diff --git a/jscomp/common/bs_version.ml b/jscomp/common/bs_version.ml index 9ecda8d2ac..9254c2513b 100644 --- a/jscomp/common/bs_version.ml +++ b/jscomp/common/bs_version.ml @@ -22,7 +22,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -let version = "6.3.0-dev.1" +let version = "7.0.0-dev.2" let header = "// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE" let package_name = "bs-platform" diff --git a/jscomp/core/bs_conditional_initial.ml b/jscomp/core/bs_conditional_initial.ml index 29e6302ec4..6eea531b78 100644 --- a/jscomp/core/bs_conditional_initial.ml +++ b/jscomp/core/bs_conditional_initial.ml @@ -37,7 +37,10 @@ let setup_env () = Clflags.binary_annotations := true; (* Turn on [-no-alias-deps] by default -- double check *) Oprint.out_ident := Outcome_printer_ns.out_ident; - + Builtin_attributes.check_bs_attributes_inclusion := Record_attributes_check.check_bs_attributes_inclusion; + Lambda.fld_record := Record_attributes_check.fld_record; + Lambda.fld_record_set := Record_attributes_check.fld_record_set; + Lambda.blk_record := Record_attributes_check.blk_record; #if undefined BS_RELEASE_BUILD then Printexc.record_backtrace true; (match Ext_sys.getenv_opt "BS_DEBUG_FILE" with diff --git a/jscomp/core/js_dump.ml b/jscomp/core/js_dump.ml index 6f2583ac43..bee935b73e 100644 --- a/jscomp/core/js_dump.ml +++ b/jscomp/core/js_dump.ml @@ -811,8 +811,9 @@ and expression_desc cxt ~(level:int) f x : cxt = (Ext_list.map_combine fields el Ext_ident.convert))) | Caml_block(el,_, _, Blk_record fields) -> expression_desc cxt ~level f (Object ( - (Ext_list.map_combine (Array.to_list fields) el Ext_ident.convert))) - (*FIXME: avoid allocaton *) + (List.combine (Array.to_list fields) el ))) + (* name convention of Record is slight different from modules + *) | Caml_block( el, mutable_flag, tag, tag_info) -> (* Note that, if we ignore more than tag [0] we loose some information diff --git a/jscomp/core/js_exp_make.ml b/jscomp/core/js_exp_make.ml index 78a636c930..37d72eb988 100644 --- a/jscomp/core/js_exp_make.ml +++ b/jscomp/core/js_exp_make.ml @@ -397,7 +397,7 @@ let array_index_by_int ?comment (e : t) (pos : int32) : t = | _ -> { expression_desc = Array_index (e, int ?comment pos); comment = None} let record_access (e : t) (name : string) (pos : int32) = - let name = Ext_ident.convert name in + (* let name = Ext_ident.convert name in *) match e.expression_desc with | Array (l,_) (* Float i -- should not appear here *) | Caml_block (l,_, _, _) when no_side_effect e diff --git a/jscomp/core/js_of_lam_block.ml b/jscomp/core/js_of_lam_block.ml index fd352bfce3..3949bdd3d1 100644 --- a/jscomp/core/js_of_lam_block.ml +++ b/jscomp/core/js_of_lam_block.ml @@ -60,7 +60,7 @@ let field (field_info : Lam_compat.field_dbg_info) e i = -> E.array_index_by_int ~comment e i #end - | Fld_record name + | Fld_record {name} -> E.record_access e name i | Fld_module name -> E.module_access e name i diff --git a/jscomp/core/lam_compat.ml b/jscomp/core/lam_compat.ml index d2008c3396..e582f0e2cd 100644 --- a/jscomp/core/lam_compat.ml +++ b/jscomp/core/lam_compat.ml @@ -184,7 +184,7 @@ type meth_kind = Lambda.meth_kind type field_dbg_info = Lambda.field_dbg_info = | Fld_na - | Fld_record of string + | Fld_record of {name : string; mutable_flag : Asttypes.mutable_flag} | Fld_module of string #if OCAML_VERSION =~ ">4.03.0" then | Fld_record_inline of string @@ -195,7 +195,7 @@ let str_of_field_info (x : field_dbg_info) : string option = match x with | Fld_na | Fld_tuple -> None - | Fld_record s + | Fld_record {name = s} | Fld_module s | Fld_record_inline s | Fld_record_extension s diff --git a/jscomp/core/lam_compat.mli b/jscomp/core/lam_compat.mli index 70eb7c0c4b..f49b8fdf74 100644 --- a/jscomp/core/lam_compat.mli +++ b/jscomp/core/lam_compat.mli @@ -85,7 +85,7 @@ type meth_kind = Lambda.meth_kind type field_dbg_info = Lambda.field_dbg_info = | Fld_na - | Fld_record of string + | Fld_record of {name : string; mutable_flag : Asttypes.mutable_flag} | Fld_module of string #if OCAML_VERSION =~ ">4.03.0" then | Fld_record_inline of string diff --git a/jscomp/core/record_attributes_check.ml b/jscomp/core/record_attributes_check.ml new file mode 100644 index 0000000000..bbbb785433 --- /dev/null +++ b/jscomp/core/record_attributes_check.ml @@ -0,0 +1,61 @@ +(* Copyright (C) 2019- Authors of BuckleScript + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) + +type label = Types.label_description + +let fn = (fun (attr : Parsetree.attribute) -> +match attr with +| {txt = "bs.as"}, PStr + [{pstr_desc = Pstr_eval ({pexp_desc = Pexp_constant (Pconst_string(s,_))},_ )}] -> + (* Bs_ast_invariant.mark_used_bs_attribute attr; *) + Some s +| _ -> None +) + +let fld_record (lbl : label) = + Lambda.Fld_record + {name = Ext_list.find_def lbl.lbl_attributes fn lbl.lbl_name; mutable_flag = lbl.Types.lbl_mut} + +let fld_record_set (lbl : label) = + Lambda.Fld_record_set + (Ext_list.find_def lbl.lbl_attributes fn lbl.lbl_name) + +let blk_record fields = + let all_labels_info = + Ext_array.map fields + (fun ((lbl : label),_) -> + Ext_list.find_def lbl.Types.lbl_attributes fn lbl.lbl_name) in + Lambda.Blk_record all_labels_info + +let check_bs_attributes_inclusion + (attrs1 : Parsetree.attributes) + (attrs2 : Parsetree.attributes) + lbl_name = + let a = Ext_list.find_def attrs1 fn lbl_name in + let b = Ext_list.find_def attrs2 fn lbl_name in + if a = b then None + else Some (a,b) + + + diff --git a/jscomp/ext/ext_list.ml b/jscomp/ext/ext_list.ml index 11a1fa7a63..04d801d115 100644 --- a/jscomp/ext/ext_list.ml +++ b/jscomp/ext/ext_list.ml @@ -583,7 +583,13 @@ let rec find_opt xs p = | Some _ as v -> v | None -> find_opt l p - +let rec find_def xs p def = + match xs with + | [] -> def + | x::l -> + match p x with + | Some v -> v + | None -> find_def l p def let rec split_map l f = match l with diff --git a/jscomp/ext/ext_list.mli b/jscomp/ext/ext_list.mli index 432e1efb5c..5f15649419 100644 --- a/jscomp/ext/ext_list.mli +++ b/jscomp/ext/ext_list.mli @@ -259,7 +259,13 @@ val find_opt : ('a -> 'b option) -> 'b option +val find_def : + 'a list -> + ('a -> 'b option) -> + 'b -> + 'b + val rev_iter : 'a list -> ('a -> unit) -> diff --git a/jscomp/syntax/bs_ast_invariant.ml b/jscomp/syntax/bs_ast_invariant.ml index a6517c097a..126f1c305f 100644 --- a/jscomp/syntax/bs_ast_invariant.ml +++ b/jscomp/syntax/bs_ast_invariant.ml @@ -117,6 +117,16 @@ let emit_external_warnings : iterator= #end | _ -> default_iterator.expr self a ); + label_declaration = (fun self lbl -> + + Ext_list.iter lbl.pld_attributes + (fun attr -> + match attr with + | {txt = "bs.as"}, _ -> mark_used_bs_attribute attr + | _ -> () + ); + default_iterator.label_declaration self lbl + ); value_description = (fun self v -> match v with diff --git a/jscomp/test/build.ninja b/jscomp/test/build.ninja index c28bd6ff90..ca62612873 100644 --- a/jscomp/test/build.ninja +++ b/jscomp/test/build.ninja @@ -496,6 +496,7 @@ build test/rec_module_test.cmi test/rec_module_test.cmj : cc test/rec_module_tes build test/rec_value_test.cmi test/rec_value_test.cmj : cc test/rec_value_test.ml | test/mt.cmj $stdlib build test/record_debug_test.cmi test/record_debug_test.cmj : cc test/record_debug_test.ml | $stdlib build test/record_extension_test.cmi test/record_extension_test.cmj : cc test/record_extension_test.ml | test/mt.cmj $stdlib +build test/record_name_test.cmi test/record_name_test.cmj : cc test/record_name_test.ml | $stdlib build test/record_with_test.cmi test/record_with_test.cmj : cc test/record_with_test.ml | test/mt.cmj $stdlib build test/recursive_module.cmi test/recursive_module.cmj : cc test/recursive_module.ml | test/mt.cmj $stdlib build test/recursive_module_test.cmi test/recursive_module_test.cmj : cc test/recursive_module_test.ml | test/mt.cmj $stdlib diff --git a/jscomp/test/flow_parser_reg_test.js b/jscomp/test/flow_parser_reg_test.js index 9ed4d4217b..c023ba6ca7 100644 --- a/jscomp/test/flow_parser_reg_test.js +++ b/jscomp/test/flow_parser_reg_test.js @@ -5084,7 +5084,7 @@ function init_env($staropt$star, $staropt$star$1, source, content) { contents: /* [] */0 }, labels: /* Empty */0, - $$exports: { + exports: { contents: /* Empty */0 }, last_loc: { @@ -5152,14 +5152,14 @@ function comment_list(env) { function record_export(env, param) { var export_name = param[1]; - var $$exports = env.$$exports.contents; + var $$exports = env.exports.contents; if (mem(export_name, $$exports)) { return error_at(env, /* tuple */[ param[0], /* DuplicateExport */Block.__(7, [export_name]) ]); } else { - env.$$exports.contents = add(export_name, env.$$exports.contents); + env.exports.contents = add(export_name, env.exports.contents); return /* () */0; } } @@ -6843,7 +6843,7 @@ function method_property(env, start_loc, $$static, key) { key: key, value: value$1, optional: false, - $$static: $$static, + static: $$static, _method: true } ]; @@ -6855,7 +6855,7 @@ function call_property(env, start_loc, $$static) { btwn(start_loc, value[0]), { value: value, - $$static: $$static + static: $$static } ]; } @@ -6873,7 +6873,7 @@ function property(env, start_loc, $$static, key) { key: key, value: value, optional: optional, - $$static: $$static, + static: $$static, _method: false } ]; @@ -6893,7 +6893,7 @@ function indexer_property(env, start_loc, $$static) { id: match[0], key: key, value: value, - $$static: $$static + static: $$static } ]; } @@ -7134,7 +7134,7 @@ function params(env, allow_default, _require_default, _acc) { name: id.name, bound: id.typeAnnotation, variance: variance, - $$default: match$3[0] + default: match$3[0] }; var param = /* tuple */[ loc, @@ -8067,7 +8067,7 @@ function call(env, _left) { btwn(left[0], match$1[0]), /* Call */Block.__(12, [{ callee: left, - $$arguments: match$1[1] + arguments: match$1[1] }]) ]; continue ; @@ -8136,7 +8136,7 @@ function _new(env, _finish_fn) { var callee$prime_000 = btwn(start_loc, match[0]); var callee$prime_001 = /* New */Block.__(11, [{ callee: callee, - $$arguments: match[1] + arguments: match[1] }]); var callee$prime = /* tuple */[ callee$prime_000, @@ -10104,7 +10104,7 @@ function init$1(env, start_loc, decorators, key, async, generator, $$static) { key: key, value: value, typeAnnotation: typeAnnotation, - $$static: $$static + static: $$static } ]]); } @@ -10164,7 +10164,7 @@ function init$1(env, start_loc, decorators, key, async, generator, $$static) { kind: kind, key: key, value: value$1, - $$static: $$static, + static: $$static, decorators: decorators } ]]); @@ -10210,7 +10210,7 @@ function class_element(env) { kind: /* Get */2, key: match$2[0], value: value, - $$static: $$static$1, + static: $$static$1, decorators: decorators$1 } ]]); @@ -10247,7 +10247,7 @@ function class_element(env) { kind: /* Set */3, key: match$4[0], value: value$1, - $$static: $$static$2, + static: $$static$2, decorators: decorators$2 } ]]); @@ -10364,7 +10364,7 @@ function class_declaration(env, decorators) { superClass: match$2[1], typeParameters: typeParameters, superTypeParameters: match$2[2], - $$implements: match$2[3], + implements: match$2[3], classDecorators: decorators$1 }]) ]; @@ -10418,7 +10418,7 @@ function class_expression(env) { superClass: match$2[1], typeParameters: match$1[1], superTypeParameters: match$2[2], - $$implements: match$2[3], + implements: match$2[3], classDecorators: decorators }]) ]; @@ -10587,7 +10587,7 @@ function declare_export_declaration($staropt$star, env) { return /* tuple */[ btwn(start_loc, end_loc), /* DeclareExportDeclaration */Block.__(27, [{ - $$default: false, + default: false, declaration: undefined, specifiers: specifiers, source: source$1 @@ -10601,7 +10601,7 @@ function declare_export_declaration($staropt$star, env) { return /* tuple */[ loc$1, /* DeclareExportDeclaration */Block.__(27, [{ - $$default: false, + default: false, declaration: /* NamedType */Block.__(4, [/* tuple */[ alias_loc, match$2[1] @@ -10621,7 +10621,7 @@ function declare_export_declaration($staropt$star, env) { return /* tuple */[ loc$2, /* DeclareExportDeclaration */Block.__(27, [{ - $$default: false, + default: false, declaration: /* Interface */Block.__(5, [/* tuple */[ iface_loc, match$3[1] @@ -10674,7 +10674,7 @@ function declare_export_declaration($staropt$star, env) { return /* tuple */[ btwn(start_loc, match$5[0]), /* DeclareExportDeclaration */Block.__(27, [{ - $$default: true, + default: true, declaration: match$5[1], specifiers: undefined, source: undefined @@ -10747,7 +10747,7 @@ function declare_export_declaration($staropt$star, env) { return /* tuple */[ btwn(start_loc, end_loc$3), /* DeclareExportDeclaration */Block.__(27, [{ - $$default: false, + default: false, declaration: undefined, specifiers: specifiers$1, source: source$2 @@ -10817,7 +10817,7 @@ function declare_export_declaration($staropt$star, env) { return /* tuple */[ btwn(start_loc, match$10[0]), /* DeclareExportDeclaration */Block.__(27, [{ - $$default: false, + default: false, declaration: match$10[1], specifiers: undefined, source: undefined @@ -11141,7 +11141,7 @@ function interface_helper(env) { id: id, typeParameters: typeParameters, body: body, - $$extends: $$extends, + extends: $$extends, mixins: /* [] */0 } ]; @@ -11266,7 +11266,7 @@ function declare_class(env, start_loc) { id: id, typeParameters: typeParameters, body: body, - $$extends: $$extends, + extends: $$extends, mixins: mixins } ]; @@ -12417,7 +12417,7 @@ function module_item(env) { return /* tuple */[ btwn(start_loc, end_loc), /* ExportDeclaration */Block.__(28, [{ - $$default: false, + default: false, declaration: /* Declaration */Block.__(0, [$$interface$1]), specifiers: undefined, source: undefined, @@ -12451,7 +12451,7 @@ function module_item(env) { return /* tuple */[ btwn(start_loc, end_loc$1), /* ExportDeclaration */Block.__(28, [{ - $$default: false, + default: false, declaration: /* Declaration */Block.__(0, [type_alias$1]), specifiers: undefined, source: undefined, @@ -12495,7 +12495,7 @@ function module_item(env) { return /* tuple */[ btwn(start_loc, end_loc$2), /* ExportDeclaration */Block.__(28, [{ - $$default: false, + default: false, declaration: undefined, specifiers: specifiers, source: source$2, @@ -12544,7 +12544,7 @@ function module_item(env) { return /* tuple */[ btwn(start_loc, match$6[0]), /* ExportDeclaration */Block.__(28, [{ - $$default: true, + default: true, declaration: match$6[1], specifiers: undefined, source: undefined, @@ -12608,7 +12608,7 @@ function module_item(env) { return /* tuple */[ btwn(start_loc, end_loc$5), /* ExportDeclaration */Block.__(28, [{ - $$default: false, + default: false, declaration: undefined, specifiers: specifiers$1, source: source$3, @@ -12688,7 +12688,7 @@ function module_item(env) { return /* tuple */[ btwn(start_loc, stmt[0]), /* ExportDeclaration */Block.__(28, [{ - $$default: false, + default: false, declaration: declaration, specifiers: undefined, source: undefined, @@ -14751,7 +14751,7 @@ function parse(content, options) { ], /* tuple */[ "arguments", - array_of_list(expression_or_spread, _new.$$arguments) + array_of_list(expression_or_spread, _new.arguments) ] ]); case /* Call */12 : @@ -14763,7 +14763,7 @@ function parse(content, options) { ], /* tuple */[ "arguments", - array_of_list(expression_or_spread, call.$$arguments) + array_of_list(expression_or_spread, call.arguments) ] ]); case /* Member */13 : @@ -14895,7 +14895,7 @@ function parse(content, options) { ], /* tuple */[ "implements", - array_of_list(class_implements, c.$$implements) + array_of_list(class_implements, c.implements) ], /* tuple */[ "decorators", @@ -15438,7 +15438,7 @@ function parse(content, options) { ], /* tuple */[ "implements", - array_of_list(class_implements, c.$$implements) + array_of_list(class_implements, c.implements) ], /* tuple */[ "decorators", @@ -15525,7 +15525,7 @@ function parse(content, options) { return node("DeclareExportDeclaration", loc, /* array */[ /* tuple */[ "default", - Curry._1(bool, $$export.$$default) + Curry._1(bool, $$export.default) ], /* tuple */[ "declaration", @@ -15553,7 +15553,7 @@ function parse(content, options) { return node("ExportDeclaration", loc, /* array */[ /* tuple */[ "default", - Curry._1(bool, $$export$1.$$default) + Curry._1(bool, $$export$1.default) ], /* tuple */[ "declaration", @@ -15661,7 +15661,7 @@ function parse(content, options) { ], /* tuple */[ "extends", - array_of_list(interface_extends, i.$$extends) + array_of_list(interface_extends, i.extends) ] ]); }; @@ -15738,7 +15738,7 @@ function parse(content, options) { ], /* tuple */[ "extends", - array_of_list(interface_extends, d.$$extends) + array_of_list(interface_extends, d.extends) ] ]); }; @@ -15766,7 +15766,7 @@ function parse(content, options) { ], /* tuple */[ "default", - option(_type, tp.$$default) + option(_type, tp.default) ] ]); }; @@ -16164,7 +16164,7 @@ function parse(content, options) { ], /* tuple */[ "static", - Curry._1(bool, prop.$$static) + Curry._1(bool, prop.static) ] ]); }; @@ -16177,7 +16177,7 @@ function parse(content, options) { ], /* tuple */[ "static", - Curry._1(bool, callProperty.$$static) + Curry._1(bool, callProperty.static) ] ]); }; @@ -16198,7 +16198,7 @@ function parse(content, options) { ], /* tuple */[ "static", - Curry._1(bool, indexer.$$static) + Curry._1(bool, indexer.static) ] ]); }; @@ -16297,7 +16297,7 @@ function parse(content, options) { ], /* tuple */[ "static", - Curry._1(bool, prop.$$static) + Curry._1(bool, prop.static) ] ]); } else { @@ -16357,7 +16357,7 @@ function parse(content, options) { ], /* tuple */[ "static", - Curry._1(bool, method_.$$static) + Curry._1(bool, method_.static) ], /* tuple */[ "computed", diff --git a/jscomp/test/key_word_property.js b/jscomp/test/key_word_property.js index 0bbc5408a3..5b260654ec 100644 --- a/jscomp/test/key_word_property.js +++ b/jscomp/test/key_word_property.js @@ -17,8 +17,8 @@ function mk($$window, $$default) { function mk2($$window, $$default) { return /* :: */[ { - $$window: $$window, - $$default: $$default + window: $$window, + default: $$default }, /* [] */0 ]; diff --git a/jscomp/test/ocaml_proto_test.js b/jscomp/test/ocaml_proto_test.js index bb3dbb6db9..1bc4f0865b 100644 --- a/jscomp/test/ocaml_proto_test.js +++ b/jscomp/test/ocaml_proto_test.js @@ -79,7 +79,7 @@ function message(content, message_name) { function $$import($$public, file_name) { return { file_name: file_name, - $$public: $$public !== undefined + public: $$public !== undefined }; } @@ -97,52 +97,52 @@ function proto(syntax, file_option, $$package, $$import, message, $$enum, proto$ syntax: syntax, imports: /* [] */0, file_options: /* [] */0, - $$package: undefined, + package: undefined, messages: /* [] */0, enums: /* [] */0, - $$extends: /* [] */0 + extends: /* [] */0 }); var proto$3 = syntax !== undefined ? ({ syntax: syntax, imports: proto$2.imports, file_options: proto$2.file_options, - $$package: proto$2.$$package, + package: proto$2.package, messages: proto$2.messages, enums: proto$2.enums, - $$extends: proto$2.$$extends + extends: proto$2.extends }) : proto$2; var proto$4 = $$package !== undefined ? ({ syntax: proto$3.syntax, imports: proto$3.imports, file_options: proto$3.file_options, - $$package: $$package, + package: $$package, messages: proto$3.messages, enums: proto$3.enums, - $$extends: proto$3.$$extends + extends: proto$3.extends }) : proto$3; var proto$5 = message !== undefined ? ({ syntax: proto$4.syntax, imports: proto$4.imports, file_options: proto$4.file_options, - $$package: proto$4.$$package, + package: proto$4.package, messages: /* :: */[ message, proto$2.messages ], enums: proto$4.enums, - $$extends: proto$4.$$extends + extends: proto$4.extends }) : proto$4; var proto$6 = $$enum !== undefined ? ({ syntax: proto$5.syntax, imports: proto$5.imports, file_options: proto$5.file_options, - $$package: proto$5.$$package, + package: proto$5.package, messages: proto$5.messages, enums: /* :: */[ $$enum, proto$2.enums ], - $$extends: proto$5.$$extends + extends: proto$5.extends }) : proto$5; var proto$7 = $$import !== undefined ? ({ syntax: proto$6.syntax, @@ -151,10 +151,10 @@ function proto(syntax, file_option, $$package, $$import, message, $$enum, proto$ proto$2.imports ], file_options: proto$6.file_options, - $$package: proto$6.$$package, + package: proto$6.package, messages: proto$6.messages, enums: proto$6.enums, - $$extends: proto$6.$$extends + extends: proto$6.extends }) : proto$6; var proto$8 = file_option !== undefined ? ({ syntax: proto$7.syntax, @@ -163,22 +163,22 @@ function proto(syntax, file_option, $$package, $$import, message, $$enum, proto$ file_option, proto$2.file_options ], - $$package: proto$7.$$package, + package: proto$7.package, messages: proto$7.messages, enums: proto$7.enums, - $$extends: proto$7.$$extends + extends: proto$7.extends }) : proto$7; if (extend !== undefined) { return { syntax: proto$8.syntax, imports: proto$8.imports, file_options: proto$8.file_options, - $$package: proto$8.$$package, + package: proto$8.package, messages: proto$8.messages, enums: proto$8.enums, - $$extends: /* :: */[ + extends: /* :: */[ extend, - proto$2.$$extends + proto$2.extends ] }; } else { @@ -4380,7 +4380,7 @@ function compile_message_p1(file_name, file_options, message_scope, param) { function compile_proto_p1(file_name, param) { var file_options = param.file_options; - var scope = scope_of_package(param.$$package); + var scope = scope_of_package(param.package); var pbtt_msgs = List.fold_right((function (e, pbtt_msgs) { return /* :: */[ compile_enum_p1(file_name, file_options, scope, e), diff --git a/jscomp/test/ocaml_re_test.js b/jscomp/test/ocaml_re_test.js index 5cab156749..a4766c7ea8 100644 --- a/jscomp/test/ocaml_re_test.js +++ b/jscomp/test/ocaml_re_test.js @@ -1451,7 +1451,7 @@ var unknown_state = { idx: -2, real_idx: 0, next: dummy_next, - $$final: /* [] */0, + final: /* [] */0, desc: Re_automata_State.dummy }; @@ -1462,7 +1462,7 @@ function mk_state(ncol, desc) { idx: break_state ? -3 : desc.idx, real_idx: desc.idx, next: break_state ? dummy_next : Caml_array.caml_make_vect(ncol, unknown_state), - $$final: /* [] */0, + final: /* [] */0, desc: desc }; } @@ -1541,7 +1541,7 @@ function loop(info, s, pos, st) { function $$final(info, st, cat) { try { - return List.assq(cat, st.$$final); + return List.assq(cat, st.final); } catch (exn){ if (exn === Caml_builtin_exceptions.not_found) { @@ -1557,7 +1557,7 @@ function $$final(info, st, cat) { cat, res ], - st.$$final + st.final ]; return res; } else { diff --git a/jscomp/test/ocaml_typedtree_test.js b/jscomp/test/ocaml_typedtree_test.js index 76fb059e2c..a22f2968be 100644 --- a/jscomp/test/ocaml_typedtree_test.js +++ b/jscomp/test/ocaml_typedtree_test.js @@ -7928,13 +7928,13 @@ function map_opt(f, param) { function map_loc(sub, param) { return { txt: param.txt, - loc: Curry._2(sub.$$location, sub, param.loc) + loc: Curry._2(sub.location, sub, param.loc) }; } function map$1(sub, param) { var desc = param.ptyp_desc; - var loc = Curry._2(sub.$$location, sub, param.ptyp_loc); + var loc = Curry._2(sub.location, sub, param.ptyp_loc); var attrs = Curry._2(sub.attributes, sub, param.ptyp_attributes); if (typeof desc === "number") { return mk(loc, attrs, /* Ptyp_any */0); @@ -7995,10 +7995,10 @@ function map$1(sub, param) { function map_type_declaration(sub, param) { var partial_arg = Curry._1(sub.typ, sub); - var partial_arg$1 = Curry._1(sub.$$location, sub); + var partial_arg$1 = Curry._1(sub.location, sub); var partial_arg$2 = Curry._1(sub.typ, sub); var partial_arg$3 = Curry._1(sub.typ, sub); - return mk$19(Curry._2(sub.$$location, sub, param.ptype_loc), Curry._2(sub.attributes, sub, param.ptype_attributes), undefined, undefined, List.map((function (param) { + return mk$19(Curry._2(sub.location, sub, param.ptype_loc), Curry._2(sub.attributes, sub, param.ptype_attributes), undefined, undefined, List.map((function (param) { return map_fst(partial_arg, param); }), param.ptype_params), List.map((function (param) { var f1 = partial_arg$3; @@ -8046,12 +8046,12 @@ function map_extension_constructor_kind(sub, param) { } function map_extension_constructor(sub, param) { - return constructor$1(Curry._2(sub.$$location, sub, param.pext_loc), Curry._2(sub.attributes, sub, param.pext_attributes), undefined, undefined, map_loc(sub, param.pext_name), map_extension_constructor_kind(sub, param.pext_kind)); + return constructor$1(Curry._2(sub.location, sub, param.pext_loc), Curry._2(sub.attributes, sub, param.pext_attributes), undefined, undefined, map_loc(sub, param.pext_name), map_extension_constructor_kind(sub, param.pext_kind)); } function map$2(sub, param) { var desc = param.pcty_desc; - var loc = Curry._2(sub.$$location, sub, param.pcty_loc); + var loc = Curry._2(sub.location, sub, param.pcty_loc); var attrs = Curry._2(sub.attributes, sub, param.pcty_attributes); switch (desc.tag | 0) { case /* Pcty_constr */0 : @@ -8068,7 +8068,7 @@ function map$2(sub, param) { function map_field(sub, param) { var desc = param.pctf_desc; - var loc = Curry._2(sub.$$location, sub, param.pctf_loc); + var loc = Curry._2(sub.location, sub, param.pctf_loc); var attrs = Curry._2(sub.attributes, sub, param.pctf_attributes); switch (desc.tag | 0) { case /* Pctf_inherit */0 : @@ -8099,7 +8099,7 @@ function map_signature(sub, param) { function map$3(sub, param) { var desc = param.pmty_desc; - var loc = Curry._2(sub.$$location, sub, param.pmty_loc); + var loc = Curry._2(sub.location, sub, param.pmty_loc); var attrs = Curry._2(sub.attributes, sub, param.pmty_attributes); switch (desc.tag | 0) { case /* Pmty_ident */0 : @@ -8145,7 +8145,7 @@ function map_with_constraint(sub, param) { function map_signature_item(sub, param) { var desc = param.psig_desc; - var loc = Curry._2(sub.$$location, sub, param.psig_loc); + var loc = Curry._2(sub.location, sub, param.psig_loc); switch (desc.tag | 0) { case /* Psig_value */0 : var a = Curry._2(sub.value_description, sub, desc[0]); @@ -8191,7 +8191,7 @@ function map_signature_item(sub, param) { function map$4(sub, param) { var desc = param.pmod_desc; - var loc = Curry._2(sub.$$location, sub, param.pmod_loc); + var loc = Curry._2(sub.location, sub, param.pmod_loc); var attrs = Curry._2(sub.attributes, sub, param.pmod_attributes); switch (desc.tag | 0) { case /* Pmod_ident */0 : @@ -8214,7 +8214,7 @@ function map$4(sub, param) { function map_structure_item(sub, param) { var desc = param.pstr_desc; - var loc = Curry._2(sub.$$location, sub, param.pstr_loc); + var loc = Curry._2(sub.location, sub, param.pstr_loc); switch (desc.tag | 0) { case /* Pstr_eval */0 : return $$eval(loc, Curry._2(sub.attributes, sub, desc[1]), Curry._2(sub.expr, sub, desc[0])); @@ -8264,7 +8264,7 @@ function map_structure_item(sub, param) { function map$5(sub, param) { var desc = param.pexp_desc; - var loc = Curry._2(sub.$$location, sub, param.pexp_loc); + var loc = Curry._2(sub.location, sub, param.pexp_loc); var attrs = Curry._2(sub.attributes, sub, param.pexp_attributes); switch (desc.tag | 0) { case /* Pexp_ident */0 : @@ -8354,7 +8354,7 @@ function map$5(sub, param) { function map$6(sub, param) { var desc = param.ppat_desc; - var loc = Curry._2(sub.$$location, sub, param.ppat_loc); + var loc = Curry._2(sub.location, sub, param.ppat_loc); var attrs = Curry._2(sub.attributes, sub, param.ppat_attributes); if (typeof desc === "number") { return mk$1(loc, attrs, /* Ppat_any */0); @@ -8404,7 +8404,7 @@ function map$6(sub, param) { function map$7(sub, param) { var desc = param.pcl_desc; - var loc = Curry._2(sub.$$location, sub, param.pcl_loc); + var loc = Curry._2(sub.location, sub, param.pcl_loc); var attrs = Curry._2(sub.attributes, sub, param.pcl_attributes); switch (desc.tag | 0) { case /* Pcl_constr */0 : @@ -8441,7 +8441,7 @@ function map_kind(sub, param) { function map_field$1(sub, param) { var desc = param.pcf_desc; - var loc = Curry._2(sub.$$location, sub, param.pcf_loc); + var loc = Curry._2(sub.location, sub, param.pcf_loc); var attrs = Curry._2(sub.attributes, sub, param.pcf_attributes); switch (desc.tag | 0) { case /* Pcf_inherit */0 : @@ -8474,7 +8474,7 @@ function map_structure(sub, param) { function class_infos(sub, f, param) { var partial_arg = Curry._1(sub.typ, sub); - return mk$18(Curry._2(sub.$$location, sub, param.pci_loc), Curry._2(sub.attributes, sub, param.pci_attributes), undefined, undefined, param.pci_virt, List.map((function (param) { + return mk$18(Curry._2(sub.location, sub, param.pci_loc), Curry._2(sub.attributes, sub, param.pci_attributes), undefined, undefined, param.pci_virt, List.map((function (param) { return map_fst(partial_arg, param); }), param.pci_params), map_loc(sub, param.pci_name), Curry._1(f, param.pci_expr)); } @@ -8499,7 +8499,7 @@ function default_mapper_case($$this, param) { } function default_mapper_cases($$this, l) { - return List.map(Curry._1($$this.$$case, $$this), l); + return List.map(Curry._1($$this.case, $$this), l); } function default_mapper_class_declaration($$this) { @@ -8524,7 +8524,7 @@ function default_mapper_class_type_declaration($$this) { } function default_mapper_constructor_declaration($$this, param) { - return constructor(Curry._2($$this.$$location, $$this, param.pcd_loc), Curry._2($$this.attributes, $$this, param.pcd_attributes), undefined, List.map(Curry._1($$this.typ, $$this), param.pcd_args), map_opt(Curry._1($$this.typ, $$this), param.pcd_res), map_loc($$this, param.pcd_name)); + return constructor(Curry._2($$this.location, $$this, param.pcd_loc), Curry._2($$this.attributes, $$this, param.pcd_attributes), undefined, List.map(Curry._1($$this.typ, $$this), param.pcd_args), map_opt(Curry._1($$this.typ, $$this), param.pcd_res), map_loc($$this, param.pcd_name)); } function default_mapper_extension($$this, param) { @@ -8535,15 +8535,15 @@ function default_mapper_extension($$this, param) { } function default_mapper_include_declaration($$this, param) { - return mk$16(Curry._2($$this.$$location, $$this, param.pincl_loc), Curry._2($$this.attributes, $$this, param.pincl_attributes), undefined, Curry._2($$this.module_expr, $$this, param.pincl_mod)); + return mk$16(Curry._2($$this.location, $$this, param.pincl_loc), Curry._2($$this.attributes, $$this, param.pincl_attributes), undefined, Curry._2($$this.module_expr, $$this, param.pincl_mod)); } function default_mapper_include_description($$this, param) { - return mk$16(Curry._2($$this.$$location, $$this, param.pincl_loc), Curry._2($$this.attributes, $$this, param.pincl_attributes), undefined, Curry._2($$this.module_type, $$this, param.pincl_mod)); + return mk$16(Curry._2($$this.location, $$this, param.pincl_loc), Curry._2($$this.attributes, $$this, param.pincl_attributes), undefined, Curry._2($$this.module_type, $$this, param.pincl_mod)); } function default_mapper_label_declaration($$this, param) { - return field$1(Curry._2($$this.$$location, $$this, param.pld_loc), Curry._2($$this.attributes, $$this, param.pld_attributes), undefined, param.pld_mutable, map_loc($$this, param.pld_name), Curry._2($$this.typ, $$this, param.pld_type)); + return field$1(Curry._2($$this.location, $$this, param.pld_loc), Curry._2($$this.attributes, $$this, param.pld_attributes), undefined, param.pld_mutable, map_loc($$this, param.pld_name), Curry._2($$this.typ, $$this, param.pld_type)); } function default_mapper_location($$this, l) { @@ -8551,19 +8551,19 @@ function default_mapper_location($$this, l) { } function default_mapper_module_binding($$this, param) { - return mk$14(Curry._2($$this.$$location, $$this, param.pmb_loc), Curry._2($$this.attributes, $$this, param.pmb_attributes), undefined, undefined, map_loc($$this, param.pmb_name), Curry._2($$this.module_expr, $$this, param.pmb_expr)); + return mk$14(Curry._2($$this.location, $$this, param.pmb_loc), Curry._2($$this.attributes, $$this, param.pmb_attributes), undefined, undefined, map_loc($$this, param.pmb_name), Curry._2($$this.module_expr, $$this, param.pmb_expr)); } function default_mapper_module_declaration($$this, param) { - return mk$12(Curry._2($$this.$$location, $$this, param.pmd_loc), Curry._2($$this.attributes, $$this, param.pmd_attributes), undefined, undefined, map_loc($$this, param.pmd_name), Curry._2($$this.module_type, $$this, param.pmd_type)); + return mk$12(Curry._2($$this.location, $$this, param.pmd_loc), Curry._2($$this.attributes, $$this, param.pmd_attributes), undefined, undefined, map_loc($$this, param.pmd_name), Curry._2($$this.module_type, $$this, param.pmd_type)); } function default_mapper_module_type_declaration($$this, param) { - return mk$13(Curry._2($$this.$$location, $$this, param.pmtd_loc), Curry._2($$this.attributes, $$this, param.pmtd_attributes), undefined, undefined, map_opt(Curry._1($$this.module_type, $$this), param.pmtd_type), map_loc($$this, param.pmtd_name)); + return mk$13(Curry._2($$this.location, $$this, param.pmtd_loc), Curry._2($$this.attributes, $$this, param.pmtd_attributes), undefined, undefined, map_opt(Curry._1($$this.module_type, $$this), param.pmtd_type), map_loc($$this, param.pmtd_name)); } function default_mapper_open_description($$this, param) { - return mk$15(Curry._2($$this.$$location, $$this, param.popen_loc), Curry._2($$this.attributes, $$this, param.popen_attributes), undefined, param.popen_override, map_loc($$this, param.popen_lid)); + return mk$15(Curry._2($$this.location, $$this, param.popen_loc), Curry._2($$this.attributes, $$this, param.popen_attributes), undefined, param.popen_override, map_loc($$this, param.popen_lid)); } function default_mapper_payload($$this, param) { @@ -8590,17 +8590,17 @@ function default_mapper_structure($$this, l) { } function default_mapper_value_binding($$this, param) { - return mk$17(Curry._2($$this.$$location, $$this, param.pvb_loc), Curry._2($$this.attributes, $$this, param.pvb_attributes), undefined, undefined, Curry._2($$this.pat, $$this, param.pvb_pat), Curry._2($$this.expr, $$this, param.pvb_expr)); + return mk$17(Curry._2($$this.location, $$this, param.pvb_loc), Curry._2($$this.attributes, $$this, param.pvb_attributes), undefined, undefined, Curry._2($$this.pat, $$this, param.pvb_pat), Curry._2($$this.expr, $$this, param.pvb_expr)); } function default_mapper_value_description($$this, param) { - return mk$11(Curry._2($$this.$$location, $$this, param.pval_loc), Curry._2($$this.attributes, $$this, param.pval_attributes), undefined, param.pval_prim, map_loc($$this, param.pval_name), Curry._2($$this.typ, $$this, param.pval_type)); + return mk$11(Curry._2($$this.location, $$this, param.pval_loc), Curry._2($$this.attributes, $$this, param.pval_attributes), undefined, param.pval_prim, map_loc($$this, param.pval_name), Curry._2($$this.typ, $$this, param.pval_type)); } var default_mapper = { attribute: default_mapper_attribute, attributes: default_mapper_attributes, - $$case: default_mapper_case, + case: default_mapper_case, cases: default_mapper_cases, class_declaration: default_mapper_class_declaration, class_description: default_mapper_class_description, @@ -8618,7 +8618,7 @@ var default_mapper = { include_declaration: default_mapper_include_declaration, include_description: default_mapper_include_description, label_declaration: default_mapper_label_declaration, - $$location: default_mapper_location, + location: default_mapper_location, module_binding: default_mapper_module_binding, module_declaration: default_mapper_module_declaration, module_expr: map$4, diff --git a/jscomp/test/record_name_test.js b/jscomp/test/record_name_test.js new file mode 100644 index 0000000000..14d548b524 --- /dev/null +++ b/jscomp/test/record_name_test.js @@ -0,0 +1,38 @@ +'use strict'; + + +function f(x) { + return { + THIS_IS_NOT_EXPRESSIBLE_IN_BUCKLE: x + }; +} + +function set(x) { + x.THIS_IS_NOT_EXPRESSIBLE_IN_BUCKLE = 3; + return (x.THIS_IS_NOT_EXPRESSIBLE_IN_BUCKLE << 1); +} + +function f1(u) { + return u.x.x.x.y; +} + +function f2(x) { + x["x'"] = x["x'"] + 3 | 0; + return { + "x'": x["x'"] + 3 | 0 + }; +} + +function f3(x) { + x.in = x.in + 3 | 0; + return { + in: x.in + 3 | 0 + }; +} + +exports.f = f; +exports.set = set; +exports.f1 = f1; +exports.f2 = f2; +exports.f3 = f3; +/* No side effect */ diff --git a/jscomp/test/record_name_test.ml b/jscomp/test/record_name_test.ml new file mode 100644 index 0000000000..c106bedf91 --- /dev/null +++ b/jscomp/test/record_name_test.ml @@ -0,0 +1,53 @@ + +(* +To work around unused attribute checking + +- we mark it used in ppx stage +we can not mark it in parsing since it won't +works for reason +*) +type t = { + mutable x : int [@bs.as "THIS_IS_NOT_EXPRESSIBLE_IN_BUCKLE"] + (* test key word later *) +} + + + +let f x = { x} + +let set x = x.x <- 3 ; x.x * 2 + +type x = t = private { + mutable x : int [@bs.as "THIS_IS_NOT_EXPRESSIBLE_IN_BUCKLE"] +} + +type t0 = { x: t0 ; y : int} + +let f1 u = +match u with +| {x = { x = {x={y}}}} -> y + +type t1 = { + mutable x' : int +} + + +let f2 (x : t1) = + x.x' <- x.x' + 3; + {x' = x.x' + 3} + +type t2 = { + mutable x' : int [@bs.as "open"] +} + +let f3 (x : t2) = + x.x' <- x.x' + 3; + {x' = x.x' + 3} + +type t3 = { + mutable x' : int [@bs.as "in"] + } + +let f3 (x : t3) = + x.x' <- x.x' + 3; + {x' = x.x' + 3} diff --git a/jscomp/test/record_with_test.js b/jscomp/test/record_with_test.js index 0f0669daf4..2a6865b9f9 100644 --- a/jscomp/test/record_with_test.js +++ b/jscomp/test/record_with_test.js @@ -8,20 +8,20 @@ var v = { syntax: undefined, imports: 0, file_options: 0, - $$package: 0, + package: 0, messages: 0, enums: 0, - $$extends: 0 + extends: 0 }; var u_v = { syntax: undefined, imports: 0, file_options: 0, - $$package: 0, + package: 0, messages: 0, enums: 0, - $$extends: 0 + extends: 0 }; function f(g, h) { @@ -30,10 +30,10 @@ function f(g, h) { syntax: init.syntax, imports: 0, file_options: init.file_options, - $$package: init.$$package, + package: init.package, messages: init.messages, enums: init.enums, - $$extends: init.$$extends + extends: init.extends }; } @@ -58,10 +58,10 @@ var uv = { syntax: undefined, imports: 1, file_options: 0, - $$package: 0, + package: 0, messages: 0, enums: 0, - $$extends: 0 + extends: 0 }; exports.v = v; diff --git a/jscomp/test/update_record_test.js b/jscomp/test/update_record_test.js index 48ffbaa080..985c7cbfbf 100644 --- a/jscomp/test/update_record_test.js +++ b/jscomp/test/update_record_test.js @@ -55,13 +55,13 @@ eq("File \"update_record_test.ml\", line 30, characters 5-12", 1, f({ }).a0); var val0 = { - invalid_js_id$prime: 3, + "invalid_js_id'": 3, x: 2 }; function fff(x) { return { - invalid_js_id$prime: x.invalid_js_id$prime + 2 | 0, + "invalid_js_id'": x["invalid_js_id'"] + 2 | 0, x: x.x }; } @@ -70,7 +70,7 @@ var val1 = fff(val0); eq("File \"update_record_test.ml\", line 42, characters 5-12", 3, 3); -eq("File \"update_record_test.ml\", line 43, characters 5-12", val1.invalid_js_id$prime, 5); +eq("File \"update_record_test.ml\", line 43, characters 5-12", val1["invalid_js_id'"], 5); Mt.from_pair_suites("Update_record_test", suites.contents); diff --git a/lib/4.06.1/bsb.ml b/lib/4.06.1/bsb.ml index 77cb802ea5..ebd494f30f 100644 --- a/lib/4.06.1/bsb.ml +++ b/lib/4.06.1/bsb.ml @@ -55,7 +55,7 @@ end = struct * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -let version = "6.3.0-dev.1" +let version = "7.0.0-dev.2" let header = "// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE" let package_name = "bs-platform" @@ -796,7 +796,13 @@ val find_opt : ('a -> 'b option) -> 'b option +val find_def : + 'a list -> + ('a -> 'b option) -> + 'b -> + 'b + val rev_iter : 'a list -> ('a -> unit) -> @@ -1496,7 +1502,13 @@ let rec find_opt xs p = | Some _ as v -> v | None -> find_opt l p - +let rec find_def xs p def = + match xs with + | [] -> def + | x::l -> + match p x with + | Some v -> v + | None -> find_def l p def let rec split_map l f = match l with diff --git a/lib/4.06.1/bsb_helper.ml b/lib/4.06.1/bsb_helper.ml index 9d3e6134d2..049e570d5e 100644 --- a/lib/4.06.1/bsb_helper.ml +++ b/lib/4.06.1/bsb_helper.ml @@ -842,7 +842,13 @@ val find_opt : ('a -> 'b option) -> 'b option +val find_def : + 'a list -> + ('a -> 'b option) -> + 'b -> + 'b + val rev_iter : 'a list -> ('a -> unit) -> @@ -1542,7 +1548,13 @@ let rec find_opt xs p = | Some _ as v -> v | None -> find_opt l p - +let rec find_def xs p def = + match xs with + | [] -> def + | x::l -> + match p x with + | Some v -> v + | None -> find_def l p def let rec split_map l f = match l with diff --git a/lib/4.06.1/bsdep.ml b/lib/4.06.1/bsdep.ml index e153fe85f0..86d333e1c4 100644 --- a/lib/4.06.1/bsdep.ml +++ b/lib/4.06.1/bsdep.ml @@ -55,7 +55,7 @@ end = struct * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -let version = "6.3.0-dev.1" +let version = "7.0.0-dev.2" let header = "// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE" let package_name = "bs-platform" @@ -5907,6 +5907,298 @@ and directive_argument = | Pdir_ident of Longident.t | Pdir_bool of bool +end +module Builtin_attributes : sig +#1 "builtin_attributes.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Alain Frisch, LexiFi *) +(* *) +(* Copyright 2012 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) + +(* Support for some of the builtin attributes: + + ocaml.deprecated + ocaml.error + ocaml.ppwarning + ocaml.warning + ocaml.warnerror + ocaml.explicit_arity (for camlp4/camlp5) + ocaml.warn_on_literal_pattern + ocaml.deprecated_mutable + ocaml.immediate + ocaml.boxed / ocaml.unboxed +*) + + +val check_deprecated: Location.t -> Parsetree.attributes -> string -> unit +val check_deprecated_inclusion: + def:Location.t -> use:Location.t -> Location.t -> Parsetree.attributes -> + Parsetree.attributes -> string -> unit +val deprecated_of_attrs: Parsetree.attributes -> string option +val deprecated_of_sig: Parsetree.signature -> string option +val deprecated_of_str: Parsetree.structure -> string option + +val check_deprecated_mutable: + Location.t -> Parsetree.attributes -> string -> unit +val check_deprecated_mutable_inclusion: + def:Location.t -> use:Location.t -> Location.t -> Parsetree.attributes -> + Parsetree.attributes -> string -> unit + +val check_bs_attributes_inclusion: + (Parsetree.attributes -> + Parsetree.attributes -> string -> (string*string) option ) ref + +val error_of_extension: Parsetree.extension -> Location.error + +val warning_attribute: ?ppwarning:bool -> Parsetree.attribute -> unit + (** Apply warning settings from the specified attribute. + "ocaml.warning"/"ocaml.warnerror" (and variants without the prefix) + are processed and other attributes are ignored. + + Also implement ocaml.ppwarning (unless ~ppwarning:false is + passed). + *) + +val warning_scope: + ?ppwarning:bool -> + Parsetree.attributes -> (unit -> 'a) -> 'a + (** Execute a function in a new scope for warning settings. This + means that the effect of any call to [warning_attribute] during + the execution of this function will be discarded after + execution. + + The function also takes a list of attributes which are processed + with [warning_attribute] in the fresh scope before the function + is executed. + *) + +val warn_on_literal_pattern: Parsetree.attributes -> bool +val explicit_arity: Parsetree.attributes -> bool + + +val immediate: Parsetree.attributes -> bool + +val has_unboxed: Parsetree.attributes -> bool +val has_boxed: Parsetree.attributes -> bool + +end = struct +#1 "builtin_attributes.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Alain Frisch, LexiFi *) +(* *) +(* Copyright 2012 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) + +open Asttypes +open Parsetree + +let string_of_cst = function + | Pconst_string(s, _) -> Some s + | _ -> None + +let string_of_payload = function + | PStr[{pstr_desc=Pstr_eval({pexp_desc=Pexp_constant c},_)}] -> + string_of_cst c + | _ -> None + +let string_of_opt_payload p = + match string_of_payload p with + | Some s -> s + | None -> "" + +let rec error_of_extension ext = + match ext with + | ({txt = ("ocaml.error"|"error") as txt; loc}, p) -> + let rec sub_from inner = + match inner with + | {pstr_desc=Pstr_extension (ext, _)} :: rest -> + error_of_extension ext :: sub_from rest + | _ :: rest -> + (Location.errorf ~loc + "Invalid syntax for sub-error of extension '%s'." txt) :: + sub_from rest + | [] -> [] + in + begin match p with + | PStr [] -> raise Location.Already_displayed_error + | PStr({pstr_desc=Pstr_eval + ({pexp_desc=Pexp_constant(Pconst_string(msg,_))}, _)}:: + {pstr_desc=Pstr_eval + ({pexp_desc=Pexp_constant(Pconst_string(if_highlight,_))}, _)}:: + inner) -> + Location.error ~loc ~if_highlight ~sub:(sub_from inner) msg + | PStr({pstr_desc=Pstr_eval + ({pexp_desc=Pexp_constant(Pconst_string(msg,_))}, _)}::inner) -> + Location.error ~loc ~sub:(sub_from inner) msg + | _ -> Location.errorf ~loc "Invalid syntax for extension '%s'." txt + end + | ({txt; loc}, _) -> + Location.errorf ~loc "Uninterpreted extension '%s'." txt + +let cat s1 s2 = + if s2 = "" then s1 else + + if Clflags.bs_vscode then s1 ^ " " ^ s2 + else s1 ^ "\n" ^ s2 + + +let rec deprecated_of_attrs = function + | [] -> None + | ({txt = "ocaml.deprecated"|"deprecated"; _}, p) :: _ -> + Some (string_of_opt_payload p) + | _ :: tl -> deprecated_of_attrs tl + +let check_deprecated loc attrs s = + match deprecated_of_attrs attrs with + | None -> () + | Some txt -> Location.deprecated loc (cat s txt) + +let check_deprecated_inclusion ~def ~use loc attrs1 attrs2 s = + match deprecated_of_attrs attrs1, deprecated_of_attrs attrs2 with + | None, _ | Some _, Some _ -> () + | Some txt, None -> Location.deprecated ~def ~use loc (cat s txt) + +let rec deprecated_mutable_of_attrs = function + | [] -> None + | ({txt = "ocaml.deprecated_mutable"|"deprecated_mutable"; _}, p) :: _ -> + Some (string_of_opt_payload p) + | _ :: tl -> deprecated_mutable_of_attrs tl + +let check_deprecated_mutable loc attrs s = + match deprecated_mutable_of_attrs attrs with + | None -> () + | Some txt -> + Location.deprecated loc (Printf.sprintf "mutating field %s" (cat s txt)) + +let check_deprecated_mutable_inclusion ~def ~use loc attrs1 attrs2 s = + match deprecated_mutable_of_attrs attrs1, + deprecated_mutable_of_attrs attrs2 + with + | None, _ | Some _, Some _ -> () + | Some txt, None -> + Location.deprecated ~def ~use loc + (Printf.sprintf "mutating field %s" (cat s txt)) + +let check_bs_attributes_inclusion = + ref (fun _attrs1 _attrs2 _s -> + None + ) + +let rec deprecated_of_sig = function + | {psig_desc = Psig_attribute a} :: tl -> + begin match deprecated_of_attrs [a] with + | None -> deprecated_of_sig tl + | Some _ as r -> r + end + | _ -> None + + +let rec deprecated_of_str = function + | {pstr_desc = Pstr_attribute a} :: tl -> + begin match deprecated_of_attrs [a] with + | None -> deprecated_of_str tl + | Some _ as r -> r + end + | _ -> None + + +let warning_attribute ?(ppwarning = true) = + let process loc txt errflag payload = + match string_of_payload payload with + | Some s -> + begin try Warnings.parse_options errflag s + with Arg.Bad _ -> + Location.prerr_warning loc + (Warnings.Attribute_payload + (txt, "Ill-formed list of warnings")) + end + | None -> + Location.prerr_warning loc + (Warnings.Attribute_payload + (txt, "A single string literal is expected")) + in + function + | ({txt = ("ocaml.warning"|"warning") as txt; loc}, payload) -> + process loc txt false payload + | ({txt = ("ocaml.warnerror"|"warnerror") as txt; loc}, payload) -> + process loc txt true payload + | {txt="ocaml.ppwarning"|"ppwarning"}, + PStr[{pstr_desc=Pstr_eval({pexp_desc=Pexp_constant + (Pconst_string (s, _))},_); + pstr_loc}] when ppwarning -> + Location.prerr_warning pstr_loc (Warnings.Preprocessor s) + | _ -> + () + +let warning_scope ?ppwarning attrs f = + let prev = Warnings.backup () in + try + List.iter (warning_attribute ?ppwarning) (List.rev attrs); + let ret = f () in + Warnings.restore prev; + ret + with exn -> + Warnings.restore prev; + raise exn + + +let warn_on_literal_pattern = + List.exists + (function + | ({txt="ocaml.warn_on_literal_pattern"|"warn_on_literal_pattern"; _}, _) + -> true + | _ -> false + ) + +let explicit_arity = + List.exists + (function + | ({txt="ocaml.explicit_arity"|"explicit_arity"; _}, _) -> true + | _ -> false + ) + +let immediate = + List.exists + (function + | ({txt="ocaml.immediate"|"immediate"; _}, _) -> true + | _ -> false + ) + +(* The "ocaml.boxed (default)" and "ocaml.unboxed (default)" + attributes cannot be input by the user, they are added by the + compiler when applying the default setting. This is done to record + in the .cmi the default used by the compiler when compiling the + source file because the default can change between compiler + invocations. *) + +let check l (x, _) = List.mem x.txt l + +let has_unboxed attr = + List.exists (check ["ocaml.unboxed"; "unboxed"]) + attr + +let has_boxed attr = + List.exists (check ["ocaml.boxed"; "boxed"]) attr + end module Docstrings : sig #1 "docstrings.mli" @@ -24636,8 +24928,8 @@ and __ocaml_lex_skip_hash_bang_rec lexbuf __ocaml_lex_state = # 3467 "parsing/lexer.ml" end -module Bs_conditional_initial : sig -#1 "bs_conditional_initial.mli" +module Ext_array : sig +#1 "ext_array.mli" (* Copyright (C) 2015-2016 Bloomberg Finance L.P. * * This program is free software: you can redistribute it and/or modify @@ -24662,22 +24954,93 @@ module Bs_conditional_initial : sig * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -(** This function set up built in compile time variables used in - conditional compilation so that - {[ - #if BS then - #elif .. then - #end - ]} - Is understood, also make sure the playground do the same initialization. -*) -val setup_env : unit -> unit + + + +(** Some utilities for {!Array} operations *) +val reverse_range : 'a array -> int -> int -> unit +val reverse_in_place : 'a array -> unit +val reverse : 'a array -> 'a array +val reverse_of_list : 'a list -> 'a array + +val filter : ('a -> bool) -> 'a array -> 'a array + +val filter_map : ('a -> 'b option) -> 'a array -> 'b array + +val range : int -> int -> int array + +val map2i : (int -> 'a -> 'b -> 'c ) -> 'a array -> 'b array -> 'c array + +val to_list_f : + 'a array -> + ('a -> 'b) -> + 'b list + +val to_list_map : ('a -> 'b option) -> 'a array -> 'b list + +val to_list_map_acc : + 'a array -> + 'b list -> + ('a -> 'b option) -> + 'b list + +val of_list_map : + 'a list -> + ('a -> 'b) -> + 'b array + +val rfind_with_index : 'a array -> ('a -> 'b -> bool) -> 'b -> int + + +type 'a split = [ `No_split | `Split of 'a array * 'a array ] + +val rfind_and_split : + 'a array -> + ('a -> 'b -> bool) -> + 'b -> 'a split + +val find_and_split : + 'a array -> + ('a -> 'b -> bool) -> + 'b -> 'a split + +val exists : ('a -> bool) -> 'a array -> bool + +val is_empty : 'a array -> bool + +val for_all2_no_exn : + 'a array -> + 'b array -> + ('a -> 'b -> bool) -> + bool + +val map : + 'a array -> + ('a -> 'b) -> + 'b array + +val iter : + 'a array -> + ('a -> unit) -> + unit + +val fold_left : + 'b array -> + 'a -> + ('a -> 'b -> 'a) -> + 'a + +val get_or : + 'a array -> + int -> + (unit -> 'a) -> + 'a end = struct -#1 "bs_conditional_initial.ml" +#1 "ext_array.ml" (* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -24695,1635 +25058,1535 @@ end = struct * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -let setup_env () = - Clflags.compile_only := true; - Clflags.bs_only := true; - Clflags.no_implicit_current_dir := true; - (* default true - otherwise [bsc -I sc src/hello.ml ] will include current directory to search path - *) - Clflags.assume_no_mli := Clflags.Mli_non_exists; - Clflags.unsafe_string := false; - Clflags.debug := true; - Clflags.record_event_when_debug := false; - Clflags.binary_annotations := true; - (* Turn on [-no-alias-deps] by default -- double check *) - Oprint.out_ident := Outcome_printer_ns.out_ident; - Lexer.replace_directive_bool "BS" true; - Lexer.replace_directive_string "BS_VERSION" Bs_version.version - +let reverse_range a i len = + if len = 0 then () + else + for k = 0 to (len-1)/2 do + let t = Array.unsafe_get a (i+k) in + Array.unsafe_set a (i+k) ( Array.unsafe_get a (i+len-1-k)); + Array.unsafe_set a (i+len-1-k) t; + done -end -module Ccomp : sig -#1 "ccomp.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) -(* Compiling C files and building C libraries *) +let reverse_in_place a = + reverse_range a 0 (Array.length a) -val command: string -> int -val run_command: string -> unit -val compile_file: ?output:string -> ?opt:string -> string -> int -val create_archive: string -> string list -> int -val expand_libname: string -> string -val quote_files: string list -> string -val quote_optfile: string option -> string -(*val make_link_options: string list -> string*) +let reverse a = + let b_len = Array.length a in + if b_len = 0 then [||] else + let b = Array.copy a in + for i = 0 to b_len - 1 do + Array.unsafe_set b i (Array.unsafe_get a (b_len - 1 -i )) + done; + b -type link_mode = - | Exe - | Dll - | MainDll - | Partial +let reverse_of_list = function + | [] -> [||] + | hd::tl as l -> + let len = List.length l in + let a = Array.make len hd in + let rec fill i = function + | [] -> a + | hd::tl -> Array.unsafe_set a (len - i - 2) hd; fill (i+1) tl in + fill 0 tl -val call_linker: link_mode -> string -> string list -> string -> bool +let filter f a = + let arr_len = Array.length a in + let rec aux acc i = + if i = arr_len + then reverse_of_list acc + else + let v = Array.unsafe_get a i in + if f v then + aux (v::acc) (i+1) + else aux acc (i + 1) + in aux [] 0 -end = struct -#1 "ccomp.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) -(* Compiling C files and building C libraries *) +let filter_map (f : _ -> _ option) a = + let arr_len = Array.length a in + let rec aux acc i = + if i = arr_len + then reverse_of_list acc + else + let v = Array.unsafe_get a i in + match f v with + | Some v -> + aux (v::acc) (i+1) + | None -> + aux acc (i + 1) + in aux [] 0 -let command cmdline = - if !Clflags.verbose then begin - prerr_string "+ "; - prerr_string cmdline; - prerr_newline() - end; - Sys.command cmdline +let range from to_ = + if from > to_ then invalid_arg "Ext_array.range" + else Array.init (to_ - from + 1) (fun i -> i + from) -let run_command cmdline = ignore(command cmdline) +let map2i f a b = + let len = Array.length a in + if len <> Array.length b then + invalid_arg "Ext_array.map2i" + else + Array.mapi (fun i a -> f i a ( Array.unsafe_get b i )) a -(* Build @responsefile to work around Windows limitations on - command-line length *) -let build_diversion lst = - let (responsefile, oc) = Filename.open_temp_file "camlresp" "" in - List.iter (fun f -> Printf.fprintf oc "%s\n" f) lst; - close_out oc; - at_exit (fun () -> Misc.remove_file responsefile); - "@" ^ responsefile +let rec tolist_f_aux a f i res = + if i < 0 then res else + let v = Array.unsafe_get a i in + tolist_f_aux a f (i - 1) + (f v :: res) + +let to_list_f a f = tolist_f_aux a f (Array.length a - 1) [] -let quote_files lst = - let lst = List.filter (fun f -> f <> "") lst in - let quoted = List.map Filename.quote lst in - let s = String.concat " " quoted in - if String.length s >= 4096 && Sys.os_type = "Win32" - then build_diversion quoted - else s +let rec tolist_aux a f i res = + if i < 0 then res else + let v = Array.unsafe_get a i in + tolist_aux a f (i - 1) + (match f v with + | Some v -> v :: res + | None -> res) -let quote_prefixed pr lst = - let lst = List.filter (fun f -> f <> "") lst in - let lst = List.map (fun f -> pr ^ f) lst in - quote_files lst +let to_list_map f a = + tolist_aux a f (Array.length a - 1) [] -let quote_optfile = function - | None -> "" - | Some f -> Filename.quote f +let to_list_map_acc a acc f = + tolist_aux a f (Array.length a - 1) acc -let display_msvc_output file name = - let c = open_in file in - try - let first = input_line c in - if first <> Filename.basename name then - print_string first; - while true do - print_string (input_line c) - done - with _ -> - close_in c; - Sys.remove file -let compile_file ?output ?(opt="") name = - let (pipe, file) = - if Config.ccomp_type = "msvc" && not !Clflags.verbose then - try - let (t, c) = Filename.open_temp_file "msvc" "stdout" in - close_out c; - (Printf.sprintf " > %s" (Filename.quote t), t) - with _ -> - ("", "") - else - ("", "") in - let exit = - command - (Printf.sprintf - "%s %s %s -c %s %s %s %s %s%s" - (match !Clflags.c_compiler with - | Some cc -> cc - | None -> - let (cflags, cppflags) = - if !Clflags.native_code - then (Config.ocamlopt_cflags, Config.ocamlopt_cppflags) - else (Config.ocamlc_cflags, Config.ocamlc_cppflags) in - (String.concat " " [Config.c_compiler; cflags; cppflags])) - (match output with - | None -> "" - | Some o -> Printf.sprintf "%s%s" Config.c_output_obj o) - opt - (if !Clflags.debug && Config.ccomp_type <> "msvc" then "-g" else "") - (String.concat " " (List.rev !Clflags.all_ccopts)) - (quote_prefixed "-I" (List.rev !Clflags.include_dirs)) - (Clflags.std_include_flag "-I") - (Filename.quote name) - (* cl tediously includes the name of the C file as the first thing it - outputs (in fairness, the tedious thing is that there's no switch to - disable this behaviour). In the absence of the Unix module, use - a temporary file to filter the output (cannot pipe the output to a - filter because this removes the exit status of cl, which is wanted. - *) - pipe) in - if pipe <> "" - then display_msvc_output file name; - exit +let of_list_map a f = + match a with + | [] -> [||] + | [a0] -> + let b0 = f a0 in + [|b0|] + | [a0;a1] -> + let b0 = f a0 in + let b1 = f a1 in + [|b0;b1|] + | [a0;a1;a2] -> + let b0 = f a0 in + let b1 = f a1 in + let b2 = f a2 in + [|b0;b1;b2|] + | [a0;a1;a2;a3] -> + let b0 = f a0 in + let b1 = f a1 in + let b2 = f a2 in + let b3 = f a3 in + [|b0;b1;b2;b3|] + | [a0;a1;a2;a3;a4] -> + let b0 = f a0 in + let b1 = f a1 in + let b2 = f a2 in + let b3 = f a3 in + let b4 = f a4 in + [|b0;b1;b2;b3;b4|] -let macos_create_empty_archive ~quoted_archive = - let result = - command (Printf.sprintf "%s rc %s /dev/null" Config.ar quoted_archive) - in - if result <> 0 then result - else - let result = - command (Printf.sprintf "%s %s 2> /dev/null" Config.ranlib quoted_archive) - in - if result <> 0 then result - else - command (Printf.sprintf "%s d %s /dev/null" Config.ar quoted_archive) + | a0::a1::a2::a3::a4::tl -> + let b0 = f a0 in + let b1 = f a1 in + let b2 = f a2 in + let b3 = f a3 in + let b4 = f a4 in + let len = List.length tl + 5 in + let arr = Array.make len b0 in + Array.unsafe_set arr 1 b1 ; + Array.unsafe_set arr 2 b2 ; + Array.unsafe_set arr 3 b3 ; + Array.unsafe_set arr 4 b4 ; + let rec fill i = function + | [] -> arr + | hd :: tl -> + Array.unsafe_set arr i (f hd); + fill (i + 1) tl in + fill 5 tl -let create_archive archive file_list = - Misc.remove_file archive; - let quoted_archive = Filename.quote archive in - match Config.ccomp_type with - "msvc" -> - command(Printf.sprintf "link /lib /nologo /out:%s %s" - quoted_archive (quote_files file_list)) - | _ -> - assert(String.length Config.ar > 0); - let is_macosx = - match Config.system with - | "macosx" -> true - | _ -> false - in - if is_macosx && file_list = [] then (* PR#6550 *) - macos_create_empty_archive ~quoted_archive - else - let r1 = - command(Printf.sprintf "%s rc %s %s" - Config.ar quoted_archive (quote_files file_list)) in - if r1 <> 0 || String.length Config.ranlib = 0 - then r1 - else command(Config.ranlib ^ " " ^ quoted_archive) +(** + {[ + # rfind_with_index [|1;2;3|] (=) 2;; + - : int = 1 + # rfind_with_index [|1;2;3|] (=) 1;; + - : int = 0 + # rfind_with_index [|1;2;3|] (=) 3;; + - : int = 2 + # rfind_with_index [|1;2;3|] (=) 4;; + - : int = -1 + ]} +*) +let rfind_with_index arr cmp v = + let len = Array.length arr in + let rec aux i = + if i < 0 then i + else if cmp (Array.unsafe_get arr i) v then i + else aux (i - 1) in + aux (len - 1) -let expand_libname name = - if String.length name < 2 || String.sub name 0 2 <> "-l" - then name - else begin - let libname = - "lib" ^ String.sub name 2 (String.length name - 2) ^ Config.ext_lib in - try - Misc.find_in_path !Config.load_path libname - with Not_found -> - libname - end +type 'a split = [ `No_split | `Split of 'a array * 'a array ] +let rfind_and_split arr cmp v : _ split = + let i = rfind_with_index arr cmp v in + if i < 0 then + `No_split + else + `Split (Array.sub arr 0 i , Array.sub arr (i + 1 ) (Array.length arr - i - 1 )) -type link_mode = - | Exe - | Dll - | MainDll - | Partial -let remove_Wl cclibs = - cclibs |> List.map (fun cclib -> - (* -Wl,-foo,bar -> -foo bar *) - if String.length cclib >= 4 && "-Wl," = String.sub cclib 0 4 then - String.map (function ',' -> ' ' | c -> c) - (String.sub cclib 4 (String.length cclib - 4)) - else cclib) +let find_with_index arr cmp v = + let len = Array.length arr in + let rec aux i len = + if i >= len then -1 + else if cmp (Array.unsafe_get arr i ) v then i + else aux (i + 1) len in + aux 0 len -let call_linker mode output_name files extra = - let cmd = - if mode = Partial then - let l_prefix = - match Config.ccomp_type with - | "msvc" -> "/libpath:" - | _ -> "-L" - in - Printf.sprintf "%s%s %s %s %s" - Config.native_pack_linker - (Filename.quote output_name) - (quote_prefixed l_prefix !Config.load_path) - (quote_files (remove_Wl files)) - extra - else - Printf.sprintf "%s -o %s %s %s %s %s %s %s" - (match !Clflags.c_compiler, mode with - | Some cc, _ -> cc - | None, Exe -> Config.mkexe - | None, Dll -> Config.mkdll - | None, MainDll -> Config.mkmaindll - | None, Partial -> assert false - ) - (Filename.quote output_name) - (if !Clflags.gprofile then Config.cc_profile else "") - "" (*(Clflags.std_include_flag "-I")*) - (quote_prefixed "-L" !Config.load_path) - (String.concat " " (List.rev !Clflags.all_ccopts)) - (quote_files files) - extra - in - command cmd = 0 +let find_and_split arr cmp v : _ split = + let i = find_with_index arr cmp v in + if i < 0 then + `No_split + else + `Split (Array.sub arr 0 i, Array.sub arr (i + 1 ) (Array.length arr - i - 1)) -end -module Compenv : sig -#1 "compenv.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Fabrice Le Fessant, EPI Gallium, INRIA Paris-Rocquencourt *) -(* *) -(* Copyright 2013 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) - -val module_of_filename : Format.formatter -> string -> string -> string +(** TODO: available since 4.03, use {!Array.exists} *) -val output_prefix : string -> string -val extract_output : string option -> string -val default_output : string option -> string +let exists p a = + let n = Array.length a in + let rec loop i = + if i = n then false + else if p (Array.unsafe_get a i) then true + else loop (succ i) in + loop 0 -val print_version_and_library : string -> 'a -val print_version_string : unit -> 'a -val print_standard_library : unit -> 'a -val fatal : string -> 'a -val first_ccopts : string list ref -val first_ppx : string list ref -val first_include_dirs : string list ref -val last_include_dirs : string list ref -val implicit_modules : string list ref +let is_empty arr = + Array.length arr = 0 -(* function to call on plugin=XXX *) -val load_plugin : (string -> unit) ref -(* return the list of objfiles, after OCAMLPARAM and List.rev *) -val get_objfiles : with_ocamlparam:bool -> string list -val last_objfiles : string list ref -val first_objfiles : string list ref +let rec unsafe_loop index len p xs ys = + if index >= len then true + else + p + (Array.unsafe_get xs index) + (Array.unsafe_get ys index) && + unsafe_loop (succ index) len p xs ys -type filename = string +let for_all2_no_exn xs ys p = + let len_xs = Array.length xs in + let len_ys = Array.length ys in + len_xs = len_ys && + unsafe_loop 0 len_xs p xs ys -type readenv_position = - Before_args | Before_compile of filename | Before_link -val readenv : Format.formatter -> readenv_position -> unit +let map a f = + let open Array in + let l = length a in + if l = 0 then [||] else begin + let r = make l (f(unsafe_get a 0)) in + for i = 1 to l - 1 do + unsafe_set r i (f(unsafe_get a i)) + done; + r + end -(* [is_unit_name name] returns true only if [name] can be used as a - correct module name *) -val is_unit_name : string -> bool -(* [check_unit_name ppf filename name] prints a warning in [filename] - on [ppf] if [name] should not be used as a module name. *) -val check_unit_name : Format.formatter -> string -> string -> unit +let iter a f = + let open Array in + for i = 0 to length a - 1 do f(unsafe_get a i) done -(* Deferred actions of the compiler, while parsing arguments *) -type deferred_action = - | ProcessImplementation of string - | ProcessInterface of string - | ProcessCFile of string - | ProcessOtherFile of string - | ProcessObjects of string list - | ProcessDLLs of string list + let fold_left a x f = + let open Array in + let r = ref x in + for i = 0 to length a - 1 do + r := f !r (unsafe_get a i) + done; + !r + +let get_or arr i cb = + if i >=0 && i < Array.length arr then + Array.unsafe_get arr i + else cb () +end +module Ext_list : sig +#1 "ext_list.mli" +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -val c_object_of_filename : string -> string -val defer : deferred_action -> unit -val anonymous : string -> unit -val impl : string -> unit -val intf : string -> unit +val map : + 'a list -> + ('a -> 'b) -> + 'b list -val process_deferred_actions : - Format.formatter * - (Format.formatter -> string -> string -> unit) * (* compile implementation *) - (Format.formatter -> string -> string -> unit) * (* compile interface *) - string * (* ocaml module extension *) - string -> (* ocaml library extension *) - unit +val map_combine : + 'a list -> + 'b list -> + ('a -> 'c) -> + ('c * 'b) list + +val has_string : + string list -> + string -> + bool -end = struct -#1 "compenv.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Fabrice Le Fessant, EPI Gallium, INRIA Paris-Rocquencourt *) -(* *) -(* Copyright 2013 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) -open Clflags +val map_split_opt : + 'a list -> + ('a -> 'b option * 'c option) -> + 'b list * 'c list -let output_prefix name = - let oname = - match !output_name with - | None -> name - | Some n -> if !compile_only then (output_name := None; n) else name in - Filename.remove_extension oname +val mapi : + 'a list -> + (int -> 'a -> 'b) -> + 'b list + +val map_snd : ('a * 'b) list -> ('b -> 'c) -> ('a * 'c) list -let print_version_and_library compiler = - Printf.printf "The OCaml %s, version " compiler; - print_string Config.version; print_newline(); - print_string "Standard library directory: "; - print_string Config.standard_library; print_newline(); - exit 0 +(** [map_last f xs ] + will pass [true] to [f] for the last element, + [false] otherwise. + For empty list, it returns empty +*) +val map_last : + 'a list -> + (bool -> 'a -> 'b) -> 'b list -let print_version_string () = - print_string Config.version; print_newline(); exit 0 +(** [last l] + return the last element + raise if the list is empty +*) +val last : 'a list -> 'a -let print_standard_library () = - print_string Config.standard_library; print_newline(); exit 0 +val append : + 'a list -> + 'a list -> + 'a list -let fatal err = - prerr_endline err; - exit 2 +val append_one : + 'a list -> + 'a -> + 'a list -let extract_output = function - | Some s -> s - | None -> - fatal "Please specify the name of the output file, using option -o" +val map_append : + 'b list -> + 'a list -> + ('b -> 'a) -> + 'a list -let default_output = function - | Some s -> s - | None -> Config.default_executable_name +val fold_right : + 'a list -> + 'b -> + ('a -> 'b -> 'b) -> + 'b -let implicit_modules = ref [] -let first_include_dirs = ref [] -let last_include_dirs = ref [] -let first_ccopts = ref [] -let last_ccopts = ref [] -let first_ppx = ref [] -let last_ppx = ref [] -let first_objfiles = ref [] -let last_objfiles = ref [] +val fold_right2 : + 'a list -> + 'b list -> + 'c -> + ('a -> 'b -> 'c -> 'c) -> 'c -(* Check validity of module name *) -let is_unit_name name = - try - if name = "" then raise Exit; - begin match name.[0] with - | 'A'..'Z' -> () - | _ -> - raise Exit; - end; - for i = 1 to String.length name - 1 do - match name.[i] with - | 'A'..'Z' | 'a'..'z' | '0'..'9' | '_' | '\'' -> () - | _ -> - raise Exit; - done; - true - with Exit -> false -;; +val map2 : + 'a list -> + 'b list -> + ('a -> 'b -> 'c) -> + 'c list -let check_unit_name ppf filename name = +val fold_left_with_offset : + 'a list -> + 'acc -> + int -> + ('a -> 'acc -> int -> 'acc) -> + 'acc - let _ = ppf in - let _ = filename in - let _ = name in - () +(** @unused *) +val filter_map : + 'a list -> + ('a -> 'b option) -> + 'b list -(* Compute name of module from output file name *) -let module_of_filename ppf inputfile outputprefix = - let basename = Filename.basename outputprefix in - let name = - try - let pos = String.index basename '.' in - String.sub basename 0 pos - with Not_found -> basename - in - let name = String.capitalize_ascii name in - check_unit_name ppf inputfile name; - name -;; +(** [exclude p l] is the opposite of [filter p l] *) +val exclude : + 'a list -> + ('a -> bool) -> + 'a list -type filename = string +(** [excludes p l] + return a tuple [excluded,newl] + where [exluded] is true indicates that at least one + element is removed,[newl] is the new list where all [p x] for [x] is false -type readenv_position = - Before_args | Before_compile of filename | Before_link +*) +val exclude_with_val : + 'a list -> + ('a -> bool) -> + 'a list option -(* Syntax of OCAMLPARAM: (name=VALUE,)* _ (,name=VALUE)* - where VALUE should not contain ',' *) -exception SyntaxError of string -let parse_args s = - let args = String.split_on_char ',' s in - let rec iter is_after args before after = - match args with - [] -> - if not is_after then - raise (SyntaxError "no '_' separator found") - else - (List.rev before, List.rev after) - | "_" :: _ when is_after -> raise (SyntaxError "too many '_' separators") - | "_" :: tail -> iter true tail before after - | arg :: tail -> - let binding = try - Misc.cut_at arg '=' - with Not_found -> - raise (SyntaxError ("missing '=' in " ^ arg)) - in - if is_after then - iter is_after tail before (binding :: after) - else - iter is_after tail (binding :: before) after - in - iter false args [] [] +val same_length : 'a list -> 'b list -> bool -let setter ppf f name options s = - try - let bool = match s with - | "0" -> false - | "1" -> true - | _ -> raise Not_found - in - List.iter (fun b -> b := f bool) options - with Not_found -> - Location.print_warning Location.none ppf - (Warnings.Bad_env_variable ("OCAMLPARAM", - Printf.sprintf "bad value for %s" name)) +val init : int -> (int -> 'a) -> 'a list -let int_setter ppf name option s = - try - option := int_of_string s - with _ -> - Location.print_warning Location.none ppf - (Warnings.Bad_env_variable - ("OCAMLPARAM", Printf.sprintf "non-integer parameter for \"%s\"" name)) +(** [split_at n l] + will split [l] into two lists [a,b], [a] will be of length [n], + otherwise, it will raise +*) +val split_at : + 'a list -> + int -> + 'a list * 'a list -let int_option_setter ppf name option s = - try - option := Some (int_of_string s) - with _ -> - Location.print_warning Location.none ppf - (Warnings.Bad_env_variable - ("OCAMLPARAM", Printf.sprintf "non-integer parameter for \"%s\"" name)) -(* -let float_setter ppf name option s = - try - option := float_of_string s - with _ -> - Location.print_warning Location.none ppf - (Warnings.Bad_env_variable - ("OCAMLPARAM", Printf.sprintf "non-float parameter for \"%s\"" name)) +(** [split_at_last l] + It is equivalent to [split_at (List.length l - 1) l ] *) +val split_at_last : 'a list -> 'a list * 'a -let load_plugin = ref (fun _ -> ()) +val filter_mapi : + 'a list -> + ('a -> int -> 'b option) -> + 'b list -let check_bool ppf name s = - match s with - | "0" -> false - | "1" -> true - | _ -> - Location.print_warning Location.none ppf - (Warnings.Bad_env_variable ("OCAMLPARAM", - Printf.sprintf "bad value for %s" name)); - false +val filter_map2 : + 'a list -> + 'b list -> + ('a -> 'b -> 'c option) -> + 'c list -(* 'can-discard=' specifies which arguments can be discarded without warning - because they are not understood by some versions of OCaml. *) -let can_discard = ref [] -let read_one_param ppf position name v = - let set name options s = setter ppf (fun b -> b) name options s in - let clear name options s = setter ppf (fun b -> not b) name options s in - match name with - | "g" -> set "g" [ Clflags.debug ] v - | "p" -> set "p" [ Clflags.gprofile ] v - | "bin-annot" -> set "bin-annot" [ Clflags.binary_annotations ] v - | "afl-instrument" -> set "afl-instrument" [ Clflags.afl_instrument ] v - | "afl-inst-ratio" -> - int_setter ppf "afl-inst-ratio" afl_inst_ratio v - | "annot" -> set "annot" [ Clflags.annotations ] v - | "absname" -> set "absname" [ Location.absname ] v - | "compat-32" -> set "compat-32" [ bytecode_compatible_32 ] v - | "noassert" -> set "noassert" [ noassert ] v - | "noautolink" -> set "noautolink" [ no_auto_link ] v - | "nostdlib" -> set "nostdlib" [ no_std_include ] v - | "linkall" -> set "linkall" [ link_everything ] v - | "nolabels" -> set "nolabels" [ classic ] v - | "principal" -> set "principal" [ principal ] v - | "rectypes" -> set "rectypes" [ recursive_types ] v - | "safe-string" -> clear "safe-string" [ unsafe_string ] v - | "strict-sequence" -> set "strict-sequence" [ strict_sequence ] v - | "strict-formats" -> set "strict-formats" [ strict_formats ] v - | "thread" -> set "thread" [ use_threads ] v - | "unboxed-types" -> set "unboxed-types" [ unboxed_types ] v - | "unsafe" -> set "unsafe" [ fast ] v - | "verbose" -> set "verbose" [ verbose ] v - | "nopervasives" -> set "nopervasives" [ nopervasives ] v - | "slash" -> set "slash" [ force_slash ] v (* for ocamldep *) - | "keep-docs" -> set "keep-docs" [ Clflags.keep_docs ] v - | "keep-locs" -> set "keep-locs" [ Clflags.keep_locs ] v +val length_compare : 'a list -> int -> [`Gt | `Eq | `Lt ] - | "compact" -> clear "compact" [ optimize_for_speed ] v - | "no-app-funct" -> clear "no-app-funct" [ applicative_functors ] v - | "nodynlink" -> clear "nodynlink" [ dlcode ] v - | "short-paths" -> clear "short-paths" [ real_paths ] v - | "trans-mod" -> set "trans-mod" [ transparent_modules ] v - | "opaque" -> set "opaque" [ opaque ] v +val length_ge : 'a list -> int -> bool - | "pp" -> preprocessor := Some v - | "runtime-variant" -> runtime_variant := v - | "cc" -> c_compiler := Some v +(** - | "clambda-checks" -> set "clambda-checks" [ clambda_checks ] v + {[length xs = length ys + n ]} + input n should be positive + TODO: input checking +*) - (* assembly sources *) - | "s" -> - set "s" [ Clflags.keep_asm_file ; Clflags.keep_startup_file ] v - | "S" -> set "S" [ Clflags.keep_asm_file ] v - | "dstartup" -> set "dstartup" [ Clflags.keep_startup_file ] v +val length_larger_than_n : + 'a list -> + 'a list -> + int -> + bool - (* warn-errors *) - | "we" | "warn-error" -> Warnings.parse_options true v - (* warnings *) - | "w" -> Warnings.parse_options false v - (* warn-errors *) - | "wwe" -> Warnings.parse_options false v - (* inlining *) - | "inline" -> - let module F = Float_arg_helper in - begin match F.parse_no_error v inline_threshold with - | F.Ok -> () - | F.Parse_failed exn -> - let error = - Printf.sprintf "bad syntax for \"inline\": %s" - (Printexc.to_string exn) - in - Location.print_warning Location.none ppf - (Warnings.Bad_env_variable ("OCAMLPARAM", error)) - end +(** + [rev_map_append f l1 l2] + [map f l1] and reverse it to append [l2] + This weird semantics is due to it is the most efficient operation + we can do +*) +val rev_map_append : + 'a list -> + 'b list -> + ('a -> 'b) -> + 'b list - | "inline-toplevel" -> - Int_arg_helper.parse v - "Bad syntax in OCAMLPARAM for 'inline-toplevel'" - inline_toplevel_threshold - | "rounds" -> int_option_setter ppf "rounds" simplify_rounds v - | "inline-max-unroll" -> - Int_arg_helper.parse v "Bad syntax in OCAMLPARAM for 'inline-max-unroll'" - inline_max_unroll - | "inline-call-cost" -> - Int_arg_helper.parse v - "Bad syntax in OCAMLPARAM for 'inline-call-cost'" - inline_call_cost - | "inline-alloc-cost" -> - Int_arg_helper.parse v - "Bad syntax in OCAMLPARAM for 'inline-alloc-cost'" - inline_alloc_cost - | "inline-prim-cost" -> - Int_arg_helper.parse v - "Bad syntax in OCAMLPARAM for 'inline-prim-cost'" - inline_prim_cost - | "inline-branch-cost" -> - Int_arg_helper.parse v - "Bad syntax in OCAMLPARAM for 'inline-branch-cost'" - inline_branch_cost - | "inline-indirect-cost" -> - Int_arg_helper.parse v - "Bad syntax in OCAMLPARAM for 'inline-indirect-cost'" - inline_indirect_cost - | "inline-lifting-benefit" -> - Int_arg_helper.parse v - "Bad syntax in OCAMLPARAM for 'inline-lifting-benefit'" - inline_lifting_benefit - | "inline-branch-factor" -> - Float_arg_helper.parse v - "Bad syntax in OCAMLPARAM for 'inline-branch-factor'" - inline_branch_factor - | "inline-max-depth" -> - Int_arg_helper.parse v - "Bad syntax in OCAMLPARAM for 'inline-max-depth'" - inline_max_depth +val flat_map : + 'a list -> + ('a -> 'b list) -> + 'b list - | "Oclassic" -> - set "Oclassic" [ classic_inlining ] v - | "O2" -> - if check_bool ppf "O2" v then begin - default_simplify_rounds := 2; - use_inlining_arguments_set o2_arguments; - use_inlining_arguments_set ~round:0 o1_arguments - end +val flat_map_append : + 'a list -> + 'b list -> + ('a -> 'b list) -> + 'b list - | "O3" -> - if check_bool ppf "O3" v then begin - default_simplify_rounds := 3; - use_inlining_arguments_set o3_arguments; - use_inlining_arguments_set ~round:1 o2_arguments; - use_inlining_arguments_set ~round:0 o1_arguments - end - | "unbox-closures" -> - set "unbox-closures" [ unbox_closures ] v - | "unbox-closures-factor" -> - int_setter ppf "unbox-closures-factor" unbox_closures_factor v - | "remove-unused-arguments" -> - set "remove-unused-arguments" [ remove_unused_arguments ] v - | "inlining-report" -> - if !native_code then - set "inlining-report" [ inlining_report ] v +(** + [stable_group eq lst] + Example: + Input: + {[ + stable_group (=) [1;2;3;4;3] + ]} + Output: + {[ + [[1];[2];[4];[3;3]] + ]} + TODO: this is O(n^2) behavior + which could be improved later +*) +val stable_group : + 'a list -> + ('a -> 'a -> bool) -> + 'a list list - | "flambda-verbose" -> - set "flambda-verbose" [ dump_flambda_verbose ] v - | "flambda-invariants" -> - set "flambda-invariants" [ flambda_invariant_checks ] v +(** [drop n list] + raise when [n] is negative + raise when list's length is less than [n] +*) +val drop : + 'a list -> + int -> + 'a list - (* color output *) - | "color" -> - begin match parse_color_setting v with - | None -> - Location.print_warning Location.none ppf - (Warnings.Bad_env_variable ("OCAMLPARAM", - "bad value for \"color\", \ - (expected \"auto\", \"always\" or \"never\")")) - | Some setting -> color := Some setting - end +val find_first : + 'a list -> + ('a -> bool) -> + 'a option + +(** [find_first_not p lst ] + if all elements in [lst] pass, return [None] + otherwise return the first element [e] as [Some e] which + fails the predicate +*) +val find_first_not : + 'a list -> + ('a -> bool) -> + 'a option - | "intf-suffix" -> Config.interface_suffix := v +(** [find_opt f l] returns [None] if all return [None], + otherwise returns the first one. +*) - | "I" -> begin - match position with - | Before_args -> first_include_dirs := v :: !first_include_dirs - | Before_link | Before_compile _ -> - last_include_dirs := v :: !last_include_dirs - end +val find_opt : + 'a list -> + ('a -> 'b option) -> + 'b option - | "cclib" -> - begin - match position with - | Before_compile _ -> () - | Before_link | Before_args -> - ccobjs := Misc.rev_split_words v @ !ccobjs - end +val find_def : + 'a list -> + ('a -> 'b option) -> + 'b -> + 'b - | "ccopts" -> - begin - match position with - | Before_link | Before_compile _ -> - last_ccopts := v :: !last_ccopts - | Before_args -> - first_ccopts := v :: !first_ccopts - end + +val rev_iter : + 'a list -> + ('a -> unit) -> + unit - | "ppx" -> - begin - match position with - | Before_link | Before_compile _ -> - last_ppx := v :: !last_ppx - | Before_args -> - first_ppx := v :: !first_ppx - end +val iter: + 'a list -> + ('a -> unit) -> + unit + +val for_all: + 'a list -> + ('a -> bool) -> + bool +val for_all_snd: + ('a * 'b) list -> + ('b -> bool) -> + bool +(** [for_all2_no_exn p xs ys] + return [true] if all satisfied, + [false] otherwise or length not equal +*) +val for_all2_no_exn : + 'a list -> + 'b list -> + ('a -> 'b -> bool) -> + bool - | "cmo" | "cma" -> - if not !native_code then - begin - match position with - | Before_link | Before_compile _ -> - last_objfiles := v ::! last_objfiles - | Before_args -> - first_objfiles := v :: !first_objfiles - end - | "cmx" | "cmxa" -> - if !native_code then - begin - match position with - | Before_link | Before_compile _ -> - last_objfiles := v ::! last_objfiles - | Before_args -> - first_objfiles := v :: !first_objfiles - end - | "pic" -> - if !native_code then - set "pic" [ pic_code ] v +(** [f] is applied follow the list order *) +val split_map : + 'a list -> + ('a -> 'b * 'c) -> + 'b list * 'c list - | "can-discard" -> - can_discard := v ::!can_discard +(** [fn] is applied from left to right *) +val reduce_from_left : + 'a list -> + ('a -> 'a -> 'a) -> + 'a - | "timings" | "profile" -> - let if_on = if name = "timings" then [ `Time ] else Profile.all_columns in - profile_columns := if check_bool ppf name v then if_on else [] +val sort_via_array : + 'a list -> + ('a -> 'a -> int) -> + 'a list - | "plugin" -> !load_plugin v - | _ -> - if not (List.mem name !can_discard) then begin - can_discard := name :: !can_discard; - Printf.eprintf - "Warning: discarding value of variable %S in OCAMLPARAM\n%!" - name - end -let read_OCAMLPARAM ppf position = - try - let s = Sys.getenv "OCAMLPARAM" in - let (before, after) = - try - parse_args s - with SyntaxError s -> - Location.print_warning Location.none ppf - (Warnings.Bad_env_variable ("OCAMLPARAM", s)); - [],[] - in - List.iter (fun (name, v) -> read_one_param ppf position name v) - (match position with - Before_args -> before - | Before_compile _ | Before_link -> after) - with Not_found -> () -(* OCAMLPARAM passed as file *) +(** [assoc_by_string default key lst] + if [key] is found in the list return that val, + other unbox the [default], + otherwise [assert false ] +*) +val assoc_by_string : + (string * 'a) list -> + string -> + 'a option -> + 'a -type pattern = - | Filename of string - | Any +val assoc_by_int : + (int * 'a) list -> + int -> + 'a option -> + 'a -type file_option = { - pattern : pattern; - name : string; - value : string; -} -let scan_line ic = - Scanf.bscanf ic "%[0-9a-zA-Z_.*] : %[a-zA-Z_-] = %s " - (fun pattern name value -> - let pattern = - match pattern with - | "*" -> Any - | _ -> Filename pattern - in - { pattern; name; value }) +val nth_opt : 'a list -> int -> 'a option -let load_config ppf filename = - match open_in_bin filename with - | exception e -> - Location.print_error ppf (Location.in_file filename); - Format.fprintf ppf "Cannot open file %s@." (Printexc.to_string e); - raise Exit - | ic -> - let sic = Scanf.Scanning.from_channel ic in - let rec read line_number line_start acc = - match scan_line sic with - | exception End_of_file -> - close_in ic; - acc - | exception Scanf.Scan_failure error -> - let position = Lexing.{ - pos_fname = filename; - pos_lnum = line_number; - pos_bol = line_start; - pos_cnum = pos_in ic; - } - in - let loc = Location.{ - loc_start = position; - loc_end = position; - loc_ghost = false; - } - in - Location.print_error ppf loc; - Format.fprintf ppf "Configuration file error %s@." error; - close_in ic; - raise Exit - | line -> - read (line_number + 1) (pos_in ic) (line :: acc) - in - let lines = read 0 0 [] in - lines +val iter_snd : ('a * 'b) list -> ('b -> unit) -> unit -let matching_filename filename { pattern } = - match pattern with - | Any -> true - | Filename pattern -> - let filename = String.lowercase_ascii filename in - let pattern = String.lowercase_ascii pattern in - filename = pattern +val iter_fst : ('a * 'b) list -> ('a -> unit) -> unit -let apply_config_file ppf position = - let config_file = - Filename.concat Config.standard_library "ocaml_compiler_internal_params" - in - let config = - if Sys.file_exists config_file then - load_config ppf config_file - else - [] - in - let config = - match position with - | Before_compile filename -> - List.filter (matching_filename filename) config - | Before_args | Before_link -> - List.filter (fun { pattern } -> pattern = Any) config - in - List.iter (fun { name; value } -> read_one_param ppf position name value) - config +val exists : 'a list -> ('a -> bool) -> bool -let readenv ppf position = - last_include_dirs := []; - last_ccopts := []; - last_ppx := []; - last_objfiles := []; - apply_config_file ppf position; - read_OCAMLPARAM ppf position; - all_ccopts := !last_ccopts @ !first_ccopts; - all_ppx := !last_ppx @ !first_ppx +val exists_fst : + ('a * 'b) list -> + ('a -> bool) -> + bool -let get_objfiles ~with_ocamlparam = - if with_ocamlparam then - List.rev (!last_objfiles @ !objfiles @ !first_objfiles) - else - List.rev !objfiles +val exists_snd : + ('a * 'b) list -> + ('b -> bool) -> + bool +val concat_append: + 'a list list -> + 'a list -> + 'a list +val fold_left2: + 'a list -> + 'b list -> + 'c -> + ('a -> 'b -> 'c -> 'c) + -> 'c +val fold_left: + 'a list -> + 'b -> + ('b -> 'a -> 'b) -> + 'b +val singleton_exn: + 'a list -> 'a +val mem_string : + string list -> + string -> + bool +end = struct +#1 "ext_list.ml" +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -type deferred_action = - | ProcessImplementation of string - | ProcessInterface of string - | ProcessCFile of string - | ProcessOtherFile of string - | ProcessObjects of string list - | ProcessDLLs of string list -let c_object_of_filename name = - Filename.chop_suffix (Filename.basename name) ".c" ^ Config.ext_obj -let process_action - (ppf, implementation, interface, ocaml_mod_ext, ocaml_lib_ext) action = - match action with - | ProcessImplementation name -> - readenv ppf (Before_compile name); - let opref = output_prefix name in - implementation ppf name opref; - objfiles := (opref ^ ocaml_mod_ext) :: !objfiles - | ProcessInterface name -> - readenv ppf (Before_compile name); - let opref = output_prefix name in - interface ppf name opref; - if !make_package then objfiles := (opref ^ ".cmi") :: !objfiles - | ProcessCFile name -> - readenv ppf (Before_compile name); - Location.set_input_name name; - if Ccomp.compile_file name <> 0 then exit 2; - ccobjs := c_object_of_filename name :: !ccobjs - | ProcessObjects names -> - ccobjs := names @ !ccobjs - | ProcessDLLs names -> - dllibs := names @ !dllibs - | ProcessOtherFile name -> - if Filename.check_suffix name ocaml_mod_ext - || Filename.check_suffix name ocaml_lib_ext then - objfiles := name :: !objfiles - else if Filename.check_suffix name ".cmi" && !make_package then - objfiles := name :: !objfiles - else if Filename.check_suffix name Config.ext_obj - || Filename.check_suffix name Config.ext_lib then - ccobjs := name :: !ccobjs - else if not !native_code && Filename.check_suffix name Config.ext_dll then - dllibs := name :: !dllibs - else - raise(Arg.Bad("don't know what to do with " ^ name)) +let rec map l f = + match l with + | [] -> + [] + | [x1] -> + let y1 = f x1 in + [y1] + | [x1; x2] -> + let y1 = f x1 in + let y2 = f x2 in + [y1; y2] + | [x1; x2; x3] -> + let y1 = f x1 in + let y2 = f x2 in + let y3 = f x3 in + [y1; y2; y3] + | [x1; x2; x3; x4] -> + let y1 = f x1 in + let y2 = f x2 in + let y3 = f x3 in + let y4 = f x4 in + [y1; y2; y3; y4] + | x1::x2::x3::x4::x5::tail -> + let y1 = f x1 in + let y2 = f x2 in + let y3 = f x3 in + let y4 = f x4 in + let y5 = f x5 in + y1::y2::y3::y4::y5::(map tail f) -let action_of_file name = - if Filename.check_suffix name ".ml" - || Filename.check_suffix name ".mlt" then - ProcessImplementation name - else if Filename.check_suffix name !Config.interface_suffix then - ProcessInterface name - else if Filename.check_suffix name ".c" then - ProcessCFile name - else - ProcessOtherFile name +let rec has_string l f = + match l with + | [] -> + false + | [x1] -> + x1 = f + | [x1; x2] -> + x1 = f || x2 = f + | [x1; x2; x3] -> + x1 = f || x2 = f || x3 = f + | x1 :: x2 :: x3 :: x4 -> + x1 = f || x2 = f || x3 = f || has_string x4 f + +let rec map_combine l1 l2 f = + match (l1, l2) with + ([], []) -> [] + | (a1::l1, a2::l2) -> + (f a1, a2) :: map_combine l1 l2 f + | (_, _) -> + invalid_arg "Ext_list.map_combine" -let deferred_actions = ref [] -let defer action = - deferred_actions := action :: !deferred_actions +let rec map_split_opt + (xs : 'a list) (f : 'a -> 'b option * 'c option) + : 'b list * 'c list = + match xs with + | [] -> [], [] + | x::xs -> + let c,d = f x in + let cs,ds = map_split_opt xs f in + (match c with Some c -> c::cs | None -> cs), + (match d with Some d -> d::ds | None -> ds) -let anonymous filename = defer (action_of_file filename) -let impl filename = defer (ProcessImplementation filename) -let intf filename = defer (ProcessInterface filename) +let rec map_snd l f = + match l with + | [] -> + [] + | [ v1,x1 ] -> + let y1 = f x1 in + [v1,y1] + | [v1, x1; v2, x2] -> + let y1 = f x1 in + let y2 = f x2 in + [v1, y1; v2, y2] + | [ v1, x1; v2, x2; v3, x3] -> + let y1 = f x1 in + let y2 = f x2 in + let y3 = f x3 in + [v1, y1; v2, y2; v3, y3] + | [ v1, x1; v2, x2; v3, x3; v4, x4] -> + let y1 = f x1 in + let y2 = f x2 in + let y3 = f x3 in + let y4 = f x4 in + [v1, y1; v2, y2; v3, y3; v4, y4] + | (v1, x1) ::(v2, x2) :: (v3, x3)::(v4, x4) :: (v5, x5) ::tail -> + let y1 = f x1 in + let y2 = f x2 in + let y3 = f x3 in + let y4 = f x4 in + let y5 = f x5 in + (v1, y1)::(v2, y2) :: (v3, y3) :: (v4, y4) :: (v5, y5) :: (map_snd tail f) -let process_deferred_actions env = - let final_output_name = !output_name in - (* Make sure the intermediate products don't clash with the final one - when we're invoked like: ocamlopt -o foo bar.c baz.ml. *) - if not !compile_only then output_name := None; - begin - match final_output_name with - | None -> () - | Some output_name -> - if !compile_only then begin - if List.filter (function - | ProcessCFile name -> c_object_of_filename name <> output_name - | _ -> false) !deferred_actions <> [] then - fatal "Options -c and -o are incompatible when compiling C files"; - if List.length (List.filter (function - | ProcessImplementation _ - | ProcessInterface _ - | _ -> false) !deferred_actions) > 1 then - fatal "Options -c -o are incompatible with compiling multiple files" - end; - end; - if !make_archive && List.exists (function - | ProcessOtherFile name -> Filename.check_suffix name ".cmxa" - | _ -> false) !deferred_actions then - fatal "Option -a cannot be used with .cmxa input files."; - List.iter (process_action env) (List.rev !deferred_actions); - output_name := final_output_name; +let rec map_last l f= + match l with + | [] -> + [] + | [x1] -> + let y1 = f true x1 in + [y1] + | [x1; x2] -> + let y1 = f false x1 in + let y2 = f true x2 in + [y1; y2] + | [x1; x2; x3] -> + let y1 = f false x1 in + let y2 = f false x2 in + let y3 = f true x3 in + [y1; y2; y3] + | [x1; x2; x3; x4] -> + let y1 = f false x1 in + let y2 = f false x2 in + let y3 = f false x3 in + let y4 = f true x4 in + [y1; y2; y3; y4] + | x1::x2::x3::x4::tail -> + (* make sure that tail is not empty *) + let y1 = f false x1 in + let y2 = f false x2 in + let y3 = f false x3 in + let y4 = f false x4 in + y1::y2::y3::y4::(map_last tail f) -end -(** Interface as module *) -module Compdynlink -= struct -#1 "compdynlink.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let rec mapi_aux lst i f = + match lst with + [] -> [] + | a::l -> + let r = f i a in r :: mapi_aux l (i + 1) f -(** Dynamic loading of object files. *) +let mapi lst f = mapi_aux lst 0 f -val is_native: bool -(** [true] if the program is native, - [false] if the program is bytecode. *) +let rec last xs = + match xs with + | [x] -> x + | _ :: tl -> last tl + | [] -> invalid_arg "Ext_list.last" -(** {1 Dynamic loading of compiled files} *) -val loadfile : string -> unit -(** In bytecode: load the given bytecode object file ([.cmo] file) or - bytecode library file ([.cma] file), and link it with the running - program. In native code: load the given OCaml plugin file (usually - [.cmxs]), and link it with the running - program. - All toplevel expressions in the loaded compilation units - are evaluated. No facilities are provided to - access value names defined by the unit. Therefore, the unit - must register itself its entry points with the main program, - e.g. by modifying tables of functions. *) -val loadfile_private : string -> unit -(** Same as [loadfile], except that the compilation units just loaded - are hidden (cannot be referenced) from other modules dynamically - loaded afterwards. *) +let rec append_aux l1 l2 = + match l1 with + | [] -> l2 + | [a0] -> a0::l2 + | [a0;a1] -> a0::a1::l2 + | [a0;a1;a2] -> a0::a1::a2::l2 + | [a0;a1;a2;a3] -> a0::a1::a2::a3::l2 + | [a0;a1;a2;a3;a4] -> a0::a1::a2::a3::a4::l2 + | a0::a1::a2::a3::a4::rest -> a0::a1::a2::a3::a4::append_aux rest l2 -val adapt_filename : string -> string -(** In bytecode, the identity function. In native code, replace the last - extension with [.cmxs]. *) +let append l1 l2 = + match l2 with + | [] -> l1 + | _ -> append_aux l1 l2 -(** {1 Access control} *) +let append_one l1 x = append_aux l1 [x] -val allow_only: string list -> unit -(** [allow_only units] restricts the compilation units that - dynamically-linked units can reference: it forbids all references - to units other than those named in the list [units]. References - to any other compilation unit will cause a [Unavailable_unit] - error during [loadfile] or [loadfile_private]. +let rec map_append l1 l2 f = + match l1 with + | [] -> l2 + | [a0] -> f a0::l2 + | [a0;a1] -> + let b0 = f a0 in + let b1 = f a1 in + b0::b1::l2 + | [a0;a1;a2] -> + let b0 = f a0 in + let b1 = f a1 in + let b2 = f a2 in + b0::b1::b2::l2 + | [a0;a1;a2;a3] -> + let b0 = f a0 in + let b1 = f a1 in + let b2 = f a2 in + let b3 = f a3 in + b0::b1::b2::b3::l2 + | [a0;a1;a2;a3;a4] -> + let b0 = f a0 in + let b1 = f a1 in + let b2 = f a2 in + let b3 = f a3 in + let b4 = f a4 in + b0::b1::b2::b3::b4::l2 - Initially (or after calling [default_available_units]) all - compilation units composing the program currently running are - available for reference from dynamically-linked units. - [allow_only] can be used to restrict access to a subset of these - units, e.g. to the units that compose the API for - dynamically-linked code, and prevent access to all other units, - e.g. private, internal modules of the running program. If - [allow_only] is called several times, access will be restricted to - the intersection of the given lists (i.e. a call to [allow_only] - can never increase the set of available units). *) + | a0::a1::a2::a3::a4::rest -> + let b0 = f a0 in + let b1 = f a1 in + let b2 = f a2 in + let b3 = f a3 in + let b4 = f a4 in + b0::b1::b2::b3::b4::map_append rest l2 f -val prohibit: string list -> unit -(** [prohibit units] prohibits dynamically-linked units from referencing - the units named in list [units]. This can be used to prevent - access to selected units, e.g. private, internal modules of - the running program. *) -val default_available_units: unit -> unit -(** Reset the set of units that can be referenced from dynamically-linked - code to its default value, that is, all units composing the currently - running program. *) -val allow_unsafe_modules : bool -> unit -(** Govern whether unsafe object files are allowed to be - dynamically linked. A compilation unit is 'unsafe' if it contains - declarations of external functions, which can break type safety. - By default, dynamic linking of unsafe object files is - not allowed. In native code, this function does nothing; object files - with external functions are always allowed to be dynamically linked. *) +let rec fold_right l acc f = + match l with + | [] -> acc + | [a0] -> f a0 acc + | [a0;a1] -> f a0 (f a1 acc) + | [a0;a1;a2] -> f a0 (f a1 (f a2 acc)) + | [a0;a1;a2;a3] -> f a0 (f a1 (f a2 (f a3 acc))) + | [a0;a1;a2;a3;a4] -> + f a0 (f a1 (f a2 (f a3 (f a4 acc)))) + | a0::a1::a2::a3::a4::rest -> + f a0 (f a1 (f a2 (f a3 (f a4 (fold_right rest acc f ))))) -(** {1 Deprecated, low-level API for access control} *) +let rec fold_right2 l r acc f = + match l,r with + | [],[] -> acc + | [a0],[b0] -> f a0 b0 acc + | [a0;a1],[b0;b1] -> f a0 b0 (f a1 b1 acc) + | [a0;a1;a2],[b0;b1;b2] -> f a0 b0 (f a1 b1 (f a2 b2 acc)) + | [a0;a1;a2;a3],[b0;b1;b2;b3] -> + f a0 b0 (f a1 b1 (f a2 b2 (f a3 b3 acc))) + | [a0;a1;a2;a3;a4], [b0;b1;b2;b3;b4] -> + f a0 b0 (f a1 b1 (f a2 b2 (f a3 b3 (f a4 b4 acc)))) + | a0::a1::a2::a3::a4::arest, b0::b1::b2::b3::b4::brest -> + f a0 b0 (f a1 b1 (f a2 b2 (f a3 b3 (f a4 b4 (fold_right2 arest brest acc f ))))) + | _, _ -> invalid_arg "Ext_list.fold_right2" -(** @deprecated The functions [add_interfaces], [add_available_units] - and [clear_available_units] should not be used in new programs, - since the default initialization of allowed units, along with the - [allow_only] and [prohibit] function, provides a better, safer - mechanism to control access to program units. The three functions - below are provided for backward compatibility only and are not - available in native code. *) +let rec map2 l r f = + match l,r with + | [],[] -> [] + | [a0],[b0] -> [f a0 b0] + | [a0;a1],[b0;b1] -> + let c0 = f a0 b0 in + let c1 = f a1 b1 in + [c0; c1] + | [a0;a1;a2],[b0;b1;b2] -> + let c0 = f a0 b0 in + let c1 = f a1 b1 in + let c2 = f a2 b2 in + [c0;c1;c2] + | [a0;a1;a2;a3],[b0;b1;b2;b3] -> + let c0 = f a0 b0 in + let c1 = f a1 b1 in + let c2 = f a2 b2 in + let c3 = f a3 b3 in + [c0;c1;c2;c3] + | [a0;a1;a2;a3;a4], [b0;b1;b2;b3;b4] -> + let c0 = f a0 b0 in + let c1 = f a1 b1 in + let c2 = f a2 b2 in + let c3 = f a3 b3 in + let c4 = f a4 b4 in + [c0;c1;c2;c3;c4] + | a0::a1::a2::a3::a4::arest, b0::b1::b2::b3::b4::brest -> + let c0 = f a0 b0 in + let c1 = f a1 b1 in + let c2 = f a2 b2 in + let c3 = f a3 b3 in + let c4 = f a4 b4 in + c0::c1::c2::c3::c4::map2 arest brest f + | _, _ -> invalid_arg "Ext_list.map2" -val add_interfaces : string list -> string list -> unit -(** [add_interfaces units path] grants dynamically-linked object - files access to the compilation units named in list [units]. - The interfaces ([.cmi] files) for these units are searched in - [path] (a list of directory names). *) +let rec fold_left_with_offset l accu i f = + match l with + | [] -> accu + | a::l -> + fold_left_with_offset + l + (f a accu i) + (i + 1) + f -val add_available_units : (string * Digest.t) list -> unit -(** Same as {!Dynlink.add_interfaces}, but instead of searching [.cmi] files - to find the unit interfaces, uses the interface digests given - for each unit. This way, the [.cmi] interface files need not be - available at run-time. The digests can be extracted from [.cmi] - files using the [extract_crc] program installed in the - OCaml standard library directory. *) -val clear_available_units : unit -> unit -(** Empty the list of compilation units accessible to dynamically-linked - programs. *) +let rec filter_map xs (f: 'a -> 'b option)= + match xs with + | [] -> [] + | y :: ys -> + begin match f y with + | None -> filter_map ys f + | Some z -> z :: filter_map ys f + end -(** {1 Deprecated, initialization} *) +let rec exclude (xs : 'a list) (p : 'a -> bool) : 'a list = + match xs with + | [] -> [] + | x::xs -> + if p x then exclude xs p + else x:: exclude xs p -val init : unit -> unit -(** @deprecated Initialize the [Dynlink] library. This function is called - automatically when needed. *) +let rec exclude_with_val l p = + match l with + | [] -> None + | a0::xs -> + if p a0 then Some (exclude xs p) + else + match xs with + | [] -> None + | a1::rest -> + if p a1 then + Some (a0:: exclude rest p) + else + match exclude_with_val rest p with + | None -> None + | Some rest -> Some (a0::a1::rest) -(** {1 Error reporting} *) -type linking_error = - Undefined_global of string - | Unavailable_primitive of string - | Uninitialized_global of string -type error = - Not_a_bytecode_file of string - | Inconsistent_import of string - | Unavailable_unit of string - | Unsafe_file - | Linking_error of string * linking_error - | Corrupted_interface of string - | File_not_found of string - | Cannot_open_dll of string - | Inconsistent_implementation of string +let rec same_length xs ys = + match xs, ys with + | [], [] -> true + | _::xs, _::ys -> same_length xs ys + | _, _ -> false -exception Error of error -(** Errors in dynamic linking are reported by raising the [Error] - exception with a description of the error. *) -val error_message : error -> string -(** Convert an error description to a printable message. *) +let init n f = + match n with + | 0 -> [] + | 1 -> + let a0 = f 0 in + [a0] + | 2 -> + let a0 = f 0 in + let a1 = f 1 in + [a0; a1] + | 3 -> + let a0 = f 0 in + let a1 = f 1 in + let a2 = f 2 in + [a0; a1; a2] + | 4 -> + let a0 = f 0 in + let a1 = f 1 in + let a2 = f 2 in + let a3 = f 3 in + [a0; a1; a2; a3] + | 5 -> + let a0 = f 0 in + let a1 = f 1 in + let a2 = f 2 in + let a3 = f 3 in + let a4 = f 4 in + [a0; a1; a2; a3; a4] + | _ -> + Array.to_list (Array.init n f) +let rec rev_append l1 l2 = + match l1 with + [] -> l2 + | a :: l -> rev_append l (a :: l2) -(**/**) +let rev l = rev_append l [] -(** {1 Internal functions} *) +let rec small_split_at n acc l = + if n <= 0 then rev acc , l + else + match l with + | x::xs -> small_split_at (n - 1) (x ::acc) xs + | _ -> invalid_arg "Ext_list.split_at" -val digest_interface : string -> string list -> Digest.t +let split_at l n = + small_split_at n [] l -end -module Compmisc : sig -#1 "compmisc.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Fabrice Le Fessant, EPI Gallium, INRIA Paris-Rocquencourt *) -(* *) -(* Copyright 2013 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let rec split_at_last_aux acc x = + match x with + | [] -> invalid_arg "Ext_list.split_at_last" + | [ x] -> rev acc, x + | y0::ys -> split_at_last_aux (y0::acc) ys -val init_path : ?dir:string -> bool -> unit -val initial_env : unit -> Env.t +let split_at_last (x : 'a list) = + match x with + | [] -> invalid_arg "Ext_list.split_at_last" + | [a0] -> + [], a0 + | [a0;a1] -> + [a0], a1 + | [a0;a1;a2] -> + [a0;a1], a2 + | [a0;a1;a2;a3] -> + [a0;a1;a2], a3 + | [a0;a1;a2;a3;a4] -> + [a0;a1;a2;a3], a4 + | a0::a1::a2::a3::a4::rest -> + let rev, last = split_at_last_aux [] rest + in + a0::a1::a2::a3::a4:: rev , last -val read_color_env : Format.formatter -> unit +(** + can not do loop unroll due to state combination +*) +let filter_mapi xs f = + let rec aux i xs = + match xs with + | [] -> [] + | y :: ys -> + begin match f y i with + | None -> aux (i + 1) ys + | Some z -> z :: aux (i + 1) ys + end in + aux 0 xs -end = struct -#1 "compmisc.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Fabrice Le Fessant, EPI Gallium, INRIA Paris-Rocquencourt *) -(* *) -(* Copyright 2013 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let rec filter_map2 xs ys (f: 'a -> 'b -> 'c option) = + match xs,ys with + | [],[] -> [] + | u::us, v :: vs -> + begin match f u v with + | None -> filter_map2 us vs f (* idea: rec f us vs instead? *) + | Some z -> z :: filter_map2 us vs f + end + | _ -> invalid_arg "Ext_list.filter_map2" -open Compenv -(* Initialize the search path. - [dir] is always searched first (default: the current directory), - then the directories specified with the -I option (in command-line order), - then the standard library directory (unless the -nostdlib option is given). - *) - -let init_path ?(dir="") native = - let dirs = - if !Clflags.use_threads then "+threads" :: !Clflags.include_dirs - else if !Clflags.use_vmthreads && not native then - "+vmthreads" :: !Clflags.include_dirs - else - !Clflags.include_dirs - in - let dirs = - !last_include_dirs @ dirs @ Config.flexdll_dirs @ !first_include_dirs - in - let exp_dirs = - List.map (Misc.expand_directory Config.standard_library) dirs in - - Config.load_path := - (if !Clflags.no_implicit_current_dir then - List.rev_append exp_dirs (Clflags.std_include_dir ()) - else - dir :: List.rev_append exp_dirs (Clflags.std_include_dir ())); - - Env.reset_cache () +let rec rev_map_append l1 l2 f = + match l1 with + | [] -> l2 + | a :: l -> rev_map_append l (f a :: l2) f -(* Return the initial environment in which compilation proceeds. *) -(* Note: do not do init_path() in initial_env, this breaks - toplevel initialization (PR#1775) *) -let open_implicit_module m env = - let open Asttypes in - let lid = {loc = Location.in_file "command line"; - txt = Longident.parse m } in - snd (Typemod.type_open_ Override env lid.loc lid) +(** It is not worth loop unrolling, + it is already tail-call, and we need to be careful + about evaluation order when unroll +*) +let rec flat_map_aux f acc append lx = + match lx with + | [] -> rev_append acc append + | a0::rest -> flat_map_aux f (rev_append (f a0) acc ) append rest -let initial_env () = - Ident.reinit(); - let initial = - if Config.safe_string then Env.initial_safe_string - else if !Clflags.unsafe_string then Env.initial_unsafe_string - else Env.initial_safe_string - in - let env = - if !Clflags.nopervasives then initial else - open_implicit_module "Pervasives" initial - in - List.fold_left (fun env m -> - open_implicit_module m env - ) env (!implicit_modules @ List.rev !Clflags.open_modules) +let flat_map lx f = + flat_map_aux f [] [] lx +let flat_map_append lx append f = + flat_map_aux f [] append lx -let read_color_env ppf = - try - match Clflags.parse_color_setting (Sys.getenv "OCAML_COLOR") with - | None -> - Location.print_warning Location.none ppf - (Warnings.Bad_env_variable - ("OCAML_COLOR", - "expected \"auto\", \"always\" or \"never\"")); - | Some x -> match !Clflags.color with - | None -> Clflags.color := Some x - | Some _ -> () - with - Not_found -> () -end -module Compplugin : sig -#1 "compplugin.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Fabrice Le Fessant, projet Gallium, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let rec length_compare l n = + if n < 0 then `Gt + else + begin match l with + | _ ::xs -> length_compare xs (n - 1) + | [] -> + if n = 0 then `Eq + else `Lt + end -val load : string -> unit +let rec length_ge l n = + if n > 0 then + match l with + | _ :: tl -> length_ge tl (n - 1) + | [] -> false + else true +(** -end = struct -#1 "compplugin.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Fabrice Le Fessant, projet Gallium, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) + {[length xs = length ys + n ]} +*) +let rec length_larger_than_n xs ys n = + match xs, ys with + | _, [] -> length_compare xs n = `Eq + | _::xs, _::ys -> + length_larger_than_n xs ys n + | [], _ -> false -(* A table to avoid double linking of plugins, especially with OCAMLPARAM *) -let plugins = Hashtbl.create 13 -let load plugin_name = - let plugin_name = - try - Compdynlink.adapt_filename plugin_name - with Invalid_argument _ -> plugin_name - in - let plugin_file = - if Filename.is_implicit plugin_name then - try - Compmisc.init_path !Clflags.native_code; - Misc.find_in_path !Config.load_path plugin_name - with Not_found -> - raise (Compdynlink.Error (Compdynlink.File_not_found plugin_name)) - else plugin_name - in +let rec group (eq : 'a -> 'a -> bool) lst = + match lst with + | [] -> [] + | x::xs -> + aux eq x (group eq xs ) - if not (Hashtbl.mem plugins plugin_file) then begin - Compdynlink.loadfile plugin_file; - Hashtbl.add plugins plugin_file (); (* plugin loaded *) - end +and aux eq (x : 'a) (xss : 'a list list) : 'a list list = + match xss with + | [] -> [[x]] + | (y0::_ as y)::ys -> (* cannot be empty *) + if eq x y0 then + (x::y) :: ys + else + y :: aux eq x ys + | _ :: _ -> assert false -let () = - Location.register_error_of_exn (function - | Compdynlink.Error error -> - Some (Location.error ( - Printf.sprintf "%s while loading argument of -plugin" - (Compdynlink.error_message error))) - | _ -> None); - Compenv.load_plugin := load +let stable_group lst eq = group eq lst |> rev -end -module Builtin_attributes : sig -#1 "builtin_attributes.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Alain Frisch, LexiFi *) -(* *) -(* Copyright 2012 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let rec drop h n = + if n < 0 then invalid_arg "Ext_list.drop" + else + if n = 0 then h + else + match h with + | [] -> + invalid_arg "Ext_list.drop" + | _ :: tl -> + drop tl (n - 1) -(* Support for some of the builtin attributes: +let rec find_first x p = + match x with + | [] -> None + | x :: l -> + if p x then Some x + else find_first l p - ocaml.deprecated - ocaml.error - ocaml.ppwarning - ocaml.warning - ocaml.warnerror - ocaml.explicit_arity (for camlp4/camlp5) - ocaml.warn_on_literal_pattern - ocaml.deprecated_mutable - ocaml.immediate - ocaml.boxed / ocaml.unboxed -*) +let rec find_first_not xs p = + match xs with + | [] -> None + | a::l -> + if p a + then find_first_not l p + else Some a -val check_deprecated: Location.t -> Parsetree.attributes -> string -> unit -val check_deprecated_inclusion: - def:Location.t -> use:Location.t -> Location.t -> Parsetree.attributes -> - Parsetree.attributes -> string -> unit -val deprecated_of_attrs: Parsetree.attributes -> string option -val deprecated_of_sig: Parsetree.signature -> string option -val deprecated_of_str: Parsetree.structure -> string option +let rec rev_iter l f = + match l with + | [] -> () + | [x1] -> + f x1 + | [x1; x2] -> + f x2 ; f x1 + | [x1; x2; x3] -> + f x3 ; f x2 ; f x1 + | [x1; x2; x3; x4] -> + f x4; f x3; f x2; f x1 + | x1::x2::x3::x4::x5::tail -> + rev_iter tail f; + f x5; f x4 ; f x3; f x2 ; f x1 -val check_deprecated_mutable: - Location.t -> Parsetree.attributes -> string -> unit -val check_deprecated_mutable_inclusion: - def:Location.t -> use:Location.t -> Location.t -> Parsetree.attributes -> - Parsetree.attributes -> string -> unit +let rec iter l f = + match l with + | [] -> () + | [x1] -> + f x1 + | [x1; x2] -> + f x1 ; f x2 + | [x1; x2; x3] -> + f x1 ; f x2 ; f x3 + | [x1; x2; x3; x4] -> + f x1; f x2; f x3; f x4 + | x1::x2::x3::x4::x5::tail -> + f x1; f x2 ; f x3; f x4 ; f x5; + iter tail f -val error_of_extension: Parsetree.extension -> Location.error -val warning_attribute: ?ppwarning:bool -> Parsetree.attribute -> unit - (** Apply warning settings from the specified attribute. - "ocaml.warning"/"ocaml.warnerror" (and variants without the prefix) - are processed and other attributes are ignored. +let rec for_all lst p = + match lst with + [] -> true + | a::l -> p a && for_all l p - Also implement ocaml.ppwarning (unless ~ppwarning:false is - passed). - *) +let rec for_all_snd lst p = + match lst with + [] -> true + | (_,a)::l -> p a && for_all_snd l p -val warning_scope: - ?ppwarning:bool -> - Parsetree.attributes -> (unit -> 'a) -> 'a - (** Execute a function in a new scope for warning settings. This - means that the effect of any call to [warning_attribute] during - the execution of this function will be discarded after - execution. - The function also takes a list of attributes which are processed - with [warning_attribute] in the fresh scope before the function - is executed. - *) +let rec for_all2_no_exn l1 l2 p = + match (l1, l2) with + | ([], []) -> true + | (a1::l1, a2::l2) -> p a1 a2 && for_all2_no_exn l1 l2 p + | (_, _) -> false -val warn_on_literal_pattern: Parsetree.attributes -> bool -val explicit_arity: Parsetree.attributes -> bool +let rec find_opt xs p = + match xs with + | [] -> None + | x :: l -> + match p x with + | Some _ as v -> v + | None -> find_opt l p -val immediate: Parsetree.attributes -> bool +let rec find_def xs p def = + match xs with + | [] -> def + | x::l -> + match p x with + | Some v -> v + | None -> find_def l p def -val has_unboxed: Parsetree.attributes -> bool -val has_boxed: Parsetree.attributes -> bool +let rec split_map l f = + match l with + | [] -> + [],[] + | [x1] -> + let a0,b0 = f x1 in + [a0],[b0] + | [x1; x2] -> + let a1,b1 = f x1 in + let a2,b2 = f x2 in + [a1;a2],[b1;b2] + | [x1; x2; x3] -> + let a1,b1 = f x1 in + let a2,b2 = f x2 in + let a3,b3 = f x3 in + [a1;a2;a3], [b1;b2;b3] + | [x1; x2; x3; x4] -> + let a1,b1 = f x1 in + let a2,b2 = f x2 in + let a3,b3 = f x3 in + let a4,b4 = f x4 in + [a1;a2;a3;a4], [b1;b2;b3;b4] + | x1::x2::x3::x4::x5::tail -> + let a1,b1 = f x1 in + let a2,b2 = f x2 in + let a3,b3 = f x3 in + let a4,b4 = f x4 in + let a5,b5 = f x5 in + let ass,bss = split_map tail f in + a1::a2::a3::a4::a5::ass, + b1::b2::b3::b4::b5::bss -end = struct -#1 "builtin_attributes.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Alain Frisch, LexiFi *) -(* *) -(* Copyright 2012 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) -open Asttypes -open Parsetree -let string_of_cst = function - | Pconst_string(s, _) -> Some s - | _ -> None -let string_of_payload = function - | PStr[{pstr_desc=Pstr_eval({pexp_desc=Pexp_constant c},_)}] -> - string_of_cst c - | _ -> None +let sort_via_array lst cmp = + let arr = Array.of_list lst in + Array.sort cmp arr; + Array.to_list arr -let string_of_opt_payload p = - match string_of_payload p with - | Some s -> s - | None -> "" -let rec error_of_extension ext = - match ext with - | ({txt = ("ocaml.error"|"error") as txt; loc}, p) -> - let rec sub_from inner = - match inner with - | {pstr_desc=Pstr_extension (ext, _)} :: rest -> - error_of_extension ext :: sub_from rest - | _ :: rest -> - (Location.errorf ~loc - "Invalid syntax for sub-error of extension '%s'." txt) :: - sub_from rest - | [] -> [] - in - begin match p with - | PStr [] -> raise Location.Already_displayed_error - | PStr({pstr_desc=Pstr_eval - ({pexp_desc=Pexp_constant(Pconst_string(msg,_))}, _)}:: - {pstr_desc=Pstr_eval - ({pexp_desc=Pexp_constant(Pconst_string(if_highlight,_))}, _)}:: - inner) -> - Location.error ~loc ~if_highlight ~sub:(sub_from inner) msg - | PStr({pstr_desc=Pstr_eval - ({pexp_desc=Pexp_constant(Pconst_string(msg,_))}, _)}::inner) -> - Location.error ~loc ~sub:(sub_from inner) msg - | _ -> Location.errorf ~loc "Invalid syntax for extension '%s'." txt - end - | ({txt; loc}, _) -> - Location.errorf ~loc "Uninterpreted extension '%s'." txt -let cat s1 s2 = - if s2 = "" then s1 else - - if Clflags.bs_vscode then s1 ^ " " ^ s2 - else s1 ^ "\n" ^ s2 - -let rec deprecated_of_attrs = function - | [] -> None - | ({txt = "ocaml.deprecated"|"deprecated"; _}, p) :: _ -> - Some (string_of_opt_payload p) - | _ :: tl -> deprecated_of_attrs tl +let rec assoc_by_string lst (k : string) def = + match lst with + | [] -> + begin match def with + | None -> assert false + | Some x -> x end + | (k1,v1)::rest -> + if k1 = k then v1 else + assoc_by_string rest k def -let check_deprecated loc attrs s = - match deprecated_of_attrs attrs with - | None -> () - | Some txt -> Location.deprecated loc (cat s txt) +let rec assoc_by_int lst (k : int) def = + match lst with + | [] -> + begin match def with + | None -> assert false + | Some x -> x end + | (k1,v1)::rest -> + if k1 = k then v1 else + assoc_by_int rest k def -let check_deprecated_inclusion ~def ~use loc attrs1 attrs2 s = - match deprecated_of_attrs attrs1, deprecated_of_attrs attrs2 with - | None, _ | Some _, Some _ -> () - | Some txt, None -> Location.deprecated ~def ~use loc (cat s txt) -let rec deprecated_mutable_of_attrs = function +let rec nth_aux l n = + match l with | [] -> None - | ({txt = "ocaml.deprecated_mutable"|"deprecated_mutable"; _}, p) :: _ -> - Some (string_of_opt_payload p) - | _ :: tl -> deprecated_mutable_of_attrs tl + | a::l -> if n = 0 then Some a else nth_aux l (n-1) -let check_deprecated_mutable loc attrs s = - match deprecated_mutable_of_attrs attrs with - | None -> () - | Some txt -> - Location.deprecated loc (Printf.sprintf "mutating field %s" (cat s txt)) +let nth_opt l n = + if n < 0 then None + else + nth_aux l n -let check_deprecated_mutable_inclusion ~def ~use loc attrs1 attrs2 s = - match deprecated_mutable_of_attrs attrs1, - deprecated_mutable_of_attrs attrs2 - with - | None, _ | Some _, Some _ -> () - | Some txt, None -> - Location.deprecated ~def ~use loc - (Printf.sprintf "mutating field %s" (cat s txt)) +let rec iter_snd lst f = + match lst with + | [] -> () + | (_,x)::xs -> + f x ; + iter_snd xs f + +let rec iter_fst lst f = + match lst with + | [] -> () + | (x,_)::xs -> + f x ; + iter_fst xs f -let rec deprecated_of_sig = function - | {psig_desc = Psig_attribute a} :: tl -> - begin match deprecated_of_attrs [a] with - | None -> deprecated_of_sig tl - | Some _ as r -> r - end - | _ -> None +let rec exists l p = + match l with + [] -> false + | x :: xs -> p x || exists xs p +let rec exists_fst l p = + match l with + [] -> false + | (a,_)::l -> p a || exists_fst l p -let rec deprecated_of_str = function - | {pstr_desc = Pstr_attribute a} :: tl -> - begin match deprecated_of_attrs [a] with - | None -> deprecated_of_str tl - | Some _ as r -> r - end - | _ -> None +let rec exists_snd l p = + match l with + [] -> false + | (_, a)::l -> p a || exists_snd l p +let rec concat_append + (xss : 'a list list) + (xs : 'a list) : 'a list = + match xss with + | [] -> xs + | l::r -> append l (concat_append r xs) -let warning_attribute ?(ppwarning = true) = - let process loc txt errflag payload = - match string_of_payload payload with - | Some s -> - begin try Warnings.parse_options errflag s - with Arg.Bad _ -> - Location.prerr_warning loc - (Warnings.Attribute_payload - (txt, "Ill-formed list of warnings")) - end - | None -> - Location.prerr_warning loc - (Warnings.Attribute_payload - (txt, "A single string literal is expected")) - in - function - | ({txt = ("ocaml.warning"|"warning") as txt; loc}, payload) -> - process loc txt false payload - | ({txt = ("ocaml.warnerror"|"warnerror") as txt; loc}, payload) -> - process loc txt true payload - | {txt="ocaml.ppwarning"|"ppwarning"}, - PStr[{pstr_desc=Pstr_eval({pexp_desc=Pexp_constant - (Pconst_string (s, _))},_); - pstr_loc}] when ppwarning -> - Location.prerr_warning pstr_loc (Warnings.Preprocessor s) - | _ -> - () +let rec fold_left l accu f = + match l with + [] -> accu + | a::l -> fold_left l (f accu a) f + +let reduce_from_left lst fn = + match lst with + | first :: rest -> fold_left rest first fn + | _ -> invalid_arg "Ext_list.reduce_from_left" -let warning_scope ?ppwarning attrs f = - let prev = Warnings.backup () in - try - List.iter (warning_attribute ?ppwarning) (List.rev attrs); - let ret = f () in - Warnings.restore prev; - ret - with exn -> - Warnings.restore prev; - raise exn +let rec fold_left2 l1 l2 accu f = + match (l1, l2) with + ([], []) -> accu + | (a1::l1, a2::l2) -> fold_left2 l1 l2 (f a1 a2 accu) f + | (_, _) -> invalid_arg "Ext_list.fold_left2" +let singleton_exn xs = match xs with [x] -> x | _ -> assert false -let warn_on_literal_pattern = - List.exists - (function - | ({txt="ocaml.warn_on_literal_pattern"|"warn_on_literal_pattern"; _}, _) - -> true - | _ -> false - ) +let rec mem_string (xs : string list) (x : string) = + match xs with + [] -> false + | a::l -> a = x || mem_string l x -let explicit_arity = - List.exists - (function - | ({txt="ocaml.explicit_arity"|"explicit_arity"; _}, _) -> true - | _ -> false - ) +end +module Record_attributes_check += struct +#1 "record_attributes_check.ml" +(* Copyright (C) 2019- Authors of BuckleScript + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -let immediate = - List.exists - (function - | ({txt="ocaml.immediate"|"immediate"; _}, _) -> true - | _ -> false - ) +type label = Types.label_description -(* The "ocaml.boxed (default)" and "ocaml.unboxed (default)" - attributes cannot be input by the user, they are added by the - compiler when applying the default setting. This is done to record - in the .cmi the default used by the compiler when compiling the - source file because the default can change between compiler - invocations. *) +let fn = (fun (attr : Parsetree.attribute) -> +match attr with +| {txt = "bs.as"}, PStr + [{pstr_desc = Pstr_eval ({pexp_desc = Pexp_constant (Pconst_string(s,_))},_ )}] -> + (* Bs_ast_invariant.mark_used_bs_attribute attr; *) + Some s +| _ -> None +) + +let fld_record (lbl : label) = + Lambda.Fld_record + {name = Ext_list.find_def lbl.lbl_attributes fn lbl.lbl_name; mutable_flag = lbl.Types.lbl_mut} + +let fld_record_set (lbl : label) = + Lambda.Fld_record_set + (Ext_list.find_def lbl.lbl_attributes fn lbl.lbl_name) + +let blk_record fields = + let all_labels_info = + Ext_array.map fields + (fun ((lbl : label),_) -> + Ext_list.find_def lbl.Types.lbl_attributes fn lbl.lbl_name) in + Lambda.Blk_record all_labels_info + +let check_bs_attributes_inclusion + (attrs1 : Parsetree.attributes) + (attrs2 : Parsetree.attributes) + lbl_name = + let a = Ext_list.find_def attrs1 fn lbl_name in + let b = Ext_list.find_def attrs2 fn lbl_name in + if a = b then None + else Some (a,b) -let check l (x, _) = List.mem x.txt l -let has_unboxed attr = - List.exists (check ["ocaml.unboxed"; "unboxed"]) - attr -let has_boxed attr = - List.exists (check ["ocaml.boxed"; "boxed"]) attr end -module Depend : sig -#1 "depend.mli" +module Bs_conditional_initial : sig +#1 "bs_conditional_initial.mli" +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) + +(** This function set up built in compile time variables used in + conditional compilation so that + {[ + #if BS then + #elif .. then + #end + ]} + Is understood, also make sure the playground do the same initialization. +*) +val setup_env : unit -> unit + + +end = struct +#1 "bs_conditional_initial.ml" +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) + + +let setup_env () = + Clflags.compile_only := true; + Clflags.bs_only := true; + Clflags.no_implicit_current_dir := true; + (* default true + otherwise [bsc -I sc src/hello.ml ] will include current directory to search path + *) + Clflags.assume_no_mli := Clflags.Mli_non_exists; + Clflags.unsafe_string := false; + Clflags.debug := true; + Clflags.record_event_when_debug := false; + Clflags.binary_annotations := true; + (* Turn on [-no-alias-deps] by default -- double check *) + Oprint.out_ident := Outcome_printer_ns.out_ident; + Builtin_attributes.check_bs_attributes_inclusion := Record_attributes_check.check_bs_attributes_inclusion; + Lambda.fld_record := Record_attributes_check.fld_record; + Lambda.fld_record_set := Record_attributes_check.fld_record_set; + Lambda.blk_record := Record_attributes_check.blk_record; + + Lexer.replace_directive_bool "BS" true; + Lexer.replace_directive_string "BS_VERSION" Bs_version.version + + + +end +module Ccomp : sig +#1 "ccomp.mli" (**************************************************************************) (* *) (* OCaml *) (* *) (* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) (* *) -(* Copyright 1999 Institut National de Recherche en Informatique et *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -26332,42 +26595,34 @@ module Depend : sig (* *) (**************************************************************************) -(** Module dependencies. *) - -module StringSet : Set.S with type elt = string -module StringMap : Map.S with type key = string - -type map_tree = Node of StringSet.t * bound_map -and bound_map = map_tree StringMap.t -val make_leaf : string -> map_tree -val make_node : bound_map -> map_tree -val weaken_map : StringSet.t -> map_tree -> map_tree - -val free_structure_names : StringSet.t ref - -(* dependencies found by preprocessing tools (plugins) *) -val pp_deps : string list ref - -val open_module : bound_map -> Longident.t -> bound_map - -val add_use_file : bound_map -> Parsetree.toplevel_phrase list -> unit +(* Compiling C files and building C libraries *) -val add_signature : bound_map -> Parsetree.signature -> unit +val command: string -> int +val run_command: string -> unit +val compile_file: ?output:string -> ?opt:string -> string -> int +val create_archive: string -> string list -> int +val expand_libname: string -> string +val quote_files: string list -> string +val quote_optfile: string option -> string +(*val make_link_options: string list -> string*) -val add_implementation : bound_map -> Parsetree.structure -> unit +type link_mode = + | Exe + | Dll + | MainDll + | Partial -val add_implementation_binding : bound_map -> Parsetree.structure -> bound_map -val add_signature_binding : bound_map -> Parsetree.signature -> bound_map +val call_linker: link_mode -> string -> string list -> string -> bool end = struct -#1 "depend.ml" +#1 "ccomp.ml" (**************************************************************************) (* *) (* OCaml *) (* *) (* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) (* *) -(* Copyright 1999 Institut National de Recherche en Informatique et *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -26376,528 +26631,287 @@ end = struct (* *) (**************************************************************************) -open Asttypes -open Location -open Longident -open Parsetree +(* Compiling C files and building C libraries *) -let pp_deps = ref [] +let command cmdline = + if !Clflags.verbose then begin + prerr_string "+ "; + prerr_string cmdline; + prerr_newline() + end; + Sys.command cmdline -module StringSet = Set.Make(struct type t = string let compare = compare end) -module StringMap = Map.Make(String) +let run_command cmdline = ignore(command cmdline) -(* Module resolution map *) -(* Node (set of imports for this path, map for submodules) *) -type map_tree = Node of StringSet.t * bound_map -and bound_map = map_tree StringMap.t -let bound = Node (StringSet.empty, StringMap.empty) +(* Build @responsefile to work around Windows limitations on + command-line length *) +let build_diversion lst = + let (responsefile, oc) = Filename.open_temp_file "camlresp" "" in + List.iter (fun f -> Printf.fprintf oc "%s\n" f) lst; + close_out oc; + at_exit (fun () -> Misc.remove_file responsefile); + "@" ^ responsefile -(*let get_free (Node (s, _m)) = s*) -let get_map (Node (_s, m)) = m -let make_leaf s = Node (StringSet.singleton s, StringMap.empty) -let make_node m = Node (StringSet.empty, m) -let rec weaken_map s (Node(s0,m0)) = - Node (StringSet.union s s0, StringMap.map (weaken_map s) m0) -let rec collect_free (Node (s, m)) = - StringMap.fold (fun _ n -> StringSet.union (collect_free n)) m s +let quote_files lst = + let lst = List.filter (fun f -> f <> "") lst in + let quoted = List.map Filename.quote lst in + let s = String.concat " " quoted in + if String.length s >= 4096 && Sys.os_type = "Win32" + then build_diversion quoted + else s -(* Returns the imports required to access the structure at path p *) -(* Only raises Not_found if the head of p is not in the toplevel map *) -let rec lookup_free p m = - match p with - [] -> raise Not_found - | s::p -> - let Node (f, m') = StringMap.find s m in - try lookup_free p m' with Not_found -> f +let quote_prefixed pr lst = + let lst = List.filter (fun f -> f <> "") lst in + let lst = List.map (fun f -> pr ^ f) lst in + quote_files lst -(* Returns the node corresponding to the structure at path p *) -let rec lookup_map lid m = - match lid with - Lident s -> StringMap.find s m - | Ldot (l, s) -> StringMap.find s (get_map (lookup_map l m)) - | Lapply _ -> raise Not_found +let quote_optfile = function + | None -> "" + | Some f -> Filename.quote f -(* Collect free module identifiers in the a.s.t. *) +let display_msvc_output file name = + let c = open_in file in + try + let first = input_line c in + if first <> Filename.basename name then + print_string first; + while true do + print_string (input_line c) + done + with _ -> + close_in c; + Sys.remove file -let free_structure_names = ref StringSet.empty +let compile_file ?output ?(opt="") name = + let (pipe, file) = + if Config.ccomp_type = "msvc" && not !Clflags.verbose then + try + let (t, c) = Filename.open_temp_file "msvc" "stdout" in + close_out c; + (Printf.sprintf " > %s" (Filename.quote t), t) + with _ -> + ("", "") + else + ("", "") in + let exit = + command + (Printf.sprintf + "%s %s %s -c %s %s %s %s %s%s" + (match !Clflags.c_compiler with + | Some cc -> cc + | None -> + let (cflags, cppflags) = + if !Clflags.native_code + then (Config.ocamlopt_cflags, Config.ocamlopt_cppflags) + else (Config.ocamlc_cflags, Config.ocamlc_cppflags) in + (String.concat " " [Config.c_compiler; cflags; cppflags])) + (match output with + | None -> "" + | Some o -> Printf.sprintf "%s%s" Config.c_output_obj o) + opt + (if !Clflags.debug && Config.ccomp_type <> "msvc" then "-g" else "") + (String.concat " " (List.rev !Clflags.all_ccopts)) + (quote_prefixed "-I" (List.rev !Clflags.include_dirs)) + (Clflags.std_include_flag "-I") + (Filename.quote name) + (* cl tediously includes the name of the C file as the first thing it + outputs (in fairness, the tedious thing is that there's no switch to + disable this behaviour). In the absence of the Unix module, use + a temporary file to filter the output (cannot pipe the output to a + filter because this removes the exit status of cl, which is wanted. + *) + pipe) in + if pipe <> "" + then display_msvc_output file name; + exit -let add_names s = - free_structure_names := StringSet.union s !free_structure_names +let macos_create_empty_archive ~quoted_archive = + let result = + command (Printf.sprintf "%s rc %s /dev/null" Config.ar quoted_archive) + in + if result <> 0 then result + else + let result = + command (Printf.sprintf "%s %s 2> /dev/null" Config.ranlib quoted_archive) + in + if result <> 0 then result + else + command (Printf.sprintf "%s d %s /dev/null" Config.ar quoted_archive) -let rec add_path bv ?(p=[]) = function - | Lident s -> - let free = - try lookup_free (s::p) bv with Not_found -> StringSet.singleton s +let create_archive archive file_list = + Misc.remove_file archive; + let quoted_archive = Filename.quote archive in + match Config.ccomp_type with + "msvc" -> + command(Printf.sprintf "link /lib /nologo /out:%s %s" + quoted_archive (quote_files file_list)) + | _ -> + assert(String.length Config.ar > 0); + let is_macosx = + match Config.system with + | "macosx" -> true + | _ -> false in - (*StringSet.iter (fun s -> Printf.eprintf "%s " s) free; - prerr_endline "";*) - add_names free - | Ldot(l, s) -> add_path bv ~p:(s::p) l - | Lapply(l1, l2) -> add_path bv l1; add_path bv l2 + if is_macosx && file_list = [] then (* PR#6550 *) + macos_create_empty_archive ~quoted_archive + else + let r1 = + command(Printf.sprintf "%s rc %s %s" + Config.ar quoted_archive (quote_files file_list)) in + if r1 <> 0 || String.length Config.ranlib = 0 + then r1 + else command(Config.ranlib ^ " " ^ quoted_archive) -let open_module bv lid = - match lookup_map lid bv with - | Node (s, m) -> - add_names s; - StringMap.fold StringMap.add m bv - | exception Not_found -> - add_path bv lid; bv +let expand_libname name = + if String.length name < 2 || String.sub name 0 2 <> "-l" + then name + else begin + let libname = + "lib" ^ String.sub name 2 (String.length name - 2) ^ Config.ext_lib in + try + Misc.find_in_path !Config.load_path libname + with Not_found -> + libname + end -let add_parent bv lid = - match lid.txt with - Ldot(l, _s) -> add_path bv l - | _ -> () +type link_mode = + | Exe + | Dll + | MainDll + | Partial -let add = add_parent +let remove_Wl cclibs = + cclibs |> List.map (fun cclib -> + (* -Wl,-foo,bar -> -foo bar *) + if String.length cclib >= 4 && "-Wl," = String.sub cclib 0 4 then + String.map (function ',' -> ' ' | c -> c) + (String.sub cclib 4 (String.length cclib - 4)) + else cclib) -let addmodule bv lid = add_path bv lid.txt +let call_linker mode output_name files extra = + let cmd = + if mode = Partial then + let l_prefix = + match Config.ccomp_type with + | "msvc" -> "/libpath:" + | _ -> "-L" + in + Printf.sprintf "%s%s %s %s %s" + Config.native_pack_linker + (Filename.quote output_name) + (quote_prefixed l_prefix !Config.load_path) + (quote_files (remove_Wl files)) + extra + else + Printf.sprintf "%s -o %s %s %s %s %s %s %s" + (match !Clflags.c_compiler, mode with + | Some cc, _ -> cc + | None, Exe -> Config.mkexe + | None, Dll -> Config.mkdll + | None, MainDll -> Config.mkmaindll + | None, Partial -> assert false + ) + (Filename.quote output_name) + (if !Clflags.gprofile then Config.cc_profile else "") + "" (*(Clflags.std_include_flag "-I")*) + (quote_prefixed "-L" !Config.load_path) + (String.concat " " (List.rev !Clflags.all_ccopts)) + (quote_files files) + extra + in + command cmd = 0 -let handle_extension ext = - match (fst ext).txt with - | "error" | "ocaml.error" -> - raise (Location.Error - (Builtin_attributes.error_of_extension ext)) - | _ -> - () +end +module Compenv : sig +#1 "compenv.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Fabrice Le Fessant, EPI Gallium, INRIA Paris-Rocquencourt *) +(* *) +(* Copyright 2013 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -let rec add_type bv ty = - match ty.ptyp_desc with - Ptyp_any -> () - | Ptyp_var _ -> () - | Ptyp_arrow(_, t1, t2) -> add_type bv t1; add_type bv t2 - | Ptyp_tuple tl -> List.iter (add_type bv) tl - | Ptyp_constr(c, tl) -> add bv c; List.iter (add_type bv) tl - | Ptyp_object (fl, _) -> - List.iter - (function Otag (_, _, t) -> add_type bv t - | Oinherit t -> add_type bv t) fl - | Ptyp_class(c, tl) -> add bv c; List.iter (add_type bv) tl - | Ptyp_alias(t, _) -> add_type bv t - | Ptyp_variant(fl, _, _) -> - List.iter - (function Rtag(_,_,_,stl) -> List.iter (add_type bv) stl - | Rinherit sty -> add_type bv sty) - fl - | Ptyp_poly(_, t) -> add_type bv t - | Ptyp_package pt -> add_package_type bv pt - | Ptyp_extension e -> handle_extension e - -and add_package_type bv (lid, l) = - add bv lid; - List.iter (add_type bv) (List.map (fun (_, e) -> e) l) - -let add_opt add_fn bv = function - None -> () - | Some x -> add_fn bv x - -let add_constructor_arguments bv = function - | Pcstr_tuple l -> List.iter (add_type bv) l - | Pcstr_record l -> List.iter (fun l -> add_type bv l.pld_type) l - -let add_constructor_decl bv pcd = - add_constructor_arguments bv pcd.pcd_args; - Misc.may (add_type bv) pcd.pcd_res - -let add_type_declaration bv td = - List.iter - (fun (ty1, ty2, _) -> add_type bv ty1; add_type bv ty2) - td.ptype_cstrs; - add_opt add_type bv td.ptype_manifest; - let add_tkind = function - Ptype_abstract -> () - | Ptype_variant cstrs -> - List.iter (add_constructor_decl bv) cstrs - | Ptype_record lbls -> - List.iter (fun pld -> add_type bv pld.pld_type) lbls - | Ptype_open -> () in - add_tkind td.ptype_kind - -let add_extension_constructor bv ext = - match ext.pext_kind with - Pext_decl(args, rty) -> - add_constructor_arguments bv args; - Misc.may (add_type bv) rty - | Pext_rebind lid -> add bv lid - -let add_type_extension bv te = - add bv te.ptyext_path; - List.iter (add_extension_constructor bv) te.ptyext_constructors - -let rec add_class_type bv cty = - match cty.pcty_desc with - Pcty_constr(l, tyl) -> - add bv l; List.iter (add_type bv) tyl - | Pcty_signature { pcsig_self = ty; pcsig_fields = fieldl } -> - add_type bv ty; - List.iter (add_class_type_field bv) fieldl - | Pcty_arrow(_, ty1, cty2) -> - add_type bv ty1; add_class_type bv cty2 - | Pcty_extension e -> handle_extension e - | Pcty_open (_ovf, m, e) -> - let bv = open_module bv m.txt in add_class_type bv e - -and add_class_type_field bv pctf = - match pctf.pctf_desc with - Pctf_inherit cty -> add_class_type bv cty - | Pctf_val(_, _, _, ty) -> add_type bv ty - | Pctf_method(_, _, _, ty) -> add_type bv ty - | Pctf_constraint(ty1, ty2) -> add_type bv ty1; add_type bv ty2 - | Pctf_attribute _ -> () - | Pctf_extension e -> handle_extension e - -let add_class_description bv infos = - add_class_type bv infos.pci_expr - -let add_class_type_declaration = add_class_description - -let pattern_bv = ref StringMap.empty - -let rec add_pattern bv pat = - match pat.ppat_desc with - Ppat_any -> () - | Ppat_var _ -> () - | Ppat_alias(p, _) -> add_pattern bv p - | Ppat_interval _ - | Ppat_constant _ -> () - | Ppat_tuple pl -> List.iter (add_pattern bv) pl - | Ppat_construct(c, op) -> add bv c; add_opt add_pattern bv op - | Ppat_record(pl, _) -> - List.iter (fun (lbl, p) -> add bv lbl; add_pattern bv p) pl - | Ppat_array pl -> List.iter (add_pattern bv) pl - | Ppat_or(p1, p2) -> add_pattern bv p1; add_pattern bv p2 - | Ppat_constraint(p, ty) -> add_pattern bv p; add_type bv ty - | Ppat_variant(_, op) -> add_opt add_pattern bv op - | Ppat_type li -> add bv li - | Ppat_lazy p -> add_pattern bv p - | Ppat_unpack id -> pattern_bv := StringMap.add id.txt bound !pattern_bv - | Ppat_open ( m, p) -> let bv = open_module bv m.txt in add_pattern bv p - | Ppat_exception p -> add_pattern bv p - | Ppat_extension e -> handle_extension e - -let add_pattern bv pat = - pattern_bv := bv; - add_pattern bv pat; - !pattern_bv - -let rec add_expr bv exp = - match exp.pexp_desc with - Pexp_ident l -> add bv l - | Pexp_constant _ -> () - | Pexp_let(rf, pel, e) -> - let bv = add_bindings rf bv pel in add_expr bv e - | Pexp_fun (_, opte, p, e) -> - add_opt add_expr bv opte; add_expr (add_pattern bv p) e - | Pexp_function pel -> - add_cases bv pel - | Pexp_apply(e, el) -> - add_expr bv e; List.iter (fun (_,e) -> add_expr bv e) el - | Pexp_match(e, pel) -> add_expr bv e; add_cases bv pel - | Pexp_try(e, pel) -> add_expr bv e; add_cases bv pel - | Pexp_tuple el -> List.iter (add_expr bv) el - | Pexp_construct(c, opte) -> add bv c; add_opt add_expr bv opte - | Pexp_variant(_, opte) -> add_opt add_expr bv opte - | Pexp_record(lblel, opte) -> - List.iter (fun (lbl, e) -> add bv lbl; add_expr bv e) lblel; - add_opt add_expr bv opte - | Pexp_field(e, fld) -> add_expr bv e; add bv fld - | Pexp_setfield(e1, fld, e2) -> add_expr bv e1; add bv fld; add_expr bv e2 - | Pexp_array el -> List.iter (add_expr bv) el - | Pexp_ifthenelse(e1, e2, opte3) -> - add_expr bv e1; add_expr bv e2; add_opt add_expr bv opte3 - | Pexp_sequence(e1, e2) -> add_expr bv e1; add_expr bv e2 - | Pexp_while(e1, e2) -> add_expr bv e1; add_expr bv e2 - | Pexp_for( _, e1, e2, _, e3) -> - add_expr bv e1; add_expr bv e2; add_expr bv e3 - | Pexp_coerce(e1, oty2, ty3) -> - add_expr bv e1; - add_opt add_type bv oty2; - add_type bv ty3 - | Pexp_constraint(e1, ty2) -> - add_expr bv e1; - add_type bv ty2 - | Pexp_send(e, _m) -> add_expr bv e - | Pexp_new li -> add bv li - | Pexp_setinstvar(_v, e) -> add_expr bv e - | Pexp_override sel -> List.iter (fun (_s, e) -> add_expr bv e) sel - | Pexp_letmodule(id, m, e) -> - let b = add_module_binding bv m in - add_expr (StringMap.add id.txt b bv) e - | Pexp_letexception(_, e) -> add_expr bv e - | Pexp_assert (e) -> add_expr bv e - | Pexp_lazy (e) -> add_expr bv e - | Pexp_poly (e, t) -> add_expr bv e; add_opt add_type bv t - | Pexp_object { pcstr_self = pat; pcstr_fields = fieldl } -> - let bv = add_pattern bv pat in List.iter (add_class_field bv) fieldl - | Pexp_newtype (_, e) -> add_expr bv e - | Pexp_pack m -> add_module bv m - | Pexp_open (_ovf, m, e) -> - let bv = open_module bv m.txt in add_expr bv e - | Pexp_extension (({ txt = ("ocaml.extension_constructor"| - "extension_constructor"); _ }, - PStr [item]) as e) -> - begin match item.pstr_desc with - | Pstr_eval ({ pexp_desc = Pexp_construct (c, None) }, _) -> add bv c - | _ -> handle_extension e - end - | Pexp_extension e -> handle_extension e - | Pexp_unreachable -> () - -and add_cases bv cases = - List.iter (add_case bv) cases - -and add_case bv {pc_lhs; pc_guard; pc_rhs} = - let bv = add_pattern bv pc_lhs in - add_opt add_expr bv pc_guard; - add_expr bv pc_rhs - -and add_bindings recf bv pel = - let bv' = List.fold_left (fun bv x -> add_pattern bv x.pvb_pat) bv pel in - let bv = if recf = Recursive then bv' else bv in - List.iter (fun x -> add_expr bv x.pvb_expr) pel; - bv' - -and add_modtype bv mty = - match mty.pmty_desc with - Pmty_ident l -> add bv l - | Pmty_alias l -> addmodule bv l - | Pmty_signature s -> add_signature bv s - | Pmty_functor(id, mty1, mty2) -> - Misc.may (add_modtype bv) mty1; - add_modtype (StringMap.add id.txt bound bv) mty2 - | Pmty_with(mty, cstrl) -> - add_modtype bv mty; - List.iter - (function - | Pwith_type (_, td) -> add_type_declaration bv td - | Pwith_module (_, lid) -> addmodule bv lid - | Pwith_typesubst (_, td) -> add_type_declaration bv td - | Pwith_modsubst (_, lid) -> addmodule bv lid - ) - cstrl - | Pmty_typeof m -> add_module bv m - | Pmty_extension e -> handle_extension e - -and add_module_alias bv l = - try - add_parent bv l; - lookup_map l.txt bv - with Not_found -> - match l.txt with - Lident s -> make_leaf s - | _ -> addmodule bv l; bound (* cannot delay *) - -and add_modtype_binding bv mty = - if not !Clflags.transparent_modules then add_modtype bv mty; - match mty.pmty_desc with - Pmty_alias l -> - add_module_alias bv l - | Pmty_signature s -> - make_node (add_signature_binding bv s) - | Pmty_typeof modl -> - add_module_binding bv modl - | _ -> - if !Clflags.transparent_modules then add_modtype bv mty; bound - -and add_signature bv sg = - ignore (add_signature_binding bv sg) +val module_of_filename : Format.formatter -> string -> string -> string -and add_signature_binding bv sg = - snd (List.fold_left add_sig_item (bv, StringMap.empty) sg) +val output_prefix : string -> string +val extract_output : string option -> string +val default_output : string option -> string -and add_sig_item (bv, m) item = - match item.psig_desc with - Psig_value vd -> - add_type bv vd.pval_type; (bv, m) - | Psig_type (_, dcls) -> - List.iter (add_type_declaration bv) dcls; (bv, m) - | Psig_typext te -> - add_type_extension bv te; (bv, m) - | Psig_exception pext -> - add_extension_constructor bv pext; (bv, m) - | Psig_module pmd -> - let m' = add_modtype_binding bv pmd.pmd_type in - let add = StringMap.add pmd.pmd_name.txt m' in - (add bv, add m) - | Psig_recmodule decls -> - let add = - List.fold_right (fun pmd -> StringMap.add pmd.pmd_name.txt bound) - decls - in - let bv' = add bv and m' = add m in - List.iter (fun pmd -> add_modtype bv' pmd.pmd_type) decls; - (bv', m') - | Psig_modtype x -> - begin match x.pmtd_type with - None -> () - | Some mty -> add_modtype bv mty - end; - (bv, m) - | Psig_open od -> - (open_module bv od.popen_lid.txt, m) - | Psig_include incl -> - let Node (s, m') = add_modtype_binding bv incl.pincl_mod in - add_names s; - let add = StringMap.fold StringMap.add m' in - (add bv, add m) - | Psig_class cdl -> - List.iter (add_class_description bv) cdl; (bv, m) - | Psig_class_type cdtl -> - List.iter (add_class_type_declaration bv) cdtl; (bv, m) - | Psig_attribute _ -> (bv, m) - | Psig_extension (e, _) -> - handle_extension e; - (bv, m) +val print_version_and_library : string -> 'a +val print_version_string : unit -> 'a +val print_standard_library : unit -> 'a +val fatal : string -> 'a -and add_module_binding bv modl = - if not !Clflags.transparent_modules then add_module bv modl; - match modl.pmod_desc with - Pmod_ident l -> - begin try - add_parent bv l; - lookup_map l.txt bv - with Not_found -> - match l.txt with - Lident s -> make_leaf s - | _ -> addmodule bv l; bound - end - | Pmod_structure s -> - make_node (snd (add_structure_binding bv s)) - | _ -> - if !Clflags.transparent_modules then add_module bv modl; bound +val first_ccopts : string list ref +val first_ppx : string list ref +val first_include_dirs : string list ref +val last_include_dirs : string list ref +val implicit_modules : string list ref -and add_module bv modl = - match modl.pmod_desc with - Pmod_ident l -> addmodule bv l - | Pmod_structure s -> ignore (add_structure bv s) - | Pmod_functor(id, mty, modl) -> - Misc.may (add_modtype bv) mty; - add_module (StringMap.add id.txt bound bv) modl - | Pmod_apply(mod1, mod2) -> - add_module bv mod1; add_module bv mod2 - | Pmod_constraint(modl, mty) -> - add_module bv modl; add_modtype bv mty - | Pmod_unpack(e) -> - add_expr bv e - | Pmod_extension e -> - handle_extension e +(* function to call on plugin=XXX *) +val load_plugin : (string -> unit) ref -and add_structure bv item_list = - let (bv, m) = add_structure_binding bv item_list in - add_names (collect_free (make_node m)); - bv +(* return the list of objfiles, after OCAMLPARAM and List.rev *) +val get_objfiles : with_ocamlparam:bool -> string list +val last_objfiles : string list ref +val first_objfiles : string list ref -and add_structure_binding bv item_list = - List.fold_left add_struct_item (bv, StringMap.empty) item_list +type filename = string -and add_struct_item (bv, m) item : _ StringMap.t * _ StringMap.t = - match item.pstr_desc with - Pstr_eval (e, _attrs) -> - add_expr bv e; (bv, m) - | Pstr_value(rf, pel) -> - let bv = add_bindings rf bv pel in (bv, m) - | Pstr_primitive vd -> - add_type bv vd.pval_type; (bv, m) - | Pstr_type (_, dcls) -> - List.iter (add_type_declaration bv) dcls; (bv, m) - | Pstr_typext te -> - add_type_extension bv te; - (bv, m) - | Pstr_exception pext -> - add_extension_constructor bv pext; (bv, m) - | Pstr_module x -> - let b = add_module_binding bv x.pmb_expr in - let add = StringMap.add x.pmb_name.txt b in - (add bv, add m) - | Pstr_recmodule bindings -> - let add = - List.fold_right (fun x -> StringMap.add x.pmb_name.txt bound) bindings - in - let bv' = add bv and m = add m in - List.iter - (fun x -> add_module bv' x.pmb_expr) - bindings; - (bv', m) - | Pstr_modtype x -> - begin match x.pmtd_type with - None -> () - | Some mty -> add_modtype bv mty - end; - (bv, m) - | Pstr_open od -> - (open_module bv od.popen_lid.txt, m) - | Pstr_class cdl -> - List.iter (add_class_declaration bv) cdl; (bv, m) - | Pstr_class_type cdtl -> - List.iter (add_class_type_declaration bv) cdtl; (bv, m) - | Pstr_include incl -> - let Node (s, m') = add_module_binding bv incl.pincl_mod in - add_names s; - let add = StringMap.fold StringMap.add m' in - (add bv, add m) - | Pstr_attribute _ -> (bv, m) - | Pstr_extension (e, _) -> - handle_extension e; - (bv, m) +type readenv_position = + Before_args | Before_compile of filename | Before_link -and add_use_file bv top_phrs = - ignore (List.fold_left add_top_phrase bv top_phrs) +val readenv : Format.formatter -> readenv_position -> unit -and add_implementation bv l = - if !Clflags.transparent_modules then - ignore (add_structure_binding bv l) - else ignore (add_structure bv l) +(* [is_unit_name name] returns true only if [name] can be used as a + correct module name *) +val is_unit_name : string -> bool +(* [check_unit_name ppf filename name] prints a warning in [filename] + on [ppf] if [name] should not be used as a module name. *) +val check_unit_name : Format.formatter -> string -> string -> unit -and add_implementation_binding bv l = - snd (add_structure_binding bv l) +(* Deferred actions of the compiler, while parsing arguments *) -and add_top_phrase bv = function - | Ptop_def str -> add_structure bv str - | Ptop_dir (_, _) -> bv +type deferred_action = + | ProcessImplementation of string + | ProcessInterface of string + | ProcessCFile of string + | ProcessOtherFile of string + | ProcessObjects of string list + | ProcessDLLs of string list -and add_class_expr bv ce = - match ce.pcl_desc with - Pcl_constr(l, tyl) -> - add bv l; List.iter (add_type bv) tyl - | Pcl_structure { pcstr_self = pat; pcstr_fields = fieldl } -> - let bv = add_pattern bv pat in List.iter (add_class_field bv) fieldl - | Pcl_fun(_, opte, pat, ce) -> - add_opt add_expr bv opte; - let bv = add_pattern bv pat in add_class_expr bv ce - | Pcl_apply(ce, exprl) -> - add_class_expr bv ce; List.iter (fun (_,e) -> add_expr bv e) exprl - | Pcl_let(rf, pel, ce) -> - let bv = add_bindings rf bv pel in add_class_expr bv ce - | Pcl_constraint(ce, ct) -> - add_class_expr bv ce; add_class_type bv ct - | Pcl_extension e -> handle_extension e - | Pcl_open (_ovf, m, e) -> - let bv = open_module bv m.txt in add_class_expr bv e +val c_object_of_filename : string -> string -and add_class_field bv pcf = - match pcf.pcf_desc with - Pcf_inherit(_, ce, _) -> add_class_expr bv ce - | Pcf_val(_, _, Cfk_concrete (_, e)) - | Pcf_method(_, _, Cfk_concrete (_, e)) -> add_expr bv e - | Pcf_val(_, _, Cfk_virtual ty) - | Pcf_method(_, _, Cfk_virtual ty) -> add_type bv ty - | Pcf_constraint(ty1, ty2) -> add_type bv ty1; add_type bv ty2 - | Pcf_initializer e -> add_expr bv e - | Pcf_attribute _ -> () - | Pcf_extension e -> handle_extension e +val defer : deferred_action -> unit +val anonymous : string -> unit +val impl : string -> unit +val intf : string -> unit -and add_class_declaration bv decl = - add_class_expr bv decl.pci_expr +val process_deferred_actions : + Format.formatter * + (Format.formatter -> string -> string -> unit) * (* compile implementation *) + (Format.formatter -> string -> string -> unit) * (* compile interface *) + string * (* ocaml module extension *) + string -> (* ocaml library extension *) + unit -end -module Parse : sig -#1 "parse.mli" +end = struct +#1 "compenv.ml" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* Fabrice Le Fessant, EPI Gallium, INRIA Paris-Rocquencourt *) (* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* Copyright 2013 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -26906,781 +26920,1557 @@ module Parse : sig (* *) (**************************************************************************) -(** Entry points in the parser *) +open Clflags -val implementation : Lexing.lexbuf -> Parsetree.structure -val interface : Lexing.lexbuf -> Parsetree.signature -val toplevel_phrase : Lexing.lexbuf -> Parsetree.toplevel_phrase -val use_file : Lexing.lexbuf -> Parsetree.toplevel_phrase list -val core_type : Lexing.lexbuf -> Parsetree.core_type -val expression : Lexing.lexbuf -> Parsetree.expression -val pattern : Lexing.lexbuf -> Parsetree.pattern +let output_prefix name = + let oname = + match !output_name with + | None -> name + | Some n -> if !compile_only then (output_name := None; n) else name in + Filename.remove_extension oname -end = struct -#1 "parse.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let print_version_and_library compiler = + Printf.printf "The OCaml %s, version " compiler; + print_string Config.version; print_newline(); + print_string "Standard library directory: "; + print_string Config.standard_library; print_newline(); + exit 0 -(* Entry points in the parser *) +let print_version_string () = + print_string Config.version; print_newline(); exit 0 -(* Skip tokens to the end of the phrase *) +let print_standard_library () = + print_string Config.standard_library; print_newline(); exit 0 -let rec skip_phrase lexbuf = - try - match Lexer.token lexbuf with - Parser.SEMISEMI | Parser.EOF -> () - | _ -> skip_phrase lexbuf - with - | Lexer.Error (Lexer.Unterminated_comment _, _) - | Lexer.Error (Lexer.Unterminated_string, _) - | Lexer.Error (Lexer.Unterminated_string_in_comment _, _) - | Lexer.Error (Lexer.Illegal_character _, _) -> skip_phrase lexbuf -;; - -let maybe_skip_phrase lexbuf = - if Parsing.is_current_lookahead Parser.SEMISEMI - || Parsing.is_current_lookahead Parser.EOF - then () - else skip_phrase lexbuf +let fatal err = + prerr_endline err; + exit 2 -let wrap parsing_fun lexbuf = - try - Docstrings.init (); - Lexer.init (); - let ast = parsing_fun Lexer.token lexbuf in - Parsing.clear_parser(); - Docstrings.warn_bad_docstrings (); - ast - with - | Lexer.Error(Lexer.Illegal_character _, _) as err - when !Location.input_name = "//toplevel//"-> - skip_phrase lexbuf; - raise err - | Syntaxerr.Error _ as err - when !Location.input_name = "//toplevel//" -> - maybe_skip_phrase lexbuf; - raise err - | Parsing.Parse_error | Syntaxerr.Escape_error -> - let loc = Location.curr lexbuf in - if !Location.input_name = "//toplevel//" - then maybe_skip_phrase lexbuf; - raise(Syntaxerr.Error(Syntaxerr.Other loc)) +let extract_output = function + | Some s -> s + | None -> + fatal "Please specify the name of the output file, using option -o" -let implementation = wrap Parser.implementation -and interface = wrap Parser.interface -and toplevel_phrase = wrap Parser.toplevel_phrase -and use_file = wrap Parser.use_file -and core_type = wrap Parser.parse_core_type -and expression = wrap Parser.parse_expression -and pattern = wrap Parser.parse_pattern +let default_output = function + | Some s -> s + | None -> Config.default_executable_name -end -module Ast_iterator : sig -#1 "ast_iterator.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Nicolas Ojeda Bar, LexiFi *) -(* *) -(* Copyright 2012 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let implicit_modules = ref [] +let first_include_dirs = ref [] +let last_include_dirs = ref [] +let first_ccopts = ref [] +let last_ccopts = ref [] +let first_ppx = ref [] +let last_ppx = ref [] +let first_objfiles = ref [] +let last_objfiles = ref [] -(** {!iterator} allows to implement AST inspection using open recursion. A - typical mapper would be based on {!default_iterator}, a trivial iterator, - and will fall back on it for handling the syntax it does not modify. *) +(* Check validity of module name *) +let is_unit_name name = + try + if name = "" then raise Exit; + begin match name.[0] with + | 'A'..'Z' -> () + | _ -> + raise Exit; + end; + for i = 1 to String.length name - 1 do + match name.[i] with + | 'A'..'Z' | 'a'..'z' | '0'..'9' | '_' | '\'' -> () + | _ -> + raise Exit; + done; + true + with Exit -> false +;; -open Parsetree +let check_unit_name ppf filename name = -(** {1 A generic Parsetree iterator} *) + let _ = ppf in + let _ = filename in + let _ = name in + () -type iterator = { - attribute: iterator -> attribute -> unit; - attributes: iterator -> attribute list -> unit; - case: iterator -> case -> unit; - cases: iterator -> case list -> unit; - class_declaration: iterator -> class_declaration -> unit; - class_description: iterator -> class_description -> unit; - class_expr: iterator -> class_expr -> unit; - class_field: iterator -> class_field -> unit; - class_signature: iterator -> class_signature -> unit; - class_structure: iterator -> class_structure -> unit; - class_type: iterator -> class_type -> unit; - class_type_declaration: iterator -> class_type_declaration -> unit; - class_type_field: iterator -> class_type_field -> unit; - constructor_declaration: iterator -> constructor_declaration -> unit; - expr: iterator -> expression -> unit; - extension: iterator -> extension -> unit; - extension_constructor: iterator -> extension_constructor -> unit; - include_declaration: iterator -> include_declaration -> unit; - include_description: iterator -> include_description -> unit; - label_declaration: iterator -> label_declaration -> unit; - location: iterator -> Location.t -> unit; - module_binding: iterator -> module_binding -> unit; - module_declaration: iterator -> module_declaration -> unit; - module_expr: iterator -> module_expr -> unit; - module_type: iterator -> module_type -> unit; - module_type_declaration: iterator -> module_type_declaration -> unit; - open_description: iterator -> open_description -> unit; - pat: iterator -> pattern -> unit; - payload: iterator -> payload -> unit; - signature: iterator -> signature -> unit; - signature_item: iterator -> signature_item -> unit; - structure: iterator -> structure -> unit; - structure_item: iterator -> structure_item -> unit; - typ: iterator -> core_type -> unit; - type_declaration: iterator -> type_declaration -> unit; - type_extension: iterator -> type_extension -> unit; - type_kind: iterator -> type_kind -> unit; - value_binding: iterator -> value_binding -> unit; - value_description: iterator -> value_description -> unit; - with_constraint: iterator -> with_constraint -> unit; -} -(** A [iterator] record implements one "method" per syntactic category, - using an open recursion style: each method takes as its first - argument the iterator to be applied to children in the syntax - tree. *) -val default_iterator: iterator -(** A default iterator, which implements a "do not do anything" mapping. *) +(* Compute name of module from output file name *) +let module_of_filename ppf inputfile outputprefix = + let basename = Filename.basename outputprefix in + let name = + try + let pos = String.index basename '.' in + String.sub basename 0 pos + with Not_found -> basename + in + let name = String.capitalize_ascii name in + check_unit_name ppf inputfile name; + name +;; -end = struct -#1 "ast_iterator.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Nicolas Ojeda Bar, LexiFi *) -(* *) -(* Copyright 2012 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +type filename = string -(* A generic Parsetree mapping class *) +type readenv_position = + Before_args | Before_compile of filename | Before_link -(* -[@@@ocaml.warning "+9"] - (* Ensure that record patterns don't miss any field. *) -*) +(* Syntax of OCAMLPARAM: (name=VALUE,)* _ (,name=VALUE)* + where VALUE should not contain ',' *) +exception SyntaxError of string +let parse_args s = + let args = String.split_on_char ',' s in + let rec iter is_after args before after = + match args with + [] -> + if not is_after then + raise (SyntaxError "no '_' separator found") + else + (List.rev before, List.rev after) + | "_" :: _ when is_after -> raise (SyntaxError "too many '_' separators") + | "_" :: tail -> iter true tail before after + | arg :: tail -> + let binding = try + Misc.cut_at arg '=' + with Not_found -> + raise (SyntaxError ("missing '=' in " ^ arg)) + in + if is_after then + iter is_after tail before (binding :: after) + else + iter is_after tail (binding :: before) after + in + iter false args [] [] -open Parsetree -open Location +let setter ppf f name options s = + try + let bool = match s with + | "0" -> false + | "1" -> true + | _ -> raise Not_found + in + List.iter (fun b -> b := f bool) options + with Not_found -> + Location.print_warning Location.none ppf + (Warnings.Bad_env_variable ("OCAMLPARAM", + Printf.sprintf "bad value for %s" name)) -type iterator = { - attribute: iterator -> attribute -> unit; - attributes: iterator -> attribute list -> unit; - case: iterator -> case -> unit; - cases: iterator -> case list -> unit; - class_declaration: iterator -> class_declaration -> unit; - class_description: iterator -> class_description -> unit; - class_expr: iterator -> class_expr -> unit; - class_field: iterator -> class_field -> unit; - class_signature: iterator -> class_signature -> unit; - class_structure: iterator -> class_structure -> unit; - class_type: iterator -> class_type -> unit; - class_type_declaration: iterator -> class_type_declaration -> unit; - class_type_field: iterator -> class_type_field -> unit; - constructor_declaration: iterator -> constructor_declaration -> unit; - expr: iterator -> expression -> unit; - extension: iterator -> extension -> unit; - extension_constructor: iterator -> extension_constructor -> unit; - include_declaration: iterator -> include_declaration -> unit; - include_description: iterator -> include_description -> unit; - label_declaration: iterator -> label_declaration -> unit; - location: iterator -> Location.t -> unit; - module_binding: iterator -> module_binding -> unit; - module_declaration: iterator -> module_declaration -> unit; - module_expr: iterator -> module_expr -> unit; - module_type: iterator -> module_type -> unit; - module_type_declaration: iterator -> module_type_declaration -> unit; - open_description: iterator -> open_description -> unit; - pat: iterator -> pattern -> unit; - payload: iterator -> payload -> unit; - signature: iterator -> signature -> unit; - signature_item: iterator -> signature_item -> unit; - structure: iterator -> structure -> unit; - structure_item: iterator -> structure_item -> unit; - typ: iterator -> core_type -> unit; - type_declaration: iterator -> type_declaration -> unit; - type_extension: iterator -> type_extension -> unit; - type_kind: iterator -> type_kind -> unit; - value_binding: iterator -> value_binding -> unit; - value_description: iterator -> value_description -> unit; - with_constraint: iterator -> with_constraint -> unit; -} -(** A [iterator] record implements one "method" per syntactic category, - using an open recursion style: each method takes as its first - argument the iterator to be applied to children in the syntax - tree. *) +let int_setter ppf name option s = + try + option := int_of_string s + with _ -> + Location.print_warning Location.none ppf + (Warnings.Bad_env_variable + ("OCAMLPARAM", Printf.sprintf "non-integer parameter for \"%s\"" name)) -let iter_fst f (x, _) = f x -let iter_snd f (_, y) = f y -let iter_tuple f1 f2 (x, y) = f1 x; f2 y -let iter_tuple3 f1 f2 f3 (x, y, z) = f1 x; f2 y; f3 z -let iter_opt f = function None -> () | Some x -> f x +let int_option_setter ppf name option s = + try + option := Some (int_of_string s) + with _ -> + Location.print_warning Location.none ppf + (Warnings.Bad_env_variable + ("OCAMLPARAM", Printf.sprintf "non-integer parameter for \"%s\"" name)) -let iter_loc sub {loc; txt = _} = sub.location sub loc +(* +let float_setter ppf name option s = + try + option := float_of_string s + with _ -> + Location.print_warning Location.none ppf + (Warnings.Bad_env_variable + ("OCAMLPARAM", Printf.sprintf "non-float parameter for \"%s\"" name)) +*) -module T = struct - (* Type expressions for the core language *) +let load_plugin = ref (fun _ -> ()) - let row_field sub = function - | Rtag (_, attrs, _, tl) -> - sub.attributes sub attrs; List.iter (sub.typ sub) tl - | Rinherit t -> sub.typ sub t +let check_bool ppf name s = + match s with + | "0" -> false + | "1" -> true + | _ -> + Location.print_warning Location.none ppf + (Warnings.Bad_env_variable ("OCAMLPARAM", + Printf.sprintf "bad value for %s" name)); + false - let object_field sub = function - | Otag (_, attrs, t) -> - sub.attributes sub attrs; sub.typ sub t - | Oinherit t -> sub.typ sub t +(* 'can-discard=' specifies which arguments can be discarded without warning + because they are not understood by some versions of OCaml. *) +let can_discard = ref [] - let iter sub {ptyp_desc = desc; ptyp_loc = loc; ptyp_attributes = attrs} = - sub.location sub loc; - sub.attributes sub attrs; - match desc with - | Ptyp_any - | Ptyp_var _ -> () - | Ptyp_arrow (_lab, t1, t2) -> - sub.typ sub t1; sub.typ sub t2 - | Ptyp_tuple tyl -> List.iter (sub.typ sub) tyl - | Ptyp_constr (lid, tl) -> - iter_loc sub lid; List.iter (sub.typ sub) tl - | Ptyp_object (ol, _o) -> - List.iter (object_field sub) ol - | Ptyp_class (lid, tl) -> - iter_loc sub lid; List.iter (sub.typ sub) tl - | Ptyp_alias (t, _) -> sub.typ sub t - | Ptyp_variant (rl, _b, _ll) -> - List.iter (row_field sub) rl - | Ptyp_poly (_, t) -> sub.typ sub t - | Ptyp_package (lid, l) -> - iter_loc sub lid; - List.iter (iter_tuple (iter_loc sub) (sub.typ sub)) l - | Ptyp_extension x -> sub.extension sub x +let read_one_param ppf position name v = + let set name options s = setter ppf (fun b -> b) name options s in + let clear name options s = setter ppf (fun b -> not b) name options s in + match name with + | "g" -> set "g" [ Clflags.debug ] v + | "p" -> set "p" [ Clflags.gprofile ] v + | "bin-annot" -> set "bin-annot" [ Clflags.binary_annotations ] v + | "afl-instrument" -> set "afl-instrument" [ Clflags.afl_instrument ] v + | "afl-inst-ratio" -> + int_setter ppf "afl-inst-ratio" afl_inst_ratio v + | "annot" -> set "annot" [ Clflags.annotations ] v + | "absname" -> set "absname" [ Location.absname ] v + | "compat-32" -> set "compat-32" [ bytecode_compatible_32 ] v + | "noassert" -> set "noassert" [ noassert ] v + | "noautolink" -> set "noautolink" [ no_auto_link ] v + | "nostdlib" -> set "nostdlib" [ no_std_include ] v + | "linkall" -> set "linkall" [ link_everything ] v + | "nolabels" -> set "nolabels" [ classic ] v + | "principal" -> set "principal" [ principal ] v + | "rectypes" -> set "rectypes" [ recursive_types ] v + | "safe-string" -> clear "safe-string" [ unsafe_string ] v + | "strict-sequence" -> set "strict-sequence" [ strict_sequence ] v + | "strict-formats" -> set "strict-formats" [ strict_formats ] v + | "thread" -> set "thread" [ use_threads ] v + | "unboxed-types" -> set "unboxed-types" [ unboxed_types ] v + | "unsafe" -> set "unsafe" [ fast ] v + | "verbose" -> set "verbose" [ verbose ] v + | "nopervasives" -> set "nopervasives" [ nopervasives ] v + | "slash" -> set "slash" [ force_slash ] v (* for ocamldep *) + | "keep-docs" -> set "keep-docs" [ Clflags.keep_docs ] v + | "keep-locs" -> set "keep-locs" [ Clflags.keep_locs ] v - let iter_type_declaration sub - {ptype_name; ptype_params; ptype_cstrs; - ptype_kind; - ptype_private = _; - ptype_manifest; - ptype_attributes; - ptype_loc} = - iter_loc sub ptype_name; - List.iter (iter_fst (sub.typ sub)) ptype_params; - List.iter - (iter_tuple3 (sub.typ sub) (sub.typ sub) (sub.location sub)) - ptype_cstrs; - sub.type_kind sub ptype_kind; - iter_opt (sub.typ sub) ptype_manifest; - sub.location sub ptype_loc; - sub.attributes sub ptype_attributes + | "compact" -> clear "compact" [ optimize_for_speed ] v + | "no-app-funct" -> clear "no-app-funct" [ applicative_functors ] v + | "nodynlink" -> clear "nodynlink" [ dlcode ] v + | "short-paths" -> clear "short-paths" [ real_paths ] v + | "trans-mod" -> set "trans-mod" [ transparent_modules ] v + | "opaque" -> set "opaque" [ opaque ] v - let iter_type_kind sub = function - | Ptype_abstract -> () - | Ptype_variant l -> - List.iter (sub.constructor_declaration sub) l - | Ptype_record l -> List.iter (sub.label_declaration sub) l - | Ptype_open -> () + | "pp" -> preprocessor := Some v + | "runtime-variant" -> runtime_variant := v + | "cc" -> c_compiler := Some v - let iter_constructor_arguments sub = function - | Pcstr_tuple l -> List.iter (sub.typ sub) l - | Pcstr_record l -> - List.iter (sub.label_declaration sub) l + | "clambda-checks" -> set "clambda-checks" [ clambda_checks ] v - let iter_type_extension sub - {ptyext_path; ptyext_params; - ptyext_constructors; - ptyext_private = _; - ptyext_attributes} = - iter_loc sub ptyext_path; - List.iter (sub.extension_constructor sub) ptyext_constructors; - List.iter (iter_fst (sub.typ sub)) ptyext_params; - sub.attributes sub ptyext_attributes + (* assembly sources *) + | "s" -> + set "s" [ Clflags.keep_asm_file ; Clflags.keep_startup_file ] v + | "S" -> set "S" [ Clflags.keep_asm_file ] v + | "dstartup" -> set "dstartup" [ Clflags.keep_startup_file ] v - let iter_extension_constructor_kind sub = function - Pext_decl(ctl, cto) -> - iter_constructor_arguments sub ctl; iter_opt (sub.typ sub) cto - | Pext_rebind li -> - iter_loc sub li + (* warn-errors *) + | "we" | "warn-error" -> Warnings.parse_options true v + (* warnings *) + | "w" -> Warnings.parse_options false v + (* warn-errors *) + | "wwe" -> Warnings.parse_options false v - let iter_extension_constructor sub - {pext_name; - pext_kind; - pext_loc; - pext_attributes} = - iter_loc sub pext_name; - iter_extension_constructor_kind sub pext_kind; - sub.location sub pext_loc; - sub.attributes sub pext_attributes + (* inlining *) + | "inline" -> + let module F = Float_arg_helper in + begin match F.parse_no_error v inline_threshold with + | F.Ok -> () + | F.Parse_failed exn -> + let error = + Printf.sprintf "bad syntax for \"inline\": %s" + (Printexc.to_string exn) + in + Location.print_warning Location.none ppf + (Warnings.Bad_env_variable ("OCAMLPARAM", error)) + end -end + | "inline-toplevel" -> + Int_arg_helper.parse v + "Bad syntax in OCAMLPARAM for 'inline-toplevel'" + inline_toplevel_threshold -module CT = struct - (* Type expressions for the class language *) + | "rounds" -> int_option_setter ppf "rounds" simplify_rounds v + | "inline-max-unroll" -> + Int_arg_helper.parse v "Bad syntax in OCAMLPARAM for 'inline-max-unroll'" + inline_max_unroll + | "inline-call-cost" -> + Int_arg_helper.parse v + "Bad syntax in OCAMLPARAM for 'inline-call-cost'" + inline_call_cost + | "inline-alloc-cost" -> + Int_arg_helper.parse v + "Bad syntax in OCAMLPARAM for 'inline-alloc-cost'" + inline_alloc_cost + | "inline-prim-cost" -> + Int_arg_helper.parse v + "Bad syntax in OCAMLPARAM for 'inline-prim-cost'" + inline_prim_cost + | "inline-branch-cost" -> + Int_arg_helper.parse v + "Bad syntax in OCAMLPARAM for 'inline-branch-cost'" + inline_branch_cost + | "inline-indirect-cost" -> + Int_arg_helper.parse v + "Bad syntax in OCAMLPARAM for 'inline-indirect-cost'" + inline_indirect_cost + | "inline-lifting-benefit" -> + Int_arg_helper.parse v + "Bad syntax in OCAMLPARAM for 'inline-lifting-benefit'" + inline_lifting_benefit + | "inline-branch-factor" -> + Float_arg_helper.parse v + "Bad syntax in OCAMLPARAM for 'inline-branch-factor'" + inline_branch_factor + | "inline-max-depth" -> + Int_arg_helper.parse v + "Bad syntax in OCAMLPARAM for 'inline-max-depth'" + inline_max_depth - let iter sub {pcty_loc = loc; pcty_desc = desc; pcty_attributes = attrs} = - sub.location sub loc; - sub.attributes sub attrs; - match desc with - | Pcty_constr (lid, tys) -> - iter_loc sub lid; List.iter (sub.typ sub) tys - | Pcty_signature x -> sub.class_signature sub x - | Pcty_arrow (_lab, t, ct) -> - sub.typ sub t; sub.class_type sub ct - | Pcty_extension x -> sub.extension sub x - | Pcty_open (_ovf, lid, e) -> - iter_loc sub lid; sub.class_type sub e + | "Oclassic" -> + set "Oclassic" [ classic_inlining ] v + | "O2" -> + if check_bool ppf "O2" v then begin + default_simplify_rounds := 2; + use_inlining_arguments_set o2_arguments; + use_inlining_arguments_set ~round:0 o1_arguments + end - let iter_field sub {pctf_desc = desc; pctf_loc = loc; pctf_attributes = attrs} - = - sub.location sub loc; - sub.attributes sub attrs; - match desc with - | Pctf_inherit ct -> sub.class_type sub ct - | Pctf_val (_s, _m, _v, t) -> sub.typ sub t - | Pctf_method (_s, _p, _v, t) -> sub.typ sub t - | Pctf_constraint (t1, t2) -> - sub.typ sub t1; sub.typ sub t2 - | Pctf_attribute x -> sub.attribute sub x - | Pctf_extension x -> sub.extension sub x + | "O3" -> + if check_bool ppf "O3" v then begin + default_simplify_rounds := 3; + use_inlining_arguments_set o3_arguments; + use_inlining_arguments_set ~round:1 o2_arguments; + use_inlining_arguments_set ~round:0 o1_arguments + end + | "unbox-closures" -> + set "unbox-closures" [ unbox_closures ] v + | "unbox-closures-factor" -> + int_setter ppf "unbox-closures-factor" unbox_closures_factor v + | "remove-unused-arguments" -> + set "remove-unused-arguments" [ remove_unused_arguments ] v - let iter_signature sub {pcsig_self; pcsig_fields} = - sub.typ sub pcsig_self; - List.iter (sub.class_type_field sub) pcsig_fields -end + | "inlining-report" -> + if !native_code then + set "inlining-report" [ inlining_report ] v -module MT = struct - (* Type expressions for the module language *) + | "flambda-verbose" -> + set "flambda-verbose" [ dump_flambda_verbose ] v + | "flambda-invariants" -> + set "flambda-invariants" [ flambda_invariant_checks ] v - let iter sub {pmty_desc = desc; pmty_loc = loc; pmty_attributes = attrs} = - sub.location sub loc; - sub.attributes sub attrs; - match desc with - | Pmty_ident s -> iter_loc sub s - | Pmty_alias s -> iter_loc sub s - | Pmty_signature sg -> sub.signature sub sg - | Pmty_functor (s, mt1, mt2) -> - iter_loc sub s; - iter_opt (sub.module_type sub) mt1; - sub.module_type sub mt2 - | Pmty_with (mt, l) -> - sub.module_type sub mt; - List.iter (sub.with_constraint sub) l - | Pmty_typeof me -> sub.module_expr sub me - | Pmty_extension x -> sub.extension sub x + (* color output *) + | "color" -> + begin match parse_color_setting v with + | None -> + Location.print_warning Location.none ppf + (Warnings.Bad_env_variable ("OCAMLPARAM", + "bad value for \"color\", \ + (expected \"auto\", \"always\" or \"never\")")) + | Some setting -> color := Some setting + end - let iter_with_constraint sub = function - | Pwith_type (lid, d) -> - iter_loc sub lid; sub.type_declaration sub d - | Pwith_module (lid, lid2) -> - iter_loc sub lid; iter_loc sub lid2 - | Pwith_typesubst (lid, d) -> - iter_loc sub lid; sub.type_declaration sub d - | Pwith_modsubst (s, lid) -> - iter_loc sub s; iter_loc sub lid + | "intf-suffix" -> Config.interface_suffix := v - let iter_signature_item sub {psig_desc = desc; psig_loc = loc} = - sub.location sub loc; - match desc with - | Psig_value vd -> sub.value_description sub vd - | Psig_type (_rf, l) -> List.iter (sub.type_declaration sub) l - | Psig_typext te -> sub.type_extension sub te - | Psig_exception ed -> sub.extension_constructor sub ed - | Psig_module x -> sub.module_declaration sub x - | Psig_recmodule l -> - List.iter (sub.module_declaration sub) l - | Psig_modtype x -> sub.module_type_declaration sub x - | Psig_open x -> sub.open_description sub x - | Psig_include x -> sub.include_description sub x - | Psig_class l -> List.iter (sub.class_description sub) l - | Psig_class_type l -> - List.iter (sub.class_type_declaration sub) l - | Psig_extension (x, attrs) -> - sub.extension sub x; sub.attributes sub attrs - | Psig_attribute x -> sub.attribute sub x -end + | "I" -> begin + match position with + | Before_args -> first_include_dirs := v :: !first_include_dirs + | Before_link | Before_compile _ -> + last_include_dirs := v :: !last_include_dirs + end + | "cclib" -> + begin + match position with + | Before_compile _ -> () + | Before_link | Before_args -> + ccobjs := Misc.rev_split_words v @ !ccobjs + end -module M = struct - (* Value expressions for the module language *) + | "ccopts" -> + begin + match position with + | Before_link | Before_compile _ -> + last_ccopts := v :: !last_ccopts + | Before_args -> + first_ccopts := v :: !first_ccopts + end - let iter sub {pmod_loc = loc; pmod_desc = desc; pmod_attributes = attrs} = - sub.location sub loc; - sub.attributes sub attrs; - match desc with - | Pmod_ident x -> iter_loc sub x - | Pmod_structure str -> sub.structure sub str - | Pmod_functor (arg, arg_ty, body) -> - iter_loc sub arg; - iter_opt (sub.module_type sub) arg_ty; - sub.module_expr sub body - | Pmod_apply (m1, m2) -> - sub.module_expr sub m1; sub.module_expr sub m2 - | Pmod_constraint (m, mty) -> - sub.module_expr sub m; sub.module_type sub mty - | Pmod_unpack e -> sub.expr sub e - | Pmod_extension x -> sub.extension sub x + | "ppx" -> + begin + match position with + | Before_link | Before_compile _ -> + last_ppx := v :: !last_ppx + | Before_args -> + first_ppx := v :: !first_ppx + end - let iter_structure_item sub {pstr_loc = loc; pstr_desc = desc} = - sub.location sub loc; - match desc with - | Pstr_eval (x, attrs) -> - sub.expr sub x; sub.attributes sub attrs - | Pstr_value (_r, vbs) -> List.iter (sub.value_binding sub) vbs - | Pstr_primitive vd -> sub.value_description sub vd - | Pstr_type (_rf, l) -> List.iter (sub.type_declaration sub) l - | Pstr_typext te -> sub.type_extension sub te - | Pstr_exception ed -> sub.extension_constructor sub ed - | Pstr_module x -> sub.module_binding sub x - | Pstr_recmodule l -> List.iter (sub.module_binding sub) l - | Pstr_modtype x -> sub.module_type_declaration sub x - | Pstr_open x -> sub.open_description sub x - | Pstr_class l -> List.iter (sub.class_declaration sub) l - | Pstr_class_type l -> - List.iter (sub.class_type_declaration sub) l - | Pstr_include x -> sub.include_declaration sub x - | Pstr_extension (x, attrs) -> - sub.extension sub x; sub.attributes sub attrs - | Pstr_attribute x -> sub.attribute sub x -end -module E = struct - (* Value expressions for the core language *) + | "cmo" | "cma" -> + if not !native_code then + begin + match position with + | Before_link | Before_compile _ -> + last_objfiles := v ::! last_objfiles + | Before_args -> + first_objfiles := v :: !first_objfiles + end - let iter sub {pexp_loc = loc; pexp_desc = desc; pexp_attributes = attrs} = - sub.location sub loc; - sub.attributes sub attrs; - match desc with - | Pexp_ident x -> iter_loc sub x - | Pexp_constant _ -> () - | Pexp_let (_r, vbs, e) -> - List.iter (sub.value_binding sub) vbs; - sub.expr sub e - | Pexp_fun (_lab, def, p, e) -> - iter_opt (sub.expr sub) def; - sub.pat sub p; - sub.expr sub e - | Pexp_function pel -> sub.cases sub pel - | Pexp_apply (e, l) -> - sub.expr sub e; List.iter (iter_snd (sub.expr sub)) l - | Pexp_match (e, pel) -> - sub.expr sub e; sub.cases sub pel - | Pexp_try (e, pel) -> sub.expr sub e; sub.cases sub pel - | Pexp_tuple el -> List.iter (sub.expr sub) el - | Pexp_construct (lid, arg) -> - iter_loc sub lid; iter_opt (sub.expr sub) arg - | Pexp_variant (_lab, eo) -> - iter_opt (sub.expr sub) eo - | Pexp_record (l, eo) -> - List.iter (iter_tuple (iter_loc sub) (sub.expr sub)) l; - iter_opt (sub.expr sub) eo - | Pexp_field (e, lid) -> - sub.expr sub e; iter_loc sub lid - | Pexp_setfield (e1, lid, e2) -> - sub.expr sub e1; iter_loc sub lid; - sub.expr sub e2 - | Pexp_array el -> List.iter (sub.expr sub) el - | Pexp_ifthenelse (e1, e2, e3) -> - sub.expr sub e1; sub.expr sub e2; - iter_opt (sub.expr sub) e3 - | Pexp_sequence (e1, e2) -> - sub.expr sub e1; sub.expr sub e2 - | Pexp_while (e1, e2) -> - sub.expr sub e1; sub.expr sub e2 - | Pexp_for (p, e1, e2, _d, e3) -> - sub.pat sub p; sub.expr sub e1; sub.expr sub e2; - sub.expr sub e3 - | Pexp_coerce (e, t1, t2) -> - sub.expr sub e; iter_opt (sub.typ sub) t1; - sub.typ sub t2 - | Pexp_constraint (e, t) -> - sub.expr sub e; sub.typ sub t - | Pexp_send (e, _s) -> sub.expr sub e - | Pexp_new lid -> iter_loc sub lid - | Pexp_setinstvar (s, e) -> - iter_loc sub s; sub.expr sub e - | Pexp_override sel -> - List.iter (iter_tuple (iter_loc sub) (sub.expr sub)) sel - | Pexp_letmodule (s, me, e) -> - iter_loc sub s; sub.module_expr sub me; - sub.expr sub e - | Pexp_letexception (cd, e) -> - sub.extension_constructor sub cd; - sub.expr sub e - | Pexp_assert e -> sub.expr sub e - | Pexp_lazy e -> sub.expr sub e - | Pexp_poly (e, t) -> - sub.expr sub e; iter_opt (sub.typ sub) t - | Pexp_object cls -> sub.class_structure sub cls - | Pexp_newtype (_s, e) -> sub.expr sub e - | Pexp_pack me -> sub.module_expr sub me - | Pexp_open (_ovf, lid, e) -> - iter_loc sub lid; sub.expr sub e - | Pexp_extension x -> sub.extension sub x - | Pexp_unreachable -> () -end + | "cmx" | "cmxa" -> + if !native_code then + begin + match position with + | Before_link | Before_compile _ -> + last_objfiles := v ::! last_objfiles + | Before_args -> + first_objfiles := v :: !first_objfiles + end -module P = struct - (* Patterns *) + | "pic" -> + if !native_code then + set "pic" [ pic_code ] v - let iter sub {ppat_desc = desc; ppat_loc = loc; ppat_attributes = attrs} = - sub.location sub loc; - sub.attributes sub attrs; - match desc with - | Ppat_any -> () - | Ppat_var s -> iter_loc sub s - | Ppat_alias (p, s) -> sub.pat sub p; iter_loc sub s - | Ppat_constant _ -> () - | Ppat_interval _ -> () - | Ppat_tuple pl -> List.iter (sub.pat sub) pl - | Ppat_construct (l, p) -> - iter_loc sub l; iter_opt (sub.pat sub) p - | Ppat_variant (_l, p) -> iter_opt (sub.pat sub) p - | Ppat_record (lpl, _cf) -> - List.iter (iter_tuple (iter_loc sub) (sub.pat sub)) lpl - | Ppat_array pl -> List.iter (sub.pat sub) pl - | Ppat_or (p1, p2) -> sub.pat sub p1; sub.pat sub p2 - | Ppat_constraint (p, t) -> - sub.pat sub p; sub.typ sub t - | Ppat_type s -> iter_loc sub s - | Ppat_lazy p -> sub.pat sub p - | Ppat_unpack s -> iter_loc sub s - | Ppat_exception p -> sub.pat sub p - | Ppat_extension x -> sub.extension sub x - | Ppat_open (lid, p) -> - iter_loc sub lid; sub.pat sub p + | "can-discard" -> + can_discard := v ::!can_discard -end + | "timings" | "profile" -> + let if_on = if name = "timings" then [ `Time ] else Profile.all_columns in + profile_columns := if check_bool ppf name v then if_on else [] -module CE = struct - (* Value expressions for the class language *) + | "plugin" -> !load_plugin v - let iter sub {pcl_loc = loc; pcl_desc = desc; pcl_attributes = attrs} = - sub.location sub loc; - sub.attributes sub attrs; - match desc with - | Pcl_constr (lid, tys) -> - iter_loc sub lid; List.iter (sub.typ sub) tys - | Pcl_structure s -> - sub.class_structure sub s - | Pcl_fun (_lab, e, p, ce) -> - iter_opt (sub.expr sub) e; - sub.pat sub p; - sub.class_expr sub ce - | Pcl_apply (ce, l) -> - sub.class_expr sub ce; - List.iter (iter_snd (sub.expr sub)) l - | Pcl_let (_r, vbs, ce) -> - List.iter (sub.value_binding sub) vbs; - sub.class_expr sub ce - | Pcl_constraint (ce, ct) -> - sub.class_expr sub ce; sub.class_type sub ct - | Pcl_extension x -> sub.extension sub x - | Pcl_open (_ovf, lid, e) -> - iter_loc sub lid; sub.class_expr sub e + | _ -> + if not (List.mem name !can_discard) then begin + can_discard := name :: !can_discard; + Printf.eprintf + "Warning: discarding value of variable %S in OCAMLPARAM\n%!" + name + end - let iter_kind sub = function - | Cfk_concrete (_o, e) -> sub.expr sub e - | Cfk_virtual t -> sub.typ sub t +let read_OCAMLPARAM ppf position = + try + let s = Sys.getenv "OCAMLPARAM" in + let (before, after) = + try + parse_args s + with SyntaxError s -> + Location.print_warning Location.none ppf + (Warnings.Bad_env_variable ("OCAMLPARAM", s)); + [],[] + in + List.iter (fun (name, v) -> read_one_param ppf position name v) + (match position with + Before_args -> before + | Before_compile _ | Before_link -> after) + with Not_found -> () - let iter_field sub {pcf_desc = desc; pcf_loc = loc; pcf_attributes = attrs} = - sub.location sub loc; - sub.attributes sub attrs; - match desc with - | Pcf_inherit (_o, ce, _s) -> sub.class_expr sub ce - | Pcf_val (s, _m, k) -> iter_loc sub s; iter_kind sub k - | Pcf_method (s, _p, k) -> - iter_loc sub s; iter_kind sub k - | Pcf_constraint (t1, t2) -> - sub.typ sub t1; sub.typ sub t2 - | Pcf_initializer e -> sub.expr sub e - | Pcf_attribute x -> sub.attribute sub x - | Pcf_extension x -> sub.extension sub x +(* OCAMLPARAM passed as file *) - let iter_structure sub {pcstr_self; pcstr_fields} = - sub.pat sub pcstr_self; - List.iter (sub.class_field sub) pcstr_fields +type pattern = + | Filename of string + | Any - let class_infos sub f {pci_virt = _; pci_params = pl; pci_name; pci_expr; - pci_loc; pci_attributes} = - List.iter (iter_fst (sub.typ sub)) pl; - iter_loc sub pci_name; - f pci_expr; - sub.location sub pci_loc; - sub.attributes sub pci_attributes -end +type file_option = { + pattern : pattern; + name : string; + value : string; +} -(* Now, a generic AST mapper, to be extended to cover all kinds and - cases of the OCaml grammar. The default behavior of the mapper is - the identity. *) +let scan_line ic = + Scanf.bscanf ic "%[0-9a-zA-Z_.*] : %[a-zA-Z_-] = %s " + (fun pattern name value -> + let pattern = + match pattern with + | "*" -> Any + | _ -> Filename pattern + in + { pattern; name; value }) -let default_iterator = - { - structure = (fun this l -> List.iter (this.structure_item this) l); - structure_item = M.iter_structure_item; - module_expr = M.iter; - signature = (fun this l -> List.iter (this.signature_item this) l); - signature_item = MT.iter_signature_item; - module_type = MT.iter; - with_constraint = MT.iter_with_constraint; - class_declaration = - (fun this -> CE.class_infos this (this.class_expr this)); - class_expr = CE.iter; - class_field = CE.iter_field; - class_structure = CE.iter_structure; - class_type = CT.iter; - class_type_field = CT.iter_field; - class_signature = CT.iter_signature; - class_type_declaration = - (fun this -> CE.class_infos this (this.class_type this)); - class_description = - (fun this -> CE.class_infos this (this.class_type this)); - type_declaration = T.iter_type_declaration; - type_kind = T.iter_type_kind; - typ = T.iter; - type_extension = T.iter_type_extension; - extension_constructor = T.iter_extension_constructor; - value_description = - (fun this {pval_name; pval_type; pval_prim = _; pval_loc; - pval_attributes} -> - iter_loc this pval_name; - this.typ this pval_type; - this.attributes this pval_attributes; - this.location this pval_loc - ); +let load_config ppf filename = + match open_in_bin filename with + | exception e -> + Location.print_error ppf (Location.in_file filename); + Format.fprintf ppf "Cannot open file %s@." (Printexc.to_string e); + raise Exit + | ic -> + let sic = Scanf.Scanning.from_channel ic in + let rec read line_number line_start acc = + match scan_line sic with + | exception End_of_file -> + close_in ic; + acc + | exception Scanf.Scan_failure error -> + let position = Lexing.{ + pos_fname = filename; + pos_lnum = line_number; + pos_bol = line_start; + pos_cnum = pos_in ic; + } + in + let loc = Location.{ + loc_start = position; + loc_end = position; + loc_ghost = false; + } + in + Location.print_error ppf loc; + Format.fprintf ppf "Configuration file error %s@." error; + close_in ic; + raise Exit + | line -> + read (line_number + 1) (pos_in ic) (line :: acc) + in + let lines = read 0 0 [] in + lines - pat = P.iter; - expr = E.iter; +let matching_filename filename { pattern } = + match pattern with + | Any -> true + | Filename pattern -> + let filename = String.lowercase_ascii filename in + let pattern = String.lowercase_ascii pattern in + filename = pattern - module_declaration = - (fun this {pmd_name; pmd_type; pmd_attributes; pmd_loc} -> - iter_loc this pmd_name; - this.module_type this pmd_type; - this.attributes this pmd_attributes; - this.location this pmd_loc - ); +let apply_config_file ppf position = + let config_file = + Filename.concat Config.standard_library "ocaml_compiler_internal_params" + in + let config = + if Sys.file_exists config_file then + load_config ppf config_file + else + [] + in + let config = + match position with + | Before_compile filename -> + List.filter (matching_filename filename) config + | Before_args | Before_link -> + List.filter (fun { pattern } -> pattern = Any) config + in + List.iter (fun { name; value } -> read_one_param ppf position name value) + config - module_type_declaration = - (fun this {pmtd_name; pmtd_type; pmtd_attributes; pmtd_loc} -> - iter_loc this pmtd_name; - iter_opt (this.module_type this) pmtd_type; - this.attributes this pmtd_attributes; - this.location this pmtd_loc - ); +let readenv ppf position = + last_include_dirs := []; + last_ccopts := []; + last_ppx := []; + last_objfiles := []; + apply_config_file ppf position; + read_OCAMLPARAM ppf position; + all_ccopts := !last_ccopts @ !first_ccopts; + all_ppx := !last_ppx @ !first_ppx - module_binding = - (fun this {pmb_name; pmb_expr; pmb_attributes; pmb_loc} -> - iter_loc this pmb_name; this.module_expr this pmb_expr; - this.attributes this pmb_attributes; - this.location this pmb_loc - ); +let get_objfiles ~with_ocamlparam = + if with_ocamlparam then + List.rev (!last_objfiles @ !objfiles @ !first_objfiles) + else + List.rev !objfiles - open_description = - (fun this {popen_lid; popen_override = _; popen_attributes; popen_loc} -> - iter_loc this popen_lid; - this.location this popen_loc; - this.attributes this popen_attributes - ); - include_description = - (fun this {pincl_mod; pincl_attributes; pincl_loc} -> - this.module_type this pincl_mod; - this.location this pincl_loc; - this.attributes this pincl_attributes - ); - include_declaration = - (fun this {pincl_mod; pincl_attributes; pincl_loc} -> - this.module_expr this pincl_mod; - this.location this pincl_loc; - this.attributes this pincl_attributes - ); +type deferred_action = + | ProcessImplementation of string + | ProcessInterface of string + | ProcessCFile of string + | ProcessOtherFile of string + | ProcessObjects of string list + | ProcessDLLs of string list + +let c_object_of_filename name = + Filename.chop_suffix (Filename.basename name) ".c" ^ Config.ext_obj + +let process_action + (ppf, implementation, interface, ocaml_mod_ext, ocaml_lib_ext) action = + match action with + | ProcessImplementation name -> + readenv ppf (Before_compile name); + let opref = output_prefix name in + implementation ppf name opref; + objfiles := (opref ^ ocaml_mod_ext) :: !objfiles + | ProcessInterface name -> + readenv ppf (Before_compile name); + let opref = output_prefix name in + interface ppf name opref; + if !make_package then objfiles := (opref ^ ".cmi") :: !objfiles + | ProcessCFile name -> + readenv ppf (Before_compile name); + Location.set_input_name name; + if Ccomp.compile_file name <> 0 then exit 2; + ccobjs := c_object_of_filename name :: !ccobjs + | ProcessObjects names -> + ccobjs := names @ !ccobjs + | ProcessDLLs names -> + dllibs := names @ !dllibs + | ProcessOtherFile name -> + if Filename.check_suffix name ocaml_mod_ext + || Filename.check_suffix name ocaml_lib_ext then + objfiles := name :: !objfiles + else if Filename.check_suffix name ".cmi" && !make_package then + objfiles := name :: !objfiles + else if Filename.check_suffix name Config.ext_obj + || Filename.check_suffix name Config.ext_lib then + ccobjs := name :: !ccobjs + else if not !native_code && Filename.check_suffix name Config.ext_dll then + dllibs := name :: !dllibs + else + raise(Arg.Bad("don't know what to do with " ^ name)) + + +let action_of_file name = + if Filename.check_suffix name ".ml" + || Filename.check_suffix name ".mlt" then + ProcessImplementation name + else if Filename.check_suffix name !Config.interface_suffix then + ProcessInterface name + else if Filename.check_suffix name ".c" then + ProcessCFile name + else + ProcessOtherFile name + +let deferred_actions = ref [] +let defer action = + deferred_actions := action :: !deferred_actions + +let anonymous filename = defer (action_of_file filename) +let impl filename = defer (ProcessImplementation filename) +let intf filename = defer (ProcessInterface filename) + +let process_deferred_actions env = + let final_output_name = !output_name in + (* Make sure the intermediate products don't clash with the final one + when we're invoked like: ocamlopt -o foo bar.c baz.ml. *) + if not !compile_only then output_name := None; + begin + match final_output_name with + | None -> () + | Some output_name -> + if !compile_only then begin + if List.filter (function + | ProcessCFile name -> c_object_of_filename name <> output_name + | _ -> false) !deferred_actions <> [] then + fatal "Options -c and -o are incompatible when compiling C files"; + + if List.length (List.filter (function + | ProcessImplementation _ + | ProcessInterface _ + | _ -> false) !deferred_actions) > 1 then + fatal "Options -c -o are incompatible with compiling multiple files" + end; + end; + if !make_archive && List.exists (function + | ProcessOtherFile name -> Filename.check_suffix name ".cmxa" + | _ -> false) !deferred_actions then + fatal "Option -a cannot be used with .cmxa input files."; + List.iter (process_action env) (List.rev !deferred_actions); + output_name := final_output_name; + +end +(** Interface as module *) +module Compdynlink += struct +#1 "compdynlink.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) + +(** Dynamic loading of object files. *) + +val is_native: bool +(** [true] if the program is native, + [false] if the program is bytecode. *) + +(** {1 Dynamic loading of compiled files} *) + +val loadfile : string -> unit +(** In bytecode: load the given bytecode object file ([.cmo] file) or + bytecode library file ([.cma] file), and link it with the running + program. In native code: load the given OCaml plugin file (usually + [.cmxs]), and link it with the running + program. + All toplevel expressions in the loaded compilation units + are evaluated. No facilities are provided to + access value names defined by the unit. Therefore, the unit + must register itself its entry points with the main program, + e.g. by modifying tables of functions. *) + +val loadfile_private : string -> unit +(** Same as [loadfile], except that the compilation units just loaded + are hidden (cannot be referenced) from other modules dynamically + loaded afterwards. *) + +val adapt_filename : string -> string +(** In bytecode, the identity function. In native code, replace the last + extension with [.cmxs]. *) + +(** {1 Access control} *) + +val allow_only: string list -> unit +(** [allow_only units] restricts the compilation units that + dynamically-linked units can reference: it forbids all references + to units other than those named in the list [units]. References + to any other compilation unit will cause a [Unavailable_unit] + error during [loadfile] or [loadfile_private]. + + Initially (or after calling [default_available_units]) all + compilation units composing the program currently running are + available for reference from dynamically-linked units. + [allow_only] can be used to restrict access to a subset of these + units, e.g. to the units that compose the API for + dynamically-linked code, and prevent access to all other units, + e.g. private, internal modules of the running program. If + [allow_only] is called several times, access will be restricted to + the intersection of the given lists (i.e. a call to [allow_only] + can never increase the set of available units). *) + +val prohibit: string list -> unit +(** [prohibit units] prohibits dynamically-linked units from referencing + the units named in list [units]. This can be used to prevent + access to selected units, e.g. private, internal modules of + the running program. *) + +val default_available_units: unit -> unit +(** Reset the set of units that can be referenced from dynamically-linked + code to its default value, that is, all units composing the currently + running program. *) + +val allow_unsafe_modules : bool -> unit +(** Govern whether unsafe object files are allowed to be + dynamically linked. A compilation unit is 'unsafe' if it contains + declarations of external functions, which can break type safety. + By default, dynamic linking of unsafe object files is + not allowed. In native code, this function does nothing; object files + with external functions are always allowed to be dynamically linked. *) + +(** {1 Deprecated, low-level API for access control} *) + +(** @deprecated The functions [add_interfaces], [add_available_units] + and [clear_available_units] should not be used in new programs, + since the default initialization of allowed units, along with the + [allow_only] and [prohibit] function, provides a better, safer + mechanism to control access to program units. The three functions + below are provided for backward compatibility only and are not + available in native code. *) + +val add_interfaces : string list -> string list -> unit +(** [add_interfaces units path] grants dynamically-linked object + files access to the compilation units named in list [units]. + The interfaces ([.cmi] files) for these units are searched in + [path] (a list of directory names). *) + +val add_available_units : (string * Digest.t) list -> unit +(** Same as {!Dynlink.add_interfaces}, but instead of searching [.cmi] files + to find the unit interfaces, uses the interface digests given + for each unit. This way, the [.cmi] interface files need not be + available at run-time. The digests can be extracted from [.cmi] + files using the [extract_crc] program installed in the + OCaml standard library directory. *) + +val clear_available_units : unit -> unit +(** Empty the list of compilation units accessible to dynamically-linked + programs. *) + +(** {1 Deprecated, initialization} *) + +val init : unit -> unit +(** @deprecated Initialize the [Dynlink] library. This function is called + automatically when needed. *) + +(** {1 Error reporting} *) + +type linking_error = + Undefined_global of string + | Unavailable_primitive of string + | Uninitialized_global of string + +type error = + Not_a_bytecode_file of string + | Inconsistent_import of string + | Unavailable_unit of string + | Unsafe_file + | Linking_error of string * linking_error + | Corrupted_interface of string + | File_not_found of string + | Cannot_open_dll of string + | Inconsistent_implementation of string + +exception Error of error +(** Errors in dynamic linking are reported by raising the [Error] + exception with a description of the error. *) + +val error_message : error -> string +(** Convert an error description to a printable message. *) + + +(**/**) + +(** {1 Internal functions} *) + +val digest_interface : string -> string list -> Digest.t + +end +module Compmisc : sig +#1 "compmisc.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Fabrice Le Fessant, EPI Gallium, INRIA Paris-Rocquencourt *) +(* *) +(* Copyright 2013 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) + +val init_path : ?dir:string -> bool -> unit +val initial_env : unit -> Env.t + +val read_color_env : Format.formatter -> unit + +end = struct +#1 "compmisc.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Fabrice Le Fessant, EPI Gallium, INRIA Paris-Rocquencourt *) +(* *) +(* Copyright 2013 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) + +open Compenv + +(* Initialize the search path. + [dir] is always searched first (default: the current directory), + then the directories specified with the -I option (in command-line order), + then the standard library directory (unless the -nostdlib option is given). + *) + +let init_path ?(dir="") native = + let dirs = + if !Clflags.use_threads then "+threads" :: !Clflags.include_dirs + else if !Clflags.use_vmthreads && not native then + "+vmthreads" :: !Clflags.include_dirs + else + !Clflags.include_dirs + in + let dirs = + !last_include_dirs @ dirs @ Config.flexdll_dirs @ !first_include_dirs + in + let exp_dirs = + List.map (Misc.expand_directory Config.standard_library) dirs in + + Config.load_path := + (if !Clflags.no_implicit_current_dir then + List.rev_append exp_dirs (Clflags.std_include_dir ()) + else + dir :: List.rev_append exp_dirs (Clflags.std_include_dir ())); + + Env.reset_cache () + +(* Return the initial environment in which compilation proceeds. *) + +(* Note: do not do init_path() in initial_env, this breaks + toplevel initialization (PR#1775) *) + +let open_implicit_module m env = + let open Asttypes in + let lid = {loc = Location.in_file "command line"; + txt = Longident.parse m } in + snd (Typemod.type_open_ Override env lid.loc lid) + +let initial_env () = + Ident.reinit(); + let initial = + if Config.safe_string then Env.initial_safe_string + else if !Clflags.unsafe_string then Env.initial_unsafe_string + else Env.initial_safe_string + in + let env = + if !Clflags.nopervasives then initial else + open_implicit_module "Pervasives" initial + in + List.fold_left (fun env m -> + open_implicit_module m env + ) env (!implicit_modules @ List.rev !Clflags.open_modules) + + +let read_color_env ppf = + try + match Clflags.parse_color_setting (Sys.getenv "OCAML_COLOR") with + | None -> + Location.print_warning Location.none ppf + (Warnings.Bad_env_variable + ("OCAML_COLOR", + "expected \"auto\", \"always\" or \"never\"")); + | Some x -> match !Clflags.color with + | None -> Clflags.color := Some x + | Some _ -> () + with + Not_found -> () + +end +module Compplugin : sig +#1 "compplugin.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Fabrice Le Fessant, projet Gallium, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) + +val load : string -> unit + +end = struct +#1 "compplugin.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Fabrice Le Fessant, projet Gallium, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) + +(* A table to avoid double linking of plugins, especially with OCAMLPARAM *) +let plugins = Hashtbl.create 13 + +let load plugin_name = + + let plugin_name = + try + Compdynlink.adapt_filename plugin_name + with Invalid_argument _ -> plugin_name + in + + let plugin_file = + if Filename.is_implicit plugin_name then + try + Compmisc.init_path !Clflags.native_code; + Misc.find_in_path !Config.load_path plugin_name + with Not_found -> + raise (Compdynlink.Error (Compdynlink.File_not_found plugin_name)) + else plugin_name + in + + if not (Hashtbl.mem plugins plugin_file) then begin + Compdynlink.loadfile plugin_file; + Hashtbl.add plugins plugin_file (); (* plugin loaded *) + end + +let () = + Location.register_error_of_exn (function + | Compdynlink.Error error -> + Some (Location.error ( + Printf.sprintf "%s while loading argument of -plugin" + (Compdynlink.error_message error))) + | _ -> None); + Compenv.load_plugin := load + +end +module Depend : sig +#1 "depend.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1999 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) + +(** Module dependencies. *) + +module StringSet : Set.S with type elt = string +module StringMap : Map.S with type key = string + +type map_tree = Node of StringSet.t * bound_map +and bound_map = map_tree StringMap.t +val make_leaf : string -> map_tree +val make_node : bound_map -> map_tree +val weaken_map : StringSet.t -> map_tree -> map_tree + +val free_structure_names : StringSet.t ref + +(* dependencies found by preprocessing tools (plugins) *) +val pp_deps : string list ref + +val open_module : bound_map -> Longident.t -> bound_map + +val add_use_file : bound_map -> Parsetree.toplevel_phrase list -> unit + +val add_signature : bound_map -> Parsetree.signature -> unit + +val add_implementation : bound_map -> Parsetree.structure -> unit + +val add_implementation_binding : bound_map -> Parsetree.structure -> bound_map +val add_signature_binding : bound_map -> Parsetree.signature -> bound_map + +end = struct +#1 "depend.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1999 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) + +open Asttypes +open Location +open Longident +open Parsetree + +let pp_deps = ref [] + +module StringSet = Set.Make(struct type t = string let compare = compare end) +module StringMap = Map.Make(String) + +(* Module resolution map *) +(* Node (set of imports for this path, map for submodules) *) +type map_tree = Node of StringSet.t * bound_map +and bound_map = map_tree StringMap.t +let bound = Node (StringSet.empty, StringMap.empty) + +(*let get_free (Node (s, _m)) = s*) +let get_map (Node (_s, m)) = m +let make_leaf s = Node (StringSet.singleton s, StringMap.empty) +let make_node m = Node (StringSet.empty, m) +let rec weaken_map s (Node(s0,m0)) = + Node (StringSet.union s s0, StringMap.map (weaken_map s) m0) +let rec collect_free (Node (s, m)) = + StringMap.fold (fun _ n -> StringSet.union (collect_free n)) m s + +(* Returns the imports required to access the structure at path p *) +(* Only raises Not_found if the head of p is not in the toplevel map *) +let rec lookup_free p m = + match p with + [] -> raise Not_found + | s::p -> + let Node (f, m') = StringMap.find s m in + try lookup_free p m' with Not_found -> f + +(* Returns the node corresponding to the structure at path p *) +let rec lookup_map lid m = + match lid with + Lident s -> StringMap.find s m + | Ldot (l, s) -> StringMap.find s (get_map (lookup_map l m)) + | Lapply _ -> raise Not_found + +(* Collect free module identifiers in the a.s.t. *) + +let free_structure_names = ref StringSet.empty + +let add_names s = + free_structure_names := StringSet.union s !free_structure_names + +let rec add_path bv ?(p=[]) = function + | Lident s -> + let free = + try lookup_free (s::p) bv with Not_found -> StringSet.singleton s + in + (*StringSet.iter (fun s -> Printf.eprintf "%s " s) free; + prerr_endline "";*) + add_names free + | Ldot(l, s) -> add_path bv ~p:(s::p) l + | Lapply(l1, l2) -> add_path bv l1; add_path bv l2 + +let open_module bv lid = + match lookup_map lid bv with + | Node (s, m) -> + add_names s; + StringMap.fold StringMap.add m bv + | exception Not_found -> + add_path bv lid; bv + +let add_parent bv lid = + match lid.txt with + Ldot(l, _s) -> add_path bv l + | _ -> () + +let add = add_parent + +let addmodule bv lid = add_path bv lid.txt + +let handle_extension ext = + match (fst ext).txt with + | "error" | "ocaml.error" -> + raise (Location.Error + (Builtin_attributes.error_of_extension ext)) + | _ -> + () + +let rec add_type bv ty = + match ty.ptyp_desc with + Ptyp_any -> () + | Ptyp_var _ -> () + | Ptyp_arrow(_, t1, t2) -> add_type bv t1; add_type bv t2 + | Ptyp_tuple tl -> List.iter (add_type bv) tl + | Ptyp_constr(c, tl) -> add bv c; List.iter (add_type bv) tl + | Ptyp_object (fl, _) -> + List.iter + (function Otag (_, _, t) -> add_type bv t + | Oinherit t -> add_type bv t) fl + | Ptyp_class(c, tl) -> add bv c; List.iter (add_type bv) tl + | Ptyp_alias(t, _) -> add_type bv t + | Ptyp_variant(fl, _, _) -> + List.iter + (function Rtag(_,_,_,stl) -> List.iter (add_type bv) stl + | Rinherit sty -> add_type bv sty) + fl + | Ptyp_poly(_, t) -> add_type bv t + | Ptyp_package pt -> add_package_type bv pt + | Ptyp_extension e -> handle_extension e + +and add_package_type bv (lid, l) = + add bv lid; + List.iter (add_type bv) (List.map (fun (_, e) -> e) l) + +let add_opt add_fn bv = function + None -> () + | Some x -> add_fn bv x + +let add_constructor_arguments bv = function + | Pcstr_tuple l -> List.iter (add_type bv) l + | Pcstr_record l -> List.iter (fun l -> add_type bv l.pld_type) l + +let add_constructor_decl bv pcd = + add_constructor_arguments bv pcd.pcd_args; + Misc.may (add_type bv) pcd.pcd_res + +let add_type_declaration bv td = + List.iter + (fun (ty1, ty2, _) -> add_type bv ty1; add_type bv ty2) + td.ptype_cstrs; + add_opt add_type bv td.ptype_manifest; + let add_tkind = function + Ptype_abstract -> () + | Ptype_variant cstrs -> + List.iter (add_constructor_decl bv) cstrs + | Ptype_record lbls -> + List.iter (fun pld -> add_type bv pld.pld_type) lbls + | Ptype_open -> () in + add_tkind td.ptype_kind + +let add_extension_constructor bv ext = + match ext.pext_kind with + Pext_decl(args, rty) -> + add_constructor_arguments bv args; + Misc.may (add_type bv) rty + | Pext_rebind lid -> add bv lid + +let add_type_extension bv te = + add bv te.ptyext_path; + List.iter (add_extension_constructor bv) te.ptyext_constructors + +let rec add_class_type bv cty = + match cty.pcty_desc with + Pcty_constr(l, tyl) -> + add bv l; List.iter (add_type bv) tyl + | Pcty_signature { pcsig_self = ty; pcsig_fields = fieldl } -> + add_type bv ty; + List.iter (add_class_type_field bv) fieldl + | Pcty_arrow(_, ty1, cty2) -> + add_type bv ty1; add_class_type bv cty2 + | Pcty_extension e -> handle_extension e + | Pcty_open (_ovf, m, e) -> + let bv = open_module bv m.txt in add_class_type bv e + +and add_class_type_field bv pctf = + match pctf.pctf_desc with + Pctf_inherit cty -> add_class_type bv cty + | Pctf_val(_, _, _, ty) -> add_type bv ty + | Pctf_method(_, _, _, ty) -> add_type bv ty + | Pctf_constraint(ty1, ty2) -> add_type bv ty1; add_type bv ty2 + | Pctf_attribute _ -> () + | Pctf_extension e -> handle_extension e + +let add_class_description bv infos = + add_class_type bv infos.pci_expr + +let add_class_type_declaration = add_class_description + +let pattern_bv = ref StringMap.empty + +let rec add_pattern bv pat = + match pat.ppat_desc with + Ppat_any -> () + | Ppat_var _ -> () + | Ppat_alias(p, _) -> add_pattern bv p + | Ppat_interval _ + | Ppat_constant _ -> () + | Ppat_tuple pl -> List.iter (add_pattern bv) pl + | Ppat_construct(c, op) -> add bv c; add_opt add_pattern bv op + | Ppat_record(pl, _) -> + List.iter (fun (lbl, p) -> add bv lbl; add_pattern bv p) pl + | Ppat_array pl -> List.iter (add_pattern bv) pl + | Ppat_or(p1, p2) -> add_pattern bv p1; add_pattern bv p2 + | Ppat_constraint(p, ty) -> add_pattern bv p; add_type bv ty + | Ppat_variant(_, op) -> add_opt add_pattern bv op + | Ppat_type li -> add bv li + | Ppat_lazy p -> add_pattern bv p + | Ppat_unpack id -> pattern_bv := StringMap.add id.txt bound !pattern_bv + | Ppat_open ( m, p) -> let bv = open_module bv m.txt in add_pattern bv p + | Ppat_exception p -> add_pattern bv p + | Ppat_extension e -> handle_extension e + +let add_pattern bv pat = + pattern_bv := bv; + add_pattern bv pat; + !pattern_bv + +let rec add_expr bv exp = + match exp.pexp_desc with + Pexp_ident l -> add bv l + | Pexp_constant _ -> () + | Pexp_let(rf, pel, e) -> + let bv = add_bindings rf bv pel in add_expr bv e + | Pexp_fun (_, opte, p, e) -> + add_opt add_expr bv opte; add_expr (add_pattern bv p) e + | Pexp_function pel -> + add_cases bv pel + | Pexp_apply(e, el) -> + add_expr bv e; List.iter (fun (_,e) -> add_expr bv e) el + | Pexp_match(e, pel) -> add_expr bv e; add_cases bv pel + | Pexp_try(e, pel) -> add_expr bv e; add_cases bv pel + | Pexp_tuple el -> List.iter (add_expr bv) el + | Pexp_construct(c, opte) -> add bv c; add_opt add_expr bv opte + | Pexp_variant(_, opte) -> add_opt add_expr bv opte + | Pexp_record(lblel, opte) -> + List.iter (fun (lbl, e) -> add bv lbl; add_expr bv e) lblel; + add_opt add_expr bv opte + | Pexp_field(e, fld) -> add_expr bv e; add bv fld + | Pexp_setfield(e1, fld, e2) -> add_expr bv e1; add bv fld; add_expr bv e2 + | Pexp_array el -> List.iter (add_expr bv) el + | Pexp_ifthenelse(e1, e2, opte3) -> + add_expr bv e1; add_expr bv e2; add_opt add_expr bv opte3 + | Pexp_sequence(e1, e2) -> add_expr bv e1; add_expr bv e2 + | Pexp_while(e1, e2) -> add_expr bv e1; add_expr bv e2 + | Pexp_for( _, e1, e2, _, e3) -> + add_expr bv e1; add_expr bv e2; add_expr bv e3 + | Pexp_coerce(e1, oty2, ty3) -> + add_expr bv e1; + add_opt add_type bv oty2; + add_type bv ty3 + | Pexp_constraint(e1, ty2) -> + add_expr bv e1; + add_type bv ty2 + | Pexp_send(e, _m) -> add_expr bv e + | Pexp_new li -> add bv li + | Pexp_setinstvar(_v, e) -> add_expr bv e + | Pexp_override sel -> List.iter (fun (_s, e) -> add_expr bv e) sel + | Pexp_letmodule(id, m, e) -> + let b = add_module_binding bv m in + add_expr (StringMap.add id.txt b bv) e + | Pexp_letexception(_, e) -> add_expr bv e + | Pexp_assert (e) -> add_expr bv e + | Pexp_lazy (e) -> add_expr bv e + | Pexp_poly (e, t) -> add_expr bv e; add_opt add_type bv t + | Pexp_object { pcstr_self = pat; pcstr_fields = fieldl } -> + let bv = add_pattern bv pat in List.iter (add_class_field bv) fieldl + | Pexp_newtype (_, e) -> add_expr bv e + | Pexp_pack m -> add_module bv m + | Pexp_open (_ovf, m, e) -> + let bv = open_module bv m.txt in add_expr bv e + | Pexp_extension (({ txt = ("ocaml.extension_constructor"| + "extension_constructor"); _ }, + PStr [item]) as e) -> + begin match item.pstr_desc with + | Pstr_eval ({ pexp_desc = Pexp_construct (c, None) }, _) -> add bv c + | _ -> handle_extension e + end + | Pexp_extension e -> handle_extension e + | Pexp_unreachable -> () + +and add_cases bv cases = + List.iter (add_case bv) cases + +and add_case bv {pc_lhs; pc_guard; pc_rhs} = + let bv = add_pattern bv pc_lhs in + add_opt add_expr bv pc_guard; + add_expr bv pc_rhs + +and add_bindings recf bv pel = + let bv' = List.fold_left (fun bv x -> add_pattern bv x.pvb_pat) bv pel in + let bv = if recf = Recursive then bv' else bv in + List.iter (fun x -> add_expr bv x.pvb_expr) pel; + bv' + +and add_modtype bv mty = + match mty.pmty_desc with + Pmty_ident l -> add bv l + | Pmty_alias l -> addmodule bv l + | Pmty_signature s -> add_signature bv s + | Pmty_functor(id, mty1, mty2) -> + Misc.may (add_modtype bv) mty1; + add_modtype (StringMap.add id.txt bound bv) mty2 + | Pmty_with(mty, cstrl) -> + add_modtype bv mty; + List.iter + (function + | Pwith_type (_, td) -> add_type_declaration bv td + | Pwith_module (_, lid) -> addmodule bv lid + | Pwith_typesubst (_, td) -> add_type_declaration bv td + | Pwith_modsubst (_, lid) -> addmodule bv lid + ) + cstrl + | Pmty_typeof m -> add_module bv m + | Pmty_extension e -> handle_extension e + +and add_module_alias bv l = + try + add_parent bv l; + lookup_map l.txt bv + with Not_found -> + match l.txt with + Lident s -> make_leaf s + | _ -> addmodule bv l; bound (* cannot delay *) + +and add_modtype_binding bv mty = + if not !Clflags.transparent_modules then add_modtype bv mty; + match mty.pmty_desc with + Pmty_alias l -> + add_module_alias bv l + | Pmty_signature s -> + make_node (add_signature_binding bv s) + | Pmty_typeof modl -> + add_module_binding bv modl + | _ -> + if !Clflags.transparent_modules then add_modtype bv mty; bound + +and add_signature bv sg = + ignore (add_signature_binding bv sg) + +and add_signature_binding bv sg = + snd (List.fold_left add_sig_item (bv, StringMap.empty) sg) + +and add_sig_item (bv, m) item = + match item.psig_desc with + Psig_value vd -> + add_type bv vd.pval_type; (bv, m) + | Psig_type (_, dcls) -> + List.iter (add_type_declaration bv) dcls; (bv, m) + | Psig_typext te -> + add_type_extension bv te; (bv, m) + | Psig_exception pext -> + add_extension_constructor bv pext; (bv, m) + | Psig_module pmd -> + let m' = add_modtype_binding bv pmd.pmd_type in + let add = StringMap.add pmd.pmd_name.txt m' in + (add bv, add m) + | Psig_recmodule decls -> + let add = + List.fold_right (fun pmd -> StringMap.add pmd.pmd_name.txt bound) + decls + in + let bv' = add bv and m' = add m in + List.iter (fun pmd -> add_modtype bv' pmd.pmd_type) decls; + (bv', m') + | Psig_modtype x -> + begin match x.pmtd_type with + None -> () + | Some mty -> add_modtype bv mty + end; + (bv, m) + | Psig_open od -> + (open_module bv od.popen_lid.txt, m) + | Psig_include incl -> + let Node (s, m') = add_modtype_binding bv incl.pincl_mod in + add_names s; + let add = StringMap.fold StringMap.add m' in + (add bv, add m) + | Psig_class cdl -> + List.iter (add_class_description bv) cdl; (bv, m) + | Psig_class_type cdtl -> + List.iter (add_class_type_declaration bv) cdtl; (bv, m) + | Psig_attribute _ -> (bv, m) + | Psig_extension (e, _) -> + handle_extension e; + (bv, m) + +and add_module_binding bv modl = + if not !Clflags.transparent_modules then add_module bv modl; + match modl.pmod_desc with + Pmod_ident l -> + begin try + add_parent bv l; + lookup_map l.txt bv + with Not_found -> + match l.txt with + Lident s -> make_leaf s + | _ -> addmodule bv l; bound + end + | Pmod_structure s -> + make_node (snd (add_structure_binding bv s)) + | _ -> + if !Clflags.transparent_modules then add_module bv modl; bound + +and add_module bv modl = + match modl.pmod_desc with + Pmod_ident l -> addmodule bv l + | Pmod_structure s -> ignore (add_structure bv s) + | Pmod_functor(id, mty, modl) -> + Misc.may (add_modtype bv) mty; + add_module (StringMap.add id.txt bound bv) modl + | Pmod_apply(mod1, mod2) -> + add_module bv mod1; add_module bv mod2 + | Pmod_constraint(modl, mty) -> + add_module bv modl; add_modtype bv mty + | Pmod_unpack(e) -> + add_expr bv e + | Pmod_extension e -> + handle_extension e + +and add_structure bv item_list = + let (bv, m) = add_structure_binding bv item_list in + add_names (collect_free (make_node m)); + bv + +and add_structure_binding bv item_list = + List.fold_left add_struct_item (bv, StringMap.empty) item_list + +and add_struct_item (bv, m) item : _ StringMap.t * _ StringMap.t = + match item.pstr_desc with + Pstr_eval (e, _attrs) -> + add_expr bv e; (bv, m) + | Pstr_value(rf, pel) -> + let bv = add_bindings rf bv pel in (bv, m) + | Pstr_primitive vd -> + add_type bv vd.pval_type; (bv, m) + | Pstr_type (_, dcls) -> + List.iter (add_type_declaration bv) dcls; (bv, m) + | Pstr_typext te -> + add_type_extension bv te; + (bv, m) + | Pstr_exception pext -> + add_extension_constructor bv pext; (bv, m) + | Pstr_module x -> + let b = add_module_binding bv x.pmb_expr in + let add = StringMap.add x.pmb_name.txt b in + (add bv, add m) + | Pstr_recmodule bindings -> + let add = + List.fold_right (fun x -> StringMap.add x.pmb_name.txt bound) bindings + in + let bv' = add bv and m = add m in + List.iter + (fun x -> add_module bv' x.pmb_expr) + bindings; + (bv', m) + | Pstr_modtype x -> + begin match x.pmtd_type with + None -> () + | Some mty -> add_modtype bv mty + end; + (bv, m) + | Pstr_open od -> + (open_module bv od.popen_lid.txt, m) + | Pstr_class cdl -> + List.iter (add_class_declaration bv) cdl; (bv, m) + | Pstr_class_type cdtl -> + List.iter (add_class_type_declaration bv) cdtl; (bv, m) + | Pstr_include incl -> + let Node (s, m') = add_module_binding bv incl.pincl_mod in + add_names s; + let add = StringMap.fold StringMap.add m' in + (add bv, add m) + | Pstr_attribute _ -> (bv, m) + | Pstr_extension (e, _) -> + handle_extension e; + (bv, m) - value_binding = - (fun this {pvb_pat; pvb_expr; pvb_attributes; pvb_loc} -> - this.pat this pvb_pat; - this.expr this pvb_expr; - this.location this pvb_loc; - this.attributes this pvb_attributes - ); +and add_use_file bv top_phrs = + ignore (List.fold_left add_top_phrase bv top_phrs) +and add_implementation bv l = + if !Clflags.transparent_modules then + ignore (add_structure_binding bv l) + else ignore (add_structure bv l) - constructor_declaration = - (fun this {pcd_name; pcd_args; pcd_res; pcd_loc; pcd_attributes} -> - iter_loc this pcd_name; - T.iter_constructor_arguments this pcd_args; - iter_opt (this.typ this) pcd_res; - this.location this pcd_loc; - this.attributes this pcd_attributes - ); +and add_implementation_binding bv l = + snd (add_structure_binding bv l) - label_declaration = - (fun this {pld_name; pld_type; pld_loc; pld_mutable = _; pld_attributes}-> - iter_loc this pld_name; - this.typ this pld_type; - this.location this pld_loc; - this.attributes this pld_attributes - ); +and add_top_phrase bv = function + | Ptop_def str -> add_structure bv str + | Ptop_dir (_, _) -> bv - cases = (fun this l -> List.iter (this.case this) l); - case = - (fun this {pc_lhs; pc_guard; pc_rhs} -> - this.pat this pc_lhs; - iter_opt (this.expr this) pc_guard; - this.expr this pc_rhs - ); +and add_class_expr bv ce = + match ce.pcl_desc with + Pcl_constr(l, tyl) -> + add bv l; List.iter (add_type bv) tyl + | Pcl_structure { pcstr_self = pat; pcstr_fields = fieldl } -> + let bv = add_pattern bv pat in List.iter (add_class_field bv) fieldl + | Pcl_fun(_, opte, pat, ce) -> + add_opt add_expr bv opte; + let bv = add_pattern bv pat in add_class_expr bv ce + | Pcl_apply(ce, exprl) -> + add_class_expr bv ce; List.iter (fun (_,e) -> add_expr bv e) exprl + | Pcl_let(rf, pel, ce) -> + let bv = add_bindings rf bv pel in add_class_expr bv ce + | Pcl_constraint(ce, ct) -> + add_class_expr bv ce; add_class_type bv ct + | Pcl_extension e -> handle_extension e + | Pcl_open (_ovf, m, e) -> + let bv = open_module bv m.txt in add_class_expr bv e - location = (fun _this _l -> ()); +and add_class_field bv pcf = + match pcf.pcf_desc with + Pcf_inherit(_, ce, _) -> add_class_expr bv ce + | Pcf_val(_, _, Cfk_concrete (_, e)) + | Pcf_method(_, _, Cfk_concrete (_, e)) -> add_expr bv e + | Pcf_val(_, _, Cfk_virtual ty) + | Pcf_method(_, _, Cfk_virtual ty) -> add_type bv ty + | Pcf_constraint(ty1, ty2) -> add_type bv ty1; add_type bv ty2 + | Pcf_initializer e -> add_expr bv e + | Pcf_attribute _ -> () + | Pcf_extension e -> handle_extension e - extension = (fun this (s, e) -> iter_loc this s; this.payload this e); - attribute = (fun this (s, e) -> iter_loc this s; this.payload this e); - attributes = (fun this l -> List.iter (this.attribute this) l); - payload = - (fun this -> function - | PStr x -> this.structure this x - | PSig x -> this.signature this x - | PTyp x -> this.typ this x - | PPat (x, g) -> this.pat this x; iter_opt (this.expr this) g - ); - } +and add_class_declaration bv decl = + add_class_expr bv decl.pci_expr end -module Ast_invariants : sig -#1 "ast_invariants.mli" +module Parse : sig +#1 "parse.mli" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Jeremie Dimino, Jane Street Europe *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) (* *) -(* Copyright 2015 Jane Street Group LLC *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) (* the GNU Lesser General Public License version 2.1, with the *) @@ -27688,20 +28478,26 @@ module Ast_invariants : sig (* *) (**************************************************************************) -(** Check AST invariants *) +(** Entry points in the parser *) -val structure : Parsetree.structure -> unit -val signature : Parsetree.signature -> unit +val implementation : Lexing.lexbuf -> Parsetree.structure +val interface : Lexing.lexbuf -> Parsetree.signature +val toplevel_phrase : Lexing.lexbuf -> Parsetree.toplevel_phrase +val use_file : Lexing.lexbuf -> Parsetree.toplevel_phrase list +val core_type : Lexing.lexbuf -> Parsetree.core_type +val expression : Lexing.lexbuf -> Parsetree.expression +val pattern : Lexing.lexbuf -> Parsetree.pattern end = struct -#1 "ast_invariants.ml" +#1 "parse.ml" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Jeremie Dimino, Jane Street Europe *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) (* *) -(* Copyright 2015 Jane Street Group LLC *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) (* the GNU Lesser General Public License version 2.1, with the *) @@ -27709,167 +28505,67 @@ end = struct (* *) (**************************************************************************) -open Asttypes -open Parsetree -open Ast_iterator +(* Entry points in the parser *) -let err = Syntaxerr.ill_formed_ast +(* Skip tokens to the end of the phrase *) -let empty_record loc = err loc "Records cannot be empty." -let empty_variant loc = err loc "Variant types cannot be empty." -let invalid_tuple loc = err loc "Tuples must have at least 2 components." -let no_args loc = err loc "Function application with no argument." -let empty_let loc = err loc "Let with no bindings." -let empty_type loc = err loc "Type declarations cannot be empty." -let complex_id loc = err loc "Functor application not allowed here." +let rec skip_phrase lexbuf = + try + match Lexer.token lexbuf with + Parser.SEMISEMI | Parser.EOF -> () + | _ -> skip_phrase lexbuf + with + | Lexer.Error (Lexer.Unterminated_comment _, _) + | Lexer.Error (Lexer.Unterminated_string, _) + | Lexer.Error (Lexer.Unterminated_string_in_comment _, _) + | Lexer.Error (Lexer.Illegal_character _, _) -> skip_phrase lexbuf +;; -let simple_longident id = - let rec is_simple = function - | Longident.Lident _ -> true - | Longident.Ldot (id, _) -> is_simple id - | Longident.Lapply _ -> false - in - if not (is_simple id.txt) then complex_id id.loc +let maybe_skip_phrase lexbuf = + if Parsing.is_current_lookahead Parser.SEMISEMI + || Parsing.is_current_lookahead Parser.EOF + then () + else skip_phrase lexbuf -let iterator = - let super = Ast_iterator.default_iterator in - let type_declaration self td = - super.type_declaration self td; - let loc = td.ptype_loc in - match td.ptype_kind with - | Ptype_record [] -> empty_record loc - | Ptype_variant [] -> empty_variant loc - | _ -> () - in - let typ self ty = - super.typ self ty; - let loc = ty.ptyp_loc in - match ty.ptyp_desc with - | Ptyp_tuple ([] | [_]) -> invalid_tuple loc - | Ptyp_class (id, _) -> simple_longident id - | Ptyp_package (_, cstrs) -> - List.iter (fun (id, _) -> simple_longident id) cstrs - | _ -> () - in - let pat self pat = - begin match pat.ppat_desc with - | Ppat_construct (_, Some ({ppat_desc = Ppat_tuple _} as p)) - when Builtin_attributes.explicit_arity pat.ppat_attributes -> - super.pat self p (* allow unary tuple, see GPR#523. *) - | _ -> - super.pat self pat - end; - let loc = pat.ppat_loc in - match pat.ppat_desc with - | Ppat_tuple ([] | [_]) -> invalid_tuple loc - | Ppat_record ([], _) -> empty_record loc - | Ppat_construct (id, _) -> simple_longident id - | Ppat_record (fields, _) -> - List.iter (fun (id, _) -> simple_longident id) fields - | _ -> () - in - let expr self exp = - begin match exp.pexp_desc with - | Pexp_construct (_, Some ({pexp_desc = Pexp_tuple _} as e)) - when Builtin_attributes.explicit_arity exp.pexp_attributes -> - super.expr self e (* allow unary tuple, see GPR#523. *) - | _ -> - super.expr self exp - end; - let loc = exp.pexp_loc in - match exp.pexp_desc with - | Pexp_tuple ([] | [_]) -> invalid_tuple loc - | Pexp_record ([], _) -> empty_record loc - | Pexp_apply (_, []) -> no_args loc - | Pexp_let (_, [], _) -> empty_let loc - | Pexp_ident id - | Pexp_construct (id, _) - | Pexp_field (_, id) - | Pexp_setfield (_, id, _) - | Pexp_new id - | Pexp_open (_, id, _) -> simple_longident id - | Pexp_record (fields, _) -> - List.iter (fun (id, _) -> simple_longident id) fields - | _ -> () - in - let extension_constructor self ec = - super.extension_constructor self ec; - match ec.pext_kind with - | Pext_rebind id -> simple_longident id - | _ -> () - in - let class_expr self ce = - super.class_expr self ce; - let loc = ce.pcl_loc in - match ce.pcl_desc with - | Pcl_apply (_, []) -> no_args loc - | Pcl_constr (id, _) -> simple_longident id - | _ -> () - in - let module_type self mty = - super.module_type self mty; - match mty.pmty_desc with - | Pmty_alias id -> simple_longident id - | _ -> () - in - let open_description self opn = - super.open_description self opn; - simple_longident opn.popen_lid - in - let with_constraint self wc = - super.with_constraint self wc; - match wc with - | Pwith_type (id, _) - | Pwith_module (id, _) -> simple_longident id - | _ -> () - in - let module_expr self me = - super.module_expr self me; - match me.pmod_desc with - | Pmod_ident id -> simple_longident id - | _ -> () - in - let structure_item self st = - super.structure_item self st; - let loc = st.pstr_loc in - match st.pstr_desc with - | Pstr_type (_, []) -> empty_type loc - | Pstr_value (_, []) -> empty_let loc - | _ -> () - in - let signature_item self sg = - super.signature_item self sg; - let loc = sg.psig_loc in - match sg.psig_desc with - | Psig_type (_, []) -> empty_type loc - | _ -> () - in - { super with - type_declaration - ; typ - ; pat - ; expr - ; extension_constructor - ; class_expr - ; module_expr - ; module_type - ; open_description - ; with_constraint - ; structure_item - ; signature_item - } +let wrap parsing_fun lexbuf = + try + Docstrings.init (); + Lexer.init (); + let ast = parsing_fun Lexer.token lexbuf in + Parsing.clear_parser(); + Docstrings.warn_bad_docstrings (); + ast + with + | Lexer.Error(Lexer.Illegal_character _, _) as err + when !Location.input_name = "//toplevel//"-> + skip_phrase lexbuf; + raise err + | Syntaxerr.Error _ as err + when !Location.input_name = "//toplevel//" -> + maybe_skip_phrase lexbuf; + raise err + | Parsing.Parse_error | Syntaxerr.Escape_error -> + let loc = Location.curr lexbuf in + if !Location.input_name = "//toplevel//" + then maybe_skip_phrase lexbuf; + raise(Syntaxerr.Error(Syntaxerr.Other loc)) -let structure st = iterator.structure iterator st -let signature sg = iterator.signature iterator sg +let implementation = wrap Parser.implementation +and interface = wrap Parser.interface +and toplevel_phrase = wrap Parser.toplevel_phrase +and use_file = wrap Parser.use_file +and core_type = wrap Parser.parse_core_type +and expression = wrap Parser.parse_expression +and pattern = wrap Parser.parse_pattern end -module Ast_mapper : sig -#1 "ast_mapper.mli" +module Ast_iterator : sig +#1 "ast_iterator.mli" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Alain Frisch, LexiFi *) +(* Nicolas Ojeda Bar, LexiFi *) (* *) (* Copyright 2012 Institut National de Recherche en Informatique et *) (* en Automatique. *) @@ -27878,201 +28574,73 @@ module Ast_mapper : sig (* the GNU Lesser General Public License version 2.1, with the *) (* special exception on linking described in the file LICENSE. *) (* *) -(**************************************************************************) - -(** The interface of a -ppx rewriter - - A -ppx rewriter is a program that accepts a serialized abstract syntax - tree and outputs another, possibly modified, abstract syntax tree. - This module encapsulates the interface between the compiler and - the -ppx rewriters, handling such details as the serialization format, - forwarding of command-line flags, and storing state. - - {!mapper} allows to implement AST rewriting using open recursion. - A typical mapper would be based on {!default_mapper}, a deep - identity mapper, and will fall back on it for handling the syntax it - does not modify. For example: - - {[ -open Asttypes -open Parsetree -open Ast_mapper - -let test_mapper argv = - { default_mapper with - expr = fun mapper expr -> - match expr with - | { pexp_desc = Pexp_extension ({ txt = "test" }, PStr [])} -> - Ast_helper.Exp.constant (Const_int 42) - | other -> default_mapper.expr mapper other; } - -let () = - register "ppx_test" test_mapper]} - - This -ppx rewriter, which replaces [[%test]] in expressions with - the constant [42], can be compiled using - [ocamlc -o ppx_test -I +compiler-libs ocamlcommon.cma ppx_test.ml]. - - *) - -open Parsetree - -(** {1 A generic Parsetree mapper} *) - -type mapper = { - attribute: mapper -> attribute -> attribute; - attributes: mapper -> attribute list -> attribute list; - case: mapper -> case -> case; - cases: mapper -> case list -> case list; - class_declaration: mapper -> class_declaration -> class_declaration; - class_description: mapper -> class_description -> class_description; - class_expr: mapper -> class_expr -> class_expr; - class_field: mapper -> class_field -> class_field; - class_signature: mapper -> class_signature -> class_signature; - class_structure: mapper -> class_structure -> class_structure; - class_type: mapper -> class_type -> class_type; - class_type_declaration: mapper -> class_type_declaration - -> class_type_declaration; - class_type_field: mapper -> class_type_field -> class_type_field; - constructor_declaration: mapper -> constructor_declaration - -> constructor_declaration; - expr: mapper -> expression -> expression; - extension: mapper -> extension -> extension; - extension_constructor: mapper -> extension_constructor - -> extension_constructor; - include_declaration: mapper -> include_declaration -> include_declaration; - include_description: mapper -> include_description -> include_description; - label_declaration: mapper -> label_declaration -> label_declaration; - location: mapper -> Location.t -> Location.t; - module_binding: mapper -> module_binding -> module_binding; - module_declaration: mapper -> module_declaration -> module_declaration; - module_expr: mapper -> module_expr -> module_expr; - module_type: mapper -> module_type -> module_type; - module_type_declaration: mapper -> module_type_declaration - -> module_type_declaration; - open_description: mapper -> open_description -> open_description; - pat: mapper -> pattern -> pattern; - payload: mapper -> payload -> payload; - signature: mapper -> signature -> signature; - signature_item: mapper -> signature_item -> signature_item; - structure: mapper -> structure -> structure; - structure_item: mapper -> structure_item -> structure_item; - typ: mapper -> core_type -> core_type; - type_declaration: mapper -> type_declaration -> type_declaration; - type_extension: mapper -> type_extension -> type_extension; - type_kind: mapper -> type_kind -> type_kind; - value_binding: mapper -> value_binding -> value_binding; - value_description: mapper -> value_description -> value_description; - with_constraint: mapper -> with_constraint -> with_constraint; -} -(** A mapper record implements one "method" per syntactic category, - using an open recursion style: each method takes as its first - argument the mapper to be applied to children in the syntax - tree. *) - -val default_mapper: mapper -(** A default mapper, which implements a "deep identity" mapping. *) - -(** {1 Apply mappers to compilation units} *) - -val tool_name: unit -> string -(** Can be used within a ppx preprocessor to know which tool is - calling it ["ocamlc"], ["ocamlopt"], ["ocamldoc"], ["ocamldep"], - ["ocaml"], ... Some global variables that reflect command-line - options are automatically synchronized between the calling tool - and the ppx preprocessor: {!Clflags.include_dirs}, - {!Config.load_path}, {!Clflags.open_modules}, {!Clflags.for_package}, - {!Clflags.debug}. *) - - -val apply: source:string -> target:string -> mapper -> unit -(** Apply a mapper (parametrized by the unit name) to a dumped - parsetree found in the [source] file and put the result in the - [target] file. The [structure] or [signature] field of the mapper - is applied to the implementation or interface. *) - -val run_main: (string list -> mapper) -> unit -(** Entry point to call to implement a standalone -ppx rewriter from a - mapper, parametrized by the command line arguments. The current - unit name can be obtained from {!Location.input_name}. This - function implements proper error reporting for uncaught - exceptions. *) - -(** {1 Registration API} *) - -val register_function: (string -> (string list -> mapper) -> unit) ref - -val register: string -> (string list -> mapper) -> unit -(** Apply the [register_function]. The default behavior is to run the - mapper immediately, taking arguments from the process command - line. This is to support a scenario where a mapper is linked as a - stand-alone executable. - - It is possible to overwrite the [register_function] to define - "-ppx drivers", which combine several mappers in a single process. - Typically, a driver starts by defining [register_function] to a - custom implementation, then lets ppx rewriters (linked statically - or dynamically) register themselves, and then run all or some of - them. It is also possible to have -ppx drivers apply rewriters to - only specific parts of an AST. - - The first argument to [register] is a symbolic name to be used by - the ppx driver. *) - - -(** {1 Convenience functions to write mappers} *) - -val map_opt: ('a -> 'b) -> 'a option -> 'b option - -val extension_of_error: Location.error -> extension -(** Encode an error into an 'ocaml.error' extension node which can be - inserted in a generated Parsetree. The compiler will be - responsible for reporting the error. *) - -val attribute_of_warning: Location.t -> string -> attribute -(** Encode a warning message into an 'ocaml.ppwarning' attribute which can be - inserted in a generated Parsetree. The compiler will be - responsible for reporting the warning. *) - -(** {1 Helper functions to call external mappers} *) - -val add_ppx_context_str: - tool_name:string -> Parsetree.structure -> Parsetree.structure -(** Extract information from the current environment and encode it - into an attribute which is prepended to the list of structure - items in order to pass the information to an external - processor. *) - -val add_ppx_context_sig: - tool_name:string -> Parsetree.signature -> Parsetree.signature -(** Same as [add_ppx_context_str], but for signatures. *) - -val drop_ppx_context_str: - restore:bool -> Parsetree.structure -> Parsetree.structure -(** Drop the ocaml.ppx.context attribute from a structure. If - [restore] is true, also restore the associated data in the current - process. *) +(**************************************************************************) -val drop_ppx_context_sig: - restore:bool -> Parsetree.signature -> Parsetree.signature -(** Same as [drop_ppx_context_str], but for signatures. *) +(** {!iterator} allows to implement AST inspection using open recursion. A + typical mapper would be based on {!default_iterator}, a trivial iterator, + and will fall back on it for handling the syntax it does not modify. *) -(** {1 Cookies} *) +open Parsetree -(** Cookies are used to pass information from a ppx processor to - a further invocation of itself, when called from the OCaml - toplevel (or other tools that support cookies). *) +(** {1 A generic Parsetree iterator} *) -val set_cookie: string -> Parsetree.expression -> unit -val get_cookie: string -> Parsetree.expression option +type iterator = { + attribute: iterator -> attribute -> unit; + attributes: iterator -> attribute list -> unit; + case: iterator -> case -> unit; + cases: iterator -> case list -> unit; + class_declaration: iterator -> class_declaration -> unit; + class_description: iterator -> class_description -> unit; + class_expr: iterator -> class_expr -> unit; + class_field: iterator -> class_field -> unit; + class_signature: iterator -> class_signature -> unit; + class_structure: iterator -> class_structure -> unit; + class_type: iterator -> class_type -> unit; + class_type_declaration: iterator -> class_type_declaration -> unit; + class_type_field: iterator -> class_type_field -> unit; + constructor_declaration: iterator -> constructor_declaration -> unit; + expr: iterator -> expression -> unit; + extension: iterator -> extension -> unit; + extension_constructor: iterator -> extension_constructor -> unit; + include_declaration: iterator -> include_declaration -> unit; + include_description: iterator -> include_description -> unit; + label_declaration: iterator -> label_declaration -> unit; + location: iterator -> Location.t -> unit; + module_binding: iterator -> module_binding -> unit; + module_declaration: iterator -> module_declaration -> unit; + module_expr: iterator -> module_expr -> unit; + module_type: iterator -> module_type -> unit; + module_type_declaration: iterator -> module_type_declaration -> unit; + open_description: iterator -> open_description -> unit; + pat: iterator -> pattern -> unit; + payload: iterator -> payload -> unit; + signature: iterator -> signature -> unit; + signature_item: iterator -> signature_item -> unit; + structure: iterator -> structure -> unit; + structure_item: iterator -> structure_item -> unit; + typ: iterator -> core_type -> unit; + type_declaration: iterator -> type_declaration -> unit; + type_extension: iterator -> type_extension -> unit; + type_kind: iterator -> type_kind -> unit; + value_binding: iterator -> value_binding -> unit; + value_description: iterator -> value_description -> unit; + with_constraint: iterator -> with_constraint -> unit; +} +(** A [iterator] record implements one "method" per syntactic category, + using an open recursion style: each method takes as its first + argument the iterator to be applied to children in the syntax + tree. *) + +val default_iterator: iterator +(** A default iterator, which implements a "do not do anything" mapping. *) end = struct -#1 "ast_mapper.ml" +#1 "ast_iterator.ml" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Alain Frisch, LexiFi *) +(* Nicolas Ojeda Bar, LexiFi *) (* *) (* Copyright 2012 Institut National de Recherche en Informatique et *) (* en Automatique. *) @@ -28092,938 +28660,599 @@ end = struct open Parsetree -open Ast_helper open Location -type mapper = { - attribute: mapper -> attribute -> attribute; - attributes: mapper -> attribute list -> attribute list; - case: mapper -> case -> case; - cases: mapper -> case list -> case list; - class_declaration: mapper -> class_declaration -> class_declaration; - class_description: mapper -> class_description -> class_description; - class_expr: mapper -> class_expr -> class_expr; - class_field: mapper -> class_field -> class_field; - class_signature: mapper -> class_signature -> class_signature; - class_structure: mapper -> class_structure -> class_structure; - class_type: mapper -> class_type -> class_type; - class_type_declaration: mapper -> class_type_declaration - -> class_type_declaration; - class_type_field: mapper -> class_type_field -> class_type_field; - constructor_declaration: mapper -> constructor_declaration - -> constructor_declaration; - expr: mapper -> expression -> expression; - extension: mapper -> extension -> extension; - extension_constructor: mapper -> extension_constructor - -> extension_constructor; - include_declaration: mapper -> include_declaration -> include_declaration; - include_description: mapper -> include_description -> include_description; - label_declaration: mapper -> label_declaration -> label_declaration; - location: mapper -> Location.t -> Location.t; - module_binding: mapper -> module_binding -> module_binding; - module_declaration: mapper -> module_declaration -> module_declaration; - module_expr: mapper -> module_expr -> module_expr; - module_type: mapper -> module_type -> module_type; - module_type_declaration: mapper -> module_type_declaration - -> module_type_declaration; - open_description: mapper -> open_description -> open_description; - pat: mapper -> pattern -> pattern; - payload: mapper -> payload -> payload; - signature: mapper -> signature -> signature; - signature_item: mapper -> signature_item -> signature_item; - structure: mapper -> structure -> structure; - structure_item: mapper -> structure_item -> structure_item; - typ: mapper -> core_type -> core_type; - type_declaration: mapper -> type_declaration -> type_declaration; - type_extension: mapper -> type_extension -> type_extension; - type_kind: mapper -> type_kind -> type_kind; - value_binding: mapper -> value_binding -> value_binding; - value_description: mapper -> value_description -> value_description; - with_constraint: mapper -> with_constraint -> with_constraint; +type iterator = { + attribute: iterator -> attribute -> unit; + attributes: iterator -> attribute list -> unit; + case: iterator -> case -> unit; + cases: iterator -> case list -> unit; + class_declaration: iterator -> class_declaration -> unit; + class_description: iterator -> class_description -> unit; + class_expr: iterator -> class_expr -> unit; + class_field: iterator -> class_field -> unit; + class_signature: iterator -> class_signature -> unit; + class_structure: iterator -> class_structure -> unit; + class_type: iterator -> class_type -> unit; + class_type_declaration: iterator -> class_type_declaration -> unit; + class_type_field: iterator -> class_type_field -> unit; + constructor_declaration: iterator -> constructor_declaration -> unit; + expr: iterator -> expression -> unit; + extension: iterator -> extension -> unit; + extension_constructor: iterator -> extension_constructor -> unit; + include_declaration: iterator -> include_declaration -> unit; + include_description: iterator -> include_description -> unit; + label_declaration: iterator -> label_declaration -> unit; + location: iterator -> Location.t -> unit; + module_binding: iterator -> module_binding -> unit; + module_declaration: iterator -> module_declaration -> unit; + module_expr: iterator -> module_expr -> unit; + module_type: iterator -> module_type -> unit; + module_type_declaration: iterator -> module_type_declaration -> unit; + open_description: iterator -> open_description -> unit; + pat: iterator -> pattern -> unit; + payload: iterator -> payload -> unit; + signature: iterator -> signature -> unit; + signature_item: iterator -> signature_item -> unit; + structure: iterator -> structure -> unit; + structure_item: iterator -> structure_item -> unit; + typ: iterator -> core_type -> unit; + type_declaration: iterator -> type_declaration -> unit; + type_extension: iterator -> type_extension -> unit; + type_kind: iterator -> type_kind -> unit; + value_binding: iterator -> value_binding -> unit; + value_description: iterator -> value_description -> unit; + with_constraint: iterator -> with_constraint -> unit; } +(** A [iterator] record implements one "method" per syntactic category, + using an open recursion style: each method takes as its first + argument the iterator to be applied to children in the syntax + tree. *) -let map_fst f (x, y) = (f x, y) -let map_snd f (x, y) = (x, f y) -let map_tuple f1 f2 (x, y) = (f1 x, f2 y) -let map_tuple3 f1 f2 f3 (x, y, z) = (f1 x, f2 y, f3 z) -let map_opt f = function None -> None | Some x -> Some (f x) +let iter_fst f (x, _) = f x +let iter_snd f (_, y) = f y +let iter_tuple f1 f2 (x, y) = f1 x; f2 y +let iter_tuple3 f1 f2 f3 (x, y, z) = f1 x; f2 y; f3 z +let iter_opt f = function None -> () | Some x -> f x -let map_loc sub {loc; txt} = {loc = sub.location sub loc; txt} +let iter_loc sub {loc; txt = _} = sub.location sub loc module T = struct (* Type expressions for the core language *) let row_field sub = function - | Rtag (l, attrs, b, tl) -> - Rtag (map_loc sub l, sub.attributes sub attrs, - b, List.map (sub.typ sub) tl) - | Rinherit t -> Rinherit (sub.typ sub t) + | Rtag (_, attrs, _, tl) -> + sub.attributes sub attrs; List.iter (sub.typ sub) tl + | Rinherit t -> sub.typ sub t let object_field sub = function - | Otag (l, attrs, t) -> - Otag (map_loc sub l, sub.attributes sub attrs, sub.typ sub t) - | Oinherit t -> Oinherit (sub.typ sub t) + | Otag (_, attrs, t) -> + sub.attributes sub attrs; sub.typ sub t + | Oinherit t -> sub.typ sub t - let map sub {ptyp_desc = desc; ptyp_loc = loc; ptyp_attributes = attrs} = - let open Typ in - let loc = sub.location sub loc in - let attrs = sub.attributes sub attrs in + let iter sub {ptyp_desc = desc; ptyp_loc = loc; ptyp_attributes = attrs} = + sub.location sub loc; + sub.attributes sub attrs; match desc with - | Ptyp_any -> any ~loc ~attrs () - | Ptyp_var s -> var ~loc ~attrs s - | Ptyp_arrow (lab, t1, t2) -> - arrow ~loc ~attrs lab (sub.typ sub t1) (sub.typ sub t2) - | Ptyp_tuple tyl -> tuple ~loc ~attrs (List.map (sub.typ sub) tyl) + | Ptyp_any + | Ptyp_var _ -> () + | Ptyp_arrow (_lab, t1, t2) -> + sub.typ sub t1; sub.typ sub t2 + | Ptyp_tuple tyl -> List.iter (sub.typ sub) tyl | Ptyp_constr (lid, tl) -> - constr ~loc ~attrs (map_loc sub lid) (List.map (sub.typ sub) tl) - | Ptyp_object (l, o) -> - object_ ~loc ~attrs (List.map (object_field sub) l) o + iter_loc sub lid; List.iter (sub.typ sub) tl + | Ptyp_object (ol, _o) -> + List.iter (object_field sub) ol | Ptyp_class (lid, tl) -> - class_ ~loc ~attrs (map_loc sub lid) (List.map (sub.typ sub) tl) - | Ptyp_alias (t, s) -> alias ~loc ~attrs (sub.typ sub t) s - | Ptyp_variant (rl, b, ll) -> - variant ~loc ~attrs (List.map (row_field sub) rl) b ll - | Ptyp_poly (sl, t) -> poly ~loc ~attrs - (List.map (map_loc sub) sl) (sub.typ sub t) + iter_loc sub lid; List.iter (sub.typ sub) tl + | Ptyp_alias (t, _) -> sub.typ sub t + | Ptyp_variant (rl, _b, _ll) -> + List.iter (row_field sub) rl + | Ptyp_poly (_, t) -> sub.typ sub t | Ptyp_package (lid, l) -> - package ~loc ~attrs (map_loc sub lid) - (List.map (map_tuple (map_loc sub) (sub.typ sub)) l) - | Ptyp_extension x -> extension ~loc ~attrs (sub.extension sub x) + iter_loc sub lid; + List.iter (iter_tuple (iter_loc sub) (sub.typ sub)) l + | Ptyp_extension x -> sub.extension sub x - let map_type_declaration sub + let iter_type_declaration sub {ptype_name; ptype_params; ptype_cstrs; ptype_kind; - ptype_private; + ptype_private = _; ptype_manifest; ptype_attributes; ptype_loc} = - Type.mk (map_loc sub ptype_name) - ~params:(List.map (map_fst (sub.typ sub)) ptype_params) - ~priv:ptype_private - ~cstrs:(List.map - (map_tuple3 (sub.typ sub) (sub.typ sub) (sub.location sub)) - ptype_cstrs) - ~kind:(sub.type_kind sub ptype_kind) - ?manifest:(map_opt (sub.typ sub) ptype_manifest) - ~loc:(sub.location sub ptype_loc) - ~attrs:(sub.attributes sub ptype_attributes) + iter_loc sub ptype_name; + List.iter (iter_fst (sub.typ sub)) ptype_params; + List.iter + (iter_tuple3 (sub.typ sub) (sub.typ sub) (sub.location sub)) + ptype_cstrs; + sub.type_kind sub ptype_kind; + iter_opt (sub.typ sub) ptype_manifest; + sub.location sub ptype_loc; + sub.attributes sub ptype_attributes - let map_type_kind sub = function - | Ptype_abstract -> Ptype_abstract + let iter_type_kind sub = function + | Ptype_abstract -> () | Ptype_variant l -> - Ptype_variant (List.map (sub.constructor_declaration sub) l) - | Ptype_record l -> Ptype_record (List.map (sub.label_declaration sub) l) - | Ptype_open -> Ptype_open + List.iter (sub.constructor_declaration sub) l + | Ptype_record l -> List.iter (sub.label_declaration sub) l + | Ptype_open -> () - let map_constructor_arguments sub = function - | Pcstr_tuple l -> Pcstr_tuple (List.map (sub.typ sub) l) + let iter_constructor_arguments sub = function + | Pcstr_tuple l -> List.iter (sub.typ sub) l | Pcstr_record l -> - Pcstr_record (List.map (sub.label_declaration sub) l) + List.iter (sub.label_declaration sub) l - let map_type_extension sub + let iter_type_extension sub {ptyext_path; ptyext_params; ptyext_constructors; - ptyext_private; + ptyext_private = _; ptyext_attributes} = - Te.mk - (map_loc sub ptyext_path) - (List.map (sub.extension_constructor sub) ptyext_constructors) - ~params:(List.map (map_fst (sub.typ sub)) ptyext_params) - ~priv:ptyext_private - ~attrs:(sub.attributes sub ptyext_attributes) + iter_loc sub ptyext_path; + List.iter (sub.extension_constructor sub) ptyext_constructors; + List.iter (iter_fst (sub.typ sub)) ptyext_params; + sub.attributes sub ptyext_attributes - let map_extension_constructor_kind sub = function + let iter_extension_constructor_kind sub = function Pext_decl(ctl, cto) -> - Pext_decl(map_constructor_arguments sub ctl, map_opt (sub.typ sub) cto) + iter_constructor_arguments sub ctl; iter_opt (sub.typ sub) cto | Pext_rebind li -> - Pext_rebind (map_loc sub li) + iter_loc sub li - let map_extension_constructor sub + let iter_extension_constructor sub {pext_name; pext_kind; pext_loc; pext_attributes} = - Te.constructor - (map_loc sub pext_name) - (map_extension_constructor_kind sub pext_kind) - ~loc:(sub.location sub pext_loc) - ~attrs:(sub.attributes sub pext_attributes) + iter_loc sub pext_name; + iter_extension_constructor_kind sub pext_kind; + sub.location sub pext_loc; + sub.attributes sub pext_attributes end module CT = struct (* Type expressions for the class language *) - let map sub {pcty_loc = loc; pcty_desc = desc; pcty_attributes = attrs} = - let open Cty in - let loc = sub.location sub loc in - let attrs = sub.attributes sub attrs in + let iter sub {pcty_loc = loc; pcty_desc = desc; pcty_attributes = attrs} = + sub.location sub loc; + sub.attributes sub attrs; match desc with | Pcty_constr (lid, tys) -> - constr ~loc ~attrs (map_loc sub lid) (List.map (sub.typ sub) tys) - | Pcty_signature x -> signature ~loc ~attrs (sub.class_signature sub x) - | Pcty_arrow (lab, t, ct) -> - arrow ~loc ~attrs lab (sub.typ sub t) (sub.class_type sub ct) - | Pcty_extension x -> extension ~loc ~attrs (sub.extension sub x) - | Pcty_open (ovf, lid, ct) -> - open_ ~loc ~attrs ovf (map_loc sub lid) (sub.class_type sub ct) + iter_loc sub lid; List.iter (sub.typ sub) tys + | Pcty_signature x -> sub.class_signature sub x + | Pcty_arrow (_lab, t, ct) -> + sub.typ sub t; sub.class_type sub ct + | Pcty_extension x -> sub.extension sub x + | Pcty_open (_ovf, lid, e) -> + iter_loc sub lid; sub.class_type sub e - let map_field sub {pctf_desc = desc; pctf_loc = loc; pctf_attributes = attrs} + let iter_field sub {pctf_desc = desc; pctf_loc = loc; pctf_attributes = attrs} = - let open Ctf in - let loc = sub.location sub loc in - let attrs = sub.attributes sub attrs in + sub.location sub loc; + sub.attributes sub attrs; match desc with - | Pctf_inherit ct -> inherit_ ~loc ~attrs (sub.class_type sub ct) - | Pctf_val (s, m, v, t) -> - val_ ~loc ~attrs (map_loc sub s) m v (sub.typ sub t) - | Pctf_method (s, p, v, t) -> - method_ ~loc ~attrs (map_loc sub s) p v (sub.typ sub t) + | Pctf_inherit ct -> sub.class_type sub ct + | Pctf_val (_s, _m, _v, t) -> sub.typ sub t + | Pctf_method (_s, _p, _v, t) -> sub.typ sub t | Pctf_constraint (t1, t2) -> - constraint_ ~loc ~attrs (sub.typ sub t1) (sub.typ sub t2) - | Pctf_attribute x -> attribute ~loc (sub.attribute sub x) - | Pctf_extension x -> extension ~loc ~attrs (sub.extension sub x) + sub.typ sub t1; sub.typ sub t2 + | Pctf_attribute x -> sub.attribute sub x + | Pctf_extension x -> sub.extension sub x - let map_signature sub {pcsig_self; pcsig_fields} = - Csig.mk - (sub.typ sub pcsig_self) - (List.map (sub.class_type_field sub) pcsig_fields) + let iter_signature sub {pcsig_self; pcsig_fields} = + sub.typ sub pcsig_self; + List.iter (sub.class_type_field sub) pcsig_fields end module MT = struct (* Type expressions for the module language *) - let map sub {pmty_desc = desc; pmty_loc = loc; pmty_attributes = attrs} = - let open Mty in - let loc = sub.location sub loc in - let attrs = sub.attributes sub attrs in + let iter sub {pmty_desc = desc; pmty_loc = loc; pmty_attributes = attrs} = + sub.location sub loc; + sub.attributes sub attrs; match desc with - | Pmty_ident s -> ident ~loc ~attrs (map_loc sub s) - | Pmty_alias s -> alias ~loc ~attrs (map_loc sub s) - | Pmty_signature sg -> signature ~loc ~attrs (sub.signature sub sg) + | Pmty_ident s -> iter_loc sub s + | Pmty_alias s -> iter_loc sub s + | Pmty_signature sg -> sub.signature sub sg | Pmty_functor (s, mt1, mt2) -> - functor_ ~loc ~attrs (map_loc sub s) - (Misc.may_map (sub.module_type sub) mt1) - (sub.module_type sub mt2) + iter_loc sub s; + iter_opt (sub.module_type sub) mt1; + sub.module_type sub mt2 | Pmty_with (mt, l) -> - with_ ~loc ~attrs (sub.module_type sub mt) - (List.map (sub.with_constraint sub) l) - | Pmty_typeof me -> typeof_ ~loc ~attrs (sub.module_expr sub me) - | Pmty_extension x -> extension ~loc ~attrs (sub.extension sub x) + sub.module_type sub mt; + List.iter (sub.with_constraint sub) l + | Pmty_typeof me -> sub.module_expr sub me + | Pmty_extension x -> sub.extension sub x - let map_with_constraint sub = function + let iter_with_constraint sub = function | Pwith_type (lid, d) -> - Pwith_type (map_loc sub lid, sub.type_declaration sub d) + iter_loc sub lid; sub.type_declaration sub d | Pwith_module (lid, lid2) -> - Pwith_module (map_loc sub lid, map_loc sub lid2) + iter_loc sub lid; iter_loc sub lid2 | Pwith_typesubst (lid, d) -> - Pwith_typesubst (map_loc sub lid, sub.type_declaration sub d) + iter_loc sub lid; sub.type_declaration sub d | Pwith_modsubst (s, lid) -> - Pwith_modsubst (map_loc sub s, map_loc sub lid) + iter_loc sub s; iter_loc sub lid - let map_signature_item sub {psig_desc = desc; psig_loc = loc} = - let open Sig in - let loc = sub.location sub loc in + let iter_signature_item sub {psig_desc = desc; psig_loc = loc} = + sub.location sub loc; match desc with - | Psig_value vd -> value ~loc (sub.value_description sub vd) - | Psig_type (rf, l) -> type_ ~loc rf (List.map (sub.type_declaration sub) l) - | Psig_typext te -> type_extension ~loc (sub.type_extension sub te) - | Psig_exception ed -> exception_ ~loc (sub.extension_constructor sub ed) - | Psig_module x -> module_ ~loc (sub.module_declaration sub x) + | Psig_value vd -> sub.value_description sub vd + | Psig_type (_rf, l) -> List.iter (sub.type_declaration sub) l + | Psig_typext te -> sub.type_extension sub te + | Psig_exception ed -> sub.extension_constructor sub ed + | Psig_module x -> sub.module_declaration sub x | Psig_recmodule l -> - rec_module ~loc (List.map (sub.module_declaration sub) l) - | Psig_modtype x -> modtype ~loc (sub.module_type_declaration sub x) - | Psig_open x -> open_ ~loc (sub.open_description sub x) - | Psig_include x -> include_ ~loc (sub.include_description sub x) - | Psig_class l -> class_ ~loc (List.map (sub.class_description sub) l) + List.iter (sub.module_declaration sub) l + | Psig_modtype x -> sub.module_type_declaration sub x + | Psig_open x -> sub.open_description sub x + | Psig_include x -> sub.include_description sub x + | Psig_class l -> List.iter (sub.class_description sub) l | Psig_class_type l -> - class_type ~loc (List.map (sub.class_type_declaration sub) l) + List.iter (sub.class_type_declaration sub) l | Psig_extension (x, attrs) -> - extension ~loc (sub.extension sub x) ~attrs:(sub.attributes sub attrs) - | Psig_attribute x -> attribute ~loc (sub.attribute sub x) + sub.extension sub x; sub.attributes sub attrs + | Psig_attribute x -> sub.attribute sub x end module M = struct (* Value expressions for the module language *) - let map sub {pmod_loc = loc; pmod_desc = desc; pmod_attributes = attrs} = - let open Mod in - let loc = sub.location sub loc in - let attrs = sub.attributes sub attrs in + let iter sub {pmod_loc = loc; pmod_desc = desc; pmod_attributes = attrs} = + sub.location sub loc; + sub.attributes sub attrs; match desc with - | Pmod_ident x -> ident ~loc ~attrs (map_loc sub x) - | Pmod_structure str -> structure ~loc ~attrs (sub.structure sub str) + | Pmod_ident x -> iter_loc sub x + | Pmod_structure str -> sub.structure sub str | Pmod_functor (arg, arg_ty, body) -> - functor_ ~loc ~attrs (map_loc sub arg) - (Misc.may_map (sub.module_type sub) arg_ty) - (sub.module_expr sub body) + iter_loc sub arg; + iter_opt (sub.module_type sub) arg_ty; + sub.module_expr sub body | Pmod_apply (m1, m2) -> - apply ~loc ~attrs (sub.module_expr sub m1) (sub.module_expr sub m2) + sub.module_expr sub m1; sub.module_expr sub m2 | Pmod_constraint (m, mty) -> - constraint_ ~loc ~attrs (sub.module_expr sub m) - (sub.module_type sub mty) - | Pmod_unpack e -> unpack ~loc ~attrs (sub.expr sub e) - | Pmod_extension x -> extension ~loc ~attrs (sub.extension sub x) + sub.module_expr sub m; sub.module_type sub mty + | Pmod_unpack e -> sub.expr sub e + | Pmod_extension x -> sub.extension sub x - let map_structure_item sub {pstr_loc = loc; pstr_desc = desc} = - let open Str in - let loc = sub.location sub loc in + let iter_structure_item sub {pstr_loc = loc; pstr_desc = desc} = + sub.location sub loc; match desc with | Pstr_eval (x, attrs) -> - eval ~loc ~attrs:(sub.attributes sub attrs) (sub.expr sub x) - | Pstr_value (r, vbs) -> value ~loc r (List.map (sub.value_binding sub) vbs) - | Pstr_primitive vd -> primitive ~loc (sub.value_description sub vd) - | Pstr_type (rf, l) -> type_ ~loc rf (List.map (sub.type_declaration sub) l) - | Pstr_typext te -> type_extension ~loc (sub.type_extension sub te) - | Pstr_exception ed -> exception_ ~loc (sub.extension_constructor sub ed) - | Pstr_module x -> module_ ~loc (sub.module_binding sub x) - | Pstr_recmodule l -> rec_module ~loc (List.map (sub.module_binding sub) l) - | Pstr_modtype x -> modtype ~loc (sub.module_type_declaration sub x) - | Pstr_open x -> open_ ~loc (sub.open_description sub x) - | Pstr_class l -> class_ ~loc (List.map (sub.class_declaration sub) l) + sub.expr sub x; sub.attributes sub attrs + | Pstr_value (_r, vbs) -> List.iter (sub.value_binding sub) vbs + | Pstr_primitive vd -> sub.value_description sub vd + | Pstr_type (_rf, l) -> List.iter (sub.type_declaration sub) l + | Pstr_typext te -> sub.type_extension sub te + | Pstr_exception ed -> sub.extension_constructor sub ed + | Pstr_module x -> sub.module_binding sub x + | Pstr_recmodule l -> List.iter (sub.module_binding sub) l + | Pstr_modtype x -> sub.module_type_declaration sub x + | Pstr_open x -> sub.open_description sub x + | Pstr_class l -> List.iter (sub.class_declaration sub) l | Pstr_class_type l -> - class_type ~loc (List.map (sub.class_type_declaration sub) l) - | Pstr_include x -> include_ ~loc (sub.include_declaration sub x) + List.iter (sub.class_type_declaration sub) l + | Pstr_include x -> sub.include_declaration sub x | Pstr_extension (x, attrs) -> - extension ~loc (sub.extension sub x) ~attrs:(sub.attributes sub attrs) - | Pstr_attribute x -> attribute ~loc (sub.attribute sub x) + sub.extension sub x; sub.attributes sub attrs + | Pstr_attribute x -> sub.attribute sub x end module E = struct (* Value expressions for the core language *) - let map sub {pexp_loc = loc; pexp_desc = desc; pexp_attributes = attrs} = - let open Exp in - let loc = sub.location sub loc in - let attrs = sub.attributes sub attrs in + let iter sub {pexp_loc = loc; pexp_desc = desc; pexp_attributes = attrs} = + sub.location sub loc; + sub.attributes sub attrs; match desc with - | Pexp_ident x -> ident ~loc ~attrs (map_loc sub x) - | Pexp_constant x -> constant ~loc ~attrs x - | Pexp_let (r, vbs, e) -> - let_ ~loc ~attrs r (List.map (sub.value_binding sub) vbs) - (sub.expr sub e) - | Pexp_fun (lab, def, p, e) -> - fun_ ~loc ~attrs lab (map_opt (sub.expr sub) def) (sub.pat sub p) - (sub.expr sub e) - | Pexp_function pel -> function_ ~loc ~attrs (sub.cases sub pel) + | Pexp_ident x -> iter_loc sub x + | Pexp_constant _ -> () + | Pexp_let (_r, vbs, e) -> + List.iter (sub.value_binding sub) vbs; + sub.expr sub e + | Pexp_fun (_lab, def, p, e) -> + iter_opt (sub.expr sub) def; + sub.pat sub p; + sub.expr sub e + | Pexp_function pel -> sub.cases sub pel | Pexp_apply (e, l) -> - apply ~loc ~attrs (sub.expr sub e) (List.map (map_snd (sub.expr sub)) l) + sub.expr sub e; List.iter (iter_snd (sub.expr sub)) l | Pexp_match (e, pel) -> - match_ ~loc ~attrs (sub.expr sub e) (sub.cases sub pel) - | Pexp_try (e, pel) -> try_ ~loc ~attrs (sub.expr sub e) (sub.cases sub pel) - | Pexp_tuple el -> tuple ~loc ~attrs (List.map (sub.expr sub) el) + sub.expr sub e; sub.cases sub pel + | Pexp_try (e, pel) -> sub.expr sub e; sub.cases sub pel + | Pexp_tuple el -> List.iter (sub.expr sub) el | Pexp_construct (lid, arg) -> - construct ~loc ~attrs (map_loc sub lid) (map_opt (sub.expr sub) arg) - | Pexp_variant (lab, eo) -> - variant ~loc ~attrs lab (map_opt (sub.expr sub) eo) + iter_loc sub lid; iter_opt (sub.expr sub) arg + | Pexp_variant (_lab, eo) -> + iter_opt (sub.expr sub) eo | Pexp_record (l, eo) -> - record ~loc ~attrs (List.map (map_tuple (map_loc sub) (sub.expr sub)) l) - (map_opt (sub.expr sub) eo) + List.iter (iter_tuple (iter_loc sub) (sub.expr sub)) l; + iter_opt (sub.expr sub) eo | Pexp_field (e, lid) -> - field ~loc ~attrs (sub.expr sub e) (map_loc sub lid) + sub.expr sub e; iter_loc sub lid | Pexp_setfield (e1, lid, e2) -> - setfield ~loc ~attrs (sub.expr sub e1) (map_loc sub lid) - (sub.expr sub e2) - | Pexp_array el -> array ~loc ~attrs (List.map (sub.expr sub) el) + sub.expr sub e1; iter_loc sub lid; + sub.expr sub e2 + | Pexp_array el -> List.iter (sub.expr sub) el | Pexp_ifthenelse (e1, e2, e3) -> - ifthenelse ~loc ~attrs (sub.expr sub e1) (sub.expr sub e2) - (map_opt (sub.expr sub) e3) + sub.expr sub e1; sub.expr sub e2; + iter_opt (sub.expr sub) e3 | Pexp_sequence (e1, e2) -> - sequence ~loc ~attrs (sub.expr sub e1) (sub.expr sub e2) + sub.expr sub e1; sub.expr sub e2 | Pexp_while (e1, e2) -> - while_ ~loc ~attrs (sub.expr sub e1) (sub.expr sub e2) - | Pexp_for (p, e1, e2, d, e3) -> - for_ ~loc ~attrs (sub.pat sub p) (sub.expr sub e1) (sub.expr sub e2) d - (sub.expr sub e3) + sub.expr sub e1; sub.expr sub e2 + | Pexp_for (p, e1, e2, _d, e3) -> + sub.pat sub p; sub.expr sub e1; sub.expr sub e2; + sub.expr sub e3 | Pexp_coerce (e, t1, t2) -> - coerce ~loc ~attrs (sub.expr sub e) (map_opt (sub.typ sub) t1) - (sub.typ sub t2) + sub.expr sub e; iter_opt (sub.typ sub) t1; + sub.typ sub t2 | Pexp_constraint (e, t) -> - constraint_ ~loc ~attrs (sub.expr sub e) (sub.typ sub t) - | Pexp_send (e, s) -> - send ~loc ~attrs (sub.expr sub e) (map_loc sub s) - | Pexp_new lid -> new_ ~loc ~attrs (map_loc sub lid) + sub.expr sub e; sub.typ sub t + | Pexp_send (e, _s) -> sub.expr sub e + | Pexp_new lid -> iter_loc sub lid | Pexp_setinstvar (s, e) -> - setinstvar ~loc ~attrs (map_loc sub s) (sub.expr sub e) + iter_loc sub s; sub.expr sub e | Pexp_override sel -> - override ~loc ~attrs - (List.map (map_tuple (map_loc sub) (sub.expr sub)) sel) + List.iter (iter_tuple (iter_loc sub) (sub.expr sub)) sel | Pexp_letmodule (s, me, e) -> - letmodule ~loc ~attrs (map_loc sub s) (sub.module_expr sub me) - (sub.expr sub e) + iter_loc sub s; sub.module_expr sub me; + sub.expr sub e | Pexp_letexception (cd, e) -> - letexception ~loc ~attrs - (sub.extension_constructor sub cd) - (sub.expr sub e) - | Pexp_assert e -> assert_ ~loc ~attrs (sub.expr sub e) - | Pexp_lazy e -> lazy_ ~loc ~attrs (sub.expr sub e) + sub.extension_constructor sub cd; + sub.expr sub e + | Pexp_assert e -> sub.expr sub e + | Pexp_lazy e -> sub.expr sub e | Pexp_poly (e, t) -> - poly ~loc ~attrs (sub.expr sub e) (map_opt (sub.typ sub) t) - | Pexp_object cls -> object_ ~loc ~attrs (sub.class_structure sub cls) - | Pexp_newtype (s, e) -> - newtype ~loc ~attrs (map_loc sub s) (sub.expr sub e) - | Pexp_pack me -> pack ~loc ~attrs (sub.module_expr sub me) - | Pexp_open (ovf, lid, e) -> - open_ ~loc ~attrs ovf (map_loc sub lid) (sub.expr sub e) - | Pexp_extension x -> extension ~loc ~attrs (sub.extension sub x) - | Pexp_unreachable -> unreachable ~loc ~attrs () + sub.expr sub e; iter_opt (sub.typ sub) t + | Pexp_object cls -> sub.class_structure sub cls + | Pexp_newtype (_s, e) -> sub.expr sub e + | Pexp_pack me -> sub.module_expr sub me + | Pexp_open (_ovf, lid, e) -> + iter_loc sub lid; sub.expr sub e + | Pexp_extension x -> sub.extension sub x + | Pexp_unreachable -> () end module P = struct (* Patterns *) - let map sub {ppat_desc = desc; ppat_loc = loc; ppat_attributes = attrs} = - let open Pat in - let loc = sub.location sub loc in - let attrs = sub.attributes sub attrs in + let iter sub {ppat_desc = desc; ppat_loc = loc; ppat_attributes = attrs} = + sub.location sub loc; + sub.attributes sub attrs; match desc with - | Ppat_any -> any ~loc ~attrs () - | Ppat_var s -> var ~loc ~attrs (map_loc sub s) - | Ppat_alias (p, s) -> alias ~loc ~attrs (sub.pat sub p) (map_loc sub s) - | Ppat_constant c -> constant ~loc ~attrs c - | Ppat_interval (c1, c2) -> interval ~loc ~attrs c1 c2 - | Ppat_tuple pl -> tuple ~loc ~attrs (List.map (sub.pat sub) pl) + | Ppat_any -> () + | Ppat_var s -> iter_loc sub s + | Ppat_alias (p, s) -> sub.pat sub p; iter_loc sub s + | Ppat_constant _ -> () + | Ppat_interval _ -> () + | Ppat_tuple pl -> List.iter (sub.pat sub) pl | Ppat_construct (l, p) -> - construct ~loc ~attrs (map_loc sub l) (map_opt (sub.pat sub) p) - | Ppat_variant (l, p) -> variant ~loc ~attrs l (map_opt (sub.pat sub) p) - | Ppat_record (lpl, cf) -> - record ~loc ~attrs - (List.map (map_tuple (map_loc sub) (sub.pat sub)) lpl) cf - | Ppat_array pl -> array ~loc ~attrs (List.map (sub.pat sub) pl) - | Ppat_or (p1, p2) -> or_ ~loc ~attrs (sub.pat sub p1) (sub.pat sub p2) + iter_loc sub l; iter_opt (sub.pat sub) p + | Ppat_variant (_l, p) -> iter_opt (sub.pat sub) p + | Ppat_record (lpl, _cf) -> + List.iter (iter_tuple (iter_loc sub) (sub.pat sub)) lpl + | Ppat_array pl -> List.iter (sub.pat sub) pl + | Ppat_or (p1, p2) -> sub.pat sub p1; sub.pat sub p2 | Ppat_constraint (p, t) -> - constraint_ ~loc ~attrs (sub.pat sub p) (sub.typ sub t) - | Ppat_type s -> type_ ~loc ~attrs (map_loc sub s) - | Ppat_lazy p -> lazy_ ~loc ~attrs (sub.pat sub p) - | Ppat_unpack s -> unpack ~loc ~attrs (map_loc sub s) - | Ppat_open (lid,p) -> open_ ~loc ~attrs (map_loc sub lid) (sub.pat sub p) - | Ppat_exception p -> exception_ ~loc ~attrs (sub.pat sub p) - | Ppat_extension x -> extension ~loc ~attrs (sub.extension sub x) + sub.pat sub p; sub.typ sub t + | Ppat_type s -> iter_loc sub s + | Ppat_lazy p -> sub.pat sub p + | Ppat_unpack s -> iter_loc sub s + | Ppat_exception p -> sub.pat sub p + | Ppat_extension x -> sub.extension sub x + | Ppat_open (lid, p) -> + iter_loc sub lid; sub.pat sub p + end module CE = struct (* Value expressions for the class language *) - let map sub {pcl_loc = loc; pcl_desc = desc; pcl_attributes = attrs} = - let open Cl in - let loc = sub.location sub loc in - let attrs = sub.attributes sub attrs in + let iter sub {pcl_loc = loc; pcl_desc = desc; pcl_attributes = attrs} = + sub.location sub loc; + sub.attributes sub attrs; match desc with | Pcl_constr (lid, tys) -> - constr ~loc ~attrs (map_loc sub lid) (List.map (sub.typ sub) tys) + iter_loc sub lid; List.iter (sub.typ sub) tys | Pcl_structure s -> - structure ~loc ~attrs (sub.class_structure sub s) - | Pcl_fun (lab, e, p, ce) -> - fun_ ~loc ~attrs lab - (map_opt (sub.expr sub) e) - (sub.pat sub p) - (sub.class_expr sub ce) + sub.class_structure sub s + | Pcl_fun (_lab, e, p, ce) -> + iter_opt (sub.expr sub) e; + sub.pat sub p; + sub.class_expr sub ce | Pcl_apply (ce, l) -> - apply ~loc ~attrs (sub.class_expr sub ce) - (List.map (map_snd (sub.expr sub)) l) - | Pcl_let (r, vbs, ce) -> - let_ ~loc ~attrs r (List.map (sub.value_binding sub) vbs) - (sub.class_expr sub ce) + sub.class_expr sub ce; + List.iter (iter_snd (sub.expr sub)) l + | Pcl_let (_r, vbs, ce) -> + List.iter (sub.value_binding sub) vbs; + sub.class_expr sub ce | Pcl_constraint (ce, ct) -> - constraint_ ~loc ~attrs (sub.class_expr sub ce) (sub.class_type sub ct) - | Pcl_extension x -> extension ~loc ~attrs (sub.extension sub x) - | Pcl_open (ovf, lid, ce) -> - open_ ~loc ~attrs ovf (map_loc sub lid) (sub.class_expr sub ce) + sub.class_expr sub ce; sub.class_type sub ct + | Pcl_extension x -> sub.extension sub x + | Pcl_open (_ovf, lid, e) -> + iter_loc sub lid; sub.class_expr sub e - let map_kind sub = function - | Cfk_concrete (o, e) -> Cfk_concrete (o, sub.expr sub e) - | Cfk_virtual t -> Cfk_virtual (sub.typ sub t) + let iter_kind sub = function + | Cfk_concrete (_o, e) -> sub.expr sub e + | Cfk_virtual t -> sub.typ sub t - let map_field sub {pcf_desc = desc; pcf_loc = loc; pcf_attributes = attrs} = - let open Cf in - let loc = sub.location sub loc in - let attrs = sub.attributes sub attrs in + let iter_field sub {pcf_desc = desc; pcf_loc = loc; pcf_attributes = attrs} = + sub.location sub loc; + sub.attributes sub attrs; match desc with - | Pcf_inherit (o, ce, s) -> - inherit_ ~loc ~attrs o (sub.class_expr sub ce) - (map_opt (map_loc sub) s) - | Pcf_val (s, m, k) -> val_ ~loc ~attrs (map_loc sub s) m (map_kind sub k) - | Pcf_method (s, p, k) -> - method_ ~loc ~attrs (map_loc sub s) p (map_kind sub k) - | Pcf_constraint (t1, t2) -> - constraint_ ~loc ~attrs (sub.typ sub t1) (sub.typ sub t2) - | Pcf_initializer e -> initializer_ ~loc ~attrs (sub.expr sub e) - | Pcf_attribute x -> attribute ~loc (sub.attribute sub x) - | Pcf_extension x -> extension ~loc ~attrs (sub.extension sub x) - - let map_structure sub {pcstr_self; pcstr_fields} = - { - pcstr_self = sub.pat sub pcstr_self; - pcstr_fields = List.map (sub.class_field sub) pcstr_fields; - } - - let class_infos sub f {pci_virt; pci_params = pl; pci_name; pci_expr; - pci_loc; pci_attributes} = - Ci.mk - ~virt:pci_virt - ~params:(List.map (map_fst (sub.typ sub)) pl) - (map_loc sub pci_name) - (f pci_expr) - ~loc:(sub.location sub pci_loc) - ~attrs:(sub.attributes sub pci_attributes) -end - -(* Now, a generic AST mapper, to be extended to cover all kinds and - cases of the OCaml grammar. The default behavior of the mapper is - the identity. *) - -let default_mapper = - { - structure = (fun this l -> List.map (this.structure_item this) l); - structure_item = M.map_structure_item; - module_expr = M.map; - signature = (fun this l -> List.map (this.signature_item this) l); - signature_item = MT.map_signature_item; - module_type = MT.map; - with_constraint = MT.map_with_constraint; - class_declaration = - (fun this -> CE.class_infos this (this.class_expr this)); - class_expr = CE.map; - class_field = CE.map_field; - class_structure = CE.map_structure; - class_type = CT.map; - class_type_field = CT.map_field; - class_signature = CT.map_signature; - class_type_declaration = - (fun this -> CE.class_infos this (this.class_type this)); - class_description = - (fun this -> CE.class_infos this (this.class_type this)); - type_declaration = T.map_type_declaration; - type_kind = T.map_type_kind; - typ = T.map; - type_extension = T.map_type_extension; - extension_constructor = T.map_extension_constructor; - value_description = - (fun this {pval_name; pval_type; pval_prim; pval_loc; - pval_attributes} -> - Val.mk - (map_loc this pval_name) - (this.typ this pval_type) - ~attrs:(this.attributes this pval_attributes) - ~loc:(this.location this pval_loc) - ~prim:pval_prim - ); - - pat = P.map; - expr = E.map; - - module_declaration = - (fun this {pmd_name; pmd_type; pmd_attributes; pmd_loc} -> - Md.mk - (map_loc this pmd_name) - (this.module_type this pmd_type) - ~attrs:(this.attributes this pmd_attributes) - ~loc:(this.location this pmd_loc) - ); - - module_type_declaration = - (fun this {pmtd_name; pmtd_type; pmtd_attributes; pmtd_loc} -> - Mtd.mk - (map_loc this pmtd_name) - ?typ:(map_opt (this.module_type this) pmtd_type) - ~attrs:(this.attributes this pmtd_attributes) - ~loc:(this.location this pmtd_loc) - ); - - module_binding = - (fun this {pmb_name; pmb_expr; pmb_attributes; pmb_loc} -> - Mb.mk (map_loc this pmb_name) (this.module_expr this pmb_expr) - ~attrs:(this.attributes this pmb_attributes) - ~loc:(this.location this pmb_loc) - ); - - - open_description = - (fun this {popen_lid; popen_override; popen_attributes; popen_loc} -> - Opn.mk (map_loc this popen_lid) - ~override:popen_override - ~loc:(this.location this popen_loc) - ~attrs:(this.attributes this popen_attributes) - ); - - - include_description = - (fun this {pincl_mod; pincl_attributes; pincl_loc} -> - Incl.mk (this.module_type this pincl_mod) - ~loc:(this.location this pincl_loc) - ~attrs:(this.attributes this pincl_attributes) - ); - - include_declaration = - (fun this {pincl_mod; pincl_attributes; pincl_loc} -> - Incl.mk (this.module_expr this pincl_mod) - ~loc:(this.location this pincl_loc) - ~attrs:(this.attributes this pincl_attributes) - ); - - - value_binding = - (fun this {pvb_pat; pvb_expr; pvb_attributes; pvb_loc} -> - Vb.mk - (this.pat this pvb_pat) - (this.expr this pvb_expr) - ~loc:(this.location this pvb_loc) - ~attrs:(this.attributes this pvb_attributes) - ); - - - constructor_declaration = - (fun this {pcd_name; pcd_args; pcd_res; pcd_loc; pcd_attributes} -> - Type.constructor - (map_loc this pcd_name) - ~args:(T.map_constructor_arguments this pcd_args) - ?res:(map_opt (this.typ this) pcd_res) - ~loc:(this.location this pcd_loc) - ~attrs:(this.attributes this pcd_attributes) - ); - - label_declaration = - (fun this {pld_name; pld_type; pld_loc; pld_mutable; pld_attributes} -> - Type.field - (map_loc this pld_name) - (this.typ this pld_type) - ~mut:pld_mutable - ~loc:(this.location this pld_loc) - ~attrs:(this.attributes this pld_attributes) - ); - - cases = (fun this l -> List.map (this.case this) l); - case = - (fun this {pc_lhs; pc_guard; pc_rhs} -> - { - pc_lhs = this.pat this pc_lhs; - pc_guard = map_opt (this.expr this) pc_guard; - pc_rhs = this.expr this pc_rhs; - } - ); - - - - location = (fun _this l -> l); - - extension = (fun this (s, e) -> (map_loc this s, this.payload this e)); - attribute = (fun this (s, e) -> (map_loc this s, this.payload this e)); - attributes = (fun this l -> List.map (this.attribute this) l); - payload = - (fun this -> function - | PStr x -> PStr (this.structure this x) - | PSig x -> PSig (this.signature this x) - | PTyp x -> PTyp (this.typ this x) - | PPat (x, g) -> PPat (this.pat this x, map_opt (this.expr this) g) - ); - } - -let rec extension_of_error {loc; msg; if_highlight; sub} = - { loc; txt = "ocaml.error" }, - PStr ([Str.eval (Exp.constant (Pconst_string (msg, None))); - Str.eval (Exp.constant (Pconst_string (if_highlight, None)))] @ - (List.map (fun ext -> Str.extension (extension_of_error ext)) sub)) - -let attribute_of_warning loc s = - { loc; txt = "ocaml.ppwarning" }, - PStr ([Str.eval ~loc (Exp.constant (Pconst_string (s, None)))]) - -module StringMap = Map.Make(struct - type t = string - let compare = compare -end) - -let cookies = ref StringMap.empty - -let get_cookie k = - try Some (StringMap.find k !cookies) - with Not_found -> None - -let set_cookie k v = - cookies := StringMap.add k v !cookies - -let tool_name_ref = ref "_none_" - -let tool_name () = !tool_name_ref - - -module PpxContext = struct - open Longident - open Asttypes - open Ast_helper - - let lid name = { txt = Lident name; loc = Location.none } - - let make_string x = Exp.constant (Pconst_string (x, None)) - - let make_bool x = - if x - then Exp.construct (lid "true") None - else Exp.construct (lid "false") None - - let rec make_list f lst = - match lst with - | x :: rest -> - Exp.construct (lid "::") (Some (Exp.tuple [f x; make_list f rest])) - | [] -> - Exp.construct (lid "[]") None - - let make_pair f1 f2 (x1, x2) = - Exp.tuple [f1 x1; f2 x2] - - let make_option f opt = - match opt with - | Some x -> Exp.construct (lid "Some") (Some (f x)) - | None -> Exp.construct (lid "None") None - - let get_cookies () = - lid "cookies", - make_list (make_pair make_string (fun x -> x)) - (StringMap.bindings !cookies) - - let mk fields = - { txt = "ocaml.ppx.context"; loc = Location.none }, - Parsetree.PStr [Str.eval (Exp.record fields None)] - - let make ~tool_name () = - let fields = - [ - lid "tool_name", make_string tool_name; - lid "include_dirs", make_list make_string !Clflags.include_dirs; - lid "load_path", make_list make_string !Config.load_path; - lid "open_modules", make_list make_string !Clflags.open_modules; - lid "for_package", make_option make_string !Clflags.for_package; - lid "debug", make_bool !Clflags.debug; - lid "use_threads", make_bool !Clflags.use_threads; - lid "use_vmthreads", make_bool !Clflags.use_vmthreads; - get_cookies () - ] - in - mk fields - - let get_fields = function - | PStr [{pstr_desc = Pstr_eval - ({ pexp_desc = Pexp_record (fields, None) }, [])}] -> - fields - | _ -> - raise_errorf "Internal error: invalid [@@@ocaml.ppx.context] syntax" - - let restore fields = - let field name payload = - let rec get_string = function - | { pexp_desc = Pexp_constant (Pconst_string (str, None)) } -> str - | _ -> raise_errorf "Internal error: invalid [@@@ocaml.ppx.context \ - { %s }] string syntax" name - and get_bool pexp = - match pexp with - | {pexp_desc = Pexp_construct ({txt = Longident.Lident "true"}, - None)} -> - true - | {pexp_desc = Pexp_construct ({txt = Longident.Lident "false"}, - None)} -> - false - | _ -> raise_errorf "Internal error: invalid [@@@ocaml.ppx.context \ - { %s }] bool syntax" name - and get_list elem = function - | {pexp_desc = - Pexp_construct ({txt = Longident.Lident "::"}, - Some {pexp_desc = Pexp_tuple [exp; rest]}) } -> - elem exp :: get_list elem rest - | {pexp_desc = - Pexp_construct ({txt = Longident.Lident "[]"}, None)} -> - [] - | _ -> raise_errorf "Internal error: invalid [@@@ocaml.ppx.context \ - { %s }] list syntax" name - and get_pair f1 f2 = function - | {pexp_desc = Pexp_tuple [e1; e2]} -> - (f1 e1, f2 e2) - | _ -> raise_errorf "Internal error: invalid [@@@ocaml.ppx.context \ - { %s }] pair syntax" name - and get_option elem = function - | { pexp_desc = - Pexp_construct ({ txt = Longident.Lident "Some" }, Some exp) } -> - Some (elem exp) - | { pexp_desc = - Pexp_construct ({ txt = Longident.Lident "None" }, None) } -> - None - | _ -> raise_errorf "Internal error: invalid [@@@ocaml.ppx.context \ - { %s }] option syntax" name - in - match name with - | "tool_name" -> - tool_name_ref := get_string payload - | "include_dirs" -> - Clflags.include_dirs := get_list get_string payload - | "load_path" -> - Config.load_path := get_list get_string payload - | "open_modules" -> - Clflags.open_modules := get_list get_string payload - | "for_package" -> - Clflags.for_package := get_option get_string payload - | "debug" -> - Clflags.debug := get_bool payload - | "use_threads" -> - Clflags.use_threads := get_bool payload - | "use_vmthreads" -> - Clflags.use_vmthreads := get_bool payload - | "cookies" -> - let l = get_list (get_pair get_string (fun x -> x)) payload in - cookies := - List.fold_left - (fun s (k, v) -> StringMap.add k v s) StringMap.empty - l - | _ -> - () - in - List.iter (function ({txt=Lident name}, x) -> field name x | _ -> ()) fields + | Pcf_inherit (_o, ce, _s) -> sub.class_expr sub ce + | Pcf_val (s, _m, k) -> iter_loc sub s; iter_kind sub k + | Pcf_method (s, _p, k) -> + iter_loc sub s; iter_kind sub k + | Pcf_constraint (t1, t2) -> + sub.typ sub t1; sub.typ sub t2 + | Pcf_initializer e -> sub.expr sub e + | Pcf_attribute x -> sub.attribute sub x + | Pcf_extension x -> sub.extension sub x - let update_cookies fields = - let fields = - List.filter - (function ({txt=Lident "cookies"}, _) -> false | _ -> true) - fields - in - fields @ [get_cookies ()] + let iter_structure sub {pcstr_self; pcstr_fields} = + sub.pat sub pcstr_self; + List.iter (sub.class_field sub) pcstr_fields + + let class_infos sub f {pci_virt = _; pci_params = pl; pci_name; pci_expr; + pci_loc; pci_attributes} = + List.iter (iter_fst (sub.typ sub)) pl; + iter_loc sub pci_name; + f pci_expr; + sub.location sub pci_loc; + sub.attributes sub pci_attributes end -let ppx_context = PpxContext.make +(* Now, a generic AST mapper, to be extended to cover all kinds and + cases of the OCaml grammar. The default behavior of the mapper is + the identity. *) -let extension_of_exn exn = - match error_of_exn exn with - | Some (`Ok error) -> extension_of_error error - | Some `Already_displayed -> { loc = Location.none; txt = "ocaml.error" }, PStr [] - | None -> raise exn +let default_iterator = + { + structure = (fun this l -> List.iter (this.structure_item this) l); + structure_item = M.iter_structure_item; + module_expr = M.iter; + signature = (fun this l -> List.iter (this.signature_item this) l); + signature_item = MT.iter_signature_item; + module_type = MT.iter; + with_constraint = MT.iter_with_constraint; + class_declaration = + (fun this -> CE.class_infos this (this.class_expr this)); + class_expr = CE.iter; + class_field = CE.iter_field; + class_structure = CE.iter_structure; + class_type = CT.iter; + class_type_field = CT.iter_field; + class_signature = CT.iter_signature; + class_type_declaration = + (fun this -> CE.class_infos this (this.class_type this)); + class_description = + (fun this -> CE.class_infos this (this.class_type this)); + type_declaration = T.iter_type_declaration; + type_kind = T.iter_type_kind; + typ = T.iter; + type_extension = T.iter_type_extension; + extension_constructor = T.iter_extension_constructor; + value_description = + (fun this {pval_name; pval_type; pval_prim = _; pval_loc; + pval_attributes} -> + iter_loc this pval_name; + this.typ this pval_type; + this.attributes this pval_attributes; + this.location this pval_loc + ); + pat = P.iter; + expr = E.iter; -let apply_lazy ~source ~target mapper = - let implem ast = - let fields, ast = - match ast with - | {pstr_desc = Pstr_attribute ({txt = "ocaml.ppx.context"}, x)} :: l -> - PpxContext.get_fields x, l - | _ -> [], ast - in - PpxContext.restore fields; - let ast = - try - let mapper = mapper () in - mapper.structure mapper ast - with exn -> - [{pstr_desc = Pstr_extension (extension_of_exn exn, []); - pstr_loc = Location.none}] - in - let fields = PpxContext.update_cookies fields in - Str.attribute (PpxContext.mk fields) :: ast - in - let iface ast = - let fields, ast = - match ast with - | {psig_desc = Psig_attribute ({txt = "ocaml.ppx.context"}, x)} :: l -> - PpxContext.get_fields x, l - | _ -> [], ast - in - PpxContext.restore fields; - let ast = - try - let mapper = mapper () in - mapper.signature mapper ast - with exn -> - [{psig_desc = Psig_extension (extension_of_exn exn, []); - psig_loc = Location.none}] - in - let fields = PpxContext.update_cookies fields in - Sig.attribute (PpxContext.mk fields) :: ast - in + module_declaration = + (fun this {pmd_name; pmd_type; pmd_attributes; pmd_loc} -> + iter_loc this pmd_name; + this.module_type this pmd_type; + this.attributes this pmd_attributes; + this.location this pmd_loc + ); - let ic = open_in_bin source in - let magic = - really_input_string ic (String.length Config.ast_impl_magic_number) - in + module_type_declaration = + (fun this {pmtd_name; pmtd_type; pmtd_attributes; pmtd_loc} -> + iter_loc this pmtd_name; + iter_opt (this.module_type this) pmtd_type; + this.attributes this pmtd_attributes; + this.location this pmtd_loc + ); - let rewrite transform = - Location.set_input_name @@ input_value ic; - let ast = input_value ic in - close_in ic; - let ast = transform ast in - let oc = open_out_bin target in - output_string oc magic; - output_value oc !Location.input_name; - output_value oc ast; - close_out oc - and fail () = - close_in ic; - failwith "Ast_mapper: OCaml version mismatch or malformed input"; - in + module_binding = + (fun this {pmb_name; pmb_expr; pmb_attributes; pmb_loc} -> + iter_loc this pmb_name; this.module_expr this pmb_expr; + this.attributes this pmb_attributes; + this.location this pmb_loc + ); - if magic = Config.ast_impl_magic_number then - rewrite (implem : structure -> structure) - else if magic = Config.ast_intf_magic_number then - rewrite (iface : signature -> signature) - else fail () -let drop_ppx_context_str ~restore = function - | {pstr_desc = Pstr_attribute({Location.txt = "ocaml.ppx.context"}, a)} - :: items -> - if restore then - PpxContext.restore (PpxContext.get_fields a); - items - | items -> items + open_description = + (fun this {popen_lid; popen_override = _; popen_attributes; popen_loc} -> + iter_loc this popen_lid; + this.location this popen_loc; + this.attributes this popen_attributes + ); -let drop_ppx_context_sig ~restore = function - | {psig_desc = Psig_attribute({Location.txt = "ocaml.ppx.context"}, a)} - :: items -> - if restore then - PpxContext.restore (PpxContext.get_fields a); - items - | items -> items -let add_ppx_context_str ~tool_name ast = - Ast_helper.Str.attribute (ppx_context ~tool_name ()) :: ast + include_description = + (fun this {pincl_mod; pincl_attributes; pincl_loc} -> + this.module_type this pincl_mod; + this.location this pincl_loc; + this.attributes this pincl_attributes + ); -let add_ppx_context_sig ~tool_name ast = - Ast_helper.Sig.attribute (ppx_context ~tool_name ()) :: ast + include_declaration = + (fun this {pincl_mod; pincl_attributes; pincl_loc} -> + this.module_expr this pincl_mod; + this.location this pincl_loc; + this.attributes this pincl_attributes + ); -let apply ~source ~target mapper = - apply_lazy ~source ~target (fun () -> mapper) + value_binding = + (fun this {pvb_pat; pvb_expr; pvb_attributes; pvb_loc} -> + this.pat this pvb_pat; + this.expr this pvb_expr; + this.location this pvb_loc; + this.attributes this pvb_attributes + ); -let run_main mapper = - try - let a = Sys.argv in - let n = Array.length a in - if n > 2 then - let mapper () = - try mapper (Array.to_list (Array.sub a 1 (n - 3))) - with exn -> - (* PR#6463 *) - let f _ _ = raise exn in - {default_mapper with structure = f; signature = f} - in - apply_lazy ~source:a.(n - 2) ~target:a.(n - 1) mapper - else begin - Printf.eprintf "Usage: %s [extra_args] \n%!" - Sys.executable_name; - exit 2 - end - with exn -> - prerr_endline (Printexc.to_string exn); - exit 2 -let register_function = ref (fun _name f -> run_main f) -let register name f = !register_function name f + constructor_declaration = + (fun this {pcd_name; pcd_args; pcd_res; pcd_loc; pcd_attributes} -> + iter_loc this pcd_name; + T.iter_constructor_arguments this pcd_args; + iter_opt (this.typ this) pcd_res; + this.location this pcd_loc; + this.attributes this pcd_attributes + ); + + label_declaration = + (fun this {pld_name; pld_type; pld_loc; pld_mutable = _; pld_attributes}-> + iter_loc this pld_name; + this.typ this pld_type; + this.location this pld_loc; + this.attributes this pld_attributes + ); + + cases = (fun this l -> List.iter (this.case this) l); + case = + (fun this {pc_lhs; pc_guard; pc_rhs} -> + this.pat this pc_lhs; + iter_opt (this.expr this) pc_guard; + this.expr this pc_rhs + ); + + location = (fun _this _l -> ()); + + extension = (fun this (s, e) -> iter_loc this s; this.payload this e); + attribute = (fun this (s, e) -> iter_loc this s; this.payload this e); + attributes = (fun this l -> List.iter (this.attribute this) l); + payload = + (fun this -> function + | PStr x -> this.structure this x + | PSig x -> this.signature this x + | PTyp x -> this.typ this x + | PPat (x, g) -> this.pat this x; iter_opt (this.expr this) g + ); + } end -module Pparse : sig -#1 "pparse.mli" +module Ast_invariants : sig +#1 "ast_invariants.mli" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Daniel de Rauglaudre, projet Cristal, INRIA Rocquencourt *) +(* Jeremie Dimino, Jane Street Europe *) (* *) -(* Copyright 2002 Institut National de Recherche en Informatique et *) -(* en Automatique. *) +(* Copyright 2015 Jane Street Group LLC *) (* *) (* All rights reserved. This file is distributed under the terms of *) (* the GNU Lesser General Public License version 2.1, with the *) @@ -29031,66 +29260,20 @@ module Pparse : sig (* *) (**************************************************************************) -(** Driver for the parser, external preprocessors and ast plugin hooks *) - -open Format - -type error = - | CannotRun of string - | WrongMagic of string - -exception Error of error - -val preprocess : string -> string -val remove_preprocessed : string -> unit - -type 'a ast_kind = -| Structure : Parsetree.structure ast_kind -| Signature : Parsetree.signature ast_kind - -val read_ast : 'a ast_kind -> string -> 'a -val write_ast : 'a ast_kind -> string -> 'a -> unit - -val file : formatter -> tool_name:string -> string -> - (Lexing.lexbuf -> 'a) -> 'a ast_kind -> 'a - -val apply_rewriters: ?restore:bool -> tool_name:string -> - 'a ast_kind -> 'a -> 'a - (** If [restore = true] (the default), cookies set by external - rewriters will be kept for later calls. *) - -val apply_rewriters_str: - ?restore:bool -> tool_name:string -> Parsetree.structure -> - Parsetree.structure -val apply_rewriters_sig: - ?restore:bool -> tool_name:string -> Parsetree.signature -> - Parsetree.signature - -val report_error : formatter -> error -> unit - - -val parse_implementation: - formatter -> tool_name:string -> string -> Parsetree.structure -val parse_interface: - formatter -> tool_name:string -> string -> Parsetree.signature - -(* [call_external_preprocessor sourcefile pp] *) -val call_external_preprocessor : string -> string -> string -val open_and_check_magic : string -> string -> in_channel * bool +(** Check AST invariants *) -module ImplementationHooks : Misc.HookSig with type t = Parsetree.structure -module InterfaceHooks : Misc.HookSig with type t = Parsetree.signature +val structure : Parsetree.structure -> unit +val signature : Parsetree.signature -> unit end = struct -#1 "pparse.ml" +#1 "ast_invariants.ml" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Daniel de Rauglaudre, projet Cristal, INRIA Rocquencourt *) +(* Jeremie Dimino, Jane Street Europe *) (* *) -(* Copyright 2002 Institut National de Recherche en Informatique et *) -(* en Automatique. *) +(* Copyright 2015 Jane Street Group LLC *) (* *) (* All rights reserved. This file is distributed under the terms of *) (* the GNU Lesser General Public License version 2.1, with the *) @@ -29098,1329 +29281,1619 @@ end = struct (* *) (**************************************************************************) -open Format - -type error = - | CannotRun of string - | WrongMagic of string - -exception Error of error - -(* Optionally preprocess a source file *) - -let call_external_preprocessor sourcefile pp = - let tmpfile = Filename.temp_file "ocamlpp" "" in - let comm = Printf.sprintf "%s %s > %s" - pp (Filename.quote sourcefile) tmpfile - in - if Ccomp.command comm <> 0 then begin - Misc.remove_file tmpfile; - raise (Error (CannotRun comm)); - end; - tmpfile - -let preprocess sourcefile = - match !Clflags.preprocessor with - None -> sourcefile - | Some pp -> - Profile.record "-pp" - (call_external_preprocessor sourcefile) pp - - -let remove_preprocessed inputfile = - match !Clflags.preprocessor with - None -> () - | Some _ -> Misc.remove_file inputfile - -type 'a ast_kind = -| Structure : Parsetree.structure ast_kind -| Signature : Parsetree.signature ast_kind - -let magic_of_kind : type a . a ast_kind -> string = function - | Structure -> Config.ast_impl_magic_number - | Signature -> Config.ast_intf_magic_number +open Asttypes +open Parsetree +open Ast_iterator -(* Note: some of the functions here should go to Ast_mapper instead, - which would encapsulate the "binary AST" protocol. *) +let err = Syntaxerr.ill_formed_ast -let write_ast (type a) (kind : a ast_kind) fn (ast : a) = - let oc = open_out_bin fn in - output_string oc (magic_of_kind kind); - output_value oc (!Location.input_name : string); - output_value oc (ast : a); - close_out oc +let empty_record loc = err loc "Records cannot be empty." +let empty_variant loc = err loc "Variant types cannot be empty." +let invalid_tuple loc = err loc "Tuples must have at least 2 components." +let no_args loc = err loc "Function application with no argument." +let empty_let loc = err loc "Let with no bindings." +let empty_type loc = err loc "Type declarations cannot be empty." +let complex_id loc = err loc "Functor application not allowed here." -let apply_rewriter kind fn_in ppx = - let magic = magic_of_kind kind in - let fn_out = Filename.temp_file "camlppx" "" in - let comm = - Printf.sprintf "%s %s %s" ppx (Filename.quote fn_in) (Filename.quote fn_out) +let simple_longident id = + let rec is_simple = function + | Longident.Lident _ -> true + | Longident.Ldot (id, _) -> is_simple id + | Longident.Lapply _ -> false in - let ok = Ccomp.command comm = 0 in - Misc.remove_file fn_in; - if not ok then begin - Misc.remove_file fn_out; - raise (Error (CannotRun comm)); - end; - if not (Sys.file_exists fn_out) then - raise (Error (WrongMagic comm)); - (* check magic before passing to the next ppx *) - let ic = open_in_bin fn_out in - let buffer = - try really_input_string ic (String.length magic) with End_of_file -> "" in - close_in ic; - if buffer <> magic then begin - Misc.remove_file fn_out; - raise (Error (WrongMagic comm)); - end; - fn_out - -let read_ast (type a) (kind : a ast_kind) fn : a = - let ic = open_in_bin fn in - try - let magic = magic_of_kind kind in - let buffer = really_input_string ic (String.length magic) in - assert(buffer = magic); (* already checked by apply_rewriter *) - Location.set_input_name @@ (input_value ic : string); - let ast = (input_value ic : a) in - close_in ic; - Misc.remove_file fn; - ast - with exn -> - close_in ic; - Misc.remove_file fn; - raise exn - -let rewrite kind ppxs ast = - let fn = Filename.temp_file "camlppx" "" in - write_ast kind fn ast; - let fn = List.fold_left (apply_rewriter kind) fn (List.rev ppxs) in - read_ast kind fn + if not (is_simple id.txt) then complex_id id.loc -let apply_rewriters_str ?(restore = true) ~tool_name ast = - match !Clflags.all_ppx with - | [] -> ast - | ppxs -> - ast - |> Ast_mapper.add_ppx_context_str ~tool_name - |> rewrite Structure ppxs - |> Ast_mapper.drop_ppx_context_str ~restore +let iterator = + let super = Ast_iterator.default_iterator in + let type_declaration self td = + super.type_declaration self td; + let loc = td.ptype_loc in + match td.ptype_kind with + | Ptype_record [] -> empty_record loc + | Ptype_variant [] -> empty_variant loc + | _ -> () + in + let typ self ty = + super.typ self ty; + let loc = ty.ptyp_loc in + match ty.ptyp_desc with + | Ptyp_tuple ([] | [_]) -> invalid_tuple loc + | Ptyp_class (id, _) -> simple_longident id + | Ptyp_package (_, cstrs) -> + List.iter (fun (id, _) -> simple_longident id) cstrs + | _ -> () + in + let pat self pat = + begin match pat.ppat_desc with + | Ppat_construct (_, Some ({ppat_desc = Ppat_tuple _} as p)) + when Builtin_attributes.explicit_arity pat.ppat_attributes -> + super.pat self p (* allow unary tuple, see GPR#523. *) + | _ -> + super.pat self pat + end; + let loc = pat.ppat_loc in + match pat.ppat_desc with + | Ppat_tuple ([] | [_]) -> invalid_tuple loc + | Ppat_record ([], _) -> empty_record loc + | Ppat_construct (id, _) -> simple_longident id + | Ppat_record (fields, _) -> + List.iter (fun (id, _) -> simple_longident id) fields + | _ -> () + in + let expr self exp = + begin match exp.pexp_desc with + | Pexp_construct (_, Some ({pexp_desc = Pexp_tuple _} as e)) + when Builtin_attributes.explicit_arity exp.pexp_attributes -> + super.expr self e (* allow unary tuple, see GPR#523. *) + | _ -> + super.expr self exp + end; + let loc = exp.pexp_loc in + match exp.pexp_desc with + | Pexp_tuple ([] | [_]) -> invalid_tuple loc + | Pexp_record ([], _) -> empty_record loc + | Pexp_apply (_, []) -> no_args loc + | Pexp_let (_, [], _) -> empty_let loc + | Pexp_ident id + | Pexp_construct (id, _) + | Pexp_field (_, id) + | Pexp_setfield (_, id, _) + | Pexp_new id + | Pexp_open (_, id, _) -> simple_longident id + | Pexp_record (fields, _) -> + List.iter (fun (id, _) -> simple_longident id) fields + | _ -> () + in + let extension_constructor self ec = + super.extension_constructor self ec; + match ec.pext_kind with + | Pext_rebind id -> simple_longident id + | _ -> () + in + let class_expr self ce = + super.class_expr self ce; + let loc = ce.pcl_loc in + match ce.pcl_desc with + | Pcl_apply (_, []) -> no_args loc + | Pcl_constr (id, _) -> simple_longident id + | _ -> () + in + let module_type self mty = + super.module_type self mty; + match mty.pmty_desc with + | Pmty_alias id -> simple_longident id + | _ -> () + in + let open_description self opn = + super.open_description self opn; + simple_longident opn.popen_lid + in + let with_constraint self wc = + super.with_constraint self wc; + match wc with + | Pwith_type (id, _) + | Pwith_module (id, _) -> simple_longident id + | _ -> () + in + let module_expr self me = + super.module_expr self me; + match me.pmod_desc with + | Pmod_ident id -> simple_longident id + | _ -> () + in + let structure_item self st = + super.structure_item self st; + let loc = st.pstr_loc in + match st.pstr_desc with + | Pstr_type (_, []) -> empty_type loc + | Pstr_value (_, []) -> empty_let loc + | _ -> () + in + let signature_item self sg = + super.signature_item self sg; + let loc = sg.psig_loc in + match sg.psig_desc with + | Psig_type (_, []) -> empty_type loc + | _ -> () + in + { super with + type_declaration + ; typ + ; pat + ; expr + ; extension_constructor + ; class_expr + ; module_expr + ; module_type + ; open_description + ; with_constraint + ; structure_item + ; signature_item + } -let apply_rewriters_sig ?(restore = true) ~tool_name ast = - match !Clflags.all_ppx with - | [] -> ast - | ppxs -> - ast - |> Ast_mapper.add_ppx_context_sig ~tool_name - |> rewrite Signature ppxs - |> Ast_mapper.drop_ppx_context_sig ~restore +let structure st = iterator.structure iterator st +let signature sg = iterator.signature iterator sg -let apply_rewriters ?restore ~tool_name - (type a) (kind : a ast_kind) (ast : a) : a = - match kind with - | Structure -> - apply_rewriters_str ?restore ~tool_name ast - | Signature -> - apply_rewriters_sig ?restore ~tool_name ast +end +module Ast_mapper : sig +#1 "ast_mapper.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Alain Frisch, LexiFi *) +(* *) +(* Copyright 2012 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -(* Parse a file or get a dumped syntax tree from it *) +(** The interface of a -ppx rewriter -exception Outdated_version + A -ppx rewriter is a program that accepts a serialized abstract syntax + tree and outputs another, possibly modified, abstract syntax tree. + This module encapsulates the interface between the compiler and + the -ppx rewriters, handling such details as the serialization format, + forwarding of command-line flags, and storing state. -let open_and_check_magic inputfile ast_magic = - let ic = open_in_bin inputfile in - let is_ast_file = - try - let buffer = really_input_string ic (String.length ast_magic) in - if buffer = ast_magic then true - else if String.sub buffer 0 9 = String.sub ast_magic 0 9 then - raise Outdated_version - else false - with - Outdated_version -> - Misc.fatal_error "OCaml and preprocessor have incompatible versions" - | _ -> false - in - (ic, is_ast_file) + {!mapper} allows to implement AST rewriting using open recursion. + A typical mapper would be based on {!default_mapper}, a deep + identity mapper, and will fall back on it for handling the syntax it + does not modify. For example: -let parse (type a) (kind : a ast_kind) lexbuf : a = - match kind with - | Structure -> Parse.implementation lexbuf - | Signature -> Parse.interface lexbuf + {[ +open Asttypes +open Parsetree +open Ast_mapper -let file_aux ppf ~tool_name inputfile (type a) parse_fun invariant_fun - (kind : a ast_kind) = - let ast_magic = magic_of_kind kind in - let (ic, is_ast_file) = open_and_check_magic inputfile ast_magic in - let ast = - try - if is_ast_file then begin - if !Clflags.fast then - (* FIXME make this a proper warning *) - fprintf ppf "@[Warning: %s@]@." - "option -unsafe used with a preprocessor returning a syntax tree"; - Location.set_input_name @@ (input_value ic : string); - (input_value ic : a) - end else begin - seek_in ic 0; - let lexbuf = Lexing.from_channel ic in - Location.init lexbuf inputfile; - Profile.record_call "parser" (fun () -> parse_fun lexbuf) - end - with x -> close_in ic; raise x - in - close_in ic; - let ast = - Profile.record_call "-ppx" (fun () -> - apply_rewriters ~restore:false ~tool_name kind ast) in - if is_ast_file || !Clflags.all_ppx <> [] then invariant_fun ast; - ast +let test_mapper argv = + { default_mapper with + expr = fun mapper expr -> + match expr with + | { pexp_desc = Pexp_extension ({ txt = "test" }, PStr [])} -> + Ast_helper.Exp.constant (Const_int 42) + | other -> default_mapper.expr mapper other; } -let file ppf ~tool_name inputfile parse_fun ast_kind = - file_aux ppf ~tool_name inputfile parse_fun ignore ast_kind +let () = + register "ppx_test" test_mapper]} -let report_error ppf = function - | CannotRun cmd -> - fprintf ppf "Error while running external preprocessor@.\ - Command line: %s@." cmd - | WrongMagic cmd -> - fprintf ppf "External preprocessor does not produce a valid file@.\ - Command line: %s@." cmd + This -ppx rewriter, which replaces [[%test]] in expressions with + the constant [42], can be compiled using + [ocamlc -o ppx_test -I +compiler-libs ocamlcommon.cma ppx_test.ml]. -let () = - Location.register_error_of_exn - (function - | Error err -> Some (Location.error_of_printer_file report_error err) - | _ -> None - ) + *) -let parse_file ~tool_name invariant_fun apply_hooks kind ppf sourcefile = - Location.set_input_name sourcefile; - let inputfile = preprocess sourcefile in - let ast = - try file_aux ppf ~tool_name inputfile (parse kind) invariant_fun kind - with exn -> - remove_preprocessed inputfile; - raise exn - in - remove_preprocessed inputfile; - let ast = apply_hooks { Misc.sourcefile } ast in - ast +open Parsetree -module ImplementationHooks = Misc.MakeHooks(struct - type t = Parsetree.structure - end) -module InterfaceHooks = Misc.MakeHooks(struct - type t = Parsetree.signature - end) +(** {1 A generic Parsetree mapper} *) -let parse_implementation ppf ~tool_name sourcefile = - Profile.record_call "parsing" (fun () -> - parse_file ~tool_name Ast_invariants.structure - ImplementationHooks.apply_hooks Structure ppf sourcefile) -let parse_interface ppf ~tool_name sourcefile = - Profile.record_call "parsing" (fun () -> - parse_file ~tool_name Ast_invariants.signature - InterfaceHooks.apply_hooks Signature ppf sourcefile) +type mapper = { + attribute: mapper -> attribute -> attribute; + attributes: mapper -> attribute list -> attribute list; + case: mapper -> case -> case; + cases: mapper -> case list -> case list; + class_declaration: mapper -> class_declaration -> class_declaration; + class_description: mapper -> class_description -> class_description; + class_expr: mapper -> class_expr -> class_expr; + class_field: mapper -> class_field -> class_field; + class_signature: mapper -> class_signature -> class_signature; + class_structure: mapper -> class_structure -> class_structure; + class_type: mapper -> class_type -> class_type; + class_type_declaration: mapper -> class_type_declaration + -> class_type_declaration; + class_type_field: mapper -> class_type_field -> class_type_field; + constructor_declaration: mapper -> constructor_declaration + -> constructor_declaration; + expr: mapper -> expression -> expression; + extension: mapper -> extension -> extension; + extension_constructor: mapper -> extension_constructor + -> extension_constructor; + include_declaration: mapper -> include_declaration -> include_declaration; + include_description: mapper -> include_description -> include_description; + label_declaration: mapper -> label_declaration -> label_declaration; + location: mapper -> Location.t -> Location.t; + module_binding: mapper -> module_binding -> module_binding; + module_declaration: mapper -> module_declaration -> module_declaration; + module_expr: mapper -> module_expr -> module_expr; + module_type: mapper -> module_type -> module_type; + module_type_declaration: mapper -> module_type_declaration + -> module_type_declaration; + open_description: mapper -> open_description -> open_description; + pat: mapper -> pattern -> pattern; + payload: mapper -> payload -> payload; + signature: mapper -> signature -> signature; + signature_item: mapper -> signature_item -> signature_item; + structure: mapper -> structure -> structure; + structure_item: mapper -> structure_item -> structure_item; + typ: mapper -> core_type -> core_type; + type_declaration: mapper -> type_declaration -> type_declaration; + type_extension: mapper -> type_extension -> type_extension; + type_kind: mapper -> type_kind -> type_kind; + value_binding: mapper -> value_binding -> value_binding; + value_description: mapper -> value_description -> value_description; + with_constraint: mapper -> with_constraint -> with_constraint; +} +(** A mapper record implements one "method" per syntactic category, + using an open recursion style: each method takes as its first + argument the mapper to be applied to children in the syntax + tree. *) -end -module Ext_list : sig -#1 "ext_list.mli" -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +val default_mapper: mapper +(** A default mapper, which implements a "deep identity" mapping. *) +(** {1 Apply mappers to compilation units} *) -val map : - 'a list -> - ('a -> 'b) -> - 'b list +val tool_name: unit -> string +(** Can be used within a ppx preprocessor to know which tool is + calling it ["ocamlc"], ["ocamlopt"], ["ocamldoc"], ["ocamldep"], + ["ocaml"], ... Some global variables that reflect command-line + options are automatically synchronized between the calling tool + and the ppx preprocessor: {!Clflags.include_dirs}, + {!Config.load_path}, {!Clflags.open_modules}, {!Clflags.for_package}, + {!Clflags.debug}. *) -val map_combine : - 'a list -> - 'b list -> - ('a -> 'c) -> - ('c * 'b) list - -val has_string : - string list -> - string -> - bool +val apply: source:string -> target:string -> mapper -> unit +(** Apply a mapper (parametrized by the unit name) to a dumped + parsetree found in the [source] file and put the result in the + [target] file. The [structure] or [signature] field of the mapper + is applied to the implementation or interface. *) -val map_split_opt : - 'a list -> - ('a -> 'b option * 'c option) -> - 'b list * 'c list +val run_main: (string list -> mapper) -> unit +(** Entry point to call to implement a standalone -ppx rewriter from a + mapper, parametrized by the command line arguments. The current + unit name can be obtained from {!Location.input_name}. This + function implements proper error reporting for uncaught + exceptions. *) -val mapi : - 'a list -> - (int -> 'a -> 'b) -> - 'b list - -val map_snd : ('a * 'b) list -> ('b -> 'c) -> ('a * 'c) list +(** {1 Registration API} *) -(** [map_last f xs ] - will pass [true] to [f] for the last element, - [false] otherwise. - For empty list, it returns empty -*) -val map_last : - 'a list -> - (bool -> 'a -> 'b) -> 'b list +val register_function: (string -> (string list -> mapper) -> unit) ref -(** [last l] - return the last element - raise if the list is empty -*) -val last : 'a list -> 'a +val register: string -> (string list -> mapper) -> unit +(** Apply the [register_function]. The default behavior is to run the + mapper immediately, taking arguments from the process command + line. This is to support a scenario where a mapper is linked as a + stand-alone executable. -val append : - 'a list -> - 'a list -> - 'a list + It is possible to overwrite the [register_function] to define + "-ppx drivers", which combine several mappers in a single process. + Typically, a driver starts by defining [register_function] to a + custom implementation, then lets ppx rewriters (linked statically + or dynamically) register themselves, and then run all or some of + them. It is also possible to have -ppx drivers apply rewriters to + only specific parts of an AST. -val append_one : - 'a list -> - 'a -> - 'a list + The first argument to [register] is a symbolic name to be used by + the ppx driver. *) -val map_append : - 'b list -> - 'a list -> - ('b -> 'a) -> - 'a list -val fold_right : - 'a list -> - 'b -> - ('a -> 'b -> 'b) -> - 'b +(** {1 Convenience functions to write mappers} *) -val fold_right2 : - 'a list -> - 'b list -> - 'c -> - ('a -> 'b -> 'c -> 'c) -> 'c +val map_opt: ('a -> 'b) -> 'a option -> 'b option -val map2 : - 'a list -> - 'b list -> - ('a -> 'b -> 'c) -> - 'c list +val extension_of_error: Location.error -> extension +(** Encode an error into an 'ocaml.error' extension node which can be + inserted in a generated Parsetree. The compiler will be + responsible for reporting the error. *) -val fold_left_with_offset : - 'a list -> - 'acc -> - int -> - ('a -> 'acc -> int -> 'acc) -> - 'acc +val attribute_of_warning: Location.t -> string -> attribute +(** Encode a warning message into an 'ocaml.ppwarning' attribute which can be + inserted in a generated Parsetree. The compiler will be + responsible for reporting the warning. *) +(** {1 Helper functions to call external mappers} *) -(** @unused *) -val filter_map : - 'a list -> - ('a -> 'b option) -> - 'b list +val add_ppx_context_str: + tool_name:string -> Parsetree.structure -> Parsetree.structure +(** Extract information from the current environment and encode it + into an attribute which is prepended to the list of structure + items in order to pass the information to an external + processor. *) -(** [exclude p l] is the opposite of [filter p l] *) -val exclude : - 'a list -> - ('a -> bool) -> - 'a list +val add_ppx_context_sig: + tool_name:string -> Parsetree.signature -> Parsetree.signature +(** Same as [add_ppx_context_str], but for signatures. *) -(** [excludes p l] - return a tuple [excluded,newl] - where [exluded] is true indicates that at least one - element is removed,[newl] is the new list where all [p x] for [x] is false +val drop_ppx_context_str: + restore:bool -> Parsetree.structure -> Parsetree.structure +(** Drop the ocaml.ppx.context attribute from a structure. If + [restore] is true, also restore the associated data in the current + process. *) -*) -val exclude_with_val : - 'a list -> - ('a -> bool) -> - 'a list option +val drop_ppx_context_sig: + restore:bool -> Parsetree.signature -> Parsetree.signature +(** Same as [drop_ppx_context_str], but for signatures. *) +(** {1 Cookies} *) -val same_length : 'a list -> 'b list -> bool +(** Cookies are used to pass information from a ppx processor to + a further invocation of itself, when called from the OCaml + toplevel (or other tools that support cookies). *) -val init : int -> (int -> 'a) -> 'a list +val set_cookie: string -> Parsetree.expression -> unit +val get_cookie: string -> Parsetree.expression option -(** [split_at n l] - will split [l] into two lists [a,b], [a] will be of length [n], - otherwise, it will raise -*) -val split_at : - 'a list -> - int -> - 'a list * 'a list +end = struct +#1 "ast_mapper.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Alain Frisch, LexiFi *) +(* *) +(* Copyright 2012 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) +(* A generic Parsetree mapping class *) -(** [split_at_last l] - It is equivalent to [split_at (List.length l - 1) l ] +(* +[@@@ocaml.warning "+9"] + (* Ensure that record patterns don't miss any field. *) *) -val split_at_last : 'a list -> 'a list * 'a -val filter_mapi : - 'a list -> - ('a -> int -> 'b option) -> - 'b list - -val filter_map2 : - 'a list -> - 'b list -> - ('a -> 'b -> 'c option) -> - 'c list +open Parsetree +open Ast_helper +open Location -val length_compare : 'a list -> int -> [`Gt | `Eq | `Lt ] +type mapper = { + attribute: mapper -> attribute -> attribute; + attributes: mapper -> attribute list -> attribute list; + case: mapper -> case -> case; + cases: mapper -> case list -> case list; + class_declaration: mapper -> class_declaration -> class_declaration; + class_description: mapper -> class_description -> class_description; + class_expr: mapper -> class_expr -> class_expr; + class_field: mapper -> class_field -> class_field; + class_signature: mapper -> class_signature -> class_signature; + class_structure: mapper -> class_structure -> class_structure; + class_type: mapper -> class_type -> class_type; + class_type_declaration: mapper -> class_type_declaration + -> class_type_declaration; + class_type_field: mapper -> class_type_field -> class_type_field; + constructor_declaration: mapper -> constructor_declaration + -> constructor_declaration; + expr: mapper -> expression -> expression; + extension: mapper -> extension -> extension; + extension_constructor: mapper -> extension_constructor + -> extension_constructor; + include_declaration: mapper -> include_declaration -> include_declaration; + include_description: mapper -> include_description -> include_description; + label_declaration: mapper -> label_declaration -> label_declaration; + location: mapper -> Location.t -> Location.t; + module_binding: mapper -> module_binding -> module_binding; + module_declaration: mapper -> module_declaration -> module_declaration; + module_expr: mapper -> module_expr -> module_expr; + module_type: mapper -> module_type -> module_type; + module_type_declaration: mapper -> module_type_declaration + -> module_type_declaration; + open_description: mapper -> open_description -> open_description; + pat: mapper -> pattern -> pattern; + payload: mapper -> payload -> payload; + signature: mapper -> signature -> signature; + signature_item: mapper -> signature_item -> signature_item; + structure: mapper -> structure -> structure; + structure_item: mapper -> structure_item -> structure_item; + typ: mapper -> core_type -> core_type; + type_declaration: mapper -> type_declaration -> type_declaration; + type_extension: mapper -> type_extension -> type_extension; + type_kind: mapper -> type_kind -> type_kind; + value_binding: mapper -> value_binding -> value_binding; + value_description: mapper -> value_description -> value_description; + with_constraint: mapper -> with_constraint -> with_constraint; +} -val length_ge : 'a list -> int -> bool +let map_fst f (x, y) = (f x, y) +let map_snd f (x, y) = (x, f y) +let map_tuple f1 f2 (x, y) = (f1 x, f2 y) +let map_tuple3 f1 f2 f3 (x, y, z) = (f1 x, f2 y, f3 z) +let map_opt f = function None -> None | Some x -> Some (f x) -(** +let map_loc sub {loc; txt} = {loc = sub.location sub loc; txt} - {[length xs = length ys + n ]} - input n should be positive - TODO: input checking -*) +module T = struct + (* Type expressions for the core language *) -val length_larger_than_n : - 'a list -> - 'a list -> - int -> - bool + let row_field sub = function + | Rtag (l, attrs, b, tl) -> + Rtag (map_loc sub l, sub.attributes sub attrs, + b, List.map (sub.typ sub) tl) + | Rinherit t -> Rinherit (sub.typ sub t) + let object_field sub = function + | Otag (l, attrs, t) -> + Otag (map_loc sub l, sub.attributes sub attrs, sub.typ sub t) + | Oinherit t -> Oinherit (sub.typ sub t) -(** - [rev_map_append f l1 l2] - [map f l1] and reverse it to append [l2] - This weird semantics is due to it is the most efficient operation - we can do -*) -val rev_map_append : - 'a list -> - 'b list -> - ('a -> 'b) -> - 'b list + let map sub {ptyp_desc = desc; ptyp_loc = loc; ptyp_attributes = attrs} = + let open Typ in + let loc = sub.location sub loc in + let attrs = sub.attributes sub attrs in + match desc with + | Ptyp_any -> any ~loc ~attrs () + | Ptyp_var s -> var ~loc ~attrs s + | Ptyp_arrow (lab, t1, t2) -> + arrow ~loc ~attrs lab (sub.typ sub t1) (sub.typ sub t2) + | Ptyp_tuple tyl -> tuple ~loc ~attrs (List.map (sub.typ sub) tyl) + | Ptyp_constr (lid, tl) -> + constr ~loc ~attrs (map_loc sub lid) (List.map (sub.typ sub) tl) + | Ptyp_object (l, o) -> + object_ ~loc ~attrs (List.map (object_field sub) l) o + | Ptyp_class (lid, tl) -> + class_ ~loc ~attrs (map_loc sub lid) (List.map (sub.typ sub) tl) + | Ptyp_alias (t, s) -> alias ~loc ~attrs (sub.typ sub t) s + | Ptyp_variant (rl, b, ll) -> + variant ~loc ~attrs (List.map (row_field sub) rl) b ll + | Ptyp_poly (sl, t) -> poly ~loc ~attrs + (List.map (map_loc sub) sl) (sub.typ sub t) + | Ptyp_package (lid, l) -> + package ~loc ~attrs (map_loc sub lid) + (List.map (map_tuple (map_loc sub) (sub.typ sub)) l) + | Ptyp_extension x -> extension ~loc ~attrs (sub.extension sub x) + let map_type_declaration sub + {ptype_name; ptype_params; ptype_cstrs; + ptype_kind; + ptype_private; + ptype_manifest; + ptype_attributes; + ptype_loc} = + Type.mk (map_loc sub ptype_name) + ~params:(List.map (map_fst (sub.typ sub)) ptype_params) + ~priv:ptype_private + ~cstrs:(List.map + (map_tuple3 (sub.typ sub) (sub.typ sub) (sub.location sub)) + ptype_cstrs) + ~kind:(sub.type_kind sub ptype_kind) + ?manifest:(map_opt (sub.typ sub) ptype_manifest) + ~loc:(sub.location sub ptype_loc) + ~attrs:(sub.attributes sub ptype_attributes) -val flat_map : - 'a list -> - ('a -> 'b list) -> - 'b list + let map_type_kind sub = function + | Ptype_abstract -> Ptype_abstract + | Ptype_variant l -> + Ptype_variant (List.map (sub.constructor_declaration sub) l) + | Ptype_record l -> Ptype_record (List.map (sub.label_declaration sub) l) + | Ptype_open -> Ptype_open -val flat_map_append : - 'a list -> - 'b list -> - ('a -> 'b list) -> - 'b list + let map_constructor_arguments sub = function + | Pcstr_tuple l -> Pcstr_tuple (List.map (sub.typ sub) l) + | Pcstr_record l -> + Pcstr_record (List.map (sub.label_declaration sub) l) + let map_type_extension sub + {ptyext_path; ptyext_params; + ptyext_constructors; + ptyext_private; + ptyext_attributes} = + Te.mk + (map_loc sub ptyext_path) + (List.map (sub.extension_constructor sub) ptyext_constructors) + ~params:(List.map (map_fst (sub.typ sub)) ptyext_params) + ~priv:ptyext_private + ~attrs:(sub.attributes sub ptyext_attributes) -(** - [stable_group eq lst] - Example: - Input: - {[ - stable_group (=) [1;2;3;4;3] - ]} - Output: - {[ - [[1];[2];[4];[3;3]] - ]} - TODO: this is O(n^2) behavior - which could be improved later -*) -val stable_group : - 'a list -> - ('a -> 'a -> bool) -> - 'a list list + let map_extension_constructor_kind sub = function + Pext_decl(ctl, cto) -> + Pext_decl(map_constructor_arguments sub ctl, map_opt (sub.typ sub) cto) + | Pext_rebind li -> + Pext_rebind (map_loc sub li) -(** [drop n list] - raise when [n] is negative - raise when list's length is less than [n] -*) -val drop : - 'a list -> - int -> - 'a list + let map_extension_constructor sub + {pext_name; + pext_kind; + pext_loc; + pext_attributes} = + Te.constructor + (map_loc sub pext_name) + (map_extension_constructor_kind sub pext_kind) + ~loc:(sub.location sub pext_loc) + ~attrs:(sub.attributes sub pext_attributes) -val find_first : - 'a list -> - ('a -> bool) -> - 'a option - -(** [find_first_not p lst ] - if all elements in [lst] pass, return [None] - otherwise return the first element [e] as [Some e] which - fails the predicate -*) -val find_first_not : - 'a list -> - ('a -> bool) -> - 'a option +end -(** [find_opt f l] returns [None] if all return [None], - otherwise returns the first one. -*) +module CT = struct + (* Type expressions for the class language *) -val find_opt : - 'a list -> - ('a -> 'b option) -> - 'b option + let map sub {pcty_loc = loc; pcty_desc = desc; pcty_attributes = attrs} = + let open Cty in + let loc = sub.location sub loc in + let attrs = sub.attributes sub attrs in + match desc with + | Pcty_constr (lid, tys) -> + constr ~loc ~attrs (map_loc sub lid) (List.map (sub.typ sub) tys) + | Pcty_signature x -> signature ~loc ~attrs (sub.class_signature sub x) + | Pcty_arrow (lab, t, ct) -> + arrow ~loc ~attrs lab (sub.typ sub t) (sub.class_type sub ct) + | Pcty_extension x -> extension ~loc ~attrs (sub.extension sub x) + | Pcty_open (ovf, lid, ct) -> + open_ ~loc ~attrs ovf (map_loc sub lid) (sub.class_type sub ct) + let map_field sub {pctf_desc = desc; pctf_loc = loc; pctf_attributes = attrs} + = + let open Ctf in + let loc = sub.location sub loc in + let attrs = sub.attributes sub attrs in + match desc with + | Pctf_inherit ct -> inherit_ ~loc ~attrs (sub.class_type sub ct) + | Pctf_val (s, m, v, t) -> + val_ ~loc ~attrs (map_loc sub s) m v (sub.typ sub t) + | Pctf_method (s, p, v, t) -> + method_ ~loc ~attrs (map_loc sub s) p v (sub.typ sub t) + | Pctf_constraint (t1, t2) -> + constraint_ ~loc ~attrs (sub.typ sub t1) (sub.typ sub t2) + | Pctf_attribute x -> attribute ~loc (sub.attribute sub x) + | Pctf_extension x -> extension ~loc ~attrs (sub.extension sub x) -val rev_iter : - 'a list -> - ('a -> unit) -> - unit + let map_signature sub {pcsig_self; pcsig_fields} = + Csig.mk + (sub.typ sub pcsig_self) + (List.map (sub.class_type_field sub) pcsig_fields) +end -val iter: - 'a list -> - ('a -> unit) -> - unit - -val for_all: - 'a list -> - ('a -> bool) -> - bool -val for_all_snd: - ('a * 'b) list -> - ('b -> bool) -> - bool +module MT = struct + (* Type expressions for the module language *) -(** [for_all2_no_exn p xs ys] - return [true] if all satisfied, - [false] otherwise or length not equal -*) -val for_all2_no_exn : - 'a list -> - 'b list -> - ('a -> 'b -> bool) -> - bool + let map sub {pmty_desc = desc; pmty_loc = loc; pmty_attributes = attrs} = + let open Mty in + let loc = sub.location sub loc in + let attrs = sub.attributes sub attrs in + match desc with + | Pmty_ident s -> ident ~loc ~attrs (map_loc sub s) + | Pmty_alias s -> alias ~loc ~attrs (map_loc sub s) + | Pmty_signature sg -> signature ~loc ~attrs (sub.signature sub sg) + | Pmty_functor (s, mt1, mt2) -> + functor_ ~loc ~attrs (map_loc sub s) + (Misc.may_map (sub.module_type sub) mt1) + (sub.module_type sub mt2) + | Pmty_with (mt, l) -> + with_ ~loc ~attrs (sub.module_type sub mt) + (List.map (sub.with_constraint sub) l) + | Pmty_typeof me -> typeof_ ~loc ~attrs (sub.module_expr sub me) + | Pmty_extension x -> extension ~loc ~attrs (sub.extension sub x) + let map_with_constraint sub = function + | Pwith_type (lid, d) -> + Pwith_type (map_loc sub lid, sub.type_declaration sub d) + | Pwith_module (lid, lid2) -> + Pwith_module (map_loc sub lid, map_loc sub lid2) + | Pwith_typesubst (lid, d) -> + Pwith_typesubst (map_loc sub lid, sub.type_declaration sub d) + | Pwith_modsubst (s, lid) -> + Pwith_modsubst (map_loc sub s, map_loc sub lid) + let map_signature_item sub {psig_desc = desc; psig_loc = loc} = + let open Sig in + let loc = sub.location sub loc in + match desc with + | Psig_value vd -> value ~loc (sub.value_description sub vd) + | Psig_type (rf, l) -> type_ ~loc rf (List.map (sub.type_declaration sub) l) + | Psig_typext te -> type_extension ~loc (sub.type_extension sub te) + | Psig_exception ed -> exception_ ~loc (sub.extension_constructor sub ed) + | Psig_module x -> module_ ~loc (sub.module_declaration sub x) + | Psig_recmodule l -> + rec_module ~loc (List.map (sub.module_declaration sub) l) + | Psig_modtype x -> modtype ~loc (sub.module_type_declaration sub x) + | Psig_open x -> open_ ~loc (sub.open_description sub x) + | Psig_include x -> include_ ~loc (sub.include_description sub x) + | Psig_class l -> class_ ~loc (List.map (sub.class_description sub) l) + | Psig_class_type l -> + class_type ~loc (List.map (sub.class_type_declaration sub) l) + | Psig_extension (x, attrs) -> + extension ~loc (sub.extension sub x) ~attrs:(sub.attributes sub attrs) + | Psig_attribute x -> attribute ~loc (sub.attribute sub x) +end -(** [f] is applied follow the list order *) -val split_map : - 'a list -> - ('a -> 'b * 'c) -> - 'b list * 'c list -(** [fn] is applied from left to right *) -val reduce_from_left : - 'a list -> - ('a -> 'a -> 'a) -> - 'a +module M = struct + (* Value expressions for the module language *) -val sort_via_array : - 'a list -> - ('a -> 'a -> int) -> - 'a list + let map sub {pmod_loc = loc; pmod_desc = desc; pmod_attributes = attrs} = + let open Mod in + let loc = sub.location sub loc in + let attrs = sub.attributes sub attrs in + match desc with + | Pmod_ident x -> ident ~loc ~attrs (map_loc sub x) + | Pmod_structure str -> structure ~loc ~attrs (sub.structure sub str) + | Pmod_functor (arg, arg_ty, body) -> + functor_ ~loc ~attrs (map_loc sub arg) + (Misc.may_map (sub.module_type sub) arg_ty) + (sub.module_expr sub body) + | Pmod_apply (m1, m2) -> + apply ~loc ~attrs (sub.module_expr sub m1) (sub.module_expr sub m2) + | Pmod_constraint (m, mty) -> + constraint_ ~loc ~attrs (sub.module_expr sub m) + (sub.module_type sub mty) + | Pmod_unpack e -> unpack ~loc ~attrs (sub.expr sub e) + | Pmod_extension x -> extension ~loc ~attrs (sub.extension sub x) + let map_structure_item sub {pstr_loc = loc; pstr_desc = desc} = + let open Str in + let loc = sub.location sub loc in + match desc with + | Pstr_eval (x, attrs) -> + eval ~loc ~attrs:(sub.attributes sub attrs) (sub.expr sub x) + | Pstr_value (r, vbs) -> value ~loc r (List.map (sub.value_binding sub) vbs) + | Pstr_primitive vd -> primitive ~loc (sub.value_description sub vd) + | Pstr_type (rf, l) -> type_ ~loc rf (List.map (sub.type_declaration sub) l) + | Pstr_typext te -> type_extension ~loc (sub.type_extension sub te) + | Pstr_exception ed -> exception_ ~loc (sub.extension_constructor sub ed) + | Pstr_module x -> module_ ~loc (sub.module_binding sub x) + | Pstr_recmodule l -> rec_module ~loc (List.map (sub.module_binding sub) l) + | Pstr_modtype x -> modtype ~loc (sub.module_type_declaration sub x) + | Pstr_open x -> open_ ~loc (sub.open_description sub x) + | Pstr_class l -> class_ ~loc (List.map (sub.class_declaration sub) l) + | Pstr_class_type l -> + class_type ~loc (List.map (sub.class_type_declaration sub) l) + | Pstr_include x -> include_ ~loc (sub.include_declaration sub x) + | Pstr_extension (x, attrs) -> + extension ~loc (sub.extension sub x) ~attrs:(sub.attributes sub attrs) + | Pstr_attribute x -> attribute ~loc (sub.attribute sub x) +end +module E = struct + (* Value expressions for the core language *) + let map sub {pexp_loc = loc; pexp_desc = desc; pexp_attributes = attrs} = + let open Exp in + let loc = sub.location sub loc in + let attrs = sub.attributes sub attrs in + match desc with + | Pexp_ident x -> ident ~loc ~attrs (map_loc sub x) + | Pexp_constant x -> constant ~loc ~attrs x + | Pexp_let (r, vbs, e) -> + let_ ~loc ~attrs r (List.map (sub.value_binding sub) vbs) + (sub.expr sub e) + | Pexp_fun (lab, def, p, e) -> + fun_ ~loc ~attrs lab (map_opt (sub.expr sub) def) (sub.pat sub p) + (sub.expr sub e) + | Pexp_function pel -> function_ ~loc ~attrs (sub.cases sub pel) + | Pexp_apply (e, l) -> + apply ~loc ~attrs (sub.expr sub e) (List.map (map_snd (sub.expr sub)) l) + | Pexp_match (e, pel) -> + match_ ~loc ~attrs (sub.expr sub e) (sub.cases sub pel) + | Pexp_try (e, pel) -> try_ ~loc ~attrs (sub.expr sub e) (sub.cases sub pel) + | Pexp_tuple el -> tuple ~loc ~attrs (List.map (sub.expr sub) el) + | Pexp_construct (lid, arg) -> + construct ~loc ~attrs (map_loc sub lid) (map_opt (sub.expr sub) arg) + | Pexp_variant (lab, eo) -> + variant ~loc ~attrs lab (map_opt (sub.expr sub) eo) + | Pexp_record (l, eo) -> + record ~loc ~attrs (List.map (map_tuple (map_loc sub) (sub.expr sub)) l) + (map_opt (sub.expr sub) eo) + | Pexp_field (e, lid) -> + field ~loc ~attrs (sub.expr sub e) (map_loc sub lid) + | Pexp_setfield (e1, lid, e2) -> + setfield ~loc ~attrs (sub.expr sub e1) (map_loc sub lid) + (sub.expr sub e2) + | Pexp_array el -> array ~loc ~attrs (List.map (sub.expr sub) el) + | Pexp_ifthenelse (e1, e2, e3) -> + ifthenelse ~loc ~attrs (sub.expr sub e1) (sub.expr sub e2) + (map_opt (sub.expr sub) e3) + | Pexp_sequence (e1, e2) -> + sequence ~loc ~attrs (sub.expr sub e1) (sub.expr sub e2) + | Pexp_while (e1, e2) -> + while_ ~loc ~attrs (sub.expr sub e1) (sub.expr sub e2) + | Pexp_for (p, e1, e2, d, e3) -> + for_ ~loc ~attrs (sub.pat sub p) (sub.expr sub e1) (sub.expr sub e2) d + (sub.expr sub e3) + | Pexp_coerce (e, t1, t2) -> + coerce ~loc ~attrs (sub.expr sub e) (map_opt (sub.typ sub) t1) + (sub.typ sub t2) + | Pexp_constraint (e, t) -> + constraint_ ~loc ~attrs (sub.expr sub e) (sub.typ sub t) + | Pexp_send (e, s) -> + send ~loc ~attrs (sub.expr sub e) (map_loc sub s) + | Pexp_new lid -> new_ ~loc ~attrs (map_loc sub lid) + | Pexp_setinstvar (s, e) -> + setinstvar ~loc ~attrs (map_loc sub s) (sub.expr sub e) + | Pexp_override sel -> + override ~loc ~attrs + (List.map (map_tuple (map_loc sub) (sub.expr sub)) sel) + | Pexp_letmodule (s, me, e) -> + letmodule ~loc ~attrs (map_loc sub s) (sub.module_expr sub me) + (sub.expr sub e) + | Pexp_letexception (cd, e) -> + letexception ~loc ~attrs + (sub.extension_constructor sub cd) + (sub.expr sub e) + | Pexp_assert e -> assert_ ~loc ~attrs (sub.expr sub e) + | Pexp_lazy e -> lazy_ ~loc ~attrs (sub.expr sub e) + | Pexp_poly (e, t) -> + poly ~loc ~attrs (sub.expr sub e) (map_opt (sub.typ sub) t) + | Pexp_object cls -> object_ ~loc ~attrs (sub.class_structure sub cls) + | Pexp_newtype (s, e) -> + newtype ~loc ~attrs (map_loc sub s) (sub.expr sub e) + | Pexp_pack me -> pack ~loc ~attrs (sub.module_expr sub me) + | Pexp_open (ovf, lid, e) -> + open_ ~loc ~attrs ovf (map_loc sub lid) (sub.expr sub e) + | Pexp_extension x -> extension ~loc ~attrs (sub.extension sub x) + | Pexp_unreachable -> unreachable ~loc ~attrs () +end -(** [assoc_by_string default key lst] - if [key] is found in the list return that val, - other unbox the [default], - otherwise [assert false ] -*) -val assoc_by_string : - (string * 'a) list -> - string -> - 'a option -> - 'a +module P = struct + (* Patterns *) -val assoc_by_int : - (int * 'a) list -> - int -> - 'a option -> - 'a + let map sub {ppat_desc = desc; ppat_loc = loc; ppat_attributes = attrs} = + let open Pat in + let loc = sub.location sub loc in + let attrs = sub.attributes sub attrs in + match desc with + | Ppat_any -> any ~loc ~attrs () + | Ppat_var s -> var ~loc ~attrs (map_loc sub s) + | Ppat_alias (p, s) -> alias ~loc ~attrs (sub.pat sub p) (map_loc sub s) + | Ppat_constant c -> constant ~loc ~attrs c + | Ppat_interval (c1, c2) -> interval ~loc ~attrs c1 c2 + | Ppat_tuple pl -> tuple ~loc ~attrs (List.map (sub.pat sub) pl) + | Ppat_construct (l, p) -> + construct ~loc ~attrs (map_loc sub l) (map_opt (sub.pat sub) p) + | Ppat_variant (l, p) -> variant ~loc ~attrs l (map_opt (sub.pat sub) p) + | Ppat_record (lpl, cf) -> + record ~loc ~attrs + (List.map (map_tuple (map_loc sub) (sub.pat sub)) lpl) cf + | Ppat_array pl -> array ~loc ~attrs (List.map (sub.pat sub) pl) + | Ppat_or (p1, p2) -> or_ ~loc ~attrs (sub.pat sub p1) (sub.pat sub p2) + | Ppat_constraint (p, t) -> + constraint_ ~loc ~attrs (sub.pat sub p) (sub.typ sub t) + | Ppat_type s -> type_ ~loc ~attrs (map_loc sub s) + | Ppat_lazy p -> lazy_ ~loc ~attrs (sub.pat sub p) + | Ppat_unpack s -> unpack ~loc ~attrs (map_loc sub s) + | Ppat_open (lid,p) -> open_ ~loc ~attrs (map_loc sub lid) (sub.pat sub p) + | Ppat_exception p -> exception_ ~loc ~attrs (sub.pat sub p) + | Ppat_extension x -> extension ~loc ~attrs (sub.extension sub x) +end +module CE = struct + (* Value expressions for the class language *) -val nth_opt : 'a list -> int -> 'a option + let map sub {pcl_loc = loc; pcl_desc = desc; pcl_attributes = attrs} = + let open Cl in + let loc = sub.location sub loc in + let attrs = sub.attributes sub attrs in + match desc with + | Pcl_constr (lid, tys) -> + constr ~loc ~attrs (map_loc sub lid) (List.map (sub.typ sub) tys) + | Pcl_structure s -> + structure ~loc ~attrs (sub.class_structure sub s) + | Pcl_fun (lab, e, p, ce) -> + fun_ ~loc ~attrs lab + (map_opt (sub.expr sub) e) + (sub.pat sub p) + (sub.class_expr sub ce) + | Pcl_apply (ce, l) -> + apply ~loc ~attrs (sub.class_expr sub ce) + (List.map (map_snd (sub.expr sub)) l) + | Pcl_let (r, vbs, ce) -> + let_ ~loc ~attrs r (List.map (sub.value_binding sub) vbs) + (sub.class_expr sub ce) + | Pcl_constraint (ce, ct) -> + constraint_ ~loc ~attrs (sub.class_expr sub ce) (sub.class_type sub ct) + | Pcl_extension x -> extension ~loc ~attrs (sub.extension sub x) + | Pcl_open (ovf, lid, ce) -> + open_ ~loc ~attrs ovf (map_loc sub lid) (sub.class_expr sub ce) -val iter_snd : ('a * 'b) list -> ('b -> unit) -> unit + let map_kind sub = function + | Cfk_concrete (o, e) -> Cfk_concrete (o, sub.expr sub e) + | Cfk_virtual t -> Cfk_virtual (sub.typ sub t) -val iter_fst : ('a * 'b) list -> ('a -> unit) -> unit + let map_field sub {pcf_desc = desc; pcf_loc = loc; pcf_attributes = attrs} = + let open Cf in + let loc = sub.location sub loc in + let attrs = sub.attributes sub attrs in + match desc with + | Pcf_inherit (o, ce, s) -> + inherit_ ~loc ~attrs o (sub.class_expr sub ce) + (map_opt (map_loc sub) s) + | Pcf_val (s, m, k) -> val_ ~loc ~attrs (map_loc sub s) m (map_kind sub k) + | Pcf_method (s, p, k) -> + method_ ~loc ~attrs (map_loc sub s) p (map_kind sub k) + | Pcf_constraint (t1, t2) -> + constraint_ ~loc ~attrs (sub.typ sub t1) (sub.typ sub t2) + | Pcf_initializer e -> initializer_ ~loc ~attrs (sub.expr sub e) + | Pcf_attribute x -> attribute ~loc (sub.attribute sub x) + | Pcf_extension x -> extension ~loc ~attrs (sub.extension sub x) -val exists : 'a list -> ('a -> bool) -> bool + let map_structure sub {pcstr_self; pcstr_fields} = + { + pcstr_self = sub.pat sub pcstr_self; + pcstr_fields = List.map (sub.class_field sub) pcstr_fields; + } -val exists_fst : - ('a * 'b) list -> - ('a -> bool) -> - bool + let class_infos sub f {pci_virt; pci_params = pl; pci_name; pci_expr; + pci_loc; pci_attributes} = + Ci.mk + ~virt:pci_virt + ~params:(List.map (map_fst (sub.typ sub)) pl) + (map_loc sub pci_name) + (f pci_expr) + ~loc:(sub.location sub pci_loc) + ~attrs:(sub.attributes sub pci_attributes) +end -val exists_snd : - ('a * 'b) list -> - ('b -> bool) -> - bool +(* Now, a generic AST mapper, to be extended to cover all kinds and + cases of the OCaml grammar. The default behavior of the mapper is + the identity. *) -val concat_append: - 'a list list -> - 'a list -> - 'a list +let default_mapper = + { + structure = (fun this l -> List.map (this.structure_item this) l); + structure_item = M.map_structure_item; + module_expr = M.map; + signature = (fun this l -> List.map (this.signature_item this) l); + signature_item = MT.map_signature_item; + module_type = MT.map; + with_constraint = MT.map_with_constraint; + class_declaration = + (fun this -> CE.class_infos this (this.class_expr this)); + class_expr = CE.map; + class_field = CE.map_field; + class_structure = CE.map_structure; + class_type = CT.map; + class_type_field = CT.map_field; + class_signature = CT.map_signature; + class_type_declaration = + (fun this -> CE.class_infos this (this.class_type this)); + class_description = + (fun this -> CE.class_infos this (this.class_type this)); + type_declaration = T.map_type_declaration; + type_kind = T.map_type_kind; + typ = T.map; + type_extension = T.map_type_extension; + extension_constructor = T.map_extension_constructor; + value_description = + (fun this {pval_name; pval_type; pval_prim; pval_loc; + pval_attributes} -> + Val.mk + (map_loc this pval_name) + (this.typ this pval_type) + ~attrs:(this.attributes this pval_attributes) + ~loc:(this.location this pval_loc) + ~prim:pval_prim + ); -val fold_left2: - 'a list -> - 'b list -> - 'c -> - ('a -> 'b -> 'c -> 'c) - -> 'c + pat = P.map; + expr = E.map; -val fold_left: - 'a list -> - 'b -> - ('b -> 'a -> 'b) -> - 'b + module_declaration = + (fun this {pmd_name; pmd_type; pmd_attributes; pmd_loc} -> + Md.mk + (map_loc this pmd_name) + (this.module_type this pmd_type) + ~attrs:(this.attributes this pmd_attributes) + ~loc:(this.location this pmd_loc) + ); -val singleton_exn: - 'a list -> 'a + module_type_declaration = + (fun this {pmtd_name; pmtd_type; pmtd_attributes; pmtd_loc} -> + Mtd.mk + (map_loc this pmtd_name) + ?typ:(map_opt (this.module_type this) pmtd_type) + ~attrs:(this.attributes this pmtd_attributes) + ~loc:(this.location this pmtd_loc) + ); -val mem_string : - string list -> - string -> - bool -end = struct -#1 "ext_list.ml" -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) + module_binding = + (fun this {pmb_name; pmb_expr; pmb_attributes; pmb_loc} -> + Mb.mk (map_loc this pmb_name) (this.module_expr this pmb_expr) + ~attrs:(this.attributes this pmb_attributes) + ~loc:(this.location this pmb_loc) + ); + open_description = + (fun this {popen_lid; popen_override; popen_attributes; popen_loc} -> + Opn.mk (map_loc this popen_lid) + ~override:popen_override + ~loc:(this.location this popen_loc) + ~attrs:(this.attributes this popen_attributes) + ); -let rec map l f = - match l with - | [] -> - [] - | [x1] -> - let y1 = f x1 in - [y1] - | [x1; x2] -> - let y1 = f x1 in - let y2 = f x2 in - [y1; y2] - | [x1; x2; x3] -> - let y1 = f x1 in - let y2 = f x2 in - let y3 = f x3 in - [y1; y2; y3] - | [x1; x2; x3; x4] -> - let y1 = f x1 in - let y2 = f x2 in - let y3 = f x3 in - let y4 = f x4 in - [y1; y2; y3; y4] - | x1::x2::x3::x4::x5::tail -> - let y1 = f x1 in - let y2 = f x2 in - let y3 = f x3 in - let y4 = f x4 in - let y5 = f x5 in - y1::y2::y3::y4::y5::(map tail f) + include_description = + (fun this {pincl_mod; pincl_attributes; pincl_loc} -> + Incl.mk (this.module_type this pincl_mod) + ~loc:(this.location this pincl_loc) + ~attrs:(this.attributes this pincl_attributes) + ); -let rec has_string l f = - match l with - | [] -> - false - | [x1] -> - x1 = f - | [x1; x2] -> - x1 = f || x2 = f - | [x1; x2; x3] -> - x1 = f || x2 = f || x3 = f - | x1 :: x2 :: x3 :: x4 -> - x1 = f || x2 = f || x3 = f || has_string x4 f - -let rec map_combine l1 l2 f = - match (l1, l2) with - ([], []) -> [] - | (a1::l1, a2::l2) -> - (f a1, a2) :: map_combine l1 l2 f - | (_, _) -> - invalid_arg "Ext_list.map_combine" + include_declaration = + (fun this {pincl_mod; pincl_attributes; pincl_loc} -> + Incl.mk (this.module_expr this pincl_mod) + ~loc:(this.location this pincl_loc) + ~attrs:(this.attributes this pincl_attributes) + ); -let rec map_split_opt - (xs : 'a list) (f : 'a -> 'b option * 'c option) - : 'b list * 'c list = - match xs with - | [] -> [], [] - | x::xs -> - let c,d = f x in - let cs,ds = map_split_opt xs f in - (match c with Some c -> c::cs | None -> cs), - (match d with Some d -> d::ds | None -> ds) -let rec map_snd l f = - match l with - | [] -> - [] - | [ v1,x1 ] -> - let y1 = f x1 in - [v1,y1] - | [v1, x1; v2, x2] -> - let y1 = f x1 in - let y2 = f x2 in - [v1, y1; v2, y2] - | [ v1, x1; v2, x2; v3, x3] -> - let y1 = f x1 in - let y2 = f x2 in - let y3 = f x3 in - [v1, y1; v2, y2; v3, y3] - | [ v1, x1; v2, x2; v3, x3; v4, x4] -> - let y1 = f x1 in - let y2 = f x2 in - let y3 = f x3 in - let y4 = f x4 in - [v1, y1; v2, y2; v3, y3; v4, y4] - | (v1, x1) ::(v2, x2) :: (v3, x3)::(v4, x4) :: (v5, x5) ::tail -> - let y1 = f x1 in - let y2 = f x2 in - let y3 = f x3 in - let y4 = f x4 in - let y5 = f x5 in - (v1, y1)::(v2, y2) :: (v3, y3) :: (v4, y4) :: (v5, y5) :: (map_snd tail f) + value_binding = + (fun this {pvb_pat; pvb_expr; pvb_attributes; pvb_loc} -> + Vb.mk + (this.pat this pvb_pat) + (this.expr this pvb_expr) + ~loc:(this.location this pvb_loc) + ~attrs:(this.attributes this pvb_attributes) + ); -let rec map_last l f= - match l with - | [] -> - [] - | [x1] -> - let y1 = f true x1 in - [y1] - | [x1; x2] -> - let y1 = f false x1 in - let y2 = f true x2 in - [y1; y2] - | [x1; x2; x3] -> - let y1 = f false x1 in - let y2 = f false x2 in - let y3 = f true x3 in - [y1; y2; y3] - | [x1; x2; x3; x4] -> - let y1 = f false x1 in - let y2 = f false x2 in - let y3 = f false x3 in - let y4 = f true x4 in - [y1; y2; y3; y4] - | x1::x2::x3::x4::tail -> - (* make sure that tail is not empty *) - let y1 = f false x1 in - let y2 = f false x2 in - let y3 = f false x3 in - let y4 = f false x4 in - y1::y2::y3::y4::(map_last tail f) + constructor_declaration = + (fun this {pcd_name; pcd_args; pcd_res; pcd_loc; pcd_attributes} -> + Type.constructor + (map_loc this pcd_name) + ~args:(T.map_constructor_arguments this pcd_args) + ?res:(map_opt (this.typ this) pcd_res) + ~loc:(this.location this pcd_loc) + ~attrs:(this.attributes this pcd_attributes) + ); -let rec mapi_aux lst i f = - match lst with - [] -> [] - | a::l -> - let r = f i a in r :: mapi_aux l (i + 1) f + label_declaration = + (fun this {pld_name; pld_type; pld_loc; pld_mutable; pld_attributes} -> + Type.field + (map_loc this pld_name) + (this.typ this pld_type) + ~mut:pld_mutable + ~loc:(this.location this pld_loc) + ~attrs:(this.attributes this pld_attributes) + ); -let mapi lst f = mapi_aux lst 0 f + cases = (fun this l -> List.map (this.case this) l); + case = + (fun this {pc_lhs; pc_guard; pc_rhs} -> + { + pc_lhs = this.pat this pc_lhs; + pc_guard = map_opt (this.expr this) pc_guard; + pc_rhs = this.expr this pc_rhs; + } + ); -let rec last xs = - match xs with - | [x] -> x - | _ :: tl -> last tl - | [] -> invalid_arg "Ext_list.last" + location = (fun _this l -> l); -let rec append_aux l1 l2 = - match l1 with - | [] -> l2 - | [a0] -> a0::l2 - | [a0;a1] -> a0::a1::l2 - | [a0;a1;a2] -> a0::a1::a2::l2 - | [a0;a1;a2;a3] -> a0::a1::a2::a3::l2 - | [a0;a1;a2;a3;a4] -> a0::a1::a2::a3::a4::l2 - | a0::a1::a2::a3::a4::rest -> a0::a1::a2::a3::a4::append_aux rest l2 + extension = (fun this (s, e) -> (map_loc this s, this.payload this e)); + attribute = (fun this (s, e) -> (map_loc this s, this.payload this e)); + attributes = (fun this l -> List.map (this.attribute this) l); + payload = + (fun this -> function + | PStr x -> PStr (this.structure this x) + | PSig x -> PSig (this.signature this x) + | PTyp x -> PTyp (this.typ this x) + | PPat (x, g) -> PPat (this.pat this x, map_opt (this.expr this) g) + ); + } -let append l1 l2 = - match l2 with - | [] -> l1 - | _ -> append_aux l1 l2 +let rec extension_of_error {loc; msg; if_highlight; sub} = + { loc; txt = "ocaml.error" }, + PStr ([Str.eval (Exp.constant (Pconst_string (msg, None))); + Str.eval (Exp.constant (Pconst_string (if_highlight, None)))] @ + (List.map (fun ext -> Str.extension (extension_of_error ext)) sub)) -let append_one l1 x = append_aux l1 [x] +let attribute_of_warning loc s = + { loc; txt = "ocaml.ppwarning" }, + PStr ([Str.eval ~loc (Exp.constant (Pconst_string (s, None)))]) -let rec map_append l1 l2 f = - match l1 with - | [] -> l2 - | [a0] -> f a0::l2 - | [a0;a1] -> - let b0 = f a0 in - let b1 = f a1 in - b0::b1::l2 - | [a0;a1;a2] -> - let b0 = f a0 in - let b1 = f a1 in - let b2 = f a2 in - b0::b1::b2::l2 - | [a0;a1;a2;a3] -> - let b0 = f a0 in - let b1 = f a1 in - let b2 = f a2 in - let b3 = f a3 in - b0::b1::b2::b3::l2 - | [a0;a1;a2;a3;a4] -> - let b0 = f a0 in - let b1 = f a1 in - let b2 = f a2 in - let b3 = f a3 in - let b4 = f a4 in - b0::b1::b2::b3::b4::l2 +module StringMap = Map.Make(struct + type t = string + let compare = compare +end) - | a0::a1::a2::a3::a4::rest -> - let b0 = f a0 in - let b1 = f a1 in - let b2 = f a2 in - let b3 = f a3 in - let b4 = f a4 in - b0::b1::b2::b3::b4::map_append rest l2 f +let cookies = ref StringMap.empty +let get_cookie k = + try Some (StringMap.find k !cookies) + with Not_found -> None +let set_cookie k v = + cookies := StringMap.add k v !cookies -let rec fold_right l acc f = - match l with - | [] -> acc - | [a0] -> f a0 acc - | [a0;a1] -> f a0 (f a1 acc) - | [a0;a1;a2] -> f a0 (f a1 (f a2 acc)) - | [a0;a1;a2;a3] -> f a0 (f a1 (f a2 (f a3 acc))) - | [a0;a1;a2;a3;a4] -> - f a0 (f a1 (f a2 (f a3 (f a4 acc)))) - | a0::a1::a2::a3::a4::rest -> - f a0 (f a1 (f a2 (f a3 (f a4 (fold_right rest acc f ))))) +let tool_name_ref = ref "_none_" -let rec fold_right2 l r acc f = - match l,r with - | [],[] -> acc - | [a0],[b0] -> f a0 b0 acc - | [a0;a1],[b0;b1] -> f a0 b0 (f a1 b1 acc) - | [a0;a1;a2],[b0;b1;b2] -> f a0 b0 (f a1 b1 (f a2 b2 acc)) - | [a0;a1;a2;a3],[b0;b1;b2;b3] -> - f a0 b0 (f a1 b1 (f a2 b2 (f a3 b3 acc))) - | [a0;a1;a2;a3;a4], [b0;b1;b2;b3;b4] -> - f a0 b0 (f a1 b1 (f a2 b2 (f a3 b3 (f a4 b4 acc)))) - | a0::a1::a2::a3::a4::arest, b0::b1::b2::b3::b4::brest -> - f a0 b0 (f a1 b1 (f a2 b2 (f a3 b3 (f a4 b4 (fold_right2 arest brest acc f ))))) - | _, _ -> invalid_arg "Ext_list.fold_right2" +let tool_name () = !tool_name_ref -let rec map2 l r f = - match l,r with - | [],[] -> [] - | [a0],[b0] -> [f a0 b0] - | [a0;a1],[b0;b1] -> - let c0 = f a0 b0 in - let c1 = f a1 b1 in - [c0; c1] - | [a0;a1;a2],[b0;b1;b2] -> - let c0 = f a0 b0 in - let c1 = f a1 b1 in - let c2 = f a2 b2 in - [c0;c1;c2] - | [a0;a1;a2;a3],[b0;b1;b2;b3] -> - let c0 = f a0 b0 in - let c1 = f a1 b1 in - let c2 = f a2 b2 in - let c3 = f a3 b3 in - [c0;c1;c2;c3] - | [a0;a1;a2;a3;a4], [b0;b1;b2;b3;b4] -> - let c0 = f a0 b0 in - let c1 = f a1 b1 in - let c2 = f a2 b2 in - let c3 = f a3 b3 in - let c4 = f a4 b4 in - [c0;c1;c2;c3;c4] - | a0::a1::a2::a3::a4::arest, b0::b1::b2::b3::b4::brest -> - let c0 = f a0 b0 in - let c1 = f a1 b1 in - let c2 = f a2 b2 in - let c3 = f a3 b3 in - let c4 = f a4 b4 in - c0::c1::c2::c3::c4::map2 arest brest f - | _, _ -> invalid_arg "Ext_list.map2" -let rec fold_left_with_offset l accu i f = - match l with - | [] -> accu - | a::l -> - fold_left_with_offset - l - (f a accu i) - (i + 1) - f +module PpxContext = struct + open Longident + open Asttypes + open Ast_helper + let lid name = { txt = Lident name; loc = Location.none } -let rec filter_map xs (f: 'a -> 'b option)= - match xs with - | [] -> [] - | y :: ys -> - begin match f y with - | None -> filter_map ys f - | Some z -> z :: filter_map ys f - end + let make_string x = Exp.constant (Pconst_string (x, None)) -let rec exclude (xs : 'a list) (p : 'a -> bool) : 'a list = - match xs with - | [] -> [] - | x::xs -> - if p x then exclude xs p - else x:: exclude xs p + let make_bool x = + if x + then Exp.construct (lid "true") None + else Exp.construct (lid "false") None -let rec exclude_with_val l p = - match l with - | [] -> None - | a0::xs -> - if p a0 then Some (exclude xs p) - else - match xs with - | [] -> None - | a1::rest -> - if p a1 then - Some (a0:: exclude rest p) - else - match exclude_with_val rest p with - | None -> None - | Some rest -> Some (a0::a1::rest) + let rec make_list f lst = + match lst with + | x :: rest -> + Exp.construct (lid "::") (Some (Exp.tuple [f x; make_list f rest])) + | [] -> + Exp.construct (lid "[]") None + let make_pair f1 f2 (x1, x2) = + Exp.tuple [f1 x1; f2 x2] + let make_option f opt = + match opt with + | Some x -> Exp.construct (lid "Some") (Some (f x)) + | None -> Exp.construct (lid "None") None -let rec same_length xs ys = - match xs, ys with - | [], [] -> true - | _::xs, _::ys -> same_length xs ys - | _, _ -> false + let get_cookies () = + lid "cookies", + make_list (make_pair make_string (fun x -> x)) + (StringMap.bindings !cookies) + let mk fields = + { txt = "ocaml.ppx.context"; loc = Location.none }, + Parsetree.PStr [Str.eval (Exp.record fields None)] -let init n f = - match n with - | 0 -> [] - | 1 -> - let a0 = f 0 in - [a0] - | 2 -> - let a0 = f 0 in - let a1 = f 1 in - [a0; a1] - | 3 -> - let a0 = f 0 in - let a1 = f 1 in - let a2 = f 2 in - [a0; a1; a2] - | 4 -> - let a0 = f 0 in - let a1 = f 1 in - let a2 = f 2 in - let a3 = f 3 in - [a0; a1; a2; a3] - | 5 -> - let a0 = f 0 in - let a1 = f 1 in - let a2 = f 2 in - let a3 = f 3 in - let a4 = f 4 in - [a0; a1; a2; a3; a4] - | _ -> - Array.to_list (Array.init n f) + let make ~tool_name () = + let fields = + [ + lid "tool_name", make_string tool_name; + lid "include_dirs", make_list make_string !Clflags.include_dirs; + lid "load_path", make_list make_string !Config.load_path; + lid "open_modules", make_list make_string !Clflags.open_modules; + lid "for_package", make_option make_string !Clflags.for_package; + lid "debug", make_bool !Clflags.debug; + lid "use_threads", make_bool !Clflags.use_threads; + lid "use_vmthreads", make_bool !Clflags.use_vmthreads; + get_cookies () + ] + in + mk fields -let rec rev_append l1 l2 = - match l1 with - [] -> l2 - | a :: l -> rev_append l (a :: l2) + let get_fields = function + | PStr [{pstr_desc = Pstr_eval + ({ pexp_desc = Pexp_record (fields, None) }, [])}] -> + fields + | _ -> + raise_errorf "Internal error: invalid [@@@ocaml.ppx.context] syntax" -let rev l = rev_append l [] + let restore fields = + let field name payload = + let rec get_string = function + | { pexp_desc = Pexp_constant (Pconst_string (str, None)) } -> str + | _ -> raise_errorf "Internal error: invalid [@@@ocaml.ppx.context \ + { %s }] string syntax" name + and get_bool pexp = + match pexp with + | {pexp_desc = Pexp_construct ({txt = Longident.Lident "true"}, + None)} -> + true + | {pexp_desc = Pexp_construct ({txt = Longident.Lident "false"}, + None)} -> + false + | _ -> raise_errorf "Internal error: invalid [@@@ocaml.ppx.context \ + { %s }] bool syntax" name + and get_list elem = function + | {pexp_desc = + Pexp_construct ({txt = Longident.Lident "::"}, + Some {pexp_desc = Pexp_tuple [exp; rest]}) } -> + elem exp :: get_list elem rest + | {pexp_desc = + Pexp_construct ({txt = Longident.Lident "[]"}, None)} -> + [] + | _ -> raise_errorf "Internal error: invalid [@@@ocaml.ppx.context \ + { %s }] list syntax" name + and get_pair f1 f2 = function + | {pexp_desc = Pexp_tuple [e1; e2]} -> + (f1 e1, f2 e2) + | _ -> raise_errorf "Internal error: invalid [@@@ocaml.ppx.context \ + { %s }] pair syntax" name + and get_option elem = function + | { pexp_desc = + Pexp_construct ({ txt = Longident.Lident "Some" }, Some exp) } -> + Some (elem exp) + | { pexp_desc = + Pexp_construct ({ txt = Longident.Lident "None" }, None) } -> + None + | _ -> raise_errorf "Internal error: invalid [@@@ocaml.ppx.context \ + { %s }] option syntax" name + in + match name with + | "tool_name" -> + tool_name_ref := get_string payload + | "include_dirs" -> + Clflags.include_dirs := get_list get_string payload + | "load_path" -> + Config.load_path := get_list get_string payload + | "open_modules" -> + Clflags.open_modules := get_list get_string payload + | "for_package" -> + Clflags.for_package := get_option get_string payload + | "debug" -> + Clflags.debug := get_bool payload + | "use_threads" -> + Clflags.use_threads := get_bool payload + | "use_vmthreads" -> + Clflags.use_vmthreads := get_bool payload + | "cookies" -> + let l = get_list (get_pair get_string (fun x -> x)) payload in + cookies := + List.fold_left + (fun s (k, v) -> StringMap.add k v s) StringMap.empty + l + | _ -> + () + in + List.iter (function ({txt=Lident name}, x) -> field name x | _ -> ()) fields -let rec small_split_at n acc l = - if n <= 0 then rev acc , l - else - match l with - | x::xs -> small_split_at (n - 1) (x ::acc) xs - | _ -> invalid_arg "Ext_list.split_at" + let update_cookies fields = + let fields = + List.filter + (function ({txt=Lident "cookies"}, _) -> false | _ -> true) + fields + in + fields @ [get_cookies ()] +end -let split_at l n = - small_split_at n [] l +let ppx_context = PpxContext.make -let rec split_at_last_aux acc x = - match x with - | [] -> invalid_arg "Ext_list.split_at_last" - | [ x] -> rev acc, x - | y0::ys -> split_at_last_aux (y0::acc) ys +let extension_of_exn exn = + match error_of_exn exn with + | Some (`Ok error) -> extension_of_error error + | Some `Already_displayed -> { loc = Location.none; txt = "ocaml.error" }, PStr [] + | None -> raise exn -let split_at_last (x : 'a list) = - match x with - | [] -> invalid_arg "Ext_list.split_at_last" - | [a0] -> - [], a0 - | [a0;a1] -> - [a0], a1 - | [a0;a1;a2] -> - [a0;a1], a2 - | [a0;a1;a2;a3] -> - [a0;a1;a2], a3 - | [a0;a1;a2;a3;a4] -> - [a0;a1;a2;a3], a4 - | a0::a1::a2::a3::a4::rest -> - let rev, last = split_at_last_aux [] rest - in - a0::a1::a2::a3::a4:: rev , last -(** - can not do loop unroll due to state combination -*) -let filter_mapi xs f = - let rec aux i xs = - match xs with - | [] -> [] - | y :: ys -> - begin match f y i with - | None -> aux (i + 1) ys - | Some z -> z :: aux (i + 1) ys - end in - aux 0 xs +let apply_lazy ~source ~target mapper = + let implem ast = + let fields, ast = + match ast with + | {pstr_desc = Pstr_attribute ({txt = "ocaml.ppx.context"}, x)} :: l -> + PpxContext.get_fields x, l + | _ -> [], ast + in + PpxContext.restore fields; + let ast = + try + let mapper = mapper () in + mapper.structure mapper ast + with exn -> + [{pstr_desc = Pstr_extension (extension_of_exn exn, []); + pstr_loc = Location.none}] + in + let fields = PpxContext.update_cookies fields in + Str.attribute (PpxContext.mk fields) :: ast + in + let iface ast = + let fields, ast = + match ast with + | {psig_desc = Psig_attribute ({txt = "ocaml.ppx.context"}, x)} :: l -> + PpxContext.get_fields x, l + | _ -> [], ast + in + PpxContext.restore fields; + let ast = + try + let mapper = mapper () in + mapper.signature mapper ast + with exn -> + [{psig_desc = Psig_extension (extension_of_exn exn, []); + psig_loc = Location.none}] + in + let fields = PpxContext.update_cookies fields in + Sig.attribute (PpxContext.mk fields) :: ast + in -let rec filter_map2 xs ys (f: 'a -> 'b -> 'c option) = - match xs,ys with - | [],[] -> [] - | u::us, v :: vs -> - begin match f u v with - | None -> filter_map2 us vs f (* idea: rec f us vs instead? *) - | Some z -> z :: filter_map2 us vs f - end - | _ -> invalid_arg "Ext_list.filter_map2" + let ic = open_in_bin source in + let magic = + really_input_string ic (String.length Config.ast_impl_magic_number) + in + let rewrite transform = + Location.set_input_name @@ input_value ic; + let ast = input_value ic in + close_in ic; + let ast = transform ast in + let oc = open_out_bin target in + output_string oc magic; + output_value oc !Location.input_name; + output_value oc ast; + close_out oc + and fail () = + close_in ic; + failwith "Ast_mapper: OCaml version mismatch or malformed input"; + in -let rec rev_map_append l1 l2 f = - match l1 with - | [] -> l2 - | a :: l -> rev_map_append l (f a :: l2) f + if magic = Config.ast_impl_magic_number then + rewrite (implem : structure -> structure) + else if magic = Config.ast_intf_magic_number then + rewrite (iface : signature -> signature) + else fail () +let drop_ppx_context_str ~restore = function + | {pstr_desc = Pstr_attribute({Location.txt = "ocaml.ppx.context"}, a)} + :: items -> + if restore then + PpxContext.restore (PpxContext.get_fields a); + items + | items -> items +let drop_ppx_context_sig ~restore = function + | {psig_desc = Psig_attribute({Location.txt = "ocaml.ppx.context"}, a)} + :: items -> + if restore then + PpxContext.restore (PpxContext.get_fields a); + items + | items -> items -(** It is not worth loop unrolling, - it is already tail-call, and we need to be careful - about evaluation order when unroll -*) -let rec flat_map_aux f acc append lx = - match lx with - | [] -> rev_append acc append - | a0::rest -> flat_map_aux f (rev_append (f a0) acc ) append rest +let add_ppx_context_str ~tool_name ast = + Ast_helper.Str.attribute (ppx_context ~tool_name ()) :: ast -let flat_map lx f = - flat_map_aux f [] [] lx +let add_ppx_context_sig ~tool_name ast = + Ast_helper.Sig.attribute (ppx_context ~tool_name ()) :: ast -let flat_map_append lx append f = - flat_map_aux f [] append lx +let apply ~source ~target mapper = + apply_lazy ~source ~target (fun () -> mapper) -let rec length_compare l n = - if n < 0 then `Gt - else - begin match l with - | _ ::xs -> length_compare xs (n - 1) - | [] -> - if n = 0 then `Eq - else `Lt +let run_main mapper = + try + let a = Sys.argv in + let n = Array.length a in + if n > 2 then + let mapper () = + try mapper (Array.to_list (Array.sub a 1 (n - 3))) + with exn -> + (* PR#6463 *) + let f _ _ = raise exn in + {default_mapper with structure = f; signature = f} + in + apply_lazy ~source:a.(n - 2) ~target:a.(n - 1) mapper + else begin + Printf.eprintf "Usage: %s [extra_args] \n%!" + Sys.executable_name; + exit 2 end + with exn -> + prerr_endline (Printexc.to_string exn); + exit 2 -let rec length_ge l n = - if n > 0 then - match l with - | _ :: tl -> length_ge tl (n - 1) - | [] -> false - else true -(** +let register_function = ref (fun _name f -> run_main f) +let register name f = !register_function name f - {[length xs = length ys + n ]} -*) -let rec length_larger_than_n xs ys n = - match xs, ys with - | _, [] -> length_compare xs n = `Eq - | _::xs, _::ys -> - length_larger_than_n xs ys n - | [], _ -> false +end +module Pparse : sig +#1 "pparse.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Daniel de Rauglaudre, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 2002 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) +(** Driver for the parser, external preprocessors and ast plugin hooks *) +open Format +type error = + | CannotRun of string + | WrongMagic of string -let rec group (eq : 'a -> 'a -> bool) lst = - match lst with - | [] -> [] - | x::xs -> - aux eq x (group eq xs ) +exception Error of error -and aux eq (x : 'a) (xss : 'a list list) : 'a list list = - match xss with - | [] -> [[x]] - | (y0::_ as y)::ys -> (* cannot be empty *) - if eq x y0 then - (x::y) :: ys - else - y :: aux eq x ys - | _ :: _ -> assert false +val preprocess : string -> string +val remove_preprocessed : string -> unit -let stable_group lst eq = group eq lst |> rev +type 'a ast_kind = +| Structure : Parsetree.structure ast_kind +| Signature : Parsetree.signature ast_kind -let rec drop h n = - if n < 0 then invalid_arg "Ext_list.drop" - else - if n = 0 then h - else - match h with - | [] -> - invalid_arg "Ext_list.drop" - | _ :: tl -> - drop tl (n - 1) +val read_ast : 'a ast_kind -> string -> 'a +val write_ast : 'a ast_kind -> string -> 'a -> unit -let rec find_first x p = - match x with - | [] -> None - | x :: l -> - if p x then Some x - else find_first l p +val file : formatter -> tool_name:string -> string -> + (Lexing.lexbuf -> 'a) -> 'a ast_kind -> 'a -let rec find_first_not xs p = - match xs with - | [] -> None - | a::l -> - if p a - then find_first_not l p - else Some a +val apply_rewriters: ?restore:bool -> tool_name:string -> + 'a ast_kind -> 'a -> 'a + (** If [restore = true] (the default), cookies set by external + rewriters will be kept for later calls. *) +val apply_rewriters_str: + ?restore:bool -> tool_name:string -> Parsetree.structure -> + Parsetree.structure +val apply_rewriters_sig: + ?restore:bool -> tool_name:string -> Parsetree.signature -> + Parsetree.signature -let rec rev_iter l f = - match l with - | [] -> () - | [x1] -> - f x1 - | [x1; x2] -> - f x2 ; f x1 - | [x1; x2; x3] -> - f x3 ; f x2 ; f x1 - | [x1; x2; x3; x4] -> - f x4; f x3; f x2; f x1 - | x1::x2::x3::x4::x5::tail -> - rev_iter tail f; - f x5; f x4 ; f x3; f x2 ; f x1 +val report_error : formatter -> error -> unit -let rec iter l f = - match l with - | [] -> () - | [x1] -> - f x1 - | [x1; x2] -> - f x1 ; f x2 - | [x1; x2; x3] -> - f x1 ; f x2 ; f x3 - | [x1; x2; x3; x4] -> - f x1; f x2; f x3; f x4 - | x1::x2::x3::x4::x5::tail -> - f x1; f x2 ; f x3; f x4 ; f x5; - iter tail f +val parse_implementation: + formatter -> tool_name:string -> string -> Parsetree.structure +val parse_interface: + formatter -> tool_name:string -> string -> Parsetree.signature -let rec for_all lst p = - match lst with - [] -> true - | a::l -> p a && for_all l p +(* [call_external_preprocessor sourcefile pp] *) +val call_external_preprocessor : string -> string -> string +val open_and_check_magic : string -> string -> in_channel * bool + +module ImplementationHooks : Misc.HookSig with type t = Parsetree.structure +module InterfaceHooks : Misc.HookSig with type t = Parsetree.signature + +end = struct +#1 "pparse.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Daniel de Rauglaudre, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 2002 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -let rec for_all_snd lst p = - match lst with - [] -> true - | (_,a)::l -> p a && for_all_snd l p +open Format +type error = + | CannotRun of string + | WrongMagic of string -let rec for_all2_no_exn l1 l2 p = - match (l1, l2) with - | ([], []) -> true - | (a1::l1, a2::l2) -> p a1 a2 && for_all2_no_exn l1 l2 p - | (_, _) -> false +exception Error of error +(* Optionally preprocess a source file *) -let rec find_opt xs p = - match xs with - | [] -> None - | x :: l -> - match p x with - | Some _ as v -> v - | None -> find_opt l p +let call_external_preprocessor sourcefile pp = + let tmpfile = Filename.temp_file "ocamlpp" "" in + let comm = Printf.sprintf "%s %s > %s" + pp (Filename.quote sourcefile) tmpfile + in + if Ccomp.command comm <> 0 then begin + Misc.remove_file tmpfile; + raise (Error (CannotRun comm)); + end; + tmpfile +let preprocess sourcefile = + match !Clflags.preprocessor with + None -> sourcefile + | Some pp -> + Profile.record "-pp" + (call_external_preprocessor sourcefile) pp -let rec split_map l f = - match l with - | [] -> - [],[] - | [x1] -> - let a0,b0 = f x1 in - [a0],[b0] - | [x1; x2] -> - let a1,b1 = f x1 in - let a2,b2 = f x2 in - [a1;a2],[b1;b2] - | [x1; x2; x3] -> - let a1,b1 = f x1 in - let a2,b2 = f x2 in - let a3,b3 = f x3 in - [a1;a2;a3], [b1;b2;b3] - | [x1; x2; x3; x4] -> - let a1,b1 = f x1 in - let a2,b2 = f x2 in - let a3,b3 = f x3 in - let a4,b4 = f x4 in - [a1;a2;a3;a4], [b1;b2;b3;b4] - | x1::x2::x3::x4::x5::tail -> - let a1,b1 = f x1 in - let a2,b2 = f x2 in - let a3,b3 = f x3 in - let a4,b4 = f x4 in - let a5,b5 = f x5 in - let ass,bss = split_map tail f in - a1::a2::a3::a4::a5::ass, - b1::b2::b3::b4::b5::bss +let remove_preprocessed inputfile = + match !Clflags.preprocessor with + None -> () + | Some _ -> Misc.remove_file inputfile +type 'a ast_kind = +| Structure : Parsetree.structure ast_kind +| Signature : Parsetree.signature ast_kind +let magic_of_kind : type a . a ast_kind -> string = function + | Structure -> Config.ast_impl_magic_number + | Signature -> Config.ast_intf_magic_number +(* Note: some of the functions here should go to Ast_mapper instead, + which would encapsulate the "binary AST" protocol. *) -let sort_via_array lst cmp = - let arr = Array.of_list lst in - Array.sort cmp arr; - Array.to_list arr +let write_ast (type a) (kind : a ast_kind) fn (ast : a) = + let oc = open_out_bin fn in + output_string oc (magic_of_kind kind); + output_value oc (!Location.input_name : string); + output_value oc (ast : a); + close_out oc +let apply_rewriter kind fn_in ppx = + let magic = magic_of_kind kind in + let fn_out = Filename.temp_file "camlppx" "" in + let comm = + Printf.sprintf "%s %s %s" ppx (Filename.quote fn_in) (Filename.quote fn_out) + in + let ok = Ccomp.command comm = 0 in + Misc.remove_file fn_in; + if not ok then begin + Misc.remove_file fn_out; + raise (Error (CannotRun comm)); + end; + if not (Sys.file_exists fn_out) then + raise (Error (WrongMagic comm)); + (* check magic before passing to the next ppx *) + let ic = open_in_bin fn_out in + let buffer = + try really_input_string ic (String.length magic) with End_of_file -> "" in + close_in ic; + if buffer <> magic then begin + Misc.remove_file fn_out; + raise (Error (WrongMagic comm)); + end; + fn_out +let read_ast (type a) (kind : a ast_kind) fn : a = + let ic = open_in_bin fn in + try + let magic = magic_of_kind kind in + let buffer = really_input_string ic (String.length magic) in + assert(buffer = magic); (* already checked by apply_rewriter *) + Location.set_input_name @@ (input_value ic : string); + let ast = (input_value ic : a) in + close_in ic; + Misc.remove_file fn; + ast + with exn -> + close_in ic; + Misc.remove_file fn; + raise exn +let rewrite kind ppxs ast = + let fn = Filename.temp_file "camlppx" "" in + write_ast kind fn ast; + let fn = List.fold_left (apply_rewriter kind) fn (List.rev ppxs) in + read_ast kind fn -let rec assoc_by_string lst (k : string) def = - match lst with - | [] -> - begin match def with - | None -> assert false - | Some x -> x end - | (k1,v1)::rest -> - if k1 = k then v1 else - assoc_by_string rest k def +let apply_rewriters_str ?(restore = true) ~tool_name ast = + match !Clflags.all_ppx with + | [] -> ast + | ppxs -> + ast + |> Ast_mapper.add_ppx_context_str ~tool_name + |> rewrite Structure ppxs + |> Ast_mapper.drop_ppx_context_str ~restore -let rec assoc_by_int lst (k : int) def = - match lst with - | [] -> - begin match def with - | None -> assert false - | Some x -> x end - | (k1,v1)::rest -> - if k1 = k then v1 else - assoc_by_int rest k def +let apply_rewriters_sig ?(restore = true) ~tool_name ast = + match !Clflags.all_ppx with + | [] -> ast + | ppxs -> + ast + |> Ast_mapper.add_ppx_context_sig ~tool_name + |> rewrite Signature ppxs + |> Ast_mapper.drop_ppx_context_sig ~restore +let apply_rewriters ?restore ~tool_name + (type a) (kind : a ast_kind) (ast : a) : a = + match kind with + | Structure -> + apply_rewriters_str ?restore ~tool_name ast + | Signature -> + apply_rewriters_sig ?restore ~tool_name ast -let rec nth_aux l n = - match l with - | [] -> None - | a::l -> if n = 0 then Some a else nth_aux l (n-1) +(* Parse a file or get a dumped syntax tree from it *) -let nth_opt l n = - if n < 0 then None - else - nth_aux l n +exception Outdated_version -let rec iter_snd lst f = - match lst with - | [] -> () - | (_,x)::xs -> - f x ; - iter_snd xs f - -let rec iter_fst lst f = - match lst with - | [] -> () - | (x,_)::xs -> - f x ; - iter_fst xs f +let open_and_check_magic inputfile ast_magic = + let ic = open_in_bin inputfile in + let is_ast_file = + try + let buffer = really_input_string ic (String.length ast_magic) in + if buffer = ast_magic then true + else if String.sub buffer 0 9 = String.sub ast_magic 0 9 then + raise Outdated_version + else false + with + Outdated_version -> + Misc.fatal_error "OCaml and preprocessor have incompatible versions" + | _ -> false + in + (ic, is_ast_file) -let rec exists l p = - match l with - [] -> false - | x :: xs -> p x || exists xs p +let parse (type a) (kind : a ast_kind) lexbuf : a = + match kind with + | Structure -> Parse.implementation lexbuf + | Signature -> Parse.interface lexbuf -let rec exists_fst l p = - match l with - [] -> false - | (a,_)::l -> p a || exists_fst l p +let file_aux ppf ~tool_name inputfile (type a) parse_fun invariant_fun + (kind : a ast_kind) = + let ast_magic = magic_of_kind kind in + let (ic, is_ast_file) = open_and_check_magic inputfile ast_magic in + let ast = + try + if is_ast_file then begin + if !Clflags.fast then + (* FIXME make this a proper warning *) + fprintf ppf "@[Warning: %s@]@." + "option -unsafe used with a preprocessor returning a syntax tree"; + Location.set_input_name @@ (input_value ic : string); + (input_value ic : a) + end else begin + seek_in ic 0; + let lexbuf = Lexing.from_channel ic in + Location.init lexbuf inputfile; + Profile.record_call "parser" (fun () -> parse_fun lexbuf) + end + with x -> close_in ic; raise x + in + close_in ic; + let ast = + Profile.record_call "-ppx" (fun () -> + apply_rewriters ~restore:false ~tool_name kind ast) in + if is_ast_file || !Clflags.all_ppx <> [] then invariant_fun ast; + ast -let rec exists_snd l p = - match l with - [] -> false - | (_, a)::l -> p a || exists_snd l p +let file ppf ~tool_name inputfile parse_fun ast_kind = + file_aux ppf ~tool_name inputfile parse_fun ignore ast_kind -let rec concat_append - (xss : 'a list list) - (xs : 'a list) : 'a list = - match xss with - | [] -> xs - | l::r -> append l (concat_append r xs) +let report_error ppf = function + | CannotRun cmd -> + fprintf ppf "Error while running external preprocessor@.\ + Command line: %s@." cmd + | WrongMagic cmd -> + fprintf ppf "External preprocessor does not produce a valid file@.\ + Command line: %s@." cmd -let rec fold_left l accu f = - match l with - [] -> accu - | a::l -> fold_left l (f accu a) f - -let reduce_from_left lst fn = - match lst with - | first :: rest -> fold_left rest first fn - | _ -> invalid_arg "Ext_list.reduce_from_left" +let () = + Location.register_error_of_exn + (function + | Error err -> Some (Location.error_of_printer_file report_error err) + | _ -> None + ) -let rec fold_left2 l1 l2 accu f = - match (l1, l2) with - ([], []) -> accu - | (a1::l1, a2::l2) -> fold_left2 l1 l2 (f a1 a2 accu) f - | (_, _) -> invalid_arg "Ext_list.fold_left2" +let parse_file ~tool_name invariant_fun apply_hooks kind ppf sourcefile = + Location.set_input_name sourcefile; + let inputfile = preprocess sourcefile in + let ast = + try file_aux ppf ~tool_name inputfile (parse kind) invariant_fun kind + with exn -> + remove_preprocessed inputfile; + raise exn + in + remove_preprocessed inputfile; + let ast = apply_hooks { Misc.sourcefile } ast in + ast -let singleton_exn xs = match xs with [x] -> x | _ -> assert false +module ImplementationHooks = Misc.MakeHooks(struct + type t = Parsetree.structure + end) +module InterfaceHooks = Misc.MakeHooks(struct + type t = Parsetree.signature + end) -let rec mem_string (xs : string list) (x : string) = - match xs with - [] -> false - | a::l -> a = x || mem_string l x +let parse_implementation ppf ~tool_name sourcefile = + Profile.record_call "parsing" (fun () -> + parse_file ~tool_name Ast_invariants.structure + ImplementationHooks.apply_hooks Structure ppf sourcefile) +let parse_interface ppf ~tool_name sourcefile = + Profile.record_call "parsing" (fun () -> + parse_file ~tool_name Ast_invariants.signature + InterfaceHooks.apply_hooks Signature ppf sourcefile) end module Ext_pervasives : sig @@ -31287,440 +31760,57 @@ module Ext_js_regex : sig * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -(* This is a module that checks if js regex is valid or not *) - -val js_regex_checker : string -> bool -end = struct -#1 "ext_js_regex.ml" -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) - - -let check_from_end al = - let rec aux l seen = - match l with - | [] -> false - | (e::r) -> - if e < 0 || e > 255 then false - else (let c = Char.chr e in - if c = '/' then true - else (if Ext_list.exists seen (fun x -> x = c) then false (* flag should not be repeated *) - else (if c = 'i' || c = 'g' || c = 'm' || c = 'y' || c ='u' then aux r (c::seen) - else false))) - in aux al [] - -let js_regex_checker s = - match Ext_utf8.decode_utf8_string s with - | [] -> false - | 47 (* [Char.code '/' = 47 ]*)::tail -> - check_from_end (List.rev tail) - | _ :: _ -> false - | exception Ext_utf8.Invalid_utf8 _ -> false - -end -module Ext_array : sig -#1 "ext_array.mli" -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) - - - - - - -(** Some utilities for {!Array} operations *) -val reverse_range : 'a array -> int -> int -> unit -val reverse_in_place : 'a array -> unit -val reverse : 'a array -> 'a array -val reverse_of_list : 'a list -> 'a array - -val filter : ('a -> bool) -> 'a array -> 'a array - -val filter_map : ('a -> 'b option) -> 'a array -> 'b array - -val range : int -> int -> int array - -val map2i : (int -> 'a -> 'b -> 'c ) -> 'a array -> 'b array -> 'c array - -val to_list_f : - 'a array -> - ('a -> 'b) -> - 'b list - -val to_list_map : ('a -> 'b option) -> 'a array -> 'b list - -val to_list_map_acc : - 'a array -> - 'b list -> - ('a -> 'b option) -> - 'b list - -val of_list_map : - 'a list -> - ('a -> 'b) -> - 'b array - -val rfind_with_index : 'a array -> ('a -> 'b -> bool) -> 'b -> int - - -type 'a split = [ `No_split | `Split of 'a array * 'a array ] - -val rfind_and_split : - 'a array -> - ('a -> 'b -> bool) -> - 'b -> 'a split - -val find_and_split : - 'a array -> - ('a -> 'b -> bool) -> - 'b -> 'a split - -val exists : ('a -> bool) -> 'a array -> bool - -val is_empty : 'a array -> bool - -val for_all2_no_exn : - 'a array -> - 'b array -> - ('a -> 'b -> bool) -> - bool - -val map : - 'a array -> - ('a -> 'b) -> - 'b array - -val iter : - 'a array -> - ('a -> unit) -> - unit - -val fold_left : - 'b array -> - 'a -> - ('a -> 'b -> 'a) -> - 'a - -val get_or : - 'a array -> - int -> - (unit -> 'a) -> - 'a -end = struct -#1 "ext_array.ml" -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) - - - - - -let reverse_range a i len = - if len = 0 then () - else - for k = 0 to (len-1)/2 do - let t = Array.unsafe_get a (i+k) in - Array.unsafe_set a (i+k) ( Array.unsafe_get a (i+len-1-k)); - Array.unsafe_set a (i+len-1-k) t; - done - - -let reverse_in_place a = - reverse_range a 0 (Array.length a) - -let reverse a = - let b_len = Array.length a in - if b_len = 0 then [||] else - let b = Array.copy a in - for i = 0 to b_len - 1 do - Array.unsafe_set b i (Array.unsafe_get a (b_len - 1 -i )) - done; - b - -let reverse_of_list = function - | [] -> [||] - | hd::tl as l -> - let len = List.length l in - let a = Array.make len hd in - let rec fill i = function - | [] -> a - | hd::tl -> Array.unsafe_set a (len - i - 2) hd; fill (i+1) tl in - fill 0 tl - -let filter f a = - let arr_len = Array.length a in - let rec aux acc i = - if i = arr_len - then reverse_of_list acc - else - let v = Array.unsafe_get a i in - if f v then - aux (v::acc) (i+1) - else aux acc (i + 1) - in aux [] 0 - - -let filter_map (f : _ -> _ option) a = - let arr_len = Array.length a in - let rec aux acc i = - if i = arr_len - then reverse_of_list acc - else - let v = Array.unsafe_get a i in - match f v with - | Some v -> - aux (v::acc) (i+1) - | None -> - aux acc (i + 1) - in aux [] 0 - -let range from to_ = - if from > to_ then invalid_arg "Ext_array.range" - else Array.init (to_ - from + 1) (fun i -> i + from) - -let map2i f a b = - let len = Array.length a in - if len <> Array.length b then - invalid_arg "Ext_array.map2i" - else - Array.mapi (fun i a -> f i a ( Array.unsafe_get b i )) a - -let rec tolist_f_aux a f i res = - if i < 0 then res else - let v = Array.unsafe_get a i in - tolist_f_aux a f (i - 1) - (f v :: res) - -let to_list_f a f = tolist_f_aux a f (Array.length a - 1) [] - -let rec tolist_aux a f i res = - if i < 0 then res else - let v = Array.unsafe_get a i in - tolist_aux a f (i - 1) - (match f v with - | Some v -> v :: res - | None -> res) - -let to_list_map f a = - tolist_aux a f (Array.length a - 1) [] - -let to_list_map_acc a acc f = - tolist_aux a f (Array.length a - 1) acc - - -let of_list_map a f = - match a with - | [] -> [||] - | [a0] -> - let b0 = f a0 in - [|b0|] - | [a0;a1] -> - let b0 = f a0 in - let b1 = f a1 in - [|b0;b1|] - | [a0;a1;a2] -> - let b0 = f a0 in - let b1 = f a1 in - let b2 = f a2 in - [|b0;b1;b2|] - | [a0;a1;a2;a3] -> - let b0 = f a0 in - let b1 = f a1 in - let b2 = f a2 in - let b3 = f a3 in - [|b0;b1;b2;b3|] - | [a0;a1;a2;a3;a4] -> - let b0 = f a0 in - let b1 = f a1 in - let b2 = f a2 in - let b3 = f a3 in - let b4 = f a4 in - [|b0;b1;b2;b3;b4|] - - | a0::a1::a2::a3::a4::tl -> - let b0 = f a0 in - let b1 = f a1 in - let b2 = f a2 in - let b3 = f a3 in - let b4 = f a4 in - let len = List.length tl + 5 in - let arr = Array.make len b0 in - Array.unsafe_set arr 1 b1 ; - Array.unsafe_set arr 2 b2 ; - Array.unsafe_set arr 3 b3 ; - Array.unsafe_set arr 4 b4 ; - let rec fill i = function - | [] -> arr - | hd :: tl -> - Array.unsafe_set arr i (f hd); - fill (i + 1) tl in - fill 5 tl - -(** - {[ - # rfind_with_index [|1;2;3|] (=) 2;; - - : int = 1 - # rfind_with_index [|1;2;3|] (=) 1;; - - : int = 0 - # rfind_with_index [|1;2;3|] (=) 3;; - - : int = 2 - # rfind_with_index [|1;2;3|] (=) 4;; - - : int = -1 - ]} -*) -let rfind_with_index arr cmp v = - let len = Array.length arr in - let rec aux i = - if i < 0 then i - else if cmp (Array.unsafe_get arr i) v then i - else aux (i - 1) in - aux (len - 1) - -type 'a split = [ `No_split | `Split of 'a array * 'a array ] -let rfind_and_split arr cmp v : _ split = - let i = rfind_with_index arr cmp v in - if i < 0 then - `No_split - else - `Split (Array.sub arr 0 i , Array.sub arr (i + 1 ) (Array.length arr - i - 1 )) - - -let find_with_index arr cmp v = - let len = Array.length arr in - let rec aux i len = - if i >= len then -1 - else if cmp (Array.unsafe_get arr i ) v then i - else aux (i + 1) len in - aux 0 len - -let find_and_split arr cmp v : _ split = - let i = find_with_index arr cmp v in - if i < 0 then - `No_split - else - `Split (Array.sub arr 0 i, Array.sub arr (i + 1 ) (Array.length arr - i - 1)) - -(** TODO: available since 4.03, use {!Array.exists} *) - -let exists p a = - let n = Array.length a in - let rec loop i = - if i = n then false - else if p (Array.unsafe_get a i) then true - else loop (succ i) in - loop 0 - - -let is_empty arr = - Array.length arr = 0 - - -let rec unsafe_loop index len p xs ys = - if index >= len then true - else - p - (Array.unsafe_get xs index) - (Array.unsafe_get ys index) && - unsafe_loop (succ index) len p xs ys - -let for_all2_no_exn xs ys p = - let len_xs = Array.length xs in - let len_ys = Array.length ys in - len_xs = len_ys && - unsafe_loop 0 len_xs p xs ys +(* This is a module that checks if js regex is valid or not *) +val js_regex_checker : string -> bool +end = struct +#1 "ext_js_regex.ml" +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -let map a f = - let open Array in - let l = length a in - if l = 0 then [||] else begin - let r = make l (f(unsafe_get a 0)) in - for i = 1 to l - 1 do - unsafe_set r i (f(unsafe_get a i)) - done; - r - end -let iter a f = - let open Array in - for i = 0 to length a - 1 do f(unsafe_get a i) done +let check_from_end al = + let rec aux l seen = + match l with + | [] -> false + | (e::r) -> + if e < 0 || e > 255 then false + else (let c = Char.chr e in + if c = '/' then true + else (if Ext_list.exists seen (fun x -> x = c) then false (* flag should not be repeated *) + else (if c = 'i' || c = 'g' || c = 'm' || c = 'y' || c ='u' then aux r (c::seen) + else false))) + in aux al [] +let js_regex_checker s = + match Ext_utf8.decode_utf8_string s with + | [] -> false + | 47 (* [Char.code '/' = 47 ]*)::tail -> + check_from_end (List.rev tail) + | _ :: _ -> false + | exception Ext_utf8.Invalid_utf8 _ -> false - let fold_left a x f = - let open Array in - let r = ref x in - for i = 0 to length a - 1 do - r := f !r (unsafe_get a i) - done; - !r - -let get_or arr i cb = - if i >=0 && i < Array.length arr then - Array.unsafe_get arr i - else cb () end module Ext_bytes : sig #1 "ext_bytes.mli" @@ -36281,6 +36371,16 @@ let emit_external_warnings : iterator= | _ -> default_iterator.expr self a ); + label_declaration = (fun self lbl -> + + Ext_list.iter lbl.pld_attributes + (fun attr -> + match attr with + | {txt = "bs.as"}, _ -> mark_used_bs_attribute attr + | _ -> () + ); + default_iterator.label_declaration self lbl + ); value_description = (fun self v -> match v with diff --git a/lib/4.06.1/bsdep.ml.d b/lib/4.06.1/bsdep.ml.d index 98e6994acd..b6e7921c54 100644 --- a/lib/4.06.1/bsdep.ml.d +++ b/lib/4.06.1/bsdep.ml.d @@ -1 +1 @@ -../lib/4.06.1/bsdep.ml: ../ocaml/driver/compdynlink.mli ../ocaml/driver/compenv.ml ../ocaml/driver/compenv.mli ../ocaml/driver/compmisc.ml ../ocaml/driver/compmisc.mli ../ocaml/driver/compplugin.ml ../ocaml/driver/compplugin.mli ../ocaml/driver/makedepend.ml ../ocaml/driver/makedepend.mli ../ocaml/driver/pparse.ml ../ocaml/driver/pparse.mli ../ocaml/parsing/ast_helper.ml ../ocaml/parsing/ast_helper.mli ../ocaml/parsing/ast_invariants.ml ../ocaml/parsing/ast_invariants.mli ../ocaml/parsing/ast_iterator.ml ../ocaml/parsing/ast_iterator.mli ../ocaml/parsing/ast_mapper.ml ../ocaml/parsing/ast_mapper.mli ../ocaml/parsing/asttypes.mli ../ocaml/parsing/builtin_attributes.ml ../ocaml/parsing/builtin_attributes.mli ../ocaml/parsing/depend.ml ../ocaml/parsing/depend.mli ../ocaml/parsing/docstrings.ml ../ocaml/parsing/docstrings.mli ../ocaml/parsing/lexer.ml ../ocaml/parsing/lexer.mli ../ocaml/parsing/location.ml ../ocaml/parsing/location.mli ../ocaml/parsing/longident.ml ../ocaml/parsing/longident.mli ../ocaml/parsing/parse.ml ../ocaml/parsing/parse.mli ../ocaml/parsing/parser.ml ../ocaml/parsing/parser.mli ../ocaml/parsing/parsetree.mli ../ocaml/parsing/syntaxerr.ml ../ocaml/parsing/syntaxerr.mli ../ocaml/tools/ocamldep.ml ../ocaml/utils/arg_helper.ml ../ocaml/utils/arg_helper.mli ../ocaml/utils/ccomp.ml ../ocaml/utils/ccomp.mli ../ocaml/utils/clflags.ml ../ocaml/utils/clflags.mli ../ocaml/utils/identifiable.ml ../ocaml/utils/identifiable.mli ../ocaml/utils/misc.ml ../ocaml/utils/misc.mli ../ocaml/utils/numbers.ml ../ocaml/utils/numbers.mli ../ocaml/utils/profile.ml ../ocaml/utils/profile.mli ../ocaml/utils/terminfo.ml ../ocaml/utils/terminfo.mli ../ocaml/utils/warnings.ml ../ocaml/utils/warnings.mli ./common/bs_loc.ml ./common/bs_loc.mli ./common/bs_version.ml ./common/bs_version.mli ./common/bs_warnings.ml ./common/bs_warnings.mli ./common/js_config.ml ./common/js_config.mli ./common/lam_methname.ml ./common/lam_methname.mli ./core/bs_conditional_initial.ml ./core/bs_conditional_initial.mli ./core/config_whole_compiler.ml ./core/config_whole_compiler.mli ./core/lam_constant.ml ./core/lam_constant.mli ./core/lam_pointer_info.ml ./core/lam_pointer_info.mli ./core/lam_tag_info.ml ./ext/ext_array.ml ./ext/ext_array.mli ./ext/ext_bytes.ml ./ext/ext_bytes.mli ./ext/ext_char.ml ./ext/ext_char.mli ./ext/ext_filename.ml ./ext/ext_filename.mli ./ext/ext_fmt.ml ./ext/ext_js_regex.ml ./ext/ext_js_regex.mli ./ext/ext_json_parse.ml ./ext/ext_json_parse.mli ./ext/ext_json_types.ml ./ext/ext_list.ml ./ext/ext_list.mli ./ext/ext_option.ml ./ext/ext_option.mli ./ext/ext_pervasives.ml ./ext/ext_pervasives.mli ./ext/ext_position.ml ./ext/ext_position.mli ./ext/ext_ref.ml ./ext/ext_ref.mli ./ext/ext_string.ml ./ext/ext_string.mli ./ext/ext_utf8.ml ./ext/ext_utf8.mli ./ext/ext_util.ml ./ext/ext_util.mli ./ext/hash_set_gen.ml ./ext/hash_set_poly.ml ./ext/hash_set_poly.mli ./ext/literals.ml ./ext/literals.mli ./ext/map_gen.ml ./ext/string_hash_set.ml ./ext/string_hash_set.mli ./ext/string_map.ml ./ext/string_map.mli ./stubs/bs_hash_stubs.ml ./syntax/ast_attributes.ml ./syntax/ast_attributes.mli ./syntax/ast_bs_open.ml ./syntax/ast_bs_open.mli ./syntax/ast_comb.ml ./syntax/ast_comb.mli ./syntax/ast_compatible.ml ./syntax/ast_compatible.mli ./syntax/ast_core_type.ml ./syntax/ast_core_type.mli ./syntax/ast_core_type_class_type.ml ./syntax/ast_core_type_class_type.mli ./syntax/ast_derive.ml ./syntax/ast_derive.mli ./syntax/ast_derive_abstract.ml ./syntax/ast_derive_abstract.mli ./syntax/ast_derive_js_mapper.ml ./syntax/ast_derive_js_mapper.mli ./syntax/ast_derive_projector.ml ./syntax/ast_derive_projector.mli ./syntax/ast_derive_util.ml ./syntax/ast_derive_util.mli ./syntax/ast_exp.ml ./syntax/ast_exp.mli ./syntax/ast_exp_apply.ml ./syntax/ast_exp_apply.mli ./syntax/ast_exp_extension.ml ./syntax/ast_exp_extension.mli ./syntax/ast_external.ml ./syntax/ast_external.mli ./syntax/ast_external_mk.ml ./syntax/ast_external_mk.mli ./syntax/ast_external_process.ml ./syntax/ast_external_process.mli ./syntax/ast_literal.ml ./syntax/ast_literal.mli ./syntax/ast_open_cxt.ml ./syntax/ast_open_cxt.mli ./syntax/ast_pat.ml ./syntax/ast_pat.mli ./syntax/ast_payload.ml ./syntax/ast_payload.mli ./syntax/ast_polyvar.ml ./syntax/ast_polyvar.mli ./syntax/ast_signature.ml ./syntax/ast_signature.mli ./syntax/ast_structure.ml ./syntax/ast_structure.mli ./syntax/ast_tdcls.ml ./syntax/ast_tdcls.mli ./syntax/ast_tuple_pattern_flatten.ml ./syntax/ast_tuple_pattern_flatten.mli ./syntax/ast_utf8_string.ml ./syntax/ast_utf8_string.mli ./syntax/ast_utf8_string_interp.ml ./syntax/ast_utf8_string_interp.mli ./syntax/ast_util.ml ./syntax/ast_util.mli ./syntax/bs_ast_invariant.ml ./syntax/bs_ast_invariant.mli ./syntax/bs_ast_mapper.ml ./syntax/bs_ast_mapper.mli ./syntax/bs_builtin_ppx.ml ./syntax/bs_builtin_ppx.mli ./syntax/bs_syntaxerr.ml ./syntax/bs_syntaxerr.mli ./syntax/external_arg_spec.ml ./syntax/external_arg_spec.mli ./syntax/external_ffi_types.ml ./syntax/external_ffi_types.mli ./syntax/ppx_entry.ml ./syntax/reactjs_jsx_ppx_v2.ml ./syntax/reactjs_jsx_ppx_v3.ml \ No newline at end of file +../lib/4.06.1/bsdep.ml: ../ocaml/driver/compdynlink.mli ../ocaml/driver/compenv.ml ../ocaml/driver/compenv.mli ../ocaml/driver/compmisc.ml ../ocaml/driver/compmisc.mli ../ocaml/driver/compplugin.ml ../ocaml/driver/compplugin.mli ../ocaml/driver/makedepend.ml ../ocaml/driver/makedepend.mli ../ocaml/driver/pparse.ml ../ocaml/driver/pparse.mli ../ocaml/parsing/ast_helper.ml ../ocaml/parsing/ast_helper.mli ../ocaml/parsing/ast_invariants.ml ../ocaml/parsing/ast_invariants.mli ../ocaml/parsing/ast_iterator.ml ../ocaml/parsing/ast_iterator.mli ../ocaml/parsing/ast_mapper.ml ../ocaml/parsing/ast_mapper.mli ../ocaml/parsing/asttypes.mli ../ocaml/parsing/builtin_attributes.ml ../ocaml/parsing/builtin_attributes.mli ../ocaml/parsing/depend.ml ../ocaml/parsing/depend.mli ../ocaml/parsing/docstrings.ml ../ocaml/parsing/docstrings.mli ../ocaml/parsing/lexer.ml ../ocaml/parsing/lexer.mli ../ocaml/parsing/location.ml ../ocaml/parsing/location.mli ../ocaml/parsing/longident.ml ../ocaml/parsing/longident.mli ../ocaml/parsing/parse.ml ../ocaml/parsing/parse.mli ../ocaml/parsing/parser.ml ../ocaml/parsing/parser.mli ../ocaml/parsing/parsetree.mli ../ocaml/parsing/syntaxerr.ml ../ocaml/parsing/syntaxerr.mli ../ocaml/tools/ocamldep.ml ../ocaml/utils/arg_helper.ml ../ocaml/utils/arg_helper.mli ../ocaml/utils/ccomp.ml ../ocaml/utils/ccomp.mli ../ocaml/utils/clflags.ml ../ocaml/utils/clflags.mli ../ocaml/utils/identifiable.ml ../ocaml/utils/identifiable.mli ../ocaml/utils/misc.ml ../ocaml/utils/misc.mli ../ocaml/utils/numbers.ml ../ocaml/utils/numbers.mli ../ocaml/utils/profile.ml ../ocaml/utils/profile.mli ../ocaml/utils/terminfo.ml ../ocaml/utils/terminfo.mli ../ocaml/utils/warnings.ml ../ocaml/utils/warnings.mli ./common/bs_loc.ml ./common/bs_loc.mli ./common/bs_version.ml ./common/bs_version.mli ./common/bs_warnings.ml ./common/bs_warnings.mli ./common/js_config.ml ./common/js_config.mli ./common/lam_methname.ml ./common/lam_methname.mli ./core/bs_conditional_initial.ml ./core/bs_conditional_initial.mli ./core/config_whole_compiler.ml ./core/config_whole_compiler.mli ./core/lam_constant.ml ./core/lam_constant.mli ./core/lam_pointer_info.ml ./core/lam_pointer_info.mli ./core/lam_tag_info.ml ./core/record_attributes_check.ml ./ext/ext_array.ml ./ext/ext_array.mli ./ext/ext_bytes.ml ./ext/ext_bytes.mli ./ext/ext_char.ml ./ext/ext_char.mli ./ext/ext_filename.ml ./ext/ext_filename.mli ./ext/ext_fmt.ml ./ext/ext_js_regex.ml ./ext/ext_js_regex.mli ./ext/ext_json_parse.ml ./ext/ext_json_parse.mli ./ext/ext_json_types.ml ./ext/ext_list.ml ./ext/ext_list.mli ./ext/ext_option.ml ./ext/ext_option.mli ./ext/ext_pervasives.ml ./ext/ext_pervasives.mli ./ext/ext_position.ml ./ext/ext_position.mli ./ext/ext_ref.ml ./ext/ext_ref.mli ./ext/ext_string.ml ./ext/ext_string.mli ./ext/ext_utf8.ml ./ext/ext_utf8.mli ./ext/ext_util.ml ./ext/ext_util.mli ./ext/hash_set_gen.ml ./ext/hash_set_poly.ml ./ext/hash_set_poly.mli ./ext/literals.ml ./ext/literals.mli ./ext/map_gen.ml ./ext/string_hash_set.ml ./ext/string_hash_set.mli ./ext/string_map.ml ./ext/string_map.mli ./stubs/bs_hash_stubs.ml ./syntax/ast_attributes.ml ./syntax/ast_attributes.mli ./syntax/ast_bs_open.ml ./syntax/ast_bs_open.mli ./syntax/ast_comb.ml ./syntax/ast_comb.mli ./syntax/ast_compatible.ml ./syntax/ast_compatible.mli ./syntax/ast_core_type.ml ./syntax/ast_core_type.mli ./syntax/ast_core_type_class_type.ml ./syntax/ast_core_type_class_type.mli ./syntax/ast_derive.ml ./syntax/ast_derive.mli ./syntax/ast_derive_abstract.ml ./syntax/ast_derive_abstract.mli ./syntax/ast_derive_js_mapper.ml ./syntax/ast_derive_js_mapper.mli ./syntax/ast_derive_projector.ml ./syntax/ast_derive_projector.mli ./syntax/ast_derive_util.ml ./syntax/ast_derive_util.mli ./syntax/ast_exp.ml ./syntax/ast_exp.mli ./syntax/ast_exp_apply.ml ./syntax/ast_exp_apply.mli ./syntax/ast_exp_extension.ml ./syntax/ast_exp_extension.mli ./syntax/ast_external.ml ./syntax/ast_external.mli ./syntax/ast_external_mk.ml ./syntax/ast_external_mk.mli ./syntax/ast_external_process.ml ./syntax/ast_external_process.mli ./syntax/ast_literal.ml ./syntax/ast_literal.mli ./syntax/ast_open_cxt.ml ./syntax/ast_open_cxt.mli ./syntax/ast_pat.ml ./syntax/ast_pat.mli ./syntax/ast_payload.ml ./syntax/ast_payload.mli ./syntax/ast_polyvar.ml ./syntax/ast_polyvar.mli ./syntax/ast_signature.ml ./syntax/ast_signature.mli ./syntax/ast_structure.ml ./syntax/ast_structure.mli ./syntax/ast_tdcls.ml ./syntax/ast_tdcls.mli ./syntax/ast_tuple_pattern_flatten.ml ./syntax/ast_tuple_pattern_flatten.mli ./syntax/ast_utf8_string.ml ./syntax/ast_utf8_string.mli ./syntax/ast_utf8_string_interp.ml ./syntax/ast_utf8_string_interp.mli ./syntax/ast_util.ml ./syntax/ast_util.mli ./syntax/bs_ast_invariant.ml ./syntax/bs_ast_invariant.mli ./syntax/bs_ast_mapper.ml ./syntax/bs_ast_mapper.mli ./syntax/bs_builtin_ppx.ml ./syntax/bs_builtin_ppx.mli ./syntax/bs_syntaxerr.ml ./syntax/bs_syntaxerr.mli ./syntax/external_arg_spec.ml ./syntax/external_arg_spec.mli ./syntax/external_ffi_types.ml ./syntax/external_ffi_types.mli ./syntax/ppx_entry.ml ./syntax/reactjs_jsx_ppx_v2.ml ./syntax/reactjs_jsx_ppx_v3.ml \ No newline at end of file diff --git a/lib/4.06.1/bsppx.ml b/lib/4.06.1/bsppx.ml index f48483d8e8..e77016a61e 100644 --- a/lib/4.06.1/bsppx.ml +++ b/lib/4.06.1/bsppx.ml @@ -8098,7 +8098,13 @@ val find_opt : ('a -> 'b option) -> 'b option +val find_def : + 'a list -> + ('a -> 'b option) -> + 'b -> + 'b + val rev_iter : 'a list -> ('a -> unit) -> @@ -8798,7 +8804,13 @@ let rec find_opt xs p = | Some _ as v -> v | None -> find_opt l p - +let rec find_def xs p def = + match xs with + | [] -> def + | x::l -> + match p x with + | Some v -> v + | None -> find_def l p def let rec split_map l f = match l with @@ -15250,6 +15262,16 @@ let emit_external_warnings : iterator= | _ -> default_iterator.expr self a ); + label_declaration = (fun self lbl -> + + Ext_list.iter lbl.pld_attributes + (fun attr -> + match attr with + | {txt = "bs.as"}, _ -> mark_used_bs_attribute attr + | _ -> () + ); + default_iterator.label_declaration self lbl + ); value_description = (fun self v -> match v with @@ -18874,7 +18896,7 @@ end = struct * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -let version = "6.3.0-dev.1" +let version = "7.0.0-dev.2" let header = "// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE" let package_name = "bs-platform" diff --git a/lib/4.06.1/unstable/all_ounit_tests.ml b/lib/4.06.1/unstable/all_ounit_tests.ml index 28b6dcfad7..bc30e151a6 100644 --- a/lib/4.06.1/unstable/all_ounit_tests.ml +++ b/lib/4.06.1/unstable/all_ounit_tests.ml @@ -2017,7 +2017,13 @@ val find_opt : ('a -> 'b option) -> 'b option +val find_def : + 'a list -> + ('a -> 'b option) -> + 'b -> + 'b + val rev_iter : 'a list -> ('a -> unit) -> @@ -2717,7 +2723,13 @@ let rec find_opt xs p = | Some _ as v -> v | None -> find_opt l p - +let rec find_def xs p def = + match xs with + | [] -> def + | x::l -> + match p x with + | Some v -> v + | None -> find_def l p def let rec split_map l f = match l with diff --git a/lib/4.06.1/unstable/bsb_native.ml b/lib/4.06.1/unstable/bsb_native.ml index efe3c0e0ca..4ac6d1fae5 100644 --- a/lib/4.06.1/unstable/bsb_native.ml +++ b/lib/4.06.1/unstable/bsb_native.ml @@ -55,7 +55,7 @@ end = struct * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -let version = "6.3.0-dev.1" +let version = "7.0.0-dev.2" let header = "// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE" let package_name = "bs-platform" @@ -796,7 +796,13 @@ val find_opt : ('a -> 'b option) -> 'b option +val find_def : + 'a list -> + ('a -> 'b option) -> + 'b -> + 'b + val rev_iter : 'a list -> ('a -> unit) -> @@ -1496,7 +1502,13 @@ let rec find_opt xs p = | Some _ as v -> v | None -> find_opt l p - +let rec find_def xs p def = + match xs with + | [] -> def + | x::l -> + match p x with + | Some v -> v + | None -> find_def l p def let rec split_map l f = match l with diff --git a/lib/4.06.1/unstable/bspack.ml b/lib/4.06.1/unstable/bspack.ml index a7dd98a2b0..8d285adcd5 100644 --- a/lib/4.06.1/unstable/bspack.ml +++ b/lib/4.06.1/unstable/bspack.ml @@ -6026,6 +6026,10 @@ val check_deprecated_mutable_inclusion: def:Location.t -> use:Location.t -> Location.t -> Parsetree.attributes -> Parsetree.attributes -> string -> unit +val check_bs_attributes_inclusion: + (Parsetree.attributes -> + Parsetree.attributes -> string -> (string*string) option ) ref + val error_of_extension: Parsetree.extension -> Location.error val warning_attribute: ?ppwarning:bool -> Parsetree.attribute -> unit @@ -6166,6 +6170,11 @@ let check_deprecated_mutable_inclusion ~def ~use loc attrs1 attrs2 s = Location.deprecated ~def ~use loc (Printf.sprintf "mutating field %s" (cat s txt)) +let check_bs_attributes_inclusion = + ref (fun _attrs1 _attrs2 _s -> + None + ) + let rec deprecated_of_sig = function | {psig_desc = Psig_attribute a} :: tl -> begin match deprecated_of_attrs [a] with @@ -7607,7 +7616,13 @@ val find_opt : ('a -> 'b option) -> 'b option +val find_def : + 'a list -> + ('a -> 'b option) -> + 'b -> + 'b + val rev_iter : 'a list -> ('a -> unit) -> @@ -8307,7 +8322,13 @@ let rec find_opt xs p = | Some _ as v -> v | None -> find_opt l p - +let rec find_def xs p def = + match xs with + | [] -> def + | x::l -> + match p x with + | Some v -> v + | None -> find_def l p def let rec split_map l f = match l with diff --git a/lib/4.06.1/unstable/js_compiler.ml b/lib/4.06.1/unstable/js_compiler.ml index 6fe6619de4..0e0d76dfd9 100644 --- a/lib/4.06.1/unstable/js_compiler.ml +++ b/lib/4.06.1/unstable/js_compiler.ml @@ -7756,7 +7756,13 @@ val find_opt : ('a -> 'b option) -> 'b option +val find_def : + 'a list -> + ('a -> 'b option) -> + 'b -> + 'b + val rev_iter : 'a list -> ('a -> unit) -> @@ -8456,7 +8462,13 @@ let rec find_opt xs p = | Some _ as v -> v | None -> find_opt l p - +let rec find_def xs p def = + match xs with + | [] -> def + | x::l -> + match p x with + | Some v -> v + | None -> find_def l p def let rec split_map l f = match l with @@ -15157,6 +15169,16 @@ let emit_external_warnings : iterator= | _ -> default_iterator.expr self a ); + label_declaration = (fun self lbl -> + + Ext_list.iter lbl.pld_attributes + (fun attr -> + match attr with + | {txt = "bs.as"}, _ -> mark_used_bs_attribute attr + | _ -> () + ); + default_iterator.label_declaration self lbl + ); value_description = (fun self v -> match v with @@ -18781,7 +18803,7 @@ end = struct * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -let version = "6.3.0-dev.1" +let version = "7.0.0-dev.2" let header = "// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE" let package_name = "bs-platform" @@ -25432,18224 +25454,837 @@ let rewrite_implementation (x : Parsetree.structure) = end -module Parser : sig -#1 "parser.mli" -type token = - | AMPERAMPER - | AMPERSAND - | AND - | AS - | ASSERT - | BACKQUOTE - | BANG - | BAR - | BARBAR - | BARRBRACKET - | BEGIN - | CHAR of (char) - | CLASS - | COLON - | COLONCOLON - | COLONEQUAL - | COLONGREATER - | COMMA - | CONSTRAINT - | DO - | DONE - | DOT - | DOTDOT - | DOWNTO - | ELSE - | END - | EOF - | EQUAL - | EXCEPTION - | EXTERNAL - | FALSE - | FLOAT of (string * char option) - | FOR - | FUN - | FUNCTION - | FUNCTOR - | GREATER - | GREATERRBRACE - | GREATERRBRACKET - | IF - | IN - | INCLUDE - | INFIXOP0 of (string) - | INFIXOP1 of (string) - | INFIXOP2 of (string) - | INFIXOP3 of (string) - | INFIXOP4 of (string) - | DOTOP of (string) - | INHERIT - | INITIALIZER - | INT of (string * char option) - | LABEL of (string) - | LAZY - | LBRACE - | LBRACELESS - | LBRACKET - | LBRACKETBAR - | LBRACKETLESS - | LBRACKETGREATER - | LBRACKETPERCENT - | LBRACKETPERCENTPERCENT - | LESS - | LESSMINUS - | LET - | LIDENT of (string) - | LPAREN - | LBRACKETAT - | LBRACKETATAT - | LBRACKETATATAT - | MATCH - | METHOD - | MINUS - | MINUSDOT - | MINUSGREATER - | MODULE - | MUTABLE - | NEW - | NONREC - | OBJECT - | OF - | OPEN - | OPTLABEL of (string) - | OR - | PERCENT - | PLUS - | PLUSDOT - | PLUSEQ - | PREFIXOP of (string) - | PRIVATE - | QUESTION - | QUOTE - | RBRACE - | RBRACKET - | REC - | RPAREN - | SEMI - | SEMISEMI - | HASH - | HASHOP of (string) - | SIG - | STAR - | STRING of (string * string option) - | STRUCT - | THEN - | TILDE - | TO - | TRUE - | TRY - | TYPE - | UIDENT of (string) - | UNDERSCORE - | VAL - | VIRTUAL - | WHEN - | WHILE - | WITH - | COMMENT of (string * Location.t) - | DOCSTRING of (Docstrings.docstring) - | EOL - -val implementation : - (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Parsetree.structure -val interface : - (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Parsetree.signature -val toplevel_phrase : - (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Parsetree.toplevel_phrase -val use_file : - (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Parsetree.toplevel_phrase list -val parse_core_type : - (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Parsetree.core_type -val parse_expression : - (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Parsetree.expression -val parse_pattern : - (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Parsetree.pattern - -end = struct -#1 "parser.ml" -type token = - | AMPERAMPER - | AMPERSAND - | AND - | AS - | ASSERT - | BACKQUOTE - | BANG - | BAR - | BARBAR - | BARRBRACKET - | BEGIN - | CHAR of (char) - | CLASS - | COLON - | COLONCOLON - | COLONEQUAL - | COLONGREATER - | COMMA - | CONSTRAINT - | DO - | DONE - | DOT - | DOTDOT - | DOWNTO - | ELSE - | END - | EOF - | EQUAL - | EXCEPTION - | EXTERNAL - | FALSE - | FLOAT of (string * char option) - | FOR - | FUN - | FUNCTION - | FUNCTOR - | GREATER - | GREATERRBRACE - | GREATERRBRACKET - | IF - | IN - | INCLUDE - | INFIXOP0 of (string) - | INFIXOP1 of (string) - | INFIXOP2 of (string) - | INFIXOP3 of (string) - | INFIXOP4 of (string) - | DOTOP of (string) - | INHERIT - | INITIALIZER - | INT of (string * char option) - | LABEL of (string) - | LAZY - | LBRACE - | LBRACELESS - | LBRACKET - | LBRACKETBAR - | LBRACKETLESS - | LBRACKETGREATER - | LBRACKETPERCENT - | LBRACKETPERCENTPERCENT - | LESS - | LESSMINUS - | LET - | LIDENT of (string) - | LPAREN - | LBRACKETAT - | LBRACKETATAT - | LBRACKETATATAT - | MATCH - | METHOD - | MINUS - | MINUSDOT - | MINUSGREATER - | MODULE - | MUTABLE - | NEW - | NONREC - | OBJECT - | OF - | OPEN - | OPTLABEL of (string) - | OR - | PERCENT - | PLUS - | PLUSDOT - | PLUSEQ - | PREFIXOP of (string) - | PRIVATE - | QUESTION - | QUOTE - | RBRACE - | RBRACKET - | REC - | RPAREN - | SEMI - | SEMISEMI - | HASH - | HASHOP of (string) - | SIG - | STAR - | STRING of (string * string option) - | STRUCT - | THEN - | TILDE - | TO - | TRUE - | TRY - | TYPE - | UIDENT of (string) - | UNDERSCORE - | VAL - | VIRTUAL - | WHEN - | WHILE - | WITH - | COMMENT of (string * Location.t) - | DOCSTRING of (Docstrings.docstring) - | EOL +module Builtin_attributes : sig +#1 "builtin_attributes.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Alain Frisch, LexiFi *) +(* *) +(* Copyright 2012 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -open Parsing;; -let _ = parse_error;; -# 19 "parsing/parser.mly" -open Location -open Asttypes -open Longident -open Parsetree -open Ast_helper -open Docstrings +(* Support for some of the builtin attributes: -let mktyp d = Typ.mk ~loc:(symbol_rloc()) d -let mkpat d = Pat.mk ~loc:(symbol_rloc()) d -let mkexp d = Exp.mk ~loc:(symbol_rloc()) d -let mkmty ?attrs d = Mty.mk ~loc:(symbol_rloc()) ?attrs d -let mksig d = Sig.mk ~loc:(symbol_rloc()) d -let mkmod ?attrs d = Mod.mk ~loc:(symbol_rloc()) ?attrs d -let mkstr d = Str.mk ~loc:(symbol_rloc()) d -let mkclass ?attrs d = Cl.mk ~loc:(symbol_rloc()) ?attrs d -let mkcty ?attrs d = Cty.mk ~loc:(symbol_rloc()) ?attrs d -let mkctf ?attrs ?docs d = - Ctf.mk ~loc:(symbol_rloc()) ?attrs ?docs d -let mkcf ?attrs ?docs d = - Cf.mk ~loc:(symbol_rloc()) ?attrs ?docs d + ocaml.deprecated + ocaml.error + ocaml.ppwarning + ocaml.warning + ocaml.warnerror + ocaml.explicit_arity (for camlp4/camlp5) + ocaml.warn_on_literal_pattern + ocaml.deprecated_mutable + ocaml.immediate + ocaml.boxed / ocaml.unboxed +*) -let mkrhs rhs pos = mkloc rhs (rhs_loc pos) -let reloc_pat x = { x with ppat_loc = symbol_rloc () };; -let reloc_exp x = { x with pexp_loc = symbol_rloc () };; +val check_deprecated: Location.t -> Parsetree.attributes -> string -> unit +val check_deprecated_inclusion: + def:Location.t -> use:Location.t -> Location.t -> Parsetree.attributes -> + Parsetree.attributes -> string -> unit +val deprecated_of_attrs: Parsetree.attributes -> string option +val deprecated_of_sig: Parsetree.signature -> string option +val deprecated_of_str: Parsetree.structure -> string option -let mkoperator name pos = - let loc = rhs_loc pos in - Exp.mk ~loc (Pexp_ident(mkloc (Lident name) loc)) +val check_deprecated_mutable: + Location.t -> Parsetree.attributes -> string -> unit +val check_deprecated_mutable_inclusion: + def:Location.t -> use:Location.t -> Location.t -> Parsetree.attributes -> + Parsetree.attributes -> string -> unit -let mkpatvar name pos = - Pat.mk ~loc:(rhs_loc pos) (Ppat_var (mkrhs name pos)) +val check_bs_attributes_inclusion: + (Parsetree.attributes -> + Parsetree.attributes -> string -> (string*string) option ) ref -(* - Ghost expressions and patterns: - expressions and patterns that do not appear explicitly in the - source file they have the loc_ghost flag set to true. - Then the profiler will not try to instrument them and the - -annot option will not try to display their type. +val error_of_extension: Parsetree.extension -> Location.error - Every grammar rule that generates an element with a location must - make at most one non-ghost element, the topmost one. +val warning_attribute: ?ppwarning:bool -> Parsetree.attribute -> unit + (** Apply warning settings from the specified attribute. + "ocaml.warning"/"ocaml.warnerror" (and variants without the prefix) + are processed and other attributes are ignored. - How to tell whether your location must be ghost: - A location corresponds to a range of characters in the source file. - If the location contains a piece of code that is syntactically - valid (according to the documentation), and corresponds to the - AST node, then the location must be real; in all other cases, - it must be ghost. -*) -let ghexp d = Exp.mk ~loc:(symbol_gloc ()) d -let ghpat d = Pat.mk ~loc:(symbol_gloc ()) d -let ghtyp d = Typ.mk ~loc:(symbol_gloc ()) d -let ghloc d = { txt = d; loc = symbol_gloc () } -let ghstr d = Str.mk ~loc:(symbol_gloc()) d -let ghsig d = Sig.mk ~loc:(symbol_gloc()) d + Also implement ocaml.ppwarning (unless ~ppwarning:false is + passed). + *) -let mkinfix arg1 name arg2 = - mkexp(Pexp_apply(mkoperator name 2, [Nolabel, arg1; Nolabel, arg2])) +val warning_scope: + ?ppwarning:bool -> + Parsetree.attributes -> (unit -> 'a) -> 'a + (** Execute a function in a new scope for warning settings. This + means that the effect of any call to [warning_attribute] during + the execution of this function will be discarded after + execution. -let neg_string f = - if String.length f > 0 && f.[0] = '-' - then String.sub f 1 (String.length f - 1) - else "-" ^ f + The function also takes a list of attributes which are processed + with [warning_attribute] in the fresh scope before the function + is executed. + *) -let mkuminus name arg = - match name, arg.pexp_desc with - | "-", Pexp_constant(Pconst_integer (n,m)) -> - mkexp(Pexp_constant(Pconst_integer(neg_string n,m))) - | ("-" | "-."), Pexp_constant(Pconst_float (f, m)) -> - mkexp(Pexp_constant(Pconst_float(neg_string f, m))) - | _ -> - mkexp(Pexp_apply(mkoperator ("~" ^ name) 1, [Nolabel, arg])) +val warn_on_literal_pattern: Parsetree.attributes -> bool +val explicit_arity: Parsetree.attributes -> bool -let mkuplus name arg = - let desc = arg.pexp_desc in - match name, desc with - | "+", Pexp_constant(Pconst_integer _) - | ("+" | "+."), Pexp_constant(Pconst_float _) -> mkexp desc - | _ -> - mkexp(Pexp_apply(mkoperator ("~" ^ name) 1, [Nolabel, arg])) -let mkexp_cons consloc args loc = - Exp.mk ~loc (Pexp_construct(mkloc (Lident "::") consloc, Some args)) +val immediate: Parsetree.attributes -> bool -let mkpat_cons consloc args loc = - Pat.mk ~loc (Ppat_construct(mkloc (Lident "::") consloc, Some args)) +val has_unboxed: Parsetree.attributes -> bool +val has_boxed: Parsetree.attributes -> bool -let rec mktailexp nilloc = function - [] -> - let loc = { nilloc with loc_ghost = true } in - let nil = { txt = Lident "[]"; loc = loc } in - Exp.mk ~loc (Pexp_construct (nil, None)) - | e1 :: el -> - let exp_el = mktailexp nilloc el in - let loc = {loc_start = e1.pexp_loc.loc_start; - loc_end = exp_el.pexp_loc.loc_end; - loc_ghost = true} - in - let arg = Exp.mk ~loc (Pexp_tuple [e1; exp_el]) in - mkexp_cons {loc with loc_ghost = true} arg loc +end = struct +#1 "builtin_attributes.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Alain Frisch, LexiFi *) +(* *) +(* Copyright 2012 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -let rec mktailpat nilloc = function - [] -> - let loc = { nilloc with loc_ghost = true } in - let nil = { txt = Lident "[]"; loc = loc } in - Pat.mk ~loc (Ppat_construct (nil, None)) - | p1 :: pl -> - let pat_pl = mktailpat nilloc pl in - let loc = {loc_start = p1.ppat_loc.loc_start; - loc_end = pat_pl.ppat_loc.loc_end; - loc_ghost = true} - in - let arg = Pat.mk ~loc (Ppat_tuple [p1; pat_pl]) in - mkpat_cons {loc with loc_ghost = true} arg loc +open Asttypes +open Parsetree -let mkstrexp e attrs = - { pstr_desc = Pstr_eval (e, attrs); pstr_loc = e.pexp_loc } +let string_of_cst = function + | Pconst_string(s, _) -> Some s + | _ -> None -let mkexp_constraint e (t1, t2) = - match t1, t2 with - | Some t, None -> ghexp(Pexp_constraint(e, t)) - | _, Some t -> ghexp(Pexp_coerce(e, t1, t)) - | None, None -> assert false +let string_of_payload = function + | PStr[{pstr_desc=Pstr_eval({pexp_desc=Pexp_constant c},_)}] -> + string_of_cst c + | _ -> None -let mkexp_opt_constraint e = function - | None -> e - | Some constraint_ -> mkexp_constraint e constraint_ +let string_of_opt_payload p = + match string_of_payload p with + | Some s -> s + | None -> "" -let mkpat_opt_constraint p = function - | None -> p - | Some typ -> mkpat (Ppat_constraint(p, typ)) +let rec error_of_extension ext = + match ext with + | ({txt = ("ocaml.error"|"error") as txt; loc}, p) -> + let rec sub_from inner = + match inner with + | {pstr_desc=Pstr_extension (ext, _)} :: rest -> + error_of_extension ext :: sub_from rest + | _ :: rest -> + (Location.errorf ~loc + "Invalid syntax for sub-error of extension '%s'." txt) :: + sub_from rest + | [] -> [] + in + begin match p with + | PStr [] -> raise Location.Already_displayed_error + | PStr({pstr_desc=Pstr_eval + ({pexp_desc=Pexp_constant(Pconst_string(msg,_))}, _)}:: + {pstr_desc=Pstr_eval + ({pexp_desc=Pexp_constant(Pconst_string(if_highlight,_))}, _)}:: + inner) -> + Location.error ~loc ~if_highlight ~sub:(sub_from inner) msg + | PStr({pstr_desc=Pstr_eval + ({pexp_desc=Pexp_constant(Pconst_string(msg,_))}, _)}::inner) -> + Location.error ~loc ~sub:(sub_from inner) msg + | _ -> Location.errorf ~loc "Invalid syntax for extension '%s'." txt + end + | ({txt; loc}, _) -> + Location.errorf ~loc "Uninterpreted extension '%s'." txt -let array_function str name = - ghloc (Ldot(Lident str, (if !Clflags.fast then "unsafe_" ^ name else name))) +let cat s1 s2 = + if s2 = "" then s1 else + + if Clflags.bs_vscode then s1 ^ " " ^ s2 + else s1 ^ "\n" ^ s2 + -let syntax_error () = - raise Syntaxerr.Escape_error +let rec deprecated_of_attrs = function + | [] -> None + | ({txt = "ocaml.deprecated"|"deprecated"; _}, p) :: _ -> + Some (string_of_opt_payload p) + | _ :: tl -> deprecated_of_attrs tl -let unclosed opening_name opening_num closing_name closing_num = - raise(Syntaxerr.Error(Syntaxerr.Unclosed(rhs_loc opening_num, opening_name, - rhs_loc closing_num, closing_name))) +let check_deprecated loc attrs s = + match deprecated_of_attrs attrs with + | None -> () + | Some txt -> Location.deprecated loc (cat s txt) -let expecting pos nonterm = - raise Syntaxerr.(Error(Expecting(rhs_loc pos, nonterm))) +let check_deprecated_inclusion ~def ~use loc attrs1 attrs2 s = + match deprecated_of_attrs attrs1, deprecated_of_attrs attrs2 with + | None, _ | Some _, Some _ -> () + | Some txt, None -> Location.deprecated ~def ~use loc (cat s txt) -let not_expecting pos nonterm = - raise Syntaxerr.(Error(Not_expecting(rhs_loc pos, nonterm))) +let rec deprecated_mutable_of_attrs = function + | [] -> None + | ({txt = "ocaml.deprecated_mutable"|"deprecated_mutable"; _}, p) :: _ -> + Some (string_of_opt_payload p) + | _ :: tl -> deprecated_mutable_of_attrs tl -let bigarray_function str name = - ghloc (Ldot(Ldot(Lident "Bigarray", str), name)) +let check_deprecated_mutable loc attrs s = + match deprecated_mutable_of_attrs attrs with + | None -> () + | Some txt -> + Location.deprecated loc (Printf.sprintf "mutating field %s" (cat s txt)) -let bigarray_untuplify = function - { pexp_desc = Pexp_tuple explist; pexp_loc = _ } -> explist - | exp -> [exp] +let check_deprecated_mutable_inclusion ~def ~use loc attrs1 attrs2 s = + match deprecated_mutable_of_attrs attrs1, + deprecated_mutable_of_attrs attrs2 + with + | None, _ | Some _, Some _ -> () + | Some txt, None -> + Location.deprecated ~def ~use loc + (Printf.sprintf "mutating field %s" (cat s txt)) -let bigarray_get arr arg = - let get = if !Clflags.fast then "unsafe_get" else "get" in - match bigarray_untuplify arg with - [c1] -> - mkexp(Pexp_apply(ghexp(Pexp_ident(bigarray_function "Array1" get)), - [Nolabel, arr; Nolabel, c1])) - | [c1;c2] -> - mkexp(Pexp_apply(ghexp(Pexp_ident(bigarray_function "Array2" get)), - [Nolabel, arr; Nolabel, c1; Nolabel, c2])) - | [c1;c2;c3] -> - mkexp(Pexp_apply(ghexp(Pexp_ident(bigarray_function "Array3" get)), - [Nolabel, arr; Nolabel, c1; Nolabel, c2; Nolabel, c3])) - | coords -> - mkexp(Pexp_apply(ghexp(Pexp_ident(bigarray_function "Genarray" "get")), - [Nolabel, arr; Nolabel, ghexp(Pexp_array coords)])) +let check_bs_attributes_inclusion = + ref (fun _attrs1 _attrs2 _s -> + None + ) -let bigarray_set arr arg newval = - let set = if !Clflags.fast then "unsafe_set" else "set" in - match bigarray_untuplify arg with - [c1] -> - mkexp(Pexp_apply(ghexp(Pexp_ident(bigarray_function "Array1" set)), - [Nolabel, arr; Nolabel, c1; Nolabel, newval])) - | [c1;c2] -> - mkexp(Pexp_apply(ghexp(Pexp_ident(bigarray_function "Array2" set)), - [Nolabel, arr; Nolabel, c1; - Nolabel, c2; Nolabel, newval])) - | [c1;c2;c3] -> - mkexp(Pexp_apply(ghexp(Pexp_ident(bigarray_function "Array3" set)), - [Nolabel, arr; Nolabel, c1; - Nolabel, c2; Nolabel, c3; Nolabel, newval])) - | coords -> - mkexp(Pexp_apply(ghexp(Pexp_ident(bigarray_function "Genarray" "set")), - [Nolabel, arr; - Nolabel, ghexp(Pexp_array coords); - Nolabel, newval])) +let rec deprecated_of_sig = function + | {psig_desc = Psig_attribute a} :: tl -> + begin match deprecated_of_attrs [a] with + | None -> deprecated_of_sig tl + | Some _ as r -> r + end + | _ -> None -let lapply p1 p2 = - if !Clflags.applicative_functors - then Lapply(p1, p2) - else raise (Syntaxerr.Error(Syntaxerr.Applicative_path (symbol_rloc()))) -let exp_of_label lbl pos = - mkexp (Pexp_ident(mkrhs (Lident(Longident.last lbl)) pos)) +let rec deprecated_of_str = function + | {pstr_desc = Pstr_attribute a} :: tl -> + begin match deprecated_of_attrs [a] with + | None -> deprecated_of_str tl + | Some _ as r -> r + end + | _ -> None -let pat_of_label lbl pos = - mkpat (Ppat_var (mkrhs (Longident.last lbl) pos)) -let mk_newtypes newtypes exp = - List.fold_right (fun newtype exp -> mkexp (Pexp_newtype (newtype, exp))) - newtypes exp +let warning_attribute ?(ppwarning = true) = + let process loc txt errflag payload = + match string_of_payload payload with + | Some s -> + begin try Warnings.parse_options errflag s + with Arg.Bad _ -> + Location.prerr_warning loc + (Warnings.Attribute_payload + (txt, "Ill-formed list of warnings")) + end + | None -> + Location.prerr_warning loc + (Warnings.Attribute_payload + (txt, "A single string literal is expected")) + in + function + | ({txt = ("ocaml.warning"|"warning") as txt; loc}, payload) -> + process loc txt false payload + | ({txt = ("ocaml.warnerror"|"warnerror") as txt; loc}, payload) -> + process loc txt true payload + | {txt="ocaml.ppwarning"|"ppwarning"}, + PStr[{pstr_desc=Pstr_eval({pexp_desc=Pexp_constant + (Pconst_string (s, _))},_); + pstr_loc}] when ppwarning -> + Location.prerr_warning pstr_loc (Warnings.Preprocessor s) + | _ -> + () -let wrap_type_annotation newtypes core_type body = - let exp = mkexp(Pexp_constraint(body,core_type)) in - let exp = mk_newtypes newtypes exp in - (exp, ghtyp(Ptyp_poly(newtypes, Typ.varify_constructors newtypes core_type))) +let warning_scope ?ppwarning attrs f = + let prev = Warnings.backup () in + try + List.iter (warning_attribute ?ppwarning) (List.rev attrs); + let ret = f () in + Warnings.restore prev; + ret + with exn -> + Warnings.restore prev; + raise exn -let wrap_exp_attrs body (ext, attrs) = - (* todo: keep exact location for the entire attribute *) - let body = {body with pexp_attributes = attrs @ body.pexp_attributes} in - match ext with - | None -> body - | Some id -> ghexp(Pexp_extension (id, PStr [mkstrexp body []])) -let mkexp_attrs d attrs = - wrap_exp_attrs (mkexp d) attrs +let warn_on_literal_pattern = + List.exists + (function + | ({txt="ocaml.warn_on_literal_pattern"|"warn_on_literal_pattern"; _}, _) + -> true + | _ -> false + ) -let wrap_typ_attrs typ (ext, attrs) = - (* todo: keep exact location for the entire attribute *) - let typ = {typ with ptyp_attributes = attrs @ typ.ptyp_attributes} in - match ext with - | None -> typ - | Some id -> ghtyp(Ptyp_extension (id, PTyp typ)) +let explicit_arity = + List.exists + (function + | ({txt="ocaml.explicit_arity"|"explicit_arity"; _}, _) -> true + | _ -> false + ) -let mktyp_attrs d attrs = - wrap_typ_attrs (mktyp d) attrs +let immediate = + List.exists + (function + | ({txt="ocaml.immediate"|"immediate"; _}, _) -> true + | _ -> false + ) -let wrap_pat_attrs pat (ext, attrs) = - (* todo: keep exact location for the entire attribute *) - let pat = {pat with ppat_attributes = attrs @ pat.ppat_attributes} in - match ext with - | None -> pat - | Some id -> ghpat(Ppat_extension (id, PPat (pat, None))) +(* The "ocaml.boxed (default)" and "ocaml.unboxed (default)" + attributes cannot be input by the user, they are added by the + compiler when applying the default setting. This is done to record + in the .cmi the default used by the compiler when compiling the + source file because the default can change between compiler + invocations. *) -let mkpat_attrs d attrs = - wrap_pat_attrs (mkpat d) attrs +let check l (x, _) = List.mem x.txt l -let wrap_class_attrs body attrs = - {body with pcl_attributes = attrs @ body.pcl_attributes} -let wrap_class_type_attrs body attrs = - {body with pcty_attributes = attrs @ body.pcty_attributes} -let wrap_mod_attrs body attrs = - {body with pmod_attributes = attrs @ body.pmod_attributes} -let wrap_mty_attrs body attrs = - {body with pmty_attributes = attrs @ body.pmty_attributes} +let has_unboxed attr = + List.exists (check ["ocaml.unboxed"; "unboxed"]) + attr -let wrap_str_ext body ext = - match ext with - | None -> body - | Some id -> ghstr(Pstr_extension ((id, PStr [body]), [])) +let has_boxed attr = + List.exists (check ["ocaml.boxed"; "boxed"]) attr -let mkstr_ext d ext = - wrap_str_ext (mkstr d) ext +end +module Ident : sig +#1 "ident.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -let wrap_sig_ext body ext = - match ext with - | None -> body - | Some id -> ghsig(Psig_extension ((id, PSig [body]), [])) +(* Identifiers (unique names) *) -let mksig_ext d ext = - wrap_sig_ext (mksig d) ext +type t = { stamp: int; name: string; mutable flags: int } -let text_str pos = Str.text (rhs_text pos) -let text_sig pos = Sig.text (rhs_text pos) -let text_cstr pos = Cf.text (rhs_text pos) -let text_csig pos = Ctf.text (rhs_text pos) -let text_def pos = [Ptop_def (Str.text (rhs_text pos))] +include Identifiable.S with type t := t +(* Notes: + - [equal] compares identifiers by name + - [compare x y] is 0 if [same x y] is true. + - [compare] compares identifiers by binding location +*) -let extra_text text pos items = - let pre_extras = rhs_pre_extra_text pos in - let post_extras = rhs_post_extra_text pos in - text pre_extras @ items @ text post_extras -let extra_str pos items = extra_text Str.text pos items -let extra_sig pos items = extra_text Sig.text pos items -let extra_cstr pos items = extra_text Cf.text pos items -let extra_csig pos items = extra_text Ctf.text pos items -let extra_def pos items = - extra_text (fun txt -> [Ptop_def (Str.text txt)]) pos items +val create: string -> t +val create_persistent: string -> t +val create_predef_exn: string -> t +val rename: t -> t +val name: t -> string +val unique_name: t -> string +val unique_toplevel_name: t -> string +val persistent: t -> bool +val same: t -> t -> bool + (* Compare identifiers by binding location. + Two identifiers are the same either if they are both + non-persistent and have been created by the same call to + [new], or if they are both persistent and have the same + name. *) +val compare: t -> t -> int +val hide: t -> t + (* Return an identifier with same name as the given identifier, + but stamp different from any stamp returned by new. + When put in a 'a tbl, this identifier can only be looked + up by name. *) -let extra_rhs_core_type ct ~pos = - let docs = rhs_info pos in - { ct with ptyp_attributes = add_info_attrs docs ct.ptyp_attributes } +val make_global: t -> unit +val global: t -> bool +val is_predef_exn: t -> bool -type let_binding = - { lb_pattern: pattern; - lb_expression: expression; - lb_attributes: attributes; - lb_docs: docs Lazy.t; - lb_text: text Lazy.t; - lb_loc: Location.t; } +val binding_time: t -> int +val current_time: unit -> int +val set_current_time: int -> unit +val reinit: unit -> unit -type let_bindings = - { lbs_bindings: let_binding list; - lbs_rec: rec_flag; - lbs_extension: string Asttypes.loc option; - lbs_loc: Location.t } +type 'a tbl + (* Association tables from identifiers to type 'a. *) -let mklb first (p, e) attrs = - { lb_pattern = p; - lb_expression = e; - lb_attributes = attrs; - lb_docs = symbol_docs_lazy (); - lb_text = if first then empty_text_lazy - else symbol_text_lazy (); - lb_loc = symbol_rloc (); } +val empty: 'a tbl +val add: t -> 'a -> 'a tbl -> 'a tbl +val find_same: t -> 'a tbl -> 'a +val find_name: string -> 'a tbl -> t * 'a +val find_all: string -> 'a tbl -> (t * 'a) list +val fold_name: (t -> 'a -> 'b -> 'b) -> 'a tbl -> 'b -> 'b +val fold_all: (t -> 'a -> 'b -> 'b) -> 'a tbl -> 'b -> 'b +val iter: (t -> 'a -> unit) -> 'a tbl -> unit -let mklbs ext rf lb = - { lbs_bindings = [lb]; - lbs_rec = rf; - lbs_extension = ext ; - lbs_loc = symbol_rloc (); } -let addlb lbs lb = - { lbs with lbs_bindings = lb :: lbs.lbs_bindings } +(* Idents for sharing keys *) -let val_of_let_bindings lbs = - let bindings = - List.map - (fun lb -> - Vb.mk ~loc:lb.lb_loc ~attrs:lb.lb_attributes - ~docs:(Lazy.force lb.lb_docs) - ~text:(Lazy.force lb.lb_text) - lb.lb_pattern lb.lb_expression) - lbs.lbs_bindings - in - let str = mkstr(Pstr_value(lbs.lbs_rec, List.rev bindings)) in - match lbs.lbs_extension with - | None -> str - | Some id -> ghstr (Pstr_extension((id, PStr [str]), [])) +val make_key_generator : unit -> (t -> t) -let expr_of_let_bindings lbs body = - let bindings = - List.map - (fun lb -> - Vb.mk ~loc:lb.lb_loc ~attrs:lb.lb_attributes - lb.lb_pattern lb.lb_expression) - lbs.lbs_bindings - in - mkexp_attrs (Pexp_let(lbs.lbs_rec, List.rev bindings, body)) - (lbs.lbs_extension, []) +end = struct +#1 "ident.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -let class_of_let_bindings lbs body = - let bindings = - List.map - (fun lb -> - Vb.mk ~loc:lb.lb_loc ~attrs:lb.lb_attributes - lb.lb_pattern lb.lb_expression) - lbs.lbs_bindings - in - if lbs.lbs_extension <> None then - raise Syntaxerr.(Error(Not_expecting(lbs.lbs_loc, "extension"))); - mkclass(Pcl_let (lbs.lbs_rec, List.rev bindings, body)) +open Format +type t = { stamp: int; name: string; mutable flags: int } -(* Alternatively, we could keep the generic module type in the Parsetree - and extract the package type during type-checking. In that case, - the assertions below should be turned into explicit checks. *) -let package_type_of_module_type pmty = - let err loc s = - raise (Syntaxerr.Error (Syntaxerr.Invalid_package_type (loc, s))) - in - let map_cstr = function - | Pwith_type (lid, ptyp) -> - let loc = ptyp.ptype_loc in - if ptyp.ptype_params <> [] then - err loc "parametrized types are not supported"; - if ptyp.ptype_cstrs <> [] then - err loc "constrained types are not supported"; - if ptyp.ptype_private <> Public then - err loc "private types are not supported"; +let global_flag = 1 +let predef_exn_flag = 2 - (* restrictions below are checked by the 'with_constraint' rule *) - assert (ptyp.ptype_kind = Ptype_abstract); - assert (ptyp.ptype_attributes = []); - let ty = - match ptyp.ptype_manifest with - | Some ty -> ty - | None -> assert false - in - (lid, ty) - | _ -> - err pmty.pmty_loc "only 'with type t =' constraints are supported" - in - match pmty with - | {pmty_desc = Pmty_ident lid} -> (lid, []) - | {pmty_desc = Pmty_with({pmty_desc = Pmty_ident lid}, cstrs)} -> - (lid, List.map map_cstr cstrs) - | _ -> - err pmty.pmty_loc - "only module type identifier and 'with type' constraints are supported" +(* A stamp of 0 denotes a persistent identifier *) +let currentstamp = ref 0 -# 524 "parsing/parser.ml" -let yytransl_const = [| - 257 (* AMPERAMPER *); - 258 (* AMPERSAND *); - 259 (* AND *); - 260 (* AS *); - 261 (* ASSERT *); - 262 (* BACKQUOTE *); - 263 (* BANG *); - 264 (* BAR *); - 265 (* BARBAR *); - 266 (* BARRBRACKET *); - 267 (* BEGIN *); - 269 (* CLASS *); - 270 (* COLON *); - 271 (* COLONCOLON *); - 272 (* COLONEQUAL *); - 273 (* COLONGREATER *); - 274 (* COMMA *); - 275 (* CONSTRAINT *); - 276 (* DO *); - 277 (* DONE *); - 278 (* DOT *); - 279 (* DOTDOT *); - 280 (* DOWNTO *); - 281 (* ELSE *); - 282 (* END *); - 0 (* EOF *); - 283 (* EQUAL *); - 284 (* EXCEPTION *); - 285 (* EXTERNAL *); - 286 (* FALSE *); - 288 (* FOR *); - 289 (* FUN *); - 290 (* FUNCTION *); - 291 (* FUNCTOR *); - 292 (* GREATER *); - 293 (* GREATERRBRACE *); - 294 (* GREATERRBRACKET *); - 295 (* IF *); - 296 (* IN *); - 297 (* INCLUDE *); - 304 (* INHERIT *); - 305 (* INITIALIZER *); - 308 (* LAZY *); - 309 (* LBRACE *); - 310 (* LBRACELESS *); - 311 (* LBRACKET *); - 312 (* LBRACKETBAR *); - 313 (* LBRACKETLESS *); - 314 (* LBRACKETGREATER *); - 315 (* LBRACKETPERCENT *); - 316 (* LBRACKETPERCENTPERCENT *); - 317 (* LESS *); - 318 (* LESSMINUS *); - 319 (* LET *); - 321 (* LPAREN *); - 322 (* LBRACKETAT *); - 323 (* LBRACKETATAT *); - 324 (* LBRACKETATATAT *); - 325 (* MATCH *); - 326 (* METHOD *); - 327 (* MINUS *); - 328 (* MINUSDOT *); - 329 (* MINUSGREATER *); - 330 (* MODULE *); - 331 (* MUTABLE *); - 332 (* NEW *); - 333 (* NONREC *); - 334 (* OBJECT *); - 335 (* OF *); - 336 (* OPEN *); - 338 (* OR *); - 339 (* PERCENT *); - 340 (* PLUS *); - 341 (* PLUSDOT *); - 342 (* PLUSEQ *); - 344 (* PRIVATE *); - 345 (* QUESTION *); - 346 (* QUOTE *); - 347 (* RBRACE *); - 348 (* RBRACKET *); - 349 (* REC *); - 350 (* RPAREN *); - 351 (* SEMI *); - 352 (* SEMISEMI *); - 353 (* HASH *); - 355 (* SIG *); - 356 (* STAR *); - 358 (* STRUCT *); - 359 (* THEN *); - 360 (* TILDE *); - 361 (* TO *); - 362 (* TRUE *); - 363 (* TRY *); - 364 (* TYPE *); - 366 (* UNDERSCORE *); - 367 (* VAL *); - 368 (* VIRTUAL *); - 369 (* WHEN *); - 370 (* WHILE *); - 371 (* WITH *); - 374 (* EOL *); - 0|] +let create s = + incr currentstamp; + { name = s; stamp = !currentstamp; flags = 0 } -let yytransl_block = [| - 268 (* CHAR *); - 287 (* FLOAT *); - 298 (* INFIXOP0 *); - 299 (* INFIXOP1 *); - 300 (* INFIXOP2 *); - 301 (* INFIXOP3 *); - 302 (* INFIXOP4 *); - 303 (* DOTOP *); - 306 (* INT *); - 307 (* LABEL *); - 320 (* LIDENT *); - 337 (* OPTLABEL *); - 343 (* PREFIXOP *); - 354 (* HASHOP *); - 357 (* STRING *); - 365 (* UIDENT *); - 372 (* COMMENT *); - 373 (* DOCSTRING *); - 0|] +let create_predef_exn s = + incr currentstamp; + { name = s; stamp = !currentstamp; flags = predef_exn_flag } -let yylhs = "\255\255\ -\001\000\002\000\003\000\003\000\003\000\010\000\010\000\014\000\ -\014\000\004\000\016\000\016\000\017\000\017\000\017\000\017\000\ -\017\000\017\000\017\000\005\000\006\000\007\000\020\000\020\000\ -\021\000\021\000\023\000\023\000\024\000\024\000\024\000\024\000\ -\024\000\024\000\024\000\024\000\024\000\027\000\027\000\027\000\ -\027\000\027\000\027\000\027\000\027\000\027\000\027\000\027\000\ -\008\000\008\000\032\000\032\000\032\000\015\000\015\000\015\000\ -\015\000\015\000\015\000\015\000\015\000\015\000\015\000\015\000\ -\015\000\015\000\015\000\015\000\045\000\049\000\049\000\049\000\ -\039\000\040\000\040\000\050\000\051\000\022\000\022\000\022\000\ -\022\000\022\000\022\000\022\000\022\000\022\000\022\000\022\000\ -\009\000\009\000\009\000\054\000\054\000\054\000\054\000\054\000\ -\054\000\054\000\054\000\054\000\054\000\054\000\054\000\054\000\ -\054\000\054\000\042\000\060\000\063\000\063\000\063\000\057\000\ -\058\000\059\000\059\000\064\000\065\000\066\000\066\000\041\000\ -\043\000\043\000\068\000\069\000\072\000\072\000\072\000\071\000\ -\071\000\077\000\077\000\073\000\073\000\073\000\073\000\073\000\ -\073\000\073\000\078\000\078\000\078\000\078\000\078\000\078\000\ -\078\000\078\000\082\000\083\000\083\000\083\000\084\000\084\000\ -\085\000\085\000\085\000\085\000\085\000\085\000\085\000\086\000\ -\086\000\087\000\087\000\087\000\087\000\088\000\088\000\088\000\ -\088\000\088\000\074\000\074\000\074\000\074\000\074\000\097\000\ -\097\000\097\000\097\000\097\000\097\000\097\000\100\000\101\000\ -\101\000\102\000\102\000\103\000\103\000\103\000\103\000\103\000\ -\103\000\104\000\104\000\104\000\106\000\089\000\061\000\061\000\ -\107\000\108\000\044\000\044\000\109\000\110\000\012\000\012\000\ -\012\000\012\000\075\000\075\000\075\000\075\000\075\000\075\000\ -\075\000\075\000\116\000\116\000\113\000\113\000\112\000\112\000\ -\114\000\115\000\115\000\030\000\030\000\030\000\030\000\030\000\ -\030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ -\030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ -\030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ -\030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ -\030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ -\030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ -\030\000\030\000\030\000\030\000\030\000\030\000\118\000\118\000\ -\118\000\118\000\118\000\118\000\118\000\118\000\118\000\118\000\ -\118\000\118\000\118\000\118\000\118\000\118\000\118\000\118\000\ -\118\000\118\000\118\000\118\000\118\000\118\000\118\000\118\000\ -\118\000\118\000\118\000\118\000\118\000\118\000\118\000\118\000\ -\118\000\118\000\118\000\118\000\118\000\118\000\118\000\118\000\ -\118\000\118\000\118\000\118\000\118\000\118\000\118\000\118\000\ -\118\000\118\000\118\000\118\000\118\000\118\000\118\000\118\000\ -\118\000\118\000\118\000\118\000\118\000\118\000\079\000\079\000\ -\136\000\136\000\137\000\137\000\137\000\137\000\138\000\096\000\ -\096\000\139\000\139\000\139\000\139\000\139\000\139\000\033\000\ -\033\000\144\000\145\000\147\000\147\000\095\000\095\000\095\000\ -\121\000\121\000\148\000\148\000\148\000\122\000\122\000\122\000\ -\122\000\123\000\123\000\132\000\132\000\150\000\150\000\150\000\ -\151\000\151\000\135\000\135\000\153\000\153\000\133\000\133\000\ -\092\000\092\000\092\000\092\000\092\000\152\000\152\000\019\000\ -\019\000\019\000\019\000\019\000\019\000\019\000\019\000\019\000\ -\019\000\142\000\142\000\142\000\142\000\142\000\142\000\142\000\ -\142\000\142\000\155\000\155\000\155\000\155\000\117\000\117\000\ -\143\000\143\000\143\000\143\000\143\000\143\000\143\000\143\000\ -\143\000\143\000\143\000\143\000\143\000\143\000\143\000\143\000\ -\143\000\143\000\143\000\143\000\143\000\143\000\159\000\159\000\ -\159\000\159\000\159\000\159\000\159\000\154\000\154\000\154\000\ -\156\000\156\000\156\000\161\000\161\000\160\000\160\000\160\000\ -\160\000\162\000\162\000\163\000\163\000\035\000\164\000\164\000\ -\034\000\036\000\036\000\165\000\166\000\170\000\170\000\169\000\ -\169\000\169\000\169\000\169\000\169\000\169\000\169\000\169\000\ -\169\000\169\000\168\000\168\000\168\000\173\000\174\000\174\000\ -\176\000\176\000\177\000\175\000\175\000\175\000\178\000\076\000\ -\076\000\171\000\171\000\171\000\179\000\180\000\038\000\038\000\ -\056\000\119\000\182\000\182\000\182\000\182\000\183\000\183\000\ -\172\000\172\000\172\000\185\000\186\000\037\000\055\000\188\000\ -\188\000\188\000\188\000\188\000\188\000\189\000\189\000\189\000\ -\190\000\191\000\192\000\193\000\053\000\053\000\194\000\194\000\ -\194\000\194\000\195\000\195\000\141\000\141\000\093\000\093\000\ -\187\000\187\000\018\000\018\000\196\000\196\000\198\000\198\000\ -\198\000\198\000\198\000\149\000\149\000\199\000\199\000\199\000\ -\199\000\199\000\199\000\199\000\199\000\199\000\199\000\199\000\ -\199\000\199\000\199\000\199\000\199\000\199\000\199\000\199\000\ -\031\000\202\000\202\000\203\000\203\000\201\000\201\000\205\000\ -\205\000\206\000\206\000\204\000\204\000\098\000\098\000\080\000\ -\080\000\184\000\184\000\200\000\200\000\200\000\200\000\200\000\ -\200\000\200\000\209\000\207\000\208\000\090\000\131\000\131\000\ -\131\000\131\000\157\000\157\000\157\000\157\000\157\000\067\000\ -\067\000\140\000\140\000\140\000\140\000\140\000\210\000\210\000\ -\210\000\210\000\210\000\210\000\210\000\210\000\210\000\210\000\ -\210\000\210\000\210\000\210\000\210\000\210\000\210\000\210\000\ -\210\000\210\000\210\000\210\000\210\000\210\000\210\000\210\000\ -\210\000\210\000\210\000\181\000\181\000\181\000\181\000\181\000\ -\181\000\130\000\130\000\124\000\124\000\124\000\124\000\124\000\ -\124\000\124\000\129\000\129\000\158\000\158\000\025\000\025\000\ -\197\000\197\000\197\000\052\000\052\000\099\000\099\000\081\000\ -\081\000\011\000\011\000\011\000\011\000\011\000\011\000\011\000\ -\125\000\146\000\146\000\167\000\167\000\126\000\126\000\094\000\ -\094\000\091\000\091\000\070\000\070\000\105\000\105\000\105\000\ -\105\000\105\000\062\000\062\000\120\000\120\000\134\000\134\000\ -\127\000\127\000\128\000\128\000\211\000\211\000\211\000\211\000\ -\211\000\211\000\211\000\211\000\211\000\211\000\211\000\211\000\ -\211\000\211\000\211\000\211\000\211\000\211\000\211\000\211\000\ -\211\000\211\000\211\000\211\000\211\000\211\000\211\000\211\000\ -\211\000\211\000\211\000\211\000\211\000\211\000\211\000\211\000\ -\211\000\211\000\211\000\211\000\211\000\211\000\211\000\211\000\ -\211\000\211\000\211\000\211\000\211\000\211\000\211\000\111\000\ -\111\000\028\000\213\000\047\000\013\000\013\000\026\000\026\000\ -\048\000\048\000\048\000\029\000\046\000\212\000\212\000\212\000\ -\212\000\212\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000" +let create_persistent s = + { name = s; stamp = 0; flags = global_flag } -let yylen = "\002\000\ -\002\000\002\000\002\000\002\000\001\000\002\000\001\000\000\000\ -\002\000\001\000\001\000\003\000\001\000\002\000\004\000\003\000\ -\003\000\002\000\002\000\002\000\002\000\002\000\002\000\005\000\ -\001\000\001\000\002\000\001\000\001\000\004\000\004\000\005\000\ -\002\000\003\000\001\000\002\000\001\000\005\000\005\000\003\000\ -\003\000\005\000\007\000\009\000\007\000\006\000\006\000\005\000\ -\003\000\001\000\000\000\002\000\002\000\001\000\001\000\001\000\ -\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\ -\001\000\001\000\002\000\001\000\004\000\002\000\004\000\002\000\ -\005\000\001\000\002\000\006\000\005\000\001\000\004\000\004\000\ -\005\000\003\000\003\000\005\000\003\000\003\000\001\000\002\000\ -\000\000\002\000\002\000\001\000\001\000\001\000\001\000\001\000\ -\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\ -\002\000\001\000\005\000\004\000\002\000\006\000\003\000\005\000\ -\006\000\001\000\002\000\007\000\006\000\000\000\002\000\006\000\ -\001\000\002\000\007\000\007\000\002\000\004\000\002\000\000\000\ -\003\000\003\000\002\000\001\000\003\000\002\000\003\000\007\000\ -\002\000\001\000\004\000\001\000\004\000\004\000\005\000\005\000\ -\003\000\003\000\002\000\003\000\005\000\000\000\000\000\002\000\ -\006\000\003\000\003\000\004\000\004\000\002\000\001\000\002\000\ -\000\000\007\000\007\000\006\000\007\000\007\000\007\000\005\000\ -\008\000\011\000\001\000\006\000\004\000\005\000\003\000\004\000\ -\001\000\004\000\004\000\002\000\001\000\007\000\002\000\003\000\ -\000\000\000\000\002\000\004\000\004\000\007\000\004\000\002\000\ -\001\000\005\000\005\000\003\000\003\000\003\000\001\000\002\000\ -\008\000\008\000\001\000\002\000\009\000\008\000\001\000\002\000\ -\003\000\005\000\005\000\002\000\005\000\002\000\004\000\002\000\ -\002\000\001\000\001\000\001\000\000\000\002\000\001\000\003\000\ -\001\000\001\000\003\000\001\000\002\000\003\000\007\000\006\000\ -\007\000\004\000\004\000\007\000\006\000\006\000\005\000\001\000\ -\002\000\002\000\007\000\005\000\006\000\010\000\003\000\003\000\ -\003\000\003\000\003\000\003\000\003\000\003\000\003\000\003\000\ -\003\000\003\000\003\000\003\000\003\000\003\000\003\000\003\000\ -\003\000\003\000\003\000\002\000\002\000\005\000\007\000\007\000\ -\007\000\007\000\007\000\007\000\009\000\009\000\009\000\003\000\ -\003\000\003\000\004\000\004\000\002\000\001\000\001\000\001\000\ -\001\000\001\000\003\000\003\000\004\000\003\000\004\000\004\000\ -\003\000\005\000\004\000\005\000\005\000\005\000\005\000\005\000\ -\005\000\005\000\005\000\005\000\005\000\005\000\007\000\007\000\ -\007\000\007\000\007\000\007\000\005\000\005\000\003\000\003\000\ -\005\000\005\000\004\000\004\000\002\000\006\000\004\000\006\000\ -\004\000\004\000\006\000\004\000\006\000\002\000\002\000\003\000\ -\003\000\003\000\002\000\005\000\004\000\005\000\003\000\003\000\ -\005\000\007\000\006\000\009\000\008\000\001\000\001\000\002\000\ -\001\000\001\000\002\000\002\000\002\000\002\000\001\000\001\000\ -\002\000\002\000\004\000\007\000\008\000\003\000\005\000\001\000\ -\002\000\005\000\004\000\001\000\003\000\002\000\002\000\005\000\ -\001\000\003\000\003\000\005\000\003\000\002\000\004\000\002\000\ -\005\000\003\000\003\000\003\000\001\000\001\000\003\000\002\000\ -\004\000\002\000\002\000\003\000\003\000\001\000\001\000\003\000\ -\002\000\004\000\002\000\002\000\002\000\001\000\000\000\003\000\ -\003\000\001\000\003\000\003\000\003\000\003\000\003\000\002\000\ -\001\000\003\000\003\000\001\000\003\000\003\000\003\000\003\000\ -\002\000\001\000\001\000\002\000\002\000\003\000\001\000\001\000\ -\001\000\001\000\003\000\001\000\001\000\002\000\001\000\003\000\ -\004\000\004\000\005\000\005\000\004\000\003\000\003\000\005\000\ -\005\000\004\000\005\000\007\000\007\000\001\000\003\000\003\000\ -\004\000\004\000\004\000\002\000\004\000\003\000\003\000\003\000\ -\003\000\003\000\003\000\001\000\003\000\001\000\002\000\004\000\ -\003\000\004\000\002\000\002\000\000\000\006\000\001\000\002\000\ -\008\000\001\000\002\000\008\000\007\000\003\000\000\000\000\000\ -\002\000\003\000\002\000\003\000\002\000\003\000\005\000\005\000\ -\005\000\007\000\000\000\001\000\003\000\002\000\001\000\003\000\ -\002\000\001\000\002\000\000\000\001\000\001\000\002\000\001\000\ -\003\000\001\000\001\000\002\000\003\000\004\000\001\000\007\000\ -\006\000\003\000\000\000\002\000\004\000\002\000\001\000\003\000\ -\001\000\001\000\002\000\005\000\007\000\009\000\009\000\001\000\ -\001\000\001\000\001\000\002\000\002\000\001\000\001\000\002\000\ -\003\000\004\000\004\000\005\000\001\000\003\000\006\000\005\000\ -\004\000\004\000\001\000\002\000\002\000\003\000\001\000\003\000\ -\001\000\003\000\001\000\002\000\001\000\004\000\001\000\006\000\ -\004\000\005\000\003\000\001\000\003\000\002\000\001\000\001\000\ -\002\000\004\000\003\000\002\000\002\000\003\000\005\000\003\000\ -\004\000\005\000\004\000\002\000\004\000\006\000\005\000\001\000\ -\001\000\001\000\003\000\001\000\001\000\005\000\002\000\001\000\ -\000\000\001\000\003\000\001\000\002\000\001\000\003\000\001\000\ -\003\000\001\000\003\000\002\000\002\000\001\000\001\000\001\000\ -\001\000\001\000\004\000\006\000\002\000\001\000\001\000\001\000\ -\001\000\001\000\001\000\002\000\002\000\002\000\002\000\001\000\ -\001\000\001\000\003\000\003\000\002\000\003\000\001\000\001\000\ -\001\000\001\000\001\000\001\000\003\000\004\000\003\000\004\000\ -\003\000\004\000\001\000\001\000\001\000\001\000\001\000\001\000\ -\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\ -\001\000\001\000\001\000\001\000\002\000\002\000\003\000\001\000\ -\001\000\001\000\003\000\001\000\005\000\002\000\002\000\003\000\ -\001\000\001\000\001\000\003\000\001\000\003\000\001\000\003\000\ -\001\000\003\000\004\000\001\000\003\000\001\000\003\000\001\000\ -\003\000\002\000\003\000\003\000\003\000\003\000\003\000\003\000\ -\002\000\000\000\001\000\000\000\001\000\001\000\001\000\000\000\ -\001\000\000\000\001\000\000\000\001\000\000\000\001\000\001\000\ -\002\000\002\000\000\000\001\000\000\000\001\000\000\000\001\000\ -\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\ -\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\ -\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\ -\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\ -\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\ -\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\ -\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\ -\003\000\004\000\004\000\004\000\000\000\002\000\000\000\002\000\ -\000\000\002\000\003\000\004\000\004\000\001\000\002\000\002\000\ -\002\000\004\000\002\000\002\000\002\000\002\000\002\000\002\000\ -\002\000" +let rename i = + incr currentstamp; + { i with stamp = !currentstamp } -let yydefred = "\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\112\002\000\000\000\000\000\000\ -\169\002\114\002\000\000\000\000\000\000\000\000\000\000\111\002\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\217\002\218\002\000\000\000\000\ -\000\000\000\000\219\002\220\002\000\000\000\000\113\002\170\002\ -\000\000\000\000\175\002\030\001\000\000\000\000\035\003\000\000\ -\000\000\000\000\000\000\094\001\000\000\050\000\000\000\055\000\ -\056\000\000\000\058\000\059\000\060\000\000\000\062\000\063\000\ -\000\000\000\000\066\000\000\000\068\000\074\000\007\002\121\000\ -\000\000\203\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\031\001\032\001\162\002\112\001\226\001\000\000\000\000\000\000\ -\000\000\000\000\000\000\036\003\000\000\093\000\092\000\000\000\ -\100\000\101\000\000\000\000\000\106\000\000\000\095\000\096\000\ -\097\000\098\000\000\000\102\000\000\000\114\000\199\000\005\000\ -\000\000\037\003\000\000\000\000\000\000\007\000\000\000\013\000\ -\000\000\038\003\000\000\000\000\000\000\010\000\011\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\177\002\063\002\039\003\000\000\080\002\055\002\000\000\ -\064\002\051\002\000\000\000\000\000\000\040\003\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\122\002\000\000\000\000\ -\000\000\000\000\177\001\041\003\000\000\000\000\198\001\171\001\ -\000\000\000\000\115\002\175\001\176\001\000\000\161\001\000\000\ -\183\001\000\000\000\000\000\000\000\000\121\002\120\002\193\002\ -\079\001\033\001\034\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\133\001\000\000\083\001\110\002\000\000\ -\000\000\000\000\166\002\000\000\000\000\069\001\000\000\223\002\ -\224\002\225\002\226\002\227\002\228\002\229\002\230\002\231\002\ -\232\002\233\002\234\002\235\002\236\002\237\002\238\002\239\002\ -\240\002\241\002\242\002\243\002\244\002\245\002\246\002\247\002\ -\221\002\248\002\249\002\250\002\251\002\252\002\253\002\254\002\ -\255\002\000\003\001\003\002\003\003\003\004\003\005\003\006\003\ -\007\003\008\003\009\003\010\003\222\002\011\003\012\003\013\003\ -\014\003\015\003\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\125\002\152\002\151\002\000\000\150\002\000\000\153\002\ -\146\002\148\002\128\002\129\002\130\002\131\002\132\002\000\000\ -\147\002\000\000\000\000\000\000\149\002\155\002\000\000\000\000\ -\154\002\000\000\167\002\139\002\145\002\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\212\002\000\000\078\001\ -\052\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\ -\000\000\000\000\053\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\029\001\000\000\000\000\113\001\ -\000\000\227\001\000\000\075\000\000\000\122\000\000\000\204\000\ -\067\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\095\001\098\001\000\000\000\000\ -\000\000\012\001\013\001\000\000\000\000\000\000\000\000\090\000\ -\000\000\002\000\105\000\091\000\000\000\115\000\000\000\200\000\ -\000\000\003\000\004\000\006\000\009\000\014\000\000\000\000\000\ -\000\000\019\000\000\000\018\000\000\000\173\002\000\000\085\002\ -\000\000\000\000\214\002\000\000\076\002\000\000\106\002\068\002\ -\000\000\000\000\000\000\000\000\000\000\000\000\103\002\000\000\ -\000\000\000\000\000\000\000\000\000\000\062\002\184\002\000\000\ -\069\002\020\000\052\002\000\000\000\000\000\000\000\000\000\000\ -\000\000\065\002\021\000\000\000\000\000\171\002\000\000\000\000\ -\000\000\000\000\000\000\000\000\204\001\000\000\140\002\000\000\ -\144\002\000\000\000\000\142\002\127\002\000\000\117\002\116\002\ -\119\002\118\002\182\001\000\000\000\000\000\000\000\000\022\000\ -\160\001\000\000\172\001\173\001\000\000\000\000\000\000\000\000\ -\026\003\000\000\000\000\000\000\000\000\038\001\000\000\000\000\ -\205\002\000\000\160\002\000\000\000\000\161\002\156\002\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\218\000\180\001\181\001\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\035\000\037\000\000\000\000\000\000\000\ -\000\000\000\000\150\001\000\000\064\001\063\001\000\000\000\000\ -\082\001\081\001\000\000\139\001\000\000\000\000\000\000\000\000\ -\000\000\030\003\000\000\000\000\000\000\000\000\000\000\000\000\ -\195\002\000\000\168\002\000\000\000\000\000\000\126\002\000\000\ -\036\001\035\001\000\000\124\002\123\002\000\000\000\000\000\000\ -\000\000\000\000\080\001\000\000\000\000\151\000\000\000\000\000\ -\197\002\000\000\000\000\000\000\000\000\049\000\022\003\000\000\ -\000\000\000\000\000\000\000\000\176\002\163\002\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\209\000\000\000\000\000\230\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\103\001\ -\101\001\087\001\000\000\100\001\096\001\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\087\000\078\000\ -\180\002\000\000\000\000\000\000\000\000\000\000\000\000\191\002\ -\188\002\187\002\192\002\000\000\189\002\017\000\000\000\016\000\ -\012\000\084\002\000\000\082\002\000\000\087\002\072\002\000\000\ -\000\000\000\000\000\000\109\002\067\002\100\002\101\002\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\098\002\000\000\ -\174\002\178\002\000\000\000\000\000\000\070\002\159\001\174\001\ -\000\000\000\000\000\000\200\001\199\001\000\000\000\000\000\000\ -\000\000\000\000\191\001\000\000\190\001\153\001\152\001\158\001\ -\000\000\156\001\000\000\208\001\000\000\000\000\000\000\184\001\ -\000\000\179\001\000\000\027\003\024\003\000\000\000\000\000\000\ -\000\000\041\001\000\000\000\000\000\000\039\001\037\001\000\000\ -\000\000\000\000\157\002\000\000\158\002\000\000\000\000\000\000\ -\000\000\143\002\000\000\141\002\000\000\000\000\217\000\000\000\ -\219\000\000\000\220\000\214\000\225\000\000\000\212\000\000\000\ -\216\000\000\000\000\000\000\000\000\000\235\000\000\000\000\000\ -\121\001\000\000\000\000\000\000\000\000\000\000\000\000\069\000\ -\033\000\036\000\000\000\000\000\132\001\148\001\000\000\149\001\ -\000\000\000\000\135\001\000\000\140\001\000\000\074\001\073\001\ -\068\001\067\001\031\003\000\000\000\000\028\003\017\003\029\003\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\170\001\000\000\000\000\000\000\000\000\000\000\040\001\020\003\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\028\001\027\001\000\000\000\000\000\000\000\000\254\001\ -\253\001\000\000\244\001\000\000\000\000\000\000\000\000\000\000\ -\085\001\000\000\076\001\000\000\071\001\000\000\000\000\000\000\ -\043\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\108\000\088\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\015\000\000\000\073\002\088\002\ -\000\000\000\000\000\000\077\002\075\002\000\000\000\000\000\000\ -\049\002\000\000\000\000\000\000\000\000\000\000\066\002\000\000\ -\000\000\185\002\000\000\000\000\179\002\054\002\172\002\000\000\ -\000\000\000\000\217\001\000\000\202\001\201\001\205\001\203\001\ -\000\000\194\001\000\000\185\001\189\001\186\001\000\000\018\003\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\002\000\000\159\002\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\012\002\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\126\001\128\001\000\000\000\000\000\000\000\000\ -\028\000\000\000\000\000\041\000\000\000\040\000\000\000\034\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\114\001\ -\000\000\000\000\000\000\000\000\000\000\106\001\000\000\000\000\ -\000\000\000\000\000\000\169\001\000\000\000\000\138\002\136\002\ -\134\002\000\000\089\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\023\000\025\000\026\000\000\000\072\000\073\000\000\000\ -\148\000\000\000\000\000\000\000\000\000\000\000\000\000\159\000\ -\152\000\107\000\239\000\000\000\247\001\000\000\000\000\000\000\ -\000\000\250\001\246\001\000\000\000\000\019\003\066\001\065\001\ -\086\001\084\001\000\000\000\000\165\002\000\000\044\001\042\001\ -\210\000\115\001\000\000\000\000\000\000\000\000\000\000\062\001\ -\048\001\000\000\046\001\000\000\000\000\000\000\000\000\000\000\ -\054\001\000\000\050\001\000\000\052\001\000\000\000\000\000\000\ -\086\000\085\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\037\002\000\000\181\002\000\000\000\000\000\000\000\000\000\000\ -\112\000\000\000\000\000\000\000\083\002\090\002\000\000\074\002\ -\092\002\000\000\000\000\000\000\000\000\000\000\000\000\079\002\ -\071\002\000\000\099\002\000\000\216\002\216\001\000\000\195\001\ -\193\001\192\001\188\001\187\001\061\001\047\001\045\001\000\000\ -\000\000\000\000\053\001\049\001\051\001\000\000\000\000\129\000\ -\000\000\251\001\000\000\000\000\000\000\000\000\203\002\000\000\ -\000\000\017\002\000\000\000\000\000\000\000\000\009\002\000\000\ -\199\002\198\002\000\000\105\001\000\000\000\000\000\000\000\000\ -\000\000\000\000\215\000\000\000\000\000\125\001\123\001\000\000\ -\122\001\000\000\000\000\027\000\000\000\000\000\031\000\030\000\ -\000\000\034\003\232\000\010\002\000\000\000\000\000\000\000\000\ -\118\001\000\000\000\000\116\001\119\001\000\000\163\001\162\001\ -\168\001\000\000\166\001\000\000\211\001\000\000\110\001\000\000\ -\000\000\091\001\000\000\000\000\000\000\120\000\076\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\158\000\000\000\000\000\245\001\000\000\231\001\000\000\ -\249\001\222\001\245\000\077\001\075\001\072\001\070\001\000\000\ -\231\001\077\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\080\000\079\000\000\000\000\000\000\000\000\000\113\000\111\000\ -\000\000\000\000\000\000\000\000\000\000\086\002\078\002\093\002\ -\050\002\046\002\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\001\002\255\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\177\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\138\000\000\000\000\000\000\000\ -\140\000\123\000\127\000\000\000\016\002\019\002\013\002\000\000\ -\008\002\000\000\000\000\000\000\236\000\000\000\222\000\213\000\ -\211\000\000\000\127\001\000\000\000\000\000\000\000\000\048\000\ -\000\000\000\000\042\000\039\000\038\000\231\000\233\000\000\000\ -\000\000\000\000\000\000\107\001\000\000\090\001\000\000\000\000\ -\149\000\000\000\000\000\000\000\000\000\000\000\155\000\000\000\ -\154\000\248\001\000\000\237\001\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\002\002\003\002\000\000\000\000\201\002\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\060\001\000\000\056\001\000\000\058\001\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\038\002\ -\116\000\000\000\000\000\117\000\000\000\091\002\108\002\197\001\ -\196\001\059\001\055\001\057\001\000\000\182\002\181\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\180\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\137\000\000\000\000\000\224\001\225\001\000\000\ -\129\001\124\001\046\000\000\000\047\000\000\000\000\000\000\000\ -\000\000\117\001\111\001\024\000\000\000\156\000\000\000\157\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\238\001\ -\000\000\000\000\000\000\000\000\004\002\000\000\000\000\228\001\ -\000\000\000\000\000\000\024\002\025\002\026\002\027\002\093\001\ -\000\000\229\001\124\000\000\000\000\000\000\000\000\000\201\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\030\002\031\002\000\000\205\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\186\000\000\000\000\000\000\000\175\000\ -\000\000\000\000\133\000\000\000\000\000\146\000\000\000\145\000\ -\000\000\000\000\000\000\000\000\000\000\043\000\045\000\000\000\ -\000\000\120\001\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\005\002\000\000\ -\230\001\000\000\000\000\000\000\022\002\028\002\029\002\092\001\ -\206\000\000\000\000\000\000\000\040\002\044\002\231\001\110\000\ -\000\000\023\002\032\002\202\000\183\002\176\000\000\000\000\000\ -\000\000\179\000\178\000\000\000\173\000\000\000\000\000\131\000\ -\139\000\000\000\000\000\142\000\141\000\000\000\246\000\000\000\ -\000\000\108\001\160\000\153\000\000\000\000\000\000\000\168\000\ -\000\000\000\000\000\000\000\000\006\002\241\001\000\000\000\000\ -\239\001\000\000\000\000\000\000\000\000\033\002\000\000\000\000\ -\174\000\184\000\000\000\000\000\000\000\000\000\000\000\193\000\ -\187\000\000\000\000\000\000\000\144\000\143\000\000\000\044\000\ -\109\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\164\000\000\000\000\000\000\000\000\000\034\002\035\002\ -\000\000\000\000\000\000\000\000\000\000\192\000\172\000\000\000\ -\021\002\166\000\167\000\000\000\000\000\000\000\000\000\000\000\ -\165\000\242\001\036\002\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\169\000\ -\000\000\191\000\188\000\209\002\210\002\000\000\000\000\000\000\ -\000\000\189\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\170\000\190\000\000\000\000\000" +let name i = i.name -let yydgoto = "\008\000\ -\055\000\100\000\122\000\130\000\148\000\158\000\172\000\034\002\ -\101\000\123\000\131\000\057\000\072\001\126\000\058\000\134\000\ -\135\000\178\001\214\001\055\003\245\003\131\003\202\003\005\003\ -\059\000\233\001\012\002\101\001\060\000\061\000\132\003\062\000\ -\160\000\064\000\065\000\066\000\067\000\068\000\069\000\070\000\ -\071\000\072\000\073\000\074\000\075\000\076\000\077\000\025\001\ -\056\003\078\000\108\001\136\002\056\004\110\000\111\000\079\000\ -\113\000\114\000\115\000\116\000\117\000\063\001\112\003\118\000\ -\142\001\238\003\137\002\080\000\110\001\242\001\226\002\109\004\ -\007\005\251\004\253\002\169\003\211\005\008\005\123\001\179\001\ -\009\005\061\002\062\002\060\003\001\004\229\005\185\004\183\004\ -\051\005\081\000\112\004\155\004\070\006\066\005\156\004\187\003\ -\252\004\151\000\254\004\203\005\204\005\012\006\057\006\109\006\ -\105\006\241\005\119\000\144\001\082\000\112\001\019\001\190\003\ -\128\004\191\003\189\003\244\002\176\000\083\000\033\003\164\001\ -\000\003\254\002\084\000\085\000\086\000\123\004\087\000\088\000\ -\210\000\089\000\090\000\211\000\221\000\028\002\217\000\125\001\ -\126\001\121\002\037\003\091\000\071\006\039\003\181\000\092\000\ -\104\001\042\002\157\004\001\003\152\000\212\000\213\000\020\002\ -\218\000\182\000\183\000\042\003\184\000\153\000\185\000\201\001\ -\204\001\202\001\187\002\019\005\093\000\106\001\066\002\066\003\ -\191\004\071\005\067\005\113\004\067\003\006\004\068\003\011\004\ -\171\003\106\004\068\005\069\005\070\005\233\002\176\003\177\003\ -\114\004\115\004\128\003\171\005\193\005\172\005\173\005\174\005\ -\175\005\057\004\189\005\154\000\155\000\156\000\157\000\172\001\ -\154\002\155\002\156\002\074\004\121\003\071\004\173\001\174\001\ -\175\001\055\001\020\001\035\002\073\001" +let unique_name i = i.name ^ "_" ^ string_of_int i.stamp -let yysindex = "\141\009\ -\228\067\075\007\170\051\083\051\204\051\233\070\196\074\000\000\ -\155\005\110\002\080\074\155\005\000\000\184\003\155\005\155\005\ -\000\000\000\000\155\005\155\005\155\005\155\005\155\005\000\000\ -\155\005\225\076\083\004\058\068\146\068\170\063\170\063\014\004\ -\000\000\024\061\170\063\155\005\000\000\000\000\087\005\155\005\ -\155\005\134\255\000\000\000\000\080\074\228\067\000\000\000\000\ -\155\005\155\005\000\000\000\000\155\005\155\005\000\000\160\000\ -\229\255\096\018\048\000\000\000\151\080\000\000\108\004\000\000\ -\000\000\195\000\000\000\000\000\000\000\075\001\000\000\000\000\ -\110\001\176\001\000\000\229\255\000\000\000\000\000\000\000\000\ -\171\000\000\000\105\076\218\001\080\074\080\074\233\070\233\070\ -\000\000\000\000\000\000\000\000\000\000\184\003\155\005\155\005\ -\087\005\075\007\155\005\000\000\049\003\000\000\000\000\195\000\ -\000\000\000\000\176\001\229\255\000\000\075\007\000\000\000\000\ -\000\000\000\000\128\002\000\000\177\002\000\000\000\000\000\000\ -\110\002\000\000\137\002\160\002\229\255\000\000\143\005\000\000\ -\035\052\000\000\171\007\229\255\171\007\000\000\000\000\151\044\ -\000\004\085\255\082\013\202\003\041\048\204\051\206\003\110\002\ -\058\003\000\000\000\000\000\000\070\000\000\000\000\000\222\003\ -\000\000\000\000\030\002\126\001\097\003\000\000\071\005\108\004\ -\155\005\155\005\208\003\199\073\006\074\000\000\136\065\090\003\ -\235\005\069\004\000\000\000\000\175\000\106\004\000\000\000\000\ -\196\074\196\074\000\000\000\000\000\000\162\004\000\000\154\004\ -\000\000\170\063\170\063\116\004\080\074\000\000\000\000\000\000\ -\000\000\000\000\000\000\231\068\155\005\147\004\023\002\116\003\ -\196\074\244\072\000\004\233\070\143\002\080\074\000\000\002\005\ -\070\001\197\003\149\255\000\000\241\004\000\000\000\000\092\005\ -\146\004\046\005\000\000\110\081\057\005\000\000\057\005\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\141\067\192\005\141\067\155\005\155\005\134\255\ -\162\005\000\000\000\000\000\000\080\074\000\000\154\005\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\203\006\ -\000\000\000\000\000\000\131\001\000\000\000\000\000\000\000\000\ -\000\000\080\074\000\000\000\000\000\000\156\000\166\255\141\067\ -\233\070\155\005\184\005\058\003\001\006\000\000\155\005\000\000\ -\000\000\233\070\211\005\116\003\233\070\000\000\170\063\096\018\ -\229\255\155\005\000\000\075\006\209\005\233\070\233\070\233\070\ -\233\070\233\070\233\070\233\070\233\070\233\070\233\070\233\070\ -\233\070\233\070\233\070\233\070\233\070\233\070\233\070\233\070\ -\233\070\233\070\060\069\233\070\000\000\116\004\233\070\000\000\ -\116\004\000\000\116\004\000\000\116\004\000\000\116\004\000\000\ -\000\000\233\070\169\004\225\006\080\074\080\074\027\006\068\006\ -\080\074\027\006\165\076\043\002\000\000\000\000\233\070\043\002\ -\043\002\000\000\000\000\147\004\023\002\075\004\236\005\000\000\ -\211\005\000\000\000\000\000\000\116\004\000\000\116\004\000\000\ -\195\003\000\000\000\000\000\000\000\000\000\000\171\007\229\255\ -\171\007\000\000\171\007\000\000\136\012\000\000\130\005\000\000\ -\042\006\138\006\000\000\136\012\000\000\136\012\000\000\000\000\ -\000\000\134\006\060\006\133\006\170\040\170\040\000\000\204\051\ -\155\005\116\004\009\001\104\006\167\006\000\000\000\000\164\006\ -\000\000\000\000\000\000\216\041\077\004\081\006\098\006\204\051\ -\058\003\000\000\000\000\196\074\009\076\000\000\173\006\179\006\ -\206\255\107\006\070\005\109\006\000\000\109\006\000\000\090\003\ -\000\000\131\001\235\005\000\000\000\000\102\002\000\000\000\000\ -\000\000\000\000\000\000\033\002\031\066\092\066\153\066\000\000\ -\000\000\176\003\000\000\000\000\196\074\242\001\141\067\116\004\ -\000\000\116\004\043\002\058\005\231\006\000\000\041\003\147\004\ -\000\000\153\006\000\000\119\006\140\000\000\000\000\000\078\002\ -\188\077\208\006\178\003\009\076\059\064\125\002\245\005\050\006\ -\048\072\000\000\000\000\000\000\196\074\110\006\116\004\254\003\ -\116\004\026\007\205\006\000\000\000\000\043\002\255\007\208\003\ -\202\009\124\017\000\000\202\006\000\000\000\000\208\003\233\070\ -\000\000\000\000\068\006\000\000\233\070\104\255\211\004\013\082\ -\196\074\000\000\149\006\170\063\155\006\023\002\142\006\155\005\ -\000\000\116\075\000\000\157\006\161\006\175\006\000\000\143\002\ -\000\000\000\000\182\006\000\000\000\000\163\006\166\006\110\002\ -\158\006\084\003\000\000\196\074\120\003\000\000\186\006\189\006\ -\000\000\092\006\252\006\006\007\141\067\000\000\000\000\225\076\ -\038\005\145\069\233\069\135\061\000\000\000\000\235\081\235\081\ -\203\081\110\013\110\081\203\081\184\012\184\012\184\012\184\012\ -\053\004\255\006\255\006\184\012\053\004\053\004\203\081\255\006\ -\053\004\053\004\053\004\170\063\000\000\255\006\116\075\000\000\ -\092\006\207\006\147\004\147\004\110\081\233\070\233\070\233\070\ -\252\001\249\006\233\070\233\070\233\070\043\002\043\002\000\000\ -\000\000\000\000\065\004\000\000\000\000\203\081\153\006\151\255\ -\116\004\075\004\213\006\116\004\000\000\163\002\000\000\000\000\ -\000\000\175\002\216\006\041\004\092\006\221\006\147\004\000\000\ -\000\000\000\000\000\000\055\007\000\000\000\000\171\007\000\000\ -\000\000\000\000\253\255\000\000\078\007\000\000\000\000\136\012\ -\127\001\112\000\120\054\000\000\000\000\000\000\000\000\008\007\ -\075\004\204\051\015\005\204\051\204\051\135\004\000\000\239\006\ -\000\000\000\000\220\001\110\002\022\007\000\000\000\000\000\000\ -\194\004\204\051\070\007\000\000\000\000\203\004\196\074\174\000\ -\024\006\247\006\000\000\254\046\000\000\000\000\000\000\000\000\ -\141\002\000\000\091\007\000\000\035\002\067\074\226\065\000\000\ -\035\002\000\000\015\007\000\000\000\000\233\070\233\070\233\070\ -\160\005\000\000\233\070\233\070\233\070\000\000\000\000\153\006\ -\237\005\044\007\000\000\018\007\000\000\013\041\179\002\013\041\ -\116\004\000\000\114\007\000\000\204\051\233\070\000\000\051\007\ -\000\000\196\074\000\000\000\000\000\000\053\007\000\000\053\007\ -\000\000\216\041\170\064\233\070\048\072\000\000\182\255\111\007\ -\000\000\233\070\056\007\116\004\033\001\228\067\247\002\000\000\ -\000\000\000\000\017\007\000\000\000\000\000\000\108\255\000\000\ -\116\004\233\070\000\000\110\081\000\000\110\081\000\000\000\000\ -\000\000\000\000\000\000\116\004\247\000\000\000\000\000\000\000\ -\087\007\151\255\084\003\186\006\229\255\216\071\239\004\115\007\ -\000\000\110\007\068\007\069\007\071\007\139\001\000\000\000\000\ -\000\004\109\007\084\003\075\004\143\002\150\005\084\003\229\255\ -\210\002\000\000\000\000\167\001\183\002\018\000\237\005\000\000\ -\000\000\209\004\000\000\136\002\204\051\233\070\047\007\242\255\ -\000\000\251\004\000\000\057\005\000\000\057\005\046\007\131\001\ -\000\000\184\255\233\070\229\255\077\007\084\003\153\006\153\006\ -\212\080\151\001\192\000\194\255\245\006\233\070\011\078\043\078\ -\121\078\080\007\056\007\119\255\063\007\075\007\075\004\060\255\ -\000\000\000\000\028\005\131\007\075\004\186\006\205\005\229\255\ -\209\004\134\007\153\006\017\003\000\000\136\012\000\000\000\000\ -\204\051\218\000\144\007\000\000\000\000\110\002\111\001\116\004\ -\000\000\204\051\255\002\058\007\116\004\058\003\000\000\022\007\ -\081\007\000\000\216\041\048\007\000\000\000\000\000\000\116\004\ -\196\074\065\007\000\000\070\005\000\000\000\000\000\000\000\000\ -\087\001\000\000\129\255\000\000\000\000\000\000\053\003\000\000\ -\017\081\048\001\246\255\020\007\153\078\231\078\007\079\102\007\ -\129\001\082\007\000\000\129\072\000\000\092\007\000\000\095\007\ -\239\006\083\007\144\001\151\007\116\004\000\000\229\255\245\001\ -\102\000\051\007\084\007\108\006\150\007\150\007\165\007\093\007\ -\108\007\051\007\000\000\000\000\063\070\233\070\196\074\049\081\ -\000\000\201\003\233\070\000\000\075\004\000\000\150\003\000\000\ -\204\051\110\081\233\070\233\070\116\004\142\007\228\004\000\000\ -\162\015\233\070\025\065\021\072\164\007\000\000\152\002\214\066\ -\019\067\080\067\233\070\000\000\204\051\196\074\000\000\000\000\ -\000\000\122\000\000\000\196\074\075\004\229\255\229\255\107\001\ -\053\006\000\000\000\000\000\000\180\007\000\000\000\000\204\051\ -\000\000\116\004\134\255\116\004\134\255\134\255\229\255\000\000\ -\000\000\000\000\000\000\196\074\000\000\207\001\168\007\112\007\ -\110\002\000\000\000\000\151\006\175\007\000\000\000\000\000\000\ -\000\000\000\000\060\001\168\006\000\000\143\002\000\000\000\000\ -\000\000\000\000\168\007\229\255\137\007\139\007\147\007\000\000\ -\000\000\148\007\000\000\154\007\233\070\233\070\233\070\110\081\ -\000\000\157\007\000\000\158\007\000\000\159\007\199\007\033\006\ -\000\000\000\000\116\004\159\004\255\002\186\006\092\006\219\007\ -\000\000\000\000\000\000\075\004\255\002\183\002\098\002\211\007\ -\000\000\140\007\075\004\163\007\000\000\000\000\072\001\000\000\ -\000\000\172\255\000\000\204\051\110\002\138\007\022\007\000\000\ -\000\000\204\051\000\000\070\005\000\000\000\000\075\004\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\233\070\ -\233\070\233\070\000\000\000\000\000\000\202\007\237\005\000\000\ -\110\002\000\000\136\050\096\005\229\255\129\072\000\000\068\006\ -\141\007\000\000\092\007\216\041\009\002\229\255\000\000\135\007\ -\000\000\000\000\233\070\000\000\048\072\204\051\233\070\146\007\ -\149\007\204\051\000\000\233\070\152\007\000\000\000\000\162\007\ -\000\000\233\070\143\002\000\000\100\077\137\255\000\000\000\000\ -\116\004\000\000\000\000\000\000\233\070\233\070\051\007\142\001\ -\000\000\051\007\214\007\000\000\000\000\233\070\000\000\000\000\ -\000\000\141\002\000\000\091\007\000\000\035\002\000\000\121\002\ -\035\002\000\000\156\007\111\007\255\002\000\000\000\000\143\002\ -\075\004\248\003\204\051\116\004\233\070\116\004\229\255\116\004\ -\229\255\000\000\111\007\237\005\000\000\031\077\000\000\160\007\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\209\002\ -\000\000\000\000\129\072\215\007\233\070\233\070\233\070\094\079\ -\126\079\204\079\233\070\233\070\233\070\136\050\075\004\143\002\ -\000\000\000\000\148\006\208\003\060\255\163\002\000\000\000\000\ -\075\004\160\007\163\002\224\007\204\051\000\000\000\000\000\000\ -\000\000\000\000\116\004\022\007\059\000\236\079\058\080\090\080\ -\163\005\000\000\000\000\054\012\173\007\230\007\116\004\216\041\ -\190\007\000\000\231\007\116\004\186\007\000\000\190\002\116\004\ -\204\051\217\005\096\005\116\004\000\000\249\004\116\004\165\076\ -\000\000\000\000\000\000\246\007\000\000\000\000\000\000\247\007\ -\000\000\135\007\229\255\241\007\000\000\116\004\000\000\000\000\ -\000\000\116\004\000\000\048\072\233\070\110\081\053\006\000\000\ -\243\000\237\002\000\000\000\000\000\000\000\000\000\000\242\007\ -\204\051\172\007\233\070\000\000\233\070\000\000\053\006\100\005\ -\000\000\250\002\229\255\096\005\229\255\195\001\000\000\234\004\ -\000\000\000\000\023\002\000\000\127\049\148\014\097\047\000\000\ -\096\003\217\007\007\008\000\000\000\000\151\255\063\002\000\000\ -\150\255\078\003\063\002\229\255\163\005\110\081\110\081\110\081\ -\000\000\216\007\000\000\218\007\000\000\221\007\110\081\110\081\ -\110\081\229\255\255\002\053\006\081\006\081\006\043\005\000\000\ -\000\000\079\006\174\255\000\000\136\050\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\204\051\000\000\000\000\151\006\ -\229\002\190\001\222\003\134\255\216\041\208\007\203\007\014\008\ -\096\005\000\000\136\050\045\005\049\073\202\001\134\255\166\000\ -\001\006\096\005\000\000\165\076\120\054\000\000\000\000\233\070\ -\000\000\000\000\000\000\249\255\000\000\193\007\204\051\215\003\ -\021\072\000\000\000\000\000\000\204\051\000\000\025\001\000\000\ -\177\007\160\007\068\006\181\007\092\007\068\006\151\255\000\000\ -\116\004\007\008\160\007\092\007\000\000\116\004\204\051\000\000\ -\023\002\082\002\194\001\000\000\000\000\000\000\000\000\000\000\ -\201\007\000\000\000\000\151\006\233\070\233\070\233\070\000\000\ -\168\003\168\003\204\051\228\007\204\051\098\002\023\002\151\255\ -\248\001\000\000\000\000\229\255\000\000\053\005\068\005\116\004\ -\223\007\204\051\200\004\000\000\136\050\216\041\116\004\000\000\ -\000\000\217\072\000\000\058\003\116\004\000\000\136\050\000\000\ -\026\005\116\004\116\004\022\008\075\004\000\000\000\000\008\004\ -\233\070\000\000\116\004\238\007\229\255\068\006\068\006\156\072\ -\068\006\068\006\103\006\116\004\101\003\212\007\000\000\052\004\ -\000\000\246\002\179\002\116\004\000\000\000\000\000\000\000\000\ -\000\000\110\081\110\081\110\081\000\000\000\000\000\000\000\000\ -\151\255\000\000\000\000\000\000\000\000\000\000\186\006\136\050\ -\103\004\000\000\000\000\158\001\000\000\234\007\096\005\000\000\ -\000\000\186\006\159\000\000\000\000\000\222\007\000\000\227\007\ -\233\070\000\000\000\000\000\000\048\008\052\008\140\048\000\000\ -\054\008\056\008\233\070\050\008\000\000\000\000\092\007\007\008\ -\000\000\204\051\179\002\116\004\116\004\000\000\060\008\036\005\ -\000\000\000\000\116\004\116\004\116\004\116\004\229\255\000\000\ -\000\000\136\050\116\004\088\005\000\000\000\000\116\004\000\000\ -\000\000\120\054\120\054\051\007\116\004\053\008\238\001\204\051\ -\204\051\000\000\233\070\240\007\116\004\116\004\000\000\000\000\ -\163\005\204\051\163\005\220\003\033\003\000\000\000\000\096\005\ -\000\000\000\000\000\000\062\008\233\070\204\051\116\004\116\004\ -\000\000\000\000\000\000\116\004\229\255\151\006\225\007\250\007\ -\068\006\147\004\092\007\073\008\229\255\116\004\204\051\000\000\ -\116\004\000\000\000\000\000\000\000\000\074\008\068\006\068\006\ -\204\051\000\000\057\004\120\054\077\008\079\008\116\004\233\070\ -\229\255\204\051\204\051\000\000\000\000\116\004\116\004" +let unique_toplevel_name i = i.name ^ "/" ^ string_of_int i.stamp -let yyrindex = "\000\000\ -\094\009\095\009\000\008\000\000\000\000\000\000\000\000\000\000\ -\232\076\000\000\000\000\148\070\000\000\022\003\029\003\171\006\ -\000\000\000\000\001\075\076\073\135\074\062\071\230\002\000\000\ -\232\076\000\000\000\000\000\000\000\000\000\000\000\000\028\075\ -\012\019\000\000\000\000\062\071\000\000\000\000\246\005\069\005\ -\015\002\042\004\000\000\000\000\000\000\099\000\000\000\000\000\ -\062\071\149\008\000\000\000\000\171\006\062\071\000\000\000\000\ -\176\040\099\000\128\019\000\000\016\046\000\000\149\013\000\000\ -\000\000\114\015\000\000\000\000\000\000\113\059\000\000\000\000\ -\122\059\171\059\000\000\215\059\000\000\000\000\000\000\000\000\ -\000\000\000\000\058\027\174\027\081\026\197\026\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\022\003\029\003\131\004\ -\246\005\116\000\149\008\000\000\000\000\000\000\000\000\222\041\ -\000\000\000\000\065\042\012\043\000\000\116\000\000\000\000\000\ -\000\000\000\000\111\043\000\000\058\044\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\002\008\000\000\000\008\000\000\ -\000\000\000\000\000\000\247\008\000\000\000\000\000\000\000\000\ -\134\014\134\014\000\000\079\010\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\247\010\ -\000\000\000\000\000\000\060\049\114\018\000\000\000\000\000\000\ -\001\075\036\076\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\150\052\000\000\000\000\ -\253\002\225\005\000\000\000\000\000\000\139\006\000\000\002\053\ -\000\000\000\000\000\000\165\060\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\022\003\239\255\000\000\000\000\ -\000\000\000\000\089\075\000\000\000\000\000\000\067\002\124\002\ -\000\000\227\255\000\000\000\000\037\000\000\000\000\000\170\255\ -\000\000\142\005\000\000\117\255\095\001\000\000\199\006\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\008\008\052\060\008\008\029\003\251\007\042\004\ -\177\075\000\000\000\000\000\000\167\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\076\062\162\062\230\002\000\000\000\000\248\062\078\063\ -\000\000\185\000\000\000\000\000\000\000\000\000\000\000\008\008\ -\000\000\069\005\000\000\000\000\002\004\000\000\251\007\000\000\ -\000\000\000\000\079\005\000\000\000\000\000\000\000\000\099\000\ -\222\055\028\075\000\000\149\013\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\220\035\000\000\000\000\204\075\000\000\000\000\ -\212\004\000\000\252\007\000\000\108\003\000\000\108\003\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\237\017\244\024\000\000\000\000\000\000\034\028\ -\151\028\000\000\000\000\239\255\000\000\000\000\000\000\000\000\ -\079\005\000\000\000\000\000\000\252\007\000\000\108\003\000\000\ -\059\014\000\000\000\000\000\000\000\000\000\000\000\000\247\008\ -\000\000\000\000\000\000\000\000\000\000\000\000\153\001\000\000\ -\095\008\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\207\255\000\000\076\008\000\000\078\008\084\008\000\000\000\000\ -\131\004\096\001\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\036\000\ -\000\000\146\000\068\000\095\001\000\000\199\006\000\000\235\000\ -\000\000\251\007\238\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\008\008\165\060\ -\000\000\229\050\011\029\000\000\000\000\000\000\000\000\239\255\ -\000\000\045\008\000\000\000\000\000\000\000\000\000\000\221\057\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\057\008\000\000\ -\246\061\215\059\064\004\000\000\000\000\127\029\000\000\000\000\ -\000\000\000\000\000\000\146\255\000\000\000\000\228\000\000\000\ -\000\000\000\000\148\005\000\000\090\001\000\000\000\000\018\008\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\251\007\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\175\004\000\000\000\000\008\008\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\138\038\242\038\ -\090\039\034\016\245\040\194\039\080\036\197\036\057\037\173\037\ -\034\033\244\029\104\030\034\038\150\033\011\034\042\040\220\030\ -\127\034\243\034\104\035\000\000\000\000\081\031\000\000\000\000\ -\085\001\000\000\239\255\239\255\088\041\000\000\000\000\000\000\ -\000\000\244\019\000\000\000\000\000\000\104\025\221\025\000\000\ -\000\000\000\000\128\024\000\000\000\000\146\040\045\008\117\011\ -\057\008\000\000\000\000\124\012\096\007\012\043\000\000\000\000\ -\000\000\000\000\000\000\000\000\175\004\000\000\239\255\000\000\ -\000\000\000\000\000\000\061\014\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\173\061\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\230\046\000\000\000\000\000\000\000\000\073\047\ -\000\000\000\000\000\000\000\000\172\047\000\000\000\000\000\000\ -\000\000\000\000\156\255\000\000\000\000\245\000\090\001\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\016\001\000\000\067\006\000\000\202\000\000\000\000\000\000\000\ -\118\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\045\008\ -\023\008\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\139\058\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\197\031\ -\000\000\000\000\000\000\147\071\000\000\204\005\000\000\000\000\ -\000\000\000\000\000\000\086\002\000\000\000\000\217\255\000\000\ -\067\000\000\000\000\000\006\000\000\000\144\000\000\000\000\000\ -\000\000\000\000\000\000\155\006\029\008\000\000\000\000\000\000\ -\000\000\170\005\000\000\000\000\230\057\028\007\000\000\188\006\ -\000\000\019\004\003\001\018\001\062\001\000\000\000\000\000\000\ -\089\075\204\058\000\000\000\000\000\000\000\000\000\000\215\059\ -\000\000\000\000\000\000\216\005\215\059\089\075\159\005\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\095\001\000\000\199\006\000\000\230\002\ -\000\000\000\000\000\000\230\057\000\000\000\000\045\008\045\008\ -\000\000\142\081\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\219\005\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\012\043\ -\000\000\000\000\045\008\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\230\001\ -\000\000\000\000\008\001\000\000\147\001\000\000\000\000\017\048\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\182\000\ -\000\000\002\001\000\000\217\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\069\008\187\054\000\000\ -\106\055\000\000\000\000\189\007\139\058\000\000\215\059\000\000\ -\000\000\009\000\000\000\250\255\040\008\040\008\254\255\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\120\046\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\172\000\000\000\000\000\083\008\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\215\059\253\058\000\000\ -\138\008\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\148\077\018\005\147\071\079\002\134\003\168\004\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\182\009\000\000\ -\000\000\000\000\000\000\215\059\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\082\056\253\058\000\000\000\000\105\020\000\000\ -\000\000\221\020\000\000\081\021\000\000\000\000\000\000\192\041\ -\000\000\198\021\000\000\058\022\000\000\174\022\000\000\000\000\ -\000\000\000\000\252\004\000\000\197\006\000\000\175\004\246\006\ -\000\000\089\008\000\000\000\000\252\052\012\043\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\153\001\000\000\ -\000\000\000\000\238\063\000\000\000\000\099\008\116\048\000\000\ -\000\000\000\000\000\000\230\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\023\008\000\000\ -\000\000\000\000\000\000\000\000\253\058\000\000\000\000\000\000\ -\000\000\000\000\085\005\000\000\000\000\215\059\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\197\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\152\006\000\000\170\003\000\000\032\006\000\000\000\000\ -\117\006\000\000\000\000\057\032\007\059\000\000\000\000\000\000\ -\000\000\000\000\000\000\248\005\000\000\038\004\168\004\117\004\ -\168\004\000\000\174\032\159\005\000\000\087\008\000\000\208\255\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\019\041\000\000\000\000\ -\000\000\208\255\019\041\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\144\016\215\048\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\037\015\059\008\000\000\ -\000\000\236\054\000\000\189\011\000\000\000\000\000\000\137\073\ -\000\000\028\075\000\000\047\003\000\000\000\000\027\058\110\053\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\069\059\215\059\000\000\000\000\058\000\000\000\000\000\ -\000\000\017\002\000\000\000\000\000\000\035\042\001\017\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\131\056\000\000\ -\000\000\000\000\168\004\000\000\168\004\072\008\000\000\069\008\ -\000\000\000\000\000\000\000\000\000\000\000\000\100\008\245\011\ -\184\056\000\000\237\056\000\000\000\000\147\016\253\058\000\000\ -\000\000\000\000\253\058\253\058\000\000\134\042\238\042\081\043\ -\000\000\035\023\000\000\151\023\000\000\011\024\180\043\028\044\ -\127\044\019\041\079\017\116\050\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\253\058\ -\000\000\000\000\119\002\146\003\000\000\194\002\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\146\003\000\000\ -\002\004\000\000\000\000\182\053\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\020\006\000\000\ -\094\008\072\008\000\000\101\008\069\008\000\000\147\016\000\000\ -\056\057\109\057\162\003\069\008\000\000\024\056\000\000\000\000\ -\000\000\234\012\215\059\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\253\058\000\000\000\000\000\000\000\000\ -\136\049\194\049\000\000\010\078\000\000\000\000\000\000\118\057\ -\012\043\000\000\000\000\019\041\000\000\000\000\000\000\252\007\ -\000\000\000\000\000\000\000\000\000\000\000\000\080\058\000\000\ -\030\055\000\000\000\000\000\000\252\007\000\000\000\000\000\000\ -\000\000\240\053\219\002\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\172\006\000\000\168\004\000\000\000\000\000\000\ -\000\000\000\000\000\000\024\056\000\000\000\000\000\000\000\000\ -\000\000\234\012\000\000\129\058\000\000\000\000\000\000\000\000\ -\000\000\226\044\074\045\173\045\000\000\000\000\000\000\000\000\ -\118\057\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\253\005\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\046\008\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\069\008\168\057\ -\000\000\000\000\000\000\129\058\129\058\000\000\252\049\000\000\ -\000\000\000\000\148\077\223\005\038\004\117\004\005\004\000\000\ -\000\000\000\000\042\054\000\000\000\000\000\000\111\005\000\000\ -\000\000\000\000\000\000\000\000\193\004\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\058\050\129\058\000\000\000\000\ -\000\000\000\000\000\000\104\008\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\077\009\186\010\ -\000\000\000\000\000\000\164\055\005\004\005\004\107\008\109\008\ -\000\000\110\008\069\008\000\000\005\004\100\054\000\000\000\000\ -\164\005\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\095\004\000\000\ -\005\004\000\000\000\000\000\000\000\000\050\009\222\010" +let persistent i = (i.stamp = 0) -let yygindex = "\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\033\000\ -\215\255\000\000\089\000\072\000\013\006\049\009\060\000\000\000\ -\214\255\126\000\233\001\099\253\000\000\217\254\078\006\071\255\ -\127\008\195\013\029\254\247\255\098\004\194\013\074\252\051\000\ -\093\000\023\000\026\000\034\000\000\000\000\000\000\000\000\000\ -\045\000\047\000\000\000\049\000\000\000\002\000\013\000\088\007\ -\093\001\000\000\000\000\000\000\000\000\000\000\000\000\052\000\ -\000\000\000\000\000\000\000\000\000\000\014\255\005\252\000\000\ -\000\000\000\000\027\000\000\000\000\000\142\254\251\253\032\252\ -\115\251\156\251\083\255\000\000\226\003\000\000\176\004\175\251\ -\113\255\059\004\000\000\000\000\000\000\000\000\000\000\000\000\ -\107\003\015\000\026\251\047\255\103\253\199\251\017\253\135\252\ -\095\251\043\254\247\003\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\046\000\200\006\ -\003\006\006\006\000\000\000\000\078\255\022\000\000\000\168\255\ -\184\001\059\253\000\254\108\010\156\012\000\000\000\000\000\000\ -\110\255\049\008\009\013\119\007\031\000\094\255\207\000\159\254\ -\000\000\080\008\100\007\216\011\115\253\000\000\078\254\000\000\ -\000\000\000\000\050\004\009\006\163\255\164\004\000\000\000\000\ -\000\000\000\000\073\000\000\000\235\007\157\255\254\007\021\007\ -\045\009\000\000\000\000\198\004\000\000\000\000\085\008\213\253\ -\190\005\138\251\021\251\213\251\011\253\000\000\097\253\000\000\ -\122\005\000\000\000\000\046\251\066\255\001\253\251\006\041\008\ -\000\000\000\000\099\004\000\000\000\000\137\004\078\252\000\000\ -\066\004\017\005\000\000\146\253\235\012\133\255\000\000\071\006\ -\128\255\220\254\141\255\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\082\255\000\000" +let equal i1 i2 = i1.name = i2.name -let yytablesize = 21372 -let yytable = "\188\000\ -\019\002\185\001\188\000\108\000\188\000\188\000\188\000\161\001\ -\248\001\188\000\188\000\188\000\188\000\188\000\109\000\188\000\ -\200\001\127\002\180\001\010\002\162\001\127\003\188\000\002\002\ -\102\000\125\002\188\000\103\000\001\002\188\000\188\000\188\000\ -\193\000\056\000\213\003\104\000\192\000\040\002\009\003\188\000\ -\188\000\216\000\160\001\188\000\188\000\171\001\105\000\209\000\ -\106\000\166\001\107\000\171\004\129\003\112\000\222\003\196\003\ -\136\001\194\001\030\002\223\000\031\002\085\003\127\000\133\000\ -\124\004\170\003\064\001\224\004\140\001\186\001\219\001\014\005\ -\133\004\005\004\125\000\132\000\021\001\159\000\065\001\112\005\ -\056\001\158\005\075\005\162\005\188\000\188\000\188\000\188\000\ -\154\001\188\000\156\001\124\000\163\001\063\000\134\002\063\000\ -\063\000\113\003\051\000\108\000\051\002\201\003\037\002\023\003\ -\124\001\054\001\128\001\129\001\075\001\090\003\109\000\108\000\ -\165\005\090\005\005\002\089\000\143\001\128\005\049\004\040\003\ -\102\000\098\003\109\000\103\000\209\003\224\002\143\001\161\002\ -\089\004\162\002\149\000\104\000\102\000\054\004\073\005\103\000\ -\036\005\054\002\063\000\187\001\062\001\011\005\105\000\104\000\ -\106\000\138\001\107\000\145\001\021\002\112\000\076\001\188\000\ -\188\000\170\001\105\000\219\001\106\000\169\005\107\000\070\001\ -\237\004\112\000\114\005\225\001\230\002\052\002\151\005\055\004\ -\099\005\142\001\182\001\180\005\059\002\186\000\224\001\126\005\ -\165\001\010\000\234\001\243\001\040\003\191\005\234\005\023\004\ -\186\000\220\001\127\000\188\000\153\001\221\001\133\000\103\003\ -\133\000\035\004\186\000\024\003\222\001\201\003\128\002\223\001\ -\152\001\207\001\186\000\243\001\244\001\188\002\142\001\165\005\ -\143\001\103\003\235\001\143\001\050\004\090\003\245\001\200\002\ -\145\001\151\001\168\003\076\001\110\002\063\000\090\004\076\001\ -\114\002\076\001\151\001\014\002\244\001\232\002\037\005\231\001\ -\232\001\104\003\076\005\207\005\138\001\200\002\245\001\022\002\ -\138\001\015\004\173\002\145\001\218\005\035\004\219\001\186\000\ -\087\003\088\003\219\001\104\003\155\005\151\001\197\003\246\001\ -\196\005\040\006\247\001\053\002\118\003\141\001\200\002\231\004\ -\142\001\221\005\070\004\239\001\188\000\188\000\173\002\157\001\ -\200\002\003\004\184\002\006\002\226\000\024\004\208\005\246\001\ -\223\000\163\001\247\001\114\005\115\003\040\005\104\001\036\004\ -\042\005\009\003\188\000\221\001\134\001\204\002\198\003\071\001\ -\189\002\192\002\141\001\193\002\140\004\173\002\204\002\173\002\ -\188\000\182\002\193\000\145\001\168\002\188\000\145\001\145\001\ -\211\002\200\002\104\005\173\002\200\002\151\001\221\001\160\001\ -\188\000\151\001\147\001\212\001\181\002\077\001\160\001\064\001\ -\160\001\239\002\009\003\152\004\016\004\212\001\002\002\171\001\ -\171\001\029\004\030\004\095\004\227\000\165\005\222\005\226\000\ -\119\003\218\002\100\003\223\000\234\001\147\001\175\002\234\001\ -\231\005\234\001\051\000\234\001\141\001\234\001\104\001\034\003\ -\013\006\237\005\140\005\142\005\150\002\068\004\152\002\063\000\ -\153\002\063\000\019\006\089\000\069\002\206\001\046\003\118\003\ -\238\005\170\004\070\002\122\003\051\000\121\004\221\001\134\001\ -\055\002\059\006\221\001\234\001\120\006\234\001\122\002\186\000\ -\047\006\064\002\118\002\119\002\068\002\089\000\123\002\144\001\ -\124\001\214\001\140\004\177\005\063\000\234\001\071\003\227\000\ -\105\005\144\001\228\002\049\002\129\002\147\001\061\006\212\001\ -\147\001\147\001\212\001\049\006\076\001\214\005\140\002\188\000\ -\187\001\017\002\101\002\137\001\018\002\149\003\104\002\100\006\ -\195\005\102\006\220\001\215\005\030\000\220\001\221\001\021\005\ -\127\002\190\000\130\002\170\001\170\001\222\001\051\000\033\004\ -\223\001\225\001\000\006\131\002\146\001\105\001\058\005\170\003\ -\188\000\207\001\110\006\125\003\225\001\207\001\122\004\089\000\ -\220\001\207\001\133\000\207\001\133\000\087\006\133\000\207\001\ -\213\001\225\001\225\001\207\001\132\002\233\004\234\001\146\001\ -\234\001\118\003\213\001\136\001\207\001\218\001\133\002\186\000\ -\114\001\229\002\143\002\144\001\214\001\141\002\144\001\173\000\ -\186\000\225\001\139\005\076\001\215\001\076\001\027\003\076\001\ -\246\005\050\002\220\001\076\006\062\006\234\001\221\001\234\001\ -\010\003\215\002\137\002\216\005\140\002\222\001\137\001\081\002\ -\223\001\150\003\137\001\220\004\240\003\009\003\003\006\157\001\ -\220\001\135\002\207\001\157\001\220\001\129\002\127\002\157\001\ -\081\002\157\001\170\002\034\004\228\005\157\001\188\000\146\001\ -\204\003\108\000\146\001\146\001\207\001\207\001\024\006\207\001\ -\207\001\216\000\157\001\200\001\109\000\030\000\205\003\033\004\ -\136\003\137\003\190\000\130\002\213\001\072\004\102\000\213\001\ -\186\000\103\000\207\001\196\004\131\002\133\002\136\001\053\004\ -\218\001\104\000\160\001\063\000\218\001\061\004\166\005\135\003\ -\143\002\229\004\002\002\141\002\105\000\107\001\106\000\215\001\ -\107\000\031\003\050\003\112\000\221\003\132\002\137\005\216\000\ -\157\001\216\002\186\000\236\001\215\002\209\000\215\002\133\002\ -\137\002\007\003\186\000\216\002\087\004\081\002\171\002\211\003\ -\076\003\078\003\157\001\157\001\117\003\157\001\157\001\135\002\ -\109\001\096\002\041\003\002\002\237\001\206\001\102\005\234\001\ -\220\003\206\001\234\001\241\003\106\003\206\001\206\003\206\001\ -\157\001\191\001\047\002\206\001\076\004\176\004\118\003\206\001\ -\175\003\186\000\175\002\094\004\203\001\203\001\015\003\017\003\ -\206\001\083\003\103\004\082\003\243\001\253\004\032\004\197\004\ -\234\003\227\001\228\001\133\002\193\003\028\003\031\001\236\005\ -\023\003\063\000\123\003\041\005\097\002\142\004\120\001\121\001\ -\127\001\019\004\244\005\020\004\186\000\225\001\252\001\041\003\ -\051\006\251\001\111\001\103\003\088\004\216\002\091\003\092\003\ -\016\002\250\003\215\002\096\002\023\003\096\002\206\001\225\001\ -\244\005\225\001\252\001\225\001\186\000\173\004\192\001\225\001\ -\077\004\169\005\092\006\007\003\186\000\052\006\142\003\170\002\ -\206\001\206\001\133\000\206\001\206\001\187\000\251\003\252\003\ -\236\003\031\000\124\003\170\002\104\004\104\003\008\004\234\001\ -\188\004\035\000\031\000\053\006\009\003\004\004\206\001\077\004\ -\235\003\021\003\035\000\127\001\253\003\051\001\097\002\086\004\ -\097\002\140\003\044\006\076\001\023\003\225\001\081\004\127\003\ -\032\006\002\002\234\001\010\003\180\001\013\000\110\004\191\005\ -\253\004\044\006\069\004\094\006\071\001\187\001\079\004\187\001\ -\180\004\023\003\182\004\184\004\054\006\066\004\025\003\120\004\ -\018\000\185\002\187\001\225\001\222\004\254\003\129\003\074\003\ -\160\001\199\005\153\005\227\004\190\001\228\003\162\003\163\003\ -\198\002\025\003\119\005\024\000\010\003\212\005\207\003\133\003\ -\025\003\002\002\093\003\224\000\189\004\083\004\220\003\225\001\ -\138\001\222\001\154\005\189\001\243\001\185\003\186\000\144\003\ -\168\000\141\003\071\001\009\003\052\004\255\003\025\003\025\003\ -\236\001\155\003\171\002\195\003\023\003\169\000\188\000\077\004\ -\000\004\016\005\025\003\009\003\253\005\244\001\255\005\025\003\ -\171\002\167\005\025\003\171\002\025\003\172\002\047\000\245\001\ -\122\002\237\001\106\003\230\002\200\004\171\002\190\001\230\002\ -\166\000\249\001\063\000\172\002\186\000\195\002\172\002\108\000\ -\231\002\220\001\184\003\122\002\243\005\221\001\224\000\109\003\ -\172\002\122\002\109\000\196\002\222\001\077\002\234\001\223\001\ -\009\003\106\003\094\002\187\001\102\000\025\003\085\002\103\000\ -\246\001\071\001\141\001\247\001\122\002\059\004\187\001\104\000\ -\094\002\048\005\225\001\120\001\121\001\013\004\211\002\253\004\ -\211\002\187\001\105\000\045\005\106\000\225\001\107\000\159\004\ -\075\004\112\000\025\004\222\001\232\002\171\002\223\001\201\005\ -\232\002\171\002\111\003\122\002\122\002\253\004\211\002\186\000\ -\090\006\091\006\164\002\234\001\183\002\190\000\187\001\091\005\ -\172\002\007\002\225\001\143\001\172\002\122\002\122\002\122\002\ -\094\002\098\005\186\000\002\002\241\002\242\002\211\002\094\002\ -\110\004\185\000\012\004\197\002\107\003\201\002\203\002\205\002\ -\122\002\030\000\002\002\234\001\011\003\209\002\186\000\008\002\ -\017\000\031\005\094\002\124\005\185\000\220\001\236\004\166\000\ -\249\001\221\001\191\000\185\000\164\002\164\002\074\005\248\003\ -\222\001\009\004\129\006\223\001\186\000\071\001\106\003\010\003\ -\146\001\178\003\243\002\103\003\141\005\255\002\164\002\190\001\ -\234\001\185\000\234\001\179\003\009\002\010\004\047\005\253\004\ -\014\006\071\001\198\005\051\000\180\001\185\000\190\001\147\001\ -\180\001\253\004\187\001\230\002\180\001\185\000\180\001\185\000\ -\025\003\029\003\180\001\180\001\135\004\136\004\180\001\129\002\ -\043\006\007\003\186\000\186\000\149\005\104\003\015\005\180\001\ -\002\002\007\002\146\004\147\004\048\000\110\004\092\005\051\000\ -\025\003\153\004\125\002\193\004\057\003\190\001\025\003\030\000\ -\222\002\234\001\167\004\106\003\190\000\130\002\023\003\249\003\ -\185\000\030\000\253\004\106\003\091\004\023\003\131\002\008\002\ -\220\001\023\003\025\003\186\000\221\001\234\001\180\001\029\000\ -\186\000\023\003\223\002\222\001\232\002\180\001\223\001\103\003\ -\023\003\095\005\225\001\025\003\025\003\176\005\145\004\132\002\ -\166\000\249\001\025\003\025\003\208\003\025\003\015\003\180\001\ -\180\001\133\002\180\001\180\001\009\002\025\003\023\003\023\003\ -\215\000\052\003\168\004\051\000\253\004\004\003\150\000\234\004\ -\175\000\002\002\023\003\106\006\059\005\180\001\053\003\023\003\ -\129\002\104\003\023\003\161\001\023\003\178\004\186\000\058\003\ -\215\001\183\001\163\005\038\006\159\005\077\002\012\005\214\003\ -\162\001\200\005\243\001\243\004\106\003\025\003\025\003\187\001\ -\030\000\025\003\170\005\216\001\213\005\190\000\130\002\239\003\ -\107\006\059\003\092\004\246\003\054\003\143\004\115\005\131\002\ -\225\001\039\006\225\001\244\001\225\001\023\003\187\001\225\001\ -\158\001\186\000\023\003\106\003\192\005\245\001\051\000\148\003\ -\187\001\200\002\234\001\023\003\234\001\165\001\234\001\144\004\ -\132\002\165\001\028\004\166\000\249\001\220\001\203\001\159\003\ -\200\002\221\001\133\002\165\001\161\001\140\003\010\003\200\002\ -\222\001\193\001\020\005\223\001\165\001\211\002\023\005\211\002\ -\006\005\162\001\002\002\027\005\238\002\146\000\246\001\210\005\ -\211\002\247\001\017\002\211\002\106\003\018\002\200\002\176\001\ -\200\002\106\003\188\003\023\003\038\005\039\005\002\002\160\001\ -\144\002\234\001\200\002\220\003\163\000\044\005\206\002\165\000\ -\190\001\150\000\242\005\165\001\150\000\234\001\150\000\150\000\ -\207\002\225\005\122\005\186\000\145\002\211\002\234\001\119\006\ -\188\000\186\000\234\001\022\005\053\005\131\005\211\002\026\005\ -\001\006\150\000\166\000\249\001\021\003\175\000\175\000\163\001\ -\175\000\054\003\187\000\200\002\187\001\181\001\200\002\198\001\ -\187\001\139\004\175\000\175\000\150\000\010\003\164\001\021\003\ -\186\000\036\006\164\001\150\000\077\002\124\001\021\003\002\002\ -\007\002\164\001\025\006\197\000\210\005\010\003\106\003\146\002\ -\187\001\022\001\175\000\175\000\147\002\164\001\013\002\051\000\ -\050\005\150\000\150\000\103\006\021\003\002\002\109\003\187\001\ -\030\000\186\000\220\003\065\005\051\000\150\000\008\002\029\000\ -\021\003\188\001\029\000\110\003\017\006\150\000\195\001\150\000\ -\021\003\186\000\021\003\104\006\029\000\029\000\042\006\186\000\ -\029\000\106\003\010\003\128\006\164\001\049\005\236\001\023\001\ -\106\003\029\000\029\000\029\000\029\000\024\001\196\000\006\005\ -\187\000\089\001\090\001\009\002\138\005\023\003\122\005\029\000\ -\029\000\111\003\051\000\211\002\004\003\129\002\102\001\237\001\ -\150\000\196\000\146\005\021\003\147\005\186\000\131\005\214\000\ -\196\000\084\004\186\000\029\000\211\002\023\003\029\000\226\001\ -\029\000\029\000\029\000\029\000\158\001\030\000\187\001\095\001\ -\029\000\029\000\190\000\130\002\177\002\131\005\196\000\029\000\ -\006\005\025\002\215\000\103\001\131\002\023\003\211\002\187\001\ -\100\001\124\001\196\000\029\000\234\001\029\000\217\004\029\000\ -\029\000\196\000\196\000\172\004\196\000\025\003\144\005\021\003\ -\186\000\232\005\122\005\029\000\235\005\132\002\029\000\255\002\ -\230\001\146\000\029\000\229\001\023\003\186\000\026\002\133\002\ -\218\004\178\002\021\003\187\004\161\005\025\003\234\001\023\003\ -\047\002\021\003\025\003\025\003\050\006\131\005\138\003\010\006\ -\162\004\164\004\166\004\234\001\025\003\196\000\169\004\220\005\ -\131\005\234\001\025\003\047\002\255\002\006\005\187\001\021\003\ -\021\003\187\001\047\002\047\002\026\003\110\002\006\005\111\002\ -\181\001\011\006\234\001\021\003\023\003\025\003\187\001\135\002\ -\198\001\112\002\234\001\021\003\255\002\021\003\243\001\025\003\ -\047\002\047\002\223\003\077\002\029\006\030\006\224\003\033\006\ -\034\006\011\003\017\004\102\001\047\002\225\003\150\000\187\001\ -\226\003\143\003\241\001\047\002\047\002\150\000\047\002\150\000\ -\252\001\227\003\198\001\150\004\224\005\055\006\150\000\150\000\ -\007\004\150\000\227\005\023\003\023\003\051\000\021\003\015\002\ -\056\006\020\006\023\003\243\001\252\001\150\000\023\003\018\004\ -\130\005\150\000\234\001\234\001\240\005\175\000\175\000\023\003\ -\026\006\234\001\234\001\234\001\234\001\023\003\077\002\047\002\ -\186\000\131\005\211\002\021\006\156\005\234\001\023\003\051\000\ -\146\003\011\003\187\005\187\001\023\003\146\000\175\000\175\000\ -\175\000\023\003\155\001\187\001\234\001\188\005\175\000\009\006\ -\211\002\220\001\073\003\081\006\211\002\221\001\158\001\023\002\ -\211\002\211\002\211\002\211\002\222\001\187\001\187\001\223\001\ -\113\001\157\005\122\005\190\000\122\005\175\000\175\000\211\002\ -\065\006\023\003\175\000\108\006\131\005\215\000\175\000\187\001\ -\023\003\013\002\074\006\006\005\209\005\011\003\214\002\134\003\ -\215\002\187\001\150\000\150\000\005\006\187\001\024\002\118\006\ -\139\001\198\001\216\002\146\000\187\001\187\001\211\002\088\006\ -\000\005\150\000\175\000\110\005\025\003\125\006\126\006\186\000\ -\058\004\148\001\154\001\175\000\027\002\215\002\196\002\196\002\ -\155\001\013\002\097\006\216\002\202\002\196\002\001\005\029\002\ -\186\000\178\002\030\000\014\000\069\006\175\000\002\005\183\001\ -\003\005\178\002\196\002\048\002\112\006\186\000\051\000\077\006\ -\196\002\187\000\015\000\016\000\103\003\004\005\023\003\018\002\ -\146\000\025\003\215\002\013\003\006\005\185\002\048\002\023\000\ -\216\002\023\003\019\003\196\002\196\002\048\002\048\002\069\006\ -\069\006\148\005\058\001\186\000\082\000\095\006\096\006\132\006\ -\175\000\023\003\031\000\051\000\051\000\074\001\164\003\050\005\ -\157\002\011\002\035\000\048\002\048\002\036\002\104\003\147\000\ -\039\000\109\005\089\000\113\006\186\000\030\000\042\000\048\002\ -\181\001\245\004\110\005\135\002\181\001\051\000\048\002\048\002\ -\181\001\048\002\181\001\011\002\123\006\187\000\181\001\181\001\ -\247\004\147\000\181\001\242\003\089\000\083\000\127\006\043\002\ -\252\001\069\006\050\000\181\001\183\000\053\000\041\002\134\006\ -\135\006\150\000\243\003\244\003\150\000\072\002\073\002\074\002\ -\075\002\217\001\135\002\150\000\252\001\150\000\150\000\146\000\ -\166\000\076\002\048\002\161\000\057\002\023\003\183\000\151\003\ -\023\003\023\003\186\000\150\000\218\001\023\003\023\003\065\002\ -\175\000\152\003\181\001\210\001\058\002\150\000\161\000\210\001\ -\127\005\181\001\063\004\187\000\023\003\161\000\023\003\175\000\ -\175\000\210\001\023\003\064\003\245\002\246\002\023\003\023\003\ -\023\003\064\004\210\001\181\001\181\001\077\002\181\001\181\001\ -\065\003\060\002\155\001\161\000\161\000\023\003\155\001\150\000\ -\139\002\150\000\155\001\023\003\155\001\102\001\150\000\161\000\ -\155\001\181\001\025\003\175\000\155\001\071\002\161\000\161\000\ -\140\002\161\000\120\002\150\000\175\000\155\001\175\000\120\002\ -\189\000\054\003\025\003\196\000\023\003\198\000\199\000\200\000\ -\013\002\215\004\201\000\202\000\203\000\204\000\205\000\220\001\ -\206\000\245\002\248\002\221\001\017\002\007\003\186\000\018\002\ -\209\001\126\004\222\001\057\001\209\001\223\001\059\001\060\001\ -\061\001\035\006\161\000\215\000\155\001\159\002\209\001\175\000\ -\066\001\067\001\154\001\155\001\068\001\069\001\154\001\209\001\ -\186\000\160\002\154\001\163\002\154\001\135\002\013\002\103\003\ -\154\001\154\001\164\002\167\001\063\003\155\001\155\001\167\001\ -\155\001\155\001\064\003\093\005\151\002\154\001\150\000\198\004\ -\165\002\011\003\128\000\198\000\190\005\186\000\094\005\065\003\ -\172\002\199\004\167\001\155\001\173\002\132\001\133\001\134\001\ -\135\001\174\002\137\001\180\002\164\002\146\000\198\000\176\001\ -\186\002\104\003\185\002\176\001\082\000\198\000\215\002\082\000\ -\135\002\190\002\176\001\191\002\154\001\176\001\135\002\225\002\ -\215\002\082\000\227\002\154\001\002\003\082\000\176\001\150\000\ -\186\000\071\001\150\000\198\000\198\000\237\002\082\000\082\000\ -\082\000\082\000\011\003\150\000\018\003\154\001\154\001\198\000\ -\154\001\154\001\025\003\025\003\150\000\082\000\198\000\198\000\ -\030\003\198\000\175\000\166\002\167\002\083\000\032\003\043\003\ -\196\001\197\001\035\003\154\001\044\003\176\001\048\003\044\002\ -\082\000\045\002\083\000\082\000\247\002\249\002\083\000\082\000\ -\082\000\069\003\051\003\046\002\045\003\175\000\082\000\083\000\ -\083\000\083\000\083\000\047\003\082\000\115\002\008\003\116\002\ -\049\003\070\003\198\000\219\002\240\001\220\002\083\000\175\001\ -\082\000\117\002\082\000\175\001\082\000\082\000\051\000\221\002\ -\175\000\037\004\175\001\038\004\090\001\175\001\135\002\062\003\ -\082\000\083\000\150\000\082\000\083\000\039\004\094\003\083\000\ -\083\000\083\000\150\000\086\003\175\000\175\000\083\000\083\000\ -\101\003\175\000\175\000\175\000\108\003\083\000\150\000\175\000\ -\096\004\114\003\097\004\135\002\116\003\175\000\135\002\120\003\ -\130\003\083\000\139\003\083\000\098\004\083\000\083\000\094\000\ -\120\002\150\000\007\003\186\000\071\001\175\001\192\001\120\002\ -\145\003\083\000\120\002\153\003\083\000\175\000\095\000\016\000\ -\083\000\222\001\160\003\172\003\120\002\038\002\039\002\173\003\ -\120\002\047\002\186\003\096\000\245\002\177\002\199\003\013\002\ -\054\003\120\002\120\002\120\002\120\002\077\002\212\003\230\003\ -\229\003\231\003\232\003\048\002\233\003\174\000\031\000\237\003\ -\120\002\070\000\014\004\021\004\027\004\051\004\035\000\047\004\ -\060\004\056\002\105\003\067\004\097\000\010\000\063\002\080\004\ -\208\000\082\004\042\000\120\002\178\002\135\002\120\002\085\004\ -\177\002\120\002\120\002\120\002\135\002\102\004\111\004\116\004\ -\120\002\120\002\098\000\105\004\117\004\150\000\219\000\120\002\ -\127\004\125\004\130\004\150\000\132\004\149\004\099\000\014\000\ -\135\002\053\000\131\004\120\002\164\002\120\002\158\004\120\002\ -\120\002\177\004\190\004\195\004\164\002\192\004\015\000\016\000\ -\203\004\164\002\204\004\120\002\250\004\005\005\120\002\175\000\ -\205\004\206\004\120\002\023\000\214\004\150\000\164\002\207\004\ -\164\002\164\002\211\004\212\004\213\004\221\004\175\000\150\000\ -\225\004\226\004\228\004\150\000\241\004\164\002\031\000\013\005\ -\235\004\074\001\029\005\018\005\013\002\101\005\035\000\024\005\ -\043\005\077\005\025\005\117\005\039\000\028\005\021\003\072\005\ -\164\002\046\005\042\000\164\002\116\005\120\005\164\002\164\002\ -\164\002\121\005\123\005\133\005\136\005\079\003\164\002\143\005\ -\169\002\145\005\129\000\121\000\164\002\164\005\059\005\184\001\ -\202\005\013\002\135\002\205\005\150\000\181\005\050\000\182\005\ -\164\002\053\000\183\005\206\005\164\002\164\002\223\005\150\000\ -\230\005\199\001\174\000\174\000\233\005\174\000\248\005\008\006\ -\164\002\194\002\023\006\164\002\175\000\027\006\041\006\174\000\ -\174\000\216\003\058\006\072\002\073\002\074\002\075\002\250\004\ -\135\002\013\002\023\003\254\005\063\006\066\006\012\003\076\002\ -\064\006\067\006\135\002\072\006\247\003\073\006\150\000\174\000\ -\174\000\002\004\098\006\011\002\075\006\023\003\167\005\093\006\ -\116\006\117\006\111\005\111\006\023\003\150\000\121\006\124\006\ -\120\002\150\000\130\006\120\002\131\006\051\000\089\000\008\000\ -\026\004\021\003\150\000\051\000\005\005\120\002\084\002\025\003\ -\023\003\120\002\023\003\077\002\128\000\089\000\178\002\105\002\ -\252\001\102\002\120\002\120\002\120\002\120\002\023\003\104\002\ -\033\003\023\003\023\003\023\003\065\004\175\000\023\003\036\003\ -\023\003\120\002\135\002\135\002\202\002\221\000\107\002\200\002\ -\020\002\070\000\150\000\200\002\070\000\001\000\002\000\003\000\ -\004\000\005\000\006\000\007\000\120\002\005\005\070\000\120\002\ -\201\002\178\002\120\002\120\002\120\002\201\002\150\000\150\000\ -\150\000\120\002\120\002\070\000\203\002\070\000\070\000\206\002\ -\120\002\023\003\207\002\135\002\208\002\204\002\111\005\149\001\ -\048\004\070\000\070\000\016\006\120\002\232\001\120\002\132\005\ -\120\002\120\002\184\001\217\005\101\006\006\006\072\003\192\003\ -\129\004\149\002\226\005\119\004\120\002\070\000\250\004\120\002\ -\070\000\124\002\084\003\120\002\070\000\070\000\150\000\137\004\ -\210\002\206\001\147\003\070\000\025\003\025\003\150\000\134\005\ -\201\004\070\000\005\005\025\003\250\004\141\002\175\000\208\002\ -\242\004\025\003\182\003\005\005\176\002\070\000\150\000\219\005\ -\025\003\070\000\070\000\194\005\247\005\096\005\025\003\000\000\ -\150\000\113\002\175\000\000\000\000\000\070\000\150\000\000\000\ -\070\000\000\000\174\004\175\004\000\000\000\000\000\000\000\000\ -\000\000\025\003\025\003\021\003\000\000\000\000\000\000\000\000\ -\150\000\000\000\000\000\186\004\000\000\000\000\000\000\148\002\ -\000\000\000\000\021\003\021\003\000\000\000\000\000\000\000\000\ -\194\004\000\000\000\000\000\000\150\000\000\000\150\000\021\003\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\202\004\000\000\000\000\150\000\000\000\000\000\250\004\150\000\ -\000\000\195\000\021\003\175\000\000\000\021\003\000\000\000\000\ -\250\004\000\000\021\003\000\000\000\000\000\000\135\002\184\001\ -\021\003\000\000\174\000\174\000\195\000\000\000\021\003\000\000\ -\000\000\175\000\223\004\195\000\162\000\000\000\173\002\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\021\003\021\003\ -\000\000\000\000\000\000\174\000\174\000\174\000\000\000\162\000\ -\000\000\195\000\021\003\174\000\000\000\021\003\162\000\000\000\ -\000\000\250\004\217\002\000\000\000\000\195\000\000\000\000\000\ -\005\005\000\000\177\000\000\000\195\000\195\000\194\000\195\000\ -\000\000\010\005\174\000\174\000\162\000\162\000\000\000\174\000\ -\150\000\000\000\017\005\174\000\000\000\194\000\011\002\000\000\ -\162\000\000\000\000\000\150\000\000\000\000\000\199\001\162\000\ -\162\000\000\000\162\000\000\000\000\000\199\001\000\000\000\000\ -\194\000\000\000\000\000\250\004\000\000\000\000\000\000\174\000\ -\195\000\000\000\000\000\150\000\150\000\000\000\000\000\022\004\ -\174\000\150\000\150\000\000\000\000\000\000\000\011\002\000\000\ -\000\000\000\000\111\005\150\000\111\005\232\001\000\000\000\000\ -\232\001\005\005\174\000\162\000\000\000\061\003\194\000\150\000\ -\194\000\194\000\232\001\055\005\000\000\057\005\208\000\000\000\ -\232\001\014\003\000\000\000\000\000\000\000\000\000\000\232\001\ -\150\000\232\001\232\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\150\000\000\000\000\000\150\000\232\001\000\000\ -\000\000\000\000\000\000\150\000\150\000\174\000\000\000\000\000\ -\000\000\000\000\097\005\000\000\000\000\000\000\000\000\100\005\ -\000\000\232\001\000\000\000\000\232\001\000\000\094\002\000\000\ -\232\001\232\001\000\000\000\000\000\000\000\000\000\000\232\001\ -\136\000\000\000\137\000\138\000\030\000\232\001\139\000\000\000\ -\000\000\140\000\141\000\173\002\000\000\000\000\000\000\177\000\ -\177\000\232\001\177\000\000\000\000\000\232\001\232\001\000\000\ -\000\000\000\000\142\000\000\000\177\000\177\000\000\000\135\005\ -\000\000\232\001\143\000\144\000\232\001\000\000\000\000\000\000\ -\194\000\000\000\145\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\177\000\003\002\146\000\147\000\ -\000\000\194\000\000\000\000\000\199\001\174\000\000\000\150\005\ -\000\000\152\005\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\174\000\174\000\173\002\000\000\ -\173\002\173\002\173\002\168\005\000\000\000\000\173\002\178\005\ -\179\005\000\000\000\000\173\002\000\000\000\000\000\000\173\002\ -\173\002\173\002\000\000\000\000\000\000\180\003\184\005\000\000\ -\173\002\173\002\173\002\173\002\000\000\000\000\000\000\000\000\ -\174\000\000\000\173\002\000\000\011\002\000\000\000\000\173\002\ -\000\000\174\000\000\000\174\000\197\005\000\000\173\002\173\002\ -\000\000\000\000\000\000\000\000\000\000\011\002\000\000\000\000\ -\194\000\000\000\173\002\000\000\000\000\173\002\173\002\000\000\ -\173\002\173\002\173\002\000\000\173\002\000\000\000\000\173\002\ -\173\002\000\000\000\000\000\000\000\000\194\000\173\002\000\000\ -\000\000\000\000\215\003\000\000\174\000\000\000\000\000\000\000\ -\000\000\173\002\173\002\000\000\173\002\173\002\173\002\173\002\ -\000\000\000\000\173\002\011\002\000\000\000\000\000\000\245\005\ -\000\000\163\000\173\002\173\002\171\000\173\002\000\000\000\000\ -\249\005\173\002\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\163\000\002\006\000\000\000\000\ -\004\006\000\000\000\000\163\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\194\000\180\000\000\000\ -\194\000\194\000\000\000\000\000\194\000\000\000\194\000\000\000\ -\000\000\163\000\163\000\000\000\062\004\000\000\000\000\000\000\ -\194\000\028\006\000\000\000\000\156\002\163\000\094\002\194\000\ -\094\002\094\002\094\002\000\000\163\000\163\000\094\002\163\000\ -\000\000\000\000\000\000\094\002\184\001\000\000\000\000\094\002\ -\094\002\094\002\000\000\000\000\000\000\194\000\000\000\174\000\ -\094\002\094\002\094\002\094\002\000\000\000\000\000\000\000\000\ -\000\000\194\000\094\002\000\000\000\000\000\000\000\000\094\002\ -\194\000\194\000\000\000\194\000\000\000\000\000\094\002\094\002\ -\163\000\000\000\174\000\000\000\000\000\000\000\000\000\177\000\ -\003\002\000\000\094\002\000\000\000\000\094\002\000\000\000\000\ -\094\002\094\002\094\002\000\000\094\002\000\000\000\000\094\002\ -\094\002\000\000\000\000\086\006\000\000\174\000\094\002\000\000\ -\177\000\177\000\177\000\000\000\194\000\000\000\000\000\000\000\ -\177\000\094\002\094\002\000\000\094\002\094\002\094\002\094\002\ -\000\000\174\000\174\000\000\000\000\000\000\000\174\000\174\000\ -\174\000\000\000\094\002\000\000\174\000\094\002\000\000\003\002\ -\177\000\094\002\174\000\000\000\003\002\000\000\000\000\000\000\ -\177\000\114\006\115\006\000\000\011\002\000\000\000\000\000\000\ -\000\000\122\006\000\000\180\000\180\000\000\000\180\000\000\000\ -\000\000\011\002\174\000\000\000\000\000\000\000\000\000\000\000\ -\180\000\180\000\000\000\000\000\177\000\133\006\011\002\000\000\ -\011\002\011\002\000\000\000\000\011\002\177\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\011\002\000\000\250\001\ -\180\000\180\000\178\000\000\000\000\000\000\000\195\000\177\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\011\002\000\000\000\000\194\000\219\004\195\000\011\002\011\002\ -\011\002\000\000\000\000\000\000\171\000\000\000\011\002\171\000\ -\000\000\000\000\000\000\000\000\011\002\000\000\000\000\000\000\ -\195\000\171\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\011\002\000\000\177\000\000\000\011\002\000\000\171\000\171\000\ -\171\000\171\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\011\002\000\000\000\000\011\002\000\000\171\000\000\000\000\000\ -\000\000\011\002\184\001\000\000\174\000\000\000\195\000\000\000\ -\195\000\195\000\000\000\000\000\156\002\000\000\000\000\156\002\ -\171\000\000\000\000\000\174\000\156\002\000\000\000\000\171\000\ -\171\000\156\002\156\002\000\000\000\000\000\000\171\000\156\002\ -\000\000\011\002\177\002\000\000\171\000\000\000\156\002\179\000\ -\156\002\156\002\000\000\000\000\000\000\000\000\000\000\000\000\ -\171\000\000\000\171\000\067\002\171\000\156\002\000\000\000\000\ -\000\000\000\000\000\000\159\001\078\002\000\000\000\000\000\000\ -\171\000\000\000\177\000\171\000\000\000\000\000\011\002\000\000\ -\156\002\000\000\000\000\156\002\000\000\177\002\156\002\156\002\ -\156\002\177\000\177\000\010\000\000\000\157\001\156\002\178\000\ -\178\000\000\000\178\000\156\002\156\002\000\000\000\000\000\000\ -\000\000\174\000\000\000\000\000\178\000\178\000\000\000\000\000\ -\156\002\000\000\181\003\000\000\156\002\156\002\011\002\000\000\ -\195\000\000\000\199\001\000\000\000\000\177\000\000\000\000\000\ -\156\002\000\000\000\000\156\002\178\000\004\002\177\000\000\000\ -\003\002\195\000\000\000\000\000\136\000\000\000\137\000\138\000\ -\030\000\000\000\139\000\000\000\000\000\140\000\141\000\000\000\ -\000\000\000\000\000\000\023\003\000\000\000\000\000\000\000\000\ -\000\000\184\001\000\000\000\000\000\000\000\000\142\000\000\000\ -\023\003\000\000\000\000\000\000\000\000\010\000\143\000\144\000\ -\000\000\003\002\000\000\000\000\054\000\023\003\145\000\023\003\ -\023\003\000\000\174\000\180\000\180\000\000\000\000\000\000\000\ -\000\000\000\000\146\000\147\000\023\003\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\179\000\179\000\000\000\179\000\ -\000\000\000\000\184\001\199\002\180\000\180\000\180\000\023\003\ -\195\000\179\000\179\000\000\000\180\000\000\000\136\000\023\003\ -\137\000\138\000\030\000\000\000\139\000\023\003\081\001\158\001\ -\141\000\000\000\000\000\023\003\000\000\195\000\000\000\000\000\ -\000\000\179\000\179\000\180\000\180\000\000\000\000\000\000\000\ -\180\000\000\000\000\000\023\003\180\000\220\000\220\000\000\000\ -\000\000\144\000\087\001\088\001\089\001\090\001\078\002\023\003\ -\145\000\011\002\023\003\000\000\000\000\000\000\000\000\000\000\ -\000\000\011\002\000\000\000\000\146\000\147\000\011\002\184\001\ -\180\000\186\000\000\000\174\000\177\000\000\000\092\001\093\001\ -\184\001\038\003\000\000\011\002\000\000\011\002\011\002\000\000\ -\000\000\000\000\095\001\096\001\097\001\098\001\000\000\174\000\ -\195\000\195\000\011\002\180\000\195\000\000\000\195\000\003\002\ -\130\001\131\001\000\000\100\001\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\011\002\000\000\000\000\ -\011\002\000\000\000\000\011\002\011\002\011\002\000\000\000\000\ -\000\000\000\000\177\000\011\002\000\000\000\000\000\000\000\000\ -\159\001\011\002\186\002\000\000\190\002\000\000\038\003\159\001\ -\000\000\159\001\000\000\000\000\000\000\011\002\177\000\003\002\ -\000\000\011\002\011\002\177\000\177\000\177\000\000\000\000\000\ -\174\000\177\000\184\001\000\000\000\000\011\002\000\000\177\000\ -\011\002\000\000\000\000\000\000\000\000\000\000\000\000\178\000\ -\004\002\000\000\000\000\000\000\000\000\000\000\174\000\000\000\ -\167\001\000\000\000\000\000\000\000\000\000\000\000\000\177\000\ -\138\002\180\003\000\000\000\000\000\000\168\001\000\000\000\000\ -\178\000\178\000\178\000\000\000\081\001\000\000\000\000\000\000\ -\178\000\000\000\000\000\000\000\000\000\048\006\000\000\000\000\ -\136\000\000\000\137\000\138\000\030\000\184\001\139\000\000\000\ -\060\006\169\001\141\000\000\000\054\000\000\000\180\000\004\002\ -\178\000\088\001\089\001\090\001\004\002\000\000\000\000\000\000\ -\178\000\054\000\000\000\000\000\000\000\180\000\180\000\000\000\ -\179\002\180\003\000\000\144\000\000\000\000\000\054\000\000\000\ -\054\000\054\000\145\000\000\000\092\001\093\001\000\000\000\000\ -\000\000\000\000\000\000\000\000\178\000\054\000\146\000\147\000\ -\095\001\096\001\097\001\098\001\000\000\178\000\000\000\000\000\ -\000\000\180\000\000\000\000\000\179\000\179\000\000\000\000\000\ -\054\000\100\001\180\000\054\000\180\000\000\000\184\001\178\000\ -\054\000\003\002\000\000\000\000\000\000\000\000\054\000\000\000\ -\000\000\000\000\000\000\195\000\054\000\179\000\179\000\179\000\ -\003\002\000\000\000\000\000\000\000\000\179\000\179\000\000\000\ -\054\000\000\000\000\000\000\000\054\000\054\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\180\000\000\000\000\000\ -\054\000\000\000\178\000\054\000\179\000\179\000\000\000\000\000\ -\000\000\179\000\000\000\000\000\000\000\179\000\000\000\079\002\ -\080\002\081\002\082\002\083\002\084\002\085\002\086\002\087\002\ -\088\002\089\002\090\002\091\002\092\002\093\002\094\002\095\002\ -\096\002\097\002\098\002\099\002\182\002\102\002\000\000\000\000\ -\103\002\179\000\000\000\105\002\000\000\106\002\000\000\107\002\ -\000\000\108\002\179\000\109\002\000\000\000\000\003\002\000\000\ -\000\000\000\000\000\000\159\001\000\000\000\000\000\000\000\000\ -\126\002\000\000\000\000\000\000\179\000\000\000\000\000\186\002\ -\000\000\190\002\000\000\078\002\000\000\000\000\000\000\142\002\ -\000\000\143\002\000\000\000\000\000\000\000\000\186\002\186\002\ -\190\002\190\002\178\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\158\002\000\000\186\002\000\000\190\002\000\000\000\000\ -\180\000\178\000\178\000\000\000\138\002\000\000\000\000\179\000\ -\000\000\057\000\000\000\194\000\000\000\000\000\186\002\000\000\ -\190\002\186\002\000\000\190\002\000\000\000\000\186\002\000\000\ -\190\002\000\000\000\000\180\000\186\002\000\000\190\002\003\002\ -\000\000\000\000\186\002\213\002\190\002\178\000\000\000\000\000\ -\000\000\000\000\000\000\138\002\000\000\000\000\178\000\000\000\ -\004\002\000\000\186\002\186\002\190\002\190\002\180\000\000\000\ -\000\000\000\000\228\002\000\000\000\000\000\000\186\002\000\000\ -\190\002\186\002\212\002\190\002\213\002\000\000\000\000\000\000\ -\000\000\000\000\180\000\180\000\000\000\000\000\160\004\180\000\ -\180\000\180\000\000\000\000\000\213\002\180\000\213\002\213\002\ -\213\002\004\002\213\002\180\000\000\000\213\002\213\002\179\000\ -\000\000\003\003\136\000\006\003\137\000\138\000\030\000\000\000\ -\139\000\000\000\000\000\140\000\141\000\000\000\179\000\179\000\ -\000\000\020\003\000\000\180\000\000\000\177\001\022\003\213\002\ -\000\000\000\000\000\000\000\000\142\000\000\000\213\002\000\000\ -\003\002\000\000\000\000\000\000\143\000\144\000\000\000\194\000\ -\000\000\229\002\213\002\213\002\145\000\000\000\000\000\000\000\ -\000\000\000\000\179\000\000\000\003\002\000\000\000\000\000\000\ -\146\000\147\000\000\000\179\000\000\000\179\000\000\000\000\000\ -\000\000\000\000\000\000\220\000\220\000\000\000\000\000\000\000\ -\000\000\159\001\000\000\000\000\000\000\000\000\073\004\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\138\002\000\000\ -\000\000\247\000\000\000\000\000\182\002\000\000\000\000\182\002\ -\000\000\000\000\000\000\000\000\178\000\000\000\179\000\089\003\ -\000\000\182\002\000\000\000\000\095\003\096\003\097\003\000\000\ -\000\000\000\000\000\000\000\000\000\000\003\002\182\002\182\002\ -\182\002\182\002\000\000\099\003\000\000\180\000\102\003\004\002\ -\000\000\000\000\000\000\000\000\000\000\182\002\000\000\000\000\ -\000\000\138\002\000\000\003\002\180\000\000\000\000\000\138\002\ -\000\000\000\000\000\000\000\000\000\000\000\000\045\006\000\000\ -\182\002\000\000\178\000\000\000\173\002\000\000\182\002\182\002\ -\182\002\000\000\000\000\000\000\000\000\173\002\182\002\000\000\ -\000\000\057\000\000\000\000\000\182\002\000\000\178\000\004\002\ -\000\000\000\000\000\000\178\000\178\000\178\000\057\000\000\000\ -\182\002\178\000\182\002\000\000\182\002\173\002\000\000\178\000\ -\173\002\000\000\000\000\057\000\000\000\057\000\057\000\000\000\ -\182\002\173\002\011\002\182\002\000\000\000\000\078\006\161\003\ -\000\000\179\000\057\000\000\000\165\003\166\003\167\003\178\000\ -\000\000\014\003\180\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\183\003\000\000\057\000\000\000\000\000\ -\057\000\000\000\000\000\000\000\179\000\057\000\000\000\138\002\ -\000\000\000\000\000\000\057\000\000\000\000\000\000\000\000\000\ -\000\000\057\000\000\000\200\003\000\000\000\000\203\003\000\000\ -\000\000\000\000\000\000\000\000\000\000\057\000\000\000\179\000\ -\000\000\057\000\057\000\210\003\138\002\000\000\000\000\138\002\ -\136\000\000\000\137\000\138\000\030\000\057\000\139\000\000\000\ -\057\000\140\000\141\000\179\000\179\000\232\004\000\000\000\000\ -\179\000\179\000\179\000\000\000\000\000\000\000\179\000\000\000\ -\000\000\000\000\142\000\180\000\179\000\000\000\000\000\000\000\ -\000\000\000\000\143\000\126\003\000\000\000\000\000\000\000\000\ -\032\000\000\000\145\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\004\002\000\000\000\000\179\000\151\004\146\000\147\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\004\002\000\000\000\000\000\000\000\000\000\000\000\000\040\004\ -\000\000\247\000\247\000\247\000\247\000\000\000\138\002\000\000\ -\000\000\247\000\247\000\247\000\000\000\138\002\247\000\247\000\ -\000\000\247\000\247\000\247\000\247\000\247\000\247\000\000\000\ -\000\000\247\000\247\000\247\000\247\000\247\000\247\000\000\000\ -\000\000\138\002\078\004\000\000\000\000\247\000\247\000\000\000\ -\000\000\247\000\247\000\247\000\247\000\000\000\081\000\000\000\ -\000\000\247\000\247\000\000\000\180\000\255\004\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\247\000\247\000\000\000\ -\247\000\000\000\000\000\247\000\247\000\247\000\004\002\247\000\ -\180\000\000\000\247\000\247\000\000\000\000\000\000\000\000\000\ -\000\000\247\000\000\000\247\000\000\000\000\000\179\000\118\004\ -\000\000\000\000\000\000\000\000\247\000\247\000\000\000\247\000\ -\247\000\247\000\247\000\000\000\000\000\179\000\000\000\000\000\ -\247\000\000\000\247\000\000\000\141\004\247\000\000\000\159\001\ -\247\000\000\000\011\002\000\000\247\000\011\002\000\000\148\004\ -\000\000\000\000\011\002\138\002\000\000\000\000\000\000\011\002\ -\000\000\000\000\000\000\195\000\000\000\011\002\023\003\000\000\ -\000\000\180\000\000\000\000\000\011\002\000\000\011\002\011\002\ -\000\000\000\000\000\000\023\003\000\000\000\000\000\000\004\002\ -\000\000\000\000\000\000\011\002\179\004\000\000\181\004\180\000\ -\255\004\138\002\000\000\000\000\000\000\000\000\023\003\000\000\ -\023\003\023\003\023\003\138\002\023\003\000\000\011\002\023\003\ -\023\003\011\002\000\000\179\000\011\002\011\002\011\002\000\000\ -\159\001\000\000\000\000\113\005\011\002\000\000\000\000\000\000\ -\000\000\000\000\011\002\000\000\000\000\000\000\208\004\209\004\ -\210\004\023\003\000\000\000\000\229\000\000\000\011\002\000\000\ -\023\003\000\000\011\002\011\002\000\000\216\004\000\000\000\000\ -\000\000\000\000\000\000\000\000\023\003\023\003\011\002\000\000\ -\032\000\011\002\000\000\032\000\000\000\000\000\000\000\000\000\ -\000\000\230\004\000\000\138\002\138\002\032\000\032\000\000\000\ -\000\000\032\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\004\002\000\000\032\000\032\000\032\000\032\000\000\000\195\000\ -\000\000\238\004\239\004\240\004\179\000\000\000\000\000\000\000\ -\032\000\032\000\000\000\000\000\004\002\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\138\002\000\000\000\000\113\005\ -\000\000\000\000\000\000\000\000\032\000\000\000\000\000\032\000\ -\000\000\000\000\000\000\032\000\032\000\000\000\000\000\185\005\ -\186\005\032\000\032\000\030\005\000\000\000\000\081\000\255\004\ -\032\000\081\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\081\000\032\000\000\000\032\000\081\000\ -\032\000\032\000\000\000\000\000\000\000\255\004\000\000\000\000\ -\081\000\081\000\081\000\081\000\032\000\004\002\000\000\032\000\ -\000\000\060\002\000\000\032\000\000\000\000\000\052\005\081\000\ -\054\005\000\000\056\005\016\003\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\004\002\000\000\179\000\000\000\000\000\ -\000\000\000\000\081\000\000\000\000\000\081\000\078\005\079\005\ -\080\005\081\000\081\000\000\000\087\005\088\005\089\005\000\000\ -\081\000\179\000\000\000\000\000\000\000\000\000\081\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\081\000\000\000\081\000\103\005\081\000\081\000\ -\000\000\113\005\136\000\000\000\137\000\138\000\030\000\255\004\ -\139\000\118\005\081\000\140\000\141\000\081\000\000\000\000\000\ -\000\000\255\004\125\005\000\000\000\000\000\000\129\005\138\002\ -\000\000\000\000\000\000\000\000\142\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\143\000\144\000\000\000\000\000\ -\000\000\000\000\179\000\000\000\145\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\146\000\147\000\000\000\000\000\229\000\229\000\229\000\229\000\ -\179\000\000\000\255\004\000\000\229\000\229\000\229\000\000\000\ -\000\000\229\000\229\000\229\000\229\000\229\000\229\000\229\000\ -\229\000\229\000\000\000\000\000\229\000\229\000\229\000\229\000\ -\229\000\229\000\000\000\122\002\000\000\000\000\000\000\000\000\ -\229\000\229\000\000\000\000\000\229\000\229\000\229\000\229\000\ -\229\000\229\000\229\000\000\000\229\000\229\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\255\004\000\000\000\000\000\000\ -\229\000\229\000\000\000\229\000\000\000\000\000\229\000\229\000\ -\229\000\000\000\229\000\229\000\229\000\229\000\229\000\000\000\ -\000\000\000\000\000\000\113\005\229\000\113\005\229\000\229\000\ -\229\000\229\000\229\000\000\000\000\000\000\000\000\000\229\000\ -\229\000\000\000\229\000\229\000\229\000\229\000\000\000\000\000\ -\229\000\000\000\000\000\229\000\000\000\229\000\000\000\000\000\ -\229\000\000\000\000\000\229\000\000\000\000\000\000\000\229\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\239\005\000\000\000\000\000\000\014\000\000\000\000\000\000\000\ -\000\000\060\002\000\000\060\002\060\002\060\002\250\005\251\005\ -\252\005\060\002\000\000\015\000\016\000\000\000\060\002\164\002\ -\000\000\000\000\060\002\060\002\060\002\000\000\000\000\000\000\ -\023\000\000\000\007\006\060\002\060\002\060\002\060\002\000\000\ -\000\000\000\000\000\000\000\000\000\000\060\002\000\000\018\006\ -\000\000\060\002\060\002\031\000\000\000\022\006\074\001\000\000\ -\000\000\060\002\060\002\035\000\000\000\000\000\000\000\000\000\ -\000\000\039\000\000\000\000\000\000\000\060\002\037\006\042\000\ -\060\002\000\000\000\000\060\002\060\002\060\002\046\006\060\002\ -\000\000\000\000\060\002\060\002\000\000\000\000\000\000\046\000\ -\000\000\060\002\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\050\000\060\002\060\002\053\000\060\002\ -\060\002\060\002\000\000\000\000\000\000\060\002\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\060\002\000\000\000\000\ -\060\002\000\000\000\000\000\000\060\002\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\079\006\080\006\ -\000\000\000\000\000\000\041\001\000\000\082\006\083\006\084\006\ -\085\006\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\089\006\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\122\002\122\002\122\002\122\002\000\000\ -\099\006\122\002\122\002\122\002\122\002\122\002\122\002\122\002\ -\122\002\122\002\122\002\122\002\122\002\122\002\122\002\122\002\ -\122\002\122\002\000\000\122\002\122\002\122\002\122\002\122\002\ -\122\002\122\002\122\002\000\000\000\000\000\000\000\000\122\002\ -\122\002\000\000\000\000\122\002\122\002\122\002\122\002\122\002\ -\122\002\122\002\122\002\122\002\122\002\122\002\122\002\000\000\ -\122\002\122\002\122\002\122\002\000\000\000\000\122\002\122\002\ -\122\002\110\002\122\002\122\002\122\002\122\002\122\002\122\002\ -\000\000\122\002\122\002\122\002\122\002\122\002\000\000\122\002\ -\000\000\000\000\000\000\122\002\122\002\122\002\122\002\122\002\ -\122\002\122\002\122\002\000\000\122\002\000\000\122\002\122\002\ -\061\001\122\002\122\002\122\002\122\002\122\002\000\000\122\002\ -\122\002\000\000\122\002\122\002\122\002\122\002\000\000\122\002\ -\122\002\000\000\122\002\000\000\000\000\000\000\122\002\164\002\ -\164\002\164\002\164\002\164\002\000\000\164\002\164\002\164\002\ -\164\002\164\002\164\002\164\002\164\002\164\002\164\002\164\002\ -\164\002\164\002\164\002\164\002\164\002\000\000\000\000\164\002\ -\164\002\164\002\164\002\164\002\164\002\164\002\164\002\000\000\ -\000\000\000\000\000\000\164\002\164\002\000\000\000\000\164\002\ -\164\002\164\002\164\002\164\002\164\002\164\002\164\002\164\002\ -\164\002\164\002\164\002\000\000\164\002\164\002\164\002\164\002\ -\000\000\000\000\164\002\164\002\164\002\000\000\164\002\164\002\ -\164\002\164\002\164\002\164\002\000\000\164\002\164\002\164\002\ -\164\002\164\002\000\000\164\002\000\000\000\000\000\000\164\002\ -\164\002\164\002\164\002\164\002\164\002\164\002\164\002\000\000\ -\164\002\000\000\164\002\164\002\047\001\164\002\164\002\164\002\ -\164\002\164\002\000\000\164\002\164\002\000\000\164\002\164\002\ -\164\002\164\002\000\000\164\002\164\002\000\000\164\002\000\000\ -\000\000\000\000\164\002\041\001\041\001\041\001\041\001\000\000\ -\000\000\041\001\041\001\041\001\041\001\041\001\041\001\041\001\ -\041\001\041\001\041\001\041\001\041\001\041\001\041\001\041\001\ -\041\001\041\001\000\000\041\001\041\001\041\001\041\001\041\001\ -\041\001\041\001\041\001\000\000\000\000\000\000\000\000\041\001\ -\041\001\000\000\000\000\041\001\041\001\041\001\041\001\041\001\ -\041\001\041\001\041\001\041\001\041\001\041\001\041\001\000\000\ -\041\001\041\001\041\001\041\001\000\000\000\000\041\001\041\001\ -\041\001\000\000\041\001\041\001\041\001\041\001\041\001\041\001\ -\000\000\041\001\041\001\041\001\041\001\041\001\000\000\041\001\ -\000\000\000\000\000\000\041\001\041\001\041\001\041\001\041\001\ -\041\001\041\001\041\001\000\000\041\001\000\000\041\001\041\001\ -\045\001\041\001\041\001\041\001\041\001\041\001\000\000\041\001\ -\041\001\000\000\041\001\041\001\041\001\041\001\000\000\041\001\ -\041\001\000\000\041\001\000\000\000\000\000\000\041\001\000\000\ -\061\001\061\001\061\001\061\001\000\000\000\000\061\001\061\001\ -\061\001\061\001\061\001\061\001\061\001\061\001\061\001\061\001\ -\061\001\061\001\061\001\061\001\061\001\061\001\061\001\000\000\ -\061\001\061\001\061\001\061\001\061\001\061\001\061\001\061\001\ -\000\000\000\000\000\000\000\000\061\001\061\001\000\000\000\000\ -\061\001\061\001\061\001\061\001\061\001\061\001\061\001\061\001\ -\061\001\061\001\061\001\061\001\000\000\061\001\061\001\061\001\ -\061\001\000\000\000\000\061\001\061\001\061\001\000\000\061\001\ -\061\001\061\001\061\001\061\001\061\001\000\000\061\001\061\001\ -\061\001\061\001\061\001\000\000\061\001\000\000\000\000\000\000\ -\061\001\061\001\061\001\061\001\061\001\061\001\061\001\061\001\ -\000\000\061\001\000\000\061\001\061\001\053\001\061\001\061\001\ -\061\001\061\001\061\001\000\000\061\001\061\001\000\000\061\001\ -\061\001\061\001\061\001\000\000\061\001\061\001\000\000\061\001\ -\000\000\000\000\000\000\061\001\047\001\047\001\047\001\047\001\ -\000\000\000\000\047\001\047\001\047\001\047\001\047\001\047\001\ -\047\001\047\001\047\001\047\001\047\001\047\001\047\001\047\001\ -\047\001\047\001\047\001\000\000\047\001\047\001\047\001\047\001\ -\047\001\047\001\047\001\047\001\000\000\000\000\000\000\000\000\ -\047\001\047\001\000\000\000\000\047\001\047\001\047\001\047\001\ -\047\001\047\001\047\001\047\001\047\001\047\001\047\001\047\001\ -\000\000\047\001\047\001\047\001\047\001\000\000\000\000\047\001\ -\047\001\047\001\000\000\047\001\047\001\047\001\047\001\047\001\ -\047\001\000\000\047\001\047\001\047\001\047\001\047\001\000\000\ -\047\001\000\000\000\000\000\000\047\001\047\001\047\001\047\001\ -\047\001\047\001\047\001\047\001\000\000\047\001\000\000\047\001\ -\047\001\049\001\047\001\047\001\047\001\047\001\047\001\000\000\ -\047\001\047\001\000\000\047\001\047\001\047\001\047\001\000\000\ -\047\001\047\001\000\000\047\001\000\000\000\000\000\000\047\001\ -\045\001\045\001\045\001\045\001\000\000\000\000\045\001\045\001\ -\045\001\045\001\045\001\045\001\045\001\045\001\045\001\045\001\ -\045\001\045\001\045\001\045\001\045\001\045\001\045\001\000\000\ -\045\001\045\001\045\001\045\001\045\001\045\001\045\001\045\001\ -\000\000\000\000\000\000\000\000\045\001\045\001\000\000\000\000\ -\045\001\045\001\045\001\045\001\045\001\045\001\045\001\045\001\ -\045\001\045\001\045\001\045\001\000\000\045\001\045\001\045\001\ -\045\001\000\000\000\000\045\001\045\001\045\001\000\000\045\001\ -\045\001\045\001\045\001\045\001\045\001\000\000\045\001\045\001\ -\045\001\045\001\045\001\000\000\045\001\000\000\000\000\000\000\ -\045\001\045\001\045\001\045\001\045\001\045\001\045\001\045\001\ -\000\000\045\001\000\000\045\001\045\001\051\001\045\001\045\001\ -\045\001\045\001\045\001\000\000\045\001\045\001\000\000\045\001\ -\045\001\045\001\045\001\000\000\045\001\045\001\000\000\045\001\ -\000\000\000\000\000\000\045\001\000\000\053\001\053\001\053\001\ -\053\001\000\000\000\000\053\001\053\001\053\001\053\001\053\001\ -\053\001\053\001\053\001\053\001\053\001\053\001\053\001\053\001\ -\053\001\053\001\053\001\053\001\000\000\053\001\053\001\053\001\ -\053\001\053\001\053\001\053\001\053\001\000\000\000\000\000\000\ -\000\000\053\001\053\001\000\000\000\000\053\001\053\001\053\001\ -\053\001\053\001\053\001\053\001\053\001\053\001\053\001\053\001\ -\053\001\000\000\053\001\053\001\053\001\053\001\000\000\000\000\ -\053\001\053\001\053\001\000\000\053\001\053\001\053\001\053\001\ -\053\001\053\001\000\000\053\001\053\001\053\001\053\001\053\001\ -\000\000\053\001\000\000\000\000\000\000\053\001\053\001\053\001\ -\053\001\053\001\053\001\053\001\053\001\000\000\053\001\000\000\ -\053\001\053\001\059\001\053\001\053\001\053\001\053\001\053\001\ -\000\000\053\001\053\001\000\000\053\001\053\001\053\001\053\001\ -\000\000\053\001\053\001\000\000\053\001\000\000\000\000\000\000\ -\053\001\049\001\049\001\049\001\049\001\000\000\000\000\049\001\ -\049\001\049\001\049\001\049\001\049\001\049\001\049\001\049\001\ -\049\001\049\001\049\001\049\001\049\001\049\001\049\001\049\001\ -\000\000\049\001\049\001\049\001\049\001\049\001\049\001\049\001\ -\049\001\000\000\000\000\000\000\000\000\049\001\049\001\000\000\ -\000\000\049\001\049\001\049\001\049\001\049\001\049\001\049\001\ -\049\001\049\001\049\001\049\001\049\001\000\000\049\001\049\001\ -\049\001\049\001\000\000\000\000\049\001\049\001\049\001\000\000\ -\049\001\049\001\049\001\049\001\049\001\049\001\000\000\049\001\ -\049\001\049\001\049\001\049\001\000\000\049\001\000\000\000\000\ -\000\000\049\001\049\001\049\001\049\001\049\001\049\001\049\001\ -\049\001\000\000\049\001\000\000\049\001\049\001\055\001\049\001\ -\049\001\049\001\049\001\049\001\000\000\049\001\049\001\000\000\ -\049\001\049\001\049\001\049\001\000\000\049\001\049\001\000\000\ -\049\001\000\000\000\000\000\000\049\001\051\001\051\001\051\001\ -\051\001\000\000\000\000\051\001\051\001\051\001\051\001\051\001\ -\051\001\051\001\051\001\051\001\051\001\051\001\051\001\051\001\ -\051\001\051\001\051\001\051\001\000\000\051\001\051\001\051\001\ -\051\001\051\001\051\001\051\001\051\001\000\000\000\000\000\000\ -\000\000\051\001\051\001\000\000\000\000\051\001\051\001\051\001\ -\051\001\051\001\051\001\051\001\051\001\051\001\051\001\051\001\ -\051\001\000\000\051\001\051\001\051\001\051\001\000\000\000\000\ -\051\001\051\001\051\001\000\000\051\001\051\001\051\001\051\001\ -\051\001\051\001\000\000\051\001\051\001\051\001\051\001\051\001\ -\000\000\051\001\000\000\000\000\000\000\051\001\051\001\051\001\ -\051\001\051\001\051\001\051\001\051\001\000\000\051\001\000\000\ -\051\001\051\001\057\001\051\001\051\001\051\001\051\001\051\001\ -\000\000\051\001\051\001\000\000\051\001\051\001\051\001\051\001\ -\000\000\051\001\051\001\000\000\051\001\000\000\000\000\000\000\ -\051\001\000\000\059\001\059\001\059\001\059\001\000\000\000\000\ -\059\001\059\001\059\001\059\001\059\001\059\001\059\001\059\001\ -\059\001\059\001\059\001\059\001\059\001\059\001\059\001\059\001\ -\059\001\000\000\059\001\059\001\059\001\059\001\059\001\059\001\ -\059\001\059\001\000\000\000\000\000\000\000\000\059\001\059\001\ -\000\000\000\000\059\001\059\001\059\001\059\001\059\001\059\001\ -\059\001\059\001\059\001\059\001\059\001\059\001\000\000\059\001\ -\059\001\059\001\059\001\000\000\000\000\059\001\059\001\059\001\ -\000\000\059\001\059\001\059\001\059\001\059\001\059\001\000\000\ -\059\001\059\001\059\001\059\001\059\001\000\000\059\001\000\000\ -\000\000\000\000\059\001\059\001\059\001\059\001\059\001\059\001\ -\059\001\059\001\000\000\059\001\000\000\059\001\059\001\088\001\ -\059\001\059\001\059\001\059\001\059\001\000\000\059\001\059\001\ -\000\000\059\001\059\001\059\001\059\001\000\000\059\001\059\001\ -\000\000\059\001\000\000\000\000\000\000\059\001\055\001\055\001\ -\055\001\055\001\000\000\000\000\055\001\055\001\055\001\055\001\ -\055\001\055\001\055\001\055\001\055\001\055\001\055\001\055\001\ -\055\001\055\001\055\001\055\001\055\001\000\000\055\001\055\001\ -\055\001\055\001\055\001\055\001\055\001\055\001\000\000\000\000\ -\000\000\000\000\055\001\055\001\000\000\000\000\055\001\055\001\ -\055\001\055\001\055\001\055\001\055\001\055\001\055\001\055\001\ -\055\001\055\001\000\000\055\001\055\001\055\001\055\001\000\000\ -\000\000\055\001\055\001\055\001\000\000\055\001\055\001\055\001\ -\055\001\055\001\055\001\000\000\055\001\055\001\055\001\055\001\ -\055\001\000\000\055\001\000\000\000\000\000\000\055\001\055\001\ -\055\001\055\001\055\001\055\001\055\001\055\001\000\000\055\001\ -\000\000\055\001\055\001\097\001\055\001\055\001\055\001\055\001\ -\055\001\000\000\055\001\055\001\000\000\055\001\055\001\055\001\ -\055\001\000\000\055\001\055\001\000\000\055\001\000\000\000\000\ -\000\000\055\001\057\001\057\001\057\001\057\001\000\000\000\000\ -\057\001\057\001\057\001\057\001\057\001\057\001\057\001\057\001\ -\057\001\057\001\057\001\057\001\057\001\057\001\057\001\057\001\ -\057\001\000\000\057\001\057\001\057\001\057\001\057\001\057\001\ -\057\001\057\001\000\000\000\000\000\000\000\000\057\001\057\001\ -\000\000\000\000\057\001\057\001\057\001\057\001\057\001\057\001\ -\057\001\057\001\057\001\057\001\057\001\057\001\000\000\057\001\ -\057\001\057\001\057\001\000\000\000\000\057\001\057\001\057\001\ -\000\000\057\001\057\001\057\001\057\001\057\001\057\001\000\000\ -\057\001\057\001\057\001\057\001\057\001\000\000\057\001\000\000\ -\000\000\000\000\057\001\057\001\057\001\057\001\057\001\057\001\ -\057\001\057\001\000\000\057\001\000\000\057\001\057\001\099\001\ -\057\001\057\001\057\001\057\001\057\001\000\000\057\001\057\001\ -\000\000\057\001\057\001\057\001\057\001\000\000\057\001\057\001\ -\000\000\057\001\000\000\000\000\000\000\057\001\000\000\088\001\ -\088\001\088\001\088\001\088\001\000\000\088\001\088\001\088\001\ -\088\001\088\001\088\001\088\001\088\001\088\001\088\001\088\001\ -\088\001\088\001\088\001\088\001\088\001\000\000\000\000\088\001\ -\088\001\088\001\088\001\088\001\088\001\088\001\088\001\000\000\ -\000\000\000\000\000\000\088\001\088\001\000\000\000\000\088\001\ -\088\001\088\001\088\001\088\001\088\001\088\001\000\000\088\001\ -\088\001\088\001\088\001\000\000\088\001\088\001\088\001\088\001\ -\000\000\000\000\088\001\088\001\088\001\000\000\088\001\088\001\ -\088\001\088\001\088\001\088\001\000\000\088\001\088\001\088\001\ -\088\001\088\001\000\000\088\001\000\000\000\000\000\000\088\001\ -\088\001\088\001\088\001\088\001\088\001\088\001\088\001\000\000\ -\088\001\000\000\088\001\088\001\102\001\088\001\088\001\088\001\ -\088\001\088\001\000\000\088\001\088\001\000\000\088\001\088\001\ -\088\001\088\001\000\000\088\001\088\001\000\000\088\001\000\000\ -\000\000\000\000\088\001\097\001\097\001\097\001\097\001\097\001\ -\000\000\097\001\097\001\097\001\097\001\097\001\097\001\097\001\ -\097\001\097\001\097\001\097\001\097\001\097\001\097\001\097\001\ -\097\001\000\000\000\000\097\001\097\001\097\001\097\001\097\001\ -\097\001\097\001\097\001\000\000\000\000\000\000\000\000\097\001\ -\097\001\000\000\000\000\097\001\097\001\097\001\097\001\097\001\ -\097\001\097\001\000\000\097\001\097\001\097\001\097\001\000\000\ -\097\001\097\001\097\001\097\001\000\000\000\000\097\001\097\001\ -\097\001\000\000\097\001\097\001\097\001\097\001\097\001\097\001\ -\000\000\097\001\097\001\097\001\097\001\097\001\000\000\097\001\ -\000\000\000\000\000\000\097\001\097\001\097\001\097\001\097\001\ -\097\001\097\001\097\001\000\000\097\001\000\000\097\001\097\001\ -\033\001\097\001\097\001\097\001\000\000\000\000\000\000\097\001\ -\097\001\000\000\097\001\097\001\097\001\097\001\000\000\097\001\ -\097\001\000\000\097\001\000\000\000\000\000\000\097\001\099\001\ -\099\001\099\001\099\001\099\001\000\000\099\001\099\001\099\001\ -\099\001\099\001\099\001\099\001\099\001\099\001\099\001\099\001\ -\099\001\099\001\099\001\099\001\099\001\000\000\000\000\099\001\ -\099\001\099\001\099\001\099\001\099\001\099\001\099\001\000\000\ -\000\000\000\000\000\000\099\001\099\001\000\000\000\000\099\001\ -\099\001\099\001\099\001\099\001\099\001\099\001\000\000\099\001\ -\099\001\099\001\099\001\000\000\099\001\099\001\099\001\099\001\ -\000\000\000\000\099\001\099\001\099\001\000\000\099\001\099\001\ -\099\001\099\001\099\001\099\001\000\000\099\001\099\001\099\001\ -\099\001\099\001\000\000\099\001\000\000\000\000\000\000\099\001\ -\099\001\099\001\099\001\099\001\099\001\099\001\099\001\000\000\ -\099\001\000\000\099\001\099\001\034\001\099\001\099\001\099\001\ -\000\000\000\000\000\000\099\001\099\001\000\000\099\001\099\001\ -\099\001\099\001\000\000\099\001\099\001\000\000\099\001\000\000\ -\000\000\000\000\099\001\000\000\102\001\102\001\102\001\102\001\ -\102\001\000\000\102\001\102\001\102\001\102\001\102\001\102\001\ -\102\001\102\001\102\001\102\001\102\001\102\001\102\001\102\001\ -\102\001\102\001\000\000\000\000\102\001\102\001\102\001\102\001\ -\102\001\102\001\102\001\102\001\000\000\000\000\000\000\000\000\ -\102\001\102\001\000\000\000\000\102\001\102\001\102\001\102\001\ -\102\001\102\001\102\001\000\000\102\001\102\001\102\001\102\001\ -\000\000\102\001\102\001\102\001\102\001\000\000\000\000\102\001\ -\102\001\102\001\000\000\102\001\102\001\102\001\102\001\102\001\ -\102\001\000\000\102\001\102\001\102\001\102\001\102\001\000\000\ -\102\001\000\000\000\000\000\000\102\001\102\001\102\001\102\001\ -\102\001\102\001\102\001\102\001\000\000\102\001\000\000\102\001\ -\102\001\228\000\102\001\102\001\102\001\000\000\000\000\000\000\ -\102\001\102\001\000\000\102\001\102\001\102\001\102\001\000\000\ -\102\001\102\001\000\000\102\001\000\000\000\000\000\000\102\001\ -\033\001\033\001\033\001\033\001\000\000\000\000\000\000\000\000\ -\033\001\033\001\033\001\000\000\000\000\033\001\033\001\033\001\ -\033\001\033\001\033\001\033\001\033\001\033\001\033\001\000\000\ -\033\001\033\001\033\001\033\001\033\001\033\001\000\000\000\000\ -\000\000\000\000\000\000\000\000\033\001\033\001\000\000\000\000\ -\033\001\033\001\033\001\033\001\033\001\033\001\033\001\033\001\ -\033\001\033\001\000\000\033\001\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\033\001\033\001\000\000\033\001\ -\000\000\000\000\033\001\033\001\033\001\000\000\033\001\033\001\ -\033\001\033\001\033\001\000\000\000\000\000\000\000\000\000\000\ -\033\001\033\001\033\001\033\001\033\001\033\001\033\001\000\000\ -\000\000\033\001\000\000\033\001\033\001\240\000\033\001\033\001\ -\033\001\033\001\033\001\000\000\033\001\000\000\000\000\033\001\ -\033\001\033\001\000\000\000\000\033\001\000\000\000\000\033\001\ -\000\000\000\000\000\000\033\001\034\001\034\001\034\001\034\001\ -\000\000\000\000\000\000\000\000\034\001\034\001\034\001\000\000\ -\000\000\034\001\034\001\034\001\034\001\034\001\034\001\034\001\ -\034\001\034\001\034\001\000\000\034\001\034\001\034\001\034\001\ -\034\001\034\001\000\000\000\000\000\000\000\000\000\000\000\000\ -\034\001\034\001\000\000\000\000\034\001\034\001\034\001\034\001\ -\034\001\034\001\034\001\034\001\034\001\034\001\000\000\034\001\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\034\001\034\001\000\000\034\001\000\000\000\000\034\001\034\001\ -\034\001\000\000\034\001\034\001\034\001\034\001\034\001\000\000\ -\000\000\000\000\000\000\000\000\034\001\034\001\034\001\034\001\ -\034\001\034\001\034\001\000\000\000\000\034\001\000\000\034\001\ -\034\001\241\000\034\001\034\001\034\001\034\001\034\001\000\000\ -\034\001\000\000\000\000\034\001\034\001\034\001\000\000\000\000\ -\034\001\000\000\000\000\034\001\000\000\000\000\000\000\034\001\ -\000\000\228\000\228\000\228\000\228\000\000\000\000\000\000\000\ -\000\000\228\000\228\000\228\000\000\000\000\000\228\000\228\000\ -\228\000\228\000\228\000\228\000\228\000\228\000\228\000\000\000\ -\000\000\228\000\228\000\228\000\228\000\228\000\228\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\228\000\228\000\000\000\ -\000\000\228\000\228\000\228\000\228\000\228\000\228\000\228\000\ -\000\000\228\000\228\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\228\000\228\000\000\000\ -\228\000\000\000\000\000\228\000\228\000\228\000\000\000\228\000\ -\228\000\228\000\228\000\228\000\000\000\000\000\000\000\000\000\ -\000\000\228\000\000\000\228\000\228\000\228\000\228\000\228\000\ -\000\000\000\000\000\000\000\000\228\000\228\000\242\000\228\000\ -\228\000\228\000\000\000\000\000\000\000\228\000\000\000\000\000\ -\228\000\000\000\228\000\000\000\000\000\228\000\000\000\000\000\ -\228\000\000\000\000\000\000\000\228\000\240\000\240\000\240\000\ -\240\000\000\000\000\000\000\000\000\000\240\000\240\000\240\000\ -\000\000\000\000\240\000\240\000\240\000\240\000\240\000\000\000\ -\240\000\240\000\240\000\000\000\000\000\240\000\240\000\240\000\ -\240\000\240\000\240\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\240\000\240\000\000\000\000\000\240\000\240\000\240\000\ -\240\000\240\000\240\000\240\000\000\000\240\000\240\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\240\000\240\000\000\000\240\000\000\000\000\000\240\000\ -\240\000\240\000\000\000\240\000\240\000\240\000\240\000\240\000\ -\000\000\000\000\000\000\000\000\000\000\240\000\000\000\240\000\ -\240\000\240\000\240\000\240\000\000\000\000\000\000\000\000\000\ -\240\000\240\000\025\001\240\000\240\000\240\000\240\000\000\000\ -\000\000\240\000\000\000\000\000\240\000\000\000\240\000\000\000\ -\000\000\240\000\000\000\000\000\240\000\000\000\000\000\000\000\ -\240\000\241\000\241\000\241\000\241\000\000\000\000\000\000\000\ -\000\000\241\000\241\000\241\000\000\000\000\000\241\000\241\000\ -\241\000\241\000\241\000\241\000\241\000\241\000\241\000\000\000\ -\000\000\241\000\241\000\241\000\241\000\241\000\241\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\241\000\241\000\000\000\ -\000\000\241\000\241\000\241\000\241\000\241\000\241\000\241\000\ -\000\000\241\000\241\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\241\000\241\000\000\000\ -\241\000\000\000\000\000\241\000\241\000\241\000\000\000\241\000\ -\241\000\241\000\241\000\241\000\000\000\000\000\000\000\000\000\ -\000\000\241\000\000\000\241\000\241\000\241\000\241\000\241\000\ -\000\000\000\000\000\000\000\000\241\000\241\000\026\001\241\000\ -\241\000\241\000\000\000\000\000\000\000\241\000\000\000\000\000\ -\241\000\000\000\241\000\000\000\000\000\241\000\000\000\000\000\ -\241\000\000\000\000\000\000\000\241\000\000\000\242\000\242\000\ -\242\000\242\000\000\000\000\000\000\000\000\000\242\000\242\000\ -\242\000\000\000\000\000\242\000\242\000\242\000\242\000\242\000\ -\242\000\242\000\242\000\242\000\000\000\000\000\242\000\242\000\ -\242\000\242\000\242\000\242\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\242\000\242\000\000\000\000\000\242\000\242\000\ -\242\000\242\000\242\000\242\000\242\000\000\000\242\000\242\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\242\000\242\000\000\000\242\000\000\000\000\000\ -\242\000\242\000\242\000\000\000\242\000\242\000\242\000\242\000\ -\242\000\000\000\000\000\000\000\000\000\000\000\242\000\000\000\ -\242\000\242\000\242\000\242\000\242\000\000\000\000\000\000\000\ -\000\000\242\000\242\000\251\000\242\000\242\000\242\000\000\000\ -\000\000\000\000\242\000\000\000\000\000\242\000\000\000\242\000\ -\000\000\000\000\242\000\000\000\000\000\242\000\000\000\000\000\ -\000\000\242\000\025\001\025\001\025\001\025\001\000\000\000\000\ -\000\000\000\000\025\001\025\001\025\001\000\000\000\000\025\001\ -\025\001\025\001\025\001\025\001\025\001\025\001\025\001\025\001\ -\000\000\000\000\025\001\025\001\025\001\025\001\025\001\025\001\ -\000\000\000\000\000\000\000\000\000\000\000\000\025\001\025\001\ -\000\000\000\000\025\001\025\001\025\001\025\001\025\001\025\001\ -\025\001\000\000\025\001\025\001\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\025\001\025\001\ -\000\000\025\001\000\000\000\000\025\001\025\001\025\001\000\000\ -\025\001\025\001\025\001\025\001\025\001\000\000\000\000\000\000\ -\000\000\000\000\025\001\000\000\025\001\025\001\025\001\025\001\ -\025\001\000\000\000\000\000\000\000\000\025\001\025\001\252\000\ -\025\001\025\001\025\001\000\000\000\000\000\000\025\001\000\000\ -\000\000\025\001\000\000\025\001\000\000\000\000\025\001\000\000\ -\000\000\025\001\000\000\000\000\000\000\025\001\026\001\026\001\ -\026\001\026\001\000\000\000\000\000\000\000\000\026\001\026\001\ -\026\001\000\000\000\000\026\001\026\001\026\001\026\001\026\001\ -\026\001\026\001\026\001\026\001\000\000\000\000\026\001\026\001\ -\026\001\026\001\026\001\026\001\000\000\000\000\000\000\000\000\ -\000\000\000\000\026\001\026\001\000\000\000\000\026\001\026\001\ -\026\001\026\001\026\001\026\001\026\001\000\000\026\001\026\001\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\026\001\026\001\000\000\026\001\000\000\000\000\ -\026\001\026\001\026\001\000\000\026\001\026\001\026\001\026\001\ -\026\001\000\000\000\000\000\000\000\000\000\000\026\001\000\000\ -\026\001\026\001\026\001\026\001\026\001\000\000\000\000\000\000\ -\000\000\026\001\026\001\003\001\026\001\026\001\026\001\000\000\ -\000\000\000\000\026\001\000\000\000\000\026\001\000\000\026\001\ -\000\000\000\000\026\001\000\000\000\000\026\001\000\000\000\000\ -\000\000\026\001\000\000\251\000\251\000\251\000\251\000\000\000\ -\000\000\000\000\000\000\251\000\251\000\251\000\000\000\000\000\ -\251\000\251\000\251\000\251\000\251\000\251\000\251\000\251\000\ -\251\000\000\000\000\000\251\000\251\000\251\000\251\000\251\000\ -\251\000\000\000\000\000\000\000\000\000\000\000\000\000\251\000\ -\251\000\000\000\000\000\251\000\251\000\251\000\251\000\251\000\ -\251\000\000\000\000\000\251\000\251\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\251\000\ -\251\000\000\000\251\000\000\000\000\000\251\000\251\000\251\000\ -\000\000\251\000\251\000\251\000\251\000\251\000\000\000\000\000\ -\000\000\000\000\000\000\251\000\000\000\251\000\251\000\251\000\ -\251\000\251\000\000\000\000\000\000\000\000\000\251\000\251\000\ -\002\001\251\000\251\000\251\000\251\000\000\000\000\000\251\000\ -\000\000\000\000\251\000\000\000\251\000\000\000\000\000\251\000\ -\000\000\000\000\251\000\000\000\000\000\000\000\251\000\252\000\ -\252\000\252\000\252\000\000\000\000\000\000\000\000\000\252\000\ -\252\000\252\000\000\000\000\000\252\000\252\000\252\000\252\000\ -\252\000\252\000\252\000\252\000\252\000\000\000\000\000\252\000\ -\252\000\252\000\252\000\252\000\252\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\252\000\252\000\000\000\000\000\252\000\ -\252\000\252\000\252\000\252\000\252\000\000\000\000\000\252\000\ -\252\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\252\000\252\000\000\000\252\000\000\000\ -\000\000\252\000\252\000\252\000\000\000\252\000\252\000\252\000\ -\252\000\252\000\000\000\000\000\000\000\000\000\000\000\252\000\ -\000\000\252\000\252\000\252\000\252\000\252\000\000\000\000\000\ -\000\000\000\000\252\000\252\000\234\000\252\000\252\000\252\000\ -\252\000\000\000\000\000\252\000\000\000\000\000\252\000\000\000\ -\252\000\000\000\000\000\252\000\000\000\000\000\252\000\000\000\ -\000\000\000\000\252\000\003\001\003\001\003\001\003\001\000\000\ -\000\000\000\000\000\000\003\001\003\001\003\001\000\000\000\000\ -\003\001\003\001\003\001\003\001\003\001\003\001\003\001\003\001\ -\003\001\000\000\000\000\003\001\003\001\003\001\003\001\003\001\ -\003\001\000\000\000\000\000\000\000\000\000\000\000\000\003\001\ -\003\001\000\000\000\000\003\001\003\001\003\001\003\001\003\001\ -\003\001\000\000\000\000\003\001\003\001\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\003\001\ -\003\001\000\000\003\001\000\000\000\000\003\001\003\001\003\001\ -\000\000\003\001\003\001\003\001\003\001\003\001\000\000\000\000\ -\000\000\000\000\000\000\003\001\000\000\003\001\003\001\003\001\ -\003\001\003\001\000\000\000\000\000\000\000\000\003\001\003\001\ -\237\000\003\001\003\001\003\001\003\001\000\000\000\000\003\001\ -\000\000\000\000\003\001\000\000\003\001\000\000\000\000\003\001\ -\000\000\000\000\003\001\000\000\000\000\000\000\003\001\000\000\ -\002\001\002\001\002\001\002\001\000\000\000\000\000\000\000\000\ -\002\001\002\001\002\001\000\000\000\000\002\001\002\001\002\001\ -\002\001\002\001\002\001\002\001\002\001\002\001\000\000\000\000\ -\002\001\002\001\002\001\002\001\002\001\002\001\000\000\000\000\ -\000\000\000\000\000\000\000\000\002\001\002\001\000\000\000\000\ -\002\001\002\001\002\001\002\001\002\001\002\001\000\000\000\000\ -\002\001\002\001\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\002\001\002\001\000\000\002\001\ -\000\000\000\000\002\001\002\001\002\001\000\000\002\001\002\001\ -\002\001\002\001\002\001\000\000\000\000\000\000\000\000\000\000\ -\002\001\000\000\002\001\002\001\002\001\002\001\002\001\000\000\ -\000\000\000\000\000\000\002\001\002\001\238\000\002\001\002\001\ -\002\001\002\001\000\000\000\000\002\001\000\000\000\000\002\001\ -\000\000\002\001\000\000\000\000\002\001\000\000\000\000\002\001\ -\000\000\000\000\000\000\002\001\234\000\234\000\234\000\234\000\ -\000\000\000\000\000\000\000\000\000\000\234\000\234\000\000\000\ -\000\000\234\000\234\000\234\000\234\000\234\000\234\000\234\000\ -\234\000\234\000\000\000\000\000\234\000\234\000\234\000\234\000\ -\234\000\234\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\234\000\234\000\000\000\000\000\234\000\234\000\234\000\234\000\ -\234\000\234\000\234\000\000\000\234\000\234\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\234\000\234\000\000\000\234\000\000\000\000\000\234\000\234\000\ -\234\000\000\000\234\000\234\000\234\000\234\000\234\000\000\000\ -\000\000\000\000\000\000\000\000\234\000\000\000\234\000\234\000\ -\234\000\234\000\234\000\000\000\000\000\000\000\000\000\234\000\ -\234\000\250\000\234\000\234\000\234\000\234\000\000\000\000\000\ -\234\000\000\000\000\000\234\000\000\000\234\000\000\000\000\000\ -\234\000\000\000\000\000\234\000\000\000\000\000\000\000\234\000\ -\237\000\237\000\237\000\237\000\000\000\000\000\000\000\000\000\ -\000\000\237\000\237\000\000\000\000\000\237\000\237\000\237\000\ -\237\000\237\000\237\000\237\000\237\000\237\000\000\000\000\000\ -\237\000\237\000\237\000\237\000\237\000\237\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\237\000\237\000\000\000\000\000\ -\237\000\237\000\237\000\237\000\237\000\237\000\237\000\000\000\ -\237\000\237\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\237\000\237\000\000\000\237\000\ -\000\000\000\000\237\000\237\000\237\000\000\000\237\000\237\000\ -\237\000\237\000\237\000\000\000\000\000\000\000\000\000\000\000\ -\237\000\000\000\237\000\237\000\237\000\237\000\237\000\000\000\ -\000\000\000\000\000\000\237\000\237\000\000\001\237\000\237\000\ -\237\000\237\000\000\000\000\000\237\000\000\000\000\000\237\000\ -\000\000\237\000\000\000\000\000\237\000\000\000\000\000\237\000\ -\000\000\000\000\000\000\237\000\000\000\238\000\238\000\238\000\ -\238\000\000\000\000\000\000\000\000\000\000\000\238\000\238\000\ -\000\000\000\000\238\000\238\000\238\000\238\000\238\000\238\000\ -\238\000\238\000\238\000\000\000\000\000\238\000\238\000\238\000\ -\238\000\238\000\238\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\238\000\238\000\000\000\000\000\238\000\238\000\238\000\ -\238\000\238\000\238\000\238\000\000\000\238\000\238\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\238\000\238\000\000\000\238\000\000\000\000\000\238\000\ -\238\000\238\000\000\000\238\000\238\000\238\000\238\000\238\000\ -\000\000\000\000\000\000\000\000\000\000\238\000\000\000\238\000\ -\238\000\238\000\238\000\238\000\000\000\000\000\000\000\000\000\ -\238\000\238\000\001\001\238\000\238\000\238\000\238\000\000\000\ -\000\000\238\000\000\000\000\000\238\000\000\000\238\000\000\000\ -\000\000\238\000\000\000\000\000\238\000\000\000\000\000\000\000\ -\238\000\250\000\250\000\250\000\250\000\000\000\000\000\000\000\ -\000\000\250\000\250\000\250\000\000\000\000\000\250\000\250\000\ -\250\000\250\000\250\000\250\000\250\000\250\000\250\000\000\000\ -\000\000\250\000\250\000\250\000\250\000\250\000\250\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\250\000\250\000\000\000\ -\000\000\250\000\250\000\250\000\250\000\250\000\000\000\000\000\ -\000\000\250\000\250\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\250\000\250\000\000\000\ -\250\000\000\000\000\000\250\000\250\000\250\000\000\000\250\000\ -\250\000\250\000\250\000\250\000\000\000\000\000\000\000\000\000\ -\000\000\250\000\000\000\250\000\000\000\250\000\250\000\250\000\ -\000\000\000\000\000\000\000\000\250\000\250\000\253\000\250\000\ -\250\000\250\000\250\000\000\000\000\000\000\000\000\000\000\000\ -\250\000\000\000\250\000\000\000\000\000\250\000\000\000\000\000\ -\250\000\000\000\000\000\000\000\250\000\000\001\000\001\000\001\ -\000\001\000\000\000\000\000\000\000\000\000\001\000\001\000\001\ -\000\000\000\000\000\001\000\001\000\001\000\001\000\001\000\001\ -\000\001\000\001\000\001\000\000\000\000\000\001\000\001\000\001\ -\000\001\000\001\000\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\001\000\001\000\000\000\000\000\001\000\001\000\001\ -\000\001\000\001\000\000\000\000\000\000\000\001\000\001\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\001\000\001\000\000\000\001\000\000\000\000\000\001\ -\000\001\000\001\000\000\000\001\000\001\000\001\000\001\000\001\ -\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\001\ -\000\000\000\001\000\001\000\001\000\000\000\000\000\000\000\000\ -\000\001\000\001\254\000\000\001\000\001\000\001\000\001\000\000\ -\000\000\000\000\000\000\000\000\000\001\000\000\000\001\000\000\ -\000\000\000\001\000\000\000\000\000\001\000\000\000\000\000\000\ -\000\001\000\000\001\001\001\001\001\001\001\001\000\000\000\000\ -\000\000\000\000\001\001\001\001\001\001\000\000\000\000\001\001\ -\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\ -\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\ -\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\ -\000\000\000\000\001\001\001\001\001\001\001\001\001\001\000\000\ -\000\000\000\000\001\001\001\001\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\ -\000\000\001\001\000\000\000\000\001\001\001\001\001\001\000\000\ -\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\ -\000\000\000\000\001\001\000\000\001\001\000\000\001\001\001\001\ -\001\001\000\000\000\000\000\000\000\000\001\001\001\001\255\000\ -\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\ -\000\000\001\001\000\000\001\001\000\000\000\000\001\001\000\000\ -\000\000\001\001\000\000\000\000\000\000\001\001\253\000\253\000\ -\253\000\253\000\000\000\000\000\000\000\000\000\253\000\253\000\ -\253\000\000\000\000\000\253\000\253\000\253\000\253\000\253\000\ -\253\000\253\000\253\000\253\000\000\000\000\000\253\000\253\000\ -\253\000\253\000\253\000\253\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\253\000\253\000\000\000\000\000\253\000\253\000\ -\253\000\253\000\253\000\000\000\000\000\000\000\253\000\253\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\253\000\253\000\000\000\253\000\000\000\000\000\ -\253\000\253\000\253\000\000\000\253\000\253\000\253\000\253\000\ -\253\000\000\000\000\000\000\000\000\000\000\000\253\000\000\000\ -\253\000\000\000\253\000\253\000\253\000\000\000\000\000\000\000\ -\000\000\253\000\253\000\208\000\253\000\253\000\253\000\253\000\ -\000\000\000\000\000\000\000\000\000\000\253\000\000\000\253\000\ -\000\000\000\000\253\000\000\000\000\000\253\000\000\000\000\000\ -\000\000\253\000\254\000\254\000\254\000\254\000\000\000\000\000\ -\000\000\000\000\254\000\254\000\254\000\000\000\000\000\254\000\ -\254\000\254\000\254\000\254\000\254\000\254\000\254\000\254\000\ -\000\000\000\000\254\000\254\000\254\000\254\000\254\000\254\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\254\000\254\000\ -\000\000\000\000\254\000\254\000\254\000\254\000\254\000\000\000\ -\000\000\000\000\254\000\254\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\254\000\254\000\ -\000\000\254\000\000\000\000\000\254\000\254\000\254\000\000\000\ -\254\000\254\000\254\000\254\000\254\000\000\000\000\000\000\000\ -\000\000\000\000\254\000\000\000\254\000\000\000\254\000\254\000\ -\254\000\000\000\000\000\000\000\000\000\254\000\254\000\004\001\ -\254\000\254\000\254\000\254\000\000\000\000\000\000\000\000\000\ -\000\000\254\000\000\000\254\000\000\000\000\000\254\000\000\000\ -\000\000\254\000\000\000\000\000\000\000\254\000\000\000\255\000\ -\255\000\255\000\255\000\000\000\000\000\000\000\000\000\255\000\ -\255\000\255\000\000\000\000\000\255\000\255\000\255\000\255\000\ -\255\000\255\000\255\000\255\000\255\000\000\000\000\000\255\000\ -\255\000\255\000\255\000\255\000\255\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\255\000\255\000\000\000\000\000\255\000\ -\255\000\255\000\255\000\255\000\000\000\000\000\000\000\255\000\ -\255\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\255\000\255\000\000\000\255\000\000\000\ -\000\000\255\000\255\000\255\000\000\000\255\000\255\000\255\000\ -\255\000\255\000\000\000\000\000\000\000\000\000\000\000\255\000\ -\000\000\255\000\000\000\255\000\255\000\255\000\000\000\000\000\ -\000\000\000\000\255\000\255\000\006\001\255\000\255\000\255\000\ -\255\000\000\000\000\000\000\000\000\000\000\000\255\000\000\000\ -\255\000\000\000\000\000\255\000\000\000\000\000\255\000\000\000\ -\000\000\000\000\255\000\208\000\208\000\208\000\208\000\000\000\ -\000\000\000\000\000\000\208\000\208\000\208\000\000\000\000\000\ -\208\000\208\000\208\000\208\000\208\000\208\000\208\000\208\000\ -\208\000\000\000\000\000\208\000\208\000\208\000\208\000\208\000\ -\208\000\000\000\000\000\000\000\000\000\000\000\000\000\208\000\ -\208\000\000\000\000\000\208\000\208\000\208\000\208\000\208\000\ -\208\000\208\000\000\000\208\000\208\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\208\000\ -\208\000\000\000\000\000\000\000\000\000\208\000\208\000\208\000\ -\000\000\208\000\000\000\000\000\208\000\208\000\000\000\000\000\ -\000\000\000\000\000\000\208\000\000\000\208\000\000\000\000\000\ -\000\000\208\000\000\000\000\000\000\000\000\000\208\000\208\000\ -\248\000\208\000\208\000\208\000\208\000\000\000\000\000\208\000\ -\000\000\000\000\208\000\000\000\208\000\000\000\000\000\208\000\ -\000\000\000\000\208\000\000\000\000\000\000\000\208\000\004\001\ -\004\001\004\001\004\001\000\000\000\000\000\000\000\000\004\001\ -\004\001\004\001\000\000\000\000\004\001\004\001\000\000\004\001\ -\004\001\004\001\004\001\004\001\004\001\000\000\000\000\004\001\ -\004\001\004\001\004\001\004\001\004\001\000\000\000\000\000\000\ -\000\000\000\000\000\000\004\001\004\001\000\000\000\000\004\001\ -\004\001\004\001\000\000\000\000\000\000\000\000\000\000\004\001\ -\004\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\004\001\004\001\000\000\004\001\000\000\ -\000\000\000\000\004\001\004\001\000\000\004\001\000\000\000\000\ -\004\001\004\001\000\000\000\000\000\000\000\000\000\000\004\001\ -\000\000\004\001\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\004\001\004\001\249\000\004\001\004\001\004\001\ -\004\001\000\000\000\000\000\000\000\000\000\000\004\001\000\000\ -\004\001\000\000\000\000\004\001\000\000\000\000\004\001\000\000\ -\000\000\000\000\004\001\000\000\006\001\006\001\006\001\006\001\ -\000\000\000\000\000\000\000\000\006\001\006\001\006\001\000\000\ -\000\000\006\001\006\001\000\000\006\001\006\001\006\001\006\001\ -\006\001\006\001\000\000\000\000\006\001\006\001\006\001\006\001\ -\006\001\006\001\000\000\000\000\000\000\000\000\000\000\000\000\ -\006\001\006\001\000\000\000\000\006\001\006\001\006\001\000\000\ -\000\000\000\000\000\000\000\000\006\001\006\001\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\006\001\006\001\000\000\006\001\000\000\000\000\000\000\006\001\ -\006\001\000\000\006\001\000\000\000\000\006\001\006\001\000\000\ -\000\000\000\000\000\000\000\000\006\001\000\000\006\001\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\006\001\ -\006\001\005\001\006\001\006\001\006\001\006\001\000\000\000\000\ -\000\000\000\000\000\000\006\001\000\000\006\001\000\000\000\000\ -\006\001\000\000\000\000\006\001\000\000\000\000\000\000\006\001\ -\248\000\248\000\248\000\248\000\000\000\000\000\000\000\000\000\ -\248\000\248\000\248\000\000\000\000\000\248\000\248\000\000\000\ -\248\000\248\000\248\000\248\000\248\000\248\000\000\000\000\000\ -\248\000\248\000\248\000\248\000\248\000\248\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\248\000\248\000\000\000\000\000\ -\248\000\248\000\248\000\000\000\000\000\000\000\000\000\000\000\ -\248\000\248\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\248\000\248\000\000\000\248\000\ -\000\000\000\000\000\000\248\000\248\000\000\000\248\000\000\000\ -\000\000\248\000\248\000\000\000\000\000\000\000\000\000\000\000\ -\248\000\010\001\248\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\248\000\248\000\000\000\248\000\248\000\ -\248\000\248\000\000\000\000\000\000\000\000\000\000\000\248\000\ -\000\000\248\000\000\000\000\000\248\000\000\000\000\000\248\000\ -\000\000\000\000\000\000\248\000\249\000\249\000\249\000\249\000\ -\000\000\000\000\000\000\000\000\249\000\249\000\249\000\000\000\ -\000\000\249\000\249\000\000\000\249\000\249\000\249\000\249\000\ -\249\000\249\000\000\000\000\000\249\000\249\000\249\000\249\000\ -\249\000\249\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\249\000\249\000\000\000\000\000\249\000\249\000\249\000\000\000\ -\000\000\000\000\000\000\000\000\249\000\249\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\249\000\249\000\000\000\249\000\000\000\000\000\000\000\249\000\ -\249\000\009\001\249\000\000\000\000\000\249\000\249\000\000\000\ -\000\000\000\000\000\000\000\000\249\000\000\000\249\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\249\000\ -\249\000\000\000\249\000\249\000\249\000\249\000\000\000\000\000\ -\000\000\000\000\000\000\249\000\000\000\249\000\000\000\000\000\ -\249\000\000\000\000\000\249\000\000\000\000\000\000\000\249\000\ -\000\000\005\001\005\001\005\001\005\001\000\000\000\000\000\000\ -\000\000\005\001\005\001\005\001\000\000\000\000\005\001\005\001\ -\000\000\005\001\005\001\005\001\005\001\005\001\005\001\000\000\ -\000\000\005\001\005\001\005\001\005\001\005\001\005\001\000\000\ -\000\000\000\000\000\000\000\000\000\000\005\001\005\001\000\000\ -\000\000\005\001\005\001\005\001\000\000\000\000\000\000\000\000\ -\000\000\005\001\005\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\008\001\000\000\000\000\000\000\005\001\005\001\000\000\ -\005\001\000\000\000\000\000\000\005\001\005\001\000\000\005\001\ -\000\000\000\000\005\001\005\001\000\000\000\000\000\000\000\000\ -\000\000\005\001\000\000\005\001\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\005\001\005\001\000\000\005\001\ -\005\001\005\001\005\001\000\000\000\000\000\000\000\000\000\000\ -\005\001\010\001\005\001\000\000\010\001\005\001\000\000\000\000\ -\005\001\010\001\010\001\010\001\005\001\000\000\010\001\010\001\ -\000\000\010\001\010\001\010\001\010\001\010\001\010\001\000\000\ -\000\000\010\001\010\001\010\001\000\000\010\001\010\001\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\010\001\000\000\ -\000\000\010\001\010\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\010\001\010\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\131\001\000\000\000\000\000\000\010\001\000\000\000\000\ -\010\001\000\000\000\000\000\000\010\001\010\001\000\000\010\001\ -\000\000\000\000\010\001\010\001\000\000\000\000\000\000\000\000\ -\000\000\010\001\000\000\010\001\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\010\001\010\001\000\000\010\001\ -\010\001\010\001\010\001\000\000\000\000\000\000\000\000\000\000\ -\010\001\009\001\010\001\000\000\009\001\010\001\000\000\000\000\ -\010\001\009\001\009\001\009\001\010\001\000\000\009\001\009\001\ -\000\000\009\001\009\001\009\001\009\001\009\001\009\001\000\000\ -\000\000\009\001\009\001\009\001\000\000\009\001\009\001\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\009\001\000\000\ -\000\000\009\001\009\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\009\001\009\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\007\001\000\000\000\000\000\000\009\001\000\000\000\000\ -\009\001\000\000\000\000\000\000\009\001\009\001\000\000\009\001\ -\000\000\000\000\009\001\009\001\000\000\000\000\000\000\000\000\ -\000\000\009\001\000\000\009\001\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\009\001\009\001\000\000\009\001\ -\009\001\009\001\009\001\000\000\000\000\000\000\000\000\000\000\ -\009\001\008\001\009\001\000\000\008\001\009\001\000\000\000\000\ -\009\001\008\001\000\000\008\001\009\001\000\000\008\001\008\001\ -\000\000\008\001\008\001\008\001\008\001\008\001\008\001\000\000\ -\000\000\008\001\008\001\008\001\000\000\008\001\008\001\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\008\001\000\000\ -\000\000\008\001\008\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\008\001\008\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\130\001\000\000\000\000\000\000\008\001\000\000\000\000\ -\008\001\000\000\000\000\000\000\008\001\008\001\000\000\008\001\ -\000\000\000\000\008\001\008\001\000\000\000\000\000\000\000\000\ -\000\000\008\001\000\000\000\000\000\000\000\000\000\000\021\003\ -\000\000\000\000\000\000\000\000\008\001\008\001\000\000\008\001\ -\008\001\008\001\008\001\000\000\000\000\000\000\000\000\000\000\ -\008\001\131\001\008\001\000\000\131\001\008\001\000\000\000\000\ -\008\001\131\001\000\000\131\001\008\001\000\000\131\001\131\001\ -\000\000\131\001\131\001\131\001\131\001\131\001\131\001\000\000\ -\000\000\131\001\131\001\131\001\000\000\131\001\131\001\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\131\001\000\000\ -\000\000\131\001\131\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\131\001\131\001\000\000\011\001\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\131\001\000\000\000\000\ -\131\001\000\000\000\000\000\000\131\001\131\001\000\000\131\001\ -\000\000\000\000\131\001\131\001\000\000\000\000\000\000\000\000\ -\000\000\131\001\021\003\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\131\001\131\001\000\000\131\001\ -\131\001\131\001\131\001\000\000\000\000\000\000\000\000\000\000\ -\131\001\007\001\131\001\000\000\007\001\131\001\000\000\000\000\ -\131\001\007\001\000\000\007\001\131\001\000\000\007\001\007\001\ -\000\000\007\001\007\001\007\001\007\001\007\001\007\001\000\000\ -\000\000\007\001\007\001\007\001\000\000\007\001\007\001\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\007\001\000\000\ -\000\000\007\001\007\001\000\000\000\000\000\000\000\000\024\001\ -\000\000\007\001\007\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\007\001\000\000\000\000\ -\007\001\000\000\000\000\000\000\007\001\007\001\000\000\007\001\ -\000\000\000\000\007\001\007\001\000\000\000\000\000\000\000\000\ -\000\000\007\001\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\007\001\007\001\000\000\007\001\ -\007\001\007\001\007\001\000\000\000\000\000\000\000\000\000\000\ -\007\001\130\001\007\001\000\000\130\001\007\001\000\000\000\000\ -\007\001\130\001\000\000\130\001\007\001\000\000\130\001\130\001\ -\000\000\130\001\130\001\130\001\130\001\130\001\130\001\000\000\ -\000\000\130\001\130\001\130\001\000\000\130\001\130\001\021\003\ -\000\000\000\000\000\000\000\000\000\000\000\000\130\001\000\000\ -\000\000\130\001\130\001\000\000\021\003\000\000\000\000\014\001\ -\167\001\130\001\130\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\021\003\000\000\021\003\021\003\130\001\000\000\000\000\ -\130\001\000\000\000\000\000\000\130\001\130\001\000\000\130\001\ -\021\003\000\000\130\001\130\001\000\000\094\000\000\000\000\000\ -\136\000\130\001\137\000\138\000\030\000\000\000\139\000\000\000\ -\000\000\169\001\141\000\021\003\130\001\130\001\021\003\130\001\ -\130\001\130\001\130\001\021\003\011\001\000\000\000\000\011\001\ -\130\001\021\003\130\001\000\000\011\001\130\001\011\001\021\003\ -\130\001\011\001\011\001\144\000\130\001\011\001\000\000\011\001\ -\011\001\011\001\145\000\021\003\011\001\011\001\011\001\021\003\ -\011\001\011\001\021\003\000\000\000\000\021\003\146\000\147\000\ -\000\000\011\001\000\000\021\003\011\001\011\001\021\003\021\003\ -\000\000\000\000\243\000\000\000\011\001\011\001\000\000\000\000\ -\000\000\000\000\000\000\000\000\021\003\000\000\021\003\021\003\ -\011\001\000\000\000\000\011\001\000\000\000\000\000\000\011\001\ -\011\001\000\000\011\001\021\003\000\000\011\001\011\001\000\000\ -\104\000\174\003\000\000\136\000\011\001\137\000\138\000\030\000\ -\000\000\139\000\000\000\000\000\158\001\141\000\021\003\011\001\ -\011\001\000\000\011\001\011\001\011\001\011\001\021\003\024\001\ -\000\000\000\000\024\001\011\001\021\003\011\001\000\000\024\001\ -\011\001\024\001\021\003\011\001\024\001\024\001\144\000\011\001\ -\024\001\000\000\024\001\024\001\024\001\145\000\021\003\024\001\ -\024\001\024\001\021\003\024\001\024\001\000\000\000\000\000\000\ -\000\000\146\000\147\000\000\000\024\001\000\000\021\003\024\001\ -\024\001\021\003\000\000\000\000\000\000\017\001\000\000\024\001\ -\024\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\024\001\000\000\000\000\024\001\000\000\ -\000\000\000\000\024\001\024\001\000\000\024\001\000\000\000\000\ -\024\001\024\001\000\000\000\000\000\000\000\000\000\000\024\001\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\024\001\024\001\000\000\024\001\024\001\024\001\ -\024\001\000\000\000\000\000\000\000\000\000\000\024\001\014\001\ -\024\001\000\000\014\001\024\001\000\000\000\000\024\001\014\001\ -\000\000\014\001\024\001\000\000\014\001\014\001\000\000\000\000\ -\014\001\000\000\014\001\014\001\014\001\000\000\000\000\014\001\ -\014\001\014\001\000\000\014\001\014\001\094\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\014\001\000\000\000\000\014\001\ -\014\001\000\000\094\000\000\000\000\000\016\001\000\000\014\001\ -\014\001\000\000\000\000\000\000\000\000\000\000\000\000\094\000\ -\000\000\094\000\094\000\014\001\000\000\000\000\014\001\000\000\ -\000\000\000\000\014\001\014\001\000\000\014\001\094\000\000\000\ -\014\001\014\001\000\000\021\003\000\000\000\000\136\000\014\001\ -\137\000\138\000\030\000\000\000\139\000\000\000\000\000\158\001\ -\141\000\094\000\014\001\014\001\000\000\014\001\014\001\014\001\ -\014\001\094\000\243\000\000\000\000\000\243\000\014\001\094\000\ -\014\001\000\000\243\000\014\001\243\000\094\000\014\001\243\000\ -\243\000\144\000\014\001\243\000\000\000\243\000\243\000\243\000\ -\145\000\094\000\243\000\243\000\243\000\094\000\243\000\243\000\ -\104\000\000\000\000\000\000\000\146\000\147\000\000\000\243\000\ -\000\000\094\000\243\000\243\000\094\000\104\000\000\000\000\000\ -\015\001\000\000\243\000\243\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\104\000\000\000\104\000\104\000\243\000\000\000\ -\000\000\243\000\000\000\000\000\000\000\243\000\243\000\000\000\ -\243\000\104\000\000\000\243\000\243\000\000\000\099\000\000\000\ -\000\000\000\000\243\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\104\000\243\000\243\000\000\000\ -\243\000\243\000\243\000\243\000\104\000\017\001\000\000\000\000\ -\017\001\243\000\104\000\243\000\000\000\017\001\243\000\017\001\ -\104\000\243\000\017\001\017\001\000\000\243\000\017\001\000\000\ -\017\001\017\001\017\001\000\000\104\000\017\001\017\001\017\001\ -\104\000\017\001\017\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\017\001\000\000\104\000\017\001\017\001\104\000\ -\000\000\000\000\000\000\020\001\000\000\017\001\017\001\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\017\001\000\000\000\000\017\001\000\000\000\000\000\000\ -\017\001\017\001\000\000\017\001\000\000\000\000\017\001\017\001\ -\000\000\000\000\000\000\000\000\000\000\017\001\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\017\001\017\001\000\000\017\001\017\001\017\001\017\001\000\000\ -\000\000\000\000\000\000\000\000\017\001\016\001\017\001\000\000\ -\016\001\017\001\000\000\000\000\017\001\016\001\000\000\016\001\ -\017\001\000\000\016\001\016\001\000\000\000\000\016\001\000\000\ -\016\001\016\001\016\001\000\000\000\000\016\001\016\001\016\001\ -\000\000\016\001\016\001\021\003\000\000\000\000\000\000\000\000\ -\000\000\000\000\016\001\000\000\000\000\016\001\016\001\000\000\ -\021\003\000\000\000\000\018\001\000\000\016\001\016\001\000\000\ -\000\000\000\000\000\000\000\000\000\000\021\003\000\000\021\003\ -\021\003\016\001\000\000\000\000\016\001\000\000\000\000\000\000\ -\016\001\016\001\000\000\016\001\021\003\000\000\016\001\016\001\ -\000\000\103\000\000\000\000\000\000\000\016\001\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\021\003\ -\016\001\016\001\000\000\016\001\016\001\016\001\016\001\021\003\ -\015\001\000\000\000\000\015\001\016\001\021\003\016\001\000\000\ -\015\001\016\001\015\001\021\003\016\001\015\001\015\001\000\000\ -\016\001\015\001\000\000\015\001\015\001\015\001\000\000\021\003\ -\015\001\015\001\015\001\021\003\015\001\015\001\099\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\015\001\000\000\021\003\ -\015\001\015\001\021\003\099\000\000\000\000\000\019\001\000\000\ -\015\001\015\001\000\000\000\000\000\000\000\000\000\000\000\000\ -\099\000\000\000\099\000\099\000\015\001\000\000\000\000\015\001\ -\000\000\000\000\000\000\015\001\015\001\000\000\015\001\099\000\ -\000\000\015\001\015\001\000\000\000\000\000\000\000\000\000\000\ -\015\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\099\000\015\001\015\001\000\000\015\001\015\001\ -\015\001\015\001\099\000\020\001\000\000\000\000\020\001\015\001\ -\099\000\015\001\000\000\020\001\015\001\020\001\099\000\015\001\ -\020\001\020\001\000\000\015\001\020\001\000\000\020\001\020\001\ -\020\001\000\000\099\000\020\001\020\001\020\001\099\000\020\001\ -\020\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\020\001\000\000\099\000\020\001\020\001\099\000\000\000\000\000\ -\000\000\023\001\000\000\020\001\020\001\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\020\001\ -\000\000\000\000\020\001\000\000\000\000\000\000\020\001\020\001\ -\000\000\020\001\000\000\000\000\020\001\020\001\000\000\000\000\ -\000\000\000\000\000\000\020\001\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\020\001\020\001\ -\000\000\020\001\020\001\020\001\020\001\000\000\000\000\000\000\ -\000\000\000\000\020\001\018\001\020\001\000\000\018\001\020\001\ -\000\000\000\000\020\001\018\001\000\000\018\001\020\001\000\000\ -\018\001\018\001\000\000\000\000\018\001\000\000\018\001\018\001\ -\018\001\000\000\000\000\018\001\018\001\018\001\000\000\018\001\ -\018\001\103\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\018\001\000\000\000\000\018\001\018\001\000\000\103\000\000\000\ -\000\000\021\001\000\000\018\001\018\001\000\000\000\000\000\000\ -\000\000\000\000\000\000\103\000\000\000\103\000\103\000\018\001\ -\000\000\000\000\018\001\000\000\000\000\000\000\018\001\018\001\ -\000\000\018\001\103\000\000\000\018\001\018\001\000\000\000\000\ -\000\000\000\000\000\000\018\001\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\103\000\018\001\018\001\ -\000\000\018\001\018\001\018\001\018\001\103\000\019\001\000\000\ -\000\000\019\001\018\001\103\000\018\001\000\000\019\001\018\001\ -\019\001\103\000\018\001\019\001\019\001\000\000\018\001\019\001\ -\000\000\019\001\019\001\019\001\000\000\103\000\019\001\019\001\ -\019\001\103\000\019\001\019\001\010\000\000\000\157\001\000\000\ -\000\000\000\000\000\000\019\001\000\000\103\000\019\001\019\001\ -\103\000\000\000\000\000\000\000\022\001\000\000\019\001\019\001\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\019\001\000\000\000\000\019\001\000\000\000\000\ -\000\000\019\001\019\001\000\000\019\001\000\000\000\000\019\001\ -\019\001\000\000\000\000\000\000\000\000\136\000\019\001\137\000\ -\138\000\030\000\000\000\139\000\000\000\000\000\158\001\141\000\ -\000\000\019\001\019\001\000\000\019\001\019\001\019\001\019\001\ -\000\000\023\001\000\000\000\000\023\001\019\001\000\000\019\001\ -\000\000\023\001\019\001\023\001\000\000\019\001\023\001\023\001\ -\144\000\019\001\023\001\000\000\023\001\023\001\023\001\145\000\ -\000\000\023\001\023\001\023\001\000\000\023\001\023\001\000\000\ -\000\000\000\000\000\000\146\000\147\000\000\000\023\001\000\000\ -\000\000\023\001\023\001\000\000\000\000\000\000\000\000\207\000\ -\000\000\023\001\023\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\023\001\000\000\000\000\ -\023\001\000\000\000\000\000\000\023\001\023\001\000\000\023\001\ -\000\000\000\000\023\001\023\001\000\000\000\000\000\000\000\000\ -\000\000\023\001\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\023\001\023\001\000\000\023\001\ -\023\001\023\001\023\001\000\000\000\000\000\000\000\000\000\000\ -\023\001\021\001\023\001\000\000\021\001\023\001\000\000\000\000\ -\023\001\021\001\000\000\021\001\023\001\000\000\021\001\021\001\ -\000\000\000\000\021\001\000\000\021\001\021\001\021\001\000\000\ -\000\000\021\001\021\001\021\001\000\000\021\001\021\001\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\021\001\000\000\ -\000\000\021\001\021\001\000\000\000\000\000\000\000\000\244\000\ -\000\000\021\001\021\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\021\001\000\000\000\000\ -\021\001\000\000\000\000\000\000\021\001\021\001\000\000\021\001\ -\000\000\000\000\021\001\021\001\000\000\000\000\000\000\000\000\ -\000\000\021\001\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\021\001\021\001\000\000\021\001\ -\021\001\021\001\021\001\000\000\022\001\000\000\000\000\022\001\ -\021\001\000\000\021\001\000\000\022\001\021\001\022\001\000\000\ -\021\001\022\001\022\001\000\000\021\001\022\001\000\000\022\001\ -\022\001\022\001\000\000\000\000\022\001\022\001\022\001\000\000\ -\022\001\022\001\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\022\001\000\000\000\000\022\001\022\001\000\000\000\000\ -\000\000\000\000\000\000\000\000\022\001\022\001\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\061\002\000\000\000\000\ -\022\001\000\000\000\000\022\001\000\000\000\000\000\000\022\001\ -\022\001\000\000\022\001\000\000\000\000\022\001\022\001\000\000\ -\000\000\000\000\000\000\000\000\022\001\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\022\001\ -\022\001\000\000\022\001\022\001\022\001\022\001\000\000\207\000\ -\000\000\000\000\207\000\022\001\000\000\022\001\000\000\207\000\ -\022\001\207\000\000\000\022\001\207\000\207\000\000\000\022\001\ -\207\000\000\000\207\000\207\000\207\000\000\000\000\000\207\000\ -\207\000\207\000\000\000\207\000\207\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\207\000\000\000\000\000\207\000\ -\207\000\000\000\000\000\000\000\000\000\000\000\000\000\207\000\ -\207\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\095\002\000\000\000\000\207\000\000\000\000\000\207\000\000\000\ -\000\000\000\000\207\000\207\000\000\000\207\000\000\000\000\000\ -\207\000\207\000\000\000\000\000\000\000\000\000\000\000\207\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\207\000\207\000\000\000\207\000\000\000\207\000\ -\207\000\000\000\000\000\000\000\000\000\000\000\207\000\244\000\ -\207\000\000\000\244\000\207\000\000\000\000\000\207\000\244\000\ -\000\000\244\000\207\000\000\000\244\000\244\000\000\000\000\000\ -\244\000\000\000\244\000\244\000\244\000\000\000\000\000\244\000\ -\000\000\244\000\000\000\244\000\244\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\244\000\000\000\000\000\244\000\ -\244\000\000\000\000\000\000\000\000\000\000\000\000\000\244\000\ -\244\000\000\000\000\000\059\002\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\244\000\000\000\000\000\244\000\000\000\ -\000\000\000\000\244\000\244\000\000\000\244\000\000\000\000\000\ -\244\000\244\000\000\000\000\000\000\000\000\000\000\000\244\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\244\000\244\000\000\000\244\000\244\000\244\000\ -\244\000\000\000\000\000\000\000\000\000\000\000\244\000\000\000\ -\244\000\000\000\000\000\244\000\000\000\061\002\244\000\061\002\ -\061\002\061\002\244\000\000\000\000\000\061\002\000\000\000\000\ -\000\000\000\000\061\002\000\000\000\000\000\000\061\002\061\002\ -\061\002\000\000\000\000\000\000\000\000\154\003\000\000\061\002\ -\061\002\061\002\061\002\000\000\000\000\000\000\000\000\000\000\ -\000\000\061\002\000\000\000\000\000\000\061\002\061\002\000\000\ -\057\002\000\000\000\000\000\000\000\000\061\002\061\002\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\061\002\000\000\000\000\061\002\000\000\000\000\061\002\ -\061\002\061\002\000\000\061\002\000\000\000\000\061\002\061\002\ -\000\000\000\000\000\000\000\000\136\000\061\002\137\000\138\000\ -\030\000\000\000\139\000\000\000\000\000\140\000\141\000\000\000\ -\061\002\061\002\000\000\061\002\061\002\061\002\000\000\000\000\ -\095\002\061\002\095\002\095\002\095\002\000\000\142\000\000\000\ -\095\002\061\002\000\000\000\000\061\002\095\002\143\000\144\000\ -\061\002\095\002\095\002\095\002\000\000\000\000\145\000\000\000\ -\000\000\000\000\095\002\095\002\095\002\095\002\000\000\000\000\ -\059\005\000\000\146\000\147\000\095\002\000\000\000\000\000\000\ -\000\000\095\002\000\000\058\002\000\000\000\000\000\000\160\005\ -\095\002\095\002\000\000\000\000\000\000\000\000\243\001\000\000\ -\000\000\000\000\000\000\000\000\095\002\000\000\000\000\095\002\ -\000\000\000\000\095\002\095\002\095\002\000\000\095\002\000\000\ -\000\000\095\002\095\002\000\000\000\000\000\000\000\000\061\005\ -\095\002\137\000\138\000\030\000\000\000\139\000\000\000\000\000\ -\140\000\062\005\000\000\095\002\095\002\000\000\095\002\095\002\ -\095\002\095\002\000\000\059\002\000\000\059\002\059\002\059\002\ -\000\000\142\000\000\000\059\002\095\002\000\000\000\000\095\002\ -\059\002\143\000\144\000\095\002\059\002\059\002\059\002\000\000\ -\000\000\145\000\000\000\000\000\000\000\059\002\059\002\059\002\ -\059\002\000\000\246\001\000\000\000\000\064\005\147\000\059\002\ -\000\000\000\000\000\000\000\000\059\002\000\000\056\002\000\000\ -\000\000\000\000\000\000\059\002\059\002\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\059\002\ -\000\000\000\000\059\002\000\000\000\000\059\002\059\002\059\002\ -\000\000\059\002\000\000\000\000\000\000\059\002\000\000\000\000\ -\000\000\000\000\000\000\059\002\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\059\002\059\002\ -\000\000\059\002\059\002\059\002\059\002\000\000\000\000\000\000\ -\057\002\000\000\057\002\057\002\057\002\000\000\000\000\059\002\ -\057\002\000\000\059\002\000\000\000\000\057\002\059\002\000\000\ -\000\000\057\002\057\002\057\002\000\000\000\000\000\000\000\000\ -\000\000\000\000\057\002\057\002\057\002\057\002\000\000\000\000\ -\000\000\000\000\000\000\000\000\057\002\000\000\000\000\000\000\ -\000\000\057\002\000\000\053\002\000\000\000\000\000\000\000\000\ -\057\002\057\002\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\057\002\000\000\000\000\057\002\ -\000\000\000\000\057\002\057\002\057\002\000\000\057\002\000\000\ -\000\000\000\000\057\002\000\000\000\000\000\000\000\000\136\000\ -\057\002\137\000\138\000\030\000\000\000\139\000\000\000\000\000\ -\140\000\141\000\000\000\057\002\057\002\000\000\057\002\057\002\ -\057\002\057\002\177\001\058\002\000\000\058\002\058\002\058\002\ -\000\000\142\000\000\000\058\002\057\002\000\000\000\000\057\002\ -\058\002\143\000\144\000\057\002\058\002\058\002\058\002\042\002\ -\000\000\145\000\000\000\000\000\000\000\058\002\058\002\058\002\ -\058\002\000\000\000\000\000\000\000\000\146\000\147\000\058\002\ -\000\000\000\000\000\000\000\000\058\002\000\000\000\000\000\000\ -\000\000\000\000\000\000\058\002\058\002\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\058\002\ -\000\000\000\000\058\002\000\000\000\000\058\002\058\002\058\002\ -\000\000\058\002\000\000\000\000\000\000\058\002\000\000\000\000\ -\000\000\041\002\136\000\058\002\137\000\138\000\030\000\000\000\ -\139\000\000\000\000\000\140\000\141\000\000\000\058\002\058\002\ -\000\000\058\002\058\002\058\002\058\002\000\000\056\002\000\000\ -\056\002\056\002\056\002\000\000\142\000\000\000\056\002\058\002\ -\000\000\000\000\058\002\056\002\143\000\126\003\058\002\056\002\ -\056\002\056\002\000\000\000\000\145\000\000\000\000\000\000\000\ -\056\002\056\002\056\002\056\002\000\000\000\000\000\000\068\006\ -\146\000\147\000\056\002\039\002\000\000\000\000\000\000\056\002\ -\000\000\000\000\000\000\000\000\000\000\000\000\056\002\056\002\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\056\002\000\000\000\000\056\002\000\000\000\000\ -\056\002\056\002\056\002\000\000\056\002\000\000\000\000\000\000\ -\056\002\000\000\000\000\000\000\000\000\000\000\056\002\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\056\002\056\002\000\000\056\002\056\002\056\002\056\002\ -\000\000\197\000\000\000\053\002\000\000\053\002\053\002\000\000\ -\000\000\000\000\056\002\053\002\000\000\056\002\000\000\000\000\ -\053\002\056\002\000\000\000\000\053\002\053\002\053\002\000\000\ -\000\000\000\000\000\000\000\000\000\000\053\002\053\002\053\002\ -\053\002\000\000\000\000\000\000\000\000\000\000\000\000\053\002\ -\000\000\000\000\000\000\000\000\053\002\000\000\000\000\000\000\ -\000\000\000\000\000\000\053\002\053\002\000\000\000\000\000\000\ -\000\000\000\000\000\000\084\000\000\000\000\000\000\000\053\002\ -\000\000\000\000\053\002\000\000\000\000\053\002\053\002\053\002\ -\000\000\053\002\000\000\000\000\010\000\053\002\157\001\042\002\ -\000\000\000\000\042\002\053\002\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\042\002\000\000\053\002\053\002\ -\042\002\053\002\053\002\053\002\053\002\000\000\000\000\000\000\ -\000\000\042\002\042\002\042\002\042\002\000\000\000\000\053\002\ -\000\000\000\000\053\002\000\000\000\000\000\000\053\002\000\000\ -\042\002\000\000\000\000\000\000\000\000\136\000\000\000\137\000\ -\138\000\030\000\000\000\139\000\000\000\000\000\158\001\141\000\ -\000\000\041\002\000\000\042\002\041\002\000\000\042\002\000\000\ -\000\000\042\002\042\002\042\002\000\000\000\000\041\002\000\000\ -\042\002\042\002\041\002\000\000\000\000\000\000\000\000\042\002\ -\144\000\000\000\227\002\041\002\041\002\041\002\041\002\145\000\ -\000\000\000\000\000\000\042\002\023\003\042\002\000\000\042\002\ -\042\002\000\000\041\002\146\000\147\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\042\002\000\000\000\000\042\002\000\000\ -\000\000\000\000\042\002\039\002\000\000\041\002\039\002\000\000\ -\041\002\000\000\000\000\041\002\041\002\041\002\000\000\000\000\ -\039\002\000\000\041\002\041\002\039\002\000\000\000\000\000\000\ -\000\000\041\002\000\000\000\000\000\000\039\002\039\002\039\002\ -\039\002\000\000\000\000\000\000\000\000\041\002\000\000\041\002\ -\000\000\041\002\041\002\000\000\039\002\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\041\002\000\000\000\000\ -\041\002\000\000\000\000\000\000\041\002\000\000\000\000\039\002\ -\000\000\197\000\039\002\000\000\197\000\039\002\039\002\039\002\ -\000\000\000\000\000\000\000\000\039\002\039\002\197\000\000\000\ -\000\000\000\000\197\000\039\002\197\000\000\000\000\000\000\000\ -\000\000\000\000\128\000\197\000\197\000\197\000\197\000\039\002\ -\000\000\039\002\000\000\039\002\039\002\000\000\000\000\000\000\ -\000\000\000\000\197\000\000\000\000\000\000\000\000\000\039\002\ -\000\000\000\000\039\002\000\000\000\000\000\000\039\002\000\000\ -\000\000\000\000\000\000\084\000\000\000\197\000\084\000\000\000\ -\197\000\000\000\000\000\000\000\197\000\197\000\000\000\000\000\ -\084\000\000\000\197\000\197\000\084\000\000\000\000\000\000\000\ -\000\000\197\000\000\000\000\000\000\000\084\000\084\000\084\000\ -\084\000\000\000\000\000\000\000\000\000\197\000\000\000\197\000\ -\000\000\197\000\197\000\000\000\084\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\197\000\000\000\000\000\ -\197\000\120\000\000\000\000\000\197\000\000\000\000\000\084\000\ -\000\000\000\000\084\000\000\000\000\000\000\000\084\000\084\000\ -\000\000\000\000\000\000\000\000\084\000\084\000\244\004\000\000\ -\137\000\138\000\030\000\084\000\139\000\000\000\245\004\246\004\ -\141\000\000\000\000\000\000\000\000\000\000\000\000\000\084\000\ -\000\000\084\000\000\000\084\000\084\000\247\004\000\000\000\000\ -\248\004\000\000\000\000\000\000\000\000\000\000\000\000\084\000\ -\249\004\144\000\084\000\000\000\023\003\000\000\084\000\023\003\ -\145\000\023\003\023\003\023\003\023\003\000\000\000\000\023\003\ -\023\003\023\003\000\000\000\000\146\000\147\000\000\000\023\003\ -\000\000\000\000\000\000\023\003\000\000\000\000\023\003\000\000\ -\023\003\023\003\023\003\023\003\023\003\023\003\023\003\023\003\ -\023\003\000\000\000\000\023\003\023\003\023\003\000\000\000\000\ -\000\000\000\000\000\000\000\000\023\003\023\003\023\003\023\003\ -\023\003\023\003\023\003\023\003\023\003\023\003\023\003\023\003\ -\023\003\023\003\150\001\023\003\023\003\023\003\000\000\023\003\ -\023\003\023\003\023\003\023\003\023\003\000\000\023\003\023\003\ -\023\003\023\003\023\003\000\000\023\003\023\003\000\000\000\000\ -\023\003\023\003\000\000\023\003\023\003\023\003\023\003\023\003\ -\023\003\023\003\000\000\023\003\023\003\023\003\000\000\023\003\ -\000\000\023\003\023\003\000\000\023\003\000\000\023\003\023\003\ -\023\003\023\003\023\003\023\003\023\003\000\000\023\003\009\000\ -\010\000\011\000\000\000\000\000\000\000\012\000\013\000\014\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\015\000\016\000\ -\017\000\018\000\019\000\020\000\021\000\000\000\000\000\000\000\ -\000\000\022\000\000\000\023\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\024\000\000\000\025\000\026\000\ -\027\000\028\000\029\000\000\000\000\000\030\000\031\000\000\000\ -\000\000\032\000\033\000\034\000\000\000\164\002\035\000\036\000\ -\000\000\037\000\038\000\000\000\039\000\000\000\040\000\000\000\ -\041\000\000\000\042\000\000\000\000\000\000\000\043\000\044\000\ -\000\000\045\000\000\000\000\000\000\000\000\000\009\000\010\000\ -\011\000\000\000\129\000\121\000\012\000\013\000\014\000\047\000\ -\000\000\000\000\000\000\000\000\048\000\049\000\050\000\051\000\ -\052\000\053\000\000\000\000\000\054\000\015\000\016\000\017\000\ -\018\000\019\000\020\000\021\000\000\000\000\000\000\000\000\000\ -\022\000\000\000\023\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\024\000\000\000\025\000\026\000\027\000\ -\028\000\029\000\000\000\000\000\030\000\031\000\000\000\000\000\ -\032\000\033\000\034\000\000\000\000\000\035\000\036\000\000\000\ -\037\000\038\000\000\000\039\000\000\000\040\000\000\000\041\000\ -\000\000\042\000\000\000\109\000\000\000\043\000\044\000\000\000\ -\045\000\178\001\136\000\000\000\137\000\138\000\030\000\000\000\ -\139\000\000\000\121\000\140\000\141\000\000\000\047\000\000\000\ -\000\000\000\000\000\000\048\000\049\000\050\000\051\000\052\000\ -\053\000\000\000\000\000\054\000\142\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\143\000\144\000\000\000\009\000\ -\010\000\011\000\000\000\000\000\145\000\012\000\013\000\014\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\146\000\147\000\000\000\000\000\000\000\000\000\015\000\016\000\ -\017\000\018\000\019\000\020\000\021\000\000\000\000\000\000\000\ -\000\000\022\000\000\000\023\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\024\000\000\000\025\000\026\000\ -\027\000\028\000\029\000\000\000\000\000\030\000\031\000\000\000\ -\000\000\032\000\033\000\034\000\000\000\000\000\035\000\036\000\ -\000\000\037\000\038\000\000\000\039\000\132\000\040\000\000\000\ -\041\000\000\000\042\000\000\000\000\000\000\000\043\000\044\000\ -\000\000\045\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\121\000\000\000\000\000\000\000\047\000\ -\000\000\000\000\000\000\000\000\048\000\049\000\050\000\051\000\ -\052\000\053\000\000\000\000\000\054\000\164\002\000\000\000\000\ -\000\000\164\002\000\000\164\002\000\000\164\002\000\000\164\002\ -\000\000\164\002\000\000\164\002\164\002\000\000\164\002\164\002\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\164\002\164\002\000\000\164\002\164\002\134\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\164\002\ -\164\002\164\002\164\002\000\000\164\002\164\002\000\000\000\000\ -\164\002\000\000\000\000\000\000\000\000\164\002\164\002\164\002\ -\000\000\000\000\000\000\000\000\164\002\000\000\164\002\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\164\002\000\000\ -\000\000\164\002\000\000\000\000\000\000\000\000\164\002\135\000\ -\164\002\164\002\000\000\164\002\164\002\000\000\164\002\000\000\ -\000\000\000\000\164\002\109\000\000\000\164\002\000\000\164\002\ -\000\000\178\001\164\002\164\002\000\000\178\001\164\002\178\001\ -\109\000\178\001\000\000\178\001\000\000\178\001\000\000\178\001\ -\178\001\000\000\178\001\178\001\000\000\109\000\000\000\109\000\ -\109\000\000\000\000\000\000\000\178\001\000\000\000\000\178\001\ -\178\001\000\000\000\000\000\000\109\000\000\000\000\000\000\000\ -\000\000\130\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\178\001\178\001\000\000\178\001\109\000\ -\178\001\178\001\000\000\000\000\178\001\000\000\109\000\109\000\ -\000\000\178\001\178\001\178\001\000\000\109\000\000\000\000\000\ -\178\001\000\000\178\001\109\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\178\001\000\000\000\000\178\001\000\000\109\000\ -\000\000\000\000\178\001\109\000\178\001\178\001\000\000\178\001\ -\178\001\000\000\178\001\136\000\000\000\000\000\178\001\109\000\ -\000\000\178\001\109\000\178\001\000\000\132\000\178\001\178\001\ -\132\000\132\000\178\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\132\000\132\000\000\000\000\000\000\000\000\000\ -\132\000\000\000\000\000\000\000\000\000\000\000\000\000\132\000\ -\000\000\132\000\132\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\132\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\132\000\132\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\132\000\000\000\000\000\132\000\000\000\000\000\132\000\ -\132\000\132\000\000\000\132\000\000\000\134\000\000\000\132\000\ -\134\000\134\000\014\002\000\000\000\000\132\000\000\000\000\000\ -\000\000\000\000\134\000\134\000\000\000\000\000\000\000\000\000\ -\134\000\132\000\000\000\132\000\000\000\132\000\132\000\134\000\ -\000\000\134\000\134\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\132\000\000\000\000\000\132\000\000\000\134\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\134\000\134\000\000\000\ -\000\000\000\000\000\000\181\000\000\000\000\000\000\000\135\000\ -\000\000\134\000\135\000\135\000\134\000\000\000\000\000\134\000\ -\134\000\134\000\000\000\134\000\135\000\135\000\000\000\134\000\ -\000\000\000\000\135\000\000\000\000\000\134\000\000\000\000\000\ -\000\000\135\000\000\000\135\000\135\000\000\000\000\000\000\000\ -\000\000\134\000\000\000\134\000\000\000\134\000\134\000\000\000\ -\135\000\000\000\000\000\000\000\000\000\183\002\000\000\135\000\ -\135\000\134\000\000\000\000\000\134\000\000\000\000\000\000\000\ -\000\000\130\000\000\000\135\000\130\000\130\000\135\000\000\000\ -\000\000\000\000\135\000\135\000\000\000\135\000\130\000\130\000\ -\000\000\135\000\000\000\000\000\130\000\000\000\000\000\135\000\ -\000\000\000\000\000\000\130\000\000\000\130\000\130\000\000\000\ -\000\000\000\000\000\000\135\000\000\000\135\000\000\000\135\000\ -\135\000\000\000\130\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\130\000\130\000\135\000\000\000\000\000\135\000\000\000\ -\000\000\000\000\000\000\136\000\000\000\130\000\136\000\136\000\ -\130\000\015\002\000\000\000\000\130\000\130\000\000\000\130\000\ -\136\000\136\000\000\000\130\000\000\000\000\000\136\000\000\000\ -\000\000\130\000\000\000\000\000\000\000\136\000\000\000\136\000\ -\136\000\000\000\000\000\000\000\000\000\130\000\000\000\130\000\ -\000\000\130\000\130\000\000\000\136\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\136\000\136\000\130\000\000\000\000\000\ -\130\000\000\000\000\000\000\000\000\000\000\000\000\000\136\000\ -\000\000\000\000\136\000\182\000\000\000\000\000\136\000\136\000\ -\000\000\136\000\000\000\000\000\000\000\136\000\136\000\000\000\ -\137\000\138\000\030\000\136\000\139\000\000\000\000\000\140\000\ -\141\000\000\000\014\002\000\000\000\000\014\002\000\000\136\000\ -\000\000\136\000\014\002\136\000\136\000\000\000\000\000\014\002\ -\142\000\000\000\000\000\000\000\000\000\014\002\000\000\136\000\ -\143\000\126\003\136\000\000\000\014\002\000\000\014\002\014\002\ -\145\000\000\000\000\000\000\000\000\000\021\003\000\000\000\000\ -\000\000\000\000\014\002\014\002\146\000\147\000\000\000\000\000\ -\000\000\000\000\000\000\181\000\000\000\000\000\181\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\014\002\000\000\ -\181\000\014\002\000\000\000\000\014\002\014\002\014\002\000\000\ -\000\000\000\000\000\000\098\002\014\002\181\000\181\000\181\000\ -\181\000\000\000\014\002\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\181\000\000\000\014\002\023\003\ -\000\000\000\000\014\002\014\002\000\000\183\002\098\002\000\000\ -\183\002\000\000\000\000\000\000\000\000\000\000\014\002\181\000\ -\000\000\014\002\183\002\080\002\000\000\181\000\181\000\181\000\ -\000\000\000\000\000\000\000\000\080\002\181\000\000\000\183\002\ -\183\002\183\002\183\002\181\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\183\002\181\000\ -\000\000\181\000\000\000\181\000\080\002\000\000\000\000\080\002\ -\000\000\232\001\000\000\000\000\000\000\000\000\000\000\181\000\ -\080\002\183\002\181\000\000\000\000\000\174\002\000\000\183\002\ -\183\002\183\002\000\000\000\000\000\000\000\000\174\002\183\002\ -\000\000\015\002\000\000\000\000\015\002\183\002\000\000\000\000\ -\000\000\015\002\000\000\000\000\000\000\000\000\015\002\000\000\ -\000\000\183\002\000\000\183\002\015\002\183\002\174\002\000\000\ -\000\000\174\002\071\000\015\002\000\000\015\002\015\002\000\000\ -\000\000\183\002\174\002\000\000\183\002\000\000\000\000\000\000\ -\000\000\015\002\015\002\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\182\000\000\000\015\002\182\000\000\000\ -\015\002\000\000\000\000\015\002\015\002\015\002\000\000\000\000\ -\182\000\000\000\015\002\015\002\000\000\000\000\182\000\233\001\ -\000\000\015\002\000\000\000\000\000\000\182\000\182\000\182\000\ -\182\000\000\000\000\000\000\000\000\000\015\002\000\000\000\000\ -\000\000\015\002\015\002\000\000\182\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\182\000\000\000\015\002\000\000\000\000\ -\015\002\000\000\000\000\000\000\000\000\021\003\000\000\182\000\ -\021\003\000\000\182\000\000\000\000\000\000\000\182\000\182\000\ -\000\000\182\000\021\003\000\000\235\001\182\000\000\000\000\000\ -\021\003\000\000\000\000\182\000\000\000\000\000\000\000\021\003\ -\000\000\021\003\021\003\000\000\000\000\000\000\000\000\182\000\ -\000\000\182\000\000\000\182\000\182\000\021\003\021\003\000\000\ -\000\000\000\000\000\000\000\000\000\000\021\003\021\003\182\000\ -\000\000\000\000\182\000\000\000\000\000\000\000\000\000\023\003\ -\000\000\021\003\023\003\000\000\021\003\000\000\000\000\023\003\ -\000\000\021\003\000\000\021\003\023\003\000\000\000\000\021\003\ -\000\000\000\000\023\003\000\000\000\000\021\003\000\000\000\000\ -\000\000\023\003\000\000\023\003\023\003\000\000\000\000\234\001\ -\000\000\021\003\000\000\000\000\000\000\021\003\021\003\000\000\ -\023\003\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\021\003\000\000\000\000\021\003\000\000\000\000\000\000\ -\000\000\232\001\000\000\023\003\232\001\000\000\023\003\000\000\ -\000\000\000\000\023\003\023\003\000\000\000\000\232\001\000\000\ -\000\000\023\003\000\000\000\000\232\001\000\000\000\000\023\003\ -\000\000\000\000\000\000\232\001\236\001\232\001\232\001\000\000\ -\000\000\000\000\000\000\023\003\000\000\011\002\000\000\023\003\ -\023\003\000\000\232\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\071\000\023\003\000\000\071\000\023\003\000\000\ -\000\000\000\000\000\000\000\000\000\000\232\001\000\000\071\000\ -\232\001\000\000\000\000\000\000\232\001\232\001\000\000\000\000\ -\000\000\000\000\000\000\232\001\071\000\000\000\071\000\071\000\ -\000\000\232\001\000\000\000\000\000\000\000\000\000\000\240\001\ -\000\000\000\000\071\000\071\000\000\000\232\001\000\000\000\000\ -\000\000\232\001\232\001\000\000\000\000\000\000\000\000\233\001\ -\000\000\000\000\233\001\000\000\000\000\232\001\071\000\000\000\ -\232\001\071\000\000\000\000\000\233\001\071\000\071\000\000\000\ -\000\000\000\000\233\001\000\000\071\000\000\000\000\000\000\000\ -\000\000\233\001\071\000\233\001\233\001\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\011\002\000\000\071\000\000\000\ -\233\001\000\000\071\000\071\000\000\000\021\003\000\000\000\000\ -\000\000\000\000\000\000\000\000\235\001\000\000\071\000\235\001\ -\000\000\071\000\000\000\233\001\000\000\000\000\233\001\000\000\ -\000\000\235\001\233\001\233\001\000\000\000\000\000\000\235\001\ -\000\000\233\001\000\000\000\000\000\000\000\000\235\001\233\001\ -\235\001\235\001\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\233\001\000\000\235\001\000\000\233\001\ -\233\001\000\000\125\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\233\001\000\000\000\000\233\001\000\000\ -\235\001\000\000\000\000\235\001\000\000\000\000\000\000\235\001\ -\235\001\000\000\000\000\000\000\000\000\000\000\235\001\234\001\ -\000\000\000\000\234\001\000\000\235\001\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\234\001\000\000\000\000\000\000\ -\235\001\000\000\234\001\000\000\235\001\235\001\000\000\126\000\ -\000\000\234\001\000\000\234\001\234\001\000\000\000\000\000\000\ -\235\001\000\000\000\000\235\001\000\000\000\000\000\000\000\000\ -\234\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\236\001\000\000\000\000\236\001\ -\000\000\000\000\000\000\234\001\000\000\011\002\234\001\000\000\ -\000\000\236\001\234\001\234\001\000\000\011\002\000\000\236\001\ -\023\003\234\001\011\002\000\000\000\000\000\000\236\001\234\001\ -\236\001\236\001\023\003\000\000\000\000\000\000\000\000\011\002\ -\000\000\011\002\011\002\234\001\000\000\236\001\000\000\234\001\ -\234\001\000\000\000\000\000\000\000\000\000\000\011\002\000\000\ -\000\000\000\000\000\000\234\001\000\000\000\000\234\001\240\001\ -\236\001\000\000\240\001\236\001\000\000\000\000\000\000\236\001\ -\236\001\011\002\000\000\000\000\240\001\000\000\236\001\011\002\ -\011\002\011\002\240\001\000\000\236\001\000\000\000\000\011\002\ -\000\000\240\001\000\000\240\001\240\001\011\002\000\000\000\000\ -\236\001\000\000\000\000\118\000\236\001\236\001\000\000\000\000\ -\240\001\011\002\000\000\000\000\000\000\011\002\000\000\000\000\ -\236\001\000\000\000\000\236\001\011\002\000\000\000\000\000\000\ -\000\000\011\002\000\000\240\001\011\002\021\003\240\001\000\000\ -\021\003\011\002\240\001\240\001\000\000\000\000\000\000\000\000\ -\000\000\240\001\021\003\000\000\000\000\000\000\011\002\240\001\ -\011\002\011\002\000\000\000\000\021\003\000\000\000\000\021\003\ -\000\000\021\003\021\003\240\001\000\000\011\002\119\000\240\001\ -\240\001\000\000\000\000\000\000\000\000\021\003\021\003\000\000\ -\000\000\000\000\000\000\240\001\000\000\000\000\240\001\000\000\ -\011\002\000\000\125\000\011\002\000\000\125\000\011\002\011\002\ -\011\002\021\003\000\000\000\000\021\003\000\000\011\002\125\000\ -\000\000\021\003\000\000\000\000\011\002\000\000\000\000\021\003\ -\000\000\000\000\000\000\000\000\125\000\021\003\125\000\125\000\ -\011\002\000\000\000\000\000\000\011\002\011\002\000\000\000\000\ -\000\000\021\003\000\000\125\000\223\001\021\003\021\003\000\000\ -\011\002\000\000\000\000\011\002\000\000\000\000\000\000\126\000\ -\000\000\021\003\126\000\000\000\021\003\000\000\125\000\000\000\ -\000\000\125\000\000\000\000\000\126\000\125\000\125\000\000\000\ -\000\000\000\000\000\000\000\000\125\000\000\000\000\000\000\000\ -\000\000\126\000\125\000\126\000\126\000\000\000\000\000\000\000\ -\061\000\000\000\000\000\000\000\000\000\000\000\125\000\000\000\ -\126\000\064\000\125\000\125\000\000\000\000\000\000\000\000\000\ -\023\003\000\000\000\000\000\000\000\000\000\000\125\000\000\000\ -\023\003\125\000\023\003\126\000\000\000\023\003\126\000\000\000\ -\000\000\000\000\126\000\126\000\000\000\000\000\000\000\023\003\ -\000\000\126\000\023\003\000\000\023\003\023\003\000\000\126\000\ -\000\000\000\000\000\000\000\000\023\003\000\000\023\003\023\003\ -\000\000\023\003\065\000\126\000\000\000\000\000\000\000\126\000\ -\126\000\000\000\000\000\023\003\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\126\000\023\003\000\000\126\000\023\003\ -\000\000\000\000\000\000\023\003\023\003\000\000\023\003\000\000\ -\000\000\023\003\023\003\118\000\000\000\023\003\023\003\000\000\ -\023\003\000\000\000\000\000\000\023\003\000\000\021\003\000\000\ -\118\000\000\000\023\003\000\000\023\003\000\000\000\000\000\000\ -\023\003\023\003\000\000\000\000\000\000\118\000\023\003\118\000\ -\118\000\000\000\023\003\023\003\023\003\000\000\000\000\023\003\ -\000\000\000\000\000\000\000\000\118\000\000\000\023\003\000\000\ -\000\000\023\003\000\000\000\000\021\003\000\000\000\000\021\003\ -\000\000\000\000\000\000\000\000\000\000\000\000\119\000\118\000\ -\000\000\021\003\118\000\000\000\000\000\000\000\118\000\118\000\ -\000\000\000\000\000\000\119\000\000\000\118\000\021\003\000\000\ -\021\003\021\003\000\000\118\000\000\000\000\000\000\000\000\000\ -\119\000\000\000\119\000\119\000\000\000\021\003\000\000\118\000\ -\000\000\000\000\000\000\118\000\118\000\000\000\000\000\119\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\118\000\ -\021\003\000\000\118\000\021\003\000\000\000\000\000\000\000\000\ -\021\003\000\000\119\000\000\000\223\001\119\000\021\003\000\000\ -\000\000\119\000\119\000\000\000\021\003\000\000\000\000\000\000\ -\119\000\223\001\000\000\000\000\000\000\000\000\119\000\000\000\ -\021\003\000\000\000\000\000\000\021\003\021\003\223\001\000\000\ -\223\001\223\001\119\000\000\000\000\000\000\000\119\000\119\000\ -\021\003\000\000\000\000\021\003\000\000\223\001\000\000\000\000\ -\061\000\000\000\119\000\000\000\000\000\119\000\000\000\000\000\ -\000\000\064\000\000\000\000\000\000\000\061\000\000\000\000\000\ -\223\001\000\000\000\000\223\001\000\000\000\000\064\000\223\001\ -\223\001\000\000\061\000\000\000\061\000\061\000\223\001\000\000\ -\000\000\000\000\000\000\064\000\223\001\064\000\064\000\000\000\ -\000\000\061\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\223\001\000\000\064\000\000\000\223\001\223\001\000\000\000\000\ -\000\000\000\000\065\000\000\000\061\000\000\000\000\000\061\000\ -\223\001\000\000\000\000\223\001\061\000\064\000\000\000\065\000\ -\064\000\000\000\061\000\000\000\000\000\064\000\000\000\000\000\ -\061\000\000\000\000\000\064\000\065\000\000\000\065\000\065\000\ -\000\000\064\000\000\000\000\000\061\000\000\000\000\000\000\000\ -\061\000\061\000\000\000\065\000\000\000\064\000\021\003\000\000\ -\000\000\064\000\064\000\000\000\061\000\000\000\000\000\061\000\ -\000\000\000\000\000\000\021\003\000\000\064\000\065\000\000\000\ -\064\000\065\000\000\000\000\000\000\000\000\000\065\000\000\000\ -\021\003\000\000\021\003\021\003\065\000\000\000\000\000\000\000\ -\000\000\000\000\065\000\000\000\000\000\000\000\000\000\021\003\ -\000\000\000\000\000\000\000\000\000\000\000\000\065\000\000\000\ -\000\000\000\000\065\000\065\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\021\003\000\000\000\000\021\003\065\000\000\000\ -\000\000\065\000\021\003\000\000\000\000\000\000\000\000\000\000\ -\021\003\000\000\000\000\000\000\000\000\000\000\021\003\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\021\003\016\003\000\000\000\000\021\003\021\003\ -\016\003\016\003\016\003\016\003\000\000\000\000\016\003\016\003\ -\016\003\016\003\021\003\000\000\000\000\021\003\016\003\000\000\ -\000\000\000\000\000\000\000\000\000\000\016\003\000\000\016\003\ -\016\003\016\003\016\003\016\003\016\003\016\003\016\003\000\000\ -\000\000\000\000\016\003\000\000\016\003\000\000\000\000\000\000\ -\000\000\000\000\000\000\016\003\016\003\016\003\016\003\016\003\ -\016\003\016\003\016\003\016\003\000\000\000\000\016\003\016\003\ -\000\000\000\000\016\003\016\003\016\003\016\003\000\000\016\003\ -\016\003\016\003\016\003\016\003\000\000\016\003\000\000\016\003\ -\016\003\016\003\000\000\016\003\016\003\000\000\000\000\016\003\ -\016\003\000\000\016\003\000\000\016\003\016\003\000\000\016\003\ -\016\003\000\000\000\000\016\003\016\003\000\000\016\003\000\000\ -\016\003\016\003\000\000\016\003\000\000\016\003\016\003\016\003\ -\016\003\016\003\016\003\016\003\023\003\016\003\000\000\000\000\ -\000\000\023\003\023\003\023\003\023\003\000\000\000\000\023\003\ -\023\003\000\000\000\000\000\000\000\000\000\000\000\000\023\003\ -\000\000\000\000\000\000\000\000\000\000\000\000\023\003\000\000\ -\023\003\000\000\023\003\023\003\023\003\023\003\023\003\023\003\ -\000\000\000\000\000\000\023\003\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\023\003\023\003\023\003\023\003\ -\023\003\023\003\023\003\023\003\023\003\000\000\000\000\023\003\ -\023\003\000\000\000\000\023\003\023\003\023\003\000\000\000\000\ -\023\003\023\003\023\003\023\003\023\003\000\000\023\003\000\000\ -\023\003\023\003\023\003\000\000\000\000\023\003\000\000\000\000\ -\023\003\023\003\000\000\023\003\000\000\023\003\023\003\000\000\ -\000\000\023\003\000\000\000\000\000\000\023\003\000\000\023\003\ -\000\000\023\003\023\003\000\000\023\003\000\000\023\003\023\003\ -\000\000\023\003\023\003\023\003\023\003\000\000\023\003\026\001\ -\027\001\028\001\000\000\000\000\009\000\010\000\029\001\000\000\ -\030\001\000\000\012\000\013\000\000\000\000\000\031\001\032\001\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\033\001\000\000\000\000\017\000\018\000\019\000\ -\020\000\021\000\000\000\034\001\000\000\000\000\022\000\000\000\ -\000\000\035\001\036\001\037\001\038\001\039\001\040\001\000\000\ -\000\000\024\000\000\000\025\000\026\000\027\000\028\000\029\000\ -\000\000\000\000\030\000\000\000\041\001\000\000\032\000\033\000\ -\034\000\000\000\000\000\000\000\036\000\000\000\042\001\043\001\ -\000\000\044\001\000\000\040\000\000\000\041\000\000\000\000\000\ -\000\000\045\001\046\001\047\001\048\001\049\001\050\001\000\000\ -\000\000\000\000\000\000\000\000\000\000\051\001\000\000\000\000\ -\000\000\052\001\000\000\053\001\047\000\000\000\000\000\000\000\ -\000\000\048\000\049\000\000\000\051\000\052\000\026\001\027\001\ -\028\001\054\000\000\000\009\000\010\000\029\001\000\000\030\001\ -\000\000\012\000\013\000\000\000\000\000\079\003\032\001\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\033\001\000\000\000\000\017\000\018\000\019\000\020\000\ -\021\000\000\000\034\001\000\000\000\000\022\000\000\000\000\000\ -\035\001\036\001\037\001\038\001\039\001\040\001\000\000\000\000\ -\024\000\000\000\025\000\026\000\027\000\028\000\029\000\000\000\ -\000\000\030\000\000\000\041\001\000\000\032\000\033\000\034\000\ -\000\000\000\000\000\000\036\000\000\000\042\001\043\001\000\000\ -\080\003\000\000\040\000\000\000\041\000\000\000\000\000\000\000\ -\045\001\046\001\047\001\048\001\049\001\050\001\000\000\000\000\ -\000\000\000\000\000\000\089\002\081\003\089\002\089\002\089\002\ -\052\001\089\002\053\001\047\000\089\002\089\002\000\000\000\000\ -\048\000\049\000\000\000\051\000\052\000\023\003\000\000\000\000\ -\054\000\000\000\023\003\023\003\023\003\089\002\000\000\000\000\ -\023\003\023\003\023\003\000\000\000\000\089\002\089\002\000\000\ -\000\000\000\000\000\000\000\000\000\000\089\002\000\000\023\003\ -\000\000\023\003\023\003\023\003\023\003\023\003\023\003\023\003\ -\000\000\089\002\089\002\000\000\023\003\000\000\023\003\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\023\003\ -\000\000\023\003\023\003\023\003\023\003\023\003\000\000\000\000\ -\023\003\023\003\000\000\000\000\023\003\023\003\023\003\000\000\ -\000\000\023\003\023\003\000\000\023\003\023\003\000\000\023\003\ -\000\000\023\003\000\000\023\003\000\000\023\003\000\000\000\000\ -\000\000\023\003\023\003\143\002\023\003\000\000\000\000\000\000\ -\217\002\217\002\217\002\000\000\000\000\023\003\217\002\217\002\ -\000\000\000\000\023\003\000\000\000\000\000\000\000\000\023\003\ -\023\003\023\003\023\003\023\003\023\003\000\000\000\000\023\003\ -\000\000\217\002\217\002\217\002\217\002\217\002\000\000\000\000\ -\000\000\000\000\217\002\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\217\002\000\000\217\002\ -\217\002\217\002\217\002\217\002\000\000\000\000\217\002\000\000\ -\000\000\000\000\217\002\217\002\217\002\000\000\000\000\000\000\ -\217\002\000\000\217\002\217\002\000\000\000\000\000\000\217\002\ -\000\000\217\002\000\000\000\000\000\000\000\000\000\000\217\002\ -\217\002\144\002\217\002\000\000\000\000\000\000\218\002\218\002\ -\218\002\143\002\000\000\000\000\218\002\218\002\000\000\000\000\ -\217\002\000\000\000\000\000\000\000\000\217\002\217\002\000\000\ -\217\002\217\002\000\000\000\000\000\000\217\002\000\000\218\002\ -\218\002\218\002\218\002\218\002\000\000\000\000\000\000\000\000\ -\218\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\218\002\000\000\218\002\218\002\218\002\ -\218\002\218\002\000\000\000\000\218\002\000\000\000\000\000\000\ -\218\002\218\002\218\002\000\000\000\000\000\000\218\002\000\000\ -\218\002\218\002\000\000\000\000\000\000\218\002\000\000\218\002\ -\000\000\000\000\000\000\000\000\000\000\218\002\218\002\141\002\ -\218\002\000\000\000\000\000\000\219\002\219\002\219\002\144\002\ -\000\000\000\000\219\002\219\002\000\000\000\000\218\002\000\000\ -\000\000\000\000\000\000\218\002\218\002\000\000\218\002\218\002\ -\000\000\000\000\000\000\218\002\000\000\219\002\219\002\219\002\ -\219\002\219\002\000\000\000\000\000\000\000\000\219\002\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\219\002\000\000\219\002\219\002\219\002\219\002\219\002\ -\000\000\000\000\219\002\000\000\000\000\000\000\219\002\219\002\ -\219\002\000\000\000\000\000\000\219\002\000\000\219\002\219\002\ -\000\000\000\000\000\000\219\002\000\000\219\002\000\000\000\000\ -\000\000\000\000\000\000\219\002\219\002\142\002\219\002\000\000\ -\000\000\000\000\220\002\220\002\220\002\141\002\000\000\000\000\ -\220\002\220\002\000\000\000\000\219\002\000\000\000\000\000\000\ -\000\000\219\002\219\002\000\000\219\002\219\002\000\000\000\000\ -\000\000\219\002\000\000\220\002\220\002\220\002\220\002\220\002\ -\000\000\000\000\000\000\000\000\220\002\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\220\002\ -\000\000\220\002\220\002\220\002\220\002\220\002\000\000\000\000\ -\220\002\000\000\000\000\000\000\220\002\220\002\220\002\000\000\ -\000\000\000\000\220\002\000\000\220\002\220\002\000\000\000\000\ -\000\000\220\002\000\000\220\002\000\000\000\000\000\000\000\000\ -\000\000\220\002\220\002\000\000\220\002\000\000\000\000\000\000\ -\000\000\000\000\000\000\142\002\224\000\225\000\226\000\000\000\ -\000\000\000\000\220\002\000\000\227\000\000\000\228\000\220\002\ -\220\002\000\000\220\002\220\002\229\000\230\000\231\000\220\002\ -\000\000\232\000\233\000\234\000\000\000\235\000\236\000\237\000\ -\000\000\238\000\239\000\240\000\241\000\000\000\000\000\000\000\ -\242\000\243\000\244\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\245\000\246\000\000\000\000\000\247\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\248\000\249\000\000\000\000\000\000\000\062\002\250\000\251\000\ -\000\000\062\002\000\000\252\000\253\000\254\000\255\000\000\001\ -\001\001\002\001\000\000\003\001\000\000\000\000\062\002\000\000\ -\062\002\004\001\000\000\045\002\000\000\000\000\005\001\062\002\ -\062\002\000\000\000\000\000\000\006\001\000\000\000\000\007\001\ -\008\001\062\002\009\001\010\001\011\001\012\001\013\001\000\000\ -\014\001\015\001\016\001\017\001\018\001\062\002\062\002\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\062\002\000\000\000\000\000\000\062\002\000\000\062\002\ -\062\002\062\002\000\000\062\002\000\000\000\000\062\002\000\000\ -\000\000\000\000\026\001\027\001\028\001\000\000\000\000\000\000\ -\010\000\207\001\000\000\030\001\000\000\000\000\013\000\045\002\ -\062\002\031\001\032\001\000\000\062\002\000\000\062\002\000\000\ -\000\000\062\002\000\000\000\000\000\000\033\001\161\000\000\000\ -\017\000\018\000\062\002\000\000\062\002\000\000\034\001\000\000\ -\000\000\000\000\000\000\000\000\035\001\036\001\037\001\038\001\ -\039\001\040\001\000\000\000\000\024\000\000\000\162\000\163\000\ -\000\000\164\000\165\000\000\000\000\000\030\000\000\000\041\001\ -\000\000\000\000\166\000\167\000\000\000\000\000\000\000\000\000\ -\000\000\208\001\209\001\000\000\210\001\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\045\001\046\001\211\001\212\001\ -\049\001\213\001\000\000\000\000\000\000\000\000\000\000\000\000\ -\051\001\000\000\000\000\170\000\052\001\000\000\053\001\047\000\ -\000\000\000\000\000\000\000\000\048\000\000\000\240\002\051\000\ -\171\000\026\001\027\001\028\001\000\000\000\000\000\000\010\000\ -\207\001\000\000\030\001\000\000\000\000\013\000\000\000\000\000\ -\031\001\032\001\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\033\001\161\000\000\000\017\000\ -\018\000\000\000\000\000\000\000\000\000\034\001\000\000\000\000\ -\000\000\000\000\000\000\035\001\036\001\037\001\038\001\039\001\ -\040\001\000\000\000\000\024\000\000\000\162\000\163\000\000\000\ -\164\000\165\000\000\000\000\000\030\000\000\000\041\001\000\000\ -\000\000\166\000\167\000\000\000\000\000\000\000\000\000\000\000\ -\208\001\209\001\000\000\210\001\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\045\001\046\001\211\001\212\001\049\001\ -\213\001\000\000\000\000\000\000\000\000\000\000\000\000\051\001\ -\000\000\000\000\170\000\052\001\000\000\053\001\047\000\000\000\ -\000\000\000\000\000\000\048\000\000\000\194\003\051\000\171\000\ -\026\001\027\001\028\001\000\000\000\000\000\000\010\000\207\001\ -\000\000\030\001\000\000\000\000\013\000\000\000\000\000\031\001\ -\032\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\033\001\161\000\000\000\017\000\018\000\ -\000\000\000\000\000\000\000\000\034\001\000\000\000\000\000\000\ -\000\000\000\000\035\001\036\001\037\001\038\001\039\001\040\001\ -\000\000\000\000\024\000\000\000\162\000\163\000\000\000\164\000\ -\165\000\000\000\000\000\030\000\000\000\041\001\000\000\000\000\ -\166\000\167\000\000\000\000\000\000\000\000\000\000\000\208\001\ -\209\001\000\000\210\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\045\001\046\001\211\001\212\001\049\001\213\001\ -\000\000\000\000\000\000\000\000\000\000\000\000\051\001\000\000\ -\000\000\170\000\052\001\000\000\053\001\047\000\000\000\000\000\ -\000\000\000\000\048\000\000\000\154\004\051\000\171\000\026\001\ -\027\001\028\001\000\000\000\000\000\000\010\000\207\001\000\000\ -\030\001\000\000\000\000\013\000\000\000\000\000\031\001\032\001\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\033\001\161\000\000\000\017\000\018\000\000\000\ -\000\000\000\000\000\000\034\001\000\000\000\000\000\000\000\000\ -\000\000\035\001\036\001\037\001\038\001\039\001\040\001\000\000\ -\000\000\024\000\000\000\162\000\163\000\000\000\164\000\165\000\ -\000\000\000\000\030\000\000\000\041\001\000\000\000\000\166\000\ -\167\000\000\000\000\000\000\000\000\000\000\000\208\001\209\001\ -\000\000\210\001\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\045\001\046\001\211\001\212\001\049\001\213\001\000\000\ -\000\000\157\003\000\000\000\000\000\000\051\001\000\000\010\000\ -\170\000\052\001\000\000\053\001\047\000\013\000\000\000\000\000\ -\079\003\048\000\000\000\000\000\051\000\171\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\161\000\000\000\017\000\ -\018\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\024\000\000\000\162\000\163\000\000\000\ -\164\000\165\000\000\000\000\000\030\000\000\000\200\002\000\000\ -\000\000\166\000\167\000\000\000\010\000\000\000\000\000\000\000\ -\168\000\000\000\013\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\169\000\000\000\000\000\ -\000\000\000\000\161\000\000\000\017\000\018\000\000\000\158\003\ -\000\000\000\000\170\000\000\000\000\000\000\000\047\000\000\000\ -\000\000\000\000\000\000\048\000\000\000\000\000\051\000\171\000\ -\024\000\000\000\162\000\163\000\000\000\164\000\165\000\000\000\ -\000\000\030\000\000\000\202\002\000\000\000\000\166\000\167\000\ -\000\000\010\000\000\000\000\000\000\000\168\000\000\000\013\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\169\000\000\000\000\000\000\000\000\000\161\000\ -\000\000\017\000\018\000\000\000\000\000\000\000\000\000\170\000\ -\000\000\000\000\000\000\047\000\000\000\000\000\000\000\000\000\ -\048\000\000\000\000\000\051\000\171\000\024\000\000\000\162\000\ -\163\000\000\000\164\000\165\000\000\000\000\000\030\000\000\000\ -\204\002\000\000\000\000\166\000\167\000\000\000\010\000\000\000\ -\000\000\000\000\168\000\000\000\013\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\169\000\ -\000\000\000\000\000\000\000\000\161\000\000\000\017\000\018\000\ -\000\000\000\000\000\000\000\000\170\000\000\000\000\000\000\000\ -\047\000\000\000\000\000\000\000\000\000\048\000\000\000\000\000\ -\051\000\171\000\024\000\000\000\162\000\163\000\000\000\164\000\ -\165\000\000\000\000\000\030\000\000\000\161\004\000\000\000\000\ -\166\000\167\000\000\000\010\000\000\000\000\000\000\000\168\000\ -\000\000\013\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\169\000\000\000\000\000\000\000\ -\000\000\161\000\000\000\017\000\018\000\000\000\000\000\000\000\ -\000\000\170\000\000\000\000\000\000\000\047\000\000\000\000\000\ -\000\000\000\000\048\000\000\000\000\000\051\000\171\000\024\000\ -\000\000\162\000\163\000\000\000\164\000\165\000\000\000\000\000\ -\030\000\000\000\163\004\000\000\000\000\166\000\167\000\000\000\ -\010\000\000\000\000\000\000\000\168\000\000\000\013\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\169\000\000\000\000\000\000\000\000\000\161\000\000\000\ -\017\000\018\000\000\000\000\000\000\000\000\000\170\000\000\000\ -\000\000\000\000\047\000\000\000\000\000\000\000\000\000\048\000\ -\000\000\000\000\051\000\171\000\024\000\000\000\162\000\163\000\ -\000\000\164\000\165\000\000\000\000\000\030\000\000\000\165\004\ -\000\000\000\000\166\000\167\000\000\000\010\000\000\000\000\000\ -\000\000\168\000\000\000\013\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\169\000\000\000\ -\000\000\000\000\000\000\161\000\000\000\017\000\018\000\000\000\ -\000\000\000\000\000\000\170\000\000\000\000\000\000\000\047\000\ -\000\000\000\000\000\000\000\000\048\000\000\000\000\000\051\000\ -\171\000\024\000\000\000\162\000\163\000\000\000\164\000\165\000\ -\000\000\000\000\030\000\000\000\000\000\000\000\000\000\166\000\ -\167\000\009\000\010\000\011\000\000\000\000\000\168\000\012\000\ -\013\000\014\000\032\002\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\169\000\000\000\000\000\000\000\000\000\ -\015\000\016\000\017\000\018\000\019\000\020\000\021\000\000\000\ -\170\000\000\000\000\000\022\000\047\000\023\000\000\000\000\000\ -\000\000\048\000\000\000\000\000\051\000\171\000\024\000\000\000\ -\025\000\026\000\027\000\028\000\029\000\000\000\000\000\030\000\ -\031\000\000\000\000\000\032\000\033\000\034\000\000\000\000\000\ -\035\000\036\000\000\000\037\000\038\000\000\000\039\000\000\000\ -\040\000\000\000\041\000\000\000\042\000\000\000\000\000\000\000\ -\043\000\044\000\000\000\045\000\000\000\033\002\000\000\000\000\ -\009\000\010\000\011\000\000\000\046\000\000\000\012\000\013\000\ -\014\000\047\000\000\000\000\000\000\000\000\000\048\000\049\000\ -\050\000\051\000\052\000\053\000\000\000\000\000\054\000\015\000\ -\016\000\017\000\018\000\019\000\020\000\021\000\000\000\000\000\ -\000\000\000\000\022\000\000\000\023\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\024\000\000\000\025\000\ -\026\000\027\000\028\000\029\000\000\000\000\000\030\000\031\000\ -\000\000\000\000\032\000\033\000\034\000\000\000\000\000\035\000\ -\036\000\000\000\037\000\038\000\000\000\039\000\000\000\040\000\ -\000\000\041\000\000\000\042\000\000\000\000\000\000\000\043\000\ -\044\000\000\000\045\000\000\000\000\000\000\000\009\000\010\000\ -\011\000\000\000\000\000\046\000\012\000\013\000\000\000\000\000\ -\047\000\000\000\000\000\000\000\000\000\048\000\049\000\050\000\ -\051\000\052\000\053\000\000\000\000\000\054\000\000\000\017\000\ -\018\000\019\000\020\000\021\000\000\000\000\000\000\000\000\000\ -\022\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\024\000\000\000\025\000\026\000\027\000\ -\028\000\029\000\000\000\000\000\030\000\000\000\000\000\000\000\ -\032\000\033\000\034\000\000\000\000\000\000\000\036\000\000\000\ -\037\000\038\000\000\000\000\000\000\000\040\000\000\000\041\000\ -\000\000\000\000\000\000\000\000\000\000\043\000\044\000\000\000\ -\045\000\000\000\000\000\000\000\000\000\219\000\009\000\010\000\ -\011\000\000\000\000\000\222\000\012\000\013\000\047\000\000\000\ -\000\000\000\000\000\000\048\000\049\000\000\000\051\000\052\000\ -\000\000\000\000\000\000\054\000\000\000\000\000\000\000\017\000\ -\018\000\019\000\020\000\021\000\000\000\000\000\000\000\000\000\ -\022\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\024\000\000\000\025\000\026\000\027\000\ -\028\000\029\000\000\000\000\000\030\000\000\000\000\000\000\000\ -\032\000\033\000\034\000\000\000\000\000\000\000\036\000\000\000\ -\037\000\038\000\000\000\000\000\000\000\040\000\000\000\041\000\ -\000\000\000\000\000\000\000\000\000\000\043\000\044\000\000\000\ -\045\000\000\000\000\000\009\000\010\000\011\000\000\000\000\000\ -\000\000\012\000\013\000\000\000\000\000\000\000\047\000\000\000\ -\000\000\000\000\000\000\048\000\049\000\000\000\051\000\052\000\ -\238\001\000\000\000\000\054\000\017\000\018\000\019\000\020\000\ -\021\000\000\000\000\000\000\000\000\000\022\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\024\000\000\000\025\000\026\000\027\000\028\000\029\000\000\000\ -\000\000\030\000\000\000\000\000\000\000\032\000\033\000\034\000\ -\000\000\000\000\000\000\036\000\000\000\037\000\038\000\000\000\ -\000\000\000\000\040\000\000\000\041\000\000\000\000\000\000\000\ -\000\000\000\000\043\000\044\000\000\000\045\000\000\000\000\000\ -\009\000\010\000\011\000\000\000\000\000\000\000\012\000\013\000\ -\000\000\000\000\000\000\047\000\000\000\000\000\000\000\000\000\ -\048\000\049\000\000\000\051\000\052\000\000\000\000\000\000\000\ -\054\000\017\000\018\000\019\000\020\000\021\000\000\000\000\000\ -\000\000\000\000\022\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\024\000\000\000\025\000\ -\026\000\027\000\028\000\029\000\000\000\000\000\030\000\000\000\ -\000\000\000\000\032\000\033\000\034\000\000\000\000\000\000\000\ -\036\000\000\000\037\000\038\000\000\000\000\000\000\000\040\000\ -\000\000\041\000\000\000\000\000\000\000\000\000\100\002\043\000\ -\044\000\000\000\045\000\000\000\000\000\009\000\010\000\011\000\ -\000\000\000\000\000\000\012\000\013\000\000\000\000\000\000\000\ -\047\000\000\000\000\000\000\000\000\000\048\000\049\000\000\000\ -\051\000\052\000\000\000\000\000\000\000\054\000\017\000\018\000\ -\019\000\020\000\021\000\000\000\000\000\000\000\000\000\022\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\024\000\000\000\025\000\026\000\027\000\028\000\ -\029\000\000\000\000\000\030\000\000\000\000\000\000\000\032\000\ -\033\000\034\000\000\000\000\000\000\000\036\000\000\000\037\000\ -\038\000\000\000\000\000\000\000\040\000\000\000\041\000\000\000\ -\000\000\000\000\000\000\000\000\043\000\044\000\000\000\045\000\ -\000\000\000\000\000\000\000\000\075\003\009\000\010\000\011\000\ -\000\000\000\000\077\003\012\000\013\000\047\000\000\000\000\000\ -\000\000\000\000\048\000\049\000\000\000\051\000\052\000\000\000\ -\000\000\000\000\054\000\000\000\000\000\000\000\017\000\018\000\ -\019\000\020\000\021\000\000\000\000\000\000\000\000\000\022\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\024\000\000\000\025\000\026\000\027\000\028\000\ -\029\000\000\000\000\000\030\000\000\000\000\000\000\000\032\000\ -\033\000\034\000\000\000\000\000\000\000\036\000\000\000\037\000\ -\038\000\000\000\000\000\000\000\040\000\000\000\041\000\000\000\ -\000\000\000\000\000\000\000\000\043\000\044\000\000\000\045\000\ -\000\000\000\000\000\000\009\000\010\000\011\000\000\000\000\000\ -\000\000\012\000\013\000\000\000\000\000\047\000\000\000\000\000\ -\000\000\000\000\048\000\049\000\134\004\051\000\052\000\000\000\ -\000\000\000\000\054\000\000\000\017\000\018\000\019\000\020\000\ -\021\000\000\000\000\000\000\000\000\000\022\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\024\000\000\000\025\000\026\000\027\000\028\000\029\000\000\000\ -\000\000\030\000\000\000\000\000\000\000\032\000\033\000\034\000\ -\000\000\000\000\000\000\036\000\000\000\037\000\038\000\000\000\ -\000\000\000\000\040\000\000\000\041\000\000\000\000\000\000\000\ -\000\000\000\000\043\000\044\000\000\000\045\000\000\000\000\000\ -\025\003\025\003\025\003\000\000\000\000\000\000\025\003\025\003\ -\000\000\000\000\000\000\047\000\000\000\000\000\000\000\000\000\ -\048\000\049\000\000\000\051\000\052\000\025\003\000\000\000\000\ -\054\000\025\003\025\003\025\003\025\003\025\003\000\000\000\000\ -\000\000\000\000\025\003\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\025\003\000\000\025\003\ -\025\003\025\003\025\003\025\003\000\000\000\000\025\003\000\000\ -\000\000\000\000\025\003\025\003\025\003\000\000\000\000\000\000\ -\025\003\000\000\025\003\025\003\000\000\000\000\000\000\025\003\ -\000\000\025\003\000\000\000\000\000\000\000\000\000\000\025\003\ -\025\003\000\000\025\003\000\000\000\000\009\000\010\000\011\000\ -\000\000\000\000\000\000\012\000\013\000\000\000\000\000\000\000\ -\025\003\000\000\000\000\000\000\000\000\025\003\025\003\000\000\ -\025\003\025\003\000\000\000\000\000\000\025\003\017\000\018\000\ -\019\000\020\000\021\000\000\000\000\000\000\000\000\000\022\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\024\000\000\000\025\000\026\000\027\000\028\000\ -\029\000\000\000\000\000\030\000\000\000\000\000\000\000\032\000\ -\033\000\034\000\000\000\000\000\000\000\036\000\000\000\037\000\ -\038\000\000\000\000\000\000\000\040\000\000\000\041\000\000\000\ -\000\000\000\000\000\000\000\000\043\000\044\000\000\000\045\000\ -\000\000\000\000\025\003\025\003\025\003\000\000\000\000\000\000\ -\025\003\025\003\000\000\000\000\000\000\047\000\000\000\000\000\ -\000\000\000\000\048\000\049\000\000\000\051\000\052\000\000\000\ -\000\000\000\000\054\000\025\003\025\003\025\003\025\003\025\003\ -\000\000\000\000\000\000\000\000\025\003\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\025\003\ -\000\000\025\003\025\003\025\003\025\003\025\003\000\000\000\000\ -\025\003\000\000\000\000\000\000\025\003\025\003\025\003\000\000\ -\000\000\000\000\025\003\000\000\025\003\025\003\000\000\000\000\ -\000\000\025\003\000\000\025\003\000\000\000\000\000\000\000\000\ -\000\000\025\003\025\003\000\000\025\003\000\000\000\000\023\003\ -\023\003\023\003\000\000\000\000\000\000\023\003\023\003\000\000\ -\000\000\000\000\025\003\000\000\000\000\000\000\000\000\025\003\ -\025\003\000\000\025\003\025\003\000\000\000\000\000\000\025\003\ -\023\003\023\003\023\003\023\003\023\003\000\000\000\000\000\000\ -\000\000\023\003\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\023\003\000\000\023\003\023\003\ -\023\003\023\003\023\003\000\000\000\000\023\003\000\000\000\000\ -\000\000\023\003\023\003\023\003\000\000\000\000\000\000\023\003\ -\000\000\023\003\023\003\000\000\000\000\010\000\023\003\000\000\ -\023\003\000\000\000\000\013\000\000\000\217\003\023\003\023\003\ -\018\002\023\003\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\218\003\000\000\000\000\017\000\018\000\023\003\ -\000\000\000\000\000\000\000\000\023\003\023\003\000\000\023\003\ -\023\003\000\000\000\000\000\000\023\003\000\000\000\000\000\000\ -\000\000\024\000\252\001\000\000\163\000\000\000\164\000\165\000\ -\000\000\000\000\030\000\000\000\000\000\000\000\000\000\166\000\ -\219\003\000\000\010\000\000\000\000\000\000\000\168\000\000\000\ -\013\000\000\000\017\002\000\000\000\000\018\002\000\000\000\000\ -\254\001\000\000\000\000\169\000\000\000\000\000\000\000\218\003\ -\255\001\000\000\017\000\018\000\000\000\010\000\000\000\000\000\ -\170\000\000\000\000\000\013\000\047\000\250\002\000\000\000\002\ -\000\000\048\000\000\000\000\000\051\000\171\000\024\000\252\001\ -\000\000\163\000\000\000\164\000\165\000\017\000\018\000\030\000\ -\000\000\000\000\000\000\000\000\166\000\219\003\000\000\000\000\ -\000\000\000\000\000\000\168\000\000\000\000\000\000\000\000\000\ -\000\000\024\000\252\001\000\000\163\000\254\001\164\000\165\000\ -\169\000\000\000\030\000\000\000\000\000\255\001\000\000\166\000\ -\251\002\000\000\000\000\000\000\000\000\170\000\168\000\000\000\ -\252\002\047\000\000\000\000\000\000\002\000\000\048\000\000\000\ -\254\001\051\000\171\000\169\000\000\000\000\000\010\000\000\000\ -\255\001\000\000\000\000\000\000\013\000\000\000\107\004\000\000\ -\170\000\000\000\000\000\000\000\047\000\000\000\000\000\000\002\ -\000\000\048\000\000\000\108\004\051\000\171\000\017\000\018\000\ -\000\000\010\000\000\000\000\000\000\000\000\000\000\000\013\000\ -\000\000\031\006\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\024\000\252\001\000\000\163\000\218\003\164\000\ -\165\000\017\000\018\000\030\000\000\000\000\000\000\000\000\000\ -\166\000\167\000\000\000\000\000\000\000\000\000\000\000\168\000\ -\000\000\000\000\000\000\000\000\000\000\024\000\252\001\000\000\ -\163\000\254\001\164\000\165\000\169\000\000\000\030\000\000\000\ -\000\000\255\001\000\000\166\000\219\003\000\000\010\000\000\000\ -\000\000\170\000\168\000\000\000\013\000\047\000\000\000\000\000\ -\000\002\000\000\048\000\000\000\254\001\051\000\171\000\169\000\ -\000\000\000\000\000\000\000\000\255\001\000\000\017\000\018\000\ -\000\000\010\000\000\000\000\000\170\000\000\000\000\000\013\000\ -\047\000\000\000\000\000\000\002\000\000\048\000\000\000\000\000\ -\051\000\171\000\024\000\252\001\000\000\163\000\000\000\164\000\ -\165\000\017\000\018\000\030\000\000\000\000\000\000\000\000\000\ -\166\000\167\000\000\000\000\000\000\000\000\000\000\000\168\000\ -\000\000\015\006\000\000\000\000\000\000\024\000\252\001\000\000\ -\163\000\254\001\164\000\165\000\169\000\000\000\030\000\000\000\ -\000\000\255\001\000\000\166\000\253\001\000\000\010\000\000\000\ -\000\000\170\000\168\000\000\000\013\000\047\000\000\000\000\000\ -\000\002\000\000\048\000\000\000\254\001\051\000\171\000\169\000\ -\000\000\000\000\000\000\000\000\255\001\000\000\017\000\018\000\ -\000\000\025\003\000\000\000\000\170\000\000\000\000\000\025\003\ -\047\000\000\000\000\000\000\002\000\000\048\000\000\000\000\000\ -\051\000\171\000\024\000\252\001\000\000\163\000\000\000\164\000\ -\165\000\025\003\025\003\030\000\000\000\000\000\000\000\000\000\ -\166\000\167\000\000\000\000\000\000\000\000\000\000\000\168\000\ -\000\000\000\000\000\000\000\000\000\000\025\003\025\003\000\000\ -\025\003\254\001\025\003\025\003\169\000\000\000\025\003\000\000\ -\000\000\255\001\000\000\025\003\025\003\000\000\023\003\000\000\ -\000\000\170\000\025\003\000\000\023\003\047\000\000\000\000\000\ -\000\002\000\000\048\000\000\000\025\003\051\000\171\000\025\003\ -\000\000\000\000\000\000\000\000\025\003\000\000\023\003\023\003\ -\000\000\000\000\000\000\000\000\025\003\000\000\000\000\000\000\ -\025\003\000\000\000\000\025\003\000\000\025\003\000\000\000\000\ -\025\003\025\003\023\003\023\003\000\000\023\003\000\000\023\003\ -\023\003\000\000\000\000\023\003\000\000\000\000\000\000\000\000\ -\023\003\023\003\000\000\000\000\010\000\000\000\000\000\023\003\ -\000\000\000\000\013\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\023\003\000\000\000\000\023\003\000\000\000\000\000\000\ -\000\000\023\003\161\000\000\000\017\000\018\000\000\000\000\000\ -\000\000\023\003\000\000\000\000\000\000\023\003\000\000\000\000\ -\023\003\000\000\023\003\000\000\000\000\023\003\023\003\000\000\ -\024\000\000\000\162\000\163\000\000\000\164\000\165\000\000\000\ -\000\000\030\000\000\000\000\000\000\000\000\000\166\000\167\000\ -\000\000\000\000\000\000\010\000\000\000\168\000\000\000\205\001\ -\000\000\013\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\169\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\161\000\219\000\017\000\018\000\000\000\000\000\170\000\ -\000\000\000\000\000\000\047\000\000\000\000\000\000\000\000\000\ -\048\000\000\000\000\000\051\000\171\000\000\000\000\000\024\000\ -\000\000\162\000\163\000\000\000\164\000\165\000\000\000\000\000\ -\030\000\000\000\000\000\000\000\000\000\166\000\167\000\000\000\ -\010\000\000\000\000\000\000\000\168\000\000\000\013\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\010\000\011\000\000\000\ -\000\000\169\000\012\000\013\000\000\000\000\000\161\000\000\000\ -\017\000\018\000\000\000\000\000\000\000\000\000\170\000\000\000\ -\000\000\000\000\047\000\000\000\000\000\017\000\018\000\048\000\ -\000\000\000\000\051\000\171\000\024\000\000\000\162\000\163\000\ -\000\000\164\000\165\000\000\000\000\000\030\000\000\000\000\000\ -\000\000\024\000\166\000\167\000\026\000\027\000\028\000\029\000\ -\000\000\168\000\030\000\000\000\025\003\000\000\025\003\166\000\ -\034\000\000\000\025\003\000\000\000\000\000\000\169\000\000\000\ -\000\000\000\000\000\000\040\000\000\000\000\000\156\003\000\000\ -\000\000\000\000\025\003\170\000\025\003\025\003\045\000\047\000\ -\000\000\000\000\000\000\000\000\048\000\000\000\000\000\051\000\ -\171\000\000\000\000\000\000\000\047\000\000\000\000\000\000\000\ -\025\003\048\000\025\003\025\003\051\000\025\003\025\003\000\000\ -\000\000\025\003\000\000\000\000\000\000\000\000\025\003\025\003\ -\000\000\010\000\000\000\000\000\000\000\025\003\000\000\013\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\025\003\000\000\000\000\000\000\000\000\161\000\ -\000\000\017\000\018\000\000\000\000\000\000\000\000\000\025\003\ -\000\000\000\000\000\000\025\003\000\000\000\000\000\000\000\000\ -\025\003\000\000\000\000\025\003\025\003\024\000\000\000\162\000\ -\163\000\000\000\164\000\165\000\000\000\000\000\030\000\000\000\ -\000\000\000\000\000\000\166\000\167\000\000\000\025\003\000\000\ -\000\000\000\000\168\000\000\000\025\003\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\169\000\ -\000\000\000\000\000\000\000\000\025\003\000\000\025\003\025\003\ -\000\000\025\003\000\000\000\000\170\000\000\000\000\000\025\003\ -\047\000\000\000\000\000\000\000\000\000\048\000\000\000\000\000\ -\051\000\171\000\025\003\000\000\025\003\025\003\000\000\025\003\ -\025\003\025\003\025\003\025\003\000\000\000\000\000\000\000\000\ -\025\003\025\003\000\000\000\000\000\000\000\000\000\000\025\003\ -\000\000\000\000\000\000\000\000\000\000\025\003\000\000\025\003\ -\025\003\000\000\025\003\025\003\025\003\000\000\025\003\000\000\ -\000\000\000\000\000\000\025\003\025\003\000\000\213\002\000\000\ -\000\000\025\003\025\003\000\000\213\002\025\003\000\000\000\000\ -\000\000\000\000\025\003\000\000\000\000\025\003\025\003\025\003\ -\000\000\000\000\000\000\000\000\213\002\000\000\213\002\213\002\ -\025\003\010\000\000\000\000\000\025\003\000\000\000\000\013\000\ -\025\003\000\000\000\000\000\000\000\000\025\003\000\000\000\000\ -\025\003\025\003\213\002\000\000\213\002\213\002\000\000\213\002\ -\213\002\017\000\018\000\213\002\000\000\000\000\000\000\000\000\ -\213\002\213\002\000\000\000\000\000\000\000\000\000\000\213\002\ -\000\000\000\000\000\000\000\000\000\000\024\000\000\000\162\000\ -\163\000\000\000\164\000\165\000\213\002\000\000\030\000\000\000\ -\000\000\000\000\000\000\166\000\167\000\000\000\194\002\000\000\ -\000\000\213\002\168\000\000\000\194\002\213\002\000\000\000\000\ -\000\000\000\000\213\002\000\000\000\000\213\002\213\002\169\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\194\002\194\002\ -\000\000\023\003\000\000\000\000\170\000\000\000\000\000\023\003\ -\047\000\000\000\000\000\000\000\000\000\048\000\000\000\000\000\ -\051\000\171\000\194\002\000\000\194\002\194\002\000\000\194\002\ -\194\002\023\003\023\003\194\002\000\000\000\000\000\000\000\000\ -\194\002\194\002\000\000\000\000\000\000\000\000\000\000\194\002\ -\000\000\000\000\000\000\000\000\000\000\023\003\000\000\023\003\ -\023\003\000\000\023\003\023\003\194\002\000\000\023\003\000\000\ -\000\000\000\000\000\000\023\003\023\003\000\000\010\000\000\000\ -\000\000\194\002\023\003\000\000\013\000\194\002\000\000\000\000\ -\000\000\000\000\194\002\000\000\000\000\194\002\194\002\023\003\ -\000\000\000\000\000\000\000\000\000\000\000\000\017\000\018\000\ -\000\000\025\003\000\000\000\000\023\003\000\000\000\000\025\003\ -\023\003\000\000\000\000\000\000\000\000\023\003\000\000\000\000\ -\023\003\023\003\024\000\000\000\000\000\163\000\000\000\164\000\ -\165\000\025\003\025\003\030\000\000\000\000\000\000\000\000\000\ -\166\000\167\000\000\000\000\000\000\000\000\000\000\000\168\000\ -\000\000\000\000\000\000\000\000\000\000\025\003\000\000\000\000\ -\025\003\000\000\025\003\025\003\169\000\000\000\025\003\000\000\ -\000\000\000\000\000\000\025\003\025\003\000\000\000\000\000\000\ -\000\000\170\000\025\003\000\000\000\000\047\000\010\000\011\000\ -\000\000\000\000\048\000\012\000\013\000\051\000\171\000\025\003\ -\000\000\000\000\000\000\000\000\000\000\000\000\115\001\000\000\ -\000\000\000\000\000\000\000\000\025\003\000\000\017\000\018\000\ -\025\003\000\000\000\000\000\000\000\000\025\003\000\000\000\000\ -\025\003\025\003\000\000\000\000\000\000\000\000\000\000\116\001\ -\000\000\000\000\024\000\117\001\000\000\026\000\027\000\028\000\ -\029\000\000\000\000\000\030\000\000\000\000\000\000\000\000\000\ -\166\000\034\000\010\000\011\000\000\000\000\000\000\000\012\000\ -\013\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\ -\000\000\118\001\000\000\000\000\000\000\000\000\000\000\045\000\ -\000\000\119\001\017\000\018\000\000\000\000\000\000\000\000\000\ -\000\000\120\001\121\001\000\000\000\000\047\000\000\000\000\000\ -\122\001\000\000\048\000\000\000\000\000\051\000\024\000\117\001\ -\000\000\026\000\027\000\028\000\029\000\000\000\000\000\030\000\ -\000\000\000\000\000\000\000\000\166\000\034\000\010\000\011\000\ -\000\000\000\000\000\000\012\000\013\000\025\003\025\003\000\000\ -\040\000\000\000\025\003\025\003\000\000\118\001\000\000\000\000\ -\000\000\000\000\000\000\045\000\000\000\119\001\017\000\018\000\ -\000\000\000\000\000\000\000\000\000\000\025\003\025\003\000\000\ -\000\000\047\000\000\000\000\000\122\001\000\000\048\000\000\000\ -\000\000\051\000\024\000\000\000\000\000\026\000\027\000\028\000\ -\029\000\025\003\000\000\030\000\025\003\025\003\025\003\025\003\ -\207\000\034\000\025\003\000\000\000\000\000\000\059\005\025\003\ -\025\003\000\000\000\000\000\000\040\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\025\003\000\000\060\005\000\000\045\000\ -\000\000\000\000\000\000\000\000\243\001\000\000\025\003\000\000\ -\000\000\000\000\000\000\000\000\000\000\047\000\000\000\000\000\ -\000\000\000\000\048\000\000\000\025\003\051\000\000\000\000\000\ -\000\000\025\003\000\000\000\000\025\003\061\005\000\000\137\000\ -\138\000\030\000\000\000\139\000\000\000\000\000\140\000\062\005\ -\000\000\000\000\000\000\032\005\078\001\079\001\000\000\000\000\ -\000\000\000\000\000\000\000\000\080\001\000\000\000\000\142\000\ -\000\000\033\005\081\001\082\001\034\005\083\001\063\005\143\000\ -\144\000\000\000\000\000\000\000\000\000\000\000\084\001\145\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\085\001\ -\246\001\000\000\000\000\064\005\147\000\086\001\087\001\088\001\ -\089\001\090\001\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\091\001\000\000\000\000\000\000\000\000\186\000\000\000\000\000\ -\000\000\000\000\092\001\093\001\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\094\001\095\001\096\001\ -\097\001\098\001\000\000\026\001\027\001\028\001\000\000\000\000\ -\000\000\035\005\207\001\000\000\030\001\000\000\000\000\100\001\ -\000\000\000\000\023\003\032\001\023\003\023\003\023\003\000\000\ -\023\003\000\000\000\000\023\003\023\003\000\000\033\001\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\034\001\ -\000\000\000\000\000\000\000\000\023\003\035\001\036\001\037\001\ -\038\001\039\001\040\001\000\000\023\003\023\003\000\000\000\000\ -\000\000\000\000\000\000\000\000\023\003\000\000\000\000\000\000\ -\041\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\023\003\023\003\234\002\209\001\000\000\235\002\000\000\000\000\ -\000\000\000\000\041\004\078\001\079\001\045\001\046\001\236\002\ -\212\001\049\001\213\001\080\001\000\000\000\000\000\000\000\000\ -\000\000\081\001\082\001\000\000\083\001\052\001\000\000\053\001\ -\000\000\000\000\000\000\000\000\000\000\084\001\000\000\000\000\ -\000\000\000\000\043\004\078\001\079\001\000\000\085\001\000\000\ -\000\000\000\000\000\000\080\001\086\001\087\001\088\001\089\001\ -\090\001\081\001\082\001\000\000\083\001\000\000\000\000\000\000\ -\043\002\000\000\043\002\043\002\043\002\084\001\043\002\091\001\ -\000\000\043\002\043\002\000\000\186\000\000\000\085\001\000\000\ -\000\000\092\001\093\001\000\000\086\001\087\001\088\001\089\001\ -\090\001\000\000\043\002\000\000\094\001\095\001\096\001\097\001\ -\098\001\000\000\043\002\043\002\000\000\042\004\000\000\091\001\ -\000\000\000\000\043\002\000\000\186\000\000\000\100\001\000\000\ -\000\000\092\001\093\001\000\000\000\000\000\000\043\002\043\002\ -\045\004\078\001\079\001\000\000\094\001\095\001\096\001\097\001\ -\098\001\080\001\000\000\000\000\000\000\000\000\044\004\081\001\ -\082\001\000\000\083\001\000\000\000\000\000\000\100\001\000\000\ -\000\000\000\000\000\000\084\001\000\000\000\000\000\000\000\000\ -\041\004\078\001\079\001\000\000\085\001\000\000\000\000\000\000\ -\000\000\080\001\086\001\087\001\088\001\089\001\090\001\081\001\ -\082\001\000\000\083\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\084\001\000\000\091\001\000\000\000\000\ -\000\000\000\000\186\000\000\000\085\001\000\000\000\000\092\001\ -\093\001\000\000\086\001\087\001\088\001\089\001\090\001\000\000\ -\000\000\000\000\094\001\095\001\096\001\097\001\098\001\000\000\ -\000\000\000\000\000\000\000\000\000\000\091\001\046\004\000\000\ -\000\000\000\000\186\000\000\000\100\001\000\000\000\000\092\001\ -\093\001\000\000\000\000\000\000\000\000\000\000\043\004\078\001\ -\079\001\000\000\094\001\095\001\096\001\097\001\098\001\080\001\ -\000\000\000\000\000\000\099\004\000\000\081\001\082\001\000\000\ -\083\001\000\000\000\000\000\000\100\001\000\000\000\000\000\000\ -\000\000\084\001\000\000\000\000\000\000\000\000\045\004\078\001\ -\079\001\000\000\085\001\000\000\000\000\000\000\000\000\080\001\ -\086\001\087\001\088\001\089\001\090\001\081\001\082\001\000\000\ -\083\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\084\001\000\000\091\001\000\000\000\000\000\000\000\000\ -\186\000\000\000\085\001\000\000\000\000\092\001\093\001\000\000\ -\086\001\087\001\088\001\089\001\090\001\000\000\000\000\000\000\ -\094\001\095\001\096\001\097\001\098\001\000\000\000\000\000\000\ -\000\000\000\000\100\004\091\001\000\000\000\000\000\000\000\000\ -\186\000\000\000\100\001\000\000\000\000\092\001\093\001\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\094\001\095\001\096\001\097\001\098\001\081\005\078\001\079\001\ -\000\000\000\000\000\000\000\000\101\004\000\000\080\001\000\000\ -\000\000\000\000\100\001\000\000\081\001\082\001\000\000\083\001\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\084\001\000\000\000\000\000\000\000\000\083\005\078\001\079\001\ -\000\000\085\001\000\000\000\000\000\000\000\000\080\001\086\001\ -\087\001\088\001\089\001\090\001\081\001\082\001\000\000\083\001\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\084\001\000\000\091\001\000\000\000\000\000\000\000\000\186\000\ -\000\000\085\001\000\000\000\000\092\001\093\001\000\000\086\001\ -\087\001\088\001\089\001\090\001\000\000\000\000\000\000\094\001\ -\095\001\096\001\097\001\098\001\000\000\000\000\000\000\000\000\ -\082\005\000\000\091\001\000\000\000\000\000\000\000\000\186\000\ -\000\000\100\001\000\000\000\000\092\001\093\001\000\000\000\000\ -\000\000\000\000\000\000\085\005\078\001\079\001\000\000\094\001\ -\095\001\096\001\097\001\098\001\080\001\000\000\000\000\000\000\ -\000\000\084\005\081\001\082\001\000\000\083\001\000\000\000\000\ -\000\000\100\001\000\000\000\000\000\000\000\000\084\001\000\000\ -\000\000\000\000\000\000\081\005\078\001\079\001\000\000\085\001\ -\000\000\000\000\000\000\000\000\080\001\086\001\087\001\088\001\ -\089\001\090\001\081\001\082\001\000\000\083\001\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\084\001\000\000\ -\091\001\000\000\000\000\000\000\000\000\186\000\000\000\085\001\ -\000\000\000\000\092\001\093\001\000\000\086\001\087\001\088\001\ -\089\001\090\001\000\000\000\000\000\000\094\001\095\001\096\001\ -\097\001\098\001\000\000\000\000\000\000\000\000\000\000\000\000\ -\091\001\086\005\000\000\000\000\000\000\186\000\000\000\100\001\ -\000\000\000\000\092\001\093\001\000\000\000\000\000\000\000\000\ -\000\000\083\005\078\001\079\001\000\000\094\001\095\001\096\001\ -\097\001\098\001\080\001\000\000\000\000\000\000\106\005\000\000\ -\081\001\082\001\000\000\083\001\000\000\000\000\000\000\100\001\ -\000\000\000\000\000\000\000\000\084\001\000\000\000\000\000\000\ -\000\000\085\005\078\001\079\001\000\000\085\001\000\000\000\000\ -\000\000\000\000\080\001\086\001\087\001\088\001\089\001\090\001\ -\081\001\082\001\000\000\083\001\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\084\001\000\000\091\001\000\000\ -\000\000\000\000\000\000\186\000\000\000\085\001\000\000\000\000\ -\092\001\093\001\000\000\086\001\087\001\088\001\089\001\090\001\ -\000\000\000\000\000\000\094\001\095\001\096\001\097\001\098\001\ -\000\000\000\000\000\000\000\000\000\000\107\005\091\001\078\001\ -\079\001\000\000\000\000\186\000\000\000\100\001\000\000\080\001\ -\092\001\093\001\000\000\000\000\000\000\081\001\082\001\000\000\ -\083\001\000\000\000\000\094\001\095\001\096\001\097\001\098\001\ -\000\000\084\001\000\000\000\000\000\000\000\000\000\000\108\005\ -\000\000\000\000\085\001\000\000\000\000\100\001\000\000\000\000\ -\086\001\087\001\088\001\089\001\090\001\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\091\001\078\001\079\001\000\000\000\000\ -\186\000\000\000\000\000\000\000\080\001\092\001\093\001\000\000\ -\000\000\000\000\081\001\082\001\000\000\083\001\000\000\000\000\ -\094\001\095\001\096\001\097\001\098\001\000\000\084\001\000\000\ -\000\000\000\000\000\000\000\000\000\000\099\001\000\000\085\001\ -\000\000\000\000\100\001\000\000\000\000\086\001\087\001\088\001\ -\089\001\090\001\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\091\001\078\001\079\001\000\000\000\000\186\000\000\000\000\000\ -\000\000\080\001\092\001\093\001\000\000\000\000\000\000\081\001\ -\082\001\000\000\083\001\000\000\000\000\094\001\095\001\096\001\ -\097\001\098\001\000\000\084\001\000\000\000\000\031\004\000\000\ -\000\000\078\001\079\001\000\000\085\001\000\000\000\000\100\001\ -\000\000\080\001\086\001\087\001\088\001\089\001\090\001\081\001\ -\082\001\000\000\083\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\138\004\000\000\084\001\000\000\091\001\000\000\000\000\ -\000\000\000\000\186\000\000\000\085\001\000\000\000\000\092\001\ -\093\001\000\000\086\001\087\001\088\001\089\001\090\001\000\000\ -\000\000\000\000\094\001\095\001\096\001\097\001\098\001\000\000\ -\000\000\000\000\000\000\093\004\000\000\091\001\078\001\079\001\ -\000\000\000\000\186\000\000\000\100\001\000\000\080\001\092\001\ -\093\001\000\000\000\000\000\000\081\001\082\001\000\000\083\001\ -\000\000\000\000\094\001\095\001\096\001\097\001\098\001\000\000\ -\084\001\000\000\000\000\000\000\000\000\000\000\240\000\240\000\ -\000\000\085\001\000\000\000\000\100\001\000\000\240\000\086\001\ -\087\001\088\001\089\001\090\001\240\000\240\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\240\000\000\000\091\001\000\000\000\000\000\000\000\000\186\000\ -\000\000\240\000\000\000\000\000\092\001\093\001\000\000\240\000\ -\240\000\240\000\240\000\240\000\000\000\000\000\000\000\094\001\ -\095\001\096\001\097\001\098\001\000\000\000\000\000\000\000\000\ -\000\000\000\000\240\000\078\001\079\001\000\000\000\000\240\000\ -\000\000\100\001\000\000\080\001\240\000\240\000\000\000\000\000\ -\000\000\081\001\000\000\000\000\000\000\000\000\000\000\240\000\ -\240\000\240\000\240\000\240\000\000\000\084\001\000\000\000\000\ -\240\000\000\000\000\000\078\001\079\001\000\000\085\001\000\000\ -\000\000\240\000\000\000\000\000\086\001\087\001\088\001\089\001\ -\090\001\081\001\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\084\001\000\000\091\001\ -\000\000\000\000\000\000\000\000\186\000\000\000\085\001\000\000\ -\000\000\092\001\093\001\000\000\086\001\087\001\088\001\089\001\ -\090\001\094\000\000\000\000\000\094\001\095\001\096\001\097\001\ -\098\001\000\000\000\000\000\000\000\000\000\000\000\000\091\001\ -\095\000\016\000\000\000\000\000\186\000\000\000\100\001\000\000\ -\000\000\092\001\093\001\000\000\000\000\096\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\095\001\096\001\097\001\ -\098\001\000\000\000\000\136\000\000\000\137\000\138\000\030\000\ -\031\000\139\000\000\000\000\000\140\000\141\000\100\001\000\000\ -\035\000\000\000\000\000\000\000\000\000\000\000\097\000\000\000\ -\000\000\000\000\000\000\000\000\042\000\142\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\143\000\144\000\000\000\ -\000\000\000\000\000\000\000\000\098\000\145\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\099\000\146\000\147\000\053\000" - -let yycheck = "\009\000\ -\210\000\145\000\012\000\002\000\014\000\015\000\016\000\136\000\ -\199\000\019\000\020\000\021\000\022\000\023\000\002\000\025\000\ -\163\000\132\001\142\000\205\000\136\000\163\002\032\000\202\000\ -\002\000\123\001\036\000\002\000\202\000\039\000\040\000\041\000\ -\011\000\001\000\034\003\002\000\010\000\024\001\010\002\049\000\ -\050\000\027\000\136\000\053\000\054\000\139\000\002\000\026\000\ -\002\000\138\000\002\000\234\003\163\002\002\000\038\003\253\002\ -\098\000\157\000\221\000\029\000\223\000\105\002\003\000\004\000\ -\186\003\225\002\045\000\063\004\110\000\000\000\170\000\115\004\ -\194\003\063\003\003\000\004\000\031\000\006\000\046\000\241\004\ -\035\000\056\005\201\004\063\005\094\000\095\000\096\000\097\000\ -\131\000\099\000\133\000\003\000\008\001\001\000\134\001\003\000\ -\004\000\141\002\000\000\098\000\054\001\003\003\021\001\000\001\ -\083\000\034\000\085\000\086\000\058\000\110\002\098\000\110\000\ -\067\005\214\004\203\000\000\000\000\001\003\005\000\001\042\002\ -\098\000\127\002\110\000\098\000\017\001\240\001\010\001\164\001\ -\000\001\166\001\005\000\098\000\110\000\074\001\192\004\110\000\ -\000\001\056\001\046\000\149\000\007\001\110\004\098\000\110\000\ -\098\000\000\001\098\000\121\000\000\001\098\000\058\000\161\000\ -\162\000\139\000\110\000\000\001\110\000\008\001\110\000\000\000\ -\087\004\110\000\244\004\173\000\014\001\000\001\052\005\108\001\ -\226\004\000\001\144\000\077\005\060\001\066\001\000\000\001\005\ -\092\001\006\001\188\000\030\001\103\002\008\001\157\005\000\001\ -\066\001\004\001\127\000\197\000\129\000\008\001\131\000\073\001\ -\133\000\000\001\066\001\092\001\015\001\099\003\133\001\018\001\ -\129\000\000\000\066\001\030\001\055\001\000\001\037\001\162\005\ -\092\001\073\001\189\000\095\001\094\001\214\002\065\001\008\001\ -\000\001\129\000\224\002\127\000\014\001\129\000\094\001\131\000\ -\115\001\133\000\000\001\206\000\055\001\079\001\094\001\186\000\ -\187\000\115\001\203\004\121\005\091\001\030\001\065\001\091\001\ -\095\001\000\001\036\001\027\001\130\005\000\001\091\001\066\001\ -\107\002\108\002\095\001\115\001\054\005\027\001\073\001\106\001\ -\101\005\237\005\109\001\094\001\008\001\000\001\055\001\092\001\ -\095\001\017\001\121\003\196\000\022\001\023\001\064\001\000\000\ -\065\001\000\001\197\001\204\000\027\001\094\001\123\005\106\001\ -\027\001\008\001\109\001\109\005\143\002\151\004\022\001\094\001\ -\154\004\005\003\044\001\000\001\000\001\055\001\113\001\067\001\ -\091\001\204\001\037\001\206\001\202\003\095\001\064\001\097\001\ -\058\001\193\001\029\001\091\001\176\001\063\001\094\001\095\001\ -\231\001\106\001\000\001\109\001\109\001\091\001\027\001\157\001\ -\074\001\095\001\000\001\000\001\192\001\022\001\164\001\050\001\ -\166\001\252\001\046\003\217\003\091\001\010\001\001\002\173\001\ -\174\001\087\003\088\003\094\001\027\001\040\006\094\001\094\001\ -\092\001\236\001\130\002\094\001\102\001\027\001\188\001\105\001\ -\154\005\107\001\000\001\109\001\095\001\111\001\094\001\038\002\ -\205\005\163\005\033\005\034\005\151\001\115\003\153\001\019\001\ -\155\001\021\001\215\005\000\001\071\001\000\000\048\002\008\001\ -\164\005\000\001\072\001\160\002\026\001\024\001\091\001\091\001\ -\057\001\015\006\095\001\141\001\107\006\143\001\120\001\066\001\ -\255\005\066\001\117\001\118\001\069\001\026\001\121\001\000\001\ -\123\001\000\001\048\004\074\005\056\001\159\001\069\002\094\001\ -\094\001\010\001\015\001\000\001\035\001\091\001\000\001\092\001\ -\094\001\095\001\095\001\008\006\072\001\000\001\000\001\177\001\ -\178\001\014\001\099\001\000\001\017\001\000\001\103\001\081\006\ -\099\005\083\006\004\001\014\001\059\001\000\001\008\001\125\004\ -\000\001\064\001\065\001\173\001\174\001\015\001\092\001\000\001\ -\018\001\203\001\190\005\074\001\000\001\003\001\188\004\103\004\ -\210\001\000\001\088\006\092\001\214\001\004\001\105\001\092\001\ -\027\001\008\001\151\001\010\001\153\001\058\006\155\001\014\001\ -\000\001\227\001\228\001\018\001\099\001\076\004\232\001\027\001\ -\234\001\008\001\010\001\000\001\027\001\000\001\109\001\066\001\ -\062\001\094\001\000\001\092\001\091\001\000\001\095\001\007\000\ -\066\001\251\001\000\001\151\001\000\001\153\001\032\002\155\001\ -\171\005\094\001\004\001\039\006\094\001\007\002\008\001\009\002\ -\010\002\000\001\000\001\094\001\094\001\015\001\091\001\000\001\ -\018\001\092\001\095\001\055\004\052\003\241\003\193\005\000\001\ -\091\001\000\001\073\001\004\001\095\001\035\001\094\001\008\001\ -\017\001\010\001\018\001\092\001\004\001\014\001\040\002\091\001\ -\000\001\032\002\094\001\095\001\091\001\092\001\221\005\094\001\ -\095\001\027\002\027\001\190\002\032\002\059\001\014\001\000\001\ -\172\002\173\002\064\001\065\001\092\001\092\001\032\002\095\001\ -\066\001\032\002\113\001\000\001\074\001\000\001\091\001\103\003\ -\091\001\032\002\160\002\231\001\095\001\109\003\070\005\171\002\ -\094\001\002\001\253\002\094\001\032\002\003\001\032\002\091\001\ -\032\002\036\002\056\002\032\002\038\003\099\001\028\005\073\002\ -\073\001\000\001\066\001\022\001\091\001\072\002\000\001\109\001\ -\094\001\065\001\066\001\010\001\014\001\094\001\094\001\113\001\ -\074\002\075\002\091\001\092\001\151\002\094\001\095\001\094\001\ -\003\001\018\001\042\002\038\003\047\001\000\001\229\004\129\002\ -\038\003\004\001\132\002\053\003\134\002\008\001\094\001\010\001\ -\113\001\004\001\000\001\014\001\022\001\027\001\008\001\018\001\ -\230\002\066\001\232\002\092\001\164\000\165\000\017\002\018\002\ -\027\001\100\002\018\001\076\002\064\001\107\004\000\001\092\001\ -\014\001\177\000\178\000\094\001\250\002\032\002\015\001\159\005\ -\008\001\069\002\036\001\022\001\018\001\205\003\097\001\098\001\ -\018\001\076\003\170\005\078\003\066\001\183\002\090\001\103\002\ -\019\001\201\000\003\001\073\001\094\001\092\001\111\002\112\002\ -\115\001\019\001\092\001\092\001\036\001\094\001\073\001\201\002\ -\192\005\203\002\110\001\205\002\066\001\237\003\073\001\209\002\ -\090\001\008\001\068\006\065\001\066\001\048\001\180\002\018\001\ -\091\001\092\001\151\002\094\001\095\001\083\001\048\001\049\001\ -\049\003\060\001\092\001\018\001\092\001\115\001\066\003\233\002\ -\018\001\068\001\060\001\070\001\200\004\062\003\113\001\090\001\ -\094\001\027\002\068\001\018\001\070\001\094\001\092\001\146\003\ -\094\001\022\001\242\005\151\002\092\001\255\002\134\003\133\005\ -\232\005\172\003\004\003\005\003\000\000\012\001\172\003\008\001\ -\214\004\001\006\118\003\022\001\067\001\015\003\130\003\017\003\ -\251\003\036\001\253\003\254\003\111\001\113\003\000\001\027\001\ -\031\001\022\001\028\003\029\003\060\004\111\001\133\005\073\002\ -\118\003\092\001\088\001\067\004\065\001\039\003\215\002\216\002\ -\000\001\019\001\248\004\050\001\046\003\092\001\006\003\170\002\ -\026\001\220\003\047\001\027\001\094\001\139\003\220\003\057\003\ -\000\000\015\001\112\001\022\001\030\001\238\002\066\001\186\002\ -\071\001\094\001\067\001\031\005\102\003\060\003\048\001\049\001\ -\022\001\196\002\000\001\252\002\095\001\084\001\080\003\090\001\ -\060\003\065\001\060\001\047\005\187\005\055\001\189\005\065\001\ -\014\001\019\001\068\001\017\001\070\001\000\001\101\001\065\001\ -\022\001\047\001\100\003\014\001\022\004\027\001\065\001\014\001\ -\064\001\065\001\006\003\014\001\066\001\000\001\017\001\102\003\ -\027\001\004\001\237\002\022\001\027\001\008\001\094\001\014\001\ -\027\001\047\001\102\003\014\001\015\001\109\001\128\003\018\001\ -\092\005\131\003\004\001\133\003\102\003\111\001\008\001\102\003\ -\106\001\067\001\003\001\109\001\047\001\107\003\144\003\102\003\ -\018\001\177\004\148\003\097\001\098\001\070\003\064\001\101\005\ -\066\001\155\003\102\003\027\001\102\003\159\003\102\003\000\001\ -\126\003\102\003\083\003\015\001\079\001\091\001\018\001\117\005\ -\079\001\095\001\065\001\097\001\098\001\123\005\088\001\066\001\ -\066\006\067\006\047\001\181\003\196\001\064\001\184\003\215\004\ -\091\001\035\001\188\003\003\001\095\001\115\001\097\001\098\001\ -\066\001\225\004\066\001\110\004\064\001\065\001\112\001\073\001\ -\110\004\000\001\069\003\094\001\022\001\221\001\222\001\223\001\ -\115\001\059\001\125\004\213\003\022\001\229\001\066\001\065\001\ -\030\001\139\004\092\001\022\001\019\001\004\001\082\004\064\001\ -\065\001\008\001\109\001\026\001\097\001\098\001\014\001\014\001\ -\015\001\090\001\124\006\018\001\066\001\067\001\240\003\241\003\ -\096\001\055\001\110\001\073\001\000\001\005\002\115\001\065\001\ -\250\003\048\001\252\003\065\001\102\001\110\001\176\004\205\005\ -\206\005\067\001\022\001\109\001\000\001\060\001\065\001\096\001\ -\004\001\215\005\012\004\014\001\008\001\068\001\010\001\070\001\ -\035\001\033\002\014\001\015\001\197\003\198\003\018\001\035\001\ -\027\001\065\001\066\001\066\001\027\001\115\001\116\004\027\001\ -\203\004\035\001\211\003\212\003\106\001\203\004\216\004\109\001\ -\059\001\218\003\132\005\009\004\060\002\065\001\065\001\059\001\ -\000\001\051\004\227\003\053\004\064\001\065\001\000\001\094\001\ -\111\001\059\001\008\006\061\004\000\001\091\001\074\001\065\001\ -\004\001\095\001\030\001\066\001\008\001\071\004\066\001\000\000\ -\066\001\019\001\026\001\015\001\079\001\073\001\018\001\073\001\ -\026\001\220\004\084\004\102\001\055\001\000\001\209\003\099\001\ -\064\001\065\001\109\001\055\001\094\001\064\001\217\003\091\001\ -\092\001\109\001\094\001\095\001\102\001\065\001\048\001\049\001\ -\064\001\014\001\229\003\109\001\058\006\111\001\005\000\077\004\ -\007\000\028\005\060\001\075\001\008\001\113\001\027\001\065\001\ -\035\001\115\001\068\001\244\004\070\001\248\003\066\001\000\001\ -\031\001\064\001\027\001\023\001\059\005\109\001\112\004\035\003\ -\244\004\116\005\030\001\105\004\142\004\112\001\106\001\145\004\ -\059\001\109\001\073\005\050\001\127\005\064\001\065\001\051\003\ -\112\001\026\001\094\001\055\003\065\001\000\001\244\004\074\001\ -\162\004\053\001\164\004\055\001\166\004\111\001\168\004\169\004\ -\064\001\066\001\055\001\173\004\099\005\065\001\109\001\191\002\ -\178\004\008\001\180\004\064\001\182\004\004\001\184\004\026\001\ -\099\001\008\001\086\003\064\001\065\001\004\001\206\002\207\002\ -\023\001\008\001\109\001\018\001\061\005\022\001\200\004\030\001\ -\015\001\097\001\123\004\018\001\027\001\064\001\127\004\066\001\ -\108\004\061\005\125\005\132\004\027\001\109\001\106\001\125\005\ -\075\001\109\001\014\001\066\001\222\004\017\001\053\001\014\001\ -\055\001\227\004\242\002\112\001\149\004\150\004\145\005\061\005\ -\030\001\235\004\065\001\145\005\053\001\158\004\055\001\056\001\ -\065\001\136\000\169\005\066\001\139\000\247\004\141\000\142\000\ -\065\001\027\001\252\004\066\001\050\001\112\001\000\005\106\006\ -\002\005\066\001\004\005\126\004\181\004\007\005\109\001\130\004\ -\191\005\000\001\064\001\065\001\000\001\164\000\165\000\008\001\ -\167\000\065\001\083\001\106\001\022\005\064\001\109\001\064\001\ -\026\005\073\001\177\000\178\000\019\001\031\005\004\001\019\001\ -\066\001\235\005\008\001\026\001\109\001\008\005\026\001\210\005\ -\035\001\015\001\027\001\108\001\210\005\047\005\048\005\101\001\ -\050\005\028\001\201\000\202\000\106\001\027\001\205\000\109\001\ -\179\004\048\001\049\001\088\001\048\001\232\005\014\001\065\005\ -\059\001\066\001\232\005\190\004\109\001\060\001\065\001\000\001\ -\060\001\100\001\003\001\027\001\212\005\068\001\000\000\070\001\ -\068\001\066\001\070\001\112\001\013\001\014\001\027\001\066\001\ -\017\001\091\005\092\005\027\001\066\001\094\001\022\001\074\001\ -\098\005\026\001\027\001\028\001\029\001\080\001\000\001\003\005\ -\083\001\045\001\046\001\102\001\029\005\064\001\112\005\040\001\ -\041\001\065\001\109\001\066\001\111\001\035\001\003\001\047\001\ -\111\001\019\001\043\005\111\001\045\005\066\001\128\005\037\001\ -\026\001\145\003\066\001\060\001\083\001\088\001\063\001\022\001\ -\065\001\066\001\067\001\068\001\064\001\059\001\144\005\083\001\ -\073\001\074\001\064\001\065\001\064\001\151\005\048\001\080\001\ -\052\005\000\001\064\001\040\001\074\001\112\001\109\001\161\005\ -\100\001\132\005\060\001\092\001\166\005\094\001\000\001\096\001\ -\097\001\067\001\068\001\236\003\070\001\035\001\041\005\000\001\ -\066\001\155\005\180\005\108\001\158\005\099\001\111\001\199\003\ -\023\001\109\001\115\001\018\001\064\001\066\001\037\001\109\001\ -\026\001\109\001\019\001\004\004\063\005\059\001\200\005\075\001\ -\000\001\026\001\064\001\065\001\094\001\207\005\064\001\000\001\ -\224\003\225\003\226\003\213\005\074\001\111\001\230\003\136\005\ -\218\005\219\005\000\001\019\001\236\003\121\005\224\005\048\001\ -\049\001\227\005\026\001\027\001\010\001\053\001\130\005\055\001\ -\000\000\026\001\236\005\060\001\112\001\099\001\240\005\134\001\ -\064\001\065\001\244\005\068\001\004\004\070\001\064\001\109\001\ -\048\001\049\001\004\001\109\001\230\005\231\005\008\001\233\005\ -\234\005\022\001\000\001\003\001\060\001\015\001\157\001\009\006\ -\018\001\064\001\112\001\067\001\068\001\164\001\070\001\166\001\ -\090\001\027\001\064\001\040\001\143\005\012\006\173\001\174\001\ -\064\001\176\001\149\005\064\001\065\001\109\001\111\001\022\001\ -\012\006\000\001\071\001\109\001\110\001\188\001\035\001\037\001\ -\040\001\192\001\044\006\045\006\167\005\196\001\197\001\084\001\ -\225\005\051\006\052\006\053\006\054\006\090\001\109\001\111\001\ -\066\001\059\006\033\001\026\001\075\001\063\006\059\001\109\001\ -\110\001\022\001\016\001\069\006\065\001\109\001\221\001\222\001\ -\223\001\110\001\000\000\077\006\078\006\027\001\229\001\202\005\ -\055\001\004\001\037\001\040\001\059\001\008\001\064\001\095\001\ -\063\001\064\001\065\001\066\001\015\001\095\006\096\006\018\001\ -\076\000\112\001\100\006\064\001\102\006\252\001\253\001\078\001\ -\025\006\102\001\001\002\085\006\110\006\064\001\005\002\113\006\ -\109\001\008\002\035\006\015\006\064\001\022\001\053\001\097\001\ -\055\001\123\006\017\002\018\002\064\001\127\006\027\001\105\006\ -\108\000\064\001\065\001\109\001\134\006\135\006\109\001\040\001\ -\033\001\032\002\033\002\064\001\064\001\119\006\120\006\066\001\ -\109\001\125\000\000\000\042\002\095\001\000\001\064\001\065\001\ -\132\000\048\002\075\006\000\001\064\001\071\001\055\001\095\001\ -\066\001\109\001\059\001\013\001\031\006\060\002\063\001\064\001\ -\065\001\109\001\084\001\000\001\093\006\066\001\109\001\042\006\ -\090\001\083\001\028\001\029\001\073\001\078\001\064\001\091\001\ -\109\001\109\001\037\001\016\002\088\006\022\001\019\001\041\001\ -\037\001\075\001\023\002\109\001\110\001\026\001\027\001\066\006\ -\067\006\094\001\108\001\066\001\000\000\072\006\073\006\128\006\ -\103\002\091\001\060\001\000\001\109\001\063\001\047\001\082\006\ -\079\001\040\001\068\001\048\001\049\001\022\001\115\001\000\001\ -\074\001\055\001\000\001\094\006\066\001\059\001\080\001\060\001\ -\000\001\063\001\064\001\130\002\004\001\026\001\067\001\068\001\ -\008\001\070\001\010\001\066\001\111\006\083\001\014\001\015\001\ -\078\001\026\001\018\001\094\001\026\001\000\000\121\006\094\001\ -\090\001\124\006\108\001\027\001\000\001\111\001\093\001\130\006\ -\131\006\160\002\109\001\110\001\163\002\053\001\054\001\055\001\ -\056\001\031\001\169\002\170\002\110\001\172\002\173\002\109\001\ -\064\001\065\001\111\001\000\001\093\001\055\001\026\001\000\001\ -\033\001\059\001\066\001\186\002\050\001\063\001\064\001\077\001\ -\191\002\010\001\066\001\004\001\109\001\196\002\019\001\008\001\ -\080\001\073\001\094\001\083\001\078\001\026\001\055\001\206\002\ -\207\002\018\001\059\001\071\001\064\001\065\001\063\001\064\001\ -\065\001\109\001\027\001\091\001\092\001\109\001\094\001\095\001\ -\084\001\065\001\000\001\048\001\049\001\078\001\004\001\230\002\ -\093\001\232\002\008\001\109\001\010\001\003\001\237\002\060\001\ -\014\001\113\001\093\001\242\002\018\001\073\001\067\001\068\001\ -\109\001\070\001\064\001\250\002\251\002\027\001\253\002\000\000\ -\009\000\065\001\109\001\012\000\109\001\014\000\015\000\016\000\ -\007\003\073\001\019\000\020\000\021\000\022\000\023\000\004\001\ -\025\000\064\001\065\001\008\001\014\001\065\001\066\001\017\001\ -\004\001\014\001\015\001\036\000\008\001\018\001\039\000\040\000\ -\041\000\027\001\111\001\064\001\066\001\092\001\018\001\038\003\ -\049\000\050\000\000\001\073\001\053\000\054\000\004\001\027\001\ -\066\001\008\001\008\001\014\001\010\001\052\003\053\003\073\001\ -\014\001\015\001\095\001\004\001\065\001\091\001\092\001\008\001\ -\094\001\095\001\071\001\016\001\152\001\027\001\069\003\000\001\ -\036\001\022\001\000\000\000\001\094\001\066\001\027\001\084\001\ -\073\001\010\001\027\001\113\001\014\001\094\000\095\000\096\000\ -\097\000\022\001\099\000\090\001\000\000\109\001\019\001\004\001\ -\014\001\115\001\022\001\008\001\000\001\026\001\000\001\003\001\ -\103\003\095\001\015\001\095\001\066\001\018\001\109\003\055\001\ -\010\001\013\001\092\001\073\001\103\001\017\001\027\001\118\003\ -\066\001\067\001\121\003\048\001\049\001\014\001\026\001\027\001\ -\028\001\029\001\022\001\130\003\027\001\091\001\092\001\060\001\ -\094\001\095\001\064\001\065\001\139\003\041\001\067\001\068\001\ -\092\001\070\001\145\003\173\001\174\001\000\001\092\001\091\001\ -\161\000\162\000\109\001\113\001\092\001\066\001\092\001\053\001\ -\060\001\055\001\013\001\063\001\255\001\000\002\017\001\067\001\ -\068\001\014\001\109\001\065\001\094\001\172\003\074\001\026\001\ -\027\001\028\001\029\001\094\001\080\001\053\001\010\002\055\001\ -\115\001\020\001\111\001\053\001\197\000\055\001\041\001\004\001\ -\092\001\065\001\094\001\008\001\096\001\097\001\109\001\065\001\ -\199\003\053\001\015\001\055\001\046\001\018\001\205\003\115\001\ -\108\001\060\001\209\003\111\001\063\001\065\001\062\001\066\001\ -\067\001\068\001\217\003\109\001\219\003\220\003\073\001\074\001\ -\108\001\224\003\225\003\226\003\109\001\080\001\229\003\230\003\ -\053\001\109\001\055\001\234\003\022\001\236\003\237\003\002\001\ -\073\001\092\001\100\001\094\001\065\001\096\001\097\001\013\001\ -\000\000\248\003\065\001\066\001\067\001\066\001\073\001\000\001\ -\027\001\108\001\003\001\109\001\111\001\004\004\028\001\029\001\ -\115\001\015\001\092\001\064\001\013\001\022\001\023\001\094\001\ -\017\001\000\001\064\001\041\001\064\001\022\001\008\001\022\004\ -\065\001\026\001\027\001\028\001\029\001\109\001\040\001\018\001\ -\014\001\062\001\062\001\044\001\062\001\007\000\060\001\027\001\ -\041\001\000\000\092\001\094\001\064\001\079\001\068\001\064\001\ -\014\001\058\001\134\002\014\001\074\001\006\001\063\001\094\001\ -\026\000\073\001\080\001\060\001\109\001\060\004\063\001\095\001\ -\065\001\066\001\067\001\068\001\067\004\064\001\075\001\073\001\ -\073\001\074\001\096\001\090\001\022\001\076\004\092\001\080\001\ -\027\001\094\001\014\001\082\004\073\001\040\001\108\001\013\001\ -\087\004\111\001\094\001\092\001\000\001\094\001\027\001\096\001\ -\097\001\014\001\027\001\021\001\008\001\086\001\028\001\029\001\ -\064\001\013\001\064\001\108\001\107\004\108\004\111\001\110\004\ -\062\001\062\001\115\001\041\001\014\001\116\004\026\001\062\001\ -\028\001\029\001\062\001\062\001\062\001\003\001\125\004\126\004\ -\014\001\086\001\064\001\130\004\027\001\041\001\060\001\091\001\ -\095\001\063\001\073\001\101\001\139\004\014\001\068\001\094\001\ -\027\001\027\001\094\001\014\001\074\001\094\001\000\000\088\001\ -\060\001\094\001\080\001\063\001\080\001\064\001\066\001\067\001\ -\068\001\027\001\073\001\014\001\020\001\015\001\074\001\022\001\ -\177\001\094\001\096\001\097\001\080\001\053\001\008\001\145\000\ -\065\001\176\004\177\004\073\001\179\004\062\001\108\001\062\001\ -\092\001\111\001\062\001\014\001\096\001\097\001\094\001\190\004\ -\112\001\163\000\164\000\165\000\112\001\167\000\094\001\073\001\ -\108\001\210\001\021\001\111\001\203\004\064\001\091\001\177\000\ -\178\000\037\003\073\001\053\001\054\001\055\001\056\001\214\004\ -\215\004\216\004\000\001\088\001\095\001\014\001\064\001\065\001\ -\094\001\014\001\225\004\014\001\056\003\014\001\229\004\201\000\ -\202\000\061\003\091\001\205\000\027\001\019\001\019\001\027\001\ -\112\001\088\001\241\004\022\001\026\001\244\004\014\001\014\001\ -\000\001\248\004\014\001\003\001\014\001\000\000\000\000\096\001\ -\084\003\096\001\001\005\092\001\003\005\013\001\008\001\109\001\ -\109\001\017\001\048\001\109\001\064\001\092\001\022\001\036\001\ -\090\001\036\001\026\001\027\001\028\001\029\001\060\001\036\001\ -\092\001\065\001\040\001\065\001\112\003\028\005\068\001\040\002\ -\070\001\041\001\033\005\034\005\064\001\094\001\036\001\064\001\ -\091\001\000\001\041\005\053\001\003\001\001\000\002\000\003\000\ -\004\000\005\000\006\000\007\000\060\001\052\005\013\001\063\001\ -\053\001\065\001\066\001\067\001\068\001\064\001\061\005\062\005\ -\063\005\073\001\074\001\026\001\064\001\028\001\029\001\064\001\ -\080\001\111\001\064\001\074\005\064\001\064\001\077\005\127\000\ -\099\003\040\001\041\001\210\005\092\001\000\000\094\001\008\005\ -\096\001\097\001\060\001\129\005\082\006\199\005\072\002\248\002\ -\190\003\145\001\145\005\183\003\108\001\060\001\101\005\111\001\ -\063\001\122\001\103\002\115\001\067\001\068\001\109\005\199\003\ -\230\001\165\000\190\002\074\001\064\001\065\001\117\005\018\005\ -\027\004\080\001\121\005\071\001\123\005\137\001\125\005\226\001\ -\103\004\077\001\232\002\130\005\188\001\092\001\133\005\133\005\ -\084\001\096\001\097\001\099\005\171\005\221\004\090\001\255\255\ -\143\005\115\001\145\005\255\255\255\255\108\001\149\005\255\255\ -\111\001\255\255\238\003\239\003\255\255\255\255\255\255\255\255\ -\255\255\109\001\110\001\013\001\255\255\255\255\255\255\255\255\ -\167\005\255\255\255\255\255\003\255\255\255\255\255\255\145\001\ -\255\255\255\255\028\001\029\001\255\255\255\255\255\255\255\255\ -\012\004\255\255\255\255\255\255\187\005\255\255\189\005\041\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\028\004\255\255\255\255\202\005\255\255\255\255\205\005\206\005\ -\255\255\000\001\060\001\210\005\255\255\063\001\255\255\255\255\ -\215\005\255\255\068\001\255\255\255\255\255\255\221\005\193\001\ -\074\001\255\255\196\001\197\001\019\001\255\255\080\001\255\255\ -\255\255\232\005\062\004\026\001\000\001\255\255\000\000\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\096\001\097\001\ -\255\255\255\255\255\255\221\001\222\001\223\001\255\255\019\001\ -\255\255\048\001\108\001\229\001\255\255\111\001\026\001\255\255\ -\255\255\008\006\236\001\255\255\255\255\060\001\255\255\255\255\ -\015\006\255\255\007\000\255\255\067\001\068\001\011\000\070\001\ -\255\255\109\004\252\001\253\001\048\001\049\001\255\255\001\002\ -\031\006\255\255\118\004\005\002\255\255\026\000\008\002\255\255\ -\060\001\255\255\255\255\042\006\255\255\255\255\016\002\067\001\ -\068\001\255\255\070\001\255\255\255\255\023\002\255\255\255\255\ -\045\000\255\255\255\255\058\006\255\255\255\255\255\255\033\002\ -\111\001\255\255\255\255\066\006\067\006\255\255\255\255\080\003\ -\042\002\072\006\073\006\255\255\255\255\255\255\048\002\255\255\ -\255\255\255\255\081\006\082\006\083\006\000\001\255\255\255\255\ -\003\001\088\006\060\002\111\001\255\255\063\002\083\000\094\006\ -\085\000\086\000\013\001\183\004\255\255\185\004\072\002\255\255\ -\019\001\000\001\255\255\255\255\255\255\255\255\255\255\026\001\ -\111\006\028\001\029\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\121\006\255\255\255\255\124\006\041\001\255\255\ -\255\255\255\255\255\255\130\006\131\006\103\002\255\255\255\255\ -\255\255\255\255\222\004\255\255\255\255\255\255\255\255\227\004\ -\255\255\060\001\255\255\255\255\063\001\255\255\000\000\255\255\ -\067\001\068\001\255\255\255\255\255\255\255\255\255\255\074\001\ -\055\001\255\255\057\001\058\001\059\001\080\001\061\001\255\255\ -\255\255\064\001\065\001\086\001\255\255\255\255\255\255\164\000\ -\165\000\092\001\167\000\255\255\255\255\096\001\097\001\255\255\ -\255\255\255\255\081\001\255\255\177\000\178\000\255\255\019\005\ -\255\255\108\001\089\001\090\001\111\001\255\255\255\255\255\255\ -\189\000\255\255\097\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\201\000\202\000\109\001\110\001\ -\255\255\206\000\255\255\255\255\190\002\191\002\255\255\051\005\ -\255\255\053\005\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\206\002\207\002\000\001\255\255\ -\002\001\003\001\004\001\071\005\255\255\255\255\008\001\075\005\ -\076\005\255\255\255\255\013\001\255\255\255\255\255\255\017\001\ -\018\001\019\001\255\255\255\255\255\255\231\002\090\005\255\255\ -\026\001\027\001\028\001\029\001\255\255\255\255\255\255\255\255\ -\242\002\255\255\036\001\255\255\000\000\255\255\255\255\041\001\ -\255\255\251\002\255\255\253\002\112\005\255\255\048\001\049\001\ -\255\255\255\255\255\255\255\255\255\255\007\003\255\255\255\255\ -\029\001\255\255\060\001\255\255\255\255\063\001\064\001\255\255\ -\066\001\067\001\068\001\255\255\070\001\255\255\255\255\073\001\ -\074\001\255\255\255\255\255\255\255\255\050\001\080\001\255\255\ -\255\255\255\255\036\003\255\255\038\003\255\255\255\255\255\255\ -\255\255\091\001\092\001\255\255\094\001\095\001\096\001\097\001\ -\255\255\255\255\100\001\053\003\255\255\255\255\255\255\171\005\ -\255\255\000\001\108\001\109\001\000\000\111\001\255\255\255\255\ -\180\005\115\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\019\001\193\005\255\255\255\255\ -\196\005\255\255\255\255\026\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\000\001\007\000\255\255\ -\117\001\118\001\255\255\255\255\121\001\255\255\123\001\255\255\ -\255\255\048\001\049\001\255\255\110\003\255\255\255\255\255\255\ -\019\001\229\005\255\255\255\255\000\000\060\001\000\001\026\001\ -\002\001\003\001\004\001\255\255\067\001\068\001\008\001\070\001\ -\255\255\255\255\255\255\013\001\134\003\255\255\255\255\017\001\ -\018\001\019\001\255\255\255\255\255\255\048\001\255\255\145\003\ -\026\001\027\001\028\001\029\001\255\255\255\255\255\255\255\255\ -\255\255\060\001\036\001\255\255\255\255\255\255\255\255\041\001\ -\067\001\068\001\255\255\070\001\255\255\255\255\048\001\049\001\ -\111\001\255\255\172\003\255\255\255\255\255\255\255\255\196\001\ -\197\001\255\255\060\001\255\255\255\255\063\001\255\255\255\255\ -\066\001\067\001\068\001\255\255\070\001\255\255\255\255\073\001\ -\074\001\255\255\255\255\055\006\255\255\199\003\080\001\255\255\ -\221\001\222\001\223\001\255\255\111\001\255\255\255\255\255\255\ -\229\001\091\001\092\001\255\255\094\001\095\001\096\001\097\001\ -\255\255\219\003\220\003\255\255\255\255\255\255\224\003\225\003\ -\226\003\255\255\108\001\255\255\230\003\111\001\255\255\252\001\ -\253\001\115\001\236\003\255\255\001\002\255\255\255\255\255\255\ -\005\002\101\006\102\006\255\255\000\001\255\255\255\255\255\255\ -\255\255\109\006\255\255\164\000\165\000\255\255\167\000\255\255\ -\255\255\013\001\004\004\255\255\255\255\255\255\255\255\255\255\ -\177\000\178\000\255\255\255\255\033\002\129\006\026\001\255\255\ -\028\001\029\001\255\255\255\255\022\004\042\002\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\041\001\255\255\200\000\ -\201\000\202\000\007\000\255\255\255\255\255\255\011\000\060\002\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\060\001\255\255\255\255\072\002\054\004\026\000\066\001\067\001\ -\068\001\255\255\255\255\255\255\000\001\255\255\074\001\003\001\ -\255\255\255\255\255\255\255\255\080\001\255\255\255\255\255\255\ -\045\000\013\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\092\001\255\255\103\002\255\255\096\001\255\255\026\001\027\001\ -\028\001\029\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\108\001\255\255\255\255\111\001\255\255\041\001\255\255\255\255\ -\255\255\000\000\108\004\255\255\110\004\255\255\083\000\255\255\ -\085\000\086\000\255\255\255\255\000\001\255\255\255\255\003\001\ -\060\001\255\255\255\255\125\004\008\001\255\255\255\255\067\001\ -\068\001\013\001\014\001\255\255\255\255\255\255\074\001\019\001\ -\255\255\139\004\022\001\255\255\080\001\255\255\026\001\007\000\ -\028\001\029\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\092\001\255\255\094\001\068\001\096\001\041\001\255\255\255\255\ -\255\255\255\255\255\255\136\000\077\001\255\255\255\255\255\255\ -\108\001\255\255\191\002\111\001\255\255\255\255\176\004\255\255\ -\060\001\255\255\255\255\063\001\255\255\065\001\066\001\067\001\ -\068\001\206\002\207\002\006\001\255\255\008\001\074\001\164\000\ -\165\000\255\255\167\000\079\001\080\001\255\255\255\255\255\255\ -\255\255\203\004\255\255\255\255\177\000\178\000\255\255\255\255\ -\092\001\255\255\231\002\255\255\096\001\097\001\216\004\255\255\ -\189\000\255\255\220\004\255\255\255\255\242\002\255\255\255\255\ -\108\001\255\255\255\255\111\001\201\000\202\000\251\002\255\255\ -\253\002\206\000\255\255\255\255\055\001\255\255\057\001\058\001\ -\059\001\255\255\061\001\255\255\255\255\064\001\065\001\255\255\ -\255\255\255\255\255\255\000\001\255\255\255\255\255\255\255\255\ -\255\255\003\005\255\255\255\255\255\255\255\255\081\001\255\255\ -\013\001\255\255\255\255\255\255\255\255\006\001\089\001\090\001\ -\255\255\038\003\255\255\255\255\000\000\026\001\097\001\028\001\ -\029\001\255\255\028\005\196\001\197\001\255\255\255\255\255\255\ -\255\255\255\255\109\001\110\001\041\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\164\000\165\000\255\255\167\000\ -\255\255\255\255\052\005\220\001\221\001\222\001\223\001\060\001\ -\029\001\177\000\178\000\255\255\229\001\255\255\055\001\068\001\ -\057\001\058\001\059\001\255\255\061\001\074\001\015\001\064\001\ -\065\001\255\255\255\255\080\001\255\255\050\001\255\255\255\255\ -\255\255\201\000\202\000\252\001\253\001\255\255\255\255\255\255\ -\001\002\255\255\255\255\096\001\005\002\028\000\029\000\255\255\ -\255\255\090\001\043\001\044\001\045\001\046\001\015\002\108\001\ -\097\001\000\001\111\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\008\001\255\255\255\255\109\001\110\001\013\001\121\005\ -\033\002\066\001\255\255\125\005\145\003\255\255\071\001\072\001\ -\130\005\042\002\255\255\026\001\255\255\028\001\029\001\255\255\ -\255\255\255\255\083\001\084\001\085\001\086\001\255\255\145\005\ -\117\001\118\001\041\001\060\002\121\001\255\255\123\001\172\003\ -\087\000\088\000\255\255\100\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\060\001\255\255\255\255\ -\063\001\255\255\255\255\066\001\067\001\068\001\255\255\255\255\ -\255\255\255\255\199\003\074\001\255\255\255\255\255\255\255\255\ -\157\001\080\001\000\000\255\255\000\000\255\255\103\002\164\001\ -\255\255\166\001\255\255\255\255\255\255\092\001\219\003\220\003\ -\255\255\096\001\097\001\224\003\225\003\226\003\255\255\255\255\ -\210\005\230\003\212\005\255\255\255\255\108\001\255\255\236\003\ -\111\001\255\255\255\255\255\255\255\255\255\255\255\255\196\001\ -\197\001\255\255\255\255\255\255\255\255\255\255\232\005\255\255\ -\023\001\255\255\255\255\255\255\255\255\255\255\255\255\004\004\ -\134\001\243\005\255\255\255\255\255\255\036\001\255\255\255\255\ -\221\001\222\001\223\001\255\255\015\001\255\255\255\255\255\255\ -\229\001\255\255\255\255\255\255\255\255\007\006\255\255\255\255\ -\055\001\255\255\057\001\058\001\059\001\015\006\061\001\255\255\ -\018\006\064\001\065\001\255\255\000\001\255\255\191\002\252\001\ -\253\001\044\001\045\001\046\001\001\002\255\255\255\255\255\255\ -\005\002\013\001\255\255\255\255\255\255\206\002\207\002\255\255\ -\190\001\043\006\255\255\090\001\255\255\255\255\026\001\255\255\ -\028\001\029\001\097\001\255\255\071\001\072\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\033\002\041\001\109\001\110\001\ -\083\001\084\001\085\001\086\001\255\255\042\002\255\255\255\255\ -\255\255\242\002\255\255\255\255\196\001\197\001\255\255\255\255\ -\060\001\100\001\251\002\063\001\253\002\255\255\088\006\060\002\ -\068\001\110\004\255\255\255\255\255\255\255\255\074\001\255\255\ -\255\255\255\255\255\255\072\002\080\001\221\001\222\001\223\001\ -\125\004\255\255\255\255\255\255\255\255\229\001\230\001\255\255\ -\092\001\255\255\255\255\255\255\096\001\097\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\038\003\255\255\255\255\ -\108\001\255\255\103\002\111\001\252\001\253\001\255\255\255\255\ -\255\255\001\002\255\255\255\255\255\255\005\002\255\255\078\001\ -\079\001\080\001\081\001\082\001\083\001\084\001\085\001\086\001\ -\087\001\088\001\089\001\090\001\091\001\092\001\093\001\094\001\ -\095\001\096\001\097\001\098\001\000\000\100\001\255\255\255\255\ -\102\001\033\002\255\255\105\001\255\255\107\001\255\255\109\001\ -\255\255\111\001\042\002\114\001\255\255\255\255\203\004\255\255\ -\255\255\255\255\255\255\160\002\255\255\255\255\255\255\255\255\ -\127\001\255\255\255\255\255\255\060\002\255\255\255\255\013\001\ -\255\255\013\001\255\255\116\003\255\255\255\255\255\255\141\001\ -\255\255\143\001\255\255\255\255\255\255\255\255\028\001\029\001\ -\028\001\029\001\191\002\255\255\255\255\255\255\255\255\255\255\ -\255\255\159\001\255\255\041\001\255\255\041\001\255\255\255\255\ -\145\003\206\002\207\002\255\255\130\002\255\255\255\255\103\002\ -\255\255\000\000\255\255\008\005\255\255\255\255\060\001\255\255\ -\060\001\063\001\255\255\063\001\255\255\255\255\068\001\255\255\ -\068\001\255\255\255\255\172\003\074\001\255\255\074\001\028\005\ -\255\255\255\255\080\001\006\001\080\001\242\002\255\255\255\255\ -\255\255\255\255\255\255\169\002\255\255\255\255\251\002\255\255\ -\253\002\255\255\096\001\097\001\096\001\097\001\199\003\255\255\ -\255\255\255\255\015\001\255\255\255\255\255\255\108\001\255\255\ -\108\001\111\001\232\001\111\001\234\001\255\255\255\255\255\255\ -\255\255\255\255\219\003\220\003\255\255\255\255\223\003\224\003\ -\225\003\226\003\255\255\255\255\055\001\230\003\057\001\058\001\ -\059\001\038\003\061\001\236\003\255\255\064\001\065\001\191\002\ -\255\255\007\002\055\001\009\002\057\001\058\001\059\001\255\255\ -\061\001\255\255\255\255\064\001\065\001\255\255\206\002\207\002\ -\255\255\024\002\255\255\004\004\255\255\074\001\029\002\090\001\ -\255\255\255\255\255\255\255\255\081\001\255\255\097\001\255\255\ -\125\005\255\255\255\255\255\255\089\001\090\001\255\255\132\005\ -\255\255\094\001\109\001\110\001\097\001\255\255\255\255\255\255\ -\255\255\255\255\242\002\255\255\145\005\255\255\255\255\255\255\ -\109\001\110\001\255\255\251\002\255\255\253\002\255\255\255\255\ -\255\255\255\255\255\255\074\002\075\002\255\255\255\255\255\255\ -\255\255\118\003\255\255\255\255\255\255\255\255\123\003\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\052\003\255\255\ -\255\255\000\000\255\255\255\255\000\001\255\255\255\255\003\001\ -\255\255\255\255\255\255\255\255\145\003\255\255\038\003\110\002\ -\255\255\013\001\255\255\255\255\115\002\116\002\117\002\255\255\ -\255\255\255\255\255\255\255\255\255\255\210\005\026\001\027\001\ -\028\001\029\001\255\255\129\002\255\255\110\004\132\002\172\003\ -\255\255\255\255\255\255\255\255\255\255\041\001\255\255\255\255\ -\255\255\103\003\255\255\232\005\125\004\255\255\255\255\109\003\ -\255\255\255\255\255\255\255\255\255\255\255\255\243\005\255\255\ -\060\001\255\255\199\003\255\255\064\001\255\255\066\001\067\001\ -\068\001\255\255\255\255\255\255\255\255\073\001\074\001\255\255\ -\255\255\000\001\255\255\255\255\080\001\255\255\219\003\220\003\ -\255\255\255\255\255\255\224\003\225\003\226\003\013\001\255\255\ -\092\001\230\003\094\001\255\255\096\001\097\001\255\255\236\003\ -\100\001\255\255\255\255\026\001\255\255\028\001\029\001\255\255\ -\108\001\109\001\000\000\111\001\255\255\255\255\043\006\214\002\ -\255\255\145\003\041\001\255\255\219\002\220\002\221\002\004\004\ -\255\255\000\001\203\004\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\233\002\255\255\060\001\255\255\255\255\ -\063\001\255\255\255\255\255\255\172\003\068\001\255\255\205\003\ -\255\255\255\255\255\255\074\001\255\255\255\255\255\255\255\255\ -\255\255\080\001\255\255\002\003\255\255\255\255\004\003\255\255\ -\255\255\255\255\255\255\255\255\255\255\092\001\255\255\199\003\ -\255\255\096\001\097\001\018\003\234\003\255\255\255\255\237\003\ -\055\001\255\255\057\001\058\001\059\001\108\001\061\001\255\255\ -\111\001\064\001\065\001\219\003\220\003\074\004\255\255\255\255\ -\224\003\225\003\226\003\255\255\255\255\255\255\230\003\255\255\ -\255\255\255\255\081\001\028\005\236\003\255\255\255\255\255\255\ -\255\255\255\255\089\001\090\001\255\255\255\255\255\255\255\255\ -\000\000\255\255\097\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\110\004\255\255\255\255\004\004\108\001\109\001\110\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\125\004\255\255\255\255\255\255\255\255\255\255\255\255\094\003\ -\255\255\000\001\001\001\002\001\003\001\255\255\060\004\255\255\ -\255\255\008\001\009\001\010\001\255\255\067\004\013\001\014\001\ -\255\255\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ -\255\255\024\001\025\001\026\001\027\001\028\001\029\001\255\255\ -\255\255\087\004\128\003\255\255\255\255\036\001\037\001\255\255\ -\255\255\040\001\041\001\042\001\043\001\255\255\000\000\255\255\ -\255\255\048\001\049\001\255\255\125\005\107\004\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\060\001\061\001\255\255\ -\063\001\255\255\255\255\066\001\067\001\068\001\203\004\070\001\ -\145\005\255\255\073\001\074\001\255\255\255\255\255\255\255\255\ -\255\255\080\001\255\255\082\001\255\255\255\255\110\004\181\003\ -\255\255\255\255\255\255\255\255\091\001\092\001\255\255\094\001\ -\095\001\096\001\097\001\255\255\255\255\125\004\255\255\255\255\ -\103\001\255\255\105\001\255\255\203\003\108\001\255\255\244\004\ -\111\001\255\255\000\001\255\255\115\001\003\001\255\255\213\003\ -\255\255\255\255\008\001\177\004\255\255\255\255\255\255\013\001\ -\255\255\255\255\255\255\008\005\255\255\019\001\023\001\255\255\ -\255\255\210\005\255\255\255\255\026\001\255\255\028\001\029\001\ -\255\255\255\255\255\255\036\001\255\255\255\255\255\255\028\005\ -\255\255\255\255\255\255\041\001\250\003\255\255\252\003\232\005\ -\214\004\215\004\255\255\255\255\255\255\255\255\055\001\255\255\ -\057\001\058\001\059\001\225\004\061\001\255\255\060\001\064\001\ -\065\001\063\001\255\255\203\004\066\001\067\001\068\001\255\255\ -\061\005\255\255\255\255\241\004\074\001\255\255\255\255\255\255\ -\255\255\255\255\080\001\255\255\255\255\255\255\037\004\038\004\ -\039\004\090\001\255\255\255\255\000\000\255\255\092\001\255\255\ -\097\001\255\255\096\001\097\001\255\255\051\004\255\255\255\255\ -\255\255\255\255\255\255\255\255\109\001\110\001\108\001\255\255\ -\000\001\111\001\255\255\003\001\255\255\255\255\255\255\255\255\ -\255\255\071\004\255\255\033\005\034\005\013\001\014\001\255\255\ -\255\255\017\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\125\005\255\255\026\001\027\001\028\001\029\001\255\255\132\005\ -\255\255\096\004\097\004\098\004\028\005\255\255\255\255\255\255\ -\040\001\041\001\255\255\255\255\145\005\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\074\005\255\255\255\255\077\005\ -\255\255\255\255\255\255\255\255\060\001\255\255\255\255\063\001\ -\255\255\255\255\255\255\067\001\068\001\255\255\255\255\093\005\ -\094\005\073\001\074\001\138\004\255\255\255\255\000\001\101\005\ -\080\001\003\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\013\001\092\001\255\255\094\001\017\001\ -\096\001\097\001\255\255\255\255\255\255\123\005\255\255\255\255\ -\026\001\027\001\028\001\029\001\108\001\210\005\255\255\111\001\ -\255\255\000\000\255\255\115\001\255\255\255\255\180\004\041\001\ -\182\004\255\255\184\004\000\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\232\005\255\255\125\005\255\255\255\255\ -\255\255\255\255\060\001\255\255\255\255\063\001\205\004\206\004\ -\207\004\067\001\068\001\255\255\211\004\212\004\213\004\255\255\ -\074\001\145\005\255\255\255\255\255\255\255\255\080\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\092\001\255\255\094\001\235\004\096\001\097\001\ -\255\255\199\005\055\001\255\255\057\001\058\001\059\001\205\005\ -\061\001\247\004\108\001\064\001\065\001\111\001\255\255\255\255\ -\255\255\215\005\000\005\255\255\255\255\255\255\004\005\221\005\ -\255\255\255\255\255\255\255\255\081\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\089\001\090\001\255\255\255\255\ -\255\255\255\255\210\005\255\255\097\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\109\001\110\001\255\255\255\255\000\001\001\001\002\001\003\001\ -\232\005\255\255\008\006\255\255\008\001\009\001\010\001\255\255\ -\255\255\013\001\014\001\015\001\016\001\017\001\018\001\019\001\ -\020\001\021\001\255\255\255\255\024\001\025\001\026\001\027\001\ -\028\001\029\001\255\255\000\000\255\255\255\255\255\255\255\255\ -\036\001\037\001\255\255\255\255\040\001\041\001\042\001\043\001\ -\044\001\045\001\046\001\255\255\048\001\049\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\058\006\255\255\255\255\255\255\ -\060\001\061\001\255\255\063\001\255\255\255\255\066\001\067\001\ -\068\001\255\255\070\001\071\001\072\001\073\001\074\001\255\255\ -\255\255\255\255\255\255\081\006\080\001\083\006\082\001\083\001\ -\084\001\085\001\086\001\255\255\255\255\255\255\255\255\091\001\ -\092\001\255\255\094\001\095\001\096\001\097\001\255\255\255\255\ -\100\001\255\255\255\255\103\001\255\255\105\001\255\255\255\255\ -\108\001\255\255\255\255\111\001\255\255\255\255\255\255\115\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\166\005\255\255\255\255\255\255\013\001\255\255\255\255\255\255\ -\255\255\000\001\255\255\002\001\003\001\004\001\181\005\182\005\ -\183\005\008\001\255\255\028\001\029\001\255\255\013\001\000\000\ -\255\255\255\255\017\001\018\001\019\001\255\255\255\255\255\255\ -\041\001\255\255\200\005\026\001\027\001\028\001\029\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\036\001\255\255\213\005\ -\255\255\040\001\041\001\060\001\255\255\219\005\063\001\255\255\ -\255\255\048\001\049\001\068\001\255\255\255\255\255\255\255\255\ -\255\255\074\001\255\255\255\255\255\255\060\001\236\005\080\001\ -\063\001\255\255\255\255\066\001\067\001\068\001\244\005\070\001\ -\255\255\255\255\073\001\074\001\255\255\255\255\255\255\096\001\ -\255\255\080\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\108\001\091\001\092\001\111\001\094\001\ -\095\001\096\001\255\255\255\255\255\255\100\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\108\001\255\255\255\255\ -\111\001\255\255\255\255\255\255\115\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\044\006\045\006\ -\255\255\255\255\255\255\000\000\255\255\051\006\052\006\053\006\ -\054\006\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\063\006\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\000\001\001\001\002\001\003\001\255\255\ -\078\006\006\001\007\001\008\001\009\001\010\001\011\001\012\001\ -\013\001\014\001\015\001\016\001\017\001\018\001\019\001\020\001\ -\021\001\022\001\255\255\024\001\025\001\026\001\027\001\028\001\ -\029\001\030\001\031\001\255\255\255\255\255\255\255\255\036\001\ -\037\001\255\255\255\255\040\001\041\001\042\001\043\001\044\001\ -\045\001\046\001\047\001\048\001\049\001\050\001\051\001\255\255\ -\053\001\054\001\055\001\056\001\255\255\255\255\059\001\060\001\ -\061\001\062\001\063\001\064\001\065\001\066\001\067\001\068\001\ -\255\255\070\001\071\001\072\001\073\001\074\001\255\255\076\001\ -\255\255\255\255\255\255\080\001\081\001\082\001\083\001\084\001\ -\085\001\086\001\087\001\255\255\089\001\255\255\091\001\092\001\ -\000\000\094\001\095\001\096\001\097\001\098\001\255\255\100\001\ -\101\001\255\255\103\001\104\001\105\001\106\001\255\255\108\001\ -\109\001\255\255\111\001\255\255\255\255\255\255\115\001\000\001\ -\001\001\002\001\003\001\004\001\255\255\006\001\007\001\008\001\ -\009\001\010\001\011\001\012\001\013\001\014\001\015\001\016\001\ -\017\001\018\001\019\001\020\001\021\001\255\255\255\255\024\001\ -\025\001\026\001\027\001\028\001\029\001\030\001\031\001\255\255\ -\255\255\255\255\255\255\036\001\037\001\255\255\255\255\040\001\ -\041\001\042\001\043\001\044\001\045\001\046\001\047\001\048\001\ -\049\001\050\001\051\001\255\255\053\001\054\001\055\001\056\001\ -\255\255\255\255\059\001\060\001\061\001\255\255\063\001\064\001\ -\065\001\066\001\067\001\068\001\255\255\070\001\071\001\072\001\ -\073\001\074\001\255\255\076\001\255\255\255\255\255\255\080\001\ -\081\001\082\001\083\001\084\001\085\001\086\001\087\001\255\255\ -\089\001\255\255\091\001\092\001\000\000\094\001\095\001\096\001\ -\097\001\098\001\255\255\100\001\101\001\255\255\103\001\104\001\ -\105\001\106\001\255\255\108\001\109\001\255\255\111\001\255\255\ -\255\255\255\255\115\001\000\001\001\001\002\001\003\001\255\255\ -\255\255\006\001\007\001\008\001\009\001\010\001\011\001\012\001\ -\013\001\014\001\015\001\016\001\017\001\018\001\019\001\020\001\ -\021\001\022\001\255\255\024\001\025\001\026\001\027\001\028\001\ -\029\001\030\001\031\001\255\255\255\255\255\255\255\255\036\001\ -\037\001\255\255\255\255\040\001\041\001\042\001\043\001\044\001\ -\045\001\046\001\047\001\048\001\049\001\050\001\051\001\255\255\ -\053\001\054\001\055\001\056\001\255\255\255\255\059\001\060\001\ -\061\001\255\255\063\001\064\001\065\001\066\001\067\001\068\001\ -\255\255\070\001\071\001\072\001\073\001\074\001\255\255\076\001\ -\255\255\255\255\255\255\080\001\081\001\082\001\083\001\084\001\ -\085\001\086\001\087\001\255\255\089\001\255\255\091\001\092\001\ -\000\000\094\001\095\001\096\001\097\001\098\001\255\255\100\001\ -\101\001\255\255\103\001\104\001\105\001\106\001\255\255\108\001\ -\109\001\255\255\111\001\255\255\255\255\255\255\115\001\255\255\ -\000\001\001\001\002\001\003\001\255\255\255\255\006\001\007\001\ -\008\001\009\001\010\001\011\001\012\001\013\001\014\001\015\001\ -\016\001\017\001\018\001\019\001\020\001\021\001\022\001\255\255\ -\024\001\025\001\026\001\027\001\028\001\029\001\030\001\031\001\ -\255\255\255\255\255\255\255\255\036\001\037\001\255\255\255\255\ -\040\001\041\001\042\001\043\001\044\001\045\001\046\001\047\001\ -\048\001\049\001\050\001\051\001\255\255\053\001\054\001\055\001\ -\056\001\255\255\255\255\059\001\060\001\061\001\255\255\063\001\ -\064\001\065\001\066\001\067\001\068\001\255\255\070\001\071\001\ -\072\001\073\001\074\001\255\255\076\001\255\255\255\255\255\255\ -\080\001\081\001\082\001\083\001\084\001\085\001\086\001\087\001\ -\255\255\089\001\255\255\091\001\092\001\000\000\094\001\095\001\ -\096\001\097\001\098\001\255\255\100\001\101\001\255\255\103\001\ -\104\001\105\001\106\001\255\255\108\001\109\001\255\255\111\001\ -\255\255\255\255\255\255\115\001\000\001\001\001\002\001\003\001\ -\255\255\255\255\006\001\007\001\008\001\009\001\010\001\011\001\ -\012\001\013\001\014\001\015\001\016\001\017\001\018\001\019\001\ -\020\001\021\001\022\001\255\255\024\001\025\001\026\001\027\001\ -\028\001\029\001\030\001\031\001\255\255\255\255\255\255\255\255\ -\036\001\037\001\255\255\255\255\040\001\041\001\042\001\043\001\ -\044\001\045\001\046\001\047\001\048\001\049\001\050\001\051\001\ -\255\255\053\001\054\001\055\001\056\001\255\255\255\255\059\001\ -\060\001\061\001\255\255\063\001\064\001\065\001\066\001\067\001\ -\068\001\255\255\070\001\071\001\072\001\073\001\074\001\255\255\ -\076\001\255\255\255\255\255\255\080\001\081\001\082\001\083\001\ -\084\001\085\001\086\001\087\001\255\255\089\001\255\255\091\001\ -\092\001\000\000\094\001\095\001\096\001\097\001\098\001\255\255\ -\100\001\101\001\255\255\103\001\104\001\105\001\106\001\255\255\ -\108\001\109\001\255\255\111\001\255\255\255\255\255\255\115\001\ -\000\001\001\001\002\001\003\001\255\255\255\255\006\001\007\001\ -\008\001\009\001\010\001\011\001\012\001\013\001\014\001\015\001\ -\016\001\017\001\018\001\019\001\020\001\021\001\022\001\255\255\ -\024\001\025\001\026\001\027\001\028\001\029\001\030\001\031\001\ -\255\255\255\255\255\255\255\255\036\001\037\001\255\255\255\255\ -\040\001\041\001\042\001\043\001\044\001\045\001\046\001\047\001\ -\048\001\049\001\050\001\051\001\255\255\053\001\054\001\055\001\ -\056\001\255\255\255\255\059\001\060\001\061\001\255\255\063\001\ -\064\001\065\001\066\001\067\001\068\001\255\255\070\001\071\001\ -\072\001\073\001\074\001\255\255\076\001\255\255\255\255\255\255\ -\080\001\081\001\082\001\083\001\084\001\085\001\086\001\087\001\ -\255\255\089\001\255\255\091\001\092\001\000\000\094\001\095\001\ -\096\001\097\001\098\001\255\255\100\001\101\001\255\255\103\001\ -\104\001\105\001\106\001\255\255\108\001\109\001\255\255\111\001\ -\255\255\255\255\255\255\115\001\255\255\000\001\001\001\002\001\ -\003\001\255\255\255\255\006\001\007\001\008\001\009\001\010\001\ -\011\001\012\001\013\001\014\001\015\001\016\001\017\001\018\001\ -\019\001\020\001\021\001\022\001\255\255\024\001\025\001\026\001\ -\027\001\028\001\029\001\030\001\031\001\255\255\255\255\255\255\ -\255\255\036\001\037\001\255\255\255\255\040\001\041\001\042\001\ -\043\001\044\001\045\001\046\001\047\001\048\001\049\001\050\001\ -\051\001\255\255\053\001\054\001\055\001\056\001\255\255\255\255\ -\059\001\060\001\061\001\255\255\063\001\064\001\065\001\066\001\ -\067\001\068\001\255\255\070\001\071\001\072\001\073\001\074\001\ -\255\255\076\001\255\255\255\255\255\255\080\001\081\001\082\001\ -\083\001\084\001\085\001\086\001\087\001\255\255\089\001\255\255\ -\091\001\092\001\000\000\094\001\095\001\096\001\097\001\098\001\ -\255\255\100\001\101\001\255\255\103\001\104\001\105\001\106\001\ -\255\255\108\001\109\001\255\255\111\001\255\255\255\255\255\255\ -\115\001\000\001\001\001\002\001\003\001\255\255\255\255\006\001\ -\007\001\008\001\009\001\010\001\011\001\012\001\013\001\014\001\ -\015\001\016\001\017\001\018\001\019\001\020\001\021\001\022\001\ -\255\255\024\001\025\001\026\001\027\001\028\001\029\001\030\001\ -\031\001\255\255\255\255\255\255\255\255\036\001\037\001\255\255\ -\255\255\040\001\041\001\042\001\043\001\044\001\045\001\046\001\ -\047\001\048\001\049\001\050\001\051\001\255\255\053\001\054\001\ -\055\001\056\001\255\255\255\255\059\001\060\001\061\001\255\255\ -\063\001\064\001\065\001\066\001\067\001\068\001\255\255\070\001\ -\071\001\072\001\073\001\074\001\255\255\076\001\255\255\255\255\ -\255\255\080\001\081\001\082\001\083\001\084\001\085\001\086\001\ -\087\001\255\255\089\001\255\255\091\001\092\001\000\000\094\001\ -\095\001\096\001\097\001\098\001\255\255\100\001\101\001\255\255\ -\103\001\104\001\105\001\106\001\255\255\108\001\109\001\255\255\ -\111\001\255\255\255\255\255\255\115\001\000\001\001\001\002\001\ -\003\001\255\255\255\255\006\001\007\001\008\001\009\001\010\001\ -\011\001\012\001\013\001\014\001\015\001\016\001\017\001\018\001\ -\019\001\020\001\021\001\022\001\255\255\024\001\025\001\026\001\ -\027\001\028\001\029\001\030\001\031\001\255\255\255\255\255\255\ -\255\255\036\001\037\001\255\255\255\255\040\001\041\001\042\001\ -\043\001\044\001\045\001\046\001\047\001\048\001\049\001\050\001\ -\051\001\255\255\053\001\054\001\055\001\056\001\255\255\255\255\ -\059\001\060\001\061\001\255\255\063\001\064\001\065\001\066\001\ -\067\001\068\001\255\255\070\001\071\001\072\001\073\001\074\001\ -\255\255\076\001\255\255\255\255\255\255\080\001\081\001\082\001\ -\083\001\084\001\085\001\086\001\087\001\255\255\089\001\255\255\ -\091\001\092\001\000\000\094\001\095\001\096\001\097\001\098\001\ -\255\255\100\001\101\001\255\255\103\001\104\001\105\001\106\001\ -\255\255\108\001\109\001\255\255\111\001\255\255\255\255\255\255\ -\115\001\255\255\000\001\001\001\002\001\003\001\255\255\255\255\ -\006\001\007\001\008\001\009\001\010\001\011\001\012\001\013\001\ -\014\001\015\001\016\001\017\001\018\001\019\001\020\001\021\001\ -\022\001\255\255\024\001\025\001\026\001\027\001\028\001\029\001\ -\030\001\031\001\255\255\255\255\255\255\255\255\036\001\037\001\ -\255\255\255\255\040\001\041\001\042\001\043\001\044\001\045\001\ -\046\001\047\001\048\001\049\001\050\001\051\001\255\255\053\001\ -\054\001\055\001\056\001\255\255\255\255\059\001\060\001\061\001\ -\255\255\063\001\064\001\065\001\066\001\067\001\068\001\255\255\ -\070\001\071\001\072\001\073\001\074\001\255\255\076\001\255\255\ -\255\255\255\255\080\001\081\001\082\001\083\001\084\001\085\001\ -\086\001\087\001\255\255\089\001\255\255\091\001\092\001\000\000\ -\094\001\095\001\096\001\097\001\098\001\255\255\100\001\101\001\ -\255\255\103\001\104\001\105\001\106\001\255\255\108\001\109\001\ -\255\255\111\001\255\255\255\255\255\255\115\001\000\001\001\001\ -\002\001\003\001\255\255\255\255\006\001\007\001\008\001\009\001\ -\010\001\011\001\012\001\013\001\014\001\015\001\016\001\017\001\ -\018\001\019\001\020\001\021\001\022\001\255\255\024\001\025\001\ -\026\001\027\001\028\001\029\001\030\001\031\001\255\255\255\255\ -\255\255\255\255\036\001\037\001\255\255\255\255\040\001\041\001\ -\042\001\043\001\044\001\045\001\046\001\047\001\048\001\049\001\ -\050\001\051\001\255\255\053\001\054\001\055\001\056\001\255\255\ -\255\255\059\001\060\001\061\001\255\255\063\001\064\001\065\001\ -\066\001\067\001\068\001\255\255\070\001\071\001\072\001\073\001\ -\074\001\255\255\076\001\255\255\255\255\255\255\080\001\081\001\ -\082\001\083\001\084\001\085\001\086\001\087\001\255\255\089\001\ -\255\255\091\001\092\001\000\000\094\001\095\001\096\001\097\001\ -\098\001\255\255\100\001\101\001\255\255\103\001\104\001\105\001\ -\106\001\255\255\108\001\109\001\255\255\111\001\255\255\255\255\ -\255\255\115\001\000\001\001\001\002\001\003\001\255\255\255\255\ -\006\001\007\001\008\001\009\001\010\001\011\001\012\001\013\001\ -\014\001\015\001\016\001\017\001\018\001\019\001\020\001\021\001\ -\022\001\255\255\024\001\025\001\026\001\027\001\028\001\029\001\ -\030\001\031\001\255\255\255\255\255\255\255\255\036\001\037\001\ -\255\255\255\255\040\001\041\001\042\001\043\001\044\001\045\001\ -\046\001\047\001\048\001\049\001\050\001\051\001\255\255\053\001\ -\054\001\055\001\056\001\255\255\255\255\059\001\060\001\061\001\ -\255\255\063\001\064\001\065\001\066\001\067\001\068\001\255\255\ -\070\001\071\001\072\001\073\001\074\001\255\255\076\001\255\255\ -\255\255\255\255\080\001\081\001\082\001\083\001\084\001\085\001\ -\086\001\087\001\255\255\089\001\255\255\091\001\092\001\000\000\ -\094\001\095\001\096\001\097\001\098\001\255\255\100\001\101\001\ -\255\255\103\001\104\001\105\001\106\001\255\255\108\001\109\001\ -\255\255\111\001\255\255\255\255\255\255\115\001\255\255\000\001\ -\001\001\002\001\003\001\004\001\255\255\006\001\007\001\008\001\ -\009\001\010\001\011\001\012\001\013\001\014\001\015\001\016\001\ -\017\001\018\001\019\001\020\001\021\001\255\255\255\255\024\001\ -\025\001\026\001\027\001\028\001\029\001\030\001\031\001\255\255\ -\255\255\255\255\255\255\036\001\037\001\255\255\255\255\040\001\ -\041\001\042\001\043\001\044\001\045\001\046\001\255\255\048\001\ -\049\001\050\001\051\001\255\255\053\001\054\001\055\001\056\001\ -\255\255\255\255\059\001\060\001\061\001\255\255\063\001\064\001\ -\065\001\066\001\067\001\068\001\255\255\070\001\071\001\072\001\ -\073\001\074\001\255\255\076\001\255\255\255\255\255\255\080\001\ -\081\001\082\001\083\001\084\001\085\001\086\001\087\001\255\255\ -\089\001\255\255\091\001\092\001\000\000\094\001\095\001\096\001\ -\097\001\098\001\255\255\100\001\101\001\255\255\103\001\104\001\ -\105\001\106\001\255\255\108\001\109\001\255\255\111\001\255\255\ -\255\255\255\255\115\001\000\001\001\001\002\001\003\001\004\001\ -\255\255\006\001\007\001\008\001\009\001\010\001\011\001\012\001\ -\013\001\014\001\015\001\016\001\017\001\018\001\019\001\020\001\ -\021\001\255\255\255\255\024\001\025\001\026\001\027\001\028\001\ -\029\001\030\001\031\001\255\255\255\255\255\255\255\255\036\001\ -\037\001\255\255\255\255\040\001\041\001\042\001\043\001\044\001\ -\045\001\046\001\255\255\048\001\049\001\050\001\051\001\255\255\ -\053\001\054\001\055\001\056\001\255\255\255\255\059\001\060\001\ -\061\001\255\255\063\001\064\001\065\001\066\001\067\001\068\001\ -\255\255\070\001\071\001\072\001\073\001\074\001\255\255\076\001\ -\255\255\255\255\255\255\080\001\081\001\082\001\083\001\084\001\ -\085\001\086\001\087\001\255\255\089\001\255\255\091\001\092\001\ -\000\000\094\001\095\001\096\001\255\255\255\255\255\255\100\001\ -\101\001\255\255\103\001\104\001\105\001\106\001\255\255\108\001\ -\109\001\255\255\111\001\255\255\255\255\255\255\115\001\000\001\ -\001\001\002\001\003\001\004\001\255\255\006\001\007\001\008\001\ -\009\001\010\001\011\001\012\001\013\001\014\001\015\001\016\001\ -\017\001\018\001\019\001\020\001\021\001\255\255\255\255\024\001\ -\025\001\026\001\027\001\028\001\029\001\030\001\031\001\255\255\ -\255\255\255\255\255\255\036\001\037\001\255\255\255\255\040\001\ -\041\001\042\001\043\001\044\001\045\001\046\001\255\255\048\001\ -\049\001\050\001\051\001\255\255\053\001\054\001\055\001\056\001\ -\255\255\255\255\059\001\060\001\061\001\255\255\063\001\064\001\ -\065\001\066\001\067\001\068\001\255\255\070\001\071\001\072\001\ -\073\001\074\001\255\255\076\001\255\255\255\255\255\255\080\001\ -\081\001\082\001\083\001\084\001\085\001\086\001\087\001\255\255\ -\089\001\255\255\091\001\092\001\000\000\094\001\095\001\096\001\ -\255\255\255\255\255\255\100\001\101\001\255\255\103\001\104\001\ -\105\001\106\001\255\255\108\001\109\001\255\255\111\001\255\255\ -\255\255\255\255\115\001\255\255\000\001\001\001\002\001\003\001\ -\004\001\255\255\006\001\007\001\008\001\009\001\010\001\011\001\ -\012\001\013\001\014\001\015\001\016\001\017\001\018\001\019\001\ -\020\001\021\001\255\255\255\255\024\001\025\001\026\001\027\001\ -\028\001\029\001\030\001\031\001\255\255\255\255\255\255\255\255\ -\036\001\037\001\255\255\255\255\040\001\041\001\042\001\043\001\ -\044\001\045\001\046\001\255\255\048\001\049\001\050\001\051\001\ -\255\255\053\001\054\001\055\001\056\001\255\255\255\255\059\001\ -\060\001\061\001\255\255\063\001\064\001\065\001\066\001\067\001\ -\068\001\255\255\070\001\071\001\072\001\073\001\074\001\255\255\ -\076\001\255\255\255\255\255\255\080\001\081\001\082\001\083\001\ -\084\001\085\001\086\001\087\001\255\255\089\001\255\255\091\001\ -\092\001\000\000\094\001\095\001\096\001\255\255\255\255\255\255\ -\100\001\101\001\255\255\103\001\104\001\105\001\106\001\255\255\ -\108\001\109\001\255\255\111\001\255\255\255\255\255\255\115\001\ -\000\001\001\001\002\001\003\001\255\255\255\255\255\255\255\255\ -\008\001\009\001\010\001\255\255\255\255\013\001\014\001\015\001\ -\016\001\017\001\018\001\019\001\020\001\021\001\022\001\255\255\ -\024\001\025\001\026\001\027\001\028\001\029\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\036\001\037\001\255\255\255\255\ -\040\001\041\001\042\001\043\001\044\001\045\001\046\001\047\001\ -\048\001\049\001\255\255\051\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\060\001\061\001\255\255\063\001\ -\255\255\255\255\066\001\067\001\068\001\255\255\070\001\071\001\ -\072\001\073\001\074\001\255\255\255\255\255\255\255\255\255\255\ -\080\001\081\001\082\001\083\001\084\001\085\001\086\001\255\255\ -\255\255\089\001\255\255\091\001\092\001\000\000\094\001\095\001\ -\096\001\097\001\098\001\255\255\100\001\255\255\255\255\103\001\ -\104\001\105\001\255\255\255\255\108\001\255\255\255\255\111\001\ -\255\255\255\255\255\255\115\001\000\001\001\001\002\001\003\001\ -\255\255\255\255\255\255\255\255\008\001\009\001\010\001\255\255\ -\255\255\013\001\014\001\015\001\016\001\017\001\018\001\019\001\ -\020\001\021\001\022\001\255\255\024\001\025\001\026\001\027\001\ -\028\001\029\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\036\001\037\001\255\255\255\255\040\001\041\001\042\001\043\001\ -\044\001\045\001\046\001\047\001\048\001\049\001\255\255\051\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\060\001\061\001\255\255\063\001\255\255\255\255\066\001\067\001\ -\068\001\255\255\070\001\071\001\072\001\073\001\074\001\255\255\ -\255\255\255\255\255\255\255\255\080\001\081\001\082\001\083\001\ -\084\001\085\001\086\001\255\255\255\255\089\001\255\255\091\001\ -\092\001\000\000\094\001\095\001\096\001\097\001\098\001\255\255\ -\100\001\255\255\255\255\103\001\104\001\105\001\255\255\255\255\ -\108\001\255\255\255\255\111\001\255\255\255\255\255\255\115\001\ -\255\255\000\001\001\001\002\001\003\001\255\255\255\255\255\255\ -\255\255\008\001\009\001\010\001\255\255\255\255\013\001\014\001\ -\015\001\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ -\255\255\024\001\025\001\026\001\027\001\028\001\029\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\036\001\037\001\255\255\ -\255\255\040\001\041\001\042\001\043\001\044\001\045\001\046\001\ -\255\255\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\060\001\061\001\255\255\ -\063\001\255\255\255\255\066\001\067\001\068\001\255\255\070\001\ -\071\001\072\001\073\001\074\001\255\255\255\255\255\255\255\255\ -\255\255\080\001\255\255\082\001\083\001\084\001\085\001\086\001\ -\255\255\255\255\255\255\255\255\091\001\092\001\000\000\094\001\ -\095\001\096\001\255\255\255\255\255\255\100\001\255\255\255\255\ -\103\001\255\255\105\001\255\255\255\255\108\001\255\255\255\255\ -\111\001\255\255\255\255\255\255\115\001\000\001\001\001\002\001\ -\003\001\255\255\255\255\255\255\255\255\008\001\009\001\010\001\ -\255\255\255\255\013\001\014\001\015\001\016\001\017\001\255\255\ -\019\001\020\001\021\001\255\255\255\255\024\001\025\001\026\001\ -\027\001\028\001\029\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\036\001\037\001\255\255\255\255\040\001\041\001\042\001\ -\043\001\044\001\045\001\046\001\255\255\048\001\049\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\060\001\061\001\255\255\063\001\255\255\255\255\066\001\ -\067\001\068\001\255\255\070\001\071\001\072\001\073\001\074\001\ -\255\255\255\255\255\255\255\255\255\255\080\001\255\255\082\001\ -\083\001\084\001\085\001\086\001\255\255\255\255\255\255\255\255\ -\091\001\092\001\000\000\094\001\095\001\096\001\097\001\255\255\ -\255\255\100\001\255\255\255\255\103\001\255\255\105\001\255\255\ -\255\255\108\001\255\255\255\255\111\001\255\255\255\255\255\255\ -\115\001\000\001\001\001\002\001\003\001\255\255\255\255\255\255\ -\255\255\008\001\009\001\010\001\255\255\255\255\013\001\014\001\ -\015\001\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ -\255\255\024\001\025\001\026\001\027\001\028\001\029\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\036\001\037\001\255\255\ -\255\255\040\001\041\001\042\001\043\001\044\001\045\001\046\001\ -\255\255\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\060\001\061\001\255\255\ -\063\001\255\255\255\255\066\001\067\001\068\001\255\255\070\001\ -\071\001\072\001\073\001\074\001\255\255\255\255\255\255\255\255\ -\255\255\080\001\255\255\082\001\083\001\084\001\085\001\086\001\ -\255\255\255\255\255\255\255\255\091\001\092\001\000\000\094\001\ -\095\001\096\001\255\255\255\255\255\255\100\001\255\255\255\255\ -\103\001\255\255\105\001\255\255\255\255\108\001\255\255\255\255\ -\111\001\255\255\255\255\255\255\115\001\255\255\000\001\001\001\ -\002\001\003\001\255\255\255\255\255\255\255\255\008\001\009\001\ -\010\001\255\255\255\255\013\001\014\001\015\001\016\001\017\001\ -\018\001\019\001\020\001\021\001\255\255\255\255\024\001\025\001\ -\026\001\027\001\028\001\029\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\036\001\037\001\255\255\255\255\040\001\041\001\ -\042\001\043\001\044\001\045\001\046\001\255\255\048\001\049\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\060\001\061\001\255\255\063\001\255\255\255\255\ -\066\001\067\001\068\001\255\255\070\001\071\001\072\001\073\001\ -\074\001\255\255\255\255\255\255\255\255\255\255\080\001\255\255\ -\082\001\083\001\084\001\085\001\086\001\255\255\255\255\255\255\ -\255\255\091\001\092\001\000\000\094\001\095\001\096\001\255\255\ -\255\255\255\255\100\001\255\255\255\255\103\001\255\255\105\001\ -\255\255\255\255\108\001\255\255\255\255\111\001\255\255\255\255\ -\255\255\115\001\000\001\001\001\002\001\003\001\255\255\255\255\ -\255\255\255\255\008\001\009\001\010\001\255\255\255\255\013\001\ -\014\001\015\001\016\001\017\001\018\001\019\001\020\001\021\001\ -\255\255\255\255\024\001\025\001\026\001\027\001\028\001\029\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\036\001\037\001\ -\255\255\255\255\040\001\041\001\042\001\043\001\044\001\045\001\ -\046\001\255\255\048\001\049\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\060\001\061\001\ -\255\255\063\001\255\255\255\255\066\001\067\001\068\001\255\255\ -\070\001\071\001\072\001\073\001\074\001\255\255\255\255\255\255\ -\255\255\255\255\080\001\255\255\082\001\083\001\084\001\085\001\ -\086\001\255\255\255\255\255\255\255\255\091\001\092\001\000\000\ -\094\001\095\001\096\001\255\255\255\255\255\255\100\001\255\255\ -\255\255\103\001\255\255\105\001\255\255\255\255\108\001\255\255\ -\255\255\111\001\255\255\255\255\255\255\115\001\000\001\001\001\ -\002\001\003\001\255\255\255\255\255\255\255\255\008\001\009\001\ -\010\001\255\255\255\255\013\001\014\001\015\001\016\001\017\001\ -\018\001\019\001\020\001\021\001\255\255\255\255\024\001\025\001\ -\026\001\027\001\028\001\029\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\036\001\037\001\255\255\255\255\040\001\041\001\ -\042\001\043\001\044\001\045\001\046\001\255\255\048\001\049\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\060\001\061\001\255\255\063\001\255\255\255\255\ -\066\001\067\001\068\001\255\255\070\001\071\001\072\001\073\001\ -\074\001\255\255\255\255\255\255\255\255\255\255\080\001\255\255\ -\082\001\083\001\084\001\085\001\086\001\255\255\255\255\255\255\ -\255\255\091\001\092\001\000\000\094\001\095\001\096\001\255\255\ -\255\255\255\255\100\001\255\255\255\255\103\001\255\255\105\001\ -\255\255\255\255\108\001\255\255\255\255\111\001\255\255\255\255\ -\255\255\115\001\255\255\000\001\001\001\002\001\003\001\255\255\ -\255\255\255\255\255\255\008\001\009\001\010\001\255\255\255\255\ -\013\001\014\001\015\001\016\001\017\001\018\001\019\001\020\001\ -\021\001\255\255\255\255\024\001\025\001\026\001\027\001\028\001\ -\029\001\255\255\255\255\255\255\255\255\255\255\255\255\036\001\ -\037\001\255\255\255\255\040\001\041\001\042\001\043\001\044\001\ -\045\001\255\255\255\255\048\001\049\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\060\001\ -\061\001\255\255\063\001\255\255\255\255\066\001\067\001\068\001\ -\255\255\070\001\071\001\072\001\073\001\074\001\255\255\255\255\ -\255\255\255\255\255\255\080\001\255\255\082\001\083\001\084\001\ -\085\001\086\001\255\255\255\255\255\255\255\255\091\001\092\001\ -\000\000\094\001\095\001\096\001\097\001\255\255\255\255\100\001\ -\255\255\255\255\103\001\255\255\105\001\255\255\255\255\108\001\ -\255\255\255\255\111\001\255\255\255\255\255\255\115\001\000\001\ -\001\001\002\001\003\001\255\255\255\255\255\255\255\255\008\001\ -\009\001\010\001\255\255\255\255\013\001\014\001\015\001\016\001\ -\017\001\018\001\019\001\020\001\021\001\255\255\255\255\024\001\ -\025\001\026\001\027\001\028\001\029\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\036\001\037\001\255\255\255\255\040\001\ -\041\001\042\001\043\001\044\001\045\001\255\255\255\255\048\001\ -\049\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\060\001\061\001\255\255\063\001\255\255\ -\255\255\066\001\067\001\068\001\255\255\070\001\071\001\072\001\ -\073\001\074\001\255\255\255\255\255\255\255\255\255\255\080\001\ -\255\255\082\001\083\001\084\001\085\001\086\001\255\255\255\255\ -\255\255\255\255\091\001\092\001\000\000\094\001\095\001\096\001\ -\097\001\255\255\255\255\100\001\255\255\255\255\103\001\255\255\ -\105\001\255\255\255\255\108\001\255\255\255\255\111\001\255\255\ -\255\255\255\255\115\001\000\001\001\001\002\001\003\001\255\255\ -\255\255\255\255\255\255\008\001\009\001\010\001\255\255\255\255\ -\013\001\014\001\015\001\016\001\017\001\018\001\019\001\020\001\ -\021\001\255\255\255\255\024\001\025\001\026\001\027\001\028\001\ -\029\001\255\255\255\255\255\255\255\255\255\255\255\255\036\001\ -\037\001\255\255\255\255\040\001\041\001\042\001\043\001\044\001\ -\045\001\255\255\255\255\048\001\049\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\060\001\ -\061\001\255\255\063\001\255\255\255\255\066\001\067\001\068\001\ -\255\255\070\001\071\001\072\001\073\001\074\001\255\255\255\255\ -\255\255\255\255\255\255\080\001\255\255\082\001\083\001\084\001\ -\085\001\086\001\255\255\255\255\255\255\255\255\091\001\092\001\ -\000\000\094\001\095\001\096\001\097\001\255\255\255\255\100\001\ -\255\255\255\255\103\001\255\255\105\001\255\255\255\255\108\001\ -\255\255\255\255\111\001\255\255\255\255\255\255\115\001\255\255\ -\000\001\001\001\002\001\003\001\255\255\255\255\255\255\255\255\ -\008\001\009\001\010\001\255\255\255\255\013\001\014\001\015\001\ -\016\001\017\001\018\001\019\001\020\001\021\001\255\255\255\255\ -\024\001\025\001\026\001\027\001\028\001\029\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\036\001\037\001\255\255\255\255\ -\040\001\041\001\042\001\043\001\044\001\045\001\255\255\255\255\ -\048\001\049\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\060\001\061\001\255\255\063\001\ -\255\255\255\255\066\001\067\001\068\001\255\255\070\001\071\001\ -\072\001\073\001\074\001\255\255\255\255\255\255\255\255\255\255\ -\080\001\255\255\082\001\083\001\084\001\085\001\086\001\255\255\ -\255\255\255\255\255\255\091\001\092\001\000\000\094\001\095\001\ -\096\001\097\001\255\255\255\255\100\001\255\255\255\255\103\001\ -\255\255\105\001\255\255\255\255\108\001\255\255\255\255\111\001\ -\255\255\255\255\255\255\115\001\000\001\001\001\002\001\003\001\ -\255\255\255\255\255\255\255\255\255\255\009\001\010\001\255\255\ -\255\255\013\001\014\001\015\001\016\001\017\001\018\001\019\001\ -\020\001\021\001\255\255\255\255\024\001\025\001\026\001\027\001\ -\028\001\029\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\036\001\037\001\255\255\255\255\040\001\041\001\042\001\043\001\ -\044\001\045\001\046\001\255\255\048\001\049\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\060\001\061\001\255\255\063\001\255\255\255\255\066\001\067\001\ -\068\001\255\255\070\001\071\001\072\001\073\001\074\001\255\255\ -\255\255\255\255\255\255\255\255\080\001\255\255\082\001\083\001\ -\084\001\085\001\086\001\255\255\255\255\255\255\255\255\091\001\ -\092\001\000\000\094\001\095\001\096\001\097\001\255\255\255\255\ -\100\001\255\255\255\255\103\001\255\255\105\001\255\255\255\255\ -\108\001\255\255\255\255\111\001\255\255\255\255\255\255\115\001\ -\000\001\001\001\002\001\003\001\255\255\255\255\255\255\255\255\ -\255\255\009\001\010\001\255\255\255\255\013\001\014\001\015\001\ -\016\001\017\001\018\001\019\001\020\001\021\001\255\255\255\255\ -\024\001\025\001\026\001\027\001\028\001\029\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\036\001\037\001\255\255\255\255\ -\040\001\041\001\042\001\043\001\044\001\045\001\046\001\255\255\ -\048\001\049\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\060\001\061\001\255\255\063\001\ -\255\255\255\255\066\001\067\001\068\001\255\255\070\001\071\001\ -\072\001\073\001\074\001\255\255\255\255\255\255\255\255\255\255\ -\080\001\255\255\082\001\083\001\084\001\085\001\086\001\255\255\ -\255\255\255\255\255\255\091\001\092\001\000\000\094\001\095\001\ -\096\001\097\001\255\255\255\255\100\001\255\255\255\255\103\001\ -\255\255\105\001\255\255\255\255\108\001\255\255\255\255\111\001\ -\255\255\255\255\255\255\115\001\255\255\000\001\001\001\002\001\ -\003\001\255\255\255\255\255\255\255\255\255\255\009\001\010\001\ -\255\255\255\255\013\001\014\001\015\001\016\001\017\001\018\001\ -\019\001\020\001\021\001\255\255\255\255\024\001\025\001\026\001\ -\027\001\028\001\029\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\036\001\037\001\255\255\255\255\040\001\041\001\042\001\ -\043\001\044\001\045\001\046\001\255\255\048\001\049\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\060\001\061\001\255\255\063\001\255\255\255\255\066\001\ -\067\001\068\001\255\255\070\001\071\001\072\001\073\001\074\001\ -\255\255\255\255\255\255\255\255\255\255\080\001\255\255\082\001\ -\083\001\084\001\085\001\086\001\255\255\255\255\255\255\255\255\ -\091\001\092\001\000\000\094\001\095\001\096\001\097\001\255\255\ -\255\255\100\001\255\255\255\255\103\001\255\255\105\001\255\255\ -\255\255\108\001\255\255\255\255\111\001\255\255\255\255\255\255\ -\115\001\000\001\001\001\002\001\003\001\255\255\255\255\255\255\ -\255\255\008\001\009\001\010\001\255\255\255\255\013\001\014\001\ -\015\001\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ -\255\255\024\001\025\001\026\001\027\001\028\001\029\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\036\001\037\001\255\255\ -\255\255\040\001\041\001\042\001\043\001\044\001\255\255\255\255\ -\255\255\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\060\001\061\001\255\255\ -\063\001\255\255\255\255\066\001\067\001\068\001\255\255\070\001\ -\071\001\072\001\073\001\074\001\255\255\255\255\255\255\255\255\ -\255\255\080\001\255\255\082\001\255\255\084\001\085\001\086\001\ -\255\255\255\255\255\255\255\255\091\001\092\001\000\000\094\001\ -\095\001\096\001\097\001\255\255\255\255\255\255\255\255\255\255\ -\103\001\255\255\105\001\255\255\255\255\108\001\255\255\255\255\ -\111\001\255\255\255\255\255\255\115\001\000\001\001\001\002\001\ -\003\001\255\255\255\255\255\255\255\255\008\001\009\001\010\001\ -\255\255\255\255\013\001\014\001\015\001\016\001\017\001\018\001\ -\019\001\020\001\021\001\255\255\255\255\024\001\025\001\026\001\ -\027\001\028\001\029\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\036\001\037\001\255\255\255\255\040\001\041\001\042\001\ -\043\001\044\001\255\255\255\255\255\255\048\001\049\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\060\001\061\001\255\255\063\001\255\255\255\255\066\001\ -\067\001\068\001\255\255\070\001\071\001\072\001\073\001\074\001\ -\255\255\255\255\255\255\255\255\255\255\080\001\255\255\082\001\ -\255\255\084\001\085\001\086\001\255\255\255\255\255\255\255\255\ -\091\001\092\001\000\000\094\001\095\001\096\001\097\001\255\255\ -\255\255\255\255\255\255\255\255\103\001\255\255\105\001\255\255\ -\255\255\108\001\255\255\255\255\111\001\255\255\255\255\255\255\ -\115\001\255\255\000\001\001\001\002\001\003\001\255\255\255\255\ -\255\255\255\255\008\001\009\001\010\001\255\255\255\255\013\001\ -\014\001\015\001\016\001\017\001\018\001\019\001\020\001\021\001\ -\255\255\255\255\024\001\025\001\026\001\027\001\028\001\029\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\036\001\037\001\ -\255\255\255\255\040\001\041\001\042\001\043\001\044\001\255\255\ -\255\255\255\255\048\001\049\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\060\001\061\001\ -\255\255\063\001\255\255\255\255\066\001\067\001\068\001\255\255\ -\070\001\071\001\072\001\073\001\074\001\255\255\255\255\255\255\ -\255\255\255\255\080\001\255\255\082\001\255\255\084\001\085\001\ -\086\001\255\255\255\255\255\255\255\255\091\001\092\001\000\000\ -\094\001\095\001\096\001\097\001\255\255\255\255\255\255\255\255\ -\255\255\103\001\255\255\105\001\255\255\255\255\108\001\255\255\ -\255\255\111\001\255\255\255\255\255\255\115\001\000\001\001\001\ -\002\001\003\001\255\255\255\255\255\255\255\255\008\001\009\001\ -\010\001\255\255\255\255\013\001\014\001\015\001\016\001\017\001\ -\018\001\019\001\020\001\021\001\255\255\255\255\024\001\025\001\ -\026\001\027\001\028\001\029\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\036\001\037\001\255\255\255\255\040\001\041\001\ -\042\001\043\001\044\001\255\255\255\255\255\255\048\001\049\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\060\001\061\001\255\255\063\001\255\255\255\255\ -\066\001\067\001\068\001\255\255\070\001\071\001\072\001\073\001\ -\074\001\255\255\255\255\255\255\255\255\255\255\080\001\255\255\ -\082\001\255\255\084\001\085\001\086\001\255\255\255\255\255\255\ -\255\255\091\001\092\001\000\000\094\001\095\001\096\001\097\001\ -\255\255\255\255\255\255\255\255\255\255\103\001\255\255\105\001\ -\255\255\255\255\108\001\255\255\255\255\111\001\255\255\255\255\ -\255\255\115\001\000\001\001\001\002\001\003\001\255\255\255\255\ -\255\255\255\255\008\001\009\001\010\001\255\255\255\255\013\001\ -\014\001\015\001\016\001\017\001\018\001\019\001\020\001\021\001\ -\255\255\255\255\024\001\025\001\026\001\027\001\028\001\029\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\036\001\037\001\ -\255\255\255\255\040\001\041\001\042\001\043\001\044\001\255\255\ -\255\255\255\255\048\001\049\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\060\001\061\001\ -\255\255\063\001\255\255\255\255\066\001\067\001\068\001\255\255\ -\070\001\071\001\072\001\073\001\074\001\255\255\255\255\255\255\ -\255\255\255\255\080\001\255\255\082\001\255\255\084\001\085\001\ -\086\001\255\255\255\255\255\255\255\255\091\001\092\001\000\000\ -\094\001\095\001\096\001\097\001\255\255\255\255\255\255\255\255\ -\255\255\103\001\255\255\105\001\255\255\255\255\108\001\255\255\ -\255\255\111\001\255\255\255\255\255\255\115\001\255\255\000\001\ -\001\001\002\001\003\001\255\255\255\255\255\255\255\255\008\001\ -\009\001\010\001\255\255\255\255\013\001\014\001\015\001\016\001\ -\017\001\018\001\019\001\020\001\021\001\255\255\255\255\024\001\ -\025\001\026\001\027\001\028\001\029\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\036\001\037\001\255\255\255\255\040\001\ -\041\001\042\001\043\001\044\001\255\255\255\255\255\255\048\001\ -\049\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\060\001\061\001\255\255\063\001\255\255\ -\255\255\066\001\067\001\068\001\255\255\070\001\071\001\072\001\ -\073\001\074\001\255\255\255\255\255\255\255\255\255\255\080\001\ -\255\255\082\001\255\255\084\001\085\001\086\001\255\255\255\255\ -\255\255\255\255\091\001\092\001\000\000\094\001\095\001\096\001\ -\097\001\255\255\255\255\255\255\255\255\255\255\103\001\255\255\ -\105\001\255\255\255\255\108\001\255\255\255\255\111\001\255\255\ -\255\255\255\255\115\001\000\001\001\001\002\001\003\001\255\255\ -\255\255\255\255\255\255\008\001\009\001\010\001\255\255\255\255\ -\013\001\014\001\015\001\016\001\017\001\018\001\019\001\020\001\ -\021\001\255\255\255\255\024\001\025\001\026\001\027\001\028\001\ -\029\001\255\255\255\255\255\255\255\255\255\255\255\255\036\001\ -\037\001\255\255\255\255\040\001\041\001\042\001\043\001\044\001\ -\045\001\046\001\255\255\048\001\049\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\060\001\ -\061\001\255\255\255\255\255\255\255\255\066\001\067\001\068\001\ -\255\255\070\001\255\255\255\255\073\001\074\001\255\255\255\255\ -\255\255\255\255\255\255\080\001\255\255\082\001\255\255\255\255\ -\255\255\086\001\255\255\255\255\255\255\255\255\091\001\092\001\ -\000\000\094\001\095\001\096\001\097\001\255\255\255\255\100\001\ -\255\255\255\255\103\001\255\255\105\001\255\255\255\255\108\001\ -\255\255\255\255\111\001\255\255\255\255\255\255\115\001\000\001\ -\001\001\002\001\003\001\255\255\255\255\255\255\255\255\008\001\ -\009\001\010\001\255\255\255\255\013\001\014\001\255\255\016\001\ -\017\001\018\001\019\001\020\001\021\001\255\255\255\255\024\001\ -\025\001\026\001\027\001\028\001\029\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\036\001\037\001\255\255\255\255\040\001\ -\041\001\042\001\255\255\255\255\255\255\255\255\255\255\048\001\ -\049\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\060\001\061\001\255\255\063\001\255\255\ -\255\255\255\255\067\001\068\001\255\255\070\001\255\255\255\255\ -\073\001\074\001\255\255\255\255\255\255\255\255\255\255\080\001\ -\255\255\082\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\091\001\092\001\000\000\094\001\095\001\096\001\ -\097\001\255\255\255\255\255\255\255\255\255\255\103\001\255\255\ -\105\001\255\255\255\255\108\001\255\255\255\255\111\001\255\255\ -\255\255\255\255\115\001\255\255\000\001\001\001\002\001\003\001\ -\255\255\255\255\255\255\255\255\008\001\009\001\010\001\255\255\ -\255\255\013\001\014\001\255\255\016\001\017\001\018\001\019\001\ -\020\001\021\001\255\255\255\255\024\001\025\001\026\001\027\001\ -\028\001\029\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\036\001\037\001\255\255\255\255\040\001\041\001\042\001\255\255\ -\255\255\255\255\255\255\255\255\048\001\049\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\060\001\061\001\255\255\063\001\255\255\255\255\255\255\067\001\ -\068\001\255\255\070\001\255\255\255\255\073\001\074\001\255\255\ -\255\255\255\255\255\255\255\255\080\001\255\255\082\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\091\001\ -\092\001\000\000\094\001\095\001\096\001\097\001\255\255\255\255\ -\255\255\255\255\255\255\103\001\255\255\105\001\255\255\255\255\ -\108\001\255\255\255\255\111\001\255\255\255\255\255\255\115\001\ -\000\001\001\001\002\001\003\001\255\255\255\255\255\255\255\255\ -\008\001\009\001\010\001\255\255\255\255\013\001\014\001\255\255\ -\016\001\017\001\018\001\019\001\020\001\021\001\255\255\255\255\ -\024\001\025\001\026\001\027\001\028\001\029\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\036\001\037\001\255\255\255\255\ -\040\001\041\001\042\001\255\255\255\255\255\255\255\255\255\255\ -\048\001\049\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\060\001\061\001\255\255\063\001\ -\255\255\255\255\255\255\067\001\068\001\255\255\070\001\255\255\ -\255\255\073\001\074\001\255\255\255\255\255\255\255\255\255\255\ -\080\001\000\000\082\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\091\001\092\001\255\255\094\001\095\001\ -\096\001\097\001\255\255\255\255\255\255\255\255\255\255\103\001\ -\255\255\105\001\255\255\255\255\108\001\255\255\255\255\111\001\ -\255\255\255\255\255\255\115\001\000\001\001\001\002\001\003\001\ -\255\255\255\255\255\255\255\255\008\001\009\001\010\001\255\255\ -\255\255\013\001\014\001\255\255\016\001\017\001\018\001\019\001\ -\020\001\021\001\255\255\255\255\024\001\025\001\026\001\027\001\ -\028\001\029\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\036\001\037\001\255\255\255\255\040\001\041\001\042\001\255\255\ -\255\255\255\255\255\255\255\255\048\001\049\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\060\001\061\001\255\255\063\001\255\255\255\255\255\255\067\001\ -\068\001\000\000\070\001\255\255\255\255\073\001\074\001\255\255\ -\255\255\255\255\255\255\255\255\080\001\255\255\082\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\091\001\ -\092\001\255\255\094\001\095\001\096\001\097\001\255\255\255\255\ -\255\255\255\255\255\255\103\001\255\255\105\001\255\255\255\255\ -\108\001\255\255\255\255\111\001\255\255\255\255\255\255\115\001\ -\255\255\000\001\001\001\002\001\003\001\255\255\255\255\255\255\ -\255\255\008\001\009\001\010\001\255\255\255\255\013\001\014\001\ -\255\255\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ -\255\255\024\001\025\001\026\001\027\001\028\001\029\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\036\001\037\001\255\255\ -\255\255\040\001\041\001\042\001\255\255\255\255\255\255\255\255\ -\255\255\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\000\000\255\255\255\255\255\255\060\001\061\001\255\255\ -\063\001\255\255\255\255\255\255\067\001\068\001\255\255\070\001\ -\255\255\255\255\073\001\074\001\255\255\255\255\255\255\255\255\ -\255\255\080\001\255\255\082\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\091\001\092\001\255\255\094\001\ -\095\001\096\001\097\001\255\255\255\255\255\255\255\255\255\255\ -\103\001\000\001\105\001\255\255\003\001\108\001\255\255\255\255\ -\111\001\008\001\009\001\010\001\115\001\255\255\013\001\014\001\ -\255\255\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ -\255\255\024\001\025\001\026\001\255\255\028\001\029\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\037\001\255\255\ -\255\255\040\001\041\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\000\000\255\255\255\255\255\255\060\001\255\255\255\255\ -\063\001\255\255\255\255\255\255\067\001\068\001\255\255\070\001\ -\255\255\255\255\073\001\074\001\255\255\255\255\255\255\255\255\ -\255\255\080\001\255\255\082\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\091\001\092\001\255\255\094\001\ -\095\001\096\001\097\001\255\255\255\255\255\255\255\255\255\255\ -\103\001\000\001\105\001\255\255\003\001\108\001\255\255\255\255\ -\111\001\008\001\009\001\010\001\115\001\255\255\013\001\014\001\ -\255\255\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ -\255\255\024\001\025\001\026\001\255\255\028\001\029\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\037\001\255\255\ -\255\255\040\001\041\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\000\000\255\255\255\255\255\255\060\001\255\255\255\255\ -\063\001\255\255\255\255\255\255\067\001\068\001\255\255\070\001\ -\255\255\255\255\073\001\074\001\255\255\255\255\255\255\255\255\ -\255\255\080\001\255\255\082\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\091\001\092\001\255\255\094\001\ -\095\001\096\001\097\001\255\255\255\255\255\255\255\255\255\255\ -\103\001\000\001\105\001\255\255\003\001\108\001\255\255\255\255\ -\111\001\008\001\255\255\010\001\115\001\255\255\013\001\014\001\ -\255\255\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ -\255\255\024\001\025\001\026\001\255\255\028\001\029\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\037\001\255\255\ -\255\255\040\001\041\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\000\000\255\255\255\255\255\255\060\001\255\255\255\255\ -\063\001\255\255\255\255\255\255\067\001\068\001\255\255\070\001\ -\255\255\255\255\073\001\074\001\255\255\255\255\255\255\255\255\ -\255\255\080\001\255\255\255\255\255\255\255\255\255\255\000\000\ -\255\255\255\255\255\255\255\255\091\001\092\001\255\255\094\001\ -\095\001\096\001\097\001\255\255\255\255\255\255\255\255\255\255\ -\103\001\000\001\105\001\255\255\003\001\108\001\255\255\255\255\ -\111\001\008\001\255\255\010\001\115\001\255\255\013\001\014\001\ -\255\255\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ -\255\255\024\001\025\001\026\001\255\255\028\001\029\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\037\001\255\255\ -\255\255\040\001\041\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\048\001\049\001\255\255\000\000\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\060\001\255\255\255\255\ -\063\001\255\255\255\255\255\255\067\001\068\001\255\255\070\001\ -\255\255\255\255\073\001\074\001\255\255\255\255\255\255\255\255\ -\255\255\080\001\000\000\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\091\001\092\001\255\255\094\001\ -\095\001\096\001\097\001\255\255\255\255\255\255\255\255\255\255\ -\103\001\000\001\105\001\255\255\003\001\108\001\255\255\255\255\ -\111\001\008\001\255\255\010\001\115\001\255\255\013\001\014\001\ -\255\255\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ -\255\255\024\001\025\001\026\001\255\255\028\001\029\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\037\001\255\255\ -\255\255\040\001\041\001\255\255\255\255\255\255\255\255\000\000\ -\255\255\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\060\001\255\255\255\255\ -\063\001\255\255\255\255\255\255\067\001\068\001\255\255\070\001\ -\255\255\255\255\073\001\074\001\255\255\255\255\255\255\255\255\ -\255\255\080\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\091\001\092\001\255\255\094\001\ -\095\001\096\001\097\001\255\255\255\255\255\255\255\255\255\255\ -\103\001\000\001\105\001\255\255\003\001\108\001\255\255\255\255\ -\111\001\008\001\255\255\010\001\115\001\255\255\013\001\014\001\ -\255\255\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ -\255\255\024\001\025\001\026\001\255\255\028\001\029\001\000\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\037\001\255\255\ -\255\255\040\001\041\001\255\255\013\001\255\255\255\255\000\000\ -\023\001\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\026\001\255\255\028\001\029\001\060\001\255\255\255\255\ -\063\001\255\255\255\255\255\255\067\001\068\001\255\255\070\001\ -\041\001\255\255\073\001\074\001\255\255\000\000\255\255\255\255\ -\055\001\080\001\057\001\058\001\059\001\255\255\061\001\255\255\ -\255\255\064\001\065\001\060\001\091\001\092\001\063\001\094\001\ -\095\001\096\001\097\001\068\001\000\001\255\255\255\255\003\001\ -\103\001\074\001\105\001\255\255\008\001\108\001\010\001\080\001\ -\111\001\013\001\014\001\090\001\115\001\017\001\255\255\019\001\ -\020\001\021\001\097\001\092\001\024\001\025\001\026\001\096\001\ -\028\001\029\001\000\001\255\255\255\255\003\001\109\001\110\001\ -\255\255\037\001\255\255\108\001\040\001\041\001\111\001\013\001\ -\255\255\255\255\000\000\255\255\048\001\049\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\026\001\255\255\028\001\029\001\ -\060\001\255\255\255\255\063\001\255\255\255\255\255\255\067\001\ -\068\001\255\255\070\001\041\001\255\255\073\001\074\001\255\255\ -\000\000\053\001\255\255\055\001\080\001\057\001\058\001\059\001\ -\255\255\061\001\255\255\255\255\064\001\065\001\060\001\091\001\ -\092\001\255\255\094\001\095\001\096\001\097\001\068\001\000\001\ -\255\255\255\255\003\001\103\001\074\001\105\001\255\255\008\001\ -\108\001\010\001\080\001\111\001\013\001\014\001\090\001\115\001\ -\017\001\255\255\019\001\020\001\021\001\097\001\092\001\024\001\ -\025\001\026\001\096\001\028\001\029\001\255\255\255\255\255\255\ -\255\255\109\001\110\001\255\255\037\001\255\255\108\001\040\001\ -\041\001\111\001\255\255\255\255\255\255\000\000\255\255\048\001\ -\049\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\060\001\255\255\255\255\063\001\255\255\ -\255\255\255\255\067\001\068\001\255\255\070\001\255\255\255\255\ -\073\001\074\001\255\255\255\255\255\255\255\255\255\255\080\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\091\001\092\001\255\255\094\001\095\001\096\001\ -\097\001\255\255\255\255\255\255\255\255\255\255\103\001\000\001\ -\105\001\255\255\003\001\108\001\255\255\255\255\111\001\008\001\ -\255\255\010\001\115\001\255\255\013\001\014\001\255\255\255\255\ -\017\001\255\255\019\001\020\001\021\001\255\255\255\255\024\001\ -\025\001\026\001\255\255\028\001\029\001\000\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\037\001\255\255\255\255\040\001\ -\041\001\255\255\013\001\255\255\255\255\000\000\255\255\048\001\ -\049\001\255\255\255\255\255\255\255\255\255\255\255\255\026\001\ -\255\255\028\001\029\001\060\001\255\255\255\255\063\001\255\255\ -\255\255\255\255\067\001\068\001\255\255\070\001\041\001\255\255\ -\073\001\074\001\255\255\000\000\255\255\255\255\055\001\080\001\ -\057\001\058\001\059\001\255\255\061\001\255\255\255\255\064\001\ -\065\001\060\001\091\001\092\001\255\255\094\001\095\001\096\001\ -\097\001\068\001\000\001\255\255\255\255\003\001\103\001\074\001\ -\105\001\255\255\008\001\108\001\010\001\080\001\111\001\013\001\ -\014\001\090\001\115\001\017\001\255\255\019\001\020\001\021\001\ -\097\001\092\001\024\001\025\001\026\001\096\001\028\001\029\001\ -\000\001\255\255\255\255\255\255\109\001\110\001\255\255\037\001\ -\255\255\108\001\040\001\041\001\111\001\013\001\255\255\255\255\ -\000\000\255\255\048\001\049\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\026\001\255\255\028\001\029\001\060\001\255\255\ -\255\255\063\001\255\255\255\255\255\255\067\001\068\001\255\255\ -\070\001\041\001\255\255\073\001\074\001\255\255\000\000\255\255\ -\255\255\255\255\080\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\060\001\091\001\092\001\255\255\ -\094\001\095\001\096\001\097\001\068\001\000\001\255\255\255\255\ -\003\001\103\001\074\001\105\001\255\255\008\001\108\001\010\001\ -\080\001\111\001\013\001\014\001\255\255\115\001\017\001\255\255\ -\019\001\020\001\021\001\255\255\092\001\024\001\025\001\026\001\ -\096\001\028\001\029\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\037\001\255\255\108\001\040\001\041\001\111\001\ -\255\255\255\255\255\255\000\000\255\255\048\001\049\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\060\001\255\255\255\255\063\001\255\255\255\255\255\255\ -\067\001\068\001\255\255\070\001\255\255\255\255\073\001\074\001\ -\255\255\255\255\255\255\255\255\255\255\080\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\091\001\092\001\255\255\094\001\095\001\096\001\097\001\255\255\ -\255\255\255\255\255\255\255\255\103\001\000\001\105\001\255\255\ -\003\001\108\001\255\255\255\255\111\001\008\001\255\255\010\001\ -\115\001\255\255\013\001\014\001\255\255\255\255\017\001\255\255\ -\019\001\020\001\021\001\255\255\255\255\024\001\025\001\026\001\ -\255\255\028\001\029\001\000\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\037\001\255\255\255\255\040\001\041\001\255\255\ -\013\001\255\255\255\255\000\000\255\255\048\001\049\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\026\001\255\255\028\001\ -\029\001\060\001\255\255\255\255\063\001\255\255\255\255\255\255\ -\067\001\068\001\255\255\070\001\041\001\255\255\073\001\074\001\ -\255\255\000\000\255\255\255\255\255\255\080\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\060\001\ -\091\001\092\001\255\255\094\001\095\001\096\001\097\001\068\001\ -\000\001\255\255\255\255\003\001\103\001\074\001\105\001\255\255\ -\008\001\108\001\010\001\080\001\111\001\013\001\014\001\255\255\ -\115\001\017\001\255\255\019\001\020\001\021\001\255\255\092\001\ -\024\001\025\001\026\001\096\001\028\001\029\001\000\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\037\001\255\255\108\001\ -\040\001\041\001\111\001\013\001\255\255\255\255\000\000\255\255\ -\048\001\049\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\026\001\255\255\028\001\029\001\060\001\255\255\255\255\063\001\ -\255\255\255\255\255\255\067\001\068\001\255\255\070\001\041\001\ -\255\255\073\001\074\001\255\255\255\255\255\255\255\255\255\255\ -\080\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\060\001\091\001\092\001\255\255\094\001\095\001\ -\096\001\097\001\068\001\000\001\255\255\255\255\003\001\103\001\ -\074\001\105\001\255\255\008\001\108\001\010\001\080\001\111\001\ -\013\001\014\001\255\255\115\001\017\001\255\255\019\001\020\001\ -\021\001\255\255\092\001\024\001\025\001\026\001\096\001\028\001\ -\029\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\037\001\255\255\108\001\040\001\041\001\111\001\255\255\255\255\ -\255\255\000\000\255\255\048\001\049\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\060\001\ -\255\255\255\255\063\001\255\255\255\255\255\255\067\001\068\001\ -\255\255\070\001\255\255\255\255\073\001\074\001\255\255\255\255\ -\255\255\255\255\255\255\080\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\091\001\092\001\ -\255\255\094\001\095\001\096\001\097\001\255\255\255\255\255\255\ -\255\255\255\255\103\001\000\001\105\001\255\255\003\001\108\001\ -\255\255\255\255\111\001\008\001\255\255\010\001\115\001\255\255\ -\013\001\014\001\255\255\255\255\017\001\255\255\019\001\020\001\ -\021\001\255\255\255\255\024\001\025\001\026\001\255\255\028\001\ -\029\001\000\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\037\001\255\255\255\255\040\001\041\001\255\255\013\001\255\255\ -\255\255\000\000\255\255\048\001\049\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\026\001\255\255\028\001\029\001\060\001\ -\255\255\255\255\063\001\255\255\255\255\255\255\067\001\068\001\ -\255\255\070\001\041\001\255\255\073\001\074\001\255\255\255\255\ -\255\255\255\255\255\255\080\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\060\001\091\001\092\001\ -\255\255\094\001\095\001\096\001\097\001\068\001\000\001\255\255\ -\255\255\003\001\103\001\074\001\105\001\255\255\008\001\108\001\ -\010\001\080\001\111\001\013\001\014\001\255\255\115\001\017\001\ -\255\255\019\001\020\001\021\001\255\255\092\001\024\001\025\001\ -\026\001\096\001\028\001\029\001\006\001\255\255\008\001\255\255\ -\255\255\255\255\255\255\037\001\255\255\108\001\040\001\041\001\ -\111\001\255\255\255\255\255\255\000\000\255\255\048\001\049\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\060\001\255\255\255\255\063\001\255\255\255\255\ -\255\255\067\001\068\001\255\255\070\001\255\255\255\255\073\001\ -\074\001\255\255\255\255\255\255\255\255\055\001\080\001\057\001\ -\058\001\059\001\255\255\061\001\255\255\255\255\064\001\065\001\ -\255\255\091\001\092\001\255\255\094\001\095\001\096\001\097\001\ -\255\255\000\001\255\255\255\255\003\001\103\001\255\255\105\001\ -\255\255\008\001\108\001\010\001\255\255\111\001\013\001\014\001\ -\090\001\115\001\017\001\255\255\019\001\020\001\021\001\097\001\ -\255\255\024\001\025\001\026\001\255\255\028\001\029\001\255\255\ -\255\255\255\255\255\255\109\001\110\001\255\255\037\001\255\255\ -\255\255\040\001\041\001\255\255\255\255\255\255\255\255\000\000\ -\255\255\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\060\001\255\255\255\255\ -\063\001\255\255\255\255\255\255\067\001\068\001\255\255\070\001\ -\255\255\255\255\073\001\074\001\255\255\255\255\255\255\255\255\ -\255\255\080\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\091\001\092\001\255\255\094\001\ -\095\001\096\001\097\001\255\255\255\255\255\255\255\255\255\255\ -\103\001\000\001\105\001\255\255\003\001\108\001\255\255\255\255\ -\111\001\008\001\255\255\010\001\115\001\255\255\013\001\014\001\ -\255\255\255\255\017\001\255\255\019\001\020\001\021\001\255\255\ -\255\255\024\001\025\001\026\001\255\255\028\001\029\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\037\001\255\255\ -\255\255\040\001\041\001\255\255\255\255\255\255\255\255\000\000\ -\255\255\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\060\001\255\255\255\255\ -\063\001\255\255\255\255\255\255\067\001\068\001\255\255\070\001\ -\255\255\255\255\073\001\074\001\255\255\255\255\255\255\255\255\ -\255\255\080\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\091\001\092\001\255\255\094\001\ -\095\001\096\001\097\001\255\255\000\001\255\255\255\255\003\001\ -\103\001\255\255\105\001\255\255\008\001\108\001\010\001\255\255\ -\111\001\013\001\014\001\255\255\115\001\017\001\255\255\019\001\ -\020\001\021\001\255\255\255\255\024\001\025\001\026\001\255\255\ -\028\001\029\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\037\001\255\255\255\255\040\001\041\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\048\001\049\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\000\000\255\255\255\255\ -\060\001\255\255\255\255\063\001\255\255\255\255\255\255\067\001\ -\068\001\255\255\070\001\255\255\255\255\073\001\074\001\255\255\ -\255\255\255\255\255\255\255\255\080\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\091\001\ -\092\001\255\255\094\001\095\001\096\001\097\001\255\255\000\001\ -\255\255\255\255\003\001\103\001\255\255\105\001\255\255\008\001\ -\108\001\010\001\255\255\111\001\013\001\014\001\255\255\115\001\ -\017\001\255\255\019\001\020\001\021\001\255\255\255\255\024\001\ -\025\001\026\001\255\255\028\001\029\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\037\001\255\255\255\255\040\001\ -\041\001\255\255\255\255\255\255\255\255\255\255\255\255\048\001\ -\049\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\000\000\255\255\255\255\060\001\255\255\255\255\063\001\255\255\ -\255\255\255\255\067\001\068\001\255\255\070\001\255\255\255\255\ -\073\001\074\001\255\255\255\255\255\255\255\255\255\255\080\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\091\001\092\001\255\255\094\001\255\255\096\001\ -\097\001\255\255\255\255\255\255\255\255\255\255\103\001\000\001\ -\105\001\255\255\003\001\108\001\255\255\255\255\111\001\008\001\ -\255\255\010\001\115\001\255\255\013\001\014\001\255\255\255\255\ -\017\001\255\255\019\001\020\001\021\001\255\255\255\255\024\001\ -\255\255\026\001\255\255\028\001\029\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\037\001\255\255\255\255\040\001\ -\041\001\255\255\255\255\255\255\255\255\255\255\255\255\048\001\ -\049\001\255\255\255\255\000\000\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\060\001\255\255\255\255\063\001\255\255\ -\255\255\255\255\067\001\068\001\255\255\070\001\255\255\255\255\ -\073\001\074\001\255\255\255\255\255\255\255\255\255\255\080\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\091\001\092\001\255\255\094\001\095\001\096\001\ -\097\001\255\255\255\255\255\255\255\255\255\255\103\001\255\255\ -\105\001\255\255\255\255\108\001\255\255\000\001\111\001\002\001\ -\003\001\004\001\115\001\255\255\255\255\008\001\255\255\255\255\ -\255\255\255\255\013\001\255\255\255\255\255\255\017\001\018\001\ -\019\001\255\255\255\255\255\255\255\255\000\001\255\255\026\001\ -\027\001\028\001\029\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\036\001\255\255\255\255\255\255\040\001\041\001\255\255\ -\000\000\255\255\255\255\255\255\255\255\048\001\049\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\060\001\255\255\255\255\063\001\255\255\255\255\066\001\ -\067\001\068\001\255\255\070\001\255\255\255\255\073\001\074\001\ -\255\255\255\255\255\255\255\255\055\001\080\001\057\001\058\001\ -\059\001\255\255\061\001\255\255\255\255\064\001\065\001\255\255\ -\091\001\092\001\255\255\094\001\095\001\096\001\255\255\255\255\ -\000\001\100\001\002\001\003\001\004\001\255\255\081\001\255\255\ -\008\001\108\001\255\255\255\255\111\001\013\001\089\001\090\001\ -\115\001\017\001\018\001\019\001\255\255\255\255\097\001\255\255\ -\255\255\255\255\026\001\027\001\028\001\029\001\255\255\255\255\ -\008\001\255\255\109\001\110\001\036\001\255\255\255\255\255\255\ -\255\255\041\001\255\255\000\000\255\255\255\255\255\255\023\001\ -\048\001\049\001\255\255\255\255\255\255\255\255\030\001\255\255\ -\255\255\255\255\255\255\255\255\060\001\255\255\255\255\063\001\ -\255\255\255\255\066\001\067\001\068\001\255\255\070\001\255\255\ -\255\255\073\001\074\001\255\255\255\255\255\255\255\255\055\001\ -\080\001\057\001\058\001\059\001\255\255\061\001\255\255\255\255\ -\064\001\065\001\255\255\091\001\092\001\255\255\094\001\095\001\ -\096\001\097\001\255\255\000\001\255\255\002\001\003\001\004\001\ -\255\255\081\001\255\255\008\001\108\001\255\255\255\255\111\001\ -\013\001\089\001\090\001\115\001\017\001\018\001\019\001\255\255\ -\255\255\097\001\255\255\255\255\255\255\026\001\027\001\028\001\ -\029\001\255\255\106\001\255\255\255\255\109\001\110\001\036\001\ -\255\255\255\255\255\255\255\255\041\001\255\255\000\000\255\255\ -\255\255\255\255\255\255\048\001\049\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\060\001\ -\255\255\255\255\063\001\255\255\255\255\066\001\067\001\068\001\ -\255\255\070\001\255\255\255\255\255\255\074\001\255\255\255\255\ -\255\255\255\255\255\255\080\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\091\001\092\001\ -\255\255\094\001\095\001\096\001\097\001\255\255\255\255\255\255\ -\000\001\255\255\002\001\003\001\004\001\255\255\255\255\108\001\ -\008\001\255\255\111\001\255\255\255\255\013\001\115\001\255\255\ -\255\255\017\001\018\001\019\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\026\001\027\001\028\001\029\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\036\001\255\255\255\255\255\255\ -\255\255\041\001\255\255\000\000\255\255\255\255\255\255\255\255\ -\048\001\049\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\060\001\255\255\255\255\063\001\ -\255\255\255\255\066\001\067\001\068\001\255\255\070\001\255\255\ -\255\255\255\255\074\001\255\255\255\255\255\255\255\255\055\001\ -\080\001\057\001\058\001\059\001\255\255\061\001\255\255\255\255\ -\064\001\065\001\255\255\091\001\092\001\255\255\094\001\095\001\ -\096\001\097\001\074\001\000\001\255\255\002\001\003\001\004\001\ -\255\255\081\001\255\255\008\001\108\001\255\255\255\255\111\001\ -\013\001\089\001\090\001\115\001\017\001\018\001\019\001\000\000\ -\255\255\097\001\255\255\255\255\255\255\026\001\027\001\028\001\ -\029\001\255\255\255\255\255\255\255\255\109\001\110\001\036\001\ -\255\255\255\255\255\255\255\255\041\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\048\001\049\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\060\001\ -\255\255\255\255\063\001\255\255\255\255\066\001\067\001\068\001\ -\255\255\070\001\255\255\255\255\255\255\074\001\255\255\255\255\ -\255\255\000\000\055\001\080\001\057\001\058\001\059\001\255\255\ -\061\001\255\255\255\255\064\001\065\001\255\255\091\001\092\001\ -\255\255\094\001\095\001\096\001\097\001\255\255\000\001\255\255\ -\002\001\003\001\004\001\255\255\081\001\255\255\008\001\108\001\ -\255\255\255\255\111\001\013\001\089\001\090\001\115\001\017\001\ -\018\001\019\001\255\255\255\255\097\001\255\255\255\255\255\255\ -\026\001\027\001\028\001\029\001\255\255\255\255\255\255\108\001\ -\109\001\110\001\036\001\000\000\255\255\255\255\255\255\041\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\048\001\049\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\060\001\255\255\255\255\063\001\255\255\255\255\ -\066\001\067\001\068\001\255\255\070\001\255\255\255\255\255\255\ -\074\001\255\255\255\255\255\255\255\255\255\255\080\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\091\001\092\001\255\255\094\001\095\001\096\001\097\001\ -\255\255\000\000\255\255\000\001\255\255\002\001\003\001\255\255\ -\255\255\255\255\108\001\008\001\255\255\111\001\255\255\255\255\ -\013\001\115\001\255\255\255\255\017\001\018\001\019\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\026\001\027\001\028\001\ -\029\001\255\255\255\255\255\255\255\255\255\255\255\255\036\001\ -\255\255\255\255\255\255\255\255\041\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\048\001\049\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\000\000\255\255\255\255\255\255\060\001\ -\255\255\255\255\063\001\255\255\255\255\066\001\067\001\068\001\ -\255\255\070\001\255\255\255\255\006\001\074\001\008\001\000\001\ -\255\255\255\255\003\001\080\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\013\001\255\255\091\001\092\001\ -\017\001\094\001\095\001\096\001\097\001\255\255\255\255\255\255\ -\255\255\026\001\027\001\028\001\029\001\255\255\255\255\108\001\ -\255\255\255\255\111\001\255\255\255\255\255\255\115\001\255\255\ -\041\001\255\255\255\255\255\255\255\255\055\001\255\255\057\001\ -\058\001\059\001\255\255\061\001\255\255\255\255\064\001\065\001\ -\255\255\000\001\255\255\060\001\003\001\255\255\063\001\255\255\ -\255\255\066\001\067\001\068\001\255\255\255\255\013\001\255\255\ -\073\001\074\001\017\001\255\255\255\255\255\255\255\255\080\001\ -\090\001\255\255\092\001\026\001\027\001\028\001\029\001\097\001\ -\255\255\255\255\255\255\092\001\000\000\094\001\255\255\096\001\ -\097\001\255\255\041\001\109\001\110\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\108\001\255\255\255\255\111\001\255\255\ -\255\255\255\255\115\001\000\001\255\255\060\001\003\001\255\255\ -\063\001\255\255\255\255\066\001\067\001\068\001\255\255\255\255\ -\013\001\255\255\073\001\074\001\017\001\255\255\255\255\255\255\ -\255\255\080\001\255\255\255\255\255\255\026\001\027\001\028\001\ -\029\001\255\255\255\255\255\255\255\255\092\001\255\255\094\001\ -\255\255\096\001\097\001\255\255\041\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\108\001\255\255\255\255\ -\111\001\255\255\255\255\255\255\115\001\255\255\255\255\060\001\ -\255\255\000\001\063\001\255\255\003\001\066\001\067\001\068\001\ -\255\255\255\255\255\255\255\255\073\001\074\001\013\001\255\255\ -\255\255\255\255\017\001\080\001\019\001\255\255\255\255\255\255\ -\255\255\255\255\000\000\026\001\027\001\028\001\029\001\092\001\ -\255\255\094\001\255\255\096\001\097\001\255\255\255\255\255\255\ -\255\255\255\255\041\001\255\255\255\255\255\255\255\255\108\001\ -\255\255\255\255\111\001\255\255\255\255\255\255\115\001\255\255\ -\255\255\255\255\255\255\000\001\255\255\060\001\003\001\255\255\ -\063\001\255\255\255\255\255\255\067\001\068\001\255\255\255\255\ -\013\001\255\255\073\001\074\001\017\001\255\255\255\255\255\255\ -\255\255\080\001\255\255\255\255\255\255\026\001\027\001\028\001\ -\029\001\255\255\255\255\255\255\255\255\092\001\255\255\094\001\ -\255\255\096\001\097\001\255\255\041\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\108\001\255\255\255\255\ -\111\001\000\000\255\255\255\255\115\001\255\255\255\255\060\001\ -\255\255\255\255\063\001\255\255\255\255\255\255\067\001\068\001\ -\255\255\255\255\255\255\255\255\073\001\074\001\055\001\255\255\ -\057\001\058\001\059\001\080\001\061\001\255\255\063\001\064\001\ -\065\001\255\255\255\255\255\255\255\255\255\255\255\255\092\001\ -\255\255\094\001\255\255\096\001\097\001\078\001\255\255\255\255\ -\081\001\255\255\255\255\255\255\255\255\255\255\255\255\108\001\ -\089\001\090\001\111\001\255\255\000\001\255\255\115\001\003\001\ -\097\001\005\001\006\001\007\001\008\001\255\255\255\255\011\001\ -\012\001\013\001\255\255\255\255\109\001\110\001\255\255\019\001\ -\255\255\255\255\255\255\023\001\255\255\255\255\026\001\255\255\ -\028\001\029\001\030\001\031\001\032\001\033\001\034\001\035\001\ -\036\001\255\255\255\255\039\001\040\001\041\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\048\001\049\001\050\001\051\001\ -\052\001\053\001\054\001\055\001\056\001\057\001\058\001\059\001\ -\060\001\061\001\000\000\063\001\064\001\065\001\255\255\067\001\ -\068\001\069\001\070\001\071\001\072\001\255\255\074\001\075\001\ -\076\001\077\001\078\001\255\255\080\001\081\001\255\255\255\255\ -\084\001\085\001\255\255\087\001\088\001\089\001\090\001\091\001\ -\092\001\093\001\255\255\095\001\096\001\097\001\255\255\099\001\ -\255\255\101\001\102\001\255\255\104\001\255\255\106\001\107\001\ -\108\001\109\001\110\001\111\001\112\001\255\255\114\001\005\001\ -\006\001\007\001\255\255\255\255\255\255\011\001\012\001\013\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\028\001\029\001\ -\030\001\031\001\032\001\033\001\034\001\255\255\255\255\255\255\ -\255\255\039\001\255\255\041\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\050\001\255\255\052\001\053\001\ -\054\001\055\001\056\001\255\255\255\255\059\001\060\001\255\255\ -\255\255\063\001\064\001\065\001\255\255\000\000\068\001\069\001\ -\255\255\071\001\072\001\255\255\074\001\255\255\076\001\255\255\ -\078\001\255\255\080\001\255\255\255\255\255\255\084\001\085\001\ -\255\255\087\001\255\255\255\255\255\255\255\255\005\001\006\001\ -\007\001\255\255\096\001\097\001\011\001\012\001\013\001\101\001\ -\255\255\255\255\255\255\255\255\106\001\107\001\108\001\109\001\ -\110\001\111\001\255\255\255\255\114\001\028\001\029\001\030\001\ -\031\001\032\001\033\001\034\001\255\255\255\255\255\255\255\255\ -\039\001\255\255\041\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\050\001\255\255\052\001\053\001\054\001\ -\055\001\056\001\255\255\255\255\059\001\060\001\255\255\255\255\ -\063\001\064\001\065\001\255\255\255\255\068\001\069\001\255\255\ -\071\001\072\001\255\255\074\001\255\255\076\001\255\255\078\001\ -\255\255\080\001\255\255\000\000\255\255\084\001\085\001\255\255\ -\087\001\000\000\055\001\255\255\057\001\058\001\059\001\255\255\ -\061\001\255\255\097\001\064\001\065\001\255\255\101\001\255\255\ -\255\255\255\255\255\255\106\001\107\001\108\001\109\001\110\001\ -\111\001\255\255\255\255\114\001\081\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\089\001\090\001\255\255\005\001\ -\006\001\007\001\255\255\255\255\097\001\011\001\012\001\013\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\109\001\110\001\255\255\255\255\255\255\255\255\028\001\029\001\ -\030\001\031\001\032\001\033\001\034\001\255\255\255\255\255\255\ -\255\255\039\001\255\255\041\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\050\001\255\255\052\001\053\001\ -\054\001\055\001\056\001\255\255\255\255\059\001\060\001\255\255\ -\255\255\063\001\064\001\065\001\255\255\255\255\068\001\069\001\ -\255\255\071\001\072\001\255\255\074\001\000\000\076\001\255\255\ -\078\001\255\255\080\001\255\255\255\255\255\255\084\001\085\001\ -\255\255\087\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\097\001\255\255\255\255\255\255\101\001\ -\255\255\255\255\255\255\255\255\106\001\107\001\108\001\109\001\ -\110\001\111\001\255\255\255\255\114\001\000\001\255\255\255\255\ -\255\255\004\001\255\255\006\001\255\255\008\001\255\255\010\001\ -\255\255\012\001\255\255\014\001\015\001\255\255\017\001\018\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\027\001\028\001\255\255\030\001\031\001\000\000\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\050\001\ -\051\001\052\001\053\001\255\255\055\001\056\001\255\255\255\255\ -\059\001\255\255\255\255\255\255\255\255\064\001\065\001\066\001\ -\255\255\255\255\255\255\255\255\071\001\255\255\073\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\081\001\255\255\ -\255\255\084\001\255\255\255\255\255\255\255\255\089\001\000\000\ -\091\001\092\001\255\255\094\001\095\001\255\255\097\001\255\255\ -\255\255\255\255\101\001\000\001\255\255\104\001\255\255\106\001\ -\255\255\000\001\109\001\110\001\255\255\004\001\113\001\006\001\ -\013\001\008\001\255\255\010\001\255\255\012\001\255\255\014\001\ -\015\001\255\255\017\001\018\001\255\255\026\001\255\255\028\001\ -\029\001\255\255\255\255\255\255\027\001\255\255\255\255\030\001\ -\031\001\255\255\255\255\255\255\041\001\255\255\255\255\255\255\ -\255\255\000\000\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\050\001\051\001\255\255\053\001\060\001\ -\055\001\056\001\255\255\255\255\059\001\255\255\067\001\068\001\ -\255\255\064\001\065\001\066\001\255\255\074\001\255\255\255\255\ -\071\001\255\255\073\001\080\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\081\001\255\255\255\255\084\001\255\255\092\001\ -\255\255\255\255\089\001\096\001\091\001\092\001\255\255\094\001\ -\095\001\255\255\097\001\000\000\255\255\255\255\101\001\108\001\ -\255\255\104\001\111\001\106\001\255\255\000\001\109\001\110\001\ -\003\001\004\001\113\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\013\001\014\001\255\255\255\255\255\255\255\255\ -\019\001\255\255\255\255\255\255\255\255\255\255\255\255\026\001\ -\255\255\028\001\029\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\041\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\048\001\049\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\060\001\255\255\255\255\063\001\255\255\255\255\066\001\ -\067\001\068\001\255\255\070\001\255\255\000\001\255\255\074\001\ -\003\001\004\001\000\000\255\255\255\255\080\001\255\255\255\255\ -\255\255\255\255\013\001\014\001\255\255\255\255\255\255\255\255\ -\019\001\092\001\255\255\094\001\255\255\096\001\097\001\026\001\ -\255\255\028\001\029\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\108\001\255\255\255\255\111\001\255\255\041\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\048\001\049\001\255\255\ -\255\255\255\255\255\255\000\000\255\255\255\255\255\255\000\001\ -\255\255\060\001\003\001\004\001\063\001\255\255\255\255\066\001\ -\067\001\068\001\255\255\070\001\013\001\014\001\255\255\074\001\ -\255\255\255\255\019\001\255\255\255\255\080\001\255\255\255\255\ -\255\255\026\001\255\255\028\001\029\001\255\255\255\255\255\255\ -\255\255\092\001\255\255\094\001\255\255\096\001\097\001\255\255\ -\041\001\255\255\255\255\255\255\255\255\000\000\255\255\048\001\ -\049\001\108\001\255\255\255\255\111\001\255\255\255\255\255\255\ -\255\255\000\001\255\255\060\001\003\001\004\001\063\001\255\255\ -\255\255\255\255\067\001\068\001\255\255\070\001\013\001\014\001\ -\255\255\074\001\255\255\255\255\019\001\255\255\255\255\080\001\ -\255\255\255\255\255\255\026\001\255\255\028\001\029\001\255\255\ -\255\255\255\255\255\255\092\001\255\255\094\001\255\255\096\001\ -\097\001\255\255\041\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\048\001\049\001\108\001\255\255\255\255\111\001\255\255\ -\255\255\255\255\255\255\000\001\255\255\060\001\003\001\004\001\ -\063\001\000\000\255\255\255\255\067\001\068\001\255\255\070\001\ -\013\001\014\001\255\255\074\001\255\255\255\255\019\001\255\255\ -\255\255\080\001\255\255\255\255\255\255\026\001\255\255\028\001\ -\029\001\255\255\255\255\255\255\255\255\092\001\255\255\094\001\ -\255\255\096\001\097\001\255\255\041\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\048\001\049\001\108\001\255\255\255\255\ -\111\001\255\255\255\255\255\255\255\255\255\255\255\255\060\001\ -\255\255\255\255\063\001\000\000\255\255\255\255\067\001\068\001\ -\255\255\070\001\255\255\255\255\255\255\074\001\055\001\255\255\ -\057\001\058\001\059\001\080\001\061\001\255\255\255\255\064\001\ -\065\001\255\255\000\001\255\255\255\255\003\001\255\255\092\001\ -\255\255\094\001\008\001\096\001\097\001\255\255\255\255\013\001\ -\081\001\255\255\255\255\255\255\255\255\019\001\255\255\108\001\ -\089\001\090\001\111\001\255\255\026\001\255\255\028\001\029\001\ -\097\001\255\255\255\255\255\255\255\255\000\000\255\255\255\255\ -\255\255\255\255\040\001\041\001\109\001\110\001\255\255\255\255\ -\255\255\255\255\255\255\000\001\255\255\255\255\003\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\060\001\255\255\ -\013\001\063\001\255\255\255\255\066\001\067\001\068\001\255\255\ -\255\255\255\255\255\255\073\001\074\001\026\001\027\001\028\001\ -\029\001\255\255\080\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\041\001\255\255\092\001\000\000\ -\255\255\255\255\096\001\097\001\255\255\000\001\100\001\255\255\ -\003\001\255\255\255\255\255\255\255\255\255\255\108\001\060\001\ -\255\255\111\001\013\001\064\001\255\255\066\001\067\001\068\001\ -\255\255\255\255\255\255\255\255\073\001\074\001\255\255\026\001\ -\027\001\028\001\029\001\080\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\041\001\092\001\ -\255\255\094\001\255\255\096\001\097\001\255\255\255\255\100\001\ -\255\255\000\000\255\255\255\255\255\255\255\255\255\255\108\001\ -\109\001\060\001\111\001\255\255\255\255\064\001\255\255\066\001\ -\067\001\068\001\255\255\255\255\255\255\255\255\073\001\074\001\ -\255\255\000\001\255\255\255\255\003\001\080\001\255\255\255\255\ -\255\255\008\001\255\255\255\255\255\255\255\255\013\001\255\255\ -\255\255\092\001\255\255\094\001\019\001\096\001\097\001\255\255\ -\255\255\100\001\000\000\026\001\255\255\028\001\029\001\255\255\ -\255\255\108\001\109\001\255\255\111\001\255\255\255\255\255\255\ -\255\255\040\001\041\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\000\001\255\255\060\001\003\001\255\255\ -\063\001\255\255\255\255\066\001\067\001\068\001\255\255\255\255\ -\013\001\255\255\073\001\074\001\255\255\255\255\019\001\000\000\ -\255\255\080\001\255\255\255\255\255\255\026\001\027\001\028\001\ -\029\001\255\255\255\255\255\255\255\255\092\001\255\255\255\255\ -\255\255\096\001\097\001\255\255\041\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\048\001\255\255\108\001\255\255\255\255\ -\111\001\255\255\255\255\255\255\255\255\000\001\255\255\060\001\ -\003\001\255\255\063\001\255\255\255\255\255\255\067\001\068\001\ -\255\255\070\001\013\001\255\255\000\000\074\001\255\255\255\255\ -\019\001\255\255\255\255\080\001\255\255\255\255\255\255\026\001\ -\255\255\028\001\029\001\255\255\255\255\255\255\255\255\092\001\ -\255\255\094\001\255\255\096\001\097\001\040\001\041\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\048\001\049\001\108\001\ -\255\255\255\255\111\001\255\255\255\255\255\255\255\255\000\001\ -\255\255\060\001\003\001\255\255\063\001\255\255\255\255\008\001\ -\255\255\068\001\255\255\070\001\013\001\255\255\255\255\074\001\ -\255\255\255\255\019\001\255\255\255\255\080\001\255\255\255\255\ -\255\255\026\001\255\255\028\001\029\001\255\255\255\255\000\000\ -\255\255\092\001\255\255\255\255\255\255\096\001\097\001\255\255\ -\041\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\108\001\255\255\255\255\111\001\255\255\255\255\255\255\ -\255\255\000\001\255\255\060\001\003\001\255\255\063\001\255\255\ -\255\255\255\255\067\001\068\001\255\255\255\255\013\001\255\255\ -\255\255\074\001\255\255\255\255\019\001\255\255\255\255\080\001\ -\255\255\255\255\255\255\026\001\000\000\028\001\029\001\255\255\ -\255\255\255\255\255\255\092\001\255\255\000\000\255\255\096\001\ -\097\001\255\255\041\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\000\001\108\001\255\255\003\001\111\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\060\001\255\255\013\001\ -\063\001\255\255\255\255\255\255\067\001\068\001\255\255\255\255\ -\255\255\255\255\255\255\074\001\026\001\255\255\028\001\029\001\ -\255\255\080\001\255\255\255\255\255\255\255\255\255\255\000\000\ -\255\255\255\255\040\001\041\001\255\255\092\001\255\255\255\255\ -\255\255\096\001\097\001\255\255\255\255\255\255\255\255\000\001\ -\255\255\255\255\003\001\255\255\255\255\108\001\060\001\255\255\ -\111\001\063\001\255\255\255\255\013\001\067\001\068\001\255\255\ -\255\255\255\255\019\001\255\255\074\001\255\255\255\255\255\255\ -\255\255\026\001\080\001\028\001\029\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\000\000\255\255\092\001\255\255\ -\041\001\255\255\096\001\097\001\255\255\000\000\255\255\255\255\ -\255\255\255\255\255\255\255\255\000\001\255\255\108\001\003\001\ -\255\255\111\001\255\255\060\001\255\255\255\255\063\001\255\255\ -\255\255\013\001\067\001\068\001\255\255\255\255\255\255\019\001\ -\255\255\074\001\255\255\255\255\255\255\255\255\026\001\080\001\ -\028\001\029\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\092\001\255\255\041\001\255\255\096\001\ -\097\001\255\255\000\000\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\108\001\255\255\255\255\111\001\255\255\ -\060\001\255\255\255\255\063\001\255\255\255\255\255\255\067\001\ -\068\001\255\255\255\255\255\255\255\255\255\255\074\001\000\001\ -\255\255\255\255\003\001\255\255\080\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\013\001\255\255\255\255\255\255\ -\092\001\255\255\019\001\255\255\096\001\097\001\255\255\000\000\ -\255\255\026\001\255\255\028\001\029\001\255\255\255\255\255\255\ -\108\001\255\255\255\255\111\001\255\255\255\255\255\255\255\255\ -\041\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\000\001\255\255\255\255\003\001\ -\255\255\255\255\255\255\060\001\255\255\000\001\063\001\255\255\ -\255\255\013\001\067\001\068\001\255\255\008\001\255\255\019\001\ -\000\000\074\001\013\001\255\255\255\255\255\255\026\001\080\001\ -\028\001\029\001\000\000\255\255\255\255\255\255\255\255\026\001\ -\255\255\028\001\029\001\092\001\255\255\041\001\255\255\096\001\ -\097\001\255\255\255\255\255\255\255\255\255\255\041\001\255\255\ -\255\255\255\255\255\255\108\001\255\255\255\255\111\001\000\001\ -\060\001\255\255\003\001\063\001\255\255\255\255\255\255\067\001\ -\068\001\060\001\255\255\255\255\013\001\255\255\074\001\066\001\ -\067\001\068\001\019\001\255\255\080\001\255\255\255\255\074\001\ -\255\255\026\001\255\255\028\001\029\001\080\001\255\255\255\255\ -\092\001\255\255\255\255\000\000\096\001\097\001\255\255\255\255\ -\041\001\092\001\255\255\255\255\255\255\096\001\255\255\255\255\ -\108\001\255\255\255\255\111\001\000\001\255\255\255\255\255\255\ -\255\255\108\001\255\255\060\001\111\001\000\001\063\001\255\255\ -\003\001\013\001\067\001\068\001\255\255\255\255\255\255\255\255\ -\255\255\074\001\013\001\255\255\255\255\255\255\026\001\080\001\ -\028\001\029\001\255\255\255\255\000\000\255\255\255\255\026\001\ -\255\255\028\001\029\001\092\001\255\255\041\001\000\000\096\001\ -\097\001\255\255\255\255\255\255\255\255\040\001\041\001\255\255\ -\255\255\255\255\255\255\108\001\255\255\255\255\111\001\255\255\ -\060\001\255\255\000\001\063\001\255\255\003\001\066\001\067\001\ -\068\001\060\001\255\255\255\255\063\001\255\255\074\001\013\001\ -\255\255\068\001\255\255\255\255\080\001\255\255\255\255\074\001\ -\255\255\255\255\255\255\255\255\026\001\080\001\028\001\029\001\ -\092\001\255\255\255\255\255\255\096\001\097\001\255\255\255\255\ -\255\255\092\001\255\255\041\001\000\000\096\001\097\001\255\255\ -\108\001\255\255\255\255\111\001\255\255\255\255\255\255\000\001\ -\255\255\108\001\003\001\255\255\111\001\255\255\060\001\255\255\ -\255\255\063\001\255\255\255\255\013\001\067\001\068\001\255\255\ -\255\255\255\255\255\255\255\255\074\001\255\255\255\255\255\255\ -\255\255\026\001\080\001\028\001\029\001\255\255\255\255\255\255\ -\000\000\255\255\255\255\255\255\255\255\255\255\092\001\255\255\ -\041\001\000\000\096\001\097\001\255\255\255\255\255\255\255\255\ -\000\001\255\255\255\255\255\255\255\255\255\255\108\001\255\255\ -\008\001\111\001\000\001\060\001\255\255\013\001\063\001\255\255\ -\255\255\255\255\067\001\068\001\255\255\255\255\255\255\013\001\ -\255\255\074\001\026\001\255\255\028\001\029\001\255\255\080\001\ -\255\255\255\255\255\255\255\255\026\001\255\255\028\001\029\001\ -\255\255\041\001\000\000\092\001\255\255\255\255\255\255\096\001\ -\097\001\255\255\255\255\041\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\108\001\060\001\255\255\111\001\063\001\ -\255\255\255\255\255\255\067\001\068\001\255\255\060\001\255\255\ -\255\255\063\001\074\001\000\001\255\255\067\001\068\001\255\255\ -\080\001\255\255\255\255\255\255\074\001\255\255\000\000\255\255\ -\013\001\255\255\080\001\255\255\092\001\255\255\255\255\255\255\ -\096\001\097\001\255\255\255\255\255\255\026\001\092\001\028\001\ -\029\001\255\255\096\001\097\001\108\001\255\255\255\255\111\001\ -\255\255\255\255\255\255\255\255\041\001\255\255\108\001\255\255\ -\255\255\111\001\255\255\255\255\000\001\255\255\255\255\003\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\000\001\060\001\ -\255\255\013\001\063\001\255\255\255\255\255\255\067\001\068\001\ -\255\255\255\255\255\255\013\001\255\255\074\001\026\001\255\255\ -\028\001\029\001\255\255\080\001\255\255\255\255\255\255\255\255\ -\026\001\255\255\028\001\029\001\255\255\041\001\255\255\092\001\ -\255\255\255\255\255\255\096\001\097\001\255\255\255\255\041\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\108\001\ -\060\001\255\255\111\001\063\001\255\255\255\255\255\255\255\255\ -\068\001\255\255\060\001\255\255\000\001\063\001\074\001\255\255\ -\255\255\067\001\068\001\255\255\080\001\255\255\255\255\255\255\ -\074\001\013\001\255\255\255\255\255\255\255\255\080\001\255\255\ -\092\001\255\255\255\255\255\255\096\001\097\001\026\001\255\255\ -\028\001\029\001\092\001\255\255\255\255\255\255\096\001\097\001\ -\108\001\255\255\255\255\111\001\255\255\041\001\255\255\255\255\ -\000\001\255\255\108\001\255\255\255\255\111\001\255\255\255\255\ -\255\255\000\001\255\255\255\255\255\255\013\001\255\255\255\255\ -\060\001\255\255\255\255\063\001\255\255\255\255\013\001\067\001\ -\068\001\255\255\026\001\255\255\028\001\029\001\074\001\255\255\ -\255\255\255\255\255\255\026\001\080\001\028\001\029\001\255\255\ -\255\255\041\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\092\001\255\255\041\001\255\255\096\001\097\001\255\255\255\255\ -\255\255\255\255\000\001\255\255\060\001\255\255\255\255\063\001\ -\108\001\255\255\255\255\111\001\068\001\060\001\255\255\013\001\ -\063\001\255\255\074\001\255\255\255\255\068\001\255\255\255\255\ -\080\001\255\255\255\255\074\001\026\001\255\255\028\001\029\001\ -\255\255\080\001\255\255\255\255\092\001\255\255\255\255\255\255\ -\096\001\097\001\255\255\041\001\255\255\092\001\000\001\255\255\ -\255\255\096\001\097\001\255\255\108\001\255\255\255\255\111\001\ -\255\255\255\255\255\255\013\001\255\255\108\001\060\001\255\255\ -\111\001\063\001\255\255\255\255\255\255\255\255\068\001\255\255\ -\026\001\255\255\028\001\029\001\074\001\255\255\255\255\255\255\ -\255\255\255\255\080\001\255\255\255\255\255\255\255\255\041\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\092\001\255\255\ -\255\255\255\255\096\001\097\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\060\001\255\255\255\255\063\001\108\001\255\255\ -\255\255\111\001\068\001\255\255\255\255\255\255\255\255\255\255\ -\074\001\255\255\255\255\255\255\255\255\255\255\080\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\092\001\000\001\255\255\255\255\096\001\097\001\ -\005\001\006\001\007\001\008\001\255\255\255\255\011\001\012\001\ -\013\001\014\001\108\001\255\255\255\255\111\001\019\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\026\001\255\255\028\001\ -\029\001\030\001\031\001\032\001\033\001\034\001\035\001\255\255\ -\255\255\255\255\039\001\255\255\041\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\048\001\049\001\050\001\051\001\052\001\ -\053\001\054\001\055\001\056\001\255\255\255\255\059\001\060\001\ -\255\255\255\255\063\001\064\001\065\001\066\001\255\255\068\001\ -\069\001\070\001\071\001\072\001\255\255\074\001\255\255\076\001\ -\077\001\078\001\255\255\080\001\081\001\255\255\255\255\084\001\ -\085\001\255\255\087\001\255\255\089\001\090\001\255\255\092\001\ -\093\001\255\255\255\255\096\001\097\001\255\255\099\001\255\255\ -\101\001\102\001\255\255\104\001\255\255\106\001\107\001\108\001\ -\109\001\110\001\111\001\112\001\000\001\114\001\255\255\255\255\ -\255\255\005\001\006\001\007\001\008\001\255\255\255\255\011\001\ -\012\001\255\255\255\255\255\255\255\255\255\255\255\255\019\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\026\001\255\255\ -\028\001\255\255\030\001\031\001\032\001\033\001\034\001\035\001\ -\255\255\255\255\255\255\039\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\048\001\049\001\050\001\051\001\ -\052\001\053\001\054\001\055\001\056\001\255\255\255\255\059\001\ -\060\001\255\255\255\255\063\001\064\001\065\001\255\255\255\255\ -\068\001\069\001\070\001\071\001\072\001\255\255\074\001\255\255\ -\076\001\077\001\078\001\255\255\255\255\081\001\255\255\255\255\ -\084\001\085\001\255\255\087\001\255\255\089\001\090\001\255\255\ -\255\255\093\001\255\255\255\255\255\255\097\001\255\255\099\001\ -\255\255\101\001\102\001\255\255\104\001\255\255\106\001\107\001\ -\255\255\109\001\110\001\111\001\112\001\255\255\114\001\000\001\ -\001\001\002\001\255\255\255\255\005\001\006\001\007\001\255\255\ -\009\001\255\255\011\001\012\001\255\255\255\255\015\001\016\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\027\001\255\255\255\255\030\001\031\001\032\001\ -\033\001\034\001\255\255\036\001\255\255\255\255\039\001\255\255\ -\255\255\042\001\043\001\044\001\045\001\046\001\047\001\255\255\ -\255\255\050\001\255\255\052\001\053\001\054\001\055\001\056\001\ -\255\255\255\255\059\001\255\255\061\001\255\255\063\001\064\001\ -\065\001\255\255\255\255\255\255\069\001\255\255\071\001\072\001\ -\255\255\074\001\255\255\076\001\255\255\078\001\255\255\255\255\ -\255\255\082\001\083\001\084\001\085\001\086\001\087\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\094\001\255\255\255\255\ -\255\255\098\001\255\255\100\001\101\001\255\255\255\255\255\255\ -\255\255\106\001\107\001\255\255\109\001\110\001\000\001\001\001\ -\002\001\114\001\255\255\005\001\006\001\007\001\255\255\009\001\ -\255\255\011\001\012\001\255\255\255\255\015\001\016\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\027\001\255\255\255\255\030\001\031\001\032\001\033\001\ -\034\001\255\255\036\001\255\255\255\255\039\001\255\255\255\255\ -\042\001\043\001\044\001\045\001\046\001\047\001\255\255\255\255\ -\050\001\255\255\052\001\053\001\054\001\055\001\056\001\255\255\ -\255\255\059\001\255\255\061\001\255\255\063\001\064\001\065\001\ -\255\255\255\255\255\255\069\001\255\255\071\001\072\001\255\255\ -\074\001\255\255\076\001\255\255\078\001\255\255\255\255\255\255\ -\082\001\083\001\084\001\085\001\086\001\087\001\255\255\255\255\ -\255\255\255\255\255\255\055\001\094\001\057\001\058\001\059\001\ -\098\001\061\001\100\001\101\001\064\001\065\001\255\255\255\255\ -\106\001\107\001\255\255\109\001\110\001\000\001\255\255\255\255\ -\114\001\255\255\005\001\006\001\007\001\081\001\255\255\255\255\ -\011\001\012\001\013\001\255\255\255\255\089\001\090\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\097\001\255\255\026\001\ -\255\255\028\001\029\001\030\001\031\001\032\001\033\001\034\001\ -\255\255\109\001\110\001\255\255\039\001\255\255\041\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\050\001\ -\255\255\052\001\053\001\054\001\055\001\056\001\255\255\255\255\ -\059\001\060\001\255\255\255\255\063\001\064\001\065\001\255\255\ -\255\255\068\001\069\001\255\255\071\001\072\001\255\255\074\001\ -\255\255\076\001\255\255\078\001\255\255\080\001\255\255\255\255\ -\255\255\084\001\085\001\000\001\087\001\255\255\255\255\255\255\ -\005\001\006\001\007\001\255\255\255\255\096\001\011\001\012\001\ -\255\255\255\255\101\001\255\255\255\255\255\255\255\255\106\001\ -\107\001\108\001\109\001\110\001\111\001\255\255\255\255\114\001\ -\255\255\030\001\031\001\032\001\033\001\034\001\255\255\255\255\ -\255\255\255\255\039\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\050\001\255\255\052\001\ -\053\001\054\001\055\001\056\001\255\255\255\255\059\001\255\255\ -\255\255\255\255\063\001\064\001\065\001\255\255\255\255\255\255\ -\069\001\255\255\071\001\072\001\255\255\255\255\255\255\076\001\ -\255\255\078\001\255\255\255\255\255\255\255\255\255\255\084\001\ -\085\001\000\001\087\001\255\255\255\255\255\255\005\001\006\001\ -\007\001\094\001\255\255\255\255\011\001\012\001\255\255\255\255\ -\101\001\255\255\255\255\255\255\255\255\106\001\107\001\255\255\ -\109\001\110\001\255\255\255\255\255\255\114\001\255\255\030\001\ -\031\001\032\001\033\001\034\001\255\255\255\255\255\255\255\255\ -\039\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\050\001\255\255\052\001\053\001\054\001\ -\055\001\056\001\255\255\255\255\059\001\255\255\255\255\255\255\ -\063\001\064\001\065\001\255\255\255\255\255\255\069\001\255\255\ -\071\001\072\001\255\255\255\255\255\255\076\001\255\255\078\001\ -\255\255\255\255\255\255\255\255\255\255\084\001\085\001\000\001\ -\087\001\255\255\255\255\255\255\005\001\006\001\007\001\094\001\ -\255\255\255\255\011\001\012\001\255\255\255\255\101\001\255\255\ -\255\255\255\255\255\255\106\001\107\001\255\255\109\001\110\001\ -\255\255\255\255\255\255\114\001\255\255\030\001\031\001\032\001\ -\033\001\034\001\255\255\255\255\255\255\255\255\039\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\050\001\255\255\052\001\053\001\054\001\055\001\056\001\ -\255\255\255\255\059\001\255\255\255\255\255\255\063\001\064\001\ -\065\001\255\255\255\255\255\255\069\001\255\255\071\001\072\001\ -\255\255\255\255\255\255\076\001\255\255\078\001\255\255\255\255\ -\255\255\255\255\255\255\084\001\085\001\000\001\087\001\255\255\ -\255\255\255\255\005\001\006\001\007\001\094\001\255\255\255\255\ -\011\001\012\001\255\255\255\255\101\001\255\255\255\255\255\255\ -\255\255\106\001\107\001\255\255\109\001\110\001\255\255\255\255\ -\255\255\114\001\255\255\030\001\031\001\032\001\033\001\034\001\ -\255\255\255\255\255\255\255\255\039\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\050\001\ -\255\255\052\001\053\001\054\001\055\001\056\001\255\255\255\255\ -\059\001\255\255\255\255\255\255\063\001\064\001\065\001\255\255\ -\255\255\255\255\069\001\255\255\071\001\072\001\255\255\255\255\ -\255\255\076\001\255\255\078\001\255\255\255\255\255\255\255\255\ -\255\255\084\001\085\001\255\255\087\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\094\001\003\001\004\001\005\001\255\255\ -\255\255\255\255\101\001\255\255\011\001\255\255\013\001\106\001\ -\107\001\255\255\109\001\110\001\019\001\020\001\021\001\114\001\ -\255\255\024\001\025\001\026\001\255\255\028\001\029\001\030\001\ -\255\255\032\001\033\001\034\001\035\001\255\255\255\255\255\255\ -\039\001\040\001\041\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\048\001\049\001\255\255\255\255\052\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\063\001\064\001\255\255\255\255\255\255\000\001\069\001\070\001\ -\255\255\004\001\255\255\074\001\075\001\076\001\077\001\078\001\ -\079\001\080\001\255\255\082\001\255\255\255\255\017\001\255\255\ -\019\001\088\001\255\255\022\001\255\255\255\255\093\001\026\001\ -\027\001\255\255\255\255\255\255\099\001\255\255\255\255\102\001\ -\103\001\036\001\105\001\106\001\107\001\108\001\109\001\255\255\ -\111\001\112\001\113\001\114\001\115\001\048\001\049\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\060\001\255\255\255\255\255\255\064\001\255\255\066\001\ -\067\001\068\001\255\255\070\001\255\255\255\255\073\001\255\255\ -\255\255\255\255\000\001\001\001\002\001\255\255\255\255\255\255\ -\006\001\007\001\255\255\009\001\255\255\255\255\012\001\090\001\ -\091\001\015\001\016\001\255\255\095\001\255\255\097\001\255\255\ -\255\255\100\001\255\255\255\255\255\255\027\001\028\001\255\255\ -\030\001\031\001\109\001\255\255\111\001\255\255\036\001\255\255\ -\255\255\255\255\255\255\255\255\042\001\043\001\044\001\045\001\ -\046\001\047\001\255\255\255\255\050\001\255\255\052\001\053\001\ -\255\255\055\001\056\001\255\255\255\255\059\001\255\255\061\001\ -\255\255\255\255\064\001\065\001\255\255\255\255\255\255\255\255\ -\255\255\071\001\072\001\255\255\074\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\082\001\083\001\084\001\085\001\ -\086\001\087\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\094\001\255\255\255\255\097\001\098\001\255\255\100\001\101\001\ -\255\255\255\255\255\255\255\255\106\001\255\255\108\001\109\001\ -\110\001\000\001\001\001\002\001\255\255\255\255\255\255\006\001\ -\007\001\255\255\009\001\255\255\255\255\012\001\255\255\255\255\ -\015\001\016\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\027\001\028\001\255\255\030\001\ -\031\001\255\255\255\255\255\255\255\255\036\001\255\255\255\255\ -\255\255\255\255\255\255\042\001\043\001\044\001\045\001\046\001\ -\047\001\255\255\255\255\050\001\255\255\052\001\053\001\255\255\ -\055\001\056\001\255\255\255\255\059\001\255\255\061\001\255\255\ -\255\255\064\001\065\001\255\255\255\255\255\255\255\255\255\255\ -\071\001\072\001\255\255\074\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\082\001\083\001\084\001\085\001\086\001\ -\087\001\255\255\255\255\255\255\255\255\255\255\255\255\094\001\ -\255\255\255\255\097\001\098\001\255\255\100\001\101\001\255\255\ -\255\255\255\255\255\255\106\001\255\255\108\001\109\001\110\001\ -\000\001\001\001\002\001\255\255\255\255\255\255\006\001\007\001\ -\255\255\009\001\255\255\255\255\012\001\255\255\255\255\015\001\ -\016\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\027\001\028\001\255\255\030\001\031\001\ -\255\255\255\255\255\255\255\255\036\001\255\255\255\255\255\255\ -\255\255\255\255\042\001\043\001\044\001\045\001\046\001\047\001\ -\255\255\255\255\050\001\255\255\052\001\053\001\255\255\055\001\ -\056\001\255\255\255\255\059\001\255\255\061\001\255\255\255\255\ -\064\001\065\001\255\255\255\255\255\255\255\255\255\255\071\001\ -\072\001\255\255\074\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\082\001\083\001\084\001\085\001\086\001\087\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\094\001\255\255\ -\255\255\097\001\098\001\255\255\100\001\101\001\255\255\255\255\ -\255\255\255\255\106\001\255\255\108\001\109\001\110\001\000\001\ -\001\001\002\001\255\255\255\255\255\255\006\001\007\001\255\255\ -\009\001\255\255\255\255\012\001\255\255\255\255\015\001\016\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\027\001\028\001\255\255\030\001\031\001\255\255\ -\255\255\255\255\255\255\036\001\255\255\255\255\255\255\255\255\ -\255\255\042\001\043\001\044\001\045\001\046\001\047\001\255\255\ -\255\255\050\001\255\255\052\001\053\001\255\255\055\001\056\001\ -\255\255\255\255\059\001\255\255\061\001\255\255\255\255\064\001\ -\065\001\255\255\255\255\255\255\255\255\255\255\071\001\072\001\ -\255\255\074\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\082\001\083\001\084\001\085\001\086\001\087\001\255\255\ -\255\255\000\001\255\255\255\255\255\255\094\001\255\255\006\001\ -\097\001\098\001\255\255\100\001\101\001\012\001\255\255\255\255\ -\015\001\106\001\255\255\255\255\109\001\110\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\028\001\255\255\030\001\ -\031\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\050\001\255\255\052\001\053\001\255\255\ -\055\001\056\001\255\255\255\255\059\001\255\255\000\001\255\255\ -\255\255\064\001\065\001\255\255\006\001\255\255\255\255\255\255\ -\071\001\255\255\012\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\084\001\255\255\255\255\ -\255\255\255\255\028\001\255\255\030\001\031\001\255\255\094\001\ -\255\255\255\255\097\001\255\255\255\255\255\255\101\001\255\255\ -\255\255\255\255\255\255\106\001\255\255\255\255\109\001\110\001\ -\050\001\255\255\052\001\053\001\255\255\055\001\056\001\255\255\ -\255\255\059\001\255\255\000\001\255\255\255\255\064\001\065\001\ -\255\255\006\001\255\255\255\255\255\255\071\001\255\255\012\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\084\001\255\255\255\255\255\255\255\255\028\001\ -\255\255\030\001\031\001\255\255\255\255\255\255\255\255\097\001\ -\255\255\255\255\255\255\101\001\255\255\255\255\255\255\255\255\ -\106\001\255\255\255\255\109\001\110\001\050\001\255\255\052\001\ -\053\001\255\255\055\001\056\001\255\255\255\255\059\001\255\255\ -\000\001\255\255\255\255\064\001\065\001\255\255\006\001\255\255\ -\255\255\255\255\071\001\255\255\012\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\084\001\ -\255\255\255\255\255\255\255\255\028\001\255\255\030\001\031\001\ -\255\255\255\255\255\255\255\255\097\001\255\255\255\255\255\255\ -\101\001\255\255\255\255\255\255\255\255\106\001\255\255\255\255\ -\109\001\110\001\050\001\255\255\052\001\053\001\255\255\055\001\ -\056\001\255\255\255\255\059\001\255\255\000\001\255\255\255\255\ -\064\001\065\001\255\255\006\001\255\255\255\255\255\255\071\001\ -\255\255\012\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\084\001\255\255\255\255\255\255\ -\255\255\028\001\255\255\030\001\031\001\255\255\255\255\255\255\ -\255\255\097\001\255\255\255\255\255\255\101\001\255\255\255\255\ -\255\255\255\255\106\001\255\255\255\255\109\001\110\001\050\001\ -\255\255\052\001\053\001\255\255\055\001\056\001\255\255\255\255\ -\059\001\255\255\000\001\255\255\255\255\064\001\065\001\255\255\ -\006\001\255\255\255\255\255\255\071\001\255\255\012\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\084\001\255\255\255\255\255\255\255\255\028\001\255\255\ -\030\001\031\001\255\255\255\255\255\255\255\255\097\001\255\255\ -\255\255\255\255\101\001\255\255\255\255\255\255\255\255\106\001\ -\255\255\255\255\109\001\110\001\050\001\255\255\052\001\053\001\ -\255\255\055\001\056\001\255\255\255\255\059\001\255\255\000\001\ -\255\255\255\255\064\001\065\001\255\255\006\001\255\255\255\255\ -\255\255\071\001\255\255\012\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\084\001\255\255\ -\255\255\255\255\255\255\028\001\255\255\030\001\031\001\255\255\ -\255\255\255\255\255\255\097\001\255\255\255\255\255\255\101\001\ -\255\255\255\255\255\255\255\255\106\001\255\255\255\255\109\001\ -\110\001\050\001\255\255\052\001\053\001\255\255\055\001\056\001\ -\255\255\255\255\059\001\255\255\255\255\255\255\255\255\064\001\ -\065\001\005\001\006\001\007\001\255\255\255\255\071\001\011\001\ -\012\001\013\001\014\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\084\001\255\255\255\255\255\255\255\255\ -\028\001\029\001\030\001\031\001\032\001\033\001\034\001\255\255\ -\097\001\255\255\255\255\039\001\101\001\041\001\255\255\255\255\ -\255\255\106\001\255\255\255\255\109\001\110\001\050\001\255\255\ -\052\001\053\001\054\001\055\001\056\001\255\255\255\255\059\001\ -\060\001\255\255\255\255\063\001\064\001\065\001\255\255\255\255\ -\068\001\069\001\255\255\071\001\072\001\255\255\074\001\255\255\ -\076\001\255\255\078\001\255\255\080\001\255\255\255\255\255\255\ -\084\001\085\001\255\255\087\001\255\255\089\001\255\255\255\255\ -\005\001\006\001\007\001\255\255\096\001\255\255\011\001\012\001\ -\013\001\101\001\255\255\255\255\255\255\255\255\106\001\107\001\ -\108\001\109\001\110\001\111\001\255\255\255\255\114\001\028\001\ -\029\001\030\001\031\001\032\001\033\001\034\001\255\255\255\255\ -\255\255\255\255\039\001\255\255\041\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\050\001\255\255\052\001\ -\053\001\054\001\055\001\056\001\255\255\255\255\059\001\060\001\ -\255\255\255\255\063\001\064\001\065\001\255\255\255\255\068\001\ -\069\001\255\255\071\001\072\001\255\255\074\001\255\255\076\001\ -\255\255\078\001\255\255\080\001\255\255\255\255\255\255\084\001\ -\085\001\255\255\087\001\255\255\255\255\255\255\005\001\006\001\ -\007\001\255\255\255\255\096\001\011\001\012\001\255\255\255\255\ -\101\001\255\255\255\255\255\255\255\255\106\001\107\001\108\001\ -\109\001\110\001\111\001\255\255\255\255\114\001\255\255\030\001\ -\031\001\032\001\033\001\034\001\255\255\255\255\255\255\255\255\ -\039\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\050\001\255\255\052\001\053\001\054\001\ -\055\001\056\001\255\255\255\255\059\001\255\255\255\255\255\255\ -\063\001\064\001\065\001\255\255\255\255\255\255\069\001\255\255\ -\071\001\072\001\255\255\255\255\255\255\076\001\255\255\078\001\ -\255\255\255\255\255\255\255\255\255\255\084\001\085\001\255\255\ -\087\001\255\255\255\255\255\255\255\255\092\001\005\001\006\001\ -\007\001\255\255\255\255\010\001\011\001\012\001\101\001\255\255\ -\255\255\255\255\255\255\106\001\107\001\255\255\109\001\110\001\ -\255\255\255\255\255\255\114\001\255\255\255\255\255\255\030\001\ -\031\001\032\001\033\001\034\001\255\255\255\255\255\255\255\255\ -\039\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\050\001\255\255\052\001\053\001\054\001\ -\055\001\056\001\255\255\255\255\059\001\255\255\255\255\255\255\ -\063\001\064\001\065\001\255\255\255\255\255\255\069\001\255\255\ -\071\001\072\001\255\255\255\255\255\255\076\001\255\255\078\001\ -\255\255\255\255\255\255\255\255\255\255\084\001\085\001\255\255\ -\087\001\255\255\255\255\005\001\006\001\007\001\255\255\255\255\ -\255\255\011\001\012\001\255\255\255\255\255\255\101\001\255\255\ -\255\255\255\255\255\255\106\001\107\001\255\255\109\001\110\001\ -\026\001\255\255\255\255\114\001\030\001\031\001\032\001\033\001\ -\034\001\255\255\255\255\255\255\255\255\039\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\050\001\255\255\052\001\053\001\054\001\055\001\056\001\255\255\ -\255\255\059\001\255\255\255\255\255\255\063\001\064\001\065\001\ -\255\255\255\255\255\255\069\001\255\255\071\001\072\001\255\255\ -\255\255\255\255\076\001\255\255\078\001\255\255\255\255\255\255\ -\255\255\255\255\084\001\085\001\255\255\087\001\255\255\255\255\ -\005\001\006\001\007\001\255\255\255\255\255\255\011\001\012\001\ -\255\255\255\255\255\255\101\001\255\255\255\255\255\255\255\255\ -\106\001\107\001\255\255\109\001\110\001\255\255\255\255\255\255\ -\114\001\030\001\031\001\032\001\033\001\034\001\255\255\255\255\ -\255\255\255\255\039\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\050\001\255\255\052\001\ -\053\001\054\001\055\001\056\001\255\255\255\255\059\001\255\255\ -\255\255\255\255\063\001\064\001\065\001\255\255\255\255\255\255\ -\069\001\255\255\071\001\072\001\255\255\255\255\255\255\076\001\ -\255\255\078\001\255\255\255\255\255\255\255\255\083\001\084\001\ -\085\001\255\255\087\001\255\255\255\255\005\001\006\001\007\001\ -\255\255\255\255\255\255\011\001\012\001\255\255\255\255\255\255\ -\101\001\255\255\255\255\255\255\255\255\106\001\107\001\255\255\ -\109\001\110\001\255\255\255\255\255\255\114\001\030\001\031\001\ -\032\001\033\001\034\001\255\255\255\255\255\255\255\255\039\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\050\001\255\255\052\001\053\001\054\001\055\001\ -\056\001\255\255\255\255\059\001\255\255\255\255\255\255\063\001\ -\064\001\065\001\255\255\255\255\255\255\069\001\255\255\071\001\ -\072\001\255\255\255\255\255\255\076\001\255\255\078\001\255\255\ -\255\255\255\255\255\255\255\255\084\001\085\001\255\255\087\001\ -\255\255\255\255\255\255\255\255\092\001\005\001\006\001\007\001\ -\255\255\255\255\010\001\011\001\012\001\101\001\255\255\255\255\ -\255\255\255\255\106\001\107\001\255\255\109\001\110\001\255\255\ -\255\255\255\255\114\001\255\255\255\255\255\255\030\001\031\001\ -\032\001\033\001\034\001\255\255\255\255\255\255\255\255\039\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\050\001\255\255\052\001\053\001\054\001\055\001\ -\056\001\255\255\255\255\059\001\255\255\255\255\255\255\063\001\ -\064\001\065\001\255\255\255\255\255\255\069\001\255\255\071\001\ -\072\001\255\255\255\255\255\255\076\001\255\255\078\001\255\255\ -\255\255\255\255\255\255\255\255\084\001\085\001\255\255\087\001\ -\255\255\255\255\255\255\005\001\006\001\007\001\255\255\255\255\ -\255\255\011\001\012\001\255\255\255\255\101\001\255\255\255\255\ -\255\255\255\255\106\001\107\001\022\001\109\001\110\001\255\255\ -\255\255\255\255\114\001\255\255\030\001\031\001\032\001\033\001\ -\034\001\255\255\255\255\255\255\255\255\039\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\050\001\255\255\052\001\053\001\054\001\055\001\056\001\255\255\ -\255\255\059\001\255\255\255\255\255\255\063\001\064\001\065\001\ -\255\255\255\255\255\255\069\001\255\255\071\001\072\001\255\255\ -\255\255\255\255\076\001\255\255\078\001\255\255\255\255\255\255\ -\255\255\255\255\084\001\085\001\255\255\087\001\255\255\255\255\ -\005\001\006\001\007\001\255\255\255\255\255\255\011\001\012\001\ -\255\255\255\255\255\255\101\001\255\255\255\255\255\255\255\255\ -\106\001\107\001\255\255\109\001\110\001\026\001\255\255\255\255\ -\114\001\030\001\031\001\032\001\033\001\034\001\255\255\255\255\ -\255\255\255\255\039\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\050\001\255\255\052\001\ -\053\001\054\001\055\001\056\001\255\255\255\255\059\001\255\255\ -\255\255\255\255\063\001\064\001\065\001\255\255\255\255\255\255\ -\069\001\255\255\071\001\072\001\255\255\255\255\255\255\076\001\ -\255\255\078\001\255\255\255\255\255\255\255\255\255\255\084\001\ -\085\001\255\255\087\001\255\255\255\255\005\001\006\001\007\001\ -\255\255\255\255\255\255\011\001\012\001\255\255\255\255\255\255\ -\101\001\255\255\255\255\255\255\255\255\106\001\107\001\255\255\ -\109\001\110\001\255\255\255\255\255\255\114\001\030\001\031\001\ -\032\001\033\001\034\001\255\255\255\255\255\255\255\255\039\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\050\001\255\255\052\001\053\001\054\001\055\001\ -\056\001\255\255\255\255\059\001\255\255\255\255\255\255\063\001\ -\064\001\065\001\255\255\255\255\255\255\069\001\255\255\071\001\ -\072\001\255\255\255\255\255\255\076\001\255\255\078\001\255\255\ -\255\255\255\255\255\255\255\255\084\001\085\001\255\255\087\001\ -\255\255\255\255\005\001\006\001\007\001\255\255\255\255\255\255\ -\011\001\012\001\255\255\255\255\255\255\101\001\255\255\255\255\ -\255\255\255\255\106\001\107\001\255\255\109\001\110\001\255\255\ -\255\255\255\255\114\001\030\001\031\001\032\001\033\001\034\001\ -\255\255\255\255\255\255\255\255\039\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\050\001\ -\255\255\052\001\053\001\054\001\055\001\056\001\255\255\255\255\ -\059\001\255\255\255\255\255\255\063\001\064\001\065\001\255\255\ -\255\255\255\255\069\001\255\255\071\001\072\001\255\255\255\255\ -\255\255\076\001\255\255\078\001\255\255\255\255\255\255\255\255\ -\255\255\084\001\085\001\255\255\087\001\255\255\255\255\005\001\ -\006\001\007\001\255\255\255\255\255\255\011\001\012\001\255\255\ -\255\255\255\255\101\001\255\255\255\255\255\255\255\255\106\001\ -\107\001\255\255\109\001\110\001\255\255\255\255\255\255\114\001\ -\030\001\031\001\032\001\033\001\034\001\255\255\255\255\255\255\ -\255\255\039\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\050\001\255\255\052\001\053\001\ -\054\001\055\001\056\001\255\255\255\255\059\001\255\255\255\255\ -\255\255\063\001\064\001\065\001\255\255\255\255\255\255\069\001\ -\255\255\071\001\072\001\255\255\255\255\006\001\076\001\255\255\ -\078\001\255\255\255\255\012\001\255\255\014\001\084\001\085\001\ -\017\001\087\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\027\001\255\255\255\255\030\001\031\001\101\001\ -\255\255\255\255\255\255\255\255\106\001\107\001\255\255\109\001\ -\110\001\255\255\255\255\255\255\114\001\255\255\255\255\255\255\ -\255\255\050\001\051\001\255\255\053\001\255\255\055\001\056\001\ -\255\255\255\255\059\001\255\255\255\255\255\255\255\255\064\001\ -\065\001\255\255\006\001\255\255\255\255\255\255\071\001\255\255\ -\012\001\255\255\014\001\255\255\255\255\017\001\255\255\255\255\ -\081\001\255\255\255\255\084\001\255\255\255\255\255\255\027\001\ -\089\001\255\255\030\001\031\001\255\255\006\001\255\255\255\255\ -\097\001\255\255\255\255\012\001\101\001\014\001\255\255\104\001\ -\255\255\106\001\255\255\255\255\109\001\110\001\050\001\051\001\ -\255\255\053\001\255\255\055\001\056\001\030\001\031\001\059\001\ -\255\255\255\255\255\255\255\255\064\001\065\001\255\255\255\255\ -\255\255\255\255\255\255\071\001\255\255\255\255\255\255\255\255\ -\255\255\050\001\051\001\255\255\053\001\081\001\055\001\056\001\ -\084\001\255\255\059\001\255\255\255\255\089\001\255\255\064\001\ -\065\001\255\255\255\255\255\255\255\255\097\001\071\001\255\255\ -\073\001\101\001\255\255\255\255\104\001\255\255\106\001\255\255\ -\081\001\109\001\110\001\084\001\255\255\255\255\006\001\255\255\ -\089\001\255\255\255\255\255\255\012\001\255\255\014\001\255\255\ -\097\001\255\255\255\255\255\255\101\001\255\255\255\255\104\001\ -\255\255\106\001\255\255\027\001\109\001\110\001\030\001\031\001\ -\255\255\006\001\255\255\255\255\255\255\255\255\255\255\012\001\ -\255\255\014\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\050\001\051\001\255\255\053\001\027\001\055\001\ -\056\001\030\001\031\001\059\001\255\255\255\255\255\255\255\255\ -\064\001\065\001\255\255\255\255\255\255\255\255\255\255\071\001\ -\255\255\255\255\255\255\255\255\255\255\050\001\051\001\255\255\ -\053\001\081\001\055\001\056\001\084\001\255\255\059\001\255\255\ -\255\255\089\001\255\255\064\001\065\001\255\255\006\001\255\255\ -\255\255\097\001\071\001\255\255\012\001\101\001\255\255\255\255\ -\104\001\255\255\106\001\255\255\081\001\109\001\110\001\084\001\ -\255\255\255\255\255\255\255\255\089\001\255\255\030\001\031\001\ -\255\255\006\001\255\255\255\255\097\001\255\255\255\255\012\001\ -\101\001\255\255\255\255\104\001\255\255\106\001\255\255\255\255\ -\109\001\110\001\050\001\051\001\255\255\053\001\255\255\055\001\ -\056\001\030\001\031\001\059\001\255\255\255\255\255\255\255\255\ -\064\001\065\001\255\255\255\255\255\255\255\255\255\255\071\001\ -\255\255\073\001\255\255\255\255\255\255\050\001\051\001\255\255\ -\053\001\081\001\055\001\056\001\084\001\255\255\059\001\255\255\ -\255\255\089\001\255\255\064\001\065\001\255\255\006\001\255\255\ -\255\255\097\001\071\001\255\255\012\001\101\001\255\255\255\255\ -\104\001\255\255\106\001\255\255\081\001\109\001\110\001\084\001\ -\255\255\255\255\255\255\255\255\089\001\255\255\030\001\031\001\ -\255\255\006\001\255\255\255\255\097\001\255\255\255\255\012\001\ -\101\001\255\255\255\255\104\001\255\255\106\001\255\255\255\255\ -\109\001\110\001\050\001\051\001\255\255\053\001\255\255\055\001\ -\056\001\030\001\031\001\059\001\255\255\255\255\255\255\255\255\ -\064\001\065\001\255\255\255\255\255\255\255\255\255\255\071\001\ -\255\255\255\255\255\255\255\255\255\255\050\001\051\001\255\255\ -\053\001\081\001\055\001\056\001\084\001\255\255\059\001\255\255\ -\255\255\089\001\255\255\064\001\065\001\255\255\006\001\255\255\ -\255\255\097\001\071\001\255\255\012\001\101\001\255\255\255\255\ -\104\001\255\255\106\001\255\255\081\001\109\001\110\001\084\001\ -\255\255\255\255\255\255\255\255\089\001\255\255\030\001\031\001\ -\255\255\255\255\255\255\255\255\097\001\255\255\255\255\255\255\ -\101\001\255\255\255\255\104\001\255\255\106\001\255\255\255\255\ -\109\001\110\001\050\001\051\001\255\255\053\001\255\255\055\001\ -\056\001\255\255\255\255\059\001\255\255\255\255\255\255\255\255\ -\064\001\065\001\255\255\255\255\006\001\255\255\255\255\071\001\ -\255\255\255\255\012\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\081\001\255\255\255\255\084\001\255\255\255\255\255\255\ -\255\255\089\001\028\001\255\255\030\001\031\001\255\255\255\255\ -\255\255\097\001\255\255\255\255\255\255\101\001\255\255\255\255\ -\104\001\255\255\106\001\255\255\255\255\109\001\110\001\255\255\ -\050\001\255\255\052\001\053\001\255\255\055\001\056\001\255\255\ -\255\255\059\001\255\255\255\255\255\255\255\255\064\001\065\001\ -\255\255\255\255\255\255\006\001\255\255\071\001\255\255\010\001\ -\255\255\012\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\084\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\028\001\092\001\030\001\031\001\255\255\255\255\097\001\ -\255\255\255\255\255\255\101\001\255\255\255\255\255\255\255\255\ -\106\001\255\255\255\255\109\001\110\001\255\255\255\255\050\001\ -\255\255\052\001\053\001\255\255\055\001\056\001\255\255\255\255\ -\059\001\255\255\255\255\255\255\255\255\064\001\065\001\255\255\ -\006\001\255\255\255\255\255\255\071\001\255\255\012\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\006\001\007\001\255\255\ -\255\255\084\001\011\001\012\001\255\255\255\255\028\001\255\255\ -\030\001\031\001\255\255\255\255\255\255\255\255\097\001\255\255\ -\255\255\255\255\101\001\255\255\255\255\030\001\031\001\106\001\ -\255\255\255\255\109\001\110\001\050\001\255\255\052\001\053\001\ -\255\255\055\001\056\001\255\255\255\255\059\001\255\255\255\255\ -\255\255\050\001\064\001\065\001\053\001\054\001\055\001\056\001\ -\255\255\071\001\059\001\255\255\006\001\255\255\008\001\064\001\ -\065\001\255\255\012\001\255\255\255\255\255\255\084\001\255\255\ -\255\255\255\255\255\255\076\001\255\255\255\255\092\001\255\255\ -\255\255\255\255\028\001\097\001\030\001\031\001\087\001\101\001\ -\255\255\255\255\255\255\255\255\106\001\255\255\255\255\109\001\ -\110\001\255\255\255\255\255\255\101\001\255\255\255\255\255\255\ -\050\001\106\001\052\001\053\001\109\001\055\001\056\001\255\255\ -\255\255\059\001\255\255\255\255\255\255\255\255\064\001\065\001\ -\255\255\006\001\255\255\255\255\255\255\071\001\255\255\012\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\084\001\255\255\255\255\255\255\255\255\028\001\ -\255\255\030\001\031\001\255\255\255\255\255\255\255\255\097\001\ -\255\255\255\255\255\255\101\001\255\255\255\255\255\255\255\255\ -\106\001\255\255\255\255\109\001\110\001\050\001\255\255\052\001\ -\053\001\255\255\055\001\056\001\255\255\255\255\059\001\255\255\ -\255\255\255\255\255\255\064\001\065\001\255\255\006\001\255\255\ -\255\255\255\255\071\001\255\255\012\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\084\001\ -\255\255\255\255\255\255\255\255\028\001\255\255\030\001\031\001\ -\255\255\006\001\255\255\255\255\097\001\255\255\255\255\012\001\ -\101\001\255\255\255\255\255\255\255\255\106\001\255\255\255\255\ -\109\001\110\001\050\001\255\255\052\001\053\001\255\255\055\001\ -\056\001\030\001\031\001\059\001\255\255\255\255\255\255\255\255\ -\064\001\065\001\255\255\255\255\255\255\255\255\255\255\071\001\ -\255\255\255\255\255\255\255\255\255\255\050\001\255\255\052\001\ -\053\001\255\255\055\001\056\001\084\001\255\255\059\001\255\255\ -\255\255\255\255\255\255\064\001\065\001\255\255\006\001\255\255\ -\255\255\097\001\071\001\255\255\012\001\101\001\255\255\255\255\ -\255\255\255\255\106\001\255\255\255\255\109\001\110\001\084\001\ -\255\255\255\255\255\255\255\255\028\001\255\255\030\001\031\001\ -\093\001\006\001\255\255\255\255\097\001\255\255\255\255\012\001\ -\101\001\255\255\255\255\255\255\255\255\106\001\255\255\255\255\ -\109\001\110\001\050\001\255\255\052\001\053\001\255\255\055\001\ -\056\001\030\001\031\001\059\001\255\255\255\255\255\255\255\255\ -\064\001\065\001\255\255\255\255\255\255\255\255\255\255\071\001\ -\255\255\255\255\255\255\255\255\255\255\050\001\255\255\052\001\ -\053\001\255\255\055\001\056\001\084\001\255\255\059\001\255\255\ -\255\255\255\255\255\255\064\001\065\001\255\255\006\001\255\255\ -\255\255\097\001\071\001\255\255\012\001\101\001\255\255\255\255\ -\255\255\255\255\106\001\255\255\255\255\109\001\110\001\084\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\030\001\031\001\ -\255\255\006\001\255\255\255\255\097\001\255\255\255\255\012\001\ -\101\001\255\255\255\255\255\255\255\255\106\001\255\255\255\255\ -\109\001\110\001\050\001\255\255\052\001\053\001\255\255\055\001\ -\056\001\030\001\031\001\059\001\255\255\255\255\255\255\255\255\ -\064\001\065\001\255\255\255\255\255\255\255\255\255\255\071\001\ -\255\255\255\255\255\255\255\255\255\255\050\001\255\255\052\001\ -\053\001\255\255\055\001\056\001\084\001\255\255\059\001\255\255\ -\255\255\255\255\255\255\064\001\065\001\255\255\006\001\255\255\ -\255\255\097\001\071\001\255\255\012\001\101\001\255\255\255\255\ -\255\255\255\255\106\001\255\255\255\255\109\001\110\001\084\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\030\001\031\001\ -\255\255\006\001\255\255\255\255\097\001\255\255\255\255\012\001\ -\101\001\255\255\255\255\255\255\255\255\106\001\255\255\255\255\ -\109\001\110\001\050\001\255\255\255\255\053\001\255\255\055\001\ -\056\001\030\001\031\001\059\001\255\255\255\255\255\255\255\255\ -\064\001\065\001\255\255\255\255\255\255\255\255\255\255\071\001\ -\255\255\255\255\255\255\255\255\255\255\050\001\255\255\255\255\ -\053\001\255\255\055\001\056\001\084\001\255\255\059\001\255\255\ -\255\255\255\255\255\255\064\001\065\001\255\255\255\255\255\255\ -\255\255\097\001\071\001\255\255\255\255\101\001\006\001\007\001\ -\255\255\255\255\106\001\011\001\012\001\109\001\110\001\084\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\022\001\255\255\ -\255\255\255\255\255\255\255\255\097\001\255\255\030\001\031\001\ -\101\001\255\255\255\255\255\255\255\255\106\001\255\255\255\255\ -\109\001\110\001\255\255\255\255\255\255\255\255\255\255\047\001\ -\255\255\255\255\050\001\051\001\255\255\053\001\054\001\055\001\ -\056\001\255\255\255\255\059\001\255\255\255\255\255\255\255\255\ -\064\001\065\001\006\001\007\001\255\255\255\255\255\255\011\001\ -\012\001\255\255\255\255\255\255\076\001\255\255\255\255\255\255\ -\255\255\081\001\255\255\255\255\255\255\255\255\255\255\087\001\ -\255\255\089\001\030\001\031\001\255\255\255\255\255\255\255\255\ -\255\255\097\001\098\001\255\255\255\255\101\001\255\255\255\255\ -\104\001\255\255\106\001\255\255\255\255\109\001\050\001\051\001\ -\255\255\053\001\054\001\055\001\056\001\255\255\255\255\059\001\ -\255\255\255\255\255\255\255\255\064\001\065\001\006\001\007\001\ -\255\255\255\255\255\255\011\001\012\001\006\001\007\001\255\255\ -\076\001\255\255\011\001\012\001\255\255\081\001\255\255\255\255\ -\255\255\255\255\255\255\087\001\255\255\089\001\030\001\031\001\ -\255\255\255\255\255\255\255\255\255\255\030\001\031\001\255\255\ -\255\255\101\001\255\255\255\255\104\001\255\255\106\001\255\255\ -\255\255\109\001\050\001\255\255\255\255\053\001\054\001\055\001\ -\056\001\050\001\255\255\059\001\053\001\054\001\055\001\056\001\ -\064\001\065\001\059\001\255\255\255\255\255\255\008\001\064\001\ -\065\001\255\255\255\255\255\255\076\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\076\001\255\255\023\001\255\255\087\001\ -\255\255\255\255\255\255\255\255\030\001\255\255\087\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\101\001\255\255\255\255\ -\255\255\255\255\106\001\255\255\101\001\109\001\255\255\255\255\ -\255\255\106\001\255\255\255\255\109\001\055\001\255\255\057\001\ -\058\001\059\001\255\255\061\001\255\255\255\255\064\001\065\001\ -\255\255\255\255\255\255\000\001\001\001\002\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\009\001\255\255\255\255\081\001\ -\255\255\014\001\015\001\016\001\017\001\018\001\088\001\089\001\ -\090\001\255\255\255\255\255\255\255\255\255\255\027\001\097\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\036\001\ -\106\001\255\255\255\255\109\001\110\001\042\001\043\001\044\001\ -\045\001\046\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\061\001\255\255\255\255\255\255\255\255\066\001\255\255\255\255\ -\255\255\255\255\071\001\072\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\082\001\083\001\084\001\ -\085\001\086\001\255\255\000\001\001\001\002\001\255\255\255\255\ -\255\255\094\001\007\001\255\255\009\001\255\255\255\255\100\001\ -\255\255\255\255\055\001\016\001\057\001\058\001\059\001\255\255\ -\061\001\255\255\255\255\064\001\065\001\255\255\027\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\036\001\ -\255\255\255\255\255\255\255\255\081\001\042\001\043\001\044\001\ -\045\001\046\001\047\001\255\255\089\001\090\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\097\001\255\255\255\255\255\255\ -\061\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\109\001\110\001\071\001\072\001\255\255\074\001\255\255\255\255\ -\255\255\255\255\000\001\001\001\002\001\082\001\083\001\084\001\ -\085\001\086\001\087\001\009\001\255\255\255\255\255\255\255\255\ -\255\255\015\001\016\001\255\255\018\001\098\001\255\255\100\001\ -\255\255\255\255\255\255\255\255\255\255\027\001\255\255\255\255\ -\255\255\255\255\000\001\001\001\002\001\255\255\036\001\255\255\ -\255\255\255\255\255\255\009\001\042\001\043\001\044\001\045\001\ -\046\001\015\001\016\001\255\255\018\001\255\255\255\255\255\255\ -\055\001\255\255\057\001\058\001\059\001\027\001\061\001\061\001\ -\255\255\064\001\065\001\255\255\066\001\255\255\036\001\255\255\ -\255\255\071\001\072\001\255\255\042\001\043\001\044\001\045\001\ -\046\001\255\255\081\001\255\255\082\001\083\001\084\001\085\001\ -\086\001\255\255\089\001\090\001\255\255\091\001\255\255\061\001\ -\255\255\255\255\097\001\255\255\066\001\255\255\100\001\255\255\ -\255\255\071\001\072\001\255\255\255\255\255\255\109\001\110\001\ -\000\001\001\001\002\001\255\255\082\001\083\001\084\001\085\001\ -\086\001\009\001\255\255\255\255\255\255\255\255\092\001\015\001\ -\016\001\255\255\018\001\255\255\255\255\255\255\100\001\255\255\ -\255\255\255\255\255\255\027\001\255\255\255\255\255\255\255\255\ -\000\001\001\001\002\001\255\255\036\001\255\255\255\255\255\255\ -\255\255\009\001\042\001\043\001\044\001\045\001\046\001\015\001\ -\016\001\255\255\018\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\027\001\255\255\061\001\255\255\255\255\ -\255\255\255\255\066\001\255\255\036\001\255\255\255\255\071\001\ -\072\001\255\255\042\001\043\001\044\001\045\001\046\001\255\255\ -\255\255\255\255\082\001\083\001\084\001\085\001\086\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\061\001\094\001\255\255\ -\255\255\255\255\066\001\255\255\100\001\255\255\255\255\071\001\ -\072\001\255\255\255\255\255\255\255\255\255\255\000\001\001\001\ -\002\001\255\255\082\001\083\001\084\001\085\001\086\001\009\001\ -\255\255\255\255\255\255\091\001\255\255\015\001\016\001\255\255\ -\018\001\255\255\255\255\255\255\100\001\255\255\255\255\255\255\ -\255\255\027\001\255\255\255\255\255\255\255\255\000\001\001\001\ -\002\001\255\255\036\001\255\255\255\255\255\255\255\255\009\001\ -\042\001\043\001\044\001\045\001\046\001\015\001\016\001\255\255\ -\018\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\027\001\255\255\061\001\255\255\255\255\255\255\255\255\ -\066\001\255\255\036\001\255\255\255\255\071\001\072\001\255\255\ -\042\001\043\001\044\001\045\001\046\001\255\255\255\255\255\255\ -\082\001\083\001\084\001\085\001\086\001\255\255\255\255\255\255\ -\255\255\255\255\092\001\061\001\255\255\255\255\255\255\255\255\ -\066\001\255\255\100\001\255\255\255\255\071\001\072\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\082\001\083\001\084\001\085\001\086\001\000\001\001\001\002\001\ -\255\255\255\255\255\255\255\255\094\001\255\255\009\001\255\255\ -\255\255\255\255\100\001\255\255\015\001\016\001\255\255\018\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\027\001\255\255\255\255\255\255\255\255\000\001\001\001\002\001\ -\255\255\036\001\255\255\255\255\255\255\255\255\009\001\042\001\ -\043\001\044\001\045\001\046\001\015\001\016\001\255\255\018\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\027\001\255\255\061\001\255\255\255\255\255\255\255\255\066\001\ -\255\255\036\001\255\255\255\255\071\001\072\001\255\255\042\001\ -\043\001\044\001\045\001\046\001\255\255\255\255\255\255\082\001\ -\083\001\084\001\085\001\086\001\255\255\255\255\255\255\255\255\ -\091\001\255\255\061\001\255\255\255\255\255\255\255\255\066\001\ -\255\255\100\001\255\255\255\255\071\001\072\001\255\255\255\255\ -\255\255\255\255\255\255\000\001\001\001\002\001\255\255\082\001\ -\083\001\084\001\085\001\086\001\009\001\255\255\255\255\255\255\ -\255\255\092\001\015\001\016\001\255\255\018\001\255\255\255\255\ -\255\255\100\001\255\255\255\255\255\255\255\255\027\001\255\255\ -\255\255\255\255\255\255\000\001\001\001\002\001\255\255\036\001\ -\255\255\255\255\255\255\255\255\009\001\042\001\043\001\044\001\ -\045\001\046\001\015\001\016\001\255\255\018\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\027\001\255\255\ -\061\001\255\255\255\255\255\255\255\255\066\001\255\255\036\001\ -\255\255\255\255\071\001\072\001\255\255\042\001\043\001\044\001\ -\045\001\046\001\255\255\255\255\255\255\082\001\083\001\084\001\ -\085\001\086\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\061\001\094\001\255\255\255\255\255\255\066\001\255\255\100\001\ -\255\255\255\255\071\001\072\001\255\255\255\255\255\255\255\255\ -\255\255\000\001\001\001\002\001\255\255\082\001\083\001\084\001\ -\085\001\086\001\009\001\255\255\255\255\255\255\091\001\255\255\ -\015\001\016\001\255\255\018\001\255\255\255\255\255\255\100\001\ -\255\255\255\255\255\255\255\255\027\001\255\255\255\255\255\255\ -\255\255\000\001\001\001\002\001\255\255\036\001\255\255\255\255\ -\255\255\255\255\009\001\042\001\043\001\044\001\045\001\046\001\ -\015\001\016\001\255\255\018\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\027\001\255\255\061\001\255\255\ -\255\255\255\255\255\255\066\001\255\255\036\001\255\255\255\255\ -\071\001\072\001\255\255\042\001\043\001\044\001\045\001\046\001\ -\255\255\255\255\255\255\082\001\083\001\084\001\085\001\086\001\ -\255\255\255\255\255\255\255\255\255\255\092\001\061\001\001\001\ -\002\001\255\255\255\255\066\001\255\255\100\001\255\255\009\001\ -\071\001\072\001\255\255\255\255\255\255\015\001\016\001\255\255\ -\018\001\255\255\255\255\082\001\083\001\084\001\085\001\086\001\ -\255\255\027\001\255\255\255\255\255\255\255\255\255\255\094\001\ -\255\255\255\255\036\001\255\255\255\255\100\001\255\255\255\255\ -\042\001\043\001\044\001\045\001\046\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\061\001\001\001\002\001\255\255\255\255\ -\066\001\255\255\255\255\255\255\009\001\071\001\072\001\255\255\ -\255\255\255\255\015\001\016\001\255\255\018\001\255\255\255\255\ -\082\001\083\001\084\001\085\001\086\001\255\255\027\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\095\001\255\255\036\001\ -\255\255\255\255\100\001\255\255\255\255\042\001\043\001\044\001\ -\045\001\046\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\061\001\001\001\002\001\255\255\255\255\066\001\255\255\255\255\ -\255\255\009\001\071\001\072\001\255\255\255\255\255\255\015\001\ -\016\001\255\255\018\001\255\255\255\255\082\001\083\001\084\001\ -\085\001\086\001\255\255\027\001\255\255\255\255\091\001\255\255\ -\255\255\001\001\002\001\255\255\036\001\255\255\255\255\100\001\ -\255\255\009\001\042\001\043\001\044\001\045\001\046\001\015\001\ -\016\001\255\255\018\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\025\001\255\255\027\001\255\255\061\001\255\255\255\255\ -\255\255\255\255\066\001\255\255\036\001\255\255\255\255\071\001\ -\072\001\255\255\042\001\043\001\044\001\045\001\046\001\255\255\ -\255\255\255\255\082\001\083\001\084\001\085\001\086\001\255\255\ -\255\255\255\255\255\255\091\001\255\255\061\001\001\001\002\001\ -\255\255\255\255\066\001\255\255\100\001\255\255\009\001\071\001\ -\072\001\255\255\255\255\255\255\015\001\016\001\255\255\018\001\ -\255\255\255\255\082\001\083\001\084\001\085\001\086\001\255\255\ -\027\001\255\255\255\255\255\255\255\255\255\255\001\001\002\001\ -\255\255\036\001\255\255\255\255\100\001\255\255\009\001\042\001\ -\043\001\044\001\045\001\046\001\015\001\016\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\027\001\255\255\061\001\255\255\255\255\255\255\255\255\066\001\ -\255\255\036\001\255\255\255\255\071\001\072\001\255\255\042\001\ -\043\001\044\001\045\001\046\001\255\255\255\255\255\255\082\001\ -\083\001\084\001\085\001\086\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\061\001\001\001\002\001\255\255\255\255\066\001\ -\255\255\100\001\255\255\009\001\071\001\072\001\255\255\255\255\ -\255\255\015\001\255\255\255\255\255\255\255\255\255\255\082\001\ -\083\001\084\001\085\001\086\001\255\255\027\001\255\255\255\255\ -\091\001\255\255\255\255\001\001\002\001\255\255\036\001\255\255\ -\255\255\100\001\255\255\255\255\042\001\043\001\044\001\045\001\ -\046\001\015\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\027\001\255\255\061\001\ -\255\255\255\255\255\255\255\255\066\001\255\255\036\001\255\255\ -\255\255\071\001\072\001\255\255\042\001\043\001\044\001\045\001\ -\046\001\013\001\255\255\255\255\082\001\083\001\084\001\085\001\ -\086\001\255\255\255\255\255\255\255\255\255\255\255\255\061\001\ -\028\001\029\001\255\255\255\255\066\001\255\255\100\001\255\255\ -\255\255\071\001\072\001\255\255\255\255\041\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\083\001\084\001\085\001\ -\086\001\255\255\255\255\055\001\255\255\057\001\058\001\059\001\ -\060\001\061\001\255\255\255\255\064\001\065\001\100\001\255\255\ -\068\001\255\255\255\255\255\255\255\255\255\255\074\001\255\255\ -\255\255\255\255\255\255\255\255\080\001\081\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\089\001\090\001\255\255\ -\255\255\255\255\255\255\255\255\096\001\097\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\108\001\109\001\110\001\111\001" - -let yynames_const = "\ - AMPERAMPER\000\ - AMPERSAND\000\ - AND\000\ - AS\000\ - ASSERT\000\ - BACKQUOTE\000\ - BANG\000\ - BAR\000\ - BARBAR\000\ - BARRBRACKET\000\ - BEGIN\000\ - CLASS\000\ - COLON\000\ - COLONCOLON\000\ - COLONEQUAL\000\ - COLONGREATER\000\ - COMMA\000\ - CONSTRAINT\000\ - DO\000\ - DONE\000\ - DOT\000\ - DOTDOT\000\ - DOWNTO\000\ - ELSE\000\ - END\000\ - EOF\000\ - EQUAL\000\ - EXCEPTION\000\ - EXTERNAL\000\ - FALSE\000\ - FOR\000\ - FUN\000\ - FUNCTION\000\ - FUNCTOR\000\ - GREATER\000\ - GREATERRBRACE\000\ - GREATERRBRACKET\000\ - IF\000\ - IN\000\ - INCLUDE\000\ - INHERIT\000\ - INITIALIZER\000\ - LAZY\000\ - LBRACE\000\ - LBRACELESS\000\ - LBRACKET\000\ - LBRACKETBAR\000\ - LBRACKETLESS\000\ - LBRACKETGREATER\000\ - LBRACKETPERCENT\000\ - LBRACKETPERCENTPERCENT\000\ - LESS\000\ - LESSMINUS\000\ - LET\000\ - LPAREN\000\ - LBRACKETAT\000\ - LBRACKETATAT\000\ - LBRACKETATATAT\000\ - MATCH\000\ - METHOD\000\ - MINUS\000\ - MINUSDOT\000\ - MINUSGREATER\000\ - MODULE\000\ - MUTABLE\000\ - NEW\000\ - NONREC\000\ - OBJECT\000\ - OF\000\ - OPEN\000\ - OR\000\ - PERCENT\000\ - PLUS\000\ - PLUSDOT\000\ - PLUSEQ\000\ - PRIVATE\000\ - QUESTION\000\ - QUOTE\000\ - RBRACE\000\ - RBRACKET\000\ - REC\000\ - RPAREN\000\ - SEMI\000\ - SEMISEMI\000\ - HASH\000\ - SIG\000\ - STAR\000\ - STRUCT\000\ - THEN\000\ - TILDE\000\ - TO\000\ - TRUE\000\ - TRY\000\ - TYPE\000\ - UNDERSCORE\000\ - VAL\000\ - VIRTUAL\000\ - WHEN\000\ - WHILE\000\ - WITH\000\ - EOL\000\ - " - -let yynames_block = "\ - CHAR\000\ - FLOAT\000\ - INFIXOP0\000\ - INFIXOP1\000\ - INFIXOP2\000\ - INFIXOP3\000\ - INFIXOP4\000\ - DOTOP\000\ - INT\000\ - LABEL\000\ - LIDENT\000\ - OPTLABEL\000\ - PREFIXOP\000\ - HASHOP\000\ - STRING\000\ - UIDENT\000\ - COMMENT\000\ - DOCSTRING\000\ - " - -let yyact = [| - (fun _ -> failwith "parser") -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'structure) in - Obj.repr( -# 630 "parsing/parser.mly" - ( extra_str 1 _1 ) -# 7030 "parsing/parser.ml" - : Parsetree.structure)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'signature) in - Obj.repr( -# 633 "parsing/parser.mly" - ( extra_sig 1 _1 ) -# 7037 "parsing/parser.ml" - : Parsetree.signature)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'top_structure) in - Obj.repr( -# 636 "parsing/parser.mly" - ( Ptop_def (extra_str 1 _1) ) -# 7044 "parsing/parser.ml" - : Parsetree.toplevel_phrase)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'toplevel_directive) in - Obj.repr( -# 637 "parsing/parser.mly" - ( _1 ) -# 7051 "parsing/parser.ml" - : Parsetree.toplevel_phrase)) -; (fun __caml_parser_env -> - Obj.repr( -# 638 "parsing/parser.mly" - ( raise End_of_file ) -# 7057 "parsing/parser.ml" - : Parsetree.toplevel_phrase)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 642 "parsing/parser.mly" - ( (text_str 1) @ [mkstrexp _1 _2] ) -# 7065 "parsing/parser.ml" - : 'top_structure)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'top_structure_tail) in - Obj.repr( -# 644 "parsing/parser.mly" - ( _1 ) -# 7072 "parsing/parser.ml" - : 'top_structure)) -; (fun __caml_parser_env -> - Obj.repr( -# 647 "parsing/parser.mly" - ( [] ) -# 7078 "parsing/parser.ml" - : 'top_structure_tail)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'structure_item) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'top_structure_tail) in - Obj.repr( -# 648 "parsing/parser.mly" - ( (text_str 1) @ _1 :: _2 ) -# 7086 "parsing/parser.ml" - : 'top_structure_tail)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'use_file_body) in - Obj.repr( -# 651 "parsing/parser.mly" - ( extra_def 1 _1 ) -# 7093 "parsing/parser.ml" - : Parsetree.toplevel_phrase list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'use_file_tail) in - Obj.repr( -# 654 "parsing/parser.mly" - ( _1 ) -# 7100 "parsing/parser.ml" - : 'use_file_body)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'seq_expr) in - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'post_item_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'use_file_tail) in - Obj.repr( -# 656 "parsing/parser.mly" - ( (text_def 1) @ Ptop_def[mkstrexp _1 _2] :: _3 ) -# 7109 "parsing/parser.ml" - : 'use_file_body)) -; (fun __caml_parser_env -> - Obj.repr( -# 660 "parsing/parser.mly" - ( [] ) -# 7115 "parsing/parser.ml" - : 'use_file_tail)) -; (fun __caml_parser_env -> - Obj.repr( -# 662 "parsing/parser.mly" - ( text_def 1 ) -# 7121 "parsing/parser.ml" - : 'use_file_tail)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'seq_expr) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'post_item_attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'use_file_tail) in - Obj.repr( -# 664 "parsing/parser.mly" - ( mark_rhs_docs 2 3; - (text_def 1) @ (text_def 2) @ Ptop_def[mkstrexp _2 _3] :: _4 ) -# 7131 "parsing/parser.ml" - : 'use_file_tail)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'structure_item) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'use_file_tail) in - Obj.repr( -# 667 "parsing/parser.mly" - ( (text_def 1) @ (text_def 2) @ Ptop_def[_2] :: _3 ) -# 7139 "parsing/parser.ml" - : 'use_file_tail)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'toplevel_directive) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'use_file_tail) in - Obj.repr( -# 669 "parsing/parser.mly" - ( mark_rhs_docs 2 3; - (text_def 1) @ (text_def 2) @ _2 :: _3 ) -# 7148 "parsing/parser.ml" - : 'use_file_tail)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'structure_item) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'use_file_tail) in - Obj.repr( -# 672 "parsing/parser.mly" - ( (text_def 1) @ Ptop_def[_1] :: _2 ) -# 7156 "parsing/parser.ml" - : 'use_file_tail)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'toplevel_directive) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'use_file_tail) in - Obj.repr( -# 674 "parsing/parser.mly" - ( mark_rhs_docs 1 1; - (text_def 1) @ _1 :: _2 ) -# 7165 "parsing/parser.ml" - : 'use_file_tail)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'core_type) in - Obj.repr( -# 678 "parsing/parser.mly" - ( _1 ) -# 7172 "parsing/parser.ml" - : Parsetree.core_type)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in - Obj.repr( -# 681 "parsing/parser.mly" - ( _1 ) -# 7179 "parsing/parser.ml" - : Parsetree.expression)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'pattern) in - Obj.repr( -# 684 "parsing/parser.mly" - ( _1 ) -# 7186 "parsing/parser.ml" - : Parsetree.pattern)) -; (fun __caml_parser_env -> - Obj.repr( -# 691 "parsing/parser.mly" - ( mkrhs "*" 2, None ) -# 7192 "parsing/parser.ml" - : 'functor_arg)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'functor_arg_name) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'module_type) in - Obj.repr( -# 693 "parsing/parser.mly" - ( mkrhs _2 2, Some _4 ) -# 7200 "parsing/parser.ml" - : 'functor_arg)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 697 "parsing/parser.mly" - ( _1 ) -# 7207 "parsing/parser.ml" - : 'functor_arg_name)) -; (fun __caml_parser_env -> - Obj.repr( -# 698 "parsing/parser.mly" - ( "_" ) -# 7213 "parsing/parser.ml" - : 'functor_arg_name)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'functor_args) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'functor_arg) in - Obj.repr( -# 703 "parsing/parser.mly" - ( _2 :: _1 ) -# 7221 "parsing/parser.ml" - : 'functor_args)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'functor_arg) in - Obj.repr( -# 705 "parsing/parser.mly" - ( [ _1 ] ) -# 7228 "parsing/parser.ml" - : 'functor_args)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'mod_longident) in - Obj.repr( -# 710 "parsing/parser.mly" - ( mkmod(Pmod_ident (mkrhs _1 1)) ) -# 7235 "parsing/parser.ml" - : 'module_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'structure) in - Obj.repr( -# 712 "parsing/parser.mly" - ( mkmod ~attrs:_2 (Pmod_structure(extra_str 3 _3)) ) -# 7243 "parsing/parser.ml" - : 'module_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'structure) in - Obj.repr( -# 714 "parsing/parser.mly" - ( unclosed "struct" 1 "end" 4 ) -# 7251 "parsing/parser.ml" - : 'module_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'functor_args) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'module_expr) in - Obj.repr( -# 716 "parsing/parser.mly" - ( let modexp = - List.fold_left - (fun acc (n, t) -> mkmod(Pmod_functor(n, t, acc))) - _5 _3 - in wrap_mod_attrs modexp _2 ) -# 7264 "parsing/parser.ml" - : 'module_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'module_expr) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'paren_module_expr) in - Obj.repr( -# 722 "parsing/parser.mly" - ( mkmod(Pmod_apply(_1, _2)) ) -# 7272 "parsing/parser.ml" - : 'module_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'module_expr) in - Obj.repr( -# 724 "parsing/parser.mly" - ( mkmod(Pmod_apply(_1, mkmod (Pmod_structure []))) ) -# 7279 "parsing/parser.ml" - : 'module_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'paren_module_expr) in - Obj.repr( -# 726 "parsing/parser.mly" - ( _1 ) -# 7286 "parsing/parser.ml" - : 'module_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'module_expr) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attribute) in - Obj.repr( -# 728 "parsing/parser.mly" - ( Mod.attr _1 _2 ) -# 7294 "parsing/parser.ml" - : 'module_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'extension) in - Obj.repr( -# 730 "parsing/parser.mly" - ( mkmod(Pmod_extension _1) ) -# 7301 "parsing/parser.ml" - : 'module_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'module_expr) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'module_type) in - Obj.repr( -# 735 "parsing/parser.mly" - ( mkmod(Pmod_constraint(_2, _4)) ) -# 7309 "parsing/parser.ml" - : 'paren_module_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'module_expr) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'module_type) in - Obj.repr( -# 737 "parsing/parser.mly" - ( unclosed "(" 1 ")" 5 ) -# 7317 "parsing/parser.ml" - : 'paren_module_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'module_expr) in - Obj.repr( -# 739 "parsing/parser.mly" - ( _2 ) -# 7324 "parsing/parser.ml" - : 'paren_module_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'module_expr) in - Obj.repr( -# 741 "parsing/parser.mly" - ( unclosed "(" 1 ")" 3 ) -# 7331 "parsing/parser.ml" - : 'paren_module_expr)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in - Obj.repr( -# 743 "parsing/parser.mly" - ( mkmod ~attrs:_3 (Pmod_unpack _4)) -# 7339 "parsing/parser.ml" - : 'paren_module_expr)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : 'expr) in - let _6 = (Parsing.peek_val __caml_parser_env 1 : 'package_type) in - Obj.repr( -# 745 "parsing/parser.mly" - ( mkmod ~attrs:_3 - (Pmod_unpack( - ghexp(Pexp_constraint(_4, ghtyp(Ptyp_package _6))))) ) -# 7350 "parsing/parser.ml" - : 'paren_module_expr)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 6 : 'attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 5 : 'expr) in - let _6 = (Parsing.peek_val __caml_parser_env 3 : 'package_type) in - let _8 = (Parsing.peek_val __caml_parser_env 1 : 'package_type) in - Obj.repr( -# 750 "parsing/parser.mly" - ( mkmod ~attrs:_3 - (Pmod_unpack( - ghexp(Pexp_coerce(_4, Some(ghtyp(Ptyp_package _6)), - ghtyp(Ptyp_package _8))))) ) -# 7363 "parsing/parser.ml" - : 'paren_module_expr)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : 'expr) in - let _6 = (Parsing.peek_val __caml_parser_env 1 : 'package_type) in - Obj.repr( -# 755 "parsing/parser.mly" - ( mkmod ~attrs:_3 - (Pmod_unpack( - ghexp(Pexp_coerce(_4, None, ghtyp(Ptyp_package _6))))) ) -# 7374 "parsing/parser.ml" - : 'paren_module_expr)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 3 : 'attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - Obj.repr( -# 759 "parsing/parser.mly" - ( unclosed "(" 1 ")" 6 ) -# 7382 "parsing/parser.ml" - : 'paren_module_expr)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 3 : 'attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - Obj.repr( -# 761 "parsing/parser.mly" - ( unclosed "(" 1 ")" 6 ) -# 7390 "parsing/parser.ml" - : 'paren_module_expr)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in - Obj.repr( -# 763 "parsing/parser.mly" - ( unclosed "(" 1 ")" 5 ) -# 7398 "parsing/parser.ml" - : 'paren_module_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'seq_expr) in - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'post_item_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'structure_tail) in - Obj.repr( -# 768 "parsing/parser.mly" - ( mark_rhs_docs 1 2; - (text_str 1) @ mkstrexp _1 _2 :: _3 ) -# 7408 "parsing/parser.ml" - : 'structure)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'structure_tail) in - Obj.repr( -# 770 "parsing/parser.mly" - ( _1 ) -# 7415 "parsing/parser.ml" - : 'structure)) -; (fun __caml_parser_env -> - Obj.repr( -# 773 "parsing/parser.mly" - ( [] ) -# 7421 "parsing/parser.ml" - : 'structure_tail)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'structure) in - Obj.repr( -# 774 "parsing/parser.mly" - ( (text_str 1) @ _2 ) -# 7428 "parsing/parser.ml" - : 'structure_tail)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'structure_item) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'structure_tail) in - Obj.repr( -# 775 "parsing/parser.mly" - ( (text_str 1) @ _1 :: _2 ) -# 7436 "parsing/parser.ml" - : 'structure_tail)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'let_bindings) in - Obj.repr( -# 779 "parsing/parser.mly" - ( val_of_let_bindings _1 ) -# 7443 "parsing/parser.ml" - : 'structure_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'primitive_declaration) in - Obj.repr( -# 781 "parsing/parser.mly" - ( let (body, ext) = _1 in mkstr_ext (Pstr_primitive body) ext ) -# 7450 "parsing/parser.ml" - : 'structure_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'value_description) in - Obj.repr( -# 783 "parsing/parser.mly" - ( let (body, ext) = _1 in mkstr_ext (Pstr_primitive body) ext ) -# 7457 "parsing/parser.ml" - : 'structure_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'type_declarations) in - Obj.repr( -# 785 "parsing/parser.mly" - ( let (nr, l, ext ) = _1 in mkstr_ext (Pstr_type (nr, List.rev l)) ext ) -# 7464 "parsing/parser.ml" - : 'structure_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'str_type_extension) in - Obj.repr( -# 787 "parsing/parser.mly" - ( let (l, ext) = _1 in mkstr_ext (Pstr_typext l) ext ) -# 7471 "parsing/parser.ml" - : 'structure_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'str_exception_declaration) in - Obj.repr( -# 789 "parsing/parser.mly" - ( let (l, ext) = _1 in mkstr_ext (Pstr_exception l) ext ) -# 7478 "parsing/parser.ml" - : 'structure_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'module_binding) in - Obj.repr( -# 791 "parsing/parser.mly" - ( let (body, ext) = _1 in mkstr_ext (Pstr_module body) ext ) -# 7485 "parsing/parser.ml" - : 'structure_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'rec_module_bindings) in - Obj.repr( -# 793 "parsing/parser.mly" - ( let (l, ext) = _1 in mkstr_ext (Pstr_recmodule(List.rev l)) ext ) -# 7492 "parsing/parser.ml" - : 'structure_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'module_type_declaration) in - Obj.repr( -# 795 "parsing/parser.mly" - ( let (body, ext) = _1 in mkstr_ext (Pstr_modtype body) ext ) -# 7499 "parsing/parser.ml" - : 'structure_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'open_statement) in - Obj.repr( -# 797 "parsing/parser.mly" - ( let (body, ext) = _1 in mkstr_ext (Pstr_open body) ext ) -# 7506 "parsing/parser.ml" - : 'structure_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'class_declarations) in - Obj.repr( -# 799 "parsing/parser.mly" - ( let (l, ext) = _1 in mkstr_ext (Pstr_class (List.rev l)) ext ) -# 7513 "parsing/parser.ml" - : 'structure_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'class_type_declarations) in - Obj.repr( -# 801 "parsing/parser.mly" - ( let (l, ext) = _1 in mkstr_ext (Pstr_class_type (List.rev l)) ext ) -# 7520 "parsing/parser.ml" - : 'structure_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'str_include_statement) in - Obj.repr( -# 803 "parsing/parser.mly" - ( let (body, ext) = _1 in mkstr_ext (Pstr_include body) ext ) -# 7527 "parsing/parser.ml" - : 'structure_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'item_extension) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 805 "parsing/parser.mly" - ( mkstr(Pstr_extension (_1, (add_docs_attrs (symbol_docs ()) _2))) ) -# 7535 "parsing/parser.ml" - : 'structure_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'floating_attribute) in - Obj.repr( -# 807 "parsing/parser.mly" - ( mark_symbol_docs (); - mkstr(Pstr_attribute _1) ) -# 7543 "parsing/parser.ml" - : 'structure_item)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'module_expr) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 812 "parsing/parser.mly" - ( let (ext, attrs) = _2 in - Incl.mk _3 ~attrs:(attrs@_4) - ~loc:(symbol_rloc()) ~docs:(symbol_docs ()) - , ext ) -# 7555 "parsing/parser.ml" - : 'str_include_statement)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'module_expr) in - Obj.repr( -# 819 "parsing/parser.mly" - ( _2 ) -# 7562 "parsing/parser.ml" - : 'module_binding_body)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'module_type) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'module_expr) in - Obj.repr( -# 821 "parsing/parser.mly" - ( mkmod(Pmod_constraint(_4, _2)) ) -# 7570 "parsing/parser.ml" - : 'module_binding_body)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'functor_arg) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'module_binding_body) in - Obj.repr( -# 823 "parsing/parser.mly" - ( mkmod(Pmod_functor(fst _1, snd _1, _2)) ) -# 7578 "parsing/parser.ml" - : 'module_binding_body)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 2 : string) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'module_binding_body) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 827 "parsing/parser.mly" - ( let (ext, attrs) = _2 in - Mb.mk (mkrhs _3 3) _4 ~attrs:(attrs@_5) - ~loc:(symbol_rloc ()) ~docs:(symbol_docs ()) - , ext ) -# 7591 "parsing/parser.ml" - : 'module_binding)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'rec_module_binding) in - Obj.repr( -# 833 "parsing/parser.mly" - ( let (b, ext) = _1 in ([b], ext) ) -# 7598 "parsing/parser.ml" - : 'rec_module_bindings)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'rec_module_bindings) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'and_module_binding) in - Obj.repr( -# 835 "parsing/parser.mly" - ( let (l, ext) = _1 in (_2 :: l, ext) ) -# 7606 "parsing/parser.ml" - : 'rec_module_bindings)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 2 : string) in - let _5 = (Parsing.peek_val __caml_parser_env 1 : 'module_binding_body) in - let _6 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 839 "parsing/parser.mly" - ( let (ext, attrs) = _2 in - Mb.mk (mkrhs _4 4) _5 ~attrs:(attrs@_6) - ~loc:(symbol_rloc ()) ~docs:(symbol_docs ()) - , ext ) -# 7619 "parsing/parser.ml" - : 'rec_module_binding)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 2 : string) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'module_binding_body) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 846 "parsing/parser.mly" - ( Mb.mk (mkrhs _3 3) _4 ~attrs:(_2@_5) ~loc:(symbol_rloc ()) - ~text:(symbol_text ()) ~docs:(symbol_docs ()) ) -# 7630 "parsing/parser.ml" - : 'and_module_binding)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'mty_longident) in - Obj.repr( -# 854 "parsing/parser.mly" - ( mkmty(Pmty_ident (mkrhs _1 1)) ) -# 7637 "parsing/parser.ml" - : 'module_type)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'signature) in - Obj.repr( -# 856 "parsing/parser.mly" - ( mkmty ~attrs:_2 (Pmty_signature (extra_sig 3 _3)) ) -# 7645 "parsing/parser.ml" - : 'module_type)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'signature) in - Obj.repr( -# 858 "parsing/parser.mly" - ( unclosed "sig" 1 "end" 4 ) -# 7653 "parsing/parser.ml" - : 'module_type)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'functor_args) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'module_type) in - Obj.repr( -# 861 "parsing/parser.mly" - ( let mty = - List.fold_left - (fun acc (n, t) -> mkmty(Pmty_functor(n, t, acc))) - _5 _3 - in wrap_mty_attrs mty _2 ) -# 7666 "parsing/parser.ml" - : 'module_type)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'module_type) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'module_type) in - Obj.repr( -# 868 "parsing/parser.mly" - ( mkmty(Pmty_functor(mknoloc "_", Some _1, _3)) ) -# 7674 "parsing/parser.ml" - : 'module_type)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'module_type) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'with_constraints) in - Obj.repr( -# 870 "parsing/parser.mly" - ( mkmty(Pmty_with(_1, List.rev _3)) ) -# 7682 "parsing/parser.ml" - : 'module_type)) -; (fun __caml_parser_env -> - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'attributes) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'module_expr) in - Obj.repr( -# 872 "parsing/parser.mly" - ( mkmty ~attrs:_4 (Pmty_typeof _5) ) -# 7690 "parsing/parser.ml" - : 'module_type)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'module_type) in - Obj.repr( -# 876 "parsing/parser.mly" - ( _2 ) -# 7697 "parsing/parser.ml" - : 'module_type)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'module_type) in - Obj.repr( -# 878 "parsing/parser.mly" - ( unclosed "(" 1 ")" 3 ) -# 7704 "parsing/parser.ml" - : 'module_type)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'extension) in - Obj.repr( -# 880 "parsing/parser.mly" - ( mkmty(Pmty_extension _1) ) -# 7711 "parsing/parser.ml" - : 'module_type)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'module_type) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attribute) in - Obj.repr( -# 882 "parsing/parser.mly" - ( Mty.attr _1 _2 ) -# 7719 "parsing/parser.ml" - : 'module_type)) -; (fun __caml_parser_env -> - Obj.repr( -# 885 "parsing/parser.mly" - ( [] ) -# 7725 "parsing/parser.ml" - : 'signature)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'signature) in - Obj.repr( -# 886 "parsing/parser.mly" - ( (text_sig 1) @ _2 ) -# 7732 "parsing/parser.ml" - : 'signature)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'signature_item) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'signature) in - Obj.repr( -# 887 "parsing/parser.mly" - ( (text_sig 1) @ _1 :: _2 ) -# 7740 "parsing/parser.ml" - : 'signature)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'value_description) in - Obj.repr( -# 891 "parsing/parser.mly" - ( let (body, ext) = _1 in mksig_ext (Psig_value body) ext ) -# 7747 "parsing/parser.ml" - : 'signature_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'primitive_declaration) in - Obj.repr( -# 893 "parsing/parser.mly" - ( let (body, ext) = _1 in mksig_ext (Psig_value body) ext) -# 7754 "parsing/parser.ml" - : 'signature_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'type_declarations) in - Obj.repr( -# 895 "parsing/parser.mly" - ( let (nr, l, ext) = _1 in mksig_ext (Psig_type (nr, List.rev l)) ext ) -# 7761 "parsing/parser.ml" - : 'signature_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'sig_type_extension) in - Obj.repr( -# 897 "parsing/parser.mly" - ( let (l, ext) = _1 in mksig_ext (Psig_typext l) ext ) -# 7768 "parsing/parser.ml" - : 'signature_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'sig_exception_declaration) in - Obj.repr( -# 899 "parsing/parser.mly" - ( let (l, ext) = _1 in mksig_ext (Psig_exception l) ext ) -# 7775 "parsing/parser.ml" - : 'signature_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'module_declaration) in - Obj.repr( -# 901 "parsing/parser.mly" - ( let (body, ext) = _1 in mksig_ext (Psig_module body) ext ) -# 7782 "parsing/parser.ml" - : 'signature_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'module_alias) in - Obj.repr( -# 903 "parsing/parser.mly" - ( let (body, ext) = _1 in mksig_ext (Psig_module body) ext ) -# 7789 "parsing/parser.ml" - : 'signature_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'rec_module_declarations) in - Obj.repr( -# 905 "parsing/parser.mly" - ( let (l, ext) = _1 in mksig_ext (Psig_recmodule (List.rev l)) ext ) -# 7796 "parsing/parser.ml" - : 'signature_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'module_type_declaration) in - Obj.repr( -# 907 "parsing/parser.mly" - ( let (body, ext) = _1 in mksig_ext (Psig_modtype body) ext ) -# 7803 "parsing/parser.ml" - : 'signature_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'open_statement) in - Obj.repr( -# 909 "parsing/parser.mly" - ( let (body, ext) = _1 in mksig_ext (Psig_open body) ext ) -# 7810 "parsing/parser.ml" - : 'signature_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'sig_include_statement) in - Obj.repr( -# 911 "parsing/parser.mly" - ( let (body, ext) = _1 in mksig_ext (Psig_include body) ext ) -# 7817 "parsing/parser.ml" - : 'signature_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'class_descriptions) in - Obj.repr( -# 913 "parsing/parser.mly" - ( let (l, ext) = _1 in mksig_ext (Psig_class (List.rev l)) ext ) -# 7824 "parsing/parser.ml" - : 'signature_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'class_type_declarations) in - Obj.repr( -# 915 "parsing/parser.mly" - ( let (l, ext) = _1 in mksig_ext (Psig_class_type (List.rev l)) ext ) -# 7831 "parsing/parser.ml" - : 'signature_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'item_extension) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 917 "parsing/parser.mly" - ( mksig(Psig_extension (_1, (add_docs_attrs (symbol_docs ()) _2))) ) -# 7839 "parsing/parser.ml" - : 'signature_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'floating_attribute) in - Obj.repr( -# 919 "parsing/parser.mly" - ( mark_symbol_docs (); - mksig(Psig_attribute _1) ) -# 7847 "parsing/parser.ml" - : 'signature_item)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'override_flag) in - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'mod_longident) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 924 "parsing/parser.mly" - ( let (ext, attrs) = _3 in - Opn.mk (mkrhs _4 4) ~override:_2 ~attrs:(attrs@_5) - ~loc:(symbol_rloc()) ~docs:(symbol_docs ()) - , ext) -# 7860 "parsing/parser.ml" - : 'open_statement)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'module_type) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 931 "parsing/parser.mly" - ( let (ext, attrs) = _2 in - Incl.mk _3 ~attrs:(attrs@_4) - ~loc:(symbol_rloc()) ~docs:(symbol_docs ()) - , ext) -# 7872 "parsing/parser.ml" - : 'sig_include_statement)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'module_type) in - Obj.repr( -# 938 "parsing/parser.mly" - ( _2 ) -# 7879 "parsing/parser.ml" - : 'module_declaration_body)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 4 : string) in - let _4 = (Parsing.peek_val __caml_parser_env 2 : 'module_type) in - let _6 = (Parsing.peek_val __caml_parser_env 0 : 'module_declaration_body) in - Obj.repr( -# 940 "parsing/parser.mly" - ( mkmty(Pmty_functor(mkrhs _2 2, Some _4, _6)) ) -# 7888 "parsing/parser.ml" - : 'module_declaration_body)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'module_declaration_body) in - Obj.repr( -# 942 "parsing/parser.mly" - ( mkmty(Pmty_functor(mkrhs "*" 1, None, _3)) ) -# 7895 "parsing/parser.ml" - : 'module_declaration_body)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 2 : string) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'module_declaration_body) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 946 "parsing/parser.mly" - ( let (ext, attrs) = _2 in - Md.mk (mkrhs _3 3) _4 ~attrs:(attrs@_5) - ~loc:(symbol_rloc()) ~docs:(symbol_docs ()) - , ext ) -# 7908 "parsing/parser.ml" - : 'module_declaration)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _5 = (Parsing.peek_val __caml_parser_env 1 : 'mod_longident) in - let _6 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 953 "parsing/parser.mly" - ( let (ext, attrs) = _2 in - Md.mk (mkrhs _3 3) - (Mty.alias ~loc:(rhs_loc 5) (mkrhs _5 5)) ~attrs:(attrs@_6) - ~loc:(symbol_rloc()) ~docs:(symbol_docs ()) - , ext ) -# 7922 "parsing/parser.ml" - : 'module_alias)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'rec_module_declaration) in - Obj.repr( -# 961 "parsing/parser.mly" - ( let (body, ext) = _1 in ([body], ext) ) -# 7929 "parsing/parser.ml" - : 'rec_module_declarations)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'rec_module_declarations) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'and_module_declaration) in - Obj.repr( -# 963 "parsing/parser.mly" - ( let (l, ext) = _1 in (_2 :: l, ext) ) -# 7937 "parsing/parser.ml" - : 'rec_module_declarations)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 5 : 'ext_attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _6 = (Parsing.peek_val __caml_parser_env 1 : 'module_type) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 967 "parsing/parser.mly" - ( let (ext, attrs) = _2 in - Md.mk (mkrhs _4 4) _6 ~attrs:(attrs@_7) - ~loc:(symbol_rloc()) ~docs:(symbol_docs ()) - , ext) -# 7950 "parsing/parser.ml" - : 'rec_module_declaration)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 4 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _5 = (Parsing.peek_val __caml_parser_env 1 : 'module_type) in - let _6 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 974 "parsing/parser.mly" - ( Md.mk (mkrhs _3 3) _5 ~attrs:(_2@_6) ~loc:(symbol_rloc()) - ~text:(symbol_text()) ~docs:(symbol_docs()) ) -# 7961 "parsing/parser.ml" - : 'and_module_declaration)) -; (fun __caml_parser_env -> - Obj.repr( -# 978 "parsing/parser.mly" - ( None ) -# 7967 "parsing/parser.ml" - : 'module_type_declaration_body)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'module_type) in - Obj.repr( -# 979 "parsing/parser.mly" - ( Some _2 ) -# 7974 "parsing/parser.ml" - : 'module_type_declaration_body)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 3 : 'ext_attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 2 : 'ident) in - let _5 = (Parsing.peek_val __caml_parser_env 1 : 'module_type_declaration_body) in - let _6 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 984 "parsing/parser.mly" - ( let (ext, attrs) = _3 in - Mtd.mk (mkrhs _4 4) ?typ:_5 ~attrs:(attrs@_6) - ~loc:(symbol_rloc()) ~docs:(symbol_docs ()) - , ext ) -# 7987 "parsing/parser.ml" - : 'module_type_declaration)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'class_declaration) in - Obj.repr( -# 993 "parsing/parser.mly" - ( let (body, ext) = _1 in ([body], ext) ) -# 7994 "parsing/parser.ml" - : 'class_declarations)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'class_declarations) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'and_class_declaration) in - Obj.repr( -# 995 "parsing/parser.mly" - ( let (l, ext) = _1 in (_2 :: l, ext) ) -# 8002 "parsing/parser.ml" - : 'class_declarations)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 5 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'virtual_flag) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : 'class_type_parameters) in - let _5 = (Parsing.peek_val __caml_parser_env 2 : string) in - let _6 = (Parsing.peek_val __caml_parser_env 1 : 'class_fun_binding) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1000 "parsing/parser.mly" - ( let (ext, attrs) = _2 in - Ci.mk (mkrhs _5 5) _6 ~virt:_3 ~params:_4 ~attrs:(attrs@_7) - ~loc:(symbol_rloc ()) ~docs:(symbol_docs ()) - , ext ) -# 8017 "parsing/parser.ml" - : 'class_declaration)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 5 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'virtual_flag) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : 'class_type_parameters) in - let _5 = (Parsing.peek_val __caml_parser_env 2 : string) in - let _6 = (Parsing.peek_val __caml_parser_env 1 : 'class_fun_binding) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1008 "parsing/parser.mly" - ( Ci.mk (mkrhs _5 5) _6 ~virt:_3 ~params:_4 - ~attrs:(_2@_7) ~loc:(symbol_rloc ()) - ~text:(symbol_text ()) ~docs:(symbol_docs ()) ) -# 8031 "parsing/parser.ml" - : 'and_class_declaration)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'class_expr) in - Obj.repr( -# 1014 "parsing/parser.mly" - ( _2 ) -# 8038 "parsing/parser.ml" - : 'class_fun_binding)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'class_type) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'class_expr) in - Obj.repr( -# 1016 "parsing/parser.mly" - ( mkclass(Pcl_constraint(_4, _2)) ) -# 8046 "parsing/parser.ml" - : 'class_fun_binding)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'labeled_simple_pattern) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'class_fun_binding) in - Obj.repr( -# 1018 "parsing/parser.mly" - ( let (l,o,p) = _1 in mkclass(Pcl_fun(l, o, p, _2)) ) -# 8054 "parsing/parser.ml" - : 'class_fun_binding)) -; (fun __caml_parser_env -> - Obj.repr( -# 1021 "parsing/parser.mly" - ( [] ) -# 8060 "parsing/parser.ml" - : 'class_type_parameters)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'type_parameter_list) in - Obj.repr( -# 1022 "parsing/parser.mly" - ( List.rev _2 ) -# 8067 "parsing/parser.ml" - : 'class_type_parameters)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'labeled_simple_pattern) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'class_expr) in - Obj.repr( -# 1026 "parsing/parser.mly" - ( let (l,o,p) = _1 in mkclass(Pcl_fun(l, o, p, _3)) ) -# 8075 "parsing/parser.ml" - : 'class_fun_def)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'labeled_simple_pattern) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'class_fun_def) in - Obj.repr( -# 1028 "parsing/parser.mly" - ( let (l,o,p) = _1 in mkclass(Pcl_fun(l, o, p, _2)) ) -# 8083 "parsing/parser.ml" - : 'class_fun_def)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'class_simple_expr) in - Obj.repr( -# 1032 "parsing/parser.mly" - ( _1 ) -# 8090 "parsing/parser.ml" - : 'class_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'class_fun_def) in - Obj.repr( -# 1034 "parsing/parser.mly" - ( wrap_class_attrs _3 _2 ) -# 8098 "parsing/parser.ml" - : 'class_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'class_simple_expr) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'simple_labeled_expr_list) in - Obj.repr( -# 1036 "parsing/parser.mly" - ( mkclass(Pcl_apply(_1, List.rev _2)) ) -# 8106 "parsing/parser.ml" - : 'class_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'let_bindings) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'class_expr) in - Obj.repr( -# 1038 "parsing/parser.mly" - ( class_of_let_bindings _1 _3 ) -# 8114 "parsing/parser.ml" - : 'class_expr)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'override_flag) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : 'attributes) in - let _5 = (Parsing.peek_val __caml_parser_env 2 : 'mod_longident) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'class_expr) in - Obj.repr( -# 1040 "parsing/parser.mly" - ( wrap_class_attrs (mkclass(Pcl_open(_3, mkrhs _5 5, _7))) _4 ) -# 8124 "parsing/parser.ml" - : 'class_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'class_expr) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attribute) in - Obj.repr( -# 1042 "parsing/parser.mly" - ( Cl.attr _1 _2 ) -# 8132 "parsing/parser.ml" - : 'class_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'extension) in - Obj.repr( -# 1044 "parsing/parser.mly" - ( mkclass(Pcl_extension _1) ) -# 8139 "parsing/parser.ml" - : 'class_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'core_type_comma_list) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'class_longident) in - Obj.repr( -# 1048 "parsing/parser.mly" - ( mkclass(Pcl_constr(mkloc _4 (rhs_loc 4), List.rev _2)) ) -# 8147 "parsing/parser.ml" - : 'class_simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'class_longident) in - Obj.repr( -# 1050 "parsing/parser.mly" - ( mkclass(Pcl_constr(mkrhs _1 1, [])) ) -# 8154 "parsing/parser.ml" - : 'class_simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'class_structure) in - Obj.repr( -# 1052 "parsing/parser.mly" - ( mkclass ~attrs:_2 (Pcl_structure _3) ) -# 8162 "parsing/parser.ml" - : 'class_simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'class_structure) in - Obj.repr( -# 1054 "parsing/parser.mly" - ( unclosed "object" 1 "end" 4 ) -# 8170 "parsing/parser.ml" - : 'class_simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'class_expr) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'class_type) in - Obj.repr( -# 1056 "parsing/parser.mly" - ( mkclass(Pcl_constraint(_2, _4)) ) -# 8178 "parsing/parser.ml" - : 'class_simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'class_expr) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'class_type) in - Obj.repr( -# 1058 "parsing/parser.mly" - ( unclosed "(" 1 ")" 5 ) -# 8186 "parsing/parser.ml" - : 'class_simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'class_expr) in - Obj.repr( -# 1060 "parsing/parser.mly" - ( _2 ) -# 8193 "parsing/parser.ml" - : 'class_simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'class_expr) in - Obj.repr( -# 1062 "parsing/parser.mly" - ( unclosed "(" 1 ")" 3 ) -# 8200 "parsing/parser.ml" - : 'class_simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'class_self_pattern) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'class_fields) in - Obj.repr( -# 1066 "parsing/parser.mly" - ( Cstr.mk _1 (extra_cstr 2 (List.rev _2)) ) -# 8208 "parsing/parser.ml" - : 'class_structure)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'pattern) in - Obj.repr( -# 1070 "parsing/parser.mly" - ( reloc_pat _2 ) -# 8215 "parsing/parser.ml" - : 'class_self_pattern)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'pattern) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'core_type) in - Obj.repr( -# 1072 "parsing/parser.mly" - ( mkpat(Ppat_constraint(_2, _4)) ) -# 8223 "parsing/parser.ml" - : 'class_self_pattern)) -; (fun __caml_parser_env -> - Obj.repr( -# 1074 "parsing/parser.mly" - ( ghpat(Ppat_any) ) -# 8229 "parsing/parser.ml" - : 'class_self_pattern)) -; (fun __caml_parser_env -> - Obj.repr( -# 1078 "parsing/parser.mly" - ( [] ) -# 8235 "parsing/parser.ml" - : 'class_fields)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'class_fields) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'class_field) in - Obj.repr( -# 1080 "parsing/parser.mly" - ( _2 :: (text_cstr 2) @ _1 ) -# 8243 "parsing/parser.ml" - : 'class_fields)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 4 : 'override_flag) in - let _3 = (Parsing.peek_val __caml_parser_env 3 : 'attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 2 : 'class_expr) in - let _5 = (Parsing.peek_val __caml_parser_env 1 : 'parent_binder) in - let _6 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1085 "parsing/parser.mly" - ( mkcf (Pcf_inherit (_2, _4, _5)) ~attrs:(_3@_6) ~docs:(symbol_docs ()) ) -# 8254 "parsing/parser.ml" - : 'class_field)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'value) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1087 "parsing/parser.mly" - ( let v, attrs = _2 in - mkcf (Pcf_val v) ~attrs:(attrs@_3) ~docs:(symbol_docs ()) ) -# 8263 "parsing/parser.ml" - : 'class_field)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'method_) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1090 "parsing/parser.mly" - ( let meth, attrs = _2 in - mkcf (Pcf_method meth) ~attrs:(attrs@_3) ~docs:(symbol_docs ()) ) -# 8272 "parsing/parser.ml" - : 'class_field)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'constrain_field) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1093 "parsing/parser.mly" - ( mkcf (Pcf_constraint _3) ~attrs:(_2@_4) ~docs:(symbol_docs ()) ) -# 8281 "parsing/parser.ml" - : 'class_field)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1095 "parsing/parser.mly" - ( mkcf (Pcf_initializer _3) ~attrs:(_2@_4) ~docs:(symbol_docs ()) ) -# 8290 "parsing/parser.ml" - : 'class_field)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'item_extension) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1097 "parsing/parser.mly" - ( mkcf (Pcf_extension _1) ~attrs:_2 ~docs:(symbol_docs ()) ) -# 8298 "parsing/parser.ml" - : 'class_field)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'floating_attribute) in - Obj.repr( -# 1099 "parsing/parser.mly" - ( mark_symbol_docs (); - mkcf (Pcf_attribute _1) ) -# 8306 "parsing/parser.ml" - : 'class_field)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 1104 "parsing/parser.mly" - ( Some (mkrhs _2 2) ) -# 8313 "parsing/parser.ml" - : 'parent_binder)) -; (fun __caml_parser_env -> - Obj.repr( -# 1106 "parsing/parser.mly" - ( None ) -# 8319 "parsing/parser.ml" - : 'parent_binder)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 6 : 'override_flag) in - let _2 = (Parsing.peek_val __caml_parser_env 5 : 'attributes) in - let _5 = (Parsing.peek_val __caml_parser_env 2 : 'label) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in - Obj.repr( -# 1111 "parsing/parser.mly" - ( if _1 = Override then syntax_error (); - (mkloc _5 (rhs_loc 5), Mutable, Cfk_virtual _7), _2 ) -# 8330 "parsing/parser.ml" - : 'value)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 6 : 'override_flag) in - let _2 = (Parsing.peek_val __caml_parser_env 5 : 'attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : 'mutable_flag) in - let _5 = (Parsing.peek_val __caml_parser_env 2 : 'label) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in - Obj.repr( -# 1114 "parsing/parser.mly" - ( if _1 = Override then syntax_error (); - (mkrhs _5 5, _4, Cfk_virtual _7), _2 ) -# 8342 "parsing/parser.ml" - : 'value)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 5 : 'override_flag) in - let _2 = (Parsing.peek_val __caml_parser_env 4 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 3 : 'mutable_flag) in - let _4 = (Parsing.peek_val __caml_parser_env 2 : 'label) in - let _6 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1117 "parsing/parser.mly" - ( (mkrhs _4 4, _3, Cfk_concrete (_1, _6)), _2 ) -# 8353 "parsing/parser.ml" - : 'value)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 6 : 'override_flag) in - let _2 = (Parsing.peek_val __caml_parser_env 5 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'mutable_flag) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : 'label) in - let _5 = (Parsing.peek_val __caml_parser_env 2 : 'type_constraint) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1119 "parsing/parser.mly" - ( - let e = mkexp_constraint _7 _5 in - (mkrhs _4 4, _3, Cfk_concrete (_1, e)), _2 - ) -# 8368 "parsing/parser.ml" - : 'value)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 6 : 'override_flag) in - let _2 = (Parsing.peek_val __caml_parser_env 5 : 'attributes) in - let _5 = (Parsing.peek_val __caml_parser_env 2 : 'label) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'poly_type) in - Obj.repr( -# 1127 "parsing/parser.mly" - ( if _1 = Override then syntax_error (); - (mkloc _5 (rhs_loc 5), Private, Cfk_virtual _7), _2 ) -# 8379 "parsing/parser.ml" - : 'method_)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 6 : 'override_flag) in - let _2 = (Parsing.peek_val __caml_parser_env 5 : 'attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : 'private_flag) in - let _5 = (Parsing.peek_val __caml_parser_env 2 : 'label) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'poly_type) in - Obj.repr( -# 1130 "parsing/parser.mly" - ( if _1 = Override then syntax_error (); - (mkloc _5 (rhs_loc 5), _4, Cfk_virtual _7), _2 ) -# 8391 "parsing/parser.ml" - : 'method_)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'override_flag) in - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'private_flag) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'label) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'strict_binding) in - Obj.repr( -# 1133 "parsing/parser.mly" - ( (mkloc _4 (rhs_loc 4), _3, - Cfk_concrete (_1, ghexp(Pexp_poly (_5, None)))), _2 ) -# 8403 "parsing/parser.ml" - : 'method_)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 7 : 'override_flag) in - let _2 = (Parsing.peek_val __caml_parser_env 6 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 5 : 'private_flag) in - let _4 = (Parsing.peek_val __caml_parser_env 4 : 'label) in - let _6 = (Parsing.peek_val __caml_parser_env 2 : 'poly_type) in - let _8 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1136 "parsing/parser.mly" - ( (mkloc _4 (rhs_loc 4), _3, - Cfk_concrete (_1, ghexp(Pexp_poly(_8, Some _6)))), _2 ) -# 8416 "parsing/parser.ml" - : 'method_)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 10 : 'override_flag) in - let _2 = (Parsing.peek_val __caml_parser_env 9 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 8 : 'private_flag) in - let _4 = (Parsing.peek_val __caml_parser_env 7 : 'label) in - let _7 = (Parsing.peek_val __caml_parser_env 4 : 'lident_list) in - let _9 = (Parsing.peek_val __caml_parser_env 2 : 'core_type) in - let _11 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1140 "parsing/parser.mly" - ( let exp, poly = wrap_type_annotation _7 _9 _11 in - (mkloc _4 (rhs_loc 4), _3, - Cfk_concrete (_1, ghexp(Pexp_poly(exp, Some poly)))), _2 ) -# 8431 "parsing/parser.ml" - : 'method_)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'class_signature) in - Obj.repr( -# 1149 "parsing/parser.mly" - ( _1 ) -# 8438 "parsing/parser.ml" - : 'class_type)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 4 : string) in - let _4 = (Parsing.peek_val __caml_parser_env 2 : 'simple_core_type_or_tuple) in - let _6 = (Parsing.peek_val __caml_parser_env 0 : 'class_type) in - Obj.repr( -# 1152 "parsing/parser.mly" - ( mkcty(Pcty_arrow(Optional _2 , _4, _6)) ) -# 8447 "parsing/parser.ml" - : 'class_type)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'simple_core_type_or_tuple) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'class_type) in - Obj.repr( -# 1154 "parsing/parser.mly" - ( mkcty(Pcty_arrow(Optional _1, _2, _4)) ) -# 8456 "parsing/parser.ml" - : 'class_type)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : string) in - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'simple_core_type_or_tuple) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'class_type) in - Obj.repr( -# 1156 "parsing/parser.mly" - ( mkcty(Pcty_arrow(Labelled _1, _3, _5)) ) -# 8465 "parsing/parser.ml" - : 'class_type)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'simple_core_type_or_tuple) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'class_type) in - Obj.repr( -# 1158 "parsing/parser.mly" - ( mkcty(Pcty_arrow(Nolabel, _1, _3)) ) -# 8473 "parsing/parser.ml" - : 'class_type)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'core_type_comma_list) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'clty_longident) in - Obj.repr( -# 1162 "parsing/parser.mly" - ( mkcty(Pcty_constr (mkloc _4 (rhs_loc 4), List.rev _2)) ) -# 8481 "parsing/parser.ml" - : 'class_signature)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'clty_longident) in - Obj.repr( -# 1164 "parsing/parser.mly" - ( mkcty(Pcty_constr (mkrhs _1 1, [])) ) -# 8488 "parsing/parser.ml" - : 'class_signature)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'class_sig_body) in - Obj.repr( -# 1166 "parsing/parser.mly" - ( mkcty ~attrs:_2 (Pcty_signature _3) ) -# 8496 "parsing/parser.ml" - : 'class_signature)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'class_sig_body) in - Obj.repr( -# 1168 "parsing/parser.mly" - ( unclosed "object" 1 "end" 4 ) -# 8504 "parsing/parser.ml" - : 'class_signature)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'class_signature) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attribute) in - Obj.repr( -# 1170 "parsing/parser.mly" - ( Cty.attr _1 _2 ) -# 8512 "parsing/parser.ml" - : 'class_signature)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'extension) in - Obj.repr( -# 1172 "parsing/parser.mly" - ( mkcty(Pcty_extension _1) ) -# 8519 "parsing/parser.ml" - : 'class_signature)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'override_flag) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : 'attributes) in - let _5 = (Parsing.peek_val __caml_parser_env 2 : 'mod_longident) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'class_signature) in - Obj.repr( -# 1174 "parsing/parser.mly" - ( wrap_class_type_attrs (mkcty(Pcty_open(_3, mkrhs _5 5, _7))) _4 ) -# 8529 "parsing/parser.ml" - : 'class_signature)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'class_self_type) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'class_sig_fields) in - Obj.repr( -# 1178 "parsing/parser.mly" - ( Csig.mk _1 (extra_csig 2 (List.rev _2)) ) -# 8537 "parsing/parser.ml" - : 'class_sig_body)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'core_type) in - Obj.repr( -# 1182 "parsing/parser.mly" - ( _2 ) -# 8544 "parsing/parser.ml" - : 'class_self_type)) -; (fun __caml_parser_env -> - Obj.repr( -# 1184 "parsing/parser.mly" - ( mktyp(Ptyp_any) ) -# 8550 "parsing/parser.ml" - : 'class_self_type)) -; (fun __caml_parser_env -> - Obj.repr( -# 1187 "parsing/parser.mly" - ( [] ) -# 8556 "parsing/parser.ml" - : 'class_sig_fields)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'class_sig_fields) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'class_sig_field) in - Obj.repr( -# 1188 "parsing/parser.mly" - ( _2 :: (text_csig 2) @ _1 ) -# 8564 "parsing/parser.ml" - : 'class_sig_fields)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'class_signature) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1192 "parsing/parser.mly" - ( mkctf (Pctf_inherit _3) ~attrs:(_2@_4) ~docs:(symbol_docs ()) ) -# 8573 "parsing/parser.ml" - : 'class_sig_field)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'value_type) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1194 "parsing/parser.mly" - ( mkctf (Pctf_val _3) ~attrs:(_2@_4) ~docs:(symbol_docs ()) ) -# 8582 "parsing/parser.ml" - : 'class_sig_field)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 5 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'private_virtual_flags) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : 'label) in - let _6 = (Parsing.peek_val __caml_parser_env 1 : 'poly_type) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1197 "parsing/parser.mly" - ( - let (p, v) = _3 in - mkctf (Pctf_method (mkrhs _4 4, p, v, _6)) ~attrs:(_2@_7) ~docs:(symbol_docs ()) - ) -# 8596 "parsing/parser.ml" - : 'class_sig_field)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'constrain_field) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1202 "parsing/parser.mly" - ( mkctf (Pctf_constraint _3) ~attrs:(_2@_4) ~docs:(symbol_docs ()) ) -# 8605 "parsing/parser.ml" - : 'class_sig_field)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'item_extension) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1204 "parsing/parser.mly" - ( mkctf (Pctf_extension _1) ~attrs:_2 ~docs:(symbol_docs ()) ) -# 8613 "parsing/parser.ml" - : 'class_sig_field)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'floating_attribute) in - Obj.repr( -# 1206 "parsing/parser.mly" - ( mark_symbol_docs (); - mkctf(Pctf_attribute _1) ) -# 8621 "parsing/parser.ml" - : 'class_sig_field)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'mutable_flag) in - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'label) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in - Obj.repr( -# 1211 "parsing/parser.mly" - ( mkrhs _3 3, _2, Virtual, _5 ) -# 8630 "parsing/parser.ml" - : 'value_type)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'virtual_flag) in - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'label) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in - Obj.repr( -# 1213 "parsing/parser.mly" - ( mkrhs _3 3, Mutable, _2, _5 ) -# 8639 "parsing/parser.ml" - : 'value_type)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'label) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in - Obj.repr( -# 1215 "parsing/parser.mly" - ( mkrhs _1 1, Immutable, Concrete, _3 ) -# 8647 "parsing/parser.ml" - : 'value_type)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'core_type) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in - Obj.repr( -# 1218 "parsing/parser.mly" - ( _1, _3, symbol_rloc() ) -# 8655 "parsing/parser.ml" - : 'constrain)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'core_type) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in - Obj.repr( -# 1221 "parsing/parser.mly" - ( _1, _3 ) -# 8663 "parsing/parser.ml" - : 'constrain_field)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'class_description) in - Obj.repr( -# 1225 "parsing/parser.mly" - ( let (body, ext) = _1 in ([body],ext) ) -# 8670 "parsing/parser.ml" - : 'class_descriptions)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'class_descriptions) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'and_class_description) in - Obj.repr( -# 1227 "parsing/parser.mly" - ( let (l, ext) = _1 in (_2 :: l, ext) ) -# 8678 "parsing/parser.ml" - : 'class_descriptions)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 6 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 5 : 'virtual_flag) in - let _4 = (Parsing.peek_val __caml_parser_env 4 : 'class_type_parameters) in - let _5 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _7 = (Parsing.peek_val __caml_parser_env 1 : 'class_type) in - let _8 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1232 "parsing/parser.mly" - ( let (ext, attrs) = _2 in - Ci.mk (mkrhs _5 5) _7 ~virt:_3 ~params:_4 ~attrs:(attrs @ _8) - ~loc:(symbol_rloc ()) ~docs:(symbol_docs ()) - , ext ) -# 8693 "parsing/parser.ml" - : 'class_description)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 6 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 5 : 'virtual_flag) in - let _4 = (Parsing.peek_val __caml_parser_env 4 : 'class_type_parameters) in - let _5 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _7 = (Parsing.peek_val __caml_parser_env 1 : 'class_type) in - let _8 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1240 "parsing/parser.mly" - ( Ci.mk (mkrhs _5 5) _7 ~virt:_3 ~params:_4 - ~attrs:(_2@_8) ~loc:(symbol_rloc ()) - ~text:(symbol_text ()) ~docs:(symbol_docs ()) ) -# 8707 "parsing/parser.ml" - : 'and_class_description)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'class_type_declaration) in - Obj.repr( -# 1246 "parsing/parser.mly" - ( let (body, ext) = _1 in ([body],ext) ) -# 8714 "parsing/parser.ml" - : 'class_type_declarations)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'class_type_declarations) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'and_class_type_declaration) in - Obj.repr( -# 1248 "parsing/parser.mly" - ( let (l, ext) = _1 in (_2 :: l, ext) ) -# 8722 "parsing/parser.ml" - : 'class_type_declarations)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 6 : 'ext_attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 5 : 'virtual_flag) in - let _5 = (Parsing.peek_val __caml_parser_env 4 : 'class_type_parameters) in - let _6 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _8 = (Parsing.peek_val __caml_parser_env 1 : 'class_signature) in - let _9 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1253 "parsing/parser.mly" - ( let (ext, attrs) = _3 in - Ci.mk (mkrhs _6 6) _8 ~virt:_4 ~params:_5 ~attrs:(attrs@_9) - ~loc:(symbol_rloc ()) ~docs:(symbol_docs ()) - , ext) -# 8737 "parsing/parser.ml" - : 'class_type_declaration)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 6 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 5 : 'virtual_flag) in - let _4 = (Parsing.peek_val __caml_parser_env 4 : 'class_type_parameters) in - let _5 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _7 = (Parsing.peek_val __caml_parser_env 1 : 'class_signature) in - let _8 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1261 "parsing/parser.mly" - ( Ci.mk (mkrhs _5 5) _7 ~virt:_3 ~params:_4 - ~attrs:(_2@_8) ~loc:(symbol_rloc ()) - ~text:(symbol_text ()) ~docs:(symbol_docs ()) ) -# 8751 "parsing/parser.ml" - : 'and_class_type_declaration)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1269 "parsing/parser.mly" - ( _1 ) -# 8758 "parsing/parser.ml" - : 'seq_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in - Obj.repr( -# 1270 "parsing/parser.mly" - ( _1 ) -# 8765 "parsing/parser.ml" - : 'seq_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1271 "parsing/parser.mly" - ( mkexp(Pexp_sequence(_1, _3)) ) -# 8773 "parsing/parser.ml" - : 'seq_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'expr) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'attr_id) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1273 "parsing/parser.mly" - ( let seq = mkexp(Pexp_sequence (_1, _5)) in - let payload = PStr [mkstrexp seq []] in - mkexp (Pexp_extension (_4, payload)) ) -# 8784 "parsing/parser.ml" - : 'seq_expr)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'label_let_pattern) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'opt_default) in - Obj.repr( -# 1279 "parsing/parser.mly" - ( (Optional (fst _3), _4, snd _3) ) -# 8792 "parsing/parser.ml" - : 'labeled_simple_pattern)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'label_var) in - Obj.repr( -# 1281 "parsing/parser.mly" - ( (Optional (fst _2), None, snd _2) ) -# 8799 "parsing/parser.ml" - : 'labeled_simple_pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : string) in - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'let_pattern) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'opt_default) in - Obj.repr( -# 1283 "parsing/parser.mly" - ( (Optional _1, _4, _3) ) -# 8808 "parsing/parser.ml" - : 'labeled_simple_pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : string) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'pattern_var) in - Obj.repr( -# 1285 "parsing/parser.mly" - ( (Optional _1, None, _2) ) -# 8816 "parsing/parser.ml" - : 'labeled_simple_pattern)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'label_let_pattern) in - Obj.repr( -# 1287 "parsing/parser.mly" - ( (Labelled (fst _3), None, snd _3) ) -# 8823 "parsing/parser.ml" - : 'labeled_simple_pattern)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'label_var) in - Obj.repr( -# 1289 "parsing/parser.mly" - ( (Labelled (fst _2), None, snd _2) ) -# 8830 "parsing/parser.ml" - : 'labeled_simple_pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : string) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'simple_pattern) in - Obj.repr( -# 1291 "parsing/parser.mly" - ( (Labelled _1, None, _2) ) -# 8838 "parsing/parser.ml" - : 'labeled_simple_pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_pattern) in - Obj.repr( -# 1293 "parsing/parser.mly" - ( (Nolabel, None, _1) ) -# 8845 "parsing/parser.ml" - : 'labeled_simple_pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 1296 "parsing/parser.mly" - ( mkpat(Ppat_var (mkrhs _1 1)) ) -# 8852 "parsing/parser.ml" - : 'pattern_var)) -; (fun __caml_parser_env -> - Obj.repr( -# 1297 "parsing/parser.mly" - ( mkpat Ppat_any ) -# 8858 "parsing/parser.ml" - : 'pattern_var)) -; (fun __caml_parser_env -> - Obj.repr( -# 1300 "parsing/parser.mly" - ( None ) -# 8864 "parsing/parser.ml" - : 'opt_default)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1301 "parsing/parser.mly" - ( Some _2 ) -# 8871 "parsing/parser.ml" - : 'opt_default)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'label_var) in - Obj.repr( -# 1305 "parsing/parser.mly" - ( _1 ) -# 8878 "parsing/parser.ml" - : 'label_let_pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'label_var) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in - Obj.repr( -# 1307 "parsing/parser.mly" - ( let (lab, pat) = _1 in (lab, mkpat(Ppat_constraint(pat, _3))) ) -# 8886 "parsing/parser.ml" - : 'label_let_pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 1310 "parsing/parser.mly" - ( (_1, mkpat(Ppat_var (mkrhs _1 1))) ) -# 8893 "parsing/parser.ml" - : 'label_var)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in - Obj.repr( -# 1314 "parsing/parser.mly" - ( _1 ) -# 8900 "parsing/parser.ml" - : 'let_pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in - Obj.repr( -# 1316 "parsing/parser.mly" - ( mkpat(Ppat_constraint(_1, _3)) ) -# 8908 "parsing/parser.ml" - : 'let_pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in - Obj.repr( -# 1320 "parsing/parser.mly" - ( _1 ) -# 8915 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'simple_expr) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'simple_labeled_expr_list) in - Obj.repr( -# 1322 "parsing/parser.mly" - ( mkexp(Pexp_apply(_1, List.rev _2)) ) -# 8923 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'let_bindings) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1324 "parsing/parser.mly" - ( expr_of_let_bindings _1 _3 ) -# 8931 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _5 = (Parsing.peek_val __caml_parser_env 2 : 'module_binding_body) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1326 "parsing/parser.mly" - ( mkexp_attrs (Pexp_letmodule(mkrhs _4 4, _5, _7)) _3 ) -# 8941 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 3 : 'ext_attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 2 : 'let_exception_declaration) in - let _6 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1328 "parsing/parser.mly" - ( mkexp_attrs (Pexp_letexception(_4, _6)) _3 ) -# 8950 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'override_flag) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : 'ext_attributes) in - let _5 = (Parsing.peek_val __caml_parser_env 2 : 'mod_longident) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1330 "parsing/parser.mly" - ( mkexp_attrs (Pexp_open(_3, mkrhs _5 5, _7)) _4 ) -# 8960 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'opt_bar) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'match_cases) in - Obj.repr( -# 1332 "parsing/parser.mly" - ( mkexp_attrs (Pexp_function(List.rev _4)) _2 ) -# 8969 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'labeled_simple_pattern) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'fun_def) in - Obj.repr( -# 1334 "parsing/parser.mly" - ( let (l,o,p) = _3 in - mkexp_attrs (Pexp_fun(l, o, p, _4)) _2 ) -# 8979 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 5 : 'ext_attributes) in - let _5 = (Parsing.peek_val __caml_parser_env 2 : 'lident_list) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'fun_def) in - Obj.repr( -# 1337 "parsing/parser.mly" - ( mkexp_attrs (mk_newtypes _5 _7).pexp_desc _2 ) -# 8988 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 3 : 'seq_expr) in - let _5 = (Parsing.peek_val __caml_parser_env 1 : 'opt_bar) in - let _6 = (Parsing.peek_val __caml_parser_env 0 : 'match_cases) in - Obj.repr( -# 1339 "parsing/parser.mly" - ( mkexp_attrs (Pexp_match(_3, List.rev _6)) _2 ) -# 8998 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 3 : 'seq_expr) in - let _5 = (Parsing.peek_val __caml_parser_env 1 : 'opt_bar) in - let _6 = (Parsing.peek_val __caml_parser_env 0 : 'match_cases) in - Obj.repr( -# 1341 "parsing/parser.mly" - ( mkexp_attrs (Pexp_try(_3, List.rev _6)) _2 ) -# 9008 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'seq_expr) in - Obj.repr( -# 1343 "parsing/parser.mly" - ( syntax_error() ) -# 9016 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'expr_comma_list) in - Obj.repr( -# 1345 "parsing/parser.mly" - ( mkexp(Pexp_tuple(List.rev _1)) ) -# 9023 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'constr_longident) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in - Obj.repr( -# 1347 "parsing/parser.mly" - ( mkexp(Pexp_construct(mkrhs _1 1, Some _2)) ) -# 9031 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'name_tag) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in - Obj.repr( -# 1349 "parsing/parser.mly" - ( mkexp(Pexp_variant(_1, Some _2)) ) -# 9039 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 5 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'seq_expr) in - let _5 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1351 "parsing/parser.mly" - ( mkexp_attrs(Pexp_ifthenelse(_3, _5, Some _7)) _2 ) -# 9049 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'seq_expr) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1353 "parsing/parser.mly" - ( mkexp_attrs (Pexp_ifthenelse(_3, _5, None)) _2 ) -# 9058 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 3 : 'seq_expr) in - let _5 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in - Obj.repr( -# 1355 "parsing/parser.mly" - ( mkexp_attrs (Pexp_while(_3, _5)) _2 ) -# 9067 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 8 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 7 : 'pattern) in - let _5 = (Parsing.peek_val __caml_parser_env 5 : 'seq_expr) in - let _6 = (Parsing.peek_val __caml_parser_env 4 : 'direction_flag) in - let _7 = (Parsing.peek_val __caml_parser_env 3 : 'seq_expr) in - let _9 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in - Obj.repr( -# 1358 "parsing/parser.mly" - ( mkexp_attrs(Pexp_for(_3, _5, _7, _6, _9)) _2 ) -# 9079 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1360 "parsing/parser.mly" - ( mkexp_cons (rhs_loc 2) (ghexp(Pexp_tuple[_1;_3])) (symbol_rloc()) ) -# 9087 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _2 = (Parsing.peek_val __caml_parser_env 1 : string) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1362 "parsing/parser.mly" - ( mkinfix _1 _2 _3 ) -# 9096 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _2 = (Parsing.peek_val __caml_parser_env 1 : string) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1364 "parsing/parser.mly" - ( mkinfix _1 _2 _3 ) -# 9105 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _2 = (Parsing.peek_val __caml_parser_env 1 : string) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1366 "parsing/parser.mly" - ( mkinfix _1 _2 _3 ) -# 9114 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _2 = (Parsing.peek_val __caml_parser_env 1 : string) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1368 "parsing/parser.mly" - ( mkinfix _1 _2 _3 ) -# 9123 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _2 = (Parsing.peek_val __caml_parser_env 1 : string) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1370 "parsing/parser.mly" - ( mkinfix _1 _2 _3 ) -# 9132 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1372 "parsing/parser.mly" - ( mkinfix _1 "+" _3 ) -# 9140 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1374 "parsing/parser.mly" - ( mkinfix _1 "+." _3 ) -# 9148 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1376 "parsing/parser.mly" - ( mkinfix _1 "+=" _3 ) -# 9156 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1378 "parsing/parser.mly" - ( mkinfix _1 "-" _3 ) -# 9164 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1380 "parsing/parser.mly" - ( mkinfix _1 "-." _3 ) -# 9172 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1382 "parsing/parser.mly" - ( mkinfix _1 "*" _3 ) -# 9180 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1384 "parsing/parser.mly" - ( mkinfix _1 "%" _3 ) -# 9188 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1386 "parsing/parser.mly" - ( mkinfix _1 "=" _3 ) -# 9196 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1388 "parsing/parser.mly" - ( mkinfix _1 "<" _3 ) -# 9204 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1390 "parsing/parser.mly" - ( mkinfix _1 ">" _3 ) -# 9212 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1392 "parsing/parser.mly" - ( mkinfix _1 "or" _3 ) -# 9220 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1394 "parsing/parser.mly" - ( mkinfix _1 "||" _3 ) -# 9228 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1396 "parsing/parser.mly" - ( mkinfix _1 "&" _3 ) -# 9236 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1398 "parsing/parser.mly" - ( mkinfix _1 "&&" _3 ) -# 9244 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1400 "parsing/parser.mly" - ( mkinfix _1 ":=" _3 ) -# 9252 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'subtractive) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1402 "parsing/parser.mly" - ( mkuminus _1 _2 ) -# 9260 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'additive) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1404 "parsing/parser.mly" - ( mkuplus _1 _2 ) -# 9268 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'label_longident) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1406 "parsing/parser.mly" - ( mkexp(Pexp_setfield(_1, mkrhs _3 3, _5)) ) -# 9277 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : 'seq_expr) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1408 "parsing/parser.mly" - ( mkexp(Pexp_apply(ghexp(Pexp_ident(array_function "Array" "set")), - [Nolabel,_1; Nolabel,_4; Nolabel,_7])) ) -# 9287 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : 'seq_expr) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1411 "parsing/parser.mly" - ( mkexp(Pexp_apply(ghexp(Pexp_ident(array_function "String" "set")), - [Nolabel,_1; Nolabel,_4; Nolabel,_7])) ) -# 9297 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : 'expr) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1414 "parsing/parser.mly" - ( bigarray_set _1 _4 _7 ) -# 9306 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in - let _2 = (Parsing.peek_val __caml_parser_env 5 : string) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : 'expr) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1416 "parsing/parser.mly" - ( let id = mkexp @@ Pexp_ident( ghloc @@ Lident ("." ^ _2 ^ "[]<-")) in - mkexp @@ Pexp_apply(id , [Nolabel, _1; Nolabel, _4; Nolabel, _7]) ) -# 9317 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in - let _2 = (Parsing.peek_val __caml_parser_env 5 : string) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : 'expr) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1419 "parsing/parser.mly" - ( let id = mkexp @@ Pexp_ident( ghloc @@ Lident ("." ^ _2 ^ "()<-")) in - mkexp @@ Pexp_apply(id , [Nolabel, _1; Nolabel, _4; Nolabel, _7]) ) -# 9328 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in - let _2 = (Parsing.peek_val __caml_parser_env 5 : string) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : 'expr) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1422 "parsing/parser.mly" - ( let id = mkexp @@ Pexp_ident( ghloc @@ Lident ("." ^ _2 ^ "{}<-")) in - mkexp @@ Pexp_apply(id , [Nolabel, _1; Nolabel, _4; Nolabel, _7]) ) -# 9339 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 8 : 'simple_expr) in - let _3 = (Parsing.peek_val __caml_parser_env 6 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 5 : string) in - let _6 = (Parsing.peek_val __caml_parser_env 3 : 'expr) in - let _9 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1425 "parsing/parser.mly" - ( let id = mkexp @@ Pexp_ident( ghloc @@ Ldot(_3,"." ^ _4 ^ "[]<-")) in - mkexp @@ Pexp_apply(id , [Nolabel, _1; Nolabel, _6; Nolabel, _9]) ) -# 9351 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 8 : 'simple_expr) in - let _3 = (Parsing.peek_val __caml_parser_env 6 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 5 : string) in - let _6 = (Parsing.peek_val __caml_parser_env 3 : 'expr) in - let _9 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1428 "parsing/parser.mly" - ( let id = mkexp @@ Pexp_ident( ghloc @@ Ldot(_3, "." ^ _4 ^ "()<-")) in - mkexp @@ Pexp_apply(id , [Nolabel, _1; Nolabel, _6; Nolabel, _9]) ) -# 9363 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 8 : 'simple_expr) in - let _3 = (Parsing.peek_val __caml_parser_env 6 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 5 : string) in - let _6 = (Parsing.peek_val __caml_parser_env 3 : 'expr) in - let _9 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1431 "parsing/parser.mly" - ( let id = mkexp @@ Pexp_ident( ghloc @@ Ldot(_3, "." ^ _4 ^ "{}<-")) in - mkexp @@ Pexp_apply(id , [Nolabel, _1; Nolabel, _6; Nolabel, _9]) ) -# 9375 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'label) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1434 "parsing/parser.mly" - ( mkexp(Pexp_setinstvar(mkrhs _1 1, _3)) ) -# 9383 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in - Obj.repr( -# 1436 "parsing/parser.mly" - ( mkexp_attrs (Pexp_assert _3) _2 ) -# 9391 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in - Obj.repr( -# 1438 "parsing/parser.mly" - ( mkexp_attrs (Pexp_lazy _3) _2 ) -# 9399 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'class_structure) in - Obj.repr( -# 1440 "parsing/parser.mly" - ( mkexp_attrs (Pexp_object _3) _2 ) -# 9407 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'class_structure) in - Obj.repr( -# 1442 "parsing/parser.mly" - ( unclosed "object" 1 "end" 4 ) -# 9415 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attribute) in - Obj.repr( -# 1444 "parsing/parser.mly" - ( Exp.attr _1 _2 ) -# 9423 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - Obj.repr( -# 1446 "parsing/parser.mly" - ( not_expecting 1 "wildcard \"_\"" ) -# 9429 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'val_longident) in - Obj.repr( -# 1450 "parsing/parser.mly" - ( mkexp(Pexp_ident (mkrhs _1 1)) ) -# 9436 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'constant) in - Obj.repr( -# 1452 "parsing/parser.mly" - ( mkexp(Pexp_constant _1) ) -# 9443 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'constr_longident) in - Obj.repr( -# 1454 "parsing/parser.mly" - ( mkexp(Pexp_construct(mkrhs _1 1, None)) ) -# 9450 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'name_tag) in - Obj.repr( -# 1456 "parsing/parser.mly" - ( mkexp(Pexp_variant(_1, None)) ) -# 9457 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in - Obj.repr( -# 1458 "parsing/parser.mly" - ( reloc_exp _2 ) -# 9464 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in - Obj.repr( -# 1460 "parsing/parser.mly" - ( unclosed "(" 1 ")" 3 ) -# 9471 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in - Obj.repr( -# 1462 "parsing/parser.mly" - ( wrap_exp_attrs (reloc_exp _3) _2 (* check location *) ) -# 9479 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ext_attributes) in - Obj.repr( -# 1464 "parsing/parser.mly" - ( mkexp_attrs (Pexp_construct (mkloc (Lident "()") (symbol_rloc ()), - None)) _2 ) -# 9487 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in - Obj.repr( -# 1467 "parsing/parser.mly" - ( unclosed "begin" 1 "end" 4 ) -# 9495 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'seq_expr) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'type_constraint) in - Obj.repr( -# 1469 "parsing/parser.mly" - ( mkexp_constraint _2 _3 ) -# 9503 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'simple_expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'label_longident) in - Obj.repr( -# 1471 "parsing/parser.mly" - ( mkexp(Pexp_field(_1, mkrhs _3 3)) ) -# 9511 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in - Obj.repr( -# 1473 "parsing/parser.mly" - ( mkexp(Pexp_open(Fresh, mkrhs _1 1, _4)) ) -# 9519 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 3 : 'mod_longident) in - Obj.repr( -# 1475 "parsing/parser.mly" - ( mkexp(Pexp_open(Fresh, mkrhs _1 1, - mkexp(Pexp_construct(mkrhs (Lident "()") 1, None)))) ) -# 9527 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in - Obj.repr( -# 1478 "parsing/parser.mly" - ( unclosed "(" 3 ")" 5 ) -# 9535 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in - Obj.repr( -# 1480 "parsing/parser.mly" - ( mkexp(Pexp_apply(ghexp(Pexp_ident(array_function "Array" "get")), - [Nolabel,_1; Nolabel,_4])) ) -# 9544 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in - Obj.repr( -# 1483 "parsing/parser.mly" - ( unclosed "(" 3 ")" 5 ) -# 9552 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in - Obj.repr( -# 1485 "parsing/parser.mly" - ( mkexp(Pexp_apply(ghexp(Pexp_ident(array_function "String" "get")), - [Nolabel,_1; Nolabel,_4])) ) -# 9561 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in - Obj.repr( -# 1488 "parsing/parser.mly" - ( unclosed "[" 3 "]" 5 ) -# 9569 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in - let _2 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in - Obj.repr( -# 1490 "parsing/parser.mly" - ( let id = mkexp @@ Pexp_ident( ghloc @@ Lident ("." ^ _2 ^ "[]")) in - mkexp @@ Pexp_apply(id, [Nolabel, _1; Nolabel, _4]) ) -# 9579 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in - let _2 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in - Obj.repr( -# 1493 "parsing/parser.mly" - ( unclosed "[" 3 "]" 5 ) -# 9588 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in - let _2 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in - Obj.repr( -# 1495 "parsing/parser.mly" - ( let id = mkexp @@ Pexp_ident( ghloc @@ Lident ("." ^ _2 ^ "()")) in - mkexp @@ Pexp_apply(id, [Nolabel, _1; Nolabel, _4]) ) -# 9598 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in - let _2 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in - Obj.repr( -# 1498 "parsing/parser.mly" - ( unclosed "(" 3 ")" 5 ) -# 9607 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in - let _2 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in - Obj.repr( -# 1500 "parsing/parser.mly" - ( let id = mkexp @@ Pexp_ident( ghloc @@ Lident ("." ^ _2 ^ "{}")) in - mkexp @@ Pexp_apply(id, [Nolabel, _1; Nolabel, _4]) ) -# 9617 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in - let _2 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in - Obj.repr( -# 1503 "parsing/parser.mly" - ( unclosed "{" 3 "}" 5 ) -# 9626 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _6 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in - Obj.repr( -# 1505 "parsing/parser.mly" - ( let id = mkexp @@ Pexp_ident( ghloc @@ Ldot(_3, "." ^ _4 ^ "[]")) in - mkexp @@ Pexp_apply(id, [Nolabel, _1; Nolabel, _6]) ) -# 9637 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _6 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in - Obj.repr( -# 1508 "parsing/parser.mly" - ( unclosed "[" 5 "]" 7 ) -# 9647 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _6 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in - Obj.repr( -# 1510 "parsing/parser.mly" - ( let id = mkexp @@ Pexp_ident( ghloc @@ Ldot(_3, "." ^ _4 ^ "()")) in - mkexp @@ Pexp_apply(id, [Nolabel, _1; Nolabel, _6]) ) -# 9658 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _6 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in - Obj.repr( -# 1513 "parsing/parser.mly" - ( unclosed "(" 5 ")" 7 ) -# 9668 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _6 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in - Obj.repr( -# 1515 "parsing/parser.mly" - ( let id = mkexp @@ Pexp_ident( ghloc @@ Ldot(_3, "." ^ _4 ^ "{}")) in - mkexp @@ Pexp_apply(id, [Nolabel, _1; Nolabel, _6]) ) -# 9679 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _6 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in - Obj.repr( -# 1518 "parsing/parser.mly" - ( unclosed "{" 5 "}" 7 ) -# 9689 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in - Obj.repr( -# 1520 "parsing/parser.mly" - ( bigarray_get _1 _4 ) -# 9697 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'expr_comma_list) in - Obj.repr( -# 1522 "parsing/parser.mly" - ( unclosed "{" 3 "}" 5 ) -# 9705 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'record_expr) in - Obj.repr( -# 1524 "parsing/parser.mly" - ( let (exten, fields) = _2 in mkexp (Pexp_record(fields, exten)) ) -# 9712 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'record_expr) in - Obj.repr( -# 1526 "parsing/parser.mly" - ( unclosed "{" 1 "}" 3 ) -# 9719 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'record_expr) in - Obj.repr( -# 1528 "parsing/parser.mly" - ( let (exten, fields) = _4 in - let rec_exp = mkexp(Pexp_record(fields, exten)) in - mkexp(Pexp_open(Fresh, mkrhs _1 1, rec_exp)) ) -# 9729 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'record_expr) in - Obj.repr( -# 1532 "parsing/parser.mly" - ( unclosed "{" 3 "}" 5 ) -# 9737 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'expr_semi_list) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in - Obj.repr( -# 1534 "parsing/parser.mly" - ( mkexp (Pexp_array(List.rev _2)) ) -# 9745 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'expr_semi_list) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in - Obj.repr( -# 1536 "parsing/parser.mly" - ( unclosed "[|" 1 "|]" 4 ) -# 9753 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - Obj.repr( -# 1538 "parsing/parser.mly" - ( mkexp (Pexp_array []) ) -# 9759 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 5 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 2 : 'expr_semi_list) in - let _5 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in - Obj.repr( -# 1540 "parsing/parser.mly" - ( mkexp(Pexp_open(Fresh, mkrhs _1 1, mkexp(Pexp_array(List.rev _4)))) ) -# 9768 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 3 : 'mod_longident) in - Obj.repr( -# 1542 "parsing/parser.mly" - ( mkexp(Pexp_open(Fresh, mkrhs _1 1, mkexp(Pexp_array []))) ) -# 9775 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 5 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 2 : 'expr_semi_list) in - let _5 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in - Obj.repr( -# 1544 "parsing/parser.mly" - ( unclosed "[|" 3 "|]" 6 ) -# 9784 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'expr_semi_list) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in - Obj.repr( -# 1546 "parsing/parser.mly" - ( reloc_exp (mktailexp (rhs_loc 4) (List.rev _2)) ) -# 9792 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'expr_semi_list) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in - Obj.repr( -# 1548 "parsing/parser.mly" - ( unclosed "[" 1 "]" 4 ) -# 9800 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 5 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 2 : 'expr_semi_list) in - let _5 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in - Obj.repr( -# 1550 "parsing/parser.mly" - ( let list_exp = reloc_exp (mktailexp (rhs_loc 6) (List.rev _4)) in - mkexp(Pexp_open(Fresh, mkrhs _1 1, list_exp)) ) -# 9810 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 3 : 'mod_longident) in - Obj.repr( -# 1553 "parsing/parser.mly" - ( mkexp(Pexp_open(Fresh, mkrhs _1 1, - mkexp(Pexp_construct(mkrhs (Lident "[]") 1, None)))) ) -# 9818 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 5 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 2 : 'expr_semi_list) in - let _5 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in - Obj.repr( -# 1556 "parsing/parser.mly" - ( unclosed "[" 3 "]" 6 ) -# 9827 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : string) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in - Obj.repr( -# 1558 "parsing/parser.mly" - ( mkexp(Pexp_apply(mkoperator _1 1, [Nolabel,_2])) ) -# 9835 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in - Obj.repr( -# 1560 "parsing/parser.mly" - ( mkexp(Pexp_apply(mkoperator "!" 1, [Nolabel,_2])) ) -# 9842 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'class_longident) in - Obj.repr( -# 1562 "parsing/parser.mly" - ( mkexp_attrs (Pexp_new(mkrhs _3 3)) _2 ) -# 9850 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'field_expr_list) in - Obj.repr( -# 1564 "parsing/parser.mly" - ( mkexp (Pexp_override _2) ) -# 9857 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'field_expr_list) in - Obj.repr( -# 1566 "parsing/parser.mly" - ( unclosed "{<" 1 ">}" 3 ) -# 9864 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - Obj.repr( -# 1568 "parsing/parser.mly" - ( mkexp (Pexp_override [])) -# 9870 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'field_expr_list) in - Obj.repr( -# 1570 "parsing/parser.mly" - ( mkexp(Pexp_open(Fresh, mkrhs _1 1, mkexp (Pexp_override _4)))) -# 9878 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 3 : 'mod_longident) in - Obj.repr( -# 1572 "parsing/parser.mly" - ( mkexp(Pexp_open(Fresh, mkrhs _1 1, mkexp (Pexp_override [])))) -# 9885 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'field_expr_list) in - Obj.repr( -# 1574 "parsing/parser.mly" - ( unclosed "{<" 3 ">}" 5 ) -# 9893 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'simple_expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'label) in - Obj.repr( -# 1576 "parsing/parser.mly" - ( mkexp(Pexp_send(_1, mkrhs _3 3)) ) -# 9901 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'simple_expr) in - let _2 = (Parsing.peek_val __caml_parser_env 1 : string) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in - Obj.repr( -# 1578 "parsing/parser.mly" - ( mkinfix _1 _2 _3 ) -# 9910 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'module_expr) in - Obj.repr( -# 1580 "parsing/parser.mly" - ( mkexp_attrs (Pexp_pack _4) _3 ) -# 9918 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : 'module_expr) in - let _6 = (Parsing.peek_val __caml_parser_env 1 : 'package_type) in - Obj.repr( -# 1582 "parsing/parser.mly" - ( mkexp_attrs (Pexp_constraint (ghexp (Pexp_pack _4), - ghtyp (Ptyp_package _6))) - _3 ) -# 9929 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 3 : 'ext_attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 2 : 'module_expr) in - Obj.repr( -# 1586 "parsing/parser.mly" - ( unclosed "(" 1 ")" 6 ) -# 9937 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 8 : 'mod_longident) in - let _5 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in - let _6 = (Parsing.peek_val __caml_parser_env 3 : 'module_expr) in - let _8 = (Parsing.peek_val __caml_parser_env 1 : 'package_type) in - Obj.repr( -# 1589 "parsing/parser.mly" - ( mkexp(Pexp_open(Fresh, mkrhs _1 1, - mkexp_attrs (Pexp_constraint (ghexp (Pexp_pack _6), - ghtyp (Ptyp_package _8))) - _5 )) ) -# 9950 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 7 : 'mod_longident) in - let _5 = (Parsing.peek_val __caml_parser_env 3 : 'ext_attributes) in - let _6 = (Parsing.peek_val __caml_parser_env 2 : 'module_expr) in - Obj.repr( -# 1594 "parsing/parser.mly" - ( unclosed "(" 3 ")" 8 ) -# 9959 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'extension) in - Obj.repr( -# 1596 "parsing/parser.mly" - ( mkexp (Pexp_extension _1) ) -# 9966 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'labeled_simple_expr) in - Obj.repr( -# 1600 "parsing/parser.mly" - ( [_1] ) -# 9973 "parsing/parser.ml" - : 'simple_labeled_expr_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'simple_labeled_expr_list) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'labeled_simple_expr) in - Obj.repr( -# 1602 "parsing/parser.mly" - ( _2 :: _1 ) -# 9981 "parsing/parser.ml" - : 'simple_labeled_expr_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in - Obj.repr( -# 1606 "parsing/parser.mly" - ( (Nolabel, _1) ) -# 9988 "parsing/parser.ml" - : 'labeled_simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'label_expr) in - Obj.repr( -# 1608 "parsing/parser.mly" - ( _1 ) -# 9995 "parsing/parser.ml" - : 'labeled_simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : string) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in - Obj.repr( -# 1612 "parsing/parser.mly" - ( (Labelled _1, _2) ) -# 10003 "parsing/parser.ml" - : 'label_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'label_ident) in - Obj.repr( -# 1614 "parsing/parser.mly" - ( (Labelled (fst _2), snd _2) ) -# 10010 "parsing/parser.ml" - : 'label_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'label_ident) in - Obj.repr( -# 1616 "parsing/parser.mly" - ( (Optional (fst _2), snd _2) ) -# 10017 "parsing/parser.ml" - : 'label_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : string) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in - Obj.repr( -# 1618 "parsing/parser.mly" - ( (Optional _1, _2) ) -# 10025 "parsing/parser.ml" - : 'label_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 1621 "parsing/parser.mly" - ( (_1, mkexp(Pexp_ident(mkrhs (Lident _1) 1))) ) -# 10032 "parsing/parser.ml" - : 'label_ident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 1624 "parsing/parser.mly" - ( [mkrhs _1 1] ) -# 10039 "parsing/parser.ml" - : 'lident_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : string) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'lident_list) in - Obj.repr( -# 1625 "parsing/parser.mly" - ( mkrhs _1 1 :: _2 ) -# 10047 "parsing/parser.ml" - : 'lident_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'val_ident) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'strict_binding) in - Obj.repr( -# 1629 "parsing/parser.mly" - ( (mkpatvar _1 1, _2) ) -# 10055 "parsing/parser.ml" - : 'let_binding_body)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 3 : 'val_ident) in - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'type_constraint) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1631 "parsing/parser.mly" - ( let v = mkpatvar _1 1 in (* PR#7344 *) - let t = - match _2 with - Some t, None -> t - | _, Some t -> t - | _ -> assert false - in - (ghpat(Ppat_constraint(v, ghtyp(Ptyp_poly([],t)))), - mkexp_constraint _4 _2) ) -# 10072 "parsing/parser.ml" - : 'let_binding_body)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 6 : 'val_ident) in - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'typevar_list) in - let _5 = (Parsing.peek_val __caml_parser_env 2 : 'core_type) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1641 "parsing/parser.mly" - ( (ghpat(Ppat_constraint(mkpatvar _1 1, - ghtyp(Ptyp_poly(List.rev _3,_5)))), - _7) ) -# 10084 "parsing/parser.ml" - : 'let_binding_body)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 7 : 'val_ident) in - let _4 = (Parsing.peek_val __caml_parser_env 4 : 'lident_list) in - let _6 = (Parsing.peek_val __caml_parser_env 2 : 'core_type) in - let _8 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1645 "parsing/parser.mly" - ( let exp, poly = wrap_type_annotation _4 _6 _8 in - (ghpat(Ppat_constraint(mkpatvar _1 1, poly)), exp) ) -# 10095 "parsing/parser.ml" - : 'let_binding_body)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_no_exn) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1648 "parsing/parser.mly" - ( (_1, _3) ) -# 10103 "parsing/parser.ml" - : 'let_binding_body)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_pattern_not_ident) in - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'core_type) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1650 "parsing/parser.mly" - ( (ghpat(Ppat_constraint(_1, _3)), _5) ) -# 10112 "parsing/parser.ml" - : 'let_binding_body)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'let_binding) in - Obj.repr( -# 1653 "parsing/parser.mly" - ( _1 ) -# 10119 "parsing/parser.ml" - : 'let_bindings)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'let_bindings) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'and_let_binding) in - Obj.repr( -# 1654 "parsing/parser.mly" - ( addlb _1 _2 ) -# 10127 "parsing/parser.ml" - : 'let_bindings)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'rec_flag) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'let_binding_body) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1658 "parsing/parser.mly" - ( let (ext, attr) = _2 in - mklbs ext _3 (mklb true _4 (attr@_5)) ) -# 10138 "parsing/parser.ml" - : 'let_binding)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'let_binding_body) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1663 "parsing/parser.mly" - ( mklb false _3 (_2@_4) ) -# 10147 "parsing/parser.ml" - : 'and_let_binding)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'strict_binding) in - Obj.repr( -# 1667 "parsing/parser.mly" - ( _1 ) -# 10154 "parsing/parser.ml" - : 'fun_binding)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'type_constraint) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1669 "parsing/parser.mly" - ( mkexp_constraint _3 _1 ) -# 10162 "parsing/parser.ml" - : 'fun_binding)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1673 "parsing/parser.mly" - ( _2 ) -# 10169 "parsing/parser.ml" - : 'strict_binding)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'labeled_simple_pattern) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'fun_binding) in - Obj.repr( -# 1675 "parsing/parser.mly" - ( let (l, o, p) = _1 in ghexp(Pexp_fun(l, o, p, _2)) ) -# 10177 "parsing/parser.ml" - : 'strict_binding)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'lident_list) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'fun_binding) in - Obj.repr( -# 1677 "parsing/parser.mly" - ( mk_newtypes _3 _5 ) -# 10185 "parsing/parser.ml" - : 'strict_binding)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'match_case) in - Obj.repr( -# 1680 "parsing/parser.mly" - ( [_1] ) -# 10192 "parsing/parser.ml" - : 'match_cases)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'match_cases) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'match_case) in - Obj.repr( -# 1681 "parsing/parser.mly" - ( _3 :: _1 ) -# 10200 "parsing/parser.ml" - : 'match_cases)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1685 "parsing/parser.mly" - ( Exp.case _1 _3 ) -# 10208 "parsing/parser.ml" - : 'match_case)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'pattern) in - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'seq_expr) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1687 "parsing/parser.mly" - ( Exp.case _1 ~guard:_3 _5 ) -# 10217 "parsing/parser.ml" - : 'match_case)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in - Obj.repr( -# 1689 "parsing/parser.mly" - ( Exp.case _1 (Exp.unreachable ~loc:(rhs_loc 3) ())) -# 10224 "parsing/parser.ml" - : 'match_case)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1693 "parsing/parser.mly" - ( _2 ) -# 10231 "parsing/parser.ml" - : 'fun_def)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'simple_core_type) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1695 "parsing/parser.mly" - ( mkexp (Pexp_constraint (_4, _2)) ) -# 10239 "parsing/parser.ml" - : 'fun_def)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'labeled_simple_pattern) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'fun_def) in - Obj.repr( -# 1698 "parsing/parser.mly" - ( - let (l,o,p) = _1 in - ghexp(Pexp_fun(l, o, p, _2)) - ) -# 10250 "parsing/parser.ml" - : 'fun_def)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'lident_list) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'fun_def) in - Obj.repr( -# 1703 "parsing/parser.mly" - ( mk_newtypes _3 _5 ) -# 10258 "parsing/parser.ml" - : 'fun_def)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr_comma_list) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1706 "parsing/parser.mly" - ( _3 :: _1 ) -# 10266 "parsing/parser.ml" - : 'expr_comma_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1707 "parsing/parser.mly" - ( [_3; _1] ) -# 10274 "parsing/parser.ml" - : 'expr_comma_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'simple_expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'lbl_expr_list) in - Obj.repr( -# 1710 "parsing/parser.mly" - ( (Some _1, _3) ) -# 10282 "parsing/parser.ml" - : 'record_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'lbl_expr_list) in - Obj.repr( -# 1711 "parsing/parser.mly" - ( (None, _1) ) -# 10289 "parsing/parser.ml" - : 'record_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'lbl_expr) in - Obj.repr( -# 1714 "parsing/parser.mly" - ( [_1] ) -# 10296 "parsing/parser.ml" - : 'lbl_expr_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'lbl_expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'lbl_expr_list) in - Obj.repr( -# 1715 "parsing/parser.mly" - ( _1 :: _3 ) -# 10304 "parsing/parser.ml" - : 'lbl_expr_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'lbl_expr) in - Obj.repr( -# 1716 "parsing/parser.mly" - ( [_1] ) -# 10311 "parsing/parser.ml" - : 'lbl_expr_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 3 : 'label_longident) in - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'opt_type_constraint) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1720 "parsing/parser.mly" - ( (mkrhs _1 1, mkexp_opt_constraint _4 _2) ) -# 10320 "parsing/parser.ml" - : 'lbl_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'label_longident) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'opt_type_constraint) in - Obj.repr( -# 1722 "parsing/parser.mly" - ( (mkrhs _1 1, mkexp_opt_constraint (exp_of_label _1 1) _2) ) -# 10328 "parsing/parser.ml" - : 'lbl_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'field_expr) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'opt_semi) in - Obj.repr( -# 1725 "parsing/parser.mly" - ( [_1] ) -# 10336 "parsing/parser.ml" - : 'field_expr_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'field_expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'field_expr_list) in - Obj.repr( -# 1726 "parsing/parser.mly" - ( _1 :: _3 ) -# 10344 "parsing/parser.ml" - : 'field_expr_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'label) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1730 "parsing/parser.mly" - ( (mkrhs _1 1, _3) ) -# 10352 "parsing/parser.ml" - : 'field_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'label) in - Obj.repr( -# 1732 "parsing/parser.mly" - ( (mkrhs _1 1, exp_of_label (Lident _1) 1) ) -# 10359 "parsing/parser.ml" - : 'field_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1735 "parsing/parser.mly" - ( [_1] ) -# 10366 "parsing/parser.ml" - : 'expr_semi_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr_semi_list) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1736 "parsing/parser.mly" - ( _3 :: _1 ) -# 10374 "parsing/parser.ml" - : 'expr_semi_list)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in - Obj.repr( -# 1739 "parsing/parser.mly" - ( (Some _2, None) ) -# 10381 "parsing/parser.ml" - : 'type_constraint)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'core_type) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in - Obj.repr( -# 1740 "parsing/parser.mly" - ( (Some _2, Some _4) ) -# 10389 "parsing/parser.ml" - : 'type_constraint)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in - Obj.repr( -# 1741 "parsing/parser.mly" - ( (None, Some _2) ) -# 10396 "parsing/parser.ml" - : 'type_constraint)) -; (fun __caml_parser_env -> - Obj.repr( -# 1742 "parsing/parser.mly" - ( syntax_error() ) -# 10402 "parsing/parser.ml" - : 'type_constraint)) -; (fun __caml_parser_env -> - Obj.repr( -# 1743 "parsing/parser.mly" - ( syntax_error() ) -# 10408 "parsing/parser.ml" - : 'type_constraint)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'type_constraint) in - Obj.repr( -# 1746 "parsing/parser.mly" - ( Some _1 ) -# 10415 "parsing/parser.ml" - : 'opt_type_constraint)) -; (fun __caml_parser_env -> - Obj.repr( -# 1747 "parsing/parser.mly" - ( None ) -# 10421 "parsing/parser.ml" - : 'opt_type_constraint)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'val_ident) in - Obj.repr( -# 1754 "parsing/parser.mly" - ( mkpat(Ppat_alias(_1, mkrhs _3 3)) ) -# 10429 "parsing/parser.ml" - : 'pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in - Obj.repr( -# 1756 "parsing/parser.mly" - ( expecting 3 "identifier" ) -# 10436 "parsing/parser.ml" - : 'pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'pattern_comma_list) in - Obj.repr( -# 1758 "parsing/parser.mly" - ( mkpat(Ppat_tuple(List.rev _1)) ) -# 10443 "parsing/parser.ml" - : 'pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in - Obj.repr( -# 1760 "parsing/parser.mly" - ( mkpat_cons (rhs_loc 2) (ghpat(Ppat_tuple[_1;_3])) (symbol_rloc()) ) -# 10451 "parsing/parser.ml" - : 'pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in - Obj.repr( -# 1762 "parsing/parser.mly" - ( expecting 3 "pattern" ) -# 10458 "parsing/parser.ml" - : 'pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in - Obj.repr( -# 1764 "parsing/parser.mly" - ( mkpat(Ppat_or(_1, _3)) ) -# 10466 "parsing/parser.ml" - : 'pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in - Obj.repr( -# 1766 "parsing/parser.mly" - ( expecting 3 "pattern" ) -# 10473 "parsing/parser.ml" - : 'pattern)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in - Obj.repr( -# 1768 "parsing/parser.mly" - ( mkpat_attrs (Ppat_exception _3) _2) -# 10481 "parsing/parser.ml" - : 'pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'pattern) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attribute) in - Obj.repr( -# 1770 "parsing/parser.mly" - ( Pat.attr _1 _2 ) -# 10489 "parsing/parser.ml" - : 'pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'pattern_gen) in - Obj.repr( -# 1771 "parsing/parser.mly" - ( _1 ) -# 10496 "parsing/parser.ml" - : 'pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_no_exn) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'val_ident) in - Obj.repr( -# 1775 "parsing/parser.mly" - ( mkpat(Ppat_alias(_1, mkrhs _3 3)) ) -# 10504 "parsing/parser.ml" - : 'pattern_no_exn)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_no_exn) in - Obj.repr( -# 1777 "parsing/parser.mly" - ( expecting 3 "identifier" ) -# 10511 "parsing/parser.ml" - : 'pattern_no_exn)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'pattern_no_exn_comma_list) in - Obj.repr( -# 1779 "parsing/parser.mly" - ( mkpat(Ppat_tuple(List.rev _1)) ) -# 10518 "parsing/parser.ml" - : 'pattern_no_exn)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_no_exn) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in - Obj.repr( -# 1781 "parsing/parser.mly" - ( mkpat_cons (rhs_loc 2) (ghpat(Ppat_tuple[_1;_3])) (symbol_rloc()) ) -# 10526 "parsing/parser.ml" - : 'pattern_no_exn)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_no_exn) in - Obj.repr( -# 1783 "parsing/parser.mly" - ( expecting 3 "pattern" ) -# 10533 "parsing/parser.ml" - : 'pattern_no_exn)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_no_exn) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in - Obj.repr( -# 1785 "parsing/parser.mly" - ( mkpat(Ppat_or(_1, _3)) ) -# 10541 "parsing/parser.ml" - : 'pattern_no_exn)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_no_exn) in - Obj.repr( -# 1787 "parsing/parser.mly" - ( expecting 3 "pattern" ) -# 10548 "parsing/parser.ml" - : 'pattern_no_exn)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'pattern_no_exn) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attribute) in - Obj.repr( -# 1789 "parsing/parser.mly" - ( Pat.attr _1 _2 ) -# 10556 "parsing/parser.ml" - : 'pattern_no_exn)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'pattern_gen) in - Obj.repr( -# 1790 "parsing/parser.mly" - ( _1 ) -# 10563 "parsing/parser.ml" - : 'pattern_no_exn)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_pattern) in - Obj.repr( -# 1794 "parsing/parser.mly" - ( _1 ) -# 10570 "parsing/parser.ml" - : 'pattern_gen)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'constr_longident) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in - Obj.repr( -# 1796 "parsing/parser.mly" - ( mkpat(Ppat_construct(mkrhs _1 1, Some _2)) ) -# 10578 "parsing/parser.ml" - : 'pattern_gen)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'name_tag) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in - Obj.repr( -# 1798 "parsing/parser.mly" - ( mkpat(Ppat_variant(_1, Some _2)) ) -# 10586 "parsing/parser.ml" - : 'pattern_gen)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'simple_pattern) in - Obj.repr( -# 1800 "parsing/parser.mly" - ( mkpat_attrs (Ppat_lazy _3) _2) -# 10594 "parsing/parser.ml" - : 'pattern_gen)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'val_ident) in - Obj.repr( -# 1804 "parsing/parser.mly" - ( mkpat(Ppat_var (mkrhs _1 1)) ) -# 10601 "parsing/parser.ml" - : 'simple_pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_pattern_not_ident) in - Obj.repr( -# 1805 "parsing/parser.mly" - ( _1 ) -# 10608 "parsing/parser.ml" - : 'simple_pattern)) -; (fun __caml_parser_env -> - Obj.repr( -# 1809 "parsing/parser.mly" - ( mkpat(Ppat_any) ) -# 10614 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'signed_constant) in - Obj.repr( -# 1811 "parsing/parser.mly" - ( mkpat(Ppat_constant _1) ) -# 10621 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'signed_constant) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'signed_constant) in - Obj.repr( -# 1813 "parsing/parser.mly" - ( mkpat(Ppat_interval (_1, _3)) ) -# 10629 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'constr_longident) in - Obj.repr( -# 1815 "parsing/parser.mly" - ( mkpat(Ppat_construct(mkrhs _1 1, None)) ) -# 10636 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'name_tag) in - Obj.repr( -# 1817 "parsing/parser.mly" - ( mkpat(Ppat_variant(_1, None)) ) -# 10643 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'type_longident) in - Obj.repr( -# 1819 "parsing/parser.mly" - ( mkpat(Ppat_type (mkrhs _2 2)) ) -# 10650 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_delimited_pattern) in - Obj.repr( -# 1821 "parsing/parser.mly" - ( _1 ) -# 10657 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'mod_longident) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'simple_delimited_pattern) in - Obj.repr( -# 1823 "parsing/parser.mly" - ( mkpat @@ Ppat_open(mkrhs _1 1, _3) ) -# 10665 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 3 : 'mod_longident) in - Obj.repr( -# 1825 "parsing/parser.mly" - ( mkpat @@ Ppat_open(mkrhs _1 1, mkpat @@ - Ppat_construct ( mkrhs (Lident "[]") 4, None)) ) -# 10673 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 3 : 'mod_longident) in - Obj.repr( -# 1828 "parsing/parser.mly" - ( mkpat @@ Ppat_open( mkrhs _1 1, mkpat @@ - Ppat_construct ( mkrhs (Lident "()") 4, None) ) ) -# 10681 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'pattern) in - Obj.repr( -# 1831 "parsing/parser.mly" - ( mkpat @@ Ppat_open (mkrhs _1 1, _4)) -# 10689 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'pattern) in - Obj.repr( -# 1833 "parsing/parser.mly" - (unclosed "(" 3 ")" 5 ) -# 10697 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 3 : 'mod_longident) in - Obj.repr( -# 1835 "parsing/parser.mly" - ( expecting 4 "pattern" ) -# 10704 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'pattern) in - Obj.repr( -# 1837 "parsing/parser.mly" - ( reloc_pat _2 ) -# 10711 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'pattern) in - Obj.repr( -# 1839 "parsing/parser.mly" - ( unclosed "(" 1 ")" 3 ) -# 10718 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'pattern) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'core_type) in - Obj.repr( -# 1841 "parsing/parser.mly" - ( mkpat(Ppat_constraint(_2, _4)) ) -# 10726 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'pattern) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'core_type) in - Obj.repr( -# 1843 "parsing/parser.mly" - ( unclosed "(" 1 ")" 5 ) -# 10734 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in - Obj.repr( -# 1845 "parsing/parser.mly" - ( expecting 4 "type" ) -# 10741 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : string) in - Obj.repr( -# 1847 "parsing/parser.mly" - ( mkpat_attrs (Ppat_unpack (mkrhs _4 4)) _3 ) -# 10749 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _6 = (Parsing.peek_val __caml_parser_env 1 : 'package_type) in - Obj.repr( -# 1849 "parsing/parser.mly" - ( mkpat_attrs - (Ppat_constraint(mkpat(Ppat_unpack (mkrhs _4 4)), - ghtyp(Ptyp_package _6))) - _3 ) -# 10761 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _6 = (Parsing.peek_val __caml_parser_env 1 : 'package_type) in - Obj.repr( -# 1854 "parsing/parser.mly" - ( unclosed "(" 1 ")" 7 ) -# 10770 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'extension) in - Obj.repr( -# 1856 "parsing/parser.mly" - ( mkpat(Ppat_extension _1) ) -# 10777 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'lbl_pattern_list) in - Obj.repr( -# 1861 "parsing/parser.mly" - ( let (fields, closed) = _2 in mkpat(Ppat_record(fields, closed)) ) -# 10784 "parsing/parser.ml" - : 'simple_delimited_pattern)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'lbl_pattern_list) in - Obj.repr( -# 1863 "parsing/parser.mly" - ( unclosed "{" 1 "}" 3 ) -# 10791 "parsing/parser.ml" - : 'simple_delimited_pattern)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_semi_list) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in - Obj.repr( -# 1865 "parsing/parser.mly" - ( reloc_pat (mktailpat (rhs_loc 4) (List.rev _2)) ) -# 10799 "parsing/parser.ml" - : 'simple_delimited_pattern)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_semi_list) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in - Obj.repr( -# 1867 "parsing/parser.mly" - ( unclosed "[" 1 "]" 4 ) -# 10807 "parsing/parser.ml" - : 'simple_delimited_pattern)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_semi_list) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in - Obj.repr( -# 1869 "parsing/parser.mly" - ( mkpat(Ppat_array(List.rev _2)) ) -# 10815 "parsing/parser.ml" - : 'simple_delimited_pattern)) -; (fun __caml_parser_env -> - Obj.repr( -# 1871 "parsing/parser.mly" - ( mkpat(Ppat_array []) ) -# 10821 "parsing/parser.ml" - : 'simple_delimited_pattern)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_semi_list) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in - Obj.repr( -# 1873 "parsing/parser.mly" - ( unclosed "[|" 1 "|]" 4 ) -# 10829 "parsing/parser.ml" - : 'simple_delimited_pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_comma_list) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in - Obj.repr( -# 1876 "parsing/parser.mly" - ( _3 :: _1 ) -# 10837 "parsing/parser.ml" - : 'pattern_comma_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in - Obj.repr( -# 1877 "parsing/parser.mly" - ( [_3; _1] ) -# 10845 "parsing/parser.ml" - : 'pattern_comma_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in - Obj.repr( -# 1878 "parsing/parser.mly" - ( expecting 3 "pattern" ) -# 10852 "parsing/parser.ml" - : 'pattern_comma_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_no_exn_comma_list) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in - Obj.repr( -# 1881 "parsing/parser.mly" - ( _3 :: _1 ) -# 10860 "parsing/parser.ml" - : 'pattern_no_exn_comma_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_no_exn) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in - Obj.repr( -# 1882 "parsing/parser.mly" - ( [_3; _1] ) -# 10868 "parsing/parser.ml" - : 'pattern_no_exn_comma_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_no_exn) in - Obj.repr( -# 1883 "parsing/parser.mly" - ( expecting 3 "pattern" ) -# 10875 "parsing/parser.ml" - : 'pattern_no_exn_comma_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in - Obj.repr( -# 1886 "parsing/parser.mly" - ( [_1] ) -# 10882 "parsing/parser.ml" - : 'pattern_semi_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_semi_list) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in - Obj.repr( -# 1887 "parsing/parser.mly" - ( _3 :: _1 ) -# 10890 "parsing/parser.ml" - : 'pattern_semi_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'lbl_pattern) in - Obj.repr( -# 1890 "parsing/parser.mly" - ( [_1], Closed ) -# 10897 "parsing/parser.ml" - : 'lbl_pattern_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'lbl_pattern) in - Obj.repr( -# 1891 "parsing/parser.mly" - ( [_1], Closed ) -# 10904 "parsing/parser.ml" - : 'lbl_pattern_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 3 : 'lbl_pattern) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'opt_semi) in - Obj.repr( -# 1892 "parsing/parser.mly" - ( [_1], Open ) -# 10912 "parsing/parser.ml" - : 'lbl_pattern_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'lbl_pattern) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'lbl_pattern_list) in - Obj.repr( -# 1894 "parsing/parser.mly" - ( let (fields, closed) = _3 in _1 :: fields, closed ) -# 10920 "parsing/parser.ml" - : 'lbl_pattern_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 3 : 'label_longident) in - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'opt_pattern_type_constraint) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in - Obj.repr( -# 1898 "parsing/parser.mly" - ( (mkrhs _1 1, mkpat_opt_constraint _4 _2) ) -# 10929 "parsing/parser.ml" - : 'lbl_pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'label_longident) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'opt_pattern_type_constraint) in - Obj.repr( -# 1900 "parsing/parser.mly" - ( (mkrhs _1 1, mkpat_opt_constraint (pat_of_label _1 1) _2) ) -# 10937 "parsing/parser.ml" - : 'lbl_pattern)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in - Obj.repr( -# 1903 "parsing/parser.mly" - ( Some _2 ) -# 10944 "parsing/parser.ml" - : 'opt_pattern_type_constraint)) -; (fun __caml_parser_env -> - Obj.repr( -# 1904 "parsing/parser.mly" - ( None ) -# 10950 "parsing/parser.ml" - : 'opt_pattern_type_constraint)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 3 : 'val_ident) in - let _5 = (Parsing.peek_val __caml_parser_env 1 : 'core_type) in - let _6 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1911 "parsing/parser.mly" - ( let (ext, attrs) = _2 in - Val.mk (mkrhs _3 3) _5 ~attrs:(attrs@_6) - ~loc:(symbol_rloc()) ~docs:(symbol_docs ()) - , ext ) -# 10963 "parsing/parser.ml" - : 'value_description)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string * string option) in - Obj.repr( -# 1920 "parsing/parser.mly" - ( [fst _1] ) -# 10970 "parsing/parser.ml" - : 'primitive_declaration_body)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : string * string option) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'primitive_declaration_body) in - Obj.repr( -# 1921 "parsing/parser.mly" - ( fst _1 :: _2 ) -# 10978 "parsing/parser.ml" - : 'primitive_declaration_body)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 6 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 5 : 'val_ident) in - let _5 = (Parsing.peek_val __caml_parser_env 3 : 'core_type) in - let _7 = (Parsing.peek_val __caml_parser_env 1 : 'primitive_declaration_body) in - let _8 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1926 "parsing/parser.mly" - ( let (ext, attrs) = _2 in - Val.mk (mkrhs _3 3) _5 ~prim:_7 ~attrs:(attrs@_8) - ~loc:(symbol_rloc ()) ~docs:(symbol_docs ()) - , ext ) -# 10992 "parsing/parser.ml" - : 'primitive_declaration)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'type_declaration) in - Obj.repr( -# 1936 "parsing/parser.mly" - ( let (nonrec_flag, ty, ext) = _1 in (nonrec_flag, [ty], ext) ) -# 10999 "parsing/parser.ml" - : 'type_declarations)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'type_declarations) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'and_type_declaration) in - Obj.repr( -# 1938 "parsing/parser.mly" - ( let (nonrec_flag, tys, ext) = _1 in (nonrec_flag, _2 :: tys, ext) ) -# 11007 "parsing/parser.ml" - : 'type_declarations)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 6 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 5 : 'nonrec_flag) in - let _4 = (Parsing.peek_val __caml_parser_env 4 : 'optional_type_parameters) in - let _5 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _6 = (Parsing.peek_val __caml_parser_env 2 : 'type_kind) in - let _7 = (Parsing.peek_val __caml_parser_env 1 : 'constraints) in - let _8 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1944 "parsing/parser.mly" - ( let (kind, priv, manifest) = _6 in - let (ext, attrs) = _2 in - let ty = - Type.mk (mkrhs _5 5) ~params:_4 ~cstrs:(List.rev _7) ~kind - ~priv ?manifest ~attrs:(attrs@_8) - ~loc:(symbol_rloc ()) ~docs:(symbol_docs ()) - in - (_3, ty, ext) ) -# 11027 "parsing/parser.ml" - : 'type_declaration)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 5 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'optional_type_parameters) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _5 = (Parsing.peek_val __caml_parser_env 2 : 'type_kind) in - let _6 = (Parsing.peek_val __caml_parser_env 1 : 'constraints) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1956 "parsing/parser.mly" - ( let (kind, priv, manifest) = _5 in - Type.mk (mkrhs _4 4) ~params:_3 ~cstrs:(List.rev _6) - ~kind ~priv ?manifest ~attrs:(_2@_7) ~loc:(symbol_rloc ()) - ~text:(symbol_text ()) ~docs:(symbol_docs ()) ) -# 11042 "parsing/parser.ml" - : 'and_type_declaration)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'constraints) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'constrain) in - Obj.repr( -# 1962 "parsing/parser.mly" - ( _3 :: _1 ) -# 11050 "parsing/parser.ml" - : 'constraints)) -; (fun __caml_parser_env -> - Obj.repr( -# 1963 "parsing/parser.mly" - ( [] ) -# 11056 "parsing/parser.ml" - : 'constraints)) -; (fun __caml_parser_env -> - Obj.repr( -# 1967 "parsing/parser.mly" - ( (Ptype_abstract, Public, None) ) -# 11062 "parsing/parser.ml" - : 'type_kind)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in - Obj.repr( -# 1969 "parsing/parser.mly" - ( (Ptype_abstract, Public, Some _2) ) -# 11069 "parsing/parser.ml" - : 'type_kind)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in - Obj.repr( -# 1971 "parsing/parser.mly" - ( (Ptype_abstract, Private, Some _3) ) -# 11076 "parsing/parser.ml" - : 'type_kind)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'constructor_declarations) in - Obj.repr( -# 1973 "parsing/parser.mly" - ( (Ptype_variant(List.rev _2), Public, None) ) -# 11083 "parsing/parser.ml" - : 'type_kind)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'constructor_declarations) in - Obj.repr( -# 1975 "parsing/parser.mly" - ( (Ptype_variant(List.rev _3), Private, None) ) -# 11090 "parsing/parser.ml" - : 'type_kind)) -; (fun __caml_parser_env -> - Obj.repr( -# 1977 "parsing/parser.mly" - ( (Ptype_open, Public, None) ) -# 11096 "parsing/parser.ml" - : 'type_kind)) -; (fun __caml_parser_env -> - Obj.repr( -# 1979 "parsing/parser.mly" - ( (Ptype_open, Private, None) ) -# 11102 "parsing/parser.ml" - : 'type_kind)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'private_flag) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'label_declarations) in - Obj.repr( -# 1981 "parsing/parser.mly" - ( (Ptype_record _4, _2, None) ) -# 11110 "parsing/parser.ml" - : 'type_kind)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'core_type) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'private_flag) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'constructor_declarations) in - Obj.repr( -# 1983 "parsing/parser.mly" - ( (Ptype_variant(List.rev _5), _4, Some _2) ) -# 11119 "parsing/parser.ml" - : 'type_kind)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'core_type) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'private_flag) in - Obj.repr( -# 1985 "parsing/parser.mly" - ( (Ptype_open, _4, Some _2) ) -# 11127 "parsing/parser.ml" - : 'type_kind)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 5 : 'core_type) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : 'private_flag) in - let _6 = (Parsing.peek_val __caml_parser_env 1 : 'label_declarations) in - Obj.repr( -# 1987 "parsing/parser.mly" - ( (Ptype_record _6, _4, Some _2) ) -# 11136 "parsing/parser.ml" - : 'type_kind)) -; (fun __caml_parser_env -> - Obj.repr( -# 1990 "parsing/parser.mly" - ( [] ) -# 11142 "parsing/parser.ml" - : 'optional_type_parameters)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'optional_type_parameter) in - Obj.repr( -# 1991 "parsing/parser.mly" - ( [_1] ) -# 11149 "parsing/parser.ml" - : 'optional_type_parameters)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'optional_type_parameter_list) in - Obj.repr( -# 1992 "parsing/parser.mly" - ( List.rev _2 ) -# 11156 "parsing/parser.ml" - : 'optional_type_parameters)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'type_variance) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'optional_type_variable) in - Obj.repr( -# 1995 "parsing/parser.mly" - ( _2, _1 ) -# 11164 "parsing/parser.ml" - : 'optional_type_parameter)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'optional_type_parameter) in - Obj.repr( -# 1998 "parsing/parser.mly" - ( [_1] ) -# 11171 "parsing/parser.ml" - : 'optional_type_parameter_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'optional_type_parameter_list) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'optional_type_parameter) in - Obj.repr( -# 1999 "parsing/parser.mly" - ( _3 :: _1 ) -# 11179 "parsing/parser.ml" - : 'optional_type_parameter_list)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'ident) in - Obj.repr( -# 2002 "parsing/parser.mly" - ( mktyp(Ptyp_var _2) ) -# 11186 "parsing/parser.ml" - : 'optional_type_variable)) -; (fun __caml_parser_env -> - Obj.repr( -# 2003 "parsing/parser.mly" - ( mktyp(Ptyp_any) ) -# 11192 "parsing/parser.ml" - : 'optional_type_variable)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'type_variance) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'type_variable) in - Obj.repr( -# 2008 "parsing/parser.mly" - ( _2, _1 ) -# 11200 "parsing/parser.ml" - : 'type_parameter)) -; (fun __caml_parser_env -> - Obj.repr( -# 2011 "parsing/parser.mly" - ( Invariant ) -# 11206 "parsing/parser.ml" - : 'type_variance)) -; (fun __caml_parser_env -> - Obj.repr( -# 2012 "parsing/parser.mly" - ( Covariant ) -# 11212 "parsing/parser.ml" - : 'type_variance)) -; (fun __caml_parser_env -> - Obj.repr( -# 2013 "parsing/parser.mly" - ( Contravariant ) -# 11218 "parsing/parser.ml" - : 'type_variance)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'ident) in - Obj.repr( -# 2016 "parsing/parser.mly" - ( mktyp(Ptyp_var _2) ) -# 11225 "parsing/parser.ml" - : 'type_variable)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'type_parameter) in - Obj.repr( -# 2019 "parsing/parser.mly" - ( [_1] ) -# 11232 "parsing/parser.ml" - : 'type_parameter_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'type_parameter_list) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'type_parameter) in - Obj.repr( -# 2020 "parsing/parser.mly" - ( _3 :: _1 ) -# 11240 "parsing/parser.ml" - : 'type_parameter_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'constructor_declaration) in - Obj.repr( -# 2023 "parsing/parser.mly" - ( [_1] ) -# 11247 "parsing/parser.ml" - : 'constructor_declarations)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'bar_constructor_declaration) in - Obj.repr( -# 2024 "parsing/parser.mly" - ( [_1] ) -# 11254 "parsing/parser.ml" - : 'constructor_declarations)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'constructor_declarations) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'bar_constructor_declaration) in - Obj.repr( -# 2025 "parsing/parser.mly" - ( _2 :: _1 ) -# 11262 "parsing/parser.ml" - : 'constructor_declarations)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'constr_ident) in - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'generalized_constructor_arguments) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in - Obj.repr( -# 2029 "parsing/parser.mly" - ( - let args,res = _2 in - Type.constructor (mkrhs _1 1) ~args ?res ~attrs:_3 - ~loc:(symbol_rloc()) ~info:(symbol_info ()) - ) -# 11275 "parsing/parser.ml" - : 'constructor_declaration)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'constr_ident) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'generalized_constructor_arguments) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in - Obj.repr( -# 2037 "parsing/parser.mly" - ( - let args,res = _3 in - Type.constructor (mkrhs _2 2) ~args ?res ~attrs:_4 - ~loc:(symbol_rloc()) ~info:(symbol_info ()) - ) -# 11288 "parsing/parser.ml" - : 'bar_constructor_declaration)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'sig_exception_declaration) in - Obj.repr( -# 2044 "parsing/parser.mly" - ( _1 ) -# 11295 "parsing/parser.ml" - : 'str_exception_declaration)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 5 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'constr_ident) in - let _5 = (Parsing.peek_val __caml_parser_env 2 : 'constr_longident) in - let _6 = (Parsing.peek_val __caml_parser_env 1 : 'attributes) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 2047 "parsing/parser.mly" - ( let (ext,attrs) = _2 in - Te.rebind (mkrhs _3 3) (mkrhs _5 5) ~attrs:(attrs @ _6 @ _7) - ~loc:(symbol_rloc()) ~docs:(symbol_docs ()) - , ext ) -# 11309 "parsing/parser.ml" - : 'str_exception_declaration)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 3 : 'constr_ident) in - let _4 = (Parsing.peek_val __caml_parser_env 2 : 'generalized_constructor_arguments) in - let _5 = (Parsing.peek_val __caml_parser_env 1 : 'attributes) in - let _6 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 2055 "parsing/parser.mly" - ( let args, res = _4 in - let (ext,attrs) = _2 in - Te.decl (mkrhs _3 3) ~args ?res ~attrs:(attrs @ _5 @ _6) - ~loc:(symbol_rloc()) ~docs:(symbol_docs ()) - , ext ) -# 11324 "parsing/parser.ml" - : 'sig_exception_declaration)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'constr_ident) in - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'generalized_constructor_arguments) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in - Obj.repr( -# 2063 "parsing/parser.mly" - ( let args, res = _2 in - Te.decl (mkrhs _1 1) ~args ?res ~attrs:_3 ~loc:(symbol_rloc()) ) -# 11334 "parsing/parser.ml" - : 'let_exception_declaration)) -; (fun __caml_parser_env -> - Obj.repr( -# 2067 "parsing/parser.mly" - ( (Pcstr_tuple [],None) ) -# 11340 "parsing/parser.ml" - : 'generalized_constructor_arguments)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'constructor_arguments) in - Obj.repr( -# 2068 "parsing/parser.mly" - ( (_2,None) ) -# 11347 "parsing/parser.ml" - : 'generalized_constructor_arguments)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'constructor_arguments) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'simple_core_type) in - Obj.repr( -# 2070 "parsing/parser.mly" - ( (_2,Some _4) ) -# 11355 "parsing/parser.ml" - : 'generalized_constructor_arguments)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'simple_core_type) in - Obj.repr( -# 2072 "parsing/parser.mly" - ( (Pcstr_tuple [],Some _2) ) -# 11362 "parsing/parser.ml" - : 'generalized_constructor_arguments)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'core_type_list) in - Obj.repr( -# 2076 "parsing/parser.mly" - ( Pcstr_tuple (List.rev _1) ) -# 11369 "parsing/parser.ml" - : 'constructor_arguments)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'label_declarations) in - Obj.repr( -# 2077 "parsing/parser.mly" - ( Pcstr_record _2 ) -# 11376 "parsing/parser.ml" - : 'constructor_arguments)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'label_declaration) in - Obj.repr( -# 2080 "parsing/parser.mly" - ( [_1] ) -# 11383 "parsing/parser.ml" - : 'label_declarations)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'label_declaration_semi) in - Obj.repr( -# 2081 "parsing/parser.mly" - ( [_1] ) -# 11390 "parsing/parser.ml" - : 'label_declarations)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'label_declaration_semi) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'label_declarations) in - Obj.repr( -# 2082 "parsing/parser.mly" - ( _1 :: _2 ) -# 11398 "parsing/parser.ml" - : 'label_declarations)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'mutable_flag) in - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'label) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'poly_type_no_attr) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in - Obj.repr( -# 2086 "parsing/parser.mly" - ( - Type.field (mkrhs _2 2) _4 ~mut:_1 ~attrs:_5 - ~loc:(symbol_rloc()) ~info:(symbol_info ()) - ) -# 11411 "parsing/parser.ml" - : 'label_declaration)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 6 : 'mutable_flag) in - let _2 = (Parsing.peek_val __caml_parser_env 5 : 'label) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : 'poly_type_no_attr) in - let _5 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in - Obj.repr( -# 2093 "parsing/parser.mly" - ( - let info = - match rhs_info 5 with - | Some _ as info_before_semi -> info_before_semi - | None -> symbol_info () - in - Type.field (mkrhs _2 2) _4 ~mut:_1 ~attrs:(_5 @ _7) - ~loc:(symbol_rloc()) ~info - ) -# 11430 "parsing/parser.ml" - : 'label_declaration_semi)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 7 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 6 : 'nonrec_flag) in - let _4 = (Parsing.peek_val __caml_parser_env 5 : 'optional_type_parameters) in - let _5 = (Parsing.peek_val __caml_parser_env 4 : 'type_longident) in - let _7 = (Parsing.peek_val __caml_parser_env 2 : 'private_flag) in - let _8 = (Parsing.peek_val __caml_parser_env 1 : 'str_extension_constructors) in - let _9 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 2109 "parsing/parser.mly" - ( let (ext, attrs) = _2 in - if _3 <> Recursive then not_expecting 3 "nonrec flag"; - Te.mk (mkrhs _5 5) (List.rev _8) ~params:_4 ~priv:_7 - ~attrs:(attrs@_9) ~docs:(symbol_docs ()) - , ext ) -# 11447 "parsing/parser.ml" - : 'str_type_extension)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 7 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 6 : 'nonrec_flag) in - let _4 = (Parsing.peek_val __caml_parser_env 5 : 'optional_type_parameters) in - let _5 = (Parsing.peek_val __caml_parser_env 4 : 'type_longident) in - let _7 = (Parsing.peek_val __caml_parser_env 2 : 'private_flag) in - let _8 = (Parsing.peek_val __caml_parser_env 1 : 'sig_extension_constructors) in - let _9 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 2118 "parsing/parser.mly" - ( let (ext, attrs) = _2 in - if _3 <> Recursive then not_expecting 3 "nonrec flag"; - Te.mk (mkrhs _5 5) (List.rev _8) ~params:_4 ~priv:_7 - ~attrs:(attrs @ _9) ~docs:(symbol_docs ()) - , ext ) -# 11464 "parsing/parser.ml" - : 'sig_type_extension)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'extension_constructor_declaration) in - Obj.repr( -# 2125 "parsing/parser.mly" - ( [_1] ) -# 11471 "parsing/parser.ml" - : 'str_extension_constructors)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'bar_extension_constructor_declaration) in - Obj.repr( -# 2126 "parsing/parser.mly" - ( [_1] ) -# 11478 "parsing/parser.ml" - : 'str_extension_constructors)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'extension_constructor_rebind) in - Obj.repr( -# 2127 "parsing/parser.mly" - ( [_1] ) -# 11485 "parsing/parser.ml" - : 'str_extension_constructors)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'bar_extension_constructor_rebind) in - Obj.repr( -# 2128 "parsing/parser.mly" - ( [_1] ) -# 11492 "parsing/parser.ml" - : 'str_extension_constructors)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'str_extension_constructors) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'bar_extension_constructor_declaration) in - Obj.repr( -# 2130 "parsing/parser.mly" - ( _2 :: _1 ) -# 11500 "parsing/parser.ml" - : 'str_extension_constructors)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'str_extension_constructors) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'bar_extension_constructor_rebind) in - Obj.repr( -# 2132 "parsing/parser.mly" - ( _2 :: _1 ) -# 11508 "parsing/parser.ml" - : 'str_extension_constructors)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'extension_constructor_declaration) in - Obj.repr( -# 2135 "parsing/parser.mly" - ( [_1] ) -# 11515 "parsing/parser.ml" - : 'sig_extension_constructors)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'bar_extension_constructor_declaration) in - Obj.repr( -# 2136 "parsing/parser.mly" - ( [_1] ) -# 11522 "parsing/parser.ml" - : 'sig_extension_constructors)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'sig_extension_constructors) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'bar_extension_constructor_declaration) in - Obj.repr( -# 2138 "parsing/parser.mly" - ( _2 :: _1 ) -# 11530 "parsing/parser.ml" - : 'sig_extension_constructors)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'constr_ident) in - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'generalized_constructor_arguments) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in - Obj.repr( -# 2142 "parsing/parser.mly" - ( let args, res = _2 in - Te.decl (mkrhs _1 1) ~args ?res ~attrs:_3 - ~loc:(symbol_rloc()) ~info:(symbol_info ()) ) -# 11541 "parsing/parser.ml" - : 'extension_constructor_declaration)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'constr_ident) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'generalized_constructor_arguments) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in - Obj.repr( -# 2148 "parsing/parser.mly" - ( let args, res = _3 in - Te.decl (mkrhs _2 2) ~args ?res ~attrs:_4 - ~loc:(symbol_rloc()) ~info:(symbol_info ()) ) -# 11552 "parsing/parser.ml" - : 'bar_extension_constructor_declaration)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 3 : 'constr_ident) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'constr_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in - Obj.repr( -# 2154 "parsing/parser.mly" - ( Te.rebind (mkrhs _1 1) (mkrhs _3 3) ~attrs:_4 - ~loc:(symbol_rloc()) ~info:(symbol_info ()) ) -# 11562 "parsing/parser.ml" - : 'extension_constructor_rebind)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'constr_ident) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'constr_longident) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in - Obj.repr( -# 2159 "parsing/parser.mly" - ( Te.rebind (mkrhs _2 2) (mkrhs _4 4) ~attrs:_5 - ~loc:(symbol_rloc()) ~info:(symbol_info ()) ) -# 11572 "parsing/parser.ml" - : 'bar_extension_constructor_rebind)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'with_constraint) in - Obj.repr( -# 2166 "parsing/parser.mly" - ( [_1] ) -# 11579 "parsing/parser.ml" - : 'with_constraints)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'with_constraints) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'with_constraint) in - Obj.repr( -# 2167 "parsing/parser.mly" - ( _3 :: _1 ) -# 11587 "parsing/parser.ml" - : 'with_constraints)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 4 : 'optional_type_parameters) in - let _3 = (Parsing.peek_val __caml_parser_env 3 : 'label_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 2 : 'with_type_binder) in - let _5 = (Parsing.peek_val __caml_parser_env 1 : 'core_type_no_attr) in - let _6 = (Parsing.peek_val __caml_parser_env 0 : 'constraints) in - Obj.repr( -# 2172 "parsing/parser.mly" - ( Pwith_type - (mkrhs _3 3, - (Type.mk (mkrhs (Longident.last _3) 3) - ~params:_2 - ~cstrs:(List.rev _6) - ~manifest:_5 - ~priv:_4 - ~loc:(symbol_rloc()))) ) -# 11605 "parsing/parser.ml" - : 'with_constraint)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'optional_type_parameters) in - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'label_longident) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'core_type_no_attr) in - Obj.repr( -# 2183 "parsing/parser.mly" - ( Pwith_typesubst - (mkrhs _3 3, - (Type.mk (mkrhs (Longident.last _3) 3) - ~params:_2 - ~manifest:_5 - ~loc:(symbol_rloc()))) ) -# 11619 "parsing/parser.ml" - : 'with_constraint)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'mod_ext_longident) in - Obj.repr( -# 2190 "parsing/parser.mly" - ( Pwith_module (mkrhs _2 2, mkrhs _4 4) ) -# 11627 "parsing/parser.ml" - : 'with_constraint)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'mod_ext_longident) in - Obj.repr( -# 2192 "parsing/parser.mly" - ( Pwith_modsubst (mkrhs _2 2, mkrhs _4 4) ) -# 11635 "parsing/parser.ml" - : 'with_constraint)) -; (fun __caml_parser_env -> - Obj.repr( -# 2195 "parsing/parser.mly" - ( Public ) -# 11641 "parsing/parser.ml" - : 'with_type_binder)) -; (fun __caml_parser_env -> - Obj.repr( -# 2196 "parsing/parser.mly" - ( Private ) -# 11647 "parsing/parser.ml" - : 'with_type_binder)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'ident) in - Obj.repr( -# 2202 "parsing/parser.mly" - ( [mkrhs _2 2] ) -# 11654 "parsing/parser.ml" - : 'typevar_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'typevar_list) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'ident) in - Obj.repr( -# 2203 "parsing/parser.mly" - ( mkrhs _3 3 :: _1 ) -# 11662 "parsing/parser.ml" - : 'typevar_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in - Obj.repr( -# 2207 "parsing/parser.mly" - ( _1 ) -# 11669 "parsing/parser.ml" - : 'poly_type)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'typevar_list) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in - Obj.repr( -# 2209 "parsing/parser.mly" - ( mktyp(Ptyp_poly(List.rev _1, _3)) ) -# 11677 "parsing/parser.ml" - : 'poly_type)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'core_type_no_attr) in - Obj.repr( -# 2213 "parsing/parser.mly" - ( _1 ) -# 11684 "parsing/parser.ml" - : 'poly_type_no_attr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'typevar_list) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type_no_attr) in - Obj.repr( -# 2215 "parsing/parser.mly" - ( mktyp(Ptyp_poly(List.rev _1, _3)) ) -# 11692 "parsing/parser.ml" - : 'poly_type_no_attr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'core_type_no_attr) in - Obj.repr( -# 2222 "parsing/parser.mly" - ( _1 ) -# 11699 "parsing/parser.ml" - : 'core_type)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'core_type) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attribute) in - Obj.repr( -# 2224 "parsing/parser.mly" - ( Typ.attr _1 _2 ) -# 11707 "parsing/parser.ml" - : 'core_type)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'core_type2) in - Obj.repr( -# 2228 "parsing/parser.mly" - ( _1 ) -# 11714 "parsing/parser.ml" - : 'core_type_no_attr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 3 : 'core_type2) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'ident) in - Obj.repr( -# 2230 "parsing/parser.mly" - ( mktyp(Ptyp_alias(_1, _4)) ) -# 11722 "parsing/parser.ml" - : 'core_type_no_attr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_core_type_or_tuple) in - Obj.repr( -# 2234 "parsing/parser.mly" - ( _1 ) -# 11729 "parsing/parser.ml" - : 'core_type2)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 4 : string) in - let _4 = (Parsing.peek_val __caml_parser_env 2 : 'core_type2) in - let _6 = (Parsing.peek_val __caml_parser_env 0 : 'core_type2) in - Obj.repr( -# 2236 "parsing/parser.mly" - ( let param = extra_rhs_core_type _4 ~pos:4 in - mktyp (Ptyp_arrow(Optional _2 , param, _6)) ) -# 11739 "parsing/parser.ml" - : 'core_type2)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'core_type2) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'core_type2) in - Obj.repr( -# 2239 "parsing/parser.mly" - ( let param = extra_rhs_core_type _2 ~pos:2 in - mktyp(Ptyp_arrow(Optional _1 , param, _4)) - ) -# 11750 "parsing/parser.ml" - : 'core_type2)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : string) in - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'core_type2) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'core_type2) in - Obj.repr( -# 2243 "parsing/parser.mly" - ( let param = extra_rhs_core_type _3 ~pos:3 in - mktyp(Ptyp_arrow(Labelled _1, param, _5)) ) -# 11760 "parsing/parser.ml" - : 'core_type2)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'core_type2) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type2) in - Obj.repr( -# 2246 "parsing/parser.mly" - ( let param = extra_rhs_core_type _1 ~pos:1 in - mktyp(Ptyp_arrow(Nolabel, param, _3)) ) -# 11769 "parsing/parser.ml" - : 'core_type2)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_core_type2) in - Obj.repr( -# 2252 "parsing/parser.mly" - ( _1 ) -# 11776 "parsing/parser.ml" - : 'simple_core_type)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'core_type_comma_list) in - Obj.repr( -# 2254 "parsing/parser.mly" - ( match _2 with [sty] -> sty | _ -> raise Parse_error ) -# 11783 "parsing/parser.ml" - : 'simple_core_type)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'ident) in - Obj.repr( -# 2259 "parsing/parser.mly" - ( mktyp(Ptyp_var _2) ) -# 11790 "parsing/parser.ml" - : 'simple_core_type2)) -; (fun __caml_parser_env -> - Obj.repr( -# 2261 "parsing/parser.mly" - ( mktyp(Ptyp_any) ) -# 11796 "parsing/parser.ml" - : 'simple_core_type2)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'type_longident) in - Obj.repr( -# 2263 "parsing/parser.mly" - ( mktyp(Ptyp_constr(mkrhs _1 1, [])) ) -# 11803 "parsing/parser.ml" - : 'simple_core_type2)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'simple_core_type2) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'type_longident) in - Obj.repr( -# 2265 "parsing/parser.mly" - ( mktyp(Ptyp_constr(mkrhs _2 2, [_1])) ) -# 11811 "parsing/parser.ml" - : 'simple_core_type2)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'core_type_comma_list) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'type_longident) in - Obj.repr( -# 2267 "parsing/parser.mly" - ( mktyp(Ptyp_constr(mkrhs _4 4, List.rev _2)) ) -# 11819 "parsing/parser.ml" - : 'simple_core_type2)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'meth_list) in - Obj.repr( -# 2269 "parsing/parser.mly" - ( let (f, c) = _2 in mktyp(Ptyp_object (f, c)) ) -# 11826 "parsing/parser.ml" - : 'simple_core_type2)) -; (fun __caml_parser_env -> - Obj.repr( -# 2271 "parsing/parser.mly" - ( mktyp(Ptyp_object ([], Closed)) ) -# 11832 "parsing/parser.ml" - : 'simple_core_type2)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'class_longident) in - Obj.repr( -# 2273 "parsing/parser.mly" - ( mktyp(Ptyp_class(mkrhs _2 2, [])) ) -# 11839 "parsing/parser.ml" - : 'simple_core_type2)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'simple_core_type2) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'class_longident) in - Obj.repr( -# 2275 "parsing/parser.mly" - ( mktyp(Ptyp_class(mkrhs _3 3, [_1])) ) -# 11847 "parsing/parser.ml" - : 'simple_core_type2)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'core_type_comma_list) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'class_longident) in - Obj.repr( -# 2277 "parsing/parser.mly" - ( mktyp(Ptyp_class(mkrhs _5 5, List.rev _2)) ) -# 11855 "parsing/parser.ml" - : 'simple_core_type2)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'tag_field) in - Obj.repr( -# 2279 "parsing/parser.mly" - ( mktyp(Ptyp_variant([_2], Closed, None)) ) -# 11862 "parsing/parser.ml" - : 'simple_core_type2)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'row_field_list) in - Obj.repr( -# 2285 "parsing/parser.mly" - ( mktyp(Ptyp_variant(List.rev _3, Closed, None)) ) -# 11869 "parsing/parser.ml" - : 'simple_core_type2)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'row_field) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'row_field_list) in - Obj.repr( -# 2287 "parsing/parser.mly" - ( mktyp(Ptyp_variant(_2 :: List.rev _4, Closed, None)) ) -# 11877 "parsing/parser.ml" - : 'simple_core_type2)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'opt_bar) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'row_field_list) in - Obj.repr( -# 2289 "parsing/parser.mly" - ( mktyp(Ptyp_variant(List.rev _3, Open, None)) ) -# 11885 "parsing/parser.ml" - : 'simple_core_type2)) -; (fun __caml_parser_env -> - Obj.repr( -# 2291 "parsing/parser.mly" - ( mktyp(Ptyp_variant([], Open, None)) ) -# 11891 "parsing/parser.ml" - : 'simple_core_type2)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'opt_bar) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'row_field_list) in - Obj.repr( -# 2293 "parsing/parser.mly" - ( mktyp(Ptyp_variant(List.rev _3, Closed, Some [])) ) -# 11899 "parsing/parser.ml" - : 'simple_core_type2)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 4 : 'opt_bar) in - let _3 = (Parsing.peek_val __caml_parser_env 3 : 'row_field_list) in - let _5 = (Parsing.peek_val __caml_parser_env 1 : 'name_tag_list) in - Obj.repr( -# 2295 "parsing/parser.mly" - ( mktyp(Ptyp_variant(List.rev _3, Closed, Some (List.rev _5))) ) -# 11908 "parsing/parser.ml" - : 'simple_core_type2)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'package_type) in - Obj.repr( -# 2297 "parsing/parser.mly" - ( mktyp_attrs (Ptyp_package _4) _3 ) -# 11916 "parsing/parser.ml" - : 'simple_core_type2)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'extension) in - Obj.repr( -# 2299 "parsing/parser.mly" - ( mktyp (Ptyp_extension _1) ) -# 11923 "parsing/parser.ml" - : 'simple_core_type2)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'module_type) in - Obj.repr( -# 2302 "parsing/parser.mly" - ( package_type_of_module_type _1 ) -# 11930 "parsing/parser.ml" - : 'package_type)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'row_field) in - Obj.repr( -# 2305 "parsing/parser.mly" - ( [_1] ) -# 11937 "parsing/parser.ml" - : 'row_field_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'row_field_list) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'row_field) in - Obj.repr( -# 2306 "parsing/parser.mly" - ( _3 :: _1 ) -# 11945 "parsing/parser.ml" - : 'row_field_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'tag_field) in - Obj.repr( -# 2309 "parsing/parser.mly" - ( _1 ) -# 11952 "parsing/parser.ml" - : 'row_field)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_core_type) in - Obj.repr( -# 2310 "parsing/parser.mly" - ( Rinherit _1 ) -# 11959 "parsing/parser.ml" - : 'row_field)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'name_tag) in - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'opt_ampersand) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'amper_type_list) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in - Obj.repr( -# 2314 "parsing/parser.mly" - ( Rtag (mkrhs _1 1, add_info_attrs (symbol_info ()) _5, - _3, List.rev _4) ) -# 11970 "parsing/parser.ml" - : 'tag_field)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'name_tag) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in - Obj.repr( -# 2317 "parsing/parser.mly" - ( Rtag (mkrhs _1 1, add_info_attrs (symbol_info ()) _2, true, []) ) -# 11978 "parsing/parser.ml" - : 'tag_field)) -; (fun __caml_parser_env -> - Obj.repr( -# 2320 "parsing/parser.mly" - ( true ) -# 11984 "parsing/parser.ml" - : 'opt_ampersand)) -; (fun __caml_parser_env -> - Obj.repr( -# 2321 "parsing/parser.mly" - ( false ) -# 11990 "parsing/parser.ml" - : 'opt_ampersand)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'core_type_no_attr) in - Obj.repr( -# 2324 "parsing/parser.mly" - ( [_1] ) -# 11997 "parsing/parser.ml" - : 'amper_type_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'amper_type_list) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type_no_attr) in - Obj.repr( -# 2325 "parsing/parser.mly" - ( _3 :: _1 ) -# 12005 "parsing/parser.ml" - : 'amper_type_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'name_tag) in - Obj.repr( -# 2328 "parsing/parser.mly" - ( [_1] ) -# 12012 "parsing/parser.ml" - : 'name_tag_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'name_tag_list) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'name_tag) in - Obj.repr( -# 2329 "parsing/parser.mly" - ( _2 :: _1 ) -# 12020 "parsing/parser.ml" - : 'name_tag_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_core_type) in - Obj.repr( -# 2332 "parsing/parser.mly" - ( _1 ) -# 12027 "parsing/parser.ml" - : 'simple_core_type_or_tuple)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'simple_core_type) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type_list) in - Obj.repr( -# 2334 "parsing/parser.mly" - ( mktyp(Ptyp_tuple(_1 :: List.rev _3)) ) -# 12035 "parsing/parser.ml" - : 'simple_core_type_or_tuple)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in - Obj.repr( -# 2337 "parsing/parser.mly" - ( [_1] ) -# 12042 "parsing/parser.ml" - : 'core_type_comma_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'core_type_comma_list) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in - Obj.repr( -# 2338 "parsing/parser.mly" - ( _3 :: _1 ) -# 12050 "parsing/parser.ml" - : 'core_type_comma_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_core_type) in - Obj.repr( -# 2341 "parsing/parser.mly" - ( [_1] ) -# 12057 "parsing/parser.ml" - : 'core_type_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'core_type_list) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'simple_core_type) in - Obj.repr( -# 2342 "parsing/parser.mly" - ( _3 :: _1 ) -# 12065 "parsing/parser.ml" - : 'core_type_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'field_semi) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'meth_list) in - Obj.repr( -# 2345 "parsing/parser.mly" - ( let (f, c) = _2 in (_1 :: f, c) ) -# 12073 "parsing/parser.ml" - : 'meth_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'inherit_field_semi) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'meth_list) in - Obj.repr( -# 2346 "parsing/parser.mly" - ( let (f, c) = _2 in (_1 :: f, c) ) -# 12081 "parsing/parser.ml" - : 'meth_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'field_semi) in - Obj.repr( -# 2347 "parsing/parser.mly" - ( [_1], Closed ) -# 12088 "parsing/parser.ml" - : 'meth_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'field) in - Obj.repr( -# 2348 "parsing/parser.mly" - ( [_1], Closed ) -# 12095 "parsing/parser.ml" - : 'meth_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'inherit_field_semi) in - Obj.repr( -# 2349 "parsing/parser.mly" - ( [_1], Closed ) -# 12102 "parsing/parser.ml" - : 'meth_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_core_type) in - Obj.repr( -# 2350 "parsing/parser.mly" - ( [Oinherit _1], Closed ) -# 12109 "parsing/parser.ml" - : 'meth_list)) -; (fun __caml_parser_env -> - Obj.repr( -# 2351 "parsing/parser.mly" - ( [], Open ) -# 12115 "parsing/parser.ml" - : 'meth_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 3 : 'label) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'poly_type_no_attr) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in - Obj.repr( -# 2355 "parsing/parser.mly" - ( Otag (mkrhs _1 1, add_info_attrs (symbol_info ()) _4, _3) ) -# 12124 "parsing/parser.ml" - : 'field)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 5 : 'label) in - let _3 = (Parsing.peek_val __caml_parser_env 3 : 'poly_type_no_attr) in - let _4 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in - let _6 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in - Obj.repr( -# 2360 "parsing/parser.mly" - ( let info = - match rhs_info 4 with - | Some _ as info_before_semi -> info_before_semi - | None -> symbol_info () - in - ( Otag (mkrhs _1 1, add_info_attrs info (_4 @ _6), _3)) ) -# 12139 "parsing/parser.ml" - : 'field_semi)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'simple_core_type) in - Obj.repr( -# 2369 "parsing/parser.mly" - ( Oinherit _1 ) -# 12146 "parsing/parser.ml" - : 'inherit_field_semi)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2372 "parsing/parser.mly" - ( _1 ) -# 12153 "parsing/parser.ml" - : 'label)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string * char option) in - Obj.repr( -# 2378 "parsing/parser.mly" - ( let (n, m) = _1 in Pconst_integer (n, m) ) -# 12160 "parsing/parser.ml" - : 'constant)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : char) in - Obj.repr( -# 2379 "parsing/parser.mly" - ( Pconst_char _1 ) -# 12167 "parsing/parser.ml" - : 'constant)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string * string option) in - Obj.repr( -# 2380 "parsing/parser.mly" - ( let (s, d) = _1 in Pconst_string (s, d) ) -# 12174 "parsing/parser.ml" - : 'constant)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string * char option) in - Obj.repr( -# 2381 "parsing/parser.mly" - ( let (f, m) = _1 in Pconst_float (f, m) ) -# 12181 "parsing/parser.ml" - : 'constant)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'constant) in - Obj.repr( -# 2384 "parsing/parser.mly" - ( _1 ) -# 12188 "parsing/parser.ml" - : 'signed_constant)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : string * char option) in - Obj.repr( -# 2385 "parsing/parser.mly" - ( let (n, m) = _2 in Pconst_integer("-" ^ n, m) ) -# 12195 "parsing/parser.ml" - : 'signed_constant)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : string * char option) in - Obj.repr( -# 2386 "parsing/parser.mly" - ( let (f, m) = _2 in Pconst_float("-" ^ f, m) ) -# 12202 "parsing/parser.ml" - : 'signed_constant)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : string * char option) in - Obj.repr( -# 2387 "parsing/parser.mly" - ( let (n, m) = _2 in Pconst_integer (n, m) ) -# 12209 "parsing/parser.ml" - : 'signed_constant)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : string * char option) in - Obj.repr( -# 2388 "parsing/parser.mly" - ( let (f, m) = _2 in Pconst_float(f, m) ) -# 12216 "parsing/parser.ml" - : 'signed_constant)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2394 "parsing/parser.mly" - ( _1 ) -# 12223 "parsing/parser.ml" - : 'ident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2395 "parsing/parser.mly" - ( _1 ) -# 12230 "parsing/parser.ml" - : 'ident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2398 "parsing/parser.mly" - ( _1 ) -# 12237 "parsing/parser.ml" - : 'val_ident)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'operator) in - Obj.repr( -# 2399 "parsing/parser.mly" - ( _2 ) -# 12244 "parsing/parser.ml" - : 'val_ident)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'operator) in - Obj.repr( -# 2400 "parsing/parser.mly" - ( unclosed "(" 1 ")" 3 ) -# 12251 "parsing/parser.ml" - : 'val_ident)) -; (fun __caml_parser_env -> - Obj.repr( -# 2401 "parsing/parser.mly" - ( expecting 2 "operator" ) -# 12257 "parsing/parser.ml" - : 'val_ident)) -; (fun __caml_parser_env -> - Obj.repr( -# 2402 "parsing/parser.mly" - ( expecting 3 "module-expr" ) -# 12263 "parsing/parser.ml" - : 'val_ident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2405 "parsing/parser.mly" - ( _1 ) -# 12270 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2406 "parsing/parser.mly" - ( _1 ) -# 12277 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2407 "parsing/parser.mly" - ( _1 ) -# 12284 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2408 "parsing/parser.mly" - ( _1 ) -# 12291 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2409 "parsing/parser.mly" - ( _1 ) -# 12298 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2410 "parsing/parser.mly" - ( _1 ) -# 12305 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : string) in - Obj.repr( -# 2411 "parsing/parser.mly" - ( "."^ _1 ^"()" ) -# 12312 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 3 : string) in - Obj.repr( -# 2412 "parsing/parser.mly" - ( "."^ _1 ^ "()<-" ) -# 12319 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : string) in - Obj.repr( -# 2413 "parsing/parser.mly" - ( "."^ _1 ^"[]" ) -# 12326 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 3 : string) in - Obj.repr( -# 2414 "parsing/parser.mly" - ( "."^ _1 ^ "[]<-" ) -# 12333 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : string) in - Obj.repr( -# 2415 "parsing/parser.mly" - ( "."^ _1 ^"{}" ) -# 12340 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 3 : string) in - Obj.repr( -# 2416 "parsing/parser.mly" - ( "."^ _1 ^ "{}<-" ) -# 12347 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2417 "parsing/parser.mly" - ( _1 ) -# 12354 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - Obj.repr( -# 2418 "parsing/parser.mly" - ( "!" ) -# 12360 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - Obj.repr( -# 2419 "parsing/parser.mly" - ( "+" ) -# 12366 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - Obj.repr( -# 2420 "parsing/parser.mly" - ( "+." ) -# 12372 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - Obj.repr( -# 2421 "parsing/parser.mly" - ( "-" ) -# 12378 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - Obj.repr( -# 2422 "parsing/parser.mly" - ( "-." ) -# 12384 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - Obj.repr( -# 2423 "parsing/parser.mly" - ( "*" ) -# 12390 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - Obj.repr( -# 2424 "parsing/parser.mly" - ( "=" ) -# 12396 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - Obj.repr( -# 2425 "parsing/parser.mly" - ( "<" ) -# 12402 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - Obj.repr( -# 2426 "parsing/parser.mly" - ( ">" ) -# 12408 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - Obj.repr( -# 2427 "parsing/parser.mly" - ( "or" ) -# 12414 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - Obj.repr( -# 2428 "parsing/parser.mly" - ( "||" ) -# 12420 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - Obj.repr( -# 2429 "parsing/parser.mly" - ( "&" ) -# 12426 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - Obj.repr( -# 2430 "parsing/parser.mly" - ( "&&" ) -# 12432 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - Obj.repr( -# 2431 "parsing/parser.mly" - ( ":=" ) -# 12438 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - Obj.repr( -# 2432 "parsing/parser.mly" - ( "+=" ) -# 12444 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - Obj.repr( -# 2433 "parsing/parser.mly" - ( "%" ) -# 12450 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2436 "parsing/parser.mly" - ( _1 ) -# 12457 "parsing/parser.ml" - : 'constr_ident)) -; (fun __caml_parser_env -> - Obj.repr( -# 2437 "parsing/parser.mly" - ( "[]" ) -# 12463 "parsing/parser.ml" - : 'constr_ident)) -; (fun __caml_parser_env -> - Obj.repr( -# 2438 "parsing/parser.mly" - ( "()" ) -# 12469 "parsing/parser.ml" - : 'constr_ident)) -; (fun __caml_parser_env -> - Obj.repr( -# 2439 "parsing/parser.mly" - ( "::" ) -# 12475 "parsing/parser.ml" - : 'constr_ident)) -; (fun __caml_parser_env -> - Obj.repr( -# 2440 "parsing/parser.mly" - ( "false" ) -# 12481 "parsing/parser.ml" - : 'constr_ident)) -; (fun __caml_parser_env -> - Obj.repr( -# 2441 "parsing/parser.mly" - ( "true" ) -# 12487 "parsing/parser.ml" - : 'constr_ident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'val_ident) in - Obj.repr( -# 2445 "parsing/parser.mly" - ( Lident _1 ) -# 12494 "parsing/parser.ml" - : 'val_longident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'mod_longident) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'val_ident) in - Obj.repr( -# 2446 "parsing/parser.mly" - ( Ldot(_1, _3) ) -# 12502 "parsing/parser.ml" - : 'val_longident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'mod_longident) in - Obj.repr( -# 2449 "parsing/parser.mly" - ( _1 ) -# 12509 "parsing/parser.ml" - : 'constr_longident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in - Obj.repr( -# 2450 "parsing/parser.mly" - ( Ldot(_1,"::") ) -# 12516 "parsing/parser.ml" - : 'constr_longident)) -; (fun __caml_parser_env -> - Obj.repr( -# 2451 "parsing/parser.mly" - ( Lident "[]" ) -# 12522 "parsing/parser.ml" - : 'constr_longident)) -; (fun __caml_parser_env -> - Obj.repr( -# 2452 "parsing/parser.mly" - ( Lident "()" ) -# 12528 "parsing/parser.ml" - : 'constr_longident)) -; (fun __caml_parser_env -> - Obj.repr( -# 2453 "parsing/parser.mly" - ( Lident "::" ) -# 12534 "parsing/parser.ml" - : 'constr_longident)) -; (fun __caml_parser_env -> - Obj.repr( -# 2454 "parsing/parser.mly" - ( Lident "false" ) -# 12540 "parsing/parser.ml" - : 'constr_longident)) -; (fun __caml_parser_env -> - Obj.repr( -# 2455 "parsing/parser.mly" - ( Lident "true" ) -# 12546 "parsing/parser.ml" - : 'constr_longident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2458 "parsing/parser.mly" - ( Lident _1 ) -# 12553 "parsing/parser.ml" - : 'label_longident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'mod_longident) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2459 "parsing/parser.mly" - ( Ldot(_1, _3) ) -# 12561 "parsing/parser.ml" - : 'label_longident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2462 "parsing/parser.mly" - ( Lident _1 ) -# 12568 "parsing/parser.ml" - : 'type_longident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'mod_ext_longident) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2463 "parsing/parser.mly" - ( Ldot(_1, _3) ) -# 12576 "parsing/parser.ml" - : 'type_longident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2466 "parsing/parser.mly" - ( Lident _1 ) -# 12583 "parsing/parser.ml" - : 'mod_longident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'mod_longident) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2467 "parsing/parser.mly" - ( Ldot(_1, _3) ) -# 12591 "parsing/parser.ml" - : 'mod_longident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2470 "parsing/parser.mly" - ( Lident _1 ) -# 12598 "parsing/parser.ml" - : 'mod_ext_longident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'mod_ext_longident) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2471 "parsing/parser.mly" - ( Ldot(_1, _3) ) -# 12606 "parsing/parser.ml" - : 'mod_ext_longident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 3 : 'mod_ext_longident) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'mod_ext_longident) in - Obj.repr( -# 2472 "parsing/parser.mly" - ( lapply _1 _3 ) -# 12614 "parsing/parser.ml" - : 'mod_ext_longident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'ident) in - Obj.repr( -# 2475 "parsing/parser.mly" - ( Lident _1 ) -# 12621 "parsing/parser.ml" - : 'mty_longident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'mod_ext_longident) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'ident) in - Obj.repr( -# 2476 "parsing/parser.mly" - ( Ldot(_1, _3) ) -# 12629 "parsing/parser.ml" - : 'mty_longident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2479 "parsing/parser.mly" - ( Lident _1 ) -# 12636 "parsing/parser.ml" - : 'clty_longident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'mod_ext_longident) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2480 "parsing/parser.mly" - ( Ldot(_1, _3) ) -# 12644 "parsing/parser.ml" - : 'clty_longident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2483 "parsing/parser.mly" - ( Lident _1 ) -# 12651 "parsing/parser.ml" - : 'class_longident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'mod_longident) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2484 "parsing/parser.mly" - ( Ldot(_1, _3) ) -# 12659 "parsing/parser.ml" - : 'class_longident)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'ident) in - Obj.repr( -# 2490 "parsing/parser.mly" - ( Ptop_dir(_2, Pdir_none) ) -# 12666 "parsing/parser.ml" - : 'toplevel_directive)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ident) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : string * string option) in - Obj.repr( -# 2491 "parsing/parser.mly" - ( Ptop_dir(_2, Pdir_string (fst _3)) ) -# 12674 "parsing/parser.ml" - : 'toplevel_directive)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ident) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : string * char option) in - Obj.repr( -# 2492 "parsing/parser.mly" - ( let (n, m) = _3 in - Ptop_dir(_2, Pdir_int (n ,m)) ) -# 12683 "parsing/parser.ml" - : 'toplevel_directive)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ident) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'val_longident) in - Obj.repr( -# 2494 "parsing/parser.mly" - ( Ptop_dir(_2, Pdir_ident _3) ) -# 12691 "parsing/parser.ml" - : 'toplevel_directive)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ident) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'mod_longident) in - Obj.repr( -# 2495 "parsing/parser.mly" - ( Ptop_dir(_2, Pdir_ident _3) ) -# 12699 "parsing/parser.ml" - : 'toplevel_directive)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ident) in - Obj.repr( -# 2496 "parsing/parser.mly" - ( Ptop_dir(_2, Pdir_bool false) ) -# 12706 "parsing/parser.ml" - : 'toplevel_directive)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ident) in - Obj.repr( -# 2497 "parsing/parser.mly" - ( Ptop_dir(_2, Pdir_bool true) ) -# 12713 "parsing/parser.ml" - : 'toplevel_directive)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'ident) in - Obj.repr( -# 2503 "parsing/parser.mly" - ( _2 ) -# 12720 "parsing/parser.ml" - : 'name_tag)) -; (fun __caml_parser_env -> - Obj.repr( -# 2506 "parsing/parser.mly" - ( Nonrecursive ) -# 12726 "parsing/parser.ml" - : 'rec_flag)) -; (fun __caml_parser_env -> - Obj.repr( -# 2507 "parsing/parser.mly" - ( Recursive ) -# 12732 "parsing/parser.ml" - : 'rec_flag)) -; (fun __caml_parser_env -> - Obj.repr( -# 2510 "parsing/parser.mly" - ( Recursive ) -# 12738 "parsing/parser.ml" - : 'nonrec_flag)) -; (fun __caml_parser_env -> - Obj.repr( -# 2511 "parsing/parser.mly" - ( Nonrecursive ) -# 12744 "parsing/parser.ml" - : 'nonrec_flag)) -; (fun __caml_parser_env -> - Obj.repr( -# 2514 "parsing/parser.mly" - ( Upto ) -# 12750 "parsing/parser.ml" - : 'direction_flag)) -; (fun __caml_parser_env -> - Obj.repr( -# 2515 "parsing/parser.mly" - ( Downto ) -# 12756 "parsing/parser.ml" - : 'direction_flag)) -; (fun __caml_parser_env -> - Obj.repr( -# 2518 "parsing/parser.mly" - ( Public ) -# 12762 "parsing/parser.ml" - : 'private_flag)) -; (fun __caml_parser_env -> - Obj.repr( -# 2519 "parsing/parser.mly" - ( Private ) -# 12768 "parsing/parser.ml" - : 'private_flag)) -; (fun __caml_parser_env -> - Obj.repr( -# 2522 "parsing/parser.mly" - ( Immutable ) -# 12774 "parsing/parser.ml" - : 'mutable_flag)) -; (fun __caml_parser_env -> - Obj.repr( -# 2523 "parsing/parser.mly" - ( Mutable ) -# 12780 "parsing/parser.ml" - : 'mutable_flag)) -; (fun __caml_parser_env -> - Obj.repr( -# 2526 "parsing/parser.mly" - ( Concrete ) -# 12786 "parsing/parser.ml" - : 'virtual_flag)) -; (fun __caml_parser_env -> - Obj.repr( -# 2527 "parsing/parser.mly" - ( Virtual ) -# 12792 "parsing/parser.ml" - : 'virtual_flag)) -; (fun __caml_parser_env -> - Obj.repr( -# 2530 "parsing/parser.mly" - ( Public, Concrete ) -# 12798 "parsing/parser.ml" - : 'private_virtual_flags)) -; (fun __caml_parser_env -> - Obj.repr( -# 2531 "parsing/parser.mly" - ( Private, Concrete ) -# 12804 "parsing/parser.ml" - : 'private_virtual_flags)) -; (fun __caml_parser_env -> - Obj.repr( -# 2532 "parsing/parser.mly" - ( Public, Virtual ) -# 12810 "parsing/parser.ml" - : 'private_virtual_flags)) -; (fun __caml_parser_env -> - Obj.repr( -# 2533 "parsing/parser.mly" - ( Private, Virtual ) -# 12816 "parsing/parser.ml" - : 'private_virtual_flags)) -; (fun __caml_parser_env -> - Obj.repr( -# 2534 "parsing/parser.mly" - ( Private, Virtual ) -# 12822 "parsing/parser.ml" - : 'private_virtual_flags)) -; (fun __caml_parser_env -> - Obj.repr( -# 2537 "parsing/parser.mly" - ( Fresh ) -# 12828 "parsing/parser.ml" - : 'override_flag)) -; (fun __caml_parser_env -> - Obj.repr( -# 2538 "parsing/parser.mly" - ( Override ) -# 12834 "parsing/parser.ml" - : 'override_flag)) -; (fun __caml_parser_env -> - Obj.repr( -# 2541 "parsing/parser.mly" - ( () ) -# 12840 "parsing/parser.ml" - : 'opt_bar)) -; (fun __caml_parser_env -> - Obj.repr( -# 2542 "parsing/parser.mly" - ( () ) -# 12846 "parsing/parser.ml" - : 'opt_bar)) -; (fun __caml_parser_env -> - Obj.repr( -# 2545 "parsing/parser.mly" - ( () ) -# 12852 "parsing/parser.ml" - : 'opt_semi)) -; (fun __caml_parser_env -> - Obj.repr( -# 2546 "parsing/parser.mly" - ( () ) -# 12858 "parsing/parser.ml" - : 'opt_semi)) -; (fun __caml_parser_env -> - Obj.repr( -# 2549 "parsing/parser.mly" - ( "-" ) -# 12864 "parsing/parser.ml" - : 'subtractive)) -; (fun __caml_parser_env -> - Obj.repr( -# 2550 "parsing/parser.mly" - ( "-." ) -# 12870 "parsing/parser.ml" - : 'subtractive)) -; (fun __caml_parser_env -> - Obj.repr( -# 2553 "parsing/parser.mly" - ( "+" ) -# 12876 "parsing/parser.ml" - : 'additive)) -; (fun __caml_parser_env -> - Obj.repr( -# 2554 "parsing/parser.mly" - ( "+." ) -# 12882 "parsing/parser.ml" - : 'additive)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2560 "parsing/parser.mly" - ( _1 ) -# 12889 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2561 "parsing/parser.mly" - ( _1 ) -# 12896 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2562 "parsing/parser.mly" - ( "and" ) -# 12902 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2563 "parsing/parser.mly" - ( "as" ) -# 12908 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2564 "parsing/parser.mly" - ( "assert" ) -# 12914 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2565 "parsing/parser.mly" - ( "begin" ) -# 12920 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2566 "parsing/parser.mly" - ( "class" ) -# 12926 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2567 "parsing/parser.mly" - ( "constraint" ) -# 12932 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2568 "parsing/parser.mly" - ( "do" ) -# 12938 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2569 "parsing/parser.mly" - ( "done" ) -# 12944 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2570 "parsing/parser.mly" - ( "downto" ) -# 12950 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2571 "parsing/parser.mly" - ( "else" ) -# 12956 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2572 "parsing/parser.mly" - ( "end" ) -# 12962 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2573 "parsing/parser.mly" - ( "exception" ) -# 12968 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2574 "parsing/parser.mly" - ( "external" ) -# 12974 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2575 "parsing/parser.mly" - ( "false" ) -# 12980 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2576 "parsing/parser.mly" - ( "for" ) -# 12986 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2577 "parsing/parser.mly" - ( "fun" ) -# 12992 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2578 "parsing/parser.mly" - ( "function" ) -# 12998 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2579 "parsing/parser.mly" - ( "functor" ) -# 13004 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2580 "parsing/parser.mly" - ( "if" ) -# 13010 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2581 "parsing/parser.mly" - ( "in" ) -# 13016 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2582 "parsing/parser.mly" - ( "include" ) -# 13022 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2583 "parsing/parser.mly" - ( "inherit" ) -# 13028 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2584 "parsing/parser.mly" - ( "initializer" ) -# 13034 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2585 "parsing/parser.mly" - ( "lazy" ) -# 13040 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2586 "parsing/parser.mly" - ( "let" ) -# 13046 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2587 "parsing/parser.mly" - ( "match" ) -# 13052 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2588 "parsing/parser.mly" - ( "method" ) -# 13058 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2589 "parsing/parser.mly" - ( "module" ) -# 13064 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2590 "parsing/parser.mly" - ( "mutable" ) -# 13070 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2591 "parsing/parser.mly" - ( "new" ) -# 13076 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2592 "parsing/parser.mly" - ( "nonrec" ) -# 13082 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2593 "parsing/parser.mly" - ( "object" ) -# 13088 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2594 "parsing/parser.mly" - ( "of" ) -# 13094 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2595 "parsing/parser.mly" - ( "open" ) -# 13100 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2596 "parsing/parser.mly" - ( "or" ) -# 13106 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2597 "parsing/parser.mly" - ( "private" ) -# 13112 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2598 "parsing/parser.mly" - ( "rec" ) -# 13118 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2599 "parsing/parser.mly" - ( "sig" ) -# 13124 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2600 "parsing/parser.mly" - ( "struct" ) -# 13130 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2601 "parsing/parser.mly" - ( "then" ) -# 13136 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2602 "parsing/parser.mly" - ( "to" ) -# 13142 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2603 "parsing/parser.mly" - ( "true" ) -# 13148 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2604 "parsing/parser.mly" - ( "try" ) -# 13154 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2605 "parsing/parser.mly" - ( "type" ) -# 13160 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2606 "parsing/parser.mly" - ( "val" ) -# 13166 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2607 "parsing/parser.mly" - ( "virtual" ) -# 13172 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2608 "parsing/parser.mly" - ( "when" ) -# 13178 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2609 "parsing/parser.mly" - ( "while" ) -# 13184 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2610 "parsing/parser.mly" - ( "with" ) -# 13190 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'single_attr_id) in - Obj.repr( -# 2615 "parsing/parser.mly" - ( mkloc _1 (symbol_rloc()) ) -# 13197 "parsing/parser.ml" - : 'attr_id)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'single_attr_id) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'attr_id) in - Obj.repr( -# 2616 "parsing/parser.mly" - ( mkloc (_1 ^ "." ^ _3.txt) (symbol_rloc())) -# 13205 "parsing/parser.ml" - : 'attr_id)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attr_id) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'payload) in - Obj.repr( -# 2619 "parsing/parser.mly" - ( (_2, _3) ) -# 13213 "parsing/parser.ml" - : 'attribute)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attr_id) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'payload) in - Obj.repr( -# 2622 "parsing/parser.mly" - ( (_2, _3) ) -# 13221 "parsing/parser.ml" - : 'post_item_attribute)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attr_id) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'payload) in - Obj.repr( -# 2625 "parsing/parser.mly" - ( (_2, _3) ) -# 13229 "parsing/parser.ml" - : 'floating_attribute)) -; (fun __caml_parser_env -> - Obj.repr( -# 2628 "parsing/parser.mly" - ( [] ) -# 13235 "parsing/parser.ml" - : 'post_item_attributes)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'post_item_attribute) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 2629 "parsing/parser.mly" - ( _1 :: _2 ) -# 13243 "parsing/parser.ml" - : 'post_item_attributes)) -; (fun __caml_parser_env -> - Obj.repr( -# 2632 "parsing/parser.mly" - ( [] ) -# 13249 "parsing/parser.ml" - : 'attributes)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'attribute) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in - Obj.repr( -# 2633 "parsing/parser.mly" - ( _1 :: _2 ) -# 13257 "parsing/parser.ml" - : 'attributes)) -; (fun __caml_parser_env -> - Obj.repr( -# 2636 "parsing/parser.mly" - ( None, [] ) -# 13263 "parsing/parser.ml" - : 'ext_attributes)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'attribute) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in - Obj.repr( -# 2637 "parsing/parser.mly" - ( None, _1 :: _2 ) -# 13271 "parsing/parser.ml" - : 'ext_attributes)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'attr_id) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in - Obj.repr( -# 2638 "parsing/parser.mly" - ( Some _2, _3 ) -# 13279 "parsing/parser.ml" - : 'ext_attributes)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attr_id) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'payload) in - Obj.repr( -# 2641 "parsing/parser.mly" - ( (_2, _3) ) -# 13287 "parsing/parser.ml" - : 'extension)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attr_id) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'payload) in - Obj.repr( -# 2644 "parsing/parser.mly" - ( (_2, _3) ) -# 13295 "parsing/parser.ml" - : 'item_extension)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'structure) in - Obj.repr( -# 2647 "parsing/parser.mly" - ( PStr _1 ) -# 13302 "parsing/parser.ml" - : 'payload)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'signature) in - Obj.repr( -# 2648 "parsing/parser.mly" - ( PSig _2 ) -# 13309 "parsing/parser.ml" - : 'payload)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in - Obj.repr( -# 2649 "parsing/parser.mly" - ( PTyp _2 ) -# 13316 "parsing/parser.ml" - : 'payload)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in - Obj.repr( -# 2650 "parsing/parser.mly" - ( PPat (_2, None) ) -# 13323 "parsing/parser.ml" - : 'payload)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 2651 "parsing/parser.mly" - ( PPat (_2, Some _4) ) -# 13331 "parsing/parser.ml" - : 'payload)) -(* Entry implementation *) -; (fun __caml_parser_env -> raise (Parsing.YYexit (Parsing.peek_val __caml_parser_env 0))) -(* Entry interface *) -; (fun __caml_parser_env -> raise (Parsing.YYexit (Parsing.peek_val __caml_parser_env 0))) -(* Entry toplevel_phrase *) -; (fun __caml_parser_env -> raise (Parsing.YYexit (Parsing.peek_val __caml_parser_env 0))) -(* Entry use_file *) -; (fun __caml_parser_env -> raise (Parsing.YYexit (Parsing.peek_val __caml_parser_env 0))) -(* Entry parse_core_type *) -; (fun __caml_parser_env -> raise (Parsing.YYexit (Parsing.peek_val __caml_parser_env 0))) -(* Entry parse_expression *) -; (fun __caml_parser_env -> raise (Parsing.YYexit (Parsing.peek_val __caml_parser_env 0))) -(* Entry parse_pattern *) -; (fun __caml_parser_env -> raise (Parsing.YYexit (Parsing.peek_val __caml_parser_env 0))) -|] -let yytables = - { Parsing.actions=yyact; - Parsing.transl_const=yytransl_const; - Parsing.transl_block=yytransl_block; - Parsing.lhs=yylhs; - Parsing.len=yylen; - Parsing.defred=yydefred; - Parsing.dgoto=yydgoto; - Parsing.sindex=yysindex; - Parsing.rindex=yyrindex; - Parsing.gindex=yygindex; - Parsing.tablesize=yytablesize; - Parsing.table=yytable; - Parsing.check=yycheck; - Parsing.error_function=parse_error; - Parsing.names_const=yynames_const; - Parsing.names_block=yynames_block } -let implementation (lexfun : Lexing.lexbuf -> token) (lexbuf : Lexing.lexbuf) = - (Parsing.yyparse yytables 1 lexfun lexbuf : Parsetree.structure) -let interface (lexfun : Lexing.lexbuf -> token) (lexbuf : Lexing.lexbuf) = - (Parsing.yyparse yytables 2 lexfun lexbuf : Parsetree.signature) -let toplevel_phrase (lexfun : Lexing.lexbuf -> token) (lexbuf : Lexing.lexbuf) = - (Parsing.yyparse yytables 3 lexfun lexbuf : Parsetree.toplevel_phrase) -let use_file (lexfun : Lexing.lexbuf -> token) (lexbuf : Lexing.lexbuf) = - (Parsing.yyparse yytables 4 lexfun lexbuf : Parsetree.toplevel_phrase list) -let parse_core_type (lexfun : Lexing.lexbuf -> token) (lexbuf : Lexing.lexbuf) = - (Parsing.yyparse yytables 5 lexfun lexbuf : Parsetree.core_type) -let parse_expression (lexfun : Lexing.lexbuf -> token) (lexbuf : Lexing.lexbuf) = - (Parsing.yyparse yytables 6 lexfun lexbuf : Parsetree.expression) -let parse_pattern (lexfun : Lexing.lexbuf -> token) (lexbuf : Lexing.lexbuf) = - (Parsing.yyparse yytables 7 lexfun lexbuf : Parsetree.pattern) -;; - -end -module Lexer : sig -#1 "lexer.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) - -(* The lexical analyzer *) - -val init : unit -> unit -val token: Lexing.lexbuf -> Parser.token -val skip_hash_bang: Lexing.lexbuf -> unit - -type directive_type - -type error = - | Illegal_character of char - | Illegal_escape of string - | Unterminated_comment of Location.t - | Unterminated_string - | Unterminated_string_in_comment of Location.t * Location.t - | Keyword_as_label of string - | Invalid_literal of string - | Invalid_directive of string * string option - | Unterminated_paren_in_conditional - | Unterminated_if - | Unterminated_else - | Unexpected_token_in_conditional - | Expect_hash_then_in_conditional - | Illegal_semver of string - | Unexpected_directive - | Conditional_expr_expected_type of directive_type * directive_type -;; - -exception Error of error * Location.t - -open Format - -val report_error: formatter -> error -> unit - (* Deprecated. Use Location.{error_of_exn, report_error}. *) - -val in_comment : unit -> bool;; -val in_string : unit -> bool;; - - -val print_warnings : bool ref -val handle_docstrings: bool ref -val comments : unit -> (string * Location.t) list -val token_with_comments : Lexing.lexbuf -> Parser.token - -(* - [set_preprocessor init preprocessor] registers [init] as the function -to call to initialize the preprocessor when the lexer is initialized, -and [preprocessor] a function that is called when a new token is needed -by the parser, as [preprocessor lexer lexbuf] where [lexer] is the -lexing function. - -When a preprocessor is configured by calling [set_preprocessor], the lexer -changes its behavior to accept backslash-newline as a token-separating blank. -*) - -val set_preprocessor : - (unit -> unit) -> - ((Lexing.lexbuf -> Parser.token) -> Lexing.lexbuf -> Parser.token) -> - unit - -(** semantic version predicate *) -val semver : Location.t -> string -> string -> bool - -val filter_directive_from_lexbuf : Lexing.lexbuf -> (int * int) list - -val replace_directive_int : string -> int -> unit -val replace_directive_string : string -> string -> unit -val replace_directive_bool : string -> bool -> unit -val remove_directive_built_in_value : string -> unit - -(** @return false means failed to define *) -val define_key_value : string -> string -> bool -val list_variables : Format.formatter -> unit - -end = struct -#1 "lexer.ml" -# 18 "parsing/lexer.mll" - -open Lexing -open Misc -open Parser - -type directive_value = - | Dir_bool of bool - | Dir_float of float - | Dir_int of int - | Dir_string of string - | Dir_null - -type directive_type = - | Dir_type_bool - | Dir_type_float - | Dir_type_int - | Dir_type_string - | Dir_type_null - -let type_of_directive x = - match x with - | Dir_bool _ -> Dir_type_bool - | Dir_float _ -> Dir_type_float - | Dir_int _ -> Dir_type_int - | Dir_string _ -> Dir_type_string - | Dir_null -> Dir_type_null - -let string_of_type_directive x = - match x with - | Dir_type_bool -> "bool" - | Dir_type_float -> "float" - | Dir_type_int -> "int" - | Dir_type_string -> "string" - | Dir_type_null -> "null" - -type error = - | Illegal_character of char - | Illegal_escape of string - | Unterminated_comment of Location.t - | Unterminated_string - | Unterminated_string_in_comment of Location.t * Location.t - | Keyword_as_label of string - | Invalid_literal of string - | Invalid_directive of string * string option - | Unterminated_paren_in_conditional - | Unterminated_if - | Unterminated_else - | Unexpected_token_in_conditional - | Expect_hash_then_in_conditional - | Illegal_semver of string - | Unexpected_directive - | Conditional_expr_expected_type of directive_type * directive_type - -;; - -exception Error of error * Location.t;; - -let assert_same_type lexbuf x y = - let lhs = type_of_directive x in let rhs = type_of_directive y in - if lhs <> rhs then - raise (Error(Conditional_expr_expected_type(lhs,rhs), Location.curr lexbuf)) - else y - -let directive_built_in_values = - Hashtbl.create 51 - - -let replace_directive_built_in_value k v = - Hashtbl.replace directive_built_in_values k v - -let remove_directive_built_in_value k = - Hashtbl.replace directive_built_in_values k Dir_null - -let replace_directive_int k v = - Hashtbl.replace directive_built_in_values k (Dir_int v) - -let replace_directive_bool k v = - Hashtbl.replace directive_built_in_values k (Dir_bool v) - -let replace_directive_string k v = - Hashtbl.replace directive_built_in_values k (Dir_string v) - -let () = - (* Note we use {!Config} instead of {!Sys} becasue - we want to overwrite in some cases with the - same stdlib - *) - let version = - Config.version (* so that it can be overridden*) - in - replace_directive_built_in_value "OCAML_VERSION" - (Dir_string version); - replace_directive_built_in_value "OCAML_PATCH" - (Dir_string - (match String.rindex version '+' with - | exception Not_found -> "" - | i -> - String.sub version (i + 1) - (String.length version - i - 1))) - ; - replace_directive_built_in_value "OS_TYPE" - (Dir_string Sys.os_type); - replace_directive_built_in_value "BIG_ENDIAN" - (Dir_bool Sys.big_endian); - replace_directive_built_in_value "WORD_SIZE" - (Dir_int Sys.word_size) - -let find_directive_built_in_value k = - Hashtbl.find directive_built_in_values k - -let iter_directive_built_in_value f = Hashtbl.iter f directive_built_in_values - -(* - {[ - # semver 0 "12";; - - : int * int * int * string = (12, 0, 0, "");; - # semver 0 "12.3";; - - : int * int * int * string = (12, 3, 0, "");; - semver 0 "12.3.10";; - - : int * int * int * string = (12, 3, 10, "");; - # semver 0 "12.3.10+x";; - - : int * int * int * string = (12, 3, 10, "+x") - ]} -*) -let zero = Char.code '0' -let dot = Char.code '.' -let semantic_version_parse str start last_index = - let rec aux start acc last_index = - if start <= last_index then - let c = Char.code (String.unsafe_get str start) in - if c = dot then (acc, start + 1) (* consume [4.] instead of [4]*) - else - let v = c - zero in - if v >=0 && v <= 9 then - aux (start + 1) (acc * 10 + v) last_index - else (acc , start) - else (acc, start) - in - let major, major_end = aux start 0 last_index in - let minor, minor_end = aux major_end 0 last_index in - let patch, patch_end = aux minor_end 0 last_index in - let additional = String.sub str patch_end (last_index - patch_end +1) in - (major, minor, patch), additional - -(** - {[ - semver Location.none "1.2.3" "~1.3.0" = false;; - semver Location.none "1.2.3" "^1.3.0" = true ;; - semver Location.none "1.2.3" ">1.3.0" = false ;; - semver Location.none "1.2.3" ">=1.3.0" = false ;; - semver Location.none "1.2.3" "<1.3.0" = true ;; - semver Location.none "1.2.3" "<=1.3.0" = true ;; - ]} -*) -let semver loc lhs str = - let last_index = String.length str - 1 in - if last_index < 0 then raise (Error(Illegal_semver str, loc)) - else - let pred, ((major, minor, _patch) as version, _) = - let v = String.unsafe_get str 0 in - match v with - | '>' -> - if last_index = 0 then raise (Error(Illegal_semver str, loc)) else - if String.unsafe_get str 1 = '=' then - `Ge, semantic_version_parse str 2 last_index - else `Gt, semantic_version_parse str 1 last_index - | '<' - -> - if last_index = 0 then raise (Error(Illegal_semver str, loc)) else - if String.unsafe_get str 1 = '=' then - `Le, semantic_version_parse str 2 last_index - else `Lt, semantic_version_parse str 1 last_index - | '^' - -> `Compatible, semantic_version_parse str 1 last_index - | '~' -> `Approximate, semantic_version_parse str 1 last_index - | _ -> `Exact, semantic_version_parse str 0 last_index - in - let ((l_major, l_minor, _l_patch) as lversion,_) = - semantic_version_parse lhs 0 (String.length lhs - 1) in - match pred with - | `Ge -> lversion >= version - | `Gt -> lversion > version - | `Le -> lversion <= version - | `Lt -> lversion < version - | `Approximate -> major = l_major && minor = l_minor - | `Compatible -> major = l_major - | `Exact -> lversion = version - - -let pp_directive_value fmt (x : directive_value) = - match x with - | Dir_bool b -> Format.pp_print_bool fmt b - | Dir_int b -> Format.pp_print_int fmt b - | Dir_float b -> Format.pp_print_float fmt b - | Dir_string s -> Format.fprintf fmt "%S" s - | Dir_null -> Format.pp_print_string fmt "null" - -let list_variables fmt = - iter_directive_built_in_value - (fun s dir_value -> - Format.fprintf - fmt "@[%s@ %a@]@." - s pp_directive_value dir_value - ) - -let defined str = - begin match find_directive_built_in_value str with - | Dir_null -> false - | _ -> true - | exception _ -> - try ignore @@ Sys.getenv str; true with _ -> false - end - -let query _loc str = - begin match find_directive_built_in_value str with - | Dir_null -> Dir_bool false - | v -> v - | exception Not_found -> - begin match Sys.getenv str with - | v -> - begin - try Dir_bool (bool_of_string v) with - _ -> - begin - try Dir_int (int_of_string v ) - with - _ -> - begin try (Dir_float (float_of_string v)) - with _ -> Dir_string v - end - end - end - | exception Not_found -> - Dir_bool false - end - end - - -let define_key_value key v = - if String.length key > 0 - && Char.uppercase_ascii (key.[0]) = key.[0] then - begin - replace_directive_built_in_value key - begin - (* NEED Sync up across {!lexer.mll} {!bspp.ml} and here, - TODO: put it in {!lexer.mll} - *) - try Dir_bool (bool_of_string v) with - _ -> - begin - try Dir_int (int_of_string v ) - with - _ -> - begin try (Dir_float (float_of_string v)) - with _ -> Dir_string v - end - end - end; - true - end - else false - -let cvt_int_literal s = - - int_of_string ("-" ^ s) - -let value_of_token loc (t : Parser.token) = - match t with - | INT (i,None) -> Dir_int (cvt_int_literal i) - | STRING (s,_) -> Dir_string s - | FLOAT (s,None) -> Dir_float (float_of_string s) - | TRUE -> Dir_bool true - | FALSE -> Dir_bool false - | UIDENT s -> query loc s - | _ -> raise (Error (Unexpected_token_in_conditional, loc)) - - -let directive_parse token_with_comments lexbuf = - let look_ahead = ref None in - let token () : Parser.token = - let v = !look_ahead in - match v with - | Some v -> - look_ahead := None ; - v - | None -> - let rec skip () = - match token_with_comments lexbuf with - | COMMENT _ - | DOCSTRING _ - | EOL -> skip () - | EOF -> raise (Error (Unterminated_if, Location.curr lexbuf)) - | t -> t - in skip () - in - let push e = - (* INVARIANT: only look at most one token *) - assert (!look_ahead = None); - look_ahead := Some e - in - let rec - token_op calc ~no lhs = - match token () with - | (LESS - | GREATER - | INFIXOP0 "<=" - | INFIXOP0 ">=" - | EQUAL - | INFIXOP0 "<>" as op) -> - let f = - match op with - | LESS -> (<) - | GREATER -> (>) - | INFIXOP0 "<=" -> (<=) - | EQUAL -> (=) - | INFIXOP0 "<>" -> (<>) - | _ -> assert false - in - let curr_loc = Location.curr lexbuf in - let rhs = value_of_token curr_loc (token ()) in - not calc || - f lhs (assert_same_type lexbuf lhs rhs) - | INFIXOP0 "=~" -> - not calc || - begin match lhs with - | Dir_string s -> - let curr_loc = Location.curr lexbuf in - let rhs = value_of_token curr_loc (token ()) in - begin match rhs with - | Dir_string rhs -> - semver curr_loc s rhs - | _ -> - raise - (Error - ( Conditional_expr_expected_type - (Dir_type_string, type_of_directive lhs), Location.curr lexbuf)) - end - | _ -> raise - (Error - ( Conditional_expr_expected_type - (Dir_type_string, type_of_directive lhs), Location.curr lexbuf)) - end - | e -> no e - and - parse_or calc : bool = - parse_or_aux calc (parse_and calc) - and (* a || (b || (c || d))*) - parse_or_aux calc v : bool = - (* let l = v in *) - match token () with - | BARBAR -> - let b = parse_or (calc && not v) in - v || b - | e -> push e ; v - and parse_and calc = - parse_and_aux calc (parse_relation calc) - and parse_and_aux calc v = (* a && (b && (c && d)) *) - (* let l = v in *) - match token () with - | AMPERAMPER -> - let b = parse_and (calc && v) in - v && b - | e -> push e ; v - and parse_relation (calc : bool) : bool = - let curr_token = token () in - let curr_loc = Location.curr lexbuf in - match curr_token with - | TRUE -> true - | FALSE -> false - | UIDENT v -> - let value_v = query curr_loc v in - token_op calc - ~no:(fun e -> push e ; - match value_v with - | Dir_bool b -> b - | _ -> - let ty = type_of_directive value_v in - raise - (Error(Conditional_expr_expected_type (Dir_type_bool, ty), - curr_loc))) - value_v - | INT (v,None) -> - let num_v = cvt_int_literal v in - token_op calc - ~no:(fun e -> - push e; - num_v <> 0 - ) - (Dir_int num_v) - | FLOAT (v,None) -> - token_op calc - ~no:(fun _e -> - raise (Error(Conditional_expr_expected_type(Dir_type_bool, Dir_type_float), - curr_loc))) - (Dir_float (float_of_string v)) - | STRING (v,_) -> - token_op calc - ~no:(fun _e -> - raise (Error - (Conditional_expr_expected_type(Dir_type_bool, Dir_type_string), - curr_loc))) - (Dir_string v) - | LIDENT ("defined" | "undefined" as r) -> - let t = token () in - let loc = Location.curr lexbuf in - begin match t with - | UIDENT s -> - not calc || - if r.[0] = 'u' then - not @@ defined s - else defined s - | _ -> raise (Error (Unexpected_token_in_conditional, loc)) - end - | LPAREN -> - let v = parse_or calc in - begin match token () with - | RPAREN -> v - | _ -> raise (Error(Unterminated_paren_in_conditional, Location.curr lexbuf)) - end - - | _ -> raise (Error (Unexpected_token_in_conditional, curr_loc)) - in - let v = parse_or true in - begin match token () with - | THEN -> v - | _ -> raise (Error (Expect_hash_then_in_conditional, Location.curr lexbuf)) - end - - -type dir_conditional = - | Dir_if_true - | Dir_if_false - | Dir_out - -(* let string_of_dir_conditional (x : dir_conditional) = *) -(* match x with *) -(* | Dir_if_true -> "Dir_if_true" *) -(* | Dir_if_false -> "Dir_if_false" *) -(* | Dir_out -> "Dir_out" *) - -let is_elif (i : Parser.token ) = - match i with - | LIDENT "elif" -> true - | _ -> false (* avoid polymorphic equal *) - - -(* The table of keywords *) - -let keyword_table = - create_hashtable 149 [ - "and", AND; - "as", AS; - "assert", ASSERT; - "begin", BEGIN; - "class", CLASS; - "constraint", CONSTRAINT; - "do", DO; - "done", DONE; - "downto", DOWNTO; - "else", ELSE; - "end", END; - "exception", EXCEPTION; - "external", EXTERNAL; - "false", FALSE; - "for", FOR; - "fun", FUN; - "function", FUNCTION; - "functor", FUNCTOR; - "if", IF; - "in", IN; - "include", INCLUDE; - "inherit", INHERIT; - "initializer", INITIALIZER; - "lazy", LAZY; - "let", LET; - "match", MATCH; - "method", METHOD; - "module", MODULE; - "mutable", MUTABLE; - "new", NEW; - "nonrec", NONREC; - "object", OBJECT; - "of", OF; - "open", OPEN; - "or", OR; -(* "parser", PARSER; *) - "private", PRIVATE; - "rec", REC; - "sig", SIG; - "struct", STRUCT; - "then", THEN; - "to", TO; - "true", TRUE; - "try", TRY; - "type", TYPE; - "val", VAL; - "virtual", VIRTUAL; - "when", WHEN; - "while", WHILE; - "with", WITH; - - "lor", INFIXOP3("lor"); (* Should be INFIXOP2 *) - "lxor", INFIXOP3("lxor"); (* Should be INFIXOP2 *) - "mod", INFIXOP3("mod"); - "land", INFIXOP3("land"); - "lsl", INFIXOP4("lsl"); - "lsr", INFIXOP4("lsr"); - "asr", INFIXOP4("asr") -] - -(* To buffer string literals *) - -let string_buffer = Buffer.create 256 -let reset_string_buffer () = Buffer.reset string_buffer -let get_stored_string () = Buffer.contents string_buffer - -let store_string_char c = Buffer.add_char string_buffer c -let store_string_utf_8_uchar u = Buffer.add_utf_8_uchar string_buffer u -let store_string s = Buffer.add_string string_buffer s -let store_lexeme lexbuf = store_string (Lexing.lexeme lexbuf) - -(* To store the position of the beginning of a string and comment *) -let string_start_loc = ref Location.none;; -let comment_start_loc = ref [];; -let in_comment () = !comment_start_loc <> [];; -let is_in_string = ref false -let in_string () = !is_in_string -let print_warnings = ref true -let if_then_else = ref Dir_out -let sharp_look_ahead = ref None -let update_if_then_else v = - (* Format.fprintf Format.err_formatter "@[update %s \n@]@." (string_of_dir_conditional v); *) - if_then_else := v - -(* Escaped chars are interpreted in strings unless they are in comments. *) -let store_escaped_char lexbuf c = - if in_comment () then store_lexeme lexbuf else store_string_char c - -let store_escaped_uchar lexbuf u = - if in_comment () then store_lexeme lexbuf else store_string_utf_8_uchar u - -let with_comment_buffer comment lexbuf = - let start_loc = Location.curr lexbuf in - comment_start_loc := [start_loc]; - reset_string_buffer (); - let end_loc = comment lexbuf in - let s = get_stored_string () in - reset_string_buffer (); - let loc = { start_loc with Location.loc_end = end_loc.Location.loc_end } in - s, loc - -(* To translate escape sequences *) - -let hex_digit_value d = (* assert (d in '0'..'9' 'a'..'f' 'A'..'F') *) - let d = Char.code d in - if d >= 97 then d - 87 else - if d >= 65 then d - 55 else - d - 48 - -let hex_num_value lexbuf ~first ~last = - let rec loop acc i = match i > last with - | true -> acc - | false -> - let value = hex_digit_value (Lexing.lexeme_char lexbuf i) in - loop (16 * acc + value) (i + 1) - in - loop 0 first - -let char_for_backslash = function - | 'n' -> '\010' - | 'r' -> '\013' - | 'b' -> '\008' - | 't' -> '\009' - | c -> c - -let char_for_decimal_code lexbuf i = - let c = 100 * (Char.code(Lexing.lexeme_char lexbuf i) - 48) + - 10 * (Char.code(Lexing.lexeme_char lexbuf (i+1)) - 48) + - (Char.code(Lexing.lexeme_char lexbuf (i+2)) - 48) in - if (c < 0 || c > 255) then - if in_comment () - then 'x' - else raise (Error(Illegal_escape (Lexing.lexeme lexbuf), - Location.curr lexbuf)) - else Char.chr c - -let char_for_octal_code lexbuf i = - let c = 64 * (Char.code(Lexing.lexeme_char lexbuf i) - 48) + - 8 * (Char.code(Lexing.lexeme_char lexbuf (i+1)) - 48) + - (Char.code(Lexing.lexeme_char lexbuf (i+2)) - 48) in - Char.chr c - -let char_for_hexadecimal_code lexbuf i = - let byte = hex_num_value lexbuf ~first:i ~last:(i+1) in - Char.chr byte - -let uchar_for_uchar_escape lexbuf = - let err e = - raise - (Error (Illegal_escape (Lexing.lexeme lexbuf ^ e), Location.curr lexbuf)) - in - let len = Lexing.lexeme_end lexbuf - Lexing.lexeme_start lexbuf in - let first = 3 (* skip opening \u{ *) in - let last = len - 2 (* skip closing } *) in - let digit_count = last - first + 1 in - match digit_count > 6 with - | true -> err ", too many digits, expected 1 to 6 hexadecimal digits" - | false -> - let cp = hex_num_value lexbuf ~first ~last in - if Uchar.is_valid cp then Uchar.unsafe_of_int cp else - err (", " ^ Printf.sprintf "%X" cp ^ " is not a Unicode scalar value") - -(* recover the name from a LABEL or OPTLABEL token *) - -let get_label_name lexbuf = - let s = Lexing.lexeme lexbuf in - let name = String.sub s 1 (String.length s - 2) in - if Hashtbl.mem keyword_table name then - raise (Error(Keyword_as_label name, Location.curr lexbuf)); - name -;; - -(* Update the current location with file name and line number. *) - -let update_loc lexbuf file line absolute chars = - let pos = lexbuf.lex_curr_p in - let new_file = match file with - | None -> pos.pos_fname - | Some s -> s - in - lexbuf.lex_curr_p <- { pos with - pos_fname = new_file; - pos_lnum = if absolute then line else pos.pos_lnum + line; - pos_bol = pos.pos_cnum - chars; - } -;; - -let preprocessor = ref None - -let escaped_newlines = ref false - -(* Warn about Latin-1 characters used in idents *) - -let warn_latin1 lexbuf = - Location.deprecated (Location.curr lexbuf)"ISO-Latin1 characters in identifiers" - -let handle_docstrings = ref true -let comment_list = ref [] - -let add_comment com = - comment_list := com :: !comment_list - -let add_docstring_comment ds = - let com = - ("*" ^ Docstrings.docstring_body ds, Docstrings.docstring_loc ds) - in - add_comment com - -let comments () = List.rev !comment_list - -(* Error report *) - -open Format - -let report_error ppf = function - | Illegal_character c -> - fprintf ppf "Illegal character (%s)" (Char.escaped c) - | Illegal_escape s -> - fprintf ppf "Illegal backslash escape in string or character (%s)" s - | Unterminated_comment _ -> - fprintf ppf "Comment not terminated" - | Unterminated_string -> - fprintf ppf "String literal not terminated" - | Unterminated_string_in_comment (_, loc) -> - fprintf ppf "This comment contains an unterminated string literal@.\ - %aString literal begins here" - Location.print_error loc - | Keyword_as_label kwd -> - fprintf ppf "`%s' is a keyword, it cannot be used as label name" kwd - | Invalid_literal s -> - fprintf ppf "Invalid literal %s" s - | Invalid_directive (dir, explanation) -> - fprintf ppf "Invalid lexer directive %S" dir; - begin match explanation with - | None -> () - | Some expl -> fprintf ppf ": %s" expl - end - | Unterminated_if -> - fprintf ppf "#if not terminated" - | Unterminated_else -> - fprintf ppf "#else not terminated" - | Unexpected_directive -> fprintf ppf "Unexpected directive" - | Unexpected_token_in_conditional -> - fprintf ppf "Unexpected token in conditional predicate" - | Unterminated_paren_in_conditional -> - fprintf ppf "Unterminated parens in conditional predicate" - | Expect_hash_then_in_conditional -> - fprintf ppf "Expect `then` after conditional predicate" - | Conditional_expr_expected_type (a,b) -> - fprintf ppf "Conditional expression type mismatch (%s,%s)" - (string_of_type_directive a ) - (string_of_type_directive b ) - | Illegal_semver s -> - fprintf ppf "Illegal semantic version string %s" s - -let () = - Location.register_error_of_exn - (function - | Error (err, loc) -> - Some (Location.error_of_printer loc report_error err) - | _ -> - None - ) - - -# 717 "parsing/lexer.ml" -let __ocaml_lex_tables = { - Lexing.lex_base = - "\000\000\162\255\163\255\224\000\003\001\038\001\073\001\108\001\ - \143\001\186\255\178\001\215\001\194\255\091\000\252\001\031\002\ - \068\000\071\000\065\002\100\002\212\255\214\255\217\255\135\002\ - \230\002\009\003\088\000\255\000\039\003\236\255\123\003\207\003\ - \035\004\243\004\195\005\147\006\114\007\206\007\158\008\122\000\ - \254\255\001\000\005\000\255\255\006\000\007\000\125\009\155\009\ - \107\010\250\255\249\255\059\011\011\012\247\255\246\255\219\012\ - \047\013\131\013\215\013\043\014\127\014\211\014\039\015\123\015\ - \207\015\035\016\087\000\119\016\203\016\031\017\115\017\199\017\ - \108\000\192\255\235\255\007\003\034\018\106\000\107\000\011\000\ - \234\255\233\255\228\255\152\002\099\000\118\000\113\000\232\255\ - \128\000\147\000\231\255\224\000\003\001\148\000\230\255\110\004\ - \149\000\229\255\148\000\224\255\217\000\223\255\222\000\034\018\ - \222\255\073\018\101\005\009\003\221\255\012\000\014\001\080\001\ - \115\001\024\001\221\255\013\000\119\018\158\018\193\018\231\018\ - \010\019\209\255\204\255\205\255\206\255\202\255\045\019\154\000\ - \183\000\195\255\196\255\197\255\217\000\182\255\180\255\189\255\ - \080\019\185\255\187\255\115\019\150\019\185\019\220\019\130\005\ - \243\255\244\255\017\000\245\255\174\001\223\005\253\255\248\000\ - \249\000\255\255\254\255\252\255\005\006\238\019\003\001\004\001\ - \018\000\251\255\250\255\249\255\222\006\026\003\005\001\248\255\ - \036\003\008\001\247\255\066\008\020\001\246\255\059\001\234\001\ - \245\255\246\255\247\255\060\001\055\020\255\255\248\255\193\000\ - \233\008\038\001\133\004\253\255\073\001\094\001\113\001\143\004\ - \252\255\192\002\027\004\251\255\230\009\250\255\182\010\089\020\ - \249\255\129\001\130\001\252\255\085\007\254\255\255\255\146\001\ - \147\001\253\255\177\007\033\001\044\001\148\001\151\001\045\001\ - \153\001\044\001\019\000\255\255"; - Lexing.lex_backtrk = - "\255\255\255\255\255\255\090\000\089\000\086\000\085\000\078\000\ - \076\000\255\255\067\000\064\000\255\255\057\000\056\000\054\000\ - \052\000\048\000\045\000\081\000\255\255\255\255\255\255\036\000\ - \035\000\042\000\040\000\039\000\062\000\255\255\014\000\014\000\ - \013\000\012\000\011\000\010\000\007\000\004\000\003\000\002\000\ - \255\255\093\000\093\000\255\255\255\255\255\255\084\000\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\018\000\ - \018\000\016\000\015\000\018\000\015\000\015\000\014\000\016\000\ - \015\000\016\000\255\255\017\000\017\000\014\000\014\000\016\000\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\027\000\027\000\027\000\027\000\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\028\000\255\255\029\000\255\255\030\000\088\000\ - \255\255\091\000\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\037\000\087\000\082\000\044\000\ - \047\000\255\255\255\255\255\255\255\255\255\255\055\000\074\000\ - \071\000\255\255\255\255\255\255\072\000\255\255\255\255\255\255\ - \065\000\255\255\255\255\083\000\077\000\080\000\079\000\255\255\ - \255\255\255\255\012\000\255\255\012\000\012\000\255\255\012\000\ - \012\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\010\000\010\000\255\255\255\255\007\000\ - \007\000\007\000\007\000\255\255\001\000\007\000\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\003\000\255\255\255\255\003\000\ - \255\255\255\255\255\255\002\000\255\255\255\255\001\000\255\255\ - \255\255\255\255\255\255\255\255"; - Lexing.lex_default = - "\001\000\000\000\000\000\255\255\255\255\255\255\255\255\255\255\ - \255\255\000\000\255\255\255\255\000\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\000\000\000\000\000\000\255\255\ - \255\255\255\255\255\255\077\000\255\255\000\000\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \000\000\255\255\255\255\000\000\255\255\255\255\255\255\255\255\ - \255\255\000\000\000\000\255\255\255\255\000\000\000\000\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\000\000\000\000\255\255\082\000\255\255\255\255\255\255\ - \000\000\000\000\000\000\255\255\255\255\255\255\255\255\000\000\ - \255\255\255\255\000\000\255\255\255\255\255\255\000\000\255\255\ - \255\255\000\000\255\255\000\000\255\255\000\000\255\255\255\255\ - \000\000\255\255\110\000\255\255\000\000\255\255\110\000\111\000\ - \110\000\113\000\000\000\255\255\255\255\255\255\255\255\255\255\ - \255\255\000\000\000\000\000\000\000\000\000\000\255\255\255\255\ - \255\255\000\000\000\000\000\000\255\255\000\000\000\000\000\000\ - \255\255\000\000\000\000\255\255\255\255\255\255\255\255\144\000\ - \000\000\000\000\255\255\000\000\158\000\255\255\000\000\255\255\ - \255\255\000\000\000\000\000\000\255\255\255\255\255\255\255\255\ - \255\255\000\000\000\000\000\000\255\255\255\255\255\255\000\000\ - \255\255\255\255\000\000\255\255\255\255\000\000\255\255\176\000\ - \000\000\000\000\000\000\255\255\182\000\000\000\000\000\255\255\ - \255\255\255\255\255\255\000\000\255\255\255\255\255\255\255\255\ - \000\000\255\255\255\255\000\000\255\255\000\000\255\255\255\255\ - \000\000\255\255\203\000\000\000\255\255\000\000\000\000\255\255\ - \255\255\000\000\255\255\255\255\255\255\213\000\216\000\255\255\ - \216\000\255\255\255\255\000\000"; - Lexing.lex_trans = - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\039\000\040\000\040\000\039\000\041\000\045\000\043\000\ - \043\000\040\000\044\000\044\000\045\000\078\000\108\000\114\000\ - \079\000\109\000\115\000\145\000\159\000\219\000\174\000\160\000\ - \039\000\008\000\029\000\024\000\006\000\004\000\023\000\027\000\ - \026\000\021\000\025\000\007\000\020\000\019\000\018\000\003\000\ - \031\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ - \030\000\030\000\017\000\016\000\015\000\014\000\010\000\036\000\ - \005\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\013\000\042\000\012\000\005\000\038\000\ - \022\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\028\000\011\000\009\000\037\000\125\000\ - \127\000\124\000\098\000\039\000\123\000\122\000\039\000\065\000\ - \065\000\065\000\065\000\065\000\065\000\065\000\065\000\065\000\ - \065\000\081\000\080\000\091\000\091\000\091\000\091\000\130\000\ - \087\000\129\000\039\000\128\000\071\000\071\000\071\000\071\000\ - \071\000\071\000\071\000\071\000\071\000\071\000\088\000\088\000\ - \088\000\088\000\088\000\088\000\088\000\088\000\088\000\088\000\ - \089\000\089\000\089\000\089\000\089\000\089\000\089\000\089\000\ - \089\000\089\000\090\000\094\000\097\000\099\000\100\000\134\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\131\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\132\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \002\000\003\000\101\000\102\000\003\000\003\000\003\000\101\000\ - \102\000\078\000\003\000\003\000\079\000\003\000\003\000\003\000\ - \092\000\092\000\092\000\092\000\092\000\092\000\092\000\092\000\ - \108\000\133\000\003\000\109\000\003\000\003\000\003\000\003\000\ - \003\000\154\000\114\000\153\000\003\000\115\000\255\255\003\000\ - \003\000\003\000\163\000\162\000\167\000\003\000\003\000\170\000\ - \003\000\003\000\003\000\093\000\093\000\093\000\093\000\093\000\ - \093\000\093\000\093\000\173\000\198\000\003\000\003\000\003\000\ - \003\000\003\000\003\000\003\000\212\000\145\000\178\000\005\000\ - \174\000\201\000\005\000\005\000\005\000\213\000\217\000\218\000\ - \005\000\005\000\188\000\005\000\005\000\005\000\193\000\193\000\ - \193\000\193\000\108\000\076\000\003\000\109\000\003\000\000\000\ - \005\000\003\000\005\000\005\000\005\000\005\000\005\000\000\000\ - \188\000\188\000\006\000\190\000\000\000\006\000\006\000\006\000\ - \000\000\000\000\113\000\006\000\006\000\000\000\006\000\006\000\ - \006\000\000\000\000\000\188\000\112\000\108\000\190\000\003\000\ - \109\000\003\000\000\000\006\000\005\000\006\000\006\000\006\000\ - \006\000\006\000\000\000\178\000\206\000\117\000\201\000\207\000\ - \117\000\117\000\117\000\112\000\000\000\111\000\117\000\117\000\ - \000\000\117\000\142\000\117\000\206\000\206\000\214\000\208\000\ - \208\000\215\000\005\000\215\000\005\000\000\000\117\000\006\000\ - \117\000\141\000\117\000\117\000\117\000\000\000\000\000\000\000\ - \139\000\000\000\000\000\139\000\139\000\139\000\000\000\000\000\ - \159\000\139\000\139\000\160\000\139\000\139\000\139\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\006\000\000\000\006\000\ - \000\000\139\000\117\000\139\000\140\000\139\000\139\000\139\000\ - \000\000\000\000\000\000\006\000\000\000\161\000\006\000\006\000\ - \006\000\000\000\000\000\000\000\006\000\006\000\000\000\006\000\ - \006\000\006\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \117\000\000\000\117\000\000\000\006\000\139\000\006\000\006\000\ - \006\000\006\000\006\000\000\000\178\000\000\000\000\000\179\000\ - \006\000\000\000\000\000\006\000\006\000\006\000\204\000\255\255\ - \000\000\006\000\006\000\000\000\006\000\006\000\006\000\000\000\ - \000\000\000\000\157\000\139\000\181\000\139\000\255\255\138\000\ - \006\000\006\000\000\000\006\000\006\000\006\000\006\000\006\000\ - \255\255\000\000\000\000\000\000\000\000\006\000\000\000\000\000\ - \006\000\006\000\006\000\000\000\000\000\000\000\006\000\006\000\ - \000\000\006\000\006\000\006\000\000\000\000\000\006\000\137\000\ - \006\000\000\000\000\000\000\000\135\000\006\000\006\000\000\000\ - \006\000\006\000\006\000\006\000\006\000\000\000\000\000\000\000\ - \006\000\000\000\000\000\006\000\006\000\006\000\180\000\000\000\ - \000\000\006\000\006\000\000\000\126\000\006\000\006\000\000\000\ - \255\255\000\000\000\000\136\000\000\000\006\000\000\000\000\000\ - \000\000\006\000\006\000\006\000\006\000\006\000\006\000\006\000\ - \000\000\000\000\120\000\000\000\000\000\120\000\120\000\120\000\ - \000\000\000\000\000\000\120\000\120\000\000\000\120\000\121\000\ - \120\000\000\000\000\000\255\255\000\000\000\000\000\000\000\000\ - \006\000\000\000\006\000\120\000\000\000\006\000\120\000\120\000\ - \120\000\120\000\205\000\000\000\000\000\117\000\000\000\000\000\ - \117\000\117\000\117\000\000\000\000\000\000\000\117\000\117\000\ - \000\000\117\000\118\000\117\000\255\255\000\000\000\000\255\255\ - \000\000\255\255\000\000\006\000\000\000\006\000\117\000\120\000\ - \117\000\117\000\119\000\117\000\117\000\000\000\000\000\000\000\ - \006\000\000\000\000\000\006\000\006\000\116\000\255\255\000\000\ - \000\000\006\000\006\000\000\000\006\000\006\000\006\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\120\000\000\000\120\000\ - \000\000\006\000\117\000\006\000\006\000\006\000\006\000\006\000\ - \095\000\095\000\095\000\095\000\095\000\095\000\095\000\095\000\ - \095\000\095\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\095\000\095\000\095\000\095\000\095\000\095\000\000\000\ - \117\000\000\000\117\000\000\000\000\000\006\000\000\000\000\000\ - \000\000\000\000\177\000\000\000\000\000\000\000\000\000\107\000\ - \194\000\194\000\194\000\194\000\194\000\194\000\194\000\194\000\ - \000\000\095\000\095\000\095\000\095\000\095\000\095\000\000\000\ - \000\000\000\000\000\000\006\000\000\000\006\000\107\000\105\000\ - \000\000\105\000\105\000\105\000\105\000\000\000\000\000\000\000\ - \105\000\105\000\107\000\105\000\105\000\105\000\106\000\106\000\ - \106\000\106\000\106\000\106\000\106\000\106\000\106\000\106\000\ - \105\000\000\000\105\000\105\000\105\000\105\000\105\000\000\000\ - \000\000\107\000\003\000\000\000\000\000\003\000\003\000\003\000\ - \000\000\000\000\104\000\103\000\003\000\000\000\003\000\003\000\ - \003\000\106\000\106\000\106\000\106\000\106\000\106\000\106\000\ - \106\000\106\000\106\000\003\000\105\000\003\000\003\000\003\000\ - \003\000\003\000\168\000\168\000\168\000\168\000\168\000\168\000\ - \168\000\168\000\168\000\168\000\169\000\169\000\169\000\169\000\ - \169\000\169\000\169\000\169\000\169\000\169\000\000\000\000\000\ - \000\000\000\000\105\000\073\000\105\000\000\000\075\000\003\000\ - \075\000\075\000\075\000\075\000\075\000\075\000\075\000\075\000\ - \075\000\075\000\075\000\075\000\075\000\075\000\075\000\075\000\ - \075\000\075\000\075\000\075\000\075\000\075\000\075\000\075\000\ - \075\000\075\000\000\000\074\000\000\000\003\000\075\000\003\000\ - \075\000\075\000\075\000\075\000\075\000\075\000\075\000\075\000\ - \075\000\075\000\075\000\075\000\075\000\075\000\075\000\075\000\ - \075\000\075\000\075\000\075\000\075\000\075\000\075\000\075\000\ - \075\000\075\000\055\000\074\000\000\000\000\000\000\000\000\000\ - \000\000\057\000\000\000\030\000\030\000\030\000\030\000\030\000\ - \030\000\030\000\030\000\030\000\030\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\055\000\055\000\055\000\055\000\ - \056\000\055\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\000\000\000\000\ - \000\000\000\000\030\000\000\000\055\000\055\000\055\000\055\000\ - \056\000\055\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\055\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\057\000\000\000\030\000\ - \030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ - \030\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \055\000\059\000\055\000\055\000\056\000\055\000\058\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\060\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\061\000\ - \058\000\058\000\000\000\000\000\000\000\000\000\030\000\000\000\ - \055\000\059\000\055\000\055\000\056\000\055\000\058\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\060\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\061\000\ - \058\000\058\000\032\000\195\000\195\000\195\000\195\000\195\000\ - \195\000\195\000\195\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\000\000\000\000\ - \000\000\000\000\032\000\000\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\096\000\096\000\ - \096\000\096\000\096\000\096\000\096\000\096\000\096\000\096\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\096\000\ - \096\000\096\000\096\000\096\000\096\000\191\000\191\000\191\000\ - \191\000\191\000\191\000\191\000\191\000\191\000\191\000\192\000\ - \192\000\192\000\192\000\192\000\192\000\192\000\192\000\192\000\ - \192\000\000\000\000\000\000\000\000\000\000\000\000\000\096\000\ - \096\000\096\000\096\000\096\000\096\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\000\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\033\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\033\000\000\000\000\000\ - \000\000\000\000\033\000\000\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\033\000\112\000\108\000\ - \000\000\000\000\109\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\112\000\000\000\111\000\ - \000\000\000\000\000\000\000\000\145\000\000\000\000\000\146\000\ - \000\000\000\000\000\000\000\000\000\000\106\000\106\000\106\000\ - \106\000\106\000\106\000\106\000\106\000\106\000\106\000\000\000\ - \000\000\000\000\000\000\000\000\150\000\000\000\000\000\000\000\ - \000\000\148\000\152\000\000\000\151\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\000\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\034\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\149\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\000\000\000\000\ - \000\000\000\000\034\000\000\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\156\000\000\000\ - \156\000\156\000\156\000\156\000\156\000\156\000\156\000\156\000\ - \156\000\156\000\156\000\156\000\156\000\156\000\156\000\156\000\ - \156\000\156\000\156\000\156\000\156\000\156\000\156\000\156\000\ - \156\000\156\000\000\000\155\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\156\000\255\255\156\000\156\000\ - \156\000\156\000\156\000\156\000\156\000\156\000\156\000\156\000\ - \156\000\156\000\156\000\156\000\156\000\156\000\156\000\156\000\ - \156\000\156\000\156\000\156\000\156\000\156\000\156\000\156\000\ - \000\000\155\000\147\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\000\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\035\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\000\000\000\000\ - \000\000\000\000\035\000\000\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\171\000\171\000\ - \171\000\171\000\171\000\171\000\171\000\171\000\171\000\171\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\171\000\ - \171\000\171\000\171\000\171\000\171\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\171\000\ - \171\000\171\000\171\000\171\000\171\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\000\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\000\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\046\000\000\000\000\000\046\000\046\000\ - \046\000\000\000\000\000\000\000\046\000\046\000\000\000\046\000\ - \046\000\046\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\046\000\000\000\046\000\046\000\ - \046\000\046\000\046\000\000\000\210\000\000\000\210\000\210\000\ - \210\000\210\000\210\000\210\000\210\000\210\000\210\000\210\000\ - \210\000\210\000\210\000\210\000\210\000\210\000\210\000\210\000\ - \210\000\210\000\210\000\210\000\210\000\210\000\210\000\210\000\ - \046\000\052\000\209\000\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\000\000\046\000\046\000\ - \046\000\000\000\046\000\046\000\046\000\000\000\000\000\000\000\ - \046\000\046\000\000\000\046\000\046\000\046\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \046\000\000\000\046\000\046\000\046\000\046\000\046\000\000\000\ - \210\000\000\000\210\000\210\000\210\000\210\000\210\000\210\000\ - \210\000\210\000\210\000\210\000\210\000\210\000\210\000\210\000\ - \210\000\210\000\210\000\210\000\210\000\210\000\210\000\210\000\ - \210\000\210\000\210\000\210\000\046\000\048\000\209\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ - \048\000\000\000\046\000\000\000\046\000\000\000\000\000\000\000\ - \000\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\000\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\172\000\172\000\172\000\172\000\172\000\172\000\ - \172\000\172\000\172\000\172\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\172\000\172\000\172\000\172\000\172\000\ - \172\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\172\000\172\000\172\000\172\000\172\000\ - \172\000\000\000\000\000\000\000\000\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\035\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\000\000\000\000\000\000\000\000\035\000\000\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\196\000\196\000\196\000\196\000\196\000\196\000\196\000\ - \196\000\196\000\196\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\196\000\196\000\196\000\196\000\196\000\196\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\196\000\196\000\196\000\196\000\196\000\196\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\000\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\000\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\046\000\000\000\ - \000\000\046\000\046\000\046\000\000\000\000\000\000\000\046\000\ - \046\000\000\000\046\000\046\000\046\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\046\000\ - \000\000\046\000\046\000\046\000\046\000\046\000\000\000\000\000\ - \000\000\000\000\047\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\050\000\000\000\000\000\ - \000\000\000\000\000\000\046\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\000\000\000\000\ - \000\000\046\000\047\000\046\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\197\000\197\000\ - \197\000\197\000\197\000\197\000\197\000\197\000\197\000\197\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\197\000\ - \197\000\197\000\197\000\197\000\197\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\197\000\ - \197\000\197\000\197\000\197\000\197\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\000\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\048\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\048\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\049\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\000\000\000\000\ - \000\000\000\000\048\000\000\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\199\000\199\000\ - \199\000\199\000\199\000\199\000\199\000\199\000\199\000\199\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\199\000\ - \199\000\199\000\199\000\199\000\199\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\199\000\ - \199\000\199\000\199\000\199\000\199\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\000\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\051\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\054\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\000\000\000\000\ - \000\000\000\000\051\000\000\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\000\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\052\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\053\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\052\000\000\000\000\000\ - \000\000\000\000\052\000\000\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\052\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\000\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\055\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\000\000\000\000\ - \000\000\000\000\055\000\000\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\000\000\ - \000\000\000\000\072\000\000\000\072\000\000\000\000\000\071\000\ - \071\000\071\000\071\000\071\000\071\000\071\000\071\000\071\000\ - \071\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\000\000\000\000\000\000\000\000\055\000\000\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\057\000\057\000\057\000\057\000\057\000\ - \057\000\057\000\057\000\057\000\057\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\055\000\055\000\055\000\055\000\ - \056\000\055\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\067\000\067\000\067\000\067\000\000\000\000\000\ - \000\000\000\000\057\000\000\000\055\000\055\000\055\000\055\000\ - \056\000\055\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\067\000\067\000\067\000\067\000\055\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\000\000\000\000\000\000\000\000\055\000\000\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\070\000\070\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\000\000\000\000\ - \000\000\000\000\055\000\000\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\069\000\ - \069\000\069\000\069\000\069\000\069\000\069\000\069\000\055\000\ - \055\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\000\000\000\000\000\000\000\000\055\000\000\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\062\000\062\000\062\000\062\000\062\000\ - \062\000\062\000\062\000\062\000\062\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\062\000\062\000\062\000\062\000\ - \062\000\062\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\000\000\000\000\ - \000\000\000\000\055\000\000\000\062\000\062\000\062\000\062\000\ - \062\000\062\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\063\000\000\000\062\000\ - \062\000\062\000\062\000\062\000\062\000\062\000\062\000\062\000\ - \062\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \062\000\062\000\062\000\062\000\062\000\062\000\058\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\064\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\058\000\000\000\000\000\000\000\000\000\062\000\000\000\ - \062\000\062\000\062\000\062\000\062\000\062\000\058\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\064\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\058\000\055\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\063\000\063\000\063\000\063\000\063\000\ - \063\000\063\000\063\000\063\000\063\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\063\000\063\000\063\000\063\000\ - \063\000\063\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\067\000\068\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\067\000\067\000\067\000\067\000\000\000\000\000\ - \000\000\000\000\063\000\000\000\063\000\063\000\063\000\063\000\ - \063\000\063\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\067\000\068\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\067\000\067\000\067\000\067\000\055\000\000\000\ - \000\000\000\000\066\000\000\000\066\000\000\000\000\000\065\000\ - \065\000\065\000\065\000\065\000\065\000\065\000\065\000\065\000\ - \065\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\000\000\000\000\000\000\000\000\055\000\000\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\065\000\065\000\065\000\065\000\065\000\ - \065\000\065\000\065\000\065\000\065\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\067\000\067\000\067\000\067\000\000\000\000\000\ - \000\000\000\000\065\000\000\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\067\000\067\000\067\000\067\000\055\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\000\000\000\000\000\000\000\000\055\000\000\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\000\000\000\000\000\000\066\000\000\000\ - \066\000\000\000\000\000\065\000\065\000\065\000\065\000\065\000\ - \065\000\065\000\065\000\065\000\065\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\000\000\000\000\ - \000\000\000\000\055\000\000\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\069\000\ - \069\000\069\000\069\000\069\000\069\000\069\000\069\000\055\000\ - \055\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\058\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\058\000\000\000\000\000\000\000\000\000\069\000\000\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\058\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\058\000\055\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\070\000\070\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\000\000\000\000\ - \000\000\000\000\070\000\000\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\055\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\071\000\ - \071\000\071\000\071\000\071\000\071\000\071\000\071\000\071\000\ - \071\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\067\000\067\000\ - \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\000\000\000\000\000\000\000\000\071\000\000\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\067\000\067\000\ - \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\086\000\103\000\086\000\000\000\103\000\103\000\ - \103\000\086\000\000\000\000\000\103\000\103\000\000\000\103\000\ - \103\000\103\000\085\000\085\000\085\000\085\000\085\000\085\000\ - \085\000\085\000\085\000\085\000\103\000\000\000\103\000\103\000\ - \103\000\103\000\103\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\105\000\000\000\105\000\105\000\105\000\105\000\ - \000\000\000\000\000\000\105\000\105\000\000\000\105\000\105\000\ - \105\000\000\000\000\000\000\000\000\000\000\000\086\000\000\000\ - \103\000\000\000\000\000\105\000\086\000\105\000\105\000\105\000\ - \105\000\105\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \086\000\084\000\000\000\000\000\086\000\000\000\086\000\000\000\ - \006\000\000\000\083\000\006\000\006\000\006\000\103\000\000\000\ - \103\000\006\000\006\000\000\000\006\000\006\000\006\000\105\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\006\000\000\000\006\000\006\000\006\000\006\000\006\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\117\000\ - \000\000\000\000\117\000\117\000\117\000\105\000\000\000\105\000\ - \117\000\117\000\000\000\117\000\117\000\117\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\006\000\000\000\000\000\ - \117\000\000\000\117\000\117\000\117\000\117\000\117\000\000\000\ - \000\000\000\000\117\000\000\000\000\000\117\000\117\000\117\000\ - \000\000\000\000\000\000\117\000\117\000\000\000\117\000\117\000\ - \117\000\000\000\000\000\006\000\000\000\006\000\000\000\000\000\ - \000\000\000\000\000\000\117\000\117\000\117\000\117\000\117\000\ - \117\000\117\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \117\000\000\000\000\000\117\000\117\000\117\000\000\000\000\000\ - \000\000\117\000\117\000\000\000\117\000\117\000\117\000\000\000\ - \000\000\000\000\117\000\000\000\117\000\000\000\000\000\117\000\ - \000\000\117\000\255\255\117\000\117\000\117\000\117\000\117\000\ - \000\000\000\000\000\000\120\000\000\000\000\000\120\000\120\000\ - \120\000\000\000\000\000\000\000\120\000\120\000\000\000\120\000\ - \120\000\120\000\000\000\000\000\000\000\117\000\000\000\117\000\ - \000\000\000\000\000\000\000\000\120\000\117\000\120\000\120\000\ - \120\000\120\000\120\000\000\000\000\000\000\000\006\000\000\000\ - \000\000\006\000\006\000\006\000\000\000\000\000\000\000\006\000\ - \006\000\000\000\006\000\006\000\006\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\117\000\000\000\117\000\000\000\006\000\ - \120\000\006\000\006\000\006\000\006\000\006\000\000\000\000\000\ - \000\000\006\000\000\000\000\000\006\000\006\000\006\000\000\000\ - \000\000\000\000\006\000\006\000\000\000\006\000\006\000\006\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\120\000\000\000\ - \120\000\000\000\006\000\006\000\006\000\006\000\006\000\006\000\ - \006\000\000\000\000\000\000\000\139\000\000\000\000\000\139\000\ - \139\000\139\000\000\000\000\000\000\000\139\000\139\000\000\000\ - \139\000\139\000\139\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\006\000\000\000\006\000\000\000\139\000\006\000\139\000\ - \139\000\139\000\139\000\139\000\000\000\000\000\000\000\139\000\ - \000\000\000\000\139\000\139\000\139\000\000\000\000\000\000\000\ - \139\000\139\000\000\000\139\000\139\000\139\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\006\000\000\000\006\000\000\000\ - \139\000\139\000\139\000\139\000\139\000\139\000\139\000\000\000\ - \000\000\000\000\117\000\000\000\000\000\117\000\117\000\117\000\ - \000\000\000\000\000\000\117\000\117\000\000\000\117\000\117\000\ - \117\000\000\000\000\000\000\000\000\000\000\000\000\000\139\000\ - \000\000\139\000\000\000\117\000\139\000\117\000\117\000\117\000\ - \117\000\117\000\000\000\000\000\000\000\117\000\000\000\000\000\ - \117\000\117\000\117\000\000\000\000\000\000\000\117\000\117\000\ - \000\000\117\000\117\000\117\000\000\000\000\000\166\000\000\000\ - \166\000\000\000\139\000\000\000\139\000\166\000\117\000\117\000\ - \117\000\117\000\117\000\117\000\117\000\000\000\165\000\165\000\ - \165\000\165\000\165\000\165\000\165\000\165\000\165\000\165\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\117\000\000\000\117\000\ - \000\000\000\000\117\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\188\000\000\000\000\000\189\000\000\000\000\000\000\000\ - \000\000\000\000\166\000\000\000\000\000\000\000\000\000\000\000\ - \166\000\000\000\000\000\000\000\000\000\000\000\000\000\187\000\ - \117\000\187\000\117\000\000\000\166\000\000\000\187\000\000\000\ - \166\000\000\000\166\000\000\000\000\000\000\000\164\000\186\000\ - \186\000\186\000\186\000\186\000\186\000\186\000\186\000\186\000\ - \186\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\199\000\199\000\199\000\199\000\199\000\199\000\199\000\ - \199\000\199\000\199\000\187\000\000\000\000\000\000\000\000\000\ - \000\000\187\000\199\000\199\000\199\000\199\000\199\000\199\000\ - \000\000\000\000\000\000\000\000\000\000\187\000\185\000\000\000\ - \000\000\187\000\000\000\187\000\183\000\000\000\000\000\184\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\199\000\199\000\199\000\199\000\199\000\199\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\200\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\255\255\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000"; - Lexing.lex_check = - "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\000\000\000\000\041\000\000\000\000\000\041\000\042\000\ - \044\000\045\000\042\000\044\000\045\000\079\000\109\000\115\000\ - \079\000\109\000\115\000\146\000\160\000\218\000\146\000\160\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\016\000\ - \013\000\017\000\026\000\039\000\017\000\017\000\039\000\066\000\ - \066\000\066\000\066\000\066\000\066\000\066\000\066\000\066\000\ - \066\000\077\000\078\000\084\000\084\000\084\000\084\000\013\000\ - \086\000\013\000\039\000\013\000\072\000\072\000\072\000\072\000\ - \072\000\072\000\072\000\072\000\072\000\072\000\085\000\085\000\ - \085\000\085\000\085\000\085\000\085\000\085\000\085\000\085\000\ - \088\000\088\000\088\000\088\000\088\000\088\000\088\000\088\000\ - \088\000\088\000\089\000\093\000\096\000\098\000\098\000\127\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\013\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\003\000\100\000\100\000\003\000\003\000\003\000\102\000\ - \102\000\027\000\003\000\003\000\027\000\003\000\003\000\003\000\ - \091\000\091\000\091\000\091\000\091\000\091\000\091\000\091\000\ - \110\000\132\000\003\000\110\000\003\000\003\000\003\000\003\000\ - \003\000\151\000\113\000\152\000\004\000\113\000\027\000\004\000\ - \004\000\004\000\158\000\159\000\166\000\004\000\004\000\169\000\ - \004\000\004\000\004\000\092\000\092\000\092\000\092\000\092\000\ - \092\000\092\000\092\000\172\000\183\000\004\000\003\000\004\000\ - \004\000\004\000\004\000\004\000\211\000\174\000\179\000\005\000\ - \174\000\179\000\005\000\005\000\005\000\212\000\215\000\217\000\ - \005\000\005\000\188\000\005\000\005\000\005\000\185\000\185\000\ - \185\000\185\000\111\000\027\000\003\000\111\000\003\000\255\255\ - \005\000\004\000\005\000\005\000\005\000\005\000\005\000\255\255\ - \189\000\188\000\006\000\189\000\255\255\006\000\006\000\006\000\ - \255\255\255\255\111\000\006\000\006\000\255\255\006\000\006\000\ - \006\000\255\255\255\255\190\000\112\000\112\000\190\000\004\000\ - \112\000\004\000\255\255\006\000\005\000\006\000\006\000\006\000\ - \006\000\006\000\255\255\201\000\202\000\007\000\201\000\202\000\ - \007\000\007\000\007\000\112\000\255\255\112\000\007\000\007\000\ - \255\255\007\000\007\000\007\000\207\000\208\000\213\000\207\000\ - \208\000\214\000\005\000\216\000\005\000\255\255\007\000\006\000\ - \007\000\007\000\007\000\007\000\007\000\255\255\255\255\255\255\ - \008\000\255\255\255\255\008\000\008\000\008\000\255\255\255\255\ - \148\000\008\000\008\000\148\000\008\000\008\000\008\000\255\255\ - \255\255\255\255\255\255\255\255\255\255\006\000\255\255\006\000\ - \255\255\008\000\007\000\008\000\008\000\008\000\008\000\008\000\ - \255\255\255\255\255\255\010\000\255\255\148\000\010\000\010\000\ - \010\000\255\255\255\255\255\255\010\000\010\000\255\255\010\000\ - \010\000\010\000\255\255\255\255\255\255\255\255\255\255\255\255\ - \007\000\255\255\007\000\255\255\010\000\008\000\010\000\010\000\ - \010\000\010\000\010\000\255\255\175\000\255\255\255\255\175\000\ - \011\000\255\255\255\255\011\000\011\000\011\000\202\000\027\000\ - \255\255\011\000\011\000\255\255\011\000\011\000\011\000\255\255\ - \255\255\255\255\148\000\008\000\175\000\008\000\110\000\010\000\ - \010\000\011\000\255\255\011\000\011\000\011\000\011\000\011\000\ - \113\000\255\255\255\255\255\255\255\255\014\000\255\255\255\255\ - \014\000\014\000\014\000\255\255\255\255\255\255\014\000\014\000\ - \255\255\014\000\014\000\014\000\255\255\255\255\010\000\010\000\ - \010\000\255\255\255\255\255\255\011\000\011\000\014\000\255\255\ - \014\000\014\000\014\000\014\000\014\000\255\255\255\255\255\255\ - \015\000\255\255\255\255\015\000\015\000\015\000\175\000\255\255\ - \255\255\015\000\015\000\255\255\015\000\015\000\015\000\255\255\ - \111\000\255\255\255\255\011\000\255\255\011\000\255\255\255\255\ - \255\255\015\000\014\000\015\000\015\000\015\000\015\000\015\000\ - \255\255\255\255\018\000\255\255\255\255\018\000\018\000\018\000\ - \255\255\255\255\255\255\018\000\018\000\255\255\018\000\018\000\ - \018\000\255\255\255\255\112\000\255\255\255\255\255\255\255\255\ - \014\000\255\255\014\000\018\000\255\255\015\000\018\000\018\000\ - \018\000\018\000\202\000\255\255\255\255\019\000\255\255\255\255\ - \019\000\019\000\019\000\255\255\255\255\255\255\019\000\019\000\ - \255\255\019\000\019\000\019\000\213\000\255\255\255\255\214\000\ - \255\255\216\000\255\255\015\000\255\255\015\000\019\000\018\000\ - \019\000\019\000\019\000\019\000\019\000\255\255\255\255\255\255\ - \023\000\255\255\255\255\023\000\023\000\023\000\148\000\255\255\ - \255\255\023\000\023\000\255\255\023\000\023\000\023\000\255\255\ - \255\255\255\255\255\255\255\255\255\255\018\000\255\255\018\000\ - \255\255\023\000\019\000\023\000\023\000\023\000\023\000\023\000\ - \083\000\083\000\083\000\083\000\083\000\083\000\083\000\083\000\ - \083\000\083\000\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\083\000\083\000\083\000\083\000\083\000\083\000\255\255\ - \019\000\255\255\019\000\255\255\255\255\023\000\255\255\255\255\ - \255\255\255\255\175\000\255\255\255\255\255\255\255\255\024\000\ - \193\000\193\000\193\000\193\000\193\000\193\000\193\000\193\000\ - \255\255\083\000\083\000\083\000\083\000\083\000\083\000\255\255\ - \255\255\255\255\255\255\023\000\255\255\023\000\024\000\024\000\ - \255\255\024\000\024\000\024\000\024\000\255\255\255\255\255\255\ - \024\000\024\000\107\000\024\000\024\000\024\000\024\000\024\000\ - \024\000\024\000\024\000\024\000\024\000\024\000\024\000\024\000\ - \024\000\255\255\024\000\024\000\024\000\024\000\024\000\255\255\ - \255\255\107\000\025\000\255\255\255\255\025\000\025\000\025\000\ - \255\255\255\255\025\000\025\000\025\000\255\255\025\000\025\000\ - \025\000\107\000\107\000\107\000\107\000\107\000\107\000\107\000\ - \107\000\107\000\107\000\025\000\024\000\025\000\025\000\025\000\ - \025\000\025\000\165\000\165\000\165\000\165\000\165\000\165\000\ - \165\000\165\000\165\000\165\000\168\000\168\000\168\000\168\000\ - \168\000\168\000\168\000\168\000\168\000\168\000\255\255\255\255\ - \255\255\255\255\024\000\028\000\024\000\255\255\075\000\025\000\ - \075\000\075\000\075\000\075\000\075\000\075\000\075\000\075\000\ - \075\000\075\000\075\000\075\000\075\000\075\000\075\000\075\000\ - \075\000\075\000\075\000\075\000\075\000\075\000\075\000\075\000\ - \075\000\075\000\255\255\075\000\255\255\025\000\028\000\025\000\ - \028\000\028\000\028\000\028\000\028\000\028\000\028\000\028\000\ - \028\000\028\000\028\000\028\000\028\000\028\000\028\000\028\000\ - \028\000\028\000\028\000\028\000\028\000\028\000\028\000\028\000\ - \028\000\028\000\030\000\028\000\255\255\255\255\255\255\255\255\ - \255\255\030\000\255\255\030\000\030\000\030\000\030\000\030\000\ - \030\000\030\000\030\000\030\000\030\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\030\000\030\000\030\000\030\000\ - \030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ - \030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ - \030\000\030\000\030\000\030\000\030\000\030\000\255\255\255\255\ - \255\255\255\255\030\000\255\255\030\000\030\000\030\000\030\000\ - \030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ - \030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ - \030\000\030\000\030\000\030\000\030\000\030\000\031\000\255\255\ - \255\255\255\255\255\255\255\255\255\255\031\000\255\255\031\000\ - \031\000\031\000\031\000\031\000\031\000\031\000\031\000\031\000\ - \031\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \031\000\031\000\031\000\031\000\031\000\031\000\031\000\031\000\ - \031\000\031\000\031\000\031\000\031\000\031\000\031\000\031\000\ - \031\000\031\000\031\000\031\000\031\000\031\000\031\000\031\000\ - \031\000\031\000\255\255\255\255\255\255\255\255\031\000\255\255\ - \031\000\031\000\031\000\031\000\031\000\031\000\031\000\031\000\ - \031\000\031\000\031\000\031\000\031\000\031\000\031\000\031\000\ - \031\000\031\000\031\000\031\000\031\000\031\000\031\000\031\000\ - \031\000\031\000\032\000\194\000\194\000\194\000\194\000\194\000\ - \194\000\194\000\194\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\255\255\255\255\ - \255\255\255\255\032\000\255\255\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\095\000\095\000\ - \095\000\095\000\095\000\095\000\095\000\095\000\095\000\095\000\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\095\000\ - \095\000\095\000\095\000\095\000\095\000\186\000\186\000\186\000\ - \186\000\186\000\186\000\186\000\186\000\186\000\186\000\191\000\ - \191\000\191\000\191\000\191\000\191\000\191\000\191\000\191\000\ - \191\000\255\255\255\255\255\255\255\255\255\255\255\255\095\000\ - \095\000\095\000\095\000\095\000\095\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\255\255\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\033\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\033\000\255\255\255\255\ - \255\255\255\255\033\000\255\255\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\033\000\106\000\106\000\ - \255\255\255\255\106\000\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\106\000\255\255\106\000\ - \255\255\255\255\255\255\255\255\143\000\255\255\255\255\143\000\ - \255\255\255\255\255\255\255\255\255\255\106\000\106\000\106\000\ - \106\000\106\000\106\000\106\000\106\000\106\000\106\000\255\255\ - \255\255\255\255\255\255\255\255\143\000\255\255\255\255\255\255\ - \255\255\143\000\143\000\255\255\143\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\255\255\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\034\000\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\143\000\255\255\255\255\ - \255\255\255\255\255\255\255\255\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\255\255\255\255\ - \255\255\255\255\034\000\255\255\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\149\000\255\255\ - \149\000\149\000\149\000\149\000\149\000\149\000\149\000\149\000\ - \149\000\149\000\149\000\149\000\149\000\149\000\149\000\149\000\ - \149\000\149\000\149\000\149\000\149\000\149\000\149\000\149\000\ - \149\000\149\000\255\255\149\000\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\156\000\106\000\156\000\156\000\ - \156\000\156\000\156\000\156\000\156\000\156\000\156\000\156\000\ - \156\000\156\000\156\000\156\000\156\000\156\000\156\000\156\000\ - \156\000\156\000\156\000\156\000\156\000\156\000\156\000\156\000\ - \255\255\156\000\143\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\255\255\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\035\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\255\255\255\255\ - \255\255\255\255\035\000\255\255\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\164\000\164\000\ - \164\000\164\000\164\000\164\000\164\000\164\000\164\000\164\000\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\164\000\ - \164\000\164\000\164\000\164\000\164\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\164\000\ - \164\000\164\000\164\000\164\000\164\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\255\255\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\255\255\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\036\000\255\255\255\255\036\000\036\000\ - \036\000\255\255\255\255\255\255\036\000\036\000\255\255\036\000\ - \036\000\036\000\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\036\000\255\255\036\000\036\000\ - \036\000\036\000\036\000\255\255\204\000\255\255\204\000\204\000\ - \204\000\204\000\204\000\204\000\204\000\204\000\204\000\204\000\ - \204\000\204\000\204\000\204\000\204\000\204\000\204\000\204\000\ - \204\000\204\000\204\000\204\000\204\000\204\000\204\000\204\000\ - \036\000\036\000\204\000\036\000\036\000\036\000\036\000\036\000\ - \036\000\036\000\036\000\036\000\036\000\036\000\036\000\036\000\ - \036\000\036\000\036\000\036\000\036\000\036\000\036\000\036\000\ - \036\000\036\000\036\000\036\000\036\000\255\255\036\000\037\000\ - \036\000\255\255\037\000\037\000\037\000\255\255\255\255\255\255\ - \037\000\037\000\255\255\037\000\037\000\037\000\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \037\000\255\255\037\000\037\000\037\000\037\000\037\000\255\255\ - \210\000\255\255\210\000\210\000\210\000\210\000\210\000\210\000\ - \210\000\210\000\210\000\210\000\210\000\210\000\210\000\210\000\ - \210\000\210\000\210\000\210\000\210\000\210\000\210\000\210\000\ - \210\000\210\000\210\000\210\000\037\000\037\000\210\000\037\000\ - \037\000\037\000\037\000\037\000\037\000\037\000\037\000\037\000\ - \037\000\037\000\037\000\037\000\037\000\037\000\037\000\037\000\ - \037\000\037\000\037\000\037\000\037\000\037\000\037\000\037\000\ - \037\000\255\255\037\000\255\255\037\000\255\255\255\255\255\255\ - \255\255\036\000\036\000\036\000\036\000\036\000\036\000\036\000\ - \036\000\036\000\036\000\036\000\036\000\036\000\036\000\036\000\ - \036\000\036\000\036\000\036\000\036\000\036\000\036\000\036\000\ - \036\000\255\255\036\000\036\000\036\000\036\000\036\000\036\000\ - \036\000\036\000\171\000\171\000\171\000\171\000\171\000\171\000\ - \171\000\171\000\171\000\171\000\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\171\000\171\000\171\000\171\000\171\000\ - \171\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\171\000\171\000\171\000\171\000\171\000\ - \171\000\255\255\255\255\255\255\255\255\037\000\037\000\037\000\ - \037\000\037\000\037\000\037\000\037\000\037\000\037\000\037\000\ - \037\000\037\000\037\000\037\000\037\000\037\000\037\000\037\000\ - \037\000\037\000\037\000\037\000\037\000\038\000\037\000\037\000\ - \037\000\037\000\037\000\037\000\037\000\037\000\038\000\038\000\ - \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\038\000\ - \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ - \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ - \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ - \038\000\255\255\255\255\255\255\255\255\038\000\255\255\038\000\ - \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ - \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ - \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ - \038\000\184\000\184\000\184\000\184\000\184\000\184\000\184\000\ - \184\000\184\000\184\000\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\184\000\184\000\184\000\184\000\184\000\184\000\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\184\000\184\000\184\000\184\000\184\000\184\000\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\038\000\038\000\ - \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ - \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ - \038\000\038\000\038\000\038\000\038\000\255\255\038\000\038\000\ - \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ - \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ - \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ - \038\000\038\000\038\000\038\000\038\000\255\255\038\000\038\000\ - \038\000\038\000\038\000\038\000\038\000\038\000\046\000\255\255\ - \255\255\046\000\046\000\046\000\255\255\255\255\255\255\046\000\ - \046\000\255\255\046\000\046\000\046\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\046\000\ - \255\255\046\000\046\000\046\000\046\000\046\000\255\255\255\255\ - \255\255\255\255\047\000\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\255\255\255\255\ - \255\255\255\255\255\255\046\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\255\255\255\255\ - \255\255\046\000\047\000\046\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\196\000\196\000\ - \196\000\196\000\196\000\196\000\196\000\196\000\196\000\196\000\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\196\000\ - \196\000\196\000\196\000\196\000\196\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\196\000\ - \196\000\196\000\196\000\196\000\196\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\255\255\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\048\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\048\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\255\255\255\255\ - \255\255\255\255\255\255\255\255\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\255\255\255\255\ - \255\255\255\255\048\000\255\255\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\198\000\198\000\ - \198\000\198\000\198\000\198\000\198\000\198\000\198\000\198\000\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\198\000\ - \198\000\198\000\198\000\198\000\198\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\198\000\ - \198\000\198\000\198\000\198\000\198\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\048\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\255\255\048\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\051\000\048\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\255\255\255\255\ - \255\255\255\255\255\255\255\255\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\255\255\255\255\ - \255\255\255\255\051\000\255\255\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\255\255\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\052\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\052\000\255\255\255\255\ - \255\255\255\255\255\255\255\255\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\052\000\255\255\255\255\ - \255\255\255\255\052\000\255\255\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\052\000\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\255\255\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\055\000\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\255\255\255\255\ - \255\255\255\255\055\000\255\255\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\056\000\255\255\ - \255\255\255\255\056\000\255\255\056\000\255\255\255\255\056\000\ - \056\000\056\000\056\000\056\000\056\000\056\000\056\000\056\000\ - \056\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \056\000\056\000\056\000\056\000\056\000\056\000\056\000\056\000\ - \056\000\056\000\056\000\056\000\056\000\056\000\056\000\056\000\ - \056\000\056\000\056\000\056\000\056\000\056\000\056\000\056\000\ - \056\000\056\000\255\255\255\255\255\255\255\255\056\000\255\255\ - \056\000\056\000\056\000\056\000\056\000\056\000\056\000\056\000\ - \056\000\056\000\056\000\056\000\056\000\056\000\056\000\056\000\ - \056\000\056\000\056\000\056\000\056\000\056\000\056\000\056\000\ - \056\000\056\000\057\000\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\057\000\057\000\057\000\057\000\057\000\ - \057\000\057\000\057\000\057\000\057\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\057\000\057\000\057\000\057\000\ - \057\000\057\000\057\000\057\000\057\000\057\000\057\000\057\000\ - \057\000\057\000\057\000\057\000\057\000\057\000\057\000\057\000\ - \057\000\057\000\057\000\057\000\057\000\057\000\255\255\255\255\ - \255\255\255\255\057\000\255\255\057\000\057\000\057\000\057\000\ - \057\000\057\000\057\000\057\000\057\000\057\000\057\000\057\000\ - \057\000\057\000\057\000\057\000\057\000\057\000\057\000\057\000\ - \057\000\057\000\057\000\057\000\057\000\057\000\058\000\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\058\000\255\255\255\255\255\255\255\255\058\000\255\255\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\058\000\059\000\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\059\000\059\000\059\000\059\000\059\000\ - \059\000\059\000\059\000\059\000\059\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\059\000\059\000\059\000\059\000\ - \059\000\059\000\059\000\059\000\059\000\059\000\059\000\059\000\ - \059\000\059\000\059\000\059\000\059\000\059\000\059\000\059\000\ - \059\000\059\000\059\000\059\000\059\000\059\000\255\255\255\255\ - \255\255\255\255\059\000\255\255\059\000\059\000\059\000\059\000\ - \059\000\059\000\059\000\059\000\059\000\059\000\059\000\059\000\ - \059\000\059\000\059\000\059\000\059\000\059\000\059\000\059\000\ - \059\000\059\000\059\000\059\000\059\000\059\000\060\000\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\060\000\ - \060\000\060\000\060\000\060\000\060\000\060\000\060\000\060\000\ - \060\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \060\000\060\000\060\000\060\000\060\000\060\000\060\000\060\000\ - \060\000\060\000\060\000\060\000\060\000\060\000\060\000\060\000\ - \060\000\060\000\060\000\060\000\060\000\060\000\060\000\060\000\ - \060\000\060\000\255\255\255\255\255\255\255\255\060\000\255\255\ - \060\000\060\000\060\000\060\000\060\000\060\000\060\000\060\000\ - \060\000\060\000\060\000\060\000\060\000\060\000\060\000\060\000\ - \060\000\060\000\060\000\060\000\060\000\060\000\060\000\060\000\ - \060\000\060\000\061\000\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\061\000\061\000\061\000\061\000\061\000\ - \061\000\061\000\061\000\061\000\061\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\061\000\061\000\061\000\061\000\ - \061\000\061\000\061\000\061\000\061\000\061\000\061\000\061\000\ - \061\000\061\000\061\000\061\000\061\000\061\000\061\000\061\000\ - \061\000\061\000\061\000\061\000\061\000\061\000\255\255\255\255\ - \255\255\255\255\061\000\255\255\061\000\061\000\061\000\061\000\ - \061\000\061\000\061\000\061\000\061\000\061\000\061\000\061\000\ - \061\000\061\000\061\000\061\000\061\000\061\000\061\000\061\000\ - \061\000\061\000\061\000\061\000\061\000\061\000\062\000\255\255\ - \255\255\255\255\255\255\255\255\255\255\062\000\255\255\062\000\ - \062\000\062\000\062\000\062\000\062\000\062\000\062\000\062\000\ - \062\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \062\000\062\000\062\000\062\000\062\000\062\000\062\000\062\000\ - \062\000\062\000\062\000\062\000\062\000\062\000\062\000\062\000\ - \062\000\062\000\062\000\062\000\062\000\062\000\062\000\062\000\ - \062\000\062\000\255\255\255\255\255\255\255\255\062\000\255\255\ - \062\000\062\000\062\000\062\000\062\000\062\000\062\000\062\000\ - \062\000\062\000\062\000\062\000\062\000\062\000\062\000\062\000\ - \062\000\062\000\062\000\062\000\062\000\062\000\062\000\062\000\ - \062\000\062\000\063\000\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\063\000\063\000\063\000\063\000\063\000\ - \063\000\063\000\063\000\063\000\063\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\063\000\063\000\063\000\063\000\ - \063\000\063\000\063\000\063\000\063\000\063\000\063\000\063\000\ - \063\000\063\000\063\000\063\000\063\000\063\000\063\000\063\000\ - \063\000\063\000\063\000\063\000\063\000\063\000\255\255\255\255\ - \255\255\255\255\063\000\255\255\063\000\063\000\063\000\063\000\ - \063\000\063\000\063\000\063\000\063\000\063\000\063\000\063\000\ - \063\000\063\000\063\000\063\000\063\000\063\000\063\000\063\000\ - \063\000\063\000\063\000\063\000\063\000\063\000\064\000\255\255\ - \255\255\255\255\064\000\255\255\064\000\255\255\255\255\064\000\ - \064\000\064\000\064\000\064\000\064\000\064\000\064\000\064\000\ - \064\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \064\000\064\000\064\000\064\000\064\000\064\000\064\000\064\000\ - \064\000\064\000\064\000\064\000\064\000\064\000\064\000\064\000\ - \064\000\064\000\064\000\064\000\064\000\064\000\064\000\064\000\ - \064\000\064\000\255\255\255\255\255\255\255\255\064\000\255\255\ - \064\000\064\000\064\000\064\000\064\000\064\000\064\000\064\000\ - \064\000\064\000\064\000\064\000\064\000\064\000\064\000\064\000\ - \064\000\064\000\064\000\064\000\064\000\064\000\064\000\064\000\ - \064\000\064\000\065\000\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\065\000\065\000\065\000\065\000\065\000\ - \065\000\065\000\065\000\065\000\065\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\065\000\065\000\065\000\065\000\ - \065\000\065\000\065\000\065\000\065\000\065\000\065\000\065\000\ - \065\000\065\000\065\000\065\000\065\000\065\000\065\000\065\000\ - \065\000\065\000\065\000\065\000\065\000\065\000\255\255\255\255\ - \255\255\255\255\065\000\255\255\065\000\065\000\065\000\065\000\ - \065\000\065\000\065\000\065\000\065\000\065\000\065\000\065\000\ - \065\000\065\000\065\000\065\000\065\000\065\000\065\000\065\000\ - \065\000\065\000\065\000\065\000\065\000\065\000\067\000\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\067\000\ - \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\255\255\255\255\255\255\255\255\067\000\255\255\ - \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\068\000\255\255\255\255\255\255\068\000\255\255\ - \068\000\255\255\255\255\068\000\068\000\068\000\068\000\068\000\ - \068\000\068\000\068\000\068\000\068\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\068\000\068\000\068\000\068\000\ - \068\000\068\000\068\000\068\000\068\000\068\000\068\000\068\000\ - \068\000\068\000\068\000\068\000\068\000\068\000\068\000\068\000\ - \068\000\068\000\068\000\068\000\068\000\068\000\255\255\255\255\ - \255\255\255\255\068\000\255\255\068\000\068\000\068\000\068\000\ - \068\000\068\000\068\000\068\000\068\000\068\000\068\000\068\000\ - \068\000\068\000\068\000\068\000\068\000\068\000\068\000\068\000\ - \068\000\068\000\068\000\068\000\068\000\068\000\069\000\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\069\000\ - \069\000\069\000\069\000\069\000\069\000\069\000\069\000\069\000\ - \069\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \069\000\069\000\069\000\069\000\069\000\069\000\069\000\069\000\ - \069\000\069\000\069\000\069\000\069\000\069\000\069\000\069\000\ - \069\000\069\000\069\000\069\000\069\000\069\000\069\000\069\000\ - \069\000\069\000\255\255\255\255\255\255\255\255\069\000\255\255\ - \069\000\069\000\069\000\069\000\069\000\069\000\069\000\069\000\ - \069\000\069\000\069\000\069\000\069\000\069\000\069\000\069\000\ - \069\000\069\000\069\000\069\000\069\000\069\000\069\000\069\000\ - \069\000\069\000\070\000\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\070\000\070\000\070\000\070\000\070\000\ - \070\000\070\000\070\000\070\000\070\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\070\000\070\000\070\000\070\000\ - \070\000\070\000\070\000\070\000\070\000\070\000\070\000\070\000\ - \070\000\070\000\070\000\070\000\070\000\070\000\070\000\070\000\ - \070\000\070\000\070\000\070\000\070\000\070\000\255\255\255\255\ - \255\255\255\255\070\000\255\255\070\000\070\000\070\000\070\000\ - \070\000\070\000\070\000\070\000\070\000\070\000\070\000\070\000\ - \070\000\070\000\070\000\070\000\070\000\070\000\070\000\070\000\ - \070\000\070\000\070\000\070\000\070\000\070\000\071\000\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\071\000\ - \071\000\071\000\071\000\071\000\071\000\071\000\071\000\071\000\ - \071\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \071\000\071\000\071\000\071\000\071\000\071\000\071\000\071\000\ - \071\000\071\000\071\000\071\000\071\000\071\000\071\000\071\000\ - \071\000\071\000\071\000\071\000\071\000\071\000\071\000\071\000\ - \071\000\071\000\255\255\255\255\255\255\255\255\071\000\255\255\ - \071\000\071\000\071\000\071\000\071\000\071\000\071\000\071\000\ - \071\000\071\000\071\000\071\000\071\000\071\000\071\000\071\000\ - \071\000\071\000\071\000\071\000\071\000\071\000\071\000\071\000\ - \071\000\071\000\076\000\103\000\076\000\255\255\103\000\103\000\ - \103\000\076\000\255\255\255\255\103\000\103\000\255\255\103\000\ - \103\000\103\000\076\000\076\000\076\000\076\000\076\000\076\000\ - \076\000\076\000\076\000\076\000\103\000\255\255\103\000\103\000\ - \103\000\103\000\103\000\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\105\000\255\255\105\000\105\000\105\000\105\000\ - \255\255\255\255\255\255\105\000\105\000\255\255\105\000\105\000\ - \105\000\255\255\255\255\255\255\255\255\255\255\076\000\255\255\ - \103\000\255\255\255\255\105\000\076\000\105\000\105\000\105\000\ - \105\000\105\000\255\255\255\255\255\255\255\255\255\255\255\255\ - \076\000\076\000\255\255\255\255\076\000\255\255\076\000\255\255\ - \116\000\255\255\076\000\116\000\116\000\116\000\103\000\255\255\ - \103\000\116\000\116\000\255\255\116\000\116\000\116\000\105\000\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\116\000\255\255\116\000\116\000\116\000\116\000\116\000\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\117\000\ - \255\255\255\255\117\000\117\000\117\000\105\000\255\255\105\000\ - \117\000\117\000\255\255\117\000\117\000\117\000\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\116\000\255\255\255\255\ - \117\000\255\255\117\000\117\000\117\000\117\000\117\000\255\255\ - \255\255\255\255\118\000\255\255\255\255\118\000\118\000\118\000\ - \255\255\255\255\255\255\118\000\118\000\255\255\118\000\118\000\ - \118\000\255\255\255\255\116\000\255\255\116\000\255\255\255\255\ - \255\255\255\255\255\255\118\000\117\000\118\000\118\000\118\000\ - \118\000\118\000\255\255\255\255\255\255\255\255\255\255\255\255\ - \119\000\255\255\255\255\119\000\119\000\119\000\255\255\255\255\ - \255\255\119\000\119\000\255\255\119\000\119\000\119\000\255\255\ - \255\255\255\255\117\000\255\255\117\000\255\255\255\255\118\000\ - \255\255\119\000\076\000\119\000\119\000\119\000\119\000\119\000\ - \255\255\255\255\255\255\120\000\255\255\255\255\120\000\120\000\ - \120\000\255\255\255\255\255\255\120\000\120\000\255\255\120\000\ - \120\000\120\000\255\255\255\255\255\255\118\000\255\255\118\000\ - \255\255\255\255\255\255\255\255\120\000\119\000\120\000\120\000\ - \120\000\120\000\120\000\255\255\255\255\255\255\126\000\255\255\ - \255\255\126\000\126\000\126\000\255\255\255\255\255\255\126\000\ - \126\000\255\255\126\000\126\000\126\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\119\000\255\255\119\000\255\255\126\000\ - \120\000\126\000\126\000\126\000\126\000\126\000\255\255\255\255\ - \255\255\136\000\255\255\255\255\136\000\136\000\136\000\255\255\ - \255\255\255\255\136\000\136\000\255\255\136\000\136\000\136\000\ - \255\255\255\255\255\255\255\255\255\255\255\255\120\000\255\255\ - \120\000\255\255\136\000\126\000\136\000\136\000\136\000\136\000\ - \136\000\255\255\255\255\255\255\139\000\255\255\255\255\139\000\ - \139\000\139\000\255\255\255\255\255\255\139\000\139\000\255\255\ - \139\000\139\000\139\000\255\255\255\255\255\255\255\255\255\255\ - \255\255\126\000\255\255\126\000\255\255\139\000\136\000\139\000\ - \139\000\139\000\139\000\139\000\255\255\255\255\255\255\140\000\ - \255\255\255\255\140\000\140\000\140\000\255\255\255\255\255\255\ - \140\000\140\000\255\255\140\000\140\000\140\000\255\255\255\255\ - \255\255\255\255\255\255\255\255\136\000\255\255\136\000\255\255\ - \140\000\139\000\140\000\140\000\140\000\140\000\140\000\255\255\ - \255\255\255\255\141\000\255\255\255\255\141\000\141\000\141\000\ - \255\255\255\255\255\255\141\000\141\000\255\255\141\000\141\000\ - \141\000\255\255\255\255\255\255\255\255\255\255\255\255\139\000\ - \255\255\139\000\255\255\141\000\140\000\141\000\141\000\141\000\ - \141\000\141\000\255\255\255\255\255\255\142\000\255\255\255\255\ - \142\000\142\000\142\000\255\255\255\255\255\255\142\000\142\000\ - \255\255\142\000\142\000\142\000\255\255\255\255\157\000\255\255\ - \157\000\255\255\140\000\255\255\140\000\157\000\142\000\141\000\ - \142\000\142\000\142\000\142\000\142\000\255\255\157\000\157\000\ - \157\000\157\000\157\000\157\000\157\000\157\000\157\000\157\000\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\141\000\255\255\141\000\ - \255\255\255\255\142\000\255\255\255\255\255\255\255\255\255\255\ - \255\255\180\000\255\255\255\255\180\000\255\255\255\255\255\255\ - \255\255\255\255\157\000\255\255\255\255\255\255\255\255\255\255\ - \157\000\255\255\255\255\255\255\255\255\255\255\255\255\180\000\ - \142\000\180\000\142\000\255\255\157\000\255\255\180\000\255\255\ - \157\000\255\255\157\000\255\255\255\255\255\255\157\000\180\000\ - \180\000\180\000\180\000\180\000\180\000\180\000\180\000\180\000\ - \180\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\199\000\199\000\199\000\199\000\199\000\199\000\199\000\ - \199\000\199\000\199\000\180\000\255\255\255\255\255\255\255\255\ - \255\255\180\000\199\000\199\000\199\000\199\000\199\000\199\000\ - \255\255\255\255\255\255\255\255\255\255\180\000\180\000\255\255\ - \255\255\180\000\255\255\180\000\180\000\255\255\255\255\180\000\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\199\000\199\000\199\000\199\000\199\000\199\000\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\199\000\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\180\000\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255"; - Lexing.lex_base_code = - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\010\000\036\000\022\000\000\000\000\000\000\000\ - \005\000\000\000\039\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\002\000\005\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000"; - Lexing.lex_backtrk_code = - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\053\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000"; - Lexing.lex_default_code = - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\031\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000"; - Lexing.lex_trans_code = - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\001\000\000\000\050\000\050\000\000\000\009\000\050\000\ - \000\000\000\000\000\000\009\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \001\000\000\000\009\000\001\000\000\000\009\000\000\000\034\000\ - \000\000\000\000\009\000\000\000\012\000\001\000\000\000\000\000\ - \004\000\004\000\004\000\004\000\004\000\004\000\004\000\004\000\ - \004\000\004\000\017\000\017\000\017\000\017\000\017\000\017\000\ - \017\000\017\000\017\000\017\000\001\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\017\000\017\000\017\000\017\000\ - \017\000\017\000\017\000\017\000\017\000\017\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000"; - Lexing.lex_check_code = - "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\024\000\111\000\180\000\189\000\111\000\112\000\190\000\ - \255\255\255\255\255\255\106\000\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \024\000\255\255\111\000\000\000\255\255\112\000\255\255\112\000\ - \255\255\255\255\106\000\255\255\106\000\107\000\255\255\255\255\ - \024\000\024\000\024\000\024\000\024\000\024\000\024\000\024\000\ - \024\000\024\000\106\000\106\000\106\000\106\000\106\000\106\000\ - \106\000\106\000\106\000\106\000\107\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\107\000\107\000\107\000\107\000\ - \107\000\107\000\107\000\107\000\107\000\107\000\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \111\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255"; - Lexing.lex_code = - "\255\005\255\255\007\255\006\255\255\007\255\255\009\255\008\255\ - \255\006\255\007\255\255\004\255\000\005\001\006\002\007\255\009\ - \255\255\008\255\009\255\255\000\005\001\006\004\008\003\009\002\ - \007\255\001\255\255\000\001\255"; -} - -let rec token lexbuf = - lexbuf.Lexing.lex_mem <- Array.make 10 (-1); __ocaml_lex_token_rec lexbuf 0 -and __ocaml_lex_token_rec lexbuf __ocaml_lex_state = - match Lexing.new_engine __ocaml_lex_tables __ocaml_lex_state lexbuf with - | 0 -> -# 770 "parsing/lexer.mll" - ( - if not !escaped_newlines then - raise (Error(Illegal_character (Lexing.lexeme_char lexbuf 0), - Location.curr lexbuf)); - update_loc lexbuf None 1 false 0; - token lexbuf ) -# 2358 "parsing/lexer.ml" - - | 1 -> -# 777 "parsing/lexer.mll" - ( update_loc lexbuf None 1 false 0; - EOL ) -# 2364 "parsing/lexer.ml" - - | 2 -> -# 780 "parsing/lexer.mll" - ( token lexbuf ) -# 2369 "parsing/lexer.ml" - - | 3 -> -# 782 "parsing/lexer.mll" - ( UNDERSCORE ) -# 2374 "parsing/lexer.ml" - - | 4 -> -# 784 "parsing/lexer.mll" - ( TILDE ) -# 2379 "parsing/lexer.ml" - - | 5 -> -# 786 "parsing/lexer.mll" - ( LABEL (get_label_name lexbuf) ) -# 2384 "parsing/lexer.ml" - - | 6 -> -# 788 "parsing/lexer.mll" - ( warn_latin1 lexbuf; LABEL (get_label_name lexbuf) ) -# 2389 "parsing/lexer.ml" - - | 7 -> -# 790 "parsing/lexer.mll" - ( QUESTION ) -# 2394 "parsing/lexer.ml" - - | 8 -> -# 792 "parsing/lexer.mll" - ( OPTLABEL (get_label_name lexbuf) ) -# 2399 "parsing/lexer.ml" - - | 9 -> -# 794 "parsing/lexer.mll" - ( warn_latin1 lexbuf; OPTLABEL (get_label_name lexbuf) ) -# 2404 "parsing/lexer.ml" - - | 10 -> -# 796 "parsing/lexer.mll" - ( let s = Lexing.lexeme lexbuf in - try Hashtbl.find keyword_table s - with Not_found -> LIDENT s ) -# 2411 "parsing/lexer.ml" - - | 11 -> -# 800 "parsing/lexer.mll" - ( warn_latin1 lexbuf; LIDENT (Lexing.lexeme lexbuf) ) -# 2416 "parsing/lexer.ml" - - | 12 -> -# 802 "parsing/lexer.mll" - ( UIDENT(Lexing.lexeme lexbuf) ) -# 2421 "parsing/lexer.ml" - - | 13 -> -# 804 "parsing/lexer.mll" - ( warn_latin1 lexbuf; UIDENT(Lexing.lexeme lexbuf) ) -# 2426 "parsing/lexer.ml" - - | 14 -> -# 805 "parsing/lexer.mll" - ( INT (Lexing.lexeme lexbuf, None) ) -# 2431 "parsing/lexer.ml" - - | 15 -> -let -# 806 "parsing/lexer.mll" - lit -# 2437 "parsing/lexer.ml" -= Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_start_pos (lexbuf.Lexing.lex_curr_pos + -1) -and -# 806 "parsing/lexer.mll" - modif -# 2442 "parsing/lexer.ml" -= Lexing.sub_lexeme_char lexbuf (lexbuf.Lexing.lex_curr_pos + -1) in -# 807 "parsing/lexer.mll" - ( INT (lit, Some modif) ) -# 2446 "parsing/lexer.ml" - - | 16 -> -# 809 "parsing/lexer.mll" - ( FLOAT (Lexing.lexeme lexbuf, None) ) -# 2451 "parsing/lexer.ml" - - | 17 -> -let -# 810 "parsing/lexer.mll" - lit -# 2457 "parsing/lexer.ml" -= Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_start_pos (lexbuf.Lexing.lex_curr_pos + -1) -and -# 810 "parsing/lexer.mll" - modif -# 2462 "parsing/lexer.ml" -= Lexing.sub_lexeme_char lexbuf (lexbuf.Lexing.lex_curr_pos + -1) in -# 811 "parsing/lexer.mll" - ( FLOAT (lit, Some modif) ) -# 2466 "parsing/lexer.ml" - - | 18 -> -# 813 "parsing/lexer.mll" - ( raise (Error(Invalid_literal (Lexing.lexeme lexbuf), - Location.curr lexbuf)) ) -# 2472 "parsing/lexer.ml" - - | 19 -> -# 816 "parsing/lexer.mll" - ( reset_string_buffer(); - is_in_string := true; - let string_start = lexbuf.lex_start_p in - string_start_loc := Location.curr lexbuf; - string lexbuf; - is_in_string := false; - lexbuf.lex_start_p <- string_start; - STRING (get_stored_string(), None) ) -# 2484 "parsing/lexer.ml" - - | 20 -> -# 825 "parsing/lexer.mll" - ( reset_string_buffer(); - let delim = Lexing.lexeme lexbuf in - let delim = String.sub delim 1 (String.length delim - 2) in - is_in_string := true; - let string_start = lexbuf.lex_start_p in - string_start_loc := Location.curr lexbuf; - quoted_string delim lexbuf; - is_in_string := false; - lexbuf.lex_start_p <- string_start; - STRING (get_stored_string(), Some delim) ) -# 2498 "parsing/lexer.ml" - - | 21 -> -# 836 "parsing/lexer.mll" - ( update_loc lexbuf None 1 false 1; - CHAR (Lexing.lexeme_char lexbuf 1) ) -# 2504 "parsing/lexer.ml" - - | 22 -> -# 839 "parsing/lexer.mll" - ( CHAR(Lexing.lexeme_char lexbuf 1) ) -# 2509 "parsing/lexer.ml" - - | 23 -> -# 841 "parsing/lexer.mll" - ( CHAR(char_for_backslash (Lexing.lexeme_char lexbuf 2)) ) -# 2514 "parsing/lexer.ml" - - | 24 -> -# 843 "parsing/lexer.mll" - ( CHAR(char_for_decimal_code lexbuf 2) ) -# 2519 "parsing/lexer.ml" - - | 25 -> -# 845 "parsing/lexer.mll" - ( CHAR(char_for_octal_code lexbuf 3) ) -# 2524 "parsing/lexer.ml" - - | 26 -> -# 847 "parsing/lexer.mll" - ( CHAR(char_for_hexadecimal_code lexbuf 3) ) -# 2529 "parsing/lexer.ml" - - | 27 -> -# 849 "parsing/lexer.mll" - ( let l = Lexing.lexeme lexbuf in - let esc = String.sub l 1 (String.length l - 1) in - raise (Error(Illegal_escape esc, Location.curr lexbuf)) - ) -# 2537 "parsing/lexer.ml" - - | 28 -> -# 854 "parsing/lexer.mll" - ( let s, loc = with_comment_buffer comment lexbuf in - COMMENT (s, loc) ) -# 2543 "parsing/lexer.ml" - - | 29 -> -# 857 "parsing/lexer.mll" - ( let s, loc = with_comment_buffer comment lexbuf in - if !handle_docstrings then - DOCSTRING (Docstrings.docstring s loc) - else - COMMENT ("*" ^ s, loc) - ) -# 2553 "parsing/lexer.ml" - - | 30 -> -let -# 863 "parsing/lexer.mll" - stars -# 2559 "parsing/lexer.ml" -= Lexing.sub_lexeme lexbuf (lexbuf.Lexing.lex_start_pos + 3) lexbuf.Lexing.lex_curr_pos in -# 864 "parsing/lexer.mll" - ( let s, loc = - with_comment_buffer - (fun lexbuf -> - store_string ("*" ^ stars); - comment lexbuf) - lexbuf - in - COMMENT (s, loc) ) -# 2570 "parsing/lexer.ml" - - | 31 -> -# 873 "parsing/lexer.mll" - ( if !print_warnings then - Location.prerr_warning (Location.curr lexbuf) Warnings.Comment_start; - let s, loc = with_comment_buffer comment lexbuf in - COMMENT (s, loc) ) -# 2578 "parsing/lexer.ml" - - | 32 -> -let -# 877 "parsing/lexer.mll" - stars -# 2584 "parsing/lexer.ml" -= Lexing.sub_lexeme lexbuf (lexbuf.Lexing.lex_start_pos + 2) (lexbuf.Lexing.lex_curr_pos + -2) in -# 878 "parsing/lexer.mll" - ( if !handle_docstrings && stars="" then - (* (**) is an empty docstring *) - DOCSTRING(Docstrings.docstring "" (Location.curr lexbuf)) - else - COMMENT (stars, Location.curr lexbuf) ) -# 2592 "parsing/lexer.ml" - - | 33 -> -# 884 "parsing/lexer.mll" - ( let loc = Location.curr lexbuf in - Location.prerr_warning loc Warnings.Comment_not_end; - lexbuf.Lexing.lex_curr_pos <- lexbuf.Lexing.lex_curr_pos - 1; - let curpos = lexbuf.lex_curr_p in - lexbuf.lex_curr_p <- { curpos with pos_cnum = curpos.pos_cnum - 1 }; - STAR - ) -# 2603 "parsing/lexer.ml" - - | 34 -> -let -# 891 "parsing/lexer.mll" - num -# 2609 "parsing/lexer.ml" -= Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_mem.(0) lexbuf.Lexing.lex_mem.(1) -and -# 892 "parsing/lexer.mll" - name -# 2614 "parsing/lexer.ml" -= Lexing.sub_lexeme_opt lexbuf lexbuf.Lexing.lex_mem.(4) lexbuf.Lexing.lex_mem.(3) -and -# 892 "parsing/lexer.mll" - directive -# 2619 "parsing/lexer.ml" -= Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_start_pos lexbuf.Lexing.lex_mem.(2) in -# 894 "parsing/lexer.mll" - ( - match int_of_string num with - | exception _ -> - (* PR#7165 *) - let loc = Location.curr lexbuf in - let explanation = "line number out of range" in - let error = Invalid_directive (directive, Some explanation) in - raise (Error (error, loc)) - | line_num -> - (* Documentation says that the line number should be - positive, but we have never guarded against this and it - might have useful hackish uses. *) - update_loc lexbuf name line_num true 0; - token lexbuf - ) -# 2637 "parsing/lexer.ml" - - | 35 -> -# 909 "parsing/lexer.mll" - ( HASH ) -# 2642 "parsing/lexer.ml" - - | 36 -> -# 910 "parsing/lexer.mll" - ( AMPERSAND ) -# 2647 "parsing/lexer.ml" - - | 37 -> -# 911 "parsing/lexer.mll" - ( AMPERAMPER ) -# 2652 "parsing/lexer.ml" - - | 38 -> -# 912 "parsing/lexer.mll" - ( BACKQUOTE ) -# 2657 "parsing/lexer.ml" - - | 39 -> -# 913 "parsing/lexer.mll" - ( QUOTE ) -# 2662 "parsing/lexer.ml" - - | 40 -> -# 914 "parsing/lexer.mll" - ( LPAREN ) -# 2667 "parsing/lexer.ml" - - | 41 -> -# 915 "parsing/lexer.mll" - ( RPAREN ) -# 2672 "parsing/lexer.ml" - - | 42 -> -# 916 "parsing/lexer.mll" - ( STAR ) -# 2677 "parsing/lexer.ml" - - | 43 -> -# 917 "parsing/lexer.mll" - ( COMMA ) -# 2682 "parsing/lexer.ml" - - | 44 -> -# 918 "parsing/lexer.mll" - ( MINUSGREATER ) -# 2687 "parsing/lexer.ml" - - | 45 -> -# 919 "parsing/lexer.mll" - ( DOT ) -# 2692 "parsing/lexer.ml" - - | 46 -> -# 920 "parsing/lexer.mll" - ( DOTDOT ) -# 2697 "parsing/lexer.ml" - - | 47 -> -let -# 921 "parsing/lexer.mll" - s -# 2703 "parsing/lexer.ml" -= Lexing.sub_lexeme lexbuf (lexbuf.Lexing.lex_start_pos + 1) lexbuf.Lexing.lex_curr_pos in -# 921 "parsing/lexer.mll" - ( DOTOP s ) -# 2707 "parsing/lexer.ml" - - | 48 -> -# 922 "parsing/lexer.mll" - ( COLON ) -# 2712 "parsing/lexer.ml" - - | 49 -> -# 923 "parsing/lexer.mll" - ( COLONCOLON ) -# 2717 "parsing/lexer.ml" - - | 50 -> -# 924 "parsing/lexer.mll" - ( COLONEQUAL ) -# 2722 "parsing/lexer.ml" - - | 51 -> -# 925 "parsing/lexer.mll" - ( COLONGREATER ) -# 2727 "parsing/lexer.ml" - - | 52 -> -# 926 "parsing/lexer.mll" - ( SEMI ) -# 2732 "parsing/lexer.ml" - - | 53 -> -# 927 "parsing/lexer.mll" - ( SEMISEMI ) -# 2737 "parsing/lexer.ml" - - | 54 -> -# 928 "parsing/lexer.mll" - ( LESS ) -# 2742 "parsing/lexer.ml" - - | 55 -> -# 929 "parsing/lexer.mll" - ( LESSMINUS ) -# 2747 "parsing/lexer.ml" - - | 56 -> -# 930 "parsing/lexer.mll" - ( EQUAL ) -# 2752 "parsing/lexer.ml" - - | 57 -> -# 931 "parsing/lexer.mll" - ( LBRACKET ) -# 2757 "parsing/lexer.ml" - - | 58 -> -# 932 "parsing/lexer.mll" - ( LBRACKETBAR ) -# 2762 "parsing/lexer.ml" - - | 59 -> -# 933 "parsing/lexer.mll" - ( LBRACKETLESS ) -# 2767 "parsing/lexer.ml" - - | 60 -> -# 934 "parsing/lexer.mll" - ( LBRACKETGREATER ) -# 2772 "parsing/lexer.ml" - - | 61 -> -# 935 "parsing/lexer.mll" - ( RBRACKET ) -# 2777 "parsing/lexer.ml" - - | 62 -> -# 936 "parsing/lexer.mll" - ( LBRACE ) -# 2782 "parsing/lexer.ml" - - | 63 -> -# 937 "parsing/lexer.mll" - ( LBRACELESS ) -# 2787 "parsing/lexer.ml" - - | 64 -> -# 938 "parsing/lexer.mll" - ( BAR ) -# 2792 "parsing/lexer.ml" - - | 65 -> -# 939 "parsing/lexer.mll" - ( BARBAR ) -# 2797 "parsing/lexer.ml" - - | 66 -> -# 940 "parsing/lexer.mll" - ( BARRBRACKET ) -# 2802 "parsing/lexer.ml" - - | 67 -> -# 941 "parsing/lexer.mll" - ( GREATER ) -# 2807 "parsing/lexer.ml" - - | 68 -> -# 942 "parsing/lexer.mll" - ( GREATERRBRACKET ) -# 2812 "parsing/lexer.ml" - - | 69 -> -# 943 "parsing/lexer.mll" - ( RBRACE ) -# 2817 "parsing/lexer.ml" - - | 70 -> -# 944 "parsing/lexer.mll" - ( GREATERRBRACE ) -# 2822 "parsing/lexer.ml" - - | 71 -> -# 945 "parsing/lexer.mll" - ( LBRACKETAT ) -# 2827 "parsing/lexer.ml" - - | 72 -> -# 946 "parsing/lexer.mll" - ( LBRACKETATAT ) -# 2832 "parsing/lexer.ml" - - | 73 -> -# 947 "parsing/lexer.mll" - ( LBRACKETATATAT ) -# 2837 "parsing/lexer.ml" - - | 74 -> -# 948 "parsing/lexer.mll" - ( LBRACKETPERCENT ) -# 2842 "parsing/lexer.ml" - - | 75 -> -# 949 "parsing/lexer.mll" - ( LBRACKETPERCENTPERCENT ) -# 2847 "parsing/lexer.ml" - - | 76 -> -# 950 "parsing/lexer.mll" - ( BANG ) -# 2852 "parsing/lexer.ml" - - | 77 -> -# 951 "parsing/lexer.mll" - ( INFIXOP0 "!=" ) -# 2857 "parsing/lexer.ml" - - | 78 -> -# 952 "parsing/lexer.mll" - ( PLUS ) -# 2862 "parsing/lexer.ml" - - | 79 -> -# 953 "parsing/lexer.mll" - ( PLUSDOT ) -# 2867 "parsing/lexer.ml" - - | 80 -> -# 954 "parsing/lexer.mll" - ( PLUSEQ ) -# 2872 "parsing/lexer.ml" - - | 81 -> -# 955 "parsing/lexer.mll" - ( MINUS ) -# 2877 "parsing/lexer.ml" - - | 82 -> -# 956 "parsing/lexer.mll" - ( MINUSDOT ) -# 2882 "parsing/lexer.ml" - - | 83 -> -# 959 "parsing/lexer.mll" - ( PREFIXOP(Lexing.lexeme lexbuf) ) -# 2887 "parsing/lexer.ml" - - | 84 -> -# 961 "parsing/lexer.mll" - ( PREFIXOP(Lexing.lexeme lexbuf) ) -# 2892 "parsing/lexer.ml" - - | 85 -> -# 963 "parsing/lexer.mll" - ( INFIXOP0(Lexing.lexeme lexbuf) ) -# 2897 "parsing/lexer.ml" - - | 86 -> -# 965 "parsing/lexer.mll" - ( INFIXOP1(Lexing.lexeme lexbuf) ) -# 2902 "parsing/lexer.ml" - - | 87 -> -# 967 "parsing/lexer.mll" - ( INFIXOP2(Lexing.lexeme lexbuf) ) -# 2907 "parsing/lexer.ml" - - | 88 -> -# 969 "parsing/lexer.mll" - ( INFIXOP4(Lexing.lexeme lexbuf) ) -# 2912 "parsing/lexer.ml" - - | 89 -> -# 970 "parsing/lexer.mll" - ( PERCENT ) -# 2917 "parsing/lexer.ml" - - | 90 -> -# 972 "parsing/lexer.mll" - ( INFIXOP3(Lexing.lexeme lexbuf) ) -# 2922 "parsing/lexer.ml" - - | 91 -> -# 974 "parsing/lexer.mll" - ( HASHOP(Lexing.lexeme lexbuf) ) -# 2927 "parsing/lexer.ml" - - | 92 -> -# 975 "parsing/lexer.mll" - ( - if !if_then_else <> Dir_out then - if !if_then_else = Dir_if_true then - raise (Error (Unterminated_if, Location.curr lexbuf)) - else raise (Error(Unterminated_else, Location.curr lexbuf)) - else - EOF - - ) -# 2940 "parsing/lexer.ml" - - | 93 -> -# 985 "parsing/lexer.mll" - ( raise (Error(Illegal_character (Lexing.lexeme_char lexbuf 0), - Location.curr lexbuf)) - ) -# 2947 "parsing/lexer.ml" - - | __ocaml_lex_state -> lexbuf.Lexing.refill_buff lexbuf; - __ocaml_lex_token_rec lexbuf __ocaml_lex_state - -and comment lexbuf = - __ocaml_lex_comment_rec lexbuf 143 -and __ocaml_lex_comment_rec lexbuf __ocaml_lex_state = - match Lexing.engine __ocaml_lex_tables __ocaml_lex_state lexbuf with - | 0 -> -# 991 "parsing/lexer.mll" - ( comment_start_loc := (Location.curr lexbuf) :: !comment_start_loc; - store_lexeme lexbuf; - comment lexbuf - ) -# 2962 "parsing/lexer.ml" - - | 1 -> -# 996 "parsing/lexer.mll" - ( match !comment_start_loc with - | [] -> assert false - | [_] -> comment_start_loc := []; Location.curr lexbuf - | _ :: l -> comment_start_loc := l; - store_lexeme lexbuf; - comment lexbuf - ) -# 2973 "parsing/lexer.ml" - - | 2 -> -# 1004 "parsing/lexer.mll" - ( - string_start_loc := Location.curr lexbuf; - store_string_char '\"'; - is_in_string := true; - begin try string lexbuf - with Error (Unterminated_string, str_start) -> - match !comment_start_loc with - | [] -> assert false - | loc :: _ -> - let start = List.hd (List.rev !comment_start_loc) in - comment_start_loc := []; - raise (Error (Unterminated_string_in_comment (start, str_start), - loc)) - end; - is_in_string := false; - store_string_char '\"'; - comment lexbuf ) -# 2994 "parsing/lexer.ml" - - | 3 -> -# 1022 "parsing/lexer.mll" - ( - let delim = Lexing.lexeme lexbuf in - let delim = String.sub delim 1 (String.length delim - 2) in - string_start_loc := Location.curr lexbuf; - store_lexeme lexbuf; - is_in_string := true; - begin try quoted_string delim lexbuf - with Error (Unterminated_string, str_start) -> - match !comment_start_loc with - | [] -> assert false - | loc :: _ -> - let start = List.hd (List.rev !comment_start_loc) in - comment_start_loc := []; - raise (Error (Unterminated_string_in_comment (start, str_start), - loc)) - end; - is_in_string := false; - store_string_char '|'; - store_string delim; - store_string_char '}'; - comment lexbuf ) -# 3019 "parsing/lexer.ml" - - | 4 -> -# 1045 "parsing/lexer.mll" - ( store_lexeme lexbuf; comment lexbuf ) -# 3024 "parsing/lexer.ml" - - | 5 -> -# 1047 "parsing/lexer.mll" - ( update_loc lexbuf None 1 false 1; - store_lexeme lexbuf; - comment lexbuf - ) -# 3032 "parsing/lexer.ml" - - | 6 -> -# 1052 "parsing/lexer.mll" - ( store_lexeme lexbuf; comment lexbuf ) -# 3037 "parsing/lexer.ml" - - | 7 -> -# 1054 "parsing/lexer.mll" - ( store_lexeme lexbuf; comment lexbuf ) -# 3042 "parsing/lexer.ml" - - | 8 -> -# 1056 "parsing/lexer.mll" - ( store_lexeme lexbuf; comment lexbuf ) -# 3047 "parsing/lexer.ml" - - | 9 -> -# 1058 "parsing/lexer.mll" - ( store_lexeme lexbuf; comment lexbuf ) -# 3052 "parsing/lexer.ml" - - | 10 -> -# 1060 "parsing/lexer.mll" - ( match !comment_start_loc with - | [] -> assert false - | loc :: _ -> - let start = List.hd (List.rev !comment_start_loc) in - comment_start_loc := []; - raise (Error (Unterminated_comment start, loc)) - ) -# 3063 "parsing/lexer.ml" - - | 11 -> -# 1068 "parsing/lexer.mll" - ( update_loc lexbuf None 1 false 0; - store_lexeme lexbuf; - comment lexbuf - ) -# 3071 "parsing/lexer.ml" - - | 12 -> -# 1073 "parsing/lexer.mll" - ( store_lexeme lexbuf; comment lexbuf ) -# 3076 "parsing/lexer.ml" - - | __ocaml_lex_state -> lexbuf.Lexing.refill_buff lexbuf; - __ocaml_lex_comment_rec lexbuf __ocaml_lex_state - -and string lexbuf = - lexbuf.Lexing.lex_mem <- Array.make 2 (-1); __ocaml_lex_string_rec lexbuf 175 -and __ocaml_lex_string_rec lexbuf __ocaml_lex_state = - match Lexing.new_engine __ocaml_lex_tables __ocaml_lex_state lexbuf with - | 0 -> -# 1077 "parsing/lexer.mll" - ( () ) -# 3088 "parsing/lexer.ml" - - | 1 -> -let -# 1078 "parsing/lexer.mll" - space -# 3094 "parsing/lexer.ml" -= Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_mem.(0) lexbuf.Lexing.lex_curr_pos in -# 1079 "parsing/lexer.mll" - ( update_loc lexbuf None 1 false (String.length space); - if in_comment () then store_lexeme lexbuf; - string lexbuf - ) -# 3101 "parsing/lexer.ml" - - | 2 -> -# 1084 "parsing/lexer.mll" - ( store_escaped_char lexbuf - (char_for_backslash(Lexing.lexeme_char lexbuf 1)); - string lexbuf ) -# 3108 "parsing/lexer.ml" - - | 3 -> -# 1088 "parsing/lexer.mll" - ( store_escaped_char lexbuf (char_for_decimal_code lexbuf 1); - string lexbuf ) -# 3114 "parsing/lexer.ml" - - | 4 -> -# 1091 "parsing/lexer.mll" - ( store_escaped_char lexbuf (char_for_octal_code lexbuf 2); - string lexbuf ) -# 3120 "parsing/lexer.ml" - - | 5 -> -# 1094 "parsing/lexer.mll" - ( store_escaped_char lexbuf (char_for_hexadecimal_code lexbuf 2); - string lexbuf ) -# 3126 "parsing/lexer.ml" - - | 6 -> -# 1097 "parsing/lexer.mll" - ( store_escaped_uchar lexbuf (uchar_for_uchar_escape lexbuf); - string lexbuf ) -# 3132 "parsing/lexer.ml" - - | 7 -> -# 1100 "parsing/lexer.mll" - ( if not (in_comment ()) then begin -(* Should be an error, but we are very lax. - raise (Error (Illegal_escape (Lexing.lexeme lexbuf), - Location.curr lexbuf)) -*) - let loc = Location.curr lexbuf in - Location.prerr_warning loc Warnings.Illegal_backslash; - end; - store_lexeme lexbuf; - string lexbuf - ) -# 3147 "parsing/lexer.ml" - - | 8 -> -# 1112 "parsing/lexer.mll" - ( if not (in_comment ()) then - Location.prerr_warning (Location.curr lexbuf) Warnings.Eol_in_string; - update_loc lexbuf None 1 false 0; - store_lexeme lexbuf; - string lexbuf - ) -# 3157 "parsing/lexer.ml" - - | 9 -> -# 1119 "parsing/lexer.mll" - ( is_in_string := false; - raise (Error (Unterminated_string, !string_start_loc)) ) -# 3163 "parsing/lexer.ml" - - | 10 -> -# 1122 "parsing/lexer.mll" - ( store_string_char(Lexing.lexeme_char lexbuf 0); - string lexbuf ) -# 3169 "parsing/lexer.ml" - - | __ocaml_lex_state -> lexbuf.Lexing.refill_buff lexbuf; - __ocaml_lex_string_rec lexbuf __ocaml_lex_state - -and quoted_string delim lexbuf = - __ocaml_lex_quoted_string_rec delim lexbuf 202 -and __ocaml_lex_quoted_string_rec delim lexbuf __ocaml_lex_state = - match Lexing.engine __ocaml_lex_tables __ocaml_lex_state lexbuf with - | 0 -> -# 1127 "parsing/lexer.mll" - ( update_loc lexbuf None 1 false 0; - store_lexeme lexbuf; - quoted_string delim lexbuf - ) -# 3184 "parsing/lexer.ml" - - | 1 -> -# 1132 "parsing/lexer.mll" - ( is_in_string := false; - raise (Error (Unterminated_string, !string_start_loc)) ) -# 3190 "parsing/lexer.ml" - - | 2 -> -# 1135 "parsing/lexer.mll" - ( - let edelim = Lexing.lexeme lexbuf in - let edelim = String.sub edelim 1 (String.length edelim - 2) in - if delim = edelim then () - else (store_lexeme lexbuf; quoted_string delim lexbuf) - ) -# 3200 "parsing/lexer.ml" - - | 3 -> -# 1142 "parsing/lexer.mll" - ( store_string_char(Lexing.lexeme_char lexbuf 0); - quoted_string delim lexbuf ) -# 3206 "parsing/lexer.ml" - - | __ocaml_lex_state -> lexbuf.Lexing.refill_buff lexbuf; - __ocaml_lex_quoted_string_rec delim lexbuf __ocaml_lex_state - -and skip_hash_bang lexbuf = - __ocaml_lex_skip_hash_bang_rec lexbuf 211 -and __ocaml_lex_skip_hash_bang_rec lexbuf __ocaml_lex_state = - match Lexing.engine __ocaml_lex_tables __ocaml_lex_state lexbuf with - | 0 -> -# 1147 "parsing/lexer.mll" - ( update_loc lexbuf None 3 false 0 ) -# 3218 "parsing/lexer.ml" - - | 1 -> -# 1149 "parsing/lexer.mll" - ( update_loc lexbuf None 1 false 0 ) -# 3223 "parsing/lexer.ml" - - | 2 -> -# 1150 "parsing/lexer.mll" - ( () ) -# 3228 "parsing/lexer.ml" - - | __ocaml_lex_state -> lexbuf.Lexing.refill_buff lexbuf; - __ocaml_lex_skip_hash_bang_rec lexbuf __ocaml_lex_state - -;; - -# 1152 "parsing/lexer.mll" - - let at_bol lexbuf = - let pos = Lexing.lexeme_start_p lexbuf in - pos.pos_cnum = pos.pos_bol - - let token_with_comments lexbuf = - match !preprocessor with - | None -> token lexbuf - | Some (_init, preprocess) -> preprocess token lexbuf - - type newline_state = - | NoLine (* There have been no blank lines yet. *) - | NewLine - (* There have been no blank lines, and the previous - token was a newline. *) - | BlankLine (* There have been blank lines. *) - - type doc_state = - | Initial (* There have been no docstrings yet *) - | After of docstring list - (* There have been docstrings, none of which were - preceded by a blank line *) - | Before of docstring list * docstring list * docstring list - (* There have been docstrings, some of which were - preceded by a blank line *) - - and docstring = Docstrings.docstring - - let interpret_directive lexbuf cont look_ahead = - let if_then_else = !if_then_else in - begin match token_with_comments lexbuf, if_then_else with - | IF, Dir_out -> - let rec skip_from_if_false () = - let token = token_with_comments lexbuf in - if token = EOF then - raise (Error (Unterminated_if, Location.curr lexbuf)) else - if token = HASH && at_bol lexbuf then - begin - let token = token_with_comments lexbuf in - match token with - | END -> - begin - update_if_then_else Dir_out; - cont lexbuf - end - | ELSE -> - begin - update_if_then_else Dir_if_false; - cont lexbuf - end - | IF -> - raise (Error (Unexpected_directive, Location.curr lexbuf)) - | _ -> - if is_elif token && - directive_parse token_with_comments lexbuf then - begin - update_if_then_else Dir_if_true; - cont lexbuf - end - else skip_from_if_false () - end - else skip_from_if_false () in - if directive_parse token_with_comments lexbuf then - begin - update_if_then_else Dir_if_true (* Next state: ELSE *); - cont lexbuf - end - else - skip_from_if_false () - | IF, (Dir_if_false | Dir_if_true)-> - raise (Error(Unexpected_directive, Location.curr lexbuf)) - | LIDENT "elif", (Dir_if_false | Dir_out) - -> (* when the predicate is false, it will continue eating `elif` *) - raise (Error(Unexpected_directive, Location.curr lexbuf)) - | (LIDENT "elif" | ELSE as token), Dir_if_true -> - (* looking for #end, however, it can not see #if anymore *) - let rec skip_from_if_true else_seen = - let token = token_with_comments lexbuf in - if token = EOF then - raise (Error (Unterminated_else, Location.curr lexbuf)) else - if token = HASH && at_bol lexbuf then - begin - let token = token_with_comments lexbuf in - match token with - | END -> - begin - update_if_then_else Dir_out; - cont lexbuf - end - | IF -> - raise (Error (Unexpected_directive, Location.curr lexbuf)) - | ELSE -> - if else_seen then - raise (Error (Unexpected_directive, Location.curr lexbuf)) - else - skip_from_if_true true - | _ -> - if else_seen && is_elif token then - raise (Error (Unexpected_directive, Location.curr lexbuf)) - else - skip_from_if_true else_seen - end - else skip_from_if_true else_seen in - skip_from_if_true (token = ELSE) - | ELSE, Dir_if_false - | ELSE, Dir_out -> - raise (Error(Unexpected_directive, Location.curr lexbuf)) - | END, (Dir_if_false | Dir_if_true ) -> - update_if_then_else Dir_out; - cont lexbuf - | END, Dir_out -> - raise (Error(Unexpected_directive, Location.curr lexbuf)) - | token, (Dir_if_true | Dir_if_false | Dir_out) -> - look_ahead token - end - - let token lexbuf = - let post_pos = lexeme_end_p lexbuf in - let attach lines docs pre_pos = - let open Docstrings in - match docs, lines with - | Initial, _ -> () - | After a, (NoLine | NewLine) -> - set_post_docstrings post_pos (List.rev a); - set_pre_docstrings pre_pos a; - | After a, BlankLine -> - set_post_docstrings post_pos (List.rev a); - set_pre_extra_docstrings pre_pos (List.rev a) - | Before(a, f, b), (NoLine | NewLine) -> - set_post_docstrings post_pos (List.rev a); - set_post_extra_docstrings post_pos - (List.rev_append f (List.rev b)); - set_floating_docstrings pre_pos (List.rev f); - set_pre_extra_docstrings pre_pos (List.rev a); - set_pre_docstrings pre_pos b - | Before(a, f, b), BlankLine -> - set_post_docstrings post_pos (List.rev a); - set_post_extra_docstrings post_pos - (List.rev_append f (List.rev b)); - set_floating_docstrings pre_pos - (List.rev_append f (List.rev b)); - set_pre_extra_docstrings pre_pos (List.rev a) - in - let rec loop lines docs lexbuf = - match token_with_comments lexbuf with - | COMMENT (s, loc) -> - add_comment (s, loc); - let lines' = - match lines with - | NoLine -> NoLine - | NewLine -> NoLine - | BlankLine -> BlankLine - in - loop lines' docs lexbuf - | EOL -> - let lines' = - match lines with - | NoLine -> NewLine - | NewLine -> BlankLine - | BlankLine -> BlankLine - in - loop lines' docs lexbuf - | HASH when at_bol lexbuf -> - interpret_directive lexbuf - (fun lexbuf -> loop lines docs lexbuf) - (fun token -> sharp_look_ahead := Some token; HASH) - | DOCSTRING doc -> - Docstrings.register doc; - add_docstring_comment doc; - let docs' = - if Docstrings.docstring_body doc = "/*" then - match docs with - | Initial -> Before([], [doc], []) - | After a -> Before (a, [doc], []) - | Before(a, f, b) -> Before(a, doc :: b @ f, []) - else - match docs, lines with - | Initial, (NoLine | NewLine) -> After [doc] - | Initial, BlankLine -> Before([], [], [doc]) - | After a, (NoLine | NewLine) -> After (doc :: a) - | After a, BlankLine -> Before (a, [], [doc]) - | Before(a, f, b), (NoLine | NewLine) -> Before(a, f, doc :: b) - | Before(a, f, b), BlankLine -> Before(a, b @ f, [doc]) - in - loop NoLine docs' lexbuf - | tok -> - attach lines docs (lexeme_start_p lexbuf); - tok - in - match !sharp_look_ahead with - | None -> - loop NoLine Initial lexbuf - | Some token -> - sharp_look_ahead := None ; - token - - let init () = - sharp_look_ahead := None; - update_if_then_else Dir_out; - is_in_string := false; - comment_start_loc := []; - comment_list := []; - match !preprocessor with - | None -> () - | Some (init, _preprocess) -> init () - - let rec filter_directive pos acc lexbuf : (int * int ) list = - match token_with_comments lexbuf with - | HASH when at_bol lexbuf -> - (* ^[start_pos]#if ... #then^[end_pos] *) - let start_pos = Lexing.lexeme_start lexbuf in - interpret_directive lexbuf - (fun lexbuf -> - filter_directive - (Lexing.lexeme_end lexbuf) - ((pos, start_pos) :: acc) - lexbuf - - ) - (fun _token -> filter_directive pos acc lexbuf ) - | EOF -> (pos, Lexing.lexeme_end lexbuf) :: acc - | _ -> filter_directive pos acc lexbuf - - let filter_directive_from_lexbuf lexbuf = - List.rev (filter_directive 0 [] lexbuf ) - - let set_preprocessor init preprocess = - escaped_newlines := true; - preprocessor := Some (init, preprocess) - - -# 3467 "parsing/lexer.ml" - -end -(** Interface as module *) -module Outcometree -= struct -#1 "outcometree.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Daniel de Rauglaudre, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 2001 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) - -(* Module [Outcometree]: results displayed by the toplevel *) - -(* These types represent messages that the toplevel displays as normal - results or errors. The real displaying is customisable using the hooks: - [Toploop.print_out_value] - [Toploop.print_out_type] - [Toploop.print_out_sig_item] - [Toploop.print_out_phrase] *) - -type out_ident = - | Oide_apply of out_ident * out_ident - | Oide_dot of out_ident * string - | Oide_ident of string - -type out_string = - | Ostr_string - | Ostr_bytes - -type out_attribute = - { oattr_name: string } - -type out_value = - | Oval_array of out_value list - | Oval_char of char - | Oval_constr of out_ident * out_value list - | Oval_ellipsis - | Oval_float of float - | Oval_int of int - | Oval_int32 of int32 - | Oval_int64 of int64 - | Oval_nativeint of nativeint - | Oval_list of out_value list - | Oval_printer of (Format.formatter -> unit) - | Oval_record of (out_ident * out_value) list - | Oval_string of string * int * out_string (* string, size-to-print, kind *) - | Oval_stuff of string - | Oval_tuple of out_value list - | Oval_variant of string * out_value option - -type out_type = - | Otyp_abstract - | Otyp_open - | Otyp_alias of out_type * string - | Otyp_arrow of string * out_type * out_type - | Otyp_class of bool * out_ident * out_type list - | Otyp_constr of out_ident * out_type list - | Otyp_manifest of out_type * out_type - | Otyp_object of (string * out_type) list * bool option - | Otyp_record of (string * bool * out_type) list - | Otyp_stuff of string - | Otyp_sum of (string * out_type list * out_type option) list - | Otyp_tuple of out_type list - | Otyp_var of bool * string - | Otyp_variant of - bool * out_variant * bool * (string list) option - | Otyp_poly of string list * out_type - | Otyp_module of string * string list * out_type list - | Otyp_attribute of out_type * out_attribute - -and out_variant = - | Ovar_fields of (string * bool * out_type list) list - | Ovar_typ of out_type - -type out_class_type = - | Octy_constr of out_ident * out_type list - | Octy_arrow of string * out_type * out_class_type - | Octy_signature of out_type option * out_class_sig_item list -and out_class_sig_item = - | Ocsg_constraint of out_type * out_type - | Ocsg_method of string * bool * bool * out_type - | Ocsg_value of string * bool * bool * out_type - -type out_module_type = - | Omty_abstract - | Omty_functor of string * out_module_type option * out_module_type - | Omty_ident of out_ident - | Omty_signature of out_sig_item list - | Omty_alias of out_ident -and out_sig_item = - | Osig_class of - bool * string * (string * (bool * bool)) list * out_class_type * - out_rec_status - | Osig_class_type of - bool * string * (string * (bool * bool)) list * out_class_type * - out_rec_status - | Osig_typext of out_extension_constructor * out_ext_status - | Osig_modtype of string * out_module_type - | Osig_module of string * out_module_type * out_rec_status - | Osig_type of out_type_decl * out_rec_status - | Osig_value of out_val_decl - | Osig_ellipsis -and out_type_decl = - { otype_name: string; - otype_params: (string * (bool * bool)) list; - otype_type: out_type; - otype_private: Asttypes.private_flag; - otype_immediate: bool; - otype_unboxed: bool; - otype_cstrs: (out_type * out_type) list } -and out_extension_constructor = - { oext_name: string; - oext_type_name: string; - oext_type_params: string list; - oext_args: out_type list; - oext_ret_type: out_type option; - oext_private: Asttypes.private_flag } -and out_type_extension = - { otyext_name: string; - otyext_params: string list; - otyext_constructors: (string * out_type list * out_type option) list; - otyext_private: Asttypes.private_flag } -and out_val_decl = - { oval_name: string; - oval_type: out_type; - oval_prims: string list; - oval_attributes: out_attribute list } -and out_rec_status = - | Orec_not - | Orec_first - | Orec_next -and out_ext_status = - | Oext_first - | Oext_next - | Oext_exception - -type out_phrase = - | Ophr_eval of out_value * out_type - | Ophr_signature of (out_sig_item * out_value option) list - | Ophr_exception of (exn * out_value) - -end -module Oprint : sig -#1 "oprint.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 2002 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) - -open Format -open Outcometree - - -val out_ident : (formatter -> string -> unit) ref - -val out_value : (formatter -> out_value -> unit) ref -val out_type : (formatter -> out_type -> unit) ref -val out_class_type : (formatter -> out_class_type -> unit) ref -val out_module_type : (formatter -> out_module_type -> unit) ref -val out_sig_item : (formatter -> out_sig_item -> unit) ref -val out_signature : (formatter -> out_sig_item list -> unit) ref -val out_type_extension : (formatter -> out_type_extension -> unit) ref -val out_phrase : (formatter -> out_phrase -> unit) ref - -val parenthesized_ident : string -> bool - -end = struct -#1 "oprint.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 2002 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) - -open Format -open Outcometree - -exception Ellipsis - -let cautious f ppf arg = - try f ppf arg with - Ellipsis -> fprintf ppf "..." - - -let out_ident = ref pp_print_string - - -let print_lident ppf = function - | "::" -> !out_ident ppf "(::)" - | s -> !out_ident ppf s - -let rec print_ident ppf = - function - Oide_ident s -> print_lident ppf s - | Oide_dot (id, s) -> - print_ident ppf id; pp_print_char ppf '.'; print_lident ppf s - | Oide_apply (id1, id2) -> - fprintf ppf "%a(%a)" print_ident id1 print_ident id2 - -let parenthesized_ident name = - (List.mem name ["or"; "mod"; "land"; "lor"; "lxor"; "lsl"; "lsr"; "asr"]) - || - (match name.[0] with - 'a'..'z' | 'A'..'Z' | '\223'..'\246' | '\248'..'\255' | '_' -> - false - | _ -> true) - -let value_ident ppf name = - if parenthesized_ident name then - fprintf ppf "( %s )" name - else - pp_print_string ppf name - -(* Values *) - -let valid_float_lexeme s = - let l = String.length s in - let rec loop i = - if i >= l then s ^ "." else - match s.[i] with - | '0' .. '9' | '-' -> loop (i+1) - | _ -> s - in loop 0 - -let float_repres f = - match classify_float f with - FP_nan -> "nan" - | FP_infinite -> - if f < 0.0 then "neg_infinity" else "infinity" - | _ -> - let float_val = - let s1 = Printf.sprintf "%.12g" f in - if f = float_of_string s1 then s1 else - let s2 = Printf.sprintf "%.15g" f in - if f = float_of_string s2 then s2 else - Printf.sprintf "%.18g" f - in valid_float_lexeme float_val - -let parenthesize_if_neg ppf fmt v isneg = - if isneg then pp_print_char ppf '('; - fprintf ppf fmt v; - if isneg then pp_print_char ppf ')' - -let escape_string s = - (* Escape only C0 control characters (bytes <= 0x1F), DEL(0x7F), '\\' and '"' *) - let n = ref 0 in - for i = 0 to String.length s - 1 do - n := !n + - (match String.unsafe_get s i with - | '\"' | '\\' | '\n' | '\t' | '\r' | '\b' -> 2 - | '\x00' .. '\x1F' - | '\x7F' -> 4 - | _ -> 1) - done; - if !n = String.length s then s else begin - let s' = Bytes.create !n in - n := 0; - for i = 0 to String.length s - 1 do - begin match String.unsafe_get s i with - | ('\"' | '\\') as c -> - Bytes.unsafe_set s' !n '\\'; incr n; Bytes.unsafe_set s' !n c - | '\n' -> - Bytes.unsafe_set s' !n '\\'; incr n; Bytes.unsafe_set s' !n 'n' - | '\t' -> - Bytes.unsafe_set s' !n '\\'; incr n; Bytes.unsafe_set s' !n 't' - | '\r' -> - Bytes.unsafe_set s' !n '\\'; incr n; Bytes.unsafe_set s' !n 'r' - | '\b' -> - Bytes.unsafe_set s' !n '\\'; incr n; Bytes.unsafe_set s' !n 'b' - | '\x00' .. '\x1F' | '\x7F' as c -> - let a = Char.code c in - Bytes.unsafe_set s' !n '\\'; - incr n; - Bytes.unsafe_set s' !n (Char.chr (48 + a / 100)); - incr n; - Bytes.unsafe_set s' !n (Char.chr (48 + (a / 10) mod 10)); - incr n; - Bytes.unsafe_set s' !n (Char.chr (48 + a mod 10)); - | c -> Bytes.unsafe_set s' !n c - end; - incr n - done; - Bytes.to_string s' - end - - -let print_out_string ppf s = - let not_escaped = - (* let the user dynamically choose if strings should be escaped: *) - match Sys.getenv_opt "OCAMLTOP_UTF_8" with - | None -> true - | Some x -> - match bool_of_string_opt x with - | None -> true - | Some f -> f in - if not_escaped then - fprintf ppf "\"%s\"" (escape_string s) - else - fprintf ppf "%S" s - -let print_out_value ppf tree = - let rec print_tree_1 ppf = - function - | Oval_constr (name, [param]) -> - fprintf ppf "@[<1>%a@ %a@]" print_ident name print_constr_param param - | Oval_constr (name, (_ :: _ as params)) -> - fprintf ppf "@[<1>%a@ (%a)@]" print_ident name - (print_tree_list print_tree_1 ",") params - | Oval_variant (name, Some param) -> - fprintf ppf "@[<2>`%s@ %a@]" name print_constr_param param - | tree -> print_simple_tree ppf tree - and print_constr_param ppf = function - | Oval_int i -> parenthesize_if_neg ppf "%i" i (i < 0) - | Oval_int32 i -> parenthesize_if_neg ppf "%lil" i (i < 0l) - | Oval_int64 i -> parenthesize_if_neg ppf "%LiL" i (i < 0L) - | Oval_nativeint i -> parenthesize_if_neg ppf "%nin" i (i < 0n) - | Oval_float f -> parenthesize_if_neg ppf "%s" (float_repres f) (f < 0.0) - | Oval_string (_,_, Ostr_bytes) as tree -> - pp_print_char ppf '('; - print_simple_tree ppf tree; - pp_print_char ppf ')'; - | tree -> print_simple_tree ppf tree - and print_simple_tree ppf = - function - Oval_int i -> fprintf ppf "%i" i - | Oval_int32 i -> fprintf ppf "%lil" i - | Oval_int64 i -> fprintf ppf "%LiL" i - | Oval_nativeint i -> fprintf ppf "%nin" i - | Oval_float f -> pp_print_string ppf (float_repres f) - | Oval_char c -> fprintf ppf "%C" c - | Oval_string (s, maxlen, kind) -> - begin try - let len = String.length s in - let s = if len > maxlen then String.sub s 0 maxlen else s in - begin match kind with - | Ostr_bytes -> fprintf ppf "Bytes.of_string %S" s - | Ostr_string -> print_out_string ppf s - end; - (if len > maxlen then - fprintf ppf - "... (* string length %d; truncated *)" len - ) - with - Invalid_argument _ (* "String.create" *)-> fprintf ppf "" - end - | Oval_list tl -> - fprintf ppf "@[<1>[%a]@]" (print_tree_list print_tree_1 ";") tl - | Oval_array tl -> - fprintf ppf "@[<2>[|%a|]@]" (print_tree_list print_tree_1 ";") tl - | Oval_constr (name, []) -> print_ident ppf name - | Oval_variant (name, None) -> fprintf ppf "`%s" name - | Oval_stuff s -> pp_print_string ppf s - | Oval_record fel -> - fprintf ppf "@[<1>{%a}@]" (cautious (print_fields true)) fel - | Oval_ellipsis -> raise Ellipsis - | Oval_printer f -> f ppf - | Oval_tuple tree_list -> - fprintf ppf "@[<1>(%a)@]" (print_tree_list print_tree_1 ",") tree_list - | tree -> fprintf ppf "@[<1>(%a)@]" (cautious print_tree_1) tree - and print_fields first ppf = - function - [] -> () - | (name, tree) :: fields -> - if not first then fprintf ppf ";@ "; - fprintf ppf "@[<1>%a@ =@ %a@]" print_ident name (cautious print_tree_1) - tree; - print_fields false ppf fields - and print_tree_list print_item sep ppf tree_list = - let rec print_list first ppf = - function - [] -> () - | tree :: tree_list -> - if not first then fprintf ppf "%s@ " sep; - print_item ppf tree; - print_list false ppf tree_list - in - cautious (print_list true) ppf tree_list - in - cautious print_tree_1 ppf tree +let same i1 i2 = i1 = i2 + (* Possibly more efficient version (with a real compiler, at least): + if i1.stamp <> 0 + then i1.stamp = i2.stamp + else i2.stamp = 0 && i1.name = i2.name *) -let out_value = ref print_out_value +let compare i1 i2 = Pervasives.compare i1 i2 -(* Types *) +let binding_time i = i.stamp -let rec print_list_init pr sep ppf = - function - [] -> () - | a :: l -> sep ppf; pr ppf a; print_list_init pr sep ppf l +let current_time() = !currentstamp +let set_current_time t = currentstamp := max !currentstamp t -let rec print_list pr sep ppf = - function - [] -> () - | [a] -> pr ppf a - | a :: l -> pr ppf a; sep ppf; print_list pr sep ppf l +let reinit_level = ref (-1) -let pr_present = - print_list (fun ppf s -> fprintf ppf "`%s" s) (fun ppf -> fprintf ppf "@ ") +let reinit () = + if !reinit_level < 0 + then reinit_level := !currentstamp + else currentstamp := !reinit_level -let pr_vars = - print_list (fun ppf s -> fprintf ppf "'%s" s) (fun ppf -> fprintf ppf "@ ") +let hide i = + { i with stamp = -1 } -let rec print_out_type ppf = - function - | Otyp_alias (ty, s) -> - fprintf ppf "@[%a@ as '%s@]" print_out_type ty s - | Otyp_poly (sl, ty) -> - fprintf ppf "@[%a.@ %a@]" - pr_vars sl - print_out_type ty - | ty -> - print_out_type_1 ppf ty +let make_global i = + i.flags <- i.flags lor global_flag -and print_out_type_1 ppf = - function - Otyp_arrow (lab, ty1, ty2) -> - pp_open_box ppf 0; - if lab <> "" then (pp_print_string ppf lab; pp_print_char ppf ':'); - print_out_type_2 ppf ty1; - pp_print_string ppf " ->"; - pp_print_space ppf (); - print_out_type_1 ppf ty2; - pp_close_box ppf () - | ty -> print_out_type_2 ppf ty -and print_out_type_2 ppf = - function - Otyp_tuple tyl -> - fprintf ppf "@[<0>%a@]" (print_typlist print_simple_out_type " *") tyl - | ty -> print_simple_out_type ppf ty -and print_simple_out_type ppf = - function - Otyp_class (ng, id, tyl) -> - fprintf ppf "@[%a%s#%a@]" print_typargs tyl (if ng then "_" else "") - print_ident id - - | Otyp_constr ( (Oide_dot (((Oide_dot (Oide_ident "Js", "Internal"))| (Oide_ident "Js_internal")), - ("fn" | "meth" as name )) as id) , - ([Otyp_variant(_,Ovar_fields [ variant, _, tys], _,_); result] as tyl)) - -> - (* Otyp_arrow*) - let make tys result = - if tys = [] then - Otyp_arrow ("", Otyp_constr (Oide_ident "unit", []),result) - else - match tys with - | [ Otyp_tuple tys as single] -> - if variant = "Arity_1" then - Otyp_arrow ("", single, result) - else - List.fold_right (fun x acc -> Otyp_arrow("",x,acc) ) tys result - | [single] -> - Otyp_arrow ("", single, result) - | _ -> - raise_notrace Not_found - in - begin match (make tys result) with - | exception _ -> - begin - pp_open_box ppf 0; - print_typargs ppf tyl; - print_ident ppf id; - pp_close_box ppf () - end - | res -> - begin match name with - | "fn" -> - fprintf ppf "@[<0>(%a@ [@bs])@]" print_out_type_1 res - | "meth" -> - fprintf ppf "@[<0>(%a@ [@bs.meth])@]" print_out_type_1 res - | _ -> assert false - end - end - | Otyp_constr ((Oide_dot ((Oide_dot (Oide_ident "Js", "Internal") | (Oide_ident "Js_internal")), "meth_callback" ) as id) , - ([Otyp_variant(_,Ovar_fields [ variant, _, tys], _,_); result] as tyl)) - -> - let make tys result = - match tys with - | [ Otyp_tuple tys as single ] -> - if variant = "Arity_1" then Otyp_arrow ("", single, result) - else - List.fold_right (fun x acc -> Otyp_arrow("",x,acc) ) tys result - | [single] -> - Otyp_arrow ("", single, result) - | _ -> - raise_notrace Not_found - in - begin match (make tys result) with - | exception _ -> - begin - pp_open_box ppf 0; - print_typargs ppf tyl; - print_ident ppf id; - pp_close_box ppf () - end - | res -> - fprintf ppf "@[<0>(%a@ [@bs.this])@]" print_out_type_1 res +let global i = + (i.flags land global_flag) <> 0 - end - - | Otyp_constr (id, tyl) -> - pp_open_box ppf 0; - print_typargs ppf tyl; - print_ident ppf id; - pp_close_box ppf () - | Otyp_object (fields, rest) -> - fprintf ppf "@[<2>< %a >@]" (print_fields rest) fields - | Otyp_stuff s -> pp_print_string ppf s - | Otyp_var (ng, s) -> fprintf ppf "'%s%s" (if ng then "_" else "") s - | Otyp_variant (non_gen, row_fields, closed, tags) -> - let print_present ppf = - function - None | Some [] -> () - | Some l -> fprintf ppf "@;<1 -2>> @[%a@]" pr_present l - in - let print_fields ppf = - function - Ovar_fields fields -> - print_list print_row_field (fun ppf -> fprintf ppf "@;<1 -2>| ") - ppf fields - | Ovar_typ typ -> - print_simple_out_type ppf typ - in - fprintf ppf "%s[%s@[@[%a@]%a ]@]" (if non_gen then "_" else "") - (if closed then if tags = None then " " else "< " - else if tags = None then "> " else "? ") - print_fields row_fields - print_present tags - | Otyp_alias _ | Otyp_poly _ | Otyp_arrow _ | Otyp_tuple _ as ty -> - pp_open_box ppf 1; - pp_print_char ppf '('; - print_out_type ppf ty; - pp_print_char ppf ')'; - pp_close_box ppf () - | Otyp_abstract | Otyp_open - | Otyp_sum _ | Otyp_manifest (_, _) -> () - | Otyp_record lbls -> print_record_decl ppf lbls - | Otyp_module (p, n, tyl) -> - fprintf ppf "@[<1>(module %s" p; - let first = ref true in - List.iter2 - (fun s t -> - let sep = if !first then (first := false; "with") else "and" in - fprintf ppf " %s type %s = %a" sep s print_out_type t - ) - n tyl; - fprintf ppf ")@]" - | Otyp_attribute (t, attr) -> - fprintf ppf "@[<1>(%a [@@%s])@]" print_out_type t attr.oattr_name -and print_record_decl ppf lbls = - fprintf ppf "{%a@;<1 -2>}" - (print_list_init print_out_label (fun ppf -> fprintf ppf "@ ")) lbls -and print_fields rest ppf = - function - [] -> - begin match rest with - Some non_gen -> fprintf ppf "%s.." (if non_gen then "_" else "") - | None -> () - end - | [s, t] -> - fprintf ppf "%s : %a" s print_out_type t; - begin match rest with - Some _ -> fprintf ppf ";@ " - | None -> () - end; - print_fields rest ppf [] - | (s, t) :: l -> - fprintf ppf "%s : %a;@ %a" s print_out_type t (print_fields rest) l -and print_row_field ppf (l, opt_amp, tyl) = - let pr_of ppf = - if opt_amp then fprintf ppf " of@ &@ " - else if tyl <> [] then fprintf ppf " of@ " - else fprintf ppf "" - in - fprintf ppf "@[`%s%t%a@]" l pr_of (print_typlist print_out_type " &") - tyl -and print_typlist print_elem sep ppf = - function - [] -> () - | [ty] -> print_elem ppf ty - | ty :: tyl -> - print_elem ppf ty; - pp_print_string ppf sep; - pp_print_space ppf (); - print_typlist print_elem sep ppf tyl -and print_typargs ppf = - function - [] -> () - | [ty1] -> print_simple_out_type ppf ty1; pp_print_space ppf () - | tyl -> - pp_open_box ppf 1; - pp_print_char ppf '('; - print_typlist print_out_type "," ppf tyl; - pp_print_char ppf ')'; - pp_close_box ppf (); - pp_print_space ppf () -and print_out_label ppf (name, mut, arg) = - fprintf ppf "@[<2>%s%s :@ %a@];" (if mut then "mutable " else "") name - print_out_type arg +let is_predef_exn i = + (i.flags land predef_exn_flag) <> 0 -let out_type = ref print_out_type +let print ppf i = + match i.stamp with + | 0 -> fprintf ppf "%s!" i.name + | -1 -> fprintf ppf "%s#" i.name + | n -> fprintf ppf "%s/%i%s" i.name n (if global i then "g" else "") -(* Class types *) +type 'a tbl = + Empty + | Node of 'a tbl * 'a data * 'a tbl * int -let type_parameter ppf (ty, (co, cn)) = - fprintf ppf "%s%s" - (if not cn then "+" else if not co then "-" else "") - (if ty = "_" then ty else "'"^ty) +and 'a data = + { ident: t; + data: 'a; + previous: 'a data option } -let print_out_class_params ppf = - function - [] -> () - | tyl -> - fprintf ppf "@[<1>[%a]@]@ " - (print_list type_parameter (fun ppf -> fprintf ppf ", ")) - tyl +let empty = Empty -let rec print_out_class_type ppf = - function - Octy_constr (id, tyl) -> - let pr_tyl ppf = - function - [] -> () - | tyl -> - fprintf ppf "@[<1>[%a]@]@ " (print_typlist !out_type ",") tyl - in - fprintf ppf "@[%a%a@]" pr_tyl tyl print_ident id - | Octy_arrow (lab, ty, cty) -> - fprintf ppf "@[%s%a ->@ %a@]" (if lab <> "" then lab ^ ":" else "") - print_out_type_2 ty print_out_class_type cty - | Octy_signature (self_ty, csil) -> - let pr_param ppf = - function - Some ty -> fprintf ppf "@ @[(%a)@]" !out_type ty - | None -> () - in - fprintf ppf "@[@[<2>object%a@]@ %a@;<1 -2>end@]" pr_param self_ty - (print_list print_out_class_sig_item (fun ppf -> fprintf ppf "@ ")) - csil -and print_out_class_sig_item ppf = - function - Ocsg_constraint (ty1, ty2) -> - fprintf ppf "@[<2>constraint %a =@ %a@]" !out_type ty1 - !out_type ty2 - | Ocsg_method (name, priv, virt, ty) -> - fprintf ppf "@[<2>method %s%s%s :@ %a@]" - (if priv then "private " else "") (if virt then "virtual " else "") - name !out_type ty - | Ocsg_value (name, mut, vr, ty) -> - fprintf ppf "@[<2>val %s%s%s :@ %a@]" - (if mut then "mutable " else "") - (if vr then "virtual " else "") - name !out_type ty +(* Inline expansion of height for better speed + * let height = function + * Empty -> 0 + * | Node(_,_,_,h) -> h + *) -let out_class_type = ref print_out_class_type +let mknode l d r = + let hl = match l with Empty -> 0 | Node(_,_,_,h) -> h + and hr = match r with Empty -> 0 | Node(_,_,_,h) -> h in + Node(l, d, r, (if hl >= hr then hl + 1 else hr + 1)) -(* Signature *) +let balance l d r = + let hl = match l with Empty -> 0 | Node(_,_,_,h) -> h + and hr = match r with Empty -> 0 | Node(_,_,_,h) -> h in + if hl > hr + 1 then + match l with + | Node (ll, ld, lr, _) + when (match ll with Empty -> 0 | Node(_,_,_,h) -> h) >= + (match lr with Empty -> 0 | Node(_,_,_,h) -> h) -> + mknode ll ld (mknode lr d r) + | Node (ll, ld, Node(lrl, lrd, lrr, _), _) -> + mknode (mknode ll ld lrl) lrd (mknode lrr d r) + | _ -> assert false + else if hr > hl + 1 then + match r with + | Node (rl, rd, rr, _) + when (match rr with Empty -> 0 | Node(_,_,_,h) -> h) >= + (match rl with Empty -> 0 | Node(_,_,_,h) -> h) -> + mknode (mknode l d rl) rd rr + | Node (Node (rll, rld, rlr, _), rd, rr, _) -> + mknode (mknode l d rll) rld (mknode rlr rd rr) + | _ -> assert false + else + mknode l d r -let out_module_type = ref (fun _ -> failwith "Oprint.out_module_type") -let out_sig_item = ref (fun _ -> failwith "Oprint.out_sig_item") -let out_signature = ref (fun _ -> failwith "Oprint.out_signature") -let out_type_extension = ref (fun _ -> failwith "Oprint.out_type_extension") +let rec add id data = function + Empty -> + Node(Empty, {ident = id; data = data; previous = None}, Empty, 1) + | Node(l, k, r, h) -> + let c = compare id.name k.ident.name in + if c = 0 then + Node(l, {ident = id; data = data; previous = Some k}, r, h) + else if c < 0 then + balance (add id data l) k r + else + balance l k (add id data r) -let rec print_out_functor funct ppf = - function - Omty_functor (_, None, mty_res) -> - if funct then fprintf ppf "() %a" (print_out_functor true) mty_res - else fprintf ppf "functor@ () %a" (print_out_functor true) mty_res - | Omty_functor (name, Some mty_arg, mty_res) -> begin - match name, funct with - | "_", true -> - fprintf ppf "->@ %a ->@ %a" - print_out_module_type mty_arg (print_out_functor false) mty_res - | "_", false -> - fprintf ppf "%a ->@ %a" - print_out_module_type mty_arg (print_out_functor false) mty_res - | name, true -> - fprintf ppf "(%s : %a) %a" name - print_out_module_type mty_arg (print_out_functor true) mty_res - | name, false -> - fprintf ppf "functor@ (%s : %a) %a" name - print_out_module_type mty_arg (print_out_functor true) mty_res - end - | m -> - if funct then fprintf ppf "->@ %a" print_out_module_type m - else print_out_module_type ppf m +let rec find_stamp s = function + None -> + raise Not_found + | Some k -> + if k.ident.stamp = s then k.data else find_stamp s k.previous -and print_out_module_type ppf = - function - Omty_abstract -> () - | Omty_functor _ as t -> - fprintf ppf "@[<2>%a@]" (print_out_functor false) t - | Omty_ident id -> fprintf ppf "%a" print_ident id - | Omty_signature sg -> - fprintf ppf "@[sig@ %a@;<1 -2>end@]" !out_signature sg - | Omty_alias id -> fprintf ppf "(module %a)" print_ident id -and print_out_signature ppf = - function - [] -> () - | [item] -> !out_sig_item ppf item - | Osig_typext(ext, Oext_first) :: items -> - (* Gather together the extension constructors *) - let rec gather_extensions acc items = - match items with - Osig_typext(ext, Oext_next) :: items -> - gather_extensions - ((ext.oext_name, ext.oext_args, ext.oext_ret_type) :: acc) - items - | _ -> (List.rev acc, items) - in - let exts, items = - gather_extensions - [(ext.oext_name, ext.oext_args, ext.oext_ret_type)] - items - in - let te = - { otyext_name = ext.oext_type_name; - otyext_params = ext.oext_type_params; - otyext_constructors = exts; - otyext_private = ext.oext_private } - in - fprintf ppf "%a@ %a" !out_type_extension te print_out_signature items - | item :: items -> - fprintf ppf "%a@ %a" !out_sig_item item print_out_signature items -and print_out_sig_item ppf = - function - Osig_class (vir_flag, name, params, clt, rs) -> - fprintf ppf "@[<2>%s%s@ %a%s@ :@ %a@]" - (if rs = Orec_next then "and" else "class") - (if vir_flag then " virtual" else "") print_out_class_params params - name !out_class_type clt - | Osig_class_type (vir_flag, name, params, clt, rs) -> - fprintf ppf "@[<2>%s%s@ %a%s@ =@ %a@]" - (if rs = Orec_next then "and" else "class type") - (if vir_flag then " virtual" else "") print_out_class_params params - name !out_class_type clt - | Osig_typext (ext, Oext_exception) -> - fprintf ppf "@[<2>exception %a@]" - print_out_constr (ext.oext_name, ext.oext_args, ext.oext_ret_type) - | Osig_typext (ext, _es) -> - print_out_extension_constructor ppf ext - | Osig_modtype (name, Omty_abstract) -> - fprintf ppf "@[<2>module type %s@]" name - | Osig_modtype (name, mty) -> - fprintf ppf "@[<2>module type %s =@ %a@]" name !out_module_type mty - | Osig_module (name, Omty_alias id, _) -> - fprintf ppf "@[<2>module %s =@ %a@]" name print_ident id - | Osig_module (name, mty, rs) -> - fprintf ppf "@[<2>%s %s :@ %a@]" - (match rs with Orec_not -> "module" - | Orec_first -> "module rec" - | Orec_next -> "and") - name !out_module_type mty - | Osig_type(td, rs) -> - print_out_type_decl - (match rs with - | Orec_not -> "type nonrec" - | Orec_first -> "type" - | Orec_next -> "and") - ppf td - | Osig_value vd -> - let kwd = if vd.oval_prims = [] then "val" else "external" in - let pr_prims ppf = - function - [] -> () - | s :: sl -> - fprintf ppf "@ = \"%s\"" s; - List.iter (fun s -> -(* TODO: in general, we should print bs attributes, some attributes like - bs.splice does need it *) +let rec find_same id = function + Empty -> + raise Not_found + | Node(l, k, r, _) -> + let c = compare id.name k.ident.name in + if c = 0 then + if id.stamp = k.ident.stamp + then k.data + else find_stamp id.stamp k.previous + else + find_same id (if c < 0 then l else r) + +let rec find_name name = function + Empty -> + raise Not_found + | Node(l, k, r, _) -> + let c = compare name k.ident.name in + if c = 0 then + k.ident, k.data + else + find_name name (if c < 0 then l else r) + +let rec get_all = function + | None -> [] + | Some k -> (k.ident, k.data) :: get_all k.previous + +let rec find_all name = function + Empty -> + [] + | Node(l, k, r, _) -> + let c = compare name k.ident.name in + if c = 0 then + (k.ident, k.data) :: get_all k.previous + else + find_all name (if c < 0 then l else r) + +let rec fold_aux f stack accu = function + Empty -> + begin match stack with + [] -> accu + | a :: l -> fold_aux f l accu a + end + | Node(l, k, r, _) -> + fold_aux f (l :: stack) (f k accu) r + +let fold_name f tbl accu = fold_aux (fun k -> f k.ident k.data) [] accu tbl - let len = String.length s in - if len >= 3 && s.[0] = 'B' && s.[1] = 'S' && s.[2] = ':' then - fprintf ppf "@ \"BS-EXTERNAL\"" +let rec fold_data f d accu = + match d with + None -> accu + | Some k -> f k.ident k.data (fold_data f k.previous accu) + +let fold_all f tbl accu = + fold_aux (fun k -> fold_data f (Some k)) [] accu tbl + +(* let keys tbl = fold_name (fun k _ accu -> k::accu) tbl [] *) + +let rec iter f = function + Empty -> () + | Node(l, k, r, _) -> + iter f l; f k.ident k.data; iter f r + +(* Idents for sharing keys *) + +(* They should be 'totally fresh' -> neg numbers *) +let key_name = "" + +let make_key_generator () = + let c = ref 1 in + fun id -> + let stamp = !c in + decr c ; + { id with name = key_name; stamp = stamp; } + +let compare x y = + let c = x.stamp - y.stamp in + if c <> 0 then c + else + let c = compare x.name y.name in + if c <> 0 then c else - fprintf ppf "@ \"%s\"" s - - ) sl - in - fprintf ppf "@[<2>%s %a :@ %a%a%a@]" kwd value_ident vd.oval_name - !out_type vd.oval_type pr_prims vd.oval_prims - (fun ppf -> List.iter (fun a -> fprintf ppf "@ [@@@@%s]" a.oattr_name)) - vd.oval_attributes - | Osig_ellipsis -> - fprintf ppf "..." + compare x.flags y.flags -and print_out_type_decl kwd ppf td = - let print_constraints ppf = - List.iter - (fun (ty1, ty2) -> - fprintf ppf "@ @[<2>constraint %a =@ %a@]" !out_type ty1 - !out_type ty2) - td.otype_cstrs - in - let type_defined ppf = - match td.otype_params with - [] -> pp_print_string ppf td.otype_name - | [param] -> fprintf ppf "@[%a@ %s@]" type_parameter param td.otype_name - | _ -> - fprintf ppf "@[(@[%a)@]@ %s@]" - (print_list type_parameter (fun ppf -> fprintf ppf ",@ ")) - td.otype_params - td.otype_name - in - let print_manifest ppf = - function - Otyp_manifest (ty, _) -> fprintf ppf " =@ %a" !out_type ty - | _ -> () - in - let print_name_params ppf = - fprintf ppf "%s %t%a" kwd type_defined print_manifest td.otype_type - in - let ty = - match td.otype_type with - Otyp_manifest (_, ty) -> ty - | _ -> td.otype_type - in - let print_private ppf = function - Asttypes.Private -> fprintf ppf " private" - | Asttypes.Public -> () - in - let print_immediate ppf = - if td.otype_immediate then fprintf ppf " [%@%@immediate]" else () - in - let print_unboxed ppf = - if td.otype_unboxed then fprintf ppf " [%@%@unboxed]" else () - in - let print_out_tkind ppf = function - | Otyp_abstract -> () - | Otyp_record lbls -> - fprintf ppf " =%a %a" - print_private td.otype_private - print_record_decl lbls - | Otyp_sum constrs -> - fprintf ppf " =%a@;<1 2>%a" - print_private td.otype_private - (print_list print_out_constr (fun ppf -> fprintf ppf "@ | ")) constrs - | Otyp_open -> - fprintf ppf " =%a .." - print_private td.otype_private - | ty -> - fprintf ppf " =%a@;<1 2>%a" - print_private td.otype_private - !out_type ty - in - fprintf ppf "@[<2>@[%t%a@]%t%t%t@]" - print_name_params - print_out_tkind ty - print_constraints - print_immediate - print_unboxed +let output oc id = output_string oc (unique_name id) +let hash i = (Char.code i.name.[0]) lxor i.stamp -and print_out_constr ppf (name, tyl,ret_type_opt) = - let name = - match name with - | "::" -> "(::)" (* #7200 *) - | s -> s - in - match ret_type_opt with - | None -> - begin match tyl with - | [] -> - pp_print_string ppf name - | _ -> - fprintf ppf "@[<2>%s of@ %a@]" name - (print_typlist print_simple_out_type " *") tyl - end - | Some ret_type -> - begin match tyl with - | [] -> - fprintf ppf "@[<2>%s :@ %a@]" name print_simple_out_type ret_type - | _ -> - fprintf ppf "@[<2>%s :@ %a -> %a@]" name - (print_typlist print_simple_out_type " *") - tyl print_simple_out_type ret_type - end +let original_equal = equal +include Identifiable.Make (struct + type nonrec t = t + let compare = compare + let output = output + let print = print + let hash = hash + let equal = same +end) +let equal = original_equal -and print_out_extension_constructor ppf ext = - let print_extended_type ppf = - let print_type_parameter ppf ty = - fprintf ppf "%s" - (if ty = "_" then ty else "'"^ty) - in - match ext.oext_type_params with - [] -> fprintf ppf "%s" ext.oext_type_name - | [ty_param] -> - fprintf ppf "@[%a@ %s@]" - print_type_parameter - ty_param - ext.oext_type_name - | _ -> - fprintf ppf "@[(@[%a)@]@ %s@]" - (print_list print_type_parameter (fun ppf -> fprintf ppf ",@ ")) - ext.oext_type_params - ext.oext_type_name - in - fprintf ppf "@[type %t +=%s@;<1 2>%a@]" - print_extended_type - (if ext.oext_private = Asttypes.Private then " private" else "") - print_out_constr (ext.oext_name, ext.oext_args, ext.oext_ret_type) +end +module Path : sig +#1 "path.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -and print_out_type_extension ppf te = - let print_extended_type ppf = - let print_type_parameter ppf ty = - fprintf ppf "%s" - (if ty = "_" then ty else "'"^ty) - in - match te.otyext_params with - [] -> fprintf ppf "%s" te.otyext_name - | [param] -> - fprintf ppf "@[%a@ %s@]" - print_type_parameter param - te.otyext_name - | _ -> - fprintf ppf "@[(@[%a)@]@ %s@]" - (print_list print_type_parameter (fun ppf -> fprintf ppf ",@ ")) - te.otyext_params - te.otyext_name - in - fprintf ppf "@[type %t +=%s@;<1 2>%a@]" - print_extended_type - (if te.otyext_private = Asttypes.Private then " private" else "") - (print_list print_out_constr (fun ppf -> fprintf ppf "@ | ")) - te.otyext_constructors +(* Access paths *) -let _ = out_module_type := print_out_module_type -let _ = out_signature := print_out_signature -let _ = out_sig_item := print_out_sig_item -let _ = out_type_extension := print_out_type_extension +type t = + Pident of Ident.t + | Pdot of t * string * int + | Papply of t * t -(* Phrases *) +val same: t -> t -> bool +val compare: t -> t -> int +val isfree: Ident.t -> t -> bool +val binding_time: t -> int +val flatten : t -> [ `Contains_apply | `Ok of Ident.t * string list ] -let print_out_exception ppf exn outv = - match exn with - Sys.Break -> fprintf ppf "Interrupted.@." - | Out_of_memory -> fprintf ppf "Out of memory during evaluation.@." - | Stack_overflow -> - fprintf ppf "Stack overflow during evaluation (looping recursion?).@." - | _ -> fprintf ppf "@[Exception:@ %a.@]@." !out_value outv +val nopos: int -let rec print_items ppf = - function - [] -> () - | (Osig_typext(ext, Oext_first), None) :: items -> - (* Gather together extension constructors *) - let rec gather_extensions acc items = - match items with - (Osig_typext(ext, Oext_next), None) :: items -> - gather_extensions - ((ext.oext_name, ext.oext_args, ext.oext_ret_type) :: acc) - items - | _ -> (List.rev acc, items) - in - let exts, items = - gather_extensions - [(ext.oext_name, ext.oext_args, ext.oext_ret_type)] - items - in - let te = - { otyext_name = ext.oext_type_name; - otyext_params = ext.oext_type_params; - otyext_constructors = exts; - otyext_private = ext.oext_private } - in - fprintf ppf "@[%a@]" !out_type_extension te; - if items <> [] then fprintf ppf "@ %a" print_items items - | (tree, valopt) :: items -> - begin match valopt with - Some v -> - fprintf ppf "@[<2>%a =@ %a@]" !out_sig_item tree - !out_value v - | None -> fprintf ppf "@[%a@]" !out_sig_item tree - end; - if items <> [] then fprintf ppf "@ %a" print_items items +val name: ?paren:(string -> bool) -> t -> string + (* [paren] tells whether a path suffix needs parentheses *) +val head: t -> Ident.t -let print_out_phrase ppf = - function - Ophr_eval (outv, ty) -> - fprintf ppf "@[- : %a@ =@ %a@]@." !out_type ty !out_value outv - | Ophr_signature [] -> () - | Ophr_signature items -> fprintf ppf "@[%a@]@." print_items items - | Ophr_exception (exn, outv) -> print_out_exception ppf exn outv +val heads: t -> Ident.t list -let out_phrase = ref print_out_phrase +val last: t -> string -end -module Ext_buffer : sig -#1 "ext_buffer.mli" -(***********************************************************************) -(* *) -(* OCaml *) -(* *) -(* Pierre Weis and Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1999 Institut National de Recherche en Informatique et *) -(* en Automatique. All rights reserved. This file is distributed *) -(* under the terms of the GNU Library General Public License, with *) -(* the special exception on linking described in file ../LICENSE. *) -(* *) -(***********************************************************************) +type typath = + | Regular of t + | Ext of t * string + | LocalExt of Ident.t + | Cstr of t * string -(** Extensible buffers. +val constructor_typath: t -> typath +val is_constructor_typath: t -> bool - This module implements buffers that automatically expand - as necessary. It provides accumulative concatenation of strings - in quasi-linear time (instead of quadratic time when strings are - concatenated pairwise). -*) +end = struct +#1 "path.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -(* BuckleScript customization: customized for efficient digest *) +type t = + Pident of Ident.t + | Pdot of t * string * int + | Papply of t * t -type t -(** The abstract type of buffers. *) +let nopos = -1 -val create : int -> t -(** [create n] returns a fresh buffer, initially empty. - The [n] parameter is the initial size of the internal byte sequence - that holds the buffer contents. That byte sequence is automatically - reallocated when more than [n] characters are stored in the buffer, - but shrinks back to [n] characters when [reset] is called. - For best performance, [n] should be of the same order of magnitude - as the number of characters that are expected to be stored in - the buffer (for instance, 80 for a buffer that holds one output - line). Nothing bad will happen if the buffer grows beyond that - limit, however. In doubt, take [n = 16] for instance. - If [n] is not between 1 and {!Sys.max_string_length}, it will - be clipped to that interval. *) +let rec same p1 p2 = + match (p1, p2) with + (Pident id1, Pident id2) -> Ident.same id1 id2 + | (Pdot(p1, s1, _pos1), Pdot(p2, s2, _pos2)) -> s1 = s2 && same p1 p2 + | (Papply(fun1, arg1), Papply(fun2, arg2)) -> + same fun1 fun2 && same arg1 arg2 + | (_, _) -> false -val contents : t -> string -(** Return a copy of the current contents of the buffer. - The buffer itself is unchanged. *) +let rec compare p1 p2 = + match (p1, p2) with + (Pident id1, Pident id2) -> Ident.compare id1 id2 + | (Pdot(p1, s1, _pos1), Pdot(p2, s2, _pos2)) -> + let h = compare p1 p2 in + if h <> 0 then h else String.compare s1 s2 + | (Papply(fun1, arg1), Papply(fun2, arg2)) -> + let h = compare fun1 fun2 in + if h <> 0 then h else compare arg1 arg2 + | ((Pident _ | Pdot _), (Pdot _ | Papply _)) -> -1 + | ((Pdot _ | Papply _), (Pident _ | Pdot _)) -> 1 -val length : t -> int -(** Return the number of characters currently contained in the buffer. *) +let rec isfree id = function + Pident id' -> Ident.same id id' + | Pdot(p, _s, _pos) -> isfree id p + | Papply(p1, p2) -> isfree id p1 || isfree id p2 -val is_empty : t -> bool +let rec binding_time = function + Pident id -> Ident.binding_time id + | Pdot(p, _s, _pos) -> binding_time p + | Papply(p1, p2) -> max (binding_time p1) (binding_time p2) -val clear : t -> unit -(** Empty the buffer. *) +let kfalse _ = false + +let rec name ?(paren=kfalse) = function + Pident id -> Ident.name id + | Pdot(p, s, _pos) -> + name ~paren p ^ if paren s then ".( " ^ s ^ " )" else "." ^ s + | Papply(p1, p2) -> name ~paren p1 ^ "(" ^ name ~paren p2 ^ ")" +let rec head = function + Pident id -> id + | Pdot(p, _s, _pos) -> head p + | Papply _ -> assert false -val add_char : t -> char -> unit -(** [add_char b c] appends the character [c] at the end of the buffer [b]. *) +let flatten = + let rec flatten acc = function + | Pident id -> `Ok (id, acc) + | Pdot (p, s, _) -> flatten (s :: acc) p + | Papply _ -> `Contains_apply + in + fun t -> flatten [] t -val add_string : t -> string -> unit -(** [add_string b s] appends the string [s] at the end of the buffer [b]. *) +let heads p = + let rec heads p acc = match p with + | Pident id -> id :: acc + | Pdot (p, _s, _pos) -> heads p acc + | Papply(p1, p2) -> + heads p1 (heads p2 acc) + in heads p [] -val add_bytes : t -> bytes -> unit -(** [add_string b s] appends the string [s] at the end of the buffer [b]. - @since 4.02 *) +let rec last = function + | Pident id -> Ident.name id + | Pdot(_, s, _) -> s + | Papply(_, p) -> last p -val add_substring : t -> string -> int -> int -> unit -(** [add_substring b s ofs len] takes [len] characters from offset - [ofs] in string [s] and appends them at the end of the buffer [b]. *) +let is_uident s = + assert (s <> ""); + match s.[0] with + | 'A'..'Z' -> true + | _ -> false -val add_subbytes : t -> bytes -> int -> int -> unit -(** [add_substring b s ofs len] takes [len] characters from offset - [ofs] in byte sequence [s] and appends them at the end of the buffer [b]. - @since 4.02 *) +type typath = + | Regular of t + | Ext of t * string + | LocalExt of Ident.t + | Cstr of t * string -val add_buffer : t -> t -> unit -(** [add_buffer b1 b2] appends the current contents of buffer [b2] - at the end of buffer [b1]. [b2] is not modified. *) +let constructor_typath = function + | Pident id when is_uident (Ident.name id) -> LocalExt id + | Pdot(ty_path, s, _) when is_uident s -> + if is_uident (last ty_path) then Ext (ty_path, s) + else Cstr (ty_path, s) + | p -> Regular p -val add_channel : t -> in_channel -> int -> unit -(** [add_channel b ic n] reads exactly [n] character from the - input channel [ic] and stores them at the end of buffer [b]. - Raise [End_of_file] if the channel contains fewer than [n] - characters. *) +let is_constructor_typath p = + match constructor_typath p with + | Regular _ -> false + | _ -> true -val output_buffer : out_channel -> t -> unit -(** [output_buffer oc b] writes the current contents of buffer [b] - on the output channel [oc]. *) +end +module Attr_helper : sig +#1 "attr_helper.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Jeremie Dimino, Jane Street Europe *) +(* *) +(* Copyright 2015 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -val digest : t -> Digest.t +(** Helpers for attributes *) -val not_equal : - t -> - string -> - bool +open Asttypes +open Parsetree -val add_int_1 : - t -> int -> unit +type error = + | Multiple_attributes of string + | No_payload_expected of string -val add_int_2 : - t -> int -> unit +(** The [string list] argument of the following functions is a list of + alternative names for the attribute we are looking for. For instance: -val add_int_3 : - t -> int -> unit + {[ + ["foo"; "ocaml.foo"] + ]} *) +val get_no_payload_attribute : string list -> attributes -> string loc option +val has_no_payload_attribute : string list -> attributes -> bool -val add_int_4 : - t -> int -> unit +exception Error of Location.t * error -val add_string_char : - t -> - string -> - char -> - unit +val report_error: Format.formatter -> error -> unit -val add_char_string : - t -> - char -> - string -> - unit end = struct -#1 "ext_buffer.ml" +#1 "attr_helper.ml" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Pierre Weis and Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* Jeremie Dimino, Jane Street Europe *) (* *) -(* Copyright 1999 Institut National de Recherche en Informatique et *) +(* Copyright 2015 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -43658,1691 +26293,1356 @@ end = struct (* *) (**************************************************************************) -(* Extensible buffers *) - -type t = - {mutable buffer : bytes; - mutable position : int; - mutable length : int; - initial_buffer : bytes} +open Asttypes +open Parsetree -let create n = - let n = if n < 1 then 1 else n in - - let n = if n > Sys.max_string_length then Sys.max_string_length else n in - - let s = Bytes.create n in - {buffer = s; position = 0; length = n; initial_buffer = s} +type error = + | Multiple_attributes of string + | No_payload_expected of string -let contents b = Bytes.sub_string b.buffer 0 b.position -let to_bytes b = Bytes.sub b.buffer 0 b.position +exception Error of Location.t * error -let sub b ofs len = - if ofs < 0 || len < 0 || ofs > b.position - len - then invalid_arg "Ext_buffer.sub" - else Bytes.sub_string b.buffer ofs len +let get_no_payload_attribute alt_names attrs = + match List.filter (fun (n, _) -> List.mem n.txt alt_names) attrs with + | [] -> None + | [ (name, PStr []) ] -> Some name + | [ (name, _) ] -> + raise (Error (name.loc, No_payload_expected name.txt)) + | _ :: (name, _) :: _ -> + raise (Error (name.loc, Multiple_attributes name.txt)) +let has_no_payload_attribute alt_names attrs = + match get_no_payload_attribute alt_names attrs with + | None -> false + | Some _ -> true -let blit src srcoff dst dstoff len = - if len < 0 || srcoff < 0 || srcoff > src.position - len - || dstoff < 0 || dstoff > (Bytes.length dst) - len - then invalid_arg "Ext_buffer.blit" - else - Bytes.unsafe_blit src.buffer srcoff dst dstoff len +open Format -let length b = b.position -let is_empty b = b.position = 0 -let clear b = b.position <- 0 +let report_error ppf = function + | Multiple_attributes name -> + fprintf ppf "Too many `%s' attributes" name + | No_payload_expected name -> + fprintf ppf "Attribute `%s' does not accept a payload" name -let reset b = - b.position <- 0; b.buffer <- b.initial_buffer; - b.length <- Bytes.length b.buffer +let () = + Location.register_error_of_exn + (function + | Error (loc, err) -> + Some (Location.error_of_printer loc report_error err) + | _ -> + None + ) -let resize b more = - let len = b.length in - let new_len = ref len in - while b.position + more > !new_len do new_len := 2 * !new_len done; - - if !new_len > Sys.max_string_length then begin - if b.position + more <= Sys.max_string_length - then new_len := Sys.max_string_length - else failwith "Ext_buffer.add: cannot grow buffer" - end; - - let new_buffer = Bytes.create !new_len in - (* PR#6148: let's keep using [blit] rather than [unsafe_blit] in - this tricky function that is slow anyway. *) - Bytes.blit b.buffer 0 new_buffer 0 b.position; - b.buffer <- new_buffer; - b.length <- !new_len ; - assert (b.position + more <= b.length) +end +(** Interface as module *) +module Outcometree += struct +#1 "outcometree.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Daniel de Rauglaudre, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 2001 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -let add_char b c = - let pos = b.position in - if pos >= b.length then resize b 1; - Bytes.unsafe_set b.buffer pos c; - b.position <- pos + 1 +(* Module [Outcometree]: results displayed by the toplevel *) -let add_substring b s offset len = - if offset < 0 || len < 0 || offset > String.length s - len - then invalid_arg "Ext_buffer.add_substring/add_subbytes"; - let new_position = b.position + len in - if new_position > b.length then resize b len; - Ext_bytes.unsafe_blit_string s offset b.buffer b.position len; - b.position <- new_position +(* These types represent messages that the toplevel displays as normal + results or errors. The real displaying is customisable using the hooks: + [Toploop.print_out_value] + [Toploop.print_out_type] + [Toploop.print_out_sig_item] + [Toploop.print_out_phrase] *) +type out_ident = + | Oide_apply of out_ident * out_ident + | Oide_dot of out_ident * string + | Oide_ident of string -let add_subbytes b s offset len = - add_substring b (Bytes.unsafe_to_string s) offset len +type out_string = + | Ostr_string + | Ostr_bytes -let add_string b s = - let len = String.length s in - let new_position = b.position + len in - if new_position > b.length then resize b len; - Ext_bytes.unsafe_blit_string s 0 b.buffer b.position len; - b.position <- new_position +type out_attribute = + { oattr_name: string } -(* TODO: micro-optimzie *) -let add_string_char b s c = - let s_len = String.length s in - let len = s_len + 1 in - let new_position = b.position + len in - if new_position > b.length then resize b len; - let b_buffer = b.buffer in - Ext_bytes.unsafe_blit_string s 0 b_buffer b.position s_len; - Bytes.unsafe_set b_buffer (new_position - 1) c; - b.position <- new_position +type out_value = + | Oval_array of out_value list + | Oval_char of char + | Oval_constr of out_ident * out_value list + | Oval_ellipsis + | Oval_float of float + | Oval_int of int + | Oval_int32 of int32 + | Oval_int64 of int64 + | Oval_nativeint of nativeint + | Oval_list of out_value list + | Oval_printer of (Format.formatter -> unit) + | Oval_record of (out_ident * out_value) list + | Oval_string of string * int * out_string (* string, size-to-print, kind *) + | Oval_stuff of string + | Oval_tuple of out_value list + | Oval_variant of string * out_value option -let add_char_string b c s = - let s_len = String.length s in - let len = s_len + 1 in - let new_position = b.position + len in - if new_position > b.length then resize b len; - let b_buffer = b.buffer in - let b_position = b.position in - Bytes.unsafe_set b_buffer b_position c ; - Ext_bytes.unsafe_blit_string s 0 b_buffer (b_position + 1) s_len; - b.position <- new_position +type out_type = + | Otyp_abstract + | Otyp_open + | Otyp_alias of out_type * string + | Otyp_arrow of string * out_type * out_type + | Otyp_class of bool * out_ident * out_type list + | Otyp_constr of out_ident * out_type list + | Otyp_manifest of out_type * out_type + | Otyp_object of (string * out_type) list * bool option + | Otyp_record of (string * bool * out_type) list + | Otyp_stuff of string + | Otyp_sum of (string * out_type list * out_type option) list + | Otyp_tuple of out_type list + | Otyp_var of bool * string + | Otyp_variant of + bool * out_variant * bool * (string list) option + | Otyp_poly of string list * out_type + | Otyp_module of string * string list * out_type list + | Otyp_attribute of out_type * out_attribute +and out_variant = + | Ovar_fields of (string * bool * out_type list) list + | Ovar_typ of out_type -let add_bytes b s = add_string b (Bytes.unsafe_to_string s) +type out_class_type = + | Octy_constr of out_ident * out_type list + | Octy_arrow of string * out_type * out_class_type + | Octy_signature of out_type option * out_class_sig_item list +and out_class_sig_item = + | Ocsg_constraint of out_type * out_type + | Ocsg_method of string * bool * bool * out_type + | Ocsg_value of string * bool * bool * out_type -let add_buffer b bs = - add_subbytes b bs.buffer 0 bs.position +type out_module_type = + | Omty_abstract + | Omty_functor of string * out_module_type option * out_module_type + | Omty_ident of out_ident + | Omty_signature of out_sig_item list + | Omty_alias of out_ident +and out_sig_item = + | Osig_class of + bool * string * (string * (bool * bool)) list * out_class_type * + out_rec_status + | Osig_class_type of + bool * string * (string * (bool * bool)) list * out_class_type * + out_rec_status + | Osig_typext of out_extension_constructor * out_ext_status + | Osig_modtype of string * out_module_type + | Osig_module of string * out_module_type * out_rec_status + | Osig_type of out_type_decl * out_rec_status + | Osig_value of out_val_decl + | Osig_ellipsis +and out_type_decl = + { otype_name: string; + otype_params: (string * (bool * bool)) list; + otype_type: out_type; + otype_private: Asttypes.private_flag; + otype_immediate: bool; + otype_unboxed: bool; + otype_cstrs: (out_type * out_type) list } +and out_extension_constructor = + { oext_name: string; + oext_type_name: string; + oext_type_params: string list; + oext_args: out_type list; + oext_ret_type: out_type option; + oext_private: Asttypes.private_flag } +and out_type_extension = + { otyext_name: string; + otyext_params: string list; + otyext_constructors: (string * out_type list * out_type option) list; + otyext_private: Asttypes.private_flag } +and out_val_decl = + { oval_name: string; + oval_type: out_type; + oval_prims: string list; + oval_attributes: out_attribute list } +and out_rec_status = + | Orec_not + | Orec_first + | Orec_next +and out_ext_status = + | Oext_first + | Oext_next + | Oext_exception -let add_channel b ic len = - if len < 0 +type out_phrase = + | Ophr_eval of out_value * out_type + | Ophr_signature of (out_sig_item * out_value option) list + | Ophr_exception of (exn * out_value) - || len > Sys.max_string_length +end +module Primitive : sig +#1 "primitive.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) - then (* PR#5004 *) - invalid_arg "Ext_buffer.add_channel"; - if b.position + len > b.length then resize b len; - really_input ic b.buffer b.position len; - b.position <- b.position + len +(* Description of primitive functions *) -let output_buffer oc b = - output oc b.buffer 0 b.position +type boxed_integer = Pnativeint | Pint32 | Pint64 -external unsafe_string: bytes -> int -> int -> Digest.t = "caml_md5_string" +(* Representation of arguments/result for the native code version + of a primitive *) +type native_repr = + | Same_as_ocaml_repr + | Unboxed_float + | Unboxed_integer of boxed_integer + | Untagged_int -let digest b = - unsafe_string - b.buffer 0 b.position +type description = private + { prim_name: string; (* Name of primitive or C function *) + prim_arity: int; (* Number of arguments *) + prim_alloc: bool; (* Does it allocates or raise? *) + prim_native_name: string; (* Name of C function for the nat. code gen. *) + prim_native_repr_args: native_repr list; + prim_native_repr_res: native_repr } -let rec not_equal_aux (b : bytes) (s : string) i len = - if i >= len then false - else - (Bytes.unsafe_get b i - <> - String.unsafe_get s i ) - || not_equal_aux b s (i + 1) len +(* Invariant [List.length d.prim_native_repr_args = d.prim_arity] *) -(** avoid a large copy *) -let not_equal (b : t) (s : string) = - let b_len = b.position in - let s_len = String.length s in - b_len <> s_len - || not_equal_aux b.buffer s 0 s_len +val simple + : name:string + -> arity:int + -> alloc:bool + -> description +val make + : name:string + -> alloc:bool + -> native_name:string + -> native_repr_args: native_repr list + -> native_repr_res: native_repr + -> description -(** - It could be one byte, two bytes, three bytes and four bytes - TODO: inline for better performance -*) -let add_int_1 (b : t ) (x : int ) = - let c = (Char.unsafe_chr (x land 0xff)) in - let pos = b.position in - if pos >= b.length then resize b 1; - Bytes.unsafe_set b.buffer pos c; - b.position <- pos + 1 - -let add_int_2 (b : t ) (x : int ) = - let c1 = (Char.unsafe_chr (x land 0xff)) in - let c2 = (Char.unsafe_chr (x lsr 8 land 0xff)) in - let pos = b.position in - if pos + 1 >= b.length then resize b 2; - let b_buffer = b.buffer in - Bytes.unsafe_set b_buffer pos c1; - Bytes.unsafe_set b_buffer (pos + 1) c2; - b.position <- pos + 2 +val parse_declaration + : Parsetree.value_description + -> native_repr_args:native_repr list + -> native_repr_res:native_repr + -> description -let add_int_3 (b : t ) (x : int ) = - let c1 = (Char.unsafe_chr (x land 0xff)) in - let c2 = (Char.unsafe_chr (x lsr 8 land 0xff)) in - let c3 = (Char.unsafe_chr (x lsr 16 land 0xff)) in - let pos = b.position in - if pos + 2 >= b.length then resize b 3; - let b_buffer = b.buffer in - Bytes.unsafe_set b_buffer pos c1; - Bytes.unsafe_set b_buffer (pos + 1) c2; - Bytes.unsafe_set b_buffer (pos + 2) c3; - b.position <- pos + 3 +val print + : description + -> Outcometree.out_val_decl + -> Outcometree.out_val_decl +val native_name: description -> string +val byte_name: description -> string -let add_int_4 (b : t ) (x : int ) = - let c1 = (Char.unsafe_chr (x land 0xff)) in - let c2 = (Char.unsafe_chr (x lsr 8 land 0xff)) in - let c3 = (Char.unsafe_chr (x lsr 16 land 0xff)) in - let c4 = (Char.unsafe_chr (x lsr 24 land 0xff)) in - let pos = b.position in - if pos + 3 >= b.length then resize b 4; - let b_buffer = b.buffer in - Bytes.unsafe_set b_buffer pos c1; - Bytes.unsafe_set b_buffer (pos + 1) c2; - Bytes.unsafe_set b_buffer (pos + 2) c3; - Bytes.unsafe_set b_buffer (pos + 3) c4; - b.position <- pos + 4 +type error = + | Old_style_float_with_native_repr_attribute + | Old_style_noalloc_with_noalloc_attribute + | No_native_primitive_with_repr_attribute +exception Error of Location.t * error +end = struct +#1 "primitive.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) +(* Description of primitive functions *) -end -module Ext_namespace : sig -#1 "ext_namespace.mli" -(* Copyright (C) 2017- Authors of BuckleScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +open Misc +open Parsetree -(** [make ~ns:"Ns" "a" ] - A typical example would return "a-Ns" - Note the namespace comes from the output of [namespace_of_package_name] -*) -val make : - ?ns:string -> string -> string +type boxed_integer = Pnativeint | Pint32 | Pint64 -val try_split_module_name : - string -> (string * string ) option +type native_repr = + | Same_as_ocaml_repr + | Unboxed_float + | Unboxed_integer of boxed_integer + | Untagged_int +type description = + { prim_name: string; (* Name of primitive or C function *) + prim_arity: int; (* Number of arguments *) + prim_alloc: bool; (* Does it allocates or raise? *) + prim_native_name: string; (* Name of C function for the nat. code gen. *) + prim_native_repr_args: native_repr list; + prim_native_repr_res: native_repr } +type error = + | Old_style_float_with_native_repr_attribute + | Old_style_noalloc_with_noalloc_attribute + | No_native_primitive_with_repr_attribute -(* Note we have to output uncapitalized file Name, - or at least be consistent, since by reading cmi file on Case insensitive OS, we don't really know it is `list.cmi` or `List.cmi`, so that `require (./list.js)` or `require(./List.js)` - relevant issues: #1609, #913 +exception Error of Location.t * error - #1933 when removing ns suffix, don't pass the bound - of basename -*) -val change_ext_ns_suffix : - string -> - string -> - string +let is_ocaml_repr = function + | Same_as_ocaml_repr -> true + | Unboxed_float + | Unboxed_integer _ + | Untagged_int -> false -type file_kind = - | Upper_js - | Upper_bs - | Little_js - | Little_bs - (** [js_name_of_modulename ~little A-Ns] - *) -val js_name_of_modulename : - string -> - file_kind -> - string +let is_unboxed = function + | Same_as_ocaml_repr + | Untagged_int -> false + | Unboxed_float + | Unboxed_integer _ -> true -(* TODO handle cases like - '@angular/core' - its directory structure is like - {[ - @angular - |-------- core - ]} -*) -val is_valid_npm_package_name : string -> bool +let is_untagged = function + | Untagged_int -> true + | Same_as_ocaml_repr + | Unboxed_float + | Unboxed_integer _ -> false -val namespace_of_package_name : string -> string +let rec make_native_repr_args arity x = + if arity = 0 then + [] + else + x :: make_native_repr_args (arity - 1) x -end = struct -#1 "ext_namespace.ml" +let simple ~name ~arity ~alloc = + {prim_name = name; + prim_arity = arity; + prim_alloc = alloc; + prim_native_name = ""; + prim_native_repr_args = make_native_repr_args arity Same_as_ocaml_repr; + prim_native_repr_res = Same_as_ocaml_repr} -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +let make ~name ~alloc ~native_name ~native_repr_args ~native_repr_res = + {prim_name = name; + prim_arity = List.length native_repr_args; + prim_alloc = alloc; + prim_native_name = native_name; + prim_native_repr_args = native_repr_args; + prim_native_repr_res = native_repr_res} +let parse_declaration valdecl ~native_repr_args ~native_repr_res = + let arity = List.length native_repr_args in + let name, native_name, old_style_noalloc, old_style_float = + match valdecl.pval_prim with + | name :: "noalloc" :: name2 :: "float" :: _ -> (name, name2, true, true) + | name :: "noalloc" :: name2 :: _ -> (name, name2, true, false) + | name :: name2 :: "float" :: _ -> (name, name2, false, true) + | name :: "noalloc" :: _ -> (name, "", true, false) + | name :: name2 :: _ -> (name, name2, false, false) + | name :: _ -> (name, "", false, false) + | [] -> + fatal_error "Primitive.parse_declaration" + in + let noalloc_attribute = + Attr_helper.has_no_payload_attribute ["noalloc"; "ocaml.noalloc"] + valdecl.pval_attributes + in + if old_style_float && + not (List.for_all is_ocaml_repr native_repr_args && + is_ocaml_repr native_repr_res) then + raise (Error (valdecl.pval_loc, + Old_style_float_with_native_repr_attribute)); + if old_style_noalloc && noalloc_attribute then + raise (Error (valdecl.pval_loc, + Old_style_noalloc_with_noalloc_attribute)); + (* The compiler used to assume "noalloc" with "float", we just make this + explicit now (GPR#167): *) + let old_style_noalloc = old_style_noalloc || old_style_float in + if old_style_float then + Location.deprecated valdecl.pval_loc + "[@@unboxed] + [@@noalloc] should be used instead of \"float\"" + else if old_style_noalloc then + Location.deprecated valdecl.pval_loc + "[@@noalloc] should be used instead of \"noalloc\""; + if native_name = "" && + not (List.for_all is_ocaml_repr native_repr_args && + is_ocaml_repr native_repr_res) then + raise (Error (valdecl.pval_loc, + No_native_primitive_with_repr_attribute)); + let noalloc = old_style_noalloc || noalloc_attribute in + let native_repr_args, native_repr_res = + if old_style_float then + (make_native_repr_args arity Unboxed_float, Unboxed_float) + else + (native_repr_args, native_repr_res) + in + {prim_name = name; + prim_arity = arity; + prim_alloc = not noalloc; + prim_native_name = native_name; + prim_native_repr_args = native_repr_args; + prim_native_repr_res = native_repr_res} -(* Note the build system should check the validity of filenames - espeically, it should not contain '-' -*) -let ns_sep_char = '-' -let ns_sep = "-" +open Outcometree -let make ?ns cunit = - match ns with - | None -> cunit - | Some ns -> cunit ^ ns_sep ^ ns +let rec add_native_repr_attributes ty attrs = + match ty, attrs with + | Otyp_arrow (label, a, b), attr_opt :: rest -> + let b = add_native_repr_attributes b rest in + let a = + match attr_opt with + | None -> a + | Some attr -> Otyp_attribute (a, attr) + in + Otyp_arrow (label, a, b) + | _, [Some attr] -> Otyp_attribute (ty, attr) + | _ -> + assert (List.for_all (fun x -> x = None) attrs); + ty +let oattr_unboxed = { oattr_name = "unboxed" } +let oattr_untagged = { oattr_name = "untagged" } +let oattr_noalloc = { oattr_name = "noalloc" } -let rec rindex_rec s i = - if i < 0 then i else - let char = String.unsafe_get s i in - if Ext_filename.is_dir_sep char then -1 - else if char = ns_sep_char then i +let print p osig_val_decl = + let prims = + if p.prim_native_name <> "" then + [p.prim_name; p.prim_native_name] else - rindex_rec s (i - 1) - -let change_ext_ns_suffix name ext = - let i = rindex_rec name (String.length name - 1) in - if i < 0 then name ^ ext - else String.sub name 0 i ^ ext (* FIXME: micro-optimizaiton*) + [p.prim_name] + in + let for_all f = + List.for_all f p.prim_native_repr_args && f p.prim_native_repr_res + in + let all_unboxed = for_all is_unboxed in + let all_untagged = for_all is_untagged in + let attrs = if p.prim_alloc then [] else [oattr_noalloc] in + let attrs = + if all_unboxed then + oattr_unboxed :: attrs + else if all_untagged then + oattr_untagged :: attrs + else + attrs + in + let attr_of_native_repr = function + | Same_as_ocaml_repr -> None + | Unboxed_float + | Unboxed_integer _ -> if all_unboxed then None else Some oattr_unboxed + | Untagged_int -> if all_untagged then None else Some oattr_untagged + in + let type_attrs = + List.map attr_of_native_repr p.prim_native_repr_args @ + [attr_of_native_repr p.prim_native_repr_res] + in + { osig_val_decl with + oval_prims = prims; + oval_type = add_native_repr_attributes osig_val_decl.oval_type type_attrs; + oval_attributes = attrs } -let try_split_module_name name = - let len = String.length name in - let i = rindex_rec name (len - 1) in - if i < 0 then None - else - Some (String.sub name (i+1) (len - i - 1), - String.sub name 0 i ) -type file_kind = - | Upper_js - | Upper_bs - | Little_js - | Little_bs +let native_name p = + if p.prim_native_name <> "" + then p.prim_native_name + else p.prim_name +let byte_name p = + p.prim_name - -(* let js_name_of_basename bs_suffix s = - change_ext_ns_suffix s - (if bs_suffix then Literals.suffix_bs_js else Literals.suffix_js ) *) +let report_error ppf err = + match err with + | Old_style_float_with_native_repr_attribute -> + Format.fprintf ppf "Cannot use \"float\" in conjunction with \ + [%@unboxed]/[%@untagged]" + | Old_style_noalloc_with_noalloc_attribute -> + Format.fprintf ppf "Cannot use \"noalloc\" in conjunction with \ + [%@%@noalloc]" + | No_native_primitive_with_repr_attribute -> + Format.fprintf ppf + "The native code version of the primitive is mandatory when \ + attributes [%@untagged] or [%@unboxed] are present" -let js_name_of_modulename s little = - match little with - | Little_js -> - change_ext_ns_suffix (Ext_string.uncapitalize_ascii s) Literals.suffix_js - | Little_bs -> - change_ext_ns_suffix (Ext_string.uncapitalize_ascii s) Literals.suffix_bs_js - | Upper_js -> - change_ext_ns_suffix s Literals.suffix_js - | Upper_bs -> - change_ext_ns_suffix s Literals.suffix_bs_js +let () = + Location.register_error_of_exn + (function + | Error (loc, err) -> + Some (Location.error_of_printer loc report_error err) + | _ -> + None + ) -(* https://docs.npmjs.com/files/package.json - Some rules: - The name must be less than or equal to 214 characters. This includes the scope for scoped packages. - The name can't start with a dot or an underscore. - New packages must not have uppercase letters in the name. - The name ends up being part of a URL, an argument on the command line, and a folder name. Therefore, the name can't contain any non-URL-safe characters. -*) -let is_valid_npm_package_name (s : string) = - let len = String.length s in - len <= 214 && (* magic number forced by npm *) - len > 0 && - match String.unsafe_get s 0 with - | 'a' .. 'z' | '@' -> - Ext_string.for_all_from s 1 - (fun x -> - match x with - | 'a'..'z' | '0'..'9' | '_' | '-' -> true - | _ -> false ) - | _ -> false +end +module Types : sig +#1 "types.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) +(** {0 Representation of types and declarations} *) -let namespace_of_package_name (s : string) : string = - let len = String.length s in - let buf = Ext_buffer.create len in - let add capital ch = - Ext_buffer.add_char buf - (if capital then - (Ext_char.uppercase_ascii ch) - else ch) in - let rec aux capital off len = - if off >= len then () - else - let ch = String.unsafe_get s off in - match ch with - | 'a' .. 'z' - | 'A' .. 'Z' - | '0' .. '9' - -> - add capital ch ; - aux false (off + 1) len - | '/' - | '-' -> - aux true (off + 1) len - | _ -> aux capital (off+1) len - in - aux true 0 len ; - Ext_buffer.contents buf +(** [Types] defines the representation of types and declarations (that is, the + content of module signatures). -end -module Outcome_printer_ns : sig -#1 "outcome_printer_ns.mli" -(* Copyright (C) 2017 Authors of BuckleScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) + CMI files are made of marshalled types. +*) -(** This funciton is used to - reverse namespace printing to - avoid namespace leaking -*) - val out_ident : - Format.formatter -> string -> unit -end = struct -#1 "outcome_printer_ns.ml" -(* Copyright (C) 2017 Authors of BuckleScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +(** Asttypes exposes basic definitions shared both by Parsetree and Types. *) +open Asttypes -let ps = Format.pp_print_string +(** Type expressions for the core language. -let out_ident ppf s = - ps ppf ( - match s with - | "Js_null" - -> "Js.Null" - | "Js_undefined" - -> "Js.Undefined" - | "Js_null_undefined" - -> "Js.Nullable" - | "Js_exn" - -> "Js.Exn" - | "Js_array" - -> "Js.Array" - | "Js_string" - -> "Js.String" - | "Js_re" - -> "Js.Re" - | "Js_promise" - -> "Js.Promise" - | "Js_date" - -> "Js.Date" - | "Js_dict" - -> "Js.Dict" - | "Js_global" - -> "Js.Global" - | "Js_json" - -> "Js.Json" - | "Js_math" - -> "Js.Math" - | "Js_obj" - -> "Js.Obj" - | "Js_typed_array" - -> "Js.Typed_array" - | "Js_types" - -> "Js.Types" - | "Js_float" - -> "Js.Float" - | "Js_int" - -> "Js.Int" - | "Js_option" - -> "Js.Option" - | "Js_result" - -> "Js.Result" - |"Js_list" - -> "Js.List" - | "Js_vector" - -> "Js.Vector" -(* Belt_libs *) - | "Belt_Id" -> "Belt.Id" - | "Belt_Array" -> "Belt.Array" + The [type_desc] variant defines all the possible type expressions one can + find in OCaml. [type_expr] wraps this with some annotations. - | "Belt_SortArray" -> "Belt.SortArray" - | "Belt_SortArrayInt" -> "Belt.SortArray.Int" - | "Belt_SortArrayString" -> "Belt.SortArray.String" - - | "Belt_MutableQueue" -> "Belt.MutableQueue" - | "Belt_MutableStack" -> "Belt.MutableStack" - | "Belt_List" -> "Belt.List" - | "Belt_Range" -> "Belt.Range" - - | "Belt_Set" -> "Belt.Set" - | "Belt_SetInt" -> "Belt.Set.Int" - | "Belt_SetString" -> "Belt.Set.String" + The [level] field tracks the level of polymorphism associated to a type, + guiding the generalization algorithm. + Put shortly, when referring to a type in a given environment, both the type + and the environment have a level. If the type has an higher level, then it + can be considered fully polymorphic (type variables will be printed as + ['a]), otherwise it'll be weakly polymorphic, or non generalized (type + variables printed as ['_a]). + See [http://okmij.org/ftp/ML/generalization.html] for more information. - | "Belt_Map" -> "Belt.Map" - | "Belt_MapInt" -> "Belt.Map.Int" - | "Belt_MapString" -> "Belt.Map.String" + Note about [type_declaration]: one should not make the confusion between + [type_expr] and [type_declaration]. - | "Belt_Option" -> "Belt.Option" + [type_declaration] refers specifically to the [type] construct in OCaml + language, where you create and name a new type or type alias. - | "Belt_MutableSet" -> "Belt.MutableSet" - | "Belt_MutableSetInt" -> "Belt.MutableSet.Int" - | "Belt_MutableSetString" -> "Belt.MutableSet.String" + [type_expr] is used when you refer to existing types, e.g. when annotating + the expected type of a value. - | "Belt_MutableMap" -> "Belt.MutableMap" - | "Belt_MutableMapInt" -> "Belt.MutableMap.Int" - | "Belt_MutableMapString" -> "Belt.MutableMap.String" - - | "Belt_HashSet" -> "Belt.HashSet" - | "Belt_HashSetInt" -> "Belt.HashSet.Int" - | "Belt_HashSetString" -> "Belt.HashSet.String" - - | "Belt_HashMap" -> "Belt.HashMap" - | "Belt_HashMapString" -> "Belt.HashMap.String" - | "Belt_HashMapInt" -> "Belt.HashMap.Int" - | "Belt_Debug" -> "Belt.Debug" - | s -> - (match Ext_namespace.try_split_module_name s with - | None -> s - | Some (ns,m) - -> ns ^ "."^ m - ) - ) + Also, as the type system of OCaml is generative, a [type_declaration] can + have the side-effect of introducing a new type constructor, different from + all other known types. + Whereas [type_expr] is a pure construct which allows referring to existing + types. + Note on mutability: TBD. + *) +type type_expr = + { mutable desc: type_desc; + mutable level: int; + id: int } +and type_desc = + | Tvar of string option + (** [Tvar (Some "a")] ==> ['a] or ['_a] + [Tvar None] ==> [_] *) -end -module Bs_conditional_initial : sig -#1 "bs_conditional_initial.mli" -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) + | Tarrow of arg_label * type_expr * type_expr * commutable + (** [Tarrow (Nolabel, e1, e2, c)] ==> [e1 -> e2] + [Tarrow (Labelled "l", e1, e2, c)] ==> [l:e1 -> e2] + [Tarrow (Optional "l", e1, e2, c)] ==> [?l:e1 -> e2] -(** This function set up built in compile time variables used in - conditional compilation so that - {[ - #if BS then - #elif .. then - #end - ]} - Is understood, also make sure the playground do the same initialization. -*) -val setup_env : unit -> unit + See [commutable] for the last argument. *) + | Ttuple of type_expr list + (** [Ttuple [t1;...;tn]] ==> [(t1 * ... * tn)] *) -end = struct -#1 "bs_conditional_initial.ml" -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) + | Tconstr of Path.t * type_expr list * abbrev_memo ref + (** [Tconstr (`A.B.t', [t1;...;tn], _)] ==> [(t1,...,tn) A.B.t] + The last parameter keep tracks of known expansions, see [abbrev_memo]. *) + | Tobject of type_expr * (Path.t * type_expr list) option ref + (** [Tobject (`f1:t1;...;fn: tn', `None')] ==> [< f1: t1; ...; fn: tn >] + f1, fn are represented as a linked list of types using Tfield and Tnil + constructors. -let setup_env () = - Clflags.compile_only := true; - Clflags.bs_only := true; - Clflags.no_implicit_current_dir := true; - (* default true - otherwise [bsc -I sc src/hello.ml ] will include current directory to search path - *) - Clflags.assume_no_mli := Clflags.Mli_non_exists; - Clflags.unsafe_string := false; - Clflags.debug := true; - Clflags.record_event_when_debug := false; - Clflags.binary_annotations := true; - (* Turn on [-no-alias-deps] by default -- double check *) - Oprint.out_ident := Outcome_printer_ns.out_ident; + [Tobject (_, `Some (`A.ct', [t1;...;tn]')] ==> [(t1, ..., tn) A.ct]. + where A.ct is the type of some class. + There are also special cases for so-called "class-types", cf. [Typeclass] + and [Ctype.set_object_name]: - Lexer.replace_directive_bool "BS" true; - Lexer.replace_directive_string "BS_VERSION" Bs_version.version - + [Tobject (Tfield(_,_,...(Tfield(_,_,rv)...), + Some(`A.#ct`, [rv;t1;...;tn])] + ==> [(t1, ..., tn) #A.ct] + [Tobject (_, Some(`A.#ct`, [Tnil;t1;...;tn])] ==> [(t1, ..., tn) A.ct] + where [rv] is the hidden row variable. + *) -end -module Bsb_build_schemas -= struct -#1 "bsb_build_schemas.ml" -(* Copyright (C) 2017 Authors of BuckleScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) + | Tfield of string * field_kind * type_expr * type_expr + (** [Tfield ("foo", Fpresent, t, ts)] ==> [<...; foo : t; ts>] *) + | Tnil + (** [Tnil] ==> [<...; >] *) -let files = "files" -let version = "version" -let name = "name" -(* let ocaml_config = "ocaml-config" *) -let bsdep = "bsdep" -let ppx_flags = "ppx-flags" -let pp_flags = "pp-flags" -let bsc = "bsc" -let refmt = "refmt" + | Tlink of type_expr + (** Indirection used by unification engine. *) -let bs_external_includes = "bs-external-includes" -let bs_lib_dir = "bs-lib-dir" -let bs_dependencies = "bs-dependencies" -let bs_dev_dependencies = "bs-dev-dependencies" + | Tsubst of type_expr (* for copying *) + (** [Tsubst] is used temporarily to store information in low-level + functions manipulating representation of types, such as + instantiation or copy. + This constructor should not appear outside of these cases. *) + | Tvariant of row_desc + (** Representation of polymorphic variants, see [row_desc]. *) -let sources = "sources" -let dir = "dir" -let files = "files" -let subdirs = "subdirs" -let bsc_flags = "bsc-flags" -let excludes = "excludes" -let slow_re = "slow-re" -let resources = "resources" -let public = "public" -let js_post_build = "js-post-build" -let cmd = "cmd" -let ninja = "ninja" -let package_specs = "package-specs" + | Tunivar of string option + (** Occurrence of a type variable introduced by a + forall quantifier / [Tpoly]. *) -let generate_merlin = "generate-merlin" + | Tpoly of type_expr * type_expr list + (** [Tpoly (ty,tyl)] ==> ['a1... 'an. ty], + where 'a1 ... 'an are names given to types in tyl + and occurrences of those types in ty. *) -let type_ = "type" -let dev = "dev" + | Tpackage of Path.t * Longident.t list * type_expr list + (** Type of a first-class module (a.k.a package). *) -let export_all = "all" -let export_none = "none" +(** [ `X | `Y ] (row_closed = true) + [< `X | `Y ] (row_closed = true) + [> `X | `Y ] (row_closed = false) + [< `X | `Y > `X ] (row_closed = true) -let bsb_dir_group = "bsb_dir_group" -let g_lib_incls = "g_lib_incls" -let use_stdlib = "use-stdlib" -let reason = "reason" -let react_jsx = "react-jsx" + type t = [> `X ] as 'a (row_more = Tvar a) + type t = private [> `X ] (row_more = Tconstr (t#row, [], ref Mnil) -let entries = "entries" -let kind = "kind" -let main = "main" -let cut_generators = "cut-generators" -let generators = "generators" -let command = "command" -let edge = "edge" -let namespace = "namespace" -let in_source = "in-source" -let warnings = "warnings" -let number = "number" -let error = "error" -let suffix = "suffix" -let gentypeconfig = "gentypeconfig" -let path = "path" -let ignored_dirs = "ignored-dirs" -end -module Bsb_pkg_types : sig -#1 "bsb_pkg_types.mli" -(* Copyright (C) 2019- Authors of BuckleScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) + And for: + let f = function `X -> `X -> | `Y -> `X -type t = - | Global of string - | Scope of string * scope -and scope = string + the type of "f" will be a [Tarrow] whose lhs will (basically) be: -val to_string : t -> string -val print : Format.formatter -> t -> unit -val equal : t -> t -> bool + Tvariant { row_fields = [("X", _)]; + row_more = + Tvariant { row_fields = [("Y", _)]; + row_more = + Tvariant { row_fields = []; + row_more = _; + _ }; + _ }; + _ + } -(* The second element could be empty or dropped *) -val extract_pkg_name_and_file : string -> t * string -val string_as_package : string -> t -end = struct -#1 "bsb_pkg_types.ml" +and row_desc = + { row_fields: (label * row_field) list; + row_more: type_expr; + row_bound: unit; (* kept for compatibility *) + row_closed: bool; + row_fixed: bool; + row_name: (Path.t * type_expr list) option } -(* Copyright (C) 2018- Authors of BuckleScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +and row_field = + Rpresent of type_expr option + | Reither of bool * type_expr list * bool * row_field option ref + (* 1st true denotes a constant constructor *) + (* 2nd true denotes a tag in a pattern matching, and + is erased later *) + | Rabsent -let (//) = Filename.concat +(** [abbrev_memo] allows one to keep track of different expansions of a type + alias. This is done for performance purposes. -type t = - | Global of string - | Scope of string * scope -and scope = string + For instance, when defining [type 'a pair = 'a * 'a], when one refers to an + ['a pair], it is just a shortcut for the ['a * 'a] type. + This expansion will be stored in the [abbrev_memo] of the corresponding + [Tconstr] node. -let to_string (x : t) = - match x with - | Global s -> s - | Scope (s,scope) -> scope // s + In practice, [abbrev_memo] behaves like list of expansions with a mutable + tail. -let print fmt (x : t) = - match x with - | Global s -> Format.pp_print_string fmt s - | Scope(name,scope) -> - Format.fprintf fmt "%s/%s" scope name + Note on marshalling: [abbrev_memo] must not appear in saved types. + [Btype], with [cleanup_abbrev] and [memo], takes care of tracking and + removing abbreviations. +*) +and abbrev_memo = + | Mnil (** No known abbreviation *) -let equal (x : t) y = - match x, y with - | Scope(a0,a1), Scope(b0,b1) - -> a0 = b0 && a1 = b1 - | Global a0, Global b0 -> a0 = b0 - | Scope _, Global _ - | Global _, Scope _ -> false + | Mcons of private_flag * Path.t * type_expr * type_expr * abbrev_memo + (** Found one abbreviation. + A valid abbreviation should be at least as visible and reachable by the + same path. + The first expression is the abbreviation and the second the expansion. *) -(** - input: {[ - @hello/yy/xx - hello/yy - ]} - FIXME: fix invalid input - {[ - hello//xh//helo - ]} -*) -let extract_pkg_name_and_file (s : string) = - let len = String.length s in - assert (len > 0 ); - let v = String.unsafe_get s 0 in - if v = '@' then - let scope_id = - Ext_string.no_slash_idx s in - assert (scope_id > 0); - let pkg_id = - Ext_string.no_slash_idx_from - s (scope_id + 1) in - let scope = - String.sub s 0 scope_id in - - if pkg_id < 0 then - (Scope(String.sub s (scope_id + 1) (len - scope_id - 1), scope),"") - else - (Scope( - String.sub s (scope_id + 1) (pkg_id - scope_id - 1), scope), - String.sub s (pkg_id + 1) (len - pkg_id - 1)) - else - let pkg_id = Ext_string.no_slash_idx s in - if pkg_id < 0 then - Global s , "" - else - Global (String.sub s 0 pkg_id), - (String.sub s (pkg_id + 1) (len - pkg_id - 1)) + | Mlink of abbrev_memo ref + (** Abbreviations can be found after this indirection *) +and field_kind = + Fvar of field_kind option ref + | Fpresent + | Fabsent -let string_as_package (s : string) : t = - let len = String.length s in - assert (len > 0); - let v = String.unsafe_get s 0 in - if v = '@' then - let scope_id = - Ext_string.no_slash_idx s in - assert (scope_id > 0); - Scope( - String.sub s (scope_id + 1) (len - scope_id - 1), - String.sub s 0 scope_id - ) - else Global s -end -module Ext_json : sig -#1 "ext_json.mli" -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +(** [commutable] is a flag appended to every arrow type. + When typing an application, if the type of the functional is + known, its type is instantiated with [Cok] arrows, otherwise as + [Clink (ref Cunknown)]. -type path = string list -type status = - | No_path - | Found of Ext_json_types.t - | Wrong_type of path + When the type is not known, the application will be used to infer + the actual type. This is fragile in presence of labels where + there is no principal type. + Two incompatible applications relying on [Cunknown] arrows will + trigger an error. -type callback = - [ - `Str of (string -> unit) - | `Str_loc of (string -> Lexing.position -> unit) - | `Flo of (string -> unit ) - | `Flo_loc of (string -> Lexing.position -> unit ) - | `Bool of (bool -> unit ) - | `Obj of (Ext_json_types.t String_map.t -> unit) - | `Arr of (Ext_json_types.t array -> unit ) - | `Arr_loc of - (Ext_json_types.t array -> Lexing.position -> Lexing.position -> unit) - | `Null of (unit -> unit) - | `Not_found of (unit -> unit) - | `Id of (Ext_json_types.t -> unit ) - ] + let f g = + g ~a:() ~b:(); + g ~b:() ~a:(); -val test: - ?fail:(unit -> unit) -> - string -> callback - -> Ext_json_types.t String_map.t - -> Ext_json_types.t String_map.t + Error: This function is applied to arguments + in an order different from other calls. + This is only allowed when the real type is known. +*) +and commutable = + Cok + | Cunknown + | Clink of commutable ref -val query : path -> Ext_json_types.t -> status +module TypeOps : sig + type t = type_expr + val compare : t -> t -> int + val equal : t -> t -> bool + val hash : t -> int +end -val loc_of : Ext_json_types.t -> Ext_position.t +(* Maps of methods and instance variables *) -val equal : Ext_json_types.t -> Ext_json_types.t -> bool +module Meths : Map.S with type key = string +module Vars : Map.S with type key = string -end = struct -#1 "ext_json.ml" -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +(* Value descriptions *) -type callback = - [ - `Str of (string -> unit) - | `Str_loc of (string -> Lexing.position -> unit) - | `Flo of (string -> unit ) - | `Flo_loc of (string -> Lexing.position -> unit ) - | `Bool of (bool -> unit ) - | `Obj of (Ext_json_types.t String_map.t -> unit) - | `Arr of (Ext_json_types.t array -> unit ) - | `Arr_loc of (Ext_json_types.t array -> Lexing.position -> Lexing.position -> unit) - | `Null of (unit -> unit) - | `Not_found of (unit -> unit) - | `Id of (Ext_json_types.t -> unit ) - ] +type value_description = + { val_type: type_expr; (* Type of the value *) + val_kind: value_kind; + val_loc: Location.t; + val_attributes: Parsetree.attributes; + } + +and value_kind = + Val_reg (* Regular value *) + | Val_prim of Primitive.description (* Primitive *) + | Val_ivar of mutable_flag * string (* Instance variable (mutable ?) *) + | Val_self of (Ident.t * type_expr) Meths.t ref * + (Ident.t * mutable_flag * virtual_flag * type_expr) Vars.t ref * + string * type_expr + (* Self *) + | Val_anc of (string * Ident.t) list * string + (* Ancestor *) + | Val_unbound (* Unbound variable *) + +(* Variance *) + +module Variance : sig + type t + type f = May_pos | May_neg | May_weak | Inj | Pos | Neg | Inv + val null : t (* no occurrence *) + val full : t (* strictly invariant *) + val covariant : t (* strictly covariant *) + val may_inv : t (* maybe invariant *) + val union : t -> t -> t + val inter : t -> t -> t + val subset : t -> t -> bool + val set : f -> bool -> t -> t + val mem : f -> t -> bool + val conjugate : t -> t (* exchange positive and negative *) + val get_upper : t -> bool * bool (* may_pos, may_neg *) + val get_lower : t -> bool * bool * bool * bool (* pos, neg, inv, inj *) +end +(* Type definitions *) -type path = string list +type type_declaration = + { type_params: type_expr list; + type_arity: int; + type_kind: type_kind; + type_private: private_flag; + type_manifest: type_expr option; + type_variance: Variance.t list; + (* covariant, contravariant, weakly contravariant, injective *) + type_newtype_level: (int * int) option; + (* definition level * expansion level *) + type_loc: Location.t; + type_attributes: Parsetree.attributes; + type_immediate: bool; (* true iff type should not be a pointer *) + type_unboxed: unboxed_status; + } -type status = - | No_path - | Found of Ext_json_types.t - | Wrong_type of path +and type_kind = + Type_abstract + | Type_record of label_declaration list * record_representation + | Type_variant of constructor_declaration list + | Type_open -let test ?(fail=(fun () -> ())) key - (cb : callback) (m : Ext_json_types.t String_map.t) - = - begin match String_map.find_exn m key, cb with - | exception Not_found -> - begin match cb with `Not_found f -> f () - | _ -> fail () - end - | True _, `Bool cb -> cb true - | False _, `Bool cb -> cb false - | Flo {flo = s} , `Flo cb -> cb s - | Flo {flo = s; loc} , `Flo_loc cb -> cb s loc - | Obj {map = b} , `Obj cb -> cb b - | Arr {content}, `Arr cb -> cb content - | Arr {content; loc_start ; loc_end}, `Arr_loc cb -> - cb content loc_start loc_end - | Null _, `Null cb -> cb () - | Str {str = s }, `Str cb -> cb s - | Str {str = s ; loc }, `Str_loc cb -> cb s loc - | any , `Id cb -> cb any - | _, _ -> fail () - end; - m -let query path (json : Ext_json_types.t ) = - let rec aux acc paths json = - match path with - | [] -> Found json - | p :: rest -> - match json with - | Obj {map } -> - (match String_map.find_opt map p with - | Some m -> aux (p::acc) rest m - | None -> No_path) - | _ -> Wrong_type acc - in aux [] path json +and record_representation = + Record_regular (* All fields are boxed / tagged *) + | Record_float (* All fields are floats *) + | Record_unboxed of bool (* Unboxed single-field record, inlined or not *) + | Record_inlined of { tag : int ; name : string; num_nonconsts : int} (* Inlined record *) + | Record_extension (* Inlined record under extension *) +and label_declaration = + { + ld_id: Ident.t; + ld_mutable: mutable_flag; + ld_type: type_expr; + ld_loc: Location.t; + ld_attributes: Parsetree.attributes; + } -let loc_of (x : Ext_json_types.t) = - match x with - | True p | False p | Null p -> p - | Str p -> p.loc - | Arr p -> p.loc_start - | Obj p -> p.loc - | Flo p -> p.loc +and constructor_declaration = + { + cd_id: Ident.t; + cd_args: constructor_arguments; + cd_res: type_expr option; + cd_loc: Location.t; + cd_attributes: Parsetree.attributes; + } +and constructor_arguments = + | Cstr_tuple of type_expr list + | Cstr_record of label_declaration list -let rec equal - (x : Ext_json_types.t) - (y : Ext_json_types.t) = - match x with - | Null _ -> (* [%p? Null _ ] *) - begin match y with - | Null _ -> true - | _ -> false end - | Str {str } -> - begin match y with - | Str {str = str2} -> str = str2 - | _ -> false end - | Flo {flo} - -> - begin match y with - | Flo {flo = flo2} -> - flo = flo2 - | _ -> false - end - | True _ -> - begin match y with - | True _ -> true - | _ -> false - end - | False _ -> - begin match y with - | False _ -> true - | _ -> false - end - | Arr {content} - -> - begin match y with - | Arr {content = content2} - -> - Ext_array.for_all2_no_exn content content2 equal - | _ -> false - end +and unboxed_status = private + (* This type must be private in order to ensure perfect sharing of the + four possible values. Otherwise, ocamlc.byte and ocamlc.opt produce + different executables. *) + { + unboxed: bool; + default: bool; (* True for unannotated unboxable types. *) + } - | Obj {map} -> - begin match y with - | Obj { map = map2} -> - String_map.equal map map2 equal - | _ -> false - end +val unboxed_false_default_false : unboxed_status +val unboxed_false_default_true : unboxed_status +val unboxed_true_default_false : unboxed_status +val unboxed_true_default_true : unboxed_status +type extension_constructor = + { + ext_type_path: Path.t; + ext_type_params: type_expr list; + ext_args: constructor_arguments; + ext_ret_type: type_expr option; + ext_private: private_flag; + ext_loc: Location.t; + ext_attributes: Parsetree.attributes; + } -end -module Bsb_exception : sig -#1 "bsb_exception.mli" -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +and type_transparence = + Type_public (* unrestricted expansion *) + | Type_new (* "new" type *) + | Type_private (* private type *) +(* Type expressions for the class language *) -(** - This module is used for fatal errros -*) -type error -exception Error of error +module Concr : Set.S with type elt = string -val print : Format.formatter -> error -> unit -val package_not_found : pkg:Bsb_pkg_types.t -> json:string option -> 'a +type class_type = + Cty_constr of Path.t * type_expr list * class_type + | Cty_signature of class_signature + | Cty_arrow of arg_label * type_expr * class_type -val conflict_module: - string -> string -> string -> 'a - -val errorf : loc:Ext_position.t -> ('a, unit, string, 'b) format4 -> 'a +and class_signature = + { csig_self: type_expr; + csig_vars: + (Asttypes.mutable_flag * Asttypes.virtual_flag * type_expr) Vars.t; + csig_concr: Concr.t; + csig_inher: (Path.t * type_expr list) list } -val config_error : Ext_json_types.t -> string -> 'a +type class_declaration = + { cty_params: type_expr list; + mutable cty_type: class_type; + cty_path: Path.t; + cty_new: type_expr option; + cty_variance: Variance.t list; + cty_loc: Location.t; + cty_attributes: Parsetree.attributes; + } -val invalid_spec : string -> 'a +type class_type_declaration = + { clty_params: type_expr list; + clty_type: class_type; + clty_path: Path.t; + clty_variance: Variance.t list; + clty_loc: Location.t; + clty_attributes: Parsetree.attributes; + } -val invalid_json : string -> 'a +(* Type expressions for the module language *) -val no_implementation : string -> 'a +type module_type = + Mty_ident of Path.t + | Mty_signature of signature + | Mty_functor of Ident.t * module_type option * module_type + | Mty_alias of alias_presence * Path.t -val not_consistent : string -> 'a -end = struct -#1 "bsb_exception.ml" -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +and alias_presence = + | Mta_present + | Mta_absent +and signature = signature_item list +and signature_item = + Sig_value of Ident.t * value_description + | Sig_type of Ident.t * type_declaration * rec_status + | Sig_typext of Ident.t * extension_constructor * ext_status + | Sig_module of Ident.t * module_declaration * rec_status + | Sig_modtype of Ident.t * modtype_declaration + | Sig_class of Ident.t * class_declaration * rec_status + | Sig_class_type of Ident.t * class_type_declaration * rec_status -type error = - | Package_not_found of Bsb_pkg_types.t * string option (* json file *) - | Json_config of Ext_position.t * string - | Invalid_json of string - | Invalid_spec of string - | Conflict_module of string * string * string - | No_implementation of string - | Not_consistent of string +and module_declaration = + { + md_type: module_type; + md_attributes: Parsetree.attributes; + md_loc: Location.t; + } -exception Error of error +and modtype_declaration = + { + mtd_type: module_type option; (* None: abstract *) + mtd_attributes: Parsetree.attributes; + mtd_loc: Location.t; + } -let error err = raise (Error err) -let package_not_found ~pkg ~json = - error (Package_not_found(pkg,json)) +and rec_status = + Trec_not (* first in a nonrecursive group *) + | Trec_first (* first in a recursive group *) + | Trec_next (* not first in a recursive/nonrecursive group *) -let print (fmt : Format.formatter) (x : error) = - match x with - | Conflict_module (modname,dir1,dir2) -> - Format.fprintf fmt - "@{Error:@} %s found in two directories: (%s, %s)\n\ - File names must be unique per project" - modname dir1 dir2 - | Not_consistent modname -> - Format.fprintf fmt - "@{Error:@} %s has implementation/interface in non-consistent syntax(reason/ocaml)" modname - | No_implementation (modname) -> - Format.fprintf fmt - "@{Error:@} %s does not have implementation file" modname - | Package_not_found (name,json_opt) -> - let in_json = match json_opt with - | None -> Ext_string.empty - | Some x -> " in " ^ x in - let name = Bsb_pkg_types.to_string name in - if Ext_string.equal name Bs_version.package_name then - Format.fprintf fmt - "File \"bsconfig.json\", line 1\n\ - @{Error:@} package @{bs-platform@} is not found %s\n\ - It's the basic, required package. If you have it installed globally,\n\ - Please run `npm link bs-platform` to make it available" in_json - else - Format.fprintf fmt - "File \"bsconfig.json\", line 1\n\ - @{Error:@} package @{%s@} not found or built %s\n\ - - Did you install it?\n\ - - If you did, did you run `bsb -make-world`?" - name - in_json +and ext_status = + Text_first (* first constructor in an extension *) + | Text_next (* not first constructor in an extension *) + | Text_exception - | Json_config (pos,s) -> - Format.fprintf fmt "File \"bsconfig.json\", line %d:\n\ - @{Error:@} %s \n\ - For more details, please checkout the schema http://bucklescript.github.io/bucklescript/docson/#build-schema.json" - pos.pos_lnum s - | Invalid_spec s -> - Format.fprintf fmt - "@{Error: Invalid bsconfig.json %s@}" s - | Invalid_json s -> - Format.fprintf fmt - "File %S, line 1\n\ - @{Error: Invalid json format@}" s -let conflict_module modname dir1 dir2 = - error (Conflict_module (modname,dir1,dir2)) -let no_implementation modname = - error (No_implementation modname) -let not_consistent modname = - error (Not_consistent modname) -let errorf ~loc fmt = - Format.ksprintf (fun s -> error (Json_config (loc,s))) fmt +(* Constructor and record label descriptions inserted held in typing + environments *) +type constructor_description = + { cstr_name: string; (* Constructor name *) + cstr_res: type_expr; (* Type of the result *) + cstr_existentials: type_expr list; (* list of existentials *) + cstr_args: type_expr list; (* Type of the arguments *) + cstr_arity: int; (* Number of arguments *) + cstr_tag: constructor_tag; (* Tag for heap blocks *) + cstr_consts: int; (* Number of constant constructors *) + cstr_nonconsts: int; (* Number of non-const constructors *) + cstr_normal: int; (* Number of non generalized constrs *) + cstr_generalized: bool; (* Constrained return type? *) + cstr_private: private_flag; (* Read-only constructor? *) + cstr_loc: Location.t; + cstr_attributes: Parsetree.attributes; + cstr_inlined: type_declaration option; + } -let config_error config fmt = - let loc = Ext_json.loc_of config in +and constructor_tag = + Cstr_constant of int (* Constant constructor (an int) *) + | Cstr_block of int (* Regular constructor (a block) *) + | Cstr_unboxed (* Constructor of an unboxed type *) + | Cstr_extension of Path.t * bool (* Extension constructor + true if a constant false if a block*) - error (Json_config (loc,fmt)) +(* Constructors are the same *) +val equal_tag : constructor_tag -> constructor_tag -> bool -let invalid_spec s = error (Invalid_spec s) +(* Constructors may be the same, given potential rebinding *) +val may_equal_constr : + constructor_description -> constructor_description -> bool -let invalid_json s = error (Invalid_json s) +type label_description = + { lbl_name: string; (* Short name *) + lbl_res: type_expr; (* Type of the result *) + lbl_arg: type_expr; (* Type of the argument *) + lbl_mut: mutable_flag; (* Is this a mutable field? *) + lbl_pos: int; (* Position in block *) + lbl_all: label_description array; (* All the labels in this type *) + lbl_repres: record_representation; (* Representation for this record *) + lbl_private: private_flag; (* Read-only field? *) + lbl_loc: Location.t; + lbl_attributes: Parsetree.attributes; + } -let () = - Printexc.register_printer (fun x -> - match x with - | Error x -> - Some (Format.asprintf "%a" print x ) - | _ -> None - ) +end = struct +#1 "types.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -end -module Bsb_warning : sig -#1 "bsb_warning.mli" -(* Copyright (C) 2017 Authors of BuckleScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +(* Representation of types and declarations *) +open Asttypes +(* Type expressions for the core language *) +type type_expr = + { mutable desc: type_desc; + mutable level: int; + id: int } -type t +and type_desc = + Tvar of string option + | Tarrow of arg_label * type_expr * type_expr * commutable + | Ttuple of type_expr list + | Tconstr of Path.t * type_expr list * abbrev_memo ref + | Tobject of type_expr * (Path.t * type_expr list) option ref + | Tfield of string * field_kind * type_expr * type_expr + | Tnil + | Tlink of type_expr + | Tsubst of type_expr (* for copying *) + | Tvariant of row_desc + | Tunivar of string option + | Tpoly of type_expr * type_expr list + | Tpackage of Path.t * Longident.t list * type_expr list -val get_warning_flag : t option -> string +and row_desc = + { row_fields: (label * row_field) list; + row_more: type_expr; + row_bound: unit; + row_closed: bool; + row_fixed: bool; + row_name: (Path.t * type_expr list) option } -val default_warning : string +and row_field = + Rpresent of type_expr option + | Reither of bool * type_expr list * bool * row_field option ref + (* 1st true denotes a constant constructor *) + (* 2nd true denotes a tag in a pattern matching, and + is erased later *) + | Rabsent -val default_warning_flag : string -(* default_warning, including the -w prefix, for command-line arguments *) +and abbrev_memo = + Mnil + | Mcons of private_flag * Path.t * type_expr * type_expr * abbrev_memo + | Mlink of abbrev_memo ref -val from_map : Ext_json_types.t String_map.t -> t option +and field_kind = + Fvar of field_kind option ref + | Fpresent + | Fabsent -(** [opt_warning_to_string not_dev warning] -*) -val opt_warning_to_string : - toplevel:bool -> - t option -> - string +and commutable = + Cok + | Cunknown + | Clink of commutable ref +module TypeOps = struct + type t = type_expr + let compare t1 t2 = t1.id - t2.id + let hash t = t.id + let equal t1 t2 = t1 == t2 +end -end = struct -#1 "bsb_warning.ml" -(* Copyright (C) 2017 Authors of BuckleScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +(* Maps of methods and instance variables *) +module OrderedString = + struct type t = string let compare (x:t) y = compare x y end +module Meths = Map.Make(OrderedString) +module Vars = Meths -type warning_error = - | Warn_error_false - (* default [false] to make our changes non-intrusive *) - | Warn_error_true - | Warn_error_number of string +(* Value descriptions *) -type t = { - number : string option; - error : warning_error -} +type value_description = + { val_type: type_expr; (* Type of the value *) + val_kind: value_kind; + val_loc: Location.t; + val_attributes: Parsetree.attributes; + } -(** - See the meanings of the warning codes here: https://caml.inria.fr/pub/docs/manual-ocaml/comp.html#sec281 +and value_kind = + Val_reg (* Regular value *) + | Val_prim of Primitive.description (* Primitive *) + | Val_ivar of mutable_flag * string (* Instance variable (mutable ?) *) + | Val_self of (Ident.t * type_expr) Meths.t ref * + (Ident.t * Asttypes.mutable_flag * + Asttypes.virtual_flag * type_expr) Vars.t ref * + string * type_expr + (* Self *) + | Val_anc of (string * Ident.t) list * string + (* Ancestor *) + | Val_unbound (* Unbound variable *) - - 30 Two labels or constructors of the same name are defined in two mutually recursive types. - - 40 Constructor or label name used out of scope. +(* Variance *) - - 6 Label omitted in function application. - - 7 Method overridden. - - 9 Missing fields in a record pattern. (*Not always desired, in some cases need [@@@warning "+9"] *) - - 27 Innocuous unused variable: unused variable that is not bound with let nor as, and doesn’t start with an underscore (_) character. - - 29 Unescaped end-of-line in a string constant (non-portable code). - - 32 .. 39 Unused blabla - - 44 Open statement shadows an already defined identifier. - - 45 Open statement shadows an already defined label or constructor. - - 48 Implicit elimination of optional arguments. https://caml.inria.fr/mantis/view.php?id=6352 - - 101 (bsb-specific) unsafe polymorphic comparison. -*) -let default_warning = "-30-40+6+7+27+32..39+44+45+101" +module Variance = struct + type t = int + type f = May_pos | May_neg | May_weak | Inj | Pos | Neg | Inv + let single = function + | May_pos -> 1 + | May_neg -> 2 + | May_weak -> 4 + | Inj -> 8 + | Pos -> 16 + | Neg -> 32 + | Inv -> 64 + let union v1 v2 = v1 lor v2 + let inter v1 v2 = v1 land v2 + let subset v1 v2 = (v1 land v2 = v1) + let set x b v = + if b then v lor single x else v land (lnot (single x)) + let mem x = subset (single x) + let null = 0 + let may_inv = 7 + let full = 127 + let covariant = single May_pos lor single Pos lor single Inj + let swap f1 f2 v = + let v' = set f1 (mem f2 v) v in set f2 (mem f1 v) v' + let conjugate v = swap May_pos May_neg (swap Pos Neg v) + let get_upper v = (mem May_pos v, mem May_neg v) + let get_lower v = (mem Pos v, mem Neg v, mem Inv v, mem Inj v) +end -let default_warning_flag = "-w " ^ default_warning +(* Type definitions *) -let get_warning_flag x = - default_warning_flag ^ - (match x with - | Some {number =None} - | None -> Ext_string.empty - | Some {number = Some x} -> Ext_string.trim x ) +type type_declaration = + { type_params: type_expr list; + type_arity: int; + type_kind: type_kind; + type_private: private_flag; + type_manifest: type_expr option; + type_variance: Variance.t list; + type_newtype_level: (int * int) option; + type_loc: Location.t; + type_attributes: Parsetree.attributes; + type_immediate: bool; + type_unboxed: unboxed_status; + } +and type_kind = + Type_abstract + | Type_record of label_declaration list * record_representation + | Type_variant of constructor_declaration list + | Type_open -let warn_error = " -warn-error A" +and record_representation = + Record_regular (* All fields are boxed / tagged *) + | Record_float (* All fields are floats *) + | Record_unboxed of bool (* Unboxed single-field record, inlined or not *) + | Record_inlined of {tag : int; name : string; num_nonconsts : int} (* Inlined record *) + | Record_extension (* Inlined record under extension *) -let warning_to_string ~toplevel - warning : string = - default_warning_flag ^ - (match warning.number with - | None -> - Ext_string.empty - | Some x -> - let content = - Ext_string.trim x in - if content = "" then content - else - match content.[0] with - | '0' .. '9' -> "+" ^ content - | _ -> content - ) ^ - if toplevel then - match warning.error with - | Warn_error_true -> - warn_error +and label_declaration = + { + ld_id: Ident.t; + ld_mutable: mutable_flag; + ld_type: type_expr; + ld_loc: Location.t; + ld_attributes: Parsetree.attributes; + } - | Warn_error_number y -> - " -warn-error " ^ y - | Warn_error_false -> - Ext_string.empty - else Ext_string.empty +and constructor_declaration = + { + cd_id: Ident.t; + cd_args: constructor_arguments; + cd_res: type_expr option; + cd_loc: Location.t; + cd_attributes: Parsetree.attributes; + } +and constructor_arguments = + | Cstr_tuple of type_expr list + | Cstr_record of label_declaration list +and unboxed_status = + { + unboxed: bool; + default: bool; (* False if the unboxed field was set from an attribute. *) + } -let from_map (m : Ext_json_types.t String_map.t) = - let number_opt = String_map.find_opt m Bsb_build_schemas.number in - let error_opt = String_map.find_opt m Bsb_build_schemas.error in - match number_opt, error_opt with - | None, None -> None - | _, _ -> - let error = - match error_opt with - | Some (True _) -> Warn_error_true - | Some (False _) -> Warn_error_false - | Some (Str {str ; }) - -> Warn_error_number str - | Some x -> Bsb_exception.config_error x "expect true/false or string" - | None -> Warn_error_false - (** To make it less intrusive : warning error has to be enabled*) - in - let number = - match number_opt with - | Some (Str { str = number}) -> Some number - | None -> None - | Some x -> Bsb_exception.config_error x "expect a string" - in - Some {number; error } +let unboxed_false_default_false = {unboxed = false; default = false} +let unboxed_false_default_true = {unboxed = false; default = true} +let unboxed_true_default_false = {unboxed = true; default = false} +let unboxed_true_default_true = {unboxed = true; default = true} -let opt_warning_to_string ~toplevel warning = - match warning with - | None -> default_warning_flag - | Some w -> warning_to_string ~toplevel w +type extension_constructor = + { ext_type_path: Path.t; + ext_type_params: type_expr list; + ext_args: constructor_arguments; + ext_ret_type: type_expr option; + ext_private: private_flag; + ext_loc: Location.t; + ext_attributes: Parsetree.attributes; } +and type_transparence = + Type_public (* unrestricted expansion *) + | Type_new (* "new" type *) + | Type_private (* private type *) -end -module Ccomp : sig -#1 "ccomp.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +(* Type expressions for the class language *) -(* Compiling C files and building C libraries *) +module Concr = Set.Make(OrderedString) -val command: string -> int -val run_command: string -> unit -val compile_file: ?output:string -> ?opt:string -> string -> int -val create_archive: string -> string list -> int -val expand_libname: string -> string -val quote_files: string list -> string -val quote_optfile: string option -> string -(*val make_link_options: string list -> string*) +type class_type = + Cty_constr of Path.t * type_expr list * class_type + | Cty_signature of class_signature + | Cty_arrow of arg_label * type_expr * class_type -type link_mode = - | Exe - | Dll - | MainDll - | Partial +and class_signature = + { csig_self: type_expr; + csig_vars: + (Asttypes.mutable_flag * Asttypes.virtual_flag * type_expr) Vars.t; + csig_concr: Concr.t; + csig_inher: (Path.t * type_expr list) list } -val call_linker: link_mode -> string -> string list -> string -> bool +type class_declaration = + { cty_params: type_expr list; + mutable cty_type: class_type; + cty_path: Path.t; + cty_new: type_expr option; + cty_variance: Variance.t list; + cty_loc: Location.t; + cty_attributes: Parsetree.attributes; + } -end = struct -#1 "ccomp.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +type class_type_declaration = + { clty_params: type_expr list; + clty_type: class_type; + clty_path: Path.t; + clty_variance: Variance.t list; + clty_loc: Location.t; + clty_attributes: Parsetree.attributes; + } -(* Compiling C files and building C libraries *) +(* Type expressions for the module language *) -let command cmdline = - if !Clflags.verbose then begin - prerr_string "+ "; - prerr_string cmdline; - prerr_newline() - end; - Sys.command cmdline +type module_type = + Mty_ident of Path.t + | Mty_signature of signature + | Mty_functor of Ident.t * module_type option * module_type + | Mty_alias of alias_presence * Path.t -let run_command cmdline = ignore(command cmdline) +and alias_presence = + | Mta_present + | Mta_absent -(* Build @responsefile to work around Windows limitations on - command-line length *) -let build_diversion lst = - let (responsefile, oc) = Filename.open_temp_file "camlresp" "" in - List.iter (fun f -> Printf.fprintf oc "%s\n" f) lst; - close_out oc; - at_exit (fun () -> Misc.remove_file responsefile); - "@" ^ responsefile +and signature = signature_item list -let quote_files lst = - let lst = List.filter (fun f -> f <> "") lst in - let quoted = List.map Filename.quote lst in - let s = String.concat " " quoted in - if String.length s >= 4096 && Sys.os_type = "Win32" - then build_diversion quoted - else s +and signature_item = + Sig_value of Ident.t * value_description + | Sig_type of Ident.t * type_declaration * rec_status + | Sig_typext of Ident.t * extension_constructor * ext_status + | Sig_module of Ident.t * module_declaration * rec_status + | Sig_modtype of Ident.t * modtype_declaration + | Sig_class of Ident.t * class_declaration * rec_status + | Sig_class_type of Ident.t * class_type_declaration * rec_status -let quote_prefixed pr lst = - let lst = List.filter (fun f -> f <> "") lst in - let lst = List.map (fun f -> pr ^ f) lst in - quote_files lst +and module_declaration = + { + md_type: module_type; + md_attributes: Parsetree.attributes; + md_loc: Location.t; + } -let quote_optfile = function - | None -> "" - | Some f -> Filename.quote f +and modtype_declaration = + { + mtd_type: module_type option; (* Note: abstract *) + mtd_attributes: Parsetree.attributes; + mtd_loc: Location.t; + } -let display_msvc_output file name = - let c = open_in file in - try - let first = input_line c in - if first <> Filename.basename name then - print_string first; - while true do - print_string (input_line c) - done - with _ -> - close_in c; - Sys.remove file +and rec_status = + Trec_not (* first in a nonrecursive group *) + | Trec_first (* first in a recursive group *) + | Trec_next (* not first in a recursive/nonrecursive group *) -let compile_file ?output ?(opt="") name = - let (pipe, file) = - if Config.ccomp_type = "msvc" && not !Clflags.verbose then - try - let (t, c) = Filename.open_temp_file "msvc" "stdout" in - close_out c; - (Printf.sprintf " > %s" (Filename.quote t), t) - with _ -> - ("", "") - else - ("", "") in - let exit = - command - (Printf.sprintf - "%s %s %s -c %s %s %s %s %s%s" - (match !Clflags.c_compiler with - | Some cc -> cc - | None -> - let (cflags, cppflags) = - if !Clflags.native_code - then (Config.ocamlopt_cflags, Config.ocamlopt_cppflags) - else (Config.ocamlc_cflags, Config.ocamlc_cppflags) in - (String.concat " " [Config.c_compiler; cflags; cppflags])) - (match output with - | None -> "" - | Some o -> Printf.sprintf "%s%s" Config.c_output_obj o) - opt - (if !Clflags.debug && Config.ccomp_type <> "msvc" then "-g" else "") - (String.concat " " (List.rev !Clflags.all_ccopts)) - (quote_prefixed "-I" (List.rev !Clflags.include_dirs)) - (Clflags.std_include_flag "-I") - (Filename.quote name) - (* cl tediously includes the name of the C file as the first thing it - outputs (in fairness, the tedious thing is that there's no switch to - disable this behaviour). In the absence of the Unix module, use - a temporary file to filter the output (cannot pipe the output to a - filter because this removes the exit status of cl, which is wanted. - *) - pipe) in - if pipe <> "" - then display_msvc_output file name; - exit +and ext_status = + Text_first (* first constructor of an extension *) + | Text_next (* not first constructor of an extension *) + | Text_exception (* an exception *) -let macos_create_empty_archive ~quoted_archive = - let result = - command (Printf.sprintf "%s rc %s /dev/null" Config.ar quoted_archive) - in - if result <> 0 then result - else - let result = - command (Printf.sprintf "%s %s 2> /dev/null" Config.ranlib quoted_archive) - in - if result <> 0 then result - else - command (Printf.sprintf "%s d %s /dev/null" Config.ar quoted_archive) -let create_archive archive file_list = - Misc.remove_file archive; - let quoted_archive = Filename.quote archive in - match Config.ccomp_type with - "msvc" -> - command(Printf.sprintf "link /lib /nologo /out:%s %s" - quoted_archive (quote_files file_list)) - | _ -> - assert(String.length Config.ar > 0); - let is_macosx = - match Config.system with - | "macosx" -> true - | _ -> false - in - if is_macosx && file_list = [] then (* PR#6550 *) - macos_create_empty_archive ~quoted_archive - else - let r1 = - command(Printf.sprintf "%s rc %s %s" - Config.ar quoted_archive (quote_files file_list)) in - if r1 <> 0 || String.length Config.ranlib = 0 - then r1 - else command(Config.ranlib ^ " " ^ quoted_archive) +(* Constructor and record label descriptions inserted held in typing + environments *) -let expand_libname name = - if String.length name < 2 || String.sub name 0 2 <> "-l" - then name - else begin - let libname = - "lib" ^ String.sub name 2 (String.length name - 2) ^ Config.ext_lib in - try - Misc.find_in_path !Config.load_path libname - with Not_found -> - libname - end +type constructor_description = + { cstr_name: string; (* Constructor name *) + cstr_res: type_expr; (* Type of the result *) + cstr_existentials: type_expr list; (* list of existentials *) + cstr_args: type_expr list; (* Type of the arguments *) + cstr_arity: int; (* Number of arguments *) + cstr_tag: constructor_tag; (* Tag for heap blocks *) + cstr_consts: int; (* Number of constant constructors *) + cstr_nonconsts: int; (* Number of non-const constructors *) + cstr_normal: int; (* Number of non generalized constrs *) + cstr_generalized: bool; (* Constrained return type? *) + cstr_private: private_flag; (* Read-only constructor? *) + cstr_loc: Location.t; + cstr_attributes: Parsetree.attributes; + cstr_inlined: type_declaration option; + } -type link_mode = - | Exe - | Dll - | MainDll - | Partial +and constructor_tag = + Cstr_constant of int (* Constant constructor (an int) *) + | Cstr_block of int (* Regular constructor (a block) *) + | Cstr_unboxed (* Constructor of an unboxed type *) + | Cstr_extension of Path.t * bool (* Extension constructor + true if a constant false if a block*) + +let equal_tag t1 t2 = + match (t1, t2) with + | Cstr_constant i1, Cstr_constant i2 -> i2 = i1 + | Cstr_block i1, Cstr_block i2 -> i2 = i1 + | Cstr_unboxed, Cstr_unboxed -> true + | Cstr_extension (path1, b1), Cstr_extension (path2, b2) -> + Path.same path1 path2 && b1 = b2 + | (Cstr_constant _|Cstr_block _|Cstr_unboxed|Cstr_extension _), _ -> false -let remove_Wl cclibs = - cclibs |> List.map (fun cclib -> - (* -Wl,-foo,bar -> -foo bar *) - if String.length cclib >= 4 && "-Wl," = String.sub cclib 0 4 then - String.map (function ',' -> ' ' | c -> c) - (String.sub cclib 4 (String.length cclib - 4)) - else cclib) +let may_equal_constr c1 c2 = match c1.cstr_tag,c2.cstr_tag with +| Cstr_extension _,Cstr_extension _ -> c1.cstr_arity = c2.cstr_arity +| tag1,tag2 -> equal_tag tag1 tag2 -let call_linker mode output_name files extra = - let cmd = - if mode = Partial then - let l_prefix = - match Config.ccomp_type with - | "msvc" -> "/libpath:" - | _ -> "-L" - in - Printf.sprintf "%s%s %s %s %s" - Config.native_pack_linker - (Filename.quote output_name) - (quote_prefixed l_prefix !Config.load_path) - (quote_files (remove_Wl files)) - extra - else - Printf.sprintf "%s -o %s %s %s %s %s %s %s" - (match !Clflags.c_compiler, mode with - | Some cc, _ -> cc - | None, Exe -> Config.mkexe - | None, Dll -> Config.mkdll - | None, MainDll -> Config.mkmaindll - | None, Partial -> assert false - ) - (Filename.quote output_name) - (if !Clflags.gprofile then Config.cc_profile else "") - "" (*(Clflags.std_include_flag "-I")*) - (quote_prefixed "-L" !Config.load_path) - (String.concat " " (List.rev !Clflags.all_ccopts)) - (quote_files files) - extra - in - command cmd = 0 +type label_description = + { lbl_name: string; (* Short name *) + lbl_res: type_expr; (* Type of the result *) + lbl_arg: type_expr; (* Type of the argument *) + lbl_mut: mutable_flag; (* Is this a mutable field? *) + lbl_pos: int; (* Position in block *) + lbl_all: label_description array; (* All the labels in this type *) + lbl_repres: record_representation; (* Representation for this record *) + lbl_private: private_flag; (* Read-only field? *) + lbl_loc: Location.t; + lbl_attributes: Parsetree.attributes; + } end -module Compenv : sig -#1 "compenv.mli" +module Btype : sig +#1 "btype.mli" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Fabrice Le Fessant, EPI Gallium, INRIA Paris-Rocquencourt *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) (* *) -(* Copyright 2013 Institut National de Recherche en Informatique et *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -45351,79 +27651,222 @@ module Compenv : sig (* *) (**************************************************************************) -val module_of_filename : Format.formatter -> string -> string -> string +(* Basic operations on core types *) -val output_prefix : string -> string -val extract_output : string option -> string -val default_output : string option -> string +open Asttypes +open Types -val print_version_and_library : string -> 'a -val print_version_string : unit -> 'a -val print_standard_library : unit -> 'a -val fatal : string -> 'a +(**** Sets, maps and hashtables of types ****) -val first_ccopts : string list ref -val first_ppx : string list ref -val first_include_dirs : string list ref -val last_include_dirs : string list ref -val implicit_modules : string list ref +module TypeSet : Set.S with type elt = type_expr +module TypeMap : Map.S with type key = type_expr +module TypeHash : Hashtbl.S with type key = type_expr -(* function to call on plugin=XXX *) -val load_plugin : (string -> unit) ref +(**** Levels ****) -(* return the list of objfiles, after OCAMLPARAM and List.rev *) -val get_objfiles : with_ocamlparam:bool -> string list -val last_objfiles : string list ref -val first_objfiles : string list ref +val generic_level: int -type filename = string +val newty2: int -> type_desc -> type_expr + (* Create a type *) +val newgenty: type_desc -> type_expr + (* Create a generic type *) +val newgenvar: ?name:string -> unit -> type_expr + (* Return a fresh generic variable *) -type readenv_position = - Before_args | Before_compile of filename | Before_link +(* Use Tsubst instead +val newmarkedvar: int -> type_expr + (* Return a fresh marked variable *) +val newmarkedgenvar: unit -> type_expr + (* Return a fresh marked generic variable *) +*) -val readenv : Format.formatter -> readenv_position -> unit +(**** Types ****) -(* [is_unit_name name] returns true only if [name] can be used as a - correct module name *) -val is_unit_name : string -> bool -(* [check_unit_name ppf filename name] prints a warning in [filename] - on [ppf] if [name] should not be used as a module name. *) -val check_unit_name : Format.formatter -> string -> string -> unit +val is_Tvar: type_expr -> bool +val is_Tunivar: type_expr -> bool +val is_Tconstr: type_expr -> bool +val dummy_method: label +val default_mty: module_type option -> module_type -(* Deferred actions of the compiler, while parsing arguments *) +val repr: type_expr -> type_expr + (* Return the canonical representative of a type. *) -type deferred_action = - | ProcessImplementation of string - | ProcessInterface of string - | ProcessCFile of string - | ProcessOtherFile of string - | ProcessObjects of string list - | ProcessDLLs of string list +val field_kind_repr: field_kind -> field_kind + (* Return the canonical representative of an object field + kind. *) -val c_object_of_filename : string -> string +val commu_repr: commutable -> commutable + (* Return the canonical representative of a commutation lock *) -val defer : deferred_action -> unit -val anonymous : string -> unit -val impl : string -> unit -val intf : string -> unit +(**** polymorphic variants ****) -val process_deferred_actions : - Format.formatter * - (Format.formatter -> string -> string -> unit) * (* compile implementation *) - (Format.formatter -> string -> string -> unit) * (* compile interface *) - string * (* ocaml module extension *) - string -> (* ocaml library extension *) - unit +val row_repr: row_desc -> row_desc + (* Return the canonical representative of a row description *) +val row_field_repr: row_field -> row_field +val row_field: label -> row_desc -> row_field + (* Return the canonical representative of a row field *) +val row_more: row_desc -> type_expr + (* Return the extension variable of the row *) +val row_fixed: row_desc -> bool + (* Return whether the row should be treated as fixed or not *) +val static_row: row_desc -> bool + (* Return whether the row is static or not *) +val hash_variant: label -> int + (* Hash function for variant tags *) + +val proxy: type_expr -> type_expr + (* Return the proxy representative of the type: either itself + or a row variable *) + +(**** Utilities for private abbreviations with fixed rows ****) +val row_of_type: type_expr -> type_expr +val has_constr_row: type_expr -> bool +val is_row_name: string -> bool +val is_constr_row: allow_ident:bool -> type_expr -> bool + +(**** Utilities for type traversal ****) + +val iter_type_expr: (type_expr -> unit) -> type_expr -> unit + (* Iteration on types *) +val iter_row: (type_expr -> unit) -> row_desc -> unit + (* Iteration on types in a row *) +val iter_abbrev: (type_expr -> unit) -> abbrev_memo -> unit + (* Iteration on types in an abbreviation list *) + +type type_iterators = + { it_signature: type_iterators -> signature -> unit; + it_signature_item: type_iterators -> signature_item -> unit; + it_value_description: type_iterators -> value_description -> unit; + it_type_declaration: type_iterators -> type_declaration -> unit; + it_extension_constructor: type_iterators -> extension_constructor -> unit; + it_module_declaration: type_iterators -> module_declaration -> unit; + it_modtype_declaration: type_iterators -> modtype_declaration -> unit; + it_class_declaration: type_iterators -> class_declaration -> unit; + it_class_type_declaration: type_iterators -> class_type_declaration -> unit; + it_module_type: type_iterators -> module_type -> unit; + it_class_type: type_iterators -> class_type -> unit; + it_type_kind: type_iterators -> type_kind -> unit; + it_do_type_expr: type_iterators -> type_expr -> unit; + it_type_expr: type_iterators -> type_expr -> unit; + it_path: Path.t -> unit; } +val type_iterators: type_iterators + (* Iteration on arbitrary type information. + [it_type_expr] calls [mark_type_node] to avoid loops. *) +val unmark_iterators: type_iterators + (* Unmark any structure containing types. See [unmark_type] below. *) + +val copy_type_desc: + ?keep_names:bool -> (type_expr -> type_expr) -> type_desc -> type_desc + (* Copy on types *) +val copy_row: + (type_expr -> type_expr) -> + bool -> row_desc -> bool -> type_expr -> row_desc +val copy_kind: field_kind -> field_kind + +val save_desc: type_expr -> type_desc -> unit + (* Save a type description *) +val dup_kind: field_kind option ref -> unit + (* Save a None field_kind, and make it point to a fresh Fvar *) +val cleanup_types: unit -> unit + (* Restore type descriptions *) + +val lowest_level: int + (* Marked type: ty.level < lowest_level *) +val pivot_level: int + (* Type marking: ty.level <- pivot_level - ty.level *) +val mark_type: type_expr -> unit + (* Mark a type *) +val mark_type_node: type_expr -> unit + (* Mark a type node (but not its sons) *) +val mark_type_params: type_expr -> unit + (* Mark the sons of a type node *) +val unmark_type: type_expr -> unit +val unmark_type_decl: type_declaration -> unit +val unmark_extension_constructor: extension_constructor -> unit +val unmark_class_type: class_type -> unit +val unmark_class_signature: class_signature -> unit + (* Remove marks from a type *) + +(**** Memorization of abbreviation expansion ****) + +val find_expans: private_flag -> Path.t -> abbrev_memo -> type_expr option + (* Look up a memorized abbreviation *) +val cleanup_abbrev: unit -> unit + (* Flush the cache of abbreviation expansions. + When some types are saved (using [output_value]), this + function MUST be called just before. *) +val memorize_abbrev: + abbrev_memo ref -> + private_flag -> Path.t -> type_expr -> type_expr -> unit + (* Add an expansion in the cache *) +val forget_abbrev: + abbrev_memo ref -> Path.t -> unit + (* Remove an abbreviation from the cache *) + +(**** Utilities for labels ****) + +val is_optional : arg_label -> bool +val label_name : arg_label -> label + +(* Returns the label name with first character '?' or '~' as appropriate. *) +val prefixed_label_name : arg_label -> label + +val extract_label : + label -> (arg_label * 'a) list -> + arg_label * 'a * (arg_label * 'a) list * (arg_label * 'a) list + (* actual label, value, before list, after list *) + +(**** Utilities for backtracking ****) + +type snapshot + (* A snapshot for backtracking *) +val snapshot: unit -> snapshot + (* Make a snapshot for later backtracking. Costs nothing *) +val backtrack: snapshot -> unit + (* Backtrack to a given snapshot. Only possible if you have + not already backtracked to a previous snapshot. + Calls [cleanup_abbrev] internally *) +val undo_compress: snapshot -> unit + (* Backtrack only path compression. Only meaningful if you have + not already backtracked to a previous snapshot. + Does not call [cleanup_abbrev] *) + +(* Functions to use when modifying a type (only Ctype?) *) +val link_type: type_expr -> type_expr -> unit + (* Set the desc field of [t1] to [Tlink t2], logging the old + value if there is an active snapshot *) +val set_level: type_expr -> int -> unit +val set_name: + (Path.t * type_expr list) option ref -> + (Path.t * type_expr list) option -> unit +val set_row_field: row_field option ref -> row_field -> unit +val set_univar: type_expr option ref -> type_expr -> unit +val set_kind: field_kind option ref -> field_kind -> unit +val set_commu: commutable ref -> commutable -> unit +val set_typeset: TypeSet.t ref -> TypeSet.t -> unit + (* Set references, logging the old value *) +val log_type: type_expr -> unit + (* Log the old value of a type, before modifying it by hand *) + +(**** Forward declarations ****) +val print_raw: (Format.formatter -> type_expr -> unit) ref + +val iter_type_expr_kind: (type_expr -> unit) -> (type_kind -> unit) + +val iter_type_expr_cstr_args: (type_expr -> unit) -> + (constructor_arguments -> unit) +val map_type_expr_cstr_args: (type_expr -> type_expr) -> + (constructor_arguments -> constructor_arguments) end = struct -#1 "compenv.ml" +#1 "btype.ml" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Fabrice Le Fessant, EPI Gallium, INRIA Paris-Rocquencourt *) +(* Xavier Leroy and Jerome Vouillon, projet Cristal, INRIA Rocquencourt *) (* *) -(* Copyright 2013 Institut National de Recherche en Informatique et *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -45432,721 +27875,739 @@ end = struct (* *) (**************************************************************************) -open Clflags +(* Basic operations on core types *) -let output_prefix name = - let oname = - match !output_name with - | None -> name - | Some n -> if !compile_only then (output_name := None; n) else name in - Filename.remove_extension oname +open Misc +open Asttypes +open Types -let print_version_and_library compiler = - Printf.printf "The OCaml %s, version " compiler; - print_string Config.version; print_newline(); - print_string "Standard library directory: "; - print_string Config.standard_library; print_newline(); - exit 0 +(**** Sets, maps and hashtables of types ****) -let print_version_string () = - print_string Config.version; print_newline(); exit 0 +module TypeSet = Set.Make(TypeOps) +module TypeMap = Map.Make (TypeOps) +module TypeHash = Hashtbl.Make(TypeOps) -let print_standard_library () = - print_string Config.standard_library; print_newline(); exit 0 +(**** Forward declarations ****) -let fatal err = - prerr_endline err; - exit 2 +let print_raw = + ref (fun _ -> assert false : Format.formatter -> type_expr -> unit) -let extract_output = function - | Some s -> s - | None -> - fatal "Please specify the name of the output file, using option -o" +(**** Type level management ****) -let default_output = function - | Some s -> s - | None -> Config.default_executable_name +let generic_level = 100000000 -let implicit_modules = ref [] -let first_include_dirs = ref [] -let last_include_dirs = ref [] -let first_ccopts = ref [] -let last_ccopts = ref [] -let first_ppx = ref [] -let last_ppx = ref [] -let first_objfiles = ref [] -let last_objfiles = ref [] +(* Used to mark a type during a traversal. *) +let lowest_level = 0 +let pivot_level = 2 * lowest_level - 1 + (* pivot_level - lowest_level < lowest_level *) -(* Check validity of module name *) -let is_unit_name name = - try - if name = "" then raise Exit; - begin match name.[0] with - | 'A'..'Z' -> () - | _ -> - raise Exit; - end; - for i = 1 to String.length name - 1 do - match name.[i] with - | 'A'..'Z' | 'a'..'z' | '0'..'9' | '_' | '\'' -> () - | _ -> - raise Exit; - done; - true - with Exit -> false -;; +(**** Some type creators ****) -let check_unit_name ppf filename name = +let new_id = ref (-1) - let _ = ppf in - let _ = filename in - let _ = name in - () +let newty2 level desc = + incr new_id; { desc; level; id = !new_id } +let newgenty desc = newty2 generic_level desc +let newgenvar ?name () = newgenty (Tvar name) +(* +let newmarkedvar level = + incr new_id; { desc = Tvar; level = pivot_level - level; id = !new_id } +let newmarkedgenvar () = + incr new_id; + { desc = Tvar; level = pivot_level - generic_level; id = !new_id } +*) +(**** Check some types ****) -(* Compute name of module from output file name *) -let module_of_filename ppf inputfile outputprefix = - let basename = Filename.basename outputprefix in - let name = - try - let pos = String.index basename '.' in - String.sub basename 0 pos - with Not_found -> basename - in - let name = String.capitalize_ascii name in - check_unit_name ppf inputfile name; - name -;; +let is_Tvar = function {desc=Tvar _} -> true | _ -> false +let is_Tunivar = function {desc=Tunivar _} -> true | _ -> false +let is_Tconstr = function {desc=Tconstr _} -> true | _ -> false -type filename = string +let dummy_method = "*dummy method*" +let default_mty = function + Some mty -> mty + | None -> Mty_signature [] -type readenv_position = - Before_args | Before_compile of filename | Before_link +(**** Definitions for backtracking ****) + +type change = + Ctype of type_expr * type_desc + | Ccompress of type_expr * type_desc * type_desc + | Clevel of type_expr * int + | Cname of + (Path.t * type_expr list) option ref * (Path.t * type_expr list) option + | Crow of row_field option ref * row_field option + | Ckind of field_kind option ref * field_kind option + | Ccommu of commutable ref * commutable + | Cuniv of type_expr option ref * type_expr option + | Ctypeset of TypeSet.t ref * TypeSet.t + +type changes = + Change of change * changes ref + | Unchanged + | Invalid + +let trail = Weak.create 1 + +let log_change ch = + match Weak.get trail 0 with None -> () + | Some r -> + let r' = ref Unchanged in + r := Change (ch, r'); + Weak.set trail 0 (Some r') + +(**** Representative of a type ****) + +let rec field_kind_repr = + function + Fvar {contents = Some kind} -> field_kind_repr kind + | kind -> kind + +let rec repr_link compress t d = + function + {desc = Tlink t' as d'} -> + repr_link true t d' t' + | {desc = Tfield (_, k, _, t') as d'} when field_kind_repr k = Fabsent -> + repr_link true t d' t' + | t' -> + if compress then begin + log_change (Ccompress (t, t.desc, d)); t.desc <- d + end; + t' + +let repr t = + match t.desc with + Tlink t' as d -> + repr_link false t d t' + | Tfield (_, k, _, t') as d when field_kind_repr k = Fabsent -> + repr_link false t d t' + | _ -> t + +let rec commu_repr = function + Clink r when !r <> Cunknown -> commu_repr !r + | c -> c + +let rec row_field_repr_aux tl = function + Reither(_, tl', _, {contents = Some fi}) -> + row_field_repr_aux (tl@tl') fi + | Reither(c, tl', m, r) -> + Reither(c, tl@tl', m, r) + | Rpresent (Some _) when tl <> [] -> + Rpresent (Some (List.hd tl)) + | fi -> fi + +let row_field_repr fi = row_field_repr_aux [] fi + +let rec rev_concat l ll = + match ll with + [] -> l + | l'::ll -> rev_concat (l'@l) ll + +let rec row_repr_aux ll row = + match (repr row.row_more).desc with + | Tvariant row' -> + let f = row.row_fields in + row_repr_aux (if f = [] then ll else f::ll) row' + | _ -> + if ll = [] then row else + {row with row_fields = rev_concat row.row_fields ll} + +let row_repr row = row_repr_aux [] row -(* Syntax of OCAMLPARAM: (name=VALUE,)* _ (,name=VALUE)* - where VALUE should not contain ',' *) -exception SyntaxError of string +let rec row_field tag row = + let rec find = function + | (tag',f) :: fields -> + if tag = tag' then row_field_repr f else find fields + | [] -> + match repr row.row_more with + | {desc=Tvariant row'} -> row_field tag row' + | _ -> Rabsent + in find row.row_fields -let parse_args s = - let args = String.split_on_char ',' s in - let rec iter is_after args before after = - match args with - [] -> - if not is_after then - raise (SyntaxError "no '_' separator found") - else - (List.rev before, List.rev after) - | "_" :: _ when is_after -> raise (SyntaxError "too many '_' separators") - | "_" :: tail -> iter true tail before after - | arg :: tail -> - let binding = try - Misc.cut_at arg '=' - with Not_found -> - raise (SyntaxError ("missing '=' in " ^ arg)) - in - if is_after then - iter is_after tail before (binding :: after) - else - iter is_after tail (binding :: before) after - in - iter false args [] [] +let rec row_more row = + match repr row.row_more with + | {desc=Tvariant row'} -> row_more row' + | ty -> ty -let setter ppf f name options s = - try - let bool = match s with - | "0" -> false - | "1" -> true - | _ -> raise Not_found - in - List.iter (fun b -> b := f bool) options - with Not_found -> - Location.print_warning Location.none ppf - (Warnings.Bad_env_variable ("OCAMLPARAM", - Printf.sprintf "bad value for %s" name)) +let row_fixed row = + let row = row_repr row in + row.row_fixed || + match (repr row.row_more).desc with + Tvar _ | Tnil -> false + | Tunivar _ | Tconstr _ -> true + | _ -> assert false -let int_setter ppf name option s = - try - option := int_of_string s - with _ -> - Location.print_warning Location.none ppf - (Warnings.Bad_env_variable - ("OCAMLPARAM", Printf.sprintf "non-integer parameter for \"%s\"" name)) +let static_row row = + let row = row_repr row in + row.row_closed && + List.for_all + (fun (_,f) -> match row_field_repr f with Reither _ -> false | _ -> true) + row.row_fields -let int_option_setter ppf name option s = - try - option := Some (int_of_string s) - with _ -> - Location.print_warning Location.none ppf - (Warnings.Bad_env_variable - ("OCAMLPARAM", Printf.sprintf "non-integer parameter for \"%s\"" name)) +let hash_variant s = + let accu = ref 0 in + for i = 0 to String.length s - 1 do + accu := 223 * !accu + Char.code s.[i] + done; + (* reduce to 31 bits *) + accu := !accu land (1 lsl 31 - 1); + (* make it signed for 64 bits architectures *) + if !accu > 0x3FFFFFFF then !accu - (1 lsl 31) else !accu -(* -let float_setter ppf name option s = - try - option := float_of_string s - with _ -> - Location.print_warning Location.none ppf - (Warnings.Bad_env_variable - ("OCAMLPARAM", Printf.sprintf "non-float parameter for \"%s\"" name)) -*) +let proxy ty = + let ty0 = repr ty in + match ty0.desc with + | Tvariant row when not (static_row row) -> + row_more row + | Tobject (ty, _) -> + let rec proxy_obj ty = + match ty.desc with + Tfield (_, _, _, ty) | Tlink ty -> proxy_obj ty + | Tvar _ | Tunivar _ | Tconstr _ -> ty + | Tnil -> ty0 + | _ -> assert false + in proxy_obj ty + | _ -> ty0 -let load_plugin = ref (fun _ -> ()) +(**** Utilities for fixed row private types ****) -let check_bool ppf name s = - match s with - | "0" -> false - | "1" -> true +let row_of_type t = + match (repr t).desc with + Tobject(t,_) -> + let rec get_row t = + let t = repr t in + match t.desc with + Tfield(_,_,_,t) -> get_row t + | _ -> t + in get_row t + | Tvariant row -> + row_more row | _ -> - Location.print_warning Location.none ppf - (Warnings.Bad_env_variable ("OCAMLPARAM", - Printf.sprintf "bad value for %s" name)); - false + t -(* 'can-discard=' specifies which arguments can be discarded without warning - because they are not understood by some versions of OCaml. *) -let can_discard = ref [] +let has_constr_row t = + not (is_Tconstr t) && is_Tconstr (row_of_type t) -let read_one_param ppf position name v = - let set name options s = setter ppf (fun b -> b) name options s in - let clear name options s = setter ppf (fun b -> not b) name options s in - match name with - | "g" -> set "g" [ Clflags.debug ] v - | "p" -> set "p" [ Clflags.gprofile ] v - | "bin-annot" -> set "bin-annot" [ Clflags.binary_annotations ] v - | "afl-instrument" -> set "afl-instrument" [ Clflags.afl_instrument ] v - | "afl-inst-ratio" -> - int_setter ppf "afl-inst-ratio" afl_inst_ratio v - | "annot" -> set "annot" [ Clflags.annotations ] v - | "absname" -> set "absname" [ Location.absname ] v - | "compat-32" -> set "compat-32" [ bytecode_compatible_32 ] v - | "noassert" -> set "noassert" [ noassert ] v - | "noautolink" -> set "noautolink" [ no_auto_link ] v - | "nostdlib" -> set "nostdlib" [ no_std_include ] v - | "linkall" -> set "linkall" [ link_everything ] v - | "nolabels" -> set "nolabels" [ classic ] v - | "principal" -> set "principal" [ principal ] v - | "rectypes" -> set "rectypes" [ recursive_types ] v - | "safe-string" -> clear "safe-string" [ unsafe_string ] v - | "strict-sequence" -> set "strict-sequence" [ strict_sequence ] v - | "strict-formats" -> set "strict-formats" [ strict_formats ] v - | "thread" -> set "thread" [ use_threads ] v - | "unboxed-types" -> set "unboxed-types" [ unboxed_types ] v - | "unsafe" -> set "unsafe" [ fast ] v - | "verbose" -> set "verbose" [ verbose ] v - | "nopervasives" -> set "nopervasives" [ nopervasives ] v - | "slash" -> set "slash" [ force_slash ] v (* for ocamldep *) - | "keep-docs" -> set "keep-docs" [ Clflags.keep_docs ] v - | "keep-locs" -> set "keep-locs" [ Clflags.keep_locs ] v +let is_row_name s = + let l = String.length s in + if l < 4 then false else String.sub s (l-4) 4 = "#row" - | "compact" -> clear "compact" [ optimize_for_speed ] v - | "no-app-funct" -> clear "no-app-funct" [ applicative_functors ] v - | "nodynlink" -> clear "nodynlink" [ dlcode ] v - | "short-paths" -> clear "short-paths" [ real_paths ] v - | "trans-mod" -> set "trans-mod" [ transparent_modules ] v - | "opaque" -> set "opaque" [ opaque ] v +let is_constr_row ~allow_ident t = + match t.desc with + Tconstr (Path.Pident id, _, _) when allow_ident -> + is_row_name (Ident.name id) + | Tconstr (Path.Pdot (_, s, _), _, _) -> is_row_name s + | _ -> false - | "pp" -> preprocessor := Some v - | "runtime-variant" -> runtime_variant := v - | "cc" -> c_compiler := Some v - | "clambda-checks" -> set "clambda-checks" [ clambda_checks ] v + (**********************************) + (* Utilities for type traversal *) + (**********************************) - (* assembly sources *) - | "s" -> - set "s" [ Clflags.keep_asm_file ; Clflags.keep_startup_file ] v - | "S" -> set "S" [ Clflags.keep_asm_file ] v - | "dstartup" -> set "dstartup" [ Clflags.keep_startup_file ] v +let rec iter_row f row = + List.iter + (fun (_, fi) -> + match row_field_repr fi with + | Rpresent(Some ty) -> f ty + | Reither(_, tl, _, _) -> List.iter f tl + | _ -> ()) + row.row_fields; + match (repr row.row_more).desc with + Tvariant row -> iter_row f row + | Tvar _ | Tunivar _ | Tsubst _ | Tconstr _ | Tnil -> + Misc.may (fun (_,l) -> List.iter f l) row.row_name + | _ -> assert false - (* warn-errors *) - | "we" | "warn-error" -> Warnings.parse_options true v - (* warnings *) - | "w" -> Warnings.parse_options false v - (* warn-errors *) - | "wwe" -> Warnings.parse_options false v +let iter_type_expr f ty = + match ty.desc with + Tvar _ -> () + | Tarrow (_, ty1, ty2, _) -> f ty1; f ty2 + | Ttuple l -> List.iter f l + | Tconstr (_, l, _) -> List.iter f l + | Tobject(ty, {contents = Some (_, p)}) + -> f ty; List.iter f p + | Tobject (ty, _) -> f ty + | Tvariant row -> iter_row f row; f (row_more row) + | Tfield (_, _, ty1, ty2) -> f ty1; f ty2 + | Tnil -> () + | Tlink ty -> f ty + | Tsubst ty -> f ty + | Tunivar _ -> () + | Tpoly (ty, tyl) -> f ty; List.iter f tyl + | Tpackage (_, _, l) -> List.iter f l - (* inlining *) - | "inline" -> - let module F = Float_arg_helper in - begin match F.parse_no_error v inline_threshold with - | F.Ok -> () - | F.Parse_failed exn -> - let error = - Printf.sprintf "bad syntax for \"inline\": %s" - (Printexc.to_string exn) - in - Location.print_warning Location.none ppf - (Warnings.Bad_env_variable ("OCAMLPARAM", error)) - end +let rec iter_abbrev f = function + Mnil -> () + | Mcons(_, _, ty, ty', rem) -> f ty; f ty'; iter_abbrev f rem + | Mlink rem -> iter_abbrev f !rem - | "inline-toplevel" -> - Int_arg_helper.parse v - "Bad syntax in OCAMLPARAM for 'inline-toplevel'" - inline_toplevel_threshold +type type_iterators = + { it_signature: type_iterators -> signature -> unit; + it_signature_item: type_iterators -> signature_item -> unit; + it_value_description: type_iterators -> value_description -> unit; + it_type_declaration: type_iterators -> type_declaration -> unit; + it_extension_constructor: type_iterators -> extension_constructor -> unit; + it_module_declaration: type_iterators -> module_declaration -> unit; + it_modtype_declaration: type_iterators -> modtype_declaration -> unit; + it_class_declaration: type_iterators -> class_declaration -> unit; + it_class_type_declaration: type_iterators -> class_type_declaration -> unit; + it_module_type: type_iterators -> module_type -> unit; + it_class_type: type_iterators -> class_type -> unit; + it_type_kind: type_iterators -> type_kind -> unit; + it_do_type_expr: type_iterators -> type_expr -> unit; + it_type_expr: type_iterators -> type_expr -> unit; + it_path: Path.t -> unit; } - | "rounds" -> int_option_setter ppf "rounds" simplify_rounds v - | "inline-max-unroll" -> - Int_arg_helper.parse v "Bad syntax in OCAMLPARAM for 'inline-max-unroll'" - inline_max_unroll - | "inline-call-cost" -> - Int_arg_helper.parse v - "Bad syntax in OCAMLPARAM for 'inline-call-cost'" - inline_call_cost - | "inline-alloc-cost" -> - Int_arg_helper.parse v - "Bad syntax in OCAMLPARAM for 'inline-alloc-cost'" - inline_alloc_cost - | "inline-prim-cost" -> - Int_arg_helper.parse v - "Bad syntax in OCAMLPARAM for 'inline-prim-cost'" - inline_prim_cost - | "inline-branch-cost" -> - Int_arg_helper.parse v - "Bad syntax in OCAMLPARAM for 'inline-branch-cost'" - inline_branch_cost - | "inline-indirect-cost" -> - Int_arg_helper.parse v - "Bad syntax in OCAMLPARAM for 'inline-indirect-cost'" - inline_indirect_cost - | "inline-lifting-benefit" -> - Int_arg_helper.parse v - "Bad syntax in OCAMLPARAM for 'inline-lifting-benefit'" - inline_lifting_benefit - | "inline-branch-factor" -> - Float_arg_helper.parse v - "Bad syntax in OCAMLPARAM for 'inline-branch-factor'" - inline_branch_factor - | "inline-max-depth" -> - Int_arg_helper.parse v - "Bad syntax in OCAMLPARAM for 'inline-max-depth'" - inline_max_depth +let iter_type_expr_cstr_args f = function + | Cstr_tuple tl -> List.iter f tl + | Cstr_record lbls -> List.iter (fun d -> f d.ld_type) lbls - | "Oclassic" -> - set "Oclassic" [ classic_inlining ] v - | "O2" -> - if check_bool ppf "O2" v then begin - default_simplify_rounds := 2; - use_inlining_arguments_set o2_arguments; - use_inlining_arguments_set ~round:0 o1_arguments - end +let map_type_expr_cstr_args f = function + | Cstr_tuple tl -> Cstr_tuple (List.map f tl) + | Cstr_record lbls -> + Cstr_record (List.map (fun d -> {d with ld_type=f d.ld_type}) lbls) - | "O3" -> - if check_bool ppf "O3" v then begin - default_simplify_rounds := 3; - use_inlining_arguments_set o3_arguments; - use_inlining_arguments_set ~round:1 o2_arguments; - use_inlining_arguments_set ~round:0 o1_arguments - end - | "unbox-closures" -> - set "unbox-closures" [ unbox_closures ] v - | "unbox-closures-factor" -> - int_setter ppf "unbox-closures-factor" unbox_closures_factor v - | "remove-unused-arguments" -> - set "remove-unused-arguments" [ remove_unused_arguments ] v +let iter_type_expr_kind f = function + | Type_abstract -> () + | Type_variant cstrs -> + List.iter + (fun cd -> + iter_type_expr_cstr_args f cd.cd_args; + Misc.may f cd.cd_res + ) + cstrs + | Type_record(lbls, _) -> + List.iter (fun d -> f d.ld_type) lbls + | Type_open -> + () - | "inlining-report" -> - if !native_code then - set "inlining-report" [ inlining_report ] v - | "flambda-verbose" -> - set "flambda-verbose" [ dump_flambda_verbose ] v - | "flambda-invariants" -> - set "flambda-invariants" [ flambda_invariant_checks ] v +let type_iterators = + let it_signature it = + List.iter (it.it_signature_item it) + and it_signature_item it = function + Sig_value (_, vd) -> it.it_value_description it vd + | Sig_type (_, td, _) -> it.it_type_declaration it td + | Sig_typext (_, td, _) -> it.it_extension_constructor it td + | Sig_module (_, md, _) -> it.it_module_declaration it md + | Sig_modtype (_, mtd) -> it.it_modtype_declaration it mtd + | Sig_class (_, cd, _) -> it.it_class_declaration it cd + | Sig_class_type (_, ctd, _) -> it.it_class_type_declaration it ctd + and it_value_description it vd = + it.it_type_expr it vd.val_type + and it_type_declaration it td = + List.iter (it.it_type_expr it) td.type_params; + may (it.it_type_expr it) td.type_manifest; + it.it_type_kind it td.type_kind + and it_extension_constructor it td = + it.it_path td.ext_type_path; + List.iter (it.it_type_expr it) td.ext_type_params; + iter_type_expr_cstr_args (it.it_type_expr it) td.ext_args; + may (it.it_type_expr it) td.ext_ret_type + and it_module_declaration it md = + it.it_module_type it md.md_type + and it_modtype_declaration it mtd = + may (it.it_module_type it) mtd.mtd_type + and it_class_declaration it cd = + List.iter (it.it_type_expr it) cd.cty_params; + it.it_class_type it cd.cty_type; + may (it.it_type_expr it) cd.cty_new; + it.it_path cd.cty_path + and it_class_type_declaration it ctd = + List.iter (it.it_type_expr it) ctd.clty_params; + it.it_class_type it ctd.clty_type; + it.it_path ctd.clty_path + and it_module_type it = function + Mty_ident p + | Mty_alias(_, p) -> it.it_path p + | Mty_signature sg -> it.it_signature it sg + | Mty_functor (_, mto, mt) -> + may (it.it_module_type it) mto; + it.it_module_type it mt + and it_class_type it = function + Cty_constr (p, tyl, cty) -> + it.it_path p; + List.iter (it.it_type_expr it) tyl; + it.it_class_type it cty + | Cty_signature cs -> + it.it_type_expr it cs.csig_self; + Vars.iter (fun _ (_,_,ty) -> it.it_type_expr it ty) cs.csig_vars; + List.iter + (fun (p, tl) -> it.it_path p; List.iter (it.it_type_expr it) tl) + cs.csig_inher + | Cty_arrow (_, ty, cty) -> + it.it_type_expr it ty; + it.it_class_type it cty + and it_type_kind it kind = + iter_type_expr_kind (it.it_type_expr it) kind + and it_do_type_expr it ty = + iter_type_expr (it.it_type_expr it) ty; + match ty.desc with + Tconstr (p, _, _) + | Tobject (_, {contents=Some (p, _)}) + | Tpackage (p, _, _) -> + it.it_path p + | Tvariant row -> + may (fun (p,_) -> it.it_path p) (row_repr row).row_name + | _ -> () + and it_path _p = () + in + { it_path; it_type_expr = it_do_type_expr; it_do_type_expr; + it_type_kind; it_class_type; it_module_type; + it_signature; it_class_type_declaration; it_class_declaration; + it_modtype_declaration; it_module_declaration; it_extension_constructor; + it_type_declaration; it_value_description; it_signature_item; } - (* color output *) - | "color" -> - begin match parse_color_setting v with - | None -> - Location.print_warning Location.none ppf - (Warnings.Bad_env_variable ("OCAMLPARAM", - "bad value for \"color\", \ - (expected \"auto\", \"always\" or \"never\")")) - | Some setting -> color := Some setting - end +let copy_row f fixed row keep more = + let fields = List.map + (fun (l, fi) -> l, + match row_field_repr fi with + | Rpresent(Some ty) -> Rpresent(Some(f ty)) + | Reither(c, tl, m, e) -> + let e = if keep then e else ref None in + let m = if row.row_fixed then fixed else m in + let tl = List.map f tl in + Reither(c, tl, m, e) + | _ -> fi) + row.row_fields in + let name = + match row.row_name with None -> None + | Some (path, tl) -> Some (path, List.map f tl) in + { row_fields = fields; row_more = more; + row_bound = (); row_fixed = row.row_fixed && fixed; + row_closed = row.row_closed; row_name = name; } - | "intf-suffix" -> Config.interface_suffix := v +let rec copy_kind = function + Fvar{contents = Some k} -> copy_kind k + | Fvar _ -> Fvar (ref None) + | Fpresent -> Fpresent + | Fabsent -> assert false - | "I" -> begin - match position with - | Before_args -> first_include_dirs := v :: !first_include_dirs - | Before_link | Before_compile _ -> - last_include_dirs := v :: !last_include_dirs - end +let copy_commu c = + if commu_repr c = Cok then Cok else Clink (ref Cunknown) - | "cclib" -> - begin - match position with - | Before_compile _ -> () - | Before_link | Before_args -> - ccobjs := Misc.rev_split_words v @ !ccobjs - end +(* Since univars may be used as row variables, we need to do some + encoding during substitution *) +let rec norm_univar ty = + match ty.desc with + Tunivar _ | Tsubst _ -> ty + | Tlink ty -> norm_univar ty + | Ttuple (ty :: _) -> norm_univar ty + | _ -> assert false - | "ccopts" -> - begin - match position with - | Before_link | Before_compile _ -> - last_ccopts := v :: !last_ccopts - | Before_args -> - first_ccopts := v :: !first_ccopts - end +let rec copy_type_desc ?(keep_names=false) f = function + Tvar _ as ty -> if keep_names then ty else Tvar None + | Tarrow (p, ty1, ty2, c)-> Tarrow (p, f ty1, f ty2, copy_commu c) + | Ttuple l -> Ttuple (List.map f l) + | Tconstr (p, l, _) -> Tconstr (p, List.map f l, ref Mnil) + | Tobject(ty, {contents = Some (p, tl)}) + -> Tobject (f ty, ref (Some(p, List.map f tl))) + | Tobject (ty, _) -> Tobject (f ty, ref None) + | Tvariant _ -> assert false (* too ambiguous *) + | Tfield (p, k, ty1, ty2) -> (* the kind is kept shared *) + Tfield (p, field_kind_repr k, f ty1, f ty2) + | Tnil -> Tnil + | Tlink ty -> copy_type_desc f ty.desc + | Tsubst _ -> assert false + | Tunivar _ as ty -> ty (* always keep the name *) + | Tpoly (ty, tyl) -> + let tyl = List.map (fun x -> norm_univar (f x)) tyl in + Tpoly (f ty, tyl) + | Tpackage (p, n, l) -> Tpackage (p, n, List.map f l) - | "ppx" -> - begin - match position with - | Before_link | Before_compile _ -> - last_ppx := v :: !last_ppx - | Before_args -> - first_ppx := v :: !first_ppx - end +(* Utilities for copying *) +let saved_desc = ref [] + (* Saved association of generic nodes with their description. *) - | "cmo" | "cma" -> - if not !native_code then - begin - match position with - | Before_link | Before_compile _ -> - last_objfiles := v ::! last_objfiles - | Before_args -> - first_objfiles := v :: !first_objfiles - end +let save_desc ty desc = + saved_desc := (ty, desc)::!saved_desc - | "cmx" | "cmxa" -> - if !native_code then - begin - match position with - | Before_link | Before_compile _ -> - last_objfiles := v ::! last_objfiles - | Before_args -> - first_objfiles := v :: !first_objfiles - end +let saved_kinds = ref [] (* duplicated kind variables *) +let new_kinds = ref [] (* new kind variables *) +let dup_kind r = + (match !r with None -> () | Some _ -> assert false); + if not (List.memq r !new_kinds) then begin + saved_kinds := r :: !saved_kinds; + let r' = ref None in + new_kinds := r' :: !new_kinds; + r := Some (Fvar r') + end - | "pic" -> - if !native_code then - set "pic" [ pic_code ] v +(* Restored type descriptions. *) +let cleanup_types () = + List.iter (fun (ty, desc) -> ty.desc <- desc) !saved_desc; + List.iter (fun r -> r := None) !saved_kinds; + saved_desc := []; saved_kinds := []; new_kinds := [] - | "can-discard" -> - can_discard := v ::!can_discard +(* Mark a type. *) +let rec mark_type ty = + let ty = repr ty in + if ty.level >= lowest_level then begin + ty.level <- pivot_level - ty.level; + iter_type_expr mark_type ty + end - | "timings" | "profile" -> - let if_on = if name = "timings" then [ `Time ] else Profile.all_columns in - profile_columns := if check_bool ppf name v then if_on else [] +let mark_type_node ty = + let ty = repr ty in + if ty.level >= lowest_level then begin + ty.level <- pivot_level - ty.level; + end - | "plugin" -> !load_plugin v +let mark_type_params ty = + iter_type_expr mark_type ty - | _ -> - if not (List.mem name !can_discard) then begin - can_discard := name :: !can_discard; - Printf.eprintf - "Warning: discarding value of variable %S in OCAMLPARAM\n%!" - name +let type_iterators = + let it_type_expr it ty = + let ty = repr ty in + if ty.level >= lowest_level then begin + mark_type_node ty; + it.it_do_type_expr it ty; end + in + {type_iterators with it_type_expr} -let read_OCAMLPARAM ppf position = - try - let s = Sys.getenv "OCAMLPARAM" in - let (before, after) = - try - parse_args s - with SyntaxError s -> - Location.print_warning Location.none ppf - (Warnings.Bad_env_variable ("OCAMLPARAM", s)); - [],[] - in - List.iter (fun (name, v) -> read_one_param ppf position name v) - (match position with - Before_args -> before - | Before_compile _ | Before_link -> after) - with Not_found -> () - -(* OCAMLPARAM passed as file *) -type pattern = - | Filename of string - | Any +(* Remove marks from a type. *) +let rec unmark_type ty = + let ty = repr ty in + if ty.level < lowest_level then begin + ty.level <- pivot_level - ty.level; + iter_type_expr unmark_type ty + end -type file_option = { - pattern : pattern; - name : string; - value : string; -} +let unmark_iterators = + let it_type_expr _it ty = unmark_type ty in + {type_iterators with it_type_expr} -let scan_line ic = - Scanf.bscanf ic "%[0-9a-zA-Z_.*] : %[a-zA-Z_-] = %s " - (fun pattern name value -> - let pattern = - match pattern with - | "*" -> Any - | _ -> Filename pattern - in - { pattern; name; value }) +let unmark_type_decl decl = + unmark_iterators.it_type_declaration unmark_iterators decl -let load_config ppf filename = - match open_in_bin filename with - | exception e -> - Location.print_error ppf (Location.in_file filename); - Format.fprintf ppf "Cannot open file %s@." (Printexc.to_string e); - raise Exit - | ic -> - let sic = Scanf.Scanning.from_channel ic in - let rec read line_number line_start acc = - match scan_line sic with - | exception End_of_file -> - close_in ic; - acc - | exception Scanf.Scan_failure error -> - let position = Lexing.{ - pos_fname = filename; - pos_lnum = line_number; - pos_bol = line_start; - pos_cnum = pos_in ic; - } - in - let loc = Location.{ - loc_start = position; - loc_end = position; - loc_ghost = false; - } - in - Location.print_error ppf loc; - Format.fprintf ppf "Configuration file error %s@." error; - close_in ic; - raise Exit - | line -> - read (line_number + 1) (pos_in ic) (line :: acc) - in - let lines = read 0 0 [] in - lines +let unmark_extension_constructor ext = + List.iter unmark_type ext.ext_type_params; + iter_type_expr_cstr_args unmark_type ext.ext_args; + Misc.may unmark_type ext.ext_ret_type -let matching_filename filename { pattern } = - match pattern with - | Any -> true - | Filename pattern -> - let filename = String.lowercase_ascii filename in - let pattern = String.lowercase_ascii pattern in - filename = pattern +let unmark_class_signature sign = + unmark_type sign.csig_self; + Vars.iter (fun _l (_m, _v, t) -> unmark_type t) sign.csig_vars -let apply_config_file ppf position = - let config_file = - Filename.concat Config.standard_library "ocaml_compiler_internal_params" - in - let config = - if Sys.file_exists config_file then - load_config ppf config_file - else - [] - in - let config = - match position with - | Before_compile filename -> - List.filter (matching_filename filename) config - | Before_args | Before_link -> - List.filter (fun { pattern } -> pattern = Any) config - in - List.iter (fun { name; value } -> read_one_param ppf position name value) - config +let unmark_class_type cty = + unmark_iterators.it_class_type unmark_iterators cty -let readenv ppf position = - last_include_dirs := []; - last_ccopts := []; - last_ppx := []; - last_objfiles := []; - apply_config_file ppf position; - read_OCAMLPARAM ppf position; - all_ccopts := !last_ccopts @ !first_ccopts; - all_ppx := !last_ppx @ !first_ppx -let get_objfiles ~with_ocamlparam = - if with_ocamlparam then - List.rev (!last_objfiles @ !objfiles @ !first_objfiles) - else - List.rev !objfiles + (*******************************************) + (* Memorization of abbreviation expansion *) + (*******************************************) +(* Search whether the expansion has been memorized. *) +let lte_public p1 p2 = (* Private <= Public *) + match p1, p2 with + | Private, _ | _, Public -> true + | Public, Private -> false +let rec find_expans priv p1 = function + Mnil -> None + | Mcons (priv', p2, _ty0, ty, _) + when lte_public priv priv' && Path.same p1 p2 -> Some ty + | Mcons (_, _, _, _, rem) -> find_expans priv p1 rem + | Mlink {contents = rem} -> find_expans priv p1 rem +(* debug: check for cycles in abbreviation. only works with -principal +let rec check_expans visited ty = + let ty = repr ty in + assert (not (List.memq ty visited)); + match ty.desc with + Tconstr (path, args, abbrev) -> + begin match find_expans path !abbrev with + Some ty' -> check_expans (ty :: visited) ty' + | None -> () + end + | _ -> () +*) +let memo = ref [] + (* Contains the list of saved abbreviation expansions. *) -type deferred_action = - | ProcessImplementation of string - | ProcessInterface of string - | ProcessCFile of string - | ProcessOtherFile of string - | ProcessObjects of string list - | ProcessDLLs of string list +let cleanup_abbrev () = + (* Remove all memorized abbreviation expansions. *) + List.iter (fun abbr -> abbr := Mnil) !memo; + memo := [] -let c_object_of_filename name = - Filename.chop_suffix (Filename.basename name) ".c" ^ Config.ext_obj +let memorize_abbrev mem priv path v v' = + (* Memorize the expansion of an abbreviation. *) + mem := Mcons (priv, path, v, v', !mem); + (* check_expans [] v; *) + memo := mem :: !memo -let process_action - (ppf, implementation, interface, ocaml_mod_ext, ocaml_lib_ext) action = - match action with - | ProcessImplementation name -> - readenv ppf (Before_compile name); - let opref = output_prefix name in - implementation ppf name opref; - objfiles := (opref ^ ocaml_mod_ext) :: !objfiles - | ProcessInterface name -> - readenv ppf (Before_compile name); - let opref = output_prefix name in - interface ppf name opref; - if !make_package then objfiles := (opref ^ ".cmi") :: !objfiles - | ProcessCFile name -> - readenv ppf (Before_compile name); - Location.set_input_name name; - if Ccomp.compile_file name <> 0 then exit 2; - ccobjs := c_object_of_filename name :: !ccobjs - | ProcessObjects names -> - ccobjs := names @ !ccobjs - | ProcessDLLs names -> - dllibs := names @ !dllibs - | ProcessOtherFile name -> - if Filename.check_suffix name ocaml_mod_ext - || Filename.check_suffix name ocaml_lib_ext then - objfiles := name :: !objfiles - else if Filename.check_suffix name ".cmi" && !make_package then - objfiles := name :: !objfiles - else if Filename.check_suffix name Config.ext_obj - || Filename.check_suffix name Config.ext_lib then - ccobjs := name :: !ccobjs - else if not !native_code && Filename.check_suffix name Config.ext_dll then - dllibs := name :: !dllibs - else - raise(Arg.Bad("don't know what to do with " ^ name)) +let rec forget_abbrev_rec mem path = + match mem with + Mnil -> + assert false + | Mcons (_, path', _, _, rem) when Path.same path path' -> + rem + | Mcons (priv, path', v, v', rem) -> + Mcons (priv, path', v, v', forget_abbrev_rec rem path) + | Mlink mem' -> + mem' := forget_abbrev_rec !mem' path; + raise Exit +let forget_abbrev mem path = + try mem := forget_abbrev_rec !mem path with Exit -> () -let action_of_file name = - if Filename.check_suffix name ".ml" - || Filename.check_suffix name ".mlt" then - ProcessImplementation name - else if Filename.check_suffix name !Config.interface_suffix then - ProcessInterface name - else if Filename.check_suffix name ".c" then - ProcessCFile name - else - ProcessOtherFile name +(* debug: check for invalid abbreviations +let rec check_abbrev_rec = function + Mnil -> true + | Mcons (_, ty1, ty2, rem) -> + repr ty1 != repr ty2 + | Mlink mem' -> + check_abbrev_rec !mem' -let deferred_actions = ref [] -let defer action = - deferred_actions := action :: !deferred_actions +let check_memorized_abbrevs () = + List.for_all (fun mem -> check_abbrev_rec !mem) !memo +*) -let anonymous filename = defer (action_of_file filename) -let impl filename = defer (ProcessImplementation filename) -let intf filename = defer (ProcessInterface filename) + (**********************************) + (* Utilities for labels *) + (**********************************) -let process_deferred_actions env = - let final_output_name = !output_name in - (* Make sure the intermediate products don't clash with the final one - when we're invoked like: ocamlopt -o foo bar.c baz.ml. *) - if not !compile_only then output_name := None; - begin - match final_output_name with - | None -> () - | Some output_name -> - if !compile_only then begin - if List.filter (function - | ProcessCFile name -> c_object_of_filename name <> output_name - | _ -> false) !deferred_actions <> [] then - fatal "Options -c and -o are incompatible when compiling C files"; +let is_optional = function Optional _ -> true | _ -> false - if List.length (List.filter (function - | ProcessImplementation _ - | ProcessInterface _ - | _ -> false) !deferred_actions) > 1 then - fatal "Options -c -o are incompatible with compiling multiple files" - end; - end; - if !make_archive && List.exists (function - | ProcessOtherFile name -> Filename.check_suffix name ".cmxa" - | _ -> false) !deferred_actions then - fatal "Option -a cannot be used with .cmxa input files."; - List.iter (process_action env) (List.rev !deferred_actions); - output_name := final_output_name; +let label_name = function + Nolabel -> "" + | Labelled s + | Optional s -> s -end -module Ident : sig -#1 "ident.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let prefixed_label_name = function + Nolabel -> "" + | Labelled s -> "~" ^ s + | Optional s -> "?" ^ s -(* Identifiers (unique names) *) +let rec extract_label_aux hd l = function + [] -> raise Not_found + | (l',t as p) :: ls -> + if label_name l' = l then (l', t, List.rev hd, ls) + else extract_label_aux (p::hd) l ls -type t = { stamp: int; name: string; mutable flags: int } +let extract_label l ls = extract_label_aux [] l ls -include Identifiable.S with type t := t -(* Notes: - - [equal] compares identifiers by name - - [compare x y] is 0 if [same x y] is true. - - [compare] compares identifiers by binding location -*) + (**********************************) + (* Utilities for backtracking *) + (**********************************) -val create: string -> t -val create_persistent: string -> t -val create_predef_exn: string -> t -val rename: t -> t -val name: t -> string -val unique_name: t -> string -val unique_toplevel_name: t -> string -val persistent: t -> bool -val same: t -> t -> bool - (* Compare identifiers by binding location. - Two identifiers are the same either if they are both - non-persistent and have been created by the same call to - [new], or if they are both persistent and have the same - name. *) -val compare: t -> t -> int -val hide: t -> t - (* Return an identifier with same name as the given identifier, - but stamp different from any stamp returned by new. - When put in a 'a tbl, this identifier can only be looked - up by name. *) +let undo_change = function + Ctype (ty, desc) -> ty.desc <- desc + | Ccompress (ty, desc, _) -> ty.desc <- desc + | Clevel (ty, level) -> ty.level <- level + | Cname (r, v) -> r := v + | Crow (r, v) -> r := v + | Ckind (r, v) -> r := v + | Ccommu (r, v) -> r := v + | Cuniv (r, v) -> r := v + | Ctypeset (r, v) -> r := v -val make_global: t -> unit -val global: t -> bool -val is_predef_exn: t -> bool +type snapshot = changes ref * int +let last_snapshot = ref 0 -val binding_time: t -> int -val current_time: unit -> int -val set_current_time: int -> unit -val reinit: unit -> unit +let log_type ty = + if ty.id <= !last_snapshot then log_change (Ctype (ty, ty.desc)) +let link_type ty ty' = + log_type ty; + let desc = ty.desc in + ty.desc <- Tlink ty'; + (* Name is a user-supplied name for this unification variable (obtained + * through a type annotation for instance). *) + match desc, ty'.desc with + Tvar name, Tvar name' -> + begin match name, name' with + | Some _, None -> log_type ty'; ty'.desc <- Tvar name + | None, Some _ -> () + | Some _, Some _ -> + if ty.level < ty'.level then (log_type ty'; ty'.desc <- Tvar name) + | None, None -> () + end + | _ -> () + (* ; assert (check_memorized_abbrevs ()) *) + (* ; check_expans [] ty' *) +let set_level ty level = + if ty.id <= !last_snapshot then log_change (Clevel (ty, ty.level)); + ty.level <- level +let set_univar rty ty = + log_change (Cuniv (rty, !rty)); rty := Some ty +let set_name nm v = + log_change (Cname (nm, !nm)); nm := v +let set_row_field e v = + log_change (Crow (e, !e)); e := Some v +let set_kind rk k = + log_change (Ckind (rk, !rk)); rk := Some k +let set_commu rc c = + log_change (Ccommu (rc, !rc)); rc := c +let set_typeset rs s = + log_change (Ctypeset (rs, !rs)); rs := s -type 'a tbl - (* Association tables from identifiers to type 'a. *) +let snapshot () = + let old = !last_snapshot in + last_snapshot := !new_id; + match Weak.get trail 0 with Some r -> (r, old) + | None -> + let r = ref Unchanged in + Weak.set trail 0 (Some r); + (r, old) -val empty: 'a tbl -val add: t -> 'a -> 'a tbl -> 'a tbl -val find_same: t -> 'a tbl -> 'a -val find_name: string -> 'a tbl -> t * 'a -val find_all: string -> 'a tbl -> (t * 'a) list -val fold_name: (t -> 'a -> 'b -> 'b) -> 'a tbl -> 'b -> 'b -val fold_all: (t -> 'a -> 'b -> 'b) -> 'a tbl -> 'b -> 'b -val iter: (t -> 'a -> unit) -> 'a tbl -> unit +let rec rev_log accu = function + Unchanged -> accu + | Invalid -> assert false + | Change (ch, next) -> + let d = !next in + next := Invalid; + rev_log (ch::accu) d +let backtrack (changes, old) = + match !changes with + Unchanged -> last_snapshot := old + | Invalid -> failwith "Btype.backtrack" + | Change _ as change -> + cleanup_abbrev (); + let backlog = rev_log [] change in + List.iter undo_change backlog; + changes := Unchanged; + last_snapshot := old; + Weak.set trail 0 (Some changes) -(* Idents for sharing keys *) +let rec rev_compress_log log r = + match !r with + Unchanged | Invalid -> + log + | Change (Ccompress _, next) -> + rev_compress_log (r::log) next + | Change (_, next) -> + rev_compress_log log next -val make_key_generator : unit -> (t -> t) +let undo_compress (changes, _old) = + match !changes with + Unchanged + | Invalid -> () + | Change _ -> + let log = rev_compress_log [] changes in + List.iter + (fun r -> match !r with + Change (Ccompress (ty, desc, d), next) when ty.desc == d -> + ty.desc <- desc; r := !next + | _ -> ()) + log -end = struct -#1 "ident.ml" +end +module Cmi_format : sig +#1 "cmi_format.mli" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* Fabrice Le Fessant, INRIA Saclay *) (* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* Copyright 2012 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -46155,251 +28616,266 @@ end = struct (* *) (**************************************************************************) -open Format - -type t = { stamp: int; name: string; mutable flags: int } - -let global_flag = 1 -let predef_exn_flag = 2 - -(* A stamp of 0 denotes a persistent identifier *) - -let currentstamp = ref 0 - -let create s = - incr currentstamp; - { name = s; stamp = !currentstamp; flags = 0 } - -let create_predef_exn s = - incr currentstamp; - { name = s; stamp = !currentstamp; flags = predef_exn_flag } - -let create_persistent s = - { name = s; stamp = 0; flags = global_flag } - -let rename i = - incr currentstamp; - { i with stamp = !currentstamp } - -let name i = i.name +type pers_flags = + | Rectypes + | Deprecated of string + | Opaque + | Unsafe_string -let unique_name i = i.name ^ "_" ^ string_of_int i.stamp +type cmi_infos = { + cmi_name : string; + cmi_sign : Types.signature_item list; + cmi_crcs : (string * Digest.t option) list; + cmi_flags : pers_flags list; +} -let unique_toplevel_name i = i.name ^ "/" ^ string_of_int i.stamp +(* write the magic + the cmi information *) +val output_cmi : string -> out_channel -> cmi_infos -> Digest.t -let persistent i = (i.stamp = 0) +val create_cmi : ?check_exists:unit -> string -> cmi_infos -> Digest.t -let equal i1 i2 = i1.name = i2.name +(* read the cmi information (the magic is supposed to have already been read) *) +val input_cmi : in_channel -> cmi_infos -let same i1 i2 = i1 = i2 - (* Possibly more efficient version (with a real compiler, at least): - if i1.stamp <> 0 - then i1.stamp = i2.stamp - else i2.stamp = 0 && i1.name = i2.name *) +(* read a cmi from a filename, checking the magic *) +val read_cmi : string -> cmi_infos -let compare i1 i2 = Pervasives.compare i1 i2 +(* Error report *) -let binding_time i = i.stamp +type error = + Not_an_interface of string + | Wrong_version_interface of string * string + | Corrupted_interface of string -let current_time() = !currentstamp -let set_current_time t = currentstamp := max !currentstamp t +exception Error of error -let reinit_level = ref (-1) +open Format -let reinit () = - if !reinit_level < 0 - then reinit_level := !currentstamp - else currentstamp := !reinit_level +val report_error: formatter -> error -> unit -let hide i = - { i with stamp = -1 } +end = struct +#1 "cmi_format.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Fabrice Le Fessant, INRIA Saclay *) +(* *) +(* Copyright 2012 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -let make_global i = - i.flags <- i.flags lor global_flag +type pers_flags = + | Rectypes + | Deprecated of string + | Opaque + | Unsafe_string -let global i = - (i.flags land global_flag) <> 0 +type error = + Not_an_interface of string + | Wrong_version_interface of string * string + | Corrupted_interface of string -let is_predef_exn i = - (i.flags land predef_exn_flag) <> 0 +exception Error of error -let print ppf i = - match i.stamp with - | 0 -> fprintf ppf "%s!" i.name - | -1 -> fprintf ppf "%s#" i.name - | n -> fprintf ppf "%s/%i%s" i.name n (if global i then "g" else "") +type cmi_infos = { + cmi_name : string; + cmi_sign : Types.signature_item list; + cmi_crcs : (string * Digest.t option) list; + cmi_flags : pers_flags list; +} -type 'a tbl = - Empty - | Node of 'a tbl * 'a data * 'a tbl * int +let input_cmi ic = + let (name, sign) = input_value ic in + let crcs = input_value ic in + let flags = input_value ic in + { + cmi_name = name; + cmi_sign = sign; + cmi_crcs = crcs; + cmi_flags = flags; + } -and 'a data = - { ident: t; - data: 'a; - previous: 'a data option } +let read_cmi filename = + let ic = open_in_bin filename in + try + let buffer = + really_input_string ic (String.length Config.cmi_magic_number) + in + if buffer <> Config.cmi_magic_number then begin + close_in ic; + let pre_len = String.length Config.cmi_magic_number - 3 in + if String.sub buffer 0 pre_len + = String.sub Config.cmi_magic_number 0 pre_len then + begin + let msg = + if buffer < Config.cmi_magic_number then "an older" else "a newer" in + raise (Error (Wrong_version_interface (filename, msg))) + end else begin + raise(Error(Not_an_interface filename)) + end + end; + let cmi = input_cmi ic in + close_in ic; + cmi + with End_of_file | Failure _ -> + close_in ic; + raise(Error(Corrupted_interface(filename))) + | Error e -> + close_in ic; + raise (Error e) -let empty = Empty +let output_cmi filename oc cmi = +(* beware: the provided signature must have been substituted for saving *) + output_string oc Config.cmi_magic_number; + output_value oc (cmi.cmi_name, cmi.cmi_sign); + flush oc; + let crc = Digest.file filename in + let crcs = (cmi.cmi_name, Some crc) :: cmi.cmi_crcs in + output_value oc crcs; + output_value oc cmi.cmi_flags; + crc -(* Inline expansion of height for better speed - * let height = function - * Empty -> 0 - * | Node(_,_,_,h) -> h - *) -let mknode l d r = - let hl = match l with Empty -> 0 | Node(_,_,_,h) -> h - and hr = match r with Empty -> 0 | Node(_,_,_,h) -> h in - Node(l, d, r, (if hl >= hr then hl + 1 else hr + 1)) +(* This function is also called by [save_cmt] as cmi_format is subset of + cmt_format, so dont close the channel yet +*) +let create_cmi ?check_exists filename (cmi : cmi_infos) = + (* beware: the provided signature must have been substituted for saving *) + let content = + Config.cmi_magic_number ^ Marshal.to_string (cmi.cmi_name, cmi.cmi_sign) [] + (* checkout [output_value] in {!Pervasives} module *) + in + let crc = Digest.string content in + let cmi_infos = + if check_exists <> None && Sys.file_exists filename then + Some (read_cmi filename) + else None in + match cmi_infos with + | Some {cmi_name = _; cmi_sign = _; cmi_crcs = (old_name, Some old_crc)::rest ; cmi_flags} + (* TODO: design the cmi format so that we don't need read the whole cmi *) + when + cmi.cmi_name = old_name && + crc = old_crc && + cmi.cmi_crcs = rest && + cmi_flags = cmi.cmi_flags -> + crc + | _ -> + let crcs = (cmi.cmi_name, Some crc) :: cmi.cmi_crcs in + let oc = open_out_bin filename in + output_string oc content; + output_value oc crcs; + output_value oc cmi.cmi_flags; + close_out oc; + crc -let balance l d r = - let hl = match l with Empty -> 0 | Node(_,_,_,h) -> h - and hr = match r with Empty -> 0 | Node(_,_,_,h) -> h in - if hl > hr + 1 then - match l with - | Node (ll, ld, lr, _) - when (match ll with Empty -> 0 | Node(_,_,_,h) -> h) >= - (match lr with Empty -> 0 | Node(_,_,_,h) -> h) -> - mknode ll ld (mknode lr d r) - | Node (ll, ld, Node(lrl, lrd, lrr, _), _) -> - mknode (mknode ll ld lrl) lrd (mknode lrr d r) - | _ -> assert false - else if hr > hl + 1 then - match r with - | Node (rl, rd, rr, _) - when (match rr with Empty -> 0 | Node(_,_,_,h) -> h) >= - (match rl with Empty -> 0 | Node(_,_,_,h) -> h) -> - mknode (mknode l d rl) rd rr - | Node (Node (rll, rld, rlr, _), rd, rr, _) -> - mknode (mknode l d rll) rld (mknode rlr rd rr) - | _ -> assert false - else - mknode l d r -let rec add id data = function - Empty -> - Node(Empty, {ident = id; data = data; previous = None}, Empty, 1) - | Node(l, k, r, h) -> - let c = compare id.name k.ident.name in - if c = 0 then - Node(l, {ident = id; data = data; previous = Some k}, r, h) - else if c < 0 then - balance (add id data l) k r - else - balance l k (add id data r) -let rec find_stamp s = function - None -> - raise Not_found - | Some k -> - if k.ident.stamp = s then k.data else find_stamp s k.previous + +(* Error report *) -let rec find_same id = function - Empty -> - raise Not_found - | Node(l, k, r, _) -> - let c = compare id.name k.ident.name in - if c = 0 then - if id.stamp = k.ident.stamp - then k.data - else find_stamp id.stamp k.previous - else - find_same id (if c < 0 then l else r) +open Format -let rec find_name name = function - Empty -> - raise Not_found - | Node(l, k, r, _) -> - let c = compare name k.ident.name in - if c = 0 then - k.ident, k.data - else - find_name name (if c < 0 then l else r) +let report_error ppf = function + | Not_an_interface filename -> + fprintf ppf "%a@ is not a compiled interface" + Location.print_filename filename + | Wrong_version_interface (filename, older_newer) -> + fprintf ppf + "%a@ is not a compiled interface for this version of OCaml.@.\ + It seems to be for %s version of OCaml." + Location.print_filename filename older_newer + | Corrupted_interface filename -> + fprintf ppf "Corrupted compiled interface@ %a" + Location.print_filename filename -let rec get_all = function - | None -> [] - | Some k -> (k.ident, k.data) :: get_all k.previous +let () = + Location.register_error_of_exn + (function + | Error err -> Some (Location.error_of_printer_file report_error err) + | _ -> None + ) -let rec find_all name = function - Empty -> - [] - | Node(l, k, r, _) -> - let c = compare name k.ident.name in - if c = 0 then - (k.ident, k.data) :: get_all k.previous - else - find_all name (if c < 0 then l else r) +end +module Consistbl : sig +#1 "consistbl.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 2002 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -let rec fold_aux f stack accu = function - Empty -> - begin match stack with - [] -> accu - | a :: l -> fold_aux f l accu a - end - | Node(l, k, r, _) -> - fold_aux f (l :: stack) (f k accu) r +(* Consistency tables: for checking consistency of module CRCs *) -let fold_name f tbl accu = fold_aux (fun k -> f k.ident k.data) [] accu tbl +type t -let rec fold_data f d accu = - match d with - None -> accu - | Some k -> f k.ident k.data (fold_data f k.previous accu) +val create: unit -> t -let fold_all f tbl accu = - fold_aux (fun k -> fold_data f (Some k)) [] accu tbl +val clear: t -> unit -(* let keys tbl = fold_name (fun k _ accu -> k::accu) tbl [] *) +val check: t -> string -> Digest.t -> string -> unit + (* [check tbl name crc source] + checks consistency of ([name], [crc]) with infos previously + stored in [tbl]. If no CRC was previously associated with + [name], record ([name], [crc]) in [tbl]. + [source] is the name of the file from which the information + comes from. This is used for error reporting. *) -let rec iter f = function - Empty -> () - | Node(l, k, r, _) -> - iter f l; f k.ident k.data; iter f r +val check_noadd: t -> string -> Digest.t -> string -> unit + (* Same as [check], but raise [Not_available] if no CRC was previously + associated with [name]. *) -(* Idents for sharing keys *) +val set: t -> string -> Digest.t -> string -> unit + (* [set tbl name crc source] forcefully associates [name] with + [crc] in [tbl], even if [name] already had a different CRC + associated with [name] in [tbl]. *) -(* They should be 'totally fresh' -> neg numbers *) -let key_name = "" +val source: t -> string -> string + (* [source tbl name] returns the file name associated with [name] + if the latter has an associated CRC in [tbl]. + Raise [Not_found] otherwise. *) -let make_key_generator () = - let c = ref 1 in - fun id -> - let stamp = !c in - decr c ; - { id with name = key_name; stamp = stamp; } +val extract: string list -> t -> (string * Digest.t option) list + (* [extract tbl names] returns an associative list mapping each string + in [names] to the CRC associated with it in [tbl]. If no CRC is + associated with a name then it is mapped to [None]. *) -let compare x y = - let c = x.stamp - y.stamp in - if c <> 0 then c - else - let c = compare x.name y.name in - if c <> 0 then c - else - compare x.flags y.flags +val filter: (string -> bool) -> t -> unit + (* [filter pred tbl] removes from [tbl] table all (name, CRC) pairs + such that [pred name] is [false]. *) -let output oc id = output_string oc (unique_name id) -let hash i = (Char.code i.name.[0]) lxor i.stamp +exception Inconsistency of string * string * string + (* Raised by [check] when a CRC mismatch is detected. + First string is the name of the compilation unit. + Second string is the source that caused the inconsistency. + Third string is the source that set the CRC. *) -let original_equal = equal -include Identifiable.Make (struct - type nonrec t = t - let compare = compare - let output = output - let print = print - let hash = hash - let equal = same -end) -let equal = original_equal +exception Not_available of string + (* Raised by [check_noadd] when a name doesn't have an associated CRC. *) -end -module Path : sig -#1 "path.mli" +end = struct +#1 "consistbl.ml" (**************************************************************************) (* *) (* OCaml *) (* *) (* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) (* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* Copyright 2002 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -46408,40 +28884,61 @@ module Path : sig (* *) (**************************************************************************) -(* Access paths *) +(* Consistency tables: for checking consistency of module CRCs *) -type t = - Pident of Ident.t - | Pdot of t * string * int - | Papply of t * t +type t = (string, Digest.t * string) Hashtbl.t -val same: t -> t -> bool -val compare: t -> t -> int -val isfree: Ident.t -> t -> bool -val binding_time: t -> int -val flatten : t -> [ `Contains_apply | `Ok of Ident.t * string list ] +let create () = Hashtbl.create 13 -val nopos: int +let clear = Hashtbl.clear -val name: ?paren:(string -> bool) -> t -> string - (* [paren] tells whether a path suffix needs parentheses *) -val head: t -> Ident.t +exception Inconsistency of string * string * string -val heads: t -> Ident.t list +exception Not_available of string -val last: t -> string +let check tbl name crc source = + try + let (old_crc, old_source) = Hashtbl.find tbl name in + if crc <> old_crc then raise(Inconsistency(name, source, old_source)) + with Not_found -> + Hashtbl.add tbl name (crc, source) -type typath = - | Regular of t - | Ext of t * string - | LocalExt of Ident.t - | Cstr of t * string +let check_noadd tbl name crc source = + try + let (old_crc, old_source) = Hashtbl.find tbl name in + if crc <> old_crc then raise(Inconsistency(name, source, old_source)) + with Not_found -> + raise (Not_available name) -val constructor_typath: t -> typath -val is_constructor_typath: t -> bool +let set tbl name crc source = Hashtbl.add tbl name (crc, source) + +let source tbl name = snd (Hashtbl.find tbl name) + +let extract l tbl = + let l = List.sort_uniq String.compare l in + List.fold_left + (fun assc name -> + try + let (crc, _) = Hashtbl.find tbl name in + (name, Some crc) :: assc + with Not_found -> + (name, None) :: assc) + [] l + +let filter p tbl = + let to_remove = ref [] in + Hashtbl.iter + (fun name _ -> + if not (p name) then to_remove := name :: !to_remove) + tbl; + List.iter + (fun name -> + while Hashtbl.mem tbl name do Hashtbl.remove tbl name done) + !to_remove -end = struct -#1 "path.ml" +end +module Datarepr : sig +#1 "datarepr.mli" (**************************************************************************) (* *) (* OCaml *) @@ -46457,111 +28954,52 @@ end = struct (* *) (**************************************************************************) -type t = - Pident of Ident.t - | Pdot of t * string * int - | Papply of t * t - -let nopos = -1 - -let rec same p1 p2 = - match (p1, p2) with - (Pident id1, Pident id2) -> Ident.same id1 id2 - | (Pdot(p1, s1, _pos1), Pdot(p2, s2, _pos2)) -> s1 = s2 && same p1 p2 - | (Papply(fun1, arg1), Papply(fun2, arg2)) -> - same fun1 fun2 && same arg1 arg2 - | (_, _) -> false - -let rec compare p1 p2 = - match (p1, p2) with - (Pident id1, Pident id2) -> Ident.compare id1 id2 - | (Pdot(p1, s1, _pos1), Pdot(p2, s2, _pos2)) -> - let h = compare p1 p2 in - if h <> 0 then h else String.compare s1 s2 - | (Papply(fun1, arg1), Papply(fun2, arg2)) -> - let h = compare fun1 fun2 in - if h <> 0 then h else compare arg1 arg2 - | ((Pident _ | Pdot _), (Pdot _ | Papply _)) -> -1 - | ((Pdot _ | Papply _), (Pident _ | Pdot _)) -> 1 - -let rec isfree id = function - Pident id' -> Ident.same id id' - | Pdot(p, _s, _pos) -> isfree id p - | Papply(p1, p2) -> isfree id p1 || isfree id p2 - -let rec binding_time = function - Pident id -> Ident.binding_time id - | Pdot(p, _s, _pos) -> binding_time p - | Papply(p1, p2) -> max (binding_time p1) (binding_time p2) +(* Compute constructor and label descriptions from type declarations, + determining their representation. *) -let kfalse _ = false +open Types -let rec name ?(paren=kfalse) = function - Pident id -> Ident.name id - | Pdot(p, s, _pos) -> - name ~paren p ^ if paren s then ".( " ^ s ^ " )" else "." ^ s - | Papply(p1, p2) -> name ~paren p1 ^ "(" ^ name ~paren p2 ^ ")" +val constructor_has_optional_shape: + Types.constructor_description -> bool -let rec head = function - Pident id -> id - | Pdot(p, _s, _pos) -> head p - | Papply _ -> assert false +val extension_descr: + Path.t -> extension_constructor -> constructor_description -let flatten = - let rec flatten acc = function - | Pident id -> `Ok (id, acc) - | Pdot (p, s, _) -> flatten (s :: acc) p - | Papply _ -> `Contains_apply - in - fun t -> flatten [] t +val labels_of_type: + Path.t -> type_declaration -> + (Ident.t * label_description) list +val constructors_of_type: + Path.t -> type_declaration -> + (Ident.t * constructor_description) list -let heads p = - let rec heads p acc = match p with - | Pident id -> id :: acc - | Pdot (p, _s, _pos) -> heads p acc - | Papply(p1, p2) -> - heads p1 (heads p2 acc) - in heads p [] -let rec last = function - | Pident id -> Ident.name id - | Pdot(_, s, _) -> s - | Papply(_, p) -> last p +exception Constr_not_found -let is_uident s = - assert (s <> ""); - match s.[0] with - | 'A'..'Z' -> true - | _ -> false +val find_constr_by_tag: + constructor_tag -> constructor_declaration list -> + constructor_declaration -type typath = - | Regular of t - | Ext of t * string - | LocalExt of Ident.t - | Cstr of t * string +val constructor_existentials : + constructor_arguments -> type_expr option -> type_expr list * type_expr list +(** Takes [cd_args] and [cd_res] from a [constructor_declaration] and + returns: + - the types of the constructor's arguments + - the existential variables introduced by the constructor + *) -let constructor_typath = function - | Pident id when is_uident (Ident.name id) -> LocalExt id - | Pdot(ty_path, s, _) when is_uident s -> - if is_uident (last ty_path) then Ext (ty_path, s) - else Cstr (ty_path, s) - | p -> Regular p -let is_constructor_typath p = - match constructor_typath p with - | Regular _ -> false - | _ -> true +(* Set the polymorphic variant row_name field *) +val set_row_name : type_declaration -> Path.t -> unit -end -module Attr_helper : sig -#1 "attr_helper.mli" +end = struct +#1 "datarepr.ml" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Jeremie Dimino, Jane Street Europe *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) (* *) -(* Copyright 2015 Institut National de Recherche en Informatique et *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -46570,88 +29008,274 @@ module Attr_helper : sig (* *) (**************************************************************************) -(** Helpers for attributes *) +(* Compute constructor and label descriptions from type declarations, + determining their representation. *) open Asttypes -open Parsetree +open Types +open Btype -type error = - | Multiple_attributes of string - | No_payload_expected of string +(* Simplified version of Ctype.free_vars *) +let free_vars ?(param=false) ty = + let ret = ref TypeSet.empty in + let rec loop ty = + let ty = repr ty in + if ty.level >= lowest_level then begin + ty.level <- pivot_level - ty.level; + match ty.desc with + | Tvar _ -> + ret := TypeSet.add ty !ret + | Tvariant row -> + let row = row_repr row in + iter_row loop row; + if not (static_row row) then begin + match row.row_more.desc with + | Tvar _ when param -> ret := TypeSet.add ty !ret + | _ -> loop row.row_more + end + (* XXX: What about Tobject ? *) + | _ -> + iter_type_expr loop ty + end + in + loop ty; + unmark_type ty; + !ret -(** The [string list] argument of the following functions is a list of - alternative names for the attribute we are looking for. For instance: +let newgenconstr path tyl = newgenty (Tconstr (path, tyl, ref Mnil)) - {[ - ["foo"; "ocaml.foo"] - ]} *) -val get_no_payload_attribute : string list -> attributes -> string loc option -val has_no_payload_attribute : string list -> attributes -> bool +let constructor_existentials cd_args cd_res = + let tyl = + match cd_args with + | Cstr_tuple l -> l + | Cstr_record l -> List.map (fun l -> l.ld_type) l + in + let existentials = + match cd_res with + | None -> [] + | Some type_ret -> + let arg_vars_set = free_vars (newgenty (Ttuple tyl)) in + let res_vars = free_vars type_ret in + TypeSet.elements (TypeSet.diff arg_vars_set res_vars) + in + (tyl, existentials) -exception Error of Location.t * error +let constructor_args priv cd_args cd_res path rep = + let tyl, existentials = constructor_existentials cd_args cd_res in + match cd_args with + | Cstr_tuple l -> existentials, l, None + | Cstr_record lbls -> + let arg_vars_set = free_vars ~param:true (newgenty (Ttuple tyl)) in + let type_params = TypeSet.elements arg_vars_set in + let type_unboxed = + match rep with + | Record_unboxed _ -> unboxed_true_default_false + | _ -> unboxed_false_default_false + in + let tdecl = + { + type_params; + type_arity = List.length type_params; + type_kind = Type_record (lbls, rep); + type_private = priv; + type_manifest = None; + type_variance = List.map (fun _ -> Variance.full) type_params; + type_newtype_level = None; + type_loc = Location.none; + type_attributes = []; + type_immediate = false; + type_unboxed; + } + in + existentials, + [ newgenconstr path type_params ], + Some tdecl -val report_error: Format.formatter -> error -> unit +let internal_optional = "internal.optional" + +let optional_shape : Parsetree.attribute = + {txt = internal_optional ; loc = Location.none}, Parsetree.PStr [] -end = struct -#1 "attr_helper.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Jeremie Dimino, Jane Street Europe *) -(* *) -(* Copyright 2015 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let constructor_has_optional_shape ({cstr_attributes = attrs} : constructor_description) = + List.exists (fun (x,_) -> x.txt = internal_optional) attrs -open Asttypes -open Parsetree -type error = - | Multiple_attributes of string - | No_payload_expected of string +let constructor_descrs ty_path decl cstrs = + let ty_res = newgenconstr ty_path decl.type_params in + let num_consts = ref 0 and num_nonconsts = ref 0 and num_normal = ref 0 in + List.iter + (fun {cd_args; cd_res; _} -> + if cd_args = Cstr_tuple [] then incr num_consts else incr num_nonconsts; + if cd_res = None then incr num_normal) + cstrs; + let rec describe_constructors idx_const idx_nonconst = function + [] -> [] + | {cd_id; cd_args; cd_res; cd_loc; cd_attributes} :: rem -> + let ty_res = + match cd_res with + | Some ty_res' -> ty_res' + | None -> ty_res + in + let (tag, descr_rem) = + match cd_args with + | _ when decl.type_unboxed.unboxed -> + assert (rem = []); + (Cstr_unboxed, []) + | Cstr_tuple [] -> (Cstr_constant idx_const, + describe_constructors (idx_const+1) idx_nonconst rem) + | _ -> (Cstr_block idx_nonconst, + describe_constructors idx_const (idx_nonconst+1) rem) in + let cstr_name = Ident.name cd_id in + let existentials, cstr_args, cstr_inlined = + let representation = + if decl.type_unboxed.unboxed + then Record_unboxed true + else Record_inlined {tag = idx_nonconst; name = cstr_name; num_nonconsts = !num_nonconsts} + in + constructor_args decl.type_private cd_args cd_res + (Path.Pdot (ty_path, cstr_name, Path.nopos)) representation + in + let cstr = + { cstr_name; + cstr_res = ty_res; + cstr_existentials = existentials; + cstr_args; + cstr_arity = List.length cstr_args; + cstr_tag = tag; + cstr_consts = !num_consts; + cstr_nonconsts = !num_nonconsts; + cstr_normal = !num_normal; + cstr_private = decl.type_private; + cstr_generalized = cd_res <> None; + cstr_loc = cd_loc; + cstr_attributes = cd_attributes; + cstr_inlined; + } in + (cd_id, cstr) :: descr_rem in + let result = describe_constructors 0 0 cstrs in + match result with + | ( + [ ({Ident.name = "None"} as a_id, ({cstr_args = []} as a_descr) ) ; + ({Ident.name = "Some"} as b_id, ({ cstr_args = [_]} as b_descr)) + ] | + [ ({Ident.name = "Some"} as a_id, ({cstr_args = [_]} as a_descr) ) ; + ({Ident.name = "None"} as b_id, ({ cstr_args = []} as b_descr)) + ] + ) + -> + [ + (a_id, {a_descr with + cstr_attributes = + optional_shape :: a_descr.cstr_attributes}); + (b_id, {b_descr with + cstr_attributes = + optional_shape :: b_descr.cstr_attributes + }) + ] + | _ -> result -exception Error of Location.t * error +let extension_descr path_ext ext = + let ty_res = + match ext.ext_ret_type with + Some type_ret -> type_ret + | None -> newgenconstr ext.ext_type_path ext.ext_type_params + in + let existentials, cstr_args, cstr_inlined = + constructor_args ext.ext_private ext.ext_args ext.ext_ret_type + path_ext Record_extension + in + { cstr_name = Path.last path_ext; + cstr_res = ty_res; + cstr_existentials = existentials; + cstr_args; + cstr_arity = List.length cstr_args; + cstr_tag = Cstr_extension(path_ext, cstr_args = []); + cstr_consts = -1; + cstr_nonconsts = -1; + cstr_private = ext.ext_private; + cstr_normal = -1; + cstr_generalized = ext.ext_ret_type <> None; + cstr_loc = ext.ext_loc; + cstr_attributes = ext.ext_attributes; + cstr_inlined; + } -let get_no_payload_attribute alt_names attrs = - match List.filter (fun (n, _) -> List.mem n.txt alt_names) attrs with - | [] -> None - | [ (name, PStr []) ] -> Some name - | [ (name, _) ] -> - raise (Error (name.loc, No_payload_expected name.txt)) - | _ :: (name, _) :: _ -> - raise (Error (name.loc, Multiple_attributes name.txt)) +let none = {desc = Ttuple []; level = -1; id = -1} + (* Clearly ill-formed type *) +let dummy_label = + { lbl_name = ""; lbl_res = none; lbl_arg = none; lbl_mut = Immutable; + lbl_pos = (-1); lbl_all = [||]; lbl_repres = Record_regular; + lbl_private = Public; + lbl_loc = Location.none; + lbl_attributes = []; + } -let has_no_payload_attribute alt_names attrs = - match get_no_payload_attribute alt_names attrs with - | None -> false - | Some _ -> true +let label_descrs ty_res lbls repres priv = + let all_labels = Array.make (List.length lbls) dummy_label in + let rec describe_labels num = function + [] -> [] + | l :: rest -> + let lbl = + { lbl_name = Ident.name l.ld_id; + lbl_res = ty_res; + lbl_arg = l.ld_type; + lbl_mut = l.ld_mutable; + lbl_pos = num; + lbl_all = all_labels; + lbl_repres = repres; + lbl_private = priv; + lbl_loc = l.ld_loc; + lbl_attributes = l.ld_attributes; + } in + all_labels.(num) <- lbl; + (l.ld_id, lbl) :: describe_labels (num+1) rest in + describe_labels 0 lbls -open Format +exception Constr_not_found -let report_error ppf = function - | Multiple_attributes name -> - fprintf ppf "Too many `%s' attributes" name - | No_payload_expected name -> - fprintf ppf "Attribute `%s' does not accept a payload" name +let rec find_constr tag num_const num_nonconst = function + [] -> + raise Constr_not_found + | {cd_args = Cstr_tuple []; _} as c :: rem -> + if tag = Cstr_constant num_const + then c + else find_constr tag (num_const + 1) num_nonconst rem + | c :: rem -> + if tag = Cstr_block num_nonconst || tag = Cstr_unboxed + then c + else find_constr tag num_const (num_nonconst + 1) rem -let () = - Location.register_error_of_exn - (function - | Error (loc, err) -> - Some (Location.error_of_printer loc report_error err) - | _ -> - None - ) +let find_constr_by_tag tag cstrlist = + find_constr tag 0 0 cstrlist + +let constructors_of_type ty_path decl = + match decl.type_kind with + | Type_variant cstrs -> constructor_descrs ty_path decl cstrs + | Type_record _ | Type_abstract | Type_open -> [] + +let labels_of_type ty_path decl = + match decl.type_kind with + | Type_record(labels, rep) -> + label_descrs (newgenconstr ty_path decl.type_params) + labels rep decl.type_private + | Type_variant _ | Type_abstract | Type_open -> [] + +(* Set row_name in Env, cf. GPR#1204/1329 *) +let set_row_name decl path = + match decl.type_manifest with + None -> () + | Some ty -> + let ty = repr ty in + match ty.desc with + Tvariant row when static_row row -> + let row = {(row_repr row) with + row_name = Some (path, decl.type_params)} in + ty.desc <- Tvariant row + | _ -> () end -module Primitive : sig -#1 "primitive.mli" +module Predef : sig +#1 "predef.mli" (**************************************************************************) (* *) (* OCaml *) @@ -46667,65 +29291,75 @@ module Primitive : sig (* *) (**************************************************************************) -(* Description of primitive functions *) - -type boxed_integer = Pnativeint | Pint32 | Pint64 +(* Predefined type constructors (with special typing rules in typecore) *) -(* Representation of arguments/result for the native code version - of a primitive *) -type native_repr = - | Same_as_ocaml_repr - | Unboxed_float - | Unboxed_integer of boxed_integer - | Untagged_int +open Types -type description = private - { prim_name: string; (* Name of primitive or C function *) - prim_arity: int; (* Number of arguments *) - prim_alloc: bool; (* Does it allocates or raise? *) - prim_native_name: string; (* Name of C function for the nat. code gen. *) - prim_native_repr_args: native_repr list; - prim_native_repr_res: native_repr } +val type_int: type_expr +val type_char: type_expr +val type_string: type_expr +val type_bytes: type_expr +val type_float: type_expr +val type_bool: type_expr +val type_unit: type_expr +val type_exn: type_expr +val type_array: type_expr -> type_expr +val type_list: type_expr -> type_expr +val type_option: type_expr -> type_expr +val type_nativeint: type_expr +val type_int32: type_expr +val type_int64: type_expr +val type_lazy_t: type_expr -> type_expr +val type_extension_constructor:type_expr +val type_floatarray:type_expr -(* Invariant [List.length d.prim_native_repr_args = d.prim_arity] *) +val path_int: Path.t +val path_char: Path.t +val path_string: Path.t +val path_bytes: Path.t +val path_float: Path.t +val path_bool: Path.t +val path_unit: Path.t +val path_exn: Path.t +val path_array: Path.t +val path_list: Path.t +val path_option: Path.t +val path_nativeint: Path.t +val path_int32: Path.t +val path_int64: Path.t +val path_lazy_t: Path.t +val path_extension_constructor: Path.t +val path_floatarray: Path.t -val simple - : name:string - -> arity:int - -> alloc:bool - -> description +val path_match_failure: Path.t +val path_assert_failure : Path.t +val path_undefined_recursive_module : Path.t -val make - : name:string - -> alloc:bool - -> native_name:string - -> native_repr_args: native_repr list - -> native_repr_res: native_repr - -> description +(* To build the initial environment. Since there is a nasty mutual + recursion between predef and env, we break it by parameterizing + over Env.t, Env.add_type and Env.add_extension. *) -val parse_declaration - : Parsetree.value_description - -> native_repr_args:native_repr list - -> native_repr_res:native_repr - -> description +val build_initial_env: + (Ident.t -> type_declaration -> 'a -> 'a) -> + (Ident.t -> extension_constructor -> 'a -> 'a) -> + 'a -> 'a * 'a -val print - : description - -> Outcometree.out_val_decl - -> Outcometree.out_val_decl +(* To initialize linker tables *) -val native_name: description -> string -val byte_name: description -> string +val builtin_values: (string * Ident.t) list +val builtin_idents: (string * Ident.t) list -type error = - | Old_style_float_with_native_repr_attribute - | Old_style_noalloc_with_noalloc_attribute - | No_native_primitive_with_repr_attribute +(** All predefined exceptions, exposed as [Ident.t] for flambda (for + building value approximations). + The [Ident.t] for division by zero is also exported explicitly + so flambda can generate code to raise it. *) +val ident_division_by_zero: Ident.t +val all_predef_exns : Ident.t list -exception Error of Location.t * error +val type_is_builtin_path_but_option : Path.t -> bool end = struct -#1 "primitive.ml" +#1 "predef.ml" (**************************************************************************) (* *) (* OCaml *) @@ -46741,1067 +29375,1412 @@ end = struct (* *) (**************************************************************************) -(* Description of primitive functions *) - -open Misc -open Parsetree - -type boxed_integer = Pnativeint | Pint32 | Pint64 +(* Predefined type constructors (with special typing rules in typecore) *) -type native_repr = - | Same_as_ocaml_repr - | Unboxed_float - | Unboxed_integer of boxed_integer - | Untagged_int +open Path +open Types +open Btype -type description = - { prim_name: string; (* Name of primitive or C function *) - prim_arity: int; (* Number of arguments *) - prim_alloc: bool; (* Does it allocates or raise? *) - prim_native_name: string; (* Name of C function for the nat. code gen. *) - prim_native_repr_args: native_repr list; - prim_native_repr_res: native_repr } +let builtin_idents = ref [] -type error = - | Old_style_float_with_native_repr_attribute - | Old_style_noalloc_with_noalloc_attribute - | No_native_primitive_with_repr_attribute +let wrap create s = + let id = create s in + builtin_idents := (s, id) :: !builtin_idents; + id -exception Error of Location.t * error +let ident_create = wrap Ident.create +let ident_create_predef_exn = wrap Ident.create_predef_exn -let is_ocaml_repr = function - | Same_as_ocaml_repr -> true - | Unboxed_float - | Unboxed_integer _ - | Untagged_int -> false +let ident_int = ident_create "int" +and ident_char = ident_create "char" +and ident_bytes = ident_create "bytes" +and ident_float = ident_create "float" +and ident_bool = ident_create "bool" +and ident_unit = ident_create "unit" +and ident_exn = ident_create "exn" +and ident_array = ident_create "array" +and ident_list = ident_create "list" +and ident_option = ident_create "option" +and ident_nativeint = ident_create "nativeint" +and ident_int32 = ident_create "int32" +and ident_int64 = ident_create "int64" +and ident_lazy_t = ident_create "lazy_t" +and ident_string = ident_create "string" +and ident_extension_constructor = ident_create "extension_constructor" +and ident_floatarray = ident_create "floatarray" -let is_unboxed = function - | Same_as_ocaml_repr - | Untagged_int -> false - | Unboxed_float - | Unboxed_integer _ -> true +let type_is_builtin_path_but_option (p : Path.t) = + match p with + | Pident {Ident.stamp} -> + stamp >= ident_int.Ident.stamp + && stamp <= ident_floatarray.Ident.stamp + && (stamp <> ident_option.Ident.stamp) + | _ -> false -let is_untagged = function - | Untagged_int -> true - | Same_as_ocaml_repr - | Unboxed_float - | Unboxed_integer _ -> false +let path_int = Pident ident_int +and path_char = Pident ident_char +and path_bytes = Pident ident_bytes +and path_float = Pident ident_float +and path_bool = Pident ident_bool +and path_unit = Pident ident_unit +and path_exn = Pident ident_exn +and path_array = Pident ident_array +and path_list = Pident ident_list +and path_option = Pident ident_option +and path_nativeint = Pident ident_nativeint +and path_int32 = Pident ident_int32 +and path_int64 = Pident ident_int64 +and path_lazy_t = Pident ident_lazy_t +and path_string = Pident ident_string +and path_extension_constructor = Pident ident_extension_constructor +and path_floatarray = Pident ident_floatarray -let rec make_native_repr_args arity x = - if arity = 0 then - [] - else - x :: make_native_repr_args (arity - 1) x +let type_int = newgenty (Tconstr(path_int, [], ref Mnil)) +and type_char = newgenty (Tconstr(path_char, [], ref Mnil)) +and type_bytes = newgenty (Tconstr(path_bytes, [], ref Mnil)) +and type_float = newgenty (Tconstr(path_float, [], ref Mnil)) +and type_bool = newgenty (Tconstr(path_bool, [], ref Mnil)) +and type_unit = newgenty (Tconstr(path_unit, [], ref Mnil)) +and type_exn = newgenty (Tconstr(path_exn, [], ref Mnil)) +and type_array t = newgenty (Tconstr(path_array, [t], ref Mnil)) +and type_list t = newgenty (Tconstr(path_list, [t], ref Mnil)) +and type_option t = newgenty (Tconstr(path_option, [t], ref Mnil)) +and type_nativeint = newgenty (Tconstr(path_nativeint, [], ref Mnil)) +and type_int32 = newgenty (Tconstr(path_int32, [], ref Mnil)) +and type_int64 = newgenty (Tconstr(path_int64, [], ref Mnil)) +and type_lazy_t t = newgenty (Tconstr(path_lazy_t, [t], ref Mnil)) +and type_string = newgenty (Tconstr(path_string, [], ref Mnil)) +and type_extension_constructor = + newgenty (Tconstr(path_extension_constructor, [], ref Mnil)) +and type_floatarray = newgenty (Tconstr(path_floatarray, [], ref Mnil)) -let simple ~name ~arity ~alloc = - {prim_name = name; - prim_arity = arity; - prim_alloc = alloc; - prim_native_name = ""; - prim_native_repr_args = make_native_repr_args arity Same_as_ocaml_repr; - prim_native_repr_res = Same_as_ocaml_repr} +let ident_match_failure = ident_create_predef_exn "Match_failure" +and ident_out_of_memory = ident_create_predef_exn "Out_of_memory" +and ident_invalid_argument = ident_create_predef_exn "Invalid_argument" +and ident_failure = ident_create_predef_exn "Failure" +and ident_not_found = ident_create_predef_exn "Not_found" +and ident_sys_error = ident_create_predef_exn "Sys_error" +and ident_end_of_file = ident_create_predef_exn "End_of_file" +and ident_division_by_zero = ident_create_predef_exn "Division_by_zero" +and ident_stack_overflow = ident_create_predef_exn "Stack_overflow" +and ident_sys_blocked_io = ident_create_predef_exn "Sys_blocked_io" +and ident_assert_failure = ident_create_predef_exn "Assert_failure" +and ident_undefined_recursive_module = + ident_create_predef_exn "Undefined_recursive_module" -let make ~name ~alloc ~native_name ~native_repr_args ~native_repr_res = - {prim_name = name; - prim_arity = List.length native_repr_args; - prim_alloc = alloc; - prim_native_name = native_name; - prim_native_repr_args = native_repr_args; - prim_native_repr_res = native_repr_res} +let all_predef_exns = [ + ident_match_failure; + ident_out_of_memory; + ident_invalid_argument; + ident_failure; + ident_not_found; + ident_sys_error; + ident_end_of_file; + ident_division_by_zero; + ident_stack_overflow; + ident_sys_blocked_io; + ident_assert_failure; + ident_undefined_recursive_module; +] -let parse_declaration valdecl ~native_repr_args ~native_repr_res = - let arity = List.length native_repr_args in - let name, native_name, old_style_noalloc, old_style_float = - match valdecl.pval_prim with - | name :: "noalloc" :: name2 :: "float" :: _ -> (name, name2, true, true) - | name :: "noalloc" :: name2 :: _ -> (name, name2, true, false) - | name :: name2 :: "float" :: _ -> (name, name2, false, true) - | name :: "noalloc" :: _ -> (name, "", true, false) - | name :: name2 :: _ -> (name, name2, false, false) - | name :: _ -> (name, "", false, false) - | [] -> - fatal_error "Primitive.parse_declaration" - in - let noalloc_attribute = - Attr_helper.has_no_payload_attribute ["noalloc"; "ocaml.noalloc"] - valdecl.pval_attributes - in - if old_style_float && - not (List.for_all is_ocaml_repr native_repr_args && - is_ocaml_repr native_repr_res) then - raise (Error (valdecl.pval_loc, - Old_style_float_with_native_repr_attribute)); - if old_style_noalloc && noalloc_attribute then - raise (Error (valdecl.pval_loc, - Old_style_noalloc_with_noalloc_attribute)); - (* The compiler used to assume "noalloc" with "float", we just make this - explicit now (GPR#167): *) - let old_style_noalloc = old_style_noalloc || old_style_float in - if old_style_float then - Location.deprecated valdecl.pval_loc - "[@@unboxed] + [@@noalloc] should be used instead of \"float\"" - else if old_style_noalloc then - Location.deprecated valdecl.pval_loc - "[@@noalloc] should be used instead of \"noalloc\""; - if native_name = "" && - not (List.for_all is_ocaml_repr native_repr_args && - is_ocaml_repr native_repr_res) then - raise (Error (valdecl.pval_loc, - No_native_primitive_with_repr_attribute)); - let noalloc = old_style_noalloc || noalloc_attribute in - let native_repr_args, native_repr_res = - if old_style_float then - (make_native_repr_args arity Unboxed_float, Unboxed_float) - else - (native_repr_args, native_repr_res) - in - {prim_name = name; - prim_arity = arity; - prim_alloc = not noalloc; - prim_native_name = native_name; - prim_native_repr_args = native_repr_args; - prim_native_repr_res = native_repr_res} +let path_match_failure = Pident ident_match_failure +and path_assert_failure = Pident ident_assert_failure +and path_undefined_recursive_module = Pident ident_undefined_recursive_module -open Outcometree +let decl_abstr = + {type_params = []; + type_arity = 0; + type_kind = Type_abstract; + type_loc = Location.none; + type_private = Asttypes.Public; + type_manifest = None; + type_variance = []; + type_newtype_level = None; + type_attributes = []; + type_immediate = false; + type_unboxed = unboxed_false_default_false; + } -let rec add_native_repr_attributes ty attrs = - match ty, attrs with - | Otyp_arrow (label, a, b), attr_opt :: rest -> - let b = add_native_repr_attributes b rest in - let a = - match attr_opt with - | None -> a - | Some attr -> Otyp_attribute (a, attr) - in - Otyp_arrow (label, a, b) - | _, [Some attr] -> Otyp_attribute (ty, attr) - | _ -> - assert (List.for_all (fun x -> x = None) attrs); - ty +let decl_abstr_imm = {decl_abstr with type_immediate = true} -let oattr_unboxed = { oattr_name = "unboxed" } -let oattr_untagged = { oattr_name = "untagged" } -let oattr_noalloc = { oattr_name = "noalloc" } +let cstr id args = + { + cd_id = id; + cd_args = Cstr_tuple args; + cd_res = None; + cd_loc = Location.none; + cd_attributes = []; + } -let print p osig_val_decl = - let prims = - if p.prim_native_name <> "" then - [p.prim_name; p.prim_native_name] - else - [p.prim_name] - in - let for_all f = - List.for_all f p.prim_native_repr_args && f p.prim_native_repr_res - in - let all_unboxed = for_all is_unboxed in - let all_untagged = for_all is_untagged in - let attrs = if p.prim_alloc then [] else [oattr_noalloc] in - let attrs = - if all_unboxed then - oattr_unboxed :: attrs - else if all_untagged then - oattr_untagged :: attrs - else - attrs - in - let attr_of_native_repr = function - | Same_as_ocaml_repr -> None - | Unboxed_float - | Unboxed_integer _ -> if all_unboxed then None else Some oattr_unboxed - | Untagged_int -> if all_untagged then None else Some oattr_untagged - in - let type_attrs = - List.map attr_of_native_repr p.prim_native_repr_args @ - [attr_of_native_repr p.prim_native_repr_res] +let ident_false = ident_create "false" +and ident_true = ident_create "true" +and ident_void = ident_create "()" +and ident_nil = ident_create "[]" +and ident_cons = ident_create "::" +and ident_none = ident_create "None" +and ident_some = ident_create "Some" +let common_initial_env add_type add_extension empty_env = + let decl_bool = + {decl_abstr with + type_kind = Type_variant([cstr ident_false []; cstr ident_true []]); + type_immediate = true} + and decl_unit = + {decl_abstr with + type_kind = Type_variant([cstr ident_void []]); + type_immediate = true} + and decl_exn = + {decl_abstr with + type_kind = Type_open} + and decl_array = + let tvar = newgenvar() in + {decl_abstr with + type_params = [tvar]; + type_arity = 1; + type_variance = [Variance.full]} + and decl_list = + let tvar = newgenvar() in + {decl_abstr with + type_params = [tvar]; + type_arity = 1; + type_kind = + Type_variant([cstr ident_nil []; cstr ident_cons [tvar; type_list tvar]]); + type_variance = [Variance.covariant]} + and decl_option = + let tvar = newgenvar() in + {decl_abstr with + type_params = [tvar]; + type_arity = 1; + type_kind = Type_variant([cstr ident_none []; cstr ident_some [tvar]]); + type_variance = [Variance.covariant]} + and decl_lazy_t = + let tvar = newgenvar() in + {decl_abstr with + type_params = [tvar]; + type_arity = 1; + type_variance = [Variance.covariant]} in - { osig_val_decl with - oval_prims = prims; - oval_type = add_native_repr_attributes osig_val_decl.oval_type type_attrs; - oval_attributes = attrs } - -let native_name p = - if p.prim_native_name <> "" - then p.prim_native_name - else p.prim_name - -let byte_name p = - p.prim_name - -let report_error ppf err = - match err with - | Old_style_float_with_native_repr_attribute -> - Format.fprintf ppf "Cannot use \"float\" in conjunction with \ - [%@unboxed]/[%@untagged]" - | Old_style_noalloc_with_noalloc_attribute -> - Format.fprintf ppf "Cannot use \"noalloc\" in conjunction with \ - [%@%@noalloc]" - | No_native_primitive_with_repr_attribute -> - Format.fprintf ppf - "The native code version of the primitive is mandatory when \ - attributes [%@untagged] or [%@unboxed] are present" -let () = - Location.register_error_of_exn - (function - | Error (loc, err) -> - Some (Location.error_of_printer loc report_error err) - | _ -> - None - ) - -end -module Types : sig -#1 "types.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) - -(** {0 Representation of types and declarations} *) - -(** [Types] defines the representation of types and declarations (that is, the - content of module signatures). - - CMI files are made of marshalled types. -*) - -(** Asttypes exposes basic definitions shared both by Parsetree and Types. *) -open Asttypes - -(** Type expressions for the core language. - - The [type_desc] variant defines all the possible type expressions one can - find in OCaml. [type_expr] wraps this with some annotations. - - The [level] field tracks the level of polymorphism associated to a type, - guiding the generalization algorithm. - Put shortly, when referring to a type in a given environment, both the type - and the environment have a level. If the type has an higher level, then it - can be considered fully polymorphic (type variables will be printed as - ['a]), otherwise it'll be weakly polymorphic, or non generalized (type - variables printed as ['_a]). - See [http://okmij.org/ftp/ML/generalization.html] for more information. - - Note about [type_declaration]: one should not make the confusion between - [type_expr] and [type_declaration]. - - [type_declaration] refers specifically to the [type] construct in OCaml - language, where you create and name a new type or type alias. - - [type_expr] is used when you refer to existing types, e.g. when annotating - the expected type of a value. + let add_extension id l = + add_extension id + { ext_type_path = path_exn; + ext_type_params = []; + ext_args = Cstr_tuple l; + ext_ret_type = None; + ext_private = Asttypes.Public; + ext_loc = Location.none; + ext_attributes = [{Asttypes.txt="ocaml.warn_on_literal_pattern"; + loc=Location.none}, + Parsetree.PStr[]] } + in + add_extension ident_match_failure + [newgenty (Ttuple[type_string; type_int; type_int])] ( + add_extension ident_out_of_memory [] ( + add_extension ident_stack_overflow [] ( + add_extension ident_invalid_argument [type_string] ( + add_extension ident_failure [type_string] ( + add_extension ident_not_found [] ( + add_extension ident_sys_blocked_io [] ( + add_extension ident_sys_error [type_string] ( + add_extension ident_end_of_file [] ( + add_extension ident_division_by_zero [] ( + add_extension ident_assert_failure + [newgenty (Ttuple[type_string; type_int; type_int])] ( + add_extension ident_undefined_recursive_module + [newgenty (Ttuple[type_string; type_int; type_int])] ( + add_type ident_int64 decl_abstr ( + add_type ident_int32 decl_abstr ( + add_type ident_nativeint decl_abstr ( + add_type ident_lazy_t decl_lazy_t ( + add_type ident_option decl_option ( + add_type ident_list decl_list ( + add_type ident_array decl_array ( + add_type ident_exn decl_exn ( + add_type ident_unit decl_unit ( + add_type ident_bool decl_bool ( + add_type ident_float decl_abstr ( + add_type ident_string decl_abstr ( + add_type ident_char decl_abstr_imm ( + add_type ident_int decl_abstr_imm ( + add_type ident_extension_constructor decl_abstr ( + add_type ident_floatarray decl_abstr ( + empty_env)))))))))))))))))))))))))))) - Also, as the type system of OCaml is generative, a [type_declaration] can - have the side-effect of introducing a new type constructor, different from - all other known types. - Whereas [type_expr] is a pure construct which allows referring to existing - types. +let build_initial_env add_type add_exception empty_env = + let common = common_initial_env add_type add_exception empty_env in + let safe_string = add_type ident_bytes decl_abstr common in + let decl_bytes_unsafe = {decl_abstr with type_manifest = Some type_string} in + let unsafe_string = add_type ident_bytes decl_bytes_unsafe common in + (safe_string, unsafe_string) - Note on mutability: TBD. - *) -type type_expr = - { mutable desc: type_desc; - mutable level: int; - id: int } +let builtin_values = + List.map (fun id -> Ident.make_global id; (Ident.name id, id)) + [ident_match_failure; ident_out_of_memory; ident_stack_overflow; + ident_invalid_argument; + ident_failure; ident_not_found; ident_sys_error; ident_end_of_file; + ident_division_by_zero; ident_sys_blocked_io; + ident_assert_failure; ident_undefined_recursive_module ] -and type_desc = - | Tvar of string option - (** [Tvar (Some "a")] ==> ['a] or ['_a] - [Tvar None] ==> [_] *) +(* Start non-predef identifiers at 1000. This way, more predefs can + be defined in this file (above!) without breaking .cmi + compatibility. *) - | Tarrow of arg_label * type_expr * type_expr * commutable - (** [Tarrow (Nolabel, e1, e2, c)] ==> [e1 -> e2] - [Tarrow (Labelled "l", e1, e2, c)] ==> [l:e1 -> e2] - [Tarrow (Optional "l", e1, e2, c)] ==> [?l:e1 -> e2] +let _ = Ident.set_current_time 999 +let builtin_idents = List.rev !builtin_idents - See [commutable] for the last argument. *) +end +module Ast_mapper : sig +#1 "ast_mapper.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Alain Frisch, LexiFi *) +(* *) +(* Copyright 2012 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) - | Ttuple of type_expr list - (** [Ttuple [t1;...;tn]] ==> [(t1 * ... * tn)] *) +(** The interface of a -ppx rewriter - | Tconstr of Path.t * type_expr list * abbrev_memo ref - (** [Tconstr (`A.B.t', [t1;...;tn], _)] ==> [(t1,...,tn) A.B.t] - The last parameter keep tracks of known expansions, see [abbrev_memo]. *) + A -ppx rewriter is a program that accepts a serialized abstract syntax + tree and outputs another, possibly modified, abstract syntax tree. + This module encapsulates the interface between the compiler and + the -ppx rewriters, handling such details as the serialization format, + forwarding of command-line flags, and storing state. - | Tobject of type_expr * (Path.t * type_expr list) option ref - (** [Tobject (`f1:t1;...;fn: tn', `None')] ==> [< f1: t1; ...; fn: tn >] - f1, fn are represented as a linked list of types using Tfield and Tnil - constructors. + {!mapper} allows to implement AST rewriting using open recursion. + A typical mapper would be based on {!default_mapper}, a deep + identity mapper, and will fall back on it for handling the syntax it + does not modify. For example: - [Tobject (_, `Some (`A.ct', [t1;...;tn]')] ==> [(t1, ..., tn) A.ct]. - where A.ct is the type of some class. + {[ +open Asttypes +open Parsetree +open Ast_mapper - There are also special cases for so-called "class-types", cf. [Typeclass] - and [Ctype.set_object_name]: +let test_mapper argv = + { default_mapper with + expr = fun mapper expr -> + match expr with + | { pexp_desc = Pexp_extension ({ txt = "test" }, PStr [])} -> + Ast_helper.Exp.constant (Const_int 42) + | other -> default_mapper.expr mapper other; } - [Tobject (Tfield(_,_,...(Tfield(_,_,rv)...), - Some(`A.#ct`, [rv;t1;...;tn])] - ==> [(t1, ..., tn) #A.ct] - [Tobject (_, Some(`A.#ct`, [Tnil;t1;...;tn])] ==> [(t1, ..., tn) A.ct] +let () = + register "ppx_test" test_mapper]} + + This -ppx rewriter, which replaces [[%test]] in expressions with + the constant [42], can be compiled using + [ocamlc -o ppx_test -I +compiler-libs ocamlcommon.cma ppx_test.ml]. - where [rv] is the hidden row variable. *) - | Tfield of string * field_kind * type_expr * type_expr - (** [Tfield ("foo", Fpresent, t, ts)] ==> [<...; foo : t; ts>] *) +open Parsetree - | Tnil - (** [Tnil] ==> [<...; >] *) +(** {1 A generic Parsetree mapper} *) - | Tlink of type_expr - (** Indirection used by unification engine. *) +type mapper = { + attribute: mapper -> attribute -> attribute; + attributes: mapper -> attribute list -> attribute list; + case: mapper -> case -> case; + cases: mapper -> case list -> case list; + class_declaration: mapper -> class_declaration -> class_declaration; + class_description: mapper -> class_description -> class_description; + class_expr: mapper -> class_expr -> class_expr; + class_field: mapper -> class_field -> class_field; + class_signature: mapper -> class_signature -> class_signature; + class_structure: mapper -> class_structure -> class_structure; + class_type: mapper -> class_type -> class_type; + class_type_declaration: mapper -> class_type_declaration + -> class_type_declaration; + class_type_field: mapper -> class_type_field -> class_type_field; + constructor_declaration: mapper -> constructor_declaration + -> constructor_declaration; + expr: mapper -> expression -> expression; + extension: mapper -> extension -> extension; + extension_constructor: mapper -> extension_constructor + -> extension_constructor; + include_declaration: mapper -> include_declaration -> include_declaration; + include_description: mapper -> include_description -> include_description; + label_declaration: mapper -> label_declaration -> label_declaration; + location: mapper -> Location.t -> Location.t; + module_binding: mapper -> module_binding -> module_binding; + module_declaration: mapper -> module_declaration -> module_declaration; + module_expr: mapper -> module_expr -> module_expr; + module_type: mapper -> module_type -> module_type; + module_type_declaration: mapper -> module_type_declaration + -> module_type_declaration; + open_description: mapper -> open_description -> open_description; + pat: mapper -> pattern -> pattern; + payload: mapper -> payload -> payload; + signature: mapper -> signature -> signature; + signature_item: mapper -> signature_item -> signature_item; + structure: mapper -> structure -> structure; + structure_item: mapper -> structure_item -> structure_item; + typ: mapper -> core_type -> core_type; + type_declaration: mapper -> type_declaration -> type_declaration; + type_extension: mapper -> type_extension -> type_extension; + type_kind: mapper -> type_kind -> type_kind; + value_binding: mapper -> value_binding -> value_binding; + value_description: mapper -> value_description -> value_description; + with_constraint: mapper -> with_constraint -> with_constraint; +} +(** A mapper record implements one "method" per syntactic category, + using an open recursion style: each method takes as its first + argument the mapper to be applied to children in the syntax + tree. *) - | Tsubst of type_expr (* for copying *) - (** [Tsubst] is used temporarily to store information in low-level - functions manipulating representation of types, such as - instantiation or copy. - This constructor should not appear outside of these cases. *) +val default_mapper: mapper +(** A default mapper, which implements a "deep identity" mapping. *) - | Tvariant of row_desc - (** Representation of polymorphic variants, see [row_desc]. *) +(** {1 Apply mappers to compilation units} *) - | Tunivar of string option - (** Occurrence of a type variable introduced by a - forall quantifier / [Tpoly]. *) +val tool_name: unit -> string +(** Can be used within a ppx preprocessor to know which tool is + calling it ["ocamlc"], ["ocamlopt"], ["ocamldoc"], ["ocamldep"], + ["ocaml"], ... Some global variables that reflect command-line + options are automatically synchronized between the calling tool + and the ppx preprocessor: {!Clflags.include_dirs}, + {!Config.load_path}, {!Clflags.open_modules}, {!Clflags.for_package}, + {!Clflags.debug}. *) - | Tpoly of type_expr * type_expr list - (** [Tpoly (ty,tyl)] ==> ['a1... 'an. ty], - where 'a1 ... 'an are names given to types in tyl - and occurrences of those types in ty. *) - | Tpackage of Path.t * Longident.t list * type_expr list - (** Type of a first-class module (a.k.a package). *) +val apply: source:string -> target:string -> mapper -> unit +(** Apply a mapper (parametrized by the unit name) to a dumped + parsetree found in the [source] file and put the result in the + [target] file. The [structure] or [signature] field of the mapper + is applied to the implementation or interface. *) -(** [ `X | `Y ] (row_closed = true) - [< `X | `Y ] (row_closed = true) - [> `X | `Y ] (row_closed = false) - [< `X | `Y > `X ] (row_closed = true) +val run_main: (string list -> mapper) -> unit +(** Entry point to call to implement a standalone -ppx rewriter from a + mapper, parametrized by the command line arguments. The current + unit name can be obtained from {!Location.input_name}. This + function implements proper error reporting for uncaught + exceptions. *) - type t = [> `X ] as 'a (row_more = Tvar a) - type t = private [> `X ] (row_more = Tconstr (t#row, [], ref Mnil) +(** {1 Registration API} *) - And for: +val register_function: (string -> (string list -> mapper) -> unit) ref - let f = function `X -> `X -> | `Y -> `X +val register: string -> (string list -> mapper) -> unit +(** Apply the [register_function]. The default behavior is to run the + mapper immediately, taking arguments from the process command + line. This is to support a scenario where a mapper is linked as a + stand-alone executable. - the type of "f" will be a [Tarrow] whose lhs will (basically) be: + It is possible to overwrite the [register_function] to define + "-ppx drivers", which combine several mappers in a single process. + Typically, a driver starts by defining [register_function] to a + custom implementation, then lets ppx rewriters (linked statically + or dynamically) register themselves, and then run all or some of + them. It is also possible to have -ppx drivers apply rewriters to + only specific parts of an AST. - Tvariant { row_fields = [("X", _)]; - row_more = - Tvariant { row_fields = [("Y", _)]; - row_more = - Tvariant { row_fields = []; - row_more = _; - _ }; - _ }; - _ - } + The first argument to [register] is a symbolic name to be used by + the ppx driver. *) -*) -and row_desc = - { row_fields: (label * row_field) list; - row_more: type_expr; - row_bound: unit; (* kept for compatibility *) - row_closed: bool; - row_fixed: bool; - row_name: (Path.t * type_expr list) option } -and row_field = - Rpresent of type_expr option - | Reither of bool * type_expr list * bool * row_field option ref - (* 1st true denotes a constant constructor *) - (* 2nd true denotes a tag in a pattern matching, and - is erased later *) - | Rabsent +(** {1 Convenience functions to write mappers} *) -(** [abbrev_memo] allows one to keep track of different expansions of a type - alias. This is done for performance purposes. +val map_opt: ('a -> 'b) -> 'a option -> 'b option - For instance, when defining [type 'a pair = 'a * 'a], when one refers to an - ['a pair], it is just a shortcut for the ['a * 'a] type. - This expansion will be stored in the [abbrev_memo] of the corresponding - [Tconstr] node. +val extension_of_error: Location.error -> extension +(** Encode an error into an 'ocaml.error' extension node which can be + inserted in a generated Parsetree. The compiler will be + responsible for reporting the error. *) - In practice, [abbrev_memo] behaves like list of expansions with a mutable - tail. +val attribute_of_warning: Location.t -> string -> attribute +(** Encode a warning message into an 'ocaml.ppwarning' attribute which can be + inserted in a generated Parsetree. The compiler will be + responsible for reporting the warning. *) - Note on marshalling: [abbrev_memo] must not appear in saved types. - [Btype], with [cleanup_abbrev] and [memo], takes care of tracking and - removing abbreviations. -*) -and abbrev_memo = - | Mnil (** No known abbreviation *) +(** {1 Helper functions to call external mappers} *) - | Mcons of private_flag * Path.t * type_expr * type_expr * abbrev_memo - (** Found one abbreviation. - A valid abbreviation should be at least as visible and reachable by the - same path. - The first expression is the abbreviation and the second the expansion. *) +val add_ppx_context_str: + tool_name:string -> Parsetree.structure -> Parsetree.structure +(** Extract information from the current environment and encode it + into an attribute which is prepended to the list of structure + items in order to pass the information to an external + processor. *) - | Mlink of abbrev_memo ref - (** Abbreviations can be found after this indirection *) +val add_ppx_context_sig: + tool_name:string -> Parsetree.signature -> Parsetree.signature +(** Same as [add_ppx_context_str], but for signatures. *) -and field_kind = - Fvar of field_kind option ref - | Fpresent - | Fabsent +val drop_ppx_context_str: + restore:bool -> Parsetree.structure -> Parsetree.structure +(** Drop the ocaml.ppx.context attribute from a structure. If + [restore] is true, also restore the associated data in the current + process. *) -(** [commutable] is a flag appended to every arrow type. +val drop_ppx_context_sig: + restore:bool -> Parsetree.signature -> Parsetree.signature +(** Same as [drop_ppx_context_str], but for signatures. *) - When typing an application, if the type of the functional is - known, its type is instantiated with [Cok] arrows, otherwise as - [Clink (ref Cunknown)]. +(** {1 Cookies} *) - When the type is not known, the application will be used to infer - the actual type. This is fragile in presence of labels where - there is no principal type. +(** Cookies are used to pass information from a ppx processor to + a further invocation of itself, when called from the OCaml + toplevel (or other tools that support cookies). *) - Two incompatible applications relying on [Cunknown] arrows will - trigger an error. +val set_cookie: string -> Parsetree.expression -> unit +val get_cookie: string -> Parsetree.expression option - let f g = - g ~a:() ~b:(); - g ~b:() ~a:(); +end = struct +#1 "ast_mapper.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Alain Frisch, LexiFi *) +(* *) +(* Copyright 2012 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) - Error: This function is applied to arguments - in an order different from other calls. - This is only allowed when the real type is known. +(* A generic Parsetree mapping class *) + +(* +[@@@ocaml.warning "+9"] + (* Ensure that record patterns don't miss any field. *) *) -and commutable = - Cok - | Cunknown - | Clink of commutable ref -module TypeOps : sig - type t = type_expr - val compare : t -> t -> int - val equal : t -> t -> bool - val hash : t -> int -end -(* Maps of methods and instance variables *) +open Parsetree +open Ast_helper +open Location -module Meths : Map.S with type key = string -module Vars : Map.S with type key = string +type mapper = { + attribute: mapper -> attribute -> attribute; + attributes: mapper -> attribute list -> attribute list; + case: mapper -> case -> case; + cases: mapper -> case list -> case list; + class_declaration: mapper -> class_declaration -> class_declaration; + class_description: mapper -> class_description -> class_description; + class_expr: mapper -> class_expr -> class_expr; + class_field: mapper -> class_field -> class_field; + class_signature: mapper -> class_signature -> class_signature; + class_structure: mapper -> class_structure -> class_structure; + class_type: mapper -> class_type -> class_type; + class_type_declaration: mapper -> class_type_declaration + -> class_type_declaration; + class_type_field: mapper -> class_type_field -> class_type_field; + constructor_declaration: mapper -> constructor_declaration + -> constructor_declaration; + expr: mapper -> expression -> expression; + extension: mapper -> extension -> extension; + extension_constructor: mapper -> extension_constructor + -> extension_constructor; + include_declaration: mapper -> include_declaration -> include_declaration; + include_description: mapper -> include_description -> include_description; + label_declaration: mapper -> label_declaration -> label_declaration; + location: mapper -> Location.t -> Location.t; + module_binding: mapper -> module_binding -> module_binding; + module_declaration: mapper -> module_declaration -> module_declaration; + module_expr: mapper -> module_expr -> module_expr; + module_type: mapper -> module_type -> module_type; + module_type_declaration: mapper -> module_type_declaration + -> module_type_declaration; + open_description: mapper -> open_description -> open_description; + pat: mapper -> pattern -> pattern; + payload: mapper -> payload -> payload; + signature: mapper -> signature -> signature; + signature_item: mapper -> signature_item -> signature_item; + structure: mapper -> structure -> structure; + structure_item: mapper -> structure_item -> structure_item; + typ: mapper -> core_type -> core_type; + type_declaration: mapper -> type_declaration -> type_declaration; + type_extension: mapper -> type_extension -> type_extension; + type_kind: mapper -> type_kind -> type_kind; + value_binding: mapper -> value_binding -> value_binding; + value_description: mapper -> value_description -> value_description; + with_constraint: mapper -> with_constraint -> with_constraint; +} -(* Value descriptions *) +let map_fst f (x, y) = (f x, y) +let map_snd f (x, y) = (x, f y) +let map_tuple f1 f2 (x, y) = (f1 x, f2 y) +let map_tuple3 f1 f2 f3 (x, y, z) = (f1 x, f2 y, f3 z) +let map_opt f = function None -> None | Some x -> Some (f x) -type value_description = - { val_type: type_expr; (* Type of the value *) - val_kind: value_kind; - val_loc: Location.t; - val_attributes: Parsetree.attributes; - } +let map_loc sub {loc; txt} = {loc = sub.location sub loc; txt} -and value_kind = - Val_reg (* Regular value *) - | Val_prim of Primitive.description (* Primitive *) - | Val_ivar of mutable_flag * string (* Instance variable (mutable ?) *) - | Val_self of (Ident.t * type_expr) Meths.t ref * - (Ident.t * mutable_flag * virtual_flag * type_expr) Vars.t ref * - string * type_expr - (* Self *) - | Val_anc of (string * Ident.t) list * string - (* Ancestor *) - | Val_unbound (* Unbound variable *) +module T = struct + (* Type expressions for the core language *) -(* Variance *) + let row_field sub = function + | Rtag (l, attrs, b, tl) -> + Rtag (map_loc sub l, sub.attributes sub attrs, + b, List.map (sub.typ sub) tl) + | Rinherit t -> Rinherit (sub.typ sub t) -module Variance : sig - type t - type f = May_pos | May_neg | May_weak | Inj | Pos | Neg | Inv - val null : t (* no occurrence *) - val full : t (* strictly invariant *) - val covariant : t (* strictly covariant *) - val may_inv : t (* maybe invariant *) - val union : t -> t -> t - val inter : t -> t -> t - val subset : t -> t -> bool - val set : f -> bool -> t -> t - val mem : f -> t -> bool - val conjugate : t -> t (* exchange positive and negative *) - val get_upper : t -> bool * bool (* may_pos, may_neg *) - val get_lower : t -> bool * bool * bool * bool (* pos, neg, inv, inj *) -end + let object_field sub = function + | Otag (l, attrs, t) -> + Otag (map_loc sub l, sub.attributes sub attrs, sub.typ sub t) + | Oinherit t -> Oinherit (sub.typ sub t) -(* Type definitions *) + let map sub {ptyp_desc = desc; ptyp_loc = loc; ptyp_attributes = attrs} = + let open Typ in + let loc = sub.location sub loc in + let attrs = sub.attributes sub attrs in + match desc with + | Ptyp_any -> any ~loc ~attrs () + | Ptyp_var s -> var ~loc ~attrs s + | Ptyp_arrow (lab, t1, t2) -> + arrow ~loc ~attrs lab (sub.typ sub t1) (sub.typ sub t2) + | Ptyp_tuple tyl -> tuple ~loc ~attrs (List.map (sub.typ sub) tyl) + | Ptyp_constr (lid, tl) -> + constr ~loc ~attrs (map_loc sub lid) (List.map (sub.typ sub) tl) + | Ptyp_object (l, o) -> + object_ ~loc ~attrs (List.map (object_field sub) l) o + | Ptyp_class (lid, tl) -> + class_ ~loc ~attrs (map_loc sub lid) (List.map (sub.typ sub) tl) + | Ptyp_alias (t, s) -> alias ~loc ~attrs (sub.typ sub t) s + | Ptyp_variant (rl, b, ll) -> + variant ~loc ~attrs (List.map (row_field sub) rl) b ll + | Ptyp_poly (sl, t) -> poly ~loc ~attrs + (List.map (map_loc sub) sl) (sub.typ sub t) + | Ptyp_package (lid, l) -> + package ~loc ~attrs (map_loc sub lid) + (List.map (map_tuple (map_loc sub) (sub.typ sub)) l) + | Ptyp_extension x -> extension ~loc ~attrs (sub.extension sub x) -type type_declaration = - { type_params: type_expr list; - type_arity: int; - type_kind: type_kind; - type_private: private_flag; - type_manifest: type_expr option; - type_variance: Variance.t list; - (* covariant, contravariant, weakly contravariant, injective *) - type_newtype_level: (int * int) option; - (* definition level * expansion level *) - type_loc: Location.t; - type_attributes: Parsetree.attributes; - type_immediate: bool; (* true iff type should not be a pointer *) - type_unboxed: unboxed_status; - } + let map_type_declaration sub + {ptype_name; ptype_params; ptype_cstrs; + ptype_kind; + ptype_private; + ptype_manifest; + ptype_attributes; + ptype_loc} = + Type.mk (map_loc sub ptype_name) + ~params:(List.map (map_fst (sub.typ sub)) ptype_params) + ~priv:ptype_private + ~cstrs:(List.map + (map_tuple3 (sub.typ sub) (sub.typ sub) (sub.location sub)) + ptype_cstrs) + ~kind:(sub.type_kind sub ptype_kind) + ?manifest:(map_opt (sub.typ sub) ptype_manifest) + ~loc:(sub.location sub ptype_loc) + ~attrs:(sub.attributes sub ptype_attributes) -and type_kind = - Type_abstract - | Type_record of label_declaration list * record_representation - | Type_variant of constructor_declaration list - | Type_open + let map_type_kind sub = function + | Ptype_abstract -> Ptype_abstract + | Ptype_variant l -> + Ptype_variant (List.map (sub.constructor_declaration sub) l) + | Ptype_record l -> Ptype_record (List.map (sub.label_declaration sub) l) + | Ptype_open -> Ptype_open + + let map_constructor_arguments sub = function + | Pcstr_tuple l -> Pcstr_tuple (List.map (sub.typ sub) l) + | Pcstr_record l -> + Pcstr_record (List.map (sub.label_declaration sub) l) + + let map_type_extension sub + {ptyext_path; ptyext_params; + ptyext_constructors; + ptyext_private; + ptyext_attributes} = + Te.mk + (map_loc sub ptyext_path) + (List.map (sub.extension_constructor sub) ptyext_constructors) + ~params:(List.map (map_fst (sub.typ sub)) ptyext_params) + ~priv:ptyext_private + ~attrs:(sub.attributes sub ptyext_attributes) -and record_representation = - Record_regular (* All fields are boxed / tagged *) - | Record_float (* All fields are floats *) - | Record_unboxed of bool (* Unboxed single-field record, inlined or not *) - | Record_inlined of { tag : int ; name : string; num_nonconsts : int} (* Inlined record *) - | Record_extension (* Inlined record under extension *) + let map_extension_constructor_kind sub = function + Pext_decl(ctl, cto) -> + Pext_decl(map_constructor_arguments sub ctl, map_opt (sub.typ sub) cto) + | Pext_rebind li -> + Pext_rebind (map_loc sub li) -and label_declaration = - { - ld_id: Ident.t; - ld_mutable: mutable_flag; - ld_type: type_expr; - ld_loc: Location.t; - ld_attributes: Parsetree.attributes; - } + let map_extension_constructor sub + {pext_name; + pext_kind; + pext_loc; + pext_attributes} = + Te.constructor + (map_loc sub pext_name) + (map_extension_constructor_kind sub pext_kind) + ~loc:(sub.location sub pext_loc) + ~attrs:(sub.attributes sub pext_attributes) -and constructor_declaration = - { - cd_id: Ident.t; - cd_args: constructor_arguments; - cd_res: type_expr option; - cd_loc: Location.t; - cd_attributes: Parsetree.attributes; - } +end -and constructor_arguments = - | Cstr_tuple of type_expr list - | Cstr_record of label_declaration list +module CT = struct + (* Type expressions for the class language *) -and unboxed_status = private - (* This type must be private in order to ensure perfect sharing of the - four possible values. Otherwise, ocamlc.byte and ocamlc.opt produce - different executables. *) - { - unboxed: bool; - default: bool; (* True for unannotated unboxable types. *) - } + let map sub {pcty_loc = loc; pcty_desc = desc; pcty_attributes = attrs} = + let open Cty in + let loc = sub.location sub loc in + let attrs = sub.attributes sub attrs in + match desc with + | Pcty_constr (lid, tys) -> + constr ~loc ~attrs (map_loc sub lid) (List.map (sub.typ sub) tys) + | Pcty_signature x -> signature ~loc ~attrs (sub.class_signature sub x) + | Pcty_arrow (lab, t, ct) -> + arrow ~loc ~attrs lab (sub.typ sub t) (sub.class_type sub ct) + | Pcty_extension x -> extension ~loc ~attrs (sub.extension sub x) + | Pcty_open (ovf, lid, ct) -> + open_ ~loc ~attrs ovf (map_loc sub lid) (sub.class_type sub ct) -val unboxed_false_default_false : unboxed_status -val unboxed_false_default_true : unboxed_status -val unboxed_true_default_false : unboxed_status -val unboxed_true_default_true : unboxed_status + let map_field sub {pctf_desc = desc; pctf_loc = loc; pctf_attributes = attrs} + = + let open Ctf in + let loc = sub.location sub loc in + let attrs = sub.attributes sub attrs in + match desc with + | Pctf_inherit ct -> inherit_ ~loc ~attrs (sub.class_type sub ct) + | Pctf_val (s, m, v, t) -> + val_ ~loc ~attrs (map_loc sub s) m v (sub.typ sub t) + | Pctf_method (s, p, v, t) -> + method_ ~loc ~attrs (map_loc sub s) p v (sub.typ sub t) + | Pctf_constraint (t1, t2) -> + constraint_ ~loc ~attrs (sub.typ sub t1) (sub.typ sub t2) + | Pctf_attribute x -> attribute ~loc (sub.attribute sub x) + | Pctf_extension x -> extension ~loc ~attrs (sub.extension sub x) -type extension_constructor = - { - ext_type_path: Path.t; - ext_type_params: type_expr list; - ext_args: constructor_arguments; - ext_ret_type: type_expr option; - ext_private: private_flag; - ext_loc: Location.t; - ext_attributes: Parsetree.attributes; - } + let map_signature sub {pcsig_self; pcsig_fields} = + Csig.mk + (sub.typ sub pcsig_self) + (List.map (sub.class_type_field sub) pcsig_fields) +end -and type_transparence = - Type_public (* unrestricted expansion *) - | Type_new (* "new" type *) - | Type_private (* private type *) +module MT = struct + (* Type expressions for the module language *) -(* Type expressions for the class language *) + let map sub {pmty_desc = desc; pmty_loc = loc; pmty_attributes = attrs} = + let open Mty in + let loc = sub.location sub loc in + let attrs = sub.attributes sub attrs in + match desc with + | Pmty_ident s -> ident ~loc ~attrs (map_loc sub s) + | Pmty_alias s -> alias ~loc ~attrs (map_loc sub s) + | Pmty_signature sg -> signature ~loc ~attrs (sub.signature sub sg) + | Pmty_functor (s, mt1, mt2) -> + functor_ ~loc ~attrs (map_loc sub s) + (Misc.may_map (sub.module_type sub) mt1) + (sub.module_type sub mt2) + | Pmty_with (mt, l) -> + with_ ~loc ~attrs (sub.module_type sub mt) + (List.map (sub.with_constraint sub) l) + | Pmty_typeof me -> typeof_ ~loc ~attrs (sub.module_expr sub me) + | Pmty_extension x -> extension ~loc ~attrs (sub.extension sub x) -module Concr : Set.S with type elt = string + let map_with_constraint sub = function + | Pwith_type (lid, d) -> + Pwith_type (map_loc sub lid, sub.type_declaration sub d) + | Pwith_module (lid, lid2) -> + Pwith_module (map_loc sub lid, map_loc sub lid2) + | Pwith_typesubst (lid, d) -> + Pwith_typesubst (map_loc sub lid, sub.type_declaration sub d) + | Pwith_modsubst (s, lid) -> + Pwith_modsubst (map_loc sub s, map_loc sub lid) -type class_type = - Cty_constr of Path.t * type_expr list * class_type - | Cty_signature of class_signature - | Cty_arrow of arg_label * type_expr * class_type + let map_signature_item sub {psig_desc = desc; psig_loc = loc} = + let open Sig in + let loc = sub.location sub loc in + match desc with + | Psig_value vd -> value ~loc (sub.value_description sub vd) + | Psig_type (rf, l) -> type_ ~loc rf (List.map (sub.type_declaration sub) l) + | Psig_typext te -> type_extension ~loc (sub.type_extension sub te) + | Psig_exception ed -> exception_ ~loc (sub.extension_constructor sub ed) + | Psig_module x -> module_ ~loc (sub.module_declaration sub x) + | Psig_recmodule l -> + rec_module ~loc (List.map (sub.module_declaration sub) l) + | Psig_modtype x -> modtype ~loc (sub.module_type_declaration sub x) + | Psig_open x -> open_ ~loc (sub.open_description sub x) + | Psig_include x -> include_ ~loc (sub.include_description sub x) + | Psig_class l -> class_ ~loc (List.map (sub.class_description sub) l) + | Psig_class_type l -> + class_type ~loc (List.map (sub.class_type_declaration sub) l) + | Psig_extension (x, attrs) -> + extension ~loc (sub.extension sub x) ~attrs:(sub.attributes sub attrs) + | Psig_attribute x -> attribute ~loc (sub.attribute sub x) +end -and class_signature = - { csig_self: type_expr; - csig_vars: - (Asttypes.mutable_flag * Asttypes.virtual_flag * type_expr) Vars.t; - csig_concr: Concr.t; - csig_inher: (Path.t * type_expr list) list } -type class_declaration = - { cty_params: type_expr list; - mutable cty_type: class_type; - cty_path: Path.t; - cty_new: type_expr option; - cty_variance: Variance.t list; - cty_loc: Location.t; - cty_attributes: Parsetree.attributes; - } +module M = struct + (* Value expressions for the module language *) -type class_type_declaration = - { clty_params: type_expr list; - clty_type: class_type; - clty_path: Path.t; - clty_variance: Variance.t list; - clty_loc: Location.t; - clty_attributes: Parsetree.attributes; - } + let map sub {pmod_loc = loc; pmod_desc = desc; pmod_attributes = attrs} = + let open Mod in + let loc = sub.location sub loc in + let attrs = sub.attributes sub attrs in + match desc with + | Pmod_ident x -> ident ~loc ~attrs (map_loc sub x) + | Pmod_structure str -> structure ~loc ~attrs (sub.structure sub str) + | Pmod_functor (arg, arg_ty, body) -> + functor_ ~loc ~attrs (map_loc sub arg) + (Misc.may_map (sub.module_type sub) arg_ty) + (sub.module_expr sub body) + | Pmod_apply (m1, m2) -> + apply ~loc ~attrs (sub.module_expr sub m1) (sub.module_expr sub m2) + | Pmod_constraint (m, mty) -> + constraint_ ~loc ~attrs (sub.module_expr sub m) + (sub.module_type sub mty) + | Pmod_unpack e -> unpack ~loc ~attrs (sub.expr sub e) + | Pmod_extension x -> extension ~loc ~attrs (sub.extension sub x) -(* Type expressions for the module language *) + let map_structure_item sub {pstr_loc = loc; pstr_desc = desc} = + let open Str in + let loc = sub.location sub loc in + match desc with + | Pstr_eval (x, attrs) -> + eval ~loc ~attrs:(sub.attributes sub attrs) (sub.expr sub x) + | Pstr_value (r, vbs) -> value ~loc r (List.map (sub.value_binding sub) vbs) + | Pstr_primitive vd -> primitive ~loc (sub.value_description sub vd) + | Pstr_type (rf, l) -> type_ ~loc rf (List.map (sub.type_declaration sub) l) + | Pstr_typext te -> type_extension ~loc (sub.type_extension sub te) + | Pstr_exception ed -> exception_ ~loc (sub.extension_constructor sub ed) + | Pstr_module x -> module_ ~loc (sub.module_binding sub x) + | Pstr_recmodule l -> rec_module ~loc (List.map (sub.module_binding sub) l) + | Pstr_modtype x -> modtype ~loc (sub.module_type_declaration sub x) + | Pstr_open x -> open_ ~loc (sub.open_description sub x) + | Pstr_class l -> class_ ~loc (List.map (sub.class_declaration sub) l) + | Pstr_class_type l -> + class_type ~loc (List.map (sub.class_type_declaration sub) l) + | Pstr_include x -> include_ ~loc (sub.include_declaration sub x) + | Pstr_extension (x, attrs) -> + extension ~loc (sub.extension sub x) ~attrs:(sub.attributes sub attrs) + | Pstr_attribute x -> attribute ~loc (sub.attribute sub x) +end -type module_type = - Mty_ident of Path.t - | Mty_signature of signature - | Mty_functor of Ident.t * module_type option * module_type - | Mty_alias of alias_presence * Path.t +module E = struct + (* Value expressions for the core language *) -and alias_presence = - | Mta_present - | Mta_absent + let map sub {pexp_loc = loc; pexp_desc = desc; pexp_attributes = attrs} = + let open Exp in + let loc = sub.location sub loc in + let attrs = sub.attributes sub attrs in + match desc with + | Pexp_ident x -> ident ~loc ~attrs (map_loc sub x) + | Pexp_constant x -> constant ~loc ~attrs x + | Pexp_let (r, vbs, e) -> + let_ ~loc ~attrs r (List.map (sub.value_binding sub) vbs) + (sub.expr sub e) + | Pexp_fun (lab, def, p, e) -> + fun_ ~loc ~attrs lab (map_opt (sub.expr sub) def) (sub.pat sub p) + (sub.expr sub e) + | Pexp_function pel -> function_ ~loc ~attrs (sub.cases sub pel) + | Pexp_apply (e, l) -> + apply ~loc ~attrs (sub.expr sub e) (List.map (map_snd (sub.expr sub)) l) + | Pexp_match (e, pel) -> + match_ ~loc ~attrs (sub.expr sub e) (sub.cases sub pel) + | Pexp_try (e, pel) -> try_ ~loc ~attrs (sub.expr sub e) (sub.cases sub pel) + | Pexp_tuple el -> tuple ~loc ~attrs (List.map (sub.expr sub) el) + | Pexp_construct (lid, arg) -> + construct ~loc ~attrs (map_loc sub lid) (map_opt (sub.expr sub) arg) + | Pexp_variant (lab, eo) -> + variant ~loc ~attrs lab (map_opt (sub.expr sub) eo) + | Pexp_record (l, eo) -> + record ~loc ~attrs (List.map (map_tuple (map_loc sub) (sub.expr sub)) l) + (map_opt (sub.expr sub) eo) + | Pexp_field (e, lid) -> + field ~loc ~attrs (sub.expr sub e) (map_loc sub lid) + | Pexp_setfield (e1, lid, e2) -> + setfield ~loc ~attrs (sub.expr sub e1) (map_loc sub lid) + (sub.expr sub e2) + | Pexp_array el -> array ~loc ~attrs (List.map (sub.expr sub) el) + | Pexp_ifthenelse (e1, e2, e3) -> + ifthenelse ~loc ~attrs (sub.expr sub e1) (sub.expr sub e2) + (map_opt (sub.expr sub) e3) + | Pexp_sequence (e1, e2) -> + sequence ~loc ~attrs (sub.expr sub e1) (sub.expr sub e2) + | Pexp_while (e1, e2) -> + while_ ~loc ~attrs (sub.expr sub e1) (sub.expr sub e2) + | Pexp_for (p, e1, e2, d, e3) -> + for_ ~loc ~attrs (sub.pat sub p) (sub.expr sub e1) (sub.expr sub e2) d + (sub.expr sub e3) + | Pexp_coerce (e, t1, t2) -> + coerce ~loc ~attrs (sub.expr sub e) (map_opt (sub.typ sub) t1) + (sub.typ sub t2) + | Pexp_constraint (e, t) -> + constraint_ ~loc ~attrs (sub.expr sub e) (sub.typ sub t) + | Pexp_send (e, s) -> + send ~loc ~attrs (sub.expr sub e) (map_loc sub s) + | Pexp_new lid -> new_ ~loc ~attrs (map_loc sub lid) + | Pexp_setinstvar (s, e) -> + setinstvar ~loc ~attrs (map_loc sub s) (sub.expr sub e) + | Pexp_override sel -> + override ~loc ~attrs + (List.map (map_tuple (map_loc sub) (sub.expr sub)) sel) + | Pexp_letmodule (s, me, e) -> + letmodule ~loc ~attrs (map_loc sub s) (sub.module_expr sub me) + (sub.expr sub e) + | Pexp_letexception (cd, e) -> + letexception ~loc ~attrs + (sub.extension_constructor sub cd) + (sub.expr sub e) + | Pexp_assert e -> assert_ ~loc ~attrs (sub.expr sub e) + | Pexp_lazy e -> lazy_ ~loc ~attrs (sub.expr sub e) + | Pexp_poly (e, t) -> + poly ~loc ~attrs (sub.expr sub e) (map_opt (sub.typ sub) t) + | Pexp_object cls -> object_ ~loc ~attrs (sub.class_structure sub cls) + | Pexp_newtype (s, e) -> + newtype ~loc ~attrs (map_loc sub s) (sub.expr sub e) + | Pexp_pack me -> pack ~loc ~attrs (sub.module_expr sub me) + | Pexp_open (ovf, lid, e) -> + open_ ~loc ~attrs ovf (map_loc sub lid) (sub.expr sub e) + | Pexp_extension x -> extension ~loc ~attrs (sub.extension sub x) + | Pexp_unreachable -> unreachable ~loc ~attrs () +end -and signature = signature_item list +module P = struct + (* Patterns *) -and signature_item = - Sig_value of Ident.t * value_description - | Sig_type of Ident.t * type_declaration * rec_status - | Sig_typext of Ident.t * extension_constructor * ext_status - | Sig_module of Ident.t * module_declaration * rec_status - | Sig_modtype of Ident.t * modtype_declaration - | Sig_class of Ident.t * class_declaration * rec_status - | Sig_class_type of Ident.t * class_type_declaration * rec_status + let map sub {ppat_desc = desc; ppat_loc = loc; ppat_attributes = attrs} = + let open Pat in + let loc = sub.location sub loc in + let attrs = sub.attributes sub attrs in + match desc with + | Ppat_any -> any ~loc ~attrs () + | Ppat_var s -> var ~loc ~attrs (map_loc sub s) + | Ppat_alias (p, s) -> alias ~loc ~attrs (sub.pat sub p) (map_loc sub s) + | Ppat_constant c -> constant ~loc ~attrs c + | Ppat_interval (c1, c2) -> interval ~loc ~attrs c1 c2 + | Ppat_tuple pl -> tuple ~loc ~attrs (List.map (sub.pat sub) pl) + | Ppat_construct (l, p) -> + construct ~loc ~attrs (map_loc sub l) (map_opt (sub.pat sub) p) + | Ppat_variant (l, p) -> variant ~loc ~attrs l (map_opt (sub.pat sub) p) + | Ppat_record (lpl, cf) -> + record ~loc ~attrs + (List.map (map_tuple (map_loc sub) (sub.pat sub)) lpl) cf + | Ppat_array pl -> array ~loc ~attrs (List.map (sub.pat sub) pl) + | Ppat_or (p1, p2) -> or_ ~loc ~attrs (sub.pat sub p1) (sub.pat sub p2) + | Ppat_constraint (p, t) -> + constraint_ ~loc ~attrs (sub.pat sub p) (sub.typ sub t) + | Ppat_type s -> type_ ~loc ~attrs (map_loc sub s) + | Ppat_lazy p -> lazy_ ~loc ~attrs (sub.pat sub p) + | Ppat_unpack s -> unpack ~loc ~attrs (map_loc sub s) + | Ppat_open (lid,p) -> open_ ~loc ~attrs (map_loc sub lid) (sub.pat sub p) + | Ppat_exception p -> exception_ ~loc ~attrs (sub.pat sub p) + | Ppat_extension x -> extension ~loc ~attrs (sub.extension sub x) +end -and module_declaration = - { - md_type: module_type; - md_attributes: Parsetree.attributes; - md_loc: Location.t; - } +module CE = struct + (* Value expressions for the class language *) -and modtype_declaration = - { - mtd_type: module_type option; (* None: abstract *) - mtd_attributes: Parsetree.attributes; - mtd_loc: Location.t; - } + let map sub {pcl_loc = loc; pcl_desc = desc; pcl_attributes = attrs} = + let open Cl in + let loc = sub.location sub loc in + let attrs = sub.attributes sub attrs in + match desc with + | Pcl_constr (lid, tys) -> + constr ~loc ~attrs (map_loc sub lid) (List.map (sub.typ sub) tys) + | Pcl_structure s -> + structure ~loc ~attrs (sub.class_structure sub s) + | Pcl_fun (lab, e, p, ce) -> + fun_ ~loc ~attrs lab + (map_opt (sub.expr sub) e) + (sub.pat sub p) + (sub.class_expr sub ce) + | Pcl_apply (ce, l) -> + apply ~loc ~attrs (sub.class_expr sub ce) + (List.map (map_snd (sub.expr sub)) l) + | Pcl_let (r, vbs, ce) -> + let_ ~loc ~attrs r (List.map (sub.value_binding sub) vbs) + (sub.class_expr sub ce) + | Pcl_constraint (ce, ct) -> + constraint_ ~loc ~attrs (sub.class_expr sub ce) (sub.class_type sub ct) + | Pcl_extension x -> extension ~loc ~attrs (sub.extension sub x) + | Pcl_open (ovf, lid, ce) -> + open_ ~loc ~attrs ovf (map_loc sub lid) (sub.class_expr sub ce) -and rec_status = - Trec_not (* first in a nonrecursive group *) - | Trec_first (* first in a recursive group *) - | Trec_next (* not first in a recursive/nonrecursive group *) + let map_kind sub = function + | Cfk_concrete (o, e) -> Cfk_concrete (o, sub.expr sub e) + | Cfk_virtual t -> Cfk_virtual (sub.typ sub t) -and ext_status = - Text_first (* first constructor in an extension *) - | Text_next (* not first constructor in an extension *) - | Text_exception + let map_field sub {pcf_desc = desc; pcf_loc = loc; pcf_attributes = attrs} = + let open Cf in + let loc = sub.location sub loc in + let attrs = sub.attributes sub attrs in + match desc with + | Pcf_inherit (o, ce, s) -> + inherit_ ~loc ~attrs o (sub.class_expr sub ce) + (map_opt (map_loc sub) s) + | Pcf_val (s, m, k) -> val_ ~loc ~attrs (map_loc sub s) m (map_kind sub k) + | Pcf_method (s, p, k) -> + method_ ~loc ~attrs (map_loc sub s) p (map_kind sub k) + | Pcf_constraint (t1, t2) -> + constraint_ ~loc ~attrs (sub.typ sub t1) (sub.typ sub t2) + | Pcf_initializer e -> initializer_ ~loc ~attrs (sub.expr sub e) + | Pcf_attribute x -> attribute ~loc (sub.attribute sub x) + | Pcf_extension x -> extension ~loc ~attrs (sub.extension sub x) + let map_structure sub {pcstr_self; pcstr_fields} = + { + pcstr_self = sub.pat sub pcstr_self; + pcstr_fields = List.map (sub.class_field sub) pcstr_fields; + } -(* Constructor and record label descriptions inserted held in typing - environments *) + let class_infos sub f {pci_virt; pci_params = pl; pci_name; pci_expr; + pci_loc; pci_attributes} = + Ci.mk + ~virt:pci_virt + ~params:(List.map (map_fst (sub.typ sub)) pl) + (map_loc sub pci_name) + (f pci_expr) + ~loc:(sub.location sub pci_loc) + ~attrs:(sub.attributes sub pci_attributes) +end -type constructor_description = - { cstr_name: string; (* Constructor name *) - cstr_res: type_expr; (* Type of the result *) - cstr_existentials: type_expr list; (* list of existentials *) - cstr_args: type_expr list; (* Type of the arguments *) - cstr_arity: int; (* Number of arguments *) - cstr_tag: constructor_tag; (* Tag for heap blocks *) - cstr_consts: int; (* Number of constant constructors *) - cstr_nonconsts: int; (* Number of non-const constructors *) - cstr_normal: int; (* Number of non generalized constrs *) - cstr_generalized: bool; (* Constrained return type? *) - cstr_private: private_flag; (* Read-only constructor? *) - cstr_loc: Location.t; - cstr_attributes: Parsetree.attributes; - cstr_inlined: type_declaration option; - } +(* Now, a generic AST mapper, to be extended to cover all kinds and + cases of the OCaml grammar. The default behavior of the mapper is + the identity. *) -and constructor_tag = - Cstr_constant of int (* Constant constructor (an int) *) - | Cstr_block of int (* Regular constructor (a block) *) - | Cstr_unboxed (* Constructor of an unboxed type *) - | Cstr_extension of Path.t * bool (* Extension constructor - true if a constant false if a block*) +let default_mapper = + { + structure = (fun this l -> List.map (this.structure_item this) l); + structure_item = M.map_structure_item; + module_expr = M.map; + signature = (fun this l -> List.map (this.signature_item this) l); + signature_item = MT.map_signature_item; + module_type = MT.map; + with_constraint = MT.map_with_constraint; + class_declaration = + (fun this -> CE.class_infos this (this.class_expr this)); + class_expr = CE.map; + class_field = CE.map_field; + class_structure = CE.map_structure; + class_type = CT.map; + class_type_field = CT.map_field; + class_signature = CT.map_signature; + class_type_declaration = + (fun this -> CE.class_infos this (this.class_type this)); + class_description = + (fun this -> CE.class_infos this (this.class_type this)); + type_declaration = T.map_type_declaration; + type_kind = T.map_type_kind; + typ = T.map; + type_extension = T.map_type_extension; + extension_constructor = T.map_extension_constructor; + value_description = + (fun this {pval_name; pval_type; pval_prim; pval_loc; + pval_attributes} -> + Val.mk + (map_loc this pval_name) + (this.typ this pval_type) + ~attrs:(this.attributes this pval_attributes) + ~loc:(this.location this pval_loc) + ~prim:pval_prim + ); -(* Constructors are the same *) -val equal_tag : constructor_tag -> constructor_tag -> bool + pat = P.map; + expr = E.map; -(* Constructors may be the same, given potential rebinding *) -val may_equal_constr : - constructor_description -> constructor_description -> bool + module_declaration = + (fun this {pmd_name; pmd_type; pmd_attributes; pmd_loc} -> + Md.mk + (map_loc this pmd_name) + (this.module_type this pmd_type) + ~attrs:(this.attributes this pmd_attributes) + ~loc:(this.location this pmd_loc) + ); -type label_description = - { lbl_name: string; (* Short name *) - lbl_res: type_expr; (* Type of the result *) - lbl_arg: type_expr; (* Type of the argument *) - lbl_mut: mutable_flag; (* Is this a mutable field? *) - lbl_pos: int; (* Position in block *) - lbl_all: label_description array; (* All the labels in this type *) - lbl_repres: record_representation; (* Representation for this record *) - lbl_private: private_flag; (* Read-only field? *) - lbl_loc: Location.t; - lbl_attributes: Parsetree.attributes; - } + module_type_declaration = + (fun this {pmtd_name; pmtd_type; pmtd_attributes; pmtd_loc} -> + Mtd.mk + (map_loc this pmtd_name) + ?typ:(map_opt (this.module_type this) pmtd_type) + ~attrs:(this.attributes this pmtd_attributes) + ~loc:(this.location this pmtd_loc) + ); -end = struct -#1 "types.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) + module_binding = + (fun this {pmb_name; pmb_expr; pmb_attributes; pmb_loc} -> + Mb.mk (map_loc this pmb_name) (this.module_expr this pmb_expr) + ~attrs:(this.attributes this pmb_attributes) + ~loc:(this.location this pmb_loc) + ); -(* Representation of types and declarations *) -open Asttypes + open_description = + (fun this {popen_lid; popen_override; popen_attributes; popen_loc} -> + Opn.mk (map_loc this popen_lid) + ~override:popen_override + ~loc:(this.location this popen_loc) + ~attrs:(this.attributes this popen_attributes) + ); -(* Type expressions for the core language *) -type type_expr = - { mutable desc: type_desc; - mutable level: int; - id: int } + include_description = + (fun this {pincl_mod; pincl_attributes; pincl_loc} -> + Incl.mk (this.module_type this pincl_mod) + ~loc:(this.location this pincl_loc) + ~attrs:(this.attributes this pincl_attributes) + ); -and type_desc = - Tvar of string option - | Tarrow of arg_label * type_expr * type_expr * commutable - | Ttuple of type_expr list - | Tconstr of Path.t * type_expr list * abbrev_memo ref - | Tobject of type_expr * (Path.t * type_expr list) option ref - | Tfield of string * field_kind * type_expr * type_expr - | Tnil - | Tlink of type_expr - | Tsubst of type_expr (* for copying *) - | Tvariant of row_desc - | Tunivar of string option - | Tpoly of type_expr * type_expr list - | Tpackage of Path.t * Longident.t list * type_expr list + include_declaration = + (fun this {pincl_mod; pincl_attributes; pincl_loc} -> + Incl.mk (this.module_expr this pincl_mod) + ~loc:(this.location this pincl_loc) + ~attrs:(this.attributes this pincl_attributes) + ); -and row_desc = - { row_fields: (label * row_field) list; - row_more: type_expr; - row_bound: unit; - row_closed: bool; - row_fixed: bool; - row_name: (Path.t * type_expr list) option } -and row_field = - Rpresent of type_expr option - | Reither of bool * type_expr list * bool * row_field option ref - (* 1st true denotes a constant constructor *) - (* 2nd true denotes a tag in a pattern matching, and - is erased later *) - | Rabsent + value_binding = + (fun this {pvb_pat; pvb_expr; pvb_attributes; pvb_loc} -> + Vb.mk + (this.pat this pvb_pat) + (this.expr this pvb_expr) + ~loc:(this.location this pvb_loc) + ~attrs:(this.attributes this pvb_attributes) + ); -and abbrev_memo = - Mnil - | Mcons of private_flag * Path.t * type_expr * type_expr * abbrev_memo - | Mlink of abbrev_memo ref -and field_kind = - Fvar of field_kind option ref - | Fpresent - | Fabsent + constructor_declaration = + (fun this {pcd_name; pcd_args; pcd_res; pcd_loc; pcd_attributes} -> + Type.constructor + (map_loc this pcd_name) + ~args:(T.map_constructor_arguments this pcd_args) + ?res:(map_opt (this.typ this) pcd_res) + ~loc:(this.location this pcd_loc) + ~attrs:(this.attributes this pcd_attributes) + ); -and commutable = - Cok - | Cunknown - | Clink of commutable ref + label_declaration = + (fun this {pld_name; pld_type; pld_loc; pld_mutable; pld_attributes} -> + Type.field + (map_loc this pld_name) + (this.typ this pld_type) + ~mut:pld_mutable + ~loc:(this.location this pld_loc) + ~attrs:(this.attributes this pld_attributes) + ); -module TypeOps = struct - type t = type_expr - let compare t1 t2 = t1.id - t2.id - let hash t = t.id - let equal t1 t2 = t1 == t2 -end + cases = (fun this l -> List.map (this.case this) l); + case = + (fun this {pc_lhs; pc_guard; pc_rhs} -> + { + pc_lhs = this.pat this pc_lhs; + pc_guard = map_opt (this.expr this) pc_guard; + pc_rhs = this.expr this pc_rhs; + } + ); -(* Maps of methods and instance variables *) -module OrderedString = - struct type t = string let compare (x:t) y = compare x y end -module Meths = Map.Make(OrderedString) -module Vars = Meths -(* Value descriptions *) + location = (fun _this l -> l); -type value_description = - { val_type: type_expr; (* Type of the value *) - val_kind: value_kind; - val_loc: Location.t; - val_attributes: Parsetree.attributes; - } + extension = (fun this (s, e) -> (map_loc this s, this.payload this e)); + attribute = (fun this (s, e) -> (map_loc this s, this.payload this e)); + attributes = (fun this l -> List.map (this.attribute this) l); + payload = + (fun this -> function + | PStr x -> PStr (this.structure this x) + | PSig x -> PSig (this.signature this x) + | PTyp x -> PTyp (this.typ this x) + | PPat (x, g) -> PPat (this.pat this x, map_opt (this.expr this) g) + ); + } -and value_kind = - Val_reg (* Regular value *) - | Val_prim of Primitive.description (* Primitive *) - | Val_ivar of mutable_flag * string (* Instance variable (mutable ?) *) - | Val_self of (Ident.t * type_expr) Meths.t ref * - (Ident.t * Asttypes.mutable_flag * - Asttypes.virtual_flag * type_expr) Vars.t ref * - string * type_expr - (* Self *) - | Val_anc of (string * Ident.t) list * string - (* Ancestor *) - | Val_unbound (* Unbound variable *) +let rec extension_of_error {loc; msg; if_highlight; sub} = + { loc; txt = "ocaml.error" }, + PStr ([Str.eval (Exp.constant (Pconst_string (msg, None))); + Str.eval (Exp.constant (Pconst_string (if_highlight, None)))] @ + (List.map (fun ext -> Str.extension (extension_of_error ext)) sub)) -(* Variance *) +let attribute_of_warning loc s = + { loc; txt = "ocaml.ppwarning" }, + PStr ([Str.eval ~loc (Exp.constant (Pconst_string (s, None)))]) -module Variance = struct - type t = int - type f = May_pos | May_neg | May_weak | Inj | Pos | Neg | Inv - let single = function - | May_pos -> 1 - | May_neg -> 2 - | May_weak -> 4 - | Inj -> 8 - | Pos -> 16 - | Neg -> 32 - | Inv -> 64 - let union v1 v2 = v1 lor v2 - let inter v1 v2 = v1 land v2 - let subset v1 v2 = (v1 land v2 = v1) - let set x b v = - if b then v lor single x else v land (lnot (single x)) - let mem x = subset (single x) - let null = 0 - let may_inv = 7 - let full = 127 - let covariant = single May_pos lor single Pos lor single Inj - let swap f1 f2 v = - let v' = set f1 (mem f2 v) v in set f2 (mem f1 v) v' - let conjugate v = swap May_pos May_neg (swap Pos Neg v) - let get_upper v = (mem May_pos v, mem May_neg v) - let get_lower v = (mem Pos v, mem Neg v, mem Inv v, mem Inj v) -end +module StringMap = Map.Make(struct + type t = string + let compare = compare +end) -(* Type definitions *) +let cookies = ref StringMap.empty -type type_declaration = - { type_params: type_expr list; - type_arity: int; - type_kind: type_kind; - type_private: private_flag; - type_manifest: type_expr option; - type_variance: Variance.t list; - type_newtype_level: (int * int) option; - type_loc: Location.t; - type_attributes: Parsetree.attributes; - type_immediate: bool; - type_unboxed: unboxed_status; - } +let get_cookie k = + try Some (StringMap.find k !cookies) + with Not_found -> None -and type_kind = - Type_abstract - | Type_record of label_declaration list * record_representation - | Type_variant of constructor_declaration list - | Type_open +let set_cookie k v = + cookies := StringMap.add k v !cookies -and record_representation = - Record_regular (* All fields are boxed / tagged *) - | Record_float (* All fields are floats *) - | Record_unboxed of bool (* Unboxed single-field record, inlined or not *) - | Record_inlined of {tag : int; name : string; num_nonconsts : int} (* Inlined record *) - | Record_extension (* Inlined record under extension *) +let tool_name_ref = ref "_none_" -and label_declaration = - { - ld_id: Ident.t; - ld_mutable: mutable_flag; - ld_type: type_expr; - ld_loc: Location.t; - ld_attributes: Parsetree.attributes; - } +let tool_name () = !tool_name_ref -and constructor_declaration = - { - cd_id: Ident.t; - cd_args: constructor_arguments; - cd_res: type_expr option; - cd_loc: Location.t; - cd_attributes: Parsetree.attributes; - } -and constructor_arguments = - | Cstr_tuple of type_expr list - | Cstr_record of label_declaration list +module PpxContext = struct + open Longident + open Asttypes + open Ast_helper -and unboxed_status = - { - unboxed: bool; - default: bool; (* False if the unboxed field was set from an attribute. *) - } + let lid name = { txt = Lident name; loc = Location.none } -let unboxed_false_default_false = {unboxed = false; default = false} -let unboxed_false_default_true = {unboxed = false; default = true} -let unboxed_true_default_false = {unboxed = true; default = false} -let unboxed_true_default_true = {unboxed = true; default = true} + let make_string x = Exp.constant (Pconst_string (x, None)) -type extension_constructor = - { ext_type_path: Path.t; - ext_type_params: type_expr list; - ext_args: constructor_arguments; - ext_ret_type: type_expr option; - ext_private: private_flag; - ext_loc: Location.t; - ext_attributes: Parsetree.attributes; } + let make_bool x = + if x + then Exp.construct (lid "true") None + else Exp.construct (lid "false") None -and type_transparence = - Type_public (* unrestricted expansion *) - | Type_new (* "new" type *) - | Type_private (* private type *) + let rec make_list f lst = + match lst with + | x :: rest -> + Exp.construct (lid "::") (Some (Exp.tuple [f x; make_list f rest])) + | [] -> + Exp.construct (lid "[]") None -(* Type expressions for the class language *) + let make_pair f1 f2 (x1, x2) = + Exp.tuple [f1 x1; f2 x2] -module Concr = Set.Make(OrderedString) + let make_option f opt = + match opt with + | Some x -> Exp.construct (lid "Some") (Some (f x)) + | None -> Exp.construct (lid "None") None -type class_type = - Cty_constr of Path.t * type_expr list * class_type - | Cty_signature of class_signature - | Cty_arrow of arg_label * type_expr * class_type + let get_cookies () = + lid "cookies", + make_list (make_pair make_string (fun x -> x)) + (StringMap.bindings !cookies) -and class_signature = - { csig_self: type_expr; - csig_vars: - (Asttypes.mutable_flag * Asttypes.virtual_flag * type_expr) Vars.t; - csig_concr: Concr.t; - csig_inher: (Path.t * type_expr list) list } + let mk fields = + { txt = "ocaml.ppx.context"; loc = Location.none }, + Parsetree.PStr [Str.eval (Exp.record fields None)] -type class_declaration = - { cty_params: type_expr list; - mutable cty_type: class_type; - cty_path: Path.t; - cty_new: type_expr option; - cty_variance: Variance.t list; - cty_loc: Location.t; - cty_attributes: Parsetree.attributes; - } + let make ~tool_name () = + let fields = + [ + lid "tool_name", make_string tool_name; + lid "include_dirs", make_list make_string !Clflags.include_dirs; + lid "load_path", make_list make_string !Config.load_path; + lid "open_modules", make_list make_string !Clflags.open_modules; + lid "for_package", make_option make_string !Clflags.for_package; + lid "debug", make_bool !Clflags.debug; + lid "use_threads", make_bool !Clflags.use_threads; + lid "use_vmthreads", make_bool !Clflags.use_vmthreads; + get_cookies () + ] + in + mk fields -type class_type_declaration = - { clty_params: type_expr list; - clty_type: class_type; - clty_path: Path.t; - clty_variance: Variance.t list; - clty_loc: Location.t; - clty_attributes: Parsetree.attributes; - } + let get_fields = function + | PStr [{pstr_desc = Pstr_eval + ({ pexp_desc = Pexp_record (fields, None) }, [])}] -> + fields + | _ -> + raise_errorf "Internal error: invalid [@@@ocaml.ppx.context] syntax" -(* Type expressions for the module language *) + let restore fields = + let field name payload = + let rec get_string = function + | { pexp_desc = Pexp_constant (Pconst_string (str, None)) } -> str + | _ -> raise_errorf "Internal error: invalid [@@@ocaml.ppx.context \ + { %s }] string syntax" name + and get_bool pexp = + match pexp with + | {pexp_desc = Pexp_construct ({txt = Longident.Lident "true"}, + None)} -> + true + | {pexp_desc = Pexp_construct ({txt = Longident.Lident "false"}, + None)} -> + false + | _ -> raise_errorf "Internal error: invalid [@@@ocaml.ppx.context \ + { %s }] bool syntax" name + and get_list elem = function + | {pexp_desc = + Pexp_construct ({txt = Longident.Lident "::"}, + Some {pexp_desc = Pexp_tuple [exp; rest]}) } -> + elem exp :: get_list elem rest + | {pexp_desc = + Pexp_construct ({txt = Longident.Lident "[]"}, None)} -> + [] + | _ -> raise_errorf "Internal error: invalid [@@@ocaml.ppx.context \ + { %s }] list syntax" name + and get_pair f1 f2 = function + | {pexp_desc = Pexp_tuple [e1; e2]} -> + (f1 e1, f2 e2) + | _ -> raise_errorf "Internal error: invalid [@@@ocaml.ppx.context \ + { %s }] pair syntax" name + and get_option elem = function + | { pexp_desc = + Pexp_construct ({ txt = Longident.Lident "Some" }, Some exp) } -> + Some (elem exp) + | { pexp_desc = + Pexp_construct ({ txt = Longident.Lident "None" }, None) } -> + None + | _ -> raise_errorf "Internal error: invalid [@@@ocaml.ppx.context \ + { %s }] option syntax" name + in + match name with + | "tool_name" -> + tool_name_ref := get_string payload + | "include_dirs" -> + Clflags.include_dirs := get_list get_string payload + | "load_path" -> + Config.load_path := get_list get_string payload + | "open_modules" -> + Clflags.open_modules := get_list get_string payload + | "for_package" -> + Clflags.for_package := get_option get_string payload + | "debug" -> + Clflags.debug := get_bool payload + | "use_threads" -> + Clflags.use_threads := get_bool payload + | "use_vmthreads" -> + Clflags.use_vmthreads := get_bool payload + | "cookies" -> + let l = get_list (get_pair get_string (fun x -> x)) payload in + cookies := + List.fold_left + (fun s (k, v) -> StringMap.add k v s) StringMap.empty + l + | _ -> + () + in + List.iter (function ({txt=Lident name}, x) -> field name x | _ -> ()) fields -type module_type = - Mty_ident of Path.t - | Mty_signature of signature - | Mty_functor of Ident.t * module_type option * module_type - | Mty_alias of alias_presence * Path.t + let update_cookies fields = + let fields = + List.filter + (function ({txt=Lident "cookies"}, _) -> false | _ -> true) + fields + in + fields @ [get_cookies ()] +end -and alias_presence = - | Mta_present - | Mta_absent +let ppx_context = PpxContext.make -and signature = signature_item list +let extension_of_exn exn = + match error_of_exn exn with + | Some (`Ok error) -> extension_of_error error + | Some `Already_displayed -> { loc = Location.none; txt = "ocaml.error" }, PStr [] + | None -> raise exn -and signature_item = - Sig_value of Ident.t * value_description - | Sig_type of Ident.t * type_declaration * rec_status - | Sig_typext of Ident.t * extension_constructor * ext_status - | Sig_module of Ident.t * module_declaration * rec_status - | Sig_modtype of Ident.t * modtype_declaration - | Sig_class of Ident.t * class_declaration * rec_status - | Sig_class_type of Ident.t * class_type_declaration * rec_status -and module_declaration = - { - md_type: module_type; - md_attributes: Parsetree.attributes; - md_loc: Location.t; - } +let apply_lazy ~source ~target mapper = + let implem ast = + let fields, ast = + match ast with + | {pstr_desc = Pstr_attribute ({txt = "ocaml.ppx.context"}, x)} :: l -> + PpxContext.get_fields x, l + | _ -> [], ast + in + PpxContext.restore fields; + let ast = + try + let mapper = mapper () in + mapper.structure mapper ast + with exn -> + [{pstr_desc = Pstr_extension (extension_of_exn exn, []); + pstr_loc = Location.none}] + in + let fields = PpxContext.update_cookies fields in + Str.attribute (PpxContext.mk fields) :: ast + in + let iface ast = + let fields, ast = + match ast with + | {psig_desc = Psig_attribute ({txt = "ocaml.ppx.context"}, x)} :: l -> + PpxContext.get_fields x, l + | _ -> [], ast + in + PpxContext.restore fields; + let ast = + try + let mapper = mapper () in + mapper.signature mapper ast + with exn -> + [{psig_desc = Psig_extension (extension_of_exn exn, []); + psig_loc = Location.none}] + in + let fields = PpxContext.update_cookies fields in + Sig.attribute (PpxContext.mk fields) :: ast + in + + let ic = open_in_bin source in + let magic = + really_input_string ic (String.length Config.ast_impl_magic_number) + in -and modtype_declaration = - { - mtd_type: module_type option; (* Note: abstract *) - mtd_attributes: Parsetree.attributes; - mtd_loc: Location.t; - } + let rewrite transform = + Location.set_input_name @@ input_value ic; + let ast = input_value ic in + close_in ic; + let ast = transform ast in + let oc = open_out_bin target in + output_string oc magic; + output_value oc !Location.input_name; + output_value oc ast; + close_out oc + and fail () = + close_in ic; + failwith "Ast_mapper: OCaml version mismatch or malformed input"; + in -and rec_status = - Trec_not (* first in a nonrecursive group *) - | Trec_first (* first in a recursive group *) - | Trec_next (* not first in a recursive/nonrecursive group *) + if magic = Config.ast_impl_magic_number then + rewrite (implem : structure -> structure) + else if magic = Config.ast_intf_magic_number then + rewrite (iface : signature -> signature) + else fail () -and ext_status = - Text_first (* first constructor of an extension *) - | Text_next (* not first constructor of an extension *) - | Text_exception (* an exception *) +let drop_ppx_context_str ~restore = function + | {pstr_desc = Pstr_attribute({Location.txt = "ocaml.ppx.context"}, a)} + :: items -> + if restore then + PpxContext.restore (PpxContext.get_fields a); + items + | items -> items +let drop_ppx_context_sig ~restore = function + | {psig_desc = Psig_attribute({Location.txt = "ocaml.ppx.context"}, a)} + :: items -> + if restore then + PpxContext.restore (PpxContext.get_fields a); + items + | items -> items -(* Constructor and record label descriptions inserted held in typing - environments *) +let add_ppx_context_str ~tool_name ast = + Ast_helper.Str.attribute (ppx_context ~tool_name ()) :: ast -type constructor_description = - { cstr_name: string; (* Constructor name *) - cstr_res: type_expr; (* Type of the result *) - cstr_existentials: type_expr list; (* list of existentials *) - cstr_args: type_expr list; (* Type of the arguments *) - cstr_arity: int; (* Number of arguments *) - cstr_tag: constructor_tag; (* Tag for heap blocks *) - cstr_consts: int; (* Number of constant constructors *) - cstr_nonconsts: int; (* Number of non-const constructors *) - cstr_normal: int; (* Number of non generalized constrs *) - cstr_generalized: bool; (* Constrained return type? *) - cstr_private: private_flag; (* Read-only constructor? *) - cstr_loc: Location.t; - cstr_attributes: Parsetree.attributes; - cstr_inlined: type_declaration option; - } +let add_ppx_context_sig ~tool_name ast = + Ast_helper.Sig.attribute (ppx_context ~tool_name ()) :: ast -and constructor_tag = - Cstr_constant of int (* Constant constructor (an int) *) - | Cstr_block of int (* Regular constructor (a block) *) - | Cstr_unboxed (* Constructor of an unboxed type *) - | Cstr_extension of Path.t * bool (* Extension constructor - true if a constant false if a block*) -let equal_tag t1 t2 = - match (t1, t2) with - | Cstr_constant i1, Cstr_constant i2 -> i2 = i1 - | Cstr_block i1, Cstr_block i2 -> i2 = i1 - | Cstr_unboxed, Cstr_unboxed -> true - | Cstr_extension (path1, b1), Cstr_extension (path2, b2) -> - Path.same path1 path2 && b1 = b2 - | (Cstr_constant _|Cstr_block _|Cstr_unboxed|Cstr_extension _), _ -> false +let apply ~source ~target mapper = + apply_lazy ~source ~target (fun () -> mapper) -let may_equal_constr c1 c2 = match c1.cstr_tag,c2.cstr_tag with -| Cstr_extension _,Cstr_extension _ -> c1.cstr_arity = c2.cstr_arity -| tag1,tag2 -> equal_tag tag1 tag2 +let run_main mapper = + try + let a = Sys.argv in + let n = Array.length a in + if n > 2 then + let mapper () = + try mapper (Array.to_list (Array.sub a 1 (n - 3))) + with exn -> + (* PR#6463 *) + let f _ _ = raise exn in + {default_mapper with structure = f; signature = f} + in + apply_lazy ~source:a.(n - 2) ~target:a.(n - 1) mapper + else begin + Printf.eprintf "Usage: %s [extra_args] \n%!" + Sys.executable_name; + exit 2 + end + with exn -> + prerr_endline (Printexc.to_string exn); + exit 2 -type label_description = - { lbl_name: string; (* Short name *) - lbl_res: type_expr; (* Type of the result *) - lbl_arg: type_expr; (* Type of the argument *) - lbl_mut: mutable_flag; (* Is this a mutable field? *) - lbl_pos: int; (* Position in block *) - lbl_all: label_description array; (* All the labels in this type *) - lbl_repres: record_representation; (* Representation for this record *) - lbl_private: private_flag; (* Read-only field? *) - lbl_loc: Location.t; - lbl_attributes: Parsetree.attributes; - } +let register_function = ref (fun _name f -> run_main f) +let register name f = !register_function name f end -module Btype : sig -#1 "btype.mli" +module Tbl : sig +#1 "tbl.mli" (**************************************************************************) (* *) (* OCaml *) @@ -47817,220 +30796,33 @@ module Btype : sig (* *) (**************************************************************************) -(* Basic operations on core types *) - -open Asttypes -open Types - -(**** Sets, maps and hashtables of types ****) - -module TypeSet : Set.S with type elt = type_expr -module TypeMap : Map.S with type key = type_expr -module TypeHash : Hashtbl.S with type key = type_expr - -(**** Levels ****) - -val generic_level: int - -val newty2: int -> type_desc -> type_expr - (* Create a type *) -val newgenty: type_desc -> type_expr - (* Create a generic type *) -val newgenvar: ?name:string -> unit -> type_expr - (* Return a fresh generic variable *) - -(* Use Tsubst instead -val newmarkedvar: int -> type_expr - (* Return a fresh marked variable *) -val newmarkedgenvar: unit -> type_expr - (* Return a fresh marked generic variable *) -*) - -(**** Types ****) - -val is_Tvar: type_expr -> bool -val is_Tunivar: type_expr -> bool -val is_Tconstr: type_expr -> bool -val dummy_method: label -val default_mty: module_type option -> module_type - -val repr: type_expr -> type_expr - (* Return the canonical representative of a type. *) - -val field_kind_repr: field_kind -> field_kind - (* Return the canonical representative of an object field - kind. *) - -val commu_repr: commutable -> commutable - (* Return the canonical representative of a commutation lock *) - -(**** polymorphic variants ****) - -val row_repr: row_desc -> row_desc - (* Return the canonical representative of a row description *) -val row_field_repr: row_field -> row_field -val row_field: label -> row_desc -> row_field - (* Return the canonical representative of a row field *) -val row_more: row_desc -> type_expr - (* Return the extension variable of the row *) -val row_fixed: row_desc -> bool - (* Return whether the row should be treated as fixed or not *) -val static_row: row_desc -> bool - (* Return whether the row is static or not *) -val hash_variant: label -> int - (* Hash function for variant tags *) - -val proxy: type_expr -> type_expr - (* Return the proxy representative of the type: either itself - or a row variable *) - -(**** Utilities for private abbreviations with fixed rows ****) -val row_of_type: type_expr -> type_expr -val has_constr_row: type_expr -> bool -val is_row_name: string -> bool -val is_constr_row: allow_ident:bool -> type_expr -> bool - -(**** Utilities for type traversal ****) - -val iter_type_expr: (type_expr -> unit) -> type_expr -> unit - (* Iteration on types *) -val iter_row: (type_expr -> unit) -> row_desc -> unit - (* Iteration on types in a row *) -val iter_abbrev: (type_expr -> unit) -> abbrev_memo -> unit - (* Iteration on types in an abbreviation list *) - -type type_iterators = - { it_signature: type_iterators -> signature -> unit; - it_signature_item: type_iterators -> signature_item -> unit; - it_value_description: type_iterators -> value_description -> unit; - it_type_declaration: type_iterators -> type_declaration -> unit; - it_extension_constructor: type_iterators -> extension_constructor -> unit; - it_module_declaration: type_iterators -> module_declaration -> unit; - it_modtype_declaration: type_iterators -> modtype_declaration -> unit; - it_class_declaration: type_iterators -> class_declaration -> unit; - it_class_type_declaration: type_iterators -> class_type_declaration -> unit; - it_module_type: type_iterators -> module_type -> unit; - it_class_type: type_iterators -> class_type -> unit; - it_type_kind: type_iterators -> type_kind -> unit; - it_do_type_expr: type_iterators -> type_expr -> unit; - it_type_expr: type_iterators -> type_expr -> unit; - it_path: Path.t -> unit; } -val type_iterators: type_iterators - (* Iteration on arbitrary type information. - [it_type_expr] calls [mark_type_node] to avoid loops. *) -val unmark_iterators: type_iterators - (* Unmark any structure containing types. See [unmark_type] below. *) - -val copy_type_desc: - ?keep_names:bool -> (type_expr -> type_expr) -> type_desc -> type_desc - (* Copy on types *) -val copy_row: - (type_expr -> type_expr) -> - bool -> row_desc -> bool -> type_expr -> row_desc -val copy_kind: field_kind -> field_kind - -val save_desc: type_expr -> type_desc -> unit - (* Save a type description *) -val dup_kind: field_kind option ref -> unit - (* Save a None field_kind, and make it point to a fresh Fvar *) -val cleanup_types: unit -> unit - (* Restore type descriptions *) - -val lowest_level: int - (* Marked type: ty.level < lowest_level *) -val pivot_level: int - (* Type marking: ty.level <- pivot_level - ty.level *) -val mark_type: type_expr -> unit - (* Mark a type *) -val mark_type_node: type_expr -> unit - (* Mark a type node (but not its sons) *) -val mark_type_params: type_expr -> unit - (* Mark the sons of a type node *) -val unmark_type: type_expr -> unit -val unmark_type_decl: type_declaration -> unit -val unmark_extension_constructor: extension_constructor -> unit -val unmark_class_type: class_type -> unit -val unmark_class_signature: class_signature -> unit - (* Remove marks from a type *) - -(**** Memorization of abbreviation expansion ****) - -val find_expans: private_flag -> Path.t -> abbrev_memo -> type_expr option - (* Look up a memorized abbreviation *) -val cleanup_abbrev: unit -> unit - (* Flush the cache of abbreviation expansions. - When some types are saved (using [output_value]), this - function MUST be called just before. *) -val memorize_abbrev: - abbrev_memo ref -> - private_flag -> Path.t -> type_expr -> type_expr -> unit - (* Add an expansion in the cache *) -val forget_abbrev: - abbrev_memo ref -> Path.t -> unit - (* Remove an abbreviation from the cache *) - -(**** Utilities for labels ****) - -val is_optional : arg_label -> bool -val label_name : arg_label -> label - -(* Returns the label name with first character '?' or '~' as appropriate. *) -val prefixed_label_name : arg_label -> label - -val extract_label : - label -> (arg_label * 'a) list -> - arg_label * 'a * (arg_label * 'a) list * (arg_label * 'a) list - (* actual label, value, before list, after list *) - -(**** Utilities for backtracking ****) - -type snapshot - (* A snapshot for backtracking *) -val snapshot: unit -> snapshot - (* Make a snapshot for later backtracking. Costs nothing *) -val backtrack: snapshot -> unit - (* Backtrack to a given snapshot. Only possible if you have - not already backtracked to a previous snapshot. - Calls [cleanup_abbrev] internally *) -val undo_compress: snapshot -> unit - (* Backtrack only path compression. Only meaningful if you have - not already backtracked to a previous snapshot. - Does not call [cleanup_abbrev] *) +(* Association tables from any ordered type to any type. + We use the generic ordering to compare keys. *) -(* Functions to use when modifying a type (only Ctype?) *) -val link_type: type_expr -> type_expr -> unit - (* Set the desc field of [t1] to [Tlink t2], logging the old - value if there is an active snapshot *) -val set_level: type_expr -> int -> unit -val set_name: - (Path.t * type_expr list) option ref -> - (Path.t * type_expr list) option -> unit -val set_row_field: row_field option ref -> row_field -> unit -val set_univar: type_expr option ref -> type_expr -> unit -val set_kind: field_kind option ref -> field_kind -> unit -val set_commu: commutable ref -> commutable -> unit -val set_typeset: TypeSet.t ref -> TypeSet.t -> unit - (* Set references, logging the old value *) -val log_type: type_expr -> unit - (* Log the old value of a type, before modifying it by hand *) +type ('k, 'v) t -(**** Forward declarations ****) -val print_raw: (Format.formatter -> type_expr -> unit) ref +val empty: ('k, 'v) t +val add: 'k -> 'v -> ('k, 'v) t -> ('k, 'v) t +val find: 'k -> ('k, 'v) t -> 'v +val find_str: string -> (string, 'v) t -> 'v +val mem: 'k -> ('k, 'v) t -> bool +val remove: 'k -> ('k, 'v) t -> ('k, 'v) t +val iter: ('k -> 'v -> unit) -> ('k, 'v) t -> unit +val map: ('k -> 'v1 -> 'v2) -> ('k, 'v1) t -> ('k, 'v2) t +val fold: ('k -> 'v -> 'acc -> 'acc) -> ('k, 'v) t -> 'acc -> 'acc -val iter_type_expr_kind: (type_expr -> unit) -> (type_kind -> unit) +open Format -val iter_type_expr_cstr_args: (type_expr -> unit) -> - (constructor_arguments -> unit) -val map_type_expr_cstr_args: (type_expr -> type_expr) -> - (constructor_arguments -> constructor_arguments) +val print: (formatter -> 'k -> unit) -> (formatter -> 'v -> unit) -> + formatter -> ('k, 'v) t -> unit end = struct -#1 "btype.ml" +#1 "tbl.ml" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Xavier Leroy and Jerome Vouillon, projet Cristal, INRIA Rocquencourt *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) (* *) (* Copyright 1996 Institut National de Recherche en Informatique et *) (* en Automatique. *) @@ -48041,739 +30833,693 @@ end = struct (* *) (**************************************************************************) -(* Basic operations on core types *) - -open Misc -open Asttypes -open Types - -(**** Sets, maps and hashtables of types ****) - -module TypeSet = Set.Make(TypeOps) -module TypeMap = Map.Make (TypeOps) -module TypeHash = Hashtbl.Make(TypeOps) - -(**** Forward declarations ****) - -let print_raw = - ref (fun _ -> assert false : Format.formatter -> type_expr -> unit) - -(**** Type level management ****) - -let generic_level = 100000000 - -(* Used to mark a type during a traversal. *) -let lowest_level = 0 -let pivot_level = 2 * lowest_level - 1 - (* pivot_level - lowest_level < lowest_level *) - -(**** Some type creators ****) - -let new_id = ref (-1) - -let newty2 level desc = - incr new_id; { desc; level; id = !new_id } -let newgenty desc = newty2 generic_level desc -let newgenvar ?name () = newgenty (Tvar name) -(* -let newmarkedvar level = - incr new_id; { desc = Tvar; level = pivot_level - level; id = !new_id } -let newmarkedgenvar () = - incr new_id; - { desc = Tvar; level = pivot_level - generic_level; id = !new_id } -*) - -(**** Check some types ****) - -let is_Tvar = function {desc=Tvar _} -> true | _ -> false -let is_Tunivar = function {desc=Tunivar _} -> true | _ -> false -let is_Tconstr = function {desc=Tconstr _} -> true | _ -> false - -let dummy_method = "*dummy method*" -let default_mty = function - Some mty -> mty - | None -> Mty_signature [] - -(**** Definitions for backtracking ****) - -type change = - Ctype of type_expr * type_desc - | Ccompress of type_expr * type_desc * type_desc - | Clevel of type_expr * int - | Cname of - (Path.t * type_expr list) option ref * (Path.t * type_expr list) option - | Crow of row_field option ref * row_field option - | Ckind of field_kind option ref * field_kind option - | Ccommu of commutable ref * commutable - | Cuniv of type_expr option ref * type_expr option - | Ctypeset of TypeSet.t ref * TypeSet.t - -type changes = - Change of change * changes ref - | Unchanged - | Invalid - -let trail = Weak.create 1 - -let log_change ch = - match Weak.get trail 0 with None -> () - | Some r -> - let r' = ref Unchanged in - r := Change (ch, r'); - Weak.set trail 0 (Some r') - -(**** Representative of a type ****) - -let rec field_kind_repr = - function - Fvar {contents = Some kind} -> field_kind_repr kind - | kind -> kind - -let rec repr_link compress t d = - function - {desc = Tlink t' as d'} -> - repr_link true t d' t' - | {desc = Tfield (_, k, _, t') as d'} when field_kind_repr k = Fabsent -> - repr_link true t d' t' - | t' -> - if compress then begin - log_change (Ccompress (t, t.desc, d)); t.desc <- d - end; - t' - -let repr t = - match t.desc with - Tlink t' as d -> - repr_link false t d t' - | Tfield (_, k, _, t') as d when field_kind_repr k = Fabsent -> - repr_link false t d t' - | _ -> t - -let rec commu_repr = function - Clink r when !r <> Cunknown -> commu_repr !r - | c -> c +type ('k, 'v) t = + Empty + | Node of ('k, 'v) t * 'k * 'v * ('k, 'v) t * int -let rec row_field_repr_aux tl = function - Reither(_, tl', _, {contents = Some fi}) -> - row_field_repr_aux (tl@tl') fi - | Reither(c, tl', m, r) -> - Reither(c, tl@tl', m, r) - | Rpresent (Some _) when tl <> [] -> - Rpresent (Some (List.hd tl)) - | fi -> fi +let empty = Empty -let row_field_repr fi = row_field_repr_aux [] fi +let height = function + Empty -> 0 + | Node(_,_,_,_,h) -> h -let rec rev_concat l ll = - match ll with - [] -> l - | l'::ll -> rev_concat (l'@l) ll +let create l x d r = + let hl = height l and hr = height r in + Node(l, x, d, r, (if hl >= hr then hl + 1 else hr + 1)) -let rec row_repr_aux ll row = - match (repr row.row_more).desc with - | Tvariant row' -> - let f = row.row_fields in - row_repr_aux (if f = [] then ll else f::ll) row' - | _ -> - if ll = [] then row else - {row with row_fields = rev_concat row.row_fields ll} +let bal l x d r = + let hl = height l and hr = height r in + if hl > hr + 1 then + match l with + | Node (ll, lv, ld, lr, _) when height ll >= height lr -> + create ll lv ld (create lr x d r) + | Node (ll, lv, ld, Node (lrl, lrv, lrd, lrr, _), _) -> + create (create ll lv ld lrl) lrv lrd (create lrr x d r) + | _ -> assert false + else if hr > hl + 1 then + match r with + | Node (rl, rv, rd, rr, _) when height rr >= height rl -> + create (create l x d rl) rv rd rr + | Node (Node (rll, rlv, rld, rlr, _), rv, rd, rr, _) -> + create (create l x d rll) rlv rld (create rlr rv rd rr) + | _ -> assert false + else + create l x d r -let row_repr row = row_repr_aux [] row +let rec add x data = function + Empty -> + Node(Empty, x, data, Empty, 1) + | Node(l, v, d, r, h) -> + let c = compare x v in + if c = 0 then + Node(l, x, data, r, h) + else if c < 0 then + bal (add x data l) v d r + else + bal l v d (add x data r) -let rec row_field tag row = - let rec find = function - | (tag',f) :: fields -> - if tag = tag' then row_field_repr f else find fields - | [] -> - match repr row.row_more with - | {desc=Tvariant row'} -> row_field tag row' - | _ -> Rabsent - in find row.row_fields +let rec find x = function + Empty -> + raise Not_found + | Node(l, v, d, r, _) -> + let c = compare x v in + if c = 0 then d + else find x (if c < 0 then l else r) -let rec row_more row = - match repr row.row_more with - | {desc=Tvariant row'} -> row_more row' - | ty -> ty +let rec find_str (x : string) = function + Empty -> + raise Not_found + | Node(l, v, d, r, _) -> + let c = compare x v in + if c = 0 then d + else find_str x (if c < 0 then l else r) -let row_fixed row = - let row = row_repr row in - row.row_fixed || - match (repr row.row_more).desc with - Tvar _ | Tnil -> false - | Tunivar _ | Tconstr _ -> true - | _ -> assert false +let rec mem x = function + Empty -> false + | Node(l, v, _d, r, _) -> + let c = compare x v in + c = 0 || mem x (if c < 0 then l else r) -let static_row row = - let row = row_repr row in - row.row_closed && - List.for_all - (fun (_,f) -> match row_field_repr f with Reither _ -> false | _ -> true) - row.row_fields +let rec merge t1 t2 = + match (t1, t2) with + (Empty, t) -> t + | (t, Empty) -> t + | (Node(l1, v1, d1, r1, _h1), Node(l2, v2, d2, r2, _h2)) -> + bal l1 v1 d1 (bal (merge r1 l2) v2 d2 r2) -let hash_variant s = - let accu = ref 0 in - for i = 0 to String.length s - 1 do - accu := 223 * !accu + Char.code s.[i] - done; - (* reduce to 31 bits *) - accu := !accu land (1 lsl 31 - 1); - (* make it signed for 64 bits architectures *) - if !accu > 0x3FFFFFFF then !accu - (1 lsl 31) else !accu +let rec remove x = function + Empty -> + Empty + | Node(l, v, d, r, _h) -> + let c = compare x v in + if c = 0 then + merge l r + else if c < 0 then + bal (remove x l) v d r + else + bal l v d (remove x r) -let proxy ty = - let ty0 = repr ty in - match ty0.desc with - | Tvariant row when not (static_row row) -> - row_more row - | Tobject (ty, _) -> - let rec proxy_obj ty = - match ty.desc with - Tfield (_, _, _, ty) | Tlink ty -> proxy_obj ty - | Tvar _ | Tunivar _ | Tconstr _ -> ty - | Tnil -> ty0 - | _ -> assert false - in proxy_obj ty - | _ -> ty0 +let rec iter f = function + Empty -> () + | Node(l, v, d, r, _) -> + iter f l; f v d; iter f r -(**** Utilities for fixed row private types ****) +let rec map f = function + Empty -> Empty + | Node(l, v, d, r, h) -> Node(map f l, v, f v d, map f r, h) -let row_of_type t = - match (repr t).desc with - Tobject(t,_) -> - let rec get_row t = - let t = repr t in - match t.desc with - Tfield(_,_,_,t) -> get_row t - | _ -> t - in get_row t - | Tvariant row -> - row_more row - | _ -> - t +let rec fold f m accu = + match m with + | Empty -> accu + | Node(l, v, d, r, _) -> + fold f r (f v d (fold f l accu)) -let has_constr_row t = - not (is_Tconstr t) && is_Tconstr (row_of_type t) +open Format -let is_row_name s = - let l = String.length s in - if l < 4 then false else String.sub s (l-4) 4 = "#row" +let print print_key print_data ppf tbl = + let print_tbl ppf tbl = + iter (fun k d -> fprintf ppf "@[<2>%a ->@ %a;@]@ " print_key k print_data d) + tbl in + fprintf ppf "@[[[%a]]@]" print_tbl tbl -let is_constr_row ~allow_ident t = - match t.desc with - Tconstr (Path.Pident id, _, _) when allow_ident -> - is_row_name (Ident.name id) - | Tconstr (Path.Pdot (_, s, _), _, _) -> is_row_name s - | _ -> false +end +module Subst : sig +#1 "subst.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) +(* Substitutions *) - (**********************************) - (* Utilities for type traversal *) - (**********************************) +open Types -let rec iter_row f row = - List.iter - (fun (_, fi) -> - match row_field_repr fi with - | Rpresent(Some ty) -> f ty - | Reither(_, tl, _, _) -> List.iter f tl - | _ -> ()) - row.row_fields; - match (repr row.row_more).desc with - Tvariant row -> iter_row f row - | Tvar _ | Tunivar _ | Tsubst _ | Tconstr _ | Tnil -> - Misc.may (fun (_,l) -> List.iter f l) row.row_name - | _ -> assert false +type t -let iter_type_expr f ty = - match ty.desc with - Tvar _ -> () - | Tarrow (_, ty1, ty2, _) -> f ty1; f ty2 - | Ttuple l -> List.iter f l - | Tconstr (_, l, _) -> List.iter f l - | Tobject(ty, {contents = Some (_, p)}) - -> f ty; List.iter f p - | Tobject (ty, _) -> f ty - | Tvariant row -> iter_row f row; f (row_more row) - | Tfield (_, _, ty1, ty2) -> f ty1; f ty2 - | Tnil -> () - | Tlink ty -> f ty - | Tsubst ty -> f ty - | Tunivar _ -> () - | Tpoly (ty, tyl) -> f ty; List.iter f tyl - | Tpackage (_, _, l) -> List.iter f l +(* + Substitutions are used to translate a type from one context to + another. This requires substituting paths for identifiers, and + possibly also lowering the level of non-generic variables so that + they are inferior to the maximum level of the new context. -let rec iter_abbrev f = function - Mnil -> () - | Mcons(_, _, ty, ty', rem) -> f ty; f ty'; iter_abbrev f rem - | Mlink rem -> iter_abbrev f !rem + Substitutions can also be used to create a "clean" copy of a type. + Indeed, non-variable node of a type are duplicated, with their + levels set to generic level. That way, the resulting type is + well-formed (decreasing levels), even if the original one was not. +*) -type type_iterators = - { it_signature: type_iterators -> signature -> unit; - it_signature_item: type_iterators -> signature_item -> unit; - it_value_description: type_iterators -> value_description -> unit; - it_type_declaration: type_iterators -> type_declaration -> unit; - it_extension_constructor: type_iterators -> extension_constructor -> unit; - it_module_declaration: type_iterators -> module_declaration -> unit; - it_modtype_declaration: type_iterators -> modtype_declaration -> unit; - it_class_declaration: type_iterators -> class_declaration -> unit; - it_class_type_declaration: type_iterators -> class_type_declaration -> unit; - it_module_type: type_iterators -> module_type -> unit; - it_class_type: type_iterators -> class_type -> unit; - it_type_kind: type_iterators -> type_kind -> unit; - it_do_type_expr: type_iterators -> type_expr -> unit; - it_type_expr: type_iterators -> type_expr -> unit; - it_path: Path.t -> unit; } +val identity: t -let iter_type_expr_cstr_args f = function - | Cstr_tuple tl -> List.iter f tl - | Cstr_record lbls -> List.iter (fun d -> f d.ld_type) lbls +val add_type: Ident.t -> Path.t -> t -> t +val add_type_path: Path.t -> Path.t -> t -> t +val add_type_function: + Path.t -> params:type_expr list -> body:type_expr -> t -> t +val add_module: Ident.t -> Path.t -> t -> t +val add_module_path: Path.t -> Path.t -> t -> t +val add_modtype: Ident.t -> module_type -> t -> t +val for_saving: t -> t +val reset_for_saving: unit -> unit -let map_type_expr_cstr_args f = function - | Cstr_tuple tl -> Cstr_tuple (List.map f tl) - | Cstr_record lbls -> - Cstr_record (List.map (fun d -> {d with ld_type=f d.ld_type}) lbls) +val module_path: t -> Path.t -> Path.t +val type_path: t -> Path.t -> Path.t -let iter_type_expr_kind f = function - | Type_abstract -> () - | Type_variant cstrs -> - List.iter - (fun cd -> - iter_type_expr_cstr_args f cd.cd_args; - Misc.may f cd.cd_res - ) - cstrs - | Type_record(lbls, _) -> - List.iter (fun d -> f d.ld_type) lbls - | Type_open -> - () +val type_expr: t -> type_expr -> type_expr +val class_type: t -> class_type -> class_type +val value_description: t -> value_description -> value_description +val type_declaration: t -> type_declaration -> type_declaration +val extension_constructor: + t -> extension_constructor -> extension_constructor +val class_declaration: t -> class_declaration -> class_declaration +val cltype_declaration: t -> class_type_declaration -> class_type_declaration +val modtype: t -> module_type -> module_type +val signature: t -> signature -> signature +val modtype_declaration: t -> modtype_declaration -> modtype_declaration +val module_declaration: t -> module_declaration -> module_declaration +val typexp : t -> Types.type_expr -> Types.type_expr +val class_signature: t -> class_signature -> class_signature +(* Composition of substitutions: + apply (compose s1 s2) x = apply s2 (apply s1 x) *) +val compose: t -> t -> t -let type_iterators = - let it_signature it = - List.iter (it.it_signature_item it) - and it_signature_item it = function - Sig_value (_, vd) -> it.it_value_description it vd - | Sig_type (_, td, _) -> it.it_type_declaration it td - | Sig_typext (_, td, _) -> it.it_extension_constructor it td - | Sig_module (_, md, _) -> it.it_module_declaration it md - | Sig_modtype (_, mtd) -> it.it_modtype_declaration it mtd - | Sig_class (_, cd, _) -> it.it_class_declaration it cd - | Sig_class_type (_, ctd, _) -> it.it_class_type_declaration it ctd - and it_value_description it vd = - it.it_type_expr it vd.val_type - and it_type_declaration it td = - List.iter (it.it_type_expr it) td.type_params; - may (it.it_type_expr it) td.type_manifest; - it.it_type_kind it td.type_kind - and it_extension_constructor it td = - it.it_path td.ext_type_path; - List.iter (it.it_type_expr it) td.ext_type_params; - iter_type_expr_cstr_args (it.it_type_expr it) td.ext_args; - may (it.it_type_expr it) td.ext_ret_type - and it_module_declaration it md = - it.it_module_type it md.md_type - and it_modtype_declaration it mtd = - may (it.it_module_type it) mtd.mtd_type - and it_class_declaration it cd = - List.iter (it.it_type_expr it) cd.cty_params; - it.it_class_type it cd.cty_type; - may (it.it_type_expr it) cd.cty_new; - it.it_path cd.cty_path - and it_class_type_declaration it ctd = - List.iter (it.it_type_expr it) ctd.clty_params; - it.it_class_type it ctd.clty_type; - it.it_path ctd.clty_path - and it_module_type it = function - Mty_ident p - | Mty_alias(_, p) -> it.it_path p - | Mty_signature sg -> it.it_signature it sg - | Mty_functor (_, mto, mt) -> - may (it.it_module_type it) mto; - it.it_module_type it mt - and it_class_type it = function - Cty_constr (p, tyl, cty) -> - it.it_path p; - List.iter (it.it_type_expr it) tyl; - it.it_class_type it cty - | Cty_signature cs -> - it.it_type_expr it cs.csig_self; - Vars.iter (fun _ (_,_,ty) -> it.it_type_expr it ty) cs.csig_vars; - List.iter - (fun (p, tl) -> it.it_path p; List.iter (it.it_type_expr it) tl) - cs.csig_inher - | Cty_arrow (_, ty, cty) -> - it.it_type_expr it ty; - it.it_class_type it cty - and it_type_kind it kind = - iter_type_expr_kind (it.it_type_expr it) kind - and it_do_type_expr it ty = - iter_type_expr (it.it_type_expr it) ty; - match ty.desc with - Tconstr (p, _, _) - | Tobject (_, {contents=Some (p, _)}) - | Tpackage (p, _, _) -> - it.it_path p - | Tvariant row -> - may (fun (p,_) -> it.it_path p) (row_repr row).row_name - | _ -> () - and it_path _p = () - in - { it_path; it_type_expr = it_do_type_expr; it_do_type_expr; - it_type_kind; it_class_type; it_module_type; - it_signature; it_class_type_declaration; it_class_declaration; - it_modtype_declaration; it_module_declaration; it_extension_constructor; - it_type_declaration; it_value_description; it_signature_item; } +(* A forward reference to be filled in ctype.ml. *) +val ctype_apply_env_empty: + (type_expr list -> type_expr -> type_expr list -> type_expr) ref -let copy_row f fixed row keep more = - let fields = List.map - (fun (l, fi) -> l, - match row_field_repr fi with - | Rpresent(Some ty) -> Rpresent(Some(f ty)) - | Reither(c, tl, m, e) -> - let e = if keep then e else ref None in - let m = if row.row_fixed then fixed else m in - let tl = List.map f tl in - Reither(c, tl, m, e) - | _ -> fi) - row.row_fields in - let name = - match row.row_name with None -> None - | Some (path, tl) -> Some (path, List.map f tl) in - { row_fields = fields; row_more = more; - row_bound = (); row_fixed = row.row_fixed && fixed; - row_closed = row.row_closed; row_name = name; } +end = struct +#1 "subst.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -let rec copy_kind = function - Fvar{contents = Some k} -> copy_kind k - | Fvar _ -> Fvar (ref None) - | Fpresent -> Fpresent - | Fabsent -> assert false +(* Substitutions *) -let copy_commu c = - if commu_repr c = Cok then Cok else Clink (ref Cunknown) +open Misc +open Path +open Types +open Btype -(* Since univars may be used as row variables, we need to do some - encoding during substitution *) -let rec norm_univar ty = - match ty.desc with - Tunivar _ | Tsubst _ -> ty - | Tlink ty -> norm_univar ty - | Ttuple (ty :: _) -> norm_univar ty - | _ -> assert false +type type_replacement = + | Path of Path.t + | Type_function of { params : type_expr list; body : type_expr } -let rec copy_type_desc ?(keep_names=false) f = function - Tvar _ as ty -> if keep_names then ty else Tvar None - | Tarrow (p, ty1, ty2, c)-> Tarrow (p, f ty1, f ty2, copy_commu c) - | Ttuple l -> Ttuple (List.map f l) - | Tconstr (p, l, _) -> Tconstr (p, List.map f l, ref Mnil) - | Tobject(ty, {contents = Some (p, tl)}) - -> Tobject (f ty, ref (Some(p, List.map f tl))) - | Tobject (ty, _) -> Tobject (f ty, ref None) - | Tvariant _ -> assert false (* too ambiguous *) - | Tfield (p, k, ty1, ty2) -> (* the kind is kept shared *) - Tfield (p, field_kind_repr k, f ty1, f ty2) - | Tnil -> Tnil - | Tlink ty -> copy_type_desc f ty.desc - | Tsubst _ -> assert false - | Tunivar _ as ty -> ty (* always keep the name *) - | Tpoly (ty, tyl) -> - let tyl = List.map (fun x -> norm_univar (f x)) tyl in - Tpoly (f ty, tyl) - | Tpackage (p, n, l) -> Tpackage (p, n, List.map f l) +module PathMap = Map.Make(Path) -(* Utilities for copying *) +type t = + { types: type_replacement PathMap.t; + modules: Path.t PathMap.t; + modtypes: (Ident.t, module_type) Tbl.t; + for_saving: bool; + } -let saved_desc = ref [] - (* Saved association of generic nodes with their description. *) +let identity = + { types = PathMap.empty; + modules = PathMap.empty; + modtypes = Tbl.empty; + for_saving = false; + } -let save_desc ty desc = - saved_desc := (ty, desc)::!saved_desc +let add_type_path id p s = { s with types = PathMap.add id (Path p) s.types } +let add_type id p s = add_type_path (Pident id) p s -let saved_kinds = ref [] (* duplicated kind variables *) -let new_kinds = ref [] (* new kind variables *) -let dup_kind r = - (match !r with None -> () | Some _ -> assert false); - if not (List.memq r !new_kinds) then begin - saved_kinds := r :: !saved_kinds; - let r' = ref None in - new_kinds := r' :: !new_kinds; - r := Some (Fvar r') - end +let add_type_function id ~params ~body s = + { s with types = PathMap.add id (Type_function { params; body }) s.types } -(* Restored type descriptions. *) -let cleanup_types () = - List.iter (fun (ty, desc) -> ty.desc <- desc) !saved_desc; - List.iter (fun r -> r := None) !saved_kinds; - saved_desc := []; saved_kinds := []; new_kinds := [] +let add_module_path id p s = { s with modules = PathMap.add id p s.modules } +let add_module id p s = add_module_path (Pident id) p s -(* Mark a type. *) -let rec mark_type ty = - let ty = repr ty in - if ty.level >= lowest_level then begin - ty.level <- pivot_level - ty.level; - iter_type_expr mark_type ty - end +let add_modtype id ty s = { s with modtypes = Tbl.add id ty s.modtypes } -let mark_type_node ty = - let ty = repr ty in - if ty.level >= lowest_level then begin - ty.level <- pivot_level - ty.level; - end +let for_saving s = { s with for_saving = true } -let mark_type_params ty = - iter_type_expr mark_type ty +let loc s x = + if s.for_saving && not !Clflags.keep_locs then Location.none else x -let type_iterators = - let it_type_expr it ty = - let ty = repr ty in - if ty.level >= lowest_level then begin - mark_type_node ty; - it.it_do_type_expr it ty; - end - in - {type_iterators with it_type_expr} +let remove_loc = + let open Ast_mapper in + {default_mapper with location = (fun _this _loc -> Location.none)} +let is_not_doc = function + | ({Location.txt = "ocaml.doc"}, _) -> false + | ({Location.txt = "ocaml.text"}, _) -> false + | ({Location.txt = "doc"}, _) -> false + | ({Location.txt = "text"}, _) -> false + | _ -> true -(* Remove marks from a type. *) -let rec unmark_type ty = - let ty = repr ty in - if ty.level < lowest_level then begin - ty.level <- pivot_level - ty.level; - iter_type_expr unmark_type ty - end +let attrs s x = + let x = + if s.for_saving && not !Clflags.keep_docs then + List.filter is_not_doc x + else x + in + if s.for_saving && not !Clflags.keep_locs + then remove_loc.Ast_mapper.attributes remove_loc x + else x -let unmark_iterators = - let it_type_expr _it ty = unmark_type ty in - {type_iterators with it_type_expr} +let rec module_path s path = + try PathMap.find path s.modules + with Not_found -> + match path with + | Pident _ -> path + | Pdot(p, n, pos) -> + Pdot(module_path s p, n, pos) + | Papply(p1, p2) -> + Papply(module_path s p1, module_path s p2) -let unmark_type_decl decl = - unmark_iterators.it_type_declaration unmark_iterators decl +let modtype_path s = function + Pident id as p -> + begin try + match Tbl.find id s.modtypes with + | Mty_ident p -> p + | _ -> fatal_error "Subst.modtype_path" + with Not_found -> p end + | Pdot(p, n, pos) -> + Pdot(module_path s p, n, pos) + | Papply _ -> + fatal_error "Subst.modtype_path" -let unmark_extension_constructor ext = - List.iter unmark_type ext.ext_type_params; - iter_type_expr_cstr_args unmark_type ext.ext_args; - Misc.may unmark_type ext.ext_ret_type +let type_path s path = + match PathMap.find path s.types with + | Path p -> p + | Type_function _ -> assert false + | exception Not_found -> + match path with + | Pident _ -> path + | Pdot(p, n, pos) -> + Pdot(module_path s p, n, pos) + | Papply _ -> + fatal_error "Subst.type_path" -let unmark_class_signature sign = - unmark_type sign.csig_self; - Vars.iter (fun _l (_m, _v, t) -> unmark_type t) sign.csig_vars +let type_path s p = + match Path.constructor_typath p with + | Regular p -> type_path s p + | Cstr (ty_path, cstr) -> Pdot(type_path s ty_path, cstr, nopos) + | LocalExt _ -> type_path s p + | Ext (p, cstr) -> Pdot(module_path s p, cstr, nopos) -let unmark_class_type cty = - unmark_iterators.it_class_type unmark_iterators cty +let to_subst_by_type_function s p = + match PathMap.find p s.types with + | Path _ -> false + | Type_function _ -> true + | exception Not_found -> false +(* Special type ids for saved signatures *) - (*******************************************) - (* Memorization of abbreviation expansion *) - (*******************************************) +let new_id = ref (-1) +let reset_for_saving () = new_id := -1 -(* Search whether the expansion has been memorized. *) +let newpersty desc = + decr new_id; + { desc = desc; level = generic_level; id = !new_id } -let lte_public p1 p2 = (* Private <= Public *) - match p1, p2 with - | Private, _ | _, Public -> true - | Public, Private -> false +(* ensure that all occurrences of 'Tvar None' are physically shared *) +let tvar_none = Tvar None +let tunivar_none = Tunivar None +let norm = function + | Tvar None -> tvar_none + | Tunivar None -> tunivar_none + | d -> d -let rec find_expans priv p1 = function - Mnil -> None - | Mcons (priv', p2, _ty0, ty, _) - when lte_public priv priv' && Path.same p1 p2 -> Some ty - | Mcons (_, _, _, _, rem) -> find_expans priv p1 rem - | Mlink {contents = rem} -> find_expans priv p1 rem +let ctype_apply_env_empty = ref (fun _ -> assert false) -(* debug: check for cycles in abbreviation. only works with -principal -let rec check_expans visited ty = +(* Similar to [Ctype.nondep_type_rec]. *) +let rec typexp s ty = let ty = repr ty in - assert (not (List.memq ty visited)); match ty.desc with - Tconstr (path, args, abbrev) -> - begin match find_expans path !abbrev with - Some ty' -> check_expans (ty :: visited) ty' - | None -> () - end - | _ -> () + Tvar _ | Tunivar _ as desc -> + if s.for_saving || ty.id < 0 then + let ty' = + if s.for_saving then newpersty (norm desc) + else newty2 ty.level desc + in + save_desc ty desc; ty.desc <- Tsubst ty'; ty' + else ty + | Tsubst ty -> + ty + | Tfield (m, k, _t1, _t2) when not s.for_saving && m = dummy_method + && field_kind_repr k <> Fabsent && (repr ty).level < generic_level -> + (* do not copy the type of self when it is not generalized *) + ty +(* cannot do it, since it would omit substitution + | Tvariant row when not (static_row row) -> + ty *) + | _ -> + let desc = ty.desc in + save_desc ty desc; + let tm = row_of_type ty in + let has_fixed_row = + not (is_Tconstr ty) && is_constr_row ~allow_ident:false tm in + (* Make a stub *) + let ty' = if s.for_saving then newpersty (Tvar None) else newgenvar () in + ty.desc <- Tsubst ty'; + ty'.desc <- + begin if has_fixed_row then + match tm.desc with (* PR#7348 *) + Tconstr (Pdot(m,i,pos), tl, _abbrev) -> + let i' = String.sub i 0 (String.length i - 4) in + Tconstr(type_path s (Pdot(m,i',pos)), tl, ref Mnil) + | _ -> assert false + else match desc with + | Tconstr (p, args, _abbrev) -> + let args = List.map (typexp s) args in + begin match PathMap.find p s.types with + | exception Not_found -> Tconstr(type_path s p, args, ref Mnil) + | Path _ -> Tconstr(type_path s p, args, ref Mnil) + | Type_function { params; body } -> + (!ctype_apply_env_empty params body args).desc + end + | Tpackage(p, n, tl) -> + Tpackage(modtype_path s p, n, List.map (typexp s) tl) + | Tobject (t1, name) -> + Tobject (typexp s t1, + ref (match !name with + None -> None + | Some (p, tl) -> + if to_subst_by_type_function s p + then None + else Some (type_path s p, List.map (typexp s) tl))) + | Tvariant row -> + let row = row_repr row in + let more = repr row.row_more in + (* We must substitute in a subtle way *) + (* Tsubst takes a tuple containing the row var and the variant *) + begin match more.desc with + Tsubst {desc = Ttuple [_;ty2]} -> + (* This variant type has been already copied *) + ty.desc <- Tsubst ty2; (* avoid Tlink in the new type *) + Tlink ty2 + | _ -> + let dup = + s.for_saving || more.level = generic_level || static_row row || + match more.desc with Tconstr _ -> true | _ -> false in + (* Various cases for the row variable *) + let more' = + match more.desc with + Tsubst ty -> ty + | Tconstr _ | Tnil -> typexp s more + | Tunivar _ | Tvar _ -> + save_desc more more.desc; + if s.for_saving then newpersty (norm more.desc) else + if dup && is_Tvar more then newgenty more.desc else more + | _ -> assert false + in + (* Register new type first for recursion *) + more.desc <- Tsubst(newgenty(Ttuple[more';ty'])); + (* Return a new copy *) + let row = + copy_row (typexp s) true row (not dup) more' in + match row.row_name with + | Some (p, tl) -> + Tvariant {row with row_name = + if to_subst_by_type_function s p + then None + else Some (type_path s p, tl)} + | None -> + Tvariant row + end + | Tfield(_label, kind, _t1, t2) when field_kind_repr kind = Fabsent -> + Tlink (typexp s t2) + | _ -> copy_type_desc (typexp s) desc + end; + ty' -let memo = ref [] - (* Contains the list of saved abbreviation expansions. *) +(* + Always make a copy of the type. If this is not done, type levels + might not be correct. +*) +let type_expr s ty = + let ty' = typexp s ty in + cleanup_types (); + ty' -let cleanup_abbrev () = - (* Remove all memorized abbreviation expansions. *) - List.iter (fun abbr -> abbr := Mnil) !memo; - memo := [] +let label_declaration s l = + { + ld_id = l.ld_id; + ld_mutable = l.ld_mutable; + ld_type = typexp s l.ld_type; + ld_loc = loc s l.ld_loc; + ld_attributes = attrs s l.ld_attributes; + } -let memorize_abbrev mem priv path v v' = - (* Memorize the expansion of an abbreviation. *) - mem := Mcons (priv, path, v, v', !mem); - (* check_expans [] v; *) - memo := mem :: !memo +let constructor_arguments s = function + | Cstr_tuple l -> + Cstr_tuple (List.map (typexp s) l) + | Cstr_record l -> + Cstr_record (List.map (label_declaration s) l) -let rec forget_abbrev_rec mem path = - match mem with - Mnil -> - assert false - | Mcons (_, path', _, _, rem) when Path.same path path' -> - rem - | Mcons (priv, path', v, v', rem) -> - Mcons (priv, path', v, v', forget_abbrev_rec rem path) - | Mlink mem' -> - mem' := forget_abbrev_rec !mem' path; - raise Exit +let constructor_declaration s c = + { + cd_id = c.cd_id; + cd_args = constructor_arguments s c.cd_args; + cd_res = may_map (typexp s) c.cd_res; + cd_loc = loc s c.cd_loc; + cd_attributes = attrs s c.cd_attributes; + } -let forget_abbrev mem path = - try mem := forget_abbrev_rec !mem path with Exit -> () +let type_declaration s decl = + let decl = + { type_params = List.map (typexp s) decl.type_params; + type_arity = decl.type_arity; + type_kind = + begin match decl.type_kind with + Type_abstract -> Type_abstract + | Type_variant cstrs -> + Type_variant (List.map (constructor_declaration s) cstrs) + | Type_record(lbls, rep) -> + Type_record (List.map (label_declaration s) lbls, rep) + | Type_open -> Type_open + end; + type_manifest = + begin + match decl.type_manifest with + None -> None + | Some ty -> Some(typexp s ty) + end; + type_private = decl.type_private; + type_variance = decl.type_variance; + type_newtype_level = None; + type_loc = loc s decl.type_loc; + type_attributes = attrs s decl.type_attributes; + type_immediate = decl.type_immediate; + type_unboxed = decl.type_unboxed; + } + in + cleanup_types (); + decl -(* debug: check for invalid abbreviations -let rec check_abbrev_rec = function - Mnil -> true - | Mcons (_, ty1, ty2, rem) -> - repr ty1 != repr ty2 - | Mlink mem' -> - check_abbrev_rec !mem' +let class_signature s sign = + { csig_self = typexp s sign.csig_self; + csig_vars = + Vars.map (function (m, v, t) -> (m, v, typexp s t)) sign.csig_vars; + csig_concr = sign.csig_concr; + csig_inher = + List.map (fun (p, tl) -> (type_path s p, List.map (typexp s) tl)) + sign.csig_inher; + } -let check_memorized_abbrevs () = - List.for_all (fun mem -> check_abbrev_rec !mem) !memo -*) +let rec class_type s = + function + Cty_constr (p, tyl, cty) -> + Cty_constr (type_path s p, List.map (typexp s) tyl, class_type s cty) + | Cty_signature sign -> + Cty_signature (class_signature s sign) + | Cty_arrow (l, ty, cty) -> + Cty_arrow (l, typexp s ty, class_type s cty) - (**********************************) - (* Utilities for labels *) - (**********************************) +let class_declaration s decl = + let decl = + { cty_params = List.map (typexp s) decl.cty_params; + cty_variance = decl.cty_variance; + cty_type = class_type s decl.cty_type; + cty_path = type_path s decl.cty_path; + cty_new = + begin match decl.cty_new with + None -> None + | Some ty -> Some (typexp s ty) + end; + cty_loc = loc s decl.cty_loc; + cty_attributes = attrs s decl.cty_attributes; + } + in + (* Do not clean up if saving: next is cltype_declaration *) + if not s.for_saving then cleanup_types (); + decl -let is_optional = function Optional _ -> true | _ -> false +let cltype_declaration s decl = + let decl = + { clty_params = List.map (typexp s) decl.clty_params; + clty_variance = decl.clty_variance; + clty_type = class_type s decl.clty_type; + clty_path = type_path s decl.clty_path; + clty_loc = loc s decl.clty_loc; + clty_attributes = attrs s decl.clty_attributes; + } + in + (* Do clean up even if saving: type_declaration may be recursive *) + cleanup_types (); + decl -let label_name = function - Nolabel -> "" - | Labelled s - | Optional s -> s +let class_type s cty = + let cty = class_type s cty in + cleanup_types (); + cty -let prefixed_label_name = function - Nolabel -> "" - | Labelled s -> "~" ^ s - | Optional s -> "?" ^ s +let value_description s descr = + { val_type = type_expr s descr.val_type; + val_kind = descr.val_kind; + val_loc = loc s descr.val_loc; + val_attributes = attrs s descr.val_attributes; + } -let rec extract_label_aux hd l = function - [] -> raise Not_found - | (l',t as p) :: ls -> - if label_name l' = l then (l', t, List.rev hd, ls) - else extract_label_aux (p::hd) l ls +let extension_constructor s ext = + let ext = + { ext_type_path = type_path s ext.ext_type_path; + ext_type_params = List.map (typexp s) ext.ext_type_params; + ext_args = constructor_arguments s ext.ext_args; + ext_ret_type = may_map (typexp s) ext.ext_ret_type; + ext_private = ext.ext_private; + ext_attributes = attrs s ext.ext_attributes; + ext_loc = if s.for_saving then Location.none else ext.ext_loc; } + in + cleanup_types (); + ext -let extract_label l ls = extract_label_aux [] l ls +let rec rename_bound_idents s idents = function + [] -> (List.rev idents, s) + | Sig_type(id, _, _) :: sg -> + let id' = Ident.rename id in + rename_bound_idents (add_type id (Pident id') s) (id' :: idents) sg + | Sig_module(id, _, _) :: sg -> + let id' = Ident.rename id in + rename_bound_idents (add_module id (Pident id') s) (id' :: idents) sg + | Sig_modtype(id, _) :: sg -> + let id' = Ident.rename id in + rename_bound_idents (add_modtype id (Mty_ident(Pident id')) s) + (id' :: idents) sg + | (Sig_class(id, _, _) | Sig_class_type(id, _, _)) :: sg -> + (* cheat and pretend they are types cf. PR#6650 *) + let id' = Ident.rename id in + rename_bound_idents (add_type id (Pident id') s) (id' :: idents) sg + | (Sig_value(id, _) | Sig_typext(id, _, _)) :: sg -> + let id' = Ident.rename id in + rename_bound_idents s (id' :: idents) sg +let rec modtype s = function + Mty_ident p as mty -> + begin match p with + Pident id -> + begin try Tbl.find id s.modtypes with Not_found -> mty end + | Pdot(p, n, pos) -> + Mty_ident(Pdot(module_path s p, n, pos)) + | Papply _ -> + fatal_error "Subst.modtype" + end + | Mty_signature sg -> + Mty_signature(signature s sg) + | Mty_functor(id, arg, res) -> + let id' = Ident.rename id in + Mty_functor(id', may_map (modtype s) arg, + modtype (add_module id (Pident id') s) res) + | Mty_alias(pres, p) -> + Mty_alias(pres, module_path s p) - (**********************************) - (* Utilities for backtracking *) - (**********************************) +and signature s sg = + (* Components of signature may be mutually recursive (e.g. type declarations + or class and type declarations), so first build global renaming + substitution... *) + let (new_idents, s') = rename_bound_idents s [] sg in + (* ... then apply it to each signature component in turn *) + List.map2 (signature_component s') sg new_idents -let undo_change = function - Ctype (ty, desc) -> ty.desc <- desc - | Ccompress (ty, desc, _) -> ty.desc <- desc - | Clevel (ty, level) -> ty.level <- level - | Cname (r, v) -> r := v - | Crow (r, v) -> r := v - | Ckind (r, v) -> r := v - | Ccommu (r, v) -> r := v - | Cuniv (r, v) -> r := v - | Ctypeset (r, v) -> r := v +and signature_component s comp newid = + match comp with + Sig_value(_id, d) -> + Sig_value(newid, value_description s d) + | Sig_type(_id, d, rs) -> + Sig_type(newid, type_declaration s d, rs) + | Sig_typext(_id, ext, es) -> + Sig_typext(newid, extension_constructor s ext, es) + | Sig_module(_id, d, rs) -> + Sig_module(newid, module_declaration s d, rs) + | Sig_modtype(_id, d) -> + Sig_modtype(newid, modtype_declaration s d) + | Sig_class(_id, d, rs) -> + Sig_class(newid, class_declaration s d, rs) + | Sig_class_type(_id, d, rs) -> + Sig_class_type(newid, cltype_declaration s d, rs) -type snapshot = changes ref * int -let last_snapshot = ref 0 +and module_declaration s decl = + { + md_type = modtype s decl.md_type; + md_attributes = attrs s decl.md_attributes; + md_loc = loc s decl.md_loc; + } -let log_type ty = - if ty.id <= !last_snapshot then log_change (Ctype (ty, ty.desc)) -let link_type ty ty' = - log_type ty; - let desc = ty.desc in - ty.desc <- Tlink ty'; - (* Name is a user-supplied name for this unification variable (obtained - * through a type annotation for instance). *) - match desc, ty'.desc with - Tvar name, Tvar name' -> - begin match name, name' with - | Some _, None -> log_type ty'; ty'.desc <- Tvar name - | None, Some _ -> () - | Some _, Some _ -> - if ty.level < ty'.level then (log_type ty'; ty'.desc <- Tvar name) - | None, None -> () - end - | _ -> () - (* ; assert (check_memorized_abbrevs ()) *) - (* ; check_expans [] ty' *) -let set_level ty level = - if ty.id <= !last_snapshot then log_change (Clevel (ty, ty.level)); - ty.level <- level -let set_univar rty ty = - log_change (Cuniv (rty, !rty)); rty := Some ty -let set_name nm v = - log_change (Cname (nm, !nm)); nm := v -let set_row_field e v = - log_change (Crow (e, !e)); e := Some v -let set_kind rk k = - log_change (Ckind (rk, !rk)); rk := Some k -let set_commu rc c = - log_change (Ccommu (rc, !rc)); rc := c -let set_typeset rs s = - log_change (Ctypeset (rs, !rs)); rs := s +and modtype_declaration s decl = + { + mtd_type = may_map (modtype s) decl.mtd_type; + mtd_attributes = attrs s decl.mtd_attributes; + mtd_loc = loc s decl.mtd_loc; + } + +(* For every binding k |-> d of m1, add k |-> f d to m2 + and return resulting merged map. *) -let snapshot () = - let old = !last_snapshot in - last_snapshot := !new_id; - match Weak.get trail 0 with Some r -> (r, old) - | None -> - let r = ref Unchanged in - Weak.set trail 0 (Some r); - (r, old) +let merge_tbls f m1 m2 = + Tbl.fold (fun k d accu -> Tbl.add k (f d) accu) m1 m2 -let rec rev_log accu = function - Unchanged -> accu - | Invalid -> assert false - | Change (ch, next) -> - let d = !next in - next := Invalid; - rev_log (ch::accu) d +let merge_path_maps f m1 m2 = + PathMap.fold (fun k d accu -> PathMap.add k (f d) accu) m1 m2 -let backtrack (changes, old) = - match !changes with - Unchanged -> last_snapshot := old - | Invalid -> failwith "Btype.backtrack" - | Change _ as change -> - cleanup_abbrev (); - let backlog = rev_log [] change in - List.iter undo_change backlog; - changes := Unchanged; - last_snapshot := old; - Weak.set trail 0 (Some changes) +let type_replacement s = function + | Path p -> Path (type_path s p) + | Type_function { params; body } -> + let params = List.map (typexp s) params in + let body = typexp s body in + Type_function { params; body } -let rec rev_compress_log log r = - match !r with - Unchanged | Invalid -> - log - | Change (Ccompress _, next) -> - rev_compress_log (r::log) next - | Change (_, next) -> - rev_compress_log log next +(* Composition of substitutions: + apply (compose s1 s2) x = apply s2 (apply s1 x) *) -let undo_compress (changes, _old) = - match !changes with - Unchanged - | Invalid -> () - | Change _ -> - let log = rev_compress_log [] changes in - List.iter - (fun r -> match !r with - Change (Ccompress (ty, desc, d), next) when ty.desc == d -> - ty.desc <- desc; r := !next - | _ -> ()) - log +let compose s1 s2 = + { types = merge_path_maps (type_replacement s2) s1.types s2.types; + modules = merge_path_maps (module_path s2) s1.modules s2.modules; + modtypes = merge_tbls (modtype s2) s1.modtypes s2.modtypes; + for_saving = s1.for_saving || s2.for_saving; + } end -module Builtin_attributes : sig -#1 "builtin_attributes.mli" +module Env : sig +#1 "env.mli" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Alain Frisch, LexiFi *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) (* *) -(* Copyright 2012 Institut National de Recherche en Informatique et *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -48782,281 +31528,327 @@ module Builtin_attributes : sig (* *) (**************************************************************************) -(* Support for some of the builtin attributes: +(* Environment handling *) - ocaml.deprecated - ocaml.error - ocaml.ppwarning - ocaml.warning - ocaml.warnerror - ocaml.explicit_arity (for camlp4/camlp5) - ocaml.warn_on_literal_pattern - ocaml.deprecated_mutable - ocaml.immediate - ocaml.boxed / ocaml.unboxed -*) +open Types +module PathMap : Map.S with type key = Path.t + and type 'a t = 'a Map.Make(Path).t -val check_deprecated: Location.t -> Parsetree.attributes -> string -> unit -val check_deprecated_inclusion: - def:Location.t -> use:Location.t -> Location.t -> Parsetree.attributes -> - Parsetree.attributes -> string -> unit -val deprecated_of_attrs: Parsetree.attributes -> string option -val deprecated_of_sig: Parsetree.signature -> string option -val deprecated_of_str: Parsetree.structure -> string option +type summary = + Env_empty + | Env_value of summary * Ident.t * value_description + | Env_type of summary * Ident.t * type_declaration + | Env_extension of summary * Ident.t * extension_constructor + | Env_module of summary * Ident.t * module_declaration + | Env_modtype of summary * Ident.t * modtype_declaration + | Env_class of summary * Ident.t * class_declaration + | Env_cltype of summary * Ident.t * class_type_declaration + | Env_open of summary * Path.t + | Env_functor_arg of summary * Ident.t + | Env_constraints of summary * type_declaration PathMap.t + | Env_copy_types of summary * string list -val check_deprecated_mutable: - Location.t -> Parsetree.attributes -> string -> unit -val check_deprecated_mutable_inclusion: - def:Location.t -> use:Location.t -> Location.t -> Parsetree.attributes -> - Parsetree.attributes -> string -> unit +type t -val error_of_extension: Parsetree.extension -> Location.error +val empty: t +val initial_safe_string: t +val initial_unsafe_string: t +val diff: t -> t -> Ident.t list +val copy_local: from:t -> t -> t -val warning_attribute: ?ppwarning:bool -> Parsetree.attribute -> unit - (** Apply warning settings from the specified attribute. - "ocaml.warning"/"ocaml.warnerror" (and variants without the prefix) - are processed and other attributes are ignored. +type type_descriptions = + constructor_description list * label_description list - Also implement ocaml.ppwarning (unless ~ppwarning:false is - passed). - *) +(* For short-paths *) +type iter_cont +val iter_types: + (Path.t -> Path.t * (type_declaration * type_descriptions) -> unit) -> + t -> iter_cont +val run_iter_cont: iter_cont list -> (Path.t * iter_cont) list +val same_types: t -> t -> bool +val used_persistent: unit -> Concr.t +val find_shadowed_types: Path.t -> t -> Path.t list +val without_cmis: ('a -> 'b) -> 'a -> 'b + (* [without_cmis f arg] applies [f] to [arg], but does not + allow opening cmis during its execution *) -val warning_scope: - ?ppwarning:bool -> - Parsetree.attributes -> (unit -> 'a) -> 'a - (** Execute a function in a new scope for warning settings. This - means that the effect of any call to [warning_attribute] during - the execution of this function will be discarded after - execution. +(* Lookup by paths *) - The function also takes a list of attributes which are processed - with [warning_attribute] in the fresh scope before the function - is executed. - *) +val find_value: Path.t -> t -> value_description +val find_type: Path.t -> t -> type_declaration +val find_type_descrs: Path.t -> t -> type_descriptions +val find_module: Path.t -> t -> module_declaration +val find_modtype: Path.t -> t -> modtype_declaration +val find_class: Path.t -> t -> class_declaration +val find_cltype: Path.t -> t -> class_type_declaration -val warn_on_literal_pattern: Parsetree.attributes -> bool -val explicit_arity: Parsetree.attributes -> bool +val find_type_expansion: + Path.t -> t -> type_expr list * type_expr * int option +val find_type_expansion_opt: + Path.t -> t -> type_expr list * type_expr * int option +(* Find the manifest type information associated to a type for the sake + of the compiler's type-based optimisations. *) +val find_modtype_expansion: Path.t -> t -> module_type +val add_functor_arg: Ident.t -> t -> t +val is_functor_arg: Path.t -> t -> bool +val normalize_path: Location.t option -> t -> Path.t -> Path.t +(* Normalize the path to a concrete value or module. + If the option is None, allow returning dangling paths. + Otherwise raise a Missing_module error, and may add forgotten + head as required global. *) +val normalize_path_prefix: Location.t option -> t -> Path.t -> Path.t +(* Only normalize the prefix part of the path *) +val reset_required_globals: unit -> unit +val get_required_globals: unit -> Ident.t list +val add_required_global: Ident.t -> unit +val has_local_constraints: t -> bool +val add_gadt_instance_level: int -> t -> t +val gadt_instance_level: t -> type_expr -> int option +val add_gadt_instances: t -> int -> type_expr list -> unit +val add_gadt_instance_chain: t -> int -> type_expr -> unit -val immediate: Parsetree.attributes -> bool +(* Lookup by long identifiers *) -val has_unboxed: Parsetree.attributes -> bool -val has_boxed: Parsetree.attributes -> bool +(* ?loc is used to report 'deprecated module' warnings *) -end = struct -#1 "builtin_attributes.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Alain Frisch, LexiFi *) -(* *) -(* Copyright 2012 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +val lookup_value: + ?loc:Location.t -> Longident.t -> t -> Path.t * value_description +val lookup_constructor: + ?loc:Location.t -> Longident.t -> t -> constructor_description +val lookup_all_constructors: + ?loc:Location.t -> + Longident.t -> t -> (constructor_description * (unit -> unit)) list +val lookup_label: + ?loc:Location.t -> Longident.t -> t -> label_description +val lookup_all_labels: + ?loc:Location.t -> + Longident.t -> t -> (label_description * (unit -> unit)) list +val lookup_type: + ?loc:Location.t -> Longident.t -> t -> Path.t + (* Since 4.04, this function no longer returns [type_description]. + To obtain it, you should either call [Env.find_type], or replace + it by [Typetexp.find_type] *) +val lookup_module: + load:bool -> ?loc:Location.t -> Longident.t -> t -> Path.t +val lookup_modtype: + ?loc:Location.t -> Longident.t -> t -> Path.t * modtype_declaration +val lookup_class: + ?loc:Location.t -> Longident.t -> t -> Path.t * class_declaration +val lookup_cltype: + ?loc:Location.t -> Longident.t -> t -> Path.t * class_type_declaration -open Asttypes -open Parsetree +val copy_types: string list -> t -> t + (* Used only in Typecore.duplicate_ident_types. *) -let string_of_cst = function - | Pconst_string(s, _) -> Some s - | _ -> None +exception Recmodule + (* Raise by lookup_module when the identifier refers + to one of the modules of a recursive definition + during the computation of its approximation (see #5965). *) -let string_of_payload = function - | PStr[{pstr_desc=Pstr_eval({pexp_desc=Pexp_constant c},_)}] -> - string_of_cst c - | _ -> None +(* Insertion by identifier *) -let string_of_opt_payload p = - match string_of_payload p with - | Some s -> s - | None -> "" +val add_value: + ?check:(string -> Warnings.t) -> Ident.t -> value_description -> t -> t +val add_type: check:bool -> Ident.t -> type_declaration -> t -> t +val add_extension: check:bool -> Ident.t -> extension_constructor -> t -> t +val add_module: ?arg:bool -> Ident.t -> module_type -> t -> t +val add_module_declaration: ?arg:bool -> check:bool -> Ident.t -> + module_declaration -> t -> t +val add_modtype: Ident.t -> modtype_declaration -> t -> t +val add_class: Ident.t -> class_declaration -> t -> t +val add_cltype: Ident.t -> class_type_declaration -> t -> t +val add_local_constraint: Path.t -> type_declaration -> int -> t -> t +val add_local_type: Path.t -> type_declaration -> t -> t -let rec error_of_extension ext = - match ext with - | ({txt = ("ocaml.error"|"error") as txt; loc}, p) -> - let rec sub_from inner = - match inner with - | {pstr_desc=Pstr_extension (ext, _)} :: rest -> - error_of_extension ext :: sub_from rest - | _ :: rest -> - (Location.errorf ~loc - "Invalid syntax for sub-error of extension '%s'." txt) :: - sub_from rest - | [] -> [] - in - begin match p with - | PStr [] -> raise Location.Already_displayed_error - | PStr({pstr_desc=Pstr_eval - ({pexp_desc=Pexp_constant(Pconst_string(msg,_))}, _)}:: - {pstr_desc=Pstr_eval - ({pexp_desc=Pexp_constant(Pconst_string(if_highlight,_))}, _)}:: - inner) -> - Location.error ~loc ~if_highlight ~sub:(sub_from inner) msg - | PStr({pstr_desc=Pstr_eval - ({pexp_desc=Pexp_constant(Pconst_string(msg,_))}, _)}::inner) -> - Location.error ~loc ~sub:(sub_from inner) msg - | _ -> Location.errorf ~loc "Invalid syntax for extension '%s'." txt - end - | ({txt; loc}, _) -> - Location.errorf ~loc "Uninterpreted extension '%s'." txt +(* Insertion of all fields of a signature. *) -let cat s1 s2 = - if s2 = "" then s1 else - - if Clflags.bs_vscode then s1 ^ " " ^ s2 - else s1 ^ "\n" ^ s2 - +val add_item: signature_item -> t -> t +val add_signature: signature -> t -> t -let rec deprecated_of_attrs = function - | [] -> None - | ({txt = "ocaml.deprecated"|"deprecated"; _}, p) :: _ -> - Some (string_of_opt_payload p) - | _ :: tl -> deprecated_of_attrs tl +(* Insertion of all fields of a signature, relative to the given path. + Used to implement open. Returns None if the path refers to a functor, + not a structure. *) +val open_signature: + ?used_slot:bool ref -> + ?loc:Location.t -> ?toplevel:bool -> Asttypes.override_flag -> Path.t -> + t -> t option -let check_deprecated loc attrs s = - match deprecated_of_attrs attrs with - | None -> () - | Some txt -> Location.deprecated loc (cat s txt) +val open_pers_signature: string -> t -> t -let check_deprecated_inclusion ~def ~use loc attrs1 attrs2 s = - match deprecated_of_attrs attrs1, deprecated_of_attrs attrs2 with - | None, _ | Some _, Some _ -> () - | Some txt, None -> Location.deprecated ~def ~use loc (cat s txt) +(* Insertion by name *) -let rec deprecated_mutable_of_attrs = function - | [] -> None - | ({txt = "ocaml.deprecated_mutable"|"deprecated_mutable"; _}, p) :: _ -> - Some (string_of_opt_payload p) - | _ :: tl -> deprecated_mutable_of_attrs tl +val enter_value: + ?check:(string -> Warnings.t) -> + string -> value_description -> t -> Ident.t * t +val enter_type: string -> type_declaration -> t -> Ident.t * t +val enter_extension: string -> extension_constructor -> t -> Ident.t * t +val enter_module: ?arg:bool -> string -> module_type -> t -> Ident.t * t +val enter_module_declaration: + ?arg:bool -> Ident.t -> module_declaration -> t -> t +val enter_modtype: string -> modtype_declaration -> t -> Ident.t * t +val enter_class: string -> class_declaration -> t -> Ident.t * t +val enter_cltype: string -> class_type_declaration -> t -> Ident.t * t -let check_deprecated_mutable loc attrs s = - match deprecated_mutable_of_attrs attrs with - | None -> () - | Some txt -> - Location.deprecated loc (Printf.sprintf "mutating field %s" (cat s txt)) +(* Initialize the cache of in-core module interfaces. *) +val reset_cache: unit -> unit -let check_deprecated_mutable_inclusion ~def ~use loc attrs1 attrs2 s = - match deprecated_mutable_of_attrs attrs1, - deprecated_mutable_of_attrs attrs2 - with - | None, _ | Some _, Some _ -> () - | Some txt, None -> - Location.deprecated ~def ~use loc - (Printf.sprintf "mutating field %s" (cat s txt)) +(* To be called before each toplevel phrase. *) +val reset_cache_toplevel: unit -> unit -let rec deprecated_of_sig = function - | {psig_desc = Psig_attribute a} :: tl -> - begin match deprecated_of_attrs [a] with - | None -> deprecated_of_sig tl - | Some _ as r -> r - end - | _ -> None +(* Remember the name of the current compilation unit. *) +val set_unit_name: string -> unit +val get_unit_name: unit -> string +(* Read, save a signature to/from a file *) -let rec deprecated_of_str = function - | {pstr_desc = Pstr_attribute a} :: tl -> - begin match deprecated_of_attrs [a] with - | None -> deprecated_of_str tl - | Some _ as r -> r - end - | _ -> None +val read_signature: string -> string -> signature + (* Arguments: module name, file name. Results: signature. *) +val save_signature: + ?check_exists:unit -> + deprecated:string option -> signature -> string -> string -> Cmi_format.cmi_infos + (* Arguments: signature, module name, file name. *) +val save_signature_with_imports: + ?check_exists:unit -> + deprecated:string option -> + signature -> string -> string -> (string * Digest.t option) list + -> Cmi_format.cmi_infos + (* Arguments: signature, module name, file name, + imported units with their CRCs. *) +(* Return the CRC of the interface of the given compilation unit *) -let warning_attribute ?(ppwarning = true) = - let process loc txt errflag payload = - match string_of_payload payload with - | Some s -> - begin try Warnings.parse_options errflag s - with Arg.Bad _ -> - Location.prerr_warning loc - (Warnings.Attribute_payload - (txt, "Ill-formed list of warnings")) - end - | None -> - Location.prerr_warning loc - (Warnings.Attribute_payload - (txt, "A single string literal is expected")) - in - function - | ({txt = ("ocaml.warning"|"warning") as txt; loc}, payload) -> - process loc txt false payload - | ({txt = ("ocaml.warnerror"|"warnerror") as txt; loc}, payload) -> - process loc txt true payload - | {txt="ocaml.ppwarning"|"ppwarning"}, - PStr[{pstr_desc=Pstr_eval({pexp_desc=Pexp_constant - (Pconst_string (s, _))},_); - pstr_loc}] when ppwarning -> - Location.prerr_warning pstr_loc (Warnings.Preprocessor s) - | _ -> - () +val crc_of_unit: string -> Digest.t -let warning_scope ?ppwarning attrs f = - let prev = Warnings.backup () in - try - List.iter (warning_attribute ?ppwarning) (List.rev attrs); - let ret = f () in - Warnings.restore prev; - ret - with exn -> - Warnings.restore prev; - raise exn +(* Return the set of compilation units imported, with their CRC *) +val imports: unit -> (string * Digest.t option) list -let warn_on_literal_pattern = - List.exists - (function - | ({txt="ocaml.warn_on_literal_pattern"|"warn_on_literal_pattern"; _}, _) - -> true - | _ -> false - ) +(* [is_imported_opaque md] returns true if [md] is an opaque imported module *) +val is_imported_opaque: string -> bool -let explicit_arity = - List.exists - (function - | ({txt="ocaml.explicit_arity"|"explicit_arity"; _}, _) -> true - | _ -> false - ) +(* Direct access to the table of imported compilation units with their CRC *) + +val crc_units: Consistbl.t +val add_import: string -> unit + +(* Summaries -- compact representation of an environment, to be + exported in debugging information. *) + +val summary: t -> summary + +(* Return an equivalent environment where all fields have been reset, + except the summary. The initial environment can be rebuilt from the + summary, using Envaux.env_of_only_summary. *) + +val keep_only_summary : t -> t +val env_of_only_summary : (summary -> Subst.t -> t) -> t -> t + +(* Error report *) + +type error = + | Illegal_renaming of string * string * string + | Inconsistent_import of string * string * string + | Need_recursive_types of string * string + | Depend_on_unsafe_string_unit of string * string + | Missing_module of Location.t * Path.t * Path.t + | Illegal_value_name of Location.t * string + +exception Error of error + +open Format + +val report_error: formatter -> error -> unit + + +val mark_value_used: t -> string -> value_description -> unit +val mark_module_used: t -> string -> Location.t -> unit +val mark_type_used: t -> string -> type_declaration -> unit + +type constructor_usage = Positive | Pattern | Privatize +val mark_constructor_used: + constructor_usage -> t -> string -> type_declaration -> string -> unit +val mark_constructor: + constructor_usage -> t -> string -> constructor_description -> unit +val mark_extension_used: + constructor_usage -> t -> extension_constructor -> string -> unit + +val in_signature: bool -> t -> t +val implicit_coercion: t -> t + +val is_in_signature: t -> bool + +val set_value_used_callback: + string -> value_description -> (unit -> unit) -> unit +val set_type_used_callback: + string -> type_declaration -> ((unit -> unit) -> unit) -> unit + +(* Forward declaration to break mutual recursion with Includemod. *) +val check_modtype_inclusion: + (loc:Location.t -> t -> module_type -> Path.t -> module_type -> unit) ref +(* Forward declaration to break mutual recursion with Typecore. *) +val add_delayed_check_forward: ((unit -> unit) -> unit) ref +(* Forward declaration to break mutual recursion with Mtype. *) +val strengthen: + (aliasable:bool -> t -> module_type -> Path.t -> module_type) ref +(* Forward declaration to break mutual recursion with Ctype. *) +val same_constr: (t -> type_expr -> type_expr -> bool) ref + +(** Folding over all identifiers (for analysis purpose) *) -let immediate = - List.exists - (function - | ({txt="ocaml.immediate"|"immediate"; _}, _) -> true - | _ -> false - ) +val fold_values: + (string -> Path.t -> value_description -> 'a -> 'a) -> + Longident.t option -> t -> 'a -> 'a +val fold_types: + (string -> Path.t -> type_declaration * type_descriptions -> 'a -> 'a) -> + Longident.t option -> t -> 'a -> 'a +val fold_constructors: + (constructor_description -> 'a -> 'a) -> + Longident.t option -> t -> 'a -> 'a +val fold_labels: + (label_description -> 'a -> 'a) -> + Longident.t option -> t -> 'a -> 'a -(* The "ocaml.boxed (default)" and "ocaml.unboxed (default)" - attributes cannot be input by the user, they are added by the - compiler when applying the default setting. This is done to record - in the .cmi the default used by the compiler when compiling the - source file because the default can change between compiler - invocations. *) +(** Persistent structures are only traversed if they are already loaded. *) +val fold_modules: + (string -> Path.t -> module_declaration -> 'a -> 'a) -> + Longident.t option -> t -> 'a -> 'a -let check l (x, _) = List.mem x.txt l +val fold_modtypes: + (string -> Path.t -> modtype_declaration -> 'a -> 'a) -> + Longident.t option -> t -> 'a -> 'a +val fold_classs: + (string -> Path.t -> class_declaration -> 'a -> 'a) -> + Longident.t option -> t -> 'a -> 'a +val fold_cltypes: + (string -> Path.t -> class_type_declaration -> 'a -> 'a) -> + Longident.t option -> t -> 'a -> 'a -let has_unboxed attr = - List.exists (check ["ocaml.unboxed"; "unboxed"]) - attr +(** Utilities *) +val scrape_alias: t -> module_type -> module_type +val check_value_name: string -> Location.t -> unit -let has_boxed attr = - List.exists (check ["ocaml.boxed"; "boxed"]) attr +module Persistent_signature : sig + type t = + { filename : string; (** Name of the file containing the signature. *) + cmi : Cmi_format.cmi_infos } + (** Function used to load a persistent signature. The default is to look for + the .cmi file in the load path. This function can be overridden to load + it from memory, for instance to build a self-contained toplevel. *) + val load : (unit_name:string -> t option) ref end -module Cmi_format : sig -#1 "cmi_format.mli" + +end = struct +#1 "env.ml" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Fabrice Le Fessant, INRIA Saclay *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) (* *) -(* Copyright 2012 Institut National de Recherche en Informatique et *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -49065,2335 +31857,2381 @@ module Cmi_format : sig (* *) (**************************************************************************) -type pers_flags = - | Rectypes - | Deprecated of string - | Opaque - | Unsafe_string +(* Environment handling *) -type cmi_infos = { - cmi_name : string; - cmi_sign : Types.signature_item list; - cmi_crcs : (string * Digest.t option) list; - cmi_flags : pers_flags list; -} +open Cmi_format +open Config +open Misc +open Asttypes +open Longident +open Path +open Types +open Btype -(* write the magic + the cmi information *) -val output_cmi : string -> out_channel -> cmi_infos -> Digest.t +let add_delayed_check_forward = ref (fun _ -> assert false) -val create_cmi : ?check_exists:unit -> string -> cmi_infos -> Digest.t +let value_declarations : ((string * Location.t), (unit -> unit)) Hashtbl.t = + Hashtbl.create 16 + (* This table is used to usage of value declarations. A declaration is + identified with its name and location. The callback attached to a + declaration is called whenever the value is used explicitly + (lookup_value) or implicitly (inclusion test between signatures, + cf Includemod.value_descriptions). *) -(* read the cmi information (the magic is supposed to have already been read) *) -val input_cmi : in_channel -> cmi_infos +let type_declarations = Hashtbl.create 16 +let module_declarations = Hashtbl.create 16 -(* read a cmi from a filename, checking the magic *) -val read_cmi : string -> cmi_infos +type constructor_usage = Positive | Pattern | Privatize +type constructor_usages = + { + mutable cu_positive: bool; + mutable cu_pattern: bool; + mutable cu_privatize: bool; + } +let add_constructor_usage cu = function + | Positive -> cu.cu_positive <- true + | Pattern -> cu.cu_pattern <- true + | Privatize -> cu.cu_privatize <- true +let constructor_usages () = + {cu_positive = false; cu_pattern = false; cu_privatize = false} -(* Error report *) +let used_constructors : + (string * Location.t * string, (constructor_usage -> unit)) Hashtbl.t + = Hashtbl.create 16 + +let prefixed_sg = Hashtbl.create 113 type error = - Not_an_interface of string - | Wrong_version_interface of string * string - | Corrupted_interface of string + | Illegal_renaming of string * string * string + | Inconsistent_import of string * string * string + | Need_recursive_types of string * string + | Depend_on_unsafe_string_unit of string * string + | Missing_module of Location.t * Path.t * Path.t + | Illegal_value_name of Location.t * string exception Error of error -open Format +let error err = raise (Error err) -val report_error: formatter -> error -> unit +module EnvLazy : sig + type ('a,'b) t -end = struct -#1 "cmi_format.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Fabrice Le Fessant, INRIA Saclay *) -(* *) -(* Copyright 2012 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) + type log -type pers_flags = - | Rectypes - | Deprecated of string - | Opaque - | Unsafe_string + val force : ('a -> 'b) -> ('a,'b) t -> 'b + val create : 'a -> ('a,'b) t + val get_arg : ('a,'b) t -> 'a option -type error = - Not_an_interface of string - | Wrong_version_interface of string * string - | Corrupted_interface of string + (* [force_logged log f t] is equivalent to [force f t] but if [f] returns [None] then + [t] is recorded in [log]. [backtrack log] will then reset all the recorded [t]s back + to their original state. *) + val log : unit -> log + val force_logged : log -> ('a -> 'b option) -> ('a,'b option) t -> 'b option + val backtrack : log -> unit -exception Error of error +end = struct -type cmi_infos = { - cmi_name : string; - cmi_sign : Types.signature_item list; - cmi_crcs : (string * Digest.t option) list; - cmi_flags : pers_flags list; -} + type ('a,'b) t = ('a,'b) eval ref -let input_cmi ic = - let (name, sign) = input_value ic in - let crcs = input_value ic in - let flags = input_value ic in - { - cmi_name = name; - cmi_sign = sign; - cmi_crcs = crcs; - cmi_flags = flags; - } + and ('a,'b) eval = + | Done of 'b + | Raise of exn + | Thunk of 'a -let read_cmi filename = - let ic = open_in_bin filename in - try - let buffer = - really_input_string ic (String.length Config.cmi_magic_number) - in - if buffer <> Config.cmi_magic_number then begin - close_in ic; - let pre_len = String.length Config.cmi_magic_number - 3 in - if String.sub buffer 0 pre_len - = String.sub Config.cmi_magic_number 0 pre_len then - begin - let msg = - if buffer < Config.cmi_magic_number then "an older" else "a newer" in - raise (Error (Wrong_version_interface (filename, msg))) - end else begin - raise(Error(Not_an_interface filename)) - end - end; - let cmi = input_cmi ic in - close_in ic; - cmi - with End_of_file | Failure _ -> - close_in ic; - raise(Error(Corrupted_interface(filename))) - | Error e -> - close_in ic; - raise (Error e) + type undo = + | Nil + | Cons : ('a, 'b) t * 'a * undo -> undo -let output_cmi filename oc cmi = -(* beware: the provided signature must have been substituted for saving *) - output_string oc Config.cmi_magic_number; - output_value oc (cmi.cmi_name, cmi.cmi_sign); - flush oc; - let crc = Digest.file filename in - let crcs = (cmi.cmi_name, Some crc) :: cmi.cmi_crcs in - output_value oc crcs; - output_value oc cmi.cmi_flags; - crc + type log = undo ref + let force f x = + match !x with + | Done x -> x + | Raise e -> raise e + | Thunk e -> + match f e with + | y -> + x := Done y; + y + | exception e -> + x := Raise e; + raise e -(* This function is also called by [save_cmt] as cmi_format is subset of - cmt_format, so dont close the channel yet -*) -let create_cmi ?check_exists filename (cmi : cmi_infos) = - (* beware: the provided signature must have been substituted for saving *) - let content = - Config.cmi_magic_number ^ Marshal.to_string (cmi.cmi_name, cmi.cmi_sign) [] - (* checkout [output_value] in {!Pervasives} module *) - in - let crc = Digest.string content in - let cmi_infos = - if check_exists <> None && Sys.file_exists filename then - Some (read_cmi filename) - else None in - match cmi_infos with - | Some {cmi_name = _; cmi_sign = _; cmi_crcs = (old_name, Some old_crc)::rest ; cmi_flags} - (* TODO: design the cmi format so that we don't need read the whole cmi *) - when - cmi.cmi_name = old_name && - crc = old_crc && - cmi.cmi_crcs = rest && - cmi_flags = cmi.cmi_flags -> - crc - | _ -> - let crcs = (cmi.cmi_name, Some crc) :: cmi.cmi_crcs in - let oc = open_out_bin filename in - output_string oc content; - output_value oc crcs; - output_value oc cmi.cmi_flags; - close_out oc; - crc + let get_arg x = + match !x with Thunk a -> Some a | _ -> None + let create x = + ref (Thunk x) + let log () = + ref Nil - -(* Error report *) + let force_logged log f x = + match !x with + | Done x -> x + | Raise e -> raise e + | Thunk e -> + match f e with + | None -> + x := Done None; + log := Cons(x, e, !log); + None + | Some _ as y -> + x := Done y; + y + | exception e -> + x := Raise e; + raise e -open Format + let backtrack log = + let rec loop = function + | Nil -> () + | Cons(x, e, rest) -> + x := Thunk e; + loop rest + in + loop !log -let report_error ppf = function - | Not_an_interface filename -> - fprintf ppf "%a@ is not a compiled interface" - Location.print_filename filename - | Wrong_version_interface (filename, older_newer) -> - fprintf ppf - "%a@ is not a compiled interface for this version of OCaml.@.\ - It seems to be for %s version of OCaml." - Location.print_filename filename older_newer - | Corrupted_interface filename -> - fprintf ppf "Corrupted compiled interface@ %a" - Location.print_filename filename +end -let () = - Location.register_error_of_exn - (function - | Error err -> Some (Location.error_of_printer_file report_error err) - | _ -> None - ) +module PathMap = Map.Make(Path) -end -module Consistbl : sig -#1 "consistbl.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 2002 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +type summary = + Env_empty + | Env_value of summary * Ident.t * value_description + | Env_type of summary * Ident.t * type_declaration + | Env_extension of summary * Ident.t * extension_constructor + | Env_module of summary * Ident.t * module_declaration + | Env_modtype of summary * Ident.t * modtype_declaration + | Env_class of summary * Ident.t * class_declaration + | Env_cltype of summary * Ident.t * class_type_declaration + | Env_open of summary * Path.t + | Env_functor_arg of summary * Ident.t + | Env_constraints of summary * type_declaration PathMap.t + | Env_copy_types of summary * string list -(* Consistency tables: for checking consistency of module CRCs *) +module TycompTbl = + struct + (** This module is used to store components of types (i.e. labels + and constructors). We keep a representation of each nested + "open" and the set of local bindings between each of them. *) -type t + type 'a t = { + current: 'a Ident.tbl; + (** Local bindings since the last open. *) -val create: unit -> t + opened: 'a opened option; + (** Symbolic representation of the last (innermost) open, if any. *) + } -val clear: t -> unit + and 'a opened = { + components: (string, 'a list) Tbl.t; + (** Components from the opened module. We keep a list of + bindings for each name, as in comp_labels and + comp_constrs. *) -val check: t -> string -> Digest.t -> string -> unit - (* [check tbl name crc source] - checks consistency of ([name], [crc]) with infos previously - stored in [tbl]. If no CRC was previously associated with - [name], record ([name], [crc]) in [tbl]. - [source] is the name of the file from which the information - comes from. This is used for error reporting. *) + using: (string -> ('a * 'a) option -> unit) option; + (** A callback to be applied when a component is used from this + "open". This is used to detect unused "opens". The + arguments are used to detect shadowing. *) -val check_noadd: t -> string -> Digest.t -> string -> unit - (* Same as [check], but raise [Not_available] if no CRC was previously - associated with [name]. *) + next: 'a t; + (** The table before opening the module. *) + } -val set: t -> string -> Digest.t -> string -> unit - (* [set tbl name crc source] forcefully associates [name] with - [crc] in [tbl], even if [name] already had a different CRC - associated with [name] in [tbl]. *) + let empty = { current = Ident.empty; opened = None } -val source: t -> string -> string - (* [source tbl name] returns the file name associated with [name] - if the latter has an associated CRC in [tbl]. - Raise [Not_found] otherwise. *) + let add id x tbl = + {tbl with current = Ident.add id x tbl.current} -val extract: string list -> t -> (string * Digest.t option) list - (* [extract tbl names] returns an associative list mapping each string - in [names] to the CRC associated with it in [tbl]. If no CRC is - associated with a name then it is mapped to [None]. *) + let add_open slot wrap components next = + let using = + match slot with + | None -> None + | Some f -> Some (fun s x -> f s (wrap x)) + in + { + current = Ident.empty; + opened = Some {using; components; next}; + } -val filter: (string -> bool) -> t -> unit - (* [filter pred tbl] removes from [tbl] table all (name, CRC) pairs - such that [pred name] is [false]. *) + let rec find_same id tbl = + try Ident.find_same id tbl.current + with Not_found as exn -> + begin match tbl.opened with + | Some {next; _} -> find_same id next + | None -> raise exn + end -exception Inconsistency of string * string * string - (* Raised by [check] when a CRC mismatch is detected. - First string is the name of the compilation unit. - Second string is the source that caused the inconsistency. - Third string is the source that set the CRC. *) + let nothing = fun () -> () -exception Not_available of string - (* Raised by [check_noadd] when a name doesn't have an associated CRC. *) + let mk_callback rest name desc = function + | None -> nothing + | Some f -> + (fun () -> + match rest with + | [] -> f name None + | (hidden, _) :: _ -> f name (Some (desc, hidden)) + ) -end = struct -#1 "consistbl.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 2002 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) + let rec find_all name tbl = + List.map (fun (_id, desc) -> desc, nothing) + (Ident.find_all name tbl.current) @ + match tbl.opened with + | None -> [] + | Some {using; next; components} -> + let rest = find_all name next in + match Tbl.find_str name components with + | exception Not_found -> rest + | opened -> + List.map + (fun desc -> desc, mk_callback rest name desc using) + opened + @ rest -(* Consistency tables: for checking consistency of module CRCs *) + let rec fold_name f tbl acc = + let acc = Ident.fold_name (fun _id d -> f d) tbl.current acc in + match tbl.opened with + | Some {using = _; next; components} -> + acc + |> Tbl.fold + (fun _name -> List.fold_right (fun desc -> f desc)) + components + |> fold_name f next + | None -> + acc + + let rec local_keys tbl acc = + let acc = Ident.fold_all (fun k _ accu -> k::accu) tbl.current acc in + match tbl.opened with + | Some o -> local_keys o.next acc + | None -> acc + + let diff_keys is_local tbl1 tbl2 = + let keys2 = local_keys tbl2 [] in + List.filter + (fun id -> + is_local (find_same id tbl2) && + try ignore (find_same id tbl1); false + with Not_found -> true) + keys2 + + end + + +module IdTbl = + struct + (** This module is used to store all kinds of components except + (labels and constructors) in environments. We keep a + representation of each nested "open" and the set of local + bindings between each of them. *) -type t = (string, Digest.t * string) Hashtbl.t -let create () = Hashtbl.create 13 + type 'a t = { + current: 'a Ident.tbl; + (** Local bindings since the last open *) -let clear = Hashtbl.clear + opened: 'a opened option; + (** Symbolic representation of the last (innermost) open, if any. *) + } -exception Inconsistency of string * string * string + and 'a opened = { + root: Path.t; + (** The path of the opened module, to be prefixed in front of + its local names to produce a valid path in the current + environment. *) -exception Not_available of string + components: (string, 'a * int) Tbl.t; + (** Components from the opened module. *) -let check tbl name crc source = - try - let (old_crc, old_source) = Hashtbl.find tbl name in - if crc <> old_crc then raise(Inconsistency(name, source, old_source)) - with Not_found -> - Hashtbl.add tbl name (crc, source) + using: (string -> ('a * 'a) option -> unit) option; + (** A callback to be applied when a component is used from this + "open". This is used to detect unused "opens". The + arguments are used to detect shadowing. *) -let check_noadd tbl name crc source = - try - let (old_crc, old_source) = Hashtbl.find tbl name in - if crc <> old_crc then raise(Inconsistency(name, source, old_source)) - with Not_found -> - raise (Not_available name) + next: 'a t; + (** The table before opening the module. *) + } -let set tbl name crc source = Hashtbl.add tbl name (crc, source) + let empty = { current = Ident.empty; opened = None } -let source tbl name = snd (Hashtbl.find tbl name) + let add id x tbl = + {tbl with current = Ident.add id x tbl.current} -let extract l tbl = - let l = List.sort_uniq String.compare l in - List.fold_left - (fun assc name -> - try - let (crc, _) = Hashtbl.find tbl name in - (name, Some crc) :: assc - with Not_found -> - (name, None) :: assc) - [] l + let add_open slot wrap root components next = + let using = + match slot with + | None -> None + | Some f -> Some (fun s x -> f s (wrap x)) + in + { + current = Ident.empty; + opened = Some {using; root; components; next}; + } -let filter p tbl = - let to_remove = ref [] in - Hashtbl.iter - (fun name _ -> - if not (p name) then to_remove := name :: !to_remove) - tbl; - List.iter - (fun name -> - while Hashtbl.mem tbl name do Hashtbl.remove tbl name done) - !to_remove + let rec find_same id tbl = + try Ident.find_same id tbl.current + with Not_found as exn -> + begin match tbl.opened with + | Some {next; _} -> find_same id next + | None -> raise exn + end -end -module Datarepr : sig -#1 "datarepr.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) + let rec find_name mark name tbl = + try + let (id, desc) = Ident.find_name name tbl.current in + Pident id, desc + with Not_found as exn -> + begin match tbl.opened with + | Some {using; root; next; components} -> + begin try + let (descr, pos) = Tbl.find_str name components in + let res = Pdot (root, name, pos), descr in + if mark then begin match using with + | None -> () + | Some f -> + begin try f name (Some (snd (find_name false name next), snd res)) + with Not_found -> f name None + end + end; + res + with Not_found -> + find_name mark name next + end + | None -> + raise exn + end -(* Compute constructor and label descriptions from type declarations, - determining their representation. *) + let find_name name tbl = find_name true name tbl -open Types + let rec update name f tbl = + try + let (id, desc) = Ident.find_name name tbl.current in + let new_desc = f desc in + {tbl with current = Ident.add id new_desc tbl.current} + with Not_found -> + begin match tbl.opened with + | Some {root; using; next; components} -> + begin try + let (desc, pos) = Tbl.find_str name components in + let new_desc = f desc in + let components = Tbl.add name (new_desc, pos) components in + {tbl with opened = Some {root; using; next; components}} + with Not_found -> + let next = update name f next in + {tbl with opened = Some {root; using; next; components}} + end + | None -> + tbl + end -val constructor_has_optional_shape: - Types.constructor_description -> bool -val extension_descr: - Path.t -> extension_constructor -> constructor_description -val labels_of_type: - Path.t -> type_declaration -> - (Ident.t * label_description) list -val constructors_of_type: - Path.t -> type_declaration -> - (Ident.t * constructor_description) list + let rec find_all name tbl = + List.map (fun (id, desc) -> Pident id, desc) (Ident.find_all name tbl.current) @ + match tbl.opened with + | None -> [] + | Some {root; using = _; next; components} -> + try + let (desc, pos) = Tbl.find_str name components in + (Pdot (root, name, pos), desc) :: find_all name next + with Not_found -> + find_all name next + let rec fold_name f tbl acc = + let acc = Ident.fold_name (fun id d -> f (Ident.name id) (Pident id, d)) tbl.current acc in + match tbl.opened with + | Some {root; using = _; next; components} -> + acc + |> Tbl.fold + (fun name (desc, pos) -> f name (Pdot (root, name, pos), desc)) + components + |> fold_name f next + | None -> + acc -exception Constr_not_found + let rec local_keys tbl acc = + let acc = Ident.fold_all (fun k _ accu -> k::accu) tbl.current acc in + match tbl.opened with + | Some o -> local_keys o.next acc + | None -> acc -val find_constr_by_tag: - constructor_tag -> constructor_declaration list -> - constructor_declaration -val constructor_existentials : - constructor_arguments -> type_expr option -> type_expr list * type_expr list -(** Takes [cd_args] and [cd_res] from a [constructor_declaration] and - returns: - - the types of the constructor's arguments - - the existential variables introduced by the constructor - *) + let rec iter f tbl = + Ident.iter (fun id desc -> f id (Pident id, desc)) tbl.current; + match tbl.opened with + | Some {root; using = _; next; components} -> + Tbl.iter + (fun s (x, pos) -> f (Ident.hide (Ident.create s) (* ??? *)) (Pdot (root, s, pos), x)) + components; + iter f next + | None -> () + let diff_keys tbl1 tbl2 = + let keys2 = local_keys tbl2 [] in + List.filter + (fun id -> + try ignore (find_same id tbl1); false + with Not_found -> true) + keys2 -(* Set the polymorphic variant row_name field *) -val set_row_name : type_declaration -> Path.t -> unit -end = struct -#1 "datarepr.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) + end -(* Compute constructor and label descriptions from type declarations, - determining their representation. *) +type type_descriptions = + constructor_description list * label_description list -open Asttypes -open Types -open Btype +let in_signature_flag = 0x01 +let implicit_coercion_flag = 0x02 -(* Simplified version of Ctype.free_vars *) -let free_vars ?(param=false) ty = - let ret = ref TypeSet.empty in - let rec loop ty = - let ty = repr ty in - if ty.level >= lowest_level then begin - ty.level <- pivot_level - ty.level; - match ty.desc with - | Tvar _ -> - ret := TypeSet.add ty !ret - | Tvariant row -> - let row = row_repr row in - iter_row loop row; - if not (static_row row) then begin - match row.row_more.desc with - | Tvar _ when param -> ret := TypeSet.add ty !ret - | _ -> loop row.row_more - end - (* XXX: What about Tobject ? *) - | _ -> - iter_type_expr loop ty - end - in - loop ty; - unmark_type ty; - !ret +type t = { + values: value_description IdTbl.t; + constrs: constructor_description TycompTbl.t; + labels: label_description TycompTbl.t; + types: (type_declaration * type_descriptions) IdTbl.t; + modules: (Subst.t * module_declaration, module_declaration) EnvLazy.t IdTbl.t; + modtypes: modtype_declaration IdTbl.t; + components: module_components IdTbl.t; + classes: class_declaration IdTbl.t; + cltypes: class_type_declaration IdTbl.t; + functor_args: unit Ident.tbl; + summary: summary; + local_constraints: type_declaration PathMap.t; + gadt_instances: (int * TypeSet.t ref) list; + flags: int; +} -let newgenconstr path tyl = newgenty (Tconstr (path, tyl, ref Mnil)) +and module_components = + { + deprecated: string option; + loc: Location.t; + comps: + (t * Subst.t * Path.t * Types.module_type, module_components_repr option) + EnvLazy.t; + } -let constructor_existentials cd_args cd_res = - let tyl = - match cd_args with - | Cstr_tuple l -> l - | Cstr_record l -> List.map (fun l -> l.ld_type) l - in - let existentials = - match cd_res with - | None -> [] - | Some type_ret -> - let arg_vars_set = free_vars (newgenty (Ttuple tyl)) in - let res_vars = free_vars type_ret in - TypeSet.elements (TypeSet.diff arg_vars_set res_vars) - in - (tyl, existentials) +and module_components_repr = + Structure_comps of structure_components + | Functor_comps of functor_components -let constructor_args priv cd_args cd_res path rep = - let tyl, existentials = constructor_existentials cd_args cd_res in - match cd_args with - | Cstr_tuple l -> existentials, l, None - | Cstr_record lbls -> - let arg_vars_set = free_vars ~param:true (newgenty (Ttuple tyl)) in - let type_params = TypeSet.elements arg_vars_set in - let type_unboxed = - match rep with - | Record_unboxed _ -> unboxed_true_default_false - | _ -> unboxed_false_default_false - in - let tdecl = - { - type_params; - type_arity = List.length type_params; - type_kind = Type_record (lbls, rep); - type_private = priv; - type_manifest = None; - type_variance = List.map (fun _ -> Variance.full) type_params; - type_newtype_level = None; - type_loc = Location.none; - type_attributes = []; - type_immediate = false; - type_unboxed; - } - in - existentials, - [ newgenconstr path type_params ], - Some tdecl +and 'a comp_tbl = (string, ('a * int)) Tbl.t -let internal_optional = "internal.optional" - -let optional_shape : Parsetree.attribute = - {txt = internal_optional ; loc = Location.none}, Parsetree.PStr [] +and structure_components = { + mutable comp_values: value_description comp_tbl; + mutable comp_constrs: (string, constructor_description list) Tbl.t; + mutable comp_labels: (string, label_description list) Tbl.t; + mutable comp_types: (type_declaration * type_descriptions) comp_tbl; + mutable comp_modules: + (Subst.t * module_declaration, module_declaration) EnvLazy.t comp_tbl; + mutable comp_modtypes: modtype_declaration comp_tbl; + mutable comp_components: module_components comp_tbl; + mutable comp_classes: class_declaration comp_tbl; + mutable comp_cltypes: class_type_declaration comp_tbl; +} -let constructor_has_optional_shape ({cstr_attributes = attrs} : constructor_description) = - List.exists (fun (x,_) -> x.txt = internal_optional) attrs +and functor_components = { + fcomp_param: Ident.t; (* Formal parameter *) + fcomp_arg: module_type option; (* Argument signature *) + fcomp_res: module_type; (* Result signature *) + fcomp_cache: (Path.t, module_components) Hashtbl.t; (* For memoization *) + fcomp_subst_cache: (Path.t, module_type) Hashtbl.t +} +let copy_local ~from env = + { env with + local_constraints = from.local_constraints; + gadt_instances = from.gadt_instances; + flags = from.flags } -let constructor_descrs ty_path decl cstrs = - let ty_res = newgenconstr ty_path decl.type_params in - let num_consts = ref 0 and num_nonconsts = ref 0 and num_normal = ref 0 in - List.iter - (fun {cd_args; cd_res; _} -> - if cd_args = Cstr_tuple [] then incr num_consts else incr num_nonconsts; - if cd_res = None then incr num_normal) - cstrs; - let rec describe_constructors idx_const idx_nonconst = function - [] -> [] - | {cd_id; cd_args; cd_res; cd_loc; cd_attributes} :: rem -> - let ty_res = - match cd_res with - | Some ty_res' -> ty_res' - | None -> ty_res - in - let (tag, descr_rem) = - match cd_args with - | _ when decl.type_unboxed.unboxed -> - assert (rem = []); - (Cstr_unboxed, []) - | Cstr_tuple [] -> (Cstr_constant idx_const, - describe_constructors (idx_const+1) idx_nonconst rem) - | _ -> (Cstr_block idx_nonconst, - describe_constructors idx_const (idx_nonconst+1) rem) in - let cstr_name = Ident.name cd_id in - let existentials, cstr_args, cstr_inlined = - let representation = - if decl.type_unboxed.unboxed - then Record_unboxed true - else Record_inlined {tag = idx_nonconst; name = cstr_name; num_nonconsts = !num_nonconsts} - in - constructor_args decl.type_private cd_args cd_res - (Path.Pdot (ty_path, cstr_name, Path.nopos)) representation - in - let cstr = - { cstr_name; - cstr_res = ty_res; - cstr_existentials = existentials; - cstr_args; - cstr_arity = List.length cstr_args; - cstr_tag = tag; - cstr_consts = !num_consts; - cstr_nonconsts = !num_nonconsts; - cstr_normal = !num_normal; - cstr_private = decl.type_private; - cstr_generalized = cd_res <> None; - cstr_loc = cd_loc; - cstr_attributes = cd_attributes; - cstr_inlined; - } in - (cd_id, cstr) :: descr_rem in - let result = describe_constructors 0 0 cstrs in - match result with - | ( - [ ({Ident.name = "None"} as a_id, ({cstr_args = []} as a_descr) ) ; - ({Ident.name = "Some"} as b_id, ({ cstr_args = [_]} as b_descr)) - ] | - [ ({Ident.name = "Some"} as a_id, ({cstr_args = [_]} as a_descr) ) ; - ({Ident.name = "None"} as b_id, ({ cstr_args = []} as b_descr)) - ] - ) - -> - [ - (a_id, {a_descr with - cstr_attributes = - optional_shape :: a_descr.cstr_attributes}); - (b_id, {b_descr with - cstr_attributes = - optional_shape :: b_descr.cstr_attributes - }) - ] - | _ -> result +let same_constr = ref (fun _ _ _ -> assert false) -let extension_descr path_ext ext = - let ty_res = - match ext.ext_ret_type with - Some type_ret -> type_ret - | None -> newgenconstr ext.ext_type_path ext.ext_type_params - in - let existentials, cstr_args, cstr_inlined = - constructor_args ext.ext_private ext.ext_args ext.ext_ret_type - path_ext Record_extension - in - { cstr_name = Path.last path_ext; - cstr_res = ty_res; - cstr_existentials = existentials; - cstr_args; - cstr_arity = List.length cstr_args; - cstr_tag = Cstr_extension(path_ext, cstr_args = []); - cstr_consts = -1; - cstr_nonconsts = -1; - cstr_private = ext.ext_private; - cstr_normal = -1; - cstr_generalized = ext.ext_ret_type <> None; - cstr_loc = ext.ext_loc; - cstr_attributes = ext.ext_attributes; - cstr_inlined; - } +(* Helper to decide whether to report an identifier shadowing + by some 'open'. For labels and constructors, we do not report + if the two elements are from the same re-exported declaration. -let none = {desc = Ttuple []; level = -1; id = -1} - (* Clearly ill-formed type *) -let dummy_label = - { lbl_name = ""; lbl_res = none; lbl_arg = none; lbl_mut = Immutable; - lbl_pos = (-1); lbl_all = [||]; lbl_repres = Record_regular; - lbl_private = Public; - lbl_loc = Location.none; - lbl_attributes = []; - } + Later, one could also interpret some attributes on value and + type declarations to silence the shadowing warnings. *) -let label_descrs ty_res lbls repres priv = - let all_labels = Array.make (List.length lbls) dummy_label in - let rec describe_labels num = function - [] -> [] - | l :: rest -> - let lbl = - { lbl_name = Ident.name l.ld_id; - lbl_res = ty_res; - lbl_arg = l.ld_type; - lbl_mut = l.ld_mutable; - lbl_pos = num; - lbl_all = all_labels; - lbl_repres = repres; - lbl_private = priv; - lbl_loc = l.ld_loc; - lbl_attributes = l.ld_attributes; - } in - all_labels.(num) <- lbl; - (l.ld_id, lbl) :: describe_labels (num+1) rest in - describe_labels 0 lbls +let check_shadowing env = function + | `Constructor (Some (c1, c2)) + when not (!same_constr env c1.cstr_res c2.cstr_res) -> + Some "constructor" + | `Label (Some (l1, l2)) + when not (!same_constr env l1.lbl_res l2.lbl_res) -> + Some "label" + | `Value (Some _) -> Some "value" + | `Type (Some _) -> Some "type" + | `Module (Some _) | `Component (Some _) -> Some "module" + | `Module_type (Some _) -> Some "module type" + | `Class (Some _) -> Some "class" + | `Class_type (Some _) -> Some "class type" + | `Constructor _ | `Label _ + | `Value None | `Type None | `Module None | `Module_type None + | `Class None | `Class_type None | `Component None -> + None -exception Constr_not_found +let subst_modtype_maker (subst, md) = + if subst == Subst.identity then md + else {md with md_type = Subst.modtype subst md.md_type} -let rec find_constr tag num_const num_nonconst = function - [] -> - raise Constr_not_found - | {cd_args = Cstr_tuple []; _} as c :: rem -> - if tag = Cstr_constant num_const - then c - else find_constr tag (num_const + 1) num_nonconst rem - | c :: rem -> - if tag = Cstr_block num_nonconst || tag = Cstr_unboxed - then c - else find_constr tag num_const (num_nonconst + 1) rem +let empty = { + values = IdTbl.empty; constrs = TycompTbl.empty; + labels = TycompTbl.empty; types = IdTbl.empty; + modules = IdTbl.empty; modtypes = IdTbl.empty; + components = IdTbl.empty; classes = IdTbl.empty; + cltypes = IdTbl.empty; + summary = Env_empty; local_constraints = PathMap.empty; gadt_instances = []; + flags = 0; + functor_args = Ident.empty; + } -let find_constr_by_tag tag cstrlist = - find_constr tag 0 0 cstrlist +let in_signature b env = + let flags = + if b then env.flags lor in_signature_flag + else env.flags land (lnot in_signature_flag) + in + {env with flags} -let constructors_of_type ty_path decl = - match decl.type_kind with - | Type_variant cstrs -> constructor_descrs ty_path decl cstrs - | Type_record _ | Type_abstract | Type_open -> [] +let implicit_coercion env = + {env with flags = env.flags lor implicit_coercion_flag} -let labels_of_type ty_path decl = - match decl.type_kind with - | Type_record(labels, rep) -> - label_descrs (newgenconstr ty_path decl.type_params) - labels rep decl.type_private - | Type_variant _ | Type_abstract | Type_open -> [] +let is_in_signature env = env.flags land in_signature_flag <> 0 +let is_implicit_coercion env = env.flags land implicit_coercion_flag <> 0 -(* Set row_name in Env, cf. GPR#1204/1329 *) -let set_row_name decl path = - match decl.type_manifest with - None -> () - | Some ty -> - let ty = repr ty in - match ty.desc with - Tvariant row when static_row row -> - let row = {(row_repr row) with - row_name = Some (path, decl.type_params)} in - ty.desc <- Tvariant row - | _ -> () +let is_ident = function + Pident _ -> true + | Pdot _ | Papply _ -> false -end -module Predef : sig -#1 "predef.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let is_local_ext = function + | {cstr_tag = Cstr_extension(p, _)} -> is_ident p + | _ -> false -(* Predefined type constructors (with special typing rules in typecore) *) +let diff env1 env2 = + IdTbl.diff_keys env1.values env2.values @ + TycompTbl.diff_keys is_local_ext env1.constrs env2.constrs @ + IdTbl.diff_keys env1.modules env2.modules @ + IdTbl.diff_keys env1.classes env2.classes -open Types +type can_load_cmis = + | Can_load_cmis + | Cannot_load_cmis of EnvLazy.log -val type_int: type_expr -val type_char: type_expr -val type_string: type_expr -val type_bytes: type_expr -val type_float: type_expr -val type_bool: type_expr -val type_unit: type_expr -val type_exn: type_expr -val type_array: type_expr -> type_expr -val type_list: type_expr -> type_expr -val type_option: type_expr -> type_expr -val type_nativeint: type_expr -val type_int32: type_expr -val type_int64: type_expr -val type_lazy_t: type_expr -> type_expr -val type_extension_constructor:type_expr -val type_floatarray:type_expr +let can_load_cmis = ref Can_load_cmis -val path_int: Path.t -val path_char: Path.t -val path_string: Path.t -val path_bytes: Path.t -val path_float: Path.t -val path_bool: Path.t -val path_unit: Path.t -val path_exn: Path.t -val path_array: Path.t -val path_list: Path.t -val path_option: Path.t -val path_nativeint: Path.t -val path_int32: Path.t -val path_int64: Path.t -val path_lazy_t: Path.t -val path_extension_constructor: Path.t -val path_floatarray: Path.t +let without_cmis f x = + let log = EnvLazy.log () in + let res = + Misc.(protect_refs + [R (can_load_cmis, Cannot_load_cmis log)] + (fun () -> f x)) + in + EnvLazy.backtrack log; + res -val path_match_failure: Path.t -val path_assert_failure : Path.t -val path_undefined_recursive_module : Path.t +(* Forward declarations *) -(* To build the initial environment. Since there is a nasty mutual - recursion between predef and env, we break it by parameterizing - over Env.t, Env.add_type and Env.add_extension. *) +let components_of_module' = + ref ((fun ~deprecated:_ ~loc:_ _env _sub _path _mty -> assert false) : + deprecated:string option -> loc:Location.t -> t -> Subst.t -> + Path.t -> module_type -> + module_components) +let components_of_module_maker' = + ref ((fun (_env, _sub, _path, _mty) -> assert false) : + t * Subst.t * Path.t * module_type -> module_components_repr option) +let components_of_functor_appl' = + ref ((fun _f _env _p1 _p2 -> assert false) : + functor_components -> t -> Path.t -> Path.t -> module_components) +let check_modtype_inclusion = + (* to be filled with Includemod.check_modtype_inclusion *) + ref ((fun ~loc:_ _env _mty1 _path1 _mty2 -> assert false) : + loc:Location.t -> t -> module_type -> Path.t -> module_type -> unit) +let strengthen = + (* to be filled with Mtype.strengthen *) + ref ((fun ~aliasable:_ _env _mty _path -> assert false) : + aliasable:bool -> t -> module_type -> Path.t -> module_type) -val build_initial_env: - (Ident.t -> type_declaration -> 'a -> 'a) -> - (Ident.t -> extension_constructor -> 'a -> 'a) -> - 'a -> 'a * 'a +let md md_type = + {md_type; md_attributes=[]; md_loc=Location.none} -(* To initialize linker tables *) +let get_components_opt c = + match !can_load_cmis with + | Can_load_cmis -> + EnvLazy.force !components_of_module_maker' c.comps + | Cannot_load_cmis log -> + EnvLazy.force_logged log !components_of_module_maker' c.comps -val builtin_values: (string * Ident.t) list -val builtin_idents: (string * Ident.t) list +let empty_structure = + Structure_comps { + comp_values = Tbl.empty; + comp_constrs = Tbl.empty; + comp_labels = Tbl.empty; + comp_types = Tbl.empty; + comp_modules = Tbl.empty; comp_modtypes = Tbl.empty; + comp_components = Tbl.empty; comp_classes = Tbl.empty; + comp_cltypes = Tbl.empty } -(** All predefined exceptions, exposed as [Ident.t] for flambda (for - building value approximations). - The [Ident.t] for division by zero is also exported explicitly - so flambda can generate code to raise it. *) -val ident_division_by_zero: Ident.t -val all_predef_exns : Ident.t list +let get_components c = + match get_components_opt c with + | None -> empty_structure + | Some c -> c -val type_is_builtin_path_but_option : Path.t -> bool +(* The name of the compilation unit currently compiled. + "" if outside a compilation unit. *) -end = struct -#1 "predef.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let current_unit = ref "" -(* Predefined type constructors (with special typing rules in typecore) *) +(* Persistent structure descriptions *) -open Path -open Types -open Btype +type pers_struct = + { ps_name: string; + ps_sig: signature Lazy.t; + ps_comps: module_components; + ps_crcs: (string * Digest.t option) list; + ps_filename: string; + ps_flags: pers_flags list } -let builtin_idents = ref [] +let persistent_structures = + (Hashtbl.create 17 : (string, pers_struct option) Hashtbl.t) -let wrap create s = - let id = create s in - builtin_idents := (s, id) :: !builtin_idents; - id +(* Consistency between persistent structures *) -let ident_create = wrap Ident.create -let ident_create_predef_exn = wrap Ident.create_predef_exn +let crc_units = Consistbl.create() -let ident_int = ident_create "int" -and ident_char = ident_create "char" -and ident_bytes = ident_create "bytes" -and ident_float = ident_create "float" -and ident_bool = ident_create "bool" -and ident_unit = ident_create "unit" -and ident_exn = ident_create "exn" -and ident_array = ident_create "array" -and ident_list = ident_create "list" -and ident_option = ident_create "option" -and ident_nativeint = ident_create "nativeint" -and ident_int32 = ident_create "int32" -and ident_int64 = ident_create "int64" -and ident_lazy_t = ident_create "lazy_t" -and ident_string = ident_create "string" -and ident_extension_constructor = ident_create "extension_constructor" -and ident_floatarray = ident_create "floatarray" +module StringSet = + Set.Make(struct type t = string let compare = String.compare end) -let type_is_builtin_path_but_option (p : Path.t) = - match p with - | Pident {Ident.stamp} -> - stamp >= ident_int.Ident.stamp - && stamp <= ident_floatarray.Ident.stamp - && (stamp <> ident_option.Ident.stamp) - | _ -> false +let imported_units = ref StringSet.empty -let path_int = Pident ident_int -and path_char = Pident ident_char -and path_bytes = Pident ident_bytes -and path_float = Pident ident_float -and path_bool = Pident ident_bool -and path_unit = Pident ident_unit -and path_exn = Pident ident_exn -and path_array = Pident ident_array -and path_list = Pident ident_list -and path_option = Pident ident_option -and path_nativeint = Pident ident_nativeint -and path_int32 = Pident ident_int32 -and path_int64 = Pident ident_int64 -and path_lazy_t = Pident ident_lazy_t -and path_string = Pident ident_string -and path_extension_constructor = Pident ident_extension_constructor -and path_floatarray = Pident ident_floatarray +let add_import s = + imported_units := StringSet.add s !imported_units -let type_int = newgenty (Tconstr(path_int, [], ref Mnil)) -and type_char = newgenty (Tconstr(path_char, [], ref Mnil)) -and type_bytes = newgenty (Tconstr(path_bytes, [], ref Mnil)) -and type_float = newgenty (Tconstr(path_float, [], ref Mnil)) -and type_bool = newgenty (Tconstr(path_bool, [], ref Mnil)) -and type_unit = newgenty (Tconstr(path_unit, [], ref Mnil)) -and type_exn = newgenty (Tconstr(path_exn, [], ref Mnil)) -and type_array t = newgenty (Tconstr(path_array, [t], ref Mnil)) -and type_list t = newgenty (Tconstr(path_list, [t], ref Mnil)) -and type_option t = newgenty (Tconstr(path_option, [t], ref Mnil)) -and type_nativeint = newgenty (Tconstr(path_nativeint, [], ref Mnil)) -and type_int32 = newgenty (Tconstr(path_int32, [], ref Mnil)) -and type_int64 = newgenty (Tconstr(path_int64, [], ref Mnil)) -and type_lazy_t t = newgenty (Tconstr(path_lazy_t, [t], ref Mnil)) -and type_string = newgenty (Tconstr(path_string, [], ref Mnil)) -and type_extension_constructor = - newgenty (Tconstr(path_extension_constructor, [], ref Mnil)) -and type_floatarray = newgenty (Tconstr(path_floatarray, [], ref Mnil)) +let imported_opaque_units = ref StringSet.empty -let ident_match_failure = ident_create_predef_exn "Match_failure" -and ident_out_of_memory = ident_create_predef_exn "Out_of_memory" -and ident_invalid_argument = ident_create_predef_exn "Invalid_argument" -and ident_failure = ident_create_predef_exn "Failure" -and ident_not_found = ident_create_predef_exn "Not_found" -and ident_sys_error = ident_create_predef_exn "Sys_error" -and ident_end_of_file = ident_create_predef_exn "End_of_file" -and ident_division_by_zero = ident_create_predef_exn "Division_by_zero" -and ident_stack_overflow = ident_create_predef_exn "Stack_overflow" -and ident_sys_blocked_io = ident_create_predef_exn "Sys_blocked_io" -and ident_assert_failure = ident_create_predef_exn "Assert_failure" -and ident_undefined_recursive_module = - ident_create_predef_exn "Undefined_recursive_module" +let add_imported_opaque s = + imported_opaque_units := StringSet.add s !imported_opaque_units -let all_predef_exns = [ - ident_match_failure; - ident_out_of_memory; - ident_invalid_argument; - ident_failure; - ident_not_found; - ident_sys_error; - ident_end_of_file; - ident_division_by_zero; - ident_stack_overflow; - ident_sys_blocked_io; - ident_assert_failure; - ident_undefined_recursive_module; -] +let clear_imports () = + Consistbl.clear crc_units; + imported_units := StringSet.empty; + imported_opaque_units := StringSet.empty -let path_match_failure = Pident ident_match_failure -and path_assert_failure = Pident ident_assert_failure -and path_undefined_recursive_module = Pident ident_undefined_recursive_module +let check_consistency ps = + try + List.iter + (fun (name, crco) -> + match crco with + None -> () + | Some crc -> + add_import name; + Consistbl.check crc_units name crc ps.ps_filename) + ps.ps_crcs; + with Consistbl.Inconsistency(name, source, auth) -> + error (Inconsistent_import(name, auth, source)) -let decl_abstr = - {type_params = []; - type_arity = 0; - type_kind = Type_abstract; - type_loc = Location.none; - type_private = Asttypes.Public; - type_manifest = None; - type_variance = []; - type_newtype_level = None; - type_attributes = []; - type_immediate = false; - type_unboxed = unboxed_false_default_false; - } +(* Reading persistent structures from .cmi files *) -let decl_abstr_imm = {decl_abstr with type_immediate = true} +let save_pers_struct crc ps = + let modname = ps.ps_name in + Hashtbl.add persistent_structures modname (Some ps); + List.iter + (function + | Rectypes -> () + | Deprecated _ -> () + | Unsafe_string -> () + | Opaque -> add_imported_opaque modname) + ps.ps_flags; + Consistbl.set crc_units modname crc ps.ps_filename; + add_import modname -let cstr id args = - { - cd_id = id; - cd_args = Cstr_tuple args; - cd_res = None; - cd_loc = Location.none; - cd_attributes = []; - } +module Persistent_signature = struct + type t = + { filename : string; + cmi : Cmi_format.cmi_infos } -let ident_false = ident_create "false" -and ident_true = ident_create "true" -and ident_void = ident_create "()" -and ident_nil = ident_create "[]" -and ident_cons = ident_create "::" -and ident_none = ident_create "None" -and ident_some = ident_create "Some" -let common_initial_env add_type add_extension empty_env = - let decl_bool = - {decl_abstr with - type_kind = Type_variant([cstr ident_false []; cstr ident_true []]); - type_immediate = true} - and decl_unit = - {decl_abstr with - type_kind = Type_variant([cstr ident_void []]); - type_immediate = true} - and decl_exn = - {decl_abstr with - type_kind = Type_open} - and decl_array = - let tvar = newgenvar() in - {decl_abstr with - type_params = [tvar]; - type_arity = 1; - type_variance = [Variance.full]} - and decl_list = - let tvar = newgenvar() in - {decl_abstr with - type_params = [tvar]; - type_arity = 1; - type_kind = - Type_variant([cstr ident_nil []; cstr ident_cons [tvar; type_list tvar]]); - type_variance = [Variance.covariant]} - and decl_option = - let tvar = newgenvar() in - {decl_abstr with - type_params = [tvar]; - type_arity = 1; - type_kind = Type_variant([cstr ident_none []; cstr ident_some [tvar]]); - type_variance = [Variance.covariant]} - and decl_lazy_t = - let tvar = newgenvar() in - {decl_abstr with - type_params = [tvar]; - type_arity = 1; - type_variance = [Variance.covariant]} - in + let load = ref (fun ~unit_name -> + match find_in_path_uncap !load_path (unit_name ^ ".cmi") with + | filename -> Some { filename; cmi = read_cmi filename } + | exception Not_found -> None) +end - let add_extension id l = - add_extension id - { ext_type_path = path_exn; - ext_type_params = []; - ext_args = Cstr_tuple l; - ext_ret_type = None; - ext_private = Asttypes.Public; - ext_loc = Location.none; - ext_attributes = [{Asttypes.txt="ocaml.warn_on_literal_pattern"; - loc=Location.none}, - Parsetree.PStr[]] } +let acknowledge_pers_struct check modname + { Persistent_signature.filename; cmi } = + let name = cmi.cmi_name in + let sign = cmi.cmi_sign in + let crcs = cmi.cmi_crcs in + let flags = cmi.cmi_flags in + let deprecated = + List.fold_left (fun acc -> function Deprecated s -> Some s | _ -> acc) None + flags in - add_extension ident_match_failure - [newgenty (Ttuple[type_string; type_int; type_int])] ( - add_extension ident_out_of_memory [] ( - add_extension ident_stack_overflow [] ( - add_extension ident_invalid_argument [type_string] ( - add_extension ident_failure [type_string] ( - add_extension ident_not_found [] ( - add_extension ident_sys_blocked_io [] ( - add_extension ident_sys_error [type_string] ( - add_extension ident_end_of_file [] ( - add_extension ident_division_by_zero [] ( - add_extension ident_assert_failure - [newgenty (Ttuple[type_string; type_int; type_int])] ( - add_extension ident_undefined_recursive_module - [newgenty (Ttuple[type_string; type_int; type_int])] ( - add_type ident_int64 decl_abstr ( - add_type ident_int32 decl_abstr ( - add_type ident_nativeint decl_abstr ( - add_type ident_lazy_t decl_lazy_t ( - add_type ident_option decl_option ( - add_type ident_list decl_list ( - add_type ident_array decl_array ( - add_type ident_exn decl_exn ( - add_type ident_unit decl_unit ( - add_type ident_bool decl_bool ( - add_type ident_float decl_abstr ( - add_type ident_string decl_abstr ( - add_type ident_char decl_abstr_imm ( - add_type ident_int decl_abstr_imm ( - add_type ident_extension_constructor decl_abstr ( - add_type ident_floatarray decl_abstr ( - empty_env)))))))))))))))))))))))))))) + let comps = + !components_of_module' ~deprecated ~loc:Location.none + empty Subst.identity + (Pident(Ident.create_persistent name)) + (Mty_signature sign) + in + let ps = { ps_name = name; + ps_sig = lazy (Subst.signature Subst.identity sign); + ps_comps = comps; + ps_crcs = crcs; + ps_filename = filename; + ps_flags = flags; + } in + if ps.ps_name <> modname then + error (Illegal_renaming(modname, ps.ps_name, filename)); -let build_initial_env add_type add_exception empty_env = - let common = common_initial_env add_type add_exception empty_env in - let safe_string = add_type ident_bytes decl_abstr common in - let decl_bytes_unsafe = {decl_abstr with type_manifest = Some type_string} in - let unsafe_string = add_type ident_bytes decl_bytes_unsafe common in - (safe_string, unsafe_string) + List.iter + (function + | Rectypes -> + if not !Clflags.recursive_types then + error (Need_recursive_types(ps.ps_name, !current_unit)) + | Unsafe_string -> + if Config.safe_string then + error (Depend_on_unsafe_string_unit (ps.ps_name, !current_unit)); + | Deprecated _ -> () + | Opaque -> add_imported_opaque modname) + ps.ps_flags; + if check then check_consistency ps; + Hashtbl.add persistent_structures modname (Some ps); + ps -let builtin_values = - List.map (fun id -> Ident.make_global id; (Ident.name id, id)) - [ident_match_failure; ident_out_of_memory; ident_stack_overflow; - ident_invalid_argument; - ident_failure; ident_not_found; ident_sys_error; ident_end_of_file; - ident_division_by_zero; ident_sys_blocked_io; - ident_assert_failure; ident_undefined_recursive_module ] +let read_pers_struct check modname filename = + add_import modname; + let cmi = read_cmi filename in + acknowledge_pers_struct check modname + { Persistent_signature.filename; cmi } -(* Start non-predef identifiers at 1000. This way, more predefs can - be defined in this file (above!) without breaking .cmi - compatibility. *) +let find_pers_struct check name = + if name = "*predef*" then raise Not_found; + match Hashtbl.find persistent_structures name with + | Some ps -> ps + | None -> raise Not_found + | exception Not_found -> + match !can_load_cmis with + | Cannot_load_cmis _ -> raise Not_found + | Can_load_cmis -> + let ps = + match !Persistent_signature.load ~unit_name:name with + | Some ps -> ps + | None -> + Hashtbl.add persistent_structures name None; + raise Not_found + in + add_import name; + acknowledge_pers_struct check name ps -let _ = Ident.set_current_time 999 -let builtin_idents = List.rev !builtin_idents +(* Emits a warning if there is no valid cmi for name *) +let check_pers_struct name = + try + ignore (find_pers_struct false name) + with + | Not_found -> + let warn = Warnings.No_cmi_file(name, None) in + Location.prerr_warning Location.none warn + | Cmi_format.Error err -> + let msg = Format.asprintf "%a" Cmi_format.report_error err in + let warn = Warnings.No_cmi_file(name, Some msg) in + Location.prerr_warning Location.none warn + | Error err -> + let msg = + match err with + | Illegal_renaming(name, ps_name, filename) -> + Format.asprintf + " %a@ contains the compiled interface for @ \ + %s when %s was expected" + Location.print_filename filename ps_name name + | Inconsistent_import _ -> assert false + | Need_recursive_types(name, _) -> + Format.sprintf + "%s uses recursive types" + name + | Depend_on_unsafe_string_unit (name, _) -> + Printf.sprintf "%s uses -unsafe-string" + name + | Missing_module _ -> assert false + | Illegal_value_name _ -> assert false + in + let warn = Warnings.No_cmi_file(name, Some msg) in + Location.prerr_warning Location.none warn -end -module Ast_mapper : sig -#1 "ast_mapper.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Alain Frisch, LexiFi *) -(* *) -(* Copyright 2012 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let read_pers_struct modname filename = + read_pers_struct true modname filename -(** The interface of a -ppx rewriter +let find_pers_struct name = + find_pers_struct true name - A -ppx rewriter is a program that accepts a serialized abstract syntax - tree and outputs another, possibly modified, abstract syntax tree. - This module encapsulates the interface between the compiler and - the -ppx rewriters, handling such details as the serialization format, - forwarding of command-line flags, and storing state. +let check_pers_struct name = + if not (Hashtbl.mem persistent_structures name) then begin + (* PR#6843: record the weak dependency ([add_import]) regardless of + whether the check succeeds, to help make builds more + deterministic. *) + add_import name; + if (Warnings.is_active (Warnings.No_cmi_file("", None))) then + !add_delayed_check_forward + (fun () -> check_pers_struct name) + end - {!mapper} allows to implement AST rewriting using open recursion. - A typical mapper would be based on {!default_mapper}, a deep - identity mapper, and will fall back on it for handling the syntax it - does not modify. For example: +let reset_cache () = + current_unit := ""; + Hashtbl.clear persistent_structures; + clear_imports (); + Hashtbl.clear value_declarations; + Hashtbl.clear type_declarations; + Hashtbl.clear module_declarations; + Hashtbl.clear used_constructors; + Hashtbl.clear prefixed_sg - {[ -open Asttypes -open Parsetree -open Ast_mapper +let reset_cache_toplevel () = + (* Delete 'missing cmi' entries from the cache. *) + let l = + Hashtbl.fold + (fun name r acc -> if r = None then name :: acc else acc) + persistent_structures [] + in + List.iter (Hashtbl.remove persistent_structures) l; + Hashtbl.clear value_declarations; + Hashtbl.clear type_declarations; + Hashtbl.clear module_declarations; + Hashtbl.clear used_constructors; + Hashtbl.clear prefixed_sg -let test_mapper argv = - { default_mapper with - expr = fun mapper expr -> - match expr with - | { pexp_desc = Pexp_extension ({ txt = "test" }, PStr [])} -> - Ast_helper.Exp.constant (Const_int 42) - | other -> default_mapper.expr mapper other; } -let () = - register "ppx_test" test_mapper]} +let set_unit_name name = + current_unit := name - This -ppx rewriter, which replaces [[%test]] in expressions with - the constant [42], can be compiled using - [ocamlc -o ppx_test -I +compiler-libs ocamlcommon.cma ppx_test.ml]. +let get_unit_name () = + !current_unit - *) +(* Lookup by identifier *) -open Parsetree +let rec find_module_descr path env = + match path with + Pident id -> + begin try + IdTbl.find_same id env.components + with Not_found -> + if Ident.persistent id && not (Ident.name id = !current_unit) + then (find_pers_struct (Ident.name id)).ps_comps + else raise Not_found + end + | Pdot(p, s, _pos) -> + begin match get_components (find_module_descr p env) with + Structure_comps c -> + let (descr, _pos) = Tbl.find_str s c.comp_components in + descr + | Functor_comps _ -> + raise Not_found + end + | Papply(p1, p2) -> + begin match get_components (find_module_descr p1 env) with + Functor_comps f -> + !components_of_functor_appl' f env p1 p2 + | Structure_comps _ -> + raise Not_found + end -(** {1 A generic Parsetree mapper} *) +let find proj1 proj2 path env = + match path with + Pident id -> + IdTbl.find_same id (proj1 env) + | Pdot(p, s, _pos) -> + begin match get_components (find_module_descr p env) with + Structure_comps c -> + let (data, _pos) = Tbl.find_str s (proj2 c) in data + | Functor_comps _ -> + raise Not_found + end + | Papply _ -> + raise Not_found -type mapper = { - attribute: mapper -> attribute -> attribute; - attributes: mapper -> attribute list -> attribute list; - case: mapper -> case -> case; - cases: mapper -> case list -> case list; - class_declaration: mapper -> class_declaration -> class_declaration; - class_description: mapper -> class_description -> class_description; - class_expr: mapper -> class_expr -> class_expr; - class_field: mapper -> class_field -> class_field; - class_signature: mapper -> class_signature -> class_signature; - class_structure: mapper -> class_structure -> class_structure; - class_type: mapper -> class_type -> class_type; - class_type_declaration: mapper -> class_type_declaration - -> class_type_declaration; - class_type_field: mapper -> class_type_field -> class_type_field; - constructor_declaration: mapper -> constructor_declaration - -> constructor_declaration; - expr: mapper -> expression -> expression; - extension: mapper -> extension -> extension; - extension_constructor: mapper -> extension_constructor - -> extension_constructor; - include_declaration: mapper -> include_declaration -> include_declaration; - include_description: mapper -> include_description -> include_description; - label_declaration: mapper -> label_declaration -> label_declaration; - location: mapper -> Location.t -> Location.t; - module_binding: mapper -> module_binding -> module_binding; - module_declaration: mapper -> module_declaration -> module_declaration; - module_expr: mapper -> module_expr -> module_expr; - module_type: mapper -> module_type -> module_type; - module_type_declaration: mapper -> module_type_declaration - -> module_type_declaration; - open_description: mapper -> open_description -> open_description; - pat: mapper -> pattern -> pattern; - payload: mapper -> payload -> payload; - signature: mapper -> signature -> signature; - signature_item: mapper -> signature_item -> signature_item; - structure: mapper -> structure -> structure; - structure_item: mapper -> structure_item -> structure_item; - typ: mapper -> core_type -> core_type; - type_declaration: mapper -> type_declaration -> type_declaration; - type_extension: mapper -> type_extension -> type_extension; - type_kind: mapper -> type_kind -> type_kind; - value_binding: mapper -> value_binding -> value_binding; - value_description: mapper -> value_description -> value_description; - with_constraint: mapper -> with_constraint -> with_constraint; -} -(** A mapper record implements one "method" per syntactic category, - using an open recursion style: each method takes as its first - argument the mapper to be applied to children in the syntax - tree. *) +let find_value = + find (fun env -> env.values) (fun sc -> sc.comp_values) +and find_type_full = + find (fun env -> env.types) (fun sc -> sc.comp_types) +and find_modtype = + find (fun env -> env.modtypes) (fun sc -> sc.comp_modtypes) +and find_class = + find (fun env -> env.classes) (fun sc -> sc.comp_classes) +and find_cltype = + find (fun env -> env.cltypes) (fun sc -> sc.comp_cltypes) -val default_mapper: mapper -(** A default mapper, which implements a "deep identity" mapping. *) +let type_of_cstr path = function + | {cstr_inlined = Some d; _} -> + (d, ([], List.map snd (Datarepr.labels_of_type path d))) + | _ -> + assert false -(** {1 Apply mappers to compilation units} *) +let find_type_full path env = + match Path.constructor_typath path with + | Regular p -> + (try (PathMap.find p env.local_constraints, ([], [])) + with Not_found -> find_type_full p env) + | Cstr (ty_path, s) -> + let (_, (cstrs, _)) = + try find_type_full ty_path env + with Not_found -> assert false + in + let cstr = + try List.find (fun cstr -> cstr.cstr_name = s) cstrs + with Not_found -> assert false + in + type_of_cstr path cstr + | LocalExt id -> + let cstr = + try TycompTbl.find_same id env.constrs + with Not_found -> assert false + in + type_of_cstr path cstr + | Ext (mod_path, s) -> + let comps = + try find_module_descr mod_path env + with Not_found -> assert false + in + let comps = + match get_components comps with + | Structure_comps c -> c + | Functor_comps _ -> assert false + in + let exts = + List.filter + (function {cstr_tag=Cstr_extension _} -> true | _ -> false) + (try Tbl.find_str s comps.comp_constrs + with Not_found -> assert false) + in + match exts with + | [cstr] -> type_of_cstr path cstr + | _ -> assert false -val tool_name: unit -> string -(** Can be used within a ppx preprocessor to know which tool is - calling it ["ocamlc"], ["ocamlopt"], ["ocamldoc"], ["ocamldep"], - ["ocaml"], ... Some global variables that reflect command-line - options are automatically synchronized between the calling tool - and the ppx preprocessor: {!Clflags.include_dirs}, - {!Config.load_path}, {!Clflags.open_modules}, {!Clflags.for_package}, - {!Clflags.debug}. *) +let find_type p env = + fst (find_type_full p env) +let find_type_descrs p env = + snd (find_type_full p env) +let find_module ~alias path env = + match path with + Pident id -> + begin try + let data = IdTbl.find_same id env.modules in + EnvLazy.force subst_modtype_maker data + with Not_found -> + if Ident.persistent id && not (Ident.name id = !current_unit) then + let ps = find_pers_struct (Ident.name id) in + md (Mty_signature(Lazy.force ps.ps_sig)) + else raise Not_found + end + | Pdot(p, s, _pos) -> + begin match get_components (find_module_descr p env) with + Structure_comps c -> + let (data, _pos) = Tbl.find_str s c.comp_modules in + EnvLazy.force subst_modtype_maker data + | Functor_comps _ -> + raise Not_found + end + | Papply(p1, p2) -> + let desc1 = find_module_descr p1 env in + begin match get_components desc1 with + Functor_comps f -> + md begin match f.fcomp_res with + | Mty_alias _ as mty -> mty + | mty -> + if alias then mty else + try + Hashtbl.find f.fcomp_subst_cache p2 + with Not_found -> + let mty = + Subst.modtype + (Subst.add_module f.fcomp_param p2 Subst.identity) + f.fcomp_res in + Hashtbl.add f.fcomp_subst_cache p2 mty; + mty + end + | Structure_comps _ -> + raise Not_found + end -val apply: source:string -> target:string -> mapper -> unit -(** Apply a mapper (parametrized by the unit name) to a dumped - parsetree found in the [source] file and put the result in the - [target] file. The [structure] or [signature] field of the mapper - is applied to the implementation or interface. *) +let required_globals = ref [] +let reset_required_globals () = required_globals := [] +let get_required_globals () = !required_globals +let add_required_global id = + if Ident.global id && not !Clflags.transparent_modules + && not (List.exists (Ident.same id) !required_globals) + then required_globals := id :: !required_globals -val run_main: (string list -> mapper) -> unit -(** Entry point to call to implement a standalone -ppx rewriter from a - mapper, parametrized by the command line arguments. The current - unit name can be obtained from {!Location.input_name}. This - function implements proper error reporting for uncaught - exceptions. *) +let rec normalize_path lax env path = + let path = + match path with + Pdot(p, s, pos) -> + Pdot(normalize_path lax env p, s, pos) + | Papply(p1, p2) -> + Papply(normalize_path lax env p1, normalize_path true env p2) + | _ -> path + in + try match find_module ~alias:true path env with + {md_type=Mty_alias(_, path1)} -> + let path' = normalize_path lax env path1 in + if lax || !Clflags.transparent_modules then path' else + let id = Path.head path in + if Ident.global id && not (Ident.same id (Path.head path')) + then add_required_global id; + path' + | _ -> path + with Not_found when lax + || (match path with Pident id -> not (Ident.persistent id) | _ -> true) -> + path -(** {1 Registration API} *) +let normalize_path oloc env path = + try normalize_path (oloc = None) env path + with Not_found -> + match oloc with None -> assert false + | Some loc -> + raise (Error(Missing_module(loc, path, normalize_path true env path))) -val register_function: (string -> (string list -> mapper) -> unit) ref +let normalize_path_prefix oloc env path = + match path with + Pdot(p, s, pos) -> + Pdot(normalize_path oloc env p, s, pos) + | Pident _ -> + path + | Papply _ -> + assert false -val register: string -> (string list -> mapper) -> unit -(** Apply the [register_function]. The default behavior is to run the - mapper immediately, taking arguments from the process command - line. This is to support a scenario where a mapper is linked as a - stand-alone executable. - It is possible to overwrite the [register_function] to define - "-ppx drivers", which combine several mappers in a single process. - Typically, a driver starts by defining [register_function] to a - custom implementation, then lets ppx rewriters (linked statically - or dynamically) register themselves, and then run all or some of - them. It is also possible to have -ppx drivers apply rewriters to - only specific parts of an AST. +let find_module = find_module ~alias:false - The first argument to [register] is a symbolic name to be used by - the ppx driver. *) +(* Find the manifest type associated to a type when appropriate: + - the type should be public or should have a private row, + - the type should have an associated manifest type. *) +let find_type_expansion path env = + let decl = find_type path env in + match decl.type_manifest with + | Some body when decl.type_private = Public + || decl.type_kind <> Type_abstract + || Btype.has_constr_row body -> + (decl.type_params, body, may_map snd decl.type_newtype_level) + (* The manifest type of Private abstract data types without + private row are still considered unknown to the type system. + Hence, this case is caught by the following clause that also handles + purely abstract data types without manifest type definition. *) + | _ -> raise Not_found +(* Find the manifest type information associated to a type, i.e. + the necessary information for the compiler's type-based optimisations. + In particular, the manifest type associated to a private abstract type + is revealed for the sake of compiler's type-based optimisations. *) +let find_type_expansion_opt path env = + let decl = find_type path env in + match decl.type_manifest with + (* The manifest type of Private abstract data types can still get + an approximation using their manifest type. *) + | Some body -> (decl.type_params, body, may_map snd decl.type_newtype_level) + | _ -> raise Not_found -(** {1 Convenience functions to write mappers} *) +let find_modtype_expansion path env = + match (find_modtype path env).mtd_type with + | None -> raise Not_found + | Some mty -> mty -val map_opt: ('a -> 'b) -> 'a option -> 'b option +let rec is_functor_arg path env = + match path with + Pident id -> + begin try Ident.find_same id env.functor_args; true + with Not_found -> false + end + | Pdot (p, _s, _) -> is_functor_arg p env + | Papply _ -> true -val extension_of_error: Location.error -> extension -(** Encode an error into an 'ocaml.error' extension node which can be - inserted in a generated Parsetree. The compiler will be - responsible for reporting the error. *) +(* Lookup by name *) -val attribute_of_warning: Location.t -> string -> attribute -(** Encode a warning message into an 'ocaml.ppwarning' attribute which can be - inserted in a generated Parsetree. The compiler will be - responsible for reporting the warning. *) +exception Recmodule -(** {1 Helper functions to call external mappers} *) +let report_deprecated ?loc p deprecated = + match loc, deprecated with + | Some loc, Some txt -> + let txt = if txt = "" then "" else "\n" ^ txt in + Location.deprecated loc (Printf.sprintf "module %s%s" (Path.name p) txt) + | _ -> () + +let mark_module_used env name loc = + if not (is_implicit_coercion env) then + try Hashtbl.find module_declarations (name, loc) () + with Not_found -> () + +let rec lookup_module_descr_aux ?loc lid env = + match lid with + Lident s -> + begin try + IdTbl.find_name s env.components + with Not_found -> + if s = !current_unit then raise Not_found; + let ps = find_pers_struct s in + (Pident(Ident.create_persistent s), ps.ps_comps) + end + | Ldot(l, s) -> + let (p, descr) = lookup_module_descr ?loc l env in + begin match get_components descr with + Structure_comps c -> + let (descr, pos) = Tbl.find_str s c.comp_components in + (Pdot(p, s, pos), descr) + | Functor_comps _ -> + raise Not_found + end + | Lapply(l1, l2) -> + let (p1, desc1) = lookup_module_descr ?loc l1 env in + let p2 = lookup_module ~load:true ?loc l2 env in + let {md_type=mty2} = find_module p2 env in + begin match get_components desc1 with + Functor_comps f -> + let loc = match loc with Some l -> l | None -> Location.none in + Misc.may (!check_modtype_inclusion ~loc env mty2 p2) f.fcomp_arg; + (Papply(p1, p2), !components_of_functor_appl' f env p1 p2) + | Structure_comps _ -> + raise Not_found + end -val add_ppx_context_str: - tool_name:string -> Parsetree.structure -> Parsetree.structure -(** Extract information from the current environment and encode it - into an attribute which is prepended to the list of structure - items in order to pass the information to an external - processor. *) +and lookup_module_descr ?loc lid env = + let (p, comps) as res = lookup_module_descr_aux ?loc lid env in + mark_module_used env (Path.last p) comps.loc; +(* + Format.printf "USE module %s at %a@." (Path.last p) + Location.print comps.loc; +*) + report_deprecated ?loc p comps.deprecated; + res -val add_ppx_context_sig: - tool_name:string -> Parsetree.signature -> Parsetree.signature -(** Same as [add_ppx_context_str], but for signatures. *) +and lookup_module ~load ?loc lid env : Path.t = + match lid with + Lident s -> + begin try + let (p, data) = IdTbl.find_name s env.modules in + let {md_loc; md_attributes; md_type} = + EnvLazy.force subst_modtype_maker data + in + mark_module_used env s md_loc; + begin match md_type with + | Mty_ident (Path.Pident id) when Ident.name id = "#recmod#" -> + (* see #5965 *) + raise Recmodule + + | Mty_alias (_, Path.Pident id) -> + if !Clflags.bs_only && not !Clflags.transparent_modules && Ident.persistent id then + find_pers_struct (Ident.name id) |> ignore + + | _ -> () + end; + report_deprecated ?loc p + (Builtin_attributes.deprecated_of_attrs md_attributes); + p + with Not_found -> + if s = !current_unit then raise Not_found; + let p = Pident(Ident.create_persistent s) in + if !Clflags.transparent_modules && not load then check_pers_struct s + else begin + let ps = find_pers_struct s in + report_deprecated ?loc p ps.ps_comps.deprecated + end; + p + end + | Ldot(l, s) -> + let (p, descr) = lookup_module_descr ?loc l env in + begin match get_components descr with + Structure_comps c -> + let (_data, pos) = Tbl.find_str s c.comp_modules in + let (comps, _) = Tbl.find_str s c.comp_components in + mark_module_used env s comps.loc; + let p = Pdot(p, s, pos) in + report_deprecated ?loc p comps.deprecated; + p + | Functor_comps _ -> + raise Not_found + end + | Lapply(l1, l2) -> + let (p1, desc1) = lookup_module_descr ?loc l1 env in + let p2 = lookup_module ~load:true ?loc l2 env in + let {md_type=mty2} = find_module p2 env in + let p = Papply(p1, p2) in + begin match get_components desc1 with + Functor_comps f -> + let loc = match loc with Some l -> l | None -> Location.none in + Misc.may (!check_modtype_inclusion ~loc env mty2 p2) f.fcomp_arg; + p + | Structure_comps _ -> + raise Not_found + end -val drop_ppx_context_str: - restore:bool -> Parsetree.structure -> Parsetree.structure -(** Drop the ocaml.ppx.context attribute from a structure. If - [restore] is true, also restore the associated data in the current - process. *) +let lookup proj1 proj2 ?loc lid env = + match lid with + Lident s -> + IdTbl.find_name s (proj1 env) + | Ldot(l, s) -> + let (p, desc) = lookup_module_descr ?loc l env in + begin match get_components desc with + Structure_comps c -> + let (data, pos) = Tbl.find_str s (proj2 c) in + (Pdot(p, s, pos), data) + | Functor_comps _ -> + raise Not_found + end + | Lapply _ -> + raise Not_found -val drop_ppx_context_sig: - restore:bool -> Parsetree.signature -> Parsetree.signature -(** Same as [drop_ppx_context_str], but for signatures. *) +let lookup_all_simple proj1 proj2 shadow ?loc lid env = + match lid with + Lident s -> + let xl = TycompTbl.find_all s (proj1 env) in + let rec do_shadow = + function + | [] -> [] + | ((x, f) :: xs) -> + (x, f) :: + (do_shadow (List.filter (fun (y, _) -> not (shadow x y)) xs)) + in + do_shadow xl + | Ldot(l, s) -> + let (_p, desc) = lookup_module_descr ?loc l env in + begin match get_components desc with + Structure_comps c -> + let comps = + try Tbl.find_str s (proj2 c) with Not_found -> [] + in + List.map + (fun data -> (data, (fun () -> ()))) + comps + | Functor_comps _ -> + raise Not_found + end + | Lapply _ -> + raise Not_found -(** {1 Cookies} *) +let has_local_constraints env = not (PathMap.is_empty env.local_constraints) -(** Cookies are used to pass information from a ppx processor to - a further invocation of itself, when called from the OCaml - toplevel (or other tools that support cookies). *) +let cstr_shadow cstr1 cstr2 = + match cstr1.cstr_tag, cstr2.cstr_tag with + | Cstr_extension _, Cstr_extension _ -> true + | _ -> false -val set_cookie: string -> Parsetree.expression -> unit -val get_cookie: string -> Parsetree.expression option +let lbl_shadow _lbl1 _lbl2 = false -end = struct -#1 "ast_mapper.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Alain Frisch, LexiFi *) -(* *) -(* Copyright 2012 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let lookup_value = + lookup (fun env -> env.values) (fun sc -> sc.comp_values) +let lookup_all_constructors = + lookup_all_simple (fun env -> env.constrs) (fun sc -> sc.comp_constrs) + cstr_shadow +let lookup_all_labels = + lookup_all_simple (fun env -> env.labels) (fun sc -> sc.comp_labels) + lbl_shadow +let lookup_type = + lookup (fun env -> env.types) (fun sc -> sc.comp_types) +let lookup_modtype = + lookup (fun env -> env.modtypes) (fun sc -> sc.comp_modtypes) +let lookup_class = + lookup (fun env -> env.classes) (fun sc -> sc.comp_classes) +let lookup_cltype = + lookup (fun env -> env.cltypes) (fun sc -> sc.comp_cltypes) -(* A generic Parsetree mapping class *) +let copy_types l env = + let f desc = {desc with val_type = Subst.type_expr Subst.identity desc.val_type} in + let values = List.fold_left (fun env s -> IdTbl.update s f env) env.values l in + {env with values; summary = Env_copy_types (env.summary, l)} -(* -[@@@ocaml.warning "+9"] - (* Ensure that record patterns don't miss any field. *) -*) +let mark_value_used env name vd = + if not (is_implicit_coercion env) then + try Hashtbl.find value_declarations (name, vd.val_loc) () + with Not_found -> () +let mark_type_used env name vd = + if not (is_implicit_coercion env) then + try Hashtbl.find type_declarations (name, vd.type_loc) () + with Not_found -> () -open Parsetree -open Ast_helper -open Location +let mark_constructor_used usage env name vd constr = + if not (is_implicit_coercion env) then + try Hashtbl.find used_constructors (name, vd.type_loc, constr) usage + with Not_found -> () -type mapper = { - attribute: mapper -> attribute -> attribute; - attributes: mapper -> attribute list -> attribute list; - case: mapper -> case -> case; - cases: mapper -> case list -> case list; - class_declaration: mapper -> class_declaration -> class_declaration; - class_description: mapper -> class_description -> class_description; - class_expr: mapper -> class_expr -> class_expr; - class_field: mapper -> class_field -> class_field; - class_signature: mapper -> class_signature -> class_signature; - class_structure: mapper -> class_structure -> class_structure; - class_type: mapper -> class_type -> class_type; - class_type_declaration: mapper -> class_type_declaration - -> class_type_declaration; - class_type_field: mapper -> class_type_field -> class_type_field; - constructor_declaration: mapper -> constructor_declaration - -> constructor_declaration; - expr: mapper -> expression -> expression; - extension: mapper -> extension -> extension; - extension_constructor: mapper -> extension_constructor - -> extension_constructor; - include_declaration: mapper -> include_declaration -> include_declaration; - include_description: mapper -> include_description -> include_description; - label_declaration: mapper -> label_declaration -> label_declaration; - location: mapper -> Location.t -> Location.t; - module_binding: mapper -> module_binding -> module_binding; - module_declaration: mapper -> module_declaration -> module_declaration; - module_expr: mapper -> module_expr -> module_expr; - module_type: mapper -> module_type -> module_type; - module_type_declaration: mapper -> module_type_declaration - -> module_type_declaration; - open_description: mapper -> open_description -> open_description; - pat: mapper -> pattern -> pattern; - payload: mapper -> payload -> payload; - signature: mapper -> signature -> signature; - signature_item: mapper -> signature_item -> signature_item; - structure: mapper -> structure -> structure; - structure_item: mapper -> structure_item -> structure_item; - typ: mapper -> core_type -> core_type; - type_declaration: mapper -> type_declaration -> type_declaration; - type_extension: mapper -> type_extension -> type_extension; - type_kind: mapper -> type_kind -> type_kind; - value_binding: mapper -> value_binding -> value_binding; - value_description: mapper -> value_description -> value_description; - with_constraint: mapper -> with_constraint -> with_constraint; -} +let mark_extension_used usage env ext name = + if not (is_implicit_coercion env) then + let ty_name = Path.last ext.ext_type_path in + try Hashtbl.find used_constructors (ty_name, ext.ext_loc, name) usage + with Not_found -> () -let map_fst f (x, y) = (f x, y) -let map_snd f (x, y) = (x, f y) -let map_tuple f1 f2 (x, y) = (f1 x, f2 y) -let map_tuple3 f1 f2 f3 (x, y, z) = (f1 x, f2 y, f3 z) -let map_opt f = function None -> None | Some x -> Some (f x) +let set_value_used_callback name vd callback = + let key = (name, vd.val_loc) in + try + let old = Hashtbl.find value_declarations key in + Hashtbl.replace value_declarations key (fun () -> old (); callback ()) + (* this is to support cases like: + let x = let x = 1 in x in x + where the two declarations have the same location + (e.g. resulting from Camlp4 expansion of grammar entries) *) + with Not_found -> + Hashtbl.add value_declarations key callback -let map_loc sub {loc; txt} = {loc = sub.location sub loc; txt} +let set_type_used_callback name td callback = + let loc = td.type_loc in + if loc.Location.loc_ghost then () + else let key = (name, loc) in + let old = + try Hashtbl.find type_declarations key + with Not_found -> assert false + in + Hashtbl.replace type_declarations key (fun () -> callback old) -module T = struct - (* Type expressions for the core language *) +let lookup_value ?loc lid env = + let (_, desc) as r = lookup_value ?loc lid env in + mark_value_used env (Longident.last lid) desc; + r - let row_field sub = function - | Rtag (l, attrs, b, tl) -> - Rtag (map_loc sub l, sub.attributes sub attrs, - b, List.map (sub.typ sub) tl) - | Rinherit t -> Rinherit (sub.typ sub t) +let lookup_type ?loc lid env = + let (path, (decl, _)) = lookup_type ?loc lid env in + mark_type_used env (Longident.last lid) decl; + path - let object_field sub = function - | Otag (l, attrs, t) -> - Otag (map_loc sub l, sub.attributes sub attrs, sub.typ sub t) - | Oinherit t -> Oinherit (sub.typ sub t) +let mark_type_path env path = + try + let decl = find_type path env in + mark_type_used env (Path.last path) decl + with Not_found -> () - let map sub {ptyp_desc = desc; ptyp_loc = loc; ptyp_attributes = attrs} = - let open Typ in - let loc = sub.location sub loc in - let attrs = sub.attributes sub attrs in - match desc with - | Ptyp_any -> any ~loc ~attrs () - | Ptyp_var s -> var ~loc ~attrs s - | Ptyp_arrow (lab, t1, t2) -> - arrow ~loc ~attrs lab (sub.typ sub t1) (sub.typ sub t2) - | Ptyp_tuple tyl -> tuple ~loc ~attrs (List.map (sub.typ sub) tyl) - | Ptyp_constr (lid, tl) -> - constr ~loc ~attrs (map_loc sub lid) (List.map (sub.typ sub) tl) - | Ptyp_object (l, o) -> - object_ ~loc ~attrs (List.map (object_field sub) l) o - | Ptyp_class (lid, tl) -> - class_ ~loc ~attrs (map_loc sub lid) (List.map (sub.typ sub) tl) - | Ptyp_alias (t, s) -> alias ~loc ~attrs (sub.typ sub t) s - | Ptyp_variant (rl, b, ll) -> - variant ~loc ~attrs (List.map (row_field sub) rl) b ll - | Ptyp_poly (sl, t) -> poly ~loc ~attrs - (List.map (map_loc sub) sl) (sub.typ sub t) - | Ptyp_package (lid, l) -> - package ~loc ~attrs (map_loc sub lid) - (List.map (map_tuple (map_loc sub) (sub.typ sub)) l) - | Ptyp_extension x -> extension ~loc ~attrs (sub.extension sub x) +let ty_path t = + match repr t with + | {desc=Tconstr(path, _, _)} -> path + | _ -> assert false - let map_type_declaration sub - {ptype_name; ptype_params; ptype_cstrs; - ptype_kind; - ptype_private; - ptype_manifest; - ptype_attributes; - ptype_loc} = - Type.mk (map_loc sub ptype_name) - ~params:(List.map (map_fst (sub.typ sub)) ptype_params) - ~priv:ptype_private - ~cstrs:(List.map - (map_tuple3 (sub.typ sub) (sub.typ sub) (sub.location sub)) - ptype_cstrs) - ~kind:(sub.type_kind sub ptype_kind) - ?manifest:(map_opt (sub.typ sub) ptype_manifest) - ~loc:(sub.location sub ptype_loc) - ~attrs:(sub.attributes sub ptype_attributes) +let lookup_constructor ?loc lid env = + match lookup_all_constructors ?loc lid env with + [] -> raise Not_found + | (desc, use) :: _ -> + mark_type_path env (ty_path desc.cstr_res); + use (); + desc - let map_type_kind sub = function - | Ptype_abstract -> Ptype_abstract - | Ptype_variant l -> - Ptype_variant (List.map (sub.constructor_declaration sub) l) - | Ptype_record l -> Ptype_record (List.map (sub.label_declaration sub) l) - | Ptype_open -> Ptype_open +let is_lident = function + Lident _ -> true + | _ -> false - let map_constructor_arguments sub = function - | Pcstr_tuple l -> Pcstr_tuple (List.map (sub.typ sub) l) - | Pcstr_record l -> - Pcstr_record (List.map (sub.label_declaration sub) l) +let lookup_all_constructors ?loc lid env = + try + let cstrs = lookup_all_constructors ?loc lid env in + let wrap_use desc use () = + mark_type_path env (ty_path desc.cstr_res); + use () + in + List.map (fun (cstr, use) -> (cstr, wrap_use cstr use)) cstrs + with + Not_found when is_lident lid -> [] - let map_type_extension sub - {ptyext_path; ptyext_params; - ptyext_constructors; - ptyext_private; - ptyext_attributes} = - Te.mk - (map_loc sub ptyext_path) - (List.map (sub.extension_constructor sub) ptyext_constructors) - ~params:(List.map (map_fst (sub.typ sub)) ptyext_params) - ~priv:ptyext_private - ~attrs:(sub.attributes sub ptyext_attributes) +let mark_constructor usage env name desc = + if not (is_implicit_coercion env) + then match desc.cstr_tag with + | Cstr_extension _ -> + begin + let ty_path = ty_path desc.cstr_res in + let ty_name = Path.last ty_path in + try Hashtbl.find used_constructors (ty_name, desc.cstr_loc, name) usage + with Not_found -> () + end + | _ -> + let ty_path = ty_path desc.cstr_res in + let ty_decl = try find_type ty_path env with Not_found -> assert false in + let ty_name = Path.last ty_path in + mark_constructor_used usage env ty_name ty_decl name - let map_extension_constructor_kind sub = function - Pext_decl(ctl, cto) -> - Pext_decl(map_constructor_arguments sub ctl, map_opt (sub.typ sub) cto) - | Pext_rebind li -> - Pext_rebind (map_loc sub li) +let lookup_label ?loc lid env = + match lookup_all_labels ?loc lid env with + [] -> raise Not_found + | (desc, use) :: _ -> + mark_type_path env (ty_path desc.lbl_res); + use (); + desc - let map_extension_constructor sub - {pext_name; - pext_kind; - pext_loc; - pext_attributes} = - Te.constructor - (map_loc sub pext_name) - (map_extension_constructor_kind sub pext_kind) - ~loc:(sub.location sub pext_loc) - ~attrs:(sub.attributes sub pext_attributes) +let lookup_all_labels ?loc lid env = + try + let lbls = lookup_all_labels ?loc lid env in + let wrap_use desc use () = + mark_type_path env (ty_path desc.lbl_res); + use () + in + List.map (fun (lbl, use) -> (lbl, wrap_use lbl use)) lbls + with + Not_found when is_lident lid -> [] -end +let lookup_class ?loc lid env = + let (_, desc) as r = lookup_class ?loc lid env in + (* special support for Typeclass.unbound_class *) + if Path.name desc.cty_path = "" then ignore (lookup_type ?loc lid env) + else mark_type_path env desc.cty_path; + r -module CT = struct - (* Type expressions for the class language *) +let lookup_cltype ?loc lid env = + let (_, desc) as r = lookup_cltype ?loc lid env in + if Path.name desc.clty_path = "" then ignore (lookup_type ?loc lid env) + else mark_type_path env desc.clty_path; + mark_type_path env desc.clty_path; + r - let map sub {pcty_loc = loc; pcty_desc = desc; pcty_attributes = attrs} = - let open Cty in - let loc = sub.location sub loc in - let attrs = sub.attributes sub attrs in - match desc with - | Pcty_constr (lid, tys) -> - constr ~loc ~attrs (map_loc sub lid) (List.map (sub.typ sub) tys) - | Pcty_signature x -> signature ~loc ~attrs (sub.class_signature sub x) - | Pcty_arrow (lab, t, ct) -> - arrow ~loc ~attrs lab (sub.typ sub t) (sub.class_type sub ct) - | Pcty_extension x -> extension ~loc ~attrs (sub.extension sub x) - | Pcty_open (ovf, lid, ct) -> - open_ ~loc ~attrs ovf (map_loc sub lid) (sub.class_type sub ct) +(* Iter on an environment (ignoring the body of functors and + not yet evaluated structures) *) - let map_field sub {pctf_desc = desc; pctf_loc = loc; pctf_attributes = attrs} - = - let open Ctf in - let loc = sub.location sub loc in - let attrs = sub.attributes sub attrs in - match desc with - | Pctf_inherit ct -> inherit_ ~loc ~attrs (sub.class_type sub ct) - | Pctf_val (s, m, v, t) -> - val_ ~loc ~attrs (map_loc sub s) m v (sub.typ sub t) - | Pctf_method (s, p, v, t) -> - method_ ~loc ~attrs (map_loc sub s) p v (sub.typ sub t) - | Pctf_constraint (t1, t2) -> - constraint_ ~loc ~attrs (sub.typ sub t1) (sub.typ sub t2) - | Pctf_attribute x -> attribute ~loc (sub.attribute sub x) - | Pctf_extension x -> extension ~loc ~attrs (sub.extension sub x) +type iter_cont = unit -> unit +let iter_env_cont = ref [] - let map_signature sub {pcsig_self; pcsig_fields} = - Csig.mk - (sub.typ sub pcsig_self) - (List.map (sub.class_type_field sub) pcsig_fields) -end +let rec scrape_alias_for_visit env mty = + match mty with + | Mty_alias(_, Pident id) + when Ident.persistent id + && not (Hashtbl.mem persistent_structures (Ident.name id)) -> false + | Mty_alias(_, path) -> (* PR#6600: find_module may raise Not_found *) + begin try scrape_alias_for_visit env (find_module path env).md_type + with Not_found -> false + end + | _ -> true -module MT = struct - (* Type expressions for the module language *) +let iter_env proj1 proj2 f env () = + IdTbl.iter (fun id x -> f (Pident id) x) (proj1 env); + let rec iter_components path path' mcomps = + let cont () = + let visit = + match EnvLazy.get_arg mcomps.comps with + | None -> true + | Some (env, _sub, _path, mty) -> scrape_alias_for_visit env mty + in + if not visit then () else + match get_components mcomps with + Structure_comps comps -> + Tbl.iter + (fun s (d, n) -> f (Pdot (path, s, n)) (Pdot (path', s, n), d)) + (proj2 comps); + Tbl.iter + (fun s (c, n) -> + iter_components (Pdot (path, s, n)) (Pdot (path', s, n)) c) + comps.comp_components + | Functor_comps _ -> () + in iter_env_cont := (path, cont) :: !iter_env_cont + in + Hashtbl.iter + (fun s pso -> + match pso with None -> () + | Some ps -> + let id = Pident (Ident.create_persistent s) in + iter_components id id ps.ps_comps) + persistent_structures; + IdTbl.iter + (fun id (path, comps) -> iter_components (Pident id) path comps) + env.components - let map sub {pmty_desc = desc; pmty_loc = loc; pmty_attributes = attrs} = - let open Mty in - let loc = sub.location sub loc in - let attrs = sub.attributes sub attrs in - match desc with - | Pmty_ident s -> ident ~loc ~attrs (map_loc sub s) - | Pmty_alias s -> alias ~loc ~attrs (map_loc sub s) - | Pmty_signature sg -> signature ~loc ~attrs (sub.signature sub sg) - | Pmty_functor (s, mt1, mt2) -> - functor_ ~loc ~attrs (map_loc sub s) - (Misc.may_map (sub.module_type sub) mt1) - (sub.module_type sub mt2) - | Pmty_with (mt, l) -> - with_ ~loc ~attrs (sub.module_type sub mt) - (List.map (sub.with_constraint sub) l) - | Pmty_typeof me -> typeof_ ~loc ~attrs (sub.module_expr sub me) - | Pmty_extension x -> extension ~loc ~attrs (sub.extension sub x) +let run_iter_cont l = + iter_env_cont := []; + List.iter (fun c -> c ()) l; + let cont = List.rev !iter_env_cont in + iter_env_cont := []; + cont - let map_with_constraint sub = function - | Pwith_type (lid, d) -> - Pwith_type (map_loc sub lid, sub.type_declaration sub d) - | Pwith_module (lid, lid2) -> - Pwith_module (map_loc sub lid, map_loc sub lid2) - | Pwith_typesubst (lid, d) -> - Pwith_typesubst (map_loc sub lid, sub.type_declaration sub d) - | Pwith_modsubst (s, lid) -> - Pwith_modsubst (map_loc sub s, map_loc sub lid) +let iter_types f = iter_env (fun env -> env.types) (fun sc -> sc.comp_types) f - let map_signature_item sub {psig_desc = desc; psig_loc = loc} = - let open Sig in - let loc = sub.location sub loc in - match desc with - | Psig_value vd -> value ~loc (sub.value_description sub vd) - | Psig_type (rf, l) -> type_ ~loc rf (List.map (sub.type_declaration sub) l) - | Psig_typext te -> type_extension ~loc (sub.type_extension sub te) - | Psig_exception ed -> exception_ ~loc (sub.extension_constructor sub ed) - | Psig_module x -> module_ ~loc (sub.module_declaration sub x) - | Psig_recmodule l -> - rec_module ~loc (List.map (sub.module_declaration sub) l) - | Psig_modtype x -> modtype ~loc (sub.module_type_declaration sub x) - | Psig_open x -> open_ ~loc (sub.open_description sub x) - | Psig_include x -> include_ ~loc (sub.include_description sub x) - | Psig_class l -> class_ ~loc (List.map (sub.class_description sub) l) - | Psig_class_type l -> - class_type ~loc (List.map (sub.class_type_declaration sub) l) - | Psig_extension (x, attrs) -> - extension ~loc (sub.extension sub x) ~attrs:(sub.attributes sub attrs) - | Psig_attribute x -> attribute ~loc (sub.attribute sub x) -end +let same_types env1 env2 = + env1.types == env2.types && env1.components == env2.components +let used_persistent () = + let r = ref Concr.empty in + Hashtbl.iter (fun s pso -> if pso != None then r := Concr.add s !r) + persistent_structures; + !r -module M = struct - (* Value expressions for the module language *) +let find_all_comps proj s (p,mcomps) = + match get_components mcomps with + Functor_comps _ -> [] + | Structure_comps comps -> + try let (c,n) = Tbl.find_str s (proj comps) in [Pdot(p,s,n), c] + with Not_found -> [] - let map sub {pmod_loc = loc; pmod_desc = desc; pmod_attributes = attrs} = - let open Mod in - let loc = sub.location sub loc in - let attrs = sub.attributes sub attrs in - match desc with - | Pmod_ident x -> ident ~loc ~attrs (map_loc sub x) - | Pmod_structure str -> structure ~loc ~attrs (sub.structure sub str) - | Pmod_functor (arg, arg_ty, body) -> - functor_ ~loc ~attrs (map_loc sub arg) - (Misc.may_map (sub.module_type sub) arg_ty) - (sub.module_expr sub body) - | Pmod_apply (m1, m2) -> - apply ~loc ~attrs (sub.module_expr sub m1) (sub.module_expr sub m2) - | Pmod_constraint (m, mty) -> - constraint_ ~loc ~attrs (sub.module_expr sub m) - (sub.module_type sub mty) - | Pmod_unpack e -> unpack ~loc ~attrs (sub.expr sub e) - | Pmod_extension x -> extension ~loc ~attrs (sub.extension sub x) +let rec find_shadowed_comps path env = + match path with + Pident id -> + IdTbl.find_all (Ident.name id) env.components + | Pdot (p, s, _) -> + let l = find_shadowed_comps p env in + let l' = + List.map (find_all_comps (fun comps -> comps.comp_components) s) l in + List.flatten l' + | Papply _ -> [] - let map_structure_item sub {pstr_loc = loc; pstr_desc = desc} = - let open Str in - let loc = sub.location sub loc in - match desc with - | Pstr_eval (x, attrs) -> - eval ~loc ~attrs:(sub.attributes sub attrs) (sub.expr sub x) - | Pstr_value (r, vbs) -> value ~loc r (List.map (sub.value_binding sub) vbs) - | Pstr_primitive vd -> primitive ~loc (sub.value_description sub vd) - | Pstr_type (rf, l) -> type_ ~loc rf (List.map (sub.type_declaration sub) l) - | Pstr_typext te -> type_extension ~loc (sub.type_extension sub te) - | Pstr_exception ed -> exception_ ~loc (sub.extension_constructor sub ed) - | Pstr_module x -> module_ ~loc (sub.module_binding sub x) - | Pstr_recmodule l -> rec_module ~loc (List.map (sub.module_binding sub) l) - | Pstr_modtype x -> modtype ~loc (sub.module_type_declaration sub x) - | Pstr_open x -> open_ ~loc (sub.open_description sub x) - | Pstr_class l -> class_ ~loc (List.map (sub.class_declaration sub) l) - | Pstr_class_type l -> - class_type ~loc (List.map (sub.class_type_declaration sub) l) - | Pstr_include x -> include_ ~loc (sub.include_declaration sub x) - | Pstr_extension (x, attrs) -> - extension ~loc (sub.extension sub x) ~attrs:(sub.attributes sub attrs) - | Pstr_attribute x -> attribute ~loc (sub.attribute sub x) -end +let find_shadowed proj1 proj2 path env = + match path with + Pident id -> + IdTbl.find_all (Ident.name id) (proj1 env) + | Pdot (p, s, _) -> + let l = find_shadowed_comps p env in + let l' = List.map (find_all_comps proj2 s) l in + List.flatten l' + | Papply _ -> [] -module E = struct - (* Value expressions for the core language *) +let find_shadowed_types path env = + List.map fst + (find_shadowed + (fun env -> env.types) (fun comps -> comps.comp_types) path env) - let map sub {pexp_loc = loc; pexp_desc = desc; pexp_attributes = attrs} = - let open Exp in - let loc = sub.location sub loc in - let attrs = sub.attributes sub attrs in - match desc with - | Pexp_ident x -> ident ~loc ~attrs (map_loc sub x) - | Pexp_constant x -> constant ~loc ~attrs x - | Pexp_let (r, vbs, e) -> - let_ ~loc ~attrs r (List.map (sub.value_binding sub) vbs) - (sub.expr sub e) - | Pexp_fun (lab, def, p, e) -> - fun_ ~loc ~attrs lab (map_opt (sub.expr sub) def) (sub.pat sub p) - (sub.expr sub e) - | Pexp_function pel -> function_ ~loc ~attrs (sub.cases sub pel) - | Pexp_apply (e, l) -> - apply ~loc ~attrs (sub.expr sub e) (List.map (map_snd (sub.expr sub)) l) - | Pexp_match (e, pel) -> - match_ ~loc ~attrs (sub.expr sub e) (sub.cases sub pel) - | Pexp_try (e, pel) -> try_ ~loc ~attrs (sub.expr sub e) (sub.cases sub pel) - | Pexp_tuple el -> tuple ~loc ~attrs (List.map (sub.expr sub) el) - | Pexp_construct (lid, arg) -> - construct ~loc ~attrs (map_loc sub lid) (map_opt (sub.expr sub) arg) - | Pexp_variant (lab, eo) -> - variant ~loc ~attrs lab (map_opt (sub.expr sub) eo) - | Pexp_record (l, eo) -> - record ~loc ~attrs (List.map (map_tuple (map_loc sub) (sub.expr sub)) l) - (map_opt (sub.expr sub) eo) - | Pexp_field (e, lid) -> - field ~loc ~attrs (sub.expr sub e) (map_loc sub lid) - | Pexp_setfield (e1, lid, e2) -> - setfield ~loc ~attrs (sub.expr sub e1) (map_loc sub lid) - (sub.expr sub e2) - | Pexp_array el -> array ~loc ~attrs (List.map (sub.expr sub) el) - | Pexp_ifthenelse (e1, e2, e3) -> - ifthenelse ~loc ~attrs (sub.expr sub e1) (sub.expr sub e2) - (map_opt (sub.expr sub) e3) - | Pexp_sequence (e1, e2) -> - sequence ~loc ~attrs (sub.expr sub e1) (sub.expr sub e2) - | Pexp_while (e1, e2) -> - while_ ~loc ~attrs (sub.expr sub e1) (sub.expr sub e2) - | Pexp_for (p, e1, e2, d, e3) -> - for_ ~loc ~attrs (sub.pat sub p) (sub.expr sub e1) (sub.expr sub e2) d - (sub.expr sub e3) - | Pexp_coerce (e, t1, t2) -> - coerce ~loc ~attrs (sub.expr sub e) (map_opt (sub.typ sub) t1) - (sub.typ sub t2) - | Pexp_constraint (e, t) -> - constraint_ ~loc ~attrs (sub.expr sub e) (sub.typ sub t) - | Pexp_send (e, s) -> - send ~loc ~attrs (sub.expr sub e) (map_loc sub s) - | Pexp_new lid -> new_ ~loc ~attrs (map_loc sub lid) - | Pexp_setinstvar (s, e) -> - setinstvar ~loc ~attrs (map_loc sub s) (sub.expr sub e) - | Pexp_override sel -> - override ~loc ~attrs - (List.map (map_tuple (map_loc sub) (sub.expr sub)) sel) - | Pexp_letmodule (s, me, e) -> - letmodule ~loc ~attrs (map_loc sub s) (sub.module_expr sub me) - (sub.expr sub e) - | Pexp_letexception (cd, e) -> - letexception ~loc ~attrs - (sub.extension_constructor sub cd) - (sub.expr sub e) - | Pexp_assert e -> assert_ ~loc ~attrs (sub.expr sub e) - | Pexp_lazy e -> lazy_ ~loc ~attrs (sub.expr sub e) - | Pexp_poly (e, t) -> - poly ~loc ~attrs (sub.expr sub e) (map_opt (sub.typ sub) t) - | Pexp_object cls -> object_ ~loc ~attrs (sub.class_structure sub cls) - | Pexp_newtype (s, e) -> - newtype ~loc ~attrs (map_loc sub s) (sub.expr sub e) - | Pexp_pack me -> pack ~loc ~attrs (sub.module_expr sub me) - | Pexp_open (ovf, lid, e) -> - open_ ~loc ~attrs ovf (map_loc sub lid) (sub.expr sub e) - | Pexp_extension x -> extension ~loc ~attrs (sub.extension sub x) - | Pexp_unreachable -> unreachable ~loc ~attrs () -end -module P = struct - (* Patterns *) +(* GADT instance tracking *) - let map sub {ppat_desc = desc; ppat_loc = loc; ppat_attributes = attrs} = - let open Pat in - let loc = sub.location sub loc in - let attrs = sub.attributes sub attrs in - match desc with - | Ppat_any -> any ~loc ~attrs () - | Ppat_var s -> var ~loc ~attrs (map_loc sub s) - | Ppat_alias (p, s) -> alias ~loc ~attrs (sub.pat sub p) (map_loc sub s) - | Ppat_constant c -> constant ~loc ~attrs c - | Ppat_interval (c1, c2) -> interval ~loc ~attrs c1 c2 - | Ppat_tuple pl -> tuple ~loc ~attrs (List.map (sub.pat sub) pl) - | Ppat_construct (l, p) -> - construct ~loc ~attrs (map_loc sub l) (map_opt (sub.pat sub) p) - | Ppat_variant (l, p) -> variant ~loc ~attrs l (map_opt (sub.pat sub) p) - | Ppat_record (lpl, cf) -> - record ~loc ~attrs - (List.map (map_tuple (map_loc sub) (sub.pat sub)) lpl) cf - | Ppat_array pl -> array ~loc ~attrs (List.map (sub.pat sub) pl) - | Ppat_or (p1, p2) -> or_ ~loc ~attrs (sub.pat sub p1) (sub.pat sub p2) - | Ppat_constraint (p, t) -> - constraint_ ~loc ~attrs (sub.pat sub p) (sub.typ sub t) - | Ppat_type s -> type_ ~loc ~attrs (map_loc sub s) - | Ppat_lazy p -> lazy_ ~loc ~attrs (sub.pat sub p) - | Ppat_unpack s -> unpack ~loc ~attrs (map_loc sub s) - | Ppat_open (lid,p) -> open_ ~loc ~attrs (map_loc sub lid) (sub.pat sub p) - | Ppat_exception p -> exception_ ~loc ~attrs (sub.pat sub p) - | Ppat_extension x -> extension ~loc ~attrs (sub.extension sub x) -end +let add_gadt_instance_level lv env = + {env with + gadt_instances = (lv, ref TypeSet.empty) :: env.gadt_instances} -module CE = struct - (* Value expressions for the class language *) +let is_Tlink = function {desc = Tlink _} -> true | _ -> false - let map sub {pcl_loc = loc; pcl_desc = desc; pcl_attributes = attrs} = - let open Cl in - let loc = sub.location sub loc in - let attrs = sub.attributes sub attrs in - match desc with - | Pcl_constr (lid, tys) -> - constr ~loc ~attrs (map_loc sub lid) (List.map (sub.typ sub) tys) - | Pcl_structure s -> - structure ~loc ~attrs (sub.class_structure sub s) - | Pcl_fun (lab, e, p, ce) -> - fun_ ~loc ~attrs lab - (map_opt (sub.expr sub) e) - (sub.pat sub p) - (sub.class_expr sub ce) - | Pcl_apply (ce, l) -> - apply ~loc ~attrs (sub.class_expr sub ce) - (List.map (map_snd (sub.expr sub)) l) - | Pcl_let (r, vbs, ce) -> - let_ ~loc ~attrs r (List.map (sub.value_binding sub) vbs) - (sub.class_expr sub ce) - | Pcl_constraint (ce, ct) -> - constraint_ ~loc ~attrs (sub.class_expr sub ce) (sub.class_type sub ct) - | Pcl_extension x -> extension ~loc ~attrs (sub.extension sub x) - | Pcl_open (ovf, lid, ce) -> - open_ ~loc ~attrs ovf (map_loc sub lid) (sub.class_expr sub ce) +let gadt_instance_level env t = + let rec find_instance = function + [] -> None + | (lv, r) :: rem -> + if TypeSet.exists is_Tlink !r then + (* Should we use set_typeset ? *) + r := TypeSet.fold (fun ty -> TypeSet.add (repr ty)) !r TypeSet.empty; + if TypeSet.mem t !r then Some lv else find_instance rem + in find_instance env.gadt_instances - let map_kind sub = function - | Cfk_concrete (o, e) -> Cfk_concrete (o, sub.expr sub e) - | Cfk_virtual t -> Cfk_virtual (sub.typ sub t) +let add_gadt_instances env lv tl = + let r = + try List.assoc lv env.gadt_instances with Not_found -> assert false in + (* Format.eprintf "Added"; + List.iter (fun ty -> Format.eprintf "@ %a" !Btype.print_raw ty) tl; + Format.eprintf "@."; *) + set_typeset r (List.fold_right TypeSet.add tl !r) - let map_field sub {pcf_desc = desc; pcf_loc = loc; pcf_attributes = attrs} = - let open Cf in - let loc = sub.location sub loc in - let attrs = sub.attributes sub attrs in - match desc with - | Pcf_inherit (o, ce, s) -> - inherit_ ~loc ~attrs o (sub.class_expr sub ce) - (map_opt (map_loc sub) s) - | Pcf_val (s, m, k) -> val_ ~loc ~attrs (map_loc sub s) m (map_kind sub k) - | Pcf_method (s, p, k) -> - method_ ~loc ~attrs (map_loc sub s) p (map_kind sub k) - | Pcf_constraint (t1, t2) -> - constraint_ ~loc ~attrs (sub.typ sub t1) (sub.typ sub t2) - | Pcf_initializer e -> initializer_ ~loc ~attrs (sub.expr sub e) - | Pcf_attribute x -> attribute ~loc (sub.attribute sub x) - | Pcf_extension x -> extension ~loc ~attrs (sub.extension sub x) +(* Only use this after expand_head! *) +let add_gadt_instance_chain env lv t = + let r = + try List.assoc lv env.gadt_instances with Not_found -> assert false in + let rec add_instance t = + let t = repr t in + if not (TypeSet.mem t !r) then begin + (* Format.eprintf "@ %a" !Btype.print_raw t; *) + set_typeset r (TypeSet.add t !r); + match t.desc with + Tconstr (p, _, memo) -> + may add_instance (find_expans Private p !memo) + | _ -> () + end + in + (* Format.eprintf "Added chain"; *) + add_instance t + (* Format.eprintf "@." *) - let map_structure sub {pcstr_self; pcstr_fields} = - { - pcstr_self = sub.pat sub pcstr_self; - pcstr_fields = List.map (sub.class_field sub) pcstr_fields; - } +(* Expand manifest module type names at the top of the given module type *) - let class_infos sub f {pci_virt; pci_params = pl; pci_name; pci_expr; - pci_loc; pci_attributes} = - Ci.mk - ~virt:pci_virt - ~params:(List.map (map_fst (sub.typ sub)) pl) - (map_loc sub pci_name) - (f pci_expr) - ~loc:(sub.location sub pci_loc) - ~attrs:(sub.attributes sub pci_attributes) -end +let rec scrape_alias env ?path mty = + match mty, path with + Mty_ident p, _ -> + begin try + scrape_alias env (find_modtype_expansion p env) ?path + with Not_found -> + mty + end + | Mty_alias(_, path), _ -> + begin try + scrape_alias env (find_module path env).md_type ~path + with Not_found -> + (*Location.prerr_warning Location.none + (Warnings.No_cmi_file (Path.name path));*) + mty + end + | mty, Some path -> + !strengthen ~aliasable:true env mty path + | _ -> mty -(* Now, a generic AST mapper, to be extended to cover all kinds and - cases of the OCaml grammar. The default behavior of the mapper is - the identity. *) +let scrape_alias env mty = scrape_alias env mty -let default_mapper = - { - structure = (fun this l -> List.map (this.structure_item this) l); - structure_item = M.map_structure_item; - module_expr = M.map; - signature = (fun this l -> List.map (this.signature_item this) l); - signature_item = MT.map_signature_item; - module_type = MT.map; - with_constraint = MT.map_with_constraint; - class_declaration = - (fun this -> CE.class_infos this (this.class_expr this)); - class_expr = CE.map; - class_field = CE.map_field; - class_structure = CE.map_structure; - class_type = CT.map; - class_type_field = CT.map_field; - class_signature = CT.map_signature; - class_type_declaration = - (fun this -> CE.class_infos this (this.class_type this)); - class_description = - (fun this -> CE.class_infos this (this.class_type this)); - type_declaration = T.map_type_declaration; - type_kind = T.map_type_kind; - typ = T.map; - type_extension = T.map_type_extension; - extension_constructor = T.map_extension_constructor; - value_description = - (fun this {pval_name; pval_type; pval_prim; pval_loc; - pval_attributes} -> - Val.mk - (map_loc this pval_name) - (this.typ this pval_type) - ~attrs:(this.attributes this pval_attributes) - ~loc:(this.location this pval_loc) - ~prim:pval_prim - ); +(* Given a signature and a root path, prefix all idents in the signature + by the root path and build the corresponding substitution. *) - pat = P.map; - expr = E.map; +let rec prefix_idents root pos sub = function + [] -> ([], sub) + | Sig_value(id, decl) :: rem -> + let p = Pdot(root, Ident.name id, pos) in + let nextpos = match decl.val_kind with Val_prim _ -> pos | _ -> pos+1 in + let (pl, final_sub) = prefix_idents root nextpos sub rem in + (p::pl, final_sub) + | Sig_type(id, _, _) :: rem -> + let p = Pdot(root, Ident.name id, nopos) in + let (pl, final_sub) = + prefix_idents root pos (Subst.add_type id p sub) rem in + (p::pl, final_sub) + | Sig_typext(id, _, _) :: rem -> + let p = Pdot(root, Ident.name id, pos) in + (* we extend the substitution in case of an inlined record *) + let (pl, final_sub) = + prefix_idents root (pos+1) (Subst.add_type id p sub) rem in + (p::pl, final_sub) + | Sig_module(id, _, _) :: rem -> + let p = Pdot(root, Ident.name id, pos) in + let (pl, final_sub) = + prefix_idents root (pos+1) (Subst.add_module id p sub) rem in + (p::pl, final_sub) + | Sig_modtype(id, _) :: rem -> + let p = Pdot(root, Ident.name id, nopos) in + let (pl, final_sub) = + prefix_idents root pos + (Subst.add_modtype id (Mty_ident p) sub) rem in + (p::pl, final_sub) + | Sig_class(id, _, _) :: rem -> + (* pretend this is a type, cf. PR#6650 *) + let p = Pdot(root, Ident.name id, pos) in + let (pl, final_sub) = + prefix_idents root (pos + 1) (Subst.add_type id p sub) rem in + (p::pl, final_sub) + | Sig_class_type(id, _, _) :: rem -> + let p = Pdot(root, Ident.name id, nopos) in + let (pl, final_sub) = + prefix_idents root pos (Subst.add_type id p sub) rem in + (p::pl, final_sub) - module_declaration = - (fun this {pmd_name; pmd_type; pmd_attributes; pmd_loc} -> - Md.mk - (map_loc this pmd_name) - (this.module_type this pmd_type) - ~attrs:(this.attributes this pmd_attributes) - ~loc:(this.location this pmd_loc) - ); +let prefix_idents root sub sg = + if sub = Subst.identity then + let sgs = + try + Hashtbl.find prefixed_sg root + with Not_found -> + let sgs = ref [] in + Hashtbl.add prefixed_sg root sgs; + sgs + in + try + List.assq sg !sgs + with Not_found -> + let r = prefix_idents root 0 sub sg in + sgs := (sg, r) :: !sgs; + r + else + prefix_idents root 0 sub sg - module_type_declaration = - (fun this {pmtd_name; pmtd_type; pmtd_attributes; pmtd_loc} -> - Mtd.mk - (map_loc this pmtd_name) - ?typ:(map_opt (this.module_type this) pmtd_type) - ~attrs:(this.attributes this pmtd_attributes) - ~loc:(this.location this pmtd_loc) - ); +(* Compute structure descriptions *) - module_binding = - (fun this {pmb_name; pmb_expr; pmb_attributes; pmb_loc} -> - Mb.mk (map_loc this pmb_name) (this.module_expr this pmb_expr) - ~attrs:(this.attributes this pmb_attributes) - ~loc:(this.location this pmb_loc) - ); +let add_to_tbl id decl tbl = + let decls = + try Tbl.find_str id tbl with Not_found -> [] in + Tbl.add id (decl :: decls) tbl +let rec components_of_module ~deprecated ~loc env sub path mty = + { + deprecated; + loc; + comps = EnvLazy.create (env, sub, path, mty) + } - open_description = - (fun this {popen_lid; popen_override; popen_attributes; popen_loc} -> - Opn.mk (map_loc this popen_lid) - ~override:popen_override - ~loc:(this.location this popen_loc) - ~attrs:(this.attributes this popen_attributes) - ); +and components_of_module_maker (env, sub, path, mty) = + match scrape_alias env mty with + Mty_signature sg -> + let c = + { comp_values = Tbl.empty; + comp_constrs = Tbl.empty; + comp_labels = Tbl.empty; comp_types = Tbl.empty; + comp_modules = Tbl.empty; comp_modtypes = Tbl.empty; + comp_components = Tbl.empty; comp_classes = Tbl.empty; + comp_cltypes = Tbl.empty } in + let pl, sub = prefix_idents path sub sg in + let env = ref env in + let pos = ref 0 in + List.iter2 (fun item path -> + match item with + Sig_value(id, decl) -> + let decl' = Subst.value_description sub decl in + c.comp_values <- + Tbl.add (Ident.name id) (decl', !pos) c.comp_values; + begin match decl.val_kind with + Val_prim _ -> () | _ -> incr pos + end + | Sig_type(id, decl, _) -> + let decl' = Subst.type_declaration sub decl in + Datarepr.set_row_name decl' (Subst.type_path sub (Path.Pident id)); + let constructors = + List.map snd (Datarepr.constructors_of_type path decl') in + let labels = + List.map snd (Datarepr.labels_of_type path decl') in + c.comp_types <- + Tbl.add (Ident.name id) + ((decl', (constructors, labels)), nopos) + c.comp_types; + List.iter + (fun descr -> + c.comp_constrs <- + add_to_tbl descr.cstr_name descr c.comp_constrs) + constructors; + List.iter + (fun descr -> + c.comp_labels <- + add_to_tbl descr.lbl_name descr c.comp_labels) + labels; + env := store_type_infos id decl !env + | Sig_typext(id, ext, _) -> + let ext' = Subst.extension_constructor sub ext in + let descr = Datarepr.extension_descr path ext' in + c.comp_constrs <- + add_to_tbl (Ident.name id) descr c.comp_constrs; + incr pos + | Sig_module(id, md, _) -> + let md' = EnvLazy.create (sub, md) in + c.comp_modules <- + Tbl.add (Ident.name id) (md', !pos) c.comp_modules; + let deprecated = + Builtin_attributes.deprecated_of_attrs md.md_attributes + in + let comps = + components_of_module ~deprecated ~loc:md.md_loc !env sub path + md.md_type + in + c.comp_components <- + Tbl.add (Ident.name id) (comps, !pos) c.comp_components; + env := store_module ~check:false id md !env; + incr pos + | Sig_modtype(id, decl) -> + let decl' = Subst.modtype_declaration sub decl in + c.comp_modtypes <- + Tbl.add (Ident.name id) (decl', nopos) c.comp_modtypes; + env := store_modtype id decl !env + | Sig_class(id, decl, _) -> + let decl' = Subst.class_declaration sub decl in + c.comp_classes <- + Tbl.add (Ident.name id) (decl', !pos) c.comp_classes; + incr pos + | Sig_class_type(id, decl, _) -> + let decl' = Subst.cltype_declaration sub decl in + c.comp_cltypes <- + Tbl.add (Ident.name id) (decl', !pos) c.comp_cltypes) + sg pl; + Some (Structure_comps c) + | Mty_functor(param, ty_arg, ty_res) -> + Some (Functor_comps { + fcomp_param = param; + (* fcomp_arg and fcomp_res must be prefixed eagerly, because + they are interpreted in the outer environment *) + fcomp_arg = may_map (Subst.modtype sub) ty_arg; + fcomp_res = Subst.modtype sub ty_res; + fcomp_cache = Hashtbl.create 17; + fcomp_subst_cache = Hashtbl.create 17 }) + | Mty_ident _ + | Mty_alias _ -> None +(* Insertion of bindings by identifier + path *) - include_description = - (fun this {pincl_mod; pincl_attributes; pincl_loc} -> - Incl.mk (this.module_type this pincl_mod) - ~loc:(this.location this pincl_loc) - ~attrs:(this.attributes this pincl_attributes) - ); +and check_usage loc id warn tbl = + if not loc.Location.loc_ghost && Warnings.is_active (warn "") then begin + let name = Ident.name id in + let key = (name, loc) in + if Hashtbl.mem tbl key then () + else let used = ref false in + Hashtbl.add tbl key (fun () -> used := true); + if not (name = "" || name.[0] = '_' || name.[0] = '#') + then + !add_delayed_check_forward + (fun () -> if not !used then Location.prerr_warning loc (warn name)) + end; - include_declaration = - (fun this {pincl_mod; pincl_attributes; pincl_loc} -> - Incl.mk (this.module_expr this pincl_mod) - ~loc:(this.location this pincl_loc) - ~attrs:(this.attributes this pincl_attributes) - ); +and check_value_name name loc = + (* Note: we could also check here general validity of the + identifier, to protect against bad identifiers forged by -pp or + -ppx preprocessors. *) + if !Clflags.bs_only && name = "|." then raise (Error(Illegal_value_name(loc, name))) + else if String.length name > 0 && (name.[0] = '#') then + for i = 1 to String.length name - 1 do + if name.[i] = '#' then + raise (Error(Illegal_value_name(loc, name))) + done - value_binding = - (fun this {pvb_pat; pvb_expr; pvb_attributes; pvb_loc} -> - Vb.mk - (this.pat this pvb_pat) - (this.expr this pvb_expr) - ~loc:(this.location this pvb_loc) - ~attrs:(this.attributes this pvb_attributes) - ); +and store_value ?check id decl env = + check_value_name (Ident.name id) decl.val_loc; + may (fun f -> check_usage decl.val_loc id f value_declarations) check; + { env with + values = IdTbl.add id decl env.values; + summary = Env_value(env.summary, id, decl) } +and store_type ~check id info env = + let loc = info.type_loc in + if check then + check_usage loc id (fun s -> Warnings.Unused_type_declaration s) + type_declarations; + let path = Pident id in + let constructors = Datarepr.constructors_of_type path info in + let labels = Datarepr.labels_of_type path info in + let descrs = (List.map snd constructors, List.map snd labels) in - constructor_declaration = - (fun this {pcd_name; pcd_args; pcd_res; pcd_loc; pcd_attributes} -> - Type.constructor - (map_loc this pcd_name) - ~args:(T.map_constructor_arguments this pcd_args) - ?res:(map_opt (this.typ this) pcd_res) - ~loc:(this.location this pcd_loc) - ~attrs:(this.attributes this pcd_attributes) - ); + if check && not loc.Location.loc_ghost && + Warnings.is_active (Warnings.Unused_constructor ("", false, false)) + then begin + let ty = Ident.name id in + List.iter + begin fun (_, {cstr_name = c; _}) -> + let k = (ty, loc, c) in + if not (Hashtbl.mem used_constructors k) then + let used = constructor_usages () in + Hashtbl.add used_constructors k (add_constructor_usage used); + if not (ty = "" || ty.[0] = '_') + then !add_delayed_check_forward + (fun () -> + if not (is_in_signature env) && not used.cu_positive then + Location.prerr_warning loc + (Warnings.Unused_constructor + (c, used.cu_pattern, used.cu_privatize))) + end + constructors + end; + { env with + constrs = + List.fold_right + (fun (id, descr) constrs -> TycompTbl.add id descr constrs) + constructors + env.constrs; + labels = + List.fold_right + (fun (id, descr) labels -> TycompTbl.add id descr labels) + labels + env.labels; + types = + IdTbl.add id (info, descrs) env.types; + summary = Env_type(env.summary, id, info) } - label_declaration = - (fun this {pld_name; pld_type; pld_loc; pld_mutable; pld_attributes} -> - Type.field - (map_loc this pld_name) - (this.typ this pld_type) - ~mut:pld_mutable - ~loc:(this.location this pld_loc) - ~attrs:(this.attributes this pld_attributes) - ); +and store_type_infos id info env = + (* Simplified version of store_type that doesn't compute and store + constructor and label infos, but simply record the arity and + manifest-ness of the type. Used in components_of_module to + keep track of type abbreviations (e.g. type t = float) in the + computation of label representations. *) + { env with + types = IdTbl.add id (info,([],[])) + env.types; + summary = Env_type(env.summary, id, info) } - cases = (fun this l -> List.map (this.case this) l); - case = - (fun this {pc_lhs; pc_guard; pc_rhs} -> - { - pc_lhs = this.pat this pc_lhs; - pc_guard = map_opt (this.expr this) pc_guard; - pc_rhs = this.expr this pc_rhs; - } - ); +and store_extension ~check id ext env = + let loc = ext.ext_loc in + if check && not loc.Location.loc_ghost && + Warnings.is_active (Warnings.Unused_extension ("", false, false, false)) + then begin + let is_exception = Path.same ext.ext_type_path Predef.path_exn in + let ty = Path.last ext.ext_type_path in + let n = Ident.name id in + let k = (ty, loc, n) in + if not (Hashtbl.mem used_constructors k) then begin + let used = constructor_usages () in + Hashtbl.add used_constructors k (add_constructor_usage used); + !add_delayed_check_forward + (fun () -> + if not (is_in_signature env) && not used.cu_positive then + Location.prerr_warning loc + (Warnings.Unused_extension + (n, is_exception, used.cu_pattern, used.cu_privatize) + ) + ) + end; + end; + { env with + constrs = TycompTbl.add id + (Datarepr.extension_descr (Pident id) ext) + env.constrs; + summary = Env_extension(env.summary, id, ext) } +and store_module ~check id md env = + let loc = md.md_loc in + if check then + check_usage loc id (fun s -> Warnings.Unused_module s) + module_declarations; + let deprecated = Builtin_attributes.deprecated_of_attrs md.md_attributes in + { env with + modules = IdTbl.add id (EnvLazy.create (Subst.identity, md)) env.modules; + components = + IdTbl.add id + (components_of_module ~deprecated ~loc:md.md_loc + env Subst.identity (Pident id) md.md_type) + env.components; + summary = Env_module(env.summary, id, md) } - location = (fun _this l -> l); +and store_modtype id info env = + { env with + modtypes = IdTbl.add id info env.modtypes; + summary = Env_modtype(env.summary, id, info) } - extension = (fun this (s, e) -> (map_loc this s, this.payload this e)); - attribute = (fun this (s, e) -> (map_loc this s, this.payload this e)); - attributes = (fun this l -> List.map (this.attribute this) l); - payload = - (fun this -> function - | PStr x -> PStr (this.structure this x) - | PSig x -> PSig (this.signature this x) - | PTyp x -> PTyp (this.typ this x) - | PPat (x, g) -> PPat (this.pat this x, map_opt (this.expr this) g) - ); - } +and store_class id desc env = + { env with + classes = IdTbl.add id desc env.classes; + summary = Env_class(env.summary, id, desc) } -let rec extension_of_error {loc; msg; if_highlight; sub} = - { loc; txt = "ocaml.error" }, - PStr ([Str.eval (Exp.constant (Pconst_string (msg, None))); - Str.eval (Exp.constant (Pconst_string (if_highlight, None)))] @ - (List.map (fun ext -> Str.extension (extension_of_error ext)) sub)) +and store_cltype id desc env = + { env with + cltypes = IdTbl.add id desc env.cltypes; + summary = Env_cltype(env.summary, id, desc) } -let attribute_of_warning loc s = - { loc; txt = "ocaml.ppwarning" }, - PStr ([Str.eval ~loc (Exp.constant (Pconst_string (s, None)))]) +(* Compute the components of a functor application in a path. *) -module StringMap = Map.Make(struct - type t = string - let compare = compare -end) +let components_of_functor_appl f env p1 p2 = + try + Hashtbl.find f.fcomp_cache p2 + with Not_found -> + let p = Papply(p1, p2) in + let sub = Subst.add_module f.fcomp_param p2 Subst.identity in + let mty = Subst.modtype sub f.fcomp_res in + let comps = components_of_module ~deprecated:None ~loc:Location.none + (*???*) + env Subst.identity p mty in + Hashtbl.add f.fcomp_cache p2 comps; + comps -let cookies = ref StringMap.empty +(* Define forward functions *) -let get_cookie k = - try Some (StringMap.find k !cookies) - with Not_found -> None +let _ = + components_of_module' := components_of_module; + components_of_functor_appl' := components_of_functor_appl; + components_of_module_maker' := components_of_module_maker -let set_cookie k v = - cookies := StringMap.add k v !cookies +(* Insertion of bindings by identifier *) -let tool_name_ref = ref "_none_" +let add_functor_arg id env = + {env with + functor_args = Ident.add id () env.functor_args; + summary = Env_functor_arg (env.summary, id)} -let tool_name () = !tool_name_ref +let add_value ?check id desc env = + store_value ?check id desc env +let add_type ~check id info env = + store_type ~check id info env -module PpxContext = struct - open Longident - open Asttypes - open Ast_helper +and add_extension ~check id ext env = + store_extension ~check id ext env - let lid name = { txt = Lident name; loc = Location.none } +and add_module_declaration ?(arg=false) ~check id md env = + let env = store_module ~check id md env in + if arg then add_functor_arg id env else env - let make_string x = Exp.constant (Pconst_string (x, None)) +and add_modtype id info env = + store_modtype id info env - let make_bool x = - if x - then Exp.construct (lid "true") None - else Exp.construct (lid "false") None +and add_class id ty env = + store_class id ty env - let rec make_list f lst = - match lst with - | x :: rest -> - Exp.construct (lid "::") (Some (Exp.tuple [f x; make_list f rest])) - | [] -> - Exp.construct (lid "[]") None +and add_cltype id ty env = + store_cltype id ty env - let make_pair f1 f2 (x1, x2) = - Exp.tuple [f1 x1; f2 x2] +let add_module ?arg id mty env = + add_module_declaration ~check:false ?arg id (md mty) env - let make_option f opt = - match opt with - | Some x -> Exp.construct (lid "Some") (Some (f x)) - | None -> Exp.construct (lid "None") None +let add_local_type path info env = + { env with + local_constraints = PathMap.add path info env.local_constraints } - let get_cookies () = - lid "cookies", - make_list (make_pair make_string (fun x -> x)) - (StringMap.bindings !cookies) +let add_local_constraint path info elv env = + match info with + {type_manifest = Some _; type_newtype_level = Some (lv, _)} -> + (* elv is the expansion level, lv is the definition level *) + let info = {info with type_newtype_level = Some (lv, elv)} in + add_local_type path info env + | _ -> assert false - let mk fields = - { txt = "ocaml.ppx.context"; loc = Location.none }, - Parsetree.PStr [Str.eval (Exp.record fields None)] - let make ~tool_name () = - let fields = - [ - lid "tool_name", make_string tool_name; - lid "include_dirs", make_list make_string !Clflags.include_dirs; - lid "load_path", make_list make_string !Config.load_path; - lid "open_modules", make_list make_string !Clflags.open_modules; - lid "for_package", make_option make_string !Clflags.for_package; - lid "debug", make_bool !Clflags.debug; - lid "use_threads", make_bool !Clflags.use_threads; - lid "use_vmthreads", make_bool !Clflags.use_vmthreads; - get_cookies () - ] - in - mk fields +(* Insertion of bindings by name *) - let get_fields = function - | PStr [{pstr_desc = Pstr_eval - ({ pexp_desc = Pexp_record (fields, None) }, [])}] -> - fields - | _ -> - raise_errorf "Internal error: invalid [@@@ocaml.ppx.context] syntax" +let enter store_fun name data env = + let id = Ident.create name in (id, store_fun id data env) - let restore fields = - let field name payload = - let rec get_string = function - | { pexp_desc = Pexp_constant (Pconst_string (str, None)) } -> str - | _ -> raise_errorf "Internal error: invalid [@@@ocaml.ppx.context \ - { %s }] string syntax" name - and get_bool pexp = - match pexp with - | {pexp_desc = Pexp_construct ({txt = Longident.Lident "true"}, - None)} -> - true - | {pexp_desc = Pexp_construct ({txt = Longident.Lident "false"}, - None)} -> - false - | _ -> raise_errorf "Internal error: invalid [@@@ocaml.ppx.context \ - { %s }] bool syntax" name - and get_list elem = function - | {pexp_desc = - Pexp_construct ({txt = Longident.Lident "::"}, - Some {pexp_desc = Pexp_tuple [exp; rest]}) } -> - elem exp :: get_list elem rest - | {pexp_desc = - Pexp_construct ({txt = Longident.Lident "[]"}, None)} -> - [] - | _ -> raise_errorf "Internal error: invalid [@@@ocaml.ppx.context \ - { %s }] list syntax" name - and get_pair f1 f2 = function - | {pexp_desc = Pexp_tuple [e1; e2]} -> - (f1 e1, f2 e2) - | _ -> raise_errorf "Internal error: invalid [@@@ocaml.ppx.context \ - { %s }] pair syntax" name - and get_option elem = function - | { pexp_desc = - Pexp_construct ({ txt = Longident.Lident "Some" }, Some exp) } -> - Some (elem exp) - | { pexp_desc = - Pexp_construct ({ txt = Longident.Lident "None" }, None) } -> - None - | _ -> raise_errorf "Internal error: invalid [@@@ocaml.ppx.context \ - { %s }] option syntax" name - in - match name with - | "tool_name" -> - tool_name_ref := get_string payload - | "include_dirs" -> - Clflags.include_dirs := get_list get_string payload - | "load_path" -> - Config.load_path := get_list get_string payload - | "open_modules" -> - Clflags.open_modules := get_list get_string payload - | "for_package" -> - Clflags.for_package := get_option get_string payload - | "debug" -> - Clflags.debug := get_bool payload - | "use_threads" -> - Clflags.use_threads := get_bool payload - | "use_vmthreads" -> - Clflags.use_vmthreads := get_bool payload - | "cookies" -> - let l = get_list (get_pair get_string (fun x -> x)) payload in - cookies := - List.fold_left - (fun s (k, v) -> StringMap.add k v s) StringMap.empty - l - | _ -> - () - in - List.iter (function ({txt=Lident name}, x) -> field name x | _ -> ()) fields +let enter_value ?check = enter (store_value ?check) +and enter_type = enter (store_type ~check:true) +and enter_extension = enter (store_extension ~check:true) +and enter_module_declaration ?arg id md env = + add_module_declaration ?arg ~check:true id md env + (* let (id, env) = enter store_module name md env in + (id, add_functor_arg ?arg id env) *) +and enter_modtype = enter store_modtype +and enter_class = enter store_class +and enter_cltype = enter store_cltype - let update_cookies fields = - let fields = - List.filter - (function ({txt=Lident "cookies"}, _) -> false | _ -> true) - fields - in - fields @ [get_cookies ()] -end +let enter_module ?arg s mty env = + let id = Ident.create s in + (id, enter_module_declaration ?arg id (md mty) env) -let ppx_context = PpxContext.make +(* Insertion of all components of a signature *) -let extension_of_exn exn = - match error_of_exn exn with - | Some (`Ok error) -> extension_of_error error - | Some `Already_displayed -> { loc = Location.none; txt = "ocaml.error" }, PStr [] - | None -> raise exn +let add_item comp env = + match comp with + Sig_value(id, decl) -> add_value id decl env + | Sig_type(id, decl, _) -> add_type ~check:false id decl env + | Sig_typext(id, ext, _) -> add_extension ~check:false id ext env + | Sig_module(id, md, _) -> add_module_declaration ~check:false id md env + | Sig_modtype(id, decl) -> add_modtype id decl env + | Sig_class(id, decl, _) -> add_class id decl env + | Sig_class_type(id, decl, _) -> add_cltype id decl env +let rec add_signature sg env = + match sg with + [] -> env + | comp :: rem -> add_signature rem (add_item comp env) -let apply_lazy ~source ~target mapper = - let implem ast = - let fields, ast = - match ast with - | {pstr_desc = Pstr_attribute ({txt = "ocaml.ppx.context"}, x)} :: l -> - PpxContext.get_fields x, l - | _ -> [], ast - in - PpxContext.restore fields; - let ast = - try - let mapper = mapper () in - mapper.structure mapper ast - with exn -> - [{pstr_desc = Pstr_extension (extension_of_exn exn, []); - pstr_loc = Location.none}] - in - let fields = PpxContext.update_cookies fields in - Str.attribute (PpxContext.mk fields) :: ast +(* Open a signature path *) + +let add_components slot root env0 comps = + let add_l w comps env0 = + TycompTbl.add_open slot w comps env0 in - let iface ast = - let fields, ast = - match ast with - | {psig_desc = Psig_attribute ({txt = "ocaml.ppx.context"}, x)} :: l -> - PpxContext.get_fields x, l - | _ -> [], ast - in - PpxContext.restore fields; - let ast = - try - let mapper = mapper () in - mapper.signature mapper ast - with exn -> - [{psig_desc = Psig_extension (extension_of_exn exn, []); - psig_loc = Location.none}] - in - let fields = PpxContext.update_cookies fields in - Sig.attribute (PpxContext.mk fields) :: ast + + let add w comps env0 = IdTbl.add_open slot w root comps env0 in + + let constrs = + add_l (fun x -> `Constructor x) comps.comp_constrs env0.constrs + in + let labels = + add_l (fun x -> `Label x) comps.comp_labels env0.labels in - let ic = open_in_bin source in - let magic = - really_input_string ic (String.length Config.ast_impl_magic_number) + let values = + add (fun x -> `Value x) comps.comp_values env0.values + in + let types = + add (fun x -> `Type x) comps.comp_types env0.types + in + let modtypes = + add (fun x -> `Module_type x) comps.comp_modtypes env0.modtypes + in + let classes = + add (fun x -> `Class x) comps.comp_classes env0.classes + in + let cltypes = + add (fun x -> `Class_type x) comps.comp_cltypes env0.cltypes + in + let components = + add (fun x -> `Component x) comps.comp_components env0.components in - let rewrite transform = - Location.set_input_name @@ input_value ic; - let ast = input_value ic in - close_in ic; - let ast = transform ast in - let oc = open_out_bin target in - output_string oc magic; - output_value oc !Location.input_name; - output_value oc ast; - close_out oc - and fail () = - close_in ic; - failwith "Ast_mapper: OCaml version mismatch or malformed input"; + let modules = + add (fun x -> `Module x) comps.comp_modules env0.modules in - if magic = Config.ast_impl_magic_number then - rewrite (implem : structure -> structure) - else if magic = Config.ast_intf_magic_number then - rewrite (iface : signature -> signature) - else fail () + { env0 with + summary = Env_open(env0.summary, root); + constrs; + labels; + values; + types; + modtypes; + classes; + cltypes; + components; + modules; + } -let drop_ppx_context_str ~restore = function - | {pstr_desc = Pstr_attribute({Location.txt = "ocaml.ppx.context"}, a)} - :: items -> - if restore then - PpxContext.restore (PpxContext.get_fields a); - items - | items -> items +let open_signature slot root env0 = + match get_components (find_module_descr root env0) with + | Functor_comps _ -> None + | Structure_comps comps -> Some (add_components slot root env0 comps) -let drop_ppx_context_sig ~restore = function - | {psig_desc = Psig_attribute({Location.txt = "ocaml.ppx.context"}, a)} - :: items -> - if restore then - PpxContext.restore (PpxContext.get_fields a); - items - | items -> items -let add_ppx_context_str ~tool_name ast = - Ast_helper.Str.attribute (ppx_context ~tool_name ()) :: ast +(* Open a signature from a file *) -let add_ppx_context_sig ~tool_name ast = - Ast_helper.Sig.attribute (ppx_context ~tool_name ()) :: ast +let open_pers_signature name env = + match open_signature None (Pident(Ident.create_persistent name)) env with + | Some env -> env + | None -> assert false (* a compilation unit cannot refer to a functor *) +let open_signature + ?(used_slot = ref false) + ?(loc = Location.none) ?(toplevel = false) ovf root env = + if not toplevel && ovf = Asttypes.Fresh && not loc.Location.loc_ghost + && (Warnings.is_active (Warnings.Unused_open "") + || Warnings.is_active (Warnings.Open_shadow_identifier ("", "")) + || Warnings.is_active (Warnings.Open_shadow_label_constructor ("",""))) + then begin + let used = used_slot in + !add_delayed_check_forward + (fun () -> + if not !used then begin + used := true; + Location.prerr_warning loc (Warnings.Unused_open (Path.name root)) + end + ); + let shadowed = ref [] in + let slot s b = + begin match check_shadowing env b with + | Some kind when not (List.mem (kind, s) !shadowed) -> + shadowed := (kind, s) :: !shadowed; + let w = + match kind with + | "label" | "constructor" -> + Warnings.Open_shadow_label_constructor (kind, s) + | _ -> Warnings.Open_shadow_identifier (kind, s) + in + Location.prerr_warning loc w + | _ -> () + end; + used := true + in + open_signature (Some slot) root env + end + else open_signature None root env -let apply ~source ~target mapper = - apply_lazy ~source ~target (fun () -> mapper) +(* Read a signature from a file *) -let run_main mapper = - try - let a = Sys.argv in - let n = Array.length a in - if n > 2 then - let mapper () = - try mapper (Array.to_list (Array.sub a 1 (n - 3))) - with exn -> - (* PR#6463 *) - let f _ _ = raise exn in - {default_mapper with structure = f; signature = f} - in - apply_lazy ~source:a.(n - 2) ~target:a.(n - 1) mapper - else begin - Printf.eprintf "Usage: %s [extra_args] \n%!" - Sys.executable_name; - exit 2 - end - with exn -> - prerr_endline (Printexc.to_string exn); - exit 2 +let read_signature modname filename = + let ps = read_pers_struct modname filename in + Lazy.force ps.ps_sig -let register_function = ref (fun _name f -> run_main f) -let register name f = !register_function name f +(* Return the CRC of the interface of the given compilation unit *) -end -module Tbl : sig -#1 "tbl.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let crc_of_unit name = + let ps = find_pers_struct name in + let crco = + try + List.assoc name ps.ps_crcs + with Not_found -> + assert false + in + match crco with + None -> assert false + | Some crc -> crc -(* Association tables from any ordered type to any type. - We use the generic ordering to compare keys. *) +(* Return the list of imported interfaces with their CRCs *) -type ('k, 'v) t +let imports () = + + let dont_record_crc_unit = !Clflags.dont_record_crc_unit in + match dont_record_crc_unit with + | None -> Consistbl.extract (StringSet.elements !imported_units) crc_units + | Some x -> + Consistbl.extract + (StringSet.fold + (fun m acc -> if m = x then acc else m::acc) + !imported_units []) crc_units -val empty: ('k, 'v) t -val add: 'k -> 'v -> ('k, 'v) t -> ('k, 'v) t -val find: 'k -> ('k, 'v) t -> 'v -val find_str: string -> (string, 'v) t -> 'v -val mem: 'k -> ('k, 'v) t -> bool -val remove: 'k -> ('k, 'v) t -> ('k, 'v) t -val iter: ('k -> 'v -> unit) -> ('k, 'v) t -> unit -val map: ('k -> 'v1 -> 'v2) -> ('k, 'v1) t -> ('k, 'v2) t -val fold: ('k -> 'v -> 'acc -> 'acc) -> ('k, 'v) t -> 'acc -> 'acc +(* Returns true if [s] is an opaque imported module *) +let is_imported_opaque s = + StringSet.mem s !imported_opaque_units -open Format +(* Save a signature to a file *) -val print: (formatter -> 'k -> unit) -> (formatter -> 'v -> unit) -> - formatter -> ('k, 'v) t -> unit +let save_signature_with_imports ?check_exists ~deprecated sg modname filename imports = + (*prerr_endline filename; + List.iter (fun (name, crc) -> prerr_endline name) imports;*) + Btype.cleanup_abbrev (); + Subst.reset_for_saving (); + let sg = Subst.signature (Subst.for_saving Subst.identity) sg in + let flags = + List.concat [ + if !Clflags.recursive_types then [Cmi_format.Rectypes] else []; + if !Clflags.opaque then [Cmi_format.Opaque] else []; + (if !Clflags.unsafe_string then [Cmi_format.Unsafe_string] else []); + (match deprecated with Some s -> [Deprecated s] | None -> []); + ] + in + try + let cmi = { + cmi_name = modname; + cmi_sign = sg; + cmi_crcs = imports; + cmi_flags = flags; + } in + let crc = -end = struct -#1 "tbl.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) + create_cmi ?check_exists filename cmi in -type ('k, 'v) t = - Empty - | Node of ('k, 'v) t * 'k * 'v * ('k, 'v) t * int + (* Enter signature in persistent table so that imported_unit() + will also return its crc *) + let comps = + components_of_module ~deprecated ~loc:Location.none + empty Subst.identity + (Pident(Ident.create_persistent modname)) (Mty_signature sg) in + let ps = + { ps_name = modname; + ps_sig = lazy (Subst.signature Subst.identity sg); + ps_comps = comps; + ps_crcs = (cmi.cmi_name, Some crc) :: imports; + ps_filename = filename; + ps_flags = cmi.cmi_flags; + } in + save_pers_struct crc ps; + cmi + with exn -> + remove_file filename; + raise exn -let empty = Empty +let save_signature ?check_exists ~deprecated sg modname filename = + save_signature_with_imports ?check_exists ~deprecated sg modname filename (imports()) -let height = function - Empty -> 0 - | Node(_,_,_,_,h) -> h +(* Folding on environments *) -let create l x d r = - let hl = height l and hr = height r in - Node(l, x, d, r, (if hl >= hr then hl + 1 else hr + 1)) +let find_all proj1 proj2 f lid env acc = + match lid with + | None -> + IdTbl.fold_name + (fun name (p, data) acc -> f name p data acc) + (proj1 env) acc + | Some l -> + let p, desc = lookup_module_descr l env in + begin match get_components desc with + Structure_comps c -> + Tbl.fold + (fun s (data, pos) acc -> f s (Pdot (p, s, pos)) data acc) + (proj2 c) acc + | Functor_comps _ -> + acc + end -let bal l x d r = - let hl = height l and hr = height r in - if hl > hr + 1 then - match l with - | Node (ll, lv, ld, lr, _) when height ll >= height lr -> - create ll lv ld (create lr x d r) - | Node (ll, lv, ld, Node (lrl, lrv, lrd, lrr, _), _) -> - create (create ll lv ld lrl) lrv lrd (create lrr x d r) - | _ -> assert false - else if hr > hl + 1 then - match r with - | Node (rl, rv, rd, rr, _) when height rr >= height rl -> - create (create l x d rl) rv rd rr - | Node (Node (rll, rlv, rld, rlr, _), rv, rd, rr, _) -> - create (create l x d rll) rlv rld (create rlr rv rd rr) - | _ -> assert false - else - create l x d r +let find_all_simple_list proj1 proj2 f lid env acc = + match lid with + | None -> + TycompTbl.fold_name + (fun data acc -> f data acc) + (proj1 env) acc + | Some l -> + let (_p, desc) = lookup_module_descr l env in + begin match get_components desc with + Structure_comps c -> + Tbl.fold + (fun _s comps acc -> + match comps with + [] -> acc + | data :: _ -> + f data acc) + (proj2 c) acc + | Functor_comps _ -> + acc + end -let rec add x data = function - Empty -> - Node(Empty, x, data, Empty, 1) - | Node(l, v, d, r, h) -> - let c = compare x v in - if c = 0 then - Node(l, x, data, r, h) - else if c < 0 then - bal (add x data l) v d r - else - bal l v d (add x data r) +let fold_modules f lid env acc = + match lid with + | None -> + let acc = + IdTbl.fold_name + (fun name (p, data) acc -> + let data = EnvLazy.force subst_modtype_maker data in + f name p data acc + ) + env.modules + acc + in + Hashtbl.fold + (fun name ps acc -> + match ps with + None -> acc + | Some ps -> + f name (Pident(Ident.create_persistent name)) + (md (Mty_signature (Lazy.force ps.ps_sig))) acc) + persistent_structures + acc + | Some l -> + let p, desc = lookup_module_descr l env in + begin match get_components desc with + Structure_comps c -> + Tbl.fold + (fun s (data, pos) acc -> + f s (Pdot (p, s, pos)) + (EnvLazy.force subst_modtype_maker data) acc) + c.comp_modules + acc + | Functor_comps _ -> + acc + end -let rec find x = function - Empty -> - raise Not_found - | Node(l, v, d, r, _) -> - let c = compare x v in - if c = 0 then d - else find x (if c < 0 then l else r) +let fold_values f = + find_all (fun env -> env.values) (fun sc -> sc.comp_values) f +and fold_constructors f = + find_all_simple_list (fun env -> env.constrs) (fun sc -> sc.comp_constrs) f +and fold_labels f = + find_all_simple_list (fun env -> env.labels) (fun sc -> sc.comp_labels) f +and fold_types f = + find_all (fun env -> env.types) (fun sc -> sc.comp_types) f +and fold_modtypes f = + find_all (fun env -> env.modtypes) (fun sc -> sc.comp_modtypes) f +and fold_classs f = + find_all (fun env -> env.classes) (fun sc -> sc.comp_classes) f +and fold_cltypes f = + find_all (fun env -> env.cltypes) (fun sc -> sc.comp_cltypes) f -let rec find_str (x : string) = function - Empty -> - raise Not_found - | Node(l, v, d, r, _) -> - let c = compare x v in - if c = 0 then d - else find_str x (if c < 0 then l else r) -let rec mem x = function - Empty -> false - | Node(l, v, _d, r, _) -> - let c = compare x v in - c = 0 || mem x (if c < 0 then l else r) +(* Make the initial environment *) +let (initial_safe_string, initial_unsafe_string) = + Predef.build_initial_env + (add_type ~check:false) + (add_extension ~check:false) + empty -let rec merge t1 t2 = - match (t1, t2) with - (Empty, t) -> t - | (t, Empty) -> t - | (Node(l1, v1, d1, r1, _h1), Node(l2, v2, d2, r2, _h2)) -> - bal l1 v1 d1 (bal (merge r1 l2) v2 d2 r2) +(* Return the environment summary *) + +let summary env = + if PathMap.is_empty env.local_constraints then env.summary + else Env_constraints (env.summary, env.local_constraints) -let rec remove x = function - Empty -> - Empty - | Node(l, v, d, r, _h) -> - let c = compare x v in - if c = 0 then - merge l r - else if c < 0 then - bal (remove x l) v d r - else - bal l v d (remove x r) +let last_env = ref empty +let last_reduced_env = ref empty -let rec iter f = function - Empty -> () - | Node(l, v, d, r, _) -> - iter f l; f v d; iter f r +let keep_only_summary env = + if !last_env == env then !last_reduced_env + else begin + let new_env = + { + empty with + summary = env.summary; + local_constraints = env.local_constraints; + flags = env.flags; + } + in + last_env := env; + last_reduced_env := new_env; + new_env + end -let rec map f = function - Empty -> Empty - | Node(l, v, d, r, h) -> Node(map f l, v, f v d, map f r, h) -let rec fold f m accu = - match m with - | Empty -> accu - | Node(l, v, d, r, _) -> - fold f r (f v d (fold f l accu)) +let env_of_only_summary env_from_summary env = + let new_env = env_from_summary env.summary Subst.identity in + { new_env with + local_constraints = env.local_constraints; + flags = env.flags; + } + +(* Error report *) open Format -let print print_key print_data ppf tbl = - let print_tbl ppf tbl = - iter (fun k d -> fprintf ppf "@[<2>%a ->@ %a;@]@ " print_key k print_data d) - tbl in - fprintf ppf "@[[[%a]]@]" print_tbl tbl +let report_error ppf = function + | Illegal_renaming(modname, ps_name, filename) -> fprintf ppf + "Wrong file naming: %a@ contains the compiled interface for @ \ + %s when %s was expected" + Location.print_filename filename ps_name modname + | Inconsistent_import(name, source1, source2) -> fprintf ppf + "@[The files %a@ and %a@ \ + make inconsistent assumptions@ over interface %s@]" + Location.print_filename source1 Location.print_filename source2 name + | Need_recursive_types(import, export) -> + fprintf ppf + "@[Unit %s imports from %s, which uses recursive types.@ %s@]" + export import "The compilation flag -rectypes is required" + | Depend_on_unsafe_string_unit(import, export) -> + fprintf ppf + "@[Unit %s imports from %s, compiled with -unsafe-string.@ %s@]" + export import "This compiler has been configured in strict \ + safe-string mode (-force-safe-string)" + | Missing_module(_, path1, path2) -> + fprintf ppf "@[@["; + if Path.same path1 path2 then + fprintf ppf "Internal path@ %s@ is dangling." (Path.name path1) + else + fprintf ppf "Internal path@ %s@ expands to@ %s@ which is dangling." + (Path.name path1) (Path.name path2); + fprintf ppf "@]@ @[%s@ %s@ %s.@]@]" + "The compiled interface for module" (Ident.name (Path.head path2)) + "was not found" + | Illegal_value_name(_loc, name) -> + fprintf ppf "'%s' is not a valid value identifier." + name + +let () = + Location.register_error_of_exn + (function + | Error (Missing_module (loc, _, _) + | Illegal_value_name (loc, _) + as err) when loc <> Location.none -> + Some (Location.error_of_printer loc report_error err) + | Error err -> Some (Location.error_of_printer_file report_error err) + | _ -> None + ) end -module Subst : sig -#1 "subst.mli" +module Typedtree : sig +#1 "typedtree.mli" (**************************************************************************) (* *) (* OCaml *) @@ -51409,559 +34247,668 @@ module Subst : sig (* *) (**************************************************************************) -(* Substitutions *) +(** Abstract syntax tree after typing *) + + +(** By comparison with {!Parsetree}: + - Every {!Longindent.t} is accompanied by a resolved {!Path.t}. + +*) +open Asttypes open Types -type t +(* Value expressions for the core language *) -(* - Substitutions are used to translate a type from one context to - another. This requires substituting paths for identifiers, and - possibly also lowering the level of non-generic variables so that - they are inferior to the maximum level of the new context. +type partial = Partial | Total - Substitutions can also be used to create a "clean" copy of a type. - Indeed, non-variable node of a type are duplicated, with their - levels set to generic level. That way, the resulting type is - well-formed (decreasing levels), even if the original one was not. -*) +(** {1 Extension points} *) -val identity: t +type attribute = Parsetree.attribute +type attributes = attribute list -val add_type: Ident.t -> Path.t -> t -> t -val add_type_path: Path.t -> Path.t -> t -> t -val add_type_function: - Path.t -> params:type_expr list -> body:type_expr -> t -> t -val add_module: Ident.t -> Path.t -> t -> t -val add_module_path: Path.t -> Path.t -> t -> t -val add_modtype: Ident.t -> module_type -> t -> t -val for_saving: t -> t -val reset_for_saving: unit -> unit +(** {1 Core language} *) -val module_path: t -> Path.t -> Path.t -val type_path: t -> Path.t -> Path.t +type pattern = + { pat_desc: pattern_desc; + pat_loc: Location.t; + pat_extra : (pat_extra * Location.t * attributes) list; + pat_type: type_expr; + mutable pat_env: Env.t; + pat_attributes: attributes; + } -val type_expr: t -> type_expr -> type_expr -val class_type: t -> class_type -> class_type -val value_description: t -> value_description -> value_description -val type_declaration: t -> type_declaration -> type_declaration -val extension_constructor: - t -> extension_constructor -> extension_constructor -val class_declaration: t -> class_declaration -> class_declaration -val cltype_declaration: t -> class_type_declaration -> class_type_declaration -val modtype: t -> module_type -> module_type -val signature: t -> signature -> signature -val modtype_declaration: t -> modtype_declaration -> modtype_declaration -val module_declaration: t -> module_declaration -> module_declaration -val typexp : t -> Types.type_expr -> Types.type_expr -val class_signature: t -> class_signature -> class_signature +and pat_extra = + | Tpat_constraint of core_type + (** P : T { pat_desc = P + ; pat_extra = (Tpat_constraint T, _, _) :: ... } + *) + | Tpat_type of Path.t * Longident.t loc + (** #tconst { pat_desc = disjunction + ; pat_extra = (Tpat_type (P, "tconst"), _, _) :: ...} -(* Composition of substitutions: - apply (compose s1 s2) x = apply s2 (apply s1 x) *) -val compose: t -> t -> t + where [disjunction] is a [Tpat_or _] representing the + branches of [tconst]. + *) + | Tpat_open of Path.t * Longident.t loc * Env.t + | Tpat_unpack + (** (module P) { pat_desc = Tpat_var "P" + ; pat_extra = (Tpat_unpack, _, _) :: ... } + *) -(* A forward reference to be filled in ctype.ml. *) -val ctype_apply_env_empty: - (type_expr list -> type_expr -> type_expr list -> type_expr) ref +and pattern_desc = + Tpat_any + (** _ *) + | Tpat_var of Ident.t * string loc + (** x *) + | Tpat_alias of pattern * Ident.t * string loc + (** P as a *) + | Tpat_constant of constant + (** 1, 'a', "true", 1.0, 1l, 1L, 1n *) + | Tpat_tuple of pattern list + (** (P1, ..., Pn) -end = struct -#1 "subst.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) + Invariant: n >= 2 + *) + | Tpat_construct of + Longident.t loc * constructor_description * pattern list + (** C [] + C P [P] + C (P1, ..., Pn) [P1; ...; Pn] + *) + | Tpat_variant of label * pattern option * row_desc ref + (** `A (None) + `A P (Some P) -(* Substitutions *) + See {!Types.row_desc} for an explanation of the last parameter. + *) + | Tpat_record of + (Longident.t loc * label_description * pattern) list * + closed_flag + (** { l1=P1; ...; ln=Pn } (flag = Closed) + { l1=P1; ...; ln=Pn; _} (flag = Open) -open Misc -open Path -open Types -open Btype + Invariant: n > 0 + *) + | Tpat_array of pattern list + (** [| P1; ...; Pn |] *) + | Tpat_or of pattern * pattern * row_desc option + (** P1 | P2 -type type_replacement = - | Path of Path.t - | Type_function of { params : type_expr list; body : type_expr } + [row_desc] = [Some _] when translating [Ppat_type _], + [None] otherwise. + *) + | Tpat_lazy of pattern + (** lazy P *) -module PathMap = Map.Make(Path) +and expression = + { exp_desc: expression_desc; + exp_loc: Location.t; + exp_extra: (exp_extra * Location.t * attributes) list; + exp_type: type_expr; + exp_env: Env.t; + exp_attributes: attributes; + } -type t = - { types: type_replacement PathMap.t; - modules: Path.t PathMap.t; - modtypes: (Ident.t, module_type) Tbl.t; - for_saving: bool; - } +and exp_extra = + | Texp_constraint of core_type + (** E : T *) + | Texp_coerce of core_type option * core_type + (** E :> T [Texp_coerce (None, T)] + E : T0 :> T [Texp_coerce (Some T0, T)] + *) + | Texp_open of override_flag * Path.t * Longident.t loc * Env.t + (** let open[!] M in [Texp_open (!, P, M, env)] + where [env] is the environment after opening [P] + *) + | Texp_poly of core_type option + (** Used for method bodies. *) + | Texp_newtype of string + (** fun (type t) -> *) -let identity = - { types = PathMap.empty; - modules = PathMap.empty; - modtypes = Tbl.empty; - for_saving = false; - } +and expression_desc = + Texp_ident of Path.t * Longident.t loc * Types.value_description + (** x + M.x + *) + | Texp_constant of constant + (** 1, 'a', "true", 1.0, 1l, 1L, 1n *) + | Texp_let of rec_flag * value_binding list * expression + (** let P1 = E1 and ... and Pn = EN in E (flag = Nonrecursive) + let rec P1 = E1 and ... and Pn = EN in E (flag = Recursive) + *) + | Texp_function of { arg_label : arg_label; param : Ident.t; + cases : case list; partial : partial; } + (** [Pexp_fun] and [Pexp_function] both translate to [Texp_function]. + See {!Parsetree} for more details. -let add_type_path id p s = { s with types = PathMap.add id (Path p) s.types } -let add_type id p s = add_type_path (Pident id) p s + [param] is the identifier that is to be used to name the + parameter of the function. -let add_type_function id ~params ~body s = - { s with types = PathMap.add id (Type_function { params; body }) s.types } + partial = + [Partial] if the pattern match is partial + [Total] otherwise. + *) + | Texp_apply of expression * (arg_label * expression option) list + (** E0 ~l1:E1 ... ~ln:En -let add_module_path id p s = { s with modules = PathMap.add id p s.modules } -let add_module id p s = add_module_path (Pident id) p s + The expression can be None if the expression is abstracted over + this argument. It currently appears when a label is applied. -let add_modtype id ty s = { s with modtypes = Tbl.add id ty s.modtypes } + For example: + let f x ~y = x + y in + f ~y:3 -let for_saving s = { s with for_saving = true } + The resulting typedtree for the application is: + Texp_apply (Texp_ident "f/1037", + [(Nolabel, None); + (Labelled "y", Some (Texp_constant Const_int 3)) + ]) + *) + | Texp_match of expression * case list * case list * partial + (** match E0 with + | P1 -> E1 + | P2 -> E2 + | exception P3 -> E3 -let loc s x = - if s.for_saving && not !Clflags.keep_locs then Location.none else x + [Texp_match (E0, [(P1, E1); (P2, E2)], [(P3, E3)], _)] + *) + | Texp_try of expression * case list + (** try E with P1 -> E1 | ... | PN -> EN *) + | Texp_tuple of expression list + (** (E1, ..., EN) *) + | Texp_construct of + Longident.t loc * constructor_description * expression list + (** C [] + C E [E] + C (E1, ..., En) [E1;...;En] + *) + | Texp_variant of label * expression option + | Texp_record of { + fields : ( Types.label_description * record_label_definition ) array; + representation : Types.record_representation; + extended_expression : expression option; + } + (** { l1=P1; ...; ln=Pn } (extended_expression = None) + { E0 with l1=P1; ...; ln=Pn } (extended_expression = Some E0) -let remove_loc = - let open Ast_mapper in - {default_mapper with location = (fun _this _loc -> Location.none)} + Invariant: n > 0 -let is_not_doc = function - | ({Location.txt = "ocaml.doc"}, _) -> false - | ({Location.txt = "ocaml.text"}, _) -> false - | ({Location.txt = "doc"}, _) -> false - | ({Location.txt = "text"}, _) -> false - | _ -> true + If the type is { l1: t1; l2: t2 }, the expression + { E0 with t2=P2 } is represented as + Texp_record + { fields = [| l1, Kept t1; l2 Override P2 |]; representation; + extended_expression = Some E0 } + *) + | Texp_field of expression * Longident.t loc * label_description + | Texp_setfield of + expression * Longident.t loc * label_description * expression + | Texp_array of expression list + | Texp_ifthenelse of expression * expression * expression option + | Texp_sequence of expression * expression + | Texp_while of expression * expression + | Texp_for of + Ident.t * Parsetree.pattern * expression * expression * direction_flag * + expression + | Texp_send of expression * meth * expression option + | Texp_new of Path.t * Longident.t loc * Types.class_declaration + | Texp_instvar of Path.t * Path.t * string loc + | Texp_setinstvar of Path.t * Path.t * string loc * expression + | Texp_override of Path.t * (Path.t * string loc * expression) list + | Texp_letmodule of Ident.t * string loc * module_expr * expression + | Texp_letexception of extension_constructor * expression + | Texp_assert of expression + | Texp_lazy of expression + | Texp_object of class_structure * string list + | Texp_pack of module_expr + | Texp_unreachable + | Texp_extension_constructor of Longident.t loc * Path.t -let attrs s x = - let x = - if s.for_saving && not !Clflags.keep_docs then - List.filter is_not_doc x - else x - in - if s.for_saving && not !Clflags.keep_locs - then remove_loc.Ast_mapper.attributes remove_loc x - else x +and meth = + Tmeth_name of string + | Tmeth_val of Ident.t -let rec module_path s path = - try PathMap.find path s.modules - with Not_found -> - match path with - | Pident _ -> path - | Pdot(p, n, pos) -> - Pdot(module_path s p, n, pos) - | Papply(p1, p2) -> - Papply(module_path s p1, module_path s p2) +and case = + { + c_lhs: pattern; + c_guard: expression option; + c_rhs: expression; + } -let modtype_path s = function - Pident id as p -> - begin try - match Tbl.find id s.modtypes with - | Mty_ident p -> p - | _ -> fatal_error "Subst.modtype_path" - with Not_found -> p end - | Pdot(p, n, pos) -> - Pdot(module_path s p, n, pos) - | Papply _ -> - fatal_error "Subst.modtype_path" +and record_label_definition = + | Kept of Types.type_expr + | Overridden of Longident.t loc * expression -let type_path s path = - match PathMap.find path s.types with - | Path p -> p - | Type_function _ -> assert false - | exception Not_found -> - match path with - | Pident _ -> path - | Pdot(p, n, pos) -> - Pdot(module_path s p, n, pos) - | Papply _ -> - fatal_error "Subst.type_path" +(* Value expressions for the class language *) + +and class_expr = + { + cl_desc: class_expr_desc; + cl_loc: Location.t; + cl_type: Types.class_type; + cl_env: Env.t; + cl_attributes: attributes; + } + +and class_expr_desc = + Tcl_ident of Path.t * Longident.t loc * core_type list + | Tcl_structure of class_structure + | Tcl_fun of + arg_label * pattern * (Ident.t * string loc * expression) list + * class_expr * partial + | Tcl_apply of class_expr * (arg_label * expression option) list + | Tcl_let of rec_flag * value_binding list * + (Ident.t * string loc * expression) list * class_expr + | Tcl_constraint of + class_expr * class_type option * string list * string list * Concr.t + (* Visible instance variables, methods and concrete methods *) + | Tcl_open of override_flag * Path.t * Longident.t loc * Env.t * class_expr + +and class_structure = + { + cstr_self: pattern; + cstr_fields: class_field list; + cstr_type: Types.class_signature; + cstr_meths: Ident.t Meths.t; + } + +and class_field = + { + cf_desc: class_field_desc; + cf_loc: Location.t; + cf_attributes: attributes; + } + +and class_field_kind = + | Tcfk_virtual of core_type + | Tcfk_concrete of override_flag * expression + +and class_field_desc = + Tcf_inherit of + override_flag * class_expr * string option * (string * Ident.t) list * + (string * Ident.t) list + (* Inherited instance variables and concrete methods *) + | Tcf_val of string loc * mutable_flag * Ident.t * class_field_kind * bool + | Tcf_method of string loc * private_flag * class_field_kind + | Tcf_constraint of core_type * core_type + | Tcf_initializer of expression + | Tcf_attribute of attribute + +(* Value expressions for the module language *) + +and module_expr = + { mod_desc: module_expr_desc; + mod_loc: Location.t; + mod_type: Types.module_type; + mod_env: Env.t; + mod_attributes: attributes; + } + +(** Annotations for [Tmod_constraint]. *) +and module_type_constraint = + | Tmodtype_implicit + (** The module type constraint has been synthesized during typechecking. *) + | Tmodtype_explicit of module_type + (** The module type was in the source file. *) -let type_path s p = - match Path.constructor_typath p with - | Regular p -> type_path s p - | Cstr (ty_path, cstr) -> Pdot(type_path s ty_path, cstr, nopos) - | LocalExt _ -> type_path s p - | Ext (p, cstr) -> Pdot(module_path s p, cstr, nopos) +and module_expr_desc = + Tmod_ident of Path.t * Longident.t loc + | Tmod_structure of structure + | Tmod_functor of Ident.t * string loc * module_type option * module_expr + | Tmod_apply of module_expr * module_expr * module_coercion + | Tmod_constraint of + module_expr * Types.module_type * module_type_constraint * module_coercion + (** ME (constraint = Tmodtype_implicit) + (ME : MT) (constraint = Tmodtype_explicit MT) + *) + | Tmod_unpack of expression * Types.module_type -let to_subst_by_type_function s p = - match PathMap.find p s.types with - | Path _ -> false - | Type_function _ -> true - | exception Not_found -> false +and structure = { + str_items : structure_item list; + str_type : Types.signature; + str_final_env : Env.t; +} -(* Special type ids for saved signatures *) +and structure_item = + { str_desc : structure_item_desc; + str_loc : Location.t; + str_env : Env.t + } -let new_id = ref (-1) -let reset_for_saving () = new_id := -1 +and structure_item_desc = + Tstr_eval of expression * attributes + | Tstr_value of rec_flag * value_binding list + | Tstr_primitive of value_description + | Tstr_type of rec_flag * type_declaration list + | Tstr_typext of type_extension + | Tstr_exception of extension_constructor + | Tstr_module of module_binding + | Tstr_recmodule of module_binding list + | Tstr_modtype of module_type_declaration + | Tstr_open of open_description + | Tstr_class of (class_declaration * string list) list + | Tstr_class_type of (Ident.t * string loc * class_type_declaration) list + | Tstr_include of include_declaration + | Tstr_attribute of attribute -let newpersty desc = - decr new_id; - { desc = desc; level = generic_level; id = !new_id } +and module_binding = + { + mb_id: Ident.t; + mb_name: string loc; + mb_expr: module_expr; + mb_attributes: attributes; + mb_loc: Location.t; + } -(* ensure that all occurrences of 'Tvar None' are physically shared *) -let tvar_none = Tvar None -let tunivar_none = Tunivar None -let norm = function - | Tvar None -> tvar_none - | Tunivar None -> tunivar_none - | d -> d +and value_binding = + { + vb_pat: pattern; + vb_expr: expression; + vb_attributes: attributes; + vb_loc: Location.t; + } -let ctype_apply_env_empty = ref (fun _ -> assert false) +and module_coercion = + Tcoerce_none + | Tcoerce_structure of (int * module_coercion) list * + (Ident.t * int * module_coercion) list * + string list (* runtime fields *) + | Tcoerce_functor of module_coercion * module_coercion + | Tcoerce_primitive of primitive_coercion + | Tcoerce_alias of Path.t * module_coercion -(* Similar to [Ctype.nondep_type_rec]. *) -let rec typexp s ty = - let ty = repr ty in - match ty.desc with - Tvar _ | Tunivar _ as desc -> - if s.for_saving || ty.id < 0 then - let ty' = - if s.for_saving then newpersty (norm desc) - else newty2 ty.level desc - in - save_desc ty desc; ty.desc <- Tsubst ty'; ty' - else ty - | Tsubst ty -> - ty - | Tfield (m, k, _t1, _t2) when not s.for_saving && m = dummy_method - && field_kind_repr k <> Fabsent && (repr ty).level < generic_level -> - (* do not copy the type of self when it is not generalized *) - ty -(* cannot do it, since it would omit substitution - | Tvariant row when not (static_row row) -> - ty -*) - | _ -> - let desc = ty.desc in - save_desc ty desc; - let tm = row_of_type ty in - let has_fixed_row = - not (is_Tconstr ty) && is_constr_row ~allow_ident:false tm in - (* Make a stub *) - let ty' = if s.for_saving then newpersty (Tvar None) else newgenvar () in - ty.desc <- Tsubst ty'; - ty'.desc <- - begin if has_fixed_row then - match tm.desc with (* PR#7348 *) - Tconstr (Pdot(m,i,pos), tl, _abbrev) -> - let i' = String.sub i 0 (String.length i - 4) in - Tconstr(type_path s (Pdot(m,i',pos)), tl, ref Mnil) - | _ -> assert false - else match desc with - | Tconstr (p, args, _abbrev) -> - let args = List.map (typexp s) args in - begin match PathMap.find p s.types with - | exception Not_found -> Tconstr(type_path s p, args, ref Mnil) - | Path _ -> Tconstr(type_path s p, args, ref Mnil) - | Type_function { params; body } -> - (!ctype_apply_env_empty params body args).desc - end - | Tpackage(p, n, tl) -> - Tpackage(modtype_path s p, n, List.map (typexp s) tl) - | Tobject (t1, name) -> - Tobject (typexp s t1, - ref (match !name with - None -> None - | Some (p, tl) -> - if to_subst_by_type_function s p - then None - else Some (type_path s p, List.map (typexp s) tl))) - | Tvariant row -> - let row = row_repr row in - let more = repr row.row_more in - (* We must substitute in a subtle way *) - (* Tsubst takes a tuple containing the row var and the variant *) - begin match more.desc with - Tsubst {desc = Ttuple [_;ty2]} -> - (* This variant type has been already copied *) - ty.desc <- Tsubst ty2; (* avoid Tlink in the new type *) - Tlink ty2 - | _ -> - let dup = - s.for_saving || more.level = generic_level || static_row row || - match more.desc with Tconstr _ -> true | _ -> false in - (* Various cases for the row variable *) - let more' = - match more.desc with - Tsubst ty -> ty - | Tconstr _ | Tnil -> typexp s more - | Tunivar _ | Tvar _ -> - save_desc more more.desc; - if s.for_saving then newpersty (norm more.desc) else - if dup && is_Tvar more then newgenty more.desc else more - | _ -> assert false - in - (* Register new type first for recursion *) - more.desc <- Tsubst(newgenty(Ttuple[more';ty'])); - (* Return a new copy *) - let row = - copy_row (typexp s) true row (not dup) more' in - match row.row_name with - | Some (p, tl) -> - Tvariant {row with row_name = - if to_subst_by_type_function s p - then None - else Some (type_path s p, tl)} - | None -> - Tvariant row - end - | Tfield(_label, kind, _t1, t2) when field_kind_repr kind = Fabsent -> - Tlink (typexp s t2) - | _ -> copy_type_desc (typexp s) desc - end; - ty' +and module_type = + { mty_desc: module_type_desc; + mty_type : Types.module_type; + mty_env : Env.t; + mty_loc: Location.t; + mty_attributes: attributes; + } -(* - Always make a copy of the type. If this is not done, type levels - might not be correct. -*) -let type_expr s ty = - let ty' = typexp s ty in - cleanup_types (); - ty' +and module_type_desc = + Tmty_ident of Path.t * Longident.t loc + | Tmty_signature of signature + | Tmty_functor of Ident.t * string loc * module_type option * module_type + | Tmty_with of module_type * (Path.t * Longident.t loc * with_constraint) list + | Tmty_typeof of module_expr + | Tmty_alias of Path.t * Longident.t loc -let label_declaration s l = +and primitive_coercion = { - ld_id = l.ld_id; - ld_mutable = l.ld_mutable; - ld_type = typexp s l.ld_type; - ld_loc = loc s l.ld_loc; - ld_attributes = attrs s l.ld_attributes; + pc_desc: Primitive.description; + pc_type: type_expr; + pc_env: Env.t; + pc_loc : Location.t; + + pc_id : Ident.t; + } -let constructor_arguments s = function - | Cstr_tuple l -> - Cstr_tuple (List.map (typexp s) l) - | Cstr_record l -> - Cstr_record (List.map (label_declaration s) l) +and signature = { + sig_items : signature_item list; + sig_type : Types.signature; + sig_final_env : Env.t; +} -let constructor_declaration s c = - { - cd_id = c.cd_id; - cd_args = constructor_arguments s c.cd_args; - cd_res = may_map (typexp s) c.cd_res; - cd_loc = loc s c.cd_loc; - cd_attributes = attrs s c.cd_attributes; - } +and signature_item = + { sig_desc: signature_item_desc; + sig_env : Env.t; (* BINANNOT ADDED *) + sig_loc: Location.t } -let type_declaration s decl = - let decl = - { type_params = List.map (typexp s) decl.type_params; - type_arity = decl.type_arity; - type_kind = - begin match decl.type_kind with - Type_abstract -> Type_abstract - | Type_variant cstrs -> - Type_variant (List.map (constructor_declaration s) cstrs) - | Type_record(lbls, rep) -> - Type_record (List.map (label_declaration s) lbls, rep) - | Type_open -> Type_open - end; - type_manifest = - begin - match decl.type_manifest with - None -> None - | Some ty -> Some(typexp s ty) - end; - type_private = decl.type_private; - type_variance = decl.type_variance; - type_newtype_level = None; - type_loc = loc s decl.type_loc; - type_attributes = attrs s decl.type_attributes; - type_immediate = decl.type_immediate; - type_unboxed = decl.type_unboxed; - } - in - cleanup_types (); - decl +and signature_item_desc = + Tsig_value of value_description + | Tsig_type of rec_flag * type_declaration list + | Tsig_typext of type_extension + | Tsig_exception of extension_constructor + | Tsig_module of module_declaration + | Tsig_recmodule of module_declaration list + | Tsig_modtype of module_type_declaration + | Tsig_open of open_description + | Tsig_include of include_description + | Tsig_class of class_description list + | Tsig_class_type of class_type_declaration list + | Tsig_attribute of attribute -let class_signature s sign = - { csig_self = typexp s sign.csig_self; - csig_vars = - Vars.map (function (m, v, t) -> (m, v, typexp s t)) sign.csig_vars; - csig_concr = sign.csig_concr; - csig_inher = - List.map (fun (p, tl) -> (type_path s p, List.map (typexp s) tl)) - sign.csig_inher; - } +and module_declaration = + { + md_id: Ident.t; + md_name: string loc; + md_type: module_type; + md_attributes: attributes; + md_loc: Location.t; + } -let rec class_type s = - function - Cty_constr (p, tyl, cty) -> - Cty_constr (type_path s p, List.map (typexp s) tyl, class_type s cty) - | Cty_signature sign -> - Cty_signature (class_signature s sign) - | Cty_arrow (l, ty, cty) -> - Cty_arrow (l, typexp s ty, class_type s cty) +and module_type_declaration = + { + mtd_id: Ident.t; + mtd_name: string loc; + mtd_type: module_type option; + mtd_attributes: attributes; + mtd_loc: Location.t; + } -let class_declaration s decl = - let decl = - { cty_params = List.map (typexp s) decl.cty_params; - cty_variance = decl.cty_variance; - cty_type = class_type s decl.cty_type; - cty_path = type_path s decl.cty_path; - cty_new = - begin match decl.cty_new with - None -> None - | Some ty -> Some (typexp s ty) - end; - cty_loc = loc s decl.cty_loc; - cty_attributes = attrs s decl.cty_attributes; +and open_description = + { + open_path: Path.t; + open_txt: Longident.t loc; + open_override: override_flag; + open_loc: Location.t; + open_attributes: attribute list; } - in - (* Do not clean up if saving: next is cltype_declaration *) - if not s.for_saving then cleanup_types (); - decl -let cltype_declaration s decl = - let decl = - { clty_params = List.map (typexp s) decl.clty_params; - clty_variance = decl.clty_variance; - clty_type = class_type s decl.clty_type; - clty_path = type_path s decl.clty_path; - clty_loc = loc s decl.clty_loc; - clty_attributes = attrs s decl.clty_attributes; +and 'a include_infos = + { + incl_mod: 'a; + incl_type: Types.signature; + incl_loc: Location.t; + incl_attributes: attribute list; } - in - (* Do clean up even if saving: type_declaration may be recursive *) - cleanup_types (); - decl -let class_type s cty = - let cty = class_type s cty in - cleanup_types (); - cty +and include_description = module_type include_infos -let value_description s descr = - { val_type = type_expr s descr.val_type; - val_kind = descr.val_kind; - val_loc = loc s descr.val_loc; - val_attributes = attrs s descr.val_attributes; +and include_declaration = module_expr include_infos + +and with_constraint = + Twith_type of type_declaration + | Twith_module of Path.t * Longident.t loc + | Twith_typesubst of type_declaration + | Twith_modsubst of Path.t * Longident.t loc + +and core_type = + { mutable ctyp_desc : core_type_desc; + (** mutable because of [Typeclass.declare_method] *) + mutable ctyp_type : type_expr; + (** mutable because of [Typeclass.declare_method] *) + ctyp_env : Env.t; (* BINANNOT ADDED *) + ctyp_loc : Location.t; + ctyp_attributes: attributes; } -let extension_constructor s ext = - let ext = - { ext_type_path = type_path s ext.ext_type_path; - ext_type_params = List.map (typexp s) ext.ext_type_params; - ext_args = constructor_arguments s ext.ext_args; - ext_ret_type = may_map (typexp s) ext.ext_ret_type; - ext_private = ext.ext_private; - ext_attributes = attrs s ext.ext_attributes; - ext_loc = if s.for_saving then Location.none else ext.ext_loc; } - in - cleanup_types (); - ext +and core_type_desc = + Ttyp_any + | Ttyp_var of string + | Ttyp_arrow of arg_label * core_type * core_type + | Ttyp_tuple of core_type list + | Ttyp_constr of Path.t * Longident.t loc * core_type list + | Ttyp_object of object_field list * closed_flag + | Ttyp_class of Path.t * Longident.t loc * core_type list + | Ttyp_alias of core_type * string + | Ttyp_variant of row_field list * closed_flag * label list option + | Ttyp_poly of string list * core_type + | Ttyp_package of package_type -let rec rename_bound_idents s idents = function - [] -> (List.rev idents, s) - | Sig_type(id, _, _) :: sg -> - let id' = Ident.rename id in - rename_bound_idents (add_type id (Pident id') s) (id' :: idents) sg - | Sig_module(id, _, _) :: sg -> - let id' = Ident.rename id in - rename_bound_idents (add_module id (Pident id') s) (id' :: idents) sg - | Sig_modtype(id, _) :: sg -> - let id' = Ident.rename id in - rename_bound_idents (add_modtype id (Mty_ident(Pident id')) s) - (id' :: idents) sg - | (Sig_class(id, _, _) | Sig_class_type(id, _, _)) :: sg -> - (* cheat and pretend they are types cf. PR#6650 *) - let id' = Ident.rename id in - rename_bound_idents (add_type id (Pident id') s) (id' :: idents) sg - | (Sig_value(id, _) | Sig_typext(id, _, _)) :: sg -> - let id' = Ident.rename id in - rename_bound_idents s (id' :: idents) sg +and package_type = { + pack_path : Path.t; + pack_fields : (Longident.t loc * core_type) list; + pack_type : Types.module_type; + pack_txt : Longident.t loc; +} -let rec modtype s = function - Mty_ident p as mty -> - begin match p with - Pident id -> - begin try Tbl.find id s.modtypes with Not_found -> mty end - | Pdot(p, n, pos) -> - Mty_ident(Pdot(module_path s p, n, pos)) - | Papply _ -> - fatal_error "Subst.modtype" - end - | Mty_signature sg -> - Mty_signature(signature s sg) - | Mty_functor(id, arg, res) -> - let id' = Ident.rename id in - Mty_functor(id', may_map (modtype s) arg, - modtype (add_module id (Pident id') s) res) - | Mty_alias(pres, p) -> - Mty_alias(pres, module_path s p) +and row_field = + Ttag of string loc * attributes * bool * core_type list + | Tinherit of core_type -and signature s sg = - (* Components of signature may be mutually recursive (e.g. type declarations - or class and type declarations), so first build global renaming - substitution... *) - let (new_idents, s') = rename_bound_idents s [] sg in - (* ... then apply it to each signature component in turn *) - List.map2 (signature_component s') sg new_idents +and object_field = + | OTtag of string loc * attributes * core_type + | OTinherit of core_type + +and value_description = + { val_id: Ident.t; + val_name: string loc; + val_desc: core_type; + val_val: Types.value_description; + val_prim: string list; + val_loc: Location.t; + val_attributes: attributes; + } + +and type_declaration = + { + typ_id: Ident.t; + typ_name: string loc; + typ_params: (core_type * variance) list; + typ_type: Types.type_declaration; + typ_cstrs: (core_type * core_type * Location.t) list; + typ_kind: type_kind; + typ_private: private_flag; + typ_manifest: core_type option; + typ_loc: Location.t; + typ_attributes: attributes; + } + +and type_kind = + Ttype_abstract + | Ttype_variant of constructor_declaration list + | Ttype_record of label_declaration list + | Ttype_open + +and label_declaration = + { + ld_id: Ident.t; + ld_name: string loc; + ld_mutable: mutable_flag; + ld_type: core_type; + ld_loc: Location.t; + ld_attributes: attributes; + } + +and constructor_declaration = + { + cd_id: Ident.t; + cd_name: string loc; + cd_args: constructor_arguments; + cd_res: core_type option; + cd_loc: Location.t; + cd_attributes: attributes; + } -and signature_component s comp newid = - match comp with - Sig_value(_id, d) -> - Sig_value(newid, value_description s d) - | Sig_type(_id, d, rs) -> - Sig_type(newid, type_declaration s d, rs) - | Sig_typext(_id, ext, es) -> - Sig_typext(newid, extension_constructor s ext, es) - | Sig_module(_id, d, rs) -> - Sig_module(newid, module_declaration s d, rs) - | Sig_modtype(_id, d) -> - Sig_modtype(newid, modtype_declaration s d) - | Sig_class(_id, d, rs) -> - Sig_class(newid, class_declaration s d, rs) - | Sig_class_type(_id, d, rs) -> - Sig_class_type(newid, cltype_declaration s d, rs) +and constructor_arguments = + | Cstr_tuple of core_type list + | Cstr_record of label_declaration list -and module_declaration s decl = +and type_extension = { - md_type = modtype s decl.md_type; - md_attributes = attrs s decl.md_attributes; - md_loc = loc s decl.md_loc; + tyext_path: Path.t; + tyext_txt: Longident.t loc; + tyext_params: (core_type * variance) list; + tyext_constructors: extension_constructor list; + tyext_private: private_flag; + tyext_attributes: attributes; } -and modtype_declaration s decl = +and extension_constructor = { - mtd_type = may_map (modtype s) decl.mtd_type; - mtd_attributes = attrs s decl.mtd_attributes; - mtd_loc = loc s decl.mtd_loc; + ext_id: Ident.t; + ext_name: string loc; + ext_type : Types.extension_constructor; + ext_kind : extension_constructor_kind; + ext_loc : Location.t; + ext_attributes: attributes; } -(* For every binding k |-> d of m1, add k |-> f d to m2 - and return resulting merged map. *) - -let merge_tbls f m1 m2 = - Tbl.fold (fun k d accu -> Tbl.add k (f d) accu) m1 m2 +and extension_constructor_kind = + Text_decl of constructor_arguments * core_type option + | Text_rebind of Path.t * Longident.t loc -let merge_path_maps f m1 m2 = - PathMap.fold (fun k d accu -> PathMap.add k (f d) accu) m1 m2 +and class_type = + { + cltyp_desc: class_type_desc; + cltyp_type: Types.class_type; + cltyp_env: Env.t; + cltyp_loc: Location.t; + cltyp_attributes: attributes; + } -let type_replacement s = function - | Path p -> Path (type_path s p) - | Type_function { params; body } -> - let params = List.map (typexp s) params in - let body = typexp s body in - Type_function { params; body } +and class_type_desc = + Tcty_constr of Path.t * Longident.t loc * core_type list + | Tcty_signature of class_signature + | Tcty_arrow of arg_label * core_type * class_type + | Tcty_open of override_flag * Path.t * Longident.t loc * Env.t * class_type -(* Composition of substitutions: - apply (compose s1 s2) x = apply s2 (apply s1 x) *) +and class_signature = { + csig_self : core_type; + csig_fields : class_type_field list; + csig_type : Types.class_signature; + } -let compose s1 s2 = - { types = merge_path_maps (type_replacement s2) s1.types s2.types; - modules = merge_path_maps (module_path s2) s1.modules s2.modules; - modtypes = merge_tbls (modtype s2) s1.modtypes s2.modtypes; - for_saving = s1.for_saving || s2.for_saving; +and class_type_field = { + ctf_desc: class_type_field_desc; + ctf_loc: Location.t; + ctf_attributes: attributes; } -end -module Env : sig -#1 "env.mli" +and class_type_field_desc = + | Tctf_inherit of class_type + | Tctf_val of (string * mutable_flag * virtual_flag * core_type) + | Tctf_method of (string * private_flag * virtual_flag * core_type) + | Tctf_constraint of (core_type * core_type) + | Tctf_attribute of attribute + +and class_declaration = + class_expr class_infos + +and class_description = + class_type class_infos + +and class_type_declaration = + class_type class_infos + +and 'a class_infos = + { ci_virt: virtual_flag; + ci_params: (core_type * variance) list; + ci_id_name : string loc; + ci_id_class: Ident.t; + ci_id_class_type : Ident.t; + ci_id_object : Ident.t; + ci_id_typehash : Ident.t; + ci_expr: 'a; + ci_decl: Types.class_declaration; + ci_type_decl : Types.class_type_declaration; + ci_loc: Location.t; + ci_attributes: attributes; + } + +(* Auxiliary functions over the a.s.t. *) + +val iter_pattern_desc: (pattern -> unit) -> pattern_desc -> unit +val map_pattern_desc: (pattern -> pattern) -> pattern_desc -> pattern_desc + +val let_bound_idents: value_binding list -> Ident.t list +val rev_let_bound_idents: value_binding list -> Ident.t list + +val let_bound_idents_with_loc: + value_binding list -> (Ident.t * string loc) list + +(** Alpha conversion of patterns *) +val alpha_pat: (Ident.t * Ident.t) list -> pattern -> pattern + +val mknoloc: 'a -> 'a Asttypes.loc +val mkloc: 'a -> Location.t -> 'a Asttypes.loc + +val pat_bound_idents: pattern -> Ident.t list + +end = struct +#1 "typedtree.ml" (**************************************************************************) (* *) (* OCaml *) @@ -51977,320 +34924,618 @@ module Env : sig (* *) (**************************************************************************) -(* Environment handling *) +(* Abstract syntax tree after typing *) +open Misc +open Asttypes open Types -module PathMap : Map.S with type key = Path.t - and type 'a t = 'a Map.Make(Path).t +(* Value expressions for the core language *) -type summary = - Env_empty - | Env_value of summary * Ident.t * value_description - | Env_type of summary * Ident.t * type_declaration - | Env_extension of summary * Ident.t * extension_constructor - | Env_module of summary * Ident.t * module_declaration - | Env_modtype of summary * Ident.t * modtype_declaration - | Env_class of summary * Ident.t * class_declaration - | Env_cltype of summary * Ident.t * class_type_declaration - | Env_open of summary * Path.t - | Env_functor_arg of summary * Ident.t - | Env_constraints of summary * type_declaration PathMap.t - | Env_copy_types of summary * string list +type partial = Partial | Total -type t +type attribute = Parsetree.attribute +type attributes = attribute list -val empty: t -val initial_safe_string: t -val initial_unsafe_string: t -val diff: t -> t -> Ident.t list -val copy_local: from:t -> t -> t +type pattern = + { pat_desc: pattern_desc; + pat_loc: Location.t; + pat_extra : (pat_extra * Location.t * attribute list) list; + pat_type: type_expr; + mutable pat_env: Env.t; + pat_attributes: attribute list; + } -type type_descriptions = - constructor_description list * label_description list +and pat_extra = + | Tpat_constraint of core_type + | Tpat_type of Path.t * Longident.t loc + | Tpat_open of Path.t * Longident.t loc * Env.t + | Tpat_unpack -(* For short-paths *) -type iter_cont -val iter_types: - (Path.t -> Path.t * (type_declaration * type_descriptions) -> unit) -> - t -> iter_cont -val run_iter_cont: iter_cont list -> (Path.t * iter_cont) list -val same_types: t -> t -> bool -val used_persistent: unit -> Concr.t -val find_shadowed_types: Path.t -> t -> Path.t list -val without_cmis: ('a -> 'b) -> 'a -> 'b - (* [without_cmis f arg] applies [f] to [arg], but does not - allow opening cmis during its execution *) +and pattern_desc = + Tpat_any + | Tpat_var of Ident.t * string loc + | Tpat_alias of pattern * Ident.t * string loc + | Tpat_constant of constant + | Tpat_tuple of pattern list + | Tpat_construct of + Longident.t loc * constructor_description * pattern list + | Tpat_variant of label * pattern option * row_desc ref + | Tpat_record of + (Longident.t loc * label_description * pattern) list * + closed_flag + | Tpat_array of pattern list + | Tpat_or of pattern * pattern * row_desc option + | Tpat_lazy of pattern -(* Lookup by paths *) +and expression = + { exp_desc: expression_desc; + exp_loc: Location.t; + exp_extra: (exp_extra * Location.t * attribute list) list; + exp_type: type_expr; + exp_env: Env.t; + exp_attributes: attribute list; + } -val find_value: Path.t -> t -> value_description -val find_type: Path.t -> t -> type_declaration -val find_type_descrs: Path.t -> t -> type_descriptions -val find_module: Path.t -> t -> module_declaration -val find_modtype: Path.t -> t -> modtype_declaration -val find_class: Path.t -> t -> class_declaration -val find_cltype: Path.t -> t -> class_type_declaration +and exp_extra = + | Texp_constraint of core_type + | Texp_coerce of core_type option * core_type + | Texp_open of override_flag * Path.t * Longident.t loc * Env.t + | Texp_poly of core_type option + | Texp_newtype of string -val find_type_expansion: - Path.t -> t -> type_expr list * type_expr * int option -val find_type_expansion_opt: - Path.t -> t -> type_expr list * type_expr * int option -(* Find the manifest type information associated to a type for the sake - of the compiler's type-based optimisations. *) -val find_modtype_expansion: Path.t -> t -> module_type -val add_functor_arg: Ident.t -> t -> t -val is_functor_arg: Path.t -> t -> bool -val normalize_path: Location.t option -> t -> Path.t -> Path.t -(* Normalize the path to a concrete value or module. - If the option is None, allow returning dangling paths. - Otherwise raise a Missing_module error, and may add forgotten - head as required global. *) -val normalize_path_prefix: Location.t option -> t -> Path.t -> Path.t -(* Only normalize the prefix part of the path *) -val reset_required_globals: unit -> unit -val get_required_globals: unit -> Ident.t list -val add_required_global: Ident.t -> unit +and expression_desc = + Texp_ident of Path.t * Longident.t loc * Types.value_description + | Texp_constant of constant + | Texp_let of rec_flag * value_binding list * expression + | Texp_function of { arg_label : arg_label; param : Ident.t; + cases : case list; partial : partial; } + | Texp_apply of expression * (arg_label * expression option) list + | Texp_match of expression * case list * case list * partial + | Texp_try of expression * case list + | Texp_tuple of expression list + | Texp_construct of + Longident.t loc * constructor_description * expression list + | Texp_variant of label * expression option + | Texp_record of { + fields : ( Types.label_description * record_label_definition ) array; + representation : Types.record_representation; + extended_expression : expression option; + } + | Texp_field of expression * Longident.t loc * label_description + | Texp_setfield of + expression * Longident.t loc * label_description * expression + | Texp_array of expression list + | Texp_ifthenelse of expression * expression * expression option + | Texp_sequence of expression * expression + | Texp_while of expression * expression + | Texp_for of + Ident.t * Parsetree.pattern * expression * expression * direction_flag * + expression + | Texp_send of expression * meth * expression option + | Texp_new of Path.t * Longident.t loc * Types.class_declaration + | Texp_instvar of Path.t * Path.t * string loc + | Texp_setinstvar of Path.t * Path.t * string loc * expression + | Texp_override of Path.t * (Path.t * string loc * expression) list + | Texp_letmodule of Ident.t * string loc * module_expr * expression + | Texp_letexception of extension_constructor * expression + | Texp_assert of expression + | Texp_lazy of expression + | Texp_object of class_structure * string list + | Texp_pack of module_expr + | Texp_unreachable + | Texp_extension_constructor of Longident.t loc * Path.t -val has_local_constraints: t -> bool -val add_gadt_instance_level: int -> t -> t -val gadt_instance_level: t -> type_expr -> int option -val add_gadt_instances: t -> int -> type_expr list -> unit -val add_gadt_instance_chain: t -> int -> type_expr -> unit +and meth = + Tmeth_name of string + | Tmeth_val of Ident.t -(* Lookup by long identifiers *) +and case = + { + c_lhs: pattern; + c_guard: expression option; + c_rhs: expression; + } -(* ?loc is used to report 'deprecated module' warnings *) +and record_label_definition = + | Kept of Types.type_expr + | Overridden of Longident.t loc * expression -val lookup_value: - ?loc:Location.t -> Longident.t -> t -> Path.t * value_description -val lookup_constructor: - ?loc:Location.t -> Longident.t -> t -> constructor_description -val lookup_all_constructors: - ?loc:Location.t -> - Longident.t -> t -> (constructor_description * (unit -> unit)) list -val lookup_label: - ?loc:Location.t -> Longident.t -> t -> label_description -val lookup_all_labels: - ?loc:Location.t -> - Longident.t -> t -> (label_description * (unit -> unit)) list -val lookup_type: - ?loc:Location.t -> Longident.t -> t -> Path.t - (* Since 4.04, this function no longer returns [type_description]. - To obtain it, you should either call [Env.find_type], or replace - it by [Typetexp.find_type] *) -val lookup_module: - load:bool -> ?loc:Location.t -> Longident.t -> t -> Path.t -val lookup_modtype: - ?loc:Location.t -> Longident.t -> t -> Path.t * modtype_declaration -val lookup_class: - ?loc:Location.t -> Longident.t -> t -> Path.t * class_declaration -val lookup_cltype: - ?loc:Location.t -> Longident.t -> t -> Path.t * class_type_declaration +(* Value expressions for the class language *) + +and class_expr = + { + cl_desc: class_expr_desc; + cl_loc: Location.t; + cl_type: Types.class_type; + cl_env: Env.t; + cl_attributes: attribute list; + } + +and class_expr_desc = + Tcl_ident of Path.t * Longident.t loc * core_type list + | Tcl_structure of class_structure + | Tcl_fun of + arg_label * pattern * (Ident.t * string loc * expression) list + * class_expr * partial + | Tcl_apply of class_expr * (arg_label * expression option) list + | Tcl_let of rec_flag * value_binding list * + (Ident.t * string loc * expression) list * class_expr + | Tcl_constraint of + class_expr * class_type option * string list * string list * Concr.t + (* Visible instance variables, methods and concrete methods *) + | Tcl_open of override_flag * Path.t * Longident.t loc * Env.t * class_expr + +and class_structure = + { + cstr_self: pattern; + cstr_fields: class_field list; + cstr_type: Types.class_signature; + cstr_meths: Ident.t Meths.t; + } + +and class_field = + { + cf_desc: class_field_desc; + cf_loc: Location.t; + cf_attributes: attribute list; + } + +and class_field_kind = + | Tcfk_virtual of core_type + | Tcfk_concrete of override_flag * expression + +and class_field_desc = + Tcf_inherit of + override_flag * class_expr * string option * (string * Ident.t) list * + (string * Ident.t) list + (* Inherited instance variables and concrete methods *) + | Tcf_val of string loc * mutable_flag * Ident.t * class_field_kind * bool + | Tcf_method of string loc * private_flag * class_field_kind + | Tcf_constraint of core_type * core_type + | Tcf_initializer of expression + | Tcf_attribute of attribute + +(* Value expressions for the module language *) + +and module_expr = + { mod_desc: module_expr_desc; + mod_loc: Location.t; + mod_type: Types.module_type; + mod_env: Env.t; + mod_attributes: attribute list; + } + +and module_type_constraint = + Tmodtype_implicit +| Tmodtype_explicit of module_type + +and module_expr_desc = + Tmod_ident of Path.t * Longident.t loc + | Tmod_structure of structure + | Tmod_functor of Ident.t * string loc * module_type option * module_expr + | Tmod_apply of module_expr * module_expr * module_coercion + | Tmod_constraint of + module_expr * Types.module_type * module_type_constraint * module_coercion + | Tmod_unpack of expression * Types.module_type + +and structure = { + str_items : structure_item list; + str_type : Types.signature; + str_final_env : Env.t; +} + +and structure_item = + { str_desc : structure_item_desc; + str_loc : Location.t; + str_env : Env.t + } + +and structure_item_desc = + Tstr_eval of expression * attributes + | Tstr_value of rec_flag * value_binding list + | Tstr_primitive of value_description + | Tstr_type of rec_flag * type_declaration list + | Tstr_typext of type_extension + | Tstr_exception of extension_constructor + | Tstr_module of module_binding + | Tstr_recmodule of module_binding list + | Tstr_modtype of module_type_declaration + | Tstr_open of open_description + | Tstr_class of (class_declaration * string list) list + | Tstr_class_type of (Ident.t * string loc * class_type_declaration) list + | Tstr_include of include_declaration + | Tstr_attribute of attribute + +and module_binding = + { + mb_id: Ident.t; + mb_name: string loc; + mb_expr: module_expr; + mb_attributes: attribute list; + mb_loc: Location.t; + } + +and value_binding = + { + vb_pat: pattern; + vb_expr: expression; + vb_attributes: attributes; + vb_loc: Location.t; + } + +and module_coercion = + Tcoerce_none + | Tcoerce_structure of (int * module_coercion) list * + (Ident.t * int * module_coercion) list * + string list (* runtime fields *) + | Tcoerce_functor of module_coercion * module_coercion + | Tcoerce_primitive of primitive_coercion + | Tcoerce_alias of Path.t * module_coercion + +and module_type = + { mty_desc: module_type_desc; + mty_type : Types.module_type; + mty_env : Env.t; + mty_loc: Location.t; + mty_attributes: attribute list; + } + +and module_type_desc = + Tmty_ident of Path.t * Longident.t loc + | Tmty_signature of signature + | Tmty_functor of Ident.t * string loc * module_type option * module_type + | Tmty_with of module_type * (Path.t * Longident.t loc * with_constraint) list + | Tmty_typeof of module_expr + | Tmty_alias of Path.t * Longident.t loc + +(* Keep primitive type information for type-based lambda-code specialization *) +and primitive_coercion = + { + pc_desc: Primitive.description; + pc_type: type_expr; + pc_env: Env.t; + pc_loc : Location.t; + + pc_id : Ident.t; + + } + +and signature = { + sig_items : signature_item list; + sig_type : Types.signature; + sig_final_env : Env.t; +} + +and signature_item = + { sig_desc: signature_item_desc; + sig_env : Env.t; (* BINANNOT ADDED *) + sig_loc: Location.t } -val copy_types: string list -> t -> t - (* Used only in Typecore.duplicate_ident_types. *) +and signature_item_desc = + Tsig_value of value_description + | Tsig_type of rec_flag * type_declaration list + | Tsig_typext of type_extension + | Tsig_exception of extension_constructor + | Tsig_module of module_declaration + | Tsig_recmodule of module_declaration list + | Tsig_modtype of module_type_declaration + | Tsig_open of open_description + | Tsig_include of include_description + | Tsig_class of class_description list + | Tsig_class_type of class_type_declaration list + | Tsig_attribute of attribute -exception Recmodule - (* Raise by lookup_module when the identifier refers - to one of the modules of a recursive definition - during the computation of its approximation (see #5965). *) +and module_declaration = + { + md_id: Ident.t; + md_name: string loc; + md_type: module_type; + md_attributes: attribute list; + md_loc: Location.t; + } -(* Insertion by identifier *) +and module_type_declaration = + { + mtd_id: Ident.t; + mtd_name: string loc; + mtd_type: module_type option; + mtd_attributes: attribute list; + mtd_loc: Location.t; + } -val add_value: - ?check:(string -> Warnings.t) -> Ident.t -> value_description -> t -> t -val add_type: check:bool -> Ident.t -> type_declaration -> t -> t -val add_extension: check:bool -> Ident.t -> extension_constructor -> t -> t -val add_module: ?arg:bool -> Ident.t -> module_type -> t -> t -val add_module_declaration: ?arg:bool -> check:bool -> Ident.t -> - module_declaration -> t -> t -val add_modtype: Ident.t -> modtype_declaration -> t -> t -val add_class: Ident.t -> class_declaration -> t -> t -val add_cltype: Ident.t -> class_type_declaration -> t -> t -val add_local_constraint: Path.t -> type_declaration -> int -> t -> t -val add_local_type: Path.t -> type_declaration -> t -> t +and open_description = + { + open_path: Path.t; + open_txt: Longident.t loc; + open_override: override_flag; + open_loc: Location.t; + open_attributes: attribute list; + } -(* Insertion of all fields of a signature. *) +and 'a include_infos = + { + incl_mod: 'a; + incl_type: Types.signature; + incl_loc: Location.t; + incl_attributes: attribute list; + } -val add_item: signature_item -> t -> t -val add_signature: signature -> t -> t +and include_description = module_type include_infos -(* Insertion of all fields of a signature, relative to the given path. - Used to implement open. Returns None if the path refers to a functor, - not a structure. *) -val open_signature: - ?used_slot:bool ref -> - ?loc:Location.t -> ?toplevel:bool -> Asttypes.override_flag -> Path.t -> - t -> t option +and include_declaration = module_expr include_infos -val open_pers_signature: string -> t -> t +and with_constraint = + Twith_type of type_declaration + | Twith_module of Path.t * Longident.t loc + | Twith_typesubst of type_declaration + | Twith_modsubst of Path.t * Longident.t loc -(* Insertion by name *) +and core_type = +(* mutable because of [Typeclass.declare_method] *) + { mutable ctyp_desc : core_type_desc; + mutable ctyp_type : type_expr; + ctyp_env : Env.t; (* BINANNOT ADDED *) + ctyp_loc : Location.t; + ctyp_attributes: attribute list; + } -val enter_value: - ?check:(string -> Warnings.t) -> - string -> value_description -> t -> Ident.t * t -val enter_type: string -> type_declaration -> t -> Ident.t * t -val enter_extension: string -> extension_constructor -> t -> Ident.t * t -val enter_module: ?arg:bool -> string -> module_type -> t -> Ident.t * t -val enter_module_declaration: - ?arg:bool -> Ident.t -> module_declaration -> t -> t -val enter_modtype: string -> modtype_declaration -> t -> Ident.t * t -val enter_class: string -> class_declaration -> t -> Ident.t * t -val enter_cltype: string -> class_type_declaration -> t -> Ident.t * t +and core_type_desc = + Ttyp_any + | Ttyp_var of string + | Ttyp_arrow of arg_label * core_type * core_type + | Ttyp_tuple of core_type list + | Ttyp_constr of Path.t * Longident.t loc * core_type list + | Ttyp_object of object_field list * closed_flag + | Ttyp_class of Path.t * Longident.t loc * core_type list + | Ttyp_alias of core_type * string + | Ttyp_variant of row_field list * closed_flag * label list option + | Ttyp_poly of string list * core_type + | Ttyp_package of package_type -(* Initialize the cache of in-core module interfaces. *) -val reset_cache: unit -> unit +and package_type = { + pack_path : Path.t; + pack_fields : (Longident.t loc * core_type) list; + pack_type : Types.module_type; + pack_txt : Longident.t loc; +} -(* To be called before each toplevel phrase. *) -val reset_cache_toplevel: unit -> unit +and row_field = + Ttag of string loc * attributes * bool * core_type list + | Tinherit of core_type -(* Remember the name of the current compilation unit. *) -val set_unit_name: string -> unit -val get_unit_name: unit -> string +and object_field = + | OTtag of string loc * attributes * core_type + | OTinherit of core_type -(* Read, save a signature to/from a file *) +and value_description = + { val_id: Ident.t; + val_name: string loc; + val_desc: core_type; + val_val: Types.value_description; + val_prim: string list; + val_loc: Location.t; + val_attributes: attribute list; + } -val read_signature: string -> string -> signature - (* Arguments: module name, file name. Results: signature. *) -val save_signature: - ?check_exists:unit -> - deprecated:string option -> signature -> string -> string -> Cmi_format.cmi_infos - (* Arguments: signature, module name, file name. *) -val save_signature_with_imports: - ?check_exists:unit -> - deprecated:string option -> - signature -> string -> string -> (string * Digest.t option) list - -> Cmi_format.cmi_infos - (* Arguments: signature, module name, file name, - imported units with their CRCs. *) +and type_declaration = + { typ_id: Ident.t; + typ_name: string loc; + typ_params: (core_type * variance) list; + typ_type: Types.type_declaration; + typ_cstrs: (core_type * core_type * Location.t) list; + typ_kind: type_kind; + typ_private: private_flag; + typ_manifest: core_type option; + typ_loc: Location.t; + typ_attributes: attribute list; + } -(* Return the CRC of the interface of the given compilation unit *) +and type_kind = + Ttype_abstract + | Ttype_variant of constructor_declaration list + | Ttype_record of label_declaration list + | Ttype_open -val crc_of_unit: string -> Digest.t +and label_declaration = + { + ld_id: Ident.t; + ld_name: string loc; + ld_mutable: mutable_flag; + ld_type: core_type; + ld_loc: Location.t; + ld_attributes: attribute list; + } -(* Return the set of compilation units imported, with their CRC *) +and constructor_declaration = + { + cd_id: Ident.t; + cd_name: string loc; + cd_args: constructor_arguments; + cd_res: core_type option; + cd_loc: Location.t; + cd_attributes: attribute list; + } -val imports: unit -> (string * Digest.t option) list +and constructor_arguments = + | Cstr_tuple of core_type list + | Cstr_record of label_declaration list -(* [is_imported_opaque md] returns true if [md] is an opaque imported module *) -val is_imported_opaque: string -> bool +and type_extension = + { + tyext_path: Path.t; + tyext_txt: Longident.t loc; + tyext_params: (core_type * variance) list; + tyext_constructors: extension_constructor list; + tyext_private: private_flag; + tyext_attributes: attribute list; + } -(* Direct access to the table of imported compilation units with their CRC *) +and extension_constructor = + { + ext_id: Ident.t; + ext_name: string loc; + ext_type: Types.extension_constructor; + ext_kind: extension_constructor_kind; + ext_loc: Location.t; + ext_attributes: attribute list; + } -val crc_units: Consistbl.t -val add_import: string -> unit +and extension_constructor_kind = + Text_decl of constructor_arguments * core_type option + | Text_rebind of Path.t * Longident.t loc -(* Summaries -- compact representation of an environment, to be - exported in debugging information. *) +and class_type = + { + cltyp_desc: class_type_desc; + cltyp_type: Types.class_type; + cltyp_env: Env.t; + cltyp_loc: Location.t; + cltyp_attributes: attribute list; + } -val summary: t -> summary +and class_type_desc = + Tcty_constr of Path.t * Longident.t loc * core_type list + | Tcty_signature of class_signature + | Tcty_arrow of arg_label * core_type * class_type + | Tcty_open of override_flag * Path.t * Longident.t loc * Env.t * class_type -(* Return an equivalent environment where all fields have been reset, - except the summary. The initial environment can be rebuilt from the - summary, using Envaux.env_of_only_summary. *) +and class_signature = { + csig_self: core_type; + csig_fields: class_type_field list; + csig_type: Types.class_signature; + } -val keep_only_summary : t -> t -val env_of_only_summary : (summary -> Subst.t -> t) -> t -> t +and class_type_field = { + ctf_desc: class_type_field_desc; + ctf_loc: Location.t; + ctf_attributes: attribute list; + } -(* Error report *) +and class_type_field_desc = + | Tctf_inherit of class_type + | Tctf_val of (string * mutable_flag * virtual_flag * core_type) + | Tctf_method of (string * private_flag * virtual_flag * core_type) + | Tctf_constraint of (core_type * core_type) + | Tctf_attribute of attribute -type error = - | Illegal_renaming of string * string * string - | Inconsistent_import of string * string * string - | Need_recursive_types of string * string - | Depend_on_unsafe_string_unit of string * string - | Missing_module of Location.t * Path.t * Path.t - | Illegal_value_name of Location.t * string +and class_declaration = + class_expr class_infos -exception Error of error +and class_description = + class_type class_infos -open Format +and class_type_declaration = + class_type class_infos -val report_error: formatter -> error -> unit +and 'a class_infos = + { ci_virt: virtual_flag; + ci_params: (core_type * variance) list; + ci_id_name: string loc; + ci_id_class: Ident.t; + ci_id_class_type: Ident.t; + ci_id_object: Ident.t; + ci_id_typehash: Ident.t; + ci_expr: 'a; + ci_decl: Types.class_declaration; + ci_type_decl: Types.class_type_declaration; + ci_loc: Location.t; + ci_attributes: attribute list; + } +(* Auxiliary functions over the a.s.t. *) -val mark_value_used: t -> string -> value_description -> unit -val mark_module_used: t -> string -> Location.t -> unit -val mark_type_used: t -> string -> type_declaration -> unit +let iter_pattern_desc f = function + | Tpat_alias(p, _, _) -> f p + | Tpat_tuple patl -> List.iter f patl + | Tpat_construct(_, _, patl) -> List.iter f patl + | Tpat_variant(_, pat, _) -> may f pat + | Tpat_record (lbl_pat_list, _) -> + List.iter (fun (_, _, pat) -> f pat) lbl_pat_list + | Tpat_array patl -> List.iter f patl + | Tpat_or(p1, p2, _) -> f p1; f p2 + | Tpat_lazy p -> f p + | Tpat_any + | Tpat_var _ + | Tpat_constant _ -> () -type constructor_usage = Positive | Pattern | Privatize -val mark_constructor_used: - constructor_usage -> t -> string -> type_declaration -> string -> unit -val mark_constructor: - constructor_usage -> t -> string -> constructor_description -> unit -val mark_extension_used: - constructor_usage -> t -> extension_constructor -> string -> unit +let map_pattern_desc f d = + match d with + | Tpat_alias (p1, id, s) -> + Tpat_alias (f p1, id, s) + | Tpat_tuple pats -> + Tpat_tuple (List.map f pats) + | Tpat_record (lpats, closed) -> + Tpat_record (List.map (fun (lid, l,p) -> lid, l, f p) lpats, closed) + | Tpat_construct (lid, c,pats) -> + Tpat_construct (lid, c, List.map f pats) + | Tpat_array pats -> + Tpat_array (List.map f pats) + | Tpat_lazy p1 -> Tpat_lazy (f p1) + | Tpat_variant (x1, Some p1, x2) -> + Tpat_variant (x1, Some (f p1), x2) + | Tpat_or (p1,p2,path) -> + Tpat_or (f p1, f p2, path) + | Tpat_var _ + | Tpat_constant _ + | Tpat_any + | Tpat_variant (_,None,_) -> d -val in_signature: bool -> t -> t -val implicit_coercion: t -> t +(* List the identifiers bound by a pattern or a let *) -val is_in_signature: t -> bool +let idents = ref([]: (Ident.t * string loc) list) -val set_value_used_callback: - string -> value_description -> (unit -> unit) -> unit -val set_type_used_callback: - string -> type_declaration -> ((unit -> unit) -> unit) -> unit +let rec bound_idents pat = + match pat.pat_desc with + | Tpat_var (id,s) -> idents := (id,s) :: !idents + | Tpat_alias(p, id, s ) -> + bound_idents p; idents := (id,s) :: !idents + | Tpat_or(p1, _, _) -> + (* Invariant : both arguments binds the same variables *) + bound_idents p1 + | d -> iter_pattern_desc bound_idents d -(* Forward declaration to break mutual recursion with Includemod. *) -val check_modtype_inclusion: - (loc:Location.t -> t -> module_type -> Path.t -> module_type -> unit) ref -(* Forward declaration to break mutual recursion with Typecore. *) -val add_delayed_check_forward: ((unit -> unit) -> unit) ref -(* Forward declaration to break mutual recursion with Mtype. *) -val strengthen: - (aliasable:bool -> t -> module_type -> Path.t -> module_type) ref -(* Forward declaration to break mutual recursion with Ctype. *) -val same_constr: (t -> type_expr -> type_expr -> bool) ref +let pat_bound_idents pat = + idents := []; + bound_idents pat; + let res = !idents in + idents := []; + List.map fst res -(** Folding over all identifiers (for analysis purpose) *) +let rev_let_bound_idents_with_loc bindings = + idents := []; + List.iter (fun vb -> bound_idents vb.vb_pat) bindings; + let res = !idents in idents := []; res -val fold_values: - (string -> Path.t -> value_description -> 'a -> 'a) -> - Longident.t option -> t -> 'a -> 'a -val fold_types: - (string -> Path.t -> type_declaration * type_descriptions -> 'a -> 'a) -> - Longident.t option -> t -> 'a -> 'a -val fold_constructors: - (constructor_description -> 'a -> 'a) -> - Longident.t option -> t -> 'a -> 'a -val fold_labels: - (label_description -> 'a -> 'a) -> - Longident.t option -> t -> 'a -> 'a +let let_bound_idents_with_loc pat_expr_list = + List.rev(rev_let_bound_idents_with_loc pat_expr_list) -(** Persistent structures are only traversed if they are already loaded. *) -val fold_modules: - (string -> Path.t -> module_declaration -> 'a -> 'a) -> - Longident.t option -> t -> 'a -> 'a +let rev_let_bound_idents pat = List.map fst (rev_let_bound_idents_with_loc pat) +let let_bound_idents pat = List.map fst (let_bound_idents_with_loc pat) -val fold_modtypes: - (string -> Path.t -> modtype_declaration -> 'a -> 'a) -> - Longident.t option -> t -> 'a -> 'a -val fold_classs: - (string -> Path.t -> class_declaration -> 'a -> 'a) -> - Longident.t option -> t -> 'a -> 'a -val fold_cltypes: - (string -> Path.t -> class_type_declaration -> 'a -> 'a) -> - Longident.t option -> t -> 'a -> 'a +let alpha_var env id = List.assoc id env -(** Utilities *) -val scrape_alias: t -> module_type -> module_type -val check_value_name: string -> Location.t -> unit +let rec alpha_pat env p = match p.pat_desc with +| Tpat_var (id, s) -> (* note the ``Not_found'' case *) + {p with pat_desc = + try Tpat_var (alpha_var env id, s) with + | Not_found -> Tpat_any} +| Tpat_alias (p1, id, s) -> + let new_p = alpha_pat env p1 in + begin try + {p with pat_desc = Tpat_alias (new_p, alpha_var env id, s)} + with + | Not_found -> new_p + end +| d -> + {p with pat_desc = map_pattern_desc (alpha_pat env) d} -module Persistent_signature : sig - type t = - { filename : string; (** Name of the file containing the signature. *) - cmi : Cmi_format.cmi_infos } +let mkloc = Location.mkloc +let mknoloc = Location.mknoloc - (** Function used to load a persistent signature. The default is to look for - the .cmi file in the load path. This function can be overridden to load - it from memory, for instance to build a self-contained toplevel. *) - val load : (unit_name:string -> t option) ref end - -end = struct -#1 "env.ml" +module Lambda : sig +#1 "lambda.mli" (**************************************************************************) (* *) (* OCaml *) @@ -52306,3722 +35551,18364 @@ end = struct (* *) (**************************************************************************) -(* Environment handling *) +(* The "lambda" intermediate code *) -open Cmi_format -open Config -open Misc open Asttypes -open Longident -open Path -open Types -open Btype -let add_delayed_check_forward = ref (fun _ -> assert false) - -let value_declarations : ((string * Location.t), (unit -> unit)) Hashtbl.t = - Hashtbl.create 16 - (* This table is used to usage of value declarations. A declaration is - identified with its name and location. The callback attached to a - declaration is called whenever the value is used explicitly - (lookup_value) or implicitly (inclusion test between signatures, - cf Includemod.value_descriptions). *) - -let type_declarations = Hashtbl.create 16 -let module_declarations = Hashtbl.create 16 - -type constructor_usage = Positive | Pattern | Privatize -type constructor_usages = - { - mutable cu_positive: bool; - mutable cu_pattern: bool; - mutable cu_privatize: bool; - } -let add_constructor_usage cu = function - | Positive -> cu.cu_positive <- true - | Pattern -> cu.cu_pattern <- true - | Privatize -> cu.cu_privatize <- true -let constructor_usages () = - {cu_positive = false; cu_pattern = false; cu_privatize = false} - -let used_constructors : - (string * Location.t * string, (constructor_usage -> unit)) Hashtbl.t - = Hashtbl.create 16 - -let prefixed_sg = Hashtbl.create 113 - -type error = - | Illegal_renaming of string * string * string - | Inconsistent_import of string * string * string - | Need_recursive_types of string * string - | Depend_on_unsafe_string_unit of string * string - | Missing_module of Location.t * Path.t * Path.t - | Illegal_value_name of Location.t * string - -exception Error of error - -let error err = raise (Error err) - -module EnvLazy : sig - type ('a,'b) t - - type log - - val force : ('a -> 'b) -> ('a,'b) t -> 'b - val create : 'a -> ('a,'b) t - val get_arg : ('a,'b) t -> 'a option - - (* [force_logged log f t] is equivalent to [force f t] but if [f] returns [None] then - [t] is recorded in [log]. [backtrack log] will then reset all the recorded [t]s back - to their original state. *) - val log : unit -> log - val force_logged : log -> ('a -> 'b option) -> ('a,'b option) t -> 'b option - val backtrack : log -> unit - -end = struct +type compile_time_constant = + | Big_endian + | Word_size + | Int_size + | Max_wosize + | Ostype_unix + | Ostype_win32 + | Ostype_cygwin + | Backend_type - type ('a,'b) t = ('a,'b) eval ref +type loc_kind = + | Loc_FILE + | Loc_LINE + | Loc_MODULE + | Loc_LOC + | Loc_POS - and ('a,'b) eval = - | Done of 'b - | Raise of exn - | Thunk of 'a +type tag_info = + | Blk_constructor of string * int (* Number of non-const constructors*) + | Blk_tuple + | Blk_array + | Blk_variant of string + | Blk_record of string array + | Blk_module of string list + | Blk_module_export of Ident.t list + | Blk_extension_slot + | Blk_extension + (* underlying is the same as tuple, immutable block + {[ + exception A of int * int + ]} + is translated into + {[ + [A, x, y] + ]} - type undo = - | Nil - | Cons : ('a, 'b) t * 'a * undo -> undo + *) + | Blk_na of string (* This string only for debugging*) + | Blk_some + | Blk_some_not_nested (* ['a option] where ['a] can not inhabit a non-like value *) + | Blk_record_inlined of string array * string * int + | Blk_record_ext of string array + | Blk_lazy_general + | Blk_lazy_forward + | Blk_class (* ocaml style class *) - type log = undo ref +val blk_record : + ( + (Types.label_description* Typedtree.record_label_definition) array -> + tag_info + ) ref + +val blk_record_ext : + ( + (Types.label_description* Typedtree.record_label_definition) array -> + tag_info + ) ref + +val blk_record_inlined : + ( + (Types.label_description* Typedtree.record_label_definition) array -> + string -> + int -> + tag_info + ) ref - let force f x = - match !x with - | Done x -> x - | Raise e -> raise e - | Thunk e -> - match f e with - | y -> - x := Done y; - y - | exception e -> - x := Raise e; - raise e +val default_tag_info : tag_info - let get_arg x = - match !x with Thunk a -> Some a | _ -> None +val ref_tag_info : tag_info - let create x = - ref (Thunk x) +type field_dbg_info = + | Fld_na + | Fld_record of {name : string; mutable_flag : Asttypes.mutable_flag} + | Fld_module of string + | Fld_record_inline of string + | Fld_record_extension of string + | Fld_tuple - let log () = - ref Nil +val fld_record : + (Types.label_description -> + field_dbg_info) ref - let force_logged log f x = - match !x with - | Done x -> x - | Raise e -> raise e - | Thunk e -> - match f e with - | None -> - x := Done None; - log := Cons(x, e, !log); - None - | Some _ as y -> - x := Done y; - y - | exception e -> - x := Raise e; - raise e +val ref_field_info : field_dbg_info - let backtrack log = - let rec loop = function - | Nil -> () - | Cons(x, e, rest) -> - x := Thunk e; - loop rest - in - loop !log +type set_field_dbg_info = + | Fld_set_na + | Fld_record_set of string + | Fld_record_inline_set of string + | Fld_record_extension_set of string -end +val ref_field_set_info : set_field_dbg_info -module PathMap = Map.Make(Path) +val fld_record_set : + (Types.label_description -> + set_field_dbg_info) ref -type summary = - Env_empty - | Env_value of summary * Ident.t * value_description - | Env_type of summary * Ident.t * type_declaration - | Env_extension of summary * Ident.t * extension_constructor - | Env_module of summary * Ident.t * module_declaration - | Env_modtype of summary * Ident.t * modtype_declaration - | Env_class of summary * Ident.t * class_declaration - | Env_cltype of summary * Ident.t * class_type_declaration - | Env_open of summary * Path.t - | Env_functor_arg of summary * Ident.t - | Env_constraints of summary * type_declaration PathMap.t - | Env_copy_types of summary * string list +type immediate_or_pointer = + | Immediate + | Pointer -module TycompTbl = - struct - (** This module is used to store components of types (i.e. labels - and constructors). We keep a representation of each nested - "open" and the set of local bindings between each of them. *) +type initialization_or_assignment = + | Assignment + (* Initialization of in heap values, like [caml_initialize] C primitive. The + field should not have been read before and initialization should happen + only once. *) + | Heap_initialization + (* Initialization of roots only. Compiles to a simple store. + No checks are done to preserve GC invariants. *) + | Root_initialization - type 'a t = { - current: 'a Ident.tbl; - (** Local bindings since the last open. *) +type is_safe = + | Safe + | Unsafe - opened: 'a opened option; - (** Symbolic representation of the last (innermost) open, if any. *) - } +type pointer_info = + | Pt_constructor of string + | Pt_variant of string + | Pt_module_alias + | Pt_builtin_boolean + | Pt_shape_none + | Pt_na - and 'a opened = { - components: (string, 'a list) Tbl.t; - (** Components from the opened module. We keep a list of - bindings for each name, as in comp_labels and - comp_constrs. *) +val default_pointer_info : pointer_info - using: (string -> ('a * 'a) option -> unit) option; - (** A callback to be applied when a component is used from this - "open". This is used to detect unused "opens". The - arguments are used to detect shadowing. *) +type primitive = + | Pidentity + | Pbytes_to_string + | Pbytes_of_string + | Pignore + | Prevapply + | Pdirapply + | Ploc of loc_kind + (* Globals *) + | Pgetglobal of Ident.t + | Psetglobal of Ident.t + (* Operations on heap blocks *) + | Pmakeblock of int * tag_info * mutable_flag * block_shape + | Pfield of int * field_dbg_info + | Pfield_computed + | Psetfield of int * immediate_or_pointer * initialization_or_assignment * set_field_dbg_info + | Psetfield_computed of immediate_or_pointer * initialization_or_assignment + | Pfloatfield of int * field_dbg_info + | Psetfloatfield of int * initialization_or_assignment * set_field_dbg_info + | Pduprecord of Types.record_representation * int + (* Force lazy values *) + | Plazyforce + (* External call *) + | Pccall of Primitive.description + (* Exceptions *) + | Praise of raise_kind + (* Boolean operations *) + | Psequand | Psequor | Pnot + (* Integer operations *) + | Pnegint | Paddint | Psubint | Pmulint + | Pdivint of is_safe | Pmodint of is_safe + | Pandint | Porint | Pxorint + | Plslint | Plsrint | Pasrint + | Pintcomp of comparison + | Poffsetint of int + | Poffsetref of int + (* Float operations *) + | Pintoffloat | Pfloatofint + | Pnegfloat | Pabsfloat + | Paddfloat | Psubfloat | Pmulfloat | Pdivfloat + | Pfloatcomp of comparison + (* String operations *) + | Pstringlength | Pstringrefu | Pstringrefs + | Pbyteslength | Pbytesrefu | Pbytessetu | Pbytesrefs | Pbytessets + (* Array operations *) + | Pmakearray of array_kind * mutable_flag + | Pduparray of array_kind * mutable_flag + (** For [Pduparray], the argument must be an immutable array. + The arguments of [Pduparray] give the kind and mutability of the + array being *produced* by the duplication. *) + | Parraylength of array_kind + | Parrayrefu of array_kind + | Parraysetu of array_kind + | Parrayrefs of array_kind + | Parraysets of array_kind + (* Test if the argument is a block or an immediate integer *) + | Pisint + (* Test if the (integer) argument is outside an interval *) + | Pisout + (* Bitvect operations *) + | Pbittest + (* Operations on boxed integers (Nativeint.t, Int32.t, Int64.t) *) + | Pbintofint of boxed_integer + | Pintofbint of boxed_integer + | Pcvtbint of boxed_integer (*source*) * boxed_integer (*destination*) + | Pnegbint of boxed_integer + | Paddbint of boxed_integer + | Psubbint of boxed_integer + | Pmulbint of boxed_integer + | Pdivbint of { size : boxed_integer; is_safe : is_safe } + | Pmodbint of { size : boxed_integer; is_safe : is_safe } + | Pandbint of boxed_integer + | Porbint of boxed_integer + | Pxorbint of boxed_integer + | Plslbint of boxed_integer + | Plsrbint of boxed_integer + | Pasrbint of boxed_integer + | Pbintcomp of boxed_integer * comparison + (* Operations on big arrays: (unsafe, #dimensions, kind, layout) *) + | Pbigarrayref of bool * int * bigarray_kind * bigarray_layout + | Pbigarrayset of bool * int * bigarray_kind * bigarray_layout + (* size of the nth dimension of a big array *) + | Pbigarraydim of int + (* load/set 16,32,64 bits from a string: (unsafe)*) + | Pstring_load_16 of bool + | Pstring_load_32 of bool + | Pstring_load_64 of bool + | Pstring_set_16 of bool + | Pstring_set_32 of bool + | Pstring_set_64 of bool + (* load/set 16,32,64 bits from a + (char, int8_unsigned_elt, c_layout) Bigarray.Array1.t : (unsafe) *) + | Pbigstring_load_16 of bool + | Pbigstring_load_32 of bool + | Pbigstring_load_64 of bool + | Pbigstring_set_16 of bool + | Pbigstring_set_32 of bool + | Pbigstring_set_64 of bool + (* Compile time constants *) + | Pctconst of compile_time_constant + (* byte swap *) + | Pbswap16 + | Pbbswap of boxed_integer + (* Integer to external pointer *) + | Pint_as_pointer + (* Inhibition of optimisation *) + | Popaque - next: 'a t; - (** The table before opening the module. *) - } +and comparison = + Ceq | Cneq | Clt | Cgt | Cle | Cge - let empty = { current = Ident.empty; opened = None } +and array_kind = + Pgenarray | Paddrarray | Pintarray | Pfloatarray - let add id x tbl = - {tbl with current = Ident.add id x tbl.current} +and value_kind = + Pgenval | Pfloatval | Pboxedintval of boxed_integer | Pintval - let add_open slot wrap components next = - let using = - match slot with - | None -> None - | Some f -> Some (fun s x -> f s (wrap x)) - in - { - current = Ident.empty; - opened = Some {using; components; next}; - } +and block_shape = + value_kind list option - let rec find_same id tbl = - try Ident.find_same id tbl.current - with Not_found as exn -> - begin match tbl.opened with - | Some {next; _} -> find_same id next - | None -> raise exn - end +and boxed_integer = Primitive.boxed_integer = + Pnativeint | Pint32 | Pint64 - let nothing = fun () -> () +and bigarray_kind = + Pbigarray_unknown + | Pbigarray_float32 | Pbigarray_float64 + | Pbigarray_sint8 | Pbigarray_uint8 + | Pbigarray_sint16 | Pbigarray_uint16 + | Pbigarray_int32 | Pbigarray_int64 + | Pbigarray_caml_int | Pbigarray_native_int + | Pbigarray_complex32 | Pbigarray_complex64 - let mk_callback rest name desc = function - | None -> nothing - | Some f -> - (fun () -> - match rest with - | [] -> f name None - | (hidden, _) :: _ -> f name (Some (desc, hidden)) - ) +and bigarray_layout = + Pbigarray_unknown_layout + | Pbigarray_c_layout + | Pbigarray_fortran_layout - let rec find_all name tbl = - List.map (fun (_id, desc) -> desc, nothing) - (Ident.find_all name tbl.current) @ - match tbl.opened with - | None -> [] - | Some {using; next; components} -> - let rest = find_all name next in - match Tbl.find_str name components with - | exception Not_found -> rest - | opened -> - List.map - (fun desc -> desc, mk_callback rest name desc using) - opened - @ rest +and raise_kind = + | Raise_regular + | Raise_reraise + | Raise_notrace - let rec fold_name f tbl acc = - let acc = Ident.fold_name (fun _id d -> f d) tbl.current acc in - match tbl.opened with - | Some {using = _; next; components} -> - acc - |> Tbl.fold - (fun _name -> List.fold_right (fun desc -> f desc)) - components - |> fold_name f next - | None -> - acc +type structured_constant = + Const_base of constant + | Const_pointer of int * pointer_info + | Const_block of int * tag_info * structured_constant list + | Const_float_array of string list + | Const_immstring of string - let rec local_keys tbl acc = - let acc = Ident.fold_all (fun k _ accu -> k::accu) tbl.current acc in - match tbl.opened with - | Some o -> local_keys o.next acc - | None -> acc +type inline_attribute = + | Always_inline (* [@inline] or [@inline always] *) + | Never_inline (* [@inline never] *) + | Unroll of int (* [@unroll x] *) + | Default_inline (* no [@inline] attribute *) - let diff_keys is_local tbl1 tbl2 = - let keys2 = local_keys tbl2 [] in - List.filter - (fun id -> - is_local (find_same id tbl2) && - try ignore (find_same id tbl1); false - with Not_found -> true) - keys2 +type specialise_attribute = + | Always_specialise (* [@specialise] or [@specialise always] *) + | Never_specialise (* [@specialise never] *) + | Default_specialise (* no [@specialise] attribute *) - end +type function_kind = Curried | Tupled +type let_kind = Strict | Alias | StrictOpt | Variable +(* Meaning of kinds for let x = e in e': + Strict: e may have side-effects; always evaluate e first + (If e is a simple expression, e.g. a variable or constant, + we may still substitute e'[x/e].) + Alias: e is pure, we can substitute e'[x/e] if x has 0 or 1 occurrences + in e' + StrictOpt: e does not have side-effects, but depend on the store; + we can discard e if x does not appear in e' + Variable: the variable x is assigned later in e' + *) -module IdTbl = - struct - (** This module is used to store all kinds of components except - (labels and constructors) in environments. We keep a - representation of each nested "open" and the set of local - bindings between each of them. *) +type public_info = string option (* label name *) +type meth_kind = Self | Public of public_info | Cached - type 'a t = { - current: 'a Ident.tbl; - (** Local bindings since the last open *) +type shared_code = (int * int) list (* stack size -> code label *) - opened: 'a opened option; - (** Symbolic representation of the last (innermost) open, if any. *) - } +type function_attribute = { + inline : inline_attribute; + specialise : specialise_attribute; + is_a_functor: bool; + stub: bool; +} - and 'a opened = { - root: Path.t; - (** The path of the opened module, to be prefixed in front of - its local names to produce a valid path in the current - environment. *) +type switch_names = {consts: string array; blocks: string array} - components: (string, 'a * int) Tbl.t; - (** Components from the opened module. *) +type lambda = + Lvar of Ident.t + | Lconst of structured_constant + | Lapply of lambda_apply + | Lfunction of lfunction + | Llet of let_kind * value_kind * Ident.t * lambda * lambda + | Lletrec of (Ident.t * lambda) list * lambda + | Lprim of primitive * lambda list * Location.t + | Lswitch of lambda * lambda_switch * Location.t +(* switch on strings, clauses are sorted by string order, + strings are pairwise distinct *) + | Lstringswitch of + lambda * (string * lambda) list * lambda option * Location.t + | Lstaticraise of int * lambda list + | Lstaticcatch of lambda * (int * Ident.t list) * lambda + | Ltrywith of lambda * Ident.t * lambda + | Lifthenelse of lambda * lambda * lambda + | Lsequence of lambda * lambda + | Lwhile of lambda * lambda + | Lfor of Ident.t * lambda * lambda * direction_flag * lambda + | Lassign of Ident.t * lambda + | Lsend of meth_kind * lambda * lambda * lambda list * Location.t + | Levent of lambda * lambda_event + | Lifused of Ident.t * lambda - using: (string -> ('a * 'a) option -> unit) option; - (** A callback to be applied when a component is used from this - "open". This is used to detect unused "opens". The - arguments are used to detect shadowing. *) +and lfunction = + { kind: function_kind; + params: Ident.t list; + body: lambda; + attr: function_attribute; (* specified with [@inline] attribute *) + loc : Location.t; } - next: 'a t; - (** The table before opening the module. *) - } +and lambda_apply = + { ap_func : lambda; + ap_args : lambda list; + ap_loc : Location.t; + ap_should_be_tailcall : bool; (* true if [@tailcall] was specified *) + ap_inlined : inline_attribute; (* specified with the [@inlined] attribute *) + ap_specialised : specialise_attribute; } - let empty = { current = Ident.empty; opened = None } +and lambda_switch = + { sw_numconsts: int; (* Number of integer cases *) + sw_consts: (int * lambda) list; (* Integer cases *) + sw_numblocks: int; (* Number of tag block cases *) + sw_blocks: (int * lambda) list; (* Tag block cases *) + sw_failaction : lambda option; (* Action to take if failure *) + sw_names: switch_names option } +and lambda_event = + { lev_loc: Location.t; + lev_kind: lambda_event_kind; + lev_repr: int ref option; + lev_env: Env.summary } - let add id x tbl = - {tbl with current = Ident.add id x tbl.current} +and lambda_event_kind = + Lev_before + | Lev_after of Types.type_expr + | Lev_function + | Lev_pseudo + | Lev_module_definition of Ident.t - let add_open slot wrap root components next = - let using = - match slot with - | None -> None - | Some f -> Some (fun s x -> f s (wrap x)) - in - { - current = Ident.empty; - opened = Some {using; root; components; next}; - } +type program = + { module_ident : Ident.t; + main_module_block_size : int; + required_globals : Ident.Set.t; (* Modules whose initializer side effects + must occur before [code]. *) + code : lambda } +(* Lambda code for the middle-end. + * In the closure case the code is a sequence of assignments to a + preallocated block of size [main_module_block_size] using + (Setfield(Getglobal(module_ident))). The size is used to preallocate + the block. + * In the flambda case the code is an expression returning a block + value of size [main_module_block_size]. The size is used to build + the module root as an initialize_symbol + Initialize_symbol(module_name, 0, + [getfield 0; ...; getfield (main_module_block_size - 1)]) +*) - let rec find_same id tbl = - try Ident.find_same id tbl.current - with Not_found as exn -> - begin match tbl.opened with - | Some {next; _} -> find_same id next - | None -> raise exn - end +(* Sharing key *) +val make_key: lambda -> lambda option - let rec find_name mark name tbl = - try - let (id, desc) = Ident.find_name name tbl.current in - Pident id, desc - with Not_found as exn -> - begin match tbl.opened with - | Some {using; root; next; components} -> - begin try - let (descr, pos) = Tbl.find_str name components in - let res = Pdot (root, name, pos), descr in - if mark then begin match using with - | None -> () - | Some f -> - begin try f name (Some (snd (find_name false name next), snd res)) - with Not_found -> f name None - end - end; - res - with Not_found -> - find_name mark name next - end - | None -> - raise exn - end +val const_unit: structured_constant +val lambda_assert_false: lambda +val lambda_unit: lambda +val name_lambda: let_kind -> lambda -> (Ident.t -> lambda) -> lambda +val name_lambda_list: lambda list -> (lambda list -> lambda) -> lambda - let find_name name tbl = find_name true name tbl +val iter: (lambda -> unit) -> lambda -> unit +module IdentSet: Set.S with type elt = Ident.t +val free_variables: lambda -> IdentSet.t +val free_methods: lambda -> IdentSet.t - let rec update name f tbl = - try - let (id, desc) = Ident.find_name name tbl.current in - let new_desc = f desc in - {tbl with current = Ident.add id new_desc tbl.current} - with Not_found -> - begin match tbl.opened with - | Some {root; using; next; components} -> - begin try - let (desc, pos) = Tbl.find_str name components in - let new_desc = f desc in - let components = Tbl.add name (new_desc, pos) components in - {tbl with opened = Some {root; using; next; components}} - with Not_found -> - let next = update name f next in - {tbl with opened = Some {root; using; next; components}} - end - | None -> - tbl - end +val transl_normal_path: Path.t -> lambda (* Path.t is already normal *) +val transl_path: ?loc:Location.t -> Env.t -> Path.t -> lambda +[@@ocaml.deprecated "use transl_{module,value,extension,class}_path instead"] +val transl_module_path: ?loc:Location.t -> Env.t -> Path.t -> lambda +val transl_value_path: ?loc:Location.t -> Env.t -> Path.t -> lambda +val transl_extension_path: ?loc:Location.t -> Env.t -> Path.t -> lambda +val transl_class_path: ?loc:Location.t -> Env.t -> Path.t -> lambda +val make_sequence: ('a -> lambda) -> 'a list -> lambda - let rec find_all name tbl = - List.map (fun (id, desc) -> Pident id, desc) (Ident.find_all name tbl.current) @ - match tbl.opened with - | None -> [] - | Some {root; using = _; next; components} -> - try - let (desc, pos) = Tbl.find_str name components in - (Pdot (root, name, pos), desc) :: find_all name next - with Not_found -> - find_all name next +val subst_lambda: lambda Ident.tbl -> lambda -> lambda +val map : (lambda -> lambda) -> lambda -> lambda +val bind : let_kind -> Ident.t -> lambda -> lambda -> lambda - let rec fold_name f tbl acc = - let acc = Ident.fold_name (fun id d -> f (Ident.name id) (Pident id, d)) tbl.current acc in - match tbl.opened with - | Some {root; using = _; next; components} -> - acc - |> Tbl.fold - (fun name (desc, pos) -> f name (Pdot (root, name, pos), desc)) - components - |> fold_name f next - | None -> - acc +val commute_comparison : comparison -> comparison +val negate_comparison : comparison -> comparison - let rec local_keys tbl acc = - let acc = Ident.fold_all (fun k _ accu -> k::accu) tbl.current acc in - match tbl.opened with - | Some o -> local_keys o.next acc - | None -> acc +val default_function_attribute : function_attribute +val default_stub_attribute : function_attribute +(***********************) +(* For static failures *) +(***********************) - let rec iter f tbl = - Ident.iter (fun id desc -> f id (Pident id, desc)) tbl.current; - match tbl.opened with - | Some {root; using = _; next; components} -> - Tbl.iter - (fun s (x, pos) -> f (Ident.hide (Ident.create s) (* ??? *)) (Pdot (root, s, pos), x)) - components; - iter f next - | None -> () +(* Get a new static failure ident *) +val next_raise_count : unit -> int +val next_negative_raise_count : unit -> int + (* Negative raise counts are used to compile 'match ... with + exception x -> ...'. This disabled some simplifications + performed by the Simplif module that assume that static raises + are in tail position in their handler. *) - let diff_keys tbl1 tbl2 = - let keys2 = local_keys tbl2 [] in - List.filter - (fun id -> - try ignore (find_same id tbl1); false - with Not_found -> true) - keys2 +val staticfail : lambda (* Anticipated static failure *) +(* Check anticipated failure, substitute its final value *) +val is_guarded: lambda -> bool +val patch_guarded : lambda -> lambda -> lambda - end +val raise_kind: raise_kind -> string +val lam_of_loc : loc_kind -> Location.t -> lambda -type type_descriptions = - constructor_description list * label_description list +val merge_inline_attributes + : inline_attribute + -> inline_attribute + -> inline_attribute option -let in_signature_flag = 0x01 -let implicit_coercion_flag = 0x02 +val reset: unit -> unit -type t = { - values: value_description IdTbl.t; - constrs: constructor_description TycompTbl.t; - labels: label_description TycompTbl.t; - types: (type_declaration * type_descriptions) IdTbl.t; - modules: (Subst.t * module_declaration, module_declaration) EnvLazy.t IdTbl.t; - modtypes: modtype_declaration IdTbl.t; - components: module_components IdTbl.t; - classes: class_declaration IdTbl.t; - cltypes: class_type_declaration IdTbl.t; - functor_args: unit Ident.tbl; - summary: summary; - local_constraints: type_declaration PathMap.t; - gadt_instances: (int * TypeSet.t ref) list; - flags: int; -} +end = struct +#1 "lambda.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -and module_components = - { - deprecated: string option; - loc: Location.t; - comps: - (t * Subst.t * Path.t * Types.module_type, module_components_repr option) - EnvLazy.t; - } +open Misc +open Path +open Asttypes -and module_components_repr = - Structure_comps of structure_components - | Functor_comps of functor_components +type compile_time_constant = + | Big_endian + | Word_size + | Int_size + | Max_wosize + | Ostype_unix + | Ostype_win32 + | Ostype_cygwin + | Backend_type -and 'a comp_tbl = (string, ('a * int)) Tbl.t +type loc_kind = + | Loc_FILE + | Loc_LINE + | Loc_MODULE + | Loc_LOC + | Loc_POS -and structure_components = { - mutable comp_values: value_description comp_tbl; - mutable comp_constrs: (string, constructor_description list) Tbl.t; - mutable comp_labels: (string, label_description list) Tbl.t; - mutable comp_types: (type_declaration * type_descriptions) comp_tbl; - mutable comp_modules: - (Subst.t * module_declaration, module_declaration) EnvLazy.t comp_tbl; - mutable comp_modtypes: modtype_declaration comp_tbl; - mutable comp_components: module_components comp_tbl; - mutable comp_classes: class_declaration comp_tbl; - mutable comp_cltypes: class_type_declaration comp_tbl; -} +type tag_info = + | Blk_constructor of string * int (* Number of non-const constructors*) + | Blk_tuple + | Blk_array + | Blk_variant of string + | Blk_record of string array (* when its empty means we dont get such information *) + | Blk_module of string list + | Blk_module_export of Ident.t list + | Blk_extension_slot + | Blk_extension + | Blk_na of string + | Blk_some + | Blk_some_not_nested (* ['a option] where ['a] can not inhabit a non-like value *) + | Blk_record_inlined of string array * string * int + | Blk_record_ext of string array + | Blk_lazy_general + | Blk_lazy_forward + | Blk_class (* Ocaml style class*) -and functor_components = { - fcomp_param: Ident.t; (* Formal parameter *) - fcomp_arg: module_type option; (* Argument signature *) - fcomp_res: module_type; (* Result signature *) - fcomp_cache: (Path.t, module_components) Hashtbl.t; (* For memoization *) - fcomp_subst_cache: (Path.t, module_type) Hashtbl.t -} +let default_tag_info : tag_info = Blk_na "" +let blk_record = ref (fun fields -> + let all_labels_info = fields |> Array.map (fun (x,_) -> x.Types.lbl_name) in + Blk_record all_labels_info + ) -let copy_local ~from env = - { env with - local_constraints = from.local_constraints; - gadt_instances = from.gadt_instances; - flags = from.flags } +let blk_record_ext = ref (fun fields -> + let all_labels_info = fields |> Array.map (fun (x,_) -> x.Types.lbl_name) in + Blk_record_ext all_labels_info + ) -let same_constr = ref (fun _ _ _ -> assert false) +let blk_record_inlined = ref (fun fields name num_nonconsts -> + let all_labels_info = fields |> Array.map (fun (x,_) -> x.Types.lbl_name) in + Blk_record_inlined (all_labels_info, name, num_nonconsts) +) -(* Helper to decide whether to report an identifier shadowing - by some 'open'. For labels and constructors, we do not report - if the two elements are from the same re-exported declaration. +let ref_tag_info : tag_info = Blk_record [| "contents" |] + +type field_dbg_info = + | Fld_na + | Fld_record of {name : string; mutable_flag : Asttypes.mutable_flag} + | Fld_module of string + | Fld_record_inline of string + | Fld_record_extension of string + | Fld_tuple - Later, one could also interpret some attributes on value and - type declarations to silence the shadowing warnings. *) +let fld_record = ref (fun (lbl : Types.label_description) -> + Fld_record {name = lbl.lbl_name; mutable_flag = Mutable}) -let check_shadowing env = function - | `Constructor (Some (c1, c2)) - when not (!same_constr env c1.cstr_res c2.cstr_res) -> - Some "constructor" - | `Label (Some (l1, l2)) - when not (!same_constr env l1.lbl_res l2.lbl_res) -> - Some "label" - | `Value (Some _) -> Some "value" - | `Type (Some _) -> Some "type" - | `Module (Some _) | `Component (Some _) -> Some "module" - | `Module_type (Some _) -> Some "module type" - | `Class (Some _) -> Some "class" - | `Class_type (Some _) -> Some "class type" - | `Constructor _ | `Label _ - | `Value None | `Type None | `Module None | `Module_type None - | `Class None | `Class_type None | `Component None -> - None +let ref_field_info : field_dbg_info = + Fld_record { name = "contents"; mutable_flag = Mutable} -let subst_modtype_maker (subst, md) = - if subst == Subst.identity then md - else {md with md_type = Subst.modtype subst md.md_type} +type set_field_dbg_info = + | Fld_set_na + | Fld_record_set of string + | Fld_record_inline_set of string + | Fld_record_extension_set of string -let empty = { - values = IdTbl.empty; constrs = TycompTbl.empty; - labels = TycompTbl.empty; types = IdTbl.empty; - modules = IdTbl.empty; modtypes = IdTbl.empty; - components = IdTbl.empty; classes = IdTbl.empty; - cltypes = IdTbl.empty; - summary = Env_empty; local_constraints = PathMap.empty; gadt_instances = []; - flags = 0; - functor_args = Ident.empty; - } +let ref_field_set_info : set_field_dbg_info = Fld_record_set "contents" +let fld_record_set = ref ( fun (lbl : Types.label_description) -> + Fld_record_set lbl.lbl_name ) -let in_signature b env = - let flags = - if b then env.flags lor in_signature_flag - else env.flags land (lnot in_signature_flag) - in - {env with flags} +type immediate_or_pointer = + | Immediate + | Pointer -let implicit_coercion env = - {env with flags = env.flags lor implicit_coercion_flag} +type initialization_or_assignment = + | Assignment + | Heap_initialization + | Root_initialization -let is_in_signature env = env.flags land in_signature_flag <> 0 -let is_implicit_coercion env = env.flags land implicit_coercion_flag <> 0 +type is_safe = + | Safe + | Unsafe -let is_ident = function - Pident _ -> true - | Pdot _ | Papply _ -> false +type primitive = + | Pidentity + | Pbytes_to_string + | Pbytes_of_string + | Pignore + | Prevapply + | Pdirapply + | Ploc of loc_kind + (* Globals *) + | Pgetglobal of Ident.t + | Psetglobal of Ident.t + (* Operations on heap blocks *) + | Pmakeblock of int * tag_info * mutable_flag * block_shape + | Pfield of int * field_dbg_info + | Pfield_computed + | Psetfield of int * immediate_or_pointer * initialization_or_assignment * set_field_dbg_info + | Psetfield_computed of immediate_or_pointer * initialization_or_assignment + | Pfloatfield of int * field_dbg_info + | Psetfloatfield of int * initialization_or_assignment * set_field_dbg_info + | Pduprecord of Types.record_representation * int + (* Force lazy values *) + | Plazyforce + (* External call *) + | Pccall of Primitive.description + (* Exceptions *) + | Praise of raise_kind + (* Boolean operations *) + | Psequand | Psequor | Pnot + (* Integer operations *) + | Pnegint | Paddint | Psubint | Pmulint + | Pdivint of is_safe | Pmodint of is_safe + | Pandint | Porint | Pxorint + | Plslint | Plsrint | Pasrint + | Pintcomp of comparison + | Poffsetint of int + | Poffsetref of int + (* Float operations *) + | Pintoffloat | Pfloatofint + | Pnegfloat | Pabsfloat + | Paddfloat | Psubfloat | Pmulfloat | Pdivfloat + | Pfloatcomp of comparison + (* String operations *) + | Pstringlength | Pstringrefu | Pstringrefs + | Pbyteslength | Pbytesrefu | Pbytessetu | Pbytesrefs | Pbytessets + (* Array operations *) + | Pmakearray of array_kind * mutable_flag + | Pduparray of array_kind * mutable_flag + | Parraylength of array_kind + | Parrayrefu of array_kind + | Parraysetu of array_kind + | Parrayrefs of array_kind + | Parraysets of array_kind + (* Test if the argument is a block or an immediate integer *) + | Pisint + (* Test if the (integer) argument is outside an interval *) + | Pisout + (* Bitvect operations *) + | Pbittest + (* Operations on boxed integers (Nativeint.t, Int32.t, Int64.t) *) + | Pbintofint of boxed_integer + | Pintofbint of boxed_integer + | Pcvtbint of boxed_integer (*source*) * boxed_integer (*destination*) + | Pnegbint of boxed_integer + | Paddbint of boxed_integer + | Psubbint of boxed_integer + | Pmulbint of boxed_integer + | Pdivbint of { size : boxed_integer; is_safe : is_safe } + | Pmodbint of { size : boxed_integer; is_safe : is_safe } + | Pandbint of boxed_integer + | Porbint of boxed_integer + | Pxorbint of boxed_integer + | Plslbint of boxed_integer + | Plsrbint of boxed_integer + | Pasrbint of boxed_integer + | Pbintcomp of boxed_integer * comparison + (* Operations on big arrays: (unsafe, #dimensions, kind, layout) *) + | Pbigarrayref of bool * int * bigarray_kind * bigarray_layout + | Pbigarrayset of bool * int * bigarray_kind * bigarray_layout + (* size of the nth dimension of a big array *) + | Pbigarraydim of int + (* load/set 16,32,64 bits from a string: (unsafe)*) + | Pstring_load_16 of bool + | Pstring_load_32 of bool + | Pstring_load_64 of bool + | Pstring_set_16 of bool + | Pstring_set_32 of bool + | Pstring_set_64 of bool + (* load/set 16,32,64 bits from a + (char, int8_unsigned_elt, c_layout) Bigarray.Array1.t : (unsafe) *) + | Pbigstring_load_16 of bool + | Pbigstring_load_32 of bool + | Pbigstring_load_64 of bool + | Pbigstring_set_16 of bool + | Pbigstring_set_32 of bool + | Pbigstring_set_64 of bool + (* Compile time constants *) + | Pctconst of compile_time_constant + (* byte swap *) + | Pbswap16 + | Pbbswap of boxed_integer + (* Integer to external pointer *) + | Pint_as_pointer + (* Inhibition of optimisation *) + | Popaque -let is_local_ext = function - | {cstr_tag = Cstr_extension(p, _)} -> is_ident p - | _ -> false +and comparison = + Ceq | Cneq | Clt | Cgt | Cle | Cge -let diff env1 env2 = - IdTbl.diff_keys env1.values env2.values @ - TycompTbl.diff_keys is_local_ext env1.constrs env2.constrs @ - IdTbl.diff_keys env1.modules env2.modules @ - IdTbl.diff_keys env1.classes env2.classes +and value_kind = + Pgenval | Pfloatval | Pboxedintval of boxed_integer | Pintval -type can_load_cmis = - | Can_load_cmis - | Cannot_load_cmis of EnvLazy.log +and block_shape = + value_kind list option -let can_load_cmis = ref Can_load_cmis +and array_kind = + Pgenarray | Paddrarray | Pintarray | Pfloatarray -let without_cmis f x = - let log = EnvLazy.log () in - let res = - Misc.(protect_refs - [R (can_load_cmis, Cannot_load_cmis log)] - (fun () -> f x)) - in - EnvLazy.backtrack log; - res +and boxed_integer = Primitive.boxed_integer = + Pnativeint | Pint32 | Pint64 -(* Forward declarations *) +and bigarray_kind = + Pbigarray_unknown + | Pbigarray_float32 | Pbigarray_float64 + | Pbigarray_sint8 | Pbigarray_uint8 + | Pbigarray_sint16 | Pbigarray_uint16 + | Pbigarray_int32 | Pbigarray_int64 + | Pbigarray_caml_int | Pbigarray_native_int + | Pbigarray_complex32 | Pbigarray_complex64 -let components_of_module' = - ref ((fun ~deprecated:_ ~loc:_ _env _sub _path _mty -> assert false) : - deprecated:string option -> loc:Location.t -> t -> Subst.t -> - Path.t -> module_type -> - module_components) -let components_of_module_maker' = - ref ((fun (_env, _sub, _path, _mty) -> assert false) : - t * Subst.t * Path.t * module_type -> module_components_repr option) -let components_of_functor_appl' = - ref ((fun _f _env _p1 _p2 -> assert false) : - functor_components -> t -> Path.t -> Path.t -> module_components) -let check_modtype_inclusion = - (* to be filled with Includemod.check_modtype_inclusion *) - ref ((fun ~loc:_ _env _mty1 _path1 _mty2 -> assert false) : - loc:Location.t -> t -> module_type -> Path.t -> module_type -> unit) -let strengthen = - (* to be filled with Mtype.strengthen *) - ref ((fun ~aliasable:_ _env _mty _path -> assert false) : - aliasable:bool -> t -> module_type -> Path.t -> module_type) +and bigarray_layout = + Pbigarray_unknown_layout + | Pbigarray_c_layout + | Pbigarray_fortran_layout + +and raise_kind = + | Raise_regular + | Raise_reraise + | Raise_notrace + +type pointer_info = + | Pt_constructor of string + | Pt_variant of string + | Pt_module_alias + | Pt_builtin_boolean + | Pt_shape_none + | Pt_na -let md md_type = - {md_type; md_attributes=[]; md_loc=Location.none} +let default_pointer_info = Pt_na + +type structured_constant = + Const_base of constant + | Const_pointer of int * pointer_info + | Const_block of int * tag_info * structured_constant list + | Const_float_array of string list + | Const_immstring of string -let get_components_opt c = - match !can_load_cmis with - | Can_load_cmis -> - EnvLazy.force !components_of_module_maker' c.comps - | Cannot_load_cmis log -> - EnvLazy.force_logged log !components_of_module_maker' c.comps -let empty_structure = - Structure_comps { - comp_values = Tbl.empty; - comp_constrs = Tbl.empty; - comp_labels = Tbl.empty; - comp_types = Tbl.empty; - comp_modules = Tbl.empty; comp_modtypes = Tbl.empty; - comp_components = Tbl.empty; comp_classes = Tbl.empty; - comp_cltypes = Tbl.empty } +type inline_attribute = + | Always_inline (* [@inline] or [@inline always] *) + | Never_inline (* [@inline never] *) + | Unroll of int (* [@unroll x] *) + | Default_inline (* no [@inline] attribute *) -let get_components c = - match get_components_opt c with - | None -> empty_structure - | Some c -> c +type specialise_attribute = + | Always_specialise (* [@specialise] or [@specialise always] *) + | Never_specialise (* [@specialise never] *) + | Default_specialise (* no [@specialise] attribute *) -(* The name of the compilation unit currently compiled. - "" if outside a compilation unit. *) +type function_kind = Curried | Tupled -let current_unit = ref "" +type let_kind = Strict | Alias | StrictOpt | Variable -(* Persistent structure descriptions *) +type public_info = string option (* label name *) -type pers_struct = - { ps_name: string; - ps_sig: signature Lazy.t; - ps_comps: module_components; - ps_crcs: (string * Digest.t option) list; - ps_filename: string; - ps_flags: pers_flags list } +type meth_kind = Self | Public of public_info | Cached -let persistent_structures = - (Hashtbl.create 17 : (string, pers_struct option) Hashtbl.t) +type shared_code = (int * int) list -(* Consistency between persistent structures *) +type function_attribute = { + inline : inline_attribute; + specialise : specialise_attribute; + is_a_functor: bool; + stub: bool; +} +type switch_names = {consts: string array; blocks: string array} -let crc_units = Consistbl.create() +type lambda = + Lvar of Ident.t + | Lconst of structured_constant + | Lapply of lambda_apply + | Lfunction of lfunction + | Llet of let_kind * value_kind * Ident.t * lambda * lambda + | Lletrec of (Ident.t * lambda) list * lambda + | Lprim of primitive * lambda list * Location.t + | Lswitch of lambda * lambda_switch * Location.t + | Lstringswitch of + lambda * (string * lambda) list * lambda option * Location.t + | Lstaticraise of int * lambda list + | Lstaticcatch of lambda * (int * Ident.t list) * lambda + | Ltrywith of lambda * Ident.t * lambda + | Lifthenelse of lambda * lambda * lambda + | Lsequence of lambda * lambda + | Lwhile of lambda * lambda + | Lfor of Ident.t * lambda * lambda * direction_flag * lambda + | Lassign of Ident.t * lambda + | Lsend of meth_kind * lambda * lambda * lambda list * Location.t + | Levent of lambda * lambda_event + | Lifused of Ident.t * lambda -module StringSet = - Set.Make(struct type t = string let compare = String.compare end) +and lfunction = + { kind: function_kind; + params: Ident.t list; + body: lambda; + attr: function_attribute; (* specified with [@inline] attribute *) + loc: Location.t; } -let imported_units = ref StringSet.empty +and lambda_apply = + { ap_func : lambda; + ap_args : lambda list; + ap_loc : Location.t; + ap_should_be_tailcall : bool; + ap_inlined : inline_attribute; + ap_specialised : specialise_attribute; } -let add_import s = - imported_units := StringSet.add s !imported_units +and lambda_switch = + { sw_numconsts: int; + sw_consts: (int * lambda) list; + sw_numblocks: int; + sw_blocks: (int * lambda) list; + sw_failaction : lambda option; + sw_names: switch_names option } -let imported_opaque_units = ref StringSet.empty +and lambda_event = + { lev_loc: Location.t; + lev_kind: lambda_event_kind; + lev_repr: int ref option; + lev_env: Env.summary } -let add_imported_opaque s = - imported_opaque_units := StringSet.add s !imported_opaque_units +and lambda_event_kind = + Lev_before + | Lev_after of Types.type_expr + | Lev_function + | Lev_pseudo + | Lev_module_definition of Ident.t -let clear_imports () = - Consistbl.clear crc_units; - imported_units := StringSet.empty; - imported_opaque_units := StringSet.empty +type program = + { module_ident : Ident.t; + main_module_block_size : int; + required_globals : Ident.Set.t; + code : lambda } -let check_consistency ps = - try - List.iter - (fun (name, crco) -> - match crco with - None -> () - | Some crc -> - add_import name; - Consistbl.check crc_units name crc ps.ps_filename) - ps.ps_crcs; - with Consistbl.Inconsistency(name, source, auth) -> - error (Inconsistent_import(name, auth, source)) +let const_unit = Const_pointer(0, default_pointer_info) -(* Reading persistent structures from .cmi files *) +let lambda_assert_false = Lconst (Const_pointer(0, Pt_constructor "assert false")) -let save_pers_struct crc ps = - let modname = ps.ps_name in - Hashtbl.add persistent_structures modname (Some ps); - List.iter - (function - | Rectypes -> () - | Deprecated _ -> () - | Unsafe_string -> () - | Opaque -> add_imported_opaque modname) - ps.ps_flags; - Consistbl.set crc_units modname crc ps.ps_filename; - add_import modname -module Persistent_signature = struct - type t = - { filename : string; - cmi : Cmi_format.cmi_infos } +let lambda_unit = Lconst const_unit - let load = ref (fun ~unit_name -> - match find_in_path_uncap !load_path (unit_name ^ ".cmi") with - | filename -> Some { filename; cmi = read_cmi filename } - | exception Not_found -> None) -end +let default_function_attribute = { + inline = Default_inline; + specialise = Default_specialise; + is_a_functor = false; + stub = false; +} -let acknowledge_pers_struct check modname - { Persistent_signature.filename; cmi } = - let name = cmi.cmi_name in - let sign = cmi.cmi_sign in - let crcs = cmi.cmi_crcs in - let flags = cmi.cmi_flags in - let deprecated = - List.fold_left (fun acc -> function Deprecated s -> Some s | _ -> acc) None - flags - in - let comps = - !components_of_module' ~deprecated ~loc:Location.none - empty Subst.identity - (Pident(Ident.create_persistent name)) - (Mty_signature sign) - in - let ps = { ps_name = name; - ps_sig = lazy (Subst.signature Subst.identity sign); - ps_comps = comps; - ps_crcs = crcs; - ps_filename = filename; - ps_flags = flags; - } in - if ps.ps_name <> modname then - error (Illegal_renaming(modname, ps.ps_name, filename)); +let default_stub_attribute = + { default_function_attribute with stub = true } - List.iter - (function - | Rectypes -> - if not !Clflags.recursive_types then - error (Need_recursive_types(ps.ps_name, !current_unit)) - | Unsafe_string -> - if Config.safe_string then - error (Depend_on_unsafe_string_unit (ps.ps_name, !current_unit)); - | Deprecated _ -> () - | Opaque -> add_imported_opaque modname) - ps.ps_flags; - if check then check_consistency ps; - Hashtbl.add persistent_structures modname (Some ps); - ps +(* Build sharing keys *) +(* + Those keys are later compared with Pervasives.compare. + For that reason, they should not include cycles. +*) -let read_pers_struct check modname filename = - add_import modname; - let cmi = read_cmi filename in - acknowledge_pers_struct check modname - { Persistent_signature.filename; cmi } +exception Not_simple -let find_pers_struct check name = - if name = "*predef*" then raise Not_found; - match Hashtbl.find persistent_structures name with - | Some ps -> ps - | None -> raise Not_found - | exception Not_found -> - match !can_load_cmis with - | Cannot_load_cmis _ -> raise Not_found - | Can_load_cmis -> - let ps = - match !Persistent_signature.load ~unit_name:name with - | Some ps -> ps - | None -> - Hashtbl.add persistent_structures name None; - raise Not_found - in - add_import name; - acknowledge_pers_struct check name ps +let max_raw = 32 -(* Emits a warning if there is no valid cmi for name *) -let check_pers_struct name = - try - ignore (find_pers_struct false name) - with - | Not_found -> - let warn = Warnings.No_cmi_file(name, None) in - Location.prerr_warning Location.none warn - | Cmi_format.Error err -> - let msg = Format.asprintf "%a" Cmi_format.report_error err in - let warn = Warnings.No_cmi_file(name, Some msg) in - Location.prerr_warning Location.none warn - | Error err -> - let msg = - match err with - | Illegal_renaming(name, ps_name, filename) -> - Format.asprintf - " %a@ contains the compiled interface for @ \ - %s when %s was expected" - Location.print_filename filename ps_name name - | Inconsistent_import _ -> assert false - | Need_recursive_types(name, _) -> - Format.sprintf - "%s uses recursive types" - name - | Depend_on_unsafe_string_unit (name, _) -> - Printf.sprintf "%s uses -unsafe-string" - name - | Missing_module _ -> assert false - | Illegal_value_name _ -> assert false - in - let warn = Warnings.No_cmi_file(name, Some msg) in - Location.prerr_warning Location.none warn +let make_key e = + let count = ref 0 (* Used for controling size *) + and make_key = Ident.make_key_generator () in + (* make_key is used for normalizing let-bound variables *) + let rec tr_rec env e = + incr count ; + if !count > max_raw then raise Not_simple ; (* Too big ! *) + match e with + | Lvar id -> + begin + try Ident.find_same id env + with Not_found -> e + end + | Lconst (Const_base (Const_string _)) -> + (* Mutable constants are not shared *) + raise Not_simple + | Lconst _ -> e + | Lapply ap -> + Lapply {ap with ap_func = tr_rec env ap.ap_func; + ap_args = tr_recs env ap.ap_args; + ap_loc = Location.none} + | Llet (Alias,_k,x,ex,e) -> (* Ignore aliases -> substitute *) + let ex = tr_rec env ex in + tr_rec (Ident.add x ex env) e + | Llet ((Strict | StrictOpt),_k,x,ex,Lvar v) when Ident.same v x -> + tr_rec env ex + | Llet (str,k,x,ex,e) -> + (* Because of side effects, keep other lets with normalized names *) + let ex = tr_rec env ex in + let y = make_key x in + Llet (str,k,y,ex,tr_rec (Ident.add x (Lvar y) env) e) + | Lprim (p,es,_) -> + Lprim (p,tr_recs env es, Location.none) + | Lswitch (e,sw,loc) -> + Lswitch (tr_rec env e,tr_sw env sw,loc) + | Lstringswitch (e,sw,d,_) -> + Lstringswitch + (tr_rec env e, + List.map (fun (s,e) -> s,tr_rec env e) sw, + tr_opt env d, + Location.none) + | Lstaticraise (i,es) -> + Lstaticraise (i,tr_recs env es) + | Lstaticcatch (e1,xs,e2) -> + Lstaticcatch (tr_rec env e1,xs,tr_rec env e2) + | Ltrywith (e1,x,e2) -> + Ltrywith (tr_rec env e1,x,tr_rec env e2) + | Lifthenelse (cond,ifso,ifnot) -> + Lifthenelse (tr_rec env cond,tr_rec env ifso,tr_rec env ifnot) + | Lsequence (e1,e2) -> + Lsequence (tr_rec env e1,tr_rec env e2) + | Lassign (x,e) -> + Lassign (x,tr_rec env e) + | Lsend (m,e1,e2,es,_loc) -> + Lsend (m,tr_rec env e1,tr_rec env e2,tr_recs env es,Location.none) + | Lifused (id,e) -> Lifused (id,tr_rec env e) + | Lletrec _|Lfunction _ + | Lfor _ | Lwhile _ +(* Beware: (PR#6412) the event argument to Levent + may include cyclic structure of type Type.typexpr *) + | Levent _ -> + raise Not_simple -let read_pers_struct modname filename = - read_pers_struct true modname filename + and tr_recs env es = List.map (tr_rec env) es -let find_pers_struct name = - find_pers_struct true name + and tr_sw env sw = + { sw with + sw_consts = List.map (fun (i,e) -> i,tr_rec env e) sw.sw_consts ; + sw_blocks = List.map (fun (i,e) -> i,tr_rec env e) sw.sw_blocks ; + sw_failaction = tr_opt env sw.sw_failaction ; } -let check_pers_struct name = - if not (Hashtbl.mem persistent_structures name) then begin - (* PR#6843: record the weak dependency ([add_import]) regardless of - whether the check succeeds, to help make builds more - deterministic. *) - add_import name; - if (Warnings.is_active (Warnings.No_cmi_file("", None))) then - !add_delayed_check_forward - (fun () -> check_pers_struct name) - end + and tr_opt env = function + | None -> None + | Some e -> Some (tr_rec env e) in -let reset_cache () = - current_unit := ""; - Hashtbl.clear persistent_structures; - clear_imports (); - Hashtbl.clear value_declarations; - Hashtbl.clear type_declarations; - Hashtbl.clear module_declarations; - Hashtbl.clear used_constructors; - Hashtbl.clear prefixed_sg + try + Some (tr_rec Ident.empty e) + with Not_simple -> None -let reset_cache_toplevel () = - (* Delete 'missing cmi' entries from the cache. *) - let l = - Hashtbl.fold - (fun name r acc -> if r = None then name :: acc else acc) - persistent_structures [] - in - List.iter (Hashtbl.remove persistent_structures) l; - Hashtbl.clear value_declarations; - Hashtbl.clear type_declarations; - Hashtbl.clear module_declarations; - Hashtbl.clear used_constructors; - Hashtbl.clear prefixed_sg +(***************) +let name_lambda strict arg fn = + match arg with + Lvar id -> fn id + | _ -> let id = Ident.create "let" in Llet(strict, Pgenval, id, arg, fn id) -let set_unit_name name = - current_unit := name +let name_lambda_list args fn = + let rec name_list names = function + [] -> fn (List.rev names) + | (Lvar _ as arg) :: rem -> + name_list (arg :: names) rem + | arg :: rem -> + let id = Ident.create "let" in + Llet(Strict, Pgenval, id, arg, name_list (Lvar id :: names) rem) in + name_list [] args -let get_unit_name () = - !current_unit -(* Lookup by identifier *) +let iter_opt f = function + | None -> () + | Some e -> f e -let rec find_module_descr path env = - match path with - Pident id -> - begin try - IdTbl.find_same id env.components - with Not_found -> - if Ident.persistent id && not (Ident.name id = !current_unit) - then (find_pers_struct (Ident.name id)).ps_comps - else raise Not_found - end - | Pdot(p, s, _pos) -> - begin match get_components (find_module_descr p env) with - Structure_comps c -> - let (descr, _pos) = Tbl.find_str s c.comp_components in - descr - | Functor_comps _ -> - raise Not_found - end - | Papply(p1, p2) -> - begin match get_components (find_module_descr p1 env) with - Functor_comps f -> - !components_of_functor_appl' f env p1 p2 - | Structure_comps _ -> - raise Not_found - end +let iter f = function + Lvar _ + | Lconst _ -> () + | Lapply{ap_func = fn; ap_args = args} -> + f fn; List.iter f args + | Lfunction{body} -> + f body + | Llet(_str, _k, _id, arg, body) -> + f arg; f body + | Lletrec(decl, body) -> + f body; + List.iter (fun (_id, exp) -> f exp) decl + | Lprim(_p, args, _loc) -> + List.iter f args + | Lswitch(arg, sw,_) -> + f arg; + List.iter (fun (_key, case) -> f case) sw.sw_consts; + List.iter (fun (_key, case) -> f case) sw.sw_blocks; + iter_opt f sw.sw_failaction + | Lstringswitch (arg,cases,default,_) -> + f arg ; + List.iter (fun (_,act) -> f act) cases ; + iter_opt f default + | Lstaticraise (_,args) -> + List.iter f args + | Lstaticcatch(e1, _, e2) -> + f e1; f e2 + | Ltrywith(e1, _, e2) -> + f e1; f e2 + | Lifthenelse(e1, e2, e3) -> + f e1; f e2; f e3 + | Lsequence(e1, e2) -> + f e1; f e2 + | Lwhile(e1, e2) -> + f e1; f e2 + | Lfor(_v, e1, e2, _dir, e3) -> + f e1; f e2; f e3 + | Lassign(_, e) -> + f e + | Lsend (_k, met, obj, args, _) -> + List.iter f (met::obj::args) + | Levent (lam, _evt) -> + f lam + | Lifused (_v, e) -> + f e + + +module IdentSet = Set.Make(Ident) + +let free_ids get l = + let fv = ref IdentSet.empty in + let rec free l = + iter free l; + fv := List.fold_right IdentSet.add (get l) !fv; + match l with + Lfunction{params} -> + List.iter (fun param -> fv := IdentSet.remove param !fv) params + | Llet(_str, _k, id, _arg, _body) -> + fv := IdentSet.remove id !fv + | Lletrec(decl, _body) -> + List.iter (fun (id, _exp) -> fv := IdentSet.remove id !fv) decl + | Lstaticcatch(_e1, (_,vars), _e2) -> + List.iter (fun id -> fv := IdentSet.remove id !fv) vars + | Ltrywith(_e1, exn, _e2) -> + fv := IdentSet.remove exn !fv + | Lfor(v, _e1, _e2, _dir, _e3) -> + fv := IdentSet.remove v !fv + | Lassign(id, _e) -> + fv := IdentSet.add id !fv + | Lvar _ | Lconst _ | Lapply _ + | Lprim _ | Lswitch _ | Lstringswitch _ | Lstaticraise _ + | Lifthenelse _ | Lsequence _ | Lwhile _ + | Lsend _ | Levent _ | Lifused _ -> () + in free l; !fv -let find proj1 proj2 path env = - match path with - Pident id -> - IdTbl.find_same id (proj1 env) - | Pdot(p, s, _pos) -> - begin match get_components (find_module_descr p env) with - Structure_comps c -> - let (data, _pos) = Tbl.find_str s (proj2 c) in data - | Functor_comps _ -> - raise Not_found - end - | Papply _ -> - raise Not_found +let free_variables l = + free_ids (function Lvar id -> [id] | _ -> []) l -let find_value = - find (fun env -> env.values) (fun sc -> sc.comp_values) -and find_type_full = - find (fun env -> env.types) (fun sc -> sc.comp_types) -and find_modtype = - find (fun env -> env.modtypes) (fun sc -> sc.comp_modtypes) -and find_class = - find (fun env -> env.classes) (fun sc -> sc.comp_classes) -and find_cltype = - find (fun env -> env.cltypes) (fun sc -> sc.comp_cltypes) +let free_methods l = + free_ids (function Lsend(Self, Lvar meth, _, _, _) -> [meth] | _ -> []) l -let type_of_cstr path = function - | {cstr_inlined = Some d; _} -> - (d, ([], List.map snd (Datarepr.labels_of_type path d))) - | _ -> - assert false +(* Check if an action has a "when" guard *) +let raise_count = ref 0 -let find_type_full path env = - match Path.constructor_typath path with - | Regular p -> - (try (PathMap.find p env.local_constraints, ([], [])) - with Not_found -> find_type_full p env) - | Cstr (ty_path, s) -> - let (_, (cstrs, _)) = - try find_type_full ty_path env - with Not_found -> assert false - in - let cstr = - try List.find (fun cstr -> cstr.cstr_name = s) cstrs - with Not_found -> assert false - in - type_of_cstr path cstr - | LocalExt id -> - let cstr = - try TycompTbl.find_same id env.constrs - with Not_found -> assert false - in - type_of_cstr path cstr - | Ext (mod_path, s) -> - let comps = - try find_module_descr mod_path env - with Not_found -> assert false - in - let comps = - match get_components comps with - | Structure_comps c -> c - | Functor_comps _ -> assert false - in - let exts = - List.filter - (function {cstr_tag=Cstr_extension _} -> true | _ -> false) - (try Tbl.find_str s comps.comp_constrs - with Not_found -> assert false) - in - match exts with - | [cstr] -> type_of_cstr path cstr - | _ -> assert false +let next_raise_count () = + incr raise_count ; + !raise_count -let find_type p env = - fst (find_type_full p env) -let find_type_descrs p env = - snd (find_type_full p env) +let negative_raise_count = ref 0 -let find_module ~alias path env = - match path with - Pident id -> - begin try - let data = IdTbl.find_same id env.modules in - EnvLazy.force subst_modtype_maker data - with Not_found -> - if Ident.persistent id && not (Ident.name id = !current_unit) then - let ps = find_pers_struct (Ident.name id) in - md (Mty_signature(Lazy.force ps.ps_sig)) - else raise Not_found - end - | Pdot(p, s, _pos) -> - begin match get_components (find_module_descr p env) with - Structure_comps c -> - let (data, _pos) = Tbl.find_str s c.comp_modules in - EnvLazy.force subst_modtype_maker data - | Functor_comps _ -> - raise Not_found - end - | Papply(p1, p2) -> - let desc1 = find_module_descr p1 env in - begin match get_components desc1 with - Functor_comps f -> - md begin match f.fcomp_res with - | Mty_alias _ as mty -> mty - | mty -> - if alias then mty else - try - Hashtbl.find f.fcomp_subst_cache p2 - with Not_found -> - let mty = - Subst.modtype - (Subst.add_module f.fcomp_param p2 Subst.identity) - f.fcomp_res in - Hashtbl.add f.fcomp_subst_cache p2 mty; - mty - end - | Structure_comps _ -> - raise Not_found - end +let next_negative_raise_count () = + decr negative_raise_count ; + !negative_raise_count -let required_globals = ref [] -let reset_required_globals () = required_globals := [] -let get_required_globals () = !required_globals -let add_required_global id = - if Ident.global id && not !Clflags.transparent_modules - && not (List.exists (Ident.same id) !required_globals) - then required_globals := id :: !required_globals +(* Anticipated staticraise, for guards *) +let staticfail = Lstaticraise (0,[]) -let rec normalize_path lax env path = - let path = - match path with - Pdot(p, s, pos) -> - Pdot(normalize_path lax env p, s, pos) - | Papply(p1, p2) -> - Papply(normalize_path lax env p1, normalize_path true env p2) - | _ -> path - in - try match find_module ~alias:true path env with - {md_type=Mty_alias(_, path1)} -> - let path' = normalize_path lax env path1 in - if lax || !Clflags.transparent_modules then path' else - let id = Path.head path in - if Ident.global id && not (Ident.same id (Path.head path')) - then add_required_global id; - path' - | _ -> path - with Not_found when lax - || (match path with Pident id -> not (Ident.persistent id) | _ -> true) -> - path +let rec is_guarded = function + | Lifthenelse(_cond, _body, Lstaticraise (0,[])) -> true + | Llet(_str, _k, _id, _lam, body) -> is_guarded body + | Levent(lam, _ev) -> is_guarded lam + | _ -> false -let normalize_path oloc env path = - try normalize_path (oloc = None) env path - with Not_found -> - match oloc with None -> assert false - | Some loc -> - raise (Error(Missing_module(loc, path, normalize_path true env path))) +let rec patch_guarded patch = function + | Lifthenelse (cond, body, Lstaticraise (0,[])) -> + Lifthenelse (cond, body, patch) + | Llet(str, k, id, lam, body) -> + Llet (str, k, id, lam, patch_guarded patch body) + | Levent(lam, ev) -> + Levent (patch_guarded patch lam, ev) + | _ -> fatal_error "Lambda.patch_guarded" -let normalize_path_prefix oloc env path = - match path with - Pdot(p, s, pos) -> - Pdot(normalize_path oloc env p, s, pos) - | Pident _ -> - path +(* Translate an access path *) + +let rec transl_normal_path = function + Pident id -> + if Ident.global id + then Lprim(Pgetglobal id, [], Location.none) + else Lvar id + | Pdot(p, s, pos) -> + Lprim(Pfield (pos, Fld_module s), [transl_normal_path p], Location.none) | Papply _ -> - assert false + fatal_error "Lambda.transl_path" +(* Translation of identifiers *) -let find_module = find_module ~alias:false +let transl_module_path ?(loc=Location.none) env path = + transl_normal_path (Env.normalize_path (Some loc) env path) -(* Find the manifest type associated to a type when appropriate: - - the type should be public or should have a private row, - - the type should have an associated manifest type. *) -let find_type_expansion path env = - let decl = find_type path env in - match decl.type_manifest with - | Some body when decl.type_private = Public - || decl.type_kind <> Type_abstract - || Btype.has_constr_row body -> - (decl.type_params, body, may_map snd decl.type_newtype_level) - (* The manifest type of Private abstract data types without - private row are still considered unknown to the type system. - Hence, this case is caught by the following clause that also handles - purely abstract data types without manifest type definition. *) - | _ -> raise Not_found +let transl_value_path ?(loc=Location.none) env path = + transl_normal_path (Env.normalize_path_prefix (Some loc) env path) -(* Find the manifest type information associated to a type, i.e. - the necessary information for the compiler's type-based optimisations. - In particular, the manifest type associated to a private abstract type - is revealed for the sake of compiler's type-based optimisations. *) -let find_type_expansion_opt path env = - let decl = find_type path env in - match decl.type_manifest with - (* The manifest type of Private abstract data types can still get - an approximation using their manifest type. *) - | Some body -> (decl.type_params, body, may_map snd decl.type_newtype_level) - | _ -> raise Not_found +let transl_class_path = transl_value_path +let transl_extension_path = transl_value_path -let find_modtype_expansion path env = - match (find_modtype path env).mtd_type with - | None -> raise Not_found - | Some mty -> mty +(* compatibility alias, deprecated in the .mli *) +let transl_path = transl_value_path -let rec is_functor_arg path env = - match path with - Pident id -> - begin try Ident.find_same id env.functor_args; true - with Not_found -> false - end - | Pdot (p, _s, _) -> is_functor_arg p env - | Papply _ -> true +(* Compile a sequence of expressions *) -(* Lookup by name *) +let rec make_sequence fn = function + [] -> lambda_unit + | [x] -> fn x + | x::rem -> + let lam = fn x in Lsequence(lam, make_sequence fn rem) -exception Recmodule +(* Apply a substitution to a lambda-term. + Assumes that the bound variables of the lambda-term do not + belong to the domain of the substitution. + Assumes that the image of the substitution is out of reach + of the bound variables of the lambda-term (no capture). *) -let report_deprecated ?loc p deprecated = - match loc, deprecated with - | Some loc, Some txt -> - let txt = if txt = "" then "" else "\n" ^ txt in - Location.deprecated loc (Printf.sprintf "module %s%s" (Path.name p) txt) - | _ -> () +let subst_lambda s lam = + let rec subst = function + Lvar id as l -> + begin try Ident.find_same id s with Not_found -> l end + | Lconst _ as l -> l + | Lapply ap -> + Lapply{ap with ap_func = subst ap.ap_func; + ap_args = List.map subst ap.ap_args} + | Lfunction{kind; params; body; attr; loc} -> + Lfunction{kind; params; body = subst body; attr; loc} + | Llet(str, k, id, arg, body) -> Llet(str, k, id, subst arg, subst body) + | Lletrec(decl, body) -> Lletrec(List.map subst_decl decl, subst body) + | Lprim(p, args, loc) -> Lprim(p, List.map subst args, loc) + | Lswitch(arg, sw, loc) -> + Lswitch(subst arg, + {sw with sw_consts = List.map subst_case sw.sw_consts; + sw_blocks = List.map subst_case sw.sw_blocks; + sw_failaction = subst_opt sw.sw_failaction; }, + loc) + | Lstringswitch (arg,cases,default,loc) -> + Lstringswitch + (subst arg,List.map subst_strcase cases,subst_opt default,loc) + | Lstaticraise (i,args) -> Lstaticraise (i, List.map subst args) + | Lstaticcatch(e1, io, e2) -> Lstaticcatch(subst e1, io, subst e2) + | Ltrywith(e1, exn, e2) -> Ltrywith(subst e1, exn, subst e2) + | Lifthenelse(e1, e2, e3) -> Lifthenelse(subst e1, subst e2, subst e3) + | Lsequence(e1, e2) -> Lsequence(subst e1, subst e2) + | Lwhile(e1, e2) -> Lwhile(subst e1, subst e2) + | Lfor(v, e1, e2, dir, e3) -> Lfor(v, subst e1, subst e2, dir, subst e3) + | Lassign(id, e) -> Lassign(id, subst e) + | Lsend (k, met, obj, args, loc) -> + Lsend (k, subst met, subst obj, List.map subst args, loc) + | Levent (lam, evt) -> Levent (subst lam, evt) + | Lifused (v, e) -> Lifused (v, subst e) + and subst_decl (id, exp) = (id, subst exp) + and subst_case (key, case) = (key, subst case) + and subst_strcase (key, case) = (key, subst case) + and subst_opt = function + | None -> None + | Some e -> Some (subst e) + in subst lam -let mark_module_used env name loc = - if not (is_implicit_coercion env) then - try Hashtbl.find module_declarations (name, loc) () - with Not_found -> () +let rec map f lam = + let lam = + match lam with + | Lvar _ -> lam + | Lconst _ -> lam + | Lapply { ap_func; ap_args; ap_loc; ap_should_be_tailcall; + ap_inlined; ap_specialised } -> + Lapply { + ap_func = map f ap_func; + ap_args = List.map (map f) ap_args; + ap_loc; + ap_should_be_tailcall; + ap_inlined; + ap_specialised; + } + | Lfunction { kind; params; body; attr; loc; } -> + Lfunction { kind; params; body = map f body; attr; loc; } + | Llet (str, k, v, e1, e2) -> + Llet (str, k, v, map f e1, map f e2) + | Lletrec (idel, e2) -> + Lletrec (List.map (fun (v, e) -> (v, map f e)) idel, map f e2) + | Lprim (p, el, loc) -> + Lprim (p, List.map (map f) el, loc) + | Lswitch (e, sw, loc) -> + Lswitch (map f e, + { sw_numconsts = sw.sw_numconsts; + sw_consts = List.map (fun (n, e) -> (n, map f e)) sw.sw_consts; + sw_numblocks = sw.sw_numblocks; + sw_blocks = List.map (fun (n, e) -> (n, map f e)) sw.sw_blocks; + sw_failaction = Misc.may_map (map f) sw.sw_failaction; + sw_names = sw.sw_names + }, + loc) + | Lstringswitch (e, sw, default, loc) -> + Lstringswitch ( + map f e, + List.map (fun (s, e) -> (s, map f e)) sw, + Misc.may_map (map f) default, + loc) + | Lstaticraise (i, args) -> + Lstaticraise (i, List.map (map f) args) + | Lstaticcatch (body, id, handler) -> + Lstaticcatch (map f body, id, map f handler) + | Ltrywith (e1, v, e2) -> + Ltrywith (map f e1, v, map f e2) + | Lifthenelse (e1, e2, e3) -> + Lifthenelse (map f e1, map f e2, map f e3) + | Lsequence (e1, e2) -> + Lsequence (map f e1, map f e2) + | Lwhile (e1, e2) -> + Lwhile (map f e1, map f e2) + | Lfor (v, e1, e2, dir, e3) -> + Lfor (v, map f e1, map f e2, dir, map f e3) + | Lassign (v, e) -> + Lassign (v, map f e) + | Lsend (k, m, o, el, loc) -> + Lsend (k, map f m, map f o, List.map (map f) el, loc) + | Levent (l, ev) -> + Levent (map f l, ev) + | Lifused (v, e) -> + Lifused (v, map f e) + in + f lam -let rec lookup_module_descr_aux ?loc lid env = - match lid with - Lident s -> - begin try - IdTbl.find_name s env.components - with Not_found -> - if s = !current_unit then raise Not_found; - let ps = find_pers_struct s in - (Pident(Ident.create_persistent s), ps.ps_comps) - end - | Ldot(l, s) -> - let (p, descr) = lookup_module_descr ?loc l env in - begin match get_components descr with - Structure_comps c -> - let (descr, pos) = Tbl.find_str s c.comp_components in - (Pdot(p, s, pos), descr) - | Functor_comps _ -> - raise Not_found - end - | Lapply(l1, l2) -> - let (p1, desc1) = lookup_module_descr ?loc l1 env in - let p2 = lookup_module ~load:true ?loc l2 env in - let {md_type=mty2} = find_module p2 env in - begin match get_components desc1 with - Functor_comps f -> - let loc = match loc with Some l -> l | None -> Location.none in - Misc.may (!check_modtype_inclusion ~loc env mty2 p2) f.fcomp_arg; - (Papply(p1, p2), !components_of_functor_appl' f env p1 p2) - | Structure_comps _ -> - raise Not_found - end +(* To let-bind expressions to variables *) -and lookup_module_descr ?loc lid env = - let (p, comps) as res = lookup_module_descr_aux ?loc lid env in - mark_module_used env (Path.last p) comps.loc; -(* - Format.printf "USE module %s at %a@." (Path.last p) - Location.print comps.loc; -*) - report_deprecated ?loc p comps.deprecated; - res +let bind str var exp body = + match exp with + Lvar var' when Ident.same var var' -> body + | _ -> Llet(str, Pgenval, var, exp, body) -and lookup_module ~load ?loc lid env : Path.t = - match lid with - Lident s -> - begin try - let (p, data) = IdTbl.find_name s env.modules in - let {md_loc; md_attributes; md_type} = - EnvLazy.force subst_modtype_maker data - in - mark_module_used env s md_loc; - begin match md_type with - | Mty_ident (Path.Pident id) when Ident.name id = "#recmod#" -> - (* see #5965 *) - raise Recmodule - - | Mty_alias (_, Path.Pident id) -> - if !Clflags.bs_only && not !Clflags.transparent_modules && Ident.persistent id then - find_pers_struct (Ident.name id) |> ignore - - | _ -> () - end; - report_deprecated ?loc p - (Builtin_attributes.deprecated_of_attrs md_attributes); - p - with Not_found -> - if s = !current_unit then raise Not_found; - let p = Pident(Ident.create_persistent s) in - if !Clflags.transparent_modules && not load then check_pers_struct s - else begin - let ps = find_pers_struct s in - report_deprecated ?loc p ps.ps_comps.deprecated - end; - p - end - | Ldot(l, s) -> - let (p, descr) = lookup_module_descr ?loc l env in - begin match get_components descr with - Structure_comps c -> - let (_data, pos) = Tbl.find_str s c.comp_modules in - let (comps, _) = Tbl.find_str s c.comp_components in - mark_module_used env s comps.loc; - let p = Pdot(p, s, pos) in - report_deprecated ?loc p comps.deprecated; - p - | Functor_comps _ -> - raise Not_found - end - | Lapply(l1, l2) -> - let (p1, desc1) = lookup_module_descr ?loc l1 env in - let p2 = lookup_module ~load:true ?loc l2 env in - let {md_type=mty2} = find_module p2 env in - let p = Papply(p1, p2) in - begin match get_components desc1 with - Functor_comps f -> - let loc = match loc with Some l -> l | None -> Location.none in - Misc.may (!check_modtype_inclusion ~loc env mty2 p2) f.fcomp_arg; - p - | Structure_comps _ -> - raise Not_found - end +and commute_comparison = function +| Ceq -> Ceq| Cneq -> Cneq +| Clt -> Cgt | Cle -> Cge +| Cgt -> Clt | Cge -> Cle + +and negate_comparison = function +| Ceq -> Cneq| Cneq -> Ceq +| Clt -> Cge | Cle -> Cgt +| Cgt -> Cle | Cge -> Clt + +let raise_kind = function + | Raise_regular -> "raise" + | Raise_reraise -> "reraise" + | Raise_notrace -> "raise_notrace" + +let lam_of_loc kind loc = + let loc_start = loc.Location.loc_start in + let (file, lnum, cnum) = Location.get_pos_info loc_start in + + let file = Filename.basename file in + + let enum = loc.Location.loc_end.Lexing.pos_cnum - + loc_start.Lexing.pos_cnum + cnum in + match kind with + | Loc_POS -> + Lconst (Const_block (0, Blk_tuple, [ + Const_immstring file; + Const_base (Const_int lnum); + Const_base (Const_int cnum); + Const_base (Const_int enum); + ])) + | Loc_FILE -> Lconst (Const_immstring file) + | Loc_MODULE -> + let filename = Filename.basename file in + let name = Env.get_unit_name () in + let module_name = if name = "" then "//"^filename^"//" else name in + Lconst (Const_immstring module_name) + | Loc_LOC -> + let loc = Printf.sprintf "File %S, line %d, characters %d-%d" + file lnum cnum enum in + Lconst (Const_immstring loc) + | Loc_LINE -> Lconst (Const_base (Const_int lnum)) -let lookup proj1 proj2 ?loc lid env = - match lid with - Lident s -> - IdTbl.find_name s (proj1 env) - | Ldot(l, s) -> - let (p, desc) = lookup_module_descr ?loc l env in - begin match get_components desc with - Structure_comps c -> - let (data, pos) = Tbl.find_str s (proj2 c) in - (Pdot(p, s, pos), data) - | Functor_comps _ -> - raise Not_found - end - | Lapply _ -> - raise Not_found +let merge_inline_attributes attr1 attr2 = + match attr1, attr2 with + | Default_inline, _ -> Some attr2 + | _, Default_inline -> Some attr1 + | _, _ -> + if attr1 = attr2 then Some attr1 + else None -let lookup_all_simple proj1 proj2 shadow ?loc lid env = - match lid with - Lident s -> - let xl = TycompTbl.find_all s (proj1 env) in - let rec do_shadow = - function - | [] -> [] - | ((x, f) :: xs) -> - (x, f) :: - (do_shadow (List.filter (fun (y, _) -> not (shadow x y)) xs)) - in - do_shadow xl - | Ldot(l, s) -> - let (_p, desc) = lookup_module_descr ?loc l env in - begin match get_components desc with - Structure_comps c -> - let comps = - try Tbl.find_str s (proj2 c) with Not_found -> [] - in - List.map - (fun data -> (data, (fun () -> ()))) - comps - | Functor_comps _ -> - raise Not_found - end - | Lapply _ -> - raise Not_found +let reset () = + raise_count := 0 -let has_local_constraints env = not (PathMap.is_empty env.local_constraints) +end +module Parser : sig +#1 "parser.mli" +type token = + | AMPERAMPER + | AMPERSAND + | AND + | AS + | ASSERT + | BACKQUOTE + | BANG + | BAR + | BARBAR + | BARRBRACKET + | BEGIN + | CHAR of (char) + | CLASS + | COLON + | COLONCOLON + | COLONEQUAL + | COLONGREATER + | COMMA + | CONSTRAINT + | DO + | DONE + | DOT + | DOTDOT + | DOWNTO + | ELSE + | END + | EOF + | EQUAL + | EXCEPTION + | EXTERNAL + | FALSE + | FLOAT of (string * char option) + | FOR + | FUN + | FUNCTION + | FUNCTOR + | GREATER + | GREATERRBRACE + | GREATERRBRACKET + | IF + | IN + | INCLUDE + | INFIXOP0 of (string) + | INFIXOP1 of (string) + | INFIXOP2 of (string) + | INFIXOP3 of (string) + | INFIXOP4 of (string) + | DOTOP of (string) + | INHERIT + | INITIALIZER + | INT of (string * char option) + | LABEL of (string) + | LAZY + | LBRACE + | LBRACELESS + | LBRACKET + | LBRACKETBAR + | LBRACKETLESS + | LBRACKETGREATER + | LBRACKETPERCENT + | LBRACKETPERCENTPERCENT + | LESS + | LESSMINUS + | LET + | LIDENT of (string) + | LPAREN + | LBRACKETAT + | LBRACKETATAT + | LBRACKETATATAT + | MATCH + | METHOD + | MINUS + | MINUSDOT + | MINUSGREATER + | MODULE + | MUTABLE + | NEW + | NONREC + | OBJECT + | OF + | OPEN + | OPTLABEL of (string) + | OR + | PERCENT + | PLUS + | PLUSDOT + | PLUSEQ + | PREFIXOP of (string) + | PRIVATE + | QUESTION + | QUOTE + | RBRACE + | RBRACKET + | REC + | RPAREN + | SEMI + | SEMISEMI + | HASH + | HASHOP of (string) + | SIG + | STAR + | STRING of (string * string option) + | STRUCT + | THEN + | TILDE + | TO + | TRUE + | TRY + | TYPE + | UIDENT of (string) + | UNDERSCORE + | VAL + | VIRTUAL + | WHEN + | WHILE + | WITH + | COMMENT of (string * Location.t) + | DOCSTRING of (Docstrings.docstring) + | EOL -let cstr_shadow cstr1 cstr2 = - match cstr1.cstr_tag, cstr2.cstr_tag with - | Cstr_extension _, Cstr_extension _ -> true - | _ -> false +val implementation : + (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Parsetree.structure +val interface : + (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Parsetree.signature +val toplevel_phrase : + (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Parsetree.toplevel_phrase +val use_file : + (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Parsetree.toplevel_phrase list +val parse_core_type : + (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Parsetree.core_type +val parse_expression : + (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Parsetree.expression +val parse_pattern : + (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Parsetree.pattern -let lbl_shadow _lbl1 _lbl2 = false +end = struct +#1 "parser.ml" +type token = + | AMPERAMPER + | AMPERSAND + | AND + | AS + | ASSERT + | BACKQUOTE + | BANG + | BAR + | BARBAR + | BARRBRACKET + | BEGIN + | CHAR of (char) + | CLASS + | COLON + | COLONCOLON + | COLONEQUAL + | COLONGREATER + | COMMA + | CONSTRAINT + | DO + | DONE + | DOT + | DOTDOT + | DOWNTO + | ELSE + | END + | EOF + | EQUAL + | EXCEPTION + | EXTERNAL + | FALSE + | FLOAT of (string * char option) + | FOR + | FUN + | FUNCTION + | FUNCTOR + | GREATER + | GREATERRBRACE + | GREATERRBRACKET + | IF + | IN + | INCLUDE + | INFIXOP0 of (string) + | INFIXOP1 of (string) + | INFIXOP2 of (string) + | INFIXOP3 of (string) + | INFIXOP4 of (string) + | DOTOP of (string) + | INHERIT + | INITIALIZER + | INT of (string * char option) + | LABEL of (string) + | LAZY + | LBRACE + | LBRACELESS + | LBRACKET + | LBRACKETBAR + | LBRACKETLESS + | LBRACKETGREATER + | LBRACKETPERCENT + | LBRACKETPERCENTPERCENT + | LESS + | LESSMINUS + | LET + | LIDENT of (string) + | LPAREN + | LBRACKETAT + | LBRACKETATAT + | LBRACKETATATAT + | MATCH + | METHOD + | MINUS + | MINUSDOT + | MINUSGREATER + | MODULE + | MUTABLE + | NEW + | NONREC + | OBJECT + | OF + | OPEN + | OPTLABEL of (string) + | OR + | PERCENT + | PLUS + | PLUSDOT + | PLUSEQ + | PREFIXOP of (string) + | PRIVATE + | QUESTION + | QUOTE + | RBRACE + | RBRACKET + | REC + | RPAREN + | SEMI + | SEMISEMI + | HASH + | HASHOP of (string) + | SIG + | STAR + | STRING of (string * string option) + | STRUCT + | THEN + | TILDE + | TO + | TRUE + | TRY + | TYPE + | UIDENT of (string) + | UNDERSCORE + | VAL + | VIRTUAL + | WHEN + | WHILE + | WITH + | COMMENT of (string * Location.t) + | DOCSTRING of (Docstrings.docstring) + | EOL -let lookup_value = - lookup (fun env -> env.values) (fun sc -> sc.comp_values) -let lookup_all_constructors = - lookup_all_simple (fun env -> env.constrs) (fun sc -> sc.comp_constrs) - cstr_shadow -let lookup_all_labels = - lookup_all_simple (fun env -> env.labels) (fun sc -> sc.comp_labels) - lbl_shadow -let lookup_type = - lookup (fun env -> env.types) (fun sc -> sc.comp_types) -let lookup_modtype = - lookup (fun env -> env.modtypes) (fun sc -> sc.comp_modtypes) -let lookup_class = - lookup (fun env -> env.classes) (fun sc -> sc.comp_classes) -let lookup_cltype = - lookup (fun env -> env.cltypes) (fun sc -> sc.comp_cltypes) +open Parsing;; +let _ = parse_error;; +# 19 "parsing/parser.mly" +open Location +open Asttypes +open Longident +open Parsetree +open Ast_helper +open Docstrings -let copy_types l env = - let f desc = {desc with val_type = Subst.type_expr Subst.identity desc.val_type} in - let values = List.fold_left (fun env s -> IdTbl.update s f env) env.values l in - {env with values; summary = Env_copy_types (env.summary, l)} +let mktyp d = Typ.mk ~loc:(symbol_rloc()) d +let mkpat d = Pat.mk ~loc:(symbol_rloc()) d +let mkexp d = Exp.mk ~loc:(symbol_rloc()) d +let mkmty ?attrs d = Mty.mk ~loc:(symbol_rloc()) ?attrs d +let mksig d = Sig.mk ~loc:(symbol_rloc()) d +let mkmod ?attrs d = Mod.mk ~loc:(symbol_rloc()) ?attrs d +let mkstr d = Str.mk ~loc:(symbol_rloc()) d +let mkclass ?attrs d = Cl.mk ~loc:(symbol_rloc()) ?attrs d +let mkcty ?attrs d = Cty.mk ~loc:(symbol_rloc()) ?attrs d +let mkctf ?attrs ?docs d = + Ctf.mk ~loc:(symbol_rloc()) ?attrs ?docs d +let mkcf ?attrs ?docs d = + Cf.mk ~loc:(symbol_rloc()) ?attrs ?docs d -let mark_value_used env name vd = - if not (is_implicit_coercion env) then - try Hashtbl.find value_declarations (name, vd.val_loc) () - with Not_found -> () +let mkrhs rhs pos = mkloc rhs (rhs_loc pos) -let mark_type_used env name vd = - if not (is_implicit_coercion env) then - try Hashtbl.find type_declarations (name, vd.type_loc) () - with Not_found -> () +let reloc_pat x = { x with ppat_loc = symbol_rloc () };; +let reloc_exp x = { x with pexp_loc = symbol_rloc () };; -let mark_constructor_used usage env name vd constr = - if not (is_implicit_coercion env) then - try Hashtbl.find used_constructors (name, vd.type_loc, constr) usage - with Not_found -> () +let mkoperator name pos = + let loc = rhs_loc pos in + Exp.mk ~loc (Pexp_ident(mkloc (Lident name) loc)) -let mark_extension_used usage env ext name = - if not (is_implicit_coercion env) then - let ty_name = Path.last ext.ext_type_path in - try Hashtbl.find used_constructors (ty_name, ext.ext_loc, name) usage - with Not_found -> () +let mkpatvar name pos = + Pat.mk ~loc:(rhs_loc pos) (Ppat_var (mkrhs name pos)) -let set_value_used_callback name vd callback = - let key = (name, vd.val_loc) in - try - let old = Hashtbl.find value_declarations key in - Hashtbl.replace value_declarations key (fun () -> old (); callback ()) - (* this is to support cases like: - let x = let x = 1 in x in x - where the two declarations have the same location - (e.g. resulting from Camlp4 expansion of grammar entries) *) - with Not_found -> - Hashtbl.add value_declarations key callback +(* + Ghost expressions and patterns: + expressions and patterns that do not appear explicitly in the + source file they have the loc_ghost flag set to true. + Then the profiler will not try to instrument them and the + -annot option will not try to display their type. -let set_type_used_callback name td callback = - let loc = td.type_loc in - if loc.Location.loc_ghost then () - else let key = (name, loc) in - let old = - try Hashtbl.find type_declarations key - with Not_found -> assert false - in - Hashtbl.replace type_declarations key (fun () -> callback old) + Every grammar rule that generates an element with a location must + make at most one non-ghost element, the topmost one. -let lookup_value ?loc lid env = - let (_, desc) as r = lookup_value ?loc lid env in - mark_value_used env (Longident.last lid) desc; - r + How to tell whether your location must be ghost: + A location corresponds to a range of characters in the source file. + If the location contains a piece of code that is syntactically + valid (according to the documentation), and corresponds to the + AST node, then the location must be real; in all other cases, + it must be ghost. +*) +let ghexp d = Exp.mk ~loc:(symbol_gloc ()) d +let ghpat d = Pat.mk ~loc:(symbol_gloc ()) d +let ghtyp d = Typ.mk ~loc:(symbol_gloc ()) d +let ghloc d = { txt = d; loc = symbol_gloc () } +let ghstr d = Str.mk ~loc:(symbol_gloc()) d +let ghsig d = Sig.mk ~loc:(symbol_gloc()) d -let lookup_type ?loc lid env = - let (path, (decl, _)) = lookup_type ?loc lid env in - mark_type_used env (Longident.last lid) decl; - path +let mkinfix arg1 name arg2 = + mkexp(Pexp_apply(mkoperator name 2, [Nolabel, arg1; Nolabel, arg2])) -let mark_type_path env path = - try - let decl = find_type path env in - mark_type_used env (Path.last path) decl - with Not_found -> () +let neg_string f = + if String.length f > 0 && f.[0] = '-' + then String.sub f 1 (String.length f - 1) + else "-" ^ f -let ty_path t = - match repr t with - | {desc=Tconstr(path, _, _)} -> path - | _ -> assert false +let mkuminus name arg = + match name, arg.pexp_desc with + | "-", Pexp_constant(Pconst_integer (n,m)) -> + mkexp(Pexp_constant(Pconst_integer(neg_string n,m))) + | ("-" | "-."), Pexp_constant(Pconst_float (f, m)) -> + mkexp(Pexp_constant(Pconst_float(neg_string f, m))) + | _ -> + mkexp(Pexp_apply(mkoperator ("~" ^ name) 1, [Nolabel, arg])) -let lookup_constructor ?loc lid env = - match lookup_all_constructors ?loc lid env with - [] -> raise Not_found - | (desc, use) :: _ -> - mark_type_path env (ty_path desc.cstr_res); - use (); - desc +let mkuplus name arg = + let desc = arg.pexp_desc in + match name, desc with + | "+", Pexp_constant(Pconst_integer _) + | ("+" | "+."), Pexp_constant(Pconst_float _) -> mkexp desc + | _ -> + mkexp(Pexp_apply(mkoperator ("~" ^ name) 1, [Nolabel, arg])) -let is_lident = function - Lident _ -> true - | _ -> false +let mkexp_cons consloc args loc = + Exp.mk ~loc (Pexp_construct(mkloc (Lident "::") consloc, Some args)) -let lookup_all_constructors ?loc lid env = - try - let cstrs = lookup_all_constructors ?loc lid env in - let wrap_use desc use () = - mark_type_path env (ty_path desc.cstr_res); - use () - in - List.map (fun (cstr, use) -> (cstr, wrap_use cstr use)) cstrs - with - Not_found when is_lident lid -> [] +let mkpat_cons consloc args loc = + Pat.mk ~loc (Ppat_construct(mkloc (Lident "::") consloc, Some args)) + +let rec mktailexp nilloc = function + [] -> + let loc = { nilloc with loc_ghost = true } in + let nil = { txt = Lident "[]"; loc = loc } in + Exp.mk ~loc (Pexp_construct (nil, None)) + | e1 :: el -> + let exp_el = mktailexp nilloc el in + let loc = {loc_start = e1.pexp_loc.loc_start; + loc_end = exp_el.pexp_loc.loc_end; + loc_ghost = true} + in + let arg = Exp.mk ~loc (Pexp_tuple [e1; exp_el]) in + mkexp_cons {loc with loc_ghost = true} arg loc + +let rec mktailpat nilloc = function + [] -> + let loc = { nilloc with loc_ghost = true } in + let nil = { txt = Lident "[]"; loc = loc } in + Pat.mk ~loc (Ppat_construct (nil, None)) + | p1 :: pl -> + let pat_pl = mktailpat nilloc pl in + let loc = {loc_start = p1.ppat_loc.loc_start; + loc_end = pat_pl.ppat_loc.loc_end; + loc_ghost = true} + in + let arg = Pat.mk ~loc (Ppat_tuple [p1; pat_pl]) in + mkpat_cons {loc with loc_ghost = true} arg loc -let mark_constructor usage env name desc = - if not (is_implicit_coercion env) - then match desc.cstr_tag with - | Cstr_extension _ -> - begin - let ty_path = ty_path desc.cstr_res in - let ty_name = Path.last ty_path in - try Hashtbl.find used_constructors (ty_name, desc.cstr_loc, name) usage - with Not_found -> () - end - | _ -> - let ty_path = ty_path desc.cstr_res in - let ty_decl = try find_type ty_path env with Not_found -> assert false in - let ty_name = Path.last ty_path in - mark_constructor_used usage env ty_name ty_decl name +let mkstrexp e attrs = + { pstr_desc = Pstr_eval (e, attrs); pstr_loc = e.pexp_loc } -let lookup_label ?loc lid env = - match lookup_all_labels ?loc lid env with - [] -> raise Not_found - | (desc, use) :: _ -> - mark_type_path env (ty_path desc.lbl_res); - use (); - desc +let mkexp_constraint e (t1, t2) = + match t1, t2 with + | Some t, None -> ghexp(Pexp_constraint(e, t)) + | _, Some t -> ghexp(Pexp_coerce(e, t1, t)) + | None, None -> assert false -let lookup_all_labels ?loc lid env = - try - let lbls = lookup_all_labels ?loc lid env in - let wrap_use desc use () = - mark_type_path env (ty_path desc.lbl_res); - use () - in - List.map (fun (lbl, use) -> (lbl, wrap_use lbl use)) lbls - with - Not_found when is_lident lid -> [] +let mkexp_opt_constraint e = function + | None -> e + | Some constraint_ -> mkexp_constraint e constraint_ -let lookup_class ?loc lid env = - let (_, desc) as r = lookup_class ?loc lid env in - (* special support for Typeclass.unbound_class *) - if Path.name desc.cty_path = "" then ignore (lookup_type ?loc lid env) - else mark_type_path env desc.cty_path; - r +let mkpat_opt_constraint p = function + | None -> p + | Some typ -> mkpat (Ppat_constraint(p, typ)) -let lookup_cltype ?loc lid env = - let (_, desc) as r = lookup_cltype ?loc lid env in - if Path.name desc.clty_path = "" then ignore (lookup_type ?loc lid env) - else mark_type_path env desc.clty_path; - mark_type_path env desc.clty_path; - r +let array_function str name = + ghloc (Ldot(Lident str, (if !Clflags.fast then "unsafe_" ^ name else name))) -(* Iter on an environment (ignoring the body of functors and - not yet evaluated structures) *) +let syntax_error () = + raise Syntaxerr.Escape_error -type iter_cont = unit -> unit -let iter_env_cont = ref [] +let unclosed opening_name opening_num closing_name closing_num = + raise(Syntaxerr.Error(Syntaxerr.Unclosed(rhs_loc opening_num, opening_name, + rhs_loc closing_num, closing_name))) -let rec scrape_alias_for_visit env mty = - match mty with - | Mty_alias(_, Pident id) - when Ident.persistent id - && not (Hashtbl.mem persistent_structures (Ident.name id)) -> false - | Mty_alias(_, path) -> (* PR#6600: find_module may raise Not_found *) - begin try scrape_alias_for_visit env (find_module path env).md_type - with Not_found -> false - end - | _ -> true +let expecting pos nonterm = + raise Syntaxerr.(Error(Expecting(rhs_loc pos, nonterm))) -let iter_env proj1 proj2 f env () = - IdTbl.iter (fun id x -> f (Pident id) x) (proj1 env); - let rec iter_components path path' mcomps = - let cont () = - let visit = - match EnvLazy.get_arg mcomps.comps with - | None -> true - | Some (env, _sub, _path, mty) -> scrape_alias_for_visit env mty - in - if not visit then () else - match get_components mcomps with - Structure_comps comps -> - Tbl.iter - (fun s (d, n) -> f (Pdot (path, s, n)) (Pdot (path', s, n), d)) - (proj2 comps); - Tbl.iter - (fun s (c, n) -> - iter_components (Pdot (path, s, n)) (Pdot (path', s, n)) c) - comps.comp_components - | Functor_comps _ -> () - in iter_env_cont := (path, cont) :: !iter_env_cont - in - Hashtbl.iter - (fun s pso -> - match pso with None -> () - | Some ps -> - let id = Pident (Ident.create_persistent s) in - iter_components id id ps.ps_comps) - persistent_structures; - IdTbl.iter - (fun id (path, comps) -> iter_components (Pident id) path comps) - env.components +let not_expecting pos nonterm = + raise Syntaxerr.(Error(Not_expecting(rhs_loc pos, nonterm))) -let run_iter_cont l = - iter_env_cont := []; - List.iter (fun c -> c ()) l; - let cont = List.rev !iter_env_cont in - iter_env_cont := []; - cont +let bigarray_function str name = + ghloc (Ldot(Ldot(Lident "Bigarray", str), name)) -let iter_types f = iter_env (fun env -> env.types) (fun sc -> sc.comp_types) f +let bigarray_untuplify = function + { pexp_desc = Pexp_tuple explist; pexp_loc = _ } -> explist + | exp -> [exp] -let same_types env1 env2 = - env1.types == env2.types && env1.components == env2.components +let bigarray_get arr arg = + let get = if !Clflags.fast then "unsafe_get" else "get" in + match bigarray_untuplify arg with + [c1] -> + mkexp(Pexp_apply(ghexp(Pexp_ident(bigarray_function "Array1" get)), + [Nolabel, arr; Nolabel, c1])) + | [c1;c2] -> + mkexp(Pexp_apply(ghexp(Pexp_ident(bigarray_function "Array2" get)), + [Nolabel, arr; Nolabel, c1; Nolabel, c2])) + | [c1;c2;c3] -> + mkexp(Pexp_apply(ghexp(Pexp_ident(bigarray_function "Array3" get)), + [Nolabel, arr; Nolabel, c1; Nolabel, c2; Nolabel, c3])) + | coords -> + mkexp(Pexp_apply(ghexp(Pexp_ident(bigarray_function "Genarray" "get")), + [Nolabel, arr; Nolabel, ghexp(Pexp_array coords)])) -let used_persistent () = - let r = ref Concr.empty in - Hashtbl.iter (fun s pso -> if pso != None then r := Concr.add s !r) - persistent_structures; - !r +let bigarray_set arr arg newval = + let set = if !Clflags.fast then "unsafe_set" else "set" in + match bigarray_untuplify arg with + [c1] -> + mkexp(Pexp_apply(ghexp(Pexp_ident(bigarray_function "Array1" set)), + [Nolabel, arr; Nolabel, c1; Nolabel, newval])) + | [c1;c2] -> + mkexp(Pexp_apply(ghexp(Pexp_ident(bigarray_function "Array2" set)), + [Nolabel, arr; Nolabel, c1; + Nolabel, c2; Nolabel, newval])) + | [c1;c2;c3] -> + mkexp(Pexp_apply(ghexp(Pexp_ident(bigarray_function "Array3" set)), + [Nolabel, arr; Nolabel, c1; + Nolabel, c2; Nolabel, c3; Nolabel, newval])) + | coords -> + mkexp(Pexp_apply(ghexp(Pexp_ident(bigarray_function "Genarray" "set")), + [Nolabel, arr; + Nolabel, ghexp(Pexp_array coords); + Nolabel, newval])) -let find_all_comps proj s (p,mcomps) = - match get_components mcomps with - Functor_comps _ -> [] - | Structure_comps comps -> - try let (c,n) = Tbl.find_str s (proj comps) in [Pdot(p,s,n), c] - with Not_found -> [] +let lapply p1 p2 = + if !Clflags.applicative_functors + then Lapply(p1, p2) + else raise (Syntaxerr.Error(Syntaxerr.Applicative_path (symbol_rloc()))) -let rec find_shadowed_comps path env = - match path with - Pident id -> - IdTbl.find_all (Ident.name id) env.components - | Pdot (p, s, _) -> - let l = find_shadowed_comps p env in - let l' = - List.map (find_all_comps (fun comps -> comps.comp_components) s) l in - List.flatten l' - | Papply _ -> [] +let exp_of_label lbl pos = + mkexp (Pexp_ident(mkrhs (Lident(Longident.last lbl)) pos)) -let find_shadowed proj1 proj2 path env = - match path with - Pident id -> - IdTbl.find_all (Ident.name id) (proj1 env) - | Pdot (p, s, _) -> - let l = find_shadowed_comps p env in - let l' = List.map (find_all_comps proj2 s) l in - List.flatten l' - | Papply _ -> [] +let pat_of_label lbl pos = + mkpat (Ppat_var (mkrhs (Longident.last lbl) pos)) -let find_shadowed_types path env = - List.map fst - (find_shadowed - (fun env -> env.types) (fun comps -> comps.comp_types) path env) +let mk_newtypes newtypes exp = + List.fold_right (fun newtype exp -> mkexp (Pexp_newtype (newtype, exp))) + newtypes exp +let wrap_type_annotation newtypes core_type body = + let exp = mkexp(Pexp_constraint(body,core_type)) in + let exp = mk_newtypes newtypes exp in + (exp, ghtyp(Ptyp_poly(newtypes, Typ.varify_constructors newtypes core_type))) -(* GADT instance tracking *) +let wrap_exp_attrs body (ext, attrs) = + (* todo: keep exact location for the entire attribute *) + let body = {body with pexp_attributes = attrs @ body.pexp_attributes} in + match ext with + | None -> body + | Some id -> ghexp(Pexp_extension (id, PStr [mkstrexp body []])) -let add_gadt_instance_level lv env = - {env with - gadt_instances = (lv, ref TypeSet.empty) :: env.gadt_instances} +let mkexp_attrs d attrs = + wrap_exp_attrs (mkexp d) attrs -let is_Tlink = function {desc = Tlink _} -> true | _ -> false +let wrap_typ_attrs typ (ext, attrs) = + (* todo: keep exact location for the entire attribute *) + let typ = {typ with ptyp_attributes = attrs @ typ.ptyp_attributes} in + match ext with + | None -> typ + | Some id -> ghtyp(Ptyp_extension (id, PTyp typ)) -let gadt_instance_level env t = - let rec find_instance = function - [] -> None - | (lv, r) :: rem -> - if TypeSet.exists is_Tlink !r then - (* Should we use set_typeset ? *) - r := TypeSet.fold (fun ty -> TypeSet.add (repr ty)) !r TypeSet.empty; - if TypeSet.mem t !r then Some lv else find_instance rem - in find_instance env.gadt_instances +let mktyp_attrs d attrs = + wrap_typ_attrs (mktyp d) attrs -let add_gadt_instances env lv tl = - let r = - try List.assoc lv env.gadt_instances with Not_found -> assert false in - (* Format.eprintf "Added"; - List.iter (fun ty -> Format.eprintf "@ %a" !Btype.print_raw ty) tl; - Format.eprintf "@."; *) - set_typeset r (List.fold_right TypeSet.add tl !r) +let wrap_pat_attrs pat (ext, attrs) = + (* todo: keep exact location for the entire attribute *) + let pat = {pat with ppat_attributes = attrs @ pat.ppat_attributes} in + match ext with + | None -> pat + | Some id -> ghpat(Ppat_extension (id, PPat (pat, None))) -(* Only use this after expand_head! *) -let add_gadt_instance_chain env lv t = - let r = - try List.assoc lv env.gadt_instances with Not_found -> assert false in - let rec add_instance t = - let t = repr t in - if not (TypeSet.mem t !r) then begin - (* Format.eprintf "@ %a" !Btype.print_raw t; *) - set_typeset r (TypeSet.add t !r); - match t.desc with - Tconstr (p, _, memo) -> - may add_instance (find_expans Private p !memo) - | _ -> () - end - in - (* Format.eprintf "Added chain"; *) - add_instance t - (* Format.eprintf "@." *) +let mkpat_attrs d attrs = + wrap_pat_attrs (mkpat d) attrs -(* Expand manifest module type names at the top of the given module type *) +let wrap_class_attrs body attrs = + {body with pcl_attributes = attrs @ body.pcl_attributes} +let wrap_class_type_attrs body attrs = + {body with pcty_attributes = attrs @ body.pcty_attributes} +let wrap_mod_attrs body attrs = + {body with pmod_attributes = attrs @ body.pmod_attributes} +let wrap_mty_attrs body attrs = + {body with pmty_attributes = attrs @ body.pmty_attributes} -let rec scrape_alias env ?path mty = - match mty, path with - Mty_ident p, _ -> - begin try - scrape_alias env (find_modtype_expansion p env) ?path - with Not_found -> - mty - end - | Mty_alias(_, path), _ -> - begin try - scrape_alias env (find_module path env).md_type ~path - with Not_found -> - (*Location.prerr_warning Location.none - (Warnings.No_cmi_file (Path.name path));*) - mty - end - | mty, Some path -> - !strengthen ~aliasable:true env mty path - | _ -> mty +let wrap_str_ext body ext = + match ext with + | None -> body + | Some id -> ghstr(Pstr_extension ((id, PStr [body]), [])) -let scrape_alias env mty = scrape_alias env mty +let mkstr_ext d ext = + wrap_str_ext (mkstr d) ext -(* Given a signature and a root path, prefix all idents in the signature - by the root path and build the corresponding substitution. *) +let wrap_sig_ext body ext = + match ext with + | None -> body + | Some id -> ghsig(Psig_extension ((id, PSig [body]), [])) -let rec prefix_idents root pos sub = function - [] -> ([], sub) - | Sig_value(id, decl) :: rem -> - let p = Pdot(root, Ident.name id, pos) in - let nextpos = match decl.val_kind with Val_prim _ -> pos | _ -> pos+1 in - let (pl, final_sub) = prefix_idents root nextpos sub rem in - (p::pl, final_sub) - | Sig_type(id, _, _) :: rem -> - let p = Pdot(root, Ident.name id, nopos) in - let (pl, final_sub) = - prefix_idents root pos (Subst.add_type id p sub) rem in - (p::pl, final_sub) - | Sig_typext(id, _, _) :: rem -> - let p = Pdot(root, Ident.name id, pos) in - (* we extend the substitution in case of an inlined record *) - let (pl, final_sub) = - prefix_idents root (pos+1) (Subst.add_type id p sub) rem in - (p::pl, final_sub) - | Sig_module(id, _, _) :: rem -> - let p = Pdot(root, Ident.name id, pos) in - let (pl, final_sub) = - prefix_idents root (pos+1) (Subst.add_module id p sub) rem in - (p::pl, final_sub) - | Sig_modtype(id, _) :: rem -> - let p = Pdot(root, Ident.name id, nopos) in - let (pl, final_sub) = - prefix_idents root pos - (Subst.add_modtype id (Mty_ident p) sub) rem in - (p::pl, final_sub) - | Sig_class(id, _, _) :: rem -> - (* pretend this is a type, cf. PR#6650 *) - let p = Pdot(root, Ident.name id, pos) in - let (pl, final_sub) = - prefix_idents root (pos + 1) (Subst.add_type id p sub) rem in - (p::pl, final_sub) - | Sig_class_type(id, _, _) :: rem -> - let p = Pdot(root, Ident.name id, nopos) in - let (pl, final_sub) = - prefix_idents root pos (Subst.add_type id p sub) rem in - (p::pl, final_sub) +let mksig_ext d ext = + wrap_sig_ext (mksig d) ext -let prefix_idents root sub sg = - if sub = Subst.identity then - let sgs = - try - Hashtbl.find prefixed_sg root - with Not_found -> - let sgs = ref [] in - Hashtbl.add prefixed_sg root sgs; - sgs - in - try - List.assq sg !sgs - with Not_found -> - let r = prefix_idents root 0 sub sg in - sgs := (sg, r) :: !sgs; - r - else - prefix_idents root 0 sub sg +let text_str pos = Str.text (rhs_text pos) +let text_sig pos = Sig.text (rhs_text pos) +let text_cstr pos = Cf.text (rhs_text pos) +let text_csig pos = Ctf.text (rhs_text pos) +let text_def pos = [Ptop_def (Str.text (rhs_text pos))] -(* Compute structure descriptions *) +let extra_text text pos items = + let pre_extras = rhs_pre_extra_text pos in + let post_extras = rhs_post_extra_text pos in + text pre_extras @ items @ text post_extras -let add_to_tbl id decl tbl = - let decls = - try Tbl.find_str id tbl with Not_found -> [] in - Tbl.add id (decl :: decls) tbl +let extra_str pos items = extra_text Str.text pos items +let extra_sig pos items = extra_text Sig.text pos items +let extra_cstr pos items = extra_text Cf.text pos items +let extra_csig pos items = extra_text Ctf.text pos items +let extra_def pos items = + extra_text (fun txt -> [Ptop_def (Str.text txt)]) pos items -let rec components_of_module ~deprecated ~loc env sub path mty = - { - deprecated; - loc; - comps = EnvLazy.create (env, sub, path, mty) - } +let extra_rhs_core_type ct ~pos = + let docs = rhs_info pos in + { ct with ptyp_attributes = add_info_attrs docs ct.ptyp_attributes } -and components_of_module_maker (env, sub, path, mty) = - match scrape_alias env mty with - Mty_signature sg -> - let c = - { comp_values = Tbl.empty; - comp_constrs = Tbl.empty; - comp_labels = Tbl.empty; comp_types = Tbl.empty; - comp_modules = Tbl.empty; comp_modtypes = Tbl.empty; - comp_components = Tbl.empty; comp_classes = Tbl.empty; - comp_cltypes = Tbl.empty } in - let pl, sub = prefix_idents path sub sg in - let env = ref env in - let pos = ref 0 in - List.iter2 (fun item path -> - match item with - Sig_value(id, decl) -> - let decl' = Subst.value_description sub decl in - c.comp_values <- - Tbl.add (Ident.name id) (decl', !pos) c.comp_values; - begin match decl.val_kind with - Val_prim _ -> () | _ -> incr pos - end - | Sig_type(id, decl, _) -> - let decl' = Subst.type_declaration sub decl in - Datarepr.set_row_name decl' (Subst.type_path sub (Path.Pident id)); - let constructors = - List.map snd (Datarepr.constructors_of_type path decl') in - let labels = - List.map snd (Datarepr.labels_of_type path decl') in - c.comp_types <- - Tbl.add (Ident.name id) - ((decl', (constructors, labels)), nopos) - c.comp_types; - List.iter - (fun descr -> - c.comp_constrs <- - add_to_tbl descr.cstr_name descr c.comp_constrs) - constructors; - List.iter - (fun descr -> - c.comp_labels <- - add_to_tbl descr.lbl_name descr c.comp_labels) - labels; - env := store_type_infos id decl !env - | Sig_typext(id, ext, _) -> - let ext' = Subst.extension_constructor sub ext in - let descr = Datarepr.extension_descr path ext' in - c.comp_constrs <- - add_to_tbl (Ident.name id) descr c.comp_constrs; - incr pos - | Sig_module(id, md, _) -> - let md' = EnvLazy.create (sub, md) in - c.comp_modules <- - Tbl.add (Ident.name id) (md', !pos) c.comp_modules; - let deprecated = - Builtin_attributes.deprecated_of_attrs md.md_attributes - in - let comps = - components_of_module ~deprecated ~loc:md.md_loc !env sub path - md.md_type - in - c.comp_components <- - Tbl.add (Ident.name id) (comps, !pos) c.comp_components; - env := store_module ~check:false id md !env; - incr pos - | Sig_modtype(id, decl) -> - let decl' = Subst.modtype_declaration sub decl in - c.comp_modtypes <- - Tbl.add (Ident.name id) (decl', nopos) c.comp_modtypes; - env := store_modtype id decl !env - | Sig_class(id, decl, _) -> - let decl' = Subst.class_declaration sub decl in - c.comp_classes <- - Tbl.add (Ident.name id) (decl', !pos) c.comp_classes; - incr pos - | Sig_class_type(id, decl, _) -> - let decl' = Subst.cltype_declaration sub decl in - c.comp_cltypes <- - Tbl.add (Ident.name id) (decl', !pos) c.comp_cltypes) - sg pl; - Some (Structure_comps c) - | Mty_functor(param, ty_arg, ty_res) -> - Some (Functor_comps { - fcomp_param = param; - (* fcomp_arg and fcomp_res must be prefixed eagerly, because - they are interpreted in the outer environment *) - fcomp_arg = may_map (Subst.modtype sub) ty_arg; - fcomp_res = Subst.modtype sub ty_res; - fcomp_cache = Hashtbl.create 17; - fcomp_subst_cache = Hashtbl.create 17 }) - | Mty_ident _ - | Mty_alias _ -> None +type let_binding = + { lb_pattern: pattern; + lb_expression: expression; + lb_attributes: attributes; + lb_docs: docs Lazy.t; + lb_text: text Lazy.t; + lb_loc: Location.t; } + +type let_bindings = + { lbs_bindings: let_binding list; + lbs_rec: rec_flag; + lbs_extension: string Asttypes.loc option; + lbs_loc: Location.t } -(* Insertion of bindings by identifier + path *) +let mklb first (p, e) attrs = + { lb_pattern = p; + lb_expression = e; + lb_attributes = attrs; + lb_docs = symbol_docs_lazy (); + lb_text = if first then empty_text_lazy + else symbol_text_lazy (); + lb_loc = symbol_rloc (); } -and check_usage loc id warn tbl = - if not loc.Location.loc_ghost && Warnings.is_active (warn "") then begin - let name = Ident.name id in - let key = (name, loc) in - if Hashtbl.mem tbl key then () - else let used = ref false in - Hashtbl.add tbl key (fun () -> used := true); - if not (name = "" || name.[0] = '_' || name.[0] = '#') - then - !add_delayed_check_forward - (fun () -> if not !used then Location.prerr_warning loc (warn name)) - end; +let mklbs ext rf lb = + { lbs_bindings = [lb]; + lbs_rec = rf; + lbs_extension = ext ; + lbs_loc = symbol_rloc (); } -and check_value_name name loc = - (* Note: we could also check here general validity of the - identifier, to protect against bad identifiers forged by -pp or - -ppx preprocessors. *) - if !Clflags.bs_only && name = "|." then raise (Error(Illegal_value_name(loc, name))) - else if String.length name > 0 && (name.[0] = '#') then - for i = 1 to String.length name - 1 do - if name.[i] = '#' then - raise (Error(Illegal_value_name(loc, name))) - done +let addlb lbs lb = + { lbs with lbs_bindings = lb :: lbs.lbs_bindings } +let val_of_let_bindings lbs = + let bindings = + List.map + (fun lb -> + Vb.mk ~loc:lb.lb_loc ~attrs:lb.lb_attributes + ~docs:(Lazy.force lb.lb_docs) + ~text:(Lazy.force lb.lb_text) + lb.lb_pattern lb.lb_expression) + lbs.lbs_bindings + in + let str = mkstr(Pstr_value(lbs.lbs_rec, List.rev bindings)) in + match lbs.lbs_extension with + | None -> str + | Some id -> ghstr (Pstr_extension((id, PStr [str]), [])) -and store_value ?check id decl env = - check_value_name (Ident.name id) decl.val_loc; - may (fun f -> check_usage decl.val_loc id f value_declarations) check; - { env with - values = IdTbl.add id decl env.values; - summary = Env_value(env.summary, id, decl) } +let expr_of_let_bindings lbs body = + let bindings = + List.map + (fun lb -> + Vb.mk ~loc:lb.lb_loc ~attrs:lb.lb_attributes + lb.lb_pattern lb.lb_expression) + lbs.lbs_bindings + in + mkexp_attrs (Pexp_let(lbs.lbs_rec, List.rev bindings, body)) + (lbs.lbs_extension, []) -and store_type ~check id info env = - let loc = info.type_loc in - if check then - check_usage loc id (fun s -> Warnings.Unused_type_declaration s) - type_declarations; - let path = Pident id in - let constructors = Datarepr.constructors_of_type path info in - let labels = Datarepr.labels_of_type path info in - let descrs = (List.map snd constructors, List.map snd labels) in +let class_of_let_bindings lbs body = + let bindings = + List.map + (fun lb -> + Vb.mk ~loc:lb.lb_loc ~attrs:lb.lb_attributes + lb.lb_pattern lb.lb_expression) + lbs.lbs_bindings + in + if lbs.lbs_extension <> None then + raise Syntaxerr.(Error(Not_expecting(lbs.lbs_loc, "extension"))); + mkclass(Pcl_let (lbs.lbs_rec, List.rev bindings, body)) - if check && not loc.Location.loc_ghost && - Warnings.is_active (Warnings.Unused_constructor ("", false, false)) - then begin - let ty = Ident.name id in - List.iter - begin fun (_, {cstr_name = c; _}) -> - let k = (ty, loc, c) in - if not (Hashtbl.mem used_constructors k) then - let used = constructor_usages () in - Hashtbl.add used_constructors k (add_constructor_usage used); - if not (ty = "" || ty.[0] = '_') - then !add_delayed_check_forward - (fun () -> - if not (is_in_signature env) && not used.cu_positive then - Location.prerr_warning loc - (Warnings.Unused_constructor - (c, used.cu_pattern, used.cu_privatize))) - end - constructors - end; - { env with - constrs = - List.fold_right - (fun (id, descr) constrs -> TycompTbl.add id descr constrs) - constructors - env.constrs; - labels = - List.fold_right - (fun (id, descr) labels -> TycompTbl.add id descr labels) - labels - env.labels; - types = - IdTbl.add id (info, descrs) env.types; - summary = Env_type(env.summary, id, info) } -and store_type_infos id info env = - (* Simplified version of store_type that doesn't compute and store - constructor and label infos, but simply record the arity and - manifest-ness of the type. Used in components_of_module to - keep track of type abbreviations (e.g. type t = float) in the - computation of label representations. *) - { env with - types = IdTbl.add id (info,([],[])) - env.types; - summary = Env_type(env.summary, id, info) } +(* Alternatively, we could keep the generic module type in the Parsetree + and extract the package type during type-checking. In that case, + the assertions below should be turned into explicit checks. *) +let package_type_of_module_type pmty = + let err loc s = + raise (Syntaxerr.Error (Syntaxerr.Invalid_package_type (loc, s))) + in + let map_cstr = function + | Pwith_type (lid, ptyp) -> + let loc = ptyp.ptype_loc in + if ptyp.ptype_params <> [] then + err loc "parametrized types are not supported"; + if ptyp.ptype_cstrs <> [] then + err loc "constrained types are not supported"; + if ptyp.ptype_private <> Public then + err loc "private types are not supported"; -and store_extension ~check id ext env = - let loc = ext.ext_loc in - if check && not loc.Location.loc_ghost && - Warnings.is_active (Warnings.Unused_extension ("", false, false, false)) - then begin - let is_exception = Path.same ext.ext_type_path Predef.path_exn in - let ty = Path.last ext.ext_type_path in - let n = Ident.name id in - let k = (ty, loc, n) in - if not (Hashtbl.mem used_constructors k) then begin - let used = constructor_usages () in - Hashtbl.add used_constructors k (add_constructor_usage used); - !add_delayed_check_forward - (fun () -> - if not (is_in_signature env) && not used.cu_positive then - Location.prerr_warning loc - (Warnings.Unused_extension - (n, is_exception, used.cu_pattern, used.cu_privatize) - ) - ) - end; - end; - { env with - constrs = TycompTbl.add id - (Datarepr.extension_descr (Pident id) ext) - env.constrs; - summary = Env_extension(env.summary, id, ext) } + (* restrictions below are checked by the 'with_constraint' rule *) + assert (ptyp.ptype_kind = Ptype_abstract); + assert (ptyp.ptype_attributes = []); + let ty = + match ptyp.ptype_manifest with + | Some ty -> ty + | None -> assert false + in + (lid, ty) + | _ -> + err pmty.pmty_loc "only 'with type t =' constraints are supported" + in + match pmty with + | {pmty_desc = Pmty_ident lid} -> (lid, []) + | {pmty_desc = Pmty_with({pmty_desc = Pmty_ident lid}, cstrs)} -> + (lid, List.map map_cstr cstrs) + | _ -> + err pmty.pmty_loc + "only module type identifier and 'with type' constraints are supported" -and store_module ~check id md env = - let loc = md.md_loc in - if check then - check_usage loc id (fun s -> Warnings.Unused_module s) - module_declarations; - let deprecated = Builtin_attributes.deprecated_of_attrs md.md_attributes in - { env with - modules = IdTbl.add id (EnvLazy.create (Subst.identity, md)) env.modules; - components = - IdTbl.add id - (components_of_module ~deprecated ~loc:md.md_loc - env Subst.identity (Pident id) md.md_type) - env.components; - summary = Env_module(env.summary, id, md) } +# 524 "parsing/parser.ml" +let yytransl_const = [| + 257 (* AMPERAMPER *); + 258 (* AMPERSAND *); + 259 (* AND *); + 260 (* AS *); + 261 (* ASSERT *); + 262 (* BACKQUOTE *); + 263 (* BANG *); + 264 (* BAR *); + 265 (* BARBAR *); + 266 (* BARRBRACKET *); + 267 (* BEGIN *); + 269 (* CLASS *); + 270 (* COLON *); + 271 (* COLONCOLON *); + 272 (* COLONEQUAL *); + 273 (* COLONGREATER *); + 274 (* COMMA *); + 275 (* CONSTRAINT *); + 276 (* DO *); + 277 (* DONE *); + 278 (* DOT *); + 279 (* DOTDOT *); + 280 (* DOWNTO *); + 281 (* ELSE *); + 282 (* END *); + 0 (* EOF *); + 283 (* EQUAL *); + 284 (* EXCEPTION *); + 285 (* EXTERNAL *); + 286 (* FALSE *); + 288 (* FOR *); + 289 (* FUN *); + 290 (* FUNCTION *); + 291 (* FUNCTOR *); + 292 (* GREATER *); + 293 (* GREATERRBRACE *); + 294 (* GREATERRBRACKET *); + 295 (* IF *); + 296 (* IN *); + 297 (* INCLUDE *); + 304 (* INHERIT *); + 305 (* INITIALIZER *); + 308 (* LAZY *); + 309 (* LBRACE *); + 310 (* LBRACELESS *); + 311 (* LBRACKET *); + 312 (* LBRACKETBAR *); + 313 (* LBRACKETLESS *); + 314 (* LBRACKETGREATER *); + 315 (* LBRACKETPERCENT *); + 316 (* LBRACKETPERCENTPERCENT *); + 317 (* LESS *); + 318 (* LESSMINUS *); + 319 (* LET *); + 321 (* LPAREN *); + 322 (* LBRACKETAT *); + 323 (* LBRACKETATAT *); + 324 (* LBRACKETATATAT *); + 325 (* MATCH *); + 326 (* METHOD *); + 327 (* MINUS *); + 328 (* MINUSDOT *); + 329 (* MINUSGREATER *); + 330 (* MODULE *); + 331 (* MUTABLE *); + 332 (* NEW *); + 333 (* NONREC *); + 334 (* OBJECT *); + 335 (* OF *); + 336 (* OPEN *); + 338 (* OR *); + 339 (* PERCENT *); + 340 (* PLUS *); + 341 (* PLUSDOT *); + 342 (* PLUSEQ *); + 344 (* PRIVATE *); + 345 (* QUESTION *); + 346 (* QUOTE *); + 347 (* RBRACE *); + 348 (* RBRACKET *); + 349 (* REC *); + 350 (* RPAREN *); + 351 (* SEMI *); + 352 (* SEMISEMI *); + 353 (* HASH *); + 355 (* SIG *); + 356 (* STAR *); + 358 (* STRUCT *); + 359 (* THEN *); + 360 (* TILDE *); + 361 (* TO *); + 362 (* TRUE *); + 363 (* TRY *); + 364 (* TYPE *); + 366 (* UNDERSCORE *); + 367 (* VAL *); + 368 (* VIRTUAL *); + 369 (* WHEN *); + 370 (* WHILE *); + 371 (* WITH *); + 374 (* EOL *); + 0|] -and store_modtype id info env = - { env with - modtypes = IdTbl.add id info env.modtypes; - summary = Env_modtype(env.summary, id, info) } +let yytransl_block = [| + 268 (* CHAR *); + 287 (* FLOAT *); + 298 (* INFIXOP0 *); + 299 (* INFIXOP1 *); + 300 (* INFIXOP2 *); + 301 (* INFIXOP3 *); + 302 (* INFIXOP4 *); + 303 (* DOTOP *); + 306 (* INT *); + 307 (* LABEL *); + 320 (* LIDENT *); + 337 (* OPTLABEL *); + 343 (* PREFIXOP *); + 354 (* HASHOP *); + 357 (* STRING *); + 365 (* UIDENT *); + 372 (* COMMENT *); + 373 (* DOCSTRING *); + 0|] + +let yylhs = "\255\255\ +\001\000\002\000\003\000\003\000\003\000\010\000\010\000\014\000\ +\014\000\004\000\016\000\016\000\017\000\017\000\017\000\017\000\ +\017\000\017\000\017\000\005\000\006\000\007\000\020\000\020\000\ +\021\000\021\000\023\000\023\000\024\000\024\000\024\000\024\000\ +\024\000\024\000\024\000\024\000\024\000\027\000\027\000\027\000\ +\027\000\027\000\027\000\027\000\027\000\027\000\027\000\027\000\ +\008\000\008\000\032\000\032\000\032\000\015\000\015\000\015\000\ +\015\000\015\000\015\000\015\000\015\000\015\000\015\000\015\000\ +\015\000\015\000\015\000\015\000\045\000\049\000\049\000\049\000\ +\039\000\040\000\040\000\050\000\051\000\022\000\022\000\022\000\ +\022\000\022\000\022\000\022\000\022\000\022\000\022\000\022\000\ +\009\000\009\000\009\000\054\000\054\000\054\000\054\000\054\000\ +\054\000\054\000\054\000\054\000\054\000\054\000\054\000\054\000\ +\054\000\054\000\042\000\060\000\063\000\063\000\063\000\057\000\ +\058\000\059\000\059\000\064\000\065\000\066\000\066\000\041\000\ +\043\000\043\000\068\000\069\000\072\000\072\000\072\000\071\000\ +\071\000\077\000\077\000\073\000\073\000\073\000\073\000\073\000\ +\073\000\073\000\078\000\078\000\078\000\078\000\078\000\078\000\ +\078\000\078\000\082\000\083\000\083\000\083\000\084\000\084\000\ +\085\000\085\000\085\000\085\000\085\000\085\000\085\000\086\000\ +\086\000\087\000\087\000\087\000\087\000\088\000\088\000\088\000\ +\088\000\088\000\074\000\074\000\074\000\074\000\074\000\097\000\ +\097\000\097\000\097\000\097\000\097\000\097\000\100\000\101\000\ +\101\000\102\000\102\000\103\000\103\000\103\000\103\000\103\000\ +\103\000\104\000\104\000\104\000\106\000\089\000\061\000\061\000\ +\107\000\108\000\044\000\044\000\109\000\110\000\012\000\012\000\ +\012\000\012\000\075\000\075\000\075\000\075\000\075\000\075\000\ +\075\000\075\000\116\000\116\000\113\000\113\000\112\000\112\000\ +\114\000\115\000\115\000\030\000\030\000\030\000\030\000\030\000\ +\030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ +\030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ +\030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ +\030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ +\030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ +\030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ +\030\000\030\000\030\000\030\000\030\000\030\000\118\000\118\000\ +\118\000\118\000\118\000\118\000\118\000\118\000\118\000\118\000\ +\118\000\118\000\118\000\118\000\118\000\118\000\118\000\118\000\ +\118\000\118\000\118\000\118\000\118\000\118\000\118\000\118\000\ +\118\000\118\000\118\000\118\000\118\000\118\000\118\000\118\000\ +\118\000\118\000\118\000\118\000\118\000\118\000\118\000\118\000\ +\118\000\118\000\118\000\118\000\118\000\118\000\118\000\118\000\ +\118\000\118\000\118\000\118\000\118\000\118\000\118\000\118\000\ +\118\000\118\000\118\000\118\000\118\000\118\000\079\000\079\000\ +\136\000\136\000\137\000\137\000\137\000\137\000\138\000\096\000\ +\096\000\139\000\139\000\139\000\139\000\139\000\139\000\033\000\ +\033\000\144\000\145\000\147\000\147\000\095\000\095\000\095\000\ +\121\000\121\000\148\000\148\000\148\000\122\000\122\000\122\000\ +\122\000\123\000\123\000\132\000\132\000\150\000\150\000\150\000\ +\151\000\151\000\135\000\135\000\153\000\153\000\133\000\133\000\ +\092\000\092\000\092\000\092\000\092\000\152\000\152\000\019\000\ +\019\000\019\000\019\000\019\000\019\000\019\000\019\000\019\000\ +\019\000\142\000\142\000\142\000\142\000\142\000\142\000\142\000\ +\142\000\142\000\155\000\155\000\155\000\155\000\117\000\117\000\ +\143\000\143\000\143\000\143\000\143\000\143\000\143\000\143\000\ +\143\000\143\000\143\000\143\000\143\000\143\000\143\000\143\000\ +\143\000\143\000\143\000\143\000\143\000\143\000\159\000\159\000\ +\159\000\159\000\159\000\159\000\159\000\154\000\154\000\154\000\ +\156\000\156\000\156\000\161\000\161\000\160\000\160\000\160\000\ +\160\000\162\000\162\000\163\000\163\000\035\000\164\000\164\000\ +\034\000\036\000\036\000\165\000\166\000\170\000\170\000\169\000\ +\169\000\169\000\169\000\169\000\169\000\169\000\169\000\169\000\ +\169\000\169\000\168\000\168\000\168\000\173\000\174\000\174\000\ +\176\000\176\000\177\000\175\000\175\000\175\000\178\000\076\000\ +\076\000\171\000\171\000\171\000\179\000\180\000\038\000\038\000\ +\056\000\119\000\182\000\182\000\182\000\182\000\183\000\183\000\ +\172\000\172\000\172\000\185\000\186\000\037\000\055\000\188\000\ +\188\000\188\000\188\000\188\000\188\000\189\000\189\000\189\000\ +\190\000\191\000\192\000\193\000\053\000\053\000\194\000\194\000\ +\194\000\194\000\195\000\195\000\141\000\141\000\093\000\093\000\ +\187\000\187\000\018\000\018\000\196\000\196\000\198\000\198\000\ +\198\000\198\000\198\000\149\000\149\000\199\000\199\000\199\000\ +\199\000\199\000\199\000\199\000\199\000\199\000\199\000\199\000\ +\199\000\199\000\199\000\199\000\199\000\199\000\199\000\199\000\ +\031\000\202\000\202\000\203\000\203\000\201\000\201\000\205\000\ +\205\000\206\000\206\000\204\000\204\000\098\000\098\000\080\000\ +\080\000\184\000\184\000\200\000\200\000\200\000\200\000\200\000\ +\200\000\200\000\209\000\207\000\208\000\090\000\131\000\131\000\ +\131\000\131\000\157\000\157\000\157\000\157\000\157\000\067\000\ +\067\000\140\000\140\000\140\000\140\000\140\000\210\000\210\000\ +\210\000\210\000\210\000\210\000\210\000\210\000\210\000\210\000\ +\210\000\210\000\210\000\210\000\210\000\210\000\210\000\210\000\ +\210\000\210\000\210\000\210\000\210\000\210\000\210\000\210\000\ +\210\000\210\000\210\000\181\000\181\000\181\000\181\000\181\000\ +\181\000\130\000\130\000\124\000\124\000\124\000\124\000\124\000\ +\124\000\124\000\129\000\129\000\158\000\158\000\025\000\025\000\ +\197\000\197\000\197\000\052\000\052\000\099\000\099\000\081\000\ +\081\000\011\000\011\000\011\000\011\000\011\000\011\000\011\000\ +\125\000\146\000\146\000\167\000\167\000\126\000\126\000\094\000\ +\094\000\091\000\091\000\070\000\070\000\105\000\105\000\105\000\ +\105\000\105\000\062\000\062\000\120\000\120\000\134\000\134\000\ +\127\000\127\000\128\000\128\000\211\000\211\000\211\000\211\000\ +\211\000\211\000\211\000\211\000\211\000\211\000\211\000\211\000\ +\211\000\211\000\211\000\211\000\211\000\211\000\211\000\211\000\ +\211\000\211\000\211\000\211\000\211\000\211\000\211\000\211\000\ +\211\000\211\000\211\000\211\000\211\000\211\000\211\000\211\000\ +\211\000\211\000\211\000\211\000\211\000\211\000\211\000\211\000\ +\211\000\211\000\211\000\211\000\211\000\211\000\211\000\111\000\ +\111\000\028\000\213\000\047\000\013\000\013\000\026\000\026\000\ +\048\000\048\000\048\000\029\000\046\000\212\000\212\000\212\000\ +\212\000\212\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000" + +let yylen = "\002\000\ +\002\000\002\000\002\000\002\000\001\000\002\000\001\000\000\000\ +\002\000\001\000\001\000\003\000\001\000\002\000\004\000\003\000\ +\003\000\002\000\002\000\002\000\002\000\002\000\002\000\005\000\ +\001\000\001\000\002\000\001\000\001\000\004\000\004\000\005\000\ +\002\000\003\000\001\000\002\000\001\000\005\000\005\000\003\000\ +\003\000\005\000\007\000\009\000\007\000\006\000\006\000\005\000\ +\003\000\001\000\000\000\002\000\002\000\001\000\001\000\001\000\ +\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\ +\001\000\001\000\002\000\001\000\004\000\002\000\004\000\002\000\ +\005\000\001\000\002\000\006\000\005\000\001\000\004\000\004\000\ +\005\000\003\000\003\000\005\000\003\000\003\000\001\000\002\000\ +\000\000\002\000\002\000\001\000\001\000\001\000\001\000\001\000\ +\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\ +\002\000\001\000\005\000\004\000\002\000\006\000\003\000\005\000\ +\006\000\001\000\002\000\007\000\006\000\000\000\002\000\006\000\ +\001\000\002\000\007\000\007\000\002\000\004\000\002\000\000\000\ +\003\000\003\000\002\000\001\000\003\000\002\000\003\000\007\000\ +\002\000\001\000\004\000\001\000\004\000\004\000\005\000\005\000\ +\003\000\003\000\002\000\003\000\005\000\000\000\000\000\002\000\ +\006\000\003\000\003\000\004\000\004\000\002\000\001\000\002\000\ +\000\000\007\000\007\000\006\000\007\000\007\000\007\000\005\000\ +\008\000\011\000\001\000\006\000\004\000\005\000\003\000\004\000\ +\001\000\004\000\004\000\002\000\001\000\007\000\002\000\003\000\ +\000\000\000\000\002\000\004\000\004\000\007\000\004\000\002\000\ +\001\000\005\000\005\000\003\000\003\000\003\000\001\000\002\000\ +\008\000\008\000\001\000\002\000\009\000\008\000\001\000\002\000\ +\003\000\005\000\005\000\002\000\005\000\002\000\004\000\002\000\ +\002\000\001\000\001\000\001\000\000\000\002\000\001\000\003\000\ +\001\000\001\000\003\000\001\000\002\000\003\000\007\000\006\000\ +\007\000\004\000\004\000\007\000\006\000\006\000\005\000\001\000\ +\002\000\002\000\007\000\005\000\006\000\010\000\003\000\003\000\ +\003\000\003\000\003\000\003\000\003\000\003\000\003\000\003\000\ +\003\000\003\000\003\000\003\000\003\000\003\000\003\000\003\000\ +\003\000\003\000\003\000\002\000\002\000\005\000\007\000\007\000\ +\007\000\007\000\007\000\007\000\009\000\009\000\009\000\003\000\ +\003\000\003\000\004\000\004\000\002\000\001\000\001\000\001\000\ +\001\000\001\000\003\000\003\000\004\000\003\000\004\000\004\000\ +\003\000\005\000\004\000\005\000\005\000\005\000\005\000\005\000\ +\005\000\005\000\005\000\005\000\005\000\005\000\007\000\007\000\ +\007\000\007\000\007\000\007\000\005\000\005\000\003\000\003\000\ +\005\000\005\000\004\000\004\000\002\000\006\000\004\000\006\000\ +\004\000\004\000\006\000\004\000\006\000\002\000\002\000\003\000\ +\003\000\003\000\002\000\005\000\004\000\005\000\003\000\003\000\ +\005\000\007\000\006\000\009\000\008\000\001\000\001\000\002\000\ +\001\000\001\000\002\000\002\000\002\000\002\000\001\000\001\000\ +\002\000\002\000\004\000\007\000\008\000\003\000\005\000\001\000\ +\002\000\005\000\004\000\001\000\003\000\002\000\002\000\005\000\ +\001\000\003\000\003\000\005\000\003\000\002\000\004\000\002\000\ +\005\000\003\000\003\000\003\000\001\000\001\000\003\000\002\000\ +\004\000\002\000\002\000\003\000\003\000\001\000\001\000\003\000\ +\002\000\004\000\002\000\002\000\002\000\001\000\000\000\003\000\ +\003\000\001\000\003\000\003\000\003\000\003\000\003\000\002\000\ +\001\000\003\000\003\000\001\000\003\000\003\000\003\000\003\000\ +\002\000\001\000\001\000\002\000\002\000\003\000\001\000\001\000\ +\001\000\001\000\003\000\001\000\001\000\002\000\001\000\003\000\ +\004\000\004\000\005\000\005\000\004\000\003\000\003\000\005\000\ +\005\000\004\000\005\000\007\000\007\000\001\000\003\000\003\000\ +\004\000\004\000\004\000\002\000\004\000\003\000\003\000\003\000\ +\003\000\003\000\003\000\001\000\003\000\001\000\002\000\004\000\ +\003\000\004\000\002\000\002\000\000\000\006\000\001\000\002\000\ +\008\000\001\000\002\000\008\000\007\000\003\000\000\000\000\000\ +\002\000\003\000\002\000\003\000\002\000\003\000\005\000\005\000\ +\005\000\007\000\000\000\001\000\003\000\002\000\001\000\003\000\ +\002\000\001\000\002\000\000\000\001\000\001\000\002\000\001\000\ +\003\000\001\000\001\000\002\000\003\000\004\000\001\000\007\000\ +\006\000\003\000\000\000\002\000\004\000\002\000\001\000\003\000\ +\001\000\001\000\002\000\005\000\007\000\009\000\009\000\001\000\ +\001\000\001\000\001\000\002\000\002\000\001\000\001\000\002\000\ +\003\000\004\000\004\000\005\000\001\000\003\000\006\000\005\000\ +\004\000\004\000\001\000\002\000\002\000\003\000\001\000\003\000\ +\001\000\003\000\001\000\002\000\001\000\004\000\001\000\006\000\ +\004\000\005\000\003\000\001\000\003\000\002\000\001\000\001\000\ +\002\000\004\000\003\000\002\000\002\000\003\000\005\000\003\000\ +\004\000\005\000\004\000\002\000\004\000\006\000\005\000\001\000\ +\001\000\001\000\003\000\001\000\001\000\005\000\002\000\001\000\ +\000\000\001\000\003\000\001\000\002\000\001\000\003\000\001\000\ +\003\000\001\000\003\000\002\000\002\000\001\000\001\000\001\000\ +\001\000\001\000\004\000\006\000\002\000\001\000\001\000\001\000\ +\001\000\001\000\001\000\002\000\002\000\002\000\002\000\001\000\ +\001\000\001\000\003\000\003\000\002\000\003\000\001\000\001\000\ +\001\000\001\000\001\000\001\000\003\000\004\000\003\000\004\000\ +\003\000\004\000\001\000\001\000\001\000\001\000\001\000\001\000\ +\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\ +\001\000\001\000\001\000\001\000\002\000\002\000\003\000\001\000\ +\001\000\001\000\003\000\001\000\005\000\002\000\002\000\003\000\ +\001\000\001\000\001\000\003\000\001\000\003\000\001\000\003\000\ +\001\000\003\000\004\000\001\000\003\000\001\000\003\000\001\000\ +\003\000\002\000\003\000\003\000\003\000\003\000\003\000\003\000\ +\002\000\000\000\001\000\000\000\001\000\001\000\001\000\000\000\ +\001\000\000\000\001\000\000\000\001\000\000\000\001\000\001\000\ +\002\000\002\000\000\000\001\000\000\000\001\000\000\000\001\000\ +\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\ +\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\ +\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\ +\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\ +\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\ +\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\ +\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\ +\003\000\004\000\004\000\004\000\000\000\002\000\000\000\002\000\ +\000\000\002\000\003\000\004\000\004\000\001\000\002\000\002\000\ +\002\000\004\000\002\000\002\000\002\000\002\000\002\000\002\000\ +\002\000" -and store_class id desc env = - { env with - classes = IdTbl.add id desc env.classes; - summary = Env_class(env.summary, id, desc) } +let yydefred = "\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\112\002\000\000\000\000\000\000\ +\169\002\114\002\000\000\000\000\000\000\000\000\000\000\111\002\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\217\002\218\002\000\000\000\000\ +\000\000\000\000\219\002\220\002\000\000\000\000\113\002\170\002\ +\000\000\000\000\175\002\030\001\000\000\000\000\035\003\000\000\ +\000\000\000\000\000\000\094\001\000\000\050\000\000\000\055\000\ +\056\000\000\000\058\000\059\000\060\000\000\000\062\000\063\000\ +\000\000\000\000\066\000\000\000\068\000\074\000\007\002\121\000\ +\000\000\203\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\031\001\032\001\162\002\112\001\226\001\000\000\000\000\000\000\ +\000\000\000\000\000\000\036\003\000\000\093\000\092\000\000\000\ +\100\000\101\000\000\000\000\000\106\000\000\000\095\000\096\000\ +\097\000\098\000\000\000\102\000\000\000\114\000\199\000\005\000\ +\000\000\037\003\000\000\000\000\000\000\007\000\000\000\013\000\ +\000\000\038\003\000\000\000\000\000\000\010\000\011\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\177\002\063\002\039\003\000\000\080\002\055\002\000\000\ +\064\002\051\002\000\000\000\000\000\000\040\003\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\122\002\000\000\000\000\ +\000\000\000\000\177\001\041\003\000\000\000\000\198\001\171\001\ +\000\000\000\000\115\002\175\001\176\001\000\000\161\001\000\000\ +\183\001\000\000\000\000\000\000\000\000\121\002\120\002\193\002\ +\079\001\033\001\034\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\133\001\000\000\083\001\110\002\000\000\ +\000\000\000\000\166\002\000\000\000\000\069\001\000\000\223\002\ +\224\002\225\002\226\002\227\002\228\002\229\002\230\002\231\002\ +\232\002\233\002\234\002\235\002\236\002\237\002\238\002\239\002\ +\240\002\241\002\242\002\243\002\244\002\245\002\246\002\247\002\ +\221\002\248\002\249\002\250\002\251\002\252\002\253\002\254\002\ +\255\002\000\003\001\003\002\003\003\003\004\003\005\003\006\003\ +\007\003\008\003\009\003\010\003\222\002\011\003\012\003\013\003\ +\014\003\015\003\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\125\002\152\002\151\002\000\000\150\002\000\000\153\002\ +\146\002\148\002\128\002\129\002\130\002\131\002\132\002\000\000\ +\147\002\000\000\000\000\000\000\149\002\155\002\000\000\000\000\ +\154\002\000\000\167\002\139\002\145\002\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\212\002\000\000\078\001\ +\052\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\ +\000\000\000\000\053\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\029\001\000\000\000\000\113\001\ +\000\000\227\001\000\000\075\000\000\000\122\000\000\000\204\000\ +\067\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\095\001\098\001\000\000\000\000\ +\000\000\012\001\013\001\000\000\000\000\000\000\000\000\090\000\ +\000\000\002\000\105\000\091\000\000\000\115\000\000\000\200\000\ +\000\000\003\000\004\000\006\000\009\000\014\000\000\000\000\000\ +\000\000\019\000\000\000\018\000\000\000\173\002\000\000\085\002\ +\000\000\000\000\214\002\000\000\076\002\000\000\106\002\068\002\ +\000\000\000\000\000\000\000\000\000\000\000\000\103\002\000\000\ +\000\000\000\000\000\000\000\000\000\000\062\002\184\002\000\000\ +\069\002\020\000\052\002\000\000\000\000\000\000\000\000\000\000\ +\000\000\065\002\021\000\000\000\000\000\171\002\000\000\000\000\ +\000\000\000\000\000\000\000\000\204\001\000\000\140\002\000\000\ +\144\002\000\000\000\000\142\002\127\002\000\000\117\002\116\002\ +\119\002\118\002\182\001\000\000\000\000\000\000\000\000\022\000\ +\160\001\000\000\172\001\173\001\000\000\000\000\000\000\000\000\ +\026\003\000\000\000\000\000\000\000\000\038\001\000\000\000\000\ +\205\002\000\000\160\002\000\000\000\000\161\002\156\002\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\218\000\180\001\181\001\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\035\000\037\000\000\000\000\000\000\000\ +\000\000\000\000\150\001\000\000\064\001\063\001\000\000\000\000\ +\082\001\081\001\000\000\139\001\000\000\000\000\000\000\000\000\ +\000\000\030\003\000\000\000\000\000\000\000\000\000\000\000\000\ +\195\002\000\000\168\002\000\000\000\000\000\000\126\002\000\000\ +\036\001\035\001\000\000\124\002\123\002\000\000\000\000\000\000\ +\000\000\000\000\080\001\000\000\000\000\151\000\000\000\000\000\ +\197\002\000\000\000\000\000\000\000\000\049\000\022\003\000\000\ +\000\000\000\000\000\000\000\000\176\002\163\002\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\209\000\000\000\000\000\230\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\103\001\ +\101\001\087\001\000\000\100\001\096\001\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\087\000\078\000\ +\180\002\000\000\000\000\000\000\000\000\000\000\000\000\191\002\ +\188\002\187\002\192\002\000\000\189\002\017\000\000\000\016\000\ +\012\000\084\002\000\000\082\002\000\000\087\002\072\002\000\000\ +\000\000\000\000\000\000\109\002\067\002\100\002\101\002\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\098\002\000\000\ +\174\002\178\002\000\000\000\000\000\000\070\002\159\001\174\001\ +\000\000\000\000\000\000\200\001\199\001\000\000\000\000\000\000\ +\000\000\000\000\191\001\000\000\190\001\153\001\152\001\158\001\ +\000\000\156\001\000\000\208\001\000\000\000\000\000\000\184\001\ +\000\000\179\001\000\000\027\003\024\003\000\000\000\000\000\000\ +\000\000\041\001\000\000\000\000\000\000\039\001\037\001\000\000\ +\000\000\000\000\157\002\000\000\158\002\000\000\000\000\000\000\ +\000\000\143\002\000\000\141\002\000\000\000\000\217\000\000\000\ +\219\000\000\000\220\000\214\000\225\000\000\000\212\000\000\000\ +\216\000\000\000\000\000\000\000\000\000\235\000\000\000\000\000\ +\121\001\000\000\000\000\000\000\000\000\000\000\000\000\069\000\ +\033\000\036\000\000\000\000\000\132\001\148\001\000\000\149\001\ +\000\000\000\000\135\001\000\000\140\001\000\000\074\001\073\001\ +\068\001\067\001\031\003\000\000\000\000\028\003\017\003\029\003\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\170\001\000\000\000\000\000\000\000\000\000\000\040\001\020\003\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\028\001\027\001\000\000\000\000\000\000\000\000\254\001\ +\253\001\000\000\244\001\000\000\000\000\000\000\000\000\000\000\ +\085\001\000\000\076\001\000\000\071\001\000\000\000\000\000\000\ +\043\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\108\000\088\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\015\000\000\000\073\002\088\002\ +\000\000\000\000\000\000\077\002\075\002\000\000\000\000\000\000\ +\049\002\000\000\000\000\000\000\000\000\000\000\066\002\000\000\ +\000\000\185\002\000\000\000\000\179\002\054\002\172\002\000\000\ +\000\000\000\000\217\001\000\000\202\001\201\001\205\001\203\001\ +\000\000\194\001\000\000\185\001\189\001\186\001\000\000\018\003\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\002\000\000\159\002\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\012\002\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\126\001\128\001\000\000\000\000\000\000\000\000\ +\028\000\000\000\000\000\041\000\000\000\040\000\000\000\034\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\114\001\ +\000\000\000\000\000\000\000\000\000\000\106\001\000\000\000\000\ +\000\000\000\000\000\000\169\001\000\000\000\000\138\002\136\002\ +\134\002\000\000\089\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\023\000\025\000\026\000\000\000\072\000\073\000\000\000\ +\148\000\000\000\000\000\000\000\000\000\000\000\000\000\159\000\ +\152\000\107\000\239\000\000\000\247\001\000\000\000\000\000\000\ +\000\000\250\001\246\001\000\000\000\000\019\003\066\001\065\001\ +\086\001\084\001\000\000\000\000\165\002\000\000\044\001\042\001\ +\210\000\115\001\000\000\000\000\000\000\000\000\000\000\062\001\ +\048\001\000\000\046\001\000\000\000\000\000\000\000\000\000\000\ +\054\001\000\000\050\001\000\000\052\001\000\000\000\000\000\000\ +\086\000\085\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\037\002\000\000\181\002\000\000\000\000\000\000\000\000\000\000\ +\112\000\000\000\000\000\000\000\083\002\090\002\000\000\074\002\ +\092\002\000\000\000\000\000\000\000\000\000\000\000\000\079\002\ +\071\002\000\000\099\002\000\000\216\002\216\001\000\000\195\001\ +\193\001\192\001\188\001\187\001\061\001\047\001\045\001\000\000\ +\000\000\000\000\053\001\049\001\051\001\000\000\000\000\129\000\ +\000\000\251\001\000\000\000\000\000\000\000\000\203\002\000\000\ +\000\000\017\002\000\000\000\000\000\000\000\000\009\002\000\000\ +\199\002\198\002\000\000\105\001\000\000\000\000\000\000\000\000\ +\000\000\000\000\215\000\000\000\000\000\125\001\123\001\000\000\ +\122\001\000\000\000\000\027\000\000\000\000\000\031\000\030\000\ +\000\000\034\003\232\000\010\002\000\000\000\000\000\000\000\000\ +\118\001\000\000\000\000\116\001\119\001\000\000\163\001\162\001\ +\168\001\000\000\166\001\000\000\211\001\000\000\110\001\000\000\ +\000\000\091\001\000\000\000\000\000\000\120\000\076\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\158\000\000\000\000\000\245\001\000\000\231\001\000\000\ +\249\001\222\001\245\000\077\001\075\001\072\001\070\001\000\000\ +\231\001\077\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\080\000\079\000\000\000\000\000\000\000\000\000\113\000\111\000\ +\000\000\000\000\000\000\000\000\000\000\086\002\078\002\093\002\ +\050\002\046\002\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\001\002\255\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\177\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\138\000\000\000\000\000\000\000\ +\140\000\123\000\127\000\000\000\016\002\019\002\013\002\000\000\ +\008\002\000\000\000\000\000\000\236\000\000\000\222\000\213\000\ +\211\000\000\000\127\001\000\000\000\000\000\000\000\000\048\000\ +\000\000\000\000\042\000\039\000\038\000\231\000\233\000\000\000\ +\000\000\000\000\000\000\107\001\000\000\090\001\000\000\000\000\ +\149\000\000\000\000\000\000\000\000\000\000\000\155\000\000\000\ +\154\000\248\001\000\000\237\001\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\002\002\003\002\000\000\000\000\201\002\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\060\001\000\000\056\001\000\000\058\001\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\038\002\ +\116\000\000\000\000\000\117\000\000\000\091\002\108\002\197\001\ +\196\001\059\001\055\001\057\001\000\000\182\002\181\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\180\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\137\000\000\000\000\000\224\001\225\001\000\000\ +\129\001\124\001\046\000\000\000\047\000\000\000\000\000\000\000\ +\000\000\117\001\111\001\024\000\000\000\156\000\000\000\157\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\238\001\ +\000\000\000\000\000\000\000\000\004\002\000\000\000\000\228\001\ +\000\000\000\000\000\000\024\002\025\002\026\002\027\002\093\001\ +\000\000\229\001\124\000\000\000\000\000\000\000\000\000\201\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\030\002\031\002\000\000\205\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\186\000\000\000\000\000\000\000\175\000\ +\000\000\000\000\133\000\000\000\000\000\146\000\000\000\145\000\ +\000\000\000\000\000\000\000\000\000\000\043\000\045\000\000\000\ +\000\000\120\001\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\005\002\000\000\ +\230\001\000\000\000\000\000\000\022\002\028\002\029\002\092\001\ +\206\000\000\000\000\000\000\000\040\002\044\002\231\001\110\000\ +\000\000\023\002\032\002\202\000\183\002\176\000\000\000\000\000\ +\000\000\179\000\178\000\000\000\173\000\000\000\000\000\131\000\ +\139\000\000\000\000\000\142\000\141\000\000\000\246\000\000\000\ +\000\000\108\001\160\000\153\000\000\000\000\000\000\000\168\000\ +\000\000\000\000\000\000\000\000\006\002\241\001\000\000\000\000\ +\239\001\000\000\000\000\000\000\000\000\033\002\000\000\000\000\ +\174\000\184\000\000\000\000\000\000\000\000\000\000\000\193\000\ +\187\000\000\000\000\000\000\000\144\000\143\000\000\000\044\000\ +\109\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\164\000\000\000\000\000\000\000\000\000\034\002\035\002\ +\000\000\000\000\000\000\000\000\000\000\192\000\172\000\000\000\ +\021\002\166\000\167\000\000\000\000\000\000\000\000\000\000\000\ +\165\000\242\001\036\002\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\169\000\ +\000\000\191\000\188\000\209\002\210\002\000\000\000\000\000\000\ +\000\000\189\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\170\000\190\000\000\000\000\000" -and store_cltype id desc env = - { env with - cltypes = IdTbl.add id desc env.cltypes; - summary = Env_cltype(env.summary, id, desc) } +let yydgoto = "\008\000\ +\055\000\100\000\122\000\130\000\148\000\158\000\172\000\034\002\ +\101\000\123\000\131\000\057\000\072\001\126\000\058\000\134\000\ +\135\000\178\001\214\001\055\003\245\003\131\003\202\003\005\003\ +\059\000\233\001\012\002\101\001\060\000\061\000\132\003\062\000\ +\160\000\064\000\065\000\066\000\067\000\068\000\069\000\070\000\ +\071\000\072\000\073\000\074\000\075\000\076\000\077\000\025\001\ +\056\003\078\000\108\001\136\002\056\004\110\000\111\000\079\000\ +\113\000\114\000\115\000\116\000\117\000\063\001\112\003\118\000\ +\142\001\238\003\137\002\080\000\110\001\242\001\226\002\109\004\ +\007\005\251\004\253\002\169\003\211\005\008\005\123\001\179\001\ +\009\005\061\002\062\002\060\003\001\004\229\005\185\004\183\004\ +\051\005\081\000\112\004\155\004\070\006\066\005\156\004\187\003\ +\252\004\151\000\254\004\203\005\204\005\012\006\057\006\109\006\ +\105\006\241\005\119\000\144\001\082\000\112\001\019\001\190\003\ +\128\004\191\003\189\003\244\002\176\000\083\000\033\003\164\001\ +\000\003\254\002\084\000\085\000\086\000\123\004\087\000\088\000\ +\210\000\089\000\090\000\211\000\221\000\028\002\217\000\125\001\ +\126\001\121\002\037\003\091\000\071\006\039\003\181\000\092\000\ +\104\001\042\002\157\004\001\003\152\000\212\000\213\000\020\002\ +\218\000\182\000\183\000\042\003\184\000\153\000\185\000\201\001\ +\204\001\202\001\187\002\019\005\093\000\106\001\066\002\066\003\ +\191\004\071\005\067\005\113\004\067\003\006\004\068\003\011\004\ +\171\003\106\004\068\005\069\005\070\005\233\002\176\003\177\003\ +\114\004\115\004\128\003\171\005\193\005\172\005\173\005\174\005\ +\175\005\057\004\189\005\154\000\155\000\156\000\157\000\172\001\ +\154\002\155\002\156\002\074\004\121\003\071\004\173\001\174\001\ +\175\001\055\001\020\001\035\002\073\001" -(* Compute the components of a functor application in a path. *) +let yysindex = "\141\009\ +\228\067\075\007\170\051\083\051\204\051\233\070\196\074\000\000\ +\155\005\110\002\080\074\155\005\000\000\184\003\155\005\155\005\ +\000\000\000\000\155\005\155\005\155\005\155\005\155\005\000\000\ +\155\005\225\076\083\004\058\068\146\068\170\063\170\063\014\004\ +\000\000\024\061\170\063\155\005\000\000\000\000\087\005\155\005\ +\155\005\134\255\000\000\000\000\080\074\228\067\000\000\000\000\ +\155\005\155\005\000\000\000\000\155\005\155\005\000\000\160\000\ +\229\255\096\018\048\000\000\000\151\080\000\000\108\004\000\000\ +\000\000\195\000\000\000\000\000\000\000\075\001\000\000\000\000\ +\110\001\176\001\000\000\229\255\000\000\000\000\000\000\000\000\ +\171\000\000\000\105\076\218\001\080\074\080\074\233\070\233\070\ +\000\000\000\000\000\000\000\000\000\000\184\003\155\005\155\005\ +\087\005\075\007\155\005\000\000\049\003\000\000\000\000\195\000\ +\000\000\000\000\176\001\229\255\000\000\075\007\000\000\000\000\ +\000\000\000\000\128\002\000\000\177\002\000\000\000\000\000\000\ +\110\002\000\000\137\002\160\002\229\255\000\000\143\005\000\000\ +\035\052\000\000\171\007\229\255\171\007\000\000\000\000\151\044\ +\000\004\085\255\082\013\202\003\041\048\204\051\206\003\110\002\ +\058\003\000\000\000\000\000\000\070\000\000\000\000\000\222\003\ +\000\000\000\000\030\002\126\001\097\003\000\000\071\005\108\004\ +\155\005\155\005\208\003\199\073\006\074\000\000\136\065\090\003\ +\235\005\069\004\000\000\000\000\175\000\106\004\000\000\000\000\ +\196\074\196\074\000\000\000\000\000\000\162\004\000\000\154\004\ +\000\000\170\063\170\063\116\004\080\074\000\000\000\000\000\000\ +\000\000\000\000\000\000\231\068\155\005\147\004\023\002\116\003\ +\196\074\244\072\000\004\233\070\143\002\080\074\000\000\002\005\ +\070\001\197\003\149\255\000\000\241\004\000\000\000\000\092\005\ +\146\004\046\005\000\000\110\081\057\005\000\000\057\005\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\141\067\192\005\141\067\155\005\155\005\134\255\ +\162\005\000\000\000\000\000\000\080\074\000\000\154\005\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\203\006\ +\000\000\000\000\000\000\131\001\000\000\000\000\000\000\000\000\ +\000\000\080\074\000\000\000\000\000\000\156\000\166\255\141\067\ +\233\070\155\005\184\005\058\003\001\006\000\000\155\005\000\000\ +\000\000\233\070\211\005\116\003\233\070\000\000\170\063\096\018\ +\229\255\155\005\000\000\075\006\209\005\233\070\233\070\233\070\ +\233\070\233\070\233\070\233\070\233\070\233\070\233\070\233\070\ +\233\070\233\070\233\070\233\070\233\070\233\070\233\070\233\070\ +\233\070\233\070\060\069\233\070\000\000\116\004\233\070\000\000\ +\116\004\000\000\116\004\000\000\116\004\000\000\116\004\000\000\ +\000\000\233\070\169\004\225\006\080\074\080\074\027\006\068\006\ +\080\074\027\006\165\076\043\002\000\000\000\000\233\070\043\002\ +\043\002\000\000\000\000\147\004\023\002\075\004\236\005\000\000\ +\211\005\000\000\000\000\000\000\116\004\000\000\116\004\000\000\ +\195\003\000\000\000\000\000\000\000\000\000\000\171\007\229\255\ +\171\007\000\000\171\007\000\000\136\012\000\000\130\005\000\000\ +\042\006\138\006\000\000\136\012\000\000\136\012\000\000\000\000\ +\000\000\134\006\060\006\133\006\170\040\170\040\000\000\204\051\ +\155\005\116\004\009\001\104\006\167\006\000\000\000\000\164\006\ +\000\000\000\000\000\000\216\041\077\004\081\006\098\006\204\051\ +\058\003\000\000\000\000\196\074\009\076\000\000\173\006\179\006\ +\206\255\107\006\070\005\109\006\000\000\109\006\000\000\090\003\ +\000\000\131\001\235\005\000\000\000\000\102\002\000\000\000\000\ +\000\000\000\000\000\000\033\002\031\066\092\066\153\066\000\000\ +\000\000\176\003\000\000\000\000\196\074\242\001\141\067\116\004\ +\000\000\116\004\043\002\058\005\231\006\000\000\041\003\147\004\ +\000\000\153\006\000\000\119\006\140\000\000\000\000\000\078\002\ +\188\077\208\006\178\003\009\076\059\064\125\002\245\005\050\006\ +\048\072\000\000\000\000\000\000\196\074\110\006\116\004\254\003\ +\116\004\026\007\205\006\000\000\000\000\043\002\255\007\208\003\ +\202\009\124\017\000\000\202\006\000\000\000\000\208\003\233\070\ +\000\000\000\000\068\006\000\000\233\070\104\255\211\004\013\082\ +\196\074\000\000\149\006\170\063\155\006\023\002\142\006\155\005\ +\000\000\116\075\000\000\157\006\161\006\175\006\000\000\143\002\ +\000\000\000\000\182\006\000\000\000\000\163\006\166\006\110\002\ +\158\006\084\003\000\000\196\074\120\003\000\000\186\006\189\006\ +\000\000\092\006\252\006\006\007\141\067\000\000\000\000\225\076\ +\038\005\145\069\233\069\135\061\000\000\000\000\235\081\235\081\ +\203\081\110\013\110\081\203\081\184\012\184\012\184\012\184\012\ +\053\004\255\006\255\006\184\012\053\004\053\004\203\081\255\006\ +\053\004\053\004\053\004\170\063\000\000\255\006\116\075\000\000\ +\092\006\207\006\147\004\147\004\110\081\233\070\233\070\233\070\ +\252\001\249\006\233\070\233\070\233\070\043\002\043\002\000\000\ +\000\000\000\000\065\004\000\000\000\000\203\081\153\006\151\255\ +\116\004\075\004\213\006\116\004\000\000\163\002\000\000\000\000\ +\000\000\175\002\216\006\041\004\092\006\221\006\147\004\000\000\ +\000\000\000\000\000\000\055\007\000\000\000\000\171\007\000\000\ +\000\000\000\000\253\255\000\000\078\007\000\000\000\000\136\012\ +\127\001\112\000\120\054\000\000\000\000\000\000\000\000\008\007\ +\075\004\204\051\015\005\204\051\204\051\135\004\000\000\239\006\ +\000\000\000\000\220\001\110\002\022\007\000\000\000\000\000\000\ +\194\004\204\051\070\007\000\000\000\000\203\004\196\074\174\000\ +\024\006\247\006\000\000\254\046\000\000\000\000\000\000\000\000\ +\141\002\000\000\091\007\000\000\035\002\067\074\226\065\000\000\ +\035\002\000\000\015\007\000\000\000\000\233\070\233\070\233\070\ +\160\005\000\000\233\070\233\070\233\070\000\000\000\000\153\006\ +\237\005\044\007\000\000\018\007\000\000\013\041\179\002\013\041\ +\116\004\000\000\114\007\000\000\204\051\233\070\000\000\051\007\ +\000\000\196\074\000\000\000\000\000\000\053\007\000\000\053\007\ +\000\000\216\041\170\064\233\070\048\072\000\000\182\255\111\007\ +\000\000\233\070\056\007\116\004\033\001\228\067\247\002\000\000\ +\000\000\000\000\017\007\000\000\000\000\000\000\108\255\000\000\ +\116\004\233\070\000\000\110\081\000\000\110\081\000\000\000\000\ +\000\000\000\000\000\000\116\004\247\000\000\000\000\000\000\000\ +\087\007\151\255\084\003\186\006\229\255\216\071\239\004\115\007\ +\000\000\110\007\068\007\069\007\071\007\139\001\000\000\000\000\ +\000\004\109\007\084\003\075\004\143\002\150\005\084\003\229\255\ +\210\002\000\000\000\000\167\001\183\002\018\000\237\005\000\000\ +\000\000\209\004\000\000\136\002\204\051\233\070\047\007\242\255\ +\000\000\251\004\000\000\057\005\000\000\057\005\046\007\131\001\ +\000\000\184\255\233\070\229\255\077\007\084\003\153\006\153\006\ +\212\080\151\001\192\000\194\255\245\006\233\070\011\078\043\078\ +\121\078\080\007\056\007\119\255\063\007\075\007\075\004\060\255\ +\000\000\000\000\028\005\131\007\075\004\186\006\205\005\229\255\ +\209\004\134\007\153\006\017\003\000\000\136\012\000\000\000\000\ +\204\051\218\000\144\007\000\000\000\000\110\002\111\001\116\004\ +\000\000\204\051\255\002\058\007\116\004\058\003\000\000\022\007\ +\081\007\000\000\216\041\048\007\000\000\000\000\000\000\116\004\ +\196\074\065\007\000\000\070\005\000\000\000\000\000\000\000\000\ +\087\001\000\000\129\255\000\000\000\000\000\000\053\003\000\000\ +\017\081\048\001\246\255\020\007\153\078\231\078\007\079\102\007\ +\129\001\082\007\000\000\129\072\000\000\092\007\000\000\095\007\ +\239\006\083\007\144\001\151\007\116\004\000\000\229\255\245\001\ +\102\000\051\007\084\007\108\006\150\007\150\007\165\007\093\007\ +\108\007\051\007\000\000\000\000\063\070\233\070\196\074\049\081\ +\000\000\201\003\233\070\000\000\075\004\000\000\150\003\000\000\ +\204\051\110\081\233\070\233\070\116\004\142\007\228\004\000\000\ +\162\015\233\070\025\065\021\072\164\007\000\000\152\002\214\066\ +\019\067\080\067\233\070\000\000\204\051\196\074\000\000\000\000\ +\000\000\122\000\000\000\196\074\075\004\229\255\229\255\107\001\ +\053\006\000\000\000\000\000\000\180\007\000\000\000\000\204\051\ +\000\000\116\004\134\255\116\004\134\255\134\255\229\255\000\000\ +\000\000\000\000\000\000\196\074\000\000\207\001\168\007\112\007\ +\110\002\000\000\000\000\151\006\175\007\000\000\000\000\000\000\ +\000\000\000\000\060\001\168\006\000\000\143\002\000\000\000\000\ +\000\000\000\000\168\007\229\255\137\007\139\007\147\007\000\000\ +\000\000\148\007\000\000\154\007\233\070\233\070\233\070\110\081\ +\000\000\157\007\000\000\158\007\000\000\159\007\199\007\033\006\ +\000\000\000\000\116\004\159\004\255\002\186\006\092\006\219\007\ +\000\000\000\000\000\000\075\004\255\002\183\002\098\002\211\007\ +\000\000\140\007\075\004\163\007\000\000\000\000\072\001\000\000\ +\000\000\172\255\000\000\204\051\110\002\138\007\022\007\000\000\ +\000\000\204\051\000\000\070\005\000\000\000\000\075\004\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\233\070\ +\233\070\233\070\000\000\000\000\000\000\202\007\237\005\000\000\ +\110\002\000\000\136\050\096\005\229\255\129\072\000\000\068\006\ +\141\007\000\000\092\007\216\041\009\002\229\255\000\000\135\007\ +\000\000\000\000\233\070\000\000\048\072\204\051\233\070\146\007\ +\149\007\204\051\000\000\233\070\152\007\000\000\000\000\162\007\ +\000\000\233\070\143\002\000\000\100\077\137\255\000\000\000\000\ +\116\004\000\000\000\000\000\000\233\070\233\070\051\007\142\001\ +\000\000\051\007\214\007\000\000\000\000\233\070\000\000\000\000\ +\000\000\141\002\000\000\091\007\000\000\035\002\000\000\121\002\ +\035\002\000\000\156\007\111\007\255\002\000\000\000\000\143\002\ +\075\004\248\003\204\051\116\004\233\070\116\004\229\255\116\004\ +\229\255\000\000\111\007\237\005\000\000\031\077\000\000\160\007\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\209\002\ +\000\000\000\000\129\072\215\007\233\070\233\070\233\070\094\079\ +\126\079\204\079\233\070\233\070\233\070\136\050\075\004\143\002\ +\000\000\000\000\148\006\208\003\060\255\163\002\000\000\000\000\ +\075\004\160\007\163\002\224\007\204\051\000\000\000\000\000\000\ +\000\000\000\000\116\004\022\007\059\000\236\079\058\080\090\080\ +\163\005\000\000\000\000\054\012\173\007\230\007\116\004\216\041\ +\190\007\000\000\231\007\116\004\186\007\000\000\190\002\116\004\ +\204\051\217\005\096\005\116\004\000\000\249\004\116\004\165\076\ +\000\000\000\000\000\000\246\007\000\000\000\000\000\000\247\007\ +\000\000\135\007\229\255\241\007\000\000\116\004\000\000\000\000\ +\000\000\116\004\000\000\048\072\233\070\110\081\053\006\000\000\ +\243\000\237\002\000\000\000\000\000\000\000\000\000\000\242\007\ +\204\051\172\007\233\070\000\000\233\070\000\000\053\006\100\005\ +\000\000\250\002\229\255\096\005\229\255\195\001\000\000\234\004\ +\000\000\000\000\023\002\000\000\127\049\148\014\097\047\000\000\ +\096\003\217\007\007\008\000\000\000\000\151\255\063\002\000\000\ +\150\255\078\003\063\002\229\255\163\005\110\081\110\081\110\081\ +\000\000\216\007\000\000\218\007\000\000\221\007\110\081\110\081\ +\110\081\229\255\255\002\053\006\081\006\081\006\043\005\000\000\ +\000\000\079\006\174\255\000\000\136\050\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\204\051\000\000\000\000\151\006\ +\229\002\190\001\222\003\134\255\216\041\208\007\203\007\014\008\ +\096\005\000\000\136\050\045\005\049\073\202\001\134\255\166\000\ +\001\006\096\005\000\000\165\076\120\054\000\000\000\000\233\070\ +\000\000\000\000\000\000\249\255\000\000\193\007\204\051\215\003\ +\021\072\000\000\000\000\000\000\204\051\000\000\025\001\000\000\ +\177\007\160\007\068\006\181\007\092\007\068\006\151\255\000\000\ +\116\004\007\008\160\007\092\007\000\000\116\004\204\051\000\000\ +\023\002\082\002\194\001\000\000\000\000\000\000\000\000\000\000\ +\201\007\000\000\000\000\151\006\233\070\233\070\233\070\000\000\ +\168\003\168\003\204\051\228\007\204\051\098\002\023\002\151\255\ +\248\001\000\000\000\000\229\255\000\000\053\005\068\005\116\004\ +\223\007\204\051\200\004\000\000\136\050\216\041\116\004\000\000\ +\000\000\217\072\000\000\058\003\116\004\000\000\136\050\000\000\ +\026\005\116\004\116\004\022\008\075\004\000\000\000\000\008\004\ +\233\070\000\000\116\004\238\007\229\255\068\006\068\006\156\072\ +\068\006\068\006\103\006\116\004\101\003\212\007\000\000\052\004\ +\000\000\246\002\179\002\116\004\000\000\000\000\000\000\000\000\ +\000\000\110\081\110\081\110\081\000\000\000\000\000\000\000\000\ +\151\255\000\000\000\000\000\000\000\000\000\000\186\006\136\050\ +\103\004\000\000\000\000\158\001\000\000\234\007\096\005\000\000\ +\000\000\186\006\159\000\000\000\000\000\222\007\000\000\227\007\ +\233\070\000\000\000\000\000\000\048\008\052\008\140\048\000\000\ +\054\008\056\008\233\070\050\008\000\000\000\000\092\007\007\008\ +\000\000\204\051\179\002\116\004\116\004\000\000\060\008\036\005\ +\000\000\000\000\116\004\116\004\116\004\116\004\229\255\000\000\ +\000\000\136\050\116\004\088\005\000\000\000\000\116\004\000\000\ +\000\000\120\054\120\054\051\007\116\004\053\008\238\001\204\051\ +\204\051\000\000\233\070\240\007\116\004\116\004\000\000\000\000\ +\163\005\204\051\163\005\220\003\033\003\000\000\000\000\096\005\ +\000\000\000\000\000\000\062\008\233\070\204\051\116\004\116\004\ +\000\000\000\000\000\000\116\004\229\255\151\006\225\007\250\007\ +\068\006\147\004\092\007\073\008\229\255\116\004\204\051\000\000\ +\116\004\000\000\000\000\000\000\000\000\074\008\068\006\068\006\ +\204\051\000\000\057\004\120\054\077\008\079\008\116\004\233\070\ +\229\255\204\051\204\051\000\000\000\000\116\004\116\004" -let components_of_functor_appl f env p1 p2 = - try - Hashtbl.find f.fcomp_cache p2 - with Not_found -> - let p = Papply(p1, p2) in - let sub = Subst.add_module f.fcomp_param p2 Subst.identity in - let mty = Subst.modtype sub f.fcomp_res in - let comps = components_of_module ~deprecated:None ~loc:Location.none - (*???*) - env Subst.identity p mty in - Hashtbl.add f.fcomp_cache p2 comps; - comps +let yyrindex = "\000\000\ +\094\009\095\009\000\008\000\000\000\000\000\000\000\000\000\000\ +\232\076\000\000\000\000\148\070\000\000\022\003\029\003\171\006\ +\000\000\000\000\001\075\076\073\135\074\062\071\230\002\000\000\ +\232\076\000\000\000\000\000\000\000\000\000\000\000\000\028\075\ +\012\019\000\000\000\000\062\071\000\000\000\000\246\005\069\005\ +\015\002\042\004\000\000\000\000\000\000\099\000\000\000\000\000\ +\062\071\149\008\000\000\000\000\171\006\062\071\000\000\000\000\ +\176\040\099\000\128\019\000\000\016\046\000\000\149\013\000\000\ +\000\000\114\015\000\000\000\000\000\000\113\059\000\000\000\000\ +\122\059\171\059\000\000\215\059\000\000\000\000\000\000\000\000\ +\000\000\000\000\058\027\174\027\081\026\197\026\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\022\003\029\003\131\004\ +\246\005\116\000\149\008\000\000\000\000\000\000\000\000\222\041\ +\000\000\000\000\065\042\012\043\000\000\116\000\000\000\000\000\ +\000\000\000\000\111\043\000\000\058\044\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\002\008\000\000\000\008\000\000\ +\000\000\000\000\000\000\247\008\000\000\000\000\000\000\000\000\ +\134\014\134\014\000\000\079\010\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\247\010\ +\000\000\000\000\000\000\060\049\114\018\000\000\000\000\000\000\ +\001\075\036\076\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\150\052\000\000\000\000\ +\253\002\225\005\000\000\000\000\000\000\139\006\000\000\002\053\ +\000\000\000\000\000\000\165\060\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\022\003\239\255\000\000\000\000\ +\000\000\000\000\089\075\000\000\000\000\000\000\067\002\124\002\ +\000\000\227\255\000\000\000\000\037\000\000\000\000\000\170\255\ +\000\000\142\005\000\000\117\255\095\001\000\000\199\006\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\008\008\052\060\008\008\029\003\251\007\042\004\ +\177\075\000\000\000\000\000\000\167\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\076\062\162\062\230\002\000\000\000\000\248\062\078\063\ +\000\000\185\000\000\000\000\000\000\000\000\000\000\000\008\008\ +\000\000\069\005\000\000\000\000\002\004\000\000\251\007\000\000\ +\000\000\000\000\079\005\000\000\000\000\000\000\000\000\099\000\ +\222\055\028\075\000\000\149\013\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\220\035\000\000\000\000\204\075\000\000\000\000\ +\212\004\000\000\252\007\000\000\108\003\000\000\108\003\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\237\017\244\024\000\000\000\000\000\000\034\028\ +\151\028\000\000\000\000\239\255\000\000\000\000\000\000\000\000\ +\079\005\000\000\000\000\000\000\252\007\000\000\108\003\000\000\ +\059\014\000\000\000\000\000\000\000\000\000\000\000\000\247\008\ +\000\000\000\000\000\000\000\000\000\000\000\000\153\001\000\000\ +\095\008\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\207\255\000\000\076\008\000\000\078\008\084\008\000\000\000\000\ +\131\004\096\001\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\036\000\ +\000\000\146\000\068\000\095\001\000\000\199\006\000\000\235\000\ +\000\000\251\007\238\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\008\008\165\060\ +\000\000\229\050\011\029\000\000\000\000\000\000\000\000\239\255\ +\000\000\045\008\000\000\000\000\000\000\000\000\000\000\221\057\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\057\008\000\000\ +\246\061\215\059\064\004\000\000\000\000\127\029\000\000\000\000\ +\000\000\000\000\000\000\146\255\000\000\000\000\228\000\000\000\ +\000\000\000\000\148\005\000\000\090\001\000\000\000\000\018\008\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\251\007\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\175\004\000\000\000\000\008\008\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\138\038\242\038\ +\090\039\034\016\245\040\194\039\080\036\197\036\057\037\173\037\ +\034\033\244\029\104\030\034\038\150\033\011\034\042\040\220\030\ +\127\034\243\034\104\035\000\000\000\000\081\031\000\000\000\000\ +\085\001\000\000\239\255\239\255\088\041\000\000\000\000\000\000\ +\000\000\244\019\000\000\000\000\000\000\104\025\221\025\000\000\ +\000\000\000\000\128\024\000\000\000\000\146\040\045\008\117\011\ +\057\008\000\000\000\000\124\012\096\007\012\043\000\000\000\000\ +\000\000\000\000\000\000\000\000\175\004\000\000\239\255\000\000\ +\000\000\000\000\000\000\061\014\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\173\061\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\230\046\000\000\000\000\000\000\000\000\073\047\ +\000\000\000\000\000\000\000\000\172\047\000\000\000\000\000\000\ +\000\000\000\000\156\255\000\000\000\000\245\000\090\001\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\016\001\000\000\067\006\000\000\202\000\000\000\000\000\000\000\ +\118\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\045\008\ +\023\008\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\139\058\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\197\031\ +\000\000\000\000\000\000\147\071\000\000\204\005\000\000\000\000\ +\000\000\000\000\000\000\086\002\000\000\000\000\217\255\000\000\ +\067\000\000\000\000\000\006\000\000\000\144\000\000\000\000\000\ +\000\000\000\000\000\000\155\006\029\008\000\000\000\000\000\000\ +\000\000\170\005\000\000\000\000\230\057\028\007\000\000\188\006\ +\000\000\019\004\003\001\018\001\062\001\000\000\000\000\000\000\ +\089\075\204\058\000\000\000\000\000\000\000\000\000\000\215\059\ +\000\000\000\000\000\000\216\005\215\059\089\075\159\005\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\095\001\000\000\199\006\000\000\230\002\ +\000\000\000\000\000\000\230\057\000\000\000\000\045\008\045\008\ +\000\000\142\081\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\219\005\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\012\043\ +\000\000\000\000\045\008\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\230\001\ +\000\000\000\000\008\001\000\000\147\001\000\000\000\000\017\048\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\182\000\ +\000\000\002\001\000\000\217\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\069\008\187\054\000\000\ +\106\055\000\000\000\000\189\007\139\058\000\000\215\059\000\000\ +\000\000\009\000\000\000\250\255\040\008\040\008\254\255\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\120\046\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\172\000\000\000\000\000\083\008\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\215\059\253\058\000\000\ +\138\008\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\148\077\018\005\147\071\079\002\134\003\168\004\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\182\009\000\000\ +\000\000\000\000\000\000\215\059\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\082\056\253\058\000\000\000\000\105\020\000\000\ +\000\000\221\020\000\000\081\021\000\000\000\000\000\000\192\041\ +\000\000\198\021\000\000\058\022\000\000\174\022\000\000\000\000\ +\000\000\000\000\252\004\000\000\197\006\000\000\175\004\246\006\ +\000\000\089\008\000\000\000\000\252\052\012\043\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\153\001\000\000\ +\000\000\000\000\238\063\000\000\000\000\099\008\116\048\000\000\ +\000\000\000\000\000\000\230\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\023\008\000\000\ +\000\000\000\000\000\000\000\000\253\058\000\000\000\000\000\000\ +\000\000\000\000\085\005\000\000\000\000\215\059\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\197\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\152\006\000\000\170\003\000\000\032\006\000\000\000\000\ +\117\006\000\000\000\000\057\032\007\059\000\000\000\000\000\000\ +\000\000\000\000\000\000\248\005\000\000\038\004\168\004\117\004\ +\168\004\000\000\174\032\159\005\000\000\087\008\000\000\208\255\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\019\041\000\000\000\000\ +\000\000\208\255\019\041\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\144\016\215\048\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\037\015\059\008\000\000\ +\000\000\236\054\000\000\189\011\000\000\000\000\000\000\137\073\ +\000\000\028\075\000\000\047\003\000\000\000\000\027\058\110\053\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\069\059\215\059\000\000\000\000\058\000\000\000\000\000\ +\000\000\017\002\000\000\000\000\000\000\035\042\001\017\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\131\056\000\000\ +\000\000\000\000\168\004\000\000\168\004\072\008\000\000\069\008\ +\000\000\000\000\000\000\000\000\000\000\000\000\100\008\245\011\ +\184\056\000\000\237\056\000\000\000\000\147\016\253\058\000\000\ +\000\000\000\000\253\058\253\058\000\000\134\042\238\042\081\043\ +\000\000\035\023\000\000\151\023\000\000\011\024\180\043\028\044\ +\127\044\019\041\079\017\116\050\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\253\058\ +\000\000\000\000\119\002\146\003\000\000\194\002\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\146\003\000\000\ +\002\004\000\000\000\000\182\053\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\020\006\000\000\ +\094\008\072\008\000\000\101\008\069\008\000\000\147\016\000\000\ +\056\057\109\057\162\003\069\008\000\000\024\056\000\000\000\000\ +\000\000\234\012\215\059\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\253\058\000\000\000\000\000\000\000\000\ +\136\049\194\049\000\000\010\078\000\000\000\000\000\000\118\057\ +\012\043\000\000\000\000\019\041\000\000\000\000\000\000\252\007\ +\000\000\000\000\000\000\000\000\000\000\000\000\080\058\000\000\ +\030\055\000\000\000\000\000\000\252\007\000\000\000\000\000\000\ +\000\000\240\053\219\002\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\172\006\000\000\168\004\000\000\000\000\000\000\ +\000\000\000\000\000\000\024\056\000\000\000\000\000\000\000\000\ +\000\000\234\012\000\000\129\058\000\000\000\000\000\000\000\000\ +\000\000\226\044\074\045\173\045\000\000\000\000\000\000\000\000\ +\118\057\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\253\005\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\046\008\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\069\008\168\057\ +\000\000\000\000\000\000\129\058\129\058\000\000\252\049\000\000\ +\000\000\000\000\148\077\223\005\038\004\117\004\005\004\000\000\ +\000\000\000\000\042\054\000\000\000\000\000\000\111\005\000\000\ +\000\000\000\000\000\000\000\000\193\004\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\058\050\129\058\000\000\000\000\ +\000\000\000\000\000\000\104\008\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\077\009\186\010\ +\000\000\000\000\000\000\164\055\005\004\005\004\107\008\109\008\ +\000\000\110\008\069\008\000\000\005\004\100\054\000\000\000\000\ +\164\005\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\095\004\000\000\ +\005\004\000\000\000\000\000\000\000\000\050\009\222\010" -(* Define forward functions *) +let yygindex = "\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\033\000\ +\215\255\000\000\089\000\072\000\013\006\049\009\060\000\000\000\ +\214\255\126\000\233\001\099\253\000\000\217\254\078\006\071\255\ +\127\008\195\013\029\254\247\255\098\004\194\013\074\252\051\000\ +\093\000\023\000\026\000\034\000\000\000\000\000\000\000\000\000\ +\045\000\047\000\000\000\049\000\000\000\002\000\013\000\088\007\ +\093\001\000\000\000\000\000\000\000\000\000\000\000\000\052\000\ +\000\000\000\000\000\000\000\000\000\000\014\255\005\252\000\000\ +\000\000\000\000\027\000\000\000\000\000\142\254\251\253\032\252\ +\115\251\156\251\083\255\000\000\226\003\000\000\176\004\175\251\ +\113\255\059\004\000\000\000\000\000\000\000\000\000\000\000\000\ +\107\003\015\000\026\251\047\255\103\253\199\251\017\253\135\252\ +\095\251\043\254\247\003\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\046\000\200\006\ +\003\006\006\006\000\000\000\000\078\255\022\000\000\000\168\255\ +\184\001\059\253\000\254\108\010\156\012\000\000\000\000\000\000\ +\110\255\049\008\009\013\119\007\031\000\094\255\207\000\159\254\ +\000\000\080\008\100\007\216\011\115\253\000\000\078\254\000\000\ +\000\000\000\000\050\004\009\006\163\255\164\004\000\000\000\000\ +\000\000\000\000\073\000\000\000\235\007\157\255\254\007\021\007\ +\045\009\000\000\000\000\198\004\000\000\000\000\085\008\213\253\ +\190\005\138\251\021\251\213\251\011\253\000\000\097\253\000\000\ +\122\005\000\000\000\000\046\251\066\255\001\253\251\006\041\008\ +\000\000\000\000\099\004\000\000\000\000\137\004\078\252\000\000\ +\066\004\017\005\000\000\146\253\235\012\133\255\000\000\071\006\ +\128\255\220\254\141\255\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\082\255\000\000" -let _ = - components_of_module' := components_of_module; - components_of_functor_appl' := components_of_functor_appl; - components_of_module_maker' := components_of_module_maker +let yytablesize = 21372 +let yytable = "\188\000\ +\019\002\185\001\188\000\108\000\188\000\188\000\188\000\161\001\ +\248\001\188\000\188\000\188\000\188\000\188\000\109\000\188\000\ +\200\001\127\002\180\001\010\002\162\001\127\003\188\000\002\002\ +\102\000\125\002\188\000\103\000\001\002\188\000\188\000\188\000\ +\193\000\056\000\213\003\104\000\192\000\040\002\009\003\188\000\ +\188\000\216\000\160\001\188\000\188\000\171\001\105\000\209\000\ +\106\000\166\001\107\000\171\004\129\003\112\000\222\003\196\003\ +\136\001\194\001\030\002\223\000\031\002\085\003\127\000\133\000\ +\124\004\170\003\064\001\224\004\140\001\186\001\219\001\014\005\ +\133\004\005\004\125\000\132\000\021\001\159\000\065\001\112\005\ +\056\001\158\005\075\005\162\005\188\000\188\000\188\000\188\000\ +\154\001\188\000\156\001\124\000\163\001\063\000\134\002\063\000\ +\063\000\113\003\051\000\108\000\051\002\201\003\037\002\023\003\ +\124\001\054\001\128\001\129\001\075\001\090\003\109\000\108\000\ +\165\005\090\005\005\002\089\000\143\001\128\005\049\004\040\003\ +\102\000\098\003\109\000\103\000\209\003\224\002\143\001\161\002\ +\089\004\162\002\149\000\104\000\102\000\054\004\073\005\103\000\ +\036\005\054\002\063\000\187\001\062\001\011\005\105\000\104\000\ +\106\000\138\001\107\000\145\001\021\002\112\000\076\001\188\000\ +\188\000\170\001\105\000\219\001\106\000\169\005\107\000\070\001\ +\237\004\112\000\114\005\225\001\230\002\052\002\151\005\055\004\ +\099\005\142\001\182\001\180\005\059\002\186\000\224\001\126\005\ +\165\001\010\000\234\001\243\001\040\003\191\005\234\005\023\004\ +\186\000\220\001\127\000\188\000\153\001\221\001\133\000\103\003\ +\133\000\035\004\186\000\024\003\222\001\201\003\128\002\223\001\ +\152\001\207\001\186\000\243\001\244\001\188\002\142\001\165\005\ +\143\001\103\003\235\001\143\001\050\004\090\003\245\001\200\002\ +\145\001\151\001\168\003\076\001\110\002\063\000\090\004\076\001\ +\114\002\076\001\151\001\014\002\244\001\232\002\037\005\231\001\ +\232\001\104\003\076\005\207\005\138\001\200\002\245\001\022\002\ +\138\001\015\004\173\002\145\001\218\005\035\004\219\001\186\000\ +\087\003\088\003\219\001\104\003\155\005\151\001\197\003\246\001\ +\196\005\040\006\247\001\053\002\118\003\141\001\200\002\231\004\ +\142\001\221\005\070\004\239\001\188\000\188\000\173\002\157\001\ +\200\002\003\004\184\002\006\002\226\000\024\004\208\005\246\001\ +\223\000\163\001\247\001\114\005\115\003\040\005\104\001\036\004\ +\042\005\009\003\188\000\221\001\134\001\204\002\198\003\071\001\ +\189\002\192\002\141\001\193\002\140\004\173\002\204\002\173\002\ +\188\000\182\002\193\000\145\001\168\002\188\000\145\001\145\001\ +\211\002\200\002\104\005\173\002\200\002\151\001\221\001\160\001\ +\188\000\151\001\147\001\212\001\181\002\077\001\160\001\064\001\ +\160\001\239\002\009\003\152\004\016\004\212\001\002\002\171\001\ +\171\001\029\004\030\004\095\004\227\000\165\005\222\005\226\000\ +\119\003\218\002\100\003\223\000\234\001\147\001\175\002\234\001\ +\231\005\234\001\051\000\234\001\141\001\234\001\104\001\034\003\ +\013\006\237\005\140\005\142\005\150\002\068\004\152\002\063\000\ +\153\002\063\000\019\006\089\000\069\002\206\001\046\003\118\003\ +\238\005\170\004\070\002\122\003\051\000\121\004\221\001\134\001\ +\055\002\059\006\221\001\234\001\120\006\234\001\122\002\186\000\ +\047\006\064\002\118\002\119\002\068\002\089\000\123\002\144\001\ +\124\001\214\001\140\004\177\005\063\000\234\001\071\003\227\000\ +\105\005\144\001\228\002\049\002\129\002\147\001\061\006\212\001\ +\147\001\147\001\212\001\049\006\076\001\214\005\140\002\188\000\ +\187\001\017\002\101\002\137\001\018\002\149\003\104\002\100\006\ +\195\005\102\006\220\001\215\005\030\000\220\001\221\001\021\005\ +\127\002\190\000\130\002\170\001\170\001\222\001\051\000\033\004\ +\223\001\225\001\000\006\131\002\146\001\105\001\058\005\170\003\ +\188\000\207\001\110\006\125\003\225\001\207\001\122\004\089\000\ +\220\001\207\001\133\000\207\001\133\000\087\006\133\000\207\001\ +\213\001\225\001\225\001\207\001\132\002\233\004\234\001\146\001\ +\234\001\118\003\213\001\136\001\207\001\218\001\133\002\186\000\ +\114\001\229\002\143\002\144\001\214\001\141\002\144\001\173\000\ +\186\000\225\001\139\005\076\001\215\001\076\001\027\003\076\001\ +\246\005\050\002\220\001\076\006\062\006\234\001\221\001\234\001\ +\010\003\215\002\137\002\216\005\140\002\222\001\137\001\081\002\ +\223\001\150\003\137\001\220\004\240\003\009\003\003\006\157\001\ +\220\001\135\002\207\001\157\001\220\001\129\002\127\002\157\001\ +\081\002\157\001\170\002\034\004\228\005\157\001\188\000\146\001\ +\204\003\108\000\146\001\146\001\207\001\207\001\024\006\207\001\ +\207\001\216\000\157\001\200\001\109\000\030\000\205\003\033\004\ +\136\003\137\003\190\000\130\002\213\001\072\004\102\000\213\001\ +\186\000\103\000\207\001\196\004\131\002\133\002\136\001\053\004\ +\218\001\104\000\160\001\063\000\218\001\061\004\166\005\135\003\ +\143\002\229\004\002\002\141\002\105\000\107\001\106\000\215\001\ +\107\000\031\003\050\003\112\000\221\003\132\002\137\005\216\000\ +\157\001\216\002\186\000\236\001\215\002\209\000\215\002\133\002\ +\137\002\007\003\186\000\216\002\087\004\081\002\171\002\211\003\ +\076\003\078\003\157\001\157\001\117\003\157\001\157\001\135\002\ +\109\001\096\002\041\003\002\002\237\001\206\001\102\005\234\001\ +\220\003\206\001\234\001\241\003\106\003\206\001\206\003\206\001\ +\157\001\191\001\047\002\206\001\076\004\176\004\118\003\206\001\ +\175\003\186\000\175\002\094\004\203\001\203\001\015\003\017\003\ +\206\001\083\003\103\004\082\003\243\001\253\004\032\004\197\004\ +\234\003\227\001\228\001\133\002\193\003\028\003\031\001\236\005\ +\023\003\063\000\123\003\041\005\097\002\142\004\120\001\121\001\ +\127\001\019\004\244\005\020\004\186\000\225\001\252\001\041\003\ +\051\006\251\001\111\001\103\003\088\004\216\002\091\003\092\003\ +\016\002\250\003\215\002\096\002\023\003\096\002\206\001\225\001\ +\244\005\225\001\252\001\225\001\186\000\173\004\192\001\225\001\ +\077\004\169\005\092\006\007\003\186\000\052\006\142\003\170\002\ +\206\001\206\001\133\000\206\001\206\001\187\000\251\003\252\003\ +\236\003\031\000\124\003\170\002\104\004\104\003\008\004\234\001\ +\188\004\035\000\031\000\053\006\009\003\004\004\206\001\077\004\ +\235\003\021\003\035\000\127\001\253\003\051\001\097\002\086\004\ +\097\002\140\003\044\006\076\001\023\003\225\001\081\004\127\003\ +\032\006\002\002\234\001\010\003\180\001\013\000\110\004\191\005\ +\253\004\044\006\069\004\094\006\071\001\187\001\079\004\187\001\ +\180\004\023\003\182\004\184\004\054\006\066\004\025\003\120\004\ +\018\000\185\002\187\001\225\001\222\004\254\003\129\003\074\003\ +\160\001\199\005\153\005\227\004\190\001\228\003\162\003\163\003\ +\198\002\025\003\119\005\024\000\010\003\212\005\207\003\133\003\ +\025\003\002\002\093\003\224\000\189\004\083\004\220\003\225\001\ +\138\001\222\001\154\005\189\001\243\001\185\003\186\000\144\003\ +\168\000\141\003\071\001\009\003\052\004\255\003\025\003\025\003\ +\236\001\155\003\171\002\195\003\023\003\169\000\188\000\077\004\ +\000\004\016\005\025\003\009\003\253\005\244\001\255\005\025\003\ +\171\002\167\005\025\003\171\002\025\003\172\002\047\000\245\001\ +\122\002\237\001\106\003\230\002\200\004\171\002\190\001\230\002\ +\166\000\249\001\063\000\172\002\186\000\195\002\172\002\108\000\ +\231\002\220\001\184\003\122\002\243\005\221\001\224\000\109\003\ +\172\002\122\002\109\000\196\002\222\001\077\002\234\001\223\001\ +\009\003\106\003\094\002\187\001\102\000\025\003\085\002\103\000\ +\246\001\071\001\141\001\247\001\122\002\059\004\187\001\104\000\ +\094\002\048\005\225\001\120\001\121\001\013\004\211\002\253\004\ +\211\002\187\001\105\000\045\005\106\000\225\001\107\000\159\004\ +\075\004\112\000\025\004\222\001\232\002\171\002\223\001\201\005\ +\232\002\171\002\111\003\122\002\122\002\253\004\211\002\186\000\ +\090\006\091\006\164\002\234\001\183\002\190\000\187\001\091\005\ +\172\002\007\002\225\001\143\001\172\002\122\002\122\002\122\002\ +\094\002\098\005\186\000\002\002\241\002\242\002\211\002\094\002\ +\110\004\185\000\012\004\197\002\107\003\201\002\203\002\205\002\ +\122\002\030\000\002\002\234\001\011\003\209\002\186\000\008\002\ +\017\000\031\005\094\002\124\005\185\000\220\001\236\004\166\000\ +\249\001\221\001\191\000\185\000\164\002\164\002\074\005\248\003\ +\222\001\009\004\129\006\223\001\186\000\071\001\106\003\010\003\ +\146\001\178\003\243\002\103\003\141\005\255\002\164\002\190\001\ +\234\001\185\000\234\001\179\003\009\002\010\004\047\005\253\004\ +\014\006\071\001\198\005\051\000\180\001\185\000\190\001\147\001\ +\180\001\253\004\187\001\230\002\180\001\185\000\180\001\185\000\ +\025\003\029\003\180\001\180\001\135\004\136\004\180\001\129\002\ +\043\006\007\003\186\000\186\000\149\005\104\003\015\005\180\001\ +\002\002\007\002\146\004\147\004\048\000\110\004\092\005\051\000\ +\025\003\153\004\125\002\193\004\057\003\190\001\025\003\030\000\ +\222\002\234\001\167\004\106\003\190\000\130\002\023\003\249\003\ +\185\000\030\000\253\004\106\003\091\004\023\003\131\002\008\002\ +\220\001\023\003\025\003\186\000\221\001\234\001\180\001\029\000\ +\186\000\023\003\223\002\222\001\232\002\180\001\223\001\103\003\ +\023\003\095\005\225\001\025\003\025\003\176\005\145\004\132\002\ +\166\000\249\001\025\003\025\003\208\003\025\003\015\003\180\001\ +\180\001\133\002\180\001\180\001\009\002\025\003\023\003\023\003\ +\215\000\052\003\168\004\051\000\253\004\004\003\150\000\234\004\ +\175\000\002\002\023\003\106\006\059\005\180\001\053\003\023\003\ +\129\002\104\003\023\003\161\001\023\003\178\004\186\000\058\003\ +\215\001\183\001\163\005\038\006\159\005\077\002\012\005\214\003\ +\162\001\200\005\243\001\243\004\106\003\025\003\025\003\187\001\ +\030\000\025\003\170\005\216\001\213\005\190\000\130\002\239\003\ +\107\006\059\003\092\004\246\003\054\003\143\004\115\005\131\002\ +\225\001\039\006\225\001\244\001\225\001\023\003\187\001\225\001\ +\158\001\186\000\023\003\106\003\192\005\245\001\051\000\148\003\ +\187\001\200\002\234\001\023\003\234\001\165\001\234\001\144\004\ +\132\002\165\001\028\004\166\000\249\001\220\001\203\001\159\003\ +\200\002\221\001\133\002\165\001\161\001\140\003\010\003\200\002\ +\222\001\193\001\020\005\223\001\165\001\211\002\023\005\211\002\ +\006\005\162\001\002\002\027\005\238\002\146\000\246\001\210\005\ +\211\002\247\001\017\002\211\002\106\003\018\002\200\002\176\001\ +\200\002\106\003\188\003\023\003\038\005\039\005\002\002\160\001\ +\144\002\234\001\200\002\220\003\163\000\044\005\206\002\165\000\ +\190\001\150\000\242\005\165\001\150\000\234\001\150\000\150\000\ +\207\002\225\005\122\005\186\000\145\002\211\002\234\001\119\006\ +\188\000\186\000\234\001\022\005\053\005\131\005\211\002\026\005\ +\001\006\150\000\166\000\249\001\021\003\175\000\175\000\163\001\ +\175\000\054\003\187\000\200\002\187\001\181\001\200\002\198\001\ +\187\001\139\004\175\000\175\000\150\000\010\003\164\001\021\003\ +\186\000\036\006\164\001\150\000\077\002\124\001\021\003\002\002\ +\007\002\164\001\025\006\197\000\210\005\010\003\106\003\146\002\ +\187\001\022\001\175\000\175\000\147\002\164\001\013\002\051\000\ +\050\005\150\000\150\000\103\006\021\003\002\002\109\003\187\001\ +\030\000\186\000\220\003\065\005\051\000\150\000\008\002\029\000\ +\021\003\188\001\029\000\110\003\017\006\150\000\195\001\150\000\ +\021\003\186\000\021\003\104\006\029\000\029\000\042\006\186\000\ +\029\000\106\003\010\003\128\006\164\001\049\005\236\001\023\001\ +\106\003\029\000\029\000\029\000\029\000\024\001\196\000\006\005\ +\187\000\089\001\090\001\009\002\138\005\023\003\122\005\029\000\ +\029\000\111\003\051\000\211\002\004\003\129\002\102\001\237\001\ +\150\000\196\000\146\005\021\003\147\005\186\000\131\005\214\000\ +\196\000\084\004\186\000\029\000\211\002\023\003\029\000\226\001\ +\029\000\029\000\029\000\029\000\158\001\030\000\187\001\095\001\ +\029\000\029\000\190\000\130\002\177\002\131\005\196\000\029\000\ +\006\005\025\002\215\000\103\001\131\002\023\003\211\002\187\001\ +\100\001\124\001\196\000\029\000\234\001\029\000\217\004\029\000\ +\029\000\196\000\196\000\172\004\196\000\025\003\144\005\021\003\ +\186\000\232\005\122\005\029\000\235\005\132\002\029\000\255\002\ +\230\001\146\000\029\000\229\001\023\003\186\000\026\002\133\002\ +\218\004\178\002\021\003\187\004\161\005\025\003\234\001\023\003\ +\047\002\021\003\025\003\025\003\050\006\131\005\138\003\010\006\ +\162\004\164\004\166\004\234\001\025\003\196\000\169\004\220\005\ +\131\005\234\001\025\003\047\002\255\002\006\005\187\001\021\003\ +\021\003\187\001\047\002\047\002\026\003\110\002\006\005\111\002\ +\181\001\011\006\234\001\021\003\023\003\025\003\187\001\135\002\ +\198\001\112\002\234\001\021\003\255\002\021\003\243\001\025\003\ +\047\002\047\002\223\003\077\002\029\006\030\006\224\003\033\006\ +\034\006\011\003\017\004\102\001\047\002\225\003\150\000\187\001\ +\226\003\143\003\241\001\047\002\047\002\150\000\047\002\150\000\ +\252\001\227\003\198\001\150\004\224\005\055\006\150\000\150\000\ +\007\004\150\000\227\005\023\003\023\003\051\000\021\003\015\002\ +\056\006\020\006\023\003\243\001\252\001\150\000\023\003\018\004\ +\130\005\150\000\234\001\234\001\240\005\175\000\175\000\023\003\ +\026\006\234\001\234\001\234\001\234\001\023\003\077\002\047\002\ +\186\000\131\005\211\002\021\006\156\005\234\001\023\003\051\000\ +\146\003\011\003\187\005\187\001\023\003\146\000\175\000\175\000\ +\175\000\023\003\155\001\187\001\234\001\188\005\175\000\009\006\ +\211\002\220\001\073\003\081\006\211\002\221\001\158\001\023\002\ +\211\002\211\002\211\002\211\002\222\001\187\001\187\001\223\001\ +\113\001\157\005\122\005\190\000\122\005\175\000\175\000\211\002\ +\065\006\023\003\175\000\108\006\131\005\215\000\175\000\187\001\ +\023\003\013\002\074\006\006\005\209\005\011\003\214\002\134\003\ +\215\002\187\001\150\000\150\000\005\006\187\001\024\002\118\006\ +\139\001\198\001\216\002\146\000\187\001\187\001\211\002\088\006\ +\000\005\150\000\175\000\110\005\025\003\125\006\126\006\186\000\ +\058\004\148\001\154\001\175\000\027\002\215\002\196\002\196\002\ +\155\001\013\002\097\006\216\002\202\002\196\002\001\005\029\002\ +\186\000\178\002\030\000\014\000\069\006\175\000\002\005\183\001\ +\003\005\178\002\196\002\048\002\112\006\186\000\051\000\077\006\ +\196\002\187\000\015\000\016\000\103\003\004\005\023\003\018\002\ +\146\000\025\003\215\002\013\003\006\005\185\002\048\002\023\000\ +\216\002\023\003\019\003\196\002\196\002\048\002\048\002\069\006\ +\069\006\148\005\058\001\186\000\082\000\095\006\096\006\132\006\ +\175\000\023\003\031\000\051\000\051\000\074\001\164\003\050\005\ +\157\002\011\002\035\000\048\002\048\002\036\002\104\003\147\000\ +\039\000\109\005\089\000\113\006\186\000\030\000\042\000\048\002\ +\181\001\245\004\110\005\135\002\181\001\051\000\048\002\048\002\ +\181\001\048\002\181\001\011\002\123\006\187\000\181\001\181\001\ +\247\004\147\000\181\001\242\003\089\000\083\000\127\006\043\002\ +\252\001\069\006\050\000\181\001\183\000\053\000\041\002\134\006\ +\135\006\150\000\243\003\244\003\150\000\072\002\073\002\074\002\ +\075\002\217\001\135\002\150\000\252\001\150\000\150\000\146\000\ +\166\000\076\002\048\002\161\000\057\002\023\003\183\000\151\003\ +\023\003\023\003\186\000\150\000\218\001\023\003\023\003\065\002\ +\175\000\152\003\181\001\210\001\058\002\150\000\161\000\210\001\ +\127\005\181\001\063\004\187\000\023\003\161\000\023\003\175\000\ +\175\000\210\001\023\003\064\003\245\002\246\002\023\003\023\003\ +\023\003\064\004\210\001\181\001\181\001\077\002\181\001\181\001\ +\065\003\060\002\155\001\161\000\161\000\023\003\155\001\150\000\ +\139\002\150\000\155\001\023\003\155\001\102\001\150\000\161\000\ +\155\001\181\001\025\003\175\000\155\001\071\002\161\000\161\000\ +\140\002\161\000\120\002\150\000\175\000\155\001\175\000\120\002\ +\189\000\054\003\025\003\196\000\023\003\198\000\199\000\200\000\ +\013\002\215\004\201\000\202\000\203\000\204\000\205\000\220\001\ +\206\000\245\002\248\002\221\001\017\002\007\003\186\000\018\002\ +\209\001\126\004\222\001\057\001\209\001\223\001\059\001\060\001\ +\061\001\035\006\161\000\215\000\155\001\159\002\209\001\175\000\ +\066\001\067\001\154\001\155\001\068\001\069\001\154\001\209\001\ +\186\000\160\002\154\001\163\002\154\001\135\002\013\002\103\003\ +\154\001\154\001\164\002\167\001\063\003\155\001\155\001\167\001\ +\155\001\155\001\064\003\093\005\151\002\154\001\150\000\198\004\ +\165\002\011\003\128\000\198\000\190\005\186\000\094\005\065\003\ +\172\002\199\004\167\001\155\001\173\002\132\001\133\001\134\001\ +\135\001\174\002\137\001\180\002\164\002\146\000\198\000\176\001\ +\186\002\104\003\185\002\176\001\082\000\198\000\215\002\082\000\ +\135\002\190\002\176\001\191\002\154\001\176\001\135\002\225\002\ +\215\002\082\000\227\002\154\001\002\003\082\000\176\001\150\000\ +\186\000\071\001\150\000\198\000\198\000\237\002\082\000\082\000\ +\082\000\082\000\011\003\150\000\018\003\154\001\154\001\198\000\ +\154\001\154\001\025\003\025\003\150\000\082\000\198\000\198\000\ +\030\003\198\000\175\000\166\002\167\002\083\000\032\003\043\003\ +\196\001\197\001\035\003\154\001\044\003\176\001\048\003\044\002\ +\082\000\045\002\083\000\082\000\247\002\249\002\083\000\082\000\ +\082\000\069\003\051\003\046\002\045\003\175\000\082\000\083\000\ +\083\000\083\000\083\000\047\003\082\000\115\002\008\003\116\002\ +\049\003\070\003\198\000\219\002\240\001\220\002\083\000\175\001\ +\082\000\117\002\082\000\175\001\082\000\082\000\051\000\221\002\ +\175\000\037\004\175\001\038\004\090\001\175\001\135\002\062\003\ +\082\000\083\000\150\000\082\000\083\000\039\004\094\003\083\000\ +\083\000\083\000\150\000\086\003\175\000\175\000\083\000\083\000\ +\101\003\175\000\175\000\175\000\108\003\083\000\150\000\175\000\ +\096\004\114\003\097\004\135\002\116\003\175\000\135\002\120\003\ +\130\003\083\000\139\003\083\000\098\004\083\000\083\000\094\000\ +\120\002\150\000\007\003\186\000\071\001\175\001\192\001\120\002\ +\145\003\083\000\120\002\153\003\083\000\175\000\095\000\016\000\ +\083\000\222\001\160\003\172\003\120\002\038\002\039\002\173\003\ +\120\002\047\002\186\003\096\000\245\002\177\002\199\003\013\002\ +\054\003\120\002\120\002\120\002\120\002\077\002\212\003\230\003\ +\229\003\231\003\232\003\048\002\233\003\174\000\031\000\237\003\ +\120\002\070\000\014\004\021\004\027\004\051\004\035\000\047\004\ +\060\004\056\002\105\003\067\004\097\000\010\000\063\002\080\004\ +\208\000\082\004\042\000\120\002\178\002\135\002\120\002\085\004\ +\177\002\120\002\120\002\120\002\135\002\102\004\111\004\116\004\ +\120\002\120\002\098\000\105\004\117\004\150\000\219\000\120\002\ +\127\004\125\004\130\004\150\000\132\004\149\004\099\000\014\000\ +\135\002\053\000\131\004\120\002\164\002\120\002\158\004\120\002\ +\120\002\177\004\190\004\195\004\164\002\192\004\015\000\016\000\ +\203\004\164\002\204\004\120\002\250\004\005\005\120\002\175\000\ +\205\004\206\004\120\002\023\000\214\004\150\000\164\002\207\004\ +\164\002\164\002\211\004\212\004\213\004\221\004\175\000\150\000\ +\225\004\226\004\228\004\150\000\241\004\164\002\031\000\013\005\ +\235\004\074\001\029\005\018\005\013\002\101\005\035\000\024\005\ +\043\005\077\005\025\005\117\005\039\000\028\005\021\003\072\005\ +\164\002\046\005\042\000\164\002\116\005\120\005\164\002\164\002\ +\164\002\121\005\123\005\133\005\136\005\079\003\164\002\143\005\ +\169\002\145\005\129\000\121\000\164\002\164\005\059\005\184\001\ +\202\005\013\002\135\002\205\005\150\000\181\005\050\000\182\005\ +\164\002\053\000\183\005\206\005\164\002\164\002\223\005\150\000\ +\230\005\199\001\174\000\174\000\233\005\174\000\248\005\008\006\ +\164\002\194\002\023\006\164\002\175\000\027\006\041\006\174\000\ +\174\000\216\003\058\006\072\002\073\002\074\002\075\002\250\004\ +\135\002\013\002\023\003\254\005\063\006\066\006\012\003\076\002\ +\064\006\067\006\135\002\072\006\247\003\073\006\150\000\174\000\ +\174\000\002\004\098\006\011\002\075\006\023\003\167\005\093\006\ +\116\006\117\006\111\005\111\006\023\003\150\000\121\006\124\006\ +\120\002\150\000\130\006\120\002\131\006\051\000\089\000\008\000\ +\026\004\021\003\150\000\051\000\005\005\120\002\084\002\025\003\ +\023\003\120\002\023\003\077\002\128\000\089\000\178\002\105\002\ +\252\001\102\002\120\002\120\002\120\002\120\002\023\003\104\002\ +\033\003\023\003\023\003\023\003\065\004\175\000\023\003\036\003\ +\023\003\120\002\135\002\135\002\202\002\221\000\107\002\200\002\ +\020\002\070\000\150\000\200\002\070\000\001\000\002\000\003\000\ +\004\000\005\000\006\000\007\000\120\002\005\005\070\000\120\002\ +\201\002\178\002\120\002\120\002\120\002\201\002\150\000\150\000\ +\150\000\120\002\120\002\070\000\203\002\070\000\070\000\206\002\ +\120\002\023\003\207\002\135\002\208\002\204\002\111\005\149\001\ +\048\004\070\000\070\000\016\006\120\002\232\001\120\002\132\005\ +\120\002\120\002\184\001\217\005\101\006\006\006\072\003\192\003\ +\129\004\149\002\226\005\119\004\120\002\070\000\250\004\120\002\ +\070\000\124\002\084\003\120\002\070\000\070\000\150\000\137\004\ +\210\002\206\001\147\003\070\000\025\003\025\003\150\000\134\005\ +\201\004\070\000\005\005\025\003\250\004\141\002\175\000\208\002\ +\242\004\025\003\182\003\005\005\176\002\070\000\150\000\219\005\ +\025\003\070\000\070\000\194\005\247\005\096\005\025\003\000\000\ +\150\000\113\002\175\000\000\000\000\000\070\000\150\000\000\000\ +\070\000\000\000\174\004\175\004\000\000\000\000\000\000\000\000\ +\000\000\025\003\025\003\021\003\000\000\000\000\000\000\000\000\ +\150\000\000\000\000\000\186\004\000\000\000\000\000\000\148\002\ +\000\000\000\000\021\003\021\003\000\000\000\000\000\000\000\000\ +\194\004\000\000\000\000\000\000\150\000\000\000\150\000\021\003\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\202\004\000\000\000\000\150\000\000\000\000\000\250\004\150\000\ +\000\000\195\000\021\003\175\000\000\000\021\003\000\000\000\000\ +\250\004\000\000\021\003\000\000\000\000\000\000\135\002\184\001\ +\021\003\000\000\174\000\174\000\195\000\000\000\021\003\000\000\ +\000\000\175\000\223\004\195\000\162\000\000\000\173\002\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\021\003\021\003\ +\000\000\000\000\000\000\174\000\174\000\174\000\000\000\162\000\ +\000\000\195\000\021\003\174\000\000\000\021\003\162\000\000\000\ +\000\000\250\004\217\002\000\000\000\000\195\000\000\000\000\000\ +\005\005\000\000\177\000\000\000\195\000\195\000\194\000\195\000\ +\000\000\010\005\174\000\174\000\162\000\162\000\000\000\174\000\ +\150\000\000\000\017\005\174\000\000\000\194\000\011\002\000\000\ +\162\000\000\000\000\000\150\000\000\000\000\000\199\001\162\000\ +\162\000\000\000\162\000\000\000\000\000\199\001\000\000\000\000\ +\194\000\000\000\000\000\250\004\000\000\000\000\000\000\174\000\ +\195\000\000\000\000\000\150\000\150\000\000\000\000\000\022\004\ +\174\000\150\000\150\000\000\000\000\000\000\000\011\002\000\000\ +\000\000\000\000\111\005\150\000\111\005\232\001\000\000\000\000\ +\232\001\005\005\174\000\162\000\000\000\061\003\194\000\150\000\ +\194\000\194\000\232\001\055\005\000\000\057\005\208\000\000\000\ +\232\001\014\003\000\000\000\000\000\000\000\000\000\000\232\001\ +\150\000\232\001\232\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\150\000\000\000\000\000\150\000\232\001\000\000\ +\000\000\000\000\000\000\150\000\150\000\174\000\000\000\000\000\ +\000\000\000\000\097\005\000\000\000\000\000\000\000\000\100\005\ +\000\000\232\001\000\000\000\000\232\001\000\000\094\002\000\000\ +\232\001\232\001\000\000\000\000\000\000\000\000\000\000\232\001\ +\136\000\000\000\137\000\138\000\030\000\232\001\139\000\000\000\ +\000\000\140\000\141\000\173\002\000\000\000\000\000\000\177\000\ +\177\000\232\001\177\000\000\000\000\000\232\001\232\001\000\000\ +\000\000\000\000\142\000\000\000\177\000\177\000\000\000\135\005\ +\000\000\232\001\143\000\144\000\232\001\000\000\000\000\000\000\ +\194\000\000\000\145\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\177\000\003\002\146\000\147\000\ +\000\000\194\000\000\000\000\000\199\001\174\000\000\000\150\005\ +\000\000\152\005\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\174\000\174\000\173\002\000\000\ +\173\002\173\002\173\002\168\005\000\000\000\000\173\002\178\005\ +\179\005\000\000\000\000\173\002\000\000\000\000\000\000\173\002\ +\173\002\173\002\000\000\000\000\000\000\180\003\184\005\000\000\ +\173\002\173\002\173\002\173\002\000\000\000\000\000\000\000\000\ +\174\000\000\000\173\002\000\000\011\002\000\000\000\000\173\002\ +\000\000\174\000\000\000\174\000\197\005\000\000\173\002\173\002\ +\000\000\000\000\000\000\000\000\000\000\011\002\000\000\000\000\ +\194\000\000\000\173\002\000\000\000\000\173\002\173\002\000\000\ +\173\002\173\002\173\002\000\000\173\002\000\000\000\000\173\002\ +\173\002\000\000\000\000\000\000\000\000\194\000\173\002\000\000\ +\000\000\000\000\215\003\000\000\174\000\000\000\000\000\000\000\ +\000\000\173\002\173\002\000\000\173\002\173\002\173\002\173\002\ +\000\000\000\000\173\002\011\002\000\000\000\000\000\000\245\005\ +\000\000\163\000\173\002\173\002\171\000\173\002\000\000\000\000\ +\249\005\173\002\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\163\000\002\006\000\000\000\000\ +\004\006\000\000\000\000\163\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\194\000\180\000\000\000\ +\194\000\194\000\000\000\000\000\194\000\000\000\194\000\000\000\ +\000\000\163\000\163\000\000\000\062\004\000\000\000\000\000\000\ +\194\000\028\006\000\000\000\000\156\002\163\000\094\002\194\000\ +\094\002\094\002\094\002\000\000\163\000\163\000\094\002\163\000\ +\000\000\000\000\000\000\094\002\184\001\000\000\000\000\094\002\ +\094\002\094\002\000\000\000\000\000\000\194\000\000\000\174\000\ +\094\002\094\002\094\002\094\002\000\000\000\000\000\000\000\000\ +\000\000\194\000\094\002\000\000\000\000\000\000\000\000\094\002\ +\194\000\194\000\000\000\194\000\000\000\000\000\094\002\094\002\ +\163\000\000\000\174\000\000\000\000\000\000\000\000\000\177\000\ +\003\002\000\000\094\002\000\000\000\000\094\002\000\000\000\000\ +\094\002\094\002\094\002\000\000\094\002\000\000\000\000\094\002\ +\094\002\000\000\000\000\086\006\000\000\174\000\094\002\000\000\ +\177\000\177\000\177\000\000\000\194\000\000\000\000\000\000\000\ +\177\000\094\002\094\002\000\000\094\002\094\002\094\002\094\002\ +\000\000\174\000\174\000\000\000\000\000\000\000\174\000\174\000\ +\174\000\000\000\094\002\000\000\174\000\094\002\000\000\003\002\ +\177\000\094\002\174\000\000\000\003\002\000\000\000\000\000\000\ +\177\000\114\006\115\006\000\000\011\002\000\000\000\000\000\000\ +\000\000\122\006\000\000\180\000\180\000\000\000\180\000\000\000\ +\000\000\011\002\174\000\000\000\000\000\000\000\000\000\000\000\ +\180\000\180\000\000\000\000\000\177\000\133\006\011\002\000\000\ +\011\002\011\002\000\000\000\000\011\002\177\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\011\002\000\000\250\001\ +\180\000\180\000\178\000\000\000\000\000\000\000\195\000\177\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\011\002\000\000\000\000\194\000\219\004\195\000\011\002\011\002\ +\011\002\000\000\000\000\000\000\171\000\000\000\011\002\171\000\ +\000\000\000\000\000\000\000\000\011\002\000\000\000\000\000\000\ +\195\000\171\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\011\002\000\000\177\000\000\000\011\002\000\000\171\000\171\000\ +\171\000\171\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\011\002\000\000\000\000\011\002\000\000\171\000\000\000\000\000\ +\000\000\011\002\184\001\000\000\174\000\000\000\195\000\000\000\ +\195\000\195\000\000\000\000\000\156\002\000\000\000\000\156\002\ +\171\000\000\000\000\000\174\000\156\002\000\000\000\000\171\000\ +\171\000\156\002\156\002\000\000\000\000\000\000\171\000\156\002\ +\000\000\011\002\177\002\000\000\171\000\000\000\156\002\179\000\ +\156\002\156\002\000\000\000\000\000\000\000\000\000\000\000\000\ +\171\000\000\000\171\000\067\002\171\000\156\002\000\000\000\000\ +\000\000\000\000\000\000\159\001\078\002\000\000\000\000\000\000\ +\171\000\000\000\177\000\171\000\000\000\000\000\011\002\000\000\ +\156\002\000\000\000\000\156\002\000\000\177\002\156\002\156\002\ +\156\002\177\000\177\000\010\000\000\000\157\001\156\002\178\000\ +\178\000\000\000\178\000\156\002\156\002\000\000\000\000\000\000\ +\000\000\174\000\000\000\000\000\178\000\178\000\000\000\000\000\ +\156\002\000\000\181\003\000\000\156\002\156\002\011\002\000\000\ +\195\000\000\000\199\001\000\000\000\000\177\000\000\000\000\000\ +\156\002\000\000\000\000\156\002\178\000\004\002\177\000\000\000\ +\003\002\195\000\000\000\000\000\136\000\000\000\137\000\138\000\ +\030\000\000\000\139\000\000\000\000\000\140\000\141\000\000\000\ +\000\000\000\000\000\000\023\003\000\000\000\000\000\000\000\000\ +\000\000\184\001\000\000\000\000\000\000\000\000\142\000\000\000\ +\023\003\000\000\000\000\000\000\000\000\010\000\143\000\144\000\ +\000\000\003\002\000\000\000\000\054\000\023\003\145\000\023\003\ +\023\003\000\000\174\000\180\000\180\000\000\000\000\000\000\000\ +\000\000\000\000\146\000\147\000\023\003\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\179\000\179\000\000\000\179\000\ +\000\000\000\000\184\001\199\002\180\000\180\000\180\000\023\003\ +\195\000\179\000\179\000\000\000\180\000\000\000\136\000\023\003\ +\137\000\138\000\030\000\000\000\139\000\023\003\081\001\158\001\ +\141\000\000\000\000\000\023\003\000\000\195\000\000\000\000\000\ +\000\000\179\000\179\000\180\000\180\000\000\000\000\000\000\000\ +\180\000\000\000\000\000\023\003\180\000\220\000\220\000\000\000\ +\000\000\144\000\087\001\088\001\089\001\090\001\078\002\023\003\ +\145\000\011\002\023\003\000\000\000\000\000\000\000\000\000\000\ +\000\000\011\002\000\000\000\000\146\000\147\000\011\002\184\001\ +\180\000\186\000\000\000\174\000\177\000\000\000\092\001\093\001\ +\184\001\038\003\000\000\011\002\000\000\011\002\011\002\000\000\ +\000\000\000\000\095\001\096\001\097\001\098\001\000\000\174\000\ +\195\000\195\000\011\002\180\000\195\000\000\000\195\000\003\002\ +\130\001\131\001\000\000\100\001\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\011\002\000\000\000\000\ +\011\002\000\000\000\000\011\002\011\002\011\002\000\000\000\000\ +\000\000\000\000\177\000\011\002\000\000\000\000\000\000\000\000\ +\159\001\011\002\186\002\000\000\190\002\000\000\038\003\159\001\ +\000\000\159\001\000\000\000\000\000\000\011\002\177\000\003\002\ +\000\000\011\002\011\002\177\000\177\000\177\000\000\000\000\000\ +\174\000\177\000\184\001\000\000\000\000\011\002\000\000\177\000\ +\011\002\000\000\000\000\000\000\000\000\000\000\000\000\178\000\ +\004\002\000\000\000\000\000\000\000\000\000\000\174\000\000\000\ +\167\001\000\000\000\000\000\000\000\000\000\000\000\000\177\000\ +\138\002\180\003\000\000\000\000\000\000\168\001\000\000\000\000\ +\178\000\178\000\178\000\000\000\081\001\000\000\000\000\000\000\ +\178\000\000\000\000\000\000\000\000\000\048\006\000\000\000\000\ +\136\000\000\000\137\000\138\000\030\000\184\001\139\000\000\000\ +\060\006\169\001\141\000\000\000\054\000\000\000\180\000\004\002\ +\178\000\088\001\089\001\090\001\004\002\000\000\000\000\000\000\ +\178\000\054\000\000\000\000\000\000\000\180\000\180\000\000\000\ +\179\002\180\003\000\000\144\000\000\000\000\000\054\000\000\000\ +\054\000\054\000\145\000\000\000\092\001\093\001\000\000\000\000\ +\000\000\000\000\000\000\000\000\178\000\054\000\146\000\147\000\ +\095\001\096\001\097\001\098\001\000\000\178\000\000\000\000\000\ +\000\000\180\000\000\000\000\000\179\000\179\000\000\000\000\000\ +\054\000\100\001\180\000\054\000\180\000\000\000\184\001\178\000\ +\054\000\003\002\000\000\000\000\000\000\000\000\054\000\000\000\ +\000\000\000\000\000\000\195\000\054\000\179\000\179\000\179\000\ +\003\002\000\000\000\000\000\000\000\000\179\000\179\000\000\000\ +\054\000\000\000\000\000\000\000\054\000\054\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\180\000\000\000\000\000\ +\054\000\000\000\178\000\054\000\179\000\179\000\000\000\000\000\ +\000\000\179\000\000\000\000\000\000\000\179\000\000\000\079\002\ +\080\002\081\002\082\002\083\002\084\002\085\002\086\002\087\002\ +\088\002\089\002\090\002\091\002\092\002\093\002\094\002\095\002\ +\096\002\097\002\098\002\099\002\182\002\102\002\000\000\000\000\ +\103\002\179\000\000\000\105\002\000\000\106\002\000\000\107\002\ +\000\000\108\002\179\000\109\002\000\000\000\000\003\002\000\000\ +\000\000\000\000\000\000\159\001\000\000\000\000\000\000\000\000\ +\126\002\000\000\000\000\000\000\179\000\000\000\000\000\186\002\ +\000\000\190\002\000\000\078\002\000\000\000\000\000\000\142\002\ +\000\000\143\002\000\000\000\000\000\000\000\000\186\002\186\002\ +\190\002\190\002\178\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\158\002\000\000\186\002\000\000\190\002\000\000\000\000\ +\180\000\178\000\178\000\000\000\138\002\000\000\000\000\179\000\ +\000\000\057\000\000\000\194\000\000\000\000\000\186\002\000\000\ +\190\002\186\002\000\000\190\002\000\000\000\000\186\002\000\000\ +\190\002\000\000\000\000\180\000\186\002\000\000\190\002\003\002\ +\000\000\000\000\186\002\213\002\190\002\178\000\000\000\000\000\ +\000\000\000\000\000\000\138\002\000\000\000\000\178\000\000\000\ +\004\002\000\000\186\002\186\002\190\002\190\002\180\000\000\000\ +\000\000\000\000\228\002\000\000\000\000\000\000\186\002\000\000\ +\190\002\186\002\212\002\190\002\213\002\000\000\000\000\000\000\ +\000\000\000\000\180\000\180\000\000\000\000\000\160\004\180\000\ +\180\000\180\000\000\000\000\000\213\002\180\000\213\002\213\002\ +\213\002\004\002\213\002\180\000\000\000\213\002\213\002\179\000\ +\000\000\003\003\136\000\006\003\137\000\138\000\030\000\000\000\ +\139\000\000\000\000\000\140\000\141\000\000\000\179\000\179\000\ +\000\000\020\003\000\000\180\000\000\000\177\001\022\003\213\002\ +\000\000\000\000\000\000\000\000\142\000\000\000\213\002\000\000\ +\003\002\000\000\000\000\000\000\143\000\144\000\000\000\194\000\ +\000\000\229\002\213\002\213\002\145\000\000\000\000\000\000\000\ +\000\000\000\000\179\000\000\000\003\002\000\000\000\000\000\000\ +\146\000\147\000\000\000\179\000\000\000\179\000\000\000\000\000\ +\000\000\000\000\000\000\220\000\220\000\000\000\000\000\000\000\ +\000\000\159\001\000\000\000\000\000\000\000\000\073\004\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\138\002\000\000\ +\000\000\247\000\000\000\000\000\182\002\000\000\000\000\182\002\ +\000\000\000\000\000\000\000\000\178\000\000\000\179\000\089\003\ +\000\000\182\002\000\000\000\000\095\003\096\003\097\003\000\000\ +\000\000\000\000\000\000\000\000\000\000\003\002\182\002\182\002\ +\182\002\182\002\000\000\099\003\000\000\180\000\102\003\004\002\ +\000\000\000\000\000\000\000\000\000\000\182\002\000\000\000\000\ +\000\000\138\002\000\000\003\002\180\000\000\000\000\000\138\002\ +\000\000\000\000\000\000\000\000\000\000\000\000\045\006\000\000\ +\182\002\000\000\178\000\000\000\173\002\000\000\182\002\182\002\ +\182\002\000\000\000\000\000\000\000\000\173\002\182\002\000\000\ +\000\000\057\000\000\000\000\000\182\002\000\000\178\000\004\002\ +\000\000\000\000\000\000\178\000\178\000\178\000\057\000\000\000\ +\182\002\178\000\182\002\000\000\182\002\173\002\000\000\178\000\ +\173\002\000\000\000\000\057\000\000\000\057\000\057\000\000\000\ +\182\002\173\002\011\002\182\002\000\000\000\000\078\006\161\003\ +\000\000\179\000\057\000\000\000\165\003\166\003\167\003\178\000\ +\000\000\014\003\180\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\183\003\000\000\057\000\000\000\000\000\ +\057\000\000\000\000\000\000\000\179\000\057\000\000\000\138\002\ +\000\000\000\000\000\000\057\000\000\000\000\000\000\000\000\000\ +\000\000\057\000\000\000\200\003\000\000\000\000\203\003\000\000\ +\000\000\000\000\000\000\000\000\000\000\057\000\000\000\179\000\ +\000\000\057\000\057\000\210\003\138\002\000\000\000\000\138\002\ +\136\000\000\000\137\000\138\000\030\000\057\000\139\000\000\000\ +\057\000\140\000\141\000\179\000\179\000\232\004\000\000\000\000\ +\179\000\179\000\179\000\000\000\000\000\000\000\179\000\000\000\ +\000\000\000\000\142\000\180\000\179\000\000\000\000\000\000\000\ +\000\000\000\000\143\000\126\003\000\000\000\000\000\000\000\000\ +\032\000\000\000\145\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\004\002\000\000\000\000\179\000\151\004\146\000\147\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\004\002\000\000\000\000\000\000\000\000\000\000\000\000\040\004\ +\000\000\247\000\247\000\247\000\247\000\000\000\138\002\000\000\ +\000\000\247\000\247\000\247\000\000\000\138\002\247\000\247\000\ +\000\000\247\000\247\000\247\000\247\000\247\000\247\000\000\000\ +\000\000\247\000\247\000\247\000\247\000\247\000\247\000\000\000\ +\000\000\138\002\078\004\000\000\000\000\247\000\247\000\000\000\ +\000\000\247\000\247\000\247\000\247\000\000\000\081\000\000\000\ +\000\000\247\000\247\000\000\000\180\000\255\004\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\247\000\247\000\000\000\ +\247\000\000\000\000\000\247\000\247\000\247\000\004\002\247\000\ +\180\000\000\000\247\000\247\000\000\000\000\000\000\000\000\000\ +\000\000\247\000\000\000\247\000\000\000\000\000\179\000\118\004\ +\000\000\000\000\000\000\000\000\247\000\247\000\000\000\247\000\ +\247\000\247\000\247\000\000\000\000\000\179\000\000\000\000\000\ +\247\000\000\000\247\000\000\000\141\004\247\000\000\000\159\001\ +\247\000\000\000\011\002\000\000\247\000\011\002\000\000\148\004\ +\000\000\000\000\011\002\138\002\000\000\000\000\000\000\011\002\ +\000\000\000\000\000\000\195\000\000\000\011\002\023\003\000\000\ +\000\000\180\000\000\000\000\000\011\002\000\000\011\002\011\002\ +\000\000\000\000\000\000\023\003\000\000\000\000\000\000\004\002\ +\000\000\000\000\000\000\011\002\179\004\000\000\181\004\180\000\ +\255\004\138\002\000\000\000\000\000\000\000\000\023\003\000\000\ +\023\003\023\003\023\003\138\002\023\003\000\000\011\002\023\003\ +\023\003\011\002\000\000\179\000\011\002\011\002\011\002\000\000\ +\159\001\000\000\000\000\113\005\011\002\000\000\000\000\000\000\ +\000\000\000\000\011\002\000\000\000\000\000\000\208\004\209\004\ +\210\004\023\003\000\000\000\000\229\000\000\000\011\002\000\000\ +\023\003\000\000\011\002\011\002\000\000\216\004\000\000\000\000\ +\000\000\000\000\000\000\000\000\023\003\023\003\011\002\000\000\ +\032\000\011\002\000\000\032\000\000\000\000\000\000\000\000\000\ +\000\000\230\004\000\000\138\002\138\002\032\000\032\000\000\000\ +\000\000\032\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\004\002\000\000\032\000\032\000\032\000\032\000\000\000\195\000\ +\000\000\238\004\239\004\240\004\179\000\000\000\000\000\000\000\ +\032\000\032\000\000\000\000\000\004\002\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\138\002\000\000\000\000\113\005\ +\000\000\000\000\000\000\000\000\032\000\000\000\000\000\032\000\ +\000\000\000\000\000\000\032\000\032\000\000\000\000\000\185\005\ +\186\005\032\000\032\000\030\005\000\000\000\000\081\000\255\004\ +\032\000\081\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\081\000\032\000\000\000\032\000\081\000\ +\032\000\032\000\000\000\000\000\000\000\255\004\000\000\000\000\ +\081\000\081\000\081\000\081\000\032\000\004\002\000\000\032\000\ +\000\000\060\002\000\000\032\000\000\000\000\000\052\005\081\000\ +\054\005\000\000\056\005\016\003\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\004\002\000\000\179\000\000\000\000\000\ +\000\000\000\000\081\000\000\000\000\000\081\000\078\005\079\005\ +\080\005\081\000\081\000\000\000\087\005\088\005\089\005\000\000\ +\081\000\179\000\000\000\000\000\000\000\000\000\081\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\081\000\000\000\081\000\103\005\081\000\081\000\ +\000\000\113\005\136\000\000\000\137\000\138\000\030\000\255\004\ +\139\000\118\005\081\000\140\000\141\000\081\000\000\000\000\000\ +\000\000\255\004\125\005\000\000\000\000\000\000\129\005\138\002\ +\000\000\000\000\000\000\000\000\142\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\143\000\144\000\000\000\000\000\ +\000\000\000\000\179\000\000\000\145\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\146\000\147\000\000\000\000\000\229\000\229\000\229\000\229\000\ +\179\000\000\000\255\004\000\000\229\000\229\000\229\000\000\000\ +\000\000\229\000\229\000\229\000\229\000\229\000\229\000\229\000\ +\229\000\229\000\000\000\000\000\229\000\229\000\229\000\229\000\ +\229\000\229\000\000\000\122\002\000\000\000\000\000\000\000\000\ +\229\000\229\000\000\000\000\000\229\000\229\000\229\000\229\000\ +\229\000\229\000\229\000\000\000\229\000\229\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\255\004\000\000\000\000\000\000\ +\229\000\229\000\000\000\229\000\000\000\000\000\229\000\229\000\ +\229\000\000\000\229\000\229\000\229\000\229\000\229\000\000\000\ +\000\000\000\000\000\000\113\005\229\000\113\005\229\000\229\000\ +\229\000\229\000\229\000\000\000\000\000\000\000\000\000\229\000\ +\229\000\000\000\229\000\229\000\229\000\229\000\000\000\000\000\ +\229\000\000\000\000\000\229\000\000\000\229\000\000\000\000\000\ +\229\000\000\000\000\000\229\000\000\000\000\000\000\000\229\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\239\005\000\000\000\000\000\000\014\000\000\000\000\000\000\000\ +\000\000\060\002\000\000\060\002\060\002\060\002\250\005\251\005\ +\252\005\060\002\000\000\015\000\016\000\000\000\060\002\164\002\ +\000\000\000\000\060\002\060\002\060\002\000\000\000\000\000\000\ +\023\000\000\000\007\006\060\002\060\002\060\002\060\002\000\000\ +\000\000\000\000\000\000\000\000\000\000\060\002\000\000\018\006\ +\000\000\060\002\060\002\031\000\000\000\022\006\074\001\000\000\ +\000\000\060\002\060\002\035\000\000\000\000\000\000\000\000\000\ +\000\000\039\000\000\000\000\000\000\000\060\002\037\006\042\000\ +\060\002\000\000\000\000\060\002\060\002\060\002\046\006\060\002\ +\000\000\000\000\060\002\060\002\000\000\000\000\000\000\046\000\ +\000\000\060\002\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\050\000\060\002\060\002\053\000\060\002\ +\060\002\060\002\000\000\000\000\000\000\060\002\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\060\002\000\000\000\000\ +\060\002\000\000\000\000\000\000\060\002\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\079\006\080\006\ +\000\000\000\000\000\000\041\001\000\000\082\006\083\006\084\006\ +\085\006\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\089\006\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\122\002\122\002\122\002\122\002\000\000\ +\099\006\122\002\122\002\122\002\122\002\122\002\122\002\122\002\ +\122\002\122\002\122\002\122\002\122\002\122\002\122\002\122\002\ +\122\002\122\002\000\000\122\002\122\002\122\002\122\002\122\002\ +\122\002\122\002\122\002\000\000\000\000\000\000\000\000\122\002\ +\122\002\000\000\000\000\122\002\122\002\122\002\122\002\122\002\ +\122\002\122\002\122\002\122\002\122\002\122\002\122\002\000\000\ +\122\002\122\002\122\002\122\002\000\000\000\000\122\002\122\002\ +\122\002\110\002\122\002\122\002\122\002\122\002\122\002\122\002\ +\000\000\122\002\122\002\122\002\122\002\122\002\000\000\122\002\ +\000\000\000\000\000\000\122\002\122\002\122\002\122\002\122\002\ +\122\002\122\002\122\002\000\000\122\002\000\000\122\002\122\002\ +\061\001\122\002\122\002\122\002\122\002\122\002\000\000\122\002\ +\122\002\000\000\122\002\122\002\122\002\122\002\000\000\122\002\ +\122\002\000\000\122\002\000\000\000\000\000\000\122\002\164\002\ +\164\002\164\002\164\002\164\002\000\000\164\002\164\002\164\002\ +\164\002\164\002\164\002\164\002\164\002\164\002\164\002\164\002\ +\164\002\164\002\164\002\164\002\164\002\000\000\000\000\164\002\ +\164\002\164\002\164\002\164\002\164\002\164\002\164\002\000\000\ +\000\000\000\000\000\000\164\002\164\002\000\000\000\000\164\002\ +\164\002\164\002\164\002\164\002\164\002\164\002\164\002\164\002\ +\164\002\164\002\164\002\000\000\164\002\164\002\164\002\164\002\ +\000\000\000\000\164\002\164\002\164\002\000\000\164\002\164\002\ +\164\002\164\002\164\002\164\002\000\000\164\002\164\002\164\002\ +\164\002\164\002\000\000\164\002\000\000\000\000\000\000\164\002\ +\164\002\164\002\164\002\164\002\164\002\164\002\164\002\000\000\ +\164\002\000\000\164\002\164\002\047\001\164\002\164\002\164\002\ +\164\002\164\002\000\000\164\002\164\002\000\000\164\002\164\002\ +\164\002\164\002\000\000\164\002\164\002\000\000\164\002\000\000\ +\000\000\000\000\164\002\041\001\041\001\041\001\041\001\000\000\ +\000\000\041\001\041\001\041\001\041\001\041\001\041\001\041\001\ +\041\001\041\001\041\001\041\001\041\001\041\001\041\001\041\001\ +\041\001\041\001\000\000\041\001\041\001\041\001\041\001\041\001\ +\041\001\041\001\041\001\000\000\000\000\000\000\000\000\041\001\ +\041\001\000\000\000\000\041\001\041\001\041\001\041\001\041\001\ +\041\001\041\001\041\001\041\001\041\001\041\001\041\001\000\000\ +\041\001\041\001\041\001\041\001\000\000\000\000\041\001\041\001\ +\041\001\000\000\041\001\041\001\041\001\041\001\041\001\041\001\ +\000\000\041\001\041\001\041\001\041\001\041\001\000\000\041\001\ +\000\000\000\000\000\000\041\001\041\001\041\001\041\001\041\001\ +\041\001\041\001\041\001\000\000\041\001\000\000\041\001\041\001\ +\045\001\041\001\041\001\041\001\041\001\041\001\000\000\041\001\ +\041\001\000\000\041\001\041\001\041\001\041\001\000\000\041\001\ +\041\001\000\000\041\001\000\000\000\000\000\000\041\001\000\000\ +\061\001\061\001\061\001\061\001\000\000\000\000\061\001\061\001\ +\061\001\061\001\061\001\061\001\061\001\061\001\061\001\061\001\ +\061\001\061\001\061\001\061\001\061\001\061\001\061\001\000\000\ +\061\001\061\001\061\001\061\001\061\001\061\001\061\001\061\001\ +\000\000\000\000\000\000\000\000\061\001\061\001\000\000\000\000\ +\061\001\061\001\061\001\061\001\061\001\061\001\061\001\061\001\ +\061\001\061\001\061\001\061\001\000\000\061\001\061\001\061\001\ +\061\001\000\000\000\000\061\001\061\001\061\001\000\000\061\001\ +\061\001\061\001\061\001\061\001\061\001\000\000\061\001\061\001\ +\061\001\061\001\061\001\000\000\061\001\000\000\000\000\000\000\ +\061\001\061\001\061\001\061\001\061\001\061\001\061\001\061\001\ +\000\000\061\001\000\000\061\001\061\001\053\001\061\001\061\001\ +\061\001\061\001\061\001\000\000\061\001\061\001\000\000\061\001\ +\061\001\061\001\061\001\000\000\061\001\061\001\000\000\061\001\ +\000\000\000\000\000\000\061\001\047\001\047\001\047\001\047\001\ +\000\000\000\000\047\001\047\001\047\001\047\001\047\001\047\001\ +\047\001\047\001\047\001\047\001\047\001\047\001\047\001\047\001\ +\047\001\047\001\047\001\000\000\047\001\047\001\047\001\047\001\ +\047\001\047\001\047\001\047\001\000\000\000\000\000\000\000\000\ +\047\001\047\001\000\000\000\000\047\001\047\001\047\001\047\001\ +\047\001\047\001\047\001\047\001\047\001\047\001\047\001\047\001\ +\000\000\047\001\047\001\047\001\047\001\000\000\000\000\047\001\ +\047\001\047\001\000\000\047\001\047\001\047\001\047\001\047\001\ +\047\001\000\000\047\001\047\001\047\001\047\001\047\001\000\000\ +\047\001\000\000\000\000\000\000\047\001\047\001\047\001\047\001\ +\047\001\047\001\047\001\047\001\000\000\047\001\000\000\047\001\ +\047\001\049\001\047\001\047\001\047\001\047\001\047\001\000\000\ +\047\001\047\001\000\000\047\001\047\001\047\001\047\001\000\000\ +\047\001\047\001\000\000\047\001\000\000\000\000\000\000\047\001\ +\045\001\045\001\045\001\045\001\000\000\000\000\045\001\045\001\ +\045\001\045\001\045\001\045\001\045\001\045\001\045\001\045\001\ +\045\001\045\001\045\001\045\001\045\001\045\001\045\001\000\000\ +\045\001\045\001\045\001\045\001\045\001\045\001\045\001\045\001\ +\000\000\000\000\000\000\000\000\045\001\045\001\000\000\000\000\ +\045\001\045\001\045\001\045\001\045\001\045\001\045\001\045\001\ +\045\001\045\001\045\001\045\001\000\000\045\001\045\001\045\001\ +\045\001\000\000\000\000\045\001\045\001\045\001\000\000\045\001\ +\045\001\045\001\045\001\045\001\045\001\000\000\045\001\045\001\ +\045\001\045\001\045\001\000\000\045\001\000\000\000\000\000\000\ +\045\001\045\001\045\001\045\001\045\001\045\001\045\001\045\001\ +\000\000\045\001\000\000\045\001\045\001\051\001\045\001\045\001\ +\045\001\045\001\045\001\000\000\045\001\045\001\000\000\045\001\ +\045\001\045\001\045\001\000\000\045\001\045\001\000\000\045\001\ +\000\000\000\000\000\000\045\001\000\000\053\001\053\001\053\001\ +\053\001\000\000\000\000\053\001\053\001\053\001\053\001\053\001\ +\053\001\053\001\053\001\053\001\053\001\053\001\053\001\053\001\ +\053\001\053\001\053\001\053\001\000\000\053\001\053\001\053\001\ +\053\001\053\001\053\001\053\001\053\001\000\000\000\000\000\000\ +\000\000\053\001\053\001\000\000\000\000\053\001\053\001\053\001\ +\053\001\053\001\053\001\053\001\053\001\053\001\053\001\053\001\ +\053\001\000\000\053\001\053\001\053\001\053\001\000\000\000\000\ +\053\001\053\001\053\001\000\000\053\001\053\001\053\001\053\001\ +\053\001\053\001\000\000\053\001\053\001\053\001\053\001\053\001\ +\000\000\053\001\000\000\000\000\000\000\053\001\053\001\053\001\ +\053\001\053\001\053\001\053\001\053\001\000\000\053\001\000\000\ +\053\001\053\001\059\001\053\001\053\001\053\001\053\001\053\001\ +\000\000\053\001\053\001\000\000\053\001\053\001\053\001\053\001\ +\000\000\053\001\053\001\000\000\053\001\000\000\000\000\000\000\ +\053\001\049\001\049\001\049\001\049\001\000\000\000\000\049\001\ +\049\001\049\001\049\001\049\001\049\001\049\001\049\001\049\001\ +\049\001\049\001\049\001\049\001\049\001\049\001\049\001\049\001\ +\000\000\049\001\049\001\049\001\049\001\049\001\049\001\049\001\ +\049\001\000\000\000\000\000\000\000\000\049\001\049\001\000\000\ +\000\000\049\001\049\001\049\001\049\001\049\001\049\001\049\001\ +\049\001\049\001\049\001\049\001\049\001\000\000\049\001\049\001\ +\049\001\049\001\000\000\000\000\049\001\049\001\049\001\000\000\ +\049\001\049\001\049\001\049\001\049\001\049\001\000\000\049\001\ +\049\001\049\001\049\001\049\001\000\000\049\001\000\000\000\000\ +\000\000\049\001\049\001\049\001\049\001\049\001\049\001\049\001\ +\049\001\000\000\049\001\000\000\049\001\049\001\055\001\049\001\ +\049\001\049\001\049\001\049\001\000\000\049\001\049\001\000\000\ +\049\001\049\001\049\001\049\001\000\000\049\001\049\001\000\000\ +\049\001\000\000\000\000\000\000\049\001\051\001\051\001\051\001\ +\051\001\000\000\000\000\051\001\051\001\051\001\051\001\051\001\ +\051\001\051\001\051\001\051\001\051\001\051\001\051\001\051\001\ +\051\001\051\001\051\001\051\001\000\000\051\001\051\001\051\001\ +\051\001\051\001\051\001\051\001\051\001\000\000\000\000\000\000\ +\000\000\051\001\051\001\000\000\000\000\051\001\051\001\051\001\ +\051\001\051\001\051\001\051\001\051\001\051\001\051\001\051\001\ +\051\001\000\000\051\001\051\001\051\001\051\001\000\000\000\000\ +\051\001\051\001\051\001\000\000\051\001\051\001\051\001\051\001\ +\051\001\051\001\000\000\051\001\051\001\051\001\051\001\051\001\ +\000\000\051\001\000\000\000\000\000\000\051\001\051\001\051\001\ +\051\001\051\001\051\001\051\001\051\001\000\000\051\001\000\000\ +\051\001\051\001\057\001\051\001\051\001\051\001\051\001\051\001\ +\000\000\051\001\051\001\000\000\051\001\051\001\051\001\051\001\ +\000\000\051\001\051\001\000\000\051\001\000\000\000\000\000\000\ +\051\001\000\000\059\001\059\001\059\001\059\001\000\000\000\000\ +\059\001\059\001\059\001\059\001\059\001\059\001\059\001\059\001\ +\059\001\059\001\059\001\059\001\059\001\059\001\059\001\059\001\ +\059\001\000\000\059\001\059\001\059\001\059\001\059\001\059\001\ +\059\001\059\001\000\000\000\000\000\000\000\000\059\001\059\001\ +\000\000\000\000\059\001\059\001\059\001\059\001\059\001\059\001\ +\059\001\059\001\059\001\059\001\059\001\059\001\000\000\059\001\ +\059\001\059\001\059\001\000\000\000\000\059\001\059\001\059\001\ +\000\000\059\001\059\001\059\001\059\001\059\001\059\001\000\000\ +\059\001\059\001\059\001\059\001\059\001\000\000\059\001\000\000\ +\000\000\000\000\059\001\059\001\059\001\059\001\059\001\059\001\ +\059\001\059\001\000\000\059\001\000\000\059\001\059\001\088\001\ +\059\001\059\001\059\001\059\001\059\001\000\000\059\001\059\001\ +\000\000\059\001\059\001\059\001\059\001\000\000\059\001\059\001\ +\000\000\059\001\000\000\000\000\000\000\059\001\055\001\055\001\ +\055\001\055\001\000\000\000\000\055\001\055\001\055\001\055\001\ +\055\001\055\001\055\001\055\001\055\001\055\001\055\001\055\001\ +\055\001\055\001\055\001\055\001\055\001\000\000\055\001\055\001\ +\055\001\055\001\055\001\055\001\055\001\055\001\000\000\000\000\ +\000\000\000\000\055\001\055\001\000\000\000\000\055\001\055\001\ +\055\001\055\001\055\001\055\001\055\001\055\001\055\001\055\001\ +\055\001\055\001\000\000\055\001\055\001\055\001\055\001\000\000\ +\000\000\055\001\055\001\055\001\000\000\055\001\055\001\055\001\ +\055\001\055\001\055\001\000\000\055\001\055\001\055\001\055\001\ +\055\001\000\000\055\001\000\000\000\000\000\000\055\001\055\001\ +\055\001\055\001\055\001\055\001\055\001\055\001\000\000\055\001\ +\000\000\055\001\055\001\097\001\055\001\055\001\055\001\055\001\ +\055\001\000\000\055\001\055\001\000\000\055\001\055\001\055\001\ +\055\001\000\000\055\001\055\001\000\000\055\001\000\000\000\000\ +\000\000\055\001\057\001\057\001\057\001\057\001\000\000\000\000\ +\057\001\057\001\057\001\057\001\057\001\057\001\057\001\057\001\ +\057\001\057\001\057\001\057\001\057\001\057\001\057\001\057\001\ +\057\001\000\000\057\001\057\001\057\001\057\001\057\001\057\001\ +\057\001\057\001\000\000\000\000\000\000\000\000\057\001\057\001\ +\000\000\000\000\057\001\057\001\057\001\057\001\057\001\057\001\ +\057\001\057\001\057\001\057\001\057\001\057\001\000\000\057\001\ +\057\001\057\001\057\001\000\000\000\000\057\001\057\001\057\001\ +\000\000\057\001\057\001\057\001\057\001\057\001\057\001\000\000\ +\057\001\057\001\057\001\057\001\057\001\000\000\057\001\000\000\ +\000\000\000\000\057\001\057\001\057\001\057\001\057\001\057\001\ +\057\001\057\001\000\000\057\001\000\000\057\001\057\001\099\001\ +\057\001\057\001\057\001\057\001\057\001\000\000\057\001\057\001\ +\000\000\057\001\057\001\057\001\057\001\000\000\057\001\057\001\ +\000\000\057\001\000\000\000\000\000\000\057\001\000\000\088\001\ +\088\001\088\001\088\001\088\001\000\000\088\001\088\001\088\001\ +\088\001\088\001\088\001\088\001\088\001\088\001\088\001\088\001\ +\088\001\088\001\088\001\088\001\088\001\000\000\000\000\088\001\ +\088\001\088\001\088\001\088\001\088\001\088\001\088\001\000\000\ +\000\000\000\000\000\000\088\001\088\001\000\000\000\000\088\001\ +\088\001\088\001\088\001\088\001\088\001\088\001\000\000\088\001\ +\088\001\088\001\088\001\000\000\088\001\088\001\088\001\088\001\ +\000\000\000\000\088\001\088\001\088\001\000\000\088\001\088\001\ +\088\001\088\001\088\001\088\001\000\000\088\001\088\001\088\001\ +\088\001\088\001\000\000\088\001\000\000\000\000\000\000\088\001\ +\088\001\088\001\088\001\088\001\088\001\088\001\088\001\000\000\ +\088\001\000\000\088\001\088\001\102\001\088\001\088\001\088\001\ +\088\001\088\001\000\000\088\001\088\001\000\000\088\001\088\001\ +\088\001\088\001\000\000\088\001\088\001\000\000\088\001\000\000\ +\000\000\000\000\088\001\097\001\097\001\097\001\097\001\097\001\ +\000\000\097\001\097\001\097\001\097\001\097\001\097\001\097\001\ +\097\001\097\001\097\001\097\001\097\001\097\001\097\001\097\001\ +\097\001\000\000\000\000\097\001\097\001\097\001\097\001\097\001\ +\097\001\097\001\097\001\000\000\000\000\000\000\000\000\097\001\ +\097\001\000\000\000\000\097\001\097\001\097\001\097\001\097\001\ +\097\001\097\001\000\000\097\001\097\001\097\001\097\001\000\000\ +\097\001\097\001\097\001\097\001\000\000\000\000\097\001\097\001\ +\097\001\000\000\097\001\097\001\097\001\097\001\097\001\097\001\ +\000\000\097\001\097\001\097\001\097\001\097\001\000\000\097\001\ +\000\000\000\000\000\000\097\001\097\001\097\001\097\001\097\001\ +\097\001\097\001\097\001\000\000\097\001\000\000\097\001\097\001\ +\033\001\097\001\097\001\097\001\000\000\000\000\000\000\097\001\ +\097\001\000\000\097\001\097\001\097\001\097\001\000\000\097\001\ +\097\001\000\000\097\001\000\000\000\000\000\000\097\001\099\001\ +\099\001\099\001\099\001\099\001\000\000\099\001\099\001\099\001\ +\099\001\099\001\099\001\099\001\099\001\099\001\099\001\099\001\ +\099\001\099\001\099\001\099\001\099\001\000\000\000\000\099\001\ +\099\001\099\001\099\001\099\001\099\001\099\001\099\001\000\000\ +\000\000\000\000\000\000\099\001\099\001\000\000\000\000\099\001\ +\099\001\099\001\099\001\099\001\099\001\099\001\000\000\099\001\ +\099\001\099\001\099\001\000\000\099\001\099\001\099\001\099\001\ +\000\000\000\000\099\001\099\001\099\001\000\000\099\001\099\001\ +\099\001\099\001\099\001\099\001\000\000\099\001\099\001\099\001\ +\099\001\099\001\000\000\099\001\000\000\000\000\000\000\099\001\ +\099\001\099\001\099\001\099\001\099\001\099\001\099\001\000\000\ +\099\001\000\000\099\001\099\001\034\001\099\001\099\001\099\001\ +\000\000\000\000\000\000\099\001\099\001\000\000\099\001\099\001\ +\099\001\099\001\000\000\099\001\099\001\000\000\099\001\000\000\ +\000\000\000\000\099\001\000\000\102\001\102\001\102\001\102\001\ +\102\001\000\000\102\001\102\001\102\001\102\001\102\001\102\001\ +\102\001\102\001\102\001\102\001\102\001\102\001\102\001\102\001\ +\102\001\102\001\000\000\000\000\102\001\102\001\102\001\102\001\ +\102\001\102\001\102\001\102\001\000\000\000\000\000\000\000\000\ +\102\001\102\001\000\000\000\000\102\001\102\001\102\001\102\001\ +\102\001\102\001\102\001\000\000\102\001\102\001\102\001\102\001\ +\000\000\102\001\102\001\102\001\102\001\000\000\000\000\102\001\ +\102\001\102\001\000\000\102\001\102\001\102\001\102\001\102\001\ +\102\001\000\000\102\001\102\001\102\001\102\001\102\001\000\000\ +\102\001\000\000\000\000\000\000\102\001\102\001\102\001\102\001\ +\102\001\102\001\102\001\102\001\000\000\102\001\000\000\102\001\ +\102\001\228\000\102\001\102\001\102\001\000\000\000\000\000\000\ +\102\001\102\001\000\000\102\001\102\001\102\001\102\001\000\000\ +\102\001\102\001\000\000\102\001\000\000\000\000\000\000\102\001\ +\033\001\033\001\033\001\033\001\000\000\000\000\000\000\000\000\ +\033\001\033\001\033\001\000\000\000\000\033\001\033\001\033\001\ +\033\001\033\001\033\001\033\001\033\001\033\001\033\001\000\000\ +\033\001\033\001\033\001\033\001\033\001\033\001\000\000\000\000\ +\000\000\000\000\000\000\000\000\033\001\033\001\000\000\000\000\ +\033\001\033\001\033\001\033\001\033\001\033\001\033\001\033\001\ +\033\001\033\001\000\000\033\001\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\033\001\033\001\000\000\033\001\ +\000\000\000\000\033\001\033\001\033\001\000\000\033\001\033\001\ +\033\001\033\001\033\001\000\000\000\000\000\000\000\000\000\000\ +\033\001\033\001\033\001\033\001\033\001\033\001\033\001\000\000\ +\000\000\033\001\000\000\033\001\033\001\240\000\033\001\033\001\ +\033\001\033\001\033\001\000\000\033\001\000\000\000\000\033\001\ +\033\001\033\001\000\000\000\000\033\001\000\000\000\000\033\001\ +\000\000\000\000\000\000\033\001\034\001\034\001\034\001\034\001\ +\000\000\000\000\000\000\000\000\034\001\034\001\034\001\000\000\ +\000\000\034\001\034\001\034\001\034\001\034\001\034\001\034\001\ +\034\001\034\001\034\001\000\000\034\001\034\001\034\001\034\001\ +\034\001\034\001\000\000\000\000\000\000\000\000\000\000\000\000\ +\034\001\034\001\000\000\000\000\034\001\034\001\034\001\034\001\ +\034\001\034\001\034\001\034\001\034\001\034\001\000\000\034\001\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\034\001\034\001\000\000\034\001\000\000\000\000\034\001\034\001\ +\034\001\000\000\034\001\034\001\034\001\034\001\034\001\000\000\ +\000\000\000\000\000\000\000\000\034\001\034\001\034\001\034\001\ +\034\001\034\001\034\001\000\000\000\000\034\001\000\000\034\001\ +\034\001\241\000\034\001\034\001\034\001\034\001\034\001\000\000\ +\034\001\000\000\000\000\034\001\034\001\034\001\000\000\000\000\ +\034\001\000\000\000\000\034\001\000\000\000\000\000\000\034\001\ +\000\000\228\000\228\000\228\000\228\000\000\000\000\000\000\000\ +\000\000\228\000\228\000\228\000\000\000\000\000\228\000\228\000\ +\228\000\228\000\228\000\228\000\228\000\228\000\228\000\000\000\ +\000\000\228\000\228\000\228\000\228\000\228\000\228\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\228\000\228\000\000\000\ +\000\000\228\000\228\000\228\000\228\000\228\000\228\000\228\000\ +\000\000\228\000\228\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\228\000\228\000\000\000\ +\228\000\000\000\000\000\228\000\228\000\228\000\000\000\228\000\ +\228\000\228\000\228\000\228\000\000\000\000\000\000\000\000\000\ +\000\000\228\000\000\000\228\000\228\000\228\000\228\000\228\000\ +\000\000\000\000\000\000\000\000\228\000\228\000\242\000\228\000\ +\228\000\228\000\000\000\000\000\000\000\228\000\000\000\000\000\ +\228\000\000\000\228\000\000\000\000\000\228\000\000\000\000\000\ +\228\000\000\000\000\000\000\000\228\000\240\000\240\000\240\000\ +\240\000\000\000\000\000\000\000\000\000\240\000\240\000\240\000\ +\000\000\000\000\240\000\240\000\240\000\240\000\240\000\000\000\ +\240\000\240\000\240\000\000\000\000\000\240\000\240\000\240\000\ +\240\000\240\000\240\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\240\000\240\000\000\000\000\000\240\000\240\000\240\000\ +\240\000\240\000\240\000\240\000\000\000\240\000\240\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\240\000\240\000\000\000\240\000\000\000\000\000\240\000\ +\240\000\240\000\000\000\240\000\240\000\240\000\240\000\240\000\ +\000\000\000\000\000\000\000\000\000\000\240\000\000\000\240\000\ +\240\000\240\000\240\000\240\000\000\000\000\000\000\000\000\000\ +\240\000\240\000\025\001\240\000\240\000\240\000\240\000\000\000\ +\000\000\240\000\000\000\000\000\240\000\000\000\240\000\000\000\ +\000\000\240\000\000\000\000\000\240\000\000\000\000\000\000\000\ +\240\000\241\000\241\000\241\000\241\000\000\000\000\000\000\000\ +\000\000\241\000\241\000\241\000\000\000\000\000\241\000\241\000\ +\241\000\241\000\241\000\241\000\241\000\241\000\241\000\000\000\ +\000\000\241\000\241\000\241\000\241\000\241\000\241\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\241\000\241\000\000\000\ +\000\000\241\000\241\000\241\000\241\000\241\000\241\000\241\000\ +\000\000\241\000\241\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\241\000\241\000\000\000\ +\241\000\000\000\000\000\241\000\241\000\241\000\000\000\241\000\ +\241\000\241\000\241\000\241\000\000\000\000\000\000\000\000\000\ +\000\000\241\000\000\000\241\000\241\000\241\000\241\000\241\000\ +\000\000\000\000\000\000\000\000\241\000\241\000\026\001\241\000\ +\241\000\241\000\000\000\000\000\000\000\241\000\000\000\000\000\ +\241\000\000\000\241\000\000\000\000\000\241\000\000\000\000\000\ +\241\000\000\000\000\000\000\000\241\000\000\000\242\000\242\000\ +\242\000\242\000\000\000\000\000\000\000\000\000\242\000\242\000\ +\242\000\000\000\000\000\242\000\242\000\242\000\242\000\242\000\ +\242\000\242\000\242\000\242\000\000\000\000\000\242\000\242\000\ +\242\000\242\000\242\000\242\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\242\000\242\000\000\000\000\000\242\000\242\000\ +\242\000\242\000\242\000\242\000\242\000\000\000\242\000\242\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\242\000\242\000\000\000\242\000\000\000\000\000\ +\242\000\242\000\242\000\000\000\242\000\242\000\242\000\242\000\ +\242\000\000\000\000\000\000\000\000\000\000\000\242\000\000\000\ +\242\000\242\000\242\000\242\000\242\000\000\000\000\000\000\000\ +\000\000\242\000\242\000\251\000\242\000\242\000\242\000\000\000\ +\000\000\000\000\242\000\000\000\000\000\242\000\000\000\242\000\ +\000\000\000\000\242\000\000\000\000\000\242\000\000\000\000\000\ +\000\000\242\000\025\001\025\001\025\001\025\001\000\000\000\000\ +\000\000\000\000\025\001\025\001\025\001\000\000\000\000\025\001\ +\025\001\025\001\025\001\025\001\025\001\025\001\025\001\025\001\ +\000\000\000\000\025\001\025\001\025\001\025\001\025\001\025\001\ +\000\000\000\000\000\000\000\000\000\000\000\000\025\001\025\001\ +\000\000\000\000\025\001\025\001\025\001\025\001\025\001\025\001\ +\025\001\000\000\025\001\025\001\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\025\001\025\001\ +\000\000\025\001\000\000\000\000\025\001\025\001\025\001\000\000\ +\025\001\025\001\025\001\025\001\025\001\000\000\000\000\000\000\ +\000\000\000\000\025\001\000\000\025\001\025\001\025\001\025\001\ +\025\001\000\000\000\000\000\000\000\000\025\001\025\001\252\000\ +\025\001\025\001\025\001\000\000\000\000\000\000\025\001\000\000\ +\000\000\025\001\000\000\025\001\000\000\000\000\025\001\000\000\ +\000\000\025\001\000\000\000\000\000\000\025\001\026\001\026\001\ +\026\001\026\001\000\000\000\000\000\000\000\000\026\001\026\001\ +\026\001\000\000\000\000\026\001\026\001\026\001\026\001\026\001\ +\026\001\026\001\026\001\026\001\000\000\000\000\026\001\026\001\ +\026\001\026\001\026\001\026\001\000\000\000\000\000\000\000\000\ +\000\000\000\000\026\001\026\001\000\000\000\000\026\001\026\001\ +\026\001\026\001\026\001\026\001\026\001\000\000\026\001\026\001\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\026\001\026\001\000\000\026\001\000\000\000\000\ +\026\001\026\001\026\001\000\000\026\001\026\001\026\001\026\001\ +\026\001\000\000\000\000\000\000\000\000\000\000\026\001\000\000\ +\026\001\026\001\026\001\026\001\026\001\000\000\000\000\000\000\ +\000\000\026\001\026\001\003\001\026\001\026\001\026\001\000\000\ +\000\000\000\000\026\001\000\000\000\000\026\001\000\000\026\001\ +\000\000\000\000\026\001\000\000\000\000\026\001\000\000\000\000\ +\000\000\026\001\000\000\251\000\251\000\251\000\251\000\000\000\ +\000\000\000\000\000\000\251\000\251\000\251\000\000\000\000\000\ +\251\000\251\000\251\000\251\000\251\000\251\000\251\000\251\000\ +\251\000\000\000\000\000\251\000\251\000\251\000\251\000\251\000\ +\251\000\000\000\000\000\000\000\000\000\000\000\000\000\251\000\ +\251\000\000\000\000\000\251\000\251\000\251\000\251\000\251\000\ +\251\000\000\000\000\000\251\000\251\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\251\000\ +\251\000\000\000\251\000\000\000\000\000\251\000\251\000\251\000\ +\000\000\251\000\251\000\251\000\251\000\251\000\000\000\000\000\ +\000\000\000\000\000\000\251\000\000\000\251\000\251\000\251\000\ +\251\000\251\000\000\000\000\000\000\000\000\000\251\000\251\000\ +\002\001\251\000\251\000\251\000\251\000\000\000\000\000\251\000\ +\000\000\000\000\251\000\000\000\251\000\000\000\000\000\251\000\ +\000\000\000\000\251\000\000\000\000\000\000\000\251\000\252\000\ +\252\000\252\000\252\000\000\000\000\000\000\000\000\000\252\000\ +\252\000\252\000\000\000\000\000\252\000\252\000\252\000\252\000\ +\252\000\252\000\252\000\252\000\252\000\000\000\000\000\252\000\ +\252\000\252\000\252\000\252\000\252\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\252\000\252\000\000\000\000\000\252\000\ +\252\000\252\000\252\000\252\000\252\000\000\000\000\000\252\000\ +\252\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\252\000\252\000\000\000\252\000\000\000\ +\000\000\252\000\252\000\252\000\000\000\252\000\252\000\252\000\ +\252\000\252\000\000\000\000\000\000\000\000\000\000\000\252\000\ +\000\000\252\000\252\000\252\000\252\000\252\000\000\000\000\000\ +\000\000\000\000\252\000\252\000\234\000\252\000\252\000\252\000\ +\252\000\000\000\000\000\252\000\000\000\000\000\252\000\000\000\ +\252\000\000\000\000\000\252\000\000\000\000\000\252\000\000\000\ +\000\000\000\000\252\000\003\001\003\001\003\001\003\001\000\000\ +\000\000\000\000\000\000\003\001\003\001\003\001\000\000\000\000\ +\003\001\003\001\003\001\003\001\003\001\003\001\003\001\003\001\ +\003\001\000\000\000\000\003\001\003\001\003\001\003\001\003\001\ +\003\001\000\000\000\000\000\000\000\000\000\000\000\000\003\001\ +\003\001\000\000\000\000\003\001\003\001\003\001\003\001\003\001\ +\003\001\000\000\000\000\003\001\003\001\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\003\001\ +\003\001\000\000\003\001\000\000\000\000\003\001\003\001\003\001\ +\000\000\003\001\003\001\003\001\003\001\003\001\000\000\000\000\ +\000\000\000\000\000\000\003\001\000\000\003\001\003\001\003\001\ +\003\001\003\001\000\000\000\000\000\000\000\000\003\001\003\001\ +\237\000\003\001\003\001\003\001\003\001\000\000\000\000\003\001\ +\000\000\000\000\003\001\000\000\003\001\000\000\000\000\003\001\ +\000\000\000\000\003\001\000\000\000\000\000\000\003\001\000\000\ +\002\001\002\001\002\001\002\001\000\000\000\000\000\000\000\000\ +\002\001\002\001\002\001\000\000\000\000\002\001\002\001\002\001\ +\002\001\002\001\002\001\002\001\002\001\002\001\000\000\000\000\ +\002\001\002\001\002\001\002\001\002\001\002\001\000\000\000\000\ +\000\000\000\000\000\000\000\000\002\001\002\001\000\000\000\000\ +\002\001\002\001\002\001\002\001\002\001\002\001\000\000\000\000\ +\002\001\002\001\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\002\001\002\001\000\000\002\001\ +\000\000\000\000\002\001\002\001\002\001\000\000\002\001\002\001\ +\002\001\002\001\002\001\000\000\000\000\000\000\000\000\000\000\ +\002\001\000\000\002\001\002\001\002\001\002\001\002\001\000\000\ +\000\000\000\000\000\000\002\001\002\001\238\000\002\001\002\001\ +\002\001\002\001\000\000\000\000\002\001\000\000\000\000\002\001\ +\000\000\002\001\000\000\000\000\002\001\000\000\000\000\002\001\ +\000\000\000\000\000\000\002\001\234\000\234\000\234\000\234\000\ +\000\000\000\000\000\000\000\000\000\000\234\000\234\000\000\000\ +\000\000\234\000\234\000\234\000\234\000\234\000\234\000\234\000\ +\234\000\234\000\000\000\000\000\234\000\234\000\234\000\234\000\ +\234\000\234\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\234\000\234\000\000\000\000\000\234\000\234\000\234\000\234\000\ +\234\000\234\000\234\000\000\000\234\000\234\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\234\000\234\000\000\000\234\000\000\000\000\000\234\000\234\000\ +\234\000\000\000\234\000\234\000\234\000\234\000\234\000\000\000\ +\000\000\000\000\000\000\000\000\234\000\000\000\234\000\234\000\ +\234\000\234\000\234\000\000\000\000\000\000\000\000\000\234\000\ +\234\000\250\000\234\000\234\000\234\000\234\000\000\000\000\000\ +\234\000\000\000\000\000\234\000\000\000\234\000\000\000\000\000\ +\234\000\000\000\000\000\234\000\000\000\000\000\000\000\234\000\ +\237\000\237\000\237\000\237\000\000\000\000\000\000\000\000\000\ +\000\000\237\000\237\000\000\000\000\000\237\000\237\000\237\000\ +\237\000\237\000\237\000\237\000\237\000\237\000\000\000\000\000\ +\237\000\237\000\237\000\237\000\237\000\237\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\237\000\237\000\000\000\000\000\ +\237\000\237\000\237\000\237\000\237\000\237\000\237\000\000\000\ +\237\000\237\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\237\000\237\000\000\000\237\000\ +\000\000\000\000\237\000\237\000\237\000\000\000\237\000\237\000\ +\237\000\237\000\237\000\000\000\000\000\000\000\000\000\000\000\ +\237\000\000\000\237\000\237\000\237\000\237\000\237\000\000\000\ +\000\000\000\000\000\000\237\000\237\000\000\001\237\000\237\000\ +\237\000\237\000\000\000\000\000\237\000\000\000\000\000\237\000\ +\000\000\237\000\000\000\000\000\237\000\000\000\000\000\237\000\ +\000\000\000\000\000\000\237\000\000\000\238\000\238\000\238\000\ +\238\000\000\000\000\000\000\000\000\000\000\000\238\000\238\000\ +\000\000\000\000\238\000\238\000\238\000\238\000\238\000\238\000\ +\238\000\238\000\238\000\000\000\000\000\238\000\238\000\238\000\ +\238\000\238\000\238\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\238\000\238\000\000\000\000\000\238\000\238\000\238\000\ +\238\000\238\000\238\000\238\000\000\000\238\000\238\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\238\000\238\000\000\000\238\000\000\000\000\000\238\000\ +\238\000\238\000\000\000\238\000\238\000\238\000\238\000\238\000\ +\000\000\000\000\000\000\000\000\000\000\238\000\000\000\238\000\ +\238\000\238\000\238\000\238\000\000\000\000\000\000\000\000\000\ +\238\000\238\000\001\001\238\000\238\000\238\000\238\000\000\000\ +\000\000\238\000\000\000\000\000\238\000\000\000\238\000\000\000\ +\000\000\238\000\000\000\000\000\238\000\000\000\000\000\000\000\ +\238\000\250\000\250\000\250\000\250\000\000\000\000\000\000\000\ +\000\000\250\000\250\000\250\000\000\000\000\000\250\000\250\000\ +\250\000\250\000\250\000\250\000\250\000\250\000\250\000\000\000\ +\000\000\250\000\250\000\250\000\250\000\250\000\250\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\250\000\250\000\000\000\ +\000\000\250\000\250\000\250\000\250\000\250\000\000\000\000\000\ +\000\000\250\000\250\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\250\000\250\000\000\000\ +\250\000\000\000\000\000\250\000\250\000\250\000\000\000\250\000\ +\250\000\250\000\250\000\250\000\000\000\000\000\000\000\000\000\ +\000\000\250\000\000\000\250\000\000\000\250\000\250\000\250\000\ +\000\000\000\000\000\000\000\000\250\000\250\000\253\000\250\000\ +\250\000\250\000\250\000\000\000\000\000\000\000\000\000\000\000\ +\250\000\000\000\250\000\000\000\000\000\250\000\000\000\000\000\ +\250\000\000\000\000\000\000\000\250\000\000\001\000\001\000\001\ +\000\001\000\000\000\000\000\000\000\000\000\001\000\001\000\001\ +\000\000\000\000\000\001\000\001\000\001\000\001\000\001\000\001\ +\000\001\000\001\000\001\000\000\000\000\000\001\000\001\000\001\ +\000\001\000\001\000\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\001\000\001\000\000\000\000\000\001\000\001\000\001\ +\000\001\000\001\000\000\000\000\000\000\000\001\000\001\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\001\000\001\000\000\000\001\000\000\000\000\000\001\ +\000\001\000\001\000\000\000\001\000\001\000\001\000\001\000\001\ +\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\001\ +\000\000\000\001\000\001\000\001\000\000\000\000\000\000\000\000\ +\000\001\000\001\254\000\000\001\000\001\000\001\000\001\000\000\ +\000\000\000\000\000\000\000\000\000\001\000\000\000\001\000\000\ +\000\000\000\001\000\000\000\000\000\001\000\000\000\000\000\000\ +\000\001\000\000\001\001\001\001\001\001\001\001\000\000\000\000\ +\000\000\000\000\001\001\001\001\001\001\000\000\000\000\001\001\ +\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\ +\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\ +\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\ +\000\000\000\000\001\001\001\001\001\001\001\001\001\001\000\000\ +\000\000\000\000\001\001\001\001\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\ +\000\000\001\001\000\000\000\000\001\001\001\001\001\001\000\000\ +\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\ +\000\000\000\000\001\001\000\000\001\001\000\000\001\001\001\001\ +\001\001\000\000\000\000\000\000\000\000\001\001\001\001\255\000\ +\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\ +\000\000\001\001\000\000\001\001\000\000\000\000\001\001\000\000\ +\000\000\001\001\000\000\000\000\000\000\001\001\253\000\253\000\ +\253\000\253\000\000\000\000\000\000\000\000\000\253\000\253\000\ +\253\000\000\000\000\000\253\000\253\000\253\000\253\000\253\000\ +\253\000\253\000\253\000\253\000\000\000\000\000\253\000\253\000\ +\253\000\253\000\253\000\253\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\253\000\253\000\000\000\000\000\253\000\253\000\ +\253\000\253\000\253\000\000\000\000\000\000\000\253\000\253\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\253\000\253\000\000\000\253\000\000\000\000\000\ +\253\000\253\000\253\000\000\000\253\000\253\000\253\000\253\000\ +\253\000\000\000\000\000\000\000\000\000\000\000\253\000\000\000\ +\253\000\000\000\253\000\253\000\253\000\000\000\000\000\000\000\ +\000\000\253\000\253\000\208\000\253\000\253\000\253\000\253\000\ +\000\000\000\000\000\000\000\000\000\000\253\000\000\000\253\000\ +\000\000\000\000\253\000\000\000\000\000\253\000\000\000\000\000\ +\000\000\253\000\254\000\254\000\254\000\254\000\000\000\000\000\ +\000\000\000\000\254\000\254\000\254\000\000\000\000\000\254\000\ +\254\000\254\000\254\000\254\000\254\000\254\000\254\000\254\000\ +\000\000\000\000\254\000\254\000\254\000\254\000\254\000\254\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\254\000\254\000\ +\000\000\000\000\254\000\254\000\254\000\254\000\254\000\000\000\ +\000\000\000\000\254\000\254\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\254\000\254\000\ +\000\000\254\000\000\000\000\000\254\000\254\000\254\000\000\000\ +\254\000\254\000\254\000\254\000\254\000\000\000\000\000\000\000\ +\000\000\000\000\254\000\000\000\254\000\000\000\254\000\254\000\ +\254\000\000\000\000\000\000\000\000\000\254\000\254\000\004\001\ +\254\000\254\000\254\000\254\000\000\000\000\000\000\000\000\000\ +\000\000\254\000\000\000\254\000\000\000\000\000\254\000\000\000\ +\000\000\254\000\000\000\000\000\000\000\254\000\000\000\255\000\ +\255\000\255\000\255\000\000\000\000\000\000\000\000\000\255\000\ +\255\000\255\000\000\000\000\000\255\000\255\000\255\000\255\000\ +\255\000\255\000\255\000\255\000\255\000\000\000\000\000\255\000\ +\255\000\255\000\255\000\255\000\255\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\255\000\255\000\000\000\000\000\255\000\ +\255\000\255\000\255\000\255\000\000\000\000\000\000\000\255\000\ +\255\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\255\000\255\000\000\000\255\000\000\000\ +\000\000\255\000\255\000\255\000\000\000\255\000\255\000\255\000\ +\255\000\255\000\000\000\000\000\000\000\000\000\000\000\255\000\ +\000\000\255\000\000\000\255\000\255\000\255\000\000\000\000\000\ +\000\000\000\000\255\000\255\000\006\001\255\000\255\000\255\000\ +\255\000\000\000\000\000\000\000\000\000\000\000\255\000\000\000\ +\255\000\000\000\000\000\255\000\000\000\000\000\255\000\000\000\ +\000\000\000\000\255\000\208\000\208\000\208\000\208\000\000\000\ +\000\000\000\000\000\000\208\000\208\000\208\000\000\000\000\000\ +\208\000\208\000\208\000\208\000\208\000\208\000\208\000\208\000\ +\208\000\000\000\000\000\208\000\208\000\208\000\208\000\208\000\ +\208\000\000\000\000\000\000\000\000\000\000\000\000\000\208\000\ +\208\000\000\000\000\000\208\000\208\000\208\000\208\000\208\000\ +\208\000\208\000\000\000\208\000\208\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\208\000\ +\208\000\000\000\000\000\000\000\000\000\208\000\208\000\208\000\ +\000\000\208\000\000\000\000\000\208\000\208\000\000\000\000\000\ +\000\000\000\000\000\000\208\000\000\000\208\000\000\000\000\000\ +\000\000\208\000\000\000\000\000\000\000\000\000\208\000\208\000\ +\248\000\208\000\208\000\208\000\208\000\000\000\000\000\208\000\ +\000\000\000\000\208\000\000\000\208\000\000\000\000\000\208\000\ +\000\000\000\000\208\000\000\000\000\000\000\000\208\000\004\001\ +\004\001\004\001\004\001\000\000\000\000\000\000\000\000\004\001\ +\004\001\004\001\000\000\000\000\004\001\004\001\000\000\004\001\ +\004\001\004\001\004\001\004\001\004\001\000\000\000\000\004\001\ +\004\001\004\001\004\001\004\001\004\001\000\000\000\000\000\000\ +\000\000\000\000\000\000\004\001\004\001\000\000\000\000\004\001\ +\004\001\004\001\000\000\000\000\000\000\000\000\000\000\004\001\ +\004\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\004\001\004\001\000\000\004\001\000\000\ +\000\000\000\000\004\001\004\001\000\000\004\001\000\000\000\000\ +\004\001\004\001\000\000\000\000\000\000\000\000\000\000\004\001\ +\000\000\004\001\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\004\001\004\001\249\000\004\001\004\001\004\001\ +\004\001\000\000\000\000\000\000\000\000\000\000\004\001\000\000\ +\004\001\000\000\000\000\004\001\000\000\000\000\004\001\000\000\ +\000\000\000\000\004\001\000\000\006\001\006\001\006\001\006\001\ +\000\000\000\000\000\000\000\000\006\001\006\001\006\001\000\000\ +\000\000\006\001\006\001\000\000\006\001\006\001\006\001\006\001\ +\006\001\006\001\000\000\000\000\006\001\006\001\006\001\006\001\ +\006\001\006\001\000\000\000\000\000\000\000\000\000\000\000\000\ +\006\001\006\001\000\000\000\000\006\001\006\001\006\001\000\000\ +\000\000\000\000\000\000\000\000\006\001\006\001\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\006\001\006\001\000\000\006\001\000\000\000\000\000\000\006\001\ +\006\001\000\000\006\001\000\000\000\000\006\001\006\001\000\000\ +\000\000\000\000\000\000\000\000\006\001\000\000\006\001\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\006\001\ +\006\001\005\001\006\001\006\001\006\001\006\001\000\000\000\000\ +\000\000\000\000\000\000\006\001\000\000\006\001\000\000\000\000\ +\006\001\000\000\000\000\006\001\000\000\000\000\000\000\006\001\ +\248\000\248\000\248\000\248\000\000\000\000\000\000\000\000\000\ +\248\000\248\000\248\000\000\000\000\000\248\000\248\000\000\000\ +\248\000\248\000\248\000\248\000\248\000\248\000\000\000\000\000\ +\248\000\248\000\248\000\248\000\248\000\248\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\248\000\248\000\000\000\000\000\ +\248\000\248\000\248\000\000\000\000\000\000\000\000\000\000\000\ +\248\000\248\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\248\000\248\000\000\000\248\000\ +\000\000\000\000\000\000\248\000\248\000\000\000\248\000\000\000\ +\000\000\248\000\248\000\000\000\000\000\000\000\000\000\000\000\ +\248\000\010\001\248\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\248\000\248\000\000\000\248\000\248\000\ +\248\000\248\000\000\000\000\000\000\000\000\000\000\000\248\000\ +\000\000\248\000\000\000\000\000\248\000\000\000\000\000\248\000\ +\000\000\000\000\000\000\248\000\249\000\249\000\249\000\249\000\ +\000\000\000\000\000\000\000\000\249\000\249\000\249\000\000\000\ +\000\000\249\000\249\000\000\000\249\000\249\000\249\000\249\000\ +\249\000\249\000\000\000\000\000\249\000\249\000\249\000\249\000\ +\249\000\249\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\249\000\249\000\000\000\000\000\249\000\249\000\249\000\000\000\ +\000\000\000\000\000\000\000\000\249\000\249\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\249\000\249\000\000\000\249\000\000\000\000\000\000\000\249\000\ +\249\000\009\001\249\000\000\000\000\000\249\000\249\000\000\000\ +\000\000\000\000\000\000\000\000\249\000\000\000\249\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\249\000\ +\249\000\000\000\249\000\249\000\249\000\249\000\000\000\000\000\ +\000\000\000\000\000\000\249\000\000\000\249\000\000\000\000\000\ +\249\000\000\000\000\000\249\000\000\000\000\000\000\000\249\000\ +\000\000\005\001\005\001\005\001\005\001\000\000\000\000\000\000\ +\000\000\005\001\005\001\005\001\000\000\000\000\005\001\005\001\ +\000\000\005\001\005\001\005\001\005\001\005\001\005\001\000\000\ +\000\000\005\001\005\001\005\001\005\001\005\001\005\001\000\000\ +\000\000\000\000\000\000\000\000\000\000\005\001\005\001\000\000\ +\000\000\005\001\005\001\005\001\000\000\000\000\000\000\000\000\ +\000\000\005\001\005\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\008\001\000\000\000\000\000\000\005\001\005\001\000\000\ +\005\001\000\000\000\000\000\000\005\001\005\001\000\000\005\001\ +\000\000\000\000\005\001\005\001\000\000\000\000\000\000\000\000\ +\000\000\005\001\000\000\005\001\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\005\001\005\001\000\000\005\001\ +\005\001\005\001\005\001\000\000\000\000\000\000\000\000\000\000\ +\005\001\010\001\005\001\000\000\010\001\005\001\000\000\000\000\ +\005\001\010\001\010\001\010\001\005\001\000\000\010\001\010\001\ +\000\000\010\001\010\001\010\001\010\001\010\001\010\001\000\000\ +\000\000\010\001\010\001\010\001\000\000\010\001\010\001\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\010\001\000\000\ +\000\000\010\001\010\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\010\001\010\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\131\001\000\000\000\000\000\000\010\001\000\000\000\000\ +\010\001\000\000\000\000\000\000\010\001\010\001\000\000\010\001\ +\000\000\000\000\010\001\010\001\000\000\000\000\000\000\000\000\ +\000\000\010\001\000\000\010\001\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\010\001\010\001\000\000\010\001\ +\010\001\010\001\010\001\000\000\000\000\000\000\000\000\000\000\ +\010\001\009\001\010\001\000\000\009\001\010\001\000\000\000\000\ +\010\001\009\001\009\001\009\001\010\001\000\000\009\001\009\001\ +\000\000\009\001\009\001\009\001\009\001\009\001\009\001\000\000\ +\000\000\009\001\009\001\009\001\000\000\009\001\009\001\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\009\001\000\000\ +\000\000\009\001\009\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\009\001\009\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\007\001\000\000\000\000\000\000\009\001\000\000\000\000\ +\009\001\000\000\000\000\000\000\009\001\009\001\000\000\009\001\ +\000\000\000\000\009\001\009\001\000\000\000\000\000\000\000\000\ +\000\000\009\001\000\000\009\001\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\009\001\009\001\000\000\009\001\ +\009\001\009\001\009\001\000\000\000\000\000\000\000\000\000\000\ +\009\001\008\001\009\001\000\000\008\001\009\001\000\000\000\000\ +\009\001\008\001\000\000\008\001\009\001\000\000\008\001\008\001\ +\000\000\008\001\008\001\008\001\008\001\008\001\008\001\000\000\ +\000\000\008\001\008\001\008\001\000\000\008\001\008\001\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\008\001\000\000\ +\000\000\008\001\008\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\008\001\008\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\130\001\000\000\000\000\000\000\008\001\000\000\000\000\ +\008\001\000\000\000\000\000\000\008\001\008\001\000\000\008\001\ +\000\000\000\000\008\001\008\001\000\000\000\000\000\000\000\000\ +\000\000\008\001\000\000\000\000\000\000\000\000\000\000\021\003\ +\000\000\000\000\000\000\000\000\008\001\008\001\000\000\008\001\ +\008\001\008\001\008\001\000\000\000\000\000\000\000\000\000\000\ +\008\001\131\001\008\001\000\000\131\001\008\001\000\000\000\000\ +\008\001\131\001\000\000\131\001\008\001\000\000\131\001\131\001\ +\000\000\131\001\131\001\131\001\131\001\131\001\131\001\000\000\ +\000\000\131\001\131\001\131\001\000\000\131\001\131\001\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\131\001\000\000\ +\000\000\131\001\131\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\131\001\131\001\000\000\011\001\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\131\001\000\000\000\000\ +\131\001\000\000\000\000\000\000\131\001\131\001\000\000\131\001\ +\000\000\000\000\131\001\131\001\000\000\000\000\000\000\000\000\ +\000\000\131\001\021\003\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\131\001\131\001\000\000\131\001\ +\131\001\131\001\131\001\000\000\000\000\000\000\000\000\000\000\ +\131\001\007\001\131\001\000\000\007\001\131\001\000\000\000\000\ +\131\001\007\001\000\000\007\001\131\001\000\000\007\001\007\001\ +\000\000\007\001\007\001\007\001\007\001\007\001\007\001\000\000\ +\000\000\007\001\007\001\007\001\000\000\007\001\007\001\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\007\001\000\000\ +\000\000\007\001\007\001\000\000\000\000\000\000\000\000\024\001\ +\000\000\007\001\007\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\007\001\000\000\000\000\ +\007\001\000\000\000\000\000\000\007\001\007\001\000\000\007\001\ +\000\000\000\000\007\001\007\001\000\000\000\000\000\000\000\000\ +\000\000\007\001\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\007\001\007\001\000\000\007\001\ +\007\001\007\001\007\001\000\000\000\000\000\000\000\000\000\000\ +\007\001\130\001\007\001\000\000\130\001\007\001\000\000\000\000\ +\007\001\130\001\000\000\130\001\007\001\000\000\130\001\130\001\ +\000\000\130\001\130\001\130\001\130\001\130\001\130\001\000\000\ +\000\000\130\001\130\001\130\001\000\000\130\001\130\001\021\003\ +\000\000\000\000\000\000\000\000\000\000\000\000\130\001\000\000\ +\000\000\130\001\130\001\000\000\021\003\000\000\000\000\014\001\ +\167\001\130\001\130\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\021\003\000\000\021\003\021\003\130\001\000\000\000\000\ +\130\001\000\000\000\000\000\000\130\001\130\001\000\000\130\001\ +\021\003\000\000\130\001\130\001\000\000\094\000\000\000\000\000\ +\136\000\130\001\137\000\138\000\030\000\000\000\139\000\000\000\ +\000\000\169\001\141\000\021\003\130\001\130\001\021\003\130\001\ +\130\001\130\001\130\001\021\003\011\001\000\000\000\000\011\001\ +\130\001\021\003\130\001\000\000\011\001\130\001\011\001\021\003\ +\130\001\011\001\011\001\144\000\130\001\011\001\000\000\011\001\ +\011\001\011\001\145\000\021\003\011\001\011\001\011\001\021\003\ +\011\001\011\001\021\003\000\000\000\000\021\003\146\000\147\000\ +\000\000\011\001\000\000\021\003\011\001\011\001\021\003\021\003\ +\000\000\000\000\243\000\000\000\011\001\011\001\000\000\000\000\ +\000\000\000\000\000\000\000\000\021\003\000\000\021\003\021\003\ +\011\001\000\000\000\000\011\001\000\000\000\000\000\000\011\001\ +\011\001\000\000\011\001\021\003\000\000\011\001\011\001\000\000\ +\104\000\174\003\000\000\136\000\011\001\137\000\138\000\030\000\ +\000\000\139\000\000\000\000\000\158\001\141\000\021\003\011\001\ +\011\001\000\000\011\001\011\001\011\001\011\001\021\003\024\001\ +\000\000\000\000\024\001\011\001\021\003\011\001\000\000\024\001\ +\011\001\024\001\021\003\011\001\024\001\024\001\144\000\011\001\ +\024\001\000\000\024\001\024\001\024\001\145\000\021\003\024\001\ +\024\001\024\001\021\003\024\001\024\001\000\000\000\000\000\000\ +\000\000\146\000\147\000\000\000\024\001\000\000\021\003\024\001\ +\024\001\021\003\000\000\000\000\000\000\017\001\000\000\024\001\ +\024\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\024\001\000\000\000\000\024\001\000\000\ +\000\000\000\000\024\001\024\001\000\000\024\001\000\000\000\000\ +\024\001\024\001\000\000\000\000\000\000\000\000\000\000\024\001\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\024\001\024\001\000\000\024\001\024\001\024\001\ +\024\001\000\000\000\000\000\000\000\000\000\000\024\001\014\001\ +\024\001\000\000\014\001\024\001\000\000\000\000\024\001\014\001\ +\000\000\014\001\024\001\000\000\014\001\014\001\000\000\000\000\ +\014\001\000\000\014\001\014\001\014\001\000\000\000\000\014\001\ +\014\001\014\001\000\000\014\001\014\001\094\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\014\001\000\000\000\000\014\001\ +\014\001\000\000\094\000\000\000\000\000\016\001\000\000\014\001\ +\014\001\000\000\000\000\000\000\000\000\000\000\000\000\094\000\ +\000\000\094\000\094\000\014\001\000\000\000\000\014\001\000\000\ +\000\000\000\000\014\001\014\001\000\000\014\001\094\000\000\000\ +\014\001\014\001\000\000\021\003\000\000\000\000\136\000\014\001\ +\137\000\138\000\030\000\000\000\139\000\000\000\000\000\158\001\ +\141\000\094\000\014\001\014\001\000\000\014\001\014\001\014\001\ +\014\001\094\000\243\000\000\000\000\000\243\000\014\001\094\000\ +\014\001\000\000\243\000\014\001\243\000\094\000\014\001\243\000\ +\243\000\144\000\014\001\243\000\000\000\243\000\243\000\243\000\ +\145\000\094\000\243\000\243\000\243\000\094\000\243\000\243\000\ +\104\000\000\000\000\000\000\000\146\000\147\000\000\000\243\000\ +\000\000\094\000\243\000\243\000\094\000\104\000\000\000\000\000\ +\015\001\000\000\243\000\243\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\104\000\000\000\104\000\104\000\243\000\000\000\ +\000\000\243\000\000\000\000\000\000\000\243\000\243\000\000\000\ +\243\000\104\000\000\000\243\000\243\000\000\000\099\000\000\000\ +\000\000\000\000\243\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\104\000\243\000\243\000\000\000\ +\243\000\243\000\243\000\243\000\104\000\017\001\000\000\000\000\ +\017\001\243\000\104\000\243\000\000\000\017\001\243\000\017\001\ +\104\000\243\000\017\001\017\001\000\000\243\000\017\001\000\000\ +\017\001\017\001\017\001\000\000\104\000\017\001\017\001\017\001\ +\104\000\017\001\017\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\017\001\000\000\104\000\017\001\017\001\104\000\ +\000\000\000\000\000\000\020\001\000\000\017\001\017\001\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\017\001\000\000\000\000\017\001\000\000\000\000\000\000\ +\017\001\017\001\000\000\017\001\000\000\000\000\017\001\017\001\ +\000\000\000\000\000\000\000\000\000\000\017\001\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\017\001\017\001\000\000\017\001\017\001\017\001\017\001\000\000\ +\000\000\000\000\000\000\000\000\017\001\016\001\017\001\000\000\ +\016\001\017\001\000\000\000\000\017\001\016\001\000\000\016\001\ +\017\001\000\000\016\001\016\001\000\000\000\000\016\001\000\000\ +\016\001\016\001\016\001\000\000\000\000\016\001\016\001\016\001\ +\000\000\016\001\016\001\021\003\000\000\000\000\000\000\000\000\ +\000\000\000\000\016\001\000\000\000\000\016\001\016\001\000\000\ +\021\003\000\000\000\000\018\001\000\000\016\001\016\001\000\000\ +\000\000\000\000\000\000\000\000\000\000\021\003\000\000\021\003\ +\021\003\016\001\000\000\000\000\016\001\000\000\000\000\000\000\ +\016\001\016\001\000\000\016\001\021\003\000\000\016\001\016\001\ +\000\000\103\000\000\000\000\000\000\000\016\001\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\021\003\ +\016\001\016\001\000\000\016\001\016\001\016\001\016\001\021\003\ +\015\001\000\000\000\000\015\001\016\001\021\003\016\001\000\000\ +\015\001\016\001\015\001\021\003\016\001\015\001\015\001\000\000\ +\016\001\015\001\000\000\015\001\015\001\015\001\000\000\021\003\ +\015\001\015\001\015\001\021\003\015\001\015\001\099\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\015\001\000\000\021\003\ +\015\001\015\001\021\003\099\000\000\000\000\000\019\001\000\000\ +\015\001\015\001\000\000\000\000\000\000\000\000\000\000\000\000\ +\099\000\000\000\099\000\099\000\015\001\000\000\000\000\015\001\ +\000\000\000\000\000\000\015\001\015\001\000\000\015\001\099\000\ +\000\000\015\001\015\001\000\000\000\000\000\000\000\000\000\000\ +\015\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\099\000\015\001\015\001\000\000\015\001\015\001\ +\015\001\015\001\099\000\020\001\000\000\000\000\020\001\015\001\ +\099\000\015\001\000\000\020\001\015\001\020\001\099\000\015\001\ +\020\001\020\001\000\000\015\001\020\001\000\000\020\001\020\001\ +\020\001\000\000\099\000\020\001\020\001\020\001\099\000\020\001\ +\020\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\020\001\000\000\099\000\020\001\020\001\099\000\000\000\000\000\ +\000\000\023\001\000\000\020\001\020\001\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\020\001\ +\000\000\000\000\020\001\000\000\000\000\000\000\020\001\020\001\ +\000\000\020\001\000\000\000\000\020\001\020\001\000\000\000\000\ +\000\000\000\000\000\000\020\001\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\020\001\020\001\ +\000\000\020\001\020\001\020\001\020\001\000\000\000\000\000\000\ +\000\000\000\000\020\001\018\001\020\001\000\000\018\001\020\001\ +\000\000\000\000\020\001\018\001\000\000\018\001\020\001\000\000\ +\018\001\018\001\000\000\000\000\018\001\000\000\018\001\018\001\ +\018\001\000\000\000\000\018\001\018\001\018\001\000\000\018\001\ +\018\001\103\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\018\001\000\000\000\000\018\001\018\001\000\000\103\000\000\000\ +\000\000\021\001\000\000\018\001\018\001\000\000\000\000\000\000\ +\000\000\000\000\000\000\103\000\000\000\103\000\103\000\018\001\ +\000\000\000\000\018\001\000\000\000\000\000\000\018\001\018\001\ +\000\000\018\001\103\000\000\000\018\001\018\001\000\000\000\000\ +\000\000\000\000\000\000\018\001\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\103\000\018\001\018\001\ +\000\000\018\001\018\001\018\001\018\001\103\000\019\001\000\000\ +\000\000\019\001\018\001\103\000\018\001\000\000\019\001\018\001\ +\019\001\103\000\018\001\019\001\019\001\000\000\018\001\019\001\ +\000\000\019\001\019\001\019\001\000\000\103\000\019\001\019\001\ +\019\001\103\000\019\001\019\001\010\000\000\000\157\001\000\000\ +\000\000\000\000\000\000\019\001\000\000\103\000\019\001\019\001\ +\103\000\000\000\000\000\000\000\022\001\000\000\019\001\019\001\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\019\001\000\000\000\000\019\001\000\000\000\000\ +\000\000\019\001\019\001\000\000\019\001\000\000\000\000\019\001\ +\019\001\000\000\000\000\000\000\000\000\136\000\019\001\137\000\ +\138\000\030\000\000\000\139\000\000\000\000\000\158\001\141\000\ +\000\000\019\001\019\001\000\000\019\001\019\001\019\001\019\001\ +\000\000\023\001\000\000\000\000\023\001\019\001\000\000\019\001\ +\000\000\023\001\019\001\023\001\000\000\019\001\023\001\023\001\ +\144\000\019\001\023\001\000\000\023\001\023\001\023\001\145\000\ +\000\000\023\001\023\001\023\001\000\000\023\001\023\001\000\000\ +\000\000\000\000\000\000\146\000\147\000\000\000\023\001\000\000\ +\000\000\023\001\023\001\000\000\000\000\000\000\000\000\207\000\ +\000\000\023\001\023\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\023\001\000\000\000\000\ +\023\001\000\000\000\000\000\000\023\001\023\001\000\000\023\001\ +\000\000\000\000\023\001\023\001\000\000\000\000\000\000\000\000\ +\000\000\023\001\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\023\001\023\001\000\000\023\001\ +\023\001\023\001\023\001\000\000\000\000\000\000\000\000\000\000\ +\023\001\021\001\023\001\000\000\021\001\023\001\000\000\000\000\ +\023\001\021\001\000\000\021\001\023\001\000\000\021\001\021\001\ +\000\000\000\000\021\001\000\000\021\001\021\001\021\001\000\000\ +\000\000\021\001\021\001\021\001\000\000\021\001\021\001\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\021\001\000\000\ +\000\000\021\001\021\001\000\000\000\000\000\000\000\000\244\000\ +\000\000\021\001\021\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\021\001\000\000\000\000\ +\021\001\000\000\000\000\000\000\021\001\021\001\000\000\021\001\ +\000\000\000\000\021\001\021\001\000\000\000\000\000\000\000\000\ +\000\000\021\001\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\021\001\021\001\000\000\021\001\ +\021\001\021\001\021\001\000\000\022\001\000\000\000\000\022\001\ +\021\001\000\000\021\001\000\000\022\001\021\001\022\001\000\000\ +\021\001\022\001\022\001\000\000\021\001\022\001\000\000\022\001\ +\022\001\022\001\000\000\000\000\022\001\022\001\022\001\000\000\ +\022\001\022\001\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\022\001\000\000\000\000\022\001\022\001\000\000\000\000\ +\000\000\000\000\000\000\000\000\022\001\022\001\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\061\002\000\000\000\000\ +\022\001\000\000\000\000\022\001\000\000\000\000\000\000\022\001\ +\022\001\000\000\022\001\000\000\000\000\022\001\022\001\000\000\ +\000\000\000\000\000\000\000\000\022\001\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\022\001\ +\022\001\000\000\022\001\022\001\022\001\022\001\000\000\207\000\ +\000\000\000\000\207\000\022\001\000\000\022\001\000\000\207\000\ +\022\001\207\000\000\000\022\001\207\000\207\000\000\000\022\001\ +\207\000\000\000\207\000\207\000\207\000\000\000\000\000\207\000\ +\207\000\207\000\000\000\207\000\207\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\207\000\000\000\000\000\207\000\ +\207\000\000\000\000\000\000\000\000\000\000\000\000\000\207\000\ +\207\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\095\002\000\000\000\000\207\000\000\000\000\000\207\000\000\000\ +\000\000\000\000\207\000\207\000\000\000\207\000\000\000\000\000\ +\207\000\207\000\000\000\000\000\000\000\000\000\000\000\207\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\207\000\207\000\000\000\207\000\000\000\207\000\ +\207\000\000\000\000\000\000\000\000\000\000\000\207\000\244\000\ +\207\000\000\000\244\000\207\000\000\000\000\000\207\000\244\000\ +\000\000\244\000\207\000\000\000\244\000\244\000\000\000\000\000\ +\244\000\000\000\244\000\244\000\244\000\000\000\000\000\244\000\ +\000\000\244\000\000\000\244\000\244\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\244\000\000\000\000\000\244\000\ +\244\000\000\000\000\000\000\000\000\000\000\000\000\000\244\000\ +\244\000\000\000\000\000\059\002\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\244\000\000\000\000\000\244\000\000\000\ +\000\000\000\000\244\000\244\000\000\000\244\000\000\000\000\000\ +\244\000\244\000\000\000\000\000\000\000\000\000\000\000\244\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\244\000\244\000\000\000\244\000\244\000\244\000\ +\244\000\000\000\000\000\000\000\000\000\000\000\244\000\000\000\ +\244\000\000\000\000\000\244\000\000\000\061\002\244\000\061\002\ +\061\002\061\002\244\000\000\000\000\000\061\002\000\000\000\000\ +\000\000\000\000\061\002\000\000\000\000\000\000\061\002\061\002\ +\061\002\000\000\000\000\000\000\000\000\154\003\000\000\061\002\ +\061\002\061\002\061\002\000\000\000\000\000\000\000\000\000\000\ +\000\000\061\002\000\000\000\000\000\000\061\002\061\002\000\000\ +\057\002\000\000\000\000\000\000\000\000\061\002\061\002\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\061\002\000\000\000\000\061\002\000\000\000\000\061\002\ +\061\002\061\002\000\000\061\002\000\000\000\000\061\002\061\002\ +\000\000\000\000\000\000\000\000\136\000\061\002\137\000\138\000\ +\030\000\000\000\139\000\000\000\000\000\140\000\141\000\000\000\ +\061\002\061\002\000\000\061\002\061\002\061\002\000\000\000\000\ +\095\002\061\002\095\002\095\002\095\002\000\000\142\000\000\000\ +\095\002\061\002\000\000\000\000\061\002\095\002\143\000\144\000\ +\061\002\095\002\095\002\095\002\000\000\000\000\145\000\000\000\ +\000\000\000\000\095\002\095\002\095\002\095\002\000\000\000\000\ +\059\005\000\000\146\000\147\000\095\002\000\000\000\000\000\000\ +\000\000\095\002\000\000\058\002\000\000\000\000\000\000\160\005\ +\095\002\095\002\000\000\000\000\000\000\000\000\243\001\000\000\ +\000\000\000\000\000\000\000\000\095\002\000\000\000\000\095\002\ +\000\000\000\000\095\002\095\002\095\002\000\000\095\002\000\000\ +\000\000\095\002\095\002\000\000\000\000\000\000\000\000\061\005\ +\095\002\137\000\138\000\030\000\000\000\139\000\000\000\000\000\ +\140\000\062\005\000\000\095\002\095\002\000\000\095\002\095\002\ +\095\002\095\002\000\000\059\002\000\000\059\002\059\002\059\002\ +\000\000\142\000\000\000\059\002\095\002\000\000\000\000\095\002\ +\059\002\143\000\144\000\095\002\059\002\059\002\059\002\000\000\ +\000\000\145\000\000\000\000\000\000\000\059\002\059\002\059\002\ +\059\002\000\000\246\001\000\000\000\000\064\005\147\000\059\002\ +\000\000\000\000\000\000\000\000\059\002\000\000\056\002\000\000\ +\000\000\000\000\000\000\059\002\059\002\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\059\002\ +\000\000\000\000\059\002\000\000\000\000\059\002\059\002\059\002\ +\000\000\059\002\000\000\000\000\000\000\059\002\000\000\000\000\ +\000\000\000\000\000\000\059\002\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\059\002\059\002\ +\000\000\059\002\059\002\059\002\059\002\000\000\000\000\000\000\ +\057\002\000\000\057\002\057\002\057\002\000\000\000\000\059\002\ +\057\002\000\000\059\002\000\000\000\000\057\002\059\002\000\000\ +\000\000\057\002\057\002\057\002\000\000\000\000\000\000\000\000\ +\000\000\000\000\057\002\057\002\057\002\057\002\000\000\000\000\ +\000\000\000\000\000\000\000\000\057\002\000\000\000\000\000\000\ +\000\000\057\002\000\000\053\002\000\000\000\000\000\000\000\000\ +\057\002\057\002\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\057\002\000\000\000\000\057\002\ +\000\000\000\000\057\002\057\002\057\002\000\000\057\002\000\000\ +\000\000\000\000\057\002\000\000\000\000\000\000\000\000\136\000\ +\057\002\137\000\138\000\030\000\000\000\139\000\000\000\000\000\ +\140\000\141\000\000\000\057\002\057\002\000\000\057\002\057\002\ +\057\002\057\002\177\001\058\002\000\000\058\002\058\002\058\002\ +\000\000\142\000\000\000\058\002\057\002\000\000\000\000\057\002\ +\058\002\143\000\144\000\057\002\058\002\058\002\058\002\042\002\ +\000\000\145\000\000\000\000\000\000\000\058\002\058\002\058\002\ +\058\002\000\000\000\000\000\000\000\000\146\000\147\000\058\002\ +\000\000\000\000\000\000\000\000\058\002\000\000\000\000\000\000\ +\000\000\000\000\000\000\058\002\058\002\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\058\002\ +\000\000\000\000\058\002\000\000\000\000\058\002\058\002\058\002\ +\000\000\058\002\000\000\000\000\000\000\058\002\000\000\000\000\ +\000\000\041\002\136\000\058\002\137\000\138\000\030\000\000\000\ +\139\000\000\000\000\000\140\000\141\000\000\000\058\002\058\002\ +\000\000\058\002\058\002\058\002\058\002\000\000\056\002\000\000\ +\056\002\056\002\056\002\000\000\142\000\000\000\056\002\058\002\ +\000\000\000\000\058\002\056\002\143\000\126\003\058\002\056\002\ +\056\002\056\002\000\000\000\000\145\000\000\000\000\000\000\000\ +\056\002\056\002\056\002\056\002\000\000\000\000\000\000\068\006\ +\146\000\147\000\056\002\039\002\000\000\000\000\000\000\056\002\ +\000\000\000\000\000\000\000\000\000\000\000\000\056\002\056\002\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\056\002\000\000\000\000\056\002\000\000\000\000\ +\056\002\056\002\056\002\000\000\056\002\000\000\000\000\000\000\ +\056\002\000\000\000\000\000\000\000\000\000\000\056\002\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\056\002\056\002\000\000\056\002\056\002\056\002\056\002\ +\000\000\197\000\000\000\053\002\000\000\053\002\053\002\000\000\ +\000\000\000\000\056\002\053\002\000\000\056\002\000\000\000\000\ +\053\002\056\002\000\000\000\000\053\002\053\002\053\002\000\000\ +\000\000\000\000\000\000\000\000\000\000\053\002\053\002\053\002\ +\053\002\000\000\000\000\000\000\000\000\000\000\000\000\053\002\ +\000\000\000\000\000\000\000\000\053\002\000\000\000\000\000\000\ +\000\000\000\000\000\000\053\002\053\002\000\000\000\000\000\000\ +\000\000\000\000\000\000\084\000\000\000\000\000\000\000\053\002\ +\000\000\000\000\053\002\000\000\000\000\053\002\053\002\053\002\ +\000\000\053\002\000\000\000\000\010\000\053\002\157\001\042\002\ +\000\000\000\000\042\002\053\002\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\042\002\000\000\053\002\053\002\ +\042\002\053\002\053\002\053\002\053\002\000\000\000\000\000\000\ +\000\000\042\002\042\002\042\002\042\002\000\000\000\000\053\002\ +\000\000\000\000\053\002\000\000\000\000\000\000\053\002\000\000\ +\042\002\000\000\000\000\000\000\000\000\136\000\000\000\137\000\ +\138\000\030\000\000\000\139\000\000\000\000\000\158\001\141\000\ +\000\000\041\002\000\000\042\002\041\002\000\000\042\002\000\000\ +\000\000\042\002\042\002\042\002\000\000\000\000\041\002\000\000\ +\042\002\042\002\041\002\000\000\000\000\000\000\000\000\042\002\ +\144\000\000\000\227\002\041\002\041\002\041\002\041\002\145\000\ +\000\000\000\000\000\000\042\002\023\003\042\002\000\000\042\002\ +\042\002\000\000\041\002\146\000\147\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\042\002\000\000\000\000\042\002\000\000\ +\000\000\000\000\042\002\039\002\000\000\041\002\039\002\000\000\ +\041\002\000\000\000\000\041\002\041\002\041\002\000\000\000\000\ +\039\002\000\000\041\002\041\002\039\002\000\000\000\000\000\000\ +\000\000\041\002\000\000\000\000\000\000\039\002\039\002\039\002\ +\039\002\000\000\000\000\000\000\000\000\041\002\000\000\041\002\ +\000\000\041\002\041\002\000\000\039\002\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\041\002\000\000\000\000\ +\041\002\000\000\000\000\000\000\041\002\000\000\000\000\039\002\ +\000\000\197\000\039\002\000\000\197\000\039\002\039\002\039\002\ +\000\000\000\000\000\000\000\000\039\002\039\002\197\000\000\000\ +\000\000\000\000\197\000\039\002\197\000\000\000\000\000\000\000\ +\000\000\000\000\128\000\197\000\197\000\197\000\197\000\039\002\ +\000\000\039\002\000\000\039\002\039\002\000\000\000\000\000\000\ +\000\000\000\000\197\000\000\000\000\000\000\000\000\000\039\002\ +\000\000\000\000\039\002\000\000\000\000\000\000\039\002\000\000\ +\000\000\000\000\000\000\084\000\000\000\197\000\084\000\000\000\ +\197\000\000\000\000\000\000\000\197\000\197\000\000\000\000\000\ +\084\000\000\000\197\000\197\000\084\000\000\000\000\000\000\000\ +\000\000\197\000\000\000\000\000\000\000\084\000\084\000\084\000\ +\084\000\000\000\000\000\000\000\000\000\197\000\000\000\197\000\ +\000\000\197\000\197\000\000\000\084\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\197\000\000\000\000\000\ +\197\000\120\000\000\000\000\000\197\000\000\000\000\000\084\000\ +\000\000\000\000\084\000\000\000\000\000\000\000\084\000\084\000\ +\000\000\000\000\000\000\000\000\084\000\084\000\244\004\000\000\ +\137\000\138\000\030\000\084\000\139\000\000\000\245\004\246\004\ +\141\000\000\000\000\000\000\000\000\000\000\000\000\000\084\000\ +\000\000\084\000\000\000\084\000\084\000\247\004\000\000\000\000\ +\248\004\000\000\000\000\000\000\000\000\000\000\000\000\084\000\ +\249\004\144\000\084\000\000\000\023\003\000\000\084\000\023\003\ +\145\000\023\003\023\003\023\003\023\003\000\000\000\000\023\003\ +\023\003\023\003\000\000\000\000\146\000\147\000\000\000\023\003\ +\000\000\000\000\000\000\023\003\000\000\000\000\023\003\000\000\ +\023\003\023\003\023\003\023\003\023\003\023\003\023\003\023\003\ +\023\003\000\000\000\000\023\003\023\003\023\003\000\000\000\000\ +\000\000\000\000\000\000\000\000\023\003\023\003\023\003\023\003\ +\023\003\023\003\023\003\023\003\023\003\023\003\023\003\023\003\ +\023\003\023\003\150\001\023\003\023\003\023\003\000\000\023\003\ +\023\003\023\003\023\003\023\003\023\003\000\000\023\003\023\003\ +\023\003\023\003\023\003\000\000\023\003\023\003\000\000\000\000\ +\023\003\023\003\000\000\023\003\023\003\023\003\023\003\023\003\ +\023\003\023\003\000\000\023\003\023\003\023\003\000\000\023\003\ +\000\000\023\003\023\003\000\000\023\003\000\000\023\003\023\003\ +\023\003\023\003\023\003\023\003\023\003\000\000\023\003\009\000\ +\010\000\011\000\000\000\000\000\000\000\012\000\013\000\014\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\015\000\016\000\ +\017\000\018\000\019\000\020\000\021\000\000\000\000\000\000\000\ +\000\000\022\000\000\000\023\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\024\000\000\000\025\000\026\000\ +\027\000\028\000\029\000\000\000\000\000\030\000\031\000\000\000\ +\000\000\032\000\033\000\034\000\000\000\164\002\035\000\036\000\ +\000\000\037\000\038\000\000\000\039\000\000\000\040\000\000\000\ +\041\000\000\000\042\000\000\000\000\000\000\000\043\000\044\000\ +\000\000\045\000\000\000\000\000\000\000\000\000\009\000\010\000\ +\011\000\000\000\129\000\121\000\012\000\013\000\014\000\047\000\ +\000\000\000\000\000\000\000\000\048\000\049\000\050\000\051\000\ +\052\000\053\000\000\000\000\000\054\000\015\000\016\000\017\000\ +\018\000\019\000\020\000\021\000\000\000\000\000\000\000\000\000\ +\022\000\000\000\023\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\024\000\000\000\025\000\026\000\027\000\ +\028\000\029\000\000\000\000\000\030\000\031\000\000\000\000\000\ +\032\000\033\000\034\000\000\000\000\000\035\000\036\000\000\000\ +\037\000\038\000\000\000\039\000\000\000\040\000\000\000\041\000\ +\000\000\042\000\000\000\109\000\000\000\043\000\044\000\000\000\ +\045\000\178\001\136\000\000\000\137\000\138\000\030\000\000\000\ +\139\000\000\000\121\000\140\000\141\000\000\000\047\000\000\000\ +\000\000\000\000\000\000\048\000\049\000\050\000\051\000\052\000\ +\053\000\000\000\000\000\054\000\142\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\143\000\144\000\000\000\009\000\ +\010\000\011\000\000\000\000\000\145\000\012\000\013\000\014\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\146\000\147\000\000\000\000\000\000\000\000\000\015\000\016\000\ +\017\000\018\000\019\000\020\000\021\000\000\000\000\000\000\000\ +\000\000\022\000\000\000\023\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\024\000\000\000\025\000\026\000\ +\027\000\028\000\029\000\000\000\000\000\030\000\031\000\000\000\ +\000\000\032\000\033\000\034\000\000\000\000\000\035\000\036\000\ +\000\000\037\000\038\000\000\000\039\000\132\000\040\000\000\000\ +\041\000\000\000\042\000\000\000\000\000\000\000\043\000\044\000\ +\000\000\045\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\121\000\000\000\000\000\000\000\047\000\ +\000\000\000\000\000\000\000\000\048\000\049\000\050\000\051\000\ +\052\000\053\000\000\000\000\000\054\000\164\002\000\000\000\000\ +\000\000\164\002\000\000\164\002\000\000\164\002\000\000\164\002\ +\000\000\164\002\000\000\164\002\164\002\000\000\164\002\164\002\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\164\002\164\002\000\000\164\002\164\002\134\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\164\002\ +\164\002\164\002\164\002\000\000\164\002\164\002\000\000\000\000\ +\164\002\000\000\000\000\000\000\000\000\164\002\164\002\164\002\ +\000\000\000\000\000\000\000\000\164\002\000\000\164\002\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\164\002\000\000\ +\000\000\164\002\000\000\000\000\000\000\000\000\164\002\135\000\ +\164\002\164\002\000\000\164\002\164\002\000\000\164\002\000\000\ +\000\000\000\000\164\002\109\000\000\000\164\002\000\000\164\002\ +\000\000\178\001\164\002\164\002\000\000\178\001\164\002\178\001\ +\109\000\178\001\000\000\178\001\000\000\178\001\000\000\178\001\ +\178\001\000\000\178\001\178\001\000\000\109\000\000\000\109\000\ +\109\000\000\000\000\000\000\000\178\001\000\000\000\000\178\001\ +\178\001\000\000\000\000\000\000\109\000\000\000\000\000\000\000\ +\000\000\130\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\178\001\178\001\000\000\178\001\109\000\ +\178\001\178\001\000\000\000\000\178\001\000\000\109\000\109\000\ +\000\000\178\001\178\001\178\001\000\000\109\000\000\000\000\000\ +\178\001\000\000\178\001\109\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\178\001\000\000\000\000\178\001\000\000\109\000\ +\000\000\000\000\178\001\109\000\178\001\178\001\000\000\178\001\ +\178\001\000\000\178\001\136\000\000\000\000\000\178\001\109\000\ +\000\000\178\001\109\000\178\001\000\000\132\000\178\001\178\001\ +\132\000\132\000\178\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\132\000\132\000\000\000\000\000\000\000\000\000\ +\132\000\000\000\000\000\000\000\000\000\000\000\000\000\132\000\ +\000\000\132\000\132\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\132\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\132\000\132\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\132\000\000\000\000\000\132\000\000\000\000\000\132\000\ +\132\000\132\000\000\000\132\000\000\000\134\000\000\000\132\000\ +\134\000\134\000\014\002\000\000\000\000\132\000\000\000\000\000\ +\000\000\000\000\134\000\134\000\000\000\000\000\000\000\000\000\ +\134\000\132\000\000\000\132\000\000\000\132\000\132\000\134\000\ +\000\000\134\000\134\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\132\000\000\000\000\000\132\000\000\000\134\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\134\000\134\000\000\000\ +\000\000\000\000\000\000\181\000\000\000\000\000\000\000\135\000\ +\000\000\134\000\135\000\135\000\134\000\000\000\000\000\134\000\ +\134\000\134\000\000\000\134\000\135\000\135\000\000\000\134\000\ +\000\000\000\000\135\000\000\000\000\000\134\000\000\000\000\000\ +\000\000\135\000\000\000\135\000\135\000\000\000\000\000\000\000\ +\000\000\134\000\000\000\134\000\000\000\134\000\134\000\000\000\ +\135\000\000\000\000\000\000\000\000\000\183\002\000\000\135\000\ +\135\000\134\000\000\000\000\000\134\000\000\000\000\000\000\000\ +\000\000\130\000\000\000\135\000\130\000\130\000\135\000\000\000\ +\000\000\000\000\135\000\135\000\000\000\135\000\130\000\130\000\ +\000\000\135\000\000\000\000\000\130\000\000\000\000\000\135\000\ +\000\000\000\000\000\000\130\000\000\000\130\000\130\000\000\000\ +\000\000\000\000\000\000\135\000\000\000\135\000\000\000\135\000\ +\135\000\000\000\130\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\130\000\130\000\135\000\000\000\000\000\135\000\000\000\ +\000\000\000\000\000\000\136\000\000\000\130\000\136\000\136\000\ +\130\000\015\002\000\000\000\000\130\000\130\000\000\000\130\000\ +\136\000\136\000\000\000\130\000\000\000\000\000\136\000\000\000\ +\000\000\130\000\000\000\000\000\000\000\136\000\000\000\136\000\ +\136\000\000\000\000\000\000\000\000\000\130\000\000\000\130\000\ +\000\000\130\000\130\000\000\000\136\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\136\000\136\000\130\000\000\000\000\000\ +\130\000\000\000\000\000\000\000\000\000\000\000\000\000\136\000\ +\000\000\000\000\136\000\182\000\000\000\000\000\136\000\136\000\ +\000\000\136\000\000\000\000\000\000\000\136\000\136\000\000\000\ +\137\000\138\000\030\000\136\000\139\000\000\000\000\000\140\000\ +\141\000\000\000\014\002\000\000\000\000\014\002\000\000\136\000\ +\000\000\136\000\014\002\136\000\136\000\000\000\000\000\014\002\ +\142\000\000\000\000\000\000\000\000\000\014\002\000\000\136\000\ +\143\000\126\003\136\000\000\000\014\002\000\000\014\002\014\002\ +\145\000\000\000\000\000\000\000\000\000\021\003\000\000\000\000\ +\000\000\000\000\014\002\014\002\146\000\147\000\000\000\000\000\ +\000\000\000\000\000\000\181\000\000\000\000\000\181\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\014\002\000\000\ +\181\000\014\002\000\000\000\000\014\002\014\002\014\002\000\000\ +\000\000\000\000\000\000\098\002\014\002\181\000\181\000\181\000\ +\181\000\000\000\014\002\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\181\000\000\000\014\002\023\003\ +\000\000\000\000\014\002\014\002\000\000\183\002\098\002\000\000\ +\183\002\000\000\000\000\000\000\000\000\000\000\014\002\181\000\ +\000\000\014\002\183\002\080\002\000\000\181\000\181\000\181\000\ +\000\000\000\000\000\000\000\000\080\002\181\000\000\000\183\002\ +\183\002\183\002\183\002\181\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\183\002\181\000\ +\000\000\181\000\000\000\181\000\080\002\000\000\000\000\080\002\ +\000\000\232\001\000\000\000\000\000\000\000\000\000\000\181\000\ +\080\002\183\002\181\000\000\000\000\000\174\002\000\000\183\002\ +\183\002\183\002\000\000\000\000\000\000\000\000\174\002\183\002\ +\000\000\015\002\000\000\000\000\015\002\183\002\000\000\000\000\ +\000\000\015\002\000\000\000\000\000\000\000\000\015\002\000\000\ +\000\000\183\002\000\000\183\002\015\002\183\002\174\002\000\000\ +\000\000\174\002\071\000\015\002\000\000\015\002\015\002\000\000\ +\000\000\183\002\174\002\000\000\183\002\000\000\000\000\000\000\ +\000\000\015\002\015\002\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\182\000\000\000\015\002\182\000\000\000\ +\015\002\000\000\000\000\015\002\015\002\015\002\000\000\000\000\ +\182\000\000\000\015\002\015\002\000\000\000\000\182\000\233\001\ +\000\000\015\002\000\000\000\000\000\000\182\000\182\000\182\000\ +\182\000\000\000\000\000\000\000\000\000\015\002\000\000\000\000\ +\000\000\015\002\015\002\000\000\182\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\182\000\000\000\015\002\000\000\000\000\ +\015\002\000\000\000\000\000\000\000\000\021\003\000\000\182\000\ +\021\003\000\000\182\000\000\000\000\000\000\000\182\000\182\000\ +\000\000\182\000\021\003\000\000\235\001\182\000\000\000\000\000\ +\021\003\000\000\000\000\182\000\000\000\000\000\000\000\021\003\ +\000\000\021\003\021\003\000\000\000\000\000\000\000\000\182\000\ +\000\000\182\000\000\000\182\000\182\000\021\003\021\003\000\000\ +\000\000\000\000\000\000\000\000\000\000\021\003\021\003\182\000\ +\000\000\000\000\182\000\000\000\000\000\000\000\000\000\023\003\ +\000\000\021\003\023\003\000\000\021\003\000\000\000\000\023\003\ +\000\000\021\003\000\000\021\003\023\003\000\000\000\000\021\003\ +\000\000\000\000\023\003\000\000\000\000\021\003\000\000\000\000\ +\000\000\023\003\000\000\023\003\023\003\000\000\000\000\234\001\ +\000\000\021\003\000\000\000\000\000\000\021\003\021\003\000\000\ +\023\003\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\021\003\000\000\000\000\021\003\000\000\000\000\000\000\ +\000\000\232\001\000\000\023\003\232\001\000\000\023\003\000\000\ +\000\000\000\000\023\003\023\003\000\000\000\000\232\001\000\000\ +\000\000\023\003\000\000\000\000\232\001\000\000\000\000\023\003\ +\000\000\000\000\000\000\232\001\236\001\232\001\232\001\000\000\ +\000\000\000\000\000\000\023\003\000\000\011\002\000\000\023\003\ +\023\003\000\000\232\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\071\000\023\003\000\000\071\000\023\003\000\000\ +\000\000\000\000\000\000\000\000\000\000\232\001\000\000\071\000\ +\232\001\000\000\000\000\000\000\232\001\232\001\000\000\000\000\ +\000\000\000\000\000\000\232\001\071\000\000\000\071\000\071\000\ +\000\000\232\001\000\000\000\000\000\000\000\000\000\000\240\001\ +\000\000\000\000\071\000\071\000\000\000\232\001\000\000\000\000\ +\000\000\232\001\232\001\000\000\000\000\000\000\000\000\233\001\ +\000\000\000\000\233\001\000\000\000\000\232\001\071\000\000\000\ +\232\001\071\000\000\000\000\000\233\001\071\000\071\000\000\000\ +\000\000\000\000\233\001\000\000\071\000\000\000\000\000\000\000\ +\000\000\233\001\071\000\233\001\233\001\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\011\002\000\000\071\000\000\000\ +\233\001\000\000\071\000\071\000\000\000\021\003\000\000\000\000\ +\000\000\000\000\000\000\000\000\235\001\000\000\071\000\235\001\ +\000\000\071\000\000\000\233\001\000\000\000\000\233\001\000\000\ +\000\000\235\001\233\001\233\001\000\000\000\000\000\000\235\001\ +\000\000\233\001\000\000\000\000\000\000\000\000\235\001\233\001\ +\235\001\235\001\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\233\001\000\000\235\001\000\000\233\001\ +\233\001\000\000\125\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\233\001\000\000\000\000\233\001\000\000\ +\235\001\000\000\000\000\235\001\000\000\000\000\000\000\235\001\ +\235\001\000\000\000\000\000\000\000\000\000\000\235\001\234\001\ +\000\000\000\000\234\001\000\000\235\001\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\234\001\000\000\000\000\000\000\ +\235\001\000\000\234\001\000\000\235\001\235\001\000\000\126\000\ +\000\000\234\001\000\000\234\001\234\001\000\000\000\000\000\000\ +\235\001\000\000\000\000\235\001\000\000\000\000\000\000\000\000\ +\234\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\236\001\000\000\000\000\236\001\ +\000\000\000\000\000\000\234\001\000\000\011\002\234\001\000\000\ +\000\000\236\001\234\001\234\001\000\000\011\002\000\000\236\001\ +\023\003\234\001\011\002\000\000\000\000\000\000\236\001\234\001\ +\236\001\236\001\023\003\000\000\000\000\000\000\000\000\011\002\ +\000\000\011\002\011\002\234\001\000\000\236\001\000\000\234\001\ +\234\001\000\000\000\000\000\000\000\000\000\000\011\002\000\000\ +\000\000\000\000\000\000\234\001\000\000\000\000\234\001\240\001\ +\236\001\000\000\240\001\236\001\000\000\000\000\000\000\236\001\ +\236\001\011\002\000\000\000\000\240\001\000\000\236\001\011\002\ +\011\002\011\002\240\001\000\000\236\001\000\000\000\000\011\002\ +\000\000\240\001\000\000\240\001\240\001\011\002\000\000\000\000\ +\236\001\000\000\000\000\118\000\236\001\236\001\000\000\000\000\ +\240\001\011\002\000\000\000\000\000\000\011\002\000\000\000\000\ +\236\001\000\000\000\000\236\001\011\002\000\000\000\000\000\000\ +\000\000\011\002\000\000\240\001\011\002\021\003\240\001\000\000\ +\021\003\011\002\240\001\240\001\000\000\000\000\000\000\000\000\ +\000\000\240\001\021\003\000\000\000\000\000\000\011\002\240\001\ +\011\002\011\002\000\000\000\000\021\003\000\000\000\000\021\003\ +\000\000\021\003\021\003\240\001\000\000\011\002\119\000\240\001\ +\240\001\000\000\000\000\000\000\000\000\021\003\021\003\000\000\ +\000\000\000\000\000\000\240\001\000\000\000\000\240\001\000\000\ +\011\002\000\000\125\000\011\002\000\000\125\000\011\002\011\002\ +\011\002\021\003\000\000\000\000\021\003\000\000\011\002\125\000\ +\000\000\021\003\000\000\000\000\011\002\000\000\000\000\021\003\ +\000\000\000\000\000\000\000\000\125\000\021\003\125\000\125\000\ +\011\002\000\000\000\000\000\000\011\002\011\002\000\000\000\000\ +\000\000\021\003\000\000\125\000\223\001\021\003\021\003\000\000\ +\011\002\000\000\000\000\011\002\000\000\000\000\000\000\126\000\ +\000\000\021\003\126\000\000\000\021\003\000\000\125\000\000\000\ +\000\000\125\000\000\000\000\000\126\000\125\000\125\000\000\000\ +\000\000\000\000\000\000\000\000\125\000\000\000\000\000\000\000\ +\000\000\126\000\125\000\126\000\126\000\000\000\000\000\000\000\ +\061\000\000\000\000\000\000\000\000\000\000\000\125\000\000\000\ +\126\000\064\000\125\000\125\000\000\000\000\000\000\000\000\000\ +\023\003\000\000\000\000\000\000\000\000\000\000\125\000\000\000\ +\023\003\125\000\023\003\126\000\000\000\023\003\126\000\000\000\ +\000\000\000\000\126\000\126\000\000\000\000\000\000\000\023\003\ +\000\000\126\000\023\003\000\000\023\003\023\003\000\000\126\000\ +\000\000\000\000\000\000\000\000\023\003\000\000\023\003\023\003\ +\000\000\023\003\065\000\126\000\000\000\000\000\000\000\126\000\ +\126\000\000\000\000\000\023\003\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\126\000\023\003\000\000\126\000\023\003\ +\000\000\000\000\000\000\023\003\023\003\000\000\023\003\000\000\ +\000\000\023\003\023\003\118\000\000\000\023\003\023\003\000\000\ +\023\003\000\000\000\000\000\000\023\003\000\000\021\003\000\000\ +\118\000\000\000\023\003\000\000\023\003\000\000\000\000\000\000\ +\023\003\023\003\000\000\000\000\000\000\118\000\023\003\118\000\ +\118\000\000\000\023\003\023\003\023\003\000\000\000\000\023\003\ +\000\000\000\000\000\000\000\000\118\000\000\000\023\003\000\000\ +\000\000\023\003\000\000\000\000\021\003\000\000\000\000\021\003\ +\000\000\000\000\000\000\000\000\000\000\000\000\119\000\118\000\ +\000\000\021\003\118\000\000\000\000\000\000\000\118\000\118\000\ +\000\000\000\000\000\000\119\000\000\000\118\000\021\003\000\000\ +\021\003\021\003\000\000\118\000\000\000\000\000\000\000\000\000\ +\119\000\000\000\119\000\119\000\000\000\021\003\000\000\118\000\ +\000\000\000\000\000\000\118\000\118\000\000\000\000\000\119\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\118\000\ +\021\003\000\000\118\000\021\003\000\000\000\000\000\000\000\000\ +\021\003\000\000\119\000\000\000\223\001\119\000\021\003\000\000\ +\000\000\119\000\119\000\000\000\021\003\000\000\000\000\000\000\ +\119\000\223\001\000\000\000\000\000\000\000\000\119\000\000\000\ +\021\003\000\000\000\000\000\000\021\003\021\003\223\001\000\000\ +\223\001\223\001\119\000\000\000\000\000\000\000\119\000\119\000\ +\021\003\000\000\000\000\021\003\000\000\223\001\000\000\000\000\ +\061\000\000\000\119\000\000\000\000\000\119\000\000\000\000\000\ +\000\000\064\000\000\000\000\000\000\000\061\000\000\000\000\000\ +\223\001\000\000\000\000\223\001\000\000\000\000\064\000\223\001\ +\223\001\000\000\061\000\000\000\061\000\061\000\223\001\000\000\ +\000\000\000\000\000\000\064\000\223\001\064\000\064\000\000\000\ +\000\000\061\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\223\001\000\000\064\000\000\000\223\001\223\001\000\000\000\000\ +\000\000\000\000\065\000\000\000\061\000\000\000\000\000\061\000\ +\223\001\000\000\000\000\223\001\061\000\064\000\000\000\065\000\ +\064\000\000\000\061\000\000\000\000\000\064\000\000\000\000\000\ +\061\000\000\000\000\000\064\000\065\000\000\000\065\000\065\000\ +\000\000\064\000\000\000\000\000\061\000\000\000\000\000\000\000\ +\061\000\061\000\000\000\065\000\000\000\064\000\021\003\000\000\ +\000\000\064\000\064\000\000\000\061\000\000\000\000\000\061\000\ +\000\000\000\000\000\000\021\003\000\000\064\000\065\000\000\000\ +\064\000\065\000\000\000\000\000\000\000\000\000\065\000\000\000\ +\021\003\000\000\021\003\021\003\065\000\000\000\000\000\000\000\ +\000\000\000\000\065\000\000\000\000\000\000\000\000\000\021\003\ +\000\000\000\000\000\000\000\000\000\000\000\000\065\000\000\000\ +\000\000\000\000\065\000\065\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\021\003\000\000\000\000\021\003\065\000\000\000\ +\000\000\065\000\021\003\000\000\000\000\000\000\000\000\000\000\ +\021\003\000\000\000\000\000\000\000\000\000\000\021\003\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\021\003\016\003\000\000\000\000\021\003\021\003\ +\016\003\016\003\016\003\016\003\000\000\000\000\016\003\016\003\ +\016\003\016\003\021\003\000\000\000\000\021\003\016\003\000\000\ +\000\000\000\000\000\000\000\000\000\000\016\003\000\000\016\003\ +\016\003\016\003\016\003\016\003\016\003\016\003\016\003\000\000\ +\000\000\000\000\016\003\000\000\016\003\000\000\000\000\000\000\ +\000\000\000\000\000\000\016\003\016\003\016\003\016\003\016\003\ +\016\003\016\003\016\003\016\003\000\000\000\000\016\003\016\003\ +\000\000\000\000\016\003\016\003\016\003\016\003\000\000\016\003\ +\016\003\016\003\016\003\016\003\000\000\016\003\000\000\016\003\ +\016\003\016\003\000\000\016\003\016\003\000\000\000\000\016\003\ +\016\003\000\000\016\003\000\000\016\003\016\003\000\000\016\003\ +\016\003\000\000\000\000\016\003\016\003\000\000\016\003\000\000\ +\016\003\016\003\000\000\016\003\000\000\016\003\016\003\016\003\ +\016\003\016\003\016\003\016\003\023\003\016\003\000\000\000\000\ +\000\000\023\003\023\003\023\003\023\003\000\000\000\000\023\003\ +\023\003\000\000\000\000\000\000\000\000\000\000\000\000\023\003\ +\000\000\000\000\000\000\000\000\000\000\000\000\023\003\000\000\ +\023\003\000\000\023\003\023\003\023\003\023\003\023\003\023\003\ +\000\000\000\000\000\000\023\003\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\023\003\023\003\023\003\023\003\ +\023\003\023\003\023\003\023\003\023\003\000\000\000\000\023\003\ +\023\003\000\000\000\000\023\003\023\003\023\003\000\000\000\000\ +\023\003\023\003\023\003\023\003\023\003\000\000\023\003\000\000\ +\023\003\023\003\023\003\000\000\000\000\023\003\000\000\000\000\ +\023\003\023\003\000\000\023\003\000\000\023\003\023\003\000\000\ +\000\000\023\003\000\000\000\000\000\000\023\003\000\000\023\003\ +\000\000\023\003\023\003\000\000\023\003\000\000\023\003\023\003\ +\000\000\023\003\023\003\023\003\023\003\000\000\023\003\026\001\ +\027\001\028\001\000\000\000\000\009\000\010\000\029\001\000\000\ +\030\001\000\000\012\000\013\000\000\000\000\000\031\001\032\001\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\033\001\000\000\000\000\017\000\018\000\019\000\ +\020\000\021\000\000\000\034\001\000\000\000\000\022\000\000\000\ +\000\000\035\001\036\001\037\001\038\001\039\001\040\001\000\000\ +\000\000\024\000\000\000\025\000\026\000\027\000\028\000\029\000\ +\000\000\000\000\030\000\000\000\041\001\000\000\032\000\033\000\ +\034\000\000\000\000\000\000\000\036\000\000\000\042\001\043\001\ +\000\000\044\001\000\000\040\000\000\000\041\000\000\000\000\000\ +\000\000\045\001\046\001\047\001\048\001\049\001\050\001\000\000\ +\000\000\000\000\000\000\000\000\000\000\051\001\000\000\000\000\ +\000\000\052\001\000\000\053\001\047\000\000\000\000\000\000\000\ +\000\000\048\000\049\000\000\000\051\000\052\000\026\001\027\001\ +\028\001\054\000\000\000\009\000\010\000\029\001\000\000\030\001\ +\000\000\012\000\013\000\000\000\000\000\079\003\032\001\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\033\001\000\000\000\000\017\000\018\000\019\000\020\000\ +\021\000\000\000\034\001\000\000\000\000\022\000\000\000\000\000\ +\035\001\036\001\037\001\038\001\039\001\040\001\000\000\000\000\ +\024\000\000\000\025\000\026\000\027\000\028\000\029\000\000\000\ +\000\000\030\000\000\000\041\001\000\000\032\000\033\000\034\000\ +\000\000\000\000\000\000\036\000\000\000\042\001\043\001\000\000\ +\080\003\000\000\040\000\000\000\041\000\000\000\000\000\000\000\ +\045\001\046\001\047\001\048\001\049\001\050\001\000\000\000\000\ +\000\000\000\000\000\000\089\002\081\003\089\002\089\002\089\002\ +\052\001\089\002\053\001\047\000\089\002\089\002\000\000\000\000\ +\048\000\049\000\000\000\051\000\052\000\023\003\000\000\000\000\ +\054\000\000\000\023\003\023\003\023\003\089\002\000\000\000\000\ +\023\003\023\003\023\003\000\000\000\000\089\002\089\002\000\000\ +\000\000\000\000\000\000\000\000\000\000\089\002\000\000\023\003\ +\000\000\023\003\023\003\023\003\023\003\023\003\023\003\023\003\ +\000\000\089\002\089\002\000\000\023\003\000\000\023\003\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\023\003\ +\000\000\023\003\023\003\023\003\023\003\023\003\000\000\000\000\ +\023\003\023\003\000\000\000\000\023\003\023\003\023\003\000\000\ +\000\000\023\003\023\003\000\000\023\003\023\003\000\000\023\003\ +\000\000\023\003\000\000\023\003\000\000\023\003\000\000\000\000\ +\000\000\023\003\023\003\143\002\023\003\000\000\000\000\000\000\ +\217\002\217\002\217\002\000\000\000\000\023\003\217\002\217\002\ +\000\000\000\000\023\003\000\000\000\000\000\000\000\000\023\003\ +\023\003\023\003\023\003\023\003\023\003\000\000\000\000\023\003\ +\000\000\217\002\217\002\217\002\217\002\217\002\000\000\000\000\ +\000\000\000\000\217\002\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\217\002\000\000\217\002\ +\217\002\217\002\217\002\217\002\000\000\000\000\217\002\000\000\ +\000\000\000\000\217\002\217\002\217\002\000\000\000\000\000\000\ +\217\002\000\000\217\002\217\002\000\000\000\000\000\000\217\002\ +\000\000\217\002\000\000\000\000\000\000\000\000\000\000\217\002\ +\217\002\144\002\217\002\000\000\000\000\000\000\218\002\218\002\ +\218\002\143\002\000\000\000\000\218\002\218\002\000\000\000\000\ +\217\002\000\000\000\000\000\000\000\000\217\002\217\002\000\000\ +\217\002\217\002\000\000\000\000\000\000\217\002\000\000\218\002\ +\218\002\218\002\218\002\218\002\000\000\000\000\000\000\000\000\ +\218\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\218\002\000\000\218\002\218\002\218\002\ +\218\002\218\002\000\000\000\000\218\002\000\000\000\000\000\000\ +\218\002\218\002\218\002\000\000\000\000\000\000\218\002\000\000\ +\218\002\218\002\000\000\000\000\000\000\218\002\000\000\218\002\ +\000\000\000\000\000\000\000\000\000\000\218\002\218\002\141\002\ +\218\002\000\000\000\000\000\000\219\002\219\002\219\002\144\002\ +\000\000\000\000\219\002\219\002\000\000\000\000\218\002\000\000\ +\000\000\000\000\000\000\218\002\218\002\000\000\218\002\218\002\ +\000\000\000\000\000\000\218\002\000\000\219\002\219\002\219\002\ +\219\002\219\002\000\000\000\000\000\000\000\000\219\002\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\219\002\000\000\219\002\219\002\219\002\219\002\219\002\ +\000\000\000\000\219\002\000\000\000\000\000\000\219\002\219\002\ +\219\002\000\000\000\000\000\000\219\002\000\000\219\002\219\002\ +\000\000\000\000\000\000\219\002\000\000\219\002\000\000\000\000\ +\000\000\000\000\000\000\219\002\219\002\142\002\219\002\000\000\ +\000\000\000\000\220\002\220\002\220\002\141\002\000\000\000\000\ +\220\002\220\002\000\000\000\000\219\002\000\000\000\000\000\000\ +\000\000\219\002\219\002\000\000\219\002\219\002\000\000\000\000\ +\000\000\219\002\000\000\220\002\220\002\220\002\220\002\220\002\ +\000\000\000\000\000\000\000\000\220\002\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\220\002\ +\000\000\220\002\220\002\220\002\220\002\220\002\000\000\000\000\ +\220\002\000\000\000\000\000\000\220\002\220\002\220\002\000\000\ +\000\000\000\000\220\002\000\000\220\002\220\002\000\000\000\000\ +\000\000\220\002\000\000\220\002\000\000\000\000\000\000\000\000\ +\000\000\220\002\220\002\000\000\220\002\000\000\000\000\000\000\ +\000\000\000\000\000\000\142\002\224\000\225\000\226\000\000\000\ +\000\000\000\000\220\002\000\000\227\000\000\000\228\000\220\002\ +\220\002\000\000\220\002\220\002\229\000\230\000\231\000\220\002\ +\000\000\232\000\233\000\234\000\000\000\235\000\236\000\237\000\ +\000\000\238\000\239\000\240\000\241\000\000\000\000\000\000\000\ +\242\000\243\000\244\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\245\000\246\000\000\000\000\000\247\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\248\000\249\000\000\000\000\000\000\000\062\002\250\000\251\000\ +\000\000\062\002\000\000\252\000\253\000\254\000\255\000\000\001\ +\001\001\002\001\000\000\003\001\000\000\000\000\062\002\000\000\ +\062\002\004\001\000\000\045\002\000\000\000\000\005\001\062\002\ +\062\002\000\000\000\000\000\000\006\001\000\000\000\000\007\001\ +\008\001\062\002\009\001\010\001\011\001\012\001\013\001\000\000\ +\014\001\015\001\016\001\017\001\018\001\062\002\062\002\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\062\002\000\000\000\000\000\000\062\002\000\000\062\002\ +\062\002\062\002\000\000\062\002\000\000\000\000\062\002\000\000\ +\000\000\000\000\026\001\027\001\028\001\000\000\000\000\000\000\ +\010\000\207\001\000\000\030\001\000\000\000\000\013\000\045\002\ +\062\002\031\001\032\001\000\000\062\002\000\000\062\002\000\000\ +\000\000\062\002\000\000\000\000\000\000\033\001\161\000\000\000\ +\017\000\018\000\062\002\000\000\062\002\000\000\034\001\000\000\ +\000\000\000\000\000\000\000\000\035\001\036\001\037\001\038\001\ +\039\001\040\001\000\000\000\000\024\000\000\000\162\000\163\000\ +\000\000\164\000\165\000\000\000\000\000\030\000\000\000\041\001\ +\000\000\000\000\166\000\167\000\000\000\000\000\000\000\000\000\ +\000\000\208\001\209\001\000\000\210\001\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\045\001\046\001\211\001\212\001\ +\049\001\213\001\000\000\000\000\000\000\000\000\000\000\000\000\ +\051\001\000\000\000\000\170\000\052\001\000\000\053\001\047\000\ +\000\000\000\000\000\000\000\000\048\000\000\000\240\002\051\000\ +\171\000\026\001\027\001\028\001\000\000\000\000\000\000\010\000\ +\207\001\000\000\030\001\000\000\000\000\013\000\000\000\000\000\ +\031\001\032\001\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\033\001\161\000\000\000\017\000\ +\018\000\000\000\000\000\000\000\000\000\034\001\000\000\000\000\ +\000\000\000\000\000\000\035\001\036\001\037\001\038\001\039\001\ +\040\001\000\000\000\000\024\000\000\000\162\000\163\000\000\000\ +\164\000\165\000\000\000\000\000\030\000\000\000\041\001\000\000\ +\000\000\166\000\167\000\000\000\000\000\000\000\000\000\000\000\ +\208\001\209\001\000\000\210\001\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\045\001\046\001\211\001\212\001\049\001\ +\213\001\000\000\000\000\000\000\000\000\000\000\000\000\051\001\ +\000\000\000\000\170\000\052\001\000\000\053\001\047\000\000\000\ +\000\000\000\000\000\000\048\000\000\000\194\003\051\000\171\000\ +\026\001\027\001\028\001\000\000\000\000\000\000\010\000\207\001\ +\000\000\030\001\000\000\000\000\013\000\000\000\000\000\031\001\ +\032\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\033\001\161\000\000\000\017\000\018\000\ +\000\000\000\000\000\000\000\000\034\001\000\000\000\000\000\000\ +\000\000\000\000\035\001\036\001\037\001\038\001\039\001\040\001\ +\000\000\000\000\024\000\000\000\162\000\163\000\000\000\164\000\ +\165\000\000\000\000\000\030\000\000\000\041\001\000\000\000\000\ +\166\000\167\000\000\000\000\000\000\000\000\000\000\000\208\001\ +\209\001\000\000\210\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\045\001\046\001\211\001\212\001\049\001\213\001\ +\000\000\000\000\000\000\000\000\000\000\000\000\051\001\000\000\ +\000\000\170\000\052\001\000\000\053\001\047\000\000\000\000\000\ +\000\000\000\000\048\000\000\000\154\004\051\000\171\000\026\001\ +\027\001\028\001\000\000\000\000\000\000\010\000\207\001\000\000\ +\030\001\000\000\000\000\013\000\000\000\000\000\031\001\032\001\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\033\001\161\000\000\000\017\000\018\000\000\000\ +\000\000\000\000\000\000\034\001\000\000\000\000\000\000\000\000\ +\000\000\035\001\036\001\037\001\038\001\039\001\040\001\000\000\ +\000\000\024\000\000\000\162\000\163\000\000\000\164\000\165\000\ +\000\000\000\000\030\000\000\000\041\001\000\000\000\000\166\000\ +\167\000\000\000\000\000\000\000\000\000\000\000\208\001\209\001\ +\000\000\210\001\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\045\001\046\001\211\001\212\001\049\001\213\001\000\000\ +\000\000\157\003\000\000\000\000\000\000\051\001\000\000\010\000\ +\170\000\052\001\000\000\053\001\047\000\013\000\000\000\000\000\ +\079\003\048\000\000\000\000\000\051\000\171\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\161\000\000\000\017\000\ +\018\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\024\000\000\000\162\000\163\000\000\000\ +\164\000\165\000\000\000\000\000\030\000\000\000\200\002\000\000\ +\000\000\166\000\167\000\000\000\010\000\000\000\000\000\000\000\ +\168\000\000\000\013\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\169\000\000\000\000\000\ +\000\000\000\000\161\000\000\000\017\000\018\000\000\000\158\003\ +\000\000\000\000\170\000\000\000\000\000\000\000\047\000\000\000\ +\000\000\000\000\000\000\048\000\000\000\000\000\051\000\171\000\ +\024\000\000\000\162\000\163\000\000\000\164\000\165\000\000\000\ +\000\000\030\000\000\000\202\002\000\000\000\000\166\000\167\000\ +\000\000\010\000\000\000\000\000\000\000\168\000\000\000\013\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\169\000\000\000\000\000\000\000\000\000\161\000\ +\000\000\017\000\018\000\000\000\000\000\000\000\000\000\170\000\ +\000\000\000\000\000\000\047\000\000\000\000\000\000\000\000\000\ +\048\000\000\000\000\000\051\000\171\000\024\000\000\000\162\000\ +\163\000\000\000\164\000\165\000\000\000\000\000\030\000\000\000\ +\204\002\000\000\000\000\166\000\167\000\000\000\010\000\000\000\ +\000\000\000\000\168\000\000\000\013\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\169\000\ +\000\000\000\000\000\000\000\000\161\000\000\000\017\000\018\000\ +\000\000\000\000\000\000\000\000\170\000\000\000\000\000\000\000\ +\047\000\000\000\000\000\000\000\000\000\048\000\000\000\000\000\ +\051\000\171\000\024\000\000\000\162\000\163\000\000\000\164\000\ +\165\000\000\000\000\000\030\000\000\000\161\004\000\000\000\000\ +\166\000\167\000\000\000\010\000\000\000\000\000\000\000\168\000\ +\000\000\013\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\169\000\000\000\000\000\000\000\ +\000\000\161\000\000\000\017\000\018\000\000\000\000\000\000\000\ +\000\000\170\000\000\000\000\000\000\000\047\000\000\000\000\000\ +\000\000\000\000\048\000\000\000\000\000\051\000\171\000\024\000\ +\000\000\162\000\163\000\000\000\164\000\165\000\000\000\000\000\ +\030\000\000\000\163\004\000\000\000\000\166\000\167\000\000\000\ +\010\000\000\000\000\000\000\000\168\000\000\000\013\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\169\000\000\000\000\000\000\000\000\000\161\000\000\000\ +\017\000\018\000\000\000\000\000\000\000\000\000\170\000\000\000\ +\000\000\000\000\047\000\000\000\000\000\000\000\000\000\048\000\ +\000\000\000\000\051\000\171\000\024\000\000\000\162\000\163\000\ +\000\000\164\000\165\000\000\000\000\000\030\000\000\000\165\004\ +\000\000\000\000\166\000\167\000\000\000\010\000\000\000\000\000\ +\000\000\168\000\000\000\013\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\169\000\000\000\ +\000\000\000\000\000\000\161\000\000\000\017\000\018\000\000\000\ +\000\000\000\000\000\000\170\000\000\000\000\000\000\000\047\000\ +\000\000\000\000\000\000\000\000\048\000\000\000\000\000\051\000\ +\171\000\024\000\000\000\162\000\163\000\000\000\164\000\165\000\ +\000\000\000\000\030\000\000\000\000\000\000\000\000\000\166\000\ +\167\000\009\000\010\000\011\000\000\000\000\000\168\000\012\000\ +\013\000\014\000\032\002\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\169\000\000\000\000\000\000\000\000\000\ +\015\000\016\000\017\000\018\000\019\000\020\000\021\000\000\000\ +\170\000\000\000\000\000\022\000\047\000\023\000\000\000\000\000\ +\000\000\048\000\000\000\000\000\051\000\171\000\024\000\000\000\ +\025\000\026\000\027\000\028\000\029\000\000\000\000\000\030\000\ +\031\000\000\000\000\000\032\000\033\000\034\000\000\000\000\000\ +\035\000\036\000\000\000\037\000\038\000\000\000\039\000\000\000\ +\040\000\000\000\041\000\000\000\042\000\000\000\000\000\000\000\ +\043\000\044\000\000\000\045\000\000\000\033\002\000\000\000\000\ +\009\000\010\000\011\000\000\000\046\000\000\000\012\000\013\000\ +\014\000\047\000\000\000\000\000\000\000\000\000\048\000\049\000\ +\050\000\051\000\052\000\053\000\000\000\000\000\054\000\015\000\ +\016\000\017\000\018\000\019\000\020\000\021\000\000\000\000\000\ +\000\000\000\000\022\000\000\000\023\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\024\000\000\000\025\000\ +\026\000\027\000\028\000\029\000\000\000\000\000\030\000\031\000\ +\000\000\000\000\032\000\033\000\034\000\000\000\000\000\035\000\ +\036\000\000\000\037\000\038\000\000\000\039\000\000\000\040\000\ +\000\000\041\000\000\000\042\000\000\000\000\000\000\000\043\000\ +\044\000\000\000\045\000\000\000\000\000\000\000\009\000\010\000\ +\011\000\000\000\000\000\046\000\012\000\013\000\000\000\000\000\ +\047\000\000\000\000\000\000\000\000\000\048\000\049\000\050\000\ +\051\000\052\000\053\000\000\000\000\000\054\000\000\000\017\000\ +\018\000\019\000\020\000\021\000\000\000\000\000\000\000\000\000\ +\022\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\024\000\000\000\025\000\026\000\027\000\ +\028\000\029\000\000\000\000\000\030\000\000\000\000\000\000\000\ +\032\000\033\000\034\000\000\000\000\000\000\000\036\000\000\000\ +\037\000\038\000\000\000\000\000\000\000\040\000\000\000\041\000\ +\000\000\000\000\000\000\000\000\000\000\043\000\044\000\000\000\ +\045\000\000\000\000\000\000\000\000\000\219\000\009\000\010\000\ +\011\000\000\000\000\000\222\000\012\000\013\000\047\000\000\000\ +\000\000\000\000\000\000\048\000\049\000\000\000\051\000\052\000\ +\000\000\000\000\000\000\054\000\000\000\000\000\000\000\017\000\ +\018\000\019\000\020\000\021\000\000\000\000\000\000\000\000\000\ +\022\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\024\000\000\000\025\000\026\000\027\000\ +\028\000\029\000\000\000\000\000\030\000\000\000\000\000\000\000\ +\032\000\033\000\034\000\000\000\000\000\000\000\036\000\000\000\ +\037\000\038\000\000\000\000\000\000\000\040\000\000\000\041\000\ +\000\000\000\000\000\000\000\000\000\000\043\000\044\000\000\000\ +\045\000\000\000\000\000\009\000\010\000\011\000\000\000\000\000\ +\000\000\012\000\013\000\000\000\000\000\000\000\047\000\000\000\ +\000\000\000\000\000\000\048\000\049\000\000\000\051\000\052\000\ +\238\001\000\000\000\000\054\000\017\000\018\000\019\000\020\000\ +\021\000\000\000\000\000\000\000\000\000\022\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\024\000\000\000\025\000\026\000\027\000\028\000\029\000\000\000\ +\000\000\030\000\000\000\000\000\000\000\032\000\033\000\034\000\ +\000\000\000\000\000\000\036\000\000\000\037\000\038\000\000\000\ +\000\000\000\000\040\000\000\000\041\000\000\000\000\000\000\000\ +\000\000\000\000\043\000\044\000\000\000\045\000\000\000\000\000\ +\009\000\010\000\011\000\000\000\000\000\000\000\012\000\013\000\ +\000\000\000\000\000\000\047\000\000\000\000\000\000\000\000\000\ +\048\000\049\000\000\000\051\000\052\000\000\000\000\000\000\000\ +\054\000\017\000\018\000\019\000\020\000\021\000\000\000\000\000\ +\000\000\000\000\022\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\024\000\000\000\025\000\ +\026\000\027\000\028\000\029\000\000\000\000\000\030\000\000\000\ +\000\000\000\000\032\000\033\000\034\000\000\000\000\000\000\000\ +\036\000\000\000\037\000\038\000\000\000\000\000\000\000\040\000\ +\000\000\041\000\000\000\000\000\000\000\000\000\100\002\043\000\ +\044\000\000\000\045\000\000\000\000\000\009\000\010\000\011\000\ +\000\000\000\000\000\000\012\000\013\000\000\000\000\000\000\000\ +\047\000\000\000\000\000\000\000\000\000\048\000\049\000\000\000\ +\051\000\052\000\000\000\000\000\000\000\054\000\017\000\018\000\ +\019\000\020\000\021\000\000\000\000\000\000\000\000\000\022\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\024\000\000\000\025\000\026\000\027\000\028\000\ +\029\000\000\000\000\000\030\000\000\000\000\000\000\000\032\000\ +\033\000\034\000\000\000\000\000\000\000\036\000\000\000\037\000\ +\038\000\000\000\000\000\000\000\040\000\000\000\041\000\000\000\ +\000\000\000\000\000\000\000\000\043\000\044\000\000\000\045\000\ +\000\000\000\000\000\000\000\000\075\003\009\000\010\000\011\000\ +\000\000\000\000\077\003\012\000\013\000\047\000\000\000\000\000\ +\000\000\000\000\048\000\049\000\000\000\051\000\052\000\000\000\ +\000\000\000\000\054\000\000\000\000\000\000\000\017\000\018\000\ +\019\000\020\000\021\000\000\000\000\000\000\000\000\000\022\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\024\000\000\000\025\000\026\000\027\000\028\000\ +\029\000\000\000\000\000\030\000\000\000\000\000\000\000\032\000\ +\033\000\034\000\000\000\000\000\000\000\036\000\000\000\037\000\ +\038\000\000\000\000\000\000\000\040\000\000\000\041\000\000\000\ +\000\000\000\000\000\000\000\000\043\000\044\000\000\000\045\000\ +\000\000\000\000\000\000\009\000\010\000\011\000\000\000\000\000\ +\000\000\012\000\013\000\000\000\000\000\047\000\000\000\000\000\ +\000\000\000\000\048\000\049\000\134\004\051\000\052\000\000\000\ +\000\000\000\000\054\000\000\000\017\000\018\000\019\000\020\000\ +\021\000\000\000\000\000\000\000\000\000\022\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\024\000\000\000\025\000\026\000\027\000\028\000\029\000\000\000\ +\000\000\030\000\000\000\000\000\000\000\032\000\033\000\034\000\ +\000\000\000\000\000\000\036\000\000\000\037\000\038\000\000\000\ +\000\000\000\000\040\000\000\000\041\000\000\000\000\000\000\000\ +\000\000\000\000\043\000\044\000\000\000\045\000\000\000\000\000\ +\025\003\025\003\025\003\000\000\000\000\000\000\025\003\025\003\ +\000\000\000\000\000\000\047\000\000\000\000\000\000\000\000\000\ +\048\000\049\000\000\000\051\000\052\000\025\003\000\000\000\000\ +\054\000\025\003\025\003\025\003\025\003\025\003\000\000\000\000\ +\000\000\000\000\025\003\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\025\003\000\000\025\003\ +\025\003\025\003\025\003\025\003\000\000\000\000\025\003\000\000\ +\000\000\000\000\025\003\025\003\025\003\000\000\000\000\000\000\ +\025\003\000\000\025\003\025\003\000\000\000\000\000\000\025\003\ +\000\000\025\003\000\000\000\000\000\000\000\000\000\000\025\003\ +\025\003\000\000\025\003\000\000\000\000\009\000\010\000\011\000\ +\000\000\000\000\000\000\012\000\013\000\000\000\000\000\000\000\ +\025\003\000\000\000\000\000\000\000\000\025\003\025\003\000\000\ +\025\003\025\003\000\000\000\000\000\000\025\003\017\000\018\000\ +\019\000\020\000\021\000\000\000\000\000\000\000\000\000\022\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\024\000\000\000\025\000\026\000\027\000\028\000\ +\029\000\000\000\000\000\030\000\000\000\000\000\000\000\032\000\ +\033\000\034\000\000\000\000\000\000\000\036\000\000\000\037\000\ +\038\000\000\000\000\000\000\000\040\000\000\000\041\000\000\000\ +\000\000\000\000\000\000\000\000\043\000\044\000\000\000\045\000\ +\000\000\000\000\025\003\025\003\025\003\000\000\000\000\000\000\ +\025\003\025\003\000\000\000\000\000\000\047\000\000\000\000\000\ +\000\000\000\000\048\000\049\000\000\000\051\000\052\000\000\000\ +\000\000\000\000\054\000\025\003\025\003\025\003\025\003\025\003\ +\000\000\000\000\000\000\000\000\025\003\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\025\003\ +\000\000\025\003\025\003\025\003\025\003\025\003\000\000\000\000\ +\025\003\000\000\000\000\000\000\025\003\025\003\025\003\000\000\ +\000\000\000\000\025\003\000\000\025\003\025\003\000\000\000\000\ +\000\000\025\003\000\000\025\003\000\000\000\000\000\000\000\000\ +\000\000\025\003\025\003\000\000\025\003\000\000\000\000\023\003\ +\023\003\023\003\000\000\000\000\000\000\023\003\023\003\000\000\ +\000\000\000\000\025\003\000\000\000\000\000\000\000\000\025\003\ +\025\003\000\000\025\003\025\003\000\000\000\000\000\000\025\003\ +\023\003\023\003\023\003\023\003\023\003\000\000\000\000\000\000\ +\000\000\023\003\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\023\003\000\000\023\003\023\003\ +\023\003\023\003\023\003\000\000\000\000\023\003\000\000\000\000\ +\000\000\023\003\023\003\023\003\000\000\000\000\000\000\023\003\ +\000\000\023\003\023\003\000\000\000\000\010\000\023\003\000\000\ +\023\003\000\000\000\000\013\000\000\000\217\003\023\003\023\003\ +\018\002\023\003\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\218\003\000\000\000\000\017\000\018\000\023\003\ +\000\000\000\000\000\000\000\000\023\003\023\003\000\000\023\003\ +\023\003\000\000\000\000\000\000\023\003\000\000\000\000\000\000\ +\000\000\024\000\252\001\000\000\163\000\000\000\164\000\165\000\ +\000\000\000\000\030\000\000\000\000\000\000\000\000\000\166\000\ +\219\003\000\000\010\000\000\000\000\000\000\000\168\000\000\000\ +\013\000\000\000\017\002\000\000\000\000\018\002\000\000\000\000\ +\254\001\000\000\000\000\169\000\000\000\000\000\000\000\218\003\ +\255\001\000\000\017\000\018\000\000\000\010\000\000\000\000\000\ +\170\000\000\000\000\000\013\000\047\000\250\002\000\000\000\002\ +\000\000\048\000\000\000\000\000\051\000\171\000\024\000\252\001\ +\000\000\163\000\000\000\164\000\165\000\017\000\018\000\030\000\ +\000\000\000\000\000\000\000\000\166\000\219\003\000\000\000\000\ +\000\000\000\000\000\000\168\000\000\000\000\000\000\000\000\000\ +\000\000\024\000\252\001\000\000\163\000\254\001\164\000\165\000\ +\169\000\000\000\030\000\000\000\000\000\255\001\000\000\166\000\ +\251\002\000\000\000\000\000\000\000\000\170\000\168\000\000\000\ +\252\002\047\000\000\000\000\000\000\002\000\000\048\000\000\000\ +\254\001\051\000\171\000\169\000\000\000\000\000\010\000\000\000\ +\255\001\000\000\000\000\000\000\013\000\000\000\107\004\000\000\ +\170\000\000\000\000\000\000\000\047\000\000\000\000\000\000\002\ +\000\000\048\000\000\000\108\004\051\000\171\000\017\000\018\000\ +\000\000\010\000\000\000\000\000\000\000\000\000\000\000\013\000\ +\000\000\031\006\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\024\000\252\001\000\000\163\000\218\003\164\000\ +\165\000\017\000\018\000\030\000\000\000\000\000\000\000\000\000\ +\166\000\167\000\000\000\000\000\000\000\000\000\000\000\168\000\ +\000\000\000\000\000\000\000\000\000\000\024\000\252\001\000\000\ +\163\000\254\001\164\000\165\000\169\000\000\000\030\000\000\000\ +\000\000\255\001\000\000\166\000\219\003\000\000\010\000\000\000\ +\000\000\170\000\168\000\000\000\013\000\047\000\000\000\000\000\ +\000\002\000\000\048\000\000\000\254\001\051\000\171\000\169\000\ +\000\000\000\000\000\000\000\000\255\001\000\000\017\000\018\000\ +\000\000\010\000\000\000\000\000\170\000\000\000\000\000\013\000\ +\047\000\000\000\000\000\000\002\000\000\048\000\000\000\000\000\ +\051\000\171\000\024\000\252\001\000\000\163\000\000\000\164\000\ +\165\000\017\000\018\000\030\000\000\000\000\000\000\000\000\000\ +\166\000\167\000\000\000\000\000\000\000\000\000\000\000\168\000\ +\000\000\015\006\000\000\000\000\000\000\024\000\252\001\000\000\ +\163\000\254\001\164\000\165\000\169\000\000\000\030\000\000\000\ +\000\000\255\001\000\000\166\000\253\001\000\000\010\000\000\000\ +\000\000\170\000\168\000\000\000\013\000\047\000\000\000\000\000\ +\000\002\000\000\048\000\000\000\254\001\051\000\171\000\169\000\ +\000\000\000\000\000\000\000\000\255\001\000\000\017\000\018\000\ +\000\000\025\003\000\000\000\000\170\000\000\000\000\000\025\003\ +\047\000\000\000\000\000\000\002\000\000\048\000\000\000\000\000\ +\051\000\171\000\024\000\252\001\000\000\163\000\000\000\164\000\ +\165\000\025\003\025\003\030\000\000\000\000\000\000\000\000\000\ +\166\000\167\000\000\000\000\000\000\000\000\000\000\000\168\000\ +\000\000\000\000\000\000\000\000\000\000\025\003\025\003\000\000\ +\025\003\254\001\025\003\025\003\169\000\000\000\025\003\000\000\ +\000\000\255\001\000\000\025\003\025\003\000\000\023\003\000\000\ +\000\000\170\000\025\003\000\000\023\003\047\000\000\000\000\000\ +\000\002\000\000\048\000\000\000\025\003\051\000\171\000\025\003\ +\000\000\000\000\000\000\000\000\025\003\000\000\023\003\023\003\ +\000\000\000\000\000\000\000\000\025\003\000\000\000\000\000\000\ +\025\003\000\000\000\000\025\003\000\000\025\003\000\000\000\000\ +\025\003\025\003\023\003\023\003\000\000\023\003\000\000\023\003\ +\023\003\000\000\000\000\023\003\000\000\000\000\000\000\000\000\ +\023\003\023\003\000\000\000\000\010\000\000\000\000\000\023\003\ +\000\000\000\000\013\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\023\003\000\000\000\000\023\003\000\000\000\000\000\000\ +\000\000\023\003\161\000\000\000\017\000\018\000\000\000\000\000\ +\000\000\023\003\000\000\000\000\000\000\023\003\000\000\000\000\ +\023\003\000\000\023\003\000\000\000\000\023\003\023\003\000\000\ +\024\000\000\000\162\000\163\000\000\000\164\000\165\000\000\000\ +\000\000\030\000\000\000\000\000\000\000\000\000\166\000\167\000\ +\000\000\000\000\000\000\010\000\000\000\168\000\000\000\205\001\ +\000\000\013\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\169\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\161\000\219\000\017\000\018\000\000\000\000\000\170\000\ +\000\000\000\000\000\000\047\000\000\000\000\000\000\000\000\000\ +\048\000\000\000\000\000\051\000\171\000\000\000\000\000\024\000\ +\000\000\162\000\163\000\000\000\164\000\165\000\000\000\000\000\ +\030\000\000\000\000\000\000\000\000\000\166\000\167\000\000\000\ +\010\000\000\000\000\000\000\000\168\000\000\000\013\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\010\000\011\000\000\000\ +\000\000\169\000\012\000\013\000\000\000\000\000\161\000\000\000\ +\017\000\018\000\000\000\000\000\000\000\000\000\170\000\000\000\ +\000\000\000\000\047\000\000\000\000\000\017\000\018\000\048\000\ +\000\000\000\000\051\000\171\000\024\000\000\000\162\000\163\000\ +\000\000\164\000\165\000\000\000\000\000\030\000\000\000\000\000\ +\000\000\024\000\166\000\167\000\026\000\027\000\028\000\029\000\ +\000\000\168\000\030\000\000\000\025\003\000\000\025\003\166\000\ +\034\000\000\000\025\003\000\000\000\000\000\000\169\000\000\000\ +\000\000\000\000\000\000\040\000\000\000\000\000\156\003\000\000\ +\000\000\000\000\025\003\170\000\025\003\025\003\045\000\047\000\ +\000\000\000\000\000\000\000\000\048\000\000\000\000\000\051\000\ +\171\000\000\000\000\000\000\000\047\000\000\000\000\000\000\000\ +\025\003\048\000\025\003\025\003\051\000\025\003\025\003\000\000\ +\000\000\025\003\000\000\000\000\000\000\000\000\025\003\025\003\ +\000\000\010\000\000\000\000\000\000\000\025\003\000\000\013\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\025\003\000\000\000\000\000\000\000\000\161\000\ +\000\000\017\000\018\000\000\000\000\000\000\000\000\000\025\003\ +\000\000\000\000\000\000\025\003\000\000\000\000\000\000\000\000\ +\025\003\000\000\000\000\025\003\025\003\024\000\000\000\162\000\ +\163\000\000\000\164\000\165\000\000\000\000\000\030\000\000\000\ +\000\000\000\000\000\000\166\000\167\000\000\000\025\003\000\000\ +\000\000\000\000\168\000\000\000\025\003\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\169\000\ +\000\000\000\000\000\000\000\000\025\003\000\000\025\003\025\003\ +\000\000\025\003\000\000\000\000\170\000\000\000\000\000\025\003\ +\047\000\000\000\000\000\000\000\000\000\048\000\000\000\000\000\ +\051\000\171\000\025\003\000\000\025\003\025\003\000\000\025\003\ +\025\003\025\003\025\003\025\003\000\000\000\000\000\000\000\000\ +\025\003\025\003\000\000\000\000\000\000\000\000\000\000\025\003\ +\000\000\000\000\000\000\000\000\000\000\025\003\000\000\025\003\ +\025\003\000\000\025\003\025\003\025\003\000\000\025\003\000\000\ +\000\000\000\000\000\000\025\003\025\003\000\000\213\002\000\000\ +\000\000\025\003\025\003\000\000\213\002\025\003\000\000\000\000\ +\000\000\000\000\025\003\000\000\000\000\025\003\025\003\025\003\ +\000\000\000\000\000\000\000\000\213\002\000\000\213\002\213\002\ +\025\003\010\000\000\000\000\000\025\003\000\000\000\000\013\000\ +\025\003\000\000\000\000\000\000\000\000\025\003\000\000\000\000\ +\025\003\025\003\213\002\000\000\213\002\213\002\000\000\213\002\ +\213\002\017\000\018\000\213\002\000\000\000\000\000\000\000\000\ +\213\002\213\002\000\000\000\000\000\000\000\000\000\000\213\002\ +\000\000\000\000\000\000\000\000\000\000\024\000\000\000\162\000\ +\163\000\000\000\164\000\165\000\213\002\000\000\030\000\000\000\ +\000\000\000\000\000\000\166\000\167\000\000\000\194\002\000\000\ +\000\000\213\002\168\000\000\000\194\002\213\002\000\000\000\000\ +\000\000\000\000\213\002\000\000\000\000\213\002\213\002\169\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\194\002\194\002\ +\000\000\023\003\000\000\000\000\170\000\000\000\000\000\023\003\ +\047\000\000\000\000\000\000\000\000\000\048\000\000\000\000\000\ +\051\000\171\000\194\002\000\000\194\002\194\002\000\000\194\002\ +\194\002\023\003\023\003\194\002\000\000\000\000\000\000\000\000\ +\194\002\194\002\000\000\000\000\000\000\000\000\000\000\194\002\ +\000\000\000\000\000\000\000\000\000\000\023\003\000\000\023\003\ +\023\003\000\000\023\003\023\003\194\002\000\000\023\003\000\000\ +\000\000\000\000\000\000\023\003\023\003\000\000\010\000\000\000\ +\000\000\194\002\023\003\000\000\013\000\194\002\000\000\000\000\ +\000\000\000\000\194\002\000\000\000\000\194\002\194\002\023\003\ +\000\000\000\000\000\000\000\000\000\000\000\000\017\000\018\000\ +\000\000\025\003\000\000\000\000\023\003\000\000\000\000\025\003\ +\023\003\000\000\000\000\000\000\000\000\023\003\000\000\000\000\ +\023\003\023\003\024\000\000\000\000\000\163\000\000\000\164\000\ +\165\000\025\003\025\003\030\000\000\000\000\000\000\000\000\000\ +\166\000\167\000\000\000\000\000\000\000\000\000\000\000\168\000\ +\000\000\000\000\000\000\000\000\000\000\025\003\000\000\000\000\ +\025\003\000\000\025\003\025\003\169\000\000\000\025\003\000\000\ +\000\000\000\000\000\000\025\003\025\003\000\000\000\000\000\000\ +\000\000\170\000\025\003\000\000\000\000\047\000\010\000\011\000\ +\000\000\000\000\048\000\012\000\013\000\051\000\171\000\025\003\ +\000\000\000\000\000\000\000\000\000\000\000\000\115\001\000\000\ +\000\000\000\000\000\000\000\000\025\003\000\000\017\000\018\000\ +\025\003\000\000\000\000\000\000\000\000\025\003\000\000\000\000\ +\025\003\025\003\000\000\000\000\000\000\000\000\000\000\116\001\ +\000\000\000\000\024\000\117\001\000\000\026\000\027\000\028\000\ +\029\000\000\000\000\000\030\000\000\000\000\000\000\000\000\000\ +\166\000\034\000\010\000\011\000\000\000\000\000\000\000\012\000\ +\013\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\ +\000\000\118\001\000\000\000\000\000\000\000\000\000\000\045\000\ +\000\000\119\001\017\000\018\000\000\000\000\000\000\000\000\000\ +\000\000\120\001\121\001\000\000\000\000\047\000\000\000\000\000\ +\122\001\000\000\048\000\000\000\000\000\051\000\024\000\117\001\ +\000\000\026\000\027\000\028\000\029\000\000\000\000\000\030\000\ +\000\000\000\000\000\000\000\000\166\000\034\000\010\000\011\000\ +\000\000\000\000\000\000\012\000\013\000\025\003\025\003\000\000\ +\040\000\000\000\025\003\025\003\000\000\118\001\000\000\000\000\ +\000\000\000\000\000\000\045\000\000\000\119\001\017\000\018\000\ +\000\000\000\000\000\000\000\000\000\000\025\003\025\003\000\000\ +\000\000\047\000\000\000\000\000\122\001\000\000\048\000\000\000\ +\000\000\051\000\024\000\000\000\000\000\026\000\027\000\028\000\ +\029\000\025\003\000\000\030\000\025\003\025\003\025\003\025\003\ +\207\000\034\000\025\003\000\000\000\000\000\000\059\005\025\003\ +\025\003\000\000\000\000\000\000\040\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\025\003\000\000\060\005\000\000\045\000\ +\000\000\000\000\000\000\000\000\243\001\000\000\025\003\000\000\ +\000\000\000\000\000\000\000\000\000\000\047\000\000\000\000\000\ +\000\000\000\000\048\000\000\000\025\003\051\000\000\000\000\000\ +\000\000\025\003\000\000\000\000\025\003\061\005\000\000\137\000\ +\138\000\030\000\000\000\139\000\000\000\000\000\140\000\062\005\ +\000\000\000\000\000\000\032\005\078\001\079\001\000\000\000\000\ +\000\000\000\000\000\000\000\000\080\001\000\000\000\000\142\000\ +\000\000\033\005\081\001\082\001\034\005\083\001\063\005\143\000\ +\144\000\000\000\000\000\000\000\000\000\000\000\084\001\145\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\085\001\ +\246\001\000\000\000\000\064\005\147\000\086\001\087\001\088\001\ +\089\001\090\001\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\091\001\000\000\000\000\000\000\000\000\186\000\000\000\000\000\ +\000\000\000\000\092\001\093\001\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\094\001\095\001\096\001\ +\097\001\098\001\000\000\026\001\027\001\028\001\000\000\000\000\ +\000\000\035\005\207\001\000\000\030\001\000\000\000\000\100\001\ +\000\000\000\000\023\003\032\001\023\003\023\003\023\003\000\000\ +\023\003\000\000\000\000\023\003\023\003\000\000\033\001\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\034\001\ +\000\000\000\000\000\000\000\000\023\003\035\001\036\001\037\001\ +\038\001\039\001\040\001\000\000\023\003\023\003\000\000\000\000\ +\000\000\000\000\000\000\000\000\023\003\000\000\000\000\000\000\ +\041\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\023\003\023\003\234\002\209\001\000\000\235\002\000\000\000\000\ +\000\000\000\000\041\004\078\001\079\001\045\001\046\001\236\002\ +\212\001\049\001\213\001\080\001\000\000\000\000\000\000\000\000\ +\000\000\081\001\082\001\000\000\083\001\052\001\000\000\053\001\ +\000\000\000\000\000\000\000\000\000\000\084\001\000\000\000\000\ +\000\000\000\000\043\004\078\001\079\001\000\000\085\001\000\000\ +\000\000\000\000\000\000\080\001\086\001\087\001\088\001\089\001\ +\090\001\081\001\082\001\000\000\083\001\000\000\000\000\000\000\ +\043\002\000\000\043\002\043\002\043\002\084\001\043\002\091\001\ +\000\000\043\002\043\002\000\000\186\000\000\000\085\001\000\000\ +\000\000\092\001\093\001\000\000\086\001\087\001\088\001\089\001\ +\090\001\000\000\043\002\000\000\094\001\095\001\096\001\097\001\ +\098\001\000\000\043\002\043\002\000\000\042\004\000\000\091\001\ +\000\000\000\000\043\002\000\000\186\000\000\000\100\001\000\000\ +\000\000\092\001\093\001\000\000\000\000\000\000\043\002\043\002\ +\045\004\078\001\079\001\000\000\094\001\095\001\096\001\097\001\ +\098\001\080\001\000\000\000\000\000\000\000\000\044\004\081\001\ +\082\001\000\000\083\001\000\000\000\000\000\000\100\001\000\000\ +\000\000\000\000\000\000\084\001\000\000\000\000\000\000\000\000\ +\041\004\078\001\079\001\000\000\085\001\000\000\000\000\000\000\ +\000\000\080\001\086\001\087\001\088\001\089\001\090\001\081\001\ +\082\001\000\000\083\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\084\001\000\000\091\001\000\000\000\000\ +\000\000\000\000\186\000\000\000\085\001\000\000\000\000\092\001\ +\093\001\000\000\086\001\087\001\088\001\089\001\090\001\000\000\ +\000\000\000\000\094\001\095\001\096\001\097\001\098\001\000\000\ +\000\000\000\000\000\000\000\000\000\000\091\001\046\004\000\000\ +\000\000\000\000\186\000\000\000\100\001\000\000\000\000\092\001\ +\093\001\000\000\000\000\000\000\000\000\000\000\043\004\078\001\ +\079\001\000\000\094\001\095\001\096\001\097\001\098\001\080\001\ +\000\000\000\000\000\000\099\004\000\000\081\001\082\001\000\000\ +\083\001\000\000\000\000\000\000\100\001\000\000\000\000\000\000\ +\000\000\084\001\000\000\000\000\000\000\000\000\045\004\078\001\ +\079\001\000\000\085\001\000\000\000\000\000\000\000\000\080\001\ +\086\001\087\001\088\001\089\001\090\001\081\001\082\001\000\000\ +\083\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\084\001\000\000\091\001\000\000\000\000\000\000\000\000\ +\186\000\000\000\085\001\000\000\000\000\092\001\093\001\000\000\ +\086\001\087\001\088\001\089\001\090\001\000\000\000\000\000\000\ +\094\001\095\001\096\001\097\001\098\001\000\000\000\000\000\000\ +\000\000\000\000\100\004\091\001\000\000\000\000\000\000\000\000\ +\186\000\000\000\100\001\000\000\000\000\092\001\093\001\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\094\001\095\001\096\001\097\001\098\001\081\005\078\001\079\001\ +\000\000\000\000\000\000\000\000\101\004\000\000\080\001\000\000\ +\000\000\000\000\100\001\000\000\081\001\082\001\000\000\083\001\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\084\001\000\000\000\000\000\000\000\000\083\005\078\001\079\001\ +\000\000\085\001\000\000\000\000\000\000\000\000\080\001\086\001\ +\087\001\088\001\089\001\090\001\081\001\082\001\000\000\083\001\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\084\001\000\000\091\001\000\000\000\000\000\000\000\000\186\000\ +\000\000\085\001\000\000\000\000\092\001\093\001\000\000\086\001\ +\087\001\088\001\089\001\090\001\000\000\000\000\000\000\094\001\ +\095\001\096\001\097\001\098\001\000\000\000\000\000\000\000\000\ +\082\005\000\000\091\001\000\000\000\000\000\000\000\000\186\000\ +\000\000\100\001\000\000\000\000\092\001\093\001\000\000\000\000\ +\000\000\000\000\000\000\085\005\078\001\079\001\000\000\094\001\ +\095\001\096\001\097\001\098\001\080\001\000\000\000\000\000\000\ +\000\000\084\005\081\001\082\001\000\000\083\001\000\000\000\000\ +\000\000\100\001\000\000\000\000\000\000\000\000\084\001\000\000\ +\000\000\000\000\000\000\081\005\078\001\079\001\000\000\085\001\ +\000\000\000\000\000\000\000\000\080\001\086\001\087\001\088\001\ +\089\001\090\001\081\001\082\001\000\000\083\001\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\084\001\000\000\ +\091\001\000\000\000\000\000\000\000\000\186\000\000\000\085\001\ +\000\000\000\000\092\001\093\001\000\000\086\001\087\001\088\001\ +\089\001\090\001\000\000\000\000\000\000\094\001\095\001\096\001\ +\097\001\098\001\000\000\000\000\000\000\000\000\000\000\000\000\ +\091\001\086\005\000\000\000\000\000\000\186\000\000\000\100\001\ +\000\000\000\000\092\001\093\001\000\000\000\000\000\000\000\000\ +\000\000\083\005\078\001\079\001\000\000\094\001\095\001\096\001\ +\097\001\098\001\080\001\000\000\000\000\000\000\106\005\000\000\ +\081\001\082\001\000\000\083\001\000\000\000\000\000\000\100\001\ +\000\000\000\000\000\000\000\000\084\001\000\000\000\000\000\000\ +\000\000\085\005\078\001\079\001\000\000\085\001\000\000\000\000\ +\000\000\000\000\080\001\086\001\087\001\088\001\089\001\090\001\ +\081\001\082\001\000\000\083\001\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\084\001\000\000\091\001\000\000\ +\000\000\000\000\000\000\186\000\000\000\085\001\000\000\000\000\ +\092\001\093\001\000\000\086\001\087\001\088\001\089\001\090\001\ +\000\000\000\000\000\000\094\001\095\001\096\001\097\001\098\001\ +\000\000\000\000\000\000\000\000\000\000\107\005\091\001\078\001\ +\079\001\000\000\000\000\186\000\000\000\100\001\000\000\080\001\ +\092\001\093\001\000\000\000\000\000\000\081\001\082\001\000\000\ +\083\001\000\000\000\000\094\001\095\001\096\001\097\001\098\001\ +\000\000\084\001\000\000\000\000\000\000\000\000\000\000\108\005\ +\000\000\000\000\085\001\000\000\000\000\100\001\000\000\000\000\ +\086\001\087\001\088\001\089\001\090\001\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\091\001\078\001\079\001\000\000\000\000\ +\186\000\000\000\000\000\000\000\080\001\092\001\093\001\000\000\ +\000\000\000\000\081\001\082\001\000\000\083\001\000\000\000\000\ +\094\001\095\001\096\001\097\001\098\001\000\000\084\001\000\000\ +\000\000\000\000\000\000\000\000\000\000\099\001\000\000\085\001\ +\000\000\000\000\100\001\000\000\000\000\086\001\087\001\088\001\ +\089\001\090\001\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\091\001\078\001\079\001\000\000\000\000\186\000\000\000\000\000\ +\000\000\080\001\092\001\093\001\000\000\000\000\000\000\081\001\ +\082\001\000\000\083\001\000\000\000\000\094\001\095\001\096\001\ +\097\001\098\001\000\000\084\001\000\000\000\000\031\004\000\000\ +\000\000\078\001\079\001\000\000\085\001\000\000\000\000\100\001\ +\000\000\080\001\086\001\087\001\088\001\089\001\090\001\081\001\ +\082\001\000\000\083\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\138\004\000\000\084\001\000\000\091\001\000\000\000\000\ +\000\000\000\000\186\000\000\000\085\001\000\000\000\000\092\001\ +\093\001\000\000\086\001\087\001\088\001\089\001\090\001\000\000\ +\000\000\000\000\094\001\095\001\096\001\097\001\098\001\000\000\ +\000\000\000\000\000\000\093\004\000\000\091\001\078\001\079\001\ +\000\000\000\000\186\000\000\000\100\001\000\000\080\001\092\001\ +\093\001\000\000\000\000\000\000\081\001\082\001\000\000\083\001\ +\000\000\000\000\094\001\095\001\096\001\097\001\098\001\000\000\ +\084\001\000\000\000\000\000\000\000\000\000\000\240\000\240\000\ +\000\000\085\001\000\000\000\000\100\001\000\000\240\000\086\001\ +\087\001\088\001\089\001\090\001\240\000\240\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\240\000\000\000\091\001\000\000\000\000\000\000\000\000\186\000\ +\000\000\240\000\000\000\000\000\092\001\093\001\000\000\240\000\ +\240\000\240\000\240\000\240\000\000\000\000\000\000\000\094\001\ +\095\001\096\001\097\001\098\001\000\000\000\000\000\000\000\000\ +\000\000\000\000\240\000\078\001\079\001\000\000\000\000\240\000\ +\000\000\100\001\000\000\080\001\240\000\240\000\000\000\000\000\ +\000\000\081\001\000\000\000\000\000\000\000\000\000\000\240\000\ +\240\000\240\000\240\000\240\000\000\000\084\001\000\000\000\000\ +\240\000\000\000\000\000\078\001\079\001\000\000\085\001\000\000\ +\000\000\240\000\000\000\000\000\086\001\087\001\088\001\089\001\ +\090\001\081\001\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\084\001\000\000\091\001\ +\000\000\000\000\000\000\000\000\186\000\000\000\085\001\000\000\ +\000\000\092\001\093\001\000\000\086\001\087\001\088\001\089\001\ +\090\001\094\000\000\000\000\000\094\001\095\001\096\001\097\001\ +\098\001\000\000\000\000\000\000\000\000\000\000\000\000\091\001\ +\095\000\016\000\000\000\000\000\186\000\000\000\100\001\000\000\ +\000\000\092\001\093\001\000\000\000\000\096\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\095\001\096\001\097\001\ +\098\001\000\000\000\000\136\000\000\000\137\000\138\000\030\000\ +\031\000\139\000\000\000\000\000\140\000\141\000\100\001\000\000\ +\035\000\000\000\000\000\000\000\000\000\000\000\097\000\000\000\ +\000\000\000\000\000\000\000\000\042\000\142\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\143\000\144\000\000\000\ +\000\000\000\000\000\000\000\000\098\000\145\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\099\000\146\000\147\000\053\000" -(* Insertion of bindings by identifier *) +let yycheck = "\009\000\ +\210\000\145\000\012\000\002\000\014\000\015\000\016\000\136\000\ +\199\000\019\000\020\000\021\000\022\000\023\000\002\000\025\000\ +\163\000\132\001\142\000\205\000\136\000\163\002\032\000\202\000\ +\002\000\123\001\036\000\002\000\202\000\039\000\040\000\041\000\ +\011\000\001\000\034\003\002\000\010\000\024\001\010\002\049\000\ +\050\000\027\000\136\000\053\000\054\000\139\000\002\000\026\000\ +\002\000\138\000\002\000\234\003\163\002\002\000\038\003\253\002\ +\098\000\157\000\221\000\029\000\223\000\105\002\003\000\004\000\ +\186\003\225\002\045\000\063\004\110\000\000\000\170\000\115\004\ +\194\003\063\003\003\000\004\000\031\000\006\000\046\000\241\004\ +\035\000\056\005\201\004\063\005\094\000\095\000\096\000\097\000\ +\131\000\099\000\133\000\003\000\008\001\001\000\134\001\003\000\ +\004\000\141\002\000\000\098\000\054\001\003\003\021\001\000\001\ +\083\000\034\000\085\000\086\000\058\000\110\002\098\000\110\000\ +\067\005\214\004\203\000\000\000\000\001\003\005\000\001\042\002\ +\098\000\127\002\110\000\098\000\017\001\240\001\010\001\164\001\ +\000\001\166\001\005\000\098\000\110\000\074\001\192\004\110\000\ +\000\001\056\001\046\000\149\000\007\001\110\004\098\000\110\000\ +\098\000\000\001\098\000\121\000\000\001\098\000\058\000\161\000\ +\162\000\139\000\110\000\000\001\110\000\008\001\110\000\000\000\ +\087\004\110\000\244\004\173\000\014\001\000\001\052\005\108\001\ +\226\004\000\001\144\000\077\005\060\001\066\001\000\000\001\005\ +\092\001\006\001\188\000\030\001\103\002\008\001\157\005\000\001\ +\066\001\004\001\127\000\197\000\129\000\008\001\131\000\073\001\ +\133\000\000\001\066\001\092\001\015\001\099\003\133\001\018\001\ +\129\000\000\000\066\001\030\001\055\001\000\001\037\001\162\005\ +\092\001\073\001\189\000\095\001\094\001\214\002\065\001\008\001\ +\000\001\129\000\224\002\127\000\014\001\129\000\094\001\131\000\ +\115\001\133\000\000\001\206\000\055\001\079\001\094\001\186\000\ +\187\000\115\001\203\004\121\005\091\001\030\001\065\001\091\001\ +\095\001\000\001\036\001\027\001\130\005\000\001\091\001\066\001\ +\107\002\108\002\095\001\115\001\054\005\027\001\073\001\106\001\ +\101\005\237\005\109\001\094\001\008\001\000\001\055\001\092\001\ +\095\001\017\001\121\003\196\000\022\001\023\001\064\001\000\000\ +\065\001\000\001\197\001\204\000\027\001\094\001\123\005\106\001\ +\027\001\008\001\109\001\109\005\143\002\151\004\022\001\094\001\ +\154\004\005\003\044\001\000\001\000\001\055\001\113\001\067\001\ +\091\001\204\001\037\001\206\001\202\003\095\001\064\001\097\001\ +\058\001\193\001\029\001\091\001\176\001\063\001\094\001\095\001\ +\231\001\106\001\000\001\109\001\109\001\091\001\027\001\157\001\ +\074\001\095\001\000\001\000\001\192\001\022\001\164\001\050\001\ +\166\001\252\001\046\003\217\003\091\001\010\001\001\002\173\001\ +\174\001\087\003\088\003\094\001\027\001\040\006\094\001\094\001\ +\092\001\236\001\130\002\094\001\102\001\027\001\188\001\105\001\ +\154\005\107\001\000\001\109\001\095\001\111\001\094\001\038\002\ +\205\005\163\005\033\005\034\005\151\001\115\003\153\001\019\001\ +\155\001\021\001\215\005\000\001\071\001\000\000\048\002\008\001\ +\164\005\000\001\072\001\160\002\026\001\024\001\091\001\091\001\ +\057\001\015\006\095\001\141\001\107\006\143\001\120\001\066\001\ +\255\005\066\001\117\001\118\001\069\001\026\001\121\001\000\001\ +\123\001\000\001\048\004\074\005\056\001\159\001\069\002\094\001\ +\094\001\010\001\015\001\000\001\035\001\091\001\000\001\092\001\ +\094\001\095\001\095\001\008\006\072\001\000\001\000\001\177\001\ +\178\001\014\001\099\001\000\001\017\001\000\001\103\001\081\006\ +\099\005\083\006\004\001\014\001\059\001\000\001\008\001\125\004\ +\000\001\064\001\065\001\173\001\174\001\015\001\092\001\000\001\ +\018\001\203\001\190\005\074\001\000\001\003\001\188\004\103\004\ +\210\001\000\001\088\006\092\001\214\001\004\001\105\001\092\001\ +\027\001\008\001\151\001\010\001\153\001\058\006\155\001\014\001\ +\000\001\227\001\228\001\018\001\099\001\076\004\232\001\027\001\ +\234\001\008\001\010\001\000\001\027\001\000\001\109\001\066\001\ +\062\001\094\001\000\001\092\001\091\001\000\001\095\001\007\000\ +\066\001\251\001\000\001\151\001\000\001\153\001\032\002\155\001\ +\171\005\094\001\004\001\039\006\094\001\007\002\008\001\009\002\ +\010\002\000\001\000\001\094\001\094\001\015\001\091\001\000\001\ +\018\001\092\001\095\001\055\004\052\003\241\003\193\005\000\001\ +\091\001\000\001\073\001\004\001\095\001\035\001\094\001\008\001\ +\017\001\010\001\018\001\092\001\004\001\014\001\040\002\091\001\ +\000\001\032\002\094\001\095\001\091\001\092\001\221\005\094\001\ +\095\001\027\002\027\001\190\002\032\002\059\001\014\001\000\001\ +\172\002\173\002\064\001\065\001\092\001\092\001\032\002\095\001\ +\066\001\032\002\113\001\000\001\074\001\000\001\091\001\103\003\ +\091\001\032\002\160\002\231\001\095\001\109\003\070\005\171\002\ +\094\001\002\001\253\002\094\001\032\002\003\001\032\002\091\001\ +\032\002\036\002\056\002\032\002\038\003\099\001\028\005\073\002\ +\073\001\000\001\066\001\022\001\091\001\072\002\000\001\109\001\ +\094\001\065\001\066\001\010\001\014\001\094\001\094\001\113\001\ +\074\002\075\002\091\001\092\001\151\002\094\001\095\001\094\001\ +\003\001\018\001\042\002\038\003\047\001\000\001\229\004\129\002\ +\038\003\004\001\132\002\053\003\134\002\008\001\094\001\010\001\ +\113\001\004\001\000\001\014\001\022\001\027\001\008\001\018\001\ +\230\002\066\001\232\002\092\001\164\000\165\000\017\002\018\002\ +\027\001\100\002\018\001\076\002\064\001\107\004\000\001\092\001\ +\014\001\177\000\178\000\094\001\250\002\032\002\015\001\159\005\ +\008\001\069\002\036\001\022\001\018\001\205\003\097\001\098\001\ +\018\001\076\003\170\005\078\003\066\001\183\002\090\001\103\002\ +\019\001\201\000\003\001\073\001\094\001\092\001\111\002\112\002\ +\115\001\019\001\092\001\092\001\036\001\094\001\073\001\201\002\ +\192\005\203\002\110\001\205\002\066\001\237\003\073\001\209\002\ +\090\001\008\001\068\006\065\001\066\001\048\001\180\002\018\001\ +\091\001\092\001\151\002\094\001\095\001\083\001\048\001\049\001\ +\049\003\060\001\092\001\018\001\092\001\115\001\066\003\233\002\ +\018\001\068\001\060\001\070\001\200\004\062\003\113\001\090\001\ +\094\001\027\002\068\001\018\001\070\001\094\001\092\001\146\003\ +\094\001\022\001\242\005\151\002\092\001\255\002\134\003\133\005\ +\232\005\172\003\004\003\005\003\000\000\012\001\172\003\008\001\ +\214\004\001\006\118\003\022\001\067\001\015\003\130\003\017\003\ +\251\003\036\001\253\003\254\003\111\001\113\003\000\001\027\001\ +\031\001\022\001\028\003\029\003\060\004\111\001\133\005\073\002\ +\118\003\092\001\088\001\067\004\065\001\039\003\215\002\216\002\ +\000\001\019\001\248\004\050\001\046\003\092\001\006\003\170\002\ +\026\001\220\003\047\001\027\001\094\001\139\003\220\003\057\003\ +\000\000\015\001\112\001\022\001\030\001\238\002\066\001\186\002\ +\071\001\094\001\067\001\031\005\102\003\060\003\048\001\049\001\ +\022\001\196\002\000\001\252\002\095\001\084\001\080\003\090\001\ +\060\003\065\001\060\001\047\005\187\005\055\001\189\005\065\001\ +\014\001\019\001\068\001\017\001\070\001\000\001\101\001\065\001\ +\022\001\047\001\100\003\014\001\022\004\027\001\065\001\014\001\ +\064\001\065\001\006\003\014\001\066\001\000\001\017\001\102\003\ +\027\001\004\001\237\002\022\001\027\001\008\001\094\001\014\001\ +\027\001\047\001\102\003\014\001\015\001\109\001\128\003\018\001\ +\092\005\131\003\004\001\133\003\102\003\111\001\008\001\102\003\ +\106\001\067\001\003\001\109\001\047\001\107\003\144\003\102\003\ +\018\001\177\004\148\003\097\001\098\001\070\003\064\001\101\005\ +\066\001\155\003\102\003\027\001\102\003\159\003\102\003\000\001\ +\126\003\102\003\083\003\015\001\079\001\091\001\018\001\117\005\ +\079\001\095\001\065\001\097\001\098\001\123\005\088\001\066\001\ +\066\006\067\006\047\001\181\003\196\001\064\001\184\003\215\004\ +\091\001\035\001\188\003\003\001\095\001\115\001\097\001\098\001\ +\066\001\225\004\066\001\110\004\064\001\065\001\112\001\073\001\ +\110\004\000\001\069\003\094\001\022\001\221\001\222\001\223\001\ +\115\001\059\001\125\004\213\003\022\001\229\001\066\001\065\001\ +\030\001\139\004\092\001\022\001\019\001\004\001\082\004\064\001\ +\065\001\008\001\109\001\026\001\097\001\098\001\014\001\014\001\ +\015\001\090\001\124\006\018\001\066\001\067\001\240\003\241\003\ +\096\001\055\001\110\001\073\001\000\001\005\002\115\001\065\001\ +\250\003\048\001\252\003\065\001\102\001\110\001\176\004\205\005\ +\206\005\067\001\022\001\109\001\000\001\060\001\065\001\096\001\ +\004\001\215\005\012\004\014\001\008\001\068\001\010\001\070\001\ +\035\001\033\002\014\001\015\001\197\003\198\003\018\001\035\001\ +\027\001\065\001\066\001\066\001\027\001\115\001\116\004\027\001\ +\203\004\035\001\211\003\212\003\106\001\203\004\216\004\109\001\ +\059\001\218\003\132\005\009\004\060\002\065\001\065\001\059\001\ +\000\001\051\004\227\003\053\004\064\001\065\001\000\001\094\001\ +\111\001\059\001\008\006\061\004\000\001\091\001\074\001\065\001\ +\004\001\095\001\030\001\066\001\008\001\071\004\066\001\000\000\ +\066\001\019\001\026\001\015\001\079\001\073\001\018\001\073\001\ +\026\001\220\004\084\004\102\001\055\001\000\001\209\003\099\001\ +\064\001\065\001\109\001\055\001\094\001\064\001\217\003\091\001\ +\092\001\109\001\094\001\095\001\102\001\065\001\048\001\049\001\ +\064\001\014\001\229\003\109\001\058\006\111\001\005\000\077\004\ +\007\000\028\005\060\001\075\001\008\001\113\001\027\001\065\001\ +\035\001\115\001\068\001\244\004\070\001\248\003\066\001\000\001\ +\031\001\064\001\027\001\023\001\059\005\109\001\112\004\035\003\ +\244\004\116\005\030\001\105\004\142\004\112\001\106\001\145\004\ +\059\001\109\001\073\005\050\001\127\005\064\001\065\001\051\003\ +\112\001\026\001\094\001\055\003\065\001\000\001\244\004\074\001\ +\162\004\053\001\164\004\055\001\166\004\111\001\168\004\169\004\ +\064\001\066\001\055\001\173\004\099\005\065\001\109\001\191\002\ +\178\004\008\001\180\004\064\001\182\004\004\001\184\004\026\001\ +\099\001\008\001\086\003\064\001\065\001\004\001\206\002\207\002\ +\023\001\008\001\109\001\018\001\061\005\022\001\200\004\030\001\ +\015\001\097\001\123\004\018\001\027\001\064\001\127\004\066\001\ +\108\004\061\005\125\005\132\004\027\001\109\001\106\001\125\005\ +\075\001\109\001\014\001\066\001\222\004\017\001\053\001\014\001\ +\055\001\227\004\242\002\112\001\149\004\150\004\145\005\061\005\ +\030\001\235\004\065\001\145\005\053\001\158\004\055\001\056\001\ +\065\001\136\000\169\005\066\001\139\000\247\004\141\000\142\000\ +\065\001\027\001\252\004\066\001\050\001\112\001\000\005\106\006\ +\002\005\066\001\004\005\126\004\181\004\007\005\109\001\130\004\ +\191\005\000\001\064\001\065\001\000\001\164\000\165\000\008\001\ +\167\000\065\001\083\001\106\001\022\005\064\001\109\001\064\001\ +\026\005\073\001\177\000\178\000\019\001\031\005\004\001\019\001\ +\066\001\235\005\008\001\026\001\109\001\008\005\026\001\210\005\ +\035\001\015\001\027\001\108\001\210\005\047\005\048\005\101\001\ +\050\005\028\001\201\000\202\000\106\001\027\001\205\000\109\001\ +\179\004\048\001\049\001\088\001\048\001\232\005\014\001\065\005\ +\059\001\066\001\232\005\190\004\109\001\060\001\065\001\000\001\ +\060\001\100\001\003\001\027\001\212\005\068\001\000\000\070\001\ +\068\001\066\001\070\001\112\001\013\001\014\001\027\001\066\001\ +\017\001\091\005\092\005\027\001\066\001\094\001\022\001\074\001\ +\098\005\026\001\027\001\028\001\029\001\080\001\000\001\003\005\ +\083\001\045\001\046\001\102\001\029\005\064\001\112\005\040\001\ +\041\001\065\001\109\001\066\001\111\001\035\001\003\001\047\001\ +\111\001\019\001\043\005\111\001\045\005\066\001\128\005\037\001\ +\026\001\145\003\066\001\060\001\083\001\088\001\063\001\022\001\ +\065\001\066\001\067\001\068\001\064\001\059\001\144\005\083\001\ +\073\001\074\001\064\001\065\001\064\001\151\005\048\001\080\001\ +\052\005\000\001\064\001\040\001\074\001\112\001\109\001\161\005\ +\100\001\132\005\060\001\092\001\166\005\094\001\000\001\096\001\ +\097\001\067\001\068\001\236\003\070\001\035\001\041\005\000\001\ +\066\001\155\005\180\005\108\001\158\005\099\001\111\001\199\003\ +\023\001\109\001\115\001\018\001\064\001\066\001\037\001\109\001\ +\026\001\109\001\019\001\004\004\063\005\059\001\200\005\075\001\ +\000\001\026\001\064\001\065\001\094\001\207\005\064\001\000\001\ +\224\003\225\003\226\003\213\005\074\001\111\001\230\003\136\005\ +\218\005\219\005\000\001\019\001\236\003\121\005\224\005\048\001\ +\049\001\227\005\026\001\027\001\010\001\053\001\130\005\055\001\ +\000\000\026\001\236\005\060\001\112\001\099\001\240\005\134\001\ +\064\001\065\001\244\005\068\001\004\004\070\001\064\001\109\001\ +\048\001\049\001\004\001\109\001\230\005\231\005\008\001\233\005\ +\234\005\022\001\000\001\003\001\060\001\015\001\157\001\009\006\ +\018\001\064\001\112\001\067\001\068\001\164\001\070\001\166\001\ +\090\001\027\001\064\001\040\001\143\005\012\006\173\001\174\001\ +\064\001\176\001\149\005\064\001\065\001\109\001\111\001\022\001\ +\012\006\000\001\071\001\109\001\110\001\188\001\035\001\037\001\ +\040\001\192\001\044\006\045\006\167\005\196\001\197\001\084\001\ +\225\005\051\006\052\006\053\006\054\006\090\001\109\001\111\001\ +\066\001\059\006\033\001\026\001\075\001\063\006\059\001\109\001\ +\110\001\022\001\016\001\069\006\065\001\109\001\221\001\222\001\ +\223\001\110\001\000\000\077\006\078\006\027\001\229\001\202\005\ +\055\001\004\001\037\001\040\001\059\001\008\001\064\001\095\001\ +\063\001\064\001\065\001\066\001\015\001\095\006\096\006\018\001\ +\076\000\112\001\100\006\064\001\102\006\252\001\253\001\078\001\ +\025\006\102\001\001\002\085\006\110\006\064\001\005\002\113\006\ +\109\001\008\002\035\006\015\006\064\001\022\001\053\001\097\001\ +\055\001\123\006\017\002\018\002\064\001\127\006\027\001\105\006\ +\108\000\064\001\065\001\109\001\134\006\135\006\109\001\040\001\ +\033\001\032\002\033\002\064\001\064\001\119\006\120\006\066\001\ +\109\001\125\000\000\000\042\002\095\001\000\001\064\001\065\001\ +\132\000\048\002\075\006\000\001\064\001\071\001\055\001\095\001\ +\066\001\109\001\059\001\013\001\031\006\060\002\063\001\064\001\ +\065\001\109\001\084\001\000\001\093\006\066\001\109\001\042\006\ +\090\001\083\001\028\001\029\001\073\001\078\001\064\001\091\001\ +\109\001\109\001\037\001\016\002\088\006\022\001\019\001\041\001\ +\037\001\075\001\023\002\109\001\110\001\026\001\027\001\066\006\ +\067\006\094\001\108\001\066\001\000\000\072\006\073\006\128\006\ +\103\002\091\001\060\001\000\001\109\001\063\001\047\001\082\006\ +\079\001\040\001\068\001\048\001\049\001\022\001\115\001\000\001\ +\074\001\055\001\000\001\094\006\066\001\059\001\080\001\060\001\ +\000\001\063\001\064\001\130\002\004\001\026\001\067\001\068\001\ +\008\001\070\001\010\001\066\001\111\006\083\001\014\001\015\001\ +\078\001\026\001\018\001\094\001\026\001\000\000\121\006\094\001\ +\090\001\124\006\108\001\027\001\000\001\111\001\093\001\130\006\ +\131\006\160\002\109\001\110\001\163\002\053\001\054\001\055\001\ +\056\001\031\001\169\002\170\002\110\001\172\002\173\002\109\001\ +\064\001\065\001\111\001\000\001\093\001\055\001\026\001\000\001\ +\033\001\059\001\066\001\186\002\050\001\063\001\064\001\077\001\ +\191\002\010\001\066\001\004\001\109\001\196\002\019\001\008\001\ +\080\001\073\001\094\001\083\001\078\001\026\001\055\001\206\002\ +\207\002\018\001\059\001\071\001\064\001\065\001\063\001\064\001\ +\065\001\109\001\027\001\091\001\092\001\109\001\094\001\095\001\ +\084\001\065\001\000\001\048\001\049\001\078\001\004\001\230\002\ +\093\001\232\002\008\001\109\001\010\001\003\001\237\002\060\001\ +\014\001\113\001\093\001\242\002\018\001\073\001\067\001\068\001\ +\109\001\070\001\064\001\250\002\251\002\027\001\253\002\000\000\ +\009\000\065\001\109\001\012\000\109\001\014\000\015\000\016\000\ +\007\003\073\001\019\000\020\000\021\000\022\000\023\000\004\001\ +\025\000\064\001\065\001\008\001\014\001\065\001\066\001\017\001\ +\004\001\014\001\015\001\036\000\008\001\018\001\039\000\040\000\ +\041\000\027\001\111\001\064\001\066\001\092\001\018\001\038\003\ +\049\000\050\000\000\001\073\001\053\000\054\000\004\001\027\001\ +\066\001\008\001\008\001\014\001\010\001\052\003\053\003\073\001\ +\014\001\015\001\095\001\004\001\065\001\091\001\092\001\008\001\ +\094\001\095\001\071\001\016\001\152\001\027\001\069\003\000\001\ +\036\001\022\001\000\000\000\001\094\001\066\001\027\001\084\001\ +\073\001\010\001\027\001\113\001\014\001\094\000\095\000\096\000\ +\097\000\022\001\099\000\090\001\000\000\109\001\019\001\004\001\ +\014\001\115\001\022\001\008\001\000\001\026\001\000\001\003\001\ +\103\003\095\001\015\001\095\001\066\001\018\001\109\003\055\001\ +\010\001\013\001\092\001\073\001\103\001\017\001\027\001\118\003\ +\066\001\067\001\121\003\048\001\049\001\014\001\026\001\027\001\ +\028\001\029\001\022\001\130\003\027\001\091\001\092\001\060\001\ +\094\001\095\001\064\001\065\001\139\003\041\001\067\001\068\001\ +\092\001\070\001\145\003\173\001\174\001\000\001\092\001\091\001\ +\161\000\162\000\109\001\113\001\092\001\066\001\092\001\053\001\ +\060\001\055\001\013\001\063\001\255\001\000\002\017\001\067\001\ +\068\001\014\001\109\001\065\001\094\001\172\003\074\001\026\001\ +\027\001\028\001\029\001\094\001\080\001\053\001\010\002\055\001\ +\115\001\020\001\111\001\053\001\197\000\055\001\041\001\004\001\ +\092\001\065\001\094\001\008\001\096\001\097\001\109\001\065\001\ +\199\003\053\001\015\001\055\001\046\001\018\001\205\003\115\001\ +\108\001\060\001\209\003\111\001\063\001\065\001\062\001\066\001\ +\067\001\068\001\217\003\109\001\219\003\220\003\073\001\074\001\ +\108\001\224\003\225\003\226\003\109\001\080\001\229\003\230\003\ +\053\001\109\001\055\001\234\003\022\001\236\003\237\003\002\001\ +\073\001\092\001\100\001\094\001\065\001\096\001\097\001\013\001\ +\000\000\248\003\065\001\066\001\067\001\066\001\073\001\000\001\ +\027\001\108\001\003\001\109\001\111\001\004\004\028\001\029\001\ +\115\001\015\001\092\001\064\001\013\001\022\001\023\001\094\001\ +\017\001\000\001\064\001\041\001\064\001\022\001\008\001\022\004\ +\065\001\026\001\027\001\028\001\029\001\109\001\040\001\018\001\ +\014\001\062\001\062\001\044\001\062\001\007\000\060\001\027\001\ +\041\001\000\000\092\001\094\001\064\001\079\001\068\001\064\001\ +\014\001\058\001\134\002\014\001\074\001\006\001\063\001\094\001\ +\026\000\073\001\080\001\060\001\109\001\060\004\063\001\095\001\ +\065\001\066\001\067\001\068\001\067\004\064\001\075\001\073\001\ +\073\001\074\001\096\001\090\001\022\001\076\004\092\001\080\001\ +\027\001\094\001\014\001\082\004\073\001\040\001\108\001\013\001\ +\087\004\111\001\094\001\092\001\000\001\094\001\027\001\096\001\ +\097\001\014\001\027\001\021\001\008\001\086\001\028\001\029\001\ +\064\001\013\001\064\001\108\001\107\004\108\004\111\001\110\004\ +\062\001\062\001\115\001\041\001\014\001\116\004\026\001\062\001\ +\028\001\029\001\062\001\062\001\062\001\003\001\125\004\126\004\ +\014\001\086\001\064\001\130\004\027\001\041\001\060\001\091\001\ +\095\001\063\001\073\001\101\001\139\004\014\001\068\001\094\001\ +\027\001\027\001\094\001\014\001\074\001\094\001\000\000\088\001\ +\060\001\094\001\080\001\063\001\080\001\064\001\066\001\067\001\ +\068\001\027\001\073\001\014\001\020\001\015\001\074\001\022\001\ +\177\001\094\001\096\001\097\001\080\001\053\001\008\001\145\000\ +\065\001\176\004\177\004\073\001\179\004\062\001\108\001\062\001\ +\092\001\111\001\062\001\014\001\096\001\097\001\094\001\190\004\ +\112\001\163\000\164\000\165\000\112\001\167\000\094\001\073\001\ +\108\001\210\001\021\001\111\001\203\004\064\001\091\001\177\000\ +\178\000\037\003\073\001\053\001\054\001\055\001\056\001\214\004\ +\215\004\216\004\000\001\088\001\095\001\014\001\064\001\065\001\ +\094\001\014\001\225\004\014\001\056\003\014\001\229\004\201\000\ +\202\000\061\003\091\001\205\000\027\001\019\001\019\001\027\001\ +\112\001\088\001\241\004\022\001\026\001\244\004\014\001\014\001\ +\000\001\248\004\014\001\003\001\014\001\000\000\000\000\096\001\ +\084\003\096\001\001\005\092\001\003\005\013\001\008\001\109\001\ +\109\001\017\001\048\001\109\001\064\001\092\001\022\001\036\001\ +\090\001\036\001\026\001\027\001\028\001\029\001\060\001\036\001\ +\092\001\065\001\040\001\065\001\112\003\028\005\068\001\040\002\ +\070\001\041\001\033\005\034\005\064\001\094\001\036\001\064\001\ +\091\001\000\001\041\005\053\001\003\001\001\000\002\000\003\000\ +\004\000\005\000\006\000\007\000\060\001\052\005\013\001\063\001\ +\053\001\065\001\066\001\067\001\068\001\064\001\061\005\062\005\ +\063\005\073\001\074\001\026\001\064\001\028\001\029\001\064\001\ +\080\001\111\001\064\001\074\005\064\001\064\001\077\005\127\000\ +\099\003\040\001\041\001\210\005\092\001\000\000\094\001\008\005\ +\096\001\097\001\060\001\129\005\082\006\199\005\072\002\248\002\ +\190\003\145\001\145\005\183\003\108\001\060\001\101\005\111\001\ +\063\001\122\001\103\002\115\001\067\001\068\001\109\005\199\003\ +\230\001\165\000\190\002\074\001\064\001\065\001\117\005\018\005\ +\027\004\080\001\121\005\071\001\123\005\137\001\125\005\226\001\ +\103\004\077\001\232\002\130\005\188\001\092\001\133\005\133\005\ +\084\001\096\001\097\001\099\005\171\005\221\004\090\001\255\255\ +\143\005\115\001\145\005\255\255\255\255\108\001\149\005\255\255\ +\111\001\255\255\238\003\239\003\255\255\255\255\255\255\255\255\ +\255\255\109\001\110\001\013\001\255\255\255\255\255\255\255\255\ +\167\005\255\255\255\255\255\003\255\255\255\255\255\255\145\001\ +\255\255\255\255\028\001\029\001\255\255\255\255\255\255\255\255\ +\012\004\255\255\255\255\255\255\187\005\255\255\189\005\041\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\028\004\255\255\255\255\202\005\255\255\255\255\205\005\206\005\ +\255\255\000\001\060\001\210\005\255\255\063\001\255\255\255\255\ +\215\005\255\255\068\001\255\255\255\255\255\255\221\005\193\001\ +\074\001\255\255\196\001\197\001\019\001\255\255\080\001\255\255\ +\255\255\232\005\062\004\026\001\000\001\255\255\000\000\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\096\001\097\001\ +\255\255\255\255\255\255\221\001\222\001\223\001\255\255\019\001\ +\255\255\048\001\108\001\229\001\255\255\111\001\026\001\255\255\ +\255\255\008\006\236\001\255\255\255\255\060\001\255\255\255\255\ +\015\006\255\255\007\000\255\255\067\001\068\001\011\000\070\001\ +\255\255\109\004\252\001\253\001\048\001\049\001\255\255\001\002\ +\031\006\255\255\118\004\005\002\255\255\026\000\008\002\255\255\ +\060\001\255\255\255\255\042\006\255\255\255\255\016\002\067\001\ +\068\001\255\255\070\001\255\255\255\255\023\002\255\255\255\255\ +\045\000\255\255\255\255\058\006\255\255\255\255\255\255\033\002\ +\111\001\255\255\255\255\066\006\067\006\255\255\255\255\080\003\ +\042\002\072\006\073\006\255\255\255\255\255\255\048\002\255\255\ +\255\255\255\255\081\006\082\006\083\006\000\001\255\255\255\255\ +\003\001\088\006\060\002\111\001\255\255\063\002\083\000\094\006\ +\085\000\086\000\013\001\183\004\255\255\185\004\072\002\255\255\ +\019\001\000\001\255\255\255\255\255\255\255\255\255\255\026\001\ +\111\006\028\001\029\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\121\006\255\255\255\255\124\006\041\001\255\255\ +\255\255\255\255\255\255\130\006\131\006\103\002\255\255\255\255\ +\255\255\255\255\222\004\255\255\255\255\255\255\255\255\227\004\ +\255\255\060\001\255\255\255\255\063\001\255\255\000\000\255\255\ +\067\001\068\001\255\255\255\255\255\255\255\255\255\255\074\001\ +\055\001\255\255\057\001\058\001\059\001\080\001\061\001\255\255\ +\255\255\064\001\065\001\086\001\255\255\255\255\255\255\164\000\ +\165\000\092\001\167\000\255\255\255\255\096\001\097\001\255\255\ +\255\255\255\255\081\001\255\255\177\000\178\000\255\255\019\005\ +\255\255\108\001\089\001\090\001\111\001\255\255\255\255\255\255\ +\189\000\255\255\097\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\201\000\202\000\109\001\110\001\ +\255\255\206\000\255\255\255\255\190\002\191\002\255\255\051\005\ +\255\255\053\005\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\206\002\207\002\000\001\255\255\ +\002\001\003\001\004\001\071\005\255\255\255\255\008\001\075\005\ +\076\005\255\255\255\255\013\001\255\255\255\255\255\255\017\001\ +\018\001\019\001\255\255\255\255\255\255\231\002\090\005\255\255\ +\026\001\027\001\028\001\029\001\255\255\255\255\255\255\255\255\ +\242\002\255\255\036\001\255\255\000\000\255\255\255\255\041\001\ +\255\255\251\002\255\255\253\002\112\005\255\255\048\001\049\001\ +\255\255\255\255\255\255\255\255\255\255\007\003\255\255\255\255\ +\029\001\255\255\060\001\255\255\255\255\063\001\064\001\255\255\ +\066\001\067\001\068\001\255\255\070\001\255\255\255\255\073\001\ +\074\001\255\255\255\255\255\255\255\255\050\001\080\001\255\255\ +\255\255\255\255\036\003\255\255\038\003\255\255\255\255\255\255\ +\255\255\091\001\092\001\255\255\094\001\095\001\096\001\097\001\ +\255\255\255\255\100\001\053\003\255\255\255\255\255\255\171\005\ +\255\255\000\001\108\001\109\001\000\000\111\001\255\255\255\255\ +\180\005\115\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\019\001\193\005\255\255\255\255\ +\196\005\255\255\255\255\026\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\000\001\007\000\255\255\ +\117\001\118\001\255\255\255\255\121\001\255\255\123\001\255\255\ +\255\255\048\001\049\001\255\255\110\003\255\255\255\255\255\255\ +\019\001\229\005\255\255\255\255\000\000\060\001\000\001\026\001\ +\002\001\003\001\004\001\255\255\067\001\068\001\008\001\070\001\ +\255\255\255\255\255\255\013\001\134\003\255\255\255\255\017\001\ +\018\001\019\001\255\255\255\255\255\255\048\001\255\255\145\003\ +\026\001\027\001\028\001\029\001\255\255\255\255\255\255\255\255\ +\255\255\060\001\036\001\255\255\255\255\255\255\255\255\041\001\ +\067\001\068\001\255\255\070\001\255\255\255\255\048\001\049\001\ +\111\001\255\255\172\003\255\255\255\255\255\255\255\255\196\001\ +\197\001\255\255\060\001\255\255\255\255\063\001\255\255\255\255\ +\066\001\067\001\068\001\255\255\070\001\255\255\255\255\073\001\ +\074\001\255\255\255\255\055\006\255\255\199\003\080\001\255\255\ +\221\001\222\001\223\001\255\255\111\001\255\255\255\255\255\255\ +\229\001\091\001\092\001\255\255\094\001\095\001\096\001\097\001\ +\255\255\219\003\220\003\255\255\255\255\255\255\224\003\225\003\ +\226\003\255\255\108\001\255\255\230\003\111\001\255\255\252\001\ +\253\001\115\001\236\003\255\255\001\002\255\255\255\255\255\255\ +\005\002\101\006\102\006\255\255\000\001\255\255\255\255\255\255\ +\255\255\109\006\255\255\164\000\165\000\255\255\167\000\255\255\ +\255\255\013\001\004\004\255\255\255\255\255\255\255\255\255\255\ +\177\000\178\000\255\255\255\255\033\002\129\006\026\001\255\255\ +\028\001\029\001\255\255\255\255\022\004\042\002\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\041\001\255\255\200\000\ +\201\000\202\000\007\000\255\255\255\255\255\255\011\000\060\002\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\060\001\255\255\255\255\072\002\054\004\026\000\066\001\067\001\ +\068\001\255\255\255\255\255\255\000\001\255\255\074\001\003\001\ +\255\255\255\255\255\255\255\255\080\001\255\255\255\255\255\255\ +\045\000\013\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\092\001\255\255\103\002\255\255\096\001\255\255\026\001\027\001\ +\028\001\029\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\108\001\255\255\255\255\111\001\255\255\041\001\255\255\255\255\ +\255\255\000\000\108\004\255\255\110\004\255\255\083\000\255\255\ +\085\000\086\000\255\255\255\255\000\001\255\255\255\255\003\001\ +\060\001\255\255\255\255\125\004\008\001\255\255\255\255\067\001\ +\068\001\013\001\014\001\255\255\255\255\255\255\074\001\019\001\ +\255\255\139\004\022\001\255\255\080\001\255\255\026\001\007\000\ +\028\001\029\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\092\001\255\255\094\001\068\001\096\001\041\001\255\255\255\255\ +\255\255\255\255\255\255\136\000\077\001\255\255\255\255\255\255\ +\108\001\255\255\191\002\111\001\255\255\255\255\176\004\255\255\ +\060\001\255\255\255\255\063\001\255\255\065\001\066\001\067\001\ +\068\001\206\002\207\002\006\001\255\255\008\001\074\001\164\000\ +\165\000\255\255\167\000\079\001\080\001\255\255\255\255\255\255\ +\255\255\203\004\255\255\255\255\177\000\178\000\255\255\255\255\ +\092\001\255\255\231\002\255\255\096\001\097\001\216\004\255\255\ +\189\000\255\255\220\004\255\255\255\255\242\002\255\255\255\255\ +\108\001\255\255\255\255\111\001\201\000\202\000\251\002\255\255\ +\253\002\206\000\255\255\255\255\055\001\255\255\057\001\058\001\ +\059\001\255\255\061\001\255\255\255\255\064\001\065\001\255\255\ +\255\255\255\255\255\255\000\001\255\255\255\255\255\255\255\255\ +\255\255\003\005\255\255\255\255\255\255\255\255\081\001\255\255\ +\013\001\255\255\255\255\255\255\255\255\006\001\089\001\090\001\ +\255\255\038\003\255\255\255\255\000\000\026\001\097\001\028\001\ +\029\001\255\255\028\005\196\001\197\001\255\255\255\255\255\255\ +\255\255\255\255\109\001\110\001\041\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\164\000\165\000\255\255\167\000\ +\255\255\255\255\052\005\220\001\221\001\222\001\223\001\060\001\ +\029\001\177\000\178\000\255\255\229\001\255\255\055\001\068\001\ +\057\001\058\001\059\001\255\255\061\001\074\001\015\001\064\001\ +\065\001\255\255\255\255\080\001\255\255\050\001\255\255\255\255\ +\255\255\201\000\202\000\252\001\253\001\255\255\255\255\255\255\ +\001\002\255\255\255\255\096\001\005\002\028\000\029\000\255\255\ +\255\255\090\001\043\001\044\001\045\001\046\001\015\002\108\001\ +\097\001\000\001\111\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\008\001\255\255\255\255\109\001\110\001\013\001\121\005\ +\033\002\066\001\255\255\125\005\145\003\255\255\071\001\072\001\ +\130\005\042\002\255\255\026\001\255\255\028\001\029\001\255\255\ +\255\255\255\255\083\001\084\001\085\001\086\001\255\255\145\005\ +\117\001\118\001\041\001\060\002\121\001\255\255\123\001\172\003\ +\087\000\088\000\255\255\100\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\060\001\255\255\255\255\ +\063\001\255\255\255\255\066\001\067\001\068\001\255\255\255\255\ +\255\255\255\255\199\003\074\001\255\255\255\255\255\255\255\255\ +\157\001\080\001\000\000\255\255\000\000\255\255\103\002\164\001\ +\255\255\166\001\255\255\255\255\255\255\092\001\219\003\220\003\ +\255\255\096\001\097\001\224\003\225\003\226\003\255\255\255\255\ +\210\005\230\003\212\005\255\255\255\255\108\001\255\255\236\003\ +\111\001\255\255\255\255\255\255\255\255\255\255\255\255\196\001\ +\197\001\255\255\255\255\255\255\255\255\255\255\232\005\255\255\ +\023\001\255\255\255\255\255\255\255\255\255\255\255\255\004\004\ +\134\001\243\005\255\255\255\255\255\255\036\001\255\255\255\255\ +\221\001\222\001\223\001\255\255\015\001\255\255\255\255\255\255\ +\229\001\255\255\255\255\255\255\255\255\007\006\255\255\255\255\ +\055\001\255\255\057\001\058\001\059\001\015\006\061\001\255\255\ +\018\006\064\001\065\001\255\255\000\001\255\255\191\002\252\001\ +\253\001\044\001\045\001\046\001\001\002\255\255\255\255\255\255\ +\005\002\013\001\255\255\255\255\255\255\206\002\207\002\255\255\ +\190\001\043\006\255\255\090\001\255\255\255\255\026\001\255\255\ +\028\001\029\001\097\001\255\255\071\001\072\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\033\002\041\001\109\001\110\001\ +\083\001\084\001\085\001\086\001\255\255\042\002\255\255\255\255\ +\255\255\242\002\255\255\255\255\196\001\197\001\255\255\255\255\ +\060\001\100\001\251\002\063\001\253\002\255\255\088\006\060\002\ +\068\001\110\004\255\255\255\255\255\255\255\255\074\001\255\255\ +\255\255\255\255\255\255\072\002\080\001\221\001\222\001\223\001\ +\125\004\255\255\255\255\255\255\255\255\229\001\230\001\255\255\ +\092\001\255\255\255\255\255\255\096\001\097\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\038\003\255\255\255\255\ +\108\001\255\255\103\002\111\001\252\001\253\001\255\255\255\255\ +\255\255\001\002\255\255\255\255\255\255\005\002\255\255\078\001\ +\079\001\080\001\081\001\082\001\083\001\084\001\085\001\086\001\ +\087\001\088\001\089\001\090\001\091\001\092\001\093\001\094\001\ +\095\001\096\001\097\001\098\001\000\000\100\001\255\255\255\255\ +\102\001\033\002\255\255\105\001\255\255\107\001\255\255\109\001\ +\255\255\111\001\042\002\114\001\255\255\255\255\203\004\255\255\ +\255\255\255\255\255\255\160\002\255\255\255\255\255\255\255\255\ +\127\001\255\255\255\255\255\255\060\002\255\255\255\255\013\001\ +\255\255\013\001\255\255\116\003\255\255\255\255\255\255\141\001\ +\255\255\143\001\255\255\255\255\255\255\255\255\028\001\029\001\ +\028\001\029\001\191\002\255\255\255\255\255\255\255\255\255\255\ +\255\255\159\001\255\255\041\001\255\255\041\001\255\255\255\255\ +\145\003\206\002\207\002\255\255\130\002\255\255\255\255\103\002\ +\255\255\000\000\255\255\008\005\255\255\255\255\060\001\255\255\ +\060\001\063\001\255\255\063\001\255\255\255\255\068\001\255\255\ +\068\001\255\255\255\255\172\003\074\001\255\255\074\001\028\005\ +\255\255\255\255\080\001\006\001\080\001\242\002\255\255\255\255\ +\255\255\255\255\255\255\169\002\255\255\255\255\251\002\255\255\ +\253\002\255\255\096\001\097\001\096\001\097\001\199\003\255\255\ +\255\255\255\255\015\001\255\255\255\255\255\255\108\001\255\255\ +\108\001\111\001\232\001\111\001\234\001\255\255\255\255\255\255\ +\255\255\255\255\219\003\220\003\255\255\255\255\223\003\224\003\ +\225\003\226\003\255\255\255\255\055\001\230\003\057\001\058\001\ +\059\001\038\003\061\001\236\003\255\255\064\001\065\001\191\002\ +\255\255\007\002\055\001\009\002\057\001\058\001\059\001\255\255\ +\061\001\255\255\255\255\064\001\065\001\255\255\206\002\207\002\ +\255\255\024\002\255\255\004\004\255\255\074\001\029\002\090\001\ +\255\255\255\255\255\255\255\255\081\001\255\255\097\001\255\255\ +\125\005\255\255\255\255\255\255\089\001\090\001\255\255\132\005\ +\255\255\094\001\109\001\110\001\097\001\255\255\255\255\255\255\ +\255\255\255\255\242\002\255\255\145\005\255\255\255\255\255\255\ +\109\001\110\001\255\255\251\002\255\255\253\002\255\255\255\255\ +\255\255\255\255\255\255\074\002\075\002\255\255\255\255\255\255\ +\255\255\118\003\255\255\255\255\255\255\255\255\123\003\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\052\003\255\255\ +\255\255\000\000\255\255\255\255\000\001\255\255\255\255\003\001\ +\255\255\255\255\255\255\255\255\145\003\255\255\038\003\110\002\ +\255\255\013\001\255\255\255\255\115\002\116\002\117\002\255\255\ +\255\255\255\255\255\255\255\255\255\255\210\005\026\001\027\001\ +\028\001\029\001\255\255\129\002\255\255\110\004\132\002\172\003\ +\255\255\255\255\255\255\255\255\255\255\041\001\255\255\255\255\ +\255\255\103\003\255\255\232\005\125\004\255\255\255\255\109\003\ +\255\255\255\255\255\255\255\255\255\255\255\255\243\005\255\255\ +\060\001\255\255\199\003\255\255\064\001\255\255\066\001\067\001\ +\068\001\255\255\255\255\255\255\255\255\073\001\074\001\255\255\ +\255\255\000\001\255\255\255\255\080\001\255\255\219\003\220\003\ +\255\255\255\255\255\255\224\003\225\003\226\003\013\001\255\255\ +\092\001\230\003\094\001\255\255\096\001\097\001\255\255\236\003\ +\100\001\255\255\255\255\026\001\255\255\028\001\029\001\255\255\ +\108\001\109\001\000\000\111\001\255\255\255\255\043\006\214\002\ +\255\255\145\003\041\001\255\255\219\002\220\002\221\002\004\004\ +\255\255\000\001\203\004\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\233\002\255\255\060\001\255\255\255\255\ +\063\001\255\255\255\255\255\255\172\003\068\001\255\255\205\003\ +\255\255\255\255\255\255\074\001\255\255\255\255\255\255\255\255\ +\255\255\080\001\255\255\002\003\255\255\255\255\004\003\255\255\ +\255\255\255\255\255\255\255\255\255\255\092\001\255\255\199\003\ +\255\255\096\001\097\001\018\003\234\003\255\255\255\255\237\003\ +\055\001\255\255\057\001\058\001\059\001\108\001\061\001\255\255\ +\111\001\064\001\065\001\219\003\220\003\074\004\255\255\255\255\ +\224\003\225\003\226\003\255\255\255\255\255\255\230\003\255\255\ +\255\255\255\255\081\001\028\005\236\003\255\255\255\255\255\255\ +\255\255\255\255\089\001\090\001\255\255\255\255\255\255\255\255\ +\000\000\255\255\097\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\110\004\255\255\255\255\004\004\108\001\109\001\110\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\125\004\255\255\255\255\255\255\255\255\255\255\255\255\094\003\ +\255\255\000\001\001\001\002\001\003\001\255\255\060\004\255\255\ +\255\255\008\001\009\001\010\001\255\255\067\004\013\001\014\001\ +\255\255\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ +\255\255\024\001\025\001\026\001\027\001\028\001\029\001\255\255\ +\255\255\087\004\128\003\255\255\255\255\036\001\037\001\255\255\ +\255\255\040\001\041\001\042\001\043\001\255\255\000\000\255\255\ +\255\255\048\001\049\001\255\255\125\005\107\004\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\060\001\061\001\255\255\ +\063\001\255\255\255\255\066\001\067\001\068\001\203\004\070\001\ +\145\005\255\255\073\001\074\001\255\255\255\255\255\255\255\255\ +\255\255\080\001\255\255\082\001\255\255\255\255\110\004\181\003\ +\255\255\255\255\255\255\255\255\091\001\092\001\255\255\094\001\ +\095\001\096\001\097\001\255\255\255\255\125\004\255\255\255\255\ +\103\001\255\255\105\001\255\255\203\003\108\001\255\255\244\004\ +\111\001\255\255\000\001\255\255\115\001\003\001\255\255\213\003\ +\255\255\255\255\008\001\177\004\255\255\255\255\255\255\013\001\ +\255\255\255\255\255\255\008\005\255\255\019\001\023\001\255\255\ +\255\255\210\005\255\255\255\255\026\001\255\255\028\001\029\001\ +\255\255\255\255\255\255\036\001\255\255\255\255\255\255\028\005\ +\255\255\255\255\255\255\041\001\250\003\255\255\252\003\232\005\ +\214\004\215\004\255\255\255\255\255\255\255\255\055\001\255\255\ +\057\001\058\001\059\001\225\004\061\001\255\255\060\001\064\001\ +\065\001\063\001\255\255\203\004\066\001\067\001\068\001\255\255\ +\061\005\255\255\255\255\241\004\074\001\255\255\255\255\255\255\ +\255\255\255\255\080\001\255\255\255\255\255\255\037\004\038\004\ +\039\004\090\001\255\255\255\255\000\000\255\255\092\001\255\255\ +\097\001\255\255\096\001\097\001\255\255\051\004\255\255\255\255\ +\255\255\255\255\255\255\255\255\109\001\110\001\108\001\255\255\ +\000\001\111\001\255\255\003\001\255\255\255\255\255\255\255\255\ +\255\255\071\004\255\255\033\005\034\005\013\001\014\001\255\255\ +\255\255\017\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\125\005\255\255\026\001\027\001\028\001\029\001\255\255\132\005\ +\255\255\096\004\097\004\098\004\028\005\255\255\255\255\255\255\ +\040\001\041\001\255\255\255\255\145\005\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\074\005\255\255\255\255\077\005\ +\255\255\255\255\255\255\255\255\060\001\255\255\255\255\063\001\ +\255\255\255\255\255\255\067\001\068\001\255\255\255\255\093\005\ +\094\005\073\001\074\001\138\004\255\255\255\255\000\001\101\005\ +\080\001\003\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\013\001\092\001\255\255\094\001\017\001\ +\096\001\097\001\255\255\255\255\255\255\123\005\255\255\255\255\ +\026\001\027\001\028\001\029\001\108\001\210\005\255\255\111\001\ +\255\255\000\000\255\255\115\001\255\255\255\255\180\004\041\001\ +\182\004\255\255\184\004\000\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\232\005\255\255\125\005\255\255\255\255\ +\255\255\255\255\060\001\255\255\255\255\063\001\205\004\206\004\ +\207\004\067\001\068\001\255\255\211\004\212\004\213\004\255\255\ +\074\001\145\005\255\255\255\255\255\255\255\255\080\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\092\001\255\255\094\001\235\004\096\001\097\001\ +\255\255\199\005\055\001\255\255\057\001\058\001\059\001\205\005\ +\061\001\247\004\108\001\064\001\065\001\111\001\255\255\255\255\ +\255\255\215\005\000\005\255\255\255\255\255\255\004\005\221\005\ +\255\255\255\255\255\255\255\255\081\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\089\001\090\001\255\255\255\255\ +\255\255\255\255\210\005\255\255\097\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\109\001\110\001\255\255\255\255\000\001\001\001\002\001\003\001\ +\232\005\255\255\008\006\255\255\008\001\009\001\010\001\255\255\ +\255\255\013\001\014\001\015\001\016\001\017\001\018\001\019\001\ +\020\001\021\001\255\255\255\255\024\001\025\001\026\001\027\001\ +\028\001\029\001\255\255\000\000\255\255\255\255\255\255\255\255\ +\036\001\037\001\255\255\255\255\040\001\041\001\042\001\043\001\ +\044\001\045\001\046\001\255\255\048\001\049\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\058\006\255\255\255\255\255\255\ +\060\001\061\001\255\255\063\001\255\255\255\255\066\001\067\001\ +\068\001\255\255\070\001\071\001\072\001\073\001\074\001\255\255\ +\255\255\255\255\255\255\081\006\080\001\083\006\082\001\083\001\ +\084\001\085\001\086\001\255\255\255\255\255\255\255\255\091\001\ +\092\001\255\255\094\001\095\001\096\001\097\001\255\255\255\255\ +\100\001\255\255\255\255\103\001\255\255\105\001\255\255\255\255\ +\108\001\255\255\255\255\111\001\255\255\255\255\255\255\115\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\166\005\255\255\255\255\255\255\013\001\255\255\255\255\255\255\ +\255\255\000\001\255\255\002\001\003\001\004\001\181\005\182\005\ +\183\005\008\001\255\255\028\001\029\001\255\255\013\001\000\000\ +\255\255\255\255\017\001\018\001\019\001\255\255\255\255\255\255\ +\041\001\255\255\200\005\026\001\027\001\028\001\029\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\036\001\255\255\213\005\ +\255\255\040\001\041\001\060\001\255\255\219\005\063\001\255\255\ +\255\255\048\001\049\001\068\001\255\255\255\255\255\255\255\255\ +\255\255\074\001\255\255\255\255\255\255\060\001\236\005\080\001\ +\063\001\255\255\255\255\066\001\067\001\068\001\244\005\070\001\ +\255\255\255\255\073\001\074\001\255\255\255\255\255\255\096\001\ +\255\255\080\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\108\001\091\001\092\001\111\001\094\001\ +\095\001\096\001\255\255\255\255\255\255\100\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\108\001\255\255\255\255\ +\111\001\255\255\255\255\255\255\115\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\044\006\045\006\ +\255\255\255\255\255\255\000\000\255\255\051\006\052\006\053\006\ +\054\006\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\063\006\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\000\001\001\001\002\001\003\001\255\255\ +\078\006\006\001\007\001\008\001\009\001\010\001\011\001\012\001\ +\013\001\014\001\015\001\016\001\017\001\018\001\019\001\020\001\ +\021\001\022\001\255\255\024\001\025\001\026\001\027\001\028\001\ +\029\001\030\001\031\001\255\255\255\255\255\255\255\255\036\001\ +\037\001\255\255\255\255\040\001\041\001\042\001\043\001\044\001\ +\045\001\046\001\047\001\048\001\049\001\050\001\051\001\255\255\ +\053\001\054\001\055\001\056\001\255\255\255\255\059\001\060\001\ +\061\001\062\001\063\001\064\001\065\001\066\001\067\001\068\001\ +\255\255\070\001\071\001\072\001\073\001\074\001\255\255\076\001\ +\255\255\255\255\255\255\080\001\081\001\082\001\083\001\084\001\ +\085\001\086\001\087\001\255\255\089\001\255\255\091\001\092\001\ +\000\000\094\001\095\001\096\001\097\001\098\001\255\255\100\001\ +\101\001\255\255\103\001\104\001\105\001\106\001\255\255\108\001\ +\109\001\255\255\111\001\255\255\255\255\255\255\115\001\000\001\ +\001\001\002\001\003\001\004\001\255\255\006\001\007\001\008\001\ +\009\001\010\001\011\001\012\001\013\001\014\001\015\001\016\001\ +\017\001\018\001\019\001\020\001\021\001\255\255\255\255\024\001\ +\025\001\026\001\027\001\028\001\029\001\030\001\031\001\255\255\ +\255\255\255\255\255\255\036\001\037\001\255\255\255\255\040\001\ +\041\001\042\001\043\001\044\001\045\001\046\001\047\001\048\001\ +\049\001\050\001\051\001\255\255\053\001\054\001\055\001\056\001\ +\255\255\255\255\059\001\060\001\061\001\255\255\063\001\064\001\ +\065\001\066\001\067\001\068\001\255\255\070\001\071\001\072\001\ +\073\001\074\001\255\255\076\001\255\255\255\255\255\255\080\001\ +\081\001\082\001\083\001\084\001\085\001\086\001\087\001\255\255\ +\089\001\255\255\091\001\092\001\000\000\094\001\095\001\096\001\ +\097\001\098\001\255\255\100\001\101\001\255\255\103\001\104\001\ +\105\001\106\001\255\255\108\001\109\001\255\255\111\001\255\255\ +\255\255\255\255\115\001\000\001\001\001\002\001\003\001\255\255\ +\255\255\006\001\007\001\008\001\009\001\010\001\011\001\012\001\ +\013\001\014\001\015\001\016\001\017\001\018\001\019\001\020\001\ +\021\001\022\001\255\255\024\001\025\001\026\001\027\001\028\001\ +\029\001\030\001\031\001\255\255\255\255\255\255\255\255\036\001\ +\037\001\255\255\255\255\040\001\041\001\042\001\043\001\044\001\ +\045\001\046\001\047\001\048\001\049\001\050\001\051\001\255\255\ +\053\001\054\001\055\001\056\001\255\255\255\255\059\001\060\001\ +\061\001\255\255\063\001\064\001\065\001\066\001\067\001\068\001\ +\255\255\070\001\071\001\072\001\073\001\074\001\255\255\076\001\ +\255\255\255\255\255\255\080\001\081\001\082\001\083\001\084\001\ +\085\001\086\001\087\001\255\255\089\001\255\255\091\001\092\001\ +\000\000\094\001\095\001\096\001\097\001\098\001\255\255\100\001\ +\101\001\255\255\103\001\104\001\105\001\106\001\255\255\108\001\ +\109\001\255\255\111\001\255\255\255\255\255\255\115\001\255\255\ +\000\001\001\001\002\001\003\001\255\255\255\255\006\001\007\001\ +\008\001\009\001\010\001\011\001\012\001\013\001\014\001\015\001\ +\016\001\017\001\018\001\019\001\020\001\021\001\022\001\255\255\ +\024\001\025\001\026\001\027\001\028\001\029\001\030\001\031\001\ +\255\255\255\255\255\255\255\255\036\001\037\001\255\255\255\255\ +\040\001\041\001\042\001\043\001\044\001\045\001\046\001\047\001\ +\048\001\049\001\050\001\051\001\255\255\053\001\054\001\055\001\ +\056\001\255\255\255\255\059\001\060\001\061\001\255\255\063\001\ +\064\001\065\001\066\001\067\001\068\001\255\255\070\001\071\001\ +\072\001\073\001\074\001\255\255\076\001\255\255\255\255\255\255\ +\080\001\081\001\082\001\083\001\084\001\085\001\086\001\087\001\ +\255\255\089\001\255\255\091\001\092\001\000\000\094\001\095\001\ +\096\001\097\001\098\001\255\255\100\001\101\001\255\255\103\001\ +\104\001\105\001\106\001\255\255\108\001\109\001\255\255\111\001\ +\255\255\255\255\255\255\115\001\000\001\001\001\002\001\003\001\ +\255\255\255\255\006\001\007\001\008\001\009\001\010\001\011\001\ +\012\001\013\001\014\001\015\001\016\001\017\001\018\001\019\001\ +\020\001\021\001\022\001\255\255\024\001\025\001\026\001\027\001\ +\028\001\029\001\030\001\031\001\255\255\255\255\255\255\255\255\ +\036\001\037\001\255\255\255\255\040\001\041\001\042\001\043\001\ +\044\001\045\001\046\001\047\001\048\001\049\001\050\001\051\001\ +\255\255\053\001\054\001\055\001\056\001\255\255\255\255\059\001\ +\060\001\061\001\255\255\063\001\064\001\065\001\066\001\067\001\ +\068\001\255\255\070\001\071\001\072\001\073\001\074\001\255\255\ +\076\001\255\255\255\255\255\255\080\001\081\001\082\001\083\001\ +\084\001\085\001\086\001\087\001\255\255\089\001\255\255\091\001\ +\092\001\000\000\094\001\095\001\096\001\097\001\098\001\255\255\ +\100\001\101\001\255\255\103\001\104\001\105\001\106\001\255\255\ +\108\001\109\001\255\255\111\001\255\255\255\255\255\255\115\001\ +\000\001\001\001\002\001\003\001\255\255\255\255\006\001\007\001\ +\008\001\009\001\010\001\011\001\012\001\013\001\014\001\015\001\ +\016\001\017\001\018\001\019\001\020\001\021\001\022\001\255\255\ +\024\001\025\001\026\001\027\001\028\001\029\001\030\001\031\001\ +\255\255\255\255\255\255\255\255\036\001\037\001\255\255\255\255\ +\040\001\041\001\042\001\043\001\044\001\045\001\046\001\047\001\ +\048\001\049\001\050\001\051\001\255\255\053\001\054\001\055\001\ +\056\001\255\255\255\255\059\001\060\001\061\001\255\255\063\001\ +\064\001\065\001\066\001\067\001\068\001\255\255\070\001\071\001\ +\072\001\073\001\074\001\255\255\076\001\255\255\255\255\255\255\ +\080\001\081\001\082\001\083\001\084\001\085\001\086\001\087\001\ +\255\255\089\001\255\255\091\001\092\001\000\000\094\001\095\001\ +\096\001\097\001\098\001\255\255\100\001\101\001\255\255\103\001\ +\104\001\105\001\106\001\255\255\108\001\109\001\255\255\111\001\ +\255\255\255\255\255\255\115\001\255\255\000\001\001\001\002\001\ +\003\001\255\255\255\255\006\001\007\001\008\001\009\001\010\001\ +\011\001\012\001\013\001\014\001\015\001\016\001\017\001\018\001\ +\019\001\020\001\021\001\022\001\255\255\024\001\025\001\026\001\ +\027\001\028\001\029\001\030\001\031\001\255\255\255\255\255\255\ +\255\255\036\001\037\001\255\255\255\255\040\001\041\001\042\001\ +\043\001\044\001\045\001\046\001\047\001\048\001\049\001\050\001\ +\051\001\255\255\053\001\054\001\055\001\056\001\255\255\255\255\ +\059\001\060\001\061\001\255\255\063\001\064\001\065\001\066\001\ +\067\001\068\001\255\255\070\001\071\001\072\001\073\001\074\001\ +\255\255\076\001\255\255\255\255\255\255\080\001\081\001\082\001\ +\083\001\084\001\085\001\086\001\087\001\255\255\089\001\255\255\ +\091\001\092\001\000\000\094\001\095\001\096\001\097\001\098\001\ +\255\255\100\001\101\001\255\255\103\001\104\001\105\001\106\001\ +\255\255\108\001\109\001\255\255\111\001\255\255\255\255\255\255\ +\115\001\000\001\001\001\002\001\003\001\255\255\255\255\006\001\ +\007\001\008\001\009\001\010\001\011\001\012\001\013\001\014\001\ +\015\001\016\001\017\001\018\001\019\001\020\001\021\001\022\001\ +\255\255\024\001\025\001\026\001\027\001\028\001\029\001\030\001\ +\031\001\255\255\255\255\255\255\255\255\036\001\037\001\255\255\ +\255\255\040\001\041\001\042\001\043\001\044\001\045\001\046\001\ +\047\001\048\001\049\001\050\001\051\001\255\255\053\001\054\001\ +\055\001\056\001\255\255\255\255\059\001\060\001\061\001\255\255\ +\063\001\064\001\065\001\066\001\067\001\068\001\255\255\070\001\ +\071\001\072\001\073\001\074\001\255\255\076\001\255\255\255\255\ +\255\255\080\001\081\001\082\001\083\001\084\001\085\001\086\001\ +\087\001\255\255\089\001\255\255\091\001\092\001\000\000\094\001\ +\095\001\096\001\097\001\098\001\255\255\100\001\101\001\255\255\ +\103\001\104\001\105\001\106\001\255\255\108\001\109\001\255\255\ +\111\001\255\255\255\255\255\255\115\001\000\001\001\001\002\001\ +\003\001\255\255\255\255\006\001\007\001\008\001\009\001\010\001\ +\011\001\012\001\013\001\014\001\015\001\016\001\017\001\018\001\ +\019\001\020\001\021\001\022\001\255\255\024\001\025\001\026\001\ +\027\001\028\001\029\001\030\001\031\001\255\255\255\255\255\255\ +\255\255\036\001\037\001\255\255\255\255\040\001\041\001\042\001\ +\043\001\044\001\045\001\046\001\047\001\048\001\049\001\050\001\ +\051\001\255\255\053\001\054\001\055\001\056\001\255\255\255\255\ +\059\001\060\001\061\001\255\255\063\001\064\001\065\001\066\001\ +\067\001\068\001\255\255\070\001\071\001\072\001\073\001\074\001\ +\255\255\076\001\255\255\255\255\255\255\080\001\081\001\082\001\ +\083\001\084\001\085\001\086\001\087\001\255\255\089\001\255\255\ +\091\001\092\001\000\000\094\001\095\001\096\001\097\001\098\001\ +\255\255\100\001\101\001\255\255\103\001\104\001\105\001\106\001\ +\255\255\108\001\109\001\255\255\111\001\255\255\255\255\255\255\ +\115\001\255\255\000\001\001\001\002\001\003\001\255\255\255\255\ +\006\001\007\001\008\001\009\001\010\001\011\001\012\001\013\001\ +\014\001\015\001\016\001\017\001\018\001\019\001\020\001\021\001\ +\022\001\255\255\024\001\025\001\026\001\027\001\028\001\029\001\ +\030\001\031\001\255\255\255\255\255\255\255\255\036\001\037\001\ +\255\255\255\255\040\001\041\001\042\001\043\001\044\001\045\001\ +\046\001\047\001\048\001\049\001\050\001\051\001\255\255\053\001\ +\054\001\055\001\056\001\255\255\255\255\059\001\060\001\061\001\ +\255\255\063\001\064\001\065\001\066\001\067\001\068\001\255\255\ +\070\001\071\001\072\001\073\001\074\001\255\255\076\001\255\255\ +\255\255\255\255\080\001\081\001\082\001\083\001\084\001\085\001\ +\086\001\087\001\255\255\089\001\255\255\091\001\092\001\000\000\ +\094\001\095\001\096\001\097\001\098\001\255\255\100\001\101\001\ +\255\255\103\001\104\001\105\001\106\001\255\255\108\001\109\001\ +\255\255\111\001\255\255\255\255\255\255\115\001\000\001\001\001\ +\002\001\003\001\255\255\255\255\006\001\007\001\008\001\009\001\ +\010\001\011\001\012\001\013\001\014\001\015\001\016\001\017\001\ +\018\001\019\001\020\001\021\001\022\001\255\255\024\001\025\001\ +\026\001\027\001\028\001\029\001\030\001\031\001\255\255\255\255\ +\255\255\255\255\036\001\037\001\255\255\255\255\040\001\041\001\ +\042\001\043\001\044\001\045\001\046\001\047\001\048\001\049\001\ +\050\001\051\001\255\255\053\001\054\001\055\001\056\001\255\255\ +\255\255\059\001\060\001\061\001\255\255\063\001\064\001\065\001\ +\066\001\067\001\068\001\255\255\070\001\071\001\072\001\073\001\ +\074\001\255\255\076\001\255\255\255\255\255\255\080\001\081\001\ +\082\001\083\001\084\001\085\001\086\001\087\001\255\255\089\001\ +\255\255\091\001\092\001\000\000\094\001\095\001\096\001\097\001\ +\098\001\255\255\100\001\101\001\255\255\103\001\104\001\105\001\ +\106\001\255\255\108\001\109\001\255\255\111\001\255\255\255\255\ +\255\255\115\001\000\001\001\001\002\001\003\001\255\255\255\255\ +\006\001\007\001\008\001\009\001\010\001\011\001\012\001\013\001\ +\014\001\015\001\016\001\017\001\018\001\019\001\020\001\021\001\ +\022\001\255\255\024\001\025\001\026\001\027\001\028\001\029\001\ +\030\001\031\001\255\255\255\255\255\255\255\255\036\001\037\001\ +\255\255\255\255\040\001\041\001\042\001\043\001\044\001\045\001\ +\046\001\047\001\048\001\049\001\050\001\051\001\255\255\053\001\ +\054\001\055\001\056\001\255\255\255\255\059\001\060\001\061\001\ +\255\255\063\001\064\001\065\001\066\001\067\001\068\001\255\255\ +\070\001\071\001\072\001\073\001\074\001\255\255\076\001\255\255\ +\255\255\255\255\080\001\081\001\082\001\083\001\084\001\085\001\ +\086\001\087\001\255\255\089\001\255\255\091\001\092\001\000\000\ +\094\001\095\001\096\001\097\001\098\001\255\255\100\001\101\001\ +\255\255\103\001\104\001\105\001\106\001\255\255\108\001\109\001\ +\255\255\111\001\255\255\255\255\255\255\115\001\255\255\000\001\ +\001\001\002\001\003\001\004\001\255\255\006\001\007\001\008\001\ +\009\001\010\001\011\001\012\001\013\001\014\001\015\001\016\001\ +\017\001\018\001\019\001\020\001\021\001\255\255\255\255\024\001\ +\025\001\026\001\027\001\028\001\029\001\030\001\031\001\255\255\ +\255\255\255\255\255\255\036\001\037\001\255\255\255\255\040\001\ +\041\001\042\001\043\001\044\001\045\001\046\001\255\255\048\001\ +\049\001\050\001\051\001\255\255\053\001\054\001\055\001\056\001\ +\255\255\255\255\059\001\060\001\061\001\255\255\063\001\064\001\ +\065\001\066\001\067\001\068\001\255\255\070\001\071\001\072\001\ +\073\001\074\001\255\255\076\001\255\255\255\255\255\255\080\001\ +\081\001\082\001\083\001\084\001\085\001\086\001\087\001\255\255\ +\089\001\255\255\091\001\092\001\000\000\094\001\095\001\096\001\ +\097\001\098\001\255\255\100\001\101\001\255\255\103\001\104\001\ +\105\001\106\001\255\255\108\001\109\001\255\255\111\001\255\255\ +\255\255\255\255\115\001\000\001\001\001\002\001\003\001\004\001\ +\255\255\006\001\007\001\008\001\009\001\010\001\011\001\012\001\ +\013\001\014\001\015\001\016\001\017\001\018\001\019\001\020\001\ +\021\001\255\255\255\255\024\001\025\001\026\001\027\001\028\001\ +\029\001\030\001\031\001\255\255\255\255\255\255\255\255\036\001\ +\037\001\255\255\255\255\040\001\041\001\042\001\043\001\044\001\ +\045\001\046\001\255\255\048\001\049\001\050\001\051\001\255\255\ +\053\001\054\001\055\001\056\001\255\255\255\255\059\001\060\001\ +\061\001\255\255\063\001\064\001\065\001\066\001\067\001\068\001\ +\255\255\070\001\071\001\072\001\073\001\074\001\255\255\076\001\ +\255\255\255\255\255\255\080\001\081\001\082\001\083\001\084\001\ +\085\001\086\001\087\001\255\255\089\001\255\255\091\001\092\001\ +\000\000\094\001\095\001\096\001\255\255\255\255\255\255\100\001\ +\101\001\255\255\103\001\104\001\105\001\106\001\255\255\108\001\ +\109\001\255\255\111\001\255\255\255\255\255\255\115\001\000\001\ +\001\001\002\001\003\001\004\001\255\255\006\001\007\001\008\001\ +\009\001\010\001\011\001\012\001\013\001\014\001\015\001\016\001\ +\017\001\018\001\019\001\020\001\021\001\255\255\255\255\024\001\ +\025\001\026\001\027\001\028\001\029\001\030\001\031\001\255\255\ +\255\255\255\255\255\255\036\001\037\001\255\255\255\255\040\001\ +\041\001\042\001\043\001\044\001\045\001\046\001\255\255\048\001\ +\049\001\050\001\051\001\255\255\053\001\054\001\055\001\056\001\ +\255\255\255\255\059\001\060\001\061\001\255\255\063\001\064\001\ +\065\001\066\001\067\001\068\001\255\255\070\001\071\001\072\001\ +\073\001\074\001\255\255\076\001\255\255\255\255\255\255\080\001\ +\081\001\082\001\083\001\084\001\085\001\086\001\087\001\255\255\ +\089\001\255\255\091\001\092\001\000\000\094\001\095\001\096\001\ +\255\255\255\255\255\255\100\001\101\001\255\255\103\001\104\001\ +\105\001\106\001\255\255\108\001\109\001\255\255\111\001\255\255\ +\255\255\255\255\115\001\255\255\000\001\001\001\002\001\003\001\ +\004\001\255\255\006\001\007\001\008\001\009\001\010\001\011\001\ +\012\001\013\001\014\001\015\001\016\001\017\001\018\001\019\001\ +\020\001\021\001\255\255\255\255\024\001\025\001\026\001\027\001\ +\028\001\029\001\030\001\031\001\255\255\255\255\255\255\255\255\ +\036\001\037\001\255\255\255\255\040\001\041\001\042\001\043\001\ +\044\001\045\001\046\001\255\255\048\001\049\001\050\001\051\001\ +\255\255\053\001\054\001\055\001\056\001\255\255\255\255\059\001\ +\060\001\061\001\255\255\063\001\064\001\065\001\066\001\067\001\ +\068\001\255\255\070\001\071\001\072\001\073\001\074\001\255\255\ +\076\001\255\255\255\255\255\255\080\001\081\001\082\001\083\001\ +\084\001\085\001\086\001\087\001\255\255\089\001\255\255\091\001\ +\092\001\000\000\094\001\095\001\096\001\255\255\255\255\255\255\ +\100\001\101\001\255\255\103\001\104\001\105\001\106\001\255\255\ +\108\001\109\001\255\255\111\001\255\255\255\255\255\255\115\001\ +\000\001\001\001\002\001\003\001\255\255\255\255\255\255\255\255\ +\008\001\009\001\010\001\255\255\255\255\013\001\014\001\015\001\ +\016\001\017\001\018\001\019\001\020\001\021\001\022\001\255\255\ +\024\001\025\001\026\001\027\001\028\001\029\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\036\001\037\001\255\255\255\255\ +\040\001\041\001\042\001\043\001\044\001\045\001\046\001\047\001\ +\048\001\049\001\255\255\051\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\060\001\061\001\255\255\063\001\ +\255\255\255\255\066\001\067\001\068\001\255\255\070\001\071\001\ +\072\001\073\001\074\001\255\255\255\255\255\255\255\255\255\255\ +\080\001\081\001\082\001\083\001\084\001\085\001\086\001\255\255\ +\255\255\089\001\255\255\091\001\092\001\000\000\094\001\095\001\ +\096\001\097\001\098\001\255\255\100\001\255\255\255\255\103\001\ +\104\001\105\001\255\255\255\255\108\001\255\255\255\255\111\001\ +\255\255\255\255\255\255\115\001\000\001\001\001\002\001\003\001\ +\255\255\255\255\255\255\255\255\008\001\009\001\010\001\255\255\ +\255\255\013\001\014\001\015\001\016\001\017\001\018\001\019\001\ +\020\001\021\001\022\001\255\255\024\001\025\001\026\001\027\001\ +\028\001\029\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\036\001\037\001\255\255\255\255\040\001\041\001\042\001\043\001\ +\044\001\045\001\046\001\047\001\048\001\049\001\255\255\051\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\060\001\061\001\255\255\063\001\255\255\255\255\066\001\067\001\ +\068\001\255\255\070\001\071\001\072\001\073\001\074\001\255\255\ +\255\255\255\255\255\255\255\255\080\001\081\001\082\001\083\001\ +\084\001\085\001\086\001\255\255\255\255\089\001\255\255\091\001\ +\092\001\000\000\094\001\095\001\096\001\097\001\098\001\255\255\ +\100\001\255\255\255\255\103\001\104\001\105\001\255\255\255\255\ +\108\001\255\255\255\255\111\001\255\255\255\255\255\255\115\001\ +\255\255\000\001\001\001\002\001\003\001\255\255\255\255\255\255\ +\255\255\008\001\009\001\010\001\255\255\255\255\013\001\014\001\ +\015\001\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ +\255\255\024\001\025\001\026\001\027\001\028\001\029\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\036\001\037\001\255\255\ +\255\255\040\001\041\001\042\001\043\001\044\001\045\001\046\001\ +\255\255\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\060\001\061\001\255\255\ +\063\001\255\255\255\255\066\001\067\001\068\001\255\255\070\001\ +\071\001\072\001\073\001\074\001\255\255\255\255\255\255\255\255\ +\255\255\080\001\255\255\082\001\083\001\084\001\085\001\086\001\ +\255\255\255\255\255\255\255\255\091\001\092\001\000\000\094\001\ +\095\001\096\001\255\255\255\255\255\255\100\001\255\255\255\255\ +\103\001\255\255\105\001\255\255\255\255\108\001\255\255\255\255\ +\111\001\255\255\255\255\255\255\115\001\000\001\001\001\002\001\ +\003\001\255\255\255\255\255\255\255\255\008\001\009\001\010\001\ +\255\255\255\255\013\001\014\001\015\001\016\001\017\001\255\255\ +\019\001\020\001\021\001\255\255\255\255\024\001\025\001\026\001\ +\027\001\028\001\029\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\036\001\037\001\255\255\255\255\040\001\041\001\042\001\ +\043\001\044\001\045\001\046\001\255\255\048\001\049\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\060\001\061\001\255\255\063\001\255\255\255\255\066\001\ +\067\001\068\001\255\255\070\001\071\001\072\001\073\001\074\001\ +\255\255\255\255\255\255\255\255\255\255\080\001\255\255\082\001\ +\083\001\084\001\085\001\086\001\255\255\255\255\255\255\255\255\ +\091\001\092\001\000\000\094\001\095\001\096\001\097\001\255\255\ +\255\255\100\001\255\255\255\255\103\001\255\255\105\001\255\255\ +\255\255\108\001\255\255\255\255\111\001\255\255\255\255\255\255\ +\115\001\000\001\001\001\002\001\003\001\255\255\255\255\255\255\ +\255\255\008\001\009\001\010\001\255\255\255\255\013\001\014\001\ +\015\001\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ +\255\255\024\001\025\001\026\001\027\001\028\001\029\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\036\001\037\001\255\255\ +\255\255\040\001\041\001\042\001\043\001\044\001\045\001\046\001\ +\255\255\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\060\001\061\001\255\255\ +\063\001\255\255\255\255\066\001\067\001\068\001\255\255\070\001\ +\071\001\072\001\073\001\074\001\255\255\255\255\255\255\255\255\ +\255\255\080\001\255\255\082\001\083\001\084\001\085\001\086\001\ +\255\255\255\255\255\255\255\255\091\001\092\001\000\000\094\001\ +\095\001\096\001\255\255\255\255\255\255\100\001\255\255\255\255\ +\103\001\255\255\105\001\255\255\255\255\108\001\255\255\255\255\ +\111\001\255\255\255\255\255\255\115\001\255\255\000\001\001\001\ +\002\001\003\001\255\255\255\255\255\255\255\255\008\001\009\001\ +\010\001\255\255\255\255\013\001\014\001\015\001\016\001\017\001\ +\018\001\019\001\020\001\021\001\255\255\255\255\024\001\025\001\ +\026\001\027\001\028\001\029\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\036\001\037\001\255\255\255\255\040\001\041\001\ +\042\001\043\001\044\001\045\001\046\001\255\255\048\001\049\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\060\001\061\001\255\255\063\001\255\255\255\255\ +\066\001\067\001\068\001\255\255\070\001\071\001\072\001\073\001\ +\074\001\255\255\255\255\255\255\255\255\255\255\080\001\255\255\ +\082\001\083\001\084\001\085\001\086\001\255\255\255\255\255\255\ +\255\255\091\001\092\001\000\000\094\001\095\001\096\001\255\255\ +\255\255\255\255\100\001\255\255\255\255\103\001\255\255\105\001\ +\255\255\255\255\108\001\255\255\255\255\111\001\255\255\255\255\ +\255\255\115\001\000\001\001\001\002\001\003\001\255\255\255\255\ +\255\255\255\255\008\001\009\001\010\001\255\255\255\255\013\001\ +\014\001\015\001\016\001\017\001\018\001\019\001\020\001\021\001\ +\255\255\255\255\024\001\025\001\026\001\027\001\028\001\029\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\036\001\037\001\ +\255\255\255\255\040\001\041\001\042\001\043\001\044\001\045\001\ +\046\001\255\255\048\001\049\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\060\001\061\001\ +\255\255\063\001\255\255\255\255\066\001\067\001\068\001\255\255\ +\070\001\071\001\072\001\073\001\074\001\255\255\255\255\255\255\ +\255\255\255\255\080\001\255\255\082\001\083\001\084\001\085\001\ +\086\001\255\255\255\255\255\255\255\255\091\001\092\001\000\000\ +\094\001\095\001\096\001\255\255\255\255\255\255\100\001\255\255\ +\255\255\103\001\255\255\105\001\255\255\255\255\108\001\255\255\ +\255\255\111\001\255\255\255\255\255\255\115\001\000\001\001\001\ +\002\001\003\001\255\255\255\255\255\255\255\255\008\001\009\001\ +\010\001\255\255\255\255\013\001\014\001\015\001\016\001\017\001\ +\018\001\019\001\020\001\021\001\255\255\255\255\024\001\025\001\ +\026\001\027\001\028\001\029\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\036\001\037\001\255\255\255\255\040\001\041\001\ +\042\001\043\001\044\001\045\001\046\001\255\255\048\001\049\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\060\001\061\001\255\255\063\001\255\255\255\255\ +\066\001\067\001\068\001\255\255\070\001\071\001\072\001\073\001\ +\074\001\255\255\255\255\255\255\255\255\255\255\080\001\255\255\ +\082\001\083\001\084\001\085\001\086\001\255\255\255\255\255\255\ +\255\255\091\001\092\001\000\000\094\001\095\001\096\001\255\255\ +\255\255\255\255\100\001\255\255\255\255\103\001\255\255\105\001\ +\255\255\255\255\108\001\255\255\255\255\111\001\255\255\255\255\ +\255\255\115\001\255\255\000\001\001\001\002\001\003\001\255\255\ +\255\255\255\255\255\255\008\001\009\001\010\001\255\255\255\255\ +\013\001\014\001\015\001\016\001\017\001\018\001\019\001\020\001\ +\021\001\255\255\255\255\024\001\025\001\026\001\027\001\028\001\ +\029\001\255\255\255\255\255\255\255\255\255\255\255\255\036\001\ +\037\001\255\255\255\255\040\001\041\001\042\001\043\001\044\001\ +\045\001\255\255\255\255\048\001\049\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\060\001\ +\061\001\255\255\063\001\255\255\255\255\066\001\067\001\068\001\ +\255\255\070\001\071\001\072\001\073\001\074\001\255\255\255\255\ +\255\255\255\255\255\255\080\001\255\255\082\001\083\001\084\001\ +\085\001\086\001\255\255\255\255\255\255\255\255\091\001\092\001\ +\000\000\094\001\095\001\096\001\097\001\255\255\255\255\100\001\ +\255\255\255\255\103\001\255\255\105\001\255\255\255\255\108\001\ +\255\255\255\255\111\001\255\255\255\255\255\255\115\001\000\001\ +\001\001\002\001\003\001\255\255\255\255\255\255\255\255\008\001\ +\009\001\010\001\255\255\255\255\013\001\014\001\015\001\016\001\ +\017\001\018\001\019\001\020\001\021\001\255\255\255\255\024\001\ +\025\001\026\001\027\001\028\001\029\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\036\001\037\001\255\255\255\255\040\001\ +\041\001\042\001\043\001\044\001\045\001\255\255\255\255\048\001\ +\049\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\060\001\061\001\255\255\063\001\255\255\ +\255\255\066\001\067\001\068\001\255\255\070\001\071\001\072\001\ +\073\001\074\001\255\255\255\255\255\255\255\255\255\255\080\001\ +\255\255\082\001\083\001\084\001\085\001\086\001\255\255\255\255\ +\255\255\255\255\091\001\092\001\000\000\094\001\095\001\096\001\ +\097\001\255\255\255\255\100\001\255\255\255\255\103\001\255\255\ +\105\001\255\255\255\255\108\001\255\255\255\255\111\001\255\255\ +\255\255\255\255\115\001\000\001\001\001\002\001\003\001\255\255\ +\255\255\255\255\255\255\008\001\009\001\010\001\255\255\255\255\ +\013\001\014\001\015\001\016\001\017\001\018\001\019\001\020\001\ +\021\001\255\255\255\255\024\001\025\001\026\001\027\001\028\001\ +\029\001\255\255\255\255\255\255\255\255\255\255\255\255\036\001\ +\037\001\255\255\255\255\040\001\041\001\042\001\043\001\044\001\ +\045\001\255\255\255\255\048\001\049\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\060\001\ +\061\001\255\255\063\001\255\255\255\255\066\001\067\001\068\001\ +\255\255\070\001\071\001\072\001\073\001\074\001\255\255\255\255\ +\255\255\255\255\255\255\080\001\255\255\082\001\083\001\084\001\ +\085\001\086\001\255\255\255\255\255\255\255\255\091\001\092\001\ +\000\000\094\001\095\001\096\001\097\001\255\255\255\255\100\001\ +\255\255\255\255\103\001\255\255\105\001\255\255\255\255\108\001\ +\255\255\255\255\111\001\255\255\255\255\255\255\115\001\255\255\ +\000\001\001\001\002\001\003\001\255\255\255\255\255\255\255\255\ +\008\001\009\001\010\001\255\255\255\255\013\001\014\001\015\001\ +\016\001\017\001\018\001\019\001\020\001\021\001\255\255\255\255\ +\024\001\025\001\026\001\027\001\028\001\029\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\036\001\037\001\255\255\255\255\ +\040\001\041\001\042\001\043\001\044\001\045\001\255\255\255\255\ +\048\001\049\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\060\001\061\001\255\255\063\001\ +\255\255\255\255\066\001\067\001\068\001\255\255\070\001\071\001\ +\072\001\073\001\074\001\255\255\255\255\255\255\255\255\255\255\ +\080\001\255\255\082\001\083\001\084\001\085\001\086\001\255\255\ +\255\255\255\255\255\255\091\001\092\001\000\000\094\001\095\001\ +\096\001\097\001\255\255\255\255\100\001\255\255\255\255\103\001\ +\255\255\105\001\255\255\255\255\108\001\255\255\255\255\111\001\ +\255\255\255\255\255\255\115\001\000\001\001\001\002\001\003\001\ +\255\255\255\255\255\255\255\255\255\255\009\001\010\001\255\255\ +\255\255\013\001\014\001\015\001\016\001\017\001\018\001\019\001\ +\020\001\021\001\255\255\255\255\024\001\025\001\026\001\027\001\ +\028\001\029\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\036\001\037\001\255\255\255\255\040\001\041\001\042\001\043\001\ +\044\001\045\001\046\001\255\255\048\001\049\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\060\001\061\001\255\255\063\001\255\255\255\255\066\001\067\001\ +\068\001\255\255\070\001\071\001\072\001\073\001\074\001\255\255\ +\255\255\255\255\255\255\255\255\080\001\255\255\082\001\083\001\ +\084\001\085\001\086\001\255\255\255\255\255\255\255\255\091\001\ +\092\001\000\000\094\001\095\001\096\001\097\001\255\255\255\255\ +\100\001\255\255\255\255\103\001\255\255\105\001\255\255\255\255\ +\108\001\255\255\255\255\111\001\255\255\255\255\255\255\115\001\ +\000\001\001\001\002\001\003\001\255\255\255\255\255\255\255\255\ +\255\255\009\001\010\001\255\255\255\255\013\001\014\001\015\001\ +\016\001\017\001\018\001\019\001\020\001\021\001\255\255\255\255\ +\024\001\025\001\026\001\027\001\028\001\029\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\036\001\037\001\255\255\255\255\ +\040\001\041\001\042\001\043\001\044\001\045\001\046\001\255\255\ +\048\001\049\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\060\001\061\001\255\255\063\001\ +\255\255\255\255\066\001\067\001\068\001\255\255\070\001\071\001\ +\072\001\073\001\074\001\255\255\255\255\255\255\255\255\255\255\ +\080\001\255\255\082\001\083\001\084\001\085\001\086\001\255\255\ +\255\255\255\255\255\255\091\001\092\001\000\000\094\001\095\001\ +\096\001\097\001\255\255\255\255\100\001\255\255\255\255\103\001\ +\255\255\105\001\255\255\255\255\108\001\255\255\255\255\111\001\ +\255\255\255\255\255\255\115\001\255\255\000\001\001\001\002\001\ +\003\001\255\255\255\255\255\255\255\255\255\255\009\001\010\001\ +\255\255\255\255\013\001\014\001\015\001\016\001\017\001\018\001\ +\019\001\020\001\021\001\255\255\255\255\024\001\025\001\026\001\ +\027\001\028\001\029\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\036\001\037\001\255\255\255\255\040\001\041\001\042\001\ +\043\001\044\001\045\001\046\001\255\255\048\001\049\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\060\001\061\001\255\255\063\001\255\255\255\255\066\001\ +\067\001\068\001\255\255\070\001\071\001\072\001\073\001\074\001\ +\255\255\255\255\255\255\255\255\255\255\080\001\255\255\082\001\ +\083\001\084\001\085\001\086\001\255\255\255\255\255\255\255\255\ +\091\001\092\001\000\000\094\001\095\001\096\001\097\001\255\255\ +\255\255\100\001\255\255\255\255\103\001\255\255\105\001\255\255\ +\255\255\108\001\255\255\255\255\111\001\255\255\255\255\255\255\ +\115\001\000\001\001\001\002\001\003\001\255\255\255\255\255\255\ +\255\255\008\001\009\001\010\001\255\255\255\255\013\001\014\001\ +\015\001\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ +\255\255\024\001\025\001\026\001\027\001\028\001\029\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\036\001\037\001\255\255\ +\255\255\040\001\041\001\042\001\043\001\044\001\255\255\255\255\ +\255\255\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\060\001\061\001\255\255\ +\063\001\255\255\255\255\066\001\067\001\068\001\255\255\070\001\ +\071\001\072\001\073\001\074\001\255\255\255\255\255\255\255\255\ +\255\255\080\001\255\255\082\001\255\255\084\001\085\001\086\001\ +\255\255\255\255\255\255\255\255\091\001\092\001\000\000\094\001\ +\095\001\096\001\097\001\255\255\255\255\255\255\255\255\255\255\ +\103\001\255\255\105\001\255\255\255\255\108\001\255\255\255\255\ +\111\001\255\255\255\255\255\255\115\001\000\001\001\001\002\001\ +\003\001\255\255\255\255\255\255\255\255\008\001\009\001\010\001\ +\255\255\255\255\013\001\014\001\015\001\016\001\017\001\018\001\ +\019\001\020\001\021\001\255\255\255\255\024\001\025\001\026\001\ +\027\001\028\001\029\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\036\001\037\001\255\255\255\255\040\001\041\001\042\001\ +\043\001\044\001\255\255\255\255\255\255\048\001\049\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\060\001\061\001\255\255\063\001\255\255\255\255\066\001\ +\067\001\068\001\255\255\070\001\071\001\072\001\073\001\074\001\ +\255\255\255\255\255\255\255\255\255\255\080\001\255\255\082\001\ +\255\255\084\001\085\001\086\001\255\255\255\255\255\255\255\255\ +\091\001\092\001\000\000\094\001\095\001\096\001\097\001\255\255\ +\255\255\255\255\255\255\255\255\103\001\255\255\105\001\255\255\ +\255\255\108\001\255\255\255\255\111\001\255\255\255\255\255\255\ +\115\001\255\255\000\001\001\001\002\001\003\001\255\255\255\255\ +\255\255\255\255\008\001\009\001\010\001\255\255\255\255\013\001\ +\014\001\015\001\016\001\017\001\018\001\019\001\020\001\021\001\ +\255\255\255\255\024\001\025\001\026\001\027\001\028\001\029\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\036\001\037\001\ +\255\255\255\255\040\001\041\001\042\001\043\001\044\001\255\255\ +\255\255\255\255\048\001\049\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\060\001\061\001\ +\255\255\063\001\255\255\255\255\066\001\067\001\068\001\255\255\ +\070\001\071\001\072\001\073\001\074\001\255\255\255\255\255\255\ +\255\255\255\255\080\001\255\255\082\001\255\255\084\001\085\001\ +\086\001\255\255\255\255\255\255\255\255\091\001\092\001\000\000\ +\094\001\095\001\096\001\097\001\255\255\255\255\255\255\255\255\ +\255\255\103\001\255\255\105\001\255\255\255\255\108\001\255\255\ +\255\255\111\001\255\255\255\255\255\255\115\001\000\001\001\001\ +\002\001\003\001\255\255\255\255\255\255\255\255\008\001\009\001\ +\010\001\255\255\255\255\013\001\014\001\015\001\016\001\017\001\ +\018\001\019\001\020\001\021\001\255\255\255\255\024\001\025\001\ +\026\001\027\001\028\001\029\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\036\001\037\001\255\255\255\255\040\001\041\001\ +\042\001\043\001\044\001\255\255\255\255\255\255\048\001\049\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\060\001\061\001\255\255\063\001\255\255\255\255\ +\066\001\067\001\068\001\255\255\070\001\071\001\072\001\073\001\ +\074\001\255\255\255\255\255\255\255\255\255\255\080\001\255\255\ +\082\001\255\255\084\001\085\001\086\001\255\255\255\255\255\255\ +\255\255\091\001\092\001\000\000\094\001\095\001\096\001\097\001\ +\255\255\255\255\255\255\255\255\255\255\103\001\255\255\105\001\ +\255\255\255\255\108\001\255\255\255\255\111\001\255\255\255\255\ +\255\255\115\001\000\001\001\001\002\001\003\001\255\255\255\255\ +\255\255\255\255\008\001\009\001\010\001\255\255\255\255\013\001\ +\014\001\015\001\016\001\017\001\018\001\019\001\020\001\021\001\ +\255\255\255\255\024\001\025\001\026\001\027\001\028\001\029\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\036\001\037\001\ +\255\255\255\255\040\001\041\001\042\001\043\001\044\001\255\255\ +\255\255\255\255\048\001\049\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\060\001\061\001\ +\255\255\063\001\255\255\255\255\066\001\067\001\068\001\255\255\ +\070\001\071\001\072\001\073\001\074\001\255\255\255\255\255\255\ +\255\255\255\255\080\001\255\255\082\001\255\255\084\001\085\001\ +\086\001\255\255\255\255\255\255\255\255\091\001\092\001\000\000\ +\094\001\095\001\096\001\097\001\255\255\255\255\255\255\255\255\ +\255\255\103\001\255\255\105\001\255\255\255\255\108\001\255\255\ +\255\255\111\001\255\255\255\255\255\255\115\001\255\255\000\001\ +\001\001\002\001\003\001\255\255\255\255\255\255\255\255\008\001\ +\009\001\010\001\255\255\255\255\013\001\014\001\015\001\016\001\ +\017\001\018\001\019\001\020\001\021\001\255\255\255\255\024\001\ +\025\001\026\001\027\001\028\001\029\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\036\001\037\001\255\255\255\255\040\001\ +\041\001\042\001\043\001\044\001\255\255\255\255\255\255\048\001\ +\049\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\060\001\061\001\255\255\063\001\255\255\ +\255\255\066\001\067\001\068\001\255\255\070\001\071\001\072\001\ +\073\001\074\001\255\255\255\255\255\255\255\255\255\255\080\001\ +\255\255\082\001\255\255\084\001\085\001\086\001\255\255\255\255\ +\255\255\255\255\091\001\092\001\000\000\094\001\095\001\096\001\ +\097\001\255\255\255\255\255\255\255\255\255\255\103\001\255\255\ +\105\001\255\255\255\255\108\001\255\255\255\255\111\001\255\255\ +\255\255\255\255\115\001\000\001\001\001\002\001\003\001\255\255\ +\255\255\255\255\255\255\008\001\009\001\010\001\255\255\255\255\ +\013\001\014\001\015\001\016\001\017\001\018\001\019\001\020\001\ +\021\001\255\255\255\255\024\001\025\001\026\001\027\001\028\001\ +\029\001\255\255\255\255\255\255\255\255\255\255\255\255\036\001\ +\037\001\255\255\255\255\040\001\041\001\042\001\043\001\044\001\ +\045\001\046\001\255\255\048\001\049\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\060\001\ +\061\001\255\255\255\255\255\255\255\255\066\001\067\001\068\001\ +\255\255\070\001\255\255\255\255\073\001\074\001\255\255\255\255\ +\255\255\255\255\255\255\080\001\255\255\082\001\255\255\255\255\ +\255\255\086\001\255\255\255\255\255\255\255\255\091\001\092\001\ +\000\000\094\001\095\001\096\001\097\001\255\255\255\255\100\001\ +\255\255\255\255\103\001\255\255\105\001\255\255\255\255\108\001\ +\255\255\255\255\111\001\255\255\255\255\255\255\115\001\000\001\ +\001\001\002\001\003\001\255\255\255\255\255\255\255\255\008\001\ +\009\001\010\001\255\255\255\255\013\001\014\001\255\255\016\001\ +\017\001\018\001\019\001\020\001\021\001\255\255\255\255\024\001\ +\025\001\026\001\027\001\028\001\029\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\036\001\037\001\255\255\255\255\040\001\ +\041\001\042\001\255\255\255\255\255\255\255\255\255\255\048\001\ +\049\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\060\001\061\001\255\255\063\001\255\255\ +\255\255\255\255\067\001\068\001\255\255\070\001\255\255\255\255\ +\073\001\074\001\255\255\255\255\255\255\255\255\255\255\080\001\ +\255\255\082\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\091\001\092\001\000\000\094\001\095\001\096\001\ +\097\001\255\255\255\255\255\255\255\255\255\255\103\001\255\255\ +\105\001\255\255\255\255\108\001\255\255\255\255\111\001\255\255\ +\255\255\255\255\115\001\255\255\000\001\001\001\002\001\003\001\ +\255\255\255\255\255\255\255\255\008\001\009\001\010\001\255\255\ +\255\255\013\001\014\001\255\255\016\001\017\001\018\001\019\001\ +\020\001\021\001\255\255\255\255\024\001\025\001\026\001\027\001\ +\028\001\029\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\036\001\037\001\255\255\255\255\040\001\041\001\042\001\255\255\ +\255\255\255\255\255\255\255\255\048\001\049\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\060\001\061\001\255\255\063\001\255\255\255\255\255\255\067\001\ +\068\001\255\255\070\001\255\255\255\255\073\001\074\001\255\255\ +\255\255\255\255\255\255\255\255\080\001\255\255\082\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\091\001\ +\092\001\000\000\094\001\095\001\096\001\097\001\255\255\255\255\ +\255\255\255\255\255\255\103\001\255\255\105\001\255\255\255\255\ +\108\001\255\255\255\255\111\001\255\255\255\255\255\255\115\001\ +\000\001\001\001\002\001\003\001\255\255\255\255\255\255\255\255\ +\008\001\009\001\010\001\255\255\255\255\013\001\014\001\255\255\ +\016\001\017\001\018\001\019\001\020\001\021\001\255\255\255\255\ +\024\001\025\001\026\001\027\001\028\001\029\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\036\001\037\001\255\255\255\255\ +\040\001\041\001\042\001\255\255\255\255\255\255\255\255\255\255\ +\048\001\049\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\060\001\061\001\255\255\063\001\ +\255\255\255\255\255\255\067\001\068\001\255\255\070\001\255\255\ +\255\255\073\001\074\001\255\255\255\255\255\255\255\255\255\255\ +\080\001\000\000\082\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\091\001\092\001\255\255\094\001\095\001\ +\096\001\097\001\255\255\255\255\255\255\255\255\255\255\103\001\ +\255\255\105\001\255\255\255\255\108\001\255\255\255\255\111\001\ +\255\255\255\255\255\255\115\001\000\001\001\001\002\001\003\001\ +\255\255\255\255\255\255\255\255\008\001\009\001\010\001\255\255\ +\255\255\013\001\014\001\255\255\016\001\017\001\018\001\019\001\ +\020\001\021\001\255\255\255\255\024\001\025\001\026\001\027\001\ +\028\001\029\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\036\001\037\001\255\255\255\255\040\001\041\001\042\001\255\255\ +\255\255\255\255\255\255\255\255\048\001\049\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\060\001\061\001\255\255\063\001\255\255\255\255\255\255\067\001\ +\068\001\000\000\070\001\255\255\255\255\073\001\074\001\255\255\ +\255\255\255\255\255\255\255\255\080\001\255\255\082\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\091\001\ +\092\001\255\255\094\001\095\001\096\001\097\001\255\255\255\255\ +\255\255\255\255\255\255\103\001\255\255\105\001\255\255\255\255\ +\108\001\255\255\255\255\111\001\255\255\255\255\255\255\115\001\ +\255\255\000\001\001\001\002\001\003\001\255\255\255\255\255\255\ +\255\255\008\001\009\001\010\001\255\255\255\255\013\001\014\001\ +\255\255\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ +\255\255\024\001\025\001\026\001\027\001\028\001\029\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\036\001\037\001\255\255\ +\255\255\040\001\041\001\042\001\255\255\255\255\255\255\255\255\ +\255\255\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\000\000\255\255\255\255\255\255\060\001\061\001\255\255\ +\063\001\255\255\255\255\255\255\067\001\068\001\255\255\070\001\ +\255\255\255\255\073\001\074\001\255\255\255\255\255\255\255\255\ +\255\255\080\001\255\255\082\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\091\001\092\001\255\255\094\001\ +\095\001\096\001\097\001\255\255\255\255\255\255\255\255\255\255\ +\103\001\000\001\105\001\255\255\003\001\108\001\255\255\255\255\ +\111\001\008\001\009\001\010\001\115\001\255\255\013\001\014\001\ +\255\255\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ +\255\255\024\001\025\001\026\001\255\255\028\001\029\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\037\001\255\255\ +\255\255\040\001\041\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\000\000\255\255\255\255\255\255\060\001\255\255\255\255\ +\063\001\255\255\255\255\255\255\067\001\068\001\255\255\070\001\ +\255\255\255\255\073\001\074\001\255\255\255\255\255\255\255\255\ +\255\255\080\001\255\255\082\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\091\001\092\001\255\255\094\001\ +\095\001\096\001\097\001\255\255\255\255\255\255\255\255\255\255\ +\103\001\000\001\105\001\255\255\003\001\108\001\255\255\255\255\ +\111\001\008\001\009\001\010\001\115\001\255\255\013\001\014\001\ +\255\255\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ +\255\255\024\001\025\001\026\001\255\255\028\001\029\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\037\001\255\255\ +\255\255\040\001\041\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\000\000\255\255\255\255\255\255\060\001\255\255\255\255\ +\063\001\255\255\255\255\255\255\067\001\068\001\255\255\070\001\ +\255\255\255\255\073\001\074\001\255\255\255\255\255\255\255\255\ +\255\255\080\001\255\255\082\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\091\001\092\001\255\255\094\001\ +\095\001\096\001\097\001\255\255\255\255\255\255\255\255\255\255\ +\103\001\000\001\105\001\255\255\003\001\108\001\255\255\255\255\ +\111\001\008\001\255\255\010\001\115\001\255\255\013\001\014\001\ +\255\255\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ +\255\255\024\001\025\001\026\001\255\255\028\001\029\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\037\001\255\255\ +\255\255\040\001\041\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\000\000\255\255\255\255\255\255\060\001\255\255\255\255\ +\063\001\255\255\255\255\255\255\067\001\068\001\255\255\070\001\ +\255\255\255\255\073\001\074\001\255\255\255\255\255\255\255\255\ +\255\255\080\001\255\255\255\255\255\255\255\255\255\255\000\000\ +\255\255\255\255\255\255\255\255\091\001\092\001\255\255\094\001\ +\095\001\096\001\097\001\255\255\255\255\255\255\255\255\255\255\ +\103\001\000\001\105\001\255\255\003\001\108\001\255\255\255\255\ +\111\001\008\001\255\255\010\001\115\001\255\255\013\001\014\001\ +\255\255\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ +\255\255\024\001\025\001\026\001\255\255\028\001\029\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\037\001\255\255\ +\255\255\040\001\041\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\048\001\049\001\255\255\000\000\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\060\001\255\255\255\255\ +\063\001\255\255\255\255\255\255\067\001\068\001\255\255\070\001\ +\255\255\255\255\073\001\074\001\255\255\255\255\255\255\255\255\ +\255\255\080\001\000\000\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\091\001\092\001\255\255\094\001\ +\095\001\096\001\097\001\255\255\255\255\255\255\255\255\255\255\ +\103\001\000\001\105\001\255\255\003\001\108\001\255\255\255\255\ +\111\001\008\001\255\255\010\001\115\001\255\255\013\001\014\001\ +\255\255\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ +\255\255\024\001\025\001\026\001\255\255\028\001\029\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\037\001\255\255\ +\255\255\040\001\041\001\255\255\255\255\255\255\255\255\000\000\ +\255\255\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\060\001\255\255\255\255\ +\063\001\255\255\255\255\255\255\067\001\068\001\255\255\070\001\ +\255\255\255\255\073\001\074\001\255\255\255\255\255\255\255\255\ +\255\255\080\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\091\001\092\001\255\255\094\001\ +\095\001\096\001\097\001\255\255\255\255\255\255\255\255\255\255\ +\103\001\000\001\105\001\255\255\003\001\108\001\255\255\255\255\ +\111\001\008\001\255\255\010\001\115\001\255\255\013\001\014\001\ +\255\255\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ +\255\255\024\001\025\001\026\001\255\255\028\001\029\001\000\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\037\001\255\255\ +\255\255\040\001\041\001\255\255\013\001\255\255\255\255\000\000\ +\023\001\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\026\001\255\255\028\001\029\001\060\001\255\255\255\255\ +\063\001\255\255\255\255\255\255\067\001\068\001\255\255\070\001\ +\041\001\255\255\073\001\074\001\255\255\000\000\255\255\255\255\ +\055\001\080\001\057\001\058\001\059\001\255\255\061\001\255\255\ +\255\255\064\001\065\001\060\001\091\001\092\001\063\001\094\001\ +\095\001\096\001\097\001\068\001\000\001\255\255\255\255\003\001\ +\103\001\074\001\105\001\255\255\008\001\108\001\010\001\080\001\ +\111\001\013\001\014\001\090\001\115\001\017\001\255\255\019\001\ +\020\001\021\001\097\001\092\001\024\001\025\001\026\001\096\001\ +\028\001\029\001\000\001\255\255\255\255\003\001\109\001\110\001\ +\255\255\037\001\255\255\108\001\040\001\041\001\111\001\013\001\ +\255\255\255\255\000\000\255\255\048\001\049\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\026\001\255\255\028\001\029\001\ +\060\001\255\255\255\255\063\001\255\255\255\255\255\255\067\001\ +\068\001\255\255\070\001\041\001\255\255\073\001\074\001\255\255\ +\000\000\053\001\255\255\055\001\080\001\057\001\058\001\059\001\ +\255\255\061\001\255\255\255\255\064\001\065\001\060\001\091\001\ +\092\001\255\255\094\001\095\001\096\001\097\001\068\001\000\001\ +\255\255\255\255\003\001\103\001\074\001\105\001\255\255\008\001\ +\108\001\010\001\080\001\111\001\013\001\014\001\090\001\115\001\ +\017\001\255\255\019\001\020\001\021\001\097\001\092\001\024\001\ +\025\001\026\001\096\001\028\001\029\001\255\255\255\255\255\255\ +\255\255\109\001\110\001\255\255\037\001\255\255\108\001\040\001\ +\041\001\111\001\255\255\255\255\255\255\000\000\255\255\048\001\ +\049\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\060\001\255\255\255\255\063\001\255\255\ +\255\255\255\255\067\001\068\001\255\255\070\001\255\255\255\255\ +\073\001\074\001\255\255\255\255\255\255\255\255\255\255\080\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\091\001\092\001\255\255\094\001\095\001\096\001\ +\097\001\255\255\255\255\255\255\255\255\255\255\103\001\000\001\ +\105\001\255\255\003\001\108\001\255\255\255\255\111\001\008\001\ +\255\255\010\001\115\001\255\255\013\001\014\001\255\255\255\255\ +\017\001\255\255\019\001\020\001\021\001\255\255\255\255\024\001\ +\025\001\026\001\255\255\028\001\029\001\000\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\037\001\255\255\255\255\040\001\ +\041\001\255\255\013\001\255\255\255\255\000\000\255\255\048\001\ +\049\001\255\255\255\255\255\255\255\255\255\255\255\255\026\001\ +\255\255\028\001\029\001\060\001\255\255\255\255\063\001\255\255\ +\255\255\255\255\067\001\068\001\255\255\070\001\041\001\255\255\ +\073\001\074\001\255\255\000\000\255\255\255\255\055\001\080\001\ +\057\001\058\001\059\001\255\255\061\001\255\255\255\255\064\001\ +\065\001\060\001\091\001\092\001\255\255\094\001\095\001\096\001\ +\097\001\068\001\000\001\255\255\255\255\003\001\103\001\074\001\ +\105\001\255\255\008\001\108\001\010\001\080\001\111\001\013\001\ +\014\001\090\001\115\001\017\001\255\255\019\001\020\001\021\001\ +\097\001\092\001\024\001\025\001\026\001\096\001\028\001\029\001\ +\000\001\255\255\255\255\255\255\109\001\110\001\255\255\037\001\ +\255\255\108\001\040\001\041\001\111\001\013\001\255\255\255\255\ +\000\000\255\255\048\001\049\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\026\001\255\255\028\001\029\001\060\001\255\255\ +\255\255\063\001\255\255\255\255\255\255\067\001\068\001\255\255\ +\070\001\041\001\255\255\073\001\074\001\255\255\000\000\255\255\ +\255\255\255\255\080\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\060\001\091\001\092\001\255\255\ +\094\001\095\001\096\001\097\001\068\001\000\001\255\255\255\255\ +\003\001\103\001\074\001\105\001\255\255\008\001\108\001\010\001\ +\080\001\111\001\013\001\014\001\255\255\115\001\017\001\255\255\ +\019\001\020\001\021\001\255\255\092\001\024\001\025\001\026\001\ +\096\001\028\001\029\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\037\001\255\255\108\001\040\001\041\001\111\001\ +\255\255\255\255\255\255\000\000\255\255\048\001\049\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\060\001\255\255\255\255\063\001\255\255\255\255\255\255\ +\067\001\068\001\255\255\070\001\255\255\255\255\073\001\074\001\ +\255\255\255\255\255\255\255\255\255\255\080\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\091\001\092\001\255\255\094\001\095\001\096\001\097\001\255\255\ +\255\255\255\255\255\255\255\255\103\001\000\001\105\001\255\255\ +\003\001\108\001\255\255\255\255\111\001\008\001\255\255\010\001\ +\115\001\255\255\013\001\014\001\255\255\255\255\017\001\255\255\ +\019\001\020\001\021\001\255\255\255\255\024\001\025\001\026\001\ +\255\255\028\001\029\001\000\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\037\001\255\255\255\255\040\001\041\001\255\255\ +\013\001\255\255\255\255\000\000\255\255\048\001\049\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\026\001\255\255\028\001\ +\029\001\060\001\255\255\255\255\063\001\255\255\255\255\255\255\ +\067\001\068\001\255\255\070\001\041\001\255\255\073\001\074\001\ +\255\255\000\000\255\255\255\255\255\255\080\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\060\001\ +\091\001\092\001\255\255\094\001\095\001\096\001\097\001\068\001\ +\000\001\255\255\255\255\003\001\103\001\074\001\105\001\255\255\ +\008\001\108\001\010\001\080\001\111\001\013\001\014\001\255\255\ +\115\001\017\001\255\255\019\001\020\001\021\001\255\255\092\001\ +\024\001\025\001\026\001\096\001\028\001\029\001\000\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\037\001\255\255\108\001\ +\040\001\041\001\111\001\013\001\255\255\255\255\000\000\255\255\ +\048\001\049\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\026\001\255\255\028\001\029\001\060\001\255\255\255\255\063\001\ +\255\255\255\255\255\255\067\001\068\001\255\255\070\001\041\001\ +\255\255\073\001\074\001\255\255\255\255\255\255\255\255\255\255\ +\080\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\060\001\091\001\092\001\255\255\094\001\095\001\ +\096\001\097\001\068\001\000\001\255\255\255\255\003\001\103\001\ +\074\001\105\001\255\255\008\001\108\001\010\001\080\001\111\001\ +\013\001\014\001\255\255\115\001\017\001\255\255\019\001\020\001\ +\021\001\255\255\092\001\024\001\025\001\026\001\096\001\028\001\ +\029\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\037\001\255\255\108\001\040\001\041\001\111\001\255\255\255\255\ +\255\255\000\000\255\255\048\001\049\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\060\001\ +\255\255\255\255\063\001\255\255\255\255\255\255\067\001\068\001\ +\255\255\070\001\255\255\255\255\073\001\074\001\255\255\255\255\ +\255\255\255\255\255\255\080\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\091\001\092\001\ +\255\255\094\001\095\001\096\001\097\001\255\255\255\255\255\255\ +\255\255\255\255\103\001\000\001\105\001\255\255\003\001\108\001\ +\255\255\255\255\111\001\008\001\255\255\010\001\115\001\255\255\ +\013\001\014\001\255\255\255\255\017\001\255\255\019\001\020\001\ +\021\001\255\255\255\255\024\001\025\001\026\001\255\255\028\001\ +\029\001\000\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\037\001\255\255\255\255\040\001\041\001\255\255\013\001\255\255\ +\255\255\000\000\255\255\048\001\049\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\026\001\255\255\028\001\029\001\060\001\ +\255\255\255\255\063\001\255\255\255\255\255\255\067\001\068\001\ +\255\255\070\001\041\001\255\255\073\001\074\001\255\255\255\255\ +\255\255\255\255\255\255\080\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\060\001\091\001\092\001\ +\255\255\094\001\095\001\096\001\097\001\068\001\000\001\255\255\ +\255\255\003\001\103\001\074\001\105\001\255\255\008\001\108\001\ +\010\001\080\001\111\001\013\001\014\001\255\255\115\001\017\001\ +\255\255\019\001\020\001\021\001\255\255\092\001\024\001\025\001\ +\026\001\096\001\028\001\029\001\006\001\255\255\008\001\255\255\ +\255\255\255\255\255\255\037\001\255\255\108\001\040\001\041\001\ +\111\001\255\255\255\255\255\255\000\000\255\255\048\001\049\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\060\001\255\255\255\255\063\001\255\255\255\255\ +\255\255\067\001\068\001\255\255\070\001\255\255\255\255\073\001\ +\074\001\255\255\255\255\255\255\255\255\055\001\080\001\057\001\ +\058\001\059\001\255\255\061\001\255\255\255\255\064\001\065\001\ +\255\255\091\001\092\001\255\255\094\001\095\001\096\001\097\001\ +\255\255\000\001\255\255\255\255\003\001\103\001\255\255\105\001\ +\255\255\008\001\108\001\010\001\255\255\111\001\013\001\014\001\ +\090\001\115\001\017\001\255\255\019\001\020\001\021\001\097\001\ +\255\255\024\001\025\001\026\001\255\255\028\001\029\001\255\255\ +\255\255\255\255\255\255\109\001\110\001\255\255\037\001\255\255\ +\255\255\040\001\041\001\255\255\255\255\255\255\255\255\000\000\ +\255\255\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\060\001\255\255\255\255\ +\063\001\255\255\255\255\255\255\067\001\068\001\255\255\070\001\ +\255\255\255\255\073\001\074\001\255\255\255\255\255\255\255\255\ +\255\255\080\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\091\001\092\001\255\255\094\001\ +\095\001\096\001\097\001\255\255\255\255\255\255\255\255\255\255\ +\103\001\000\001\105\001\255\255\003\001\108\001\255\255\255\255\ +\111\001\008\001\255\255\010\001\115\001\255\255\013\001\014\001\ +\255\255\255\255\017\001\255\255\019\001\020\001\021\001\255\255\ +\255\255\024\001\025\001\026\001\255\255\028\001\029\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\037\001\255\255\ +\255\255\040\001\041\001\255\255\255\255\255\255\255\255\000\000\ +\255\255\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\060\001\255\255\255\255\ +\063\001\255\255\255\255\255\255\067\001\068\001\255\255\070\001\ +\255\255\255\255\073\001\074\001\255\255\255\255\255\255\255\255\ +\255\255\080\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\091\001\092\001\255\255\094\001\ +\095\001\096\001\097\001\255\255\000\001\255\255\255\255\003\001\ +\103\001\255\255\105\001\255\255\008\001\108\001\010\001\255\255\ +\111\001\013\001\014\001\255\255\115\001\017\001\255\255\019\001\ +\020\001\021\001\255\255\255\255\024\001\025\001\026\001\255\255\ +\028\001\029\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\037\001\255\255\255\255\040\001\041\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\048\001\049\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\000\000\255\255\255\255\ +\060\001\255\255\255\255\063\001\255\255\255\255\255\255\067\001\ +\068\001\255\255\070\001\255\255\255\255\073\001\074\001\255\255\ +\255\255\255\255\255\255\255\255\080\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\091\001\ +\092\001\255\255\094\001\095\001\096\001\097\001\255\255\000\001\ +\255\255\255\255\003\001\103\001\255\255\105\001\255\255\008\001\ +\108\001\010\001\255\255\111\001\013\001\014\001\255\255\115\001\ +\017\001\255\255\019\001\020\001\021\001\255\255\255\255\024\001\ +\025\001\026\001\255\255\028\001\029\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\037\001\255\255\255\255\040\001\ +\041\001\255\255\255\255\255\255\255\255\255\255\255\255\048\001\ +\049\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\000\000\255\255\255\255\060\001\255\255\255\255\063\001\255\255\ +\255\255\255\255\067\001\068\001\255\255\070\001\255\255\255\255\ +\073\001\074\001\255\255\255\255\255\255\255\255\255\255\080\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\091\001\092\001\255\255\094\001\255\255\096\001\ +\097\001\255\255\255\255\255\255\255\255\255\255\103\001\000\001\ +\105\001\255\255\003\001\108\001\255\255\255\255\111\001\008\001\ +\255\255\010\001\115\001\255\255\013\001\014\001\255\255\255\255\ +\017\001\255\255\019\001\020\001\021\001\255\255\255\255\024\001\ +\255\255\026\001\255\255\028\001\029\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\037\001\255\255\255\255\040\001\ +\041\001\255\255\255\255\255\255\255\255\255\255\255\255\048\001\ +\049\001\255\255\255\255\000\000\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\060\001\255\255\255\255\063\001\255\255\ +\255\255\255\255\067\001\068\001\255\255\070\001\255\255\255\255\ +\073\001\074\001\255\255\255\255\255\255\255\255\255\255\080\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\091\001\092\001\255\255\094\001\095\001\096\001\ +\097\001\255\255\255\255\255\255\255\255\255\255\103\001\255\255\ +\105\001\255\255\255\255\108\001\255\255\000\001\111\001\002\001\ +\003\001\004\001\115\001\255\255\255\255\008\001\255\255\255\255\ +\255\255\255\255\013\001\255\255\255\255\255\255\017\001\018\001\ +\019\001\255\255\255\255\255\255\255\255\000\001\255\255\026\001\ +\027\001\028\001\029\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\036\001\255\255\255\255\255\255\040\001\041\001\255\255\ +\000\000\255\255\255\255\255\255\255\255\048\001\049\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\060\001\255\255\255\255\063\001\255\255\255\255\066\001\ +\067\001\068\001\255\255\070\001\255\255\255\255\073\001\074\001\ +\255\255\255\255\255\255\255\255\055\001\080\001\057\001\058\001\ +\059\001\255\255\061\001\255\255\255\255\064\001\065\001\255\255\ +\091\001\092\001\255\255\094\001\095\001\096\001\255\255\255\255\ +\000\001\100\001\002\001\003\001\004\001\255\255\081\001\255\255\ +\008\001\108\001\255\255\255\255\111\001\013\001\089\001\090\001\ +\115\001\017\001\018\001\019\001\255\255\255\255\097\001\255\255\ +\255\255\255\255\026\001\027\001\028\001\029\001\255\255\255\255\ +\008\001\255\255\109\001\110\001\036\001\255\255\255\255\255\255\ +\255\255\041\001\255\255\000\000\255\255\255\255\255\255\023\001\ +\048\001\049\001\255\255\255\255\255\255\255\255\030\001\255\255\ +\255\255\255\255\255\255\255\255\060\001\255\255\255\255\063\001\ +\255\255\255\255\066\001\067\001\068\001\255\255\070\001\255\255\ +\255\255\073\001\074\001\255\255\255\255\255\255\255\255\055\001\ +\080\001\057\001\058\001\059\001\255\255\061\001\255\255\255\255\ +\064\001\065\001\255\255\091\001\092\001\255\255\094\001\095\001\ +\096\001\097\001\255\255\000\001\255\255\002\001\003\001\004\001\ +\255\255\081\001\255\255\008\001\108\001\255\255\255\255\111\001\ +\013\001\089\001\090\001\115\001\017\001\018\001\019\001\255\255\ +\255\255\097\001\255\255\255\255\255\255\026\001\027\001\028\001\ +\029\001\255\255\106\001\255\255\255\255\109\001\110\001\036\001\ +\255\255\255\255\255\255\255\255\041\001\255\255\000\000\255\255\ +\255\255\255\255\255\255\048\001\049\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\060\001\ +\255\255\255\255\063\001\255\255\255\255\066\001\067\001\068\001\ +\255\255\070\001\255\255\255\255\255\255\074\001\255\255\255\255\ +\255\255\255\255\255\255\080\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\091\001\092\001\ +\255\255\094\001\095\001\096\001\097\001\255\255\255\255\255\255\ +\000\001\255\255\002\001\003\001\004\001\255\255\255\255\108\001\ +\008\001\255\255\111\001\255\255\255\255\013\001\115\001\255\255\ +\255\255\017\001\018\001\019\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\026\001\027\001\028\001\029\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\036\001\255\255\255\255\255\255\ +\255\255\041\001\255\255\000\000\255\255\255\255\255\255\255\255\ +\048\001\049\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\060\001\255\255\255\255\063\001\ +\255\255\255\255\066\001\067\001\068\001\255\255\070\001\255\255\ +\255\255\255\255\074\001\255\255\255\255\255\255\255\255\055\001\ +\080\001\057\001\058\001\059\001\255\255\061\001\255\255\255\255\ +\064\001\065\001\255\255\091\001\092\001\255\255\094\001\095\001\ +\096\001\097\001\074\001\000\001\255\255\002\001\003\001\004\001\ +\255\255\081\001\255\255\008\001\108\001\255\255\255\255\111\001\ +\013\001\089\001\090\001\115\001\017\001\018\001\019\001\000\000\ +\255\255\097\001\255\255\255\255\255\255\026\001\027\001\028\001\ +\029\001\255\255\255\255\255\255\255\255\109\001\110\001\036\001\ +\255\255\255\255\255\255\255\255\041\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\048\001\049\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\060\001\ +\255\255\255\255\063\001\255\255\255\255\066\001\067\001\068\001\ +\255\255\070\001\255\255\255\255\255\255\074\001\255\255\255\255\ +\255\255\000\000\055\001\080\001\057\001\058\001\059\001\255\255\ +\061\001\255\255\255\255\064\001\065\001\255\255\091\001\092\001\ +\255\255\094\001\095\001\096\001\097\001\255\255\000\001\255\255\ +\002\001\003\001\004\001\255\255\081\001\255\255\008\001\108\001\ +\255\255\255\255\111\001\013\001\089\001\090\001\115\001\017\001\ +\018\001\019\001\255\255\255\255\097\001\255\255\255\255\255\255\ +\026\001\027\001\028\001\029\001\255\255\255\255\255\255\108\001\ +\109\001\110\001\036\001\000\000\255\255\255\255\255\255\041\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\048\001\049\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\060\001\255\255\255\255\063\001\255\255\255\255\ +\066\001\067\001\068\001\255\255\070\001\255\255\255\255\255\255\ +\074\001\255\255\255\255\255\255\255\255\255\255\080\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\091\001\092\001\255\255\094\001\095\001\096\001\097\001\ +\255\255\000\000\255\255\000\001\255\255\002\001\003\001\255\255\ +\255\255\255\255\108\001\008\001\255\255\111\001\255\255\255\255\ +\013\001\115\001\255\255\255\255\017\001\018\001\019\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\026\001\027\001\028\001\ +\029\001\255\255\255\255\255\255\255\255\255\255\255\255\036\001\ +\255\255\255\255\255\255\255\255\041\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\048\001\049\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\000\000\255\255\255\255\255\255\060\001\ +\255\255\255\255\063\001\255\255\255\255\066\001\067\001\068\001\ +\255\255\070\001\255\255\255\255\006\001\074\001\008\001\000\001\ +\255\255\255\255\003\001\080\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\013\001\255\255\091\001\092\001\ +\017\001\094\001\095\001\096\001\097\001\255\255\255\255\255\255\ +\255\255\026\001\027\001\028\001\029\001\255\255\255\255\108\001\ +\255\255\255\255\111\001\255\255\255\255\255\255\115\001\255\255\ +\041\001\255\255\255\255\255\255\255\255\055\001\255\255\057\001\ +\058\001\059\001\255\255\061\001\255\255\255\255\064\001\065\001\ +\255\255\000\001\255\255\060\001\003\001\255\255\063\001\255\255\ +\255\255\066\001\067\001\068\001\255\255\255\255\013\001\255\255\ +\073\001\074\001\017\001\255\255\255\255\255\255\255\255\080\001\ +\090\001\255\255\092\001\026\001\027\001\028\001\029\001\097\001\ +\255\255\255\255\255\255\092\001\000\000\094\001\255\255\096\001\ +\097\001\255\255\041\001\109\001\110\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\108\001\255\255\255\255\111\001\255\255\ +\255\255\255\255\115\001\000\001\255\255\060\001\003\001\255\255\ +\063\001\255\255\255\255\066\001\067\001\068\001\255\255\255\255\ +\013\001\255\255\073\001\074\001\017\001\255\255\255\255\255\255\ +\255\255\080\001\255\255\255\255\255\255\026\001\027\001\028\001\ +\029\001\255\255\255\255\255\255\255\255\092\001\255\255\094\001\ +\255\255\096\001\097\001\255\255\041\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\108\001\255\255\255\255\ +\111\001\255\255\255\255\255\255\115\001\255\255\255\255\060\001\ +\255\255\000\001\063\001\255\255\003\001\066\001\067\001\068\001\ +\255\255\255\255\255\255\255\255\073\001\074\001\013\001\255\255\ +\255\255\255\255\017\001\080\001\019\001\255\255\255\255\255\255\ +\255\255\255\255\000\000\026\001\027\001\028\001\029\001\092\001\ +\255\255\094\001\255\255\096\001\097\001\255\255\255\255\255\255\ +\255\255\255\255\041\001\255\255\255\255\255\255\255\255\108\001\ +\255\255\255\255\111\001\255\255\255\255\255\255\115\001\255\255\ +\255\255\255\255\255\255\000\001\255\255\060\001\003\001\255\255\ +\063\001\255\255\255\255\255\255\067\001\068\001\255\255\255\255\ +\013\001\255\255\073\001\074\001\017\001\255\255\255\255\255\255\ +\255\255\080\001\255\255\255\255\255\255\026\001\027\001\028\001\ +\029\001\255\255\255\255\255\255\255\255\092\001\255\255\094\001\ +\255\255\096\001\097\001\255\255\041\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\108\001\255\255\255\255\ +\111\001\000\000\255\255\255\255\115\001\255\255\255\255\060\001\ +\255\255\255\255\063\001\255\255\255\255\255\255\067\001\068\001\ +\255\255\255\255\255\255\255\255\073\001\074\001\055\001\255\255\ +\057\001\058\001\059\001\080\001\061\001\255\255\063\001\064\001\ +\065\001\255\255\255\255\255\255\255\255\255\255\255\255\092\001\ +\255\255\094\001\255\255\096\001\097\001\078\001\255\255\255\255\ +\081\001\255\255\255\255\255\255\255\255\255\255\255\255\108\001\ +\089\001\090\001\111\001\255\255\000\001\255\255\115\001\003\001\ +\097\001\005\001\006\001\007\001\008\001\255\255\255\255\011\001\ +\012\001\013\001\255\255\255\255\109\001\110\001\255\255\019\001\ +\255\255\255\255\255\255\023\001\255\255\255\255\026\001\255\255\ +\028\001\029\001\030\001\031\001\032\001\033\001\034\001\035\001\ +\036\001\255\255\255\255\039\001\040\001\041\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\048\001\049\001\050\001\051\001\ +\052\001\053\001\054\001\055\001\056\001\057\001\058\001\059\001\ +\060\001\061\001\000\000\063\001\064\001\065\001\255\255\067\001\ +\068\001\069\001\070\001\071\001\072\001\255\255\074\001\075\001\ +\076\001\077\001\078\001\255\255\080\001\081\001\255\255\255\255\ +\084\001\085\001\255\255\087\001\088\001\089\001\090\001\091\001\ +\092\001\093\001\255\255\095\001\096\001\097\001\255\255\099\001\ +\255\255\101\001\102\001\255\255\104\001\255\255\106\001\107\001\ +\108\001\109\001\110\001\111\001\112\001\255\255\114\001\005\001\ +\006\001\007\001\255\255\255\255\255\255\011\001\012\001\013\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\028\001\029\001\ +\030\001\031\001\032\001\033\001\034\001\255\255\255\255\255\255\ +\255\255\039\001\255\255\041\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\050\001\255\255\052\001\053\001\ +\054\001\055\001\056\001\255\255\255\255\059\001\060\001\255\255\ +\255\255\063\001\064\001\065\001\255\255\000\000\068\001\069\001\ +\255\255\071\001\072\001\255\255\074\001\255\255\076\001\255\255\ +\078\001\255\255\080\001\255\255\255\255\255\255\084\001\085\001\ +\255\255\087\001\255\255\255\255\255\255\255\255\005\001\006\001\ +\007\001\255\255\096\001\097\001\011\001\012\001\013\001\101\001\ +\255\255\255\255\255\255\255\255\106\001\107\001\108\001\109\001\ +\110\001\111\001\255\255\255\255\114\001\028\001\029\001\030\001\ +\031\001\032\001\033\001\034\001\255\255\255\255\255\255\255\255\ +\039\001\255\255\041\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\050\001\255\255\052\001\053\001\054\001\ +\055\001\056\001\255\255\255\255\059\001\060\001\255\255\255\255\ +\063\001\064\001\065\001\255\255\255\255\068\001\069\001\255\255\ +\071\001\072\001\255\255\074\001\255\255\076\001\255\255\078\001\ +\255\255\080\001\255\255\000\000\255\255\084\001\085\001\255\255\ +\087\001\000\000\055\001\255\255\057\001\058\001\059\001\255\255\ +\061\001\255\255\097\001\064\001\065\001\255\255\101\001\255\255\ +\255\255\255\255\255\255\106\001\107\001\108\001\109\001\110\001\ +\111\001\255\255\255\255\114\001\081\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\089\001\090\001\255\255\005\001\ +\006\001\007\001\255\255\255\255\097\001\011\001\012\001\013\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\109\001\110\001\255\255\255\255\255\255\255\255\028\001\029\001\ +\030\001\031\001\032\001\033\001\034\001\255\255\255\255\255\255\ +\255\255\039\001\255\255\041\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\050\001\255\255\052\001\053\001\ +\054\001\055\001\056\001\255\255\255\255\059\001\060\001\255\255\ +\255\255\063\001\064\001\065\001\255\255\255\255\068\001\069\001\ +\255\255\071\001\072\001\255\255\074\001\000\000\076\001\255\255\ +\078\001\255\255\080\001\255\255\255\255\255\255\084\001\085\001\ +\255\255\087\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\097\001\255\255\255\255\255\255\101\001\ +\255\255\255\255\255\255\255\255\106\001\107\001\108\001\109\001\ +\110\001\111\001\255\255\255\255\114\001\000\001\255\255\255\255\ +\255\255\004\001\255\255\006\001\255\255\008\001\255\255\010\001\ +\255\255\012\001\255\255\014\001\015\001\255\255\017\001\018\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\027\001\028\001\255\255\030\001\031\001\000\000\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\050\001\ +\051\001\052\001\053\001\255\255\055\001\056\001\255\255\255\255\ +\059\001\255\255\255\255\255\255\255\255\064\001\065\001\066\001\ +\255\255\255\255\255\255\255\255\071\001\255\255\073\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\081\001\255\255\ +\255\255\084\001\255\255\255\255\255\255\255\255\089\001\000\000\ +\091\001\092\001\255\255\094\001\095\001\255\255\097\001\255\255\ +\255\255\255\255\101\001\000\001\255\255\104\001\255\255\106\001\ +\255\255\000\001\109\001\110\001\255\255\004\001\113\001\006\001\ +\013\001\008\001\255\255\010\001\255\255\012\001\255\255\014\001\ +\015\001\255\255\017\001\018\001\255\255\026\001\255\255\028\001\ +\029\001\255\255\255\255\255\255\027\001\255\255\255\255\030\001\ +\031\001\255\255\255\255\255\255\041\001\255\255\255\255\255\255\ +\255\255\000\000\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\050\001\051\001\255\255\053\001\060\001\ +\055\001\056\001\255\255\255\255\059\001\255\255\067\001\068\001\ +\255\255\064\001\065\001\066\001\255\255\074\001\255\255\255\255\ +\071\001\255\255\073\001\080\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\081\001\255\255\255\255\084\001\255\255\092\001\ +\255\255\255\255\089\001\096\001\091\001\092\001\255\255\094\001\ +\095\001\255\255\097\001\000\000\255\255\255\255\101\001\108\001\ +\255\255\104\001\111\001\106\001\255\255\000\001\109\001\110\001\ +\003\001\004\001\113\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\013\001\014\001\255\255\255\255\255\255\255\255\ +\019\001\255\255\255\255\255\255\255\255\255\255\255\255\026\001\ +\255\255\028\001\029\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\041\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\048\001\049\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\060\001\255\255\255\255\063\001\255\255\255\255\066\001\ +\067\001\068\001\255\255\070\001\255\255\000\001\255\255\074\001\ +\003\001\004\001\000\000\255\255\255\255\080\001\255\255\255\255\ +\255\255\255\255\013\001\014\001\255\255\255\255\255\255\255\255\ +\019\001\092\001\255\255\094\001\255\255\096\001\097\001\026\001\ +\255\255\028\001\029\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\108\001\255\255\255\255\111\001\255\255\041\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\048\001\049\001\255\255\ +\255\255\255\255\255\255\000\000\255\255\255\255\255\255\000\001\ +\255\255\060\001\003\001\004\001\063\001\255\255\255\255\066\001\ +\067\001\068\001\255\255\070\001\013\001\014\001\255\255\074\001\ +\255\255\255\255\019\001\255\255\255\255\080\001\255\255\255\255\ +\255\255\026\001\255\255\028\001\029\001\255\255\255\255\255\255\ +\255\255\092\001\255\255\094\001\255\255\096\001\097\001\255\255\ +\041\001\255\255\255\255\255\255\255\255\000\000\255\255\048\001\ +\049\001\108\001\255\255\255\255\111\001\255\255\255\255\255\255\ +\255\255\000\001\255\255\060\001\003\001\004\001\063\001\255\255\ +\255\255\255\255\067\001\068\001\255\255\070\001\013\001\014\001\ +\255\255\074\001\255\255\255\255\019\001\255\255\255\255\080\001\ +\255\255\255\255\255\255\026\001\255\255\028\001\029\001\255\255\ +\255\255\255\255\255\255\092\001\255\255\094\001\255\255\096\001\ +\097\001\255\255\041\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\048\001\049\001\108\001\255\255\255\255\111\001\255\255\ +\255\255\255\255\255\255\000\001\255\255\060\001\003\001\004\001\ +\063\001\000\000\255\255\255\255\067\001\068\001\255\255\070\001\ +\013\001\014\001\255\255\074\001\255\255\255\255\019\001\255\255\ +\255\255\080\001\255\255\255\255\255\255\026\001\255\255\028\001\ +\029\001\255\255\255\255\255\255\255\255\092\001\255\255\094\001\ +\255\255\096\001\097\001\255\255\041\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\048\001\049\001\108\001\255\255\255\255\ +\111\001\255\255\255\255\255\255\255\255\255\255\255\255\060\001\ +\255\255\255\255\063\001\000\000\255\255\255\255\067\001\068\001\ +\255\255\070\001\255\255\255\255\255\255\074\001\055\001\255\255\ +\057\001\058\001\059\001\080\001\061\001\255\255\255\255\064\001\ +\065\001\255\255\000\001\255\255\255\255\003\001\255\255\092\001\ +\255\255\094\001\008\001\096\001\097\001\255\255\255\255\013\001\ +\081\001\255\255\255\255\255\255\255\255\019\001\255\255\108\001\ +\089\001\090\001\111\001\255\255\026\001\255\255\028\001\029\001\ +\097\001\255\255\255\255\255\255\255\255\000\000\255\255\255\255\ +\255\255\255\255\040\001\041\001\109\001\110\001\255\255\255\255\ +\255\255\255\255\255\255\000\001\255\255\255\255\003\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\060\001\255\255\ +\013\001\063\001\255\255\255\255\066\001\067\001\068\001\255\255\ +\255\255\255\255\255\255\073\001\074\001\026\001\027\001\028\001\ +\029\001\255\255\080\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\041\001\255\255\092\001\000\000\ +\255\255\255\255\096\001\097\001\255\255\000\001\100\001\255\255\ +\003\001\255\255\255\255\255\255\255\255\255\255\108\001\060\001\ +\255\255\111\001\013\001\064\001\255\255\066\001\067\001\068\001\ +\255\255\255\255\255\255\255\255\073\001\074\001\255\255\026\001\ +\027\001\028\001\029\001\080\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\041\001\092\001\ +\255\255\094\001\255\255\096\001\097\001\255\255\255\255\100\001\ +\255\255\000\000\255\255\255\255\255\255\255\255\255\255\108\001\ +\109\001\060\001\111\001\255\255\255\255\064\001\255\255\066\001\ +\067\001\068\001\255\255\255\255\255\255\255\255\073\001\074\001\ +\255\255\000\001\255\255\255\255\003\001\080\001\255\255\255\255\ +\255\255\008\001\255\255\255\255\255\255\255\255\013\001\255\255\ +\255\255\092\001\255\255\094\001\019\001\096\001\097\001\255\255\ +\255\255\100\001\000\000\026\001\255\255\028\001\029\001\255\255\ +\255\255\108\001\109\001\255\255\111\001\255\255\255\255\255\255\ +\255\255\040\001\041\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\000\001\255\255\060\001\003\001\255\255\ +\063\001\255\255\255\255\066\001\067\001\068\001\255\255\255\255\ +\013\001\255\255\073\001\074\001\255\255\255\255\019\001\000\000\ +\255\255\080\001\255\255\255\255\255\255\026\001\027\001\028\001\ +\029\001\255\255\255\255\255\255\255\255\092\001\255\255\255\255\ +\255\255\096\001\097\001\255\255\041\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\048\001\255\255\108\001\255\255\255\255\ +\111\001\255\255\255\255\255\255\255\255\000\001\255\255\060\001\ +\003\001\255\255\063\001\255\255\255\255\255\255\067\001\068\001\ +\255\255\070\001\013\001\255\255\000\000\074\001\255\255\255\255\ +\019\001\255\255\255\255\080\001\255\255\255\255\255\255\026\001\ +\255\255\028\001\029\001\255\255\255\255\255\255\255\255\092\001\ +\255\255\094\001\255\255\096\001\097\001\040\001\041\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\048\001\049\001\108\001\ +\255\255\255\255\111\001\255\255\255\255\255\255\255\255\000\001\ +\255\255\060\001\003\001\255\255\063\001\255\255\255\255\008\001\ +\255\255\068\001\255\255\070\001\013\001\255\255\255\255\074\001\ +\255\255\255\255\019\001\255\255\255\255\080\001\255\255\255\255\ +\255\255\026\001\255\255\028\001\029\001\255\255\255\255\000\000\ +\255\255\092\001\255\255\255\255\255\255\096\001\097\001\255\255\ +\041\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\108\001\255\255\255\255\111\001\255\255\255\255\255\255\ +\255\255\000\001\255\255\060\001\003\001\255\255\063\001\255\255\ +\255\255\255\255\067\001\068\001\255\255\255\255\013\001\255\255\ +\255\255\074\001\255\255\255\255\019\001\255\255\255\255\080\001\ +\255\255\255\255\255\255\026\001\000\000\028\001\029\001\255\255\ +\255\255\255\255\255\255\092\001\255\255\000\000\255\255\096\001\ +\097\001\255\255\041\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\000\001\108\001\255\255\003\001\111\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\060\001\255\255\013\001\ +\063\001\255\255\255\255\255\255\067\001\068\001\255\255\255\255\ +\255\255\255\255\255\255\074\001\026\001\255\255\028\001\029\001\ +\255\255\080\001\255\255\255\255\255\255\255\255\255\255\000\000\ +\255\255\255\255\040\001\041\001\255\255\092\001\255\255\255\255\ +\255\255\096\001\097\001\255\255\255\255\255\255\255\255\000\001\ +\255\255\255\255\003\001\255\255\255\255\108\001\060\001\255\255\ +\111\001\063\001\255\255\255\255\013\001\067\001\068\001\255\255\ +\255\255\255\255\019\001\255\255\074\001\255\255\255\255\255\255\ +\255\255\026\001\080\001\028\001\029\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\000\000\255\255\092\001\255\255\ +\041\001\255\255\096\001\097\001\255\255\000\000\255\255\255\255\ +\255\255\255\255\255\255\255\255\000\001\255\255\108\001\003\001\ +\255\255\111\001\255\255\060\001\255\255\255\255\063\001\255\255\ +\255\255\013\001\067\001\068\001\255\255\255\255\255\255\019\001\ +\255\255\074\001\255\255\255\255\255\255\255\255\026\001\080\001\ +\028\001\029\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\092\001\255\255\041\001\255\255\096\001\ +\097\001\255\255\000\000\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\108\001\255\255\255\255\111\001\255\255\ +\060\001\255\255\255\255\063\001\255\255\255\255\255\255\067\001\ +\068\001\255\255\255\255\255\255\255\255\255\255\074\001\000\001\ +\255\255\255\255\003\001\255\255\080\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\013\001\255\255\255\255\255\255\ +\092\001\255\255\019\001\255\255\096\001\097\001\255\255\000\000\ +\255\255\026\001\255\255\028\001\029\001\255\255\255\255\255\255\ +\108\001\255\255\255\255\111\001\255\255\255\255\255\255\255\255\ +\041\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\000\001\255\255\255\255\003\001\ +\255\255\255\255\255\255\060\001\255\255\000\001\063\001\255\255\ +\255\255\013\001\067\001\068\001\255\255\008\001\255\255\019\001\ +\000\000\074\001\013\001\255\255\255\255\255\255\026\001\080\001\ +\028\001\029\001\000\000\255\255\255\255\255\255\255\255\026\001\ +\255\255\028\001\029\001\092\001\255\255\041\001\255\255\096\001\ +\097\001\255\255\255\255\255\255\255\255\255\255\041\001\255\255\ +\255\255\255\255\255\255\108\001\255\255\255\255\111\001\000\001\ +\060\001\255\255\003\001\063\001\255\255\255\255\255\255\067\001\ +\068\001\060\001\255\255\255\255\013\001\255\255\074\001\066\001\ +\067\001\068\001\019\001\255\255\080\001\255\255\255\255\074\001\ +\255\255\026\001\255\255\028\001\029\001\080\001\255\255\255\255\ +\092\001\255\255\255\255\000\000\096\001\097\001\255\255\255\255\ +\041\001\092\001\255\255\255\255\255\255\096\001\255\255\255\255\ +\108\001\255\255\255\255\111\001\000\001\255\255\255\255\255\255\ +\255\255\108\001\255\255\060\001\111\001\000\001\063\001\255\255\ +\003\001\013\001\067\001\068\001\255\255\255\255\255\255\255\255\ +\255\255\074\001\013\001\255\255\255\255\255\255\026\001\080\001\ +\028\001\029\001\255\255\255\255\000\000\255\255\255\255\026\001\ +\255\255\028\001\029\001\092\001\255\255\041\001\000\000\096\001\ +\097\001\255\255\255\255\255\255\255\255\040\001\041\001\255\255\ +\255\255\255\255\255\255\108\001\255\255\255\255\111\001\255\255\ +\060\001\255\255\000\001\063\001\255\255\003\001\066\001\067\001\ +\068\001\060\001\255\255\255\255\063\001\255\255\074\001\013\001\ +\255\255\068\001\255\255\255\255\080\001\255\255\255\255\074\001\ +\255\255\255\255\255\255\255\255\026\001\080\001\028\001\029\001\ +\092\001\255\255\255\255\255\255\096\001\097\001\255\255\255\255\ +\255\255\092\001\255\255\041\001\000\000\096\001\097\001\255\255\ +\108\001\255\255\255\255\111\001\255\255\255\255\255\255\000\001\ +\255\255\108\001\003\001\255\255\111\001\255\255\060\001\255\255\ +\255\255\063\001\255\255\255\255\013\001\067\001\068\001\255\255\ +\255\255\255\255\255\255\255\255\074\001\255\255\255\255\255\255\ +\255\255\026\001\080\001\028\001\029\001\255\255\255\255\255\255\ +\000\000\255\255\255\255\255\255\255\255\255\255\092\001\255\255\ +\041\001\000\000\096\001\097\001\255\255\255\255\255\255\255\255\ +\000\001\255\255\255\255\255\255\255\255\255\255\108\001\255\255\ +\008\001\111\001\000\001\060\001\255\255\013\001\063\001\255\255\ +\255\255\255\255\067\001\068\001\255\255\255\255\255\255\013\001\ +\255\255\074\001\026\001\255\255\028\001\029\001\255\255\080\001\ +\255\255\255\255\255\255\255\255\026\001\255\255\028\001\029\001\ +\255\255\041\001\000\000\092\001\255\255\255\255\255\255\096\001\ +\097\001\255\255\255\255\041\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\108\001\060\001\255\255\111\001\063\001\ +\255\255\255\255\255\255\067\001\068\001\255\255\060\001\255\255\ +\255\255\063\001\074\001\000\001\255\255\067\001\068\001\255\255\ +\080\001\255\255\255\255\255\255\074\001\255\255\000\000\255\255\ +\013\001\255\255\080\001\255\255\092\001\255\255\255\255\255\255\ +\096\001\097\001\255\255\255\255\255\255\026\001\092\001\028\001\ +\029\001\255\255\096\001\097\001\108\001\255\255\255\255\111\001\ +\255\255\255\255\255\255\255\255\041\001\255\255\108\001\255\255\ +\255\255\111\001\255\255\255\255\000\001\255\255\255\255\003\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\000\001\060\001\ +\255\255\013\001\063\001\255\255\255\255\255\255\067\001\068\001\ +\255\255\255\255\255\255\013\001\255\255\074\001\026\001\255\255\ +\028\001\029\001\255\255\080\001\255\255\255\255\255\255\255\255\ +\026\001\255\255\028\001\029\001\255\255\041\001\255\255\092\001\ +\255\255\255\255\255\255\096\001\097\001\255\255\255\255\041\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\108\001\ +\060\001\255\255\111\001\063\001\255\255\255\255\255\255\255\255\ +\068\001\255\255\060\001\255\255\000\001\063\001\074\001\255\255\ +\255\255\067\001\068\001\255\255\080\001\255\255\255\255\255\255\ +\074\001\013\001\255\255\255\255\255\255\255\255\080\001\255\255\ +\092\001\255\255\255\255\255\255\096\001\097\001\026\001\255\255\ +\028\001\029\001\092\001\255\255\255\255\255\255\096\001\097\001\ +\108\001\255\255\255\255\111\001\255\255\041\001\255\255\255\255\ +\000\001\255\255\108\001\255\255\255\255\111\001\255\255\255\255\ +\255\255\000\001\255\255\255\255\255\255\013\001\255\255\255\255\ +\060\001\255\255\255\255\063\001\255\255\255\255\013\001\067\001\ +\068\001\255\255\026\001\255\255\028\001\029\001\074\001\255\255\ +\255\255\255\255\255\255\026\001\080\001\028\001\029\001\255\255\ +\255\255\041\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\092\001\255\255\041\001\255\255\096\001\097\001\255\255\255\255\ +\255\255\255\255\000\001\255\255\060\001\255\255\255\255\063\001\ +\108\001\255\255\255\255\111\001\068\001\060\001\255\255\013\001\ +\063\001\255\255\074\001\255\255\255\255\068\001\255\255\255\255\ +\080\001\255\255\255\255\074\001\026\001\255\255\028\001\029\001\ +\255\255\080\001\255\255\255\255\092\001\255\255\255\255\255\255\ +\096\001\097\001\255\255\041\001\255\255\092\001\000\001\255\255\ +\255\255\096\001\097\001\255\255\108\001\255\255\255\255\111\001\ +\255\255\255\255\255\255\013\001\255\255\108\001\060\001\255\255\ +\111\001\063\001\255\255\255\255\255\255\255\255\068\001\255\255\ +\026\001\255\255\028\001\029\001\074\001\255\255\255\255\255\255\ +\255\255\255\255\080\001\255\255\255\255\255\255\255\255\041\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\092\001\255\255\ +\255\255\255\255\096\001\097\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\060\001\255\255\255\255\063\001\108\001\255\255\ +\255\255\111\001\068\001\255\255\255\255\255\255\255\255\255\255\ +\074\001\255\255\255\255\255\255\255\255\255\255\080\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\092\001\000\001\255\255\255\255\096\001\097\001\ +\005\001\006\001\007\001\008\001\255\255\255\255\011\001\012\001\ +\013\001\014\001\108\001\255\255\255\255\111\001\019\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\026\001\255\255\028\001\ +\029\001\030\001\031\001\032\001\033\001\034\001\035\001\255\255\ +\255\255\255\255\039\001\255\255\041\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\048\001\049\001\050\001\051\001\052\001\ +\053\001\054\001\055\001\056\001\255\255\255\255\059\001\060\001\ +\255\255\255\255\063\001\064\001\065\001\066\001\255\255\068\001\ +\069\001\070\001\071\001\072\001\255\255\074\001\255\255\076\001\ +\077\001\078\001\255\255\080\001\081\001\255\255\255\255\084\001\ +\085\001\255\255\087\001\255\255\089\001\090\001\255\255\092\001\ +\093\001\255\255\255\255\096\001\097\001\255\255\099\001\255\255\ +\101\001\102\001\255\255\104\001\255\255\106\001\107\001\108\001\ +\109\001\110\001\111\001\112\001\000\001\114\001\255\255\255\255\ +\255\255\005\001\006\001\007\001\008\001\255\255\255\255\011\001\ +\012\001\255\255\255\255\255\255\255\255\255\255\255\255\019\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\026\001\255\255\ +\028\001\255\255\030\001\031\001\032\001\033\001\034\001\035\001\ +\255\255\255\255\255\255\039\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\048\001\049\001\050\001\051\001\ +\052\001\053\001\054\001\055\001\056\001\255\255\255\255\059\001\ +\060\001\255\255\255\255\063\001\064\001\065\001\255\255\255\255\ +\068\001\069\001\070\001\071\001\072\001\255\255\074\001\255\255\ +\076\001\077\001\078\001\255\255\255\255\081\001\255\255\255\255\ +\084\001\085\001\255\255\087\001\255\255\089\001\090\001\255\255\ +\255\255\093\001\255\255\255\255\255\255\097\001\255\255\099\001\ +\255\255\101\001\102\001\255\255\104\001\255\255\106\001\107\001\ +\255\255\109\001\110\001\111\001\112\001\255\255\114\001\000\001\ +\001\001\002\001\255\255\255\255\005\001\006\001\007\001\255\255\ +\009\001\255\255\011\001\012\001\255\255\255\255\015\001\016\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\027\001\255\255\255\255\030\001\031\001\032\001\ +\033\001\034\001\255\255\036\001\255\255\255\255\039\001\255\255\ +\255\255\042\001\043\001\044\001\045\001\046\001\047\001\255\255\ +\255\255\050\001\255\255\052\001\053\001\054\001\055\001\056\001\ +\255\255\255\255\059\001\255\255\061\001\255\255\063\001\064\001\ +\065\001\255\255\255\255\255\255\069\001\255\255\071\001\072\001\ +\255\255\074\001\255\255\076\001\255\255\078\001\255\255\255\255\ +\255\255\082\001\083\001\084\001\085\001\086\001\087\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\094\001\255\255\255\255\ +\255\255\098\001\255\255\100\001\101\001\255\255\255\255\255\255\ +\255\255\106\001\107\001\255\255\109\001\110\001\000\001\001\001\ +\002\001\114\001\255\255\005\001\006\001\007\001\255\255\009\001\ +\255\255\011\001\012\001\255\255\255\255\015\001\016\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\027\001\255\255\255\255\030\001\031\001\032\001\033\001\ +\034\001\255\255\036\001\255\255\255\255\039\001\255\255\255\255\ +\042\001\043\001\044\001\045\001\046\001\047\001\255\255\255\255\ +\050\001\255\255\052\001\053\001\054\001\055\001\056\001\255\255\ +\255\255\059\001\255\255\061\001\255\255\063\001\064\001\065\001\ +\255\255\255\255\255\255\069\001\255\255\071\001\072\001\255\255\ +\074\001\255\255\076\001\255\255\078\001\255\255\255\255\255\255\ +\082\001\083\001\084\001\085\001\086\001\087\001\255\255\255\255\ +\255\255\255\255\255\255\055\001\094\001\057\001\058\001\059\001\ +\098\001\061\001\100\001\101\001\064\001\065\001\255\255\255\255\ +\106\001\107\001\255\255\109\001\110\001\000\001\255\255\255\255\ +\114\001\255\255\005\001\006\001\007\001\081\001\255\255\255\255\ +\011\001\012\001\013\001\255\255\255\255\089\001\090\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\097\001\255\255\026\001\ +\255\255\028\001\029\001\030\001\031\001\032\001\033\001\034\001\ +\255\255\109\001\110\001\255\255\039\001\255\255\041\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\050\001\ +\255\255\052\001\053\001\054\001\055\001\056\001\255\255\255\255\ +\059\001\060\001\255\255\255\255\063\001\064\001\065\001\255\255\ +\255\255\068\001\069\001\255\255\071\001\072\001\255\255\074\001\ +\255\255\076\001\255\255\078\001\255\255\080\001\255\255\255\255\ +\255\255\084\001\085\001\000\001\087\001\255\255\255\255\255\255\ +\005\001\006\001\007\001\255\255\255\255\096\001\011\001\012\001\ +\255\255\255\255\101\001\255\255\255\255\255\255\255\255\106\001\ +\107\001\108\001\109\001\110\001\111\001\255\255\255\255\114\001\ +\255\255\030\001\031\001\032\001\033\001\034\001\255\255\255\255\ +\255\255\255\255\039\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\050\001\255\255\052\001\ +\053\001\054\001\055\001\056\001\255\255\255\255\059\001\255\255\ +\255\255\255\255\063\001\064\001\065\001\255\255\255\255\255\255\ +\069\001\255\255\071\001\072\001\255\255\255\255\255\255\076\001\ +\255\255\078\001\255\255\255\255\255\255\255\255\255\255\084\001\ +\085\001\000\001\087\001\255\255\255\255\255\255\005\001\006\001\ +\007\001\094\001\255\255\255\255\011\001\012\001\255\255\255\255\ +\101\001\255\255\255\255\255\255\255\255\106\001\107\001\255\255\ +\109\001\110\001\255\255\255\255\255\255\114\001\255\255\030\001\ +\031\001\032\001\033\001\034\001\255\255\255\255\255\255\255\255\ +\039\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\050\001\255\255\052\001\053\001\054\001\ +\055\001\056\001\255\255\255\255\059\001\255\255\255\255\255\255\ +\063\001\064\001\065\001\255\255\255\255\255\255\069\001\255\255\ +\071\001\072\001\255\255\255\255\255\255\076\001\255\255\078\001\ +\255\255\255\255\255\255\255\255\255\255\084\001\085\001\000\001\ +\087\001\255\255\255\255\255\255\005\001\006\001\007\001\094\001\ +\255\255\255\255\011\001\012\001\255\255\255\255\101\001\255\255\ +\255\255\255\255\255\255\106\001\107\001\255\255\109\001\110\001\ +\255\255\255\255\255\255\114\001\255\255\030\001\031\001\032\001\ +\033\001\034\001\255\255\255\255\255\255\255\255\039\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\050\001\255\255\052\001\053\001\054\001\055\001\056\001\ +\255\255\255\255\059\001\255\255\255\255\255\255\063\001\064\001\ +\065\001\255\255\255\255\255\255\069\001\255\255\071\001\072\001\ +\255\255\255\255\255\255\076\001\255\255\078\001\255\255\255\255\ +\255\255\255\255\255\255\084\001\085\001\000\001\087\001\255\255\ +\255\255\255\255\005\001\006\001\007\001\094\001\255\255\255\255\ +\011\001\012\001\255\255\255\255\101\001\255\255\255\255\255\255\ +\255\255\106\001\107\001\255\255\109\001\110\001\255\255\255\255\ +\255\255\114\001\255\255\030\001\031\001\032\001\033\001\034\001\ +\255\255\255\255\255\255\255\255\039\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\050\001\ +\255\255\052\001\053\001\054\001\055\001\056\001\255\255\255\255\ +\059\001\255\255\255\255\255\255\063\001\064\001\065\001\255\255\ +\255\255\255\255\069\001\255\255\071\001\072\001\255\255\255\255\ +\255\255\076\001\255\255\078\001\255\255\255\255\255\255\255\255\ +\255\255\084\001\085\001\255\255\087\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\094\001\003\001\004\001\005\001\255\255\ +\255\255\255\255\101\001\255\255\011\001\255\255\013\001\106\001\ +\107\001\255\255\109\001\110\001\019\001\020\001\021\001\114\001\ +\255\255\024\001\025\001\026\001\255\255\028\001\029\001\030\001\ +\255\255\032\001\033\001\034\001\035\001\255\255\255\255\255\255\ +\039\001\040\001\041\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\048\001\049\001\255\255\255\255\052\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\063\001\064\001\255\255\255\255\255\255\000\001\069\001\070\001\ +\255\255\004\001\255\255\074\001\075\001\076\001\077\001\078\001\ +\079\001\080\001\255\255\082\001\255\255\255\255\017\001\255\255\ +\019\001\088\001\255\255\022\001\255\255\255\255\093\001\026\001\ +\027\001\255\255\255\255\255\255\099\001\255\255\255\255\102\001\ +\103\001\036\001\105\001\106\001\107\001\108\001\109\001\255\255\ +\111\001\112\001\113\001\114\001\115\001\048\001\049\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\060\001\255\255\255\255\255\255\064\001\255\255\066\001\ +\067\001\068\001\255\255\070\001\255\255\255\255\073\001\255\255\ +\255\255\255\255\000\001\001\001\002\001\255\255\255\255\255\255\ +\006\001\007\001\255\255\009\001\255\255\255\255\012\001\090\001\ +\091\001\015\001\016\001\255\255\095\001\255\255\097\001\255\255\ +\255\255\100\001\255\255\255\255\255\255\027\001\028\001\255\255\ +\030\001\031\001\109\001\255\255\111\001\255\255\036\001\255\255\ +\255\255\255\255\255\255\255\255\042\001\043\001\044\001\045\001\ +\046\001\047\001\255\255\255\255\050\001\255\255\052\001\053\001\ +\255\255\055\001\056\001\255\255\255\255\059\001\255\255\061\001\ +\255\255\255\255\064\001\065\001\255\255\255\255\255\255\255\255\ +\255\255\071\001\072\001\255\255\074\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\082\001\083\001\084\001\085\001\ +\086\001\087\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\094\001\255\255\255\255\097\001\098\001\255\255\100\001\101\001\ +\255\255\255\255\255\255\255\255\106\001\255\255\108\001\109\001\ +\110\001\000\001\001\001\002\001\255\255\255\255\255\255\006\001\ +\007\001\255\255\009\001\255\255\255\255\012\001\255\255\255\255\ +\015\001\016\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\027\001\028\001\255\255\030\001\ +\031\001\255\255\255\255\255\255\255\255\036\001\255\255\255\255\ +\255\255\255\255\255\255\042\001\043\001\044\001\045\001\046\001\ +\047\001\255\255\255\255\050\001\255\255\052\001\053\001\255\255\ +\055\001\056\001\255\255\255\255\059\001\255\255\061\001\255\255\ +\255\255\064\001\065\001\255\255\255\255\255\255\255\255\255\255\ +\071\001\072\001\255\255\074\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\082\001\083\001\084\001\085\001\086\001\ +\087\001\255\255\255\255\255\255\255\255\255\255\255\255\094\001\ +\255\255\255\255\097\001\098\001\255\255\100\001\101\001\255\255\ +\255\255\255\255\255\255\106\001\255\255\108\001\109\001\110\001\ +\000\001\001\001\002\001\255\255\255\255\255\255\006\001\007\001\ +\255\255\009\001\255\255\255\255\012\001\255\255\255\255\015\001\ +\016\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\027\001\028\001\255\255\030\001\031\001\ +\255\255\255\255\255\255\255\255\036\001\255\255\255\255\255\255\ +\255\255\255\255\042\001\043\001\044\001\045\001\046\001\047\001\ +\255\255\255\255\050\001\255\255\052\001\053\001\255\255\055\001\ +\056\001\255\255\255\255\059\001\255\255\061\001\255\255\255\255\ +\064\001\065\001\255\255\255\255\255\255\255\255\255\255\071\001\ +\072\001\255\255\074\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\082\001\083\001\084\001\085\001\086\001\087\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\094\001\255\255\ +\255\255\097\001\098\001\255\255\100\001\101\001\255\255\255\255\ +\255\255\255\255\106\001\255\255\108\001\109\001\110\001\000\001\ +\001\001\002\001\255\255\255\255\255\255\006\001\007\001\255\255\ +\009\001\255\255\255\255\012\001\255\255\255\255\015\001\016\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\027\001\028\001\255\255\030\001\031\001\255\255\ +\255\255\255\255\255\255\036\001\255\255\255\255\255\255\255\255\ +\255\255\042\001\043\001\044\001\045\001\046\001\047\001\255\255\ +\255\255\050\001\255\255\052\001\053\001\255\255\055\001\056\001\ +\255\255\255\255\059\001\255\255\061\001\255\255\255\255\064\001\ +\065\001\255\255\255\255\255\255\255\255\255\255\071\001\072\001\ +\255\255\074\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\082\001\083\001\084\001\085\001\086\001\087\001\255\255\ +\255\255\000\001\255\255\255\255\255\255\094\001\255\255\006\001\ +\097\001\098\001\255\255\100\001\101\001\012\001\255\255\255\255\ +\015\001\106\001\255\255\255\255\109\001\110\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\028\001\255\255\030\001\ +\031\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\050\001\255\255\052\001\053\001\255\255\ +\055\001\056\001\255\255\255\255\059\001\255\255\000\001\255\255\ +\255\255\064\001\065\001\255\255\006\001\255\255\255\255\255\255\ +\071\001\255\255\012\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\084\001\255\255\255\255\ +\255\255\255\255\028\001\255\255\030\001\031\001\255\255\094\001\ +\255\255\255\255\097\001\255\255\255\255\255\255\101\001\255\255\ +\255\255\255\255\255\255\106\001\255\255\255\255\109\001\110\001\ +\050\001\255\255\052\001\053\001\255\255\055\001\056\001\255\255\ +\255\255\059\001\255\255\000\001\255\255\255\255\064\001\065\001\ +\255\255\006\001\255\255\255\255\255\255\071\001\255\255\012\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\084\001\255\255\255\255\255\255\255\255\028\001\ +\255\255\030\001\031\001\255\255\255\255\255\255\255\255\097\001\ +\255\255\255\255\255\255\101\001\255\255\255\255\255\255\255\255\ +\106\001\255\255\255\255\109\001\110\001\050\001\255\255\052\001\ +\053\001\255\255\055\001\056\001\255\255\255\255\059\001\255\255\ +\000\001\255\255\255\255\064\001\065\001\255\255\006\001\255\255\ +\255\255\255\255\071\001\255\255\012\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\084\001\ +\255\255\255\255\255\255\255\255\028\001\255\255\030\001\031\001\ +\255\255\255\255\255\255\255\255\097\001\255\255\255\255\255\255\ +\101\001\255\255\255\255\255\255\255\255\106\001\255\255\255\255\ +\109\001\110\001\050\001\255\255\052\001\053\001\255\255\055\001\ +\056\001\255\255\255\255\059\001\255\255\000\001\255\255\255\255\ +\064\001\065\001\255\255\006\001\255\255\255\255\255\255\071\001\ +\255\255\012\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\084\001\255\255\255\255\255\255\ +\255\255\028\001\255\255\030\001\031\001\255\255\255\255\255\255\ +\255\255\097\001\255\255\255\255\255\255\101\001\255\255\255\255\ +\255\255\255\255\106\001\255\255\255\255\109\001\110\001\050\001\ +\255\255\052\001\053\001\255\255\055\001\056\001\255\255\255\255\ +\059\001\255\255\000\001\255\255\255\255\064\001\065\001\255\255\ +\006\001\255\255\255\255\255\255\071\001\255\255\012\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\084\001\255\255\255\255\255\255\255\255\028\001\255\255\ +\030\001\031\001\255\255\255\255\255\255\255\255\097\001\255\255\ +\255\255\255\255\101\001\255\255\255\255\255\255\255\255\106\001\ +\255\255\255\255\109\001\110\001\050\001\255\255\052\001\053\001\ +\255\255\055\001\056\001\255\255\255\255\059\001\255\255\000\001\ +\255\255\255\255\064\001\065\001\255\255\006\001\255\255\255\255\ +\255\255\071\001\255\255\012\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\084\001\255\255\ +\255\255\255\255\255\255\028\001\255\255\030\001\031\001\255\255\ +\255\255\255\255\255\255\097\001\255\255\255\255\255\255\101\001\ +\255\255\255\255\255\255\255\255\106\001\255\255\255\255\109\001\ +\110\001\050\001\255\255\052\001\053\001\255\255\055\001\056\001\ +\255\255\255\255\059\001\255\255\255\255\255\255\255\255\064\001\ +\065\001\005\001\006\001\007\001\255\255\255\255\071\001\011\001\ +\012\001\013\001\014\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\084\001\255\255\255\255\255\255\255\255\ +\028\001\029\001\030\001\031\001\032\001\033\001\034\001\255\255\ +\097\001\255\255\255\255\039\001\101\001\041\001\255\255\255\255\ +\255\255\106\001\255\255\255\255\109\001\110\001\050\001\255\255\ +\052\001\053\001\054\001\055\001\056\001\255\255\255\255\059\001\ +\060\001\255\255\255\255\063\001\064\001\065\001\255\255\255\255\ +\068\001\069\001\255\255\071\001\072\001\255\255\074\001\255\255\ +\076\001\255\255\078\001\255\255\080\001\255\255\255\255\255\255\ +\084\001\085\001\255\255\087\001\255\255\089\001\255\255\255\255\ +\005\001\006\001\007\001\255\255\096\001\255\255\011\001\012\001\ +\013\001\101\001\255\255\255\255\255\255\255\255\106\001\107\001\ +\108\001\109\001\110\001\111\001\255\255\255\255\114\001\028\001\ +\029\001\030\001\031\001\032\001\033\001\034\001\255\255\255\255\ +\255\255\255\255\039\001\255\255\041\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\050\001\255\255\052\001\ +\053\001\054\001\055\001\056\001\255\255\255\255\059\001\060\001\ +\255\255\255\255\063\001\064\001\065\001\255\255\255\255\068\001\ +\069\001\255\255\071\001\072\001\255\255\074\001\255\255\076\001\ +\255\255\078\001\255\255\080\001\255\255\255\255\255\255\084\001\ +\085\001\255\255\087\001\255\255\255\255\255\255\005\001\006\001\ +\007\001\255\255\255\255\096\001\011\001\012\001\255\255\255\255\ +\101\001\255\255\255\255\255\255\255\255\106\001\107\001\108\001\ +\109\001\110\001\111\001\255\255\255\255\114\001\255\255\030\001\ +\031\001\032\001\033\001\034\001\255\255\255\255\255\255\255\255\ +\039\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\050\001\255\255\052\001\053\001\054\001\ +\055\001\056\001\255\255\255\255\059\001\255\255\255\255\255\255\ +\063\001\064\001\065\001\255\255\255\255\255\255\069\001\255\255\ +\071\001\072\001\255\255\255\255\255\255\076\001\255\255\078\001\ +\255\255\255\255\255\255\255\255\255\255\084\001\085\001\255\255\ +\087\001\255\255\255\255\255\255\255\255\092\001\005\001\006\001\ +\007\001\255\255\255\255\010\001\011\001\012\001\101\001\255\255\ +\255\255\255\255\255\255\106\001\107\001\255\255\109\001\110\001\ +\255\255\255\255\255\255\114\001\255\255\255\255\255\255\030\001\ +\031\001\032\001\033\001\034\001\255\255\255\255\255\255\255\255\ +\039\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\050\001\255\255\052\001\053\001\054\001\ +\055\001\056\001\255\255\255\255\059\001\255\255\255\255\255\255\ +\063\001\064\001\065\001\255\255\255\255\255\255\069\001\255\255\ +\071\001\072\001\255\255\255\255\255\255\076\001\255\255\078\001\ +\255\255\255\255\255\255\255\255\255\255\084\001\085\001\255\255\ +\087\001\255\255\255\255\005\001\006\001\007\001\255\255\255\255\ +\255\255\011\001\012\001\255\255\255\255\255\255\101\001\255\255\ +\255\255\255\255\255\255\106\001\107\001\255\255\109\001\110\001\ +\026\001\255\255\255\255\114\001\030\001\031\001\032\001\033\001\ +\034\001\255\255\255\255\255\255\255\255\039\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\050\001\255\255\052\001\053\001\054\001\055\001\056\001\255\255\ +\255\255\059\001\255\255\255\255\255\255\063\001\064\001\065\001\ +\255\255\255\255\255\255\069\001\255\255\071\001\072\001\255\255\ +\255\255\255\255\076\001\255\255\078\001\255\255\255\255\255\255\ +\255\255\255\255\084\001\085\001\255\255\087\001\255\255\255\255\ +\005\001\006\001\007\001\255\255\255\255\255\255\011\001\012\001\ +\255\255\255\255\255\255\101\001\255\255\255\255\255\255\255\255\ +\106\001\107\001\255\255\109\001\110\001\255\255\255\255\255\255\ +\114\001\030\001\031\001\032\001\033\001\034\001\255\255\255\255\ +\255\255\255\255\039\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\050\001\255\255\052\001\ +\053\001\054\001\055\001\056\001\255\255\255\255\059\001\255\255\ +\255\255\255\255\063\001\064\001\065\001\255\255\255\255\255\255\ +\069\001\255\255\071\001\072\001\255\255\255\255\255\255\076\001\ +\255\255\078\001\255\255\255\255\255\255\255\255\083\001\084\001\ +\085\001\255\255\087\001\255\255\255\255\005\001\006\001\007\001\ +\255\255\255\255\255\255\011\001\012\001\255\255\255\255\255\255\ +\101\001\255\255\255\255\255\255\255\255\106\001\107\001\255\255\ +\109\001\110\001\255\255\255\255\255\255\114\001\030\001\031\001\ +\032\001\033\001\034\001\255\255\255\255\255\255\255\255\039\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\050\001\255\255\052\001\053\001\054\001\055\001\ +\056\001\255\255\255\255\059\001\255\255\255\255\255\255\063\001\ +\064\001\065\001\255\255\255\255\255\255\069\001\255\255\071\001\ +\072\001\255\255\255\255\255\255\076\001\255\255\078\001\255\255\ +\255\255\255\255\255\255\255\255\084\001\085\001\255\255\087\001\ +\255\255\255\255\255\255\255\255\092\001\005\001\006\001\007\001\ +\255\255\255\255\010\001\011\001\012\001\101\001\255\255\255\255\ +\255\255\255\255\106\001\107\001\255\255\109\001\110\001\255\255\ +\255\255\255\255\114\001\255\255\255\255\255\255\030\001\031\001\ +\032\001\033\001\034\001\255\255\255\255\255\255\255\255\039\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\050\001\255\255\052\001\053\001\054\001\055\001\ +\056\001\255\255\255\255\059\001\255\255\255\255\255\255\063\001\ +\064\001\065\001\255\255\255\255\255\255\069\001\255\255\071\001\ +\072\001\255\255\255\255\255\255\076\001\255\255\078\001\255\255\ +\255\255\255\255\255\255\255\255\084\001\085\001\255\255\087\001\ +\255\255\255\255\255\255\005\001\006\001\007\001\255\255\255\255\ +\255\255\011\001\012\001\255\255\255\255\101\001\255\255\255\255\ +\255\255\255\255\106\001\107\001\022\001\109\001\110\001\255\255\ +\255\255\255\255\114\001\255\255\030\001\031\001\032\001\033\001\ +\034\001\255\255\255\255\255\255\255\255\039\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\050\001\255\255\052\001\053\001\054\001\055\001\056\001\255\255\ +\255\255\059\001\255\255\255\255\255\255\063\001\064\001\065\001\ +\255\255\255\255\255\255\069\001\255\255\071\001\072\001\255\255\ +\255\255\255\255\076\001\255\255\078\001\255\255\255\255\255\255\ +\255\255\255\255\084\001\085\001\255\255\087\001\255\255\255\255\ +\005\001\006\001\007\001\255\255\255\255\255\255\011\001\012\001\ +\255\255\255\255\255\255\101\001\255\255\255\255\255\255\255\255\ +\106\001\107\001\255\255\109\001\110\001\026\001\255\255\255\255\ +\114\001\030\001\031\001\032\001\033\001\034\001\255\255\255\255\ +\255\255\255\255\039\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\050\001\255\255\052\001\ +\053\001\054\001\055\001\056\001\255\255\255\255\059\001\255\255\ +\255\255\255\255\063\001\064\001\065\001\255\255\255\255\255\255\ +\069\001\255\255\071\001\072\001\255\255\255\255\255\255\076\001\ +\255\255\078\001\255\255\255\255\255\255\255\255\255\255\084\001\ +\085\001\255\255\087\001\255\255\255\255\005\001\006\001\007\001\ +\255\255\255\255\255\255\011\001\012\001\255\255\255\255\255\255\ +\101\001\255\255\255\255\255\255\255\255\106\001\107\001\255\255\ +\109\001\110\001\255\255\255\255\255\255\114\001\030\001\031\001\ +\032\001\033\001\034\001\255\255\255\255\255\255\255\255\039\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\050\001\255\255\052\001\053\001\054\001\055\001\ +\056\001\255\255\255\255\059\001\255\255\255\255\255\255\063\001\ +\064\001\065\001\255\255\255\255\255\255\069\001\255\255\071\001\ +\072\001\255\255\255\255\255\255\076\001\255\255\078\001\255\255\ +\255\255\255\255\255\255\255\255\084\001\085\001\255\255\087\001\ +\255\255\255\255\005\001\006\001\007\001\255\255\255\255\255\255\ +\011\001\012\001\255\255\255\255\255\255\101\001\255\255\255\255\ +\255\255\255\255\106\001\107\001\255\255\109\001\110\001\255\255\ +\255\255\255\255\114\001\030\001\031\001\032\001\033\001\034\001\ +\255\255\255\255\255\255\255\255\039\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\050\001\ +\255\255\052\001\053\001\054\001\055\001\056\001\255\255\255\255\ +\059\001\255\255\255\255\255\255\063\001\064\001\065\001\255\255\ +\255\255\255\255\069\001\255\255\071\001\072\001\255\255\255\255\ +\255\255\076\001\255\255\078\001\255\255\255\255\255\255\255\255\ +\255\255\084\001\085\001\255\255\087\001\255\255\255\255\005\001\ +\006\001\007\001\255\255\255\255\255\255\011\001\012\001\255\255\ +\255\255\255\255\101\001\255\255\255\255\255\255\255\255\106\001\ +\107\001\255\255\109\001\110\001\255\255\255\255\255\255\114\001\ +\030\001\031\001\032\001\033\001\034\001\255\255\255\255\255\255\ +\255\255\039\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\050\001\255\255\052\001\053\001\ +\054\001\055\001\056\001\255\255\255\255\059\001\255\255\255\255\ +\255\255\063\001\064\001\065\001\255\255\255\255\255\255\069\001\ +\255\255\071\001\072\001\255\255\255\255\006\001\076\001\255\255\ +\078\001\255\255\255\255\012\001\255\255\014\001\084\001\085\001\ +\017\001\087\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\027\001\255\255\255\255\030\001\031\001\101\001\ +\255\255\255\255\255\255\255\255\106\001\107\001\255\255\109\001\ +\110\001\255\255\255\255\255\255\114\001\255\255\255\255\255\255\ +\255\255\050\001\051\001\255\255\053\001\255\255\055\001\056\001\ +\255\255\255\255\059\001\255\255\255\255\255\255\255\255\064\001\ +\065\001\255\255\006\001\255\255\255\255\255\255\071\001\255\255\ +\012\001\255\255\014\001\255\255\255\255\017\001\255\255\255\255\ +\081\001\255\255\255\255\084\001\255\255\255\255\255\255\027\001\ +\089\001\255\255\030\001\031\001\255\255\006\001\255\255\255\255\ +\097\001\255\255\255\255\012\001\101\001\014\001\255\255\104\001\ +\255\255\106\001\255\255\255\255\109\001\110\001\050\001\051\001\ +\255\255\053\001\255\255\055\001\056\001\030\001\031\001\059\001\ +\255\255\255\255\255\255\255\255\064\001\065\001\255\255\255\255\ +\255\255\255\255\255\255\071\001\255\255\255\255\255\255\255\255\ +\255\255\050\001\051\001\255\255\053\001\081\001\055\001\056\001\ +\084\001\255\255\059\001\255\255\255\255\089\001\255\255\064\001\ +\065\001\255\255\255\255\255\255\255\255\097\001\071\001\255\255\ +\073\001\101\001\255\255\255\255\104\001\255\255\106\001\255\255\ +\081\001\109\001\110\001\084\001\255\255\255\255\006\001\255\255\ +\089\001\255\255\255\255\255\255\012\001\255\255\014\001\255\255\ +\097\001\255\255\255\255\255\255\101\001\255\255\255\255\104\001\ +\255\255\106\001\255\255\027\001\109\001\110\001\030\001\031\001\ +\255\255\006\001\255\255\255\255\255\255\255\255\255\255\012\001\ +\255\255\014\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\050\001\051\001\255\255\053\001\027\001\055\001\ +\056\001\030\001\031\001\059\001\255\255\255\255\255\255\255\255\ +\064\001\065\001\255\255\255\255\255\255\255\255\255\255\071\001\ +\255\255\255\255\255\255\255\255\255\255\050\001\051\001\255\255\ +\053\001\081\001\055\001\056\001\084\001\255\255\059\001\255\255\ +\255\255\089\001\255\255\064\001\065\001\255\255\006\001\255\255\ +\255\255\097\001\071\001\255\255\012\001\101\001\255\255\255\255\ +\104\001\255\255\106\001\255\255\081\001\109\001\110\001\084\001\ +\255\255\255\255\255\255\255\255\089\001\255\255\030\001\031\001\ +\255\255\006\001\255\255\255\255\097\001\255\255\255\255\012\001\ +\101\001\255\255\255\255\104\001\255\255\106\001\255\255\255\255\ +\109\001\110\001\050\001\051\001\255\255\053\001\255\255\055\001\ +\056\001\030\001\031\001\059\001\255\255\255\255\255\255\255\255\ +\064\001\065\001\255\255\255\255\255\255\255\255\255\255\071\001\ +\255\255\073\001\255\255\255\255\255\255\050\001\051\001\255\255\ +\053\001\081\001\055\001\056\001\084\001\255\255\059\001\255\255\ +\255\255\089\001\255\255\064\001\065\001\255\255\006\001\255\255\ +\255\255\097\001\071\001\255\255\012\001\101\001\255\255\255\255\ +\104\001\255\255\106\001\255\255\081\001\109\001\110\001\084\001\ +\255\255\255\255\255\255\255\255\089\001\255\255\030\001\031\001\ +\255\255\006\001\255\255\255\255\097\001\255\255\255\255\012\001\ +\101\001\255\255\255\255\104\001\255\255\106\001\255\255\255\255\ +\109\001\110\001\050\001\051\001\255\255\053\001\255\255\055\001\ +\056\001\030\001\031\001\059\001\255\255\255\255\255\255\255\255\ +\064\001\065\001\255\255\255\255\255\255\255\255\255\255\071\001\ +\255\255\255\255\255\255\255\255\255\255\050\001\051\001\255\255\ +\053\001\081\001\055\001\056\001\084\001\255\255\059\001\255\255\ +\255\255\089\001\255\255\064\001\065\001\255\255\006\001\255\255\ +\255\255\097\001\071\001\255\255\012\001\101\001\255\255\255\255\ +\104\001\255\255\106\001\255\255\081\001\109\001\110\001\084\001\ +\255\255\255\255\255\255\255\255\089\001\255\255\030\001\031\001\ +\255\255\255\255\255\255\255\255\097\001\255\255\255\255\255\255\ +\101\001\255\255\255\255\104\001\255\255\106\001\255\255\255\255\ +\109\001\110\001\050\001\051\001\255\255\053\001\255\255\055\001\ +\056\001\255\255\255\255\059\001\255\255\255\255\255\255\255\255\ +\064\001\065\001\255\255\255\255\006\001\255\255\255\255\071\001\ +\255\255\255\255\012\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\081\001\255\255\255\255\084\001\255\255\255\255\255\255\ +\255\255\089\001\028\001\255\255\030\001\031\001\255\255\255\255\ +\255\255\097\001\255\255\255\255\255\255\101\001\255\255\255\255\ +\104\001\255\255\106\001\255\255\255\255\109\001\110\001\255\255\ +\050\001\255\255\052\001\053\001\255\255\055\001\056\001\255\255\ +\255\255\059\001\255\255\255\255\255\255\255\255\064\001\065\001\ +\255\255\255\255\255\255\006\001\255\255\071\001\255\255\010\001\ +\255\255\012\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\084\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\028\001\092\001\030\001\031\001\255\255\255\255\097\001\ +\255\255\255\255\255\255\101\001\255\255\255\255\255\255\255\255\ +\106\001\255\255\255\255\109\001\110\001\255\255\255\255\050\001\ +\255\255\052\001\053\001\255\255\055\001\056\001\255\255\255\255\ +\059\001\255\255\255\255\255\255\255\255\064\001\065\001\255\255\ +\006\001\255\255\255\255\255\255\071\001\255\255\012\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\006\001\007\001\255\255\ +\255\255\084\001\011\001\012\001\255\255\255\255\028\001\255\255\ +\030\001\031\001\255\255\255\255\255\255\255\255\097\001\255\255\ +\255\255\255\255\101\001\255\255\255\255\030\001\031\001\106\001\ +\255\255\255\255\109\001\110\001\050\001\255\255\052\001\053\001\ +\255\255\055\001\056\001\255\255\255\255\059\001\255\255\255\255\ +\255\255\050\001\064\001\065\001\053\001\054\001\055\001\056\001\ +\255\255\071\001\059\001\255\255\006\001\255\255\008\001\064\001\ +\065\001\255\255\012\001\255\255\255\255\255\255\084\001\255\255\ +\255\255\255\255\255\255\076\001\255\255\255\255\092\001\255\255\ +\255\255\255\255\028\001\097\001\030\001\031\001\087\001\101\001\ +\255\255\255\255\255\255\255\255\106\001\255\255\255\255\109\001\ +\110\001\255\255\255\255\255\255\101\001\255\255\255\255\255\255\ +\050\001\106\001\052\001\053\001\109\001\055\001\056\001\255\255\ +\255\255\059\001\255\255\255\255\255\255\255\255\064\001\065\001\ +\255\255\006\001\255\255\255\255\255\255\071\001\255\255\012\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\084\001\255\255\255\255\255\255\255\255\028\001\ +\255\255\030\001\031\001\255\255\255\255\255\255\255\255\097\001\ +\255\255\255\255\255\255\101\001\255\255\255\255\255\255\255\255\ +\106\001\255\255\255\255\109\001\110\001\050\001\255\255\052\001\ +\053\001\255\255\055\001\056\001\255\255\255\255\059\001\255\255\ +\255\255\255\255\255\255\064\001\065\001\255\255\006\001\255\255\ +\255\255\255\255\071\001\255\255\012\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\084\001\ +\255\255\255\255\255\255\255\255\028\001\255\255\030\001\031\001\ +\255\255\006\001\255\255\255\255\097\001\255\255\255\255\012\001\ +\101\001\255\255\255\255\255\255\255\255\106\001\255\255\255\255\ +\109\001\110\001\050\001\255\255\052\001\053\001\255\255\055\001\ +\056\001\030\001\031\001\059\001\255\255\255\255\255\255\255\255\ +\064\001\065\001\255\255\255\255\255\255\255\255\255\255\071\001\ +\255\255\255\255\255\255\255\255\255\255\050\001\255\255\052\001\ +\053\001\255\255\055\001\056\001\084\001\255\255\059\001\255\255\ +\255\255\255\255\255\255\064\001\065\001\255\255\006\001\255\255\ +\255\255\097\001\071\001\255\255\012\001\101\001\255\255\255\255\ +\255\255\255\255\106\001\255\255\255\255\109\001\110\001\084\001\ +\255\255\255\255\255\255\255\255\028\001\255\255\030\001\031\001\ +\093\001\006\001\255\255\255\255\097\001\255\255\255\255\012\001\ +\101\001\255\255\255\255\255\255\255\255\106\001\255\255\255\255\ +\109\001\110\001\050\001\255\255\052\001\053\001\255\255\055\001\ +\056\001\030\001\031\001\059\001\255\255\255\255\255\255\255\255\ +\064\001\065\001\255\255\255\255\255\255\255\255\255\255\071\001\ +\255\255\255\255\255\255\255\255\255\255\050\001\255\255\052\001\ +\053\001\255\255\055\001\056\001\084\001\255\255\059\001\255\255\ +\255\255\255\255\255\255\064\001\065\001\255\255\006\001\255\255\ +\255\255\097\001\071\001\255\255\012\001\101\001\255\255\255\255\ +\255\255\255\255\106\001\255\255\255\255\109\001\110\001\084\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\030\001\031\001\ +\255\255\006\001\255\255\255\255\097\001\255\255\255\255\012\001\ +\101\001\255\255\255\255\255\255\255\255\106\001\255\255\255\255\ +\109\001\110\001\050\001\255\255\052\001\053\001\255\255\055\001\ +\056\001\030\001\031\001\059\001\255\255\255\255\255\255\255\255\ +\064\001\065\001\255\255\255\255\255\255\255\255\255\255\071\001\ +\255\255\255\255\255\255\255\255\255\255\050\001\255\255\052\001\ +\053\001\255\255\055\001\056\001\084\001\255\255\059\001\255\255\ +\255\255\255\255\255\255\064\001\065\001\255\255\006\001\255\255\ +\255\255\097\001\071\001\255\255\012\001\101\001\255\255\255\255\ +\255\255\255\255\106\001\255\255\255\255\109\001\110\001\084\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\030\001\031\001\ +\255\255\006\001\255\255\255\255\097\001\255\255\255\255\012\001\ +\101\001\255\255\255\255\255\255\255\255\106\001\255\255\255\255\ +\109\001\110\001\050\001\255\255\255\255\053\001\255\255\055\001\ +\056\001\030\001\031\001\059\001\255\255\255\255\255\255\255\255\ +\064\001\065\001\255\255\255\255\255\255\255\255\255\255\071\001\ +\255\255\255\255\255\255\255\255\255\255\050\001\255\255\255\255\ +\053\001\255\255\055\001\056\001\084\001\255\255\059\001\255\255\ +\255\255\255\255\255\255\064\001\065\001\255\255\255\255\255\255\ +\255\255\097\001\071\001\255\255\255\255\101\001\006\001\007\001\ +\255\255\255\255\106\001\011\001\012\001\109\001\110\001\084\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\022\001\255\255\ +\255\255\255\255\255\255\255\255\097\001\255\255\030\001\031\001\ +\101\001\255\255\255\255\255\255\255\255\106\001\255\255\255\255\ +\109\001\110\001\255\255\255\255\255\255\255\255\255\255\047\001\ +\255\255\255\255\050\001\051\001\255\255\053\001\054\001\055\001\ +\056\001\255\255\255\255\059\001\255\255\255\255\255\255\255\255\ +\064\001\065\001\006\001\007\001\255\255\255\255\255\255\011\001\ +\012\001\255\255\255\255\255\255\076\001\255\255\255\255\255\255\ +\255\255\081\001\255\255\255\255\255\255\255\255\255\255\087\001\ +\255\255\089\001\030\001\031\001\255\255\255\255\255\255\255\255\ +\255\255\097\001\098\001\255\255\255\255\101\001\255\255\255\255\ +\104\001\255\255\106\001\255\255\255\255\109\001\050\001\051\001\ +\255\255\053\001\054\001\055\001\056\001\255\255\255\255\059\001\ +\255\255\255\255\255\255\255\255\064\001\065\001\006\001\007\001\ +\255\255\255\255\255\255\011\001\012\001\006\001\007\001\255\255\ +\076\001\255\255\011\001\012\001\255\255\081\001\255\255\255\255\ +\255\255\255\255\255\255\087\001\255\255\089\001\030\001\031\001\ +\255\255\255\255\255\255\255\255\255\255\030\001\031\001\255\255\ +\255\255\101\001\255\255\255\255\104\001\255\255\106\001\255\255\ +\255\255\109\001\050\001\255\255\255\255\053\001\054\001\055\001\ +\056\001\050\001\255\255\059\001\053\001\054\001\055\001\056\001\ +\064\001\065\001\059\001\255\255\255\255\255\255\008\001\064\001\ +\065\001\255\255\255\255\255\255\076\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\076\001\255\255\023\001\255\255\087\001\ +\255\255\255\255\255\255\255\255\030\001\255\255\087\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\101\001\255\255\255\255\ +\255\255\255\255\106\001\255\255\101\001\109\001\255\255\255\255\ +\255\255\106\001\255\255\255\255\109\001\055\001\255\255\057\001\ +\058\001\059\001\255\255\061\001\255\255\255\255\064\001\065\001\ +\255\255\255\255\255\255\000\001\001\001\002\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\009\001\255\255\255\255\081\001\ +\255\255\014\001\015\001\016\001\017\001\018\001\088\001\089\001\ +\090\001\255\255\255\255\255\255\255\255\255\255\027\001\097\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\036\001\ +\106\001\255\255\255\255\109\001\110\001\042\001\043\001\044\001\ +\045\001\046\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\061\001\255\255\255\255\255\255\255\255\066\001\255\255\255\255\ +\255\255\255\255\071\001\072\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\082\001\083\001\084\001\ +\085\001\086\001\255\255\000\001\001\001\002\001\255\255\255\255\ +\255\255\094\001\007\001\255\255\009\001\255\255\255\255\100\001\ +\255\255\255\255\055\001\016\001\057\001\058\001\059\001\255\255\ +\061\001\255\255\255\255\064\001\065\001\255\255\027\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\036\001\ +\255\255\255\255\255\255\255\255\081\001\042\001\043\001\044\001\ +\045\001\046\001\047\001\255\255\089\001\090\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\097\001\255\255\255\255\255\255\ +\061\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\109\001\110\001\071\001\072\001\255\255\074\001\255\255\255\255\ +\255\255\255\255\000\001\001\001\002\001\082\001\083\001\084\001\ +\085\001\086\001\087\001\009\001\255\255\255\255\255\255\255\255\ +\255\255\015\001\016\001\255\255\018\001\098\001\255\255\100\001\ +\255\255\255\255\255\255\255\255\255\255\027\001\255\255\255\255\ +\255\255\255\255\000\001\001\001\002\001\255\255\036\001\255\255\ +\255\255\255\255\255\255\009\001\042\001\043\001\044\001\045\001\ +\046\001\015\001\016\001\255\255\018\001\255\255\255\255\255\255\ +\055\001\255\255\057\001\058\001\059\001\027\001\061\001\061\001\ +\255\255\064\001\065\001\255\255\066\001\255\255\036\001\255\255\ +\255\255\071\001\072\001\255\255\042\001\043\001\044\001\045\001\ +\046\001\255\255\081\001\255\255\082\001\083\001\084\001\085\001\ +\086\001\255\255\089\001\090\001\255\255\091\001\255\255\061\001\ +\255\255\255\255\097\001\255\255\066\001\255\255\100\001\255\255\ +\255\255\071\001\072\001\255\255\255\255\255\255\109\001\110\001\ +\000\001\001\001\002\001\255\255\082\001\083\001\084\001\085\001\ +\086\001\009\001\255\255\255\255\255\255\255\255\092\001\015\001\ +\016\001\255\255\018\001\255\255\255\255\255\255\100\001\255\255\ +\255\255\255\255\255\255\027\001\255\255\255\255\255\255\255\255\ +\000\001\001\001\002\001\255\255\036\001\255\255\255\255\255\255\ +\255\255\009\001\042\001\043\001\044\001\045\001\046\001\015\001\ +\016\001\255\255\018\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\027\001\255\255\061\001\255\255\255\255\ +\255\255\255\255\066\001\255\255\036\001\255\255\255\255\071\001\ +\072\001\255\255\042\001\043\001\044\001\045\001\046\001\255\255\ +\255\255\255\255\082\001\083\001\084\001\085\001\086\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\061\001\094\001\255\255\ +\255\255\255\255\066\001\255\255\100\001\255\255\255\255\071\001\ +\072\001\255\255\255\255\255\255\255\255\255\255\000\001\001\001\ +\002\001\255\255\082\001\083\001\084\001\085\001\086\001\009\001\ +\255\255\255\255\255\255\091\001\255\255\015\001\016\001\255\255\ +\018\001\255\255\255\255\255\255\100\001\255\255\255\255\255\255\ +\255\255\027\001\255\255\255\255\255\255\255\255\000\001\001\001\ +\002\001\255\255\036\001\255\255\255\255\255\255\255\255\009\001\ +\042\001\043\001\044\001\045\001\046\001\015\001\016\001\255\255\ +\018\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\027\001\255\255\061\001\255\255\255\255\255\255\255\255\ +\066\001\255\255\036\001\255\255\255\255\071\001\072\001\255\255\ +\042\001\043\001\044\001\045\001\046\001\255\255\255\255\255\255\ +\082\001\083\001\084\001\085\001\086\001\255\255\255\255\255\255\ +\255\255\255\255\092\001\061\001\255\255\255\255\255\255\255\255\ +\066\001\255\255\100\001\255\255\255\255\071\001\072\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\082\001\083\001\084\001\085\001\086\001\000\001\001\001\002\001\ +\255\255\255\255\255\255\255\255\094\001\255\255\009\001\255\255\ +\255\255\255\255\100\001\255\255\015\001\016\001\255\255\018\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\027\001\255\255\255\255\255\255\255\255\000\001\001\001\002\001\ +\255\255\036\001\255\255\255\255\255\255\255\255\009\001\042\001\ +\043\001\044\001\045\001\046\001\015\001\016\001\255\255\018\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\027\001\255\255\061\001\255\255\255\255\255\255\255\255\066\001\ +\255\255\036\001\255\255\255\255\071\001\072\001\255\255\042\001\ +\043\001\044\001\045\001\046\001\255\255\255\255\255\255\082\001\ +\083\001\084\001\085\001\086\001\255\255\255\255\255\255\255\255\ +\091\001\255\255\061\001\255\255\255\255\255\255\255\255\066\001\ +\255\255\100\001\255\255\255\255\071\001\072\001\255\255\255\255\ +\255\255\255\255\255\255\000\001\001\001\002\001\255\255\082\001\ +\083\001\084\001\085\001\086\001\009\001\255\255\255\255\255\255\ +\255\255\092\001\015\001\016\001\255\255\018\001\255\255\255\255\ +\255\255\100\001\255\255\255\255\255\255\255\255\027\001\255\255\ +\255\255\255\255\255\255\000\001\001\001\002\001\255\255\036\001\ +\255\255\255\255\255\255\255\255\009\001\042\001\043\001\044\001\ +\045\001\046\001\015\001\016\001\255\255\018\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\027\001\255\255\ +\061\001\255\255\255\255\255\255\255\255\066\001\255\255\036\001\ +\255\255\255\255\071\001\072\001\255\255\042\001\043\001\044\001\ +\045\001\046\001\255\255\255\255\255\255\082\001\083\001\084\001\ +\085\001\086\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\061\001\094\001\255\255\255\255\255\255\066\001\255\255\100\001\ +\255\255\255\255\071\001\072\001\255\255\255\255\255\255\255\255\ +\255\255\000\001\001\001\002\001\255\255\082\001\083\001\084\001\ +\085\001\086\001\009\001\255\255\255\255\255\255\091\001\255\255\ +\015\001\016\001\255\255\018\001\255\255\255\255\255\255\100\001\ +\255\255\255\255\255\255\255\255\027\001\255\255\255\255\255\255\ +\255\255\000\001\001\001\002\001\255\255\036\001\255\255\255\255\ +\255\255\255\255\009\001\042\001\043\001\044\001\045\001\046\001\ +\015\001\016\001\255\255\018\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\027\001\255\255\061\001\255\255\ +\255\255\255\255\255\255\066\001\255\255\036\001\255\255\255\255\ +\071\001\072\001\255\255\042\001\043\001\044\001\045\001\046\001\ +\255\255\255\255\255\255\082\001\083\001\084\001\085\001\086\001\ +\255\255\255\255\255\255\255\255\255\255\092\001\061\001\001\001\ +\002\001\255\255\255\255\066\001\255\255\100\001\255\255\009\001\ +\071\001\072\001\255\255\255\255\255\255\015\001\016\001\255\255\ +\018\001\255\255\255\255\082\001\083\001\084\001\085\001\086\001\ +\255\255\027\001\255\255\255\255\255\255\255\255\255\255\094\001\ +\255\255\255\255\036\001\255\255\255\255\100\001\255\255\255\255\ +\042\001\043\001\044\001\045\001\046\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\061\001\001\001\002\001\255\255\255\255\ +\066\001\255\255\255\255\255\255\009\001\071\001\072\001\255\255\ +\255\255\255\255\015\001\016\001\255\255\018\001\255\255\255\255\ +\082\001\083\001\084\001\085\001\086\001\255\255\027\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\095\001\255\255\036\001\ +\255\255\255\255\100\001\255\255\255\255\042\001\043\001\044\001\ +\045\001\046\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\061\001\001\001\002\001\255\255\255\255\066\001\255\255\255\255\ +\255\255\009\001\071\001\072\001\255\255\255\255\255\255\015\001\ +\016\001\255\255\018\001\255\255\255\255\082\001\083\001\084\001\ +\085\001\086\001\255\255\027\001\255\255\255\255\091\001\255\255\ +\255\255\001\001\002\001\255\255\036\001\255\255\255\255\100\001\ +\255\255\009\001\042\001\043\001\044\001\045\001\046\001\015\001\ +\016\001\255\255\018\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\025\001\255\255\027\001\255\255\061\001\255\255\255\255\ +\255\255\255\255\066\001\255\255\036\001\255\255\255\255\071\001\ +\072\001\255\255\042\001\043\001\044\001\045\001\046\001\255\255\ +\255\255\255\255\082\001\083\001\084\001\085\001\086\001\255\255\ +\255\255\255\255\255\255\091\001\255\255\061\001\001\001\002\001\ +\255\255\255\255\066\001\255\255\100\001\255\255\009\001\071\001\ +\072\001\255\255\255\255\255\255\015\001\016\001\255\255\018\001\ +\255\255\255\255\082\001\083\001\084\001\085\001\086\001\255\255\ +\027\001\255\255\255\255\255\255\255\255\255\255\001\001\002\001\ +\255\255\036\001\255\255\255\255\100\001\255\255\009\001\042\001\ +\043\001\044\001\045\001\046\001\015\001\016\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\027\001\255\255\061\001\255\255\255\255\255\255\255\255\066\001\ +\255\255\036\001\255\255\255\255\071\001\072\001\255\255\042\001\ +\043\001\044\001\045\001\046\001\255\255\255\255\255\255\082\001\ +\083\001\084\001\085\001\086\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\061\001\001\001\002\001\255\255\255\255\066\001\ +\255\255\100\001\255\255\009\001\071\001\072\001\255\255\255\255\ +\255\255\015\001\255\255\255\255\255\255\255\255\255\255\082\001\ +\083\001\084\001\085\001\086\001\255\255\027\001\255\255\255\255\ +\091\001\255\255\255\255\001\001\002\001\255\255\036\001\255\255\ +\255\255\100\001\255\255\255\255\042\001\043\001\044\001\045\001\ +\046\001\015\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\027\001\255\255\061\001\ +\255\255\255\255\255\255\255\255\066\001\255\255\036\001\255\255\ +\255\255\071\001\072\001\255\255\042\001\043\001\044\001\045\001\ +\046\001\013\001\255\255\255\255\082\001\083\001\084\001\085\001\ +\086\001\255\255\255\255\255\255\255\255\255\255\255\255\061\001\ +\028\001\029\001\255\255\255\255\066\001\255\255\100\001\255\255\ +\255\255\071\001\072\001\255\255\255\255\041\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\083\001\084\001\085\001\ +\086\001\255\255\255\255\055\001\255\255\057\001\058\001\059\001\ +\060\001\061\001\255\255\255\255\064\001\065\001\100\001\255\255\ +\068\001\255\255\255\255\255\255\255\255\255\255\074\001\255\255\ +\255\255\255\255\255\255\255\255\080\001\081\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\089\001\090\001\255\255\ +\255\255\255\255\255\255\255\255\096\001\097\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\108\001\109\001\110\001\111\001" -let add_functor_arg id env = - {env with - functor_args = Ident.add id () env.functor_args; - summary = Env_functor_arg (env.summary, id)} +let yynames_const = "\ + AMPERAMPER\000\ + AMPERSAND\000\ + AND\000\ + AS\000\ + ASSERT\000\ + BACKQUOTE\000\ + BANG\000\ + BAR\000\ + BARBAR\000\ + BARRBRACKET\000\ + BEGIN\000\ + CLASS\000\ + COLON\000\ + COLONCOLON\000\ + COLONEQUAL\000\ + COLONGREATER\000\ + COMMA\000\ + CONSTRAINT\000\ + DO\000\ + DONE\000\ + DOT\000\ + DOTDOT\000\ + DOWNTO\000\ + ELSE\000\ + END\000\ + EOF\000\ + EQUAL\000\ + EXCEPTION\000\ + EXTERNAL\000\ + FALSE\000\ + FOR\000\ + FUN\000\ + FUNCTION\000\ + FUNCTOR\000\ + GREATER\000\ + GREATERRBRACE\000\ + GREATERRBRACKET\000\ + IF\000\ + IN\000\ + INCLUDE\000\ + INHERIT\000\ + INITIALIZER\000\ + LAZY\000\ + LBRACE\000\ + LBRACELESS\000\ + LBRACKET\000\ + LBRACKETBAR\000\ + LBRACKETLESS\000\ + LBRACKETGREATER\000\ + LBRACKETPERCENT\000\ + LBRACKETPERCENTPERCENT\000\ + LESS\000\ + LESSMINUS\000\ + LET\000\ + LPAREN\000\ + LBRACKETAT\000\ + LBRACKETATAT\000\ + LBRACKETATATAT\000\ + MATCH\000\ + METHOD\000\ + MINUS\000\ + MINUSDOT\000\ + MINUSGREATER\000\ + MODULE\000\ + MUTABLE\000\ + NEW\000\ + NONREC\000\ + OBJECT\000\ + OF\000\ + OPEN\000\ + OR\000\ + PERCENT\000\ + PLUS\000\ + PLUSDOT\000\ + PLUSEQ\000\ + PRIVATE\000\ + QUESTION\000\ + QUOTE\000\ + RBRACE\000\ + RBRACKET\000\ + REC\000\ + RPAREN\000\ + SEMI\000\ + SEMISEMI\000\ + HASH\000\ + SIG\000\ + STAR\000\ + STRUCT\000\ + THEN\000\ + TILDE\000\ + TO\000\ + TRUE\000\ + TRY\000\ + TYPE\000\ + UNDERSCORE\000\ + VAL\000\ + VIRTUAL\000\ + WHEN\000\ + WHILE\000\ + WITH\000\ + EOL\000\ + " -let add_value ?check id desc env = - store_value ?check id desc env +let yynames_block = "\ + CHAR\000\ + FLOAT\000\ + INFIXOP0\000\ + INFIXOP1\000\ + INFIXOP2\000\ + INFIXOP3\000\ + INFIXOP4\000\ + DOTOP\000\ + INT\000\ + LABEL\000\ + LIDENT\000\ + OPTLABEL\000\ + PREFIXOP\000\ + HASHOP\000\ + STRING\000\ + UIDENT\000\ + COMMENT\000\ + DOCSTRING\000\ + " -let add_type ~check id info env = - store_type ~check id info env +let yyact = [| + (fun _ -> failwith "parser") +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'structure) in + Obj.repr( +# 630 "parsing/parser.mly" + ( extra_str 1 _1 ) +# 7030 "parsing/parser.ml" + : Parsetree.structure)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'signature) in + Obj.repr( +# 633 "parsing/parser.mly" + ( extra_sig 1 _1 ) +# 7037 "parsing/parser.ml" + : Parsetree.signature)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'top_structure) in + Obj.repr( +# 636 "parsing/parser.mly" + ( Ptop_def (extra_str 1 _1) ) +# 7044 "parsing/parser.ml" + : Parsetree.toplevel_phrase)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'toplevel_directive) in + Obj.repr( +# 637 "parsing/parser.mly" + ( _1 ) +# 7051 "parsing/parser.ml" + : Parsetree.toplevel_phrase)) +; (fun __caml_parser_env -> + Obj.repr( +# 638 "parsing/parser.mly" + ( raise End_of_file ) +# 7057 "parsing/parser.ml" + : Parsetree.toplevel_phrase)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 642 "parsing/parser.mly" + ( (text_str 1) @ [mkstrexp _1 _2] ) +# 7065 "parsing/parser.ml" + : 'top_structure)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'top_structure_tail) in + Obj.repr( +# 644 "parsing/parser.mly" + ( _1 ) +# 7072 "parsing/parser.ml" + : 'top_structure)) +; (fun __caml_parser_env -> + Obj.repr( +# 647 "parsing/parser.mly" + ( [] ) +# 7078 "parsing/parser.ml" + : 'top_structure_tail)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'structure_item) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'top_structure_tail) in + Obj.repr( +# 648 "parsing/parser.mly" + ( (text_str 1) @ _1 :: _2 ) +# 7086 "parsing/parser.ml" + : 'top_structure_tail)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'use_file_body) in + Obj.repr( +# 651 "parsing/parser.mly" + ( extra_def 1 _1 ) +# 7093 "parsing/parser.ml" + : Parsetree.toplevel_phrase list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'use_file_tail) in + Obj.repr( +# 654 "parsing/parser.mly" + ( _1 ) +# 7100 "parsing/parser.ml" + : 'use_file_body)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'seq_expr) in + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'post_item_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'use_file_tail) in + Obj.repr( +# 656 "parsing/parser.mly" + ( (text_def 1) @ Ptop_def[mkstrexp _1 _2] :: _3 ) +# 7109 "parsing/parser.ml" + : 'use_file_body)) +; (fun __caml_parser_env -> + Obj.repr( +# 660 "parsing/parser.mly" + ( [] ) +# 7115 "parsing/parser.ml" + : 'use_file_tail)) +; (fun __caml_parser_env -> + Obj.repr( +# 662 "parsing/parser.mly" + ( text_def 1 ) +# 7121 "parsing/parser.ml" + : 'use_file_tail)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'seq_expr) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'post_item_attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'use_file_tail) in + Obj.repr( +# 664 "parsing/parser.mly" + ( mark_rhs_docs 2 3; + (text_def 1) @ (text_def 2) @ Ptop_def[mkstrexp _2 _3] :: _4 ) +# 7131 "parsing/parser.ml" + : 'use_file_tail)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'structure_item) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'use_file_tail) in + Obj.repr( +# 667 "parsing/parser.mly" + ( (text_def 1) @ (text_def 2) @ Ptop_def[_2] :: _3 ) +# 7139 "parsing/parser.ml" + : 'use_file_tail)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'toplevel_directive) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'use_file_tail) in + Obj.repr( +# 669 "parsing/parser.mly" + ( mark_rhs_docs 2 3; + (text_def 1) @ (text_def 2) @ _2 :: _3 ) +# 7148 "parsing/parser.ml" + : 'use_file_tail)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'structure_item) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'use_file_tail) in + Obj.repr( +# 672 "parsing/parser.mly" + ( (text_def 1) @ Ptop_def[_1] :: _2 ) +# 7156 "parsing/parser.ml" + : 'use_file_tail)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'toplevel_directive) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'use_file_tail) in + Obj.repr( +# 674 "parsing/parser.mly" + ( mark_rhs_docs 1 1; + (text_def 1) @ _1 :: _2 ) +# 7165 "parsing/parser.ml" + : 'use_file_tail)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'core_type) in + Obj.repr( +# 678 "parsing/parser.mly" + ( _1 ) +# 7172 "parsing/parser.ml" + : Parsetree.core_type)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in + Obj.repr( +# 681 "parsing/parser.mly" + ( _1 ) +# 7179 "parsing/parser.ml" + : Parsetree.expression)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'pattern) in + Obj.repr( +# 684 "parsing/parser.mly" + ( _1 ) +# 7186 "parsing/parser.ml" + : Parsetree.pattern)) +; (fun __caml_parser_env -> + Obj.repr( +# 691 "parsing/parser.mly" + ( mkrhs "*" 2, None ) +# 7192 "parsing/parser.ml" + : 'functor_arg)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'functor_arg_name) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'module_type) in + Obj.repr( +# 693 "parsing/parser.mly" + ( mkrhs _2 2, Some _4 ) +# 7200 "parsing/parser.ml" + : 'functor_arg)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 697 "parsing/parser.mly" + ( _1 ) +# 7207 "parsing/parser.ml" + : 'functor_arg_name)) +; (fun __caml_parser_env -> + Obj.repr( +# 698 "parsing/parser.mly" + ( "_" ) +# 7213 "parsing/parser.ml" + : 'functor_arg_name)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'functor_args) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'functor_arg) in + Obj.repr( +# 703 "parsing/parser.mly" + ( _2 :: _1 ) +# 7221 "parsing/parser.ml" + : 'functor_args)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'functor_arg) in + Obj.repr( +# 705 "parsing/parser.mly" + ( [ _1 ] ) +# 7228 "parsing/parser.ml" + : 'functor_args)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'mod_longident) in + Obj.repr( +# 710 "parsing/parser.mly" + ( mkmod(Pmod_ident (mkrhs _1 1)) ) +# 7235 "parsing/parser.ml" + : 'module_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'structure) in + Obj.repr( +# 712 "parsing/parser.mly" + ( mkmod ~attrs:_2 (Pmod_structure(extra_str 3 _3)) ) +# 7243 "parsing/parser.ml" + : 'module_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'structure) in + Obj.repr( +# 714 "parsing/parser.mly" + ( unclosed "struct" 1 "end" 4 ) +# 7251 "parsing/parser.ml" + : 'module_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'functor_args) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'module_expr) in + Obj.repr( +# 716 "parsing/parser.mly" + ( let modexp = + List.fold_left + (fun acc (n, t) -> mkmod(Pmod_functor(n, t, acc))) + _5 _3 + in wrap_mod_attrs modexp _2 ) +# 7264 "parsing/parser.ml" + : 'module_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'module_expr) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'paren_module_expr) in + Obj.repr( +# 722 "parsing/parser.mly" + ( mkmod(Pmod_apply(_1, _2)) ) +# 7272 "parsing/parser.ml" + : 'module_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'module_expr) in + Obj.repr( +# 724 "parsing/parser.mly" + ( mkmod(Pmod_apply(_1, mkmod (Pmod_structure []))) ) +# 7279 "parsing/parser.ml" + : 'module_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'paren_module_expr) in + Obj.repr( +# 726 "parsing/parser.mly" + ( _1 ) +# 7286 "parsing/parser.ml" + : 'module_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'module_expr) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attribute) in + Obj.repr( +# 728 "parsing/parser.mly" + ( Mod.attr _1 _2 ) +# 7294 "parsing/parser.ml" + : 'module_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'extension) in + Obj.repr( +# 730 "parsing/parser.mly" + ( mkmod(Pmod_extension _1) ) +# 7301 "parsing/parser.ml" + : 'module_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'module_expr) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'module_type) in + Obj.repr( +# 735 "parsing/parser.mly" + ( mkmod(Pmod_constraint(_2, _4)) ) +# 7309 "parsing/parser.ml" + : 'paren_module_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'module_expr) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'module_type) in + Obj.repr( +# 737 "parsing/parser.mly" + ( unclosed "(" 1 ")" 5 ) +# 7317 "parsing/parser.ml" + : 'paren_module_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'module_expr) in + Obj.repr( +# 739 "parsing/parser.mly" + ( _2 ) +# 7324 "parsing/parser.ml" + : 'paren_module_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'module_expr) in + Obj.repr( +# 741 "parsing/parser.mly" + ( unclosed "(" 1 ")" 3 ) +# 7331 "parsing/parser.ml" + : 'paren_module_expr)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in + Obj.repr( +# 743 "parsing/parser.mly" + ( mkmod ~attrs:_3 (Pmod_unpack _4)) +# 7339 "parsing/parser.ml" + : 'paren_module_expr)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : 'expr) in + let _6 = (Parsing.peek_val __caml_parser_env 1 : 'package_type) in + Obj.repr( +# 745 "parsing/parser.mly" + ( mkmod ~attrs:_3 + (Pmod_unpack( + ghexp(Pexp_constraint(_4, ghtyp(Ptyp_package _6))))) ) +# 7350 "parsing/parser.ml" + : 'paren_module_expr)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 6 : 'attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 5 : 'expr) in + let _6 = (Parsing.peek_val __caml_parser_env 3 : 'package_type) in + let _8 = (Parsing.peek_val __caml_parser_env 1 : 'package_type) in + Obj.repr( +# 750 "parsing/parser.mly" + ( mkmod ~attrs:_3 + (Pmod_unpack( + ghexp(Pexp_coerce(_4, Some(ghtyp(Ptyp_package _6)), + ghtyp(Ptyp_package _8))))) ) +# 7363 "parsing/parser.ml" + : 'paren_module_expr)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : 'expr) in + let _6 = (Parsing.peek_val __caml_parser_env 1 : 'package_type) in + Obj.repr( +# 755 "parsing/parser.mly" + ( mkmod ~attrs:_3 + (Pmod_unpack( + ghexp(Pexp_coerce(_4, None, ghtyp(Ptyp_package _6))))) ) +# 7374 "parsing/parser.ml" + : 'paren_module_expr)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 3 : 'attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + Obj.repr( +# 759 "parsing/parser.mly" + ( unclosed "(" 1 ")" 6 ) +# 7382 "parsing/parser.ml" + : 'paren_module_expr)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 3 : 'attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + Obj.repr( +# 761 "parsing/parser.mly" + ( unclosed "(" 1 ")" 6 ) +# 7390 "parsing/parser.ml" + : 'paren_module_expr)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in + Obj.repr( +# 763 "parsing/parser.mly" + ( unclosed "(" 1 ")" 5 ) +# 7398 "parsing/parser.ml" + : 'paren_module_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'seq_expr) in + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'post_item_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'structure_tail) in + Obj.repr( +# 768 "parsing/parser.mly" + ( mark_rhs_docs 1 2; + (text_str 1) @ mkstrexp _1 _2 :: _3 ) +# 7408 "parsing/parser.ml" + : 'structure)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'structure_tail) in + Obj.repr( +# 770 "parsing/parser.mly" + ( _1 ) +# 7415 "parsing/parser.ml" + : 'structure)) +; (fun __caml_parser_env -> + Obj.repr( +# 773 "parsing/parser.mly" + ( [] ) +# 7421 "parsing/parser.ml" + : 'structure_tail)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'structure) in + Obj.repr( +# 774 "parsing/parser.mly" + ( (text_str 1) @ _2 ) +# 7428 "parsing/parser.ml" + : 'structure_tail)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'structure_item) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'structure_tail) in + Obj.repr( +# 775 "parsing/parser.mly" + ( (text_str 1) @ _1 :: _2 ) +# 7436 "parsing/parser.ml" + : 'structure_tail)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'let_bindings) in + Obj.repr( +# 779 "parsing/parser.mly" + ( val_of_let_bindings _1 ) +# 7443 "parsing/parser.ml" + : 'structure_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'primitive_declaration) in + Obj.repr( +# 781 "parsing/parser.mly" + ( let (body, ext) = _1 in mkstr_ext (Pstr_primitive body) ext ) +# 7450 "parsing/parser.ml" + : 'structure_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'value_description) in + Obj.repr( +# 783 "parsing/parser.mly" + ( let (body, ext) = _1 in mkstr_ext (Pstr_primitive body) ext ) +# 7457 "parsing/parser.ml" + : 'structure_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'type_declarations) in + Obj.repr( +# 785 "parsing/parser.mly" + ( let (nr, l, ext ) = _1 in mkstr_ext (Pstr_type (nr, List.rev l)) ext ) +# 7464 "parsing/parser.ml" + : 'structure_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'str_type_extension) in + Obj.repr( +# 787 "parsing/parser.mly" + ( let (l, ext) = _1 in mkstr_ext (Pstr_typext l) ext ) +# 7471 "parsing/parser.ml" + : 'structure_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'str_exception_declaration) in + Obj.repr( +# 789 "parsing/parser.mly" + ( let (l, ext) = _1 in mkstr_ext (Pstr_exception l) ext ) +# 7478 "parsing/parser.ml" + : 'structure_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'module_binding) in + Obj.repr( +# 791 "parsing/parser.mly" + ( let (body, ext) = _1 in mkstr_ext (Pstr_module body) ext ) +# 7485 "parsing/parser.ml" + : 'structure_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'rec_module_bindings) in + Obj.repr( +# 793 "parsing/parser.mly" + ( let (l, ext) = _1 in mkstr_ext (Pstr_recmodule(List.rev l)) ext ) +# 7492 "parsing/parser.ml" + : 'structure_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'module_type_declaration) in + Obj.repr( +# 795 "parsing/parser.mly" + ( let (body, ext) = _1 in mkstr_ext (Pstr_modtype body) ext ) +# 7499 "parsing/parser.ml" + : 'structure_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'open_statement) in + Obj.repr( +# 797 "parsing/parser.mly" + ( let (body, ext) = _1 in mkstr_ext (Pstr_open body) ext ) +# 7506 "parsing/parser.ml" + : 'structure_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'class_declarations) in + Obj.repr( +# 799 "parsing/parser.mly" + ( let (l, ext) = _1 in mkstr_ext (Pstr_class (List.rev l)) ext ) +# 7513 "parsing/parser.ml" + : 'structure_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'class_type_declarations) in + Obj.repr( +# 801 "parsing/parser.mly" + ( let (l, ext) = _1 in mkstr_ext (Pstr_class_type (List.rev l)) ext ) +# 7520 "parsing/parser.ml" + : 'structure_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'str_include_statement) in + Obj.repr( +# 803 "parsing/parser.mly" + ( let (body, ext) = _1 in mkstr_ext (Pstr_include body) ext ) +# 7527 "parsing/parser.ml" + : 'structure_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'item_extension) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 805 "parsing/parser.mly" + ( mkstr(Pstr_extension (_1, (add_docs_attrs (symbol_docs ()) _2))) ) +# 7535 "parsing/parser.ml" + : 'structure_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'floating_attribute) in + Obj.repr( +# 807 "parsing/parser.mly" + ( mark_symbol_docs (); + mkstr(Pstr_attribute _1) ) +# 7543 "parsing/parser.ml" + : 'structure_item)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'module_expr) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 812 "parsing/parser.mly" + ( let (ext, attrs) = _2 in + Incl.mk _3 ~attrs:(attrs@_4) + ~loc:(symbol_rloc()) ~docs:(symbol_docs ()) + , ext ) +# 7555 "parsing/parser.ml" + : 'str_include_statement)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'module_expr) in + Obj.repr( +# 819 "parsing/parser.mly" + ( _2 ) +# 7562 "parsing/parser.ml" + : 'module_binding_body)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'module_type) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'module_expr) in + Obj.repr( +# 821 "parsing/parser.mly" + ( mkmod(Pmod_constraint(_4, _2)) ) +# 7570 "parsing/parser.ml" + : 'module_binding_body)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'functor_arg) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'module_binding_body) in + Obj.repr( +# 823 "parsing/parser.mly" + ( mkmod(Pmod_functor(fst _1, snd _1, _2)) ) +# 7578 "parsing/parser.ml" + : 'module_binding_body)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 2 : string) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'module_binding_body) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 827 "parsing/parser.mly" + ( let (ext, attrs) = _2 in + Mb.mk (mkrhs _3 3) _4 ~attrs:(attrs@_5) + ~loc:(symbol_rloc ()) ~docs:(symbol_docs ()) + , ext ) +# 7591 "parsing/parser.ml" + : 'module_binding)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'rec_module_binding) in + Obj.repr( +# 833 "parsing/parser.mly" + ( let (b, ext) = _1 in ([b], ext) ) +# 7598 "parsing/parser.ml" + : 'rec_module_bindings)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'rec_module_bindings) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'and_module_binding) in + Obj.repr( +# 835 "parsing/parser.mly" + ( let (l, ext) = _1 in (_2 :: l, ext) ) +# 7606 "parsing/parser.ml" + : 'rec_module_bindings)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 2 : string) in + let _5 = (Parsing.peek_val __caml_parser_env 1 : 'module_binding_body) in + let _6 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 839 "parsing/parser.mly" + ( let (ext, attrs) = _2 in + Mb.mk (mkrhs _4 4) _5 ~attrs:(attrs@_6) + ~loc:(symbol_rloc ()) ~docs:(symbol_docs ()) + , ext ) +# 7619 "parsing/parser.ml" + : 'rec_module_binding)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 2 : string) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'module_binding_body) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 846 "parsing/parser.mly" + ( Mb.mk (mkrhs _3 3) _4 ~attrs:(_2@_5) ~loc:(symbol_rloc ()) + ~text:(symbol_text ()) ~docs:(symbol_docs ()) ) +# 7630 "parsing/parser.ml" + : 'and_module_binding)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'mty_longident) in + Obj.repr( +# 854 "parsing/parser.mly" + ( mkmty(Pmty_ident (mkrhs _1 1)) ) +# 7637 "parsing/parser.ml" + : 'module_type)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'signature) in + Obj.repr( +# 856 "parsing/parser.mly" + ( mkmty ~attrs:_2 (Pmty_signature (extra_sig 3 _3)) ) +# 7645 "parsing/parser.ml" + : 'module_type)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'signature) in + Obj.repr( +# 858 "parsing/parser.mly" + ( unclosed "sig" 1 "end" 4 ) +# 7653 "parsing/parser.ml" + : 'module_type)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'functor_args) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'module_type) in + Obj.repr( +# 861 "parsing/parser.mly" + ( let mty = + List.fold_left + (fun acc (n, t) -> mkmty(Pmty_functor(n, t, acc))) + _5 _3 + in wrap_mty_attrs mty _2 ) +# 7666 "parsing/parser.ml" + : 'module_type)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'module_type) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'module_type) in + Obj.repr( +# 868 "parsing/parser.mly" + ( mkmty(Pmty_functor(mknoloc "_", Some _1, _3)) ) +# 7674 "parsing/parser.ml" + : 'module_type)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'module_type) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'with_constraints) in + Obj.repr( +# 870 "parsing/parser.mly" + ( mkmty(Pmty_with(_1, List.rev _3)) ) +# 7682 "parsing/parser.ml" + : 'module_type)) +; (fun __caml_parser_env -> + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'attributes) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'module_expr) in + Obj.repr( +# 872 "parsing/parser.mly" + ( mkmty ~attrs:_4 (Pmty_typeof _5) ) +# 7690 "parsing/parser.ml" + : 'module_type)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'module_type) in + Obj.repr( +# 876 "parsing/parser.mly" + ( _2 ) +# 7697 "parsing/parser.ml" + : 'module_type)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'module_type) in + Obj.repr( +# 878 "parsing/parser.mly" + ( unclosed "(" 1 ")" 3 ) +# 7704 "parsing/parser.ml" + : 'module_type)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'extension) in + Obj.repr( +# 880 "parsing/parser.mly" + ( mkmty(Pmty_extension _1) ) +# 7711 "parsing/parser.ml" + : 'module_type)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'module_type) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attribute) in + Obj.repr( +# 882 "parsing/parser.mly" + ( Mty.attr _1 _2 ) +# 7719 "parsing/parser.ml" + : 'module_type)) +; (fun __caml_parser_env -> + Obj.repr( +# 885 "parsing/parser.mly" + ( [] ) +# 7725 "parsing/parser.ml" + : 'signature)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'signature) in + Obj.repr( +# 886 "parsing/parser.mly" + ( (text_sig 1) @ _2 ) +# 7732 "parsing/parser.ml" + : 'signature)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'signature_item) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'signature) in + Obj.repr( +# 887 "parsing/parser.mly" + ( (text_sig 1) @ _1 :: _2 ) +# 7740 "parsing/parser.ml" + : 'signature)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'value_description) in + Obj.repr( +# 891 "parsing/parser.mly" + ( let (body, ext) = _1 in mksig_ext (Psig_value body) ext ) +# 7747 "parsing/parser.ml" + : 'signature_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'primitive_declaration) in + Obj.repr( +# 893 "parsing/parser.mly" + ( let (body, ext) = _1 in mksig_ext (Psig_value body) ext) +# 7754 "parsing/parser.ml" + : 'signature_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'type_declarations) in + Obj.repr( +# 895 "parsing/parser.mly" + ( let (nr, l, ext) = _1 in mksig_ext (Psig_type (nr, List.rev l)) ext ) +# 7761 "parsing/parser.ml" + : 'signature_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'sig_type_extension) in + Obj.repr( +# 897 "parsing/parser.mly" + ( let (l, ext) = _1 in mksig_ext (Psig_typext l) ext ) +# 7768 "parsing/parser.ml" + : 'signature_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'sig_exception_declaration) in + Obj.repr( +# 899 "parsing/parser.mly" + ( let (l, ext) = _1 in mksig_ext (Psig_exception l) ext ) +# 7775 "parsing/parser.ml" + : 'signature_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'module_declaration) in + Obj.repr( +# 901 "parsing/parser.mly" + ( let (body, ext) = _1 in mksig_ext (Psig_module body) ext ) +# 7782 "parsing/parser.ml" + : 'signature_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'module_alias) in + Obj.repr( +# 903 "parsing/parser.mly" + ( let (body, ext) = _1 in mksig_ext (Psig_module body) ext ) +# 7789 "parsing/parser.ml" + : 'signature_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'rec_module_declarations) in + Obj.repr( +# 905 "parsing/parser.mly" + ( let (l, ext) = _1 in mksig_ext (Psig_recmodule (List.rev l)) ext ) +# 7796 "parsing/parser.ml" + : 'signature_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'module_type_declaration) in + Obj.repr( +# 907 "parsing/parser.mly" + ( let (body, ext) = _1 in mksig_ext (Psig_modtype body) ext ) +# 7803 "parsing/parser.ml" + : 'signature_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'open_statement) in + Obj.repr( +# 909 "parsing/parser.mly" + ( let (body, ext) = _1 in mksig_ext (Psig_open body) ext ) +# 7810 "parsing/parser.ml" + : 'signature_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'sig_include_statement) in + Obj.repr( +# 911 "parsing/parser.mly" + ( let (body, ext) = _1 in mksig_ext (Psig_include body) ext ) +# 7817 "parsing/parser.ml" + : 'signature_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'class_descriptions) in + Obj.repr( +# 913 "parsing/parser.mly" + ( let (l, ext) = _1 in mksig_ext (Psig_class (List.rev l)) ext ) +# 7824 "parsing/parser.ml" + : 'signature_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'class_type_declarations) in + Obj.repr( +# 915 "parsing/parser.mly" + ( let (l, ext) = _1 in mksig_ext (Psig_class_type (List.rev l)) ext ) +# 7831 "parsing/parser.ml" + : 'signature_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'item_extension) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 917 "parsing/parser.mly" + ( mksig(Psig_extension (_1, (add_docs_attrs (symbol_docs ()) _2))) ) +# 7839 "parsing/parser.ml" + : 'signature_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'floating_attribute) in + Obj.repr( +# 919 "parsing/parser.mly" + ( mark_symbol_docs (); + mksig(Psig_attribute _1) ) +# 7847 "parsing/parser.ml" + : 'signature_item)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'override_flag) in + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'mod_longident) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 924 "parsing/parser.mly" + ( let (ext, attrs) = _3 in + Opn.mk (mkrhs _4 4) ~override:_2 ~attrs:(attrs@_5) + ~loc:(symbol_rloc()) ~docs:(symbol_docs ()) + , ext) +# 7860 "parsing/parser.ml" + : 'open_statement)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'module_type) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 931 "parsing/parser.mly" + ( let (ext, attrs) = _2 in + Incl.mk _3 ~attrs:(attrs@_4) + ~loc:(symbol_rloc()) ~docs:(symbol_docs ()) + , ext) +# 7872 "parsing/parser.ml" + : 'sig_include_statement)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'module_type) in + Obj.repr( +# 938 "parsing/parser.mly" + ( _2 ) +# 7879 "parsing/parser.ml" + : 'module_declaration_body)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 4 : string) in + let _4 = (Parsing.peek_val __caml_parser_env 2 : 'module_type) in + let _6 = (Parsing.peek_val __caml_parser_env 0 : 'module_declaration_body) in + Obj.repr( +# 940 "parsing/parser.mly" + ( mkmty(Pmty_functor(mkrhs _2 2, Some _4, _6)) ) +# 7888 "parsing/parser.ml" + : 'module_declaration_body)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'module_declaration_body) in + Obj.repr( +# 942 "parsing/parser.mly" + ( mkmty(Pmty_functor(mkrhs "*" 1, None, _3)) ) +# 7895 "parsing/parser.ml" + : 'module_declaration_body)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 2 : string) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'module_declaration_body) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 946 "parsing/parser.mly" + ( let (ext, attrs) = _2 in + Md.mk (mkrhs _3 3) _4 ~attrs:(attrs@_5) + ~loc:(symbol_rloc()) ~docs:(symbol_docs ()) + , ext ) +# 7908 "parsing/parser.ml" + : 'module_declaration)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _5 = (Parsing.peek_val __caml_parser_env 1 : 'mod_longident) in + let _6 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 953 "parsing/parser.mly" + ( let (ext, attrs) = _2 in + Md.mk (mkrhs _3 3) + (Mty.alias ~loc:(rhs_loc 5) (mkrhs _5 5)) ~attrs:(attrs@_6) + ~loc:(symbol_rloc()) ~docs:(symbol_docs ()) + , ext ) +# 7922 "parsing/parser.ml" + : 'module_alias)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'rec_module_declaration) in + Obj.repr( +# 961 "parsing/parser.mly" + ( let (body, ext) = _1 in ([body], ext) ) +# 7929 "parsing/parser.ml" + : 'rec_module_declarations)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'rec_module_declarations) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'and_module_declaration) in + Obj.repr( +# 963 "parsing/parser.mly" + ( let (l, ext) = _1 in (_2 :: l, ext) ) +# 7937 "parsing/parser.ml" + : 'rec_module_declarations)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 5 : 'ext_attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _6 = (Parsing.peek_val __caml_parser_env 1 : 'module_type) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 967 "parsing/parser.mly" + ( let (ext, attrs) = _2 in + Md.mk (mkrhs _4 4) _6 ~attrs:(attrs@_7) + ~loc:(symbol_rloc()) ~docs:(symbol_docs ()) + , ext) +# 7950 "parsing/parser.ml" + : 'rec_module_declaration)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 4 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _5 = (Parsing.peek_val __caml_parser_env 1 : 'module_type) in + let _6 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 974 "parsing/parser.mly" + ( Md.mk (mkrhs _3 3) _5 ~attrs:(_2@_6) ~loc:(symbol_rloc()) + ~text:(symbol_text()) ~docs:(symbol_docs()) ) +# 7961 "parsing/parser.ml" + : 'and_module_declaration)) +; (fun __caml_parser_env -> + Obj.repr( +# 978 "parsing/parser.mly" + ( None ) +# 7967 "parsing/parser.ml" + : 'module_type_declaration_body)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'module_type) in + Obj.repr( +# 979 "parsing/parser.mly" + ( Some _2 ) +# 7974 "parsing/parser.ml" + : 'module_type_declaration_body)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 3 : 'ext_attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 2 : 'ident) in + let _5 = (Parsing.peek_val __caml_parser_env 1 : 'module_type_declaration_body) in + let _6 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 984 "parsing/parser.mly" + ( let (ext, attrs) = _3 in + Mtd.mk (mkrhs _4 4) ?typ:_5 ~attrs:(attrs@_6) + ~loc:(symbol_rloc()) ~docs:(symbol_docs ()) + , ext ) +# 7987 "parsing/parser.ml" + : 'module_type_declaration)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'class_declaration) in + Obj.repr( +# 993 "parsing/parser.mly" + ( let (body, ext) = _1 in ([body], ext) ) +# 7994 "parsing/parser.ml" + : 'class_declarations)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'class_declarations) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'and_class_declaration) in + Obj.repr( +# 995 "parsing/parser.mly" + ( let (l, ext) = _1 in (_2 :: l, ext) ) +# 8002 "parsing/parser.ml" + : 'class_declarations)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 5 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'virtual_flag) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : 'class_type_parameters) in + let _5 = (Parsing.peek_val __caml_parser_env 2 : string) in + let _6 = (Parsing.peek_val __caml_parser_env 1 : 'class_fun_binding) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1000 "parsing/parser.mly" + ( let (ext, attrs) = _2 in + Ci.mk (mkrhs _5 5) _6 ~virt:_3 ~params:_4 ~attrs:(attrs@_7) + ~loc:(symbol_rloc ()) ~docs:(symbol_docs ()) + , ext ) +# 8017 "parsing/parser.ml" + : 'class_declaration)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 5 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'virtual_flag) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : 'class_type_parameters) in + let _5 = (Parsing.peek_val __caml_parser_env 2 : string) in + let _6 = (Parsing.peek_val __caml_parser_env 1 : 'class_fun_binding) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1008 "parsing/parser.mly" + ( Ci.mk (mkrhs _5 5) _6 ~virt:_3 ~params:_4 + ~attrs:(_2@_7) ~loc:(symbol_rloc ()) + ~text:(symbol_text ()) ~docs:(symbol_docs ()) ) +# 8031 "parsing/parser.ml" + : 'and_class_declaration)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'class_expr) in + Obj.repr( +# 1014 "parsing/parser.mly" + ( _2 ) +# 8038 "parsing/parser.ml" + : 'class_fun_binding)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'class_type) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'class_expr) in + Obj.repr( +# 1016 "parsing/parser.mly" + ( mkclass(Pcl_constraint(_4, _2)) ) +# 8046 "parsing/parser.ml" + : 'class_fun_binding)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'labeled_simple_pattern) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'class_fun_binding) in + Obj.repr( +# 1018 "parsing/parser.mly" + ( let (l,o,p) = _1 in mkclass(Pcl_fun(l, o, p, _2)) ) +# 8054 "parsing/parser.ml" + : 'class_fun_binding)) +; (fun __caml_parser_env -> + Obj.repr( +# 1021 "parsing/parser.mly" + ( [] ) +# 8060 "parsing/parser.ml" + : 'class_type_parameters)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'type_parameter_list) in + Obj.repr( +# 1022 "parsing/parser.mly" + ( List.rev _2 ) +# 8067 "parsing/parser.ml" + : 'class_type_parameters)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'labeled_simple_pattern) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'class_expr) in + Obj.repr( +# 1026 "parsing/parser.mly" + ( let (l,o,p) = _1 in mkclass(Pcl_fun(l, o, p, _3)) ) +# 8075 "parsing/parser.ml" + : 'class_fun_def)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'labeled_simple_pattern) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'class_fun_def) in + Obj.repr( +# 1028 "parsing/parser.mly" + ( let (l,o,p) = _1 in mkclass(Pcl_fun(l, o, p, _2)) ) +# 8083 "parsing/parser.ml" + : 'class_fun_def)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'class_simple_expr) in + Obj.repr( +# 1032 "parsing/parser.mly" + ( _1 ) +# 8090 "parsing/parser.ml" + : 'class_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'class_fun_def) in + Obj.repr( +# 1034 "parsing/parser.mly" + ( wrap_class_attrs _3 _2 ) +# 8098 "parsing/parser.ml" + : 'class_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'class_simple_expr) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'simple_labeled_expr_list) in + Obj.repr( +# 1036 "parsing/parser.mly" + ( mkclass(Pcl_apply(_1, List.rev _2)) ) +# 8106 "parsing/parser.ml" + : 'class_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'let_bindings) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'class_expr) in + Obj.repr( +# 1038 "parsing/parser.mly" + ( class_of_let_bindings _1 _3 ) +# 8114 "parsing/parser.ml" + : 'class_expr)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'override_flag) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : 'attributes) in + let _5 = (Parsing.peek_val __caml_parser_env 2 : 'mod_longident) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'class_expr) in + Obj.repr( +# 1040 "parsing/parser.mly" + ( wrap_class_attrs (mkclass(Pcl_open(_3, mkrhs _5 5, _7))) _4 ) +# 8124 "parsing/parser.ml" + : 'class_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'class_expr) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attribute) in + Obj.repr( +# 1042 "parsing/parser.mly" + ( Cl.attr _1 _2 ) +# 8132 "parsing/parser.ml" + : 'class_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'extension) in + Obj.repr( +# 1044 "parsing/parser.mly" + ( mkclass(Pcl_extension _1) ) +# 8139 "parsing/parser.ml" + : 'class_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'core_type_comma_list) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'class_longident) in + Obj.repr( +# 1048 "parsing/parser.mly" + ( mkclass(Pcl_constr(mkloc _4 (rhs_loc 4), List.rev _2)) ) +# 8147 "parsing/parser.ml" + : 'class_simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'class_longident) in + Obj.repr( +# 1050 "parsing/parser.mly" + ( mkclass(Pcl_constr(mkrhs _1 1, [])) ) +# 8154 "parsing/parser.ml" + : 'class_simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'class_structure) in + Obj.repr( +# 1052 "parsing/parser.mly" + ( mkclass ~attrs:_2 (Pcl_structure _3) ) +# 8162 "parsing/parser.ml" + : 'class_simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'class_structure) in + Obj.repr( +# 1054 "parsing/parser.mly" + ( unclosed "object" 1 "end" 4 ) +# 8170 "parsing/parser.ml" + : 'class_simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'class_expr) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'class_type) in + Obj.repr( +# 1056 "parsing/parser.mly" + ( mkclass(Pcl_constraint(_2, _4)) ) +# 8178 "parsing/parser.ml" + : 'class_simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'class_expr) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'class_type) in + Obj.repr( +# 1058 "parsing/parser.mly" + ( unclosed "(" 1 ")" 5 ) +# 8186 "parsing/parser.ml" + : 'class_simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'class_expr) in + Obj.repr( +# 1060 "parsing/parser.mly" + ( _2 ) +# 8193 "parsing/parser.ml" + : 'class_simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'class_expr) in + Obj.repr( +# 1062 "parsing/parser.mly" + ( unclosed "(" 1 ")" 3 ) +# 8200 "parsing/parser.ml" + : 'class_simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'class_self_pattern) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'class_fields) in + Obj.repr( +# 1066 "parsing/parser.mly" + ( Cstr.mk _1 (extra_cstr 2 (List.rev _2)) ) +# 8208 "parsing/parser.ml" + : 'class_structure)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'pattern) in + Obj.repr( +# 1070 "parsing/parser.mly" + ( reloc_pat _2 ) +# 8215 "parsing/parser.ml" + : 'class_self_pattern)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'pattern) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'core_type) in + Obj.repr( +# 1072 "parsing/parser.mly" + ( mkpat(Ppat_constraint(_2, _4)) ) +# 8223 "parsing/parser.ml" + : 'class_self_pattern)) +; (fun __caml_parser_env -> + Obj.repr( +# 1074 "parsing/parser.mly" + ( ghpat(Ppat_any) ) +# 8229 "parsing/parser.ml" + : 'class_self_pattern)) +; (fun __caml_parser_env -> + Obj.repr( +# 1078 "parsing/parser.mly" + ( [] ) +# 8235 "parsing/parser.ml" + : 'class_fields)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'class_fields) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'class_field) in + Obj.repr( +# 1080 "parsing/parser.mly" + ( _2 :: (text_cstr 2) @ _1 ) +# 8243 "parsing/parser.ml" + : 'class_fields)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 4 : 'override_flag) in + let _3 = (Parsing.peek_val __caml_parser_env 3 : 'attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 2 : 'class_expr) in + let _5 = (Parsing.peek_val __caml_parser_env 1 : 'parent_binder) in + let _6 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1085 "parsing/parser.mly" + ( mkcf (Pcf_inherit (_2, _4, _5)) ~attrs:(_3@_6) ~docs:(symbol_docs ()) ) +# 8254 "parsing/parser.ml" + : 'class_field)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'value) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1087 "parsing/parser.mly" + ( let v, attrs = _2 in + mkcf (Pcf_val v) ~attrs:(attrs@_3) ~docs:(symbol_docs ()) ) +# 8263 "parsing/parser.ml" + : 'class_field)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'method_) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1090 "parsing/parser.mly" + ( let meth, attrs = _2 in + mkcf (Pcf_method meth) ~attrs:(attrs@_3) ~docs:(symbol_docs ()) ) +# 8272 "parsing/parser.ml" + : 'class_field)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'constrain_field) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1093 "parsing/parser.mly" + ( mkcf (Pcf_constraint _3) ~attrs:(_2@_4) ~docs:(symbol_docs ()) ) +# 8281 "parsing/parser.ml" + : 'class_field)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1095 "parsing/parser.mly" + ( mkcf (Pcf_initializer _3) ~attrs:(_2@_4) ~docs:(symbol_docs ()) ) +# 8290 "parsing/parser.ml" + : 'class_field)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'item_extension) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1097 "parsing/parser.mly" + ( mkcf (Pcf_extension _1) ~attrs:_2 ~docs:(symbol_docs ()) ) +# 8298 "parsing/parser.ml" + : 'class_field)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'floating_attribute) in + Obj.repr( +# 1099 "parsing/parser.mly" + ( mark_symbol_docs (); + mkcf (Pcf_attribute _1) ) +# 8306 "parsing/parser.ml" + : 'class_field)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 1104 "parsing/parser.mly" + ( Some (mkrhs _2 2) ) +# 8313 "parsing/parser.ml" + : 'parent_binder)) +; (fun __caml_parser_env -> + Obj.repr( +# 1106 "parsing/parser.mly" + ( None ) +# 8319 "parsing/parser.ml" + : 'parent_binder)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 6 : 'override_flag) in + let _2 = (Parsing.peek_val __caml_parser_env 5 : 'attributes) in + let _5 = (Parsing.peek_val __caml_parser_env 2 : 'label) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in + Obj.repr( +# 1111 "parsing/parser.mly" + ( if _1 = Override then syntax_error (); + (mkloc _5 (rhs_loc 5), Mutable, Cfk_virtual _7), _2 ) +# 8330 "parsing/parser.ml" + : 'value)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 6 : 'override_flag) in + let _2 = (Parsing.peek_val __caml_parser_env 5 : 'attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : 'mutable_flag) in + let _5 = (Parsing.peek_val __caml_parser_env 2 : 'label) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in + Obj.repr( +# 1114 "parsing/parser.mly" + ( if _1 = Override then syntax_error (); + (mkrhs _5 5, _4, Cfk_virtual _7), _2 ) +# 8342 "parsing/parser.ml" + : 'value)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 5 : 'override_flag) in + let _2 = (Parsing.peek_val __caml_parser_env 4 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 3 : 'mutable_flag) in + let _4 = (Parsing.peek_val __caml_parser_env 2 : 'label) in + let _6 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1117 "parsing/parser.mly" + ( (mkrhs _4 4, _3, Cfk_concrete (_1, _6)), _2 ) +# 8353 "parsing/parser.ml" + : 'value)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 6 : 'override_flag) in + let _2 = (Parsing.peek_val __caml_parser_env 5 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'mutable_flag) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : 'label) in + let _5 = (Parsing.peek_val __caml_parser_env 2 : 'type_constraint) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1119 "parsing/parser.mly" + ( + let e = mkexp_constraint _7 _5 in + (mkrhs _4 4, _3, Cfk_concrete (_1, e)), _2 + ) +# 8368 "parsing/parser.ml" + : 'value)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 6 : 'override_flag) in + let _2 = (Parsing.peek_val __caml_parser_env 5 : 'attributes) in + let _5 = (Parsing.peek_val __caml_parser_env 2 : 'label) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'poly_type) in + Obj.repr( +# 1127 "parsing/parser.mly" + ( if _1 = Override then syntax_error (); + (mkloc _5 (rhs_loc 5), Private, Cfk_virtual _7), _2 ) +# 8379 "parsing/parser.ml" + : 'method_)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 6 : 'override_flag) in + let _2 = (Parsing.peek_val __caml_parser_env 5 : 'attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : 'private_flag) in + let _5 = (Parsing.peek_val __caml_parser_env 2 : 'label) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'poly_type) in + Obj.repr( +# 1130 "parsing/parser.mly" + ( if _1 = Override then syntax_error (); + (mkloc _5 (rhs_loc 5), _4, Cfk_virtual _7), _2 ) +# 8391 "parsing/parser.ml" + : 'method_)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'override_flag) in + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'private_flag) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'label) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'strict_binding) in + Obj.repr( +# 1133 "parsing/parser.mly" + ( (mkloc _4 (rhs_loc 4), _3, + Cfk_concrete (_1, ghexp(Pexp_poly (_5, None)))), _2 ) +# 8403 "parsing/parser.ml" + : 'method_)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 7 : 'override_flag) in + let _2 = (Parsing.peek_val __caml_parser_env 6 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 5 : 'private_flag) in + let _4 = (Parsing.peek_val __caml_parser_env 4 : 'label) in + let _6 = (Parsing.peek_val __caml_parser_env 2 : 'poly_type) in + let _8 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1136 "parsing/parser.mly" + ( (mkloc _4 (rhs_loc 4), _3, + Cfk_concrete (_1, ghexp(Pexp_poly(_8, Some _6)))), _2 ) +# 8416 "parsing/parser.ml" + : 'method_)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 10 : 'override_flag) in + let _2 = (Parsing.peek_val __caml_parser_env 9 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 8 : 'private_flag) in + let _4 = (Parsing.peek_val __caml_parser_env 7 : 'label) in + let _7 = (Parsing.peek_val __caml_parser_env 4 : 'lident_list) in + let _9 = (Parsing.peek_val __caml_parser_env 2 : 'core_type) in + let _11 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1140 "parsing/parser.mly" + ( let exp, poly = wrap_type_annotation _7 _9 _11 in + (mkloc _4 (rhs_loc 4), _3, + Cfk_concrete (_1, ghexp(Pexp_poly(exp, Some poly)))), _2 ) +# 8431 "parsing/parser.ml" + : 'method_)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'class_signature) in + Obj.repr( +# 1149 "parsing/parser.mly" + ( _1 ) +# 8438 "parsing/parser.ml" + : 'class_type)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 4 : string) in + let _4 = (Parsing.peek_val __caml_parser_env 2 : 'simple_core_type_or_tuple) in + let _6 = (Parsing.peek_val __caml_parser_env 0 : 'class_type) in + Obj.repr( +# 1152 "parsing/parser.mly" + ( mkcty(Pcty_arrow(Optional _2 , _4, _6)) ) +# 8447 "parsing/parser.ml" + : 'class_type)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'simple_core_type_or_tuple) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'class_type) in + Obj.repr( +# 1154 "parsing/parser.mly" + ( mkcty(Pcty_arrow(Optional _1, _2, _4)) ) +# 8456 "parsing/parser.ml" + : 'class_type)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : string) in + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'simple_core_type_or_tuple) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'class_type) in + Obj.repr( +# 1156 "parsing/parser.mly" + ( mkcty(Pcty_arrow(Labelled _1, _3, _5)) ) +# 8465 "parsing/parser.ml" + : 'class_type)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'simple_core_type_or_tuple) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'class_type) in + Obj.repr( +# 1158 "parsing/parser.mly" + ( mkcty(Pcty_arrow(Nolabel, _1, _3)) ) +# 8473 "parsing/parser.ml" + : 'class_type)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'core_type_comma_list) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'clty_longident) in + Obj.repr( +# 1162 "parsing/parser.mly" + ( mkcty(Pcty_constr (mkloc _4 (rhs_loc 4), List.rev _2)) ) +# 8481 "parsing/parser.ml" + : 'class_signature)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'clty_longident) in + Obj.repr( +# 1164 "parsing/parser.mly" + ( mkcty(Pcty_constr (mkrhs _1 1, [])) ) +# 8488 "parsing/parser.ml" + : 'class_signature)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'class_sig_body) in + Obj.repr( +# 1166 "parsing/parser.mly" + ( mkcty ~attrs:_2 (Pcty_signature _3) ) +# 8496 "parsing/parser.ml" + : 'class_signature)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'class_sig_body) in + Obj.repr( +# 1168 "parsing/parser.mly" + ( unclosed "object" 1 "end" 4 ) +# 8504 "parsing/parser.ml" + : 'class_signature)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'class_signature) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attribute) in + Obj.repr( +# 1170 "parsing/parser.mly" + ( Cty.attr _1 _2 ) +# 8512 "parsing/parser.ml" + : 'class_signature)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'extension) in + Obj.repr( +# 1172 "parsing/parser.mly" + ( mkcty(Pcty_extension _1) ) +# 8519 "parsing/parser.ml" + : 'class_signature)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'override_flag) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : 'attributes) in + let _5 = (Parsing.peek_val __caml_parser_env 2 : 'mod_longident) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'class_signature) in + Obj.repr( +# 1174 "parsing/parser.mly" + ( wrap_class_type_attrs (mkcty(Pcty_open(_3, mkrhs _5 5, _7))) _4 ) +# 8529 "parsing/parser.ml" + : 'class_signature)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'class_self_type) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'class_sig_fields) in + Obj.repr( +# 1178 "parsing/parser.mly" + ( Csig.mk _1 (extra_csig 2 (List.rev _2)) ) +# 8537 "parsing/parser.ml" + : 'class_sig_body)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'core_type) in + Obj.repr( +# 1182 "parsing/parser.mly" + ( _2 ) +# 8544 "parsing/parser.ml" + : 'class_self_type)) +; (fun __caml_parser_env -> + Obj.repr( +# 1184 "parsing/parser.mly" + ( mktyp(Ptyp_any) ) +# 8550 "parsing/parser.ml" + : 'class_self_type)) +; (fun __caml_parser_env -> + Obj.repr( +# 1187 "parsing/parser.mly" + ( [] ) +# 8556 "parsing/parser.ml" + : 'class_sig_fields)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'class_sig_fields) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'class_sig_field) in + Obj.repr( +# 1188 "parsing/parser.mly" + ( _2 :: (text_csig 2) @ _1 ) +# 8564 "parsing/parser.ml" + : 'class_sig_fields)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'class_signature) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1192 "parsing/parser.mly" + ( mkctf (Pctf_inherit _3) ~attrs:(_2@_4) ~docs:(symbol_docs ()) ) +# 8573 "parsing/parser.ml" + : 'class_sig_field)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'value_type) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1194 "parsing/parser.mly" + ( mkctf (Pctf_val _3) ~attrs:(_2@_4) ~docs:(symbol_docs ()) ) +# 8582 "parsing/parser.ml" + : 'class_sig_field)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 5 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'private_virtual_flags) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : 'label) in + let _6 = (Parsing.peek_val __caml_parser_env 1 : 'poly_type) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1197 "parsing/parser.mly" + ( + let (p, v) = _3 in + mkctf (Pctf_method (mkrhs _4 4, p, v, _6)) ~attrs:(_2@_7) ~docs:(symbol_docs ()) + ) +# 8596 "parsing/parser.ml" + : 'class_sig_field)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'constrain_field) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1202 "parsing/parser.mly" + ( mkctf (Pctf_constraint _3) ~attrs:(_2@_4) ~docs:(symbol_docs ()) ) +# 8605 "parsing/parser.ml" + : 'class_sig_field)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'item_extension) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1204 "parsing/parser.mly" + ( mkctf (Pctf_extension _1) ~attrs:_2 ~docs:(symbol_docs ()) ) +# 8613 "parsing/parser.ml" + : 'class_sig_field)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'floating_attribute) in + Obj.repr( +# 1206 "parsing/parser.mly" + ( mark_symbol_docs (); + mkctf(Pctf_attribute _1) ) +# 8621 "parsing/parser.ml" + : 'class_sig_field)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'mutable_flag) in + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'label) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in + Obj.repr( +# 1211 "parsing/parser.mly" + ( mkrhs _3 3, _2, Virtual, _5 ) +# 8630 "parsing/parser.ml" + : 'value_type)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'virtual_flag) in + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'label) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in + Obj.repr( +# 1213 "parsing/parser.mly" + ( mkrhs _3 3, Mutable, _2, _5 ) +# 8639 "parsing/parser.ml" + : 'value_type)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'label) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in + Obj.repr( +# 1215 "parsing/parser.mly" + ( mkrhs _1 1, Immutable, Concrete, _3 ) +# 8647 "parsing/parser.ml" + : 'value_type)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'core_type) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in + Obj.repr( +# 1218 "parsing/parser.mly" + ( _1, _3, symbol_rloc() ) +# 8655 "parsing/parser.ml" + : 'constrain)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'core_type) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in + Obj.repr( +# 1221 "parsing/parser.mly" + ( _1, _3 ) +# 8663 "parsing/parser.ml" + : 'constrain_field)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'class_description) in + Obj.repr( +# 1225 "parsing/parser.mly" + ( let (body, ext) = _1 in ([body],ext) ) +# 8670 "parsing/parser.ml" + : 'class_descriptions)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'class_descriptions) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'and_class_description) in + Obj.repr( +# 1227 "parsing/parser.mly" + ( let (l, ext) = _1 in (_2 :: l, ext) ) +# 8678 "parsing/parser.ml" + : 'class_descriptions)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 6 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 5 : 'virtual_flag) in + let _4 = (Parsing.peek_val __caml_parser_env 4 : 'class_type_parameters) in + let _5 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _7 = (Parsing.peek_val __caml_parser_env 1 : 'class_type) in + let _8 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1232 "parsing/parser.mly" + ( let (ext, attrs) = _2 in + Ci.mk (mkrhs _5 5) _7 ~virt:_3 ~params:_4 ~attrs:(attrs @ _8) + ~loc:(symbol_rloc ()) ~docs:(symbol_docs ()) + , ext ) +# 8693 "parsing/parser.ml" + : 'class_description)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 6 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 5 : 'virtual_flag) in + let _4 = (Parsing.peek_val __caml_parser_env 4 : 'class_type_parameters) in + let _5 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _7 = (Parsing.peek_val __caml_parser_env 1 : 'class_type) in + let _8 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1240 "parsing/parser.mly" + ( Ci.mk (mkrhs _5 5) _7 ~virt:_3 ~params:_4 + ~attrs:(_2@_8) ~loc:(symbol_rloc ()) + ~text:(symbol_text ()) ~docs:(symbol_docs ()) ) +# 8707 "parsing/parser.ml" + : 'and_class_description)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'class_type_declaration) in + Obj.repr( +# 1246 "parsing/parser.mly" + ( let (body, ext) = _1 in ([body],ext) ) +# 8714 "parsing/parser.ml" + : 'class_type_declarations)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'class_type_declarations) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'and_class_type_declaration) in + Obj.repr( +# 1248 "parsing/parser.mly" + ( let (l, ext) = _1 in (_2 :: l, ext) ) +# 8722 "parsing/parser.ml" + : 'class_type_declarations)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 6 : 'ext_attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 5 : 'virtual_flag) in + let _5 = (Parsing.peek_val __caml_parser_env 4 : 'class_type_parameters) in + let _6 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _8 = (Parsing.peek_val __caml_parser_env 1 : 'class_signature) in + let _9 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1253 "parsing/parser.mly" + ( let (ext, attrs) = _3 in + Ci.mk (mkrhs _6 6) _8 ~virt:_4 ~params:_5 ~attrs:(attrs@_9) + ~loc:(symbol_rloc ()) ~docs:(symbol_docs ()) + , ext) +# 8737 "parsing/parser.ml" + : 'class_type_declaration)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 6 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 5 : 'virtual_flag) in + let _4 = (Parsing.peek_val __caml_parser_env 4 : 'class_type_parameters) in + let _5 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _7 = (Parsing.peek_val __caml_parser_env 1 : 'class_signature) in + let _8 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1261 "parsing/parser.mly" + ( Ci.mk (mkrhs _5 5) _7 ~virt:_3 ~params:_4 + ~attrs:(_2@_8) ~loc:(symbol_rloc ()) + ~text:(symbol_text ()) ~docs:(symbol_docs ()) ) +# 8751 "parsing/parser.ml" + : 'and_class_type_declaration)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1269 "parsing/parser.mly" + ( _1 ) +# 8758 "parsing/parser.ml" + : 'seq_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in + Obj.repr( +# 1270 "parsing/parser.mly" + ( _1 ) +# 8765 "parsing/parser.ml" + : 'seq_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1271 "parsing/parser.mly" + ( mkexp(Pexp_sequence(_1, _3)) ) +# 8773 "parsing/parser.ml" + : 'seq_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'expr) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'attr_id) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1273 "parsing/parser.mly" + ( let seq = mkexp(Pexp_sequence (_1, _5)) in + let payload = PStr [mkstrexp seq []] in + mkexp (Pexp_extension (_4, payload)) ) +# 8784 "parsing/parser.ml" + : 'seq_expr)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'label_let_pattern) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'opt_default) in + Obj.repr( +# 1279 "parsing/parser.mly" + ( (Optional (fst _3), _4, snd _3) ) +# 8792 "parsing/parser.ml" + : 'labeled_simple_pattern)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'label_var) in + Obj.repr( +# 1281 "parsing/parser.mly" + ( (Optional (fst _2), None, snd _2) ) +# 8799 "parsing/parser.ml" + : 'labeled_simple_pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : string) in + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'let_pattern) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'opt_default) in + Obj.repr( +# 1283 "parsing/parser.mly" + ( (Optional _1, _4, _3) ) +# 8808 "parsing/parser.ml" + : 'labeled_simple_pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : string) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'pattern_var) in + Obj.repr( +# 1285 "parsing/parser.mly" + ( (Optional _1, None, _2) ) +# 8816 "parsing/parser.ml" + : 'labeled_simple_pattern)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'label_let_pattern) in + Obj.repr( +# 1287 "parsing/parser.mly" + ( (Labelled (fst _3), None, snd _3) ) +# 8823 "parsing/parser.ml" + : 'labeled_simple_pattern)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'label_var) in + Obj.repr( +# 1289 "parsing/parser.mly" + ( (Labelled (fst _2), None, snd _2) ) +# 8830 "parsing/parser.ml" + : 'labeled_simple_pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : string) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'simple_pattern) in + Obj.repr( +# 1291 "parsing/parser.mly" + ( (Labelled _1, None, _2) ) +# 8838 "parsing/parser.ml" + : 'labeled_simple_pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_pattern) in + Obj.repr( +# 1293 "parsing/parser.mly" + ( (Nolabel, None, _1) ) +# 8845 "parsing/parser.ml" + : 'labeled_simple_pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 1296 "parsing/parser.mly" + ( mkpat(Ppat_var (mkrhs _1 1)) ) +# 8852 "parsing/parser.ml" + : 'pattern_var)) +; (fun __caml_parser_env -> + Obj.repr( +# 1297 "parsing/parser.mly" + ( mkpat Ppat_any ) +# 8858 "parsing/parser.ml" + : 'pattern_var)) +; (fun __caml_parser_env -> + Obj.repr( +# 1300 "parsing/parser.mly" + ( None ) +# 8864 "parsing/parser.ml" + : 'opt_default)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1301 "parsing/parser.mly" + ( Some _2 ) +# 8871 "parsing/parser.ml" + : 'opt_default)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'label_var) in + Obj.repr( +# 1305 "parsing/parser.mly" + ( _1 ) +# 8878 "parsing/parser.ml" + : 'label_let_pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'label_var) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in + Obj.repr( +# 1307 "parsing/parser.mly" + ( let (lab, pat) = _1 in (lab, mkpat(Ppat_constraint(pat, _3))) ) +# 8886 "parsing/parser.ml" + : 'label_let_pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 1310 "parsing/parser.mly" + ( (_1, mkpat(Ppat_var (mkrhs _1 1))) ) +# 8893 "parsing/parser.ml" + : 'label_var)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in + Obj.repr( +# 1314 "parsing/parser.mly" + ( _1 ) +# 8900 "parsing/parser.ml" + : 'let_pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in + Obj.repr( +# 1316 "parsing/parser.mly" + ( mkpat(Ppat_constraint(_1, _3)) ) +# 8908 "parsing/parser.ml" + : 'let_pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in + Obj.repr( +# 1320 "parsing/parser.mly" + ( _1 ) +# 8915 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'simple_expr) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'simple_labeled_expr_list) in + Obj.repr( +# 1322 "parsing/parser.mly" + ( mkexp(Pexp_apply(_1, List.rev _2)) ) +# 8923 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'let_bindings) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1324 "parsing/parser.mly" + ( expr_of_let_bindings _1 _3 ) +# 8931 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _5 = (Parsing.peek_val __caml_parser_env 2 : 'module_binding_body) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1326 "parsing/parser.mly" + ( mkexp_attrs (Pexp_letmodule(mkrhs _4 4, _5, _7)) _3 ) +# 8941 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 3 : 'ext_attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 2 : 'let_exception_declaration) in + let _6 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1328 "parsing/parser.mly" + ( mkexp_attrs (Pexp_letexception(_4, _6)) _3 ) +# 8950 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'override_flag) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : 'ext_attributes) in + let _5 = (Parsing.peek_val __caml_parser_env 2 : 'mod_longident) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1330 "parsing/parser.mly" + ( mkexp_attrs (Pexp_open(_3, mkrhs _5 5, _7)) _4 ) +# 8960 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'opt_bar) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'match_cases) in + Obj.repr( +# 1332 "parsing/parser.mly" + ( mkexp_attrs (Pexp_function(List.rev _4)) _2 ) +# 8969 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'labeled_simple_pattern) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'fun_def) in + Obj.repr( +# 1334 "parsing/parser.mly" + ( let (l,o,p) = _3 in + mkexp_attrs (Pexp_fun(l, o, p, _4)) _2 ) +# 8979 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 5 : 'ext_attributes) in + let _5 = (Parsing.peek_val __caml_parser_env 2 : 'lident_list) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'fun_def) in + Obj.repr( +# 1337 "parsing/parser.mly" + ( mkexp_attrs (mk_newtypes _5 _7).pexp_desc _2 ) +# 8988 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 3 : 'seq_expr) in + let _5 = (Parsing.peek_val __caml_parser_env 1 : 'opt_bar) in + let _6 = (Parsing.peek_val __caml_parser_env 0 : 'match_cases) in + Obj.repr( +# 1339 "parsing/parser.mly" + ( mkexp_attrs (Pexp_match(_3, List.rev _6)) _2 ) +# 8998 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 3 : 'seq_expr) in + let _5 = (Parsing.peek_val __caml_parser_env 1 : 'opt_bar) in + let _6 = (Parsing.peek_val __caml_parser_env 0 : 'match_cases) in + Obj.repr( +# 1341 "parsing/parser.mly" + ( mkexp_attrs (Pexp_try(_3, List.rev _6)) _2 ) +# 9008 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'seq_expr) in + Obj.repr( +# 1343 "parsing/parser.mly" + ( syntax_error() ) +# 9016 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'expr_comma_list) in + Obj.repr( +# 1345 "parsing/parser.mly" + ( mkexp(Pexp_tuple(List.rev _1)) ) +# 9023 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'constr_longident) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in + Obj.repr( +# 1347 "parsing/parser.mly" + ( mkexp(Pexp_construct(mkrhs _1 1, Some _2)) ) +# 9031 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'name_tag) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in + Obj.repr( +# 1349 "parsing/parser.mly" + ( mkexp(Pexp_variant(_1, Some _2)) ) +# 9039 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 5 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'seq_expr) in + let _5 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1351 "parsing/parser.mly" + ( mkexp_attrs(Pexp_ifthenelse(_3, _5, Some _7)) _2 ) +# 9049 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'seq_expr) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1353 "parsing/parser.mly" + ( mkexp_attrs (Pexp_ifthenelse(_3, _5, None)) _2 ) +# 9058 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 3 : 'seq_expr) in + let _5 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in + Obj.repr( +# 1355 "parsing/parser.mly" + ( mkexp_attrs (Pexp_while(_3, _5)) _2 ) +# 9067 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 8 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 7 : 'pattern) in + let _5 = (Parsing.peek_val __caml_parser_env 5 : 'seq_expr) in + let _6 = (Parsing.peek_val __caml_parser_env 4 : 'direction_flag) in + let _7 = (Parsing.peek_val __caml_parser_env 3 : 'seq_expr) in + let _9 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in + Obj.repr( +# 1358 "parsing/parser.mly" + ( mkexp_attrs(Pexp_for(_3, _5, _7, _6, _9)) _2 ) +# 9079 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1360 "parsing/parser.mly" + ( mkexp_cons (rhs_loc 2) (ghexp(Pexp_tuple[_1;_3])) (symbol_rloc()) ) +# 9087 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _2 = (Parsing.peek_val __caml_parser_env 1 : string) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1362 "parsing/parser.mly" + ( mkinfix _1 _2 _3 ) +# 9096 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _2 = (Parsing.peek_val __caml_parser_env 1 : string) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1364 "parsing/parser.mly" + ( mkinfix _1 _2 _3 ) +# 9105 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _2 = (Parsing.peek_val __caml_parser_env 1 : string) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1366 "parsing/parser.mly" + ( mkinfix _1 _2 _3 ) +# 9114 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _2 = (Parsing.peek_val __caml_parser_env 1 : string) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1368 "parsing/parser.mly" + ( mkinfix _1 _2 _3 ) +# 9123 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _2 = (Parsing.peek_val __caml_parser_env 1 : string) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1370 "parsing/parser.mly" + ( mkinfix _1 _2 _3 ) +# 9132 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1372 "parsing/parser.mly" + ( mkinfix _1 "+" _3 ) +# 9140 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1374 "parsing/parser.mly" + ( mkinfix _1 "+." _3 ) +# 9148 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1376 "parsing/parser.mly" + ( mkinfix _1 "+=" _3 ) +# 9156 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1378 "parsing/parser.mly" + ( mkinfix _1 "-" _3 ) +# 9164 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1380 "parsing/parser.mly" + ( mkinfix _1 "-." _3 ) +# 9172 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1382 "parsing/parser.mly" + ( mkinfix _1 "*" _3 ) +# 9180 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1384 "parsing/parser.mly" + ( mkinfix _1 "%" _3 ) +# 9188 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1386 "parsing/parser.mly" + ( mkinfix _1 "=" _3 ) +# 9196 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1388 "parsing/parser.mly" + ( mkinfix _1 "<" _3 ) +# 9204 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1390 "parsing/parser.mly" + ( mkinfix _1 ">" _3 ) +# 9212 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1392 "parsing/parser.mly" + ( mkinfix _1 "or" _3 ) +# 9220 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1394 "parsing/parser.mly" + ( mkinfix _1 "||" _3 ) +# 9228 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1396 "parsing/parser.mly" + ( mkinfix _1 "&" _3 ) +# 9236 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1398 "parsing/parser.mly" + ( mkinfix _1 "&&" _3 ) +# 9244 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1400 "parsing/parser.mly" + ( mkinfix _1 ":=" _3 ) +# 9252 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'subtractive) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1402 "parsing/parser.mly" + ( mkuminus _1 _2 ) +# 9260 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'additive) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1404 "parsing/parser.mly" + ( mkuplus _1 _2 ) +# 9268 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'label_longident) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1406 "parsing/parser.mly" + ( mkexp(Pexp_setfield(_1, mkrhs _3 3, _5)) ) +# 9277 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : 'seq_expr) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1408 "parsing/parser.mly" + ( mkexp(Pexp_apply(ghexp(Pexp_ident(array_function "Array" "set")), + [Nolabel,_1; Nolabel,_4; Nolabel,_7])) ) +# 9287 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : 'seq_expr) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1411 "parsing/parser.mly" + ( mkexp(Pexp_apply(ghexp(Pexp_ident(array_function "String" "set")), + [Nolabel,_1; Nolabel,_4; Nolabel,_7])) ) +# 9297 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : 'expr) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1414 "parsing/parser.mly" + ( bigarray_set _1 _4 _7 ) +# 9306 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in + let _2 = (Parsing.peek_val __caml_parser_env 5 : string) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : 'expr) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1416 "parsing/parser.mly" + ( let id = mkexp @@ Pexp_ident( ghloc @@ Lident ("." ^ _2 ^ "[]<-")) in + mkexp @@ Pexp_apply(id , [Nolabel, _1; Nolabel, _4; Nolabel, _7]) ) +# 9317 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in + let _2 = (Parsing.peek_val __caml_parser_env 5 : string) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : 'expr) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1419 "parsing/parser.mly" + ( let id = mkexp @@ Pexp_ident( ghloc @@ Lident ("." ^ _2 ^ "()<-")) in + mkexp @@ Pexp_apply(id , [Nolabel, _1; Nolabel, _4; Nolabel, _7]) ) +# 9328 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in + let _2 = (Parsing.peek_val __caml_parser_env 5 : string) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : 'expr) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1422 "parsing/parser.mly" + ( let id = mkexp @@ Pexp_ident( ghloc @@ Lident ("." ^ _2 ^ "{}<-")) in + mkexp @@ Pexp_apply(id , [Nolabel, _1; Nolabel, _4; Nolabel, _7]) ) +# 9339 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 8 : 'simple_expr) in + let _3 = (Parsing.peek_val __caml_parser_env 6 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 5 : string) in + let _6 = (Parsing.peek_val __caml_parser_env 3 : 'expr) in + let _9 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1425 "parsing/parser.mly" + ( let id = mkexp @@ Pexp_ident( ghloc @@ Ldot(_3,"." ^ _4 ^ "[]<-")) in + mkexp @@ Pexp_apply(id , [Nolabel, _1; Nolabel, _6; Nolabel, _9]) ) +# 9351 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 8 : 'simple_expr) in + let _3 = (Parsing.peek_val __caml_parser_env 6 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 5 : string) in + let _6 = (Parsing.peek_val __caml_parser_env 3 : 'expr) in + let _9 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1428 "parsing/parser.mly" + ( let id = mkexp @@ Pexp_ident( ghloc @@ Ldot(_3, "." ^ _4 ^ "()<-")) in + mkexp @@ Pexp_apply(id , [Nolabel, _1; Nolabel, _6; Nolabel, _9]) ) +# 9363 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 8 : 'simple_expr) in + let _3 = (Parsing.peek_val __caml_parser_env 6 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 5 : string) in + let _6 = (Parsing.peek_val __caml_parser_env 3 : 'expr) in + let _9 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1431 "parsing/parser.mly" + ( let id = mkexp @@ Pexp_ident( ghloc @@ Ldot(_3, "." ^ _4 ^ "{}<-")) in + mkexp @@ Pexp_apply(id , [Nolabel, _1; Nolabel, _6; Nolabel, _9]) ) +# 9375 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'label) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1434 "parsing/parser.mly" + ( mkexp(Pexp_setinstvar(mkrhs _1 1, _3)) ) +# 9383 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in + Obj.repr( +# 1436 "parsing/parser.mly" + ( mkexp_attrs (Pexp_assert _3) _2 ) +# 9391 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in + Obj.repr( +# 1438 "parsing/parser.mly" + ( mkexp_attrs (Pexp_lazy _3) _2 ) +# 9399 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'class_structure) in + Obj.repr( +# 1440 "parsing/parser.mly" + ( mkexp_attrs (Pexp_object _3) _2 ) +# 9407 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'class_structure) in + Obj.repr( +# 1442 "parsing/parser.mly" + ( unclosed "object" 1 "end" 4 ) +# 9415 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attribute) in + Obj.repr( +# 1444 "parsing/parser.mly" + ( Exp.attr _1 _2 ) +# 9423 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + Obj.repr( +# 1446 "parsing/parser.mly" + ( not_expecting 1 "wildcard \"_\"" ) +# 9429 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'val_longident) in + Obj.repr( +# 1450 "parsing/parser.mly" + ( mkexp(Pexp_ident (mkrhs _1 1)) ) +# 9436 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'constant) in + Obj.repr( +# 1452 "parsing/parser.mly" + ( mkexp(Pexp_constant _1) ) +# 9443 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'constr_longident) in + Obj.repr( +# 1454 "parsing/parser.mly" + ( mkexp(Pexp_construct(mkrhs _1 1, None)) ) +# 9450 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'name_tag) in + Obj.repr( +# 1456 "parsing/parser.mly" + ( mkexp(Pexp_variant(_1, None)) ) +# 9457 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in + Obj.repr( +# 1458 "parsing/parser.mly" + ( reloc_exp _2 ) +# 9464 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in + Obj.repr( +# 1460 "parsing/parser.mly" + ( unclosed "(" 1 ")" 3 ) +# 9471 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in + Obj.repr( +# 1462 "parsing/parser.mly" + ( wrap_exp_attrs (reloc_exp _3) _2 (* check location *) ) +# 9479 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ext_attributes) in + Obj.repr( +# 1464 "parsing/parser.mly" + ( mkexp_attrs (Pexp_construct (mkloc (Lident "()") (symbol_rloc ()), + None)) _2 ) +# 9487 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in + Obj.repr( +# 1467 "parsing/parser.mly" + ( unclosed "begin" 1 "end" 4 ) +# 9495 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'seq_expr) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'type_constraint) in + Obj.repr( +# 1469 "parsing/parser.mly" + ( mkexp_constraint _2 _3 ) +# 9503 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'simple_expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'label_longident) in + Obj.repr( +# 1471 "parsing/parser.mly" + ( mkexp(Pexp_field(_1, mkrhs _3 3)) ) +# 9511 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in + Obj.repr( +# 1473 "parsing/parser.mly" + ( mkexp(Pexp_open(Fresh, mkrhs _1 1, _4)) ) +# 9519 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 3 : 'mod_longident) in + Obj.repr( +# 1475 "parsing/parser.mly" + ( mkexp(Pexp_open(Fresh, mkrhs _1 1, + mkexp(Pexp_construct(mkrhs (Lident "()") 1, None)))) ) +# 9527 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in + Obj.repr( +# 1478 "parsing/parser.mly" + ( unclosed "(" 3 ")" 5 ) +# 9535 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in + Obj.repr( +# 1480 "parsing/parser.mly" + ( mkexp(Pexp_apply(ghexp(Pexp_ident(array_function "Array" "get")), + [Nolabel,_1; Nolabel,_4])) ) +# 9544 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in + Obj.repr( +# 1483 "parsing/parser.mly" + ( unclosed "(" 3 ")" 5 ) +# 9552 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in + Obj.repr( +# 1485 "parsing/parser.mly" + ( mkexp(Pexp_apply(ghexp(Pexp_ident(array_function "String" "get")), + [Nolabel,_1; Nolabel,_4])) ) +# 9561 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in + Obj.repr( +# 1488 "parsing/parser.mly" + ( unclosed "[" 3 "]" 5 ) +# 9569 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in + let _2 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in + Obj.repr( +# 1490 "parsing/parser.mly" + ( let id = mkexp @@ Pexp_ident( ghloc @@ Lident ("." ^ _2 ^ "[]")) in + mkexp @@ Pexp_apply(id, [Nolabel, _1; Nolabel, _4]) ) +# 9579 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in + let _2 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in + Obj.repr( +# 1493 "parsing/parser.mly" + ( unclosed "[" 3 "]" 5 ) +# 9588 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in + let _2 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in + Obj.repr( +# 1495 "parsing/parser.mly" + ( let id = mkexp @@ Pexp_ident( ghloc @@ Lident ("." ^ _2 ^ "()")) in + mkexp @@ Pexp_apply(id, [Nolabel, _1; Nolabel, _4]) ) +# 9598 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in + let _2 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in + Obj.repr( +# 1498 "parsing/parser.mly" + ( unclosed "(" 3 ")" 5 ) +# 9607 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in + let _2 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in + Obj.repr( +# 1500 "parsing/parser.mly" + ( let id = mkexp @@ Pexp_ident( ghloc @@ Lident ("." ^ _2 ^ "{}")) in + mkexp @@ Pexp_apply(id, [Nolabel, _1; Nolabel, _4]) ) +# 9617 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in + let _2 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in + Obj.repr( +# 1503 "parsing/parser.mly" + ( unclosed "{" 3 "}" 5 ) +# 9626 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _6 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in + Obj.repr( +# 1505 "parsing/parser.mly" + ( let id = mkexp @@ Pexp_ident( ghloc @@ Ldot(_3, "." ^ _4 ^ "[]")) in + mkexp @@ Pexp_apply(id, [Nolabel, _1; Nolabel, _6]) ) +# 9637 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _6 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in + Obj.repr( +# 1508 "parsing/parser.mly" + ( unclosed "[" 5 "]" 7 ) +# 9647 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _6 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in + Obj.repr( +# 1510 "parsing/parser.mly" + ( let id = mkexp @@ Pexp_ident( ghloc @@ Ldot(_3, "." ^ _4 ^ "()")) in + mkexp @@ Pexp_apply(id, [Nolabel, _1; Nolabel, _6]) ) +# 9658 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _6 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in + Obj.repr( +# 1513 "parsing/parser.mly" + ( unclosed "(" 5 ")" 7 ) +# 9668 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _6 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in + Obj.repr( +# 1515 "parsing/parser.mly" + ( let id = mkexp @@ Pexp_ident( ghloc @@ Ldot(_3, "." ^ _4 ^ "{}")) in + mkexp @@ Pexp_apply(id, [Nolabel, _1; Nolabel, _6]) ) +# 9679 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _6 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in + Obj.repr( +# 1518 "parsing/parser.mly" + ( unclosed "{" 5 "}" 7 ) +# 9689 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in + Obj.repr( +# 1520 "parsing/parser.mly" + ( bigarray_get _1 _4 ) +# 9697 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'expr_comma_list) in + Obj.repr( +# 1522 "parsing/parser.mly" + ( unclosed "{" 3 "}" 5 ) +# 9705 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'record_expr) in + Obj.repr( +# 1524 "parsing/parser.mly" + ( let (exten, fields) = _2 in mkexp (Pexp_record(fields, exten)) ) +# 9712 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'record_expr) in + Obj.repr( +# 1526 "parsing/parser.mly" + ( unclosed "{" 1 "}" 3 ) +# 9719 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'record_expr) in + Obj.repr( +# 1528 "parsing/parser.mly" + ( let (exten, fields) = _4 in + let rec_exp = mkexp(Pexp_record(fields, exten)) in + mkexp(Pexp_open(Fresh, mkrhs _1 1, rec_exp)) ) +# 9729 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'record_expr) in + Obj.repr( +# 1532 "parsing/parser.mly" + ( unclosed "{" 3 "}" 5 ) +# 9737 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'expr_semi_list) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in + Obj.repr( +# 1534 "parsing/parser.mly" + ( mkexp (Pexp_array(List.rev _2)) ) +# 9745 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'expr_semi_list) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in + Obj.repr( +# 1536 "parsing/parser.mly" + ( unclosed "[|" 1 "|]" 4 ) +# 9753 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + Obj.repr( +# 1538 "parsing/parser.mly" + ( mkexp (Pexp_array []) ) +# 9759 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 5 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 2 : 'expr_semi_list) in + let _5 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in + Obj.repr( +# 1540 "parsing/parser.mly" + ( mkexp(Pexp_open(Fresh, mkrhs _1 1, mkexp(Pexp_array(List.rev _4)))) ) +# 9768 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 3 : 'mod_longident) in + Obj.repr( +# 1542 "parsing/parser.mly" + ( mkexp(Pexp_open(Fresh, mkrhs _1 1, mkexp(Pexp_array []))) ) +# 9775 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 5 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 2 : 'expr_semi_list) in + let _5 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in + Obj.repr( +# 1544 "parsing/parser.mly" + ( unclosed "[|" 3 "|]" 6 ) +# 9784 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'expr_semi_list) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in + Obj.repr( +# 1546 "parsing/parser.mly" + ( reloc_exp (mktailexp (rhs_loc 4) (List.rev _2)) ) +# 9792 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'expr_semi_list) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in + Obj.repr( +# 1548 "parsing/parser.mly" + ( unclosed "[" 1 "]" 4 ) +# 9800 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 5 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 2 : 'expr_semi_list) in + let _5 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in + Obj.repr( +# 1550 "parsing/parser.mly" + ( let list_exp = reloc_exp (mktailexp (rhs_loc 6) (List.rev _4)) in + mkexp(Pexp_open(Fresh, mkrhs _1 1, list_exp)) ) +# 9810 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 3 : 'mod_longident) in + Obj.repr( +# 1553 "parsing/parser.mly" + ( mkexp(Pexp_open(Fresh, mkrhs _1 1, + mkexp(Pexp_construct(mkrhs (Lident "[]") 1, None)))) ) +# 9818 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 5 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 2 : 'expr_semi_list) in + let _5 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in + Obj.repr( +# 1556 "parsing/parser.mly" + ( unclosed "[" 3 "]" 6 ) +# 9827 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : string) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in + Obj.repr( +# 1558 "parsing/parser.mly" + ( mkexp(Pexp_apply(mkoperator _1 1, [Nolabel,_2])) ) +# 9835 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in + Obj.repr( +# 1560 "parsing/parser.mly" + ( mkexp(Pexp_apply(mkoperator "!" 1, [Nolabel,_2])) ) +# 9842 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'class_longident) in + Obj.repr( +# 1562 "parsing/parser.mly" + ( mkexp_attrs (Pexp_new(mkrhs _3 3)) _2 ) +# 9850 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'field_expr_list) in + Obj.repr( +# 1564 "parsing/parser.mly" + ( mkexp (Pexp_override _2) ) +# 9857 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'field_expr_list) in + Obj.repr( +# 1566 "parsing/parser.mly" + ( unclosed "{<" 1 ">}" 3 ) +# 9864 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + Obj.repr( +# 1568 "parsing/parser.mly" + ( mkexp (Pexp_override [])) +# 9870 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'field_expr_list) in + Obj.repr( +# 1570 "parsing/parser.mly" + ( mkexp(Pexp_open(Fresh, mkrhs _1 1, mkexp (Pexp_override _4)))) +# 9878 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 3 : 'mod_longident) in + Obj.repr( +# 1572 "parsing/parser.mly" + ( mkexp(Pexp_open(Fresh, mkrhs _1 1, mkexp (Pexp_override [])))) +# 9885 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'field_expr_list) in + Obj.repr( +# 1574 "parsing/parser.mly" + ( unclosed "{<" 3 ">}" 5 ) +# 9893 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'simple_expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'label) in + Obj.repr( +# 1576 "parsing/parser.mly" + ( mkexp(Pexp_send(_1, mkrhs _3 3)) ) +# 9901 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'simple_expr) in + let _2 = (Parsing.peek_val __caml_parser_env 1 : string) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in + Obj.repr( +# 1578 "parsing/parser.mly" + ( mkinfix _1 _2 _3 ) +# 9910 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'module_expr) in + Obj.repr( +# 1580 "parsing/parser.mly" + ( mkexp_attrs (Pexp_pack _4) _3 ) +# 9918 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : 'module_expr) in + let _6 = (Parsing.peek_val __caml_parser_env 1 : 'package_type) in + Obj.repr( +# 1582 "parsing/parser.mly" + ( mkexp_attrs (Pexp_constraint (ghexp (Pexp_pack _4), + ghtyp (Ptyp_package _6))) + _3 ) +# 9929 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 3 : 'ext_attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 2 : 'module_expr) in + Obj.repr( +# 1586 "parsing/parser.mly" + ( unclosed "(" 1 ")" 6 ) +# 9937 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 8 : 'mod_longident) in + let _5 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in + let _6 = (Parsing.peek_val __caml_parser_env 3 : 'module_expr) in + let _8 = (Parsing.peek_val __caml_parser_env 1 : 'package_type) in + Obj.repr( +# 1589 "parsing/parser.mly" + ( mkexp(Pexp_open(Fresh, mkrhs _1 1, + mkexp_attrs (Pexp_constraint (ghexp (Pexp_pack _6), + ghtyp (Ptyp_package _8))) + _5 )) ) +# 9950 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 7 : 'mod_longident) in + let _5 = (Parsing.peek_val __caml_parser_env 3 : 'ext_attributes) in + let _6 = (Parsing.peek_val __caml_parser_env 2 : 'module_expr) in + Obj.repr( +# 1594 "parsing/parser.mly" + ( unclosed "(" 3 ")" 8 ) +# 9959 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'extension) in + Obj.repr( +# 1596 "parsing/parser.mly" + ( mkexp (Pexp_extension _1) ) +# 9966 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'labeled_simple_expr) in + Obj.repr( +# 1600 "parsing/parser.mly" + ( [_1] ) +# 9973 "parsing/parser.ml" + : 'simple_labeled_expr_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'simple_labeled_expr_list) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'labeled_simple_expr) in + Obj.repr( +# 1602 "parsing/parser.mly" + ( _2 :: _1 ) +# 9981 "parsing/parser.ml" + : 'simple_labeled_expr_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in + Obj.repr( +# 1606 "parsing/parser.mly" + ( (Nolabel, _1) ) +# 9988 "parsing/parser.ml" + : 'labeled_simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'label_expr) in + Obj.repr( +# 1608 "parsing/parser.mly" + ( _1 ) +# 9995 "parsing/parser.ml" + : 'labeled_simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : string) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in + Obj.repr( +# 1612 "parsing/parser.mly" + ( (Labelled _1, _2) ) +# 10003 "parsing/parser.ml" + : 'label_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'label_ident) in + Obj.repr( +# 1614 "parsing/parser.mly" + ( (Labelled (fst _2), snd _2) ) +# 10010 "parsing/parser.ml" + : 'label_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'label_ident) in + Obj.repr( +# 1616 "parsing/parser.mly" + ( (Optional (fst _2), snd _2) ) +# 10017 "parsing/parser.ml" + : 'label_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : string) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in + Obj.repr( +# 1618 "parsing/parser.mly" + ( (Optional _1, _2) ) +# 10025 "parsing/parser.ml" + : 'label_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 1621 "parsing/parser.mly" + ( (_1, mkexp(Pexp_ident(mkrhs (Lident _1) 1))) ) +# 10032 "parsing/parser.ml" + : 'label_ident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 1624 "parsing/parser.mly" + ( [mkrhs _1 1] ) +# 10039 "parsing/parser.ml" + : 'lident_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : string) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'lident_list) in + Obj.repr( +# 1625 "parsing/parser.mly" + ( mkrhs _1 1 :: _2 ) +# 10047 "parsing/parser.ml" + : 'lident_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'val_ident) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'strict_binding) in + Obj.repr( +# 1629 "parsing/parser.mly" + ( (mkpatvar _1 1, _2) ) +# 10055 "parsing/parser.ml" + : 'let_binding_body)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 3 : 'val_ident) in + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'type_constraint) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1631 "parsing/parser.mly" + ( let v = mkpatvar _1 1 in (* PR#7344 *) + let t = + match _2 with + Some t, None -> t + | _, Some t -> t + | _ -> assert false + in + (ghpat(Ppat_constraint(v, ghtyp(Ptyp_poly([],t)))), + mkexp_constraint _4 _2) ) +# 10072 "parsing/parser.ml" + : 'let_binding_body)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 6 : 'val_ident) in + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'typevar_list) in + let _5 = (Parsing.peek_val __caml_parser_env 2 : 'core_type) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1641 "parsing/parser.mly" + ( (ghpat(Ppat_constraint(mkpatvar _1 1, + ghtyp(Ptyp_poly(List.rev _3,_5)))), + _7) ) +# 10084 "parsing/parser.ml" + : 'let_binding_body)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 7 : 'val_ident) in + let _4 = (Parsing.peek_val __caml_parser_env 4 : 'lident_list) in + let _6 = (Parsing.peek_val __caml_parser_env 2 : 'core_type) in + let _8 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1645 "parsing/parser.mly" + ( let exp, poly = wrap_type_annotation _4 _6 _8 in + (ghpat(Ppat_constraint(mkpatvar _1 1, poly)), exp) ) +# 10095 "parsing/parser.ml" + : 'let_binding_body)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_no_exn) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1648 "parsing/parser.mly" + ( (_1, _3) ) +# 10103 "parsing/parser.ml" + : 'let_binding_body)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_pattern_not_ident) in + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'core_type) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1650 "parsing/parser.mly" + ( (ghpat(Ppat_constraint(_1, _3)), _5) ) +# 10112 "parsing/parser.ml" + : 'let_binding_body)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'let_binding) in + Obj.repr( +# 1653 "parsing/parser.mly" + ( _1 ) +# 10119 "parsing/parser.ml" + : 'let_bindings)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'let_bindings) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'and_let_binding) in + Obj.repr( +# 1654 "parsing/parser.mly" + ( addlb _1 _2 ) +# 10127 "parsing/parser.ml" + : 'let_bindings)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'rec_flag) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'let_binding_body) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1658 "parsing/parser.mly" + ( let (ext, attr) = _2 in + mklbs ext _3 (mklb true _4 (attr@_5)) ) +# 10138 "parsing/parser.ml" + : 'let_binding)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'let_binding_body) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1663 "parsing/parser.mly" + ( mklb false _3 (_2@_4) ) +# 10147 "parsing/parser.ml" + : 'and_let_binding)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'strict_binding) in + Obj.repr( +# 1667 "parsing/parser.mly" + ( _1 ) +# 10154 "parsing/parser.ml" + : 'fun_binding)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'type_constraint) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1669 "parsing/parser.mly" + ( mkexp_constraint _3 _1 ) +# 10162 "parsing/parser.ml" + : 'fun_binding)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1673 "parsing/parser.mly" + ( _2 ) +# 10169 "parsing/parser.ml" + : 'strict_binding)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'labeled_simple_pattern) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'fun_binding) in + Obj.repr( +# 1675 "parsing/parser.mly" + ( let (l, o, p) = _1 in ghexp(Pexp_fun(l, o, p, _2)) ) +# 10177 "parsing/parser.ml" + : 'strict_binding)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'lident_list) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'fun_binding) in + Obj.repr( +# 1677 "parsing/parser.mly" + ( mk_newtypes _3 _5 ) +# 10185 "parsing/parser.ml" + : 'strict_binding)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'match_case) in + Obj.repr( +# 1680 "parsing/parser.mly" + ( [_1] ) +# 10192 "parsing/parser.ml" + : 'match_cases)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'match_cases) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'match_case) in + Obj.repr( +# 1681 "parsing/parser.mly" + ( _3 :: _1 ) +# 10200 "parsing/parser.ml" + : 'match_cases)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1685 "parsing/parser.mly" + ( Exp.case _1 _3 ) +# 10208 "parsing/parser.ml" + : 'match_case)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'pattern) in + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'seq_expr) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1687 "parsing/parser.mly" + ( Exp.case _1 ~guard:_3 _5 ) +# 10217 "parsing/parser.ml" + : 'match_case)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in + Obj.repr( +# 1689 "parsing/parser.mly" + ( Exp.case _1 (Exp.unreachable ~loc:(rhs_loc 3) ())) +# 10224 "parsing/parser.ml" + : 'match_case)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1693 "parsing/parser.mly" + ( _2 ) +# 10231 "parsing/parser.ml" + : 'fun_def)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'simple_core_type) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1695 "parsing/parser.mly" + ( mkexp (Pexp_constraint (_4, _2)) ) +# 10239 "parsing/parser.ml" + : 'fun_def)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'labeled_simple_pattern) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'fun_def) in + Obj.repr( +# 1698 "parsing/parser.mly" + ( + let (l,o,p) = _1 in + ghexp(Pexp_fun(l, o, p, _2)) + ) +# 10250 "parsing/parser.ml" + : 'fun_def)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'lident_list) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'fun_def) in + Obj.repr( +# 1703 "parsing/parser.mly" + ( mk_newtypes _3 _5 ) +# 10258 "parsing/parser.ml" + : 'fun_def)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr_comma_list) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1706 "parsing/parser.mly" + ( _3 :: _1 ) +# 10266 "parsing/parser.ml" + : 'expr_comma_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1707 "parsing/parser.mly" + ( [_3; _1] ) +# 10274 "parsing/parser.ml" + : 'expr_comma_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'simple_expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'lbl_expr_list) in + Obj.repr( +# 1710 "parsing/parser.mly" + ( (Some _1, _3) ) +# 10282 "parsing/parser.ml" + : 'record_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'lbl_expr_list) in + Obj.repr( +# 1711 "parsing/parser.mly" + ( (None, _1) ) +# 10289 "parsing/parser.ml" + : 'record_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'lbl_expr) in + Obj.repr( +# 1714 "parsing/parser.mly" + ( [_1] ) +# 10296 "parsing/parser.ml" + : 'lbl_expr_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'lbl_expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'lbl_expr_list) in + Obj.repr( +# 1715 "parsing/parser.mly" + ( _1 :: _3 ) +# 10304 "parsing/parser.ml" + : 'lbl_expr_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'lbl_expr) in + Obj.repr( +# 1716 "parsing/parser.mly" + ( [_1] ) +# 10311 "parsing/parser.ml" + : 'lbl_expr_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 3 : 'label_longident) in + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'opt_type_constraint) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1720 "parsing/parser.mly" + ( (mkrhs _1 1, mkexp_opt_constraint _4 _2) ) +# 10320 "parsing/parser.ml" + : 'lbl_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'label_longident) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'opt_type_constraint) in + Obj.repr( +# 1722 "parsing/parser.mly" + ( (mkrhs _1 1, mkexp_opt_constraint (exp_of_label _1 1) _2) ) +# 10328 "parsing/parser.ml" + : 'lbl_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'field_expr) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'opt_semi) in + Obj.repr( +# 1725 "parsing/parser.mly" + ( [_1] ) +# 10336 "parsing/parser.ml" + : 'field_expr_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'field_expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'field_expr_list) in + Obj.repr( +# 1726 "parsing/parser.mly" + ( _1 :: _3 ) +# 10344 "parsing/parser.ml" + : 'field_expr_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'label) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1730 "parsing/parser.mly" + ( (mkrhs _1 1, _3) ) +# 10352 "parsing/parser.ml" + : 'field_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'label) in + Obj.repr( +# 1732 "parsing/parser.mly" + ( (mkrhs _1 1, exp_of_label (Lident _1) 1) ) +# 10359 "parsing/parser.ml" + : 'field_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1735 "parsing/parser.mly" + ( [_1] ) +# 10366 "parsing/parser.ml" + : 'expr_semi_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr_semi_list) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1736 "parsing/parser.mly" + ( _3 :: _1 ) +# 10374 "parsing/parser.ml" + : 'expr_semi_list)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in + Obj.repr( +# 1739 "parsing/parser.mly" + ( (Some _2, None) ) +# 10381 "parsing/parser.ml" + : 'type_constraint)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'core_type) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in + Obj.repr( +# 1740 "parsing/parser.mly" + ( (Some _2, Some _4) ) +# 10389 "parsing/parser.ml" + : 'type_constraint)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in + Obj.repr( +# 1741 "parsing/parser.mly" + ( (None, Some _2) ) +# 10396 "parsing/parser.ml" + : 'type_constraint)) +; (fun __caml_parser_env -> + Obj.repr( +# 1742 "parsing/parser.mly" + ( syntax_error() ) +# 10402 "parsing/parser.ml" + : 'type_constraint)) +; (fun __caml_parser_env -> + Obj.repr( +# 1743 "parsing/parser.mly" + ( syntax_error() ) +# 10408 "parsing/parser.ml" + : 'type_constraint)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'type_constraint) in + Obj.repr( +# 1746 "parsing/parser.mly" + ( Some _1 ) +# 10415 "parsing/parser.ml" + : 'opt_type_constraint)) +; (fun __caml_parser_env -> + Obj.repr( +# 1747 "parsing/parser.mly" + ( None ) +# 10421 "parsing/parser.ml" + : 'opt_type_constraint)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'val_ident) in + Obj.repr( +# 1754 "parsing/parser.mly" + ( mkpat(Ppat_alias(_1, mkrhs _3 3)) ) +# 10429 "parsing/parser.ml" + : 'pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in + Obj.repr( +# 1756 "parsing/parser.mly" + ( expecting 3 "identifier" ) +# 10436 "parsing/parser.ml" + : 'pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'pattern_comma_list) in + Obj.repr( +# 1758 "parsing/parser.mly" + ( mkpat(Ppat_tuple(List.rev _1)) ) +# 10443 "parsing/parser.ml" + : 'pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in + Obj.repr( +# 1760 "parsing/parser.mly" + ( mkpat_cons (rhs_loc 2) (ghpat(Ppat_tuple[_1;_3])) (symbol_rloc()) ) +# 10451 "parsing/parser.ml" + : 'pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in + Obj.repr( +# 1762 "parsing/parser.mly" + ( expecting 3 "pattern" ) +# 10458 "parsing/parser.ml" + : 'pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in + Obj.repr( +# 1764 "parsing/parser.mly" + ( mkpat(Ppat_or(_1, _3)) ) +# 10466 "parsing/parser.ml" + : 'pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in + Obj.repr( +# 1766 "parsing/parser.mly" + ( expecting 3 "pattern" ) +# 10473 "parsing/parser.ml" + : 'pattern)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in + Obj.repr( +# 1768 "parsing/parser.mly" + ( mkpat_attrs (Ppat_exception _3) _2) +# 10481 "parsing/parser.ml" + : 'pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'pattern) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attribute) in + Obj.repr( +# 1770 "parsing/parser.mly" + ( Pat.attr _1 _2 ) +# 10489 "parsing/parser.ml" + : 'pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'pattern_gen) in + Obj.repr( +# 1771 "parsing/parser.mly" + ( _1 ) +# 10496 "parsing/parser.ml" + : 'pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_no_exn) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'val_ident) in + Obj.repr( +# 1775 "parsing/parser.mly" + ( mkpat(Ppat_alias(_1, mkrhs _3 3)) ) +# 10504 "parsing/parser.ml" + : 'pattern_no_exn)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_no_exn) in + Obj.repr( +# 1777 "parsing/parser.mly" + ( expecting 3 "identifier" ) +# 10511 "parsing/parser.ml" + : 'pattern_no_exn)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'pattern_no_exn_comma_list) in + Obj.repr( +# 1779 "parsing/parser.mly" + ( mkpat(Ppat_tuple(List.rev _1)) ) +# 10518 "parsing/parser.ml" + : 'pattern_no_exn)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_no_exn) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in + Obj.repr( +# 1781 "parsing/parser.mly" + ( mkpat_cons (rhs_loc 2) (ghpat(Ppat_tuple[_1;_3])) (symbol_rloc()) ) +# 10526 "parsing/parser.ml" + : 'pattern_no_exn)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_no_exn) in + Obj.repr( +# 1783 "parsing/parser.mly" + ( expecting 3 "pattern" ) +# 10533 "parsing/parser.ml" + : 'pattern_no_exn)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_no_exn) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in + Obj.repr( +# 1785 "parsing/parser.mly" + ( mkpat(Ppat_or(_1, _3)) ) +# 10541 "parsing/parser.ml" + : 'pattern_no_exn)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_no_exn) in + Obj.repr( +# 1787 "parsing/parser.mly" + ( expecting 3 "pattern" ) +# 10548 "parsing/parser.ml" + : 'pattern_no_exn)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'pattern_no_exn) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attribute) in + Obj.repr( +# 1789 "parsing/parser.mly" + ( Pat.attr _1 _2 ) +# 10556 "parsing/parser.ml" + : 'pattern_no_exn)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'pattern_gen) in + Obj.repr( +# 1790 "parsing/parser.mly" + ( _1 ) +# 10563 "parsing/parser.ml" + : 'pattern_no_exn)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_pattern) in + Obj.repr( +# 1794 "parsing/parser.mly" + ( _1 ) +# 10570 "parsing/parser.ml" + : 'pattern_gen)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'constr_longident) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in + Obj.repr( +# 1796 "parsing/parser.mly" + ( mkpat(Ppat_construct(mkrhs _1 1, Some _2)) ) +# 10578 "parsing/parser.ml" + : 'pattern_gen)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'name_tag) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in + Obj.repr( +# 1798 "parsing/parser.mly" + ( mkpat(Ppat_variant(_1, Some _2)) ) +# 10586 "parsing/parser.ml" + : 'pattern_gen)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'simple_pattern) in + Obj.repr( +# 1800 "parsing/parser.mly" + ( mkpat_attrs (Ppat_lazy _3) _2) +# 10594 "parsing/parser.ml" + : 'pattern_gen)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'val_ident) in + Obj.repr( +# 1804 "parsing/parser.mly" + ( mkpat(Ppat_var (mkrhs _1 1)) ) +# 10601 "parsing/parser.ml" + : 'simple_pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_pattern_not_ident) in + Obj.repr( +# 1805 "parsing/parser.mly" + ( _1 ) +# 10608 "parsing/parser.ml" + : 'simple_pattern)) +; (fun __caml_parser_env -> + Obj.repr( +# 1809 "parsing/parser.mly" + ( mkpat(Ppat_any) ) +# 10614 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'signed_constant) in + Obj.repr( +# 1811 "parsing/parser.mly" + ( mkpat(Ppat_constant _1) ) +# 10621 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'signed_constant) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'signed_constant) in + Obj.repr( +# 1813 "parsing/parser.mly" + ( mkpat(Ppat_interval (_1, _3)) ) +# 10629 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'constr_longident) in + Obj.repr( +# 1815 "parsing/parser.mly" + ( mkpat(Ppat_construct(mkrhs _1 1, None)) ) +# 10636 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'name_tag) in + Obj.repr( +# 1817 "parsing/parser.mly" + ( mkpat(Ppat_variant(_1, None)) ) +# 10643 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'type_longident) in + Obj.repr( +# 1819 "parsing/parser.mly" + ( mkpat(Ppat_type (mkrhs _2 2)) ) +# 10650 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_delimited_pattern) in + Obj.repr( +# 1821 "parsing/parser.mly" + ( _1 ) +# 10657 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'mod_longident) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'simple_delimited_pattern) in + Obj.repr( +# 1823 "parsing/parser.mly" + ( mkpat @@ Ppat_open(mkrhs _1 1, _3) ) +# 10665 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 3 : 'mod_longident) in + Obj.repr( +# 1825 "parsing/parser.mly" + ( mkpat @@ Ppat_open(mkrhs _1 1, mkpat @@ + Ppat_construct ( mkrhs (Lident "[]") 4, None)) ) +# 10673 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 3 : 'mod_longident) in + Obj.repr( +# 1828 "parsing/parser.mly" + ( mkpat @@ Ppat_open( mkrhs _1 1, mkpat @@ + Ppat_construct ( mkrhs (Lident "()") 4, None) ) ) +# 10681 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'pattern) in + Obj.repr( +# 1831 "parsing/parser.mly" + ( mkpat @@ Ppat_open (mkrhs _1 1, _4)) +# 10689 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'pattern) in + Obj.repr( +# 1833 "parsing/parser.mly" + (unclosed "(" 3 ")" 5 ) +# 10697 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 3 : 'mod_longident) in + Obj.repr( +# 1835 "parsing/parser.mly" + ( expecting 4 "pattern" ) +# 10704 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'pattern) in + Obj.repr( +# 1837 "parsing/parser.mly" + ( reloc_pat _2 ) +# 10711 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'pattern) in + Obj.repr( +# 1839 "parsing/parser.mly" + ( unclosed "(" 1 ")" 3 ) +# 10718 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'pattern) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'core_type) in + Obj.repr( +# 1841 "parsing/parser.mly" + ( mkpat(Ppat_constraint(_2, _4)) ) +# 10726 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'pattern) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'core_type) in + Obj.repr( +# 1843 "parsing/parser.mly" + ( unclosed "(" 1 ")" 5 ) +# 10734 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in + Obj.repr( +# 1845 "parsing/parser.mly" + ( expecting 4 "type" ) +# 10741 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : string) in + Obj.repr( +# 1847 "parsing/parser.mly" + ( mkpat_attrs (Ppat_unpack (mkrhs _4 4)) _3 ) +# 10749 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _6 = (Parsing.peek_val __caml_parser_env 1 : 'package_type) in + Obj.repr( +# 1849 "parsing/parser.mly" + ( mkpat_attrs + (Ppat_constraint(mkpat(Ppat_unpack (mkrhs _4 4)), + ghtyp(Ptyp_package _6))) + _3 ) +# 10761 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _6 = (Parsing.peek_val __caml_parser_env 1 : 'package_type) in + Obj.repr( +# 1854 "parsing/parser.mly" + ( unclosed "(" 1 ")" 7 ) +# 10770 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'extension) in + Obj.repr( +# 1856 "parsing/parser.mly" + ( mkpat(Ppat_extension _1) ) +# 10777 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'lbl_pattern_list) in + Obj.repr( +# 1861 "parsing/parser.mly" + ( let (fields, closed) = _2 in mkpat(Ppat_record(fields, closed)) ) +# 10784 "parsing/parser.ml" + : 'simple_delimited_pattern)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'lbl_pattern_list) in + Obj.repr( +# 1863 "parsing/parser.mly" + ( unclosed "{" 1 "}" 3 ) +# 10791 "parsing/parser.ml" + : 'simple_delimited_pattern)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_semi_list) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in + Obj.repr( +# 1865 "parsing/parser.mly" + ( reloc_pat (mktailpat (rhs_loc 4) (List.rev _2)) ) +# 10799 "parsing/parser.ml" + : 'simple_delimited_pattern)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_semi_list) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in + Obj.repr( +# 1867 "parsing/parser.mly" + ( unclosed "[" 1 "]" 4 ) +# 10807 "parsing/parser.ml" + : 'simple_delimited_pattern)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_semi_list) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in + Obj.repr( +# 1869 "parsing/parser.mly" + ( mkpat(Ppat_array(List.rev _2)) ) +# 10815 "parsing/parser.ml" + : 'simple_delimited_pattern)) +; (fun __caml_parser_env -> + Obj.repr( +# 1871 "parsing/parser.mly" + ( mkpat(Ppat_array []) ) +# 10821 "parsing/parser.ml" + : 'simple_delimited_pattern)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_semi_list) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in + Obj.repr( +# 1873 "parsing/parser.mly" + ( unclosed "[|" 1 "|]" 4 ) +# 10829 "parsing/parser.ml" + : 'simple_delimited_pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_comma_list) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in + Obj.repr( +# 1876 "parsing/parser.mly" + ( _3 :: _1 ) +# 10837 "parsing/parser.ml" + : 'pattern_comma_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in + Obj.repr( +# 1877 "parsing/parser.mly" + ( [_3; _1] ) +# 10845 "parsing/parser.ml" + : 'pattern_comma_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in + Obj.repr( +# 1878 "parsing/parser.mly" + ( expecting 3 "pattern" ) +# 10852 "parsing/parser.ml" + : 'pattern_comma_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_no_exn_comma_list) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in + Obj.repr( +# 1881 "parsing/parser.mly" + ( _3 :: _1 ) +# 10860 "parsing/parser.ml" + : 'pattern_no_exn_comma_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_no_exn) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in + Obj.repr( +# 1882 "parsing/parser.mly" + ( [_3; _1] ) +# 10868 "parsing/parser.ml" + : 'pattern_no_exn_comma_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_no_exn) in + Obj.repr( +# 1883 "parsing/parser.mly" + ( expecting 3 "pattern" ) +# 10875 "parsing/parser.ml" + : 'pattern_no_exn_comma_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in + Obj.repr( +# 1886 "parsing/parser.mly" + ( [_1] ) +# 10882 "parsing/parser.ml" + : 'pattern_semi_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_semi_list) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in + Obj.repr( +# 1887 "parsing/parser.mly" + ( _3 :: _1 ) +# 10890 "parsing/parser.ml" + : 'pattern_semi_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'lbl_pattern) in + Obj.repr( +# 1890 "parsing/parser.mly" + ( [_1], Closed ) +# 10897 "parsing/parser.ml" + : 'lbl_pattern_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'lbl_pattern) in + Obj.repr( +# 1891 "parsing/parser.mly" + ( [_1], Closed ) +# 10904 "parsing/parser.ml" + : 'lbl_pattern_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 3 : 'lbl_pattern) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'opt_semi) in + Obj.repr( +# 1892 "parsing/parser.mly" + ( [_1], Open ) +# 10912 "parsing/parser.ml" + : 'lbl_pattern_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'lbl_pattern) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'lbl_pattern_list) in + Obj.repr( +# 1894 "parsing/parser.mly" + ( let (fields, closed) = _3 in _1 :: fields, closed ) +# 10920 "parsing/parser.ml" + : 'lbl_pattern_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 3 : 'label_longident) in + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'opt_pattern_type_constraint) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in + Obj.repr( +# 1898 "parsing/parser.mly" + ( (mkrhs _1 1, mkpat_opt_constraint _4 _2) ) +# 10929 "parsing/parser.ml" + : 'lbl_pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'label_longident) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'opt_pattern_type_constraint) in + Obj.repr( +# 1900 "parsing/parser.mly" + ( (mkrhs _1 1, mkpat_opt_constraint (pat_of_label _1 1) _2) ) +# 10937 "parsing/parser.ml" + : 'lbl_pattern)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in + Obj.repr( +# 1903 "parsing/parser.mly" + ( Some _2 ) +# 10944 "parsing/parser.ml" + : 'opt_pattern_type_constraint)) +; (fun __caml_parser_env -> + Obj.repr( +# 1904 "parsing/parser.mly" + ( None ) +# 10950 "parsing/parser.ml" + : 'opt_pattern_type_constraint)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 3 : 'val_ident) in + let _5 = (Parsing.peek_val __caml_parser_env 1 : 'core_type) in + let _6 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1911 "parsing/parser.mly" + ( let (ext, attrs) = _2 in + Val.mk (mkrhs _3 3) _5 ~attrs:(attrs@_6) + ~loc:(symbol_rloc()) ~docs:(symbol_docs ()) + , ext ) +# 10963 "parsing/parser.ml" + : 'value_description)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string * string option) in + Obj.repr( +# 1920 "parsing/parser.mly" + ( [fst _1] ) +# 10970 "parsing/parser.ml" + : 'primitive_declaration_body)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : string * string option) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'primitive_declaration_body) in + Obj.repr( +# 1921 "parsing/parser.mly" + ( fst _1 :: _2 ) +# 10978 "parsing/parser.ml" + : 'primitive_declaration_body)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 6 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 5 : 'val_ident) in + let _5 = (Parsing.peek_val __caml_parser_env 3 : 'core_type) in + let _7 = (Parsing.peek_val __caml_parser_env 1 : 'primitive_declaration_body) in + let _8 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1926 "parsing/parser.mly" + ( let (ext, attrs) = _2 in + Val.mk (mkrhs _3 3) _5 ~prim:_7 ~attrs:(attrs@_8) + ~loc:(symbol_rloc ()) ~docs:(symbol_docs ()) + , ext ) +# 10992 "parsing/parser.ml" + : 'primitive_declaration)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'type_declaration) in + Obj.repr( +# 1936 "parsing/parser.mly" + ( let (nonrec_flag, ty, ext) = _1 in (nonrec_flag, [ty], ext) ) +# 10999 "parsing/parser.ml" + : 'type_declarations)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'type_declarations) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'and_type_declaration) in + Obj.repr( +# 1938 "parsing/parser.mly" + ( let (nonrec_flag, tys, ext) = _1 in (nonrec_flag, _2 :: tys, ext) ) +# 11007 "parsing/parser.ml" + : 'type_declarations)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 6 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 5 : 'nonrec_flag) in + let _4 = (Parsing.peek_val __caml_parser_env 4 : 'optional_type_parameters) in + let _5 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _6 = (Parsing.peek_val __caml_parser_env 2 : 'type_kind) in + let _7 = (Parsing.peek_val __caml_parser_env 1 : 'constraints) in + let _8 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1944 "parsing/parser.mly" + ( let (kind, priv, manifest) = _6 in + let (ext, attrs) = _2 in + let ty = + Type.mk (mkrhs _5 5) ~params:_4 ~cstrs:(List.rev _7) ~kind + ~priv ?manifest ~attrs:(attrs@_8) + ~loc:(symbol_rloc ()) ~docs:(symbol_docs ()) + in + (_3, ty, ext) ) +# 11027 "parsing/parser.ml" + : 'type_declaration)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 5 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'optional_type_parameters) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _5 = (Parsing.peek_val __caml_parser_env 2 : 'type_kind) in + let _6 = (Parsing.peek_val __caml_parser_env 1 : 'constraints) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1956 "parsing/parser.mly" + ( let (kind, priv, manifest) = _5 in + Type.mk (mkrhs _4 4) ~params:_3 ~cstrs:(List.rev _6) + ~kind ~priv ?manifest ~attrs:(_2@_7) ~loc:(symbol_rloc ()) + ~text:(symbol_text ()) ~docs:(symbol_docs ()) ) +# 11042 "parsing/parser.ml" + : 'and_type_declaration)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'constraints) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'constrain) in + Obj.repr( +# 1962 "parsing/parser.mly" + ( _3 :: _1 ) +# 11050 "parsing/parser.ml" + : 'constraints)) +; (fun __caml_parser_env -> + Obj.repr( +# 1963 "parsing/parser.mly" + ( [] ) +# 11056 "parsing/parser.ml" + : 'constraints)) +; (fun __caml_parser_env -> + Obj.repr( +# 1967 "parsing/parser.mly" + ( (Ptype_abstract, Public, None) ) +# 11062 "parsing/parser.ml" + : 'type_kind)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in + Obj.repr( +# 1969 "parsing/parser.mly" + ( (Ptype_abstract, Public, Some _2) ) +# 11069 "parsing/parser.ml" + : 'type_kind)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in + Obj.repr( +# 1971 "parsing/parser.mly" + ( (Ptype_abstract, Private, Some _3) ) +# 11076 "parsing/parser.ml" + : 'type_kind)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'constructor_declarations) in + Obj.repr( +# 1973 "parsing/parser.mly" + ( (Ptype_variant(List.rev _2), Public, None) ) +# 11083 "parsing/parser.ml" + : 'type_kind)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'constructor_declarations) in + Obj.repr( +# 1975 "parsing/parser.mly" + ( (Ptype_variant(List.rev _3), Private, None) ) +# 11090 "parsing/parser.ml" + : 'type_kind)) +; (fun __caml_parser_env -> + Obj.repr( +# 1977 "parsing/parser.mly" + ( (Ptype_open, Public, None) ) +# 11096 "parsing/parser.ml" + : 'type_kind)) +; (fun __caml_parser_env -> + Obj.repr( +# 1979 "parsing/parser.mly" + ( (Ptype_open, Private, None) ) +# 11102 "parsing/parser.ml" + : 'type_kind)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'private_flag) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'label_declarations) in + Obj.repr( +# 1981 "parsing/parser.mly" + ( (Ptype_record _4, _2, None) ) +# 11110 "parsing/parser.ml" + : 'type_kind)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'core_type) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'private_flag) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'constructor_declarations) in + Obj.repr( +# 1983 "parsing/parser.mly" + ( (Ptype_variant(List.rev _5), _4, Some _2) ) +# 11119 "parsing/parser.ml" + : 'type_kind)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'core_type) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'private_flag) in + Obj.repr( +# 1985 "parsing/parser.mly" + ( (Ptype_open, _4, Some _2) ) +# 11127 "parsing/parser.ml" + : 'type_kind)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 5 : 'core_type) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : 'private_flag) in + let _6 = (Parsing.peek_val __caml_parser_env 1 : 'label_declarations) in + Obj.repr( +# 1987 "parsing/parser.mly" + ( (Ptype_record _6, _4, Some _2) ) +# 11136 "parsing/parser.ml" + : 'type_kind)) +; (fun __caml_parser_env -> + Obj.repr( +# 1990 "parsing/parser.mly" + ( [] ) +# 11142 "parsing/parser.ml" + : 'optional_type_parameters)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'optional_type_parameter) in + Obj.repr( +# 1991 "parsing/parser.mly" + ( [_1] ) +# 11149 "parsing/parser.ml" + : 'optional_type_parameters)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'optional_type_parameter_list) in + Obj.repr( +# 1992 "parsing/parser.mly" + ( List.rev _2 ) +# 11156 "parsing/parser.ml" + : 'optional_type_parameters)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'type_variance) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'optional_type_variable) in + Obj.repr( +# 1995 "parsing/parser.mly" + ( _2, _1 ) +# 11164 "parsing/parser.ml" + : 'optional_type_parameter)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'optional_type_parameter) in + Obj.repr( +# 1998 "parsing/parser.mly" + ( [_1] ) +# 11171 "parsing/parser.ml" + : 'optional_type_parameter_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'optional_type_parameter_list) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'optional_type_parameter) in + Obj.repr( +# 1999 "parsing/parser.mly" + ( _3 :: _1 ) +# 11179 "parsing/parser.ml" + : 'optional_type_parameter_list)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'ident) in + Obj.repr( +# 2002 "parsing/parser.mly" + ( mktyp(Ptyp_var _2) ) +# 11186 "parsing/parser.ml" + : 'optional_type_variable)) +; (fun __caml_parser_env -> + Obj.repr( +# 2003 "parsing/parser.mly" + ( mktyp(Ptyp_any) ) +# 11192 "parsing/parser.ml" + : 'optional_type_variable)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'type_variance) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'type_variable) in + Obj.repr( +# 2008 "parsing/parser.mly" + ( _2, _1 ) +# 11200 "parsing/parser.ml" + : 'type_parameter)) +; (fun __caml_parser_env -> + Obj.repr( +# 2011 "parsing/parser.mly" + ( Invariant ) +# 11206 "parsing/parser.ml" + : 'type_variance)) +; (fun __caml_parser_env -> + Obj.repr( +# 2012 "parsing/parser.mly" + ( Covariant ) +# 11212 "parsing/parser.ml" + : 'type_variance)) +; (fun __caml_parser_env -> + Obj.repr( +# 2013 "parsing/parser.mly" + ( Contravariant ) +# 11218 "parsing/parser.ml" + : 'type_variance)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'ident) in + Obj.repr( +# 2016 "parsing/parser.mly" + ( mktyp(Ptyp_var _2) ) +# 11225 "parsing/parser.ml" + : 'type_variable)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'type_parameter) in + Obj.repr( +# 2019 "parsing/parser.mly" + ( [_1] ) +# 11232 "parsing/parser.ml" + : 'type_parameter_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'type_parameter_list) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'type_parameter) in + Obj.repr( +# 2020 "parsing/parser.mly" + ( _3 :: _1 ) +# 11240 "parsing/parser.ml" + : 'type_parameter_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'constructor_declaration) in + Obj.repr( +# 2023 "parsing/parser.mly" + ( [_1] ) +# 11247 "parsing/parser.ml" + : 'constructor_declarations)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'bar_constructor_declaration) in + Obj.repr( +# 2024 "parsing/parser.mly" + ( [_1] ) +# 11254 "parsing/parser.ml" + : 'constructor_declarations)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'constructor_declarations) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'bar_constructor_declaration) in + Obj.repr( +# 2025 "parsing/parser.mly" + ( _2 :: _1 ) +# 11262 "parsing/parser.ml" + : 'constructor_declarations)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'constr_ident) in + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'generalized_constructor_arguments) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in + Obj.repr( +# 2029 "parsing/parser.mly" + ( + let args,res = _2 in + Type.constructor (mkrhs _1 1) ~args ?res ~attrs:_3 + ~loc:(symbol_rloc()) ~info:(symbol_info ()) + ) +# 11275 "parsing/parser.ml" + : 'constructor_declaration)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'constr_ident) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'generalized_constructor_arguments) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in + Obj.repr( +# 2037 "parsing/parser.mly" + ( + let args,res = _3 in + Type.constructor (mkrhs _2 2) ~args ?res ~attrs:_4 + ~loc:(symbol_rloc()) ~info:(symbol_info ()) + ) +# 11288 "parsing/parser.ml" + : 'bar_constructor_declaration)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'sig_exception_declaration) in + Obj.repr( +# 2044 "parsing/parser.mly" + ( _1 ) +# 11295 "parsing/parser.ml" + : 'str_exception_declaration)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 5 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'constr_ident) in + let _5 = (Parsing.peek_val __caml_parser_env 2 : 'constr_longident) in + let _6 = (Parsing.peek_val __caml_parser_env 1 : 'attributes) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 2047 "parsing/parser.mly" + ( let (ext,attrs) = _2 in + Te.rebind (mkrhs _3 3) (mkrhs _5 5) ~attrs:(attrs @ _6 @ _7) + ~loc:(symbol_rloc()) ~docs:(symbol_docs ()) + , ext ) +# 11309 "parsing/parser.ml" + : 'str_exception_declaration)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 3 : 'constr_ident) in + let _4 = (Parsing.peek_val __caml_parser_env 2 : 'generalized_constructor_arguments) in + let _5 = (Parsing.peek_val __caml_parser_env 1 : 'attributes) in + let _6 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 2055 "parsing/parser.mly" + ( let args, res = _4 in + let (ext,attrs) = _2 in + Te.decl (mkrhs _3 3) ~args ?res ~attrs:(attrs @ _5 @ _6) + ~loc:(symbol_rloc()) ~docs:(symbol_docs ()) + , ext ) +# 11324 "parsing/parser.ml" + : 'sig_exception_declaration)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'constr_ident) in + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'generalized_constructor_arguments) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in + Obj.repr( +# 2063 "parsing/parser.mly" + ( let args, res = _2 in + Te.decl (mkrhs _1 1) ~args ?res ~attrs:_3 ~loc:(symbol_rloc()) ) +# 11334 "parsing/parser.ml" + : 'let_exception_declaration)) +; (fun __caml_parser_env -> + Obj.repr( +# 2067 "parsing/parser.mly" + ( (Pcstr_tuple [],None) ) +# 11340 "parsing/parser.ml" + : 'generalized_constructor_arguments)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'constructor_arguments) in + Obj.repr( +# 2068 "parsing/parser.mly" + ( (_2,None) ) +# 11347 "parsing/parser.ml" + : 'generalized_constructor_arguments)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'constructor_arguments) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'simple_core_type) in + Obj.repr( +# 2070 "parsing/parser.mly" + ( (_2,Some _4) ) +# 11355 "parsing/parser.ml" + : 'generalized_constructor_arguments)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'simple_core_type) in + Obj.repr( +# 2072 "parsing/parser.mly" + ( (Pcstr_tuple [],Some _2) ) +# 11362 "parsing/parser.ml" + : 'generalized_constructor_arguments)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'core_type_list) in + Obj.repr( +# 2076 "parsing/parser.mly" + ( Pcstr_tuple (List.rev _1) ) +# 11369 "parsing/parser.ml" + : 'constructor_arguments)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'label_declarations) in + Obj.repr( +# 2077 "parsing/parser.mly" + ( Pcstr_record _2 ) +# 11376 "parsing/parser.ml" + : 'constructor_arguments)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'label_declaration) in + Obj.repr( +# 2080 "parsing/parser.mly" + ( [_1] ) +# 11383 "parsing/parser.ml" + : 'label_declarations)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'label_declaration_semi) in + Obj.repr( +# 2081 "parsing/parser.mly" + ( [_1] ) +# 11390 "parsing/parser.ml" + : 'label_declarations)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'label_declaration_semi) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'label_declarations) in + Obj.repr( +# 2082 "parsing/parser.mly" + ( _1 :: _2 ) +# 11398 "parsing/parser.ml" + : 'label_declarations)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'mutable_flag) in + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'label) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'poly_type_no_attr) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in + Obj.repr( +# 2086 "parsing/parser.mly" + ( + Type.field (mkrhs _2 2) _4 ~mut:_1 ~attrs:_5 + ~loc:(symbol_rloc()) ~info:(symbol_info ()) + ) +# 11411 "parsing/parser.ml" + : 'label_declaration)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 6 : 'mutable_flag) in + let _2 = (Parsing.peek_val __caml_parser_env 5 : 'label) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : 'poly_type_no_attr) in + let _5 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in + Obj.repr( +# 2093 "parsing/parser.mly" + ( + let info = + match rhs_info 5 with + | Some _ as info_before_semi -> info_before_semi + | None -> symbol_info () + in + Type.field (mkrhs _2 2) _4 ~mut:_1 ~attrs:(_5 @ _7) + ~loc:(symbol_rloc()) ~info + ) +# 11430 "parsing/parser.ml" + : 'label_declaration_semi)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 7 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 6 : 'nonrec_flag) in + let _4 = (Parsing.peek_val __caml_parser_env 5 : 'optional_type_parameters) in + let _5 = (Parsing.peek_val __caml_parser_env 4 : 'type_longident) in + let _7 = (Parsing.peek_val __caml_parser_env 2 : 'private_flag) in + let _8 = (Parsing.peek_val __caml_parser_env 1 : 'str_extension_constructors) in + let _9 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 2109 "parsing/parser.mly" + ( let (ext, attrs) = _2 in + if _3 <> Recursive then not_expecting 3 "nonrec flag"; + Te.mk (mkrhs _5 5) (List.rev _8) ~params:_4 ~priv:_7 + ~attrs:(attrs@_9) ~docs:(symbol_docs ()) + , ext ) +# 11447 "parsing/parser.ml" + : 'str_type_extension)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 7 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 6 : 'nonrec_flag) in + let _4 = (Parsing.peek_val __caml_parser_env 5 : 'optional_type_parameters) in + let _5 = (Parsing.peek_val __caml_parser_env 4 : 'type_longident) in + let _7 = (Parsing.peek_val __caml_parser_env 2 : 'private_flag) in + let _8 = (Parsing.peek_val __caml_parser_env 1 : 'sig_extension_constructors) in + let _9 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 2118 "parsing/parser.mly" + ( let (ext, attrs) = _2 in + if _3 <> Recursive then not_expecting 3 "nonrec flag"; + Te.mk (mkrhs _5 5) (List.rev _8) ~params:_4 ~priv:_7 + ~attrs:(attrs @ _9) ~docs:(symbol_docs ()) + , ext ) +# 11464 "parsing/parser.ml" + : 'sig_type_extension)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'extension_constructor_declaration) in + Obj.repr( +# 2125 "parsing/parser.mly" + ( [_1] ) +# 11471 "parsing/parser.ml" + : 'str_extension_constructors)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'bar_extension_constructor_declaration) in + Obj.repr( +# 2126 "parsing/parser.mly" + ( [_1] ) +# 11478 "parsing/parser.ml" + : 'str_extension_constructors)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'extension_constructor_rebind) in + Obj.repr( +# 2127 "parsing/parser.mly" + ( [_1] ) +# 11485 "parsing/parser.ml" + : 'str_extension_constructors)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'bar_extension_constructor_rebind) in + Obj.repr( +# 2128 "parsing/parser.mly" + ( [_1] ) +# 11492 "parsing/parser.ml" + : 'str_extension_constructors)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'str_extension_constructors) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'bar_extension_constructor_declaration) in + Obj.repr( +# 2130 "parsing/parser.mly" + ( _2 :: _1 ) +# 11500 "parsing/parser.ml" + : 'str_extension_constructors)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'str_extension_constructors) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'bar_extension_constructor_rebind) in + Obj.repr( +# 2132 "parsing/parser.mly" + ( _2 :: _1 ) +# 11508 "parsing/parser.ml" + : 'str_extension_constructors)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'extension_constructor_declaration) in + Obj.repr( +# 2135 "parsing/parser.mly" + ( [_1] ) +# 11515 "parsing/parser.ml" + : 'sig_extension_constructors)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'bar_extension_constructor_declaration) in + Obj.repr( +# 2136 "parsing/parser.mly" + ( [_1] ) +# 11522 "parsing/parser.ml" + : 'sig_extension_constructors)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'sig_extension_constructors) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'bar_extension_constructor_declaration) in + Obj.repr( +# 2138 "parsing/parser.mly" + ( _2 :: _1 ) +# 11530 "parsing/parser.ml" + : 'sig_extension_constructors)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'constr_ident) in + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'generalized_constructor_arguments) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in + Obj.repr( +# 2142 "parsing/parser.mly" + ( let args, res = _2 in + Te.decl (mkrhs _1 1) ~args ?res ~attrs:_3 + ~loc:(symbol_rloc()) ~info:(symbol_info ()) ) +# 11541 "parsing/parser.ml" + : 'extension_constructor_declaration)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'constr_ident) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'generalized_constructor_arguments) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in + Obj.repr( +# 2148 "parsing/parser.mly" + ( let args, res = _3 in + Te.decl (mkrhs _2 2) ~args ?res ~attrs:_4 + ~loc:(symbol_rloc()) ~info:(symbol_info ()) ) +# 11552 "parsing/parser.ml" + : 'bar_extension_constructor_declaration)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 3 : 'constr_ident) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'constr_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in + Obj.repr( +# 2154 "parsing/parser.mly" + ( Te.rebind (mkrhs _1 1) (mkrhs _3 3) ~attrs:_4 + ~loc:(symbol_rloc()) ~info:(symbol_info ()) ) +# 11562 "parsing/parser.ml" + : 'extension_constructor_rebind)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'constr_ident) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'constr_longident) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in + Obj.repr( +# 2159 "parsing/parser.mly" + ( Te.rebind (mkrhs _2 2) (mkrhs _4 4) ~attrs:_5 + ~loc:(symbol_rloc()) ~info:(symbol_info ()) ) +# 11572 "parsing/parser.ml" + : 'bar_extension_constructor_rebind)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'with_constraint) in + Obj.repr( +# 2166 "parsing/parser.mly" + ( [_1] ) +# 11579 "parsing/parser.ml" + : 'with_constraints)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'with_constraints) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'with_constraint) in + Obj.repr( +# 2167 "parsing/parser.mly" + ( _3 :: _1 ) +# 11587 "parsing/parser.ml" + : 'with_constraints)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 4 : 'optional_type_parameters) in + let _3 = (Parsing.peek_val __caml_parser_env 3 : 'label_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 2 : 'with_type_binder) in + let _5 = (Parsing.peek_val __caml_parser_env 1 : 'core_type_no_attr) in + let _6 = (Parsing.peek_val __caml_parser_env 0 : 'constraints) in + Obj.repr( +# 2172 "parsing/parser.mly" + ( Pwith_type + (mkrhs _3 3, + (Type.mk (mkrhs (Longident.last _3) 3) + ~params:_2 + ~cstrs:(List.rev _6) + ~manifest:_5 + ~priv:_4 + ~loc:(symbol_rloc()))) ) +# 11605 "parsing/parser.ml" + : 'with_constraint)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'optional_type_parameters) in + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'label_longident) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'core_type_no_attr) in + Obj.repr( +# 2183 "parsing/parser.mly" + ( Pwith_typesubst + (mkrhs _3 3, + (Type.mk (mkrhs (Longident.last _3) 3) + ~params:_2 + ~manifest:_5 + ~loc:(symbol_rloc()))) ) +# 11619 "parsing/parser.ml" + : 'with_constraint)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'mod_ext_longident) in + Obj.repr( +# 2190 "parsing/parser.mly" + ( Pwith_module (mkrhs _2 2, mkrhs _4 4) ) +# 11627 "parsing/parser.ml" + : 'with_constraint)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'mod_ext_longident) in + Obj.repr( +# 2192 "parsing/parser.mly" + ( Pwith_modsubst (mkrhs _2 2, mkrhs _4 4) ) +# 11635 "parsing/parser.ml" + : 'with_constraint)) +; (fun __caml_parser_env -> + Obj.repr( +# 2195 "parsing/parser.mly" + ( Public ) +# 11641 "parsing/parser.ml" + : 'with_type_binder)) +; (fun __caml_parser_env -> + Obj.repr( +# 2196 "parsing/parser.mly" + ( Private ) +# 11647 "parsing/parser.ml" + : 'with_type_binder)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'ident) in + Obj.repr( +# 2202 "parsing/parser.mly" + ( [mkrhs _2 2] ) +# 11654 "parsing/parser.ml" + : 'typevar_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'typevar_list) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'ident) in + Obj.repr( +# 2203 "parsing/parser.mly" + ( mkrhs _3 3 :: _1 ) +# 11662 "parsing/parser.ml" + : 'typevar_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in + Obj.repr( +# 2207 "parsing/parser.mly" + ( _1 ) +# 11669 "parsing/parser.ml" + : 'poly_type)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'typevar_list) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in + Obj.repr( +# 2209 "parsing/parser.mly" + ( mktyp(Ptyp_poly(List.rev _1, _3)) ) +# 11677 "parsing/parser.ml" + : 'poly_type)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'core_type_no_attr) in + Obj.repr( +# 2213 "parsing/parser.mly" + ( _1 ) +# 11684 "parsing/parser.ml" + : 'poly_type_no_attr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'typevar_list) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type_no_attr) in + Obj.repr( +# 2215 "parsing/parser.mly" + ( mktyp(Ptyp_poly(List.rev _1, _3)) ) +# 11692 "parsing/parser.ml" + : 'poly_type_no_attr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'core_type_no_attr) in + Obj.repr( +# 2222 "parsing/parser.mly" + ( _1 ) +# 11699 "parsing/parser.ml" + : 'core_type)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'core_type) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attribute) in + Obj.repr( +# 2224 "parsing/parser.mly" + ( Typ.attr _1 _2 ) +# 11707 "parsing/parser.ml" + : 'core_type)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'core_type2) in + Obj.repr( +# 2228 "parsing/parser.mly" + ( _1 ) +# 11714 "parsing/parser.ml" + : 'core_type_no_attr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 3 : 'core_type2) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'ident) in + Obj.repr( +# 2230 "parsing/parser.mly" + ( mktyp(Ptyp_alias(_1, _4)) ) +# 11722 "parsing/parser.ml" + : 'core_type_no_attr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_core_type_or_tuple) in + Obj.repr( +# 2234 "parsing/parser.mly" + ( _1 ) +# 11729 "parsing/parser.ml" + : 'core_type2)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 4 : string) in + let _4 = (Parsing.peek_val __caml_parser_env 2 : 'core_type2) in + let _6 = (Parsing.peek_val __caml_parser_env 0 : 'core_type2) in + Obj.repr( +# 2236 "parsing/parser.mly" + ( let param = extra_rhs_core_type _4 ~pos:4 in + mktyp (Ptyp_arrow(Optional _2 , param, _6)) ) +# 11739 "parsing/parser.ml" + : 'core_type2)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'core_type2) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'core_type2) in + Obj.repr( +# 2239 "parsing/parser.mly" + ( let param = extra_rhs_core_type _2 ~pos:2 in + mktyp(Ptyp_arrow(Optional _1 , param, _4)) + ) +# 11750 "parsing/parser.ml" + : 'core_type2)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : string) in + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'core_type2) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'core_type2) in + Obj.repr( +# 2243 "parsing/parser.mly" + ( let param = extra_rhs_core_type _3 ~pos:3 in + mktyp(Ptyp_arrow(Labelled _1, param, _5)) ) +# 11760 "parsing/parser.ml" + : 'core_type2)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'core_type2) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type2) in + Obj.repr( +# 2246 "parsing/parser.mly" + ( let param = extra_rhs_core_type _1 ~pos:1 in + mktyp(Ptyp_arrow(Nolabel, param, _3)) ) +# 11769 "parsing/parser.ml" + : 'core_type2)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_core_type2) in + Obj.repr( +# 2252 "parsing/parser.mly" + ( _1 ) +# 11776 "parsing/parser.ml" + : 'simple_core_type)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'core_type_comma_list) in + Obj.repr( +# 2254 "parsing/parser.mly" + ( match _2 with [sty] -> sty | _ -> raise Parse_error ) +# 11783 "parsing/parser.ml" + : 'simple_core_type)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'ident) in + Obj.repr( +# 2259 "parsing/parser.mly" + ( mktyp(Ptyp_var _2) ) +# 11790 "parsing/parser.ml" + : 'simple_core_type2)) +; (fun __caml_parser_env -> + Obj.repr( +# 2261 "parsing/parser.mly" + ( mktyp(Ptyp_any) ) +# 11796 "parsing/parser.ml" + : 'simple_core_type2)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'type_longident) in + Obj.repr( +# 2263 "parsing/parser.mly" + ( mktyp(Ptyp_constr(mkrhs _1 1, [])) ) +# 11803 "parsing/parser.ml" + : 'simple_core_type2)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'simple_core_type2) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'type_longident) in + Obj.repr( +# 2265 "parsing/parser.mly" + ( mktyp(Ptyp_constr(mkrhs _2 2, [_1])) ) +# 11811 "parsing/parser.ml" + : 'simple_core_type2)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'core_type_comma_list) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'type_longident) in + Obj.repr( +# 2267 "parsing/parser.mly" + ( mktyp(Ptyp_constr(mkrhs _4 4, List.rev _2)) ) +# 11819 "parsing/parser.ml" + : 'simple_core_type2)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'meth_list) in + Obj.repr( +# 2269 "parsing/parser.mly" + ( let (f, c) = _2 in mktyp(Ptyp_object (f, c)) ) +# 11826 "parsing/parser.ml" + : 'simple_core_type2)) +; (fun __caml_parser_env -> + Obj.repr( +# 2271 "parsing/parser.mly" + ( mktyp(Ptyp_object ([], Closed)) ) +# 11832 "parsing/parser.ml" + : 'simple_core_type2)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'class_longident) in + Obj.repr( +# 2273 "parsing/parser.mly" + ( mktyp(Ptyp_class(mkrhs _2 2, [])) ) +# 11839 "parsing/parser.ml" + : 'simple_core_type2)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'simple_core_type2) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'class_longident) in + Obj.repr( +# 2275 "parsing/parser.mly" + ( mktyp(Ptyp_class(mkrhs _3 3, [_1])) ) +# 11847 "parsing/parser.ml" + : 'simple_core_type2)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'core_type_comma_list) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'class_longident) in + Obj.repr( +# 2277 "parsing/parser.mly" + ( mktyp(Ptyp_class(mkrhs _5 5, List.rev _2)) ) +# 11855 "parsing/parser.ml" + : 'simple_core_type2)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'tag_field) in + Obj.repr( +# 2279 "parsing/parser.mly" + ( mktyp(Ptyp_variant([_2], Closed, None)) ) +# 11862 "parsing/parser.ml" + : 'simple_core_type2)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'row_field_list) in + Obj.repr( +# 2285 "parsing/parser.mly" + ( mktyp(Ptyp_variant(List.rev _3, Closed, None)) ) +# 11869 "parsing/parser.ml" + : 'simple_core_type2)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'row_field) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'row_field_list) in + Obj.repr( +# 2287 "parsing/parser.mly" + ( mktyp(Ptyp_variant(_2 :: List.rev _4, Closed, None)) ) +# 11877 "parsing/parser.ml" + : 'simple_core_type2)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'opt_bar) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'row_field_list) in + Obj.repr( +# 2289 "parsing/parser.mly" + ( mktyp(Ptyp_variant(List.rev _3, Open, None)) ) +# 11885 "parsing/parser.ml" + : 'simple_core_type2)) +; (fun __caml_parser_env -> + Obj.repr( +# 2291 "parsing/parser.mly" + ( mktyp(Ptyp_variant([], Open, None)) ) +# 11891 "parsing/parser.ml" + : 'simple_core_type2)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'opt_bar) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'row_field_list) in + Obj.repr( +# 2293 "parsing/parser.mly" + ( mktyp(Ptyp_variant(List.rev _3, Closed, Some [])) ) +# 11899 "parsing/parser.ml" + : 'simple_core_type2)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 4 : 'opt_bar) in + let _3 = (Parsing.peek_val __caml_parser_env 3 : 'row_field_list) in + let _5 = (Parsing.peek_val __caml_parser_env 1 : 'name_tag_list) in + Obj.repr( +# 2295 "parsing/parser.mly" + ( mktyp(Ptyp_variant(List.rev _3, Closed, Some (List.rev _5))) ) +# 11908 "parsing/parser.ml" + : 'simple_core_type2)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'package_type) in + Obj.repr( +# 2297 "parsing/parser.mly" + ( mktyp_attrs (Ptyp_package _4) _3 ) +# 11916 "parsing/parser.ml" + : 'simple_core_type2)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'extension) in + Obj.repr( +# 2299 "parsing/parser.mly" + ( mktyp (Ptyp_extension _1) ) +# 11923 "parsing/parser.ml" + : 'simple_core_type2)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'module_type) in + Obj.repr( +# 2302 "parsing/parser.mly" + ( package_type_of_module_type _1 ) +# 11930 "parsing/parser.ml" + : 'package_type)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'row_field) in + Obj.repr( +# 2305 "parsing/parser.mly" + ( [_1] ) +# 11937 "parsing/parser.ml" + : 'row_field_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'row_field_list) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'row_field) in + Obj.repr( +# 2306 "parsing/parser.mly" + ( _3 :: _1 ) +# 11945 "parsing/parser.ml" + : 'row_field_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'tag_field) in + Obj.repr( +# 2309 "parsing/parser.mly" + ( _1 ) +# 11952 "parsing/parser.ml" + : 'row_field)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_core_type) in + Obj.repr( +# 2310 "parsing/parser.mly" + ( Rinherit _1 ) +# 11959 "parsing/parser.ml" + : 'row_field)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'name_tag) in + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'opt_ampersand) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'amper_type_list) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in + Obj.repr( +# 2314 "parsing/parser.mly" + ( Rtag (mkrhs _1 1, add_info_attrs (symbol_info ()) _5, + _3, List.rev _4) ) +# 11970 "parsing/parser.ml" + : 'tag_field)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'name_tag) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in + Obj.repr( +# 2317 "parsing/parser.mly" + ( Rtag (mkrhs _1 1, add_info_attrs (symbol_info ()) _2, true, []) ) +# 11978 "parsing/parser.ml" + : 'tag_field)) +; (fun __caml_parser_env -> + Obj.repr( +# 2320 "parsing/parser.mly" + ( true ) +# 11984 "parsing/parser.ml" + : 'opt_ampersand)) +; (fun __caml_parser_env -> + Obj.repr( +# 2321 "parsing/parser.mly" + ( false ) +# 11990 "parsing/parser.ml" + : 'opt_ampersand)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'core_type_no_attr) in + Obj.repr( +# 2324 "parsing/parser.mly" + ( [_1] ) +# 11997 "parsing/parser.ml" + : 'amper_type_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'amper_type_list) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type_no_attr) in + Obj.repr( +# 2325 "parsing/parser.mly" + ( _3 :: _1 ) +# 12005 "parsing/parser.ml" + : 'amper_type_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'name_tag) in + Obj.repr( +# 2328 "parsing/parser.mly" + ( [_1] ) +# 12012 "parsing/parser.ml" + : 'name_tag_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'name_tag_list) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'name_tag) in + Obj.repr( +# 2329 "parsing/parser.mly" + ( _2 :: _1 ) +# 12020 "parsing/parser.ml" + : 'name_tag_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_core_type) in + Obj.repr( +# 2332 "parsing/parser.mly" + ( _1 ) +# 12027 "parsing/parser.ml" + : 'simple_core_type_or_tuple)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'simple_core_type) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type_list) in + Obj.repr( +# 2334 "parsing/parser.mly" + ( mktyp(Ptyp_tuple(_1 :: List.rev _3)) ) +# 12035 "parsing/parser.ml" + : 'simple_core_type_or_tuple)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in + Obj.repr( +# 2337 "parsing/parser.mly" + ( [_1] ) +# 12042 "parsing/parser.ml" + : 'core_type_comma_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'core_type_comma_list) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in + Obj.repr( +# 2338 "parsing/parser.mly" + ( _3 :: _1 ) +# 12050 "parsing/parser.ml" + : 'core_type_comma_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_core_type) in + Obj.repr( +# 2341 "parsing/parser.mly" + ( [_1] ) +# 12057 "parsing/parser.ml" + : 'core_type_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'core_type_list) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'simple_core_type) in + Obj.repr( +# 2342 "parsing/parser.mly" + ( _3 :: _1 ) +# 12065 "parsing/parser.ml" + : 'core_type_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'field_semi) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'meth_list) in + Obj.repr( +# 2345 "parsing/parser.mly" + ( let (f, c) = _2 in (_1 :: f, c) ) +# 12073 "parsing/parser.ml" + : 'meth_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'inherit_field_semi) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'meth_list) in + Obj.repr( +# 2346 "parsing/parser.mly" + ( let (f, c) = _2 in (_1 :: f, c) ) +# 12081 "parsing/parser.ml" + : 'meth_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'field_semi) in + Obj.repr( +# 2347 "parsing/parser.mly" + ( [_1], Closed ) +# 12088 "parsing/parser.ml" + : 'meth_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'field) in + Obj.repr( +# 2348 "parsing/parser.mly" + ( [_1], Closed ) +# 12095 "parsing/parser.ml" + : 'meth_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'inherit_field_semi) in + Obj.repr( +# 2349 "parsing/parser.mly" + ( [_1], Closed ) +# 12102 "parsing/parser.ml" + : 'meth_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_core_type) in + Obj.repr( +# 2350 "parsing/parser.mly" + ( [Oinherit _1], Closed ) +# 12109 "parsing/parser.ml" + : 'meth_list)) +; (fun __caml_parser_env -> + Obj.repr( +# 2351 "parsing/parser.mly" + ( [], Open ) +# 12115 "parsing/parser.ml" + : 'meth_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 3 : 'label) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'poly_type_no_attr) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in + Obj.repr( +# 2355 "parsing/parser.mly" + ( Otag (mkrhs _1 1, add_info_attrs (symbol_info ()) _4, _3) ) +# 12124 "parsing/parser.ml" + : 'field)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 5 : 'label) in + let _3 = (Parsing.peek_val __caml_parser_env 3 : 'poly_type_no_attr) in + let _4 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in + let _6 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in + Obj.repr( +# 2360 "parsing/parser.mly" + ( let info = + match rhs_info 4 with + | Some _ as info_before_semi -> info_before_semi + | None -> symbol_info () + in + ( Otag (mkrhs _1 1, add_info_attrs info (_4 @ _6), _3)) ) +# 12139 "parsing/parser.ml" + : 'field_semi)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'simple_core_type) in + Obj.repr( +# 2369 "parsing/parser.mly" + ( Oinherit _1 ) +# 12146 "parsing/parser.ml" + : 'inherit_field_semi)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2372 "parsing/parser.mly" + ( _1 ) +# 12153 "parsing/parser.ml" + : 'label)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string * char option) in + Obj.repr( +# 2378 "parsing/parser.mly" + ( let (n, m) = _1 in Pconst_integer (n, m) ) +# 12160 "parsing/parser.ml" + : 'constant)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : char) in + Obj.repr( +# 2379 "parsing/parser.mly" + ( Pconst_char _1 ) +# 12167 "parsing/parser.ml" + : 'constant)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string * string option) in + Obj.repr( +# 2380 "parsing/parser.mly" + ( let (s, d) = _1 in Pconst_string (s, d) ) +# 12174 "parsing/parser.ml" + : 'constant)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string * char option) in + Obj.repr( +# 2381 "parsing/parser.mly" + ( let (f, m) = _1 in Pconst_float (f, m) ) +# 12181 "parsing/parser.ml" + : 'constant)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'constant) in + Obj.repr( +# 2384 "parsing/parser.mly" + ( _1 ) +# 12188 "parsing/parser.ml" + : 'signed_constant)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : string * char option) in + Obj.repr( +# 2385 "parsing/parser.mly" + ( let (n, m) = _2 in Pconst_integer("-" ^ n, m) ) +# 12195 "parsing/parser.ml" + : 'signed_constant)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : string * char option) in + Obj.repr( +# 2386 "parsing/parser.mly" + ( let (f, m) = _2 in Pconst_float("-" ^ f, m) ) +# 12202 "parsing/parser.ml" + : 'signed_constant)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : string * char option) in + Obj.repr( +# 2387 "parsing/parser.mly" + ( let (n, m) = _2 in Pconst_integer (n, m) ) +# 12209 "parsing/parser.ml" + : 'signed_constant)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : string * char option) in + Obj.repr( +# 2388 "parsing/parser.mly" + ( let (f, m) = _2 in Pconst_float(f, m) ) +# 12216 "parsing/parser.ml" + : 'signed_constant)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2394 "parsing/parser.mly" + ( _1 ) +# 12223 "parsing/parser.ml" + : 'ident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2395 "parsing/parser.mly" + ( _1 ) +# 12230 "parsing/parser.ml" + : 'ident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2398 "parsing/parser.mly" + ( _1 ) +# 12237 "parsing/parser.ml" + : 'val_ident)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'operator) in + Obj.repr( +# 2399 "parsing/parser.mly" + ( _2 ) +# 12244 "parsing/parser.ml" + : 'val_ident)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'operator) in + Obj.repr( +# 2400 "parsing/parser.mly" + ( unclosed "(" 1 ")" 3 ) +# 12251 "parsing/parser.ml" + : 'val_ident)) +; (fun __caml_parser_env -> + Obj.repr( +# 2401 "parsing/parser.mly" + ( expecting 2 "operator" ) +# 12257 "parsing/parser.ml" + : 'val_ident)) +; (fun __caml_parser_env -> + Obj.repr( +# 2402 "parsing/parser.mly" + ( expecting 3 "module-expr" ) +# 12263 "parsing/parser.ml" + : 'val_ident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2405 "parsing/parser.mly" + ( _1 ) +# 12270 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2406 "parsing/parser.mly" + ( _1 ) +# 12277 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2407 "parsing/parser.mly" + ( _1 ) +# 12284 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2408 "parsing/parser.mly" + ( _1 ) +# 12291 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2409 "parsing/parser.mly" + ( _1 ) +# 12298 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2410 "parsing/parser.mly" + ( _1 ) +# 12305 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : string) in + Obj.repr( +# 2411 "parsing/parser.mly" + ( "."^ _1 ^"()" ) +# 12312 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 3 : string) in + Obj.repr( +# 2412 "parsing/parser.mly" + ( "."^ _1 ^ "()<-" ) +# 12319 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : string) in + Obj.repr( +# 2413 "parsing/parser.mly" + ( "."^ _1 ^"[]" ) +# 12326 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 3 : string) in + Obj.repr( +# 2414 "parsing/parser.mly" + ( "."^ _1 ^ "[]<-" ) +# 12333 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : string) in + Obj.repr( +# 2415 "parsing/parser.mly" + ( "."^ _1 ^"{}" ) +# 12340 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 3 : string) in + Obj.repr( +# 2416 "parsing/parser.mly" + ( "."^ _1 ^ "{}<-" ) +# 12347 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2417 "parsing/parser.mly" + ( _1 ) +# 12354 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + Obj.repr( +# 2418 "parsing/parser.mly" + ( "!" ) +# 12360 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + Obj.repr( +# 2419 "parsing/parser.mly" + ( "+" ) +# 12366 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + Obj.repr( +# 2420 "parsing/parser.mly" + ( "+." ) +# 12372 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + Obj.repr( +# 2421 "parsing/parser.mly" + ( "-" ) +# 12378 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + Obj.repr( +# 2422 "parsing/parser.mly" + ( "-." ) +# 12384 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + Obj.repr( +# 2423 "parsing/parser.mly" + ( "*" ) +# 12390 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + Obj.repr( +# 2424 "parsing/parser.mly" + ( "=" ) +# 12396 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + Obj.repr( +# 2425 "parsing/parser.mly" + ( "<" ) +# 12402 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + Obj.repr( +# 2426 "parsing/parser.mly" + ( ">" ) +# 12408 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + Obj.repr( +# 2427 "parsing/parser.mly" + ( "or" ) +# 12414 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + Obj.repr( +# 2428 "parsing/parser.mly" + ( "||" ) +# 12420 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + Obj.repr( +# 2429 "parsing/parser.mly" + ( "&" ) +# 12426 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + Obj.repr( +# 2430 "parsing/parser.mly" + ( "&&" ) +# 12432 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + Obj.repr( +# 2431 "parsing/parser.mly" + ( ":=" ) +# 12438 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + Obj.repr( +# 2432 "parsing/parser.mly" + ( "+=" ) +# 12444 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + Obj.repr( +# 2433 "parsing/parser.mly" + ( "%" ) +# 12450 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2436 "parsing/parser.mly" + ( _1 ) +# 12457 "parsing/parser.ml" + : 'constr_ident)) +; (fun __caml_parser_env -> + Obj.repr( +# 2437 "parsing/parser.mly" + ( "[]" ) +# 12463 "parsing/parser.ml" + : 'constr_ident)) +; (fun __caml_parser_env -> + Obj.repr( +# 2438 "parsing/parser.mly" + ( "()" ) +# 12469 "parsing/parser.ml" + : 'constr_ident)) +; (fun __caml_parser_env -> + Obj.repr( +# 2439 "parsing/parser.mly" + ( "::" ) +# 12475 "parsing/parser.ml" + : 'constr_ident)) +; (fun __caml_parser_env -> + Obj.repr( +# 2440 "parsing/parser.mly" + ( "false" ) +# 12481 "parsing/parser.ml" + : 'constr_ident)) +; (fun __caml_parser_env -> + Obj.repr( +# 2441 "parsing/parser.mly" + ( "true" ) +# 12487 "parsing/parser.ml" + : 'constr_ident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'val_ident) in + Obj.repr( +# 2445 "parsing/parser.mly" + ( Lident _1 ) +# 12494 "parsing/parser.ml" + : 'val_longident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'mod_longident) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'val_ident) in + Obj.repr( +# 2446 "parsing/parser.mly" + ( Ldot(_1, _3) ) +# 12502 "parsing/parser.ml" + : 'val_longident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'mod_longident) in + Obj.repr( +# 2449 "parsing/parser.mly" + ( _1 ) +# 12509 "parsing/parser.ml" + : 'constr_longident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in + Obj.repr( +# 2450 "parsing/parser.mly" + ( Ldot(_1,"::") ) +# 12516 "parsing/parser.ml" + : 'constr_longident)) +; (fun __caml_parser_env -> + Obj.repr( +# 2451 "parsing/parser.mly" + ( Lident "[]" ) +# 12522 "parsing/parser.ml" + : 'constr_longident)) +; (fun __caml_parser_env -> + Obj.repr( +# 2452 "parsing/parser.mly" + ( Lident "()" ) +# 12528 "parsing/parser.ml" + : 'constr_longident)) +; (fun __caml_parser_env -> + Obj.repr( +# 2453 "parsing/parser.mly" + ( Lident "::" ) +# 12534 "parsing/parser.ml" + : 'constr_longident)) +; (fun __caml_parser_env -> + Obj.repr( +# 2454 "parsing/parser.mly" + ( Lident "false" ) +# 12540 "parsing/parser.ml" + : 'constr_longident)) +; (fun __caml_parser_env -> + Obj.repr( +# 2455 "parsing/parser.mly" + ( Lident "true" ) +# 12546 "parsing/parser.ml" + : 'constr_longident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2458 "parsing/parser.mly" + ( Lident _1 ) +# 12553 "parsing/parser.ml" + : 'label_longident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'mod_longident) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2459 "parsing/parser.mly" + ( Ldot(_1, _3) ) +# 12561 "parsing/parser.ml" + : 'label_longident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2462 "parsing/parser.mly" + ( Lident _1 ) +# 12568 "parsing/parser.ml" + : 'type_longident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'mod_ext_longident) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2463 "parsing/parser.mly" + ( Ldot(_1, _3) ) +# 12576 "parsing/parser.ml" + : 'type_longident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2466 "parsing/parser.mly" + ( Lident _1 ) +# 12583 "parsing/parser.ml" + : 'mod_longident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'mod_longident) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2467 "parsing/parser.mly" + ( Ldot(_1, _3) ) +# 12591 "parsing/parser.ml" + : 'mod_longident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2470 "parsing/parser.mly" + ( Lident _1 ) +# 12598 "parsing/parser.ml" + : 'mod_ext_longident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'mod_ext_longident) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2471 "parsing/parser.mly" + ( Ldot(_1, _3) ) +# 12606 "parsing/parser.ml" + : 'mod_ext_longident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 3 : 'mod_ext_longident) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'mod_ext_longident) in + Obj.repr( +# 2472 "parsing/parser.mly" + ( lapply _1 _3 ) +# 12614 "parsing/parser.ml" + : 'mod_ext_longident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'ident) in + Obj.repr( +# 2475 "parsing/parser.mly" + ( Lident _1 ) +# 12621 "parsing/parser.ml" + : 'mty_longident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'mod_ext_longident) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'ident) in + Obj.repr( +# 2476 "parsing/parser.mly" + ( Ldot(_1, _3) ) +# 12629 "parsing/parser.ml" + : 'mty_longident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2479 "parsing/parser.mly" + ( Lident _1 ) +# 12636 "parsing/parser.ml" + : 'clty_longident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'mod_ext_longident) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2480 "parsing/parser.mly" + ( Ldot(_1, _3) ) +# 12644 "parsing/parser.ml" + : 'clty_longident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2483 "parsing/parser.mly" + ( Lident _1 ) +# 12651 "parsing/parser.ml" + : 'class_longident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'mod_longident) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2484 "parsing/parser.mly" + ( Ldot(_1, _3) ) +# 12659 "parsing/parser.ml" + : 'class_longident)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'ident) in + Obj.repr( +# 2490 "parsing/parser.mly" + ( Ptop_dir(_2, Pdir_none) ) +# 12666 "parsing/parser.ml" + : 'toplevel_directive)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ident) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : string * string option) in + Obj.repr( +# 2491 "parsing/parser.mly" + ( Ptop_dir(_2, Pdir_string (fst _3)) ) +# 12674 "parsing/parser.ml" + : 'toplevel_directive)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ident) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : string * char option) in + Obj.repr( +# 2492 "parsing/parser.mly" + ( let (n, m) = _3 in + Ptop_dir(_2, Pdir_int (n ,m)) ) +# 12683 "parsing/parser.ml" + : 'toplevel_directive)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ident) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'val_longident) in + Obj.repr( +# 2494 "parsing/parser.mly" + ( Ptop_dir(_2, Pdir_ident _3) ) +# 12691 "parsing/parser.ml" + : 'toplevel_directive)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ident) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'mod_longident) in + Obj.repr( +# 2495 "parsing/parser.mly" + ( Ptop_dir(_2, Pdir_ident _3) ) +# 12699 "parsing/parser.ml" + : 'toplevel_directive)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ident) in + Obj.repr( +# 2496 "parsing/parser.mly" + ( Ptop_dir(_2, Pdir_bool false) ) +# 12706 "parsing/parser.ml" + : 'toplevel_directive)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ident) in + Obj.repr( +# 2497 "parsing/parser.mly" + ( Ptop_dir(_2, Pdir_bool true) ) +# 12713 "parsing/parser.ml" + : 'toplevel_directive)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'ident) in + Obj.repr( +# 2503 "parsing/parser.mly" + ( _2 ) +# 12720 "parsing/parser.ml" + : 'name_tag)) +; (fun __caml_parser_env -> + Obj.repr( +# 2506 "parsing/parser.mly" + ( Nonrecursive ) +# 12726 "parsing/parser.ml" + : 'rec_flag)) +; (fun __caml_parser_env -> + Obj.repr( +# 2507 "parsing/parser.mly" + ( Recursive ) +# 12732 "parsing/parser.ml" + : 'rec_flag)) +; (fun __caml_parser_env -> + Obj.repr( +# 2510 "parsing/parser.mly" + ( Recursive ) +# 12738 "parsing/parser.ml" + : 'nonrec_flag)) +; (fun __caml_parser_env -> + Obj.repr( +# 2511 "parsing/parser.mly" + ( Nonrecursive ) +# 12744 "parsing/parser.ml" + : 'nonrec_flag)) +; (fun __caml_parser_env -> + Obj.repr( +# 2514 "parsing/parser.mly" + ( Upto ) +# 12750 "parsing/parser.ml" + : 'direction_flag)) +; (fun __caml_parser_env -> + Obj.repr( +# 2515 "parsing/parser.mly" + ( Downto ) +# 12756 "parsing/parser.ml" + : 'direction_flag)) +; (fun __caml_parser_env -> + Obj.repr( +# 2518 "parsing/parser.mly" + ( Public ) +# 12762 "parsing/parser.ml" + : 'private_flag)) +; (fun __caml_parser_env -> + Obj.repr( +# 2519 "parsing/parser.mly" + ( Private ) +# 12768 "parsing/parser.ml" + : 'private_flag)) +; (fun __caml_parser_env -> + Obj.repr( +# 2522 "parsing/parser.mly" + ( Immutable ) +# 12774 "parsing/parser.ml" + : 'mutable_flag)) +; (fun __caml_parser_env -> + Obj.repr( +# 2523 "parsing/parser.mly" + ( Mutable ) +# 12780 "parsing/parser.ml" + : 'mutable_flag)) +; (fun __caml_parser_env -> + Obj.repr( +# 2526 "parsing/parser.mly" + ( Concrete ) +# 12786 "parsing/parser.ml" + : 'virtual_flag)) +; (fun __caml_parser_env -> + Obj.repr( +# 2527 "parsing/parser.mly" + ( Virtual ) +# 12792 "parsing/parser.ml" + : 'virtual_flag)) +; (fun __caml_parser_env -> + Obj.repr( +# 2530 "parsing/parser.mly" + ( Public, Concrete ) +# 12798 "parsing/parser.ml" + : 'private_virtual_flags)) +; (fun __caml_parser_env -> + Obj.repr( +# 2531 "parsing/parser.mly" + ( Private, Concrete ) +# 12804 "parsing/parser.ml" + : 'private_virtual_flags)) +; (fun __caml_parser_env -> + Obj.repr( +# 2532 "parsing/parser.mly" + ( Public, Virtual ) +# 12810 "parsing/parser.ml" + : 'private_virtual_flags)) +; (fun __caml_parser_env -> + Obj.repr( +# 2533 "parsing/parser.mly" + ( Private, Virtual ) +# 12816 "parsing/parser.ml" + : 'private_virtual_flags)) +; (fun __caml_parser_env -> + Obj.repr( +# 2534 "parsing/parser.mly" + ( Private, Virtual ) +# 12822 "parsing/parser.ml" + : 'private_virtual_flags)) +; (fun __caml_parser_env -> + Obj.repr( +# 2537 "parsing/parser.mly" + ( Fresh ) +# 12828 "parsing/parser.ml" + : 'override_flag)) +; (fun __caml_parser_env -> + Obj.repr( +# 2538 "parsing/parser.mly" + ( Override ) +# 12834 "parsing/parser.ml" + : 'override_flag)) +; (fun __caml_parser_env -> + Obj.repr( +# 2541 "parsing/parser.mly" + ( () ) +# 12840 "parsing/parser.ml" + : 'opt_bar)) +; (fun __caml_parser_env -> + Obj.repr( +# 2542 "parsing/parser.mly" + ( () ) +# 12846 "parsing/parser.ml" + : 'opt_bar)) +; (fun __caml_parser_env -> + Obj.repr( +# 2545 "parsing/parser.mly" + ( () ) +# 12852 "parsing/parser.ml" + : 'opt_semi)) +; (fun __caml_parser_env -> + Obj.repr( +# 2546 "parsing/parser.mly" + ( () ) +# 12858 "parsing/parser.ml" + : 'opt_semi)) +; (fun __caml_parser_env -> + Obj.repr( +# 2549 "parsing/parser.mly" + ( "-" ) +# 12864 "parsing/parser.ml" + : 'subtractive)) +; (fun __caml_parser_env -> + Obj.repr( +# 2550 "parsing/parser.mly" + ( "-." ) +# 12870 "parsing/parser.ml" + : 'subtractive)) +; (fun __caml_parser_env -> + Obj.repr( +# 2553 "parsing/parser.mly" + ( "+" ) +# 12876 "parsing/parser.ml" + : 'additive)) +; (fun __caml_parser_env -> + Obj.repr( +# 2554 "parsing/parser.mly" + ( "+." ) +# 12882 "parsing/parser.ml" + : 'additive)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2560 "parsing/parser.mly" + ( _1 ) +# 12889 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2561 "parsing/parser.mly" + ( _1 ) +# 12896 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2562 "parsing/parser.mly" + ( "and" ) +# 12902 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2563 "parsing/parser.mly" + ( "as" ) +# 12908 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2564 "parsing/parser.mly" + ( "assert" ) +# 12914 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2565 "parsing/parser.mly" + ( "begin" ) +# 12920 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2566 "parsing/parser.mly" + ( "class" ) +# 12926 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2567 "parsing/parser.mly" + ( "constraint" ) +# 12932 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2568 "parsing/parser.mly" + ( "do" ) +# 12938 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2569 "parsing/parser.mly" + ( "done" ) +# 12944 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2570 "parsing/parser.mly" + ( "downto" ) +# 12950 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2571 "parsing/parser.mly" + ( "else" ) +# 12956 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2572 "parsing/parser.mly" + ( "end" ) +# 12962 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2573 "parsing/parser.mly" + ( "exception" ) +# 12968 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2574 "parsing/parser.mly" + ( "external" ) +# 12974 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2575 "parsing/parser.mly" + ( "false" ) +# 12980 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2576 "parsing/parser.mly" + ( "for" ) +# 12986 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2577 "parsing/parser.mly" + ( "fun" ) +# 12992 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2578 "parsing/parser.mly" + ( "function" ) +# 12998 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2579 "parsing/parser.mly" + ( "functor" ) +# 13004 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2580 "parsing/parser.mly" + ( "if" ) +# 13010 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2581 "parsing/parser.mly" + ( "in" ) +# 13016 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2582 "parsing/parser.mly" + ( "include" ) +# 13022 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2583 "parsing/parser.mly" + ( "inherit" ) +# 13028 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2584 "parsing/parser.mly" + ( "initializer" ) +# 13034 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2585 "parsing/parser.mly" + ( "lazy" ) +# 13040 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2586 "parsing/parser.mly" + ( "let" ) +# 13046 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2587 "parsing/parser.mly" + ( "match" ) +# 13052 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2588 "parsing/parser.mly" + ( "method" ) +# 13058 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2589 "parsing/parser.mly" + ( "module" ) +# 13064 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2590 "parsing/parser.mly" + ( "mutable" ) +# 13070 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2591 "parsing/parser.mly" + ( "new" ) +# 13076 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2592 "parsing/parser.mly" + ( "nonrec" ) +# 13082 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2593 "parsing/parser.mly" + ( "object" ) +# 13088 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2594 "parsing/parser.mly" + ( "of" ) +# 13094 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2595 "parsing/parser.mly" + ( "open" ) +# 13100 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2596 "parsing/parser.mly" + ( "or" ) +# 13106 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2597 "parsing/parser.mly" + ( "private" ) +# 13112 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2598 "parsing/parser.mly" + ( "rec" ) +# 13118 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2599 "parsing/parser.mly" + ( "sig" ) +# 13124 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2600 "parsing/parser.mly" + ( "struct" ) +# 13130 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2601 "parsing/parser.mly" + ( "then" ) +# 13136 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2602 "parsing/parser.mly" + ( "to" ) +# 13142 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2603 "parsing/parser.mly" + ( "true" ) +# 13148 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2604 "parsing/parser.mly" + ( "try" ) +# 13154 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2605 "parsing/parser.mly" + ( "type" ) +# 13160 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2606 "parsing/parser.mly" + ( "val" ) +# 13166 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2607 "parsing/parser.mly" + ( "virtual" ) +# 13172 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2608 "parsing/parser.mly" + ( "when" ) +# 13178 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2609 "parsing/parser.mly" + ( "while" ) +# 13184 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2610 "parsing/parser.mly" + ( "with" ) +# 13190 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'single_attr_id) in + Obj.repr( +# 2615 "parsing/parser.mly" + ( mkloc _1 (symbol_rloc()) ) +# 13197 "parsing/parser.ml" + : 'attr_id)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'single_attr_id) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'attr_id) in + Obj.repr( +# 2616 "parsing/parser.mly" + ( mkloc (_1 ^ "." ^ _3.txt) (symbol_rloc())) +# 13205 "parsing/parser.ml" + : 'attr_id)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attr_id) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'payload) in + Obj.repr( +# 2619 "parsing/parser.mly" + ( (_2, _3) ) +# 13213 "parsing/parser.ml" + : 'attribute)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attr_id) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'payload) in + Obj.repr( +# 2622 "parsing/parser.mly" + ( (_2, _3) ) +# 13221 "parsing/parser.ml" + : 'post_item_attribute)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attr_id) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'payload) in + Obj.repr( +# 2625 "parsing/parser.mly" + ( (_2, _3) ) +# 13229 "parsing/parser.ml" + : 'floating_attribute)) +; (fun __caml_parser_env -> + Obj.repr( +# 2628 "parsing/parser.mly" + ( [] ) +# 13235 "parsing/parser.ml" + : 'post_item_attributes)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'post_item_attribute) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 2629 "parsing/parser.mly" + ( _1 :: _2 ) +# 13243 "parsing/parser.ml" + : 'post_item_attributes)) +; (fun __caml_parser_env -> + Obj.repr( +# 2632 "parsing/parser.mly" + ( [] ) +# 13249 "parsing/parser.ml" + : 'attributes)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'attribute) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in + Obj.repr( +# 2633 "parsing/parser.mly" + ( _1 :: _2 ) +# 13257 "parsing/parser.ml" + : 'attributes)) +; (fun __caml_parser_env -> + Obj.repr( +# 2636 "parsing/parser.mly" + ( None, [] ) +# 13263 "parsing/parser.ml" + : 'ext_attributes)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'attribute) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in + Obj.repr( +# 2637 "parsing/parser.mly" + ( None, _1 :: _2 ) +# 13271 "parsing/parser.ml" + : 'ext_attributes)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'attr_id) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in + Obj.repr( +# 2638 "parsing/parser.mly" + ( Some _2, _3 ) +# 13279 "parsing/parser.ml" + : 'ext_attributes)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attr_id) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'payload) in + Obj.repr( +# 2641 "parsing/parser.mly" + ( (_2, _3) ) +# 13287 "parsing/parser.ml" + : 'extension)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attr_id) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'payload) in + Obj.repr( +# 2644 "parsing/parser.mly" + ( (_2, _3) ) +# 13295 "parsing/parser.ml" + : 'item_extension)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'structure) in + Obj.repr( +# 2647 "parsing/parser.mly" + ( PStr _1 ) +# 13302 "parsing/parser.ml" + : 'payload)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'signature) in + Obj.repr( +# 2648 "parsing/parser.mly" + ( PSig _2 ) +# 13309 "parsing/parser.ml" + : 'payload)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in + Obj.repr( +# 2649 "parsing/parser.mly" + ( PTyp _2 ) +# 13316 "parsing/parser.ml" + : 'payload)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in + Obj.repr( +# 2650 "parsing/parser.mly" + ( PPat (_2, None) ) +# 13323 "parsing/parser.ml" + : 'payload)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 2651 "parsing/parser.mly" + ( PPat (_2, Some _4) ) +# 13331 "parsing/parser.ml" + : 'payload)) +(* Entry implementation *) +; (fun __caml_parser_env -> raise (Parsing.YYexit (Parsing.peek_val __caml_parser_env 0))) +(* Entry interface *) +; (fun __caml_parser_env -> raise (Parsing.YYexit (Parsing.peek_val __caml_parser_env 0))) +(* Entry toplevel_phrase *) +; (fun __caml_parser_env -> raise (Parsing.YYexit (Parsing.peek_val __caml_parser_env 0))) +(* Entry use_file *) +; (fun __caml_parser_env -> raise (Parsing.YYexit (Parsing.peek_val __caml_parser_env 0))) +(* Entry parse_core_type *) +; (fun __caml_parser_env -> raise (Parsing.YYexit (Parsing.peek_val __caml_parser_env 0))) +(* Entry parse_expression *) +; (fun __caml_parser_env -> raise (Parsing.YYexit (Parsing.peek_val __caml_parser_env 0))) +(* Entry parse_pattern *) +; (fun __caml_parser_env -> raise (Parsing.YYexit (Parsing.peek_val __caml_parser_env 0))) +|] +let yytables = + { Parsing.actions=yyact; + Parsing.transl_const=yytransl_const; + Parsing.transl_block=yytransl_block; + Parsing.lhs=yylhs; + Parsing.len=yylen; + Parsing.defred=yydefred; + Parsing.dgoto=yydgoto; + Parsing.sindex=yysindex; + Parsing.rindex=yyrindex; + Parsing.gindex=yygindex; + Parsing.tablesize=yytablesize; + Parsing.table=yytable; + Parsing.check=yycheck; + Parsing.error_function=parse_error; + Parsing.names_const=yynames_const; + Parsing.names_block=yynames_block } +let implementation (lexfun : Lexing.lexbuf -> token) (lexbuf : Lexing.lexbuf) = + (Parsing.yyparse yytables 1 lexfun lexbuf : Parsetree.structure) +let interface (lexfun : Lexing.lexbuf -> token) (lexbuf : Lexing.lexbuf) = + (Parsing.yyparse yytables 2 lexfun lexbuf : Parsetree.signature) +let toplevel_phrase (lexfun : Lexing.lexbuf -> token) (lexbuf : Lexing.lexbuf) = + (Parsing.yyparse yytables 3 lexfun lexbuf : Parsetree.toplevel_phrase) +let use_file (lexfun : Lexing.lexbuf -> token) (lexbuf : Lexing.lexbuf) = + (Parsing.yyparse yytables 4 lexfun lexbuf : Parsetree.toplevel_phrase list) +let parse_core_type (lexfun : Lexing.lexbuf -> token) (lexbuf : Lexing.lexbuf) = + (Parsing.yyparse yytables 5 lexfun lexbuf : Parsetree.core_type) +let parse_expression (lexfun : Lexing.lexbuf -> token) (lexbuf : Lexing.lexbuf) = + (Parsing.yyparse yytables 6 lexfun lexbuf : Parsetree.expression) +let parse_pattern (lexfun : Lexing.lexbuf -> token) (lexbuf : Lexing.lexbuf) = + (Parsing.yyparse yytables 7 lexfun lexbuf : Parsetree.pattern) +;; -and add_extension ~check id ext env = - store_extension ~check id ext env +end +module Lexer : sig +#1 "lexer.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -and add_module_declaration ?(arg=false) ~check id md env = - let env = store_module ~check id md env in - if arg then add_functor_arg id env else env +(* The lexical analyzer *) -and add_modtype id info env = - store_modtype id info env +val init : unit -> unit +val token: Lexing.lexbuf -> Parser.token +val skip_hash_bang: Lexing.lexbuf -> unit -and add_class id ty env = - store_class id ty env +type directive_type -and add_cltype id ty env = - store_cltype id ty env +type error = + | Illegal_character of char + | Illegal_escape of string + | Unterminated_comment of Location.t + | Unterminated_string + | Unterminated_string_in_comment of Location.t * Location.t + | Keyword_as_label of string + | Invalid_literal of string + | Invalid_directive of string * string option + | Unterminated_paren_in_conditional + | Unterminated_if + | Unterminated_else + | Unexpected_token_in_conditional + | Expect_hash_then_in_conditional + | Illegal_semver of string + | Unexpected_directive + | Conditional_expr_expected_type of directive_type * directive_type +;; -let add_module ?arg id mty env = - add_module_declaration ~check:false ?arg id (md mty) env +exception Error of error * Location.t -let add_local_type path info env = - { env with - local_constraints = PathMap.add path info env.local_constraints } +open Format -let add_local_constraint path info elv env = - match info with - {type_manifest = Some _; type_newtype_level = Some (lv, _)} -> - (* elv is the expansion level, lv is the definition level *) - let info = {info with type_newtype_level = Some (lv, elv)} in - add_local_type path info env - | _ -> assert false +val report_error: formatter -> error -> unit + (* Deprecated. Use Location.{error_of_exn, report_error}. *) +val in_comment : unit -> bool;; +val in_string : unit -> bool;; -(* Insertion of bindings by name *) -let enter store_fun name data env = - let id = Ident.create name in (id, store_fun id data env) +val print_warnings : bool ref +val handle_docstrings: bool ref +val comments : unit -> (string * Location.t) list +val token_with_comments : Lexing.lexbuf -> Parser.token -let enter_value ?check = enter (store_value ?check) -and enter_type = enter (store_type ~check:true) -and enter_extension = enter (store_extension ~check:true) -and enter_module_declaration ?arg id md env = - add_module_declaration ?arg ~check:true id md env - (* let (id, env) = enter store_module name md env in - (id, add_functor_arg ?arg id env) *) -and enter_modtype = enter store_modtype -and enter_class = enter store_class -and enter_cltype = enter store_cltype +(* + [set_preprocessor init preprocessor] registers [init] as the function +to call to initialize the preprocessor when the lexer is initialized, +and [preprocessor] a function that is called when a new token is needed +by the parser, as [preprocessor lexer lexbuf] where [lexer] is the +lexing function. -let enter_module ?arg s mty env = - let id = Ident.create s in - (id, enter_module_declaration ?arg id (md mty) env) +When a preprocessor is configured by calling [set_preprocessor], the lexer +changes its behavior to accept backslash-newline as a token-separating blank. +*) -(* Insertion of all components of a signature *) +val set_preprocessor : + (unit -> unit) -> + ((Lexing.lexbuf -> Parser.token) -> Lexing.lexbuf -> Parser.token) -> + unit -let add_item comp env = - match comp with - Sig_value(id, decl) -> add_value id decl env - | Sig_type(id, decl, _) -> add_type ~check:false id decl env - | Sig_typext(id, ext, _) -> add_extension ~check:false id ext env - | Sig_module(id, md, _) -> add_module_declaration ~check:false id md env - | Sig_modtype(id, decl) -> add_modtype id decl env - | Sig_class(id, decl, _) -> add_class id decl env - | Sig_class_type(id, decl, _) -> add_cltype id decl env +(** semantic version predicate *) +val semver : Location.t -> string -> string -> bool -let rec add_signature sg env = - match sg with - [] -> env - | comp :: rem -> add_signature rem (add_item comp env) +val filter_directive_from_lexbuf : Lexing.lexbuf -> (int * int) list -(* Open a signature path *) +val replace_directive_int : string -> int -> unit +val replace_directive_string : string -> string -> unit +val replace_directive_bool : string -> bool -> unit +val remove_directive_built_in_value : string -> unit -let add_components slot root env0 comps = - let add_l w comps env0 = - TycompTbl.add_open slot w comps env0 - in +(** @return false means failed to define *) +val define_key_value : string -> string -> bool +val list_variables : Format.formatter -> unit - let add w comps env0 = IdTbl.add_open slot w root comps env0 in +end = struct +#1 "lexer.ml" +# 18 "parsing/lexer.mll" + +open Lexing +open Misc +open Parser - let constrs = - add_l (fun x -> `Constructor x) comps.comp_constrs env0.constrs - in - let labels = - add_l (fun x -> `Label x) comps.comp_labels env0.labels - in +type directive_value = + | Dir_bool of bool + | Dir_float of float + | Dir_int of int + | Dir_string of string + | Dir_null - let values = - add (fun x -> `Value x) comps.comp_values env0.values - in - let types = - add (fun x -> `Type x) comps.comp_types env0.types - in - let modtypes = - add (fun x -> `Module_type x) comps.comp_modtypes env0.modtypes - in - let classes = - add (fun x -> `Class x) comps.comp_classes env0.classes - in - let cltypes = - add (fun x -> `Class_type x) comps.comp_cltypes env0.cltypes - in - let components = - add (fun x -> `Component x) comps.comp_components env0.components - in +type directive_type = + | Dir_type_bool + | Dir_type_float + | Dir_type_int + | Dir_type_string + | Dir_type_null - let modules = - add (fun x -> `Module x) comps.comp_modules env0.modules - in +let type_of_directive x = + match x with + | Dir_bool _ -> Dir_type_bool + | Dir_float _ -> Dir_type_float + | Dir_int _ -> Dir_type_int + | Dir_string _ -> Dir_type_string + | Dir_null -> Dir_type_null - { env0 with - summary = Env_open(env0.summary, root); - constrs; - labels; - values; - types; - modtypes; - classes; - cltypes; - components; - modules; - } +let string_of_type_directive x = + match x with + | Dir_type_bool -> "bool" + | Dir_type_float -> "float" + | Dir_type_int -> "int" + | Dir_type_string -> "string" + | Dir_type_null -> "null" -let open_signature slot root env0 = - match get_components (find_module_descr root env0) with - | Functor_comps _ -> None - | Structure_comps comps -> Some (add_components slot root env0 comps) +type error = + | Illegal_character of char + | Illegal_escape of string + | Unterminated_comment of Location.t + | Unterminated_string + | Unterminated_string_in_comment of Location.t * Location.t + | Keyword_as_label of string + | Invalid_literal of string + | Invalid_directive of string * string option + | Unterminated_paren_in_conditional + | Unterminated_if + | Unterminated_else + | Unexpected_token_in_conditional + | Expect_hash_then_in_conditional + | Illegal_semver of string + | Unexpected_directive + | Conditional_expr_expected_type of directive_type * directive_type + +;; +exception Error of error * Location.t;; -(* Open a signature from a file *) +let assert_same_type lexbuf x y = + let lhs = type_of_directive x in let rhs = type_of_directive y in + if lhs <> rhs then + raise (Error(Conditional_expr_expected_type(lhs,rhs), Location.curr lexbuf)) + else y -let open_pers_signature name env = - match open_signature None (Pident(Ident.create_persistent name)) env with - | Some env -> env - | None -> assert false (* a compilation unit cannot refer to a functor *) +let directive_built_in_values = + Hashtbl.create 51 -let open_signature - ?(used_slot = ref false) - ?(loc = Location.none) ?(toplevel = false) ovf root env = - if not toplevel && ovf = Asttypes.Fresh && not loc.Location.loc_ghost - && (Warnings.is_active (Warnings.Unused_open "") - || Warnings.is_active (Warnings.Open_shadow_identifier ("", "")) - || Warnings.is_active (Warnings.Open_shadow_label_constructor ("",""))) - then begin - let used = used_slot in - !add_delayed_check_forward - (fun () -> - if not !used then begin - used := true; - Location.prerr_warning loc (Warnings.Unused_open (Path.name root)) - end - ); - let shadowed = ref [] in - let slot s b = - begin match check_shadowing env b with - | Some kind when not (List.mem (kind, s) !shadowed) -> - shadowed := (kind, s) :: !shadowed; - let w = - match kind with - | "label" | "constructor" -> - Warnings.Open_shadow_label_constructor (kind, s) - | _ -> Warnings.Open_shadow_identifier (kind, s) - in - Location.prerr_warning loc w - | _ -> () - end; - used := true - in - open_signature (Some slot) root env - end - else open_signature None root env -(* Read a signature from a file *) +let replace_directive_built_in_value k v = + Hashtbl.replace directive_built_in_values k v -let read_signature modname filename = - let ps = read_pers_struct modname filename in - Lazy.force ps.ps_sig +let remove_directive_built_in_value k = + Hashtbl.replace directive_built_in_values k Dir_null -(* Return the CRC of the interface of the given compilation unit *) +let replace_directive_int k v = + Hashtbl.replace directive_built_in_values k (Dir_int v) -let crc_of_unit name = - let ps = find_pers_struct name in - let crco = - try - List.assoc name ps.ps_crcs - with Not_found -> - assert false - in - match crco with - None -> assert false - | Some crc -> crc +let replace_directive_bool k v = + Hashtbl.replace directive_built_in_values k (Dir_bool v) -(* Return the list of imported interfaces with their CRCs *) +let replace_directive_string k v = + Hashtbl.replace directive_built_in_values k (Dir_string v) -let imports () = - - let dont_record_crc_unit = !Clflags.dont_record_crc_unit in - match dont_record_crc_unit with - | None -> Consistbl.extract (StringSet.elements !imported_units) crc_units - | Some x -> - Consistbl.extract - (StringSet.fold - (fun m acc -> if m = x then acc else m::acc) - !imported_units []) crc_units +let () = + (* Note we use {!Config} instead of {!Sys} becasue + we want to overwrite in some cases with the + same stdlib + *) + let version = + Config.version (* so that it can be overridden*) + in + replace_directive_built_in_value "OCAML_VERSION" + (Dir_string version); + replace_directive_built_in_value "OCAML_PATCH" + (Dir_string + (match String.rindex version '+' with + | exception Not_found -> "" + | i -> + String.sub version (i + 1) + (String.length version - i - 1))) + ; + replace_directive_built_in_value "OS_TYPE" + (Dir_string Sys.os_type); + replace_directive_built_in_value "BIG_ENDIAN" + (Dir_bool Sys.big_endian); + replace_directive_built_in_value "WORD_SIZE" + (Dir_int Sys.word_size) -(* Returns true if [s] is an opaque imported module *) -let is_imported_opaque s = - StringSet.mem s !imported_opaque_units +let find_directive_built_in_value k = + Hashtbl.find directive_built_in_values k -(* Save a signature to a file *) +let iter_directive_built_in_value f = Hashtbl.iter f directive_built_in_values -let save_signature_with_imports ?check_exists ~deprecated sg modname filename imports = - (*prerr_endline filename; - List.iter (fun (name, crc) -> prerr_endline name) imports;*) - Btype.cleanup_abbrev (); - Subst.reset_for_saving (); - let sg = Subst.signature (Subst.for_saving Subst.identity) sg in - let flags = - List.concat [ - if !Clflags.recursive_types then [Cmi_format.Rectypes] else []; - if !Clflags.opaque then [Cmi_format.Opaque] else []; - (if !Clflags.unsafe_string then [Cmi_format.Unsafe_string] else []); - (match deprecated with Some s -> [Deprecated s] | None -> []); - ] +(* + {[ + # semver 0 "12";; + - : int * int * int * string = (12, 0, 0, "");; + # semver 0 "12.3";; + - : int * int * int * string = (12, 3, 0, "");; + semver 0 "12.3.10";; + - : int * int * int * string = (12, 3, 10, "");; + # semver 0 "12.3.10+x";; + - : int * int * int * string = (12, 3, 10, "+x") + ]} +*) +let zero = Char.code '0' +let dot = Char.code '.' +let semantic_version_parse str start last_index = + let rec aux start acc last_index = + if start <= last_index then + let c = Char.code (String.unsafe_get str start) in + if c = dot then (acc, start + 1) (* consume [4.] instead of [4]*) + else + let v = c - zero in + if v >=0 && v <= 9 then + aux (start + 1) (acc * 10 + v) last_index + else (acc , start) + else (acc, start) in - try - let cmi = { - cmi_name = modname; - cmi_sign = sg; - cmi_crcs = imports; - cmi_flags = flags; - } in - let crc = - - create_cmi ?check_exists filename cmi in + let major, major_end = aux start 0 last_index in + let minor, minor_end = aux major_end 0 last_index in + let patch, patch_end = aux minor_end 0 last_index in + let additional = String.sub str patch_end (last_index - patch_end +1) in + (major, minor, patch), additional - (* Enter signature in persistent table so that imported_unit() - will also return its crc *) - let comps = - components_of_module ~deprecated ~loc:Location.none - empty Subst.identity - (Pident(Ident.create_persistent modname)) (Mty_signature sg) in - let ps = - { ps_name = modname; - ps_sig = lazy (Subst.signature Subst.identity sg); - ps_comps = comps; - ps_crcs = (cmi.cmi_name, Some crc) :: imports; - ps_filename = filename; - ps_flags = cmi.cmi_flags; - } in - save_pers_struct crc ps; - cmi - with exn -> - remove_file filename; - raise exn +(** + {[ + semver Location.none "1.2.3" "~1.3.0" = false;; + semver Location.none "1.2.3" "^1.3.0" = true ;; + semver Location.none "1.2.3" ">1.3.0" = false ;; + semver Location.none "1.2.3" ">=1.3.0" = false ;; + semver Location.none "1.2.3" "<1.3.0" = true ;; + semver Location.none "1.2.3" "<=1.3.0" = true ;; + ]} +*) +let semver loc lhs str = + let last_index = String.length str - 1 in + if last_index < 0 then raise (Error(Illegal_semver str, loc)) + else + let pred, ((major, minor, _patch) as version, _) = + let v = String.unsafe_get str 0 in + match v with + | '>' -> + if last_index = 0 then raise (Error(Illegal_semver str, loc)) else + if String.unsafe_get str 1 = '=' then + `Ge, semantic_version_parse str 2 last_index + else `Gt, semantic_version_parse str 1 last_index + | '<' + -> + if last_index = 0 then raise (Error(Illegal_semver str, loc)) else + if String.unsafe_get str 1 = '=' then + `Le, semantic_version_parse str 2 last_index + else `Lt, semantic_version_parse str 1 last_index + | '^' + -> `Compatible, semantic_version_parse str 1 last_index + | '~' -> `Approximate, semantic_version_parse str 1 last_index + | _ -> `Exact, semantic_version_parse str 0 last_index + in + let ((l_major, l_minor, _l_patch) as lversion,_) = + semantic_version_parse lhs 0 (String.length lhs - 1) in + match pred with + | `Ge -> lversion >= version + | `Gt -> lversion > version + | `Le -> lversion <= version + | `Lt -> lversion < version + | `Approximate -> major = l_major && minor = l_minor + | `Compatible -> major = l_major + | `Exact -> lversion = version -let save_signature ?check_exists ~deprecated sg modname filename = - save_signature_with_imports ?check_exists ~deprecated sg modname filename (imports()) -(* Folding on environments *) +let pp_directive_value fmt (x : directive_value) = + match x with + | Dir_bool b -> Format.pp_print_bool fmt b + | Dir_int b -> Format.pp_print_int fmt b + | Dir_float b -> Format.pp_print_float fmt b + | Dir_string s -> Format.fprintf fmt "%S" s + | Dir_null -> Format.pp_print_string fmt "null" -let find_all proj1 proj2 f lid env acc = - match lid with - | None -> - IdTbl.fold_name - (fun name (p, data) acc -> f name p data acc) - (proj1 env) acc - | Some l -> - let p, desc = lookup_module_descr l env in - begin match get_components desc with - Structure_comps c -> - Tbl.fold - (fun s (data, pos) acc -> f s (Pdot (p, s, pos)) data acc) - (proj2 c) acc - | Functor_comps _ -> - acc - end +let list_variables fmt = + iter_directive_built_in_value + (fun s dir_value -> + Format.fprintf + fmt "@[%s@ %a@]@." + s pp_directive_value dir_value + ) -let find_all_simple_list proj1 proj2 f lid env acc = - match lid with - | None -> - TycompTbl.fold_name - (fun data acc -> f data acc) - (proj1 env) acc - | Some l -> - let (_p, desc) = lookup_module_descr l env in - begin match get_components desc with - Structure_comps c -> - Tbl.fold - (fun _s comps acc -> - match comps with - [] -> acc - | data :: _ -> - f data acc) - (proj2 c) acc - | Functor_comps _ -> - acc - end +let defined str = + begin match find_directive_built_in_value str with + | Dir_null -> false + | _ -> true + | exception _ -> + try ignore @@ Sys.getenv str; true with _ -> false + end -let fold_modules f lid env acc = - match lid with - | None -> - let acc = - IdTbl.fold_name - (fun name (p, data) acc -> - let data = EnvLazy.force subst_modtype_maker data in - f name p data acc - ) - env.modules - acc - in - Hashtbl.fold - (fun name ps acc -> - match ps with - None -> acc - | Some ps -> - f name (Pident(Ident.create_persistent name)) - (md (Mty_signature (Lazy.force ps.ps_sig))) acc) - persistent_structures - acc - | Some l -> - let p, desc = lookup_module_descr l env in - begin match get_components desc with - Structure_comps c -> - Tbl.fold - (fun s (data, pos) acc -> - f s (Pdot (p, s, pos)) - (EnvLazy.force subst_modtype_maker data) acc) - c.comp_modules - acc - | Functor_comps _ -> - acc +let query _loc str = + begin match find_directive_built_in_value str with + | Dir_null -> Dir_bool false + | v -> v + | exception Not_found -> + begin match Sys.getenv str with + | v -> + begin + try Dir_bool (bool_of_string v) with + _ -> + begin + try Dir_int (int_of_string v ) + with + _ -> + begin try (Dir_float (float_of_string v)) + with _ -> Dir_string v + end + end + end + | exception Not_found -> + Dir_bool false end - -let fold_values f = - find_all (fun env -> env.values) (fun sc -> sc.comp_values) f -and fold_constructors f = - find_all_simple_list (fun env -> env.constrs) (fun sc -> sc.comp_constrs) f -and fold_labels f = - find_all_simple_list (fun env -> env.labels) (fun sc -> sc.comp_labels) f -and fold_types f = - find_all (fun env -> env.types) (fun sc -> sc.comp_types) f -and fold_modtypes f = - find_all (fun env -> env.modtypes) (fun sc -> sc.comp_modtypes) f -and fold_classs f = - find_all (fun env -> env.classes) (fun sc -> sc.comp_classes) f -and fold_cltypes f = - find_all (fun env -> env.cltypes) (fun sc -> sc.comp_cltypes) f + end -(* Make the initial environment *) -let (initial_safe_string, initial_unsafe_string) = - Predef.build_initial_env - (add_type ~check:false) - (add_extension ~check:false) - empty +let define_key_value key v = + if String.length key > 0 + && Char.uppercase_ascii (key.[0]) = key.[0] then + begin + replace_directive_built_in_value key + begin + (* NEED Sync up across {!lexer.mll} {!bspp.ml} and here, + TODO: put it in {!lexer.mll} + *) + try Dir_bool (bool_of_string v) with + _ -> + begin + try Dir_int (int_of_string v ) + with + _ -> + begin try (Dir_float (float_of_string v)) + with _ -> Dir_string v + end + end + end; + true + end + else false -(* Return the environment summary *) +let cvt_int_literal s = + - int_of_string ("-" ^ s) + +let value_of_token loc (t : Parser.token) = + match t with + | INT (i,None) -> Dir_int (cvt_int_literal i) + | STRING (s,_) -> Dir_string s + | FLOAT (s,None) -> Dir_float (float_of_string s) + | TRUE -> Dir_bool true + | FALSE -> Dir_bool false + | UIDENT s -> query loc s + | _ -> raise (Error (Unexpected_token_in_conditional, loc)) -let summary env = - if PathMap.is_empty env.local_constraints then env.summary - else Env_constraints (env.summary, env.local_constraints) -let last_env = ref empty -let last_reduced_env = ref empty +let directive_parse token_with_comments lexbuf = + let look_ahead = ref None in + let token () : Parser.token = + let v = !look_ahead in + match v with + | Some v -> + look_ahead := None ; + v + | None -> + let rec skip () = + match token_with_comments lexbuf with + | COMMENT _ + | DOCSTRING _ + | EOL -> skip () + | EOF -> raise (Error (Unterminated_if, Location.curr lexbuf)) + | t -> t + in skip () + in + let push e = + (* INVARIANT: only look at most one token *) + assert (!look_ahead = None); + look_ahead := Some e + in + let rec + token_op calc ~no lhs = + match token () with + | (LESS + | GREATER + | INFIXOP0 "<=" + | INFIXOP0 ">=" + | EQUAL + | INFIXOP0 "<>" as op) -> + let f = + match op with + | LESS -> (<) + | GREATER -> (>) + | INFIXOP0 "<=" -> (<=) + | EQUAL -> (=) + | INFIXOP0 "<>" -> (<>) + | _ -> assert false + in + let curr_loc = Location.curr lexbuf in + let rhs = value_of_token curr_loc (token ()) in + not calc || + f lhs (assert_same_type lexbuf lhs rhs) + | INFIXOP0 "=~" -> + not calc || + begin match lhs with + | Dir_string s -> + let curr_loc = Location.curr lexbuf in + let rhs = value_of_token curr_loc (token ()) in + begin match rhs with + | Dir_string rhs -> + semver curr_loc s rhs + | _ -> + raise + (Error + ( Conditional_expr_expected_type + (Dir_type_string, type_of_directive lhs), Location.curr lexbuf)) + end + | _ -> raise + (Error + ( Conditional_expr_expected_type + (Dir_type_string, type_of_directive lhs), Location.curr lexbuf)) + end + | e -> no e + and + parse_or calc : bool = + parse_or_aux calc (parse_and calc) + and (* a || (b || (c || d))*) + parse_or_aux calc v : bool = + (* let l = v in *) + match token () with + | BARBAR -> + let b = parse_or (calc && not v) in + v || b + | e -> push e ; v + and parse_and calc = + parse_and_aux calc (parse_relation calc) + and parse_and_aux calc v = (* a && (b && (c && d)) *) + (* let l = v in *) + match token () with + | AMPERAMPER -> + let b = parse_and (calc && v) in + v && b + | e -> push e ; v + and parse_relation (calc : bool) : bool = + let curr_token = token () in + let curr_loc = Location.curr lexbuf in + match curr_token with + | TRUE -> true + | FALSE -> false + | UIDENT v -> + let value_v = query curr_loc v in + token_op calc + ~no:(fun e -> push e ; + match value_v with + | Dir_bool b -> b + | _ -> + let ty = type_of_directive value_v in + raise + (Error(Conditional_expr_expected_type (Dir_type_bool, ty), + curr_loc))) + value_v + | INT (v,None) -> + let num_v = cvt_int_literal v in + token_op calc + ~no:(fun e -> + push e; + num_v <> 0 + ) + (Dir_int num_v) + | FLOAT (v,None) -> + token_op calc + ~no:(fun _e -> + raise (Error(Conditional_expr_expected_type(Dir_type_bool, Dir_type_float), + curr_loc))) + (Dir_float (float_of_string v)) + | STRING (v,_) -> + token_op calc + ~no:(fun _e -> + raise (Error + (Conditional_expr_expected_type(Dir_type_bool, Dir_type_string), + curr_loc))) + (Dir_string v) + | LIDENT ("defined" | "undefined" as r) -> + let t = token () in + let loc = Location.curr lexbuf in + begin match t with + | UIDENT s -> + not calc || + if r.[0] = 'u' then + not @@ defined s + else defined s + | _ -> raise (Error (Unexpected_token_in_conditional, loc)) + end + | LPAREN -> + let v = parse_or calc in + begin match token () with + | RPAREN -> v + | _ -> raise (Error(Unterminated_paren_in_conditional, Location.curr lexbuf)) + end -let keep_only_summary env = - if !last_env == env then !last_reduced_env - else begin - let new_env = - { - empty with - summary = env.summary; - local_constraints = env.local_constraints; - flags = env.flags; - } - in - last_env := env; - last_reduced_env := new_env; - new_env + | _ -> raise (Error (Unexpected_token_in_conditional, curr_loc)) + in + let v = parse_or true in + begin match token () with + | THEN -> v + | _ -> raise (Error (Expect_hash_then_in_conditional, Location.curr lexbuf)) end -let env_of_only_summary env_from_summary env = - let new_env = env_from_summary env.summary Subst.identity in - { new_env with - local_constraints = env.local_constraints; - flags = env.flags; - } - -(* Error report *) - -open Format - -let report_error ppf = function - | Illegal_renaming(modname, ps_name, filename) -> fprintf ppf - "Wrong file naming: %a@ contains the compiled interface for @ \ - %s when %s was expected" - Location.print_filename filename ps_name modname - | Inconsistent_import(name, source1, source2) -> fprintf ppf - "@[The files %a@ and %a@ \ - make inconsistent assumptions@ over interface %s@]" - Location.print_filename source1 Location.print_filename source2 name - | Need_recursive_types(import, export) -> - fprintf ppf - "@[Unit %s imports from %s, which uses recursive types.@ %s@]" - export import "The compilation flag -rectypes is required" - | Depend_on_unsafe_string_unit(import, export) -> - fprintf ppf - "@[Unit %s imports from %s, compiled with -unsafe-string.@ %s@]" - export import "This compiler has been configured in strict \ - safe-string mode (-force-safe-string)" - | Missing_module(_, path1, path2) -> - fprintf ppf "@[@["; - if Path.same path1 path2 then - fprintf ppf "Internal path@ %s@ is dangling." (Path.name path1) - else - fprintf ppf "Internal path@ %s@ expands to@ %s@ which is dangling." - (Path.name path1) (Path.name path2); - fprintf ppf "@]@ @[%s@ %s@ %s.@]@]" - "The compiled interface for module" (Ident.name (Path.head path2)) - "was not found" - | Illegal_value_name(_loc, name) -> - fprintf ppf "'%s' is not a valid value identifier." - name - -let () = - Location.register_error_of_exn - (function - | Error (Missing_module (loc, _, _) - | Illegal_value_name (loc, _) - as err) when loc <> Location.none -> - Some (Location.error_of_printer loc report_error err) - | Error err -> Some (Location.error_of_printer_file report_error err) - | _ -> None - ) +type dir_conditional = + | Dir_if_true + | Dir_if_false + | Dir_out -end -(** Interface as module *) -module Annot -= struct -#1 "annot.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Damien Doligez, projet Gallium, INRIA Rocquencourt *) -(* *) -(* Copyright 2007 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +(* let string_of_dir_conditional (x : dir_conditional) = *) +(* match x with *) +(* | Dir_if_true -> "Dir_if_true" *) +(* | Dir_if_false -> "Dir_if_false" *) +(* | Dir_out -> "Dir_out" *) -(* Data types for annotations (Stypes.ml) *) +let is_elif (i : Parser.token ) = + match i with + | LIDENT "elif" -> true + | _ -> false (* avoid polymorphic equal *) -type call = Tail | Stack | Inline;; -type ident = - | Iref_internal of Location.t (* defining occurrence *) - | Iref_external - | Idef of Location.t (* scope *) -;; +(* The table of keywords *) -end -module Typedtree : sig -#1 "typedtree.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let keyword_table = + create_hashtable 149 [ + "and", AND; + "as", AS; + "assert", ASSERT; + "begin", BEGIN; + "class", CLASS; + "constraint", CONSTRAINT; + "do", DO; + "done", DONE; + "downto", DOWNTO; + "else", ELSE; + "end", END; + "exception", EXCEPTION; + "external", EXTERNAL; + "false", FALSE; + "for", FOR; + "fun", FUN; + "function", FUNCTION; + "functor", FUNCTOR; + "if", IF; + "in", IN; + "include", INCLUDE; + "inherit", INHERIT; + "initializer", INITIALIZER; + "lazy", LAZY; + "let", LET; + "match", MATCH; + "method", METHOD; + "module", MODULE; + "mutable", MUTABLE; + "new", NEW; + "nonrec", NONREC; + "object", OBJECT; + "of", OF; + "open", OPEN; + "or", OR; +(* "parser", PARSER; *) + "private", PRIVATE; + "rec", REC; + "sig", SIG; + "struct", STRUCT; + "then", THEN; + "to", TO; + "true", TRUE; + "try", TRY; + "type", TYPE; + "val", VAL; + "virtual", VIRTUAL; + "when", WHEN; + "while", WHILE; + "with", WITH; -(** Abstract syntax tree after typing *) + "lor", INFIXOP3("lor"); (* Should be INFIXOP2 *) + "lxor", INFIXOP3("lxor"); (* Should be INFIXOP2 *) + "mod", INFIXOP3("mod"); + "land", INFIXOP3("land"); + "lsl", INFIXOP4("lsl"); + "lsr", INFIXOP4("lsr"); + "asr", INFIXOP4("asr") +] +(* To buffer string literals *) -(** By comparison with {!Parsetree}: - - Every {!Longindent.t} is accompanied by a resolved {!Path.t}. +let string_buffer = Buffer.create 256 +let reset_string_buffer () = Buffer.reset string_buffer +let get_stored_string () = Buffer.contents string_buffer -*) +let store_string_char c = Buffer.add_char string_buffer c +let store_string_utf_8_uchar u = Buffer.add_utf_8_uchar string_buffer u +let store_string s = Buffer.add_string string_buffer s +let store_lexeme lexbuf = store_string (Lexing.lexeme lexbuf) -open Asttypes -open Types +(* To store the position of the beginning of a string and comment *) +let string_start_loc = ref Location.none;; +let comment_start_loc = ref [];; +let in_comment () = !comment_start_loc <> [];; +let is_in_string = ref false +let in_string () = !is_in_string +let print_warnings = ref true +let if_then_else = ref Dir_out +let sharp_look_ahead = ref None +let update_if_then_else v = + (* Format.fprintf Format.err_formatter "@[update %s \n@]@." (string_of_dir_conditional v); *) + if_then_else := v -(* Value expressions for the core language *) +(* Escaped chars are interpreted in strings unless they are in comments. *) +let store_escaped_char lexbuf c = + if in_comment () then store_lexeme lexbuf else store_string_char c -type partial = Partial | Total +let store_escaped_uchar lexbuf u = + if in_comment () then store_lexeme lexbuf else store_string_utf_8_uchar u -(** {1 Extension points} *) +let with_comment_buffer comment lexbuf = + let start_loc = Location.curr lexbuf in + comment_start_loc := [start_loc]; + reset_string_buffer (); + let end_loc = comment lexbuf in + let s = get_stored_string () in + reset_string_buffer (); + let loc = { start_loc with Location.loc_end = end_loc.Location.loc_end } in + s, loc -type attribute = Parsetree.attribute -type attributes = attribute list +(* To translate escape sequences *) -(** {1 Core language} *) +let hex_digit_value d = (* assert (d in '0'..'9' 'a'..'f' 'A'..'F') *) + let d = Char.code d in + if d >= 97 then d - 87 else + if d >= 65 then d - 55 else + d - 48 -type pattern = - { pat_desc: pattern_desc; - pat_loc: Location.t; - pat_extra : (pat_extra * Location.t * attributes) list; - pat_type: type_expr; - mutable pat_env: Env.t; - pat_attributes: attributes; - } +let hex_num_value lexbuf ~first ~last = + let rec loop acc i = match i > last with + | true -> acc + | false -> + let value = hex_digit_value (Lexing.lexeme_char lexbuf i) in + loop (16 * acc + value) (i + 1) + in + loop 0 first -and pat_extra = - | Tpat_constraint of core_type - (** P : T { pat_desc = P - ; pat_extra = (Tpat_constraint T, _, _) :: ... } - *) - | Tpat_type of Path.t * Longident.t loc - (** #tconst { pat_desc = disjunction - ; pat_extra = (Tpat_type (P, "tconst"), _, _) :: ...} +let char_for_backslash = function + | 'n' -> '\010' + | 'r' -> '\013' + | 'b' -> '\008' + | 't' -> '\009' + | c -> c - where [disjunction] is a [Tpat_or _] representing the - branches of [tconst]. - *) - | Tpat_open of Path.t * Longident.t loc * Env.t - | Tpat_unpack - (** (module P) { pat_desc = Tpat_var "P" - ; pat_extra = (Tpat_unpack, _, _) :: ... } - *) +let char_for_decimal_code lexbuf i = + let c = 100 * (Char.code(Lexing.lexeme_char lexbuf i) - 48) + + 10 * (Char.code(Lexing.lexeme_char lexbuf (i+1)) - 48) + + (Char.code(Lexing.lexeme_char lexbuf (i+2)) - 48) in + if (c < 0 || c > 255) then + if in_comment () + then 'x' + else raise (Error(Illegal_escape (Lexing.lexeme lexbuf), + Location.curr lexbuf)) + else Char.chr c -and pattern_desc = - Tpat_any - (** _ *) - | Tpat_var of Ident.t * string loc - (** x *) - | Tpat_alias of pattern * Ident.t * string loc - (** P as a *) - | Tpat_constant of constant - (** 1, 'a', "true", 1.0, 1l, 1L, 1n *) - | Tpat_tuple of pattern list - (** (P1, ..., Pn) +let char_for_octal_code lexbuf i = + let c = 64 * (Char.code(Lexing.lexeme_char lexbuf i) - 48) + + 8 * (Char.code(Lexing.lexeme_char lexbuf (i+1)) - 48) + + (Char.code(Lexing.lexeme_char lexbuf (i+2)) - 48) in + Char.chr c - Invariant: n >= 2 - *) - | Tpat_construct of - Longident.t loc * constructor_description * pattern list - (** C [] - C P [P] - C (P1, ..., Pn) [P1; ...; Pn] - *) - | Tpat_variant of label * pattern option * row_desc ref - (** `A (None) - `A P (Some P) +let char_for_hexadecimal_code lexbuf i = + let byte = hex_num_value lexbuf ~first:i ~last:(i+1) in + Char.chr byte - See {!Types.row_desc} for an explanation of the last parameter. - *) - | Tpat_record of - (Longident.t loc * label_description * pattern) list * - closed_flag - (** { l1=P1; ...; ln=Pn } (flag = Closed) - { l1=P1; ...; ln=Pn; _} (flag = Open) +let uchar_for_uchar_escape lexbuf = + let err e = + raise + (Error (Illegal_escape (Lexing.lexeme lexbuf ^ e), Location.curr lexbuf)) + in + let len = Lexing.lexeme_end lexbuf - Lexing.lexeme_start lexbuf in + let first = 3 (* skip opening \u{ *) in + let last = len - 2 (* skip closing } *) in + let digit_count = last - first + 1 in + match digit_count > 6 with + | true -> err ", too many digits, expected 1 to 6 hexadecimal digits" + | false -> + let cp = hex_num_value lexbuf ~first ~last in + if Uchar.is_valid cp then Uchar.unsafe_of_int cp else + err (", " ^ Printf.sprintf "%X" cp ^ " is not a Unicode scalar value") - Invariant: n > 0 - *) - | Tpat_array of pattern list - (** [| P1; ...; Pn |] *) - | Tpat_or of pattern * pattern * row_desc option - (** P1 | P2 +(* recover the name from a LABEL or OPTLABEL token *) - [row_desc] = [Some _] when translating [Ppat_type _], - [None] otherwise. - *) - | Tpat_lazy of pattern - (** lazy P *) +let get_label_name lexbuf = + let s = Lexing.lexeme lexbuf in + let name = String.sub s 1 (String.length s - 2) in + if Hashtbl.mem keyword_table name then + raise (Error(Keyword_as_label name, Location.curr lexbuf)); + name +;; -and expression = - { exp_desc: expression_desc; - exp_loc: Location.t; - exp_extra: (exp_extra * Location.t * attributes) list; - exp_type: type_expr; - exp_env: Env.t; - exp_attributes: attributes; - } +(* Update the current location with file name and line number. *) -and exp_extra = - | Texp_constraint of core_type - (** E : T *) - | Texp_coerce of core_type option * core_type - (** E :> T [Texp_coerce (None, T)] - E : T0 :> T [Texp_coerce (Some T0, T)] - *) - | Texp_open of override_flag * Path.t * Longident.t loc * Env.t - (** let open[!] M in [Texp_open (!, P, M, env)] - where [env] is the environment after opening [P] - *) - | Texp_poly of core_type option - (** Used for method bodies. *) - | Texp_newtype of string - (** fun (type t) -> *) +let update_loc lexbuf file line absolute chars = + let pos = lexbuf.lex_curr_p in + let new_file = match file with + | None -> pos.pos_fname + | Some s -> s + in + lexbuf.lex_curr_p <- { pos with + pos_fname = new_file; + pos_lnum = if absolute then line else pos.pos_lnum + line; + pos_bol = pos.pos_cnum - chars; + } +;; -and expression_desc = - Texp_ident of Path.t * Longident.t loc * Types.value_description - (** x - M.x - *) - | Texp_constant of constant - (** 1, 'a', "true", 1.0, 1l, 1L, 1n *) - | Texp_let of rec_flag * value_binding list * expression - (** let P1 = E1 and ... and Pn = EN in E (flag = Nonrecursive) - let rec P1 = E1 and ... and Pn = EN in E (flag = Recursive) - *) - | Texp_function of { arg_label : arg_label; param : Ident.t; - cases : case list; partial : partial; } - (** [Pexp_fun] and [Pexp_function] both translate to [Texp_function]. - See {!Parsetree} for more details. +let preprocessor = ref None - [param] is the identifier that is to be used to name the - parameter of the function. +let escaped_newlines = ref false - partial = - [Partial] if the pattern match is partial - [Total] otherwise. - *) - | Texp_apply of expression * (arg_label * expression option) list - (** E0 ~l1:E1 ... ~ln:En +(* Warn about Latin-1 characters used in idents *) - The expression can be None if the expression is abstracted over - this argument. It currently appears when a label is applied. +let warn_latin1 lexbuf = + Location.deprecated (Location.curr lexbuf)"ISO-Latin1 characters in identifiers" - For example: - let f x ~y = x + y in - f ~y:3 +let handle_docstrings = ref true +let comment_list = ref [] - The resulting typedtree for the application is: - Texp_apply (Texp_ident "f/1037", - [(Nolabel, None); - (Labelled "y", Some (Texp_constant Const_int 3)) - ]) - *) - | Texp_match of expression * case list * case list * partial - (** match E0 with - | P1 -> E1 - | P2 -> E2 - | exception P3 -> E3 +let add_comment com = + comment_list := com :: !comment_list - [Texp_match (E0, [(P1, E1); (P2, E2)], [(P3, E3)], _)] - *) - | Texp_try of expression * case list - (** try E with P1 -> E1 | ... | PN -> EN *) - | Texp_tuple of expression list - (** (E1, ..., EN) *) - | Texp_construct of - Longident.t loc * constructor_description * expression list - (** C [] - C E [E] - C (E1, ..., En) [E1;...;En] - *) - | Texp_variant of label * expression option - | Texp_record of { - fields : ( Types.label_description * record_label_definition ) array; - representation : Types.record_representation; - extended_expression : expression option; - } - (** { l1=P1; ...; ln=Pn } (extended_expression = None) - { E0 with l1=P1; ...; ln=Pn } (extended_expression = Some E0) +let add_docstring_comment ds = + let com = + ("*" ^ Docstrings.docstring_body ds, Docstrings.docstring_loc ds) + in + add_comment com - Invariant: n > 0 +let comments () = List.rev !comment_list - If the type is { l1: t1; l2: t2 }, the expression - { E0 with t2=P2 } is represented as - Texp_record - { fields = [| l1, Kept t1; l2 Override P2 |]; representation; - extended_expression = Some E0 } - *) - | Texp_field of expression * Longident.t loc * label_description - | Texp_setfield of - expression * Longident.t loc * label_description * expression - | Texp_array of expression list - | Texp_ifthenelse of expression * expression * expression option - | Texp_sequence of expression * expression - | Texp_while of expression * expression - | Texp_for of - Ident.t * Parsetree.pattern * expression * expression * direction_flag * - expression - | Texp_send of expression * meth * expression option - | Texp_new of Path.t * Longident.t loc * Types.class_declaration - | Texp_instvar of Path.t * Path.t * string loc - | Texp_setinstvar of Path.t * Path.t * string loc * expression - | Texp_override of Path.t * (Path.t * string loc * expression) list - | Texp_letmodule of Ident.t * string loc * module_expr * expression - | Texp_letexception of extension_constructor * expression - | Texp_assert of expression - | Texp_lazy of expression - | Texp_object of class_structure * string list - | Texp_pack of module_expr - | Texp_unreachable - | Texp_extension_constructor of Longident.t loc * Path.t +(* Error report *) -and meth = - Tmeth_name of string - | Tmeth_val of Ident.t +open Format -and case = - { - c_lhs: pattern; - c_guard: expression option; - c_rhs: expression; - } +let report_error ppf = function + | Illegal_character c -> + fprintf ppf "Illegal character (%s)" (Char.escaped c) + | Illegal_escape s -> + fprintf ppf "Illegal backslash escape in string or character (%s)" s + | Unterminated_comment _ -> + fprintf ppf "Comment not terminated" + | Unterminated_string -> + fprintf ppf "String literal not terminated" + | Unterminated_string_in_comment (_, loc) -> + fprintf ppf "This comment contains an unterminated string literal@.\ + %aString literal begins here" + Location.print_error loc + | Keyword_as_label kwd -> + fprintf ppf "`%s' is a keyword, it cannot be used as label name" kwd + | Invalid_literal s -> + fprintf ppf "Invalid literal %s" s + | Invalid_directive (dir, explanation) -> + fprintf ppf "Invalid lexer directive %S" dir; + begin match explanation with + | None -> () + | Some expl -> fprintf ppf ": %s" expl + end + | Unterminated_if -> + fprintf ppf "#if not terminated" + | Unterminated_else -> + fprintf ppf "#else not terminated" + | Unexpected_directive -> fprintf ppf "Unexpected directive" + | Unexpected_token_in_conditional -> + fprintf ppf "Unexpected token in conditional predicate" + | Unterminated_paren_in_conditional -> + fprintf ppf "Unterminated parens in conditional predicate" + | Expect_hash_then_in_conditional -> + fprintf ppf "Expect `then` after conditional predicate" + | Conditional_expr_expected_type (a,b) -> + fprintf ppf "Conditional expression type mismatch (%s,%s)" + (string_of_type_directive a ) + (string_of_type_directive b ) + | Illegal_semver s -> + fprintf ppf "Illegal semantic version string %s" s -and record_label_definition = - | Kept of Types.type_expr - | Overridden of Longident.t loc * expression +let () = + Location.register_error_of_exn + (function + | Error (err, loc) -> + Some (Location.error_of_printer loc report_error err) + | _ -> + None + ) + + +# 717 "parsing/lexer.ml" +let __ocaml_lex_tables = { + Lexing.lex_base = + "\000\000\162\255\163\255\224\000\003\001\038\001\073\001\108\001\ + \143\001\186\255\178\001\215\001\194\255\091\000\252\001\031\002\ + \068\000\071\000\065\002\100\002\212\255\214\255\217\255\135\002\ + \230\002\009\003\088\000\255\000\039\003\236\255\123\003\207\003\ + \035\004\243\004\195\005\147\006\114\007\206\007\158\008\122\000\ + \254\255\001\000\005\000\255\255\006\000\007\000\125\009\155\009\ + \107\010\250\255\249\255\059\011\011\012\247\255\246\255\219\012\ + \047\013\131\013\215\013\043\014\127\014\211\014\039\015\123\015\ + \207\015\035\016\087\000\119\016\203\016\031\017\115\017\199\017\ + \108\000\192\255\235\255\007\003\034\018\106\000\107\000\011\000\ + \234\255\233\255\228\255\152\002\099\000\118\000\113\000\232\255\ + \128\000\147\000\231\255\224\000\003\001\148\000\230\255\110\004\ + \149\000\229\255\148\000\224\255\217\000\223\255\222\000\034\018\ + \222\255\073\018\101\005\009\003\221\255\012\000\014\001\080\001\ + \115\001\024\001\221\255\013\000\119\018\158\018\193\018\231\018\ + \010\019\209\255\204\255\205\255\206\255\202\255\045\019\154\000\ + \183\000\195\255\196\255\197\255\217\000\182\255\180\255\189\255\ + \080\019\185\255\187\255\115\019\150\019\185\019\220\019\130\005\ + \243\255\244\255\017\000\245\255\174\001\223\005\253\255\248\000\ + \249\000\255\255\254\255\252\255\005\006\238\019\003\001\004\001\ + \018\000\251\255\250\255\249\255\222\006\026\003\005\001\248\255\ + \036\003\008\001\247\255\066\008\020\001\246\255\059\001\234\001\ + \245\255\246\255\247\255\060\001\055\020\255\255\248\255\193\000\ + \233\008\038\001\133\004\253\255\073\001\094\001\113\001\143\004\ + \252\255\192\002\027\004\251\255\230\009\250\255\182\010\089\020\ + \249\255\129\001\130\001\252\255\085\007\254\255\255\255\146\001\ + \147\001\253\255\177\007\033\001\044\001\148\001\151\001\045\001\ + \153\001\044\001\019\000\255\255"; + Lexing.lex_backtrk = + "\255\255\255\255\255\255\090\000\089\000\086\000\085\000\078\000\ + \076\000\255\255\067\000\064\000\255\255\057\000\056\000\054\000\ + \052\000\048\000\045\000\081\000\255\255\255\255\255\255\036\000\ + \035\000\042\000\040\000\039\000\062\000\255\255\014\000\014\000\ + \013\000\012\000\011\000\010\000\007\000\004\000\003\000\002\000\ + \255\255\093\000\093\000\255\255\255\255\255\255\084\000\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\018\000\ + \018\000\016\000\015\000\018\000\015\000\015\000\014\000\016\000\ + \015\000\016\000\255\255\017\000\017\000\014\000\014\000\016\000\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\027\000\027\000\027\000\027\000\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\028\000\255\255\029\000\255\255\030\000\088\000\ + \255\255\091\000\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\037\000\087\000\082\000\044\000\ + \047\000\255\255\255\255\255\255\255\255\255\255\055\000\074\000\ + \071\000\255\255\255\255\255\255\072\000\255\255\255\255\255\255\ + \065\000\255\255\255\255\083\000\077\000\080\000\079\000\255\255\ + \255\255\255\255\012\000\255\255\012\000\012\000\255\255\012\000\ + \012\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\010\000\010\000\255\255\255\255\007\000\ + \007\000\007\000\007\000\255\255\001\000\007\000\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\003\000\255\255\255\255\003\000\ + \255\255\255\255\255\255\002\000\255\255\255\255\001\000\255\255\ + \255\255\255\255\255\255\255\255"; + Lexing.lex_default = + "\001\000\000\000\000\000\255\255\255\255\255\255\255\255\255\255\ + \255\255\000\000\255\255\255\255\000\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\000\000\000\000\000\000\255\255\ + \255\255\255\255\255\255\077\000\255\255\000\000\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \000\000\255\255\255\255\000\000\255\255\255\255\255\255\255\255\ + \255\255\000\000\000\000\255\255\255\255\000\000\000\000\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\000\000\000\000\255\255\082\000\255\255\255\255\255\255\ + \000\000\000\000\000\000\255\255\255\255\255\255\255\255\000\000\ + \255\255\255\255\000\000\255\255\255\255\255\255\000\000\255\255\ + \255\255\000\000\255\255\000\000\255\255\000\000\255\255\255\255\ + \000\000\255\255\110\000\255\255\000\000\255\255\110\000\111\000\ + \110\000\113\000\000\000\255\255\255\255\255\255\255\255\255\255\ + \255\255\000\000\000\000\000\000\000\000\000\000\255\255\255\255\ + \255\255\000\000\000\000\000\000\255\255\000\000\000\000\000\000\ + \255\255\000\000\000\000\255\255\255\255\255\255\255\255\144\000\ + \000\000\000\000\255\255\000\000\158\000\255\255\000\000\255\255\ + \255\255\000\000\000\000\000\000\255\255\255\255\255\255\255\255\ + \255\255\000\000\000\000\000\000\255\255\255\255\255\255\000\000\ + \255\255\255\255\000\000\255\255\255\255\000\000\255\255\176\000\ + \000\000\000\000\000\000\255\255\182\000\000\000\000\000\255\255\ + \255\255\255\255\255\255\000\000\255\255\255\255\255\255\255\255\ + \000\000\255\255\255\255\000\000\255\255\000\000\255\255\255\255\ + \000\000\255\255\203\000\000\000\255\255\000\000\000\000\255\255\ + \255\255\000\000\255\255\255\255\255\255\213\000\216\000\255\255\ + \216\000\255\255\255\255\000\000"; + Lexing.lex_trans = + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\039\000\040\000\040\000\039\000\041\000\045\000\043\000\ + \043\000\040\000\044\000\044\000\045\000\078\000\108\000\114\000\ + \079\000\109\000\115\000\145\000\159\000\219\000\174\000\160\000\ + \039\000\008\000\029\000\024\000\006\000\004\000\023\000\027\000\ + \026\000\021\000\025\000\007\000\020\000\019\000\018\000\003\000\ + \031\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ + \030\000\030\000\017\000\016\000\015\000\014\000\010\000\036\000\ + \005\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\013\000\042\000\012\000\005\000\038\000\ + \022\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\028\000\011\000\009\000\037\000\125\000\ + \127\000\124\000\098\000\039\000\123\000\122\000\039\000\065\000\ + \065\000\065\000\065\000\065\000\065\000\065\000\065\000\065\000\ + \065\000\081\000\080\000\091\000\091\000\091\000\091\000\130\000\ + \087\000\129\000\039\000\128\000\071\000\071\000\071\000\071\000\ + \071\000\071\000\071\000\071\000\071\000\071\000\088\000\088\000\ + \088\000\088\000\088\000\088\000\088\000\088\000\088\000\088\000\ + \089\000\089\000\089\000\089\000\089\000\089\000\089\000\089\000\ + \089\000\089\000\090\000\094\000\097\000\099\000\100\000\134\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\131\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\132\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \002\000\003\000\101\000\102\000\003\000\003\000\003\000\101\000\ + \102\000\078\000\003\000\003\000\079\000\003\000\003\000\003\000\ + \092\000\092\000\092\000\092\000\092\000\092\000\092\000\092\000\ + \108\000\133\000\003\000\109\000\003\000\003\000\003\000\003\000\ + \003\000\154\000\114\000\153\000\003\000\115\000\255\255\003\000\ + \003\000\003\000\163\000\162\000\167\000\003\000\003\000\170\000\ + \003\000\003\000\003\000\093\000\093\000\093\000\093\000\093\000\ + \093\000\093\000\093\000\173\000\198\000\003\000\003\000\003\000\ + \003\000\003\000\003\000\003\000\212\000\145\000\178\000\005\000\ + \174\000\201\000\005\000\005\000\005\000\213\000\217\000\218\000\ + \005\000\005\000\188\000\005\000\005\000\005\000\193\000\193\000\ + \193\000\193\000\108\000\076\000\003\000\109\000\003\000\000\000\ + \005\000\003\000\005\000\005\000\005\000\005\000\005\000\000\000\ + \188\000\188\000\006\000\190\000\000\000\006\000\006\000\006\000\ + \000\000\000\000\113\000\006\000\006\000\000\000\006\000\006\000\ + \006\000\000\000\000\000\188\000\112\000\108\000\190\000\003\000\ + \109\000\003\000\000\000\006\000\005\000\006\000\006\000\006\000\ + \006\000\006\000\000\000\178\000\206\000\117\000\201\000\207\000\ + \117\000\117\000\117\000\112\000\000\000\111\000\117\000\117\000\ + \000\000\117\000\142\000\117\000\206\000\206\000\214\000\208\000\ + \208\000\215\000\005\000\215\000\005\000\000\000\117\000\006\000\ + \117\000\141\000\117\000\117\000\117\000\000\000\000\000\000\000\ + \139\000\000\000\000\000\139\000\139\000\139\000\000\000\000\000\ + \159\000\139\000\139\000\160\000\139\000\139\000\139\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\006\000\000\000\006\000\ + \000\000\139\000\117\000\139\000\140\000\139\000\139\000\139\000\ + \000\000\000\000\000\000\006\000\000\000\161\000\006\000\006\000\ + \006\000\000\000\000\000\000\000\006\000\006\000\000\000\006\000\ + \006\000\006\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \117\000\000\000\117\000\000\000\006\000\139\000\006\000\006\000\ + \006\000\006\000\006\000\000\000\178\000\000\000\000\000\179\000\ + \006\000\000\000\000\000\006\000\006\000\006\000\204\000\255\255\ + \000\000\006\000\006\000\000\000\006\000\006\000\006\000\000\000\ + \000\000\000\000\157\000\139\000\181\000\139\000\255\255\138\000\ + \006\000\006\000\000\000\006\000\006\000\006\000\006\000\006\000\ + \255\255\000\000\000\000\000\000\000\000\006\000\000\000\000\000\ + \006\000\006\000\006\000\000\000\000\000\000\000\006\000\006\000\ + \000\000\006\000\006\000\006\000\000\000\000\000\006\000\137\000\ + \006\000\000\000\000\000\000\000\135\000\006\000\006\000\000\000\ + \006\000\006\000\006\000\006\000\006\000\000\000\000\000\000\000\ + \006\000\000\000\000\000\006\000\006\000\006\000\180\000\000\000\ + \000\000\006\000\006\000\000\000\126\000\006\000\006\000\000\000\ + \255\255\000\000\000\000\136\000\000\000\006\000\000\000\000\000\ + \000\000\006\000\006\000\006\000\006\000\006\000\006\000\006\000\ + \000\000\000\000\120\000\000\000\000\000\120\000\120\000\120\000\ + \000\000\000\000\000\000\120\000\120\000\000\000\120\000\121\000\ + \120\000\000\000\000\000\255\255\000\000\000\000\000\000\000\000\ + \006\000\000\000\006\000\120\000\000\000\006\000\120\000\120\000\ + \120\000\120\000\205\000\000\000\000\000\117\000\000\000\000\000\ + \117\000\117\000\117\000\000\000\000\000\000\000\117\000\117\000\ + \000\000\117\000\118\000\117\000\255\255\000\000\000\000\255\255\ + \000\000\255\255\000\000\006\000\000\000\006\000\117\000\120\000\ + \117\000\117\000\119\000\117\000\117\000\000\000\000\000\000\000\ + \006\000\000\000\000\000\006\000\006\000\116\000\255\255\000\000\ + \000\000\006\000\006\000\000\000\006\000\006\000\006\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\120\000\000\000\120\000\ + \000\000\006\000\117\000\006\000\006\000\006\000\006\000\006\000\ + \095\000\095\000\095\000\095\000\095\000\095\000\095\000\095\000\ + \095\000\095\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\095\000\095\000\095\000\095\000\095\000\095\000\000\000\ + \117\000\000\000\117\000\000\000\000\000\006\000\000\000\000\000\ + \000\000\000\000\177\000\000\000\000\000\000\000\000\000\107\000\ + \194\000\194\000\194\000\194\000\194\000\194\000\194\000\194\000\ + \000\000\095\000\095\000\095\000\095\000\095\000\095\000\000\000\ + \000\000\000\000\000\000\006\000\000\000\006\000\107\000\105\000\ + \000\000\105\000\105\000\105\000\105\000\000\000\000\000\000\000\ + \105\000\105\000\107\000\105\000\105\000\105\000\106\000\106\000\ + \106\000\106\000\106\000\106\000\106\000\106\000\106\000\106\000\ + \105\000\000\000\105\000\105\000\105\000\105\000\105\000\000\000\ + \000\000\107\000\003\000\000\000\000\000\003\000\003\000\003\000\ + \000\000\000\000\104\000\103\000\003\000\000\000\003\000\003\000\ + \003\000\106\000\106\000\106\000\106\000\106\000\106\000\106\000\ + \106\000\106\000\106\000\003\000\105\000\003\000\003\000\003\000\ + \003\000\003\000\168\000\168\000\168\000\168\000\168\000\168\000\ + \168\000\168\000\168\000\168\000\169\000\169\000\169\000\169\000\ + \169\000\169\000\169\000\169\000\169\000\169\000\000\000\000\000\ + \000\000\000\000\105\000\073\000\105\000\000\000\075\000\003\000\ + \075\000\075\000\075\000\075\000\075\000\075\000\075\000\075\000\ + \075\000\075\000\075\000\075\000\075\000\075\000\075\000\075\000\ + \075\000\075\000\075\000\075\000\075\000\075\000\075\000\075\000\ + \075\000\075\000\000\000\074\000\000\000\003\000\075\000\003\000\ + \075\000\075\000\075\000\075\000\075\000\075\000\075\000\075\000\ + \075\000\075\000\075\000\075\000\075\000\075\000\075\000\075\000\ + \075\000\075\000\075\000\075\000\075\000\075\000\075\000\075\000\ + \075\000\075\000\055\000\074\000\000\000\000\000\000\000\000\000\ + \000\000\057\000\000\000\030\000\030\000\030\000\030\000\030\000\ + \030\000\030\000\030\000\030\000\030\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\055\000\055\000\055\000\055\000\ + \056\000\055\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\000\000\000\000\ + \000\000\000\000\030\000\000\000\055\000\055\000\055\000\055\000\ + \056\000\055\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\055\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\057\000\000\000\030\000\ + \030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ + \030\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \055\000\059\000\055\000\055\000\056\000\055\000\058\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\060\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\061\000\ + \058\000\058\000\000\000\000\000\000\000\000\000\030\000\000\000\ + \055\000\059\000\055\000\055\000\056\000\055\000\058\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\060\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\061\000\ + \058\000\058\000\032\000\195\000\195\000\195\000\195\000\195\000\ + \195\000\195\000\195\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\000\000\000\000\ + \000\000\000\000\032\000\000\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\096\000\096\000\ + \096\000\096\000\096\000\096\000\096\000\096\000\096\000\096\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\096\000\ + \096\000\096\000\096\000\096\000\096\000\191\000\191\000\191\000\ + \191\000\191\000\191\000\191\000\191\000\191\000\191\000\192\000\ + \192\000\192\000\192\000\192\000\192\000\192\000\192\000\192\000\ + \192\000\000\000\000\000\000\000\000\000\000\000\000\000\096\000\ + \096\000\096\000\096\000\096\000\096\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\000\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\033\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\033\000\000\000\000\000\ + \000\000\000\000\033\000\000\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\033\000\112\000\108\000\ + \000\000\000\000\109\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\112\000\000\000\111\000\ + \000\000\000\000\000\000\000\000\145\000\000\000\000\000\146\000\ + \000\000\000\000\000\000\000\000\000\000\106\000\106\000\106\000\ + \106\000\106\000\106\000\106\000\106\000\106\000\106\000\000\000\ + \000\000\000\000\000\000\000\000\150\000\000\000\000\000\000\000\ + \000\000\148\000\152\000\000\000\151\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\000\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\034\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\149\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\000\000\000\000\ + \000\000\000\000\034\000\000\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\156\000\000\000\ + \156\000\156\000\156\000\156\000\156\000\156\000\156\000\156\000\ + \156\000\156\000\156\000\156\000\156\000\156\000\156\000\156\000\ + \156\000\156\000\156\000\156\000\156\000\156\000\156\000\156\000\ + \156\000\156\000\000\000\155\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\156\000\255\255\156\000\156\000\ + \156\000\156\000\156\000\156\000\156\000\156\000\156\000\156\000\ + \156\000\156\000\156\000\156\000\156\000\156\000\156\000\156\000\ + \156\000\156\000\156\000\156\000\156\000\156\000\156\000\156\000\ + \000\000\155\000\147\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\000\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\035\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\000\000\000\000\ + \000\000\000\000\035\000\000\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\171\000\171\000\ + \171\000\171\000\171\000\171\000\171\000\171\000\171\000\171\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\171\000\ + \171\000\171\000\171\000\171\000\171\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\171\000\ + \171\000\171\000\171\000\171\000\171\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\000\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\000\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\046\000\000\000\000\000\046\000\046\000\ + \046\000\000\000\000\000\000\000\046\000\046\000\000\000\046\000\ + \046\000\046\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\046\000\000\000\046\000\046\000\ + \046\000\046\000\046\000\000\000\210\000\000\000\210\000\210\000\ + \210\000\210\000\210\000\210\000\210\000\210\000\210\000\210\000\ + \210\000\210\000\210\000\210\000\210\000\210\000\210\000\210\000\ + \210\000\210\000\210\000\210\000\210\000\210\000\210\000\210\000\ + \046\000\052\000\209\000\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\000\000\046\000\046\000\ + \046\000\000\000\046\000\046\000\046\000\000\000\000\000\000\000\ + \046\000\046\000\000\000\046\000\046\000\046\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \046\000\000\000\046\000\046\000\046\000\046\000\046\000\000\000\ + \210\000\000\000\210\000\210\000\210\000\210\000\210\000\210\000\ + \210\000\210\000\210\000\210\000\210\000\210\000\210\000\210\000\ + \210\000\210\000\210\000\210\000\210\000\210\000\210\000\210\000\ + \210\000\210\000\210\000\210\000\046\000\048\000\209\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ + \048\000\000\000\046\000\000\000\046\000\000\000\000\000\000\000\ + \000\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\000\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\172\000\172\000\172\000\172\000\172\000\172\000\ + \172\000\172\000\172\000\172\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\172\000\172\000\172\000\172\000\172\000\ + \172\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\172\000\172\000\172\000\172\000\172\000\ + \172\000\000\000\000\000\000\000\000\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\035\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\000\000\000\000\000\000\000\000\035\000\000\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\196\000\196\000\196\000\196\000\196\000\196\000\196\000\ + \196\000\196\000\196\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\196\000\196\000\196\000\196\000\196\000\196\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\196\000\196\000\196\000\196\000\196\000\196\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\000\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\000\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\046\000\000\000\ + \000\000\046\000\046\000\046\000\000\000\000\000\000\000\046\000\ + \046\000\000\000\046\000\046\000\046\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\046\000\ + \000\000\046\000\046\000\046\000\046\000\046\000\000\000\000\000\ + \000\000\000\000\047\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\050\000\000\000\000\000\ + \000\000\000\000\000\000\046\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\000\000\000\000\ + \000\000\046\000\047\000\046\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\197\000\197\000\ + \197\000\197\000\197\000\197\000\197\000\197\000\197\000\197\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\197\000\ + \197\000\197\000\197\000\197\000\197\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\197\000\ + \197\000\197\000\197\000\197\000\197\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\000\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\048\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\048\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\049\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\000\000\000\000\ + \000\000\000\000\048\000\000\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\199\000\199\000\ + \199\000\199\000\199\000\199\000\199\000\199\000\199\000\199\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\199\000\ + \199\000\199\000\199\000\199\000\199\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\199\000\ + \199\000\199\000\199\000\199\000\199\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\000\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\051\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\054\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\000\000\000\000\ + \000\000\000\000\051\000\000\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\000\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\052\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\053\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\052\000\000\000\000\000\ + \000\000\000\000\052\000\000\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\052\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\000\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\055\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\000\000\000\000\ + \000\000\000\000\055\000\000\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\000\000\ + \000\000\000\000\072\000\000\000\072\000\000\000\000\000\071\000\ + \071\000\071\000\071\000\071\000\071\000\071\000\071\000\071\000\ + \071\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\000\000\000\000\000\000\000\000\055\000\000\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\057\000\057\000\057\000\057\000\057\000\ + \057\000\057\000\057\000\057\000\057\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\055\000\055\000\055\000\055\000\ + \056\000\055\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\067\000\067\000\067\000\067\000\000\000\000\000\ + \000\000\000\000\057\000\000\000\055\000\055\000\055\000\055\000\ + \056\000\055\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\067\000\067\000\067\000\067\000\055\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\000\000\000\000\000\000\000\000\055\000\000\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\070\000\070\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\000\000\000\000\ + \000\000\000\000\055\000\000\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\069\000\ + \069\000\069\000\069\000\069\000\069\000\069\000\069\000\055\000\ + \055\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\000\000\000\000\000\000\000\000\055\000\000\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\062\000\062\000\062\000\062\000\062\000\ + \062\000\062\000\062\000\062\000\062\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\062\000\062\000\062\000\062\000\ + \062\000\062\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\000\000\000\000\ + \000\000\000\000\055\000\000\000\062\000\062\000\062\000\062\000\ + \062\000\062\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\063\000\000\000\062\000\ + \062\000\062\000\062\000\062\000\062\000\062\000\062\000\062\000\ + \062\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \062\000\062\000\062\000\062\000\062\000\062\000\058\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\064\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\058\000\000\000\000\000\000\000\000\000\062\000\000\000\ + \062\000\062\000\062\000\062\000\062\000\062\000\058\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\064\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\058\000\055\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\063\000\063\000\063\000\063\000\063\000\ + \063\000\063\000\063\000\063\000\063\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\063\000\063\000\063\000\063\000\ + \063\000\063\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\067\000\068\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\067\000\067\000\067\000\067\000\000\000\000\000\ + \000\000\000\000\063\000\000\000\063\000\063\000\063\000\063\000\ + \063\000\063\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\067\000\068\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\067\000\067\000\067\000\067\000\055\000\000\000\ + \000\000\000\000\066\000\000\000\066\000\000\000\000\000\065\000\ + \065\000\065\000\065\000\065\000\065\000\065\000\065\000\065\000\ + \065\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\000\000\000\000\000\000\000\000\055\000\000\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\065\000\065\000\065\000\065\000\065\000\ + \065\000\065\000\065\000\065\000\065\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\067\000\067\000\067\000\067\000\000\000\000\000\ + \000\000\000\000\065\000\000\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\067\000\067\000\067\000\067\000\055\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\000\000\000\000\000\000\000\000\055\000\000\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\000\000\000\000\000\000\066\000\000\000\ + \066\000\000\000\000\000\065\000\065\000\065\000\065\000\065\000\ + \065\000\065\000\065\000\065\000\065\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\000\000\000\000\ + \000\000\000\000\055\000\000\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\069\000\ + \069\000\069\000\069\000\069\000\069\000\069\000\069\000\055\000\ + \055\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\058\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\058\000\000\000\000\000\000\000\000\000\069\000\000\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\058\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\058\000\055\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\070\000\070\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\000\000\000\000\ + \000\000\000\000\070\000\000\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\055\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\071\000\ + \071\000\071\000\071\000\071\000\071\000\071\000\071\000\071\000\ + \071\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\067\000\067\000\ + \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\000\000\000\000\000\000\000\000\071\000\000\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\067\000\067\000\ + \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\086\000\103\000\086\000\000\000\103\000\103\000\ + \103\000\086\000\000\000\000\000\103\000\103\000\000\000\103\000\ + \103\000\103\000\085\000\085\000\085\000\085\000\085\000\085\000\ + \085\000\085\000\085\000\085\000\103\000\000\000\103\000\103\000\ + \103\000\103\000\103\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\105\000\000\000\105\000\105\000\105\000\105\000\ + \000\000\000\000\000\000\105\000\105\000\000\000\105\000\105\000\ + \105\000\000\000\000\000\000\000\000\000\000\000\086\000\000\000\ + \103\000\000\000\000\000\105\000\086\000\105\000\105\000\105\000\ + \105\000\105\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \086\000\084\000\000\000\000\000\086\000\000\000\086\000\000\000\ + \006\000\000\000\083\000\006\000\006\000\006\000\103\000\000\000\ + \103\000\006\000\006\000\000\000\006\000\006\000\006\000\105\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\006\000\000\000\006\000\006\000\006\000\006\000\006\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\117\000\ + \000\000\000\000\117\000\117\000\117\000\105\000\000\000\105\000\ + \117\000\117\000\000\000\117\000\117\000\117\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\006\000\000\000\000\000\ + \117\000\000\000\117\000\117\000\117\000\117\000\117\000\000\000\ + \000\000\000\000\117\000\000\000\000\000\117\000\117\000\117\000\ + \000\000\000\000\000\000\117\000\117\000\000\000\117\000\117\000\ + \117\000\000\000\000\000\006\000\000\000\006\000\000\000\000\000\ + \000\000\000\000\000\000\117\000\117\000\117\000\117\000\117\000\ + \117\000\117\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \117\000\000\000\000\000\117\000\117\000\117\000\000\000\000\000\ + \000\000\117\000\117\000\000\000\117\000\117\000\117\000\000\000\ + \000\000\000\000\117\000\000\000\117\000\000\000\000\000\117\000\ + \000\000\117\000\255\255\117\000\117\000\117\000\117\000\117\000\ + \000\000\000\000\000\000\120\000\000\000\000\000\120\000\120\000\ + \120\000\000\000\000\000\000\000\120\000\120\000\000\000\120\000\ + \120\000\120\000\000\000\000\000\000\000\117\000\000\000\117\000\ + \000\000\000\000\000\000\000\000\120\000\117\000\120\000\120\000\ + \120\000\120\000\120\000\000\000\000\000\000\000\006\000\000\000\ + \000\000\006\000\006\000\006\000\000\000\000\000\000\000\006\000\ + \006\000\000\000\006\000\006\000\006\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\117\000\000\000\117\000\000\000\006\000\ + \120\000\006\000\006\000\006\000\006\000\006\000\000\000\000\000\ + \000\000\006\000\000\000\000\000\006\000\006\000\006\000\000\000\ + \000\000\000\000\006\000\006\000\000\000\006\000\006\000\006\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\120\000\000\000\ + \120\000\000\000\006\000\006\000\006\000\006\000\006\000\006\000\ + \006\000\000\000\000\000\000\000\139\000\000\000\000\000\139\000\ + \139\000\139\000\000\000\000\000\000\000\139\000\139\000\000\000\ + \139\000\139\000\139\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\006\000\000\000\006\000\000\000\139\000\006\000\139\000\ + \139\000\139\000\139\000\139\000\000\000\000\000\000\000\139\000\ + \000\000\000\000\139\000\139\000\139\000\000\000\000\000\000\000\ + \139\000\139\000\000\000\139\000\139\000\139\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\006\000\000\000\006\000\000\000\ + \139\000\139\000\139\000\139\000\139\000\139\000\139\000\000\000\ + \000\000\000\000\117\000\000\000\000\000\117\000\117\000\117\000\ + \000\000\000\000\000\000\117\000\117\000\000\000\117\000\117\000\ + \117\000\000\000\000\000\000\000\000\000\000\000\000\000\139\000\ + \000\000\139\000\000\000\117\000\139\000\117\000\117\000\117\000\ + \117\000\117\000\000\000\000\000\000\000\117\000\000\000\000\000\ + \117\000\117\000\117\000\000\000\000\000\000\000\117\000\117\000\ + \000\000\117\000\117\000\117\000\000\000\000\000\166\000\000\000\ + \166\000\000\000\139\000\000\000\139\000\166\000\117\000\117\000\ + \117\000\117\000\117\000\117\000\117\000\000\000\165\000\165\000\ + \165\000\165\000\165\000\165\000\165\000\165\000\165\000\165\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\117\000\000\000\117\000\ + \000\000\000\000\117\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\188\000\000\000\000\000\189\000\000\000\000\000\000\000\ + \000\000\000\000\166\000\000\000\000\000\000\000\000\000\000\000\ + \166\000\000\000\000\000\000\000\000\000\000\000\000\000\187\000\ + \117\000\187\000\117\000\000\000\166\000\000\000\187\000\000\000\ + \166\000\000\000\166\000\000\000\000\000\000\000\164\000\186\000\ + \186\000\186\000\186\000\186\000\186\000\186\000\186\000\186\000\ + \186\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\199\000\199\000\199\000\199\000\199\000\199\000\199\000\ + \199\000\199\000\199\000\187\000\000\000\000\000\000\000\000\000\ + \000\000\187\000\199\000\199\000\199\000\199\000\199\000\199\000\ + \000\000\000\000\000\000\000\000\000\000\187\000\185\000\000\000\ + \000\000\187\000\000\000\187\000\183\000\000\000\000\000\184\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\199\000\199\000\199\000\199\000\199\000\199\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\200\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\255\255\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000"; + Lexing.lex_check = + "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\000\000\000\000\041\000\000\000\000\000\041\000\042\000\ + \044\000\045\000\042\000\044\000\045\000\079\000\109\000\115\000\ + \079\000\109\000\115\000\146\000\160\000\218\000\146\000\160\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\016\000\ + \013\000\017\000\026\000\039\000\017\000\017\000\039\000\066\000\ + \066\000\066\000\066\000\066\000\066\000\066\000\066\000\066\000\ + \066\000\077\000\078\000\084\000\084\000\084\000\084\000\013\000\ + \086\000\013\000\039\000\013\000\072\000\072\000\072\000\072\000\ + \072\000\072\000\072\000\072\000\072\000\072\000\085\000\085\000\ + \085\000\085\000\085\000\085\000\085\000\085\000\085\000\085\000\ + \088\000\088\000\088\000\088\000\088\000\088\000\088\000\088\000\ + \088\000\088\000\089\000\093\000\096\000\098\000\098\000\127\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\013\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\003\000\100\000\100\000\003\000\003\000\003\000\102\000\ + \102\000\027\000\003\000\003\000\027\000\003\000\003\000\003\000\ + \091\000\091\000\091\000\091\000\091\000\091\000\091\000\091\000\ + \110\000\132\000\003\000\110\000\003\000\003\000\003\000\003\000\ + \003\000\151\000\113\000\152\000\004\000\113\000\027\000\004\000\ + \004\000\004\000\158\000\159\000\166\000\004\000\004\000\169\000\ + \004\000\004\000\004\000\092\000\092\000\092\000\092\000\092\000\ + \092\000\092\000\092\000\172\000\183\000\004\000\003\000\004\000\ + \004\000\004\000\004\000\004\000\211\000\174\000\179\000\005\000\ + \174\000\179\000\005\000\005\000\005\000\212\000\215\000\217\000\ + \005\000\005\000\188\000\005\000\005\000\005\000\185\000\185\000\ + \185\000\185\000\111\000\027\000\003\000\111\000\003\000\255\255\ + \005\000\004\000\005\000\005\000\005\000\005\000\005\000\255\255\ + \189\000\188\000\006\000\189\000\255\255\006\000\006\000\006\000\ + \255\255\255\255\111\000\006\000\006\000\255\255\006\000\006\000\ + \006\000\255\255\255\255\190\000\112\000\112\000\190\000\004\000\ + \112\000\004\000\255\255\006\000\005\000\006\000\006\000\006\000\ + \006\000\006\000\255\255\201\000\202\000\007\000\201\000\202\000\ + \007\000\007\000\007\000\112\000\255\255\112\000\007\000\007\000\ + \255\255\007\000\007\000\007\000\207\000\208\000\213\000\207\000\ + \208\000\214\000\005\000\216\000\005\000\255\255\007\000\006\000\ + \007\000\007\000\007\000\007\000\007\000\255\255\255\255\255\255\ + \008\000\255\255\255\255\008\000\008\000\008\000\255\255\255\255\ + \148\000\008\000\008\000\148\000\008\000\008\000\008\000\255\255\ + \255\255\255\255\255\255\255\255\255\255\006\000\255\255\006\000\ + \255\255\008\000\007\000\008\000\008\000\008\000\008\000\008\000\ + \255\255\255\255\255\255\010\000\255\255\148\000\010\000\010\000\ + \010\000\255\255\255\255\255\255\010\000\010\000\255\255\010\000\ + \010\000\010\000\255\255\255\255\255\255\255\255\255\255\255\255\ + \007\000\255\255\007\000\255\255\010\000\008\000\010\000\010\000\ + \010\000\010\000\010\000\255\255\175\000\255\255\255\255\175\000\ + \011\000\255\255\255\255\011\000\011\000\011\000\202\000\027\000\ + \255\255\011\000\011\000\255\255\011\000\011\000\011\000\255\255\ + \255\255\255\255\148\000\008\000\175\000\008\000\110\000\010\000\ + \010\000\011\000\255\255\011\000\011\000\011\000\011\000\011\000\ + \113\000\255\255\255\255\255\255\255\255\014\000\255\255\255\255\ + \014\000\014\000\014\000\255\255\255\255\255\255\014\000\014\000\ + \255\255\014\000\014\000\014\000\255\255\255\255\010\000\010\000\ + \010\000\255\255\255\255\255\255\011\000\011\000\014\000\255\255\ + \014\000\014\000\014\000\014\000\014\000\255\255\255\255\255\255\ + \015\000\255\255\255\255\015\000\015\000\015\000\175\000\255\255\ + \255\255\015\000\015\000\255\255\015\000\015\000\015\000\255\255\ + \111\000\255\255\255\255\011\000\255\255\011\000\255\255\255\255\ + \255\255\015\000\014\000\015\000\015\000\015\000\015\000\015\000\ + \255\255\255\255\018\000\255\255\255\255\018\000\018\000\018\000\ + \255\255\255\255\255\255\018\000\018\000\255\255\018\000\018\000\ + \018\000\255\255\255\255\112\000\255\255\255\255\255\255\255\255\ + \014\000\255\255\014\000\018\000\255\255\015\000\018\000\018\000\ + \018\000\018\000\202\000\255\255\255\255\019\000\255\255\255\255\ + \019\000\019\000\019\000\255\255\255\255\255\255\019\000\019\000\ + \255\255\019\000\019\000\019\000\213\000\255\255\255\255\214\000\ + \255\255\216\000\255\255\015\000\255\255\015\000\019\000\018\000\ + \019\000\019\000\019\000\019\000\019\000\255\255\255\255\255\255\ + \023\000\255\255\255\255\023\000\023\000\023\000\148\000\255\255\ + \255\255\023\000\023\000\255\255\023\000\023\000\023\000\255\255\ + \255\255\255\255\255\255\255\255\255\255\018\000\255\255\018\000\ + \255\255\023\000\019\000\023\000\023\000\023\000\023\000\023\000\ + \083\000\083\000\083\000\083\000\083\000\083\000\083\000\083\000\ + \083\000\083\000\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\083\000\083\000\083\000\083\000\083\000\083\000\255\255\ + \019\000\255\255\019\000\255\255\255\255\023\000\255\255\255\255\ + \255\255\255\255\175\000\255\255\255\255\255\255\255\255\024\000\ + \193\000\193\000\193\000\193\000\193\000\193\000\193\000\193\000\ + \255\255\083\000\083\000\083\000\083\000\083\000\083\000\255\255\ + \255\255\255\255\255\255\023\000\255\255\023\000\024\000\024\000\ + \255\255\024\000\024\000\024\000\024\000\255\255\255\255\255\255\ + \024\000\024\000\107\000\024\000\024\000\024\000\024\000\024\000\ + \024\000\024\000\024\000\024\000\024\000\024\000\024\000\024\000\ + \024\000\255\255\024\000\024\000\024\000\024\000\024\000\255\255\ + \255\255\107\000\025\000\255\255\255\255\025\000\025\000\025\000\ + \255\255\255\255\025\000\025\000\025\000\255\255\025\000\025\000\ + \025\000\107\000\107\000\107\000\107\000\107\000\107\000\107\000\ + \107\000\107\000\107\000\025\000\024\000\025\000\025\000\025\000\ + \025\000\025\000\165\000\165\000\165\000\165\000\165\000\165\000\ + \165\000\165\000\165\000\165\000\168\000\168\000\168\000\168\000\ + \168\000\168\000\168\000\168\000\168\000\168\000\255\255\255\255\ + \255\255\255\255\024\000\028\000\024\000\255\255\075\000\025\000\ + \075\000\075\000\075\000\075\000\075\000\075\000\075\000\075\000\ + \075\000\075\000\075\000\075\000\075\000\075\000\075\000\075\000\ + \075\000\075\000\075\000\075\000\075\000\075\000\075\000\075\000\ + \075\000\075\000\255\255\075\000\255\255\025\000\028\000\025\000\ + \028\000\028\000\028\000\028\000\028\000\028\000\028\000\028\000\ + \028\000\028\000\028\000\028\000\028\000\028\000\028\000\028\000\ + \028\000\028\000\028\000\028\000\028\000\028\000\028\000\028\000\ + \028\000\028\000\030\000\028\000\255\255\255\255\255\255\255\255\ + \255\255\030\000\255\255\030\000\030\000\030\000\030\000\030\000\ + \030\000\030\000\030\000\030\000\030\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\030\000\030\000\030\000\030\000\ + \030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ + \030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ + \030\000\030\000\030\000\030\000\030\000\030\000\255\255\255\255\ + \255\255\255\255\030\000\255\255\030\000\030\000\030\000\030\000\ + \030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ + \030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ + \030\000\030\000\030\000\030\000\030\000\030\000\031\000\255\255\ + \255\255\255\255\255\255\255\255\255\255\031\000\255\255\031\000\ + \031\000\031\000\031\000\031\000\031\000\031\000\031\000\031\000\ + \031\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \031\000\031\000\031\000\031\000\031\000\031\000\031\000\031\000\ + \031\000\031\000\031\000\031\000\031\000\031\000\031\000\031\000\ + \031\000\031\000\031\000\031\000\031\000\031\000\031\000\031\000\ + \031\000\031\000\255\255\255\255\255\255\255\255\031\000\255\255\ + \031\000\031\000\031\000\031\000\031\000\031\000\031\000\031\000\ + \031\000\031\000\031\000\031\000\031\000\031\000\031\000\031\000\ + \031\000\031\000\031\000\031\000\031\000\031\000\031\000\031\000\ + \031\000\031\000\032\000\194\000\194\000\194\000\194\000\194\000\ + \194\000\194\000\194\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\255\255\255\255\ + \255\255\255\255\032\000\255\255\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\095\000\095\000\ + \095\000\095\000\095\000\095\000\095\000\095\000\095\000\095\000\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\095\000\ + \095\000\095\000\095\000\095\000\095\000\186\000\186\000\186\000\ + \186\000\186\000\186\000\186\000\186\000\186\000\186\000\191\000\ + \191\000\191\000\191\000\191\000\191\000\191\000\191\000\191\000\ + \191\000\255\255\255\255\255\255\255\255\255\255\255\255\095\000\ + \095\000\095\000\095\000\095\000\095\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\255\255\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\033\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\033\000\255\255\255\255\ + \255\255\255\255\033\000\255\255\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\033\000\106\000\106\000\ + \255\255\255\255\106\000\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\106\000\255\255\106\000\ + \255\255\255\255\255\255\255\255\143\000\255\255\255\255\143\000\ + \255\255\255\255\255\255\255\255\255\255\106\000\106\000\106\000\ + \106\000\106\000\106\000\106\000\106\000\106\000\106\000\255\255\ + \255\255\255\255\255\255\255\255\143\000\255\255\255\255\255\255\ + \255\255\143\000\143\000\255\255\143\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\255\255\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\034\000\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\143\000\255\255\255\255\ + \255\255\255\255\255\255\255\255\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\255\255\255\255\ + \255\255\255\255\034\000\255\255\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\149\000\255\255\ + \149\000\149\000\149\000\149\000\149\000\149\000\149\000\149\000\ + \149\000\149\000\149\000\149\000\149\000\149\000\149\000\149\000\ + \149\000\149\000\149\000\149\000\149\000\149\000\149\000\149\000\ + \149\000\149\000\255\255\149\000\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\156\000\106\000\156\000\156\000\ + \156\000\156\000\156\000\156\000\156\000\156\000\156\000\156\000\ + \156\000\156\000\156\000\156\000\156\000\156\000\156\000\156\000\ + \156\000\156\000\156\000\156\000\156\000\156\000\156\000\156\000\ + \255\255\156\000\143\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\255\255\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\035\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\255\255\255\255\ + \255\255\255\255\035\000\255\255\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\164\000\164\000\ + \164\000\164\000\164\000\164\000\164\000\164\000\164\000\164\000\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\164\000\ + \164\000\164\000\164\000\164\000\164\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\164\000\ + \164\000\164\000\164\000\164\000\164\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\255\255\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\255\255\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\036\000\255\255\255\255\036\000\036\000\ + \036\000\255\255\255\255\255\255\036\000\036\000\255\255\036\000\ + \036\000\036\000\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\036\000\255\255\036\000\036\000\ + \036\000\036\000\036\000\255\255\204\000\255\255\204\000\204\000\ + \204\000\204\000\204\000\204\000\204\000\204\000\204\000\204\000\ + \204\000\204\000\204\000\204\000\204\000\204\000\204\000\204\000\ + \204\000\204\000\204\000\204\000\204\000\204\000\204\000\204\000\ + \036\000\036\000\204\000\036\000\036\000\036\000\036\000\036\000\ + \036\000\036\000\036\000\036\000\036\000\036\000\036\000\036\000\ + \036\000\036\000\036\000\036\000\036\000\036\000\036\000\036\000\ + \036\000\036\000\036\000\036\000\036\000\255\255\036\000\037\000\ + \036\000\255\255\037\000\037\000\037\000\255\255\255\255\255\255\ + \037\000\037\000\255\255\037\000\037\000\037\000\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \037\000\255\255\037\000\037\000\037\000\037\000\037\000\255\255\ + \210\000\255\255\210\000\210\000\210\000\210\000\210\000\210\000\ + \210\000\210\000\210\000\210\000\210\000\210\000\210\000\210\000\ + \210\000\210\000\210\000\210\000\210\000\210\000\210\000\210\000\ + \210\000\210\000\210\000\210\000\037\000\037\000\210\000\037\000\ + \037\000\037\000\037\000\037\000\037\000\037\000\037\000\037\000\ + \037\000\037\000\037\000\037\000\037\000\037\000\037\000\037\000\ + \037\000\037\000\037\000\037\000\037\000\037\000\037\000\037\000\ + \037\000\255\255\037\000\255\255\037\000\255\255\255\255\255\255\ + \255\255\036\000\036\000\036\000\036\000\036\000\036\000\036\000\ + \036\000\036\000\036\000\036\000\036\000\036\000\036\000\036\000\ + \036\000\036\000\036\000\036\000\036\000\036\000\036\000\036\000\ + \036\000\255\255\036\000\036\000\036\000\036\000\036\000\036\000\ + \036\000\036\000\171\000\171\000\171\000\171\000\171\000\171\000\ + \171\000\171\000\171\000\171\000\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\171\000\171\000\171\000\171\000\171\000\ + \171\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\171\000\171\000\171\000\171\000\171\000\ + \171\000\255\255\255\255\255\255\255\255\037\000\037\000\037\000\ + \037\000\037\000\037\000\037\000\037\000\037\000\037\000\037\000\ + \037\000\037\000\037\000\037\000\037\000\037\000\037\000\037\000\ + \037\000\037\000\037\000\037\000\037\000\038\000\037\000\037\000\ + \037\000\037\000\037\000\037\000\037\000\037\000\038\000\038\000\ + \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\038\000\ + \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ + \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ + \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ + \038\000\255\255\255\255\255\255\255\255\038\000\255\255\038\000\ + \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ + \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ + \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ + \038\000\184\000\184\000\184\000\184\000\184\000\184\000\184\000\ + \184\000\184\000\184\000\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\184\000\184\000\184\000\184\000\184\000\184\000\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\184\000\184\000\184\000\184\000\184\000\184\000\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\038\000\038\000\ + \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ + \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ + \038\000\038\000\038\000\038\000\038\000\255\255\038\000\038\000\ + \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ + \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ + \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ + \038\000\038\000\038\000\038\000\038\000\255\255\038\000\038\000\ + \038\000\038\000\038\000\038\000\038\000\038\000\046\000\255\255\ + \255\255\046\000\046\000\046\000\255\255\255\255\255\255\046\000\ + \046\000\255\255\046\000\046\000\046\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\046\000\ + \255\255\046\000\046\000\046\000\046\000\046\000\255\255\255\255\ + \255\255\255\255\047\000\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\255\255\255\255\ + \255\255\255\255\255\255\046\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\255\255\255\255\ + \255\255\046\000\047\000\046\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\196\000\196\000\ + \196\000\196\000\196\000\196\000\196\000\196\000\196\000\196\000\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\196\000\ + \196\000\196\000\196\000\196\000\196\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\196\000\ + \196\000\196\000\196\000\196\000\196\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\255\255\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\048\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\048\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\255\255\255\255\ + \255\255\255\255\255\255\255\255\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\255\255\255\255\ + \255\255\255\255\048\000\255\255\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\198\000\198\000\ + \198\000\198\000\198\000\198\000\198\000\198\000\198\000\198\000\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\198\000\ + \198\000\198\000\198\000\198\000\198\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\198\000\ + \198\000\198\000\198\000\198\000\198\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\048\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\255\255\048\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\051\000\048\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\255\255\255\255\ + \255\255\255\255\255\255\255\255\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\255\255\255\255\ + \255\255\255\255\051\000\255\255\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\255\255\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\052\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\052\000\255\255\255\255\ + \255\255\255\255\255\255\255\255\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\052\000\255\255\255\255\ + \255\255\255\255\052\000\255\255\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\052\000\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\255\255\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\055\000\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\255\255\255\255\ + \255\255\255\255\055\000\255\255\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\056\000\255\255\ + \255\255\255\255\056\000\255\255\056\000\255\255\255\255\056\000\ + \056\000\056\000\056\000\056\000\056\000\056\000\056\000\056\000\ + \056\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \056\000\056\000\056\000\056\000\056\000\056\000\056\000\056\000\ + \056\000\056\000\056\000\056\000\056\000\056\000\056\000\056\000\ + \056\000\056\000\056\000\056\000\056\000\056\000\056\000\056\000\ + \056\000\056\000\255\255\255\255\255\255\255\255\056\000\255\255\ + \056\000\056\000\056\000\056\000\056\000\056\000\056\000\056\000\ + \056\000\056\000\056\000\056\000\056\000\056\000\056\000\056\000\ + \056\000\056\000\056\000\056\000\056\000\056\000\056\000\056\000\ + \056\000\056\000\057\000\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\057\000\057\000\057\000\057\000\057\000\ + \057\000\057\000\057\000\057\000\057\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\057\000\057\000\057\000\057\000\ + \057\000\057\000\057\000\057\000\057\000\057\000\057\000\057\000\ + \057\000\057\000\057\000\057\000\057\000\057\000\057\000\057\000\ + \057\000\057\000\057\000\057\000\057\000\057\000\255\255\255\255\ + \255\255\255\255\057\000\255\255\057\000\057\000\057\000\057\000\ + \057\000\057\000\057\000\057\000\057\000\057\000\057\000\057\000\ + \057\000\057\000\057\000\057\000\057\000\057\000\057\000\057\000\ + \057\000\057\000\057\000\057\000\057\000\057\000\058\000\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\058\000\255\255\255\255\255\255\255\255\058\000\255\255\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\058\000\059\000\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\059\000\059\000\059\000\059\000\059\000\ + \059\000\059\000\059\000\059\000\059\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\059\000\059\000\059\000\059\000\ + \059\000\059\000\059\000\059\000\059\000\059\000\059\000\059\000\ + \059\000\059\000\059\000\059\000\059\000\059\000\059\000\059\000\ + \059\000\059\000\059\000\059\000\059\000\059\000\255\255\255\255\ + \255\255\255\255\059\000\255\255\059\000\059\000\059\000\059\000\ + \059\000\059\000\059\000\059\000\059\000\059\000\059\000\059\000\ + \059\000\059\000\059\000\059\000\059\000\059\000\059\000\059\000\ + \059\000\059\000\059\000\059\000\059\000\059\000\060\000\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\060\000\ + \060\000\060\000\060\000\060\000\060\000\060\000\060\000\060\000\ + \060\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \060\000\060\000\060\000\060\000\060\000\060\000\060\000\060\000\ + \060\000\060\000\060\000\060\000\060\000\060\000\060\000\060\000\ + \060\000\060\000\060\000\060\000\060\000\060\000\060\000\060\000\ + \060\000\060\000\255\255\255\255\255\255\255\255\060\000\255\255\ + \060\000\060\000\060\000\060\000\060\000\060\000\060\000\060\000\ + \060\000\060\000\060\000\060\000\060\000\060\000\060\000\060\000\ + \060\000\060\000\060\000\060\000\060\000\060\000\060\000\060\000\ + \060\000\060\000\061\000\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\061\000\061\000\061\000\061\000\061\000\ + \061\000\061\000\061\000\061\000\061\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\061\000\061\000\061\000\061\000\ + \061\000\061\000\061\000\061\000\061\000\061\000\061\000\061\000\ + \061\000\061\000\061\000\061\000\061\000\061\000\061\000\061\000\ + \061\000\061\000\061\000\061\000\061\000\061\000\255\255\255\255\ + \255\255\255\255\061\000\255\255\061\000\061\000\061\000\061\000\ + \061\000\061\000\061\000\061\000\061\000\061\000\061\000\061\000\ + \061\000\061\000\061\000\061\000\061\000\061\000\061\000\061\000\ + \061\000\061\000\061\000\061\000\061\000\061\000\062\000\255\255\ + \255\255\255\255\255\255\255\255\255\255\062\000\255\255\062\000\ + \062\000\062\000\062\000\062\000\062\000\062\000\062\000\062\000\ + \062\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \062\000\062\000\062\000\062\000\062\000\062\000\062\000\062\000\ + \062\000\062\000\062\000\062\000\062\000\062\000\062\000\062\000\ + \062\000\062\000\062\000\062\000\062\000\062\000\062\000\062\000\ + \062\000\062\000\255\255\255\255\255\255\255\255\062\000\255\255\ + \062\000\062\000\062\000\062\000\062\000\062\000\062\000\062\000\ + \062\000\062\000\062\000\062\000\062\000\062\000\062\000\062\000\ + \062\000\062\000\062\000\062\000\062\000\062\000\062\000\062\000\ + \062\000\062\000\063\000\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\063\000\063\000\063\000\063\000\063\000\ + \063\000\063\000\063\000\063\000\063\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\063\000\063\000\063\000\063\000\ + \063\000\063\000\063\000\063\000\063\000\063\000\063\000\063\000\ + \063\000\063\000\063\000\063\000\063\000\063\000\063\000\063\000\ + \063\000\063\000\063\000\063\000\063\000\063\000\255\255\255\255\ + \255\255\255\255\063\000\255\255\063\000\063\000\063\000\063\000\ + \063\000\063\000\063\000\063\000\063\000\063\000\063\000\063\000\ + \063\000\063\000\063\000\063\000\063\000\063\000\063\000\063\000\ + \063\000\063\000\063\000\063\000\063\000\063\000\064\000\255\255\ + \255\255\255\255\064\000\255\255\064\000\255\255\255\255\064\000\ + \064\000\064\000\064\000\064\000\064\000\064\000\064\000\064\000\ + \064\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \064\000\064\000\064\000\064\000\064\000\064\000\064\000\064\000\ + \064\000\064\000\064\000\064\000\064\000\064\000\064\000\064\000\ + \064\000\064\000\064\000\064\000\064\000\064\000\064\000\064\000\ + \064\000\064\000\255\255\255\255\255\255\255\255\064\000\255\255\ + \064\000\064\000\064\000\064\000\064\000\064\000\064\000\064\000\ + \064\000\064\000\064\000\064\000\064\000\064\000\064\000\064\000\ + \064\000\064\000\064\000\064\000\064\000\064\000\064\000\064\000\ + \064\000\064\000\065\000\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\065\000\065\000\065\000\065\000\065\000\ + \065\000\065\000\065\000\065\000\065\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\065\000\065\000\065\000\065\000\ + \065\000\065\000\065\000\065\000\065\000\065\000\065\000\065\000\ + \065\000\065\000\065\000\065\000\065\000\065\000\065\000\065\000\ + \065\000\065\000\065\000\065\000\065\000\065\000\255\255\255\255\ + \255\255\255\255\065\000\255\255\065\000\065\000\065\000\065\000\ + \065\000\065\000\065\000\065\000\065\000\065\000\065\000\065\000\ + \065\000\065\000\065\000\065\000\065\000\065\000\065\000\065\000\ + \065\000\065\000\065\000\065\000\065\000\065\000\067\000\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\067\000\ + \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\255\255\255\255\255\255\255\255\067\000\255\255\ + \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\068\000\255\255\255\255\255\255\068\000\255\255\ + \068\000\255\255\255\255\068\000\068\000\068\000\068\000\068\000\ + \068\000\068\000\068\000\068\000\068\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\068\000\068\000\068\000\068\000\ + \068\000\068\000\068\000\068\000\068\000\068\000\068\000\068\000\ + \068\000\068\000\068\000\068\000\068\000\068\000\068\000\068\000\ + \068\000\068\000\068\000\068\000\068\000\068\000\255\255\255\255\ + \255\255\255\255\068\000\255\255\068\000\068\000\068\000\068\000\ + \068\000\068\000\068\000\068\000\068\000\068\000\068\000\068\000\ + \068\000\068\000\068\000\068\000\068\000\068\000\068\000\068\000\ + \068\000\068\000\068\000\068\000\068\000\068\000\069\000\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\069\000\ + \069\000\069\000\069\000\069\000\069\000\069\000\069\000\069\000\ + \069\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \069\000\069\000\069\000\069\000\069\000\069\000\069\000\069\000\ + \069\000\069\000\069\000\069\000\069\000\069\000\069\000\069\000\ + \069\000\069\000\069\000\069\000\069\000\069\000\069\000\069\000\ + \069\000\069\000\255\255\255\255\255\255\255\255\069\000\255\255\ + \069\000\069\000\069\000\069\000\069\000\069\000\069\000\069\000\ + \069\000\069\000\069\000\069\000\069\000\069\000\069\000\069\000\ + \069\000\069\000\069\000\069\000\069\000\069\000\069\000\069\000\ + \069\000\069\000\070\000\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\070\000\070\000\070\000\070\000\070\000\ + \070\000\070\000\070\000\070\000\070\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\070\000\070\000\070\000\070\000\ + \070\000\070\000\070\000\070\000\070\000\070\000\070\000\070\000\ + \070\000\070\000\070\000\070\000\070\000\070\000\070\000\070\000\ + \070\000\070\000\070\000\070\000\070\000\070\000\255\255\255\255\ + \255\255\255\255\070\000\255\255\070\000\070\000\070\000\070\000\ + \070\000\070\000\070\000\070\000\070\000\070\000\070\000\070\000\ + \070\000\070\000\070\000\070\000\070\000\070\000\070\000\070\000\ + \070\000\070\000\070\000\070\000\070\000\070\000\071\000\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\071\000\ + \071\000\071\000\071\000\071\000\071\000\071\000\071\000\071\000\ + \071\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \071\000\071\000\071\000\071\000\071\000\071\000\071\000\071\000\ + \071\000\071\000\071\000\071\000\071\000\071\000\071\000\071\000\ + \071\000\071\000\071\000\071\000\071\000\071\000\071\000\071\000\ + \071\000\071\000\255\255\255\255\255\255\255\255\071\000\255\255\ + \071\000\071\000\071\000\071\000\071\000\071\000\071\000\071\000\ + \071\000\071\000\071\000\071\000\071\000\071\000\071\000\071\000\ + \071\000\071\000\071\000\071\000\071\000\071\000\071\000\071\000\ + \071\000\071\000\076\000\103\000\076\000\255\255\103\000\103\000\ + \103\000\076\000\255\255\255\255\103\000\103\000\255\255\103\000\ + \103\000\103\000\076\000\076\000\076\000\076\000\076\000\076\000\ + \076\000\076\000\076\000\076\000\103\000\255\255\103\000\103\000\ + \103\000\103\000\103\000\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\105\000\255\255\105\000\105\000\105\000\105\000\ + \255\255\255\255\255\255\105\000\105\000\255\255\105\000\105\000\ + \105\000\255\255\255\255\255\255\255\255\255\255\076\000\255\255\ + \103\000\255\255\255\255\105\000\076\000\105\000\105\000\105\000\ + \105\000\105\000\255\255\255\255\255\255\255\255\255\255\255\255\ + \076\000\076\000\255\255\255\255\076\000\255\255\076\000\255\255\ + \116\000\255\255\076\000\116\000\116\000\116\000\103\000\255\255\ + \103\000\116\000\116\000\255\255\116\000\116\000\116\000\105\000\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\116\000\255\255\116\000\116\000\116\000\116\000\116\000\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\117\000\ + \255\255\255\255\117\000\117\000\117\000\105\000\255\255\105\000\ + \117\000\117\000\255\255\117\000\117\000\117\000\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\116\000\255\255\255\255\ + \117\000\255\255\117\000\117\000\117\000\117\000\117\000\255\255\ + \255\255\255\255\118\000\255\255\255\255\118\000\118\000\118\000\ + \255\255\255\255\255\255\118\000\118\000\255\255\118\000\118\000\ + \118\000\255\255\255\255\116\000\255\255\116\000\255\255\255\255\ + \255\255\255\255\255\255\118\000\117\000\118\000\118\000\118\000\ + \118\000\118\000\255\255\255\255\255\255\255\255\255\255\255\255\ + \119\000\255\255\255\255\119\000\119\000\119\000\255\255\255\255\ + \255\255\119\000\119\000\255\255\119\000\119\000\119\000\255\255\ + \255\255\255\255\117\000\255\255\117\000\255\255\255\255\118\000\ + \255\255\119\000\076\000\119\000\119\000\119\000\119\000\119\000\ + \255\255\255\255\255\255\120\000\255\255\255\255\120\000\120\000\ + \120\000\255\255\255\255\255\255\120\000\120\000\255\255\120\000\ + \120\000\120\000\255\255\255\255\255\255\118\000\255\255\118\000\ + \255\255\255\255\255\255\255\255\120\000\119\000\120\000\120\000\ + \120\000\120\000\120\000\255\255\255\255\255\255\126\000\255\255\ + \255\255\126\000\126\000\126\000\255\255\255\255\255\255\126\000\ + \126\000\255\255\126\000\126\000\126\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\119\000\255\255\119\000\255\255\126\000\ + \120\000\126\000\126\000\126\000\126\000\126\000\255\255\255\255\ + \255\255\136\000\255\255\255\255\136\000\136\000\136\000\255\255\ + \255\255\255\255\136\000\136\000\255\255\136\000\136\000\136\000\ + \255\255\255\255\255\255\255\255\255\255\255\255\120\000\255\255\ + \120\000\255\255\136\000\126\000\136\000\136\000\136\000\136\000\ + \136\000\255\255\255\255\255\255\139\000\255\255\255\255\139\000\ + \139\000\139\000\255\255\255\255\255\255\139\000\139\000\255\255\ + \139\000\139\000\139\000\255\255\255\255\255\255\255\255\255\255\ + \255\255\126\000\255\255\126\000\255\255\139\000\136\000\139\000\ + \139\000\139\000\139\000\139\000\255\255\255\255\255\255\140\000\ + \255\255\255\255\140\000\140\000\140\000\255\255\255\255\255\255\ + \140\000\140\000\255\255\140\000\140\000\140\000\255\255\255\255\ + \255\255\255\255\255\255\255\255\136\000\255\255\136\000\255\255\ + \140\000\139\000\140\000\140\000\140\000\140\000\140\000\255\255\ + \255\255\255\255\141\000\255\255\255\255\141\000\141\000\141\000\ + \255\255\255\255\255\255\141\000\141\000\255\255\141\000\141\000\ + \141\000\255\255\255\255\255\255\255\255\255\255\255\255\139\000\ + \255\255\139\000\255\255\141\000\140\000\141\000\141\000\141\000\ + \141\000\141\000\255\255\255\255\255\255\142\000\255\255\255\255\ + \142\000\142\000\142\000\255\255\255\255\255\255\142\000\142\000\ + \255\255\142\000\142\000\142\000\255\255\255\255\157\000\255\255\ + \157\000\255\255\140\000\255\255\140\000\157\000\142\000\141\000\ + \142\000\142\000\142\000\142\000\142\000\255\255\157\000\157\000\ + \157\000\157\000\157\000\157\000\157\000\157\000\157\000\157\000\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\141\000\255\255\141\000\ + \255\255\255\255\142\000\255\255\255\255\255\255\255\255\255\255\ + \255\255\180\000\255\255\255\255\180\000\255\255\255\255\255\255\ + \255\255\255\255\157\000\255\255\255\255\255\255\255\255\255\255\ + \157\000\255\255\255\255\255\255\255\255\255\255\255\255\180\000\ + \142\000\180\000\142\000\255\255\157\000\255\255\180\000\255\255\ + \157\000\255\255\157\000\255\255\255\255\255\255\157\000\180\000\ + \180\000\180\000\180\000\180\000\180\000\180\000\180\000\180\000\ + \180\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\199\000\199\000\199\000\199\000\199\000\199\000\199\000\ + \199\000\199\000\199\000\180\000\255\255\255\255\255\255\255\255\ + \255\255\180\000\199\000\199\000\199\000\199\000\199\000\199\000\ + \255\255\255\255\255\255\255\255\255\255\180\000\180\000\255\255\ + \255\255\180\000\255\255\180\000\180\000\255\255\255\255\180\000\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\199\000\199\000\199\000\199\000\199\000\199\000\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\199\000\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\180\000\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255"; + Lexing.lex_base_code = + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\010\000\036\000\022\000\000\000\000\000\000\000\ + \005\000\000\000\039\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\002\000\005\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000"; + Lexing.lex_backtrk_code = + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\053\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000"; + Lexing.lex_default_code = + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\031\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000"; + Lexing.lex_trans_code = + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\001\000\000\000\050\000\050\000\000\000\009\000\050\000\ + \000\000\000\000\000\000\009\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \001\000\000\000\009\000\001\000\000\000\009\000\000\000\034\000\ + \000\000\000\000\009\000\000\000\012\000\001\000\000\000\000\000\ + \004\000\004\000\004\000\004\000\004\000\004\000\004\000\004\000\ + \004\000\004\000\017\000\017\000\017\000\017\000\017\000\017\000\ + \017\000\017\000\017\000\017\000\001\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\017\000\017\000\017\000\017\000\ + \017\000\017\000\017\000\017\000\017\000\017\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000"; + Lexing.lex_check_code = + "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\024\000\111\000\180\000\189\000\111\000\112\000\190\000\ + \255\255\255\255\255\255\106\000\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \024\000\255\255\111\000\000\000\255\255\112\000\255\255\112\000\ + \255\255\255\255\106\000\255\255\106\000\107\000\255\255\255\255\ + \024\000\024\000\024\000\024\000\024\000\024\000\024\000\024\000\ + \024\000\024\000\106\000\106\000\106\000\106\000\106\000\106\000\ + \106\000\106\000\106\000\106\000\107\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\107\000\107\000\107\000\107\000\ + \107\000\107\000\107\000\107\000\107\000\107\000\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \111\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255"; + Lexing.lex_code = + "\255\005\255\255\007\255\006\255\255\007\255\255\009\255\008\255\ + \255\006\255\007\255\255\004\255\000\005\001\006\002\007\255\009\ + \255\255\008\255\009\255\255\000\005\001\006\004\008\003\009\002\ + \007\255\001\255\255\000\001\255"; +} -(* Value expressions for the class language *) +let rec token lexbuf = + lexbuf.Lexing.lex_mem <- Array.make 10 (-1); __ocaml_lex_token_rec lexbuf 0 +and __ocaml_lex_token_rec lexbuf __ocaml_lex_state = + match Lexing.new_engine __ocaml_lex_tables __ocaml_lex_state lexbuf with + | 0 -> +# 770 "parsing/lexer.mll" + ( + if not !escaped_newlines then + raise (Error(Illegal_character (Lexing.lexeme_char lexbuf 0), + Location.curr lexbuf)); + update_loc lexbuf None 1 false 0; + token lexbuf ) +# 2358 "parsing/lexer.ml" -and class_expr = - { - cl_desc: class_expr_desc; - cl_loc: Location.t; - cl_type: Types.class_type; - cl_env: Env.t; - cl_attributes: attributes; - } + | 1 -> +# 777 "parsing/lexer.mll" + ( update_loc lexbuf None 1 false 0; + EOL ) +# 2364 "parsing/lexer.ml" -and class_expr_desc = - Tcl_ident of Path.t * Longident.t loc * core_type list - | Tcl_structure of class_structure - | Tcl_fun of - arg_label * pattern * (Ident.t * string loc * expression) list - * class_expr * partial - | Tcl_apply of class_expr * (arg_label * expression option) list - | Tcl_let of rec_flag * value_binding list * - (Ident.t * string loc * expression) list * class_expr - | Tcl_constraint of - class_expr * class_type option * string list * string list * Concr.t - (* Visible instance variables, methods and concrete methods *) - | Tcl_open of override_flag * Path.t * Longident.t loc * Env.t * class_expr + | 2 -> +# 780 "parsing/lexer.mll" + ( token lexbuf ) +# 2369 "parsing/lexer.ml" -and class_structure = - { - cstr_self: pattern; - cstr_fields: class_field list; - cstr_type: Types.class_signature; - cstr_meths: Ident.t Meths.t; - } + | 3 -> +# 782 "parsing/lexer.mll" + ( UNDERSCORE ) +# 2374 "parsing/lexer.ml" -and class_field = - { - cf_desc: class_field_desc; - cf_loc: Location.t; - cf_attributes: attributes; - } + | 4 -> +# 784 "parsing/lexer.mll" + ( TILDE ) +# 2379 "parsing/lexer.ml" -and class_field_kind = - | Tcfk_virtual of core_type - | Tcfk_concrete of override_flag * expression + | 5 -> +# 786 "parsing/lexer.mll" + ( LABEL (get_label_name lexbuf) ) +# 2384 "parsing/lexer.ml" -and class_field_desc = - Tcf_inherit of - override_flag * class_expr * string option * (string * Ident.t) list * - (string * Ident.t) list - (* Inherited instance variables and concrete methods *) - | Tcf_val of string loc * mutable_flag * Ident.t * class_field_kind * bool - | Tcf_method of string loc * private_flag * class_field_kind - | Tcf_constraint of core_type * core_type - | Tcf_initializer of expression - | Tcf_attribute of attribute + | 6 -> +# 788 "parsing/lexer.mll" + ( warn_latin1 lexbuf; LABEL (get_label_name lexbuf) ) +# 2389 "parsing/lexer.ml" -(* Value expressions for the module language *) + | 7 -> +# 790 "parsing/lexer.mll" + ( QUESTION ) +# 2394 "parsing/lexer.ml" -and module_expr = - { mod_desc: module_expr_desc; - mod_loc: Location.t; - mod_type: Types.module_type; - mod_env: Env.t; - mod_attributes: attributes; - } + | 8 -> +# 792 "parsing/lexer.mll" + ( OPTLABEL (get_label_name lexbuf) ) +# 2399 "parsing/lexer.ml" -(** Annotations for [Tmod_constraint]. *) -and module_type_constraint = - | Tmodtype_implicit - (** The module type constraint has been synthesized during typechecking. *) - | Tmodtype_explicit of module_type - (** The module type was in the source file. *) + | 9 -> +# 794 "parsing/lexer.mll" + ( warn_latin1 lexbuf; OPTLABEL (get_label_name lexbuf) ) +# 2404 "parsing/lexer.ml" -and module_expr_desc = - Tmod_ident of Path.t * Longident.t loc - | Tmod_structure of structure - | Tmod_functor of Ident.t * string loc * module_type option * module_expr - | Tmod_apply of module_expr * module_expr * module_coercion - | Tmod_constraint of - module_expr * Types.module_type * module_type_constraint * module_coercion - (** ME (constraint = Tmodtype_implicit) - (ME : MT) (constraint = Tmodtype_explicit MT) - *) - | Tmod_unpack of expression * Types.module_type + | 10 -> +# 796 "parsing/lexer.mll" + ( let s = Lexing.lexeme lexbuf in + try Hashtbl.find keyword_table s + with Not_found -> LIDENT s ) +# 2411 "parsing/lexer.ml" -and structure = { - str_items : structure_item list; - str_type : Types.signature; - str_final_env : Env.t; -} + | 11 -> +# 800 "parsing/lexer.mll" + ( warn_latin1 lexbuf; LIDENT (Lexing.lexeme lexbuf) ) +# 2416 "parsing/lexer.ml" -and structure_item = - { str_desc : structure_item_desc; - str_loc : Location.t; - str_env : Env.t - } + | 12 -> +# 802 "parsing/lexer.mll" + ( UIDENT(Lexing.lexeme lexbuf) ) +# 2421 "parsing/lexer.ml" -and structure_item_desc = - Tstr_eval of expression * attributes - | Tstr_value of rec_flag * value_binding list - | Tstr_primitive of value_description - | Tstr_type of rec_flag * type_declaration list - | Tstr_typext of type_extension - | Tstr_exception of extension_constructor - | Tstr_module of module_binding - | Tstr_recmodule of module_binding list - | Tstr_modtype of module_type_declaration - | Tstr_open of open_description - | Tstr_class of (class_declaration * string list) list - | Tstr_class_type of (Ident.t * string loc * class_type_declaration) list - | Tstr_include of include_declaration - | Tstr_attribute of attribute + | 13 -> +# 804 "parsing/lexer.mll" + ( warn_latin1 lexbuf; UIDENT(Lexing.lexeme lexbuf) ) +# 2426 "parsing/lexer.ml" -and module_binding = - { - mb_id: Ident.t; - mb_name: string loc; - mb_expr: module_expr; - mb_attributes: attributes; - mb_loc: Location.t; - } + | 14 -> +# 805 "parsing/lexer.mll" + ( INT (Lexing.lexeme lexbuf, None) ) +# 2431 "parsing/lexer.ml" -and value_binding = - { - vb_pat: pattern; - vb_expr: expression; - vb_attributes: attributes; - vb_loc: Location.t; - } + | 15 -> +let +# 806 "parsing/lexer.mll" + lit +# 2437 "parsing/lexer.ml" += Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_start_pos (lexbuf.Lexing.lex_curr_pos + -1) +and +# 806 "parsing/lexer.mll" + modif +# 2442 "parsing/lexer.ml" += Lexing.sub_lexeme_char lexbuf (lexbuf.Lexing.lex_curr_pos + -1) in +# 807 "parsing/lexer.mll" + ( INT (lit, Some modif) ) +# 2446 "parsing/lexer.ml" -and module_coercion = - Tcoerce_none - | Tcoerce_structure of (int * module_coercion) list * - (Ident.t * int * module_coercion) list * - string list (* runtime fields *) - | Tcoerce_functor of module_coercion * module_coercion - | Tcoerce_primitive of primitive_coercion - | Tcoerce_alias of Path.t * module_coercion + | 16 -> +# 809 "parsing/lexer.mll" + ( FLOAT (Lexing.lexeme lexbuf, None) ) +# 2451 "parsing/lexer.ml" -and module_type = - { mty_desc: module_type_desc; - mty_type : Types.module_type; - mty_env : Env.t; - mty_loc: Location.t; - mty_attributes: attributes; - } + | 17 -> +let +# 810 "parsing/lexer.mll" + lit +# 2457 "parsing/lexer.ml" += Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_start_pos (lexbuf.Lexing.lex_curr_pos + -1) +and +# 810 "parsing/lexer.mll" + modif +# 2462 "parsing/lexer.ml" += Lexing.sub_lexeme_char lexbuf (lexbuf.Lexing.lex_curr_pos + -1) in +# 811 "parsing/lexer.mll" + ( FLOAT (lit, Some modif) ) +# 2466 "parsing/lexer.ml" -and module_type_desc = - Tmty_ident of Path.t * Longident.t loc - | Tmty_signature of signature - | Tmty_functor of Ident.t * string loc * module_type option * module_type - | Tmty_with of module_type * (Path.t * Longident.t loc * with_constraint) list - | Tmty_typeof of module_expr - | Tmty_alias of Path.t * Longident.t loc + | 18 -> +# 813 "parsing/lexer.mll" + ( raise (Error(Invalid_literal (Lexing.lexeme lexbuf), + Location.curr lexbuf)) ) +# 2472 "parsing/lexer.ml" -and primitive_coercion = - { - pc_desc: Primitive.description; - pc_type: type_expr; - pc_env: Env.t; - pc_loc : Location.t; - - pc_id : Ident.t; - - } + | 19 -> +# 816 "parsing/lexer.mll" + ( reset_string_buffer(); + is_in_string := true; + let string_start = lexbuf.lex_start_p in + string_start_loc := Location.curr lexbuf; + string lexbuf; + is_in_string := false; + lexbuf.lex_start_p <- string_start; + STRING (get_stored_string(), None) ) +# 2484 "parsing/lexer.ml" -and signature = { - sig_items : signature_item list; - sig_type : Types.signature; - sig_final_env : Env.t; -} + | 20 -> +# 825 "parsing/lexer.mll" + ( reset_string_buffer(); + let delim = Lexing.lexeme lexbuf in + let delim = String.sub delim 1 (String.length delim - 2) in + is_in_string := true; + let string_start = lexbuf.lex_start_p in + string_start_loc := Location.curr lexbuf; + quoted_string delim lexbuf; + is_in_string := false; + lexbuf.lex_start_p <- string_start; + STRING (get_stored_string(), Some delim) ) +# 2498 "parsing/lexer.ml" -and signature_item = - { sig_desc: signature_item_desc; - sig_env : Env.t; (* BINANNOT ADDED *) - sig_loc: Location.t } + | 21 -> +# 836 "parsing/lexer.mll" + ( update_loc lexbuf None 1 false 1; + CHAR (Lexing.lexeme_char lexbuf 1) ) +# 2504 "parsing/lexer.ml" -and signature_item_desc = - Tsig_value of value_description - | Tsig_type of rec_flag * type_declaration list - | Tsig_typext of type_extension - | Tsig_exception of extension_constructor - | Tsig_module of module_declaration - | Tsig_recmodule of module_declaration list - | Tsig_modtype of module_type_declaration - | Tsig_open of open_description - | Tsig_include of include_description - | Tsig_class of class_description list - | Tsig_class_type of class_type_declaration list - | Tsig_attribute of attribute + | 22 -> +# 839 "parsing/lexer.mll" + ( CHAR(Lexing.lexeme_char lexbuf 1) ) +# 2509 "parsing/lexer.ml" -and module_declaration = - { - md_id: Ident.t; - md_name: string loc; - md_type: module_type; - md_attributes: attributes; - md_loc: Location.t; - } + | 23 -> +# 841 "parsing/lexer.mll" + ( CHAR(char_for_backslash (Lexing.lexeme_char lexbuf 2)) ) +# 2514 "parsing/lexer.ml" -and module_type_declaration = - { - mtd_id: Ident.t; - mtd_name: string loc; - mtd_type: module_type option; - mtd_attributes: attributes; - mtd_loc: Location.t; - } + | 24 -> +# 843 "parsing/lexer.mll" + ( CHAR(char_for_decimal_code lexbuf 2) ) +# 2519 "parsing/lexer.ml" -and open_description = - { - open_path: Path.t; - open_txt: Longident.t loc; - open_override: override_flag; - open_loc: Location.t; - open_attributes: attribute list; - } + | 25 -> +# 845 "parsing/lexer.mll" + ( CHAR(char_for_octal_code lexbuf 3) ) +# 2524 "parsing/lexer.ml" -and 'a include_infos = - { - incl_mod: 'a; - incl_type: Types.signature; - incl_loc: Location.t; - incl_attributes: attribute list; - } + | 26 -> +# 847 "parsing/lexer.mll" + ( CHAR(char_for_hexadecimal_code lexbuf 3) ) +# 2529 "parsing/lexer.ml" -and include_description = module_type include_infos + | 27 -> +# 849 "parsing/lexer.mll" + ( let l = Lexing.lexeme lexbuf in + let esc = String.sub l 1 (String.length l - 1) in + raise (Error(Illegal_escape esc, Location.curr lexbuf)) + ) +# 2537 "parsing/lexer.ml" -and include_declaration = module_expr include_infos + | 28 -> +# 854 "parsing/lexer.mll" + ( let s, loc = with_comment_buffer comment lexbuf in + COMMENT (s, loc) ) +# 2543 "parsing/lexer.ml" -and with_constraint = - Twith_type of type_declaration - | Twith_module of Path.t * Longident.t loc - | Twith_typesubst of type_declaration - | Twith_modsubst of Path.t * Longident.t loc + | 29 -> +# 857 "parsing/lexer.mll" + ( let s, loc = with_comment_buffer comment lexbuf in + if !handle_docstrings then + DOCSTRING (Docstrings.docstring s loc) + else + COMMENT ("*" ^ s, loc) + ) +# 2553 "parsing/lexer.ml" -and core_type = - { mutable ctyp_desc : core_type_desc; - (** mutable because of [Typeclass.declare_method] *) - mutable ctyp_type : type_expr; - (** mutable because of [Typeclass.declare_method] *) - ctyp_env : Env.t; (* BINANNOT ADDED *) - ctyp_loc : Location.t; - ctyp_attributes: attributes; - } + | 30 -> +let +# 863 "parsing/lexer.mll" + stars +# 2559 "parsing/lexer.ml" += Lexing.sub_lexeme lexbuf (lexbuf.Lexing.lex_start_pos + 3) lexbuf.Lexing.lex_curr_pos in +# 864 "parsing/lexer.mll" + ( let s, loc = + with_comment_buffer + (fun lexbuf -> + store_string ("*" ^ stars); + comment lexbuf) + lexbuf + in + COMMENT (s, loc) ) +# 2570 "parsing/lexer.ml" -and core_type_desc = - Ttyp_any - | Ttyp_var of string - | Ttyp_arrow of arg_label * core_type * core_type - | Ttyp_tuple of core_type list - | Ttyp_constr of Path.t * Longident.t loc * core_type list - | Ttyp_object of object_field list * closed_flag - | Ttyp_class of Path.t * Longident.t loc * core_type list - | Ttyp_alias of core_type * string - | Ttyp_variant of row_field list * closed_flag * label list option - | Ttyp_poly of string list * core_type - | Ttyp_package of package_type + | 31 -> +# 873 "parsing/lexer.mll" + ( if !print_warnings then + Location.prerr_warning (Location.curr lexbuf) Warnings.Comment_start; + let s, loc = with_comment_buffer comment lexbuf in + COMMENT (s, loc) ) +# 2578 "parsing/lexer.ml" -and package_type = { - pack_path : Path.t; - pack_fields : (Longident.t loc * core_type) list; - pack_type : Types.module_type; - pack_txt : Longident.t loc; -} + | 32 -> +let +# 877 "parsing/lexer.mll" + stars +# 2584 "parsing/lexer.ml" += Lexing.sub_lexeme lexbuf (lexbuf.Lexing.lex_start_pos + 2) (lexbuf.Lexing.lex_curr_pos + -2) in +# 878 "parsing/lexer.mll" + ( if !handle_docstrings && stars="" then + (* (**) is an empty docstring *) + DOCSTRING(Docstrings.docstring "" (Location.curr lexbuf)) + else + COMMENT (stars, Location.curr lexbuf) ) +# 2592 "parsing/lexer.ml" -and row_field = - Ttag of string loc * attributes * bool * core_type list - | Tinherit of core_type + | 33 -> +# 884 "parsing/lexer.mll" + ( let loc = Location.curr lexbuf in + Location.prerr_warning loc Warnings.Comment_not_end; + lexbuf.Lexing.lex_curr_pos <- lexbuf.Lexing.lex_curr_pos - 1; + let curpos = lexbuf.lex_curr_p in + lexbuf.lex_curr_p <- { curpos with pos_cnum = curpos.pos_cnum - 1 }; + STAR + ) +# 2603 "parsing/lexer.ml" -and object_field = - | OTtag of string loc * attributes * core_type - | OTinherit of core_type + | 34 -> +let +# 891 "parsing/lexer.mll" + num +# 2609 "parsing/lexer.ml" += Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_mem.(0) lexbuf.Lexing.lex_mem.(1) +and +# 892 "parsing/lexer.mll" + name +# 2614 "parsing/lexer.ml" += Lexing.sub_lexeme_opt lexbuf lexbuf.Lexing.lex_mem.(4) lexbuf.Lexing.lex_mem.(3) +and +# 892 "parsing/lexer.mll" + directive +# 2619 "parsing/lexer.ml" += Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_start_pos lexbuf.Lexing.lex_mem.(2) in +# 894 "parsing/lexer.mll" + ( + match int_of_string num with + | exception _ -> + (* PR#7165 *) + let loc = Location.curr lexbuf in + let explanation = "line number out of range" in + let error = Invalid_directive (directive, Some explanation) in + raise (Error (error, loc)) + | line_num -> + (* Documentation says that the line number should be + positive, but we have never guarded against this and it + might have useful hackish uses. *) + update_loc lexbuf name line_num true 0; + token lexbuf + ) +# 2637 "parsing/lexer.ml" -and value_description = - { val_id: Ident.t; - val_name: string loc; - val_desc: core_type; - val_val: Types.value_description; - val_prim: string list; - val_loc: Location.t; - val_attributes: attributes; - } + | 35 -> +# 909 "parsing/lexer.mll" + ( HASH ) +# 2642 "parsing/lexer.ml" -and type_declaration = - { - typ_id: Ident.t; - typ_name: string loc; - typ_params: (core_type * variance) list; - typ_type: Types.type_declaration; - typ_cstrs: (core_type * core_type * Location.t) list; - typ_kind: type_kind; - typ_private: private_flag; - typ_manifest: core_type option; - typ_loc: Location.t; - typ_attributes: attributes; - } + | 36 -> +# 910 "parsing/lexer.mll" + ( AMPERSAND ) +# 2647 "parsing/lexer.ml" -and type_kind = - Ttype_abstract - | Ttype_variant of constructor_declaration list - | Ttype_record of label_declaration list - | Ttype_open + | 37 -> +# 911 "parsing/lexer.mll" + ( AMPERAMPER ) +# 2652 "parsing/lexer.ml" -and label_declaration = - { - ld_id: Ident.t; - ld_name: string loc; - ld_mutable: mutable_flag; - ld_type: core_type; - ld_loc: Location.t; - ld_attributes: attributes; - } + | 38 -> +# 912 "parsing/lexer.mll" + ( BACKQUOTE ) +# 2657 "parsing/lexer.ml" -and constructor_declaration = - { - cd_id: Ident.t; - cd_name: string loc; - cd_args: constructor_arguments; - cd_res: core_type option; - cd_loc: Location.t; - cd_attributes: attributes; - } + | 39 -> +# 913 "parsing/lexer.mll" + ( QUOTE ) +# 2662 "parsing/lexer.ml" -and constructor_arguments = - | Cstr_tuple of core_type list - | Cstr_record of label_declaration list + | 40 -> +# 914 "parsing/lexer.mll" + ( LPAREN ) +# 2667 "parsing/lexer.ml" -and type_extension = - { - tyext_path: Path.t; - tyext_txt: Longident.t loc; - tyext_params: (core_type * variance) list; - tyext_constructors: extension_constructor list; - tyext_private: private_flag; - tyext_attributes: attributes; - } + | 41 -> +# 915 "parsing/lexer.mll" + ( RPAREN ) +# 2672 "parsing/lexer.ml" -and extension_constructor = - { - ext_id: Ident.t; - ext_name: string loc; - ext_type : Types.extension_constructor; - ext_kind : extension_constructor_kind; - ext_loc : Location.t; - ext_attributes: attributes; - } + | 42 -> +# 916 "parsing/lexer.mll" + ( STAR ) +# 2677 "parsing/lexer.ml" -and extension_constructor_kind = - Text_decl of constructor_arguments * core_type option - | Text_rebind of Path.t * Longident.t loc + | 43 -> +# 917 "parsing/lexer.mll" + ( COMMA ) +# 2682 "parsing/lexer.ml" -and class_type = - { - cltyp_desc: class_type_desc; - cltyp_type: Types.class_type; - cltyp_env: Env.t; - cltyp_loc: Location.t; - cltyp_attributes: attributes; - } + | 44 -> +# 918 "parsing/lexer.mll" + ( MINUSGREATER ) +# 2687 "parsing/lexer.ml" -and class_type_desc = - Tcty_constr of Path.t * Longident.t loc * core_type list - | Tcty_signature of class_signature - | Tcty_arrow of arg_label * core_type * class_type - | Tcty_open of override_flag * Path.t * Longident.t loc * Env.t * class_type + | 45 -> +# 919 "parsing/lexer.mll" + ( DOT ) +# 2692 "parsing/lexer.ml" -and class_signature = { - csig_self : core_type; - csig_fields : class_type_field list; - csig_type : Types.class_signature; - } + | 46 -> +# 920 "parsing/lexer.mll" + ( DOTDOT ) +# 2697 "parsing/lexer.ml" -and class_type_field = { - ctf_desc: class_type_field_desc; - ctf_loc: Location.t; - ctf_attributes: attributes; - } + | 47 -> +let +# 921 "parsing/lexer.mll" + s +# 2703 "parsing/lexer.ml" += Lexing.sub_lexeme lexbuf (lexbuf.Lexing.lex_start_pos + 1) lexbuf.Lexing.lex_curr_pos in +# 921 "parsing/lexer.mll" + ( DOTOP s ) +# 2707 "parsing/lexer.ml" -and class_type_field_desc = - | Tctf_inherit of class_type - | Tctf_val of (string * mutable_flag * virtual_flag * core_type) - | Tctf_method of (string * private_flag * virtual_flag * core_type) - | Tctf_constraint of (core_type * core_type) - | Tctf_attribute of attribute + | 48 -> +# 922 "parsing/lexer.mll" + ( COLON ) +# 2712 "parsing/lexer.ml" -and class_declaration = - class_expr class_infos + | 49 -> +# 923 "parsing/lexer.mll" + ( COLONCOLON ) +# 2717 "parsing/lexer.ml" -and class_description = - class_type class_infos + | 50 -> +# 924 "parsing/lexer.mll" + ( COLONEQUAL ) +# 2722 "parsing/lexer.ml" -and class_type_declaration = - class_type class_infos + | 51 -> +# 925 "parsing/lexer.mll" + ( COLONGREATER ) +# 2727 "parsing/lexer.ml" -and 'a class_infos = - { ci_virt: virtual_flag; - ci_params: (core_type * variance) list; - ci_id_name : string loc; - ci_id_class: Ident.t; - ci_id_class_type : Ident.t; - ci_id_object : Ident.t; - ci_id_typehash : Ident.t; - ci_expr: 'a; - ci_decl: Types.class_declaration; - ci_type_decl : Types.class_type_declaration; - ci_loc: Location.t; - ci_attributes: attributes; - } + | 52 -> +# 926 "parsing/lexer.mll" + ( SEMI ) +# 2732 "parsing/lexer.ml" -(* Auxiliary functions over the a.s.t. *) + | 53 -> +# 927 "parsing/lexer.mll" + ( SEMISEMI ) +# 2737 "parsing/lexer.ml" -val iter_pattern_desc: (pattern -> unit) -> pattern_desc -> unit -val map_pattern_desc: (pattern -> pattern) -> pattern_desc -> pattern_desc + | 54 -> +# 928 "parsing/lexer.mll" + ( LESS ) +# 2742 "parsing/lexer.ml" -val let_bound_idents: value_binding list -> Ident.t list -val rev_let_bound_idents: value_binding list -> Ident.t list + | 55 -> +# 929 "parsing/lexer.mll" + ( LESSMINUS ) +# 2747 "parsing/lexer.ml" -val let_bound_idents_with_loc: - value_binding list -> (Ident.t * string loc) list + | 56 -> +# 930 "parsing/lexer.mll" + ( EQUAL ) +# 2752 "parsing/lexer.ml" -(** Alpha conversion of patterns *) -val alpha_pat: (Ident.t * Ident.t) list -> pattern -> pattern + | 57 -> +# 931 "parsing/lexer.mll" + ( LBRACKET ) +# 2757 "parsing/lexer.ml" -val mknoloc: 'a -> 'a Asttypes.loc -val mkloc: 'a -> Location.t -> 'a Asttypes.loc + | 58 -> +# 932 "parsing/lexer.mll" + ( LBRACKETBAR ) +# 2762 "parsing/lexer.ml" -val pat_bound_idents: pattern -> Ident.t list + | 59 -> +# 933 "parsing/lexer.mll" + ( LBRACKETLESS ) +# 2767 "parsing/lexer.ml" -end = struct -#1 "typedtree.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) + | 60 -> +# 934 "parsing/lexer.mll" + ( LBRACKETGREATER ) +# 2772 "parsing/lexer.ml" -(* Abstract syntax tree after typing *) + | 61 -> +# 935 "parsing/lexer.mll" + ( RBRACKET ) +# 2777 "parsing/lexer.ml" -open Misc -open Asttypes -open Types + | 62 -> +# 936 "parsing/lexer.mll" + ( LBRACE ) +# 2782 "parsing/lexer.ml" -(* Value expressions for the core language *) + | 63 -> +# 937 "parsing/lexer.mll" + ( LBRACELESS ) +# 2787 "parsing/lexer.ml" -type partial = Partial | Total + | 64 -> +# 938 "parsing/lexer.mll" + ( BAR ) +# 2792 "parsing/lexer.ml" -type attribute = Parsetree.attribute -type attributes = attribute list + | 65 -> +# 939 "parsing/lexer.mll" + ( BARBAR ) +# 2797 "parsing/lexer.ml" -type pattern = - { pat_desc: pattern_desc; - pat_loc: Location.t; - pat_extra : (pat_extra * Location.t * attribute list) list; - pat_type: type_expr; - mutable pat_env: Env.t; - pat_attributes: attribute list; - } + | 66 -> +# 940 "parsing/lexer.mll" + ( BARRBRACKET ) +# 2802 "parsing/lexer.ml" -and pat_extra = - | Tpat_constraint of core_type - | Tpat_type of Path.t * Longident.t loc - | Tpat_open of Path.t * Longident.t loc * Env.t - | Tpat_unpack + | 67 -> +# 941 "parsing/lexer.mll" + ( GREATER ) +# 2807 "parsing/lexer.ml" -and pattern_desc = - Tpat_any - | Tpat_var of Ident.t * string loc - | Tpat_alias of pattern * Ident.t * string loc - | Tpat_constant of constant - | Tpat_tuple of pattern list - | Tpat_construct of - Longident.t loc * constructor_description * pattern list - | Tpat_variant of label * pattern option * row_desc ref - | Tpat_record of - (Longident.t loc * label_description * pattern) list * - closed_flag - | Tpat_array of pattern list - | Tpat_or of pattern * pattern * row_desc option - | Tpat_lazy of pattern + | 68 -> +# 942 "parsing/lexer.mll" + ( GREATERRBRACKET ) +# 2812 "parsing/lexer.ml" -and expression = - { exp_desc: expression_desc; - exp_loc: Location.t; - exp_extra: (exp_extra * Location.t * attribute list) list; - exp_type: type_expr; - exp_env: Env.t; - exp_attributes: attribute list; - } + | 69 -> +# 943 "parsing/lexer.mll" + ( RBRACE ) +# 2817 "parsing/lexer.ml" + + | 70 -> +# 944 "parsing/lexer.mll" + ( GREATERRBRACE ) +# 2822 "parsing/lexer.ml" -and exp_extra = - | Texp_constraint of core_type - | Texp_coerce of core_type option * core_type - | Texp_open of override_flag * Path.t * Longident.t loc * Env.t - | Texp_poly of core_type option - | Texp_newtype of string + | 71 -> +# 945 "parsing/lexer.mll" + ( LBRACKETAT ) +# 2827 "parsing/lexer.ml" -and expression_desc = - Texp_ident of Path.t * Longident.t loc * Types.value_description - | Texp_constant of constant - | Texp_let of rec_flag * value_binding list * expression - | Texp_function of { arg_label : arg_label; param : Ident.t; - cases : case list; partial : partial; } - | Texp_apply of expression * (arg_label * expression option) list - | Texp_match of expression * case list * case list * partial - | Texp_try of expression * case list - | Texp_tuple of expression list - | Texp_construct of - Longident.t loc * constructor_description * expression list - | Texp_variant of label * expression option - | Texp_record of { - fields : ( Types.label_description * record_label_definition ) array; - representation : Types.record_representation; - extended_expression : expression option; - } - | Texp_field of expression * Longident.t loc * label_description - | Texp_setfield of - expression * Longident.t loc * label_description * expression - | Texp_array of expression list - | Texp_ifthenelse of expression * expression * expression option - | Texp_sequence of expression * expression - | Texp_while of expression * expression - | Texp_for of - Ident.t * Parsetree.pattern * expression * expression * direction_flag * - expression - | Texp_send of expression * meth * expression option - | Texp_new of Path.t * Longident.t loc * Types.class_declaration - | Texp_instvar of Path.t * Path.t * string loc - | Texp_setinstvar of Path.t * Path.t * string loc * expression - | Texp_override of Path.t * (Path.t * string loc * expression) list - | Texp_letmodule of Ident.t * string loc * module_expr * expression - | Texp_letexception of extension_constructor * expression - | Texp_assert of expression - | Texp_lazy of expression - | Texp_object of class_structure * string list - | Texp_pack of module_expr - | Texp_unreachable - | Texp_extension_constructor of Longident.t loc * Path.t + | 72 -> +# 946 "parsing/lexer.mll" + ( LBRACKETATAT ) +# 2832 "parsing/lexer.ml" -and meth = - Tmeth_name of string - | Tmeth_val of Ident.t + | 73 -> +# 947 "parsing/lexer.mll" + ( LBRACKETATATAT ) +# 2837 "parsing/lexer.ml" -and case = - { - c_lhs: pattern; - c_guard: expression option; - c_rhs: expression; - } + | 74 -> +# 948 "parsing/lexer.mll" + ( LBRACKETPERCENT ) +# 2842 "parsing/lexer.ml" -and record_label_definition = - | Kept of Types.type_expr - | Overridden of Longident.t loc * expression + | 75 -> +# 949 "parsing/lexer.mll" + ( LBRACKETPERCENTPERCENT ) +# 2847 "parsing/lexer.ml" -(* Value expressions for the class language *) + | 76 -> +# 950 "parsing/lexer.mll" + ( BANG ) +# 2852 "parsing/lexer.ml" -and class_expr = - { - cl_desc: class_expr_desc; - cl_loc: Location.t; - cl_type: Types.class_type; - cl_env: Env.t; - cl_attributes: attribute list; - } + | 77 -> +# 951 "parsing/lexer.mll" + ( INFIXOP0 "!=" ) +# 2857 "parsing/lexer.ml" -and class_expr_desc = - Tcl_ident of Path.t * Longident.t loc * core_type list - | Tcl_structure of class_structure - | Tcl_fun of - arg_label * pattern * (Ident.t * string loc * expression) list - * class_expr * partial - | Tcl_apply of class_expr * (arg_label * expression option) list - | Tcl_let of rec_flag * value_binding list * - (Ident.t * string loc * expression) list * class_expr - | Tcl_constraint of - class_expr * class_type option * string list * string list * Concr.t - (* Visible instance variables, methods and concrete methods *) - | Tcl_open of override_flag * Path.t * Longident.t loc * Env.t * class_expr + | 78 -> +# 952 "parsing/lexer.mll" + ( PLUS ) +# 2862 "parsing/lexer.ml" -and class_structure = - { - cstr_self: pattern; - cstr_fields: class_field list; - cstr_type: Types.class_signature; - cstr_meths: Ident.t Meths.t; - } + | 79 -> +# 953 "parsing/lexer.mll" + ( PLUSDOT ) +# 2867 "parsing/lexer.ml" -and class_field = - { - cf_desc: class_field_desc; - cf_loc: Location.t; - cf_attributes: attribute list; - } + | 80 -> +# 954 "parsing/lexer.mll" + ( PLUSEQ ) +# 2872 "parsing/lexer.ml" -and class_field_kind = - | Tcfk_virtual of core_type - | Tcfk_concrete of override_flag * expression + | 81 -> +# 955 "parsing/lexer.mll" + ( MINUS ) +# 2877 "parsing/lexer.ml" -and class_field_desc = - Tcf_inherit of - override_flag * class_expr * string option * (string * Ident.t) list * - (string * Ident.t) list - (* Inherited instance variables and concrete methods *) - | Tcf_val of string loc * mutable_flag * Ident.t * class_field_kind * bool - | Tcf_method of string loc * private_flag * class_field_kind - | Tcf_constraint of core_type * core_type - | Tcf_initializer of expression - | Tcf_attribute of attribute + | 82 -> +# 956 "parsing/lexer.mll" + ( MINUSDOT ) +# 2882 "parsing/lexer.ml" -(* Value expressions for the module language *) + | 83 -> +# 959 "parsing/lexer.mll" + ( PREFIXOP(Lexing.lexeme lexbuf) ) +# 2887 "parsing/lexer.ml" -and module_expr = - { mod_desc: module_expr_desc; - mod_loc: Location.t; - mod_type: Types.module_type; - mod_env: Env.t; - mod_attributes: attribute list; - } + | 84 -> +# 961 "parsing/lexer.mll" + ( PREFIXOP(Lexing.lexeme lexbuf) ) +# 2892 "parsing/lexer.ml" -and module_type_constraint = - Tmodtype_implicit -| Tmodtype_explicit of module_type + | 85 -> +# 963 "parsing/lexer.mll" + ( INFIXOP0(Lexing.lexeme lexbuf) ) +# 2897 "parsing/lexer.ml" -and module_expr_desc = - Tmod_ident of Path.t * Longident.t loc - | Tmod_structure of structure - | Tmod_functor of Ident.t * string loc * module_type option * module_expr - | Tmod_apply of module_expr * module_expr * module_coercion - | Tmod_constraint of - module_expr * Types.module_type * module_type_constraint * module_coercion - | Tmod_unpack of expression * Types.module_type + | 86 -> +# 965 "parsing/lexer.mll" + ( INFIXOP1(Lexing.lexeme lexbuf) ) +# 2902 "parsing/lexer.ml" -and structure = { - str_items : structure_item list; - str_type : Types.signature; - str_final_env : Env.t; -} + | 87 -> +# 967 "parsing/lexer.mll" + ( INFIXOP2(Lexing.lexeme lexbuf) ) +# 2907 "parsing/lexer.ml" -and structure_item = - { str_desc : structure_item_desc; - str_loc : Location.t; - str_env : Env.t - } + | 88 -> +# 969 "parsing/lexer.mll" + ( INFIXOP4(Lexing.lexeme lexbuf) ) +# 2912 "parsing/lexer.ml" -and structure_item_desc = - Tstr_eval of expression * attributes - | Tstr_value of rec_flag * value_binding list - | Tstr_primitive of value_description - | Tstr_type of rec_flag * type_declaration list - | Tstr_typext of type_extension - | Tstr_exception of extension_constructor - | Tstr_module of module_binding - | Tstr_recmodule of module_binding list - | Tstr_modtype of module_type_declaration - | Tstr_open of open_description - | Tstr_class of (class_declaration * string list) list - | Tstr_class_type of (Ident.t * string loc * class_type_declaration) list - | Tstr_include of include_declaration - | Tstr_attribute of attribute + | 89 -> +# 970 "parsing/lexer.mll" + ( PERCENT ) +# 2917 "parsing/lexer.ml" -and module_binding = - { - mb_id: Ident.t; - mb_name: string loc; - mb_expr: module_expr; - mb_attributes: attribute list; - mb_loc: Location.t; - } + | 90 -> +# 972 "parsing/lexer.mll" + ( INFIXOP3(Lexing.lexeme lexbuf) ) +# 2922 "parsing/lexer.ml" -and value_binding = - { - vb_pat: pattern; - vb_expr: expression; - vb_attributes: attributes; - vb_loc: Location.t; - } + | 91 -> +# 974 "parsing/lexer.mll" + ( HASHOP(Lexing.lexeme lexbuf) ) +# 2927 "parsing/lexer.ml" -and module_coercion = - Tcoerce_none - | Tcoerce_structure of (int * module_coercion) list * - (Ident.t * int * module_coercion) list * - string list (* runtime fields *) - | Tcoerce_functor of module_coercion * module_coercion - | Tcoerce_primitive of primitive_coercion - | Tcoerce_alias of Path.t * module_coercion + | 92 -> +# 975 "parsing/lexer.mll" + ( + if !if_then_else <> Dir_out then + if !if_then_else = Dir_if_true then + raise (Error (Unterminated_if, Location.curr lexbuf)) + else raise (Error(Unterminated_else, Location.curr lexbuf)) + else + EOF -and module_type = - { mty_desc: module_type_desc; - mty_type : Types.module_type; - mty_env : Env.t; - mty_loc: Location.t; - mty_attributes: attribute list; - } + ) +# 2940 "parsing/lexer.ml" -and module_type_desc = - Tmty_ident of Path.t * Longident.t loc - | Tmty_signature of signature - | Tmty_functor of Ident.t * string loc * module_type option * module_type - | Tmty_with of module_type * (Path.t * Longident.t loc * with_constraint) list - | Tmty_typeof of module_expr - | Tmty_alias of Path.t * Longident.t loc + | 93 -> +# 985 "parsing/lexer.mll" + ( raise (Error(Illegal_character (Lexing.lexeme_char lexbuf 0), + Location.curr lexbuf)) + ) +# 2947 "parsing/lexer.ml" -(* Keep primitive type information for type-based lambda-code specialization *) -and primitive_coercion = - { - pc_desc: Primitive.description; - pc_type: type_expr; - pc_env: Env.t; - pc_loc : Location.t; - - pc_id : Ident.t; + | __ocaml_lex_state -> lexbuf.Lexing.refill_buff lexbuf; + __ocaml_lex_token_rec lexbuf __ocaml_lex_state - } +and comment lexbuf = + __ocaml_lex_comment_rec lexbuf 143 +and __ocaml_lex_comment_rec lexbuf __ocaml_lex_state = + match Lexing.engine __ocaml_lex_tables __ocaml_lex_state lexbuf with + | 0 -> +# 991 "parsing/lexer.mll" + ( comment_start_loc := (Location.curr lexbuf) :: !comment_start_loc; + store_lexeme lexbuf; + comment lexbuf + ) +# 2962 "parsing/lexer.ml" -and signature = { - sig_items : signature_item list; - sig_type : Types.signature; - sig_final_env : Env.t; -} + | 1 -> +# 996 "parsing/lexer.mll" + ( match !comment_start_loc with + | [] -> assert false + | [_] -> comment_start_loc := []; Location.curr lexbuf + | _ :: l -> comment_start_loc := l; + store_lexeme lexbuf; + comment lexbuf + ) +# 2973 "parsing/lexer.ml" -and signature_item = - { sig_desc: signature_item_desc; - sig_env : Env.t; (* BINANNOT ADDED *) - sig_loc: Location.t } + | 2 -> +# 1004 "parsing/lexer.mll" + ( + string_start_loc := Location.curr lexbuf; + store_string_char '\"'; + is_in_string := true; + begin try string lexbuf + with Error (Unterminated_string, str_start) -> + match !comment_start_loc with + | [] -> assert false + | loc :: _ -> + let start = List.hd (List.rev !comment_start_loc) in + comment_start_loc := []; + raise (Error (Unterminated_string_in_comment (start, str_start), + loc)) + end; + is_in_string := false; + store_string_char '\"'; + comment lexbuf ) +# 2994 "parsing/lexer.ml" -and signature_item_desc = - Tsig_value of value_description - | Tsig_type of rec_flag * type_declaration list - | Tsig_typext of type_extension - | Tsig_exception of extension_constructor - | Tsig_module of module_declaration - | Tsig_recmodule of module_declaration list - | Tsig_modtype of module_type_declaration - | Tsig_open of open_description - | Tsig_include of include_description - | Tsig_class of class_description list - | Tsig_class_type of class_type_declaration list - | Tsig_attribute of attribute + | 3 -> +# 1022 "parsing/lexer.mll" + ( + let delim = Lexing.lexeme lexbuf in + let delim = String.sub delim 1 (String.length delim - 2) in + string_start_loc := Location.curr lexbuf; + store_lexeme lexbuf; + is_in_string := true; + begin try quoted_string delim lexbuf + with Error (Unterminated_string, str_start) -> + match !comment_start_loc with + | [] -> assert false + | loc :: _ -> + let start = List.hd (List.rev !comment_start_loc) in + comment_start_loc := []; + raise (Error (Unterminated_string_in_comment (start, str_start), + loc)) + end; + is_in_string := false; + store_string_char '|'; + store_string delim; + store_string_char '}'; + comment lexbuf ) +# 3019 "parsing/lexer.ml" -and module_declaration = - { - md_id: Ident.t; - md_name: string loc; - md_type: module_type; - md_attributes: attribute list; - md_loc: Location.t; - } + | 4 -> +# 1045 "parsing/lexer.mll" + ( store_lexeme lexbuf; comment lexbuf ) +# 3024 "parsing/lexer.ml" -and module_type_declaration = - { - mtd_id: Ident.t; - mtd_name: string loc; - mtd_type: module_type option; - mtd_attributes: attribute list; - mtd_loc: Location.t; - } + | 5 -> +# 1047 "parsing/lexer.mll" + ( update_loc lexbuf None 1 false 1; + store_lexeme lexbuf; + comment lexbuf + ) +# 3032 "parsing/lexer.ml" -and open_description = - { - open_path: Path.t; - open_txt: Longident.t loc; - open_override: override_flag; - open_loc: Location.t; - open_attributes: attribute list; - } + | 6 -> +# 1052 "parsing/lexer.mll" + ( store_lexeme lexbuf; comment lexbuf ) +# 3037 "parsing/lexer.ml" -and 'a include_infos = - { - incl_mod: 'a; - incl_type: Types.signature; - incl_loc: Location.t; - incl_attributes: attribute list; - } + | 7 -> +# 1054 "parsing/lexer.mll" + ( store_lexeme lexbuf; comment lexbuf ) +# 3042 "parsing/lexer.ml" -and include_description = module_type include_infos + | 8 -> +# 1056 "parsing/lexer.mll" + ( store_lexeme lexbuf; comment lexbuf ) +# 3047 "parsing/lexer.ml" -and include_declaration = module_expr include_infos + | 9 -> +# 1058 "parsing/lexer.mll" + ( store_lexeme lexbuf; comment lexbuf ) +# 3052 "parsing/lexer.ml" -and with_constraint = - Twith_type of type_declaration - | Twith_module of Path.t * Longident.t loc - | Twith_typesubst of type_declaration - | Twith_modsubst of Path.t * Longident.t loc + | 10 -> +# 1060 "parsing/lexer.mll" + ( match !comment_start_loc with + | [] -> assert false + | loc :: _ -> + let start = List.hd (List.rev !comment_start_loc) in + comment_start_loc := []; + raise (Error (Unterminated_comment start, loc)) + ) +# 3063 "parsing/lexer.ml" -and core_type = -(* mutable because of [Typeclass.declare_method] *) - { mutable ctyp_desc : core_type_desc; - mutable ctyp_type : type_expr; - ctyp_env : Env.t; (* BINANNOT ADDED *) - ctyp_loc : Location.t; - ctyp_attributes: attribute list; - } + | 11 -> +# 1068 "parsing/lexer.mll" + ( update_loc lexbuf None 1 false 0; + store_lexeme lexbuf; + comment lexbuf + ) +# 3071 "parsing/lexer.ml" -and core_type_desc = - Ttyp_any - | Ttyp_var of string - | Ttyp_arrow of arg_label * core_type * core_type - | Ttyp_tuple of core_type list - | Ttyp_constr of Path.t * Longident.t loc * core_type list - | Ttyp_object of object_field list * closed_flag - | Ttyp_class of Path.t * Longident.t loc * core_type list - | Ttyp_alias of core_type * string - | Ttyp_variant of row_field list * closed_flag * label list option - | Ttyp_poly of string list * core_type - | Ttyp_package of package_type + | 12 -> +# 1073 "parsing/lexer.mll" + ( store_lexeme lexbuf; comment lexbuf ) +# 3076 "parsing/lexer.ml" -and package_type = { - pack_path : Path.t; - pack_fields : (Longident.t loc * core_type) list; - pack_type : Types.module_type; - pack_txt : Longident.t loc; -} + | __ocaml_lex_state -> lexbuf.Lexing.refill_buff lexbuf; + __ocaml_lex_comment_rec lexbuf __ocaml_lex_state + +and string lexbuf = + lexbuf.Lexing.lex_mem <- Array.make 2 (-1); __ocaml_lex_string_rec lexbuf 175 +and __ocaml_lex_string_rec lexbuf __ocaml_lex_state = + match Lexing.new_engine __ocaml_lex_tables __ocaml_lex_state lexbuf with + | 0 -> +# 1077 "parsing/lexer.mll" + ( () ) +# 3088 "parsing/lexer.ml" -and row_field = - Ttag of string loc * attributes * bool * core_type list - | Tinherit of core_type + | 1 -> +let +# 1078 "parsing/lexer.mll" + space +# 3094 "parsing/lexer.ml" += Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_mem.(0) lexbuf.Lexing.lex_curr_pos in +# 1079 "parsing/lexer.mll" + ( update_loc lexbuf None 1 false (String.length space); + if in_comment () then store_lexeme lexbuf; + string lexbuf + ) +# 3101 "parsing/lexer.ml" -and object_field = - | OTtag of string loc * attributes * core_type - | OTinherit of core_type + | 2 -> +# 1084 "parsing/lexer.mll" + ( store_escaped_char lexbuf + (char_for_backslash(Lexing.lexeme_char lexbuf 1)); + string lexbuf ) +# 3108 "parsing/lexer.ml" -and value_description = - { val_id: Ident.t; - val_name: string loc; - val_desc: core_type; - val_val: Types.value_description; - val_prim: string list; - val_loc: Location.t; - val_attributes: attribute list; - } + | 3 -> +# 1088 "parsing/lexer.mll" + ( store_escaped_char lexbuf (char_for_decimal_code lexbuf 1); + string lexbuf ) +# 3114 "parsing/lexer.ml" -and type_declaration = - { typ_id: Ident.t; - typ_name: string loc; - typ_params: (core_type * variance) list; - typ_type: Types.type_declaration; - typ_cstrs: (core_type * core_type * Location.t) list; - typ_kind: type_kind; - typ_private: private_flag; - typ_manifest: core_type option; - typ_loc: Location.t; - typ_attributes: attribute list; - } + | 4 -> +# 1091 "parsing/lexer.mll" + ( store_escaped_char lexbuf (char_for_octal_code lexbuf 2); + string lexbuf ) +# 3120 "parsing/lexer.ml" -and type_kind = - Ttype_abstract - | Ttype_variant of constructor_declaration list - | Ttype_record of label_declaration list - | Ttype_open + | 5 -> +# 1094 "parsing/lexer.mll" + ( store_escaped_char lexbuf (char_for_hexadecimal_code lexbuf 2); + string lexbuf ) +# 3126 "parsing/lexer.ml" -and label_declaration = - { - ld_id: Ident.t; - ld_name: string loc; - ld_mutable: mutable_flag; - ld_type: core_type; - ld_loc: Location.t; - ld_attributes: attribute list; - } + | 6 -> +# 1097 "parsing/lexer.mll" + ( store_escaped_uchar lexbuf (uchar_for_uchar_escape lexbuf); + string lexbuf ) +# 3132 "parsing/lexer.ml" -and constructor_declaration = - { - cd_id: Ident.t; - cd_name: string loc; - cd_args: constructor_arguments; - cd_res: core_type option; - cd_loc: Location.t; - cd_attributes: attribute list; - } + | 7 -> +# 1100 "parsing/lexer.mll" + ( if not (in_comment ()) then begin +(* Should be an error, but we are very lax. + raise (Error (Illegal_escape (Lexing.lexeme lexbuf), + Location.curr lexbuf)) +*) + let loc = Location.curr lexbuf in + Location.prerr_warning loc Warnings.Illegal_backslash; + end; + store_lexeme lexbuf; + string lexbuf + ) +# 3147 "parsing/lexer.ml" -and constructor_arguments = - | Cstr_tuple of core_type list - | Cstr_record of label_declaration list + | 8 -> +# 1112 "parsing/lexer.mll" + ( if not (in_comment ()) then + Location.prerr_warning (Location.curr lexbuf) Warnings.Eol_in_string; + update_loc lexbuf None 1 false 0; + store_lexeme lexbuf; + string lexbuf + ) +# 3157 "parsing/lexer.ml" -and type_extension = - { - tyext_path: Path.t; - tyext_txt: Longident.t loc; - tyext_params: (core_type * variance) list; - tyext_constructors: extension_constructor list; - tyext_private: private_flag; - tyext_attributes: attribute list; - } + | 9 -> +# 1119 "parsing/lexer.mll" + ( is_in_string := false; + raise (Error (Unterminated_string, !string_start_loc)) ) +# 3163 "parsing/lexer.ml" -and extension_constructor = - { - ext_id: Ident.t; - ext_name: string loc; - ext_type: Types.extension_constructor; - ext_kind: extension_constructor_kind; - ext_loc: Location.t; - ext_attributes: attribute list; - } + | 10 -> +# 1122 "parsing/lexer.mll" + ( store_string_char(Lexing.lexeme_char lexbuf 0); + string lexbuf ) +# 3169 "parsing/lexer.ml" -and extension_constructor_kind = - Text_decl of constructor_arguments * core_type option - | Text_rebind of Path.t * Longident.t loc + | __ocaml_lex_state -> lexbuf.Lexing.refill_buff lexbuf; + __ocaml_lex_string_rec lexbuf __ocaml_lex_state -and class_type = - { - cltyp_desc: class_type_desc; - cltyp_type: Types.class_type; - cltyp_env: Env.t; - cltyp_loc: Location.t; - cltyp_attributes: attribute list; - } +and quoted_string delim lexbuf = + __ocaml_lex_quoted_string_rec delim lexbuf 202 +and __ocaml_lex_quoted_string_rec delim lexbuf __ocaml_lex_state = + match Lexing.engine __ocaml_lex_tables __ocaml_lex_state lexbuf with + | 0 -> +# 1127 "parsing/lexer.mll" + ( update_loc lexbuf None 1 false 0; + store_lexeme lexbuf; + quoted_string delim lexbuf + ) +# 3184 "parsing/lexer.ml" -and class_type_desc = - Tcty_constr of Path.t * Longident.t loc * core_type list - | Tcty_signature of class_signature - | Tcty_arrow of arg_label * core_type * class_type - | Tcty_open of override_flag * Path.t * Longident.t loc * Env.t * class_type + | 1 -> +# 1132 "parsing/lexer.mll" + ( is_in_string := false; + raise (Error (Unterminated_string, !string_start_loc)) ) +# 3190 "parsing/lexer.ml" -and class_signature = { - csig_self: core_type; - csig_fields: class_type_field list; - csig_type: Types.class_signature; - } + | 2 -> +# 1135 "parsing/lexer.mll" + ( + let edelim = Lexing.lexeme lexbuf in + let edelim = String.sub edelim 1 (String.length edelim - 2) in + if delim = edelim then () + else (store_lexeme lexbuf; quoted_string delim lexbuf) + ) +# 3200 "parsing/lexer.ml" -and class_type_field = { - ctf_desc: class_type_field_desc; - ctf_loc: Location.t; - ctf_attributes: attribute list; - } + | 3 -> +# 1142 "parsing/lexer.mll" + ( store_string_char(Lexing.lexeme_char lexbuf 0); + quoted_string delim lexbuf ) +# 3206 "parsing/lexer.ml" -and class_type_field_desc = - | Tctf_inherit of class_type - | Tctf_val of (string * mutable_flag * virtual_flag * core_type) - | Tctf_method of (string * private_flag * virtual_flag * core_type) - | Tctf_constraint of (core_type * core_type) - | Tctf_attribute of attribute + | __ocaml_lex_state -> lexbuf.Lexing.refill_buff lexbuf; + __ocaml_lex_quoted_string_rec delim lexbuf __ocaml_lex_state -and class_declaration = - class_expr class_infos +and skip_hash_bang lexbuf = + __ocaml_lex_skip_hash_bang_rec lexbuf 211 +and __ocaml_lex_skip_hash_bang_rec lexbuf __ocaml_lex_state = + match Lexing.engine __ocaml_lex_tables __ocaml_lex_state lexbuf with + | 0 -> +# 1147 "parsing/lexer.mll" + ( update_loc lexbuf None 3 false 0 ) +# 3218 "parsing/lexer.ml" -and class_description = - class_type class_infos + | 1 -> +# 1149 "parsing/lexer.mll" + ( update_loc lexbuf None 1 false 0 ) +# 3223 "parsing/lexer.ml" -and class_type_declaration = - class_type class_infos + | 2 -> +# 1150 "parsing/lexer.mll" + ( () ) +# 3228 "parsing/lexer.ml" -and 'a class_infos = - { ci_virt: virtual_flag; - ci_params: (core_type * variance) list; - ci_id_name: string loc; - ci_id_class: Ident.t; - ci_id_class_type: Ident.t; - ci_id_object: Ident.t; - ci_id_typehash: Ident.t; - ci_expr: 'a; - ci_decl: Types.class_declaration; - ci_type_decl: Types.class_type_declaration; - ci_loc: Location.t; - ci_attributes: attribute list; - } + | __ocaml_lex_state -> lexbuf.Lexing.refill_buff lexbuf; + __ocaml_lex_skip_hash_bang_rec lexbuf __ocaml_lex_state -(* Auxiliary functions over the a.s.t. *) +;; -let iter_pattern_desc f = function - | Tpat_alias(p, _, _) -> f p - | Tpat_tuple patl -> List.iter f patl - | Tpat_construct(_, _, patl) -> List.iter f patl - | Tpat_variant(_, pat, _) -> may f pat - | Tpat_record (lbl_pat_list, _) -> - List.iter (fun (_, _, pat) -> f pat) lbl_pat_list - | Tpat_array patl -> List.iter f patl - | Tpat_or(p1, p2, _) -> f p1; f p2 - | Tpat_lazy p -> f p - | Tpat_any - | Tpat_var _ - | Tpat_constant _ -> () +# 1152 "parsing/lexer.mll" + + let at_bol lexbuf = + let pos = Lexing.lexeme_start_p lexbuf in + pos.pos_cnum = pos.pos_bol -let map_pattern_desc f d = - match d with - | Tpat_alias (p1, id, s) -> - Tpat_alias (f p1, id, s) - | Tpat_tuple pats -> - Tpat_tuple (List.map f pats) - | Tpat_record (lpats, closed) -> - Tpat_record (List.map (fun (lid, l,p) -> lid, l, f p) lpats, closed) - | Tpat_construct (lid, c,pats) -> - Tpat_construct (lid, c, List.map f pats) - | Tpat_array pats -> - Tpat_array (List.map f pats) - | Tpat_lazy p1 -> Tpat_lazy (f p1) - | Tpat_variant (x1, Some p1, x2) -> - Tpat_variant (x1, Some (f p1), x2) - | Tpat_or (p1,p2,path) -> - Tpat_or (f p1, f p2, path) - | Tpat_var _ - | Tpat_constant _ - | Tpat_any - | Tpat_variant (_,None,_) -> d + let token_with_comments lexbuf = + match !preprocessor with + | None -> token lexbuf + | Some (_init, preprocess) -> preprocess token lexbuf -(* List the identifiers bound by a pattern or a let *) + type newline_state = + | NoLine (* There have been no blank lines yet. *) + | NewLine + (* There have been no blank lines, and the previous + token was a newline. *) + | BlankLine (* There have been blank lines. *) -let idents = ref([]: (Ident.t * string loc) list) + type doc_state = + | Initial (* There have been no docstrings yet *) + | After of docstring list + (* There have been docstrings, none of which were + preceded by a blank line *) + | Before of docstring list * docstring list * docstring list + (* There have been docstrings, some of which were + preceded by a blank line *) -let rec bound_idents pat = - match pat.pat_desc with - | Tpat_var (id,s) -> idents := (id,s) :: !idents - | Tpat_alias(p, id, s ) -> - bound_idents p; idents := (id,s) :: !idents - | Tpat_or(p1, _, _) -> - (* Invariant : both arguments binds the same variables *) - bound_idents p1 - | d -> iter_pattern_desc bound_idents d + and docstring = Docstrings.docstring -let pat_bound_idents pat = - idents := []; - bound_idents pat; - let res = !idents in - idents := []; - List.map fst res + let interpret_directive lexbuf cont look_ahead = + let if_then_else = !if_then_else in + begin match token_with_comments lexbuf, if_then_else with + | IF, Dir_out -> + let rec skip_from_if_false () = + let token = token_with_comments lexbuf in + if token = EOF then + raise (Error (Unterminated_if, Location.curr lexbuf)) else + if token = HASH && at_bol lexbuf then + begin + let token = token_with_comments lexbuf in + match token with + | END -> + begin + update_if_then_else Dir_out; + cont lexbuf + end + | ELSE -> + begin + update_if_then_else Dir_if_false; + cont lexbuf + end + | IF -> + raise (Error (Unexpected_directive, Location.curr lexbuf)) + | _ -> + if is_elif token && + directive_parse token_with_comments lexbuf then + begin + update_if_then_else Dir_if_true; + cont lexbuf + end + else skip_from_if_false () + end + else skip_from_if_false () in + if directive_parse token_with_comments lexbuf then + begin + update_if_then_else Dir_if_true (* Next state: ELSE *); + cont lexbuf + end + else + skip_from_if_false () + | IF, (Dir_if_false | Dir_if_true)-> + raise (Error(Unexpected_directive, Location.curr lexbuf)) + | LIDENT "elif", (Dir_if_false | Dir_out) + -> (* when the predicate is false, it will continue eating `elif` *) + raise (Error(Unexpected_directive, Location.curr lexbuf)) + | (LIDENT "elif" | ELSE as token), Dir_if_true -> + (* looking for #end, however, it can not see #if anymore *) + let rec skip_from_if_true else_seen = + let token = token_with_comments lexbuf in + if token = EOF then + raise (Error (Unterminated_else, Location.curr lexbuf)) else + if token = HASH && at_bol lexbuf then + begin + let token = token_with_comments lexbuf in + match token with + | END -> + begin + update_if_then_else Dir_out; + cont lexbuf + end + | IF -> + raise (Error (Unexpected_directive, Location.curr lexbuf)) + | ELSE -> + if else_seen then + raise (Error (Unexpected_directive, Location.curr lexbuf)) + else + skip_from_if_true true + | _ -> + if else_seen && is_elif token then + raise (Error (Unexpected_directive, Location.curr lexbuf)) + else + skip_from_if_true else_seen + end + else skip_from_if_true else_seen in + skip_from_if_true (token = ELSE) + | ELSE, Dir_if_false + | ELSE, Dir_out -> + raise (Error(Unexpected_directive, Location.curr lexbuf)) + | END, (Dir_if_false | Dir_if_true ) -> + update_if_then_else Dir_out; + cont lexbuf + | END, Dir_out -> + raise (Error(Unexpected_directive, Location.curr lexbuf)) + | token, (Dir_if_true | Dir_if_false | Dir_out) -> + look_ahead token + end -let rev_let_bound_idents_with_loc bindings = - idents := []; - List.iter (fun vb -> bound_idents vb.vb_pat) bindings; - let res = !idents in idents := []; res + let token lexbuf = + let post_pos = lexeme_end_p lexbuf in + let attach lines docs pre_pos = + let open Docstrings in + match docs, lines with + | Initial, _ -> () + | After a, (NoLine | NewLine) -> + set_post_docstrings post_pos (List.rev a); + set_pre_docstrings pre_pos a; + | After a, BlankLine -> + set_post_docstrings post_pos (List.rev a); + set_pre_extra_docstrings pre_pos (List.rev a) + | Before(a, f, b), (NoLine | NewLine) -> + set_post_docstrings post_pos (List.rev a); + set_post_extra_docstrings post_pos + (List.rev_append f (List.rev b)); + set_floating_docstrings pre_pos (List.rev f); + set_pre_extra_docstrings pre_pos (List.rev a); + set_pre_docstrings pre_pos b + | Before(a, f, b), BlankLine -> + set_post_docstrings post_pos (List.rev a); + set_post_extra_docstrings post_pos + (List.rev_append f (List.rev b)); + set_floating_docstrings pre_pos + (List.rev_append f (List.rev b)); + set_pre_extra_docstrings pre_pos (List.rev a) + in + let rec loop lines docs lexbuf = + match token_with_comments lexbuf with + | COMMENT (s, loc) -> + add_comment (s, loc); + let lines' = + match lines with + | NoLine -> NoLine + | NewLine -> NoLine + | BlankLine -> BlankLine + in + loop lines' docs lexbuf + | EOL -> + let lines' = + match lines with + | NoLine -> NewLine + | NewLine -> BlankLine + | BlankLine -> BlankLine + in + loop lines' docs lexbuf + | HASH when at_bol lexbuf -> + interpret_directive lexbuf + (fun lexbuf -> loop lines docs lexbuf) + (fun token -> sharp_look_ahead := Some token; HASH) + | DOCSTRING doc -> + Docstrings.register doc; + add_docstring_comment doc; + let docs' = + if Docstrings.docstring_body doc = "/*" then + match docs with + | Initial -> Before([], [doc], []) + | After a -> Before (a, [doc], []) + | Before(a, f, b) -> Before(a, doc :: b @ f, []) + else + match docs, lines with + | Initial, (NoLine | NewLine) -> After [doc] + | Initial, BlankLine -> Before([], [], [doc]) + | After a, (NoLine | NewLine) -> After (doc :: a) + | After a, BlankLine -> Before (a, [], [doc]) + | Before(a, f, b), (NoLine | NewLine) -> Before(a, f, doc :: b) + | Before(a, f, b), BlankLine -> Before(a, b @ f, [doc]) + in + loop NoLine docs' lexbuf + | tok -> + attach lines docs (lexeme_start_p lexbuf); + tok + in + match !sharp_look_ahead with + | None -> + loop NoLine Initial lexbuf + | Some token -> + sharp_look_ahead := None ; + token -let let_bound_idents_with_loc pat_expr_list = - List.rev(rev_let_bound_idents_with_loc pat_expr_list) + let init () = + sharp_look_ahead := None; + update_if_then_else Dir_out; + is_in_string := false; + comment_start_loc := []; + comment_list := []; + match !preprocessor with + | None -> () + | Some (init, _preprocess) -> init () + + let rec filter_directive pos acc lexbuf : (int * int ) list = + match token_with_comments lexbuf with + | HASH when at_bol lexbuf -> + (* ^[start_pos]#if ... #then^[end_pos] *) + let start_pos = Lexing.lexeme_start lexbuf in + interpret_directive lexbuf + (fun lexbuf -> + filter_directive + (Lexing.lexeme_end lexbuf) + ((pos, start_pos) :: acc) + lexbuf + + ) + (fun _token -> filter_directive pos acc lexbuf ) + | EOF -> (pos, Lexing.lexeme_end lexbuf) :: acc + | _ -> filter_directive pos acc lexbuf -let rev_let_bound_idents pat = List.map fst (rev_let_bound_idents_with_loc pat) -let let_bound_idents pat = List.map fst (let_bound_idents_with_loc pat) + let filter_directive_from_lexbuf lexbuf = + List.rev (filter_directive 0 [] lexbuf ) -let alpha_var env id = List.assoc id env + let set_preprocessor init preprocess = + escaped_newlines := true; + preprocessor := Some (init, preprocess) -let rec alpha_pat env p = match p.pat_desc with -| Tpat_var (id, s) -> (* note the ``Not_found'' case *) - {p with pat_desc = - try Tpat_var (alpha_var env id, s) with - | Not_found -> Tpat_any} -| Tpat_alias (p1, id, s) -> - let new_p = alpha_pat env p1 in - begin try - {p with pat_desc = Tpat_alias (new_p, alpha_var env id, s)} - with - | Not_found -> new_p - end -| d -> - {p with pat_desc = map_pattern_desc (alpha_pat env) d} -let mkloc = Location.mkloc -let mknoloc = Location.mknoloc +# 3467 "parsing/lexer.ml" end -module Tast_mapper : sig -#1 "tast_mapper.mli" +module Oprint : sig +#1 "oprint.mli" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Alain Frisch, LexiFi *) +(* Projet Cristal, INRIA Rocquencourt *) (* *) -(* Copyright 2015 Institut National de Recherche en Informatique et *) +(* Copyright 2002 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -56030,69 +53917,32 @@ module Tast_mapper : sig (* *) (**************************************************************************) -open Asttypes -open Typedtree +open Format +open Outcometree -(** {1 A generic Typedtree mapper} *) -type mapper = - { - case: mapper -> case -> case; - cases: mapper -> case list -> case list; - class_declaration: mapper -> class_declaration -> class_declaration; - class_description: mapper -> class_description -> class_description; - class_expr: mapper -> class_expr -> class_expr; - class_field: mapper -> class_field -> class_field; - class_signature: mapper -> class_signature -> class_signature; - class_structure: mapper -> class_structure -> class_structure; - class_type: mapper -> class_type -> class_type; - class_type_declaration: mapper -> class_type_declaration -> - class_type_declaration; - class_type_field: mapper -> class_type_field -> class_type_field; - env: mapper -> Env.t -> Env.t; - expr: mapper -> expression -> expression; - extension_constructor: mapper -> extension_constructor -> - extension_constructor; - module_binding: mapper -> module_binding -> module_binding; - module_coercion: mapper -> module_coercion -> module_coercion; - module_declaration: mapper -> module_declaration -> module_declaration; - module_expr: mapper -> module_expr -> module_expr; - module_type: mapper -> module_type -> module_type; - module_type_declaration: - mapper -> module_type_declaration -> module_type_declaration; - package_type: mapper -> package_type -> package_type; - pat: mapper -> pattern -> pattern; - row_field: mapper -> row_field -> row_field; - object_field: mapper -> object_field -> object_field; - signature: mapper -> signature -> signature; - signature_item: mapper -> signature_item -> signature_item; - structure: mapper -> structure -> structure; - structure_item: mapper -> structure_item -> structure_item; - typ: mapper -> core_type -> core_type; - type_declaration: mapper -> type_declaration -> type_declaration; - type_declarations: mapper -> (rec_flag * type_declaration list) -> - (rec_flag * type_declaration list); - type_extension: mapper -> type_extension -> type_extension; - type_kind: mapper -> type_kind -> type_kind; - value_binding: mapper -> value_binding -> value_binding; - value_bindings: mapper -> (rec_flag * value_binding list) -> - (rec_flag * value_binding list); - value_description: mapper -> value_description -> value_description; - with_constraint: mapper -> with_constraint -> with_constraint; - } +val out_ident : (formatter -> string -> unit) ref +val out_value : (formatter -> out_value -> unit) ref +val out_type : (formatter -> out_type -> unit) ref +val out_class_type : (formatter -> out_class_type -> unit) ref +val out_module_type : (formatter -> out_module_type -> unit) ref +val out_sig_item : (formatter -> out_sig_item -> unit) ref +val out_signature : (formatter -> out_sig_item list -> unit) ref +val out_type_extension : (formatter -> out_type_extension -> unit) ref +val out_phrase : (formatter -> out_phrase -> unit) ref -val default: mapper +val parenthesized_ident : string -> bool end = struct -#1 "tast_mapper.ml" +#1 "oprint.ml" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Alain Frisch, LexiFi *) +(* Projet Cristal, INRIA Rocquencourt *) (* *) -(* Copyright 2015 Institut National de Recherche en Informatique et *) +(* Copyright 2002 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -56101,702 +53951,943 @@ end = struct (* *) (**************************************************************************) -open Asttypes -open Typedtree +open Format +open Outcometree -(* TODO: add 'methods' for location, attribute, extension, - open_description, include_declaration, include_description *) +exception Ellipsis -type mapper = - { - case: mapper -> case -> case; - cases: mapper -> case list -> case list; - class_declaration: mapper -> class_declaration -> class_declaration; - class_description: mapper -> class_description -> class_description; - class_expr: mapper -> class_expr -> class_expr; - class_field: mapper -> class_field -> class_field; - class_signature: mapper -> class_signature -> class_signature; - class_structure: mapper -> class_structure -> class_structure; - class_type: mapper -> class_type -> class_type; - class_type_declaration: mapper -> class_type_declaration -> - class_type_declaration; - class_type_field: mapper -> class_type_field -> class_type_field; - env: mapper -> Env.t -> Env.t; - expr: mapper -> expression -> expression; - extension_constructor: mapper -> extension_constructor -> - extension_constructor; - module_binding: mapper -> module_binding -> module_binding; - module_coercion: mapper -> module_coercion -> module_coercion; - module_declaration: mapper -> module_declaration -> module_declaration; - module_expr: mapper -> module_expr -> module_expr; - module_type: mapper -> module_type -> module_type; - module_type_declaration: - mapper -> module_type_declaration -> module_type_declaration; - package_type: mapper -> package_type -> package_type; - pat: mapper -> pattern -> pattern; - row_field: mapper -> row_field -> row_field; - object_field: mapper -> object_field -> object_field; - signature: mapper -> signature -> signature; - signature_item: mapper -> signature_item -> signature_item; - structure: mapper -> structure -> structure; - structure_item: mapper -> structure_item -> structure_item; - typ: mapper -> core_type -> core_type; - type_declaration: mapper -> type_declaration -> type_declaration; - type_declarations: mapper -> (rec_flag * type_declaration list) -> - (rec_flag * type_declaration list); - type_extension: mapper -> type_extension -> type_extension; - type_kind: mapper -> type_kind -> type_kind; - value_binding: mapper -> value_binding -> value_binding; - value_bindings: mapper -> (rec_flag * value_binding list) -> - (rec_flag * value_binding list); - value_description: mapper -> value_description -> value_description; - with_constraint: mapper -> with_constraint -> with_constraint; - } +let cautious f ppf arg = + try f ppf arg with + Ellipsis -> fprintf ppf "..." -let id x = x -let tuple2 f1 f2 (x, y) = (f1 x, f2 y) -let tuple3 f1 f2 f3 (x, y, z) = (f1 x, f2 y, f3 z) -let opt f = function None -> None | Some x -> Some (f x) -let structure sub {str_items; str_type; str_final_env} = - { - str_items = List.map (sub.structure_item sub) str_items; - str_final_env = sub.env sub str_final_env; - str_type; - } +let out_ident = ref pp_print_string -let class_infos sub f x = - {x with - ci_params = List.map (tuple2 (sub.typ sub) id) x.ci_params; - ci_expr = f x.ci_expr; - } -let module_type_declaration sub x = - let mtd_type = opt (sub.module_type sub) x.mtd_type in - {x with mtd_type} +let print_lident ppf = function + | "::" -> !out_ident ppf "(::)" + | s -> !out_ident ppf s -let module_declaration sub x = - let md_type = sub.module_type sub x.md_type in - {x with md_type} +let rec print_ident ppf = + function + Oide_ident s -> print_lident ppf s + | Oide_dot (id, s) -> + print_ident ppf id; pp_print_char ppf '.'; print_lident ppf s + | Oide_apply (id1, id2) -> + fprintf ppf "%a(%a)" print_ident id1 print_ident id2 -let include_infos f x = {x with incl_mod = f x.incl_mod} +let parenthesized_ident name = + (List.mem name ["or"; "mod"; "land"; "lor"; "lxor"; "lsl"; "lsr"; "asr"]) + || + (match name.[0] with + 'a'..'z' | 'A'..'Z' | '\223'..'\246' | '\248'..'\255' | '_' -> + false + | _ -> true) -let class_type_declaration sub x = - class_infos sub (sub.class_type sub) x +let value_ident ppf name = + if parenthesized_ident name then + fprintf ppf "( %s )" name + else + pp_print_string ppf name -let class_declaration sub x = - class_infos sub (sub.class_expr sub) x +(* Values *) -let structure_item sub {str_desc; str_loc; str_env} = - let str_env = sub.env sub str_env in - let str_desc = - match str_desc with - | Tstr_eval (exp, attrs) -> Tstr_eval (sub.expr sub exp, attrs) - | Tstr_value (rec_flag, list) -> - let (rec_flag, list) = sub.value_bindings sub (rec_flag, list) in - Tstr_value (rec_flag, list) - | Tstr_primitive v -> Tstr_primitive (sub.value_description sub v) - | Tstr_type (rec_flag, list) -> - let (rec_flag, list) = sub.type_declarations sub (rec_flag, list) in - Tstr_type (rec_flag, list) - | Tstr_typext te -> Tstr_typext (sub.type_extension sub te) - | Tstr_exception ext -> Tstr_exception (sub.extension_constructor sub ext) - | Tstr_module mb -> Tstr_module (sub.module_binding sub mb) - | Tstr_recmodule list -> - Tstr_recmodule (List.map (sub.module_binding sub) list) - | Tstr_modtype x -> Tstr_modtype (sub.module_type_declaration sub x) - | Tstr_class list -> - Tstr_class - (List.map (tuple2 (sub.class_declaration sub) id) list) - | Tstr_class_type list -> - Tstr_class_type - (List.map (tuple3 id id (sub.class_type_declaration sub)) list) - | Tstr_include incl -> - Tstr_include (include_infos (sub.module_expr sub) incl) - | Tstr_open _ - | Tstr_attribute _ as d -> d +let valid_float_lexeme s = + let l = String.length s in + let rec loop i = + if i >= l then s ^ "." else + match s.[i] with + | '0' .. '9' | '-' -> loop (i+1) + | _ -> s + in loop 0 + +let float_repres f = + match classify_float f with + FP_nan -> "nan" + | FP_infinite -> + if f < 0.0 then "neg_infinity" else "infinity" + | _ -> + let float_val = + let s1 = Printf.sprintf "%.12g" f in + if f = float_of_string s1 then s1 else + let s2 = Printf.sprintf "%.15g" f in + if f = float_of_string s2 then s2 else + Printf.sprintf "%.18g" f + in valid_float_lexeme float_val + +let parenthesize_if_neg ppf fmt v isneg = + if isneg then pp_print_char ppf '('; + fprintf ppf fmt v; + if isneg then pp_print_char ppf ')' + +let escape_string s = + (* Escape only C0 control characters (bytes <= 0x1F), DEL(0x7F), '\\' and '"' *) + let n = ref 0 in + for i = 0 to String.length s - 1 do + n := !n + + (match String.unsafe_get s i with + | '\"' | '\\' | '\n' | '\t' | '\r' | '\b' -> 2 + | '\x00' .. '\x1F' + | '\x7F' -> 4 + | _ -> 1) + done; + if !n = String.length s then s else begin + let s' = Bytes.create !n in + n := 0; + for i = 0 to String.length s - 1 do + begin match String.unsafe_get s i with + | ('\"' | '\\') as c -> + Bytes.unsafe_set s' !n '\\'; incr n; Bytes.unsafe_set s' !n c + | '\n' -> + Bytes.unsafe_set s' !n '\\'; incr n; Bytes.unsafe_set s' !n 'n' + | '\t' -> + Bytes.unsafe_set s' !n '\\'; incr n; Bytes.unsafe_set s' !n 't' + | '\r' -> + Bytes.unsafe_set s' !n '\\'; incr n; Bytes.unsafe_set s' !n 'r' + | '\b' -> + Bytes.unsafe_set s' !n '\\'; incr n; Bytes.unsafe_set s' !n 'b' + | '\x00' .. '\x1F' | '\x7F' as c -> + let a = Char.code c in + Bytes.unsafe_set s' !n '\\'; + incr n; + Bytes.unsafe_set s' !n (Char.chr (48 + a / 100)); + incr n; + Bytes.unsafe_set s' !n (Char.chr (48 + (a / 10) mod 10)); + incr n; + Bytes.unsafe_set s' !n (Char.chr (48 + a mod 10)); + | c -> Bytes.unsafe_set s' !n c + end; + incr n + done; + Bytes.to_string s' + end + + +let print_out_string ppf s = + let not_escaped = + (* let the user dynamically choose if strings should be escaped: *) + match Sys.getenv_opt "OCAMLTOP_UTF_8" with + | None -> true + | Some x -> + match bool_of_string_opt x with + | None -> true + | Some f -> f in + if not_escaped then + fprintf ppf "\"%s\"" (escape_string s) + else + fprintf ppf "%S" s + +let print_out_value ppf tree = + let rec print_tree_1 ppf = + function + | Oval_constr (name, [param]) -> + fprintf ppf "@[<1>%a@ %a@]" print_ident name print_constr_param param + | Oval_constr (name, (_ :: _ as params)) -> + fprintf ppf "@[<1>%a@ (%a)@]" print_ident name + (print_tree_list print_tree_1 ",") params + | Oval_variant (name, Some param) -> + fprintf ppf "@[<2>`%s@ %a@]" name print_constr_param param + | tree -> print_simple_tree ppf tree + and print_constr_param ppf = function + | Oval_int i -> parenthesize_if_neg ppf "%i" i (i < 0) + | Oval_int32 i -> parenthesize_if_neg ppf "%lil" i (i < 0l) + | Oval_int64 i -> parenthesize_if_neg ppf "%LiL" i (i < 0L) + | Oval_nativeint i -> parenthesize_if_neg ppf "%nin" i (i < 0n) + | Oval_float f -> parenthesize_if_neg ppf "%s" (float_repres f) (f < 0.0) + | Oval_string (_,_, Ostr_bytes) as tree -> + pp_print_char ppf '('; + print_simple_tree ppf tree; + pp_print_char ppf ')'; + | tree -> print_simple_tree ppf tree + and print_simple_tree ppf = + function + Oval_int i -> fprintf ppf "%i" i + | Oval_int32 i -> fprintf ppf "%lil" i + | Oval_int64 i -> fprintf ppf "%LiL" i + | Oval_nativeint i -> fprintf ppf "%nin" i + | Oval_float f -> pp_print_string ppf (float_repres f) + | Oval_char c -> fprintf ppf "%C" c + | Oval_string (s, maxlen, kind) -> + begin try + let len = String.length s in + let s = if len > maxlen then String.sub s 0 maxlen else s in + begin match kind with + | Ostr_bytes -> fprintf ppf "Bytes.of_string %S" s + | Ostr_string -> print_out_string ppf s + end; + (if len > maxlen then + fprintf ppf + "... (* string length %d; truncated *)" len + ) + with + Invalid_argument _ (* "String.create" *)-> fprintf ppf "" + end + | Oval_list tl -> + fprintf ppf "@[<1>[%a]@]" (print_tree_list print_tree_1 ";") tl + | Oval_array tl -> + fprintf ppf "@[<2>[|%a|]@]" (print_tree_list print_tree_1 ";") tl + | Oval_constr (name, []) -> print_ident ppf name + | Oval_variant (name, None) -> fprintf ppf "`%s" name + | Oval_stuff s -> pp_print_string ppf s + | Oval_record fel -> + fprintf ppf "@[<1>{%a}@]" (cautious (print_fields true)) fel + | Oval_ellipsis -> raise Ellipsis + | Oval_printer f -> f ppf + | Oval_tuple tree_list -> + fprintf ppf "@[<1>(%a)@]" (print_tree_list print_tree_1 ",") tree_list + | tree -> fprintf ppf "@[<1>(%a)@]" (cautious print_tree_1) tree + and print_fields first ppf = + function + [] -> () + | (name, tree) :: fields -> + if not first then fprintf ppf ";@ "; + fprintf ppf "@[<1>%a@ =@ %a@]" print_ident name (cautious print_tree_1) + tree; + print_fields false ppf fields + and print_tree_list print_item sep ppf tree_list = + let rec print_list first ppf = + function + [] -> () + | tree :: tree_list -> + if not first then fprintf ppf "%s@ " sep; + print_item ppf tree; + print_list false ppf tree_list + in + cautious (print_list true) ppf tree_list + in + cautious print_tree_1 ppf tree + +let out_value = ref print_out_value + +(* Types *) + +let rec print_list_init pr sep ppf = + function + [] -> () + | a :: l -> sep ppf; pr ppf a; print_list_init pr sep ppf l + +let rec print_list pr sep ppf = + function + [] -> () + | [a] -> pr ppf a + | a :: l -> pr ppf a; sep ppf; print_list pr sep ppf l + +let pr_present = + print_list (fun ppf s -> fprintf ppf "`%s" s) (fun ppf -> fprintf ppf "@ ") + +let pr_vars = + print_list (fun ppf s -> fprintf ppf "'%s" s) (fun ppf -> fprintf ppf "@ ") + +let rec print_out_type ppf = + function + | Otyp_alias (ty, s) -> + fprintf ppf "@[%a@ as '%s@]" print_out_type ty s + | Otyp_poly (sl, ty) -> + fprintf ppf "@[%a.@ %a@]" + pr_vars sl + print_out_type ty + | ty -> + print_out_type_1 ppf ty + +and print_out_type_1 ppf = + function + Otyp_arrow (lab, ty1, ty2) -> + pp_open_box ppf 0; + if lab <> "" then (pp_print_string ppf lab; pp_print_char ppf ':'); + print_out_type_2 ppf ty1; + pp_print_string ppf " ->"; + pp_print_space ppf (); + print_out_type_1 ppf ty2; + pp_close_box ppf () + | ty -> print_out_type_2 ppf ty +and print_out_type_2 ppf = + function + Otyp_tuple tyl -> + fprintf ppf "@[<0>%a@]" (print_typlist print_simple_out_type " *") tyl + | ty -> print_simple_out_type ppf ty +and print_simple_out_type ppf = + function + Otyp_class (ng, id, tyl) -> + fprintf ppf "@[%a%s#%a@]" print_typargs tyl (if ng then "_" else "") + print_ident id + + | Otyp_constr ( (Oide_dot (((Oide_dot (Oide_ident "Js", "Internal"))| (Oide_ident "Js_internal")), + ("fn" | "meth" as name )) as id) , + ([Otyp_variant(_,Ovar_fields [ variant, _, tys], _,_); result] as tyl)) + -> + (* Otyp_arrow*) + let make tys result = + if tys = [] then + Otyp_arrow ("", Otyp_constr (Oide_ident "unit", []),result) + else + match tys with + | [ Otyp_tuple tys as single] -> + if variant = "Arity_1" then + Otyp_arrow ("", single, result) + else + List.fold_right (fun x acc -> Otyp_arrow("",x,acc) ) tys result + | [single] -> + Otyp_arrow ("", single, result) + | _ -> + raise_notrace Not_found + in + begin match (make tys result) with + | exception _ -> + begin + pp_open_box ppf 0; + print_typargs ppf tyl; + print_ident ppf id; + pp_close_box ppf () + end + | res -> + begin match name with + | "fn" -> + fprintf ppf "@[<0>(%a@ [@bs])@]" print_out_type_1 res + | "meth" -> + fprintf ppf "@[<0>(%a@ [@bs.meth])@]" print_out_type_1 res + | _ -> assert false + end + end + | Otyp_constr ((Oide_dot ((Oide_dot (Oide_ident "Js", "Internal") | (Oide_ident "Js_internal")), "meth_callback" ) as id) , + ([Otyp_variant(_,Ovar_fields [ variant, _, tys], _,_); result] as tyl)) + -> + let make tys result = + match tys with + | [ Otyp_tuple tys as single ] -> + if variant = "Arity_1" then Otyp_arrow ("", single, result) + else + List.fold_right (fun x acc -> Otyp_arrow("",x,acc) ) tys result + | [single] -> + Otyp_arrow ("", single, result) + | _ -> + raise_notrace Not_found + in + begin match (make tys result) with + | exception _ -> + begin + pp_open_box ppf 0; + print_typargs ppf tyl; + print_ident ppf id; + pp_close_box ppf () + end + | res -> + fprintf ppf "@[<0>(%a@ [@bs.this])@]" print_out_type_1 res + + end + + | Otyp_constr (id, tyl) -> + pp_open_box ppf 0; + print_typargs ppf tyl; + print_ident ppf id; + pp_close_box ppf () + | Otyp_object (fields, rest) -> + fprintf ppf "@[<2>< %a >@]" (print_fields rest) fields + | Otyp_stuff s -> pp_print_string ppf s + | Otyp_var (ng, s) -> fprintf ppf "'%s%s" (if ng then "_" else "") s + | Otyp_variant (non_gen, row_fields, closed, tags) -> + let print_present ppf = + function + None | Some [] -> () + | Some l -> fprintf ppf "@;<1 -2>> @[%a@]" pr_present l + in + let print_fields ppf = + function + Ovar_fields fields -> + print_list print_row_field (fun ppf -> fprintf ppf "@;<1 -2>| ") + ppf fields + | Ovar_typ typ -> + print_simple_out_type ppf typ + in + fprintf ppf "%s[%s@[@[%a@]%a ]@]" (if non_gen then "_" else "") + (if closed then if tags = None then " " else "< " + else if tags = None then "> " else "? ") + print_fields row_fields + print_present tags + | Otyp_alias _ | Otyp_poly _ | Otyp_arrow _ | Otyp_tuple _ as ty -> + pp_open_box ppf 1; + pp_print_char ppf '('; + print_out_type ppf ty; + pp_print_char ppf ')'; + pp_close_box ppf () + | Otyp_abstract | Otyp_open + | Otyp_sum _ | Otyp_manifest (_, _) -> () + | Otyp_record lbls -> print_record_decl ppf lbls + | Otyp_module (p, n, tyl) -> + fprintf ppf "@[<1>(module %s" p; + let first = ref true in + List.iter2 + (fun s t -> + let sep = if !first then (first := false; "with") else "and" in + fprintf ppf " %s type %s = %a" sep s print_out_type t + ) + n tyl; + fprintf ppf ")@]" + | Otyp_attribute (t, attr) -> + fprintf ppf "@[<1>(%a [@@%s])@]" print_out_type t attr.oattr_name +and print_record_decl ppf lbls = + fprintf ppf "{%a@;<1 -2>}" + (print_list_init print_out_label (fun ppf -> fprintf ppf "@ ")) lbls +and print_fields rest ppf = + function + [] -> + begin match rest with + Some non_gen -> fprintf ppf "%s.." (if non_gen then "_" else "") + | None -> () + end + | [s, t] -> + fprintf ppf "%s : %a" s print_out_type t; + begin match rest with + Some _ -> fprintf ppf ";@ " + | None -> () + end; + print_fields rest ppf [] + | (s, t) :: l -> + fprintf ppf "%s : %a;@ %a" s print_out_type t (print_fields rest) l +and print_row_field ppf (l, opt_amp, tyl) = + let pr_of ppf = + if opt_amp then fprintf ppf " of@ &@ " + else if tyl <> [] then fprintf ppf " of@ " + else fprintf ppf "" in - {str_desc; str_env; str_loc} + fprintf ppf "@[`%s%t%a@]" l pr_of (print_typlist print_out_type " &") + tyl +and print_typlist print_elem sep ppf = + function + [] -> () + | [ty] -> print_elem ppf ty + | ty :: tyl -> + print_elem ppf ty; + pp_print_string ppf sep; + pp_print_space ppf (); + print_typlist print_elem sep ppf tyl +and print_typargs ppf = + function + [] -> () + | [ty1] -> print_simple_out_type ppf ty1; pp_print_space ppf () + | tyl -> + pp_open_box ppf 1; + pp_print_char ppf '('; + print_typlist print_out_type "," ppf tyl; + pp_print_char ppf ')'; + pp_close_box ppf (); + pp_print_space ppf () +and print_out_label ppf (name, mut, arg) = + fprintf ppf "@[<2>%s%s :@ %a@];" (if mut then "mutable " else "") name + print_out_type arg -let value_description sub x = - let val_desc = sub.typ sub x.val_desc in - {x with val_desc} +let out_type = ref print_out_type -let label_decl sub x = - let ld_type = sub.typ sub x.ld_type in - {x with ld_type} +(* Class types *) -let constructor_args sub = function - | Cstr_tuple l -> Cstr_tuple (List.map (sub.typ sub) l) - | Cstr_record l -> Cstr_record (List.map (label_decl sub) l) +let type_parameter ppf (ty, (co, cn)) = + fprintf ppf "%s%s" + (if not cn then "+" else if not co then "-" else "") + (if ty = "_" then ty else "'"^ty) -let constructor_decl sub cd = - let cd_args = constructor_args sub cd.cd_args in - let cd_res = opt (sub.typ sub) cd.cd_res in - {cd with cd_args; cd_res} +let print_out_class_params ppf = + function + [] -> () + | tyl -> + fprintf ppf "@[<1>[%a]@]@ " + (print_list type_parameter (fun ppf -> fprintf ppf ", ")) + tyl -let type_kind sub = function - | Ttype_abstract -> Ttype_abstract - | Ttype_variant list -> Ttype_variant (List.map (constructor_decl sub) list) - | Ttype_record list -> Ttype_record (List.map (label_decl sub) list) - | Ttype_open -> Ttype_open +let rec print_out_class_type ppf = + function + Octy_constr (id, tyl) -> + let pr_tyl ppf = + function + [] -> () + | tyl -> + fprintf ppf "@[<1>[%a]@]@ " (print_typlist !out_type ",") tyl + in + fprintf ppf "@[%a%a@]" pr_tyl tyl print_ident id + | Octy_arrow (lab, ty, cty) -> + fprintf ppf "@[%s%a ->@ %a@]" (if lab <> "" then lab ^ ":" else "") + print_out_type_2 ty print_out_class_type cty + | Octy_signature (self_ty, csil) -> + let pr_param ppf = + function + Some ty -> fprintf ppf "@ @[(%a)@]" !out_type ty + | None -> () + in + fprintf ppf "@[@[<2>object%a@]@ %a@;<1 -2>end@]" pr_param self_ty + (print_list print_out_class_sig_item (fun ppf -> fprintf ppf "@ ")) + csil +and print_out_class_sig_item ppf = + function + Ocsg_constraint (ty1, ty2) -> + fprintf ppf "@[<2>constraint %a =@ %a@]" !out_type ty1 + !out_type ty2 + | Ocsg_method (name, priv, virt, ty) -> + fprintf ppf "@[<2>method %s%s%s :@ %a@]" + (if priv then "private " else "") (if virt then "virtual " else "") + name !out_type ty + | Ocsg_value (name, mut, vr, ty) -> + fprintf ppf "@[<2>val %s%s%s :@ %a@]" + (if mut then "mutable " else "") + (if vr then "virtual " else "") + name !out_type ty -let type_declaration sub x = - let typ_cstrs = - List.map - (tuple3 (sub.typ sub) (sub.typ sub) id) - x.typ_cstrs - in - let typ_kind = sub.type_kind sub x.typ_kind in - let typ_manifest = opt (sub.typ sub) x.typ_manifest in - let typ_params = List.map (tuple2 (sub.typ sub) id) x.typ_params in - {x with typ_cstrs; typ_kind; typ_manifest; typ_params} +let out_class_type = ref print_out_class_type -let type_declarations sub (rec_flag, list) = - (rec_flag, List.map (sub.type_declaration sub) list) +(* Signature *) -let type_extension sub x = - let tyext_params = List.map (tuple2 (sub.typ sub) id) x.tyext_params in - let tyext_constructors = - List.map (sub.extension_constructor sub) x.tyext_constructors - in - {x with tyext_constructors; tyext_params} +let out_module_type = ref (fun _ -> failwith "Oprint.out_module_type") +let out_sig_item = ref (fun _ -> failwith "Oprint.out_sig_item") +let out_signature = ref (fun _ -> failwith "Oprint.out_signature") +let out_type_extension = ref (fun _ -> failwith "Oprint.out_type_extension") -let extension_constructor sub x = - let ext_kind = - match x.ext_kind with - Text_decl(ctl, cto) -> - Text_decl(constructor_args sub ctl, opt (sub.typ sub) cto) - | Text_rebind _ as d -> d - in - {x with ext_kind} +let rec print_out_functor funct ppf = + function + Omty_functor (_, None, mty_res) -> + if funct then fprintf ppf "() %a" (print_out_functor true) mty_res + else fprintf ppf "functor@ () %a" (print_out_functor true) mty_res + | Omty_functor (name, Some mty_arg, mty_res) -> begin + match name, funct with + | "_", true -> + fprintf ppf "->@ %a ->@ %a" + print_out_module_type mty_arg (print_out_functor false) mty_res + | "_", false -> + fprintf ppf "%a ->@ %a" + print_out_module_type mty_arg (print_out_functor false) mty_res + | name, true -> + fprintf ppf "(%s : %a) %a" name + print_out_module_type mty_arg (print_out_functor true) mty_res + | name, false -> + fprintf ppf "functor@ (%s : %a) %a" name + print_out_module_type mty_arg (print_out_functor true) mty_res + end + | m -> + if funct then fprintf ppf "->@ %a" print_out_module_type m + else print_out_module_type ppf m -let pat sub x = - let extra = function - | Tpat_type _ - | Tpat_unpack as d -> d - | Tpat_open (path,loc,env) -> Tpat_open (path, loc, sub.env sub env) - | Tpat_constraint ct -> Tpat_constraint (sub.typ sub ct) - in - let pat_env = sub.env sub x.pat_env in - let pat_extra = List.map (tuple3 extra id id) x.pat_extra in - let pat_desc = - match x.pat_desc with - | Tpat_any - | Tpat_var _ - | Tpat_constant _ as d -> d - | Tpat_tuple l -> Tpat_tuple (List.map (sub.pat sub) l) - | Tpat_construct (loc, cd, l) -> - Tpat_construct (loc, cd, List.map (sub.pat sub) l) - | Tpat_variant (l, po, rd) -> Tpat_variant (l, opt (sub.pat sub) po, rd) - | Tpat_record (l, closed) -> - Tpat_record (List.map (tuple3 id id (sub.pat sub)) l, closed) - | Tpat_array l -> Tpat_array (List.map (sub.pat sub) l) - | Tpat_or (p1, p2, rd) -> - Tpat_or (sub.pat sub p1, sub.pat sub p2, rd) - | Tpat_alias (p, id, s) -> Tpat_alias (sub.pat sub p, id, s) - | Tpat_lazy p -> Tpat_lazy (sub.pat sub p) - in - {x with pat_extra; pat_desc; pat_env} +and print_out_module_type ppf = + function + Omty_abstract -> () + | Omty_functor _ as t -> + fprintf ppf "@[<2>%a@]" (print_out_functor false) t + | Omty_ident id -> fprintf ppf "%a" print_ident id + | Omty_signature sg -> + fprintf ppf "@[sig@ %a@;<1 -2>end@]" !out_signature sg + | Omty_alias id -> fprintf ppf "(module %a)" print_ident id +and print_out_signature ppf = + function + [] -> () + | [item] -> !out_sig_item ppf item + | Osig_typext(ext, Oext_first) :: items -> + (* Gather together the extension constructors *) + let rec gather_extensions acc items = + match items with + Osig_typext(ext, Oext_next) :: items -> + gather_extensions + ((ext.oext_name, ext.oext_args, ext.oext_ret_type) :: acc) + items + | _ -> (List.rev acc, items) + in + let exts, items = + gather_extensions + [(ext.oext_name, ext.oext_args, ext.oext_ret_type)] + items + in + let te = + { otyext_name = ext.oext_type_name; + otyext_params = ext.oext_type_params; + otyext_constructors = exts; + otyext_private = ext.oext_private } + in + fprintf ppf "%a@ %a" !out_type_extension te print_out_signature items + | item :: items -> + fprintf ppf "%a@ %a" !out_sig_item item print_out_signature items +and print_out_sig_item ppf = + function + Osig_class (vir_flag, name, params, clt, rs) -> + fprintf ppf "@[<2>%s%s@ %a%s@ :@ %a@]" + (if rs = Orec_next then "and" else "class") + (if vir_flag then " virtual" else "") print_out_class_params params + name !out_class_type clt + | Osig_class_type (vir_flag, name, params, clt, rs) -> + fprintf ppf "@[<2>%s%s@ %a%s@ =@ %a@]" + (if rs = Orec_next then "and" else "class type") + (if vir_flag then " virtual" else "") print_out_class_params params + name !out_class_type clt + | Osig_typext (ext, Oext_exception) -> + fprintf ppf "@[<2>exception %a@]" + print_out_constr (ext.oext_name, ext.oext_args, ext.oext_ret_type) + | Osig_typext (ext, _es) -> + print_out_extension_constructor ppf ext + | Osig_modtype (name, Omty_abstract) -> + fprintf ppf "@[<2>module type %s@]" name + | Osig_modtype (name, mty) -> + fprintf ppf "@[<2>module type %s =@ %a@]" name !out_module_type mty + | Osig_module (name, Omty_alias id, _) -> + fprintf ppf "@[<2>module %s =@ %a@]" name print_ident id + | Osig_module (name, mty, rs) -> + fprintf ppf "@[<2>%s %s :@ %a@]" + (match rs with Orec_not -> "module" + | Orec_first -> "module rec" + | Orec_next -> "and") + name !out_module_type mty + | Osig_type(td, rs) -> + print_out_type_decl + (match rs with + | Orec_not -> "type nonrec" + | Orec_first -> "type" + | Orec_next -> "and") + ppf td + | Osig_value vd -> + let kwd = if vd.oval_prims = [] then "val" else "external" in + let pr_prims ppf = + function + [] -> () + | s :: sl -> + fprintf ppf "@ = \"%s\"" s; + List.iter (fun s -> +(* TODO: in general, we should print bs attributes, some attributes like + bs.splice does need it *) -let expr sub x = - let extra = function - | Texp_constraint cty -> - Texp_constraint (sub.typ sub cty) - | Texp_coerce (cty1, cty2) -> - Texp_coerce (opt (sub.typ sub) cty1, sub.typ sub cty2) - | Texp_open (ovf, path, loc, env) -> - Texp_open (ovf, path, loc, sub.env sub env) - | Texp_newtype _ as d -> d - | Texp_poly cto -> Texp_poly (opt (sub.typ sub) cto) + let len = String.length s in + if len >= 3 && s.[0] = 'B' && s.[1] = 'S' && s.[2] = ':' then + fprintf ppf "@ \"BS-EXTERNAL\"" + else + fprintf ppf "@ \"%s\"" s + + ) sl + in + fprintf ppf "@[<2>%s %a :@ %a%a%a@]" kwd value_ident vd.oval_name + !out_type vd.oval_type pr_prims vd.oval_prims + (fun ppf -> List.iter (fun a -> fprintf ppf "@ [@@@@%s]" a.oattr_name)) + vd.oval_attributes + | Osig_ellipsis -> + fprintf ppf "..." + +and print_out_type_decl kwd ppf td = + let print_constraints ppf = + List.iter + (fun (ty1, ty2) -> + fprintf ppf "@ @[<2>constraint %a =@ %a@]" !out_type ty1 + !out_type ty2) + td.otype_cstrs in - let exp_extra = List.map (tuple3 extra id id) x.exp_extra in - let exp_env = sub.env sub x.exp_env in - let exp_desc = - match x.exp_desc with - | Texp_ident _ - | Texp_constant _ as d -> d - | Texp_let (rec_flag, list, exp) -> - let (rec_flag, list) = sub.value_bindings sub (rec_flag, list) in - Texp_let (rec_flag, list, sub.expr sub exp) - | Texp_function { arg_label; param; cases; partial; } -> - Texp_function { arg_label; param; cases = sub.cases sub cases; - partial; } - | Texp_apply (exp, list) -> - Texp_apply ( - sub.expr sub exp, - List.map (tuple2 id (opt (sub.expr sub))) list - ) - | Texp_match (exp, cases, exn_cases, p) -> - Texp_match ( - sub.expr sub exp, - sub.cases sub cases, - sub.cases sub exn_cases, - p - ) - | Texp_try (exp, cases) -> - Texp_try ( - sub.expr sub exp, - sub.cases sub cases - ) - | Texp_tuple list -> - Texp_tuple (List.map (sub.expr sub) list) - | Texp_construct (lid, cd, args) -> - Texp_construct (lid, cd, List.map (sub.expr sub) args) - | Texp_variant (l, expo) -> - Texp_variant (l, opt (sub.expr sub) expo) - | Texp_record { fields; representation; extended_expression } -> - let fields = Array.map (function - | label, Kept t -> label, Kept t - | label, Overridden (lid, exp) -> - label, Overridden (lid, sub.expr sub exp)) - fields - in - Texp_record { - fields; representation; - extended_expression = opt (sub.expr sub) extended_expression; - } - | Texp_field (exp, lid, ld) -> - Texp_field (sub.expr sub exp, lid, ld) - | Texp_setfield (exp1, lid, ld, exp2) -> - Texp_setfield ( - sub.expr sub exp1, - lid, - ld, - sub.expr sub exp2 - ) - | Texp_array list -> - Texp_array (List.map (sub.expr sub) list) - | Texp_ifthenelse (exp1, exp2, expo) -> - Texp_ifthenelse ( - sub.expr sub exp1, - sub.expr sub exp2, - opt (sub.expr sub) expo - ) - | Texp_sequence (exp1, exp2) -> - Texp_sequence ( - sub.expr sub exp1, - sub.expr sub exp2 - ) - | Texp_while (exp1, exp2) -> - Texp_while ( - sub.expr sub exp1, - sub.expr sub exp2 - ) - | Texp_for (id, p, exp1, exp2, dir, exp3) -> - Texp_for ( - id, - p, - sub.expr sub exp1, - sub.expr sub exp2, - dir, - sub.expr sub exp3 - ) - | Texp_send (exp, meth, expo) -> - Texp_send - ( - sub.expr sub exp, - meth, - opt (sub.expr sub) expo - ) - | Texp_new _ - | Texp_instvar _ as d -> d - | Texp_setinstvar (path1, path2, id, exp) -> - Texp_setinstvar ( - path1, - path2, - id, - sub.expr sub exp - ) - | Texp_override (path, list) -> - Texp_override ( - path, - List.map (tuple3 id id (sub.expr sub)) list - ) - | Texp_letmodule (id, s, mexpr, exp) -> - Texp_letmodule ( - id, - s, - sub.module_expr sub mexpr, - sub.expr sub exp - ) - | Texp_letexception (cd, exp) -> - Texp_letexception ( - sub.extension_constructor sub cd, - sub.expr sub exp - ) - | Texp_assert exp -> - Texp_assert (sub.expr sub exp) - | Texp_lazy exp -> - Texp_lazy (sub.expr sub exp) - | Texp_object (cl, sl) -> - Texp_object (sub.class_structure sub cl, sl) - | Texp_pack mexpr -> - Texp_pack (sub.module_expr sub mexpr) - | Texp_unreachable -> - Texp_unreachable - | Texp_extension_constructor _ as e -> - e + let type_defined ppf = + match td.otype_params with + [] -> pp_print_string ppf td.otype_name + | [param] -> fprintf ppf "@[%a@ %s@]" type_parameter param td.otype_name + | _ -> + fprintf ppf "@[(@[%a)@]@ %s@]" + (print_list type_parameter (fun ppf -> fprintf ppf ",@ ")) + td.otype_params + td.otype_name in - {x with exp_extra; exp_desc; exp_env} - + let print_manifest ppf = + function + Otyp_manifest (ty, _) -> fprintf ppf " =@ %a" !out_type ty + | _ -> () + in + let print_name_params ppf = + fprintf ppf "%s %t%a" kwd type_defined print_manifest td.otype_type + in + let ty = + match td.otype_type with + Otyp_manifest (_, ty) -> ty + | _ -> td.otype_type + in + let print_private ppf = function + Asttypes.Private -> fprintf ppf " private" + | Asttypes.Public -> () + in + let print_immediate ppf = + if td.otype_immediate then fprintf ppf " [%@%@immediate]" else () + in + let print_unboxed ppf = + if td.otype_unboxed then fprintf ppf " [%@%@unboxed]" else () + in + let print_out_tkind ppf = function + | Otyp_abstract -> () + | Otyp_record lbls -> + fprintf ppf " =%a %a" + print_private td.otype_private + print_record_decl lbls + | Otyp_sum constrs -> + fprintf ppf " =%a@;<1 2>%a" + print_private td.otype_private + (print_list print_out_constr (fun ppf -> fprintf ppf "@ | ")) constrs + | Otyp_open -> + fprintf ppf " =%a .." + print_private td.otype_private + | ty -> + fprintf ppf " =%a@;<1 2>%a" + print_private td.otype_private + !out_type ty + in + fprintf ppf "@[<2>@[%t%a@]%t%t%t@]" + print_name_params + print_out_tkind ty + print_constraints + print_immediate + print_unboxed -let package_type sub x = - let pack_fields = List.map (tuple2 id (sub.typ sub)) x.pack_fields in - {x with pack_fields} +and print_out_constr ppf (name, tyl,ret_type_opt) = + let name = + match name with + | "::" -> "(::)" (* #7200 *) + | s -> s + in + match ret_type_opt with + | None -> + begin match tyl with + | [] -> + pp_print_string ppf name + | _ -> + fprintf ppf "@[<2>%s of@ %a@]" name + (print_typlist print_simple_out_type " *") tyl + end + | Some ret_type -> + begin match tyl with + | [] -> + fprintf ppf "@[<2>%s :@ %a@]" name print_simple_out_type ret_type + | _ -> + fprintf ppf "@[<2>%s :@ %a -> %a@]" name + (print_typlist print_simple_out_type " *") + tyl print_simple_out_type ret_type + end -let signature sub x = - let sig_final_env = sub.env sub x.sig_final_env in - let sig_items = List.map (sub.signature_item sub) x.sig_items in - {x with sig_items; sig_final_env} +and print_out_extension_constructor ppf ext = + let print_extended_type ppf = + let print_type_parameter ppf ty = + fprintf ppf "%s" + (if ty = "_" then ty else "'"^ty) + in + match ext.oext_type_params with + [] -> fprintf ppf "%s" ext.oext_type_name + | [ty_param] -> + fprintf ppf "@[%a@ %s@]" + print_type_parameter + ty_param + ext.oext_type_name + | _ -> + fprintf ppf "@[(@[%a)@]@ %s@]" + (print_list print_type_parameter (fun ppf -> fprintf ppf ",@ ")) + ext.oext_type_params + ext.oext_type_name + in + fprintf ppf "@[type %t +=%s@;<1 2>%a@]" + print_extended_type + (if ext.oext_private = Asttypes.Private then " private" else "") + print_out_constr (ext.oext_name, ext.oext_args, ext.oext_ret_type) -let signature_item sub x = - let sig_env = sub.env sub x.sig_env in - let sig_desc = - match x.sig_desc with - | Tsig_value v -> - Tsig_value (sub.value_description sub v) - | Tsig_type (rec_flag, list) -> - let (rec_flag, list) = sub.type_declarations sub (rec_flag, list) in - Tsig_type (rec_flag, list) - | Tsig_typext te -> - Tsig_typext (sub.type_extension sub te) - | Tsig_exception ext -> - Tsig_exception (sub.extension_constructor sub ext) - | Tsig_module x -> - Tsig_module (sub.module_declaration sub x) - | Tsig_recmodule list -> - Tsig_recmodule (List.map (sub.module_declaration sub) list) - | Tsig_modtype x -> - Tsig_modtype (sub.module_type_declaration sub x) - | Tsig_include incl -> - Tsig_include (include_infos (sub.module_type sub) incl) - | Tsig_class list -> - Tsig_class (List.map (sub.class_description sub) list) - | Tsig_class_type list -> - Tsig_class_type - (List.map (sub.class_type_declaration sub) list) - | Tsig_open _ - | Tsig_attribute _ as d -> d +and print_out_type_extension ppf te = + let print_extended_type ppf = + let print_type_parameter ppf ty = + fprintf ppf "%s" + (if ty = "_" then ty else "'"^ty) + in + match te.otyext_params with + [] -> fprintf ppf "%s" te.otyext_name + | [param] -> + fprintf ppf "@[%a@ %s@]" + print_type_parameter param + te.otyext_name + | _ -> + fprintf ppf "@[(@[%a)@]@ %s@]" + (print_list print_type_parameter (fun ppf -> fprintf ppf ",@ ")) + te.otyext_params + te.otyext_name in - {x with sig_desc; sig_env} + fprintf ppf "@[type %t +=%s@;<1 2>%a@]" + print_extended_type + (if te.otyext_private = Asttypes.Private then " private" else "") + (print_list print_out_constr (fun ppf -> fprintf ppf "@ | ")) + te.otyext_constructors -let class_description sub x = - class_infos sub (sub.class_type sub) x +let _ = out_module_type := print_out_module_type +let _ = out_signature := print_out_signature +let _ = out_sig_item := print_out_sig_item +let _ = out_type_extension := print_out_type_extension -let module_type sub x = - let mty_env = sub.env sub x.mty_env in - let mty_desc = - match x.mty_desc with - | Tmty_ident _ - | Tmty_alias _ as d -> d - | Tmty_signature sg -> Tmty_signature (sub.signature sub sg) - | Tmty_functor (id, s, mtype1, mtype2) -> - Tmty_functor ( - id, - s, - opt (sub.module_type sub) mtype1, - sub.module_type sub mtype2 - ) - | Tmty_with (mtype, list) -> - Tmty_with ( - sub.module_type sub mtype, - List.map (tuple3 id id (sub.with_constraint sub)) list - ) - | Tmty_typeof mexpr -> - Tmty_typeof (sub.module_expr sub mexpr) - in - {x with mty_desc; mty_env} +(* Phrases *) -let with_constraint sub = function - | Twith_type decl -> Twith_type (sub.type_declaration sub decl) - | Twith_typesubst decl -> Twith_typesubst (sub.type_declaration sub decl) - | Twith_module _ - | Twith_modsubst _ as d -> d +let print_out_exception ppf exn outv = + match exn with + Sys.Break -> fprintf ppf "Interrupted.@." + | Out_of_memory -> fprintf ppf "Out of memory during evaluation.@." + | Stack_overflow -> + fprintf ppf "Stack overflow during evaluation (looping recursion?).@." + | _ -> fprintf ppf "@[Exception:@ %a.@]@." !out_value outv -let module_coercion sub = function - | Tcoerce_none -> Tcoerce_none - | Tcoerce_functor (c1,c2) -> - Tcoerce_functor (sub.module_coercion sub c1, sub.module_coercion sub c2) - | Tcoerce_alias (p, c1) -> - Tcoerce_alias (p, sub.module_coercion sub c1) - | Tcoerce_structure (l1, l2, runtime_fields) -> - let l1' = List.map (fun (i,c) -> i, sub.module_coercion sub c) l1 in - let l2' = - List.map (fun (id,i,c) -> id, i, sub.module_coercion sub c) l2 +let rec print_items ppf = + function + [] -> () + | (Osig_typext(ext, Oext_first), None) :: items -> + (* Gather together extension constructors *) + let rec gather_extensions acc items = + match items with + (Osig_typext(ext, Oext_next), None) :: items -> + gather_extensions + ((ext.oext_name, ext.oext_args, ext.oext_ret_type) :: acc) + items + | _ -> (List.rev acc, items) in - Tcoerce_structure (l1', l2', runtime_fields) - | Tcoerce_primitive pc -> - Tcoerce_primitive {pc with pc_env = sub.env sub pc.pc_env} + let exts, items = + gather_extensions + [(ext.oext_name, ext.oext_args, ext.oext_ret_type)] + items + in + let te = + { otyext_name = ext.oext_type_name; + otyext_params = ext.oext_type_params; + otyext_constructors = exts; + otyext_private = ext.oext_private } + in + fprintf ppf "@[%a@]" !out_type_extension te; + if items <> [] then fprintf ppf "@ %a" print_items items + | (tree, valopt) :: items -> + begin match valopt with + Some v -> + fprintf ppf "@[<2>%a =@ %a@]" !out_sig_item tree + !out_value v + | None -> fprintf ppf "@[%a@]" !out_sig_item tree + end; + if items <> [] then fprintf ppf "@ %a" print_items items -let module_expr sub x = - let mod_env = sub.env sub x.mod_env in - let mod_desc = - match x.mod_desc with - | Tmod_ident _ as d -> d - | Tmod_structure st -> Tmod_structure (sub.structure sub st) - | Tmod_functor (id, s, mtype, mexpr) -> - Tmod_functor ( - id, - s, - opt (sub.module_type sub) mtype, - sub.module_expr sub mexpr - ) - | Tmod_apply (mexp1, mexp2, c) -> - Tmod_apply ( - sub.module_expr sub mexp1, - sub.module_expr sub mexp2, - sub.module_coercion sub c - ) - | Tmod_constraint (mexpr, mt, Tmodtype_implicit, c) -> - Tmod_constraint (sub.module_expr sub mexpr, mt, Tmodtype_implicit, - sub.module_coercion sub c) - | Tmod_constraint (mexpr, mt, Tmodtype_explicit mtype, c) -> - Tmod_constraint ( - sub.module_expr sub mexpr, - mt, - Tmodtype_explicit (sub.module_type sub mtype), - sub.module_coercion sub c - ) - | Tmod_unpack (exp, mty) -> - Tmod_unpack - ( - sub.expr sub exp, - mty - ) - in - {x with mod_desc; mod_env} +let print_out_phrase ppf = + function + Ophr_eval (outv, ty) -> + fprintf ppf "@[- : %a@ =@ %a@]@." !out_type ty !out_value outv + | Ophr_signature [] -> () + | Ophr_signature items -> fprintf ppf "@[%a@]@." print_items items + | Ophr_exception (exn, outv) -> print_out_exception ppf exn outv -let module_binding sub x = - let mb_expr = sub.module_expr sub x.mb_expr in - {x with mb_expr} +let out_phrase = ref print_out_phrase -let class_expr sub x = - let cl_env = sub.env sub x.cl_env in - let cl_desc = - match x.cl_desc with - | Tcl_constraint (cl, clty, vals, meths, concrs) -> - Tcl_constraint ( - sub.class_expr sub cl, - opt (sub.class_type sub) clty, - vals, - meths, - concrs - ) - | Tcl_structure clstr -> - Tcl_structure (sub.class_structure sub clstr) - | Tcl_fun (label, pat, priv, cl, partial) -> - Tcl_fun ( - label, - sub.pat sub pat, - List.map (tuple3 id id (sub.expr sub)) priv, - sub.class_expr sub cl, - partial - ) - | Tcl_apply (cl, args) -> - Tcl_apply ( - sub.class_expr sub cl, - List.map (tuple2 id (opt (sub.expr sub))) args - ) - | Tcl_let (rec_flag, value_bindings, ivars, cl) -> - let (rec_flag, value_bindings) = - sub.value_bindings sub (rec_flag, value_bindings) - in - Tcl_let ( - rec_flag, - value_bindings, - List.map (tuple3 id id (sub.expr sub)) ivars, - sub.class_expr sub cl - ) - | Tcl_ident (path, lid, tyl) -> - Tcl_ident (path, lid, List.map (sub.typ sub) tyl) - | Tcl_open (ovf, p, lid, env, e) -> - Tcl_open (ovf, p, lid, sub.env sub env, sub.class_expr sub e) - in - {x with cl_desc; cl_env} +end +module Ext_buffer : sig +#1 "ext_buffer.mli" +(***********************************************************************) +(* *) +(* OCaml *) +(* *) +(* Pierre Weis and Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1999 Institut National de Recherche en Informatique et *) +(* en Automatique. All rights reserved. This file is distributed *) +(* under the terms of the GNU Library General Public License, with *) +(* the special exception on linking described in file ../LICENSE. *) +(* *) +(***********************************************************************) -let class_type sub x = - let cltyp_env = sub.env sub x.cltyp_env in - let cltyp_desc = - match x.cltyp_desc with - | Tcty_signature csg -> Tcty_signature (sub.class_signature sub csg) - | Tcty_constr (path, lid, list) -> - Tcty_constr ( - path, - lid, - List.map (sub.typ sub) list - ) - | Tcty_arrow (label, ct, cl) -> - Tcty_arrow - (label, - sub.typ sub ct, - sub.class_type sub cl - ) - | Tcty_open (ovf, p, lid, env, e) -> - Tcty_open (ovf, p, lid, sub.env sub env, sub.class_type sub e) - in - {x with cltyp_desc; cltyp_env} +(** Extensible buffers. -let class_signature sub x = - let csig_self = sub.typ sub x.csig_self in - let csig_fields = List.map (sub.class_type_field sub) x.csig_fields in - {x with csig_self; csig_fields} + This module implements buffers that automatically expand + as necessary. It provides accumulative concatenation of strings + in quasi-linear time (instead of quadratic time when strings are + concatenated pairwise). +*) -let class_type_field sub x = - let ctf_desc = - match x.ctf_desc with - | Tctf_inherit ct -> - Tctf_inherit (sub.class_type sub ct) - | Tctf_val (s, mut, virt, ct) -> - Tctf_val (s, mut, virt, sub.typ sub ct) - | Tctf_method (s, priv, virt, ct) -> - Tctf_method (s, priv, virt, sub.typ sub ct) - | Tctf_constraint (ct1, ct2) -> - Tctf_constraint (sub.typ sub ct1, sub.typ sub ct2) - | Tctf_attribute _ as d -> d - in - {x with ctf_desc} +(* BuckleScript customization: customized for efficient digest *) -let typ sub x = - let ctyp_env = sub.env sub x.ctyp_env in - let ctyp_desc = - match x.ctyp_desc with - | Ttyp_any - | Ttyp_var _ as d -> d - | Ttyp_arrow (label, ct1, ct2) -> - Ttyp_arrow (label, sub.typ sub ct1, sub.typ sub ct2) - | Ttyp_tuple list -> Ttyp_tuple (List.map (sub.typ sub) list) - | Ttyp_constr (path, lid, list) -> - Ttyp_constr (path, lid, List.map (sub.typ sub) list) - | Ttyp_object (list, closed) -> - Ttyp_object ((List.map (sub.object_field sub) list), closed) - | Ttyp_class (path, lid, list) -> - Ttyp_class - (path, - lid, - List.map (sub.typ sub) list - ) - | Ttyp_alias (ct, s) -> - Ttyp_alias (sub.typ sub ct, s) - | Ttyp_variant (list, closed, labels) -> - Ttyp_variant (List.map (sub.row_field sub) list, closed, labels) - | Ttyp_poly (sl, ct) -> - Ttyp_poly (sl, sub.typ sub ct) - | Ttyp_package pack -> - Ttyp_package (sub.package_type sub pack) - in - {x with ctyp_desc; ctyp_env} +type t +(** The abstract type of buffers. *) -let class_structure sub x = - let cstr_self = sub.pat sub x.cstr_self in - let cstr_fields = List.map (sub.class_field sub) x.cstr_fields in - {x with cstr_self; cstr_fields} +val create : int -> t +(** [create n] returns a fresh buffer, initially empty. + The [n] parameter is the initial size of the internal byte sequence + that holds the buffer contents. That byte sequence is automatically + reallocated when more than [n] characters are stored in the buffer, + but shrinks back to [n] characters when [reset] is called. + For best performance, [n] should be of the same order of magnitude + as the number of characters that are expected to be stored in + the buffer (for instance, 80 for a buffer that holds one output + line). Nothing bad will happen if the buffer grows beyond that + limit, however. In doubt, take [n = 16] for instance. + If [n] is not between 1 and {!Sys.max_string_length}, it will + be clipped to that interval. *) -let row_field sub = function - | Ttag (label, attrs, b, list) -> - Ttag (label, attrs, b, List.map (sub.typ sub) list) - | Tinherit ct -> Tinherit (sub.typ sub ct) +val contents : t -> string +(** Return a copy of the current contents of the buffer. + The buffer itself is unchanged. *) -let object_field sub = function - | OTtag (label, attrs, ct) -> - OTtag (label, attrs, (sub.typ sub ct)) - | OTinherit ct -> OTinherit (sub.typ sub ct) +val length : t -> int +(** Return the number of characters currently contained in the buffer. *) -let class_field_kind sub = function - | Tcfk_virtual ct -> Tcfk_virtual (sub.typ sub ct) - | Tcfk_concrete (ovf, e) -> Tcfk_concrete (ovf, sub.expr sub e) +val is_empty : t -> bool -let class_field sub x = - let cf_desc = - match x.cf_desc with - | Tcf_inherit (ovf, cl, super, vals, meths) -> - Tcf_inherit (ovf, sub.class_expr sub cl, super, vals, meths) - | Tcf_constraint (cty, cty') -> - Tcf_constraint ( - sub.typ sub cty, - sub.typ sub cty' - ) - | Tcf_val (s, mf, id, k, b) -> - Tcf_val (s, mf, id, class_field_kind sub k, b) - | Tcf_method (s, priv, k) -> - Tcf_method (s, priv, class_field_kind sub k) - | Tcf_initializer exp -> - Tcf_initializer (sub.expr sub exp) - | Tcf_attribute _ as d -> d - in - {x with cf_desc} +val clear : t -> unit +(** Empty the buffer. *) + + +val add_char : t -> char -> unit +(** [add_char b c] appends the character [c] at the end of the buffer [b]. *) + +val add_string : t -> string -> unit +(** [add_string b s] appends the string [s] at the end of the buffer [b]. *) + +val add_bytes : t -> bytes -> unit +(** [add_string b s] appends the string [s] at the end of the buffer [b]. + @since 4.02 *) + +val add_substring : t -> string -> int -> int -> unit +(** [add_substring b s ofs len] takes [len] characters from offset + [ofs] in string [s] and appends them at the end of the buffer [b]. *) + +val add_subbytes : t -> bytes -> int -> int -> unit +(** [add_substring b s ofs len] takes [len] characters from offset + [ofs] in byte sequence [s] and appends them at the end of the buffer [b]. + @since 4.02 *) + +val add_buffer : t -> t -> unit +(** [add_buffer b1 b2] appends the current contents of buffer [b2] + at the end of buffer [b1]. [b2] is not modified. *) + +val add_channel : t -> in_channel -> int -> unit +(** [add_channel b ic n] reads exactly [n] character from the + input channel [ic] and stores them at the end of buffer [b]. + Raise [End_of_file] if the channel contains fewer than [n] + characters. *) -let value_bindings sub (rec_flag, list) = - (rec_flag, List.map (sub.value_binding sub) list) +val output_buffer : out_channel -> t -> unit +(** [output_buffer oc b] writes the current contents of buffer [b] + on the output channel [oc]. *) -let cases sub l = - List.map (sub.case sub) l +val digest : t -> Digest.t -let case sub {c_lhs; c_guard; c_rhs} = - { - c_lhs = sub.pat sub c_lhs; - c_guard = opt (sub.expr sub) c_guard; - c_rhs = sub.expr sub c_rhs; - } +val not_equal : + t -> + string -> + bool -let value_binding sub x = - let vb_pat = sub.pat sub x.vb_pat in - let vb_expr = sub.expr sub x.vb_expr in - {x with vb_pat; vb_expr} +val add_int_1 : + t -> int -> unit -let env _sub x = x +val add_int_2 : + t -> int -> unit -let default = - { - case; - cases; - class_declaration; - class_description; - class_expr; - class_field; - class_signature; - class_structure; - class_type; - class_type_declaration; - class_type_field; - env; - expr; - extension_constructor; - module_binding; - module_coercion; - module_declaration; - module_expr; - module_type; - module_type_declaration; - package_type; - pat; - row_field; - object_field; - signature; - signature_item; - structure; - structure_item; - typ; - type_declaration; - type_declarations; - type_extension; - type_kind; - value_binding; - value_bindings; - value_description; - with_constraint; - } +val add_int_3 : + t -> int -> unit -end -module Cmt_format : sig -#1 "cmt_format.mli" +val add_int_4 : + t -> int -> unit + +val add_string_char : + t -> + string -> + char -> + unit + +val add_char_string : + t -> + char -> + string -> + unit +end = struct +#1 "ext_buffer.ml" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Fabrice Le Fessant, INRIA Saclay *) +(* Pierre Weis and Xavier Leroy, projet Cristal, INRIA Rocquencourt *) (* *) -(* Copyright 2012 Institut National de Recherche en Informatique et *) +(* Copyright 1999 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -56805,8086 +54896,8486 @@ module Cmt_format : sig (* *) (**************************************************************************) -(** cmt and cmti files format. *) - -(** The layout of a cmt file is as follows: - := \{\} \{cmt infos\} \{\} - where is the cmi file format: - := . - More precisely, the optional part must be present if and only if - the file is: - - a cmti, or - - a cmt, for a ml file which has no corresponding mli (hence no - corresponding cmti). - - Thus, we provide a common reading function for cmi and cmt(i) - files which returns an option for each of the three parts: cmi - info, cmt info, source info. *) - -open Typedtree - -type binary_annots = - | Packed of Types.signature * string list - | Implementation of structure - | Interface of signature - | Partial_implementation of binary_part array - | Partial_interface of binary_part array - -and binary_part = - | Partial_structure of structure - | Partial_structure_item of structure_item - | Partial_expression of expression - | Partial_pattern of pattern - | Partial_class_expr of class_expr - | Partial_signature of signature - | Partial_signature_item of signature_item - | Partial_module_type of module_type +(* Extensible buffers *) -type cmt_infos = { - cmt_modname : string; - cmt_annots : binary_annots; - cmt_value_dependencies : - (Types.value_description * Types.value_description) list; - cmt_comments : (string * Location.t) list; - cmt_args : string array; - cmt_sourcefile : string option; - cmt_builddir : string; - cmt_loadpath : string list; - cmt_source_digest : string option; - cmt_initial_env : Env.t; - cmt_imports : (string * Digest.t option) list; - cmt_interface_digest : Digest.t option; - cmt_use_summaries : bool; -} +type t = + {mutable buffer : bytes; + mutable position : int; + mutable length : int; + initial_buffer : bytes} -type error = - Not_a_typedtree of string +let create n = + let n = if n < 1 then 1 else n in + + let n = if n > Sys.max_string_length then Sys.max_string_length else n in + + let s = Bytes.create n in + {buffer = s; position = 0; length = n; initial_buffer = s} -exception Error of error +let contents b = Bytes.sub_string b.buffer 0 b.position +let to_bytes b = Bytes.sub b.buffer 0 b.position -(** [read filename] opens filename, and extract both the cmi_infos, if - it exists, and the cmt_infos, if it exists. Thus, it can be used - with .cmi, .cmt and .cmti files. +let sub b ofs len = + if ofs < 0 || len < 0 || ofs > b.position - len + then invalid_arg "Ext_buffer.sub" + else Bytes.sub_string b.buffer ofs len - .cmti files always contain a cmi_infos at the beginning. .cmt files - only contain a cmi_infos at the beginning if there is no associated - .cmti file. -*) -val read : string -> Cmi_format.cmi_infos option * cmt_infos option -val read_cmt : string -> cmt_infos -val read_cmi : string -> Cmi_format.cmi_infos +let blit src srcoff dst dstoff len = + if len < 0 || srcoff < 0 || srcoff > src.position - len + || dstoff < 0 || dstoff > (Bytes.length dst) - len + then invalid_arg "Ext_buffer.blit" + else + Bytes.unsafe_blit src.buffer srcoff dst dstoff len -(** [save_cmt filename modname binary_annots sourcefile initial_env cmi] - writes a cmt(i) file. *) -val save_cmt : - string -> (* filename.cmt to generate *) - string -> (* module name *) - binary_annots -> - string option -> (* source file *) - Env.t -> (* initial env *) - Cmi_format.cmi_infos option -> (* if a .cmi was generated *) - unit +let length b = b.position +let is_empty b = b.position = 0 +let clear b = b.position <- 0 -(* Miscellaneous functions *) +let reset b = + b.position <- 0; b.buffer <- b.initial_buffer; + b.length <- Bytes.length b.buffer -val read_magic_number : in_channel -> string +let resize b more = + let len = b.length in + let new_len = ref len in + while b.position + more > !new_len do new_len := 2 * !new_len done; + + if !new_len > Sys.max_string_length then begin + if b.position + more <= Sys.max_string_length + then new_len := Sys.max_string_length + else failwith "Ext_buffer.add: cannot grow buffer" + end; + + let new_buffer = Bytes.create !new_len in + (* PR#6148: let's keep using [blit] rather than [unsafe_blit] in + this tricky function that is slow anyway. *) + Bytes.blit b.buffer 0 new_buffer 0 b.position; + b.buffer <- new_buffer; + b.length <- !new_len ; + assert (b.position + more <= b.length) -val clear: unit -> unit +let add_char b c = + let pos = b.position in + if pos >= b.length then resize b 1; + Bytes.unsafe_set b.buffer pos c; + b.position <- pos + 1 -val add_saved_type : binary_part -> unit -val get_saved_types : unit -> binary_part list -val set_saved_types : binary_part list -> unit +let add_substring b s offset len = + if offset < 0 || len < 0 || offset > String.length s - len + then invalid_arg "Ext_buffer.add_substring/add_subbytes"; + let new_position = b.position + len in + if new_position > b.length then resize b len; + Ext_bytes.unsafe_blit_string s offset b.buffer b.position len; + b.position <- new_position -val record_value_dependency: - Types.value_description -> Types.value_description -> unit +let add_subbytes b s offset len = + add_substring b (Bytes.unsafe_to_string s) offset len -(* +let add_string b s = + let len = String.length s in + let new_position = b.position + len in + if new_position > b.length then resize b len; + Ext_bytes.unsafe_blit_string s 0 b.buffer b.position len; + b.position <- new_position - val is_magic_number : string -> bool - val read : in_channel -> Env.cmi_infos option * t - val write_magic_number : out_channel -> unit - val write : out_channel -> t -> unit +(* TODO: micro-optimzie *) +let add_string_char b s c = + let s_len = String.length s in + let len = s_len + 1 in + let new_position = b.position + len in + if new_position > b.length then resize b len; + let b_buffer = b.buffer in + Ext_bytes.unsafe_blit_string s 0 b_buffer b.position s_len; + Bytes.unsafe_set b_buffer (new_position - 1) c; + b.position <- new_position - val find : string list -> string -> string - val read_signature : 'a -> string -> Types.signature * 'b list * 'c list +let add_char_string b c s = + let s_len = String.length s in + let len = s_len + 1 in + let new_position = b.position + len in + if new_position > b.length then resize b len; + let b_buffer = b.buffer in + let b_position = b.position in + Bytes.unsafe_set b_buffer b_position c ; + Ext_bytes.unsafe_blit_string s 0 b_buffer (b_position + 1) s_len; + b.position <- new_position -*) -end = struct -#1 "cmt_format.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Fabrice Le Fessant, INRIA Saclay *) -(* *) -(* Copyright 2012 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let add_bytes b s = add_string b (Bytes.unsafe_to_string s) -open Cmi_format -open Typedtree +let add_buffer b bs = + add_subbytes b bs.buffer 0 bs.position -(* Note that in Typerex, there is an awful hack to save a cmt file - together with the interface file that was generated by ocaml (this - is because the installed version of ocaml might differ from the one - integrated in Typerex). -*) +let add_channel b ic len = + if len < 0 + || len > Sys.max_string_length + then (* PR#5004 *) + invalid_arg "Ext_buffer.add_channel"; + if b.position + len > b.length then resize b len; + really_input ic b.buffer b.position len; + b.position <- b.position + len -let read_magic_number ic = - let len_magic_number = String.length Config.cmt_magic_number in - really_input_string ic len_magic_number +let output_buffer oc b = + output oc b.buffer 0 b.position -type binary_annots = - | Packed of Types.signature * string list - | Implementation of structure - | Interface of signature - | Partial_implementation of binary_part array - | Partial_interface of binary_part array +external unsafe_string: bytes -> int -> int -> Digest.t = "caml_md5_string" -and binary_part = -| Partial_structure of structure -| Partial_structure_item of structure_item -| Partial_expression of expression -| Partial_pattern of pattern -| Partial_class_expr of class_expr -| Partial_signature of signature -| Partial_signature_item of signature_item -| Partial_module_type of module_type +let digest b = + unsafe_string + b.buffer 0 b.position -type cmt_infos = { - cmt_modname : string; - cmt_annots : binary_annots; - cmt_value_dependencies : - (Types.value_description * Types.value_description) list; - cmt_comments : (string * Location.t) list; - cmt_args : string array; - cmt_sourcefile : string option; - cmt_builddir : string; - cmt_loadpath : string list; - cmt_source_digest : Digest.t option; - cmt_initial_env : Env.t; - cmt_imports : (string * Digest.t option) list; - cmt_interface_digest : Digest.t option; - cmt_use_summaries : bool; -} +let rec not_equal_aux (b : bytes) (s : string) i len = + if i >= len then false + else + (Bytes.unsafe_get b i + <> + String.unsafe_get s i ) + || not_equal_aux b s (i + 1) len -type error = - Not_a_typedtree of string +(** avoid a large copy *) +let not_equal (b : t) (s : string) = + let b_len = b.position in + let s_len = String.length s in + b_len <> s_len + || not_equal_aux b.buffer s 0 s_len -let need_to_clear_env = - try ignore (Sys.getenv "OCAML_BINANNOT_WITHENV"); false - with Not_found -> true -let keep_only_summary = Env.keep_only_summary +(** + It could be one byte, two bytes, three bytes and four bytes + TODO: inline for better performance +*) +let add_int_1 (b : t ) (x : int ) = + let c = (Char.unsafe_chr (x land 0xff)) in + let pos = b.position in + if pos >= b.length then resize b 1; + Bytes.unsafe_set b.buffer pos c; + b.position <- pos + 1 + +let add_int_2 (b : t ) (x : int ) = + let c1 = (Char.unsafe_chr (x land 0xff)) in + let c2 = (Char.unsafe_chr (x lsr 8 land 0xff)) in + let pos = b.position in + if pos + 1 >= b.length then resize b 2; + let b_buffer = b.buffer in + Bytes.unsafe_set b_buffer pos c1; + Bytes.unsafe_set b_buffer (pos + 1) c2; + b.position <- pos + 2 -open Tast_mapper +let add_int_3 (b : t ) (x : int ) = + let c1 = (Char.unsafe_chr (x land 0xff)) in + let c2 = (Char.unsafe_chr (x lsr 8 land 0xff)) in + let c3 = (Char.unsafe_chr (x lsr 16 land 0xff)) in + let pos = b.position in + if pos + 2 >= b.length then resize b 3; + let b_buffer = b.buffer in + Bytes.unsafe_set b_buffer pos c1; + Bytes.unsafe_set b_buffer (pos + 1) c2; + Bytes.unsafe_set b_buffer (pos + 2) c3; + b.position <- pos + 3 -let cenv = - {Tast_mapper.default with env = fun _sub env -> keep_only_summary env} -let clear_part = function - | Partial_structure s -> Partial_structure (cenv.structure cenv s) - | Partial_structure_item s -> - Partial_structure_item (cenv.structure_item cenv s) - | Partial_expression e -> Partial_expression (cenv.expr cenv e) - | Partial_pattern p -> Partial_pattern (cenv.pat cenv p) - | Partial_class_expr ce -> Partial_class_expr (cenv.class_expr cenv ce) - | Partial_signature s -> Partial_signature (cenv.signature cenv s) - | Partial_signature_item s -> - Partial_signature_item (cenv.signature_item cenv s) - | Partial_module_type s -> Partial_module_type (cenv.module_type cenv s) +let add_int_4 (b : t ) (x : int ) = + let c1 = (Char.unsafe_chr (x land 0xff)) in + let c2 = (Char.unsafe_chr (x lsr 8 land 0xff)) in + let c3 = (Char.unsafe_chr (x lsr 16 land 0xff)) in + let c4 = (Char.unsafe_chr (x lsr 24 land 0xff)) in + let pos = b.position in + if pos + 3 >= b.length then resize b 4; + let b_buffer = b.buffer in + Bytes.unsafe_set b_buffer pos c1; + Bytes.unsafe_set b_buffer (pos + 1) c2; + Bytes.unsafe_set b_buffer (pos + 2) c3; + Bytes.unsafe_set b_buffer (pos + 3) c4; + b.position <- pos + 4 -let clear_env binary_annots = - if need_to_clear_env then - match binary_annots with - | Implementation s -> Implementation (cenv.structure cenv s) - | Interface s -> Interface (cenv.signature cenv s) - | Packed _ -> binary_annots - | Partial_implementation array -> - Partial_implementation (Array.map clear_part array) - | Partial_interface array -> - Partial_interface (Array.map clear_part array) - else binary_annots -exception Error of error -let input_cmt ic = (input_value ic : cmt_infos) +end +module Ext_namespace : sig +#1 "ext_namespace.mli" +(* Copyright (C) 2017- Authors of BuckleScript + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -let output_cmt oc cmt = - output_string oc Config.cmt_magic_number; - output_value oc (cmt : cmt_infos) +(** [make ~ns:"Ns" "a" ] + A typical example would return "a-Ns" + Note the namespace comes from the output of [namespace_of_package_name] +*) +val make : + ?ns:string -> string -> string -let read filename = -(* Printf.fprintf stderr "Cmt_format.read %s\n%!" filename; *) - let ic = open_in_bin filename in - try - let magic_number = read_magic_number ic in - let cmi, cmt = - if magic_number = Config.cmt_magic_number then - None, Some (input_cmt ic) - else if magic_number = Config.cmi_magic_number then - let cmi = Cmi_format.input_cmi ic in - let cmt = try - let magic_number = read_magic_number ic in - if magic_number = Config.cmt_magic_number then - let cmt = input_cmt ic in - Some cmt - else None - with _ -> None - in - Some cmi, cmt - else - raise(Cmi_format.Error(Cmi_format.Not_an_interface filename)) - in - close_in ic; -(* Printf.fprintf stderr "Cmt_format.read done\n%!"; *) - cmi, cmt - with e -> - close_in ic; - raise e +val try_split_module_name : + string -> (string * string ) option -let read_cmt filename = - match read filename with - _, None -> raise (Error (Not_a_typedtree filename)) - | _, Some cmt -> cmt -let read_cmi filename = - match read filename with - None, _ -> - raise (Cmi_format.Error (Cmi_format.Not_an_interface filename)) - | Some cmi, _ -> cmi -let saved_types = ref [] -let value_deps = ref [] +(* Note we have to output uncapitalized file Name, + or at least be consistent, since by reading cmi file on Case insensitive OS, we don't really know it is `list.cmi` or `List.cmi`, so that `require (./list.js)` or `require(./List.js)` + relevant issues: #1609, #913 -let clear () = - saved_types := []; - value_deps := [] + #1933 when removing ns suffix, don't pass the bound + of basename +*) +val change_ext_ns_suffix : + string -> + string -> + string -let add_saved_type b = saved_types := b :: !saved_types -let get_saved_types () = !saved_types -let set_saved_types l = saved_types := l +type file_kind = + | Upper_js + | Upper_bs + | Little_js + | Little_bs + (** [js_name_of_modulename ~little A-Ns] + *) +val js_name_of_modulename : + string -> + file_kind -> + string -let record_value_dependency vd1 vd2 = - if vd1.Types.val_loc <> vd2.Types.val_loc then - value_deps := (vd1, vd2) :: !value_deps +(* TODO handle cases like + '@angular/core' + its directory structure is like + {[ + @angular + |-------- core + ]} +*) +val is_valid_npm_package_name : string -> bool -let save_cmt filename modname binary_annots sourcefile initial_env cmi = - if !Clflags.binary_annotations && not !Clflags.print_types then begin - (if !Clflags.bs_only then Misc.output_to_bin_file_directly else - Misc.output_to_file_via_temporary - ~mode:[Open_binary] ) filename - (fun temp_file_name oc -> - let this_crc = - match cmi with - | None -> None - | Some cmi -> Some (output_cmi temp_file_name oc cmi) - in - let source_digest = Misc.may_map Digest.file sourcefile in - let cmt = { - cmt_modname = modname; - cmt_annots = clear_env binary_annots; - cmt_value_dependencies = !value_deps; - cmt_comments = Lexer.comments (); - cmt_args = Sys.argv; - cmt_sourcefile = sourcefile; - cmt_builddir = Sys.getcwd (); - cmt_loadpath = !Config.load_path; - cmt_source_digest = source_digest; - cmt_initial_env = if need_to_clear_env then - keep_only_summary initial_env else initial_env; - cmt_imports = List.sort compare (Env.imports ()); - cmt_interface_digest = this_crc; - cmt_use_summaries = need_to_clear_env; - } in - output_cmt oc cmt) - end; - clear () +val namespace_of_package_name : string -> string -end -module Ctype : sig -#1 "ctype.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +end = struct +#1 "ext_namespace.ml" -(* Operations on core types *) +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -open Asttypes -open Types -exception Unify of (type_expr * type_expr) list -exception Tags of label * label -exception Subtype of - (type_expr * type_expr) list * (type_expr * type_expr) list -exception Cannot_expand -exception Cannot_apply -exception Recursive_abbrev -exception Unification_recursive_abbrev of (type_expr * type_expr) list +(* Note the build system should check the validity of filenames + espeically, it should not contain '-' +*) +let ns_sep_char = '-' +let ns_sep = "-" -val init_def: int -> unit - (* Set the initial variable level *) -val begin_def: unit -> unit - (* Raise the variable level by one at the beginning of a definition. *) -val end_def: unit -> unit - (* Lower the variable level by one at the end of a definition *) -val begin_class_def: unit -> unit -val raise_nongen_level: unit -> unit -val reset_global_level: unit -> unit - (* Reset the global level before typing an expression *) -val increase_global_level: unit -> int -val restore_global_level: int -> unit - (* This pair of functions is only used in Typetexp *) -type levels = - { current_level: int; nongen_level: int; global_level: int; - saved_level: (int * int) list; } -val save_levels: unit -> levels -val set_levels: levels -> unit +let make ?ns cunit = + match ns with + | None -> cunit + | Some ns -> cunit ^ ns_sep ^ ns -val newty: type_desc -> type_expr -val newvar: ?name:string -> unit -> type_expr -val newvar2: ?name:string -> int -> type_expr - (* Return a fresh variable *) -val new_global_var: ?name:string -> unit -> type_expr - (* Return a fresh variable, bound at toplevel - (as type variables ['a] in type constraints). *) -val newobj: type_expr -> type_expr -val newconstr: Path.t -> type_expr list -> type_expr -val none: type_expr - (* A dummy type expression *) -val repr: type_expr -> type_expr - (* Return the canonical representative of a type. *) +let rec rindex_rec s i = + if i < 0 then i else + let char = String.unsafe_get s i in + if Ext_filename.is_dir_sep char then -1 + else if char = ns_sep_char then i + else + rindex_rec s (i - 1) -val object_fields: type_expr -> type_expr -val flatten_fields: - type_expr -> (string * field_kind * type_expr) list * type_expr - (* Transform a field type into a list of pairs label-type *) - (* The fields are sorted *) -val associate_fields: - (string * field_kind * type_expr) list -> - (string * field_kind * type_expr) list -> - (string * field_kind * type_expr * field_kind * type_expr) list * - (string * field_kind * type_expr) list * - (string * field_kind * type_expr) list -val opened_object: type_expr -> bool -val close_object: type_expr -> unit -val row_variable: type_expr -> type_expr - (* Return the row variable of an open object type *) -val set_object_name: - Ident.t -> type_expr -> type_expr list -> type_expr -> unit -val remove_object_name: type_expr -> unit -val hide_private_methods: type_expr -> unit -val find_cltype_for_path: Env.t -> Path.t -> type_declaration * type_expr -val lid_of_path: ?hash:string -> Path.t -> Longident.t +let change_ext_ns_suffix name ext = + let i = rindex_rec name (String.length name - 1) in + if i < 0 then name ^ ext + else String.sub name 0 i ^ ext (* FIXME: micro-optimizaiton*) -val sort_row_fields: (label * row_field) list -> (label * row_field) list -val merge_row_fields: - (label * row_field) list -> (label * row_field) list -> - (label * row_field) list * (label * row_field) list * - (label * row_field * row_field) list -val filter_row_fields: - bool -> (label * row_field) list -> (label * row_field) list +let try_split_module_name name = + let len = String.length name in + let i = rindex_rec name (len - 1) in + if i < 0 then None + else + Some (String.sub name (i+1) (len - i - 1), + String.sub name 0 i ) +type file_kind = + | Upper_js + | Upper_bs + | Little_js + | Little_bs -val generalize: type_expr -> unit - (* Generalize in-place the given type *) -val generalize_expansive: Env.t -> type_expr -> unit - (* Generalize the covariant part of a type, making - contravariant branches non-generalizable *) -val generalize_global: type_expr -> unit - (* Generalize the structure of a type, lowering variables - to !global_level *) -val generalize_structure: type_expr -> unit - (* Same, but variables are only lowered to !current_level *) -val generalize_spine: type_expr -> unit - (* Special function to generalize a method during inference *) -val correct_levels: type_expr -> type_expr - (* Returns a copy with decreasing levels *) -val limited_generalize: type_expr -> type_expr -> unit - (* Only generalize some part of the type - Make the remaining of the type non-generalizable *) -val instance: ?partial:bool -> Env.t -> type_expr -> type_expr - (* Take an instance of a type scheme *) - (* partial=None -> normal - partial=false -> newvar() for non generic subterms - partial=true -> newty2 ty.level Tvar for non generic subterms *) -val instance_def: type_expr -> type_expr - (* use defaults *) -val generic_instance: Env.t -> type_expr -> type_expr - (* Same as instance, but new nodes at generic_level *) -val instance_list: Env.t -> type_expr list -> type_expr list - (* Take an instance of a list of type schemes *) -val instance_constructor: - ?in_pattern:Env.t ref * int -> - constructor_description -> type_expr list * type_expr - (* Same, for a constructor *) -val instance_parameterized_type: - ?keep_names:bool -> - type_expr list -> type_expr -> type_expr list * type_expr -val instance_parameterized_type_2: - type_expr list -> type_expr list -> type_expr -> - type_expr list * type_expr list * type_expr -val instance_declaration: type_declaration -> type_declaration -val instance_class: - type_expr list -> class_type -> type_expr list * class_type -val instance_poly: - ?keep_names:bool -> - bool -> type_expr list -> type_expr -> type_expr list * type_expr - (* Take an instance of a type scheme containing free univars *) -val instance_label: - bool -> label_description -> type_expr list * type_expr * type_expr - (* Same, for a label *) -val apply: - Env.t -> type_expr list -> type_expr -> type_expr list -> type_expr - (* [apply [p1...pN] t [a1...aN]] match the arguments [ai] to - the parameters [pi] and returns the corresponding instance of - [t]. Exception [Cannot_apply] is raised in case of failure. *) + +(* let js_name_of_basename bs_suffix s = + change_ext_ns_suffix s + (if bs_suffix then Literals.suffix_bs_js else Literals.suffix_js ) *) -val expand_head_once: Env.t -> type_expr -> type_expr -val expand_head: Env.t -> type_expr -> type_expr -val try_expand_once_opt: Env.t -> type_expr -> type_expr -val expand_head_opt: Env.t -> type_expr -> type_expr -(** The compiler's own version of [expand_head] necessary for type-based - optimisations. *) +let js_name_of_modulename s little = + match little with + | Little_js -> + change_ext_ns_suffix (Ext_string.uncapitalize_ascii s) Literals.suffix_js + | Little_bs -> + change_ext_ns_suffix (Ext_string.uncapitalize_ascii s) Literals.suffix_bs_js + | Upper_js -> + change_ext_ns_suffix s Literals.suffix_js + | Upper_bs -> + change_ext_ns_suffix s Literals.suffix_bs_js -val full_expand: Env.t -> type_expr -> type_expr -val extract_concrete_typedecl: - Env.t -> type_expr -> Path.t * Path.t * type_declaration - (* Return the original path of the types, and the first concrete - type declaration found expanding it. - Raise [Not_found] if none appears or not a type constructor. *) +(* https://docs.npmjs.com/files/package.json + Some rules: + The name must be less than or equal to 214 characters. This includes the scope for scoped packages. + The name can't start with a dot or an underscore. + New packages must not have uppercase letters in the name. + The name ends up being part of a URL, an argument on the command line, and a folder name. Therefore, the name can't contain any non-URL-safe characters. +*) +let is_valid_npm_package_name (s : string) = + let len = String.length s in + len <= 214 && (* magic number forced by npm *) + len > 0 && + match String.unsafe_get s 0 with + | 'a' .. 'z' | '@' -> + Ext_string.for_all_from s 1 + (fun x -> + match x with + | 'a'..'z' | '0'..'9' | '_' | '-' -> true + | _ -> false ) + | _ -> false -val enforce_constraints: Env.t -> type_expr -> unit -val unify: Env.t -> type_expr -> type_expr -> unit - (* Unify the two types given. Raise [Unify] if not possible. *) -val unify_gadt: newtype_level:int -> Env.t ref -> type_expr -> type_expr -> unit - (* Unify the two types given and update the environment with the - local constraints. Raise [Unify] if not possible. *) -val unify_var: Env.t -> type_expr -> type_expr -> unit - (* Same as [unify], but allow free univars when first type - is a variable. *) -val with_passive_variants: ('a -> 'b) -> ('a -> 'b) - (* Call [f] in passive_variants mode, for exhaustiveness check. *) -val filter_arrow: Env.t -> type_expr -> arg_label -> type_expr * type_expr - (* A special case of unification (with l:'a -> 'b). *) -val filter_method: Env.t -> string -> private_flag -> type_expr -> type_expr - (* A special case of unification (with {m : 'a; 'b}). *) -val check_filter_method: Env.t -> string -> private_flag -> type_expr -> unit - (* A special case of unification (with {m : 'a; 'b}), returning unit. *) -val occur_in: Env.t -> type_expr -> type_expr -> bool -val deep_occur: type_expr -> type_expr -> bool -val filter_self_method: - Env.t -> string -> private_flag -> (Ident.t * type_expr) Meths.t ref -> - type_expr -> Ident.t * type_expr -val moregeneral: Env.t -> bool -> type_expr -> type_expr -> bool - (* Check if the first type scheme is more general than the second. *) +let namespace_of_package_name (s : string) : string = + let len = String.length s in + let buf = Ext_buffer.create len in + let add capital ch = + Ext_buffer.add_char buf + (if capital then + (Ext_char.uppercase_ascii ch) + else ch) in + let rec aux capital off len = + if off >= len then () + else + let ch = String.unsafe_get s off in + match ch with + | 'a' .. 'z' + | 'A' .. 'Z' + | '0' .. '9' + -> + add capital ch ; + aux false (off + 1) len + | '/' + | '-' -> + aux true (off + 1) len + | _ -> aux capital (off+1) len + in + aux true 0 len ; + Ext_buffer.contents buf -val rigidify: type_expr -> type_expr list - (* "Rigidify" a type and return its type variable *) -val all_distinct_vars: Env.t -> type_expr list -> bool - (* Check those types are all distinct type variables *) -val matches: Env.t -> type_expr -> type_expr -> bool - (* Same as [moregeneral false], implemented using the two above - functions and backtracking. Ignore levels *) +end +module Outcome_printer_ns : sig +#1 "outcome_printer_ns.mli" +(* Copyright (C) 2017 Authors of BuckleScript + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -type class_match_failure = - CM_Virtual_class - | CM_Parameter_arity_mismatch of int * int - | CM_Type_parameter_mismatch of Env.t * (type_expr * type_expr) list - | CM_Class_type_mismatch of Env.t * class_type * class_type - | CM_Parameter_mismatch of Env.t * (type_expr * type_expr) list - | CM_Val_type_mismatch of string * Env.t * (type_expr * type_expr) list - | CM_Meth_type_mismatch of string * Env.t * (type_expr * type_expr) list - | CM_Non_mutable_value of string - | CM_Non_concrete_value of string - | CM_Missing_value of string - | CM_Missing_method of string - | CM_Hide_public of string - | CM_Hide_virtual of string * string - | CM_Public_method of string - | CM_Private_method of string - | CM_Virtual_method of string -val match_class_types: - ?trace:bool -> Env.t -> class_type -> class_type -> class_match_failure list - (* Check if the first class type is more general than the second. *) -val equal: Env.t -> bool -> type_expr list -> type_expr list -> bool - (* [equal env [x1...xn] tau [y1...yn] sigma] - checks whether the parameterized types - [/\x1.../\xn.tau] and [/\y1.../\yn.sigma] are equivalent. *) -val match_class_declarations: - Env.t -> type_expr list -> class_type -> type_expr list -> - class_type -> class_match_failure list - (* Check if the first class type is more general than the second. *) +(** This funciton is used to + reverse namespace printing to + avoid namespace leaking +*) + val out_ident : + Format.formatter -> string -> unit +end = struct +#1 "outcome_printer_ns.ml" +(* Copyright (C) 2017 Authors of BuckleScript + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -val enlarge_type: Env.t -> type_expr -> type_expr * bool - (* Make a type larger, flag is true if some pruning had to be done *) -val subtype: Env.t -> type_expr -> type_expr -> unit -> unit - (* [subtype env t1 t2] checks that [t1] is a subtype of [t2]. - It accumulates the constraints the type variables must - enforce and returns a function that enforces this - constraints. *) +let ps = Format.pp_print_string -val nondep_type: Env.t -> Ident.t -> type_expr -> type_expr - (* Return a type equivalent to the given type but without - references to the given module identifier. Raise [Not_found] - if no such type exists. *) -val nondep_type_decl: - Env.t -> Ident.t -> Ident.t -> bool -> type_declaration -> - type_declaration - (* Same for type declarations. *) -val nondep_extension_constructor: - Env.t -> Ident.t -> extension_constructor -> - extension_constructor - (* Same for extension constructor *) -val nondep_class_declaration: - Env.t -> Ident.t -> class_declaration -> class_declaration - (* Same for class declarations. *) -val nondep_cltype_declaration: - Env.t -> Ident.t -> class_type_declaration -> class_type_declaration - (* Same for class type declarations. *) -(*val correct_abbrev: Env.t -> Path.t -> type_expr list -> type_expr -> unit*) -val cyclic_abbrev: Env.t -> Ident.t -> type_expr -> bool -val is_contractive: Env.t -> Path.t -> bool -val normalize_type: Env.t -> type_expr -> unit +let out_ident ppf s = + ps ppf ( + match s with + | "Js_null" + -> "Js.Null" + | "Js_undefined" + -> "Js.Undefined" + | "Js_null_undefined" + -> "Js.Nullable" + | "Js_exn" + -> "Js.Exn" + | "Js_array" + -> "Js.Array" + | "Js_string" + -> "Js.String" + | "Js_re" + -> "Js.Re" + | "Js_promise" + -> "Js.Promise" + | "Js_date" + -> "Js.Date" + | "Js_dict" + -> "Js.Dict" + | "Js_global" + -> "Js.Global" + | "Js_json" + -> "Js.Json" + | "Js_math" + -> "Js.Math" + | "Js_obj" + -> "Js.Obj" + | "Js_typed_array" + -> "Js.Typed_array" + | "Js_types" + -> "Js.Types" + | "Js_float" + -> "Js.Float" + | "Js_int" + -> "Js.Int" + | "Js_option" + -> "Js.Option" + | "Js_result" + -> "Js.Result" + |"Js_list" + -> "Js.List" + | "Js_vector" + -> "Js.Vector" +(* Belt_libs *) + | "Belt_Id" -> "Belt.Id" + | "Belt_Array" -> "Belt.Array" -val closed_schema: Env.t -> type_expr -> bool - (* Check whether the given type scheme contains no non-generic - type variables *) + | "Belt_SortArray" -> "Belt.SortArray" + | "Belt_SortArrayInt" -> "Belt.SortArray.Int" + | "Belt_SortArrayString" -> "Belt.SortArray.String" + + | "Belt_MutableQueue" -> "Belt.MutableQueue" + | "Belt_MutableStack" -> "Belt.MutableStack" + | "Belt_List" -> "Belt.List" + | "Belt_Range" -> "Belt.Range" + + | "Belt_Set" -> "Belt.Set" + | "Belt_SetInt" -> "Belt.Set.Int" + | "Belt_SetString" -> "Belt.Set.String" -val free_variables: ?env:Env.t -> type_expr -> type_expr list - (* If env present, then check for incomplete definitions too *) -val closed_type_decl: type_declaration -> type_expr option -val closed_extension_constructor: extension_constructor -> type_expr option -type closed_class_failure = - CC_Method of type_expr * bool * string * type_expr - | CC_Value of type_expr * bool * string * type_expr -val closed_class: - type_expr list -> class_signature -> closed_class_failure option - (* Check whether all type variables are bound *) + | "Belt_Map" -> "Belt.Map" + | "Belt_MapInt" -> "Belt.Map.Int" + | "Belt_MapString" -> "Belt.Map.String" -val unalias: type_expr -> type_expr -val signature_of_class_type: class_type -> class_signature -val self_type: class_type -> type_expr -val class_type_arity: class_type -> int -val arity: type_expr -> int - (* Return the arity (as for curried functions) of the given type. *) + | "Belt_Option" -> "Belt.Option" -val collapse_conj_params: Env.t -> type_expr list -> unit - (* Collapse conjunctive types in class parameters *) + | "Belt_MutableSet" -> "Belt.MutableSet" + | "Belt_MutableSetInt" -> "Belt.MutableSet.Int" + | "Belt_MutableSetString" -> "Belt.MutableSet.String" -val get_current_level: unit -> int -val wrap_trace_gadt_instances: Env.t -> ('a -> 'b) -> 'a -> 'b -val reset_reified_var_counter: unit -> unit + | "Belt_MutableMap" -> "Belt.MutableMap" + | "Belt_MutableMapInt" -> "Belt.MutableMap.Int" + | "Belt_MutableMapString" -> "Belt.MutableMap.String" + + | "Belt_HashSet" -> "Belt.HashSet" + | "Belt_HashSetInt" -> "Belt.HashSet.Int" + | "Belt_HashSetString" -> "Belt.HashSet.String" + + | "Belt_HashMap" -> "Belt.HashMap" + | "Belt_HashMapString" -> "Belt.HashMap.String" + | "Belt_HashMapInt" -> "Belt.HashMap.Int" + | "Belt_Debug" -> "Belt.Debug" + | s -> + (match Ext_namespace.try_split_module_name s with + | None -> s + | Some (ns,m) + -> ns ^ "."^ m + ) + ) -val maybe_pointer_type : Env.t -> type_expr -> bool - (* True if type is possibly pointer, false if definitely not a pointer *) -(* Stubs *) -val package_subtype : - (Env.t -> Path.t -> Longident.t list -> type_expr list -> - Path.t -> Longident.t list -> type_expr list -> bool) ref -end = struct -#1 "ctype.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy and Jerome Vouillon, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +end +module Record_attributes_check += struct +#1 "record_attributes_check.ml" +(* Copyright (C) 2019- Authors of BuckleScript + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -(* Operations on core types *) +type label = Types.label_description -open Misc -open Asttypes -open Types -open Btype +let fn = (fun (attr : Parsetree.attribute) -> +match attr with +| {txt = "bs.as"}, PStr + [{pstr_desc = Pstr_eval ({pexp_desc = Pexp_constant (Pconst_string(s,_))},_ )}] -> + (* Bs_ast_invariant.mark_used_bs_attribute attr; *) + Some s +| _ -> None +) -(* - Type manipulation after type inference - ====================================== - If one wants to manipulate a type after type inference (for - instance, during code generation or in the debugger), one must - first make sure that the type levels are correct, using the - function [correct_levels]. Then, this type can be correctly - manipulated by [apply], [expand_head] and [moregeneral]. -*) +let fld_record (lbl : label) = + Lambda.Fld_record + {name = Ext_list.find_def lbl.lbl_attributes fn lbl.lbl_name; mutable_flag = lbl.Types.lbl_mut} + +let fld_record_set (lbl : label) = + Lambda.Fld_record_set + (Ext_list.find_def lbl.lbl_attributes fn lbl.lbl_name) + +let blk_record fields = + let all_labels_info = + Ext_array.map fields + (fun ((lbl : label),_) -> + Ext_list.find_def lbl.Types.lbl_attributes fn lbl.lbl_name) in + Lambda.Blk_record all_labels_info -(* - General notes - ============= - - As much sharing as possible should be kept : it makes types - smaller and better abbreviated. - When necessary, some sharing can be lost. Types will still be - printed correctly (+++ TO DO...), and abbreviations defined by a - class do not depend on sharing thanks to constrained - abbreviations. (Of course, even if some sharing is lost, typing - will still be correct.) - - All nodes of a type have a level : that way, one know whether a - node need to be duplicated or not when instantiating a type. - - Levels of a type are decreasing (generic level being considered - as greatest). - - The level of a type constructor is superior to the binding - time of its path. - - Recursive types without limitation should be handled (even if - there is still an occur check). This avoid treating specially the - case for objects, for instance. Furthermore, the occur check - policy can then be easily changed. -*) +let check_bs_attributes_inclusion + (attrs1 : Parsetree.attributes) + (attrs2 : Parsetree.attributes) + lbl_name = + let a = Ext_list.find_def attrs1 fn lbl_name in + let b = Ext_list.find_def attrs2 fn lbl_name in + if a = b then None + else Some (a,b) -(**** Errors ****) -exception Unify of (type_expr * type_expr) list -exception Tags of label * label -let () = - Location.register_error_of_exn - (function - | Tags (l, l') -> - Some - Location. - (errorf ~loc:(in_file !input_name) - "In this program,@ variant constructors@ `%s and `%s@ \ - have the same hash value.@ Change one of them." l l' - ) - | _ -> None - ) +end +module Bs_conditional_initial : sig +#1 "bs_conditional_initial.mli" +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -exception Subtype of - (type_expr * type_expr) list * (type_expr * type_expr) list +(** This function set up built in compile time variables used in + conditional compilation so that + {[ + #if BS then + #elif .. then + #end + ]} + Is understood, also make sure the playground do the same initialization. +*) +val setup_env : unit -> unit -exception Cannot_expand -exception Cannot_apply +end = struct +#1 "bs_conditional_initial.ml" +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -exception Recursive_abbrev -(* GADT: recursive abbrevs can appear as a result of local constraints *) -exception Unification_recursive_abbrev of (type_expr * type_expr) list +let setup_env () = + Clflags.compile_only := true; + Clflags.bs_only := true; + Clflags.no_implicit_current_dir := true; + (* default true + otherwise [bsc -I sc src/hello.ml ] will include current directory to search path + *) + Clflags.assume_no_mli := Clflags.Mli_non_exists; + Clflags.unsafe_string := false; + Clflags.debug := true; + Clflags.record_event_when_debug := false; + Clflags.binary_annotations := true; + (* Turn on [-no-alias-deps] by default -- double check *) + Oprint.out_ident := Outcome_printer_ns.out_ident; + Builtin_attributes.check_bs_attributes_inclusion := Record_attributes_check.check_bs_attributes_inclusion; + Lambda.fld_record := Record_attributes_check.fld_record; + Lambda.fld_record_set := Record_attributes_check.fld_record_set; + Lambda.blk_record := Record_attributes_check.blk_record; -(**** Type level management ****) + Lexer.replace_directive_bool "BS" true; + Lexer.replace_directive_string "BS_VERSION" Bs_version.version + -let current_level = ref 0 -let nongen_level = ref 0 -let global_level = ref 1 -let saved_level = ref [] -type levels = - { current_level: int; nongen_level: int; global_level: int; - saved_level: (int * int) list; } -let save_levels () = - { current_level = !current_level; - nongen_level = !nongen_level; - global_level = !global_level; - saved_level = !saved_level } -let set_levels l = - current_level := l.current_level; - nongen_level := l.nongen_level; - global_level := l.global_level; - saved_level := l.saved_level +end +module Bsb_build_schemas += struct +#1 "bsb_build_schemas.ml" +(* Copyright (C) 2017 Authors of BuckleScript + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -let get_current_level () = !current_level -let init_def level = current_level := level; nongen_level := level -let begin_def () = - saved_level := (!current_level, !nongen_level) :: !saved_level; - incr current_level; nongen_level := !current_level -let begin_class_def () = - saved_level := (!current_level, !nongen_level) :: !saved_level; - incr current_level -let raise_nongen_level () = - saved_level := (!current_level, !nongen_level) :: !saved_level; - nongen_level := !current_level -let end_def () = - let (cl, nl) = List.hd !saved_level in - saved_level := List.tl !saved_level; - current_level := cl; nongen_level := nl -let reset_global_level () = - global_level := !current_level + 1 -let increase_global_level () = - let gl = !global_level in - global_level := !current_level; - gl -let restore_global_level gl = - global_level := gl +let files = "files" +let version = "version" +let name = "name" +(* let ocaml_config = "ocaml-config" *) +let bsdep = "bsdep" +let ppx_flags = "ppx-flags" +let pp_flags = "pp-flags" +let bsc = "bsc" +let refmt = "refmt" -(**** Whether a path points to an object type (with hidden row variable) ****) -let is_object_type path = - let name = - match path with Path.Pident id -> Ident.name id - | Path.Pdot(_, s,_) -> s - | Path.Papply _ -> assert false - in name.[0] = '#' +let bs_external_includes = "bs-external-includes" +let bs_lib_dir = "bs-lib-dir" +let bs_dependencies = "bs-dependencies" +let bs_dev_dependencies = "bs-dev-dependencies" -(**** Control tracing of GADT instances *) -let trace_gadt_instances = ref false -let check_trace_gadt_instances env = - not !trace_gadt_instances && Env.has_local_constraints env && - (trace_gadt_instances := true; cleanup_abbrev (); true) +let sources = "sources" +let dir = "dir" +let files = "files" +let subdirs = "subdirs" +let bsc_flags = "bsc-flags" +let excludes = "excludes" +let slow_re = "slow-re" +let resources = "resources" +let public = "public" +let js_post_build = "js-post-build" +let cmd = "cmd" +let ninja = "ninja" +let package_specs = "package-specs" -let reset_trace_gadt_instances b = - if b then trace_gadt_instances := false +let generate_merlin = "generate-merlin" -let wrap_trace_gadt_instances env f x = - let b = check_trace_gadt_instances env in - let y = f x in - reset_trace_gadt_instances b; - y +let type_ = "type" +let dev = "dev" -(**** Abbreviations without parameters ****) -(* Shall reset after generalizing *) +let export_all = "all" +let export_none = "none" -let simple_abbrevs = ref Mnil +let bsb_dir_group = "bsb_dir_group" +let g_lib_incls = "g_lib_incls" +let use_stdlib = "use-stdlib" +let reason = "reason" +let react_jsx = "react-jsx" -let proper_abbrevs path tl abbrev = - if tl <> [] || !trace_gadt_instances || !Clflags.principal || - is_object_type path - then abbrev - else simple_abbrevs +let entries = "entries" +let kind = "kind" +let main = "main" +let cut_generators = "cut-generators" +let generators = "generators" +let command = "command" +let edge = "edge" +let namespace = "namespace" +let in_source = "in-source" +let warnings = "warnings" +let number = "number" +let error = "error" +let suffix = "suffix" +let gentypeconfig = "gentypeconfig" +let path = "path" +let ignored_dirs = "ignored-dirs" +end +module Bsb_pkg_types : sig +#1 "bsb_pkg_types.mli" +(* Copyright (C) 2019- Authors of BuckleScript + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -(**** Some type creators ****) -(* Re-export generic type creators *) +type t = + | Global of string + | Scope of string * scope +and scope = string -let newty2 = Btype.newty2 -let newty desc = newty2 !current_level desc +val to_string : t -> string +val print : Format.formatter -> t -> unit +val equal : t -> t -> bool -let newvar ?name () = newty2 !current_level (Tvar name) -let newvar2 ?name level = newty2 level (Tvar name) -let new_global_var ?name () = newty2 !global_level (Tvar name) +(* The second element could be empty or dropped +*) +val extract_pkg_name_and_file : string -> t * string +val string_as_package : string -> t +end = struct +#1 "bsb_pkg_types.ml" -let newobj fields = newty (Tobject (fields, ref None)) +(* Copyright (C) 2018- Authors of BuckleScript + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -let newconstr path tyl = newty (Tconstr (path, tyl, ref Mnil)) +let (//) = Filename.concat -let none = newty (Ttuple []) (* Clearly ill-formed type *) +type t = + | Global of string + | Scope of string * scope +and scope = string -(**** Representative of a type ****) +let to_string (x : t) = + match x with + | Global s -> s + | Scope (s,scope) -> scope // s -(* Re-export repr *) -let repr = repr +let print fmt (x : t) = + match x with + | Global s -> Format.pp_print_string fmt s + | Scope(name,scope) -> + Format.fprintf fmt "%s/%s" scope name -(**** Type maps ****) +let equal (x : t) y = + match x, y with + | Scope(a0,a1), Scope(b0,b1) + -> a0 = b0 && a1 = b1 + | Global a0, Global b0 -> a0 = b0 + | Scope _, Global _ + | Global _, Scope _ -> false -module TypePairs = - Hashtbl.Make (struct - type t = type_expr * type_expr - let equal (t1, t1') (t2, t2') = (t1 == t2) && (t1' == t2') - let hash (t, t') = t.id + 93 * t'.id - end) +(** + input: {[ + @hello/yy/xx + hello/yy + ]} + FIXME: fix invalid input + {[ + hello//xh//helo + ]} +*) +let extract_pkg_name_and_file (s : string) = + let len = String.length s in + assert (len > 0 ); + let v = String.unsafe_get s 0 in + if v = '@' then + let scope_id = + Ext_string.no_slash_idx s in + assert (scope_id > 0); + let pkg_id = + Ext_string.no_slash_idx_from + s (scope_id + 1) in + let scope = + String.sub s 0 scope_id in + + if pkg_id < 0 then + (Scope(String.sub s (scope_id + 1) (len - scope_id - 1), scope),"") + else + (Scope( + String.sub s (scope_id + 1) (pkg_id - scope_id - 1), scope), + String.sub s (pkg_id + 1) (len - pkg_id - 1)) + else + let pkg_id = Ext_string.no_slash_idx s in + if pkg_id < 0 then + Global s , "" + else + Global (String.sub s 0 pkg_id), + (String.sub s (pkg_id + 1) (len - pkg_id - 1)) -(**** unification mode ****) +let string_as_package (s : string) : t = + let len = String.length s in + assert (len > 0); + let v = String.unsafe_get s 0 in + if v = '@' then + let scope_id = + Ext_string.no_slash_idx s in + assert (scope_id > 0); + Scope( + String.sub s (scope_id + 1) (len - scope_id - 1), + String.sub s 0 scope_id + ) + else Global s +end +module Ext_json : sig +#1 "ext_json.mli" +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -type unification_mode = - | Expression (* unification in expression *) - | Pattern (* unification in pattern which may add local constraints *) -let umode = ref Expression -let generate_equations = ref false -let assume_injective = ref false +type path = string list +type status = + | No_path + | Found of Ext_json_types.t + | Wrong_type of path -let set_mode_pattern ~generate ~injective f = - let old_unification_mode = !umode - and old_gen = !generate_equations - and old_inj = !assume_injective in - try - umode := Pattern; - generate_equations := generate; - assume_injective := injective; - let ret = f () in - umode := old_unification_mode; - generate_equations := old_gen; - assume_injective := old_inj; - ret - with e -> - umode := old_unification_mode; - generate_equations := old_gen; - assume_injective := old_inj; - raise e -(*** Checks for type definitions ***) +type callback = + [ + `Str of (string -> unit) + | `Str_loc of (string -> Lexing.position -> unit) + | `Flo of (string -> unit ) + | `Flo_loc of (string -> Lexing.position -> unit ) + | `Bool of (bool -> unit ) + | `Obj of (Ext_json_types.t String_map.t -> unit) + | `Arr of (Ext_json_types.t array -> unit ) + | `Arr_loc of + (Ext_json_types.t array -> Lexing.position -> Lexing.position -> unit) + | `Null of (unit -> unit) + | `Not_found of (unit -> unit) + | `Id of (Ext_json_types.t -> unit ) + ] -let in_current_module = function - | Path.Pident _ -> true - | Path.Pdot _ | Path.Papply _ -> false +val test: + ?fail:(unit -> unit) -> + string -> callback + -> Ext_json_types.t String_map.t + -> Ext_json_types.t String_map.t -let in_pervasives p = - in_current_module p && - try ignore (Env.find_type p Env.initial_safe_string); true - with Not_found -> false +val query : path -> Ext_json_types.t -> status -let is_datatype decl= - match decl.type_kind with - Type_record _ | Type_variant _ | Type_open -> true - | Type_abstract -> false +val loc_of : Ext_json_types.t -> Ext_position.t +val equal : Ext_json_types.t -> Ext_json_types.t -> bool - (**********************************************) - (* Miscellaneous operations on object types *) - (**********************************************) +end = struct +#1 "ext_json.ml" +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -(* Note: - We need to maintain some invariants: - * cty_self must be a Tobject - * ... -*) +type callback = + [ + `Str of (string -> unit) + | `Str_loc of (string -> Lexing.position -> unit) + | `Flo of (string -> unit ) + | `Flo_loc of (string -> Lexing.position -> unit ) + | `Bool of (bool -> unit ) + | `Obj of (Ext_json_types.t String_map.t -> unit) + | `Arr of (Ext_json_types.t array -> unit ) + | `Arr_loc of (Ext_json_types.t array -> Lexing.position -> Lexing.position -> unit) + | `Null of (unit -> unit) + | `Not_found of (unit -> unit) + | `Id of (Ext_json_types.t -> unit ) + ] -(**** Object field manipulation. ****) -let object_fields ty = - match (repr ty).desc with - Tobject (fields, _) -> fields - | _ -> assert false +type path = string list -let flatten_fields ty = - let rec flatten l ty = - let ty = repr ty in - match ty.desc with - Tfield(s, k, ty1, ty2) -> - flatten ((s, k, ty1)::l) ty2 - | _ -> - (l, ty) - in - let (l, r) = flatten [] ty in - (List.sort (fun (n, _, _) (n', _, _) -> compare n n') l, r) +type status = + | No_path + | Found of Ext_json_types.t + | Wrong_type of path -let build_fields level = - List.fold_right - (fun (s, k, ty1) ty2 -> newty2 level (Tfield(s, k, ty1, ty2))) +let test ?(fail=(fun () -> ())) key + (cb : callback) (m : Ext_json_types.t String_map.t) + = + begin match String_map.find_exn m key, cb with + | exception Not_found -> + begin match cb with `Not_found f -> f () + | _ -> fail () + end + | True _, `Bool cb -> cb true + | False _, `Bool cb -> cb false + | Flo {flo = s} , `Flo cb -> cb s + | Flo {flo = s; loc} , `Flo_loc cb -> cb s loc + | Obj {map = b} , `Obj cb -> cb b + | Arr {content}, `Arr cb -> cb content + | Arr {content; loc_start ; loc_end}, `Arr_loc cb -> + cb content loc_start loc_end + | Null _, `Null cb -> cb () + | Str {str = s }, `Str cb -> cb s + | Str {str = s ; loc }, `Str_loc cb -> cb s loc + | any , `Id cb -> cb any + | _, _ -> fail () + end; + m +let query path (json : Ext_json_types.t ) = + let rec aux acc paths json = + match path with + | [] -> Found json + | p :: rest -> + match json with + | Obj {map } -> + (match String_map.find_opt map p with + | Some m -> aux (p::acc) rest m + | None -> No_path) + | _ -> Wrong_type acc + in aux [] path json -let associate_fields fields1 fields2 = - let rec associate p s s' = - function - (l, []) -> - (List.rev p, (List.rev s) @ l, List.rev s') - | ([], l') -> - (List.rev p, List.rev s, (List.rev s') @ l') - | ((n, k, t)::r, (n', k', t')::r') when n = n' -> - associate ((n, k, t, k', t')::p) s s' (r, r') - | ((n, k, t)::r, ((n', _k', _t')::_ as l')) when n < n' -> - associate p ((n, k, t)::s) s' (r, l') - | (((_n, _k, _t)::_ as l), (n', k', t')::r') (* when n > n' *) -> - associate p s ((n', k', t')::s') (l, r') - in - associate [] [] [] (fields1, fields2) -(**** Check whether an object is open ****) +let loc_of (x : Ext_json_types.t) = + match x with + | True p | False p | Null p -> p + | Str p -> p.loc + | Arr p -> p.loc_start + | Obj p -> p.loc + | Flo p -> p.loc -(* +++ The abbreviation should eventually be expanded *) -let rec object_row ty = - let ty = repr ty in - match ty.desc with - Tobject (t, _) -> object_row t - | Tfield(_, _, _, t) -> object_row t - | _ -> ty -let opened_object ty = - match (object_row ty).desc with - | Tvar _ | Tunivar _ | Tconstr _ -> true - | _ -> false +let rec equal + (x : Ext_json_types.t) + (y : Ext_json_types.t) = + match x with + | Null _ -> (* [%p? Null _ ] *) + begin match y with + | Null _ -> true + | _ -> false end + | Str {str } -> + begin match y with + | Str {str = str2} -> str = str2 + | _ -> false end + | Flo {flo} + -> + begin match y with + | Flo {flo = flo2} -> + flo = flo2 + | _ -> false + end + | True _ -> + begin match y with + | True _ -> true + | _ -> false + end + | False _ -> + begin match y with + | False _ -> true + | _ -> false + end + | Arr {content} + -> + begin match y with + | Arr {content = content2} + -> + Ext_array.for_all2_no_exn content content2 equal + | _ -> false + end -let concrete_object ty = - match (object_row ty).desc with - | Tvar _ -> false - | _ -> true + | Obj {map} -> + begin match y with + | Obj { map = map2} -> + String_map.equal map map2 equal + | _ -> false + end -(**** Close an object ****) -let close_object ty = - let rec close ty = - let ty = repr ty in - match ty.desc with - Tvar _ -> - link_type ty (newty2 ty.level Tnil) - | Tfield(_, _, _, ty') -> close ty' - | _ -> assert false - in - match (repr ty).desc with - Tobject (ty, _) -> close ty - | _ -> assert false +end +module Bsb_exception : sig +#1 "bsb_exception.mli" +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -(**** Row variable of an object type ****) -let row_variable ty = - let rec find ty = - let ty = repr ty in - match ty.desc with - Tfield (_, _, _, ty) -> find ty - | Tvar _ -> ty - | _ -> assert false - in - match (repr ty).desc with - Tobject (fi, _) -> find fi - | _ -> assert false +(** + This module is used for fatal errros +*) +type error +exception Error of error -(**** Object name manipulation ****) -(* +++ Bientot obsolete *) +val print : Format.formatter -> error -> unit +val package_not_found : pkg:Bsb_pkg_types.t -> json:string option -> 'a -let set_object_name id rv params ty = - match (repr ty).desc with - Tobject (_fi, nm) -> - set_name nm (Some (Path.Pident id, rv::params)) - | _ -> - assert false +val conflict_module: + string -> string -> string -> 'a + +val errorf : loc:Ext_position.t -> ('a, unit, string, 'b) format4 -> 'a -let remove_object_name ty = - match (repr ty).desc with - Tobject (_, nm) -> set_name nm None - | Tconstr (_, _, _) -> () - | _ -> fatal_error "Ctype.remove_object_name" +val config_error : Ext_json_types.t -> string -> 'a -(**** Hiding of private methods ****) +val invalid_spec : string -> 'a -let hide_private_methods ty = - match (repr ty).desc with - Tobject (fi, nm) -> - nm := None; - let (fl, _) = flatten_fields fi in - List.iter - (function (_, k, _) -> - match field_kind_repr k with - Fvar r -> set_kind r Fabsent - | _ -> ()) - fl - | _ -> - assert false +val invalid_json : string -> 'a +val no_implementation : string -> 'a - (*******************************) - (* Operations on class types *) - (*******************************) +val not_consistent : string -> 'a +end = struct +#1 "bsb_exception.ml" +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -let rec signature_of_class_type = - function - Cty_constr (_, _, cty) -> signature_of_class_type cty - | Cty_signature sign -> sign - | Cty_arrow (_, _, cty) -> signature_of_class_type cty -let self_type cty = - repr (signature_of_class_type cty).csig_self +type error = + | Package_not_found of Bsb_pkg_types.t * string option (* json file *) + | Json_config of Ext_position.t * string + | Invalid_json of string + | Invalid_spec of string + | Conflict_module of string * string * string + | No_implementation of string + | Not_consistent of string -let rec class_type_arity = - function - Cty_constr (_, _, cty) -> class_type_arity cty - | Cty_signature _ -> 0 - | Cty_arrow (_, _, cty) -> 1 + class_type_arity cty +exception Error of error +let error err = raise (Error err) +let package_not_found ~pkg ~json = + error (Package_not_found(pkg,json)) - (*******************************************) - (* Miscellaneous operations on row types *) - (*******************************************) +let print (fmt : Format.formatter) (x : error) = + match x with + | Conflict_module (modname,dir1,dir2) -> + Format.fprintf fmt + "@{Error:@} %s found in two directories: (%s, %s)\n\ + File names must be unique per project" + modname dir1 dir2 + | Not_consistent modname -> + Format.fprintf fmt + "@{Error:@} %s has implementation/interface in non-consistent syntax(reason/ocaml)" modname + | No_implementation (modname) -> + Format.fprintf fmt + "@{Error:@} %s does not have implementation file" modname + | Package_not_found (name,json_opt) -> + let in_json = match json_opt with + | None -> Ext_string.empty + | Some x -> " in " ^ x in + let name = Bsb_pkg_types.to_string name in + if Ext_string.equal name Bs_version.package_name then + Format.fprintf fmt + "File \"bsconfig.json\", line 1\n\ + @{Error:@} package @{bs-platform@} is not found %s\n\ + It's the basic, required package. If you have it installed globally,\n\ + Please run `npm link bs-platform` to make it available" in_json + else + Format.fprintf fmt + "File \"bsconfig.json\", line 1\n\ + @{Error:@} package @{%s@} not found or built %s\n\ + - Did you install it?\n\ + - If you did, did you run `bsb -make-world`?" + name + in_json -let sort_row_fields = List.sort (fun (p,_) (q,_) -> compare p q) + | Json_config (pos,s) -> + Format.fprintf fmt "File \"bsconfig.json\", line %d:\n\ + @{Error:@} %s \n\ + For more details, please checkout the schema http://bucklescript.github.io/bucklescript/docson/#build-schema.json" + pos.pos_lnum s + | Invalid_spec s -> + Format.fprintf fmt + "@{Error: Invalid bsconfig.json %s@}" s + | Invalid_json s -> + Format.fprintf fmt + "File %S, line 1\n\ + @{Error: Invalid json format@}" s -let rec merge_rf r1 r2 pairs fi1 fi2 = - match fi1, fi2 with - (l1,f1 as p1)::fi1', (l2,f2 as p2)::fi2' -> - if l1 = l2 then merge_rf r1 r2 ((l1,f1,f2)::pairs) fi1' fi2' else - if l1 < l2 then merge_rf (p1::r1) r2 pairs fi1' fi2 else - merge_rf r1 (p2::r2) pairs fi1 fi2' - | [], _ -> (List.rev r1, List.rev_append r2 fi2, pairs) - | _, [] -> (List.rev_append r1 fi1, List.rev r2, pairs) +let conflict_module modname dir1 dir2 = + error (Conflict_module (modname,dir1,dir2)) +let no_implementation modname = + error (No_implementation modname) +let not_consistent modname = + error (Not_consistent modname) +let errorf ~loc fmt = + Format.ksprintf (fun s -> error (Json_config (loc,s))) fmt -let merge_row_fields fi1 fi2 = - match fi1, fi2 with - [], _ | _, [] -> (fi1, fi2, []) - | [p1], _ when not (List.mem_assoc (fst p1) fi2) -> (fi1, fi2, []) - | _, [p2] when not (List.mem_assoc (fst p2) fi1) -> (fi1, fi2, []) - | _ -> merge_rf [] [] [] (sort_row_fields fi1) (sort_row_fields fi2) -let rec filter_row_fields erase = function - [] -> [] - | (_l,f as p)::fi -> - let fi = filter_row_fields erase fi in - match row_field_repr f with - Rabsent -> fi - | Reither(_,_,false,e) when erase -> set_row_field e Rabsent; fi - | _ -> p :: fi +let config_error config fmt = + let loc = Ext_json.loc_of config in - (**************************************) - (* Check genericity of type schemes *) - (**************************************) + error (Json_config (loc,fmt)) +let invalid_spec s = error (Invalid_spec s) -exception Non_closed of type_expr * bool +let invalid_json s = error (Invalid_json s) -let free_variables = ref [] -let really_closed = ref None +let () = + Printexc.register_printer (fun x -> + match x with + | Error x -> + Some (Format.asprintf "%a" print x ) + | _ -> None + ) -let rec free_vars_rec real ty = - let ty = repr ty in - if ty.level >= lowest_level then begin - ty.level <- pivot_level - ty.level; - begin match ty.desc, !really_closed with - Tvar _, _ -> - free_variables := (ty, real) :: !free_variables - | Tconstr (path, tl, _), Some env -> - begin try - let (_, body, _) = Env.find_type_expansion path env in - if (repr body).level <> generic_level then - free_variables := (ty, real) :: !free_variables - with Not_found -> () - end; - List.iter (free_vars_rec true) tl -(* Do not count "virtual" free variables - | Tobject(ty, {contents = Some (_, p)}) -> - free_vars_rec false ty; List.iter (free_vars_rec true) p -*) - | Tobject (ty, _), _ -> - free_vars_rec false ty - | Tfield (_, _, ty1, ty2), _ -> - free_vars_rec true ty1; free_vars_rec false ty2 - | Tvariant row, _ -> - let row = row_repr row in - iter_row (free_vars_rec true) row; - if not (static_row row) then free_vars_rec false row.row_more - | _ -> - iter_type_expr (free_vars_rec true) ty - end; - end +end +module Bsb_warning : sig +#1 "bsb_warning.mli" +(* Copyright (C) 2017 Authors of BuckleScript + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -let free_vars ?env ty = - free_variables := []; - really_closed := env; - free_vars_rec true ty; - let res = !free_variables in - free_variables := []; - really_closed := None; - res -let free_variables ?env ty = - let tl = List.map fst (free_vars ?env ty) in - unmark_type ty; - tl -let closed_type ty = - match free_vars ty with - [] -> () - | (v, real) :: _ -> raise (Non_closed (v, real)) -let closed_parameterized_type params ty = - List.iter mark_type params; - let ok = - try closed_type ty; true with Non_closed _ -> false in - List.iter unmark_type params; - unmark_type ty; - ok +type t -let closed_type_decl decl = - try - List.iter mark_type decl.type_params; - begin match decl.type_kind with - Type_abstract -> - () - | Type_variant v -> - List.iter - (fun {cd_args; cd_res; _} -> - match cd_res with - | Some _ -> () - | None -> - match cd_args with - | Cstr_tuple l -> List.iter closed_type l - | Cstr_record l -> List.iter (fun l -> closed_type l.ld_type) l - ) - v - | Type_record(r, _rep) -> - List.iter (fun l -> closed_type l.ld_type) r - | Type_open -> () - end; - begin match decl.type_manifest with - None -> () - | Some ty -> closed_type ty - end; - unmark_type_decl decl; - None - with Non_closed (ty, _) -> - unmark_type_decl decl; - Some ty +val get_warning_flag : t option -> string -let closed_extension_constructor ext = - try - List.iter mark_type ext.ext_type_params; - begin match ext.ext_ret_type with - | Some _ -> () - | None -> iter_type_expr_cstr_args closed_type ext.ext_args - end; - unmark_extension_constructor ext; - None - with Non_closed (ty, _) -> - unmark_extension_constructor ext; - Some ty +val default_warning : string -type closed_class_failure = - CC_Method of type_expr * bool * string * type_expr - | CC_Value of type_expr * bool * string * type_expr +val default_warning_flag : string +(* default_warning, including the -w prefix, for command-line arguments *) -exception CCFailure of closed_class_failure +val from_map : Ext_json_types.t String_map.t -> t option -let closed_class params sign = - let ty = object_fields (repr sign.csig_self) in - let (fields, rest) = flatten_fields ty in - List.iter mark_type params; - mark_type rest; - List.iter - (fun (lab, _, ty) -> if lab = dummy_method then mark_type ty) - fields; - try - mark_type_node (repr sign.csig_self); - List.iter - (fun (lab, kind, ty) -> - if field_kind_repr kind = Fpresent then - try closed_type ty with Non_closed (ty0, real) -> - raise (CCFailure (CC_Method (ty0, real, lab, ty)))) - fields; - mark_type_params (repr sign.csig_self); - List.iter unmark_type params; - unmark_class_signature sign; - None - with CCFailure reason -> - mark_type_params (repr sign.csig_self); - List.iter unmark_type params; - unmark_class_signature sign; - Some reason +(** [opt_warning_to_string not_dev warning] +*) +val opt_warning_to_string : + toplevel:bool -> + t option -> + string - (**********************) - (* Type duplication *) - (**********************) +end = struct +#1 "bsb_warning.ml" +(* Copyright (C) 2017 Authors of BuckleScript + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -(* Duplicate a type, preserving only type variables *) -let duplicate_type ty = - Subst.type_expr Subst.identity ty +type warning_error = + | Warn_error_false + (* default [false] to make our changes non-intrusive *) + | Warn_error_true + | Warn_error_number of string -(* Same, for class types *) -let duplicate_class_type ty = - Subst.class_type Subst.identity ty +type t = { + number : string option; + error : warning_error +} +(** + See the meanings of the warning codes here: https://caml.inria.fr/pub/docs/manual-ocaml/comp.html#sec281 - (*****************************) - (* Type level manipulation *) - (*****************************) + - 30 Two labels or constructors of the same name are defined in two mutually recursive types. + - 40 Constructor or label name used out of scope. -(* - It would be a bit more efficient to remove abbreviation expansions - rather than generalizing them: these expansions will usually not be - used anymore. However, this is not possible in the general case, as - [expand_abbrev] (via [subst]) requires these expansions to be - preserved. Does it worth duplicating this code ? + - 6 Label omitted in function application. + - 7 Method overridden. + - 9 Missing fields in a record pattern. (*Not always desired, in some cases need [@@@warning "+9"] *) + - 27 Innocuous unused variable: unused variable that is not bound with let nor as, and doesn’t start with an underscore (_) character. + - 29 Unescaped end-of-line in a string constant (non-portable code). + - 32 .. 39 Unused blabla + - 44 Open statement shadows an already defined identifier. + - 45 Open statement shadows an already defined label or constructor. + - 48 Implicit elimination of optional arguments. https://caml.inria.fr/mantis/view.php?id=6352 + - 101 (bsb-specific) unsafe polymorphic comparison. *) -let rec generalize ty = - let ty = repr ty in - if (ty.level > !current_level) && (ty.level <> generic_level) then begin - set_level ty generic_level; - begin match ty.desc with - Tconstr (_, _, abbrev) -> - iter_abbrev generalize !abbrev - | _ -> () - end; - iter_type_expr generalize ty - end - -let generalize ty = - simple_abbrevs := Mnil; - generalize ty +let default_warning = "-30-40+6+7+27+32..39+44+45+101" -(* Generalize the structure and lower the variables *) +let default_warning_flag = "-w " ^ default_warning -let rec generalize_structure var_level ty = - let ty = repr ty in - if ty.level <> generic_level then begin - if is_Tvar ty && ty.level > var_level then - set_level ty var_level - else if - ty.level > !current_level && - match ty.desc with - Tconstr (p, _, abbrev) -> - not (is_object_type p) && (abbrev := Mnil; true) - | _ -> true - then begin - set_level ty generic_level; - iter_type_expr (generalize_structure var_level) ty - end - end +let get_warning_flag x = + default_warning_flag ^ + (match x with + | Some {number =None} + | None -> Ext_string.empty + | Some {number = Some x} -> Ext_string.trim x ) -let generalize_structure var_level ty = - simple_abbrevs := Mnil; - generalize_structure var_level ty -(* Generalize the spine of a function, if the level >= !current_level *) +let warn_error = " -warn-error A" -let rec generalize_spine ty = - let ty = repr ty in - if ty.level < !current_level || ty.level = generic_level then () else - match ty.desc with - Tarrow (_, ty1, ty2, _) -> - set_level ty generic_level; - generalize_spine ty1; - generalize_spine ty2; - | Tpoly (ty', _) -> - set_level ty generic_level; - generalize_spine ty' - | Ttuple tyl - | Tpackage (_, _, tyl) -> - set_level ty generic_level; - List.iter generalize_spine tyl - | Tconstr (p, tyl, memo) when not (is_object_type p) -> - set_level ty generic_level; - memo := Mnil; - List.iter generalize_spine tyl - | _ -> () +let warning_to_string ~toplevel + warning : string = + default_warning_flag ^ + (match warning.number with + | None -> + Ext_string.empty + | Some x -> + let content = + Ext_string.trim x in + if content = "" then content + else + match content.[0] with + | '0' .. '9' -> "+" ^ content + | _ -> content + ) ^ + if toplevel then + match warning.error with + | Warn_error_true -> + warn_error -let forward_try_expand_once = (* Forward declaration *) - ref (fun _env _ty -> raise Cannot_expand) + | Warn_error_number y -> + " -warn-error " ^ y + | Warn_error_false -> + Ext_string.empty + else Ext_string.empty -(* - Lower the levels of a type (assume [level] is not - [generic_level]). -*) -(* - The level of a type constructor must be greater than its binding - time. That way, a type constructor cannot escape the scope of its - definition, as would be the case in - let x = ref [] - module M = struct type t let _ = (x : t list ref) end - (without this constraint, the type system would actually be unsound.) -*) -let get_level env p = - try - match (Env.find_type p env).type_newtype_level with - | None -> Path.binding_time p - | Some (x, _) -> x - with - | Not_found -> - (* no newtypes in predef *) - Path.binding_time p -let rec normalize_package_path env p = - let t = - try (Env.find_modtype p env).mtd_type - with Not_found -> None - in - match t with - | Some (Mty_ident p) -> normalize_package_path env p - | Some (Mty_signature _ | Mty_functor _ | Mty_alias _) | None -> - match p with - Path.Pdot (p1, s, n) -> - (* For module aliases *) - let p1' = Env.normalize_path None env p1 in - if Path.same p1 p1' then p else - normalize_package_path env (Path.Pdot (p1', s, n)) - | _ -> p -let rec update_level env level expand ty = - let ty = repr ty in - if ty.level > level then begin - begin match Env.gadt_instance_level env ty with - Some lv -> if level < lv then raise (Unify [(ty, newvar2 level)]) - | None -> () - end; - match ty.desc with - Tconstr(p, _tl, _abbrev) when level < get_level env p -> - (* Try first to replace an abbreviation by its expansion. *) - begin try - (* if is_newtype env p then raise Cannot_expand; *) - link_type ty (!forward_try_expand_once env ty); - update_level env level expand ty - with Cannot_expand -> - (* +++ Levels should be restored... *) - (* Format.printf "update_level: %i < %i@." level (get_level env p); *) - if level < get_level env p then raise (Unify [(ty, newvar2 level)]); - iter_type_expr (update_level env level expand) ty - end - | Tconstr(_, _ :: _, _) when expand -> - begin try - link_type ty (!forward_try_expand_once env ty); - update_level env level expand ty - with Cannot_expand -> - set_level ty level; - iter_type_expr (update_level env level expand) ty - end - | Tpackage (p, nl, tl) when level < Path.binding_time p -> - let p' = normalize_package_path env p in - if Path.same p p' then raise (Unify [(ty, newvar2 level)]); - log_type ty; ty.desc <- Tpackage (p', nl, tl); - update_level env level expand ty - | Tobject(_, ({contents=Some(p, _tl)} as nm)) - when level < get_level env p -> - set_name nm None; - update_level env level expand ty - | Tvariant row -> - let row = row_repr row in - begin match row.row_name with - | Some (p, _tl) when level < get_level env p -> - log_type ty; - ty.desc <- Tvariant {row with row_name = None} - | _ -> () - end; - set_level ty level; - iter_type_expr (update_level env level expand) ty - | Tfield(lab, _, ty1, _) - when lab = dummy_method && (repr ty1).level > level -> - raise (Unify [(ty1, newvar2 level)]) - | _ -> - set_level ty level; - (* XXX what about abbreviations in Tconstr ? *) - iter_type_expr (update_level env level expand) ty - end +let from_map (m : Ext_json_types.t String_map.t) = + let number_opt = String_map.find_opt m Bsb_build_schemas.number in + let error_opt = String_map.find_opt m Bsb_build_schemas.error in + match number_opt, error_opt with + | None, None -> None + | _, _ -> + let error = + match error_opt with + | Some (True _) -> Warn_error_true + | Some (False _) -> Warn_error_false + | Some (Str {str ; }) + -> Warn_error_number str + | Some x -> Bsb_exception.config_error x "expect true/false or string" + | None -> Warn_error_false + (** To make it less intrusive : warning error has to be enabled*) + in + let number = + match number_opt with + | Some (Str { str = number}) -> Some number + | None -> None + | Some x -> Bsb_exception.config_error x "expect a string" + in + Some {number; error } -(* First try without expanding, then expand everything, - to avoid combinatorial blow-up *) -let update_level env level ty = - let ty = repr ty in - if ty.level > level then begin - let snap = snapshot () in - try - update_level env level false ty - with Unify _ -> - backtrack snap; - update_level env level true ty - end +let opt_warning_to_string ~toplevel warning = + match warning with + | None -> default_warning_flag + | Some w -> warning_to_string ~toplevel w -(* Generalize and lower levels of contravariant branches simultaneously *) -let rec generalize_expansive env var_level visited ty = - let ty = repr ty in - if ty.level = generic_level || ty.level <= var_level then () else - if not (Hashtbl.mem visited ty.id) then begin - Hashtbl.add visited ty.id (); - match ty.desc with - Tconstr (path, tyl, abbrev) -> - let variance = - try (Env.find_type path env).type_variance - with Not_found -> List.map (fun _ -> Variance.may_inv) tyl in - abbrev := Mnil; - List.iter2 - (fun v t -> - if Variance.(mem May_weak v) - then generalize_structure var_level t - else generalize_expansive env var_level visited t) - variance tyl - | Tpackage (_, _, tyl) -> - List.iter (generalize_structure var_level) tyl - | Tarrow (_, t1, t2, _) -> - generalize_structure var_level t1; - generalize_expansive env var_level visited t2 - | _ -> - iter_type_expr (generalize_expansive env var_level visited) ty - end +end +module Ccomp : sig +#1 "ccomp.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -let generalize_expansive env ty = - simple_abbrevs := Mnil; - try - generalize_expansive env !nongen_level (Hashtbl.create 7) ty - with Unify ([_, ty'] as tr) -> - raise (Unify ((ty, ty') :: tr)) +(* Compiling C files and building C libraries *) -let generalize_global ty = generalize_structure !global_level ty -let generalize_structure ty = generalize_structure !current_level ty +val command: string -> int +val run_command: string -> unit +val compile_file: ?output:string -> ?opt:string -> string -> int +val create_archive: string -> string list -> int +val expand_libname: string -> string +val quote_files: string list -> string +val quote_optfile: string option -> string +(*val make_link_options: string list -> string*) -(* Correct the levels of type [ty]. *) -let correct_levels ty = - duplicate_type ty +type link_mode = + | Exe + | Dll + | MainDll + | Partial -(* Only generalize the type ty0 in ty *) -let limited_generalize ty0 ty = - let ty0 = repr ty0 in +val call_linker: link_mode -> string -> string list -> string -> bool - let graph = Hashtbl.create 17 in - let idx = ref lowest_level in - let roots = ref [] in +end = struct +#1 "ccomp.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) - let rec inverse pty ty = - let ty = repr ty in - if (ty.level > !current_level) || (ty.level = generic_level) then begin - decr idx; - Hashtbl.add graph !idx (ty, ref pty); - if (ty.level = generic_level) || (ty == ty0) then - roots := ty :: !roots; - set_level ty !idx; - iter_type_expr (inverse [ty]) ty - end else if ty.level < lowest_level then begin - let (_, parents) = Hashtbl.find graph ty.level in - parents := pty @ !parents - end +(* Compiling C files and building C libraries *) - and generalize_parents ty = - let idx = ty.level in - if idx <> generic_level then begin - set_level ty generic_level; - List.iter generalize_parents !(snd (Hashtbl.find graph idx)); - (* Special case for rows: must generalize the row variable *) - match ty.desc with - Tvariant row -> - let more = row_more row in - let lv = more.level in - if (lv < lowest_level || lv > !current_level) - && lv <> generic_level then set_level more generic_level - | _ -> () - end - in +let command cmdline = + if !Clflags.verbose then begin + prerr_string "+ "; + prerr_string cmdline; + prerr_newline() + end; + Sys.command cmdline - inverse [] ty; - if ty0.level < lowest_level then - iter_type_expr (inverse []) ty0; - List.iter generalize_parents !roots; - Hashtbl.iter - (fun _ (ty, _) -> - if ty.level <> generic_level then set_level ty !current_level) - graph +let run_command cmdline = ignore(command cmdline) +(* Build @responsefile to work around Windows limitations on + command-line length *) +let build_diversion lst = + let (responsefile, oc) = Filename.open_temp_file "camlresp" "" in + List.iter (fun f -> Printf.fprintf oc "%s\n" f) lst; + close_out oc; + at_exit (fun () -> Misc.remove_file responsefile); + "@" ^ responsefile -(* Compute statically the free univars of all nodes in a type *) -(* This avoids doing it repeatedly during instantiation *) +let quote_files lst = + let lst = List.filter (fun f -> f <> "") lst in + let quoted = List.map Filename.quote lst in + let s = String.concat " " quoted in + if String.length s >= 4096 && Sys.os_type = "Win32" + then build_diversion quoted + else s -type inv_type_expr = - { inv_type : type_expr; - mutable inv_parents : inv_type_expr list } +let quote_prefixed pr lst = + let lst = List.filter (fun f -> f <> "") lst in + let lst = List.map (fun f -> pr ^ f) lst in + quote_files lst -let rec inv_type hash pty ty = - let ty = repr ty in +let quote_optfile = function + | None -> "" + | Some f -> Filename.quote f + +let display_msvc_output file name = + let c = open_in file in try - let inv = TypeHash.find hash ty in - inv.inv_parents <- pty @ inv.inv_parents - with Not_found -> - let inv = { inv_type = ty; inv_parents = pty } in - TypeHash.add hash ty inv; - iter_type_expr (inv_type hash [inv]) ty + let first = input_line c in + if first <> Filename.basename name then + print_string first; + while true do + print_string (input_line c) + done + with _ -> + close_in c; + Sys.remove file -let compute_univars ty = - let inverted = TypeHash.create 17 in - inv_type inverted [] ty; - let node_univars = TypeHash.create 17 in - let rec add_univar univ inv = - match inv.inv_type.desc with - Tpoly (_ty, tl) when List.memq univ (List.map repr tl) -> () - | _ -> - try - let univs = TypeHash.find node_univars inv.inv_type in - if not (TypeSet.mem univ !univs) then begin - univs := TypeSet.add univ !univs; - List.iter (add_univar univ) inv.inv_parents - end - with Not_found -> - TypeHash.add node_univars inv.inv_type (ref(TypeSet.singleton univ)); - List.iter (add_univar univ) inv.inv_parents +let compile_file ?output ?(opt="") name = + let (pipe, file) = + if Config.ccomp_type = "msvc" && not !Clflags.verbose then + try + let (t, c) = Filename.open_temp_file "msvc" "stdout" in + close_out c; + (Printf.sprintf " > %s" (Filename.quote t), t) + with _ -> + ("", "") + else + ("", "") in + let exit = + command + (Printf.sprintf + "%s %s %s -c %s %s %s %s %s%s" + (match !Clflags.c_compiler with + | Some cc -> cc + | None -> + let (cflags, cppflags) = + if !Clflags.native_code + then (Config.ocamlopt_cflags, Config.ocamlopt_cppflags) + else (Config.ocamlc_cflags, Config.ocamlc_cppflags) in + (String.concat " " [Config.c_compiler; cflags; cppflags])) + (match output with + | None -> "" + | Some o -> Printf.sprintf "%s%s" Config.c_output_obj o) + opt + (if !Clflags.debug && Config.ccomp_type <> "msvc" then "-g" else "") + (String.concat " " (List.rev !Clflags.all_ccopts)) + (quote_prefixed "-I" (List.rev !Clflags.include_dirs)) + (Clflags.std_include_flag "-I") + (Filename.quote name) + (* cl tediously includes the name of the C file as the first thing it + outputs (in fairness, the tedious thing is that there's no switch to + disable this behaviour). In the absence of the Unix module, use + a temporary file to filter the output (cannot pipe the output to a + filter because this removes the exit status of cl, which is wanted. + *) + pipe) in + if pipe <> "" + then display_msvc_output file name; + exit + +let macos_create_empty_archive ~quoted_archive = + let result = + command (Printf.sprintf "%s rc %s /dev/null" Config.ar quoted_archive) in - TypeHash.iter (fun ty inv -> if is_Tunivar ty then add_univar ty inv) - inverted; - fun ty -> - try !(TypeHash.find node_univars ty) with Not_found -> TypeSet.empty + if result <> 0 then result + else + let result = + command (Printf.sprintf "%s %s 2> /dev/null" Config.ranlib quoted_archive) + in + if result <> 0 then result + else + command (Printf.sprintf "%s d %s /dev/null" Config.ar quoted_archive) +let create_archive archive file_list = + Misc.remove_file archive; + let quoted_archive = Filename.quote archive in + match Config.ccomp_type with + "msvc" -> + command(Printf.sprintf "link /lib /nologo /out:%s %s" + quoted_archive (quote_files file_list)) + | _ -> + assert(String.length Config.ar > 0); + let is_macosx = + match Config.system with + | "macosx" -> true + | _ -> false + in + if is_macosx && file_list = [] then (* PR#6550 *) + macos_create_empty_archive ~quoted_archive + else + let r1 = + command(Printf.sprintf "%s rc %s %s" + Config.ar quoted_archive (quote_files file_list)) in + if r1 <> 0 || String.length Config.ranlib = 0 + then r1 + else command(Config.ranlib ^ " " ^ quoted_archive) - (*******************) - (* Instantiation *) - (*******************) +let expand_libname name = + if String.length name < 2 || String.sub name 0 2 <> "-l" + then name + else begin + let libname = + "lib" ^ String.sub name 2 (String.length name - 2) ^ Config.ext_lib in + try + Misc.find_in_path !Config.load_path libname + with Not_found -> + libname + end +type link_mode = + | Exe + | Dll + | MainDll + | Partial -let rec find_repr p1 = - function - Mnil -> - None - | Mcons (Public, p2, ty, _, _) when Path.same p1 p2 -> - Some ty - | Mcons (_, _, _, _, rem) -> - find_repr p1 rem - | Mlink {contents = rem} -> - find_repr p1 rem +let remove_Wl cclibs = + cclibs |> List.map (fun cclib -> + (* -Wl,-foo,bar -> -foo bar *) + if String.length cclib >= 4 && "-Wl," = String.sub cclib 0 4 then + String.map (function ',' -> ' ' | c -> c) + (String.sub cclib 4 (String.length cclib - 4)) + else cclib) -(* - Generic nodes are duplicated, while non-generic nodes are left - as-is. - During instantiation, the description of a generic node is first - replaced by a link to a stub ([Tsubst (newvar ())]). Once the - copy is made, it replaces the stub. - After instantiation, the description of generic node, which was - stored by [save_desc], must be put back, using [cleanup_types]. -*) +let call_linker mode output_name files extra = + let cmd = + if mode = Partial then + let l_prefix = + match Config.ccomp_type with + | "msvc" -> "/libpath:" + | _ -> "-L" + in + Printf.sprintf "%s%s %s %s %s" + Config.native_pack_linker + (Filename.quote output_name) + (quote_prefixed l_prefix !Config.load_path) + (quote_files (remove_Wl files)) + extra + else + Printf.sprintf "%s -o %s %s %s %s %s %s %s" + (match !Clflags.c_compiler, mode with + | Some cc, _ -> cc + | None, Exe -> Config.mkexe + | None, Dll -> Config.mkdll + | None, MainDll -> Config.mkmaindll + | None, Partial -> assert false + ) + (Filename.quote output_name) + (if !Clflags.gprofile then Config.cc_profile else "") + "" (*(Clflags.std_include_flag "-I")*) + (quote_prefixed "-L" !Config.load_path) + (String.concat " " (List.rev !Clflags.all_ccopts)) + (quote_files files) + extra + in + command cmd = 0 -let abbreviations = ref (ref Mnil) - (* Abbreviation memorized. *) +end +module Compenv : sig +#1 "compenv.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Fabrice Le Fessant, EPI Gallium, INRIA Paris-Rocquencourt *) +(* *) +(* Copyright 2013 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -(* partial: we may not wish to copy the non generic types - before we call type_pat *) -let rec copy ?env ?partial ?keep_names ty = - let copy = copy ?env ?partial ?keep_names in - let ty = repr ty in - match ty.desc with - Tsubst ty -> ty - | _ -> - if ty.level <> generic_level && partial = None then ty else - (* We only forget types that are non generic and do not contain - free univars *) - let forget = - if ty.level = generic_level then generic_level else - match partial with - None -> assert false - | Some (free_univars, keep) -> - if TypeSet.is_empty (free_univars ty) then - if keep then ty.level else !current_level - else generic_level - in - if forget <> generic_level then newty2 forget (Tvar None) else - let desc = ty.desc in - save_desc ty desc; - let t = newvar() in (* Stub *) - begin match env with - Some env when Env.has_local_constraints env -> - begin match Env.gadt_instance_level env ty with - Some lv -> Env.add_gadt_instances env lv [t] - | None -> () - end - | _ -> () - end; - ty.desc <- Tsubst t; - t.desc <- - begin match desc with - | Tconstr (p, tl, _) -> - let abbrevs = proper_abbrevs p tl !abbreviations in - begin match find_repr p !abbrevs with - Some ty when repr ty != t -> - Tlink ty - | _ -> - (* - One must allocate a new reference, so that abbrevia- - tions belonging to different branches of a type are - independent. - Moreover, a reference containing a [Mcons] must be - shared, so that the memorized expansion of an abbrevi- - ation can be released by changing the content of just - one reference. - *) - Tconstr (p, List.map copy tl, - ref (match !(!abbreviations) with - Mcons _ -> Mlink !abbreviations - | abbrev -> abbrev)) - end - | Tvariant row0 -> - let row = row_repr row0 in - let more = repr row.row_more in - (* We must substitute in a subtle way *) - (* Tsubst takes a tuple containing the row var and the variant *) - begin match more.desc with - Tsubst {desc = Ttuple [_;ty2]} -> - (* This variant type has been already copied *) - ty.desc <- Tsubst ty2; (* avoid Tlink in the new type *) - Tlink ty2 - | _ -> - (* If the row variable is not generic, we must keep it *) - let keep = more.level <> generic_level in - let more' = - match more.desc with - Tsubst ty -> ty - | Tconstr _ | Tnil -> - if keep then save_desc more more.desc; - copy more - | Tvar _ | Tunivar _ -> - save_desc more more.desc; - if keep then more else newty more.desc - | _ -> assert false - in - let row = - match repr more' with (* PR#6163 *) - {desc=Tconstr _} when not row.row_fixed -> - {row with row_fixed = true} - | _ -> row - in - (* Open row if partial for pattern and contains Reither *) - let more', row = - match partial with - Some (free_univars, false) -> - let more' = - if more.id != more'.id then more' else - let lv = if keep then more.level else !current_level in - newty2 lv (Tvar None) - in - let not_reither (_, f) = - match row_field_repr f with - Reither _ -> false - | _ -> true - in - if row.row_closed && not row.row_fixed - && TypeSet.is_empty (free_univars ty) - && not (List.for_all not_reither row.row_fields) then - (more', - {row_fields = List.filter not_reither row.row_fields; - row_more = more'; row_bound = (); - row_closed = false; row_fixed = false; row_name = None}) - else (more', row) - | _ -> (more', row) - in - (* Register new type first for recursion *) - more.desc <- Tsubst(newgenty(Ttuple[more';t])); - (* Return a new copy *) - Tvariant (copy_row copy true row keep more') - end - | Tfield (_p, k, _ty1, ty2) -> - begin match field_kind_repr k with - Fabsent -> Tlink (copy ty2) - | Fpresent -> copy_type_desc copy desc - | Fvar r -> - dup_kind r; - copy_type_desc copy desc - end - | Tobject (ty1, _) when partial <> None -> - Tobject (copy ty1, ref None) - | _ -> copy_type_desc ?keep_names copy desc - end; - t +val module_of_filename : Format.formatter -> string -> string -> string + +val output_prefix : string -> string +val extract_output : string option -> string +val default_output : string option -> string + +val print_version_and_library : string -> 'a +val print_version_string : unit -> 'a +val print_standard_library : unit -> 'a +val fatal : string -> 'a -let simple_copy t = copy t +val first_ccopts : string list ref +val first_ppx : string list ref +val first_include_dirs : string list ref +val last_include_dirs : string list ref +val implicit_modules : string list ref -(**** Variants of instantiations ****) +(* function to call on plugin=XXX *) +val load_plugin : (string -> unit) ref -let gadt_env env = - if Env.has_local_constraints env - then Some env - else None +(* return the list of objfiles, after OCAMLPARAM and List.rev *) +val get_objfiles : with_ocamlparam:bool -> string list +val last_objfiles : string list ref +val first_objfiles : string list ref -let instance ?partial env sch = - let env = gadt_env env in - let partial = - match partial with - None -> None - | Some keep -> Some (compute_univars sch, keep) - in - let ty = copy ?env ?partial sch in - cleanup_types (); - ty +type filename = string -let instance_def sch = - let ty = copy sch in - cleanup_types (); - ty +type readenv_position = + Before_args | Before_compile of filename | Before_link -let generic_instance env sch = - let old = !current_level in - current_level := generic_level; - let ty = instance env sch in - current_level := old; - ty +val readenv : Format.formatter -> readenv_position -> unit -let instance_list env schl = - let env = gadt_env env in - let tyl = List.map (fun t -> copy ?env t) schl in - cleanup_types (); - tyl +(* [is_unit_name name] returns true only if [name] can be used as a + correct module name *) +val is_unit_name : string -> bool +(* [check_unit_name ppf filename name] prints a warning in [filename] + on [ppf] if [name] should not be used as a module name. *) +val check_unit_name : Format.formatter -> string -> string -> unit -let reified_var_counter = ref Vars.empty -let reset_reified_var_counter () = - reified_var_counter := Vars.empty +(* Deferred actions of the compiler, while parsing arguments *) -(* names given to new type constructors. - Used for existential types and - local constraints *) -let get_new_abstract_name s = - let index = - try Vars.find s !reified_var_counter + 1 - with Not_found -> 0 in - reified_var_counter := Vars.add s index !reified_var_counter; - if index = 0 && s <> "" && s.[String.length s - 1] <> '$' then s else - Printf.sprintf "%s%d" s index +type deferred_action = + | ProcessImplementation of string + | ProcessInterface of string + | ProcessCFile of string + | ProcessOtherFile of string + | ProcessObjects of string list + | ProcessDLLs of string list -let new_declaration newtype manifest = - { - type_params = []; - type_arity = 0; - type_kind = Type_abstract; - type_private = Public; - type_manifest = manifest; - type_variance = []; - type_newtype_level = newtype; - type_loc = Location.none; - type_attributes = []; - type_immediate = false; - type_unboxed = unboxed_false_default_false; - } +val c_object_of_filename : string -> string -let instance_constructor ?in_pattern cstr = - begin match in_pattern with - | None -> () - | Some (env, newtype_lev) -> - let process existential = - let decl = new_declaration (Some (newtype_lev, newtype_lev)) None in - let name = - match repr existential with - {desc = Tvar (Some name)} -> "$" ^ cstr.cstr_name ^ "_'" ^ name - | _ -> "$" ^ cstr.cstr_name - in - let path = Path.Pident (Ident.create (get_new_abstract_name name)) in - let new_env = Env.add_local_type path decl !env in - env := new_env; - let to_unify = newty (Tconstr (path,[],ref Mnil)) in - let tv = copy existential in - assert (is_Tvar tv); - link_type tv to_unify - in - List.iter process cstr.cstr_existentials - end; - let ty_res = copy cstr.cstr_res in - let ty_args = List.map simple_copy cstr.cstr_args in - cleanup_types (); - (ty_args, ty_res) +val defer : deferred_action -> unit +val anonymous : string -> unit +val impl : string -> unit +val intf : string -> unit -let instance_parameterized_type ?keep_names sch_args sch = - let ty_args = List.map (fun t -> copy ?keep_names t) sch_args in - let ty = copy sch in - cleanup_types (); - (ty_args, ty) +val process_deferred_actions : + Format.formatter * + (Format.formatter -> string -> string -> unit) * (* compile implementation *) + (Format.formatter -> string -> string -> unit) * (* compile interface *) + string * (* ocaml module extension *) + string -> (* ocaml library extension *) + unit -let instance_parameterized_type_2 sch_args sch_lst sch = - let ty_args = List.map simple_copy sch_args in - let ty_lst = List.map simple_copy sch_lst in - let ty = copy sch in - cleanup_types (); - (ty_args, ty_lst, ty) +end = struct +#1 "compenv.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Fabrice Le Fessant, EPI Gallium, INRIA Paris-Rocquencourt *) +(* *) +(* Copyright 2013 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -let map_kind f = function - | Type_abstract -> Type_abstract - | Type_open -> Type_open - | Type_variant cl -> - Type_variant ( - List.map - (fun c -> - {c with - cd_args = map_type_expr_cstr_args f c.cd_args; - cd_res = may_map f c.cd_res - }) - cl) - | Type_record (fl, rr) -> - Type_record ( - List.map - (fun l -> - {l with ld_type = f l.ld_type} - ) fl, rr) +open Clflags +let output_prefix name = + let oname = + match !output_name with + | None -> name + | Some n -> if !compile_only then (output_name := None; n) else name in + Filename.remove_extension oname -let instance_declaration decl = - let decl = - {decl with type_params = List.map simple_copy decl.type_params; - type_manifest = may_map simple_copy decl.type_manifest; - type_kind = map_kind simple_copy decl.type_kind; - } - in - cleanup_types (); - decl +let print_version_and_library compiler = + Printf.printf "The OCaml %s, version " compiler; + print_string Config.version; print_newline(); + print_string "Standard library directory: "; + print_string Config.standard_library; print_newline(); + exit 0 -let instance_class params cty = - let rec copy_class_type = - function - Cty_constr (path, tyl, cty) -> - Cty_constr (path, List.map simple_copy tyl, copy_class_type cty) - | Cty_signature sign -> - Cty_signature - {csig_self = copy sign.csig_self; - csig_vars = - Vars.map (function (m, v, ty) -> (m, v, copy ty)) sign.csig_vars; - csig_concr = sign.csig_concr; - csig_inher = - List.map (fun (p,tl) -> (p, List.map simple_copy tl)) - sign.csig_inher} - | Cty_arrow (l, ty, cty) -> - Cty_arrow (l, copy ty, copy_class_type cty) - in - let params' = List.map simple_copy params in - let cty' = copy_class_type cty in - cleanup_types (); - (params', cty') +let print_version_string () = + print_string Config.version; print_newline(); exit 0 -(**** Instantiation for types with free universal variables ****) +let print_standard_library () = + print_string Config.standard_library; print_newline(); exit 0 -let rec diff_list l1 l2 = - if l1 == l2 then [] else - match l1 with [] -> invalid_arg "Ctype.diff_list" - | a :: l1 -> a :: diff_list l1 l2 +let fatal err = + prerr_endline err; + exit 2 -let conflicts free bound = - let bound = List.map repr bound in - TypeSet.exists (fun t -> List.memq (repr t) bound) free +let extract_output = function + | Some s -> s + | None -> + fatal "Please specify the name of the output file, using option -o" -let delayed_copy = ref [] - (* copying to do later *) +let default_output = function + | Some s -> s + | None -> Config.default_executable_name -(* Copy without sharing until there are no free univars left *) -(* all free univars must be included in [visited] *) -let rec copy_sep fixed free bound visited ty = - let ty = repr ty in - let univars = free ty in - if TypeSet.is_empty univars then - if ty.level <> generic_level then ty else - let t = newvar () in - delayed_copy := - lazy (t.desc <- Tlink (copy ty)) - :: !delayed_copy; - t - else try - let t, bound_t = List.assq ty visited in - let dl = if is_Tunivar ty then [] else diff_list bound bound_t in - if dl <> [] && conflicts univars dl then raise Not_found; - t - with Not_found -> begin - let t = newvar() in (* Stub *) - let visited = - match ty.desc with - Tarrow _ | Ttuple _ | Tvariant _ | Tconstr _ | Tobject _ | Tpackage _ -> - (ty,(t,bound)) :: visited - | _ -> visited in - let copy_rec = copy_sep fixed free bound visited in - t.desc <- - begin match ty.desc with - | Tvariant row0 -> - let row = row_repr row0 in - let more = repr row.row_more in - (* We shall really check the level on the row variable *) - let keep = is_Tvar more && more.level <> generic_level in - let more' = copy_rec more in - let fixed' = fixed && is_Tvar (repr more') in - let row = copy_row copy_rec fixed' row keep more' in - Tvariant row - | Tpoly (t1, tl) -> - let tl = List.map repr tl in - let tl' = List.map (fun t -> newty t.desc) tl in - let bound = tl @ bound in - let visited = - List.map2 (fun ty t -> ty,(t,bound)) tl tl' @ visited in - Tpoly (copy_sep fixed free bound visited t1, tl') - | _ -> copy_type_desc copy_rec ty.desc - end; - t - end +let implicit_modules = ref [] +let first_include_dirs = ref [] +let last_include_dirs = ref [] +let first_ccopts = ref [] +let last_ccopts = ref [] +let first_ppx = ref [] +let last_ppx = ref [] +let first_objfiles = ref [] +let last_objfiles = ref [] -let instance_poly ?(keep_names=false) fixed univars sch = - let univars = List.map repr univars in - let copy_var ty = - match ty.desc with - Tunivar name -> if keep_names then newty (Tvar name) else newvar () - | _ -> assert false +(* Check validity of module name *) +let is_unit_name name = + try + if name = "" then raise Exit; + begin match name.[0] with + | 'A'..'Z' -> () + | _ -> + raise Exit; + end; + for i = 1 to String.length name - 1 do + match name.[i] with + | 'A'..'Z' | 'a'..'z' | '0'..'9' | '_' | '\'' -> () + | _ -> + raise Exit; + done; + true + with Exit -> false +;; + +let check_unit_name ppf filename name = + + let _ = ppf in + let _ = filename in + let _ = name in + () + + +(* Compute name of module from output file name *) +let module_of_filename ppf inputfile outputprefix = + let basename = Filename.basename outputprefix in + let name = + try + let pos = String.index basename '.' in + String.sub basename 0 pos + with Not_found -> basename in - let vars = List.map copy_var univars in - let pairs = List.map2 (fun u v -> u, (v, [])) univars vars in - delayed_copy := []; - let ty = copy_sep fixed (compute_univars sch) [] pairs sch in - List.iter Lazy.force !delayed_copy; - delayed_copy := []; - cleanup_types (); - vars, ty + let name = String.capitalize_ascii name in + check_unit_name ppf inputfile name; + name +;; -let instance_label fixed lbl = - let ty_res = copy lbl.lbl_res in - let vars, ty_arg = - match repr lbl.lbl_arg with - {desc = Tpoly (ty, tl)} -> - instance_poly fixed tl ty - | _ -> - [], copy lbl.lbl_arg +type filename = string + +type readenv_position = + Before_args | Before_compile of filename | Before_link + +(* Syntax of OCAMLPARAM: (name=VALUE,)* _ (,name=VALUE)* + where VALUE should not contain ',' *) +exception SyntaxError of string + +let parse_args s = + let args = String.split_on_char ',' s in + let rec iter is_after args before after = + match args with + [] -> + if not is_after then + raise (SyntaxError "no '_' separator found") + else + (List.rev before, List.rev after) + | "_" :: _ when is_after -> raise (SyntaxError "too many '_' separators") + | "_" :: tail -> iter true tail before after + | arg :: tail -> + let binding = try + Misc.cut_at arg '=' + with Not_found -> + raise (SyntaxError ("missing '=' in " ^ arg)) + in + if is_after then + iter is_after tail before (binding :: after) + else + iter is_after tail (binding :: before) after in - cleanup_types (); - (vars, ty_arg, ty_res) + iter false args [] [] -(**** Instantiation with parameter substitution ****) +let setter ppf f name options s = + try + let bool = match s with + | "0" -> false + | "1" -> true + | _ -> raise Not_found + in + List.iter (fun b -> b := f bool) options + with Not_found -> + Location.print_warning Location.none ppf + (Warnings.Bad_env_variable ("OCAMLPARAM", + Printf.sprintf "bad value for %s" name)) -let unify' = (* Forward declaration *) - ref (fun _env _ty1 _ty2 -> raise (Unify [])) +let int_setter ppf name option s = + try + option := int_of_string s + with _ -> + Location.print_warning Location.none ppf + (Warnings.Bad_env_variable + ("OCAMLPARAM", Printf.sprintf "non-integer parameter for \"%s\"" name)) -let subst env level priv abbrev ty params args body = - if List.length params <> List.length args then raise (Unify []); - let old_level = !current_level in - current_level := level; +let int_option_setter ppf name option s = try - let body0 = newvar () in (* Stub *) - begin match ty with - None -> () - | Some ({desc = Tconstr (path, tl, _)} as ty) -> - let abbrev = proper_abbrevs path tl abbrev in - memorize_abbrev abbrev priv path ty body0 - | _ -> - assert false - end; - abbreviations := abbrev; - let (params', body') = instance_parameterized_type params body in - abbreviations := ref Mnil; - !unify' env body0 body'; - List.iter2 (!unify' env) params' args; - current_level := old_level; - body' - with Unify _ as exn -> - current_level := old_level; - raise exn + option := Some (int_of_string s) + with _ -> + Location.print_warning Location.none ppf + (Warnings.Bad_env_variable + ("OCAMLPARAM", Printf.sprintf "non-integer parameter for \"%s\"" name)) (* - Only the shape of the type matters, not whether it is generic or - not. [generic_level] might be somewhat slower, but it ensures - invariants on types are enforced (decreasing levels), and we don't - care about efficiency here. -*) -let apply env params body args = +let float_setter ppf name option s = try - subst env generic_level Public (ref Mnil) None params args body - with - Unify _ -> raise Cannot_apply + option := float_of_string s + with _ -> + Location.print_warning Location.none ppf + (Warnings.Bad_env_variable + ("OCAMLPARAM", Printf.sprintf "non-float parameter for \"%s\"" name)) +*) + +let load_plugin = ref (fun _ -> ()) + +let check_bool ppf name s = + match s with + | "0" -> false + | "1" -> true + | _ -> + Location.print_warning Location.none ppf + (Warnings.Bad_env_variable ("OCAMLPARAM", + Printf.sprintf "bad value for %s" name)); + false + +(* 'can-discard=' specifies which arguments can be discarded without warning + because they are not understood by some versions of OCaml. *) +let can_discard = ref [] + +let read_one_param ppf position name v = + let set name options s = setter ppf (fun b -> b) name options s in + let clear name options s = setter ppf (fun b -> not b) name options s in + match name with + | "g" -> set "g" [ Clflags.debug ] v + | "p" -> set "p" [ Clflags.gprofile ] v + | "bin-annot" -> set "bin-annot" [ Clflags.binary_annotations ] v + | "afl-instrument" -> set "afl-instrument" [ Clflags.afl_instrument ] v + | "afl-inst-ratio" -> + int_setter ppf "afl-inst-ratio" afl_inst_ratio v + | "annot" -> set "annot" [ Clflags.annotations ] v + | "absname" -> set "absname" [ Location.absname ] v + | "compat-32" -> set "compat-32" [ bytecode_compatible_32 ] v + | "noassert" -> set "noassert" [ noassert ] v + | "noautolink" -> set "noautolink" [ no_auto_link ] v + | "nostdlib" -> set "nostdlib" [ no_std_include ] v + | "linkall" -> set "linkall" [ link_everything ] v + | "nolabels" -> set "nolabels" [ classic ] v + | "principal" -> set "principal" [ principal ] v + | "rectypes" -> set "rectypes" [ recursive_types ] v + | "safe-string" -> clear "safe-string" [ unsafe_string ] v + | "strict-sequence" -> set "strict-sequence" [ strict_sequence ] v + | "strict-formats" -> set "strict-formats" [ strict_formats ] v + | "thread" -> set "thread" [ use_threads ] v + | "unboxed-types" -> set "unboxed-types" [ unboxed_types ] v + | "unsafe" -> set "unsafe" [ fast ] v + | "verbose" -> set "verbose" [ verbose ] v + | "nopervasives" -> set "nopervasives" [ nopervasives ] v + | "slash" -> set "slash" [ force_slash ] v (* for ocamldep *) + | "keep-docs" -> set "keep-docs" [ Clflags.keep_docs ] v + | "keep-locs" -> set "keep-locs" [ Clflags.keep_locs ] v + + | "compact" -> clear "compact" [ optimize_for_speed ] v + | "no-app-funct" -> clear "no-app-funct" [ applicative_functors ] v + | "nodynlink" -> clear "nodynlink" [ dlcode ] v + | "short-paths" -> clear "short-paths" [ real_paths ] v + | "trans-mod" -> set "trans-mod" [ transparent_modules ] v + | "opaque" -> set "opaque" [ opaque ] v -let () = Subst.ctype_apply_env_empty := apply Env.empty + | "pp" -> preprocessor := Some v + | "runtime-variant" -> runtime_variant := v + | "cc" -> c_compiler := Some v - (****************************) - (* Abbreviation expansion *) - (****************************) + | "clambda-checks" -> set "clambda-checks" [ clambda_checks ] v -(* - If the environment has changed, memorized expansions might not - be correct anymore, and so we flush the cache. This is safe but - quite pessimistic: it would be enough to flush the cache when a - type or module definition is overridden in the environment. -*) -let previous_env = ref Env.empty -(*let string_of_kind = function Public -> "public" | Private -> "private"*) -let check_abbrev_env env = - if env != !previous_env then begin - (* prerr_endline "cleanup expansion cache"; *) - cleanup_abbrev (); - previous_env := env - end + (* assembly sources *) + | "s" -> + set "s" [ Clflags.keep_asm_file ; Clflags.keep_startup_file ] v + | "S" -> set "S" [ Clflags.keep_asm_file ] v + | "dstartup" -> set "dstartup" [ Clflags.keep_startup_file ] v + (* warn-errors *) + | "we" | "warn-error" -> Warnings.parse_options true v + (* warnings *) + | "w" -> Warnings.parse_options false v + (* warn-errors *) + | "wwe" -> Warnings.parse_options false v -(* Expand an abbreviation. The expansion is memorized. *) -(* - Assume the level is greater than the path binding time of the - expanded abbreviation. -*) -(* - An abbreviation expansion will fail in either of these cases: - 1. The type constructor does not correspond to a manifest type. - 2. The type constructor is defined in an external file, and this - file is not in the path (missing -I options). - 3. The type constructor is not in the "local" environment. This can - happens when a non-generic type variable has been instantiated - afterwards to the not yet defined type constructor. (Actually, - this cannot happen at the moment due to the strong constraints - between type levels and constructor binding time.) - 4. The expansion requires the expansion of another abbreviation, - and this other expansion fails. -*) -let expand_abbrev_gen kind find_type_expansion env ty = - check_abbrev_env env; - match ty with - {desc = Tconstr (path, args, abbrev); level = level} -> - let lookup_abbrev = proper_abbrevs path args abbrev in - begin match find_expans kind path !lookup_abbrev with - Some ty' -> - (* prerr_endline - ("found a "^string_of_kind kind^" expansion for "^Path.name path);*) - if level <> generic_level then - begin try - update_level env level ty' - with Unify _ -> - (* XXX This should not happen. - However, levels are not correctly restored after a - typing error *) - () - end; - let ty' = repr ty' in - (* assert (ty != ty'); *) (* PR#7324 *) - ty' - | None -> - match find_type_expansion path env with - | exception Not_found -> - (* another way to expand is to normalize the path itself *) - let path' = Env.normalize_path None env path in - if Path.same path path' then raise Cannot_expand - else newty2 level (Tconstr (path', args, abbrev)) - | (params, body, lv) -> - (* prerr_endline - ("add a "^string_of_kind kind^" expansion for "^Path.name path);*) - let ty' = subst env level kind abbrev (Some ty) params args body in - (* For gadts, remember type as non exportable *) - (* The ambiguous level registered for ty' should be the highest *) - if !trace_gadt_instances then begin - match max lv (Env.gadt_instance_level env ty) with - None -> () - | Some lv -> - if level < lv then raise (Unify [(ty, newvar2 level)]); - Env.add_gadt_instances env lv [ty; ty'] - end; - ty' + (* inlining *) + | "inline" -> + let module F = Float_arg_helper in + begin match F.parse_no_error v inline_threshold with + | F.Ok -> () + | F.Parse_failed exn -> + let error = + Printf.sprintf "bad syntax for \"inline\": %s" + (Printexc.to_string exn) + in + Location.print_warning Location.none ppf + (Warnings.Bad_env_variable ("OCAMLPARAM", error)) end - | _ -> - assert false -(* Expand respecting privacy *) -let expand_abbrev env ty = - expand_abbrev_gen Public Env.find_type_expansion env ty + | "inline-toplevel" -> + Int_arg_helper.parse v + "Bad syntax in OCAMLPARAM for 'inline-toplevel'" + inline_toplevel_threshold -(* Expand once the head of a type *) -let expand_head_once env ty = - try expand_abbrev env (repr ty) with Cannot_expand -> assert false + | "rounds" -> int_option_setter ppf "rounds" simplify_rounds v + | "inline-max-unroll" -> + Int_arg_helper.parse v "Bad syntax in OCAMLPARAM for 'inline-max-unroll'" + inline_max_unroll + | "inline-call-cost" -> + Int_arg_helper.parse v + "Bad syntax in OCAMLPARAM for 'inline-call-cost'" + inline_call_cost + | "inline-alloc-cost" -> + Int_arg_helper.parse v + "Bad syntax in OCAMLPARAM for 'inline-alloc-cost'" + inline_alloc_cost + | "inline-prim-cost" -> + Int_arg_helper.parse v + "Bad syntax in OCAMLPARAM for 'inline-prim-cost'" + inline_prim_cost + | "inline-branch-cost" -> + Int_arg_helper.parse v + "Bad syntax in OCAMLPARAM for 'inline-branch-cost'" + inline_branch_cost + | "inline-indirect-cost" -> + Int_arg_helper.parse v + "Bad syntax in OCAMLPARAM for 'inline-indirect-cost'" + inline_indirect_cost + | "inline-lifting-benefit" -> + Int_arg_helper.parse v + "Bad syntax in OCAMLPARAM for 'inline-lifting-benefit'" + inline_lifting_benefit + | "inline-branch-factor" -> + Float_arg_helper.parse v + "Bad syntax in OCAMLPARAM for 'inline-branch-factor'" + inline_branch_factor + | "inline-max-depth" -> + Int_arg_helper.parse v + "Bad syntax in OCAMLPARAM for 'inline-max-depth'" + inline_max_depth -(* Check whether a type can be expanded *) -let safe_abbrev env ty = - let snap = Btype.snapshot () in - try ignore (expand_abbrev env ty); true - with Cannot_expand | Unify _ -> - Btype.backtrack snap; - false + | "Oclassic" -> + set "Oclassic" [ classic_inlining ] v + | "O2" -> + if check_bool ppf "O2" v then begin + default_simplify_rounds := 2; + use_inlining_arguments_set o2_arguments; + use_inlining_arguments_set ~round:0 o1_arguments + end -(* Expand the head of a type once. - Raise Cannot_expand if the type cannot be expanded. - May raise Unify, if a recursion was hidden in the type. *) -let try_expand_once env ty = - let ty = repr ty in - match ty.desc with - Tconstr _ -> repr (expand_abbrev env ty) - | _ -> raise Cannot_expand + | "O3" -> + if check_bool ppf "O3" v then begin + default_simplify_rounds := 3; + use_inlining_arguments_set o3_arguments; + use_inlining_arguments_set ~round:1 o2_arguments; + use_inlining_arguments_set ~round:0 o1_arguments + end + | "unbox-closures" -> + set "unbox-closures" [ unbox_closures ] v + | "unbox-closures-factor" -> + int_setter ppf "unbox-closures-factor" unbox_closures_factor v + | "remove-unused-arguments" -> + set "remove-unused-arguments" [ remove_unused_arguments ] v -(* This one only raises Cannot_expand *) -let try_expand_safe env ty = - let snap = Btype.snapshot () in - try try_expand_once env ty - with Unify _ -> - Btype.backtrack snap; raise Cannot_expand + | "inlining-report" -> + if !native_code then + set "inlining-report" [ inlining_report ] v -(* Fully expand the head of a type. *) -let rec try_expand_head try_once env ty = - let ty' = try_once env ty in - try try_expand_head try_once env ty' - with Cannot_expand -> ty' + | "flambda-verbose" -> + set "flambda-verbose" [ dump_flambda_verbose ] v + | "flambda-invariants" -> + set "flambda-invariants" [ flambda_invariant_checks ] v -let try_expand_head try_once env ty = - let ty' = try_expand_head try_once env ty in - begin match Env.gadt_instance_level env ty' with - None -> () - | Some lv -> Env.add_gadt_instance_chain env lv ty - end; - ty' + (* color output *) + | "color" -> + begin match parse_color_setting v with + | None -> + Location.print_warning Location.none ppf + (Warnings.Bad_env_variable ("OCAMLPARAM", + "bad value for \"color\", \ + (expected \"auto\", \"always\" or \"never\")")) + | Some setting -> color := Some setting + end -(* Unsafe full expansion, may raise Unify. *) -let expand_head_unif env ty = - try try_expand_head try_expand_once env ty with Cannot_expand -> repr ty + | "intf-suffix" -> Config.interface_suffix := v -(* Safe version of expand_head, never fails *) -let expand_head env ty = - try try_expand_head try_expand_safe env ty with Cannot_expand -> repr ty + | "I" -> begin + match position with + | Before_args -> first_include_dirs := v :: !first_include_dirs + | Before_link | Before_compile _ -> + last_include_dirs := v :: !last_include_dirs + end -let _ = forward_try_expand_once := try_expand_safe + | "cclib" -> + begin + match position with + | Before_compile _ -> () + | Before_link | Before_args -> + ccobjs := Misc.rev_split_words v @ !ccobjs + end + | "ccopts" -> + begin + match position with + | Before_link | Before_compile _ -> + last_ccopts := v :: !last_ccopts + | Before_args -> + first_ccopts := v :: !first_ccopts + end -(* Expand until we find a non-abstract type declaration *) + | "ppx" -> + begin + match position with + | Before_link | Before_compile _ -> + last_ppx := v :: !last_ppx + | Before_args -> + first_ppx := v :: !first_ppx + end -let rec extract_concrete_typedecl env ty = - let ty = repr ty in - match ty.desc with - Tconstr (p, _, _) -> - let decl = Env.find_type p env in - if decl.type_kind <> Type_abstract then (p, p, decl) else - let ty = - try try_expand_once env ty with Cannot_expand -> raise Not_found - in - let (_, p', decl) = extract_concrete_typedecl env ty in - (p, p', decl) - | _ -> raise Not_found -(* Implementing function [expand_head_opt], the compiler's own version of - [expand_head] used for type-based optimisations. - [expand_head_opt] uses [Env.find_type_expansion_opt] to access the - manifest type information of private abstract data types which is - normally hidden to the type-checker out of the implementation module of - the private abbreviation. *) + | "cmo" | "cma" -> + if not !native_code then + begin + match position with + | Before_link | Before_compile _ -> + last_objfiles := v ::! last_objfiles + | Before_args -> + first_objfiles := v :: !first_objfiles + end -let expand_abbrev_opt = - expand_abbrev_gen Private Env.find_type_expansion_opt + | "cmx" | "cmxa" -> + if !native_code then + begin + match position with + | Before_link | Before_compile _ -> + last_objfiles := v ::! last_objfiles + | Before_args -> + first_objfiles := v :: !first_objfiles + end -let try_expand_once_opt env ty = - let ty = repr ty in - match ty.desc with - Tconstr _ -> repr (expand_abbrev_opt env ty) - | _ -> raise Cannot_expand + | "pic" -> + if !native_code then + set "pic" [ pic_code ] v -let rec try_expand_head_opt env ty = - let ty' = try_expand_once_opt env ty in - begin try - try_expand_head_opt env ty' - with Cannot_expand -> - ty' - end + | "can-discard" -> + can_discard := v ::!can_discard -let expand_head_opt env ty = - let snap = Btype.snapshot () in - try try_expand_head_opt env ty - with Cannot_expand | Unify _ -> (* expand_head shall never fail *) - Btype.backtrack snap; - repr ty + | "timings" | "profile" -> + let if_on = if name = "timings" then [ `Time ] else Profile.all_columns in + profile_columns := if check_bool ppf name v then if_on else [] -(* Make sure that the type parameters of the type constructor [ty] - respect the type constraints *) -let enforce_constraints env ty = - match ty with - {desc = Tconstr (path, args, _abbrev); level = level} -> - begin try - let decl = Env.find_type path env in - ignore - (subst env level Public (ref Mnil) None decl.type_params args - (newvar2 level)) - with Not_found -> () - end - | _ -> - assert false + | "plugin" -> !load_plugin v -(* Recursively expand the head of a type. - Also expand #-types. *) -let full_expand env ty = - let ty = repr (expand_head env ty) in - match ty.desc with - Tobject (fi, {contents = Some (_, v::_)}) when is_Tvar (repr v) -> - newty2 ty.level (Tobject (fi, ref None)) | _ -> - ty + if not (List.mem name !can_discard) then begin + can_discard := name :: !can_discard; + Printf.eprintf + "Warning: discarding value of variable %S in OCAMLPARAM\n%!" + name + end -(* - Check whether the abbreviation expands to a well-defined type. - During the typing of a class, abbreviations for correspondings - types expand to non-generic types. -*) -let generic_abbrev env path = +let read_OCAMLPARAM ppf position = try - let (_, body, _) = Env.find_type_expansion path env in - (repr body).level = generic_level - with - Not_found -> - false + let s = Sys.getenv "OCAMLPARAM" in + let (before, after) = + try + parse_args s + with SyntaxError s -> + Location.print_warning Location.none ppf + (Warnings.Bad_env_variable ("OCAMLPARAM", s)); + [],[] + in + List.iter (fun (name, v) -> read_one_param ppf position name v) + (match position with + Before_args -> before + | Before_compile _ | Before_link -> after) + with Not_found -> () -let generic_private_abbrev env path = - try - match Env.find_type path env with - {type_kind = Type_abstract; - type_private = Private; - type_manifest = Some body} -> - (repr body).level = generic_level - | _ -> false - with Not_found -> false +(* OCAMLPARAM passed as file *) -let is_contractive env p = - try - let decl = Env.find_type p env in - in_pervasives p && decl.type_manifest = None || is_datatype decl - with Not_found -> false +type pattern = + | Filename of string + | Any +type file_option = { + pattern : pattern; + name : string; + value : string; +} - (*****************) - (* Occur check *) - (*****************) +let scan_line ic = + Scanf.bscanf ic "%[0-9a-zA-Z_.*] : %[a-zA-Z_-] = %s " + (fun pattern name value -> + let pattern = + match pattern with + | "*" -> Any + | _ -> Filename pattern + in + { pattern; name; value }) + +let load_config ppf filename = + match open_in_bin filename with + | exception e -> + Location.print_error ppf (Location.in_file filename); + Format.fprintf ppf "Cannot open file %s@." (Printexc.to_string e); + raise Exit + | ic -> + let sic = Scanf.Scanning.from_channel ic in + let rec read line_number line_start acc = + match scan_line sic with + | exception End_of_file -> + close_in ic; + acc + | exception Scanf.Scan_failure error -> + let position = Lexing.{ + pos_fname = filename; + pos_lnum = line_number; + pos_bol = line_start; + pos_cnum = pos_in ic; + } + in + let loc = Location.{ + loc_start = position; + loc_end = position; + loc_ghost = false; + } + in + Location.print_error ppf loc; + Format.fprintf ppf "Configuration file error %s@." error; + close_in ic; + raise Exit + | line -> + read (line_number + 1) (pos_in ic) (line :: acc) + in + let lines = read 0 0 [] in + lines +let matching_filename filename { pattern } = + match pattern with + | Any -> true + | Filename pattern -> + let filename = String.lowercase_ascii filename in + let pattern = String.lowercase_ascii pattern in + filename = pattern -exception Occur +let apply_config_file ppf position = + let config_file = + Filename.concat Config.standard_library "ocaml_compiler_internal_params" + in + let config = + if Sys.file_exists config_file then + load_config ppf config_file + else + [] + in + let config = + match position with + | Before_compile filename -> + List.filter (matching_filename filename) config + | Before_args | Before_link -> + List.filter (fun { pattern } -> pattern = Any) config + in + List.iter (fun { name; value } -> read_one_param ppf position name value) + config -let rec occur_rec env allow_recursive visited ty0 = function - | {desc=Tlink ty} -> - occur_rec env allow_recursive visited ty0 ty - | ty -> - if ty == ty0 then raise Occur; - match ty.desc with - Tconstr(p, _tl, _abbrev) -> - if allow_recursive && is_contractive env p then () else - begin try - if TypeSet.mem ty visited then raise Occur; - let visited = TypeSet.add ty visited in - iter_type_expr (occur_rec env allow_recursive visited ty0) ty - with Occur -> try - let ty' = try_expand_head try_expand_once env ty in - (* This call used to be inlined, but there seems no reason for it. - Message was referring to change in rev. 1.58 of the CVS repo. *) - occur_rec env allow_recursive visited ty0 ty' - with Cannot_expand -> - raise Occur - end - | Tobject _ | Tvariant _ -> - () - | _ -> - if allow_recursive || TypeSet.mem ty visited then () else begin - let visited = TypeSet.add ty visited in - iter_type_expr (occur_rec env allow_recursive visited ty0) ty - end +let readenv ppf position = + last_include_dirs := []; + last_ccopts := []; + last_ppx := []; + last_objfiles := []; + apply_config_file ppf position; + read_OCAMLPARAM ppf position; + all_ccopts := !last_ccopts @ !first_ccopts; + all_ppx := !last_ppx @ !first_ppx -let type_changed = ref false (* trace possible changes to the studied type *) +let get_objfiles ~with_ocamlparam = + if with_ocamlparam then + List.rev (!last_objfiles @ !objfiles @ !first_objfiles) + else + List.rev !objfiles -let merge r b = if b then r := true -let occur env ty0 ty = - let allow_recursive = !Clflags.recursive_types || !umode = Pattern in - let old = !type_changed in - try - while - type_changed := false; - occur_rec env allow_recursive TypeSet.empty ty0 ty; - !type_changed - do () (* prerr_endline "changed" *) done; - merge type_changed old - with exn -> - merge type_changed old; - raise (match exn with Occur -> Unify [] | _ -> exn) -let occur_in env ty0 t = - try occur env ty0 t; false with Unify _ -> true -(* Check that a local constraint is well-founded *) -(* PR#6405: not needed since we allow recursion and work on normalized types *) -(* PR#6992: we actually need it for contractiveness *) -(* This is a simplified version of occur, only for the rectypes case *) -let rec local_non_recursive_abbrev strict visited env p ty = - (*Format.eprintf "@[Check %s =@ %a@]@." (Path.name p) !Btype.print_raw ty;*) - let ty = repr ty in - if not (List.memq ty visited) then begin - match ty.desc with - Tconstr(p', args, _abbrev) -> - if Path.same p p' then raise Occur; - if not strict && is_contractive env p' then () else - let visited = ty :: visited in - begin try - (* try expanding, since [p] could be hidden *) - local_non_recursive_abbrev strict visited env p - (try_expand_head try_expand_once env ty) - with Cannot_expand -> - let params = - try (Env.find_type p' env).type_params - with Not_found -> args - in - List.iter2 - (fun tv ty -> - let strict = strict || not (is_Tvar (repr tv)) in - local_non_recursive_abbrev strict visited env p ty) - params args - end - | _ -> - if strict then (* PR#7374 *) - let visited = ty :: visited in - iter_type_expr (local_non_recursive_abbrev true visited env p) ty - end -let local_non_recursive_abbrev env p ty = - try (* PR#7397: need to check trace_gadt_instances *) - wrap_trace_gadt_instances env - (local_non_recursive_abbrev false [] env p) ty; - true - with Occur -> false +type deferred_action = + | ProcessImplementation of string + | ProcessInterface of string + | ProcessCFile of string + | ProcessOtherFile of string + | ProcessObjects of string list + | ProcessDLLs of string list +let c_object_of_filename name = + Filename.chop_suffix (Filename.basename name) ".c" ^ Config.ext_obj - (*****************************) - (* Polymorphic Unification *) - (*****************************) +let process_action + (ppf, implementation, interface, ocaml_mod_ext, ocaml_lib_ext) action = + match action with + | ProcessImplementation name -> + readenv ppf (Before_compile name); + let opref = output_prefix name in + implementation ppf name opref; + objfiles := (opref ^ ocaml_mod_ext) :: !objfiles + | ProcessInterface name -> + readenv ppf (Before_compile name); + let opref = output_prefix name in + interface ppf name opref; + if !make_package then objfiles := (opref ^ ".cmi") :: !objfiles + | ProcessCFile name -> + readenv ppf (Before_compile name); + Location.set_input_name name; + if Ccomp.compile_file name <> 0 then exit 2; + ccobjs := c_object_of_filename name :: !ccobjs + | ProcessObjects names -> + ccobjs := names @ !ccobjs + | ProcessDLLs names -> + dllibs := names @ !dllibs + | ProcessOtherFile name -> + if Filename.check_suffix name ocaml_mod_ext + || Filename.check_suffix name ocaml_lib_ext then + objfiles := name :: !objfiles + else if Filename.check_suffix name ".cmi" && !make_package then + objfiles := name :: !objfiles + else if Filename.check_suffix name Config.ext_obj + || Filename.check_suffix name Config.ext_lib then + ccobjs := name :: !ccobjs + else if not !native_code && Filename.check_suffix name Config.ext_dll then + dllibs := name :: !dllibs + else + raise(Arg.Bad("don't know what to do with " ^ name)) -(* Since we cannot duplicate universal variables, unification must - be done at meta-level, using bindings in univar_pairs *) -let rec unify_univar t1 t2 = function - (cl1, cl2) :: rem -> - let find_univ t cl = - try - let (_, r) = List.find (fun (t',_) -> t == repr t') cl in - Some r - with Not_found -> None - in - begin match find_univ t1 cl1, find_univ t2 cl2 with - Some {contents=Some t'2}, Some _ when t2 == repr t'2 -> - () - | Some({contents=None} as r1), Some({contents=None} as r2) -> - set_univar r1 t2; set_univar r2 t1 - | None, None -> - unify_univar t1 t2 rem - | _ -> - raise (Unify []) - end - | [] -> raise (Unify []) -(* Test the occurrence of free univars in a type *) -(* that's way too expensive. Must do some kind of caching *) -let occur_univar env ty = - let visited = ref TypeMap.empty in - let rec occur_rec bound ty = - let ty = repr ty in - if ty.level >= lowest_level && - if TypeSet.is_empty bound then - (ty.level <- pivot_level - ty.level; true) - else try - let bound' = TypeMap.find ty !visited in - if TypeSet.exists (fun x -> not (TypeSet.mem x bound)) bound' then - (visited := TypeMap.add ty (TypeSet.inter bound bound') !visited; - true) - else false - with Not_found -> - visited := TypeMap.add ty bound !visited; - true - then - match ty.desc with - Tunivar _ -> - if not (TypeSet.mem ty bound) then raise (Unify [ty, newgenvar ()]) - | Tpoly (ty, tyl) -> - let bound = List.fold_right TypeSet.add (List.map repr tyl) bound in - occur_rec bound ty - | Tconstr (_, [], _) -> () - | Tconstr (p, tl, _) -> - begin try - let td = Env.find_type p env in - List.iter2 - (fun t v -> - if Variance.(mem May_pos v || mem May_neg v) - then occur_rec bound t) - tl td.type_variance - with Not_found -> - List.iter (occur_rec bound) tl - end - | _ -> iter_type_expr (occur_rec bound) ty - in - try - occur_rec TypeSet.empty ty; unmark_type ty - with exn -> - unmark_type ty; raise exn +let action_of_file name = + if Filename.check_suffix name ".ml" + || Filename.check_suffix name ".mlt" then + ProcessImplementation name + else if Filename.check_suffix name !Config.interface_suffix then + ProcessInterface name + else if Filename.check_suffix name ".c" then + ProcessCFile name + else + ProcessOtherFile name -(* Grouping univars by families according to their binders *) -let add_univars = - List.fold_left (fun s (t,_) -> TypeSet.add (repr t) s) +let deferred_actions = ref [] +let defer action = + deferred_actions := action :: !deferred_actions -let get_univar_family univar_pairs univars = - if univars = [] then TypeSet.empty else - let insert s = function - cl1, (_::_ as cl2) -> - if List.exists (fun (t1,_) -> TypeSet.mem (repr t1) s) cl1 then - add_univars s cl2 - else s - | _ -> s - in - let s = List.fold_right TypeSet.add univars TypeSet.empty in - List.fold_left insert s univar_pairs +let anonymous filename = defer (action_of_file filename) +let impl filename = defer (ProcessImplementation filename) +let intf filename = defer (ProcessInterface filename) -(* Whether a family of univars escapes from a type *) -let univars_escape env univar_pairs vl ty = - let family = get_univar_family univar_pairs vl in - let visited = ref TypeSet.empty in - let rec occur t = - let t = repr t in - if TypeSet.mem t !visited then () else begin - visited := TypeSet.add t !visited; - match t.desc with - Tpoly (t, tl) -> - if List.exists (fun t -> TypeSet.mem (repr t) family) tl then () - else occur t - | Tunivar _ -> - if TypeSet.mem t family then raise Occur - | Tconstr (_, [], _) -> () - | Tconstr (p, tl, _) -> - begin try - let td = Env.find_type p env in - List.iter2 - (fun t v -> - if Variance.(mem May_pos v || mem May_neg v) then occur t) - tl td.type_variance - with Not_found -> - List.iter occur tl - end - | _ -> - iter_type_expr occur t - end - in - try occur ty; false with Occur -> true +let process_deferred_actions env = + let final_output_name = !output_name in + (* Make sure the intermediate products don't clash with the final one + when we're invoked like: ocamlopt -o foo bar.c baz.ml. *) + if not !compile_only then output_name := None; + begin + match final_output_name with + | None -> () + | Some output_name -> + if !compile_only then begin + if List.filter (function + | ProcessCFile name -> c_object_of_filename name <> output_name + | _ -> false) !deferred_actions <> [] then + fatal "Options -c and -o are incompatible when compiling C files"; -(* Wrapper checking that no variable escapes and updating univar_pairs *) -let enter_poly env univar_pairs t1 tl1 t2 tl2 f = - let old_univars = !univar_pairs in - let known_univars = - List.fold_left (fun s (cl,_) -> add_univars s cl) - TypeSet.empty old_univars - in - let tl1 = List.map repr tl1 and tl2 = List.map repr tl2 in - if List.exists (fun t -> TypeSet.mem t known_univars) tl1 && - univars_escape env old_univars tl1 (newty(Tpoly(t2,tl2))) - || List.exists (fun t -> TypeSet.mem t known_univars) tl2 && - univars_escape env old_univars tl2 (newty(Tpoly(t1,tl1))) - then raise (Unify []); - let cl1 = List.map (fun t -> t, ref None) tl1 - and cl2 = List.map (fun t -> t, ref None) tl2 in - univar_pairs := (cl1,cl2) :: (cl2,cl1) :: old_univars; - try let res = f t1 t2 in univar_pairs := old_univars; res - with exn -> univar_pairs := old_univars; raise exn + if List.length (List.filter (function + | ProcessImplementation _ + | ProcessInterface _ + | _ -> false) !deferred_actions) > 1 then + fatal "Options -c -o are incompatible with compiling multiple files" + end; + end; + if !make_archive && List.exists (function + | ProcessOtherFile name -> Filename.check_suffix name ".cmxa" + | _ -> false) !deferred_actions then + fatal "Option -a cannot be used with .cmxa input files."; + List.iter (process_action env) (List.rev !deferred_actions); + output_name := final_output_name; -let univar_pairs = ref [] +end +(** Interface as module *) +module Annot += struct +#1 "annot.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Damien Doligez, projet Gallium, INRIA Rocquencourt *) +(* *) +(* Copyright 2007 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) +(* Data types for annotations (Stypes.ml) *) - (*****************) - (* Unification *) - (*****************) +type call = Tail | Stack | Inline;; +type ident = + | Iref_internal of Location.t (* defining occurrence *) + | Iref_external + | Idef of Location.t (* scope *) +;; +end +module Tast_mapper : sig +#1 "tast_mapper.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Alain Frisch, LexiFi *) +(* *) +(* Copyright 2015 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -let rec has_cached_expansion p abbrev = - match abbrev with - Mnil -> false - | Mcons(_, p', _, _, rem) -> Path.same p p' || has_cached_expansion p rem - | Mlink rem -> has_cached_expansion p !rem +open Asttypes +open Typedtree -(**** Transform error trace ****) -(* +++ Move it to some other place ? *) +(** {1 A generic Typedtree mapper} *) -let expand_trace env trace = - List.fold_right - (fun (t1, t2) rem -> - (repr t1, full_expand env t1)::(repr t2, full_expand env t2)::rem) - trace [] +type mapper = + { + case: mapper -> case -> case; + cases: mapper -> case list -> case list; + class_declaration: mapper -> class_declaration -> class_declaration; + class_description: mapper -> class_description -> class_description; + class_expr: mapper -> class_expr -> class_expr; + class_field: mapper -> class_field -> class_field; + class_signature: mapper -> class_signature -> class_signature; + class_structure: mapper -> class_structure -> class_structure; + class_type: mapper -> class_type -> class_type; + class_type_declaration: mapper -> class_type_declaration -> + class_type_declaration; + class_type_field: mapper -> class_type_field -> class_type_field; + env: mapper -> Env.t -> Env.t; + expr: mapper -> expression -> expression; + extension_constructor: mapper -> extension_constructor -> + extension_constructor; + module_binding: mapper -> module_binding -> module_binding; + module_coercion: mapper -> module_coercion -> module_coercion; + module_declaration: mapper -> module_declaration -> module_declaration; + module_expr: mapper -> module_expr -> module_expr; + module_type: mapper -> module_type -> module_type; + module_type_declaration: + mapper -> module_type_declaration -> module_type_declaration; + package_type: mapper -> package_type -> package_type; + pat: mapper -> pattern -> pattern; + row_field: mapper -> row_field -> row_field; + object_field: mapper -> object_field -> object_field; + signature: mapper -> signature -> signature; + signature_item: mapper -> signature_item -> signature_item; + structure: mapper -> structure -> structure; + structure_item: mapper -> structure_item -> structure_item; + typ: mapper -> core_type -> core_type; + type_declaration: mapper -> type_declaration -> type_declaration; + type_declarations: mapper -> (rec_flag * type_declaration list) -> + (rec_flag * type_declaration list); + type_extension: mapper -> type_extension -> type_extension; + type_kind: mapper -> type_kind -> type_kind; + value_binding: mapper -> value_binding -> value_binding; + value_bindings: mapper -> (rec_flag * value_binding list) -> + (rec_flag * value_binding list); + value_description: mapper -> value_description -> value_description; + with_constraint: mapper -> with_constraint -> with_constraint; + } -(* build a dummy variant type *) -let mkvariant fields closed = - newgenty - (Tvariant - {row_fields = fields; row_closed = closed; row_more = newvar(); - row_bound = (); row_fixed = false; row_name = None }) -(**** Unification ****) +val default: mapper -(* Return whether [t0] occurs in [ty]. Objects are also traversed. *) -let deep_occur t0 ty = - let rec occur_rec ty = - let ty = repr ty in - if ty.level >= lowest_level then begin - if ty == t0 then raise Occur; - ty.level <- pivot_level - ty.level; - iter_type_expr occur_rec ty - end - in - try - occur_rec ty; unmark_type ty; false - with Occur -> - unmark_type ty; true +end = struct +#1 "tast_mapper.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Alain Frisch, LexiFi *) +(* *) +(* Copyright 2015 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -(* - 1. When unifying two non-abbreviated types, one type is made a link - to the other. When unifying an abbreviated type with a - non-abbreviated type, the non-abbreviated type is made a link to - the other one. When unifying to abbreviated types, these two - types are kept distincts, but they are made to (temporally) - expand to the same type. - 2. Abbreviations with at least one parameter are systematically - expanded. The overhead does not seem too high, and that way - abbreviations where some parameters does not appear in the - expansion, such as ['a t = int], are correctly handled. In - particular, for this example, unifying ['a t] with ['b t] keeps - ['a] and ['b] distincts. (Is it really important ?) - 3. Unifying an abbreviation ['a t = 'a] with ['a] should not yield - ['a t as 'a]. Indeed, the type variable would otherwise be lost. - This problem occurs for abbreviations expanding to a type - variable, but also to many other constrained abbreviations (for - instance, [(< x : 'a > -> unit) t = ]). The solution is - that, if an abbreviation is unified with some subpart of its - parameters, then the parameter actually does not get - abbreviated. It would be possible to check whether some - information is indeed lost, but it probably does not worth it. -*) +open Asttypes +open Typedtree + +(* TODO: add 'methods' for location, attribute, extension, + open_description, include_declaration, include_description *) + +type mapper = + { + case: mapper -> case -> case; + cases: mapper -> case list -> case list; + class_declaration: mapper -> class_declaration -> class_declaration; + class_description: mapper -> class_description -> class_description; + class_expr: mapper -> class_expr -> class_expr; + class_field: mapper -> class_field -> class_field; + class_signature: mapper -> class_signature -> class_signature; + class_structure: mapper -> class_structure -> class_structure; + class_type: mapper -> class_type -> class_type; + class_type_declaration: mapper -> class_type_declaration -> + class_type_declaration; + class_type_field: mapper -> class_type_field -> class_type_field; + env: mapper -> Env.t -> Env.t; + expr: mapper -> expression -> expression; + extension_constructor: mapper -> extension_constructor -> + extension_constructor; + module_binding: mapper -> module_binding -> module_binding; + module_coercion: mapper -> module_coercion -> module_coercion; + module_declaration: mapper -> module_declaration -> module_declaration; + module_expr: mapper -> module_expr -> module_expr; + module_type: mapper -> module_type -> module_type; + module_type_declaration: + mapper -> module_type_declaration -> module_type_declaration; + package_type: mapper -> package_type -> package_type; + pat: mapper -> pattern -> pattern; + row_field: mapper -> row_field -> row_field; + object_field: mapper -> object_field -> object_field; + signature: mapper -> signature -> signature; + signature_item: mapper -> signature_item -> signature_item; + structure: mapper -> structure -> structure; + structure_item: mapper -> structure_item -> structure_item; + typ: mapper -> core_type -> core_type; + type_declaration: mapper -> type_declaration -> type_declaration; + type_declarations: mapper -> (rec_flag * type_declaration list) -> + (rec_flag * type_declaration list); + type_extension: mapper -> type_extension -> type_extension; + type_kind: mapper -> type_kind -> type_kind; + value_binding: mapper -> value_binding -> value_binding; + value_bindings: mapper -> (rec_flag * value_binding list) -> + (rec_flag * value_binding list); + value_description: mapper -> value_description -> value_description; + with_constraint: mapper -> with_constraint -> with_constraint; + } + +let id x = x +let tuple2 f1 f2 (x, y) = (f1 x, f2 y) +let tuple3 f1 f2 f3 (x, y, z) = (f1 x, f2 y, f3 z) +let opt f = function None -> None | Some x -> Some (f x) + +let structure sub {str_items; str_type; str_final_env} = + { + str_items = List.map (sub.structure_item sub) str_items; + str_final_env = sub.env sub str_final_env; + str_type; + } -let newtype_level = ref None +let class_infos sub f x = + {x with + ci_params = List.map (tuple2 (sub.typ sub) id) x.ci_params; + ci_expr = f x.ci_expr; + } -let get_newtype_level () = - match !newtype_level with - | None -> assert false - | Some x -> x +let module_type_declaration sub x = + let mtd_type = opt (sub.module_type sub) x.mtd_type in + {x with mtd_type} -(* a local constraint can be added only if the rhs - of the constraint does not contain any Tvars. - They need to be removed using this function *) -let reify env t = - let newtype_level = get_newtype_level () in - let create_fresh_constr lev name = - let decl = new_declaration (Some (newtype_level, newtype_level)) None in - let name = match name with Some s -> "$'"^s | _ -> "$" in - let path = Path.Pident (Ident.create (get_new_abstract_name name)) in - let new_env = Env.add_local_type path decl !env in - let t = newty2 lev (Tconstr (path,[],ref Mnil)) in - env := new_env; - t - in - let visited = ref TypeSet.empty in - let rec iterator ty = - let ty = repr ty in - if TypeSet.mem ty !visited then () else begin - visited := TypeSet.add ty !visited; - match ty.desc with - Tvar o -> - let t = create_fresh_constr ty.level o in - link_type ty t; - if ty.level < newtype_level then - raise (Unify [t, newvar2 ty.level]) - | Tvariant r -> - let r = row_repr r in - if not (static_row r) then begin - if r.row_fixed then iterator (row_more r) else - let m = r.row_more in - match m.desc with - Tvar o -> - let t = create_fresh_constr m.level o in - let row = - {r with row_fields=[]; row_fixed=true; row_more = t} in - link_type m (newty2 m.level (Tvariant row)); - if m.level < newtype_level then - raise (Unify [t, newvar2 m.level]) - | _ -> assert false - end; - iter_row iterator r - | Tconstr (p, _, _) when is_object_type p -> - iter_type_expr iterator (full_expand !env ty) - | _ -> - iter_type_expr iterator ty - end - in - iterator t +let module_declaration sub x = + let md_type = sub.module_type sub x.md_type in + {x with md_type} -let is_newtype env p = - try - let decl = Env.find_type p env in - decl.type_newtype_level <> None && - decl.type_kind = Type_abstract && - decl.type_private = Public - with Not_found -> false +let include_infos f x = {x with incl_mod = f x.incl_mod} -let non_aliasable p decl = - (* in_pervasives p || (subsumed by in_current_module) *) - in_current_module p && decl.type_newtype_level = None +let class_type_declaration sub x = + class_infos sub (sub.class_type sub) x -let is_instantiable env p = - try - let decl = Env.find_type p env in - decl.type_kind = Type_abstract && - decl.type_private = Public && - decl.type_arity = 0 && - decl.type_manifest = None && - not (non_aliasable p decl) - with Not_found -> false +let class_declaration sub x = + class_infos sub (sub.class_expr sub) x +let structure_item sub {str_desc; str_loc; str_env} = + let str_env = sub.env sub str_env in + let str_desc = + match str_desc with + | Tstr_eval (exp, attrs) -> Tstr_eval (sub.expr sub exp, attrs) + | Tstr_value (rec_flag, list) -> + let (rec_flag, list) = sub.value_bindings sub (rec_flag, list) in + Tstr_value (rec_flag, list) + | Tstr_primitive v -> Tstr_primitive (sub.value_description sub v) + | Tstr_type (rec_flag, list) -> + let (rec_flag, list) = sub.type_declarations sub (rec_flag, list) in + Tstr_type (rec_flag, list) + | Tstr_typext te -> Tstr_typext (sub.type_extension sub te) + | Tstr_exception ext -> Tstr_exception (sub.extension_constructor sub ext) + | Tstr_module mb -> Tstr_module (sub.module_binding sub mb) + | Tstr_recmodule list -> + Tstr_recmodule (List.map (sub.module_binding sub) list) + | Tstr_modtype x -> Tstr_modtype (sub.module_type_declaration sub x) + | Tstr_class list -> + Tstr_class + (List.map (tuple2 (sub.class_declaration sub) id) list) + | Tstr_class_type list -> + Tstr_class_type + (List.map (tuple3 id id (sub.class_type_declaration sub)) list) + | Tstr_include incl -> + Tstr_include (include_infos (sub.module_expr sub) incl) + | Tstr_open _ + | Tstr_attribute _ as d -> d + in + {str_desc; str_env; str_loc} -(* PR#7113: -safe-string should be a global property *) -let compatible_paths p1 p2 = - let open Predef in - Path.same p1 p2 || - Path.same p1 path_bytes && Path.same p2 path_string || - Path.same p1 path_string && Path.same p2 path_bytes +let value_description sub x = + let val_desc = sub.typ sub x.val_desc in + {x with val_desc} -(* Check for datatypes carefully; see PR#6348 *) -let rec expands_to_datatype env ty = - let ty = repr ty in - match ty.desc with - Tconstr (p, _, _) -> - begin try - is_datatype (Env.find_type p env) || - expands_to_datatype env (try_expand_once env ty) - with Not_found | Cannot_expand -> false - end - | _ -> false +let label_decl sub x = + let ld_type = sub.typ sub x.ld_type in + {x with ld_type} -(* mcomp type_pairs subst env t1 t2 does not raise an - exception if it is possible that t1 and t2 are actually - equal, assuming the types in type_pairs are equal and - that the mapping subst holds. - Assumes that both t1 and t2 do not contain any tvars - and that both their objects and variants are closed - *) +let constructor_args sub = function + | Cstr_tuple l -> Cstr_tuple (List.map (sub.typ sub) l) + | Cstr_record l -> Cstr_record (List.map (label_decl sub) l) -let rec mcomp type_pairs env t1 t2 = - if t1 == t2 then () else - let t1 = repr t1 in - let t2 = repr t2 in - if t1 == t2 then () else - match (t1.desc, t2.desc) with - | (Tvar _, _) - | (_, Tvar _) -> - () - | (Tconstr (p1, [], _), Tconstr (p2, [], _)) when Path.same p1 p2 -> - () - | _ -> - let t1' = expand_head_opt env t1 in - let t2' = expand_head_opt env t2 in - (* Expansion may have changed the representative of the types... *) - let t1' = repr t1' and t2' = repr t2' in - if t1' == t2' then () else - begin try TypePairs.find type_pairs (t1', t2') - with Not_found -> - TypePairs.add type_pairs (t1', t2') (); - match (t1'.desc, t2'.desc) with - (Tvar _, Tvar _) -> assert false - | (Tarrow (l1, t1, u1, _), Tarrow (l2, t2, u2, _)) - when l1 = l2 || not (is_optional l1 || is_optional l2) -> - mcomp type_pairs env t1 t2; - mcomp type_pairs env u1 u2; - | (Ttuple tl1, Ttuple tl2) -> - mcomp_list type_pairs env tl1 tl2 - | (Tconstr (p1, tl1, _), Tconstr (p2, tl2, _)) -> - mcomp_type_decl type_pairs env p1 p2 tl1 tl2 - | (Tconstr (p, _, _), _) | (_, Tconstr (p, _, _)) -> - begin try - let decl = Env.find_type p env in - if non_aliasable p decl || is_datatype decl then raise (Unify []) - with Not_found -> () - end - (* - | (Tpackage (p1, n1, tl1), Tpackage (p2, n2, tl2)) when n1 = n2 -> - mcomp_list type_pairs env tl1 tl2 - *) - | (Tpackage _, Tpackage _) -> () - | (Tvariant row1, Tvariant row2) -> - mcomp_row type_pairs env row1 row2 - | (Tobject (fi1, _), Tobject (fi2, _)) -> - mcomp_fields type_pairs env fi1 fi2 - | (Tfield _, Tfield _) -> (* Actually unused *) - mcomp_fields type_pairs env t1' t2' - | (Tnil, Tnil) -> - () - | (Tpoly (t1, []), Tpoly (t2, [])) -> - mcomp type_pairs env t1 t2 - | (Tpoly (t1, tl1), Tpoly (t2, tl2)) -> - enter_poly env univar_pairs t1 tl1 t2 tl2 - (mcomp type_pairs env) - | (Tunivar _, Tunivar _) -> - unify_univar t1' t2' !univar_pairs - | (_, _) -> - raise (Unify []) - end +let constructor_decl sub cd = + let cd_args = constructor_args sub cd.cd_args in + let cd_res = opt (sub.typ sub) cd.cd_res in + {cd with cd_args; cd_res} -and mcomp_list type_pairs env tl1 tl2 = - if List.length tl1 <> List.length tl2 then - raise (Unify []); - List.iter2 (mcomp type_pairs env) tl1 tl2 +let type_kind sub = function + | Ttype_abstract -> Ttype_abstract + | Ttype_variant list -> Ttype_variant (List.map (constructor_decl sub) list) + | Ttype_record list -> Ttype_record (List.map (label_decl sub) list) + | Ttype_open -> Ttype_open -and mcomp_fields type_pairs env ty1 ty2 = - if not (concrete_object ty1 && concrete_object ty2) then assert false; - let (fields2, rest2) = flatten_fields ty2 in - let (fields1, rest1) = flatten_fields ty1 in - let (pairs, miss1, miss2) = associate_fields fields1 fields2 in - let has_present = - List.exists (fun (_, k, _) -> field_kind_repr k = Fpresent) in - mcomp type_pairs env rest1 rest2; - if has_present miss1 && (object_row ty2).desc = Tnil - || has_present miss2 && (object_row ty1).desc = Tnil then raise (Unify []); - List.iter - (function (_n, k1, t1, k2, t2) -> - mcomp_kind k1 k2; - mcomp type_pairs env t1 t2) - pairs +let type_declaration sub x = + let typ_cstrs = + List.map + (tuple3 (sub.typ sub) (sub.typ sub) id) + x.typ_cstrs + in + let typ_kind = sub.type_kind sub x.typ_kind in + let typ_manifest = opt (sub.typ sub) x.typ_manifest in + let typ_params = List.map (tuple2 (sub.typ sub) id) x.typ_params in + {x with typ_cstrs; typ_kind; typ_manifest; typ_params} -and mcomp_kind k1 k2 = - let k1 = field_kind_repr k1 in - let k2 = field_kind_repr k2 in - match k1, k2 with - (Fpresent, Fabsent) - | (Fabsent, Fpresent) -> raise (Unify []) - | _ -> () +let type_declarations sub (rec_flag, list) = + (rec_flag, List.map (sub.type_declaration sub) list) -and mcomp_row type_pairs env row1 row2 = - let row1 = row_repr row1 and row2 = row_repr row2 in - let r1, r2, pairs = merge_row_fields row1.row_fields row2.row_fields in - let cannot_erase (_,f) = - match row_field_repr f with - Rpresent _ -> true - | Rabsent | Reither _ -> false +let type_extension sub x = + let tyext_params = List.map (tuple2 (sub.typ sub) id) x.tyext_params in + let tyext_constructors = + List.map (sub.extension_constructor sub) x.tyext_constructors in - if row1.row_closed && List.exists cannot_erase r2 - || row2.row_closed && List.exists cannot_erase r1 then raise (Unify []); - List.iter - (fun (_,f1,f2) -> - match row_field_repr f1, row_field_repr f2 with - | Rpresent None, (Rpresent (Some _) | Reither (_, _::_, _, _) | Rabsent) - | Rpresent (Some _), (Rpresent None | Reither (true, _, _, _) | Rabsent) - | (Reither (_, _::_, _, _) | Rabsent), Rpresent None - | (Reither (true, _, _, _) | Rabsent), Rpresent (Some _) -> - raise (Unify []) - | Rpresent(Some t1), Rpresent(Some t2) -> - mcomp type_pairs env t1 t2 - | Rpresent(Some t1), Reither(false, tl2, _, _) -> - List.iter (mcomp type_pairs env t1) tl2 - | Reither(false, tl1, _, _), Rpresent(Some t2) -> - List.iter (mcomp type_pairs env t2) tl1 - | _ -> ()) - pairs - -and mcomp_type_decl type_pairs env p1 p2 tl1 tl2 = - try - let decl = Env.find_type p1 env in - let decl' = Env.find_type p2 env in - if compatible_paths p1 p2 then begin - let inj = - try List.map Variance.(mem Inj) (Env.find_type p1 env).type_variance - with Not_found -> List.map (fun _ -> false) tl1 - in - List.iter2 - (fun i (t1,t2) -> if i then mcomp type_pairs env t1 t2) - inj (List.combine tl1 tl2) - end else if non_aliasable p1 decl && non_aliasable p2 decl' then - raise (Unify []) - else - match decl.type_kind, decl'.type_kind with - | Type_record (lst,r), Type_record (lst',r') when r = r' -> - mcomp_list type_pairs env tl1 tl2; - mcomp_record_description type_pairs env lst lst' - | Type_variant v1, Type_variant v2 -> - mcomp_list type_pairs env tl1 tl2; - mcomp_variant_description type_pairs env v1 v2 - | Type_open, Type_open -> - mcomp_list type_pairs env tl1 tl2 - | Type_abstract, Type_abstract -> () - | Type_abstract, _ when not (non_aliasable p1 decl)-> () - | _, Type_abstract when not (non_aliasable p2 decl') -> () - | _ -> raise (Unify []) - with Not_found -> () + {x with tyext_constructors; tyext_params} -and mcomp_type_option type_pairs env t t' = - match t, t' with - None, None -> () - | Some t, Some t' -> mcomp type_pairs env t t' - | _ -> raise (Unify []) +let extension_constructor sub x = + let ext_kind = + match x.ext_kind with + Text_decl(ctl, cto) -> + Text_decl(constructor_args sub ctl, opt (sub.typ sub) cto) + | Text_rebind _ as d -> d + in + {x with ext_kind} -and mcomp_variant_description type_pairs env xs ys = - let rec iter = fun x y -> - match x, y with - | c1 :: xs, c2 :: ys -> - mcomp_type_option type_pairs env c1.cd_res c2.cd_res; - begin match c1.cd_args, c2.cd_args with - | Cstr_tuple l1, Cstr_tuple l2 -> mcomp_list type_pairs env l1 l2 - | Cstr_record l1, Cstr_record l2 -> - mcomp_record_description type_pairs env l1 l2 - | _ -> raise (Unify []) - end; - if Ident.name c1.cd_id = Ident.name c2.cd_id - then iter xs ys - else raise (Unify []) - | [],[] -> () - | _ -> raise (Unify []) +let pat sub x = + let extra = function + | Tpat_type _ + | Tpat_unpack as d -> d + | Tpat_open (path,loc,env) -> Tpat_open (path, loc, sub.env sub env) + | Tpat_constraint ct -> Tpat_constraint (sub.typ sub ct) in - iter xs ys + let pat_env = sub.env sub x.pat_env in + let pat_extra = List.map (tuple3 extra id id) x.pat_extra in + let pat_desc = + match x.pat_desc with + | Tpat_any + | Tpat_var _ + | Tpat_constant _ as d -> d + | Tpat_tuple l -> Tpat_tuple (List.map (sub.pat sub) l) + | Tpat_construct (loc, cd, l) -> + Tpat_construct (loc, cd, List.map (sub.pat sub) l) + | Tpat_variant (l, po, rd) -> Tpat_variant (l, opt (sub.pat sub) po, rd) + | Tpat_record (l, closed) -> + Tpat_record (List.map (tuple3 id id (sub.pat sub)) l, closed) + | Tpat_array l -> Tpat_array (List.map (sub.pat sub) l) + | Tpat_or (p1, p2, rd) -> + Tpat_or (sub.pat sub p1, sub.pat sub p2, rd) + | Tpat_alias (p, id, s) -> Tpat_alias (sub.pat sub p, id, s) + | Tpat_lazy p -> Tpat_lazy (sub.pat sub p) + in + {x with pat_extra; pat_desc; pat_env} -and mcomp_record_description type_pairs env = - let rec iter x y = - match x, y with - | l1 :: xs, l2 :: ys -> - mcomp type_pairs env l1.ld_type l2.ld_type; - if Ident.name l1.ld_id = Ident.name l2.ld_id && - l1.ld_mutable = l2.ld_mutable - then iter xs ys - else raise (Unify []) - | [], [] -> () - | _ -> raise (Unify []) +let expr sub x = + let extra = function + | Texp_constraint cty -> + Texp_constraint (sub.typ sub cty) + | Texp_coerce (cty1, cty2) -> + Texp_coerce (opt (sub.typ sub) cty1, sub.typ sub cty2) + | Texp_open (ovf, path, loc, env) -> + Texp_open (ovf, path, loc, sub.env sub env) + | Texp_newtype _ as d -> d + | Texp_poly cto -> Texp_poly (opt (sub.typ sub) cto) + in + let exp_extra = List.map (tuple3 extra id id) x.exp_extra in + let exp_env = sub.env sub x.exp_env in + let exp_desc = + match x.exp_desc with + | Texp_ident _ + | Texp_constant _ as d -> d + | Texp_let (rec_flag, list, exp) -> + let (rec_flag, list) = sub.value_bindings sub (rec_flag, list) in + Texp_let (rec_flag, list, sub.expr sub exp) + | Texp_function { arg_label; param; cases; partial; } -> + Texp_function { arg_label; param; cases = sub.cases sub cases; + partial; } + | Texp_apply (exp, list) -> + Texp_apply ( + sub.expr sub exp, + List.map (tuple2 id (opt (sub.expr sub))) list + ) + | Texp_match (exp, cases, exn_cases, p) -> + Texp_match ( + sub.expr sub exp, + sub.cases sub cases, + sub.cases sub exn_cases, + p + ) + | Texp_try (exp, cases) -> + Texp_try ( + sub.expr sub exp, + sub.cases sub cases + ) + | Texp_tuple list -> + Texp_tuple (List.map (sub.expr sub) list) + | Texp_construct (lid, cd, args) -> + Texp_construct (lid, cd, List.map (sub.expr sub) args) + | Texp_variant (l, expo) -> + Texp_variant (l, opt (sub.expr sub) expo) + | Texp_record { fields; representation; extended_expression } -> + let fields = Array.map (function + | label, Kept t -> label, Kept t + | label, Overridden (lid, exp) -> + label, Overridden (lid, sub.expr sub exp)) + fields + in + Texp_record { + fields; representation; + extended_expression = opt (sub.expr sub) extended_expression; + } + | Texp_field (exp, lid, ld) -> + Texp_field (sub.expr sub exp, lid, ld) + | Texp_setfield (exp1, lid, ld, exp2) -> + Texp_setfield ( + sub.expr sub exp1, + lid, + ld, + sub.expr sub exp2 + ) + | Texp_array list -> + Texp_array (List.map (sub.expr sub) list) + | Texp_ifthenelse (exp1, exp2, expo) -> + Texp_ifthenelse ( + sub.expr sub exp1, + sub.expr sub exp2, + opt (sub.expr sub) expo + ) + | Texp_sequence (exp1, exp2) -> + Texp_sequence ( + sub.expr sub exp1, + sub.expr sub exp2 + ) + | Texp_while (exp1, exp2) -> + Texp_while ( + sub.expr sub exp1, + sub.expr sub exp2 + ) + | Texp_for (id, p, exp1, exp2, dir, exp3) -> + Texp_for ( + id, + p, + sub.expr sub exp1, + sub.expr sub exp2, + dir, + sub.expr sub exp3 + ) + | Texp_send (exp, meth, expo) -> + Texp_send + ( + sub.expr sub exp, + meth, + opt (sub.expr sub) expo + ) + | Texp_new _ + | Texp_instvar _ as d -> d + | Texp_setinstvar (path1, path2, id, exp) -> + Texp_setinstvar ( + path1, + path2, + id, + sub.expr sub exp + ) + | Texp_override (path, list) -> + Texp_override ( + path, + List.map (tuple3 id id (sub.expr sub)) list + ) + | Texp_letmodule (id, s, mexpr, exp) -> + Texp_letmodule ( + id, + s, + sub.module_expr sub mexpr, + sub.expr sub exp + ) + | Texp_letexception (cd, exp) -> + Texp_letexception ( + sub.extension_constructor sub cd, + sub.expr sub exp + ) + | Texp_assert exp -> + Texp_assert (sub.expr sub exp) + | Texp_lazy exp -> + Texp_lazy (sub.expr sub exp) + | Texp_object (cl, sl) -> + Texp_object (sub.class_structure sub cl, sl) + | Texp_pack mexpr -> + Texp_pack (sub.module_expr sub mexpr) + | Texp_unreachable -> + Texp_unreachable + | Texp_extension_constructor _ as e -> + e in - iter - -let mcomp env t1 t2 = - mcomp (TypePairs.create 4) env t1 t2 - -(* Real unification *) - -let find_lowest_level ty = - let lowest = ref generic_level in - let rec find ty = - let ty = repr ty in - if ty.level >= lowest_level then begin - if ty.level < !lowest then lowest := ty.level; - ty.level <- pivot_level - ty.level; - iter_type_expr find ty - end - in find ty; unmark_type ty; !lowest - -let find_newtype_level env path = - try match (Env.find_type path env).type_newtype_level with - Some x -> x - | None -> raise Not_found - with Not_found -> let lev = Path.binding_time path in (lev, lev) - -let add_gadt_equation env source destination = - if local_non_recursive_abbrev !env source destination then begin - let destination = duplicate_type destination in - let source_lev = find_newtype_level !env source in - let decl = new_declaration (Some source_lev) (Some destination) in - let newtype_level = get_newtype_level () in - env := Env.add_local_constraint source decl newtype_level !env; - cleanup_abbrev () - end - -let unify_eq_set = TypePairs.create 11 - -let order_type_pair t1 t2 = - if t1.id <= t2.id then (t1, t2) else (t2, t1) - -let add_type_equality t1 t2 = - TypePairs.add unify_eq_set (order_type_pair t1 t2) () - -let eq_package_path env p1 p2 = - Path.same p1 p2 || - Path.same (normalize_package_path env p1) (normalize_package_path env p2) + {x with exp_extra; exp_desc; exp_env} -let nondep_type' = ref (fun _ _ _ -> assert false) -let package_subtype = ref (fun _ _ _ _ _ _ _ -> assert false) -let rec concat_longident lid1 = - let open Longident in - function - Lident s -> Ldot (lid1, s) - | Ldot (lid2, s) -> Ldot (concat_longident lid1 lid2, s) - | Lapply (lid2, lid) -> Lapply (concat_longident lid1 lid2, lid) +let package_type sub x = + let pack_fields = List.map (tuple2 id (sub.typ sub)) x.pack_fields in + {x with pack_fields} -let nondep_instance env level id ty = - let ty = !nondep_type' env id ty in - if level = generic_level then duplicate_type ty else - let old = !current_level in - current_level := level; - let ty = instance env ty in - current_level := old; - ty +let signature sub x = + let sig_final_env = sub.env sub x.sig_final_env in + let sig_items = List.map (sub.signature_item sub) x.sig_items in + {x with sig_items; sig_final_env} -(* Find the type paths nl1 in the module type mty2, and add them to the - list (nl2, tl2). raise Not_found if impossible *) -let complete_type_list ?(allow_absent=false) env nl1 lv2 mty2 nl2 tl2 = - let id2 = Ident.create "Pkg" in - let env' = Env.add_module id2 mty2 env in - let rec complete nl1 ntl2 = - match nl1, ntl2 with - [], _ -> ntl2 - | n :: nl, (n2, _ as nt2) :: ntl' when n >= n2 -> - nt2 :: complete (if n = n2 then nl else nl1) ntl' - | n :: nl, _ -> - try - let path = - Env.lookup_type (concat_longident (Longident.Lident "Pkg") n) env' - in - match Env.find_type path env' with - {type_arity = 0; type_kind = Type_abstract; - type_private = Public; type_manifest = Some t2} -> - (n, nondep_instance env' lv2 id2 t2) :: complete nl ntl2 - | {type_arity = 0; type_kind = Type_abstract; - type_private = Public; type_manifest = None} when allow_absent -> - complete nl ntl2 - | _ -> raise Exit - with - | Not_found when allow_absent -> complete nl ntl2 - | Exit -> raise Not_found +let signature_item sub x = + let sig_env = sub.env sub x.sig_env in + let sig_desc = + match x.sig_desc with + | Tsig_value v -> + Tsig_value (sub.value_description sub v) + | Tsig_type (rec_flag, list) -> + let (rec_flag, list) = sub.type_declarations sub (rec_flag, list) in + Tsig_type (rec_flag, list) + | Tsig_typext te -> + Tsig_typext (sub.type_extension sub te) + | Tsig_exception ext -> + Tsig_exception (sub.extension_constructor sub ext) + | Tsig_module x -> + Tsig_module (sub.module_declaration sub x) + | Tsig_recmodule list -> + Tsig_recmodule (List.map (sub.module_declaration sub) list) + | Tsig_modtype x -> + Tsig_modtype (sub.module_type_declaration sub x) + | Tsig_include incl -> + Tsig_include (include_infos (sub.module_type sub) incl) + | Tsig_class list -> + Tsig_class (List.map (sub.class_description sub) list) + | Tsig_class_type list -> + Tsig_class_type + (List.map (sub.class_type_declaration sub) list) + | Tsig_open _ + | Tsig_attribute _ as d -> d in - complete nl1 (List.combine nl2 tl2) - -(* raise Not_found rather than Unify if the module types are incompatible *) -let unify_package env unify_list lv1 p1 n1 tl1 lv2 p2 n2 tl2 = - let ntl2 = complete_type_list env n1 lv2 (Mty_ident p2) n2 tl2 - and ntl1 = complete_type_list env n2 lv1 (Mty_ident p1) n1 tl1 in - unify_list (List.map snd ntl1) (List.map snd ntl2); - if eq_package_path env p1 p2 - || !package_subtype env p1 n1 tl1 p2 n2 tl2 - && !package_subtype env p2 n2 tl2 p1 n1 tl1 then () else raise Not_found - - -(* force unification in Reither when one side has a non-conjunctive type *) -let rigid_variants = ref false - -(* drop not force unification in Reither, even in fixed case - (not sound, only use it when checking exhaustiveness) *) -let passive_variants = ref false -let with_passive_variants f x = - if !passive_variants then f x else - match passive_variants := true; f x with - | r -> passive_variants := false; r - | exception e -> passive_variants := false; raise e - -let unify_eq t1 t2 = - t1 == t2 || - match !umode with - | Expression -> false - | Pattern -> - try TypePairs.find unify_eq_set (order_type_pair t1 t2); true - with Not_found -> false + {x with sig_desc; sig_env} -let unify1_var env t1 t2 = - assert (is_Tvar t1); - occur env t1 t2; - occur_univar env t2; - let d1 = t1.desc in - link_type t1 t2; - try - update_level env t1.level t2 - with Unify _ as e -> - t1.desc <- d1; - raise e +let class_description sub x = + class_infos sub (sub.class_type sub) x -let rec unify (env:Env.t ref) t1 t2 = - (* First step: special cases (optimizations) *) - if t1 == t2 then () else - let t1 = repr t1 in - let t2 = repr t2 in - if unify_eq t1 t2 then () else - let reset_tracing = check_trace_gadt_instances !env in +let module_type sub x = + let mty_env = sub.env sub x.mty_env in + let mty_desc = + match x.mty_desc with + | Tmty_ident _ + | Tmty_alias _ as d -> d + | Tmty_signature sg -> Tmty_signature (sub.signature sub sg) + | Tmty_functor (id, s, mtype1, mtype2) -> + Tmty_functor ( + id, + s, + opt (sub.module_type sub) mtype1, + sub.module_type sub mtype2 + ) + | Tmty_with (mtype, list) -> + Tmty_with ( + sub.module_type sub mtype, + List.map (tuple3 id id (sub.with_constraint sub)) list + ) + | Tmty_typeof mexpr -> + Tmty_typeof (sub.module_expr sub mexpr) + in + {x with mty_desc; mty_env} - try - type_changed := true; - begin match (t1.desc, t2.desc) with - (Tvar _, Tconstr _) when deep_occur t1 t2 -> - unify2 env t1 t2 - | (Tconstr _, Tvar _) when deep_occur t2 t1 -> - unify2 env t1 t2 - | (Tvar _, _) -> - unify1_var !env t1 t2 - | (_, Tvar _) -> - unify1_var !env t2 t1 - | (Tunivar _, Tunivar _) -> - unify_univar t1 t2 !univar_pairs; - update_level !env t1.level t2; - link_type t1 t2 - | (Tconstr (p1, [], a1), Tconstr (p2, [], a2)) - when Path.same p1 p2 (* && actual_mode !env = Old *) - (* This optimization assumes that t1 does not expand to t2 - (and conversely), so we fall back to the general case - when any of the types has a cached expansion. *) - && not (has_cached_expansion p1 !a1 - || has_cached_expansion p2 !a2) -> - update_level !env t1.level t2; - link_type t1 t2 - | (Tconstr (p1, [], _), Tconstr (p2, [], _)) - when Env.has_local_constraints !env - && is_newtype !env p1 && is_newtype !env p2 -> - (* Do not use local constraints more than necessary *) - begin try - if find_newtype_level !env p1 < find_newtype_level !env p2 then - unify env t1 (try_expand_once !env t2) - else - unify env (try_expand_once !env t1) t2 - with Cannot_expand -> - unify2 env t1 t2 - end - | _ -> - unify2 env t1 t2 - end; - reset_trace_gadt_instances reset_tracing; - with Unify trace -> - reset_trace_gadt_instances reset_tracing; - raise (Unify ((t1, t2)::trace)) +let with_constraint sub = function + | Twith_type decl -> Twith_type (sub.type_declaration sub decl) + | Twith_typesubst decl -> Twith_typesubst (sub.type_declaration sub decl) + | Twith_module _ + | Twith_modsubst _ as d -> d -and unify2 env t1 t2 = - (* Second step: expansion of abbreviations *) - (* Expansion may change the representative of the types. *) - ignore (expand_head_unif !env t1); - ignore (expand_head_unif !env t2); - let t1' = expand_head_unif !env t1 in - let t2' = expand_head_unif !env t2 in - let lv = min t1'.level t2'.level in - update_level !env lv t2; - update_level !env lv t1; - if unify_eq t1' t2' then () else +let module_coercion sub = function + | Tcoerce_none -> Tcoerce_none + | Tcoerce_functor (c1,c2) -> + Tcoerce_functor (sub.module_coercion sub c1, sub.module_coercion sub c2) + | Tcoerce_alias (p, c1) -> + Tcoerce_alias (p, sub.module_coercion sub c1) + | Tcoerce_structure (l1, l2, runtime_fields) -> + let l1' = List.map (fun (i,c) -> i, sub.module_coercion sub c) l1 in + let l2' = + List.map (fun (id,i,c) -> id, i, sub.module_coercion sub c) l2 + in + Tcoerce_structure (l1', l2', runtime_fields) + | Tcoerce_primitive pc -> + Tcoerce_primitive {pc with pc_env = sub.env sub pc.pc_env} - let t1 = repr t1 and t2 = repr t2 in - if !trace_gadt_instances then begin - (* All types in chains already have the same ambiguity levels *) - let ilevel t = - match Env.gadt_instance_level !env t with None -> 0 | Some lv -> lv in - let lv1 = ilevel t1 and lv2 = ilevel t2 in - if lv1 > lv2 then Env.add_gadt_instance_chain !env lv1 t2 else - if lv2 > lv1 then Env.add_gadt_instance_chain !env lv2 t1 - end; - let t1, t2 = - if !Clflags.principal - && (find_lowest_level t1' < lv || find_lowest_level t2' < lv) then - (* Expand abbreviations hiding a lower level *) - (* Should also do it for parameterized types, after unification... *) - (match t1.desc with Tconstr (_, [], _) -> t1' | _ -> t1), - (match t2.desc with Tconstr (_, [], _) -> t2' | _ -> t2) - else (t1, t2) +let module_expr sub x = + let mod_env = sub.env sub x.mod_env in + let mod_desc = + match x.mod_desc with + | Tmod_ident _ as d -> d + | Tmod_structure st -> Tmod_structure (sub.structure sub st) + | Tmod_functor (id, s, mtype, mexpr) -> + Tmod_functor ( + id, + s, + opt (sub.module_type sub) mtype, + sub.module_expr sub mexpr + ) + | Tmod_apply (mexp1, mexp2, c) -> + Tmod_apply ( + sub.module_expr sub mexp1, + sub.module_expr sub mexp2, + sub.module_coercion sub c + ) + | Tmod_constraint (mexpr, mt, Tmodtype_implicit, c) -> + Tmod_constraint (sub.module_expr sub mexpr, mt, Tmodtype_implicit, + sub.module_coercion sub c) + | Tmod_constraint (mexpr, mt, Tmodtype_explicit mtype, c) -> + Tmod_constraint ( + sub.module_expr sub mexpr, + mt, + Tmodtype_explicit (sub.module_type sub mtype), + sub.module_coercion sub c + ) + | Tmod_unpack (exp, mty) -> + Tmod_unpack + ( + sub.expr sub exp, + mty + ) in - if unify_eq t1 t1' || not (unify_eq t2 t2') then - unify3 env t1 t1' t2 t2' - else - try unify3 env t2 t2' t1 t1' with Unify trace -> - raise (Unify (List.map (fun (x, y) -> (y, x)) trace)) + {x with mod_desc; mod_env} -and unify3 env t1 t1' t2 t2' = - (* Third step: truly unification *) - (* Assumes either [t1 == t1'] or [t2 != t2'] *) - let d1 = t1'.desc and d2 = t2'.desc in - let create_recursion = (t2 != t2') && (deep_occur t1' t2) in +let module_binding sub x = + let mb_expr = sub.module_expr sub x.mb_expr in + {x with mb_expr} - begin match (d1, d2) with (* handle vars and univars specially *) - (Tunivar _, Tunivar _) -> - unify_univar t1' t2' !univar_pairs; - link_type t1' t2' - | (Tvar _, _) -> - occur !env t1' t2; - occur_univar !env t2; - link_type t1' t2; - | (_, Tvar _) -> - occur !env t2' t1; - occur_univar !env t1; - link_type t2' t1; - | (Tfield _, Tfield _) -> (* special case for GADTs *) - unify_fields env t1' t2' - | _ -> - begin match !umode with - | Expression -> - occur !env t1' t2'; - link_type t1' t2 - | Pattern -> - add_type_equality t1' t2' - end; - try - begin match (d1, d2) with - (Tarrow (l1, t1, u1, c1), Tarrow (l2, t2, u2, c2)) when l1 = l2 || - (!Clflags.classic || !umode = Pattern) && - not (is_optional l1 || is_optional l2) -> - unify env t1 t2; unify env u1 u2; - begin match commu_repr c1, commu_repr c2 with - Clink r, c2 -> set_commu r c2 - | c1, Clink r -> set_commu r c1 - | _ -> () - end - | (Ttuple tl1, Ttuple tl2) -> - unify_list env tl1 tl2 - | (Tconstr (p1, tl1, _), Tconstr (p2, tl2, _)) when Path.same p1 p2 -> - if !umode = Expression || not !generate_equations then - unify_list env tl1 tl2 - else if !assume_injective then - set_mode_pattern ~generate:true ~injective:false - (fun () -> unify_list env tl1 tl2) - else if in_current_module p1 (* || in_pervasives p1 *) - || List.exists (expands_to_datatype !env) [t1'; t1; t2] then - unify_list env tl1 tl2 - else - let inj = - try List.map Variance.(mem Inj) - (Env.find_type p1 !env).type_variance - with Not_found -> List.map (fun _ -> false) tl1 - in - List.iter2 - (fun i (t1, t2) -> - if i then unify env t1 t2 else - set_mode_pattern ~generate:false ~injective:false - begin fun () -> - let snap = snapshot () in - try unify env t1 t2 with Unify _ -> - backtrack snap; - reify env t1; reify env t2 - end) - inj (List.combine tl1 tl2) - | (Tconstr (path,[],_), - Tconstr (path',[],_)) - when is_instantiable !env path && is_instantiable !env path' - && !generate_equations -> - let source, destination = - if find_newtype_level !env path > find_newtype_level !env path' - then path , t2' - else path', t1' - in - add_gadt_equation env source destination - | (Tconstr (path,[],_), _) - when is_instantiable !env path && !generate_equations -> - reify env t2'; - add_gadt_equation env path t2' - | (_, Tconstr (path,[],_)) - when is_instantiable !env path && !generate_equations -> - reify env t1'; - add_gadt_equation env path t1' - | (Tconstr (_,_,_), _) | (_, Tconstr (_,_,_)) when !umode = Pattern -> - reify env t1'; - reify env t2'; - if !generate_equations then mcomp !env t1' t2' - | (Tobject (fi1, nm1), Tobject (fi2, _)) -> - unify_fields env fi1 fi2; - (* Type [t2'] may have been instantiated by [unify_fields] *) - (* XXX One should do some kind of unification... *) - begin match (repr t2').desc with - Tobject (_, {contents = Some (_, va::_)}) when - (match (repr va).desc with - Tvar _|Tunivar _|Tnil -> true | _ -> false) -> () - | Tobject (_, nm2) -> set_name nm2 !nm1 - | _ -> () - end - | (Tvariant row1, Tvariant row2) -> - if !umode = Expression then - unify_row env row1 row2 - else begin - let snap = snapshot () in - try unify_row env row1 row2 - with Unify _ -> - backtrack snap; - reify env t1'; - reify env t2'; - if !generate_equations then mcomp !env t1' t2' - end - | (Tfield(f,kind,_,rem), Tnil) | (Tnil, Tfield(f,kind,_,rem)) -> - begin match field_kind_repr kind with - Fvar r when f <> dummy_method -> - set_kind r Fabsent; - if d2 = Tnil then unify env rem t2' - else unify env (newty2 rem.level Tnil) rem - | _ -> raise (Unify []) - end - | (Tnil, Tnil) -> - () - | (Tpoly (t1, []), Tpoly (t2, [])) -> - unify env t1 t2 - | (Tpoly (t1, tl1), Tpoly (t2, tl2)) -> - enter_poly !env univar_pairs t1 tl1 t2 tl2 (unify env) - | (Tpackage (p1, n1, tl1), Tpackage (p2, n2, tl2)) -> - begin try - unify_package !env (unify_list env) - t1.level p1 n1 tl1 t2.level p2 n2 tl2 - with Not_found -> - if !umode = Expression then raise (Unify []); - List.iter (reify env) (tl1 @ tl2); - (* if !generate_equations then List.iter2 (mcomp !env) tl1 tl2 *) - end - | (_, _) -> - raise (Unify []) - end; - (* XXX Commentaires + changer "create_recursion" - ||| Comments + change "create_recursion" *) - if create_recursion then - match t2.desc with - Tconstr (p, tl, abbrev) -> - forget_abbrev abbrev p; - let t2'' = expand_head_unif !env t2 in - if not (closed_parameterized_type tl t2'') then - link_type (repr t2) (repr t2') - | _ -> - () (* t2 has already been expanded by update_level *) - with Unify trace -> - t1'.desc <- d1; - raise (Unify trace) - end +let class_expr sub x = + let cl_env = sub.env sub x.cl_env in + let cl_desc = + match x.cl_desc with + | Tcl_constraint (cl, clty, vals, meths, concrs) -> + Tcl_constraint ( + sub.class_expr sub cl, + opt (sub.class_type sub) clty, + vals, + meths, + concrs + ) + | Tcl_structure clstr -> + Tcl_structure (sub.class_structure sub clstr) + | Tcl_fun (label, pat, priv, cl, partial) -> + Tcl_fun ( + label, + sub.pat sub pat, + List.map (tuple3 id id (sub.expr sub)) priv, + sub.class_expr sub cl, + partial + ) + | Tcl_apply (cl, args) -> + Tcl_apply ( + sub.class_expr sub cl, + List.map (tuple2 id (opt (sub.expr sub))) args + ) + | Tcl_let (rec_flag, value_bindings, ivars, cl) -> + let (rec_flag, value_bindings) = + sub.value_bindings sub (rec_flag, value_bindings) + in + Tcl_let ( + rec_flag, + value_bindings, + List.map (tuple3 id id (sub.expr sub)) ivars, + sub.class_expr sub cl + ) + | Tcl_ident (path, lid, tyl) -> + Tcl_ident (path, lid, List.map (sub.typ sub) tyl) + | Tcl_open (ovf, p, lid, env, e) -> + Tcl_open (ovf, p, lid, sub.env sub env, sub.class_expr sub e) + in + {x with cl_desc; cl_env} -and unify_list env tl1 tl2 = - if List.length tl1 <> List.length tl2 then - raise (Unify []); - List.iter2 (unify env) tl1 tl2 +let class_type sub x = + let cltyp_env = sub.env sub x.cltyp_env in + let cltyp_desc = + match x.cltyp_desc with + | Tcty_signature csg -> Tcty_signature (sub.class_signature sub csg) + | Tcty_constr (path, lid, list) -> + Tcty_constr ( + path, + lid, + List.map (sub.typ sub) list + ) + | Tcty_arrow (label, ct, cl) -> + Tcty_arrow + (label, + sub.typ sub ct, + sub.class_type sub cl + ) + | Tcty_open (ovf, p, lid, env, e) -> + Tcty_open (ovf, p, lid, sub.env sub env, sub.class_type sub e) + in + {x with cltyp_desc; cltyp_env} -(* Build a fresh row variable for unification *) -and make_rowvar level use1 rest1 use2 rest2 = - let set_name ty name = - match ty.desc with - Tvar None -> log_type ty; ty.desc <- Tvar name - | _ -> () +let class_signature sub x = + let csig_self = sub.typ sub x.csig_self in + let csig_fields = List.map (sub.class_type_field sub) x.csig_fields in + {x with csig_self; csig_fields} + +let class_type_field sub x = + let ctf_desc = + match x.ctf_desc with + | Tctf_inherit ct -> + Tctf_inherit (sub.class_type sub ct) + | Tctf_val (s, mut, virt, ct) -> + Tctf_val (s, mut, virt, sub.typ sub ct) + | Tctf_method (s, priv, virt, ct) -> + Tctf_method (s, priv, virt, sub.typ sub ct) + | Tctf_constraint (ct1, ct2) -> + Tctf_constraint (sub.typ sub ct1, sub.typ sub ct2) + | Tctf_attribute _ as d -> d in - let name = - match rest1.desc, rest2.desc with - Tvar (Some _ as name1), Tvar (Some _ as name2) -> - if rest1.level <= rest2.level then name1 else name2 - | Tvar (Some _ as name), _ -> - if use2 then set_name rest2 name; name - | _, Tvar (Some _ as name) -> - if use1 then set_name rest2 name; name - | _ -> None + {x with ctf_desc} + +let typ sub x = + let ctyp_env = sub.env sub x.ctyp_env in + let ctyp_desc = + match x.ctyp_desc with + | Ttyp_any + | Ttyp_var _ as d -> d + | Ttyp_arrow (label, ct1, ct2) -> + Ttyp_arrow (label, sub.typ sub ct1, sub.typ sub ct2) + | Ttyp_tuple list -> Ttyp_tuple (List.map (sub.typ sub) list) + | Ttyp_constr (path, lid, list) -> + Ttyp_constr (path, lid, List.map (sub.typ sub) list) + | Ttyp_object (list, closed) -> + Ttyp_object ((List.map (sub.object_field sub) list), closed) + | Ttyp_class (path, lid, list) -> + Ttyp_class + (path, + lid, + List.map (sub.typ sub) list + ) + | Ttyp_alias (ct, s) -> + Ttyp_alias (sub.typ sub ct, s) + | Ttyp_variant (list, closed, labels) -> + Ttyp_variant (List.map (sub.row_field sub) list, closed, labels) + | Ttyp_poly (sl, ct) -> + Ttyp_poly (sl, sub.typ sub ct) + | Ttyp_package pack -> + Ttyp_package (sub.package_type sub pack) in - if use1 then rest1 else - if use2 then rest2 else newvar2 ?name level + {x with ctyp_desc; ctyp_env} -and unify_fields env ty1 ty2 = (* Optimization *) - let (fields1, rest1) = flatten_fields ty1 - and (fields2, rest2) = flatten_fields ty2 in - let (pairs, miss1, miss2) = associate_fields fields1 fields2 in - let l1 = (repr ty1).level and l2 = (repr ty2).level in - let va = make_rowvar (min l1 l2) (miss2=[]) rest1 (miss1=[]) rest2 in - let d1 = rest1.desc and d2 = rest2.desc in - try - unify env (build_fields l1 miss1 va) rest2; - unify env rest1 (build_fields l2 miss2 va); - List.iter - (fun (n, k1, t1, k2, t2) -> - unify_kind k1 k2; - try - if !trace_gadt_instances then update_level !env va.level t1; - unify env t1 t2 - with Unify trace -> - raise (Unify ((newty (Tfield(n, k1, t1, newty Tnil)), - newty (Tfield(n, k2, t2, newty Tnil)))::trace))) - pairs - with exn -> - log_type rest1; rest1.desc <- d1; - log_type rest2; rest2.desc <- d2; - raise exn +let class_structure sub x = + let cstr_self = sub.pat sub x.cstr_self in + let cstr_fields = List.map (sub.class_field sub) x.cstr_fields in + {x with cstr_self; cstr_fields} -and unify_kind k1 k2 = - let k1 = field_kind_repr k1 in - let k2 = field_kind_repr k2 in - if k1 == k2 then () else - match k1, k2 with - (Fvar r, (Fvar _ | Fpresent)) -> set_kind r k2 - | (Fpresent, Fvar r) -> set_kind r k1 - | (Fpresent, Fpresent) -> () - | _ -> assert false +let row_field sub = function + | Ttag (label, attrs, b, list) -> + Ttag (label, attrs, b, List.map (sub.typ sub) list) + | Tinherit ct -> Tinherit (sub.typ sub ct) -and unify_row env row1 row2 = - let row1 = row_repr row1 and row2 = row_repr row2 in - let rm1 = row_more row1 and rm2 = row_more row2 in - if unify_eq rm1 rm2 then () else - let r1, r2, pairs = merge_row_fields row1.row_fields row2.row_fields in - if r1 <> [] && r2 <> [] then begin - let ht = Hashtbl.create (List.length r1) in - List.iter (fun (l,_) -> Hashtbl.add ht (hash_variant l) l) r1; - List.iter - (fun (l,_) -> - try raise (Tags(l, Hashtbl.find ht (hash_variant l))) - with Not_found -> ()) - r2 - end; - let fixed1 = row_fixed row1 and fixed2 = row_fixed row2 in - let more = - if fixed1 then rm1 else - if fixed2 then rm2 else - newty2 (min rm1.level rm2.level) (Tvar None) in - let fixed = fixed1 || fixed2 - and closed = row1.row_closed || row2.row_closed in - let keep switch = - List.for_all - (fun (_,f1,f2) -> - let f1, f2 = switch f1 f2 in - row_field_repr f1 = Rabsent || row_field_repr f2 <> Rabsent) - pairs - in - let empty fields = - List.for_all (fun (_,f) -> row_field_repr f = Rabsent) fields in - (* Check whether we are going to build an empty type *) - if closed && (empty r1 || row2.row_closed) && (empty r2 || row1.row_closed) - && List.for_all - (fun (_,f1,f2) -> - row_field_repr f1 = Rabsent || row_field_repr f2 = Rabsent) - pairs - then raise (Unify [mkvariant [] true, mkvariant [] true]); - let name = - if row1.row_name <> None && (row1.row_closed || empty r2) && - (not row2.row_closed || keep (fun f1 f2 -> f1, f2) && empty r1) - then row1.row_name - else if row2.row_name <> None && (row2.row_closed || empty r1) && - (not row1.row_closed || keep (fun f1 f2 -> f2, f1) && empty r2) - then row2.row_name - else None - in - let row0 = {row_fields = []; row_more = more; row_bound = (); - row_closed = closed; row_fixed = fixed; row_name = name} in - let set_more row rest = - let rest = - if closed then - filter_row_fields row.row_closed rest - else rest in - if rest <> [] && (row.row_closed || row_fixed row) - || closed && row_fixed row && not row.row_closed then begin - let t1 = mkvariant [] true and t2 = mkvariant rest false in - raise (Unify [if row == row1 then (t1,t2) else (t2,t1)]) - end; - (* The following test is not principal... should rather use Tnil *) - let rm = row_more row in - (*if !trace_gadt_instances && rm.desc = Tnil then () else*) - if !trace_gadt_instances then - update_level !env rm.level (newgenty (Tvariant row)); - if row_fixed row then - if more == rm then () else - if is_Tvar rm then link_type rm more else unify env rm more - else - let ty = newgenty (Tvariant {row0 with row_fields = rest}) in - update_level !env rm.level ty; - link_type rm ty +let object_field sub = function + | OTtag (label, attrs, ct) -> + OTtag (label, attrs, (sub.typ sub ct)) + | OTinherit ct -> OTinherit (sub.typ sub ct) + +let class_field_kind sub = function + | Tcfk_virtual ct -> Tcfk_virtual (sub.typ sub ct) + | Tcfk_concrete (ovf, e) -> Tcfk_concrete (ovf, sub.expr sub e) + +let class_field sub x = + let cf_desc = + match x.cf_desc with + | Tcf_inherit (ovf, cl, super, vals, meths) -> + Tcf_inherit (ovf, sub.class_expr sub cl, super, vals, meths) + | Tcf_constraint (cty, cty') -> + Tcf_constraint ( + sub.typ sub cty, + sub.typ sub cty' + ) + | Tcf_val (s, mf, id, k, b) -> + Tcf_val (s, mf, id, class_field_kind sub k, b) + | Tcf_method (s, priv, k) -> + Tcf_method (s, priv, class_field_kind sub k) + | Tcf_initializer exp -> + Tcf_initializer (sub.expr sub exp) + | Tcf_attribute _ as d -> d in - let md1 = rm1.desc and md2 = rm2.desc in - begin try - set_more row2 r1; - set_more row1 r2; - List.iter - (fun (l,f1,f2) -> - try unify_row_field env fixed1 fixed2 more l f1 f2 - with Unify trace -> - raise (Unify ((mkvariant [l,f1] true, - mkvariant [l,f2] true) :: trace))) - pairs; - if static_row row1 then begin - let rm = row_more row1 in - if is_Tvar rm then link_type rm (newty2 rm.level Tnil) - end - with exn -> - log_type rm1; rm1.desc <- md1; log_type rm2; rm2.desc <- md2; raise exn - end + {x with cf_desc} -and unify_row_field env fixed1 fixed2 more l f1 f2 = - let f1 = row_field_repr f1 and f2 = row_field_repr f2 in - if f1 == f2 then () else - match f1, f2 with - Rpresent(Some t1), Rpresent(Some t2) -> unify env t1 t2 - | Rpresent None, Rpresent None -> () - | Reither(c1, tl1, m1, e1), Reither(c2, tl2, m2, e2) -> - if e1 == e2 then () else - if (fixed1 || fixed2) && not (c1 || c2) - && List.length tl1 = List.length tl2 then begin - (* PR#7496 *) - let f = Reither (c1 || c2, [], m1 || m2, ref None) in - set_row_field e1 f; set_row_field e2 f; - List.iter2 (unify env) tl1 tl2 - end - else let redo = - not !passive_variants && - (m1 || m2 || fixed1 || fixed2 || - !rigid_variants && (List.length tl1 = 1 || List.length tl2 = 1)) && - begin match tl1 @ tl2 with [] -> false - | t1 :: tl -> - if c1 || c2 then raise (Unify []); - List.iter (unify env t1) tl; - !e1 <> None || !e2 <> None - end in - if redo then unify_row_field env fixed1 fixed2 more l f1 f2 else - let tl1 = List.map repr tl1 and tl2 = List.map repr tl2 in - let rec remq tl = function [] -> [] - | ty :: tl' -> - if List.memq ty tl then remq tl tl' else ty :: remq tl tl' - in - let tl2' = remq tl2 tl1 and tl1' = remq tl1 tl2 in - (* PR#6744 *) - let split_univars = - List.partition - (fun ty -> try occur_univar !env ty; true with Unify _ -> false) in - let (tl1',tlu1) = split_univars tl1' - and (tl2',tlu2) = split_univars tl2' in - begin match tlu1, tlu2 with - [], [] -> () - | (tu1::tlu1), _ :: _ -> - (* Attempt to merge all the types containing univars *) - if not !passive_variants then - List.iter (unify env tu1) (tlu1@tlu2) - | (tu::_, []) | ([], tu::_) -> occur_univar !env tu - end; - (* Is this handling of levels really principal? *) - List.iter (update_level !env (repr more).level) (tl1' @ tl2'); - let e = ref None in - let f1' = Reither(c1 || c2, tl1', m1 || m2, e) - and f2' = Reither(c1 || c2, tl2', m1 || m2, e) in - set_row_field e1 f1'; set_row_field e2 f2'; - | Reither(_, _, false, e1), Rabsent when not fixed1 -> set_row_field e1 f2 - | Rabsent, Reither(_, _, false, e2) when not fixed2 -> set_row_field e2 f1 - | Rabsent, Rabsent -> () - | Reither(false, tl, _, e1), Rpresent(Some t2) when not fixed1 -> - set_row_field e1 f2; - update_level !env (repr more).level t2; - (try List.iter (fun t1 -> unify env t1 t2) tl - with exn -> e1 := None; raise exn) - | Rpresent(Some t1), Reither(false, tl, _, e2) when not fixed2 -> - set_row_field e2 f1; - update_level !env (repr more).level t1; - (try List.iter (unify env t1) tl - with exn -> e2 := None; raise exn) - | Reither(true, [], _, e1), Rpresent None when not fixed1 -> - set_row_field e1 f2 - | Rpresent None, Reither(true, [], _, e2) when not fixed2 -> - set_row_field e2 f1 - | _ -> raise (Unify []) +let value_bindings sub (rec_flag, list) = + (rec_flag, List.map (sub.value_binding sub) list) +let cases sub l = + List.map (sub.case sub) l -let unify env ty1 ty2 = - let snap = Btype.snapshot () in - try - unify env ty1 ty2 - with - Unify trace -> - undo_compress snap; - raise (Unify (expand_trace !env trace)) - | Recursive_abbrev -> - undo_compress snap; - raise (Unification_recursive_abbrev (expand_trace !env [(ty1,ty2)])) +let case sub {c_lhs; c_guard; c_rhs} = + { + c_lhs = sub.pat sub c_lhs; + c_guard = opt (sub.expr sub) c_guard; + c_rhs = sub.expr sub c_rhs; + } -let unify_gadt ~newtype_level:lev (env:Env.t ref) ty1 ty2 = - try - univar_pairs := []; - newtype_level := Some lev; - set_mode_pattern ~generate:true ~injective:true - (fun () -> unify env ty1 ty2); - newtype_level := None; - TypePairs.clear unify_eq_set; - with e -> - newtype_level := None; - TypePairs.clear unify_eq_set; - raise e +let value_binding sub x = + let vb_pat = sub.pat sub x.vb_pat in + let vb_expr = sub.expr sub x.vb_expr in + {x with vb_pat; vb_expr} -let unify_var env t1 t2 = - let t1 = repr t1 and t2 = repr t2 in - if t1 == t2 then () else - match t1.desc, t2.desc with - Tvar _, Tconstr _ when deep_occur t1 t2 -> - unify (ref env) t1 t2 - | Tvar _, _ -> - let reset_tracing = check_trace_gadt_instances env in - begin try - occur env t1 t2; - update_level env t1.level t2; - link_type t1 t2; - reset_trace_gadt_instances reset_tracing; - with Unify trace -> - reset_trace_gadt_instances reset_tracing; - let expanded_trace = expand_trace env ((t1,t2)::trace) in - raise (Unify expanded_trace) - end - | _ -> - unify (ref env) t1 t2 +let env _sub x = x + +let default = + { + case; + cases; + class_declaration; + class_description; + class_expr; + class_field; + class_signature; + class_structure; + class_type; + class_type_declaration; + class_type_field; + env; + expr; + extension_constructor; + module_binding; + module_coercion; + module_declaration; + module_expr; + module_type; + module_type_declaration; + package_type; + pat; + row_field; + object_field; + signature; + signature_item; + structure; + structure_item; + typ; + type_declaration; + type_declarations; + type_extension; + type_kind; + value_binding; + value_bindings; + value_description; + with_constraint; + } + +end +module Cmt_format : sig +#1 "cmt_format.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Fabrice Le Fessant, INRIA Saclay *) +(* *) +(* Copyright 2012 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) + +(** cmt and cmti files format. *) + +(** The layout of a cmt file is as follows: + := \{\} \{cmt infos\} \{\} + where is the cmi file format: + := . + More precisely, the optional part must be present if and only if + the file is: + - a cmti, or + - a cmt, for a ml file which has no corresponding mli (hence no + corresponding cmti). + + Thus, we provide a common reading function for cmi and cmt(i) + files which returns an option for each of the three parts: cmi + info, cmt info, source info. *) + +open Typedtree + +type binary_annots = + | Packed of Types.signature * string list + | Implementation of structure + | Interface of signature + | Partial_implementation of binary_part array + | Partial_interface of binary_part array + +and binary_part = + | Partial_structure of structure + | Partial_structure_item of structure_item + | Partial_expression of expression + | Partial_pattern of pattern + | Partial_class_expr of class_expr + | Partial_signature of signature + | Partial_signature_item of signature_item + | Partial_module_type of module_type + +type cmt_infos = { + cmt_modname : string; + cmt_annots : binary_annots; + cmt_value_dependencies : + (Types.value_description * Types.value_description) list; + cmt_comments : (string * Location.t) list; + cmt_args : string array; + cmt_sourcefile : string option; + cmt_builddir : string; + cmt_loadpath : string list; + cmt_source_digest : string option; + cmt_initial_env : Env.t; + cmt_imports : (string * Digest.t option) list; + cmt_interface_digest : Digest.t option; + cmt_use_summaries : bool; +} + +type error = + Not_a_typedtree of string -let _ = unify' := unify_var +exception Error of error -let unify_pairs env ty1 ty2 pairs = - univar_pairs := pairs; - unify env ty1 ty2 +(** [read filename] opens filename, and extract both the cmi_infos, if + it exists, and the cmt_infos, if it exists. Thus, it can be used + with .cmi, .cmt and .cmti files. -let unify env ty1 ty2 = - unify_pairs (ref env) ty1 ty2 [] + .cmti files always contain a cmi_infos at the beginning. .cmt files + only contain a cmi_infos at the beginning if there is no associated + .cmti file. +*) +val read : string -> Cmi_format.cmi_infos option * cmt_infos option +val read_cmt : string -> cmt_infos +val read_cmi : string -> Cmi_format.cmi_infos +(** [save_cmt filename modname binary_annots sourcefile initial_env cmi] + writes a cmt(i) file. *) +val save_cmt : + string -> (* filename.cmt to generate *) + string -> (* module name *) + binary_annots -> + string option -> (* source file *) + Env.t -> (* initial env *) + Cmi_format.cmi_infos option -> (* if a .cmi was generated *) + unit -(**** Special cases of unification ****) +(* Miscellaneous functions *) + +val read_magic_number : in_channel -> string + +val clear: unit -> unit + +val add_saved_type : binary_part -> unit +val get_saved_types : unit -> binary_part list +val set_saved_types : binary_part list -> unit + +val record_value_dependency: + Types.value_description -> Types.value_description -> unit -let expand_head_trace env t = - let reset_tracing = check_trace_gadt_instances env in - let t = expand_head_unif env t in - reset_trace_gadt_instances reset_tracing; - t (* - Unify [t] and [l:'a -> 'b]. Return ['a] and ['b]. - In label mode, label mismatch is accepted when - (1) the requested label is "" - (2) the original label is not optional + + val is_magic_number : string -> bool + val read : in_channel -> Env.cmi_infos option * t + val write_magic_number : out_channel -> unit + val write : out_channel -> t -> unit + + val find : string list -> string -> string + val read_signature : 'a -> string -> Types.signature * 'b list * 'c list + *) -let filter_arrow env t l = - let t = expand_head_trace env t in - match t.desc with - Tvar _ -> - let lv = t.level in - let t1 = newvar2 lv and t2 = newvar2 lv in - let t' = newty2 lv (Tarrow (l, t1, t2, Cok)) in - link_type t t'; - (t1, t2) - | Tarrow(l', t1, t2, _) - when l = l' || !Clflags.classic && l = Nolabel && not (is_optional l') -> - (t1, t2) - | _ -> - raise (Unify []) +end = struct +#1 "cmt_format.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Fabrice Le Fessant, INRIA Saclay *) +(* *) +(* Copyright 2012 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -(* Used by [filter_method]. *) -let rec filter_method_field env name priv ty = - let ty = expand_head_trace env ty in - match ty.desc with - Tvar _ -> - let level = ty.level in - let ty1 = newvar2 level and ty2 = newvar2 level in - let ty' = newty2 level (Tfield (name, - begin match priv with - Private -> Fvar (ref None) - | Public -> Fpresent - end, - ty1, ty2)) - in - link_type ty ty'; - ty1 - | Tfield(n, kind, ty1, ty2) -> - let kind = field_kind_repr kind in - if (n = name) && (kind <> Fabsent) then begin - if priv = Public then - unify_kind kind Fpresent; - ty1 - end else - filter_method_field env name priv ty2 - | _ -> - raise (Unify []) +open Cmi_format +open Typedtree -(* Unify [ty] and [< name : 'a; .. >]. Return ['a]. *) -let filter_method env name priv ty = - let ty = expand_head_trace env ty in - match ty.desc with - Tvar _ -> - let ty1 = newvar () in - let ty' = newobj ty1 in - update_level env ty.level ty'; - link_type ty ty'; - filter_method_field env name priv ty1 - | Tobject(f, _) -> - filter_method_field env name priv f - | _ -> - raise (Unify []) +(* Note that in Typerex, there is an awful hack to save a cmt file + together with the interface file that was generated by ocaml (this + is because the installed version of ocaml might differ from the one + integrated in Typerex). +*) -let check_filter_method env name priv ty = - ignore(filter_method env name priv ty) -let filter_self_method env lab priv meths ty = - let ty' = filter_method env lab priv ty in - try - Meths.find lab !meths - with Not_found -> - let pair = (Ident.create lab, ty') in - meths := Meths.add lab pair !meths; - pair +let read_magic_number ic = + let len_magic_number = String.length Config.cmt_magic_number in + really_input_string ic len_magic_number - (***********************************) - (* Matching between type schemes *) - (***********************************) +type binary_annots = + | Packed of Types.signature * string list + | Implementation of structure + | Interface of signature + | Partial_implementation of binary_part array + | Partial_interface of binary_part array -(* - Update the level of [ty]. First check that the levels of generic - variables from the subject are not lowered. -*) -let moregen_occur env level ty = - let rec occur ty = - let ty = repr ty in - if ty.level > level then begin - if is_Tvar ty && ty.level >= generic_level - 1 then raise Occur; - ty.level <- pivot_level - ty.level; - match ty.desc with - Tvariant row when static_row row -> - iter_row occur row - | _ -> - iter_type_expr occur ty - end - in - begin try - occur ty; unmark_type ty - with Occur -> - unmark_type ty; raise (Unify []) - end; - (* also check for free univars *) - occur_univar env ty; - update_level env level ty +and binary_part = +| Partial_structure of structure +| Partial_structure_item of structure_item +| Partial_expression of expression +| Partial_pattern of pattern +| Partial_class_expr of class_expr +| Partial_signature of signature +| Partial_signature_item of signature_item +| Partial_module_type of module_type -let may_instantiate inst_nongen t1 = - if inst_nongen then t1.level <> generic_level - 1 - else t1.level = generic_level +type cmt_infos = { + cmt_modname : string; + cmt_annots : binary_annots; + cmt_value_dependencies : + (Types.value_description * Types.value_description) list; + cmt_comments : (string * Location.t) list; + cmt_args : string array; + cmt_sourcefile : string option; + cmt_builddir : string; + cmt_loadpath : string list; + cmt_source_digest : Digest.t option; + cmt_initial_env : Env.t; + cmt_imports : (string * Digest.t option) list; + cmt_interface_digest : Digest.t option; + cmt_use_summaries : bool; +} -let rec moregen inst_nongen type_pairs env t1 t2 = - if t1 == t2 then () else - let t1 = repr t1 in - let t2 = repr t2 in - if t1 == t2 then () else +type error = + Not_a_typedtree of string - try - match (t1.desc, t2.desc) with - (Tvar _, _) when may_instantiate inst_nongen t1 -> - moregen_occur env t1.level t2; - occur env t1 t2; - link_type t1 t2 - | (Tconstr (p1, [], _), Tconstr (p2, [], _)) when Path.same p1 p2 -> - () - | _ -> - let t1' = expand_head env t1 in - let t2' = expand_head env t2 in - (* Expansion may have changed the representative of the types... *) - let t1' = repr t1' and t2' = repr t2' in - if t1' == t2' then () else - begin try - TypePairs.find type_pairs (t1', t2') - with Not_found -> - TypePairs.add type_pairs (t1', t2') (); - match (t1'.desc, t2'.desc) with - (Tvar _, _) when may_instantiate inst_nongen t1' -> - moregen_occur env t1'.level t2; - link_type t1' t2 - | (Tarrow (l1, t1, u1, _), Tarrow (l2, t2, u2, _)) when l1 = l2 - || !Clflags.classic && not (is_optional l1 || is_optional l2) -> - moregen inst_nongen type_pairs env t1 t2; - moregen inst_nongen type_pairs env u1 u2 - | (Ttuple tl1, Ttuple tl2) -> - moregen_list inst_nongen type_pairs env tl1 tl2 - | (Tconstr (p1, tl1, _), Tconstr (p2, tl2, _)) - when Path.same p1 p2 -> - moregen_list inst_nongen type_pairs env tl1 tl2 - | (Tpackage (p1, n1, tl1), Tpackage (p2, n2, tl2)) -> - begin try - unify_package env (moregen_list inst_nongen type_pairs env) - t1'.level p1 n1 tl1 t2'.level p2 n2 tl2 - with Not_found -> raise (Unify []) - end - | (Tvariant row1, Tvariant row2) -> - moregen_row inst_nongen type_pairs env row1 row2 - | (Tobject (fi1, _nm1), Tobject (fi2, _nm2)) -> - moregen_fields inst_nongen type_pairs env fi1 fi2 - | (Tfield _, Tfield _) -> (* Actually unused *) - moregen_fields inst_nongen type_pairs env t1' t2' - | (Tnil, Tnil) -> - () - | (Tpoly (t1, []), Tpoly (t2, [])) -> - moregen inst_nongen type_pairs env t1 t2 - | (Tpoly (t1, tl1), Tpoly (t2, tl2)) -> - enter_poly env univar_pairs t1 tl1 t2 tl2 - (moregen inst_nongen type_pairs env) - | (Tunivar _, Tunivar _) -> - unify_univar t1' t2' !univar_pairs - | (_, _) -> - raise (Unify []) - end - with Unify trace -> - raise (Unify ((t1, t2)::trace)) +let need_to_clear_env = + try ignore (Sys.getenv "OCAML_BINANNOT_WITHENV"); false + with Not_found -> true -and moregen_list inst_nongen type_pairs env tl1 tl2 = - if List.length tl1 <> List.length tl2 then - raise (Unify []); - List.iter2 (moregen inst_nongen type_pairs env) tl1 tl2 +let keep_only_summary = Env.keep_only_summary -and moregen_fields inst_nongen type_pairs env ty1 ty2 = - let (fields1, rest1) = flatten_fields ty1 - and (fields2, rest2) = flatten_fields ty2 in - let (pairs, miss1, miss2) = associate_fields fields1 fields2 in - if miss1 <> [] then raise (Unify []); - moregen inst_nongen type_pairs env rest1 - (build_fields (repr ty2).level miss2 rest2); - List.iter - (fun (n, k1, t1, k2, t2) -> - moregen_kind k1 k2; - try moregen inst_nongen type_pairs env t1 t2 with Unify trace -> - raise (Unify ((newty (Tfield(n, k1, t1, rest2)), - newty (Tfield(n, k2, t2, rest2)))::trace))) - pairs +open Tast_mapper -and moregen_kind k1 k2 = - let k1 = field_kind_repr k1 in - let k2 = field_kind_repr k2 in - if k1 == k2 then () else - match k1, k2 with - (Fvar r, (Fvar _ | Fpresent)) -> set_kind r k2 - | (Fpresent, Fpresent) -> () - | _ -> raise (Unify []) +let cenv = + {Tast_mapper.default with env = fun _sub env -> keep_only_summary env} -and moregen_row inst_nongen type_pairs env row1 row2 = - let row1 = row_repr row1 and row2 = row_repr row2 in - let rm1 = repr row1.row_more and rm2 = repr row2.row_more in - if rm1 == rm2 then () else - let may_inst = - is_Tvar rm1 && may_instantiate inst_nongen rm1 || rm1.desc = Tnil in - let r1, r2, pairs = merge_row_fields row1.row_fields row2.row_fields in - let r1, r2 = - if row2.row_closed then - filter_row_fields may_inst r1, filter_row_fields false r2 - else r1, r2 - in - if r1 <> [] || row1.row_closed && (not row2.row_closed || r2 <> []) - then raise (Unify []); - begin match rm1.desc, rm2.desc with - Tunivar _, Tunivar _ -> - unify_univar rm1 rm2 !univar_pairs - | Tunivar _, _ | _, Tunivar _ -> - raise (Unify []) - | _ when static_row row1 -> () - | _ when may_inst -> - let ext = - newgenty (Tvariant {row2 with row_fields = r2; row_name = None}) - in - moregen_occur env rm1.level ext; - link_type rm1 ext - | Tconstr _, Tconstr _ -> - moregen inst_nongen type_pairs env rm1 rm2 - | _ -> raise (Unify []) - end; - List.iter - (fun (_l,f1,f2) -> - let f1 = row_field_repr f1 and f2 = row_field_repr f2 in - if f1 == f2 then () else - match f1, f2 with - Rpresent(Some t1), Rpresent(Some t2) -> - moregen inst_nongen type_pairs env t1 t2 - | Rpresent None, Rpresent None -> () - | Reither(false, tl1, _, e1), Rpresent(Some t2) when may_inst -> - set_row_field e1 f2; - List.iter (fun t1 -> moregen inst_nongen type_pairs env t1 t2) tl1 - | Reither(c1, tl1, _, e1), Reither(c2, tl2, m2, e2) -> - if e1 != e2 then begin - if c1 && not c2 then raise(Unify []); - set_row_field e1 (Reither (c2, [], m2, e2)); - if List.length tl1 = List.length tl2 then - List.iter2 (moregen inst_nongen type_pairs env) tl1 tl2 - else match tl2 with - t2 :: _ -> - List.iter (fun t1 -> moregen inst_nongen type_pairs env t1 t2) - tl1 - | [] -> - if tl1 <> [] then raise (Unify []) - end - | Reither(true, [], _, e1), Rpresent None when may_inst -> - set_row_field e1 f2 - | Reither(_, _, _, e1), Rabsent when may_inst -> - set_row_field e1 f2 - | Rabsent, Rabsent -> () - | _ -> raise (Unify [])) - pairs +let clear_part = function + | Partial_structure s -> Partial_structure (cenv.structure cenv s) + | Partial_structure_item s -> + Partial_structure_item (cenv.structure_item cenv s) + | Partial_expression e -> Partial_expression (cenv.expr cenv e) + | Partial_pattern p -> Partial_pattern (cenv.pat cenv p) + | Partial_class_expr ce -> Partial_class_expr (cenv.class_expr cenv ce) + | Partial_signature s -> Partial_signature (cenv.signature cenv s) + | Partial_signature_item s -> + Partial_signature_item (cenv.signature_item cenv s) + | Partial_module_type s -> Partial_module_type (cenv.module_type cenv s) -(* Must empty univar_pairs first *) -let moregen inst_nongen type_pairs env patt subj = - univar_pairs := []; - moregen inst_nongen type_pairs env patt subj +let clear_env binary_annots = + if need_to_clear_env then + match binary_annots with + | Implementation s -> Implementation (cenv.structure cenv s) + | Interface s -> Interface (cenv.signature cenv s) + | Packed _ -> binary_annots + | Partial_implementation array -> + Partial_implementation (Array.map clear_part array) + | Partial_interface array -> + Partial_interface (Array.map clear_part array) -(* - Non-generic variable can be instantiated only if [inst_nongen] is - true. So, [inst_nongen] should be set to false if the subject might - contain non-generic variables (and we do not want them to be - instantiated). - Usually, the subject is given by the user, and the pattern - is unimportant. So, no need to propagate abbreviations. -*) -let moregeneral env inst_nongen pat_sch subj_sch = - let old_level = !current_level in - current_level := generic_level - 1; - (* - Generic variables are first duplicated with [instance]. So, - their levels are lowered to [generic_level - 1]. The subject is - then copied with [duplicate_type]. That way, its levels won't be - changed. - *) - let subj = duplicate_type (instance env subj_sch) in - current_level := generic_level; - (* Duplicate generic variables *) - let patt = instance env pat_sch in - let res = - try moregen inst_nongen (TypePairs.create 13) env patt subj; true with - Unify _ -> false - in - current_level := old_level; - res + else binary_annots +exception Error of error -(* Alternative approach: "rigidify" a type scheme, - and check validity after unification *) -(* Simpler, no? *) +let input_cmt ic = (input_value ic : cmt_infos) -let rec rigidify_rec vars ty = - let ty = repr ty in - if ty.level >= lowest_level then begin - ty.level <- pivot_level - ty.level; - match ty.desc with - | Tvar _ -> - if not (List.memq ty !vars) then vars := ty :: !vars - | Tvariant row -> - let row = row_repr row in - let more = repr row.row_more in - if is_Tvar more && not (row_fixed row) then begin - let more' = newty2 more.level more.desc in - let row' = {row with row_fixed=true; row_fields=[]; row_more=more'} - in link_type more (newty2 ty.level (Tvariant row')) - end; - iter_row (rigidify_rec vars) row; - (* only consider the row variable if the variant is not static *) - if not (static_row row) then rigidify_rec vars (row_more row) - | _ -> - iter_type_expr (rigidify_rec vars) ty - end +let output_cmt oc cmt = + output_string oc Config.cmt_magic_number; + output_value oc (cmt : cmt_infos) -let rigidify ty = - let vars = ref [] in - rigidify_rec vars ty; - unmark_type ty; - !vars +let read filename = +(* Printf.fprintf stderr "Cmt_format.read %s\n%!" filename; *) + let ic = open_in_bin filename in + try + let magic_number = read_magic_number ic in + let cmi, cmt = + if magic_number = Config.cmt_magic_number then + None, Some (input_cmt ic) + else if magic_number = Config.cmi_magic_number then + let cmi = Cmi_format.input_cmi ic in + let cmt = try + let magic_number = read_magic_number ic in + if magic_number = Config.cmt_magic_number then + let cmt = input_cmt ic in + Some cmt + else None + with _ -> None + in + Some cmi, cmt + else + raise(Cmi_format.Error(Cmi_format.Not_an_interface filename)) + in + close_in ic; +(* Printf.fprintf stderr "Cmt_format.read done\n%!"; *) + cmi, cmt + with e -> + close_in ic; + raise e -let all_distinct_vars env vars = - let tyl = ref [] in - List.for_all - (fun ty -> - let ty = expand_head env ty in - if List.memq ty !tyl then false else - (tyl := ty :: !tyl; is_Tvar ty)) - vars +let read_cmt filename = + match read filename with + _, None -> raise (Error (Not_a_typedtree filename)) + | _, Some cmt -> cmt -let matches env ty ty' = - let snap = snapshot () in - let vars = rigidify ty in - cleanup_abbrev (); - let ok = - try unify env ty ty'; all_distinct_vars env vars - with Unify _ -> false - in - backtrack snap; - ok +let read_cmi filename = + match read filename with + None, _ -> + raise (Cmi_format.Error (Cmi_format.Not_an_interface filename)) + | Some cmi, _ -> cmi +let saved_types = ref [] +let value_deps = ref [] - (*********************************************) - (* Equivalence between parameterized types *) - (*********************************************) +let clear () = + saved_types := []; + value_deps := [] -let expand_head_rigid env ty = - let old = !rigid_variants in - rigid_variants := true; - let ty' = expand_head env ty in - rigid_variants := old; ty' +let add_saved_type b = saved_types := b :: !saved_types +let get_saved_types () = !saved_types +let set_saved_types l = saved_types := l -let normalize_subst subst = - if List.exists - (function {desc=Tlink _}, _ | _, {desc=Tlink _} -> true | _ -> false) - !subst - then subst := List.map (fun (t1,t2) -> repr t1, repr t2) !subst +let record_value_dependency vd1 vd2 = + if vd1.Types.val_loc <> vd2.Types.val_loc then + value_deps := (vd1, vd2) :: !value_deps -let rec eqtype rename type_pairs subst env t1 t2 = - if t1 == t2 then () else - let t1 = repr t1 in - let t2 = repr t2 in - if t1 == t2 then () else +let save_cmt filename modname binary_annots sourcefile initial_env cmi = + if !Clflags.binary_annotations && not !Clflags.print_types then begin + (if !Clflags.bs_only then Misc.output_to_bin_file_directly else + Misc.output_to_file_via_temporary + ~mode:[Open_binary] ) filename + (fun temp_file_name oc -> + let this_crc = + match cmi with + | None -> None + | Some cmi -> Some (output_cmi temp_file_name oc cmi) + in + let source_digest = Misc.may_map Digest.file sourcefile in + let cmt = { + cmt_modname = modname; + cmt_annots = clear_env binary_annots; + cmt_value_dependencies = !value_deps; + cmt_comments = Lexer.comments (); + cmt_args = Sys.argv; + cmt_sourcefile = sourcefile; + cmt_builddir = Sys.getcwd (); + cmt_loadpath = !Config.load_path; + cmt_source_digest = source_digest; + cmt_initial_env = if need_to_clear_env then + keep_only_summary initial_env else initial_env; + cmt_imports = List.sort compare (Env.imports ()); + cmt_interface_digest = this_crc; + cmt_use_summaries = need_to_clear_env; + } in + output_cmt oc cmt) + end; + clear () - try - match (t1.desc, t2.desc) with - (Tvar _, Tvar _) when rename -> - begin try - normalize_subst subst; - if List.assq t1 !subst != t2 then raise (Unify []) - with Not_found -> - if List.exists (fun (_, t) -> t == t2) !subst then raise (Unify []); - subst := (t1, t2) :: !subst - end - | (Tconstr (p1, [], _), Tconstr (p2, [], _)) when Path.same p1 p2 -> - () - | _ -> - let t1' = expand_head_rigid env t1 in - let t2' = expand_head_rigid env t2 in - (* Expansion may have changed the representative of the types... *) - let t1' = repr t1' and t2' = repr t2' in - if t1' == t2' then () else - begin try - TypePairs.find type_pairs (t1', t2') - with Not_found -> - TypePairs.add type_pairs (t1', t2') (); - match (t1'.desc, t2'.desc) with - (Tvar _, Tvar _) when rename -> - begin try - normalize_subst subst; - if List.assq t1' !subst != t2' then raise (Unify []) - with Not_found -> - if List.exists (fun (_, t) -> t == t2') !subst - then raise (Unify []); - subst := (t1', t2') :: !subst - end - | (Tarrow (l1, t1, u1, _), Tarrow (l2, t2, u2, _)) when l1 = l2 - || !Clflags.classic && not (is_optional l1 || is_optional l2) -> - eqtype rename type_pairs subst env t1 t2; - eqtype rename type_pairs subst env u1 u2; - | (Ttuple tl1, Ttuple tl2) -> - eqtype_list rename type_pairs subst env tl1 tl2 - | (Tconstr (p1, tl1, _), Tconstr (p2, tl2, _)) - when Path.same p1 p2 -> - eqtype_list rename type_pairs subst env tl1 tl2 - | (Tpackage (p1, n1, tl1), Tpackage (p2, n2, tl2)) -> - begin try - unify_package env (eqtype_list rename type_pairs subst env) - t1'.level p1 n1 tl1 t2'.level p2 n2 tl2 - with Not_found -> raise (Unify []) - end - | (Tvariant row1, Tvariant row2) -> - eqtype_row rename type_pairs subst env row1 row2 - | (Tobject (fi1, _nm1), Tobject (fi2, _nm2)) -> - eqtype_fields rename type_pairs subst env fi1 fi2 - | (Tfield _, Tfield _) -> (* Actually unused *) - eqtype_fields rename type_pairs subst env t1' t2' - | (Tnil, Tnil) -> - () - | (Tpoly (t1, []), Tpoly (t2, [])) -> - eqtype rename type_pairs subst env t1 t2 - | (Tpoly (t1, tl1), Tpoly (t2, tl2)) -> - enter_poly env univar_pairs t1 tl1 t2 tl2 - (eqtype rename type_pairs subst env) - | (Tunivar _, Tunivar _) -> - unify_univar t1' t2' !univar_pairs - | (_, _) -> - raise (Unify []) - end - with Unify trace -> - raise (Unify ((t1, t2)::trace)) +end +module Ctype : sig +#1 "ctype.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -and eqtype_list rename type_pairs subst env tl1 tl2 = - if List.length tl1 <> List.length tl2 then - raise (Unify []); - List.iter2 (eqtype rename type_pairs subst env) tl1 tl2 +(* Operations on core types *) -and eqtype_fields rename type_pairs subst env ty1 ty2 = - let (fields1, rest1) = flatten_fields ty1 in - let (fields2, rest2) = flatten_fields ty2 in - (* First check if same row => already equal *) - let same_row = - rest1 == rest2 || TypePairs.mem type_pairs (rest1,rest2) || - (rename && List.mem (rest1, rest2) !subst) - in - if same_row then () else - (* Try expansion, needed when called from Includecore.type_manifest *) - match expand_head_rigid env rest2 with - {desc=Tobject(ty2,_)} -> eqtype_fields rename type_pairs subst env ty1 ty2 - | _ -> - let (pairs, miss1, miss2) = associate_fields fields1 fields2 in - eqtype rename type_pairs subst env rest1 rest2; - if (miss1 <> []) || (miss2 <> []) then raise (Unify []); - List.iter - (function (n, k1, t1, k2, t2) -> - eqtype_kind k1 k2; - try eqtype rename type_pairs subst env t1 t2 with Unify trace -> - raise (Unify ((newty (Tfield(n, k1, t1, rest2)), - newty (Tfield(n, k2, t2, rest2)))::trace))) - pairs +open Asttypes +open Types -and eqtype_kind k1 k2 = - let k1 = field_kind_repr k1 in - let k2 = field_kind_repr k2 in - match k1, k2 with - (Fvar _, Fvar _) - | (Fpresent, Fpresent) -> () - | _ -> raise (Unify []) +exception Unify of (type_expr * type_expr) list +exception Tags of label * label +exception Subtype of + (type_expr * type_expr) list * (type_expr * type_expr) list +exception Cannot_expand +exception Cannot_apply +exception Recursive_abbrev +exception Unification_recursive_abbrev of (type_expr * type_expr) list -and eqtype_row rename type_pairs subst env row1 row2 = - (* Try expansion, needed when called from Includecore.type_manifest *) - match expand_head_rigid env (row_more row2) with - {desc=Tvariant row2} -> eqtype_row rename type_pairs subst env row1 row2 - | _ -> - let row1 = row_repr row1 and row2 = row_repr row2 in - let r1, r2, pairs = merge_row_fields row1.row_fields row2.row_fields in - if row1.row_closed <> row2.row_closed - || not row1.row_closed && (r1 <> [] || r2 <> []) - || filter_row_fields false (r1 @ r2) <> [] - then raise (Unify []); - if not (static_row row1) then - eqtype rename type_pairs subst env row1.row_more row2.row_more; - List.iter - (fun (_,f1,f2) -> - match row_field_repr f1, row_field_repr f2 with - Rpresent(Some t1), Rpresent(Some t2) -> - eqtype rename type_pairs subst env t1 t2 - | Reither(c1, [], _, _), Reither(c2, [], _, _) when c1 = c2 -> - () - | Reither(c1, t1::tl1, _, _), Reither(c2, t2::tl2, _, _) when c1 = c2 -> - eqtype rename type_pairs subst env t1 t2; - if List.length tl1 = List.length tl2 then - (* if same length allow different types (meaning?) *) - List.iter2 (eqtype rename type_pairs subst env) tl1 tl2 - else begin - (* otherwise everything must be equal *) - List.iter (eqtype rename type_pairs subst env t1) tl2; - List.iter (fun t1 -> eqtype rename type_pairs subst env t1 t2) tl1 - end - | Rpresent None, Rpresent None -> () - | Rabsent, Rabsent -> () - | _ -> raise (Unify [])) - pairs +val init_def: int -> unit + (* Set the initial variable level *) +val begin_def: unit -> unit + (* Raise the variable level by one at the beginning of a definition. *) +val end_def: unit -> unit + (* Lower the variable level by one at the end of a definition *) +val begin_class_def: unit -> unit +val raise_nongen_level: unit -> unit +val reset_global_level: unit -> unit + (* Reset the global level before typing an expression *) +val increase_global_level: unit -> int +val restore_global_level: int -> unit + (* This pair of functions is only used in Typetexp *) +type levels = + { current_level: int; nongen_level: int; global_level: int; + saved_level: (int * int) list; } +val save_levels: unit -> levels +val set_levels: levels -> unit -(* Must empty univar_pairs first *) -let eqtype_list rename type_pairs subst env tl1 tl2 = - univar_pairs := []; - let snap = Btype.snapshot () in - try eqtype_list rename type_pairs subst env tl1 tl2; backtrack snap - with exn -> backtrack snap; raise exn +val newty: type_desc -> type_expr +val newvar: ?name:string -> unit -> type_expr +val newvar2: ?name:string -> int -> type_expr + (* Return a fresh variable *) +val new_global_var: ?name:string -> unit -> type_expr + (* Return a fresh variable, bound at toplevel + (as type variables ['a] in type constraints). *) +val newobj: type_expr -> type_expr +val newconstr: Path.t -> type_expr list -> type_expr +val none: type_expr + (* A dummy type expression *) -let eqtype rename type_pairs subst env t1 t2 = - eqtype_list rename type_pairs subst env [t1] [t2] +val repr: type_expr -> type_expr + (* Return the canonical representative of a type. *) -(* Two modes: with or without renaming of variables *) -let equal env rename tyl1 tyl2 = - try - eqtype_list rename (TypePairs.create 11) (ref []) env tyl1 tyl2; true - with - Unify _ -> false +val object_fields: type_expr -> type_expr +val flatten_fields: + type_expr -> (string * field_kind * type_expr) list * type_expr + (* Transform a field type into a list of pairs label-type *) + (* The fields are sorted *) +val associate_fields: + (string * field_kind * type_expr) list -> + (string * field_kind * type_expr) list -> + (string * field_kind * type_expr * field_kind * type_expr) list * + (string * field_kind * type_expr) list * + (string * field_kind * type_expr) list +val opened_object: type_expr -> bool +val close_object: type_expr -> unit +val row_variable: type_expr -> type_expr + (* Return the row variable of an open object type *) +val set_object_name: + Ident.t -> type_expr -> type_expr list -> type_expr -> unit +val remove_object_name: type_expr -> unit +val hide_private_methods: type_expr -> unit +val find_cltype_for_path: Env.t -> Path.t -> type_declaration * type_expr +val lid_of_path: ?hash:string -> Path.t -> Longident.t +val sort_row_fields: (label * row_field) list -> (label * row_field) list +val merge_row_fields: + (label * row_field) list -> (label * row_field) list -> + (label * row_field) list * (label * row_field) list * + (label * row_field * row_field) list +val filter_row_fields: + bool -> (label * row_field) list -> (label * row_field) list - (*************************) - (* Class type matching *) - (*************************) +val generalize: type_expr -> unit + (* Generalize in-place the given type *) +val generalize_expansive: Env.t -> type_expr -> unit + (* Generalize the covariant part of a type, making + contravariant branches non-generalizable *) +val generalize_global: type_expr -> unit + (* Generalize the structure of a type, lowering variables + to !global_level *) +val generalize_structure: type_expr -> unit + (* Same, but variables are only lowered to !current_level *) +val generalize_spine: type_expr -> unit + (* Special function to generalize a method during inference *) +val correct_levels: type_expr -> type_expr + (* Returns a copy with decreasing levels *) +val limited_generalize: type_expr -> type_expr -> unit + (* Only generalize some part of the type + Make the remaining of the type non-generalizable *) +val instance: ?partial:bool -> Env.t -> type_expr -> type_expr + (* Take an instance of a type scheme *) + (* partial=None -> normal + partial=false -> newvar() for non generic subterms + partial=true -> newty2 ty.level Tvar for non generic subterms *) +val instance_def: type_expr -> type_expr + (* use defaults *) +val generic_instance: Env.t -> type_expr -> type_expr + (* Same as instance, but new nodes at generic_level *) +val instance_list: Env.t -> type_expr list -> type_expr list + (* Take an instance of a list of type schemes *) +val instance_constructor: + ?in_pattern:Env.t ref * int -> + constructor_description -> type_expr list * type_expr + (* Same, for a constructor *) +val instance_parameterized_type: + ?keep_names:bool -> + type_expr list -> type_expr -> type_expr list * type_expr +val instance_parameterized_type_2: + type_expr list -> type_expr list -> type_expr -> + type_expr list * type_expr list * type_expr +val instance_declaration: type_declaration -> type_declaration +val instance_class: + type_expr list -> class_type -> type_expr list * class_type +val instance_poly: + ?keep_names:bool -> + bool -> type_expr list -> type_expr -> type_expr list * type_expr + (* Take an instance of a type scheme containing free univars *) +val instance_label: + bool -> label_description -> type_expr list * type_expr * type_expr + (* Same, for a label *) +val apply: + Env.t -> type_expr list -> type_expr -> type_expr list -> type_expr + (* [apply [p1...pN] t [a1...aN]] match the arguments [ai] to + the parameters [pi] and returns the corresponding instance of + [t]. Exception [Cannot_apply] is raised in case of failure. *) -type class_match_failure = - CM_Virtual_class - | CM_Parameter_arity_mismatch of int * int - | CM_Type_parameter_mismatch of Env.t * (type_expr * type_expr) list - | CM_Class_type_mismatch of Env.t * class_type * class_type - | CM_Parameter_mismatch of Env.t * (type_expr * type_expr) list - | CM_Val_type_mismatch of string * Env.t * (type_expr * type_expr) list - | CM_Meth_type_mismatch of string * Env.t * (type_expr * type_expr) list - | CM_Non_mutable_value of string - | CM_Non_concrete_value of string - | CM_Missing_value of string - | CM_Missing_method of string - | CM_Hide_public of string - | CM_Hide_virtual of string * string - | CM_Public_method of string - | CM_Private_method of string - | CM_Virtual_method of string +val expand_head_once: Env.t -> type_expr -> type_expr +val expand_head: Env.t -> type_expr -> type_expr +val try_expand_once_opt: Env.t -> type_expr -> type_expr +val expand_head_opt: Env.t -> type_expr -> type_expr +(** The compiler's own version of [expand_head] necessary for type-based + optimisations. *) -exception Failure of class_match_failure list +val full_expand: Env.t -> type_expr -> type_expr +val extract_concrete_typedecl: + Env.t -> type_expr -> Path.t * Path.t * type_declaration + (* Return the original path of the types, and the first concrete + type declaration found expanding it. + Raise [Not_found] if none appears or not a type constructor. *) -let rec moregen_clty trace type_pairs env cty1 cty2 = - try - match cty1, cty2 with - Cty_constr (_, _, cty1), _ -> - moregen_clty true type_pairs env cty1 cty2 - | _, Cty_constr (_, _, cty2) -> - moregen_clty true type_pairs env cty1 cty2 - | Cty_arrow (l1, ty1, cty1'), Cty_arrow (l2, ty2, cty2') when l1 = l2 -> - begin try moregen true type_pairs env ty1 ty2 with Unify trace -> - raise (Failure [CM_Parameter_mismatch (env, expand_trace env trace)]) - end; - moregen_clty false type_pairs env cty1' cty2' - | Cty_signature sign1, Cty_signature sign2 -> - let ty1 = object_fields (repr sign1.csig_self) in - let ty2 = object_fields (repr sign2.csig_self) in - let (fields1, _rest1) = flatten_fields ty1 - and (fields2, _rest2) = flatten_fields ty2 in - let (pairs, _miss1, _miss2) = associate_fields fields1 fields2 in - List.iter - (fun (lab, _k1, t1, _k2, t2) -> - begin try moregen true type_pairs env t1 t2 with Unify trace -> - raise (Failure [CM_Meth_type_mismatch - (lab, env, expand_trace env trace)]) - end) - pairs; - Vars.iter - (fun lab (_mut, _v, ty) -> - let (_mut', _v', ty') = Vars.find lab sign1.csig_vars in - try moregen true type_pairs env ty' ty with Unify trace -> - raise (Failure [CM_Val_type_mismatch - (lab, env, expand_trace env trace)])) - sign2.csig_vars - | _ -> - raise (Failure []) - with - Failure error when trace || error = [] -> - raise (Failure (CM_Class_type_mismatch (env, cty1, cty2)::error)) +val enforce_constraints: Env.t -> type_expr -> unit -let match_class_types ?(trace=true) env pat_sch subj_sch = - let type_pairs = TypePairs.create 53 in - let old_level = !current_level in - current_level := generic_level - 1; - (* - Generic variables are first duplicated with [instance]. So, - their levels are lowered to [generic_level - 1]. The subject is - then copied with [duplicate_type]. That way, its levels won't be - changed. - *) - let (_, subj_inst) = instance_class [] subj_sch in - let subj = duplicate_class_type subj_inst in - current_level := generic_level; - (* Duplicate generic variables *) - let (_, patt) = instance_class [] pat_sch in - let res = - let sign1 = signature_of_class_type patt in - let sign2 = signature_of_class_type subj in - let t1 = repr sign1.csig_self in - let t2 = repr sign2.csig_self in - TypePairs.add type_pairs (t1, t2) (); - let (fields1, rest1) = flatten_fields (object_fields t1) - and (fields2, rest2) = flatten_fields (object_fields t2) in - let (pairs, miss1, miss2) = associate_fields fields1 fields2 in - let error = - List.fold_right - (fun (lab, k, _) err -> - let err = - let k = field_kind_repr k in - begin match k with - Fvar r -> set_kind r Fabsent; err - | _ -> CM_Hide_public lab::err - end - in - if Concr.mem lab sign1.csig_concr then err - else CM_Hide_virtual ("method", lab) :: err) - miss1 [] - in - let missing_method = List.map (fun (m, _, _) -> m) miss2 in - let error = - (List.map (fun m -> CM_Missing_method m) missing_method) @ error - in - (* Always succeeds *) - moregen true type_pairs env rest1 rest2; - let error = - List.fold_right - (fun (lab, k1, _t1, k2, _t2) err -> - try moregen_kind k1 k2; err with - Unify _ -> CM_Public_method lab::err) - pairs error - in - let error = - Vars.fold - (fun lab (mut, vr, _ty) err -> - try - let (mut', vr', _ty') = Vars.find lab sign1.csig_vars in - if mut = Mutable && mut' <> Mutable then - CM_Non_mutable_value lab::err - else if vr = Concrete && vr' <> Concrete then - CM_Non_concrete_value lab::err - else - err - with Not_found -> - CM_Missing_value lab::err) - sign2.csig_vars error - in - let error = - Vars.fold - (fun lab (_,vr,_) err -> - if vr = Virtual && not (Vars.mem lab sign2.csig_vars) then - CM_Hide_virtual ("instance variable", lab) :: err - else err) - sign1.csig_vars error - in - let error = - List.fold_right - (fun e l -> - if List.mem e missing_method then l else CM_Virtual_method e::l) - (Concr.elements (Concr.diff sign2.csig_concr sign1.csig_concr)) - error - in - match error with - [] -> - begin try - moregen_clty trace type_pairs env patt subj; - [] - with - Failure r -> r - end - | error -> - CM_Class_type_mismatch (env, patt, subj)::error - in - current_level := old_level; - res +val unify: Env.t -> type_expr -> type_expr -> unit + (* Unify the two types given. Raise [Unify] if not possible. *) +val unify_gadt: newtype_level:int -> Env.t ref -> type_expr -> type_expr -> unit + (* Unify the two types given and update the environment with the + local constraints. Raise [Unify] if not possible. *) +val unify_var: Env.t -> type_expr -> type_expr -> unit + (* Same as [unify], but allow free univars when first type + is a variable. *) +val with_passive_variants: ('a -> 'b) -> ('a -> 'b) + (* Call [f] in passive_variants mode, for exhaustiveness check. *) +val filter_arrow: Env.t -> type_expr -> arg_label -> type_expr * type_expr + (* A special case of unification (with l:'a -> 'b). *) +val filter_method: Env.t -> string -> private_flag -> type_expr -> type_expr + (* A special case of unification (with {m : 'a; 'b}). *) +val check_filter_method: Env.t -> string -> private_flag -> type_expr -> unit + (* A special case of unification (with {m : 'a; 'b}), returning unit. *) +val occur_in: Env.t -> type_expr -> type_expr -> bool +val deep_occur: type_expr -> type_expr -> bool +val filter_self_method: + Env.t -> string -> private_flag -> (Ident.t * type_expr) Meths.t ref -> + type_expr -> Ident.t * type_expr +val moregeneral: Env.t -> bool -> type_expr -> type_expr -> bool + (* Check if the first type scheme is more general than the second. *) -let rec equal_clty trace type_pairs subst env cty1 cty2 = - try - match cty1, cty2 with - Cty_constr (_, _, cty1), Cty_constr (_, _, cty2) -> - equal_clty true type_pairs subst env cty1 cty2 - | Cty_constr (_, _, cty1), _ -> - equal_clty true type_pairs subst env cty1 cty2 - | _, Cty_constr (_, _, cty2) -> - equal_clty true type_pairs subst env cty1 cty2 - | Cty_arrow (l1, ty1, cty1'), Cty_arrow (l2, ty2, cty2') when l1 = l2 -> - begin try eqtype true type_pairs subst env ty1 ty2 with Unify trace -> - raise (Failure [CM_Parameter_mismatch (env, expand_trace env trace)]) - end; - equal_clty false type_pairs subst env cty1' cty2' - | Cty_signature sign1, Cty_signature sign2 -> - let ty1 = object_fields (repr sign1.csig_self) in - let ty2 = object_fields (repr sign2.csig_self) in - let (fields1, _rest1) = flatten_fields ty1 - and (fields2, _rest2) = flatten_fields ty2 in - let (pairs, _miss1, _miss2) = associate_fields fields1 fields2 in - List.iter - (fun (lab, _k1, t1, _k2, t2) -> - begin try eqtype true type_pairs subst env t1 t2 with - Unify trace -> - raise (Failure [CM_Meth_type_mismatch - (lab, env, expand_trace env trace)]) - end) - pairs; - Vars.iter - (fun lab (_, _, ty) -> - let (_, _, ty') = Vars.find lab sign1.csig_vars in - try eqtype true type_pairs subst env ty' ty with Unify trace -> - raise (Failure [CM_Val_type_mismatch - (lab, env, expand_trace env trace)])) - sign2.csig_vars - | _ -> - raise - (Failure (if trace then [] - else [CM_Class_type_mismatch (env, cty1, cty2)])) - with - Failure error when trace -> - raise (Failure (CM_Class_type_mismatch (env, cty1, cty2)::error)) +val rigidify: type_expr -> type_expr list + (* "Rigidify" a type and return its type variable *) +val all_distinct_vars: Env.t -> type_expr list -> bool + (* Check those types are all distinct type variables *) +val matches: Env.t -> type_expr -> type_expr -> bool + (* Same as [moregeneral false], implemented using the two above + functions and backtracking. Ignore levels *) -let match_class_declarations env patt_params patt_type subj_params subj_type = - let type_pairs = TypePairs.create 53 in - let subst = ref [] in - let sign1 = signature_of_class_type patt_type in - let sign2 = signature_of_class_type subj_type in - let t1 = repr sign1.csig_self in - let t2 = repr sign2.csig_self in - TypePairs.add type_pairs (t1, t2) (); - let (fields1, rest1) = flatten_fields (object_fields t1) - and (fields2, rest2) = flatten_fields (object_fields t2) in - let (pairs, miss1, miss2) = associate_fields fields1 fields2 in - let error = - List.fold_right - (fun (lab, k, _) err -> - let err = - let k = field_kind_repr k in - begin match k with - Fvar _ -> err - | _ -> CM_Hide_public lab::err - end - in - if Concr.mem lab sign1.csig_concr then err - else CM_Hide_virtual ("method", lab) :: err) - miss1 [] - in - let missing_method = List.map (fun (m, _, _) -> m) miss2 in - let error = - (List.map (fun m -> CM_Missing_method m) missing_method) @ error - in - (* Always succeeds *) - eqtype true type_pairs subst env rest1 rest2; - let error = - List.fold_right - (fun (lab, k1, _t1, k2, _t2) err -> - let k1 = field_kind_repr k1 in - let k2 = field_kind_repr k2 in - match k1, k2 with - (Fvar _, Fvar _) - | (Fpresent, Fpresent) -> err - | (Fvar _, Fpresent) -> CM_Private_method lab::err - | (Fpresent, Fvar _) -> CM_Public_method lab::err - | _ -> assert false) - pairs error - in - let error = - Vars.fold - (fun lab (mut, vr, _ty) err -> - try - let (mut', vr', _ty') = Vars.find lab sign1.csig_vars in - if mut = Mutable && mut' <> Mutable then - CM_Non_mutable_value lab::err - else if vr = Concrete && vr' <> Concrete then - CM_Non_concrete_value lab::err - else - err - with Not_found -> - CM_Missing_value lab::err) - sign2.csig_vars error - in - let error = - Vars.fold - (fun lab (_,vr,_) err -> - if vr = Virtual && not (Vars.mem lab sign2.csig_vars) then - CM_Hide_virtual ("instance variable", lab) :: err - else err) - sign1.csig_vars error - in - let error = - List.fold_right - (fun e l -> - if List.mem e missing_method then l else CM_Virtual_method e::l) - (Concr.elements (Concr.diff sign2.csig_concr sign1.csig_concr)) - error - in - match error with - [] -> - begin try - let lp = List.length patt_params in - let ls = List.length subj_params in - if lp <> ls then - raise (Failure [CM_Parameter_arity_mismatch (lp, ls)]); - List.iter2 (fun p s -> - try eqtype true type_pairs subst env p s with Unify trace -> - raise (Failure [CM_Type_parameter_mismatch - (env, expand_trace env trace)])) - patt_params subj_params; - (* old code: equal_clty false type_pairs subst env patt_type subj_type; *) - equal_clty false type_pairs subst env - (Cty_signature sign1) (Cty_signature sign2); - (* Use moregeneral for class parameters, need to recheck everything to - keeps relationships (PR#4824) *) - let clty_params = - List.fold_right (fun ty cty -> Cty_arrow (Labelled "*",ty,cty)) in - match_class_types ~trace:false env - (clty_params patt_params patt_type) - (clty_params subj_params subj_type) - with - Failure r -> r - end - | error -> - error +type class_match_failure = + CM_Virtual_class + | CM_Parameter_arity_mismatch of int * int + | CM_Type_parameter_mismatch of Env.t * (type_expr * type_expr) list + | CM_Class_type_mismatch of Env.t * class_type * class_type + | CM_Parameter_mismatch of Env.t * (type_expr * type_expr) list + | CM_Val_type_mismatch of string * Env.t * (type_expr * type_expr) list + | CM_Meth_type_mismatch of string * Env.t * (type_expr * type_expr) list + | CM_Non_mutable_value of string + | CM_Non_concrete_value of string + | CM_Missing_value of string + | CM_Missing_method of string + | CM_Hide_public of string + | CM_Hide_virtual of string * string + | CM_Public_method of string + | CM_Private_method of string + | CM_Virtual_method of string +val match_class_types: + ?trace:bool -> Env.t -> class_type -> class_type -> class_match_failure list + (* Check if the first class type is more general than the second. *) +val equal: Env.t -> bool -> type_expr list -> type_expr list -> bool + (* [equal env [x1...xn] tau [y1...yn] sigma] + checks whether the parameterized types + [/\x1.../\xn.tau] and [/\y1.../\yn.sigma] are equivalent. *) +val match_class_declarations: + Env.t -> type_expr list -> class_type -> type_expr list -> + class_type -> class_match_failure list + (* Check if the first class type is more general than the second. *) +val enlarge_type: Env.t -> type_expr -> type_expr * bool + (* Make a type larger, flag is true if some pruning had to be done *) +val subtype: Env.t -> type_expr -> type_expr -> unit -> unit + (* [subtype env t1 t2] checks that [t1] is a subtype of [t2]. + It accumulates the constraints the type variables must + enforce and returns a function that enforces this + constraints. *) - (***************) - (* Subtyping *) - (***************) +val nondep_type: Env.t -> Ident.t -> type_expr -> type_expr + (* Return a type equivalent to the given type but without + references to the given module identifier. Raise [Not_found] + if no such type exists. *) +val nondep_type_decl: + Env.t -> Ident.t -> Ident.t -> bool -> type_declaration -> + type_declaration + (* Same for type declarations. *) +val nondep_extension_constructor: + Env.t -> Ident.t -> extension_constructor -> + extension_constructor + (* Same for extension constructor *) +val nondep_class_declaration: + Env.t -> Ident.t -> class_declaration -> class_declaration + (* Same for class declarations. *) +val nondep_cltype_declaration: + Env.t -> Ident.t -> class_type_declaration -> class_type_declaration + (* Same for class type declarations. *) +(*val correct_abbrev: Env.t -> Path.t -> type_expr list -> type_expr -> unit*) +val cyclic_abbrev: Env.t -> Ident.t -> type_expr -> bool +val is_contractive: Env.t -> Path.t -> bool +val normalize_type: Env.t -> type_expr -> unit +val closed_schema: Env.t -> type_expr -> bool + (* Check whether the given type scheme contains no non-generic + type variables *) -(**** Build a subtype of a given type. ****) +val free_variables: ?env:Env.t -> type_expr -> type_expr list + (* If env present, then check for incomplete definitions too *) +val closed_type_decl: type_declaration -> type_expr option +val closed_extension_constructor: extension_constructor -> type_expr option +type closed_class_failure = + CC_Method of type_expr * bool * string * type_expr + | CC_Value of type_expr * bool * string * type_expr +val closed_class: + type_expr list -> class_signature -> closed_class_failure option + (* Check whether all type variables are bound *) -(* build_subtype: - [visited] traces traversed object and variant types - [loops] is a mapping from variables to variables, to reproduce - positive loops in a class type - [posi] true if the current variance is positive - [level] number of expansions/enlargement allowed on this branch *) +val unalias: type_expr -> type_expr +val signature_of_class_type: class_type -> class_signature +val self_type: class_type -> type_expr +val class_type_arity: class_type -> int +val arity: type_expr -> int + (* Return the arity (as for curried functions) of the given type. *) -let warn = ref false (* whether double coercion might do better *) -let pred_expand n = if n mod 2 = 0 && n > 0 then pred n else n -let pred_enlarge n = if n mod 2 = 1 then pred n else n +val collapse_conj_params: Env.t -> type_expr list -> unit + (* Collapse conjunctive types in class parameters *) -type change = Unchanged | Equiv | Changed -let collect l = List.fold_left (fun c1 (_, c2) -> max c1 c2) Unchanged l +val get_current_level: unit -> int +val wrap_trace_gadt_instances: Env.t -> ('a -> 'b) -> 'a -> 'b +val reset_reified_var_counter: unit -> unit -let rec filter_visited = function - [] -> [] - | {desc=Tobject _|Tvariant _} :: _ as l -> l - | _ :: l -> filter_visited l +val maybe_pointer_type : Env.t -> type_expr -> bool + (* True if type is possibly pointer, false if definitely not a pointer *) -let memq_warn t visited = - if List.memq t visited then (warn := true; true) else false +(* Stubs *) +val package_subtype : + (Env.t -> Path.t -> Longident.t list -> type_expr list -> + Path.t -> Longident.t list -> type_expr list -> bool) ref -let rec lid_of_path ?(hash="") = function - Path.Pident id -> - Longident.Lident (hash ^ Ident.name id) - | Path.Pdot (p1, s, _) -> - Longident.Ldot (lid_of_path p1, hash ^ s) - | Path.Papply (p1, p2) -> - Longident.Lapply (lid_of_path ~hash p1, lid_of_path p2) +end = struct +#1 "ctype.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy and Jerome Vouillon, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -let find_cltype_for_path env p = - let cl_path = Env.lookup_type (lid_of_path ~hash:"#" p) env in - let cl_abbr = Env.find_type cl_path env in +(* Operations on core types *) - match cl_abbr.type_manifest with - Some ty -> - begin match (repr ty).desc with - Tobject(_,{contents=Some(p',_)}) when Path.same p p' -> cl_abbr, ty - | _ -> raise Not_found - end - | None -> assert false +open Misc +open Asttypes +open Types +open Btype -let has_constr_row' env t = - has_constr_row (expand_abbrev env t) +(* + Type manipulation after type inference + ====================================== + If one wants to manipulate a type after type inference (for + instance, during code generation or in the debugger), one must + first make sure that the type levels are correct, using the + function [correct_levels]. Then, this type can be correctly + manipulated by [apply], [expand_head] and [moregeneral]. +*) -let rec build_subtype env visited loops posi level t = - let t = repr t in - match t.desc with - Tvar _ -> - if posi then - try - let t' = List.assq t loops in - warn := true; - (t', Equiv) - with Not_found -> - (t, Unchanged) - else - (t, Unchanged) - | Tarrow(l, t1, t2, _) -> - if memq_warn t visited then (t, Unchanged) else - let visited = t :: visited in - let (t1', c1) = build_subtype env visited loops (not posi) level t1 in - let (t2', c2) = build_subtype env visited loops posi level t2 in - let c = max c1 c2 in - if c > Unchanged then (newty (Tarrow(l, t1', t2', Cok)), c) - else (t, Unchanged) - | Ttuple tlist -> - if memq_warn t visited then (t, Unchanged) else - let visited = t :: visited in - let tlist' = - List.map (build_subtype env visited loops posi level) tlist - in - let c = collect tlist' in - if c > Unchanged then (newty (Ttuple (List.map fst tlist')), c) - else (t, Unchanged) - | Tconstr(p, tl, abbrev) - when level > 0 && generic_abbrev env p && safe_abbrev env t - && not (has_constr_row' env t) -> - let t' = repr (expand_abbrev env t) in - let level' = pred_expand level in - begin try match t'.desc with - Tobject _ when posi && not (opened_object t') -> - let cl_abbr, body = find_cltype_for_path env p in - let ty = - subst env !current_level Public abbrev None - cl_abbr.type_params tl body in - let ty = repr ty in - let ty1, tl1 = - match ty.desc with - Tobject(ty1,{contents=Some(p',tl1)}) when Path.same p p' -> - ty1, tl1 - | _ -> raise Not_found - in - (* Fix PR#4505: do not set ty to Tvar when it appears in tl1, - as this occurrence might break the occur check. - XXX not clear whether this correct anyway... *) - if List.exists (deep_occur ty) tl1 then raise Not_found; - ty.desc <- Tvar None; - let t'' = newvar () in - let loops = (ty, t'') :: loops in - (* May discard [visited] as level is going down *) - let (ty1', c) = - build_subtype env [t'] loops posi (pred_enlarge level') ty1 in - assert (is_Tvar t''); - let nm = - if c > Equiv || deep_occur ty ty1' then None else Some(p,tl1) in - t''.desc <- Tobject (ty1', ref nm); - (try unify_var env ty t with Unify _ -> assert false); - (t'', Changed) - | _ -> raise Not_found - with Not_found -> - let (t'',c) = build_subtype env visited loops posi level' t' in - if c > Unchanged then (t'',c) - else (t, Unchanged) - end - | Tconstr(p, tl, _abbrev) -> - (* Must check recursion on constructors, since we do not always - expand them *) - if memq_warn t visited then (t, Unchanged) else - let visited = t :: visited in - begin try - let decl = Env.find_type p env in - if level = 0 && generic_abbrev env p && safe_abbrev env t - && not (has_constr_row' env t) - then warn := true; - let tl' = - List.map2 - (fun v t -> - let (co,cn) = Variance.get_upper v in - if cn then - if co then (t, Unchanged) - else build_subtype env visited loops (not posi) level t - else - if co then build_subtype env visited loops posi level t - else (newvar(), Changed)) - decl.type_variance tl - in - let c = collect tl' in - if c > Unchanged then (newconstr p (List.map fst tl'), c) - else (t, Unchanged) - with Not_found -> - (t, Unchanged) - end - | Tvariant row -> - let row = row_repr row in - if memq_warn t visited || not (static_row row) then (t, Unchanged) else - let level' = pred_enlarge level in - let visited = - t :: if level' < level then [] else filter_visited visited in - let fields = filter_row_fields false row.row_fields in - let fields = - List.map - (fun (l,f as orig) -> match row_field_repr f with - Rpresent None -> - if posi then - (l, Reither(true, [], false, ref None)), Unchanged - else - orig, Unchanged - | Rpresent(Some t) -> - let (t', c) = build_subtype env visited loops posi level' t in - let f = - if posi && level > 0 - then Reither(false, [t'], false, ref None) - else Rpresent(Some t') - in (l, f), c - | _ -> assert false) - fields - in - let c = collect fields in - let row = - { row_fields = List.map fst fields; row_more = newvar(); - row_bound = (); row_closed = posi; row_fixed = false; - row_name = if c > Unchanged then None else row.row_name } - in - (newty (Tvariant row), Changed) - | Tobject (t1, _) -> - if memq_warn t visited || opened_object t1 then (t, Unchanged) else - let level' = pred_enlarge level in - let visited = - t :: if level' < level then [] else filter_visited visited in - let (t1', c) = build_subtype env visited loops posi level' t1 in - if c > Unchanged then (newty (Tobject (t1', ref None)), c) - else (t, Unchanged) - | Tfield(s, _, t1, t2) (* Always present *) -> - let (t1', c1) = build_subtype env visited loops posi level t1 in - let (t2', c2) = build_subtype env visited loops posi level t2 in - let c = max c1 c2 in - if c > Unchanged then (newty (Tfield(s, Fpresent, t1', t2')), c) - else (t, Unchanged) - | Tnil -> - if posi then - let v = newvar () in - (v, Changed) - else begin - warn := true; - (t, Unchanged) - end - | Tsubst _ | Tlink _ -> - assert false - | Tpoly(t1, tl) -> - let (t1', c) = build_subtype env visited loops posi level t1 in - if c > Unchanged then (newty (Tpoly(t1', tl)), c) - else (t, Unchanged) - | Tunivar _ | Tpackage _ -> - (t, Unchanged) +(* + General notes + ============= + - As much sharing as possible should be kept : it makes types + smaller and better abbreviated. + When necessary, some sharing can be lost. Types will still be + printed correctly (+++ TO DO...), and abbreviations defined by a + class do not depend on sharing thanks to constrained + abbreviations. (Of course, even if some sharing is lost, typing + will still be correct.) + - All nodes of a type have a level : that way, one know whether a + node need to be duplicated or not when instantiating a type. + - Levels of a type are decreasing (generic level being considered + as greatest). + - The level of a type constructor is superior to the binding + time of its path. + - Recursive types without limitation should be handled (even if + there is still an occur check). This avoid treating specially the + case for objects, for instance. Furthermore, the occur check + policy can then be easily changed. +*) + +(**** Errors ****) -let enlarge_type env ty = - warn := false; - (* [level = 4] allows 2 expansions involving objects/variants *) - let (ty', _) = build_subtype env [] [] true 4 ty in - (ty', !warn) +exception Unify of (type_expr * type_expr) list -(**** Check whether a type is a subtype of another type. ****) +exception Tags of label * label -(* - During the traversal, a trace of visited types is maintained. It - is printed in case of error. - Constraints (pairs of types that must be equals) are accumulated - rather than being enforced straight. Indeed, the result would - otherwise depend on the order in which these constraints are - enforced. - A function enforcing these constraints is returned. That way, type - variables can be bound to their actual values before this function - is called (see Typecore). - Only well-defined abbreviations are expanded (hence the tests - [generic_abbrev ...]). -*) +let () = + Location.register_error_of_exn + (function + | Tags (l, l') -> + Some + Location. + (errorf ~loc:(in_file !input_name) + "In this program,@ variant constructors@ `%s and `%s@ \ + have the same hash value.@ Change one of them." l l' + ) + | _ -> None + ) -let subtypes = TypePairs.create 17 +exception Subtype of + (type_expr * type_expr) list * (type_expr * type_expr) list -let subtype_error env trace = - raise (Subtype (expand_trace env (List.rev trace), [])) +exception Cannot_expand -let rec subtype_rec env trace t1 t2 cstrs = - let t1 = repr t1 in - let t2 = repr t2 in - if t1 == t2 then cstrs else +exception Cannot_apply - begin try - TypePairs.find subtypes (t1, t2); - cstrs - with Not_found -> - TypePairs.add subtypes (t1, t2) (); - match (t1.desc, t2.desc) with - (Tvar _, _) | (_, Tvar _) -> - (trace, t1, t2, !univar_pairs)::cstrs - | (Tarrow(l1, t1, u1, _), Tarrow(l2, t2, u2, _)) when l1 = l2 - || !Clflags.classic && not (is_optional l1 || is_optional l2) -> - let cstrs = subtype_rec env ((t2, t1)::trace) t2 t1 cstrs in - subtype_rec env ((u1, u2)::trace) u1 u2 cstrs - | (Ttuple tl1, Ttuple tl2) -> - subtype_list env trace tl1 tl2 cstrs - | (Tconstr(p1, [], _), Tconstr(p2, [], _)) when Path.same p1 p2 -> - cstrs - | (Tconstr(p1, _tl1, _abbrev1), _) - when generic_abbrev env p1 && safe_abbrev env t1 -> - subtype_rec env trace (expand_abbrev env t1) t2 cstrs - | (_, Tconstr(p2, _tl2, _abbrev2)) - when generic_abbrev env p2 && safe_abbrev env t2 -> - subtype_rec env trace t1 (expand_abbrev env t2) cstrs - | (Tconstr(p1, tl1, _), Tconstr(p2, tl2, _)) when Path.same p1 p2 -> - begin try - let decl = Env.find_type p1 env in - List.fold_left2 - (fun cstrs v (t1, t2) -> - let (co, cn) = Variance.get_upper v in - if co then - if cn then - (trace, newty2 t1.level (Ttuple[t1]), - newty2 t2.level (Ttuple[t2]), !univar_pairs) :: cstrs - else subtype_rec env ((t1, t2)::trace) t1 t2 cstrs - else - if cn then subtype_rec env ((t2, t1)::trace) t2 t1 cstrs - else cstrs) - cstrs decl.type_variance (List.combine tl1 tl2) - with Not_found -> - (trace, t1, t2, !univar_pairs)::cstrs - end - | (Tconstr(p1, _, _), _) when generic_private_abbrev env p1 -> - subtype_rec env trace (expand_abbrev_opt env t1) t2 cstrs -(* | (_, Tconstr(p2, _, _)) when generic_private_abbrev false env p2 -> - subtype_rec env trace t1 (expand_abbrev_opt env t2) cstrs *) - | (Tobject (f1, _), Tobject (f2, _)) - when is_Tvar (object_row f1) && is_Tvar (object_row f2) -> - (* Same row variable implies same object. *) - (trace, t1, t2, !univar_pairs)::cstrs - | (Tobject (f1, _), Tobject (f2, _)) -> - subtype_fields env trace f1 f2 cstrs - | (Tvariant row1, Tvariant row2) -> - begin try - subtype_row env trace row1 row2 cstrs - with Exit -> - (trace, t1, t2, !univar_pairs)::cstrs - end - | (Tpoly (u1, []), Tpoly (u2, [])) -> - subtype_rec env trace u1 u2 cstrs - | (Tpoly (u1, tl1), Tpoly (u2, [])) -> - let _, u1' = instance_poly false tl1 u1 in - subtype_rec env trace u1' u2 cstrs - | (Tpoly (u1, tl1), Tpoly (u2,tl2)) -> - begin try - enter_poly env univar_pairs u1 tl1 u2 tl2 - (fun t1 t2 -> subtype_rec env trace t1 t2 cstrs) - with Unify _ -> - (trace, t1, t2, !univar_pairs)::cstrs - end - | (Tpackage (p1, nl1, tl1), Tpackage (p2, nl2, tl2)) -> - begin try - let ntl1 = complete_type_list env nl2 t1.level (Mty_ident p1) nl1 tl1 - and ntl2 = complete_type_list env nl1 t2.level (Mty_ident p2) nl2 tl2 - ~allow_absent:true in - let cstrs' = - List.map - (fun (n2,t2) -> (trace, List.assoc n2 ntl1, t2, !univar_pairs)) - ntl2 - in - if eq_package_path env p1 p2 then cstrs' @ cstrs - else begin - (* need to check module subtyping *) - let snap = Btype.snapshot () in - try - List.iter (fun (_, t1, t2, _) -> unify env t1 t2) cstrs'; - if !package_subtype env p1 nl1 tl1 p2 nl2 tl2 - then (Btype.backtrack snap; cstrs' @ cstrs) - else raise (Unify []) - with Unify _ -> - Btype.backtrack snap; raise Not_found - end - with Not_found -> - (trace, t1, t2, !univar_pairs)::cstrs - end - | (_, _) -> - (trace, t1, t2, !univar_pairs)::cstrs - end +exception Recursive_abbrev -and subtype_list env trace tl1 tl2 cstrs = - if List.length tl1 <> List.length tl2 then - subtype_error env trace; - List.fold_left2 - (fun cstrs t1 t2 -> subtype_rec env ((t1, t2)::trace) t1 t2 cstrs) - cstrs tl1 tl2 +(* GADT: recursive abbrevs can appear as a result of local constraints *) +exception Unification_recursive_abbrev of (type_expr * type_expr) list -and subtype_fields env trace ty1 ty2 cstrs = - (* Assume that either rest1 or rest2 is not Tvar *) - let (fields1, rest1) = flatten_fields ty1 in - let (fields2, rest2) = flatten_fields ty2 in - let (pairs, miss1, miss2) = associate_fields fields1 fields2 in - let cstrs = - if rest2.desc = Tnil then cstrs else - if miss1 = [] then - subtype_rec env ((rest1, rest2)::trace) rest1 rest2 cstrs - else - (trace, build_fields (repr ty1).level miss1 rest1, rest2, - !univar_pairs) :: cstrs - in - let cstrs = - if miss2 = [] then cstrs else - (trace, rest1, build_fields (repr ty2).level miss2 (newvar ()), - !univar_pairs) :: cstrs - in - List.fold_left - (fun cstrs (_, _k1, t1, _k2, t2) -> - (* These fields are always present *) - subtype_rec env ((t1, t2)::trace) t1 t2 cstrs) - cstrs pairs +(**** Type level management ****) -and subtype_row env trace row1 row2 cstrs = - let row1 = row_repr row1 and row2 = row_repr row2 in - let r1, r2, pairs = - merge_row_fields row1.row_fields row2.row_fields in - let more1 = repr row1.row_more - and more2 = repr row2.row_more in - match more1.desc, more2.desc with - Tconstr(p1,_,_), Tconstr(p2,_,_) when Path.same p1 p2 -> - subtype_rec env ((more1,more2)::trace) more1 more2 cstrs - | (Tvar _|Tconstr _|Tnil), (Tvar _|Tconstr _|Tnil) - when row1.row_closed && r1 = [] -> - List.fold_left - (fun cstrs (_,f1,f2) -> - match row_field_repr f1, row_field_repr f2 with - (Rpresent None|Reither(true,_,_,_)), Rpresent None -> - cstrs - | Rpresent(Some t1), Rpresent(Some t2) -> - subtype_rec env ((t1, t2)::trace) t1 t2 cstrs - | Reither(false, t1::_, _, _), Rpresent(Some t2) -> - subtype_rec env ((t1, t2)::trace) t1 t2 cstrs - | Rabsent, _ -> cstrs - | _ -> raise Exit) - cstrs pairs - | Tunivar _, Tunivar _ - when row1.row_closed = row2.row_closed && r1 = [] && r2 = [] -> - let cstrs = - subtype_rec env ((more1,more2)::trace) more1 more2 cstrs in - List.fold_left - (fun cstrs (_,f1,f2) -> - match row_field_repr f1, row_field_repr f2 with - Rpresent None, Rpresent None - | Reither(true,[],_,_), Reither(true,[],_,_) - | Rabsent, Rabsent -> - cstrs - | Rpresent(Some t1), Rpresent(Some t2) - | Reither(false,[t1],_,_), Reither(false,[t2],_,_) -> - subtype_rec env ((t1, t2)::trace) t1 t2 cstrs - | _ -> raise Exit) - cstrs pairs - | _ -> - raise Exit +let current_level = ref 0 +let nongen_level = ref 0 +let global_level = ref 1 +let saved_level = ref [] -let subtype env ty1 ty2 = - TypePairs.clear subtypes; - univar_pairs := []; - (* Build constraint set. *) - let cstrs = subtype_rec env [(ty1, ty2)] ty1 ty2 [] in - TypePairs.clear subtypes; - (* Enforce constraints. *) - function () -> - List.iter - (function (trace0, t1, t2, pairs) -> - try unify_pairs (ref env) t1 t2 pairs with Unify trace -> - raise (Subtype (expand_trace env (List.rev trace0), - List.tl (List.tl trace)))) - (List.rev cstrs) +type levels = + { current_level: int; nongen_level: int; global_level: int; + saved_level: (int * int) list; } +let save_levels () = + { current_level = !current_level; + nongen_level = !nongen_level; + global_level = !global_level; + saved_level = !saved_level } +let set_levels l = + current_level := l.current_level; + nongen_level := l.nongen_level; + global_level := l.global_level; + saved_level := l.saved_level - (*******************) - (* Miscellaneous *) - (*******************) +let get_current_level () = !current_level +let init_def level = current_level := level; nongen_level := level +let begin_def () = + saved_level := (!current_level, !nongen_level) :: !saved_level; + incr current_level; nongen_level := !current_level +let begin_class_def () = + saved_level := (!current_level, !nongen_level) :: !saved_level; + incr current_level +let raise_nongen_level () = + saved_level := (!current_level, !nongen_level) :: !saved_level; + nongen_level := !current_level +let end_def () = + let (cl, nl) = List.hd !saved_level in + saved_level := List.tl !saved_level; + current_level := cl; nongen_level := nl -(* Utility for printing. The resulting type is not used in computation. *) -let rec unalias_object ty = - let ty = repr ty in - match ty.desc with - Tfield (s, k, t1, t2) -> - newty2 ty.level (Tfield (s, k, t1, unalias_object t2)) - | Tvar _ | Tnil -> - newty2 ty.level ty.desc - | Tunivar _ -> - ty - | Tconstr _ -> - newvar2 ty.level - | _ -> - assert false +let reset_global_level () = + global_level := !current_level + 1 +let increase_global_level () = + let gl = !global_level in + global_level := !current_level; + gl +let restore_global_level gl = + global_level := gl -let unalias ty = - let ty = repr ty in - match ty.desc with - Tvar _ | Tunivar _ -> - ty - | Tvariant row -> - let row = row_repr row in - let more = row.row_more in - newty2 ty.level - (Tvariant {row with row_more = newty2 more.level more.desc}) - | Tobject (ty, nm) -> - newty2 ty.level (Tobject (unalias_object ty, nm)) - | _ -> - newty2 ty.level ty.desc +(**** Whether a path points to an object type (with hidden row variable) ****) +let is_object_type path = + let name = + match path with Path.Pident id -> Ident.name id + | Path.Pdot(_, s,_) -> s + | Path.Papply _ -> assert false + in name.[0] = '#' -(* Return the arity (as for curried functions) of the given type. *) -let rec arity ty = - match (repr ty).desc with - Tarrow(_, _t1, t2, _) -> 1 + arity t2 - | _ -> 0 +(**** Control tracing of GADT instances *) -(* Check whether an abbreviation expands to itself. *) -let cyclic_abbrev env id ty = - let rec check_cycle seen ty = - let ty = repr ty in - match ty.desc with - Tconstr (p, _tl, _abbrev) -> - p = Path.Pident id || List.memq ty seen || - begin try - check_cycle (ty :: seen) (expand_abbrev_opt env ty) - with - Cannot_expand -> false - | Unify _ -> true - end - | _ -> - false - in check_cycle [] ty +let trace_gadt_instances = ref false +let check_trace_gadt_instances env = + not !trace_gadt_instances && Env.has_local_constraints env && + (trace_gadt_instances := true; cleanup_abbrev (); true) -(* Check for non-generalizable type variables *) -exception Non_closed0 -let visited = ref TypeSet.empty +let reset_trace_gadt_instances b = + if b then trace_gadt_instances := false -let rec closed_schema_rec env ty = - let ty = repr ty in - if TypeSet.mem ty !visited then () else begin - visited := TypeSet.add ty !visited; - match ty.desc with - Tvar _ when ty.level <> generic_level -> - raise Non_closed0 - | Tconstr _ -> - let old = !visited in - begin try iter_type_expr (closed_schema_rec env) ty - with Non_closed0 -> try - visited := old; - closed_schema_rec env (try_expand_head try_expand_safe env ty) - with Cannot_expand -> - raise Non_closed0 - end - | Tfield(_, kind, t1, t2) -> - if field_kind_repr kind = Fpresent then - closed_schema_rec env t1; - closed_schema_rec env t2 - | Tvariant row -> - let row = row_repr row in - iter_row (closed_schema_rec env) row; - if not (static_row row) then closed_schema_rec env row.row_more - | _ -> - iter_type_expr (closed_schema_rec env) ty - end +let wrap_trace_gadt_instances env f x = + let b = check_trace_gadt_instances env in + let y = f x in + reset_trace_gadt_instances b; + y -(* Return whether all variables of type [ty] are generic. *) -let closed_schema env ty = - visited := TypeSet.empty; - try - closed_schema_rec env ty; - visited := TypeSet.empty; - true - with Non_closed0 -> - visited := TypeSet.empty; - false +(**** Abbreviations without parameters ****) +(* Shall reset after generalizing *) -(* Normalize a type before printing, saving... *) -(* Cannot use mark_type because deep_occur uses it too *) -let rec normalize_type_rec env visited ty = - let ty = repr ty in - if not (TypeSet.mem ty !visited) then begin - visited := TypeSet.add ty !visited; - let tm = row_of_type ty in - begin if not (is_Tconstr ty) && is_constr_row ~allow_ident:false tm then - match tm.desc with (* PR#7348 *) - Tconstr (Path.Pdot(m,i,pos), tl, _abbrev) -> - let i' = String.sub i 0 (String.length i - 4) in - log_type ty; - ty.desc <- Tconstr(Path.Pdot(m,i',pos), tl, ref Mnil) - | _ -> assert false - else match ty.desc with - | Tvariant row -> - let row = row_repr row in - let fields = List.map - (fun (l,f0) -> - let f = row_field_repr f0 in l, - match f with Reither(b, ty::(_::_ as tyl), m, e) -> - let tyl' = - List.fold_left - (fun tyl ty -> - if List.exists (fun ty' -> equal env false [ty] [ty']) tyl - then tyl else ty::tyl) - [ty] tyl - in - if f != f0 || List.length tyl' < List.length tyl then - Reither(b, List.rev tyl', m, e) - else f - | _ -> f) - row.row_fields in - let fields = - List.sort (fun (p,_) (q,_) -> compare p q) - (List.filter (fun (_,fi) -> fi <> Rabsent) fields) in - log_type ty; - ty.desc <- Tvariant {row with row_fields = fields} - | Tobject (fi, nm) -> - begin match !nm with - | None -> () - | Some (n, v :: l) -> - if deep_occur ty (newgenty (Ttuple l)) then - (* The abbreviation may be hiding something, so remove it *) - set_name nm None - else let v' = repr v in - begin match v'.desc with - | Tvar _ | Tunivar _ -> - if v' != v then set_name nm (Some (n, v' :: l)) - | Tnil -> - log_type ty; ty.desc <- Tconstr (n, l, ref Mnil) - | _ -> set_name nm None - end - | _ -> - fatal_error "Ctype.normalize_type_rec" - end; - let fi = repr fi in - if fi.level < lowest_level then () else - let fields, row = flatten_fields fi in - let fi' = build_fields fi.level fields row in - log_type ty; fi.desc <- fi'.desc - | _ -> () - end; - iter_type_expr (normalize_type_rec env visited) ty - end +let simple_abbrevs = ref Mnil + +let proper_abbrevs path tl abbrev = + if tl <> [] || !trace_gadt_instances || !Clflags.principal || + is_object_type path + then abbrev + else simple_abbrevs + +(**** Some type creators ****) + +(* Re-export generic type creators *) + +let newty2 = Btype.newty2 +let newty desc = newty2 !current_level desc + +let newvar ?name () = newty2 !current_level (Tvar name) +let newvar2 ?name level = newty2 level (Tvar name) +let new_global_var ?name () = newty2 !global_level (Tvar name) + +let newobj fields = newty (Tobject (fields, ref None)) + +let newconstr path tyl = newty (Tconstr (path, tyl, ref Mnil)) + +let none = newty (Ttuple []) (* Clearly ill-formed type *) + +(**** Representative of a type ****) + +(* Re-export repr *) +let repr = repr + +(**** Type maps ****) + +module TypePairs = + Hashtbl.Make (struct + type t = type_expr * type_expr + let equal (t1, t1') (t2, t2') = (t1 == t2) && (t1' == t2') + let hash (t, t') = t.id + 93 * t'.id + end) + + +(**** unification mode ****) + +type unification_mode = + | Expression (* unification in expression *) + | Pattern (* unification in pattern which may add local constraints *) + +let umode = ref Expression +let generate_equations = ref false +let assume_injective = ref false + +let set_mode_pattern ~generate ~injective f = + let old_unification_mode = !umode + and old_gen = !generate_equations + and old_inj = !assume_injective in + try + umode := Pattern; + generate_equations := generate; + assume_injective := injective; + let ret = f () in + umode := old_unification_mode; + generate_equations := old_gen; + assume_injective := old_inj; + ret + with e -> + umode := old_unification_mode; + generate_equations := old_gen; + assume_injective := old_inj; + raise e -let normalize_type env ty = - normalize_type_rec env (ref TypeSet.empty) ty +(*** Checks for type definitions ***) +let in_current_module = function + | Path.Pident _ -> true + | Path.Pdot _ | Path.Papply _ -> false - (*************************) - (* Remove dependencies *) - (*************************) +let in_pervasives p = + in_current_module p && + try ignore (Env.find_type p Env.initial_safe_string); true + with Not_found -> false +let is_datatype decl= + match decl.type_kind with + Type_record _ | Type_variant _ | Type_open -> true + | Type_abstract -> false -(* - Variables are left unchanged. Other type nodes are duplicated, with - levels set to generic level. - We cannot use Tsubst here, because unification may be called by - expand_abbrev. + + (**********************************************) + (* Miscellaneous operations on object types *) + (**********************************************) + +(* Note: + We need to maintain some invariants: + * cty_self must be a Tobject + * ... *) -let nondep_hash = TypeHash.create 47 -let nondep_variants = TypeHash.create 17 -let clear_hash () = - TypeHash.clear nondep_hash; TypeHash.clear nondep_variants +(**** Object field manipulation. ****) -let rec nondep_type_rec env id ty = - match ty.desc with - Tvar _ | Tunivar _ -> ty - | Tlink ty -> nondep_type_rec env id ty - | _ -> try TypeHash.find nondep_hash ty - with Not_found -> - let ty' = newgenvar () in (* Stub *) - TypeHash.add nondep_hash ty ty'; - ty'.desc <- - begin match ty.desc with - | Tconstr(p, tl, _abbrev) -> - if Path.isfree id p then - begin try - Tlink (nondep_type_rec env id - (expand_abbrev env (newty2 ty.level ty.desc))) - (* - The [Tlink] is important. The expanded type may be a - variable, or may not be completely copied yet - (recursive type), so one cannot just take its - description. - *) - with Cannot_expand | Unify _ -> - raise Not_found - end - else - Tconstr(p, List.map (nondep_type_rec env id) tl, ref Mnil) - | Tpackage(p, nl, tl) when Path.isfree id p -> - let p' = normalize_package_path env p in - if Path.isfree id p' then raise Not_found; - Tpackage (p', nl, List.map (nondep_type_rec env id) tl) - | Tobject (t1, name) -> - Tobject (nondep_type_rec env id t1, - ref (match !name with - None -> None - | Some (p, tl) -> - if Path.isfree id p then None - else Some (p, List.map (nondep_type_rec env id) tl))) - | Tvariant row -> - let row = row_repr row in - let more = repr row.row_more in - (* We must keep sharing according to the row variable *) - begin try - let ty2 = TypeHash.find nondep_variants more in - (* This variant type has been already copied *) - TypeHash.add nondep_hash ty ty2; - Tlink ty2 - with Not_found -> - (* Register new type first for recursion *) - TypeHash.add nondep_variants more ty'; - let static = static_row row in - let more' = if static then newgenty Tnil else more in - (* Return a new copy *) - let row = - copy_row (nondep_type_rec env id) true row true more' in - match row.row_name with - Some (p, _tl) when Path.isfree id p -> - Tvariant {row with row_name = None} - | _ -> Tvariant row - end - | _ -> copy_type_desc (nondep_type_rec env id) ty.desc - end; - ty' +let object_fields ty = + match (repr ty).desc with + Tobject (fields, _) -> fields + | _ -> assert false -let nondep_type env id ty = - try - let ty' = nondep_type_rec env id ty in - clear_hash (); - ty' - with Not_found -> - clear_hash (); - raise Not_found +let flatten_fields ty = + let rec flatten l ty = + let ty = repr ty in + match ty.desc with + Tfield(s, k, ty1, ty2) -> + flatten ((s, k, ty1)::l) ty2 + | _ -> + (l, ty) + in + let (l, r) = flatten [] ty in + (List.sort (fun (n, _, _) (n', _, _) -> compare n n') l, r) -let () = nondep_type' := nondep_type +let build_fields level = + List.fold_right + (fun (s, k, ty1) ty2 -> newty2 level (Tfield(s, k, ty1, ty2))) -let unroll_abbrev id tl ty = - let ty = repr ty and path = Path.Pident id in - if is_Tvar ty || (List.exists (deep_occur ty) tl) - || is_object_type path then - ty - else - let ty' = newty2 ty.level ty.desc in - link_type ty (newty2 ty.level (Tconstr (path, tl, ref Mnil))); - ty' +let associate_fields fields1 fields2 = + let rec associate p s s' = + function + (l, []) -> + (List.rev p, (List.rev s) @ l, List.rev s') + | ([], l') -> + (List.rev p, List.rev s, (List.rev s') @ l') + | ((n, k, t)::r, (n', k', t')::r') when n = n' -> + associate ((n, k, t, k', t')::p) s s' (r, r') + | ((n, k, t)::r, ((n', _k', _t')::_ as l')) when n < n' -> + associate p ((n, k, t)::s) s' (r, l') + | (((_n, _k, _t)::_ as l), (n', k', t')::r') (* when n > n' *) -> + associate p s ((n', k', t')::s') (l, r') + in + associate [] [] [] (fields1, fields2) -(* Preserve sharing inside type declarations. *) -let nondep_type_decl env mid id is_covariant decl = - try - let params = List.map (nondep_type_rec env mid) decl.type_params in - let tk = - try map_kind (nondep_type_rec env mid) decl.type_kind - with Not_found when is_covariant -> Type_abstract - and tm = - try match decl.type_manifest with - None -> None - | Some ty -> - Some (unroll_abbrev id params (nondep_type_rec env mid ty)) - with Not_found when is_covariant -> - None - in - clear_hash (); - let priv = - match tm with - | Some ty when Btype.has_constr_row ty -> Private - | _ -> decl.type_private - in - { type_params = params; - type_arity = decl.type_arity; - type_kind = tk; - type_manifest = tm; - type_private = priv; - type_variance = decl.type_variance; - type_newtype_level = None; - type_loc = decl.type_loc; - type_attributes = decl.type_attributes; - type_immediate = decl.type_immediate; - type_unboxed = decl.type_unboxed; - } - with Not_found -> - clear_hash (); - raise Not_found +(**** Check whether an object is open ****) -(* Preserve sharing inside extension constructors. *) -let nondep_extension_constructor env mid ext = - try - let type_path, type_params = - if Path.isfree mid ext.ext_type_path then - begin - let ty = - newgenty (Tconstr(ext.ext_type_path, ext.ext_type_params, ref Mnil)) - in - let ty' = nondep_type_rec env mid ty in - match (repr ty').desc with - Tconstr(p, tl, _) -> p, tl - | _ -> raise Not_found - end - else - let type_params = - List.map (nondep_type_rec env mid) ext.ext_type_params - in - ext.ext_type_path, type_params - in - let args = map_type_expr_cstr_args (nondep_type_rec env mid) ext.ext_args in - let ret_type = may_map (nondep_type_rec env mid) ext.ext_ret_type in - clear_hash (); - { ext_type_path = type_path; - ext_type_params = type_params; - ext_args = args; - ext_ret_type = ret_type; - ext_private = ext.ext_private; - ext_attributes = ext.ext_attributes; - ext_loc = ext.ext_loc; - } - with Not_found -> - clear_hash (); - raise Not_found +(* +++ The abbreviation should eventually be expanded *) +let rec object_row ty = + let ty = repr ty in + match ty.desc with + Tobject (t, _) -> object_row t + | Tfield(_, _, _, t) -> object_row t + | _ -> ty +let opened_object ty = + match (object_row ty).desc with + | Tvar _ | Tunivar _ | Tconstr _ -> true + | _ -> false -(* Preserve sharing inside class types. *) -let nondep_class_signature env id sign = - { csig_self = nondep_type_rec env id sign.csig_self; - csig_vars = - Vars.map (function (m, v, t) -> (m, v, nondep_type_rec env id t)) - sign.csig_vars; - csig_concr = sign.csig_concr; - csig_inher = - List.map (fun (p,tl) -> (p, List.map (nondep_type_rec env id) tl)) - sign.csig_inher } +let concrete_object ty = + match (object_row ty).desc with + | Tvar _ -> false + | _ -> true -let rec nondep_class_type env id = - function - Cty_constr (p, _, cty) when Path.isfree id p -> - nondep_class_type env id cty - | Cty_constr (p, tyl, cty) -> - Cty_constr (p, List.map (nondep_type_rec env id) tyl, - nondep_class_type env id cty) - | Cty_signature sign -> - Cty_signature (nondep_class_signature env id sign) - | Cty_arrow (l, ty, cty) -> - Cty_arrow (l, nondep_type_rec env id ty, nondep_class_type env id cty) +(**** Close an object ****) -let nondep_class_declaration env id decl = - assert (not (Path.isfree id decl.cty_path)); - let decl = - { cty_params = List.map (nondep_type_rec env id) decl.cty_params; - cty_variance = decl.cty_variance; - cty_type = nondep_class_type env id decl.cty_type; - cty_path = decl.cty_path; - cty_new = - begin match decl.cty_new with - None -> None - | Some ty -> Some (nondep_type_rec env id ty) - end; - cty_loc = decl.cty_loc; - cty_attributes = decl.cty_attributes; - } +let close_object ty = + let rec close ty = + let ty = repr ty in + match ty.desc with + Tvar _ -> + link_type ty (newty2 ty.level Tnil) + | Tfield(_, _, _, ty') -> close ty' + | _ -> assert false in - clear_hash (); - decl + match (repr ty).desc with + Tobject (ty, _) -> close ty + | _ -> assert false -let nondep_cltype_declaration env id decl = - assert (not (Path.isfree id decl.clty_path)); - let decl = - { clty_params = List.map (nondep_type_rec env id) decl.clty_params; - clty_variance = decl.clty_variance; - clty_type = nondep_class_type env id decl.clty_type; - clty_path = decl.clty_path; - clty_loc = decl.clty_loc; - clty_attributes = decl.clty_attributes; - } +(**** Row variable of an object type ****) + +let row_variable ty = + let rec find ty = + let ty = repr ty in + match ty.desc with + Tfield (_, _, _, ty) -> find ty + | Tvar _ -> ty + | _ -> assert false in - clear_hash (); - decl + match (repr ty).desc with + Tobject (fi, _) -> find fi + | _ -> assert false -(* collapse conjunctive types in class parameters *) -let rec collapse_conj env visited ty = - let ty = repr ty in - if List.memq ty visited then () else - let visited = ty :: visited in - match ty.desc with - Tvariant row -> - let row = row_repr row in +(**** Object name manipulation ****) +(* +++ Bientot obsolete *) + +let set_object_name id rv params ty = + match (repr ty).desc with + Tobject (_fi, nm) -> + set_name nm (Some (Path.Pident id, rv::params)) + | _ -> + assert false + +let remove_object_name ty = + match (repr ty).desc with + Tobject (_, nm) -> set_name nm None + | Tconstr (_, _, _) -> () + | _ -> fatal_error "Ctype.remove_object_name" + +(**** Hiding of private methods ****) + +let hide_private_methods ty = + match (repr ty).desc with + Tobject (fi, nm) -> + nm := None; + let (fl, _) = flatten_fields fi in List.iter - (fun (_l,fi) -> - match row_field_repr fi with - Reither (c, t1::(_::_ as tl), m, e) -> - List.iter (unify env t1) tl; - set_row_field e (Reither (c, [t1], m, ref None)) - | _ -> - ()) - row.row_fields; - iter_row (collapse_conj env visited) row + (function (_, k, _) -> + match field_kind_repr k with + Fvar r -> set_kind r Fabsent + | _ -> ()) + fl | _ -> - iter_type_expr (collapse_conj env visited) ty + assert false -let collapse_conj_params env params = - List.iter (collapse_conj env []) params -let same_constr env t1 t2 = - let t1 = expand_head env t1 in - let t2 = expand_head env t2 in - match t1.desc, t2.desc with - | Tconstr (p1, _, _), Tconstr (p2, _, _) -> Path.same p1 p2 - | _ -> false + (*******************************) + (* Operations on class types *) + (*******************************) -let () = - Env.same_constr := same_constr -let maybe_pointer_type env typ = - match (repr typ).desc with - | Tconstr(p, _args, _abbrev) -> - begin try - let type_decl = Env.find_type p env in - not type_decl.type_immediate - with Not_found -> true - (* This can happen due to e.g. missing -I options, - causing some .cmi files to be unavailable. - Maybe we should emit a warning. *) - end - | Tvariant row -> - let row = Btype.row_repr row in - (* if all labels are devoid of arguments, not a pointer *) - not row.row_closed - || List.exists - (function - | _, (Rpresent (Some _) | Reither (false, _, _, _)) -> true - | _ -> false) - row.row_fields - | _ -> true +let rec signature_of_class_type = + function + Cty_constr (_, _, cty) -> signature_of_class_type cty + | Cty_signature sign -> sign + | Cty_arrow (_, _, cty) -> signature_of_class_type cty -end -module Printtyp : sig -#1 "printtyp.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let self_type cty = + repr (signature_of_class_type cty).csig_self -(* Printing functions *) +let rec class_type_arity = + function + Cty_constr (_, _, cty) -> class_type_arity cty + | Cty_signature _ -> 0 + | Cty_arrow (_, _, cty) -> 1 + class_type_arity cty -open Format -open Types -open Outcometree -val longident: formatter -> Longident.t -> unit -val ident: formatter -> Ident.t -> unit -val tree_of_path: Path.t -> out_ident -val path: formatter -> Path.t -> unit -val string_of_path: Path.t -> string -val raw_type_expr: formatter -> type_expr -> unit -val string_of_label: Asttypes.arg_label -> string + (*******************************************) + (* Miscellaneous operations on row types *) + (*******************************************) -val wrap_printing_env: Env.t -> (unit -> 'a) -> 'a - (* Call the function using the environment for type path shortening *) - (* This affects all the printing functions below *) +let sort_row_fields = List.sort (fun (p,_) (q,_) -> compare p q) -val reset: unit -> unit -val mark_loops: type_expr -> unit -val reset_and_mark_loops: type_expr -> unit -val reset_and_mark_loops_list: type_expr list -> unit -val type_expr: formatter -> type_expr -> unit -val constructor_arguments: formatter -> constructor_arguments -> unit -val tree_of_type_scheme: type_expr -> out_type -val type_sch : formatter -> type_expr -> unit -val type_scheme: formatter -> type_expr -> unit -(* Maxence *) -val reset_names: unit -> unit -val type_scheme_max: ?b_reset_names: bool -> - formatter -> type_expr -> unit -(* End Maxence *) -val tree_of_value_description: Ident.t -> value_description -> out_sig_item -val value_description: Ident.t -> formatter -> value_description -> unit -val tree_of_type_declaration: - Ident.t -> type_declaration -> rec_status -> out_sig_item -val type_declaration: Ident.t -> formatter -> type_declaration -> unit -val tree_of_extension_constructor: - Ident.t -> extension_constructor -> ext_status -> out_sig_item -val extension_constructor: - Ident.t -> formatter -> extension_constructor -> unit -val tree_of_module: - Ident.t -> ?ellipsis:bool -> module_type -> rec_status -> out_sig_item -val modtype: formatter -> module_type -> unit -val signature: formatter -> signature -> unit -val tree_of_modtype_declaration: - Ident.t -> modtype_declaration -> out_sig_item -val tree_of_signature: Types.signature -> out_sig_item list -val tree_of_typexp: bool -> type_expr -> out_type -val modtype_declaration: Ident.t -> formatter -> modtype_declaration -> unit -val class_type: formatter -> class_type -> unit -val tree_of_class_declaration: - Ident.t -> class_declaration -> rec_status -> out_sig_item -val class_declaration: Ident.t -> formatter -> class_declaration -> unit -val tree_of_cltype_declaration: - Ident.t -> class_type_declaration -> rec_status -> out_sig_item -val cltype_declaration: Ident.t -> formatter -> class_type_declaration -> unit -val type_expansion: type_expr -> Format.formatter -> type_expr -> unit -val prepare_expansion: type_expr * type_expr -> type_expr * type_expr -val trace: - bool -> bool-> string -> formatter -> (type_expr * type_expr) list -> unit -val report_unification_error: - formatter -> Env.t -> ?unif:bool -> (type_expr * type_expr) list -> - (formatter -> unit) -> (formatter -> unit) -> - unit +let rec merge_rf r1 r2 pairs fi1 fi2 = + match fi1, fi2 with + (l1,f1 as p1)::fi1', (l2,f2 as p2)::fi2' -> + if l1 = l2 then merge_rf r1 r2 ((l1,f1,f2)::pairs) fi1' fi2' else + if l1 < l2 then merge_rf (p1::r1) r2 pairs fi1' fi2 else + merge_rf r1 (p2::r2) pairs fi1 fi2' + | [], _ -> (List.rev r1, List.rev_append r2 fi2, pairs) + | _, [] -> (List.rev_append r1 fi1, List.rev r2, pairs) + +let merge_row_fields fi1 fi2 = + match fi1, fi2 with + [], _ | _, [] -> (fi1, fi2, []) + | [p1], _ when not (List.mem_assoc (fst p1) fi2) -> (fi1, fi2, []) + | _, [p2] when not (List.mem_assoc (fst p2) fi1) -> (fi1, fi2, []) + | _ -> merge_rf [] [] [] (sort_row_fields fi1) (sort_row_fields fi2) + +let rec filter_row_fields erase = function + [] -> [] + | (_l,f as p)::fi -> + let fi = filter_row_fields erase fi in + match row_field_repr f with + Rabsent -> fi + | Reither(_,_,false,e) when erase -> set_row_field e Rabsent; fi + | _ -> p :: fi + (**************************************) + (* Check genericity of type schemes *) + (**************************************) -val super_report_unification_error: - formatter -> Env.t -> ?unif:bool -> (type_expr * type_expr) list -> - (formatter -> unit) -> (formatter -> unit) -> - unit +exception Non_closed of type_expr * bool -val report_subtyping_error: - formatter -> Env.t -> (type_expr * type_expr) list -> - string -> (type_expr * type_expr) list -> unit -val report_ambiguous_type_error: - formatter -> Env.t -> (Path.t * Path.t) -> (Path.t * Path.t) list -> - (formatter -> unit) -> (formatter -> unit) -> (formatter -> unit) -> unit +let free_variables = ref [] +let really_closed = ref None -(* for toploop *) -val print_items: (Env.t -> signature_item -> 'a option) -> - Env.t -> signature_item list -> (out_sig_item * 'a option) list +let rec free_vars_rec real ty = + let ty = repr ty in + if ty.level >= lowest_level then begin + ty.level <- pivot_level - ty.level; + begin match ty.desc, !really_closed with + Tvar _, _ -> + free_variables := (ty, real) :: !free_variables + | Tconstr (path, tl, _), Some env -> + begin try + let (_, body, _) = Env.find_type_expansion path env in + if (repr body).level <> generic_level then + free_variables := (ty, real) :: !free_variables + with Not_found -> () + end; + List.iter (free_vars_rec true) tl +(* Do not count "virtual" free variables + | Tobject(ty, {contents = Some (_, p)}) -> + free_vars_rec false ty; List.iter (free_vars_rec true) p +*) + | Tobject (ty, _), _ -> + free_vars_rec false ty + | Tfield (_, _, ty1, ty2), _ -> + free_vars_rec true ty1; free_vars_rec false ty2 + | Tvariant row, _ -> + let row = row_repr row in + iter_row (free_vars_rec true) row; + if not (static_row row) then free_vars_rec false row.row_more + | _ -> + iter_type_expr (free_vars_rec true) ty + end; + end -end = struct -#1 "printtyp.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy and Jerome Vouillon, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let free_vars ?env ty = + free_variables := []; + really_closed := env; + free_vars_rec true ty; + let res = !free_variables in + free_variables := []; + really_closed := None; + res -(* Printing functions *) +let free_variables ?env ty = + let tl = List.map fst (free_vars ?env ty) in + unmark_type ty; + tl -open Misc -open Ctype -open Format -open Longident -open Path -open Asttypes -open Types -open Btype -open Outcometree +let closed_type ty = + match free_vars ty with + [] -> () + | (v, real) :: _ -> raise (Non_closed (v, real)) -(* Print a long identifier *) +let closed_parameterized_type params ty = + List.iter mark_type params; + let ok = + try closed_type ty; true with Non_closed _ -> false in + List.iter unmark_type params; + unmark_type ty; + ok -let rec longident ppf = function - | Lident s -> pp_print_string ppf s - | Ldot(p, s) -> fprintf ppf "%a.%s" longident p s - | Lapply(p1, p2) -> fprintf ppf "%a(%a)" longident p1 longident p2 +let closed_type_decl decl = + try + List.iter mark_type decl.type_params; + begin match decl.type_kind with + Type_abstract -> + () + | Type_variant v -> + List.iter + (fun {cd_args; cd_res; _} -> + match cd_res with + | Some _ -> () + | None -> + match cd_args with + | Cstr_tuple l -> List.iter closed_type l + | Cstr_record l -> List.iter (fun l -> closed_type l.ld_type) l + ) + v + | Type_record(r, _rep) -> + List.iter (fun l -> closed_type l.ld_type) r + | Type_open -> () + end; + begin match decl.type_manifest with + None -> () + | Some ty -> closed_type ty + end; + unmark_type_decl decl; + None + with Non_closed (ty, _) -> + unmark_type_decl decl; + Some ty -(* Print an identifier *) +let closed_extension_constructor ext = + try + List.iter mark_type ext.ext_type_params; + begin match ext.ext_ret_type with + | Some _ -> () + | None -> iter_type_expr_cstr_args closed_type ext.ext_args + end; + unmark_extension_constructor ext; + None + with Non_closed (ty, _) -> + unmark_extension_constructor ext; + Some ty -let unique_names = ref Ident.empty +type closed_class_failure = + CC_Method of type_expr * bool * string * type_expr + | CC_Value of type_expr * bool * string * type_expr -let ident_name id = - try Ident.find_same id !unique_names with Not_found -> Ident.name id +exception CCFailure of closed_class_failure -let add_unique id = - try ignore (Ident.find_same id !unique_names) - with Not_found -> - unique_names := Ident.add id (Ident.unique_toplevel_name id) !unique_names +let closed_class params sign = + let ty = object_fields (repr sign.csig_self) in + let (fields, rest) = flatten_fields ty in + List.iter mark_type params; + mark_type rest; + List.iter + (fun (lab, _, ty) -> if lab = dummy_method then mark_type ty) + fields; + try + mark_type_node (repr sign.csig_self); + List.iter + (fun (lab, kind, ty) -> + if field_kind_repr kind = Fpresent then + try closed_type ty with Non_closed (ty0, real) -> + raise (CCFailure (CC_Method (ty0, real, lab, ty)))) + fields; + mark_type_params (repr sign.csig_self); + List.iter unmark_type params; + unmark_class_signature sign; + None + with CCFailure reason -> + mark_type_params (repr sign.csig_self); + List.iter unmark_type params; + unmark_class_signature sign; + Some reason -let ident ppf id = pp_print_string ppf (ident_name id) -(* Print a path *) + (**********************) + (* Type duplication *) + (**********************) -let ident_pervasives = Ident.create_persistent "Pervasives" -let printing_env = ref Env.empty -let non_shadowed_pervasive = function - | Pdot(Pident id, s, _pos) as path -> - Ident.same id ident_pervasives && - (try Path.same path (Env.lookup_type (Lident s) !printing_env) - with Not_found -> true) - | _ -> false -let rec tree_of_path = function - | Pident id -> - Oide_ident (ident_name id) - | Pdot(_, s, _pos) as path when non_shadowed_pervasive path -> - Oide_ident s - | Pdot(p, s, _pos) -> - Oide_dot (tree_of_path p, s) - | Papply(p1, p2) -> - Oide_apply (tree_of_path p1, tree_of_path p2) +(* Duplicate a type, preserving only type variables *) +let duplicate_type ty = + Subst.type_expr Subst.identity ty -let rec path ppf = function - | Pident id -> - ident ppf id - | Pdot(_, s, _pos) as path when non_shadowed_pervasive path -> - pp_print_string ppf s - | Pdot(p, s, _pos) -> - path ppf p; - pp_print_char ppf '.'; - pp_print_string ppf s - | Papply(p1, p2) -> - fprintf ppf "%a(%a)" path p1 path p2 +(* Same, for class types *) +let duplicate_class_type ty = + Subst.class_type Subst.identity ty -let rec string_of_out_ident = function - | Oide_ident s -> s - | Oide_dot (id, s) -> String.concat "." [string_of_out_ident id; s] - | Oide_apply (id1, id2) -> - String.concat "" - [string_of_out_ident id1; "("; string_of_out_ident id2; ")"] -let string_of_path p = string_of_out_ident (tree_of_path p) + (*****************************) + (* Type level manipulation *) + (*****************************) -(* Print a recursive annotation *) +(* + It would be a bit more efficient to remove abbreviation expansions + rather than generalizing them: these expansions will usually not be + used anymore. However, this is not possible in the general case, as + [expand_abbrev] (via [subst]) requires these expansions to be + preserved. Does it worth duplicating this code ? +*) +let rec generalize ty = + let ty = repr ty in + if (ty.level > !current_level) && (ty.level <> generic_level) then begin + set_level ty generic_level; + begin match ty.desc with + Tconstr (_, _, abbrev) -> + iter_abbrev generalize !abbrev + | _ -> () + end; + iter_type_expr generalize ty + end -let tree_of_rec = function - | Trec_not -> Orec_not - | Trec_first -> Orec_first - | Trec_next -> Orec_next +let generalize ty = + simple_abbrevs := Mnil; + generalize ty -(* Print a raw type expression, with sharing *) +(* Generalize the structure and lower the variables *) -let raw_list pr ppf = function - [] -> fprintf ppf "[]" - | a :: l -> - fprintf ppf "@[<1>[%a%t]@]" pr a - (fun ppf -> List.iter (fun x -> fprintf ppf ";@,%a" pr x) l) +let rec generalize_structure var_level ty = + let ty = repr ty in + if ty.level <> generic_level then begin + if is_Tvar ty && ty.level > var_level then + set_level ty var_level + else if + ty.level > !current_level && + match ty.desc with + Tconstr (p, _, abbrev) -> + not (is_object_type p) && (abbrev := Mnil; true) + | _ -> true + then begin + set_level ty generic_level; + iter_type_expr (generalize_structure var_level) ty + end + end -let kind_vars = ref [] -let kind_count = ref 0 +let generalize_structure var_level ty = + simple_abbrevs := Mnil; + generalize_structure var_level ty -let rec safe_kind_repr v = function - Fvar {contents=Some k} -> - if List.memq k v then "Fvar loop" else - safe_kind_repr (k::v) k - | Fvar r -> - let vid = - try List.assq r !kind_vars - with Not_found -> - let c = incr kind_count; !kind_count in - kind_vars := (r,c) :: !kind_vars; - c - in - Printf.sprintf "Fvar {None}@%d" vid - | Fpresent -> "Fpresent" - | Fabsent -> "Fabsent" +(* Generalize the spine of a function, if the level >= !current_level *) -let rec safe_commu_repr v = function - Cok -> "Cok" - | Cunknown -> "Cunknown" - | Clink r -> - if List.memq r v then "Clink loop" else - safe_commu_repr (r::v) !r +let rec generalize_spine ty = + let ty = repr ty in + if ty.level < !current_level || ty.level = generic_level then () else + match ty.desc with + Tarrow (_, ty1, ty2, _) -> + set_level ty generic_level; + generalize_spine ty1; + generalize_spine ty2; + | Tpoly (ty', _) -> + set_level ty generic_level; + generalize_spine ty' + | Ttuple tyl + | Tpackage (_, _, tyl) -> + set_level ty generic_level; + List.iter generalize_spine tyl + | Tconstr (p, tyl, memo) when not (is_object_type p) -> + set_level ty generic_level; + memo := Mnil; + List.iter generalize_spine tyl + | _ -> () -let rec safe_repr v = function - {desc = Tlink t} when not (List.memq t v) -> - safe_repr (t::v) t - | t -> t +let forward_try_expand_once = (* Forward declaration *) + ref (fun _env _ty -> raise Cannot_expand) -let rec list_of_memo = function - Mnil -> [] - | Mcons (_priv, p, _t1, _t2, rem) -> p :: list_of_memo rem - | Mlink rem -> list_of_memo !rem +(* + Lower the levels of a type (assume [level] is not + [generic_level]). +*) +(* + The level of a type constructor must be greater than its binding + time. That way, a type constructor cannot escape the scope of its + definition, as would be the case in + let x = ref [] + module M = struct type t let _ = (x : t list ref) end + (without this constraint, the type system would actually be unsound.) +*) +let get_level env p = + try + match (Env.find_type p env).type_newtype_level with + | None -> Path.binding_time p + | Some (x, _) -> x + with + | Not_found -> + (* no newtypes in predef *) + Path.binding_time p -let print_name ppf = function - None -> fprintf ppf "None" - | Some name -> fprintf ppf "\"%s\"" name +let rec normalize_package_path env p = + let t = + try (Env.find_modtype p env).mtd_type + with Not_found -> None + in + match t with + | Some (Mty_ident p) -> normalize_package_path env p + | Some (Mty_signature _ | Mty_functor _ | Mty_alias _) | None -> + match p with + Path.Pdot (p1, s, n) -> + (* For module aliases *) + let p1' = Env.normalize_path None env p1 in + if Path.same p1 p1' then p else + normalize_package_path env (Path.Pdot (p1', s, n)) + | _ -> p -let string_of_label = function - Nolabel -> "" - | Labelled s -> s - | Optional s -> "?"^s +let rec update_level env level expand ty = + let ty = repr ty in + if ty.level > level then begin + begin match Env.gadt_instance_level env ty with + Some lv -> if level < lv then raise (Unify [(ty, newvar2 level)]) + | None -> () + end; + match ty.desc with + Tconstr(p, _tl, _abbrev) when level < get_level env p -> + (* Try first to replace an abbreviation by its expansion. *) + begin try + (* if is_newtype env p then raise Cannot_expand; *) + link_type ty (!forward_try_expand_once env ty); + update_level env level expand ty + with Cannot_expand -> + (* +++ Levels should be restored... *) + (* Format.printf "update_level: %i < %i@." level (get_level env p); *) + if level < get_level env p then raise (Unify [(ty, newvar2 level)]); + iter_type_expr (update_level env level expand) ty + end + | Tconstr(_, _ :: _, _) when expand -> + begin try + link_type ty (!forward_try_expand_once env ty); + update_level env level expand ty + with Cannot_expand -> + set_level ty level; + iter_type_expr (update_level env level expand) ty + end + | Tpackage (p, nl, tl) when level < Path.binding_time p -> + let p' = normalize_package_path env p in + if Path.same p p' then raise (Unify [(ty, newvar2 level)]); + log_type ty; ty.desc <- Tpackage (p', nl, tl); + update_level env level expand ty + | Tobject(_, ({contents=Some(p, _tl)} as nm)) + when level < get_level env p -> + set_name nm None; + update_level env level expand ty + | Tvariant row -> + let row = row_repr row in + begin match row.row_name with + | Some (p, _tl) when level < get_level env p -> + log_type ty; + ty.desc <- Tvariant {row with row_name = None} + | _ -> () + end; + set_level ty level; + iter_type_expr (update_level env level expand) ty + | Tfield(lab, _, ty1, _) + when lab = dummy_method && (repr ty1).level > level -> + raise (Unify [(ty1, newvar2 level)]) + | _ -> + set_level ty level; + (* XXX what about abbreviations in Tconstr ? *) + iter_type_expr (update_level env level expand) ty + end -let visited = ref [] -let rec raw_type ppf ty = - let ty = safe_repr [] ty in - if List.memq ty !visited then fprintf ppf "{id=%d}" ty.id else begin - visited := ty :: !visited; - fprintf ppf "@[<1>{id=%d;level=%d;desc=@,%a}@]" ty.id ty.level - raw_type_desc ty.desc +(* First try without expanding, then expand everything, + to avoid combinatorial blow-up *) +let update_level env level ty = + let ty = repr ty in + if ty.level > level then begin + let snap = snapshot () in + try + update_level env level false ty + with Unify _ -> + backtrack snap; + update_level env level true ty end -and raw_type_list tl = raw_list raw_type tl -and raw_type_desc ppf = function - Tvar name -> fprintf ppf "Tvar %a" print_name name - | Tarrow(l,t1,t2,c) -> - fprintf ppf "@[Tarrow(\"%s\",@,%a,@,%a,@,%s)@]" - (string_of_label l) raw_type t1 raw_type t2 - (safe_commu_repr [] c) - | Ttuple tl -> - fprintf ppf "@[<1>Ttuple@,%a@]" raw_type_list tl - | Tconstr (p, tl, abbrev) -> - fprintf ppf "@[Tconstr(@,%a,@,%a,@,%a)@]" path p - raw_type_list tl - (raw_list path) (list_of_memo !abbrev) - | Tobject (t, nm) -> - fprintf ppf "@[Tobject(@,%a,@,@[<1>ref%t@])@]" raw_type t - (fun ppf -> - match !nm with None -> fprintf ppf " None" - | Some(p,tl) -> - fprintf ppf "(Some(@,%a,@,%a))" path p raw_type_list tl) - | Tfield (f, k, t1, t2) -> - fprintf ppf "@[Tfield(@,%s,@,%s,@,%a,@;<0 -1>%a)@]" f - (safe_kind_repr [] k) - raw_type t1 raw_type t2 - | Tnil -> fprintf ppf "Tnil" - | Tlink t -> fprintf ppf "@[<1>Tlink@,%a@]" raw_type t - | Tsubst t -> fprintf ppf "@[<1>Tsubst@,%a@]" raw_type t - | Tunivar name -> fprintf ppf "Tunivar %a" print_name name - | Tpoly (t, tl) -> - fprintf ppf "@[Tpoly(@,%a,@,%a)@]" - raw_type t - raw_type_list tl - | Tvariant row -> - fprintf ppf - "@[{@[%s@,%a;@]@ @[%s@,%a;@]@ %s%B;@ %s%B;@ @[<1>%s%t@]}@]" - "row_fields=" - (raw_list (fun ppf (l, f) -> - fprintf ppf "@[%s,@ %a@]" l raw_field f)) - row.row_fields - "row_more=" raw_type row.row_more - "row_closed=" row.row_closed - "row_fixed=" row.row_fixed - "row_name=" - (fun ppf -> - match row.row_name with None -> fprintf ppf "None" - | Some(p,tl) -> - fprintf ppf "Some(@,%a,@,%a)" path p raw_type_list tl) - | Tpackage (p, _, tl) -> - fprintf ppf "@[Tpackage(@,%a@,%a)@]" path p - raw_type_list tl -and raw_field ppf = function - Rpresent None -> fprintf ppf "Rpresent None" - | Rpresent (Some t) -> fprintf ppf "@[<1>Rpresent(Some@,%a)@]" raw_type t - | Reither (c,tl,m,e) -> - fprintf ppf "@[Reither(%B,@,%a,@,%B,@,@[<1>ref%t@])@]" c - raw_type_list tl m - (fun ppf -> - match !e with None -> fprintf ppf " None" - | Some f -> fprintf ppf "@,@[<1>(%a)@]" raw_field f) - | Rabsent -> fprintf ppf "Rabsent" +(* Generalize and lower levels of contravariant branches simultaneously *) -let raw_type_expr ppf t = - visited := []; kind_vars := []; kind_count := 0; - raw_type ppf t; - visited := []; kind_vars := [] +let rec generalize_expansive env var_level visited ty = + let ty = repr ty in + if ty.level = generic_level || ty.level <= var_level then () else + if not (Hashtbl.mem visited ty.id) then begin + Hashtbl.add visited ty.id (); + match ty.desc with + Tconstr (path, tyl, abbrev) -> + let variance = + try (Env.find_type path env).type_variance + with Not_found -> List.map (fun _ -> Variance.may_inv) tyl in + abbrev := Mnil; + List.iter2 + (fun v t -> + if Variance.(mem May_weak v) + then generalize_structure var_level t + else generalize_expansive env var_level visited t) + variance tyl + | Tpackage (_, _, tyl) -> + List.iter (generalize_structure var_level) tyl + | Tarrow (_, t1, t2, _) -> + generalize_structure var_level t1; + generalize_expansive env var_level visited t2 + | _ -> + iter_type_expr (generalize_expansive env var_level visited) ty + end -let () = Btype.print_raw := raw_type_expr +let generalize_expansive env ty = + simple_abbrevs := Mnil; + try + generalize_expansive env !nongen_level (Hashtbl.create 7) ty + with Unify ([_, ty'] as tr) -> + raise (Unify ((ty, ty') :: tr)) -(* Normalize paths *) +let generalize_global ty = generalize_structure !global_level ty +let generalize_structure ty = generalize_structure !current_level ty -type param_subst = Id | Nth of int | Map of int list +(* Correct the levels of type [ty]. *) +let correct_levels ty = + duplicate_type ty -let is_nth = function - Nth _ -> true - | _ -> false +(* Only generalize the type ty0 in ty *) +let limited_generalize ty0 ty = + let ty0 = repr ty0 in -let compose l1 = function - | Id -> Map l1 - | Map l2 -> Map (List.map (List.nth l1) l2) - | Nth n -> Nth (List.nth l1 n) + let graph = Hashtbl.create 17 in + let idx = ref lowest_level in + let roots = ref [] in -let apply_subst s1 tyl = - if tyl = [] then [] - (* cf. PR#7543: Typemod.type_package doesn't respect type constructor arity *) - else - match s1 with - Nth n1 -> [List.nth tyl n1] - | Map l1 -> List.map (List.nth tyl) l1 - | Id -> tyl + let rec inverse pty ty = + let ty = repr ty in + if (ty.level > !current_level) || (ty.level = generic_level) then begin + decr idx; + Hashtbl.add graph !idx (ty, ref pty); + if (ty.level = generic_level) || (ty == ty0) then + roots := ty :: !roots; + set_level ty !idx; + iter_type_expr (inverse [ty]) ty + end else if ty.level < lowest_level then begin + let (_, parents) = Hashtbl.find graph ty.level in + parents := pty @ !parents + end -type best_path = Paths of Path.t list | Best of Path.t + and generalize_parents ty = + let idx = ty.level in + if idx <> generic_level then begin + set_level ty generic_level; + List.iter generalize_parents !(snd (Hashtbl.find graph idx)); + (* Special case for rows: must generalize the row variable *) + match ty.desc with + Tvariant row -> + let more = row_more row in + let lv = more.level in + if (lv < lowest_level || lv > !current_level) + && lv <> generic_level then set_level more generic_level + | _ -> () + end + in -let printing_depth = ref 0 -let printing_cont = ref ([] : Env.iter_cont list) -let printing_old = ref Env.empty -let printing_pers = ref Concr.empty -module PathMap = Map.Make(Path) -let printing_map = ref PathMap.empty + inverse [] ty; + if ty0.level < lowest_level then + iter_type_expr (inverse []) ty0; + List.iter generalize_parents !roots; + Hashtbl.iter + (fun _ (ty, _) -> + if ty.level <> generic_level then set_level ty !current_level) + graph -let same_type t t' = repr t == repr t' -let rec index l x = - match l with - [] -> raise Not_found - | a :: l -> if x == a then 0 else 1 + index l x +(* Compute statically the free univars of all nodes in a type *) +(* This avoids doing it repeatedly during instantiation *) -let rec uniq = function - [] -> true - | a :: l -> not (List.memq a l) && uniq l +type inv_type_expr = + { inv_type : type_expr; + mutable inv_parents : inv_type_expr list } -let rec normalize_type_path ?(cache=false) env p = +let rec inv_type hash pty ty = + let ty = repr ty in try - let (params, ty, _) = Env.find_type_expansion p env in - let params = List.map repr params in - match repr ty with - {desc = Tconstr (p1, tyl, _)} -> - let tyl = List.map repr tyl in - if List.length params = List.length tyl - && List.for_all2 (==) params tyl - then normalize_type_path ~cache env p1 - else if cache || List.length params <= List.length tyl - || not (uniq tyl) then (p, Id) - else - let l1 = List.map (index params) tyl in - let (p2, s2) = normalize_type_path ~cache env p1 in - (p2, compose l1 s2) - | ty -> - (p, Nth (index params ty)) - with - Not_found -> - (Env.normalize_path None env p, Id) + let inv = TypeHash.find hash ty in + inv.inv_parents <- pty @ inv.inv_parents + with Not_found -> + let inv = { inv_type = ty; inv_parents = pty } in + TypeHash.add hash ty inv; + iter_type_expr (inv_type hash [inv]) ty -let penalty s = - if s <> "" && s.[0] = '_' then - 10 - else - try - for i = 0 to String.length s - 2 do - if s.[i] = '_' && s.[i + 1] = '_' then - raise Exit - done; - 1 - with Exit -> 10 +let compute_univars ty = + let inverted = TypeHash.create 17 in + inv_type inverted [] ty; + let node_univars = TypeHash.create 17 in + let rec add_univar univ inv = + match inv.inv_type.desc with + Tpoly (_ty, tl) when List.memq univ (List.map repr tl) -> () + | _ -> + try + let univs = TypeHash.find node_univars inv.inv_type in + if not (TypeSet.mem univ !univs) then begin + univs := TypeSet.add univ !univs; + List.iter (add_univar univ) inv.inv_parents + end + with Not_found -> + TypeHash.add node_univars inv.inv_type (ref(TypeSet.singleton univ)); + List.iter (add_univar univ) inv.inv_parents + in + TypeHash.iter (fun ty inv -> if is_Tunivar ty then add_univar ty inv) + inverted; + fun ty -> + try !(TypeHash.find node_univars ty) with Not_found -> TypeSet.empty -let rec path_size = function - Pident id -> - penalty (Ident.name id), -Ident.binding_time id - | Pdot (p, _, _) -> - let (l, b) = path_size p in (1+l, b) - | Papply (p1, p2) -> - let (l, b) = path_size p1 in - (l + fst (path_size p2), b) -let same_printing_env env = - let used_pers = Env.used_persistent () in - Env.same_types !printing_old env && Concr.equal !printing_pers used_pers + (*******************) + (* Instantiation *) + (*******************) -let set_printing_env env = - printing_env := env; - if !Clflags.real_paths - || !printing_env == Env.empty || same_printing_env env then () else - begin - (* printf "Reset printing_map@."; *) - printing_old := env; - printing_pers := Env.used_persistent (); - printing_map := PathMap.empty; - printing_depth := 0; - (* printf "Recompute printing_map.@."; *) - let cont = - Env.iter_types - (fun p (p', _decl) -> - let (p1, s1) = normalize_type_path env p' ~cache:true in - (* Format.eprintf "%a -> %a = %a@." path p path p' path p1 *) - if s1 = Id then - try - let r = PathMap.find p1 !printing_map in - match !r with - Paths l -> r := Paths (p :: l) - | Best p' -> r := Paths [p; p'] (* assert false *) - with Not_found -> - printing_map := PathMap.add p1 (ref (Paths [p])) !printing_map) - env in - printing_cont := [cont]; - end -let wrap_printing_env env f = - set_printing_env env; - try_finally f (fun () -> set_printing_env Env.empty) +let rec find_repr p1 = + function + Mnil -> + None + | Mcons (Public, p2, ty, _, _) when Path.same p1 p2 -> + Some ty + | Mcons (_, _, _, _, rem) -> + find_repr p1 rem + | Mlink {contents = rem} -> + find_repr p1 rem -let wrap_printing_env env f = - Env.without_cmis (wrap_printing_env env) f +(* + Generic nodes are duplicated, while non-generic nodes are left + as-is. + During instantiation, the description of a generic node is first + replaced by a link to a stub ([Tsubst (newvar ())]). Once the + copy is made, it replaces the stub. + After instantiation, the description of generic node, which was + stored by [save_desc], must be put back, using [cleanup_types]. +*) -let is_unambiguous path env = - let l = Env.find_shadowed_types path env in - List.exists (Path.same path) l || (* concrete paths are ok *) - match l with - [] -> true - | p :: rem -> - (* allow also coherent paths: *) - let normalize p = fst (normalize_type_path ~cache:true env p) in - let p' = normalize p in - List.for_all (fun p -> Path.same (normalize p) p') rem || - (* also allow repeatedly defining and opening (for toplevel) *) - let id = lid_of_path p in - List.for_all (fun p -> lid_of_path p = id) rem && - Path.same p (Env.lookup_type id env) +let abbreviations = ref (ref Mnil) + (* Abbreviation memorized. *) -let rec get_best_path r = - match !r with - Best p' -> p' - | Paths [] -> raise Not_found - | Paths l -> - r := Paths []; - List.iter - (fun p -> - (* Format.eprintf "evaluating %a@." path p; *) - match !r with - Best p' when path_size p >= path_size p' -> () - | _ -> if is_unambiguous p !printing_env then r := Best p) - (* else Format.eprintf "%a ignored as ambiguous@." path p *) - l; - get_best_path r +(* partial: we may not wish to copy the non generic types + before we call type_pat *) +let rec copy ?env ?partial ?keep_names ty = + let copy = copy ?env ?partial ?keep_names in + let ty = repr ty in + match ty.desc with + Tsubst ty -> ty + | _ -> + if ty.level <> generic_level && partial = None then ty else + (* We only forget types that are non generic and do not contain + free univars *) + let forget = + if ty.level = generic_level then generic_level else + match partial with + None -> assert false + | Some (free_univars, keep) -> + if TypeSet.is_empty (free_univars ty) then + if keep then ty.level else !current_level + else generic_level + in + if forget <> generic_level then newty2 forget (Tvar None) else + let desc = ty.desc in + save_desc ty desc; + let t = newvar() in (* Stub *) + begin match env with + Some env when Env.has_local_constraints env -> + begin match Env.gadt_instance_level env ty with + Some lv -> Env.add_gadt_instances env lv [t] + | None -> () + end + | _ -> () + end; + ty.desc <- Tsubst t; + t.desc <- + begin match desc with + | Tconstr (p, tl, _) -> + let abbrevs = proper_abbrevs p tl !abbreviations in + begin match find_repr p !abbrevs with + Some ty when repr ty != t -> + Tlink ty + | _ -> + (* + One must allocate a new reference, so that abbrevia- + tions belonging to different branches of a type are + independent. + Moreover, a reference containing a [Mcons] must be + shared, so that the memorized expansion of an abbrevi- + ation can be released by changing the content of just + one reference. + *) + Tconstr (p, List.map copy tl, + ref (match !(!abbreviations) with + Mcons _ -> Mlink !abbreviations + | abbrev -> abbrev)) + end + | Tvariant row0 -> + let row = row_repr row0 in + let more = repr row.row_more in + (* We must substitute in a subtle way *) + (* Tsubst takes a tuple containing the row var and the variant *) + begin match more.desc with + Tsubst {desc = Ttuple [_;ty2]} -> + (* This variant type has been already copied *) + ty.desc <- Tsubst ty2; (* avoid Tlink in the new type *) + Tlink ty2 + | _ -> + (* If the row variable is not generic, we must keep it *) + let keep = more.level <> generic_level in + let more' = + match more.desc with + Tsubst ty -> ty + | Tconstr _ | Tnil -> + if keep then save_desc more more.desc; + copy more + | Tvar _ | Tunivar _ -> + save_desc more more.desc; + if keep then more else newty more.desc + | _ -> assert false + in + let row = + match repr more' with (* PR#6163 *) + {desc=Tconstr _} when not row.row_fixed -> + {row with row_fixed = true} + | _ -> row + in + (* Open row if partial for pattern and contains Reither *) + let more', row = + match partial with + Some (free_univars, false) -> + let more' = + if more.id != more'.id then more' else + let lv = if keep then more.level else !current_level in + newty2 lv (Tvar None) + in + let not_reither (_, f) = + match row_field_repr f with + Reither _ -> false + | _ -> true + in + if row.row_closed && not row.row_fixed + && TypeSet.is_empty (free_univars ty) + && not (List.for_all not_reither row.row_fields) then + (more', + {row_fields = List.filter not_reither row.row_fields; + row_more = more'; row_bound = (); + row_closed = false; row_fixed = false; row_name = None}) + else (more', row) + | _ -> (more', row) + in + (* Register new type first for recursion *) + more.desc <- Tsubst(newgenty(Ttuple[more';t])); + (* Return a new copy *) + Tvariant (copy_row copy true row keep more') + end + | Tfield (_p, k, _ty1, ty2) -> + begin match field_kind_repr k with + Fabsent -> Tlink (copy ty2) + | Fpresent -> copy_type_desc copy desc + | Fvar r -> + dup_kind r; + copy_type_desc copy desc + end + | Tobject (ty1, _) when partial <> None -> + Tobject (copy ty1, ref None) + | _ -> copy_type_desc ?keep_names copy desc + end; + t -let best_type_path p = - if !Clflags.real_paths || !printing_env == Env.empty - then (p, Id) - else - let (p', s) = normalize_type_path !printing_env p in - let get_path () = get_best_path (PathMap.find p' !printing_map) in - while !printing_cont <> [] && - try fst (path_size (get_path ())) > !printing_depth with Not_found -> true - do - printing_cont := List.map snd (Env.run_iter_cont !printing_cont); - incr printing_depth; - done; - let p'' = try get_path () with Not_found -> p' in - (* Format.eprintf "%a = %a -> %a@." path p path p' path p''; *) - (p'', s) +let simple_copy t = copy t -(* Print a type expression *) +(**** Variants of instantiations ****) -let names = ref ([] : (type_expr * string) list) -let name_counter = ref 0 -let named_vars = ref ([] : string list) +let gadt_env env = + if Env.has_local_constraints env + then Some env + else None + +let instance ?partial env sch = + let env = gadt_env env in + let partial = + match partial with + None -> None + | Some keep -> Some (compute_univars sch, keep) + in + let ty = copy ?env ?partial sch in + cleanup_types (); + ty + +let instance_def sch = + let ty = copy sch in + cleanup_types (); + ty + +let generic_instance env sch = + let old = !current_level in + current_level := generic_level; + let ty = instance env sch in + current_level := old; + ty + +let instance_list env schl = + let env = gadt_env env in + let tyl = List.map (fun t -> copy ?env t) schl in + cleanup_types (); + tyl + +let reified_var_counter = ref Vars.empty +let reset_reified_var_counter () = + reified_var_counter := Vars.empty + +(* names given to new type constructors. + Used for existential types and + local constraints *) +let get_new_abstract_name s = + let index = + try Vars.find s !reified_var_counter + 1 + with Not_found -> 0 in + reified_var_counter := Vars.add s index !reified_var_counter; + if index = 0 && s <> "" && s.[String.length s - 1] <> '$' then s else + Printf.sprintf "%s%d" s index + +let new_declaration newtype manifest = + { + type_params = []; + type_arity = 0; + type_kind = Type_abstract; + type_private = Public; + type_manifest = manifest; + type_variance = []; + type_newtype_level = newtype; + type_loc = Location.none; + type_attributes = []; + type_immediate = false; + type_unboxed = unboxed_false_default_false; + } + +let instance_constructor ?in_pattern cstr = + begin match in_pattern with + | None -> () + | Some (env, newtype_lev) -> + let process existential = + let decl = new_declaration (Some (newtype_lev, newtype_lev)) None in + let name = + match repr existential with + {desc = Tvar (Some name)} -> "$" ^ cstr.cstr_name ^ "_'" ^ name + | _ -> "$" ^ cstr.cstr_name + in + let path = Path.Pident (Ident.create (get_new_abstract_name name)) in + let new_env = Env.add_local_type path decl !env in + env := new_env; + let to_unify = newty (Tconstr (path,[],ref Mnil)) in + let tv = copy existential in + assert (is_Tvar tv); + link_type tv to_unify + in + List.iter process cstr.cstr_existentials + end; + let ty_res = copy cstr.cstr_res in + let ty_args = List.map simple_copy cstr.cstr_args in + cleanup_types (); + (ty_args, ty_res) -let weak_counter = ref 1 -let weak_var_map = ref TypeMap.empty -let named_weak_vars = ref StringSet.empty +let instance_parameterized_type ?keep_names sch_args sch = + let ty_args = List.map (fun t -> copy ?keep_names t) sch_args in + let ty = copy sch in + cleanup_types (); + (ty_args, ty) -let reset_names () = names := []; name_counter := 0; named_vars := [] -let add_named_var ty = - match ty.desc with - Tvar (Some name) | Tunivar (Some name) -> - if List.mem name !named_vars then () else - named_vars := name :: !named_vars - | _ -> () +let instance_parameterized_type_2 sch_args sch_lst sch = + let ty_args = List.map simple_copy sch_args in + let ty_lst = List.map simple_copy sch_lst in + let ty = copy sch in + cleanup_types (); + (ty_args, ty_lst, ty) -let name_is_already_used name = - List.mem name !named_vars - || List.exists (fun (_, name') -> name = name') !names - || StringSet.mem name !named_weak_vars +let map_kind f = function + | Type_abstract -> Type_abstract + | Type_open -> Type_open + | Type_variant cl -> + Type_variant ( + List.map + (fun c -> + {c with + cd_args = map_type_expr_cstr_args f c.cd_args; + cd_res = may_map f c.cd_res + }) + cl) + | Type_record (fl, rr) -> + Type_record ( + List.map + (fun l -> + {l with ld_type = f l.ld_type} + ) fl, rr) -let rec new_name () = - let name = - if !name_counter < 26 - then String.make 1 (Char.chr(97 + !name_counter)) - else String.make 1 (Char.chr(97 + !name_counter mod 26)) ^ - string_of_int(!name_counter / 26) in - incr name_counter; - if name_is_already_used name then new_name () else name -let rec new_weak_name ty () = - let name = "weak" ^ string_of_int !weak_counter in - incr weak_counter; - if name_is_already_used name then new_weak_name ty () - else begin - named_weak_vars := StringSet.add name !named_weak_vars; - weak_var_map := TypeMap.add ty name !weak_var_map; - name - end +let instance_declaration decl = + let decl = + {decl with type_params = List.map simple_copy decl.type_params; + type_manifest = may_map simple_copy decl.type_manifest; + type_kind = map_kind simple_copy decl.type_kind; + } + in + cleanup_types (); + decl -let name_of_type name_generator t = - (* We've already been through repr at this stage, so t is our representative - of the union-find class. *) - try List.assq t !names with Not_found -> - try TypeMap.find t !weak_var_map with Not_found -> - let name = - match t.desc with - Tvar (Some name) | Tunivar (Some name) -> - (* Some part of the type we've already printed has assigned another - * unification variable to that name. We want to keep the name, so try - * adding a number until we find a name that's not taken. *) - let current_name = ref name in - let i = ref 0 in - while List.exists (fun (_, name') -> !current_name = name') !names do - current_name := name ^ (string_of_int !i); - i := !i + 1; - done; - !current_name - | _ -> - (* No name available, create a new one *) - name_generator () - in - (* Exception for type declarations *) - if name <> "_" then names := (t, name) :: !names; - name +let instance_class params cty = + let rec copy_class_type = + function + Cty_constr (path, tyl, cty) -> + Cty_constr (path, List.map simple_copy tyl, copy_class_type cty) + | Cty_signature sign -> + Cty_signature + {csig_self = copy sign.csig_self; + csig_vars = + Vars.map (function (m, v, ty) -> (m, v, copy ty)) sign.csig_vars; + csig_concr = sign.csig_concr; + csig_inher = + List.map (fun (p,tl) -> (p, List.map simple_copy tl)) + sign.csig_inher} + | Cty_arrow (l, ty, cty) -> + Cty_arrow (l, copy ty, copy_class_type cty) + in + let params' = List.map simple_copy params in + let cty' = copy_class_type cty in + cleanup_types (); + (params', cty') -let check_name_of_type t = ignore(name_of_type new_name t) +(**** Instantiation for types with free universal variables ****) -let remove_names tyl = - let tyl = List.map repr tyl in - names := List.filter (fun (ty,_) -> not (List.memq ty tyl)) !names +let rec diff_list l1 l2 = + if l1 == l2 then [] else + match l1 with [] -> invalid_arg "Ctype.diff_list" + | a :: l1 -> a :: diff_list l1 l2 -let visited_objects = ref ([] : type_expr list) -let aliased = ref ([] : type_expr list) -let delayed = ref ([] : type_expr list) +let conflicts free bound = + let bound = List.map repr bound in + TypeSet.exists (fun t -> List.memq (repr t) bound) free -let add_delayed t = - if not (List.memq t !delayed) then delayed := t :: !delayed +let delayed_copy = ref [] + (* copying to do later *) -let is_aliased ty = List.memq (proxy ty) !aliased -let add_alias ty = - let px = proxy ty in - if not (is_aliased px) then begin - aliased := px :: !aliased; - add_named_var px +(* Copy without sharing until there are no free univars left *) +(* all free univars must be included in [visited] *) +let rec copy_sep fixed free bound visited ty = + let ty = repr ty in + let univars = free ty in + if TypeSet.is_empty univars then + if ty.level <> generic_level then ty else + let t = newvar () in + delayed_copy := + lazy (t.desc <- Tlink (copy ty)) + :: !delayed_copy; + t + else try + let t, bound_t = List.assq ty visited in + let dl = if is_Tunivar ty then [] else diff_list bound bound_t in + if dl <> [] && conflicts univars dl then raise Not_found; + t + with Not_found -> begin + let t = newvar() in (* Stub *) + let visited = + match ty.desc with + Tarrow _ | Ttuple _ | Tvariant _ | Tconstr _ | Tobject _ | Tpackage _ -> + (ty,(t,bound)) :: visited + | _ -> visited in + let copy_rec = copy_sep fixed free bound visited in + t.desc <- + begin match ty.desc with + | Tvariant row0 -> + let row = row_repr row0 in + let more = repr row.row_more in + (* We shall really check the level on the row variable *) + let keep = is_Tvar more && more.level <> generic_level in + let more' = copy_rec more in + let fixed' = fixed && is_Tvar (repr more') in + let row = copy_row copy_rec fixed' row keep more' in + Tvariant row + | Tpoly (t1, tl) -> + let tl = List.map repr tl in + let tl' = List.map (fun t -> newty t.desc) tl in + let bound = tl @ bound in + let visited = + List.map2 (fun ty t -> ty,(t,bound)) tl tl' @ visited in + Tpoly (copy_sep fixed free bound visited t1, tl') + | _ -> copy_type_desc copy_rec ty.desc + end; + t end -let aliasable ty = - match ty.desc with - Tvar _ | Tunivar _ | Tpoly _ -> false - | Tconstr (p, _, _) -> - not (is_nth (snd (best_type_path p))) - | _ -> true +let instance_poly ?(keep_names=false) fixed univars sch = + let univars = List.map repr univars in + let copy_var ty = + match ty.desc with + Tunivar name -> if keep_names then newty (Tvar name) else newvar () + | _ -> assert false + in + let vars = List.map copy_var univars in + let pairs = List.map2 (fun u v -> u, (v, [])) univars vars in + delayed_copy := []; + let ty = copy_sep fixed (compute_univars sch) [] pairs sch in + List.iter Lazy.force !delayed_copy; + delayed_copy := []; + cleanup_types (); + vars, ty -let namable_row row = - row.row_name <> None && - List.for_all - (fun (_, f) -> - match row_field_repr f with - | Reither(c, l, _, _) -> - row.row_closed && if c then l = [] else List.length l = 1 - | _ -> true) - row.row_fields +let instance_label fixed lbl = + let ty_res = copy lbl.lbl_res in + let vars, ty_arg = + match repr lbl.lbl_arg with + {desc = Tpoly (ty, tl)} -> + instance_poly fixed tl ty + | _ -> + [], copy lbl.lbl_arg + in + cleanup_types (); + (vars, ty_arg, ty_res) -let rec mark_loops_rec visited ty = - let ty = repr ty in - let px = proxy ty in - if List.memq px visited && aliasable ty then add_alias px else - let visited = px :: visited in - match ty.desc with - | Tvar _ -> add_named_var ty - | Tarrow(_, ty1, ty2, _) -> - mark_loops_rec visited ty1; mark_loops_rec visited ty2 - | Ttuple tyl -> List.iter (mark_loops_rec visited) tyl - | Tconstr(p, tyl, _) -> - let (_p', s) = best_type_path p in - List.iter (mark_loops_rec visited) (apply_subst s tyl) - | Tpackage (_, _, tyl) -> - List.iter (mark_loops_rec visited) tyl - | Tvariant row -> - if List.memq px !visited_objects then add_alias px else - begin - let row = row_repr row in - if not (static_row row) then - visited_objects := px :: !visited_objects; - match row.row_name with - | Some(_p, tyl) when namable_row row -> - List.iter (mark_loops_rec visited) tyl - | _ -> - iter_row (mark_loops_rec visited) row - end - | Tobject (fi, nm) -> - if List.memq px !visited_objects then add_alias px else - begin - if opened_object ty then - visited_objects := px :: !visited_objects; - begin match !nm with - | None -> - let fields, _ = flatten_fields fi in - List.iter - (fun (_, kind, ty) -> - if field_kind_repr kind = Fpresent then - mark_loops_rec visited ty) - fields - | Some (_, l) -> - List.iter (mark_loops_rec visited) (List.tl l) - end - end - | Tfield(_, kind, ty1, ty2) when field_kind_repr kind = Fpresent -> - mark_loops_rec visited ty1; mark_loops_rec visited ty2 - | Tfield(_, _, _, ty2) -> - mark_loops_rec visited ty2 - | Tnil -> () - | Tsubst ty -> mark_loops_rec visited ty - | Tlink _ -> fatal_error "Printtyp.mark_loops_rec (2)" - | Tpoly (ty, tyl) -> - List.iter (fun t -> add_alias t) tyl; - mark_loops_rec visited ty - | Tunivar _ -> add_named_var ty +(**** Instantiation with parameter substitution ****) -let mark_loops ty = - normalize_type Env.empty ty; - mark_loops_rec [] ty;; +let unify' = (* Forward declaration *) + ref (fun _env _ty1 _ty2 -> raise (Unify [])) -let reset_loop_marks () = - visited_objects := []; aliased := []; delayed := [] +let subst env level priv abbrev ty params args body = + if List.length params <> List.length args then raise (Unify []); + let old_level = !current_level in + current_level := level; + try + let body0 = newvar () in (* Stub *) + begin match ty with + None -> () + | Some ({desc = Tconstr (path, tl, _)} as ty) -> + let abbrev = proper_abbrevs path tl abbrev in + memorize_abbrev abbrev priv path ty body0 + | _ -> + assert false + end; + abbreviations := abbrev; + let (params', body') = instance_parameterized_type params body in + abbreviations := ref Mnil; + !unify' env body0 body'; + List.iter2 (!unify' env) params' args; + current_level := old_level; + body' + with Unify _ as exn -> + current_level := old_level; + raise exn -let reset () = - unique_names := Ident.empty; reset_names (); reset_loop_marks () +(* + Only the shape of the type matters, not whether it is generic or + not. [generic_level] might be somewhat slower, but it ensures + invariants on types are enforced (decreasing levels), and we don't + care about efficiency here. +*) +let apply env params body args = + try + subst env generic_level Public (ref Mnil) None params args body + with + Unify _ -> raise Cannot_apply -let reset_and_mark_loops ty = - reset (); mark_loops ty +let () = Subst.ctype_apply_env_empty := apply Env.empty -let reset_and_mark_loops_list tyl = - reset (); List.iter mark_loops tyl + (****************************) + (* Abbreviation expansion *) + (****************************) -(* Disabled in classic mode when printing an unification error *) -let print_labels = ref true +(* + If the environment has changed, memorized expansions might not + be correct anymore, and so we flush the cache. This is safe but + quite pessimistic: it would be enough to flush the cache when a + type or module definition is overridden in the environment. +*) +let previous_env = ref Env.empty +(*let string_of_kind = function Public -> "public" | Private -> "private"*) +let check_abbrev_env env = + if env != !previous_env then begin + (* prerr_endline "cleanup expansion cache"; *) + cleanup_abbrev (); + previous_env := env + end -let rec tree_of_typexp sch ty = - let ty = repr ty in - let px = proxy ty in - if List.mem_assq px !names && not (List.memq px !delayed) then - let mark = is_non_gen sch ty in - let name = name_of_type (if mark then new_weak_name ty else new_name) px in - Otyp_var (mark, name) else - let pr_typ () = - match ty.desc with - | Tvar _ -> - (*let lev = - if is_non_gen sch ty then "/" ^ string_of_int ty.level else "" in*) - let non_gen = is_non_gen sch ty in - let name_gen = if non_gen then new_weak_name ty else new_name in - Otyp_var (non_gen, name_of_type name_gen ty) - | Tarrow(l, ty1, ty2, _) -> - let pr_arrow l ty1 ty2 = - let lab = - if !print_labels || is_optional l then string_of_label l else "" - in - let t1 = - if is_optional l then - match (repr ty1).desc with - | Tconstr(path, [ty], _) - when Path.same path Predef.path_option -> - tree_of_typexp sch ty - | _ -> Otyp_stuff "" - else tree_of_typexp sch ty1 in - Otyp_arrow (lab, t1, tree_of_typexp sch ty2) in - pr_arrow l ty1 ty2 - | Ttuple tyl -> - Otyp_tuple (tree_of_typlist sch tyl) - | Tconstr(p, tyl, _abbrev) -> - let p', s = best_type_path p in - let tyl' = apply_subst s tyl in - if is_nth s && not (tyl'=[]) then tree_of_typexp sch (List.hd tyl') else - Otyp_constr (tree_of_path p', tree_of_typlist sch tyl') - | Tvariant row -> - let row = row_repr row in - let fields = - if row.row_closed then - List.filter (fun (_, f) -> row_field_repr f <> Rabsent) - row.row_fields - else row.row_fields in - let present = - List.filter - (fun (_, f) -> - match row_field_repr f with - | Rpresent _ -> true - | _ -> false) - fields in - let all_present = List.length present = List.length fields in - begin match row.row_name with - | Some(p, tyl) when namable_row row -> - let (p', s) = best_type_path p in - let id = tree_of_path p' in - let args = tree_of_typlist sch (apply_subst s tyl) in - let out_variant = - if is_nth s then List.hd args else Otyp_constr (id, args) in - if row.row_closed && all_present then - out_variant - else - let non_gen = is_non_gen sch px in - let tags = - if all_present then None else Some (List.map fst present) in - Otyp_variant (non_gen, Ovar_typ out_variant, row.row_closed, tags) - | _ -> - let non_gen = - not (row.row_closed && all_present) && is_non_gen sch px in - let fields = List.map (tree_of_row_field sch) fields in - let tags = - if all_present then None else Some (List.map fst present) in - Otyp_variant (non_gen, Ovar_fields fields, row.row_closed, tags) - end - | Tobject (fi, nm) -> - tree_of_typobject sch fi !nm - | Tnil | Tfield _ -> - tree_of_typobject sch ty None - | Tsubst ty -> - tree_of_typexp sch ty - | Tlink _ -> - fatal_error "Printtyp.tree_of_typexp" - | Tpoly (ty, []) -> - tree_of_typexp sch ty - | Tpoly (ty, tyl) -> - (*let print_names () = - List.iter (fun (_, name) -> prerr_string (name ^ " ")) !names; - prerr_string "; " in *) - let tyl = List.map repr tyl in - if tyl = [] then tree_of_typexp sch ty else begin - let old_delayed = !delayed in - (* Make the names delayed, so that the real type is - printed once when used as proxy *) - List.iter add_delayed tyl; - let tl = List.map (name_of_type new_name) tyl in - let tr = Otyp_poly (tl, tree_of_typexp sch ty) in - (* Forget names when we leave scope *) - remove_names tyl; - delayed := old_delayed; tr - end - | Tunivar _ -> - Otyp_var (false, name_of_type new_name ty) - | Tpackage (p, n, tyl) -> - let n = - List.map (fun li -> String.concat "." (Longident.flatten li)) n in - Otyp_module (Path.name p, n, tree_of_typlist sch tyl) - in - if List.memq px !delayed then delayed := List.filter ((!=) px) !delayed; - if is_aliased px && aliasable ty then begin - check_name_of_type px; - Otyp_alias (pr_typ (), name_of_type new_name px) end - else pr_typ () +(* Expand an abbreviation. The expansion is memorized. *) +(* + Assume the level is greater than the path binding time of the + expanded abbreviation. +*) +(* + An abbreviation expansion will fail in either of these cases: + 1. The type constructor does not correspond to a manifest type. + 2. The type constructor is defined in an external file, and this + file is not in the path (missing -I options). + 3. The type constructor is not in the "local" environment. This can + happens when a non-generic type variable has been instantiated + afterwards to the not yet defined type constructor. (Actually, + this cannot happen at the moment due to the strong constraints + between type levels and constructor binding time.) + 4. The expansion requires the expansion of another abbreviation, + and this other expansion fails. +*) +let expand_abbrev_gen kind find_type_expansion env ty = + check_abbrev_env env; + match ty with + {desc = Tconstr (path, args, abbrev); level = level} -> + let lookup_abbrev = proper_abbrevs path args abbrev in + begin match find_expans kind path !lookup_abbrev with + Some ty' -> + (* prerr_endline + ("found a "^string_of_kind kind^" expansion for "^Path.name path);*) + if level <> generic_level then + begin try + update_level env level ty' + with Unify _ -> + (* XXX This should not happen. + However, levels are not correctly restored after a + typing error *) + () + end; + let ty' = repr ty' in + (* assert (ty != ty'); *) (* PR#7324 *) + ty' + | None -> + match find_type_expansion path env with + | exception Not_found -> + (* another way to expand is to normalize the path itself *) + let path' = Env.normalize_path None env path in + if Path.same path path' then raise Cannot_expand + else newty2 level (Tconstr (path', args, abbrev)) + | (params, body, lv) -> + (* prerr_endline + ("add a "^string_of_kind kind^" expansion for "^Path.name path);*) + let ty' = subst env level kind abbrev (Some ty) params args body in + (* For gadts, remember type as non exportable *) + (* The ambiguous level registered for ty' should be the highest *) + if !trace_gadt_instances then begin + match max lv (Env.gadt_instance_level env ty) with + None -> () + | Some lv -> + if level < lv then raise (Unify [(ty, newvar2 level)]); + Env.add_gadt_instances env lv [ty; ty'] + end; + ty' + end + | _ -> + assert false -and tree_of_row_field sch (l, f) = - match row_field_repr f with - | Rpresent None | Reither(true, [], _, _) -> (l, false, []) - | Rpresent(Some ty) -> (l, false, [tree_of_typexp sch ty]) - | Reither(c, tyl, _, _) -> - if c (* contradiction: constant constructor with an argument *) - then (l, true, tree_of_typlist sch tyl) - else (l, false, tree_of_typlist sch tyl) - | Rabsent -> (l, false, [] (* actually, an error *)) +(* Expand respecting privacy *) +let expand_abbrev env ty = + expand_abbrev_gen Public Env.find_type_expansion env ty -and tree_of_typlist sch tyl = - List.map (tree_of_typexp sch) tyl +(* Expand once the head of a type *) +let expand_head_once env ty = + try expand_abbrev env (repr ty) with Cannot_expand -> assert false -and tree_of_typobject sch fi nm = - begin match nm with - | None -> - let pr_fields fi = - let (fields, rest) = flatten_fields fi in - let present_fields = - List.fold_right - (fun (n, k, t) l -> - match field_kind_repr k with - | Fpresent -> (n, t) :: l - | _ -> l) - fields [] in - let sorted_fields = - List.sort - (fun (n, _) (n', _) -> String.compare n n') present_fields in - tree_of_typfields sch rest sorted_fields in - let (fields, rest) = pr_fields fi in - Otyp_object (fields, rest) - | Some (p, ty :: tyl) -> - let non_gen = is_non_gen sch (repr ty) in - let args = tree_of_typlist sch tyl in - let (p', s) = best_type_path p in - assert (s = Id); - Otyp_class (non_gen, tree_of_path p', args) - | _ -> - fatal_error "Printtyp.tree_of_typobject" - end +(* Check whether a type can be expanded *) +let safe_abbrev env ty = + let snap = Btype.snapshot () in + try ignore (expand_abbrev env ty); true + with Cannot_expand | Unify _ -> + Btype.backtrack snap; + false -and is_non_gen sch ty = - sch && is_Tvar ty && ty.level <> generic_level +(* Expand the head of a type once. + Raise Cannot_expand if the type cannot be expanded. + May raise Unify, if a recursion was hidden in the type. *) +let try_expand_once env ty = + let ty = repr ty in + match ty.desc with + Tconstr _ -> repr (expand_abbrev env ty) + | _ -> raise Cannot_expand -and tree_of_typfields sch rest = function - | [] -> - let rest = - match rest.desc with - | Tvar _ | Tunivar _ -> Some (is_non_gen sch rest) - | Tconstr _ -> Some false - | Tnil -> None - | _ -> fatal_error "typfields (1)" +(* This one only raises Cannot_expand *) +let try_expand_safe env ty = + let snap = Btype.snapshot () in + try try_expand_once env ty + with Unify _ -> + Btype.backtrack snap; raise Cannot_expand + +(* Fully expand the head of a type. *) +let rec try_expand_head try_once env ty = + let ty' = try_once env ty in + try try_expand_head try_once env ty' + with Cannot_expand -> ty' + +let try_expand_head try_once env ty = + let ty' = try_expand_head try_once env ty in + begin match Env.gadt_instance_level env ty' with + None -> () + | Some lv -> Env.add_gadt_instance_chain env lv ty + end; + ty' + +(* Unsafe full expansion, may raise Unify. *) +let expand_head_unif env ty = + try try_expand_head try_expand_once env ty with Cannot_expand -> repr ty + +(* Safe version of expand_head, never fails *) +let expand_head env ty = + try try_expand_head try_expand_safe env ty with Cannot_expand -> repr ty + +let _ = forward_try_expand_once := try_expand_safe + + +(* Expand until we find a non-abstract type declaration *) + +let rec extract_concrete_typedecl env ty = + let ty = repr ty in + match ty.desc with + Tconstr (p, _, _) -> + let decl = Env.find_type p env in + if decl.type_kind <> Type_abstract then (p, p, decl) else + let ty = + try try_expand_once env ty with Cannot_expand -> raise Not_found in - ([], rest) - | (s, t) :: l -> - let field = (s, tree_of_typexp sch t) in - let (fields, rest) = tree_of_typfields sch rest l in - (field :: fields, rest) + let (_, p', decl) = extract_concrete_typedecl env ty in + (p, p', decl) + | _ -> raise Not_found -let typexp sch ppf ty = - !Oprint.out_type ppf (tree_of_typexp sch ty) +(* Implementing function [expand_head_opt], the compiler's own version of + [expand_head] used for type-based optimisations. + [expand_head_opt] uses [Env.find_type_expansion_opt] to access the + manifest type information of private abstract data types which is + normally hidden to the type-checker out of the implementation module of + the private abbreviation. *) -let type_expr ppf ty = typexp false ppf ty +let expand_abbrev_opt = + expand_abbrev_gen Private Env.find_type_expansion_opt -and type_sch ppf ty = typexp true ppf ty +let try_expand_once_opt env ty = + let ty = repr ty in + match ty.desc with + Tconstr _ -> repr (expand_abbrev_opt env ty) + | _ -> raise Cannot_expand -and type_scheme ppf ty = reset_and_mark_loops ty; typexp true ppf ty +let rec try_expand_head_opt env ty = + let ty' = try_expand_once_opt env ty in + begin try + try_expand_head_opt env ty' + with Cannot_expand -> + ty' + end -(* Maxence *) -let type_scheme_max ?(b_reset_names=true) ppf ty = - if b_reset_names then reset_names () ; - typexp true ppf ty -(* End Maxence *) +let expand_head_opt env ty = + let snap = Btype.snapshot () in + try try_expand_head_opt env ty + with Cannot_expand | Unify _ -> (* expand_head shall never fail *) + Btype.backtrack snap; + repr ty -let tree_of_type_scheme ty = reset_and_mark_loops ty; tree_of_typexp true ty +(* Make sure that the type parameters of the type constructor [ty] + respect the type constraints *) +let enforce_constraints env ty = + match ty with + {desc = Tconstr (path, args, _abbrev); level = level} -> + begin try + let decl = Env.find_type path env in + ignore + (subst env level Public (ref Mnil) None decl.type_params args + (newvar2 level)) + with Not_found -> () + end + | _ -> + assert false -(* Print one type declaration *) +(* Recursively expand the head of a type. + Also expand #-types. *) +let full_expand env ty = + let ty = repr (expand_head env ty) in + match ty.desc with + Tobject (fi, {contents = Some (_, v::_)}) when is_Tvar (repr v) -> + newty2 ty.level (Tobject (fi, ref None)) + | _ -> + ty -let tree_of_constraints params = - List.fold_right - (fun ty list -> - let ty' = unalias ty in - if proxy ty != proxy ty' then - let tr = tree_of_typexp true ty in - (tr, tree_of_typexp true ty') :: list - else list) - params [] +(* + Check whether the abbreviation expands to a well-defined type. + During the typing of a class, abbreviations for correspondings + types expand to non-generic types. +*) +let generic_abbrev env path = + try + let (_, body, _) = Env.find_type_expansion path env in + (repr body).level = generic_level + with + Not_found -> + false -let filter_params tyl = - let params = - List.fold_left - (fun tyl ty -> - let ty = repr ty in - if List.memq ty tyl then Btype.newgenty (Tsubst ty) :: tyl - else ty :: tyl) - [] tyl - in List.rev params +let generic_private_abbrev env path = + try + match Env.find_type path env with + {type_kind = Type_abstract; + type_private = Private; + type_manifest = Some body} -> + (repr body).level = generic_level + | _ -> false + with Not_found -> false -let mark_loops_constructor_arguments = function - | Cstr_tuple l -> List.iter mark_loops l - | Cstr_record l -> List.iter (fun l -> mark_loops l.ld_type) l +let is_contractive env p = + try + let decl = Env.find_type p env in + in_pervasives p && decl.type_manifest = None || is_datatype decl + with Not_found -> false -let rec tree_of_type_decl id decl = - reset(); + (*****************) + (* Occur check *) + (*****************) - let params = filter_params decl.type_params in - begin match decl.type_manifest with - | Some ty -> - let vars = free_variables ty in - List.iter - (function {desc = Tvar (Some "_")} as ty -> - if List.memq ty vars then ty.desc <- Tvar None - | _ -> ()) - params - | None -> () - end; +exception Occur - List.iter add_alias params; - List.iter mark_loops params; - List.iter check_name_of_type (List.map proxy params); - let ty_manifest = - match decl.type_manifest with - | None -> None - | Some ty -> - let ty = - (* Special hack to hide variant name *) - match repr ty with {desc=Tvariant row} -> - let row = row_repr row in - begin match row.row_name with - Some (Pident id', _) when Ident.same id id' -> - newgenty (Tvariant {row with row_name = None}) - | _ -> ty - end - | _ -> ty - in - mark_loops ty; - Some ty - in - begin match decl.type_kind with - | Type_abstract -> () - | Type_variant cstrs -> - List.iter - (fun c -> - mark_loops_constructor_arguments c.cd_args; - may mark_loops c.cd_res) - cstrs - | Type_record(l, _rep) -> - List.iter (fun l -> mark_loops l.ld_type) l - | Type_open -> () - end; +let rec occur_rec env allow_recursive visited ty0 = function + | {desc=Tlink ty} -> + occur_rec env allow_recursive visited ty0 ty + | ty -> + if ty == ty0 then raise Occur; + match ty.desc with + Tconstr(p, _tl, _abbrev) -> + if allow_recursive && is_contractive env p then () else + begin try + if TypeSet.mem ty visited then raise Occur; + let visited = TypeSet.add ty visited in + iter_type_expr (occur_rec env allow_recursive visited ty0) ty + with Occur -> try + let ty' = try_expand_head try_expand_once env ty in + (* This call used to be inlined, but there seems no reason for it. + Message was referring to change in rev. 1.58 of the CVS repo. *) + occur_rec env allow_recursive visited ty0 ty' + with Cannot_expand -> + raise Occur + end + | Tobject _ | Tvariant _ -> + () + | _ -> + if allow_recursive || TypeSet.mem ty visited then () else begin + let visited = TypeSet.add ty visited in + iter_type_expr (occur_rec env allow_recursive visited ty0) ty + end - let type_param = - function - | Otyp_var (_, id) -> id - | _ -> "?" - in - let type_defined decl = - let abstr = - match decl.type_kind with - Type_abstract -> - decl.type_manifest = None || decl.type_private = Private - | Type_record _ -> - decl.type_private = Private - | Type_variant tll -> - decl.type_private = Private || - List.exists (fun cd -> cd.cd_res <> None) tll - | Type_open -> - decl.type_manifest = None - in - let vari = - List.map2 - (fun ty v -> - if abstr || not (is_Tvar (repr ty)) then Variance.get_upper v - else (true,true)) - decl.type_params decl.type_variance - in - (Ident.name id, - List.map2 (fun ty cocn -> type_param (tree_of_typexp false ty), cocn) - params vari) - in - let tree_of_manifest ty1 = - match ty_manifest with - | None -> ty1 - | Some ty -> Otyp_manifest (tree_of_typexp false ty, ty1) - in - let (name, args) = type_defined decl in - let constraints = tree_of_constraints params in - let ty, priv = - match decl.type_kind with - | Type_abstract -> - begin match ty_manifest with - | None -> (Otyp_abstract, Public) - | Some ty -> - tree_of_typexp false ty, decl.type_private - end - | Type_variant cstrs -> - tree_of_manifest (Otyp_sum (List.map tree_of_constructor cstrs)), - decl.type_private - | Type_record(lbls, _rep) -> - tree_of_manifest (Otyp_record (List.map tree_of_label lbls)), - decl.type_private - | Type_open -> - tree_of_manifest Otyp_open, - decl.type_private - in - let immediate = - Builtin_attributes.immediate decl.type_attributes - in - { otype_name = name; - otype_params = args; - otype_type = ty; - otype_private = priv; - otype_immediate = immediate; - otype_unboxed = decl.type_unboxed.unboxed; - otype_cstrs = constraints } +let type_changed = ref false (* trace possible changes to the studied type *) -and tree_of_constructor_arguments = function - | Cstr_tuple l -> tree_of_typlist false l - | Cstr_record l -> [ Otyp_record (List.map tree_of_label l) ] +let merge r b = if b then r := true -and tree_of_constructor cd = - let name = Ident.name cd.cd_id in - let arg () = tree_of_constructor_arguments cd.cd_args in - match cd.cd_res with - | None -> (name, arg (), None) - | Some res -> - let nm = !names in - names := []; - let ret = tree_of_typexp false res in - let args = arg () in - names := nm; - (name, args, Some ret) +let occur env ty0 ty = + let allow_recursive = !Clflags.recursive_types || !umode = Pattern in + let old = !type_changed in + try + while + type_changed := false; + occur_rec env allow_recursive TypeSet.empty ty0 ty; + !type_changed + do () (* prerr_endline "changed" *) done; + merge type_changed old + with exn -> + merge type_changed old; + raise (match exn with Occur -> Unify [] | _ -> exn) -and tree_of_label l = - (Ident.name l.ld_id, l.ld_mutable = Mutable, tree_of_typexp false l.ld_type) +let occur_in env ty0 t = + try occur env ty0 t; false with Unify _ -> true -let tree_of_type_declaration id decl rs = - Osig_type (tree_of_type_decl id decl, tree_of_rec rs) +(* Check that a local constraint is well-founded *) +(* PR#6405: not needed since we allow recursion and work on normalized types *) +(* PR#6992: we actually need it for contractiveness *) +(* This is a simplified version of occur, only for the rectypes case *) -let type_declaration id ppf decl = - !Oprint.out_sig_item ppf (tree_of_type_declaration id decl Trec_first) +let rec local_non_recursive_abbrev strict visited env p ty = + (*Format.eprintf "@[Check %s =@ %a@]@." (Path.name p) !Btype.print_raw ty;*) + let ty = repr ty in + if not (List.memq ty visited) then begin + match ty.desc with + Tconstr(p', args, _abbrev) -> + if Path.same p p' then raise Occur; + if not strict && is_contractive env p' then () else + let visited = ty :: visited in + begin try + (* try expanding, since [p] could be hidden *) + local_non_recursive_abbrev strict visited env p + (try_expand_head try_expand_once env ty) + with Cannot_expand -> + let params = + try (Env.find_type p' env).type_params + with Not_found -> args + in + List.iter2 + (fun tv ty -> + let strict = strict || not (is_Tvar (repr tv)) in + local_non_recursive_abbrev strict visited env p ty) + params args + end + | _ -> + if strict then (* PR#7374 *) + let visited = ty :: visited in + iter_type_expr (local_non_recursive_abbrev true visited env p) ty + end -let constructor_arguments ppf a = - let tys = tree_of_constructor_arguments a in - !Oprint.out_type ppf (Otyp_tuple tys) +let local_non_recursive_abbrev env p ty = + try (* PR#7397: need to check trace_gadt_instances *) + wrap_trace_gadt_instances env + (local_non_recursive_abbrev false [] env p) ty; + true + with Occur -> false -(* Print an extension declaration *) -let tree_of_extension_constructor id ext es = - reset (); - let ty_name = Path.name ext.ext_type_path in - let ty_params = filter_params ext.ext_type_params in - List.iter add_alias ty_params; - List.iter mark_loops ty_params; - List.iter check_name_of_type (List.map proxy ty_params); - mark_loops_constructor_arguments ext.ext_args; - may mark_loops ext.ext_ret_type; - let type_param = - function - | Otyp_var (_, id) -> id - | _ -> "?" - in - let ty_params = - List.map (fun ty -> type_param (tree_of_typexp false ty)) ty_params - in - let name = Ident.name id in - let args, ret = - match ext.ext_ret_type with - | None -> (tree_of_constructor_arguments ext.ext_args, None) - | Some res -> - let nm = !names in - names := []; - let ret = tree_of_typexp false res in - let args = tree_of_constructor_arguments ext.ext_args in - names := nm; - (args, Some ret) - in - let ext = - { oext_name = name; - oext_type_name = ty_name; - oext_type_params = ty_params; - oext_args = args; - oext_ret_type = ret; - oext_private = ext.ext_private } - in - let es = - match es with - Text_first -> Oext_first - | Text_next -> Oext_next - | Text_exception -> Oext_exception - in - Osig_typext (ext, es) + (*****************************) + (* Polymorphic Unification *) + (*****************************) -let extension_constructor id ppf ext = - !Oprint.out_sig_item ppf (tree_of_extension_constructor id ext Text_first) +(* Since we cannot duplicate universal variables, unification must + be done at meta-level, using bindings in univar_pairs *) +let rec unify_univar t1 t2 = function + (cl1, cl2) :: rem -> + let find_univ t cl = + try + let (_, r) = List.find (fun (t',_) -> t == repr t') cl in + Some r + with Not_found -> None + in + begin match find_univ t1 cl1, find_univ t2 cl2 with + Some {contents=Some t'2}, Some _ when t2 == repr t'2 -> + () + | Some({contents=None} as r1), Some({contents=None} as r2) -> + set_univar r1 t2; set_univar r2 t1 + | None, None -> + unify_univar t1 t2 rem + | _ -> + raise (Unify []) + end + | [] -> raise (Unify []) -(* Print a value declaration *) +(* Test the occurrence of free univars in a type *) +(* that's way too expensive. Must do some kind of caching *) +let occur_univar env ty = + let visited = ref TypeMap.empty in + let rec occur_rec bound ty = + let ty = repr ty in + if ty.level >= lowest_level && + if TypeSet.is_empty bound then + (ty.level <- pivot_level - ty.level; true) + else try + let bound' = TypeMap.find ty !visited in + if TypeSet.exists (fun x -> not (TypeSet.mem x bound)) bound' then + (visited := TypeMap.add ty (TypeSet.inter bound bound') !visited; + true) + else false + with Not_found -> + visited := TypeMap.add ty bound !visited; + true + then + match ty.desc with + Tunivar _ -> + if not (TypeSet.mem ty bound) then raise (Unify [ty, newgenvar ()]) + | Tpoly (ty, tyl) -> + let bound = List.fold_right TypeSet.add (List.map repr tyl) bound in + occur_rec bound ty + | Tconstr (_, [], _) -> () + | Tconstr (p, tl, _) -> + begin try + let td = Env.find_type p env in + List.iter2 + (fun t v -> + if Variance.(mem May_pos v || mem May_neg v) + then occur_rec bound t) + tl td.type_variance + with Not_found -> + List.iter (occur_rec bound) tl + end + | _ -> iter_type_expr (occur_rec bound) ty + in + try + occur_rec TypeSet.empty ty; unmark_type ty + with exn -> + unmark_type ty; raise exn -let tree_of_value_description id decl = - (* Format.eprintf "@[%a@]@." raw_type_expr decl.val_type; *) - let id = Ident.name id in - let ty = tree_of_type_scheme decl.val_type in - let vd = - { oval_name = id; - oval_type = ty; - oval_prims = []; - oval_attributes = [] } +(* Grouping univars by families according to their binders *) +let add_univars = + List.fold_left (fun s (t,_) -> TypeSet.add (repr t) s) + +let get_univar_family univar_pairs univars = + if univars = [] then TypeSet.empty else + let insert s = function + cl1, (_::_ as cl2) -> + if List.exists (fun (t1,_) -> TypeSet.mem (repr t1) s) cl1 then + add_univars s cl2 + else s + | _ -> s in - let vd = - match decl.val_kind with - | Val_prim p -> Primitive.print p vd - | _ -> vd + let s = List.fold_right TypeSet.add univars TypeSet.empty in + List.fold_left insert s univar_pairs + +(* Whether a family of univars escapes from a type *) +let univars_escape env univar_pairs vl ty = + let family = get_univar_family univar_pairs vl in + let visited = ref TypeSet.empty in + let rec occur t = + let t = repr t in + if TypeSet.mem t !visited then () else begin + visited := TypeSet.add t !visited; + match t.desc with + Tpoly (t, tl) -> + if List.exists (fun t -> TypeSet.mem (repr t) family) tl then () + else occur t + | Tunivar _ -> + if TypeSet.mem t family then raise Occur + | Tconstr (_, [], _) -> () + | Tconstr (p, tl, _) -> + begin try + let td = Env.find_type p env in + List.iter2 + (fun t v -> + if Variance.(mem May_pos v || mem May_neg v) then occur t) + tl td.type_variance + with Not_found -> + List.iter occur tl + end + | _ -> + iter_type_expr occur t + end in - Osig_value vd + try occur ty; false with Occur -> true -let value_description id ppf decl = - !Oprint.out_sig_item ppf (tree_of_value_description id decl) +(* Wrapper checking that no variable escapes and updating univar_pairs *) +let enter_poly env univar_pairs t1 tl1 t2 tl2 f = + let old_univars = !univar_pairs in + let known_univars = + List.fold_left (fun s (cl,_) -> add_univars s cl) + TypeSet.empty old_univars + in + let tl1 = List.map repr tl1 and tl2 = List.map repr tl2 in + if List.exists (fun t -> TypeSet.mem t known_univars) tl1 && + univars_escape env old_univars tl1 (newty(Tpoly(t2,tl2))) + || List.exists (fun t -> TypeSet.mem t known_univars) tl2 && + univars_escape env old_univars tl2 (newty(Tpoly(t1,tl1))) + then raise (Unify []); + let cl1 = List.map (fun t -> t, ref None) tl1 + and cl2 = List.map (fun t -> t, ref None) tl2 in + univar_pairs := (cl1,cl2) :: (cl2,cl1) :: old_univars; + try let res = f t1 t2 in univar_pairs := old_univars; res + with exn -> univar_pairs := old_univars; raise exn -(* Print a class type *) +let univar_pairs = ref [] -let method_type (_, kind, ty) = - match field_kind_repr kind, repr ty with - Fpresent, {desc=Tpoly(ty, tyl)} -> (ty, tyl) - | _ , ty -> (ty, []) -let tree_of_metho sch concrete csil (lab, kind, ty) = - if lab <> dummy_method then begin - let kind = field_kind_repr kind in - let priv = kind <> Fpresent in - let virt = not (Concr.mem lab concrete) in - let (ty, tyl) = method_type (lab, kind, ty) in - let tty = tree_of_typexp sch ty in - remove_names tyl; - Ocsg_method (lab, priv, virt, tty) :: csil - end - else csil + (*****************) + (* Unification *) + (*****************) -let rec prepare_class_type params = function - | Cty_constr (_p, tyl, cty) -> - let sty = Ctype.self_type cty in - if List.memq (proxy sty) !visited_objects - || not (List.for_all is_Tvar params) - || List.exists (deep_occur sty) tyl - then prepare_class_type params cty - else List.iter mark_loops tyl - | Cty_signature sign -> - let sty = repr sign.csig_self in - (* Self may have a name *) - let px = proxy sty in - if List.memq px !visited_objects then add_alias sty - else visited_objects := px :: !visited_objects; - let (fields, _) = - Ctype.flatten_fields (Ctype.object_fields sign.csig_self) - in - List.iter (fun met -> mark_loops (fst (method_type met))) fields; - Vars.iter (fun _ (_, _, ty) -> mark_loops ty) sign.csig_vars - | Cty_arrow (_, ty, cty) -> - mark_loops ty; - prepare_class_type params cty -let rec tree_of_class_type sch params = - function - | Cty_constr (p', tyl, cty) -> - let sty = Ctype.self_type cty in - if List.memq (proxy sty) !visited_objects - || not (List.for_all is_Tvar params) - then - tree_of_class_type sch params cty - else - Octy_constr (tree_of_path p', tree_of_typlist true tyl) - | Cty_signature sign -> - let sty = repr sign.csig_self in - let self_ty = - if is_aliased sty then - Some (Otyp_var (false, name_of_type new_name (proxy sty))) - else None - in - let (fields, _) = - Ctype.flatten_fields (Ctype.object_fields sign.csig_self) - in - let csil = [] in - let csil = - List.fold_left - (fun csil (ty1, ty2) -> Ocsg_constraint (ty1, ty2) :: csil) - csil (tree_of_constraints params) - in - let all_vars = - Vars.fold (fun l (m, v, t) all -> (l, m, v, t) :: all) sign.csig_vars [] - in - (* Consequence of PR#3607: order of Map.fold has changed! *) - let all_vars = List.rev all_vars in - let csil = - List.fold_left - (fun csil (l, m, v, t) -> - Ocsg_value (l, m = Mutable, v = Virtual, tree_of_typexp sch t) - :: csil) - csil all_vars - in - let csil = - List.fold_left (tree_of_metho sch sign.csig_concr) csil fields - in - Octy_signature (self_ty, List.rev csil) - | Cty_arrow (l, ty, cty) -> - let lab = - if !print_labels || is_optional l then string_of_label l else "" - in - let ty = - if is_optional l then - match (repr ty).desc with - | Tconstr(path, [ty], _) when Path.same path Predef.path_option -> ty - | _ -> newconstr (Path.Pident(Ident.create "")) [] - else ty in - let tr = tree_of_typexp sch ty in - Octy_arrow (lab, tr, tree_of_class_type sch params cty) -let class_type ppf cty = - reset (); - prepare_class_type [] cty; - !Oprint.out_class_type ppf (tree_of_class_type false [] cty) +let rec has_cached_expansion p abbrev = + match abbrev with + Mnil -> false + | Mcons(_, p', _, _, rem) -> Path.same p p' || has_cached_expansion p rem + | Mlink rem -> has_cached_expansion p !rem -let tree_of_class_param param variance = - (match tree_of_typexp true param with - Otyp_var (_, s) -> s - | _ -> "?"), - if is_Tvar (repr param) then (true, true) else variance +(**** Transform error trace ****) +(* +++ Move it to some other place ? *) -let class_variance = - List.map Variance.(fun v -> mem May_pos v, mem May_neg v) +let expand_trace env trace = + List.fold_right + (fun (t1, t2) rem -> + (repr t1, full_expand env t1)::(repr t2, full_expand env t2)::rem) + trace [] -let tree_of_class_declaration id cl rs = - let params = filter_params cl.cty_params in +(* build a dummy variant type *) +let mkvariant fields closed = + newgenty + (Tvariant + {row_fields = fields; row_closed = closed; row_more = newvar(); + row_bound = (); row_fixed = false; row_name = None }) - reset (); - List.iter add_alias params; - prepare_class_type params cl.cty_type; - let sty = Ctype.self_type cl.cty_type in - List.iter mark_loops params; +(**** Unification ****) - List.iter check_name_of_type (List.map proxy params); - if is_aliased sty then check_name_of_type (proxy sty); +(* Return whether [t0] occurs in [ty]. Objects are also traversed. *) +let deep_occur t0 ty = + let rec occur_rec ty = + let ty = repr ty in + if ty.level >= lowest_level then begin + if ty == t0 then raise Occur; + ty.level <- pivot_level - ty.level; + iter_type_expr occur_rec ty + end + in + try + occur_rec ty; unmark_type ty; false + with Occur -> + unmark_type ty; true - let vir_flag = cl.cty_new = None in - Osig_class - (vir_flag, Ident.name id, - List.map2 tree_of_class_param params (class_variance cl.cty_variance), - tree_of_class_type true params cl.cty_type, - tree_of_rec rs) +(* + 1. When unifying two non-abbreviated types, one type is made a link + to the other. When unifying an abbreviated type with a + non-abbreviated type, the non-abbreviated type is made a link to + the other one. When unifying to abbreviated types, these two + types are kept distincts, but they are made to (temporally) + expand to the same type. + 2. Abbreviations with at least one parameter are systematically + expanded. The overhead does not seem too high, and that way + abbreviations where some parameters does not appear in the + expansion, such as ['a t = int], are correctly handled. In + particular, for this example, unifying ['a t] with ['b t] keeps + ['a] and ['b] distincts. (Is it really important ?) + 3. Unifying an abbreviation ['a t = 'a] with ['a] should not yield + ['a t as 'a]. Indeed, the type variable would otherwise be lost. + This problem occurs for abbreviations expanding to a type + variable, but also to many other constrained abbreviations (for + instance, [(< x : 'a > -> unit) t = ]). The solution is + that, if an abbreviation is unified with some subpart of its + parameters, then the parameter actually does not get + abbreviated. It would be possible to check whether some + information is indeed lost, but it probably does not worth it. +*) -let class_declaration id ppf cl = - !Oprint.out_sig_item ppf (tree_of_class_declaration id cl Trec_first) +let newtype_level = ref None -let tree_of_cltype_declaration id cl rs = - let params = List.map repr cl.clty_params in +let get_newtype_level () = + match !newtype_level with + | None -> assert false + | Some x -> x - reset (); - List.iter add_alias params; - prepare_class_type params cl.clty_type; - let sty = Ctype.self_type cl.clty_type in - List.iter mark_loops params; +(* a local constraint can be added only if the rhs + of the constraint does not contain any Tvars. + They need to be removed using this function *) +let reify env t = + let newtype_level = get_newtype_level () in + let create_fresh_constr lev name = + let decl = new_declaration (Some (newtype_level, newtype_level)) None in + let name = match name with Some s -> "$'"^s | _ -> "$" in + let path = Path.Pident (Ident.create (get_new_abstract_name name)) in + let new_env = Env.add_local_type path decl !env in + let t = newty2 lev (Tconstr (path,[],ref Mnil)) in + env := new_env; + t + in + let visited = ref TypeSet.empty in + let rec iterator ty = + let ty = repr ty in + if TypeSet.mem ty !visited then () else begin + visited := TypeSet.add ty !visited; + match ty.desc with + Tvar o -> + let t = create_fresh_constr ty.level o in + link_type ty t; + if ty.level < newtype_level then + raise (Unify [t, newvar2 ty.level]) + | Tvariant r -> + let r = row_repr r in + if not (static_row r) then begin + if r.row_fixed then iterator (row_more r) else + let m = r.row_more in + match m.desc with + Tvar o -> + let t = create_fresh_constr m.level o in + let row = + {r with row_fields=[]; row_fixed=true; row_more = t} in + link_type m (newty2 m.level (Tvariant row)); + if m.level < newtype_level then + raise (Unify [t, newvar2 m.level]) + | _ -> assert false + end; + iter_row iterator r + | Tconstr (p, _, _) when is_object_type p -> + iter_type_expr iterator (full_expand !env ty) + | _ -> + iter_type_expr iterator ty + end + in + iterator t - List.iter check_name_of_type (List.map proxy params); - if is_aliased sty then check_name_of_type (proxy sty); +let is_newtype env p = + try + let decl = Env.find_type p env in + decl.type_newtype_level <> None && + decl.type_kind = Type_abstract && + decl.type_private = Public + with Not_found -> false - let sign = Ctype.signature_of_class_type cl.clty_type in +let non_aliasable p decl = + (* in_pervasives p || (subsumed by in_current_module) *) + in_current_module p && decl.type_newtype_level = None - let virt = - let (fields, _) = - Ctype.flatten_fields (Ctype.object_fields sign.csig_self) in - List.exists - (fun (lab, _, _) -> - not (lab = dummy_method || Concr.mem lab sign.csig_concr)) - fields - || Vars.fold (fun _ (_,vr,_) b -> vr = Virtual || b) sign.csig_vars false - in +let is_instantiable env p = + try + let decl = Env.find_type p env in + decl.type_kind = Type_abstract && + decl.type_private = Public && + decl.type_arity = 0 && + decl.type_manifest = None && + not (non_aliasable p decl) + with Not_found -> false - Osig_class_type - (virt, Ident.name id, - List.map2 tree_of_class_param params (class_variance cl.clty_variance), - tree_of_class_type true params cl.clty_type, - tree_of_rec rs) -let cltype_declaration id ppf cl = - !Oprint.out_sig_item ppf (tree_of_cltype_declaration id cl Trec_first) +(* PR#7113: -safe-string should be a global property *) +let compatible_paths p1 p2 = + let open Predef in + Path.same p1 p2 || + Path.same p1 path_bytes && Path.same p2 path_string || + Path.same p1 path_string && Path.same p2 path_bytes -(* Print a module type *) +(* Check for datatypes carefully; see PR#6348 *) +let rec expands_to_datatype env ty = + let ty = repr ty in + match ty.desc with + Tconstr (p, _, _) -> + begin try + is_datatype (Env.find_type p env) || + expands_to_datatype env (try_expand_once env ty) + with Not_found | Cannot_expand -> false + end + | _ -> false -let wrap_env fenv ftree arg = - let env = !printing_env in - set_printing_env (fenv env); - let tree = ftree arg in - set_printing_env env; - tree +(* mcomp type_pairs subst env t1 t2 does not raise an + exception if it is possible that t1 and t2 are actually + equal, assuming the types in type_pairs are equal and + that the mapping subst holds. + Assumes that both t1 and t2 do not contain any tvars + and that both their objects and variants are closed + *) -let filter_rem_sig item rem = - match item, rem with - | Sig_class _, ctydecl :: tydecl1 :: tydecl2 :: rem -> - ([ctydecl; tydecl1; tydecl2], rem) - | Sig_class_type _, tydecl1 :: tydecl2 :: rem -> - ([tydecl1; tydecl2], rem) +let rec mcomp type_pairs env t1 t2 = + if t1 == t2 then () else + let t1 = repr t1 in + let t2 = repr t2 in + if t1 == t2 then () else + match (t1.desc, t2.desc) with + | (Tvar _, _) + | (_, Tvar _) -> + () + | (Tconstr (p1, [], _), Tconstr (p2, [], _)) when Path.same p1 p2 -> + () | _ -> - ([], rem) + let t1' = expand_head_opt env t1 in + let t2' = expand_head_opt env t2 in + (* Expansion may have changed the representative of the types... *) + let t1' = repr t1' and t2' = repr t2' in + if t1' == t2' then () else + begin try TypePairs.find type_pairs (t1', t2') + with Not_found -> + TypePairs.add type_pairs (t1', t2') (); + match (t1'.desc, t2'.desc) with + (Tvar _, Tvar _) -> assert false + | (Tarrow (l1, t1, u1, _), Tarrow (l2, t2, u2, _)) + when l1 = l2 || not (is_optional l1 || is_optional l2) -> + mcomp type_pairs env t1 t2; + mcomp type_pairs env u1 u2; + | (Ttuple tl1, Ttuple tl2) -> + mcomp_list type_pairs env tl1 tl2 + | (Tconstr (p1, tl1, _), Tconstr (p2, tl2, _)) -> + mcomp_type_decl type_pairs env p1 p2 tl1 tl2 + | (Tconstr (p, _, _), _) | (_, Tconstr (p, _, _)) -> + begin try + let decl = Env.find_type p env in + if non_aliasable p decl || is_datatype decl then raise (Unify []) + with Not_found -> () + end + (* + | (Tpackage (p1, n1, tl1), Tpackage (p2, n2, tl2)) when n1 = n2 -> + mcomp_list type_pairs env tl1 tl2 + *) + | (Tpackage _, Tpackage _) -> () + | (Tvariant row1, Tvariant row2) -> + mcomp_row type_pairs env row1 row2 + | (Tobject (fi1, _), Tobject (fi2, _)) -> + mcomp_fields type_pairs env fi1 fi2 + | (Tfield _, Tfield _) -> (* Actually unused *) + mcomp_fields type_pairs env t1' t2' + | (Tnil, Tnil) -> + () + | (Tpoly (t1, []), Tpoly (t2, [])) -> + mcomp type_pairs env t1 t2 + | (Tpoly (t1, tl1), Tpoly (t2, tl2)) -> + enter_poly env univar_pairs t1 tl1 t2 tl2 + (mcomp type_pairs env) + | (Tunivar _, Tunivar _) -> + unify_univar t1' t2' !univar_pairs + | (_, _) -> + raise (Unify []) + end -let dummy = - { type_params = []; type_arity = 0; type_kind = Type_abstract; - type_private = Public; type_manifest = None; type_variance = []; - type_newtype_level = None; type_loc = Location.none; - type_attributes = []; - type_immediate = false; - type_unboxed = unboxed_false_default_false; - } +and mcomp_list type_pairs env tl1 tl2 = + if List.length tl1 <> List.length tl2 then + raise (Unify []); + List.iter2 (mcomp type_pairs env) tl1 tl2 -let hide_rec_items = function - | Sig_type(id, _decl, rs) ::rem - when rs = Trec_first && not !Clflags.real_paths -> - let rec get_ids = function - Sig_type (id, _, Trec_next) :: rem -> - id :: get_ids rem - | _ -> [] - in - let ids = id :: get_ids rem in - set_printing_env - (List.fold_right - (fun id -> Env.add_type ~check:false (Ident.rename id) dummy) - ids !printing_env) - | _ -> () +and mcomp_fields type_pairs env ty1 ty2 = + if not (concrete_object ty1 && concrete_object ty2) then assert false; + let (fields2, rest2) = flatten_fields ty2 in + let (fields1, rest1) = flatten_fields ty1 in + let (pairs, miss1, miss2) = associate_fields fields1 fields2 in + let has_present = + List.exists (fun (_, k, _) -> field_kind_repr k = Fpresent) in + mcomp type_pairs env rest1 rest2; + if has_present miss1 && (object_row ty2).desc = Tnil + || has_present miss2 && (object_row ty1).desc = Tnil then raise (Unify []); + List.iter + (function (_n, k1, t1, k2, t2) -> + mcomp_kind k1 k2; + mcomp type_pairs env t1 t2) + pairs -let rec tree_of_modtype ?(ellipsis=false) = function - | Mty_ident p -> - Omty_ident (tree_of_path p) - | Mty_signature sg -> - Omty_signature (if ellipsis then [Osig_ellipsis] - else tree_of_signature sg) - | Mty_functor(param, ty_arg, ty_res) -> - let res = - match ty_arg with None -> tree_of_modtype ~ellipsis ty_res - | Some mty -> - wrap_env (Env.add_module ~arg:true param mty) - (tree_of_modtype ~ellipsis) ty_res - in - Omty_functor (Ident.name param, - may_map (tree_of_modtype ~ellipsis:false) ty_arg, res) - | Mty_alias(_, p) -> - Omty_alias (tree_of_path p) +and mcomp_kind k1 k2 = + let k1 = field_kind_repr k1 in + let k2 = field_kind_repr k2 in + match k1, k2 with + (Fpresent, Fabsent) + | (Fabsent, Fpresent) -> raise (Unify []) + | _ -> () -and tree_of_signature sg = - wrap_env (fun env -> env) (tree_of_signature_rec !printing_env false) sg +and mcomp_row type_pairs env row1 row2 = + let row1 = row_repr row1 and row2 = row_repr row2 in + let r1, r2, pairs = merge_row_fields row1.row_fields row2.row_fields in + let cannot_erase (_,f) = + match row_field_repr f with + Rpresent _ -> true + | Rabsent | Reither _ -> false + in + if row1.row_closed && List.exists cannot_erase r2 + || row2.row_closed && List.exists cannot_erase r1 then raise (Unify []); + List.iter + (fun (_,f1,f2) -> + match row_field_repr f1, row_field_repr f2 with + | Rpresent None, (Rpresent (Some _) | Reither (_, _::_, _, _) | Rabsent) + | Rpresent (Some _), (Rpresent None | Reither (true, _, _, _) | Rabsent) + | (Reither (_, _::_, _, _) | Rabsent), Rpresent None + | (Reither (true, _, _, _) | Rabsent), Rpresent (Some _) -> + raise (Unify []) + | Rpresent(Some t1), Rpresent(Some t2) -> + mcomp type_pairs env t1 t2 + | Rpresent(Some t1), Reither(false, tl2, _, _) -> + List.iter (mcomp type_pairs env t1) tl2 + | Reither(false, tl1, _, _), Rpresent(Some t2) -> + List.iter (mcomp type_pairs env t2) tl1 + | _ -> ()) + pairs -and tree_of_signature_rec env' in_type_group = function - [] -> [] - | item :: rem as items -> - let in_type_group = - match in_type_group, item with - true, Sig_type (_, _, Trec_next) -> true - | _, Sig_type (_, _, (Trec_not | Trec_first)) -> - set_printing_env env'; true - | _ -> set_printing_env env'; false +and mcomp_type_decl type_pairs env p1 p2 tl1 tl2 = + try + let decl = Env.find_type p1 env in + let decl' = Env.find_type p2 env in + if compatible_paths p1 p2 then begin + let inj = + try List.map Variance.(mem Inj) (Env.find_type p1 env).type_variance + with Not_found -> List.map (fun _ -> false) tl1 in - let (sg, rem) = filter_rem_sig item rem in - hide_rec_items items; - let trees = trees_of_sigitem item in - let env' = Env.add_signature (item :: sg) env' in - trees @ tree_of_signature_rec env' in_type_group rem + List.iter2 + (fun i (t1,t2) -> if i then mcomp type_pairs env t1 t2) + inj (List.combine tl1 tl2) + end else if non_aliasable p1 decl && non_aliasable p2 decl' then + raise (Unify []) + else + match decl.type_kind, decl'.type_kind with + | Type_record (lst,r), Type_record (lst',r') when r = r' -> + mcomp_list type_pairs env tl1 tl2; + mcomp_record_description type_pairs env lst lst' + | Type_variant v1, Type_variant v2 -> + mcomp_list type_pairs env tl1 tl2; + mcomp_variant_description type_pairs env v1 v2 + | Type_open, Type_open -> + mcomp_list type_pairs env tl1 tl2 + | Type_abstract, Type_abstract -> () + | Type_abstract, _ when not (non_aliasable p1 decl)-> () + | _, Type_abstract when not (non_aliasable p2 decl') -> () + | _ -> raise (Unify []) + with Not_found -> () -and trees_of_sigitem = function - | Sig_value(id, decl) -> - [tree_of_value_description id decl] - | Sig_type(id, _, _) when is_row_name (Ident.name id) -> - [] - | Sig_type(id, decl, rs) -> - [tree_of_type_declaration id decl rs] - | Sig_typext(id, ext, es) -> - [tree_of_extension_constructor id ext es] - | Sig_module(id, md, rs) -> - let ellipsis = - List.exists (function ({txt="..."}, Parsetree.PStr []) -> true - | _ -> false) - md.md_attributes in - [tree_of_module id md.md_type rs ~ellipsis] - | Sig_modtype(id, decl) -> - [tree_of_modtype_declaration id decl] - | Sig_class(id, decl, rs) -> - [tree_of_class_declaration id decl rs] - | Sig_class_type(id, decl, rs) -> - [tree_of_cltype_declaration id decl rs] +and mcomp_type_option type_pairs env t t' = + match t, t' with + None, None -> () + | Some t, Some t' -> mcomp type_pairs env t t' + | _ -> raise (Unify []) -and tree_of_modtype_declaration id decl = - let mty = - match decl.mtd_type with - | None -> Omty_abstract - | Some mty -> tree_of_modtype mty +and mcomp_variant_description type_pairs env xs ys = + let rec iter = fun x y -> + match x, y with + | c1 :: xs, c2 :: ys -> + mcomp_type_option type_pairs env c1.cd_res c2.cd_res; + begin match c1.cd_args, c2.cd_args with + | Cstr_tuple l1, Cstr_tuple l2 -> mcomp_list type_pairs env l1 l2 + | Cstr_record l1, Cstr_record l2 -> + mcomp_record_description type_pairs env l1 l2 + | _ -> raise (Unify []) + end; + if Ident.name c1.cd_id = Ident.name c2.cd_id + then iter xs ys + else raise (Unify []) + | [],[] -> () + | _ -> raise (Unify []) in - Osig_modtype (Ident.name id, mty) - -and tree_of_module id ?ellipsis mty rs = - Osig_module (Ident.name id, tree_of_modtype ?ellipsis mty, tree_of_rec rs) - -let modtype ppf mty = !Oprint.out_module_type ppf (tree_of_modtype mty) -let modtype_declaration id ppf decl = - !Oprint.out_sig_item ppf (tree_of_modtype_declaration id decl) - -(* For the toplevel: merge with tree_of_signature? *) - -(* Refresh weak variable map in the toplevel *) -let refresh_weak () = - let refresh t name (m,s) = - if is_non_gen true (repr t) then - begin - TypeMap.add t name m, - StringSet.add name s - end - else m, s in - let m, s = - TypeMap.fold refresh !weak_var_map (TypeMap.empty ,StringSet.empty) in - named_weak_vars := s; - weak_var_map := m - -let print_items showval env x = - refresh_weak(); - let rec print showval env = function - | [] -> [] - | item :: rem as items -> - let (_sg, rem) = filter_rem_sig item rem in - hide_rec_items items; - let trees = trees_of_sigitem item in - List.map (fun d -> (d, showval env item)) trees @ - print showval env rem in - print showval env x + iter xs ys -(* Print a signature body (used by -i when compiling a .ml) *) +and mcomp_record_description type_pairs env = + let rec iter x y = + match x, y with + | l1 :: xs, l2 :: ys -> + mcomp type_pairs env l1.ld_type l2.ld_type; + if Ident.name l1.ld_id = Ident.name l2.ld_id && + l1.ld_mutable = l2.ld_mutable + then iter xs ys + else raise (Unify []) + | [], [] -> () + | _ -> raise (Unify []) + in + iter -let print_signature ppf tree = - fprintf ppf "@[%a@]" !Oprint.out_signature tree +let mcomp env t1 t2 = + mcomp (TypePairs.create 4) env t1 t2 -let signature ppf sg = - fprintf ppf "%a" print_signature (tree_of_signature sg) +(* Real unification *) -(* Print an unification error *) +let find_lowest_level ty = + let lowest = ref generic_level in + let rec find ty = + let ty = repr ty in + if ty.level >= lowest_level then begin + if ty.level < !lowest then lowest := ty.level; + ty.level <- pivot_level - ty.level; + iter_type_expr find ty + end + in find ty; unmark_type ty; !lowest -let same_path t t' = - let t = repr t and t' = repr t' in - t == t' || - match t.desc, t'.desc with - Tconstr(p,tl,_), Tconstr(p',tl',_) -> - let (p1, s1) = best_type_path p and (p2, s2) = best_type_path p' in - begin match s1, s2 with - Nth n1, Nth n2 when n1 = n2 -> true - | (Id | Map _), (Id | Map _) when Path.same p1 p2 -> - let tl = apply_subst s1 tl and tl' = apply_subst s2 tl' in - List.length tl = List.length tl' && - List.for_all2 same_type tl tl' - | _ -> false - end - | _ -> - false +let find_newtype_level env path = + try match (Env.find_type path env).type_newtype_level with + Some x -> x + | None -> raise Not_found + with Not_found -> let lev = Path.binding_time path in (lev, lev) -let type_expansion t ppf t' = - if same_path t t' - then begin add_delayed (proxy t); type_expr ppf t end - else - let t' = if proxy t == proxy t' then unalias t' else t' in - fprintf ppf "@[<2>%a@ =@ %a@]" type_expr t type_expr t' +let add_gadt_equation env source destination = + if local_non_recursive_abbrev !env source destination then begin + let destination = duplicate_type destination in + let source_lev = find_newtype_level !env source in + let decl = new_declaration (Some source_lev) (Some destination) in + let newtype_level = get_newtype_level () in + env := Env.add_local_constraint source decl newtype_level !env; + cleanup_abbrev () + end -let type_path_expansion tp ppf tp' = - if Path.same tp tp' then path ppf tp else - fprintf ppf "@[<2>%a@ =@ %a@]" path tp path tp' +let unify_eq_set = TypePairs.create 11 -let rec trace fst txt ppf = function - | (t1, t1') :: (t2, t2') :: rem -> - if not fst then fprintf ppf "@,"; - fprintf ppf "@[Type@;<1 2>%a@ %s@;<1 2>%a@] %a" - (type_expansion t1) t1' txt (type_expansion t2) t2' - (trace false txt) rem - | _ -> () +let order_type_pair t1 t2 = + if t1.id <= t2.id then (t1, t2) else (t2, t1) -let rec filter_trace keep_last = function - | (_, t1') :: (_, t2') :: [] when is_Tvar t1' || is_Tvar t2' -> - [] - | (t1, t1') :: (t2, t2') :: rem -> - let rem' = filter_trace keep_last rem in - if is_constr_row ~allow_ident:true t1' - || is_constr_row ~allow_ident:true t2' - || same_path t1 t1' && same_path t2 t2' && not (keep_last && rem' = []) - then rem' - else (t1, t1') :: (t2, t2') :: rem' - | _ -> [] +let add_type_equality t1 t2 = + TypePairs.add unify_eq_set (order_type_pair t1 t2) () -let rec type_path_list ppf = function - | [tp, tp'] -> type_path_expansion tp ppf tp' - | (tp, tp') :: rem -> - fprintf ppf "%a@;<2 0>%a" - (type_path_expansion tp) tp' - type_path_list rem - | [] -> () +let eq_package_path env p1 p2 = + Path.same p1 p2 || + Path.same (normalize_package_path env p1) (normalize_package_path env p2) -(* Hide variant name and var, to force printing the expanded type *) -let hide_variant_name t = - match repr t with - | {desc = Tvariant row} as t when (row_repr row).row_name <> None -> - newty2 t.level - (Tvariant {(row_repr row) with row_name = None; - row_more = newvar2 (row_more row).level}) - | _ -> t +let nondep_type' = ref (fun _ _ _ -> assert false) +let package_subtype = ref (fun _ _ _ _ _ _ _ -> assert false) -let prepare_expansion (t, t') = - let t' = hide_variant_name t' in - mark_loops t; - if not (same_path t t') then mark_loops t'; - (t, t') +let rec concat_longident lid1 = + let open Longident in + function + Lident s -> Ldot (lid1, s) + | Ldot (lid2, s) -> Ldot (concat_longident lid1 lid2, s) + | Lapply (lid2, lid) -> Lapply (concat_longident lid1 lid2, lid) -let may_prepare_expansion compact (t, t') = - match (repr t').desc with - Tvariant _ | Tobject _ when compact -> - mark_loops t; (t, t) - | _ -> prepare_expansion (t, t') +let nondep_instance env level id ty = + let ty = !nondep_type' env id ty in + if level = generic_level then duplicate_type ty else + let old = !current_level in + current_level := level; + let ty = instance env ty in + current_level := old; + ty -let print_tags ppf fields = - match fields with [] -> () - | (t, _) :: fields -> - fprintf ppf "`%s" t; - List.iter (fun (t, _) -> fprintf ppf ",@ `%s" t) fields +(* Find the type paths nl1 in the module type mty2, and add them to the + list (nl2, tl2). raise Not_found if impossible *) +let complete_type_list ?(allow_absent=false) env nl1 lv2 mty2 nl2 tl2 = + let id2 = Ident.create "Pkg" in + let env' = Env.add_module id2 mty2 env in + let rec complete nl1 ntl2 = + match nl1, ntl2 with + [], _ -> ntl2 + | n :: nl, (n2, _ as nt2) :: ntl' when n >= n2 -> + nt2 :: complete (if n = n2 then nl else nl1) ntl' + | n :: nl, _ -> + try + let path = + Env.lookup_type (concat_longident (Longident.Lident "Pkg") n) env' + in + match Env.find_type path env' with + {type_arity = 0; type_kind = Type_abstract; + type_private = Public; type_manifest = Some t2} -> + (n, nondep_instance env' lv2 id2 t2) :: complete nl ntl2 + | {type_arity = 0; type_kind = Type_abstract; + type_private = Public; type_manifest = None} when allow_absent -> + complete nl ntl2 + | _ -> raise Exit + with + | Not_found when allow_absent -> complete nl ntl2 + | Exit -> raise Not_found + in + complete nl1 (List.combine nl2 tl2) -let has_explanation t3 t4 = - match t3.desc, t4.desc with - Tfield _, (Tnil|Tconstr _) | (Tnil|Tconstr _), Tfield _ - | Tnil, Tconstr _ | Tconstr _, Tnil - | _, Tvar _ | Tvar _, _ - | Tvariant _, Tvariant _ -> true - | Tfield (l,_,_,{desc=Tnil}), Tfield (l',_,_,{desc=Tnil}) -> l = l' - | _ -> false +(* raise Not_found rather than Unify if the module types are incompatible *) +let unify_package env unify_list lv1 p1 n1 tl1 lv2 p2 n2 tl2 = + let ntl2 = complete_type_list env n1 lv2 (Mty_ident p2) n2 tl2 + and ntl1 = complete_type_list env n2 lv1 (Mty_ident p1) n1 tl1 in + unify_list (List.map snd ntl1) (List.map snd ntl2); + if eq_package_path env p1 p2 + || !package_subtype env p1 n1 tl1 p2 n2 tl2 + && !package_subtype env p2 n2 tl2 p1 n1 tl1 then () else raise Not_found -let rec mismatch = function - (_, t) :: (_, t') :: rem -> - begin match mismatch rem with - Some _ as m -> m - | None -> - if has_explanation t t' then Some(t,t') else None - end - | [] -> None - | _ -> assert false -let explanation unif t3 t4 ppf = - match t3.desc, t4.desc with - | Ttuple [], Tvar _ | Tvar _, Ttuple [] -> - fprintf ppf "@,Self type cannot escape its class" - | Tconstr (p, _, _), Tvar _ - when unif && t4.level < Path.binding_time p -> - fprintf ppf - "@,@[The type constructor@;<1 2>%a@ would escape its scope@]" - path p - | Tvar _, Tconstr (p, _, _) - when unif && t3.level < Path.binding_time p -> - fprintf ppf - "@,@[The type constructor@;<1 2>%a@ would escape its scope@]" - path p - | Tvar _, Tunivar _ | Tunivar _, Tvar _ -> - fprintf ppf "@,The universal variable %a would escape its scope" - type_expr (if is_Tunivar t3 then t3 else t4) - | Tvar _, _ | _, Tvar _ -> - let t, t' = if is_Tvar t3 then (t3, t4) else (t4, t3) in - if occur_in Env.empty t t' then - fprintf ppf "@,@[The type variable %a occurs inside@ %a@]" - type_expr t type_expr t' - else - fprintf ppf "@,@[This instance of %a is ambiguous:@ %s@]" - type_expr t' - "it would escape the scope of its equation" - | Tfield (lab, _, _, _), _ when lab = dummy_method -> - fprintf ppf - "@,Self type cannot be unified with a closed object type" - | _, Tfield (lab, _, _, _) when lab = dummy_method -> - fprintf ppf - "@,Self type cannot be unified with a closed object type" - | Tfield (l,_,_,{desc=Tnil}), Tfield (l',_,_,{desc=Tnil}) when l = l' -> - fprintf ppf "@,Types for method %s are incompatible" l - | (Tnil|Tconstr _), Tfield (l, _, _, _) -> - fprintf ppf - "@,@[The first object type has no method %s@]" l - | Tfield (l, _, _, _), (Tnil|Tconstr _) -> - fprintf ppf - "@,@[The second object type has no method %s@]" l - | Tnil, Tconstr _ | Tconstr _, Tnil -> - fprintf ppf - "@,@[The %s object type has an abstract row, it cannot be closed@]" - (if t4.desc = Tnil then "first" else "second") - | Tvariant row1, Tvariant row2 -> - let row1 = row_repr row1 and row2 = row_repr row2 in - begin match - row1.row_fields, row1.row_closed, row2.row_fields, row2.row_closed with - | [], true, [], true -> - fprintf ppf "@,These two variant types have no intersection" - | [], true, (_::_ as fields), _ -> - fprintf ppf - "@,@[The first variant type does not allow tag(s)@ @[%a@]@]" - print_tags fields - | (_::_ as fields), _, [], true -> - fprintf ppf - "@,@[The second variant type does not allow tag(s)@ @[%a@]@]" - print_tags fields - | [l1,_], true, [l2,_], true when l1 = l2 -> - fprintf ppf "@,Types for tag `%s are incompatible" l1 - | _ -> () - end - | _ -> () +(* force unification in Reither when one side has a non-conjunctive type *) +let rigid_variants = ref false +(* drop not force unification in Reither, even in fixed case + (not sound, only use it when checking exhaustiveness) *) +let passive_variants = ref false +let with_passive_variants f x = + if !passive_variants then f x else + match passive_variants := true; f x with + | r -> passive_variants := false; r + | exception e -> passive_variants := false; raise e -let warn_on_missing_def env ppf t = - match t.desc with - | Tconstr (p,_,_) -> - begin - try - ignore(Env.find_type p env : Types.type_declaration) - with Not_found -> - fprintf ppf - "@,@[%a is abstract because no corresponding cmi file was found \ - in path.@]" path p - end - | _ -> () +let unify_eq t1 t2 = + t1 == t2 || + match !umode with + | Expression -> false + | Pattern -> + try TypePairs.find unify_eq_set (order_type_pair t1 t2); true + with Not_found -> false -let explanation unif mis ppf = - match mis with - None -> () - | Some (t3, t4) -> explanation unif t3 t4 ppf +let unify1_var env t1 t2 = + assert (is_Tvar t1); + occur env t1 t2; + occur_univar env t2; + let d1 = t1.desc in + link_type t1 t2; + try + update_level env t1.level t2 + with Unify _ as e -> + t1.desc <- d1; + raise e -let ident_same_name id1 id2 = - if Ident.equal id1 id2 && not (Ident.same id1 id2) then begin - add_unique id1; add_unique id2 - end +let rec unify (env:Env.t ref) t1 t2 = + (* First step: special cases (optimizations) *) + if t1 == t2 then () else + let t1 = repr t1 in + let t2 = repr t2 in + if unify_eq t1 t2 then () else + let reset_tracing = check_trace_gadt_instances !env in -let rec path_same_name p1 p2 = - match p1, p2 with - Pident id1, Pident id2 -> ident_same_name id1 id2 - | Pdot (p1, s1, _), Pdot (p2, s2, _) when s1 = s2 -> path_same_name p1 p2 - | Papply (p1, p1'), Papply (p2, p2') -> - path_same_name p1 p2; path_same_name p1' p2' - | _ -> () + try + type_changed := true; + begin match (t1.desc, t2.desc) with + (Tvar _, Tconstr _) when deep_occur t1 t2 -> + unify2 env t1 t2 + | (Tconstr _, Tvar _) when deep_occur t2 t1 -> + unify2 env t1 t2 + | (Tvar _, _) -> + unify1_var !env t1 t2 + | (_, Tvar _) -> + unify1_var !env t2 t1 + | (Tunivar _, Tunivar _) -> + unify_univar t1 t2 !univar_pairs; + update_level !env t1.level t2; + link_type t1 t2 + | (Tconstr (p1, [], a1), Tconstr (p2, [], a2)) + when Path.same p1 p2 (* && actual_mode !env = Old *) + (* This optimization assumes that t1 does not expand to t2 + (and conversely), so we fall back to the general case + when any of the types has a cached expansion. *) + && not (has_cached_expansion p1 !a1 + || has_cached_expansion p2 !a2) -> + update_level !env t1.level t2; + link_type t1 t2 + | (Tconstr (p1, [], _), Tconstr (p2, [], _)) + when Env.has_local_constraints !env + && is_newtype !env p1 && is_newtype !env p2 -> + (* Do not use local constraints more than necessary *) + begin try + if find_newtype_level !env p1 < find_newtype_level !env p2 then + unify env t1 (try_expand_once !env t2) + else + unify env (try_expand_once !env t1) t2 + with Cannot_expand -> + unify2 env t1 t2 + end + | _ -> + unify2 env t1 t2 + end; + reset_trace_gadt_instances reset_tracing; + with Unify trace -> + reset_trace_gadt_instances reset_tracing; + raise (Unify ((t1, t2)::trace)) -let type_same_name t1 t2 = - match (repr t1).desc, (repr t2).desc with - Tconstr (p1, _, _), Tconstr (p2, _, _) -> - path_same_name (fst (best_type_path p1)) (fst (best_type_path p2)) - | _ -> () +and unify2 env t1 t2 = + (* Second step: expansion of abbreviations *) + (* Expansion may change the representative of the types. *) + ignore (expand_head_unif !env t1); + ignore (expand_head_unif !env t2); + let t1' = expand_head_unif !env t1 in + let t2' = expand_head_unif !env t2 in + let lv = min t1'.level t2'.level in + update_level !env lv t2; + update_level !env lv t1; + if unify_eq t1' t2' then () else -let rec trace_same_names = function - (t1, t1') :: (t2, t2') :: rem -> - type_same_name t1 t2; type_same_name t1' t2'; trace_same_names rem - | _ -> () + let t1 = repr t1 and t2 = repr t2 in + if !trace_gadt_instances then begin + (* All types in chains already have the same ambiguity levels *) + let ilevel t = + match Env.gadt_instance_level !env t with None -> 0 | Some lv -> lv in + let lv1 = ilevel t1 and lv2 = ilevel t2 in + if lv1 > lv2 then Env.add_gadt_instance_chain !env lv1 t2 else + if lv2 > lv1 then Env.add_gadt_instance_chain !env lv2 t1 + end; + let t1, t2 = + if !Clflags.principal + && (find_lowest_level t1' < lv || find_lowest_level t2' < lv) then + (* Expand abbreviations hiding a lower level *) + (* Should also do it for parameterized types, after unification... *) + (match t1.desc with Tconstr (_, [], _) -> t1' | _ -> t1), + (match t2.desc with Tconstr (_, [], _) -> t2' | _ -> t2) + else (t1, t2) + in + if unify_eq t1 t1' || not (unify_eq t2 t2') then + unify3 env t1 t1' t2 t2' + else + try unify3 env t2 t2' t1 t1' with Unify trace -> + raise (Unify (List.map (fun (x, y) -> (y, x)) trace)) -let unification_error env unif tr txt1 ppf txt2 = - reset (); - trace_same_names tr; - let tr = List.map (fun (t, t') -> (t, hide_variant_name t')) tr in - let mis = mismatch tr in - match tr with - | [] | _ :: [] -> assert false - | t1 :: t2 :: tr -> +and unify3 env t1 t1' t2 t2' = + (* Third step: truly unification *) + (* Assumes either [t1 == t1'] or [t2 != t2'] *) + let d1 = t1'.desc and d2 = t2'.desc in + let create_recursion = (t2 != t2') && (deep_occur t1' t2) in + + begin match (d1, d2) with (* handle vars and univars specially *) + (Tunivar _, Tunivar _) -> + unify_univar t1' t2' !univar_pairs; + link_type t1' t2' + | (Tvar _, _) -> + occur !env t1' t2; + occur_univar !env t2; + link_type t1' t2; + | (_, Tvar _) -> + occur !env t2' t1; + occur_univar !env t1; + link_type t2' t1; + | (Tfield _, Tfield _) -> (* special case for GADTs *) + unify_fields env t1' t2' + | _ -> + begin match !umode with + | Expression -> + occur !env t1' t2'; + link_type t1' t2 + | Pattern -> + add_type_equality t1' t2' + end; try - let tr = filter_trace (mis = None) tr in - let t1, t1' = may_prepare_expansion (tr = []) t1 - and t2, t2' = may_prepare_expansion (tr = []) t2 in - print_labels := not !Clflags.classic; - let tr = List.map prepare_expansion tr in - fprintf ppf - "@[\ - @[%t@;<1 2>%a@ \ - %t@;<1 2>%a\ - @]%a%t\ - @]" - txt1 (type_expansion t1) t1' - txt2 (type_expansion t2) t2' - (trace false "is not compatible with type") tr - (explanation unif mis); - if env <> Env.empty - then begin - warn_on_missing_def env ppf t1; - warn_on_missing_def env ppf t2 + begin match (d1, d2) with + (Tarrow (l1, t1, u1, c1), Tarrow (l2, t2, u2, c2)) when l1 = l2 || + (!Clflags.classic || !umode = Pattern) && + not (is_optional l1 || is_optional l2) -> + unify env t1 t2; unify env u1 u2; + begin match commu_repr c1, commu_repr c2 with + Clink r, c2 -> set_commu r c2 + | c1, Clink r -> set_commu r c1 + | _ -> () + end + | (Ttuple tl1, Ttuple tl2) -> + unify_list env tl1 tl2 + | (Tconstr (p1, tl1, _), Tconstr (p2, tl2, _)) when Path.same p1 p2 -> + if !umode = Expression || not !generate_equations then + unify_list env tl1 tl2 + else if !assume_injective then + set_mode_pattern ~generate:true ~injective:false + (fun () -> unify_list env tl1 tl2) + else if in_current_module p1 (* || in_pervasives p1 *) + || List.exists (expands_to_datatype !env) [t1'; t1; t2] then + unify_list env tl1 tl2 + else + let inj = + try List.map Variance.(mem Inj) + (Env.find_type p1 !env).type_variance + with Not_found -> List.map (fun _ -> false) tl1 + in + List.iter2 + (fun i (t1, t2) -> + if i then unify env t1 t2 else + set_mode_pattern ~generate:false ~injective:false + begin fun () -> + let snap = snapshot () in + try unify env t1 t2 with Unify _ -> + backtrack snap; + reify env t1; reify env t2 + end) + inj (List.combine tl1 tl2) + | (Tconstr (path,[],_), + Tconstr (path',[],_)) + when is_instantiable !env path && is_instantiable !env path' + && !generate_equations -> + let source, destination = + if find_newtype_level !env path > find_newtype_level !env path' + then path , t2' + else path', t1' + in + add_gadt_equation env source destination + | (Tconstr (path,[],_), _) + when is_instantiable !env path && !generate_equations -> + reify env t2'; + add_gadt_equation env path t2' + | (_, Tconstr (path,[],_)) + when is_instantiable !env path && !generate_equations -> + reify env t1'; + add_gadt_equation env path t1' + | (Tconstr (_,_,_), _) | (_, Tconstr (_,_,_)) when !umode = Pattern -> + reify env t1'; + reify env t2'; + if !generate_equations then mcomp !env t1' t2' + | (Tobject (fi1, nm1), Tobject (fi2, _)) -> + unify_fields env fi1 fi2; + (* Type [t2'] may have been instantiated by [unify_fields] *) + (* XXX One should do some kind of unification... *) + begin match (repr t2').desc with + Tobject (_, {contents = Some (_, va::_)}) when + (match (repr va).desc with + Tvar _|Tunivar _|Tnil -> true | _ -> false) -> () + | Tobject (_, nm2) -> set_name nm2 !nm1 + | _ -> () + end + | (Tvariant row1, Tvariant row2) -> + if !umode = Expression then + unify_row env row1 row2 + else begin + let snap = snapshot () in + try unify_row env row1 row2 + with Unify _ -> + backtrack snap; + reify env t1'; + reify env t2'; + if !generate_equations then mcomp !env t1' t2' + end + | (Tfield(f,kind,_,rem), Tnil) | (Tnil, Tfield(f,kind,_,rem)) -> + begin match field_kind_repr kind with + Fvar r when f <> dummy_method -> + set_kind r Fabsent; + if d2 = Tnil then unify env rem t2' + else unify env (newty2 rem.level Tnil) rem + | _ -> raise (Unify []) + end + | (Tnil, Tnil) -> + () + | (Tpoly (t1, []), Tpoly (t2, [])) -> + unify env t1 t2 + | (Tpoly (t1, tl1), Tpoly (t2, tl2)) -> + enter_poly !env univar_pairs t1 tl1 t2 tl2 (unify env) + | (Tpackage (p1, n1, tl1), Tpackage (p2, n2, tl2)) -> + begin try + unify_package !env (unify_list env) + t1.level p1 n1 tl1 t2.level p2 n2 tl2 + with Not_found -> + if !umode = Expression then raise (Unify []); + List.iter (reify env) (tl1 @ tl2); + (* if !generate_equations then List.iter2 (mcomp !env) tl1 tl2 *) + end + | (_, _) -> + raise (Unify []) end; - print_labels := true - with exn -> - print_labels := true; - raise exn + (* XXX Commentaires + changer "create_recursion" + ||| Comments + change "create_recursion" *) + if create_recursion then + match t2.desc with + Tconstr (p, tl, abbrev) -> + forget_abbrev abbrev p; + let t2'' = expand_head_unif !env t2 in + if not (closed_parameterized_type tl t2'') then + link_type (repr t2) (repr t2') + | _ -> + () (* t2 has already been expanded by update_level *) + with Unify trace -> + t1'.desc <- d1; + raise (Unify trace) + end -let report_unification_error ppf env ?(unif=true) - tr txt1 txt2 = - wrap_printing_env env (fun () -> unification_error env unif tr txt1 ppf txt2) -;; +and unify_list env tl1 tl2 = + if List.length tl1 <> List.length tl2 then + raise (Unify []); + List.iter2 (unify env) tl1 tl2 + +(* Build a fresh row variable for unification *) +and make_rowvar level use1 rest1 use2 rest2 = + let set_name ty name = + match ty.desc with + Tvar None -> log_type ty; ty.desc <- Tvar name + | _ -> () + in + let name = + match rest1.desc, rest2.desc with + Tvar (Some _ as name1), Tvar (Some _ as name2) -> + if rest1.level <= rest2.level then name1 else name2 + | Tvar (Some _ as name), _ -> + if use2 then set_name rest2 name; name + | _, Tvar (Some _ as name) -> + if use1 then set_name rest2 name; name + | _ -> None + in + if use1 then rest1 else + if use2 then rest2 else newvar2 ?name level + +and unify_fields env ty1 ty2 = (* Optimization *) + let (fields1, rest1) = flatten_fields ty1 + and (fields2, rest2) = flatten_fields ty2 in + let (pairs, miss1, miss2) = associate_fields fields1 fields2 in + let l1 = (repr ty1).level and l2 = (repr ty2).level in + let va = make_rowvar (min l1 l2) (miss2=[]) rest1 (miss1=[]) rest2 in + let d1 = rest1.desc and d2 = rest2.desc in + try + unify env (build_fields l1 miss1 va) rest2; + unify env rest1 (build_fields l2 miss2 va); + List.iter + (fun (n, k1, t1, k2, t2) -> + unify_kind k1 k2; + try + if !trace_gadt_instances then update_level !env va.level t1; + unify env t1 t2 + with Unify trace -> + raise (Unify ((newty (Tfield(n, k1, t1, newty Tnil)), + newty (Tfield(n, k2, t2, newty Tnil)))::trace))) + pairs + with exn -> + log_type rest1; rest1.desc <- d1; + log_type rest2; rest2.desc <- d2; + raise exn +and unify_kind k1 k2 = + let k1 = field_kind_repr k1 in + let k2 = field_kind_repr k2 in + if k1 == k2 then () else + match k1, k2 with + (Fvar r, (Fvar _ | Fpresent)) -> set_kind r k2 + | (Fpresent, Fvar r) -> set_kind r k1 + | (Fpresent, Fpresent) -> () + | _ -> assert false -let super_type_expansion ~tag t ppf t' = - if same_path t t' then begin - Format.pp_open_tag ppf tag; - type_expr ppf t; - Format.pp_close_tag ppf (); - end else begin - let t' = if proxy t == proxy t' then unalias t' else t' in - fprintf ppf "@[<2>"; - Format.pp_open_tag ppf tag; - fprintf ppf "%a" type_expr t; - Format.pp_close_tag ppf (); - fprintf ppf "@ @{(defined as@}@ "; - Format.pp_open_tag ppf tag; - fprintf ppf "%a" type_expr t'; - Format.pp_close_tag ppf (); - fprintf ppf "@{)@}"; - fprintf ppf "@]"; +and unify_row env row1 row2 = + let row1 = row_repr row1 and row2 = row_repr row2 in + let rm1 = row_more row1 and rm2 = row_more row2 in + if unify_eq rm1 rm2 then () else + let r1, r2, pairs = merge_row_fields row1.row_fields row2.row_fields in + if r1 <> [] && r2 <> [] then begin + let ht = Hashtbl.create (List.length r1) in + List.iter (fun (l,_) -> Hashtbl.add ht (hash_variant l) l) r1; + List.iter + (fun (l,_) -> + try raise (Tags(l, Hashtbl.find ht (hash_variant l))) + with Not_found -> ()) + r2 + end; + let fixed1 = row_fixed row1 and fixed2 = row_fixed row2 in + let more = + if fixed1 then rm1 else + if fixed2 then rm2 else + newty2 (min rm1.level rm2.level) (Tvar None) in + let fixed = fixed1 || fixed2 + and closed = row1.row_closed || row2.row_closed in + let keep switch = + List.for_all + (fun (_,f1,f2) -> + let f1, f2 = switch f1 f2 in + row_field_repr f1 = Rabsent || row_field_repr f2 <> Rabsent) + pairs + in + let empty fields = + List.for_all (fun (_,f) -> row_field_repr f = Rabsent) fields in + (* Check whether we are going to build an empty type *) + if closed && (empty r1 || row2.row_closed) && (empty r2 || row1.row_closed) + && List.for_all + (fun (_,f1,f2) -> + row_field_repr f1 = Rabsent || row_field_repr f2 = Rabsent) + pairs + then raise (Unify [mkvariant [] true, mkvariant [] true]); + let name = + if row1.row_name <> None && (row1.row_closed || empty r2) && + (not row2.row_closed || keep (fun f1 f2 -> f1, f2) && empty r1) + then row1.row_name + else if row2.row_name <> None && (row2.row_closed || empty r1) && + (not row1.row_closed || keep (fun f1 f2 -> f2, f1) && empty r2) + then row2.row_name + else None + in + let row0 = {row_fields = []; row_more = more; row_bound = (); + row_closed = closed; row_fixed = fixed; row_name = name} in + let set_more row rest = + let rest = + if closed then + filter_row_fields row.row_closed rest + else rest in + if rest <> [] && (row.row_closed || row_fixed row) + || closed && row_fixed row && not row.row_closed then begin + let t1 = mkvariant [] true and t2 = mkvariant rest false in + raise (Unify [if row == row1 then (t1,t2) else (t2,t1)]) + end; + (* The following test is not principal... should rather use Tnil *) + let rm = row_more row in + (*if !trace_gadt_instances && rm.desc = Tnil then () else*) + if !trace_gadt_instances then + update_level !env rm.level (newgenty (Tvariant row)); + if row_fixed row then + if more == rm then () else + if is_Tvar rm then link_type rm more else unify env rm more + else + let ty = newgenty (Tvariant {row0 with row_fields = rest}) in + update_level !env rm.level ty; + link_type rm ty + in + let md1 = rm1.desc and md2 = rm2.desc in + begin try + set_more row2 r1; + set_more row1 r2; + List.iter + (fun (l,f1,f2) -> + try unify_row_field env fixed1 fixed2 more l f1 f2 + with Unify trace -> + raise (Unify ((mkvariant [l,f1] true, + mkvariant [l,f2] true) :: trace))) + pairs; + if static_row row1 then begin + let rm = row_more row1 in + if is_Tvar rm then link_type rm (newty2 rm.level Tnil) + end + with exn -> + log_type rm1; rm1.desc <- md1; log_type rm2; rm2.desc <- md2; raise exn end -let super_trace ppf = - let rec super_trace first_report ppf = function - | (t1, t1') :: (t2, t2') :: rem -> - fprintf ppf - "@,@,@["; - if first_report then - fprintf ppf "The incompatible parts:@," - else begin - fprintf ppf "Further expanded:@," +and unify_row_field env fixed1 fixed2 more l f1 f2 = + let f1 = row_field_repr f1 and f2 = row_field_repr f2 in + if f1 == f2 then () else + match f1, f2 with + Rpresent(Some t1), Rpresent(Some t2) -> unify env t1 t2 + | Rpresent None, Rpresent None -> () + | Reither(c1, tl1, m1, e1), Reither(c2, tl2, m2, e2) -> + if e1 == e2 then () else + if (fixed1 || fixed2) && not (c1 || c2) + && List.length tl1 = List.length tl2 then begin + (* PR#7496 *) + let f = Reither (c1 || c2, [], m1 || m2, ref None) in + set_row_field e1 f; set_row_field e2 f; + List.iter2 (unify env) tl1 tl2 + end + else let redo = + not !passive_variants && + (m1 || m2 || fixed1 || fixed2 || + !rigid_variants && (List.length tl1 = 1 || List.length tl2 = 1)) && + begin match tl1 @ tl2 with [] -> false + | t1 :: tl -> + if c1 || c2 then raise (Unify []); + List.iter (unify env t1) tl; + !e1 <> None || !e2 <> None + end in + if redo then unify_row_field env fixed1 fixed2 more l f1 f2 else + let tl1 = List.map repr tl1 and tl2 = List.map repr tl2 in + let rec remq tl = function [] -> [] + | ty :: tl' -> + if List.memq ty tl then remq tl tl' else ty :: remq tl tl' + in + let tl2' = remq tl2 tl1 and tl1' = remq tl1 tl2 in + (* PR#6744 *) + let split_univars = + List.partition + (fun ty -> try occur_univar !env ty; true with Unify _ -> false) in + let (tl1',tlu1) = split_univars tl1' + and (tl2',tlu2) = split_univars tl2' in + begin match tlu1, tlu2 with + [], [] -> () + | (tu1::tlu1), _ :: _ -> + (* Attempt to merge all the types containing univars *) + if not !passive_variants then + List.iter (unify env tu1) (tlu1@tlu2) + | (tu::_, []) | ([], tu::_) -> occur_univar !env tu end; - fprintf ppf - "@[\ - @[%a@]@,\ - vs@,\ - @[%a@]\ - %a\ - @]" - (super_type_expansion ~tag:"error" t1) t1' - (super_type_expansion ~tag:"info" t2) t2' - (super_trace false) rem; - fprintf ppf "@]" - | _ -> () - in super_trace true ppf + (* Is this handling of levels really principal? *) + List.iter (update_level !env (repr more).level) (tl1' @ tl2'); + let e = ref None in + let f1' = Reither(c1 || c2, tl1', m1 || m2, e) + and f2' = Reither(c1 || c2, tl2', m1 || m2, e) in + set_row_field e1 f1'; set_row_field e2 f2'; + | Reither(_, _, false, e1), Rabsent when not fixed1 -> set_row_field e1 f2 + | Rabsent, Reither(_, _, false, e2) when not fixed2 -> set_row_field e2 f1 + | Rabsent, Rabsent -> () + | Reither(false, tl, _, e1), Rpresent(Some t2) when not fixed1 -> + set_row_field e1 f2; + update_level !env (repr more).level t2; + (try List.iter (fun t1 -> unify env t1 t2) tl + with exn -> e1 := None; raise exn) + | Rpresent(Some t1), Reither(false, tl, _, e2) when not fixed2 -> + set_row_field e2 f1; + update_level !env (repr more).level t1; + (try List.iter (unify env t1) tl + with exn -> e2 := None; raise exn) + | Reither(true, [], _, e1), Rpresent None when not fixed1 -> + set_row_field e1 f2 + | Rpresent None, Reither(true, [], _, e2) when not fixed2 -> + set_row_field e2 f1 + | _ -> raise (Unify []) -let super_unification_error unif tr txt1 ppf txt2 = begin - reset (); - trace_same_names tr; - let tr = List.map (fun (t, t') -> (t, hide_variant_name t')) tr in - let mis = mismatch tr in - match tr with - | [] | _ :: [] -> assert false - | t1 :: t2 :: tr -> - try - let tr = filter_trace (mis = None) tr in - let t1, t1' = may_prepare_expansion (tr = []) t1 - and t2, t2' = may_prepare_expansion (tr = []) t2 in - print_labels := not !Clflags.classic; - let tr = List.map prepare_expansion tr in - fprintf ppf - "@[\ - @[\ - %t@,\ - @[<2>%a@]\ - @]@,\ - @[\ - %t@,\ - @[<2>%a@]\ - @]\ - %a\ - %t\ - @]" - txt1 (super_type_expansion ~tag:"error" t1) t1' - txt2 (super_type_expansion ~tag:"info" t2) t2' - super_trace tr - (explanation unif mis); - print_labels := true - with exn -> - print_labels := true; - raise exn -end -let super_report_unification_error ppf env ?(unif=true) - tr txt1 txt2 = - wrap_printing_env env (fun () -> super_unification_error unif tr txt1 ppf txt2) -;; +let unify env ty1 ty2 = + let snap = Btype.snapshot () in + try + unify env ty1 ty2 + with + Unify trace -> + undo_compress snap; + raise (Unify (expand_trace !env trace)) + | Recursive_abbrev -> + undo_compress snap; + raise (Unification_recursive_abbrev (expand_trace !env [(ty1,ty2)])) +let unify_gadt ~newtype_level:lev (env:Env.t ref) ty1 ty2 = + try + univar_pairs := []; + newtype_level := Some lev; + set_mode_pattern ~generate:true ~injective:true + (fun () -> unify env ty1 ty2); + newtype_level := None; + TypePairs.clear unify_eq_set; + with e -> + newtype_level := None; + TypePairs.clear unify_eq_set; + raise e -let trace fst keep_last txt ppf tr = - print_labels := not !Clflags.classic; - trace_same_names tr; - try match tr with - t1 :: t2 :: tr' -> - if fst then trace fst txt ppf (t1 :: t2 :: filter_trace keep_last tr') - else trace fst txt ppf (filter_trace keep_last tr); - print_labels := true - | _ -> () - with exn -> - print_labels := true; - raise exn +let unify_var env t1 t2 = + let t1 = repr t1 and t2 = repr t2 in + if t1 == t2 then () else + match t1.desc, t2.desc with + Tvar _, Tconstr _ when deep_occur t1 t2 -> + unify (ref env) t1 t2 + | Tvar _, _ -> + let reset_tracing = check_trace_gadt_instances env in + begin try + occur env t1 t2; + update_level env t1.level t2; + link_type t1 t2; + reset_trace_gadt_instances reset_tracing; + with Unify trace -> + reset_trace_gadt_instances reset_tracing; + let expanded_trace = expand_trace env ((t1,t2)::trace) in + raise (Unify expanded_trace) + end + | _ -> + unify (ref env) t1 t2 -let report_subtyping_error ppf env tr1 txt1 tr2 = - wrap_printing_env env (fun () -> - reset (); - let tr1 = List.map prepare_expansion tr1 - and tr2 = List.map prepare_expansion tr2 in - fprintf ppf "@[%a" (trace true (tr2 = []) txt1) tr1; - if tr2 = [] then fprintf ppf "@]" else - let mis = mismatch tr2 in - fprintf ppf "%a%t@]" - (trace false (mis = None) "is not compatible with type") tr2 - (explanation true mis)) +let _ = unify' := unify_var -let report_ambiguous_type_error ppf env (tp0, tp0') tpl txt1 txt2 txt3 = - wrap_printing_env env (fun () -> - reset (); - List.iter - (fun (tp, tp') -> path_same_name tp0 tp; path_same_name tp0' tp') - tpl; - match tpl with - [] -> assert false - | [tp, tp'] -> - fprintf ppf - "@[%t@;<1 2>%a@ \ - %t@;<1 2>%a\ - @]" - txt1 (type_path_expansion tp) tp' - txt3 (type_path_expansion tp0) tp0' - | _ -> - fprintf ppf - "@[%t@;<1 2>@[%a@]\ - @ %t@;<1 2>%a\ - @]" - txt2 type_path_list tpl - txt3 (type_path_expansion tp0) tp0') +let unify_pairs env ty1 ty2 pairs = + univar_pairs := pairs; + unify env ty1 ty2 -end -module Includeclass : sig -#1 "includeclass.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Jerome Vouillon, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1997 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let unify env ty1 ty2 = + unify_pairs (ref env) ty1 ty2 [] -(* Inclusion checks for the class language *) -open Types -open Ctype -open Format -val class_types: - Env.t -> class_type -> class_type -> class_match_failure list -val class_type_declarations: - loc:Location.t -> - Env.t -> class_type_declaration -> class_type_declaration -> - class_match_failure list -val class_declarations: - Env.t -> class_declaration -> class_declaration -> - class_match_failure list +(**** Special cases of unification ****) -val report_error: formatter -> class_match_failure list -> unit +let expand_head_trace env t = + let reset_tracing = check_trace_gadt_instances env in + let t = expand_head_unif env t in + reset_trace_gadt_instances reset_tracing; + t -end = struct -#1 "includeclass.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Jerome Vouillon, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1997 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +(* + Unify [t] and [l:'a -> 'b]. Return ['a] and ['b]. + In label mode, label mismatch is accepted when + (1) the requested label is "" + (2) the original label is not optional +*) -(* Inclusion checks for the class language *) +let filter_arrow env t l = + let t = expand_head_trace env t in + match t.desc with + Tvar _ -> + let lv = t.level in + let t1 = newvar2 lv and t2 = newvar2 lv in + let t' = newty2 lv (Tarrow (l, t1, t2, Cok)) in + link_type t t'; + (t1, t2) + | Tarrow(l', t1, t2, _) + when l = l' || !Clflags.classic && l = Nolabel && not (is_optional l') -> + (t1, t2) + | _ -> + raise (Unify []) -open Types +(* Used by [filter_method]. *) +let rec filter_method_field env name priv ty = + let ty = expand_head_trace env ty in + match ty.desc with + Tvar _ -> + let level = ty.level in + let ty1 = newvar2 level and ty2 = newvar2 level in + let ty' = newty2 level (Tfield (name, + begin match priv with + Private -> Fvar (ref None) + | Public -> Fpresent + end, + ty1, ty2)) + in + link_type ty ty'; + ty1 + | Tfield(n, kind, ty1, ty2) -> + let kind = field_kind_repr kind in + if (n = name) && (kind <> Fabsent) then begin + if priv = Public then + unify_kind kind Fpresent; + ty1 + end else + filter_method_field env name priv ty2 + | _ -> + raise (Unify []) -let class_types env cty1 cty2 = - Ctype.match_class_types env cty1 cty2 +(* Unify [ty] and [< name : 'a; .. >]. Return ['a]. *) +let filter_method env name priv ty = + let ty = expand_head_trace env ty in + match ty.desc with + Tvar _ -> + let ty1 = newvar () in + let ty' = newobj ty1 in + update_level env ty.level ty'; + link_type ty ty'; + filter_method_field env name priv ty1 + | Tobject(f, _) -> + filter_method_field env name priv f + | _ -> + raise (Unify []) -let class_type_declarations ~loc env cty1 cty2 = - Builtin_attributes.check_deprecated_inclusion - ~def:cty1.clty_loc - ~use:cty2.clty_loc - loc - cty1.clty_attributes cty2.clty_attributes - (Path.last cty1.clty_path); - Ctype.match_class_declarations env - cty1.clty_params cty1.clty_type - cty2.clty_params cty2.clty_type +let check_filter_method env name priv ty = + ignore(filter_method env name priv ty) -let class_declarations env cty1 cty2 = - match cty1.cty_new, cty2.cty_new with - None, Some _ -> - [Ctype.CM_Virtual_class] - | _ -> - Ctype.match_class_declarations env - cty1.cty_params cty1.cty_type - cty2.cty_params cty2.cty_type +let filter_self_method env lab priv meths ty = + let ty' = filter_method env lab priv ty in + try + Meths.find lab !meths + with Not_found -> + let pair = (Ident.create lab, ty') in + meths := Meths.add lab pair !meths; + pair -open Format -open Ctype + + (***********************************) + (* Matching between type schemes *) + (***********************************) (* -let rec hide_params = function - Tcty_arrow ("*", _, cty) -> hide_params cty - | cty -> cty + Update the level of [ty]. First check that the levels of generic + variables from the subject are not lowered. *) +let moregen_occur env level ty = + let rec occur ty = + let ty = repr ty in + if ty.level > level then begin + if is_Tvar ty && ty.level >= generic_level - 1 then raise Occur; + ty.level <- pivot_level - ty.level; + match ty.desc with + Tvariant row when static_row row -> + iter_row occur row + | _ -> + iter_type_expr occur ty + end + in + begin try + occur ty; unmark_type ty + with Occur -> + unmark_type ty; raise (Unify []) + end; + (* also check for free univars *) + occur_univar env ty; + update_level env level ty -let include_err ppf = - function - | CM_Virtual_class -> - fprintf ppf "A class cannot be changed from virtual to concrete" - | CM_Parameter_arity_mismatch _ -> - fprintf ppf - "The classes do not have the same number of type parameters" - | CM_Type_parameter_mismatch (env, trace) -> - Printtyp.report_unification_error ppf env ~unif:false trace - (function ppf -> - fprintf ppf "A type parameter has type") - (function ppf -> - fprintf ppf "but is expected to have type") - | CM_Class_type_mismatch (env, cty1, cty2) -> - Printtyp.wrap_printing_env env (fun () -> - fprintf ppf - "@[The class type@;<1 2>%a@ %s@;<1 2>%a@]" - Printtyp.class_type cty1 - "is not matched by the class type" - Printtyp.class_type cty2) - | CM_Parameter_mismatch (env, trace) -> - Printtyp.report_unification_error ppf env ~unif:false trace - (function ppf -> - fprintf ppf "A parameter has type") - (function ppf -> - fprintf ppf "but is expected to have type") - | CM_Val_type_mismatch (lab, env, trace) -> - Printtyp.report_unification_error ppf env ~unif:false trace - (function ppf -> - fprintf ppf "The instance variable %s@ has type" lab) - (function ppf -> - fprintf ppf "but is expected to have type") - | CM_Meth_type_mismatch (lab, env, trace) -> - Printtyp.report_unification_error ppf env ~unif:false trace - (function ppf -> - fprintf ppf "The method %s@ has type" lab) - (function ppf -> - fprintf ppf "but is expected to have type") - | CM_Non_mutable_value lab -> - fprintf ppf - "@[The non-mutable instance variable %s cannot become mutable@]" lab - | CM_Non_concrete_value lab -> - fprintf ppf - "@[The virtual instance variable %s cannot become concrete@]" lab - | CM_Missing_value lab -> - fprintf ppf "@[The first class type has no instance variable %s@]" lab - | CM_Missing_method lab -> - fprintf ppf "@[The first class type has no method %s@]" lab - | CM_Hide_public lab -> - fprintf ppf "@[The public method %s cannot be hidden@]" lab - | CM_Hide_virtual (k, lab) -> - fprintf ppf "@[The virtual %s %s cannot be hidden@]" k lab - | CM_Public_method lab -> - fprintf ppf "@[The public method %s cannot become private" lab - | CM_Virtual_method lab -> - fprintf ppf "@[The virtual method %s cannot become concrete" lab - | CM_Private_method lab -> - fprintf ppf "The private method %s cannot become public" lab - -let report_error ppf = function - | [] -> () - | err :: errs -> - let print_errs ppf errs = - List.iter (fun err -> fprintf ppf "@ %a" include_err err) errs in - fprintf ppf "@[%a%a@]" include_err err print_errs errs +let may_instantiate inst_nongen t1 = + if inst_nongen then t1.level <> generic_level - 1 + else t1.level = generic_level -end -module Includecore : sig -#1 "includecore.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let rec moregen inst_nongen type_pairs env t1 t2 = + if t1 == t2 then () else + let t1 = repr t1 in + let t2 = repr t2 in + if t1 == t2 then () else -(* Inclusion checks for the core language *) + try + match (t1.desc, t2.desc) with + (Tvar _, _) when may_instantiate inst_nongen t1 -> + moregen_occur env t1.level t2; + occur env t1 t2; + link_type t1 t2 + | (Tconstr (p1, [], _), Tconstr (p2, [], _)) when Path.same p1 p2 -> + () + | _ -> + let t1' = expand_head env t1 in + let t2' = expand_head env t2 in + (* Expansion may have changed the representative of the types... *) + let t1' = repr t1' and t2' = repr t2' in + if t1' == t2' then () else + begin try + TypePairs.find type_pairs (t1', t2') + with Not_found -> + TypePairs.add type_pairs (t1', t2') (); + match (t1'.desc, t2'.desc) with + (Tvar _, _) when may_instantiate inst_nongen t1' -> + moregen_occur env t1'.level t2; + link_type t1' t2 + | (Tarrow (l1, t1, u1, _), Tarrow (l2, t2, u2, _)) when l1 = l2 + || !Clflags.classic && not (is_optional l1 || is_optional l2) -> + moregen inst_nongen type_pairs env t1 t2; + moregen inst_nongen type_pairs env u1 u2 + | (Ttuple tl1, Ttuple tl2) -> + moregen_list inst_nongen type_pairs env tl1 tl2 + | (Tconstr (p1, tl1, _), Tconstr (p2, tl2, _)) + when Path.same p1 p2 -> + moregen_list inst_nongen type_pairs env tl1 tl2 + | (Tpackage (p1, n1, tl1), Tpackage (p2, n2, tl2)) -> + begin try + unify_package env (moregen_list inst_nongen type_pairs env) + t1'.level p1 n1 tl1 t2'.level p2 n2 tl2 + with Not_found -> raise (Unify []) + end + | (Tvariant row1, Tvariant row2) -> + moregen_row inst_nongen type_pairs env row1 row2 + | (Tobject (fi1, _nm1), Tobject (fi2, _nm2)) -> + moregen_fields inst_nongen type_pairs env fi1 fi2 + | (Tfield _, Tfield _) -> (* Actually unused *) + moregen_fields inst_nongen type_pairs env t1' t2' + | (Tnil, Tnil) -> + () + | (Tpoly (t1, []), Tpoly (t2, [])) -> + moregen inst_nongen type_pairs env t1 t2 + | (Tpoly (t1, tl1), Tpoly (t2, tl2)) -> + enter_poly env univar_pairs t1 tl1 t2 tl2 + (moregen inst_nongen type_pairs env) + | (Tunivar _, Tunivar _) -> + unify_univar t1' t2' !univar_pairs + | (_, _) -> + raise (Unify []) + end + with Unify trace -> + raise (Unify ((t1, t2)::trace)) -open Typedtree -open Types +and moregen_list inst_nongen type_pairs env tl1 tl2 = + if List.length tl1 <> List.length tl2 then + raise (Unify []); + List.iter2 (moregen inst_nongen type_pairs env) tl1 tl2 -exception Dont_match +and moregen_fields inst_nongen type_pairs env ty1 ty2 = + let (fields1, rest1) = flatten_fields ty1 + and (fields2, rest2) = flatten_fields ty2 in + let (pairs, miss1, miss2) = associate_fields fields1 fields2 in + if miss1 <> [] then raise (Unify []); + moregen inst_nongen type_pairs env rest1 + (build_fields (repr ty2).level miss2 rest2); + List.iter + (fun (n, k1, t1, k2, t2) -> + moregen_kind k1 k2; + try moregen inst_nongen type_pairs env t1 t2 with Unify trace -> + raise (Unify ((newty (Tfield(n, k1, t1, rest2)), + newty (Tfield(n, k2, t2, rest2)))::trace))) + pairs -type type_mismatch = - Arity - | Privacy - | Kind - | Constraint - | Manifest - | Variance - | Field_type of Ident.t - | Field_mutable of Ident.t - | Field_arity of Ident.t - | Field_names of int * Ident.t * Ident.t - | Field_missing of bool * Ident.t - | Record_representation of bool - | Unboxed_representation of bool - | Immediate +and moregen_kind k1 k2 = + let k1 = field_kind_repr k1 in + let k2 = field_kind_repr k2 in + if k1 == k2 then () else + match k1, k2 with + (Fvar r, (Fvar _ | Fpresent)) -> set_kind r k2 + | (Fpresent, Fpresent) -> () + | _ -> raise (Unify []) -val value_descriptions: - loc:Location.t -> Env.t -> Ident.t -> - value_description -> value_description -> module_coercion +and moregen_row inst_nongen type_pairs env row1 row2 = + let row1 = row_repr row1 and row2 = row_repr row2 in + let rm1 = repr row1.row_more and rm2 = repr row2.row_more in + if rm1 == rm2 then () else + let may_inst = + is_Tvar rm1 && may_instantiate inst_nongen rm1 || rm1.desc = Tnil in + let r1, r2, pairs = merge_row_fields row1.row_fields row2.row_fields in + let r1, r2 = + if row2.row_closed then + filter_row_fields may_inst r1, filter_row_fields false r2 + else r1, r2 + in + if r1 <> [] || row1.row_closed && (not row2.row_closed || r2 <> []) + then raise (Unify []); + begin match rm1.desc, rm2.desc with + Tunivar _, Tunivar _ -> + unify_univar rm1 rm2 !univar_pairs + | Tunivar _, _ | _, Tunivar _ -> + raise (Unify []) + | _ when static_row row1 -> () + | _ when may_inst -> + let ext = + newgenty (Tvariant {row2 with row_fields = r2; row_name = None}) + in + moregen_occur env rm1.level ext; + link_type rm1 ext + | Tconstr _, Tconstr _ -> + moregen inst_nongen type_pairs env rm1 rm2 + | _ -> raise (Unify []) + end; + List.iter + (fun (_l,f1,f2) -> + let f1 = row_field_repr f1 and f2 = row_field_repr f2 in + if f1 == f2 then () else + match f1, f2 with + Rpresent(Some t1), Rpresent(Some t2) -> + moregen inst_nongen type_pairs env t1 t2 + | Rpresent None, Rpresent None -> () + | Reither(false, tl1, _, e1), Rpresent(Some t2) when may_inst -> + set_row_field e1 f2; + List.iter (fun t1 -> moregen inst_nongen type_pairs env t1 t2) tl1 + | Reither(c1, tl1, _, e1), Reither(c2, tl2, m2, e2) -> + if e1 != e2 then begin + if c1 && not c2 then raise(Unify []); + set_row_field e1 (Reither (c2, [], m2, e2)); + if List.length tl1 = List.length tl2 then + List.iter2 (moregen inst_nongen type_pairs env) tl1 tl2 + else match tl2 with + t2 :: _ -> + List.iter (fun t1 -> moregen inst_nongen type_pairs env t1 t2) + tl1 + | [] -> + if tl1 <> [] then raise (Unify []) + end + | Reither(true, [], _, e1), Rpresent None when may_inst -> + set_row_field e1 f2 + | Reither(_, _, _, e1), Rabsent when may_inst -> + set_row_field e1 f2 + | Rabsent, Rabsent -> () + | _ -> raise (Unify [])) + pairs -val type_declarations: - ?equality:bool -> - loc:Location.t -> - Env.t -> string -> - type_declaration -> Ident.t -> type_declaration -> type_mismatch list +(* Must empty univar_pairs first *) +let moregen inst_nongen type_pairs env patt subj = + univar_pairs := []; + moregen inst_nongen type_pairs env patt subj -val extension_constructors: - loc:Location.t -> - Env.t -> Ident.t -> - extension_constructor -> extension_constructor -> bool (* -val class_types: - Env.t -> class_type -> class_type -> bool + Non-generic variable can be instantiated only if [inst_nongen] is + true. So, [inst_nongen] should be set to false if the subject might + contain non-generic variables (and we do not want them to be + instantiated). + Usually, the subject is given by the user, and the pattern + is unimportant. So, no need to propagate abbreviations. *) +let moregeneral env inst_nongen pat_sch subj_sch = + let old_level = !current_level in + current_level := generic_level - 1; + (* + Generic variables are first duplicated with [instance]. So, + their levels are lowered to [generic_level - 1]. The subject is + then copied with [duplicate_type]. That way, its levels won't be + changed. + *) + let subj = duplicate_type (instance env subj_sch) in + current_level := generic_level; + (* Duplicate generic variables *) + let patt = instance env pat_sch in + let res = + try moregen inst_nongen (TypePairs.create 13) env patt subj; true with + Unify _ -> false + in + current_level := old_level; + res -val report_type_mismatch: - string -> string -> string -> Format.formatter -> type_mismatch list -> unit - -end = struct -#1 "includecore.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) -(* Inclusion checks for the core language *) +(* Alternative approach: "rigidify" a type scheme, + and check validity after unification *) +(* Simpler, no? *) -open Asttypes -open Path -open Types -open Typedtree +let rec rigidify_rec vars ty = + let ty = repr ty in + if ty.level >= lowest_level then begin + ty.level <- pivot_level - ty.level; + match ty.desc with + | Tvar _ -> + if not (List.memq ty !vars) then vars := ty :: !vars + | Tvariant row -> + let row = row_repr row in + let more = repr row.row_more in + if is_Tvar more && not (row_fixed row) then begin + let more' = newty2 more.level more.desc in + let row' = {row with row_fixed=true; row_fields=[]; row_more=more'} + in link_type more (newty2 ty.level (Tvariant row')) + end; + iter_row (rigidify_rec vars) row; + (* only consider the row variable if the variant is not static *) + if not (static_row row) then rigidify_rec vars (row_more row) + | _ -> + iter_type_expr (rigidify_rec vars) ty + end -(* Inclusion between value descriptions *) +let rigidify ty = + let vars = ref [] in + rigidify_rec vars ty; + unmark_type ty; + !vars -exception Dont_match +let all_distinct_vars env vars = + let tyl = ref [] in + List.for_all + (fun ty -> + let ty = expand_head env ty in + if List.memq ty !tyl then false else + (tyl := ty :: !tyl; is_Tvar ty)) + vars -let value_descriptions ~loc env name - (vd1 : Types.value_description) - (vd2 : Types.value_description) = - Builtin_attributes.check_deprecated_inclusion - ~def:vd1.val_loc - ~use:vd2.val_loc - loc - vd1.val_attributes vd2.val_attributes +let matches env ty ty' = + let snap = snapshot () in + let vars = rigidify ty in + cleanup_abbrev (); + let ok = + try unify env ty ty'; all_distinct_vars env vars + with Unify _ -> false + in + backtrack snap; + ok - (Ident.name name); - - if Ctype.moregeneral env true vd1.val_type vd2.val_type then begin - match (vd1.val_kind, vd2.val_kind) with - (Val_prim p1, Val_prim p2) -> - if p1 = p2 then Tcoerce_none else raise Dont_match - | (Val_prim p, _) -> - let pc = {pc_desc = p; pc_type = vd2.Types.val_type; - pc_env = env; pc_loc = vd1.Types.val_loc; - pc_id = name; + (*********************************************) + (* Equivalence between parameterized types *) + (*********************************************) - } in - Tcoerce_primitive pc - | (_, Val_prim _) -> raise Dont_match - | (_, _) -> Tcoerce_none - end else - raise Dont_match +let expand_head_rigid env ty = + let old = !rigid_variants in + rigid_variants := true; + let ty' = expand_head env ty in + rigid_variants := old; ty' -(* Inclusion between "private" annotations *) +let normalize_subst subst = + if List.exists + (function {desc=Tlink _}, _ | _, {desc=Tlink _} -> true | _ -> false) + !subst + then subst := List.map (fun (t1,t2) -> repr t1, repr t2) !subst -let private_flags decl1 decl2 = - match decl1.type_private, decl2.type_private with - | Private, Public -> - decl2.type_kind = Type_abstract && - (decl2.type_manifest = None || decl1.type_kind <> Type_abstract) - | _, _ -> true +let rec eqtype rename type_pairs subst env t1 t2 = + if t1 == t2 then () else + let t1 = repr t1 in + let t2 = repr t2 in + if t1 == t2 then () else -(* Inclusion between manifest types (particularly for private row types) *) + try + match (t1.desc, t2.desc) with + (Tvar _, Tvar _) when rename -> + begin try + normalize_subst subst; + if List.assq t1 !subst != t2 then raise (Unify []) + with Not_found -> + if List.exists (fun (_, t) -> t == t2) !subst then raise (Unify []); + subst := (t1, t2) :: !subst + end + | (Tconstr (p1, [], _), Tconstr (p2, [], _)) when Path.same p1 p2 -> + () + | _ -> + let t1' = expand_head_rigid env t1 in + let t2' = expand_head_rigid env t2 in + (* Expansion may have changed the representative of the types... *) + let t1' = repr t1' and t2' = repr t2' in + if t1' == t2' then () else + begin try + TypePairs.find type_pairs (t1', t2') + with Not_found -> + TypePairs.add type_pairs (t1', t2') (); + match (t1'.desc, t2'.desc) with + (Tvar _, Tvar _) when rename -> + begin try + normalize_subst subst; + if List.assq t1' !subst != t2' then raise (Unify []) + with Not_found -> + if List.exists (fun (_, t) -> t == t2') !subst + then raise (Unify []); + subst := (t1', t2') :: !subst + end + | (Tarrow (l1, t1, u1, _), Tarrow (l2, t2, u2, _)) when l1 = l2 + || !Clflags.classic && not (is_optional l1 || is_optional l2) -> + eqtype rename type_pairs subst env t1 t2; + eqtype rename type_pairs subst env u1 u2; + | (Ttuple tl1, Ttuple tl2) -> + eqtype_list rename type_pairs subst env tl1 tl2 + | (Tconstr (p1, tl1, _), Tconstr (p2, tl2, _)) + when Path.same p1 p2 -> + eqtype_list rename type_pairs subst env tl1 tl2 + | (Tpackage (p1, n1, tl1), Tpackage (p2, n2, tl2)) -> + begin try + unify_package env (eqtype_list rename type_pairs subst env) + t1'.level p1 n1 tl1 t2'.level p2 n2 tl2 + with Not_found -> raise (Unify []) + end + | (Tvariant row1, Tvariant row2) -> + eqtype_row rename type_pairs subst env row1 row2 + | (Tobject (fi1, _nm1), Tobject (fi2, _nm2)) -> + eqtype_fields rename type_pairs subst env fi1 fi2 + | (Tfield _, Tfield _) -> (* Actually unused *) + eqtype_fields rename type_pairs subst env t1' t2' + | (Tnil, Tnil) -> + () + | (Tpoly (t1, []), Tpoly (t2, [])) -> + eqtype rename type_pairs subst env t1 t2 + | (Tpoly (t1, tl1), Tpoly (t2, tl2)) -> + enter_poly env univar_pairs t1 tl1 t2 tl2 + (eqtype rename type_pairs subst env) + | (Tunivar _, Tunivar _) -> + unify_univar t1' t2' !univar_pairs + | (_, _) -> + raise (Unify []) + end + with Unify trace -> + raise (Unify ((t1, t2)::trace)) -let is_absrow env ty = - match ty.desc with - Tconstr(Pident _, _, _) -> - begin match Ctype.expand_head env ty with - {desc=Tobject _|Tvariant _} -> true - | _ -> false - end - | _ -> false +and eqtype_list rename type_pairs subst env tl1 tl2 = + if List.length tl1 <> List.length tl2 then + raise (Unify []); + List.iter2 (eqtype rename type_pairs subst env) tl1 tl2 -let type_manifest env ty1 params1 ty2 params2 priv2 = - let ty1' = Ctype.expand_head env ty1 and ty2' = Ctype.expand_head env ty2 in - match ty1'.desc, ty2'.desc with - Tvariant row1, Tvariant row2 when is_absrow env (Btype.row_more row2) -> - let row1 = Btype.row_repr row1 and row2 = Btype.row_repr row2 in - Ctype.equal env true (ty1::params1) (row2.row_more::params2) && - begin match row1.row_more with - {desc=Tvar _|Tconstr _|Tnil} -> true - | _ -> false - end && - let r1, r2, pairs = - Ctype.merge_row_fields row1.row_fields row2.row_fields in - (not row2.row_closed || - row1.row_closed && Ctype.filter_row_fields false r1 = []) && - List.for_all - (fun (_,f) -> match Btype.row_field_repr f with - Rabsent | Reither _ -> true | Rpresent _ -> false) - r2 && - let to_equal = ref (List.combine params1 params2) in - List.for_all - (fun (_, f1, f2) -> - match Btype.row_field_repr f1, Btype.row_field_repr f2 with - Rpresent(Some t1), - (Rpresent(Some t2) | Reither(false, [t2], _, _)) -> - to_equal := (t1,t2) :: !to_equal; true - | Rpresent None, (Rpresent None | Reither(true, [], _, _)) -> true - | Reither(c1,tl1,_,_), Reither(c2,tl2,_,_) - when List.length tl1 = List.length tl2 && c1 = c2 -> - to_equal := List.combine tl1 tl2 @ !to_equal; true - | Rabsent, (Reither _ | Rabsent) -> true - | _ -> false) - pairs && - let tl1, tl2 = List.split !to_equal in - Ctype.equal env true tl1 tl2 - | Tobject (fi1, _), Tobject (fi2, _) - when is_absrow env (snd(Ctype.flatten_fields fi2)) -> - let (fields2,rest2) = Ctype.flatten_fields fi2 in - Ctype.equal env true (ty1::params1) (rest2::params2) && - let (fields1,rest1) = Ctype.flatten_fields fi1 in - (match rest1 with {desc=Tnil|Tvar _|Tconstr _} -> true | _ -> false) && - let pairs, _miss1, miss2 = Ctype.associate_fields fields1 fields2 in - miss2 = [] && - let tl1, tl2 = - List.split (List.map (fun (_,_,t1,_,t2) -> t1, t2) pairs) in - Ctype.equal env true (params1 @ tl1) (params2 @ tl2) +and eqtype_fields rename type_pairs subst env ty1 ty2 = + let (fields1, rest1) = flatten_fields ty1 in + let (fields2, rest2) = flatten_fields ty2 in + (* First check if same row => already equal *) + let same_row = + rest1 == rest2 || TypePairs.mem type_pairs (rest1,rest2) || + (rename && List.mem (rest1, rest2) !subst) + in + if same_row then () else + (* Try expansion, needed when called from Includecore.type_manifest *) + match expand_head_rigid env rest2 with + {desc=Tobject(ty2,_)} -> eqtype_fields rename type_pairs subst env ty1 ty2 | _ -> - let rec check_super ty1 = - Ctype.equal env true (ty1 :: params1) (ty2 :: params2) || - priv2 = Private && - try check_super - (Ctype.try_expand_once_opt env (Ctype.expand_head env ty1)) - with Ctype.Cannot_expand -> false - in check_super ty1 + let (pairs, miss1, miss2) = associate_fields fields1 fields2 in + eqtype rename type_pairs subst env rest1 rest2; + if (miss1 <> []) || (miss2 <> []) then raise (Unify []); + List.iter + (function (n, k1, t1, k2, t2) -> + eqtype_kind k1 k2; + try eqtype rename type_pairs subst env t1 t2 with Unify trace -> + raise (Unify ((newty (Tfield(n, k1, t1, rest2)), + newty (Tfield(n, k2, t2, rest2)))::trace))) + pairs -(* Inclusion between type declarations *) +and eqtype_kind k1 k2 = + let k1 = field_kind_repr k1 in + let k2 = field_kind_repr k2 in + match k1, k2 with + (Fvar _, Fvar _) + | (Fpresent, Fpresent) -> () + | _ -> raise (Unify []) -type type_mismatch = - Arity - | Privacy - | Kind - | Constraint - | Manifest - | Variance - | Field_type of Ident.t - | Field_mutable of Ident.t - | Field_arity of Ident.t - | Field_names of int * Ident.t * Ident.t - | Field_missing of bool * Ident.t - | Record_representation of bool (* true means second one is unboxed float *) - | Unboxed_representation of bool (* true means second one is unboxed *) - | Immediate +and eqtype_row rename type_pairs subst env row1 row2 = + (* Try expansion, needed when called from Includecore.type_manifest *) + match expand_head_rigid env (row_more row2) with + {desc=Tvariant row2} -> eqtype_row rename type_pairs subst env row1 row2 + | _ -> + let row1 = row_repr row1 and row2 = row_repr row2 in + let r1, r2, pairs = merge_row_fields row1.row_fields row2.row_fields in + if row1.row_closed <> row2.row_closed + || not row1.row_closed && (r1 <> [] || r2 <> []) + || filter_row_fields false (r1 @ r2) <> [] + then raise (Unify []); + if not (static_row row1) then + eqtype rename type_pairs subst env row1.row_more row2.row_more; + List.iter + (fun (_,f1,f2) -> + match row_field_repr f1, row_field_repr f2 with + Rpresent(Some t1), Rpresent(Some t2) -> + eqtype rename type_pairs subst env t1 t2 + | Reither(c1, [], _, _), Reither(c2, [], _, _) when c1 = c2 -> + () + | Reither(c1, t1::tl1, _, _), Reither(c2, t2::tl2, _, _) when c1 = c2 -> + eqtype rename type_pairs subst env t1 t2; + if List.length tl1 = List.length tl2 then + (* if same length allow different types (meaning?) *) + List.iter2 (eqtype rename type_pairs subst env) tl1 tl2 + else begin + (* otherwise everything must be equal *) + List.iter (eqtype rename type_pairs subst env t1) tl2; + List.iter (fun t1 -> eqtype rename type_pairs subst env t1 t2) tl1 + end + | Rpresent None, Rpresent None -> () + | Rabsent, Rabsent -> () + | _ -> raise (Unify [])) + pairs -let report_type_mismatch0 first second decl ppf err = - let pr fmt = Format.fprintf ppf fmt in - match err with - Arity -> pr "They have different arities" - | Privacy -> pr "A private type would be revealed" - | Kind -> pr "Their kinds differ" - | Constraint -> pr "Their constraints differ" - | Manifest -> () - | Variance -> pr "Their variances do not agree" - | Field_type s -> - pr "The types for field %s are not equal" (Ident.name s) - | Field_mutable s -> - pr "The mutability of field %s is different" (Ident.name s) - | Field_arity s -> - pr "The arities for field %s differ" (Ident.name s) - | Field_names (n, name1, name2) -> - pr "Fields number %i have different names, %s and %s" - n (Ident.name name1) (Ident.name name2) - | Field_missing (b, s) -> - pr "The field %s is only present in %s %s" - (Ident.name s) (if b then second else first) decl - | Record_representation b -> - pr "Their internal representations differ:@ %s %s %s" - (if b then second else first) decl - "uses unboxed float representation" - | Unboxed_representation b -> - pr "Their internal representations differ:@ %s %s %s" - (if b then second else first) decl - "uses unboxed representation" - | Immediate -> pr "%s is not an immediate type" first +(* Must empty univar_pairs first *) +let eqtype_list rename type_pairs subst env tl1 tl2 = + univar_pairs := []; + let snap = Btype.snapshot () in + try eqtype_list rename type_pairs subst env tl1 tl2; backtrack snap + with exn -> backtrack snap; raise exn + +let eqtype rename type_pairs subst env t1 t2 = + eqtype_list rename type_pairs subst env [t1] [t2] -let report_type_mismatch first second decl ppf = - List.iter - (fun err -> - if err = Manifest then () else - Format.fprintf ppf "@ %a." (report_type_mismatch0 first second decl) err) +(* Two modes: with or without renaming of variables *) +let equal env rename tyl1 tyl2 = + try + eqtype_list rename (TypePairs.create 11) (ref []) env tyl1 tyl2; true + with + Unify _ -> false -let rec compare_constructor_arguments ~loc env cstr params1 params2 arg1 arg2 = - match arg1, arg2 with - | Types.Cstr_tuple arg1, Types.Cstr_tuple arg2 -> - if List.length arg1 <> List.length arg2 then [Field_arity cstr] - else if - (* Ctype.equal must be called on all arguments at once, cf. PR#7378 *) - Ctype.equal env true (params1 @ arg1) (params2 @ arg2) - then [] else [Field_type cstr] - | Types.Cstr_record l1, Types.Cstr_record l2 -> - compare_records env ~loc params1 params2 0 l1 l2 - | _ -> [Field_type cstr] -and compare_variants ~loc env params1 params2 n - (cstrs1 : Types.constructor_declaration list) - (cstrs2 : Types.constructor_declaration list) = - match cstrs1, cstrs2 with - [], [] -> [] - | [], c::_ -> [Field_missing (true, c.Types.cd_id)] - | c::_, [] -> [Field_missing (false, c.Types.cd_id)] - | cd1::rem1, cd2::rem2 -> - if Ident.name cd1.cd_id <> Ident.name cd2.cd_id then - [Field_names (n, cd1.cd_id, cd2.cd_id)] - else begin - Builtin_attributes.check_deprecated_inclusion - ~def:cd1.cd_loc - ~use:cd2.cd_loc - loc - cd1.cd_attributes cd2.cd_attributes - (Ident.name cd1.cd_id); - let r = - match cd1.cd_res, cd2.cd_res with - | Some r1, Some r2 -> - if Ctype.equal env true [r1] [r2] then - compare_constructor_arguments ~loc env cd1.cd_id [r1] [r2] - cd1.cd_args cd2.cd_args - else [Field_type cd1.cd_id] - | Some _, None | None, Some _ -> - [Field_type cd1.cd_id] - | _ -> - compare_constructor_arguments ~loc env cd1.cd_id - params1 params2 cd1.cd_args cd2.cd_args - in - if r <> [] then r - else compare_variants ~loc env params1 params2 (n+1) rem1 rem2 - end + (*************************) + (* Class type matching *) + (*************************) -and compare_records ~loc env params1 params2 n - (labels1 : Types.label_declaration list) - (labels2 : Types.label_declaration list) = - match labels1, labels2 with - [], [] -> [] - | [], l::_ -> [Field_missing (true, l.Types.ld_id)] - | l::_, [] -> [Field_missing (false, l.Types.ld_id)] - | ld1::rem1, ld2::rem2 -> - if Ident.name ld1.ld_id <> Ident.name ld2.ld_id - then [Field_names (n, ld1.ld_id, ld2.ld_id)] - else if ld1.ld_mutable <> ld2.ld_mutable then [Field_mutable ld1.ld_id] else begin - Builtin_attributes.check_deprecated_mutable_inclusion - ~def:ld1.ld_loc - ~use:ld2.ld_loc - loc - ld1.ld_attributes ld2.ld_attributes - (Ident.name ld1.ld_id); - if Ctype.equal env true (ld1.ld_type::params1)(ld2.ld_type::params2) - then (* add arguments to the parameters, cf. PR#7378 *) - compare_records ~loc env - (ld1.ld_type::params1) (ld2.ld_type::params2) - (n+1) - rem1 rem2 - else - [Field_type ld1.ld_id] - end +type class_match_failure = + CM_Virtual_class + | CM_Parameter_arity_mismatch of int * int + | CM_Type_parameter_mismatch of Env.t * (type_expr * type_expr) list + | CM_Class_type_mismatch of Env.t * class_type * class_type + | CM_Parameter_mismatch of Env.t * (type_expr * type_expr) list + | CM_Val_type_mismatch of string * Env.t * (type_expr * type_expr) list + | CM_Meth_type_mismatch of string * Env.t * (type_expr * type_expr) list + | CM_Non_mutable_value of string + | CM_Non_concrete_value of string + | CM_Missing_value of string + | CM_Missing_method of string + | CM_Hide_public of string + | CM_Hide_virtual of string * string + | CM_Public_method of string + | CM_Private_method of string + | CM_Virtual_method of string -let type_declarations ?(equality = false) ~loc env name decl1 id decl2 = - Builtin_attributes.check_deprecated_inclusion - ~def:decl1.type_loc - ~use:decl2.type_loc - loc - decl1.type_attributes decl2.type_attributes - name; - if decl1.type_arity <> decl2.type_arity then [Arity] else - if not (private_flags decl1 decl2) then [Privacy] else - let err = match (decl1.type_manifest, decl2.type_manifest) with - (_, None) -> - if Ctype.equal env true decl1.type_params decl2.type_params - then [] else [Constraint] - | (Some ty1, Some ty2) -> - if type_manifest env ty1 decl1.type_params ty2 decl2.type_params - decl2.type_private - then [] else [Manifest] - | (None, Some ty2) -> - let ty1 = - Btype.newgenty (Tconstr(Pident id, decl2.type_params, ref Mnil)) - in - if Ctype.equal env true decl1.type_params decl2.type_params then - if Ctype.equal env false [ty1] [ty2] then [] - else [Manifest] - else [Constraint] - in - if err <> [] then err else - let err = - match (decl2.type_kind, decl1.type_unboxed.unboxed, - decl2.type_unboxed.unboxed) with - | Type_abstract, _, _ -> [] - | _, true, false -> [Unboxed_representation false] - | _, false, true -> [Unboxed_representation true] - | _ -> [] +exception Failure of class_match_failure list + +let rec moregen_clty trace type_pairs env cty1 cty2 = + try + match cty1, cty2 with + Cty_constr (_, _, cty1), _ -> + moregen_clty true type_pairs env cty1 cty2 + | _, Cty_constr (_, _, cty2) -> + moregen_clty true type_pairs env cty1 cty2 + | Cty_arrow (l1, ty1, cty1'), Cty_arrow (l2, ty2, cty2') when l1 = l2 -> + begin try moregen true type_pairs env ty1 ty2 with Unify trace -> + raise (Failure [CM_Parameter_mismatch (env, expand_trace env trace)]) + end; + moregen_clty false type_pairs env cty1' cty2' + | Cty_signature sign1, Cty_signature sign2 -> + let ty1 = object_fields (repr sign1.csig_self) in + let ty2 = object_fields (repr sign2.csig_self) in + let (fields1, _rest1) = flatten_fields ty1 + and (fields2, _rest2) = flatten_fields ty2 in + let (pairs, _miss1, _miss2) = associate_fields fields1 fields2 in + List.iter + (fun (lab, _k1, t1, _k2, t2) -> + begin try moregen true type_pairs env t1 t2 with Unify trace -> + raise (Failure [CM_Meth_type_mismatch + (lab, env, expand_trace env trace)]) + end) + pairs; + Vars.iter + (fun lab (_mut, _v, ty) -> + let (_mut', _v', ty') = Vars.find lab sign1.csig_vars in + try moregen true type_pairs env ty' ty with Unify trace -> + raise (Failure [CM_Val_type_mismatch + (lab, env, expand_trace env trace)])) + sign2.csig_vars + | _ -> + raise (Failure []) + with + Failure error when trace || error = [] -> + raise (Failure (CM_Class_type_mismatch (env, cty1, cty2)::error)) + +let match_class_types ?(trace=true) env pat_sch subj_sch = + let type_pairs = TypePairs.create 53 in + let old_level = !current_level in + current_level := generic_level - 1; + (* + Generic variables are first duplicated with [instance]. So, + their levels are lowered to [generic_level - 1]. The subject is + then copied with [duplicate_type]. That way, its levels won't be + changed. + *) + let (_, subj_inst) = instance_class [] subj_sch in + let subj = duplicate_class_type subj_inst in + current_level := generic_level; + (* Duplicate generic variables *) + let (_, patt) = instance_class [] pat_sch in + let res = + let sign1 = signature_of_class_type patt in + let sign2 = signature_of_class_type subj in + let t1 = repr sign1.csig_self in + let t2 = repr sign2.csig_self in + TypePairs.add type_pairs (t1, t2) (); + let (fields1, rest1) = flatten_fields (object_fields t1) + and (fields2, rest2) = flatten_fields (object_fields t2) in + let (pairs, miss1, miss2) = associate_fields fields1 fields2 in + let error = + List.fold_right + (fun (lab, k, _) err -> + let err = + let k = field_kind_repr k in + begin match k with + Fvar r -> set_kind r Fabsent; err + | _ -> CM_Hide_public lab::err + end + in + if Concr.mem lab sign1.csig_concr then err + else CM_Hide_virtual ("method", lab) :: err) + miss1 [] + in + let missing_method = List.map (fun (m, _, _) -> m) miss2 in + let error = + (List.map (fun m -> CM_Missing_method m) missing_method) @ error + in + (* Always succeeds *) + moregen true type_pairs env rest1 rest2; + let error = + List.fold_right + (fun (lab, k1, _t1, k2, _t2) err -> + try moregen_kind k1 k2; err with + Unify _ -> CM_Public_method lab::err) + pairs error + in + let error = + Vars.fold + (fun lab (mut, vr, _ty) err -> + try + let (mut', vr', _ty') = Vars.find lab sign1.csig_vars in + if mut = Mutable && mut' <> Mutable then + CM_Non_mutable_value lab::err + else if vr = Concrete && vr' <> Concrete then + CM_Non_concrete_value lab::err + else + err + with Not_found -> + CM_Missing_value lab::err) + sign2.csig_vars error + in + let error = + Vars.fold + (fun lab (_,vr,_) err -> + if vr = Virtual && not (Vars.mem lab sign2.csig_vars) then + CM_Hide_virtual ("instance variable", lab) :: err + else err) + sign1.csig_vars error + in + let error = + List.fold_right + (fun e l -> + if List.mem e missing_method then l else CM_Virtual_method e::l) + (Concr.elements (Concr.diff sign2.csig_concr sign1.csig_concr)) + error + in + match error with + [] -> + begin try + moregen_clty trace type_pairs env patt subj; + [] + with + Failure r -> r + end + | error -> + CM_Class_type_mismatch (env, patt, subj)::error in - if err <> [] then err else - let err = match (decl1.type_kind, decl2.type_kind) with - (_, Type_abstract) -> [] - | (Type_variant cstrs1, Type_variant cstrs2) -> - let mark cstrs usage name decl = - List.iter - (fun c -> - Env.mark_constructor_used usage env name decl - (Ident.name c.Types.cd_id)) - cstrs - in - let usage = - if decl1.type_private = Private || decl2.type_private = Public - then Env.Positive else Env.Privatize + current_level := old_level; + res + +let rec equal_clty trace type_pairs subst env cty1 cty2 = + try + match cty1, cty2 with + Cty_constr (_, _, cty1), Cty_constr (_, _, cty2) -> + equal_clty true type_pairs subst env cty1 cty2 + | Cty_constr (_, _, cty1), _ -> + equal_clty true type_pairs subst env cty1 cty2 + | _, Cty_constr (_, _, cty2) -> + equal_clty true type_pairs subst env cty1 cty2 + | Cty_arrow (l1, ty1, cty1'), Cty_arrow (l2, ty2, cty2') when l1 = l2 -> + begin try eqtype true type_pairs subst env ty1 ty2 with Unify trace -> + raise (Failure [CM_Parameter_mismatch (env, expand_trace env trace)]) + end; + equal_clty false type_pairs subst env cty1' cty2' + | Cty_signature sign1, Cty_signature sign2 -> + let ty1 = object_fields (repr sign1.csig_self) in + let ty2 = object_fields (repr sign2.csig_self) in + let (fields1, _rest1) = flatten_fields ty1 + and (fields2, _rest2) = flatten_fields ty2 in + let (pairs, _miss1, _miss2) = associate_fields fields1 fields2 in + List.iter + (fun (lab, _k1, t1, _k2, t2) -> + begin try eqtype true type_pairs subst env t1 t2 with + Unify trace -> + raise (Failure [CM_Meth_type_mismatch + (lab, env, expand_trace env trace)]) + end) + pairs; + Vars.iter + (fun lab (_, _, ty) -> + let (_, _, ty') = Vars.find lab sign1.csig_vars in + try eqtype true type_pairs subst env ty' ty with Unify trace -> + raise (Failure [CM_Val_type_mismatch + (lab, env, expand_trace env trace)])) + sign2.csig_vars + | _ -> + raise + (Failure (if trace then [] + else [CM_Class_type_mismatch (env, cty1, cty2)])) + with + Failure error when trace -> + raise (Failure (CM_Class_type_mismatch (env, cty1, cty2)::error)) + +let match_class_declarations env patt_params patt_type subj_params subj_type = + let type_pairs = TypePairs.create 53 in + let subst = ref [] in + let sign1 = signature_of_class_type patt_type in + let sign2 = signature_of_class_type subj_type in + let t1 = repr sign1.csig_self in + let t2 = repr sign2.csig_self in + TypePairs.add type_pairs (t1, t2) (); + let (fields1, rest1) = flatten_fields (object_fields t1) + and (fields2, rest2) = flatten_fields (object_fields t2) in + let (pairs, miss1, miss2) = associate_fields fields1 fields2 in + let error = + List.fold_right + (fun (lab, k, _) err -> + let err = + let k = field_kind_repr k in + begin match k with + Fvar _ -> err + | _ -> CM_Hide_public lab::err + end in - mark cstrs1 usage name decl1; - if equality then mark cstrs2 Env.Positive (Ident.name id) decl2; - compare_variants ~loc env decl1.type_params decl2.type_params 1 cstrs1 cstrs2 - | (Type_record(labels1,rep1), Type_record(labels2,rep2)) -> - let err = compare_records ~loc env decl1.type_params decl2.type_params - 1 labels1 labels2 in - if err <> [] || rep1 = rep2 then err else - [Record_representation (rep2 = Record_float)] - | (Type_open, Type_open) -> [] - | (_, _) -> [Kind] + if Concr.mem lab sign1.csig_concr then err + else CM_Hide_virtual ("method", lab) :: err) + miss1 [] in - if err <> [] then err else - let abstr = decl2.type_kind = Type_abstract && decl2.type_manifest = None in - (* If attempt to assign a non-immediate type (e.g. string) to a type that - * must be immediate, then we error *) - let err = - if abstr && - not decl1.type_immediate && - decl2.type_immediate then - [Immediate] - else [] + let missing_method = List.map (fun (m, _, _) -> m) miss2 in + let error = + (List.map (fun m -> CM_Missing_method m) missing_method) @ error in - if err <> [] then err else - let need_variance = - abstr || decl1.type_private = Private || decl1.type_kind = Type_open in - if not need_variance then [] else - let abstr = abstr || decl2.type_private = Private in - let opn = decl2.type_kind = Type_open && decl2.type_manifest = None in - let constrained ty = not (Btype.(is_Tvar (repr ty))) in - if List.for_all2 - (fun ty (v1,v2) -> - let open Variance in - let imp a b = not a || b in - let (co1,cn1) = get_upper v1 and (co2,cn2) = get_upper v2 in - (if abstr then (imp co1 co2 && imp cn1 cn2) - else if opn || constrained ty then (co1 = co2 && cn1 = cn2) - else true) && - let (p1,n1,i1,j1) = get_lower v1 and (p2,n2,i2,j2) = get_lower v2 in - imp abstr (imp p2 p1 && imp n2 n1 && imp i2 i1 && imp j2 j1)) - decl2.type_params (List.combine decl1.type_variance decl2.type_variance) - then [] else [Variance] - -(* Inclusion between extension constructors *) - -let extension_constructors ~loc env id ext1 ext2 = - let usage = - if ext1.ext_private = Private || ext2.ext_private = Public - then Env.Positive else Env.Privatize + (* Always succeeds *) + eqtype true type_pairs subst env rest1 rest2; + let error = + List.fold_right + (fun (lab, k1, _t1, k2, _t2) err -> + let k1 = field_kind_repr k1 in + let k2 = field_kind_repr k2 in + match k1, k2 with + (Fvar _, Fvar _) + | (Fpresent, Fpresent) -> err + | (Fvar _, Fpresent) -> CM_Private_method lab::err + | (Fpresent, Fvar _) -> CM_Public_method lab::err + | _ -> assert false) + pairs error in - Env.mark_extension_used usage env ext1 (Ident.name id); - let ty1 = - Btype.newgenty (Tconstr(ext1.ext_type_path, ext1.ext_type_params, ref Mnil)) + let error = + Vars.fold + (fun lab (mut, vr, _ty) err -> + try + let (mut', vr', _ty') = Vars.find lab sign1.csig_vars in + if mut = Mutable && mut' <> Mutable then + CM_Non_mutable_value lab::err + else if vr = Concrete && vr' <> Concrete then + CM_Non_concrete_value lab::err + else + err + with Not_found -> + CM_Missing_value lab::err) + sign2.csig_vars error in - let ty2 = - Btype.newgenty (Tconstr(ext2.ext_type_path, ext2.ext_type_params, ref Mnil)) + let error = + Vars.fold + (fun lab (_,vr,_) err -> + if vr = Virtual && not (Vars.mem lab sign2.csig_vars) then + CM_Hide_virtual ("instance variable", lab) :: err + else err) + sign1.csig_vars error in - if Ctype.equal env true - (ty1 :: ext1.ext_type_params) - (ty2 :: ext2.ext_type_params) - then - if compare_constructor_arguments ~loc env (Ident.create "") - ext1.ext_type_params ext2.ext_type_params - ext1.ext_args ext2.ext_args = [] then - if match ext1.ext_ret_type, ext2.ext_ret_type with - Some r1, Some r2 when not (Ctype.equal env true [r1] [r2]) -> false - | Some _, None | None, Some _ -> false - | _ -> true - then - match ext1.ext_private, ext2.ext_private with - Private, Public -> false - | _, _ -> true - else false - else false - else false + let error = + List.fold_right + (fun e l -> + if List.mem e missing_method then l else CM_Virtual_method e::l) + (Concr.elements (Concr.diff sign2.csig_concr sign1.csig_concr)) + error + in + match error with + [] -> + begin try + let lp = List.length patt_params in + let ls = List.length subj_params in + if lp <> ls then + raise (Failure [CM_Parameter_arity_mismatch (lp, ls)]); + List.iter2 (fun p s -> + try eqtype true type_pairs subst env p s with Unify trace -> + raise (Failure [CM_Type_parameter_mismatch + (env, expand_trace env trace)])) + patt_params subj_params; + (* old code: equal_clty false type_pairs subst env patt_type subj_type; *) + equal_clty false type_pairs subst env + (Cty_signature sign1) (Cty_signature sign2); + (* Use moregeneral for class parameters, need to recheck everything to + keeps relationships (PR#4824) *) + let clty_params = + List.fold_right (fun ty cty -> Cty_arrow (Labelled "*",ty,cty)) in + match_class_types ~trace:false env + (clty_params patt_params patt_type) + (clty_params subj_params subj_type) + with + Failure r -> r + end + | error -> + error + + + (***************) + (* Subtyping *) + (***************) -end -module Mtype : sig -#1 "mtype.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) -(* Operations on module types *) +(**** Build a subtype of a given type. ****) -open Types +(* build_subtype: + [visited] traces traversed object and variant types + [loops] is a mapping from variables to variables, to reproduce + positive loops in a class type + [posi] true if the current variance is positive + [level] number of expansions/enlargement allowed on this branch *) -val scrape: Env.t -> module_type -> module_type - (* Expand toplevel module type abbreviations - till hitting a "hard" module type (signature, functor, - or abstract module type ident. *) -val freshen: module_type -> module_type - (* Return an alpha-equivalent copy of the given module type - where bound identifiers are fresh. *) -val strengthen: aliasable:bool -> Env.t -> module_type -> Path.t -> module_type - (* Strengthen abstract type components relative to the - given path. *) -val strengthen_decl: - aliasable:bool -> Env.t -> module_declaration -> Path.t -> module_declaration -val nondep_supertype: Env.t -> Ident.t -> module_type -> module_type - (* Return the smallest supertype of the given type - in which the given ident does not appear. - Raise [Not_found] if no such type exists. *) -val no_code_needed: Env.t -> module_type -> bool -val no_code_needed_sig: Env.t -> signature -> bool - (* Determine whether a module needs no implementation code, - i.e. consists only of type definitions. *) -val enrich_modtype: Env.t -> Path.t -> module_type -> module_type -val enrich_typedecl: Env.t -> Path.t -> type_declaration -> type_declaration -val type_paths: Env.t -> Path.t -> module_type -> Path.t list -val contains_type: Env.t -> module_type -> bool -val remove_aliases: Env.t -> module_type -> module_type -val lower_nongen: int -> module_type -> unit +let warn = ref false (* whether double coercion might do better *) +let pred_expand n = if n mod 2 = 0 && n > 0 then pred n else n +let pred_enlarge n = if n mod 2 = 1 then pred n else n -end = struct -#1 "mtype.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +type change = Unchanged | Equiv | Changed +let collect l = List.fold_left (fun c1 (_, c2) -> max c1 c2) Unchanged l -(* Operations on module types *) +let rec filter_visited = function + [] -> [] + | {desc=Tobject _|Tvariant _} :: _ as l -> l + | _ :: l -> filter_visited l -open Asttypes -open Path -open Types +let memq_warn t visited = + if List.memq t visited then (warn := true; true) else false +let rec lid_of_path ?(hash="") = function + Path.Pident id -> + Longident.Lident (hash ^ Ident.name id) + | Path.Pdot (p1, s, _) -> + Longident.Ldot (lid_of_path p1, hash ^ s) + | Path.Papply (p1, p2) -> + Longident.Lapply (lid_of_path ~hash p1, lid_of_path p2) -let rec scrape env mty = - match mty with - Mty_ident p -> - begin try - scrape env (Env.find_modtype_expansion p env) - with Not_found -> - mty - end - | _ -> mty +let find_cltype_for_path env p = + let cl_path = Env.lookup_type (lid_of_path ~hash:"#" p) env in + let cl_abbr = Env.find_type cl_path env in -let freshen mty = - Subst.modtype Subst.identity mty + match cl_abbr.type_manifest with + Some ty -> + begin match (repr ty).desc with + Tobject(_,{contents=Some(p',_)}) when Path.same p p' -> cl_abbr, ty + | _ -> raise Not_found + end + | None -> assert false -let rec strengthen ~aliasable env mty p = - match scrape env mty with - Mty_signature sg -> - Mty_signature(strengthen_sig ~aliasable env sg p 0) - | Mty_functor(param, arg, res) - when !Clflags.applicative_functors && Ident.name param <> "*" -> - Mty_functor(param, arg, - strengthen ~aliasable:false env res (Papply(p, Pident param))) - | mty -> - mty +let has_constr_row' env t = + has_constr_row (expand_abbrev env t) -and strengthen_sig ~aliasable env sg p pos = - match sg with - [] -> [] - | (Sig_value(_, desc) as sigelt) :: rem -> - let nextpos = - match desc.val_kind with - | Val_prim _ -> pos - | _ -> pos + 1 - in - sigelt :: strengthen_sig ~aliasable env rem p nextpos - | Sig_type(id, {type_kind=Type_abstract}, _) :: - (Sig_type(id', {type_private=Private}, _) :: _ as rem) - when Ident.name id = Ident.name id' ^ "#row" -> - strengthen_sig ~aliasable env rem p pos - | Sig_type(id, decl, rs) :: rem -> - let newdecl = - match decl.type_manifest, decl.type_private, decl.type_kind with - Some _, Public, _ -> decl - | Some _, Private, (Type_record _ | Type_variant _) -> decl - | _ -> - let manif = - Some(Btype.newgenty(Tconstr(Pdot(p, Ident.name id, nopos), - decl.type_params, ref Mnil))) in - if decl.type_kind = Type_abstract then - { decl with type_private = Public; type_manifest = manif } - else - { decl with type_manifest = manif } +let rec build_subtype env visited loops posi level t = + let t = repr t in + match t.desc with + Tvar _ -> + if posi then + try + let t' = List.assq t loops in + warn := true; + (t', Equiv) + with Not_found -> + (t, Unchanged) + else + (t, Unchanged) + | Tarrow(l, t1, t2, _) -> + if memq_warn t visited then (t, Unchanged) else + let visited = t :: visited in + let (t1', c1) = build_subtype env visited loops (not posi) level t1 in + let (t2', c2) = build_subtype env visited loops posi level t2 in + let c = max c1 c2 in + if c > Unchanged then (newty (Tarrow(l, t1', t2', Cok)), c) + else (t, Unchanged) + | Ttuple tlist -> + if memq_warn t visited then (t, Unchanged) else + let visited = t :: visited in + let tlist' = + List.map (build_subtype env visited loops posi level) tlist in - Sig_type(id, newdecl, rs) :: strengthen_sig ~aliasable env rem p pos - | (Sig_typext _ as sigelt) :: rem -> - sigelt :: strengthen_sig ~aliasable env rem p (pos+1) - | Sig_module(id, md, rs) :: rem -> - let str = - strengthen_decl ~aliasable env md (Pdot(p, Ident.name id, pos)) + let c = collect tlist' in + if c > Unchanged then (newty (Ttuple (List.map fst tlist')), c) + else (t, Unchanged) + | Tconstr(p, tl, abbrev) + when level > 0 && generic_abbrev env p && safe_abbrev env t + && not (has_constr_row' env t) -> + let t' = repr (expand_abbrev env t) in + let level' = pred_expand level in + begin try match t'.desc with + Tobject _ when posi && not (opened_object t') -> + let cl_abbr, body = find_cltype_for_path env p in + let ty = + subst env !current_level Public abbrev None + cl_abbr.type_params tl body in + let ty = repr ty in + let ty1, tl1 = + match ty.desc with + Tobject(ty1,{contents=Some(p',tl1)}) when Path.same p p' -> + ty1, tl1 + | _ -> raise Not_found + in + (* Fix PR#4505: do not set ty to Tvar when it appears in tl1, + as this occurrence might break the occur check. + XXX not clear whether this correct anyway... *) + if List.exists (deep_occur ty) tl1 then raise Not_found; + ty.desc <- Tvar None; + let t'' = newvar () in + let loops = (ty, t'') :: loops in + (* May discard [visited] as level is going down *) + let (ty1', c) = + build_subtype env [t'] loops posi (pred_enlarge level') ty1 in + assert (is_Tvar t''); + let nm = + if c > Equiv || deep_occur ty ty1' then None else Some(p,tl1) in + t''.desc <- Tobject (ty1', ref nm); + (try unify_var env ty t with Unify _ -> assert false); + (t'', Changed) + | _ -> raise Not_found + with Not_found -> + let (t'',c) = build_subtype env visited loops posi level' t' in + if c > Unchanged then (t'',c) + else (t, Unchanged) + end + | Tconstr(p, tl, _abbrev) -> + (* Must check recursion on constructors, since we do not always + expand them *) + if memq_warn t visited then (t, Unchanged) else + let visited = t :: visited in + begin try + let decl = Env.find_type p env in + if level = 0 && generic_abbrev env p && safe_abbrev env t + && not (has_constr_row' env t) + then warn := true; + let tl' = + List.map2 + (fun v t -> + let (co,cn) = Variance.get_upper v in + if cn then + if co then (t, Unchanged) + else build_subtype env visited loops (not posi) level t + else + if co then build_subtype env visited loops posi level t + else (newvar(), Changed)) + decl.type_variance tl + in + let c = collect tl' in + if c > Unchanged then (newconstr p (List.map fst tl'), c) + else (t, Unchanged) + with Not_found -> + (t, Unchanged) + end + | Tvariant row -> + let row = row_repr row in + if memq_warn t visited || not (static_row row) then (t, Unchanged) else + let level' = pred_enlarge level in + let visited = + t :: if level' < level then [] else filter_visited visited in + let fields = filter_row_fields false row.row_fields in + let fields = + List.map + (fun (l,f as orig) -> match row_field_repr f with + Rpresent None -> + if posi then + (l, Reither(true, [], false, ref None)), Unchanged + else + orig, Unchanged + | Rpresent(Some t) -> + let (t', c) = build_subtype env visited loops posi level' t in + let f = + if posi && level > 0 + then Reither(false, [t'], false, ref None) + else Rpresent(Some t') + in (l, f), c + | _ -> assert false) + fields in - Sig_module(id, str, rs) - :: strengthen_sig ~aliasable - (Env.add_module_declaration ~check:false id md env) rem p (pos+1) - (* Need to add the module in case it defines manifest module types *) - | Sig_modtype(id, decl) :: rem -> - let newdecl = - match decl.mtd_type with - None -> - {decl with mtd_type = Some(Mty_ident(Pdot(p,Ident.name id,nopos)))} - | Some _ -> - decl + let c = collect fields in + let row = + { row_fields = List.map fst fields; row_more = newvar(); + row_bound = (); row_closed = posi; row_fixed = false; + row_name = if c > Unchanged then None else row.row_name } in - Sig_modtype(id, newdecl) :: - strengthen_sig ~aliasable (Env.add_modtype id decl env) rem p pos - (* Need to add the module type in case it is manifest *) - | (Sig_class _ as sigelt) :: rem -> - sigelt :: strengthen_sig ~aliasable env rem p (pos+1) - | (Sig_class_type _ as sigelt) :: rem -> - sigelt :: strengthen_sig ~aliasable env rem p pos + (newty (Tvariant row), Changed) + | Tobject (t1, _) -> + if memq_warn t visited || opened_object t1 then (t, Unchanged) else + let level' = pred_enlarge level in + let visited = + t :: if level' < level then [] else filter_visited visited in + let (t1', c) = build_subtype env visited loops posi level' t1 in + if c > Unchanged then (newty (Tobject (t1', ref None)), c) + else (t, Unchanged) + | Tfield(s, _, t1, t2) (* Always present *) -> + let (t1', c1) = build_subtype env visited loops posi level t1 in + let (t2', c2) = build_subtype env visited loops posi level t2 in + let c = max c1 c2 in + if c > Unchanged then (newty (Tfield(s, Fpresent, t1', t2')), c) + else (t, Unchanged) + | Tnil -> + if posi then + let v = newvar () in + (v, Changed) + else begin + warn := true; + (t, Unchanged) + end + | Tsubst _ | Tlink _ -> + assert false + | Tpoly(t1, tl) -> + let (t1', c) = build_subtype env visited loops posi level t1 in + if c > Unchanged then (newty (Tpoly(t1', tl)), c) + else (t, Unchanged) + | Tunivar _ | Tpackage _ -> + (t, Unchanged) -and strengthen_decl ~aliasable env md p = - match md.md_type with - | Mty_alias _ -> md - | _ when aliasable -> {md with md_type = Mty_alias(Mta_present, p)} - | mty -> {md with md_type = strengthen ~aliasable env mty p} +let enlarge_type env ty = + warn := false; + (* [level = 4] allows 2 expansions involving objects/variants *) + let (ty', _) = build_subtype env [] [] true 4 ty in + (ty', !warn) -let () = Env.strengthen := strengthen +(**** Check whether a type is a subtype of another type. ****) -(* In nondep_supertype, env is only used for the type it assigns to id. - Hence there is no need to keep env up-to-date by adding the bindings - traversed. *) +(* + During the traversal, a trace of visited types is maintained. It + is printed in case of error. + Constraints (pairs of types that must be equals) are accumulated + rather than being enforced straight. Indeed, the result would + otherwise depend on the order in which these constraints are + enforced. + A function enforcing these constraints is returned. That way, type + variables can be bound to their actual values before this function + is called (see Typecore). + Only well-defined abbreviations are expanded (hence the tests + [generic_abbrev ...]). +*) -type variance = Co | Contra | Strict +let subtypes = TypePairs.create 17 + +let subtype_error env trace = + raise (Subtype (expand_trace env (List.rev trace), [])) + +let rec subtype_rec env trace t1 t2 cstrs = + let t1 = repr t1 in + let t2 = repr t2 in + if t1 == t2 then cstrs else + + begin try + TypePairs.find subtypes (t1, t2); + cstrs + with Not_found -> + TypePairs.add subtypes (t1, t2) (); + match (t1.desc, t2.desc) with + (Tvar _, _) | (_, Tvar _) -> + (trace, t1, t2, !univar_pairs)::cstrs + | (Tarrow(l1, t1, u1, _), Tarrow(l2, t2, u2, _)) when l1 = l2 + || !Clflags.classic && not (is_optional l1 || is_optional l2) -> + let cstrs = subtype_rec env ((t2, t1)::trace) t2 t1 cstrs in + subtype_rec env ((u1, u2)::trace) u1 u2 cstrs + | (Ttuple tl1, Ttuple tl2) -> + subtype_list env trace tl1 tl2 cstrs + | (Tconstr(p1, [], _), Tconstr(p2, [], _)) when Path.same p1 p2 -> + cstrs + | (Tconstr(p1, _tl1, _abbrev1), _) + when generic_abbrev env p1 && safe_abbrev env t1 -> + subtype_rec env trace (expand_abbrev env t1) t2 cstrs + | (_, Tconstr(p2, _tl2, _abbrev2)) + when generic_abbrev env p2 && safe_abbrev env t2 -> + subtype_rec env trace t1 (expand_abbrev env t2) cstrs + | (Tconstr(p1, tl1, _), Tconstr(p2, tl2, _)) when Path.same p1 p2 -> + begin try + let decl = Env.find_type p1 env in + List.fold_left2 + (fun cstrs v (t1, t2) -> + let (co, cn) = Variance.get_upper v in + if co then + if cn then + (trace, newty2 t1.level (Ttuple[t1]), + newty2 t2.level (Ttuple[t2]), !univar_pairs) :: cstrs + else subtype_rec env ((t1, t2)::trace) t1 t2 cstrs + else + if cn then subtype_rec env ((t2, t1)::trace) t2 t1 cstrs + else cstrs) + cstrs decl.type_variance (List.combine tl1 tl2) + with Not_found -> + (trace, t1, t2, !univar_pairs)::cstrs + end + | (Tconstr(p1, _, _), _) when generic_private_abbrev env p1 -> + subtype_rec env trace (expand_abbrev_opt env t1) t2 cstrs +(* | (_, Tconstr(p2, _, _)) when generic_private_abbrev false env p2 -> + subtype_rec env trace t1 (expand_abbrev_opt env t2) cstrs *) + | (Tobject (f1, _), Tobject (f2, _)) + when is_Tvar (object_row f1) && is_Tvar (object_row f2) -> + (* Same row variable implies same object. *) + (trace, t1, t2, !univar_pairs)::cstrs + | (Tobject (f1, _), Tobject (f2, _)) -> + subtype_fields env trace f1 f2 cstrs + | (Tvariant row1, Tvariant row2) -> + begin try + subtype_row env trace row1 row2 cstrs + with Exit -> + (trace, t1, t2, !univar_pairs)::cstrs + end + | (Tpoly (u1, []), Tpoly (u2, [])) -> + subtype_rec env trace u1 u2 cstrs + | (Tpoly (u1, tl1), Tpoly (u2, [])) -> + let _, u1' = instance_poly false tl1 u1 in + subtype_rec env trace u1' u2 cstrs + | (Tpoly (u1, tl1), Tpoly (u2,tl2)) -> + begin try + enter_poly env univar_pairs u1 tl1 u2 tl2 + (fun t1 t2 -> subtype_rec env trace t1 t2 cstrs) + with Unify _ -> + (trace, t1, t2, !univar_pairs)::cstrs + end + | (Tpackage (p1, nl1, tl1), Tpackage (p2, nl2, tl2)) -> + begin try + let ntl1 = complete_type_list env nl2 t1.level (Mty_ident p1) nl1 tl1 + and ntl2 = complete_type_list env nl1 t2.level (Mty_ident p2) nl2 tl2 + ~allow_absent:true in + let cstrs' = + List.map + (fun (n2,t2) -> (trace, List.assoc n2 ntl1, t2, !univar_pairs)) + ntl2 + in + if eq_package_path env p1 p2 then cstrs' @ cstrs + else begin + (* need to check module subtyping *) + let snap = Btype.snapshot () in + try + List.iter (fun (_, t1, t2, _) -> unify env t1 t2) cstrs'; + if !package_subtype env p1 nl1 tl1 p2 nl2 tl2 + then (Btype.backtrack snap; cstrs' @ cstrs) + else raise (Unify []) + with Unify _ -> + Btype.backtrack snap; raise Not_found + end + with Not_found -> + (trace, t1, t2, !univar_pairs)::cstrs + end + | (_, _) -> + (trace, t1, t2, !univar_pairs)::cstrs + end + +and subtype_list env trace tl1 tl2 cstrs = + if List.length tl1 <> List.length tl2 then + subtype_error env trace; + List.fold_left2 + (fun cstrs t1 t2 -> subtype_rec env ((t1, t2)::trace) t1 t2 cstrs) + cstrs tl1 tl2 + +and subtype_fields env trace ty1 ty2 cstrs = + (* Assume that either rest1 or rest2 is not Tvar *) + let (fields1, rest1) = flatten_fields ty1 in + let (fields2, rest2) = flatten_fields ty2 in + let (pairs, miss1, miss2) = associate_fields fields1 fields2 in + let cstrs = + if rest2.desc = Tnil then cstrs else + if miss1 = [] then + subtype_rec env ((rest1, rest2)::trace) rest1 rest2 cstrs + else + (trace, build_fields (repr ty1).level miss1 rest1, rest2, + !univar_pairs) :: cstrs + in + let cstrs = + if miss2 = [] then cstrs else + (trace, rest1, build_fields (repr ty2).level miss2 (newvar ()), + !univar_pairs) :: cstrs + in + List.fold_left + (fun cstrs (_, _k1, t1, _k2, t2) -> + (* These fields are always present *) + subtype_rec env ((t1, t2)::trace) t1 t2 cstrs) + cstrs pairs + +and subtype_row env trace row1 row2 cstrs = + let row1 = row_repr row1 and row2 = row_repr row2 in + let r1, r2, pairs = + merge_row_fields row1.row_fields row2.row_fields in + let more1 = repr row1.row_more + and more2 = repr row2.row_more in + match more1.desc, more2.desc with + Tconstr(p1,_,_), Tconstr(p2,_,_) when Path.same p1 p2 -> + subtype_rec env ((more1,more2)::trace) more1 more2 cstrs + | (Tvar _|Tconstr _|Tnil), (Tvar _|Tconstr _|Tnil) + when row1.row_closed && r1 = [] -> + List.fold_left + (fun cstrs (_,f1,f2) -> + match row_field_repr f1, row_field_repr f2 with + (Rpresent None|Reither(true,_,_,_)), Rpresent None -> + cstrs + | Rpresent(Some t1), Rpresent(Some t2) -> + subtype_rec env ((t1, t2)::trace) t1 t2 cstrs + | Reither(false, t1::_, _, _), Rpresent(Some t2) -> + subtype_rec env ((t1, t2)::trace) t1 t2 cstrs + | Rabsent, _ -> cstrs + | _ -> raise Exit) + cstrs pairs + | Tunivar _, Tunivar _ + when row1.row_closed = row2.row_closed && r1 = [] && r2 = [] -> + let cstrs = + subtype_rec env ((more1,more2)::trace) more1 more2 cstrs in + List.fold_left + (fun cstrs (_,f1,f2) -> + match row_field_repr f1, row_field_repr f2 with + Rpresent None, Rpresent None + | Reither(true,[],_,_), Reither(true,[],_,_) + | Rabsent, Rabsent -> + cstrs + | Rpresent(Some t1), Rpresent(Some t2) + | Reither(false,[t1],_,_), Reither(false,[t2],_,_) -> + subtype_rec env ((t1, t2)::trace) t1 t2 cstrs + | _ -> raise Exit) + cstrs pairs + | _ -> + raise Exit -let nondep_supertype env mid mty = +let subtype env ty1 ty2 = + TypePairs.clear subtypes; + univar_pairs := []; + (* Build constraint set. *) + let cstrs = subtype_rec env [(ty1, ty2)] ty1 ty2 [] in + TypePairs.clear subtypes; + (* Enforce constraints. *) + function () -> + List.iter + (function (trace0, t1, t2, pairs) -> + try unify_pairs (ref env) t1 t2 pairs with Unify trace -> + raise (Subtype (expand_trace env (List.rev trace0), + List.tl (List.tl trace)))) + (List.rev cstrs) - let rec nondep_mty env va mty = - match mty with - Mty_ident p -> - if Path.isfree mid p then - nondep_mty env va (Env.find_modtype_expansion p env) - else mty - | Mty_alias(_, p) -> - if Path.isfree mid p then - nondep_mty env va (Env.find_module p env).md_type - else mty - | Mty_signature sg -> - Mty_signature(nondep_sig env va sg) - | Mty_functor(param, arg, res) -> - let var_inv = - match va with Co -> Contra | Contra -> Co | Strict -> Strict in - Mty_functor(param, Misc.may_map (nondep_mty env var_inv) arg, - nondep_mty - (Env.add_module ~arg:true param - (Btype.default_mty arg) env) va res) + (*******************) + (* Miscellaneous *) + (*******************) - and nondep_sig env va = function - [] -> [] - | item :: rem -> - let rem' = nondep_sig env va rem in - match item with - Sig_value(id, d) -> - Sig_value(id, - {d with val_type = Ctype.nondep_type env mid d.val_type}) - :: rem' - | Sig_type(id, d, rs) -> - Sig_type(id, Ctype.nondep_type_decl env mid id (va = Co) d, rs) - :: rem' - | Sig_typext(id, ext, es) -> - Sig_typext(id, Ctype.nondep_extension_constructor env mid ext, es) - :: rem' - | Sig_module(id, md, rs) -> - Sig_module(id, {md with md_type=nondep_mty env va md.md_type}, rs) - :: rem' - | Sig_modtype(id, d) -> - begin try - Sig_modtype(id, nondep_modtype_decl env d) :: rem' - with Not_found -> - match va with - Co -> Sig_modtype(id, {mtd_type=None; mtd_loc=Location.none; - mtd_attributes=[]}) :: rem' - | _ -> raise Not_found - end - | Sig_class(id, d, rs) -> - Sig_class(id, Ctype.nondep_class_declaration env mid d, rs) - :: rem' - | Sig_class_type(id, d, rs) -> - Sig_class_type(id, Ctype.nondep_cltype_declaration env mid d, rs) - :: rem' +(* Utility for printing. The resulting type is not used in computation. *) +let rec unalias_object ty = + let ty = repr ty in + match ty.desc with + Tfield (s, k, t1, t2) -> + newty2 ty.level (Tfield (s, k, t1, unalias_object t2)) + | Tvar _ | Tnil -> + newty2 ty.level ty.desc + | Tunivar _ -> + ty + | Tconstr _ -> + newvar2 ty.level + | _ -> + assert false - and nondep_modtype_decl env mtd = - {mtd with mtd_type = Misc.may_map (nondep_mty env Strict) mtd.mtd_type} +let unalias ty = + let ty = repr ty in + match ty.desc with + Tvar _ | Tunivar _ -> + ty + | Tvariant row -> + let row = row_repr row in + let more = row.row_more in + newty2 ty.level + (Tvariant {row with row_more = newty2 more.level more.desc}) + | Tobject (ty, nm) -> + newty2 ty.level (Tobject (unalias_object ty, nm)) + | _ -> + newty2 ty.level ty.desc - in - nondep_mty env Co mty +(* Return the arity (as for curried functions) of the given type. *) +let rec arity ty = + match (repr ty).desc with + Tarrow(_, _t1, t2, _) -> 1 + arity t2 + | _ -> 0 -let enrich_typedecl env p decl = - match decl.type_manifest with - Some _ -> decl - | None -> - try - let orig_decl = Env.find_type p env in - if orig_decl.type_arity <> decl.type_arity - then decl - else {decl with type_manifest = - Some(Btype.newgenty(Tconstr(p, decl.type_params, ref Mnil)))} - with Not_found -> - decl +(* Check whether an abbreviation expands to itself. *) +let cyclic_abbrev env id ty = + let rec check_cycle seen ty = + let ty = repr ty in + match ty.desc with + Tconstr (p, _tl, _abbrev) -> + p = Path.Pident id || List.memq ty seen || + begin try + check_cycle (ty :: seen) (expand_abbrev_opt env ty) + with + Cannot_expand -> false + | Unify _ -> true + end + | _ -> + false + in check_cycle [] ty -let rec enrich_modtype env p mty = - match mty with - Mty_signature sg -> - Mty_signature(List.map (enrich_item env p) sg) - | _ -> - mty +(* Check for non-generalizable type variables *) +exception Non_closed0 +let visited = ref TypeSet.empty -and enrich_item env p = function - Sig_type(id, decl, rs) -> - Sig_type(id, - enrich_typedecl env (Pdot(p, Ident.name id, nopos)) decl, rs) - | Sig_module(id, md, rs) -> - Sig_module(id, - {md with - md_type = enrich_modtype env - (Pdot(p, Ident.name id, nopos)) md.md_type}, - rs) - | item -> item +let rec closed_schema_rec env ty = + let ty = repr ty in + if TypeSet.mem ty !visited then () else begin + visited := TypeSet.add ty !visited; + match ty.desc with + Tvar _ when ty.level <> generic_level -> + raise Non_closed0 + | Tconstr _ -> + let old = !visited in + begin try iter_type_expr (closed_schema_rec env) ty + with Non_closed0 -> try + visited := old; + closed_schema_rec env (try_expand_head try_expand_safe env ty) + with Cannot_expand -> + raise Non_closed0 + end + | Tfield(_, kind, t1, t2) -> + if field_kind_repr kind = Fpresent then + closed_schema_rec env t1; + closed_schema_rec env t2 + | Tvariant row -> + let row = row_repr row in + iter_row (closed_schema_rec env) row; + if not (static_row row) then closed_schema_rec env row.row_more + | _ -> + iter_type_expr (closed_schema_rec env) ty + end -let rec type_paths env p mty = - match scrape env mty with - Mty_ident _ -> [] - | Mty_alias _ -> [] - | Mty_signature sg -> type_paths_sig env p 0 sg - | Mty_functor _ -> [] +(* Return whether all variables of type [ty] are generic. *) +let closed_schema env ty = + visited := TypeSet.empty; + try + closed_schema_rec env ty; + visited := TypeSet.empty; + true + with Non_closed0 -> + visited := TypeSet.empty; + false -and type_paths_sig env p pos sg = - match sg with - [] -> [] - | Sig_value(_id, decl) :: rem -> - let pos' = match decl.val_kind with Val_prim _ -> pos | _ -> pos + 1 in - type_paths_sig env p pos' rem - | Sig_type(id, _decl, _) :: rem -> - Pdot(p, Ident.name id, nopos) :: type_paths_sig env p pos rem - | Sig_module(id, md, _) :: rem -> - type_paths env (Pdot(p, Ident.name id, pos)) md.md_type @ - type_paths_sig (Env.add_module_declaration ~check:false id md env) - p (pos+1) rem - | Sig_modtype(id, decl) :: rem -> - type_paths_sig (Env.add_modtype id decl env) p pos rem - | (Sig_typext _ | Sig_class _) :: rem -> - type_paths_sig env p (pos+1) rem - | (Sig_class_type _) :: rem -> - type_paths_sig env p pos rem +(* Normalize a type before printing, saving... *) +(* Cannot use mark_type because deep_occur uses it too *) +let rec normalize_type_rec env visited ty = + let ty = repr ty in + if not (TypeSet.mem ty !visited) then begin + visited := TypeSet.add ty !visited; + let tm = row_of_type ty in + begin if not (is_Tconstr ty) && is_constr_row ~allow_ident:false tm then + match tm.desc with (* PR#7348 *) + Tconstr (Path.Pdot(m,i,pos), tl, _abbrev) -> + let i' = String.sub i 0 (String.length i - 4) in + log_type ty; + ty.desc <- Tconstr(Path.Pdot(m,i',pos), tl, ref Mnil) + | _ -> assert false + else match ty.desc with + | Tvariant row -> + let row = row_repr row in + let fields = List.map + (fun (l,f0) -> + let f = row_field_repr f0 in l, + match f with Reither(b, ty::(_::_ as tyl), m, e) -> + let tyl' = + List.fold_left + (fun tyl ty -> + if List.exists (fun ty' -> equal env false [ty] [ty']) tyl + then tyl else ty::tyl) + [ty] tyl + in + if f != f0 || List.length tyl' < List.length tyl then + Reither(b, List.rev tyl', m, e) + else f + | _ -> f) + row.row_fields in + let fields = + List.sort (fun (p,_) (q,_) -> compare p q) + (List.filter (fun (_,fi) -> fi <> Rabsent) fields) in + log_type ty; + ty.desc <- Tvariant {row with row_fields = fields} + | Tobject (fi, nm) -> + begin match !nm with + | None -> () + | Some (n, v :: l) -> + if deep_occur ty (newgenty (Ttuple l)) then + (* The abbreviation may be hiding something, so remove it *) + set_name nm None + else let v' = repr v in + begin match v'.desc with + | Tvar _ | Tunivar _ -> + if v' != v then set_name nm (Some (n, v' :: l)) + | Tnil -> + log_type ty; ty.desc <- Tconstr (n, l, ref Mnil) + | _ -> set_name nm None + end + | _ -> + fatal_error "Ctype.normalize_type_rec" + end; + let fi = repr fi in + if fi.level < lowest_level then () else + let fields, row = flatten_fields fi in + let fi' = build_fields fi.level fields row in + log_type ty; fi.desc <- fi'.desc + | _ -> () + end; + iter_type_expr (normalize_type_rec env visited) ty + end -let rec no_code_needed env mty = - match scrape env mty with - Mty_ident _ -> false - | Mty_signature sg -> no_code_needed_sig env sg - | Mty_functor(_, _, _) -> false - | Mty_alias(Mta_absent, _) -> true - | Mty_alias(Mta_present, _) -> false +let normalize_type env ty = + normalize_type_rec env (ref TypeSet.empty) ty -and no_code_needed_sig env sg = - match sg with - [] -> true - | Sig_value(_id, decl) :: rem -> - begin match decl.val_kind with - | Val_prim _ -> no_code_needed_sig env rem - | _ -> false - end - | Sig_module(id, md, _) :: rem -> - no_code_needed env md.md_type && - no_code_needed_sig - (Env.add_module_declaration ~check:false id md env) rem - | (Sig_type _ | Sig_modtype _ | Sig_class_type _) :: rem -> - no_code_needed_sig env rem - | (Sig_typext _ | Sig_class _) :: _ -> - false + (*************************) + (* Remove dependencies *) + (*************************) -(* Check whether a module type may return types *) -let rec contains_type env = function - Mty_ident path -> - begin try match (Env.find_modtype path env).mtd_type with - | None -> raise Exit (* PR#6427 *) - | Some mty -> contains_type env mty - with Not_found -> raise Exit - end - | Mty_signature sg -> - contains_type_sig env sg - | Mty_functor (_, _, body) -> - contains_type env body - | Mty_alias _ -> - () +(* + Variables are left unchanged. Other type nodes are duplicated, with + levels set to generic level. + We cannot use Tsubst here, because unification may be called by + expand_abbrev. +*) -and contains_type_sig env = List.iter (contains_type_item env) +let nondep_hash = TypeHash.create 47 +let nondep_variants = TypeHash.create 17 +let clear_hash () = + TypeHash.clear nondep_hash; TypeHash.clear nondep_variants -and contains_type_item env = function - Sig_type (_,({type_manifest = None} | - {type_kind = Type_abstract; type_private = Private}),_) - | Sig_modtype _ - | Sig_typext (_, {ext_args = Cstr_record _}, _) -> - (* We consider that extension constructors with an inlined - record create a type (the inlined record), even though - it would be technically safe to ignore that considering - the current constraints which guarantee that this type - is kept local to expressions. *) - raise Exit - | Sig_module (_, {md_type = mty}, _) -> - contains_type env mty - | Sig_value _ - | Sig_type _ - | Sig_typext _ - | Sig_class _ - | Sig_class_type _ -> - () +let rec nondep_type_rec env id ty = + match ty.desc with + Tvar _ | Tunivar _ -> ty + | Tlink ty -> nondep_type_rec env id ty + | _ -> try TypeHash.find nondep_hash ty + with Not_found -> + let ty' = newgenvar () in (* Stub *) + TypeHash.add nondep_hash ty ty'; + ty'.desc <- + begin match ty.desc with + | Tconstr(p, tl, _abbrev) -> + if Path.isfree id p then + begin try + Tlink (nondep_type_rec env id + (expand_abbrev env (newty2 ty.level ty.desc))) + (* + The [Tlink] is important. The expanded type may be a + variable, or may not be completely copied yet + (recursive type), so one cannot just take its + description. + *) + with Cannot_expand | Unify _ -> + raise Not_found + end + else + Tconstr(p, List.map (nondep_type_rec env id) tl, ref Mnil) + | Tpackage(p, nl, tl) when Path.isfree id p -> + let p' = normalize_package_path env p in + if Path.isfree id p' then raise Not_found; + Tpackage (p', nl, List.map (nondep_type_rec env id) tl) + | Tobject (t1, name) -> + Tobject (nondep_type_rec env id t1, + ref (match !name with + None -> None + | Some (p, tl) -> + if Path.isfree id p then None + else Some (p, List.map (nondep_type_rec env id) tl))) + | Tvariant row -> + let row = row_repr row in + let more = repr row.row_more in + (* We must keep sharing according to the row variable *) + begin try + let ty2 = TypeHash.find nondep_variants more in + (* This variant type has been already copied *) + TypeHash.add nondep_hash ty ty2; + Tlink ty2 + with Not_found -> + (* Register new type first for recursion *) + TypeHash.add nondep_variants more ty'; + let static = static_row row in + let more' = if static then newgenty Tnil else more in + (* Return a new copy *) + let row = + copy_row (nondep_type_rec env id) true row true more' in + match row.row_name with + Some (p, _tl) when Path.isfree id p -> + Tvariant {row with row_name = None} + | _ -> Tvariant row + end + | _ -> copy_type_desc (nondep_type_rec env id) ty.desc + end; + ty' -let contains_type env mty = - try contains_type env mty; false with Exit -> true +let nondep_type env id ty = + try + let ty' = nondep_type_rec env id ty in + clear_hash (); + ty' + with Not_found -> + clear_hash (); + raise Not_found +let () = nondep_type' := nondep_type -(* Remove module aliases from a signature *) +let unroll_abbrev id tl ty = + let ty = repr ty and path = Path.Pident id in + if is_Tvar ty || (List.exists (deep_occur ty) tl) + || is_object_type path then + ty + else + let ty' = newty2 ty.level ty.desc in + link_type ty (newty2 ty.level (Tconstr (path, tl, ref Mnil))); + ty' -module PathSet = Set.Make (Path) -module PathMap = Map.Make (Path) -module IdentSet = Set.Make (Ident) +(* Preserve sharing inside type declarations. *) +let nondep_type_decl env mid id is_covariant decl = + try + let params = List.map (nondep_type_rec env mid) decl.type_params in + let tk = + try map_kind (nondep_type_rec env mid) decl.type_kind + with Not_found when is_covariant -> Type_abstract + and tm = + try match decl.type_manifest with + None -> None + | Some ty -> + Some (unroll_abbrev id params (nondep_type_rec env mid ty)) + with Not_found when is_covariant -> + None + in + clear_hash (); + let priv = + match tm with + | Some ty when Btype.has_constr_row ty -> Private + | _ -> decl.type_private + in + { type_params = params; + type_arity = decl.type_arity; + type_kind = tk; + type_manifest = tm; + type_private = priv; + type_variance = decl.type_variance; + type_newtype_level = None; + type_loc = decl.type_loc; + type_attributes = decl.type_attributes; + type_immediate = decl.type_immediate; + type_unboxed = decl.type_unboxed; + } + with Not_found -> + clear_hash (); + raise Not_found -let rec get_prefixes = function - Pident _ -> PathSet.empty - | Pdot (p, _, _) - | Papply (p, _) -> PathSet.add p (get_prefixes p) +(* Preserve sharing inside extension constructors. *) +let nondep_extension_constructor env mid ext = + try + let type_path, type_params = + if Path.isfree mid ext.ext_type_path then + begin + let ty = + newgenty (Tconstr(ext.ext_type_path, ext.ext_type_params, ref Mnil)) + in + let ty' = nondep_type_rec env mid ty in + match (repr ty').desc with + Tconstr(p, tl, _) -> p, tl + | _ -> raise Not_found + end + else + let type_params = + List.map (nondep_type_rec env mid) ext.ext_type_params + in + ext.ext_type_path, type_params + in + let args = map_type_expr_cstr_args (nondep_type_rec env mid) ext.ext_args in + let ret_type = may_map (nondep_type_rec env mid) ext.ext_ret_type in + clear_hash (); + { ext_type_path = type_path; + ext_type_params = type_params; + ext_args = args; + ext_ret_type = ret_type; + ext_private = ext.ext_private; + ext_attributes = ext.ext_attributes; + ext_loc = ext.ext_loc; + } + with Not_found -> + clear_hash (); + raise Not_found -let rec get_arg_paths = function - Pident _ -> PathSet.empty - | Pdot (p, _, _) -> get_arg_paths p - | Papply (p1, p2) -> - PathSet.add p2 - (PathSet.union (get_prefixes p2) - (PathSet.union (get_arg_paths p1) (get_arg_paths p2))) -let rec rollback_path subst p = - try Pident (PathMap.find p subst) - with Not_found -> - match p with - Pident _ | Papply _ -> p - | Pdot (p1, s, n) -> - let p1' = rollback_path subst p1 in - if Path.same p1 p1' then p else rollback_path subst (Pdot (p1', s, n)) +(* Preserve sharing inside class types. *) +let nondep_class_signature env id sign = + { csig_self = nondep_type_rec env id sign.csig_self; + csig_vars = + Vars.map (function (m, v, t) -> (m, v, nondep_type_rec env id t)) + sign.csig_vars; + csig_concr = sign.csig_concr; + csig_inher = + List.map (fun (p,tl) -> (p, List.map (nondep_type_rec env id) tl)) + sign.csig_inher } -let rec collect_ids subst bindings p = - begin match rollback_path subst p with - Pident id -> - let ids = - try collect_ids subst bindings (Ident.find_same id bindings) - with Not_found -> IdentSet.empty - in - IdentSet.add id ids - | _ -> IdentSet.empty - end +let rec nondep_class_type env id = + function + Cty_constr (p, _, cty) when Path.isfree id p -> + nondep_class_type env id cty + | Cty_constr (p, tyl, cty) -> + Cty_constr (p, List.map (nondep_type_rec env id) tyl, + nondep_class_type env id cty) + | Cty_signature sign -> + Cty_signature (nondep_class_signature env id sign) + | Cty_arrow (l, ty, cty) -> + Cty_arrow (l, nondep_type_rec env id ty, nondep_class_type env id cty) -let collect_arg_paths mty = - let open Btype in - let paths = ref PathSet.empty - and subst = ref PathMap.empty - and bindings = ref Ident.empty in - (* let rt = Ident.create "Root" in - and prefix = ref (Path.Pident rt) in *) - let it_path p = paths := PathSet.union (get_arg_paths p) !paths - and it_signature_item it si = - type_iterators.it_signature_item it si; - match si with - Sig_module (id, {md_type=Mty_alias(_, p)}, _) -> - bindings := Ident.add id p !bindings - | Sig_module (id, {md_type=Mty_signature sg}, _) -> - List.iter - (function Sig_module (id', _, _) -> - subst := - PathMap.add (Pdot (Pident id, Ident.name id', -1)) id' !subst - | _ -> ()) - sg - | _ -> () +let nondep_class_declaration env id decl = + assert (not (Path.isfree id decl.cty_path)); + let decl = + { cty_params = List.map (nondep_type_rec env id) decl.cty_params; + cty_variance = decl.cty_variance; + cty_type = nondep_class_type env id decl.cty_type; + cty_path = decl.cty_path; + cty_new = + begin match decl.cty_new with + None -> None + | Some ty -> Some (nondep_type_rec env id ty) + end; + cty_loc = decl.cty_loc; + cty_attributes = decl.cty_attributes; + } in - let it = {type_iterators with it_path; it_signature_item} in - it.it_module_type it mty; - it.it_module_type unmark_iterators mty; - PathSet.fold (fun p -> IdentSet.union (collect_ids !subst !bindings p)) - !paths IdentSet.empty + clear_hash (); + decl -let rec remove_aliases env excl mty = - match mty with - Mty_signature sg -> - Mty_signature (remove_aliases_sig env excl sg) - | Mty_alias _ -> - let mty' = Env.scrape_alias env mty in - if mty' = mty then mty else - remove_aliases env excl mty' - | mty -> - mty +let nondep_cltype_declaration env id decl = + assert (not (Path.isfree id decl.clty_path)); + let decl = + { clty_params = List.map (nondep_type_rec env id) decl.clty_params; + clty_variance = decl.clty_variance; + clty_type = nondep_class_type env id decl.clty_type; + clty_path = decl.clty_path; + clty_loc = decl.clty_loc; + clty_attributes = decl.clty_attributes; + } + in + clear_hash (); + decl -and remove_aliases_sig env excl sg = - match sg with - [] -> [] - | Sig_module(id, md, rs) :: rem -> - let mty = - match md.md_type with - Mty_alias _ when IdentSet.mem id excl -> - md.md_type - | mty -> - remove_aliases env excl mty - in - Sig_module(id, {md with md_type = mty} , rs) :: - remove_aliases_sig (Env.add_module id mty env) excl rem - | Sig_modtype(id, mtd) :: rem -> - Sig_modtype(id, mtd) :: - remove_aliases_sig (Env.add_modtype id mtd env) excl rem - | it :: rem -> - it :: remove_aliases_sig env excl rem +(* collapse conjunctive types in class parameters *) +let rec collapse_conj env visited ty = + let ty = repr ty in + if List.memq ty visited then () else + let visited = ty :: visited in + match ty.desc with + Tvariant row -> + let row = row_repr row in + List.iter + (fun (_l,fi) -> + match row_field_repr fi with + Reither (c, t1::(_::_ as tl), m, e) -> + List.iter (unify env t1) tl; + set_row_field e (Reither (c, [t1], m, ref None)) + | _ -> + ()) + row.row_fields; + iter_row (collapse_conj env visited) row + | _ -> + iter_type_expr (collapse_conj env visited) ty -let remove_aliases env sg = - let excl = collect_arg_paths sg in - (* PathSet.iter (fun p -> Format.eprintf "%a@ " Printtyp.path p) excl; - Format.eprintf "@."; *) - remove_aliases env excl sg +let collapse_conj_params env params = + List.iter (collapse_conj env []) params +let same_constr env t1 t2 = + let t1 = expand_head env t1 in + let t2 = expand_head env t2 in + match t1.desc, t2.desc with + | Tconstr (p1, _, _), Tconstr (p2, _, _) -> Path.same p1 p2 + | _ -> false -(* Lower non-generalizable type variables *) +let () = + Env.same_constr := same_constr -let lower_nongen nglev mty = - let open Btype in - let it_type_expr it ty = - let ty = repr ty in - match ty with - {desc=Tvar _; level} -> - if level < generic_level && level > nglev then set_level ty nglev - | _ -> - type_iterators.it_type_expr it ty - in - let it = {type_iterators with it_type_expr} in - it.it_module_type it mty; - it.it_module_type unmark_iterators mty +let maybe_pointer_type env typ = + match (repr typ).desc with + | Tconstr(p, _args, _abbrev) -> + begin try + let type_decl = Env.find_type p env in + not type_decl.type_immediate + with Not_found -> true + (* This can happen due to e.g. missing -I options, + causing some .cmi files to be unavailable. + Maybe we should emit a warning. *) + end + | Tvariant row -> + let row = Btype.row_repr row in + (* if all labels are devoid of arguments, not a pointer *) + not row.row_closed + || List.exists + (function + | _, (Rpresent (Some _) | Reither (false, _, _, _)) -> true + | _ -> false) + row.row_fields + | _ -> true end -module Includemod : sig -#1 "includemod.mli" +module Printtyp : sig +#1 "printtyp.mli" (**************************************************************************) (* *) (* OCaml *) @@ -64900,64 +63391,97 @@ module Includemod : sig (* *) (**************************************************************************) -(* Inclusion checks for the module language *) +(* Printing functions *) -open Typedtree -open Types open Format +open Types +open Outcometree -val modtypes: - loc:Location.t -> Env.t -> - module_type -> module_type -> module_coercion - -val signatures: Env.t -> signature -> signature -> module_coercion +val longident: formatter -> Longident.t -> unit +val ident: formatter -> Ident.t -> unit +val tree_of_path: Path.t -> out_ident +val path: formatter -> Path.t -> unit +val string_of_path: Path.t -> string +val raw_type_expr: formatter -> type_expr -> unit +val string_of_label: Asttypes.arg_label -> string -val compunit: - Env.t -> string -> signature -> string -> signature -> module_coercion +val wrap_printing_env: Env.t -> (unit -> 'a) -> 'a + (* Call the function using the environment for type path shortening *) + (* This affects all the printing functions below *) -val type_declarations: - loc:Location.t -> Env.t -> - Ident.t -> type_declaration -> type_declaration -> unit +val reset: unit -> unit +val mark_loops: type_expr -> unit +val reset_and_mark_loops: type_expr -> unit +val reset_and_mark_loops_list: type_expr list -> unit +val type_expr: formatter -> type_expr -> unit +val constructor_arguments: formatter -> constructor_arguments -> unit +val tree_of_type_scheme: type_expr -> out_type +val type_sch : formatter -> type_expr -> unit +val type_scheme: formatter -> type_expr -> unit +(* Maxence *) +val reset_names: unit -> unit +val type_scheme_max: ?b_reset_names: bool -> + formatter -> type_expr -> unit +(* End Maxence *) +val tree_of_value_description: Ident.t -> value_description -> out_sig_item +val value_description: Ident.t -> formatter -> value_description -> unit +val tree_of_type_declaration: + Ident.t -> type_declaration -> rec_status -> out_sig_item +val type_declaration: Ident.t -> formatter -> type_declaration -> unit +val tree_of_extension_constructor: + Ident.t -> extension_constructor -> ext_status -> out_sig_item +val extension_constructor: + Ident.t -> formatter -> extension_constructor -> unit +val tree_of_module: + Ident.t -> ?ellipsis:bool -> module_type -> rec_status -> out_sig_item +val modtype: formatter -> module_type -> unit +val signature: formatter -> signature -> unit +val tree_of_modtype_declaration: + Ident.t -> modtype_declaration -> out_sig_item +val tree_of_signature: Types.signature -> out_sig_item list +val tree_of_typexp: bool -> type_expr -> out_type +val modtype_declaration: Ident.t -> formatter -> modtype_declaration -> unit +val class_type: formatter -> class_type -> unit +val tree_of_class_declaration: + Ident.t -> class_declaration -> rec_status -> out_sig_item +val class_declaration: Ident.t -> formatter -> class_declaration -> unit +val tree_of_cltype_declaration: + Ident.t -> class_type_declaration -> rec_status -> out_sig_item +val cltype_declaration: Ident.t -> formatter -> class_type_declaration -> unit +val type_expansion: type_expr -> Format.formatter -> type_expr -> unit +val prepare_expansion: type_expr * type_expr -> type_expr * type_expr +val trace: + bool -> bool-> string -> formatter -> (type_expr * type_expr) list -> unit +val report_unification_error: + formatter -> Env.t -> ?unif:bool -> (type_expr * type_expr) list -> + (formatter -> unit) -> (formatter -> unit) -> + unit -val print_coercion: formatter -> module_coercion -> unit -type symptom = - Missing_field of Ident.t * Location.t * string (* kind *) - | Value_descriptions of Ident.t * value_description * value_description - | Type_declarations of Ident.t * type_declaration - * type_declaration * Includecore.type_mismatch list - | Extension_constructors of - Ident.t * extension_constructor * extension_constructor - | Module_types of module_type * module_type - | Modtype_infos of Ident.t * modtype_declaration * modtype_declaration - | Modtype_permutation - | Interface_mismatch of string * string - | Class_type_declarations of - Ident.t * class_type_declaration * class_type_declaration * - Ctype.class_match_failure list - | Class_declarations of - Ident.t * class_declaration * class_declaration * - Ctype.class_match_failure list - | Unbound_modtype_path of Path.t - | Unbound_module_path of Path.t - | Invalid_module_alias of Path.t +val super_report_unification_error: + formatter -> Env.t -> ?unif:bool -> (type_expr * type_expr) list -> + (formatter -> unit) -> (formatter -> unit) -> + unit -type pos = - Module of Ident.t | Modtype of Ident.t | Arg of Ident.t | Body of Ident.t -type error = pos list * Env.t * symptom -exception Error of error list +val report_subtyping_error: + formatter -> Env.t -> (type_expr * type_expr) list -> + string -> (type_expr * type_expr) list -> unit +val report_ambiguous_type_error: + formatter -> Env.t -> (Path.t * Path.t) -> (Path.t * Path.t) list -> + (formatter -> unit) -> (formatter -> unit) -> (formatter -> unit) -> unit -val report_error: formatter -> error list -> unit -val expand_module_alias: Env.t -> pos list -> Path.t -> Types.module_type +(* for toploop *) +val print_items: (Env.t -> signature_item -> 'a option) -> + Env.t -> signature_item list -> (out_sig_item * 'a option) list end = struct -#1 "includemod.ml" +#1 "printtyp.ml" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* Xavier Leroy and Jerome Vouillon, projet Cristal, INRIA Rocquencourt *) (* *) (* Copyright 1996 Institut National de Recherche en Informatique et *) (* en Automatique. *) @@ -64968,1736 +63492,1751 @@ end = struct (* *) (**************************************************************************) -(* Inclusion checks for the module language *) +(* Printing functions *) open Misc +open Ctype +open Format +open Longident open Path -open Typedtree +open Asttypes open Types +open Btype +open Outcometree -type symptom = - Missing_field of Ident.t * Location.t * string (* kind *) - | Value_descriptions of Ident.t * value_description * value_description - | Type_declarations of Ident.t * type_declaration - * type_declaration * Includecore.type_mismatch list - | Extension_constructors of - Ident.t * extension_constructor * extension_constructor - | Module_types of module_type * module_type - | Modtype_infos of Ident.t * modtype_declaration * modtype_declaration - | Modtype_permutation - | Interface_mismatch of string * string - | Class_type_declarations of - Ident.t * class_type_declaration * class_type_declaration * - Ctype.class_match_failure list - | Class_declarations of - Ident.t * class_declaration * class_declaration * - Ctype.class_match_failure list - | Unbound_modtype_path of Path.t - | Unbound_module_path of Path.t - | Invalid_module_alias of Path.t +(* Print a long identifier *) -type pos = - Module of Ident.t | Modtype of Ident.t | Arg of Ident.t | Body of Ident.t -type error = pos list * Env.t * symptom +let rec longident ppf = function + | Lident s -> pp_print_string ppf s + | Ldot(p, s) -> fprintf ppf "%a.%s" longident p s + | Lapply(p1, p2) -> fprintf ppf "%a(%a)" longident p1 longident p2 -exception Error of error list +(* Print an identifier *) -(* All functions "blah env x1 x2" check that x1 is included in x2, - i.e. that x1 is the type of an implementation that fulfills the - specification x2. If not, Error is raised with a backtrace of the error. *) +let unique_names = ref Ident.empty -(* Inclusion between value descriptions *) +let ident_name id = + try Ident.find_same id !unique_names with Not_found -> Ident.name id -let value_descriptions ~loc env cxt subst id vd1 vd2 = - Cmt_format.record_value_dependency vd1 vd2; - Env.mark_value_used env (Ident.name id) vd1; - let vd2 = Subst.value_description subst vd2 in - try +let add_unique id = + try ignore (Ident.find_same id !unique_names) + with Not_found -> + unique_names := Ident.add id (Ident.unique_toplevel_name id) !unique_names - Includecore.value_descriptions ~loc env id vd1 vd2 - - with Includecore.Dont_match -> - raise(Error[cxt, env, Value_descriptions(id, vd1, vd2)]) +let ident ppf id = pp_print_string ppf (ident_name id) -(* Inclusion between type declarations *) +(* Print a path *) -let type_declarations ~loc env ?(old_env=env) cxt subst id decl1 decl2 = - Env.mark_type_used env (Ident.name id) decl1; - let decl2 = Subst.type_declaration subst decl2 in - let err = - Includecore.type_declarations ~loc env (Ident.name id) decl1 id decl2 - in - if err <> [] then - raise(Error[cxt, old_env, Type_declarations(id, decl1, decl2, err)]) +let ident_pervasives = Ident.create_persistent "Pervasives" +let printing_env = ref Env.empty +let non_shadowed_pervasive = function + | Pdot(Pident id, s, _pos) as path -> + Ident.same id ident_pervasives && + (try Path.same path (Env.lookup_type (Lident s) !printing_env) + with Not_found -> true) + | _ -> false -(* Inclusion between extension constructors *) +let rec tree_of_path = function + | Pident id -> + Oide_ident (ident_name id) + | Pdot(_, s, _pos) as path when non_shadowed_pervasive path -> + Oide_ident s + | Pdot(p, s, _pos) -> + Oide_dot (tree_of_path p, s) + | Papply(p1, p2) -> + Oide_apply (tree_of_path p1, tree_of_path p2) -let extension_constructors ~loc env cxt subst id ext1 ext2 = - let ext2 = Subst.extension_constructor subst ext2 in - if Includecore.extension_constructors ~loc env id ext1 ext2 - then () - else raise(Error[cxt, env, Extension_constructors(id, ext1, ext2)]) +let rec path ppf = function + | Pident id -> + ident ppf id + | Pdot(_, s, _pos) as path when non_shadowed_pervasive path -> + pp_print_string ppf s + | Pdot(p, s, _pos) -> + path ppf p; + pp_print_char ppf '.'; + pp_print_string ppf s + | Papply(p1, p2) -> + fprintf ppf "%a(%a)" path p1 path p2 -(* Inclusion between class declarations *) +let rec string_of_out_ident = function + | Oide_ident s -> s + | Oide_dot (id, s) -> String.concat "." [string_of_out_ident id; s] + | Oide_apply (id1, id2) -> + String.concat "" + [string_of_out_ident id1; "("; string_of_out_ident id2; ")"] -let class_type_declarations ~loc ~old_env env cxt subst id decl1 decl2 = - let decl2 = Subst.cltype_declaration subst decl2 in - match Includeclass.class_type_declarations ~loc env decl1 decl2 with - [] -> () - | reason -> - raise(Error[cxt, old_env, - Class_type_declarations(id, decl1, decl2, reason)]) +let string_of_path p = string_of_out_ident (tree_of_path p) -let class_declarations ~old_env env cxt subst id decl1 decl2 = - let decl2 = Subst.class_declaration subst decl2 in - match Includeclass.class_declarations env decl1 decl2 with - [] -> () - | reason -> - raise(Error[cxt, old_env, Class_declarations(id, decl1, decl2, reason)]) +(* Print a recursive annotation *) -(* Expand a module type identifier when possible *) +let tree_of_rec = function + | Trec_not -> Orec_not + | Trec_first -> Orec_first + | Trec_next -> Orec_next -exception Dont_match +(* Print a raw type expression, with sharing *) -let may_expand_module_path env path = - try ignore (Env.find_modtype_expansion path env); true - with Not_found -> false +let raw_list pr ppf = function + [] -> fprintf ppf "[]" + | a :: l -> + fprintf ppf "@[<1>[%a%t]@]" pr a + (fun ppf -> List.iter (fun x -> fprintf ppf ";@,%a" pr x) l) + +let kind_vars = ref [] +let kind_count = ref 0 + +let rec safe_kind_repr v = function + Fvar {contents=Some k} -> + if List.memq k v then "Fvar loop" else + safe_kind_repr (k::v) k + | Fvar r -> + let vid = + try List.assq r !kind_vars + with Not_found -> + let c = incr kind_count; !kind_count in + kind_vars := (r,c) :: !kind_vars; + c + in + Printf.sprintf "Fvar {None}@%d" vid + | Fpresent -> "Fpresent" + | Fabsent -> "Fabsent" + +let rec safe_commu_repr v = function + Cok -> "Cok" + | Cunknown -> "Cunknown" + | Clink r -> + if List.memq r v then "Clink loop" else + safe_commu_repr (r::v) !r + +let rec safe_repr v = function + {desc = Tlink t} when not (List.memq t v) -> + safe_repr (t::v) t + | t -> t + +let rec list_of_memo = function + Mnil -> [] + | Mcons (_priv, p, _t1, _t2, rem) -> p :: list_of_memo rem + | Mlink rem -> list_of_memo !rem + +let print_name ppf = function + None -> fprintf ppf "None" + | Some name -> fprintf ppf "\"%s\"" name -let expand_module_path env cxt path = - try - Env.find_modtype_expansion path env - with Not_found -> - raise(Error[cxt, env, Unbound_modtype_path path]) +let string_of_label = function + Nolabel -> "" + | Labelled s -> s + | Optional s -> "?"^s -let expand_module_alias env cxt path = - try (Env.find_module path env).md_type - with Not_found -> - raise(Error[cxt, env, Unbound_module_path path]) +let visited = ref [] +let rec raw_type ppf ty = + let ty = safe_repr [] ty in + if List.memq ty !visited then fprintf ppf "{id=%d}" ty.id else begin + visited := ty :: !visited; + fprintf ppf "@[<1>{id=%d;level=%d;desc=@,%a}@]" ty.id ty.level + raw_type_desc ty.desc + end +and raw_type_list tl = raw_list raw_type tl +and raw_type_desc ppf = function + Tvar name -> fprintf ppf "Tvar %a" print_name name + | Tarrow(l,t1,t2,c) -> + fprintf ppf "@[Tarrow(\"%s\",@,%a,@,%a,@,%s)@]" + (string_of_label l) raw_type t1 raw_type t2 + (safe_commu_repr [] c) + | Ttuple tl -> + fprintf ppf "@[<1>Ttuple@,%a@]" raw_type_list tl + | Tconstr (p, tl, abbrev) -> + fprintf ppf "@[Tconstr(@,%a,@,%a,@,%a)@]" path p + raw_type_list tl + (raw_list path) (list_of_memo !abbrev) + | Tobject (t, nm) -> + fprintf ppf "@[Tobject(@,%a,@,@[<1>ref%t@])@]" raw_type t + (fun ppf -> + match !nm with None -> fprintf ppf " None" + | Some(p,tl) -> + fprintf ppf "(Some(@,%a,@,%a))" path p raw_type_list tl) + | Tfield (f, k, t1, t2) -> + fprintf ppf "@[Tfield(@,%s,@,%s,@,%a,@;<0 -1>%a)@]" f + (safe_kind_repr [] k) + raw_type t1 raw_type t2 + | Tnil -> fprintf ppf "Tnil" + | Tlink t -> fprintf ppf "@[<1>Tlink@,%a@]" raw_type t + | Tsubst t -> fprintf ppf "@[<1>Tsubst@,%a@]" raw_type t + | Tunivar name -> fprintf ppf "Tunivar %a" print_name name + | Tpoly (t, tl) -> + fprintf ppf "@[Tpoly(@,%a,@,%a)@]" + raw_type t + raw_type_list tl + | Tvariant row -> + fprintf ppf + "@[{@[%s@,%a;@]@ @[%s@,%a;@]@ %s%B;@ %s%B;@ @[<1>%s%t@]}@]" + "row_fields=" + (raw_list (fun ppf (l, f) -> + fprintf ppf "@[%s,@ %a@]" l raw_field f)) + row.row_fields + "row_more=" raw_type row.row_more + "row_closed=" row.row_closed + "row_fixed=" row.row_fixed + "row_name=" + (fun ppf -> + match row.row_name with None -> fprintf ppf "None" + | Some(p,tl) -> + fprintf ppf "Some(@,%a,@,%a)" path p raw_type_list tl) + | Tpackage (p, _, tl) -> + fprintf ppf "@[Tpackage(@,%a@,%a)@]" path p + raw_type_list tl -(* -let rec normalize_module_path env cxt path = - match expand_module_alias env cxt path with - Mty_alias path' -> normalize_module_path env cxt path' - | _ -> path -*) +and raw_field ppf = function + Rpresent None -> fprintf ppf "Rpresent None" + | Rpresent (Some t) -> fprintf ppf "@[<1>Rpresent(Some@,%a)@]" raw_type t + | Reither (c,tl,m,e) -> + fprintf ppf "@[Reither(%B,@,%a,@,%B,@,@[<1>ref%t@])@]" c + raw_type_list tl m + (fun ppf -> + match !e with None -> fprintf ppf " None" + | Some f -> fprintf ppf "@,@[<1>(%a)@]" raw_field f) + | Rabsent -> fprintf ppf "Rabsent" -(* Extract name, kind and ident from a signature item *) +let raw_type_expr ppf t = + visited := []; kind_vars := []; kind_count := 0; + raw_type ppf t; + visited := []; kind_vars := [] -type field_desc = - Field_value of string - | Field_type of string - | Field_typext of string - | Field_module of string - | Field_modtype of string - | Field_class of string - | Field_classtype of string +let () = Btype.print_raw := raw_type_expr -let kind_of_field_desc = function - | Field_value _ -> "value" - | Field_type _ -> "type" - | Field_typext _ -> "extension constructor" - | Field_module _ -> "module" - | Field_modtype _ -> "module type" - | Field_class _ -> "class" - | Field_classtype _ -> "class type" +(* Normalize paths *) -let item_ident_name = function - Sig_value(id, d) -> (id, d.val_loc, Field_value(Ident.name id)) - | Sig_type(id, d, _) -> (id, d.type_loc, Field_type(Ident.name id)) - | Sig_typext(id, d, _) -> (id, d.ext_loc, Field_typext(Ident.name id)) - | Sig_module(id, d, _) -> (id, d.md_loc, Field_module(Ident.name id)) - | Sig_modtype(id, d) -> (id, d.mtd_loc, Field_modtype(Ident.name id)) - | Sig_class(id, d, _) -> (id, d.cty_loc, Field_class(Ident.name id)) - | Sig_class_type(id, d, _) -> (id, d.clty_loc, Field_classtype(Ident.name id)) +type param_subst = Id | Nth of int | Map of int list -let is_runtime_component = function - | Sig_value(_,{val_kind = Val_prim _}) - | Sig_type(_,_,_) - | Sig_modtype(_,_) - | Sig_class_type(_,_,_) -> false - | Sig_value(_,_) - | Sig_typext(_,_,_) - | Sig_module(_,_,_) - | Sig_class(_, _,_) -> true +let is_nth = function + Nth _ -> true + | _ -> false -(* Print a coercion *) +let compose l1 = function + | Id -> Map l1 + | Map l2 -> Map (List.map (List.nth l1) l2) + | Nth n -> Nth (List.nth l1 n) -let rec print_list pr ppf = function - [] -> () - | [a] -> pr ppf a - | a :: l -> pr ppf a; Format.fprintf ppf ";@ "; print_list pr ppf l -let print_list pr ppf l = - Format.fprintf ppf "[@[%a@]]" (print_list pr) l +let apply_subst s1 tyl = + if tyl = [] then [] + (* cf. PR#7543: Typemod.type_package doesn't respect type constructor arity *) + else + match s1 with + Nth n1 -> [List.nth tyl n1] + | Map l1 -> List.map (List.nth tyl) l1 + | Id -> tyl -let rec print_coercion ppf c = - let pr fmt = Format.fprintf ppf fmt in - match c with - Tcoerce_none -> pr "id" - | Tcoerce_structure (fl, nl, _) -> - pr "@[<2>struct@ %a@ %a@]" - (print_list print_coercion2) fl - (print_list print_coercion3) nl - | Tcoerce_functor (inp, out) -> - pr "@[<2>functor@ (%a)@ (%a)@]" - print_coercion inp - print_coercion out - | Tcoerce_primitive {pc_desc; pc_env = _; pc_type} -> - pr "prim %s@ (%a)" pc_desc.Primitive.prim_name - Printtyp.raw_type_expr pc_type - | Tcoerce_alias (p, c) -> - pr "@[<2>alias %a@ (%a)@]" - Printtyp.path p - print_coercion c -and print_coercion2 ppf (n, c) = - Format.fprintf ppf "@[%d,@ %a@]" n print_coercion c -and print_coercion3 ppf (i, n, c) = - Format.fprintf ppf "@[%s, %d,@ %a@]" - (Ident.unique_name i) n print_coercion c +type best_path = Paths of Path.t list | Best of Path.t -(* Simplify a structure coercion *) +let printing_depth = ref 0 +let printing_cont = ref ([] : Env.iter_cont list) +let printing_old = ref Env.empty +let printing_pers = ref Concr.empty +module PathMap = Map.Make(Path) +let printing_map = ref PathMap.empty -let simplify_structure_coercion cc id_pos_list runtime_fields = - let rec is_identity_coercion pos = function - | [] -> - true - | (n, c) :: rem -> - n = pos && c = Tcoerce_none && is_identity_coercion (pos + 1) rem in - if is_identity_coercion 0 cc - then Tcoerce_none - else Tcoerce_structure (cc, id_pos_list, runtime_fields) +let same_type t t' = repr t == repr t' -(* Inclusion between module types. - Return the restriction that transforms a value of the smaller type - into a value of the bigger type. *) +let rec index l x = + match l with + [] -> raise Not_found + | a :: l -> if x == a then 0 else 1 + index l x -let rec modtypes ~loc env cxt subst mty1 mty2 = +let rec uniq = function + [] -> true + | a :: l -> not (List.memq a l) && uniq l + +let rec normalize_type_path ?(cache=false) env p = try - try_modtypes ~loc env cxt subst mty1 mty2 + let (params, ty, _) = Env.find_type_expansion p env in + let params = List.map repr params in + match repr ty with + {desc = Tconstr (p1, tyl, _)} -> + let tyl = List.map repr tyl in + if List.length params = List.length tyl + && List.for_all2 (==) params tyl + then normalize_type_path ~cache env p1 + else if cache || List.length params <= List.length tyl + || not (uniq tyl) then (p, Id) + else + let l1 = List.map (index params) tyl in + let (p2, s2) = normalize_type_path ~cache env p1 in + (p2, compose l1 s2) + | ty -> + (p, Nth (index params ty)) with - Dont_match -> - raise(Error[cxt, env, Module_types(mty1, Subst.modtype subst mty2)]) - | Error reasons as err -> - match mty1, mty2 with - Mty_alias _, _ - | _, Mty_alias _ -> raise err - | _ -> - raise(Error((cxt, env, Module_types(mty1, Subst.modtype subst mty2)) - :: reasons)) - -and try_modtypes ~loc env cxt subst mty1 mty2 = - match (mty1, mty2) with - | (Mty_alias(pres1, p1), Mty_alias(pres2, p2)) -> begin - if Env.is_functor_arg p2 env then - raise (Error[cxt, env, Invalid_module_alias p2]); - if not (Path.same p1 p2) then begin - let p1 = Env.normalize_path None env p1 - and p2 = Env.normalize_path None env (Subst.module_path subst p2) in - if not (Path.same p1 p2) then raise Dont_match - end; - match pres1, pres2 with - | Mta_present, Mta_present -> Tcoerce_none - (* Should really be Tcoerce_ignore if it existed *) - | Mta_absent, Mta_absent -> Tcoerce_none - (* Should really be Tcoerce_empty if it existed *) - | Mta_present, Mta_absent -> Tcoerce_none - | Mta_absent, Mta_present -> - let p1 = try - Env.normalize_path (Some Location.none) env p1 - with Env.Error (Env.Missing_module (_, _, path)) -> - raise (Error[cxt, env, Unbound_module_path path]) - in - Tcoerce_alias (p1, Tcoerce_none) - end - | (Mty_alias(pres1, p1), _) -> begin - let p1 = try - Env.normalize_path (Some Location.none) env p1 - with Env.Error (Env.Missing_module (_, _, path)) -> - raise (Error[cxt, env, Unbound_module_path path]) - in - let mty1 = - Mtype.strengthen ~aliasable:true env - (expand_module_alias env cxt p1) p1 - in - let cc = modtypes ~loc env cxt subst mty1 mty2 in - match pres1 with - | Mta_present -> cc - | Mta_absent -> Tcoerce_alias (p1, cc) - end - | (Mty_ident p1, _) when may_expand_module_path env p1 -> - try_modtypes ~loc env cxt subst (expand_module_path env cxt p1) mty2 - | (_, Mty_ident _) -> - try_modtypes2 ~loc env cxt mty1 (Subst.modtype subst mty2) - | (Mty_signature sig1, Mty_signature sig2) -> - signatures ~loc env cxt subst sig1 sig2 - | (Mty_functor(param1, None, res1), Mty_functor(_param2, None, res2)) -> - begin match modtypes ~loc env (Body param1::cxt) subst res1 res2 with - Tcoerce_none -> Tcoerce_none - | cc -> Tcoerce_functor (Tcoerce_none, cc) - end - | (Mty_functor(param1, Some arg1, res1), - Mty_functor(param2, Some arg2, res2)) -> - let arg2' = Subst.modtype subst arg2 in - let cc_arg = modtypes ~loc env (Arg param1::cxt) Subst.identity arg2' arg1 in - let cc_res = - modtypes ~loc (Env.add_module param1 arg2' env) (Body param1::cxt) - (Subst.add_module param2 (Pident param1) subst) res1 res2 in - begin match (cc_arg, cc_res) with - (Tcoerce_none, Tcoerce_none) -> Tcoerce_none - | _ -> Tcoerce_functor(cc_arg, cc_res) - end - | (_, _) -> - raise Dont_match - -and try_modtypes2 ~loc env cxt mty1 mty2 = - (* mty2 is an identifier *) - match (mty1, mty2) with - (Mty_ident p1, Mty_ident p2) - when Path.same (Env.normalize_path_prefix None env p1) - (Env.normalize_path_prefix None env p2) -> - Tcoerce_none - | (_, Mty_ident p2) when may_expand_module_path env p2 -> - try_modtypes ~loc env cxt Subst.identity mty1 (expand_module_path env cxt p2) - | (_, _) -> - raise Dont_match + Not_found -> + (Env.normalize_path None env p, Id) -(* Inclusion between signatures *) +let penalty s = + if s <> "" && s.[0] = '_' then + 10 + else + try + for i = 0 to String.length s - 2 do + if s.[i] = '_' && s.[i + 1] = '_' then + raise Exit + done; + 1 + with Exit -> 10 -and signatures ~loc env cxt subst sig1 sig2 = - (* Environment used to check inclusion of components *) - let new_env = - Env.add_signature sig1 (Env.in_signature true env) in - (* Keep ids for module aliases *) - let (id_pos_list,_) = - List.fold_left - (fun (l,pos) -> function - Sig_module (id, _, _) -> - ((id,pos,Tcoerce_none)::l , pos+1) - | item -> (l, if is_runtime_component item then pos+1 else pos)) - ([], 0) sig1 in +let rec path_size = function + Pident id -> + penalty (Ident.name id), -Ident.binding_time id + | Pdot (p, _, _) -> + let (l, b) = path_size p in (1+l, b) + | Papply (p1, p2) -> + let (l, b) = path_size p1 in + (l + fst (path_size p2), b) - let runtime_fields = - let get_id = function - | Sig_value (i,_) - | Sig_module (i,_,_) - | Sig_typext (i,_,_) - | Sig_modtype(i,_) - | Sig_class (i,_,_) - | Sig_class_type(i,_,_) - | Sig_type(i,_,_) -> Ident.name i in - List.fold_right (fun item fields -> - if is_runtime_component item then get_id item :: fields else fields) sig2 [] in +let same_printing_env env = + let used_pers = Env.used_persistent () in + Env.same_types !printing_old env && Concr.equal !printing_pers used_pers - (* Build a table of the components of sig1, along with their positions. - The table is indexed by kind and name of component *) - let rec build_component_table pos tbl = function - [] -> pos, tbl - | item :: rem -> - let (id, _loc, name) = item_ident_name item in - let nextpos = if is_runtime_component item then pos + 1 else pos in - build_component_table nextpos - (Tbl.add name (id, item, pos) tbl) rem in - let len1, comps1 = - build_component_table 0 Tbl.empty sig1 in - let len2 = - List.fold_left - (fun n i -> if is_runtime_component i then n + 1 else n) - 0 - sig2 - in - (* Pair each component of sig2 with a component of sig1, - identifying the names along the way. - Return a coercion list indicating, for all run-time components - of sig2, the position of the matching run-time components of sig1 - and the coercion to be applied to it. *) - let rec pair_components subst paired unpaired = function - [] -> - begin match unpaired with - [] -> - let cc = - signature_components ~loc env new_env cxt subst - (List.rev paired) - in - if len1 = len2 then (* see PR#5098 *) - simplify_structure_coercion cc id_pos_list runtime_fields - else - Tcoerce_structure (cc, id_pos_list, runtime_fields) - | _ -> raise(Error unpaired) - end - | item2 :: rem -> - let (id2, loc, name2) = item_ident_name item2 in - let name2, report = - match item2, name2 with - Sig_type (_, {type_manifest=None}, _), Field_type s - when Btype.is_row_name s -> - (* Do not report in case of failure, - as the main type will generate an error *) - Field_type (String.sub s 0 (String.length s - 4)), false - | _ -> name2, true - in - begin try - let (id1, item1, pos1) = Tbl.find name2 comps1 in - let new_subst = - match item2 with - Sig_type _ -> - Subst.add_type id2 (Pident id1) subst - | Sig_module _ -> - Subst.add_module id2 (Pident id1) subst - | Sig_modtype _ -> - Subst.add_modtype id2 (Mty_ident (Pident id1)) subst - | Sig_value _ | Sig_typext _ - | Sig_class _ | Sig_class_type _ -> - subst - in - pair_components new_subst - ((item1, item2, pos1) :: paired) unpaired rem - with Not_found -> - let unpaired = - if report then - (cxt, env, Missing_field (id2, loc, kind_of_field_desc name2)) :: - unpaired - else unpaired in - pair_components subst paired unpaired rem - end in - (* Do the pairing and checking, and return the final coercion *) - pair_components subst [] [] sig2 +let set_printing_env env = + printing_env := env; + if !Clflags.real_paths + || !printing_env == Env.empty || same_printing_env env then () else + begin + (* printf "Reset printing_map@."; *) + printing_old := env; + printing_pers := Env.used_persistent (); + printing_map := PathMap.empty; + printing_depth := 0; + (* printf "Recompute printing_map.@."; *) + let cont = + Env.iter_types + (fun p (p', _decl) -> + let (p1, s1) = normalize_type_path env p' ~cache:true in + (* Format.eprintf "%a -> %a = %a@." path p path p' path p1 *) + if s1 = Id then + try + let r = PathMap.find p1 !printing_map in + match !r with + Paths l -> r := Paths (p :: l) + | Best p' -> r := Paths [p; p'] (* assert false *) + with Not_found -> + printing_map := PathMap.add p1 (ref (Paths [p])) !printing_map) + env in + printing_cont := [cont]; + end -(* Inclusion between signature components *) +let wrap_printing_env env f = + set_printing_env env; + try_finally f (fun () -> set_printing_env Env.empty) -and signature_components ~loc old_env env cxt subst paired = - let comps_rec rem = signature_components ~loc old_env env cxt subst rem in - match paired with - [] -> [] - | (Sig_value(id1, valdecl1), Sig_value(_id2, valdecl2), pos) :: rem -> - let cc = value_descriptions ~loc env cxt subst id1 valdecl1 valdecl2 in - begin match valdecl2.val_kind with - Val_prim _ -> comps_rec rem - | _ -> (pos, cc) :: comps_rec rem - end - | (Sig_type(id1, tydecl1, _), Sig_type(_id2, tydecl2, _), _pos) :: rem -> - type_declarations ~loc ~old_env env cxt subst id1 tydecl1 tydecl2; - comps_rec rem - | (Sig_typext(id1, ext1, _), Sig_typext(_id2, ext2, _), pos) - :: rem -> - extension_constructors ~loc env cxt subst id1 ext1 ext2; - (pos, Tcoerce_none) :: comps_rec rem - | (Sig_module(id1, mty1, _), Sig_module(_id2, mty2, _), pos) :: rem -> - let cc = module_declarations ~loc env cxt subst id1 mty1 mty2 in - (pos, cc) :: comps_rec rem - | (Sig_modtype(id1, info1), Sig_modtype(_id2, info2), _pos) :: rem -> - modtype_infos ~loc env cxt subst id1 info1 info2; - comps_rec rem - | (Sig_class(id1, decl1, _), Sig_class(_id2, decl2, _), pos) :: rem -> - class_declarations ~old_env env cxt subst id1 decl1 decl2; - (pos, Tcoerce_none) :: comps_rec rem - | (Sig_class_type(id1, info1, _), - Sig_class_type(_id2, info2, _), _pos) :: rem -> - class_type_declarations ~loc ~old_env env cxt subst id1 info1 info2; - comps_rec rem - | _ -> - assert false +let wrap_printing_env env f = + Env.without_cmis (wrap_printing_env env) f -and module_declarations ~loc env cxt subst id1 md1 md2 = - Builtin_attributes.check_deprecated_inclusion - ~def:md1.md_loc - ~use:md2.md_loc - loc - md1.md_attributes md2.md_attributes - (Ident.name id1); - let p1 = Pident id1 in - Env.mark_module_used env (Ident.name id1) md1.md_loc; - modtypes ~loc env (Module id1::cxt) subst - (Mtype.strengthen ~aliasable:true env md1.md_type p1) md2.md_type +let is_unambiguous path env = + let l = Env.find_shadowed_types path env in + List.exists (Path.same path) l || (* concrete paths are ok *) + match l with + [] -> true + | p :: rem -> + (* allow also coherent paths: *) + let normalize p = fst (normalize_type_path ~cache:true env p) in + let p' = normalize p in + List.for_all (fun p -> Path.same (normalize p) p') rem || + (* also allow repeatedly defining and opening (for toplevel) *) + let id = lid_of_path p in + List.for_all (fun p -> lid_of_path p = id) rem && + Path.same p (Env.lookup_type id env) -(* Inclusion between module type specifications *) +let rec get_best_path r = + match !r with + Best p' -> p' + | Paths [] -> raise Not_found + | Paths l -> + r := Paths []; + List.iter + (fun p -> + (* Format.eprintf "evaluating %a@." path p; *) + match !r with + Best p' when path_size p >= path_size p' -> () + | _ -> if is_unambiguous p !printing_env then r := Best p) + (* else Format.eprintf "%a ignored as ambiguous@." path p *) + l; + get_best_path r -and modtype_infos ~loc env cxt subst id info1 info2 = - Builtin_attributes.check_deprecated_inclusion - ~def:info1.mtd_loc - ~use:info2.mtd_loc - loc - info1.mtd_attributes info2.mtd_attributes - (Ident.name id); - let info2 = Subst.modtype_declaration subst info2 in - let cxt' = Modtype id :: cxt in - try - match (info1.mtd_type, info2.mtd_type) with - (None, None) -> () - | (Some _, None) -> () - | (Some mty1, Some mty2) -> - check_modtype_equiv ~loc env cxt' mty1 mty2 - | (None, Some mty2) -> - check_modtype_equiv ~loc env cxt' (Mty_ident(Pident id)) mty2 - with Error reasons -> - raise(Error((cxt, env, Modtype_infos(id, info1, info2)) :: reasons)) +let best_type_path p = + if !Clflags.real_paths || !printing_env == Env.empty + then (p, Id) + else + let (p', s) = normalize_type_path !printing_env p in + let get_path () = get_best_path (PathMap.find p' !printing_map) in + while !printing_cont <> [] && + try fst (path_size (get_path ())) > !printing_depth with Not_found -> true + do + printing_cont := List.map snd (Env.run_iter_cont !printing_cont); + incr printing_depth; + done; + let p'' = try get_path () with Not_found -> p' in + (* Format.eprintf "%a = %a -> %a@." path p path p' path p''; *) + (p'', s) -and check_modtype_equiv ~loc env cxt mty1 mty2 = - match - (modtypes ~loc env cxt Subst.identity mty1 mty2, - modtypes ~loc env cxt Subst.identity mty2 mty1) - with - (Tcoerce_none, Tcoerce_none) -> () - | (_c1, _c2) -> - (* Format.eprintf "@[c1 = %a@ c2 = %a@]@." - print_coercion _c1 print_coercion _c2; *) - raise(Error [cxt, env, Modtype_permutation]) +(* Print a type expression *) -(* Simplified inclusion check between module types (for Env) *) +let names = ref ([] : (type_expr * string) list) +let name_counter = ref 0 +let named_vars = ref ([] : string list) -let can_alias env path = - let rec no_apply = function - | Pident _ -> true - | Pdot(p, _, _) -> no_apply p - | Papply _ -> false - in - no_apply path && not (Env.is_functor_arg path env) +let weak_counter = ref 1 +let weak_var_map = ref TypeMap.empty +let named_weak_vars = ref StringSet.empty -let check_modtype_inclusion ~loc env mty1 path1 mty2 = - try - let aliasable = can_alias env path1 in - ignore(modtypes ~loc env [] Subst.identity - (Mtype.strengthen ~aliasable env mty1 path1) mty2) - with Error _ -> - raise Not_found +let reset_names () = names := []; name_counter := 0; named_vars := [] +let add_named_var ty = + match ty.desc with + Tvar (Some name) | Tunivar (Some name) -> + if List.mem name !named_vars then () else + named_vars := name :: !named_vars + | _ -> () -let _ = Env.check_modtype_inclusion := check_modtype_inclusion +let name_is_already_used name = + List.mem name !named_vars + || List.exists (fun (_, name') -> name = name') !names + || StringSet.mem name !named_weak_vars -(* Check that an implementation of a compilation unit meets its - interface. *) +let rec new_name () = + let name = + if !name_counter < 26 + then String.make 1 (Char.chr(97 + !name_counter)) + else String.make 1 (Char.chr(97 + !name_counter mod 26)) ^ + string_of_int(!name_counter / 26) in + incr name_counter; + if name_is_already_used name then new_name () else name -let compunit env impl_name impl_sig intf_name intf_sig = - try - signatures ~loc:(Location.in_file impl_name) env [] Subst.identity - impl_sig intf_sig - with Error reasons -> - raise(Error(([], Env.empty,Interface_mismatch(impl_name, intf_name)) - :: reasons)) +let rec new_weak_name ty () = + let name = "weak" ^ string_of_int !weak_counter in + incr weak_counter; + if name_is_already_used name then new_weak_name ty () + else begin + named_weak_vars := StringSet.add name !named_weak_vars; + weak_var_map := TypeMap.add ty name !weak_var_map; + name + end -(* Hide the context and substitution parameters to the outside world *) +let name_of_type name_generator t = + (* We've already been through repr at this stage, so t is our representative + of the union-find class. *) + try List.assq t !names with Not_found -> + try TypeMap.find t !weak_var_map with Not_found -> + let name = + match t.desc with + Tvar (Some name) | Tunivar (Some name) -> + (* Some part of the type we've already printed has assigned another + * unification variable to that name. We want to keep the name, so try + * adding a number until we find a name that's not taken. *) + let current_name = ref name in + let i = ref 0 in + while List.exists (fun (_, name') -> !current_name = name') !names do + current_name := name ^ (string_of_int !i); + i := !i + 1; + done; + !current_name + | _ -> + (* No name available, create a new one *) + name_generator () + in + (* Exception for type declarations *) + if name <> "_" then names := (t, name) :: !names; + name -let modtypes ~loc env mty1 mty2 = modtypes ~loc env [] Subst.identity mty1 mty2 -let signatures env sig1 sig2 = - signatures ~loc:Location.none env [] Subst.identity sig1 sig2 -let type_declarations ~loc env id decl1 decl2 = - type_declarations ~loc env [] Subst.identity id decl1 decl2 +let check_name_of_type t = ignore(name_of_type new_name t) -(* -let modtypes env m1 m2 = - let c = modtypes env m1 m2 in - Format.eprintf "@[<2>modtypes@ %a@ %a =@ %a@]@." - Printtyp.modtype m1 Printtyp.modtype m2 - print_coercion c; - c -*) +let remove_names tyl = + let tyl = List.map repr tyl in + names := List.filter (fun (ty,_) -> not (List.memq ty tyl)) !names -(* Error report *) +let visited_objects = ref ([] : type_expr list) +let aliased = ref ([] : type_expr list) +let delayed = ref ([] : type_expr list) -open Format -open Printtyp +let add_delayed t = + if not (List.memq t !delayed) then delayed := t :: !delayed -let show_loc msg ppf loc = - let pos = loc.Location.loc_start in - if List.mem pos.Lexing.pos_fname [""; "_none_"; "//toplevel//"] then () - else fprintf ppf "@\n@[<2>%a:@ %s@]" Location.print_loc loc msg +let is_aliased ty = List.memq (proxy ty) !aliased +let add_alias ty = + let px = proxy ty in + if not (is_aliased px) then begin + aliased := px :: !aliased; + add_named_var px + end -let show_locs ppf (loc1, loc2) = - show_loc "Expected declaration" ppf loc2; - show_loc "Actual declaration" ppf loc1 +let aliasable ty = + match ty.desc with + Tvar _ | Tunivar _ | Tpoly _ -> false + | Tconstr (p, _, _) -> + not (is_nth (snd (best_type_path p))) + | _ -> true -let include_err ppf = function - | Missing_field (id, loc, kind) -> - fprintf ppf "The %s `%a' is required but not provided" kind ident id; - show_loc "Expected declaration" ppf loc - | Value_descriptions(id, d1, d2) -> - fprintf ppf - "@[Values do not match:@ %a@;<1 -2>is not included in@ %a@]" - (value_description id) d1 (value_description id) d2; - show_locs ppf (d1.val_loc, d2.val_loc); - | Type_declarations(id, d1, d2, errs) -> - fprintf ppf "@[@[%s:@;<1 2>%a@ %s@;<1 2>%a@]%a%a@]" - "Type declarations do not match" - (type_declaration id) d1 - "is not included in" - (type_declaration id) d2 - show_locs (d1.type_loc, d2.type_loc) - (Includecore.report_type_mismatch - "the first" "the second" "declaration") errs - | Extension_constructors(id, x1, x2) -> - fprintf ppf - "@[Extension declarations do not match:@ \ - %a@;<1 -2>is not included in@ %a@]" - (extension_constructor id) x1 - (extension_constructor id) x2; - show_locs ppf (x1.ext_loc, x2.ext_loc) - | Module_types(mty1, mty2)-> - fprintf ppf - "@[Modules do not match:@ \ - %a@;<1 -2>is not included in@ %a@]" - modtype mty1 - modtype mty2 - | Modtype_infos(id, d1, d2) -> - fprintf ppf - "@[Module type declarations do not match:@ \ - %a@;<1 -2>does not match@ %a@]" - (modtype_declaration id) d1 - (modtype_declaration id) d2 - | Modtype_permutation -> - fprintf ppf "Illegal permutation of structure fields" - | Interface_mismatch(impl_name, intf_name) -> - fprintf ppf "@[The implementation %s@ does not match the interface %s:" - impl_name intf_name - | Class_type_declarations(id, d1, d2, reason) -> - fprintf ppf - "@[Class type declarations do not match:@ \ - %a@;<1 -2>does not match@ %a@]@ %a" - (Printtyp.cltype_declaration id) d1 - (Printtyp.cltype_declaration id) d2 - Includeclass.report_error reason - | Class_declarations(id, d1, d2, reason) -> - fprintf ppf - "@[Class declarations do not match:@ \ - %a@;<1 -2>does not match@ %a@]@ %a" - (Printtyp.class_declaration id) d1 - (Printtyp.class_declaration id) d2 - Includeclass.report_error reason - | Unbound_modtype_path path -> - fprintf ppf "Unbound module type %a" Printtyp.path path - | Unbound_module_path path -> - fprintf ppf "Unbound module %a" Printtyp.path path - | Invalid_module_alias path -> - fprintf ppf "Module %a cannot be aliased" Printtyp.path path +let namable_row row = + row.row_name <> None && + List.for_all + (fun (_, f) -> + match row_field_repr f with + | Reither(c, l, _, _) -> + row.row_closed && if c then l = [] else List.length l = 1 + | _ -> true) + row.row_fields -let rec context ppf = function - Module id :: rem -> - fprintf ppf "@[<2>module %a%a@]" ident id args rem - | Modtype id :: rem -> - fprintf ppf "@[<2>module type %a =@ %a@]" ident id context_mty rem - | Body x :: rem -> - fprintf ppf "functor (%s) ->@ %a" (argname x) context_mty rem - | Arg x :: rem -> - fprintf ppf "functor (%a : %a) -> ..." ident x context_mty rem - | [] -> - fprintf ppf "" -and context_mty ppf = function - (Module _ | Modtype _) :: _ as rem -> - fprintf ppf "@[<2>sig@ %a@;<1 -2>end@]" context rem - | cxt -> context ppf cxt -and args ppf = function - Body x :: rem -> - fprintf ppf "(%s)%a" (argname x) args rem - | Arg x :: rem -> - fprintf ppf "(%a :@ %a) : ..." ident x context_mty rem - | cxt -> - fprintf ppf " :@ %a" context_mty cxt -and argname x = - let s = Ident.name x in - if s = "*" then "" else s +let rec mark_loops_rec visited ty = + let ty = repr ty in + let px = proxy ty in + if List.memq px visited && aliasable ty then add_alias px else + let visited = px :: visited in + match ty.desc with + | Tvar _ -> add_named_var ty + | Tarrow(_, ty1, ty2, _) -> + mark_loops_rec visited ty1; mark_loops_rec visited ty2 + | Ttuple tyl -> List.iter (mark_loops_rec visited) tyl + | Tconstr(p, tyl, _) -> + let (_p', s) = best_type_path p in + List.iter (mark_loops_rec visited) (apply_subst s tyl) + | Tpackage (_, _, tyl) -> + List.iter (mark_loops_rec visited) tyl + | Tvariant row -> + if List.memq px !visited_objects then add_alias px else + begin + let row = row_repr row in + if not (static_row row) then + visited_objects := px :: !visited_objects; + match row.row_name with + | Some(_p, tyl) when namable_row row -> + List.iter (mark_loops_rec visited) tyl + | _ -> + iter_row (mark_loops_rec visited) row + end + | Tobject (fi, nm) -> + if List.memq px !visited_objects then add_alias px else + begin + if opened_object ty then + visited_objects := px :: !visited_objects; + begin match !nm with + | None -> + let fields, _ = flatten_fields fi in + List.iter + (fun (_, kind, ty) -> + if field_kind_repr kind = Fpresent then + mark_loops_rec visited ty) + fields + | Some (_, l) -> + List.iter (mark_loops_rec visited) (List.tl l) + end + end + | Tfield(_, kind, ty1, ty2) when field_kind_repr kind = Fpresent -> + mark_loops_rec visited ty1; mark_loops_rec visited ty2 + | Tfield(_, _, _, ty2) -> + mark_loops_rec visited ty2 + | Tnil -> () + | Tsubst ty -> mark_loops_rec visited ty + | Tlink _ -> fatal_error "Printtyp.mark_loops_rec (2)" + | Tpoly (ty, tyl) -> + List.iter (fun t -> add_alias t) tyl; + mark_loops_rec visited ty + | Tunivar _ -> add_named_var ty -let path_of_context = function - Module id :: rem -> - let rec subm path = function - [] -> path - | Module id :: rem -> subm (Pdot (path, Ident.name id, -1)) rem - | _ -> assert false - in subm (Pident id) rem - | _ -> assert false +let mark_loops ty = + normalize_type Env.empty ty; + mark_loops_rec [] ty;; -let context ppf cxt = - if cxt = [] then () else - if List.for_all (function Module _ -> true | _ -> false) cxt then - fprintf ppf "In module %a:@ " path (path_of_context cxt) - else - fprintf ppf "@[At position@ %a@]@ " context cxt +let reset_loop_marks () = + visited_objects := []; aliased := []; delayed := [] -let include_err ppf (cxt, env, err) = - Printtyp.wrap_printing_env env (fun () -> - fprintf ppf "@[%a%a@]" context (List.rev cxt) include_err err) +let reset () = + unique_names := Ident.empty; reset_names (); reset_loop_marks () -let buffer = ref Bytes.empty -let is_big obj = - let size = !Clflags.error_size in - size > 0 && - begin - if Bytes.length !buffer < size then buffer := Bytes.create size; - try ignore (Marshal.to_buffer !buffer 0 size obj []); false - with _ -> true - end +let reset_and_mark_loops ty = + reset (); mark_loops ty -let report_error ppf errs = - if errs = [] then () else - let (errs , err) = split_last errs in - let pe = ref true in - let include_err' ppf (_,_,obj as err) = - if not (is_big obj) then fprintf ppf "%a@ " include_err err - else if !pe then (fprintf ppf "...@ "; pe := false) - in - let print_errs ppf = List.iter (include_err' ppf) in - fprintf ppf "@[%a%a@]" print_errs errs include_err err +let reset_and_mark_loops_list tyl = + reset (); List.iter mark_loops tyl +(* Disabled in classic mode when printing an unification error *) +let print_labels = ref true -(* We could do a better job to split the individual error items - as sub-messages of the main interface mismatch on the whole unit. *) -let () = - Location.register_error_of_exn - (function - | Error err -> Some (Location.error_of_printer_file report_error err) - | _ -> None - ) +let rec tree_of_typexp sch ty = + let ty = repr ty in + let px = proxy ty in + if List.mem_assq px !names && not (List.memq px !delayed) then + let mark = is_non_gen sch ty in + let name = name_of_type (if mark then new_weak_name ty else new_name) px in + Otyp_var (mark, name) else -end -module Stypes : sig -#1 "stypes.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Damien Doligez, projet Moscova, INRIA Rocquencourt *) -(* *) -(* Copyright 2003 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) + let pr_typ () = + match ty.desc with + | Tvar _ -> + (*let lev = + if is_non_gen sch ty then "/" ^ string_of_int ty.level else "" in*) + let non_gen = is_non_gen sch ty in + let name_gen = if non_gen then new_weak_name ty else new_name in + Otyp_var (non_gen, name_of_type name_gen ty) + | Tarrow(l, ty1, ty2, _) -> + let pr_arrow l ty1 ty2 = + let lab = + if !print_labels || is_optional l then string_of_label l else "" + in + let t1 = + if is_optional l then + match (repr ty1).desc with + | Tconstr(path, [ty], _) + when Path.same path Predef.path_option -> + tree_of_typexp sch ty + | _ -> Otyp_stuff "" + else tree_of_typexp sch ty1 in + Otyp_arrow (lab, t1, tree_of_typexp sch ty2) in + pr_arrow l ty1 ty2 + | Ttuple tyl -> + Otyp_tuple (tree_of_typlist sch tyl) + | Tconstr(p, tyl, _abbrev) -> + let p', s = best_type_path p in + let tyl' = apply_subst s tyl in + if is_nth s && not (tyl'=[]) then tree_of_typexp sch (List.hd tyl') else + Otyp_constr (tree_of_path p', tree_of_typlist sch tyl') + | Tvariant row -> + let row = row_repr row in + let fields = + if row.row_closed then + List.filter (fun (_, f) -> row_field_repr f <> Rabsent) + row.row_fields + else row.row_fields in + let present = + List.filter + (fun (_, f) -> + match row_field_repr f with + | Rpresent _ -> true + | _ -> false) + fields in + let all_present = List.length present = List.length fields in + begin match row.row_name with + | Some(p, tyl) when namable_row row -> + let (p', s) = best_type_path p in + let id = tree_of_path p' in + let args = tree_of_typlist sch (apply_subst s tyl) in + let out_variant = + if is_nth s then List.hd args else Otyp_constr (id, args) in + if row.row_closed && all_present then + out_variant + else + let non_gen = is_non_gen sch px in + let tags = + if all_present then None else Some (List.map fst present) in + Otyp_variant (non_gen, Ovar_typ out_variant, row.row_closed, tags) + | _ -> + let non_gen = + not (row.row_closed && all_present) && is_non_gen sch px in + let fields = List.map (tree_of_row_field sch) fields in + let tags = + if all_present then None else Some (List.map fst present) in + Otyp_variant (non_gen, Ovar_fields fields, row.row_closed, tags) + end + | Tobject (fi, nm) -> + tree_of_typobject sch fi !nm + | Tnil | Tfield _ -> + tree_of_typobject sch ty None + | Tsubst ty -> + tree_of_typexp sch ty + | Tlink _ -> + fatal_error "Printtyp.tree_of_typexp" + | Tpoly (ty, []) -> + tree_of_typexp sch ty + | Tpoly (ty, tyl) -> + (*let print_names () = + List.iter (fun (_, name) -> prerr_string (name ^ " ")) !names; + prerr_string "; " in *) + let tyl = List.map repr tyl in + if tyl = [] then tree_of_typexp sch ty else begin + let old_delayed = !delayed in + (* Make the names delayed, so that the real type is + printed once when used as proxy *) + List.iter add_delayed tyl; + let tl = List.map (name_of_type new_name) tyl in + let tr = Otyp_poly (tl, tree_of_typexp sch ty) in + (* Forget names when we leave scope *) + remove_names tyl; + delayed := old_delayed; tr + end + | Tunivar _ -> + Otyp_var (false, name_of_type new_name ty) + | Tpackage (p, n, tyl) -> + let n = + List.map (fun li -> String.concat "." (Longident.flatten li)) n in + Otyp_module (Path.name p, n, tree_of_typlist sch tyl) + in + if List.memq px !delayed then delayed := List.filter ((!=) px) !delayed; + if is_aliased px && aliasable ty then begin + check_name_of_type px; + Otyp_alias (pr_typ (), name_of_type new_name px) end + else pr_typ () -(* Recording and dumping (partial) type information *) +and tree_of_row_field sch (l, f) = + match row_field_repr f with + | Rpresent None | Reither(true, [], _, _) -> (l, false, []) + | Rpresent(Some ty) -> (l, false, [tree_of_typexp sch ty]) + | Reither(c, tyl, _, _) -> + if c (* contradiction: constant constructor with an argument *) + then (l, true, tree_of_typlist sch tyl) + else (l, false, tree_of_typlist sch tyl) + | Rabsent -> (l, false, [] (* actually, an error *)) -(* Clflags.save_types must be true *) +and tree_of_typlist sch tyl = + List.map (tree_of_typexp sch) tyl -open Typedtree;; +and tree_of_typobject sch fi nm = + begin match nm with + | None -> + let pr_fields fi = + let (fields, rest) = flatten_fields fi in + let present_fields = + List.fold_right + (fun (n, k, t) l -> + match field_kind_repr k with + | Fpresent -> (n, t) :: l + | _ -> l) + fields [] in + let sorted_fields = + List.sort + (fun (n, _) (n', _) -> String.compare n n') present_fields in + tree_of_typfields sch rest sorted_fields in + let (fields, rest) = pr_fields fi in + Otyp_object (fields, rest) + | Some (p, ty :: tyl) -> + let non_gen = is_non_gen sch (repr ty) in + let args = tree_of_typlist sch tyl in + let (p', s) = best_type_path p in + assert (s = Id); + Otyp_class (non_gen, tree_of_path p', args) + | _ -> + fatal_error "Printtyp.tree_of_typobject" + end -type annotation = - | Ti_pat of pattern - | Ti_expr of expression - | Ti_class of class_expr - | Ti_mod of module_expr - | An_call of Location.t * Annot.call - | An_ident of Location.t * string * Annot.ident -;; +and is_non_gen sch ty = + sch && is_Tvar ty && ty.level <> generic_level -val record : annotation -> unit;; -val record_phrase : Location.t -> unit;; -val dump : string option -> unit;; +and tree_of_typfields sch rest = function + | [] -> + let rest = + match rest.desc with + | Tvar _ | Tunivar _ -> Some (is_non_gen sch rest) + | Tconstr _ -> Some false + | Tnil -> None + | _ -> fatal_error "typfields (1)" + in + ([], rest) + | (s, t) :: l -> + let field = (s, tree_of_typexp sch t) in + let (fields, rest) = tree_of_typfields sch rest l in + (field :: fields, rest) -val get_location : annotation -> Location.t;; -val get_info : unit -> annotation list;; +let typexp sch ppf ty = + !Oprint.out_type ppf (tree_of_typexp sch ty) -end = struct -#1 "stypes.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Damien Doligez, projet Moscova, INRIA Rocquencourt *) -(* *) -(* Copyright 2003 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let type_expr ppf ty = typexp false ppf ty -(* Recording and dumping (partial) type information *) +and type_sch ppf ty = typexp true ppf ty -(* - We record all types in a list as they are created. - This means we can dump type information even if type inference fails, - which is extremely important, since type information is most - interesting in case of errors. -*) +and type_scheme ppf ty = reset_and_mark_loops ty; typexp true ppf ty -open Annot;; -open Lexing;; -open Location;; -open Typedtree;; +(* Maxence *) +let type_scheme_max ?(b_reset_names=true) ppf ty = + if b_reset_names then reset_names () ; + typexp true ppf ty +(* End Maxence *) -let output_int oc i = output_string oc (string_of_int i) +let tree_of_type_scheme ty = reset_and_mark_loops ty; tree_of_typexp true ty -type annotation = - | Ti_pat of pattern - | Ti_expr of expression - | Ti_class of class_expr - | Ti_mod of module_expr - | An_call of Location.t * Annot.call - | An_ident of Location.t * string * Annot.ident -;; +(* Print one type declaration *) -let get_location ti = - match ti with - Ti_pat p -> p.pat_loc - | Ti_expr e -> e.exp_loc - | Ti_class c -> c.cl_loc - | Ti_mod m -> m.mod_loc - | An_call (l, _k) -> l - | An_ident (l, _s, _k) -> l -;; +let tree_of_constraints params = + List.fold_right + (fun ty list -> + let ty' = unalias ty in + if proxy ty != proxy ty' then + let tr = tree_of_typexp true ty in + (tr, tree_of_typexp true ty') :: list + else list) + params [] -let annotations = ref ([] : annotation list);; -let phrases = ref ([] : Location.t list);; +let filter_params tyl = + let params = + List.fold_left + (fun tyl ty -> + let ty = repr ty in + if List.memq ty tyl then Btype.newgenty (Tsubst ty) :: tyl + else ty :: tyl) + [] tyl + in List.rev params -let record ti = - if !Clflags.annotations && not (get_location ti).Location.loc_ghost then - annotations := ti :: !annotations -;; +let mark_loops_constructor_arguments = function + | Cstr_tuple l -> List.iter mark_loops l + | Cstr_record l -> List.iter (fun l -> mark_loops l.ld_type) l -let record_phrase loc = - if !Clflags.annotations then phrases := loc :: !phrases; -;; +let rec tree_of_type_decl id decl = -(* comparison order: - the intervals are sorted by order of increasing upper bound - same upper bound -> sorted by decreasing lower bound -*) -let cmp_loc_inner_first loc1 loc2 = - match compare loc1.loc_end.pos_cnum loc2.loc_end.pos_cnum with - | 0 -> compare loc2.loc_start.pos_cnum loc1.loc_start.pos_cnum - | x -> x -;; -let cmp_ti_inner_first ti1 ti2 = - cmp_loc_inner_first (get_location ti1) (get_location ti2) -;; + reset(); -let print_position pp pos = - if pos = dummy_pos then - output_string pp "--" - else begin - output_char pp '\"'; - output_string pp (String.escaped pos.pos_fname); - output_string pp "\" "; - output_int pp pos.pos_lnum; - output_char pp ' '; - output_int pp pos.pos_bol; - output_char pp ' '; - output_int pp pos.pos_cnum; - end -;; + let params = filter_params decl.type_params in -let print_location pp loc = - print_position pp loc.loc_start; - output_char pp ' '; - print_position pp loc.loc_end; -;; + begin match decl.type_manifest with + | Some ty -> + let vars = free_variables ty in + List.iter + (function {desc = Tvar (Some "_")} as ty -> + if List.memq ty vars then ty.desc <- Tvar None + | _ -> ()) + params + | None -> () + end; -let sort_filter_phrases () = - let ph = List.sort (fun x y -> cmp_loc_inner_first y x) !phrases in - let rec loop accu cur l = - match l with - | [] -> accu - | loc :: t -> - if cur.loc_start.pos_cnum <= loc.loc_start.pos_cnum - && cur.loc_end.pos_cnum >= loc.loc_end.pos_cnum - then loop accu cur t - else loop (loc :: accu) loc t + List.iter add_alias params; + List.iter mark_loops params; + List.iter check_name_of_type (List.map proxy params); + let ty_manifest = + match decl.type_manifest with + | None -> None + | Some ty -> + let ty = + (* Special hack to hide variant name *) + match repr ty with {desc=Tvariant row} -> + let row = row_repr row in + begin match row.row_name with + Some (Pident id', _) when Ident.same id id' -> + newgenty (Tvariant {row with row_name = None}) + | _ -> ty + end + | _ -> ty + in + mark_loops ty; + Some ty in - phrases := loop [] Location.none ph; -;; - -let rec printtyp_reset_maybe loc = - match !phrases with - | cur :: t when cur.loc_start.pos_cnum <= loc.loc_start.pos_cnum -> - Printtyp.reset (); - phrases := t; - printtyp_reset_maybe loc; - | _ -> () -;; - -let call_kind_string k = - match k with - | Tail -> "tail" - | Stack -> "stack" - | Inline -> "inline" -;; - -let print_ident_annot pp str k = - match k with - | Idef l -> - output_string pp "def "; - output_string pp str; - output_char pp ' '; - print_location pp l; - output_char pp '\n' - | Iref_internal l -> - output_string pp "int_ref "; - output_string pp str; - output_char pp ' '; - print_location pp l; - output_char pp '\n' - | Iref_external -> - output_string pp "ext_ref "; - output_string pp str; - output_char pp '\n' -;; + begin match decl.type_kind with + | Type_abstract -> () + | Type_variant cstrs -> + List.iter + (fun c -> + mark_loops_constructor_arguments c.cd_args; + may mark_loops c.cd_res) + cstrs + | Type_record(l, _rep) -> + List.iter (fun l -> mark_loops l.ld_type) l + | Type_open -> () + end; -(* The format of the annotation file is documented in emacs/caml-types.el. *) + let type_param = + function + | Otyp_var (_, id) -> id + | _ -> "?" + in + let type_defined decl = + let abstr = + match decl.type_kind with + Type_abstract -> + decl.type_manifest = None || decl.type_private = Private + | Type_record _ -> + decl.type_private = Private + | Type_variant tll -> + decl.type_private = Private || + List.exists (fun cd -> cd.cd_res <> None) tll + | Type_open -> + decl.type_manifest = None + in + let vari = + List.map2 + (fun ty v -> + if abstr || not (is_Tvar (repr ty)) then Variance.get_upper v + else (true,true)) + decl.type_params decl.type_variance + in + (Ident.name id, + List.map2 (fun ty cocn -> type_param (tree_of_typexp false ty), cocn) + params vari) + in + let tree_of_manifest ty1 = + match ty_manifest with + | None -> ty1 + | Some ty -> Otyp_manifest (tree_of_typexp false ty, ty1) + in + let (name, args) = type_defined decl in + let constraints = tree_of_constraints params in + let ty, priv = + match decl.type_kind with + | Type_abstract -> + begin match ty_manifest with + | None -> (Otyp_abstract, Public) + | Some ty -> + tree_of_typexp false ty, decl.type_private + end + | Type_variant cstrs -> + tree_of_manifest (Otyp_sum (List.map tree_of_constructor cstrs)), + decl.type_private + | Type_record(lbls, _rep) -> + tree_of_manifest (Otyp_record (List.map tree_of_label lbls)), + decl.type_private + | Type_open -> + tree_of_manifest Otyp_open, + decl.type_private + in + let immediate = + Builtin_attributes.immediate decl.type_attributes + in + { otype_name = name; + otype_params = args; + otype_type = ty; + otype_private = priv; + otype_immediate = immediate; + otype_unboxed = decl.type_unboxed.unboxed; + otype_cstrs = constraints } -let print_info pp prev_loc ti = - match ti with - | Ti_class _ | Ti_mod _ -> prev_loc - | Ti_pat {pat_loc = loc; pat_type = typ; pat_env = env} - | Ti_expr {exp_loc = loc; exp_type = typ; exp_env = env} -> - if loc <> prev_loc then begin - print_location pp loc; - output_char pp '\n' - end; - output_string pp "type(\n"; - printtyp_reset_maybe loc; - Printtyp.mark_loops typ; - Format.pp_print_string Format.str_formatter " "; - Printtyp.wrap_printing_env env - (fun () -> Printtyp.type_sch Format.str_formatter typ); - Format.pp_print_newline Format.str_formatter (); - let s = Format.flush_str_formatter () in - output_string pp s; - output_string pp ")\n"; - loc - | An_call (loc, k) -> - if loc <> prev_loc then begin - print_location pp loc; - output_char pp '\n' - end; - output_string pp "call(\n "; - output_string pp (call_kind_string k); - output_string pp "\n)\n"; - loc - | An_ident (loc, str, k) -> - if loc <> prev_loc then begin - print_location pp loc; - output_char pp '\n' - end; - output_string pp "ident(\n "; - print_ident_annot pp str k; - output_string pp ")\n"; - loc -;; +and tree_of_constructor_arguments = function + | Cstr_tuple l -> tree_of_typlist false l + | Cstr_record l -> [ Otyp_record (List.map tree_of_label l) ] -let get_info () = - let info = List.fast_sort cmp_ti_inner_first !annotations in - annotations := []; - info -;; +and tree_of_constructor cd = + let name = Ident.name cd.cd_id in + let arg () = tree_of_constructor_arguments cd.cd_args in + match cd.cd_res with + | None -> (name, arg (), None) + | Some res -> + let nm = !names in + names := []; + let ret = tree_of_typexp false res in + let args = arg () in + names := nm; + (name, args, Some ret) -let dump filename = - if !Clflags.annotations then begin - let do_dump _temp_filename pp = - let info = get_info () in - sort_filter_phrases (); - ignore (List.fold_left (print_info pp) Location.none info) in - begin match filename with - | None -> do_dump "" stdout - | Some filename -> - Misc.output_to_file_via_temporary ~mode:[Open_text] filename do_dump - end; - phrases := []; - end else begin - annotations := []; - end; -;; +and tree_of_label l = + (Ident.name l.ld_id, l.ld_mutable = Mutable, tree_of_typexp false l.ld_type) -end -module TypedtreeIter : sig -#1 "typedtreeIter.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Thomas Gazagnaire (OCamlPro), Fabrice Le Fessant (INRIA Saclay) *) -(* *) -(* Copyright 2007 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let tree_of_type_declaration id decl rs = + Osig_type (tree_of_type_decl id decl, tree_of_rec rs) -open Asttypes -open Typedtree +let type_declaration id ppf decl = + !Oprint.out_sig_item ppf (tree_of_type_declaration id decl Trec_first) +let constructor_arguments ppf a = + let tys = tree_of_constructor_arguments a in + !Oprint.out_type ppf (Otyp_tuple tys) -module type IteratorArgument = sig - val enter_structure : structure -> unit - val enter_value_description : value_description -> unit - val enter_type_extension : type_extension -> unit - val enter_extension_constructor : extension_constructor -> unit - val enter_pattern : pattern -> unit - val enter_expression : expression -> unit - val enter_package_type : package_type -> unit - val enter_signature : signature -> unit - val enter_signature_item : signature_item -> unit - val enter_module_type_declaration : module_type_declaration -> unit - val enter_module_type : module_type -> unit - val enter_module_expr : module_expr -> unit - val enter_with_constraint : with_constraint -> unit - val enter_class_expr : class_expr -> unit - val enter_class_signature : class_signature -> unit - val enter_class_declaration : class_declaration -> unit - val enter_class_description : class_description -> unit - val enter_class_type_declaration : class_type_declaration -> unit - val enter_class_type : class_type -> unit - val enter_class_type_field : class_type_field -> unit - val enter_core_type : core_type -> unit - val enter_class_structure : class_structure -> unit - val enter_class_field : class_field -> unit - val enter_structure_item : structure_item -> unit +(* Print an extension declaration *) +let tree_of_extension_constructor id ext es = + reset (); + let ty_name = Path.name ext.ext_type_path in + let ty_params = filter_params ext.ext_type_params in + List.iter add_alias ty_params; + List.iter mark_loops ty_params; + List.iter check_name_of_type (List.map proxy ty_params); + mark_loops_constructor_arguments ext.ext_args; + may mark_loops ext.ext_ret_type; + let type_param = + function + | Otyp_var (_, id) -> id + | _ -> "?" + in + let ty_params = + List.map (fun ty -> type_param (tree_of_typexp false ty)) ty_params + in + let name = Ident.name id in + let args, ret = + match ext.ext_ret_type with + | None -> (tree_of_constructor_arguments ext.ext_args, None) + | Some res -> + let nm = !names in + names := []; + let ret = tree_of_typexp false res in + let args = tree_of_constructor_arguments ext.ext_args in + names := nm; + (args, Some ret) + in + let ext = + { oext_name = name; + oext_type_name = ty_name; + oext_type_params = ty_params; + oext_args = args; + oext_ret_type = ret; + oext_private = ext.ext_private } + in + let es = + match es with + Text_first -> Oext_first + | Text_next -> Oext_next + | Text_exception -> Oext_exception + in + Osig_typext (ext, es) - val leave_structure : structure -> unit - val leave_value_description : value_description -> unit - val leave_type_extension : type_extension -> unit - val leave_extension_constructor : extension_constructor -> unit - val leave_pattern : pattern -> unit - val leave_expression : expression -> unit - val leave_package_type : package_type -> unit - val leave_signature : signature -> unit - val leave_signature_item : signature_item -> unit - val leave_module_type_declaration : module_type_declaration -> unit - val leave_module_type : module_type -> unit - val leave_module_expr : module_expr -> unit - val leave_with_constraint : with_constraint -> unit - val leave_class_expr : class_expr -> unit - val leave_class_signature : class_signature -> unit - val leave_class_declaration : class_declaration -> unit - val leave_class_description : class_description -> unit - val leave_class_type_declaration : class_type_declaration -> unit - val leave_class_type : class_type -> unit - val leave_class_type_field : class_type_field -> unit - val leave_core_type : core_type -> unit - val leave_class_structure : class_structure -> unit - val leave_class_field : class_field -> unit - val leave_structure_item : structure_item -> unit +let extension_constructor id ppf ext = + !Oprint.out_sig_item ppf (tree_of_extension_constructor id ext Text_first) - val enter_bindings : rec_flag -> unit - val enter_binding : value_binding -> unit - val leave_binding : value_binding -> unit - val leave_bindings : rec_flag -> unit +(* Print a value declaration *) - val enter_type_declarations : rec_flag -> unit - val enter_type_declaration : type_declaration -> unit - val leave_type_declaration : type_declaration -> unit - val leave_type_declarations : rec_flag -> unit +let tree_of_value_description id decl = + (* Format.eprintf "@[%a@]@." raw_type_expr decl.val_type; *) + let id = Ident.name id in + let ty = tree_of_type_scheme decl.val_type in + let vd = + { oval_name = id; + oval_type = ty; + oval_prims = []; + oval_attributes = [] } + in + let vd = + match decl.val_kind with + | Val_prim p -> Primitive.print p vd + | _ -> vd + in + Osig_value vd -end +let value_description id ppf decl = + !Oprint.out_sig_item ppf (tree_of_value_description id decl) -module MakeIterator : - functor (Iter : IteratorArgument) -> - sig - val iter_structure : structure -> unit - val iter_signature : signature -> unit - val iter_structure_item : structure_item -> unit - val iter_signature_item : signature_item -> unit - val iter_expression : expression -> unit - val iter_module_type : module_type -> unit - val iter_pattern : pattern -> unit - val iter_class_expr : class_expr -> unit - end +(* Print a class type *) -module DefaultIteratorArgument : IteratorArgument +let method_type (_, kind, ty) = + match field_kind_repr kind, repr ty with + Fpresent, {desc=Tpoly(ty, tyl)} -> (ty, tyl) + | _ , ty -> (ty, []) -end = struct -#1 "typedtreeIter.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Thomas Gazagnaire (OCamlPro), Fabrice Le Fessant (INRIA Saclay) *) -(* *) -(* Copyright 2007 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let tree_of_metho sch concrete csil (lab, kind, ty) = + if lab <> dummy_method then begin + let kind = field_kind_repr kind in + let priv = kind <> Fpresent in + let virt = not (Concr.mem lab concrete) in + let (ty, tyl) = method_type (lab, kind, ty) in + let tty = tree_of_typexp sch ty in + remove_names tyl; + Ocsg_method (lab, priv, virt, tty) :: csil + end + else csil -(* -TODO: - - 2012/05/10: Follow camlp4 way of building map and iter using classes - and inheritance ? -*) +let rec prepare_class_type params = function + | Cty_constr (_p, tyl, cty) -> + let sty = Ctype.self_type cty in + if List.memq (proxy sty) !visited_objects + || not (List.for_all is_Tvar params) + || List.exists (deep_occur sty) tyl + then prepare_class_type params cty + else List.iter mark_loops tyl + | Cty_signature sign -> + let sty = repr sign.csig_self in + (* Self may have a name *) + let px = proxy sty in + if List.memq px !visited_objects then add_alias sty + else visited_objects := px :: !visited_objects; + let (fields, _) = + Ctype.flatten_fields (Ctype.object_fields sign.csig_self) + in + List.iter (fun met -> mark_loops (fst (method_type met))) fields; + Vars.iter (fun _ (_, _, ty) -> mark_loops ty) sign.csig_vars + | Cty_arrow (_, ty, cty) -> + mark_loops ty; + prepare_class_type params cty -open Asttypes -open Typedtree +let rec tree_of_class_type sch params = + function + | Cty_constr (p', tyl, cty) -> + let sty = Ctype.self_type cty in + if List.memq (proxy sty) !visited_objects + || not (List.for_all is_Tvar params) + then + tree_of_class_type sch params cty + else + Octy_constr (tree_of_path p', tree_of_typlist true tyl) + | Cty_signature sign -> + let sty = repr sign.csig_self in + let self_ty = + if is_aliased sty then + Some (Otyp_var (false, name_of_type new_name (proxy sty))) + else None + in + let (fields, _) = + Ctype.flatten_fields (Ctype.object_fields sign.csig_self) + in + let csil = [] in + let csil = + List.fold_left + (fun csil (ty1, ty2) -> Ocsg_constraint (ty1, ty2) :: csil) + csil (tree_of_constraints params) + in + let all_vars = + Vars.fold (fun l (m, v, t) all -> (l, m, v, t) :: all) sign.csig_vars [] + in + (* Consequence of PR#3607: order of Map.fold has changed! *) + let all_vars = List.rev all_vars in + let csil = + List.fold_left + (fun csil (l, m, v, t) -> + Ocsg_value (l, m = Mutable, v = Virtual, tree_of_typexp sch t) + :: csil) + csil all_vars + in + let csil = + List.fold_left (tree_of_metho sch sign.csig_concr) csil fields + in + Octy_signature (self_ty, List.rev csil) + | Cty_arrow (l, ty, cty) -> + let lab = + if !print_labels || is_optional l then string_of_label l else "" + in + let ty = + if is_optional l then + match (repr ty).desc with + | Tconstr(path, [ty], _) when Path.same path Predef.path_option -> ty + | _ -> newconstr (Path.Pident(Ident.create "")) [] + else ty in + let tr = tree_of_typexp sch ty in + Octy_arrow (lab, tr, tree_of_class_type sch params cty) -module type IteratorArgument = sig +let class_type ppf cty = + reset (); + prepare_class_type [] cty; + !Oprint.out_class_type ppf (tree_of_class_type false [] cty) - val enter_structure : structure -> unit - val enter_value_description : value_description -> unit - val enter_type_extension : type_extension -> unit - val enter_extension_constructor : extension_constructor -> unit - val enter_pattern : pattern -> unit - val enter_expression : expression -> unit - val enter_package_type : package_type -> unit - val enter_signature : signature -> unit - val enter_signature_item : signature_item -> unit - val enter_module_type_declaration : module_type_declaration -> unit - val enter_module_type : module_type -> unit - val enter_module_expr : module_expr -> unit - val enter_with_constraint : with_constraint -> unit - val enter_class_expr : class_expr -> unit - val enter_class_signature : class_signature -> unit - val enter_class_declaration : class_declaration -> unit - val enter_class_description : class_description -> unit - val enter_class_type_declaration : class_type_declaration -> unit - val enter_class_type : class_type -> unit - val enter_class_type_field : class_type_field -> unit - val enter_core_type : core_type -> unit - val enter_class_structure : class_structure -> unit - val enter_class_field : class_field -> unit - val enter_structure_item : structure_item -> unit +let tree_of_class_param param variance = + (match tree_of_typexp true param with + Otyp_var (_, s) -> s + | _ -> "?"), + if is_Tvar (repr param) then (true, true) else variance +let class_variance = + List.map Variance.(fun v -> mem May_pos v, mem May_neg v) - val leave_structure : structure -> unit - val leave_value_description : value_description -> unit - val leave_type_extension : type_extension -> unit - val leave_extension_constructor : extension_constructor -> unit - val leave_pattern : pattern -> unit - val leave_expression : expression -> unit - val leave_package_type : package_type -> unit - val leave_signature : signature -> unit - val leave_signature_item : signature_item -> unit - val leave_module_type_declaration : module_type_declaration -> unit - val leave_module_type : module_type -> unit - val leave_module_expr : module_expr -> unit - val leave_with_constraint : with_constraint -> unit - val leave_class_expr : class_expr -> unit - val leave_class_signature : class_signature -> unit - val leave_class_declaration : class_declaration -> unit - val leave_class_description : class_description -> unit - val leave_class_type_declaration : class_type_declaration -> unit - val leave_class_type : class_type -> unit - val leave_class_type_field : class_type_field -> unit - val leave_core_type : core_type -> unit - val leave_class_structure : class_structure -> unit - val leave_class_field : class_field -> unit - val leave_structure_item : structure_item -> unit +let tree_of_class_declaration id cl rs = + let params = filter_params cl.cty_params in - val enter_bindings : rec_flag -> unit - val enter_binding : value_binding -> unit - val leave_binding : value_binding -> unit - val leave_bindings : rec_flag -> unit + reset (); + List.iter add_alias params; + prepare_class_type params cl.cty_type; + let sty = Ctype.self_type cl.cty_type in + List.iter mark_loops params; - val enter_type_declarations : rec_flag -> unit - val enter_type_declaration : type_declaration -> unit - val leave_type_declaration : type_declaration -> unit - val leave_type_declarations : rec_flag -> unit + List.iter check_name_of_type (List.map proxy params); + if is_aliased sty then check_name_of_type (proxy sty); - end + let vir_flag = cl.cty_new = None in + Osig_class + (vir_flag, Ident.name id, + List.map2 tree_of_class_param params (class_variance cl.cty_variance), + tree_of_class_type true params cl.cty_type, + tree_of_rec rs) -module MakeIterator(Iter : IteratorArgument) : sig +let class_declaration id ppf cl = + !Oprint.out_sig_item ppf (tree_of_class_declaration id cl Trec_first) - val iter_structure : structure -> unit - val iter_signature : signature -> unit - val iter_structure_item : structure_item -> unit - val iter_signature_item : signature_item -> unit - val iter_expression : expression -> unit - val iter_module_type : module_type -> unit - val iter_pattern : pattern -> unit - val iter_class_expr : class_expr -> unit +let tree_of_cltype_declaration id cl rs = + let params = List.map repr cl.clty_params in - end = struct + reset (); + List.iter add_alias params; + prepare_class_type params cl.clty_type; + let sty = Ctype.self_type cl.clty_type in + List.iter mark_loops params; - let may_iter f v = - match v with - None -> () - | Some x -> f x + List.iter check_name_of_type (List.map proxy params); + if is_aliased sty then check_name_of_type (proxy sty); + let sign = Ctype.signature_of_class_type cl.clty_type in - let rec iter_structure str = - Iter.enter_structure str; - List.iter iter_structure_item str.str_items; - Iter.leave_structure str + let virt = + let (fields, _) = + Ctype.flatten_fields (Ctype.object_fields sign.csig_self) in + List.exists + (fun (lab, _, _) -> + not (lab = dummy_method || Concr.mem lab sign.csig_concr)) + fields + || Vars.fold (fun _ (_,vr,_) b -> vr = Virtual || b) sign.csig_vars false + in + Osig_class_type + (virt, Ident.name id, + List.map2 tree_of_class_param params (class_variance cl.clty_variance), + tree_of_class_type true params cl.clty_type, + tree_of_rec rs) - and iter_binding vb = - Iter.enter_binding vb; - iter_pattern vb.vb_pat; - iter_expression vb.vb_expr; - Iter.leave_binding vb +let cltype_declaration id ppf cl = + !Oprint.out_sig_item ppf (tree_of_cltype_declaration id cl Trec_first) - and iter_bindings rec_flag list = - Iter.enter_bindings rec_flag; - List.iter iter_binding list; - Iter.leave_bindings rec_flag +(* Print a module type *) - and iter_case {c_lhs; c_guard; c_rhs} = - iter_pattern c_lhs; - may_iter iter_expression c_guard; - iter_expression c_rhs +let wrap_env fenv ftree arg = + let env = !printing_env in + set_printing_env (fenv env); + let tree = ftree arg in + set_printing_env env; + tree - and iter_cases cases = - List.iter iter_case cases +let filter_rem_sig item rem = + match item, rem with + | Sig_class _, ctydecl :: tydecl1 :: tydecl2 :: rem -> + ([ctydecl; tydecl1; tydecl2], rem) + | Sig_class_type _, tydecl1 :: tydecl2 :: rem -> + ([tydecl1; tydecl2], rem) + | _ -> + ([], rem) - and iter_structure_item item = - Iter.enter_structure_item item; - begin - match item.str_desc with - Tstr_eval (exp, _attrs) -> iter_expression exp - | Tstr_value (rec_flag, list) -> - iter_bindings rec_flag list - | Tstr_primitive vd -> iter_value_description vd - | Tstr_type (rf, list) -> iter_type_declarations rf list - | Tstr_typext tyext -> iter_type_extension tyext - | Tstr_exception ext -> iter_extension_constructor ext - | Tstr_module x -> iter_module_binding x - | Tstr_recmodule list -> List.iter iter_module_binding list - | Tstr_modtype mtd -> iter_module_type_declaration mtd - | Tstr_open _ -> () - | Tstr_class list -> - List.iter (fun (ci, _) -> iter_class_declaration ci) list - | Tstr_class_type list -> - List.iter - (fun (_, _, ct) -> iter_class_type_declaration ct) - list - | Tstr_include incl -> iter_module_expr incl.incl_mod - | Tstr_attribute _ -> - () - end; - Iter.leave_structure_item item +let dummy = + { type_params = []; type_arity = 0; type_kind = Type_abstract; + type_private = Public; type_manifest = None; type_variance = []; + type_newtype_level = None; type_loc = Location.none; + type_attributes = []; + type_immediate = false; + type_unboxed = unboxed_false_default_false; + } - and iter_module_binding x = - iter_module_expr x.mb_expr +let hide_rec_items = function + | Sig_type(id, _decl, rs) ::rem + when rs = Trec_first && not !Clflags.real_paths -> + let rec get_ids = function + Sig_type (id, _, Trec_next) :: rem -> + id :: get_ids rem + | _ -> [] + in + let ids = id :: get_ids rem in + set_printing_env + (List.fold_right + (fun id -> Env.add_type ~check:false (Ident.rename id) dummy) + ids !printing_env) + | _ -> () - and iter_value_description v = - Iter.enter_value_description v; - iter_core_type v.val_desc; - Iter.leave_value_description v +let rec tree_of_modtype ?(ellipsis=false) = function + | Mty_ident p -> + Omty_ident (tree_of_path p) + | Mty_signature sg -> + Omty_signature (if ellipsis then [Osig_ellipsis] + else tree_of_signature sg) + | Mty_functor(param, ty_arg, ty_res) -> + let res = + match ty_arg with None -> tree_of_modtype ~ellipsis ty_res + | Some mty -> + wrap_env (Env.add_module ~arg:true param mty) + (tree_of_modtype ~ellipsis) ty_res + in + Omty_functor (Ident.name param, + may_map (tree_of_modtype ~ellipsis:false) ty_arg, res) + | Mty_alias(_, p) -> + Omty_alias (tree_of_path p) - and iter_constructor_arguments = function - | Cstr_tuple l -> List.iter iter_core_type l - | Cstr_record l -> List.iter (fun ld -> iter_core_type ld.ld_type) l +and tree_of_signature sg = + wrap_env (fun env -> env) (tree_of_signature_rec !printing_env false) sg - and iter_constructor_declaration cd = - iter_constructor_arguments cd.cd_args; - option iter_core_type cd.cd_res; +and tree_of_signature_rec env' in_type_group = function + [] -> [] + | item :: rem as items -> + let in_type_group = + match in_type_group, item with + true, Sig_type (_, _, Trec_next) -> true + | _, Sig_type (_, _, (Trec_not | Trec_first)) -> + set_printing_env env'; true + | _ -> set_printing_env env'; false + in + let (sg, rem) = filter_rem_sig item rem in + hide_rec_items items; + let trees = trees_of_sigitem item in + let env' = Env.add_signature (item :: sg) env' in + trees @ tree_of_signature_rec env' in_type_group rem - and iter_type_parameter (ct, _v) = - iter_core_type ct +and trees_of_sigitem = function + | Sig_value(id, decl) -> + [tree_of_value_description id decl] + | Sig_type(id, _, _) when is_row_name (Ident.name id) -> + [] + | Sig_type(id, decl, rs) -> + [tree_of_type_declaration id decl rs] + | Sig_typext(id, ext, es) -> + [tree_of_extension_constructor id ext es] + | Sig_module(id, md, rs) -> + let ellipsis = + List.exists (function ({txt="..."}, Parsetree.PStr []) -> true + | _ -> false) + md.md_attributes in + [tree_of_module id md.md_type rs ~ellipsis] + | Sig_modtype(id, decl) -> + [tree_of_modtype_declaration id decl] + | Sig_class(id, decl, rs) -> + [tree_of_class_declaration id decl rs] + | Sig_class_type(id, decl, rs) -> + [tree_of_cltype_declaration id decl rs] - and iter_type_declaration decl = - Iter.enter_type_declaration decl; - List.iter iter_type_parameter decl.typ_params; - List.iter (fun (ct1, ct2, _loc) -> - iter_core_type ct1; - iter_core_type ct2 - ) decl.typ_cstrs; - begin match decl.typ_kind with - Ttype_abstract -> () - | Ttype_variant list -> - List.iter iter_constructor_declaration list - | Ttype_record list -> - List.iter - (fun ld -> - iter_core_type ld.ld_type - ) list - | Ttype_open -> () - end; - option iter_core_type decl.typ_manifest; - Iter.leave_type_declaration decl +and tree_of_modtype_declaration id decl = + let mty = + match decl.mtd_type with + | None -> Omty_abstract + | Some mty -> tree_of_modtype mty + in + Osig_modtype (Ident.name id, mty) - and iter_type_declarations rec_flag decls = - Iter.enter_type_declarations rec_flag; - List.iter iter_type_declaration decls; - Iter.leave_type_declarations rec_flag +and tree_of_module id ?ellipsis mty rs = + Osig_module (Ident.name id, tree_of_modtype ?ellipsis mty, tree_of_rec rs) - and iter_extension_constructor ext = - Iter.enter_extension_constructor ext; - begin match ext.ext_kind with - Text_decl(args, ret) -> - iter_constructor_arguments args; - option iter_core_type ret - | Text_rebind _ -> () - end; - Iter.leave_extension_constructor ext; +let modtype ppf mty = !Oprint.out_module_type ppf (tree_of_modtype mty) +let modtype_declaration id ppf decl = + !Oprint.out_sig_item ppf (tree_of_modtype_declaration id decl) - and iter_type_extension tyext = - Iter.enter_type_extension tyext; - List.iter iter_type_parameter tyext.tyext_params; - List.iter iter_extension_constructor tyext.tyext_constructors; - Iter.leave_type_extension tyext +(* For the toplevel: merge with tree_of_signature? *) - and iter_pattern pat = - Iter.enter_pattern pat; - List.iter (fun (cstr, _, _attrs) -> match cstr with - | Tpat_type _ -> () - | Tpat_unpack -> () - | Tpat_open _ -> () - | Tpat_constraint ct -> iter_core_type ct) pat.pat_extra; +(* Refresh weak variable map in the toplevel *) +let refresh_weak () = + let refresh t name (m,s) = + if is_non_gen true (repr t) then begin - match pat.pat_desc with - Tpat_any -> () - | Tpat_var _ -> () - | Tpat_alias (pat1, _, _) -> iter_pattern pat1 - | Tpat_constant _ -> () - | Tpat_tuple list -> - List.iter iter_pattern list - | Tpat_construct (_, _, args) -> - List.iter iter_pattern args - | Tpat_variant (_, pato, _) -> - begin match pato with - None -> () - | Some pat -> iter_pattern pat - end - | Tpat_record (list, _closed) -> - List.iter (fun (_, _, pat) -> iter_pattern pat) list - | Tpat_array list -> List.iter iter_pattern list - | Tpat_or (p1, p2, _) -> iter_pattern p1; iter_pattern p2 - | Tpat_lazy p -> iter_pattern p - end; - Iter.leave_pattern pat + TypeMap.add t name m, + StringSet.add name s + end + else m, s in + let m, s = + TypeMap.fold refresh !weak_var_map (TypeMap.empty ,StringSet.empty) in + named_weak_vars := s; + weak_var_map := m - and option f x = match x with None -> () | Some e -> f e +let print_items showval env x = + refresh_weak(); + let rec print showval env = function + | [] -> [] + | item :: rem as items -> + let (_sg, rem) = filter_rem_sig item rem in + hide_rec_items items; + let trees = trees_of_sigitem item in + List.map (fun d -> (d, showval env item)) trees @ + print showval env rem in + print showval env x - and iter_expression exp = - Iter.enter_expression exp; - List.iter (function (cstr, _, _attrs) -> - match cstr with - Texp_constraint ct -> - iter_core_type ct - | Texp_coerce (cty1, cty2) -> - option iter_core_type cty1; iter_core_type cty2 - | Texp_open _ -> () - | Texp_poly cto -> option iter_core_type cto - | Texp_newtype _ -> ()) - exp.exp_extra; - begin - match exp.exp_desc with - Texp_ident _ -> () - | Texp_constant _ -> () - | Texp_let (rec_flag, list, exp) -> - iter_bindings rec_flag list; - iter_expression exp - | Texp_function { cases; _ } -> - iter_cases cases - | Texp_apply (exp, list) -> - iter_expression exp; - List.iter (fun (_label, expo) -> - match expo with - None -> () - | Some exp -> iter_expression exp - ) list - | Texp_match (exp, list1, list2, _) -> - iter_expression exp; - iter_cases list1; - iter_cases list2; - | Texp_try (exp, list) -> - iter_expression exp; - iter_cases list - | Texp_tuple list -> - List.iter iter_expression list - | Texp_construct (_, _, args) -> - List.iter iter_expression args - | Texp_variant (_label, expo) -> - begin match expo with - None -> () - | Some exp -> iter_expression exp - end - | Texp_record { fields; extended_expression; _ } -> - Array.iter (function - | _, Kept _ -> () - | _, Overridden (_, exp) -> iter_expression exp) - fields; - begin match extended_expression with - None -> () - | Some exp -> iter_expression exp - end - | Texp_field (exp, _, _label) -> - iter_expression exp - | Texp_setfield (exp1, _, _label, exp2) -> - iter_expression exp1; - iter_expression exp2 - | Texp_array list -> - List.iter iter_expression list - | Texp_ifthenelse (exp1, exp2, expo) -> - iter_expression exp1; - iter_expression exp2; - begin match expo with - None -> () - | Some exp -> iter_expression exp - end - | Texp_sequence (exp1, exp2) -> - iter_expression exp1; - iter_expression exp2 - | Texp_while (exp1, exp2) -> - iter_expression exp1; - iter_expression exp2 - | Texp_for (_id, _, exp1, exp2, _dir, exp3) -> - iter_expression exp1; - iter_expression exp2; - iter_expression exp3 - | Texp_send (exp, _meth, expo) -> - iter_expression exp; - begin - match expo with - None -> () - | Some exp -> iter_expression exp - end - | Texp_new _ -> () - | Texp_instvar _ -> () - | Texp_setinstvar (_, _, _, exp) -> - iter_expression exp - | Texp_override (_, list) -> - List.iter (fun (_path, _, exp) -> - iter_expression exp - ) list - | Texp_letmodule (_id, _, mexpr, exp) -> - iter_module_expr mexpr; - iter_expression exp - | Texp_letexception (cd, exp) -> - iter_extension_constructor cd; - iter_expression exp - | Texp_assert exp -> iter_expression exp - | Texp_lazy exp -> iter_expression exp - | Texp_object (cl, _) -> - iter_class_structure cl - | Texp_pack (mexpr) -> - iter_module_expr mexpr - | Texp_unreachable -> - () - | Texp_extension_constructor _ -> - () - end; - Iter.leave_expression exp; +(* Print a signature body (used by -i when compiling a .ml) *) - and iter_package_type pack = - Iter.enter_package_type pack; - List.iter (fun (_s, ct) -> iter_core_type ct) pack.pack_fields; - Iter.leave_package_type pack; +let print_signature ppf tree = + fprintf ppf "@[%a@]" !Oprint.out_signature tree - and iter_signature sg = - Iter.enter_signature sg; - List.iter iter_signature_item sg.sig_items; - Iter.leave_signature sg; +let signature ppf sg = + fprintf ppf "%a" print_signature (tree_of_signature sg) - and iter_signature_item item = - Iter.enter_signature_item item; - begin - match item.sig_desc with - Tsig_value vd -> - iter_value_description vd - | Tsig_type (rf, list) -> - iter_type_declarations rf list - | Tsig_exception ext -> - iter_extension_constructor ext - | Tsig_typext tyext -> - iter_type_extension tyext - | Tsig_module md -> - iter_module_type md.md_type - | Tsig_recmodule list -> - List.iter (fun md -> iter_module_type md.md_type) list - | Tsig_modtype mtd -> - iter_module_type_declaration mtd - | Tsig_open _ -> () - | Tsig_include incl -> iter_module_type incl.incl_mod - | Tsig_class list -> - List.iter iter_class_description list - | Tsig_class_type list -> - List.iter iter_class_type_declaration list - | Tsig_attribute _ -> () - end; - Iter.leave_signature_item item; +(* Print an unification error *) - and iter_module_type_declaration mtd = - Iter.enter_module_type_declaration mtd; - begin - match mtd.mtd_type with - | None -> () - | Some mtype -> iter_module_type mtype - end; - Iter.leave_module_type_declaration mtd +let same_path t t' = + let t = repr t and t' = repr t' in + t == t' || + match t.desc, t'.desc with + Tconstr(p,tl,_), Tconstr(p',tl',_) -> + let (p1, s1) = best_type_path p and (p2, s2) = best_type_path p' in + begin match s1, s2 with + Nth n1, Nth n2 when n1 = n2 -> true + | (Id | Map _), (Id | Map _) when Path.same p1 p2 -> + let tl = apply_subst s1 tl and tl' = apply_subst s2 tl' in + List.length tl = List.length tl' && + List.for_all2 same_type tl tl' + | _ -> false + end + | _ -> + false - and iter_class_declaration cd = - Iter.enter_class_declaration cd; - List.iter iter_type_parameter cd.ci_params; - iter_class_expr cd.ci_expr; - Iter.leave_class_declaration cd; +let type_expansion t ppf t' = + if same_path t t' + then begin add_delayed (proxy t); type_expr ppf t end + else + let t' = if proxy t == proxy t' then unalias t' else t' in + fprintf ppf "@[<2>%a@ =@ %a@]" type_expr t type_expr t' - and iter_class_description cd = - Iter.enter_class_description cd; - List.iter iter_type_parameter cd.ci_params; - iter_class_type cd.ci_expr; - Iter.leave_class_description cd; +let type_path_expansion tp ppf tp' = + if Path.same tp tp' then path ppf tp else + fprintf ppf "@[<2>%a@ =@ %a@]" path tp path tp' - and iter_class_type_declaration cd = - Iter.enter_class_type_declaration cd; - List.iter iter_type_parameter cd.ci_params; - iter_class_type cd.ci_expr; - Iter.leave_class_type_declaration cd; +let rec trace fst txt ppf = function + | (t1, t1') :: (t2, t2') :: rem -> + if not fst then fprintf ppf "@,"; + fprintf ppf "@[Type@;<1 2>%a@ %s@;<1 2>%a@] %a" + (type_expansion t1) t1' txt (type_expansion t2) t2' + (trace false txt) rem + | _ -> () - and iter_module_type mty = - Iter.enter_module_type mty; - begin - match mty.mty_desc with - Tmty_ident _ -> () - | Tmty_alias _ -> () - | Tmty_signature sg -> iter_signature sg - | Tmty_functor (_, _, mtype1, mtype2) -> - Misc.may iter_module_type mtype1; iter_module_type mtype2 - | Tmty_with (mtype, list) -> - iter_module_type mtype; - List.iter (fun (_path, _, withc) -> - iter_with_constraint withc - ) list - | Tmty_typeof mexpr -> - iter_module_expr mexpr - end; - Iter.leave_module_type mty; +let rec filter_trace keep_last = function + | (_, t1') :: (_, t2') :: [] when is_Tvar t1' || is_Tvar t2' -> + [] + | (t1, t1') :: (t2, t2') :: rem -> + let rem' = filter_trace keep_last rem in + if is_constr_row ~allow_ident:true t1' + || is_constr_row ~allow_ident:true t2' + || same_path t1 t1' && same_path t2 t2' && not (keep_last && rem' = []) + then rem' + else (t1, t1') :: (t2, t2') :: rem' + | _ -> [] - and iter_with_constraint cstr = - Iter.enter_with_constraint cstr; - begin - match cstr with - Twith_type decl -> iter_type_declaration decl - | Twith_module _ -> () - | Twith_typesubst decl -> iter_type_declaration decl - | Twith_modsubst _ -> () - end; - Iter.leave_with_constraint cstr; +let rec type_path_list ppf = function + | [tp, tp'] -> type_path_expansion tp ppf tp' + | (tp, tp') :: rem -> + fprintf ppf "%a@;<2 0>%a" + (type_path_expansion tp) tp' + type_path_list rem + | [] -> () - and iter_module_expr mexpr = - Iter.enter_module_expr mexpr; - begin - match mexpr.mod_desc with - Tmod_ident _ -> () - | Tmod_structure st -> iter_structure st - | Tmod_functor (_, _, mtype, mexpr) -> - Misc.may iter_module_type mtype; - iter_module_expr mexpr - | Tmod_apply (mexp1, mexp2, _) -> - iter_module_expr mexp1; - iter_module_expr mexp2 - | Tmod_constraint (mexpr, _, Tmodtype_implicit, _ ) -> - iter_module_expr mexpr - | Tmod_constraint (mexpr, _, Tmodtype_explicit mtype, _) -> - iter_module_expr mexpr; - iter_module_type mtype - | Tmod_unpack (exp, _mty) -> - iter_expression exp -(* iter_module_type mty *) - end; - Iter.leave_module_expr mexpr; +(* Hide variant name and var, to force printing the expanded type *) +let hide_variant_name t = + match repr t with + | {desc = Tvariant row} as t when (row_repr row).row_name <> None -> + newty2 t.level + (Tvariant {(row_repr row) with row_name = None; + row_more = newvar2 (row_more row).level}) + | _ -> t - and iter_class_expr cexpr = - Iter.enter_class_expr cexpr; - begin - match cexpr.cl_desc with - | Tcl_constraint (cl, None, _, _, _ ) -> - iter_class_expr cl; - | Tcl_structure clstr -> iter_class_structure clstr - | Tcl_fun (_label, pat, priv, cl, _partial) -> - iter_pattern pat; - List.iter (fun (_id, _, exp) -> iter_expression exp) priv; - iter_class_expr cl +let prepare_expansion (t, t') = + let t' = hide_variant_name t' in + mark_loops t; + if not (same_path t t') then mark_loops t'; + (t, t') - | Tcl_apply (cl, args) -> - iter_class_expr cl; - List.iter (fun (_label, expo) -> - match expo with - None -> () - | Some exp -> iter_expression exp - ) args +let may_prepare_expansion compact (t, t') = + match (repr t').desc with + Tvariant _ | Tobject _ when compact -> + mark_loops t; (t, t) + | _ -> prepare_expansion (t, t') - | Tcl_let (rec_flat, bindings, ivars, cl) -> - iter_bindings rec_flat bindings; - List.iter (fun (_id, _, exp) -> iter_expression exp) ivars; - iter_class_expr cl +let print_tags ppf fields = + match fields with [] -> () + | (t, _) :: fields -> + fprintf ppf "`%s" t; + List.iter (fun (t, _) -> fprintf ppf ",@ `%s" t) fields - | Tcl_constraint (cl, Some clty, _vals, _meths, _concrs) -> - iter_class_expr cl; - iter_class_type clty +let has_explanation t3 t4 = + match t3.desc, t4.desc with + Tfield _, (Tnil|Tconstr _) | (Tnil|Tconstr _), Tfield _ + | Tnil, Tconstr _ | Tconstr _, Tnil + | _, Tvar _ | Tvar _, _ + | Tvariant _, Tvariant _ -> true + | Tfield (l,_,_,{desc=Tnil}), Tfield (l',_,_,{desc=Tnil}) -> l = l' + | _ -> false - | Tcl_ident (_, _, tyl) -> - List.iter iter_core_type tyl +let rec mismatch = function + (_, t) :: (_, t') :: rem -> + begin match mismatch rem with + Some _ as m -> m + | None -> + if has_explanation t t' then Some(t,t') else None + end + | [] -> None + | _ -> assert false - | Tcl_open (_, _, _, _, e) -> - iter_class_expr e - end; - Iter.leave_class_expr cexpr; +let explanation unif t3 t4 ppf = + match t3.desc, t4.desc with + | Ttuple [], Tvar _ | Tvar _, Ttuple [] -> + fprintf ppf "@,Self type cannot escape its class" + | Tconstr (p, _, _), Tvar _ + when unif && t4.level < Path.binding_time p -> + fprintf ppf + "@,@[The type constructor@;<1 2>%a@ would escape its scope@]" + path p + | Tvar _, Tconstr (p, _, _) + when unif && t3.level < Path.binding_time p -> + fprintf ppf + "@,@[The type constructor@;<1 2>%a@ would escape its scope@]" + path p + | Tvar _, Tunivar _ | Tunivar _, Tvar _ -> + fprintf ppf "@,The universal variable %a would escape its scope" + type_expr (if is_Tunivar t3 then t3 else t4) + | Tvar _, _ | _, Tvar _ -> + let t, t' = if is_Tvar t3 then (t3, t4) else (t4, t3) in + if occur_in Env.empty t t' then + fprintf ppf "@,@[The type variable %a occurs inside@ %a@]" + type_expr t type_expr t' + else + fprintf ppf "@,@[This instance of %a is ambiguous:@ %s@]" + type_expr t' + "it would escape the scope of its equation" + | Tfield (lab, _, _, _), _ when lab = dummy_method -> + fprintf ppf + "@,Self type cannot be unified with a closed object type" + | _, Tfield (lab, _, _, _) when lab = dummy_method -> + fprintf ppf + "@,Self type cannot be unified with a closed object type" + | Tfield (l,_,_,{desc=Tnil}), Tfield (l',_,_,{desc=Tnil}) when l = l' -> + fprintf ppf "@,Types for method %s are incompatible" l + | (Tnil|Tconstr _), Tfield (l, _, _, _) -> + fprintf ppf + "@,@[The first object type has no method %s@]" l + | Tfield (l, _, _, _), (Tnil|Tconstr _) -> + fprintf ppf + "@,@[The second object type has no method %s@]" l + | Tnil, Tconstr _ | Tconstr _, Tnil -> + fprintf ppf + "@,@[The %s object type has an abstract row, it cannot be closed@]" + (if t4.desc = Tnil then "first" else "second") + | Tvariant row1, Tvariant row2 -> + let row1 = row_repr row1 and row2 = row_repr row2 in + begin match + row1.row_fields, row1.row_closed, row2.row_fields, row2.row_closed with + | [], true, [], true -> + fprintf ppf "@,These two variant types have no intersection" + | [], true, (_::_ as fields), _ -> + fprintf ppf + "@,@[The first variant type does not allow tag(s)@ @[%a@]@]" + print_tags fields + | (_::_ as fields), _, [], true -> + fprintf ppf + "@,@[The second variant type does not allow tag(s)@ @[%a@]@]" + print_tags fields + | [l1,_], true, [l2,_], true when l1 = l2 -> + fprintf ppf "@,Types for tag `%s are incompatible" l1 + | _ -> () + end + | _ -> () - and iter_class_type ct = - Iter.enter_class_type ct; - begin - match ct.cltyp_desc with - Tcty_signature csg -> iter_class_signature csg - | Tcty_constr (_path, _, list) -> - List.iter iter_core_type list - | Tcty_arrow (_label, ct, cl) -> - iter_core_type ct; - iter_class_type cl - | Tcty_open (_, _, _, _, e) -> - iter_class_type e - end; - Iter.leave_class_type ct; - and iter_class_signature cs = - Iter.enter_class_signature cs; - iter_core_type cs.csig_self; - List.iter iter_class_type_field cs.csig_fields; - Iter.leave_class_signature cs +let warn_on_missing_def env ppf t = + match t.desc with + | Tconstr (p,_,_) -> + begin + try + ignore(Env.find_type p env : Types.type_declaration) + with Not_found -> + fprintf ppf + "@,@[%a is abstract because no corresponding cmi file was found \ + in path.@]" path p + end + | _ -> () + +let explanation unif mis ppf = + match mis with + None -> () + | Some (t3, t4) -> explanation unif t3 t4 ppf +let ident_same_name id1 id2 = + if Ident.equal id1 id2 && not (Ident.same id1 id2) then begin + add_unique id1; add_unique id2 + end - and iter_class_type_field ctf = - Iter.enter_class_type_field ctf; - begin - match ctf.ctf_desc with - Tctf_inherit ct -> iter_class_type ct - | Tctf_val (_s, _mut, _virt, ct) -> - iter_core_type ct - | Tctf_method (_s, _priv, _virt, ct) -> - iter_core_type ct - | Tctf_constraint (ct1, ct2) -> - iter_core_type ct1; - iter_core_type ct2 - | Tctf_attribute _ -> () - end; - Iter.leave_class_type_field ctf +let rec path_same_name p1 p2 = + match p1, p2 with + Pident id1, Pident id2 -> ident_same_name id1 id2 + | Pdot (p1, s1, _), Pdot (p2, s2, _) when s1 = s2 -> path_same_name p1 p2 + | Papply (p1, p1'), Papply (p2, p2') -> + path_same_name p1 p2; path_same_name p1' p2' + | _ -> () - and iter_core_type ct = - Iter.enter_core_type ct; - begin - match ct.ctyp_desc with - Ttyp_any -> () - | Ttyp_var _ -> () - | Ttyp_arrow (_label, ct1, ct2) -> - iter_core_type ct1; - iter_core_type ct2 - | Ttyp_tuple list -> List.iter iter_core_type list - | Ttyp_constr (_path, _, list) -> - List.iter iter_core_type list - | Ttyp_object (list, _o) -> - List.iter iter_object_field list - | Ttyp_class (_path, _, list) -> - List.iter iter_core_type list - | Ttyp_alias (ct, _s) -> - iter_core_type ct - | Ttyp_variant (list, _bool, _labels) -> - List.iter iter_row_field list - | Ttyp_poly (_list, ct) -> iter_core_type ct - | Ttyp_package pack -> iter_package_type pack - end; - Iter.leave_core_type ct +let type_same_name t1 t2 = + match (repr t1).desc, (repr t2).desc with + Tconstr (p1, _, _), Tconstr (p2, _, _) -> + path_same_name (fst (best_type_path p1)) (fst (best_type_path p2)) + | _ -> () - and iter_class_structure cs = - Iter.enter_class_structure cs; - iter_pattern cs.cstr_self; - List.iter iter_class_field cs.cstr_fields; - Iter.leave_class_structure cs; +let rec trace_same_names = function + (t1, t1') :: (t2, t2') :: rem -> + type_same_name t1 t2; type_same_name t1' t2'; trace_same_names rem + | _ -> () +let unification_error env unif tr txt1 ppf txt2 = + reset (); + trace_same_names tr; + let tr = List.map (fun (t, t') -> (t, hide_variant_name t')) tr in + let mis = mismatch tr in + match tr with + | [] | _ :: [] -> assert false + | t1 :: t2 :: tr -> + try + let tr = filter_trace (mis = None) tr in + let t1, t1' = may_prepare_expansion (tr = []) t1 + and t2, t2' = may_prepare_expansion (tr = []) t2 in + print_labels := not !Clflags.classic; + let tr = List.map prepare_expansion tr in + fprintf ppf + "@[\ + @[%t@;<1 2>%a@ \ + %t@;<1 2>%a\ + @]%a%t\ + @]" + txt1 (type_expansion t1) t1' + txt2 (type_expansion t2) t2' + (trace false "is not compatible with type") tr + (explanation unif mis); + if env <> Env.empty + then begin + warn_on_missing_def env ppf t1; + warn_on_missing_def env ppf t2 + end; + print_labels := true + with exn -> + print_labels := true; + raise exn - and iter_row_field rf = - match rf with - Ttag (_label, _attrs, _bool, list) -> - List.iter iter_core_type list - | Tinherit ct -> iter_core_type ct +let report_unification_error ppf env ?(unif=true) + tr txt1 txt2 = + wrap_printing_env env (fun () -> unification_error env unif tr txt1 ppf txt2) +;; - and iter_object_field ofield = - match ofield with - OTtag (_, _, ct) | OTinherit ct -> iter_core_type ct - and iter_class_field cf = - Iter.enter_class_field cf; - begin - match cf.cf_desc with - Tcf_inherit (_ovf, cl, _super, _vals, _meths) -> - iter_class_expr cl - | Tcf_constraint (cty, cty') -> - iter_core_type cty; - iter_core_type cty' - | Tcf_val (_lab, _, _, Tcfk_virtual cty, _) -> - iter_core_type cty - | Tcf_val (_lab, _, _, Tcfk_concrete (_, exp), _) -> - iter_expression exp - | Tcf_method (_lab, _, Tcfk_virtual cty) -> - iter_core_type cty - | Tcf_method (_lab, _, Tcfk_concrete (_, exp)) -> - iter_expression exp - | Tcf_initializer exp -> - iter_expression exp - | Tcf_attribute _ -> () - end; - Iter.leave_class_field cf; +let super_type_expansion ~tag t ppf t' = + if same_path t t' then begin + Format.pp_open_tag ppf tag; + type_expr ppf t; + Format.pp_close_tag ppf (); + end else begin + let t' = if proxy t == proxy t' then unalias t' else t' in + fprintf ppf "@[<2>"; + Format.pp_open_tag ppf tag; + fprintf ppf "%a" type_expr t; + Format.pp_close_tag ppf (); + fprintf ppf "@ @{(defined as@}@ "; + Format.pp_open_tag ppf tag; + fprintf ppf "%a" type_expr t'; + Format.pp_close_tag ppf (); + fprintf ppf "@{)@}"; + fprintf ppf "@]"; end -module DefaultIteratorArgument = struct +let super_trace ppf = + let rec super_trace first_report ppf = function + | (t1, t1') :: (t2, t2') :: rem -> + fprintf ppf + "@,@,@["; + if first_report then + fprintf ppf "The incompatible parts:@," + else begin + fprintf ppf "Further expanded:@," + end; + fprintf ppf + "@[\ + @[%a@]@,\ + vs@,\ + @[%a@]\ + %a\ + @]" + (super_type_expansion ~tag:"error" t1) t1' + (super_type_expansion ~tag:"info" t2) t2' + (super_trace false) rem; + fprintf ppf "@]" + | _ -> () + in super_trace true ppf - let enter_structure _ = () - let enter_value_description _ = () - let enter_type_extension _ = () - let enter_extension_constructor _ = () - let enter_pattern _ = () - let enter_expression _ = () - let enter_package_type _ = () - let enter_signature _ = () - let enter_signature_item _ = () - let enter_module_type_declaration _ = () - let enter_module_type _ = () - let enter_module_expr _ = () - let enter_with_constraint _ = () - let enter_class_expr _ = () - let enter_class_signature _ = () - let enter_class_declaration _ = () - let enter_class_description _ = () - let enter_class_type_declaration _ = () - let enter_class_type _ = () - let enter_class_type_field _ = () - let enter_core_type _ = () - let enter_class_structure _ = () - let enter_class_field _ = () - let enter_structure_item _ = () +let super_unification_error unif tr txt1 ppf txt2 = begin + reset (); + trace_same_names tr; + let tr = List.map (fun (t, t') -> (t, hide_variant_name t')) tr in + let mis = mismatch tr in + match tr with + | [] | _ :: [] -> assert false + | t1 :: t2 :: tr -> + try + let tr = filter_trace (mis = None) tr in + let t1, t1' = may_prepare_expansion (tr = []) t1 + and t2, t2' = may_prepare_expansion (tr = []) t2 in + print_labels := not !Clflags.classic; + let tr = List.map prepare_expansion tr in + fprintf ppf + "@[\ + @[\ + %t@,\ + @[<2>%a@]\ + @]@,\ + @[\ + %t@,\ + @[<2>%a@]\ + @]\ + %a\ + %t\ + @]" + txt1 (super_type_expansion ~tag:"error" t1) t1' + txt2 (super_type_expansion ~tag:"info" t2) t2' + super_trace tr + (explanation unif mis); + print_labels := true + with exn -> + print_labels := true; + raise exn +end +let super_report_unification_error ppf env ?(unif=true) + tr txt1 txt2 = + wrap_printing_env env (fun () -> super_unification_error unif tr txt1 ppf txt2) +;; - let leave_structure _ = () - let leave_value_description _ = () - let leave_type_extension _ = () - let leave_extension_constructor _ = () - let leave_pattern _ = () - let leave_expression _ = () - let leave_package_type _ = () - let leave_signature _ = () - let leave_signature_item _ = () - let leave_module_type_declaration _ = () - let leave_module_type _ = () - let leave_module_expr _ = () - let leave_with_constraint _ = () - let leave_class_expr _ = () - let leave_class_signature _ = () - let leave_class_declaration _ = () - let leave_class_description _ = () - let leave_class_type_declaration _ = () - let leave_class_type _ = () - let leave_class_type_field _ = () - let leave_core_type _ = () - let leave_class_structure _ = () - let leave_class_field _ = () - let leave_structure_item _ = () - let enter_binding _ = () - let leave_binding _ = () +let trace fst keep_last txt ppf tr = + print_labels := not !Clflags.classic; + trace_same_names tr; + try match tr with + t1 :: t2 :: tr' -> + if fst then trace fst txt ppf (t1 :: t2 :: filter_trace keep_last tr') + else trace fst txt ppf (filter_trace keep_last tr); + print_labels := true + | _ -> () + with exn -> + print_labels := true; + raise exn - let enter_bindings _ = () - let leave_bindings _ = () +let report_subtyping_error ppf env tr1 txt1 tr2 = + wrap_printing_env env (fun () -> + reset (); + let tr1 = List.map prepare_expansion tr1 + and tr2 = List.map prepare_expansion tr2 in + fprintf ppf "@[%a" (trace true (tr2 = []) txt1) tr1; + if tr2 = [] then fprintf ppf "@]" else + let mis = mismatch tr2 in + fprintf ppf "%a%t@]" + (trace false (mis = None) "is not compatible with type") tr2 + (explanation true mis)) - let enter_type_declaration _ = () - let leave_type_declaration _ = () +let report_ambiguous_type_error ppf env (tp0, tp0') tpl txt1 txt2 txt3 = + wrap_printing_env env (fun () -> + reset (); + List.iter + (fun (tp, tp') -> path_same_name tp0 tp; path_same_name tp0' tp') + tpl; + match tpl with + [] -> assert false + | [tp, tp'] -> + fprintf ppf + "@[%t@;<1 2>%a@ \ + %t@;<1 2>%a\ + @]" + txt1 (type_path_expansion tp) tp' + txt3 (type_path_expansion tp0) tp0' + | _ -> + fprintf ppf + "@[%t@;<1 2>@[%a@]\ + @ %t@;<1 2>%a\ + @]" + txt2 type_path_list tpl + txt3 (type_path_expansion tp0) tp0') - let enter_type_declarations _ = () - let leave_type_declarations _ = () end +module Includeclass : sig +#1 "includeclass.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Jerome Vouillon, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1997 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -end -module Untypeast : sig -#1 "untypeast.mli" +(* Inclusion checks for the class language *) + +open Types +open Ctype +open Format + +val class_types: + Env.t -> class_type -> class_type -> class_match_failure list +val class_type_declarations: + loc:Location.t -> + Env.t -> class_type_declaration -> class_type_declaration -> + class_match_failure list +val class_declarations: + Env.t -> class_declaration -> class_declaration -> + class_match_failure list + +val report_error: formatter -> class_match_failure list -> unit + +end = struct +#1 "includeclass.ml" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Thomas Gazagnaire (OCamlPro), Fabrice Le Fessant (INRIA Saclay) *) +(* Jerome Vouillon, projet Cristal, INRIA Rocquencourt *) (* *) -(* Copyright 2007 Institut National de Recherche en Informatique et *) +(* Copyright 1997 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -66706,80 +65245,118 @@ module Untypeast : sig (* *) (**************************************************************************) -open Parsetree +(* Inclusion checks for the class language *) -val lident_of_path : Path.t -> Longident.t +open Types -type mapper = { - attribute: mapper -> Typedtree.attribute -> attribute; - attributes: mapper -> Typedtree.attribute list -> attribute list; - case: mapper -> Typedtree.case -> case; - cases: mapper -> Typedtree.case list -> case list; - class_declaration: mapper -> Typedtree.class_declaration -> class_declaration; - class_description: mapper -> Typedtree.class_description -> class_description; - class_expr: mapper -> Typedtree.class_expr -> class_expr; - class_field: mapper -> Typedtree.class_field -> class_field; - class_signature: mapper -> Typedtree.class_signature -> class_signature; - class_structure: mapper -> Typedtree.class_structure -> class_structure; - class_type: mapper -> Typedtree.class_type -> class_type; - class_type_declaration: mapper -> Typedtree.class_type_declaration - -> class_type_declaration; - class_type_field: mapper -> Typedtree.class_type_field -> class_type_field; - constructor_declaration: mapper -> Typedtree.constructor_declaration - -> constructor_declaration; - expr: mapper -> Typedtree.expression -> expression; - extension_constructor: mapper -> Typedtree.extension_constructor - -> extension_constructor; - include_declaration: - mapper -> Typedtree.include_declaration -> include_declaration; - include_description: - mapper -> Typedtree.include_description -> include_description; - label_declaration: - mapper -> Typedtree.label_declaration -> label_declaration; - location: mapper -> Location.t -> Location.t; - module_binding: mapper -> Typedtree.module_binding -> module_binding; - module_declaration: - mapper -> Typedtree.module_declaration -> module_declaration; - module_expr: mapper -> Typedtree.module_expr -> module_expr; - module_type: mapper -> Typedtree.module_type -> module_type; - module_type_declaration: - mapper -> Typedtree.module_type_declaration -> module_type_declaration; - package_type: mapper -> Typedtree.package_type -> package_type; - open_description: mapper -> Typedtree.open_description -> open_description; - pat: mapper -> Typedtree.pattern -> pattern; - row_field: mapper -> Typedtree.row_field -> row_field; - object_field: mapper -> Typedtree.object_field -> object_field; - signature: mapper -> Typedtree.signature -> signature; - signature_item: mapper -> Typedtree.signature_item -> signature_item; - structure: mapper -> Typedtree.structure -> structure; - structure_item: mapper -> Typedtree.structure_item -> structure_item; - typ: mapper -> Typedtree.core_type -> core_type; - type_declaration: mapper -> Typedtree.type_declaration -> type_declaration; - type_extension: mapper -> Typedtree.type_extension -> type_extension; - type_kind: mapper -> Typedtree.type_kind -> type_kind; - value_binding: mapper -> Typedtree.value_binding -> value_binding; - value_description: mapper -> Typedtree.value_description -> value_description; - with_constraint: - mapper -> (Path.t * Longident.t Location.loc * Typedtree.with_constraint) - -> with_constraint; -} +let class_types env cty1 cty2 = + Ctype.match_class_types env cty1 cty2 -val default_mapper : mapper +let class_type_declarations ~loc env cty1 cty2 = + Builtin_attributes.check_deprecated_inclusion + ~def:cty1.clty_loc + ~use:cty2.clty_loc + loc + cty1.clty_attributes cty2.clty_attributes + (Path.last cty1.clty_path); + Ctype.match_class_declarations env + cty1.clty_params cty1.clty_type + cty2.clty_params cty2.clty_type -val untype_structure : ?mapper:mapper -> Typedtree.structure -> structure -val untype_signature : ?mapper:mapper -> Typedtree.signature -> signature +let class_declarations env cty1 cty2 = + match cty1.cty_new, cty2.cty_new with + None, Some _ -> + [Ctype.CM_Virtual_class] + | _ -> + Ctype.match_class_declarations env + cty1.cty_params cty1.cty_type + cty2.cty_params cty2.cty_type + +open Format +open Ctype + +(* +let rec hide_params = function + Tcty_arrow ("*", _, cty) -> hide_params cty + | cty -> cty +*) + +let include_err ppf = + function + | CM_Virtual_class -> + fprintf ppf "A class cannot be changed from virtual to concrete" + | CM_Parameter_arity_mismatch _ -> + fprintf ppf + "The classes do not have the same number of type parameters" + | CM_Type_parameter_mismatch (env, trace) -> + Printtyp.report_unification_error ppf env ~unif:false trace + (function ppf -> + fprintf ppf "A type parameter has type") + (function ppf -> + fprintf ppf "but is expected to have type") + | CM_Class_type_mismatch (env, cty1, cty2) -> + Printtyp.wrap_printing_env env (fun () -> + fprintf ppf + "@[The class type@;<1 2>%a@ %s@;<1 2>%a@]" + Printtyp.class_type cty1 + "is not matched by the class type" + Printtyp.class_type cty2) + | CM_Parameter_mismatch (env, trace) -> + Printtyp.report_unification_error ppf env ~unif:false trace + (function ppf -> + fprintf ppf "A parameter has type") + (function ppf -> + fprintf ppf "but is expected to have type") + | CM_Val_type_mismatch (lab, env, trace) -> + Printtyp.report_unification_error ppf env ~unif:false trace + (function ppf -> + fprintf ppf "The instance variable %s@ has type" lab) + (function ppf -> + fprintf ppf "but is expected to have type") + | CM_Meth_type_mismatch (lab, env, trace) -> + Printtyp.report_unification_error ppf env ~unif:false trace + (function ppf -> + fprintf ppf "The method %s@ has type" lab) + (function ppf -> + fprintf ppf "but is expected to have type") + | CM_Non_mutable_value lab -> + fprintf ppf + "@[The non-mutable instance variable %s cannot become mutable@]" lab + | CM_Non_concrete_value lab -> + fprintf ppf + "@[The virtual instance variable %s cannot become concrete@]" lab + | CM_Missing_value lab -> + fprintf ppf "@[The first class type has no instance variable %s@]" lab + | CM_Missing_method lab -> + fprintf ppf "@[The first class type has no method %s@]" lab + | CM_Hide_public lab -> + fprintf ppf "@[The public method %s cannot be hidden@]" lab + | CM_Hide_virtual (k, lab) -> + fprintf ppf "@[The virtual %s %s cannot be hidden@]" k lab + | CM_Public_method lab -> + fprintf ppf "@[The public method %s cannot become private" lab + | CM_Virtual_method lab -> + fprintf ppf "@[The virtual method %s cannot become concrete" lab + | CM_Private_method lab -> + fprintf ppf "The private method %s cannot become public" lab -val constant : Asttypes.constant -> Parsetree.constant +let report_error ppf = function + | [] -> () + | err :: errs -> + let print_errs ppf errs = + List.iter (fun err -> fprintf ppf "@ %a" include_err err) errs in + fprintf ppf "@[%a%a@]" include_err err print_errs errs -end = struct -#1 "untypeast.ml" +end +module Includecore : sig +#1 "includecore.mli" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Thomas Gazagnaire (OCamlPro), Fabrice Le Fessant (INRIA Saclay) *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) (* *) -(* Copyright 2007 Institut National de Recherche en Informatique et *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -66788,819 +65365,918 @@ end = struct (* *) (**************************************************************************) -open Longident -open Asttypes -open Parsetree -open Ast_helper +(* Inclusion checks for the core language *) -module T = Typedtree +open Typedtree +open Types -type mapper = { - attribute: mapper -> T.attribute -> attribute; - attributes: mapper -> T.attribute list -> attribute list; - case: mapper -> T.case -> case; - cases: mapper -> T.case list -> case list; - class_declaration: mapper -> T.class_declaration -> class_declaration; - class_description: mapper -> T.class_description -> class_description; - class_expr: mapper -> T.class_expr -> class_expr; - class_field: mapper -> T.class_field -> class_field; - class_signature: mapper -> T.class_signature -> class_signature; - class_structure: mapper -> T.class_structure -> class_structure; - class_type: mapper -> T.class_type -> class_type; - class_type_declaration: mapper -> T.class_type_declaration - -> class_type_declaration; - class_type_field: mapper -> T.class_type_field -> class_type_field; - constructor_declaration: mapper -> T.constructor_declaration - -> constructor_declaration; - expr: mapper -> T.expression -> expression; - extension_constructor: mapper -> T.extension_constructor - -> extension_constructor; - include_declaration: mapper -> T.include_declaration -> include_declaration; - include_description: mapper -> T.include_description -> include_description; - label_declaration: mapper -> T.label_declaration -> label_declaration; - location: mapper -> Location.t -> Location.t; - module_binding: mapper -> T.module_binding -> module_binding; - module_declaration: mapper -> T.module_declaration -> module_declaration; - module_expr: mapper -> T.module_expr -> module_expr; - module_type: mapper -> T.module_type -> module_type; - module_type_declaration: - mapper -> T.module_type_declaration -> module_type_declaration; - package_type: mapper -> T.package_type -> package_type; - open_description: mapper -> T.open_description -> open_description; - pat: mapper -> T.pattern -> pattern; - row_field: mapper -> T.row_field -> row_field; - object_field: mapper -> T.object_field -> object_field; - signature: mapper -> T.signature -> signature; - signature_item: mapper -> T.signature_item -> signature_item; - structure: mapper -> T.structure -> structure; - structure_item: mapper -> T.structure_item -> structure_item; - typ: mapper -> T.core_type -> core_type; - type_declaration: mapper -> T.type_declaration -> type_declaration; - type_extension: mapper -> T.type_extension -> type_extension; - type_kind: mapper -> T.type_kind -> type_kind; - value_binding: mapper -> T.value_binding -> value_binding; - value_description: mapper -> T.value_description -> value_description; - with_constraint: - mapper -> (Path.t * Longident.t Location.loc * T.with_constraint) - -> with_constraint; -} +exception Dont_match -open T +type type_mismatch = + Arity + | Privacy + | Kind + | Constraint + | Manifest + | Variance + | Field_type of Ident.t + | Field_mutable of Ident.t + | Field_arity of Ident.t + | Field_names of int * string * string + | Field_missing of bool * Ident.t + | Record_representation of bool + | Unboxed_representation of bool + | Immediate + +val value_descriptions: + loc:Location.t -> Env.t -> Ident.t -> + value_description -> value_description -> module_coercion +val type_declarations: + ?equality:bool -> + loc:Location.t -> + Env.t -> string -> + type_declaration -> Ident.t -> type_declaration -> type_mismatch list + +val extension_constructors: + loc:Location.t -> + Env.t -> Ident.t -> + extension_constructor -> extension_constructor -> bool (* -Some notes: +val class_types: + Env.t -> class_type -> class_type -> bool +*) - * For Pexp_function, we cannot go back to the exact original version - when there is a default argument, because the default argument is - translated in the typer. The code, if printed, will not be parsable because - new generated identifiers are not correct. +val report_type_mismatch: + string -> string -> string -> Format.formatter -> type_mismatch list -> unit - * For Pexp_apply, it is unclear whether arguments are reordered, especially - when there are optional arguments. +end = struct +#1 "includecore.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -*) +(* Inclusion checks for the core language *) +open Asttypes +open Path +open Types +open Typedtree -(** Utility functions. *) +(* Inclusion between value descriptions *) -let string_is_prefix sub str = - let sublen = String.length sub in - String.length str >= sublen && String.sub str 0 sublen = sub +exception Dont_match -let map_opt f = function None -> None | Some e -> Some (f e) +let value_descriptions ~loc env name + (vd1 : Types.value_description) + (vd2 : Types.value_description) = + Builtin_attributes.check_deprecated_inclusion + ~def:vd1.val_loc + ~use:vd2.val_loc + loc + vd1.val_attributes vd2.val_attributes -let rec lident_of_path = function - | Path.Pident id -> Longident.Lident (Ident.name id) - | Path.Pdot (p, s, _) -> Longident.Ldot (lident_of_path p, s) - | Path.Papply (p1, p2) -> - Longident.Lapply (lident_of_path p1, lident_of_path p2) + (Ident.name name); + + if Ctype.moregeneral env true vd1.val_type vd2.val_type then begin + match (vd1.val_kind, vd2.val_kind) with + (Val_prim p1, Val_prim p2) -> + if p1 = p2 then Tcoerce_none else raise Dont_match + | (Val_prim p, _) -> + let pc = {pc_desc = p; pc_type = vd2.Types.val_type; + pc_env = env; pc_loc = vd1.Types.val_loc; -let map_loc sub {loc; txt} = {loc = sub.location sub loc; txt} + pc_id = name; -(** Try a name [$name$0], check if it's free, if not, increment and repeat. *) -let fresh_name s env = - let rec aux i = - let name = s ^ string_of_int i in - try - let _ = Env.lookup_value (Lident name) env in - name - with - | Not_found -> aux (i+1) - in - aux 0 + } in + Tcoerce_primitive pc + | (_, Val_prim _) -> raise Dont_match + | (_, _) -> Tcoerce_none + end else + raise Dont_match -(** Mapping functions. *) +(* Inclusion between "private" annotations *) -let constant = function - | Const_char c -> Pconst_char c - | Const_string (s,d) -> Pconst_string (s,d) - | Const_int i -> Pconst_integer (string_of_int i, None) - | Const_int32 i -> Pconst_integer (Int32.to_string i, Some 'l') - | Const_int64 i -> Pconst_integer (Int64.to_string i, Some 'L') - | Const_nativeint i -> Pconst_integer (Nativeint.to_string i, Some 'n') - | Const_float f -> Pconst_float (f,None) +let private_flags decl1 decl2 = + match decl1.type_private, decl2.type_private with + | Private, Public -> + decl2.type_kind = Type_abstract && + (decl2.type_manifest = None || decl1.type_kind <> Type_abstract) + | _, _ -> true -let attribute sub (s, p) = (map_loc sub s, p) -let attributes sub l = List.map (sub.attribute sub) l +(* Inclusion between manifest types (particularly for private row types) *) -let structure sub str = - List.map (sub.structure_item sub) str.str_items +let is_absrow env ty = + match ty.desc with + Tconstr(Pident _, _, _) -> + begin match Ctype.expand_head env ty with + {desc=Tobject _|Tvariant _} -> true + | _ -> false + end + | _ -> false -let open_description sub od = - let loc = sub.location sub od.open_loc in - let attrs = sub.attributes sub od.open_attributes in - Opn.mk ~loc ~attrs - ~override:od.open_override - (map_loc sub od.open_txt) +let type_manifest env ty1 params1 ty2 params2 priv2 = + let ty1' = Ctype.expand_head env ty1 and ty2' = Ctype.expand_head env ty2 in + match ty1'.desc, ty2'.desc with + Tvariant row1, Tvariant row2 when is_absrow env (Btype.row_more row2) -> + let row1 = Btype.row_repr row1 and row2 = Btype.row_repr row2 in + Ctype.equal env true (ty1::params1) (row2.row_more::params2) && + begin match row1.row_more with + {desc=Tvar _|Tconstr _|Tnil} -> true + | _ -> false + end && + let r1, r2, pairs = + Ctype.merge_row_fields row1.row_fields row2.row_fields in + (not row2.row_closed || + row1.row_closed && Ctype.filter_row_fields false r1 = []) && + List.for_all + (fun (_,f) -> match Btype.row_field_repr f with + Rabsent | Reither _ -> true | Rpresent _ -> false) + r2 && + let to_equal = ref (List.combine params1 params2) in + List.for_all + (fun (_, f1, f2) -> + match Btype.row_field_repr f1, Btype.row_field_repr f2 with + Rpresent(Some t1), + (Rpresent(Some t2) | Reither(false, [t2], _, _)) -> + to_equal := (t1,t2) :: !to_equal; true + | Rpresent None, (Rpresent None | Reither(true, [], _, _)) -> true + | Reither(c1,tl1,_,_), Reither(c2,tl2,_,_) + when List.length tl1 = List.length tl2 && c1 = c2 -> + to_equal := List.combine tl1 tl2 @ !to_equal; true + | Rabsent, (Reither _ | Rabsent) -> true + | _ -> false) + pairs && + let tl1, tl2 = List.split !to_equal in + Ctype.equal env true tl1 tl2 + | Tobject (fi1, _), Tobject (fi2, _) + when is_absrow env (snd(Ctype.flatten_fields fi2)) -> + let (fields2,rest2) = Ctype.flatten_fields fi2 in + Ctype.equal env true (ty1::params1) (rest2::params2) && + let (fields1,rest1) = Ctype.flatten_fields fi1 in + (match rest1 with {desc=Tnil|Tvar _|Tconstr _} -> true | _ -> false) && + let pairs, _miss1, miss2 = Ctype.associate_fields fields1 fields2 in + miss2 = [] && + let tl1, tl2 = + List.split (List.map (fun (_,_,t1,_,t2) -> t1, t2) pairs) in + Ctype.equal env true (params1 @ tl1) (params2 @ tl2) + | _ -> + let rec check_super ty1 = + Ctype.equal env true (ty1 :: params1) (ty2 :: params2) || + priv2 = Private && + try check_super + (Ctype.try_expand_once_opt env (Ctype.expand_head env ty1)) + with Ctype.Cannot_expand -> false + in check_super ty1 -let structure_item sub item = - let loc = sub.location sub item.str_loc in - let desc = - match item.str_desc with - Tstr_eval (exp, attrs) -> Pstr_eval (sub.expr sub exp, attrs) - | Tstr_value (rec_flag, list) -> - Pstr_value (rec_flag, List.map (sub.value_binding sub) list) - | Tstr_primitive vd -> - Pstr_primitive (sub.value_description sub vd) - | Tstr_type (rec_flag, list) -> - Pstr_type (rec_flag, List.map (sub.type_declaration sub) list) - | Tstr_typext tyext -> - Pstr_typext (sub.type_extension sub tyext) - | Tstr_exception ext -> - Pstr_exception (sub.extension_constructor sub ext) - | Tstr_module mb -> - Pstr_module (sub.module_binding sub mb) - | Tstr_recmodule list -> - Pstr_recmodule (List.map (sub.module_binding sub) list) - | Tstr_modtype mtd -> - Pstr_modtype (sub.module_type_declaration sub mtd) - | Tstr_open od -> - Pstr_open (sub.open_description sub od) - | Tstr_class list -> - Pstr_class - (List.map - (fun (ci, _) -> sub.class_declaration sub ci) - list) - | Tstr_class_type list -> - Pstr_class_type - (List.map - (fun (_id, _name, ct) -> sub.class_type_declaration sub ct) - list) - | Tstr_include incl -> - Pstr_include (sub.include_declaration sub incl) - | Tstr_attribute x -> - Pstr_attribute x - in - Str.mk ~loc desc +(* Inclusion between type declarations *) -let value_description sub v = - let loc = sub.location sub v.val_loc in - let attrs = sub.attributes sub v.val_attributes in - Val.mk ~loc ~attrs - ~prim:v.val_prim - (map_loc sub v.val_name) - (sub.typ sub v.val_desc) +type type_mismatch = + Arity + | Privacy + | Kind + | Constraint + | Manifest + | Variance + | Field_type of Ident.t + | Field_mutable of Ident.t + | Field_arity of Ident.t + | Field_names of int * string * string + | Field_missing of bool * Ident.t + | Record_representation of bool (* true means second one is unboxed float *) + | Unboxed_representation of bool (* true means second one is unboxed *) + | Immediate -let module_binding sub mb = - let loc = sub.location sub mb.mb_loc in - let attrs = sub.attributes sub mb.mb_attributes in - Mb.mk ~loc ~attrs - (map_loc sub mb.mb_name) - (sub.module_expr sub mb.mb_expr) +let report_type_mismatch0 first second decl ppf err = + let pr fmt = Format.fprintf ppf fmt in + match err with + Arity -> pr "They have different arities" + | Privacy -> pr "A private type would be revealed" + | Kind -> pr "Their kinds differ" + | Constraint -> pr "Their constraints differ" + | Manifest -> () + | Variance -> pr "Their variances do not agree" + | Field_type s -> + pr "The types for field %s are not equal" (Ident.name s) + | Field_mutable s -> + pr "The mutability of field %s is different" (Ident.name s) + | Field_arity s -> + pr "The arities for field %s differ" (Ident.name s) + | Field_names (n, name1, name2) -> + pr "Fields number %i have different names, %s and %s" + n name1 name2 + | Field_missing (b, s) -> + pr "The field %s is only present in %s %s" + (Ident.name s) (if b then second else first) decl + | Record_representation b -> + pr "Their internal representations differ:@ %s %s %s" + (if b then second else first) decl + "uses unboxed float representation" + | Unboxed_representation b -> + pr "Their internal representations differ:@ %s %s %s" + (if b then second else first) decl + "uses unboxed representation" + | Immediate -> pr "%s is not an immediate type" first -let type_parameter sub (ct, v) = (sub.typ sub ct, v) +let report_type_mismatch first second decl ppf = + List.iter + (fun err -> + if err = Manifest then () else + Format.fprintf ppf "@ %a." (report_type_mismatch0 first second decl) err) -let type_declaration sub decl = - let loc = sub.location sub decl.typ_loc in - let attrs = sub.attributes sub decl.typ_attributes in - Type.mk ~loc ~attrs - ~params:(List.map (type_parameter sub) decl.typ_params) - ~cstrs:( - List.map - (fun (ct1, ct2, loc) -> - (sub.typ sub ct1, sub.typ sub ct2, sub.location sub loc)) - decl.typ_cstrs) - ~kind:(sub.type_kind sub decl.typ_kind) - ~priv:decl.typ_private - ?manifest:(map_opt (sub.typ sub) decl.typ_manifest) - (map_loc sub decl.typ_name) +let rec compare_constructor_arguments ~loc env cstr params1 params2 arg1 arg2 = + match arg1, arg2 with + | Types.Cstr_tuple arg1, Types.Cstr_tuple arg2 -> + if List.length arg1 <> List.length arg2 then [Field_arity cstr] + else if + (* Ctype.equal must be called on all arguments at once, cf. PR#7378 *) + Ctype.equal env true (params1 @ arg1) (params2 @ arg2) + then [] else [Field_type cstr] + | Types.Cstr_record l1, Types.Cstr_record l2 -> + compare_records env ~loc params1 params2 0 l1 l2 + | _ -> [Field_type cstr] -let type_kind sub tk = match tk with - | Ttype_abstract -> Ptype_abstract - | Ttype_variant list -> - Ptype_variant (List.map (sub.constructor_declaration sub) list) - | Ttype_record list -> - Ptype_record (List.map (sub.label_declaration sub) list) - | Ttype_open -> Ptype_open +and compare_variants ~loc env params1 params2 n + (cstrs1 : Types.constructor_declaration list) + (cstrs2 : Types.constructor_declaration list) = + match cstrs1, cstrs2 with + [], [] -> [] + | [], c::_ -> [Field_missing (true, c.Types.cd_id)] + | c::_, [] -> [Field_missing (false, c.Types.cd_id)] + | cd1::rem1, cd2::rem2 -> + if Ident.name cd1.cd_id <> Ident.name cd2.cd_id then + [Field_names (n, cd1.cd_id.name, cd2.cd_id.name)] + else begin + Builtin_attributes.check_deprecated_inclusion + ~def:cd1.cd_loc + ~use:cd2.cd_loc + loc + cd1.cd_attributes cd2.cd_attributes + (Ident.name cd1.cd_id); + let r = + match cd1.cd_res, cd2.cd_res with + | Some r1, Some r2 -> + if Ctype.equal env true [r1] [r2] then + compare_constructor_arguments ~loc env cd1.cd_id [r1] [r2] + cd1.cd_args cd2.cd_args + else [Field_type cd1.cd_id] + | Some _, None | None, Some _ -> + [Field_type cd1.cd_id] + | _ -> + compare_constructor_arguments ~loc env cd1.cd_id + params1 params2 cd1.cd_args cd2.cd_args + in + if r <> [] then r + else compare_variants ~loc env params1 params2 (n+1) rem1 rem2 + end + + +and compare_records ~loc env params1 params2 n + (labels1 : Types.label_declaration list) + (labels2 : Types.label_declaration list) = + match labels1, labels2 with + [], [] -> [] + | [], l::_ -> [Field_missing (true, l.Types.ld_id)] + | l::_, [] -> [Field_missing (false, l.Types.ld_id)] + | ld1::rem1, ld2::rem2 -> + if Ident.name ld1.ld_id <> Ident.name ld2.ld_id + then [Field_names (n, ld1.ld_id.name, ld2.ld_id.name)] + else if ld1.ld_mutable <> ld2.ld_mutable then [Field_mutable ld1.ld_id] else begin + Builtin_attributes.check_deprecated_mutable_inclusion + ~def:ld1.ld_loc + ~use:ld2.ld_loc + loc + ld1.ld_attributes ld2.ld_attributes + (Ident.name ld1.ld_id); + let field_mismatch = !Builtin_attributes.check_bs_attributes_inclusion + ld1.ld_attributes ld2.ld_attributes + (Ident.name ld1.ld_id) in + match field_mismatch with + | Some (a,b) -> [Field_names (n,a,b)] + | None -> + if Ctype.equal env true (ld1.ld_type::params1)(ld2.ld_type::params2) + then (* add arguments to the parameters, cf. PR#7378 *) + compare_records ~loc env + (ld1.ld_type::params1) (ld2.ld_type::params2) + (n+1) + rem1 rem2 + else + [Field_type ld1.ld_id] + end + +let type_declarations ?(equality = false) ~loc env name decl1 id decl2 = + Builtin_attributes.check_deprecated_inclusion + ~def:decl1.type_loc + ~use:decl2.type_loc + loc + decl1.type_attributes decl2.type_attributes + name; + if decl1.type_arity <> decl2.type_arity then [Arity] else + if not (private_flags decl1 decl2) then [Privacy] else + let err = match (decl1.type_manifest, decl2.type_manifest) with + (_, None) -> + if Ctype.equal env true decl1.type_params decl2.type_params + then [] else [Constraint] + | (Some ty1, Some ty2) -> + if type_manifest env ty1 decl1.type_params ty2 decl2.type_params + decl2.type_private + then [] else [Manifest] + | (None, Some ty2) -> + let ty1 = + Btype.newgenty (Tconstr(Pident id, decl2.type_params, ref Mnil)) + in + if Ctype.equal env true decl1.type_params decl2.type_params then + if Ctype.equal env false [ty1] [ty2] then [] + else [Manifest] + else [Constraint] + in + if err <> [] then err else + let err = + match (decl2.type_kind, decl1.type_unboxed.unboxed, + decl2.type_unboxed.unboxed) with + | Type_abstract, _, _ -> [] + | _, true, false -> [Unboxed_representation false] + | _, false, true -> [Unboxed_representation true] + | _ -> [] + in + if err <> [] then err else + let err = match (decl1.type_kind, decl2.type_kind) with + (_, Type_abstract) -> [] + | (Type_variant cstrs1, Type_variant cstrs2) -> + let mark cstrs usage name decl = + List.iter + (fun c -> + Env.mark_constructor_used usage env name decl + (Ident.name c.Types.cd_id)) + cstrs + in + let usage = + if decl1.type_private = Private || decl2.type_private = Public + then Env.Positive else Env.Privatize + in + mark cstrs1 usage name decl1; + if equality then mark cstrs2 Env.Positive (Ident.name id) decl2; + compare_variants ~loc env decl1.type_params decl2.type_params 1 cstrs1 cstrs2 + | (Type_record(labels1,rep1), Type_record(labels2,rep2)) -> + let err = compare_records ~loc env decl1.type_params decl2.type_params + 1 labels1 labels2 in + if err <> [] || rep1 = rep2 then err else + [Record_representation (rep2 = Record_float)] + | (Type_open, Type_open) -> [] + | (_, _) -> [Kind] + in + if err <> [] then err else + let abstr = decl2.type_kind = Type_abstract && decl2.type_manifest = None in + (* If attempt to assign a non-immediate type (e.g. string) to a type that + * must be immediate, then we error *) + let err = + if abstr && + not decl1.type_immediate && + decl2.type_immediate then + [Immediate] + else [] + in + if err <> [] then err else + let need_variance = + abstr || decl1.type_private = Private || decl1.type_kind = Type_open in + if not need_variance then [] else + let abstr = abstr || decl2.type_private = Private in + let opn = decl2.type_kind = Type_open && decl2.type_manifest = None in + let constrained ty = not (Btype.(is_Tvar (repr ty))) in + if List.for_all2 + (fun ty (v1,v2) -> + let open Variance in + let imp a b = not a || b in + let (co1,cn1) = get_upper v1 and (co2,cn2) = get_upper v2 in + (if abstr then (imp co1 co2 && imp cn1 cn2) + else if opn || constrained ty then (co1 = co2 && cn1 = cn2) + else true) && + let (p1,n1,i1,j1) = get_lower v1 and (p2,n2,i2,j2) = get_lower v2 in + imp abstr (imp p2 p1 && imp n2 n1 && imp i2 i1 && imp j2 j1)) + decl2.type_params (List.combine decl1.type_variance decl2.type_variance) + then [] else [Variance] -let constructor_arguments sub = function - | Cstr_tuple l -> Pcstr_tuple (List.map (sub.typ sub) l) - | Cstr_record l -> Pcstr_record (List.map (sub.label_declaration sub) l) +(* Inclusion between extension constructors *) -let constructor_declaration sub cd = - let loc = sub.location sub cd.cd_loc in - let attrs = sub.attributes sub cd.cd_attributes in - Type.constructor ~loc ~attrs - ~args:(constructor_arguments sub cd.cd_args) - ?res:(map_opt (sub.typ sub) cd.cd_res) - (map_loc sub cd.cd_name) +let extension_constructors ~loc env id ext1 ext2 = + let usage = + if ext1.ext_private = Private || ext2.ext_private = Public + then Env.Positive else Env.Privatize + in + Env.mark_extension_used usage env ext1 (Ident.name id); + let ty1 = + Btype.newgenty (Tconstr(ext1.ext_type_path, ext1.ext_type_params, ref Mnil)) + in + let ty2 = + Btype.newgenty (Tconstr(ext2.ext_type_path, ext2.ext_type_params, ref Mnil)) + in + if Ctype.equal env true + (ty1 :: ext1.ext_type_params) + (ty2 :: ext2.ext_type_params) + then + if compare_constructor_arguments ~loc env (Ident.create "") + ext1.ext_type_params ext2.ext_type_params + ext1.ext_args ext2.ext_args = [] then + if match ext1.ext_ret_type, ext2.ext_ret_type with + Some r1, Some r2 when not (Ctype.equal env true [r1] [r2]) -> false + | Some _, None | None, Some _ -> false + | _ -> true + then + match ext1.ext_private, ext2.ext_private with + Private, Public -> false + | _, _ -> true + else false + else false + else false -let label_declaration sub ld = - let loc = sub.location sub ld.ld_loc in - let attrs = sub.attributes sub ld.ld_attributes in - Type.field ~loc ~attrs - ~mut:ld.ld_mutable - (map_loc sub ld.ld_name) - (sub.typ sub ld.ld_type) +end +module Mtype : sig +#1 "mtype.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -let type_extension sub tyext = - let attrs = sub.attributes sub tyext.tyext_attributes in - Te.mk ~attrs - ~params:(List.map (type_parameter sub) tyext.tyext_params) - ~priv:tyext.tyext_private - (map_loc sub tyext.tyext_txt) - (List.map (sub.extension_constructor sub) tyext.tyext_constructors) +(* Operations on module types *) -let extension_constructor sub ext = - let loc = sub.location sub ext.ext_loc in - let attrs = sub.attributes sub ext.ext_attributes in - Te.constructor ~loc ~attrs - (map_loc sub ext.ext_name) - (match ext.ext_kind with - | Text_decl (args, ret) -> - Pext_decl (constructor_arguments sub args, - map_opt (sub.typ sub) ret) - | Text_rebind (_p, lid) -> Pext_rebind (map_loc sub lid) - ) +open Types -let pattern sub pat = - let loc = sub.location sub pat.pat_loc in - (* todo: fix attributes on extras *) - let attrs = sub.attributes sub pat.pat_attributes in - let desc = - match pat with - { pat_extra=[Tpat_unpack, _, _attrs]; pat_desc = Tpat_var (_,name); _ } -> - Ppat_unpack name - | { pat_extra=[Tpat_type (_path, lid), _, _attrs]; _ } -> - Ppat_type (map_loc sub lid) - | { pat_extra= (Tpat_constraint ct, _, _attrs) :: rem; _ } -> - Ppat_constraint (sub.pat sub { pat with pat_extra=rem }, - sub.typ sub ct) - | _ -> - match pat.pat_desc with - Tpat_any -> Ppat_any - | Tpat_var (id, name) -> - begin - match (Ident.name id).[0] with - 'A'..'Z' -> - Ppat_unpack name - | _ -> - Ppat_var name - end +val scrape: Env.t -> module_type -> module_type + (* Expand toplevel module type abbreviations + till hitting a "hard" module type (signature, functor, + or abstract module type ident. *) +val freshen: module_type -> module_type + (* Return an alpha-equivalent copy of the given module type + where bound identifiers are fresh. *) +val strengthen: aliasable:bool -> Env.t -> module_type -> Path.t -> module_type + (* Strengthen abstract type components relative to the + given path. *) +val strengthen_decl: + aliasable:bool -> Env.t -> module_declaration -> Path.t -> module_declaration +val nondep_supertype: Env.t -> Ident.t -> module_type -> module_type + (* Return the smallest supertype of the given type + in which the given ident does not appear. + Raise [Not_found] if no such type exists. *) +val no_code_needed: Env.t -> module_type -> bool +val no_code_needed_sig: Env.t -> signature -> bool + (* Determine whether a module needs no implementation code, + i.e. consists only of type definitions. *) +val enrich_modtype: Env.t -> Path.t -> module_type -> module_type +val enrich_typedecl: Env.t -> Path.t -> type_declaration -> type_declaration +val type_paths: Env.t -> Path.t -> module_type -> Path.t list +val contains_type: Env.t -> module_type -> bool +val remove_aliases: Env.t -> module_type -> module_type +val lower_nongen: int -> module_type -> unit - (* We transform (_ as x) in x if _ and x have the same location. - The compiler transforms (x:t) into (_ as x : t). - This avoids transforming a warning 27 into a 26. - *) - | Tpat_alias ({pat_desc = Tpat_any; pat_loc}, _id, name) - when pat_loc = pat.pat_loc -> - Ppat_var name +end = struct +#1 "mtype.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) - | Tpat_alias (pat, _id, name) -> - Ppat_alias (sub.pat sub pat, name) - | Tpat_constant cst -> Ppat_constant (constant cst) - | Tpat_tuple list -> - Ppat_tuple (List.map (sub.pat sub) list) - | Tpat_construct (lid, _, args) -> - Ppat_construct (map_loc sub lid, - (match args with - [] -> None - | [arg] -> Some (sub.pat sub arg) - | args -> - Some - (Pat.tuple ~loc - (List.map (sub.pat sub) args) - ) - )) - | Tpat_variant (label, pato, _) -> - Ppat_variant (label, map_opt (sub.pat sub) pato) - | Tpat_record (list, closed) -> - Ppat_record (List.map (fun (lid, _, pat) -> - map_loc sub lid, sub.pat sub pat) list, closed) - | Tpat_array list -> Ppat_array (List.map (sub.pat sub) list) - | Tpat_or (p1, p2, _) -> Ppat_or (sub.pat sub p1, sub.pat sub p2) - | Tpat_lazy p -> Ppat_lazy (sub.pat sub p) - in - Pat.mk ~loc ~attrs desc +(* Operations on module types *) -let exp_extra sub (extra, loc, attrs) sexp = - let loc = sub.location sub loc in - let attrs = sub.attributes sub attrs in - let desc = - match extra with - Texp_coerce (cty1, cty2) -> - Pexp_coerce (sexp, - map_opt (sub.typ sub) cty1, - sub.typ sub cty2) - | Texp_constraint cty -> - Pexp_constraint (sexp, sub.typ sub cty) - | Texp_open (ovf, _path, lid, _) -> - Pexp_open (ovf, map_loc sub lid, sexp) - | Texp_poly cto -> Pexp_poly (sexp, map_opt (sub.typ sub) cto) - | Texp_newtype s -> Pexp_newtype (mkloc s loc, sexp) - in - Exp.mk ~loc ~attrs desc +open Asttypes +open Path +open Types -let cases sub l = List.map (sub.case sub) l -let case sub {c_lhs; c_guard; c_rhs} = - { - pc_lhs = sub.pat sub c_lhs; - pc_guard = map_opt (sub.expr sub) c_guard; - pc_rhs = sub.expr sub c_rhs; - } +let rec scrape env mty = + match mty with + Mty_ident p -> + begin try + scrape env (Env.find_modtype_expansion p env) + with Not_found -> + mty + end + | _ -> mty -let value_binding sub vb = - let loc = sub.location sub vb.vb_loc in - let attrs = sub.attributes sub vb.vb_attributes in - Vb.mk ~loc ~attrs - (sub.pat sub vb.vb_pat) - (sub.expr sub vb.vb_expr) +let freshen mty = + Subst.modtype Subst.identity mty -let expression sub exp = - let loc = sub.location sub exp.exp_loc in - let attrs = sub.attributes sub exp.exp_attributes in - let desc = - match exp.exp_desc with - Texp_ident (_path, lid, _) -> Pexp_ident (map_loc sub lid) - | Texp_constant cst -> Pexp_constant (constant cst) - | Texp_let (rec_flag, list, exp) -> - Pexp_let (rec_flag, - List.map (sub.value_binding sub) list, - sub.expr sub exp) +let rec strengthen ~aliasable env mty p = + match scrape env mty with + Mty_signature sg -> + Mty_signature(strengthen_sig ~aliasable env sg p 0) + | Mty_functor(param, arg, res) + when !Clflags.applicative_functors && Ident.name param <> "*" -> + Mty_functor(param, arg, + strengthen ~aliasable:false env res (Papply(p, Pident param))) + | mty -> + mty - (* Pexp_function can't have a label, so we split in 3 cases. *) - (* One case, no guard: It's a fun. *) - | Texp_function { arg_label; cases = [{c_lhs=p; c_guard=None; c_rhs=e}]; - _ } -> - Pexp_fun (arg_label, None, sub.pat sub p, sub.expr sub e) - (* No label: it's a function. *) - | Texp_function { arg_label = Nolabel; cases; _; } -> - Pexp_function (sub.cases sub cases) - (* Mix of both, we generate `fun ~label:$name$ -> match $name$ with ...` *) - | Texp_function { arg_label = Labelled s | Optional s as label; cases; - _ } -> - let name = fresh_name s exp.exp_env in - Pexp_fun (label, None, Pat.var ~loc {loc;txt = name }, - Exp.match_ ~loc (Exp.ident ~loc {loc;txt= Lident name}) - (sub.cases sub cases)) - | Texp_apply (exp, list) -> - Pexp_apply (sub.expr sub exp, - List.fold_right (fun (label, expo) list -> - match expo with - None -> list - | Some exp -> (label, sub.expr sub exp) :: list - ) list []) - | Texp_match (exp, cases, exn_cases, _) -> - let merged_cases = sub.cases sub cases - @ List.map - (fun c -> - let uc = sub.case sub c in - let pat = { uc.pc_lhs - with ppat_desc = Ppat_exception uc.pc_lhs } - in - { uc with pc_lhs = pat }) - exn_cases +and strengthen_sig ~aliasable env sg p pos = + match sg with + [] -> [] + | (Sig_value(_, desc) as sigelt) :: rem -> + let nextpos = + match desc.val_kind with + | Val_prim _ -> pos + | _ -> pos + 1 in - Pexp_match (sub.expr sub exp, merged_cases) - | Texp_try (exp, cases) -> - Pexp_try (sub.expr sub exp, sub.cases sub cases) - | Texp_tuple list -> - Pexp_tuple (List.map (sub.expr sub) list) - | Texp_construct (lid, _, args) -> - Pexp_construct (map_loc sub lid, - (match args with - [] -> None - | [ arg ] -> Some (sub.expr sub arg) - | args -> - Some - (Exp.tuple ~loc (List.map (sub.expr sub) args)) - )) - | Texp_variant (label, expo) -> - Pexp_variant (label, map_opt (sub.expr sub) expo) - | Texp_record { fields; extended_expression; _ } -> - let list = Array.fold_left (fun l -> function - | _, Kept _ -> l - | _, Overridden (lid, exp) -> (lid, sub.expr sub exp) :: l) - [] fields - in - Pexp_record (list, map_opt (sub.expr sub) extended_expression) - | Texp_field (exp, lid, _label) -> - Pexp_field (sub.expr sub exp, map_loc sub lid) - | Texp_setfield (exp1, lid, _label, exp2) -> - Pexp_setfield (sub.expr sub exp1, map_loc sub lid, - sub.expr sub exp2) - | Texp_array list -> - Pexp_array (List.map (sub.expr sub) list) - | Texp_ifthenelse (exp1, exp2, expo) -> - Pexp_ifthenelse (sub.expr sub exp1, - sub.expr sub exp2, - map_opt (sub.expr sub) expo) - | Texp_sequence (exp1, exp2) -> - Pexp_sequence (sub.expr sub exp1, sub.expr sub exp2) - | Texp_while (exp1, exp2) -> - Pexp_while (sub.expr sub exp1, sub.expr sub exp2) - | Texp_for (_id, name, exp1, exp2, dir, exp3) -> - Pexp_for (name, - sub.expr sub exp1, sub.expr sub exp2, - dir, sub.expr sub exp3) - | Texp_send (exp, meth, _) -> - Pexp_send (sub.expr sub exp, match meth with - Tmeth_name name -> mkloc name loc - | Tmeth_val id -> mkloc (Ident.name id) loc) - | Texp_new (_path, lid, _) -> Pexp_new (map_loc sub lid) - | Texp_instvar (_, path, name) -> - Pexp_ident ({loc = sub.location sub name.loc ; txt = lident_of_path path}) - | Texp_setinstvar (_, _path, lid, exp) -> - Pexp_setinstvar (map_loc sub lid, sub.expr sub exp) - | Texp_override (_, list) -> - Pexp_override (List.map (fun (_path, lid, exp) -> - (map_loc sub lid, sub.expr sub exp) - ) list) - | Texp_letmodule (_id, name, mexpr, exp) -> - Pexp_letmodule (name, sub.module_expr sub mexpr, - sub.expr sub exp) - | Texp_letexception (ext, exp) -> - Pexp_letexception (sub.extension_constructor sub ext, - sub.expr sub exp) - | Texp_assert exp -> Pexp_assert (sub.expr sub exp) - | Texp_lazy exp -> Pexp_lazy (sub.expr sub exp) - | Texp_object (cl, _) -> - Pexp_object (sub.class_structure sub cl) - | Texp_pack (mexpr) -> - Pexp_pack (sub.module_expr sub mexpr) - | Texp_unreachable -> - Pexp_unreachable - | Texp_extension_constructor (lid, _) -> - Pexp_extension ({ txt = "ocaml.extension_constructor"; loc }, - PStr [ Str.eval ~loc - (Exp.construct ~loc (map_loc sub lid) None) - ]) - in - List.fold_right (exp_extra sub) exp.exp_extra - (Exp.mk ~loc ~attrs desc) - -let package_type sub pack = - (map_loc sub pack.pack_txt, - List.map (fun (s, ct) -> - (s, sub.typ sub ct)) pack.pack_fields) - -let module_type_declaration sub mtd = - let loc = sub.location sub mtd.mtd_loc in - let attrs = sub.attributes sub mtd.mtd_attributes in - Mtd.mk ~loc ~attrs - ?typ:(map_opt (sub.module_type sub) mtd.mtd_type) - (map_loc sub mtd.mtd_name) + sigelt :: strengthen_sig ~aliasable env rem p nextpos + | Sig_type(id, {type_kind=Type_abstract}, _) :: + (Sig_type(id', {type_private=Private}, _) :: _ as rem) + when Ident.name id = Ident.name id' ^ "#row" -> + strengthen_sig ~aliasable env rem p pos + | Sig_type(id, decl, rs) :: rem -> + let newdecl = + match decl.type_manifest, decl.type_private, decl.type_kind with + Some _, Public, _ -> decl + | Some _, Private, (Type_record _ | Type_variant _) -> decl + | _ -> + let manif = + Some(Btype.newgenty(Tconstr(Pdot(p, Ident.name id, nopos), + decl.type_params, ref Mnil))) in + if decl.type_kind = Type_abstract then + { decl with type_private = Public; type_manifest = manif } + else + { decl with type_manifest = manif } + in + Sig_type(id, newdecl, rs) :: strengthen_sig ~aliasable env rem p pos + | (Sig_typext _ as sigelt) :: rem -> + sigelt :: strengthen_sig ~aliasable env rem p (pos+1) + | Sig_module(id, md, rs) :: rem -> + let str = + strengthen_decl ~aliasable env md (Pdot(p, Ident.name id, pos)) + in + Sig_module(id, str, rs) + :: strengthen_sig ~aliasable + (Env.add_module_declaration ~check:false id md env) rem p (pos+1) + (* Need to add the module in case it defines manifest module types *) + | Sig_modtype(id, decl) :: rem -> + let newdecl = + match decl.mtd_type with + None -> + {decl with mtd_type = Some(Mty_ident(Pdot(p,Ident.name id,nopos)))} + | Some _ -> + decl + in + Sig_modtype(id, newdecl) :: + strengthen_sig ~aliasable (Env.add_modtype id decl env) rem p pos + (* Need to add the module type in case it is manifest *) + | (Sig_class _ as sigelt) :: rem -> + sigelt :: strengthen_sig ~aliasable env rem p (pos+1) + | (Sig_class_type _ as sigelt) :: rem -> + sigelt :: strengthen_sig ~aliasable env rem p pos -let signature sub sg = - List.map (sub.signature_item sub) sg.sig_items +and strengthen_decl ~aliasable env md p = + match md.md_type with + | Mty_alias _ -> md + | _ when aliasable -> {md with md_type = Mty_alias(Mta_present, p)} + | mty -> {md with md_type = strengthen ~aliasable env mty p} -let signature_item sub item = - let loc = sub.location sub item.sig_loc in - let desc = - match item.sig_desc with - Tsig_value v -> - Psig_value (sub.value_description sub v) - | Tsig_type (rec_flag, list) -> - Psig_type (rec_flag, List.map (sub.type_declaration sub) list) - | Tsig_typext tyext -> - Psig_typext (sub.type_extension sub tyext) - | Tsig_exception ext -> - Psig_exception (sub.extension_constructor sub ext) - | Tsig_module md -> - Psig_module (sub.module_declaration sub md) - | Tsig_recmodule list -> - Psig_recmodule (List.map (sub.module_declaration sub) list) - | Tsig_modtype mtd -> - Psig_modtype (sub.module_type_declaration sub mtd) - | Tsig_open od -> - Psig_open (sub.open_description sub od) - | Tsig_include incl -> - Psig_include (sub.include_description sub incl) - | Tsig_class list -> - Psig_class (List.map (sub.class_description sub) list) - | Tsig_class_type list -> - Psig_class_type (List.map (sub.class_type_declaration sub) list) - | Tsig_attribute x -> - Psig_attribute x - in - Sig.mk ~loc desc +let () = Env.strengthen := strengthen -let module_declaration sub md = - let loc = sub.location sub md.md_loc in - let attrs = sub.attributes sub md.md_attributes in - Md.mk ~loc ~attrs - (map_loc sub md.md_name) - (sub.module_type sub md.md_type) +(* In nondep_supertype, env is only used for the type it assigns to id. + Hence there is no need to keep env up-to-date by adding the bindings + traversed. *) -let include_infos f sub incl = - let loc = sub.location sub incl.incl_loc in - let attrs = sub.attributes sub incl.incl_attributes in - Incl.mk ~loc ~attrs - (f sub incl.incl_mod) +type variance = Co | Contra | Strict -let include_declaration sub = include_infos sub.module_expr sub -let include_description sub = include_infos sub.module_type sub +let nondep_supertype env mid mty = -let class_infos f sub ci = - let loc = sub.location sub ci.ci_loc in - let attrs = sub.attributes sub ci.ci_attributes in - Ci.mk ~loc ~attrs - ~virt:ci.ci_virt - ~params:(List.map (type_parameter sub) ci.ci_params) - (map_loc sub ci.ci_id_name) - (f sub ci.ci_expr) + let rec nondep_mty env va mty = + match mty with + Mty_ident p -> + if Path.isfree mid p then + nondep_mty env va (Env.find_modtype_expansion p env) + else mty + | Mty_alias(_, p) -> + if Path.isfree mid p then + nondep_mty env va (Env.find_module p env).md_type + else mty + | Mty_signature sg -> + Mty_signature(nondep_sig env va sg) + | Mty_functor(param, arg, res) -> + let var_inv = + match va with Co -> Contra | Contra -> Co | Strict -> Strict in + Mty_functor(param, Misc.may_map (nondep_mty env var_inv) arg, + nondep_mty + (Env.add_module ~arg:true param + (Btype.default_mty arg) env) va res) -let class_declaration sub = class_infos sub.class_expr sub -let class_description sub = class_infos sub.class_type sub -let class_type_declaration sub = class_infos sub.class_type sub + and nondep_sig env va = function + [] -> [] + | item :: rem -> + let rem' = nondep_sig env va rem in + match item with + Sig_value(id, d) -> + Sig_value(id, + {d with val_type = Ctype.nondep_type env mid d.val_type}) + :: rem' + | Sig_type(id, d, rs) -> + Sig_type(id, Ctype.nondep_type_decl env mid id (va = Co) d, rs) + :: rem' + | Sig_typext(id, ext, es) -> + Sig_typext(id, Ctype.nondep_extension_constructor env mid ext, es) + :: rem' + | Sig_module(id, md, rs) -> + Sig_module(id, {md with md_type=nondep_mty env va md.md_type}, rs) + :: rem' + | Sig_modtype(id, d) -> + begin try + Sig_modtype(id, nondep_modtype_decl env d) :: rem' + with Not_found -> + match va with + Co -> Sig_modtype(id, {mtd_type=None; mtd_loc=Location.none; + mtd_attributes=[]}) :: rem' + | _ -> raise Not_found + end + | Sig_class(id, d, rs) -> + Sig_class(id, Ctype.nondep_class_declaration env mid d, rs) + :: rem' + | Sig_class_type(id, d, rs) -> + Sig_class_type(id, Ctype.nondep_cltype_declaration env mid d, rs) + :: rem' + + and nondep_modtype_decl env mtd = + {mtd with mtd_type = Misc.may_map (nondep_mty env Strict) mtd.mtd_type} -let module_type sub mty = - let loc = sub.location sub mty.mty_loc in - let attrs = sub.attributes sub mty.mty_attributes in - let desc = match mty.mty_desc with - Tmty_ident (_path, lid) -> Pmty_ident (map_loc sub lid) - | Tmty_alias (_path, lid) -> Pmty_alias (map_loc sub lid) - | Tmty_signature sg -> Pmty_signature (sub.signature sub sg) - | Tmty_functor (_id, name, mtype1, mtype2) -> - Pmty_functor (name, map_opt (sub.module_type sub) mtype1, - sub.module_type sub mtype2) - | Tmty_with (mtype, list) -> - Pmty_with (sub.module_type sub mtype, - List.map (sub.with_constraint sub) list) - | Tmty_typeof mexpr -> - Pmty_typeof (sub.module_expr sub mexpr) in - Mty.mk ~loc ~attrs desc + nondep_mty env Co mty -let with_constraint sub (_path, lid, cstr) = - match cstr with - | Twith_type decl -> - Pwith_type (map_loc sub lid, sub.type_declaration sub decl) - | Twith_module (_path, lid2) -> - Pwith_module (map_loc sub lid, map_loc sub lid2) - | Twith_typesubst decl -> - Pwith_typesubst (map_loc sub lid, sub.type_declaration sub decl) - | Twith_modsubst (_path, lid2) -> - Pwith_modsubst (map_loc sub lid, map_loc sub lid2) +let enrich_typedecl env p decl = + match decl.type_manifest with + Some _ -> decl + | None -> + try + let orig_decl = Env.find_type p env in + if orig_decl.type_arity <> decl.type_arity + then decl + else {decl with type_manifest = + Some(Btype.newgenty(Tconstr(p, decl.type_params, ref Mnil)))} + with Not_found -> + decl -let module_expr sub mexpr = - let loc = sub.location sub mexpr.mod_loc in - let attrs = sub.attributes sub mexpr.mod_attributes in - match mexpr.mod_desc with - Tmod_constraint (m, _, Tmodtype_implicit, _ ) -> - sub.module_expr sub m - | _ -> - let desc = match mexpr.mod_desc with - Tmod_ident (_p, lid) -> Pmod_ident (map_loc sub lid) - | Tmod_structure st -> Pmod_structure (sub.structure sub st) - | Tmod_functor (_id, name, mtype, mexpr) -> - Pmod_functor (name, Misc.may_map (sub.module_type sub) mtype, - sub.module_expr sub mexpr) - | Tmod_apply (mexp1, mexp2, _) -> - Pmod_apply (sub.module_expr sub mexp1, sub.module_expr sub mexp2) - | Tmod_constraint (mexpr, _, Tmodtype_explicit mtype, _) -> - Pmod_constraint (sub.module_expr sub mexpr, - sub.module_type sub mtype) - | Tmod_constraint (_mexpr, _, Tmodtype_implicit, _) -> - assert false - | Tmod_unpack (exp, _pack) -> - Pmod_unpack (sub.expr sub exp) - (* TODO , sub.package_type sub pack) *) - in - Mod.mk ~loc ~attrs desc +let rec enrich_modtype env p mty = + match mty with + Mty_signature sg -> + Mty_signature(List.map (enrich_item env p) sg) + | _ -> + mty -let class_expr sub cexpr = - let loc = sub.location sub cexpr.cl_loc in - let attrs = sub.attributes sub cexpr.cl_attributes in - let desc = match cexpr.cl_desc with - | Tcl_constraint ( { cl_desc = Tcl_ident (_path, lid, tyl); _ }, - None, _, _, _ ) -> - Pcl_constr (map_loc sub lid, - List.map (sub.typ sub) tyl) - | Tcl_structure clstr -> Pcl_structure (sub.class_structure sub clstr) +and enrich_item env p = function + Sig_type(id, decl, rs) -> + Sig_type(id, + enrich_typedecl env (Pdot(p, Ident.name id, nopos)) decl, rs) + | Sig_module(id, md, rs) -> + Sig_module(id, + {md with + md_type = enrich_modtype env + (Pdot(p, Ident.name id, nopos)) md.md_type}, + rs) + | item -> item - | Tcl_fun (label, pat, _pv, cl, _partial) -> - Pcl_fun (label, None, sub.pat sub pat, sub.class_expr sub cl) +let rec type_paths env p mty = + match scrape env mty with + Mty_ident _ -> [] + | Mty_alias _ -> [] + | Mty_signature sg -> type_paths_sig env p 0 sg + | Mty_functor _ -> [] - | Tcl_apply (cl, args) -> - Pcl_apply (sub.class_expr sub cl, - List.fold_right (fun (label, expo) list -> - match expo with - None -> list - | Some exp -> (label, sub.expr sub exp) :: list - ) args []) +and type_paths_sig env p pos sg = + match sg with + [] -> [] + | Sig_value(_id, decl) :: rem -> + let pos' = match decl.val_kind with Val_prim _ -> pos | _ -> pos + 1 in + type_paths_sig env p pos' rem + | Sig_type(id, _decl, _) :: rem -> + Pdot(p, Ident.name id, nopos) :: type_paths_sig env p pos rem + | Sig_module(id, md, _) :: rem -> + type_paths env (Pdot(p, Ident.name id, pos)) md.md_type @ + type_paths_sig (Env.add_module_declaration ~check:false id md env) + p (pos+1) rem + | Sig_modtype(id, decl) :: rem -> + type_paths_sig (Env.add_modtype id decl env) p pos rem + | (Sig_typext _ | Sig_class _) :: rem -> + type_paths_sig env p (pos+1) rem + | (Sig_class_type _) :: rem -> + type_paths_sig env p pos rem - | Tcl_let (rec_flat, bindings, _ivars, cl) -> - Pcl_let (rec_flat, - List.map (sub.value_binding sub) bindings, - sub.class_expr sub cl) +let rec no_code_needed env mty = + match scrape env mty with + Mty_ident _ -> false + | Mty_signature sg -> no_code_needed_sig env sg + | Mty_functor(_, _, _) -> false + | Mty_alias(Mta_absent, _) -> true + | Mty_alias(Mta_present, _) -> false - | Tcl_constraint (cl, Some clty, _vals, _meths, _concrs) -> - Pcl_constraint (sub.class_expr sub cl, sub.class_type sub clty) +and no_code_needed_sig env sg = + match sg with + [] -> true + | Sig_value(_id, decl) :: rem -> + begin match decl.val_kind with + | Val_prim _ -> no_code_needed_sig env rem + | _ -> false + end + | Sig_module(id, md, _) :: rem -> + no_code_needed env md.md_type && + no_code_needed_sig + (Env.add_module_declaration ~check:false id md env) rem + | (Sig_type _ | Sig_modtype _ | Sig_class_type _) :: rem -> + no_code_needed_sig env rem + | (Sig_typext _ | Sig_class _) :: _ -> + false - | Tcl_open (ovf, _p, lid, _env, e) -> - Pcl_open (ovf, lid, sub.class_expr sub e) - | Tcl_ident _ -> assert false - | Tcl_constraint (_, None, _, _, _) -> assert false - in - Cl.mk ~loc ~attrs desc +(* Check whether a module type may return types *) -let class_type sub ct = - let loc = sub.location sub ct.cltyp_loc in - let attrs = sub.attributes sub ct.cltyp_attributes in - let desc = match ct.cltyp_desc with - Tcty_signature csg -> Pcty_signature (sub.class_signature sub csg) - | Tcty_constr (_path, lid, list) -> - Pcty_constr (map_loc sub lid, List.map (sub.typ sub) list) - | Tcty_arrow (label, ct, cl) -> - Pcty_arrow (label, sub.typ sub ct, sub.class_type sub cl) - | Tcty_open (ovf, _p, lid, _env, e) -> - Pcty_open (ovf, lid, sub.class_type sub e) - in - Cty.mk ~loc ~attrs desc +let rec contains_type env = function + Mty_ident path -> + begin try match (Env.find_modtype path env).mtd_type with + | None -> raise Exit (* PR#6427 *) + | Some mty -> contains_type env mty + with Not_found -> raise Exit + end + | Mty_signature sg -> + contains_type_sig env sg + | Mty_functor (_, _, body) -> + contains_type env body + | Mty_alias _ -> + () -let class_signature sub cs = - { - pcsig_self = sub.typ sub cs.csig_self; - pcsig_fields = List.map (sub.class_type_field sub) cs.csig_fields; - } +and contains_type_sig env = List.iter (contains_type_item env) -let class_type_field sub ctf = - let loc = sub.location sub ctf.ctf_loc in - let attrs = sub.attributes sub ctf.ctf_attributes in - let desc = match ctf.ctf_desc with - Tctf_inherit ct -> Pctf_inherit (sub.class_type sub ct) - | Tctf_val (s, mut, virt, ct) -> - Pctf_val (mkloc s loc, mut, virt, sub.typ sub ct) - | Tctf_method (s, priv, virt, ct) -> - Pctf_method (mkloc s loc, priv, virt, sub.typ sub ct) - | Tctf_constraint (ct1, ct2) -> - Pctf_constraint (sub.typ sub ct1, sub.typ sub ct2) - | Tctf_attribute x -> Pctf_attribute x - in - Ctf.mk ~loc ~attrs desc +and contains_type_item env = function + Sig_type (_,({type_manifest = None} | + {type_kind = Type_abstract; type_private = Private}),_) + | Sig_modtype _ + | Sig_typext (_, {ext_args = Cstr_record _}, _) -> + (* We consider that extension constructors with an inlined + record create a type (the inlined record), even though + it would be technically safe to ignore that considering + the current constraints which guarantee that this type + is kept local to expressions. *) + raise Exit + | Sig_module (_, {md_type = mty}, _) -> + contains_type env mty + | Sig_value _ + | Sig_type _ + | Sig_typext _ + | Sig_class _ + | Sig_class_type _ -> + () -let core_type sub ct = - let loc = sub.location sub ct.ctyp_loc in - let attrs = sub.attributes sub ct.ctyp_attributes in - let desc = match ct.ctyp_desc with - Ttyp_any -> Ptyp_any - | Ttyp_var s -> Ptyp_var s - | Ttyp_arrow (label, ct1, ct2) -> - Ptyp_arrow (label, sub.typ sub ct1, sub.typ sub ct2) - | Ttyp_tuple list -> Ptyp_tuple (List.map (sub.typ sub) list) - | Ttyp_constr (_path, lid, list) -> - Ptyp_constr (map_loc sub lid, - List.map (sub.typ sub) list) - | Ttyp_object (list, o) -> - Ptyp_object - (List.map (sub.object_field sub) list, o) - | Ttyp_class (_path, lid, list) -> - Ptyp_class (map_loc sub lid, List.map (sub.typ sub) list) - | Ttyp_alias (ct, s) -> - Ptyp_alias (sub.typ sub ct, s) - | Ttyp_variant (list, bool, labels) -> - Ptyp_variant (List.map (sub.row_field sub) list, bool, labels) - | Ttyp_poly (list, ct) -> - let list = List.map (fun v -> mkloc v loc) list in - Ptyp_poly (list, sub.typ sub ct) - | Ttyp_package pack -> Ptyp_package (sub.package_type sub pack) - in - Typ.mk ~loc ~attrs desc +let contains_type env mty = + try contains_type env mty; false with Exit -> true -let class_structure sub cs = - let rec remove_self = function - | { pat_desc = Tpat_alias (p, id, _s) } - when string_is_prefix "selfpat-" id.Ident.name -> - remove_self p - | p -> p - in - { pcstr_self = sub.pat sub (remove_self cs.cstr_self); - pcstr_fields = List.map (sub.class_field sub) cs.cstr_fields; - } -let row_field sub rf = - match rf with - Ttag (label, attrs, bool, list) -> - Rtag (label, sub.attributes sub attrs, bool, List.map (sub.typ sub) list) - | Tinherit ct -> Rinherit (sub.typ sub ct) +(* Remove module aliases from a signature *) -let object_field sub ofield = - match ofield with - OTtag (label, attrs, ct) -> - Otag (label, sub.attributes sub attrs, sub.typ sub ct) - | OTinherit ct -> Oinherit (sub.typ sub ct) +module PathSet = Set.Make (Path) +module PathMap = Map.Make (Path) +module IdentSet = Set.Make (Ident) -and is_self_pat = function - | { pat_desc = Tpat_alias(_pat, id, _) } -> - string_is_prefix "self-" (Ident.name id) - | _ -> false +let rec get_prefixes = function + Pident _ -> PathSet.empty + | Pdot (p, _, _) + | Papply (p, _) -> PathSet.add p (get_prefixes p) -let class_field sub cf = - let loc = sub.location sub cf.cf_loc in - let attrs = sub.attributes sub cf.cf_attributes in - let desc = match cf.cf_desc with - Tcf_inherit (ovf, cl, super, _vals, _meths) -> - Pcf_inherit (ovf, sub.class_expr sub cl, - map_opt (fun v -> mkloc v loc) super) - | Tcf_constraint (cty, cty') -> - Pcf_constraint (sub.typ sub cty, sub.typ sub cty') - | Tcf_val (lab, mut, _, Tcfk_virtual cty, _) -> - Pcf_val (lab, mut, Cfk_virtual (sub.typ sub cty)) - | Tcf_val (lab, mut, _, Tcfk_concrete (o, exp), _) -> - Pcf_val (lab, mut, Cfk_concrete (o, sub.expr sub exp)) - | Tcf_method (lab, priv, Tcfk_virtual cty) -> - Pcf_method (lab, priv, Cfk_virtual (sub.typ sub cty)) - | Tcf_method (lab, priv, Tcfk_concrete (o, exp)) -> - let remove_fun_self = function - | { exp_desc = - Texp_function { arg_label = Nolabel; cases = [case]; _ } } - when is_self_pat case.c_lhs && case.c_guard = None -> case.c_rhs - | e -> e - in - let exp = remove_fun_self exp in - Pcf_method (lab, priv, Cfk_concrete (o, sub.expr sub exp)) - | Tcf_initializer exp -> - let remove_fun_self = function - | { exp_desc = - Texp_function { arg_label = Nolabel; cases = [case]; _ } } - when is_self_pat case.c_lhs && case.c_guard = None -> case.c_rhs - | e -> e +let rec get_arg_paths = function + Pident _ -> PathSet.empty + | Pdot (p, _, _) -> get_arg_paths p + | Papply (p1, p2) -> + PathSet.add p2 + (PathSet.union (get_prefixes p2) + (PathSet.union (get_arg_paths p1) (get_arg_paths p2))) + +let rec rollback_path subst p = + try Pident (PathMap.find p subst) + with Not_found -> + match p with + Pident _ | Papply _ -> p + | Pdot (p1, s, n) -> + let p1' = rollback_path subst p1 in + if Path.same p1 p1' then p else rollback_path subst (Pdot (p1', s, n)) + +let rec collect_ids subst bindings p = + begin match rollback_path subst p with + Pident id -> + let ids = + try collect_ids subst bindings (Ident.find_same id bindings) + with Not_found -> IdentSet.empty in - let exp = remove_fun_self exp in - Pcf_initializer (sub.expr sub exp) - | Tcf_attribute x -> Pcf_attribute x - in - Cf.mk ~loc ~attrs desc + IdentSet.add id ids + | _ -> IdentSet.empty + end -let location _sub l = l +let collect_arg_paths mty = + let open Btype in + let paths = ref PathSet.empty + and subst = ref PathMap.empty + and bindings = ref Ident.empty in + (* let rt = Ident.create "Root" in + and prefix = ref (Path.Pident rt) in *) + let it_path p = paths := PathSet.union (get_arg_paths p) !paths + and it_signature_item it si = + type_iterators.it_signature_item it si; + match si with + Sig_module (id, {md_type=Mty_alias(_, p)}, _) -> + bindings := Ident.add id p !bindings + | Sig_module (id, {md_type=Mty_signature sg}, _) -> + List.iter + (function Sig_module (id', _, _) -> + subst := + PathMap.add (Pdot (Pident id, Ident.name id', -1)) id' !subst + | _ -> ()) + sg + | _ -> () + in + let it = {type_iterators with it_path; it_signature_item} in + it.it_module_type it mty; + it.it_module_type unmark_iterators mty; + PathSet.fold (fun p -> IdentSet.union (collect_ids !subst !bindings p)) + !paths IdentSet.empty -let default_mapper = - { - attribute = attribute ; - attributes = attributes ; - structure = structure; - structure_item = structure_item; - module_expr = module_expr; - signature = signature; - signature_item = signature_item; - module_type = module_type; - with_constraint = with_constraint; - class_declaration = class_declaration; - class_expr = class_expr; - class_field = class_field; - class_structure = class_structure; - class_type = class_type; - class_type_field = class_type_field; - class_signature = class_signature; - class_type_declaration = class_type_declaration; - class_description = class_description; - type_declaration = type_declaration; - type_kind = type_kind; - typ = core_type; - type_extension = type_extension; - extension_constructor = extension_constructor; - value_description = value_description; - pat = pattern; - expr = expression; - module_declaration = module_declaration; - module_type_declaration = module_type_declaration; - module_binding = module_binding; - package_type = package_type ; - open_description = open_description; - include_description = include_description; - include_declaration = include_declaration; - value_binding = value_binding; - constructor_declaration = constructor_declaration; - label_declaration = label_declaration; - cases = cases; - case = case; - location = location; - row_field = row_field ; - object_field = object_field ; - } +let rec remove_aliases env excl mty = + match mty with + Mty_signature sg -> + Mty_signature (remove_aliases_sig env excl sg) + | Mty_alias _ -> + let mty' = Env.scrape_alias env mty in + if mty' = mty then mty else + remove_aliases env excl mty' + | mty -> + mty -let untype_structure ?(mapper=default_mapper) structure = - mapper.structure mapper structure +and remove_aliases_sig env excl sg = + match sg with + [] -> [] + | Sig_module(id, md, rs) :: rem -> + let mty = + match md.md_type with + Mty_alias _ when IdentSet.mem id excl -> + md.md_type + | mty -> + remove_aliases env excl mty + in + Sig_module(id, {md with md_type = mty} , rs) :: + remove_aliases_sig (Env.add_module id mty env) excl rem + | Sig_modtype(id, mtd) :: rem -> + Sig_modtype(id, mtd) :: + remove_aliases_sig (Env.add_modtype id mtd env) excl rem + | it :: rem -> + it :: remove_aliases_sig env excl rem -let untype_signature ?(mapper=default_mapper) signature = - mapper.signature mapper signature +let remove_aliases env sg = + let excl = collect_arg_paths sg in + (* PathSet.iter (fun p -> Format.eprintf "%a@ " Printtyp.path p) excl; + Format.eprintf "@."; *) + remove_aliases env excl sg + + +(* Lower non-generalizable type variables *) + +let lower_nongen nglev mty = + let open Btype in + let it_type_expr it ty = + let ty = repr ty in + match ty with + {desc=Tvar _; level} -> + if level < generic_level && level > nglev then set_level ty nglev + | _ -> + type_iterators.it_type_expr it ty + in + let it = {type_iterators with it_type_expr} in + it.it_module_type it mty; + it.it_module_type unmark_iterators mty end -module Parmatch : sig -#1 "parmatch.mli" +module Includemod : sig +#1 "includemod.mli" (**************************************************************************) (* *) (* OCaml *) @@ -67616,94 +66292,59 @@ module Parmatch : sig (* *) (**************************************************************************) -(* Detection of partial matches and unused match cases. *) -open Asttypes +(* Inclusion checks for the module language *) + open Typedtree open Types +open Format -val pretty_const : constant -> string -val top_pretty : Format.formatter -> pattern -> unit -val pretty_pat : pattern -> unit -val pretty_line : pattern list -> unit -val pretty_matrix : pattern list list -> unit - -val omega : pattern -val omegas : int -> pattern list -val omega_list : 'a list -> pattern list -val normalize_pat : pattern -> pattern -val all_record_args : - (Longident.t loc * label_description * pattern) list -> - (Longident.t loc * label_description * pattern) list -val const_compare : constant -> constant -> int - -val le_pat : pattern -> pattern -> bool -val le_pats : pattern list -> pattern list -> bool - -(* Exported compatibility functor, abstracted over constructor equality *) -module Compat : - functor - (Constr: sig - val equal : - Types.constructor_description -> - Types.constructor_description -> - bool - end) -> sig - val compat : pattern -> pattern -> bool - val compats : pattern list -> pattern list -> bool - end - -exception Empty -val lub : pattern -> pattern -> pattern -val lubs : pattern list -> pattern list -> pattern list +val modtypes: + loc:Location.t -> Env.t -> + module_type -> module_type -> module_coercion -val get_mins : ('a -> 'a -> bool) -> 'a list -> 'a list +val signatures: Env.t -> signature -> signature -> module_coercion -(* Those two functions recombine one pattern and its arguments: - For instance: - (_,_)::p1::p2::rem -> (p1, p2)::rem - The second one will replace mutable arguments by '_' -*) -val set_args : pattern -> pattern list -> pattern list -val set_args_erase_mutable : pattern -> pattern list -> pattern list +val compunit: + Env.t -> string -> signature -> string -> signature -> module_coercion -val pat_of_constr : pattern -> constructor_description -> pattern -val complete_constrs : - pattern -> constructor_tag list -> constructor_description list -val ppat_of_type : - Env.t -> type_expr -> - Parsetree.pattern * - (string, constructor_description) Hashtbl.t * - (string, label_description) Hashtbl.t +val type_declarations: + loc:Location.t -> Env.t -> + Ident.t -> type_declaration -> type_declaration -> unit -val pressure_variants: Env.t -> pattern list -> unit -val check_partial_gadt: - ((string, constructor_description) Hashtbl.t -> - (string, label_description) Hashtbl.t -> - Parsetree.pattern -> pattern option) -> - Location.t -> case list -> partial -val check_unused: - (bool -> - (string, constructor_description) Hashtbl.t -> - (string, label_description) Hashtbl.t -> - Parsetree.pattern -> pattern option) -> - case list -> unit +val print_coercion: formatter -> module_coercion -> unit -(* Irrefutability tests *) -val irrefutable : pattern -> bool +type symptom = + Missing_field of Ident.t * Location.t * string (* kind *) + | Value_descriptions of Ident.t * value_description * value_description + | Type_declarations of Ident.t * type_declaration + * type_declaration * Includecore.type_mismatch list + | Extension_constructors of + Ident.t * extension_constructor * extension_constructor + | Module_types of module_type * module_type + | Modtype_infos of Ident.t * modtype_declaration * modtype_declaration + | Modtype_permutation + | Interface_mismatch of string * string + | Class_type_declarations of + Ident.t * class_type_declaration * class_type_declaration * + Ctype.class_match_failure list + | Class_declarations of + Ident.t * class_declaration * class_declaration * + Ctype.class_match_failure list + | Unbound_modtype_path of Path.t + | Unbound_module_path of Path.t + | Invalid_module_alias of Path.t -(** An inactive pattern is a pattern, matching against which can be duplicated, erased or - delayed without change in observable behavior of the program. Patterns containing - (lazy _) subpatterns or reads of mutable fields are active. *) -val inactive : partial:partial -> pattern -> bool +type pos = + Module of Ident.t | Modtype of Ident.t | Arg of Ident.t | Body of Ident.t +type error = pos list * Env.t * symptom -(* Ambiguous bindings *) -val check_ambiguous_bindings : case list -> unit +exception Error of error list -(* The tag used for open polymorphic variant types *) -val some_other_tag : label +val report_error: formatter -> error list -> unit +val expand_module_alias: Env.t -> pos list -> Path.t -> Types.module_type end = struct -#1 "parmatch.ml" +#1 "includemod.ml" (**************************************************************************) (* *) (* OCaml *) @@ -67719,6512 +66360,6618 @@ end = struct (* *) (**************************************************************************) -(* Detection of partial matches and unused match cases. *) +(* Inclusion checks for the module language *) open Misc -open Asttypes -open Types +open Path open Typedtree +open Types -(*************************************) -(* Utilities for building patterns *) -(*************************************) +type symptom = + Missing_field of Ident.t * Location.t * string (* kind *) + | Value_descriptions of Ident.t * value_description * value_description + | Type_declarations of Ident.t * type_declaration + * type_declaration * Includecore.type_mismatch list + | Extension_constructors of + Ident.t * extension_constructor * extension_constructor + | Module_types of module_type * module_type + | Modtype_infos of Ident.t * modtype_declaration * modtype_declaration + | Modtype_permutation + | Interface_mismatch of string * string + | Class_type_declarations of + Ident.t * class_type_declaration * class_type_declaration * + Ctype.class_match_failure list + | Class_declarations of + Ident.t * class_declaration * class_declaration * + Ctype.class_match_failure list + | Unbound_modtype_path of Path.t + | Unbound_module_path of Path.t + | Invalid_module_alias of Path.t -let make_pat desc ty tenv = - {pat_desc = desc; pat_loc = Location.none; pat_extra = []; - pat_type = ty ; pat_env = tenv; - pat_attributes = []; - } +type pos = + Module of Ident.t | Modtype of Ident.t | Arg of Ident.t | Body of Ident.t +type error = pos list * Env.t * symptom -let omega = make_pat Tpat_any Ctype.none Env.empty +exception Error of error list -let extra_pat = - make_pat - (Tpat_var (Ident.create "+", mknoloc "+")) - Ctype.none Env.empty +(* All functions "blah env x1 x2" check that x1 is included in x2, + i.e. that x1 is the type of an implementation that fulfills the + specification x2. If not, Error is raised with a backtrace of the error. *) -let rec omegas i = - if i <= 0 then [] else omega :: omegas (i-1) +(* Inclusion between value descriptions *) -let omega_list l = List.map (fun _ -> omega) l +let value_descriptions ~loc env cxt subst id vd1 vd2 = + Cmt_format.record_value_dependency vd1 vd2; + Env.mark_value_used env (Ident.name id) vd1; + let vd2 = Subst.value_description subst vd2 in + try -let zero = make_pat (Tpat_constant (Const_int 0)) Ctype.none Env.empty + Includecore.value_descriptions ~loc env id vd1 vd2 + + with Includecore.Dont_match -> + raise(Error[cxt, env, Value_descriptions(id, vd1, vd2)]) -(*******************) -(* Coherence check *) -(*******************) +(* Inclusion between type declarations *) -(* For some of the operations we do in this module, we would like (because it - simplifies matters) to assume that patterns appearing on a given column in a - pattern matrix are /coherent/ (think "of the same type"). - Unfortunately that is not always true. +let type_declarations ~loc env ?(old_env=env) cxt subst id decl1 decl2 = + Env.mark_type_used env (Ident.name id) decl1; + let decl2 = Subst.type_declaration subst decl2 in + let err = + Includecore.type_declarations ~loc env (Ident.name id) decl1 id decl2 + in + if err <> [] then + raise(Error[cxt, old_env, Type_declarations(id, decl1, decl2, err)]) - Consider the following (well-typed) example: - {[ - type _ t = S : string t | U : unit t +(* Inclusion between extension constructors *) - let f (type a) (t1 : a t) (t2 : a t) (a : a) = - match t1, t2, a with - | U, _, () -> () - | _, S, "" -> () - ]} +let extension_constructors ~loc env cxt subst id ext1 ext2 = + let ext2 = Subst.extension_constructor subst ext2 in + if Includecore.extension_constructors ~loc env id ext1 ext2 + then () + else raise(Error[cxt, env, Extension_constructors(id, ext1, ext2)]) - Clearly the 3rd column contains incoherent patterns. +(* Inclusion between class declarations *) - On the example above, most of the algorithms will explore the pattern matrix - as illustrated by the following tree: +let class_type_declarations ~loc ~old_env env cxt subst id decl1 decl2 = + let decl2 = Subst.cltype_declaration subst decl2 in + match Includeclass.class_type_declarations ~loc env decl1 decl2 with + [] -> () + | reason -> + raise(Error[cxt, old_env, + Class_type_declarations(id, decl1, decl2, reason)]) - {v - S - -------> | "" | - U | S, "" | __/ | () | - --------> | _, () | \ ¬ S - | U, _, () | __/ -------> | () | - | _, S, "" | \ - ---------> | S, "" | ----------> | "" | - ¬ U S - v} +let class_declarations ~old_env env cxt subst id decl1 decl2 = + let decl2 = Subst.class_declaration subst decl2 in + match Includeclass.class_declarations env decl1 decl2 with + [] -> () + | reason -> + raise(Error[cxt, old_env, Class_declarations(id, decl1, decl2, reason)]) + +(* Expand a module type identifier when possible *) + +exception Dont_match + +let may_expand_module_path env path = + try ignore (Env.find_modtype_expansion path env); true + with Not_found -> false + +let expand_module_path env cxt path = + try + Env.find_modtype_expansion path env + with Not_found -> + raise(Error[cxt, env, Unbound_modtype_path path]) + +let expand_module_alias env cxt path = + try (Env.find_module path env).md_type + with Not_found -> + raise(Error[cxt, env, Unbound_module_path path]) + +(* +let rec normalize_module_path env cxt path = + match expand_module_alias env cxt path with + Mty_alias path' -> normalize_module_path env cxt path' + | _ -> path +*) + +(* Extract name, kind and ident from a signature item *) + +type field_desc = + Field_value of string + | Field_type of string + | Field_typext of string + | Field_module of string + | Field_modtype of string + | Field_class of string + | Field_classtype of string + +let kind_of_field_desc = function + | Field_value _ -> "value" + | Field_type _ -> "type" + | Field_typext _ -> "extension constructor" + | Field_module _ -> "module" + | Field_modtype _ -> "module type" + | Field_class _ -> "class" + | Field_classtype _ -> "class type" + +let item_ident_name = function + Sig_value(id, d) -> (id, d.val_loc, Field_value(Ident.name id)) + | Sig_type(id, d, _) -> (id, d.type_loc, Field_type(Ident.name id)) + | Sig_typext(id, d, _) -> (id, d.ext_loc, Field_typext(Ident.name id)) + | Sig_module(id, d, _) -> (id, d.md_loc, Field_module(Ident.name id)) + | Sig_modtype(id, d) -> (id, d.mtd_loc, Field_modtype(Ident.name id)) + | Sig_class(id, d, _) -> (id, d.cty_loc, Field_class(Ident.name id)) + | Sig_class_type(id, d, _) -> (id, d.clty_loc, Field_classtype(Ident.name id)) + +let is_runtime_component = function + | Sig_value(_,{val_kind = Val_prim _}) + | Sig_type(_,_,_) + | Sig_modtype(_,_) + | Sig_class_type(_,_,_) -> false + | Sig_value(_,_) + | Sig_typext(_,_,_) + | Sig_module(_,_,_) + | Sig_class(_, _,_) -> true + +(* Print a coercion *) + +let rec print_list pr ppf = function + [] -> () + | [a] -> pr ppf a + | a :: l -> pr ppf a; Format.fprintf ppf ";@ "; print_list pr ppf l +let print_list pr ppf l = + Format.fprintf ppf "[@[%a@]]" (print_list pr) l + +let rec print_coercion ppf c = + let pr fmt = Format.fprintf ppf fmt in + match c with + Tcoerce_none -> pr "id" + | Tcoerce_structure (fl, nl, _) -> + pr "@[<2>struct@ %a@ %a@]" + (print_list print_coercion2) fl + (print_list print_coercion3) nl + | Tcoerce_functor (inp, out) -> + pr "@[<2>functor@ (%a)@ (%a)@]" + print_coercion inp + print_coercion out + | Tcoerce_primitive {pc_desc; pc_env = _; pc_type} -> + pr "prim %s@ (%a)" pc_desc.Primitive.prim_name + Printtyp.raw_type_expr pc_type + | Tcoerce_alias (p, c) -> + pr "@[<2>alias %a@ (%a)@]" + Printtyp.path p + print_coercion c +and print_coercion2 ppf (n, c) = + Format.fprintf ppf "@[%d,@ %a@]" n print_coercion c +and print_coercion3 ppf (i, n, c) = + Format.fprintf ppf "@[%s, %d,@ %a@]" + (Ident.unique_name i) n print_coercion c + +(* Simplify a structure coercion *) + +let simplify_structure_coercion cc id_pos_list runtime_fields = + let rec is_identity_coercion pos = function + | [] -> + true + | (n, c) :: rem -> + n = pos && c = Tcoerce_none && is_identity_coercion (pos + 1) rem in + if is_identity_coercion 0 cc + then Tcoerce_none + else Tcoerce_structure (cc, id_pos_list, runtime_fields) + +(* Inclusion between module types. + Return the restriction that transforms a value of the smaller type + into a value of the bigger type. *) + +let rec modtypes ~loc env cxt subst mty1 mty2 = + try + try_modtypes ~loc env cxt subst mty1 mty2 + with + Dont_match -> + raise(Error[cxt, env, Module_types(mty1, Subst.modtype subst mty2)]) + | Error reasons as err -> + match mty1, mty2 with + Mty_alias _, _ + | _, Mty_alias _ -> raise err + | _ -> + raise(Error((cxt, env, Module_types(mty1, Subst.modtype subst mty2)) + :: reasons)) + +and try_modtypes ~loc env cxt subst mty1 mty2 = + match (mty1, mty2) with + | (Mty_alias(pres1, p1), Mty_alias(pres2, p2)) -> begin + if Env.is_functor_arg p2 env then + raise (Error[cxt, env, Invalid_module_alias p2]); + if not (Path.same p1 p2) then begin + let p1 = Env.normalize_path None env p1 + and p2 = Env.normalize_path None env (Subst.module_path subst p2) in + if not (Path.same p1 p2) then raise Dont_match + end; + match pres1, pres2 with + | Mta_present, Mta_present -> Tcoerce_none + (* Should really be Tcoerce_ignore if it existed *) + | Mta_absent, Mta_absent -> Tcoerce_none + (* Should really be Tcoerce_empty if it existed *) + | Mta_present, Mta_absent -> Tcoerce_none + | Mta_absent, Mta_present -> + let p1 = try + Env.normalize_path (Some Location.none) env p1 + with Env.Error (Env.Missing_module (_, _, path)) -> + raise (Error[cxt, env, Unbound_module_path path]) + in + Tcoerce_alias (p1, Tcoerce_none) + end + | (Mty_alias(pres1, p1), _) -> begin + let p1 = try + Env.normalize_path (Some Location.none) env p1 + with Env.Error (Env.Missing_module (_, _, path)) -> + raise (Error[cxt, env, Unbound_module_path path]) + in + let mty1 = + Mtype.strengthen ~aliasable:true env + (expand_module_alias env cxt p1) p1 + in + let cc = modtypes ~loc env cxt subst mty1 mty2 in + match pres1 with + | Mta_present -> cc + | Mta_absent -> Tcoerce_alias (p1, cc) + end + | (Mty_ident p1, _) when may_expand_module_path env p1 -> + try_modtypes ~loc env cxt subst (expand_module_path env cxt p1) mty2 + | (_, Mty_ident _) -> + try_modtypes2 ~loc env cxt mty1 (Subst.modtype subst mty2) + | (Mty_signature sig1, Mty_signature sig2) -> + signatures ~loc env cxt subst sig1 sig2 + | (Mty_functor(param1, None, res1), Mty_functor(_param2, None, res2)) -> + begin match modtypes ~loc env (Body param1::cxt) subst res1 res2 with + Tcoerce_none -> Tcoerce_none + | cc -> Tcoerce_functor (Tcoerce_none, cc) + end + | (Mty_functor(param1, Some arg1, res1), + Mty_functor(param2, Some arg2, res2)) -> + let arg2' = Subst.modtype subst arg2 in + let cc_arg = modtypes ~loc env (Arg param1::cxt) Subst.identity arg2' arg1 in + let cc_res = + modtypes ~loc (Env.add_module param1 arg2' env) (Body param1::cxt) + (Subst.add_module param2 (Pident param1) subst) res1 res2 in + begin match (cc_arg, cc_res) with + (Tcoerce_none, Tcoerce_none) -> Tcoerce_none + | _ -> Tcoerce_functor(cc_arg, cc_res) + end + | (_, _) -> + raise Dont_match + +and try_modtypes2 ~loc env cxt mty1 mty2 = + (* mty2 is an identifier *) + match (mty1, mty2) with + (Mty_ident p1, Mty_ident p2) + when Path.same (Env.normalize_path_prefix None env p1) + (Env.normalize_path_prefix None env p2) -> + Tcoerce_none + | (_, Mty_ident p2) when may_expand_module_path env p2 -> + try_modtypes ~loc env cxt Subst.identity mty1 (expand_module_path env cxt p2) + | (_, _) -> + raise Dont_match + +(* Inclusion between signatures *) + +and signatures ~loc env cxt subst sig1 sig2 = + (* Environment used to check inclusion of components *) + let new_env = + Env.add_signature sig1 (Env.in_signature true env) in + (* Keep ids for module aliases *) + let (id_pos_list,_) = + List.fold_left + (fun (l,pos) -> function + Sig_module (id, _, _) -> + ((id,pos,Tcoerce_none)::l , pos+1) + | item -> (l, if is_runtime_component item then pos+1 else pos)) + ([], 0) sig1 in + + let runtime_fields = + let get_id = function + | Sig_value (i,_) + | Sig_module (i,_,_) + | Sig_typext (i,_,_) + | Sig_modtype(i,_) + | Sig_class (i,_,_) + | Sig_class_type(i,_,_) + | Sig_type(i,_,_) -> Ident.name i in + List.fold_right (fun item fields -> + if is_runtime_component item then get_id item :: fields else fields) sig2 [] in - where following an edge labelled by a pattern P means "assuming the value I - am matching on is filtered by [P] on the column I am currently looking at, - then the following submatrix is still reachable". + (* Build a table of the components of sig1, along with their positions. + The table is indexed by kind and name of component *) + let rec build_component_table pos tbl = function + [] -> pos, tbl + | item :: rem -> + let (id, _loc, name) = item_ident_name item in + let nextpos = if is_runtime_component item then pos + 1 else pos in + build_component_table nextpos + (Tbl.add name (id, item, pos) tbl) rem in + let len1, comps1 = + build_component_table 0 Tbl.empty sig1 in + let len2 = + List.fold_left + (fun n i -> if is_runtime_component i then n + 1 else n) + 0 + sig2 + in + (* Pair each component of sig2 with a component of sig1, + identifying the names along the way. + Return a coercion list indicating, for all run-time components + of sig2, the position of the matching run-time components of sig1 + and the coercion to be applied to it. *) + let rec pair_components subst paired unpaired = function + [] -> + begin match unpaired with + [] -> + let cc = + signature_components ~loc env new_env cxt subst + (List.rev paired) + in + if len1 = len2 then (* see PR#5098 *) + simplify_structure_coercion cc id_pos_list runtime_fields + else + Tcoerce_structure (cc, id_pos_list, runtime_fields) + | _ -> raise(Error unpaired) + end + | item2 :: rem -> + let (id2, loc, name2) = item_ident_name item2 in + let name2, report = + match item2, name2 with + Sig_type (_, {type_manifest=None}, _), Field_type s + when Btype.is_row_name s -> + (* Do not report in case of failure, + as the main type will generate an error *) + Field_type (String.sub s 0 (String.length s - 4)), false + | _ -> name2, true + in + begin try + let (id1, item1, pos1) = Tbl.find name2 comps1 in + let new_subst = + match item2 with + Sig_type _ -> + Subst.add_type id2 (Pident id1) subst + | Sig_module _ -> + Subst.add_module id2 (Pident id1) subst + | Sig_modtype _ -> + Subst.add_modtype id2 (Mty_ident (Pident id1)) subst + | Sig_value _ | Sig_typext _ + | Sig_class _ | Sig_class_type _ -> + subst + in + pair_components new_subst + ((item1, item2, pos1) :: paired) unpaired rem + with Not_found -> + let unpaired = + if report then + (cxt, env, Missing_field (id2, loc, kind_of_field_desc name2)) :: + unpaired + else unpaired in + pair_components subst paired unpaired rem + end in + (* Do the pairing and checking, and return the final coercion *) + pair_components subst [] [] sig2 - Notice that at any point of that tree, if the first column of a matrix is - incoherent, then the branch leading to it can only be taken if the scrutinee - is ill-typed. - In the example above the only case where we have a matrix with an incoherent - first column is when we consider [t1, t2, a] to be [U, S, ...]. However such - a value would be ill-typed, so we can never actually get there. +(* Inclusion between signature components *) - Checking the first column at each step of the recursion and making the - concious decision of "aborting" the algorithm whenever the first column - becomes incoherent, allows us to retain the initial assumption in later - stages of the algorithms. +and signature_components ~loc old_env env cxt subst paired = + let comps_rec rem = signature_components ~loc old_env env cxt subst rem in + match paired with + [] -> [] + | (Sig_value(id1, valdecl1), Sig_value(_id2, valdecl2), pos) :: rem -> + let cc = value_descriptions ~loc env cxt subst id1 valdecl1 valdecl2 in + begin match valdecl2.val_kind with + Val_prim _ -> comps_rec rem + | _ -> (pos, cc) :: comps_rec rem + end + | (Sig_type(id1, tydecl1, _), Sig_type(_id2, tydecl2, _), _pos) :: rem -> + type_declarations ~loc ~old_env env cxt subst id1 tydecl1 tydecl2; + comps_rec rem + | (Sig_typext(id1, ext1, _), Sig_typext(_id2, ext2, _), pos) + :: rem -> + extension_constructors ~loc env cxt subst id1 ext1 ext2; + (pos, Tcoerce_none) :: comps_rec rem + | (Sig_module(id1, mty1, _), Sig_module(_id2, mty2, _), pos) :: rem -> + let cc = module_declarations ~loc env cxt subst id1 mty1 mty2 in + (pos, cc) :: comps_rec rem + | (Sig_modtype(id1, info1), Sig_modtype(_id2, info2), _pos) :: rem -> + modtype_infos ~loc env cxt subst id1 info1 info2; + comps_rec rem + | (Sig_class(id1, decl1, _), Sig_class(_id2, decl2, _), pos) :: rem -> + class_declarations ~old_env env cxt subst id1 decl1 decl2; + (pos, Tcoerce_none) :: comps_rec rem + | (Sig_class_type(id1, info1, _), + Sig_class_type(_id2, info2, _), _pos) :: rem -> + class_type_declarations ~loc ~old_env env cxt subst id1 info1 info2; + comps_rec rem + | _ -> + assert false - --- +and module_declarations ~loc env cxt subst id1 md1 md2 = + Builtin_attributes.check_deprecated_inclusion + ~def:md1.md_loc + ~use:md2.md_loc + loc + md1.md_attributes md2.md_attributes + (Ident.name id1); + let p1 = Pident id1 in + Env.mark_module_used env (Ident.name id1) md1.md_loc; + modtypes ~loc env (Module id1::cxt) subst + (Mtype.strengthen ~aliasable:true env md1.md_type p1) md2.md_type - N.B. two patterns can be considered coherent even though they might not be of - the same type. +(* Inclusion between module type specifications *) - That's in part because we only care about the "head" of patterns and leave - checking coherence of subpatterns for the next steps of the algorithm: - ('a', 'b') and (1, ()) will be deemed coherent because they are both a tuples - of arity 2 (we'll notice at a later stage the incoherence of 'a' and 1). +and modtype_infos ~loc env cxt subst id info1 info2 = + Builtin_attributes.check_deprecated_inclusion + ~def:info1.mtd_loc + ~use:info2.mtd_loc + loc + info1.mtd_attributes info2.mtd_attributes + (Ident.name id); + let info2 = Subst.modtype_declaration subst info2 in + let cxt' = Modtype id :: cxt in + try + match (info1.mtd_type, info2.mtd_type) with + (None, None) -> () + | (Some _, None) -> () + | (Some mty1, Some mty2) -> + check_modtype_equiv ~loc env cxt' mty1 mty2 + | (None, Some mty2) -> + check_modtype_equiv ~loc env cxt' (Mty_ident(Pident id)) mty2 + with Error reasons -> + raise(Error((cxt, env, Modtype_infos(id, info1, info2)) :: reasons)) - But also because it can be hard/costly to determine exactly whether two - patterns are of the same type or not (eg. in the example above with _ and S, - but see also the module [Coherence_illustration] in - testsuite/tests/basic-more/robustmatch.ml). +and check_modtype_equiv ~loc env cxt mty1 mty2 = + match + (modtypes ~loc env cxt Subst.identity mty1 mty2, + modtypes ~loc env cxt Subst.identity mty2 mty1) + with + (Tcoerce_none, Tcoerce_none) -> () + | (_c1, _c2) -> + (* Format.eprintf "@[c1 = %a@ c2 = %a@]@." + print_coercion _c1 print_coercion _c2; *) + raise(Error [cxt, env, Modtype_permutation]) - For the moment our weak, loosely-syntactic, coherence check seems to be - enough and we leave it to each user to consider (and document!) what happens - when an "incoherence" is not detected by this check. -*) +(* Simplified inclusion check between module types (for Env) *) +let can_alias env path = + let rec no_apply = function + | Pident _ -> true + | Pdot(p, _, _) -> no_apply p + | Papply _ -> false + in + no_apply path && not (Env.is_functor_arg path env) -let simplify_head_pat p k = - let rec simplify_head_pat p k = - match p.pat_desc with - | Tpat_alias (p,_,_) -> simplify_head_pat p k - | Tpat_var (_,_) -> omega :: k - | Tpat_or (p1,p2,_) -> simplify_head_pat p1 (simplify_head_pat p2 k) - | _ -> p :: k - in simplify_head_pat p k +let check_modtype_inclusion ~loc env mty1 path1 mty2 = + try + let aliasable = can_alias env path1 in + ignore(modtypes ~loc env [] Subst.identity + (Mtype.strengthen ~aliasable env mty1 path1) mty2) + with Error _ -> + raise Not_found -let rec simplified_first_col = function - | [] -> [] - | [] :: _ -> assert false (* the rows are non-empty! *) - | (p::_) :: rows -> - simplify_head_pat p (simplified_first_col rows) +let _ = Env.check_modtype_inclusion := check_modtype_inclusion -(* Given the simplified first column of a matrix, this function first looks for - a "discriminating" pattern on that column (i.e. a non-omega one) and then - check that every other head pattern in the column is coherent with that one. -*) -let all_coherent column = - let coherent_heads hp1 hp2 = - match hp1.pat_desc, hp2.pat_desc with - | (Tpat_var _ | Tpat_alias _ | Tpat_or _), _ - | _, (Tpat_var _ | Tpat_alias _ | Tpat_or _) -> - assert false - | Tpat_construct (_, c, _), Tpat_construct (_, c', _) -> - c.cstr_consts = c'.cstr_consts - && c.cstr_nonconsts = c'.cstr_nonconsts - | Tpat_constant c1, Tpat_constant c2 -> begin - match c1, c2 with - | Const_char _, Const_char _ - | Const_int _, Const_int _ - | Const_int32 _, Const_int32 _ - | Const_int64 _, Const_int64 _ - | Const_nativeint _, Const_nativeint _ - | Const_float _, Const_float _ - | Const_string _, Const_string _ -> true - | ( Const_char _ - | Const_int _ - | Const_int32 _ - | Const_int64 _ - | Const_nativeint _ - | Const_float _ - | Const_string _), _ -> false - end - | Tpat_tuple l1, Tpat_tuple l2 -> List.length l1 = List.length l2 - | Tpat_record ((_, lbl1, _) :: _, _), Tpat_record ((_, lbl2, _) :: _, _) -> - Array.length lbl1.lbl_all = Array.length lbl2.lbl_all - | Tpat_any, _ - | _, Tpat_any - | Tpat_record ([], _), Tpat_record (_, _) - | Tpat_record (_, _), Tpat_record ([], _) - | Tpat_variant _, Tpat_variant _ - | Tpat_array _, Tpat_array _ - | Tpat_lazy _, Tpat_lazy _ -> true - | _, _ -> false - in - match - List.find (fun head_pat -> - match head_pat.pat_desc with - | Tpat_var _ | Tpat_alias _ | Tpat_or _ -> assert false - | Tpat_any -> false - | _ -> true - ) column - with - | exception Not_found -> - (* only omegas on the column: the column is coherent. *) - true - | discr_pat -> - List.for_all (coherent_heads discr_pat) column +(* Check that an implementation of a compilation unit meets its + interface. *) -let first_column simplified_matrix = - List.map fst simplified_matrix +let compunit env impl_name impl_sig intf_name intf_sig = + try + signatures ~loc:(Location.in_file impl_name) env [] Subst.identity + impl_sig intf_sig + with Error reasons -> + raise(Error(([], Env.empty,Interface_mismatch(impl_name, intf_name)) + :: reasons)) -(***********************) -(* Compatibility check *) -(***********************) +(* Hide the context and substitution parameters to the outside world *) -(* Patterns p and q compatible means: - there exists value V that matches both, However.... +let modtypes ~loc env mty1 mty2 = modtypes ~loc env [] Subst.identity mty1 mty2 +let signatures env sig1 sig2 = + signatures ~loc:Location.none env [] Subst.identity sig1 sig2 +let type_declarations ~loc env id decl1 decl2 = + type_declarations ~loc env [] Subst.identity id decl1 decl2 - The case of extension types is dubious, as constructor rebind permits - that different constructors are the same (and are thus compatible). +(* +let modtypes env m1 m2 = + let c = modtypes env m1 m2 in + Format.eprintf "@[<2>modtypes@ %a@ %a =@ %a@]@." + Printtyp.modtype m1 Printtyp.modtype m2 + print_coercion c; + c +*) - Compilation must take this into account, consider: +(* Error report *) - type t = .. - type t += A|B - type t += C=A +open Format +open Printtyp - let f x y = match x,y with - | true,A -> '1' - | _,C -> '2' - | false,A -> '3' - | _,_ -> '_' +let show_loc msg ppf loc = + let pos = loc.Location.loc_start in + if List.mem pos.Lexing.pos_fname [""; "_none_"; "//toplevel//"] then () + else fprintf ppf "@\n@[<2>%a:@ %s@]" Location.print_loc loc msg - As C is bound to A the value of f false A is '2' (and not '3' as it would - be in the absence of rebinding). +let show_locs ppf (loc1, loc2) = + show_loc "Expected declaration" ppf loc2; + show_loc "Actual declaration" ppf loc1 - Not considering rebinding, patterns "false,A" and "_,C" are incompatible - and the compiler can swap the second and third clause, resulting in the - (more efficiently compiled) matching +let include_err ppf = function + | Missing_field (id, loc, kind) -> + fprintf ppf "The %s `%a' is required but not provided" kind ident id; + show_loc "Expected declaration" ppf loc + | Value_descriptions(id, d1, d2) -> + fprintf ppf + "@[Values do not match:@ %a@;<1 -2>is not included in@ %a@]" + (value_description id) d1 (value_description id) d2; + show_locs ppf (d1.val_loc, d2.val_loc); + | Type_declarations(id, d1, d2, errs) -> + fprintf ppf "@[@[%s:@;<1 2>%a@ %s@;<1 2>%a@]%a%a@]" + "Type declarations do not match" + (type_declaration id) d1 + "is not included in" + (type_declaration id) d2 + show_locs (d1.type_loc, d2.type_loc) + (Includecore.report_type_mismatch + "the first" "the second" "declaration") errs + | Extension_constructors(id, x1, x2) -> + fprintf ppf + "@[Extension declarations do not match:@ \ + %a@;<1 -2>is not included in@ %a@]" + (extension_constructor id) x1 + (extension_constructor id) x2; + show_locs ppf (x1.ext_loc, x2.ext_loc) + | Module_types(mty1, mty2)-> + fprintf ppf + "@[Modules do not match:@ \ + %a@;<1 -2>is not included in@ %a@]" + modtype mty1 + modtype mty2 + | Modtype_infos(id, d1, d2) -> + fprintf ppf + "@[Module type declarations do not match:@ \ + %a@;<1 -2>does not match@ %a@]" + (modtype_declaration id) d1 + (modtype_declaration id) d2 + | Modtype_permutation -> + fprintf ppf "Illegal permutation of structure fields" + | Interface_mismatch(impl_name, intf_name) -> + fprintf ppf "@[The implementation %s@ does not match the interface %s:" + impl_name intf_name + | Class_type_declarations(id, d1, d2, reason) -> + fprintf ppf + "@[Class type declarations do not match:@ \ + %a@;<1 -2>does not match@ %a@]@ %a" + (Printtyp.cltype_declaration id) d1 + (Printtyp.cltype_declaration id) d2 + Includeclass.report_error reason + | Class_declarations(id, d1, d2, reason) -> + fprintf ppf + "@[Class declarations do not match:@ \ + %a@;<1 -2>does not match@ %a@]@ %a" + (Printtyp.class_declaration id) d1 + (Printtyp.class_declaration id) d2 + Includeclass.report_error reason + | Unbound_modtype_path path -> + fprintf ppf "Unbound module type %a" Printtyp.path path + | Unbound_module_path path -> + fprintf ppf "Unbound module %a" Printtyp.path path + | Invalid_module_alias path -> + fprintf ppf "Module %a cannot be aliased" Printtyp.path path - match x,y with - | true,A -> '1' - | false,A -> '3' - | _,C -> '2' - | _,_ -> '_' +let rec context ppf = function + Module id :: rem -> + fprintf ppf "@[<2>module %a%a@]" ident id args rem + | Modtype id :: rem -> + fprintf ppf "@[<2>module type %a =@ %a@]" ident id context_mty rem + | Body x :: rem -> + fprintf ppf "functor (%s) ->@ %a" (argname x) context_mty rem + | Arg x :: rem -> + fprintf ppf "functor (%a : %a) -> ..." ident x context_mty rem + | [] -> + fprintf ppf "" +and context_mty ppf = function + (Module _ | Modtype _) :: _ as rem -> + fprintf ppf "@[<2>sig@ %a@;<1 -2>end@]" context rem + | cxt -> context ppf cxt +and args ppf = function + Body x :: rem -> + fprintf ppf "(%s)%a" (argname x) args rem + | Arg x :: rem -> + fprintf ppf "(%a :@ %a) : ..." ident x context_mty rem + | cxt -> + fprintf ppf " :@ %a" context_mty cxt +and argname x = + let s = Ident.name x in + if s = "*" then "" else s - This is not correct: when C is bound to A, "f false A" returns '2' (not '3') +let path_of_context = function + Module id :: rem -> + let rec subm path = function + [] -> path + | Module id :: rem -> subm (Pdot (path, Ident.name id, -1)) rem + | _ -> assert false + in subm (Pident id) rem + | _ -> assert false +let context ppf cxt = + if cxt = [] then () else + if List.for_all (function Module _ -> true | _ -> false) cxt then + fprintf ppf "In module %a:@ " path (path_of_context cxt) + else + fprintf ppf "@[At position@ %a@]@ " context cxt - However, diagnostics do not take constructor rebinding into account. - Notice, that due to module abstraction constructor rebinding is hidden. +let include_err ppf (cxt, env, err) = + Printtyp.wrap_printing_env env (fun () -> + fprintf ppf "@[%a%a@]" context (List.rev cxt) include_err err) - module X : sig type t = .. type t += A|B end = struct - type t = .. - type t += A - type t += B=A +let buffer = ref Bytes.empty +let is_big obj = + let size = !Clflags.error_size in + size > 0 && + begin + if Bytes.length !buffer < size then buffer := Bytes.create size; + try ignore (Marshal.to_buffer !buffer 0 size obj []); false + with _ -> true end - open X +let report_error ppf errs = + if errs = [] then () else + let (errs , err) = split_last errs in + let pe = ref true in + let include_err' ppf (_,_,obj as err) = + if not (is_big obj) then fprintf ppf "%a@ " include_err err + else if !pe then (fprintf ppf "...@ "; pe := false) + in + let print_errs ppf = List.iter (include_err' ppf) in + fprintf ppf "@[%a%a@]" print_errs errs include_err err - let f x = match x with - | A -> '1' - | B -> '2' - | _ -> '_' - The second clause above will NOT (and cannot) be flagged as useless. +(* We could do a better job to split the individual error items + as sub-messages of the main interface mismatch on the whole unit. *) +let () = + Location.register_error_of_exn + (function + | Error err -> Some (Location.error_of_printer_file report_error err) + | _ -> None + ) - Finally, there are two compatibility fonction - compat p q ---> 'syntactic compatibility, used for diagnostics. - may_compat p q ---> a safe approximation of possible compat, - for compilation +end +module Stypes : sig +#1 "stypes.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Damien Doligez, projet Moscova, INRIA Rocquencourt *) +(* *) +(* Copyright 2003 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -*) +(* Recording and dumping (partial) type information *) +(* Clflags.save_types must be true *) -let is_absent tag row = Btype.row_field tag !row = Rabsent +open Typedtree;; -let is_absent_pat p = match p.pat_desc with -| Tpat_variant (tag, _, row) -> is_absent tag row -| _ -> false +type annotation = + | Ti_pat of pattern + | Ti_expr of expression + | Ti_class of class_expr + | Ti_mod of module_expr + | An_call of Location.t * Annot.call + | An_ident of Location.t * string * Annot.ident +;; -let const_compare x y = - match x,y with - | Const_float f1, Const_float f2 -> - Pervasives.compare (float_of_string f1) (float_of_string f2) - | Const_string (s1, _), Const_string (s2, _) -> - String.compare s1 s2 - | _, _ -> Pervasives.compare x y +val record : annotation -> unit;; +val record_phrase : Location.t -> unit;; +val dump : string option -> unit;; + +val get_location : annotation -> Location.t;; +val get_info : unit -> annotation list;; -let records_args l1 l2 = - (* Invariant: fields are already sorted by Typecore.type_label_a_list *) - let rec combine r1 r2 l1 l2 = match l1,l2 with - | [],[] -> List.rev r1, List.rev r2 - | [],(_,_,p2)::rem2 -> combine (omega::r1) (p2::r2) [] rem2 - | (_,_,p1)::rem1,[] -> combine (p1::r1) (omega::r2) rem1 [] - | (_,lbl1,p1)::rem1, ( _,lbl2,p2)::rem2 -> - if lbl1.lbl_pos < lbl2.lbl_pos then - combine (p1::r1) (omega::r2) rem1 l2 - else if lbl1.lbl_pos > lbl2.lbl_pos then - combine (omega::r1) (p2::r2) l1 rem2 - else (* same label on both sides *) - combine (p1::r1) (p2::r2) rem1 rem2 in - combine [] [] l1 l2 +end = struct +#1 "stypes.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Damien Doligez, projet Moscova, INRIA Rocquencourt *) +(* *) +(* Copyright 2003 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) +(* Recording and dumping (partial) type information *) +(* + We record all types in a list as they are created. + This means we can dump type information even if type inference fails, + which is extremely important, since type information is most + interesting in case of errors. +*) -module Compat - (Constr:sig - val equal : - Types.constructor_description -> - Types.constructor_description -> - bool - end) = struct +open Annot;; +open Lexing;; +open Location;; +open Typedtree;; - let rec compat p q = match p.pat_desc,q.pat_desc with -(* Variables match any value *) - | ((Tpat_any|Tpat_var _),_) - | (_,(Tpat_any|Tpat_var _)) -> true -(* Structural induction *) - | Tpat_alias (p,_,_),_ -> compat p q - | _,Tpat_alias (q,_,_) -> compat p q - | Tpat_or (p1,p2,_),_ -> - (compat p1 q || compat p2 q) - | _,Tpat_or (q1,q2,_) -> - (compat p q1 || compat p q2) -(* Constructors, with special case for extension *) - | Tpat_construct (_, c1,ps1), Tpat_construct (_, c2,ps2) -> - Constr.equal c1 c2 && compats ps1 ps2 -(* More standard stuff *) - | Tpat_variant(l1,op1, _), Tpat_variant(l2,op2,_) -> - l1=l2 && ocompat op1 op2 - | Tpat_constant c1, Tpat_constant c2 -> - const_compare c1 c2 = 0 - | Tpat_tuple ps, Tpat_tuple qs -> compats ps qs - | Tpat_lazy p, Tpat_lazy q -> compat p q - | Tpat_record (l1,_),Tpat_record (l2,_) -> - let ps,qs = records_args l1 l2 in - compats ps qs - | Tpat_array ps, Tpat_array qs -> - List.length ps = List.length qs && - compats ps qs - | _,_ -> false +let output_int oc i = output_string oc (string_of_int i) - and ocompat op oq = match op,oq with - | None,None -> true - | Some p,Some q -> compat p q - | (None,Some _)|(Some _,None) -> false +type annotation = + | Ti_pat of pattern + | Ti_expr of expression + | Ti_class of class_expr + | Ti_mod of module_expr + | An_call of Location.t * Annot.call + | An_ident of Location.t * string * Annot.ident +;; - and compats ps qs = match ps,qs with - | [], [] -> true - | p::ps, q::qs -> compat p q && compats ps qs - | _,_ -> false +let get_location ti = + match ti with + Ti_pat p -> p.pat_loc + | Ti_expr e -> e.exp_loc + | Ti_class c -> c.cl_loc + | Ti_mod m -> m.mod_loc + | An_call (l, _k) -> l + | An_ident (l, _s, _k) -> l +;; -end +let annotations = ref ([] : annotation list);; +let phrases = ref ([] : Location.t list);; -module SyntacticCompat = - Compat - (struct - let equal c1 c2 = Types.equal_tag c1.cstr_tag c2.cstr_tag - end) +let record ti = + if !Clflags.annotations && not (get_location ti).Location.loc_ghost then + annotations := ti :: !annotations +;; -let compat = SyntacticCompat.compat -and compats = SyntacticCompat.compats +let record_phrase loc = + if !Clflags.annotations then phrases := loc :: !phrases; +;; -(* Due to (potential) rebinding, two extension constructors - of the same arity type may equal *) +(* comparison order: + the intervals are sorted by order of increasing upper bound + same upper bound -> sorted by decreasing lower bound +*) +let cmp_loc_inner_first loc1 loc2 = + match compare loc1.loc_end.pos_cnum loc2.loc_end.pos_cnum with + | 0 -> compare loc2.loc_start.pos_cnum loc1.loc_start.pos_cnum + | x -> x +;; +let cmp_ti_inner_first ti1 ti2 = + cmp_loc_inner_first (get_location ti1) (get_location ti2) +;; -exception Empty (* Empty pattern *) +let print_position pp pos = + if pos = dummy_pos then + output_string pp "--" + else begin + output_char pp '\"'; + output_string pp (String.escaped pos.pos_fname); + output_string pp "\" "; + output_int pp pos.pos_lnum; + output_char pp ' '; + output_int pp pos.pos_bol; + output_char pp ' '; + output_int pp pos.pos_cnum; + end +;; -(****************************************) -(* Utilities for retrieving type paths *) -(****************************************) +let print_location pp loc = + print_position pp loc.loc_start; + output_char pp ' '; + print_position pp loc.loc_end; +;; -(* May need a clean copy, cf. PR#4745 *) -let clean_copy ty = - if ty.level = Btype.generic_level then ty - else Subst.type_expr Subst.identity ty +let sort_filter_phrases () = + let ph = List.sort (fun x y -> cmp_loc_inner_first y x) !phrases in + let rec loop accu cur l = + match l with + | [] -> accu + | loc :: t -> + if cur.loc_start.pos_cnum <= loc.loc_start.pos_cnum + && cur.loc_end.pos_cnum >= loc.loc_end.pos_cnum + then loop accu cur t + else loop (loc :: accu) loc t + in + phrases := loop [] Location.none ph; +;; -let get_type_path ty tenv = - let ty = Ctype.repr (Ctype.expand_head tenv (clean_copy ty)) in - match ty.desc with - | Tconstr (path,_,_) -> path - | _ -> fatal_error "Parmatch.get_type_path" +let rec printtyp_reset_maybe loc = + match !phrases with + | cur :: t when cur.loc_start.pos_cnum <= loc.loc_start.pos_cnum -> + Printtyp.reset (); + phrases := t; + printtyp_reset_maybe loc; + | _ -> () +;; -(*************************************) -(* Values as patterns pretty printer *) -(*************************************) +let call_kind_string k = + match k with + | Tail -> "tail" + | Stack -> "stack" + | Inline -> "inline" +;; -open Format +let print_ident_annot pp str k = + match k with + | Idef l -> + output_string pp "def "; + output_string pp str; + output_char pp ' '; + print_location pp l; + output_char pp '\n' + | Iref_internal l -> + output_string pp "int_ref "; + output_string pp str; + output_char pp ' '; + print_location pp l; + output_char pp '\n' + | Iref_external -> + output_string pp "ext_ref "; + output_string pp str; + output_char pp '\n' ;; -let is_cons = function -| {cstr_name = "::"} -> true -| _ -> false +(* The format of the annotation file is documented in emacs/caml-types.el. *) -let pretty_const c = match c with -| Const_int i -> Printf.sprintf "%d" i -| Const_char c -> Printf.sprintf "%C" c -| Const_string (s, _) -> Printf.sprintf "%S" s -| Const_float f -> Printf.sprintf "%s" f -| Const_int32 i -> Printf.sprintf "%ldl" i -| Const_int64 i -> Printf.sprintf "%LdL" i -| Const_nativeint i -> Printf.sprintf "%ndn" i +let print_info pp prev_loc ti = + match ti with + | Ti_class _ | Ti_mod _ -> prev_loc + | Ti_pat {pat_loc = loc; pat_type = typ; pat_env = env} + | Ti_expr {exp_loc = loc; exp_type = typ; exp_env = env} -> + if loc <> prev_loc then begin + print_location pp loc; + output_char pp '\n' + end; + output_string pp "type(\n"; + printtyp_reset_maybe loc; + Printtyp.mark_loops typ; + Format.pp_print_string Format.str_formatter " "; + Printtyp.wrap_printing_env env + (fun () -> Printtyp.type_sch Format.str_formatter typ); + Format.pp_print_newline Format.str_formatter (); + let s = Format.flush_str_formatter () in + output_string pp s; + output_string pp ")\n"; + loc + | An_call (loc, k) -> + if loc <> prev_loc then begin + print_location pp loc; + output_char pp '\n' + end; + output_string pp "call(\n "; + output_string pp (call_kind_string k); + output_string pp "\n)\n"; + loc + | An_ident (loc, str, k) -> + if loc <> prev_loc then begin + print_location pp loc; + output_char pp '\n' + end; + output_string pp "ident(\n "; + print_ident_annot pp str k; + output_string pp ")\n"; + loc +;; -let rec pretty_val ppf v = - match v.pat_extra with - (cstr, _loc, _attrs) :: rem -> - begin match cstr with - | Tpat_unpack -> - fprintf ppf "@[(module %a)@]" pretty_val { v with pat_extra = rem } - | Tpat_constraint _ -> - fprintf ppf "@[(%a : _)@]" pretty_val { v with pat_extra = rem } - | Tpat_type _ -> - fprintf ppf "@[(# %a)@]" pretty_val { v with pat_extra = rem } - | Tpat_open _ -> - fprintf ppf "@[(# %a)@]" pretty_val { v with pat_extra = rem } - end - | [] -> - match v.pat_desc with - | Tpat_any -> fprintf ppf "_" - | Tpat_var (x,_) -> fprintf ppf "%s" (Ident.name x) - | Tpat_constant c -> fprintf ppf "%s" (pretty_const c) - | Tpat_tuple vs -> - fprintf ppf "@[(%a)@]" (pretty_vals ",") vs - | Tpat_construct (_, cstr, []) -> - fprintf ppf "%s" cstr.cstr_name - | Tpat_construct (_, cstr, [w]) -> - fprintf ppf "@[<2>%s@ %a@]" cstr.cstr_name pretty_arg w - | Tpat_construct (_, cstr, vs) -> - let name = cstr.cstr_name in - begin match (name, vs) with - ("::", [v1;v2]) -> - fprintf ppf "@[%a::@,%a@]" pretty_car v1 pretty_cdr v2 - | _ -> - fprintf ppf "@[<2>%s@ @[(%a)@]@]" name (pretty_vals ",") vs - end - | Tpat_variant (l, None, _) -> - fprintf ppf "`%s" l - | Tpat_variant (l, Some w, _) -> - fprintf ppf "@[<2>`%s@ %a@]" l pretty_arg w - | Tpat_record (lvs,_) -> - let filtered_lvs = List.filter - (function - | (_,_,{pat_desc=Tpat_any}) -> false (* do not show lbl=_ *) - | _ -> true) lvs in - begin match filtered_lvs with - | [] -> fprintf ppf "_" - | (_, lbl, _) :: q -> - let elision_mark ppf = - (* we assume that there is no label repetitions here *) - if Array.length lbl.lbl_all > 1 + List.length q then - fprintf ppf ";@ _@ " - else () in - fprintf ppf "@[{%a%t}@]" - pretty_lvals filtered_lvs elision_mark - end - | Tpat_array vs -> - fprintf ppf "@[[| %a |]@]" (pretty_vals " ;") vs - | Tpat_lazy v -> - fprintf ppf "@[<2>lazy@ %a@]" pretty_arg v - | Tpat_alias (v, x,_) -> - fprintf ppf "@[(%a@ as %a)@]" pretty_val v Ident.print x - | Tpat_or (v,w,_) -> - fprintf ppf "@[(%a|@,%a)@]" pretty_or v pretty_or w +let get_info () = + let info = List.fast_sort cmp_ti_inner_first !annotations in + annotations := []; + info +;; -and pretty_car ppf v = match v.pat_desc with -| Tpat_construct (_,cstr, [_ ; _]) - when is_cons cstr -> - fprintf ppf "(%a)" pretty_val v -| _ -> pretty_val ppf v +let dump filename = + if !Clflags.annotations then begin + let do_dump _temp_filename pp = + let info = get_info () in + sort_filter_phrases (); + ignore (List.fold_left (print_info pp) Location.none info) in + begin match filename with + | None -> do_dump "" stdout + | Some filename -> + Misc.output_to_file_via_temporary ~mode:[Open_text] filename do_dump + end; + phrases := []; + end else begin + annotations := []; + end; +;; -and pretty_cdr ppf v = match v.pat_desc with -| Tpat_construct (_,cstr, [v1 ; v2]) - when is_cons cstr -> - fprintf ppf "%a::@,%a" pretty_car v1 pretty_cdr v2 -| _ -> pretty_val ppf v +end +module TypedtreeIter : sig +#1 "typedtreeIter.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Thomas Gazagnaire (OCamlPro), Fabrice Le Fessant (INRIA Saclay) *) +(* *) +(* Copyright 2007 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -and pretty_arg ppf v = match v.pat_desc with -| Tpat_construct (_,_,_::_) -| Tpat_variant (_, Some _, _) -> fprintf ppf "(%a)" pretty_val v -| _ -> pretty_val ppf v +open Asttypes +open Typedtree -and pretty_or ppf v = match v.pat_desc with -| Tpat_or (v,w,_) -> - fprintf ppf "%a|@,%a" pretty_or v pretty_or w -| _ -> pretty_val ppf v -and pretty_vals sep ppf = function - | [] -> () - | [v] -> pretty_val ppf v - | v::vs -> - fprintf ppf "%a%s@ %a" pretty_val v sep (pretty_vals sep) vs +module type IteratorArgument = sig + val enter_structure : structure -> unit + val enter_value_description : value_description -> unit + val enter_type_extension : type_extension -> unit + val enter_extension_constructor : extension_constructor -> unit + val enter_pattern : pattern -> unit + val enter_expression : expression -> unit + val enter_package_type : package_type -> unit + val enter_signature : signature -> unit + val enter_signature_item : signature_item -> unit + val enter_module_type_declaration : module_type_declaration -> unit + val enter_module_type : module_type -> unit + val enter_module_expr : module_expr -> unit + val enter_with_constraint : with_constraint -> unit + val enter_class_expr : class_expr -> unit + val enter_class_signature : class_signature -> unit + val enter_class_declaration : class_declaration -> unit + val enter_class_description : class_description -> unit + val enter_class_type_declaration : class_type_declaration -> unit + val enter_class_type : class_type -> unit + val enter_class_type_field : class_type_field -> unit + val enter_core_type : core_type -> unit + val enter_class_structure : class_structure -> unit + val enter_class_field : class_field -> unit + val enter_structure_item : structure_item -> unit -and pretty_lvals ppf = function - | [] -> () - | [_,lbl,v] -> - fprintf ppf "%s=%a" lbl.lbl_name pretty_val v - | (_, lbl,v)::rest -> - fprintf ppf "%s=%a;@ %a" - lbl.lbl_name pretty_val v pretty_lvals rest -let top_pretty ppf v = - fprintf ppf "@[%a@]@?" pretty_val v + val leave_structure : structure -> unit + val leave_value_description : value_description -> unit + val leave_type_extension : type_extension -> unit + val leave_extension_constructor : extension_constructor -> unit + val leave_pattern : pattern -> unit + val leave_expression : expression -> unit + val leave_package_type : package_type -> unit + val leave_signature : signature -> unit + val leave_signature_item : signature_item -> unit + val leave_module_type_declaration : module_type_declaration -> unit + val leave_module_type : module_type -> unit + val leave_module_expr : module_expr -> unit + val leave_with_constraint : with_constraint -> unit + val leave_class_expr : class_expr -> unit + val leave_class_signature : class_signature -> unit + val leave_class_declaration : class_declaration -> unit + val leave_class_description : class_description -> unit + val leave_class_type_declaration : class_type_declaration -> unit + val leave_class_type : class_type -> unit + val leave_class_type_field : class_type_field -> unit + val leave_core_type : core_type -> unit + val leave_class_structure : class_structure -> unit + val leave_class_field : class_field -> unit + val leave_structure_item : structure_item -> unit + val enter_bindings : rec_flag -> unit + val enter_binding : value_binding -> unit + val leave_binding : value_binding -> unit + val leave_bindings : rec_flag -> unit -let pretty_pat p = - top_pretty Format.str_formatter p ; - prerr_string (Format.flush_str_formatter ()) + val enter_type_declarations : rec_flag -> unit + val enter_type_declaration : type_declaration -> unit + val leave_type_declaration : type_declaration -> unit + val leave_type_declarations : rec_flag -> unit -type matrix = pattern list list +end -let pretty_line ps = - List.iter - (fun p -> - top_pretty Format.str_formatter p ; - prerr_string " <" ; - prerr_string (Format.flush_str_formatter ()) ; - prerr_string ">") - ps +module MakeIterator : + functor (Iter : IteratorArgument) -> + sig + val iter_structure : structure -> unit + val iter_signature : signature -> unit + val iter_structure_item : structure_item -> unit + val iter_signature_item : signature_item -> unit + val iter_expression : expression -> unit + val iter_module_type : module_type -> unit + val iter_pattern : pattern -> unit + val iter_class_expr : class_expr -> unit + end -let pretty_matrix (pss : matrix) = - prerr_endline "begin matrix" ; - List.iter - (fun ps -> - pretty_line ps ; - prerr_endline "") - pss ; - prerr_endline "end matrix" +module DefaultIteratorArgument : IteratorArgument +end = struct +#1 "typedtreeIter.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Thomas Gazagnaire (OCamlPro), Fabrice Le Fessant (INRIA Saclay) *) +(* *) +(* Copyright 2007 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -(****************************) -(* Utilities for matching *) -(****************************) +(* +TODO: + - 2012/05/10: Follow camlp4 way of building map and iter using classes + and inheritance ? +*) -(* Check top matching *) -let simple_match p1 p2 = - match p1.pat_desc, p2.pat_desc with - | Tpat_construct(_, c1, _), Tpat_construct(_, c2, _) -> - Types.equal_tag c1.cstr_tag c2.cstr_tag - | Tpat_variant(l1, _, _), Tpat_variant(l2, _, _) -> - l1 = l2 - | Tpat_constant(c1), Tpat_constant(c2) -> const_compare c1 c2 = 0 - | Tpat_lazy _, Tpat_lazy _ -> true - | Tpat_record _ , Tpat_record _ -> true - | Tpat_tuple p1s, Tpat_tuple p2s - | Tpat_array p1s, Tpat_array p2s -> List.length p1s = List.length p2s - | _, (Tpat_any | Tpat_var(_)) -> true - | _, _ -> false +open Asttypes +open Typedtree +module type IteratorArgument = sig + val enter_structure : structure -> unit + val enter_value_description : value_description -> unit + val enter_type_extension : type_extension -> unit + val enter_extension_constructor : extension_constructor -> unit + val enter_pattern : pattern -> unit + val enter_expression : expression -> unit + val enter_package_type : package_type -> unit + val enter_signature : signature -> unit + val enter_signature_item : signature_item -> unit + val enter_module_type_declaration : module_type_declaration -> unit + val enter_module_type : module_type -> unit + val enter_module_expr : module_expr -> unit + val enter_with_constraint : with_constraint -> unit + val enter_class_expr : class_expr -> unit + val enter_class_signature : class_signature -> unit + val enter_class_declaration : class_declaration -> unit + val enter_class_description : class_description -> unit + val enter_class_type_declaration : class_type_declaration -> unit + val enter_class_type : class_type -> unit + val enter_class_type_field : class_type_field -> unit + val enter_core_type : core_type -> unit + val enter_class_structure : class_structure -> unit + val enter_class_field : class_field -> unit + val enter_structure_item : structure_item -> unit -(* extract record fields as a whole *) -let record_arg p = match p.pat_desc with -| Tpat_any -> [] -| Tpat_record (args,_) -> args -| _ -> fatal_error "Parmatch.as_record" + val leave_structure : structure -> unit + val leave_value_description : value_description -> unit + val leave_type_extension : type_extension -> unit + val leave_extension_constructor : extension_constructor -> unit + val leave_pattern : pattern -> unit + val leave_expression : expression -> unit + val leave_package_type : package_type -> unit + val leave_signature : signature -> unit + val leave_signature_item : signature_item -> unit + val leave_module_type_declaration : module_type_declaration -> unit + val leave_module_type : module_type -> unit + val leave_module_expr : module_expr -> unit + val leave_with_constraint : with_constraint -> unit + val leave_class_expr : class_expr -> unit + val leave_class_signature : class_signature -> unit + val leave_class_declaration : class_declaration -> unit + val leave_class_description : class_description -> unit + val leave_class_type_declaration : class_type_declaration -> unit + val leave_class_type : class_type -> unit + val leave_class_type_field : class_type_field -> unit + val leave_core_type : core_type -> unit + val leave_class_structure : class_structure -> unit + val leave_class_field : class_field -> unit + val leave_structure_item : structure_item -> unit + val enter_bindings : rec_flag -> unit + val enter_binding : value_binding -> unit + val leave_binding : value_binding -> unit + val leave_bindings : rec_flag -> unit -(* Raise Not_found when pos is not present in arg *) -let get_field pos arg = - let _,_, p = List.find (fun (_,lbl,_) -> pos = lbl.lbl_pos) arg in - p + val enter_type_declarations : rec_flag -> unit + val enter_type_declaration : type_declaration -> unit + val leave_type_declaration : type_declaration -> unit + val leave_type_declarations : rec_flag -> unit -let extract_fields omegas arg = - List.map - (fun (_,lbl,_) -> - try - get_field lbl.lbl_pos arg - with Not_found -> omega) - omegas + end -let all_record_args lbls = match lbls with -| (_,{lbl_all=lbl_all},_)::_ -> - let t = - Array.map - (fun lbl -> mknoloc (Longident.Lident "?temp?"), lbl,omega) - lbl_all in - List.iter - (fun ((_, lbl,_) as x) -> t.(lbl.lbl_pos) <- x) - lbls ; - Array.to_list t -| _ -> fatal_error "Parmatch.all_record_args" +module MakeIterator(Iter : IteratorArgument) : sig + val iter_structure : structure -> unit + val iter_signature : signature -> unit + val iter_structure_item : structure_item -> unit + val iter_signature_item : signature_item -> unit + val iter_expression : expression -> unit + val iter_module_type : module_type -> unit + val iter_pattern : pattern -> unit + val iter_class_expr : class_expr -> unit -(* Build argument list when p2 >= p1, where p1 is a simple pattern *) -let rec simple_match_args p1 p2 = match p2.pat_desc with -| Tpat_alias (p2,_,_) -> simple_match_args p1 p2 -| Tpat_construct(_, _, args) -> args -| Tpat_variant(_, Some arg, _) -> [arg] -| Tpat_tuple(args) -> args -| Tpat_record(args,_) -> extract_fields (record_arg p1) args -| Tpat_array(args) -> args -| Tpat_lazy arg -> [arg] -| (Tpat_any | Tpat_var(_)) -> - begin match p1.pat_desc with - Tpat_construct(_, _,args) -> omega_list args - | Tpat_variant(_, Some _, _) -> [omega] - | Tpat_tuple(args) -> omega_list args - | Tpat_record(args,_) -> omega_list args - | Tpat_array(args) -> omega_list args - | Tpat_lazy _ -> [omega] - | _ -> [] - end -| _ -> [] + end = struct -(* - Normalize a pattern -> - all arguments are omega (simple pattern) and no more variables -*) + let may_iter f v = + match v with + None -> () + | Some x -> f x -let rec normalize_pat q = match q.pat_desc with - | Tpat_any | Tpat_constant _ -> q - | Tpat_var _ -> make_pat Tpat_any q.pat_type q.pat_env - | Tpat_alias (p,_,_) -> normalize_pat p - | Tpat_tuple (args) -> - make_pat (Tpat_tuple (omega_list args)) q.pat_type q.pat_env - | Tpat_construct (lid, c,args) -> - make_pat - (Tpat_construct (lid, c,omega_list args)) - q.pat_type q.pat_env - | Tpat_variant (l, arg, row) -> - make_pat (Tpat_variant (l, may_map (fun _ -> omega) arg, row)) - q.pat_type q.pat_env - | Tpat_array (args) -> - make_pat (Tpat_array (omega_list args)) q.pat_type q.pat_env - | Tpat_record (largs, closed) -> - make_pat - (Tpat_record (List.map (fun (lid,lbl,_) -> - lid, lbl,omega) largs, closed)) - q.pat_type q.pat_env - | Tpat_lazy _ -> - make_pat (Tpat_lazy omega) q.pat_type q.pat_env - | Tpat_or _ -> fatal_error "Parmatch.normalize_pat" -(* - Build normalized (cf. supra) discriminating pattern, - in the non-data type case -*) + let rec iter_structure str = + Iter.enter_structure str; + List.iter iter_structure_item str.str_items; + Iter.leave_structure str -let discr_pat q pss = - let rec acc_pat acc pss = match pss with - ({pat_desc = Tpat_alias (p,_,_)}::ps)::pss -> - acc_pat acc ((p::ps)::pss) - | ({pat_desc = Tpat_or (p1,p2,_)}::ps)::pss -> - acc_pat acc ((p1::ps)::(p2::ps)::pss) - | ({pat_desc = (Tpat_any | Tpat_var _)}::_)::pss -> - acc_pat acc pss - | (({pat_desc = Tpat_tuple _} as p)::_)::_ -> normalize_pat p - | (({pat_desc = Tpat_lazy _} as p)::_)::_ -> normalize_pat p - | (({pat_desc = Tpat_record (largs,closed)} as p)::_)::pss -> - let new_omegas = - List.fold_right - (fun (lid, lbl,_) r -> - try - let _ = get_field lbl.lbl_pos r in - r - with Not_found -> - (lid, lbl,omega)::r) - largs (record_arg acc) - in - acc_pat - (make_pat (Tpat_record (new_omegas, closed)) p.pat_type p.pat_env) - pss - | _ -> acc in + and iter_binding vb = + Iter.enter_binding vb; + iter_pattern vb.vb_pat; + iter_expression vb.vb_expr; + Iter.leave_binding vb - match normalize_pat q with - | {pat_desc= (Tpat_any | Tpat_record _)} as q -> acc_pat q pss - | q -> q + and iter_bindings rec_flag list = + Iter.enter_bindings rec_flag; + List.iter iter_binding list; + Iter.leave_bindings rec_flag -(* - In case a matching value is found, set actual arguments - of the matching pattern. -*) + and iter_case {c_lhs; c_guard; c_rhs} = + iter_pattern c_lhs; + may_iter iter_expression c_guard; + iter_expression c_rhs -let rec read_args xs r = match xs,r with -| [],_ -> [],r -| _::xs, arg::rest -> - let args,rest = read_args xs rest in - arg::args,rest -| _,_ -> - fatal_error "Parmatch.read_args" + and iter_cases cases = + List.iter iter_case cases -let do_set_args erase_mutable q r = match q with -| {pat_desc = Tpat_tuple omegas} -> - let args,rest = read_args omegas r in - make_pat (Tpat_tuple args) q.pat_type q.pat_env::rest -| {pat_desc = Tpat_record (omegas,closed)} -> - let args,rest = read_args omegas r in - make_pat - (Tpat_record - (List.map2 (fun (lid, lbl,_) arg -> - if - erase_mutable && - (match lbl.lbl_mut with - | Mutable -> true | Immutable -> false) - then - lid, lbl, omega - else - lid, lbl, arg) - omegas args, closed)) - q.pat_type q.pat_env:: - rest -| {pat_desc = Tpat_construct (lid, c,omegas)} -> - let args,rest = read_args omegas r in - make_pat - (Tpat_construct (lid, c,args)) - q.pat_type q.pat_env:: - rest -| {pat_desc = Tpat_variant (l, omega, row)} -> - let arg, rest = - match omega, r with - Some _, a::r -> Some a, r - | None, r -> None, r - | _ -> assert false - in - make_pat - (Tpat_variant (l, arg, row)) q.pat_type q.pat_env:: - rest -| {pat_desc = Tpat_lazy _omega} -> - begin match r with - arg::rest -> - make_pat (Tpat_lazy arg) q.pat_type q.pat_env::rest - | _ -> fatal_error "Parmatch.do_set_args (lazy)" - end -| {pat_desc = Tpat_array omegas} -> - let args,rest = read_args omegas r in - make_pat - (Tpat_array args) q.pat_type q.pat_env:: - rest -| {pat_desc=Tpat_constant _|Tpat_any} -> - q::r (* case any is used in matching.ml *) -| _ -> fatal_error "Parmatch.set_args" + and iter_structure_item item = + Iter.enter_structure_item item; + begin + match item.str_desc with + Tstr_eval (exp, _attrs) -> iter_expression exp + | Tstr_value (rec_flag, list) -> + iter_bindings rec_flag list + | Tstr_primitive vd -> iter_value_description vd + | Tstr_type (rf, list) -> iter_type_declarations rf list + | Tstr_typext tyext -> iter_type_extension tyext + | Tstr_exception ext -> iter_extension_constructor ext + | Tstr_module x -> iter_module_binding x + | Tstr_recmodule list -> List.iter iter_module_binding list + | Tstr_modtype mtd -> iter_module_type_declaration mtd + | Tstr_open _ -> () + | Tstr_class list -> + List.iter (fun (ci, _) -> iter_class_declaration ci) list + | Tstr_class_type list -> + List.iter + (fun (_, _, ct) -> iter_class_type_declaration ct) + list + | Tstr_include incl -> iter_module_expr incl.incl_mod + | Tstr_attribute _ -> + () + end; + Iter.leave_structure_item item -let set_args q r = do_set_args false q r -and set_args_erase_mutable q r = do_set_args true q r + and iter_module_binding x = + iter_module_expr x.mb_expr -(* filter pss according to pattern q *) -let filter_one q pss = - let rec filter_rec = function - ({pat_desc = Tpat_alias(p,_,_)}::ps)::pss -> - filter_rec ((p::ps)::pss) - | ({pat_desc = Tpat_or(p1,p2,_)}::ps)::pss -> - filter_rec ((p1::ps)::(p2::ps)::pss) - | (p::ps)::pss -> - if simple_match q p - then (simple_match_args q p @ ps) :: filter_rec pss - else filter_rec pss - | _ -> [] in - filter_rec pss + and iter_value_description v = + Iter.enter_value_description v; + iter_core_type v.val_desc; + Iter.leave_value_description v -(* - Filter pss in the ``extra case''. This applies : - - According to an extra constructor (datatype case, non-complete signature). - - According to anything (all-variables case). -*) -let filter_extra pss = - let rec filter_rec = function - ({pat_desc = Tpat_alias(p,_,_)}::ps)::pss -> - filter_rec ((p::ps)::pss) - | ({pat_desc = Tpat_or(p1,p2,_)}::ps)::pss -> - filter_rec ((p1::ps)::(p2::ps)::pss) - | ({pat_desc = (Tpat_any | Tpat_var(_))} :: qs) :: pss -> - qs :: filter_rec pss - | _::pss -> filter_rec pss - | [] -> [] in - filter_rec pss + and iter_constructor_arguments = function + | Cstr_tuple l -> List.iter iter_core_type l + | Cstr_record l -> List.iter (fun ld -> iter_core_type ld.ld_type) l -(* - Pattern p0 is the discriminating pattern, - returns [(q0,pss0) ; ... ; (qn,pssn)] - where the qi's are simple patterns and the pssi's are - matched matrices. + and iter_constructor_declaration cd = + iter_constructor_arguments cd.cd_args; + option iter_core_type cd.cd_res; - NOTES - * (qi,[]) is impossible. - * In the case when matching is useless (all-variable case), - returns [] -*) + and iter_type_parameter (ct, _v) = + iter_core_type ct -let filter_all pat0 pss = + and iter_type_declaration decl = + Iter.enter_type_declaration decl; + List.iter iter_type_parameter decl.typ_params; + List.iter (fun (ct1, ct2, _loc) -> + iter_core_type ct1; + iter_core_type ct2 + ) decl.typ_cstrs; + begin match decl.typ_kind with + Ttype_abstract -> () + | Ttype_variant list -> + List.iter iter_constructor_declaration list + | Ttype_record list -> + List.iter + (fun ld -> + iter_core_type ld.ld_type + ) list + | Ttype_open -> () + end; + option iter_core_type decl.typ_manifest; + Iter.leave_type_declaration decl - let rec insert q qs env = - match env with - [] -> - let q0 = normalize_pat q in - [q0, [simple_match_args q0 q @ qs]] - | ((q0,pss) as c)::env -> - if simple_match q0 q - then (q0, ((simple_match_args q0 q @ qs) :: pss)) :: env - else c :: insert q qs env in + and iter_type_declarations rec_flag decls = + Iter.enter_type_declarations rec_flag; + List.iter iter_type_declaration decls; + Iter.leave_type_declarations rec_flag - let rec filter_rec env = function - ({pat_desc = Tpat_alias(p,_,_)}::ps)::pss -> - filter_rec env ((p::ps)::pss) - | ({pat_desc = Tpat_or(p1,p2,_)}::ps)::pss -> - filter_rec env ((p1::ps)::(p2::ps)::pss) - | ({pat_desc = (Tpat_any | Tpat_var(_))}::_)::pss -> - filter_rec env pss - | (p::ps)::pss -> - filter_rec (insert p ps env) pss - | _ -> env + and iter_extension_constructor ext = + Iter.enter_extension_constructor ext; + begin match ext.ext_kind with + Text_decl(args, ret) -> + iter_constructor_arguments args; + option iter_core_type ret + | Text_rebind _ -> () + end; + Iter.leave_extension_constructor ext; - and filter_omega env = function - ({pat_desc = Tpat_alias(p,_,_)}::ps)::pss -> - filter_omega env ((p::ps)::pss) - | ({pat_desc = Tpat_or(p1,p2,_)}::ps)::pss -> - filter_omega env ((p1::ps)::(p2::ps)::pss) - | ({pat_desc = (Tpat_any | Tpat_var(_))}::ps)::pss -> - filter_omega - (List.map (fun (q,qss) -> (q,(simple_match_args q omega @ ps) :: qss)) - env) - pss - | _::pss -> filter_omega env pss - | [] -> env in + and iter_type_extension tyext = + Iter.enter_type_extension tyext; + List.iter iter_type_parameter tyext.tyext_params; + List.iter iter_extension_constructor tyext.tyext_constructors; + Iter.leave_type_extension tyext - filter_omega - (filter_rec - (match pat0.pat_desc with - (Tpat_record(_) | Tpat_tuple(_) | Tpat_lazy(_)) -> [pat0,[]] - | _ -> []) - pss) - pss + and iter_pattern pat = + Iter.enter_pattern pat; + List.iter (fun (cstr, _, _attrs) -> match cstr with + | Tpat_type _ -> () + | Tpat_unpack -> () + | Tpat_open _ -> () + | Tpat_constraint ct -> iter_core_type ct) pat.pat_extra; + begin + match pat.pat_desc with + Tpat_any -> () + | Tpat_var _ -> () + | Tpat_alias (pat1, _, _) -> iter_pattern pat1 + | Tpat_constant _ -> () + | Tpat_tuple list -> + List.iter iter_pattern list + | Tpat_construct (_, _, args) -> + List.iter iter_pattern args + | Tpat_variant (_, pato, _) -> + begin match pato with + None -> () + | Some pat -> iter_pattern pat + end + | Tpat_record (list, _closed) -> + List.iter (fun (_, _, pat) -> iter_pattern pat) list + | Tpat_array list -> List.iter iter_pattern list + | Tpat_or (p1, p2, _) -> iter_pattern p1; iter_pattern p2 + | Tpat_lazy p -> iter_pattern p + end; + Iter.leave_pattern pat -(* Variant related functions *) + and option f x = match x with None -> () | Some e -> f e -let rec set_last a = function - [] -> [] - | [_] -> [a] - | x::l -> x :: set_last a l + and iter_expression exp = + Iter.enter_expression exp; + List.iter (function (cstr, _, _attrs) -> + match cstr with + Texp_constraint ct -> + iter_core_type ct + | Texp_coerce (cty1, cty2) -> + option iter_core_type cty1; iter_core_type cty2 + | Texp_open _ -> () + | Texp_poly cto -> option iter_core_type cto + | Texp_newtype _ -> ()) + exp.exp_extra; + begin + match exp.exp_desc with + Texp_ident _ -> () + | Texp_constant _ -> () + | Texp_let (rec_flag, list, exp) -> + iter_bindings rec_flag list; + iter_expression exp + | Texp_function { cases; _ } -> + iter_cases cases + | Texp_apply (exp, list) -> + iter_expression exp; + List.iter (fun (_label, expo) -> + match expo with + None -> () + | Some exp -> iter_expression exp + ) list + | Texp_match (exp, list1, list2, _) -> + iter_expression exp; + iter_cases list1; + iter_cases list2; + | Texp_try (exp, list) -> + iter_expression exp; + iter_cases list + | Texp_tuple list -> + List.iter iter_expression list + | Texp_construct (_, _, args) -> + List.iter iter_expression args + | Texp_variant (_label, expo) -> + begin match expo with + None -> () + | Some exp -> iter_expression exp + end + | Texp_record { fields; extended_expression; _ } -> + Array.iter (function + | _, Kept _ -> () + | _, Overridden (_, exp) -> iter_expression exp) + fields; + begin match extended_expression with + None -> () + | Some exp -> iter_expression exp + end + | Texp_field (exp, _, _label) -> + iter_expression exp + | Texp_setfield (exp1, _, _label, exp2) -> + iter_expression exp1; + iter_expression exp2 + | Texp_array list -> + List.iter iter_expression list + | Texp_ifthenelse (exp1, exp2, expo) -> + iter_expression exp1; + iter_expression exp2; + begin match expo with + None -> () + | Some exp -> iter_expression exp + end + | Texp_sequence (exp1, exp2) -> + iter_expression exp1; + iter_expression exp2 + | Texp_while (exp1, exp2) -> + iter_expression exp1; + iter_expression exp2 + | Texp_for (_id, _, exp1, exp2, _dir, exp3) -> + iter_expression exp1; + iter_expression exp2; + iter_expression exp3 + | Texp_send (exp, _meth, expo) -> + iter_expression exp; + begin + match expo with + None -> () + | Some exp -> iter_expression exp + end + | Texp_new _ -> () + | Texp_instvar _ -> () + | Texp_setinstvar (_, _, _, exp) -> + iter_expression exp + | Texp_override (_, list) -> + List.iter (fun (_path, _, exp) -> + iter_expression exp + ) list + | Texp_letmodule (_id, _, mexpr, exp) -> + iter_module_expr mexpr; + iter_expression exp + | Texp_letexception (cd, exp) -> + iter_extension_constructor cd; + iter_expression exp + | Texp_assert exp -> iter_expression exp + | Texp_lazy exp -> iter_expression exp + | Texp_object (cl, _) -> + iter_class_structure cl + | Texp_pack (mexpr) -> + iter_module_expr mexpr + | Texp_unreachable -> + () + | Texp_extension_constructor _ -> + () + end; + Iter.leave_expression exp; -(* mark constructor lines for failure when they are incomplete *) -let rec mark_partial = function - ({pat_desc = Tpat_alias(p,_,_)}::ps)::pss -> - mark_partial ((p::ps)::pss) - | ({pat_desc = Tpat_or(p1,p2,_)}::ps)::pss -> - mark_partial ((p1::ps)::(p2::ps)::pss) - | ({pat_desc = (Tpat_any | Tpat_var(_))} :: _ as ps) :: pss -> - ps :: mark_partial pss - | ps::pss -> - (set_last zero ps) :: mark_partial pss - | [] -> [] + and iter_package_type pack = + Iter.enter_package_type pack; + List.iter (fun (_s, ct) -> iter_core_type ct) pack.pack_fields; + Iter.leave_package_type pack; -let close_variant env row = - let row = Btype.row_repr row in - let nm = - List.fold_left - (fun nm (_tag,f) -> - match Btype.row_field_repr f with - | Reither(_, _, false, e) -> - (* m=false means that this tag is not explicitly matched *) - Btype.set_row_field e Rabsent; - None - | Rabsent | Reither (_, _, true, _) | Rpresent _ -> nm) - row.row_name row.row_fields in - if not row.row_closed || nm != row.row_name then begin - (* this unification cannot fail *) - Ctype.unify env row.row_more - (Btype.newgenty - (Tvariant {row with row_fields = []; row_more = Btype.newgenvar(); - row_closed = true; row_name = nm})) - end + and iter_signature sg = + Iter.enter_signature sg; + List.iter iter_signature_item sg.sig_items; + Iter.leave_signature sg; -let row_of_pat pat = - match Ctype.expand_head pat.pat_env pat.pat_type with - {desc = Tvariant row} -> Btype.row_repr row - | _ -> assert false + and iter_signature_item item = + Iter.enter_signature_item item; + begin + match item.sig_desc with + Tsig_value vd -> + iter_value_description vd + | Tsig_type (rf, list) -> + iter_type_declarations rf list + | Tsig_exception ext -> + iter_extension_constructor ext + | Tsig_typext tyext -> + iter_type_extension tyext + | Tsig_module md -> + iter_module_type md.md_type + | Tsig_recmodule list -> + List.iter (fun md -> iter_module_type md.md_type) list + | Tsig_modtype mtd -> + iter_module_type_declaration mtd + | Tsig_open _ -> () + | Tsig_include incl -> iter_module_type incl.incl_mod + | Tsig_class list -> + List.iter iter_class_description list + | Tsig_class_type list -> + List.iter iter_class_type_declaration list + | Tsig_attribute _ -> () + end; + Iter.leave_signature_item item; -(* - Check whether the first column of env makes up a complete signature or - not. -*) + and iter_module_type_declaration mtd = + Iter.enter_module_type_declaration mtd; + begin + match mtd.mtd_type with + | None -> () + | Some mtype -> iter_module_type mtype + end; + Iter.leave_module_type_declaration mtd -let full_match closing env = match env with -| ({pat_desc = Tpat_construct(_,c,_)},_) :: _ -> - if c.cstr_consts < 0 then false (* extensions *) - else List.length env = c.cstr_consts + c.cstr_nonconsts -| ({pat_desc = Tpat_variant _} as p,_) :: _ -> - let fields = - List.map - (function ({pat_desc = Tpat_variant (tag, _, _)}, _) -> tag - | _ -> assert false) - env - in - let row = row_of_pat p in - if closing && not (Btype.row_fixed row) then - (* closing=true, we are considering the variant as closed *) - List.for_all - (fun (tag,f) -> - match Btype.row_field_repr f with - Rabsent | Reither(_, _, false, _) -> true - | Reither (_, _, true, _) - (* m=true, do not discard matched tags, rather warn *) - | Rpresent _ -> List.mem tag fields) - row.row_fields - else - row.row_closed && - List.for_all - (fun (tag,f) -> - Btype.row_field_repr f = Rabsent || List.mem tag fields) - row.row_fields -| ({pat_desc = Tpat_constant(Const_char _)},_) :: _ -> - List.length env = 256 -| ({pat_desc = Tpat_constant(_)},_) :: _ -> false -| ({pat_desc = Tpat_tuple(_)},_) :: _ -> true -| ({pat_desc = Tpat_record(_)},_) :: _ -> true -| ({pat_desc = Tpat_array(_)},_) :: _ -> false -| ({pat_desc = Tpat_lazy(_)},_) :: _ -> true -| ({pat_desc = (Tpat_any|Tpat_var _|Tpat_alias _|Tpat_or _)},_) :: _ -| [] - -> - assert false + and iter_class_declaration cd = + Iter.enter_class_declaration cd; + List.iter iter_type_parameter cd.ci_params; + iter_class_expr cd.ci_expr; + Iter.leave_class_declaration cd; -(* Written as a non-fragile matching, PR#7451 originated from a fragile matching below. *) -let should_extend ext env = match ext with -| None -> false -| Some ext -> begin match env with - | [] -> assert false - | (p,_)::_ -> - begin match p.pat_desc with - | Tpat_construct - (_, {cstr_tag=(Cstr_constant _|Cstr_block _|Cstr_unboxed)},_) -> - let path = get_type_path p.pat_type p.pat_env in - Path.same path ext - | Tpat_construct - (_, {cstr_tag=(Cstr_extension _)},_) -> false - | Tpat_constant _|Tpat_tuple _|Tpat_variant _ - | Tpat_record _|Tpat_array _ | Tpat_lazy _ - -> false - | Tpat_any|Tpat_var _|Tpat_alias _|Tpat_or _ - -> assert false - end -end + and iter_class_description cd = + Iter.enter_class_description cd; + List.iter iter_type_parameter cd.ci_params; + iter_class_type cd.ci_expr; + Iter.leave_class_description cd; -module ConstructorTagHashtbl = Hashtbl.Make( - struct - type t = Types.constructor_tag - let hash = Hashtbl.hash - let equal = Types.equal_tag - end -) + and iter_class_type_declaration cd = + Iter.enter_class_type_declaration cd; + List.iter iter_type_parameter cd.ci_params; + iter_class_type cd.ci_expr; + Iter.leave_class_type_declaration cd; -(* complement constructor tags *) -let complete_tags nconsts nconstrs tags = - let seen_const = Array.make nconsts false - and seen_constr = Array.make nconstrs false in - List.iter - (function - | Cstr_constant i -> seen_const.(i) <- true - | Cstr_block i -> seen_constr.(i) <- true - | _ -> assert false) - tags ; - let r = ConstructorTagHashtbl.create (nconsts+nconstrs) in - for i = 0 to nconsts-1 do - if not seen_const.(i) then - ConstructorTagHashtbl.add r (Cstr_constant i) () - done ; - for i = 0 to nconstrs-1 do - if not seen_constr.(i) then - ConstructorTagHashtbl.add r (Cstr_block i) () - done ; - r + and iter_module_type mty = + Iter.enter_module_type mty; + begin + match mty.mty_desc with + Tmty_ident _ -> () + | Tmty_alias _ -> () + | Tmty_signature sg -> iter_signature sg + | Tmty_functor (_, _, mtype1, mtype2) -> + Misc.may iter_module_type mtype1; iter_module_type mtype2 + | Tmty_with (mtype, list) -> + iter_module_type mtype; + List.iter (fun (_path, _, withc) -> + iter_with_constraint withc + ) list + | Tmty_typeof mexpr -> + iter_module_expr mexpr + end; + Iter.leave_module_type mty; -(* build a pattern from a constructor list *) -let pat_of_constr ex_pat cstr = - {ex_pat with pat_desc = - Tpat_construct (mknoloc (Longident.Lident "?pat_of_constr?"), - cstr, omegas cstr.cstr_arity)} + and iter_with_constraint cstr = + Iter.enter_with_constraint cstr; + begin + match cstr with + Twith_type decl -> iter_type_declaration decl + | Twith_module _ -> () + | Twith_typesubst decl -> iter_type_declaration decl + | Twith_modsubst _ -> () + end; + Iter.leave_with_constraint cstr; -let orify x y = make_pat (Tpat_or (x, y, None)) x.pat_type x.pat_env + and iter_module_expr mexpr = + Iter.enter_module_expr mexpr; + begin + match mexpr.mod_desc with + Tmod_ident _ -> () + | Tmod_structure st -> iter_structure st + | Tmod_functor (_, _, mtype, mexpr) -> + Misc.may iter_module_type mtype; + iter_module_expr mexpr + | Tmod_apply (mexp1, mexp2, _) -> + iter_module_expr mexp1; + iter_module_expr mexp2 + | Tmod_constraint (mexpr, _, Tmodtype_implicit, _ ) -> + iter_module_expr mexpr + | Tmod_constraint (mexpr, _, Tmodtype_explicit mtype, _) -> + iter_module_expr mexpr; + iter_module_type mtype + | Tmod_unpack (exp, _mty) -> + iter_expression exp +(* iter_module_type mty *) + end; + Iter.leave_module_expr mexpr; -let rec orify_many = function -| [] -> assert false -| [x] -> x -| x :: xs -> orify x (orify_many xs) + and iter_class_expr cexpr = + Iter.enter_class_expr cexpr; + begin + match cexpr.cl_desc with + | Tcl_constraint (cl, None, _, _, _ ) -> + iter_class_expr cl; + | Tcl_structure clstr -> iter_class_structure clstr + | Tcl_fun (_label, pat, priv, cl, _partial) -> + iter_pattern pat; + List.iter (fun (_id, _, exp) -> iter_expression exp) priv; + iter_class_expr cl -let pat_of_constrs ex_pat cstrs = - if cstrs = [] then raise Empty else - orify_many (List.map (pat_of_constr ex_pat) cstrs) + | Tcl_apply (cl, args) -> + iter_class_expr cl; + List.iter (fun (_label, expo) -> + match expo with + None -> () + | Some exp -> iter_expression exp + ) args -let pats_of_type ?(always=false) env ty = - let ty' = Ctype.expand_head env ty in - match ty'.desc with - | Tconstr (path, _, _) -> - begin try match (Env.find_type path env).type_kind with - | Type_variant cl when always || List.length cl = 1 || - List.for_all (fun cd -> cd.Types.cd_res <> None) cl -> - let cstrs = fst (Env.find_type_descrs path env) in - List.map (pat_of_constr (make_pat Tpat_any ty env)) cstrs - | Type_record _ -> - let labels = snd (Env.find_type_descrs path env) in - let fields = - List.map (fun ld -> - mknoloc (Longident.Lident "?pat_of_label?"), ld, omega) - labels - in - [make_pat (Tpat_record (fields, Closed)) ty env] - | _ -> [omega] - with Not_found -> [omega] - end - | Ttuple tl -> - [make_pat (Tpat_tuple (omegas (List.length tl))) ty env] - | _ -> [omega] + | Tcl_let (rec_flat, bindings, ivars, cl) -> + iter_bindings rec_flat bindings; + List.iter (fun (_id, _, exp) -> iter_expression exp) ivars; + iter_class_expr cl -let rec get_variant_constructors env ty = - match (Ctype.repr ty).desc with - | Tconstr (path,_,_) -> begin - try match Env.find_type path env with - | {type_kind=Type_variant _} -> - fst (Env.find_type_descrs path env) - | {type_manifest = Some _} -> - get_variant_constructors env - (Ctype.expand_head_once env (clean_copy ty)) - | _ -> fatal_error "Parmatch.get_variant_constructors" - with Not_found -> - fatal_error "Parmatch.get_variant_constructors" - end - | _ -> fatal_error "Parmatch.get_variant_constructors" + | Tcl_constraint (cl, Some clty, _vals, _meths, _concrs) -> + iter_class_expr cl; + iter_class_type clty -(* Sends back a pattern that complements constructor tags all_tag *) -let complete_constrs p all_tags = - let c = - match p.pat_desc with Tpat_construct (_, c, _) -> c | _ -> assert false in - let not_tags = complete_tags c.cstr_consts c.cstr_nonconsts all_tags in - let constrs = get_variant_constructors p.pat_env c.cstr_res in - let others = - List.filter - (fun cnstr -> ConstructorTagHashtbl.mem not_tags cnstr.cstr_tag) - constrs in - let const, nonconst = - List.partition (fun cnstr -> cnstr.cstr_arity = 0) others in - const @ nonconst + | Tcl_ident (_, _, tyl) -> + List.iter iter_core_type tyl -let build_other_constrs env p = - match p.pat_desc with - Tpat_construct (_, {cstr_tag=Cstr_constant _|Cstr_block _}, _) -> - let get_tag = function - | {pat_desc = Tpat_construct (_,c,_)} -> c.cstr_tag - | _ -> fatal_error "Parmatch.get_tag" in - let all_tags = List.map (fun (p,_) -> get_tag p) env in - pat_of_constrs p (complete_constrs p all_tags) - | _ -> extra_pat + | Tcl_open (_, _, _, _, e) -> + iter_class_expr e + end; + Iter.leave_class_expr cexpr; -(* Auxiliary for build_other *) + and iter_class_type ct = + Iter.enter_class_type ct; + begin + match ct.cltyp_desc with + Tcty_signature csg -> iter_class_signature csg + | Tcty_constr (_path, _, list) -> + List.iter iter_core_type list + | Tcty_arrow (_label, ct, cl) -> + iter_core_type ct; + iter_class_type cl + | Tcty_open (_, _, _, _, e) -> + iter_class_type e + end; + Iter.leave_class_type ct; -let build_other_constant proj make first next p env = - let all = List.map (fun (p, _) -> proj p.pat_desc) env in - let rec try_const i = - if List.mem i all - then try_const (next i) - else make_pat (make i) p.pat_type p.pat_env - in try_const first + and iter_class_signature cs = + Iter.enter_class_signature cs; + iter_core_type cs.csig_self; + List.iter iter_class_type_field cs.csig_fields; + Iter.leave_class_signature cs -(* - Builds a pattern that is incompatible with all patterns in - in the first column of env -*) -let some_other_tag = "" + and iter_class_type_field ctf = + Iter.enter_class_type_field ctf; + begin + match ctf.ctf_desc with + Tctf_inherit ct -> iter_class_type ct + | Tctf_val (_s, _mut, _virt, ct) -> + iter_core_type ct + | Tctf_method (_s, _priv, _virt, ct) -> + iter_core_type ct + | Tctf_constraint (ct1, ct2) -> + iter_core_type ct1; + iter_core_type ct2 + | Tctf_attribute _ -> () + end; + Iter.leave_class_type_field ctf -let build_other ext env = match env with -| ({pat_desc = Tpat_construct (lid, {cstr_tag=Cstr_extension _},_)},_) :: _ -> - (* let c = {c with cstr_name = "*extension*"} in *) (* PR#7330 *) - make_pat (Tpat_var (Ident.create "*extension*", - {lid with txt="*extension*"})) Ctype.none Env.empty -| ({pat_desc = Tpat_construct _} as p,_) :: _ -> - begin match ext with - | Some ext when Path.same ext (get_type_path p.pat_type p.pat_env) -> - extra_pat - | _ -> - build_other_constrs env p - end -| ({pat_desc = Tpat_variant (_,_,r)} as p,_) :: _ -> - let tags = - List.map - (function ({pat_desc = Tpat_variant (tag, _, _)}, _) -> tag - | _ -> assert false) - env - in - let row = row_of_pat p in - let make_other_pat tag const = - let arg = if const then None else Some omega in - make_pat (Tpat_variant(tag, arg, r)) p.pat_type p.pat_env in - begin match - List.fold_left - (fun others (tag,f) -> - if List.mem tag tags then others else - match Btype.row_field_repr f with - Rabsent (* | Reither _ *) -> others - (* This one is called after erasing pattern info *) - | Reither (c, _, _, _) -> make_other_pat tag c :: others - | Rpresent arg -> make_other_pat tag (arg = None) :: others) - [] row.row_fields - with - [] -> - make_other_pat some_other_tag true - | pat::other_pats -> - List.fold_left - (fun p_res pat -> - make_pat (Tpat_or (pat, p_res, None)) p.pat_type p.pat_env) - pat other_pats - end -| ({pat_desc = Tpat_constant(Const_char _)} as p,_) :: _ -> - let all_chars = - List.map - (fun (p,_) -> match p.pat_desc with - | Tpat_constant (Const_char c) -> c - | _ -> assert false) - env in + and iter_core_type ct = + Iter.enter_core_type ct; + begin + match ct.ctyp_desc with + Ttyp_any -> () + | Ttyp_var _ -> () + | Ttyp_arrow (_label, ct1, ct2) -> + iter_core_type ct1; + iter_core_type ct2 + | Ttyp_tuple list -> List.iter iter_core_type list + | Ttyp_constr (_path, _, list) -> + List.iter iter_core_type list + | Ttyp_object (list, _o) -> + List.iter iter_object_field list + | Ttyp_class (_path, _, list) -> + List.iter iter_core_type list + | Ttyp_alias (ct, _s) -> + iter_core_type ct + | Ttyp_variant (list, _bool, _labels) -> + List.iter iter_row_field list + | Ttyp_poly (_list, ct) -> iter_core_type ct + | Ttyp_package pack -> iter_package_type pack + end; + Iter.leave_core_type ct - let rec find_other i imax = - if i > imax then raise Not_found - else - let ci = Char.chr i in - if List.mem ci all_chars then - find_other (i+1) imax - else - make_pat (Tpat_constant (Const_char ci)) p.pat_type p.pat_env in - let rec try_chars = function - | [] -> omega - | (c1,c2) :: rest -> - try - find_other (Char.code c1) (Char.code c2) - with - | Not_found -> try_chars rest in + and iter_class_structure cs = + Iter.enter_class_structure cs; + iter_pattern cs.cstr_self; + List.iter iter_class_field cs.cstr_fields; + Iter.leave_class_structure cs; - try_chars - [ 'a', 'z' ; 'A', 'Z' ; '0', '9' ; - ' ', '~' ; Char.chr 0 , Char.chr 255] -| ({pat_desc=(Tpat_constant (Const_int _))} as p,_) :: _ -> - build_other_constant - (function Tpat_constant(Const_int i) -> i | _ -> assert false) - (function i -> Tpat_constant(Const_int i)) - 0 succ p env -| ({pat_desc=(Tpat_constant (Const_int32 _))} as p,_) :: _ -> - build_other_constant - (function Tpat_constant(Const_int32 i) -> i | _ -> assert false) - (function i -> Tpat_constant(Const_int32 i)) - 0l Int32.succ p env -| ({pat_desc=(Tpat_constant (Const_int64 _))} as p,_) :: _ -> - build_other_constant - (function Tpat_constant(Const_int64 i) -> i | _ -> assert false) - (function i -> Tpat_constant(Const_int64 i)) - 0L Int64.succ p env -| ({pat_desc=(Tpat_constant (Const_nativeint _))} as p,_) :: _ -> - build_other_constant - (function Tpat_constant(Const_nativeint i) -> i | _ -> assert false) - (function i -> Tpat_constant(Const_nativeint i)) - 0n Nativeint.succ p env -| ({pat_desc=(Tpat_constant (Const_string _))} as p,_) :: _ -> - build_other_constant - (function Tpat_constant(Const_string (s, _)) -> String.length s - | _ -> assert false) - (function i -> Tpat_constant(Const_string(String.make i '*', None))) - 0 succ p env -| ({pat_desc=(Tpat_constant (Const_float _))} as p,_) :: _ -> - build_other_constant - (function Tpat_constant(Const_float f) -> float_of_string f - | _ -> assert false) - (function f -> Tpat_constant(Const_float (string_of_float f))) - 0.0 (fun f -> f +. 1.0) p env + and iter_row_field rf = + match rf with + Ttag (_label, _attrs, _bool, list) -> + List.iter iter_core_type list + | Tinherit ct -> iter_core_type ct -| ({pat_desc = Tpat_array _} as p,_)::_ -> - let all_lengths = - List.map - (fun (p,_) -> match p.pat_desc with - | Tpat_array args -> List.length args - | _ -> assert false) - env in - let rec try_arrays l = - if List.mem l all_lengths then try_arrays (l+1) - else - make_pat - (Tpat_array (omegas l)) - p.pat_type p.pat_env in - try_arrays 0 -| [] -> omega -| _ -> omega + and iter_object_field ofield = + match ofield with + OTtag (_, _, ct) | OTinherit ct -> iter_core_type ct -(* - Core function : - Is the last row of pattern matrix pss + qs satisfiable ? - That is : - Does there exists at least one value vector, es such that : - 1- for all ps in pss ps # es (ps and es are not compatible) - 2- qs <= es (es matches qs) -*) + and iter_class_field cf = + Iter.enter_class_field cf; + begin + match cf.cf_desc with + Tcf_inherit (_ovf, cl, _super, _vals, _meths) -> + iter_class_expr cl + | Tcf_constraint (cty, cty') -> + iter_core_type cty; + iter_core_type cty' + | Tcf_val (_lab, _, _, Tcfk_virtual cty, _) -> + iter_core_type cty + | Tcf_val (_lab, _, _, Tcfk_concrete (_, exp), _) -> + iter_expression exp + | Tcf_method (_lab, _, Tcfk_virtual cty) -> + iter_core_type cty + | Tcf_method (_lab, _, Tcfk_concrete (_, exp)) -> + iter_expression exp + | Tcf_initializer exp -> + iter_expression exp + | Tcf_attribute _ -> () + end; + Iter.leave_class_field cf; + end -let rec has_instance p = match p.pat_desc with - | Tpat_variant (l,_,r) when is_absent l r -> false - | Tpat_any | Tpat_var _ | Tpat_constant _ | Tpat_variant (_,None,_) -> true - | Tpat_alias (p,_,_) | Tpat_variant (_,Some p,_) -> has_instance p - | Tpat_or (p1,p2,_) -> has_instance p1 || has_instance p2 - | Tpat_construct (_,_,ps) | Tpat_tuple ps | Tpat_array ps -> - has_instances ps - | Tpat_record (lps,_) -> has_instances (List.map (fun (_,_,x) -> x) lps) - | Tpat_lazy p - -> has_instance p +module DefaultIteratorArgument = struct + let enter_structure _ = () + let enter_value_description _ = () + let enter_type_extension _ = () + let enter_extension_constructor _ = () + let enter_pattern _ = () + let enter_expression _ = () + let enter_package_type _ = () + let enter_signature _ = () + let enter_signature_item _ = () + let enter_module_type_declaration _ = () + let enter_module_type _ = () + let enter_module_expr _ = () + let enter_with_constraint _ = () + let enter_class_expr _ = () + let enter_class_signature _ = () + let enter_class_declaration _ = () + let enter_class_description _ = () + let enter_class_type_declaration _ = () + let enter_class_type _ = () + let enter_class_type_field _ = () + let enter_core_type _ = () + let enter_class_structure _ = () + let enter_class_field _ = () + let enter_structure_item _ = () -and has_instances = function - | [] -> true - | q::rem -> has_instance q && has_instances rem -(* - In two places in the following function, we check the coherence of the first - column of (pss + qs). - If it is incoherent, then we exit early saying that (pss + qs) is not - satisfiable (which is equivalent to saying "oh, we shouldn't have considered - that branch, no good result came come from here"). + let leave_structure _ = () + let leave_value_description _ = () + let leave_type_extension _ = () + let leave_extension_constructor _ = () + let leave_pattern _ = () + let leave_expression _ = () + let leave_package_type _ = () + let leave_signature _ = () + let leave_signature_item _ = () + let leave_module_type_declaration _ = () + let leave_module_type _ = () + let leave_module_expr _ = () + let leave_with_constraint _ = () + let leave_class_expr _ = () + let leave_class_signature _ = () + let leave_class_declaration _ = () + let leave_class_description _ = () + let leave_class_type_declaration _ = () + let leave_class_type _ = () + let leave_class_type_field _ = () + let leave_core_type _ = () + let leave_class_structure _ = () + let leave_class_field _ = () + let leave_structure_item _ = () - But what happens if we have a coherent but ill-typed column? - - we might end up returning [false], which is equivalent to noticing the - incompatibility: clearly this is fine. - - if we end up returning [true] then we're saying that [qs] is useful while - it is not. This is sad but not the end of the world, we're just allowing dead - code to survive. -*) -let rec satisfiable pss qs = match pss with -| [] -> has_instances qs -| _ -> - match qs with - | [] -> false - | {pat_desc = Tpat_or(q1,q2,_)}::qs -> - satisfiable pss (q1::qs) || satisfiable pss (q2::qs) - | {pat_desc = Tpat_alias(q,_,_)}::qs -> - satisfiable pss (q::qs) - | {pat_desc = (Tpat_any | Tpat_var(_))}::qs -> - if not (all_coherent (simplified_first_col pss)) then - false - else begin - let q0 = discr_pat omega pss in - match filter_all q0 pss with - (* first column of pss is made of variables only *) - | [] -> satisfiable (filter_extra pss) qs - | constrs -> - if full_match false constrs then - List.exists - (fun (p,pss) -> - not (is_absent_pat p) && - satisfiable pss (simple_match_args p omega @ qs)) - constrs - else - satisfiable (filter_extra pss) qs - end - | {pat_desc=Tpat_variant (l,_,r)}::_ when is_absent l r -> false - | q::qs -> - if not (all_coherent (q :: simplified_first_col pss)) then - false - else begin - let q0 = discr_pat q pss in - satisfiable (filter_one q0 pss) (simple_match_args q0 q @ qs) - end + let enter_binding _ = () + let leave_binding _ = () -(* Also return the remaining cases, to enable GADT handling + let enter_bindings _ = () + let leave_bindings _ = () - For considerations regarding the coherence check, see the comment on - [satisfiable] above. *) -let rec satisfiables pss qs = match pss with -| [] -> if has_instances qs then [qs] else [] -| _ -> - match qs with - | [] -> [] - | {pat_desc = Tpat_or(q1,q2,_)}::qs -> - satisfiables pss (q1::qs) @ satisfiables pss (q2::qs) - | {pat_desc = Tpat_alias(q,_,_)}::qs -> - satisfiables pss (q::qs) - | {pat_desc = (Tpat_any | Tpat_var(_))}::qs -> - if not (all_coherent (simplified_first_col pss)) then - [] - else begin - let q0 = discr_pat omega pss in - let wild p = - List.map (fun qs -> p::qs) (satisfiables (filter_extra pss) qs) in - match filter_all q0 pss with - (* first column of pss is made of variables only *) - | [] -> - wild omega - | (p,_)::_ as constrs -> - let for_constrs () = - List.flatten ( - List.map - (fun (p,pss) -> - if is_absent_pat p then [] else - List.map (set_args p) - (satisfiables pss (simple_match_args p omega @ qs))) - constrs ) - in - if full_match false constrs then for_constrs () else - match p.pat_desc with - Tpat_construct _ -> - (* activate this code for checking non-gadt constructors *) - wild (build_other_constrs constrs p) @ for_constrs () - | _ -> - wild omega - end - | {pat_desc=Tpat_variant (l,_,r)}::_ when is_absent l r -> [] - | q::qs -> - if not (all_coherent (q :: simplified_first_col pss)) then - [] - else begin - let q0 = discr_pat q pss in - List.map (set_args q0) - (satisfiables (filter_one q0 pss) (simple_match_args q0 q @ qs)) - end + let enter_type_declaration _ = () + let leave_type_declaration _ = () -(* - Now another satisfiable function that additionally - supplies an example of a matching value. + let enter_type_declarations _ = () + let leave_type_declarations _ = () +end - This function should be called for exhaustiveness check only. -*) +end +module Untypeast : sig +#1 "untypeast.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Thomas Gazagnaire (OCamlPro), Fabrice Le Fessant (INRIA Saclay) *) +(* *) +(* Copyright 2007 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -type 'a result = - | Rnone (* No matching value *) - | Rsome of 'a (* This matching value *) +open Parsetree -(* -let rec try_many f = function - | [] -> Rnone - | (p,pss)::rest -> - match f (p,pss) with - | Rnone -> try_many f rest - | r -> r -*) +val lident_of_path : Path.t -> Longident.t -let rappend r1 r2 = - match r1, r2 with - | Rnone, _ -> r2 - | _, Rnone -> r1 - | Rsome l1, Rsome l2 -> Rsome (l1 @ l2) +type mapper = { + attribute: mapper -> Typedtree.attribute -> attribute; + attributes: mapper -> Typedtree.attribute list -> attribute list; + case: mapper -> Typedtree.case -> case; + cases: mapper -> Typedtree.case list -> case list; + class_declaration: mapper -> Typedtree.class_declaration -> class_declaration; + class_description: mapper -> Typedtree.class_description -> class_description; + class_expr: mapper -> Typedtree.class_expr -> class_expr; + class_field: mapper -> Typedtree.class_field -> class_field; + class_signature: mapper -> Typedtree.class_signature -> class_signature; + class_structure: mapper -> Typedtree.class_structure -> class_structure; + class_type: mapper -> Typedtree.class_type -> class_type; + class_type_declaration: mapper -> Typedtree.class_type_declaration + -> class_type_declaration; + class_type_field: mapper -> Typedtree.class_type_field -> class_type_field; + constructor_declaration: mapper -> Typedtree.constructor_declaration + -> constructor_declaration; + expr: mapper -> Typedtree.expression -> expression; + extension_constructor: mapper -> Typedtree.extension_constructor + -> extension_constructor; + include_declaration: + mapper -> Typedtree.include_declaration -> include_declaration; + include_description: + mapper -> Typedtree.include_description -> include_description; + label_declaration: + mapper -> Typedtree.label_declaration -> label_declaration; + location: mapper -> Location.t -> Location.t; + module_binding: mapper -> Typedtree.module_binding -> module_binding; + module_declaration: + mapper -> Typedtree.module_declaration -> module_declaration; + module_expr: mapper -> Typedtree.module_expr -> module_expr; + module_type: mapper -> Typedtree.module_type -> module_type; + module_type_declaration: + mapper -> Typedtree.module_type_declaration -> module_type_declaration; + package_type: mapper -> Typedtree.package_type -> package_type; + open_description: mapper -> Typedtree.open_description -> open_description; + pat: mapper -> Typedtree.pattern -> pattern; + row_field: mapper -> Typedtree.row_field -> row_field; + object_field: mapper -> Typedtree.object_field -> object_field; + signature: mapper -> Typedtree.signature -> signature; + signature_item: mapper -> Typedtree.signature_item -> signature_item; + structure: mapper -> Typedtree.structure -> structure; + structure_item: mapper -> Typedtree.structure_item -> structure_item; + typ: mapper -> Typedtree.core_type -> core_type; + type_declaration: mapper -> Typedtree.type_declaration -> type_declaration; + type_extension: mapper -> Typedtree.type_extension -> type_extension; + type_kind: mapper -> Typedtree.type_kind -> type_kind; + value_binding: mapper -> Typedtree.value_binding -> value_binding; + value_description: mapper -> Typedtree.value_description -> value_description; + with_constraint: + mapper -> (Path.t * Longident.t Location.loc * Typedtree.with_constraint) + -> with_constraint; +} -let rec try_many_gadt f = function - | [] -> Rnone - | (p,pss)::rest -> - rappend (f (p, pss)) (try_many_gadt f rest) +val default_mapper : mapper -(* -let rec exhaust ext pss n = match pss with -| [] -> Rsome (omegas n) -| []::_ -> Rnone -| pss -> - let q0 = discr_pat omega pss in - begin match filter_all q0 pss with - (* first column of pss is made of variables only *) - | [] -> - begin match exhaust ext (filter_extra pss) (n-1) with - | Rsome r -> Rsome (q0::r) - | r -> r - end - | constrs -> - let try_non_omega (p,pss) = - if is_absent_pat p then - Rnone - else - match - exhaust - ext pss (List.length (simple_match_args p omega) + n - 1) - with - | Rsome r -> Rsome (set_args p r) - | r -> r in - if - full_match true false constrs && not (should_extend ext constrs) - then - try_many try_non_omega constrs - else - (* - D = filter_extra pss is the default matrix - as it is included in pss, one can avoid - recursive calls on specialized matrices, - Essentially : - * D exhaustive => pss exhaustive - * D non-exhaustive => we have a non-filtered value - *) - let r = exhaust ext (filter_extra pss) (n-1) in - match r with - | Rnone -> Rnone - | Rsome r -> - try - Rsome (build_other ext constrs::r) - with - (* cannot occur, since constructors don't make a full signature *) - | Empty -> fatal_error "Parmatch.exhaust" - end +val untype_structure : ?mapper:mapper -> Typedtree.structure -> structure +val untype_signature : ?mapper:mapper -> Typedtree.signature -> signature + +val constant : Asttypes.constant -> Parsetree.constant + +end = struct +#1 "untypeast.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Thomas Gazagnaire (OCamlPro), Fabrice Le Fessant (INRIA Saclay) *) +(* *) +(* Copyright 2007 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) + +open Longident +open Asttypes +open Parsetree +open Ast_helper + +module T = Typedtree + +type mapper = { + attribute: mapper -> T.attribute -> attribute; + attributes: mapper -> T.attribute list -> attribute list; + case: mapper -> T.case -> case; + cases: mapper -> T.case list -> case list; + class_declaration: mapper -> T.class_declaration -> class_declaration; + class_description: mapper -> T.class_description -> class_description; + class_expr: mapper -> T.class_expr -> class_expr; + class_field: mapper -> T.class_field -> class_field; + class_signature: mapper -> T.class_signature -> class_signature; + class_structure: mapper -> T.class_structure -> class_structure; + class_type: mapper -> T.class_type -> class_type; + class_type_declaration: mapper -> T.class_type_declaration + -> class_type_declaration; + class_type_field: mapper -> T.class_type_field -> class_type_field; + constructor_declaration: mapper -> T.constructor_declaration + -> constructor_declaration; + expr: mapper -> T.expression -> expression; + extension_constructor: mapper -> T.extension_constructor + -> extension_constructor; + include_declaration: mapper -> T.include_declaration -> include_declaration; + include_description: mapper -> T.include_description -> include_description; + label_declaration: mapper -> T.label_declaration -> label_declaration; + location: mapper -> Location.t -> Location.t; + module_binding: mapper -> T.module_binding -> module_binding; + module_declaration: mapper -> T.module_declaration -> module_declaration; + module_expr: mapper -> T.module_expr -> module_expr; + module_type: mapper -> T.module_type -> module_type; + module_type_declaration: + mapper -> T.module_type_declaration -> module_type_declaration; + package_type: mapper -> T.package_type -> package_type; + open_description: mapper -> T.open_description -> open_description; + pat: mapper -> T.pattern -> pattern; + row_field: mapper -> T.row_field -> row_field; + object_field: mapper -> T.object_field -> object_field; + signature: mapper -> T.signature -> signature; + signature_item: mapper -> T.signature_item -> signature_item; + structure: mapper -> T.structure -> structure; + structure_item: mapper -> T.structure_item -> structure_item; + typ: mapper -> T.core_type -> core_type; + type_declaration: mapper -> T.type_declaration -> type_declaration; + type_extension: mapper -> T.type_extension -> type_extension; + type_kind: mapper -> T.type_kind -> type_kind; + value_binding: mapper -> T.value_binding -> value_binding; + value_description: mapper -> T.value_description -> value_description; + with_constraint: + mapper -> (Path.t * Longident.t Location.loc * T.with_constraint) + -> with_constraint; +} + +open T -let combinations f lst lst' = - let rec iter2 x = - function - [] -> [] - | y :: ys -> - f x y :: iter2 x ys - in - let rec iter = - function - [] -> [] - | x :: xs -> iter2 x lst' @ iter xs - in - iter lst -*) (* -let print_pat pat = - let rec string_of_pat pat = - match pat.pat_desc with - Tpat_var _ -> "v" - | Tpat_any -> "_" - | Tpat_alias (p, x) -> Printf.sprintf "(%s) as ?" (string_of_pat p) - | Tpat_constant n -> "0" - | Tpat_construct (_, lid, _) -> - Printf.sprintf "%s" (String.concat "." (Longident.flatten lid.txt)) - | Tpat_lazy p -> - Printf.sprintf "(lazy %s)" (string_of_pat p) - | Tpat_or (p1,p2,_) -> - Printf.sprintf "(%s | %s)" (string_of_pat p1) (string_of_pat p2) - | Tpat_tuple list -> - Printf.sprintf "(%s)" (String.concat "," (List.map string_of_pat list)) - | Tpat_variant (_, _, _) -> "variant" - | Tpat_record (_, _) -> "record" - | Tpat_array _ -> "array" - in - Printf.fprintf stderr "PAT[%s]\n%!" (string_of_pat pat) +Some notes: + + * For Pexp_function, we cannot go back to the exact original version + when there is a default argument, because the default argument is + translated in the typer. The code, if printed, will not be parsable because + new generated identifiers are not correct. + + * For Pexp_apply, it is unclear whether arguments are reordered, especially + when there are optional arguments. + *) -(* strictly more powerful than exhaust; however, exhaust - was kept for backwards compatibility *) -let rec exhaust_gadt (ext:Path.t option) pss n = match pss with -| [] -> Rsome [omegas n] -| []::_ -> Rnone -| pss -> - if not (all_coherent (simplified_first_col pss)) then - (* We're considering an ill-typed branch, we won't actually be able to - produce a well typed value taking that branch. *) - Rnone - else begin - (* Assuming the first column is ill-typed but considered coherent, we - might end up producing an ill-typed witness of non-exhaustivity - corresponding to the current branch. - If [exhaust] has been called by [do_check_partial], then the witnesses - produced get typechecked and the ill-typed ones are discarded. +(** Utility functions. *) - If [exhaust] has been called by [do_check_fragile], then it is possible - we might fail to warn the user that the matching is fragile. See for - example testsuite/tests/warnings/w04_failure.ml. *) - let q0 = discr_pat omega pss in - match filter_all q0 pss with - (* first column of pss is made of variables only *) - | [] -> - begin match exhaust_gadt ext (filter_extra pss) (n-1) with - | Rsome r -> Rsome (List.map (fun row -> q0::row) r) - | r -> r - end - | constrs -> - let try_non_omega (p,pss) = - if is_absent_pat p then - Rnone - else - match - exhaust_gadt - ext pss (List.length (simple_match_args p omega) + n - 1) - with - | Rsome r -> Rsome (List.map (fun row -> (set_args p row)) r) - | r -> r in - let before = try_many_gadt try_non_omega constrs in - if - full_match false constrs && not (should_extend ext constrs) - then - before - else - (* - D = filter_extra pss is the default matrix - as it is included in pss, one can avoid - recursive calls on specialized matrices, - Essentially : - * D exhaustive => pss exhaustive - * D non-exhaustive => we have a non-filtered value - *) - let r = exhaust_gadt ext (filter_extra pss) (n-1) in - match r with - | Rnone -> before - | Rsome r -> - try - let p = build_other ext constrs in - let dug = List.map (fun tail -> p :: tail) r in - match before with - | Rnone -> Rsome dug - | Rsome x -> Rsome (x @ dug) - with - (* cannot occur, since constructors don't make a full signature *) - | Empty -> fatal_error "Parmatch.exhaust" - end +let string_is_prefix sub str = + let sublen = String.length sub in + String.length str >= sublen && String.sub str 0 sublen = sub -let exhaust_gadt ext pss n = - let ret = exhaust_gadt ext pss n in - match ret with - Rnone -> Rnone - | Rsome lst -> - (* The following line is needed to compile stdlib/printf.ml *) - if lst = [] then Rsome (omegas n) else - let singletons = - List.map - (function - [x] -> x - | _ -> assert false) - lst - in - Rsome [orify_many singletons] +let map_opt f = function None -> None | Some e -> Some (f e) -(* - Another exhaustiveness check, enforcing variant typing. - Note that it does not check exact exhaustiveness, but whether a - matching could be made exhaustive by closing all variant types. - When this is true of all other columns, the current column is left - open (even if it means that the whole matching is not exhaustive as - a result). - When this is false for the matrix minus the current column, and the - current column is composed of variant tags, we close the variant - (even if it doesn't help in making the matching exhaustive). -*) +let rec lident_of_path = function + | Path.Pident id -> Longident.Lident (Ident.name id) + | Path.Pdot (p, s, _) -> Longident.Ldot (lident_of_path p, s) + | Path.Papply (p1, p2) -> + Longident.Lapply (lident_of_path p1, lident_of_path p2) -let rec pressure_variants tdefs = function - | [] -> false - | []::_ -> true - | pss -> - if not (all_coherent (simplified_first_col pss)) then - true - else begin - let q0 = discr_pat omega pss in - match filter_all q0 pss with - [] -> pressure_variants tdefs (filter_extra pss) - | constrs -> - let rec try_non_omega = function - (_p,pss) :: rem -> - let ok = pressure_variants tdefs pss in - try_non_omega rem && ok - | [] -> true - in - if full_match (tdefs=None) constrs then - try_non_omega constrs - else if tdefs = None then - pressure_variants None (filter_extra pss) - else - let full = full_match true constrs in - let ok = - if full then try_non_omega constrs - else try_non_omega (filter_all q0 (mark_partial pss)) - in - begin match constrs, tdefs with - ({pat_desc=Tpat_variant _} as p,_):: _, Some env -> - let row = row_of_pat p in - if Btype.row_fixed row - || pressure_variants None (filter_extra pss) then () - else close_variant env row - | _ -> () - end; - ok - end +let map_loc sub {loc; txt} = {loc = sub.location sub loc; txt} +(** Try a name [$name$0], check if it's free, if not, increment and repeat. *) +let fresh_name s env = + let rec aux i = + let name = s ^ string_of_int i in + try + let _ = Env.lookup_value (Lident name) env in + name + with + | Not_found -> aux (i+1) + in + aux 0 -(* Yet another satisfiable function *) +(** Mapping functions. *) -(* - This time every_satisfiable pss qs checks the - utility of every expansion of qs. - Expansion means expansion of or-patterns inside qs -*) +let constant = function + | Const_char c -> Pconst_char c + | Const_string (s,d) -> Pconst_string (s,d) + | Const_int i -> Pconst_integer (string_of_int i, None) + | Const_int32 i -> Pconst_integer (Int32.to_string i, Some 'l') + | Const_int64 i -> Pconst_integer (Int64.to_string i, Some 'L') + | Const_nativeint i -> Pconst_integer (Nativeint.to_string i, Some 'n') + | Const_float f -> Pconst_float (f,None) -type answer = - | Used (* Useful pattern *) - | Unused (* Useless pattern *) - | Upartial of Typedtree.pattern list (* Mixed, with list of useless ones *) +let attribute sub (s, p) = (map_loc sub s, p) +let attributes sub l = List.map (sub.attribute sub) l +let structure sub str = + List.map (sub.structure_item sub) str.str_items +let open_description sub od = + let loc = sub.location sub od.open_loc in + let attrs = sub.attributes sub od.open_attributes in + Opn.mk ~loc ~attrs + ~override:od.open_override + (map_loc sub od.open_txt) -(* this row type enable column processing inside the matrix - - left -> elements not to be processed, - - right -> elements to be processed -*) -type 'a row = {no_ors : 'a list ; ors : 'a list ; active : 'a list} +let structure_item sub item = + let loc = sub.location sub item.str_loc in + let desc = + match item.str_desc with + Tstr_eval (exp, attrs) -> Pstr_eval (sub.expr sub exp, attrs) + | Tstr_value (rec_flag, list) -> + Pstr_value (rec_flag, List.map (sub.value_binding sub) list) + | Tstr_primitive vd -> + Pstr_primitive (sub.value_description sub vd) + | Tstr_type (rec_flag, list) -> + Pstr_type (rec_flag, List.map (sub.type_declaration sub) list) + | Tstr_typext tyext -> + Pstr_typext (sub.type_extension sub tyext) + | Tstr_exception ext -> + Pstr_exception (sub.extension_constructor sub ext) + | Tstr_module mb -> + Pstr_module (sub.module_binding sub mb) + | Tstr_recmodule list -> + Pstr_recmodule (List.map (sub.module_binding sub) list) + | Tstr_modtype mtd -> + Pstr_modtype (sub.module_type_declaration sub mtd) + | Tstr_open od -> + Pstr_open (sub.open_description sub od) + | Tstr_class list -> + Pstr_class + (List.map + (fun (ci, _) -> sub.class_declaration sub ci) + list) + | Tstr_class_type list -> + Pstr_class_type + (List.map + (fun (_id, _name, ct) -> sub.class_type_declaration sub ct) + list) + | Tstr_include incl -> + Pstr_include (sub.include_declaration sub incl) + | Tstr_attribute x -> + Pstr_attribute x + in + Str.mk ~loc desc +let value_description sub v = + let loc = sub.location sub v.val_loc in + let attrs = sub.attributes sub v.val_attributes in + Val.mk ~loc ~attrs + ~prim:v.val_prim + (map_loc sub v.val_name) + (sub.typ sub v.val_desc) -(* -let pretty_row {ors=ors ; no_ors=no_ors; active=active} = - pretty_line ors ; prerr_string " *" ; - pretty_line no_ors ; prerr_string " *" ; - pretty_line active +let module_binding sub mb = + let loc = sub.location sub mb.mb_loc in + let attrs = sub.attributes sub mb.mb_attributes in + Mb.mk ~loc ~attrs + (map_loc sub mb.mb_name) + (sub.module_expr sub mb.mb_expr) -let pretty_rows rs = - prerr_endline "begin matrix" ; - List.iter - (fun r -> - pretty_row r ; - prerr_endline "") - rs ; - prerr_endline "end matrix" -*) +let type_parameter sub (ct, v) = (sub.typ sub ct, v) -(* Initial build *) -let make_row ps = {ors=[] ; no_ors=[]; active=ps} +let type_declaration sub decl = + let loc = sub.location sub decl.typ_loc in + let attrs = sub.attributes sub decl.typ_attributes in + Type.mk ~loc ~attrs + ~params:(List.map (type_parameter sub) decl.typ_params) + ~cstrs:( + List.map + (fun (ct1, ct2, loc) -> + (sub.typ sub ct1, sub.typ sub ct2, sub.location sub loc)) + decl.typ_cstrs) + ~kind:(sub.type_kind sub decl.typ_kind) + ~priv:decl.typ_private + ?manifest:(map_opt (sub.typ sub) decl.typ_manifest) + (map_loc sub decl.typ_name) -let make_rows pss = List.map make_row pss +let type_kind sub tk = match tk with + | Ttype_abstract -> Ptype_abstract + | Ttype_variant list -> + Ptype_variant (List.map (sub.constructor_declaration sub) list) + | Ttype_record list -> + Ptype_record (List.map (sub.label_declaration sub) list) + | Ttype_open -> Ptype_open +let constructor_arguments sub = function + | Cstr_tuple l -> Pcstr_tuple (List.map (sub.typ sub) l) + | Cstr_record l -> Pcstr_record (List.map (sub.label_declaration sub) l) -(* Useful to detect and expand or pats inside as pats *) -let rec unalias p = match p.pat_desc with -| Tpat_alias (p,_,_) -> unalias p -| _ -> p +let constructor_declaration sub cd = + let loc = sub.location sub cd.cd_loc in + let attrs = sub.attributes sub cd.cd_attributes in + Type.constructor ~loc ~attrs + ~args:(constructor_arguments sub cd.cd_args) + ?res:(map_opt (sub.typ sub) cd.cd_res) + (map_loc sub cd.cd_name) +let label_declaration sub ld = + let loc = sub.location sub ld.ld_loc in + let attrs = sub.attributes sub ld.ld_attributes in + Type.field ~loc ~attrs + ~mut:ld.ld_mutable + (map_loc sub ld.ld_name) + (sub.typ sub ld.ld_type) -let is_var p = match (unalias p).pat_desc with -| Tpat_any|Tpat_var _ -> true -| _ -> false +let type_extension sub tyext = + let attrs = sub.attributes sub tyext.tyext_attributes in + Te.mk ~attrs + ~params:(List.map (type_parameter sub) tyext.tyext_params) + ~priv:tyext.tyext_private + (map_loc sub tyext.tyext_txt) + (List.map (sub.extension_constructor sub) tyext.tyext_constructors) -let is_var_column rs = - List.for_all - (fun r -> match r.active with - | p::_ -> is_var p - | [] -> assert false) - rs +let extension_constructor sub ext = + let loc = sub.location sub ext.ext_loc in + let attrs = sub.attributes sub ext.ext_attributes in + Te.constructor ~loc ~attrs + (map_loc sub ext.ext_name) + (match ext.ext_kind with + | Text_decl (args, ret) -> + Pext_decl (constructor_arguments sub args, + map_opt (sub.typ sub) ret) + | Text_rebind (_p, lid) -> Pext_rebind (map_loc sub lid) + ) -(* Standard or-args for left-to-right matching *) -let rec or_args p = match p.pat_desc with -| Tpat_or (p1,p2,_) -> p1,p2 -| Tpat_alias (p,_,_) -> or_args p -| _ -> assert false +let pattern sub pat = + let loc = sub.location sub pat.pat_loc in + (* todo: fix attributes on extras *) + let attrs = sub.attributes sub pat.pat_attributes in + let desc = + match pat with + { pat_extra=[Tpat_unpack, _, _attrs]; pat_desc = Tpat_var (_,name); _ } -> + Ppat_unpack name + | { pat_extra=[Tpat_type (_path, lid), _, _attrs]; _ } -> + Ppat_type (map_loc sub lid) + | { pat_extra= (Tpat_constraint ct, _, _attrs) :: rem; _ } -> + Ppat_constraint (sub.pat sub { pat with pat_extra=rem }, + sub.typ sub ct) + | _ -> + match pat.pat_desc with + Tpat_any -> Ppat_any + | Tpat_var (id, name) -> + begin + match (Ident.name id).[0] with + 'A'..'Z' -> + Ppat_unpack name + | _ -> + Ppat_var name + end -(* Just remove current column *) -let remove r = match r.active with -| _::rem -> {r with active=rem} -| [] -> assert false + (* We transform (_ as x) in x if _ and x have the same location. + The compiler transforms (x:t) into (_ as x : t). + This avoids transforming a warning 27 into a 26. + *) + | Tpat_alias ({pat_desc = Tpat_any; pat_loc}, _id, name) + when pat_loc = pat.pat_loc -> + Ppat_var name -let remove_column rs = List.map remove rs + | Tpat_alias (pat, _id, name) -> + Ppat_alias (sub.pat sub pat, name) + | Tpat_constant cst -> Ppat_constant (constant cst) + | Tpat_tuple list -> + Ppat_tuple (List.map (sub.pat sub) list) + | Tpat_construct (lid, _, args) -> + Ppat_construct (map_loc sub lid, + (match args with + [] -> None + | [arg] -> Some (sub.pat sub arg) + | args -> + Some + (Pat.tuple ~loc + (List.map (sub.pat sub) args) + ) + )) + | Tpat_variant (label, pato, _) -> + Ppat_variant (label, map_opt (sub.pat sub) pato) + | Tpat_record (list, closed) -> + Ppat_record (List.map (fun (lid, _, pat) -> + map_loc sub lid, sub.pat sub pat) list, closed) + | Tpat_array list -> Ppat_array (List.map (sub.pat sub) list) + | Tpat_or (p1, p2, _) -> Ppat_or (sub.pat sub p1, sub.pat sub p2) + | Tpat_lazy p -> Ppat_lazy (sub.pat sub p) + in + Pat.mk ~loc ~attrs desc -(* Current column has been processed *) -let push_no_or r = match r.active with -| p::rem -> { r with no_ors = p::r.no_ors ; active=rem} -| [] -> assert false +let exp_extra sub (extra, loc, attrs) sexp = + let loc = sub.location sub loc in + let attrs = sub.attributes sub attrs in + let desc = + match extra with + Texp_coerce (cty1, cty2) -> + Pexp_coerce (sexp, + map_opt (sub.typ sub) cty1, + sub.typ sub cty2) + | Texp_constraint cty -> + Pexp_constraint (sexp, sub.typ sub cty) + | Texp_open (ovf, _path, lid, _) -> + Pexp_open (ovf, map_loc sub lid, sexp) + | Texp_poly cto -> Pexp_poly (sexp, map_opt (sub.typ sub) cto) + | Texp_newtype s -> Pexp_newtype (mkloc s loc, sexp) + in + Exp.mk ~loc ~attrs desc -let push_or r = match r.active with -| p::rem -> { r with ors = p::r.ors ; active=rem} -| [] -> assert false +let cases sub l = List.map (sub.case sub) l -let push_or_column rs = List.map push_or rs -and push_no_or_column rs = List.map push_no_or rs +let case sub {c_lhs; c_guard; c_rhs} = + { + pc_lhs = sub.pat sub c_lhs; + pc_guard = map_opt (sub.expr sub) c_guard; + pc_rhs = sub.expr sub c_rhs; + } -(* Those are adaptations of the previous homonymous functions that - work on the current column, instead of the first column -*) +let value_binding sub vb = + let loc = sub.location sub vb.vb_loc in + let attrs = sub.attributes sub vb.vb_attributes in + Vb.mk ~loc ~attrs + (sub.pat sub vb.vb_pat) + (sub.expr sub vb.vb_expr) + +let expression sub exp = + let loc = sub.location sub exp.exp_loc in + let attrs = sub.attributes sub exp.exp_attributes in + let desc = + match exp.exp_desc with + Texp_ident (_path, lid, _) -> Pexp_ident (map_loc sub lid) + | Texp_constant cst -> Pexp_constant (constant cst) + | Texp_let (rec_flag, list, exp) -> + Pexp_let (rec_flag, + List.map (sub.value_binding sub) list, + sub.expr sub exp) + + (* Pexp_function can't have a label, so we split in 3 cases. *) + (* One case, no guard: It's a fun. *) + | Texp_function { arg_label; cases = [{c_lhs=p; c_guard=None; c_rhs=e}]; + _ } -> + Pexp_fun (arg_label, None, sub.pat sub p, sub.expr sub e) + (* No label: it's a function. *) + | Texp_function { arg_label = Nolabel; cases; _; } -> + Pexp_function (sub.cases sub cases) + (* Mix of both, we generate `fun ~label:$name$ -> match $name$ with ...` *) + | Texp_function { arg_label = Labelled s | Optional s as label; cases; + _ } -> + let name = fresh_name s exp.exp_env in + Pexp_fun (label, None, Pat.var ~loc {loc;txt = name }, + Exp.match_ ~loc (Exp.ident ~loc {loc;txt= Lident name}) + (sub.cases sub cases)) + | Texp_apply (exp, list) -> + Pexp_apply (sub.expr sub exp, + List.fold_right (fun (label, expo) list -> + match expo with + None -> list + | Some exp -> (label, sub.expr sub exp) :: list + ) list []) + | Texp_match (exp, cases, exn_cases, _) -> + let merged_cases = sub.cases sub cases + @ List.map + (fun c -> + let uc = sub.case sub c in + let pat = { uc.pc_lhs + with ppat_desc = Ppat_exception uc.pc_lhs } + in + { uc with pc_lhs = pat }) + exn_cases + in + Pexp_match (sub.expr sub exp, merged_cases) + | Texp_try (exp, cases) -> + Pexp_try (sub.expr sub exp, sub.cases sub cases) + | Texp_tuple list -> + Pexp_tuple (List.map (sub.expr sub) list) + | Texp_construct (lid, _, args) -> + Pexp_construct (map_loc sub lid, + (match args with + [] -> None + | [ arg ] -> Some (sub.expr sub arg) + | args -> + Some + (Exp.tuple ~loc (List.map (sub.expr sub) args)) + )) + | Texp_variant (label, expo) -> + Pexp_variant (label, map_opt (sub.expr sub) expo) + | Texp_record { fields; extended_expression; _ } -> + let list = Array.fold_left (fun l -> function + | _, Kept _ -> l + | _, Overridden (lid, exp) -> (lid, sub.expr sub exp) :: l) + [] fields + in + Pexp_record (list, map_opt (sub.expr sub) extended_expression) + | Texp_field (exp, lid, _label) -> + Pexp_field (sub.expr sub exp, map_loc sub lid) + | Texp_setfield (exp1, lid, _label, exp2) -> + Pexp_setfield (sub.expr sub exp1, map_loc sub lid, + sub.expr sub exp2) + | Texp_array list -> + Pexp_array (List.map (sub.expr sub) list) + | Texp_ifthenelse (exp1, exp2, expo) -> + Pexp_ifthenelse (sub.expr sub exp1, + sub.expr sub exp2, + map_opt (sub.expr sub) expo) + | Texp_sequence (exp1, exp2) -> + Pexp_sequence (sub.expr sub exp1, sub.expr sub exp2) + | Texp_while (exp1, exp2) -> + Pexp_while (sub.expr sub exp1, sub.expr sub exp2) + | Texp_for (_id, name, exp1, exp2, dir, exp3) -> + Pexp_for (name, + sub.expr sub exp1, sub.expr sub exp2, + dir, sub.expr sub exp3) + | Texp_send (exp, meth, _) -> + Pexp_send (sub.expr sub exp, match meth with + Tmeth_name name -> mkloc name loc + | Tmeth_val id -> mkloc (Ident.name id) loc) + | Texp_new (_path, lid, _) -> Pexp_new (map_loc sub lid) + | Texp_instvar (_, path, name) -> + Pexp_ident ({loc = sub.location sub name.loc ; txt = lident_of_path path}) + | Texp_setinstvar (_, _path, lid, exp) -> + Pexp_setinstvar (map_loc sub lid, sub.expr sub exp) + | Texp_override (_, list) -> + Pexp_override (List.map (fun (_path, lid, exp) -> + (map_loc sub lid, sub.expr sub exp) + ) list) + | Texp_letmodule (_id, name, mexpr, exp) -> + Pexp_letmodule (name, sub.module_expr sub mexpr, + sub.expr sub exp) + | Texp_letexception (ext, exp) -> + Pexp_letexception (sub.extension_constructor sub ext, + sub.expr sub exp) + | Texp_assert exp -> Pexp_assert (sub.expr sub exp) + | Texp_lazy exp -> Pexp_lazy (sub.expr sub exp) + | Texp_object (cl, _) -> + Pexp_object (sub.class_structure sub cl) + | Texp_pack (mexpr) -> + Pexp_pack (sub.module_expr sub mexpr) + | Texp_unreachable -> + Pexp_unreachable + | Texp_extension_constructor (lid, _) -> + Pexp_extension ({ txt = "ocaml.extension_constructor"; loc }, + PStr [ Str.eval ~loc + (Exp.construct ~loc (map_loc sub lid) None) + ]) + in + List.fold_right (exp_extra sub) exp.exp_extra + (Exp.mk ~loc ~attrs desc) -let discr_pat q rs = - discr_pat q (List.map (fun r -> r.active) rs) +let package_type sub pack = + (map_loc sub pack.pack_txt, + List.map (fun (s, ct) -> + (s, sub.typ sub ct)) pack.pack_fields) -let filter_one q rs = - let rec filter_rec rs = match rs with - | [] -> [] - | r::rem -> - match r.active with - | [] -> assert false - | {pat_desc = Tpat_alias(p,_,_)}::ps -> - filter_rec ({r with active = p::ps}::rem) - | {pat_desc = Tpat_or(p1,p2,_)}::ps -> - filter_rec - ({r with active = p1::ps}:: - {r with active = p2::ps}:: - rem) - | p::ps -> - if simple_match q p then - {r with active=simple_match_args q p @ ps} :: filter_rec rem - else - filter_rec rem in - filter_rec rs +let module_type_declaration sub mtd = + let loc = sub.location sub mtd.mtd_loc in + let attrs = sub.attributes sub mtd.mtd_attributes in + Mtd.mk ~loc ~attrs + ?typ:(map_opt (sub.module_type sub) mtd.mtd_type) + (map_loc sub mtd.mtd_name) +let signature sub sg = + List.map (sub.signature_item sub) sg.sig_items -(* Back to normal matrices *) -let make_vector r = List.rev r.no_ors +let signature_item sub item = + let loc = sub.location sub item.sig_loc in + let desc = + match item.sig_desc with + Tsig_value v -> + Psig_value (sub.value_description sub v) + | Tsig_type (rec_flag, list) -> + Psig_type (rec_flag, List.map (sub.type_declaration sub) list) + | Tsig_typext tyext -> + Psig_typext (sub.type_extension sub tyext) + | Tsig_exception ext -> + Psig_exception (sub.extension_constructor sub ext) + | Tsig_module md -> + Psig_module (sub.module_declaration sub md) + | Tsig_recmodule list -> + Psig_recmodule (List.map (sub.module_declaration sub) list) + | Tsig_modtype mtd -> + Psig_modtype (sub.module_type_declaration sub mtd) + | Tsig_open od -> + Psig_open (sub.open_description sub od) + | Tsig_include incl -> + Psig_include (sub.include_description sub incl) + | Tsig_class list -> + Psig_class (List.map (sub.class_description sub) list) + | Tsig_class_type list -> + Psig_class_type (List.map (sub.class_type_declaration sub) list) + | Tsig_attribute x -> + Psig_attribute x + in + Sig.mk ~loc desc -let make_matrix rs = List.map make_vector rs +let module_declaration sub md = + let loc = sub.location sub md.md_loc in + let attrs = sub.attributes sub md.md_attributes in + Md.mk ~loc ~attrs + (map_loc sub md.md_name) + (sub.module_type sub md.md_type) +let include_infos f sub incl = + let loc = sub.location sub incl.incl_loc in + let attrs = sub.attributes sub incl.incl_attributes in + Incl.mk ~loc ~attrs + (f sub incl.incl_mod) -(* Standard union on answers *) -let union_res r1 r2 = match r1, r2 with -| (Unused,_) -| (_, Unused) -> Unused -| Used,_ -> r2 -| _, Used -> r1 -| Upartial u1, Upartial u2 -> Upartial (u1@u2) +let include_declaration sub = include_infos sub.module_expr sub +let include_description sub = include_infos sub.module_type sub -(* propose or pats for expansion *) -let extract_elements qs = - let rec do_rec seen = function - | [] -> [] - | q::rem -> - {no_ors= List.rev_append seen rem @ qs.no_ors ; - ors=[] ; - active = [q]}:: - do_rec (q::seen) rem in - do_rec [] qs.ors +let class_infos f sub ci = + let loc = sub.location sub ci.ci_loc in + let attrs = sub.attributes sub ci.ci_attributes in + Ci.mk ~loc ~attrs + ~virt:ci.ci_virt + ~params:(List.map (type_parameter sub) ci.ci_params) + (map_loc sub ci.ci_id_name) + (f sub ci.ci_expr) -(* idem for matrices *) -let transpose rs = match rs with -| [] -> assert false -| r::rem -> - let i = List.map (fun x -> [x]) r in - List.fold_left - (List.map2 (fun r x -> x::r)) - i rem +let class_declaration sub = class_infos sub.class_expr sub +let class_description sub = class_infos sub.class_type sub +let class_type_declaration sub = class_infos sub.class_type sub -let extract_columns pss qs = match pss with -| [] -> List.map (fun _ -> []) qs.ors -| _ -> - let rows = List.map extract_elements pss in - transpose rows +let module_type sub mty = + let loc = sub.location sub mty.mty_loc in + let attrs = sub.attributes sub mty.mty_attributes in + let desc = match mty.mty_desc with + Tmty_ident (_path, lid) -> Pmty_ident (map_loc sub lid) + | Tmty_alias (_path, lid) -> Pmty_alias (map_loc sub lid) + | Tmty_signature sg -> Pmty_signature (sub.signature sub sg) + | Tmty_functor (_id, name, mtype1, mtype2) -> + Pmty_functor (name, map_opt (sub.module_type sub) mtype1, + sub.module_type sub mtype2) + | Tmty_with (mtype, list) -> + Pmty_with (sub.module_type sub mtype, + List.map (sub.with_constraint sub) list) + | Tmty_typeof mexpr -> + Pmty_typeof (sub.module_expr sub mexpr) + in + Mty.mk ~loc ~attrs desc -(* Core function - The idea is to first look for or patterns (recursive case), then - check or-patterns argument usefulness (terminal case) -*) -let rec simplified_first_usefulness_col = function - | [] -> [] - | row :: rows -> - match row.active with - | [] -> assert false (* the rows are non-empty! *) - | p :: _ -> simplify_head_pat p (simplified_first_usefulness_col rows) +let with_constraint sub (_path, lid, cstr) = + match cstr with + | Twith_type decl -> + Pwith_type (map_loc sub lid, sub.type_declaration sub decl) + | Twith_module (_path, lid2) -> + Pwith_module (map_loc sub lid, map_loc sub lid2) + | Twith_typesubst decl -> + Pwith_typesubst (map_loc sub lid, sub.type_declaration sub decl) + | Twith_modsubst (_path, lid2) -> + Pwith_modsubst (map_loc sub lid, map_loc sub lid2) -let rec every_satisfiables pss qs = match qs.active with -| [] -> - (* qs is now partitionned, check usefulness *) - begin match qs.ors with - | [] -> (* no or-patterns *) - if satisfiable (make_matrix pss) (make_vector qs) then - Used - else - Unused - | _ -> (* n or-patterns -> 2n expansions *) - List.fold_right2 - (fun pss qs r -> match r with - | Unused -> Unused - | _ -> - match qs.active with - | [q] -> - let q1,q2 = or_args q in - let r_loc = every_both pss qs q1 q2 in - union_res r r_loc - | _ -> assert false) - (extract_columns pss qs) (extract_elements qs) - Used - end -| q::rem -> - let uq = unalias q in - begin match uq.pat_desc with - | Tpat_any | Tpat_var _ -> - if is_var_column pss then -(* forget about ``all-variable'' columns now *) - every_satisfiables (remove_column pss) (remove qs) - else -(* otherwise this is direct food for satisfiable *) - every_satisfiables (push_no_or_column pss) (push_no_or qs) - | Tpat_or (q1,q2,_) -> - if - q1.pat_loc.Location.loc_ghost && - q2.pat_loc.Location.loc_ghost - then -(* syntactically generated or-pats should not be expanded *) - every_satisfiables (push_no_or_column pss) (push_no_or qs) - else -(* this is a real or-pattern *) - every_satisfiables (push_or_column pss) (push_or qs) - | Tpat_variant (l,_,r) when is_absent l r -> (* Ah Jacques... *) - Unused +let module_expr sub mexpr = + let loc = sub.location sub mexpr.mod_loc in + let attrs = sub.attributes sub mexpr.mod_attributes in + match mexpr.mod_desc with + Tmod_constraint (m, _, Tmodtype_implicit, _ ) -> + sub.module_expr sub m | _ -> -(* standard case, filter matrix *) - (* The handling of incoherent matrices is kept in line with - [satisfiable] *) - if not (all_coherent (uq :: simplified_first_usefulness_col pss)) then - Unused - else begin - let q0 = discr_pat q pss in - every_satisfiables - (filter_one q0 pss) - {qs with active=simple_match_args q0 q @ rem} - end - end + let desc = match mexpr.mod_desc with + Tmod_ident (_p, lid) -> Pmod_ident (map_loc sub lid) + | Tmod_structure st -> Pmod_structure (sub.structure sub st) + | Tmod_functor (_id, name, mtype, mexpr) -> + Pmod_functor (name, Misc.may_map (sub.module_type sub) mtype, + sub.module_expr sub mexpr) + | Tmod_apply (mexp1, mexp2, _) -> + Pmod_apply (sub.module_expr sub mexp1, sub.module_expr sub mexp2) + | Tmod_constraint (mexpr, _, Tmodtype_explicit mtype, _) -> + Pmod_constraint (sub.module_expr sub mexpr, + sub.module_type sub mtype) + | Tmod_constraint (_mexpr, _, Tmodtype_implicit, _) -> + assert false + | Tmod_unpack (exp, _pack) -> + Pmod_unpack (sub.expr sub exp) + (* TODO , sub.package_type sub pack) *) + in + Mod.mk ~loc ~attrs desc -(* - This function ``every_both'' performs the usefulness check - of or-pat q1|q2. - The trick is to call every_satisfied twice with - current active columns restricted to q1 and q2, - That way, - - others orpats in qs.ors will not get expanded. - - all matching work performed on qs.no_ors is not performed again. - *) -and every_both pss qs q1 q2 = - let qs1 = {qs with active=[q1]} - and qs2 = {qs with active=[q2]} in - let r1 = every_satisfiables pss qs1 - and r2 = every_satisfiables (if compat q1 q2 then qs1::pss else pss) qs2 in - match r1 with - | Unused -> - begin match r2 with - | Unused -> Unused - | Used -> Upartial [q1] - | Upartial u2 -> Upartial (q1::u2) - end - | Used -> - begin match r2 with - | Unused -> Upartial [q2] - | _ -> r2 - end - | Upartial u1 -> - begin match r2 with - | Unused -> Upartial (u1@[q2]) - | Used -> r1 - | Upartial u2 -> Upartial (u1 @ u2) - end +let class_expr sub cexpr = + let loc = sub.location sub cexpr.cl_loc in + let attrs = sub.attributes sub cexpr.cl_attributes in + let desc = match cexpr.cl_desc with + | Tcl_constraint ( { cl_desc = Tcl_ident (_path, lid, tyl); _ }, + None, _, _, _ ) -> + Pcl_constr (map_loc sub lid, + List.map (sub.typ sub) tyl) + | Tcl_structure clstr -> Pcl_structure (sub.class_structure sub clstr) + | Tcl_fun (label, pat, _pv, cl, _partial) -> + Pcl_fun (label, None, sub.pat sub pat, sub.class_expr sub cl) + | Tcl_apply (cl, args) -> + Pcl_apply (sub.class_expr sub cl, + List.fold_right (fun (label, expo) list -> + match expo with + None -> list + | Some exp -> (label, sub.expr sub exp) :: list + ) args []) + | Tcl_let (rec_flat, bindings, _ivars, cl) -> + Pcl_let (rec_flat, + List.map (sub.value_binding sub) bindings, + sub.class_expr sub cl) -(* le_pat p q means, forall V, V matches q implies V matches p *) -let rec le_pat p q = - match (p.pat_desc, q.pat_desc) with - | (Tpat_var _|Tpat_any),_ -> true - | Tpat_alias(p,_,_), _ -> le_pat p q - | _, Tpat_alias(q,_,_) -> le_pat p q - | Tpat_constant(c1), Tpat_constant(c2) -> const_compare c1 c2 = 0 - | Tpat_construct(_,c1,ps), Tpat_construct(_,c2,qs) -> - Types.equal_tag c1.cstr_tag c2.cstr_tag && le_pats ps qs - | Tpat_variant(l1,Some p1,_), Tpat_variant(l2,Some p2,_) -> - (l1 = l2 && le_pat p1 p2) - | Tpat_variant(l1,None,_r1), Tpat_variant(l2,None,_) -> - l1 = l2 - | Tpat_variant(_,_,_), Tpat_variant(_,_,_) -> false - | Tpat_tuple(ps), Tpat_tuple(qs) -> le_pats ps qs - | Tpat_lazy p, Tpat_lazy q -> le_pat p q - | Tpat_record (l1,_), Tpat_record (l2,_) -> - let ps,qs = records_args l1 l2 in - le_pats ps qs - | Tpat_array(ps), Tpat_array(qs) -> - List.length ps = List.length qs && le_pats ps qs -(* In all other cases, enumeration is performed *) - | _,_ -> not (satisfiable [[p]] [q]) + | Tcl_constraint (cl, Some clty, _vals, _meths, _concrs) -> + Pcl_constraint (sub.class_expr sub cl, sub.class_type sub clty) -and le_pats ps qs = - match ps,qs with - p::ps, q::qs -> le_pat p q && le_pats ps qs - | _, _ -> true + | Tcl_open (ovf, _p, lid, _env, e) -> + Pcl_open (ovf, lid, sub.class_expr sub e) -let get_mins le ps = - let rec select_rec r = function - [] -> r - | p::ps -> - if List.exists (fun p0 -> le p0 p) ps - then select_rec r ps - else select_rec (p::r) ps in - select_rec [] (select_rec [] ps) + | Tcl_ident _ -> assert false + | Tcl_constraint (_, None, _, _, _) -> assert false + in + Cl.mk ~loc ~attrs desc -(* - lub p q is a pattern that matches all values matched by p and q - may raise Empty, when p and q are not compatible -*) +let class_type sub ct = + let loc = sub.location sub ct.cltyp_loc in + let attrs = sub.attributes sub ct.cltyp_attributes in + let desc = match ct.cltyp_desc with + Tcty_signature csg -> Pcty_signature (sub.class_signature sub csg) + | Tcty_constr (_path, lid, list) -> + Pcty_constr (map_loc sub lid, List.map (sub.typ sub) list) + | Tcty_arrow (label, ct, cl) -> + Pcty_arrow (label, sub.typ sub ct, sub.class_type sub cl) + | Tcty_open (ovf, _p, lid, _env, e) -> + Pcty_open (ovf, lid, sub.class_type sub e) + in + Cty.mk ~loc ~attrs desc -let rec lub p q = match p.pat_desc,q.pat_desc with -| Tpat_alias (p,_,_),_ -> lub p q -| _,Tpat_alias (q,_,_) -> lub p q -| (Tpat_any|Tpat_var _),_ -> q -| _,(Tpat_any|Tpat_var _) -> p -| Tpat_or (p1,p2,_),_ -> orlub p1 p2 q -| _,Tpat_or (q1,q2,_) -> orlub q1 q2 p (* Thanks god, lub is commutative *) -| Tpat_constant c1, Tpat_constant c2 when const_compare c1 c2 = 0 -> p -| Tpat_tuple ps, Tpat_tuple qs -> - let rs = lubs ps qs in - make_pat (Tpat_tuple rs) p.pat_type p.pat_env -| Tpat_lazy p, Tpat_lazy q -> - let r = lub p q in - make_pat (Tpat_lazy r) p.pat_type p.pat_env -| Tpat_construct (lid, c1,ps1), Tpat_construct (_,c2,ps2) - when Types.equal_tag c1.cstr_tag c2.cstr_tag -> - let rs = lubs ps1 ps2 in - make_pat (Tpat_construct (lid, c1,rs)) - p.pat_type p.pat_env -| Tpat_variant(l1,Some p1,row), Tpat_variant(l2,Some p2,_) - when l1=l2 -> - let r=lub p1 p2 in - make_pat (Tpat_variant (l1,Some r,row)) p.pat_type p.pat_env -| Tpat_variant (l1,None,_row), Tpat_variant(l2,None,_) - when l1 = l2 -> p -| Tpat_record (l1,closed),Tpat_record (l2,_) -> - let rs = record_lubs l1 l2 in - make_pat (Tpat_record (rs, closed)) p.pat_type p.pat_env -| Tpat_array ps, Tpat_array qs - when List.length ps = List.length qs -> - let rs = lubs ps qs in - make_pat (Tpat_array rs) p.pat_type p.pat_env -| _,_ -> - raise Empty +let class_signature sub cs = + { + pcsig_self = sub.typ sub cs.csig_self; + pcsig_fields = List.map (sub.class_type_field sub) cs.csig_fields; + } -and orlub p1 p2 q = - try - let r1 = lub p1 q in - try - {q with pat_desc=(Tpat_or (r1,lub p2 q,None))} - with - | Empty -> r1 -with -| Empty -> lub p2 q +let class_type_field sub ctf = + let loc = sub.location sub ctf.ctf_loc in + let attrs = sub.attributes sub ctf.ctf_attributes in + let desc = match ctf.ctf_desc with + Tctf_inherit ct -> Pctf_inherit (sub.class_type sub ct) + | Tctf_val (s, mut, virt, ct) -> + Pctf_val (mkloc s loc, mut, virt, sub.typ sub ct) + | Tctf_method (s, priv, virt, ct) -> + Pctf_method (mkloc s loc, priv, virt, sub.typ sub ct) + | Tctf_constraint (ct1, ct2) -> + Pctf_constraint (sub.typ sub ct1, sub.typ sub ct2) + | Tctf_attribute x -> Pctf_attribute x + in + Ctf.mk ~loc ~attrs desc + +let core_type sub ct = + let loc = sub.location sub ct.ctyp_loc in + let attrs = sub.attributes sub ct.ctyp_attributes in + let desc = match ct.ctyp_desc with + Ttyp_any -> Ptyp_any + | Ttyp_var s -> Ptyp_var s + | Ttyp_arrow (label, ct1, ct2) -> + Ptyp_arrow (label, sub.typ sub ct1, sub.typ sub ct2) + | Ttyp_tuple list -> Ptyp_tuple (List.map (sub.typ sub) list) + | Ttyp_constr (_path, lid, list) -> + Ptyp_constr (map_loc sub lid, + List.map (sub.typ sub) list) + | Ttyp_object (list, o) -> + Ptyp_object + (List.map (sub.object_field sub) list, o) + | Ttyp_class (_path, lid, list) -> + Ptyp_class (map_loc sub lid, List.map (sub.typ sub) list) + | Ttyp_alias (ct, s) -> + Ptyp_alias (sub.typ sub ct, s) + | Ttyp_variant (list, bool, labels) -> + Ptyp_variant (List.map (sub.row_field sub) list, bool, labels) + | Ttyp_poly (list, ct) -> + let list = List.map (fun v -> mkloc v loc) list in + Ptyp_poly (list, sub.typ sub ct) + | Ttyp_package pack -> Ptyp_package (sub.package_type sub pack) + in + Typ.mk ~loc ~attrs desc -and record_lubs l1 l2 = - let rec lub_rec l1 l2 = match l1,l2 with - | [],_ -> l2 - | _,[] -> l1 - | (lid1, lbl1,p1)::rem1, (lid2, lbl2,p2)::rem2 -> - if lbl1.lbl_pos < lbl2.lbl_pos then - (lid1, lbl1,p1)::lub_rec rem1 l2 - else if lbl2.lbl_pos < lbl1.lbl_pos then - (lid2, lbl2,p2)::lub_rec l1 rem2 - else - (lid1, lbl1,lub p1 p2)::lub_rec rem1 rem2 in - lub_rec l1 l2 +let class_structure sub cs = + let rec remove_self = function + | { pat_desc = Tpat_alias (p, id, _s) } + when string_is_prefix "selfpat-" id.Ident.name -> + remove_self p + | p -> p + in + { pcstr_self = sub.pat sub (remove_self cs.cstr_self); + pcstr_fields = List.map (sub.class_field sub) cs.cstr_fields; + } -and lubs ps qs = match ps,qs with -| p::ps, q::qs -> lub p q :: lubs ps qs -| _,_ -> [] +let row_field sub rf = + match rf with + Ttag (label, attrs, bool, list) -> + Rtag (label, sub.attributes sub attrs, bool, List.map (sub.typ sub) list) + | Tinherit ct -> Rinherit (sub.typ sub ct) +let object_field sub ofield = + match ofield with + OTtag (label, attrs, ct) -> + Otag (label, sub.attributes sub attrs, sub.typ sub ct) + | OTinherit ct -> Oinherit (sub.typ sub ct) -(******************************) -(* Exported variant closing *) -(******************************) +and is_self_pat = function + | { pat_desc = Tpat_alias(_pat, id, _) } -> + string_is_prefix "self-" (Ident.name id) + | _ -> false -(* Apply pressure to variants *) +let class_field sub cf = + let loc = sub.location sub cf.cf_loc in + let attrs = sub.attributes sub cf.cf_attributes in + let desc = match cf.cf_desc with + Tcf_inherit (ovf, cl, super, _vals, _meths) -> + Pcf_inherit (ovf, sub.class_expr sub cl, + map_opt (fun v -> mkloc v loc) super) + | Tcf_constraint (cty, cty') -> + Pcf_constraint (sub.typ sub cty, sub.typ sub cty') + | Tcf_val (lab, mut, _, Tcfk_virtual cty, _) -> + Pcf_val (lab, mut, Cfk_virtual (sub.typ sub cty)) + | Tcf_val (lab, mut, _, Tcfk_concrete (o, exp), _) -> + Pcf_val (lab, mut, Cfk_concrete (o, sub.expr sub exp)) + | Tcf_method (lab, priv, Tcfk_virtual cty) -> + Pcf_method (lab, priv, Cfk_virtual (sub.typ sub cty)) + | Tcf_method (lab, priv, Tcfk_concrete (o, exp)) -> + let remove_fun_self = function + | { exp_desc = + Texp_function { arg_label = Nolabel; cases = [case]; _ } } + when is_self_pat case.c_lhs && case.c_guard = None -> case.c_rhs + | e -> e + in + let exp = remove_fun_self exp in + Pcf_method (lab, priv, Cfk_concrete (o, sub.expr sub exp)) + | Tcf_initializer exp -> + let remove_fun_self = function + | { exp_desc = + Texp_function { arg_label = Nolabel; cases = [case]; _ } } + when is_self_pat case.c_lhs && case.c_guard = None -> case.c_rhs + | e -> e + in + let exp = remove_fun_self exp in + Pcf_initializer (sub.expr sub exp) + | Tcf_attribute x -> Pcf_attribute x + in + Cf.mk ~loc ~attrs desc -let pressure_variants tdefs patl = - let pss = List.map (fun p -> [p;omega]) patl in - ignore (pressure_variants (Some tdefs) pss) +let location _sub l = l -(*****************************) -(* Utilities for diagnostics *) -(*****************************) +let default_mapper = + { + attribute = attribute ; + attributes = attributes ; + structure = structure; + structure_item = structure_item; + module_expr = module_expr; + signature = signature; + signature_item = signature_item; + module_type = module_type; + with_constraint = with_constraint; + class_declaration = class_declaration; + class_expr = class_expr; + class_field = class_field; + class_structure = class_structure; + class_type = class_type; + class_type_field = class_type_field; + class_signature = class_signature; + class_type_declaration = class_type_declaration; + class_description = class_description; + type_declaration = type_declaration; + type_kind = type_kind; + typ = core_type; + type_extension = type_extension; + extension_constructor = extension_constructor; + value_description = value_description; + pat = pattern; + expr = expression; + module_declaration = module_declaration; + module_type_declaration = module_type_declaration; + module_binding = module_binding; + package_type = package_type ; + open_description = open_description; + include_description = include_description; + include_declaration = include_declaration; + value_binding = value_binding; + constructor_declaration = constructor_declaration; + label_declaration = label_declaration; + cases = cases; + case = case; + location = location; + row_field = row_field ; + object_field = object_field ; + } -(* - Build up a working pattern matrix by forgetting - about guarded patterns -*) +let untype_structure ?(mapper=default_mapper) structure = + mapper.structure mapper structure -let rec initial_matrix = function - [] -> [] - | {c_guard=Some _} :: rem -> initial_matrix rem - | {c_guard=None; c_lhs=p} :: rem -> [p] :: initial_matrix rem +let untype_signature ?(mapper=default_mapper) signature = + mapper.signature mapper signature -(******************************************) -(* Look for a row that matches some value *) -(******************************************) +end +module Parmatch : sig +#1 "parmatch.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -(* - Useful for seeing if the example of - non-matched value can indeed be matched - (by a guarded clause) -*) +(* Detection of partial matches and unused match cases. *) +open Asttypes +open Typedtree +open Types +val pretty_const : constant -> string +val top_pretty : Format.formatter -> pattern -> unit +val pretty_pat : pattern -> unit +val pretty_line : pattern list -> unit +val pretty_matrix : pattern list list -> unit +val omega : pattern +val omegas : int -> pattern list +val omega_list : 'a list -> pattern list +val normalize_pat : pattern -> pattern +val all_record_args : + (Longident.t loc * label_description * pattern) list -> + (Longident.t loc * label_description * pattern) list +val const_compare : constant -> constant -> int -exception NoGuard +val le_pat : pattern -> pattern -> bool +val le_pats : pattern list -> pattern list -> bool -let rec initial_all no_guard = function - | [] -> - if no_guard then - raise NoGuard - else - [] - | {c_lhs=pat; c_guard; _} :: rem -> - ([pat], pat.pat_loc) :: initial_all (no_guard && c_guard = None) rem +(* Exported compatibility functor, abstracted over constructor equality *) +module Compat : + functor + (Constr: sig + val equal : + Types.constructor_description -> + Types.constructor_description -> + bool + end) -> sig + val compat : pattern -> pattern -> bool + val compats : pattern list -> pattern list -> bool + end +exception Empty +val lub : pattern -> pattern -> pattern +val lubs : pattern list -> pattern list -> pattern list -let rec do_filter_var = function - | (_::ps,loc)::rem -> (ps,loc)::do_filter_var rem - | _ -> [] +val get_mins : ('a -> 'a -> bool) -> 'a list -> 'a list -let do_filter_one q pss = - let rec filter_rec = function - | ({pat_desc = Tpat_alias(p,_,_)}::ps,loc)::pss -> - filter_rec ((p::ps,loc)::pss) - | ({pat_desc = Tpat_or(p1,p2,_)}::ps,loc)::pss -> - filter_rec ((p1::ps,loc)::(p2::ps,loc)::pss) - | (p::ps,loc)::pss -> - if simple_match q p - then (simple_match_args q p @ ps, loc) :: filter_rec pss - else filter_rec pss - | _ -> [] in - filter_rec pss +(* Those two functions recombine one pattern and its arguments: + For instance: + (_,_)::p1::p2::rem -> (p1, p2)::rem + The second one will replace mutable arguments by '_' +*) +val set_args : pattern -> pattern list -> pattern list +val set_args_erase_mutable : pattern -> pattern list -> pattern list -let rec do_match pss qs = match qs with -| [] -> - begin match pss with - | ([],loc)::_ -> Some loc - | _ -> None - end -| q::qs -> match q with - | {pat_desc = Tpat_or (q1,q2,_)} -> - begin match do_match pss (q1::qs) with - | None -> do_match pss (q2::qs) - | r -> r - end - | {pat_desc = Tpat_any} -> - do_match (do_filter_var pss) qs - | _ -> - let q0 = normalize_pat q in - (* [pss] will (or won't) match [q0 :: qs] regardless of the coherence of - its first column. *) - do_match (do_filter_one q0 pss) (simple_match_args q0 q @ qs) +val pat_of_constr : pattern -> constructor_description -> pattern +val complete_constrs : + pattern -> constructor_tag list -> constructor_description list +val ppat_of_type : + Env.t -> type_expr -> + Parsetree.pattern * + (string, constructor_description) Hashtbl.t * + (string, label_description) Hashtbl.t +val pressure_variants: Env.t -> pattern list -> unit +val check_partial_gadt: + ((string, constructor_description) Hashtbl.t -> + (string, label_description) Hashtbl.t -> + Parsetree.pattern -> pattern option) -> + Location.t -> case list -> partial +val check_unused: + (bool -> + (string, constructor_description) Hashtbl.t -> + (string, label_description) Hashtbl.t -> + Parsetree.pattern -> pattern option) -> + case list -> unit -let check_partial_all v casel = - try - let pss = initial_all true casel in - do_match pss [v] - with - | NoGuard -> None +(* Irrefutability tests *) +val irrefutable : pattern -> bool -(************************) -(* Exhaustiveness check *) -(************************) +(** An inactive pattern is a pattern, matching against which can be duplicated, erased or + delayed without change in observable behavior of the program. Patterns containing + (lazy _) subpatterns or reads of mutable fields are active. *) +val inactive : partial:partial -> pattern -> bool -(* conversion from Typedtree.pattern to Parsetree.pattern list *) -module Conv = struct - open Parsetree - let mkpat desc = Ast_helper.Pat.mk desc +(* Ambiguous bindings *) +val check_ambiguous_bindings : case list -> unit - let name_counter = ref 0 - let fresh name = - let current = !name_counter in - name_counter := !name_counter + 1; - "#$" ^ name ^ string_of_int current +(* The tag used for open polymorphic variant types *) +val some_other_tag : label - let conv typed = - let constrs = Hashtbl.create 7 in - let labels = Hashtbl.create 7 in - let rec loop pat = - match pat.pat_desc with - Tpat_or (pa,pb,_) -> - mkpat (Ppat_or (loop pa, loop pb)) - | Tpat_var (_, ({txt="*extension*"} as nm)) -> (* PR#7330 *) - mkpat (Ppat_var nm) - | Tpat_any - | Tpat_var _ -> - mkpat Ppat_any - | Tpat_constant c -> - mkpat (Ppat_constant (Untypeast.constant c)) - | Tpat_alias (p,_,_) -> loop p - | Tpat_tuple lst -> - mkpat (Ppat_tuple (List.map loop lst)) - | Tpat_construct (cstr_lid, cstr, lst) -> - let id = fresh cstr.cstr_name in - let lid = { cstr_lid with txt = Longident.Lident id } in - Hashtbl.add constrs id cstr; - let arg = - match List.map loop lst with - | [] -> None - | [p] -> Some p - | lst -> Some (mkpat (Ppat_tuple lst)) - in - mkpat (Ppat_construct(lid, arg)) - | Tpat_variant(label,p_opt,_row_desc) -> - let arg = Misc.may_map loop p_opt in - mkpat (Ppat_variant(label, arg)) - | Tpat_record (subpatterns, _closed_flag) -> - let fields = - List.map - (fun (_, lbl, p) -> - let id = fresh lbl.lbl_name in - Hashtbl.add labels id lbl; - (mknoloc (Longident.Lident id), loop p)) - subpatterns - in - mkpat (Ppat_record (fields, Open)) - | Tpat_array lst -> - mkpat (Ppat_array (List.map loop lst)) - | Tpat_lazy p -> - mkpat (Ppat_lazy (loop p)) - in - let ps = loop typed in - (ps, constrs, labels) -end +end = struct +#1 "parmatch.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) +(* Detection of partial matches and unused match cases. *) -(* Whether the counter-example contains an extension pattern *) -let contains_extension pat = - let r = ref false in - let rec loop = function - {pat_desc=Tpat_var (_, {txt="*extension*"})} -> - r := true - | p -> Typedtree.iter_pattern_desc loop p.pat_desc - in loop pat; !r +open Misc +open Asttypes +open Types +open Typedtree -(* Build an untyped or-pattern from its expected type *) -let ppat_of_type env ty = - match pats_of_type env ty with - [{pat_desc = Tpat_any}] -> - (Conv.mkpat Parsetree.Ppat_any, Hashtbl.create 0, Hashtbl.create 0) - | pats -> - Conv.conv (orify_many pats) +(*************************************) +(* Utilities for building patterns *) +(*************************************) -let do_check_partial ?pred exhaust loc casel pss = match pss with -| [] -> - (* - This can occur - - For empty matches generated by ocamlp4 (no warning) - - when all patterns have guards (then, casel <> []) - (specific warning) - Then match MUST be considered non-exhaustive, - otherwise compilation of PM is broken. - *) - begin match casel with - | [] -> () - | _ -> - if Warnings.is_active Warnings.All_clauses_guarded then - Location.prerr_warning loc Warnings.All_clauses_guarded - end ; - Partial -| ps::_ -> - begin match exhaust None pss (List.length ps) with - | Rnone -> Total - | Rsome [u] -> - let v = - match pred with - | Some pred -> - let (pattern,constrs,labels) = Conv.conv u in - let u' = pred constrs labels pattern in - (* pretty_pat u; - begin match u' with - None -> prerr_endline ": impossible" - | Some _ -> prerr_endline ": possible" - end; *) - u' - | None -> Some u - in - begin match v with - None -> Total - | Some v -> - if Warnings.is_active (Warnings.Partial_match "") then begin - let errmsg = - try - let buf = Buffer.create 16 in - let fmt = formatter_of_buffer buf in - top_pretty fmt v; - begin match check_partial_all v casel with - | None -> () - | Some _ -> - (* This is 'Some loc', where loc is the location of - a possibly matching clause. - Forget about loc, because printing two locations - is a pain in the top-level *) - Buffer.add_string buf - "\n(However, some guarded clause may match this value.)" - end; - if contains_extension v then - Buffer.add_string buf - "\nMatching over values of extensible variant types \ - (the *extension* above)\n\ - must include a wild card pattern in order to be exhaustive." - ; - Buffer.contents buf - with _ -> - "" - in - Location.prerr_warning loc (Warnings.Partial_match errmsg) - end; - Partial - end - | _ -> - fatal_error "Parmatch.check_partial" - end +let make_pat desc ty tenv = + {pat_desc = desc; pat_loc = Location.none; pat_extra = []; + pat_type = ty ; pat_env = tenv; + pat_attributes = []; + } -(* -let do_check_partial_normal loc casel pss = - do_check_partial exhaust loc casel pss - *) +let omega = make_pat Tpat_any Ctype.none Env.empty -let do_check_partial_gadt pred loc casel pss = - do_check_partial ~pred exhaust_gadt loc casel pss +let extra_pat = + make_pat + (Tpat_var (Ident.create "+", mknoloc "+")) + Ctype.none Env.empty +let rec omegas i = + if i <= 0 then [] else omega :: omegas (i-1) +let omega_list l = List.map (fun _ -> omega) l -(*****************) -(* Fragile check *) -(*****************) +let zero = make_pat (Tpat_constant (Const_int 0)) Ctype.none Env.empty -(* Collect all data types in a pattern *) +(*******************) +(* Coherence check *) +(*******************) -let rec add_path path = function - | [] -> [path] - | x::rem as paths -> - if Path.same path x then paths - else x::add_path path rem +(* For some of the operations we do in this module, we would like (because it + simplifies matters) to assume that patterns appearing on a given column in a + pattern matrix are /coherent/ (think "of the same type"). + Unfortunately that is not always true. -let extendable_path path = - not - (Path.same path Predef.path_bool || - Path.same path Predef.path_list || - Path.same path Predef.path_unit || - Path.same path Predef.path_option) + Consider the following (well-typed) example: + {[ + type _ t = S : string t | U : unit t -let rec collect_paths_from_pat r p = match p.pat_desc with -| Tpat_construct(_, {cstr_tag=(Cstr_constant _|Cstr_block _|Cstr_unboxed)},ps) - -> - let path = get_type_path p.pat_type p.pat_env in - List.fold_left - collect_paths_from_pat - (if extendable_path path then add_path path r else r) - ps -| Tpat_any|Tpat_var _|Tpat_constant _| Tpat_variant (_,None,_) -> r -| Tpat_tuple ps | Tpat_array ps -| Tpat_construct (_, {cstr_tag=Cstr_extension _}, ps)-> - List.fold_left collect_paths_from_pat r ps -| Tpat_record (lps,_) -> - List.fold_left - (fun r (_, _, p) -> collect_paths_from_pat r p) - r lps -| Tpat_variant (_, Some p, _) | Tpat_alias (p,_,_) -> collect_paths_from_pat r p -| Tpat_or (p1,p2,_) -> - collect_paths_from_pat (collect_paths_from_pat r p1) p2 -| Tpat_lazy p - -> - collect_paths_from_pat r p + let f (type a) (t1 : a t) (t2 : a t) (a : a) = + match t1, t2, a with + | U, _, () -> () + | _, S, "" -> () + ]} + Clearly the 3rd column contains incoherent patterns. -(* - Actual fragile check - 1. Collect data types in the patterns of the match. - 2. One exhaustivity check per datatype, considering that - the type is extended. -*) + On the example above, most of the algorithms will explore the pattern matrix + as illustrated by the following tree: -let do_check_fragile_param exhaust loc casel pss = - let exts = - List.fold_left - (fun r c -> collect_paths_from_pat r c.c_lhs) - [] casel in - match exts with - | [] -> () - | _ -> match pss with - | [] -> () - | ps::_ -> - List.iter - (fun ext -> - match exhaust (Some ext) pss (List.length ps) with - | Rnone -> - Location.prerr_warning - loc - (Warnings.Fragile_match (Path.name ext)) - | Rsome _ -> ()) - exts + {v + S + -------> | "" | + U | S, "" | __/ | () | + --------> | _, () | \ ¬ S + | U, _, () | __/ -------> | () | + | _, S, "" | \ + ---------> | S, "" | ----------> | "" | + ¬ U S + v} -(*let do_check_fragile_normal = do_check_fragile_param exhaust*) -let do_check_fragile_gadt = do_check_fragile_param exhaust_gadt + where following an edge labelled by a pattern P means "assuming the value I + am matching on is filtered by [P] on the column I am currently looking at, + then the following submatrix is still reachable". -(********************************) -(* Exported unused clause check *) -(********************************) + Notice that at any point of that tree, if the first column of a matrix is + incoherent, then the branch leading to it can only be taken if the scrutinee + is ill-typed. + In the example above the only case where we have a matrix with an incoherent + first column is when we consider [t1, t2, a] to be [U, S, ...]. However such + a value would be ill-typed, so we can never actually get there. -let check_unused pred casel = - if Warnings.is_active Warnings.Unused_match - || List.exists (fun c -> c.c_rhs.exp_desc = Texp_unreachable) casel then - let rec do_rec pref = function - | [] -> () - | {c_lhs=q; c_guard; c_rhs} :: rem -> - let qs = [q] in - begin try - let pss = - get_mins le_pats (List.filter (compats qs) pref) in - (* First look for redundant or partially redundant patterns *) - let r = every_satisfiables (make_rows pss) (make_row qs) in - let refute = (c_rhs.exp_desc = Texp_unreachable) in - (* Do not warn for unused [pat -> .] *) - if r = Unused && refute then () else - let r = - (* Do not refine if there are no other lines *) - let skip = - r = Unused || (not refute && pref = []) || - not(refute || Warnings.is_active Warnings.Unreachable_case) in - if skip then r else - (* Then look for empty patterns *) - let sfs = satisfiables pss qs in - if sfs = [] then Unused else - let sfs = - List.map (function [u] -> u | _ -> assert false) sfs in - let u = orify_many sfs in - (*Format.eprintf "%a@." pretty_val u;*) - let (pattern,constrs,labels) = Conv.conv u in - let pattern = {pattern with Parsetree.ppat_loc = q.pat_loc} in - match pred refute constrs labels pattern with - None when not refute -> - Location.prerr_warning q.pat_loc Warnings.Unreachable_case; - Used - | _ -> r - in - match r with - | Unused -> - Location.prerr_warning - q.pat_loc Warnings.Unused_match - | Upartial ps -> - List.iter - (fun p -> - Location.prerr_warning - p.pat_loc Warnings.Unused_pat) - ps - | Used -> () - with Empty | Not_found | NoGuard -> assert false - end ; + Checking the first column at each step of the recursion and making the + concious decision of "aborting" the algorithm whenever the first column + becomes incoherent, allows us to retain the initial assumption in later + stages of the algorithms. - if c_guard <> None then - do_rec pref rem - else - do_rec ([q]::pref) rem in + --- - do_rec [] casel + N.B. two patterns can be considered coherent even though they might not be of + the same type. -(*********************************) -(* Exported irrefutability tests *) -(*********************************) + That's in part because we only care about the "head" of patterns and leave + checking coherence of subpatterns for the next steps of the algorithm: + ('a', 'b') and (1, ()) will be deemed coherent because they are both a tuples + of arity 2 (we'll notice at a later stage the incoherence of 'a' and 1). -let irrefutable pat = le_pat pat omega + But also because it can be hard/costly to determine exactly whether two + patterns are of the same type or not (eg. in the example above with _ and S, + but see also the module [Coherence_illustration] in + testsuite/tests/basic-more/robustmatch.ml). -let inactive ~partial pat = - match partial with - | Partial -> false - | Total -> begin - let rec loop pat = - match pat.pat_desc with - | Tpat_lazy _ | Tpat_array _ -> - false - | Tpat_any | Tpat_var _ | Tpat_variant (_, None, _) -> - true - | Tpat_constant c -> begin - match c with - | Const_string _ -> Config.safe_string - | Const_int _ | Const_char _ | Const_float _ - | Const_int32 _ | Const_int64 _ | Const_nativeint _ -> true - end - | Tpat_tuple ps | Tpat_construct (_, _, ps) -> - List.for_all (fun p -> loop p) ps - | Tpat_alias (p,_,_) | Tpat_variant (_, Some p, _) -> - loop p - | Tpat_record (ldps,_) -> - List.for_all - (fun (_, lbl, p) -> lbl.lbl_mut = Immutable && loop p) - ldps - | Tpat_or (p,q,_) -> - loop p && loop q - in - loop pat - end + For the moment our weak, loosely-syntactic, coherence check seems to be + enough and we leave it to each user to consider (and document!) what happens + when an "incoherence" is not detected by this check. +*) +let simplify_head_pat p k = + let rec simplify_head_pat p k = + match p.pat_desc with + | Tpat_alias (p,_,_) -> simplify_head_pat p k + | Tpat_var (_,_) -> omega :: k + | Tpat_or (p1,p2,_) -> simplify_head_pat p1 (simplify_head_pat p2 k) + | _ -> p :: k + in simplify_head_pat p k + +let rec simplified_first_col = function + | [] -> [] + | [] :: _ -> assert false (* the rows are non-empty! *) + | (p::_) :: rows -> + simplify_head_pat p (simplified_first_col rows) +(* Given the simplified first column of a matrix, this function first looks for + a "discriminating" pattern on that column (i.e. a non-omega one) and then + check that every other head pattern in the column is coherent with that one. +*) +let all_coherent column = + let coherent_heads hp1 hp2 = + match hp1.pat_desc, hp2.pat_desc with + | (Tpat_var _ | Tpat_alias _ | Tpat_or _), _ + | _, (Tpat_var _ | Tpat_alias _ | Tpat_or _) -> + assert false + | Tpat_construct (_, c, _), Tpat_construct (_, c', _) -> + c.cstr_consts = c'.cstr_consts + && c.cstr_nonconsts = c'.cstr_nonconsts + | Tpat_constant c1, Tpat_constant c2 -> begin + match c1, c2 with + | Const_char _, Const_char _ + | Const_int _, Const_int _ + | Const_int32 _, Const_int32 _ + | Const_int64 _, Const_int64 _ + | Const_nativeint _, Const_nativeint _ + | Const_float _, Const_float _ + | Const_string _, Const_string _ -> true + | ( Const_char _ + | Const_int _ + | Const_int32 _ + | Const_int64 _ + | Const_nativeint _ + | Const_float _ + | Const_string _), _ -> false + end + | Tpat_tuple l1, Tpat_tuple l2 -> List.length l1 = List.length l2 + | Tpat_record ((_, lbl1, _) :: _, _), Tpat_record ((_, lbl2, _) :: _, _) -> + Array.length lbl1.lbl_all = Array.length lbl2.lbl_all + | Tpat_any, _ + | _, Tpat_any + | Tpat_record ([], _), Tpat_record (_, _) + | Tpat_record (_, _), Tpat_record ([], _) + | Tpat_variant _, Tpat_variant _ + | Tpat_array _, Tpat_array _ + | Tpat_lazy _, Tpat_lazy _ -> true + | _, _ -> false + in + match + List.find (fun head_pat -> + match head_pat.pat_desc with + | Tpat_var _ | Tpat_alias _ | Tpat_or _ -> assert false + | Tpat_any -> false + | _ -> true + ) column + with + | exception Not_found -> + (* only omegas on the column: the column is coherent. *) + true + | discr_pat -> + List.for_all (coherent_heads discr_pat) column +let first_column simplified_matrix = + List.map fst simplified_matrix +(***********************) +(* Compatibility check *) +(***********************) +(* Patterns p and q compatible means: + there exists value V that matches both, However.... -(*********************************) -(* Exported exhaustiveness check *) -(*********************************) + The case of extension types is dubious, as constructor rebind permits + that different constructors are the same (and are thus compatible). -(* - Fragile check is performed when required and - on exhaustive matches only. -*) + Compilation must take this into account, consider: -let check_partial_param do_check_partial do_check_fragile loc casel = - let pss = initial_matrix casel in - let pss = get_mins le_pats pss in - let total = do_check_partial loc casel pss in - if - total = Total && Warnings.is_active (Warnings.Fragile_match "") - then begin - do_check_fragile loc casel pss - end ; - total + type t = .. + type t += A|B + type t += C=A -(*let check_partial = - check_partial_param - do_check_partial_normal - do_check_fragile_normal*) + let f x y = match x,y with + | true,A -> '1' + | _,C -> '2' + | false,A -> '3' + | _,_ -> '_' -let check_partial_gadt pred loc casel = - check_partial_param (do_check_partial_gadt pred) - do_check_fragile_gadt loc casel + As C is bound to A the value of f false A is '2' (and not '3' as it would + be in the absence of rebinding). + Not considering rebinding, patterns "false,A" and "_,C" are incompatible + and the compiler can swap the second and third clause, resulting in the + (more efficiently compiled) matching -(*************************************) -(* Ambiguous variable in or-patterns *) -(*************************************) + match x,y with + | true,A -> '1' + | false,A -> '3' + | _,C -> '2' + | _,_ -> '_' -(* Specification: ambiguous variables in or-patterns. + This is not correct: when C is bound to A, "f false A" returns '2' (not '3') - The semantics of or-patterns in OCaml is specified with - a left-to-right bias: a value [v] matches the pattern [p | q] if it - matches [p] or [q], but if it matches both, the environment - captured by the match is the environment captured by [p], never the - one captured by [q]. - While this property is generally well-understood, one specific case - where users expect a different semantics is when a pattern is - followed by a when-guard: [| p when g -> e]. Consider for example: + However, diagnostics do not take constructor rebinding into account. + Notice, that due to module abstraction constructor rebinding is hidden. - | ((Const x, _) | (_, Const x)) when is_neutral x -> branch + module X : sig type t = .. type t += A|B end = struct + type t = .. + type t += A + type t += B=A + end - The semantics is clear: match the scrutinee against the pattern, if - it matches, test the guard, and if the guard passes, take the - branch. + open X - However, consider the input [(Const a, Const b)], where [a] fails - the test [is_neutral f], while [b] passes the test [is_neutral - b]. With the left-to-right semantics, the clause above is *not* - taken by its input: matching [(Const a, Const b)] against the - or-pattern succeeds in the left branch, it returns the environment - [x -> a], and then the guard [is_neutral a] is tested and fails, - the branch is not taken. Most users, however, intuitively expect - that any pair that has one side passing the test will take the - branch. They assume it is equivalent to the following: + let f x = match x with + | A -> '1' + | B -> '2' + | _ -> '_' - | (Const x, _) when is_neutral x -> branch - | (_, Const x) when is_neutral x -> branch + The second clause above will NOT (and cannot) be flagged as useless. - while it is not. + Finally, there are two compatibility fonction + compat p q ---> 'syntactic compatibility, used for diagnostics. + may_compat p q ---> a safe approximation of possible compat, + for compilation - The code below is dedicated to finding these confusing cases: the - cases where a guard uses "ambiguous" variables, that are bound to - different parts of the scrutinees by different sides of - a or-pattern. In other words, it finds the cases where the - specified left-to-right semantics is not equivalent to - a non-deterministic semantics (any branch can be taken) relatively - to a specific guard. *) -module IdSet = Set.Make(Ident) -let pattern_vars p = IdSet.of_list (Typedtree.pat_bound_idents p) +let is_absent tag row = Btype.row_field tag !row = Rabsent -(* Row for ambiguous variable search, - unseen is the traditional pattern row, - seen is a list of position bindings *) +let is_absent_pat p = match p.pat_desc with +| Tpat_variant (tag, _, row) -> is_absent tag row +| _ -> false -type amb_row = { unseen : pattern list ; seen : IdSet.t list; } +let const_compare x y = + match x,y with + | Const_float f1, Const_float f2 -> + Pervasives.compare (float_of_string f1) (float_of_string f2) + | Const_string (s1, _), Const_string (s2, _) -> + String.compare s1 s2 + | _, _ -> Pervasives.compare x y +let records_args l1 l2 = + (* Invariant: fields are already sorted by Typecore.type_label_a_list *) + let rec combine r1 r2 l1 l2 = match l1,l2 with + | [],[] -> List.rev r1, List.rev r2 + | [],(_,_,p2)::rem2 -> combine (omega::r1) (p2::r2) [] rem2 + | (_,_,p1)::rem1,[] -> combine (p1::r1) (omega::r2) rem1 [] + | (_,lbl1,p1)::rem1, ( _,lbl2,p2)::rem2 -> + if lbl1.lbl_pos < lbl2.lbl_pos then + combine (p1::r1) (omega::r2) rem1 l2 + else if lbl1.lbl_pos > lbl2.lbl_pos then + combine (omega::r1) (p2::r2) l1 rem2 + else (* same label on both sides *) + combine (p1::r1) (p2::r2) rem1 rem2 in + combine [] [] l1 l2 -(* Push binding variables now *) -let rec do_push r p ps seen k = match p.pat_desc with -| Tpat_alias (p,x,_) -> do_push (IdSet.add x r) p ps seen k -| Tpat_var (x,_) -> - (omega,{ unseen = ps; seen=IdSet.add x r::seen; })::k -| Tpat_or (p1,p2,_) -> - do_push r p1 ps seen (do_push r p2 ps seen k) -| _ -> - (p,{ unseen = ps; seen = r::seen; })::k -let rec push_vars = function - | [] -> [] - | { unseen = [] }::_ -> assert false - | { unseen = p::ps; seen; }::rem -> - do_push IdSet.empty p ps seen (push_vars rem) +module Compat + (Constr:sig + val equal : + Types.constructor_description -> + Types.constructor_description -> + bool + end) = struct -let collect_stable = function - | [] -> assert false - | { seen=xss; _}::rem -> - let rec c_rec xss = function - | [] -> xss - | {seen=yss; _}::rem -> - let xss = List.map2 IdSet.inter xss yss in - c_rec xss rem in - let inters = c_rec xss rem in - List.fold_left IdSet.union IdSet.empty inters + let rec compat p q = match p.pat_desc,q.pat_desc with +(* Variables match any value *) + | ((Tpat_any|Tpat_var _),_) + | (_,(Tpat_any|Tpat_var _)) -> true +(* Structural induction *) + | Tpat_alias (p,_,_),_ -> compat p q + | _,Tpat_alias (q,_,_) -> compat p q + | Tpat_or (p1,p2,_),_ -> + (compat p1 q || compat p2 q) + | _,Tpat_or (q1,q2,_) -> + (compat p q1 || compat p q2) +(* Constructors, with special case for extension *) + | Tpat_construct (_, c1,ps1), Tpat_construct (_, c2,ps2) -> + Constr.equal c1 c2 && compats ps1 ps2 +(* More standard stuff *) + | Tpat_variant(l1,op1, _), Tpat_variant(l2,op2,_) -> + l1=l2 && ocompat op1 op2 + | Tpat_constant c1, Tpat_constant c2 -> + const_compare c1 c2 = 0 + | Tpat_tuple ps, Tpat_tuple qs -> compats ps qs + | Tpat_lazy p, Tpat_lazy q -> compat p q + | Tpat_record (l1,_),Tpat_record (l2,_) -> + let ps,qs = records_args l1 l2 in + compats ps qs + | Tpat_array ps, Tpat_array qs -> + List.length ps = List.length qs && + compats ps qs + | _,_ -> false + and ocompat op oq = match op,oq with + | None,None -> true + | Some p,Some q -> compat p q + | (None,Some _)|(Some _,None) -> false -(*********************************************) -(* Filtering utilities for our specific rows *) -(*********************************************) + and compats ps qs = match ps,qs with + | [], [] -> true + | p::ps, q::qs -> compat p q && compats ps qs + | _,_ -> false -(* Take a pattern matrix as a list (rows) of lists (columns) of patterns - | p1, p2, .., pn - | q1, q2, .., qn - | r1, r2, .., rn - | ... +end - We split this matrix into a list of sub-matrices, one for each head - constructor appearing in the leftmost column. For each row whose - left column starts with a head constructor, remove this head - column, prepend one column for each argument of the constructor, - and add the resulting row in the sub-matrix corresponding to this - head constructor. +module SyntacticCompat = + Compat + (struct + let equal c1 c2 = Types.equal_tag c1.cstr_tag c2.cstr_tag + end) - Rows whose left column is omega (the Any pattern _) may match any - head constructor, so they are added to all groups. +let compat = SyntacticCompat.compat +and compats = SyntacticCompat.compats - The list of sub-matrices is represented as a list of pair - (head constructor, submatrix) -*) +(* Due to (potential) rebinding, two extension constructors + of the same arity type may equal *) -let filter_all = - (* the head constructor (as a pattern with omega arguments) of - a pattern *) - let discr_head pat = - match pat.pat_desc with - | Tpat_record (lbls, closed) -> - (* a partial record pattern { f1 = p1; f2 = p2; _ } - needs to be expanded, otherwise matching against this head - would drop the pattern arguments for non-mentioned fields *) - let lbls = all_record_args lbls in - normalize_pat { pat with pat_desc = Tpat_record (lbls, closed) } - | _ -> normalize_pat pat - in +exception Empty (* Empty pattern *) + +(****************************************) +(* Utilities for retrieving type paths *) +(****************************************) - (* insert a row of head [p] and rest [r] into the right group *) - let rec insert p r env = match env with - | [] -> - (* if no group matched this row, it has a head constructor that - was never seen before; add a new sub-matrix for this head *) - let p0 = discr_head p in - [p0,[{ r with unseen = simple_match_args p0 p @ r.unseen }]] - | (q0,rs) as bd::env -> - if simple_match q0 p then begin - let r = { r with unseen = simple_match_args q0 p@r.unseen; } in - (q0,r::rs)::env - end - else bd::insert p r env in +(* May need a clean copy, cf. PR#4745 *) +let clean_copy ty = + if ty.level = Btype.generic_level then ty + else Subst.type_expr Subst.identity ty - (* insert a row of head omega into all groups *) - let insert_omega r env = - List.map - (fun (q0,rs) -> - let r = - { r with unseen = simple_match_args q0 omega @ r.unseen; } in - (q0,r::rs)) - env - in +let get_type_path ty tenv = + let ty = Ctype.repr (Ctype.expand_head tenv (clean_copy ty)) in + match ty.desc with + | Tconstr (path,_,_) -> path + | _ -> fatal_error "Parmatch.get_type_path" - let rec filter_rec env = function - | [] -> env - | ({pat_desc=(Tpat_var _|Tpat_alias _|Tpat_or _)},_)::_ -> assert false - | ({pat_desc=Tpat_any}, _)::rs -> filter_rec env rs - | (p,r)::rs -> filter_rec (insert p r env) rs in +(*************************************) +(* Values as patterns pretty printer *) +(*************************************) - let rec filter_omega env = function - | [] -> env - | ({pat_desc=(Tpat_var _|Tpat_alias _|Tpat_or _)},_)::_ -> assert false - | ({pat_desc=Tpat_any},r)::rs -> filter_omega (insert_omega r env) rs - | _::rs -> filter_omega env rs in +open Format +;; - fun rs -> - (* first insert the rows with head constructors, - to get the definitive list of groups *) - let env = filter_rec [] rs in - (* then add the omega rows to all groups *) - filter_omega env rs +let is_cons = function +| {cstr_name = "::"} -> true +| _ -> false -(* Compute stable bindings *) +let pretty_const c = match c with +| Const_int i -> Printf.sprintf "%d" i +| Const_char c -> Printf.sprintf "%C" c +| Const_string (s, _) -> Printf.sprintf "%S" s +| Const_float f -> Printf.sprintf "%s" f +| Const_int32 i -> Printf.sprintf "%ldl" i +| Const_int64 i -> Printf.sprintf "%LdL" i +| Const_nativeint i -> Printf.sprintf "%ndn" i -let rec do_stable rs = match rs with -| [] -> assert false (* No empty matrix *) -| { unseen=[]; _ }::_ -> - collect_stable rs -| _ -> - let rs = push_vars rs in - if not (all_coherent (first_column rs)) then begin - (* If the first column is incoherent, then all the variables of this - matrix are stable. *) - List.fold_left (fun acc (_, { seen; _ }) -> - List.fold_left IdSet.union acc seen - ) IdSet.empty rs - end else begin - (* If the column is ill-typed but deemed coherent, we might spuriously - warn about some variables being unstable. - As sad as that might be, the warning can be silenced by splitting the - or-pattern... *) - match filter_all rs with - | [] -> - do_stable (List.map snd rs) - | (_,rs)::env -> - List.fold_left - (fun xs (_,rs) -> IdSet.inter xs (do_stable rs)) - (do_stable rs) env - end +let rec pretty_val ppf v = + match v.pat_extra with + (cstr, _loc, _attrs) :: rem -> + begin match cstr with + | Tpat_unpack -> + fprintf ppf "@[(module %a)@]" pretty_val { v with pat_extra = rem } + | Tpat_constraint _ -> + fprintf ppf "@[(%a : _)@]" pretty_val { v with pat_extra = rem } + | Tpat_type _ -> + fprintf ppf "@[(# %a)@]" pretty_val { v with pat_extra = rem } + | Tpat_open _ -> + fprintf ppf "@[(# %a)@]" pretty_val { v with pat_extra = rem } + end + | [] -> + match v.pat_desc with + | Tpat_any -> fprintf ppf "_" + | Tpat_var (x,_) -> fprintf ppf "%s" (Ident.name x) + | Tpat_constant c -> fprintf ppf "%s" (pretty_const c) + | Tpat_tuple vs -> + fprintf ppf "@[(%a)@]" (pretty_vals ",") vs + | Tpat_construct (_, cstr, []) -> + fprintf ppf "%s" cstr.cstr_name + | Tpat_construct (_, cstr, [w]) -> + fprintf ppf "@[<2>%s@ %a@]" cstr.cstr_name pretty_arg w + | Tpat_construct (_, cstr, vs) -> + let name = cstr.cstr_name in + begin match (name, vs) with + ("::", [v1;v2]) -> + fprintf ppf "@[%a::@,%a@]" pretty_car v1 pretty_cdr v2 + | _ -> + fprintf ppf "@[<2>%s@ @[(%a)@]@]" name (pretty_vals ",") vs + end + | Tpat_variant (l, None, _) -> + fprintf ppf "`%s" l + | Tpat_variant (l, Some w, _) -> + fprintf ppf "@[<2>`%s@ %a@]" l pretty_arg w + | Tpat_record (lvs,_) -> + let filtered_lvs = List.filter + (function + | (_,_,{pat_desc=Tpat_any}) -> false (* do not show lbl=_ *) + | _ -> true) lvs in + begin match filtered_lvs with + | [] -> fprintf ppf "_" + | (_, lbl, _) :: q -> + let elision_mark ppf = + (* we assume that there is no label repetitions here *) + if Array.length lbl.lbl_all > 1 + List.length q then + fprintf ppf ";@ _@ " + else () in + fprintf ppf "@[{%a%t}@]" + pretty_lvals filtered_lvs elision_mark + end + | Tpat_array vs -> + fprintf ppf "@[[| %a |]@]" (pretty_vals " ;") vs + | Tpat_lazy v -> + fprintf ppf "@[<2>lazy@ %a@]" pretty_arg v + | Tpat_alias (v, x,_) -> + fprintf ppf "@[(%a@ as %a)@]" pretty_val v Ident.print x + | Tpat_or (v,w,_) -> + fprintf ppf "@[(%a|@,%a)@]" pretty_or v pretty_or w -let stable p = do_stable [{unseen=[p]; seen=[];}] +and pretty_car ppf v = match v.pat_desc with +| Tpat_construct (_,cstr, [_ ; _]) + when is_cons cstr -> + fprintf ppf "(%a)" pretty_val v +| _ -> pretty_val ppf v +and pretty_cdr ppf v = match v.pat_desc with +| Tpat_construct (_,cstr, [v1 ; v2]) + when is_cons cstr -> + fprintf ppf "%a::@,%a" pretty_car v1 pretty_cdr v2 +| _ -> pretty_val ppf v -(* All identifier paths that appear in an expression that occurs - as a clause right hand side or guard. +and pretty_arg ppf v = match v.pat_desc with +| Tpat_construct (_,_,_::_) +| Tpat_variant (_, Some _, _) -> fprintf ppf "(%a)" pretty_val v +| _ -> pretty_val ppf v - The function is rather complex due to the compilation of - unpack patterns by introducing code in rhs expressions - and **guards**. +and pretty_or ppf v = match v.pat_desc with +| Tpat_or (v,w,_) -> + fprintf ppf "%a|@,%a" pretty_or v pretty_or w +| _ -> pretty_val ppf v - For pattern (module M:S) -> e the code is - let module M_mod = unpack M .. in e +and pretty_vals sep ppf = function + | [] -> () + | [v] -> pretty_val ppf v + | v::vs -> + fprintf ppf "%a%s@ %a" pretty_val v sep (pretty_vals sep) vs - Hence M is "free" in e iff M_mod is free in e. +and pretty_lvals ppf = function + | [] -> () + | [_,lbl,v] -> + fprintf ppf "%s=%a" lbl.lbl_name pretty_val v + | (_, lbl,v)::rest -> + fprintf ppf "%s=%a;@ %a" + lbl.lbl_name pretty_val v pretty_lvals rest - Not doing so will yield excessive warning in - (module (M:S) } ...) when true -> .... - as M is always present in - let module M_mod = unpack M .. in true -*) +let top_pretty ppf v = + fprintf ppf "@[%a@]@?" pretty_val v -let all_rhs_idents exp = - let ids = ref IdSet.empty in - let module Iterator = TypedtreeIter.MakeIterator(struct - include TypedtreeIter.DefaultIteratorArgument - let enter_expression exp = match exp.exp_desc with - | Texp_ident (path, _lid, _descr) -> - List.iter - (fun id -> ids := IdSet.add id !ids) - (Path.heads path) - | _ -> () -(* Very hackish, detect unpack pattern compilation - and perform "indirect check for them" *) - let is_unpack exp = - List.exists - (fun (attr, _) -> attr.txt = "#modulepat") exp.exp_attributes +let pretty_pat p = + top_pretty Format.str_formatter p ; + prerr_string (Format.flush_str_formatter ()) - let leave_expression exp = - if is_unpack exp then begin match exp.exp_desc with - | Texp_letmodule - (id_mod,_, - {mod_desc= - Tmod_unpack ({exp_desc=Texp_ident (Path.Pident id_exp,_,_)},_)}, - _) -> - assert (IdSet.mem id_exp !ids) ; - if not (IdSet.mem id_mod !ids) then begin - ids := IdSet.remove id_exp !ids - end - | _ -> assert false - end - end) in - Iterator.iter_expression exp; - !ids +type matrix = pattern list list -let check_ambiguous_bindings = - let open Warnings in - let warn0 = Ambiguous_pattern [] in - fun cases -> - if is_active warn0 then - List.iter - (fun case -> match case with - | { c_guard=None ; _} -> () - | { c_lhs=p; c_guard=Some g; _} -> - let all = - IdSet.inter (pattern_vars p) (all_rhs_idents g) in - if not (IdSet.is_empty all) then begin - let st = stable p in - let ambiguous = IdSet.diff all st in - if not (IdSet.is_empty ambiguous) then begin - let pps = IdSet.elements ambiguous |> List.map Ident.name in - let warn = Ambiguous_pattern pps in - Location.prerr_warning p.pat_loc warn - end - end) - cases +let pretty_line ps = + List.iter + (fun p -> + top_pretty Format.str_formatter p ; + prerr_string " <" ; + prerr_string (Format.flush_str_formatter ()) ; + prerr_string ">") + ps -end -module Typetexp : sig -#1 "typetexp.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let pretty_matrix (pss : matrix) = + prerr_endline "begin matrix" ; + List.iter + (fun ps -> + pretty_line ps ; + prerr_endline "") + pss ; + prerr_endline "end matrix" -(* Typechecking of type expressions for the core language *) -open Types +(****************************) +(* Utilities for matching *) +(****************************) -val transl_simple_type: - Env.t -> bool -> Parsetree.core_type -> Typedtree.core_type -val transl_simple_type_univars: - Env.t -> Parsetree.core_type -> Typedtree.core_type -val transl_simple_type_delayed: - Env.t -> Parsetree.core_type -> Typedtree.core_type * (unit -> unit) - (* Translate a type, but leave type variables unbound. Returns - the type and a function that binds the type variable. *) -val transl_type_scheme: - Env.t -> Parsetree.core_type -> Typedtree.core_type -val reset_type_variables: unit -> unit -val type_variable: Location.t -> string -> type_expr -val transl_type_param: - Env.t -> Parsetree.core_type -> Typedtree.core_type +(* Check top matching *) +let simple_match p1 p2 = + match p1.pat_desc, p2.pat_desc with + | Tpat_construct(_, c1, _), Tpat_construct(_, c2, _) -> + Types.equal_tag c1.cstr_tag c2.cstr_tag + | Tpat_variant(l1, _, _), Tpat_variant(l2, _, _) -> + l1 = l2 + | Tpat_constant(c1), Tpat_constant(c2) -> const_compare c1 c2 = 0 + | Tpat_lazy _, Tpat_lazy _ -> true + | Tpat_record _ , Tpat_record _ -> true + | Tpat_tuple p1s, Tpat_tuple p2s + | Tpat_array p1s, Tpat_array p2s -> List.length p1s = List.length p2s + | _, (Tpat_any | Tpat_var(_)) -> true + | _, _ -> false -type variable_context -val narrow: unit -> variable_context -val widen: variable_context -> unit -exception Already_bound -type error = - Unbound_type_variable of string - | Unbound_type_constructor of Longident.t - | Unbound_type_constructor_2 of Path.t - | Type_arity_mismatch of Longident.t * int * int - | Bound_type_variable of string - | Recursive_type - | Unbound_row_variable of Longident.t - | Type_mismatch of (type_expr * type_expr) list - | Alias_type_mismatch of (type_expr * type_expr) list - | Present_has_conjunction of string - | Present_has_no_type of string - | Constructor_mismatch of type_expr * type_expr - | Not_a_variant of type_expr - | Variant_tags of string * string - | Invalid_variable_name of string - | Cannot_quantify of string * type_expr - | Multiple_constraints_on_type of Longident.t - | Method_mismatch of string * type_expr * type_expr - | Unbound_value of Longident.t - | Unbound_constructor of Longident.t - | Unbound_label of Longident.t - | Unbound_module of Longident.t - | Unbound_class of Longident.t - | Unbound_modtype of Longident.t - | Unbound_cltype of Longident.t - | Ill_typed_functor_application of Longident.t - | Illegal_reference_to_recursive_module - | Access_functor_as_structure of Longident.t - | Apply_structure_as_functor of Longident.t - | Cannot_scrape_alias of Longident.t * Path.t - | Opened_object of Path.t option - | Not_an_object of type_expr -exception Error of Location.t * Env.t * error +(* extract record fields as a whole *) +let record_arg p = match p.pat_desc with +| Tpat_any -> [] +| Tpat_record (args,_) -> args +| _ -> fatal_error "Parmatch.as_record" -val report_error: Env.t -> Format.formatter -> error -> unit -(* Support for first-class modules. *) -val transl_modtype_longident: (* from Typemod *) - (Location.t -> Env.t -> Longident.t -> Path.t) ref -val transl_modtype: (* from Typemod *) - (Env.t -> Parsetree.module_type -> Typedtree.module_type) ref -val create_package_mty: - Location.t -> Env.t -> Parsetree.package_type -> - (Longident.t Asttypes.loc * Parsetree.core_type) list * - Parsetree.module_type +(* Raise Not_found when pos is not present in arg *) +let get_field pos arg = + let _,_, p = List.find (fun (_,lbl,_) -> pos = lbl.lbl_pos) arg in + p -val find_type: - Env.t -> Location.t -> Longident.t -> Path.t * type_declaration -val find_constructor: - Env.t -> Location.t -> Longident.t -> constructor_description -val find_all_constructors: - Env.t -> Location.t -> Longident.t -> - (constructor_description * (unit -> unit)) list -val find_label: - Env.t -> Location.t -> Longident.t -> label_description -val find_all_labels: - Env.t -> Location.t -> Longident.t -> - (label_description * (unit -> unit)) list -val find_value: - Env.t -> Location.t -> Longident.t -> Path.t * value_description -val find_class: - Env.t -> Location.t -> Longident.t -> Path.t * class_declaration -val find_module: - Env.t -> Location.t -> Longident.t -> Path.t * module_declaration -val lookup_module: - ?load:bool -> Env.t -> Location.t -> Longident.t -> Path.t -val find_modtype: - Env.t -> Location.t -> Longident.t -> Path.t * modtype_declaration -val find_class_type: - Env.t -> Location.t -> Longident.t -> Path.t * class_type_declaration +let extract_fields omegas arg = + List.map + (fun (_,lbl,_) -> + try + get_field lbl.lbl_pos arg + with Not_found -> omega) + omegas -val unbound_constructor_error: Env.t -> Longident.t Location.loc -> 'a -val unbound_label_error: Env.t -> Longident.t Location.loc -> 'a +let all_record_args lbls = match lbls with +| (_,{lbl_all=lbl_all},_)::_ -> + let t = + Array.map + (fun lbl -> mknoloc (Longident.Lident "?temp?"), lbl,omega) + lbl_all in + List.iter + (fun ((_, lbl,_) as x) -> t.(lbl.lbl_pos) <- x) + lbls ; + Array.to_list t +| _ -> fatal_error "Parmatch.all_record_args" -val spellcheck: - Format.formatter -> - (('a -> 'a list -> 'a list) -> - Longident.t option -> 'b -> 'c list -> string list) -> - 'b -> Longident.t -> unit +(* Build argument list when p2 >= p1, where p1 is a simple pattern *) +let rec simple_match_args p1 p2 = match p2.pat_desc with +| Tpat_alias (p2,_,_) -> simple_match_args p1 p2 +| Tpat_construct(_, _, args) -> args +| Tpat_variant(_, Some arg, _) -> [arg] +| Tpat_tuple(args) -> args +| Tpat_record(args,_) -> extract_fields (record_arg p1) args +| Tpat_array(args) -> args +| Tpat_lazy arg -> [arg] +| (Tpat_any | Tpat_var(_)) -> + begin match p1.pat_desc with + Tpat_construct(_, _,args) -> omega_list args + | Tpat_variant(_, Some _, _) -> [omega] + | Tpat_tuple(args) -> omega_list args + | Tpat_record(args,_) -> omega_list args + | Tpat_array(args) -> omega_list args + | Tpat_lazy _ -> [omega] + | _ -> [] + end +| _ -> [] -end = struct -#1 "typetexp.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +(* + Normalize a pattern -> + all arguments are omega (simple pattern) and no more variables +*) -(* typetexp.ml,v 1.34.4.9 2002/01/07 08:39:16 garrigue Exp *) +let rec normalize_pat q = match q.pat_desc with + | Tpat_any | Tpat_constant _ -> q + | Tpat_var _ -> make_pat Tpat_any q.pat_type q.pat_env + | Tpat_alias (p,_,_) -> normalize_pat p + | Tpat_tuple (args) -> + make_pat (Tpat_tuple (omega_list args)) q.pat_type q.pat_env + | Tpat_construct (lid, c,args) -> + make_pat + (Tpat_construct (lid, c,omega_list args)) + q.pat_type q.pat_env + | Tpat_variant (l, arg, row) -> + make_pat (Tpat_variant (l, may_map (fun _ -> omega) arg, row)) + q.pat_type q.pat_env + | Tpat_array (args) -> + make_pat (Tpat_array (omega_list args)) q.pat_type q.pat_env + | Tpat_record (largs, closed) -> + make_pat + (Tpat_record (List.map (fun (lid,lbl,_) -> + lid, lbl,omega) largs, closed)) + q.pat_type q.pat_env + | Tpat_lazy _ -> + make_pat (Tpat_lazy omega) q.pat_type q.pat_env + | Tpat_or _ -> fatal_error "Parmatch.normalize_pat" -(* Typechecking of type expressions for the core language *) +(* + Build normalized (cf. supra) discriminating pattern, + in the non-data type case +*) -open Asttypes -open Misc -open Parsetree -open Typedtree -open Types -open Ctype +let discr_pat q pss = + + let rec acc_pat acc pss = match pss with + ({pat_desc = Tpat_alias (p,_,_)}::ps)::pss -> + acc_pat acc ((p::ps)::pss) + | ({pat_desc = Tpat_or (p1,p2,_)}::ps)::pss -> + acc_pat acc ((p1::ps)::(p2::ps)::pss) + | ({pat_desc = (Tpat_any | Tpat_var _)}::_)::pss -> + acc_pat acc pss + | (({pat_desc = Tpat_tuple _} as p)::_)::_ -> normalize_pat p + | (({pat_desc = Tpat_lazy _} as p)::_)::_ -> normalize_pat p + | (({pat_desc = Tpat_record (largs,closed)} as p)::_)::pss -> + let new_omegas = + List.fold_right + (fun (lid, lbl,_) r -> + try + let _ = get_field lbl.lbl_pos r in + r + with Not_found -> + (lid, lbl,omega)::r) + largs (record_arg acc) + in + acc_pat + (make_pat (Tpat_record (new_omegas, closed)) p.pat_type p.pat_env) + pss + | _ -> acc in -exception Already_bound + match normalize_pat q with + | {pat_desc= (Tpat_any | Tpat_record _)} as q -> acc_pat q pss + | q -> q -type error = - Unbound_type_variable of string - | Unbound_type_constructor of Longident.t - | Unbound_type_constructor_2 of Path.t - | Type_arity_mismatch of Longident.t * int * int - | Bound_type_variable of string - | Recursive_type - | Unbound_row_variable of Longident.t - | Type_mismatch of (type_expr * type_expr) list - | Alias_type_mismatch of (type_expr * type_expr) list - | Present_has_conjunction of string - | Present_has_no_type of string - | Constructor_mismatch of type_expr * type_expr - | Not_a_variant of type_expr - | Variant_tags of string * string - | Invalid_variable_name of string - | Cannot_quantify of string * type_expr - | Multiple_constraints_on_type of Longident.t - | Method_mismatch of string * type_expr * type_expr - | Unbound_value of Longident.t - | Unbound_constructor of Longident.t - | Unbound_label of Longident.t - | Unbound_module of Longident.t - | Unbound_class of Longident.t - | Unbound_modtype of Longident.t - | Unbound_cltype of Longident.t - | Ill_typed_functor_application of Longident.t - | Illegal_reference_to_recursive_module - | Access_functor_as_structure of Longident.t - | Apply_structure_as_functor of Longident.t - | Cannot_scrape_alias of Longident.t * Path.t - | Opened_object of Path.t option - | Not_an_object of type_expr +(* + In case a matching value is found, set actual arguments + of the matching pattern. +*) -exception Error of Location.t * Env.t * error -exception Error_forward of Location.error +let rec read_args xs r = match xs,r with +| [],_ -> [],r +| _::xs, arg::rest -> + let args,rest = read_args xs rest in + arg::args,rest +| _,_ -> + fatal_error "Parmatch.read_args" +let do_set_args erase_mutable q r = match q with +| {pat_desc = Tpat_tuple omegas} -> + let args,rest = read_args omegas r in + make_pat (Tpat_tuple args) q.pat_type q.pat_env::rest +| {pat_desc = Tpat_record (omegas,closed)} -> + let args,rest = read_args omegas r in + make_pat + (Tpat_record + (List.map2 (fun (lid, lbl,_) arg -> + if + erase_mutable && + (match lbl.lbl_mut with + | Mutable -> true | Immutable -> false) + then + lid, lbl, omega + else + lid, lbl, arg) + omegas args, closed)) + q.pat_type q.pat_env:: + rest +| {pat_desc = Tpat_construct (lid, c,omegas)} -> + let args,rest = read_args omegas r in + make_pat + (Tpat_construct (lid, c,args)) + q.pat_type q.pat_env:: + rest +| {pat_desc = Tpat_variant (l, omega, row)} -> + let arg, rest = + match omega, r with + Some _, a::r -> Some a, r + | None, r -> None, r + | _ -> assert false + in + make_pat + (Tpat_variant (l, arg, row)) q.pat_type q.pat_env:: + rest +| {pat_desc = Tpat_lazy _omega} -> + begin match r with + arg::rest -> + make_pat (Tpat_lazy arg) q.pat_type q.pat_env::rest + | _ -> fatal_error "Parmatch.do_set_args (lazy)" + end +| {pat_desc = Tpat_array omegas} -> + let args,rest = read_args omegas r in + make_pat + (Tpat_array args) q.pat_type q.pat_env:: + rest +| {pat_desc=Tpat_constant _|Tpat_any} -> + q::r (* case any is used in matching.ml *) +| _ -> fatal_error "Parmatch.set_args" -type variable_context = int * (string, type_expr) Tbl.t +let set_args q r = do_set_args false q r +and set_args_erase_mutable q r = do_set_args true q r -(* Local definitions *) +(* filter pss according to pattern q *) +let filter_one q pss = + let rec filter_rec = function + ({pat_desc = Tpat_alias(p,_,_)}::ps)::pss -> + filter_rec ((p::ps)::pss) + | ({pat_desc = Tpat_or(p1,p2,_)}::ps)::pss -> + filter_rec ((p1::ps)::(p2::ps)::pss) + | (p::ps)::pss -> + if simple_match q p + then (simple_match_args q p @ ps) :: filter_rec pss + else filter_rec pss + | _ -> [] in + filter_rec pss -let instance_list = Ctype.instance_list Env.empty +(* + Filter pss in the ``extra case''. This applies : + - According to an extra constructor (datatype case, non-complete signature). + - According to anything (all-variables case). +*) +let filter_extra pss = + let rec filter_rec = function + ({pat_desc = Tpat_alias(p,_,_)}::ps)::pss -> + filter_rec ((p::ps)::pss) + | ({pat_desc = Tpat_or(p1,p2,_)}::ps)::pss -> + filter_rec ((p1::ps)::(p2::ps)::pss) + | ({pat_desc = (Tpat_any | Tpat_var(_))} :: qs) :: pss -> + qs :: filter_rec pss + | _::pss -> filter_rec pss + | [] -> [] in + filter_rec pss -(* Narrowing unbound identifier errors. *) +(* + Pattern p0 is the discriminating pattern, + returns [(q0,pss0) ; ... ; (qn,pssn)] + where the qi's are simple patterns and the pssi's are + matched matrices. -let rec narrow_unbound_lid_error : 'a. _ -> _ -> _ -> _ -> 'a = - fun env loc lid make_error -> - let check_module mlid = - try ignore (Env.lookup_module ~load:true mlid env) with - | Not_found -> - narrow_unbound_lid_error env loc mlid (fun lid -> Unbound_module lid) - | Env.Recmodule -> - raise (Error (loc, env, Illegal_reference_to_recursive_module)) - in - begin match lid with - | Longident.Lident _ -> () - | Longident.Ldot (mlid, _) -> - check_module mlid; - let md = Env.find_module (Env.lookup_module ~load:true mlid env) env in - begin match Env.scrape_alias env md.md_type with - | Mty_functor _ -> - raise (Error (loc, env, Access_functor_as_structure mlid)) - | Mty_alias(_, p) -> - raise (Error (loc, env, Cannot_scrape_alias(mlid, p))) - | _ -> () - end - | Longident.Lapply (flid, mlid) -> - check_module flid; - let fmd = Env.find_module (Env.lookup_module ~load:true flid env) env in - begin match Env.scrape_alias env fmd.md_type with - | Mty_signature _ -> - raise (Error (loc, env, Apply_structure_as_functor flid)) - | Mty_alias(_, p) -> - raise (Error (loc, env, Cannot_scrape_alias(flid, p))) - | _ -> () - end; - check_module mlid; - let mmd = Env.find_module (Env.lookup_module ~load:true mlid env) env in - begin match Env.scrape_alias env mmd.md_type with - | Mty_alias(_, p) -> - raise (Error (loc, env, Cannot_scrape_alias(mlid, p))) - | _ -> - raise (Error (loc, env, Ill_typed_functor_application lid)) - end - end; - raise (Error (loc, env, make_error lid)) + NOTES + * (qi,[]) is impossible. + * In the case when matching is useless (all-variable case), + returns [] +*) -let find_component (lookup : ?loc:_ -> _) make_error env loc lid = - try - match lid with - | Longident.Ldot (Longident.Lident "*predef*", s) -> - lookup ~loc (Longident.Lident s) Env.initial_safe_string - | _ -> - lookup ~loc lid env - with Not_found -> - narrow_unbound_lid_error env loc lid make_error - | Env.Recmodule -> - raise (Error (loc, env, Illegal_reference_to_recursive_module)) +let filter_all pat0 pss = -let find_type env loc lid = - let path = - find_component Env.lookup_type (fun lid -> Unbound_type_constructor lid) - env loc lid - in - let decl = Env.find_type path env in - Builtin_attributes.check_deprecated loc decl.type_attributes (Path.name path); - (path, decl) + let rec insert q qs env = + match env with + [] -> + let q0 = normalize_pat q in + [q0, [simple_match_args q0 q @ qs]] + | ((q0,pss) as c)::env -> + if simple_match q0 q + then (q0, ((simple_match_args q0 q @ qs) :: pss)) :: env + else c :: insert q qs env in -let find_constructor = - find_component Env.lookup_constructor (fun lid -> Unbound_constructor lid) -let find_all_constructors = - find_component Env.lookup_all_constructors - (fun lid -> Unbound_constructor lid) -let find_label = - find_component Env.lookup_label (fun lid -> Unbound_label lid) -let find_all_labels = - find_component Env.lookup_all_labels (fun lid -> Unbound_label lid) + let rec filter_rec env = function + ({pat_desc = Tpat_alias(p,_,_)}::ps)::pss -> + filter_rec env ((p::ps)::pss) + | ({pat_desc = Tpat_or(p1,p2,_)}::ps)::pss -> + filter_rec env ((p1::ps)::(p2::ps)::pss) + | ({pat_desc = (Tpat_any | Tpat_var(_))}::_)::pss -> + filter_rec env pss + | (p::ps)::pss -> + filter_rec (insert p ps env) pss + | _ -> env -let find_class env loc lid = - let (path, decl) as r = - find_component Env.lookup_class (fun lid -> Unbound_class lid) env loc lid - in - Builtin_attributes.check_deprecated loc decl.cty_attributes (Path.name path); - r + and filter_omega env = function + ({pat_desc = Tpat_alias(p,_,_)}::ps)::pss -> + filter_omega env ((p::ps)::pss) + | ({pat_desc = Tpat_or(p1,p2,_)}::ps)::pss -> + filter_omega env ((p1::ps)::(p2::ps)::pss) + | ({pat_desc = (Tpat_any | Tpat_var(_))}::ps)::pss -> + filter_omega + (List.map (fun (q,qss) -> (q,(simple_match_args q omega @ ps) :: qss)) + env) + pss + | _::pss -> filter_omega env pss + | [] -> env in -let find_value env loc lid = - Env.check_value_name (Longident.last lid) loc; - let (path, decl) as r = - find_component Env.lookup_value (fun lid -> Unbound_value lid) env loc lid - in - Builtin_attributes.check_deprecated loc decl.val_attributes (Path.name path); - r + filter_omega + (filter_rec + (match pat0.pat_desc with + (Tpat_record(_) | Tpat_tuple(_) | Tpat_lazy(_)) -> [pat0,[]] + | _ -> []) + pss) + pss -let lookup_module ?(load=false) env loc lid = - find_component (fun ?loc lid env -> (Env.lookup_module ~load ?loc lid env)) - (fun lid -> Unbound_module lid) env loc lid +(* Variant related functions *) -let find_module env loc lid = - let path = lookup_module ~load:true env loc lid in - let decl = Env.find_module path env in - (* No need to check for deprecated here, this is done in Env. *) - (path, decl) +let rec set_last a = function + [] -> [] + | [_] -> [a] + | x::l -> x :: set_last a l -let find_modtype env loc lid = - let (path, decl) as r = - find_component Env.lookup_modtype (fun lid -> Unbound_modtype lid) - env loc lid - in - Builtin_attributes.check_deprecated loc decl.mtd_attributes (Path.name path); - r +(* mark constructor lines for failure when they are incomplete *) +let rec mark_partial = function + ({pat_desc = Tpat_alias(p,_,_)}::ps)::pss -> + mark_partial ((p::ps)::pss) + | ({pat_desc = Tpat_or(p1,p2,_)}::ps)::pss -> + mark_partial ((p1::ps)::(p2::ps)::pss) + | ({pat_desc = (Tpat_any | Tpat_var(_))} :: _ as ps) :: pss -> + ps :: mark_partial pss + | ps::pss -> + (set_last zero ps) :: mark_partial pss + | [] -> [] -let find_class_type env loc lid = - let (path, decl) as r = - find_component Env.lookup_cltype (fun lid -> Unbound_cltype lid) - env loc lid - in - Builtin_attributes.check_deprecated loc decl.clty_attributes (Path.name path); - r +let close_variant env row = + let row = Btype.row_repr row in + let nm = + List.fold_left + (fun nm (_tag,f) -> + match Btype.row_field_repr f with + | Reither(_, _, false, e) -> + (* m=false means that this tag is not explicitly matched *) + Btype.set_row_field e Rabsent; + None + | Rabsent | Reither (_, _, true, _) | Rpresent _ -> nm) + row.row_name row.row_fields in + if not row.row_closed || nm != row.row_name then begin + (* this unification cannot fail *) + Ctype.unify env row.row_more + (Btype.newgenty + (Tvariant {row with row_fields = []; row_more = Btype.newgenvar(); + row_closed = true; row_name = nm})) + end -let unbound_constructor_error env lid = - narrow_unbound_lid_error env lid.loc lid.txt - (fun lid -> Unbound_constructor lid) +let row_of_pat pat = + match Ctype.expand_head pat.pat_env pat.pat_type with + {desc = Tvariant row} -> Btype.row_repr row + | _ -> assert false -let unbound_label_error env lid = - narrow_unbound_lid_error env lid.loc lid.txt - (fun lid -> Unbound_label lid) +(* + Check whether the first column of env makes up a complete signature or + not. +*) -(* Support for first-class modules. *) +let full_match closing env = match env with +| ({pat_desc = Tpat_construct(_,c,_)},_) :: _ -> + if c.cstr_consts < 0 then false (* extensions *) + else List.length env = c.cstr_consts + c.cstr_nonconsts +| ({pat_desc = Tpat_variant _} as p,_) :: _ -> + let fields = + List.map + (function ({pat_desc = Tpat_variant (tag, _, _)}, _) -> tag + | _ -> assert false) + env + in + let row = row_of_pat p in + if closing && not (Btype.row_fixed row) then + (* closing=true, we are considering the variant as closed *) + List.for_all + (fun (tag,f) -> + match Btype.row_field_repr f with + Rabsent | Reither(_, _, false, _) -> true + | Reither (_, _, true, _) + (* m=true, do not discard matched tags, rather warn *) + | Rpresent _ -> List.mem tag fields) + row.row_fields + else + row.row_closed && + List.for_all + (fun (tag,f) -> + Btype.row_field_repr f = Rabsent || List.mem tag fields) + row.row_fields +| ({pat_desc = Tpat_constant(Const_char _)},_) :: _ -> + List.length env = 256 +| ({pat_desc = Tpat_constant(_)},_) :: _ -> false +| ({pat_desc = Tpat_tuple(_)},_) :: _ -> true +| ({pat_desc = Tpat_record(_)},_) :: _ -> true +| ({pat_desc = Tpat_array(_)},_) :: _ -> false +| ({pat_desc = Tpat_lazy(_)},_) :: _ -> true +| ({pat_desc = (Tpat_any|Tpat_var _|Tpat_alias _|Tpat_or _)},_) :: _ +| [] + -> + assert false -let transl_modtype_longident = ref (fun _ -> assert false) -let transl_modtype = ref (fun _ -> assert false) +(* Written as a non-fragile matching, PR#7451 originated from a fragile matching below. *) +let should_extend ext env = match ext with +| None -> false +| Some ext -> begin match env with + | [] -> assert false + | (p,_)::_ -> + begin match p.pat_desc with + | Tpat_construct + (_, {cstr_tag=(Cstr_constant _|Cstr_block _|Cstr_unboxed)},_) -> + let path = get_type_path p.pat_type p.pat_env in + Path.same path ext + | Tpat_construct + (_, {cstr_tag=(Cstr_extension _)},_) -> false + | Tpat_constant _|Tpat_tuple _|Tpat_variant _ + | Tpat_record _|Tpat_array _ | Tpat_lazy _ + -> false + | Tpat_any|Tpat_var _|Tpat_alias _|Tpat_or _ + -> assert false + end +end -let create_package_mty fake loc env (p, l) = - let l = - List.sort - (fun (s1, _t1) (s2, _t2) -> - if s1.txt = s2.txt then - raise (Error (loc, env, Multiple_constraints_on_type s1.txt)); - compare s1.txt s2.txt) - l - in - l, - List.fold_left - (fun mty (s, t) -> - let d = {ptype_name = mkloc (Longident.last s.txt) s.loc; - ptype_params = []; - ptype_cstrs = []; - ptype_kind = Ptype_abstract; - ptype_private = Asttypes.Public; - ptype_manifest = if fake then None else Some t; - ptype_attributes = []; - ptype_loc = loc} in - Ast_helper.Mty.mk ~loc - (Pmty_with (mty, [ Pwith_type ({ txt = s.txt; loc }, d) ])) - ) - (Ast_helper.Mty.mk ~loc (Pmty_ident p)) - l +module ConstructorTagHashtbl = Hashtbl.Make( + struct + type t = Types.constructor_tag + let hash = Hashtbl.hash + let equal = Types.equal_tag + end +) -(* Translation of type expressions *) +(* complement constructor tags *) +let complete_tags nconsts nconstrs tags = + let seen_const = Array.make nconsts false + and seen_constr = Array.make nconstrs false in + List.iter + (function + | Cstr_constant i -> seen_const.(i) <- true + | Cstr_block i -> seen_constr.(i) <- true + | _ -> assert false) + tags ; + let r = ConstructorTagHashtbl.create (nconsts+nconstrs) in + for i = 0 to nconsts-1 do + if not seen_const.(i) then + ConstructorTagHashtbl.add r (Cstr_constant i) () + done ; + for i = 0 to nconstrs-1 do + if not seen_constr.(i) then + ConstructorTagHashtbl.add r (Cstr_block i) () + done ; + r -let type_variables = ref (Tbl.empty : (string, type_expr) Tbl.t) -let univars = ref ([] : (string * type_expr) list) -let pre_univars = ref ([] : type_expr list) -let used_variables = ref (Tbl.empty : (string, type_expr * Location.t) Tbl.t) +(* build a pattern from a constructor list *) +let pat_of_constr ex_pat cstr = + {ex_pat with pat_desc = + Tpat_construct (mknoloc (Longident.Lident "?pat_of_constr?"), + cstr, omegas cstr.cstr_arity)} -let reset_type_variables () = - reset_global_level (); - Ctype.reset_reified_var_counter (); - type_variables := Tbl.empty +let orify x y = make_pat (Tpat_or (x, y, None)) x.pat_type x.pat_env -let narrow () = - (increase_global_level (), !type_variables) +let rec orify_many = function +| [] -> assert false +| [x] -> x +| x :: xs -> orify x (orify_many xs) -let widen (gl, tv) = - restore_global_level gl; - type_variables := tv +let pat_of_constrs ex_pat cstrs = + if cstrs = [] then raise Empty else + orify_many (List.map (pat_of_constr ex_pat) cstrs) -let strict_ident c = (c = '_' || c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z') +let pats_of_type ?(always=false) env ty = + let ty' = Ctype.expand_head env ty in + match ty'.desc with + | Tconstr (path, _, _) -> + begin try match (Env.find_type path env).type_kind with + | Type_variant cl when always || List.length cl = 1 || + List.for_all (fun cd -> cd.Types.cd_res <> None) cl -> + let cstrs = fst (Env.find_type_descrs path env) in + List.map (pat_of_constr (make_pat Tpat_any ty env)) cstrs + | Type_record _ -> + let labels = snd (Env.find_type_descrs path env) in + let fields = + List.map (fun ld -> + mknoloc (Longident.Lident "?pat_of_label?"), ld, omega) + labels + in + [make_pat (Tpat_record (fields, Closed)) ty env] + | _ -> [omega] + with Not_found -> [omega] + end + | Ttuple tl -> + [make_pat (Tpat_tuple (omegas (List.length tl))) ty env] + | _ -> [omega] -let validate_name = function - None -> None - | Some name as s -> - if name <> "" && strict_ident name.[0] then s else None +let rec get_variant_constructors env ty = + match (Ctype.repr ty).desc with + | Tconstr (path,_,_) -> begin + try match Env.find_type path env with + | {type_kind=Type_variant _} -> + fst (Env.find_type_descrs path env) + | {type_manifest = Some _} -> + get_variant_constructors env + (Ctype.expand_head_once env (clean_copy ty)) + | _ -> fatal_error "Parmatch.get_variant_constructors" + with Not_found -> + fatal_error "Parmatch.get_variant_constructors" + end + | _ -> fatal_error "Parmatch.get_variant_constructors" -let new_global_var ?name () = - new_global_var ?name:(validate_name name) () -let newvar ?name () = - newvar ?name:(validate_name name) () +(* Sends back a pattern that complements constructor tags all_tag *) +let complete_constrs p all_tags = + let c = + match p.pat_desc with Tpat_construct (_, c, _) -> c | _ -> assert false in + let not_tags = complete_tags c.cstr_consts c.cstr_nonconsts all_tags in + let constrs = get_variant_constructors p.pat_env c.cstr_res in + let others = + List.filter + (fun cnstr -> ConstructorTagHashtbl.mem not_tags cnstr.cstr_tag) + constrs in + let const, nonconst = + List.partition (fun cnstr -> cnstr.cstr_arity = 0) others in + const @ nonconst -let type_variable loc name = - try - Tbl.find name !type_variables - with Not_found -> - raise(Error(loc, Env.empty, Unbound_type_variable ("'" ^ name))) +let build_other_constrs env p = + match p.pat_desc with + Tpat_construct (_, {cstr_tag=Cstr_constant _|Cstr_block _}, _) -> + let get_tag = function + | {pat_desc = Tpat_construct (_,c,_)} -> c.cstr_tag + | _ -> fatal_error "Parmatch.get_tag" in + let all_tags = List.map (fun (p,_) -> get_tag p) env in + pat_of_constrs p (complete_constrs p all_tags) + | _ -> extra_pat -let transl_type_param env styp = - let loc = styp.ptyp_loc in - match styp.ptyp_desc with - Ptyp_any -> - let ty = new_global_var ~name:"_" () in - { ctyp_desc = Ttyp_any; ctyp_type = ty; ctyp_env = env; - ctyp_loc = loc; ctyp_attributes = styp.ptyp_attributes; } - | Ptyp_var name -> - let ty = - try - if name <> "" && name.[0] = '_' then - raise (Error (loc, Env.empty, Invalid_variable_name ("'" ^ name))); - ignore (Tbl.find name !type_variables); - raise Already_bound - with Not_found -> - let v = new_global_var ~name () in - type_variables := Tbl.add name v !type_variables; - v - in - { ctyp_desc = Ttyp_var name; ctyp_type = ty; ctyp_env = env; - ctyp_loc = loc; ctyp_attributes = styp.ptyp_attributes; } - | _ -> assert false +(* Auxiliary for build_other *) -let transl_type_param env styp = - (* Currently useless, since type parameters cannot hold attributes - (but this could easily be lifted in the future). *) - Builtin_attributes.warning_scope styp.ptyp_attributes - (fun () -> transl_type_param env styp) +let build_other_constant proj make first next p env = + let all = List.map (fun (p, _) -> proj p.pat_desc) env in + let rec try_const i = + if List.mem i all + then try_const (next i) + else make_pat (make i) p.pat_type p.pat_env + in try_const first +(* + Builds a pattern that is incompatible with all patterns in + in the first column of env +*) -let new_pre_univar ?name () = - let v = newvar ?name () in pre_univars := v :: !pre_univars; v +let some_other_tag = "" -let rec swap_list = function - x :: y :: l -> y :: x :: swap_list l - | l -> l +let build_other ext env = match env with +| ({pat_desc = Tpat_construct (lid, {cstr_tag=Cstr_extension _},_)},_) :: _ -> + (* let c = {c with cstr_name = "*extension*"} in *) (* PR#7330 *) + make_pat (Tpat_var (Ident.create "*extension*", + {lid with txt="*extension*"})) Ctype.none Env.empty +| ({pat_desc = Tpat_construct _} as p,_) :: _ -> + begin match ext with + | Some ext when Path.same ext (get_type_path p.pat_type p.pat_env) -> + extra_pat + | _ -> + build_other_constrs env p + end +| ({pat_desc = Tpat_variant (_,_,r)} as p,_) :: _ -> + let tags = + List.map + (function ({pat_desc = Tpat_variant (tag, _, _)}, _) -> tag + | _ -> assert false) + env + in + let row = row_of_pat p in + let make_other_pat tag const = + let arg = if const then None else Some omega in + make_pat (Tpat_variant(tag, arg, r)) p.pat_type p.pat_env in + begin match + List.fold_left + (fun others (tag,f) -> + if List.mem tag tags then others else + match Btype.row_field_repr f with + Rabsent (* | Reither _ *) -> others + (* This one is called after erasing pattern info *) + | Reither (c, _, _, _) -> make_other_pat tag c :: others + | Rpresent arg -> make_other_pat tag (arg = None) :: others) + [] row.row_fields + with + [] -> + make_other_pat some_other_tag true + | pat::other_pats -> + List.fold_left + (fun p_res pat -> + make_pat (Tpat_or (pat, p_res, None)) p.pat_type p.pat_env) + pat other_pats + end +| ({pat_desc = Tpat_constant(Const_char _)} as p,_) :: _ -> + let all_chars = + List.map + (fun (p,_) -> match p.pat_desc with + | Tpat_constant (Const_char c) -> c + | _ -> assert false) + env in -type policy = Fixed | Extensible | Univars + let rec find_other i imax = + if i > imax then raise Not_found + else + let ci = Char.chr i in + if List.mem ci all_chars then + find_other (i+1) imax + else + make_pat (Tpat_constant (Const_char ci)) p.pat_type p.pat_env in + let rec try_chars = function + | [] -> omega + | (c1,c2) :: rest -> + try + find_other (Char.code c1) (Char.code c2) + with + | Not_found -> try_chars rest in -let rec transl_type env policy styp = - Builtin_attributes.warning_scope styp.ptyp_attributes - (fun () -> transl_type_aux env policy styp) + try_chars + [ 'a', 'z' ; 'A', 'Z' ; '0', '9' ; + ' ', '~' ; Char.chr 0 , Char.chr 255] -and transl_type_aux env policy styp = - let loc = styp.ptyp_loc in - let ctyp ctyp_desc ctyp_type = - { ctyp_desc; ctyp_type; ctyp_env = env; - ctyp_loc = loc; ctyp_attributes = styp.ptyp_attributes } - in - match styp.ptyp_desc with - Ptyp_any -> - let ty = - if policy = Univars then new_pre_univar () else - if policy = Fixed then - raise (Error (styp.ptyp_loc, env, Unbound_type_variable "_")) - else newvar () - in - ctyp Ttyp_any ty - | Ptyp_var name -> - let ty = - if name <> "" && name.[0] = '_' then - raise (Error (styp.ptyp_loc, env, Invalid_variable_name ("'" ^ name))); - begin try - instance env (List.assoc name !univars) - with Not_found -> try - instance env (fst(Tbl.find name !used_variables)) - with Not_found -> - let v = - if policy = Univars then new_pre_univar ~name () else newvar ~name () - in - used_variables := Tbl.add name (v, styp.ptyp_loc) !used_variables; - v - end - in - ctyp (Ttyp_var name) ty - | Ptyp_arrow(l, st1, st2) -> - let cty1 = transl_type env policy st1 in - let cty2 = transl_type env policy st2 in - let ty1 = cty1.ctyp_type in - let ty1 = - if Btype.is_optional l - then newty (Tconstr(Predef.path_option,[ty1], ref Mnil)) - else ty1 in - let ty = newty (Tarrow(l, ty1, cty2.ctyp_type, Cok)) in - ctyp (Ttyp_arrow (l, cty1, cty2)) ty - | Ptyp_tuple stl -> - assert (List.length stl >= 2); - let ctys = List.map (transl_type env policy) stl in - let ty = newty (Ttuple (List.map (fun ctyp -> ctyp.ctyp_type) ctys)) in - ctyp (Ttyp_tuple ctys) ty - | Ptyp_constr(lid, stl) -> - let (path, decl) = find_type env lid.loc lid.txt in - let stl = - match stl with - | [ {ptyp_desc=Ptyp_any} as t ] when decl.type_arity > 1 -> - List.map (fun _ -> t) decl.type_params - | _ -> stl - in - if List.length stl <> decl.type_arity then - raise(Error(styp.ptyp_loc, env, - Type_arity_mismatch(lid.txt, decl.type_arity, - List.length stl))); - let args = List.map (transl_type env policy) stl in - let params = instance_list decl.type_params in - let unify_param = - match decl.type_manifest with - None -> unify_var - | Some ty -> - if (repr ty).level = Btype.generic_level then unify_var else unify - in - List.iter2 - (fun (sty, cty) ty' -> - try unify_param env ty' cty.ctyp_type with Unify trace -> - raise (Error(sty.ptyp_loc, env, Type_mismatch (swap_list trace)))) - (List.combine stl args) params; - let constr = - newconstr path (List.map (fun ctyp -> ctyp.ctyp_type) args) in - begin try - Ctype.enforce_constraints env constr - with Unify trace -> - raise (Error(styp.ptyp_loc, env, Type_mismatch trace)) - end; - ctyp (Ttyp_constr (path, lid, args)) constr - | Ptyp_object (fields, o) -> - let ty, fields = transl_fields env policy o fields in - ctyp (Ttyp_object (fields, o)) (newobj ty) - | Ptyp_class(lid, stl) -> - let (path, decl, _is_variant) = - try - let path = Env.lookup_type lid.txt env in - let decl = Env.find_type path env in - let rec check decl = - match decl.type_manifest with - None -> raise Not_found - | Some ty -> - match (repr ty).desc with - Tvariant row when Btype.static_row row -> () - | Tconstr (path, _, _) -> - check (Env.find_type path env) - | _ -> raise Not_found - in check decl; - Location.deprecated styp.ptyp_loc - "old syntax for polymorphic variant type"; - (path, decl,true) - with Not_found -> try - let lid2 = - match lid.txt with - Longident.Lident s -> Longident.Lident ("#" ^ s) - | Longident.Ldot(r, s) -> Longident.Ldot (r, "#" ^ s) - | Longident.Lapply(_, _) -> fatal_error "Typetexp.transl_type" - in - let path = Env.lookup_type lid2 env in - let decl = Env.find_type path env in - (path, decl, false) - with Not_found -> - ignore (find_class env lid.loc lid.txt); assert false - in - if List.length stl <> decl.type_arity then - raise(Error(styp.ptyp_loc, env, - Type_arity_mismatch(lid.txt, decl.type_arity, - List.length stl))); - let args = List.map (transl_type env policy) stl in - let params = instance_list decl.type_params in - List.iter2 - (fun (sty, cty) ty' -> - try unify_var env ty' cty.ctyp_type with Unify trace -> - raise (Error(sty.ptyp_loc, env, Type_mismatch (swap_list trace)))) - (List.combine stl args) params; - let ty_args = List.map (fun ctyp -> ctyp.ctyp_type) args in - let ty = - try Ctype.expand_head env (newconstr path ty_args) - with Unify trace -> - raise (Error(styp.ptyp_loc, env, Type_mismatch trace)) - in - let ty = match ty.desc with - Tvariant row -> - let row = Btype.row_repr row in - let fields = - List.map - (fun (l,f) -> l, - match Btype.row_field_repr f with - | Rpresent (Some ty) -> - Reither(false, [ty], false, ref None) - | Rpresent None -> - Reither (true, [], false, ref None) - | _ -> f) - row.row_fields - in - let row = { row_closed = true; row_fields = fields; - row_bound = (); row_name = Some (path, ty_args); - row_fixed = false; row_more = newvar () } in - let static = Btype.static_row row in - let row = - if static then { row with row_more = newty Tnil } - else if policy <> Univars then row - else { row with row_more = new_pre_univar () } - in - newty (Tvariant row) - | Tobject (fi, _) -> - let _, tv = flatten_fields fi in - if policy = Univars then pre_univars := tv :: !pre_univars; - ty - | _ -> - assert false - in - ctyp (Ttyp_class (path, lid, args)) ty - | Ptyp_alias(st, alias) -> - let cty = - try - let t = - try List.assoc alias !univars - with Not_found -> - instance env (fst(Tbl.find alias !used_variables)) - in - let ty = transl_type env policy st in - begin try unify_var env t ty.ctyp_type with Unify trace -> - let trace = swap_list trace in - raise(Error(styp.ptyp_loc, env, Alias_type_mismatch trace)) - end; - ty - with Not_found -> - if !Clflags.principal then begin_def (); - let t = newvar () in - used_variables := Tbl.add alias (t, styp.ptyp_loc) !used_variables; - let ty = transl_type env policy st in - begin try unify_var env t ty.ctyp_type with Unify trace -> - let trace = swap_list trace in - raise(Error(styp.ptyp_loc, env, Alias_type_mismatch trace)) - end; - if !Clflags.principal then begin - end_def (); - generalize_structure t; - end; - let t = instance env t in - let px = Btype.proxy t in - begin match px.desc with - | Tvar None -> Btype.log_type px; px.desc <- Tvar (Some alias) - | Tunivar None -> Btype.log_type px; px.desc <- Tunivar (Some alias) - | _ -> () - end; - { ty with ctyp_type = t } - in - ctyp (Ttyp_alias (cty, alias)) cty.ctyp_type - | Ptyp_variant(fields, closed, present) -> - let name = ref None in - let mkfield l f = - newty (Tvariant {row_fields=[l,f]; row_more=newvar(); - row_bound=(); row_closed=true; - row_fixed=false; row_name=None}) in - let hfields = Hashtbl.create 17 in - let add_typed_field loc l f = - let h = Btype.hash_variant l in - try - let (l',f') = Hashtbl.find hfields h in - (* Check for tag conflicts *) - if l <> l' then raise(Error(styp.ptyp_loc, env, Variant_tags(l, l'))); - let ty = mkfield l f and ty' = mkfield l f' in - if equal env false [ty] [ty'] then () else - try unify env ty ty' - with Unify _trace -> - raise(Error(loc, env, Constructor_mismatch (ty,ty'))) - with Not_found -> - Hashtbl.add hfields h (l,f) - in - let add_field = function - Rtag (l, attrs, c, stl) -> - name := None; - let tl = - Builtin_attributes.warning_scope attrs - (fun () -> List.map (transl_type env policy) stl) - in - let f = match present with - Some present when not (List.mem l.txt present) -> - let ty_tl = List.map (fun cty -> cty.ctyp_type) tl in - Reither(c, ty_tl, false, ref None) - | _ -> - if List.length stl > 1 || c && stl <> [] then - raise(Error(styp.ptyp_loc, env, - Present_has_conjunction l.txt)); - match tl with [] -> Rpresent None - | st :: _ -> - Rpresent (Some st.ctyp_type) - in - add_typed_field styp.ptyp_loc l.txt f; - Ttag (l,attrs,c,tl) - | Rinherit sty -> - let cty = transl_type env policy sty in - let ty = cty.ctyp_type in - let nm = - match repr cty.ctyp_type with - {desc=Tconstr(p, tl, _)} -> Some(p, tl) - | _ -> None - in - begin try - (* Set name if there are no fields yet *) - Hashtbl.iter (fun _ _ -> raise Exit) hfields; - name := nm - with Exit -> - (* Unset it otherwise *) - name := None - end; - let fl = match expand_head env cty.ctyp_type, nm with - {desc=Tvariant row}, _ when Btype.static_row row -> - let row = Btype.row_repr row in - row.row_fields - | {desc=Tvar _}, Some(p, _) -> - raise(Error(sty.ptyp_loc, env, Unbound_type_constructor_2 p)) - | _ -> - raise(Error(sty.ptyp_loc, env, Not_a_variant ty)) - in - List.iter - (fun (l, f) -> - let f = match present with - Some present when not (List.mem l present) -> - begin match f with - Rpresent(Some ty) -> - Reither(false, [ty], false, ref None) - | Rpresent None -> - Reither(true, [], false, ref None) - | _ -> - assert false - end - | _ -> f - in - add_typed_field sty.ptyp_loc l f) - fl; - Tinherit cty - in - let tfields = List.map add_field fields in - let fields = Hashtbl.fold (fun _ p l -> p :: l) hfields [] in - begin match present with None -> () - | Some present -> - List.iter - (fun l -> if not (List.mem_assoc l fields) then - raise(Error(styp.ptyp_loc, env, Present_has_no_type l))) - present - end; - let row = - { row_fields = List.rev fields; row_more = newvar (); - row_bound = (); row_closed = (closed = Closed); - row_fixed = false; row_name = !name } in - let static = Btype.static_row row in - let row = - if static then { row with row_more = newty Tnil } - else if policy <> Univars then row - else { row with row_more = new_pre_univar () } - in - let ty = newty (Tvariant row) in - ctyp (Ttyp_variant (tfields, closed, present)) ty - | Ptyp_poly(vars, st) -> - let vars = List.map (fun v -> v.txt) vars in - begin_def(); - let new_univars = List.map (fun name -> name, newvar ~name ()) vars in - let old_univars = !univars in - univars := new_univars @ !univars; - let cty = transl_type env policy st in - let ty = cty.ctyp_type in - univars := old_univars; - end_def(); - generalize ty; - let ty_list = - List.fold_left - (fun tyl (name, ty1) -> - let v = Btype.proxy ty1 in - if deep_occur v ty then begin - match v.desc with - Tvar name when v.level = Btype.generic_level -> - v.desc <- Tunivar name; - v :: tyl +| ({pat_desc=(Tpat_constant (Const_int _))} as p,_) :: _ -> + build_other_constant + (function Tpat_constant(Const_int i) -> i | _ -> assert false) + (function i -> Tpat_constant(Const_int i)) + 0 succ p env +| ({pat_desc=(Tpat_constant (Const_int32 _))} as p,_) :: _ -> + build_other_constant + (function Tpat_constant(Const_int32 i) -> i | _ -> assert false) + (function i -> Tpat_constant(Const_int32 i)) + 0l Int32.succ p env +| ({pat_desc=(Tpat_constant (Const_int64 _))} as p,_) :: _ -> + build_other_constant + (function Tpat_constant(Const_int64 i) -> i | _ -> assert false) + (function i -> Tpat_constant(Const_int64 i)) + 0L Int64.succ p env +| ({pat_desc=(Tpat_constant (Const_nativeint _))} as p,_) :: _ -> + build_other_constant + (function Tpat_constant(Const_nativeint i) -> i | _ -> assert false) + (function i -> Tpat_constant(Const_nativeint i)) + 0n Nativeint.succ p env +| ({pat_desc=(Tpat_constant (Const_string _))} as p,_) :: _ -> + build_other_constant + (function Tpat_constant(Const_string (s, _)) -> String.length s + | _ -> assert false) + (function i -> Tpat_constant(Const_string(String.make i '*', None))) + 0 succ p env +| ({pat_desc=(Tpat_constant (Const_float _))} as p,_) :: _ -> + build_other_constant + (function Tpat_constant(Const_float f) -> float_of_string f + | _ -> assert false) + (function f -> Tpat_constant(Const_float (string_of_float f))) + 0.0 (fun f -> f +. 1.0) p env + +| ({pat_desc = Tpat_array _} as p,_)::_ -> + let all_lengths = + List.map + (fun (p,_) -> match p.pat_desc with + | Tpat_array args -> List.length args + | _ -> assert false) + env in + let rec try_arrays l = + if List.mem l all_lengths then try_arrays (l+1) + else + make_pat + (Tpat_array (omegas l)) + p.pat_type p.pat_env in + try_arrays 0 +| [] -> omega +| _ -> omega + +(* + Core function : + Is the last row of pattern matrix pss + qs satisfiable ? + That is : + Does there exists at least one value vector, es such that : + 1- for all ps in pss ps # es (ps and es are not compatible) + 2- qs <= es (es matches qs) +*) + +let rec has_instance p = match p.pat_desc with + | Tpat_variant (l,_,r) when is_absent l r -> false + | Tpat_any | Tpat_var _ | Tpat_constant _ | Tpat_variant (_,None,_) -> true + | Tpat_alias (p,_,_) | Tpat_variant (_,Some p,_) -> has_instance p + | Tpat_or (p1,p2,_) -> has_instance p1 || has_instance p2 + | Tpat_construct (_,_,ps) | Tpat_tuple ps | Tpat_array ps -> + has_instances ps + | Tpat_record (lps,_) -> has_instances (List.map (fun (_,_,x) -> x) lps) + | Tpat_lazy p + -> has_instance p + + +and has_instances = function + | [] -> true + | q::rem -> has_instance q && has_instances rem + +(* + In two places in the following function, we check the coherence of the first + column of (pss + qs). + If it is incoherent, then we exit early saying that (pss + qs) is not + satisfiable (which is equivalent to saying "oh, we shouldn't have considered + that branch, no good result came come from here"). + + But what happens if we have a coherent but ill-typed column? + - we might end up returning [false], which is equivalent to noticing the + incompatibility: clearly this is fine. + - if we end up returning [true] then we're saying that [qs] is useful while + it is not. This is sad but not the end of the world, we're just allowing dead + code to survive. +*) +let rec satisfiable pss qs = match pss with +| [] -> has_instances qs +| _ -> + match qs with + | [] -> false + | {pat_desc = Tpat_or(q1,q2,_)}::qs -> + satisfiable pss (q1::qs) || satisfiable pss (q2::qs) + | {pat_desc = Tpat_alias(q,_,_)}::qs -> + satisfiable pss (q::qs) + | {pat_desc = (Tpat_any | Tpat_var(_))}::qs -> + if not (all_coherent (simplified_first_col pss)) then + false + else begin + let q0 = discr_pat omega pss in + match filter_all q0 pss with + (* first column of pss is made of variables only *) + | [] -> satisfiable (filter_extra pss) qs + | constrs -> + if full_match false constrs then + List.exists + (fun (p,pss) -> + not (is_absent_pat p) && + satisfiable pss (simple_match_args p omega @ qs)) + constrs + else + satisfiable (filter_extra pss) qs + end + | {pat_desc=Tpat_variant (l,_,r)}::_ when is_absent l r -> false + | q::qs -> + if not (all_coherent (q :: simplified_first_col pss)) then + false + else begin + let q0 = discr_pat q pss in + satisfiable (filter_one q0 pss) (simple_match_args q0 q @ qs) + end + +(* Also return the remaining cases, to enable GADT handling + + For considerations regarding the coherence check, see the comment on + [satisfiable] above. *) +let rec satisfiables pss qs = match pss with +| [] -> if has_instances qs then [qs] else [] +| _ -> + match qs with + | [] -> [] + | {pat_desc = Tpat_or(q1,q2,_)}::qs -> + satisfiables pss (q1::qs) @ satisfiables pss (q2::qs) + | {pat_desc = Tpat_alias(q,_,_)}::qs -> + satisfiables pss (q::qs) + | {pat_desc = (Tpat_any | Tpat_var(_))}::qs -> + if not (all_coherent (simplified_first_col pss)) then + [] + else begin + let q0 = discr_pat omega pss in + let wild p = + List.map (fun qs -> p::qs) (satisfiables (filter_extra pss) qs) in + match filter_all q0 pss with + (* first column of pss is made of variables only *) + | [] -> + wild omega + | (p,_)::_ as constrs -> + let for_constrs () = + List.flatten ( + List.map + (fun (p,pss) -> + if is_absent_pat p then [] else + List.map (set_args p) + (satisfiables pss (simple_match_args p omega @ qs))) + constrs ) + in + if full_match false constrs then for_constrs () else + match p.pat_desc with + Tpat_construct _ -> + (* activate this code for checking non-gadt constructors *) + wild (build_other_constrs constrs p) @ for_constrs () | _ -> - raise (Error (styp.ptyp_loc, env, Cannot_quantify (name, v))) - end else tyl) - [] new_univars - in - let ty' = Btype.newgenty (Tpoly(ty, List.rev ty_list)) in - unify_var env (newvar()) ty'; - ctyp (Ttyp_poly (vars, cty)) ty' - | Ptyp_package (p, l) -> - let l, mty = create_package_mty true styp.ptyp_loc env (p, l) in - let z = narrow () in - let mty = !transl_modtype env mty in - widen z; - let ptys = List.map (fun (s, pty) -> - s, transl_type env policy pty - ) l in - let path = !transl_modtype_longident styp.ptyp_loc env p.txt in - let ty = newty (Tpackage (path, - List.map (fun (s, _pty) -> s.txt) l, - List.map (fun (_,cty) -> cty.ctyp_type) ptys)) + wild omega + end + | {pat_desc=Tpat_variant (l,_,r)}::_ when is_absent l r -> [] + | q::qs -> + if not (all_coherent (q :: simplified_first_col pss)) then + [] + else begin + let q0 = discr_pat q pss in + List.map (set_args q0) + (satisfiables (filter_one q0 pss) (simple_match_args q0 q @ qs)) + end + +(* + Now another satisfiable function that additionally + supplies an example of a matching value. + + This function should be called for exhaustiveness check only. +*) + +type 'a result = + | Rnone (* No matching value *) + | Rsome of 'a (* This matching value *) + +(* +let rec try_many f = function + | [] -> Rnone + | (p,pss)::rest -> + match f (p,pss) with + | Rnone -> try_many f rest + | r -> r +*) + +let rappend r1 r2 = + match r1, r2 with + | Rnone, _ -> r2 + | _, Rnone -> r1 + | Rsome l1, Rsome l2 -> Rsome (l1 @ l2) + +let rec try_many_gadt f = function + | [] -> Rnone + | (p,pss)::rest -> + rappend (f (p, pss)) (try_many_gadt f rest) + +(* +let rec exhaust ext pss n = match pss with +| [] -> Rsome (omegas n) +| []::_ -> Rnone +| pss -> + let q0 = discr_pat omega pss in + begin match filter_all q0 pss with + (* first column of pss is made of variables only *) + | [] -> + begin match exhaust ext (filter_extra pss) (n-1) with + | Rsome r -> Rsome (q0::r) + | r -> r + end + | constrs -> + let try_non_omega (p,pss) = + if is_absent_pat p then + Rnone + else + match + exhaust + ext pss (List.length (simple_match_args p omega) + n - 1) + with + | Rsome r -> Rsome (set_args p r) + | r -> r in + if + full_match true false constrs && not (should_extend ext constrs) + then + try_many try_non_omega constrs + else + (* + D = filter_extra pss is the default matrix + as it is included in pss, one can avoid + recursive calls on specialized matrices, + Essentially : + * D exhaustive => pss exhaustive + * D non-exhaustive => we have a non-filtered value + *) + let r = exhaust ext (filter_extra pss) (n-1) in + match r with + | Rnone -> Rnone + | Rsome r -> + try + Rsome (build_other ext constrs::r) + with + (* cannot occur, since constructors don't make a full signature *) + | Empty -> fatal_error "Parmatch.exhaust" + end + +let combinations f lst lst' = + let rec iter2 x = + function + [] -> [] + | y :: ys -> + f x y :: iter2 x ys + in + let rec iter = + function + [] -> [] + | x :: xs -> iter2 x lst' @ iter xs + in + iter lst +*) +(* +let print_pat pat = + let rec string_of_pat pat = + match pat.pat_desc with + Tpat_var _ -> "v" + | Tpat_any -> "_" + | Tpat_alias (p, x) -> Printf.sprintf "(%s) as ?" (string_of_pat p) + | Tpat_constant n -> "0" + | Tpat_construct (_, lid, _) -> + Printf.sprintf "%s" (String.concat "." (Longident.flatten lid.txt)) + | Tpat_lazy p -> + Printf.sprintf "(lazy %s)" (string_of_pat p) + | Tpat_or (p1,p2,_) -> + Printf.sprintf "(%s | %s)" (string_of_pat p1) (string_of_pat p2) + | Tpat_tuple list -> + Printf.sprintf "(%s)" (String.concat "," (List.map string_of_pat list)) + | Tpat_variant (_, _, _) -> "variant" + | Tpat_record (_, _) -> "record" + | Tpat_array _ -> "array" + in + Printf.fprintf stderr "PAT[%s]\n%!" (string_of_pat pat) +*) + +(* strictly more powerful than exhaust; however, exhaust + was kept for backwards compatibility *) +let rec exhaust_gadt (ext:Path.t option) pss n = match pss with +| [] -> Rsome [omegas n] +| []::_ -> Rnone +| pss -> + if not (all_coherent (simplified_first_col pss)) then + (* We're considering an ill-typed branch, we won't actually be able to + produce a well typed value taking that branch. *) + Rnone + else begin + (* Assuming the first column is ill-typed but considered coherent, we + might end up producing an ill-typed witness of non-exhaustivity + corresponding to the current branch. + + If [exhaust] has been called by [do_check_partial], then the witnesses + produced get typechecked and the ill-typed ones are discarded. + + If [exhaust] has been called by [do_check_fragile], then it is possible + we might fail to warn the user that the matching is fragile. See for + example testsuite/tests/warnings/w04_failure.ml. *) + let q0 = discr_pat omega pss in + match filter_all q0 pss with + (* first column of pss is made of variables only *) + | [] -> + begin match exhaust_gadt ext (filter_extra pss) (n-1) with + | Rsome r -> Rsome (List.map (fun row -> q0::row) r) + | r -> r + end + | constrs -> + let try_non_omega (p,pss) = + if is_absent_pat p then + Rnone + else + match + exhaust_gadt + ext pss (List.length (simple_match_args p omega) + n - 1) + with + | Rsome r -> Rsome (List.map (fun row -> (set_args p row)) r) + | r -> r in + let before = try_many_gadt try_non_omega constrs in + if + full_match false constrs && not (should_extend ext constrs) + then + before + else + (* + D = filter_extra pss is the default matrix + as it is included in pss, one can avoid + recursive calls on specialized matrices, + Essentially : + * D exhaustive => pss exhaustive + * D non-exhaustive => we have a non-filtered value + *) + let r = exhaust_gadt ext (filter_extra pss) (n-1) in + match r with + | Rnone -> before + | Rsome r -> + try + let p = build_other ext constrs in + let dug = List.map (fun tail -> p :: tail) r in + match before with + | Rnone -> Rsome dug + | Rsome x -> Rsome (x @ dug) + with + (* cannot occur, since constructors don't make a full signature *) + | Empty -> fatal_error "Parmatch.exhaust" + end + +let exhaust_gadt ext pss n = + let ret = exhaust_gadt ext pss n in + match ret with + Rnone -> Rnone + | Rsome lst -> + (* The following line is needed to compile stdlib/printf.ml *) + if lst = [] then Rsome (omegas n) else + let singletons = + List.map + (function + [x] -> x + | _ -> assert false) + lst in - ctyp (Ttyp_package { - pack_path = path; - pack_type = mty.mty_type; - pack_fields = ptys; - pack_txt = p; - }) ty - | Ptyp_extension ext -> - raise (Error_forward (Builtin_attributes.error_of_extension ext)) + Rsome [orify_many singletons] -and transl_poly_type env policy t = - transl_type env policy (Ast_helper.Typ.force_poly t) +(* + Another exhaustiveness check, enforcing variant typing. + Note that it does not check exact exhaustiveness, but whether a + matching could be made exhaustive by closing all variant types. + When this is true of all other columns, the current column is left + open (even if it means that the whole matching is not exhaustive as + a result). + When this is false for the matrix minus the current column, and the + current column is composed of variant tags, we close the variant + (even if it doesn't help in making the matching exhaustive). +*) -and transl_fields env policy o fields = - let hfields = Hashtbl.create 17 in - let add_typed_field loc l ty = - try - let ty' = Hashtbl.find hfields l in - if equal env false [ty] [ty'] then () else - try unify env ty ty' - with Unify _trace -> - raise(Error(loc, env, Method_mismatch (l, ty, ty'))) - with Not_found -> - Hashtbl.add hfields l ty in - let add_field = function - | Otag (s, a, ty1) -> begin - let ty1 = - Builtin_attributes.warning_scope a - (fun () -> transl_poly_type env policy ty1) - in - let field = OTtag (s, a, ty1) in - add_typed_field ty1.ctyp_loc s.txt ty1.ctyp_type; - field +let rec pressure_variants tdefs = function + | [] -> false + | []::_ -> true + | pss -> + if not (all_coherent (simplified_first_col pss)) then + true + else begin + let q0 = discr_pat omega pss in + match filter_all q0 pss with + [] -> pressure_variants tdefs (filter_extra pss) + | constrs -> + let rec try_non_omega = function + (_p,pss) :: rem -> + let ok = pressure_variants tdefs pss in + try_non_omega rem && ok + | [] -> true + in + if full_match (tdefs=None) constrs then + try_non_omega constrs + else if tdefs = None then + pressure_variants None (filter_extra pss) + else + let full = full_match true constrs in + let ok = + if full then try_non_omega constrs + else try_non_omega (filter_all q0 (mark_partial pss)) + in + begin match constrs, tdefs with + ({pat_desc=Tpat_variant _} as p,_):: _, Some env -> + let row = row_of_pat p in + if Btype.row_fixed row + || pressure_variants None (filter_extra pss) then () + else close_variant env row + | _ -> () + end; + ok end - | Oinherit sty -> begin - let cty = transl_type env policy sty in - let nm = - match repr cty.ctyp_type with - {desc=Tconstr(p, _, _)} -> Some p - | _ -> None in - let t = expand_head env cty.ctyp_type in - match t, nm with - {desc=Tobject ({desc=(Tfield _ | Tnil) as tf}, _)}, _ -> begin - if opened_object t then - raise (Error (sty.ptyp_loc, env, Opened_object nm)); - let rec iter_add = function - | Tfield (s, _k, ty1, ty2) -> begin - add_typed_field sty.ptyp_loc s ty1; - iter_add ty2.desc - end - | Tnil -> () - | _ -> assert false in - iter_add tf; - OTinherit cty - end - | {desc=Tvar _}, Some p -> - raise (Error (sty.ptyp_loc, env, Unbound_type_constructor_2 p)) - | _ -> raise (Error (sty.ptyp_loc, env, Not_an_object t)) - end in - let object_fields = List.map add_field fields in - let fields = Hashtbl.fold (fun s ty l -> (s, ty) :: l) hfields [] in - let ty_init = - match o, policy with - | Closed, _ -> newty Tnil - | Open, Univars -> new_pre_univar () - | Open, _ -> newvar () in - let ty = List.fold_left (fun ty (s, ty') -> - newty (Tfield (s, Fpresent, ty', ty))) ty_init fields in - ty, object_fields -(* Make the rows "fixed" in this type, to make universal check easier *) -let rec make_fixed_univars ty = - let ty = repr ty in - if ty.level >= Btype.lowest_level then begin - Btype.mark_type_node ty; - match ty.desc with - | Tvariant row -> - let row = Btype.row_repr row in - if Btype.is_Tunivar (Btype.row_more row) then - ty.desc <- Tvariant - {row with row_fixed=true; - row_fields = List.map - (fun (s,f as p) -> match Btype.row_field_repr f with - Reither (c, tl, _m, r) -> s, Reither (c, tl, true, r) - | _ -> p) - row.row_fields}; - Btype.iter_row make_fixed_univars row - | _ -> - Btype.iter_type_expr make_fixed_univars ty - end +(* Yet another satisfiable function *) + +(* + This time every_satisfiable pss qs checks the + utility of every expansion of qs. + Expansion means expansion of or-patterns inside qs +*) -let make_fixed_univars ty = - make_fixed_univars ty; - Btype.unmark_type ty +type answer = + | Used (* Useful pattern *) + | Unused (* Useless pattern *) + | Upartial of Typedtree.pattern list (* Mixed, with list of useless ones *) -let create_package_mty = create_package_mty false -let globalize_used_variables env fixed = - let r = ref [] in - Tbl.iter - (fun name (ty, loc) -> - let v = new_global_var () in - let snap = Btype.snapshot () in - if try unify env v ty; true with _ -> Btype.backtrack snap; false - then try - r := (loc, v, Tbl.find name !type_variables) :: !r - with Not_found -> - if fixed && Btype.is_Tvar (repr ty) then - raise(Error(loc, env, Unbound_type_variable ("'"^name))); - let v2 = new_global_var () in - r := (loc, v, v2) :: !r; - type_variables := Tbl.add name v2 !type_variables) - !used_variables; - used_variables := Tbl.empty; - fun () -> - List.iter - (function (loc, t1, t2) -> - try unify env t1 t2 with Unify trace -> - raise (Error(loc, env, Type_mismatch trace))) - !r -let transl_simple_type env fixed styp = - univars := []; used_variables := Tbl.empty; - let typ = transl_type env (if fixed then Fixed else Extensible) styp in - globalize_used_variables env fixed (); - make_fixed_univars typ.ctyp_type; - typ +(* this row type enable column processing inside the matrix + - left -> elements not to be processed, + - right -> elements to be processed +*) +type 'a row = {no_ors : 'a list ; ors : 'a list ; active : 'a list} -let transl_simple_type_univars env styp = - univars := []; used_variables := Tbl.empty; pre_univars := []; - begin_def (); - let typ = transl_type env Univars styp in - (* Only keep already global variables in used_variables *) - let new_variables = !used_variables in - used_variables := Tbl.empty; - Tbl.iter - (fun name p -> - if Tbl.mem name !type_variables then - used_variables := Tbl.add name p !used_variables) - new_variables; - globalize_used_variables env false (); - end_def (); - generalize typ.ctyp_type; - let univs = - List.fold_left - (fun acc v -> - let v = repr v in - match v.desc with - Tvar name when v.level = Btype.generic_level -> - v.desc <- Tunivar name; v :: acc - | _ -> acc) - [] !pre_univars - in - make_fixed_univars typ.ctyp_type; - { typ with ctyp_type = - instance env (Btype.newgenty (Tpoly (typ.ctyp_type, univs))) } -let transl_simple_type_delayed env styp = - univars := []; used_variables := Tbl.empty; - let typ = transl_type env Extensible styp in - make_fixed_univars typ.ctyp_type; - (typ, globalize_used_variables env false) +(* +let pretty_row {ors=ors ; no_ors=no_ors; active=active} = + pretty_line ors ; prerr_string " *" ; + pretty_line no_ors ; prerr_string " *" ; + pretty_line active -let transl_type_scheme env styp = - reset_type_variables(); - begin_def(); - let typ = transl_simple_type env false styp in - end_def(); - generalize typ.ctyp_type; - typ +let pretty_rows rs = + prerr_endline "begin matrix" ; + List.iter + (fun r -> + pretty_row r ; + prerr_endline "") + rs ; + prerr_endline "end matrix" +*) +(* Initial build *) +let make_row ps = {ors=[] ; no_ors=[]; active=ps} -(* Error report *) +let make_rows pss = List.map make_row pss -open Format -open Printtyp -let spellcheck ppf fold env lid = - let choices ~path name = - let env = fold (fun x xs -> x::xs) path env [] in - Misc.spellcheck env name in - match lid with - | Longident.Lapply _ -> () - | Longident.Lident s -> - Misc.did_you_mean ppf (fun () -> choices ~path:None s) - | Longident.Ldot (r, s) -> - Misc.did_you_mean ppf (fun () -> choices ~path:(Some r) s) +(* Useful to detect and expand or pats inside as pats *) +let rec unalias p = match p.pat_desc with +| Tpat_alias (p,_,_) -> unalias p +| _ -> p -let fold_descr fold get_name f = fold (fun descr acc -> f (get_name descr) acc) -let fold_simple fold4 f = fold4 (fun name _path _descr acc -> f name acc) -let fold_values = fold_simple Env.fold_values -let fold_types = fold_simple Env.fold_types -let fold_modules = fold_simple Env.fold_modules -let fold_constructors = fold_descr Env.fold_constructors (fun d -> d.cstr_name) -let fold_labels = fold_descr Env.fold_labels (fun d -> d.lbl_name) -let fold_classs = fold_simple Env.fold_classs -let fold_modtypes = fold_simple Env.fold_modtypes -let fold_cltypes = fold_simple Env.fold_cltypes +let is_var p = match (unalias p).pat_desc with +| Tpat_any|Tpat_var _ -> true +| _ -> false -let report_error env ppf = function - | Unbound_type_variable name -> - (* we don't use "spellcheck" here: the function that raises this - error seems not to be called anywhere, so it's unclear how it - should be handled *) - fprintf ppf "Unbound type parameter %s@." name - | Unbound_type_constructor lid -> - fprintf ppf "Unbound type constructor %a" longident lid; - spellcheck ppf fold_types env lid; - | Unbound_type_constructor_2 p -> - fprintf ppf "The type constructor@ %a@ is not yet completely defined" - path p - | Type_arity_mismatch(lid, expected, provided) -> - fprintf ppf - "@[The type constructor %a@ expects %i argument(s),@ \ - but is here applied to %i argument(s)@]" - longident lid expected provided - | Bound_type_variable name -> - fprintf ppf "Already bound type parameter '%s" name - | Recursive_type -> - fprintf ppf "This type is recursive" - | Unbound_row_variable lid -> - (* we don't use "spellcheck" here: this error is not raised - anywhere so it's unclear how it should be handled *) - fprintf ppf "Unbound row variable in #%a" longident lid - | Type_mismatch trace -> - Printtyp.report_unification_error ppf Env.empty trace - (function ppf -> - fprintf ppf "This type") - (function ppf -> - fprintf ppf "should be an instance of type") - | Alias_type_mismatch trace -> - Printtyp.report_unification_error ppf Env.empty trace - (function ppf -> - fprintf ppf "This alias is bound to type") - (function ppf -> - fprintf ppf "but is used as an instance of type") - | Present_has_conjunction l -> - fprintf ppf "The present constructor %s has a conjunctive type" l - | Present_has_no_type l -> - fprintf ppf "The present constructor %s has no type" l - | Constructor_mismatch (ty, ty') -> - wrap_printing_env env (fun () -> - Printtyp.reset_and_mark_loops_list [ty; ty']; - fprintf ppf "@[%s %a@ %s@ %a@]" - "This variant type contains a constructor" - Printtyp.type_expr ty - "which should be" - Printtyp.type_expr ty') - | Not_a_variant ty -> - Printtyp.reset_and_mark_loops ty; - fprintf ppf - "@[The type %a@ does not expand to a polymorphic variant type@]" - Printtyp.type_expr ty; - begin match ty.desc with - | Tvar (Some s) -> - (* PR#7012: help the user that wrote 'Foo instead of `Foo *) - Misc.did_you_mean ppf (fun () -> ["`" ^ s]) - | _ -> () - end - | Variant_tags (lab1, lab2) -> - fprintf ppf - "@[Variant tags `%s@ and `%s have the same hash value.@ %s@]" - lab1 lab2 "Change one of them." - | Invalid_variable_name name -> - fprintf ppf "The type variable name %s is not allowed in programs" name - | Cannot_quantify (name, v) -> - fprintf ppf - "@[The universal type variable '%s cannot be generalized:@ %s.@]" - name - (if Btype.is_Tvar v then "it escapes its scope" else - if Btype.is_Tunivar v then "it is already bound to another variable" - else "it is not a variable") - | Multiple_constraints_on_type s -> - fprintf ppf "Multiple constraints for type %a" longident s - | Method_mismatch (l, ty, ty') -> - wrap_printing_env env (fun () -> - Printtyp.reset_and_mark_loops_list [ty; ty']; - fprintf ppf "@[Method '%s' has type %a,@ which should be %a@]" - l Printtyp.type_expr ty Printtyp.type_expr ty') - | Unbound_value lid -> - fprintf ppf "Unbound value %a" longident lid; - spellcheck ppf fold_values env lid; - | Unbound_module lid -> - fprintf ppf "Unbound module %a" longident lid; - spellcheck ppf fold_modules env lid; - | Unbound_constructor lid -> - fprintf ppf "Unbound constructor %a" longident lid; - spellcheck ppf fold_constructors env lid; - | Unbound_label lid -> - fprintf ppf "Unbound record field %a" longident lid; - spellcheck ppf fold_labels env lid; - | Unbound_class lid -> - fprintf ppf "Unbound class %a" longident lid; - spellcheck ppf fold_classs env lid; - | Unbound_modtype lid -> - fprintf ppf "Unbound module type %a" longident lid; - spellcheck ppf fold_modtypes env lid; - | Unbound_cltype lid -> - fprintf ppf "Unbound class type %a" longident lid; - spellcheck ppf fold_cltypes env lid; - | Ill_typed_functor_application lid -> - fprintf ppf "Ill-typed functor application %a" longident lid - | Illegal_reference_to_recursive_module -> - fprintf ppf "Illegal recursive module reference" - | Access_functor_as_structure lid -> - fprintf ppf "The module %a is a functor, not a structure" longident lid - | Apply_structure_as_functor lid -> - fprintf ppf "The module %a is a structure, not a functor" longident lid - | Cannot_scrape_alias(lid, p) -> - fprintf ppf - "The module %a is an alias for module %a, which is missing" - longident lid path p - | Opened_object nm -> - fprintf ppf - "Illegal open object type%a" - (fun ppf -> function - Some p -> fprintf ppf "@ %a" path p - | None -> fprintf ppf "") nm - | Not_an_object ty -> - Printtyp.reset_and_mark_loops ty; - fprintf ppf "@[The type %a@ is not an object type@]" - Printtyp.type_expr ty +let is_var_column rs = + List.for_all + (fun r -> match r.active with + | p::_ -> is_var p + | [] -> assert false) + rs -let () = - Location.register_error_of_exn - (function - | Error (loc, env, err) -> - Some (Location.error_of_printer loc (report_error env) err) - | Error_forward err -> - Some err - | _ -> - None - ) +(* Standard or-args for left-to-right matching *) +let rec or_args p = match p.pat_desc with +| Tpat_or (p1,p2,_) -> p1,p2 +| Tpat_alias (p,_,_) -> or_args p +| _ -> assert false -end -module Typedecl : sig -#1 "typedecl.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +(* Just remove current column *) +let remove r = match r.active with +| _::rem -> {r with active=rem} +| [] -> assert false -(* Typing of type definitions and primitive definitions *) +let remove_column rs = List.map remove rs -open Types -open Format +(* Current column has been processed *) +let push_no_or r = match r.active with +| p::rem -> { r with no_ors = p::r.no_ors ; active=rem} +| [] -> assert false -val transl_type_decl: - Env.t -> Asttypes.rec_flag -> Parsetree.type_declaration list -> - Typedtree.type_declaration list * Env.t +let push_or r = match r.active with +| p::rem -> { r with ors = p::r.ors ; active=rem} +| [] -> assert false -val transl_exception: - Env.t -> - Parsetree.extension_constructor -> Typedtree.extension_constructor * Env.t +let push_or_column rs = List.map push_or rs +and push_no_or_column rs = List.map push_no_or rs -val transl_type_extension: - bool -> Env.t -> Location.t -> Parsetree.type_extension -> - Typedtree.type_extension * Env.t +(* Those are adaptations of the previous homonymous functions that + work on the current column, instead of the first column +*) -val transl_value_decl: - Env.t -> Location.t -> - Parsetree.value_description -> Typedtree.value_description * Env.t +let discr_pat q rs = + discr_pat q (List.map (fun r -> r.active) rs) -val transl_with_constraint: - Env.t -> Ident.t -> Path.t option -> Types.type_declaration -> - Parsetree.type_declaration -> Typedtree.type_declaration +let filter_one q rs = + let rec filter_rec rs = match rs with + | [] -> [] + | r::rem -> + match r.active with + | [] -> assert false + | {pat_desc = Tpat_alias(p,_,_)}::ps -> + filter_rec ({r with active = p::ps}::rem) + | {pat_desc = Tpat_or(p1,p2,_)}::ps -> + filter_rec + ({r with active = p1::ps}:: + {r with active = p2::ps}:: + rem) + | p::ps -> + if simple_match q p then + {r with active=simple_match_args q p @ ps} :: filter_rec rem + else + filter_rec rem in + filter_rec rs -val abstract_type_decl: int -> type_declaration -val approx_type_decl: - Parsetree.type_declaration list -> - (Ident.t * type_declaration) list -val check_recmod_typedecl: - Env.t -> Location.t -> Ident.t list -> Path.t -> type_declaration -> unit -val check_coherence: - Env.t -> Location.t -> Ident.t -> type_declaration -> unit -(* for fixed types *) -val is_fixed_type : Parsetree.type_declaration -> bool +(* Back to normal matrices *) +let make_vector r = List.rev r.no_ors -(* for typeclass.ml *) -val compute_variance_decls: - Env.t -> - (Ident.t * Types.type_declaration * Types.type_declaration * - Types.class_declaration * Types.class_type_declaration * - 'a Typedtree.class_infos) list -> - (Types.type_declaration * Types.type_declaration * - Types.class_declaration * Types.class_type_declaration) list +let make_matrix rs = List.map make_vector rs -(* for typeopt.ml *) -val get_unboxed_type_representation: Env.t -> type_expr -> type_expr option +(* Standard union on answers *) +let union_res r1 r2 = match r1, r2 with +| (Unused,_) +| (_, Unused) -> Unused +| Used,_ -> r2 +| _, Used -> r1 +| Upartial u1, Upartial u2 -> Upartial (u1@u2) -type native_repr_kind = Unboxed | Untagged +(* propose or pats for expansion *) +let extract_elements qs = + let rec do_rec seen = function + | [] -> [] + | q::rem -> + {no_ors= List.rev_append seen rem @ qs.no_ors ; + ors=[] ; + active = [q]}:: + do_rec (q::seen) rem in + do_rec [] qs.ors -type error = - Repeated_parameter - | Duplicate_constructor of string - | Too_many_constructors - | Duplicate_label of string - | Recursive_abbrev of string - | Cycle_in_def of string * type_expr - | Definition_mismatch of type_expr * Includecore.type_mismatch list - | Constraint_failed of type_expr * type_expr - | Inconsistent_constraint of Env.t * (type_expr * type_expr) list - | Type_clash of Env.t * (type_expr * type_expr) list - | Parameters_differ of Path.t * type_expr * type_expr - | Null_arity_external - | Missing_native_external - | Unbound_type_var of type_expr * type_declaration - | Cannot_extend_private_type of Path.t - | Not_extensible_type of Path.t - | Extension_mismatch of Path.t * Includecore.type_mismatch list - | Rebind_wrong_type of Longident.t * Env.t * (type_expr * type_expr) list - | Rebind_mismatch of Longident.t * Path.t * Path.t - | Rebind_private of Longident.t - | Bad_variance of int * (bool*bool*bool) * (bool*bool*bool) - | Unavailable_type_constructor of Path.t - | Bad_fixed_type of string - | Unbound_type_var_ext of type_expr * extension_constructor - | Varying_anonymous - | Val_in_structure - | Multiple_native_repr_attributes - | Cannot_unbox_or_untag_type of native_repr_kind - | Deep_unbox_or_untag_attribute of native_repr_kind - | Bad_immediate_attribute - | Bad_unboxed_attribute of string - | Wrong_unboxed_type_float - | Boxed_and_unboxed - | Nonrec_gadt +(* idem for matrices *) +let transpose rs = match rs with +| [] -> assert false +| r::rem -> + let i = List.map (fun x -> [x]) r in + List.fold_left + (List.map2 (fun r x -> x::r)) + i rem + +let extract_columns pss qs = match pss with +| [] -> List.map (fun _ -> []) qs.ors +| _ -> + let rows = List.map extract_elements pss in + transpose rows + +(* Core function + The idea is to first look for or patterns (recursive case), then + check or-patterns argument usefulness (terminal case) +*) +let rec simplified_first_usefulness_col = function + | [] -> [] + | row :: rows -> + match row.active with + | [] -> assert false (* the rows are non-empty! *) + | p :: _ -> simplify_head_pat p (simplified_first_usefulness_col rows) + +let rec every_satisfiables pss qs = match qs.active with +| [] -> + (* qs is now partitionned, check usefulness *) + begin match qs.ors with + | [] -> (* no or-patterns *) + if satisfiable (make_matrix pss) (make_vector qs) then + Used + else + Unused + | _ -> (* n or-patterns -> 2n expansions *) + List.fold_right2 + (fun pss qs r -> match r with + | Unused -> Unused + | _ -> + match qs.active with + | [q] -> + let q1,q2 = or_args q in + let r_loc = every_both pss qs q1 q2 in + union_res r r_loc + | _ -> assert false) + (extract_columns pss qs) (extract_elements qs) + Used + end +| q::rem -> + let uq = unalias q in + begin match uq.pat_desc with + | Tpat_any | Tpat_var _ -> + if is_var_column pss then +(* forget about ``all-variable'' columns now *) + every_satisfiables (remove_column pss) (remove qs) + else +(* otherwise this is direct food for satisfiable *) + every_satisfiables (push_no_or_column pss) (push_no_or qs) + | Tpat_or (q1,q2,_) -> + if + q1.pat_loc.Location.loc_ghost && + q2.pat_loc.Location.loc_ghost + then +(* syntactically generated or-pats should not be expanded *) + every_satisfiables (push_no_or_column pss) (push_no_or qs) + else +(* this is a real or-pattern *) + every_satisfiables (push_or_column pss) (push_or qs) + | Tpat_variant (l,_,r) when is_absent l r -> (* Ah Jacques... *) + Unused + | _ -> +(* standard case, filter matrix *) + (* The handling of incoherent matrices is kept in line with + [satisfiable] *) + if not (all_coherent (uq :: simplified_first_usefulness_col pss)) then + Unused + else begin + let q0 = discr_pat q pss in + every_satisfiables + (filter_one q0 pss) + {qs with active=simple_match_args q0 q @ rem} + end + end + +(* + This function ``every_both'' performs the usefulness check + of or-pat q1|q2. + The trick is to call every_satisfied twice with + current active columns restricted to q1 and q2, + That way, + - others orpats in qs.ors will not get expanded. + - all matching work performed on qs.no_ors is not performed again. + *) +and every_both pss qs q1 q2 = + let qs1 = {qs with active=[q1]} + and qs2 = {qs with active=[q2]} in + let r1 = every_satisfiables pss qs1 + and r2 = every_satisfiables (if compat q1 q2 then qs1::pss else pss) qs2 in + match r1 with + | Unused -> + begin match r2 with + | Unused -> Unused + | Used -> Upartial [q1] + | Upartial u2 -> Upartial (q1::u2) + end + | Used -> + begin match r2 with + | Unused -> Upartial [q2] + | _ -> r2 + end + | Upartial u1 -> + begin match r2 with + | Unused -> Upartial (u1@[q2]) + | Used -> r1 + | Upartial u2 -> Upartial (u1 @ u2) + end -exception Error of Location.t * error -val report_error: formatter -> error -> unit -end = struct -#1 "typedecl.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy and Jerome Vouillon, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) -(**** Typing of type definitions ****) +(* le_pat p q means, forall V, V matches q implies V matches p *) +let rec le_pat p q = + match (p.pat_desc, q.pat_desc) with + | (Tpat_var _|Tpat_any),_ -> true + | Tpat_alias(p,_,_), _ -> le_pat p q + | _, Tpat_alias(q,_,_) -> le_pat p q + | Tpat_constant(c1), Tpat_constant(c2) -> const_compare c1 c2 = 0 + | Tpat_construct(_,c1,ps), Tpat_construct(_,c2,qs) -> + Types.equal_tag c1.cstr_tag c2.cstr_tag && le_pats ps qs + | Tpat_variant(l1,Some p1,_), Tpat_variant(l2,Some p2,_) -> + (l1 = l2 && le_pat p1 p2) + | Tpat_variant(l1,None,_r1), Tpat_variant(l2,None,_) -> + l1 = l2 + | Tpat_variant(_,_,_), Tpat_variant(_,_,_) -> false + | Tpat_tuple(ps), Tpat_tuple(qs) -> le_pats ps qs + | Tpat_lazy p, Tpat_lazy q -> le_pat p q + | Tpat_record (l1,_), Tpat_record (l2,_) -> + let ps,qs = records_args l1 l2 in + le_pats ps qs + | Tpat_array(ps), Tpat_array(qs) -> + List.length ps = List.length qs && le_pats ps qs +(* In all other cases, enumeration is performed *) + | _,_ -> not (satisfiable [[p]] [q]) -open Misc -open Asttypes -open Parsetree -open Primitive -open Types -open Typetexp +and le_pats ps qs = + match ps,qs with + p::ps, q::qs -> le_pat p q && le_pats ps qs + | _, _ -> true -type native_repr_kind = Unboxed | Untagged +let get_mins le ps = + let rec select_rec r = function + [] -> r + | p::ps -> + if List.exists (fun p0 -> le p0 p) ps + then select_rec r ps + else select_rec (p::r) ps in + select_rec [] (select_rec [] ps) -type error = - Repeated_parameter - | Duplicate_constructor of string - | Too_many_constructors - | Duplicate_label of string - | Recursive_abbrev of string - | Cycle_in_def of string * type_expr - | Definition_mismatch of type_expr * Includecore.type_mismatch list - | Constraint_failed of type_expr * type_expr - | Inconsistent_constraint of Env.t * (type_expr * type_expr) list - | Type_clash of Env.t * (type_expr * type_expr) list - | Parameters_differ of Path.t * type_expr * type_expr - | Null_arity_external - | Missing_native_external - | Unbound_type_var of type_expr * type_declaration - | Cannot_extend_private_type of Path.t - | Not_extensible_type of Path.t - | Extension_mismatch of Path.t * Includecore.type_mismatch list - | Rebind_wrong_type of Longident.t * Env.t * (type_expr * type_expr) list - | Rebind_mismatch of Longident.t * Path.t * Path.t - | Rebind_private of Longident.t - | Bad_variance of int * (bool * bool * bool) * (bool * bool * bool) - | Unavailable_type_constructor of Path.t - | Bad_fixed_type of string - | Unbound_type_var_ext of type_expr * extension_constructor - | Varying_anonymous - | Val_in_structure - | Multiple_native_repr_attributes - | Cannot_unbox_or_untag_type of native_repr_kind - | Deep_unbox_or_untag_attribute of native_repr_kind - | Bad_immediate_attribute - | Bad_unboxed_attribute of string - | Wrong_unboxed_type_float - | Boxed_and_unboxed - | Nonrec_gadt +(* + lub p q is a pattern that matches all values matched by p and q + may raise Empty, when p and q are not compatible +*) -open Typedtree +let rec lub p q = match p.pat_desc,q.pat_desc with +| Tpat_alias (p,_,_),_ -> lub p q +| _,Tpat_alias (q,_,_) -> lub p q +| (Tpat_any|Tpat_var _),_ -> q +| _,(Tpat_any|Tpat_var _) -> p +| Tpat_or (p1,p2,_),_ -> orlub p1 p2 q +| _,Tpat_or (q1,q2,_) -> orlub q1 q2 p (* Thanks god, lub is commutative *) +| Tpat_constant c1, Tpat_constant c2 when const_compare c1 c2 = 0 -> p +| Tpat_tuple ps, Tpat_tuple qs -> + let rs = lubs ps qs in + make_pat (Tpat_tuple rs) p.pat_type p.pat_env +| Tpat_lazy p, Tpat_lazy q -> + let r = lub p q in + make_pat (Tpat_lazy r) p.pat_type p.pat_env +| Tpat_construct (lid, c1,ps1), Tpat_construct (_,c2,ps2) + when Types.equal_tag c1.cstr_tag c2.cstr_tag -> + let rs = lubs ps1 ps2 in + make_pat (Tpat_construct (lid, c1,rs)) + p.pat_type p.pat_env +| Tpat_variant(l1,Some p1,row), Tpat_variant(l2,Some p2,_) + when l1=l2 -> + let r=lub p1 p2 in + make_pat (Tpat_variant (l1,Some r,row)) p.pat_type p.pat_env +| Tpat_variant (l1,None,_row), Tpat_variant(l2,None,_) + when l1 = l2 -> p +| Tpat_record (l1,closed),Tpat_record (l2,_) -> + let rs = record_lubs l1 l2 in + make_pat (Tpat_record (rs, closed)) p.pat_type p.pat_env +| Tpat_array ps, Tpat_array qs + when List.length ps = List.length qs -> + let rs = lubs ps qs in + make_pat (Tpat_array rs) p.pat_type p.pat_env +| _,_ -> + raise Empty -exception Error of Location.t * error +and orlub p1 p2 q = + try + let r1 = lub p1 q in + try + {q with pat_desc=(Tpat_or (r1,lub p2 q,None))} + with + | Empty -> r1 +with +| Empty -> lub p2 q -(* Note: do not factor the branches in the following pattern-matching: - the records must be constants for the compiler to do sharing on them. -*) -let get_unboxed_from_attributes sdecl = - - if !Clflags.bs_only then unboxed_false_default_false - else +and record_lubs l1 l2 = + let rec lub_rec l1 l2 = match l1,l2 with + | [],_ -> l2 + | _,[] -> l1 + | (lid1, lbl1,p1)::rem1, (lid2, lbl2,p2)::rem2 -> + if lbl1.lbl_pos < lbl2.lbl_pos then + (lid1, lbl1,p1)::lub_rec rem1 l2 + else if lbl2.lbl_pos < lbl1.lbl_pos then + (lid2, lbl2,p2)::lub_rec l1 rem2 + else + (lid1, lbl1,lub p1 p2)::lub_rec rem1 rem2 in + lub_rec l1 l2 - let unboxed = Builtin_attributes.has_unboxed sdecl.ptype_attributes in - let boxed = Builtin_attributes.has_boxed sdecl.ptype_attributes in - match boxed, unboxed, !Clflags.unboxed_types with - | true, true, _ -> raise (Error(sdecl.ptype_loc, Boxed_and_unboxed)) - | true, false, _ -> unboxed_false_default_false - | false, true, _ -> unboxed_true_default_false - | false, false, false -> unboxed_false_default_true - | false, false, true -> unboxed_true_default_true +and lubs ps qs = match ps,qs with +| p::ps, q::qs -> lub p q :: lubs ps qs +| _,_ -> [] -(* Enter all declared types in the environment as abstract types *) -let enter_type rec_flag env sdecl id = - let needed = - match rec_flag with - | Asttypes.Nonrecursive -> - begin match sdecl.ptype_kind with - | Ptype_variant scds -> - List.iter (fun cd -> - if cd.pcd_res <> None then raise (Error(cd.pcd_loc, Nonrec_gadt))) - scds - | _ -> () - end; - Btype.is_row_name (Ident.name id) - | Asttypes.Recursive -> true - in - if not needed then env else - let decl = - { type_params = - List.map (fun _ -> Btype.newgenvar ()) sdecl.ptype_params; - type_arity = List.length sdecl.ptype_params; - type_kind = Type_abstract; - type_private = sdecl.ptype_private; - type_manifest = - begin match sdecl.ptype_manifest with None -> None - | Some _ -> Some(Ctype.newvar ()) end; - type_variance = List.map (fun _ -> Variance.full) sdecl.ptype_params; - type_newtype_level = None; - type_loc = sdecl.ptype_loc; - type_attributes = sdecl.ptype_attributes; - type_immediate = false; - type_unboxed = unboxed_false_default_false; - } - in - Env.add_type ~check:true id decl env +(******************************) +(* Exported variant closing *) +(******************************) -let update_type temp_env env id loc = - let path = Path.Pident id in - let decl = Env.find_type path temp_env in - match decl.type_manifest with None -> () - | Some ty -> - let params = List.map (fun _ -> Ctype.newvar ()) decl.type_params in - try Ctype.unify env (Ctype.newconstr path params) ty - with Ctype.Unify trace -> - raise (Error(loc, Type_clash (env, trace))) +(* Apply pressure to variants *) -(* We use the Ctype.expand_head_opt version of expand_head to get access - to the manifest type of private abbreviations. *) -let rec get_unboxed_type_representation env ty fuel = - if fuel < 0 then None else - let ty = Ctype.repr (Ctype.expand_head_opt env ty) in - match ty.desc with - | Tconstr (p, args, _) -> - begin match Env.find_type p env with - | exception Not_found -> Some ty - | {type_unboxed = {unboxed = false}} -> Some ty - | {type_params; type_kind = - Type_record ([{ld_type = ty2; _}], _) - | Type_variant [{cd_args = Cstr_tuple [ty2]; _}] - | Type_variant [{cd_args = Cstr_record [{ld_type = ty2; _}]; _}]} +let pressure_variants tdefs patl = + let pss = List.map (fun p -> [p;omega]) patl in + ignore (pressure_variants (Some tdefs) pss) - -> get_unboxed_type_representation env - (Ctype.apply env type_params ty2 args) (fuel - 1) - | {type_kind=Type_abstract} -> None - (* This case can occur when checking a recursive unboxed type - declaration. *) - | _ -> assert false (* only the above can be unboxed *) - end - | _ -> Some ty +(*****************************) +(* Utilities for diagnostics *) +(*****************************) -let get_unboxed_type_representation env ty = - (* Do not give too much fuel: PR#7424 *) - get_unboxed_type_representation env ty 100 -;; +(* + Build up a working pattern matrix by forgetting + about guarded patterns +*) -(* Determine if a type's values are represented by floats at run-time. *) -let is_float env ty = - match get_unboxed_type_representation env ty with - Some {desc = Tconstr(p, _, _); _} -> Path.same p Predef.path_float - | _ -> false +let rec initial_matrix = function + [] -> [] + | {c_guard=Some _} :: rem -> initial_matrix rem + | {c_guard=None; c_lhs=p} :: rem -> [p] :: initial_matrix rem -(* Determine if a type definition defines a fixed type. (PW) *) -let is_fixed_type sd = - let rec has_row_var sty = - match sty.ptyp_desc with - Ptyp_alias (sty, _) -> has_row_var sty - | Ptyp_class _ - | Ptyp_object (_, Open) - | Ptyp_variant (_, Open, _) - | Ptyp_variant (_, Closed, Some _) -> true - | _ -> false - in - match sd.ptype_manifest with - None -> false - | Some sty -> - sd.ptype_kind = Ptype_abstract && - sd.ptype_private = Private && - has_row_var sty +(******************************************) +(* Look for a row that matches some value *) +(******************************************) -(* Set the row variable in a fixed type *) -let set_fixed_row env loc p decl = - let tm = - match decl.type_manifest with - None -> assert false - | Some t -> Ctype.expand_head env t - in - let rv = - match tm.desc with - Tvariant row -> - let row = Btype.row_repr row in - tm.desc <- Tvariant {row with row_fixed = true}; - if Btype.static_row row then Btype.newgenty Tnil - else row.row_more - | Tobject (ty, _) -> - snd (Ctype.flatten_fields ty) - | _ -> - raise (Error (loc, Bad_fixed_type "is not an object or variant")) - in - if not (Btype.is_Tvar rv) then - raise (Error (loc, Bad_fixed_type "has no row variable")); - rv.desc <- Tconstr (p, decl.type_params, ref Mnil) +(* + Useful for seeing if the example of + non-matched value can indeed be matched + (by a guarded clause) +*) -(* Translate one type declaration *) -module StringSet = - Set.Make(struct - type t = string - let compare (x:t) y = compare x y - end) -let make_params env params = - let make_param (sty, v) = - try - (transl_type_param env sty, v) - with Already_bound -> - raise(Error(sty.ptyp_loc, Repeated_parameter)) - in - List.map make_param params +exception NoGuard -let transl_labels env closed lbls = - assert (lbls <> []); - let all_labels = ref StringSet.empty in - List.iter - (fun {pld_name = {txt=name; loc}} -> - if StringSet.mem name !all_labels then - raise(Error(loc, Duplicate_label name)); - all_labels := StringSet.add name !all_labels) - lbls; - let mk {pld_name=name;pld_mutable=mut;pld_type=arg;pld_loc=loc; - pld_attributes=attrs} = - Builtin_attributes.warning_scope attrs - (fun () -> - let arg = Ast_helper.Typ.force_poly arg in - let cty = transl_simple_type env closed arg in - {ld_id = Ident.create name.txt; ld_name = name; ld_mutable = mut; - ld_type = cty; ld_loc = loc; ld_attributes = attrs} - ) - in - let lbls = List.map mk lbls in - let lbls' = - List.map - (fun ld -> - let ty = ld.ld_type.ctyp_type in - let ty = match ty.desc with Tpoly(t,[]) -> t | _ -> ty in - {Types.ld_id = ld.ld_id; - ld_mutable = ld.ld_mutable; - ld_type = ty; - ld_loc = ld.ld_loc; - ld_attributes = ld.ld_attributes - } - ) - lbls in - lbls, lbls' +let rec initial_all no_guard = function + | [] -> + if no_guard then + raise NoGuard + else + [] + | {c_lhs=pat; c_guard; _} :: rem -> + ([pat], pat.pat_loc) :: initial_all (no_guard && c_guard = None) rem -let transl_constructor_arguments env closed = function - | Pcstr_tuple l -> - let l = List.map (transl_simple_type env closed) l in - Types.Cstr_tuple (List.map (fun t -> t.ctyp_type) l), - Cstr_tuple l - | Pcstr_record l -> - let lbls, lbls' = transl_labels env closed l in - Types.Cstr_record lbls', - Cstr_record lbls -let make_constructor env type_path type_params sargs sret_type = - match sret_type with - | None -> - let args, targs = - transl_constructor_arguments env true sargs - in - targs, None, args, None, type_params - | Some sret_type -> - (* if it's a generalized constructor we must first narrow and - then widen so as to not introduce any new constraints *) - let z = narrow () in - reset_type_variables (); - let args, targs = - transl_constructor_arguments env false sargs - in - let tret_type = transl_simple_type env false sret_type in - let ret_type = tret_type.ctyp_type in - let params = - match (Ctype.repr ret_type).desc with - | Tconstr (p', params, _) when Path.same type_path p' -> - params - | _ -> - raise (Error (sret_type.ptyp_loc, Constraint_failed - (ret_type, Ctype.newconstr type_path type_params))) - in - widen z; - targs, Some tret_type, args, Some ret_type, params +let rec do_filter_var = function + | (_::ps,loc)::rem -> (ps,loc)::do_filter_var rem + | _ -> [] -(* Check that the variable [id] is present in the [univ] list. *) -let check_type_var loc univ id = - let f t = (Btype.repr t).id = id in - if not (List.exists f univ) then raise (Error (loc, Wrong_unboxed_type_float)) +let do_filter_one q pss = + let rec filter_rec = function + | ({pat_desc = Tpat_alias(p,_,_)}::ps,loc)::pss -> + filter_rec ((p::ps,loc)::pss) + | ({pat_desc = Tpat_or(p1,p2,_)}::ps,loc)::pss -> + filter_rec ((p1::ps,loc)::(p2::ps,loc)::pss) + | (p::ps,loc)::pss -> + if simple_match q p + then (simple_match_args q p @ ps, loc) :: filter_rec pss + else filter_rec pss + | _ -> [] in + filter_rec pss -(* Check that all the variables found in [ty] are in [univ]. - Because [ty] is the argument to an abstract type, the representation - of that abstract type could be any subexpression of [ty], in particular - any type variable present in [ty]. -*) -let rec check_unboxed_abstract_arg loc univ ty = - match ty.desc with - | Tvar _ -> check_type_var loc univ ty.id - | Tarrow (_, t1, t2, _) - | Tfield (_, _, t1, t2) -> - check_unboxed_abstract_arg loc univ t1; - check_unboxed_abstract_arg loc univ t2 - | Ttuple args - | Tconstr (_, args, _) - | Tpackage (_, _, args) -> - List.iter (check_unboxed_abstract_arg loc univ) args - | Tobject (fields, r) -> - check_unboxed_abstract_arg loc univ fields; - begin match !r with - | None -> () - | Some (_, args) -> List.iter (check_unboxed_abstract_arg loc univ) args - end - | Tnil - | Tunivar _ -> () - | Tlink e -> check_unboxed_abstract_arg loc univ e - | Tsubst _ -> assert false - | Tvariant { row_fields; row_more; row_name } -> - List.iter (check_unboxed_abstract_row_field loc univ) row_fields; - check_unboxed_abstract_arg loc univ row_more; - begin match row_name with - | None -> () - | Some (_, args) -> List.iter (check_unboxed_abstract_arg loc univ) args +let rec do_match pss qs = match qs with +| [] -> + begin match pss with + | ([],loc)::_ -> Some loc + | _ -> None end - | Tpoly (t, _) -> check_unboxed_abstract_arg loc univ t +| q::qs -> match q with + | {pat_desc = Tpat_or (q1,q2,_)} -> + begin match do_match pss (q1::qs) with + | None -> do_match pss (q2::qs) + | r -> r + end + | {pat_desc = Tpat_any} -> + do_match (do_filter_var pss) qs + | _ -> + let q0 = normalize_pat q in + (* [pss] will (or won't) match [q0 :: qs] regardless of the coherence of + its first column. *) + do_match (do_filter_one q0 pss) (simple_match_args q0 q @ qs) + + +let check_partial_all v casel = + try + let pss = initial_all true casel in + do_match pss [v] + with + | NoGuard -> None -and check_unboxed_abstract_row_field loc univ (_, field) = - match field with - | Rpresent (Some ty) -> check_unboxed_abstract_arg loc univ ty - | Reither (_, args, _, r) -> - List.iter (check_unboxed_abstract_arg loc univ) args; - begin match !r with - | None -> () - | Some f -> check_unboxed_abstract_row_field loc univ ("", f) - end - | Rabsent - | Rpresent None -> () +(************************) +(* Exhaustiveness check *) +(************************) -(* Check that the argument to a GADT constructor is compatible with unboxing - the type, given the universal parameters of the type. *) -let rec check_unboxed_gadt_arg loc univ env ty = - match get_unboxed_type_representation env ty with - | Some {desc = Tvar _; id} -> check_type_var loc univ id - | Some {desc = Tarrow _ | Ttuple _ | Tpackage _ | Tobject _ | Tnil - | Tvariant _; _} -> - () - (* A comment in [Translcore.transl_exp0] claims the above cannot be - represented by floats. *) - | Some {desc = Tconstr (p, args, _); _} -> - let tydecl = Env.find_type p env in - assert (not tydecl.type_unboxed.unboxed); - if tydecl.type_kind = Type_abstract then - List.iter (check_unboxed_abstract_arg loc univ) args - | Some {desc = Tfield _ | Tlink _ | Tsubst _; _} -> assert false - | Some {desc = Tunivar _; _} -> () - | Some {desc = Tpoly (t2, _); _} -> check_unboxed_gadt_arg loc univ env t2 - | None -> () - (* This case is tricky: the argument is another (or the same) type - in the same recursive definition. In this case we don't have to - check because we will also check that other type for correctness. *) +(* conversion from Typedtree.pattern to Parsetree.pattern list *) +module Conv = struct + open Parsetree + let mkpat desc = Ast_helper.Pat.mk desc -let transl_declaration env sdecl id = - (* Bind type parameters *) - reset_type_variables(); - Ctype.begin_def (); - let tparams = make_params env sdecl.ptype_params in - let params = List.map (fun (cty, _) -> cty.ctyp_type) tparams in - let cstrs = List.map - (fun (sty, sty', loc) -> - transl_simple_type env false sty, - transl_simple_type env false sty', loc) - sdecl.ptype_cstrs - in - let raw_status = get_unboxed_from_attributes sdecl in - if raw_status.unboxed && not raw_status.default then begin - match sdecl.ptype_kind with - | Ptype_abstract -> - raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute - "it is abstract")) - | Ptype_variant [{pcd_args = Pcstr_tuple []; _}] -> - raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute - "its constructor has no argument")) - | Ptype_variant [{pcd_args = Pcstr_tuple [_]; _}] -> () - | Ptype_variant [{pcd_args = Pcstr_tuple _; _}] -> - raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute - "its constructor has more than one argument")) - | Ptype_variant [{pcd_args = Pcstr_record - [{pld_mutable=Immutable; _}]; _}] -> () - | Ptype_variant [{pcd_args = Pcstr_record [{pld_mutable=Mutable; _}]; _}] -> - raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute "it is mutable")) - | Ptype_variant [{pcd_args = Pcstr_record _; _}] -> - raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute - "its constructor has more than one argument")) - | Ptype_variant _ -> - raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute - "it has more than one constructor")) - | Ptype_record [{pld_mutable=Immutable; _}] -> () - | Ptype_record [{pld_mutable=Mutable; _}] -> - raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute - "it is mutable")) - | Ptype_record _ -> - raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute - "it has more than one field")) - | Ptype_open -> - raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute - "extensible variant types cannot be unboxed")) - end; - let unboxed_status = - match sdecl.ptype_kind with - | Ptype_variant [{pcd_args = Pcstr_tuple [_]; _}] - | Ptype_variant [{pcd_args = Pcstr_record - [{pld_mutable = Immutable; _}]; _}] - | Ptype_record [{pld_mutable = Immutable; _}] -> - raw_status - | _ -> (* The type is not unboxable, mark it as boxed *) - unboxed_false_default_false - in - let unbox = unboxed_status.unboxed in - let (tkind, kind) = - match sdecl.ptype_kind with - | Ptype_abstract -> Ttype_abstract, Type_abstract - | Ptype_variant scstrs -> - assert (scstrs <> []); - if List.exists (fun cstr -> cstr.pcd_res <> None) scstrs then begin - match cstrs with - [] -> () - | (_,_,loc)::_ -> - Location.prerr_warning loc Warnings.Constraint_on_gadt - end; - let all_constrs = ref StringSet.empty in - List.iter - (fun {pcd_name = {txt = name}} -> - if StringSet.mem name !all_constrs then - raise(Error(sdecl.ptype_loc, Duplicate_constructor name)); - all_constrs := StringSet.add name !all_constrs) - scstrs; - if List.length - (List.filter (fun cd -> cd.pcd_args <> Pcstr_tuple []) scstrs) - > (Config.max_tag + 1) then - raise(Error(sdecl.ptype_loc, Too_many_constructors)); - let make_cstr scstr = - let name = Ident.create scstr.pcd_name.txt in - let targs, tret_type, args, ret_type, cstr_params = - make_constructor env (Path.Pident id) params - scstr.pcd_args scstr.pcd_res - in - if Config.flat_float_array && unbox then begin - (* Cannot unbox a type when the argument can be both float and - non-float because it interferes with the dynamic float array - optimization. This can only happen when the type is a GADT - and the argument is an existential type variable or an - unboxed (or abstract) type constructor applied to some - existential type variable. Of course we also have to rule - out any abstract type constructor applied to anything that - might be an existential type variable. - There is a difficulty with existential variables created - out of thin air (rather than bound by the declaration). - See PR#7511 and GPR#1133 for details. *) - match Datarepr.constructor_existentials args ret_type with - | _, [] -> () - | [argty], _ex -> - check_unboxed_gadt_arg sdecl.ptype_loc cstr_params env argty - | _ -> assert false - end; - let tcstr = - { cd_id = name; - cd_name = scstr.pcd_name; - cd_args = targs; - cd_res = tret_type; - cd_loc = scstr.pcd_loc; - cd_attributes = scstr.pcd_attributes } - in - let cstr = - { Types.cd_id = name; - cd_args = args; - cd_res = ret_type; - cd_loc = scstr.pcd_loc; - cd_attributes = scstr.pcd_attributes } + let name_counter = ref 0 + let fresh name = + let current = !name_counter in + name_counter := !name_counter + 1; + "#$" ^ name ^ string_of_int current + + let conv typed = + let constrs = Hashtbl.create 7 in + let labels = Hashtbl.create 7 in + let rec loop pat = + match pat.pat_desc with + Tpat_or (pa,pb,_) -> + mkpat (Ppat_or (loop pa, loop pb)) + | Tpat_var (_, ({txt="*extension*"} as nm)) -> (* PR#7330 *) + mkpat (Ppat_var nm) + | Tpat_any + | Tpat_var _ -> + mkpat Ppat_any + | Tpat_constant c -> + mkpat (Ppat_constant (Untypeast.constant c)) + | Tpat_alias (p,_,_) -> loop p + | Tpat_tuple lst -> + mkpat (Ppat_tuple (List.map loop lst)) + | Tpat_construct (cstr_lid, cstr, lst) -> + let id = fresh cstr.cstr_name in + let lid = { cstr_lid with txt = Longident.Lident id } in + Hashtbl.add constrs id cstr; + let arg = + match List.map loop lst with + | [] -> None + | [p] -> Some p + | lst -> Some (mkpat (Ppat_tuple lst)) in - tcstr, cstr - in - let make_cstr scstr = - Builtin_attributes.warning_scope scstr.pcd_attributes - (fun () -> make_cstr scstr) - in - let tcstrs, cstrs = List.split (List.map make_cstr scstrs) in - Ttype_variant tcstrs, Type_variant cstrs - | Ptype_record lbls -> - let lbls, lbls' = transl_labels env true lbls in - let rep = - if !Clflags.bs_only then Record_regular else (* ATTENTION: revisit when we support @@unbox*) - if unbox then Record_unboxed false - else if List.for_all (fun l -> is_float env l.Types.ld_type) lbls' - then Record_float - else Record_regular + mkpat (Ppat_construct(lid, arg)) + | Tpat_variant(label,p_opt,_row_desc) -> + let arg = Misc.may_map loop p_opt in + mkpat (Ppat_variant(label, arg)) + | Tpat_record (subpatterns, _closed_flag) -> + let fields = + List.map + (fun (_, lbl, p) -> + let id = fresh lbl.lbl_name in + Hashtbl.add labels id lbl; + (mknoloc (Longident.Lident id), loop p)) + subpatterns in - Ttype_record lbls, Type_record(lbls', rep) - | Ptype_open -> Ttype_open, Type_open - in - let (tman, man) = match sdecl.ptype_manifest with - None -> None, None - | Some sty -> - let no_row = not (is_fixed_type sdecl) in - let cty = transl_simple_type env no_row sty in - Some cty, Some cty.ctyp_type + mkpat (Ppat_record (fields, Open)) + | Tpat_array lst -> + mkpat (Ppat_array (List.map loop lst)) + | Tpat_lazy p -> + mkpat (Ppat_lazy (loop p)) in - let decl = - { type_params = params; - type_arity = List.length params; - type_kind = kind; - type_private = sdecl.ptype_private; - type_manifest = man; - type_variance = List.map (fun _ -> Variance.full) params; - type_newtype_level = None; - type_loc = sdecl.ptype_loc; - type_attributes = sdecl.ptype_attributes; - type_immediate = false; - type_unboxed = unboxed_status; - } in + let ps = loop typed in + (ps, constrs, labels) +end - (* Check constraints *) - List.iter - (fun (cty, cty', loc) -> - let ty = cty.ctyp_type in - let ty' = cty'.ctyp_type in - try Ctype.unify env ty ty' with Ctype.Unify tr -> - raise(Error(loc, Inconsistent_constraint (env, tr)))) - cstrs; - Ctype.end_def (); - (* Add abstract row *) - if is_fixed_type sdecl then begin - let p = - try Env.lookup_type (Longident.Lident(Ident.name id ^ "#row")) env - with Not_found -> assert false in - set_fixed_row env sdecl.ptype_loc p decl - end; - (* Check for cyclic abbreviations *) - begin match decl.type_manifest with None -> () - | Some ty -> - if Ctype.cyclic_abbrev env id ty then - raise(Error(sdecl.ptype_loc, Recursive_abbrev sdecl.ptype_name.txt)); - end; - { - typ_id = id; - typ_name = sdecl.ptype_name; - typ_params = tparams; - typ_type = decl; - typ_cstrs = cstrs; - typ_loc = sdecl.ptype_loc; - typ_manifest = tman; - typ_kind = tkind; - typ_private = sdecl.ptype_private; - typ_attributes = sdecl.ptype_attributes; - } -(* Generalize a type declaration *) +(* Whether the counter-example contains an extension pattern *) +let contains_extension pat = + let r = ref false in + let rec loop = function + {pat_desc=Tpat_var (_, {txt="*extension*"})} -> + r := true + | p -> Typedtree.iter_pattern_desc loop p.pat_desc + in loop pat; !r -let generalize_decl decl = - List.iter Ctype.generalize decl.type_params; - Btype.iter_type_expr_kind Ctype.generalize decl.type_kind; - begin match decl.type_manifest with - | None -> () - | Some ty -> Ctype.generalize ty - end +(* Build an untyped or-pattern from its expected type *) +let ppat_of_type env ty = + match pats_of_type env ty with + [{pat_desc = Tpat_any}] -> + (Conv.mkpat Parsetree.Ppat_any, Hashtbl.create 0, Hashtbl.create 0) + | pats -> + Conv.conv (orify_many pats) -(* Check that all constraints are enforced *) +let do_check_partial ?pred exhaust loc casel pss = match pss with +| [] -> + (* + This can occur + - For empty matches generated by ocamlp4 (no warning) + - when all patterns have guards (then, casel <> []) + (specific warning) + Then match MUST be considered non-exhaustive, + otherwise compilation of PM is broken. + *) + begin match casel with + | [] -> () + | _ -> + if Warnings.is_active Warnings.All_clauses_guarded then + Location.prerr_warning loc Warnings.All_clauses_guarded + end ; + Partial +| ps::_ -> + begin match exhaust None pss (List.length ps) with + | Rnone -> Total + | Rsome [u] -> + let v = + match pred with + | Some pred -> + let (pattern,constrs,labels) = Conv.conv u in + let u' = pred constrs labels pattern in + (* pretty_pat u; + begin match u' with + None -> prerr_endline ": impossible" + | Some _ -> prerr_endline ": possible" + end; *) + u' + | None -> Some u + in + begin match v with + None -> Total + | Some v -> + if Warnings.is_active (Warnings.Partial_match "") then begin + let errmsg = + try + let buf = Buffer.create 16 in + let fmt = formatter_of_buffer buf in + top_pretty fmt v; + begin match check_partial_all v casel with + | None -> () + | Some _ -> + (* This is 'Some loc', where loc is the location of + a possibly matching clause. + Forget about loc, because printing two locations + is a pain in the top-level *) + Buffer.add_string buf + "\n(However, some guarded clause may match this value.)" + end; + if contains_extension v then + Buffer.add_string buf + "\nMatching over values of extensible variant types \ + (the *extension* above)\n\ + must include a wild card pattern in order to be exhaustive." + ; + Buffer.contents buf + with _ -> + "" + in + Location.prerr_warning loc (Warnings.Partial_match errmsg) + end; + Partial + end + | _ -> + fatal_error "Parmatch.check_partial" + end -module TypeSet = Btype.TypeSet -module TypeMap = Btype.TypeMap +(* +let do_check_partial_normal loc casel pss = + do_check_partial exhaust loc casel pss + *) -let rec check_constraints_rec env loc visited ty = - let ty = Ctype.repr ty in - if TypeSet.mem ty !visited then () else begin - visited := TypeSet.add ty !visited; - match ty.desc with - | Tconstr (path, args, _) -> - let args' = List.map (fun _ -> Ctype.newvar ()) args in - let ty' = Ctype.newconstr path args' in - begin try Ctype.enforce_constraints env ty' - with Ctype.Unify _ -> assert false - | Not_found -> raise (Error(loc, Unavailable_type_constructor path)) - end; - if not (Ctype.matches env ty ty') then - raise (Error(loc, Constraint_failed (ty, ty'))); - List.iter (check_constraints_rec env loc visited) args - | Tpoly (ty, tl) -> - let _, ty = Ctype.instance_poly false tl ty in - check_constraints_rec env loc visited ty - | _ -> - Btype.iter_type_expr (check_constraints_rec env loc visited) ty - end +let do_check_partial_gadt pred loc casel pss = + do_check_partial ~pred exhaust_gadt loc casel pss -module SMap = Map.Make(String) -let check_constraints_labels env visited l pl = - let rec get_loc name = function - [] -> assert false - | pld :: tl -> - if name = pld.pld_name.txt then pld.pld_type.ptyp_loc - else get_loc name tl - in - List.iter - (fun {Types.ld_id=name; ld_type=ty} -> - check_constraints_rec env (get_loc (Ident.name name) pl) visited ty) - l -let check_constraints env sdecl (_, decl) = - let visited = ref TypeSet.empty in - begin match decl.type_kind with - | Type_abstract -> () - | Type_variant l -> - let find_pl = function - Ptype_variant pl -> pl - | Ptype_record _ | Ptype_abstract | Ptype_open -> assert false - in - let pl = find_pl sdecl.ptype_kind in - let pl_index = - let foldf acc x = - SMap.add x.pcd_name.txt x acc - in - List.fold_left foldf SMap.empty pl - in - List.iter - (fun {Types.cd_id=name; cd_args; cd_res} -> - let {pcd_args; pcd_res; _} = - try SMap.find (Ident.name name) pl_index - with Not_found -> assert false in - begin match cd_args, pcd_args with - | Cstr_tuple tyl, Pcstr_tuple styl -> - List.iter2 - (fun sty ty -> - check_constraints_rec env sty.ptyp_loc visited ty) - styl tyl - | Cstr_record tyl, Pcstr_record styl -> - check_constraints_labels env visited tyl styl - | _ -> assert false - end; - match pcd_res, cd_res with - | Some sr, Some r -> - check_constraints_rec env sr.ptyp_loc visited r - | _ -> - () ) - l - | Type_record (l, _) -> - let find_pl = function - Ptype_record pl -> pl - | Ptype_variant _ | Ptype_abstract | Ptype_open -> assert false - in - let pl = find_pl sdecl.ptype_kind in - check_constraints_labels env visited l pl - | Type_open -> () - end; - begin match decl.type_manifest with - | None -> () - | Some ty -> - let sty = - match sdecl.ptype_manifest with Some sty -> sty | _ -> assert false - in - check_constraints_rec env sty.ptyp_loc visited ty - end +(*****************) +(* Fragile check *) +(*****************) + +(* Collect all data types in a pattern *) + +let rec add_path path = function + | [] -> [path] + | x::rem as paths -> + if Path.same path x then paths + else x::add_path path rem + +let extendable_path path = + not + (Path.same path Predef.path_bool || + Path.same path Predef.path_list || + Path.same path Predef.path_unit || + Path.same path Predef.path_option) + +let rec collect_paths_from_pat r p = match p.pat_desc with +| Tpat_construct(_, {cstr_tag=(Cstr_constant _|Cstr_block _|Cstr_unboxed)},ps) + -> + let path = get_type_path p.pat_type p.pat_env in + List.fold_left + collect_paths_from_pat + (if extendable_path path then add_path path r else r) + ps +| Tpat_any|Tpat_var _|Tpat_constant _| Tpat_variant (_,None,_) -> r +| Tpat_tuple ps | Tpat_array ps +| Tpat_construct (_, {cstr_tag=Cstr_extension _}, ps)-> + List.fold_left collect_paths_from_pat r ps +| Tpat_record (lps,_) -> + List.fold_left + (fun r (_, _, p) -> collect_paths_from_pat r p) + r lps +| Tpat_variant (_, Some p, _) | Tpat_alias (p,_,_) -> collect_paths_from_pat r p +| Tpat_or (p1,p2,_) -> + collect_paths_from_pat (collect_paths_from_pat r p1) p2 +| Tpat_lazy p + -> + collect_paths_from_pat r p + (* - If both a variant/record definition and a type equation are given, - need to check that the equation refers to a type of the same kind - with the same constructors and labels. + Actual fragile check + 1. Collect data types in the patterns of the match. + 2. One exhaustivity check per datatype, considering that + the type is extended. *) -let check_coherence env loc id decl = - match decl with - { type_kind = (Type_variant _ | Type_record _| Type_open); - type_manifest = Some ty } -> - begin match (Ctype.repr ty).desc with - Tconstr(path, args, _) -> - begin try - let decl' = Env.find_type path env in - let err = - if List.length args <> List.length decl.type_params - then [Includecore.Arity] - else if not (Ctype.equal env false args decl.type_params) - then [Includecore.Constraint] - else - Includecore.type_declarations ~loc ~equality:true env - (Path.last path) - decl' - id - (Subst.type_declaration - (Subst.add_type id path Subst.identity) decl) - in - if err <> [] then - raise(Error(loc, Definition_mismatch (ty, err))) - with Not_found -> - raise(Error(loc, Unavailable_type_constructor path)) - end - | _ -> raise(Error(loc, Definition_mismatch (ty, []))) - end - | _ -> () - -let check_abbrev env sdecl (id, decl) = - check_coherence env sdecl.ptype_loc id decl -(* Check that recursion is well-founded *) +let do_check_fragile_param exhaust loc casel pss = + let exts = + List.fold_left + (fun r c -> collect_paths_from_pat r c.c_lhs) + [] casel in + match exts with + | [] -> () + | _ -> match pss with + | [] -> () + | ps::_ -> + List.iter + (fun ext -> + match exhaust (Some ext) pss (List.length ps) with + | Rnone -> + Location.prerr_warning + loc + (Warnings.Fragile_match (Path.name ext)) + | Rsome _ -> ()) + exts -let check_well_founded env loc path to_check ty = - let visited = ref TypeMap.empty in - let rec check ty0 parents ty = - let ty = Btype.repr ty in - if TypeSet.mem ty parents then begin - (*Format.eprintf "@[%a@]@." Printtyp.raw_type_expr ty;*) - if match ty0.desc with - | Tconstr (p, _, _) -> Path.same p path - | _ -> false - then raise (Error (loc, Recursive_abbrev (Path.name path))) - else raise (Error (loc, Cycle_in_def (Path.name path, ty0))) - end; - let (fini, parents) = - try - let prev = TypeMap.find ty !visited in - if TypeSet.subset parents prev then (true, parents) else - (false, TypeSet.union parents prev) - with Not_found -> - (false, parents) - in - if fini then () else - let rec_ok = - match ty.desc with - Tconstr(p,_,_) -> - !Clflags.recursive_types && Ctype.is_contractive env p - | Tobject _ | Tvariant _ -> true - | _ -> !Clflags.recursive_types - in - let visited' = TypeMap.add ty parents !visited in - let arg_exn = - try - visited := visited'; - let parents = - if rec_ok then TypeSet.empty else TypeSet.add ty parents in - Btype.iter_type_expr (check ty0 parents) ty; - None - with e -> - visited := visited'; Some e - in - match ty.desc with - | Tconstr(p, _, _) when arg_exn <> None || to_check p -> - if to_check p then may raise arg_exn - else Btype.iter_type_expr (check ty0 TypeSet.empty) ty; - begin try - let ty' = Ctype.try_expand_once_opt env ty in - let ty0 = if TypeSet.is_empty parents then ty else ty0 in - check ty0 (TypeSet.add ty parents) ty' - with - Ctype.Cannot_expand -> may raise arg_exn - end - | _ -> may raise arg_exn - in - let snap = Btype.snapshot () in - try Ctype.wrap_trace_gadt_instances env (check ty TypeSet.empty) ty - with Ctype.Unify _ -> - (* Will be detected by check_recursion *) - Btype.backtrack snap +(*let do_check_fragile_normal = do_check_fragile_param exhaust*) +let do_check_fragile_gadt = do_check_fragile_param exhaust_gadt -let check_well_founded_manifest env loc path decl = - if decl.type_manifest = None then () else - let args = List.map (fun _ -> Ctype.newvar()) decl.type_params in - check_well_founded env loc path (Path.same path) (Ctype.newconstr path args) +(********************************) +(* Exported unused clause check *) +(********************************) -let check_well_founded_decl env loc path decl to_check = - let open Btype in - let it = - {type_iterators with - it_type_expr = (fun _ -> check_well_founded env loc path to_check)} in - it.it_type_declaration it (Ctype.instance_declaration decl) +let check_unused pred casel = + if Warnings.is_active Warnings.Unused_match + || List.exists (fun c -> c.c_rhs.exp_desc = Texp_unreachable) casel then + let rec do_rec pref = function + | [] -> () + | {c_lhs=q; c_guard; c_rhs} :: rem -> + let qs = [q] in + begin try + let pss = + get_mins le_pats (List.filter (compats qs) pref) in + (* First look for redundant or partially redundant patterns *) + let r = every_satisfiables (make_rows pss) (make_row qs) in + let refute = (c_rhs.exp_desc = Texp_unreachable) in + (* Do not warn for unused [pat -> .] *) + if r = Unused && refute then () else + let r = + (* Do not refine if there are no other lines *) + let skip = + r = Unused || (not refute && pref = []) || + not(refute || Warnings.is_active Warnings.Unreachable_case) in + if skip then r else + (* Then look for empty patterns *) + let sfs = satisfiables pss qs in + if sfs = [] then Unused else + let sfs = + List.map (function [u] -> u | _ -> assert false) sfs in + let u = orify_many sfs in + (*Format.eprintf "%a@." pretty_val u;*) + let (pattern,constrs,labels) = Conv.conv u in + let pattern = {pattern with Parsetree.ppat_loc = q.pat_loc} in + match pred refute constrs labels pattern with + None when not refute -> + Location.prerr_warning q.pat_loc Warnings.Unreachable_case; + Used + | _ -> r + in + match r with + | Unused -> + Location.prerr_warning + q.pat_loc Warnings.Unused_match + | Upartial ps -> + List.iter + (fun p -> + Location.prerr_warning + p.pat_loc Warnings.Unused_pat) + ps + | Used -> () + with Empty | Not_found | NoGuard -> assert false + end ; -(* Check for ill-defined abbrevs *) + if c_guard <> None then + do_rec pref rem + else + do_rec ([q]::pref) rem in -let check_recursion env loc path decl to_check = - (* to_check is true for potentially mutually recursive paths. - (path, decl) is the type declaration to be checked. *) + do_rec [] casel - if decl.type_params = [] then () else +(*********************************) +(* Exported irrefutability tests *) +(*********************************) - let visited = ref [] in +let irrefutable pat = le_pat pat omega - let rec check_regular cpath args prev_exp ty = - let ty = Ctype.repr ty in - if not (List.memq ty !visited) then begin - visited := ty :: !visited; - match ty.desc with - | Tconstr(path', args', _) -> - if Path.same path path' then begin - if not (Ctype.equal env false args args') then - raise (Error(loc, - Parameters_differ(cpath, ty, Ctype.newconstr path args))) +let inactive ~partial pat = + match partial with + | Partial -> false + | Total -> begin + let rec loop pat = + match pat.pat_desc with + | Tpat_lazy _ | Tpat_array _ -> + false + | Tpat_any | Tpat_var _ | Tpat_variant (_, None, _) -> + true + | Tpat_constant c -> begin + match c with + | Const_string _ -> Config.safe_string + | Const_int _ | Const_char _ | Const_float _ + | Const_int32 _ | Const_int64 _ | Const_nativeint _ -> true end - (* Attempt to expand a type abbreviation if: - 1- [to_check path'] holds - (otherwise the expansion cannot involve [path]); - 2- we haven't expanded this type constructor before - (otherwise we could loop if [path'] is itself - a non-regular abbreviation). *) - else if to_check path' && not (List.mem path' prev_exp) then begin - try - (* Attempt expansion *) - let (params0, body0, _) = Env.find_type_expansion path' env in - let (params, body) = - Ctype.instance_parameterized_type params0 body0 in - begin - try List.iter2 (Ctype.unify env) params args' - with Ctype.Unify _ -> - raise (Error(loc, Constraint_failed - (ty, Ctype.newconstr path' params0))); - end; - check_regular path' args (path' :: prev_exp) body - with Not_found -> () - end; - List.iter (check_regular cpath args prev_exp) args' - | Tpoly (ty, tl) -> - let (_, ty) = Ctype.instance_poly ~keep_names:true false tl ty in - check_regular cpath args prev_exp ty - | _ -> - Btype.iter_type_expr (check_regular cpath args prev_exp) ty - end in - - Misc.may - (fun body -> - let (args, body) = - Ctype.instance_parameterized_type - ~keep_names:true decl.type_params body in - check_regular path args [] body) - decl.type_manifest + | Tpat_tuple ps | Tpat_construct (_, _, ps) -> + List.for_all (fun p -> loop p) ps + | Tpat_alias (p,_,_) | Tpat_variant (_, Some p, _) -> + loop p + | Tpat_record (ldps,_) -> + List.for_all + (fun (_, lbl, p) -> lbl.lbl_mut = Immutable && loop p) + ldps + | Tpat_or (p,q,_) -> + loop p && loop q + in + loop pat + end -let check_abbrev_recursion env id_loc_list to_check tdecl = - let decl = tdecl.typ_type in - let id = tdecl.typ_id in - check_recursion env (List.assoc id id_loc_list) (Path.Pident id) decl to_check -(* Compute variance *) -let get_variance ty visited = - try TypeMap.find ty !visited with Not_found -> Variance.null -let compute_variance env visited vari ty = - let rec compute_variance_rec vari ty = - (* Format.eprintf "%a: %x@." Printtyp.type_expr ty (Obj.magic vari); *) - let ty = Ctype.repr ty in - let vari' = get_variance ty visited in - if Variance.subset vari vari' then () else - let vari = Variance.union vari vari' in - visited := TypeMap.add ty vari !visited; - let compute_same = compute_variance_rec vari in - match ty.desc with - Tarrow (_, ty1, ty2, _) -> - let open Variance in - let v = conjugate vari in - let v1 = - if mem May_pos v || mem May_neg v - then set May_weak true v else v - in - compute_variance_rec v1 ty1; - compute_same ty2 - | Ttuple tl -> - List.iter compute_same tl - | Tconstr (path, tl, _) -> - let open Variance in - if tl = [] then () else begin - try - let decl = Env.find_type path env in - let cvari f = mem f vari in - List.iter2 - (fun ty v -> - let cv f = mem f v in - let strict = - cvari Inv && cv Inj || (cvari Pos || cvari Neg) && cv Inv - in - if strict then compute_variance_rec full ty else - let p1 = inter v vari - and n1 = inter v (conjugate vari) in - let v1 = - union (inter covariant (union p1 (conjugate p1))) - (inter (conjugate covariant) (union n1 (conjugate n1))) - and weak = - cvari May_weak && (cv May_pos || cv May_neg) || - (cvari May_pos || cvari May_neg) && cv May_weak - in - let v2 = set May_weak weak v1 in - compute_variance_rec v2 ty) - tl decl.type_variance - with Not_found -> - List.iter (compute_variance_rec may_inv) tl - end - | Tobject (ty, _) -> - compute_same ty - | Tfield (_, _, ty1, ty2) -> - compute_same ty1; - compute_same ty2 - | Tsubst ty -> - compute_same ty - | Tvariant row -> - let row = Btype.row_repr row in - List.iter - (fun (_,f) -> - match Btype.row_field_repr f with - Rpresent (Some ty) -> - compute_same ty - | Reither (_, tyl, _, _) -> - let open Variance in - let upper = - List.fold_left (fun s f -> set f true s) - null [May_pos; May_neg; May_weak] - in - let v = inter vari upper in - (* cf PR#7269: - if List.length tyl > 1 then upper else inter vari upper *) - List.iter (compute_variance_rec v) tyl - | _ -> ()) - row.row_fields; - compute_same row.row_more - | Tpoly (ty, _) -> - compute_same ty - | Tvar _ | Tnil | Tlink _ | Tunivar _ -> () - | Tpackage (_, _, tyl) -> - let v = - Variance.(if mem Pos vari || mem Neg vari then full else may_inv) - in - List.iter (compute_variance_rec v) tyl - in - compute_variance_rec vari ty -let make p n i = - let open Variance in - set May_pos p (set May_neg n (set May_weak n (set Inj i null))) -let compute_variance_type env check (required, loc) decl tyl = - (* Requirements *) - let required = - List.map (fun (c,n,i) -> if c || n then (c,n,i) else (true,true,i)) - required - in - (* Prepare *) - let params = List.map Btype.repr decl.type_params in - let tvl = ref TypeMap.empty in - (* Compute occurrences in the body *) - let open Variance in - List.iter - (fun (cn,ty) -> - compute_variance env tvl (if cn then full else covariant) ty) - tyl; - if check then begin - (* Check variance of parameters *) - let pos = ref 0 in - List.iter2 - (fun ty (c, n, i) -> - incr pos; - let var = get_variance ty tvl in - let (co,cn) = get_upper var and ij = mem Inj var in - if Btype.is_Tvar ty && (co && not c || cn && not n || not ij && i) - then raise (Error(loc, Bad_variance (!pos, (co,cn,ij), (c,n,i))))) - params required; - (* Check propagation from constrained parameters *) - let args = Btype.newgenty (Ttuple params) in - let fvl = Ctype.free_variables args in - let fvl = List.filter (fun v -> not (List.memq v params)) fvl in - (* If there are no extra variables there is nothing to do *) - if fvl = [] then () else - let tvl2 = ref TypeMap.empty in - List.iter2 - (fun ty (p,n,_) -> - if Btype.is_Tvar ty then () else - let v = - if p then if n then full else covariant else conjugate covariant in - compute_variance env tvl2 v ty) - params required; - let visited = ref TypeSet.empty in - let rec check ty = - let ty = Ctype.repr ty in - if TypeSet.mem ty !visited then () else - let visited' = TypeSet.add ty !visited in - visited := visited'; - let v1 = get_variance ty tvl in - let snap = Btype.snapshot () in - let v2 = - TypeMap.fold - (fun t vt v -> - if Ctype.equal env false [ty] [t] then union vt v else v) - !tvl2 null in - Btype.backtrack snap; - let (c1,n1) = get_upper v1 and (c2,n2,_,i2) = get_lower v2 in - if c1 && not c2 || n1 && not n2 then - if List.memq ty fvl then - let code = if not i2 then -2 else if c2 || n2 then -1 else -3 in - raise (Error (loc, Bad_variance (code, (c1,n1,false), (c2,n2,false)))) - else - Btype.iter_type_expr check ty - in - List.iter (fun (_,ty) -> check ty) tyl; - end; - List.map2 - (fun ty (p, n, i) -> - let v = get_variance ty tvl in - let tr = decl.type_private in - (* Use required variance where relevant *) - let concr = decl.type_kind <> Type_abstract (*|| tr = Type_new*) in - let (p, n) = - if tr = Private || not (Btype.is_Tvar ty) then (p, n) (* set *) - else (false, false) (* only check *) - and i = concr || i && tr = Private in - let v = union v (make p n i) in - let v = - if not concr then v else - if mem Pos v && mem Neg v then full else - if Btype.is_Tvar ty then v else - union v - (if p then if n then full else covariant else conjugate covariant) - in - if decl.type_kind = Type_abstract && tr = Public then v else - set May_weak (mem May_neg v) v) - params required -let add_false = List.map (fun ty -> false, ty) +(*********************************) +(* Exported exhaustiveness check *) +(*********************************) -(* A parameter is constrained if it is either instantiated, - or it is a variable appearing in another parameter *) -let constrained vars ty = - match ty.desc with - | Tvar _ -> List.exists (fun tl -> List.memq ty tl) vars - | _ -> true +(* + Fragile check is performed when required and + on exhaustive matches only. +*) -let for_constr = function - | Types.Cstr_tuple l -> add_false l - | Types.Cstr_record l -> - List.map - (fun {Types.ld_mutable; ld_type} -> (ld_mutable = Mutable, ld_type)) - l +let check_partial_param do_check_partial do_check_fragile loc casel = + let pss = initial_matrix casel in + let pss = get_mins le_pats pss in + let total = do_check_partial loc casel pss in + if + total = Total && Warnings.is_active (Warnings.Fragile_match "") + then begin + do_check_fragile loc casel pss + end ; + total -let compute_variance_gadt env check (required, loc as rloc) decl - (tl, ret_type_opt) = - match ret_type_opt with - | None -> - compute_variance_type env check rloc {decl with type_private = Private} - (for_constr tl) - | Some ret_type -> - match Ctype.repr ret_type with - | {desc=Tconstr (_, tyl, _)} -> - (* let tyl = List.map (Ctype.expand_head env) tyl in *) - let tyl = List.map Ctype.repr tyl in - let fvl = List.map (Ctype.free_variables ?env:None) tyl in - let _ = - List.fold_left2 - (fun (fv1,fv2) ty (c,n,_) -> - match fv2 with [] -> assert false - | fv :: fv2 -> - (* fv1 @ fv2 = free_variables of other parameters *) - if (c||n) && constrained (fv1 @ fv2) ty then - raise (Error(loc, Varying_anonymous)); - (fv :: fv1, fv2)) - ([], fvl) tyl required - in - compute_variance_type env check rloc - {decl with type_params = tyl; type_private = Private} - (for_constr tl) - | _ -> assert false +(*let check_partial = + check_partial_param + do_check_partial_normal + do_check_fragile_normal*) -let compute_variance_extension env check decl ext rloc = - compute_variance_gadt env check rloc - {decl with type_params = ext.ext_type_params} - (ext.ext_args, ext.ext_ret_type) +let check_partial_gadt pred loc casel = + check_partial_param (do_check_partial_gadt pred) + do_check_fragile_gadt loc casel -let compute_variance_decl env check decl (required, _ as rloc) = - if (decl.type_kind = Type_abstract || decl.type_kind = Type_open) - && decl.type_manifest = None then - List.map - (fun (c, n, i) -> - make (not n) (not c) (decl.type_kind <> Type_abstract || i)) - required - else - let mn = - match decl.type_manifest with - None -> [] - | Some ty -> [false, ty] - in - match decl.type_kind with - Type_abstract | Type_open -> - compute_variance_type env check rloc decl mn - | Type_variant tll -> - if List.for_all (fun c -> c.Types.cd_res = None) tll then - compute_variance_type env check rloc decl - (mn @ List.flatten (List.map (fun c -> for_constr c.Types.cd_args) - tll)) - else begin - let mn = - List.map (fun (_,ty) -> (Types.Cstr_tuple [ty],None)) mn in - let tll = - mn @ List.map (fun c -> c.Types.cd_args, c.Types.cd_res) tll in - match List.map (compute_variance_gadt env check rloc decl) tll with - | vari :: rem -> - let varl = List.fold_left (List.map2 Variance.union) vari rem in - List.map - Variance.(fun v -> if mem Pos v && mem Neg v then full else v) - varl - | _ -> assert false - end - | Type_record (ftl, _) -> - compute_variance_type env check rloc decl - (mn @ List.map (fun {Types.ld_mutable; ld_type} -> - (ld_mutable = Mutable, ld_type)) ftl) -let is_hash id = - let s = Ident.name id in - String.length s > 0 && s.[0] = '#' +(*************************************) +(* Ambiguous variable in or-patterns *) +(*************************************) -let marked_as_immediate decl = - Builtin_attributes.immediate decl.type_attributes +(* Specification: ambiguous variables in or-patterns. -let compute_immediacy env tdecl = - match (tdecl.type_kind, tdecl.type_manifest) with - | (Type_variant [{cd_args = Cstr_tuple [arg]; _}], _) - | (Type_variant [{cd_args = Cstr_record [{ld_type = arg; _}]; _}], _) - | (Type_record ([{ld_type = arg; _}], _), _) - when tdecl.type_unboxed.unboxed -> - begin match get_unboxed_type_representation env arg with - | Some argrepr -> not (Ctype.maybe_pointer_type env argrepr) - | None -> false - end - | (Type_variant (_ :: _ as cstrs), _) -> - not (List.exists (fun c -> c.Types.cd_args <> Types.Cstr_tuple []) cstrs) - | (Type_abstract, Some(typ)) -> - not (Ctype.maybe_pointer_type env typ) - | (Type_abstract, None) -> marked_as_immediate tdecl - | _ -> false + The semantics of or-patterns in OCaml is specified with + a left-to-right bias: a value [v] matches the pattern [p | q] if it + matches [p] or [q], but if it matches both, the environment + captured by the match is the environment captured by [p], never the + one captured by [q]. -(* Computes the fixpoint for the variance and immediacy of type declarations *) + While this property is generally well-understood, one specific case + where users expect a different semantics is when a pattern is + followed by a when-guard: [| p when g -> e]. Consider for example: -let rec compute_properties_fixpoint env decls required variances immediacies = - let new_decls = - List.map2 - (fun (id, decl) (variance, immediacy) -> - id, {decl with type_variance = variance; type_immediate = immediacy}) - decls (List.combine variances immediacies) - in - let new_env = - List.fold_right - (fun (id, decl) env -> Env.add_type ~check:true id decl env) - new_decls env - in - let new_variances = - List.map2 - (fun (_id, decl) -> compute_variance_decl new_env false decl) - new_decls required - in - let new_variances = - List.map2 (List.map2 Variance.union) new_variances variances in - let new_immediacies = - List.map - (fun (_id, decl) -> compute_immediacy new_env decl) - new_decls - in - if new_variances <> variances || new_immediacies <> immediacies then - compute_properties_fixpoint env decls required new_variances new_immediacies - else begin - (* List.iter (fun (id, decl) -> - Printf.eprintf "%s:" (Ident.name id); - List.iter (fun (v : Variance.t) -> - Printf.eprintf " %x" (Obj.magic v : int)) - decl.type_variance; - prerr_endline "") - new_decls; *) - List.iter (fun (_, decl) -> - if (marked_as_immediate decl) && (not decl.type_immediate) then - raise (Error (decl.type_loc, Bad_immediate_attribute)) - else ()) - new_decls; - List.iter2 - (fun (id, decl) req -> if not (is_hash id) then - ignore (compute_variance_decl new_env true decl req)) - new_decls required; - new_decls, new_env - end + | ((Const x, _) | (_, Const x)) when is_neutral x -> branch -let init_variance (_id, decl) = - List.map (fun _ -> Variance.null) decl.type_params + The semantics is clear: match the scrutinee against the pattern, if + it matches, test the guard, and if the guard passes, take the + branch. -let add_injectivity = - List.map - (function - | Covariant -> (true, false, false) - | Contravariant -> (false, true, false) - | Invariant -> (false, false, false) - ) + However, consider the input [(Const a, Const b)], where [a] fails + the test [is_neutral f], while [b] passes the test [is_neutral + b]. With the left-to-right semantics, the clause above is *not* + taken by its input: matching [(Const a, Const b)] against the + or-pattern succeeds in the left branch, it returns the environment + [x -> a], and then the guard [is_neutral a] is tested and fails, + the branch is not taken. Most users, however, intuitively expect + that any pair that has one side passing the test will take the + branch. They assume it is equivalent to the following: -(* for typeclass.ml *) -let compute_variance_decls env cldecls = - let decls, required = - List.fold_right - (fun (obj_id, obj_abbr, _cl_abbr, _clty, _cltydef, ci) (decls, req) -> - let variance = List.map snd ci.ci_params in - (obj_id, obj_abbr) :: decls, - (add_injectivity variance, ci.ci_loc) :: req) - cldecls ([],[]) - in - let (decls, _) = - compute_properties_fixpoint env decls required - (List.map init_variance decls) - (List.map (fun _ -> false) decls) - in - List.map2 - (fun (_,decl) (_, _, cl_abbr, clty, cltydef, _) -> - let variance = decl.type_variance in - (decl, {cl_abbr with type_variance = variance}, - {clty with cty_variance = variance}, - {cltydef with clty_variance = variance})) - decls cldecls + | (Const x, _) when is_neutral x -> branch + | (_, Const x) when is_neutral x -> branch -(* Check multiple declarations of labels/constructors *) + while it is not. -let check_duplicates sdecl_list = - let labels = Hashtbl.create 7 and constrs = Hashtbl.create 7 in - List.iter - (fun sdecl -> match sdecl.ptype_kind with - Ptype_variant cl -> - List.iter - (fun pcd -> - try - let name' = Hashtbl.find constrs pcd.pcd_name.txt in - Location.prerr_warning pcd.pcd_loc - (Warnings.Duplicate_definitions - ("constructor", pcd.pcd_name.txt, name', - sdecl.ptype_name.txt)) - with Not_found -> - Hashtbl.add constrs pcd.pcd_name.txt sdecl.ptype_name.txt) - cl - | Ptype_record fl -> - List.iter - (fun {pld_name=cname;pld_loc=loc} -> - try - let name' = Hashtbl.find labels cname.txt in - Location.prerr_warning loc - (Warnings.Duplicate_definitions - ("label", cname.txt, name', sdecl.ptype_name.txt)) - with Not_found -> Hashtbl.add labels cname.txt sdecl.ptype_name.txt) - fl - | Ptype_abstract -> () - | Ptype_open -> ()) - sdecl_list + The code below is dedicated to finding these confusing cases: the + cases where a guard uses "ambiguous" variables, that are bound to + different parts of the scrutinees by different sides of + a or-pattern. In other words, it finds the cases where the + specified left-to-right semantics is not equivalent to + a non-deterministic semantics (any branch can be taken) relatively + to a specific guard. +*) -(* Force recursion to go through id for private types*) -let name_recursion sdecl id decl = - match decl with - | { type_kind = Type_abstract; - type_manifest = Some ty; - type_private = Private; } when is_fixed_type sdecl -> - let ty = Ctype.repr ty in - let ty' = Btype.newty2 ty.level ty.desc in - if Ctype.deep_occur ty ty' then - let td = Tconstr(Path.Pident id, decl.type_params, ref Mnil) in - Btype.link_type ty (Btype.newty2 ty.level td); - {decl with type_manifest = Some ty'} - else decl - | _ -> decl +module IdSet = Set.Make(Ident) -(* Translate a set of type declarations, mutually recursive or not *) -let transl_type_decl env rec_flag sdecl_list = - (* Add dummy types for fixed rows *) - let fixed_types = List.filter is_fixed_type sdecl_list in - let sdecl_list = - List.map - (fun sdecl -> - let ptype_name = - mkloc (sdecl.ptype_name.txt ^"#row") sdecl.ptype_name.loc in - {sdecl with - ptype_name; ptype_kind = Ptype_abstract; ptype_manifest = None}) - fixed_types - @ sdecl_list - in +let pattern_vars p = IdSet.of_list (Typedtree.pat_bound_idents p) - (* Create identifiers. *) - let id_list = - List.map (fun sdecl -> Ident.create sdecl.ptype_name.txt) sdecl_list - in - (* - Since we've introduced fresh idents, make sure the definition - level is at least the binding time of these events. Otherwise, - passing one of the recursively-defined type constrs as argument - to an abbreviation may fail. - *) - Ctype.init_def(Ident.current_time()); - Ctype.begin_def(); - (* Enter types. *) - let temp_env = - List.fold_left2 (enter_type rec_flag) env sdecl_list id_list in - (* Translate each declaration. *) - let current_slot = ref None in - let warn_unused = Warnings.is_active (Warnings.Unused_type_declaration "") in - let id_slots id = - match rec_flag with - | Asttypes.Recursive when warn_unused -> - (* See typecore.ml for a description of the algorithm used - to detect unused declarations in a set of recursive definitions. *) - let slot = ref [] in - let td = Env.find_type (Path.Pident id) temp_env in - let name = Ident.name id in - Env.set_type_used_callback - name td - (fun old_callback -> - match !current_slot with - | Some slot -> slot := (name, td) :: !slot - | None -> - List.iter (fun (name, d) -> Env.mark_type_used env name d) - (get_ref slot); - old_callback () - ); - id, Some slot - | Asttypes.Recursive | Asttypes.Nonrecursive -> - id, None - in - let transl_declaration name_sdecl (id, slot) = - current_slot := slot; - Builtin_attributes.warning_scope - name_sdecl.ptype_attributes - (fun () -> transl_declaration temp_env name_sdecl id) - in - let tdecls = - List.map2 transl_declaration sdecl_list (List.map id_slots id_list) in - let decls = - List.map (fun tdecl -> (tdecl.typ_id, tdecl.typ_type)) tdecls in - current_slot := None; - (* Check for duplicates *) - check_duplicates sdecl_list; - (* Build the final env. *) - let newenv = - List.fold_right - (fun (id, decl) env -> Env.add_type ~check:true id decl env) - decls env - in - (* Update stubs *) - begin match rec_flag with - | Asttypes.Nonrecursive -> () - | Asttypes.Recursive -> - List.iter2 - (fun id sdecl -> update_type temp_env newenv id sdecl.ptype_loc) - id_list sdecl_list - end; - (* Generalize type declarations. *) - Ctype.end_def(); - List.iter (fun (_, decl) -> generalize_decl decl) decls; - (* Check for ill-formed abbrevs *) - let id_loc_list = - List.map2 (fun id sdecl -> (id, sdecl.ptype_loc)) - id_list sdecl_list - in - List.iter (fun (id, decl) -> - check_well_founded_manifest newenv (List.assoc id id_loc_list) - (Path.Pident id) decl) - decls; - let to_check = - function Path.Pident id -> List.mem_assoc id id_loc_list | _ -> false in - List.iter (fun (id, decl) -> - check_well_founded_decl newenv (List.assoc id id_loc_list) (Path.Pident id) - decl to_check) - decls; - List.iter (check_abbrev_recursion newenv id_loc_list to_check) tdecls; - (* Check that all type variables are closed *) - List.iter2 - (fun sdecl tdecl -> - let decl = tdecl.typ_type in - match Ctype.closed_type_decl decl with - Some ty -> raise(Error(sdecl.ptype_loc, Unbound_type_var(ty,decl))) - | None -> ()) - sdecl_list tdecls; - (* Check that constraints are enforced *) - List.iter2 (check_constraints newenv) sdecl_list decls; - (* Name recursion *) - let decls = - List.map2 (fun sdecl (id, decl) -> id, name_recursion sdecl id decl) - sdecl_list decls - in - (* Add variances to the environment *) - let required = - List.map - (fun sdecl -> - add_injectivity (List.map snd sdecl.ptype_params), - sdecl.ptype_loc - ) - sdecl_list - in - let final_decls, final_env = - compute_properties_fixpoint env decls required - (List.map init_variance decls) - (List.map (fun _ -> false) decls) - in - (* Check re-exportation *) - List.iter2 (check_abbrev final_env) sdecl_list final_decls; - (* Keep original declaration *) - let final_decls = - List.map2 - (fun tdecl (_id2, decl) -> - { tdecl with typ_type = decl } - ) tdecls final_decls - in - (* Done *) - (final_decls, final_env) +(* Row for ambiguous variable search, + unseen is the traditional pattern row, + seen is a list of position bindings *) -(* Translating type extensions *) +type amb_row = { unseen : pattern list ; seen : IdSet.t list; } -let transl_extension_constructor env type_path type_params - typext_params priv sext = - let id = Ident.create sext.pext_name.txt in - let args, ret_type, kind = - match sext.pext_kind with - Pext_decl(sargs, sret_type) -> - let targs, tret_type, args, ret_type, _ = - make_constructor env type_path typext_params - sargs sret_type - in - args, ret_type, Text_decl(targs, tret_type) - | Pext_rebind lid -> - let cdescr = Typetexp.find_constructor env lid.loc lid.txt in - let usage = - if cdescr.cstr_private = Private || priv = Public - then Env.Positive else Env.Privatize - in - Env.mark_constructor usage env (Longident.last lid.txt) cdescr; - let (args, cstr_res) = Ctype.instance_constructor cdescr in - let res, ret_type = - if cdescr.cstr_generalized then - let params = Ctype.instance_list env type_params in - let res = Ctype.newconstr type_path params in - let ret_type = Some (Ctype.newconstr type_path params) in - res, ret_type - else (Ctype.newconstr type_path typext_params), None - in - begin - try - Ctype.unify env cstr_res res - with Ctype.Unify trace -> - raise (Error(lid.loc, - Rebind_wrong_type(lid.txt, env, trace))) - end; - (* Remove "_" names from parameters used in the constructor *) - if not cdescr.cstr_generalized then begin - let vars = - Ctype.free_variables (Btype.newgenty (Ttuple args)) - in - List.iter - (function {desc = Tvar (Some "_")} as ty -> - if List.memq ty vars then ty.desc <- Tvar None - | _ -> ()) - typext_params - end; - (* Ensure that constructor's type matches the type being extended *) - let cstr_type_path, cstr_type_params = - match cdescr.cstr_res.desc with - Tconstr (p, _, _) -> - let decl = Env.find_type p env in - p, decl.type_params - | _ -> assert false - in - let cstr_types = - (Btype.newgenty - (Tconstr(cstr_type_path, cstr_type_params, ref Mnil))) - :: cstr_type_params - in - let ext_types = - (Btype.newgenty - (Tconstr(type_path, type_params, ref Mnil))) - :: type_params - in - if not (Ctype.equal env true cstr_types ext_types) then - raise (Error(lid.loc, - Rebind_mismatch(lid.txt, cstr_type_path, type_path))); - (* Disallow rebinding private constructors to non-private *) - begin - match cdescr.cstr_private, priv with - Private, Public -> - raise (Error(lid.loc, Rebind_private lid.txt)) - | _ -> () - end; - let path = - match cdescr.cstr_tag with - Cstr_extension(path, _) -> path - | _ -> assert false - in - let args = - match cdescr.cstr_inlined with - | None -> - Types.Cstr_tuple args - | Some decl -> - let tl = - match args with - | [ {desc=Tconstr(_, tl, _)} ] -> tl - | _ -> assert false - in - let decl = Ctype.instance_declaration decl in - assert (List.length decl.type_params = List.length tl); - List.iter2 (Ctype.unify env) decl.type_params tl; - let lbls = - match decl.type_kind with - | Type_record (lbls, Record_extension) -> lbls - | _ -> assert false - in - Types.Cstr_record lbls - in - args, ret_type, Text_rebind(path, lid) - in - let ext = - { ext_type_path = type_path; - ext_type_params = typext_params; - ext_args = args; - ext_ret_type = ret_type; - ext_private = priv; - Types.ext_loc = sext.pext_loc; - Types.ext_attributes = sext.pext_attributes; } - in - { ext_id = id; - ext_name = sext.pext_name; - ext_type = ext; - ext_kind = kind; - Typedtree.ext_loc = sext.pext_loc; - Typedtree.ext_attributes = sext.pext_attributes; } -let transl_extension_constructor env type_path type_params - typext_params priv sext = - Builtin_attributes.warning_scope sext.pext_attributes - (fun () -> transl_extension_constructor env type_path type_params - typext_params priv sext) +(* Push binding variables now *) + +let rec do_push r p ps seen k = match p.pat_desc with +| Tpat_alias (p,x,_) -> do_push (IdSet.add x r) p ps seen k +| Tpat_var (x,_) -> + (omega,{ unseen = ps; seen=IdSet.add x r::seen; })::k +| Tpat_or (p1,p2,_) -> + do_push r p1 ps seen (do_push r p2 ps seen k) +| _ -> + (p,{ unseen = ps; seen = r::seen; })::k + +let rec push_vars = function + | [] -> [] + | { unseen = [] }::_ -> assert false + | { unseen = p::ps; seen; }::rem -> + do_push IdSet.empty p ps seen (push_vars rem) + +let collect_stable = function + | [] -> assert false + | { seen=xss; _}::rem -> + let rec c_rec xss = function + | [] -> xss + | {seen=yss; _}::rem -> + let xss = List.map2 IdSet.inter xss yss in + c_rec xss rem in + let inters = c_rec xss rem in + List.fold_left IdSet.union IdSet.empty inters + -let transl_type_extension extend env loc styext = - reset_type_variables(); - Ctype.begin_def(); - let (type_path, type_decl) = - let lid = styext.ptyext_path in - Typetexp.find_type env lid.loc lid.txt - in - begin - match type_decl.type_kind with - | Type_open -> begin - match type_decl.type_private with - | Private when extend -> begin - match - List.find - (function {pext_kind = Pext_decl _} -> true - | {pext_kind = Pext_rebind _} -> false) - styext.ptyext_constructors - with - | {pext_loc} -> - raise (Error(pext_loc, Cannot_extend_private_type type_path)) - | exception Not_found -> () - end - | _ -> () - end - | _ -> - raise (Error(loc, Not_extensible_type type_path)) - end; - let type_variance = - List.map (fun v -> - let (co, cn) = Variance.get_upper v in - (not cn, not co, false)) - type_decl.type_variance - in - let err = - if type_decl.type_arity <> List.length styext.ptyext_params then - [Includecore.Arity] - else - if List.for_all2 - (fun (c1, n1, _) (c2, n2, _) -> (not c2 || c1) && (not n2 || n1)) - type_variance - (add_injectivity (List.map snd styext.ptyext_params)) - then [] else [Includecore.Variance] - in - if err <> [] then - raise (Error(loc, Extension_mismatch (type_path, err))); - let ttype_params = make_params env styext.ptyext_params in - let type_params = List.map (fun (cty, _) -> cty.ctyp_type) ttype_params in - List.iter2 (Ctype.unify_var env) - (Ctype.instance_list env type_decl.type_params) - type_params; - let constructors = - List.map (transl_extension_constructor env type_path - type_decl.type_params type_params styext.ptyext_private) - styext.ptyext_constructors - in - Ctype.end_def(); - (* Generalize types *) - List.iter Ctype.generalize type_params; - List.iter - (fun ext -> - Btype.iter_type_expr_cstr_args Ctype.generalize ext.ext_type.ext_args; - may Ctype.generalize ext.ext_type.ext_ret_type) - constructors; - (* Check that all type variables are closed *) - List.iter - (fun ext -> - match Ctype.closed_extension_constructor ext.ext_type with - Some ty -> - raise(Error(ext.ext_loc, Unbound_type_var_ext(ty, ext.ext_type))) - | None -> ()) - constructors; - (* Check variances are correct *) - List.iter - (fun ext-> - ignore (compute_variance_extension env true type_decl - ext.ext_type (type_variance, loc))) - constructors; - (* Add extension constructors to the environment *) - let newenv = - List.fold_left - (fun env ext -> - Env.add_extension ~check:true ext.ext_id ext.ext_type env) - env constructors - in - let tyext = - { tyext_path = type_path; - tyext_txt = styext.ptyext_path; - tyext_params = ttype_params; - tyext_constructors = constructors; - tyext_private = styext.ptyext_private; - tyext_attributes = styext.ptyext_attributes; } +(*********************************************) +(* Filtering utilities for our specific rows *) +(*********************************************) + +(* Take a pattern matrix as a list (rows) of lists (columns) of patterns + | p1, p2, .., pn + | q1, q2, .., qn + | r1, r2, .., rn + | ... + + We split this matrix into a list of sub-matrices, one for each head + constructor appearing in the leftmost column. For each row whose + left column starts with a head constructor, remove this head + column, prepend one column for each argument of the constructor, + and add the resulting row in the sub-matrix corresponding to this + head constructor. + + Rows whose left column is omega (the Any pattern _) may match any + head constructor, so they are added to all groups. + + The list of sub-matrices is represented as a list of pair + (head constructor, submatrix) +*) + +let filter_all = + (* the head constructor (as a pattern with omega arguments) of + a pattern *) + let discr_head pat = + match pat.pat_desc with + | Tpat_record (lbls, closed) -> + (* a partial record pattern { f1 = p1; f2 = p2; _ } + needs to be expanded, otherwise matching against this head + would drop the pattern arguments for non-mentioned fields *) + let lbls = all_record_args lbls in + normalize_pat { pat with pat_desc = Tpat_record (lbls, closed) } + | _ -> normalize_pat pat in - (tyext, newenv) -let transl_type_extension extend env loc styext = - Builtin_attributes.warning_scope styext.ptyext_attributes - (fun () -> transl_type_extension extend env loc styext) + (* insert a row of head [p] and rest [r] into the right group *) + let rec insert p r env = match env with + | [] -> + (* if no group matched this row, it has a head constructor that + was never seen before; add a new sub-matrix for this head *) + let p0 = discr_head p in + [p0,[{ r with unseen = simple_match_args p0 p @ r.unseen }]] + | (q0,rs) as bd::env -> + if simple_match q0 p then begin + let r = { r with unseen = simple_match_args q0 p@r.unseen; } in + (q0,r::rs)::env + end + else bd::insert p r env in -let transl_exception env sext = - reset_type_variables(); - Ctype.begin_def(); - let ext = - transl_extension_constructor env - Predef.path_exn [] [] Asttypes.Public sext + (* insert a row of head omega into all groups *) + let insert_omega r env = + List.map + (fun (q0,rs) -> + let r = + { r with unseen = simple_match_args q0 omega @ r.unseen; } in + (q0,r::rs)) + env in - Ctype.end_def(); - (* Generalize types *) - Btype.iter_type_expr_cstr_args Ctype.generalize ext.ext_type.ext_args; - may Ctype.generalize ext.ext_type.ext_ret_type; - (* Check that all type variables are closed *) - begin match Ctype.closed_extension_constructor ext.ext_type with - Some ty -> - raise (Error(ext.ext_loc, Unbound_type_var_ext(ty, ext.ext_type))) - | None -> () - end; - let newenv = Env.add_extension ~check:true ext.ext_id ext.ext_type env in - ext, newenv -type native_repr_attribute = - | Native_repr_attr_absent - | Native_repr_attr_present of native_repr_kind + let rec filter_rec env = function + | [] -> env + | ({pat_desc=(Tpat_var _|Tpat_alias _|Tpat_or _)},_)::_ -> assert false + | ({pat_desc=Tpat_any}, _)::rs -> filter_rec env rs + | (p,r)::rs -> filter_rec (insert p r env) rs in -let get_native_repr_attribute attrs ~global_repr = - match - Attr_helper.get_no_payload_attribute ["unboxed"; "ocaml.unboxed"] attrs, - Attr_helper.get_no_payload_attribute ["untagged"; "ocaml.untagged"] attrs, - global_repr - with - | None, None, None -> Native_repr_attr_absent - | None, None, Some repr -> Native_repr_attr_present repr - | Some _, None, None -> Native_repr_attr_present Unboxed - | None, Some _, None -> Native_repr_attr_present Untagged - | Some { Location.loc }, _, _ - | _, Some { Location.loc }, _ -> - raise (Error (loc, Multiple_native_repr_attributes)) + let rec filter_omega env = function + | [] -> env + | ({pat_desc=(Tpat_var _|Tpat_alias _|Tpat_or _)},_)::_ -> assert false + | ({pat_desc=Tpat_any},r)::rs -> filter_omega (insert_omega r env) rs + | _::rs -> filter_omega env rs in -let native_repr_of_type env kind ty = - match kind, (Ctype.expand_head_opt env ty).desc with - | Untagged, Tconstr (path, _, _) when Path.same path Predef.path_int -> - Some Untagged_int - | Unboxed, Tconstr (path, _, _) when Path.same path Predef.path_float -> - Some Unboxed_float - | Unboxed, Tconstr (path, _, _) when Path.same path Predef.path_int32 -> - Some (Unboxed_integer Pint32) - | Unboxed, Tconstr (path, _, _) when Path.same path Predef.path_int64 -> - Some (Unboxed_integer Pint64) - | Unboxed, Tconstr (path, _, _) when Path.same path Predef.path_nativeint -> - Some (Unboxed_integer Pnativeint) - | _ -> - None + fun rs -> + (* first insert the rows with head constructors, + to get the definitive list of groups *) + let env = filter_rec [] rs in + (* then add the omega rows to all groups *) + filter_omega env rs -(* Raises an error when [core_type] contains an [@unboxed] or [@untagged] - attribute in a strict sub-term. *) -let error_if_has_deep_native_repr_attributes core_type = - let open Ast_iterator in - let this_iterator = - { default_iterator with typ = fun iterator core_type -> - begin - match - get_native_repr_attribute core_type.ptyp_attributes ~global_repr:None - with - | Native_repr_attr_present kind -> - raise (Error (core_type.ptyp_loc, - Deep_unbox_or_untag_attribute kind)) - | Native_repr_attr_absent -> () - end; - default_iterator.typ iterator core_type } - in - default_iterator.typ this_iterator core_type +(* Compute stable bindings *) -let make_native_repr env core_type ty ~global_repr = - error_if_has_deep_native_repr_attributes core_type; - match get_native_repr_attribute core_type.ptyp_attributes ~global_repr with - | Native_repr_attr_absent -> - Same_as_ocaml_repr - | Native_repr_attr_present kind -> - begin match native_repr_of_type env kind ty with - | None -> - raise (Error (core_type.ptyp_loc, Cannot_unbox_or_untag_type kind)) - | Some repr -> repr +let rec do_stable rs = match rs with +| [] -> assert false (* No empty matrix *) +| { unseen=[]; _ }::_ -> + collect_stable rs +| _ -> + let rs = push_vars rs in + if not (all_coherent (first_column rs)) then begin + (* If the first column is incoherent, then all the variables of this + matrix are stable. *) + List.fold_left (fun acc (_, { seen; _ }) -> + List.fold_left IdSet.union acc seen + ) IdSet.empty rs + end else begin + (* If the column is ill-typed but deemed coherent, we might spuriously + warn about some variables being unstable. + As sad as that might be, the warning can be silenced by splitting the + or-pattern... *) + match filter_all rs with + | [] -> + do_stable (List.map snd rs) + | (_,rs)::env -> + List.fold_left + (fun xs (_,rs) -> IdSet.inter xs (do_stable rs)) + (do_stable rs) env end -let rec parse_native_repr_attributes env core_type ty ~global_repr = - match core_type.ptyp_desc, (Ctype.repr ty).desc, - get_native_repr_attribute core_type.ptyp_attributes ~global_repr:None - with - | Ptyp_arrow _, Tarrow _, Native_repr_attr_present kind -> - raise (Error (core_type.ptyp_loc, Cannot_unbox_or_untag_type kind)) - | Ptyp_arrow (_, ct1, ct2), Tarrow (_, t1, t2, _), _ -> - let repr_arg = make_native_repr env ct1 t1 ~global_repr in - let repr_args, repr_res = - parse_native_repr_attributes env ct2 t2 ~global_repr - in - (repr_arg :: repr_args, repr_res) - | Ptyp_arrow _, _, _ | _, Tarrow _, _ -> assert false - | _ -> ([], make_native_repr env core_type ty ~global_repr) +let stable p = do_stable [{unseen=[p]; seen=[];}] -let check_unboxable env loc ty = - let ty = Ctype.repr (Ctype.expand_head_opt env ty) in - try match ty.desc with - | Tconstr (p, _, _) -> - let tydecl = Env.find_type p env in - if tydecl.type_unboxed.unboxed then - Location.prerr_warning loc - (Warnings.Unboxable_type_in_prim_decl (Path.name p)) - | _ -> () - with Not_found -> () +(* All identifier paths that appear in an expression that occurs + as a clause right hand side or guard. -(* Translate a value declaration *) -let transl_value_decl env loc valdecl = - let cty = Typetexp.transl_type_scheme env valdecl.pval_type in - let ty = cty.ctyp_type in - let v = - match valdecl.pval_prim with - [] when Env.is_in_signature env -> - { val_type = ty; val_kind = Val_reg; Types.val_loc = loc; - val_attributes = valdecl.pval_attributes } - | [] -> - raise (Error(valdecl.pval_loc, Val_in_structure)) - | _ -> - let global_repr = - match - get_native_repr_attribute valdecl.pval_attributes ~global_repr:None - with - | Native_repr_attr_present repr -> Some repr - | Native_repr_attr_absent -> None - in - let native_repr_args, native_repr_res = - if !Clflags.bs_only then - let rec scann (attrs : Parsetree.attributes) = - match attrs with - | ({txt = "internal.arity";_}, - PStr [ {pstr_desc = Pstr_eval - ( - ({pexp_desc = Pexp_constant (Pconst_integer (i,_))} : - Parsetree.expression) ,_)}]) :: _ -> - Some (int_of_string i) - | _ :: rest -> scann rest - | [] -> None - and make n = - if n = 0 then [] - else Primitive.Same_as_ocaml_repr :: make (n - 1) - in - match scann valdecl.pval_attributes with - | None -> parse_native_repr_attributes env valdecl.pval_type ty ~global_repr - | Some x -> make x , Primitive.Same_as_ocaml_repr - else - parse_native_repr_attributes env valdecl.pval_type ty ~global_repr - in - let prim = - Primitive.parse_declaration valdecl - ~native_repr_args - ~native_repr_res - in - let prim_native_name = prim.prim_native_name in - if prim.prim_arity = 0 && - not ( String.length prim_native_name > 3 && - String.unsafe_get prim_native_name 0 = 'B' && - String.unsafe_get prim_native_name 1 = 'S' && - String.unsafe_get prim_native_name 2 = ':' - ) && - (prim.prim_name = "" || (prim.prim_name.[0] <> '%' && prim.prim_name.[0] <> '#')) then - raise(Error(valdecl.pval_type.ptyp_loc, Null_arity_external)); - if !Clflags.native_code - && prim.prim_arity > 5 - && prim_native_name = "" - then raise(Error(valdecl.pval_type.ptyp_loc, Missing_native_external)); - Btype.iter_type_expr (check_unboxable env loc) ty; - { val_type = ty; val_kind = Val_prim prim; Types.val_loc = loc; - val_attributes = valdecl.pval_attributes } - in - let (id, newenv) = - Env.enter_value valdecl.pval_name.txt v env - ~check:(fun s -> Warnings.Unused_value_declaration s) - in - let desc = - { - val_id = id; - val_name = valdecl.pval_name; - val_desc = cty; val_val = v; - val_prim = valdecl.pval_prim; - val_loc = valdecl.pval_loc; - val_attributes = valdecl.pval_attributes; - } - in - desc, newenv + The function is rather complex due to the compilation of + unpack patterns by introducing code in rhs expressions + and **guards**. + + For pattern (module M:S) -> e the code is + let module M_mod = unpack M .. in e + + Hence M is "free" in e iff M_mod is free in e. + + Not doing so will yield excessive warning in + (module (M:S) } ...) when true -> .... + as M is always present in + let module M_mod = unpack M .. in true +*) + +let all_rhs_idents exp = + let ids = ref IdSet.empty in + let module Iterator = TypedtreeIter.MakeIterator(struct + include TypedtreeIter.DefaultIteratorArgument + let enter_expression exp = match exp.exp_desc with + | Texp_ident (path, _lid, _descr) -> + List.iter + (fun id -> ids := IdSet.add id !ids) + (Path.heads path) + | _ -> () + +(* Very hackish, detect unpack pattern compilation + and perform "indirect check for them" *) + let is_unpack exp = + List.exists + (fun (attr, _) -> attr.txt = "#modulepat") exp.exp_attributes + + let leave_expression exp = + if is_unpack exp then begin match exp.exp_desc with + | Texp_letmodule + (id_mod,_, + {mod_desc= + Tmod_unpack ({exp_desc=Texp_ident (Path.Pident id_exp,_,_)},_)}, + _) -> + assert (IdSet.mem id_exp !ids) ; + if not (IdSet.mem id_mod !ids) then begin + ids := IdSet.remove id_exp !ids + end + | _ -> assert false + end + end) in + Iterator.iter_expression exp; + !ids + +let check_ambiguous_bindings = + let open Warnings in + let warn0 = Ambiguous_pattern [] in + fun cases -> + if is_active warn0 then + List.iter + (fun case -> match case with + | { c_guard=None ; _} -> () + | { c_lhs=p; c_guard=Some g; _} -> + let all = + IdSet.inter (pattern_vars p) (all_rhs_idents g) in + if not (IdSet.is_empty all) then begin + let st = stable p in + let ambiguous = IdSet.diff all st in + if not (IdSet.is_empty ambiguous) then begin + let pps = IdSet.elements ambiguous |> List.map Ident.name in + let warn = Ambiguous_pattern pps in + Location.prerr_warning p.pat_loc warn + end + end) + cases + +end +module Typetexp : sig +#1 "typetexp.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) + +(* Typechecking of type expressions for the core language *) + +open Types + +val transl_simple_type: + Env.t -> bool -> Parsetree.core_type -> Typedtree.core_type +val transl_simple_type_univars: + Env.t -> Parsetree.core_type -> Typedtree.core_type +val transl_simple_type_delayed: + Env.t -> Parsetree.core_type -> Typedtree.core_type * (unit -> unit) + (* Translate a type, but leave type variables unbound. Returns + the type and a function that binds the type variable. *) +val transl_type_scheme: + Env.t -> Parsetree.core_type -> Typedtree.core_type +val reset_type_variables: unit -> unit +val type_variable: Location.t -> string -> type_expr +val transl_type_param: + Env.t -> Parsetree.core_type -> Typedtree.core_type + +type variable_context +val narrow: unit -> variable_context +val widen: variable_context -> unit + +exception Already_bound + +type error = + Unbound_type_variable of string + | Unbound_type_constructor of Longident.t + | Unbound_type_constructor_2 of Path.t + | Type_arity_mismatch of Longident.t * int * int + | Bound_type_variable of string + | Recursive_type + | Unbound_row_variable of Longident.t + | Type_mismatch of (type_expr * type_expr) list + | Alias_type_mismatch of (type_expr * type_expr) list + | Present_has_conjunction of string + | Present_has_no_type of string + | Constructor_mismatch of type_expr * type_expr + | Not_a_variant of type_expr + | Variant_tags of string * string + | Invalid_variable_name of string + | Cannot_quantify of string * type_expr + | Multiple_constraints_on_type of Longident.t + | Method_mismatch of string * type_expr * type_expr + | Unbound_value of Longident.t + | Unbound_constructor of Longident.t + | Unbound_label of Longident.t + | Unbound_module of Longident.t + | Unbound_class of Longident.t + | Unbound_modtype of Longident.t + | Unbound_cltype of Longident.t + | Ill_typed_functor_application of Longident.t + | Illegal_reference_to_recursive_module + | Access_functor_as_structure of Longident.t + | Apply_structure_as_functor of Longident.t + | Cannot_scrape_alias of Longident.t * Path.t + | Opened_object of Path.t option + | Not_an_object of type_expr -let transl_value_decl env loc valdecl = - Builtin_attributes.warning_scope valdecl.pval_attributes - (fun () -> transl_value_decl env loc valdecl) +exception Error of Location.t * Env.t * error -(* Translate a "with" constraint -- much simplified version of - transl_type_decl. *) -let transl_with_constraint env id row_path orig_decl sdecl = - Env.mark_type_used env (Ident.name id) orig_decl; - reset_type_variables(); - Ctype.begin_def(); - let tparams = make_params env sdecl.ptype_params in - let params = List.map (fun (cty, _) -> cty.ctyp_type) tparams in - let orig_decl = Ctype.instance_declaration orig_decl in - let arity_ok = List.length params = orig_decl.type_arity in - if arity_ok then - List.iter2 (Ctype.unify_var env) params orig_decl.type_params; - let constraints = List.map - (function (ty, ty', loc) -> - try - let cty = transl_simple_type env false ty in - let cty' = transl_simple_type env false ty' in - let ty = cty.ctyp_type in - let ty' = cty'.ctyp_type in - Ctype.unify env ty ty'; - (cty, cty', loc) - with Ctype.Unify tr -> - raise(Error(loc, Inconsistent_constraint (env, tr)))) - sdecl.ptype_cstrs - in - let no_row = not (is_fixed_type sdecl) in - let (tman, man) = match sdecl.ptype_manifest with - None -> None, None - | Some sty -> - let cty = transl_simple_type env no_row sty in - Some cty, Some cty.ctyp_type - in - let priv = - if sdecl.ptype_private = Private then Private else - if arity_ok && orig_decl.type_kind <> Type_abstract - then orig_decl.type_private else sdecl.ptype_private - in - if arity_ok && orig_decl.type_kind <> Type_abstract - && sdecl.ptype_private = Private then - Location.deprecated sdecl.ptype_loc "spurious use of private"; - let type_kind, type_unboxed = - if arity_ok && man <> None then - orig_decl.type_kind, orig_decl.type_unboxed - else - Type_abstract, unboxed_false_default_false - in - let decl = - { type_params = params; - type_arity = List.length params; - type_kind; - type_private = priv; - type_manifest = man; - type_variance = []; - type_newtype_level = None; - type_loc = sdecl.ptype_loc; - type_attributes = sdecl.ptype_attributes; - type_immediate = false; - type_unboxed; - } - in - begin match row_path with None -> () - | Some p -> set_fixed_row env sdecl.ptype_loc p decl - end; - begin match Ctype.closed_type_decl decl with None -> () - | Some ty -> raise(Error(sdecl.ptype_loc, Unbound_type_var(ty,decl))) - end; - let decl = name_recursion sdecl id decl in - let type_variance = - compute_variance_decl env true decl - (add_injectivity (List.map snd sdecl.ptype_params), sdecl.ptype_loc) - in - let type_immediate = compute_immediacy env decl in - let decl = {decl with type_variance; type_immediate} in - Ctype.end_def(); - generalize_decl decl; - { - typ_id = id; - typ_name = sdecl.ptype_name; - typ_params = tparams; - typ_type = decl; - typ_cstrs = constraints; - typ_loc = sdecl.ptype_loc; - typ_manifest = tman; - typ_kind = Ttype_abstract; - typ_private = sdecl.ptype_private; - typ_attributes = sdecl.ptype_attributes; - } +val report_error: Env.t -> Format.formatter -> error -> unit -(* Approximate a type declaration: just make all types abstract *) +(* Support for first-class modules. *) +val transl_modtype_longident: (* from Typemod *) + (Location.t -> Env.t -> Longident.t -> Path.t) ref +val transl_modtype: (* from Typemod *) + (Env.t -> Parsetree.module_type -> Typedtree.module_type) ref +val create_package_mty: + Location.t -> Env.t -> Parsetree.package_type -> + (Longident.t Asttypes.loc * Parsetree.core_type) list * + Parsetree.module_type -let abstract_type_decl arity = - let rec make_params n = - if n <= 0 then [] else Ctype.newvar() :: make_params (n-1) in - Ctype.begin_def(); - let decl = - { type_params = make_params arity; - type_arity = arity; - type_kind = Type_abstract; - type_private = Public; - type_manifest = None; - type_variance = replicate_list Variance.full arity; - type_newtype_level = None; - type_loc = Location.none; - type_attributes = []; - type_immediate = false; - type_unboxed = unboxed_false_default_false; - } in - Ctype.end_def(); - generalize_decl decl; - decl +val find_type: + Env.t -> Location.t -> Longident.t -> Path.t * type_declaration +val find_constructor: + Env.t -> Location.t -> Longident.t -> constructor_description +val find_all_constructors: + Env.t -> Location.t -> Longident.t -> + (constructor_description * (unit -> unit)) list +val find_label: + Env.t -> Location.t -> Longident.t -> label_description +val find_all_labels: + Env.t -> Location.t -> Longident.t -> + (label_description * (unit -> unit)) list +val find_value: + Env.t -> Location.t -> Longident.t -> Path.t * value_description +val find_class: + Env.t -> Location.t -> Longident.t -> Path.t * class_declaration +val find_module: + Env.t -> Location.t -> Longident.t -> Path.t * module_declaration +val lookup_module: + ?load:bool -> Env.t -> Location.t -> Longident.t -> Path.t +val find_modtype: + Env.t -> Location.t -> Longident.t -> Path.t * modtype_declaration +val find_class_type: + Env.t -> Location.t -> Longident.t -> Path.t * class_type_declaration -let approx_type_decl sdecl_list = - List.map - (fun sdecl -> - (Ident.create sdecl.ptype_name.txt, - abstract_type_decl (List.length sdecl.ptype_params))) - sdecl_list +val unbound_constructor_error: Env.t -> Longident.t Location.loc -> 'a +val unbound_label_error: Env.t -> Longident.t Location.loc -> 'a -(* Variant of check_abbrev_recursion to check the well-formedness - conditions on type abbreviations defined within recursive modules. *) -let check_recmod_typedecl env loc recmod_ids path decl = - (* recmod_ids is the list of recursively-defined module idents. - (path, decl) is the type declaration to be checked. *) - let to_check path = - List.exists (fun id -> Path.isfree id path) recmod_ids in - check_well_founded_decl env loc path decl to_check; - check_recursion env loc path decl to_check +val spellcheck: + Format.formatter -> + (('a -> 'a list -> 'a list) -> + Longident.t option -> 'b -> 'c list -> string list) -> + 'b -> Longident.t -> unit +end = struct +#1 "typetexp.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -(**** Error report ****) +(* typetexp.ml,v 1.34.4.9 2002/01/07 08:39:16 garrigue Exp *) -open Format +(* Typechecking of type expressions for the core language *) -let explain_unbound_gen ppf tv tl typ kwd pr = - try - let ti = List.find (fun ti -> Ctype.deep_occur tv (typ ti)) tl in - let ty0 = (* Hack to force aliasing when needed *) - Btype.newgenty (Tobject(tv, ref None)) in - Printtyp.reset_and_mark_loops_list [typ ti; ty0]; - fprintf ppf - ".@.@[In %s@ %a@;<1 -2>the variable %a is unbound@]" - kwd pr ti Printtyp.type_expr tv - with Not_found -> () +open Asttypes +open Misc +open Parsetree +open Typedtree +open Types +open Ctype -let explain_unbound ppf tv tl typ kwd lab = - explain_unbound_gen ppf tv tl typ kwd - (fun ppf ti -> fprintf ppf "%s%a" (lab ti) Printtyp.type_expr (typ ti)) +exception Already_bound -let explain_unbound_single ppf tv ty = - let trivial ty = - explain_unbound ppf tv [ty] (fun t -> t) "type" (fun _ -> "") in - match (Ctype.repr ty).desc with - Tobject(fi,_) -> - let (tl, rv) = Ctype.flatten_fields fi in - if rv == tv then trivial ty else - explain_unbound ppf tv tl (fun (_,_,t) -> t) - "method" (fun (lab,_,_) -> lab ^ ": ") - | Tvariant row -> - let row = Btype.row_repr row in - if row.row_more == tv then trivial ty else - explain_unbound ppf tv row.row_fields - (fun (_l,f) -> match Btype.row_field_repr f with - Rpresent (Some t) -> t - | Reither (_,[t],_,_) -> t - | Reither (_,tl,_,_) -> Btype.newgenty (Ttuple tl) - | _ -> Btype.newgenty (Ttuple[])) - "case" (fun (lab,_) -> "`" ^ lab ^ " of ") - | _ -> trivial ty +type error = + Unbound_type_variable of string + | Unbound_type_constructor of Longident.t + | Unbound_type_constructor_2 of Path.t + | Type_arity_mismatch of Longident.t * int * int + | Bound_type_variable of string + | Recursive_type + | Unbound_row_variable of Longident.t + | Type_mismatch of (type_expr * type_expr) list + | Alias_type_mismatch of (type_expr * type_expr) list + | Present_has_conjunction of string + | Present_has_no_type of string + | Constructor_mismatch of type_expr * type_expr + | Not_a_variant of type_expr + | Variant_tags of string * string + | Invalid_variable_name of string + | Cannot_quantify of string * type_expr + | Multiple_constraints_on_type of Longident.t + | Method_mismatch of string * type_expr * type_expr + | Unbound_value of Longident.t + | Unbound_constructor of Longident.t + | Unbound_label of Longident.t + | Unbound_module of Longident.t + | Unbound_class of Longident.t + | Unbound_modtype of Longident.t + | Unbound_cltype of Longident.t + | Ill_typed_functor_application of Longident.t + | Illegal_reference_to_recursive_module + | Access_functor_as_structure of Longident.t + | Apply_structure_as_functor of Longident.t + | Cannot_scrape_alias of Longident.t * Path.t + | Opened_object of Path.t option + | Not_an_object of type_expr +exception Error of Location.t * Env.t * error +exception Error_forward of Location.error -let tys_of_constr_args = function - | Types.Cstr_tuple tl -> tl - | Types.Cstr_record lbls -> List.map (fun l -> l.Types.ld_type) lbls -let report_error ppf = function - | Repeated_parameter -> - fprintf ppf "A type parameter occurs several times" - | Duplicate_constructor s -> - fprintf ppf "Two constructors are named %s" s - | Too_many_constructors -> - fprintf ppf - "@[Too many non-constant constructors@ -- maximum is %i %s@]" - (Config.max_tag + 1) "non-constant constructors" - | Duplicate_label s -> - fprintf ppf "Two labels are named %s" s - | Recursive_abbrev s -> - fprintf ppf "The type abbreviation %s is cyclic" s - | Cycle_in_def (s, ty) -> - Printtyp.reset_and_mark_loops ty; - fprintf ppf "@[The definition of %s contains a cycle:@ %a@]" - s Printtyp.type_expr ty - | Definition_mismatch (ty, errs) -> - Printtyp.reset_and_mark_loops ty; - fprintf ppf "@[@[%s@ %s@;<1 2>%a@]%a@]" - "This variant or record definition" "does not match that of type" - Printtyp.type_expr ty - (Includecore.report_type_mismatch "the original" "this" "definition") - errs - | Constraint_failed (ty, ty') -> - Printtyp.reset_and_mark_loops ty; - Printtyp.mark_loops ty'; - fprintf ppf "@[%s@ @[Type@ %a@ should be an instance of@ %a@]@]" - "Constraints are not satisfied in this type." - Printtyp.type_expr ty Printtyp.type_expr ty' - | Parameters_differ (path, ty, ty') -> - Printtyp.reset_and_mark_loops ty; - Printtyp.mark_loops ty'; - fprintf ppf - "@[In the definition of %s, type@ %a@ should be@ %a@]" - (Path.name path) Printtyp.type_expr ty Printtyp.type_expr ty' - | Inconsistent_constraint (env, trace) -> - fprintf ppf "The type constraints are not consistent.@."; - Printtyp.report_unification_error ppf env trace - (fun ppf -> fprintf ppf "Type") - (fun ppf -> fprintf ppf "is not compatible with type") - | Type_clash (env, trace) -> - Printtyp.report_unification_error ppf env trace - (function ppf -> - fprintf ppf "This type constructor expands to type") - (function ppf -> - fprintf ppf "but is used here with type") - | Null_arity_external -> - fprintf ppf "External identifiers must be functions" - | Missing_native_external -> - fprintf ppf "@[An external function with more than 5 arguments \ - requires a second stub function@ \ - for native-code compilation@]" - | Unbound_type_var (ty, decl) -> - fprintf ppf "A type variable is unbound in this type declaration"; - let ty = Ctype.repr ty in - begin match decl.type_kind, decl.type_manifest with - | Type_variant tl, _ -> - explain_unbound_gen ppf ty tl (fun c -> - let tl = tys_of_constr_args c.Types.cd_args in - Btype.newgenty (Ttuple tl) - ) - "case" (fun ppf c -> - fprintf ppf - "%s of %a" (Ident.name c.Types.cd_id) - Printtyp.constructor_arguments c.Types.cd_args) - | Type_record (tl, _), _ -> - explain_unbound ppf ty tl (fun l -> l.Types.ld_type) - "field" (fun l -> Ident.name l.Types.ld_id ^ ": ") - | Type_abstract, Some ty' -> - explain_unbound_single ppf ty ty' +type variable_context = int * (string, type_expr) Tbl.t + +(* Local definitions *) + +let instance_list = Ctype.instance_list Env.empty + +(* Narrowing unbound identifier errors. *) + +let rec narrow_unbound_lid_error : 'a. _ -> _ -> _ -> _ -> 'a = + fun env loc lid make_error -> + let check_module mlid = + try ignore (Env.lookup_module ~load:true mlid env) with + | Not_found -> + narrow_unbound_lid_error env loc mlid (fun lid -> Unbound_module lid) + | Env.Recmodule -> + raise (Error (loc, env, Illegal_reference_to_recursive_module)) + in + begin match lid with + | Longident.Lident _ -> () + | Longident.Ldot (mlid, _) -> + check_module mlid; + let md = Env.find_module (Env.lookup_module ~load:true mlid env) env in + begin match Env.scrape_alias env md.md_type with + | Mty_functor _ -> + raise (Error (loc, env, Access_functor_as_structure mlid)) + | Mty_alias(_, p) -> + raise (Error (loc, env, Cannot_scrape_alias(mlid, p))) | _ -> () end - | Unbound_type_var_ext (ty, ext) -> - fprintf ppf "A type variable is unbound in this extension constructor"; - let args = tys_of_constr_args ext.ext_args in - explain_unbound ppf ty args (fun c -> c) "type" (fun _ -> "") - | Cannot_extend_private_type path -> - fprintf ppf "@[%s@ %a@]" - "Cannot extend private type definition" - Printtyp.path path - | Not_extensible_type path -> - fprintf ppf "@[%s@ %a@ %s@]" - "Type definition" - Printtyp.path path - "is not extensible" - | Extension_mismatch (path, errs) -> - fprintf ppf "@[@[%s@ %s@;<1 2>%s@]%a@]" - "This extension" "does not match the definition of type" - (Path.name path) - (Includecore.report_type_mismatch - "the type" "this extension" "definition") - errs - | Rebind_wrong_type (lid, env, trace) -> - Printtyp.report_unification_error ppf env trace - (function ppf -> - fprintf ppf "The constructor %a@ has type" - Printtyp.longident lid) - (function ppf -> - fprintf ppf "but was expected to be of type") - | Rebind_mismatch (lid, p, p') -> - fprintf ppf - "@[%s@ %a@ %s@ %s@ %s@ %s@ %s@]" - "The constructor" Printtyp.longident lid - "extends type" (Path.name p) - "whose declaration does not match" - "the declaration of type" (Path.name p') - | Rebind_private lid -> - fprintf ppf "@[%s@ %a@ %s@]" - "The constructor" - Printtyp.longident lid - "is private" - | Bad_variance (n, v1, v2) -> - let variance (p,n,i) = - let inj = if i then "injective " else "" in - match p, n with - true, true -> inj ^ "invariant" - | true, false -> inj ^ "covariant" - | false, true -> inj ^ "contravariant" - | false, false -> if inj = "" then "unrestricted" else inj - in - let suffix n = - let teen = (n mod 100)/10 = 1 in - match n mod 10 with - | 1 when not teen -> "st" - | 2 when not teen -> "nd" - | 3 when not teen -> "rd" - | _ -> "th" - in - if n = -1 then - fprintf ppf "@[%s@ %s@ It" - "In this definition, a type variable has a variance that" - "is not reflected by its occurrence in type parameters." - else if n = -2 then - fprintf ppf "@[%s@ %s@]" - "In this definition, a type variable cannot be deduced" - "from the type parameters." - else if n = -3 then - fprintf ppf "@[%s@ %s@ It" - "In this definition, a type variable has a variance that" - "cannot be deduced from the type parameters." - else - fprintf ppf "@[%s@ %s@ The %d%s type parameter" - "In this definition, expected parameter" - "variances are not satisfied." - n (suffix n); - if n <> -2 then - fprintf ppf " was expected to be %s,@ but it is %s.@]" - (variance v2) (variance v1) - | Unavailable_type_constructor p -> - fprintf ppf "The definition of type %a@ is unavailable" Printtyp.path p - | Bad_fixed_type r -> - fprintf ppf "This fixed type %s" r - | Varying_anonymous -> - fprintf ppf "@[%s@ %s@ %s@]" - "In this GADT definition," "the variance of some parameter" - "cannot be checked" - | Val_in_structure -> - fprintf ppf "Value declarations are only allowed in signatures" - | Multiple_native_repr_attributes -> - fprintf ppf "Too many [@@unboxed]/[@@untagged] attributes" - | Cannot_unbox_or_untag_type Unboxed -> - fprintf ppf "Don't know how to unbox this type. Only float, int32, \ - int64 and nativeint can be unboxed" - | Cannot_unbox_or_untag_type Untagged -> - fprintf ppf "Don't know how to untag this type. Only int \ - can be untagged" - | Deep_unbox_or_untag_attribute kind -> - fprintf ppf - "The attribute '%s' should be attached to a direct argument or \ - result of the primitive, it should not occur deeply into its type" - (match kind with Unboxed -> "@unboxed" | Untagged -> "@untagged") - | Bad_immediate_attribute -> - fprintf ppf "@[%s@ %s@]" - "Types marked with the immediate attribute must be" - "non-pointer types like int or bool" - | Bad_unboxed_attribute msg -> - fprintf ppf "@[This type cannot be unboxed because@ %s.@]" msg - | Wrong_unboxed_type_float -> - fprintf ppf "@[This type cannot be unboxed because@ \ - it might contain both float and non-float values.@ \ - You should annotate it with [%@%@ocaml.boxed].@]" - | Boxed_and_unboxed -> - fprintf ppf "@[A type cannot be boxed and unboxed at the same time.@]" - | Nonrec_gadt -> - fprintf ppf - "@[GADT case syntax cannot be used in a 'nonrec' block.@]" - -let () = - Location.register_error_of_exn - (function - | Error (loc, err) -> - Some (Location.error_of_printer loc report_error err) + | Longident.Lapply (flid, mlid) -> + check_module flid; + let fmd = Env.find_module (Env.lookup_module ~load:true flid env) env in + begin match Env.scrape_alias env fmd.md_type with + | Mty_signature _ -> + raise (Error (loc, env, Apply_structure_as_functor flid)) + | Mty_alias(_, p) -> + raise (Error (loc, env, Cannot_scrape_alias(flid, p))) + | _ -> () + end; + check_module mlid; + let mmd = Env.find_module (Env.lookup_module ~load:true mlid env) env in + begin match Env.scrape_alias env mmd.md_type with + | Mty_alias(_, p) -> + raise (Error (loc, env, Cannot_scrape_alias(mlid, p))) | _ -> - None - ) + raise (Error (loc, env, Ill_typed_functor_application lid)) + end + end; + raise (Error (loc, env, make_error lid)) -end -module Lambda : sig -#1 "lambda.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let find_component (lookup : ?loc:_ -> _) make_error env loc lid = + try + match lid with + | Longident.Ldot (Longident.Lident "*predef*", s) -> + lookup ~loc (Longident.Lident s) Env.initial_safe_string + | _ -> + lookup ~loc lid env + with Not_found -> + narrow_unbound_lid_error env loc lid make_error + | Env.Recmodule -> + raise (Error (loc, env, Illegal_reference_to_recursive_module)) -(* The "lambda" intermediate code *) +let find_type env loc lid = + let path = + find_component Env.lookup_type (fun lid -> Unbound_type_constructor lid) + env loc lid + in + let decl = Env.find_type path env in + Builtin_attributes.check_deprecated loc decl.type_attributes (Path.name path); + (path, decl) -open Asttypes +let find_constructor = + find_component Env.lookup_constructor (fun lid -> Unbound_constructor lid) +let find_all_constructors = + find_component Env.lookup_all_constructors + (fun lid -> Unbound_constructor lid) +let find_label = + find_component Env.lookup_label (fun lid -> Unbound_label lid) +let find_all_labels = + find_component Env.lookup_all_labels (fun lid -> Unbound_label lid) -type compile_time_constant = - | Big_endian - | Word_size - | Int_size - | Max_wosize - | Ostype_unix - | Ostype_win32 - | Ostype_cygwin - | Backend_type +let find_class env loc lid = + let (path, decl) as r = + find_component Env.lookup_class (fun lid -> Unbound_class lid) env loc lid + in + Builtin_attributes.check_deprecated loc decl.cty_attributes (Path.name path); + r -type loc_kind = - | Loc_FILE - | Loc_LINE - | Loc_MODULE - | Loc_LOC - | Loc_POS +let find_value env loc lid = + Env.check_value_name (Longident.last lid) loc; + let (path, decl) as r = + find_component Env.lookup_value (fun lid -> Unbound_value lid) env loc lid + in + Builtin_attributes.check_deprecated loc decl.val_attributes (Path.name path); + r -type tag_info = - | Blk_constructor of string * int (* Number of non-const constructors*) - | Blk_tuple - | Blk_array - | Blk_variant of string - | Blk_record of string array - | Blk_module of string list - | Blk_module_export of Ident.t list - | Blk_extension_slot - | Blk_extension - (* underlying is the same as tuple, immutable block - {[ - exception A of int * int - ]} - is translated into - {[ - [A, x, y] - ]} +let lookup_module ?(load=false) env loc lid = + find_component (fun ?loc lid env -> (Env.lookup_module ~load ?loc lid env)) + (fun lid -> Unbound_module lid) env loc lid - *) - | Blk_na of string (* This string only for debugging*) - | Blk_some - | Blk_some_not_nested (* ['a option] where ['a] can not inhabit a non-like value *) - | Blk_record_inlined of string array * string * int - | Blk_record_ext of string array - | Blk_lazy_general - | Blk_lazy_forward - | Blk_class (* ocaml style class *) -val default_tag_info : tag_info +let find_module env loc lid = + let path = lookup_module ~load:true env loc lid in + let decl = Env.find_module path env in + (* No need to check for deprecated here, this is done in Env. *) + (path, decl) -val ref_tag_info : tag_info +let find_modtype env loc lid = + let (path, decl) as r = + find_component Env.lookup_modtype (fun lid -> Unbound_modtype lid) + env loc lid + in + Builtin_attributes.check_deprecated loc decl.mtd_attributes (Path.name path); + r -type field_dbg_info = - | Fld_na - | Fld_record of string - | Fld_module of string - | Fld_record_inline of string - | Fld_record_extension of string - | Fld_tuple +let find_class_type env loc lid = + let (path, decl) as r = + find_component Env.lookup_cltype (fun lid -> Unbound_cltype lid) + env loc lid + in + Builtin_attributes.check_deprecated loc decl.clty_attributes (Path.name path); + r -val ref_field_info : field_dbg_info +let unbound_constructor_error env lid = + narrow_unbound_lid_error env lid.loc lid.txt + (fun lid -> Unbound_constructor lid) -type set_field_dbg_info = - | Fld_set_na - | Fld_record_set of string - | Fld_record_inline_set of string - | Fld_record_extension_set of string +let unbound_label_error env lid = + narrow_unbound_lid_error env lid.loc lid.txt + (fun lid -> Unbound_label lid) -val ref_field_set_info : set_field_dbg_info +(* Support for first-class modules. *) -type immediate_or_pointer = - | Immediate - | Pointer +let transl_modtype_longident = ref (fun _ -> assert false) +let transl_modtype = ref (fun _ -> assert false) -type initialization_or_assignment = - | Assignment - (* Initialization of in heap values, like [caml_initialize] C primitive. The - field should not have been read before and initialization should happen - only once. *) - | Heap_initialization - (* Initialization of roots only. Compiles to a simple store. - No checks are done to preserve GC invariants. *) - | Root_initialization +let create_package_mty fake loc env (p, l) = + let l = + List.sort + (fun (s1, _t1) (s2, _t2) -> + if s1.txt = s2.txt then + raise (Error (loc, env, Multiple_constraints_on_type s1.txt)); + compare s1.txt s2.txt) + l + in + l, + List.fold_left + (fun mty (s, t) -> + let d = {ptype_name = mkloc (Longident.last s.txt) s.loc; + ptype_params = []; + ptype_cstrs = []; + ptype_kind = Ptype_abstract; + ptype_private = Asttypes.Public; + ptype_manifest = if fake then None else Some t; + ptype_attributes = []; + ptype_loc = loc} in + Ast_helper.Mty.mk ~loc + (Pmty_with (mty, [ Pwith_type ({ txt = s.txt; loc }, d) ])) + ) + (Ast_helper.Mty.mk ~loc (Pmty_ident p)) + l -type is_safe = - | Safe - | Unsafe +(* Translation of type expressions *) -type pointer_info = - | Pt_constructor of string - | Pt_variant of string - | Pt_module_alias - | Pt_builtin_boolean - | Pt_shape_none - | Pt_na +let type_variables = ref (Tbl.empty : (string, type_expr) Tbl.t) +let univars = ref ([] : (string * type_expr) list) +let pre_univars = ref ([] : type_expr list) +let used_variables = ref (Tbl.empty : (string, type_expr * Location.t) Tbl.t) -val default_pointer_info : pointer_info +let reset_type_variables () = + reset_global_level (); + Ctype.reset_reified_var_counter (); + type_variables := Tbl.empty -type primitive = - | Pidentity - | Pbytes_to_string - | Pbytes_of_string - | Pignore - | Prevapply - | Pdirapply - | Ploc of loc_kind - (* Globals *) - | Pgetglobal of Ident.t - | Psetglobal of Ident.t - (* Operations on heap blocks *) - | Pmakeblock of int * tag_info * mutable_flag * block_shape - | Pfield of int * field_dbg_info - | Pfield_computed - | Psetfield of int * immediate_or_pointer * initialization_or_assignment * set_field_dbg_info - | Psetfield_computed of immediate_or_pointer * initialization_or_assignment - | Pfloatfield of int * field_dbg_info - | Psetfloatfield of int * initialization_or_assignment * set_field_dbg_info - | Pduprecord of Types.record_representation * int - (* Force lazy values *) - | Plazyforce - (* External call *) - | Pccall of Primitive.description - (* Exceptions *) - | Praise of raise_kind - (* Boolean operations *) - | Psequand | Psequor | Pnot - (* Integer operations *) - | Pnegint | Paddint | Psubint | Pmulint - | Pdivint of is_safe | Pmodint of is_safe - | Pandint | Porint | Pxorint - | Plslint | Plsrint | Pasrint - | Pintcomp of comparison - | Poffsetint of int - | Poffsetref of int - (* Float operations *) - | Pintoffloat | Pfloatofint - | Pnegfloat | Pabsfloat - | Paddfloat | Psubfloat | Pmulfloat | Pdivfloat - | Pfloatcomp of comparison - (* String operations *) - | Pstringlength | Pstringrefu | Pstringrefs - | Pbyteslength | Pbytesrefu | Pbytessetu | Pbytesrefs | Pbytessets - (* Array operations *) - | Pmakearray of array_kind * mutable_flag - | Pduparray of array_kind * mutable_flag - (** For [Pduparray], the argument must be an immutable array. - The arguments of [Pduparray] give the kind and mutability of the - array being *produced* by the duplication. *) - | Parraylength of array_kind - | Parrayrefu of array_kind - | Parraysetu of array_kind - | Parrayrefs of array_kind - | Parraysets of array_kind - (* Test if the argument is a block or an immediate integer *) - | Pisint - (* Test if the (integer) argument is outside an interval *) - | Pisout - (* Bitvect operations *) - | Pbittest - (* Operations on boxed integers (Nativeint.t, Int32.t, Int64.t) *) - | Pbintofint of boxed_integer - | Pintofbint of boxed_integer - | Pcvtbint of boxed_integer (*source*) * boxed_integer (*destination*) - | Pnegbint of boxed_integer - | Paddbint of boxed_integer - | Psubbint of boxed_integer - | Pmulbint of boxed_integer - | Pdivbint of { size : boxed_integer; is_safe : is_safe } - | Pmodbint of { size : boxed_integer; is_safe : is_safe } - | Pandbint of boxed_integer - | Porbint of boxed_integer - | Pxorbint of boxed_integer - | Plslbint of boxed_integer - | Plsrbint of boxed_integer - | Pasrbint of boxed_integer - | Pbintcomp of boxed_integer * comparison - (* Operations on big arrays: (unsafe, #dimensions, kind, layout) *) - | Pbigarrayref of bool * int * bigarray_kind * bigarray_layout - | Pbigarrayset of bool * int * bigarray_kind * bigarray_layout - (* size of the nth dimension of a big array *) - | Pbigarraydim of int - (* load/set 16,32,64 bits from a string: (unsafe)*) - | Pstring_load_16 of bool - | Pstring_load_32 of bool - | Pstring_load_64 of bool - | Pstring_set_16 of bool - | Pstring_set_32 of bool - | Pstring_set_64 of bool - (* load/set 16,32,64 bits from a - (char, int8_unsigned_elt, c_layout) Bigarray.Array1.t : (unsafe) *) - | Pbigstring_load_16 of bool - | Pbigstring_load_32 of bool - | Pbigstring_load_64 of bool - | Pbigstring_set_16 of bool - | Pbigstring_set_32 of bool - | Pbigstring_set_64 of bool - (* Compile time constants *) - | Pctconst of compile_time_constant - (* byte swap *) - | Pbswap16 - | Pbbswap of boxed_integer - (* Integer to external pointer *) - | Pint_as_pointer - (* Inhibition of optimisation *) - | Popaque +let narrow () = + (increase_global_level (), !type_variables) -and comparison = - Ceq | Cneq | Clt | Cgt | Cle | Cge +let widen (gl, tv) = + restore_global_level gl; + type_variables := tv -and array_kind = - Pgenarray | Paddrarray | Pintarray | Pfloatarray +let strict_ident c = (c = '_' || c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z') -and value_kind = - Pgenval | Pfloatval | Pboxedintval of boxed_integer | Pintval +let validate_name = function + None -> None + | Some name as s -> + if name <> "" && strict_ident name.[0] then s else None -and block_shape = - value_kind list option +let new_global_var ?name () = + new_global_var ?name:(validate_name name) () +let newvar ?name () = + newvar ?name:(validate_name name) () -and boxed_integer = Primitive.boxed_integer = - Pnativeint | Pint32 | Pint64 +let type_variable loc name = + try + Tbl.find name !type_variables + with Not_found -> + raise(Error(loc, Env.empty, Unbound_type_variable ("'" ^ name))) + +let transl_type_param env styp = + let loc = styp.ptyp_loc in + match styp.ptyp_desc with + Ptyp_any -> + let ty = new_global_var ~name:"_" () in + { ctyp_desc = Ttyp_any; ctyp_type = ty; ctyp_env = env; + ctyp_loc = loc; ctyp_attributes = styp.ptyp_attributes; } + | Ptyp_var name -> + let ty = + try + if name <> "" && name.[0] = '_' then + raise (Error (loc, Env.empty, Invalid_variable_name ("'" ^ name))); + ignore (Tbl.find name !type_variables); + raise Already_bound + with Not_found -> + let v = new_global_var ~name () in + type_variables := Tbl.add name v !type_variables; + v + in + { ctyp_desc = Ttyp_var name; ctyp_type = ty; ctyp_env = env; + ctyp_loc = loc; ctyp_attributes = styp.ptyp_attributes; } + | _ -> assert false + +let transl_type_param env styp = + (* Currently useless, since type parameters cannot hold attributes + (but this could easily be lifted in the future). *) + Builtin_attributes.warning_scope styp.ptyp_attributes + (fun () -> transl_type_param env styp) + + +let new_pre_univar ?name () = + let v = newvar ?name () in pre_univars := v :: !pre_univars; v + +let rec swap_list = function + x :: y :: l -> y :: x :: swap_list l + | l -> l + +type policy = Fixed | Extensible | Univars + +let rec transl_type env policy styp = + Builtin_attributes.warning_scope styp.ptyp_attributes + (fun () -> transl_type_aux env policy styp) + +and transl_type_aux env policy styp = + let loc = styp.ptyp_loc in + let ctyp ctyp_desc ctyp_type = + { ctyp_desc; ctyp_type; ctyp_env = env; + ctyp_loc = loc; ctyp_attributes = styp.ptyp_attributes } + in + match styp.ptyp_desc with + Ptyp_any -> + let ty = + if policy = Univars then new_pre_univar () else + if policy = Fixed then + raise (Error (styp.ptyp_loc, env, Unbound_type_variable "_")) + else newvar () + in + ctyp Ttyp_any ty + | Ptyp_var name -> + let ty = + if name <> "" && name.[0] = '_' then + raise (Error (styp.ptyp_loc, env, Invalid_variable_name ("'" ^ name))); + begin try + instance env (List.assoc name !univars) + with Not_found -> try + instance env (fst(Tbl.find name !used_variables)) + with Not_found -> + let v = + if policy = Univars then new_pre_univar ~name () else newvar ~name () + in + used_variables := Tbl.add name (v, styp.ptyp_loc) !used_variables; + v + end + in + ctyp (Ttyp_var name) ty + | Ptyp_arrow(l, st1, st2) -> + let cty1 = transl_type env policy st1 in + let cty2 = transl_type env policy st2 in + let ty1 = cty1.ctyp_type in + let ty1 = + if Btype.is_optional l + then newty (Tconstr(Predef.path_option,[ty1], ref Mnil)) + else ty1 in + let ty = newty (Tarrow(l, ty1, cty2.ctyp_type, Cok)) in + ctyp (Ttyp_arrow (l, cty1, cty2)) ty + | Ptyp_tuple stl -> + assert (List.length stl >= 2); + let ctys = List.map (transl_type env policy) stl in + let ty = newty (Ttuple (List.map (fun ctyp -> ctyp.ctyp_type) ctys)) in + ctyp (Ttyp_tuple ctys) ty + | Ptyp_constr(lid, stl) -> + let (path, decl) = find_type env lid.loc lid.txt in + let stl = + match stl with + | [ {ptyp_desc=Ptyp_any} as t ] when decl.type_arity > 1 -> + List.map (fun _ -> t) decl.type_params + | _ -> stl + in + if List.length stl <> decl.type_arity then + raise(Error(styp.ptyp_loc, env, + Type_arity_mismatch(lid.txt, decl.type_arity, + List.length stl))); + let args = List.map (transl_type env policy) stl in + let params = instance_list decl.type_params in + let unify_param = + match decl.type_manifest with + None -> unify_var + | Some ty -> + if (repr ty).level = Btype.generic_level then unify_var else unify + in + List.iter2 + (fun (sty, cty) ty' -> + try unify_param env ty' cty.ctyp_type with Unify trace -> + raise (Error(sty.ptyp_loc, env, Type_mismatch (swap_list trace)))) + (List.combine stl args) params; + let constr = + newconstr path (List.map (fun ctyp -> ctyp.ctyp_type) args) in + begin try + Ctype.enforce_constraints env constr + with Unify trace -> + raise (Error(styp.ptyp_loc, env, Type_mismatch trace)) + end; + ctyp (Ttyp_constr (path, lid, args)) constr + | Ptyp_object (fields, o) -> + let ty, fields = transl_fields env policy o fields in + ctyp (Ttyp_object (fields, o)) (newobj ty) + | Ptyp_class(lid, stl) -> + let (path, decl, _is_variant) = + try + let path = Env.lookup_type lid.txt env in + let decl = Env.find_type path env in + let rec check decl = + match decl.type_manifest with + None -> raise Not_found + | Some ty -> + match (repr ty).desc with + Tvariant row when Btype.static_row row -> () + | Tconstr (path, _, _) -> + check (Env.find_type path env) + | _ -> raise Not_found + in check decl; + Location.deprecated styp.ptyp_loc + "old syntax for polymorphic variant type"; + (path, decl,true) + with Not_found -> try + let lid2 = + match lid.txt with + Longident.Lident s -> Longident.Lident ("#" ^ s) + | Longident.Ldot(r, s) -> Longident.Ldot (r, "#" ^ s) + | Longident.Lapply(_, _) -> fatal_error "Typetexp.transl_type" + in + let path = Env.lookup_type lid2 env in + let decl = Env.find_type path env in + (path, decl, false) + with Not_found -> + ignore (find_class env lid.loc lid.txt); assert false + in + if List.length stl <> decl.type_arity then + raise(Error(styp.ptyp_loc, env, + Type_arity_mismatch(lid.txt, decl.type_arity, + List.length stl))); + let args = List.map (transl_type env policy) stl in + let params = instance_list decl.type_params in + List.iter2 + (fun (sty, cty) ty' -> + try unify_var env ty' cty.ctyp_type with Unify trace -> + raise (Error(sty.ptyp_loc, env, Type_mismatch (swap_list trace)))) + (List.combine stl args) params; + let ty_args = List.map (fun ctyp -> ctyp.ctyp_type) args in + let ty = + try Ctype.expand_head env (newconstr path ty_args) + with Unify trace -> + raise (Error(styp.ptyp_loc, env, Type_mismatch trace)) + in + let ty = match ty.desc with + Tvariant row -> + let row = Btype.row_repr row in + let fields = + List.map + (fun (l,f) -> l, + match Btype.row_field_repr f with + | Rpresent (Some ty) -> + Reither(false, [ty], false, ref None) + | Rpresent None -> + Reither (true, [], false, ref None) + | _ -> f) + row.row_fields + in + let row = { row_closed = true; row_fields = fields; + row_bound = (); row_name = Some (path, ty_args); + row_fixed = false; row_more = newvar () } in + let static = Btype.static_row row in + let row = + if static then { row with row_more = newty Tnil } + else if policy <> Univars then row + else { row with row_more = new_pre_univar () } + in + newty (Tvariant row) + | Tobject (fi, _) -> + let _, tv = flatten_fields fi in + if policy = Univars then pre_univars := tv :: !pre_univars; + ty + | _ -> + assert false + in + ctyp (Ttyp_class (path, lid, args)) ty + | Ptyp_alias(st, alias) -> + let cty = + try + let t = + try List.assoc alias !univars + with Not_found -> + instance env (fst(Tbl.find alias !used_variables)) + in + let ty = transl_type env policy st in + begin try unify_var env t ty.ctyp_type with Unify trace -> + let trace = swap_list trace in + raise(Error(styp.ptyp_loc, env, Alias_type_mismatch trace)) + end; + ty + with Not_found -> + if !Clflags.principal then begin_def (); + let t = newvar () in + used_variables := Tbl.add alias (t, styp.ptyp_loc) !used_variables; + let ty = transl_type env policy st in + begin try unify_var env t ty.ctyp_type with Unify trace -> + let trace = swap_list trace in + raise(Error(styp.ptyp_loc, env, Alias_type_mismatch trace)) + end; + if !Clflags.principal then begin + end_def (); + generalize_structure t; + end; + let t = instance env t in + let px = Btype.proxy t in + begin match px.desc with + | Tvar None -> Btype.log_type px; px.desc <- Tvar (Some alias) + | Tunivar None -> Btype.log_type px; px.desc <- Tunivar (Some alias) + | _ -> () + end; + { ty with ctyp_type = t } + in + ctyp (Ttyp_alias (cty, alias)) cty.ctyp_type + | Ptyp_variant(fields, closed, present) -> + let name = ref None in + let mkfield l f = + newty (Tvariant {row_fields=[l,f]; row_more=newvar(); + row_bound=(); row_closed=true; + row_fixed=false; row_name=None}) in + let hfields = Hashtbl.create 17 in + let add_typed_field loc l f = + let h = Btype.hash_variant l in + try + let (l',f') = Hashtbl.find hfields h in + (* Check for tag conflicts *) + if l <> l' then raise(Error(styp.ptyp_loc, env, Variant_tags(l, l'))); + let ty = mkfield l f and ty' = mkfield l f' in + if equal env false [ty] [ty'] then () else + try unify env ty ty' + with Unify _trace -> + raise(Error(loc, env, Constructor_mismatch (ty,ty'))) + with Not_found -> + Hashtbl.add hfields h (l,f) + in + let add_field = function + Rtag (l, attrs, c, stl) -> + name := None; + let tl = + Builtin_attributes.warning_scope attrs + (fun () -> List.map (transl_type env policy) stl) + in + let f = match present with + Some present when not (List.mem l.txt present) -> + let ty_tl = List.map (fun cty -> cty.ctyp_type) tl in + Reither(c, ty_tl, false, ref None) + | _ -> + if List.length stl > 1 || c && stl <> [] then + raise(Error(styp.ptyp_loc, env, + Present_has_conjunction l.txt)); + match tl with [] -> Rpresent None + | st :: _ -> + Rpresent (Some st.ctyp_type) + in + add_typed_field styp.ptyp_loc l.txt f; + Ttag (l,attrs,c,tl) + | Rinherit sty -> + let cty = transl_type env policy sty in + let ty = cty.ctyp_type in + let nm = + match repr cty.ctyp_type with + {desc=Tconstr(p, tl, _)} -> Some(p, tl) + | _ -> None + in + begin try + (* Set name if there are no fields yet *) + Hashtbl.iter (fun _ _ -> raise Exit) hfields; + name := nm + with Exit -> + (* Unset it otherwise *) + name := None + end; + let fl = match expand_head env cty.ctyp_type, nm with + {desc=Tvariant row}, _ when Btype.static_row row -> + let row = Btype.row_repr row in + row.row_fields + | {desc=Tvar _}, Some(p, _) -> + raise(Error(sty.ptyp_loc, env, Unbound_type_constructor_2 p)) + | _ -> + raise(Error(sty.ptyp_loc, env, Not_a_variant ty)) + in + List.iter + (fun (l, f) -> + let f = match present with + Some present when not (List.mem l present) -> + begin match f with + Rpresent(Some ty) -> + Reither(false, [ty], false, ref None) + | Rpresent None -> + Reither(true, [], false, ref None) + | _ -> + assert false + end + | _ -> f + in + add_typed_field sty.ptyp_loc l f) + fl; + Tinherit cty + in + let tfields = List.map add_field fields in + let fields = Hashtbl.fold (fun _ p l -> p :: l) hfields [] in + begin match present with None -> () + | Some present -> + List.iter + (fun l -> if not (List.mem_assoc l fields) then + raise(Error(styp.ptyp_loc, env, Present_has_no_type l))) + present + end; + let row = + { row_fields = List.rev fields; row_more = newvar (); + row_bound = (); row_closed = (closed = Closed); + row_fixed = false; row_name = !name } in + let static = Btype.static_row row in + let row = + if static then { row with row_more = newty Tnil } + else if policy <> Univars then row + else { row with row_more = new_pre_univar () } + in + let ty = newty (Tvariant row) in + ctyp (Ttyp_variant (tfields, closed, present)) ty + | Ptyp_poly(vars, st) -> + let vars = List.map (fun v -> v.txt) vars in + begin_def(); + let new_univars = List.map (fun name -> name, newvar ~name ()) vars in + let old_univars = !univars in + univars := new_univars @ !univars; + let cty = transl_type env policy st in + let ty = cty.ctyp_type in + univars := old_univars; + end_def(); + generalize ty; + let ty_list = + List.fold_left + (fun tyl (name, ty1) -> + let v = Btype.proxy ty1 in + if deep_occur v ty then begin + match v.desc with + Tvar name when v.level = Btype.generic_level -> + v.desc <- Tunivar name; + v :: tyl + | _ -> + raise (Error (styp.ptyp_loc, env, Cannot_quantify (name, v))) + end else tyl) + [] new_univars + in + let ty' = Btype.newgenty (Tpoly(ty, List.rev ty_list)) in + unify_var env (newvar()) ty'; + ctyp (Ttyp_poly (vars, cty)) ty' + | Ptyp_package (p, l) -> + let l, mty = create_package_mty true styp.ptyp_loc env (p, l) in + let z = narrow () in + let mty = !transl_modtype env mty in + widen z; + let ptys = List.map (fun (s, pty) -> + s, transl_type env policy pty + ) l in + let path = !transl_modtype_longident styp.ptyp_loc env p.txt in + let ty = newty (Tpackage (path, + List.map (fun (s, _pty) -> s.txt) l, + List.map (fun (_,cty) -> cty.ctyp_type) ptys)) + in + ctyp (Ttyp_package { + pack_path = path; + pack_type = mty.mty_type; + pack_fields = ptys; + pack_txt = p; + }) ty + | Ptyp_extension ext -> + raise (Error_forward (Builtin_attributes.error_of_extension ext)) -and bigarray_kind = - Pbigarray_unknown - | Pbigarray_float32 | Pbigarray_float64 - | Pbigarray_sint8 | Pbigarray_uint8 - | Pbigarray_sint16 | Pbigarray_uint16 - | Pbigarray_int32 | Pbigarray_int64 - | Pbigarray_caml_int | Pbigarray_native_int - | Pbigarray_complex32 | Pbigarray_complex64 +and transl_poly_type env policy t = + transl_type env policy (Ast_helper.Typ.force_poly t) -and bigarray_layout = - Pbigarray_unknown_layout - | Pbigarray_c_layout - | Pbigarray_fortran_layout +and transl_fields env policy o fields = + let hfields = Hashtbl.create 17 in + let add_typed_field loc l ty = + try + let ty' = Hashtbl.find hfields l in + if equal env false [ty] [ty'] then () else + try unify env ty ty' + with Unify _trace -> + raise(Error(loc, env, Method_mismatch (l, ty, ty'))) + with Not_found -> + Hashtbl.add hfields l ty in + let add_field = function + | Otag (s, a, ty1) -> begin + let ty1 = + Builtin_attributes.warning_scope a + (fun () -> transl_poly_type env policy ty1) + in + let field = OTtag (s, a, ty1) in + add_typed_field ty1.ctyp_loc s.txt ty1.ctyp_type; + field + end + | Oinherit sty -> begin + let cty = transl_type env policy sty in + let nm = + match repr cty.ctyp_type with + {desc=Tconstr(p, _, _)} -> Some p + | _ -> None in + let t = expand_head env cty.ctyp_type in + match t, nm with + {desc=Tobject ({desc=(Tfield _ | Tnil) as tf}, _)}, _ -> begin + if opened_object t then + raise (Error (sty.ptyp_loc, env, Opened_object nm)); + let rec iter_add = function + | Tfield (s, _k, ty1, ty2) -> begin + add_typed_field sty.ptyp_loc s ty1; + iter_add ty2.desc + end + | Tnil -> () + | _ -> assert false in + iter_add tf; + OTinherit cty + end + | {desc=Tvar _}, Some p -> + raise (Error (sty.ptyp_loc, env, Unbound_type_constructor_2 p)) + | _ -> raise (Error (sty.ptyp_loc, env, Not_an_object t)) + end in + let object_fields = List.map add_field fields in + let fields = Hashtbl.fold (fun s ty l -> (s, ty) :: l) hfields [] in + let ty_init = + match o, policy with + | Closed, _ -> newty Tnil + | Open, Univars -> new_pre_univar () + | Open, _ -> newvar () in + let ty = List.fold_left (fun ty (s, ty') -> + newty (Tfield (s, Fpresent, ty', ty))) ty_init fields in + ty, object_fields -and raise_kind = - | Raise_regular - | Raise_reraise - | Raise_notrace -type structured_constant = - Const_base of constant - | Const_pointer of int * pointer_info - | Const_block of int * tag_info * structured_constant list - | Const_float_array of string list - | Const_immstring of string +(* Make the rows "fixed" in this type, to make universal check easier *) +let rec make_fixed_univars ty = + let ty = repr ty in + if ty.level >= Btype.lowest_level then begin + Btype.mark_type_node ty; + match ty.desc with + | Tvariant row -> + let row = Btype.row_repr row in + if Btype.is_Tunivar (Btype.row_more row) then + ty.desc <- Tvariant + {row with row_fixed=true; + row_fields = List.map + (fun (s,f as p) -> match Btype.row_field_repr f with + Reither (c, tl, _m, r) -> s, Reither (c, tl, true, r) + | _ -> p) + row.row_fields}; + Btype.iter_row make_fixed_univars row + | _ -> + Btype.iter_type_expr make_fixed_univars ty + end -type inline_attribute = - | Always_inline (* [@inline] or [@inline always] *) - | Never_inline (* [@inline never] *) - | Unroll of int (* [@unroll x] *) - | Default_inline (* no [@inline] attribute *) +let make_fixed_univars ty = + make_fixed_univars ty; + Btype.unmark_type ty -type specialise_attribute = - | Always_specialise (* [@specialise] or [@specialise always] *) - | Never_specialise (* [@specialise never] *) - | Default_specialise (* no [@specialise] attribute *) +let create_package_mty = create_package_mty false -type function_kind = Curried | Tupled +let globalize_used_variables env fixed = + let r = ref [] in + Tbl.iter + (fun name (ty, loc) -> + let v = new_global_var () in + let snap = Btype.snapshot () in + if try unify env v ty; true with _ -> Btype.backtrack snap; false + then try + r := (loc, v, Tbl.find name !type_variables) :: !r + with Not_found -> + if fixed && Btype.is_Tvar (repr ty) then + raise(Error(loc, env, Unbound_type_variable ("'"^name))); + let v2 = new_global_var () in + r := (loc, v, v2) :: !r; + type_variables := Tbl.add name v2 !type_variables) + !used_variables; + used_variables := Tbl.empty; + fun () -> + List.iter + (function (loc, t1, t2) -> + try unify env t1 t2 with Unify trace -> + raise (Error(loc, env, Type_mismatch trace))) + !r -type let_kind = Strict | Alias | StrictOpt | Variable -(* Meaning of kinds for let x = e in e': - Strict: e may have side-effects; always evaluate e first - (If e is a simple expression, e.g. a variable or constant, - we may still substitute e'[x/e].) - Alias: e is pure, we can substitute e'[x/e] if x has 0 or 1 occurrences - in e' - StrictOpt: e does not have side-effects, but depend on the store; - we can discard e if x does not appear in e' - Variable: the variable x is assigned later in e' - *) +let transl_simple_type env fixed styp = + univars := []; used_variables := Tbl.empty; + let typ = transl_type env (if fixed then Fixed else Extensible) styp in + globalize_used_variables env fixed (); + make_fixed_univars typ.ctyp_type; + typ -type public_info = string option (* label name *) +let transl_simple_type_univars env styp = + univars := []; used_variables := Tbl.empty; pre_univars := []; + begin_def (); + let typ = transl_type env Univars styp in + (* Only keep already global variables in used_variables *) + let new_variables = !used_variables in + used_variables := Tbl.empty; + Tbl.iter + (fun name p -> + if Tbl.mem name !type_variables then + used_variables := Tbl.add name p !used_variables) + new_variables; + globalize_used_variables env false (); + end_def (); + generalize typ.ctyp_type; + let univs = + List.fold_left + (fun acc v -> + let v = repr v in + match v.desc with + Tvar name when v.level = Btype.generic_level -> + v.desc <- Tunivar name; v :: acc + | _ -> acc) + [] !pre_univars + in + make_fixed_univars typ.ctyp_type; + { typ with ctyp_type = + instance env (Btype.newgenty (Tpoly (typ.ctyp_type, univs))) } -type meth_kind = Self | Public of public_info | Cached +let transl_simple_type_delayed env styp = + univars := []; used_variables := Tbl.empty; + let typ = transl_type env Extensible styp in + make_fixed_univars typ.ctyp_type; + (typ, globalize_used_variables env false) -type shared_code = (int * int) list (* stack size -> code label *) +let transl_type_scheme env styp = + reset_type_variables(); + begin_def(); + let typ = transl_simple_type env false styp in + end_def(); + generalize typ.ctyp_type; + typ -type function_attribute = { - inline : inline_attribute; - specialise : specialise_attribute; - is_a_functor: bool; - stub: bool; -} -type switch_names = {consts: string array; blocks: string array} +(* Error report *) -type lambda = - Lvar of Ident.t - | Lconst of structured_constant - | Lapply of lambda_apply - | Lfunction of lfunction - | Llet of let_kind * value_kind * Ident.t * lambda * lambda - | Lletrec of (Ident.t * lambda) list * lambda - | Lprim of primitive * lambda list * Location.t - | Lswitch of lambda * lambda_switch * Location.t -(* switch on strings, clauses are sorted by string order, - strings are pairwise distinct *) - | Lstringswitch of - lambda * (string * lambda) list * lambda option * Location.t - | Lstaticraise of int * lambda list - | Lstaticcatch of lambda * (int * Ident.t list) * lambda - | Ltrywith of lambda * Ident.t * lambda - | Lifthenelse of lambda * lambda * lambda - | Lsequence of lambda * lambda - | Lwhile of lambda * lambda - | Lfor of Ident.t * lambda * lambda * direction_flag * lambda - | Lassign of Ident.t * lambda - | Lsend of meth_kind * lambda * lambda * lambda list * Location.t - | Levent of lambda * lambda_event - | Lifused of Ident.t * lambda +open Format +open Printtyp -and lfunction = - { kind: function_kind; - params: Ident.t list; - body: lambda; - attr: function_attribute; (* specified with [@inline] attribute *) - loc : Location.t; } +let spellcheck ppf fold env lid = + let choices ~path name = + let env = fold (fun x xs -> x::xs) path env [] in + Misc.spellcheck env name in + match lid with + | Longident.Lapply _ -> () + | Longident.Lident s -> + Misc.did_you_mean ppf (fun () -> choices ~path:None s) + | Longident.Ldot (r, s) -> + Misc.did_you_mean ppf (fun () -> choices ~path:(Some r) s) -and lambda_apply = - { ap_func : lambda; - ap_args : lambda list; - ap_loc : Location.t; - ap_should_be_tailcall : bool; (* true if [@tailcall] was specified *) - ap_inlined : inline_attribute; (* specified with the [@inlined] attribute *) - ap_specialised : specialise_attribute; } +let fold_descr fold get_name f = fold (fun descr acc -> f (get_name descr) acc) +let fold_simple fold4 f = fold4 (fun name _path _descr acc -> f name acc) -and lambda_switch = - { sw_numconsts: int; (* Number of integer cases *) - sw_consts: (int * lambda) list; (* Integer cases *) - sw_numblocks: int; (* Number of tag block cases *) - sw_blocks: (int * lambda) list; (* Tag block cases *) - sw_failaction : lambda option; (* Action to take if failure *) - sw_names: switch_names option } -and lambda_event = - { lev_loc: Location.t; - lev_kind: lambda_event_kind; - lev_repr: int ref option; - lev_env: Env.summary } +let fold_values = fold_simple Env.fold_values +let fold_types = fold_simple Env.fold_types +let fold_modules = fold_simple Env.fold_modules +let fold_constructors = fold_descr Env.fold_constructors (fun d -> d.cstr_name) +let fold_labels = fold_descr Env.fold_labels (fun d -> d.lbl_name) +let fold_classs = fold_simple Env.fold_classs +let fold_modtypes = fold_simple Env.fold_modtypes +let fold_cltypes = fold_simple Env.fold_cltypes -and lambda_event_kind = - Lev_before - | Lev_after of Types.type_expr - | Lev_function - | Lev_pseudo - | Lev_module_definition of Ident.t +let report_error env ppf = function + | Unbound_type_variable name -> + (* we don't use "spellcheck" here: the function that raises this + error seems not to be called anywhere, so it's unclear how it + should be handled *) + fprintf ppf "Unbound type parameter %s@." name + | Unbound_type_constructor lid -> + fprintf ppf "Unbound type constructor %a" longident lid; + spellcheck ppf fold_types env lid; + | Unbound_type_constructor_2 p -> + fprintf ppf "The type constructor@ %a@ is not yet completely defined" + path p + | Type_arity_mismatch(lid, expected, provided) -> + fprintf ppf + "@[The type constructor %a@ expects %i argument(s),@ \ + but is here applied to %i argument(s)@]" + longident lid expected provided + | Bound_type_variable name -> + fprintf ppf "Already bound type parameter '%s" name + | Recursive_type -> + fprintf ppf "This type is recursive" + | Unbound_row_variable lid -> + (* we don't use "spellcheck" here: this error is not raised + anywhere so it's unclear how it should be handled *) + fprintf ppf "Unbound row variable in #%a" longident lid + | Type_mismatch trace -> + Printtyp.report_unification_error ppf Env.empty trace + (function ppf -> + fprintf ppf "This type") + (function ppf -> + fprintf ppf "should be an instance of type") + | Alias_type_mismatch trace -> + Printtyp.report_unification_error ppf Env.empty trace + (function ppf -> + fprintf ppf "This alias is bound to type") + (function ppf -> + fprintf ppf "but is used as an instance of type") + | Present_has_conjunction l -> + fprintf ppf "The present constructor %s has a conjunctive type" l + | Present_has_no_type l -> + fprintf ppf "The present constructor %s has no type" l + | Constructor_mismatch (ty, ty') -> + wrap_printing_env env (fun () -> + Printtyp.reset_and_mark_loops_list [ty; ty']; + fprintf ppf "@[%s %a@ %s@ %a@]" + "This variant type contains a constructor" + Printtyp.type_expr ty + "which should be" + Printtyp.type_expr ty') + | Not_a_variant ty -> + Printtyp.reset_and_mark_loops ty; + fprintf ppf + "@[The type %a@ does not expand to a polymorphic variant type@]" + Printtyp.type_expr ty; + begin match ty.desc with + | Tvar (Some s) -> + (* PR#7012: help the user that wrote 'Foo instead of `Foo *) + Misc.did_you_mean ppf (fun () -> ["`" ^ s]) + | _ -> () + end + | Variant_tags (lab1, lab2) -> + fprintf ppf + "@[Variant tags `%s@ and `%s have the same hash value.@ %s@]" + lab1 lab2 "Change one of them." + | Invalid_variable_name name -> + fprintf ppf "The type variable name %s is not allowed in programs" name + | Cannot_quantify (name, v) -> + fprintf ppf + "@[The universal type variable '%s cannot be generalized:@ %s.@]" + name + (if Btype.is_Tvar v then "it escapes its scope" else + if Btype.is_Tunivar v then "it is already bound to another variable" + else "it is not a variable") + | Multiple_constraints_on_type s -> + fprintf ppf "Multiple constraints for type %a" longident s + | Method_mismatch (l, ty, ty') -> + wrap_printing_env env (fun () -> + Printtyp.reset_and_mark_loops_list [ty; ty']; + fprintf ppf "@[Method '%s' has type %a,@ which should be %a@]" + l Printtyp.type_expr ty Printtyp.type_expr ty') + | Unbound_value lid -> + fprintf ppf "Unbound value %a" longident lid; + spellcheck ppf fold_values env lid; + | Unbound_module lid -> + fprintf ppf "Unbound module %a" longident lid; + spellcheck ppf fold_modules env lid; + | Unbound_constructor lid -> + fprintf ppf "Unbound constructor %a" longident lid; + spellcheck ppf fold_constructors env lid; + | Unbound_label lid -> + fprintf ppf "Unbound record field %a" longident lid; + spellcheck ppf fold_labels env lid; + | Unbound_class lid -> + fprintf ppf "Unbound class %a" longident lid; + spellcheck ppf fold_classs env lid; + | Unbound_modtype lid -> + fprintf ppf "Unbound module type %a" longident lid; + spellcheck ppf fold_modtypes env lid; + | Unbound_cltype lid -> + fprintf ppf "Unbound class type %a" longident lid; + spellcheck ppf fold_cltypes env lid; + | Ill_typed_functor_application lid -> + fprintf ppf "Ill-typed functor application %a" longident lid + | Illegal_reference_to_recursive_module -> + fprintf ppf "Illegal recursive module reference" + | Access_functor_as_structure lid -> + fprintf ppf "The module %a is a functor, not a structure" longident lid + | Apply_structure_as_functor lid -> + fprintf ppf "The module %a is a structure, not a functor" longident lid + | Cannot_scrape_alias(lid, p) -> + fprintf ppf + "The module %a is an alias for module %a, which is missing" + longident lid path p + | Opened_object nm -> + fprintf ppf + "Illegal open object type%a" + (fun ppf -> function + Some p -> fprintf ppf "@ %a" path p + | None -> fprintf ppf "") nm + | Not_an_object ty -> + Printtyp.reset_and_mark_loops ty; + fprintf ppf "@[The type %a@ is not an object type@]" + Printtyp.type_expr ty -type program = - { module_ident : Ident.t; - main_module_block_size : int; - required_globals : Ident.Set.t; (* Modules whose initializer side effects - must occur before [code]. *) - code : lambda } -(* Lambda code for the middle-end. - * In the closure case the code is a sequence of assignments to a - preallocated block of size [main_module_block_size] using - (Setfield(Getglobal(module_ident))). The size is used to preallocate - the block. - * In the flambda case the code is an expression returning a block - value of size [main_module_block_size]. The size is used to build - the module root as an initialize_symbol - Initialize_symbol(module_name, 0, - [getfield 0; ...; getfield (main_module_block_size - 1)]) -*) +let () = + Location.register_error_of_exn + (function + | Error (loc, env, err) -> + Some (Location.error_of_printer loc (report_error env) err) + | Error_forward err -> + Some err + | _ -> + None + ) -(* Sharing key *) -val make_key: lambda -> lambda option +end +module Typedecl : sig +#1 "typedecl.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -val const_unit: structured_constant -val lambda_assert_false: lambda -val lambda_unit: lambda -val name_lambda: let_kind -> lambda -> (Ident.t -> lambda) -> lambda -val name_lambda_list: lambda list -> (lambda list -> lambda) -> lambda +(* Typing of type definitions and primitive definitions *) -val iter: (lambda -> unit) -> lambda -> unit -module IdentSet: Set.S with type elt = Ident.t -val free_variables: lambda -> IdentSet.t -val free_methods: lambda -> IdentSet.t +open Types +open Format -val transl_normal_path: Path.t -> lambda (* Path.t is already normal *) -val transl_path: ?loc:Location.t -> Env.t -> Path.t -> lambda -[@@ocaml.deprecated "use transl_{module,value,extension,class}_path instead"] +val transl_type_decl: + Env.t -> Asttypes.rec_flag -> Parsetree.type_declaration list -> + Typedtree.type_declaration list * Env.t -val transl_module_path: ?loc:Location.t -> Env.t -> Path.t -> lambda -val transl_value_path: ?loc:Location.t -> Env.t -> Path.t -> lambda -val transl_extension_path: ?loc:Location.t -> Env.t -> Path.t -> lambda -val transl_class_path: ?loc:Location.t -> Env.t -> Path.t -> lambda +val transl_exception: + Env.t -> + Parsetree.extension_constructor -> Typedtree.extension_constructor * Env.t -val make_sequence: ('a -> lambda) -> 'a list -> lambda +val transl_type_extension: + bool -> Env.t -> Location.t -> Parsetree.type_extension -> + Typedtree.type_extension * Env.t -val subst_lambda: lambda Ident.tbl -> lambda -> lambda -val map : (lambda -> lambda) -> lambda -> lambda -val bind : let_kind -> Ident.t -> lambda -> lambda -> lambda +val transl_value_decl: + Env.t -> Location.t -> + Parsetree.value_description -> Typedtree.value_description * Env.t -val commute_comparison : comparison -> comparison -val negate_comparison : comparison -> comparison +val transl_with_constraint: + Env.t -> Ident.t -> Path.t option -> Types.type_declaration -> + Parsetree.type_declaration -> Typedtree.type_declaration -val default_function_attribute : function_attribute -val default_stub_attribute : function_attribute +val abstract_type_decl: int -> type_declaration +val approx_type_decl: + Parsetree.type_declaration list -> + (Ident.t * type_declaration) list +val check_recmod_typedecl: + Env.t -> Location.t -> Ident.t list -> Path.t -> type_declaration -> unit +val check_coherence: + Env.t -> Location.t -> Ident.t -> type_declaration -> unit -(***********************) -(* For static failures *) -(***********************) +(* for fixed types *) +val is_fixed_type : Parsetree.type_declaration -> bool -(* Get a new static failure ident *) -val next_raise_count : unit -> int -val next_negative_raise_count : unit -> int - (* Negative raise counts are used to compile 'match ... with - exception x -> ...'. This disabled some simplifications - performed by the Simplif module that assume that static raises - are in tail position in their handler. *) +(* for typeclass.ml *) +val compute_variance_decls: + Env.t -> + (Ident.t * Types.type_declaration * Types.type_declaration * + Types.class_declaration * Types.class_type_declaration * + 'a Typedtree.class_infos) list -> + (Types.type_declaration * Types.type_declaration * + Types.class_declaration * Types.class_type_declaration) list -val staticfail : lambda (* Anticipated static failure *) +(* for typeopt.ml *) +val get_unboxed_type_representation: Env.t -> type_expr -> type_expr option -(* Check anticipated failure, substitute its final value *) -val is_guarded: lambda -> bool -val patch_guarded : lambda -> lambda -> lambda -val raise_kind: raise_kind -> string -val lam_of_loc : loc_kind -> Location.t -> lambda +type native_repr_kind = Unboxed | Untagged -val merge_inline_attributes - : inline_attribute - -> inline_attribute - -> inline_attribute option +type error = + Repeated_parameter + | Duplicate_constructor of string + | Too_many_constructors + | Duplicate_label of string + | Recursive_abbrev of string + | Cycle_in_def of string * type_expr + | Definition_mismatch of type_expr * Includecore.type_mismatch list + | Constraint_failed of type_expr * type_expr + | Inconsistent_constraint of Env.t * (type_expr * type_expr) list + | Type_clash of Env.t * (type_expr * type_expr) list + | Parameters_differ of Path.t * type_expr * type_expr + | Null_arity_external + | Missing_native_external + | Unbound_type_var of type_expr * type_declaration + | Cannot_extend_private_type of Path.t + | Not_extensible_type of Path.t + | Extension_mismatch of Path.t * Includecore.type_mismatch list + | Rebind_wrong_type of Longident.t * Env.t * (type_expr * type_expr) list + | Rebind_mismatch of Longident.t * Path.t * Path.t + | Rebind_private of Longident.t + | Bad_variance of int * (bool*bool*bool) * (bool*bool*bool) + | Unavailable_type_constructor of Path.t + | Bad_fixed_type of string + | Unbound_type_var_ext of type_expr * extension_constructor + | Varying_anonymous + | Val_in_structure + | Multiple_native_repr_attributes + | Cannot_unbox_or_untag_type of native_repr_kind + | Deep_unbox_or_untag_attribute of native_repr_kind + | Bad_immediate_attribute + | Bad_unboxed_attribute of string + | Wrong_unboxed_type_float + | Boxed_and_unboxed + | Nonrec_gadt -val reset: unit -> unit +exception Error of Location.t * error + +val report_error: formatter -> error -> unit end = struct -#1 "lambda.ml" +#1 "typedecl.ml" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* Xavier Leroy and Jerome Vouillon, projet Cristal, INRIA Rocquencourt *) (* *) (* Copyright 1996 Institut National de Recherche en Informatique et *) (* en Automatique. *) @@ -74235,777 +72982,2186 @@ end = struct (* *) (**************************************************************************) +(**** Typing of type definitions ****) + open Misc -open Path open Asttypes +open Parsetree +open Primitive +open Types +open Typetexp -type compile_time_constant = - | Big_endian - | Word_size - | Int_size - | Max_wosize - | Ostype_unix - | Ostype_win32 - | Ostype_cygwin - | Backend_type +type native_repr_kind = Unboxed | Untagged -type loc_kind = - | Loc_FILE - | Loc_LINE - | Loc_MODULE - | Loc_LOC - | Loc_POS +type error = + Repeated_parameter + | Duplicate_constructor of string + | Too_many_constructors + | Duplicate_label of string + | Recursive_abbrev of string + | Cycle_in_def of string * type_expr + | Definition_mismatch of type_expr * Includecore.type_mismatch list + | Constraint_failed of type_expr * type_expr + | Inconsistent_constraint of Env.t * (type_expr * type_expr) list + | Type_clash of Env.t * (type_expr * type_expr) list + | Parameters_differ of Path.t * type_expr * type_expr + | Null_arity_external + | Missing_native_external + | Unbound_type_var of type_expr * type_declaration + | Cannot_extend_private_type of Path.t + | Not_extensible_type of Path.t + | Extension_mismatch of Path.t * Includecore.type_mismatch list + | Rebind_wrong_type of Longident.t * Env.t * (type_expr * type_expr) list + | Rebind_mismatch of Longident.t * Path.t * Path.t + | Rebind_private of Longident.t + | Bad_variance of int * (bool * bool * bool) * (bool * bool * bool) + | Unavailable_type_constructor of Path.t + | Bad_fixed_type of string + | Unbound_type_var_ext of type_expr * extension_constructor + | Varying_anonymous + | Val_in_structure + | Multiple_native_repr_attributes + | Cannot_unbox_or_untag_type of native_repr_kind + | Deep_unbox_or_untag_attribute of native_repr_kind + | Bad_immediate_attribute + | Bad_unboxed_attribute of string + | Wrong_unboxed_type_float + | Boxed_and_unboxed + | Nonrec_gadt -type tag_info = - | Blk_constructor of string * int (* Number of non-const constructors*) - | Blk_tuple - | Blk_array - | Blk_variant of string - | Blk_record of string array (* when its empty means we dont get such information *) - | Blk_module of string list - | Blk_module_export of Ident.t list - | Blk_extension_slot - | Blk_extension - | Blk_na of string - | Blk_some - | Blk_some_not_nested (* ['a option] where ['a] can not inhabit a non-like value *) - | Blk_record_inlined of string array * string * int - | Blk_record_ext of string array - | Blk_lazy_general - | Blk_lazy_forward - | Blk_class (* Ocaml style class*) -let default_tag_info : tag_info = Blk_na "" +open Typedtree + +exception Error of Location.t * error + +(* Note: do not factor the branches in the following pattern-matching: + the records must be constants for the compiler to do sharing on them. +*) +let get_unboxed_from_attributes sdecl = + + if !Clflags.bs_only then unboxed_false_default_false + else + + let unboxed = Builtin_attributes.has_unboxed sdecl.ptype_attributes in + let boxed = Builtin_attributes.has_boxed sdecl.ptype_attributes in + match boxed, unboxed, !Clflags.unboxed_types with + | true, true, _ -> raise (Error(sdecl.ptype_loc, Boxed_and_unboxed)) + | true, false, _ -> unboxed_false_default_false + | false, true, _ -> unboxed_true_default_false + | false, false, false -> unboxed_false_default_true + | false, false, true -> unboxed_true_default_true + +(* Enter all declared types in the environment as abstract types *) + +let enter_type rec_flag env sdecl id = + let needed = + match rec_flag with + | Asttypes.Nonrecursive -> + begin match sdecl.ptype_kind with + | Ptype_variant scds -> + List.iter (fun cd -> + if cd.pcd_res <> None then raise (Error(cd.pcd_loc, Nonrec_gadt))) + scds + | _ -> () + end; + Btype.is_row_name (Ident.name id) + | Asttypes.Recursive -> true + in + if not needed then env else + let decl = + { type_params = + List.map (fun _ -> Btype.newgenvar ()) sdecl.ptype_params; + type_arity = List.length sdecl.ptype_params; + type_kind = Type_abstract; + type_private = sdecl.ptype_private; + type_manifest = + begin match sdecl.ptype_manifest with None -> None + | Some _ -> Some(Ctype.newvar ()) end; + type_variance = List.map (fun _ -> Variance.full) sdecl.ptype_params; + type_newtype_level = None; + type_loc = sdecl.ptype_loc; + type_attributes = sdecl.ptype_attributes; + type_immediate = false; + type_unboxed = unboxed_false_default_false; + } + in + Env.add_type ~check:true id decl env + +let update_type temp_env env id loc = + let path = Path.Pident id in + let decl = Env.find_type path temp_env in + match decl.type_manifest with None -> () + | Some ty -> + let params = List.map (fun _ -> Ctype.newvar ()) decl.type_params in + try Ctype.unify env (Ctype.newconstr path params) ty + with Ctype.Unify trace -> + raise (Error(loc, Type_clash (env, trace))) + +(* We use the Ctype.expand_head_opt version of expand_head to get access + to the manifest type of private abbreviations. *) +let rec get_unboxed_type_representation env ty fuel = + if fuel < 0 then None else + let ty = Ctype.repr (Ctype.expand_head_opt env ty) in + match ty.desc with + | Tconstr (p, args, _) -> + begin match Env.find_type p env with + | exception Not_found -> Some ty + | {type_unboxed = {unboxed = false}} -> Some ty + | {type_params; type_kind = + Type_record ([{ld_type = ty2; _}], _) + | Type_variant [{cd_args = Cstr_tuple [ty2]; _}] + | Type_variant [{cd_args = Cstr_record [{ld_type = ty2; _}]; _}]} + + -> get_unboxed_type_representation env + (Ctype.apply env type_params ty2 args) (fuel - 1) + | {type_kind=Type_abstract} -> None + (* This case can occur when checking a recursive unboxed type + declaration. *) + | _ -> assert false (* only the above can be unboxed *) + end + | _ -> Some ty + +let get_unboxed_type_representation env ty = + (* Do not give too much fuel: PR#7424 *) + get_unboxed_type_representation env ty 100 +;; + +(* Determine if a type's values are represented by floats at run-time. *) +let is_float env ty = + match get_unboxed_type_representation env ty with + Some {desc = Tconstr(p, _, _); _} -> Path.same p Predef.path_float + | _ -> false + +(* Determine if a type definition defines a fixed type. (PW) *) +let is_fixed_type sd = + let rec has_row_var sty = + match sty.ptyp_desc with + Ptyp_alias (sty, _) -> has_row_var sty + | Ptyp_class _ + | Ptyp_object (_, Open) + | Ptyp_variant (_, Open, _) + | Ptyp_variant (_, Closed, Some _) -> true + | _ -> false + in + match sd.ptype_manifest with + None -> false + | Some sty -> + sd.ptype_kind = Ptype_abstract && + sd.ptype_private = Private && + has_row_var sty + +(* Set the row variable in a fixed type *) +let set_fixed_row env loc p decl = + let tm = + match decl.type_manifest with + None -> assert false + | Some t -> Ctype.expand_head env t + in + let rv = + match tm.desc with + Tvariant row -> + let row = Btype.row_repr row in + tm.desc <- Tvariant {row with row_fixed = true}; + if Btype.static_row row then Btype.newgenty Tnil + else row.row_more + | Tobject (ty, _) -> + snd (Ctype.flatten_fields ty) + | _ -> + raise (Error (loc, Bad_fixed_type "is not an object or variant")) + in + if not (Btype.is_Tvar rv) then + raise (Error (loc, Bad_fixed_type "has no row variable")); + rv.desc <- Tconstr (p, decl.type_params, ref Mnil) -let ref_tag_info : tag_info = Blk_record [| "contents" |] - -type field_dbg_info = - | Fld_na - | Fld_record of string - | Fld_module of string - | Fld_record_inline of string - | Fld_record_extension of string - | Fld_tuple +(* Translate one type declaration *) -let ref_field_info : field_dbg_info = Fld_record "contents" +module StringSet = + Set.Make(struct + type t = string + let compare (x:t) y = compare x y + end) -type set_field_dbg_info = - | Fld_set_na - | Fld_record_set of string - | Fld_record_inline_set of string - | Fld_record_extension_set of string +let make_params env params = + let make_param (sty, v) = + try + (transl_type_param env sty, v) + with Already_bound -> + raise(Error(sty.ptyp_loc, Repeated_parameter)) + in + List.map make_param params -let ref_field_set_info : set_field_dbg_info = Fld_record_set "contents" +let transl_labels env closed lbls = + assert (lbls <> []); + let all_labels = ref StringSet.empty in + List.iter + (fun {pld_name = {txt=name; loc}} -> + if StringSet.mem name !all_labels then + raise(Error(loc, Duplicate_label name)); + all_labels := StringSet.add name !all_labels) + lbls; + let mk {pld_name=name;pld_mutable=mut;pld_type=arg;pld_loc=loc; + pld_attributes=attrs} = + Builtin_attributes.warning_scope attrs + (fun () -> + let arg = Ast_helper.Typ.force_poly arg in + let cty = transl_simple_type env closed arg in + {ld_id = Ident.create name.txt; ld_name = name; ld_mutable = mut; + ld_type = cty; ld_loc = loc; ld_attributes = attrs} + ) + in + let lbls = List.map mk lbls in + let lbls' = + List.map + (fun ld -> + let ty = ld.ld_type.ctyp_type in + let ty = match ty.desc with Tpoly(t,[]) -> t | _ -> ty in + {Types.ld_id = ld.ld_id; + ld_mutable = ld.ld_mutable; + ld_type = ty; + ld_loc = ld.ld_loc; + ld_attributes = ld.ld_attributes + } + ) + lbls in + lbls, lbls' -type immediate_or_pointer = - | Immediate - | Pointer +let transl_constructor_arguments env closed = function + | Pcstr_tuple l -> + let l = List.map (transl_simple_type env closed) l in + Types.Cstr_tuple (List.map (fun t -> t.ctyp_type) l), + Cstr_tuple l + | Pcstr_record l -> + let lbls, lbls' = transl_labels env closed l in + Types.Cstr_record lbls', + Cstr_record lbls -type initialization_or_assignment = - | Assignment - | Heap_initialization - | Root_initialization +let make_constructor env type_path type_params sargs sret_type = + match sret_type with + | None -> + let args, targs = + transl_constructor_arguments env true sargs + in + targs, None, args, None, type_params + | Some sret_type -> + (* if it's a generalized constructor we must first narrow and + then widen so as to not introduce any new constraints *) + let z = narrow () in + reset_type_variables (); + let args, targs = + transl_constructor_arguments env false sargs + in + let tret_type = transl_simple_type env false sret_type in + let ret_type = tret_type.ctyp_type in + let params = + match (Ctype.repr ret_type).desc with + | Tconstr (p', params, _) when Path.same type_path p' -> + params + | _ -> + raise (Error (sret_type.ptyp_loc, Constraint_failed + (ret_type, Ctype.newconstr type_path type_params))) + in + widen z; + targs, Some tret_type, args, Some ret_type, params -type is_safe = - | Safe - | Unsafe +(* Check that the variable [id] is present in the [univ] list. *) +let check_type_var loc univ id = + let f t = (Btype.repr t).id = id in + if not (List.exists f univ) then raise (Error (loc, Wrong_unboxed_type_float)) -type primitive = - | Pidentity - | Pbytes_to_string - | Pbytes_of_string - | Pignore - | Prevapply - | Pdirapply - | Ploc of loc_kind - (* Globals *) - | Pgetglobal of Ident.t - | Psetglobal of Ident.t - (* Operations on heap blocks *) - | Pmakeblock of int * tag_info * mutable_flag * block_shape - | Pfield of int * field_dbg_info - | Pfield_computed - | Psetfield of int * immediate_or_pointer * initialization_or_assignment * set_field_dbg_info - | Psetfield_computed of immediate_or_pointer * initialization_or_assignment - | Pfloatfield of int * field_dbg_info - | Psetfloatfield of int * initialization_or_assignment * set_field_dbg_info - | Pduprecord of Types.record_representation * int - (* Force lazy values *) - | Plazyforce - (* External call *) - | Pccall of Primitive.description - (* Exceptions *) - | Praise of raise_kind - (* Boolean operations *) - | Psequand | Psequor | Pnot - (* Integer operations *) - | Pnegint | Paddint | Psubint | Pmulint - | Pdivint of is_safe | Pmodint of is_safe - | Pandint | Porint | Pxorint - | Plslint | Plsrint | Pasrint - | Pintcomp of comparison - | Poffsetint of int - | Poffsetref of int - (* Float operations *) - | Pintoffloat | Pfloatofint - | Pnegfloat | Pabsfloat - | Paddfloat | Psubfloat | Pmulfloat | Pdivfloat - | Pfloatcomp of comparison - (* String operations *) - | Pstringlength | Pstringrefu | Pstringrefs - | Pbyteslength | Pbytesrefu | Pbytessetu | Pbytesrefs | Pbytessets - (* Array operations *) - | Pmakearray of array_kind * mutable_flag - | Pduparray of array_kind * mutable_flag - | Parraylength of array_kind - | Parrayrefu of array_kind - | Parraysetu of array_kind - | Parrayrefs of array_kind - | Parraysets of array_kind - (* Test if the argument is a block or an immediate integer *) - | Pisint - (* Test if the (integer) argument is outside an interval *) - | Pisout - (* Bitvect operations *) - | Pbittest - (* Operations on boxed integers (Nativeint.t, Int32.t, Int64.t) *) - | Pbintofint of boxed_integer - | Pintofbint of boxed_integer - | Pcvtbint of boxed_integer (*source*) * boxed_integer (*destination*) - | Pnegbint of boxed_integer - | Paddbint of boxed_integer - | Psubbint of boxed_integer - | Pmulbint of boxed_integer - | Pdivbint of { size : boxed_integer; is_safe : is_safe } - | Pmodbint of { size : boxed_integer; is_safe : is_safe } - | Pandbint of boxed_integer - | Porbint of boxed_integer - | Pxorbint of boxed_integer - | Plslbint of boxed_integer - | Plsrbint of boxed_integer - | Pasrbint of boxed_integer - | Pbintcomp of boxed_integer * comparison - (* Operations on big arrays: (unsafe, #dimensions, kind, layout) *) - | Pbigarrayref of bool * int * bigarray_kind * bigarray_layout - | Pbigarrayset of bool * int * bigarray_kind * bigarray_layout - (* size of the nth dimension of a big array *) - | Pbigarraydim of int - (* load/set 16,32,64 bits from a string: (unsafe)*) - | Pstring_load_16 of bool - | Pstring_load_32 of bool - | Pstring_load_64 of bool - | Pstring_set_16 of bool - | Pstring_set_32 of bool - | Pstring_set_64 of bool - (* load/set 16,32,64 bits from a - (char, int8_unsigned_elt, c_layout) Bigarray.Array1.t : (unsafe) *) - | Pbigstring_load_16 of bool - | Pbigstring_load_32 of bool - | Pbigstring_load_64 of bool - | Pbigstring_set_16 of bool - | Pbigstring_set_32 of bool - | Pbigstring_set_64 of bool - (* Compile time constants *) - | Pctconst of compile_time_constant - (* byte swap *) - | Pbswap16 - | Pbbswap of boxed_integer - (* Integer to external pointer *) - | Pint_as_pointer - (* Inhibition of optimisation *) - | Popaque +(* Check that all the variables found in [ty] are in [univ]. + Because [ty] is the argument to an abstract type, the representation + of that abstract type could be any subexpression of [ty], in particular + any type variable present in [ty]. +*) +let rec check_unboxed_abstract_arg loc univ ty = + match ty.desc with + | Tvar _ -> check_type_var loc univ ty.id + | Tarrow (_, t1, t2, _) + | Tfield (_, _, t1, t2) -> + check_unboxed_abstract_arg loc univ t1; + check_unboxed_abstract_arg loc univ t2 + | Ttuple args + | Tconstr (_, args, _) + | Tpackage (_, _, args) -> + List.iter (check_unboxed_abstract_arg loc univ) args + | Tobject (fields, r) -> + check_unboxed_abstract_arg loc univ fields; + begin match !r with + | None -> () + | Some (_, args) -> List.iter (check_unboxed_abstract_arg loc univ) args + end + | Tnil + | Tunivar _ -> () + | Tlink e -> check_unboxed_abstract_arg loc univ e + | Tsubst _ -> assert false + | Tvariant { row_fields; row_more; row_name } -> + List.iter (check_unboxed_abstract_row_field loc univ) row_fields; + check_unboxed_abstract_arg loc univ row_more; + begin match row_name with + | None -> () + | Some (_, args) -> List.iter (check_unboxed_abstract_arg loc univ) args + end + | Tpoly (t, _) -> check_unboxed_abstract_arg loc univ t -and comparison = - Ceq | Cneq | Clt | Cgt | Cle | Cge +and check_unboxed_abstract_row_field loc univ (_, field) = + match field with + | Rpresent (Some ty) -> check_unboxed_abstract_arg loc univ ty + | Reither (_, args, _, r) -> + List.iter (check_unboxed_abstract_arg loc univ) args; + begin match !r with + | None -> () + | Some f -> check_unboxed_abstract_row_field loc univ ("", f) + end + | Rabsent + | Rpresent None -> () -and value_kind = - Pgenval | Pfloatval | Pboxedintval of boxed_integer | Pintval +(* Check that the argument to a GADT constructor is compatible with unboxing + the type, given the universal parameters of the type. *) +let rec check_unboxed_gadt_arg loc univ env ty = + match get_unboxed_type_representation env ty with + | Some {desc = Tvar _; id} -> check_type_var loc univ id + | Some {desc = Tarrow _ | Ttuple _ | Tpackage _ | Tobject _ | Tnil + | Tvariant _; _} -> + () + (* A comment in [Translcore.transl_exp0] claims the above cannot be + represented by floats. *) + | Some {desc = Tconstr (p, args, _); _} -> + let tydecl = Env.find_type p env in + assert (not tydecl.type_unboxed.unboxed); + if tydecl.type_kind = Type_abstract then + List.iter (check_unboxed_abstract_arg loc univ) args + | Some {desc = Tfield _ | Tlink _ | Tsubst _; _} -> assert false + | Some {desc = Tunivar _; _} -> () + | Some {desc = Tpoly (t2, _); _} -> check_unboxed_gadt_arg loc univ env t2 + | None -> () + (* This case is tricky: the argument is another (or the same) type + in the same recursive definition. In this case we don't have to + check because we will also check that other type for correctness. *) -and block_shape = - value_kind list option +let transl_declaration env sdecl id = + (* Bind type parameters *) + reset_type_variables(); + Ctype.begin_def (); + let tparams = make_params env sdecl.ptype_params in + let params = List.map (fun (cty, _) -> cty.ctyp_type) tparams in + let cstrs = List.map + (fun (sty, sty', loc) -> + transl_simple_type env false sty, + transl_simple_type env false sty', loc) + sdecl.ptype_cstrs + in + let raw_status = get_unboxed_from_attributes sdecl in + if raw_status.unboxed && not raw_status.default then begin + match sdecl.ptype_kind with + | Ptype_abstract -> + raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute + "it is abstract")) + | Ptype_variant [{pcd_args = Pcstr_tuple []; _}] -> + raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute + "its constructor has no argument")) + | Ptype_variant [{pcd_args = Pcstr_tuple [_]; _}] -> () + | Ptype_variant [{pcd_args = Pcstr_tuple _; _}] -> + raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute + "its constructor has more than one argument")) + | Ptype_variant [{pcd_args = Pcstr_record + [{pld_mutable=Immutable; _}]; _}] -> () + | Ptype_variant [{pcd_args = Pcstr_record [{pld_mutable=Mutable; _}]; _}] -> + raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute "it is mutable")) + | Ptype_variant [{pcd_args = Pcstr_record _; _}] -> + raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute + "its constructor has more than one argument")) + | Ptype_variant _ -> + raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute + "it has more than one constructor")) + | Ptype_record [{pld_mutable=Immutable; _}] -> () + | Ptype_record [{pld_mutable=Mutable; _}] -> + raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute + "it is mutable")) + | Ptype_record _ -> + raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute + "it has more than one field")) + | Ptype_open -> + raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute + "extensible variant types cannot be unboxed")) + end; + let unboxed_status = + match sdecl.ptype_kind with + | Ptype_variant [{pcd_args = Pcstr_tuple [_]; _}] + | Ptype_variant [{pcd_args = Pcstr_record + [{pld_mutable = Immutable; _}]; _}] + | Ptype_record [{pld_mutable = Immutable; _}] -> + raw_status + | _ -> (* The type is not unboxable, mark it as boxed *) + unboxed_false_default_false + in + let unbox = unboxed_status.unboxed in + let (tkind, kind) = + match sdecl.ptype_kind with + | Ptype_abstract -> Ttype_abstract, Type_abstract + | Ptype_variant scstrs -> + assert (scstrs <> []); + if List.exists (fun cstr -> cstr.pcd_res <> None) scstrs then begin + match cstrs with + [] -> () + | (_,_,loc)::_ -> + Location.prerr_warning loc Warnings.Constraint_on_gadt + end; + let all_constrs = ref StringSet.empty in + List.iter + (fun {pcd_name = {txt = name}} -> + if StringSet.mem name !all_constrs then + raise(Error(sdecl.ptype_loc, Duplicate_constructor name)); + all_constrs := StringSet.add name !all_constrs) + scstrs; + if List.length + (List.filter (fun cd -> cd.pcd_args <> Pcstr_tuple []) scstrs) + > (Config.max_tag + 1) then + raise(Error(sdecl.ptype_loc, Too_many_constructors)); + let make_cstr scstr = + let name = Ident.create scstr.pcd_name.txt in + let targs, tret_type, args, ret_type, cstr_params = + make_constructor env (Path.Pident id) params + scstr.pcd_args scstr.pcd_res + in + if Config.flat_float_array && unbox then begin + (* Cannot unbox a type when the argument can be both float and + non-float because it interferes with the dynamic float array + optimization. This can only happen when the type is a GADT + and the argument is an existential type variable or an + unboxed (or abstract) type constructor applied to some + existential type variable. Of course we also have to rule + out any abstract type constructor applied to anything that + might be an existential type variable. + There is a difficulty with existential variables created + out of thin air (rather than bound by the declaration). + See PR#7511 and GPR#1133 for details. *) + match Datarepr.constructor_existentials args ret_type with + | _, [] -> () + | [argty], _ex -> + check_unboxed_gadt_arg sdecl.ptype_loc cstr_params env argty + | _ -> assert false + end; + let tcstr = + { cd_id = name; + cd_name = scstr.pcd_name; + cd_args = targs; + cd_res = tret_type; + cd_loc = scstr.pcd_loc; + cd_attributes = scstr.pcd_attributes } + in + let cstr = + { Types.cd_id = name; + cd_args = args; + cd_res = ret_type; + cd_loc = scstr.pcd_loc; + cd_attributes = scstr.pcd_attributes } + in + tcstr, cstr + in + let make_cstr scstr = + Builtin_attributes.warning_scope scstr.pcd_attributes + (fun () -> make_cstr scstr) + in + let tcstrs, cstrs = List.split (List.map make_cstr scstrs) in + Ttype_variant tcstrs, Type_variant cstrs + | Ptype_record lbls -> + let lbls, lbls' = transl_labels env true lbls in + let rep = + if !Clflags.bs_only then Record_regular else (* ATTENTION: revisit when we support @@unbox*) + if unbox then Record_unboxed false + else if List.for_all (fun l -> is_float env l.Types.ld_type) lbls' + then Record_float + else Record_regular + in + Ttype_record lbls, Type_record(lbls', rep) + | Ptype_open -> Ttype_open, Type_open + in + let (tman, man) = match sdecl.ptype_manifest with + None -> None, None + | Some sty -> + let no_row = not (is_fixed_type sdecl) in + let cty = transl_simple_type env no_row sty in + Some cty, Some cty.ctyp_type + in + let decl = + { type_params = params; + type_arity = List.length params; + type_kind = kind; + type_private = sdecl.ptype_private; + type_manifest = man; + type_variance = List.map (fun _ -> Variance.full) params; + type_newtype_level = None; + type_loc = sdecl.ptype_loc; + type_attributes = sdecl.ptype_attributes; + type_immediate = false; + type_unboxed = unboxed_status; + } in -and array_kind = - Pgenarray | Paddrarray | Pintarray | Pfloatarray + (* Check constraints *) + List.iter + (fun (cty, cty', loc) -> + let ty = cty.ctyp_type in + let ty' = cty'.ctyp_type in + try Ctype.unify env ty ty' with Ctype.Unify tr -> + raise(Error(loc, Inconsistent_constraint (env, tr)))) + cstrs; + Ctype.end_def (); + (* Add abstract row *) + if is_fixed_type sdecl then begin + let p = + try Env.lookup_type (Longident.Lident(Ident.name id ^ "#row")) env + with Not_found -> assert false in + set_fixed_row env sdecl.ptype_loc p decl + end; + (* Check for cyclic abbreviations *) + begin match decl.type_manifest with None -> () + | Some ty -> + if Ctype.cyclic_abbrev env id ty then + raise(Error(sdecl.ptype_loc, Recursive_abbrev sdecl.ptype_name.txt)); + end; + { + typ_id = id; + typ_name = sdecl.ptype_name; + typ_params = tparams; + typ_type = decl; + typ_cstrs = cstrs; + typ_loc = sdecl.ptype_loc; + typ_manifest = tman; + typ_kind = tkind; + typ_private = sdecl.ptype_private; + typ_attributes = sdecl.ptype_attributes; + } -and boxed_integer = Primitive.boxed_integer = - Pnativeint | Pint32 | Pint64 +(* Generalize a type declaration *) -and bigarray_kind = - Pbigarray_unknown - | Pbigarray_float32 | Pbigarray_float64 - | Pbigarray_sint8 | Pbigarray_uint8 - | Pbigarray_sint16 | Pbigarray_uint16 - | Pbigarray_int32 | Pbigarray_int64 - | Pbigarray_caml_int | Pbigarray_native_int - | Pbigarray_complex32 | Pbigarray_complex64 +let generalize_decl decl = + List.iter Ctype.generalize decl.type_params; + Btype.iter_type_expr_kind Ctype.generalize decl.type_kind; + begin match decl.type_manifest with + | None -> () + | Some ty -> Ctype.generalize ty + end -and bigarray_layout = - Pbigarray_unknown_layout - | Pbigarray_c_layout - | Pbigarray_fortran_layout +(* Check that all constraints are enforced *) -and raise_kind = - | Raise_regular - | Raise_reraise - | Raise_notrace +module TypeSet = Btype.TypeSet +module TypeMap = Btype.TypeMap -type pointer_info = - | Pt_constructor of string - | Pt_variant of string - | Pt_module_alias - | Pt_builtin_boolean - | Pt_shape_none - | Pt_na +let rec check_constraints_rec env loc visited ty = + let ty = Ctype.repr ty in + if TypeSet.mem ty !visited then () else begin + visited := TypeSet.add ty !visited; + match ty.desc with + | Tconstr (path, args, _) -> + let args' = List.map (fun _ -> Ctype.newvar ()) args in + let ty' = Ctype.newconstr path args' in + begin try Ctype.enforce_constraints env ty' + with Ctype.Unify _ -> assert false + | Not_found -> raise (Error(loc, Unavailable_type_constructor path)) + end; + if not (Ctype.matches env ty ty') then + raise (Error(loc, Constraint_failed (ty, ty'))); + List.iter (check_constraints_rec env loc visited) args + | Tpoly (ty, tl) -> + let _, ty = Ctype.instance_poly false tl ty in + check_constraints_rec env loc visited ty + | _ -> + Btype.iter_type_expr (check_constraints_rec env loc visited) ty + end -let default_pointer_info = Pt_na - -type structured_constant = - Const_base of constant - | Const_pointer of int * pointer_info - | Const_block of int * tag_info * structured_constant list - | Const_float_array of string list - | Const_immstring of string +module SMap = Map.Make(String) +let check_constraints_labels env visited l pl = + let rec get_loc name = function + [] -> assert false + | pld :: tl -> + if name = pld.pld_name.txt then pld.pld_type.ptyp_loc + else get_loc name tl + in + List.iter + (fun {Types.ld_id=name; ld_type=ty} -> + check_constraints_rec env (get_loc (Ident.name name) pl) visited ty) + l -type inline_attribute = - | Always_inline (* [@inline] or [@inline always] *) - | Never_inline (* [@inline never] *) - | Unroll of int (* [@unroll x] *) - | Default_inline (* no [@inline] attribute *) +let check_constraints env sdecl (_, decl) = + let visited = ref TypeSet.empty in + begin match decl.type_kind with + | Type_abstract -> () + | Type_variant l -> + let find_pl = function + Ptype_variant pl -> pl + | Ptype_record _ | Ptype_abstract | Ptype_open -> assert false + in + let pl = find_pl sdecl.ptype_kind in + let pl_index = + let foldf acc x = + SMap.add x.pcd_name.txt x acc + in + List.fold_left foldf SMap.empty pl + in + List.iter + (fun {Types.cd_id=name; cd_args; cd_res} -> + let {pcd_args; pcd_res; _} = + try SMap.find (Ident.name name) pl_index + with Not_found -> assert false in + begin match cd_args, pcd_args with + | Cstr_tuple tyl, Pcstr_tuple styl -> + List.iter2 + (fun sty ty -> + check_constraints_rec env sty.ptyp_loc visited ty) + styl tyl + | Cstr_record tyl, Pcstr_record styl -> + check_constraints_labels env visited tyl styl + | _ -> assert false + end; + match pcd_res, cd_res with + | Some sr, Some r -> + check_constraints_rec env sr.ptyp_loc visited r + | _ -> + () ) + l + | Type_record (l, _) -> + let find_pl = function + Ptype_record pl -> pl + | Ptype_variant _ | Ptype_abstract | Ptype_open -> assert false + in + let pl = find_pl sdecl.ptype_kind in + check_constraints_labels env visited l pl + | Type_open -> () + end; + begin match decl.type_manifest with + | None -> () + | Some ty -> + let sty = + match sdecl.ptype_manifest with Some sty -> sty | _ -> assert false + in + check_constraints_rec env sty.ptyp_loc visited ty + end -type specialise_attribute = - | Always_specialise (* [@specialise] or [@specialise always] *) - | Never_specialise (* [@specialise never] *) - | Default_specialise (* no [@specialise] attribute *) +(* + If both a variant/record definition and a type equation are given, + need to check that the equation refers to a type of the same kind + with the same constructors and labels. +*) +let check_coherence env loc id decl = + match decl with + { type_kind = (Type_variant _ | Type_record _| Type_open); + type_manifest = Some ty } -> + begin match (Ctype.repr ty).desc with + Tconstr(path, args, _) -> + begin try + let decl' = Env.find_type path env in + let err = + if List.length args <> List.length decl.type_params + then [Includecore.Arity] + else if not (Ctype.equal env false args decl.type_params) + then [Includecore.Constraint] + else + Includecore.type_declarations ~loc ~equality:true env + (Path.last path) + decl' + id + (Subst.type_declaration + (Subst.add_type id path Subst.identity) decl) + in + if err <> [] then + raise(Error(loc, Definition_mismatch (ty, err))) + with Not_found -> + raise(Error(loc, Unavailable_type_constructor path)) + end + | _ -> raise(Error(loc, Definition_mismatch (ty, []))) + end + | _ -> () -type function_kind = Curried | Tupled +let check_abbrev env sdecl (id, decl) = + check_coherence env sdecl.ptype_loc id decl -type let_kind = Strict | Alias | StrictOpt | Variable +(* Check that recursion is well-founded *) -type public_info = string option (* label name *) +let check_well_founded env loc path to_check ty = + let visited = ref TypeMap.empty in + let rec check ty0 parents ty = + let ty = Btype.repr ty in + if TypeSet.mem ty parents then begin + (*Format.eprintf "@[%a@]@." Printtyp.raw_type_expr ty;*) + if match ty0.desc with + | Tconstr (p, _, _) -> Path.same p path + | _ -> false + then raise (Error (loc, Recursive_abbrev (Path.name path))) + else raise (Error (loc, Cycle_in_def (Path.name path, ty0))) + end; + let (fini, parents) = + try + let prev = TypeMap.find ty !visited in + if TypeSet.subset parents prev then (true, parents) else + (false, TypeSet.union parents prev) + with Not_found -> + (false, parents) + in + if fini then () else + let rec_ok = + match ty.desc with + Tconstr(p,_,_) -> + !Clflags.recursive_types && Ctype.is_contractive env p + | Tobject _ | Tvariant _ -> true + | _ -> !Clflags.recursive_types + in + let visited' = TypeMap.add ty parents !visited in + let arg_exn = + try + visited := visited'; + let parents = + if rec_ok then TypeSet.empty else TypeSet.add ty parents in + Btype.iter_type_expr (check ty0 parents) ty; + None + with e -> + visited := visited'; Some e + in + match ty.desc with + | Tconstr(p, _, _) when arg_exn <> None || to_check p -> + if to_check p then may raise arg_exn + else Btype.iter_type_expr (check ty0 TypeSet.empty) ty; + begin try + let ty' = Ctype.try_expand_once_opt env ty in + let ty0 = if TypeSet.is_empty parents then ty else ty0 in + check ty0 (TypeSet.add ty parents) ty' + with + Ctype.Cannot_expand -> may raise arg_exn + end + | _ -> may raise arg_exn + in + let snap = Btype.snapshot () in + try Ctype.wrap_trace_gadt_instances env (check ty TypeSet.empty) ty + with Ctype.Unify _ -> + (* Will be detected by check_recursion *) + Btype.backtrack snap -type meth_kind = Self | Public of public_info | Cached +let check_well_founded_manifest env loc path decl = + if decl.type_manifest = None then () else + let args = List.map (fun _ -> Ctype.newvar()) decl.type_params in + check_well_founded env loc path (Path.same path) (Ctype.newconstr path args) -type shared_code = (int * int) list +let check_well_founded_decl env loc path decl to_check = + let open Btype in + let it = + {type_iterators with + it_type_expr = (fun _ -> check_well_founded env loc path to_check)} in + it.it_type_declaration it (Ctype.instance_declaration decl) -type function_attribute = { - inline : inline_attribute; - specialise : specialise_attribute; - is_a_functor: bool; - stub: bool; -} -type switch_names = {consts: string array; blocks: string array} +(* Check for ill-defined abbrevs *) -type lambda = - Lvar of Ident.t - | Lconst of structured_constant - | Lapply of lambda_apply - | Lfunction of lfunction - | Llet of let_kind * value_kind * Ident.t * lambda * lambda - | Lletrec of (Ident.t * lambda) list * lambda - | Lprim of primitive * lambda list * Location.t - | Lswitch of lambda * lambda_switch * Location.t - | Lstringswitch of - lambda * (string * lambda) list * lambda option * Location.t - | Lstaticraise of int * lambda list - | Lstaticcatch of lambda * (int * Ident.t list) * lambda - | Ltrywith of lambda * Ident.t * lambda - | Lifthenelse of lambda * lambda * lambda - | Lsequence of lambda * lambda - | Lwhile of lambda * lambda - | Lfor of Ident.t * lambda * lambda * direction_flag * lambda - | Lassign of Ident.t * lambda - | Lsend of meth_kind * lambda * lambda * lambda list * Location.t - | Levent of lambda * lambda_event - | Lifused of Ident.t * lambda +let check_recursion env loc path decl to_check = + (* to_check is true for potentially mutually recursive paths. + (path, decl) is the type declaration to be checked. *) -and lfunction = - { kind: function_kind; - params: Ident.t list; - body: lambda; - attr: function_attribute; (* specified with [@inline] attribute *) - loc: Location.t; } + if decl.type_params = [] then () else -and lambda_apply = - { ap_func : lambda; - ap_args : lambda list; - ap_loc : Location.t; - ap_should_be_tailcall : bool; - ap_inlined : inline_attribute; - ap_specialised : specialise_attribute; } + let visited = ref [] in -and lambda_switch = - { sw_numconsts: int; - sw_consts: (int * lambda) list; - sw_numblocks: int; - sw_blocks: (int * lambda) list; - sw_failaction : lambda option; - sw_names: switch_names option } + let rec check_regular cpath args prev_exp ty = + let ty = Ctype.repr ty in + if not (List.memq ty !visited) then begin + visited := ty :: !visited; + match ty.desc with + | Tconstr(path', args', _) -> + if Path.same path path' then begin + if not (Ctype.equal env false args args') then + raise (Error(loc, + Parameters_differ(cpath, ty, Ctype.newconstr path args))) + end + (* Attempt to expand a type abbreviation if: + 1- [to_check path'] holds + (otherwise the expansion cannot involve [path]); + 2- we haven't expanded this type constructor before + (otherwise we could loop if [path'] is itself + a non-regular abbreviation). *) + else if to_check path' && not (List.mem path' prev_exp) then begin + try + (* Attempt expansion *) + let (params0, body0, _) = Env.find_type_expansion path' env in + let (params, body) = + Ctype.instance_parameterized_type params0 body0 in + begin + try List.iter2 (Ctype.unify env) params args' + with Ctype.Unify _ -> + raise (Error(loc, Constraint_failed + (ty, Ctype.newconstr path' params0))); + end; + check_regular path' args (path' :: prev_exp) body + with Not_found -> () + end; + List.iter (check_regular cpath args prev_exp) args' + | Tpoly (ty, tl) -> + let (_, ty) = Ctype.instance_poly ~keep_names:true false tl ty in + check_regular cpath args prev_exp ty + | _ -> + Btype.iter_type_expr (check_regular cpath args prev_exp) ty + end in -and lambda_event = - { lev_loc: Location.t; - lev_kind: lambda_event_kind; - lev_repr: int ref option; - lev_env: Env.summary } + Misc.may + (fun body -> + let (args, body) = + Ctype.instance_parameterized_type + ~keep_names:true decl.type_params body in + check_regular path args [] body) + decl.type_manifest -and lambda_event_kind = - Lev_before - | Lev_after of Types.type_expr - | Lev_function - | Lev_pseudo - | Lev_module_definition of Ident.t +let check_abbrev_recursion env id_loc_list to_check tdecl = + let decl = tdecl.typ_type in + let id = tdecl.typ_id in + check_recursion env (List.assoc id id_loc_list) (Path.Pident id) decl to_check -type program = - { module_ident : Ident.t; - main_module_block_size : int; - required_globals : Ident.Set.t; - code : lambda } +(* Compute variance *) -let const_unit = Const_pointer(0, default_pointer_info) +let get_variance ty visited = + try TypeMap.find ty !visited with Not_found -> Variance.null -let lambda_assert_false = Lconst (Const_pointer(0, Pt_constructor "assert false")) +let compute_variance env visited vari ty = + let rec compute_variance_rec vari ty = + (* Format.eprintf "%a: %x@." Printtyp.type_expr ty (Obj.magic vari); *) + let ty = Ctype.repr ty in + let vari' = get_variance ty visited in + if Variance.subset vari vari' then () else + let vari = Variance.union vari vari' in + visited := TypeMap.add ty vari !visited; + let compute_same = compute_variance_rec vari in + match ty.desc with + Tarrow (_, ty1, ty2, _) -> + let open Variance in + let v = conjugate vari in + let v1 = + if mem May_pos v || mem May_neg v + then set May_weak true v else v + in + compute_variance_rec v1 ty1; + compute_same ty2 + | Ttuple tl -> + List.iter compute_same tl + | Tconstr (path, tl, _) -> + let open Variance in + if tl = [] then () else begin + try + let decl = Env.find_type path env in + let cvari f = mem f vari in + List.iter2 + (fun ty v -> + let cv f = mem f v in + let strict = + cvari Inv && cv Inj || (cvari Pos || cvari Neg) && cv Inv + in + if strict then compute_variance_rec full ty else + let p1 = inter v vari + and n1 = inter v (conjugate vari) in + let v1 = + union (inter covariant (union p1 (conjugate p1))) + (inter (conjugate covariant) (union n1 (conjugate n1))) + and weak = + cvari May_weak && (cv May_pos || cv May_neg) || + (cvari May_pos || cvari May_neg) && cv May_weak + in + let v2 = set May_weak weak v1 in + compute_variance_rec v2 ty) + tl decl.type_variance + with Not_found -> + List.iter (compute_variance_rec may_inv) tl + end + | Tobject (ty, _) -> + compute_same ty + | Tfield (_, _, ty1, ty2) -> + compute_same ty1; + compute_same ty2 + | Tsubst ty -> + compute_same ty + | Tvariant row -> + let row = Btype.row_repr row in + List.iter + (fun (_,f) -> + match Btype.row_field_repr f with + Rpresent (Some ty) -> + compute_same ty + | Reither (_, tyl, _, _) -> + let open Variance in + let upper = + List.fold_left (fun s f -> set f true s) + null [May_pos; May_neg; May_weak] + in + let v = inter vari upper in + (* cf PR#7269: + if List.length tyl > 1 then upper else inter vari upper *) + List.iter (compute_variance_rec v) tyl + | _ -> ()) + row.row_fields; + compute_same row.row_more + | Tpoly (ty, _) -> + compute_same ty + | Tvar _ | Tnil | Tlink _ | Tunivar _ -> () + | Tpackage (_, _, tyl) -> + let v = + Variance.(if mem Pos vari || mem Neg vari then full else may_inv) + in + List.iter (compute_variance_rec v) tyl + in + compute_variance_rec vari ty + +let make p n i = + let open Variance in + set May_pos p (set May_neg n (set May_weak n (set Inj i null))) + +let compute_variance_type env check (required, loc) decl tyl = + (* Requirements *) + let required = + List.map (fun (c,n,i) -> if c || n then (c,n,i) else (true,true,i)) + required + in + (* Prepare *) + let params = List.map Btype.repr decl.type_params in + let tvl = ref TypeMap.empty in + (* Compute occurrences in the body *) + let open Variance in + List.iter + (fun (cn,ty) -> + compute_variance env tvl (if cn then full else covariant) ty) + tyl; + if check then begin + (* Check variance of parameters *) + let pos = ref 0 in + List.iter2 + (fun ty (c, n, i) -> + incr pos; + let var = get_variance ty tvl in + let (co,cn) = get_upper var and ij = mem Inj var in + if Btype.is_Tvar ty && (co && not c || cn && not n || not ij && i) + then raise (Error(loc, Bad_variance (!pos, (co,cn,ij), (c,n,i))))) + params required; + (* Check propagation from constrained parameters *) + let args = Btype.newgenty (Ttuple params) in + let fvl = Ctype.free_variables args in + let fvl = List.filter (fun v -> not (List.memq v params)) fvl in + (* If there are no extra variables there is nothing to do *) + if fvl = [] then () else + let tvl2 = ref TypeMap.empty in + List.iter2 + (fun ty (p,n,_) -> + if Btype.is_Tvar ty then () else + let v = + if p then if n then full else covariant else conjugate covariant in + compute_variance env tvl2 v ty) + params required; + let visited = ref TypeSet.empty in + let rec check ty = + let ty = Ctype.repr ty in + if TypeSet.mem ty !visited then () else + let visited' = TypeSet.add ty !visited in + visited := visited'; + let v1 = get_variance ty tvl in + let snap = Btype.snapshot () in + let v2 = + TypeMap.fold + (fun t vt v -> + if Ctype.equal env false [ty] [t] then union vt v else v) + !tvl2 null in + Btype.backtrack snap; + let (c1,n1) = get_upper v1 and (c2,n2,_,i2) = get_lower v2 in + if c1 && not c2 || n1 && not n2 then + if List.memq ty fvl then + let code = if not i2 then -2 else if c2 || n2 then -1 else -3 in + raise (Error (loc, Bad_variance (code, (c1,n1,false), (c2,n2,false)))) + else + Btype.iter_type_expr check ty + in + List.iter (fun (_,ty) -> check ty) tyl; + end; + List.map2 + (fun ty (p, n, i) -> + let v = get_variance ty tvl in + let tr = decl.type_private in + (* Use required variance where relevant *) + let concr = decl.type_kind <> Type_abstract (*|| tr = Type_new*) in + let (p, n) = + if tr = Private || not (Btype.is_Tvar ty) then (p, n) (* set *) + else (false, false) (* only check *) + and i = concr || i && tr = Private in + let v = union v (make p n i) in + let v = + if not concr then v else + if mem Pos v && mem Neg v then full else + if Btype.is_Tvar ty then v else + union v + (if p then if n then full else covariant else conjugate covariant) + in + if decl.type_kind = Type_abstract && tr = Public then v else + set May_weak (mem May_neg v) v) + params required +let add_false = List.map (fun ty -> false, ty) -let lambda_unit = Lconst const_unit +(* A parameter is constrained if it is either instantiated, + or it is a variable appearing in another parameter *) +let constrained vars ty = + match ty.desc with + | Tvar _ -> List.exists (fun tl -> List.memq ty tl) vars + | _ -> true -let default_function_attribute = { - inline = Default_inline; - specialise = Default_specialise; - is_a_functor = false; - stub = false; -} +let for_constr = function + | Types.Cstr_tuple l -> add_false l + | Types.Cstr_record l -> + List.map + (fun {Types.ld_mutable; ld_type} -> (ld_mutable = Mutable, ld_type)) + l -let default_stub_attribute = - { default_function_attribute with stub = true } +let compute_variance_gadt env check (required, loc as rloc) decl + (tl, ret_type_opt) = + match ret_type_opt with + | None -> + compute_variance_type env check rloc {decl with type_private = Private} + (for_constr tl) + | Some ret_type -> + match Ctype.repr ret_type with + | {desc=Tconstr (_, tyl, _)} -> + (* let tyl = List.map (Ctype.expand_head env) tyl in *) + let tyl = List.map Ctype.repr tyl in + let fvl = List.map (Ctype.free_variables ?env:None) tyl in + let _ = + List.fold_left2 + (fun (fv1,fv2) ty (c,n,_) -> + match fv2 with [] -> assert false + | fv :: fv2 -> + (* fv1 @ fv2 = free_variables of other parameters *) + if (c||n) && constrained (fv1 @ fv2) ty then + raise (Error(loc, Varying_anonymous)); + (fv :: fv1, fv2)) + ([], fvl) tyl required + in + compute_variance_type env check rloc + {decl with type_params = tyl; type_private = Private} + (for_constr tl) + | _ -> assert false -(* Build sharing keys *) -(* - Those keys are later compared with Pervasives.compare. - For that reason, they should not include cycles. -*) +let compute_variance_extension env check decl ext rloc = + compute_variance_gadt env check rloc + {decl with type_params = ext.ext_type_params} + (ext.ext_args, ext.ext_ret_type) -exception Not_simple +let compute_variance_decl env check decl (required, _ as rloc) = + if (decl.type_kind = Type_abstract || decl.type_kind = Type_open) + && decl.type_manifest = None then + List.map + (fun (c, n, i) -> + make (not n) (not c) (decl.type_kind <> Type_abstract || i)) + required + else + let mn = + match decl.type_manifest with + None -> [] + | Some ty -> [false, ty] + in + match decl.type_kind with + Type_abstract | Type_open -> + compute_variance_type env check rloc decl mn + | Type_variant tll -> + if List.for_all (fun c -> c.Types.cd_res = None) tll then + compute_variance_type env check rloc decl + (mn @ List.flatten (List.map (fun c -> for_constr c.Types.cd_args) + tll)) + else begin + let mn = + List.map (fun (_,ty) -> (Types.Cstr_tuple [ty],None)) mn in + let tll = + mn @ List.map (fun c -> c.Types.cd_args, c.Types.cd_res) tll in + match List.map (compute_variance_gadt env check rloc decl) tll with + | vari :: rem -> + let varl = List.fold_left (List.map2 Variance.union) vari rem in + List.map + Variance.(fun v -> if mem Pos v && mem Neg v then full else v) + varl + | _ -> assert false + end + | Type_record (ftl, _) -> + compute_variance_type env check rloc decl + (mn @ List.map (fun {Types.ld_mutable; ld_type} -> + (ld_mutable = Mutable, ld_type)) ftl) -let max_raw = 32 +let is_hash id = + let s = Ident.name id in + String.length s > 0 && s.[0] = '#' -let make_key e = - let count = ref 0 (* Used for controling size *) - and make_key = Ident.make_key_generator () in - (* make_key is used for normalizing let-bound variables *) - let rec tr_rec env e = - incr count ; - if !count > max_raw then raise Not_simple ; (* Too big ! *) - match e with - | Lvar id -> - begin - try Ident.find_same id env - with Not_found -> e - end - | Lconst (Const_base (Const_string _)) -> - (* Mutable constants are not shared *) - raise Not_simple - | Lconst _ -> e - | Lapply ap -> - Lapply {ap with ap_func = tr_rec env ap.ap_func; - ap_args = tr_recs env ap.ap_args; - ap_loc = Location.none} - | Llet (Alias,_k,x,ex,e) -> (* Ignore aliases -> substitute *) - let ex = tr_rec env ex in - tr_rec (Ident.add x ex env) e - | Llet ((Strict | StrictOpt),_k,x,ex,Lvar v) when Ident.same v x -> - tr_rec env ex - | Llet (str,k,x,ex,e) -> - (* Because of side effects, keep other lets with normalized names *) - let ex = tr_rec env ex in - let y = make_key x in - Llet (str,k,y,ex,tr_rec (Ident.add x (Lvar y) env) e) - | Lprim (p,es,_) -> - Lprim (p,tr_recs env es, Location.none) - | Lswitch (e,sw,loc) -> - Lswitch (tr_rec env e,tr_sw env sw,loc) - | Lstringswitch (e,sw,d,_) -> - Lstringswitch - (tr_rec env e, - List.map (fun (s,e) -> s,tr_rec env e) sw, - tr_opt env d, - Location.none) - | Lstaticraise (i,es) -> - Lstaticraise (i,tr_recs env es) - | Lstaticcatch (e1,xs,e2) -> - Lstaticcatch (tr_rec env e1,xs,tr_rec env e2) - | Ltrywith (e1,x,e2) -> - Ltrywith (tr_rec env e1,x,tr_rec env e2) - | Lifthenelse (cond,ifso,ifnot) -> - Lifthenelse (tr_rec env cond,tr_rec env ifso,tr_rec env ifnot) - | Lsequence (e1,e2) -> - Lsequence (tr_rec env e1,tr_rec env e2) - | Lassign (x,e) -> - Lassign (x,tr_rec env e) - | Lsend (m,e1,e2,es,_loc) -> - Lsend (m,tr_rec env e1,tr_rec env e2,tr_recs env es,Location.none) - | Lifused (id,e) -> Lifused (id,tr_rec env e) - | Lletrec _|Lfunction _ - | Lfor _ | Lwhile _ -(* Beware: (PR#6412) the event argument to Levent - may include cyclic structure of type Type.typexpr *) - | Levent _ -> - raise Not_simple +let marked_as_immediate decl = + Builtin_attributes.immediate decl.type_attributes - and tr_recs env es = List.map (tr_rec env) es +let compute_immediacy env tdecl = + match (tdecl.type_kind, tdecl.type_manifest) with + | (Type_variant [{cd_args = Cstr_tuple [arg]; _}], _) + | (Type_variant [{cd_args = Cstr_record [{ld_type = arg; _}]; _}], _) + | (Type_record ([{ld_type = arg; _}], _), _) + when tdecl.type_unboxed.unboxed -> + begin match get_unboxed_type_representation env arg with + | Some argrepr -> not (Ctype.maybe_pointer_type env argrepr) + | None -> false + end + | (Type_variant (_ :: _ as cstrs), _) -> + not (List.exists (fun c -> c.Types.cd_args <> Types.Cstr_tuple []) cstrs) + | (Type_abstract, Some(typ)) -> + not (Ctype.maybe_pointer_type env typ) + | (Type_abstract, None) -> marked_as_immediate tdecl + | _ -> false - and tr_sw env sw = - { sw with - sw_consts = List.map (fun (i,e) -> i,tr_rec env e) sw.sw_consts ; - sw_blocks = List.map (fun (i,e) -> i,tr_rec env e) sw.sw_blocks ; - sw_failaction = tr_opt env sw.sw_failaction ; } +(* Computes the fixpoint for the variance and immediacy of type declarations *) - and tr_opt env = function - | None -> None - | Some e -> Some (tr_rec env e) in +let rec compute_properties_fixpoint env decls required variances immediacies = + let new_decls = + List.map2 + (fun (id, decl) (variance, immediacy) -> + id, {decl with type_variance = variance; type_immediate = immediacy}) + decls (List.combine variances immediacies) + in + let new_env = + List.fold_right + (fun (id, decl) env -> Env.add_type ~check:true id decl env) + new_decls env + in + let new_variances = + List.map2 + (fun (_id, decl) -> compute_variance_decl new_env false decl) + new_decls required + in + let new_variances = + List.map2 (List.map2 Variance.union) new_variances variances in + let new_immediacies = + List.map + (fun (_id, decl) -> compute_immediacy new_env decl) + new_decls + in + if new_variances <> variances || new_immediacies <> immediacies then + compute_properties_fixpoint env decls required new_variances new_immediacies + else begin + (* List.iter (fun (id, decl) -> + Printf.eprintf "%s:" (Ident.name id); + List.iter (fun (v : Variance.t) -> + Printf.eprintf " %x" (Obj.magic v : int)) + decl.type_variance; + prerr_endline "") + new_decls; *) + List.iter (fun (_, decl) -> + if (marked_as_immediate decl) && (not decl.type_immediate) then + raise (Error (decl.type_loc, Bad_immediate_attribute)) + else ()) + new_decls; + List.iter2 + (fun (id, decl) req -> if not (is_hash id) then + ignore (compute_variance_decl new_env true decl req)) + new_decls required; + new_decls, new_env + end - try - Some (tr_rec Ident.empty e) - with Not_simple -> None +let init_variance (_id, decl) = + List.map (fun _ -> Variance.null) decl.type_params -(***************) +let add_injectivity = + List.map + (function + | Covariant -> (true, false, false) + | Contravariant -> (false, true, false) + | Invariant -> (false, false, false) + ) -let name_lambda strict arg fn = - match arg with - Lvar id -> fn id - | _ -> let id = Ident.create "let" in Llet(strict, Pgenval, id, arg, fn id) +(* for typeclass.ml *) +let compute_variance_decls env cldecls = + let decls, required = + List.fold_right + (fun (obj_id, obj_abbr, _cl_abbr, _clty, _cltydef, ci) (decls, req) -> + let variance = List.map snd ci.ci_params in + (obj_id, obj_abbr) :: decls, + (add_injectivity variance, ci.ci_loc) :: req) + cldecls ([],[]) + in + let (decls, _) = + compute_properties_fixpoint env decls required + (List.map init_variance decls) + (List.map (fun _ -> false) decls) + in + List.map2 + (fun (_,decl) (_, _, cl_abbr, clty, cltydef, _) -> + let variance = decl.type_variance in + (decl, {cl_abbr with type_variance = variance}, + {clty with cty_variance = variance}, + {cltydef with clty_variance = variance})) + decls cldecls -let name_lambda_list args fn = - let rec name_list names = function - [] -> fn (List.rev names) - | (Lvar _ as arg) :: rem -> - name_list (arg :: names) rem - | arg :: rem -> - let id = Ident.create "let" in - Llet(Strict, Pgenval, id, arg, name_list (Lvar id :: names) rem) in - name_list [] args +(* Check multiple declarations of labels/constructors *) +let check_duplicates sdecl_list = + let labels = Hashtbl.create 7 and constrs = Hashtbl.create 7 in + List.iter + (fun sdecl -> match sdecl.ptype_kind with + Ptype_variant cl -> + List.iter + (fun pcd -> + try + let name' = Hashtbl.find constrs pcd.pcd_name.txt in + Location.prerr_warning pcd.pcd_loc + (Warnings.Duplicate_definitions + ("constructor", pcd.pcd_name.txt, name', + sdecl.ptype_name.txt)) + with Not_found -> + Hashtbl.add constrs pcd.pcd_name.txt sdecl.ptype_name.txt) + cl + | Ptype_record fl -> + List.iter + (fun {pld_name=cname;pld_loc=loc} -> + try + let name' = Hashtbl.find labels cname.txt in + Location.prerr_warning loc + (Warnings.Duplicate_definitions + ("label", cname.txt, name', sdecl.ptype_name.txt)) + with Not_found -> Hashtbl.add labels cname.txt sdecl.ptype_name.txt) + fl + | Ptype_abstract -> () + | Ptype_open -> ()) + sdecl_list -let iter_opt f = function - | None -> () - | Some e -> f e +(* Force recursion to go through id for private types*) +let name_recursion sdecl id decl = + match decl with + | { type_kind = Type_abstract; + type_manifest = Some ty; + type_private = Private; } when is_fixed_type sdecl -> + let ty = Ctype.repr ty in + let ty' = Btype.newty2 ty.level ty.desc in + if Ctype.deep_occur ty ty' then + let td = Tconstr(Path.Pident id, decl.type_params, ref Mnil) in + Btype.link_type ty (Btype.newty2 ty.level td); + {decl with type_manifest = Some ty'} + else decl + | _ -> decl -let iter f = function - Lvar _ - | Lconst _ -> () - | Lapply{ap_func = fn; ap_args = args} -> - f fn; List.iter f args - | Lfunction{body} -> - f body - | Llet(_str, _k, _id, arg, body) -> - f arg; f body - | Lletrec(decl, body) -> - f body; - List.iter (fun (_id, exp) -> f exp) decl - | Lprim(_p, args, _loc) -> - List.iter f args - | Lswitch(arg, sw,_) -> - f arg; - List.iter (fun (_key, case) -> f case) sw.sw_consts; - List.iter (fun (_key, case) -> f case) sw.sw_blocks; - iter_opt f sw.sw_failaction - | Lstringswitch (arg,cases,default,_) -> - f arg ; - List.iter (fun (_,act) -> f act) cases ; - iter_opt f default - | Lstaticraise (_,args) -> - List.iter f args - | Lstaticcatch(e1, _, e2) -> - f e1; f e2 - | Ltrywith(e1, _, e2) -> - f e1; f e2 - | Lifthenelse(e1, e2, e3) -> - f e1; f e2; f e3 - | Lsequence(e1, e2) -> - f e1; f e2 - | Lwhile(e1, e2) -> - f e1; f e2 - | Lfor(_v, e1, e2, _dir, e3) -> - f e1; f e2; f e3 - | Lassign(_, e) -> - f e - | Lsend (_k, met, obj, args, _) -> - List.iter f (met::obj::args) - | Levent (lam, _evt) -> - f lam - | Lifused (_v, e) -> - f e +(* Translate a set of type declarations, mutually recursive or not *) +let transl_type_decl env rec_flag sdecl_list = + (* Add dummy types for fixed rows *) + let fixed_types = List.filter is_fixed_type sdecl_list in + let sdecl_list = + List.map + (fun sdecl -> + let ptype_name = + mkloc (sdecl.ptype_name.txt ^"#row") sdecl.ptype_name.loc in + {sdecl with + ptype_name; ptype_kind = Ptype_abstract; ptype_manifest = None}) + fixed_types + @ sdecl_list + in + (* Create identifiers. *) + let id_list = + List.map (fun sdecl -> Ident.create sdecl.ptype_name.txt) sdecl_list + in + (* + Since we've introduced fresh idents, make sure the definition + level is at least the binding time of these events. Otherwise, + passing one of the recursively-defined type constrs as argument + to an abbreviation may fail. + *) + Ctype.init_def(Ident.current_time()); + Ctype.begin_def(); + (* Enter types. *) + let temp_env = + List.fold_left2 (enter_type rec_flag) env sdecl_list id_list in + (* Translate each declaration. *) + let current_slot = ref None in + let warn_unused = Warnings.is_active (Warnings.Unused_type_declaration "") in + let id_slots id = + match rec_flag with + | Asttypes.Recursive when warn_unused -> + (* See typecore.ml for a description of the algorithm used + to detect unused declarations in a set of recursive definitions. *) + let slot = ref [] in + let td = Env.find_type (Path.Pident id) temp_env in + let name = Ident.name id in + Env.set_type_used_callback + name td + (fun old_callback -> + match !current_slot with + | Some slot -> slot := (name, td) :: !slot + | None -> + List.iter (fun (name, d) -> Env.mark_type_used env name d) + (get_ref slot); + old_callback () + ); + id, Some slot + | Asttypes.Recursive | Asttypes.Nonrecursive -> + id, None + in + let transl_declaration name_sdecl (id, slot) = + current_slot := slot; + Builtin_attributes.warning_scope + name_sdecl.ptype_attributes + (fun () -> transl_declaration temp_env name_sdecl id) + in + let tdecls = + List.map2 transl_declaration sdecl_list (List.map id_slots id_list) in + let decls = + List.map (fun tdecl -> (tdecl.typ_id, tdecl.typ_type)) tdecls in + current_slot := None; + (* Check for duplicates *) + check_duplicates sdecl_list; + (* Build the final env. *) + let newenv = + List.fold_right + (fun (id, decl) env -> Env.add_type ~check:true id decl env) + decls env + in + (* Update stubs *) + begin match rec_flag with + | Asttypes.Nonrecursive -> () + | Asttypes.Recursive -> + List.iter2 + (fun id sdecl -> update_type temp_env newenv id sdecl.ptype_loc) + id_list sdecl_list + end; + (* Generalize type declarations. *) + Ctype.end_def(); + List.iter (fun (_, decl) -> generalize_decl decl) decls; + (* Check for ill-formed abbrevs *) + let id_loc_list = + List.map2 (fun id sdecl -> (id, sdecl.ptype_loc)) + id_list sdecl_list + in + List.iter (fun (id, decl) -> + check_well_founded_manifest newenv (List.assoc id id_loc_list) + (Path.Pident id) decl) + decls; + let to_check = + function Path.Pident id -> List.mem_assoc id id_loc_list | _ -> false in + List.iter (fun (id, decl) -> + check_well_founded_decl newenv (List.assoc id id_loc_list) (Path.Pident id) + decl to_check) + decls; + List.iter (check_abbrev_recursion newenv id_loc_list to_check) tdecls; + (* Check that all type variables are closed *) + List.iter2 + (fun sdecl tdecl -> + let decl = tdecl.typ_type in + match Ctype.closed_type_decl decl with + Some ty -> raise(Error(sdecl.ptype_loc, Unbound_type_var(ty,decl))) + | None -> ()) + sdecl_list tdecls; + (* Check that constraints are enforced *) + List.iter2 (check_constraints newenv) sdecl_list decls; + (* Name recursion *) + let decls = + List.map2 (fun sdecl (id, decl) -> id, name_recursion sdecl id decl) + sdecl_list decls + in + (* Add variances to the environment *) + let required = + List.map + (fun sdecl -> + add_injectivity (List.map snd sdecl.ptype_params), + sdecl.ptype_loc + ) + sdecl_list + in + let final_decls, final_env = + compute_properties_fixpoint env decls required + (List.map init_variance decls) + (List.map (fun _ -> false) decls) + in + (* Check re-exportation *) + List.iter2 (check_abbrev final_env) sdecl_list final_decls; + (* Keep original declaration *) + let final_decls = + List.map2 + (fun tdecl (_id2, decl) -> + { tdecl with typ_type = decl } + ) tdecls final_decls + in + (* Done *) + (final_decls, final_env) -module IdentSet = Set.Make(Ident) +(* Translating type extensions *) -let free_ids get l = - let fv = ref IdentSet.empty in - let rec free l = - iter free l; - fv := List.fold_right IdentSet.add (get l) !fv; - match l with - Lfunction{params} -> - List.iter (fun param -> fv := IdentSet.remove param !fv) params - | Llet(_str, _k, id, _arg, _body) -> - fv := IdentSet.remove id !fv - | Lletrec(decl, _body) -> - List.iter (fun (id, _exp) -> fv := IdentSet.remove id !fv) decl - | Lstaticcatch(_e1, (_,vars), _e2) -> - List.iter (fun id -> fv := IdentSet.remove id !fv) vars - | Ltrywith(_e1, exn, _e2) -> - fv := IdentSet.remove exn !fv - | Lfor(v, _e1, _e2, _dir, _e3) -> - fv := IdentSet.remove v !fv - | Lassign(id, _e) -> - fv := IdentSet.add id !fv - | Lvar _ | Lconst _ | Lapply _ - | Lprim _ | Lswitch _ | Lstringswitch _ | Lstaticraise _ - | Lifthenelse _ | Lsequence _ | Lwhile _ - | Lsend _ | Levent _ | Lifused _ -> () - in free l; !fv +let transl_extension_constructor env type_path type_params + typext_params priv sext = + let id = Ident.create sext.pext_name.txt in + let args, ret_type, kind = + match sext.pext_kind with + Pext_decl(sargs, sret_type) -> + let targs, tret_type, args, ret_type, _ = + make_constructor env type_path typext_params + sargs sret_type + in + args, ret_type, Text_decl(targs, tret_type) + | Pext_rebind lid -> + let cdescr = Typetexp.find_constructor env lid.loc lid.txt in + let usage = + if cdescr.cstr_private = Private || priv = Public + then Env.Positive else Env.Privatize + in + Env.mark_constructor usage env (Longident.last lid.txt) cdescr; + let (args, cstr_res) = Ctype.instance_constructor cdescr in + let res, ret_type = + if cdescr.cstr_generalized then + let params = Ctype.instance_list env type_params in + let res = Ctype.newconstr type_path params in + let ret_type = Some (Ctype.newconstr type_path params) in + res, ret_type + else (Ctype.newconstr type_path typext_params), None + in + begin + try + Ctype.unify env cstr_res res + with Ctype.Unify trace -> + raise (Error(lid.loc, + Rebind_wrong_type(lid.txt, env, trace))) + end; + (* Remove "_" names from parameters used in the constructor *) + if not cdescr.cstr_generalized then begin + let vars = + Ctype.free_variables (Btype.newgenty (Ttuple args)) + in + List.iter + (function {desc = Tvar (Some "_")} as ty -> + if List.memq ty vars then ty.desc <- Tvar None + | _ -> ()) + typext_params + end; + (* Ensure that constructor's type matches the type being extended *) + let cstr_type_path, cstr_type_params = + match cdescr.cstr_res.desc with + Tconstr (p, _, _) -> + let decl = Env.find_type p env in + p, decl.type_params + | _ -> assert false + in + let cstr_types = + (Btype.newgenty + (Tconstr(cstr_type_path, cstr_type_params, ref Mnil))) + :: cstr_type_params + in + let ext_types = + (Btype.newgenty + (Tconstr(type_path, type_params, ref Mnil))) + :: type_params + in + if not (Ctype.equal env true cstr_types ext_types) then + raise (Error(lid.loc, + Rebind_mismatch(lid.txt, cstr_type_path, type_path))); + (* Disallow rebinding private constructors to non-private *) + begin + match cdescr.cstr_private, priv with + Private, Public -> + raise (Error(lid.loc, Rebind_private lid.txt)) + | _ -> () + end; + let path = + match cdescr.cstr_tag with + Cstr_extension(path, _) -> path + | _ -> assert false + in + let args = + match cdescr.cstr_inlined with + | None -> + Types.Cstr_tuple args + | Some decl -> + let tl = + match args with + | [ {desc=Tconstr(_, tl, _)} ] -> tl + | _ -> assert false + in + let decl = Ctype.instance_declaration decl in + assert (List.length decl.type_params = List.length tl); + List.iter2 (Ctype.unify env) decl.type_params tl; + let lbls = + match decl.type_kind with + | Type_record (lbls, Record_extension) -> lbls + | _ -> assert false + in + Types.Cstr_record lbls + in + args, ret_type, Text_rebind(path, lid) + in + let ext = + { ext_type_path = type_path; + ext_type_params = typext_params; + ext_args = args; + ext_ret_type = ret_type; + ext_private = priv; + Types.ext_loc = sext.pext_loc; + Types.ext_attributes = sext.pext_attributes; } + in + { ext_id = id; + ext_name = sext.pext_name; + ext_type = ext; + ext_kind = kind; + Typedtree.ext_loc = sext.pext_loc; + Typedtree.ext_attributes = sext.pext_attributes; } -let free_variables l = - free_ids (function Lvar id -> [id] | _ -> []) l +let transl_extension_constructor env type_path type_params + typext_params priv sext = + Builtin_attributes.warning_scope sext.pext_attributes + (fun () -> transl_extension_constructor env type_path type_params + typext_params priv sext) -let free_methods l = - free_ids (function Lsend(Self, Lvar meth, _, _, _) -> [meth] | _ -> []) l +let transl_type_extension extend env loc styext = + reset_type_variables(); + Ctype.begin_def(); + let (type_path, type_decl) = + let lid = styext.ptyext_path in + Typetexp.find_type env lid.loc lid.txt + in + begin + match type_decl.type_kind with + | Type_open -> begin + match type_decl.type_private with + | Private when extend -> begin + match + List.find + (function {pext_kind = Pext_decl _} -> true + | {pext_kind = Pext_rebind _} -> false) + styext.ptyext_constructors + with + | {pext_loc} -> + raise (Error(pext_loc, Cannot_extend_private_type type_path)) + | exception Not_found -> () + end + | _ -> () + end + | _ -> + raise (Error(loc, Not_extensible_type type_path)) + end; + let type_variance = + List.map (fun v -> + let (co, cn) = Variance.get_upper v in + (not cn, not co, false)) + type_decl.type_variance + in + let err = + if type_decl.type_arity <> List.length styext.ptyext_params then + [Includecore.Arity] + else + if List.for_all2 + (fun (c1, n1, _) (c2, n2, _) -> (not c2 || c1) && (not n2 || n1)) + type_variance + (add_injectivity (List.map snd styext.ptyext_params)) + then [] else [Includecore.Variance] + in + if err <> [] then + raise (Error(loc, Extension_mismatch (type_path, err))); + let ttype_params = make_params env styext.ptyext_params in + let type_params = List.map (fun (cty, _) -> cty.ctyp_type) ttype_params in + List.iter2 (Ctype.unify_var env) + (Ctype.instance_list env type_decl.type_params) + type_params; + let constructors = + List.map (transl_extension_constructor env type_path + type_decl.type_params type_params styext.ptyext_private) + styext.ptyext_constructors + in + Ctype.end_def(); + (* Generalize types *) + List.iter Ctype.generalize type_params; + List.iter + (fun ext -> + Btype.iter_type_expr_cstr_args Ctype.generalize ext.ext_type.ext_args; + may Ctype.generalize ext.ext_type.ext_ret_type) + constructors; + (* Check that all type variables are closed *) + List.iter + (fun ext -> + match Ctype.closed_extension_constructor ext.ext_type with + Some ty -> + raise(Error(ext.ext_loc, Unbound_type_var_ext(ty, ext.ext_type))) + | None -> ()) + constructors; + (* Check variances are correct *) + List.iter + (fun ext-> + ignore (compute_variance_extension env true type_decl + ext.ext_type (type_variance, loc))) + constructors; + (* Add extension constructors to the environment *) + let newenv = + List.fold_left + (fun env ext -> + Env.add_extension ~check:true ext.ext_id ext.ext_type env) + env constructors + in + let tyext = + { tyext_path = type_path; + tyext_txt = styext.ptyext_path; + tyext_params = ttype_params; + tyext_constructors = constructors; + tyext_private = styext.ptyext_private; + tyext_attributes = styext.ptyext_attributes; } + in + (tyext, newenv) -(* Check if an action has a "when" guard *) -let raise_count = ref 0 +let transl_type_extension extend env loc styext = + Builtin_attributes.warning_scope styext.ptyext_attributes + (fun () -> transl_type_extension extend env loc styext) -let next_raise_count () = - incr raise_count ; - !raise_count +let transl_exception env sext = + reset_type_variables(); + Ctype.begin_def(); + let ext = + transl_extension_constructor env + Predef.path_exn [] [] Asttypes.Public sext + in + Ctype.end_def(); + (* Generalize types *) + Btype.iter_type_expr_cstr_args Ctype.generalize ext.ext_type.ext_args; + may Ctype.generalize ext.ext_type.ext_ret_type; + (* Check that all type variables are closed *) + begin match Ctype.closed_extension_constructor ext.ext_type with + Some ty -> + raise (Error(ext.ext_loc, Unbound_type_var_ext(ty, ext.ext_type))) + | None -> () + end; + let newenv = Env.add_extension ~check:true ext.ext_id ext.ext_type env in + ext, newenv -let negative_raise_count = ref 0 +type native_repr_attribute = + | Native_repr_attr_absent + | Native_repr_attr_present of native_repr_kind -let next_negative_raise_count () = - decr negative_raise_count ; - !negative_raise_count +let get_native_repr_attribute attrs ~global_repr = + match + Attr_helper.get_no_payload_attribute ["unboxed"; "ocaml.unboxed"] attrs, + Attr_helper.get_no_payload_attribute ["untagged"; "ocaml.untagged"] attrs, + global_repr + with + | None, None, None -> Native_repr_attr_absent + | None, None, Some repr -> Native_repr_attr_present repr + | Some _, None, None -> Native_repr_attr_present Unboxed + | None, Some _, None -> Native_repr_attr_present Untagged + | Some { Location.loc }, _, _ + | _, Some { Location.loc }, _ -> + raise (Error (loc, Multiple_native_repr_attributes)) -(* Anticipated staticraise, for guards *) -let staticfail = Lstaticraise (0,[]) +let native_repr_of_type env kind ty = + match kind, (Ctype.expand_head_opt env ty).desc with + | Untagged, Tconstr (path, _, _) when Path.same path Predef.path_int -> + Some Untagged_int + | Unboxed, Tconstr (path, _, _) when Path.same path Predef.path_float -> + Some Unboxed_float + | Unboxed, Tconstr (path, _, _) when Path.same path Predef.path_int32 -> + Some (Unboxed_integer Pint32) + | Unboxed, Tconstr (path, _, _) when Path.same path Predef.path_int64 -> + Some (Unboxed_integer Pint64) + | Unboxed, Tconstr (path, _, _) when Path.same path Predef.path_nativeint -> + Some (Unboxed_integer Pnativeint) + | _ -> + None -let rec is_guarded = function - | Lifthenelse(_cond, _body, Lstaticraise (0,[])) -> true - | Llet(_str, _k, _id, _lam, body) -> is_guarded body - | Levent(lam, _ev) -> is_guarded lam - | _ -> false +(* Raises an error when [core_type] contains an [@unboxed] or [@untagged] + attribute in a strict sub-term. *) +let error_if_has_deep_native_repr_attributes core_type = + let open Ast_iterator in + let this_iterator = + { default_iterator with typ = fun iterator core_type -> + begin + match + get_native_repr_attribute core_type.ptyp_attributes ~global_repr:None + with + | Native_repr_attr_present kind -> + raise (Error (core_type.ptyp_loc, + Deep_unbox_or_untag_attribute kind)) + | Native_repr_attr_absent -> () + end; + default_iterator.typ iterator core_type } + in + default_iterator.typ this_iterator core_type -let rec patch_guarded patch = function - | Lifthenelse (cond, body, Lstaticraise (0,[])) -> - Lifthenelse (cond, body, patch) - | Llet(str, k, id, lam, body) -> - Llet (str, k, id, lam, patch_guarded patch body) - | Levent(lam, ev) -> - Levent (patch_guarded patch lam, ev) - | _ -> fatal_error "Lambda.patch_guarded" +let make_native_repr env core_type ty ~global_repr = + error_if_has_deep_native_repr_attributes core_type; + match get_native_repr_attribute core_type.ptyp_attributes ~global_repr with + | Native_repr_attr_absent -> + Same_as_ocaml_repr + | Native_repr_attr_present kind -> + begin match native_repr_of_type env kind ty with + | None -> + raise (Error (core_type.ptyp_loc, Cannot_unbox_or_untag_type kind)) + | Some repr -> repr + end -(* Translate an access path *) +let rec parse_native_repr_attributes env core_type ty ~global_repr = + match core_type.ptyp_desc, (Ctype.repr ty).desc, + get_native_repr_attribute core_type.ptyp_attributes ~global_repr:None + with + | Ptyp_arrow _, Tarrow _, Native_repr_attr_present kind -> + raise (Error (core_type.ptyp_loc, Cannot_unbox_or_untag_type kind)) + | Ptyp_arrow (_, ct1, ct2), Tarrow (_, t1, t2, _), _ -> + let repr_arg = make_native_repr env ct1 t1 ~global_repr in + let repr_args, repr_res = + parse_native_repr_attributes env ct2 t2 ~global_repr + in + (repr_arg :: repr_args, repr_res) + | Ptyp_arrow _, _, _ | _, Tarrow _, _ -> assert false + | _ -> ([], make_native_repr env core_type ty ~global_repr) -let rec transl_normal_path = function - Pident id -> - if Ident.global id - then Lprim(Pgetglobal id, [], Location.none) - else Lvar id - | Pdot(p, s, pos) -> - Lprim(Pfield (pos, Fld_module s), [transl_normal_path p], Location.none) - | Papply _ -> - fatal_error "Lambda.transl_path" -(* Translation of identifiers *) +let check_unboxable env loc ty = + let ty = Ctype.repr (Ctype.expand_head_opt env ty) in + try match ty.desc with + | Tconstr (p, _, _) -> + let tydecl = Env.find_type p env in + if tydecl.type_unboxed.unboxed then + Location.prerr_warning loc + (Warnings.Unboxable_type_in_prim_decl (Path.name p)) + | _ -> () + with Not_found -> () -let transl_module_path ?(loc=Location.none) env path = - transl_normal_path (Env.normalize_path (Some loc) env path) +(* Translate a value declaration *) +let transl_value_decl env loc valdecl = + let cty = Typetexp.transl_type_scheme env valdecl.pval_type in + let ty = cty.ctyp_type in + let v = + match valdecl.pval_prim with + [] when Env.is_in_signature env -> + { val_type = ty; val_kind = Val_reg; Types.val_loc = loc; + val_attributes = valdecl.pval_attributes } + | [] -> + raise (Error(valdecl.pval_loc, Val_in_structure)) + | _ -> + let global_repr = + match + get_native_repr_attribute valdecl.pval_attributes ~global_repr:None + with + | Native_repr_attr_present repr -> Some repr + | Native_repr_attr_absent -> None + in + let native_repr_args, native_repr_res = + if !Clflags.bs_only then + let rec scann (attrs : Parsetree.attributes) = + match attrs with + | ({txt = "internal.arity";_}, + PStr [ {pstr_desc = Pstr_eval + ( + ({pexp_desc = Pexp_constant (Pconst_integer (i,_))} : + Parsetree.expression) ,_)}]) :: _ -> + Some (int_of_string i) + | _ :: rest -> scann rest + | [] -> None + and make n = + if n = 0 then [] + else Primitive.Same_as_ocaml_repr :: make (n - 1) + in + match scann valdecl.pval_attributes with + | None -> parse_native_repr_attributes env valdecl.pval_type ty ~global_repr + | Some x -> make x , Primitive.Same_as_ocaml_repr + else + parse_native_repr_attributes env valdecl.pval_type ty ~global_repr + in + let prim = + Primitive.parse_declaration valdecl + ~native_repr_args + ~native_repr_res + in + let prim_native_name = prim.prim_native_name in + if prim.prim_arity = 0 && + not ( String.length prim_native_name > 3 && + String.unsafe_get prim_native_name 0 = 'B' && + String.unsafe_get prim_native_name 1 = 'S' && + String.unsafe_get prim_native_name 2 = ':' + ) && + (prim.prim_name = "" || (prim.prim_name.[0] <> '%' && prim.prim_name.[0] <> '#')) then + raise(Error(valdecl.pval_type.ptyp_loc, Null_arity_external)); + if !Clflags.native_code + && prim.prim_arity > 5 + && prim_native_name = "" + then raise(Error(valdecl.pval_type.ptyp_loc, Missing_native_external)); + Btype.iter_type_expr (check_unboxable env loc) ty; + { val_type = ty; val_kind = Val_prim prim; Types.val_loc = loc; + val_attributes = valdecl.pval_attributes } + in + let (id, newenv) = + Env.enter_value valdecl.pval_name.txt v env + ~check:(fun s -> Warnings.Unused_value_declaration s) + in + let desc = + { + val_id = id; + val_name = valdecl.pval_name; + val_desc = cty; val_val = v; + val_prim = valdecl.pval_prim; + val_loc = valdecl.pval_loc; + val_attributes = valdecl.pval_attributes; + } + in + desc, newenv -let transl_value_path ?(loc=Location.none) env path = - transl_normal_path (Env.normalize_path_prefix (Some loc) env path) +let transl_value_decl env loc valdecl = + Builtin_attributes.warning_scope valdecl.pval_attributes + (fun () -> transl_value_decl env loc valdecl) -let transl_class_path = transl_value_path -let transl_extension_path = transl_value_path +(* Translate a "with" constraint -- much simplified version of + transl_type_decl. *) +let transl_with_constraint env id row_path orig_decl sdecl = + Env.mark_type_used env (Ident.name id) orig_decl; + reset_type_variables(); + Ctype.begin_def(); + let tparams = make_params env sdecl.ptype_params in + let params = List.map (fun (cty, _) -> cty.ctyp_type) tparams in + let orig_decl = Ctype.instance_declaration orig_decl in + let arity_ok = List.length params = orig_decl.type_arity in + if arity_ok then + List.iter2 (Ctype.unify_var env) params orig_decl.type_params; + let constraints = List.map + (function (ty, ty', loc) -> + try + let cty = transl_simple_type env false ty in + let cty' = transl_simple_type env false ty' in + let ty = cty.ctyp_type in + let ty' = cty'.ctyp_type in + Ctype.unify env ty ty'; + (cty, cty', loc) + with Ctype.Unify tr -> + raise(Error(loc, Inconsistent_constraint (env, tr)))) + sdecl.ptype_cstrs + in + let no_row = not (is_fixed_type sdecl) in + let (tman, man) = match sdecl.ptype_manifest with + None -> None, None + | Some sty -> + let cty = transl_simple_type env no_row sty in + Some cty, Some cty.ctyp_type + in + let priv = + if sdecl.ptype_private = Private then Private else + if arity_ok && orig_decl.type_kind <> Type_abstract + then orig_decl.type_private else sdecl.ptype_private + in + if arity_ok && orig_decl.type_kind <> Type_abstract + && sdecl.ptype_private = Private then + Location.deprecated sdecl.ptype_loc "spurious use of private"; + let type_kind, type_unboxed = + if arity_ok && man <> None then + orig_decl.type_kind, orig_decl.type_unboxed + else + Type_abstract, unboxed_false_default_false + in + let decl = + { type_params = params; + type_arity = List.length params; + type_kind; + type_private = priv; + type_manifest = man; + type_variance = []; + type_newtype_level = None; + type_loc = sdecl.ptype_loc; + type_attributes = sdecl.ptype_attributes; + type_immediate = false; + type_unboxed; + } + in + begin match row_path with None -> () + | Some p -> set_fixed_row env sdecl.ptype_loc p decl + end; + begin match Ctype.closed_type_decl decl with None -> () + | Some ty -> raise(Error(sdecl.ptype_loc, Unbound_type_var(ty,decl))) + end; + let decl = name_recursion sdecl id decl in + let type_variance = + compute_variance_decl env true decl + (add_injectivity (List.map snd sdecl.ptype_params), sdecl.ptype_loc) + in + let type_immediate = compute_immediacy env decl in + let decl = {decl with type_variance; type_immediate} in + Ctype.end_def(); + generalize_decl decl; + { + typ_id = id; + typ_name = sdecl.ptype_name; + typ_params = tparams; + typ_type = decl; + typ_cstrs = constraints; + typ_loc = sdecl.ptype_loc; + typ_manifest = tman; + typ_kind = Ttype_abstract; + typ_private = sdecl.ptype_private; + typ_attributes = sdecl.ptype_attributes; + } -(* compatibility alias, deprecated in the .mli *) -let transl_path = transl_value_path +(* Approximate a type declaration: just make all types abstract *) -(* Compile a sequence of expressions *) +let abstract_type_decl arity = + let rec make_params n = + if n <= 0 then [] else Ctype.newvar() :: make_params (n-1) in + Ctype.begin_def(); + let decl = + { type_params = make_params arity; + type_arity = arity; + type_kind = Type_abstract; + type_private = Public; + type_manifest = None; + type_variance = replicate_list Variance.full arity; + type_newtype_level = None; + type_loc = Location.none; + type_attributes = []; + type_immediate = false; + type_unboxed = unboxed_false_default_false; + } in + Ctype.end_def(); + generalize_decl decl; + decl -let rec make_sequence fn = function - [] -> lambda_unit - | [x] -> fn x - | x::rem -> - let lam = fn x in Lsequence(lam, make_sequence fn rem) +let approx_type_decl sdecl_list = + List.map + (fun sdecl -> + (Ident.create sdecl.ptype_name.txt, + abstract_type_decl (List.length sdecl.ptype_params))) + sdecl_list -(* Apply a substitution to a lambda-term. - Assumes that the bound variables of the lambda-term do not - belong to the domain of the substitution. - Assumes that the image of the substitution is out of reach - of the bound variables of the lambda-term (no capture). *) +(* Variant of check_abbrev_recursion to check the well-formedness + conditions on type abbreviations defined within recursive modules. *) -let subst_lambda s lam = - let rec subst = function - Lvar id as l -> - begin try Ident.find_same id s with Not_found -> l end - | Lconst _ as l -> l - | Lapply ap -> - Lapply{ap with ap_func = subst ap.ap_func; - ap_args = List.map subst ap.ap_args} - | Lfunction{kind; params; body; attr; loc} -> - Lfunction{kind; params; body = subst body; attr; loc} - | Llet(str, k, id, arg, body) -> Llet(str, k, id, subst arg, subst body) - | Lletrec(decl, body) -> Lletrec(List.map subst_decl decl, subst body) - | Lprim(p, args, loc) -> Lprim(p, List.map subst args, loc) - | Lswitch(arg, sw, loc) -> - Lswitch(subst arg, - {sw with sw_consts = List.map subst_case sw.sw_consts; - sw_blocks = List.map subst_case sw.sw_blocks; - sw_failaction = subst_opt sw.sw_failaction; }, - loc) - | Lstringswitch (arg,cases,default,loc) -> - Lstringswitch - (subst arg,List.map subst_strcase cases,subst_opt default,loc) - | Lstaticraise (i,args) -> Lstaticraise (i, List.map subst args) - | Lstaticcatch(e1, io, e2) -> Lstaticcatch(subst e1, io, subst e2) - | Ltrywith(e1, exn, e2) -> Ltrywith(subst e1, exn, subst e2) - | Lifthenelse(e1, e2, e3) -> Lifthenelse(subst e1, subst e2, subst e3) - | Lsequence(e1, e2) -> Lsequence(subst e1, subst e2) - | Lwhile(e1, e2) -> Lwhile(subst e1, subst e2) - | Lfor(v, e1, e2, dir, e3) -> Lfor(v, subst e1, subst e2, dir, subst e3) - | Lassign(id, e) -> Lassign(id, subst e) - | Lsend (k, met, obj, args, loc) -> - Lsend (k, subst met, subst obj, List.map subst args, loc) - | Levent (lam, evt) -> Levent (subst lam, evt) - | Lifused (v, e) -> Lifused (v, subst e) - and subst_decl (id, exp) = (id, subst exp) - and subst_case (key, case) = (key, subst case) - and subst_strcase (key, case) = (key, subst case) - and subst_opt = function - | None -> None - | Some e -> Some (subst e) - in subst lam +let check_recmod_typedecl env loc recmod_ids path decl = + (* recmod_ids is the list of recursively-defined module idents. + (path, decl) is the type declaration to be checked. *) + let to_check path = + List.exists (fun id -> Path.isfree id path) recmod_ids in + check_well_founded_decl env loc path decl to_check; + check_recursion env loc path decl to_check -let rec map f lam = - let lam = - match lam with - | Lvar _ -> lam - | Lconst _ -> lam - | Lapply { ap_func; ap_args; ap_loc; ap_should_be_tailcall; - ap_inlined; ap_specialised } -> - Lapply { - ap_func = map f ap_func; - ap_args = List.map (map f) ap_args; - ap_loc; - ap_should_be_tailcall; - ap_inlined; - ap_specialised; - } - | Lfunction { kind; params; body; attr; loc; } -> - Lfunction { kind; params; body = map f body; attr; loc; } - | Llet (str, k, v, e1, e2) -> - Llet (str, k, v, map f e1, map f e2) - | Lletrec (idel, e2) -> - Lletrec (List.map (fun (v, e) -> (v, map f e)) idel, map f e2) - | Lprim (p, el, loc) -> - Lprim (p, List.map (map f) el, loc) - | Lswitch (e, sw, loc) -> - Lswitch (map f e, - { sw_numconsts = sw.sw_numconsts; - sw_consts = List.map (fun (n, e) -> (n, map f e)) sw.sw_consts; - sw_numblocks = sw.sw_numblocks; - sw_blocks = List.map (fun (n, e) -> (n, map f e)) sw.sw_blocks; - sw_failaction = Misc.may_map (map f) sw.sw_failaction; - sw_names = sw.sw_names - }, - loc) - | Lstringswitch (e, sw, default, loc) -> - Lstringswitch ( - map f e, - List.map (fun (s, e) -> (s, map f e)) sw, - Misc.may_map (map f) default, - loc) - | Lstaticraise (i, args) -> - Lstaticraise (i, List.map (map f) args) - | Lstaticcatch (body, id, handler) -> - Lstaticcatch (map f body, id, map f handler) - | Ltrywith (e1, v, e2) -> - Ltrywith (map f e1, v, map f e2) - | Lifthenelse (e1, e2, e3) -> - Lifthenelse (map f e1, map f e2, map f e3) - | Lsequence (e1, e2) -> - Lsequence (map f e1, map f e2) - | Lwhile (e1, e2) -> - Lwhile (map f e1, map f e2) - | Lfor (v, e1, e2, dir, e3) -> - Lfor (v, map f e1, map f e2, dir, map f e3) - | Lassign (v, e) -> - Lassign (v, map f e) - | Lsend (k, m, o, el, loc) -> - Lsend (k, map f m, map f o, List.map (map f) el, loc) - | Levent (l, ev) -> - Levent (map f l, ev) - | Lifused (v, e) -> - Lifused (v, map f e) - in - f lam -(* To let-bind expressions to variables *) +(**** Error report ****) -let bind str var exp body = - match exp with - Lvar var' when Ident.same var var' -> body - | _ -> Llet(str, Pgenval, var, exp, body) +open Format -and commute_comparison = function -| Ceq -> Ceq| Cneq -> Cneq -| Clt -> Cgt | Cle -> Cge -| Cgt -> Clt | Cge -> Cle +let explain_unbound_gen ppf tv tl typ kwd pr = + try + let ti = List.find (fun ti -> Ctype.deep_occur tv (typ ti)) tl in + let ty0 = (* Hack to force aliasing when needed *) + Btype.newgenty (Tobject(tv, ref None)) in + Printtyp.reset_and_mark_loops_list [typ ti; ty0]; + fprintf ppf + ".@.@[In %s@ %a@;<1 -2>the variable %a is unbound@]" + kwd pr ti Printtyp.type_expr tv + with Not_found -> () -and negate_comparison = function -| Ceq -> Cneq| Cneq -> Ceq -| Clt -> Cge | Cle -> Cgt -| Cgt -> Cle | Cge -> Clt +let explain_unbound ppf tv tl typ kwd lab = + explain_unbound_gen ppf tv tl typ kwd + (fun ppf ti -> fprintf ppf "%s%a" (lab ti) Printtyp.type_expr (typ ti)) -let raise_kind = function - | Raise_regular -> "raise" - | Raise_reraise -> "reraise" - | Raise_notrace -> "raise_notrace" +let explain_unbound_single ppf tv ty = + let trivial ty = + explain_unbound ppf tv [ty] (fun t -> t) "type" (fun _ -> "") in + match (Ctype.repr ty).desc with + Tobject(fi,_) -> + let (tl, rv) = Ctype.flatten_fields fi in + if rv == tv then trivial ty else + explain_unbound ppf tv tl (fun (_,_,t) -> t) + "method" (fun (lab,_,_) -> lab ^ ": ") + | Tvariant row -> + let row = Btype.row_repr row in + if row.row_more == tv then trivial ty else + explain_unbound ppf tv row.row_fields + (fun (_l,f) -> match Btype.row_field_repr f with + Rpresent (Some t) -> t + | Reither (_,[t],_,_) -> t + | Reither (_,tl,_,_) -> Btype.newgenty (Ttuple tl) + | _ -> Btype.newgenty (Ttuple[])) + "case" (fun (lab,_) -> "`" ^ lab ^ " of ") + | _ -> trivial ty -let lam_of_loc kind loc = - let loc_start = loc.Location.loc_start in - let (file, lnum, cnum) = Location.get_pos_info loc_start in - - let file = Filename.basename file in - let enum = loc.Location.loc_end.Lexing.pos_cnum - - loc_start.Lexing.pos_cnum + cnum in - match kind with - | Loc_POS -> - Lconst (Const_block (0, Blk_tuple, [ - Const_immstring file; - Const_base (Const_int lnum); - Const_base (Const_int cnum); - Const_base (Const_int enum); - ])) - | Loc_FILE -> Lconst (Const_immstring file) - | Loc_MODULE -> - let filename = Filename.basename file in - let name = Env.get_unit_name () in - let module_name = if name = "" then "//"^filename^"//" else name in - Lconst (Const_immstring module_name) - | Loc_LOC -> - let loc = Printf.sprintf "File %S, line %d, characters %d-%d" - file lnum cnum enum in - Lconst (Const_immstring loc) - | Loc_LINE -> Lconst (Const_base (Const_int lnum)) +let tys_of_constr_args = function + | Types.Cstr_tuple tl -> tl + | Types.Cstr_record lbls -> List.map (fun l -> l.Types.ld_type) lbls -let merge_inline_attributes attr1 attr2 = - match attr1, attr2 with - | Default_inline, _ -> Some attr2 - | _, Default_inline -> Some attr1 - | _, _ -> - if attr1 = attr2 then Some attr1 - else None +let report_error ppf = function + | Repeated_parameter -> + fprintf ppf "A type parameter occurs several times" + | Duplicate_constructor s -> + fprintf ppf "Two constructors are named %s" s + | Too_many_constructors -> + fprintf ppf + "@[Too many non-constant constructors@ -- maximum is %i %s@]" + (Config.max_tag + 1) "non-constant constructors" + | Duplicate_label s -> + fprintf ppf "Two labels are named %s" s + | Recursive_abbrev s -> + fprintf ppf "The type abbreviation %s is cyclic" s + | Cycle_in_def (s, ty) -> + Printtyp.reset_and_mark_loops ty; + fprintf ppf "@[The definition of %s contains a cycle:@ %a@]" + s Printtyp.type_expr ty + | Definition_mismatch (ty, errs) -> + Printtyp.reset_and_mark_loops ty; + fprintf ppf "@[@[%s@ %s@;<1 2>%a@]%a@]" + "This variant or record definition" "does not match that of type" + Printtyp.type_expr ty + (Includecore.report_type_mismatch "the original" "this" "definition") + errs + | Constraint_failed (ty, ty') -> + Printtyp.reset_and_mark_loops ty; + Printtyp.mark_loops ty'; + fprintf ppf "@[%s@ @[Type@ %a@ should be an instance of@ %a@]@]" + "Constraints are not satisfied in this type." + Printtyp.type_expr ty Printtyp.type_expr ty' + | Parameters_differ (path, ty, ty') -> + Printtyp.reset_and_mark_loops ty; + Printtyp.mark_loops ty'; + fprintf ppf + "@[In the definition of %s, type@ %a@ should be@ %a@]" + (Path.name path) Printtyp.type_expr ty Printtyp.type_expr ty' + | Inconsistent_constraint (env, trace) -> + fprintf ppf "The type constraints are not consistent.@."; + Printtyp.report_unification_error ppf env trace + (fun ppf -> fprintf ppf "Type") + (fun ppf -> fprintf ppf "is not compatible with type") + | Type_clash (env, trace) -> + Printtyp.report_unification_error ppf env trace + (function ppf -> + fprintf ppf "This type constructor expands to type") + (function ppf -> + fprintf ppf "but is used here with type") + | Null_arity_external -> + fprintf ppf "External identifiers must be functions" + | Missing_native_external -> + fprintf ppf "@[An external function with more than 5 arguments \ + requires a second stub function@ \ + for native-code compilation@]" + | Unbound_type_var (ty, decl) -> + fprintf ppf "A type variable is unbound in this type declaration"; + let ty = Ctype.repr ty in + begin match decl.type_kind, decl.type_manifest with + | Type_variant tl, _ -> + explain_unbound_gen ppf ty tl (fun c -> + let tl = tys_of_constr_args c.Types.cd_args in + Btype.newgenty (Ttuple tl) + ) + "case" (fun ppf c -> + fprintf ppf + "%s of %a" (Ident.name c.Types.cd_id) + Printtyp.constructor_arguments c.Types.cd_args) + | Type_record (tl, _), _ -> + explain_unbound ppf ty tl (fun l -> l.Types.ld_type) + "field" (fun l -> Ident.name l.Types.ld_id ^ ": ") + | Type_abstract, Some ty' -> + explain_unbound_single ppf ty ty' + | _ -> () + end + | Unbound_type_var_ext (ty, ext) -> + fprintf ppf "A type variable is unbound in this extension constructor"; + let args = tys_of_constr_args ext.ext_args in + explain_unbound ppf ty args (fun c -> c) "type" (fun _ -> "") + | Cannot_extend_private_type path -> + fprintf ppf "@[%s@ %a@]" + "Cannot extend private type definition" + Printtyp.path path + | Not_extensible_type path -> + fprintf ppf "@[%s@ %a@ %s@]" + "Type definition" + Printtyp.path path + "is not extensible" + | Extension_mismatch (path, errs) -> + fprintf ppf "@[@[%s@ %s@;<1 2>%s@]%a@]" + "This extension" "does not match the definition of type" + (Path.name path) + (Includecore.report_type_mismatch + "the type" "this extension" "definition") + errs + | Rebind_wrong_type (lid, env, trace) -> + Printtyp.report_unification_error ppf env trace + (function ppf -> + fprintf ppf "The constructor %a@ has type" + Printtyp.longident lid) + (function ppf -> + fprintf ppf "but was expected to be of type") + | Rebind_mismatch (lid, p, p') -> + fprintf ppf + "@[%s@ %a@ %s@ %s@ %s@ %s@ %s@]" + "The constructor" Printtyp.longident lid + "extends type" (Path.name p) + "whose declaration does not match" + "the declaration of type" (Path.name p') + | Rebind_private lid -> + fprintf ppf "@[%s@ %a@ %s@]" + "The constructor" + Printtyp.longident lid + "is private" + | Bad_variance (n, v1, v2) -> + let variance (p,n,i) = + let inj = if i then "injective " else "" in + match p, n with + true, true -> inj ^ "invariant" + | true, false -> inj ^ "covariant" + | false, true -> inj ^ "contravariant" + | false, false -> if inj = "" then "unrestricted" else inj + in + let suffix n = + let teen = (n mod 100)/10 = 1 in + match n mod 10 with + | 1 when not teen -> "st" + | 2 when not teen -> "nd" + | 3 when not teen -> "rd" + | _ -> "th" + in + if n = -1 then + fprintf ppf "@[%s@ %s@ It" + "In this definition, a type variable has a variance that" + "is not reflected by its occurrence in type parameters." + else if n = -2 then + fprintf ppf "@[%s@ %s@]" + "In this definition, a type variable cannot be deduced" + "from the type parameters." + else if n = -3 then + fprintf ppf "@[%s@ %s@ It" + "In this definition, a type variable has a variance that" + "cannot be deduced from the type parameters." + else + fprintf ppf "@[%s@ %s@ The %d%s type parameter" + "In this definition, expected parameter" + "variances are not satisfied." + n (suffix n); + if n <> -2 then + fprintf ppf " was expected to be %s,@ but it is %s.@]" + (variance v2) (variance v1) + | Unavailable_type_constructor p -> + fprintf ppf "The definition of type %a@ is unavailable" Printtyp.path p + | Bad_fixed_type r -> + fprintf ppf "This fixed type %s" r + | Varying_anonymous -> + fprintf ppf "@[%s@ %s@ %s@]" + "In this GADT definition," "the variance of some parameter" + "cannot be checked" + | Val_in_structure -> + fprintf ppf "Value declarations are only allowed in signatures" + | Multiple_native_repr_attributes -> + fprintf ppf "Too many [@@unboxed]/[@@untagged] attributes" + | Cannot_unbox_or_untag_type Unboxed -> + fprintf ppf "Don't know how to unbox this type. Only float, int32, \ + int64 and nativeint can be unboxed" + | Cannot_unbox_or_untag_type Untagged -> + fprintf ppf "Don't know how to untag this type. Only int \ + can be untagged" + | Deep_unbox_or_untag_attribute kind -> + fprintf ppf + "The attribute '%s' should be attached to a direct argument or \ + result of the primitive, it should not occur deeply into its type" + (match kind with Unboxed -> "@unboxed" | Untagged -> "@untagged") + | Bad_immediate_attribute -> + fprintf ppf "@[%s@ %s@]" + "Types marked with the immediate attribute must be" + "non-pointer types like int or bool" + | Bad_unboxed_attribute msg -> + fprintf ppf "@[This type cannot be unboxed because@ %s.@]" msg + | Wrong_unboxed_type_float -> + fprintf ppf "@[This type cannot be unboxed because@ \ + it might contain both float and non-float values.@ \ + You should annotate it with [%@%@ocaml.boxed].@]" + | Boxed_and_unboxed -> + fprintf ppf "@[A type cannot be boxed and unboxed at the same time.@]" + | Nonrec_gadt -> + fprintf ppf + "@[GADT case syntax cannot be used in a 'nonrec' block.@]" -let reset () = - raise_count := 0 +let () = + Location.register_error_of_exn + (function + | Error (loc, err) -> + Some (Location.error_of_printer loc report_error err) + | _ -> + None + ) end module Typeopt : sig @@ -85777,7 +85933,7 @@ type meth_kind = Lambda.meth_kind type field_dbg_info = Lambda.field_dbg_info = | Fld_na - | Fld_record of string + | Fld_record of {name : string; mutable_flag : Asttypes.mutable_flag} | Fld_module of string | Fld_record_inline of string @@ -85989,7 +86145,7 @@ type meth_kind = Lambda.meth_kind type field_dbg_info = Lambda.field_dbg_info = | Fld_na - | Fld_record of string + | Fld_record of {name : string; mutable_flag : Asttypes.mutable_flag} | Fld_module of string | Fld_record_inline of string @@ -86000,7 +86156,7 @@ let str_of_field_info (x : field_dbg_info) : string option = match x with | Fld_na | Fld_tuple -> None - | Fld_record s + | Fld_record {name = s} | Fld_module s | Fld_record_inline s | Fld_record_extension s @@ -95143,7 +95299,7 @@ let array_index_by_int ?comment (e : t) (pos : int32) : t = | _ -> { expression_desc = Array_index (e, int ?comment pos); comment = None} let record_access (e : t) (name : string) (pos : int32) = - let name = Ext_ident.convert name in + (* let name = Ext_ident.convert name in *) match e.expression_desc with | Array (l,_) (* Float i -- should not appear here *) | Caml_block (l,_, _, _) when no_side_effect e @@ -97729,8 +97885,9 @@ and expression_desc cxt ~(level:int) f x : cxt = (Ext_list.map_combine fields el Ext_ident.convert))) | Caml_block(el,_, _, Blk_record fields) -> expression_desc cxt ~level f (Object ( - (Ext_list.map_combine (Array.to_list fields) el Ext_ident.convert))) - (*FIXME: avoid allocaton *) + (List.combine (Array.to_list fields) el ))) + (* name convention of Record is slight different from modules + *) | Caml_block( el, mutable_flag, tag, tag_info) -> (* Note that, if we ignore more than tag [0] we loose some information @@ -100595,7 +100752,7 @@ let primitive ppf = function fprintf ppf "makeblock %i%a" tag block_shape shape | Pmakeblock(tag, _, Mutable, shape) -> fprintf ppf "makemutable %i%a" tag block_shape shape - | Pfield (n, (Fld_module s | Fld_record s)) -> fprintf ppf "field:%s/%i" s n + | Pfield (n, (Fld_module s | Fld_record {name=s})) -> fprintf ppf "field:%s/%i" s n | Pfield (n,_) -> fprintf ppf "field %i" n | Pfield_computed -> fprintf ppf "field_computed" | Psetfield(n, ptr, init, _) -> @@ -103777,11 +103934,11 @@ let make_record_matching loc all_labels def = function let access = match lbl.lbl_repres with | Record_regular -> - Lprim (Pfield (lbl.lbl_pos, Fld_record lbl.lbl_name), [arg], loc) + Lprim (Pfield (lbl.lbl_pos, !Lambda.fld_record lbl), [arg], loc) | Record_inlined _ -> Lprim (Pfield (lbl.lbl_pos, Fld_record_inline lbl.lbl_name), [arg], loc) | Record_unboxed _ -> arg - | Record_float -> Lprim (Pfloatfield (lbl.lbl_pos, Fld_record lbl.lbl_name), [arg], loc) + | Record_float -> Lprim (Pfloatfield (lbl.lbl_pos, !Lambda.fld_record lbl), [arg], loc) | Record_extension -> Lprim (Pfield (lbl.lbl_pos + 1, Fld_record_extension lbl.lbl_name), [arg], loc) in let str = @@ -106731,11 +106888,11 @@ and transl_exp0 e = let targ = transl_exp arg in begin match lbl.lbl_repres with Record_regular -> - Lprim (Pfield (lbl.lbl_pos, Fld_record lbl.lbl_name), [targ], e.exp_loc) + Lprim (Pfield (lbl.lbl_pos, !Lambda.fld_record lbl), [targ], e.exp_loc) | Record_inlined _ -> Lprim (Pfield (lbl.lbl_pos, Fld_record_inline lbl.lbl_name), [targ], e.exp_loc) | Record_unboxed _ -> targ - | Record_float -> Lprim (Pfloatfield (lbl.lbl_pos, Fld_record lbl.lbl_name), [targ], e.exp_loc) + | Record_float -> Lprim (Pfloatfield (lbl.lbl_pos, !Lambda.fld_record lbl), [targ], e.exp_loc) | Record_extension -> Lprim (Pfield (lbl.lbl_pos + 1, Fld_record_extension lbl.lbl_name), [targ], e.exp_loc) end @@ -106743,11 +106900,11 @@ and transl_exp0 e = let access = match lbl.lbl_repres with Record_regular -> - Psetfield(lbl.lbl_pos, maybe_pointer newval, Assignment, Fld_record_set lbl.lbl_name) + Psetfield(lbl.lbl_pos, maybe_pointer newval, Assignment, !Lambda.fld_record_set lbl) | Record_inlined _ -> Psetfield(lbl.lbl_pos, maybe_pointer newval, Assignment, Fld_record_inline_set lbl.lbl_name) | Record_unboxed _ -> assert false - | Record_float -> Psetfloatfield (lbl.lbl_pos, Assignment, Fld_record_set lbl.lbl_name) + | Record_float -> Psetfloatfield (lbl.lbl_pos, Assignment, !Lambda.fld_record_set lbl) | Record_extension -> Psetfield (lbl.lbl_pos + 1, maybe_pointer newval, Assignment, Fld_record_extension_set lbl.lbl_name) in @@ -107137,11 +107294,11 @@ and transl_record loc env fields repres opt_init_expr = let field_kind = value_kind env typ in let access = match repres with - Record_regular -> Pfield (i, Fld_record lbl.lbl_name) + Record_regular -> Pfield (i, !Lambda.fld_record lbl) | Record_inlined _ -> Pfield (i, Fld_record_inline lbl.lbl_name) | Record_unboxed _ -> assert false | Record_extension -> Pfield (i + 1, Fld_record_extension lbl.lbl_name) - | Record_float -> Pfloatfield (i, Fld_record lbl.lbl_name) in + | Record_float -> Pfloatfield (i, !Lambda.fld_record lbl) in Lprim(access, [Lvar init_id], loc), field_kind | Overridden (_lid, expr) -> let field_kind = value_kind expr.exp_env expr.exp_type in @@ -107153,17 +107310,16 @@ and transl_record loc env fields repres opt_init_expr = if Array.exists (fun (lbl, _) -> lbl.lbl_mut = Mutable) fields then Mutable else Immutable in - let all_labels_info = fields |> Array.map (fun (x,_) -> x.Types.lbl_name) in let lam = try if mut = Mutable then raise Not_constant; let cl = List.map extract_constant ll in match repres with - | Record_regular -> Lconst(Const_block(0, Lambda.Blk_record all_labels_info, cl)) - | Record_inlined {tag;name;num_nonconsts} -> Lconst(Const_block(tag, Lambda.Blk_record_inlined (all_labels_info,name,num_nonconsts), cl)) + | Record_regular -> Lconst(Const_block(0, !Lambda.blk_record fields, cl)) + | Record_inlined {tag;name;num_nonconsts} -> Lconst(Const_block(tag, !Lambda.blk_record_inlined fields name num_nonconsts, cl)) | Record_unboxed _ -> Lconst(match cl with [v] -> v | _ -> assert false) | Record_float -> - if !Clflags.bs_only then Lconst(Const_block(0, Lambda.Blk_record all_labels_info, cl)) + if !Clflags.bs_only then Lconst(Const_block(0, !Lambda.blk_record fields, cl)) else Lconst(Const_float_array(List.map extract_float cl)) | Record_extension -> @@ -107171,12 +107327,12 @@ and transl_record loc env fields repres opt_init_expr = with Not_constant -> match repres with Record_regular -> - Lprim(Pmakeblock(0, Lambda.Blk_record all_labels_info, mut, Some shape), ll, loc) + Lprim(Pmakeblock(0, !Lambda.blk_record fields, mut, Some shape), ll, loc) | Record_inlined {tag;name; num_nonconsts} -> - Lprim(Pmakeblock(tag, Lambda.Blk_record_inlined (all_labels_info, name, num_nonconsts), mut, Some shape), ll, loc) + Lprim(Pmakeblock(tag, !Lambda.blk_record_inlined fields name num_nonconsts, mut, Some shape), ll, loc) | Record_unboxed _ -> (match ll with [v] -> v | _ -> assert false) | Record_float -> - if !Clflags.bs_only then Lprim(Pmakeblock(0, Lambda.Blk_record all_labels_info, mut, Some shape), ll, loc) + if !Clflags.bs_only then Lprim(Pmakeblock(0, !Lambda.blk_record fields, mut, Some shape), ll, loc) else Lprim(Pmakearray (Pfloatarray, mut), ll, loc) | Record_extension -> @@ -107187,7 +107343,7 @@ and transl_record loc env fields repres opt_init_expr = | _ -> assert false in let slot = transl_extension_path env path in - Lprim(Pmakeblock(0, Lambda.Blk_record_ext all_labels_info, mut, Some (Pgenval :: shape)), slot :: ll, loc) + Lprim(Pmakeblock(0, !Lambda.blk_record_ext fields, mut, Some (Pgenval :: shape)), slot :: ll, loc) in begin match opt_init_expr with None -> lam @@ -107205,11 +107361,11 @@ and transl_record loc env fields repres opt_init_expr = let upd = match repres with Record_regular -> - Psetfield(lbl.lbl_pos, maybe_pointer expr, Assignment, Fld_record_set lbl.lbl_name) + Psetfield(lbl.lbl_pos, maybe_pointer expr, Assignment, !Lambda.fld_record_set lbl) | Record_inlined _ -> Psetfield(lbl.lbl_pos, maybe_pointer expr, Assignment, Fld_record_inline_set lbl.lbl_name) | Record_unboxed _ -> assert false - | Record_float -> Psetfloatfield (lbl.lbl_pos, Assignment, Fld_record_set lbl.lbl_name) + | Record_float -> Psetfloatfield (lbl.lbl_pos, Assignment, !Lambda.fld_record_set lbl) | Record_extension -> Psetfield(lbl.lbl_pos + 1, maybe_pointer expr, Assignment, Fld_record_extension_set lbl.lbl_name) in @@ -116280,7 +116436,7 @@ let field (field_info : Lam_compat.field_dbg_info) e i = -> E.array_index_by_int ~comment e i - | Fld_record name + | Fld_record {name} -> E.record_access e name i | Fld_module name -> E.module_access e name i diff --git a/lib/4.06.1/unstable/js_compiler.ml.d b/lib/4.06.1/unstable/js_compiler.ml.d index d45e7d78f0..3c264201b2 100644 --- a/lib/4.06.1/unstable/js_compiler.ml.d +++ b/lib/4.06.1/unstable/js_compiler.ml.d @@ -1 +1 @@ -../lib/4.06.1/unstable/js_compiler.ml: ../ocaml/bytecomp/lambda.ml ../ocaml/bytecomp/lambda.mli ../ocaml/bytecomp/matching.ml ../ocaml/bytecomp/matching.mli ../ocaml/bytecomp/printlambda.ml ../ocaml/bytecomp/printlambda.mli ../ocaml/bytecomp/switch.ml ../ocaml/bytecomp/switch.mli ../ocaml/bytecomp/translattribute.ml ../ocaml/bytecomp/translattribute.mli ../ocaml/bytecomp/translclass.ml ../ocaml/bytecomp/translclass.mli ../ocaml/bytecomp/translcore.ml ../ocaml/bytecomp/translcore.mli ../ocaml/bytecomp/translmod.ml ../ocaml/bytecomp/translmod.mli ../ocaml/bytecomp/translobj.ml ../ocaml/bytecomp/translobj.mli ../ocaml/driver/compenv.ml ../ocaml/driver/compenv.mli ../ocaml/driver/compmisc.ml ../ocaml/driver/compmisc.mli ../ocaml/parsing/ast_helper.ml ../ocaml/parsing/ast_helper.mli ../ocaml/parsing/ast_iterator.ml ../ocaml/parsing/ast_iterator.mli ../ocaml/parsing/ast_mapper.ml ../ocaml/parsing/ast_mapper.mli ../ocaml/parsing/asttypes.mli ../ocaml/parsing/attr_helper.ml ../ocaml/parsing/attr_helper.mli ../ocaml/parsing/builtin_attributes.ml ../ocaml/parsing/builtin_attributes.mli ../ocaml/parsing/docstrings.ml ../ocaml/parsing/docstrings.mli ../ocaml/parsing/lexer.ml ../ocaml/parsing/lexer.mli ../ocaml/parsing/location.ml ../ocaml/parsing/location.mli ../ocaml/parsing/longident.ml ../ocaml/parsing/longident.mli ../ocaml/parsing/parse.ml ../ocaml/parsing/parse.mli ../ocaml/parsing/parser.ml ../ocaml/parsing/parser.mli ../ocaml/parsing/parsetree.mli ../ocaml/parsing/syntaxerr.ml ../ocaml/parsing/syntaxerr.mli ../ocaml/typing/annot.mli ../ocaml/typing/btype.ml ../ocaml/typing/btype.mli ../ocaml/typing/cmi_format.ml ../ocaml/typing/cmi_format.mli ../ocaml/typing/cmt_format.ml ../ocaml/typing/cmt_format.mli ../ocaml/typing/ctype.ml ../ocaml/typing/ctype.mli ../ocaml/typing/datarepr.ml ../ocaml/typing/datarepr.mli ../ocaml/typing/env.ml ../ocaml/typing/env.mli ../ocaml/typing/ident.ml ../ocaml/typing/ident.mli ../ocaml/typing/includeclass.ml ../ocaml/typing/includeclass.mli ../ocaml/typing/includecore.ml ../ocaml/typing/includecore.mli ../ocaml/typing/includemod.ml ../ocaml/typing/includemod.mli ../ocaml/typing/mtype.ml ../ocaml/typing/mtype.mli ../ocaml/typing/oprint.ml ../ocaml/typing/oprint.mli ../ocaml/typing/outcometree.mli ../ocaml/typing/parmatch.ml ../ocaml/typing/parmatch.mli ../ocaml/typing/path.ml ../ocaml/typing/path.mli ../ocaml/typing/predef.ml ../ocaml/typing/predef.mli ../ocaml/typing/primitive.ml ../ocaml/typing/primitive.mli ../ocaml/typing/printtyp.ml ../ocaml/typing/printtyp.mli ../ocaml/typing/stypes.ml ../ocaml/typing/stypes.mli ../ocaml/typing/subst.ml ../ocaml/typing/subst.mli ../ocaml/typing/tast_mapper.ml ../ocaml/typing/tast_mapper.mli ../ocaml/typing/typeclass.ml ../ocaml/typing/typeclass.mli ../ocaml/typing/typecore.ml ../ocaml/typing/typecore.mli ../ocaml/typing/typedecl.ml ../ocaml/typing/typedecl.mli ../ocaml/typing/typedtree.ml ../ocaml/typing/typedtree.mli ../ocaml/typing/typedtreeIter.ml ../ocaml/typing/typedtreeIter.mli ../ocaml/typing/typemod.ml ../ocaml/typing/typemod.mli ../ocaml/typing/typeopt.ml ../ocaml/typing/typeopt.mli ../ocaml/typing/types.ml ../ocaml/typing/types.mli ../ocaml/typing/typetexp.ml ../ocaml/typing/typetexp.mli ../ocaml/typing/untypeast.ml ../ocaml/typing/untypeast.mli ../ocaml/utils/arg_helper.ml ../ocaml/utils/arg_helper.mli ../ocaml/utils/ccomp.ml ../ocaml/utils/ccomp.mli ../ocaml/utils/clflags.ml ../ocaml/utils/clflags.mli ../ocaml/utils/consistbl.ml ../ocaml/utils/consistbl.mli ../ocaml/utils/identifiable.ml ../ocaml/utils/identifiable.mli ../ocaml/utils/misc.ml ../ocaml/utils/misc.mli ../ocaml/utils/numbers.ml ../ocaml/utils/numbers.mli ../ocaml/utils/profile.ml ../ocaml/utils/profile.mli ../ocaml/utils/tbl.ml ../ocaml/utils/tbl.mli ../ocaml/utils/terminfo.ml ../ocaml/utils/terminfo.mli ../ocaml/utils/warnings.ml ../ocaml/utils/warnings.mli ./bsb/bsb_build_schemas.ml ./bsb/bsb_exception.ml ./bsb/bsb_exception.mli ./bsb/bsb_pkg_types.ml ./bsb/bsb_pkg_types.mli ./bsb/bsb_warning.ml ./bsb/bsb_warning.mli ./common/bs_loc.ml ./common/bs_loc.mli ./common/bs_version.ml ./common/bs_version.mli ./common/bs_warnings.ml ./common/bs_warnings.mli ./common/ext_log.ml ./common/ext_log.mli ./common/js_config.ml ./common/js_config.mli ./common/lam_methname.ml ./common/lam_methname.mli ./core/bs_conditional_initial.ml ./core/bs_conditional_initial.mli ./core/config_util.ml ./core/config_util.mli ./core/config_whole_compiler.ml ./core/config_whole_compiler.mli ./core/j.ml ./core/js_analyzer.ml ./core/js_analyzer.mli ./core/js_arr.ml ./core/js_arr.mli ./core/js_ast_util.ml ./core/js_ast_util.mli ./core/js_block_runtime.ml ./core/js_block_runtime.mli ./core/js_call_info.ml ./core/js_call_info.mli ./core/js_closure.ml ./core/js_closure.mli ./core/js_cmj_datasets.ml ./core/js_cmj_datasets.mli ./core/js_cmj_format.ml ./core/js_cmj_format.mli ./core/js_cmj_load.ml ./core/js_cmj_load.mli ./core/js_dump.ml ./core/js_dump.mli ./core/js_dump_import_export.ml ./core/js_dump_import_export.mli ./core/js_dump_lit.ml ./core/js_dump_program.ml ./core/js_dump_program.mli ./core/js_dump_property.ml ./core/js_dump_property.mli ./core/js_dump_string.ml ./core/js_dump_string.mli ./core/js_exp_make.ml ./core/js_exp_make.mli ./core/js_fold.ml ./core/js_fold_basic.ml ./core/js_fold_basic.mli ./core/js_fun_env.ml ./core/js_fun_env.mli ./core/js_long.ml ./core/js_long.mli ./core/js_map.ml ./core/js_name_of_module_id.ml ./core/js_name_of_module_id.mli ./core/js_number.ml ./core/js_number.mli ./core/js_of_lam_array.ml ./core/js_of_lam_array.mli ./core/js_of_lam_block.ml ./core/js_of_lam_block.mli ./core/js_of_lam_exception.ml ./core/js_of_lam_exception.mli ./core/js_of_lam_option.ml ./core/js_of_lam_option.mli ./core/js_of_lam_polyvar.ml ./core/js_of_lam_polyvar.mli ./core/js_of_lam_string.ml ./core/js_of_lam_string.mli ./core/js_of_lam_tuple.ml ./core/js_of_lam_tuple.mli ./core/js_of_lam_variant.ml ./core/js_of_lam_variant.mli ./core/js_op.ml ./core/js_op_util.ml ./core/js_op_util.mli ./core/js_output.ml ./core/js_output.mli ./core/js_packages_info.ml ./core/js_packages_info.mli ./core/js_packages_state.ml ./core/js_packages_state.mli ./core/js_pass_debug.ml ./core/js_pass_debug.mli ./core/js_pass_flatten.ml ./core/js_pass_flatten.mli ./core/js_pass_flatten_and_mark_dead.ml ./core/js_pass_flatten_and_mark_dead.mli ./core/js_pass_scope.ml ./core/js_pass_scope.mli ./core/js_pass_tailcall_inline.ml ./core/js_pass_tailcall_inline.mli ./core/js_shake.ml ./core/js_shake.mli ./core/js_stmt_make.ml ./core/js_stmt_make.mli ./core/lam.ml ./core/lam.mli ./core/lam_analysis.ml ./core/lam_analysis.mli ./core/lam_arity.ml ./core/lam_arity.mli ./core/lam_arity_analysis.ml ./core/lam_arity_analysis.mli ./core/lam_beta_reduce.ml ./core/lam_beta_reduce.mli ./core/lam_beta_reduce_util.ml ./core/lam_beta_reduce_util.mli ./core/lam_bounded_vars.ml ./core/lam_bounded_vars.mli ./core/lam_closure.ml ./core/lam_closure.mli ./core/lam_coercion.ml ./core/lam_coercion.mli ./core/lam_compat.ml ./core/lam_compat.mli ./core/lam_compile.ml ./core/lam_compile.mli ./core/lam_compile_const.ml ./core/lam_compile_const.mli ./core/lam_compile_context.ml ./core/lam_compile_context.mli ./core/lam_compile_env.ml ./core/lam_compile_env.mli ./core/lam_compile_external_call.ml ./core/lam_compile_external_call.mli ./core/lam_compile_external_obj.ml ./core/lam_compile_external_obj.mli ./core/lam_compile_main.ml ./core/lam_compile_main.mli ./core/lam_compile_primitive.ml ./core/lam_compile_primitive.mli ./core/lam_compile_util.ml ./core/lam_compile_util.mli ./core/lam_constant.ml ./core/lam_constant.mli ./core/lam_constant_convert.ml ./core/lam_constant_convert.mli ./core/lam_convert.ml ./core/lam_convert.mli ./core/lam_dce.ml ./core/lam_dce.mli ./core/lam_dispatch_primitive.ml ./core/lam_dispatch_primitive.mli ./core/lam_eta_conversion.ml ./core/lam_eta_conversion.mli ./core/lam_exit_code.ml ./core/lam_exit_code.mli ./core/lam_exit_count.ml ./core/lam_exit_count.mli ./core/lam_free_variables.ml ./core/lam_free_variables.mli ./core/lam_group.ml ./core/lam_group.mli ./core/lam_hit.ml ./core/lam_hit.mli ./core/lam_id_kind.ml ./core/lam_id_kind.mli ./core/lam_inline_util.ml ./core/lam_inline_util.mli ./core/lam_iter.ml ./core/lam_iter.mli ./core/lam_module_ident.ml ./core/lam_module_ident.mli ./core/lam_pass_alpha_conversion.ml ./core/lam_pass_alpha_conversion.mli ./core/lam_pass_collect.ml ./core/lam_pass_collect.mli ./core/lam_pass_count.ml ./core/lam_pass_count.mli ./core/lam_pass_deep_flatten.ml ./core/lam_pass_deep_flatten.mli ./core/lam_pass_eliminate_ref.ml ./core/lam_pass_eliminate_ref.mli ./core/lam_pass_exits.ml ./core/lam_pass_exits.mli ./core/lam_pass_lets_dce.ml ./core/lam_pass_lets_dce.mli ./core/lam_pass_remove_alias.ml ./core/lam_pass_remove_alias.mli ./core/lam_pointer_info.ml ./core/lam_pointer_info.mli ./core/lam_primitive.ml ./core/lam_primitive.mli ./core/lam_print.ml ./core/lam_print.mli ./core/lam_scc.ml ./core/lam_scc.mli ./core/lam_stats.ml ./core/lam_stats.mli ./core/lam_stats_export.ml ./core/lam_stats_export.mli ./core/lam_subst.ml ./core/lam_subst.mli ./core/lam_tag_info.ml ./core/lam_util.ml ./core/lam_util.mli ./core/lam_var_stats.ml ./core/lam_var_stats.mli ./core/primitive_compat.ml ./core/primitive_compat.mli ./depends/bs_exception.ml ./depends/bs_exception.mli ./ext/ext_arg.ml ./ext/ext_arg.mli ./ext/ext_array.ml ./ext/ext_array.mli ./ext/ext_buffer.ml ./ext/ext_buffer.mli ./ext/ext_bytes.ml ./ext/ext_bytes.mli ./ext/ext_char.ml ./ext/ext_char.mli ./ext/ext_filename.ml ./ext/ext_filename.mli ./ext/ext_fmt.ml ./ext/ext_ident.ml ./ext/ext_ident.mli ./ext/ext_int.ml ./ext/ext_int.mli ./ext/ext_js_regex.ml ./ext/ext_js_regex.mli ./ext/ext_json.ml ./ext/ext_json.mli ./ext/ext_json_parse.ml ./ext/ext_json_parse.mli ./ext/ext_json_types.ml ./ext/ext_list.ml ./ext/ext_list.mli ./ext/ext_modulename.ml ./ext/ext_modulename.mli ./ext/ext_namespace.ml ./ext/ext_namespace.mli ./ext/ext_option.ml ./ext/ext_option.mli ./ext/ext_path.ml ./ext/ext_path.mli ./ext/ext_pervasives.ml ./ext/ext_pervasives.mli ./ext/ext_position.ml ./ext/ext_position.mli ./ext/ext_pp.ml ./ext/ext_pp.mli ./ext/ext_pp_scope.ml ./ext/ext_pp_scope.mli ./ext/ext_ref.ml ./ext/ext_ref.mli ./ext/ext_scc.ml ./ext/ext_scc.mli ./ext/ext_string.ml ./ext/ext_string.mli ./ext/ext_sys.ml ./ext/ext_sys.mli ./ext/ext_utf8.ml ./ext/ext_utf8.mli ./ext/ext_util.ml ./ext/ext_util.mli ./ext/hash_set.ml ./ext/hash_set.mli ./ext/hash_set_gen.ml ./ext/hash_set_ident_mask.ml ./ext/hash_set_ident_mask.mli ./ext/hash_set_poly.ml ./ext/hash_set_poly.mli ./ext/hashtbl_gen.ml ./ext/hashtbl_make.ml ./ext/hashtbl_make.mli ./ext/ident_hash_set.ml ./ext/ident_hash_set.mli ./ext/ident_hashtbl.ml ./ext/ident_hashtbl.mli ./ext/ident_map.ml ./ext/ident_map.mli ./ext/ident_set.ml ./ext/ident_set.mli ./ext/int_hashtbl.ml ./ext/int_hashtbl.mli ./ext/int_map.ml ./ext/int_map.mli ./ext/int_vec.ml ./ext/int_vec.mli ./ext/int_vec_util.ml ./ext/int_vec_util.mli ./ext/int_vec_vec.ml ./ext/int_vec_vec.mli ./ext/js_reserved_map.ml ./ext/js_reserved_map.mli ./ext/js_runtime_modules.ml ./ext/literals.ml ./ext/literals.mli ./ext/map_gen.ml ./ext/ordered_hash_map_gen.ml ./ext/ordered_hash_map_local_ident.ml ./ext/ordered_hash_map_local_ident.mli ./ext/resize_array.ml ./ext/resize_array.mli ./ext/set_gen.ml ./ext/string_hash_set.ml ./ext/string_hash_set.mli ./ext/string_hashtbl.ml ./ext/string_hashtbl.mli ./ext/string_map.ml ./ext/string_map.mli ./ext/vec_gen.ml ./main/jsoo_main.ml ./main/jsoo_main.mli ./outcome_printer/outcome_printer_ns.ml ./outcome_printer/outcome_printer_ns.mli ./stubs/bs_hash_stubs.ml ./super_errors/super_env.ml ./super_errors/super_location.ml ./super_errors/super_main.ml ./super_errors/super_misc.ml ./super_errors/super_misc.mli ./super_errors/super_pparse.ml ./super_errors/super_reason_react.ml ./super_errors/super_reason_react.mli ./super_errors/super_typecore.ml ./super_errors/super_typemod.ml ./super_errors/super_typetexp.ml ./super_errors/super_warnings.ml ./syntax/ast_attributes.ml ./syntax/ast_attributes.mli ./syntax/ast_bs_open.ml ./syntax/ast_bs_open.mli ./syntax/ast_comb.ml ./syntax/ast_comb.mli ./syntax/ast_compatible.ml ./syntax/ast_compatible.mli ./syntax/ast_core_type.ml ./syntax/ast_core_type.mli ./syntax/ast_core_type_class_type.ml ./syntax/ast_core_type_class_type.mli ./syntax/ast_derive.ml ./syntax/ast_derive.mli ./syntax/ast_derive_abstract.ml ./syntax/ast_derive_abstract.mli ./syntax/ast_derive_js_mapper.ml ./syntax/ast_derive_js_mapper.mli ./syntax/ast_derive_projector.ml ./syntax/ast_derive_projector.mli ./syntax/ast_derive_util.ml ./syntax/ast_derive_util.mli ./syntax/ast_exp.ml ./syntax/ast_exp.mli ./syntax/ast_exp_apply.ml ./syntax/ast_exp_apply.mli ./syntax/ast_exp_extension.ml ./syntax/ast_exp_extension.mli ./syntax/ast_external.ml ./syntax/ast_external.mli ./syntax/ast_external_mk.ml ./syntax/ast_external_mk.mli ./syntax/ast_external_process.ml ./syntax/ast_external_process.mli ./syntax/ast_literal.ml ./syntax/ast_literal.mli ./syntax/ast_open_cxt.ml ./syntax/ast_open_cxt.mli ./syntax/ast_pat.ml ./syntax/ast_pat.mli ./syntax/ast_payload.ml ./syntax/ast_payload.mli ./syntax/ast_polyvar.ml ./syntax/ast_polyvar.mli ./syntax/ast_reason_pp.ml ./syntax/ast_reason_pp.mli ./syntax/ast_signature.ml ./syntax/ast_signature.mli ./syntax/ast_structure.ml ./syntax/ast_structure.mli ./syntax/ast_tdcls.ml ./syntax/ast_tdcls.mli ./syntax/ast_tuple_pattern_flatten.ml ./syntax/ast_tuple_pattern_flatten.mli ./syntax/ast_utf8_string.ml ./syntax/ast_utf8_string.mli ./syntax/ast_utf8_string_interp.ml ./syntax/ast_utf8_string_interp.mli ./syntax/ast_util.ml ./syntax/ast_util.mli ./syntax/bs_ast_invariant.ml ./syntax/bs_ast_invariant.mli ./syntax/bs_ast_mapper.ml ./syntax/bs_ast_mapper.mli ./syntax/bs_builtin_ppx.ml ./syntax/bs_builtin_ppx.mli ./syntax/bs_syntaxerr.ml ./syntax/bs_syntaxerr.mli ./syntax/external_arg_spec.ml ./syntax/external_arg_spec.mli ./syntax/external_ffi_types.ml ./syntax/external_ffi_types.mli ./syntax/reactjs_jsx_ppx_v2.ml ./syntax/reactjs_jsx_ppx_v3.ml \ No newline at end of file +../lib/4.06.1/unstable/js_compiler.ml: ../ocaml/bytecomp/lambda.ml ../ocaml/bytecomp/lambda.mli ../ocaml/bytecomp/matching.ml ../ocaml/bytecomp/matching.mli ../ocaml/bytecomp/printlambda.ml ../ocaml/bytecomp/printlambda.mli ../ocaml/bytecomp/switch.ml ../ocaml/bytecomp/switch.mli ../ocaml/bytecomp/translattribute.ml ../ocaml/bytecomp/translattribute.mli ../ocaml/bytecomp/translclass.ml ../ocaml/bytecomp/translclass.mli ../ocaml/bytecomp/translcore.ml ../ocaml/bytecomp/translcore.mli ../ocaml/bytecomp/translmod.ml ../ocaml/bytecomp/translmod.mli ../ocaml/bytecomp/translobj.ml ../ocaml/bytecomp/translobj.mli ../ocaml/driver/compenv.ml ../ocaml/driver/compenv.mli ../ocaml/driver/compmisc.ml ../ocaml/driver/compmisc.mli ../ocaml/parsing/ast_helper.ml ../ocaml/parsing/ast_helper.mli ../ocaml/parsing/ast_iterator.ml ../ocaml/parsing/ast_iterator.mli ../ocaml/parsing/ast_mapper.ml ../ocaml/parsing/ast_mapper.mli ../ocaml/parsing/asttypes.mli ../ocaml/parsing/attr_helper.ml ../ocaml/parsing/attr_helper.mli ../ocaml/parsing/builtin_attributes.ml ../ocaml/parsing/builtin_attributes.mli ../ocaml/parsing/docstrings.ml ../ocaml/parsing/docstrings.mli ../ocaml/parsing/lexer.ml ../ocaml/parsing/lexer.mli ../ocaml/parsing/location.ml ../ocaml/parsing/location.mli ../ocaml/parsing/longident.ml ../ocaml/parsing/longident.mli ../ocaml/parsing/parse.ml ../ocaml/parsing/parse.mli ../ocaml/parsing/parser.ml ../ocaml/parsing/parser.mli ../ocaml/parsing/parsetree.mli ../ocaml/parsing/syntaxerr.ml ../ocaml/parsing/syntaxerr.mli ../ocaml/typing/annot.mli ../ocaml/typing/btype.ml ../ocaml/typing/btype.mli ../ocaml/typing/cmi_format.ml ../ocaml/typing/cmi_format.mli ../ocaml/typing/cmt_format.ml ../ocaml/typing/cmt_format.mli ../ocaml/typing/ctype.ml ../ocaml/typing/ctype.mli ../ocaml/typing/datarepr.ml ../ocaml/typing/datarepr.mli ../ocaml/typing/env.ml ../ocaml/typing/env.mli ../ocaml/typing/ident.ml ../ocaml/typing/ident.mli ../ocaml/typing/includeclass.ml ../ocaml/typing/includeclass.mli ../ocaml/typing/includecore.ml ../ocaml/typing/includecore.mli ../ocaml/typing/includemod.ml ../ocaml/typing/includemod.mli ../ocaml/typing/mtype.ml ../ocaml/typing/mtype.mli ../ocaml/typing/oprint.ml ../ocaml/typing/oprint.mli ../ocaml/typing/outcometree.mli ../ocaml/typing/parmatch.ml ../ocaml/typing/parmatch.mli ../ocaml/typing/path.ml ../ocaml/typing/path.mli ../ocaml/typing/predef.ml ../ocaml/typing/predef.mli ../ocaml/typing/primitive.ml ../ocaml/typing/primitive.mli ../ocaml/typing/printtyp.ml ../ocaml/typing/printtyp.mli ../ocaml/typing/stypes.ml ../ocaml/typing/stypes.mli ../ocaml/typing/subst.ml ../ocaml/typing/subst.mli ../ocaml/typing/tast_mapper.ml ../ocaml/typing/tast_mapper.mli ../ocaml/typing/typeclass.ml ../ocaml/typing/typeclass.mli ../ocaml/typing/typecore.ml ../ocaml/typing/typecore.mli ../ocaml/typing/typedecl.ml ../ocaml/typing/typedecl.mli ../ocaml/typing/typedtree.ml ../ocaml/typing/typedtree.mli ../ocaml/typing/typedtreeIter.ml ../ocaml/typing/typedtreeIter.mli ../ocaml/typing/typemod.ml ../ocaml/typing/typemod.mli ../ocaml/typing/typeopt.ml ../ocaml/typing/typeopt.mli ../ocaml/typing/types.ml ../ocaml/typing/types.mli ../ocaml/typing/typetexp.ml ../ocaml/typing/typetexp.mli ../ocaml/typing/untypeast.ml ../ocaml/typing/untypeast.mli ../ocaml/utils/arg_helper.ml ../ocaml/utils/arg_helper.mli ../ocaml/utils/ccomp.ml ../ocaml/utils/ccomp.mli ../ocaml/utils/clflags.ml ../ocaml/utils/clflags.mli ../ocaml/utils/consistbl.ml ../ocaml/utils/consistbl.mli ../ocaml/utils/identifiable.ml ../ocaml/utils/identifiable.mli ../ocaml/utils/misc.ml ../ocaml/utils/misc.mli ../ocaml/utils/numbers.ml ../ocaml/utils/numbers.mli ../ocaml/utils/profile.ml ../ocaml/utils/profile.mli ../ocaml/utils/tbl.ml ../ocaml/utils/tbl.mli ../ocaml/utils/terminfo.ml ../ocaml/utils/terminfo.mli ../ocaml/utils/warnings.ml ../ocaml/utils/warnings.mli ./bsb/bsb_build_schemas.ml ./bsb/bsb_exception.ml ./bsb/bsb_exception.mli ./bsb/bsb_pkg_types.ml ./bsb/bsb_pkg_types.mli ./bsb/bsb_warning.ml ./bsb/bsb_warning.mli ./common/bs_loc.ml ./common/bs_loc.mli ./common/bs_version.ml ./common/bs_version.mli ./common/bs_warnings.ml ./common/bs_warnings.mli ./common/ext_log.ml ./common/ext_log.mli ./common/js_config.ml ./common/js_config.mli ./common/lam_methname.ml ./common/lam_methname.mli ./core/bs_conditional_initial.ml ./core/bs_conditional_initial.mli ./core/config_util.ml ./core/config_util.mli ./core/config_whole_compiler.ml ./core/config_whole_compiler.mli ./core/j.ml ./core/js_analyzer.ml ./core/js_analyzer.mli ./core/js_arr.ml ./core/js_arr.mli ./core/js_ast_util.ml ./core/js_ast_util.mli ./core/js_block_runtime.ml ./core/js_block_runtime.mli ./core/js_call_info.ml ./core/js_call_info.mli ./core/js_closure.ml ./core/js_closure.mli ./core/js_cmj_datasets.ml ./core/js_cmj_datasets.mli ./core/js_cmj_format.ml ./core/js_cmj_format.mli ./core/js_cmj_load.ml ./core/js_cmj_load.mli ./core/js_dump.ml ./core/js_dump.mli ./core/js_dump_import_export.ml ./core/js_dump_import_export.mli ./core/js_dump_lit.ml ./core/js_dump_program.ml ./core/js_dump_program.mli ./core/js_dump_property.ml ./core/js_dump_property.mli ./core/js_dump_string.ml ./core/js_dump_string.mli ./core/js_exp_make.ml ./core/js_exp_make.mli ./core/js_fold.ml ./core/js_fold_basic.ml ./core/js_fold_basic.mli ./core/js_fun_env.ml ./core/js_fun_env.mli ./core/js_long.ml ./core/js_long.mli ./core/js_map.ml ./core/js_name_of_module_id.ml ./core/js_name_of_module_id.mli ./core/js_number.ml ./core/js_number.mli ./core/js_of_lam_array.ml ./core/js_of_lam_array.mli ./core/js_of_lam_block.ml ./core/js_of_lam_block.mli ./core/js_of_lam_exception.ml ./core/js_of_lam_exception.mli ./core/js_of_lam_option.ml ./core/js_of_lam_option.mli ./core/js_of_lam_polyvar.ml ./core/js_of_lam_polyvar.mli ./core/js_of_lam_string.ml ./core/js_of_lam_string.mli ./core/js_of_lam_tuple.ml ./core/js_of_lam_tuple.mli ./core/js_of_lam_variant.ml ./core/js_of_lam_variant.mli ./core/js_op.ml ./core/js_op_util.ml ./core/js_op_util.mli ./core/js_output.ml ./core/js_output.mli ./core/js_packages_info.ml ./core/js_packages_info.mli ./core/js_packages_state.ml ./core/js_packages_state.mli ./core/js_pass_debug.ml ./core/js_pass_debug.mli ./core/js_pass_flatten.ml ./core/js_pass_flatten.mli ./core/js_pass_flatten_and_mark_dead.ml ./core/js_pass_flatten_and_mark_dead.mli ./core/js_pass_scope.ml ./core/js_pass_scope.mli ./core/js_pass_tailcall_inline.ml ./core/js_pass_tailcall_inline.mli ./core/js_shake.ml ./core/js_shake.mli ./core/js_stmt_make.ml ./core/js_stmt_make.mli ./core/lam.ml ./core/lam.mli ./core/lam_analysis.ml ./core/lam_analysis.mli ./core/lam_arity.ml ./core/lam_arity.mli ./core/lam_arity_analysis.ml ./core/lam_arity_analysis.mli ./core/lam_beta_reduce.ml ./core/lam_beta_reduce.mli ./core/lam_beta_reduce_util.ml ./core/lam_beta_reduce_util.mli ./core/lam_bounded_vars.ml ./core/lam_bounded_vars.mli ./core/lam_closure.ml ./core/lam_closure.mli ./core/lam_coercion.ml ./core/lam_coercion.mli ./core/lam_compat.ml ./core/lam_compat.mli ./core/lam_compile.ml ./core/lam_compile.mli ./core/lam_compile_const.ml ./core/lam_compile_const.mli ./core/lam_compile_context.ml ./core/lam_compile_context.mli ./core/lam_compile_env.ml ./core/lam_compile_env.mli ./core/lam_compile_external_call.ml ./core/lam_compile_external_call.mli ./core/lam_compile_external_obj.ml ./core/lam_compile_external_obj.mli ./core/lam_compile_main.ml ./core/lam_compile_main.mli ./core/lam_compile_primitive.ml ./core/lam_compile_primitive.mli ./core/lam_compile_util.ml ./core/lam_compile_util.mli ./core/lam_constant.ml ./core/lam_constant.mli ./core/lam_constant_convert.ml ./core/lam_constant_convert.mli ./core/lam_convert.ml ./core/lam_convert.mli ./core/lam_dce.ml ./core/lam_dce.mli ./core/lam_dispatch_primitive.ml ./core/lam_dispatch_primitive.mli ./core/lam_eta_conversion.ml ./core/lam_eta_conversion.mli ./core/lam_exit_code.ml ./core/lam_exit_code.mli ./core/lam_exit_count.ml ./core/lam_exit_count.mli ./core/lam_free_variables.ml ./core/lam_free_variables.mli ./core/lam_group.ml ./core/lam_group.mli ./core/lam_hit.ml ./core/lam_hit.mli ./core/lam_id_kind.ml ./core/lam_id_kind.mli ./core/lam_inline_util.ml ./core/lam_inline_util.mli ./core/lam_iter.ml ./core/lam_iter.mli ./core/lam_module_ident.ml ./core/lam_module_ident.mli ./core/lam_pass_alpha_conversion.ml ./core/lam_pass_alpha_conversion.mli ./core/lam_pass_collect.ml ./core/lam_pass_collect.mli ./core/lam_pass_count.ml ./core/lam_pass_count.mli ./core/lam_pass_deep_flatten.ml ./core/lam_pass_deep_flatten.mli ./core/lam_pass_eliminate_ref.ml ./core/lam_pass_eliminate_ref.mli ./core/lam_pass_exits.ml ./core/lam_pass_exits.mli ./core/lam_pass_lets_dce.ml ./core/lam_pass_lets_dce.mli ./core/lam_pass_remove_alias.ml ./core/lam_pass_remove_alias.mli ./core/lam_pointer_info.ml ./core/lam_pointer_info.mli ./core/lam_primitive.ml ./core/lam_primitive.mli ./core/lam_print.ml ./core/lam_print.mli ./core/lam_scc.ml ./core/lam_scc.mli ./core/lam_stats.ml ./core/lam_stats.mli ./core/lam_stats_export.ml ./core/lam_stats_export.mli ./core/lam_subst.ml ./core/lam_subst.mli ./core/lam_tag_info.ml ./core/lam_util.ml ./core/lam_util.mli ./core/lam_var_stats.ml ./core/lam_var_stats.mli ./core/primitive_compat.ml ./core/primitive_compat.mli ./core/record_attributes_check.ml ./depends/bs_exception.ml ./depends/bs_exception.mli ./ext/ext_arg.ml ./ext/ext_arg.mli ./ext/ext_array.ml ./ext/ext_array.mli ./ext/ext_buffer.ml ./ext/ext_buffer.mli ./ext/ext_bytes.ml ./ext/ext_bytes.mli ./ext/ext_char.ml ./ext/ext_char.mli ./ext/ext_filename.ml ./ext/ext_filename.mli ./ext/ext_fmt.ml ./ext/ext_ident.ml ./ext/ext_ident.mli ./ext/ext_int.ml ./ext/ext_int.mli ./ext/ext_js_regex.ml ./ext/ext_js_regex.mli ./ext/ext_json.ml ./ext/ext_json.mli ./ext/ext_json_parse.ml ./ext/ext_json_parse.mli ./ext/ext_json_types.ml ./ext/ext_list.ml ./ext/ext_list.mli ./ext/ext_modulename.ml ./ext/ext_modulename.mli ./ext/ext_namespace.ml ./ext/ext_namespace.mli ./ext/ext_option.ml ./ext/ext_option.mli ./ext/ext_path.ml ./ext/ext_path.mli ./ext/ext_pervasives.ml ./ext/ext_pervasives.mli ./ext/ext_position.ml ./ext/ext_position.mli ./ext/ext_pp.ml ./ext/ext_pp.mli ./ext/ext_pp_scope.ml ./ext/ext_pp_scope.mli ./ext/ext_ref.ml ./ext/ext_ref.mli ./ext/ext_scc.ml ./ext/ext_scc.mli ./ext/ext_string.ml ./ext/ext_string.mli ./ext/ext_sys.ml ./ext/ext_sys.mli ./ext/ext_utf8.ml ./ext/ext_utf8.mli ./ext/ext_util.ml ./ext/ext_util.mli ./ext/hash_set.ml ./ext/hash_set.mli ./ext/hash_set_gen.ml ./ext/hash_set_ident_mask.ml ./ext/hash_set_ident_mask.mli ./ext/hash_set_poly.ml ./ext/hash_set_poly.mli ./ext/hashtbl_gen.ml ./ext/hashtbl_make.ml ./ext/hashtbl_make.mli ./ext/ident_hash_set.ml ./ext/ident_hash_set.mli ./ext/ident_hashtbl.ml ./ext/ident_hashtbl.mli ./ext/ident_map.ml ./ext/ident_map.mli ./ext/ident_set.ml ./ext/ident_set.mli ./ext/int_hashtbl.ml ./ext/int_hashtbl.mli ./ext/int_map.ml ./ext/int_map.mli ./ext/int_vec.ml ./ext/int_vec.mli ./ext/int_vec_util.ml ./ext/int_vec_util.mli ./ext/int_vec_vec.ml ./ext/int_vec_vec.mli ./ext/js_reserved_map.ml ./ext/js_reserved_map.mli ./ext/js_runtime_modules.ml ./ext/literals.ml ./ext/literals.mli ./ext/map_gen.ml ./ext/ordered_hash_map_gen.ml ./ext/ordered_hash_map_local_ident.ml ./ext/ordered_hash_map_local_ident.mli ./ext/resize_array.ml ./ext/resize_array.mli ./ext/set_gen.ml ./ext/string_hash_set.ml ./ext/string_hash_set.mli ./ext/string_hashtbl.ml ./ext/string_hashtbl.mli ./ext/string_map.ml ./ext/string_map.mli ./ext/vec_gen.ml ./main/jsoo_main.ml ./main/jsoo_main.mli ./outcome_printer/outcome_printer_ns.ml ./outcome_printer/outcome_printer_ns.mli ./stubs/bs_hash_stubs.ml ./super_errors/super_env.ml ./super_errors/super_location.ml ./super_errors/super_main.ml ./super_errors/super_misc.ml ./super_errors/super_misc.mli ./super_errors/super_pparse.ml ./super_errors/super_reason_react.ml ./super_errors/super_reason_react.mli ./super_errors/super_typecore.ml ./super_errors/super_typemod.ml ./super_errors/super_typetexp.ml ./super_errors/super_warnings.ml ./syntax/ast_attributes.ml ./syntax/ast_attributes.mli ./syntax/ast_bs_open.ml ./syntax/ast_bs_open.mli ./syntax/ast_comb.ml ./syntax/ast_comb.mli ./syntax/ast_compatible.ml ./syntax/ast_compatible.mli ./syntax/ast_core_type.ml ./syntax/ast_core_type.mli ./syntax/ast_core_type_class_type.ml ./syntax/ast_core_type_class_type.mli ./syntax/ast_derive.ml ./syntax/ast_derive.mli ./syntax/ast_derive_abstract.ml ./syntax/ast_derive_abstract.mli ./syntax/ast_derive_js_mapper.ml ./syntax/ast_derive_js_mapper.mli ./syntax/ast_derive_projector.ml ./syntax/ast_derive_projector.mli ./syntax/ast_derive_util.ml ./syntax/ast_derive_util.mli ./syntax/ast_exp.ml ./syntax/ast_exp.mli ./syntax/ast_exp_apply.ml ./syntax/ast_exp_apply.mli ./syntax/ast_exp_extension.ml ./syntax/ast_exp_extension.mli ./syntax/ast_external.ml ./syntax/ast_external.mli ./syntax/ast_external_mk.ml ./syntax/ast_external_mk.mli ./syntax/ast_external_process.ml ./syntax/ast_external_process.mli ./syntax/ast_literal.ml ./syntax/ast_literal.mli ./syntax/ast_open_cxt.ml ./syntax/ast_open_cxt.mli ./syntax/ast_pat.ml ./syntax/ast_pat.mli ./syntax/ast_payload.ml ./syntax/ast_payload.mli ./syntax/ast_polyvar.ml ./syntax/ast_polyvar.mli ./syntax/ast_reason_pp.ml ./syntax/ast_reason_pp.mli ./syntax/ast_signature.ml ./syntax/ast_signature.mli ./syntax/ast_structure.ml ./syntax/ast_structure.mli ./syntax/ast_tdcls.ml ./syntax/ast_tdcls.mli ./syntax/ast_tuple_pattern_flatten.ml ./syntax/ast_tuple_pattern_flatten.mli ./syntax/ast_utf8_string.ml ./syntax/ast_utf8_string.mli ./syntax/ast_utf8_string_interp.ml ./syntax/ast_utf8_string_interp.mli ./syntax/ast_util.ml ./syntax/ast_util.mli ./syntax/bs_ast_invariant.ml ./syntax/bs_ast_invariant.mli ./syntax/bs_ast_mapper.ml ./syntax/bs_ast_mapper.mli ./syntax/bs_builtin_ppx.ml ./syntax/bs_builtin_ppx.mli ./syntax/bs_syntaxerr.ml ./syntax/bs_syntaxerr.mli ./syntax/external_arg_spec.ml ./syntax/external_arg_spec.mli ./syntax/external_ffi_types.ml ./syntax/external_ffi_types.mli ./syntax/reactjs_jsx_ppx_v2.ml ./syntax/reactjs_jsx_ppx_v3.ml \ No newline at end of file diff --git a/lib/4.06.1/unstable/native_ppx.ml b/lib/4.06.1/unstable/native_ppx.ml index 6357919e26..aeb0958e1d 100644 --- a/lib/4.06.1/unstable/native_ppx.ml +++ b/lib/4.06.1/unstable/native_ppx.ml @@ -7756,7 +7756,13 @@ val find_opt : ('a -> 'b option) -> 'b option +val find_def : + 'a list -> + ('a -> 'b option) -> + 'b -> + 'b + val rev_iter : 'a list -> ('a -> unit) -> @@ -8456,7 +8462,13 @@ let rec find_opt xs p = | Some _ as v -> v | None -> find_opt l p - +let rec find_def xs p def = + match xs with + | [] -> def + | x::l -> + match p x with + | Some v -> v + | None -> find_def l p def let rec split_map l f = match l with @@ -15135,6 +15147,16 @@ let emit_external_warnings : iterator= | _ -> default_iterator.expr self a ); + label_declaration = (fun self lbl -> + + Ext_list.iter lbl.pld_attributes + (fun attr -> + match attr with + | {txt = "bs.as"}, _ -> mark_used_bs_attribute attr + | _ -> () + ); + default_iterator.label_declaration self lbl + ); value_description = (fun self v -> match v with @@ -17939,7 +17961,7 @@ end = struct * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -let version = "6.3.0-dev.1" +let version = "7.0.0-dev.2" let header = "// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE" let package_name = "bs-platform" diff --git a/lib/4.06.1/whole_compiler.ml b/lib/4.06.1/whole_compiler.ml index 2f491456be..b5701a3ed7 100644 --- a/lib/4.06.1/whole_compiler.ml +++ b/lib/4.06.1/whole_compiler.ml @@ -3657,7 +3657,13 @@ val find_opt : ('a -> 'b option) -> 'b option +val find_def : + 'a list -> + ('a -> 'b option) -> + 'b -> + 'b + val rev_iter : 'a list -> ('a -> unit) -> @@ -4357,7 +4363,13 @@ let rec find_opt xs p = | Some _ as v -> v | None -> find_opt l p - +let rec find_def xs p def = + match xs with + | [] -> def + | x::l -> + match p x with + | Some v -> v + | None -> find_def l p def let rec split_map l f = match l with @@ -7442,7 +7454,7 @@ end = struct * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -let version = "6.3.0-dev.1" +let version = "7.0.0-dev.2" let header = "// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE" let package_name = "bs-platform" @@ -8475,15 +8487,15 @@ and directive_argument = | Pdir_bool of bool end -module Docstrings : sig -#1 "docstrings.mli" +module Builtin_attributes : sig +#1 "builtin_attributes.mli" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Leo White *) +(* Alain Frisch, LexiFi *) (* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* Copyright 2012 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -8492,156 +8504,364 @@ module Docstrings : sig (* *) (**************************************************************************) -(** Documentation comments *) +(* Support for some of the builtin attributes: -(** (Re)Initialise all docstring state *) -val init : unit -> unit + ocaml.deprecated + ocaml.error + ocaml.ppwarning + ocaml.warning + ocaml.warnerror + ocaml.explicit_arity (for camlp4/camlp5) + ocaml.warn_on_literal_pattern + ocaml.deprecated_mutable + ocaml.immediate + ocaml.boxed / ocaml.unboxed +*) -(** Emit warnings for unattached and ambiguous docstrings *) -val warn_bad_docstrings : unit -> unit -(** {2 Docstrings} *) +val check_deprecated: Location.t -> Parsetree.attributes -> string -> unit +val check_deprecated_inclusion: + def:Location.t -> use:Location.t -> Location.t -> Parsetree.attributes -> + Parsetree.attributes -> string -> unit +val deprecated_of_attrs: Parsetree.attributes -> string option +val deprecated_of_sig: Parsetree.signature -> string option +val deprecated_of_str: Parsetree.structure -> string option -(** Documentation comments *) -type docstring +val check_deprecated_mutable: + Location.t -> Parsetree.attributes -> string -> unit +val check_deprecated_mutable_inclusion: + def:Location.t -> use:Location.t -> Location.t -> Parsetree.attributes -> + Parsetree.attributes -> string -> unit -(** Create a docstring *) -val docstring : string -> Location.t -> docstring +val check_bs_attributes_inclusion: + (Parsetree.attributes -> + Parsetree.attributes -> string -> (string*string) option ) ref -(** Register a docstring *) -val register : docstring -> unit +val error_of_extension: Parsetree.extension -> Location.error -(** Get the text of a docstring *) -val docstring_body : docstring -> string +val warning_attribute: ?ppwarning:bool -> Parsetree.attribute -> unit + (** Apply warning settings from the specified attribute. + "ocaml.warning"/"ocaml.warnerror" (and variants without the prefix) + are processed and other attributes are ignored. -(** Get the location of a docstring *) -val docstring_loc : docstring -> Location.t + Also implement ocaml.ppwarning (unless ~ppwarning:false is + passed). + *) -(** {2 Set functions} +val warning_scope: + ?ppwarning:bool -> + Parsetree.attributes -> (unit -> 'a) -> 'a + (** Execute a function in a new scope for warning settings. This + means that the effect of any call to [warning_attribute] during + the execution of this function will be discarded after + execution. - These functions are used by the lexer to associate docstrings to - the locations of tokens. *) + The function also takes a list of attributes which are processed + with [warning_attribute] in the fresh scope before the function + is executed. + *) -(** Docstrings immediately preceding a token *) -val set_pre_docstrings : Lexing.position -> docstring list -> unit +val warn_on_literal_pattern: Parsetree.attributes -> bool +val explicit_arity: Parsetree.attributes -> bool -(** Docstrings immediately following a token *) -val set_post_docstrings : Lexing.position -> docstring list -> unit -(** Docstrings not immediately adjacent to a token *) -val set_floating_docstrings : Lexing.position -> docstring list -> unit +val immediate: Parsetree.attributes -> bool -(** Docstrings immediately following the token which precedes this one *) -val set_pre_extra_docstrings : Lexing.position -> docstring list -> unit +val has_unboxed: Parsetree.attributes -> bool +val has_boxed: Parsetree.attributes -> bool -(** Docstrings immediately preceding the token which follows this one *) -val set_post_extra_docstrings : Lexing.position -> docstring list -> unit +end = struct +#1 "builtin_attributes.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Alain Frisch, LexiFi *) +(* *) +(* Copyright 2012 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -(** {2 Items} +open Asttypes +open Parsetree - The {!docs} type represents documentation attached to an item. *) +let string_of_cst = function + | Pconst_string(s, _) -> Some s + | _ -> None -type docs = - { docs_pre: docstring option; - docs_post: docstring option; } +let string_of_payload = function + | PStr[{pstr_desc=Pstr_eval({pexp_desc=Pexp_constant c},_)}] -> + string_of_cst c + | _ -> None -val empty_docs : docs +let string_of_opt_payload p = + match string_of_payload p with + | Some s -> s + | None -> "" -val docs_attr : docstring -> Parsetree.attribute +let rec error_of_extension ext = + match ext with + | ({txt = ("ocaml.error"|"error") as txt; loc}, p) -> + let rec sub_from inner = + match inner with + | {pstr_desc=Pstr_extension (ext, _)} :: rest -> + error_of_extension ext :: sub_from rest + | _ :: rest -> + (Location.errorf ~loc + "Invalid syntax for sub-error of extension '%s'." txt) :: + sub_from rest + | [] -> [] + in + begin match p with + | PStr [] -> raise Location.Already_displayed_error + | PStr({pstr_desc=Pstr_eval + ({pexp_desc=Pexp_constant(Pconst_string(msg,_))}, _)}:: + {pstr_desc=Pstr_eval + ({pexp_desc=Pexp_constant(Pconst_string(if_highlight,_))}, _)}:: + inner) -> + Location.error ~loc ~if_highlight ~sub:(sub_from inner) msg + | PStr({pstr_desc=Pstr_eval + ({pexp_desc=Pexp_constant(Pconst_string(msg,_))}, _)}::inner) -> + Location.error ~loc ~sub:(sub_from inner) msg + | _ -> Location.errorf ~loc "Invalid syntax for extension '%s'." txt + end + | ({txt; loc}, _) -> + Location.errorf ~loc "Uninterpreted extension '%s'." txt -(** Convert item documentation to attributes and add them to an - attribute list *) -val add_docs_attrs : docs -> Parsetree.attributes -> Parsetree.attributes +let cat s1 s2 = + if s2 = "" then s1 else + + if Clflags.bs_vscode then s1 ^ " " ^ s2 + else s1 ^ "\n" ^ s2 + -(** Fetch the item documentation for the current symbol. This also - marks this documentation (for ambiguity warnings). *) -val symbol_docs : unit -> docs -val symbol_docs_lazy : unit -> docs Lazy.t +let rec deprecated_of_attrs = function + | [] -> None + | ({txt = "ocaml.deprecated"|"deprecated"; _}, p) :: _ -> + Some (string_of_opt_payload p) + | _ :: tl -> deprecated_of_attrs tl -(** Fetch the item documentation for the symbols between two - positions. This also marks this documentation (for ambiguity - warnings). *) -val rhs_docs : int -> int -> docs -val rhs_docs_lazy : int -> int -> docs Lazy.t +let check_deprecated loc attrs s = + match deprecated_of_attrs attrs with + | None -> () + | Some txt -> Location.deprecated loc (cat s txt) -(** Mark the item documentation for the current symbol (for ambiguity - warnings). *) -val mark_symbol_docs : unit -> unit +let check_deprecated_inclusion ~def ~use loc attrs1 attrs2 s = + match deprecated_of_attrs attrs1, deprecated_of_attrs attrs2 with + | None, _ | Some _, Some _ -> () + | Some txt, None -> Location.deprecated ~def ~use loc (cat s txt) -(** Mark as associated the item documentation for the symbols between - two positions (for ambiguity warnings) *) -val mark_rhs_docs : int -> int -> unit +let rec deprecated_mutable_of_attrs = function + | [] -> None + | ({txt = "ocaml.deprecated_mutable"|"deprecated_mutable"; _}, p) :: _ -> + Some (string_of_opt_payload p) + | _ :: tl -> deprecated_mutable_of_attrs tl -(** {2 Fields and constructors} +let check_deprecated_mutable loc attrs s = + match deprecated_mutable_of_attrs attrs with + | None -> () + | Some txt -> + Location.deprecated loc (Printf.sprintf "mutating field %s" (cat s txt)) - The {!info} type represents documentation attached to a field or - constructor. *) +let check_deprecated_mutable_inclusion ~def ~use loc attrs1 attrs2 s = + match deprecated_mutable_of_attrs attrs1, + deprecated_mutable_of_attrs attrs2 + with + | None, _ | Some _, Some _ -> () + | Some txt, None -> + Location.deprecated ~def ~use loc + (Printf.sprintf "mutating field %s" (cat s txt)) -type info = docstring option +let check_bs_attributes_inclusion = + ref (fun _attrs1 _attrs2 _s -> + None + ) -val empty_info : info +let rec deprecated_of_sig = function + | {psig_desc = Psig_attribute a} :: tl -> + begin match deprecated_of_attrs [a] with + | None -> deprecated_of_sig tl + | Some _ as r -> r + end + | _ -> None -val info_attr : docstring -> Parsetree.attribute -(** Convert field info to attributes and add them to an - attribute list *) -val add_info_attrs : info -> Parsetree.attributes -> Parsetree.attributes +let rec deprecated_of_str = function + | {pstr_desc = Pstr_attribute a} :: tl -> + begin match deprecated_of_attrs [a] with + | None -> deprecated_of_str tl + | Some _ as r -> r + end + | _ -> None -(** Fetch the field info for the current symbol. *) -val symbol_info : unit -> info -(** Fetch the field info following the symbol at a given position. *) -val rhs_info : int -> info +let warning_attribute ?(ppwarning = true) = + let process loc txt errflag payload = + match string_of_payload payload with + | Some s -> + begin try Warnings.parse_options errflag s + with Arg.Bad _ -> + Location.prerr_warning loc + (Warnings.Attribute_payload + (txt, "Ill-formed list of warnings")) + end + | None -> + Location.prerr_warning loc + (Warnings.Attribute_payload + (txt, "A single string literal is expected")) + in + function + | ({txt = ("ocaml.warning"|"warning") as txt; loc}, payload) -> + process loc txt false payload + | ({txt = ("ocaml.warnerror"|"warnerror") as txt; loc}, payload) -> + process loc txt true payload + | {txt="ocaml.ppwarning"|"ppwarning"}, + PStr[{pstr_desc=Pstr_eval({pexp_desc=Pexp_constant + (Pconst_string (s, _))},_); + pstr_loc}] when ppwarning -> + Location.prerr_warning pstr_loc (Warnings.Preprocessor s) + | _ -> + () -(** {2 Unattached comments} +let warning_scope ?ppwarning attrs f = + let prev = Warnings.backup () in + try + List.iter (warning_attribute ?ppwarning) (List.rev attrs); + let ret = f () in + Warnings.restore prev; + ret + with exn -> + Warnings.restore prev; + raise exn - The {!text} type represents documentation which is not attached to - anything. *) -type text = docstring list +let warn_on_literal_pattern = + List.exists + (function + | ({txt="ocaml.warn_on_literal_pattern"|"warn_on_literal_pattern"; _}, _) + -> true + | _ -> false + ) -val empty_text : text -val empty_text_lazy : text Lazy.t +let explicit_arity = + List.exists + (function + | ({txt="ocaml.explicit_arity"|"explicit_arity"; _}, _) -> true + | _ -> false + ) -val text_attr : docstring -> Parsetree.attribute +let immediate = + List.exists + (function + | ({txt="ocaml.immediate"|"immediate"; _}, _) -> true + | _ -> false + ) -(** Convert text to attributes and add them to an attribute list *) -val add_text_attrs : text -> Parsetree.attributes -> Parsetree.attributes +(* The "ocaml.boxed (default)" and "ocaml.unboxed (default)" + attributes cannot be input by the user, they are added by the + compiler when applying the default setting. This is done to record + in the .cmi the default used by the compiler when compiling the + source file because the default can change between compiler + invocations. *) -(** Fetch the text preceding the current symbol. *) -val symbol_text : unit -> text -val symbol_text_lazy : unit -> text Lazy.t +let check l (x, _) = List.mem x.txt l -(** Fetch the text preceding the symbol at the given position. *) -val rhs_text : int -> text -val rhs_text_lazy : int -> text Lazy.t +let has_unboxed attr = + List.exists (check ["ocaml.unboxed"; "unboxed"]) + attr -(** {2 Extra text} +let has_boxed attr = + List.exists (check ["ocaml.boxed"; "boxed"]) attr - There may be additional text attached to the delimiters of a block - (e.g. [struct] and [end]). This is fetched by the following - functions, which are applied to the contents of the block rather - than the delimiters. *) +end +module Ident : sig +#1 "ident.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -(** Fetch additional text preceding the current symbol *) -val symbol_pre_extra_text : unit -> text +(* Identifiers (unique names) *) -(** Fetch additional text following the current symbol *) -val symbol_post_extra_text : unit -> text +type t = { stamp: int; name: string; mutable flags: int } -(** Fetch additional text preceding the symbol at the given position *) -val rhs_pre_extra_text : int -> text +include Identifiable.S with type t := t +(* Notes: + - [equal] compares identifiers by name + - [compare x y] is 0 if [same x y] is true. + - [compare] compares identifiers by binding location +*) -(** Fetch additional text following the symbol at the given position *) -val rhs_post_extra_text : int -> text + +val create: string -> t +val create_persistent: string -> t +val create_predef_exn: string -> t +val rename: t -> t +val name: t -> string +val unique_name: t -> string +val unique_toplevel_name: t -> string +val persistent: t -> bool +val same: t -> t -> bool + (* Compare identifiers by binding location. + Two identifiers are the same either if they are both + non-persistent and have been created by the same call to + [new], or if they are both persistent and have the same + name. *) +val compare: t -> t -> int +val hide: t -> t + (* Return an identifier with same name as the given identifier, + but stamp different from any stamp returned by new. + When put in a 'a tbl, this identifier can only be looked + up by name. *) + +val make_global: t -> unit +val global: t -> bool +val is_predef_exn: t -> bool + +val binding_time: t -> int +val current_time: unit -> int +val set_current_time: int -> unit +val reinit: unit -> unit + +type 'a tbl + (* Association tables from identifiers to type 'a. *) + +val empty: 'a tbl +val add: t -> 'a -> 'a tbl -> 'a tbl +val find_same: t -> 'a tbl -> 'a +val find_name: string -> 'a tbl -> t * 'a +val find_all: string -> 'a tbl -> (t * 'a) list +val fold_name: (t -> 'a -> 'b -> 'b) -> 'a tbl -> 'b -> 'b +val fold_all: (t -> 'a -> 'b -> 'b) -> 'a tbl -> 'b -> 'b +val iter: (t -> 'a -> unit) -> 'a tbl -> unit + + +(* Idents for sharing keys *) + +val make_key_generator : unit -> (t -> t) end = struct -#1 "docstrings.ml" +#1 "ident.ml" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Leo White *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) (* *) (* Copyright 1996 Institut National de Recherche en Informatique et *) (* en Automatique. *) @@ -8652,345 +8872,413 @@ end = struct (* *) (**************************************************************************) -open Location +open Format -(* Docstrings *) +type t = { stamp: int; name: string; mutable flags: int } -(* A docstring is "attached" if it has been inserted in the AST. This - is used for generating unexpected docstring warnings. *) -type ds_attached = - | Unattached (* Not yet attached anything.*) - | Info (* Attached to a field or constructor. *) - | Docs (* Attached to an item or as floating text. *) +let global_flag = 1 +let predef_exn_flag = 2 -(* A docstring is "associated" with an item if there are no blank lines between - them. This is used for generating docstring ambiguity warnings. *) -type ds_associated = - | Zero (* Not associated with an item *) - | One (* Associated with one item *) - | Many (* Associated with multiple items (ambiguity) *) +(* A stamp of 0 denotes a persistent identifier *) -type docstring = - { ds_body: string; - ds_loc: Location.t; - mutable ds_attached: ds_attached; - mutable ds_associated: ds_associated; } +let currentstamp = ref 0 -(* List of docstrings *) +let create s = + incr currentstamp; + { name = s; stamp = !currentstamp; flags = 0 } -let docstrings : docstring list ref = ref [] +let create_predef_exn s = + incr currentstamp; + { name = s; stamp = !currentstamp; flags = predef_exn_flag } -(* Warn for unused and ambiguous docstrings *) +let create_persistent s = + { name = s; stamp = 0; flags = global_flag } -let warn_bad_docstrings () = - if Warnings.is_active (Warnings.Bad_docstring true) then begin - List.iter - (fun ds -> - match ds.ds_attached with - | Info -> () - | Unattached -> - prerr_warning ds.ds_loc (Warnings.Bad_docstring true) - | Docs -> - match ds.ds_associated with - | Zero | One -> () - | Many -> - prerr_warning ds.ds_loc (Warnings.Bad_docstring false)) - (List.rev !docstrings) -end +let rename i = + incr currentstamp; + { i with stamp = !currentstamp } -(* Docstring constructors and destructors *) +let name i = i.name -let docstring body loc = - let ds = - { ds_body = body; - ds_loc = loc; - ds_attached = Unattached; - ds_associated = Zero; } - in - ds +let unique_name i = i.name ^ "_" ^ string_of_int i.stamp -let register ds = - docstrings := ds :: !docstrings +let unique_toplevel_name i = i.name ^ "/" ^ string_of_int i.stamp -let docstring_body ds = ds.ds_body +let persistent i = (i.stamp = 0) -let docstring_loc ds = ds.ds_loc +let equal i1 i2 = i1.name = i2.name -(* Docstrings attached to items *) +let same i1 i2 = i1 = i2 + (* Possibly more efficient version (with a real compiler, at least): + if i1.stamp <> 0 + then i1.stamp = i2.stamp + else i2.stamp = 0 && i1.name = i2.name *) -type docs = - { docs_pre: docstring option; - docs_post: docstring option; } +let compare i1 i2 = Pervasives.compare i1 i2 -let empty_docs = { docs_pre = None; docs_post = None } +let binding_time i = i.stamp -let doc_loc = {txt = "ocaml.doc"; loc = Location.none} +let current_time() = !currentstamp +let set_current_time t = currentstamp := max !currentstamp t -let docs_attr ds = - let open Parsetree in - let exp = - { pexp_desc = Pexp_constant (Pconst_string(ds.ds_body, None)); - pexp_loc = ds.ds_loc; - pexp_attributes = []; } - in - let item = - { pstr_desc = Pstr_eval (exp, []); pstr_loc = exp.pexp_loc } - in - (doc_loc, PStr [item]) +let reinit_level = ref (-1) -let add_docs_attrs docs attrs = - let attrs = - match docs.docs_pre with - | None | Some { ds_body=""; _ } -> attrs - | Some ds -> docs_attr ds :: attrs - in - let attrs = - match docs.docs_post with - | None | Some { ds_body=""; _ } -> attrs - | Some ds -> attrs @ [docs_attr ds] - in - attrs +let reinit () = + if !reinit_level < 0 + then reinit_level := !currentstamp + else currentstamp := !reinit_level -(* Docstrings attached to constructors or fields *) +let hide i = + { i with stamp = -1 } -type info = docstring option +let make_global i = + i.flags <- i.flags lor global_flag -let empty_info = None +let global i = + (i.flags land global_flag) <> 0 -let info_attr = docs_attr +let is_predef_exn i = + (i.flags land predef_exn_flag) <> 0 -let add_info_attrs info attrs = - match info with - | None | Some {ds_body=""; _} -> attrs - | Some ds -> attrs @ [info_attr ds] +let print ppf i = + match i.stamp with + | 0 -> fprintf ppf "%s!" i.name + | -1 -> fprintf ppf "%s#" i.name + | n -> fprintf ppf "%s/%i%s" i.name n (if global i then "g" else "") -(* Docstrings not attached to a specific item *) +type 'a tbl = + Empty + | Node of 'a tbl * 'a data * 'a tbl * int -type text = docstring list +and 'a data = + { ident: t; + data: 'a; + previous: 'a data option } -let empty_text = [] -let empty_text_lazy = lazy [] +let empty = Empty -let text_loc = {txt = "ocaml.text"; loc = Location.none} +(* Inline expansion of height for better speed + * let height = function + * Empty -> 0 + * | Node(_,_,_,h) -> h + *) -let text_attr ds = - let open Parsetree in - let exp = - { pexp_desc = Pexp_constant (Pconst_string(ds.ds_body, None)); - pexp_loc = ds.ds_loc; - pexp_attributes = []; } - in - let item = - { pstr_desc = Pstr_eval (exp, []); pstr_loc = exp.pexp_loc } - in - (text_loc, PStr [item]) +let mknode l d r = + let hl = match l with Empty -> 0 | Node(_,_,_,h) -> h + and hr = match r with Empty -> 0 | Node(_,_,_,h) -> h in + Node(l, d, r, (if hl >= hr then hl + 1 else hr + 1)) -let add_text_attrs dsl attrs = - let fdsl = List.filter (function {ds_body=""} -> false| _ ->true) dsl in - (List.map text_attr fdsl) @ attrs +let balance l d r = + let hl = match l with Empty -> 0 | Node(_,_,_,h) -> h + and hr = match r with Empty -> 0 | Node(_,_,_,h) -> h in + if hl > hr + 1 then + match l with + | Node (ll, ld, lr, _) + when (match ll with Empty -> 0 | Node(_,_,_,h) -> h) >= + (match lr with Empty -> 0 | Node(_,_,_,h) -> h) -> + mknode ll ld (mknode lr d r) + | Node (ll, ld, Node(lrl, lrd, lrr, _), _) -> + mknode (mknode ll ld lrl) lrd (mknode lrr d r) + | _ -> assert false + else if hr > hl + 1 then + match r with + | Node (rl, rd, rr, _) + when (match rr with Empty -> 0 | Node(_,_,_,h) -> h) >= + (match rl with Empty -> 0 | Node(_,_,_,h) -> h) -> + mknode (mknode l d rl) rd rr + | Node (Node (rll, rld, rlr, _), rd, rr, _) -> + mknode (mknode l d rll) rld (mknode rlr rd rr) + | _ -> assert false + else + mknode l d r -(* Find the first non-info docstring in a list, attach it and return it *) -let get_docstring ~info dsl = - let rec loop = function - | [] -> None - | {ds_attached = Info; _} :: rest -> loop rest - | ds :: _ -> - ds.ds_attached <- if info then Info else Docs; - Some ds - in - loop dsl +let rec add id data = function + Empty -> + Node(Empty, {ident = id; data = data; previous = None}, Empty, 1) + | Node(l, k, r, h) -> + let c = compare id.name k.ident.name in + if c = 0 then + Node(l, {ident = id; data = data; previous = Some k}, r, h) + else if c < 0 then + balance (add id data l) k r + else + balance l k (add id data r) -(* Find all the non-info docstrings in a list, attach them and return them *) -let get_docstrings dsl = - let rec loop acc = function - | [] -> List.rev acc - | {ds_attached = Info; _} :: rest -> loop acc rest - | ds :: rest -> - ds.ds_attached <- Docs; - loop (ds :: acc) rest - in - loop [] dsl +let rec find_stamp s = function + None -> + raise Not_found + | Some k -> + if k.ident.stamp = s then k.data else find_stamp s k.previous -(* "Associate" all the docstrings in a list *) -let associate_docstrings dsl = - List.iter - (fun ds -> - match ds.ds_associated with - | Zero -> ds.ds_associated <- One - | (One | Many) -> ds.ds_associated <- Many) - dsl +let rec find_same id = function + Empty -> + raise Not_found + | Node(l, k, r, _) -> + let c = compare id.name k.ident.name in + if c = 0 then + if id.stamp = k.ident.stamp + then k.data + else find_stamp id.stamp k.previous + else + find_same id (if c < 0 then l else r) -(* Map from positions to pre docstrings *) +let rec find_name name = function + Empty -> + raise Not_found + | Node(l, k, r, _) -> + let c = compare name k.ident.name in + if c = 0 then + k.ident, k.data + else + find_name name (if c < 0 then l else r) -let pre_table : (Lexing.position, docstring list) Hashtbl.t = - Hashtbl.create 50 +let rec get_all = function + | None -> [] + | Some k -> (k.ident, k.data) :: get_all k.previous -let set_pre_docstrings pos dsl = - if dsl <> [] then Hashtbl.add pre_table pos dsl +let rec find_all name = function + Empty -> + [] + | Node(l, k, r, _) -> + let c = compare name k.ident.name in + if c = 0 then + (k.ident, k.data) :: get_all k.previous + else + find_all name (if c < 0 then l else r) -let get_pre_docs pos = - try - let dsl = Hashtbl.find pre_table pos in - associate_docstrings dsl; - get_docstring ~info:false dsl - with Not_found -> None +let rec fold_aux f stack accu = function + Empty -> + begin match stack with + [] -> accu + | a :: l -> fold_aux f l accu a + end + | Node(l, k, r, _) -> + fold_aux f (l :: stack) (f k accu) r -let mark_pre_docs pos = - try - let dsl = Hashtbl.find pre_table pos in - associate_docstrings dsl - with Not_found -> () +let fold_name f tbl accu = fold_aux (fun k -> f k.ident k.data) [] accu tbl -(* Map from positions to post docstrings *) +let rec fold_data f d accu = + match d with + None -> accu + | Some k -> f k.ident k.data (fold_data f k.previous accu) -let post_table : (Lexing.position, docstring list) Hashtbl.t = - Hashtbl.create 50 +let fold_all f tbl accu = + fold_aux (fun k -> fold_data f (Some k)) [] accu tbl -let set_post_docstrings pos dsl = - if dsl <> [] then Hashtbl.add post_table pos dsl +(* let keys tbl = fold_name (fun k _ accu -> k::accu) tbl [] *) -let get_post_docs pos = - try - let dsl = Hashtbl.find post_table pos in - associate_docstrings dsl; - get_docstring ~info:false dsl - with Not_found -> None +let rec iter f = function + Empty -> () + | Node(l, k, r, _) -> + iter f l; f k.ident k.data; iter f r -let mark_post_docs pos = - try - let dsl = Hashtbl.find post_table pos in - associate_docstrings dsl - with Not_found -> () +(* Idents for sharing keys *) -let get_info pos = - try - let dsl = Hashtbl.find post_table pos in - get_docstring ~info:true dsl - with Not_found -> None +(* They should be 'totally fresh' -> neg numbers *) +let key_name = "" -(* Map from positions to floating docstrings *) +let make_key_generator () = + let c = ref 1 in + fun id -> + let stamp = !c in + decr c ; + { id with name = key_name; stamp = stamp; } -let floating_table : (Lexing.position, docstring list) Hashtbl.t = - Hashtbl.create 50 +let compare x y = + let c = x.stamp - y.stamp in + if c <> 0 then c + else + let c = compare x.name y.name in + if c <> 0 then c + else + compare x.flags y.flags -let set_floating_docstrings pos dsl = - if dsl <> [] then Hashtbl.add floating_table pos dsl +let output oc id = output_string oc (unique_name id) +let hash i = (Char.code i.name.[0]) lxor i.stamp -let get_text pos = - try - let dsl = Hashtbl.find floating_table pos in - get_docstrings dsl - with Not_found -> [] +let original_equal = equal +include Identifiable.Make (struct + type nonrec t = t + let compare = compare + let output = output + let print = print + let hash = hash + let equal = same +end) +let equal = original_equal -(* Maps from positions to extra docstrings *) +end +module Path : sig +#1 "path.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -let pre_extra_table : (Lexing.position, docstring list) Hashtbl.t = - Hashtbl.create 50 +(* Access paths *) -let set_pre_extra_docstrings pos dsl = - if dsl <> [] then Hashtbl.add pre_extra_table pos dsl +type t = + Pident of Ident.t + | Pdot of t * string * int + | Papply of t * t -let get_pre_extra_text pos = - try - let dsl = Hashtbl.find pre_extra_table pos in - get_docstrings dsl - with Not_found -> [] +val same: t -> t -> bool +val compare: t -> t -> int +val isfree: Ident.t -> t -> bool +val binding_time: t -> int +val flatten : t -> [ `Contains_apply | `Ok of Ident.t * string list ] -let post_extra_table : (Lexing.position, docstring list) Hashtbl.t = - Hashtbl.create 50 +val nopos: int -let set_post_extra_docstrings pos dsl = - if dsl <> [] then Hashtbl.add post_extra_table pos dsl +val name: ?paren:(string -> bool) -> t -> string + (* [paren] tells whether a path suffix needs parentheses *) +val head: t -> Ident.t -let get_post_extra_text pos = - try - let dsl = Hashtbl.find post_extra_table pos in - get_docstrings dsl - with Not_found -> [] +val heads: t -> Ident.t list -(* Docstrings from parser actions *) +val last: t -> string -let symbol_docs () = - { docs_pre = get_pre_docs (Parsing.symbol_start_pos ()); - docs_post = get_post_docs (Parsing.symbol_end_pos ()); } +type typath = + | Regular of t + | Ext of t * string + | LocalExt of Ident.t + | Cstr of t * string -let symbol_docs_lazy () = - let p1 = Parsing.symbol_start_pos () in - let p2 = Parsing.symbol_end_pos () in - lazy { docs_pre = get_pre_docs p1; - docs_post = get_post_docs p2; } +val constructor_typath: t -> typath +val is_constructor_typath: t -> bool -let rhs_docs pos1 pos2 = - { docs_pre = get_pre_docs (Parsing.rhs_start_pos pos1); - docs_post = get_post_docs (Parsing.rhs_end_pos pos2); } +end = struct +#1 "path.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -let rhs_docs_lazy pos1 pos2 = - let p1 = Parsing.rhs_start_pos pos1 in - let p2 = Parsing.rhs_end_pos pos2 in - lazy { docs_pre = get_pre_docs p1; - docs_post = get_post_docs p2; } +type t = + Pident of Ident.t + | Pdot of t * string * int + | Papply of t * t -let mark_symbol_docs () = - mark_pre_docs (Parsing.symbol_start_pos ()); - mark_post_docs (Parsing.symbol_end_pos ()) +let nopos = -1 -let mark_rhs_docs pos1 pos2 = - mark_pre_docs (Parsing.rhs_start_pos pos1); - mark_post_docs (Parsing.rhs_end_pos pos2) +let rec same p1 p2 = + match (p1, p2) with + (Pident id1, Pident id2) -> Ident.same id1 id2 + | (Pdot(p1, s1, _pos1), Pdot(p2, s2, _pos2)) -> s1 = s2 && same p1 p2 + | (Papply(fun1, arg1), Papply(fun2, arg2)) -> + same fun1 fun2 && same arg1 arg2 + | (_, _) -> false -let symbol_info () = - get_info (Parsing.symbol_end_pos ()) +let rec compare p1 p2 = + match (p1, p2) with + (Pident id1, Pident id2) -> Ident.compare id1 id2 + | (Pdot(p1, s1, _pos1), Pdot(p2, s2, _pos2)) -> + let h = compare p1 p2 in + if h <> 0 then h else String.compare s1 s2 + | (Papply(fun1, arg1), Papply(fun2, arg2)) -> + let h = compare fun1 fun2 in + if h <> 0 then h else compare arg1 arg2 + | ((Pident _ | Pdot _), (Pdot _ | Papply _)) -> -1 + | ((Pdot _ | Papply _), (Pident _ | Pdot _)) -> 1 -let rhs_info pos = - get_info (Parsing.rhs_end_pos pos) +let rec isfree id = function + Pident id' -> Ident.same id id' + | Pdot(p, _s, _pos) -> isfree id p + | Papply(p1, p2) -> isfree id p1 || isfree id p2 -let symbol_text () = - get_text (Parsing.symbol_start_pos ()) +let rec binding_time = function + Pident id -> Ident.binding_time id + | Pdot(p, _s, _pos) -> binding_time p + | Papply(p1, p2) -> max (binding_time p1) (binding_time p2) -let symbol_text_lazy () = - let pos = Parsing.symbol_start_pos () in - lazy (get_text pos) +let kfalse _ = false -let rhs_text pos = - get_text (Parsing.rhs_start_pos pos) +let rec name ?(paren=kfalse) = function + Pident id -> Ident.name id + | Pdot(p, s, _pos) -> + name ~paren p ^ if paren s then ".( " ^ s ^ " )" else "." ^ s + | Papply(p1, p2) -> name ~paren p1 ^ "(" ^ name ~paren p2 ^ ")" -let rhs_text_lazy pos = - let pos = Parsing.rhs_start_pos pos in - lazy (get_text pos) +let rec head = function + Pident id -> id + | Pdot(p, _s, _pos) -> head p + | Papply _ -> assert false -let symbol_pre_extra_text () = - get_pre_extra_text (Parsing.symbol_start_pos ()) +let flatten = + let rec flatten acc = function + | Pident id -> `Ok (id, acc) + | Pdot (p, s, _) -> flatten (s :: acc) p + | Papply _ -> `Contains_apply + in + fun t -> flatten [] t -let symbol_post_extra_text () = - get_post_extra_text (Parsing.symbol_end_pos ()) +let heads p = + let rec heads p acc = match p with + | Pident id -> id :: acc + | Pdot (p, _s, _pos) -> heads p acc + | Papply(p1, p2) -> + heads p1 (heads p2 acc) + in heads p [] -let rhs_pre_extra_text pos = - get_pre_extra_text (Parsing.rhs_start_pos pos) +let rec last = function + | Pident id -> Ident.name id + | Pdot(_, s, _) -> s + | Papply(_, p) -> last p -let rhs_post_extra_text pos = - get_post_extra_text (Parsing.rhs_end_pos pos) +let is_uident s = + assert (s <> ""); + match s.[0] with + | 'A'..'Z' -> true + | _ -> false +type typath = + | Regular of t + | Ext of t * string + | LocalExt of Ident.t + | Cstr of t * string -(* (Re)Initialise all comment state *) +let constructor_typath = function + | Pident id when is_uident (Ident.name id) -> LocalExt id + | Pdot(ty_path, s, _) when is_uident s -> + if is_uident (last ty_path) then Ext (ty_path, s) + else Cstr (ty_path, s) + | p -> Regular p -let init () = - docstrings := []; - Hashtbl.reset pre_table; - Hashtbl.reset post_table; - Hashtbl.reset floating_table; - Hashtbl.reset pre_extra_table; - Hashtbl.reset post_extra_table +let is_constructor_typath p = + match constructor_typath p with + | Regular _ -> false + | _ -> true end -module Syntaxerr : sig -#1 "syntaxerr.mli" +module Attr_helper : sig +#1 "attr_helper.mli" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* Jeremie Dimino, Jane Street Europe *) (* *) -(* Copyright 1997 Institut National de Recherche en Informatique et *) +(* Copyright 2015 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -8999,38 +9287,37 @@ module Syntaxerr : sig (* *) (**************************************************************************) -(** Auxiliary type for reporting syntax errors *) +(** Helpers for attributes *) -open Format +open Asttypes +open Parsetree type error = - Unclosed of Location.t * string * Location.t * string - | Expecting of Location.t * string - | Not_expecting of Location.t * string - | Applicative_path of Location.t - | Variable_in_scope of Location.t * string - | Other of Location.t - | Ill_formed_ast of Location.t * string - | Invalid_package_type of Location.t * string + | Multiple_attributes of string + | No_payload_expected of string -exception Error of error -exception Escape_error +(** The [string list] argument of the following functions is a list of + alternative names for the attribute we are looking for. For instance: -val report_error: formatter -> error -> unit - (** @deprecated Use {!Location.error_of_exn}, {!Location.report_error}. *) + {[ + ["foo"; "ocaml.foo"] + ]} *) +val get_no_payload_attribute : string list -> attributes -> string loc option +val has_no_payload_attribute : string list -> attributes -> bool -val location_of_error: error -> Location.t -val ill_formed_ast: Location.t -> string -> 'a +exception Error of Location.t * error + +val report_error: Format.formatter -> error -> unit end = struct -#1 "syntaxerr.ml" +#1 "attr_helper.ml" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* Jeremie Dimino, Jane Street Europe *) (* *) -(* Copyright 1997 Institut National de Recherche en Informatique et *) +(* Copyright 2015 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -9039,89 +9326,58 @@ end = struct (* *) (**************************************************************************) -(* Auxiliary type for reporting syntax errors *) +open Asttypes +open Parsetree type error = - Unclosed of Location.t * string * Location.t * string - | Expecting of Location.t * string - | Not_expecting of Location.t * string - | Applicative_path of Location.t - | Variable_in_scope of Location.t * string - | Other of Location.t - | Ill_formed_ast of Location.t * string - | Invalid_package_type of Location.t * string + | Multiple_attributes of string + | No_payload_expected of string -exception Error of error -exception Escape_error +exception Error of Location.t * error -let prepare_error = function - | Unclosed(opening_loc, opening, closing_loc, closing) -> - Location.errorf ~loc:closing_loc - ~sub:[ - Location.errorf ~loc:opening_loc - "This '%s' might be unmatched" opening - ] - ~if_highlight: - (Printf.sprintf "Syntax error: '%s' expected, \ - the highlighted '%s' might be unmatched" - closing opening) - "Syntax error: '%s' expected" closing +let get_no_payload_attribute alt_names attrs = + match List.filter (fun (n, _) -> List.mem n.txt alt_names) attrs with + | [] -> None + | [ (name, PStr []) ] -> Some name + | [ (name, _) ] -> + raise (Error (name.loc, No_payload_expected name.txt)) + | _ :: (name, _) :: _ -> + raise (Error (name.loc, Multiple_attributes name.txt)) - | Expecting (loc, nonterm) -> - Location.errorf ~loc "Syntax error: %s expected." nonterm - | Not_expecting (loc, nonterm) -> - Location.errorf ~loc "Syntax error: %s not expected." nonterm - | Applicative_path loc -> - Location.errorf ~loc - "Syntax error: applicative paths of the form F(X).t \ - are not supported when the option -no-app-func is set." - | Variable_in_scope (loc, var) -> - Location.errorf ~loc - "In this scoped type, variable '%s \ - is reserved for the local type %s." - var var - | Other loc -> - Location.errorf ~loc "Syntax error" - | Ill_formed_ast (loc, s) -> - Location.errorf ~loc "broken invariant in parsetree: %s" s - | Invalid_package_type (loc, s) -> - Location.errorf ~loc "invalid package type: %s" s +let has_no_payload_attribute alt_names attrs = + match get_no_payload_attribute alt_names attrs with + | None -> false + | Some _ -> true + +open Format + +let report_error ppf = function + | Multiple_attributes name -> + fprintf ppf "Too many `%s' attributes" name + | No_payload_expected name -> + fprintf ppf "Attribute `%s' does not accept a payload" name let () = Location.register_error_of_exn (function - | Error err -> Some (prepare_error err) - | _ -> None + | Error (loc, err) -> + Some (Location.error_of_printer loc report_error err) + | _ -> + None ) - -let report_error ppf err = - Location.report_error ppf (prepare_error err) - -let location_of_error = function - | Unclosed(l,_,_,_) - | Applicative_path l - | Variable_in_scope(l,_) - | Other l - | Not_expecting (l, _) - | Ill_formed_ast (l, _) - | Invalid_package_type (l, _) - | Expecting (l, _) -> l - - -let ill_formed_ast loc s = - raise (Error (Ill_formed_ast (loc, s))) - end -module Ast_helper : sig -#1 "ast_helper.mli" +(** Interface as module *) +module Outcometree += struct +#1 "outcometree.mli" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Alain Frisch, LexiFi *) +(* Daniel de Rauglaudre, projet Cristal, INRIA Rocquencourt *) (* *) -(* Copyright 2012 Institut National de Recherche en Informatique et *) +(* Copyright 2001 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -9130,443 +9386,446 @@ module Ast_helper : sig (* *) (**************************************************************************) -(** Helpers to produce Parsetree fragments *) +(* Module [Outcometree]: results displayed by the toplevel *) -open Asttypes -open Docstrings -open Parsetree +(* These types represent messages that the toplevel displays as normal + results or errors. The real displaying is customisable using the hooks: + [Toploop.print_out_value] + [Toploop.print_out_type] + [Toploop.print_out_sig_item] + [Toploop.print_out_phrase] *) -type lid = Longident.t loc -type str = string loc -type loc = Location.t -type attrs = attribute list +type out_ident = + | Oide_apply of out_ident * out_ident + | Oide_dot of out_ident * string + | Oide_ident of string -(** {1 Default locations} *) +type out_string = + | Ostr_string + | Ostr_bytes -val default_loc: loc ref - (** Default value for all optional location arguments. *) +type out_attribute = + { oattr_name: string } -val with_default_loc: loc -> (unit -> 'a) -> 'a - (** Set the [default_loc] within the scope of the execution - of the provided function. *) +type out_value = + | Oval_array of out_value list + | Oval_char of char + | Oval_constr of out_ident * out_value list + | Oval_ellipsis + | Oval_float of float + | Oval_int of int + | Oval_int32 of int32 + | Oval_int64 of int64 + | Oval_nativeint of nativeint + | Oval_list of out_value list + | Oval_printer of (Format.formatter -> unit) + | Oval_record of (out_ident * out_value) list + | Oval_string of string * int * out_string (* string, size-to-print, kind *) + | Oval_stuff of string + | Oval_tuple of out_value list + | Oval_variant of string * out_value option -(** {1 Constants} *) +type out_type = + | Otyp_abstract + | Otyp_open + | Otyp_alias of out_type * string + | Otyp_arrow of string * out_type * out_type + | Otyp_class of bool * out_ident * out_type list + | Otyp_constr of out_ident * out_type list + | Otyp_manifest of out_type * out_type + | Otyp_object of (string * out_type) list * bool option + | Otyp_record of (string * bool * out_type) list + | Otyp_stuff of string + | Otyp_sum of (string * out_type list * out_type option) list + | Otyp_tuple of out_type list + | Otyp_var of bool * string + | Otyp_variant of + bool * out_variant * bool * (string list) option + | Otyp_poly of string list * out_type + | Otyp_module of string * string list * out_type list + | Otyp_attribute of out_type * out_attribute -module Const : sig - val char : char -> constant - val string : ?quotation_delimiter:string -> string -> constant - val integer : ?suffix:char -> string -> constant - val int : ?suffix:char -> int -> constant - val int32 : ?suffix:char -> int32 -> constant - val int64 : ?suffix:char -> int64 -> constant - val nativeint : ?suffix:char -> nativeint -> constant - val float : ?suffix:char -> string -> constant -end +and out_variant = + | Ovar_fields of (string * bool * out_type list) list + | Ovar_typ of out_type -(** {1 Core language} *) +type out_class_type = + | Octy_constr of out_ident * out_type list + | Octy_arrow of string * out_type * out_class_type + | Octy_signature of out_type option * out_class_sig_item list +and out_class_sig_item = + | Ocsg_constraint of out_type * out_type + | Ocsg_method of string * bool * bool * out_type + | Ocsg_value of string * bool * bool * out_type -(** Type expressions *) -module Typ : - sig - val mk: ?loc:loc -> ?attrs:attrs -> core_type_desc -> core_type - val attr: core_type -> attribute -> core_type +type out_module_type = + | Omty_abstract + | Omty_functor of string * out_module_type option * out_module_type + | Omty_ident of out_ident + | Omty_signature of out_sig_item list + | Omty_alias of out_ident +and out_sig_item = + | Osig_class of + bool * string * (string * (bool * bool)) list * out_class_type * + out_rec_status + | Osig_class_type of + bool * string * (string * (bool * bool)) list * out_class_type * + out_rec_status + | Osig_typext of out_extension_constructor * out_ext_status + | Osig_modtype of string * out_module_type + | Osig_module of string * out_module_type * out_rec_status + | Osig_type of out_type_decl * out_rec_status + | Osig_value of out_val_decl + | Osig_ellipsis +and out_type_decl = + { otype_name: string; + otype_params: (string * (bool * bool)) list; + otype_type: out_type; + otype_private: Asttypes.private_flag; + otype_immediate: bool; + otype_unboxed: bool; + otype_cstrs: (out_type * out_type) list } +and out_extension_constructor = + { oext_name: string; + oext_type_name: string; + oext_type_params: string list; + oext_args: out_type list; + oext_ret_type: out_type option; + oext_private: Asttypes.private_flag } +and out_type_extension = + { otyext_name: string; + otyext_params: string list; + otyext_constructors: (string * out_type list * out_type option) list; + otyext_private: Asttypes.private_flag } +and out_val_decl = + { oval_name: string; + oval_type: out_type; + oval_prims: string list; + oval_attributes: out_attribute list } +and out_rec_status = + | Orec_not + | Orec_first + | Orec_next +and out_ext_status = + | Oext_first + | Oext_next + | Oext_exception - val any: ?loc:loc -> ?attrs:attrs -> unit -> core_type - val var: ?loc:loc -> ?attrs:attrs -> string -> core_type - val arrow: ?loc:loc -> ?attrs:attrs -> arg_label -> core_type -> core_type - -> core_type - val tuple: ?loc:loc -> ?attrs:attrs -> core_type list -> core_type - val constr: ?loc:loc -> ?attrs:attrs -> lid -> core_type list -> core_type - val object_: ?loc:loc -> ?attrs:attrs -> object_field list - -> closed_flag -> core_type - val class_: ?loc:loc -> ?attrs:attrs -> lid -> core_type list -> core_type - val alias: ?loc:loc -> ?attrs:attrs -> core_type -> string -> core_type - val variant: ?loc:loc -> ?attrs:attrs -> row_field list -> closed_flag - -> label list option -> core_type - val poly: ?loc:loc -> ?attrs:attrs -> str list -> core_type -> core_type - val package: ?loc:loc -> ?attrs:attrs -> lid -> (lid * core_type) list - -> core_type - val extension: ?loc:loc -> ?attrs:attrs -> extension -> core_type +type out_phrase = + | Ophr_eval of out_value * out_type + | Ophr_signature of (out_sig_item * out_value option) list + | Ophr_exception of (exn * out_value) - val force_poly: core_type -> core_type +end +module Primitive : sig +#1 "primitive.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) - val varify_constructors: str list -> core_type -> core_type - (** [varify_constructors newtypes te] is type expression [te], of which - any of nullary type constructor [tc] is replaced by type variable of - the same name, if [tc]'s name appears in [newtypes]. - Raise [Syntaxerr.Variable_in_scope] if any type variable inside [te] - appears in [newtypes]. - @since 4.05 - *) - end +(* Description of primitive functions *) -(** Patterns *) -module Pat: - sig - val mk: ?loc:loc -> ?attrs:attrs -> pattern_desc -> pattern - val attr:pattern -> attribute -> pattern +type boxed_integer = Pnativeint | Pint32 | Pint64 - val any: ?loc:loc -> ?attrs:attrs -> unit -> pattern - val var: ?loc:loc -> ?attrs:attrs -> str -> pattern - val alias: ?loc:loc -> ?attrs:attrs -> pattern -> str -> pattern - val constant: ?loc:loc -> ?attrs:attrs -> constant -> pattern - val interval: ?loc:loc -> ?attrs:attrs -> constant -> constant -> pattern - val tuple: ?loc:loc -> ?attrs:attrs -> pattern list -> pattern - val construct: ?loc:loc -> ?attrs:attrs -> lid -> pattern option -> pattern - val variant: ?loc:loc -> ?attrs:attrs -> label -> pattern option -> pattern - val record: ?loc:loc -> ?attrs:attrs -> (lid * pattern) list -> closed_flag - -> pattern - val array: ?loc:loc -> ?attrs:attrs -> pattern list -> pattern - val or_: ?loc:loc -> ?attrs:attrs -> pattern -> pattern -> pattern - val constraint_: ?loc:loc -> ?attrs:attrs -> pattern -> core_type -> pattern - val type_: ?loc:loc -> ?attrs:attrs -> lid -> pattern - val lazy_: ?loc:loc -> ?attrs:attrs -> pattern -> pattern - val unpack: ?loc:loc -> ?attrs:attrs -> str -> pattern - val open_: ?loc:loc -> ?attrs:attrs -> lid -> pattern -> pattern - val exception_: ?loc:loc -> ?attrs:attrs -> pattern -> pattern - val extension: ?loc:loc -> ?attrs:attrs -> extension -> pattern - end +(* Representation of arguments/result for the native code version + of a primitive *) +type native_repr = + | Same_as_ocaml_repr + | Unboxed_float + | Unboxed_integer of boxed_integer + | Untagged_int -(** Expressions *) -module Exp: - sig - val mk: ?loc:loc -> ?attrs:attrs -> expression_desc -> expression - val attr: expression -> attribute -> expression +type description = private + { prim_name: string; (* Name of primitive or C function *) + prim_arity: int; (* Number of arguments *) + prim_alloc: bool; (* Does it allocates or raise? *) + prim_native_name: string; (* Name of C function for the nat. code gen. *) + prim_native_repr_args: native_repr list; + prim_native_repr_res: native_repr } - val ident: ?loc:loc -> ?attrs:attrs -> lid -> expression - val constant: ?loc:loc -> ?attrs:attrs -> constant -> expression - val let_: ?loc:loc -> ?attrs:attrs -> rec_flag -> value_binding list - -> expression -> expression - val fun_: ?loc:loc -> ?attrs:attrs -> arg_label -> expression option - -> pattern -> expression -> expression - val function_: ?loc:loc -> ?attrs:attrs -> case list -> expression - val apply: ?loc:loc -> ?attrs:attrs -> expression - -> (arg_label * expression) list -> expression - val match_: ?loc:loc -> ?attrs:attrs -> expression -> case list - -> expression - val try_: ?loc:loc -> ?attrs:attrs -> expression -> case list -> expression - val tuple: ?loc:loc -> ?attrs:attrs -> expression list -> expression - val construct: ?loc:loc -> ?attrs:attrs -> lid -> expression option - -> expression - val variant: ?loc:loc -> ?attrs:attrs -> label -> expression option - -> expression - val record: ?loc:loc -> ?attrs:attrs -> (lid * expression) list - -> expression option -> expression - val field: ?loc:loc -> ?attrs:attrs -> expression -> lid -> expression - val setfield: ?loc:loc -> ?attrs:attrs -> expression -> lid -> expression - -> expression - val array: ?loc:loc -> ?attrs:attrs -> expression list -> expression - val ifthenelse: ?loc:loc -> ?attrs:attrs -> expression -> expression - -> expression option -> expression - val sequence: ?loc:loc -> ?attrs:attrs -> expression -> expression - -> expression - val while_: ?loc:loc -> ?attrs:attrs -> expression -> expression - -> expression - val for_: ?loc:loc -> ?attrs:attrs -> pattern -> expression -> expression - -> direction_flag -> expression -> expression - val coerce: ?loc:loc -> ?attrs:attrs -> expression -> core_type option - -> core_type -> expression - val constraint_: ?loc:loc -> ?attrs:attrs -> expression -> core_type - -> expression - val send: ?loc:loc -> ?attrs:attrs -> expression -> str -> expression - val new_: ?loc:loc -> ?attrs:attrs -> lid -> expression - val setinstvar: ?loc:loc -> ?attrs:attrs -> str -> expression -> expression - val override: ?loc:loc -> ?attrs:attrs -> (str * expression) list - -> expression - val letmodule: ?loc:loc -> ?attrs:attrs -> str -> module_expr -> expression - -> expression - val letexception: - ?loc:loc -> ?attrs:attrs -> extension_constructor -> expression - -> expression - val assert_: ?loc:loc -> ?attrs:attrs -> expression -> expression - val lazy_: ?loc:loc -> ?attrs:attrs -> expression -> expression - val poly: ?loc:loc -> ?attrs:attrs -> expression -> core_type option - -> expression - val object_: ?loc:loc -> ?attrs:attrs -> class_structure -> expression - val newtype: ?loc:loc -> ?attrs:attrs -> str -> expression -> expression - val pack: ?loc:loc -> ?attrs:attrs -> module_expr -> expression - val open_: ?loc:loc -> ?attrs:attrs -> override_flag -> lid -> expression - -> expression - val extension: ?loc:loc -> ?attrs:attrs -> extension -> expression - val unreachable: ?loc:loc -> ?attrs:attrs -> unit -> expression +(* Invariant [List.length d.prim_native_repr_args = d.prim_arity] *) - val case: pattern -> ?guard:expression -> expression -> case - end +val simple + : name:string + -> arity:int + -> alloc:bool + -> description -(** Value declarations *) -module Val: - sig - val mk: ?loc:loc -> ?attrs:attrs -> ?docs:docs -> - ?prim:string list -> str -> core_type -> value_description - end +val make + : name:string + -> alloc:bool + -> native_name:string + -> native_repr_args: native_repr list + -> native_repr_res: native_repr + -> description -(** Type declarations *) -module Type: - sig - val mk: ?loc:loc -> ?attrs:attrs -> ?docs:docs -> ?text:text -> - ?params:(core_type * variance) list -> - ?cstrs:(core_type * core_type * loc) list -> - ?kind:type_kind -> ?priv:private_flag -> ?manifest:core_type -> str -> - type_declaration +val parse_declaration + : Parsetree.value_description + -> native_repr_args:native_repr list + -> native_repr_res:native_repr + -> description - val constructor: ?loc:loc -> ?attrs:attrs -> ?info:info -> - ?args:constructor_arguments -> ?res:core_type -> str -> - constructor_declaration - val field: ?loc:loc -> ?attrs:attrs -> ?info:info -> - ?mut:mutable_flag -> str -> core_type -> label_declaration - end +val print + : description + -> Outcometree.out_val_decl + -> Outcometree.out_val_decl -(** Type extensions *) -module Te: - sig - val mk: ?attrs:attrs -> ?docs:docs -> - ?params:(core_type * variance) list -> ?priv:private_flag -> - lid -> extension_constructor list -> type_extension +val native_name: description -> string +val byte_name: description -> string - val constructor: ?loc:loc -> ?attrs:attrs -> ?docs:docs -> ?info:info -> - str -> extension_constructor_kind -> extension_constructor +type error = + | Old_style_float_with_native_repr_attribute + | Old_style_noalloc_with_noalloc_attribute + | No_native_primitive_with_repr_attribute - val decl: ?loc:loc -> ?attrs:attrs -> ?docs:docs -> ?info:info -> - ?args:constructor_arguments -> ?res:core_type -> str -> - extension_constructor - val rebind: ?loc:loc -> ?attrs:attrs -> ?docs:docs -> ?info:info -> - str -> lid -> extension_constructor - end +exception Error of Location.t * error -(** {1 Module language} *) +end = struct +#1 "primitive.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -(** Module type expressions *) -module Mty: - sig - val mk: ?loc:loc -> ?attrs:attrs -> module_type_desc -> module_type - val attr: module_type -> attribute -> module_type +(* Description of primitive functions *) - val ident: ?loc:loc -> ?attrs:attrs -> lid -> module_type - val alias: ?loc:loc -> ?attrs:attrs -> lid -> module_type - val signature: ?loc:loc -> ?attrs:attrs -> signature -> module_type - val functor_: ?loc:loc -> ?attrs:attrs -> - str -> module_type option -> module_type -> module_type - val with_: ?loc:loc -> ?attrs:attrs -> module_type -> - with_constraint list -> module_type - val typeof_: ?loc:loc -> ?attrs:attrs -> module_expr -> module_type - val extension: ?loc:loc -> ?attrs:attrs -> extension -> module_type - end +open Misc +open Parsetree -(** Module expressions *) -module Mod: - sig - val mk: ?loc:loc -> ?attrs:attrs -> module_expr_desc -> module_expr - val attr: module_expr -> attribute -> module_expr +type boxed_integer = Pnativeint | Pint32 | Pint64 - val ident: ?loc:loc -> ?attrs:attrs -> lid -> module_expr - val structure: ?loc:loc -> ?attrs:attrs -> structure -> module_expr - val functor_: ?loc:loc -> ?attrs:attrs -> - str -> module_type option -> module_expr -> module_expr - val apply: ?loc:loc -> ?attrs:attrs -> module_expr -> module_expr -> - module_expr - val constraint_: ?loc:loc -> ?attrs:attrs -> module_expr -> module_type -> - module_expr - val unpack: ?loc:loc -> ?attrs:attrs -> expression -> module_expr - val extension: ?loc:loc -> ?attrs:attrs -> extension -> module_expr - end - -(** Signature items *) -module Sig: - sig - val mk: ?loc:loc -> signature_item_desc -> signature_item - - val value: ?loc:loc -> value_description -> signature_item - val type_: ?loc:loc -> rec_flag -> type_declaration list -> signature_item - val type_extension: ?loc:loc -> type_extension -> signature_item - val exception_: ?loc:loc -> extension_constructor -> signature_item - val module_: ?loc:loc -> module_declaration -> signature_item - val rec_module: ?loc:loc -> module_declaration list -> signature_item - val modtype: ?loc:loc -> module_type_declaration -> signature_item - val open_: ?loc:loc -> open_description -> signature_item - val include_: ?loc:loc -> include_description -> signature_item - val class_: ?loc:loc -> class_description list -> signature_item - val class_type: ?loc:loc -> class_type_declaration list -> signature_item - val extension: ?loc:loc -> ?attrs:attrs -> extension -> signature_item - val attribute: ?loc:loc -> attribute -> signature_item - val text: text -> signature_item list - end - -(** Structure items *) -module Str: - sig - val mk: ?loc:loc -> structure_item_desc -> structure_item - - val eval: ?loc:loc -> ?attrs:attributes -> expression -> structure_item - val value: ?loc:loc -> rec_flag -> value_binding list -> structure_item - val primitive: ?loc:loc -> value_description -> structure_item - val type_: ?loc:loc -> rec_flag -> type_declaration list -> structure_item - val type_extension: ?loc:loc -> type_extension -> structure_item - val exception_: ?loc:loc -> extension_constructor -> structure_item - val module_: ?loc:loc -> module_binding -> structure_item - val rec_module: ?loc:loc -> module_binding list -> structure_item - val modtype: ?loc:loc -> module_type_declaration -> structure_item - val open_: ?loc:loc -> open_description -> structure_item - val class_: ?loc:loc -> class_declaration list -> structure_item - val class_type: ?loc:loc -> class_type_declaration list -> structure_item - val include_: ?loc:loc -> include_declaration -> structure_item - val extension: ?loc:loc -> ?attrs:attrs -> extension -> structure_item - val attribute: ?loc:loc -> attribute -> structure_item - val text: text -> structure_item list - end - -(** Module declarations *) -module Md: - sig - val mk: ?loc:loc -> ?attrs:attrs -> ?docs:docs -> ?text:text -> - str -> module_type -> module_declaration - end - -(** Module type declarations *) -module Mtd: - sig - val mk: ?loc:loc -> ?attrs:attrs -> ?docs:docs -> ?text:text -> - ?typ:module_type -> str -> module_type_declaration - end - -(** Module bindings *) -module Mb: - sig - val mk: ?loc:loc -> ?attrs:attrs -> ?docs:docs -> ?text:text -> - str -> module_expr -> module_binding - end +type native_repr = + | Same_as_ocaml_repr + | Unboxed_float + | Unboxed_integer of boxed_integer + | Untagged_int -(** Opens *) -module Opn: - sig - val mk: ?loc: loc -> ?attrs:attrs -> ?docs:docs -> - ?override:override_flag -> lid -> open_description - end +type description = + { prim_name: string; (* Name of primitive or C function *) + prim_arity: int; (* Number of arguments *) + prim_alloc: bool; (* Does it allocates or raise? *) + prim_native_name: string; (* Name of C function for the nat. code gen. *) + prim_native_repr_args: native_repr list; + prim_native_repr_res: native_repr } -(** Includes *) -module Incl: - sig - val mk: ?loc: loc -> ?attrs:attrs -> ?docs:docs -> 'a -> 'a include_infos - end +type error = + | Old_style_float_with_native_repr_attribute + | Old_style_noalloc_with_noalloc_attribute + | No_native_primitive_with_repr_attribute -(** Value bindings *) -module Vb: - sig - val mk: ?loc: loc -> ?attrs:attrs -> ?docs:docs -> ?text:text -> - pattern -> expression -> value_binding - end +exception Error of Location.t * error +let is_ocaml_repr = function + | Same_as_ocaml_repr -> true + | Unboxed_float + | Unboxed_integer _ + | Untagged_int -> false -(** {1 Class language} *) +let is_unboxed = function + | Same_as_ocaml_repr + | Untagged_int -> false + | Unboxed_float + | Unboxed_integer _ -> true -(** Class type expressions *) -module Cty: - sig - val mk: ?loc:loc -> ?attrs:attrs -> class_type_desc -> class_type - val attr: class_type -> attribute -> class_type +let is_untagged = function + | Untagged_int -> true + | Same_as_ocaml_repr + | Unboxed_float + | Unboxed_integer _ -> false - val constr: ?loc:loc -> ?attrs:attrs -> lid -> core_type list -> class_type - val signature: ?loc:loc -> ?attrs:attrs -> class_signature -> class_type - val arrow: ?loc:loc -> ?attrs:attrs -> arg_label -> core_type -> - class_type -> class_type - val extension: ?loc:loc -> ?attrs:attrs -> extension -> class_type - val open_: ?loc:loc -> ?attrs:attrs -> override_flag -> lid -> class_type - -> class_type - end +let rec make_native_repr_args arity x = + if arity = 0 then + [] + else + x :: make_native_repr_args (arity - 1) x -(** Class type fields *) -module Ctf: - sig - val mk: ?loc:loc -> ?attrs:attrs -> ?docs:docs -> - class_type_field_desc -> class_type_field - val attr: class_type_field -> attribute -> class_type_field +let simple ~name ~arity ~alloc = + {prim_name = name; + prim_arity = arity; + prim_alloc = alloc; + prim_native_name = ""; + prim_native_repr_args = make_native_repr_args arity Same_as_ocaml_repr; + prim_native_repr_res = Same_as_ocaml_repr} - val inherit_: ?loc:loc -> ?attrs:attrs -> class_type -> class_type_field - val val_: ?loc:loc -> ?attrs:attrs -> str -> mutable_flag -> - virtual_flag -> core_type -> class_type_field - val method_: ?loc:loc -> ?attrs:attrs -> str -> private_flag -> - virtual_flag -> core_type -> class_type_field - val constraint_: ?loc:loc -> ?attrs:attrs -> core_type -> core_type -> - class_type_field - val extension: ?loc:loc -> ?attrs:attrs -> extension -> class_type_field - val attribute: ?loc:loc -> attribute -> class_type_field - val text: text -> class_type_field list - end +let make ~name ~alloc ~native_name ~native_repr_args ~native_repr_res = + {prim_name = name; + prim_arity = List.length native_repr_args; + prim_alloc = alloc; + prim_native_name = native_name; + prim_native_repr_args = native_repr_args; + prim_native_repr_res = native_repr_res} -(** Class expressions *) -module Cl: - sig - val mk: ?loc:loc -> ?attrs:attrs -> class_expr_desc -> class_expr - val attr: class_expr -> attribute -> class_expr +let parse_declaration valdecl ~native_repr_args ~native_repr_res = + let arity = List.length native_repr_args in + let name, native_name, old_style_noalloc, old_style_float = + match valdecl.pval_prim with + | name :: "noalloc" :: name2 :: "float" :: _ -> (name, name2, true, true) + | name :: "noalloc" :: name2 :: _ -> (name, name2, true, false) + | name :: name2 :: "float" :: _ -> (name, name2, false, true) + | name :: "noalloc" :: _ -> (name, "", true, false) + | name :: name2 :: _ -> (name, name2, false, false) + | name :: _ -> (name, "", false, false) + | [] -> + fatal_error "Primitive.parse_declaration" + in + let noalloc_attribute = + Attr_helper.has_no_payload_attribute ["noalloc"; "ocaml.noalloc"] + valdecl.pval_attributes + in + if old_style_float && + not (List.for_all is_ocaml_repr native_repr_args && + is_ocaml_repr native_repr_res) then + raise (Error (valdecl.pval_loc, + Old_style_float_with_native_repr_attribute)); + if old_style_noalloc && noalloc_attribute then + raise (Error (valdecl.pval_loc, + Old_style_noalloc_with_noalloc_attribute)); + (* The compiler used to assume "noalloc" with "float", we just make this + explicit now (GPR#167): *) + let old_style_noalloc = old_style_noalloc || old_style_float in + if old_style_float then + Location.deprecated valdecl.pval_loc + "[@@unboxed] + [@@noalloc] should be used instead of \"float\"" + else if old_style_noalloc then + Location.deprecated valdecl.pval_loc + "[@@noalloc] should be used instead of \"noalloc\""; + if native_name = "" && + not (List.for_all is_ocaml_repr native_repr_args && + is_ocaml_repr native_repr_res) then + raise (Error (valdecl.pval_loc, + No_native_primitive_with_repr_attribute)); + let noalloc = old_style_noalloc || noalloc_attribute in + let native_repr_args, native_repr_res = + if old_style_float then + (make_native_repr_args arity Unboxed_float, Unboxed_float) + else + (native_repr_args, native_repr_res) + in + {prim_name = name; + prim_arity = arity; + prim_alloc = not noalloc; + prim_native_name = native_name; + prim_native_repr_args = native_repr_args; + prim_native_repr_res = native_repr_res} - val constr: ?loc:loc -> ?attrs:attrs -> lid -> core_type list -> class_expr - val structure: ?loc:loc -> ?attrs:attrs -> class_structure -> class_expr - val fun_: ?loc:loc -> ?attrs:attrs -> arg_label -> expression option -> - pattern -> class_expr -> class_expr - val apply: ?loc:loc -> ?attrs:attrs -> class_expr -> - (arg_label * expression) list -> class_expr - val let_: ?loc:loc -> ?attrs:attrs -> rec_flag -> value_binding list -> - class_expr -> class_expr - val constraint_: ?loc:loc -> ?attrs:attrs -> class_expr -> class_type -> - class_expr - val extension: ?loc:loc -> ?attrs:attrs -> extension -> class_expr - val open_: ?loc:loc -> ?attrs:attrs -> override_flag -> lid -> class_expr - -> class_expr - end +open Outcometree -(** Class fields *) -module Cf: - sig - val mk: ?loc:loc -> ?attrs:attrs -> ?docs:docs -> class_field_desc -> - class_field - val attr: class_field -> attribute -> class_field +let rec add_native_repr_attributes ty attrs = + match ty, attrs with + | Otyp_arrow (label, a, b), attr_opt :: rest -> + let b = add_native_repr_attributes b rest in + let a = + match attr_opt with + | None -> a + | Some attr -> Otyp_attribute (a, attr) + in + Otyp_arrow (label, a, b) + | _, [Some attr] -> Otyp_attribute (ty, attr) + | _ -> + assert (List.for_all (fun x -> x = None) attrs); + ty - val inherit_: ?loc:loc -> ?attrs:attrs -> override_flag -> class_expr -> - str option -> class_field - val val_: ?loc:loc -> ?attrs:attrs -> str -> mutable_flag -> - class_field_kind -> class_field - val method_: ?loc:loc -> ?attrs:attrs -> str -> private_flag -> - class_field_kind -> class_field - val constraint_: ?loc:loc -> ?attrs:attrs -> core_type -> core_type -> - class_field - val initializer_: ?loc:loc -> ?attrs:attrs -> expression -> class_field - val extension: ?loc:loc -> ?attrs:attrs -> extension -> class_field - val attribute: ?loc:loc -> attribute -> class_field - val text: text -> class_field list +let oattr_unboxed = { oattr_name = "unboxed" } +let oattr_untagged = { oattr_name = "untagged" } +let oattr_noalloc = { oattr_name = "noalloc" } - val virtual_: core_type -> class_field_kind - val concrete: override_flag -> expression -> class_field_kind +let print p osig_val_decl = + let prims = + if p.prim_native_name <> "" then + [p.prim_name; p.prim_native_name] + else + [p.prim_name] + in + let for_all f = + List.for_all f p.prim_native_repr_args && f p.prim_native_repr_res + in + let all_unboxed = for_all is_unboxed in + let all_untagged = for_all is_untagged in + let attrs = if p.prim_alloc then [] else [oattr_noalloc] in + let attrs = + if all_unboxed then + oattr_unboxed :: attrs + else if all_untagged then + oattr_untagged :: attrs + else + attrs + in + let attr_of_native_repr = function + | Same_as_ocaml_repr -> None + | Unboxed_float + | Unboxed_integer _ -> if all_unboxed then None else Some oattr_unboxed + | Untagged_int -> if all_untagged then None else Some oattr_untagged + in + let type_attrs = + List.map attr_of_native_repr p.prim_native_repr_args @ + [attr_of_native_repr p.prim_native_repr_res] + in + { osig_val_decl with + oval_prims = prims; + oval_type = add_native_repr_attributes osig_val_decl.oval_type type_attrs; + oval_attributes = attrs } - end +let native_name p = + if p.prim_native_name <> "" + then p.prim_native_name + else p.prim_name -(** Classes *) -module Ci: - sig - val mk: ?loc:loc -> ?attrs:attrs -> ?docs:docs -> ?text:text -> - ?virt:virtual_flag -> ?params:(core_type * variance) list -> - str -> 'a -> 'a class_infos - end +let byte_name p = + p.prim_name -(** Class signatures *) -module Csig: - sig - val mk: core_type -> class_type_field list -> class_signature - end +let report_error ppf err = + match err with + | Old_style_float_with_native_repr_attribute -> + Format.fprintf ppf "Cannot use \"float\" in conjunction with \ + [%@unboxed]/[%@untagged]" + | Old_style_noalloc_with_noalloc_attribute -> + Format.fprintf ppf "Cannot use \"noalloc\" in conjunction with \ + [%@%@noalloc]" + | No_native_primitive_with_repr_attribute -> + Format.fprintf ppf + "The native code version of the primitive is mandatory when \ + attributes [%@untagged] or [%@unboxed] are present" -(** Class structures *) -module Cstr: - sig - val mk: pattern -> class_field list -> class_structure - end +let () = + Location.register_error_of_exn + (function + | Error (loc, err) -> + Some (Location.error_of_printer loc report_error err) + | _ -> + None + ) -end = struct -#1 "ast_helper.ml" +end +module Types : sig +#1 "types.mli" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Alain Frisch, LexiFi *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) (* *) -(* Copyright 2012 Institut National de Recherche en Informatique et *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -9575,17645 +9834,1813 @@ end = struct (* *) (**************************************************************************) -(** Helpers to produce Parsetree fragments *) +(** {0 Representation of types and declarations} *) +(** [Types] defines the representation of types and declarations (that is, the + content of module signatures). + + CMI files are made of marshalled types. +*) + +(** Asttypes exposes basic definitions shared both by Parsetree and Types. *) open Asttypes -open Parsetree -open Docstrings -type lid = Longident.t loc -type str = string loc -type loc = Location.t -type attrs = attribute list +(** Type expressions for the core language. -let default_loc = ref Location.none + The [type_desc] variant defines all the possible type expressions one can + find in OCaml. [type_expr] wraps this with some annotations. -let with_default_loc l f = - let old = !default_loc in - default_loc := l; - try let r = f () in default_loc := old; r - with exn -> default_loc := old; raise exn + The [level] field tracks the level of polymorphism associated to a type, + guiding the generalization algorithm. + Put shortly, when referring to a type in a given environment, both the type + and the environment have a level. If the type has an higher level, then it + can be considered fully polymorphic (type variables will be printed as + ['a]), otherwise it'll be weakly polymorphic, or non generalized (type + variables printed as ['_a]). + See [http://okmij.org/ftp/ML/generalization.html] for more information. -module Const = struct - let integer ?suffix i = Pconst_integer (i, suffix) - let int ?suffix i = integer ?suffix (string_of_int i) - let int32 ?(suffix='l') i = integer ~suffix (Int32.to_string i) - let int64 ?(suffix='L') i = integer ~suffix (Int64.to_string i) - let nativeint ?(suffix='n') i = integer ~suffix (Nativeint.to_string i) - let float ?suffix f = Pconst_float (f, suffix) - let char c = Pconst_char c - let string ?quotation_delimiter s = Pconst_string (s, quotation_delimiter) -end + Note about [type_declaration]: one should not make the confusion between + [type_expr] and [type_declaration]. -module Typ = struct - let mk ?(loc = !default_loc) ?(attrs = []) d = - {ptyp_desc = d; ptyp_loc = loc; ptyp_attributes = attrs} - let attr d a = {d with ptyp_attributes = d.ptyp_attributes @ [a]} + [type_declaration] refers specifically to the [type] construct in OCaml + language, where you create and name a new type or type alias. - let any ?loc ?attrs () = mk ?loc ?attrs Ptyp_any - let var ?loc ?attrs a = mk ?loc ?attrs (Ptyp_var a) - let arrow ?loc ?attrs a b c = mk ?loc ?attrs (Ptyp_arrow (a, b, c)) - let tuple ?loc ?attrs a = mk ?loc ?attrs (Ptyp_tuple a) - let constr ?loc ?attrs a b = mk ?loc ?attrs (Ptyp_constr (a, b)) - let object_ ?loc ?attrs a b = mk ?loc ?attrs (Ptyp_object (a, b)) - let class_ ?loc ?attrs a b = mk ?loc ?attrs (Ptyp_class (a, b)) - let alias ?loc ?attrs a b = mk ?loc ?attrs (Ptyp_alias (a, b)) - let variant ?loc ?attrs a b c = mk ?loc ?attrs (Ptyp_variant (a, b, c)) - let poly ?loc ?attrs a b = mk ?loc ?attrs (Ptyp_poly (a, b)) - let package ?loc ?attrs a b = mk ?loc ?attrs (Ptyp_package (a, b)) - let extension ?loc ?attrs a = mk ?loc ?attrs (Ptyp_extension a) + [type_expr] is used when you refer to existing types, e.g. when annotating + the expected type of a value. - let force_poly t = - match t.ptyp_desc with - | Ptyp_poly _ -> t - | _ -> poly ~loc:t.ptyp_loc [] t (* -> ghost? *) + Also, as the type system of OCaml is generative, a [type_declaration] can + have the side-effect of introducing a new type constructor, different from + all other known types. + Whereas [type_expr] is a pure construct which allows referring to existing + types. - let varify_constructors var_names t = - let check_variable vl loc v = - if List.mem v vl then - raise Syntaxerr.(Error(Variable_in_scope(loc,v))) in - let var_names = List.map (fun v -> v.txt) var_names in - let rec loop t = - let desc = - match t.ptyp_desc with - | Ptyp_any -> Ptyp_any - | Ptyp_var x -> - check_variable var_names t.ptyp_loc x; - Ptyp_var x - | Ptyp_arrow (label,core_type,core_type') -> - Ptyp_arrow(label, loop core_type, loop core_type') - | Ptyp_tuple lst -> Ptyp_tuple (List.map loop lst) - | Ptyp_constr( { txt = Longident.Lident s }, []) - when List.mem s var_names -> - Ptyp_var s - | Ptyp_constr(longident, lst) -> - Ptyp_constr(longident, List.map loop lst) - | Ptyp_object (lst, o) -> - Ptyp_object (List.map loop_object_field lst, o) - | Ptyp_class (longident, lst) -> - Ptyp_class (longident, List.map loop lst) - | Ptyp_alias(core_type, string) -> - check_variable var_names t.ptyp_loc string; - Ptyp_alias(loop core_type, string) - | Ptyp_variant(row_field_list, flag, lbl_lst_option) -> - Ptyp_variant(List.map loop_row_field row_field_list, - flag, lbl_lst_option) - | Ptyp_poly(string_lst, core_type) -> - List.iter (fun v -> - check_variable var_names t.ptyp_loc v.txt) string_lst; - Ptyp_poly(string_lst, loop core_type) - | Ptyp_package(longident,lst) -> - Ptyp_package(longident,List.map (fun (n,typ) -> (n,loop typ) ) lst) - | Ptyp_extension (s, arg) -> - Ptyp_extension (s, arg) - in - {t with ptyp_desc = desc} - and loop_row_field = - function - | Rtag(label,attrs,flag,lst) -> - Rtag(label,attrs,flag,List.map loop lst) - | Rinherit t -> - Rinherit (loop t) - and loop_object_field = - function - | Otag(label, attrs, t) -> - Otag(label, attrs, loop t) - | Oinherit t -> - Oinherit (loop t) - in - loop t + Note on mutability: TBD. + *) +type type_expr = + { mutable desc: type_desc; + mutable level: int; + id: int } -end +and type_desc = + | Tvar of string option + (** [Tvar (Some "a")] ==> ['a] or ['_a] + [Tvar None] ==> [_] *) -module Pat = struct - let mk ?(loc = !default_loc) ?(attrs = []) d = - {ppat_desc = d; ppat_loc = loc; ppat_attributes = attrs} - let attr d a = {d with ppat_attributes = d.ppat_attributes @ [a]} + | Tarrow of arg_label * type_expr * type_expr * commutable + (** [Tarrow (Nolabel, e1, e2, c)] ==> [e1 -> e2] + [Tarrow (Labelled "l", e1, e2, c)] ==> [l:e1 -> e2] + [Tarrow (Optional "l", e1, e2, c)] ==> [?l:e1 -> e2] - let any ?loc ?attrs () = mk ?loc ?attrs Ppat_any - let var ?loc ?attrs a = mk ?loc ?attrs (Ppat_var a) - let alias ?loc ?attrs a b = mk ?loc ?attrs (Ppat_alias (a, b)) - let constant ?loc ?attrs a = mk ?loc ?attrs (Ppat_constant a) - let interval ?loc ?attrs a b = mk ?loc ?attrs (Ppat_interval (a, b)) - let tuple ?loc ?attrs a = mk ?loc ?attrs (Ppat_tuple a) - let construct ?loc ?attrs a b = mk ?loc ?attrs (Ppat_construct (a, b)) - let variant ?loc ?attrs a b = mk ?loc ?attrs (Ppat_variant (a, b)) - let record ?loc ?attrs a b = mk ?loc ?attrs (Ppat_record (a, b)) - let array ?loc ?attrs a = mk ?loc ?attrs (Ppat_array a) - let or_ ?loc ?attrs a b = mk ?loc ?attrs (Ppat_or (a, b)) - let constraint_ ?loc ?attrs a b = mk ?loc ?attrs (Ppat_constraint (a, b)) - let type_ ?loc ?attrs a = mk ?loc ?attrs (Ppat_type a) - let lazy_ ?loc ?attrs a = mk ?loc ?attrs (Ppat_lazy a) - let unpack ?loc ?attrs a = mk ?loc ?attrs (Ppat_unpack a) - let open_ ?loc ?attrs a b = mk ?loc ?attrs (Ppat_open (a, b)) - let exception_ ?loc ?attrs a = mk ?loc ?attrs (Ppat_exception a) - let extension ?loc ?attrs a = mk ?loc ?attrs (Ppat_extension a) -end + See [commutable] for the last argument. *) -module Exp = struct - let mk ?(loc = !default_loc) ?(attrs = []) d = - {pexp_desc = d; pexp_loc = loc; pexp_attributes = attrs} - let attr d a = {d with pexp_attributes = d.pexp_attributes @ [a]} + | Ttuple of type_expr list + (** [Ttuple [t1;...;tn]] ==> [(t1 * ... * tn)] *) - let ident ?loc ?attrs a = mk ?loc ?attrs (Pexp_ident a) - let constant ?loc ?attrs a = mk ?loc ?attrs (Pexp_constant a) - let let_ ?loc ?attrs a b c = mk ?loc ?attrs (Pexp_let (a, b, c)) - let fun_ ?loc ?attrs a b c d = mk ?loc ?attrs (Pexp_fun (a, b, c, d)) - let function_ ?loc ?attrs a = mk ?loc ?attrs (Pexp_function a) - let apply ?loc ?attrs a b = mk ?loc ?attrs (Pexp_apply (a, b)) - let match_ ?loc ?attrs a b = mk ?loc ?attrs (Pexp_match (a, b)) - let try_ ?loc ?attrs a b = mk ?loc ?attrs (Pexp_try (a, b)) - let tuple ?loc ?attrs a = mk ?loc ?attrs (Pexp_tuple a) - let construct ?loc ?attrs a b = mk ?loc ?attrs (Pexp_construct (a, b)) - let variant ?loc ?attrs a b = mk ?loc ?attrs (Pexp_variant (a, b)) - let record ?loc ?attrs a b = mk ?loc ?attrs (Pexp_record (a, b)) - let field ?loc ?attrs a b = mk ?loc ?attrs (Pexp_field (a, b)) - let setfield ?loc ?attrs a b c = mk ?loc ?attrs (Pexp_setfield (a, b, c)) - let array ?loc ?attrs a = mk ?loc ?attrs (Pexp_array a) - let ifthenelse ?loc ?attrs a b c = mk ?loc ?attrs (Pexp_ifthenelse (a, b, c)) - let sequence ?loc ?attrs a b = mk ?loc ?attrs (Pexp_sequence (a, b)) - let while_ ?loc ?attrs a b = mk ?loc ?attrs (Pexp_while (a, b)) - let for_ ?loc ?attrs a b c d e = mk ?loc ?attrs (Pexp_for (a, b, c, d, e)) - let constraint_ ?loc ?attrs a b = mk ?loc ?attrs (Pexp_constraint (a, b)) - let coerce ?loc ?attrs a b c = mk ?loc ?attrs (Pexp_coerce (a, b, c)) - let send ?loc ?attrs a b = mk ?loc ?attrs (Pexp_send (a, b)) - let new_ ?loc ?attrs a = mk ?loc ?attrs (Pexp_new a) - let setinstvar ?loc ?attrs a b = mk ?loc ?attrs (Pexp_setinstvar (a, b)) - let override ?loc ?attrs a = mk ?loc ?attrs (Pexp_override a) - let letmodule ?loc ?attrs a b c= mk ?loc ?attrs (Pexp_letmodule (a, b, c)) - let letexception ?loc ?attrs a b = mk ?loc ?attrs (Pexp_letexception (a, b)) - let assert_ ?loc ?attrs a = mk ?loc ?attrs (Pexp_assert a) - let lazy_ ?loc ?attrs a = mk ?loc ?attrs (Pexp_lazy a) - let poly ?loc ?attrs a b = mk ?loc ?attrs (Pexp_poly (a, b)) - let object_ ?loc ?attrs a = mk ?loc ?attrs (Pexp_object a) - let newtype ?loc ?attrs a b = mk ?loc ?attrs (Pexp_newtype (a, b)) - let pack ?loc ?attrs a = mk ?loc ?attrs (Pexp_pack a) - let open_ ?loc ?attrs a b c = mk ?loc ?attrs (Pexp_open (a, b, c)) - let extension ?loc ?attrs a = mk ?loc ?attrs (Pexp_extension a) - let unreachable ?loc ?attrs () = mk ?loc ?attrs Pexp_unreachable + | Tconstr of Path.t * type_expr list * abbrev_memo ref + (** [Tconstr (`A.B.t', [t1;...;tn], _)] ==> [(t1,...,tn) A.B.t] + The last parameter keep tracks of known expansions, see [abbrev_memo]. *) - let case lhs ?guard rhs = - { - pc_lhs = lhs; - pc_guard = guard; - pc_rhs = rhs; - } -end + | Tobject of type_expr * (Path.t * type_expr list) option ref + (** [Tobject (`f1:t1;...;fn: tn', `None')] ==> [< f1: t1; ...; fn: tn >] + f1, fn are represented as a linked list of types using Tfield and Tnil + constructors. -module Mty = struct - let mk ?(loc = !default_loc) ?(attrs = []) d = - {pmty_desc = d; pmty_loc = loc; pmty_attributes = attrs} - let attr d a = {d with pmty_attributes = d.pmty_attributes @ [a]} + [Tobject (_, `Some (`A.ct', [t1;...;tn]')] ==> [(t1, ..., tn) A.ct]. + where A.ct is the type of some class. - let ident ?loc ?attrs a = mk ?loc ?attrs (Pmty_ident a) - let alias ?loc ?attrs a = mk ?loc ?attrs (Pmty_alias a) - let signature ?loc ?attrs a = mk ?loc ?attrs (Pmty_signature a) - let functor_ ?loc ?attrs a b c = mk ?loc ?attrs (Pmty_functor (a, b, c)) - let with_ ?loc ?attrs a b = mk ?loc ?attrs (Pmty_with (a, b)) - let typeof_ ?loc ?attrs a = mk ?loc ?attrs (Pmty_typeof a) - let extension ?loc ?attrs a = mk ?loc ?attrs (Pmty_extension a) -end + There are also special cases for so-called "class-types", cf. [Typeclass] + and [Ctype.set_object_name]: -module Mod = struct -let mk ?(loc = !default_loc) ?(attrs = []) d = - {pmod_desc = d; pmod_loc = loc; pmod_attributes = attrs} - let attr d a = {d with pmod_attributes = d.pmod_attributes @ [a]} + [Tobject (Tfield(_,_,...(Tfield(_,_,rv)...), + Some(`A.#ct`, [rv;t1;...;tn])] + ==> [(t1, ..., tn) #A.ct] + [Tobject (_, Some(`A.#ct`, [Tnil;t1;...;tn])] ==> [(t1, ..., tn) A.ct] - let ident ?loc ?attrs x = mk ?loc ?attrs (Pmod_ident x) - let structure ?loc ?attrs x = mk ?loc ?attrs (Pmod_structure x) - let functor_ ?loc ?attrs arg arg_ty body = - mk ?loc ?attrs (Pmod_functor (arg, arg_ty, body)) - let apply ?loc ?attrs m1 m2 = mk ?loc ?attrs (Pmod_apply (m1, m2)) - let constraint_ ?loc ?attrs m mty = mk ?loc ?attrs (Pmod_constraint (m, mty)) - let unpack ?loc ?attrs e = mk ?loc ?attrs (Pmod_unpack e) - let extension ?loc ?attrs a = mk ?loc ?attrs (Pmod_extension a) -end + where [rv] is the hidden row variable. + *) -module Sig = struct - let mk ?(loc = !default_loc) d = {psig_desc = d; psig_loc = loc} + | Tfield of string * field_kind * type_expr * type_expr + (** [Tfield ("foo", Fpresent, t, ts)] ==> [<...; foo : t; ts>] *) - let value ?loc a = mk ?loc (Psig_value a) - let type_ ?loc rec_flag a = mk ?loc (Psig_type (rec_flag, a)) - let type_extension ?loc a = mk ?loc (Psig_typext a) - let exception_ ?loc a = mk ?loc (Psig_exception a) - let module_ ?loc a = mk ?loc (Psig_module a) - let rec_module ?loc a = mk ?loc (Psig_recmodule a) - let modtype ?loc a = mk ?loc (Psig_modtype a) - let open_ ?loc a = mk ?loc (Psig_open a) - let include_ ?loc a = mk ?loc (Psig_include a) - let class_ ?loc a = mk ?loc (Psig_class a) - let class_type ?loc a = mk ?loc (Psig_class_type a) - let extension ?loc ?(attrs = []) a = mk ?loc (Psig_extension (a, attrs)) - let attribute ?loc a = mk ?loc (Psig_attribute a) - let text txt = - let f_txt = List.filter (fun ds -> docstring_body ds <> "") txt in - List.map - (fun ds -> attribute ~loc:(docstring_loc ds) (text_attr ds)) - f_txt -end + | Tnil + (** [Tnil] ==> [<...; >] *) -module Str = struct - let mk ?(loc = !default_loc) d = {pstr_desc = d; pstr_loc = loc} + | Tlink of type_expr + (** Indirection used by unification engine. *) - let eval ?loc ?(attrs = []) a = mk ?loc (Pstr_eval (a, attrs)) - let value ?loc a b = mk ?loc (Pstr_value (a, b)) - let primitive ?loc a = mk ?loc (Pstr_primitive a) - let type_ ?loc rec_flag a = mk ?loc (Pstr_type (rec_flag, a)) - let type_extension ?loc a = mk ?loc (Pstr_typext a) - let exception_ ?loc a = mk ?loc (Pstr_exception a) - let module_ ?loc a = mk ?loc (Pstr_module a) - let rec_module ?loc a = mk ?loc (Pstr_recmodule a) - let modtype ?loc a = mk ?loc (Pstr_modtype a) - let open_ ?loc a = mk ?loc (Pstr_open a) - let class_ ?loc a = mk ?loc (Pstr_class a) - let class_type ?loc a = mk ?loc (Pstr_class_type a) - let include_ ?loc a = mk ?loc (Pstr_include a) - let extension ?loc ?(attrs = []) a = mk ?loc (Pstr_extension (a, attrs)) - let attribute ?loc a = mk ?loc (Pstr_attribute a) - let text txt = - let f_txt = List.filter (fun ds -> docstring_body ds <> "") txt in - List.map - (fun ds -> attribute ~loc:(docstring_loc ds) (text_attr ds)) - f_txt -end + | Tsubst of type_expr (* for copying *) + (** [Tsubst] is used temporarily to store information in low-level + functions manipulating representation of types, such as + instantiation or copy. + This constructor should not appear outside of these cases. *) -module Cl = struct - let mk ?(loc = !default_loc) ?(attrs = []) d = - { - pcl_desc = d; - pcl_loc = loc; - pcl_attributes = attrs; - } - let attr d a = {d with pcl_attributes = d.pcl_attributes @ [a]} + | Tvariant of row_desc + (** Representation of polymorphic variants, see [row_desc]. *) - let constr ?loc ?attrs a b = mk ?loc ?attrs (Pcl_constr (a, b)) - let structure ?loc ?attrs a = mk ?loc ?attrs (Pcl_structure a) - let fun_ ?loc ?attrs a b c d = mk ?loc ?attrs (Pcl_fun (a, b, c, d)) - let apply ?loc ?attrs a b = mk ?loc ?attrs (Pcl_apply (a, b)) - let let_ ?loc ?attrs a b c = mk ?loc ?attrs (Pcl_let (a, b, c)) - let constraint_ ?loc ?attrs a b = mk ?loc ?attrs (Pcl_constraint (a, b)) - let extension ?loc ?attrs a = mk ?loc ?attrs (Pcl_extension a) - let open_ ?loc ?attrs a b c = mk ?loc ?attrs (Pcl_open (a, b, c)) -end + | Tunivar of string option + (** Occurrence of a type variable introduced by a + forall quantifier / [Tpoly]. *) -module Cty = struct - let mk ?(loc = !default_loc) ?(attrs = []) d = - { - pcty_desc = d; - pcty_loc = loc; - pcty_attributes = attrs; - } - let attr d a = {d with pcty_attributes = d.pcty_attributes @ [a]} + | Tpoly of type_expr * type_expr list + (** [Tpoly (ty,tyl)] ==> ['a1... 'an. ty], + where 'a1 ... 'an are names given to types in tyl + and occurrences of those types in ty. *) - let constr ?loc ?attrs a b = mk ?loc ?attrs (Pcty_constr (a, b)) - let signature ?loc ?attrs a = mk ?loc ?attrs (Pcty_signature a) - let arrow ?loc ?attrs a b c = mk ?loc ?attrs (Pcty_arrow (a, b, c)) - let extension ?loc ?attrs a = mk ?loc ?attrs (Pcty_extension a) - let open_ ?loc ?attrs a b c = mk ?loc ?attrs (Pcty_open (a, b, c)) -end + | Tpackage of Path.t * Longident.t list * type_expr list + (** Type of a first-class module (a.k.a package). *) -module Ctf = struct - let mk ?(loc = !default_loc) ?(attrs = []) - ?(docs = empty_docs) d = - { - pctf_desc = d; - pctf_loc = loc; - pctf_attributes = add_docs_attrs docs attrs; - } +(** [ `X | `Y ] (row_closed = true) + [< `X | `Y ] (row_closed = true) + [> `X | `Y ] (row_closed = false) + [< `X | `Y > `X ] (row_closed = true) - let inherit_ ?loc ?attrs a = mk ?loc ?attrs (Pctf_inherit a) - let val_ ?loc ?attrs a b c d = mk ?loc ?attrs (Pctf_val (a, b, c, d)) - let method_ ?loc ?attrs a b c d = mk ?loc ?attrs (Pctf_method (a, b, c, d)) - let constraint_ ?loc ?attrs a b = mk ?loc ?attrs (Pctf_constraint (a, b)) - let extension ?loc ?attrs a = mk ?loc ?attrs (Pctf_extension a) - let attribute ?loc a = mk ?loc (Pctf_attribute a) - let text txt = - let f_txt = List.filter (fun ds -> docstring_body ds <> "") txt in - List.map - (fun ds -> attribute ~loc:(docstring_loc ds) (text_attr ds)) - f_txt + type t = [> `X ] as 'a (row_more = Tvar a) + type t = private [> `X ] (row_more = Tconstr (t#row, [], ref Mnil) - let attr d a = {d with pctf_attributes = d.pctf_attributes @ [a]} + And for: -end + let f = function `X -> `X -> | `Y -> `X -module Cf = struct - let mk ?(loc = !default_loc) ?(attrs = []) - ?(docs = empty_docs) d = - { - pcf_desc = d; - pcf_loc = loc; - pcf_attributes = add_docs_attrs docs attrs; - } + the type of "f" will be a [Tarrow] whose lhs will (basically) be: - let inherit_ ?loc ?attrs a b c = mk ?loc ?attrs (Pcf_inherit (a, b, c)) - let val_ ?loc ?attrs a b c = mk ?loc ?attrs (Pcf_val (a, b, c)) - let method_ ?loc ?attrs a b c = mk ?loc ?attrs (Pcf_method (a, b, c)) - let constraint_ ?loc ?attrs a b = mk ?loc ?attrs (Pcf_constraint (a, b)) - let initializer_ ?loc ?attrs a = mk ?loc ?attrs (Pcf_initializer a) - let extension ?loc ?attrs a = mk ?loc ?attrs (Pcf_extension a) - let attribute ?loc a = mk ?loc (Pcf_attribute a) - let text txt = - let f_txt = List.filter (fun ds -> docstring_body ds <> "") txt in - List.map - (fun ds -> attribute ~loc:(docstring_loc ds) (text_attr ds)) - f_txt + Tvariant { row_fields = [("X", _)]; + row_more = + Tvariant { row_fields = [("Y", _)]; + row_more = + Tvariant { row_fields = []; + row_more = _; + _ }; + _ }; + _ + } - let virtual_ ct = Cfk_virtual ct - let concrete o e = Cfk_concrete (o, e) +*) +and row_desc = + { row_fields: (label * row_field) list; + row_more: type_expr; + row_bound: unit; (* kept for compatibility *) + row_closed: bool; + row_fixed: bool; + row_name: (Path.t * type_expr list) option } - let attr d a = {d with pcf_attributes = d.pcf_attributes @ [a]} +and row_field = + Rpresent of type_expr option + | Reither of bool * type_expr list * bool * row_field option ref + (* 1st true denotes a constant constructor *) + (* 2nd true denotes a tag in a pattern matching, and + is erased later *) + | Rabsent -end +(** [abbrev_memo] allows one to keep track of different expansions of a type + alias. This is done for performance purposes. -module Val = struct - let mk ?(loc = !default_loc) ?(attrs = []) ?(docs = empty_docs) - ?(prim = []) name typ = - { - pval_name = name; - pval_type = typ; - pval_attributes = add_docs_attrs docs attrs; - pval_loc = loc; - pval_prim = prim; - } -end + For instance, when defining [type 'a pair = 'a * 'a], when one refers to an + ['a pair], it is just a shortcut for the ['a * 'a] type. + This expansion will be stored in the [abbrev_memo] of the corresponding + [Tconstr] node. -module Md = struct - let mk ?(loc = !default_loc) ?(attrs = []) - ?(docs = empty_docs) ?(text = []) name typ = - { - pmd_name = name; - pmd_type = typ; - pmd_attributes = - add_text_attrs text (add_docs_attrs docs attrs); - pmd_loc = loc; - } -end + In practice, [abbrev_memo] behaves like list of expansions with a mutable + tail. -module Mtd = struct - let mk ?(loc = !default_loc) ?(attrs = []) - ?(docs = empty_docs) ?(text = []) ?typ name = - { - pmtd_name = name; - pmtd_type = typ; - pmtd_attributes = - add_text_attrs text (add_docs_attrs docs attrs); - pmtd_loc = loc; - } -end + Note on marshalling: [abbrev_memo] must not appear in saved types. + [Btype], with [cleanup_abbrev] and [memo], takes care of tracking and + removing abbreviations. +*) +and abbrev_memo = + | Mnil (** No known abbreviation *) -module Mb = struct - let mk ?(loc = !default_loc) ?(attrs = []) - ?(docs = empty_docs) ?(text = []) name expr = - { - pmb_name = name; - pmb_expr = expr; - pmb_attributes = - add_text_attrs text (add_docs_attrs docs attrs); - pmb_loc = loc; - } -end + | Mcons of private_flag * Path.t * type_expr * type_expr * abbrev_memo + (** Found one abbreviation. + A valid abbreviation should be at least as visible and reachable by the + same path. + The first expression is the abbreviation and the second the expansion. *) -module Opn = struct - let mk ?(loc = !default_loc) ?(attrs = []) ?(docs = empty_docs) - ?(override = Fresh) lid = - { - popen_lid = lid; - popen_override = override; - popen_loc = loc; - popen_attributes = add_docs_attrs docs attrs; - } -end + | Mlink of abbrev_memo ref + (** Abbreviations can be found after this indirection *) -module Incl = struct - let mk ?(loc = !default_loc) ?(attrs = []) ?(docs = empty_docs) mexpr = - { - pincl_mod = mexpr; - pincl_loc = loc; - pincl_attributes = add_docs_attrs docs attrs; - } +and field_kind = + Fvar of field_kind option ref + | Fpresent + | Fabsent -end +(** [commutable] is a flag appended to every arrow type. -module Vb = struct - let mk ?(loc = !default_loc) ?(attrs = []) ?(docs = empty_docs) - ?(text = []) pat expr = - { - pvb_pat = pat; - pvb_expr = expr; - pvb_attributes = - add_text_attrs text (add_docs_attrs docs attrs); - pvb_loc = loc; - } -end + When typing an application, if the type of the functional is + known, its type is instantiated with [Cok] arrows, otherwise as + [Clink (ref Cunknown)]. -module Ci = struct - let mk ?(loc = !default_loc) ?(attrs = []) - ?(docs = empty_docs) ?(text = []) - ?(virt = Concrete) ?(params = []) name expr = - { - pci_virt = virt; - pci_params = params; - pci_name = name; - pci_expr = expr; - pci_attributes = - add_text_attrs text (add_docs_attrs docs attrs); - pci_loc = loc; - } -end + When the type is not known, the application will be used to infer + the actual type. This is fragile in presence of labels where + there is no principal type. -module Type = struct - let mk ?(loc = !default_loc) ?(attrs = []) - ?(docs = empty_docs) ?(text = []) - ?(params = []) - ?(cstrs = []) - ?(kind = Ptype_abstract) - ?(priv = Public) - ?manifest - name = - { - ptype_name = name; - ptype_params = params; - ptype_cstrs = cstrs; - ptype_kind = kind; - ptype_private = priv; - ptype_manifest = manifest; - ptype_attributes = - add_text_attrs text (add_docs_attrs docs attrs); - ptype_loc = loc; - } + Two incompatible applications relying on [Cunknown] arrows will + trigger an error. - let constructor ?(loc = !default_loc) ?(attrs = []) ?(info = empty_info) - ?(args = Pcstr_tuple []) ?res name = - { - pcd_name = name; - pcd_args = args; - pcd_res = res; - pcd_loc = loc; - pcd_attributes = add_info_attrs info attrs; - } + let f g = + g ~a:() ~b:(); + g ~b:() ~a:(); - let field ?(loc = !default_loc) ?(attrs = []) ?(info = empty_info) - ?(mut = Immutable) name typ = - { - pld_name = name; - pld_mutable = mut; - pld_type = typ; - pld_loc = loc; - pld_attributes = add_info_attrs info attrs; - } + Error: This function is applied to arguments + in an order different from other calls. + This is only allowed when the real type is known. +*) +and commutable = + Cok + | Cunknown + | Clink of commutable ref +module TypeOps : sig + type t = type_expr + val compare : t -> t -> int + val equal : t -> t -> bool + val hash : t -> int end -(** Type extensions *) -module Te = struct - let mk ?(attrs = []) ?(docs = empty_docs) - ?(params = []) ?(priv = Public) path constructors = - { - ptyext_path = path; - ptyext_params = params; - ptyext_constructors = constructors; - ptyext_private = priv; - ptyext_attributes = add_docs_attrs docs attrs; - } - - let constructor ?(loc = !default_loc) ?(attrs = []) - ?(docs = empty_docs) ?(info = empty_info) name kind = - { - pext_name = name; - pext_kind = kind; - pext_loc = loc; - pext_attributes = add_docs_attrs docs (add_info_attrs info attrs); - } +(* Maps of methods and instance variables *) - let decl ?(loc = !default_loc) ?(attrs = []) ?(docs = empty_docs) - ?(info = empty_info) ?(args = Pcstr_tuple []) ?res name = - { - pext_name = name; - pext_kind = Pext_decl(args, res); - pext_loc = loc; - pext_attributes = add_docs_attrs docs (add_info_attrs info attrs); - } +module Meths : Map.S with type key = string +module Vars : Map.S with type key = string - let rebind ?(loc = !default_loc) ?(attrs = []) - ?(docs = empty_docs) ?(info = empty_info) name lid = - { - pext_name = name; - pext_kind = Pext_rebind lid; - pext_loc = loc; - pext_attributes = add_docs_attrs docs (add_info_attrs info attrs); - } +(* Value descriptions *) -end +type value_description = + { val_type: type_expr; (* Type of the value *) + val_kind: value_kind; + val_loc: Location.t; + val_attributes: Parsetree.attributes; + } -module Csig = struct - let mk self fields = - { - pcsig_self = self; - pcsig_fields = fields; - } -end +and value_kind = + Val_reg (* Regular value *) + | Val_prim of Primitive.description (* Primitive *) + | Val_ivar of mutable_flag * string (* Instance variable (mutable ?) *) + | Val_self of (Ident.t * type_expr) Meths.t ref * + (Ident.t * mutable_flag * virtual_flag * type_expr) Vars.t ref * + string * type_expr + (* Self *) + | Val_anc of (string * Ident.t) list * string + (* Ancestor *) + | Val_unbound (* Unbound variable *) -module Cstr = struct - let mk self fields = - { - pcstr_self = self; - pcstr_fields = fields; - } -end +(* Variance *) +module Variance : sig + type t + type f = May_pos | May_neg | May_weak | Inj | Pos | Neg | Inv + val null : t (* no occurrence *) + val full : t (* strictly invariant *) + val covariant : t (* strictly covariant *) + val may_inv : t (* maybe invariant *) + val union : t -> t -> t + val inter : t -> t -> t + val subset : t -> t -> bool + val set : f -> bool -> t -> t + val mem : f -> t -> bool + val conjugate : t -> t (* exchange positive and negative *) + val get_upper : t -> bool * bool (* may_pos, may_neg *) + val get_lower : t -> bool * bool * bool * bool (* pos, neg, inv, inj *) end -module Parser : sig -#1 "parser.mli" -type token = - | AMPERAMPER - | AMPERSAND - | AND - | AS - | ASSERT - | BACKQUOTE - | BANG - | BAR - | BARBAR - | BARRBRACKET - | BEGIN - | CHAR of (char) - | CLASS - | COLON - | COLONCOLON - | COLONEQUAL - | COLONGREATER - | COMMA - | CONSTRAINT - | DO - | DONE - | DOT - | DOTDOT - | DOWNTO - | ELSE - | END - | EOF - | EQUAL - | EXCEPTION - | EXTERNAL - | FALSE - | FLOAT of (string * char option) - | FOR - | FUN - | FUNCTION - | FUNCTOR - | GREATER - | GREATERRBRACE - | GREATERRBRACKET - | IF - | IN - | INCLUDE - | INFIXOP0 of (string) - | INFIXOP1 of (string) - | INFIXOP2 of (string) - | INFIXOP3 of (string) - | INFIXOP4 of (string) - | DOTOP of (string) - | INHERIT - | INITIALIZER - | INT of (string * char option) - | LABEL of (string) - | LAZY - | LBRACE - | LBRACELESS - | LBRACKET - | LBRACKETBAR - | LBRACKETLESS - | LBRACKETGREATER - | LBRACKETPERCENT - | LBRACKETPERCENTPERCENT - | LESS - | LESSMINUS - | LET - | LIDENT of (string) - | LPAREN - | LBRACKETAT - | LBRACKETATAT - | LBRACKETATATAT - | MATCH - | METHOD - | MINUS - | MINUSDOT - | MINUSGREATER - | MODULE - | MUTABLE - | NEW - | NONREC - | OBJECT - | OF - | OPEN - | OPTLABEL of (string) - | OR - | PERCENT - | PLUS - | PLUSDOT - | PLUSEQ - | PREFIXOP of (string) - | PRIVATE - | QUESTION - | QUOTE - | RBRACE - | RBRACKET - | REC - | RPAREN - | SEMI - | SEMISEMI - | HASH - | HASHOP of (string) - | SIG - | STAR - | STRING of (string * string option) - | STRUCT - | THEN - | TILDE - | TO - | TRUE - | TRY - | TYPE - | UIDENT of (string) - | UNDERSCORE - | VAL - | VIRTUAL - | WHEN - | WHILE - | WITH - | COMMENT of (string * Location.t) - | DOCSTRING of (Docstrings.docstring) - | EOL -val implementation : - (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Parsetree.structure -val interface : - (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Parsetree.signature -val toplevel_phrase : - (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Parsetree.toplevel_phrase -val use_file : - (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Parsetree.toplevel_phrase list -val parse_core_type : - (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Parsetree.core_type -val parse_expression : - (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Parsetree.expression -val parse_pattern : - (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Parsetree.pattern +(* Type definitions *) -end = struct -#1 "parser.ml" -type token = - | AMPERAMPER - | AMPERSAND - | AND - | AS - | ASSERT - | BACKQUOTE - | BANG - | BAR - | BARBAR - | BARRBRACKET - | BEGIN - | CHAR of (char) - | CLASS - | COLON - | COLONCOLON - | COLONEQUAL - | COLONGREATER - | COMMA - | CONSTRAINT - | DO - | DONE - | DOT - | DOTDOT - | DOWNTO - | ELSE - | END - | EOF - | EQUAL - | EXCEPTION - | EXTERNAL - | FALSE - | FLOAT of (string * char option) - | FOR - | FUN - | FUNCTION - | FUNCTOR - | GREATER - | GREATERRBRACE - | GREATERRBRACKET - | IF - | IN - | INCLUDE - | INFIXOP0 of (string) - | INFIXOP1 of (string) - | INFIXOP2 of (string) - | INFIXOP3 of (string) - | INFIXOP4 of (string) - | DOTOP of (string) - | INHERIT - | INITIALIZER - | INT of (string * char option) - | LABEL of (string) - | LAZY - | LBRACE - | LBRACELESS - | LBRACKET - | LBRACKETBAR - | LBRACKETLESS - | LBRACKETGREATER - | LBRACKETPERCENT - | LBRACKETPERCENTPERCENT - | LESS - | LESSMINUS - | LET - | LIDENT of (string) - | LPAREN - | LBRACKETAT - | LBRACKETATAT - | LBRACKETATATAT - | MATCH - | METHOD - | MINUS - | MINUSDOT - | MINUSGREATER - | MODULE - | MUTABLE - | NEW - | NONREC - | OBJECT - | OF - | OPEN - | OPTLABEL of (string) - | OR - | PERCENT - | PLUS - | PLUSDOT - | PLUSEQ - | PREFIXOP of (string) - | PRIVATE - | QUESTION - | QUOTE - | RBRACE - | RBRACKET - | REC - | RPAREN - | SEMI - | SEMISEMI - | HASH - | HASHOP of (string) - | SIG - | STAR - | STRING of (string * string option) - | STRUCT - | THEN - | TILDE - | TO - | TRUE - | TRY - | TYPE - | UIDENT of (string) - | UNDERSCORE - | VAL - | VIRTUAL - | WHEN - | WHILE - | WITH - | COMMENT of (string * Location.t) - | DOCSTRING of (Docstrings.docstring) - | EOL +type type_declaration = + { type_params: type_expr list; + type_arity: int; + type_kind: type_kind; + type_private: private_flag; + type_manifest: type_expr option; + type_variance: Variance.t list; + (* covariant, contravariant, weakly contravariant, injective *) + type_newtype_level: (int * int) option; + (* definition level * expansion level *) + type_loc: Location.t; + type_attributes: Parsetree.attributes; + type_immediate: bool; (* true iff type should not be a pointer *) + type_unboxed: unboxed_status; + } -open Parsing;; -let _ = parse_error;; -# 19 "parsing/parser.mly" -open Location -open Asttypes -open Longident -open Parsetree -open Ast_helper -open Docstrings +and type_kind = + Type_abstract + | Type_record of label_declaration list * record_representation + | Type_variant of constructor_declaration list + | Type_open -let mktyp d = Typ.mk ~loc:(symbol_rloc()) d -let mkpat d = Pat.mk ~loc:(symbol_rloc()) d -let mkexp d = Exp.mk ~loc:(symbol_rloc()) d -let mkmty ?attrs d = Mty.mk ~loc:(symbol_rloc()) ?attrs d -let mksig d = Sig.mk ~loc:(symbol_rloc()) d -let mkmod ?attrs d = Mod.mk ~loc:(symbol_rloc()) ?attrs d -let mkstr d = Str.mk ~loc:(symbol_rloc()) d -let mkclass ?attrs d = Cl.mk ~loc:(symbol_rloc()) ?attrs d -let mkcty ?attrs d = Cty.mk ~loc:(symbol_rloc()) ?attrs d -let mkctf ?attrs ?docs d = - Ctf.mk ~loc:(symbol_rloc()) ?attrs ?docs d -let mkcf ?attrs ?docs d = - Cf.mk ~loc:(symbol_rloc()) ?attrs ?docs d +and record_representation = + Record_regular (* All fields are boxed / tagged *) + | Record_float (* All fields are floats *) + | Record_unboxed of bool (* Unboxed single-field record, inlined or not *) + | Record_inlined of { tag : int ; name : string; num_nonconsts : int} (* Inlined record *) + | Record_extension (* Inlined record under extension *) -let mkrhs rhs pos = mkloc rhs (rhs_loc pos) +and label_declaration = + { + ld_id: Ident.t; + ld_mutable: mutable_flag; + ld_type: type_expr; + ld_loc: Location.t; + ld_attributes: Parsetree.attributes; + } -let reloc_pat x = { x with ppat_loc = symbol_rloc () };; -let reloc_exp x = { x with pexp_loc = symbol_rloc () };; +and constructor_declaration = + { + cd_id: Ident.t; + cd_args: constructor_arguments; + cd_res: type_expr option; + cd_loc: Location.t; + cd_attributes: Parsetree.attributes; + } -let mkoperator name pos = - let loc = rhs_loc pos in - Exp.mk ~loc (Pexp_ident(mkloc (Lident name) loc)) +and constructor_arguments = + | Cstr_tuple of type_expr list + | Cstr_record of label_declaration list -let mkpatvar name pos = - Pat.mk ~loc:(rhs_loc pos) (Ppat_var (mkrhs name pos)) +and unboxed_status = private + (* This type must be private in order to ensure perfect sharing of the + four possible values. Otherwise, ocamlc.byte and ocamlc.opt produce + different executables. *) + { + unboxed: bool; + default: bool; (* True for unannotated unboxable types. *) + } -(* - Ghost expressions and patterns: - expressions and patterns that do not appear explicitly in the - source file they have the loc_ghost flag set to true. - Then the profiler will not try to instrument them and the - -annot option will not try to display their type. +val unboxed_false_default_false : unboxed_status +val unboxed_false_default_true : unboxed_status +val unboxed_true_default_false : unboxed_status +val unboxed_true_default_true : unboxed_status - Every grammar rule that generates an element with a location must - make at most one non-ghost element, the topmost one. +type extension_constructor = + { + ext_type_path: Path.t; + ext_type_params: type_expr list; + ext_args: constructor_arguments; + ext_ret_type: type_expr option; + ext_private: private_flag; + ext_loc: Location.t; + ext_attributes: Parsetree.attributes; + } - How to tell whether your location must be ghost: - A location corresponds to a range of characters in the source file. - If the location contains a piece of code that is syntactically - valid (according to the documentation), and corresponds to the - AST node, then the location must be real; in all other cases, - it must be ghost. -*) -let ghexp d = Exp.mk ~loc:(symbol_gloc ()) d -let ghpat d = Pat.mk ~loc:(symbol_gloc ()) d -let ghtyp d = Typ.mk ~loc:(symbol_gloc ()) d -let ghloc d = { txt = d; loc = symbol_gloc () } -let ghstr d = Str.mk ~loc:(symbol_gloc()) d -let ghsig d = Sig.mk ~loc:(symbol_gloc()) d +and type_transparence = + Type_public (* unrestricted expansion *) + | Type_new (* "new" type *) + | Type_private (* private type *) -let mkinfix arg1 name arg2 = - mkexp(Pexp_apply(mkoperator name 2, [Nolabel, arg1; Nolabel, arg2])) +(* Type expressions for the class language *) -let neg_string f = - if String.length f > 0 && f.[0] = '-' - then String.sub f 1 (String.length f - 1) - else "-" ^ f +module Concr : Set.S with type elt = string -let mkuminus name arg = - match name, arg.pexp_desc with - | "-", Pexp_constant(Pconst_integer (n,m)) -> - mkexp(Pexp_constant(Pconst_integer(neg_string n,m))) - | ("-" | "-."), Pexp_constant(Pconst_float (f, m)) -> - mkexp(Pexp_constant(Pconst_float(neg_string f, m))) - | _ -> - mkexp(Pexp_apply(mkoperator ("~" ^ name) 1, [Nolabel, arg])) +type class_type = + Cty_constr of Path.t * type_expr list * class_type + | Cty_signature of class_signature + | Cty_arrow of arg_label * type_expr * class_type -let mkuplus name arg = - let desc = arg.pexp_desc in - match name, desc with - | "+", Pexp_constant(Pconst_integer _) - | ("+" | "+."), Pexp_constant(Pconst_float _) -> mkexp desc - | _ -> - mkexp(Pexp_apply(mkoperator ("~" ^ name) 1, [Nolabel, arg])) +and class_signature = + { csig_self: type_expr; + csig_vars: + (Asttypes.mutable_flag * Asttypes.virtual_flag * type_expr) Vars.t; + csig_concr: Concr.t; + csig_inher: (Path.t * type_expr list) list } -let mkexp_cons consloc args loc = - Exp.mk ~loc (Pexp_construct(mkloc (Lident "::") consloc, Some args)) +type class_declaration = + { cty_params: type_expr list; + mutable cty_type: class_type; + cty_path: Path.t; + cty_new: type_expr option; + cty_variance: Variance.t list; + cty_loc: Location.t; + cty_attributes: Parsetree.attributes; + } -let mkpat_cons consloc args loc = - Pat.mk ~loc (Ppat_construct(mkloc (Lident "::") consloc, Some args)) +type class_type_declaration = + { clty_params: type_expr list; + clty_type: class_type; + clty_path: Path.t; + clty_variance: Variance.t list; + clty_loc: Location.t; + clty_attributes: Parsetree.attributes; + } -let rec mktailexp nilloc = function - [] -> - let loc = { nilloc with loc_ghost = true } in - let nil = { txt = Lident "[]"; loc = loc } in - Exp.mk ~loc (Pexp_construct (nil, None)) - | e1 :: el -> - let exp_el = mktailexp nilloc el in - let loc = {loc_start = e1.pexp_loc.loc_start; - loc_end = exp_el.pexp_loc.loc_end; - loc_ghost = true} - in - let arg = Exp.mk ~loc (Pexp_tuple [e1; exp_el]) in - mkexp_cons {loc with loc_ghost = true} arg loc +(* Type expressions for the module language *) -let rec mktailpat nilloc = function - [] -> - let loc = { nilloc with loc_ghost = true } in - let nil = { txt = Lident "[]"; loc = loc } in - Pat.mk ~loc (Ppat_construct (nil, None)) - | p1 :: pl -> - let pat_pl = mktailpat nilloc pl in - let loc = {loc_start = p1.ppat_loc.loc_start; - loc_end = pat_pl.ppat_loc.loc_end; - loc_ghost = true} - in - let arg = Pat.mk ~loc (Ppat_tuple [p1; pat_pl]) in - mkpat_cons {loc with loc_ghost = true} arg loc +type module_type = + Mty_ident of Path.t + | Mty_signature of signature + | Mty_functor of Ident.t * module_type option * module_type + | Mty_alias of alias_presence * Path.t -let mkstrexp e attrs = - { pstr_desc = Pstr_eval (e, attrs); pstr_loc = e.pexp_loc } +and alias_presence = + | Mta_present + | Mta_absent -let mkexp_constraint e (t1, t2) = - match t1, t2 with - | Some t, None -> ghexp(Pexp_constraint(e, t)) - | _, Some t -> ghexp(Pexp_coerce(e, t1, t)) - | None, None -> assert false +and signature = signature_item list -let mkexp_opt_constraint e = function - | None -> e - | Some constraint_ -> mkexp_constraint e constraint_ +and signature_item = + Sig_value of Ident.t * value_description + | Sig_type of Ident.t * type_declaration * rec_status + | Sig_typext of Ident.t * extension_constructor * ext_status + | Sig_module of Ident.t * module_declaration * rec_status + | Sig_modtype of Ident.t * modtype_declaration + | Sig_class of Ident.t * class_declaration * rec_status + | Sig_class_type of Ident.t * class_type_declaration * rec_status -let mkpat_opt_constraint p = function - | None -> p - | Some typ -> mkpat (Ppat_constraint(p, typ)) +and module_declaration = + { + md_type: module_type; + md_attributes: Parsetree.attributes; + md_loc: Location.t; + } -let array_function str name = - ghloc (Ldot(Lident str, (if !Clflags.fast then "unsafe_" ^ name else name))) +and modtype_declaration = + { + mtd_type: module_type option; (* None: abstract *) + mtd_attributes: Parsetree.attributes; + mtd_loc: Location.t; + } -let syntax_error () = - raise Syntaxerr.Escape_error +and rec_status = + Trec_not (* first in a nonrecursive group *) + | Trec_first (* first in a recursive group *) + | Trec_next (* not first in a recursive/nonrecursive group *) -let unclosed opening_name opening_num closing_name closing_num = - raise(Syntaxerr.Error(Syntaxerr.Unclosed(rhs_loc opening_num, opening_name, - rhs_loc closing_num, closing_name))) +and ext_status = + Text_first (* first constructor in an extension *) + | Text_next (* not first constructor in an extension *) + | Text_exception -let expecting pos nonterm = - raise Syntaxerr.(Error(Expecting(rhs_loc pos, nonterm))) -let not_expecting pos nonterm = - raise Syntaxerr.(Error(Not_expecting(rhs_loc pos, nonterm))) +(* Constructor and record label descriptions inserted held in typing + environments *) -let bigarray_function str name = - ghloc (Ldot(Ldot(Lident "Bigarray", str), name)) +type constructor_description = + { cstr_name: string; (* Constructor name *) + cstr_res: type_expr; (* Type of the result *) + cstr_existentials: type_expr list; (* list of existentials *) + cstr_args: type_expr list; (* Type of the arguments *) + cstr_arity: int; (* Number of arguments *) + cstr_tag: constructor_tag; (* Tag for heap blocks *) + cstr_consts: int; (* Number of constant constructors *) + cstr_nonconsts: int; (* Number of non-const constructors *) + cstr_normal: int; (* Number of non generalized constrs *) + cstr_generalized: bool; (* Constrained return type? *) + cstr_private: private_flag; (* Read-only constructor? *) + cstr_loc: Location.t; + cstr_attributes: Parsetree.attributes; + cstr_inlined: type_declaration option; + } -let bigarray_untuplify = function - { pexp_desc = Pexp_tuple explist; pexp_loc = _ } -> explist - | exp -> [exp] +and constructor_tag = + Cstr_constant of int (* Constant constructor (an int) *) + | Cstr_block of int (* Regular constructor (a block) *) + | Cstr_unboxed (* Constructor of an unboxed type *) + | Cstr_extension of Path.t * bool (* Extension constructor + true if a constant false if a block*) -let bigarray_get arr arg = - let get = if !Clflags.fast then "unsafe_get" else "get" in - match bigarray_untuplify arg with - [c1] -> - mkexp(Pexp_apply(ghexp(Pexp_ident(bigarray_function "Array1" get)), - [Nolabel, arr; Nolabel, c1])) - | [c1;c2] -> - mkexp(Pexp_apply(ghexp(Pexp_ident(bigarray_function "Array2" get)), - [Nolabel, arr; Nolabel, c1; Nolabel, c2])) - | [c1;c2;c3] -> - mkexp(Pexp_apply(ghexp(Pexp_ident(bigarray_function "Array3" get)), - [Nolabel, arr; Nolabel, c1; Nolabel, c2; Nolabel, c3])) - | coords -> - mkexp(Pexp_apply(ghexp(Pexp_ident(bigarray_function "Genarray" "get")), - [Nolabel, arr; Nolabel, ghexp(Pexp_array coords)])) +(* Constructors are the same *) +val equal_tag : constructor_tag -> constructor_tag -> bool -let bigarray_set arr arg newval = - let set = if !Clflags.fast then "unsafe_set" else "set" in - match bigarray_untuplify arg with - [c1] -> - mkexp(Pexp_apply(ghexp(Pexp_ident(bigarray_function "Array1" set)), - [Nolabel, arr; Nolabel, c1; Nolabel, newval])) - | [c1;c2] -> - mkexp(Pexp_apply(ghexp(Pexp_ident(bigarray_function "Array2" set)), - [Nolabel, arr; Nolabel, c1; - Nolabel, c2; Nolabel, newval])) - | [c1;c2;c3] -> - mkexp(Pexp_apply(ghexp(Pexp_ident(bigarray_function "Array3" set)), - [Nolabel, arr; Nolabel, c1; - Nolabel, c2; Nolabel, c3; Nolabel, newval])) - | coords -> - mkexp(Pexp_apply(ghexp(Pexp_ident(bigarray_function "Genarray" "set")), - [Nolabel, arr; - Nolabel, ghexp(Pexp_array coords); - Nolabel, newval])) +(* Constructors may be the same, given potential rebinding *) +val may_equal_constr : + constructor_description -> constructor_description -> bool -let lapply p1 p2 = - if !Clflags.applicative_functors - then Lapply(p1, p2) - else raise (Syntaxerr.Error(Syntaxerr.Applicative_path (symbol_rloc()))) +type label_description = + { lbl_name: string; (* Short name *) + lbl_res: type_expr; (* Type of the result *) + lbl_arg: type_expr; (* Type of the argument *) + lbl_mut: mutable_flag; (* Is this a mutable field? *) + lbl_pos: int; (* Position in block *) + lbl_all: label_description array; (* All the labels in this type *) + lbl_repres: record_representation; (* Representation for this record *) + lbl_private: private_flag; (* Read-only field? *) + lbl_loc: Location.t; + lbl_attributes: Parsetree.attributes; + } -let exp_of_label lbl pos = - mkexp (Pexp_ident(mkrhs (Lident(Longident.last lbl)) pos)) +end = struct +#1 "types.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -let pat_of_label lbl pos = - mkpat (Ppat_var (mkrhs (Longident.last lbl) pos)) +(* Representation of types and declarations *) -let mk_newtypes newtypes exp = - List.fold_right (fun newtype exp -> mkexp (Pexp_newtype (newtype, exp))) - newtypes exp +open Asttypes -let wrap_type_annotation newtypes core_type body = - let exp = mkexp(Pexp_constraint(body,core_type)) in - let exp = mk_newtypes newtypes exp in - (exp, ghtyp(Ptyp_poly(newtypes, Typ.varify_constructors newtypes core_type))) +(* Type expressions for the core language *) -let wrap_exp_attrs body (ext, attrs) = - (* todo: keep exact location for the entire attribute *) - let body = {body with pexp_attributes = attrs @ body.pexp_attributes} in - match ext with - | None -> body - | Some id -> ghexp(Pexp_extension (id, PStr [mkstrexp body []])) +type type_expr = + { mutable desc: type_desc; + mutable level: int; + id: int } -let mkexp_attrs d attrs = - wrap_exp_attrs (mkexp d) attrs +and type_desc = + Tvar of string option + | Tarrow of arg_label * type_expr * type_expr * commutable + | Ttuple of type_expr list + | Tconstr of Path.t * type_expr list * abbrev_memo ref + | Tobject of type_expr * (Path.t * type_expr list) option ref + | Tfield of string * field_kind * type_expr * type_expr + | Tnil + | Tlink of type_expr + | Tsubst of type_expr (* for copying *) + | Tvariant of row_desc + | Tunivar of string option + | Tpoly of type_expr * type_expr list + | Tpackage of Path.t * Longident.t list * type_expr list -let wrap_typ_attrs typ (ext, attrs) = - (* todo: keep exact location for the entire attribute *) - let typ = {typ with ptyp_attributes = attrs @ typ.ptyp_attributes} in - match ext with - | None -> typ - | Some id -> ghtyp(Ptyp_extension (id, PTyp typ)) +and row_desc = + { row_fields: (label * row_field) list; + row_more: type_expr; + row_bound: unit; + row_closed: bool; + row_fixed: bool; + row_name: (Path.t * type_expr list) option } -let mktyp_attrs d attrs = - wrap_typ_attrs (mktyp d) attrs +and row_field = + Rpresent of type_expr option + | Reither of bool * type_expr list * bool * row_field option ref + (* 1st true denotes a constant constructor *) + (* 2nd true denotes a tag in a pattern matching, and + is erased later *) + | Rabsent -let wrap_pat_attrs pat (ext, attrs) = - (* todo: keep exact location for the entire attribute *) - let pat = {pat with ppat_attributes = attrs @ pat.ppat_attributes} in - match ext with - | None -> pat - | Some id -> ghpat(Ppat_extension (id, PPat (pat, None))) +and abbrev_memo = + Mnil + | Mcons of private_flag * Path.t * type_expr * type_expr * abbrev_memo + | Mlink of abbrev_memo ref -let mkpat_attrs d attrs = - wrap_pat_attrs (mkpat d) attrs +and field_kind = + Fvar of field_kind option ref + | Fpresent + | Fabsent -let wrap_class_attrs body attrs = - {body with pcl_attributes = attrs @ body.pcl_attributes} -let wrap_class_type_attrs body attrs = - {body with pcty_attributes = attrs @ body.pcty_attributes} -let wrap_mod_attrs body attrs = - {body with pmod_attributes = attrs @ body.pmod_attributes} -let wrap_mty_attrs body attrs = - {body with pmty_attributes = attrs @ body.pmty_attributes} +and commutable = + Cok + | Cunknown + | Clink of commutable ref -let wrap_str_ext body ext = - match ext with - | None -> body - | Some id -> ghstr(Pstr_extension ((id, PStr [body]), [])) +module TypeOps = struct + type t = type_expr + let compare t1 t2 = t1.id - t2.id + let hash t = t.id + let equal t1 t2 = t1 == t2 +end -let mkstr_ext d ext = - wrap_str_ext (mkstr d) ext +(* Maps of methods and instance variables *) -let wrap_sig_ext body ext = - match ext with - | None -> body - | Some id -> ghsig(Psig_extension ((id, PSig [body]), [])) +module OrderedString = + struct type t = string let compare (x:t) y = compare x y end +module Meths = Map.Make(OrderedString) +module Vars = Meths -let mksig_ext d ext = - wrap_sig_ext (mksig d) ext +(* Value descriptions *) -let text_str pos = Str.text (rhs_text pos) -let text_sig pos = Sig.text (rhs_text pos) -let text_cstr pos = Cf.text (rhs_text pos) -let text_csig pos = Ctf.text (rhs_text pos) -let text_def pos = [Ptop_def (Str.text (rhs_text pos))] +type value_description = + { val_type: type_expr; (* Type of the value *) + val_kind: value_kind; + val_loc: Location.t; + val_attributes: Parsetree.attributes; + } -let extra_text text pos items = - let pre_extras = rhs_pre_extra_text pos in - let post_extras = rhs_post_extra_text pos in - text pre_extras @ items @ text post_extras +and value_kind = + Val_reg (* Regular value *) + | Val_prim of Primitive.description (* Primitive *) + | Val_ivar of mutable_flag * string (* Instance variable (mutable ?) *) + | Val_self of (Ident.t * type_expr) Meths.t ref * + (Ident.t * Asttypes.mutable_flag * + Asttypes.virtual_flag * type_expr) Vars.t ref * + string * type_expr + (* Self *) + | Val_anc of (string * Ident.t) list * string + (* Ancestor *) + | Val_unbound (* Unbound variable *) -let extra_str pos items = extra_text Str.text pos items -let extra_sig pos items = extra_text Sig.text pos items -let extra_cstr pos items = extra_text Cf.text pos items -let extra_csig pos items = extra_text Ctf.text pos items -let extra_def pos items = - extra_text (fun txt -> [Ptop_def (Str.text txt)]) pos items +(* Variance *) -let extra_rhs_core_type ct ~pos = - let docs = rhs_info pos in - { ct with ptyp_attributes = add_info_attrs docs ct.ptyp_attributes } +module Variance = struct + type t = int + type f = May_pos | May_neg | May_weak | Inj | Pos | Neg | Inv + let single = function + | May_pos -> 1 + | May_neg -> 2 + | May_weak -> 4 + | Inj -> 8 + | Pos -> 16 + | Neg -> 32 + | Inv -> 64 + let union v1 v2 = v1 lor v2 + let inter v1 v2 = v1 land v2 + let subset v1 v2 = (v1 land v2 = v1) + let set x b v = + if b then v lor single x else v land (lnot (single x)) + let mem x = subset (single x) + let null = 0 + let may_inv = 7 + let full = 127 + let covariant = single May_pos lor single Pos lor single Inj + let swap f1 f2 v = + let v' = set f1 (mem f2 v) v in set f2 (mem f1 v) v' + let conjugate v = swap May_pos May_neg (swap Pos Neg v) + let get_upper v = (mem May_pos v, mem May_neg v) + let get_lower v = (mem Pos v, mem Neg v, mem Inv v, mem Inj v) +end -type let_binding = - { lb_pattern: pattern; - lb_expression: expression; - lb_attributes: attributes; - lb_docs: docs Lazy.t; - lb_text: text Lazy.t; - lb_loc: Location.t; } +(* Type definitions *) -type let_bindings = - { lbs_bindings: let_binding list; - lbs_rec: rec_flag; - lbs_extension: string Asttypes.loc option; - lbs_loc: Location.t } +type type_declaration = + { type_params: type_expr list; + type_arity: int; + type_kind: type_kind; + type_private: private_flag; + type_manifest: type_expr option; + type_variance: Variance.t list; + type_newtype_level: (int * int) option; + type_loc: Location.t; + type_attributes: Parsetree.attributes; + type_immediate: bool; + type_unboxed: unboxed_status; + } -let mklb first (p, e) attrs = - { lb_pattern = p; - lb_expression = e; - lb_attributes = attrs; - lb_docs = symbol_docs_lazy (); - lb_text = if first then empty_text_lazy - else symbol_text_lazy (); - lb_loc = symbol_rloc (); } +and type_kind = + Type_abstract + | Type_record of label_declaration list * record_representation + | Type_variant of constructor_declaration list + | Type_open -let mklbs ext rf lb = - { lbs_bindings = [lb]; - lbs_rec = rf; - lbs_extension = ext ; - lbs_loc = symbol_rloc (); } +and record_representation = + Record_regular (* All fields are boxed / tagged *) + | Record_float (* All fields are floats *) + | Record_unboxed of bool (* Unboxed single-field record, inlined or not *) + | Record_inlined of {tag : int; name : string; num_nonconsts : int} (* Inlined record *) + | Record_extension (* Inlined record under extension *) -let addlb lbs lb = - { lbs with lbs_bindings = lb :: lbs.lbs_bindings } +and label_declaration = + { + ld_id: Ident.t; + ld_mutable: mutable_flag; + ld_type: type_expr; + ld_loc: Location.t; + ld_attributes: Parsetree.attributes; + } -let val_of_let_bindings lbs = - let bindings = - List.map - (fun lb -> - Vb.mk ~loc:lb.lb_loc ~attrs:lb.lb_attributes - ~docs:(Lazy.force lb.lb_docs) - ~text:(Lazy.force lb.lb_text) - lb.lb_pattern lb.lb_expression) - lbs.lbs_bindings - in - let str = mkstr(Pstr_value(lbs.lbs_rec, List.rev bindings)) in - match lbs.lbs_extension with - | None -> str - | Some id -> ghstr (Pstr_extension((id, PStr [str]), [])) +and constructor_declaration = + { + cd_id: Ident.t; + cd_args: constructor_arguments; + cd_res: type_expr option; + cd_loc: Location.t; + cd_attributes: Parsetree.attributes; + } -let expr_of_let_bindings lbs body = - let bindings = - List.map - (fun lb -> - Vb.mk ~loc:lb.lb_loc ~attrs:lb.lb_attributes - lb.lb_pattern lb.lb_expression) - lbs.lbs_bindings - in - mkexp_attrs (Pexp_let(lbs.lbs_rec, List.rev bindings, body)) - (lbs.lbs_extension, []) +and constructor_arguments = + | Cstr_tuple of type_expr list + | Cstr_record of label_declaration list -let class_of_let_bindings lbs body = - let bindings = - List.map - (fun lb -> - Vb.mk ~loc:lb.lb_loc ~attrs:lb.lb_attributes - lb.lb_pattern lb.lb_expression) - lbs.lbs_bindings - in - if lbs.lbs_extension <> None then - raise Syntaxerr.(Error(Not_expecting(lbs.lbs_loc, "extension"))); - mkclass(Pcl_let (lbs.lbs_rec, List.rev bindings, body)) +and unboxed_status = + { + unboxed: bool; + default: bool; (* False if the unboxed field was set from an attribute. *) + } +let unboxed_false_default_false = {unboxed = false; default = false} +let unboxed_false_default_true = {unboxed = false; default = true} +let unboxed_true_default_false = {unboxed = true; default = false} +let unboxed_true_default_true = {unboxed = true; default = true} -(* Alternatively, we could keep the generic module type in the Parsetree - and extract the package type during type-checking. In that case, - the assertions below should be turned into explicit checks. *) -let package_type_of_module_type pmty = - let err loc s = - raise (Syntaxerr.Error (Syntaxerr.Invalid_package_type (loc, s))) - in - let map_cstr = function - | Pwith_type (lid, ptyp) -> - let loc = ptyp.ptype_loc in - if ptyp.ptype_params <> [] then - err loc "parametrized types are not supported"; - if ptyp.ptype_cstrs <> [] then - err loc "constrained types are not supported"; - if ptyp.ptype_private <> Public then - err loc "private types are not supported"; +type extension_constructor = + { ext_type_path: Path.t; + ext_type_params: type_expr list; + ext_args: constructor_arguments; + ext_ret_type: type_expr option; + ext_private: private_flag; + ext_loc: Location.t; + ext_attributes: Parsetree.attributes; } - (* restrictions below are checked by the 'with_constraint' rule *) - assert (ptyp.ptype_kind = Ptype_abstract); - assert (ptyp.ptype_attributes = []); - let ty = - match ptyp.ptype_manifest with - | Some ty -> ty - | None -> assert false - in - (lid, ty) - | _ -> - err pmty.pmty_loc "only 'with type t =' constraints are supported" - in - match pmty with - | {pmty_desc = Pmty_ident lid} -> (lid, []) - | {pmty_desc = Pmty_with({pmty_desc = Pmty_ident lid}, cstrs)} -> - (lid, List.map map_cstr cstrs) - | _ -> - err pmty.pmty_loc - "only module type identifier and 'with type' constraints are supported" +and type_transparence = + Type_public (* unrestricted expansion *) + | Type_new (* "new" type *) + | Type_private (* private type *) +(* Type expressions for the class language *) -# 524 "parsing/parser.ml" -let yytransl_const = [| - 257 (* AMPERAMPER *); - 258 (* AMPERSAND *); - 259 (* AND *); - 260 (* AS *); - 261 (* ASSERT *); - 262 (* BACKQUOTE *); - 263 (* BANG *); - 264 (* BAR *); - 265 (* BARBAR *); - 266 (* BARRBRACKET *); - 267 (* BEGIN *); - 269 (* CLASS *); - 270 (* COLON *); - 271 (* COLONCOLON *); - 272 (* COLONEQUAL *); - 273 (* COLONGREATER *); - 274 (* COMMA *); - 275 (* CONSTRAINT *); - 276 (* DO *); - 277 (* DONE *); - 278 (* DOT *); - 279 (* DOTDOT *); - 280 (* DOWNTO *); - 281 (* ELSE *); - 282 (* END *); - 0 (* EOF *); - 283 (* EQUAL *); - 284 (* EXCEPTION *); - 285 (* EXTERNAL *); - 286 (* FALSE *); - 288 (* FOR *); - 289 (* FUN *); - 290 (* FUNCTION *); - 291 (* FUNCTOR *); - 292 (* GREATER *); - 293 (* GREATERRBRACE *); - 294 (* GREATERRBRACKET *); - 295 (* IF *); - 296 (* IN *); - 297 (* INCLUDE *); - 304 (* INHERIT *); - 305 (* INITIALIZER *); - 308 (* LAZY *); - 309 (* LBRACE *); - 310 (* LBRACELESS *); - 311 (* LBRACKET *); - 312 (* LBRACKETBAR *); - 313 (* LBRACKETLESS *); - 314 (* LBRACKETGREATER *); - 315 (* LBRACKETPERCENT *); - 316 (* LBRACKETPERCENTPERCENT *); - 317 (* LESS *); - 318 (* LESSMINUS *); - 319 (* LET *); - 321 (* LPAREN *); - 322 (* LBRACKETAT *); - 323 (* LBRACKETATAT *); - 324 (* LBRACKETATATAT *); - 325 (* MATCH *); - 326 (* METHOD *); - 327 (* MINUS *); - 328 (* MINUSDOT *); - 329 (* MINUSGREATER *); - 330 (* MODULE *); - 331 (* MUTABLE *); - 332 (* NEW *); - 333 (* NONREC *); - 334 (* OBJECT *); - 335 (* OF *); - 336 (* OPEN *); - 338 (* OR *); - 339 (* PERCENT *); - 340 (* PLUS *); - 341 (* PLUSDOT *); - 342 (* PLUSEQ *); - 344 (* PRIVATE *); - 345 (* QUESTION *); - 346 (* QUOTE *); - 347 (* RBRACE *); - 348 (* RBRACKET *); - 349 (* REC *); - 350 (* RPAREN *); - 351 (* SEMI *); - 352 (* SEMISEMI *); - 353 (* HASH *); - 355 (* SIG *); - 356 (* STAR *); - 358 (* STRUCT *); - 359 (* THEN *); - 360 (* TILDE *); - 361 (* TO *); - 362 (* TRUE *); - 363 (* TRY *); - 364 (* TYPE *); - 366 (* UNDERSCORE *); - 367 (* VAL *); - 368 (* VIRTUAL *); - 369 (* WHEN *); - 370 (* WHILE *); - 371 (* WITH *); - 374 (* EOL *); - 0|] +module Concr = Set.Make(OrderedString) -let yytransl_block = [| - 268 (* CHAR *); - 287 (* FLOAT *); - 298 (* INFIXOP0 *); - 299 (* INFIXOP1 *); - 300 (* INFIXOP2 *); - 301 (* INFIXOP3 *); - 302 (* INFIXOP4 *); - 303 (* DOTOP *); - 306 (* INT *); - 307 (* LABEL *); - 320 (* LIDENT *); - 337 (* OPTLABEL *); - 343 (* PREFIXOP *); - 354 (* HASHOP *); - 357 (* STRING *); - 365 (* UIDENT *); - 372 (* COMMENT *); - 373 (* DOCSTRING *); - 0|] +type class_type = + Cty_constr of Path.t * type_expr list * class_type + | Cty_signature of class_signature + | Cty_arrow of arg_label * type_expr * class_type -let yylhs = "\255\255\ -\001\000\002\000\003\000\003\000\003\000\010\000\010\000\014\000\ -\014\000\004\000\016\000\016\000\017\000\017\000\017\000\017\000\ -\017\000\017\000\017\000\005\000\006\000\007\000\020\000\020\000\ -\021\000\021\000\023\000\023\000\024\000\024\000\024\000\024\000\ -\024\000\024\000\024\000\024\000\024\000\027\000\027\000\027\000\ -\027\000\027\000\027\000\027\000\027\000\027\000\027\000\027\000\ -\008\000\008\000\032\000\032\000\032\000\015\000\015\000\015\000\ -\015\000\015\000\015\000\015\000\015\000\015\000\015\000\015\000\ -\015\000\015\000\015\000\015\000\045\000\049\000\049\000\049\000\ -\039\000\040\000\040\000\050\000\051\000\022\000\022\000\022\000\ -\022\000\022\000\022\000\022\000\022\000\022\000\022\000\022\000\ -\009\000\009\000\009\000\054\000\054\000\054\000\054\000\054\000\ -\054\000\054\000\054\000\054\000\054\000\054\000\054\000\054\000\ -\054\000\054\000\042\000\060\000\063\000\063\000\063\000\057\000\ -\058\000\059\000\059\000\064\000\065\000\066\000\066\000\041\000\ -\043\000\043\000\068\000\069\000\072\000\072\000\072\000\071\000\ -\071\000\077\000\077\000\073\000\073\000\073\000\073\000\073\000\ -\073\000\073\000\078\000\078\000\078\000\078\000\078\000\078\000\ -\078\000\078\000\082\000\083\000\083\000\083\000\084\000\084\000\ -\085\000\085\000\085\000\085\000\085\000\085\000\085\000\086\000\ -\086\000\087\000\087\000\087\000\087\000\088\000\088\000\088\000\ -\088\000\088\000\074\000\074\000\074\000\074\000\074\000\097\000\ -\097\000\097\000\097\000\097\000\097\000\097\000\100\000\101\000\ -\101\000\102\000\102\000\103\000\103\000\103\000\103\000\103\000\ -\103\000\104\000\104\000\104\000\106\000\089\000\061\000\061\000\ -\107\000\108\000\044\000\044\000\109\000\110\000\012\000\012\000\ -\012\000\012\000\075\000\075\000\075\000\075\000\075\000\075\000\ -\075\000\075\000\116\000\116\000\113\000\113\000\112\000\112\000\ -\114\000\115\000\115\000\030\000\030\000\030\000\030\000\030\000\ -\030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ -\030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ -\030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ -\030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ -\030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ -\030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ -\030\000\030\000\030\000\030\000\030\000\030\000\118\000\118\000\ -\118\000\118\000\118\000\118\000\118\000\118\000\118\000\118\000\ -\118\000\118\000\118\000\118\000\118\000\118\000\118\000\118\000\ -\118\000\118\000\118\000\118\000\118\000\118\000\118\000\118\000\ -\118\000\118\000\118\000\118\000\118\000\118\000\118\000\118\000\ -\118\000\118\000\118\000\118\000\118\000\118\000\118\000\118\000\ -\118\000\118\000\118\000\118\000\118\000\118\000\118\000\118\000\ -\118\000\118\000\118\000\118\000\118\000\118\000\118\000\118\000\ -\118\000\118\000\118\000\118\000\118\000\118\000\079\000\079\000\ -\136\000\136\000\137\000\137\000\137\000\137\000\138\000\096\000\ -\096\000\139\000\139\000\139\000\139\000\139\000\139\000\033\000\ -\033\000\144\000\145\000\147\000\147\000\095\000\095\000\095\000\ -\121\000\121\000\148\000\148\000\148\000\122\000\122\000\122\000\ -\122\000\123\000\123\000\132\000\132\000\150\000\150\000\150\000\ -\151\000\151\000\135\000\135\000\153\000\153\000\133\000\133\000\ -\092\000\092\000\092\000\092\000\092\000\152\000\152\000\019\000\ -\019\000\019\000\019\000\019\000\019\000\019\000\019\000\019\000\ -\019\000\142\000\142\000\142\000\142\000\142\000\142\000\142\000\ -\142\000\142\000\155\000\155\000\155\000\155\000\117\000\117\000\ -\143\000\143\000\143\000\143\000\143\000\143\000\143\000\143\000\ -\143\000\143\000\143\000\143\000\143\000\143\000\143\000\143\000\ -\143\000\143\000\143\000\143\000\143\000\143\000\159\000\159\000\ -\159\000\159\000\159\000\159\000\159\000\154\000\154\000\154\000\ -\156\000\156\000\156\000\161\000\161\000\160\000\160\000\160\000\ -\160\000\162\000\162\000\163\000\163\000\035\000\164\000\164\000\ -\034\000\036\000\036\000\165\000\166\000\170\000\170\000\169\000\ -\169\000\169\000\169\000\169\000\169\000\169\000\169\000\169\000\ -\169\000\169\000\168\000\168\000\168\000\173\000\174\000\174\000\ -\176\000\176\000\177\000\175\000\175\000\175\000\178\000\076\000\ -\076\000\171\000\171\000\171\000\179\000\180\000\038\000\038\000\ -\056\000\119\000\182\000\182\000\182\000\182\000\183\000\183\000\ -\172\000\172\000\172\000\185\000\186\000\037\000\055\000\188\000\ -\188\000\188\000\188\000\188\000\188\000\189\000\189\000\189\000\ -\190\000\191\000\192\000\193\000\053\000\053\000\194\000\194\000\ -\194\000\194\000\195\000\195\000\141\000\141\000\093\000\093\000\ -\187\000\187\000\018\000\018\000\196\000\196\000\198\000\198\000\ -\198\000\198\000\198\000\149\000\149\000\199\000\199\000\199\000\ -\199\000\199\000\199\000\199\000\199\000\199\000\199\000\199\000\ -\199\000\199\000\199\000\199\000\199\000\199\000\199\000\199\000\ -\031\000\202\000\202\000\203\000\203\000\201\000\201\000\205\000\ -\205\000\206\000\206\000\204\000\204\000\098\000\098\000\080\000\ -\080\000\184\000\184\000\200\000\200\000\200\000\200\000\200\000\ -\200\000\200\000\209\000\207\000\208\000\090\000\131\000\131\000\ -\131\000\131\000\157\000\157\000\157\000\157\000\157\000\067\000\ -\067\000\140\000\140\000\140\000\140\000\140\000\210\000\210\000\ -\210\000\210\000\210\000\210\000\210\000\210\000\210\000\210\000\ -\210\000\210\000\210\000\210\000\210\000\210\000\210\000\210\000\ -\210\000\210\000\210\000\210\000\210\000\210\000\210\000\210\000\ -\210\000\210\000\210\000\181\000\181\000\181\000\181\000\181\000\ -\181\000\130\000\130\000\124\000\124\000\124\000\124\000\124\000\ -\124\000\124\000\129\000\129\000\158\000\158\000\025\000\025\000\ -\197\000\197\000\197\000\052\000\052\000\099\000\099\000\081\000\ -\081\000\011\000\011\000\011\000\011\000\011\000\011\000\011\000\ -\125\000\146\000\146\000\167\000\167\000\126\000\126\000\094\000\ -\094\000\091\000\091\000\070\000\070\000\105\000\105\000\105\000\ -\105\000\105\000\062\000\062\000\120\000\120\000\134\000\134\000\ -\127\000\127\000\128\000\128\000\211\000\211\000\211\000\211\000\ -\211\000\211\000\211\000\211\000\211\000\211\000\211\000\211\000\ -\211\000\211\000\211\000\211\000\211\000\211\000\211\000\211\000\ -\211\000\211\000\211\000\211\000\211\000\211\000\211\000\211\000\ -\211\000\211\000\211\000\211\000\211\000\211\000\211\000\211\000\ -\211\000\211\000\211\000\211\000\211\000\211\000\211\000\211\000\ -\211\000\211\000\211\000\211\000\211\000\211\000\211\000\111\000\ -\111\000\028\000\213\000\047\000\013\000\013\000\026\000\026\000\ -\048\000\048\000\048\000\029\000\046\000\212\000\212\000\212\000\ -\212\000\212\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000" +and class_signature = + { csig_self: type_expr; + csig_vars: + (Asttypes.mutable_flag * Asttypes.virtual_flag * type_expr) Vars.t; + csig_concr: Concr.t; + csig_inher: (Path.t * type_expr list) list } -let yylen = "\002\000\ -\002\000\002\000\002\000\002\000\001\000\002\000\001\000\000\000\ -\002\000\001\000\001\000\003\000\001\000\002\000\004\000\003\000\ -\003\000\002\000\002\000\002\000\002\000\002\000\002\000\005\000\ -\001\000\001\000\002\000\001\000\001\000\004\000\004\000\005\000\ -\002\000\003\000\001\000\002\000\001\000\005\000\005\000\003\000\ -\003\000\005\000\007\000\009\000\007\000\006\000\006\000\005\000\ -\003\000\001\000\000\000\002\000\002\000\001\000\001\000\001\000\ -\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\ -\001\000\001\000\002\000\001\000\004\000\002\000\004\000\002\000\ -\005\000\001\000\002\000\006\000\005\000\001\000\004\000\004\000\ -\005\000\003\000\003\000\005\000\003\000\003\000\001\000\002\000\ -\000\000\002\000\002\000\001\000\001\000\001\000\001\000\001\000\ -\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\ -\002\000\001\000\005\000\004\000\002\000\006\000\003\000\005\000\ -\006\000\001\000\002\000\007\000\006\000\000\000\002\000\006\000\ -\001\000\002\000\007\000\007\000\002\000\004\000\002\000\000\000\ -\003\000\003\000\002\000\001\000\003\000\002\000\003\000\007\000\ -\002\000\001\000\004\000\001\000\004\000\004\000\005\000\005\000\ -\003\000\003\000\002\000\003\000\005\000\000\000\000\000\002\000\ -\006\000\003\000\003\000\004\000\004\000\002\000\001\000\002\000\ -\000\000\007\000\007\000\006\000\007\000\007\000\007\000\005\000\ -\008\000\011\000\001\000\006\000\004\000\005\000\003\000\004\000\ -\001\000\004\000\004\000\002\000\001\000\007\000\002\000\003\000\ -\000\000\000\000\002\000\004\000\004\000\007\000\004\000\002\000\ -\001\000\005\000\005\000\003\000\003\000\003\000\001\000\002\000\ -\008\000\008\000\001\000\002\000\009\000\008\000\001\000\002\000\ -\003\000\005\000\005\000\002\000\005\000\002\000\004\000\002\000\ -\002\000\001\000\001\000\001\000\000\000\002\000\001\000\003\000\ -\001\000\001\000\003\000\001\000\002\000\003\000\007\000\006\000\ -\007\000\004\000\004\000\007\000\006\000\006\000\005\000\001\000\ -\002\000\002\000\007\000\005\000\006\000\010\000\003\000\003\000\ -\003\000\003\000\003\000\003\000\003\000\003\000\003\000\003\000\ -\003\000\003\000\003\000\003\000\003\000\003\000\003\000\003\000\ -\003\000\003\000\003\000\002\000\002\000\005\000\007\000\007\000\ -\007\000\007\000\007\000\007\000\009\000\009\000\009\000\003\000\ -\003\000\003\000\004\000\004\000\002\000\001\000\001\000\001\000\ -\001\000\001\000\003\000\003\000\004\000\003\000\004\000\004\000\ -\003\000\005\000\004\000\005\000\005\000\005\000\005\000\005\000\ -\005\000\005\000\005\000\005\000\005\000\005\000\007\000\007\000\ -\007\000\007\000\007\000\007\000\005\000\005\000\003\000\003\000\ -\005\000\005\000\004\000\004\000\002\000\006\000\004\000\006\000\ -\004\000\004\000\006\000\004\000\006\000\002\000\002\000\003\000\ -\003\000\003\000\002\000\005\000\004\000\005\000\003\000\003\000\ -\005\000\007\000\006\000\009\000\008\000\001\000\001\000\002\000\ -\001\000\001\000\002\000\002\000\002\000\002\000\001\000\001\000\ -\002\000\002\000\004\000\007\000\008\000\003\000\005\000\001\000\ -\002\000\005\000\004\000\001\000\003\000\002\000\002\000\005\000\ -\001\000\003\000\003\000\005\000\003\000\002\000\004\000\002\000\ -\005\000\003\000\003\000\003\000\001\000\001\000\003\000\002\000\ -\004\000\002\000\002\000\003\000\003\000\001\000\001\000\003\000\ -\002\000\004\000\002\000\002\000\002\000\001\000\000\000\003\000\ -\003\000\001\000\003\000\003\000\003\000\003\000\003\000\002\000\ -\001\000\003\000\003\000\001\000\003\000\003\000\003\000\003\000\ -\002\000\001\000\001\000\002\000\002\000\003\000\001\000\001\000\ -\001\000\001\000\003\000\001\000\001\000\002\000\001\000\003\000\ -\004\000\004\000\005\000\005\000\004\000\003\000\003\000\005\000\ -\005\000\004\000\005\000\007\000\007\000\001\000\003\000\003\000\ -\004\000\004\000\004\000\002\000\004\000\003\000\003\000\003\000\ -\003\000\003\000\003\000\001\000\003\000\001\000\002\000\004\000\ -\003\000\004\000\002\000\002\000\000\000\006\000\001\000\002\000\ -\008\000\001\000\002\000\008\000\007\000\003\000\000\000\000\000\ -\002\000\003\000\002\000\003\000\002\000\003\000\005\000\005\000\ -\005\000\007\000\000\000\001\000\003\000\002\000\001\000\003\000\ -\002\000\001\000\002\000\000\000\001\000\001\000\002\000\001\000\ -\003\000\001\000\001\000\002\000\003\000\004\000\001\000\007\000\ -\006\000\003\000\000\000\002\000\004\000\002\000\001\000\003\000\ -\001\000\001\000\002\000\005\000\007\000\009\000\009\000\001\000\ -\001\000\001\000\001\000\002\000\002\000\001\000\001\000\002\000\ -\003\000\004\000\004\000\005\000\001\000\003\000\006\000\005\000\ -\004\000\004\000\001\000\002\000\002\000\003\000\001\000\003\000\ -\001\000\003\000\001\000\002\000\001\000\004\000\001\000\006\000\ -\004\000\005\000\003\000\001\000\003\000\002\000\001\000\001\000\ -\002\000\004\000\003\000\002\000\002\000\003\000\005\000\003\000\ -\004\000\005\000\004\000\002\000\004\000\006\000\005\000\001\000\ -\001\000\001\000\003\000\001\000\001\000\005\000\002\000\001\000\ -\000\000\001\000\003\000\001\000\002\000\001\000\003\000\001\000\ -\003\000\001\000\003\000\002\000\002\000\001\000\001\000\001\000\ -\001\000\001\000\004\000\006\000\002\000\001\000\001\000\001\000\ -\001\000\001\000\001\000\002\000\002\000\002\000\002\000\001\000\ -\001\000\001\000\003\000\003\000\002\000\003\000\001\000\001\000\ -\001\000\001\000\001\000\001\000\003\000\004\000\003\000\004\000\ -\003\000\004\000\001\000\001\000\001\000\001\000\001\000\001\000\ -\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\ -\001\000\001\000\001\000\001\000\002\000\002\000\003\000\001\000\ -\001\000\001\000\003\000\001\000\005\000\002\000\002\000\003\000\ -\001\000\001\000\001\000\003\000\001\000\003\000\001\000\003\000\ -\001\000\003\000\004\000\001\000\003\000\001\000\003\000\001\000\ -\003\000\002\000\003\000\003\000\003\000\003\000\003\000\003\000\ -\002\000\000\000\001\000\000\000\001\000\001\000\001\000\000\000\ -\001\000\000\000\001\000\000\000\001\000\000\000\001\000\001\000\ -\002\000\002\000\000\000\001\000\000\000\001\000\000\000\001\000\ -\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\ -\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\ -\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\ -\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\ -\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\ -\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\ -\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\ -\003\000\004\000\004\000\004\000\000\000\002\000\000\000\002\000\ -\000\000\002\000\003\000\004\000\004\000\001\000\002\000\002\000\ -\002\000\004\000\002\000\002\000\002\000\002\000\002\000\002\000\ -\002\000" +type class_declaration = + { cty_params: type_expr list; + mutable cty_type: class_type; + cty_path: Path.t; + cty_new: type_expr option; + cty_variance: Variance.t list; + cty_loc: Location.t; + cty_attributes: Parsetree.attributes; + } -let yydefred = "\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\112\002\000\000\000\000\000\000\ -\169\002\114\002\000\000\000\000\000\000\000\000\000\000\111\002\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\217\002\218\002\000\000\000\000\ -\000\000\000\000\219\002\220\002\000\000\000\000\113\002\170\002\ -\000\000\000\000\175\002\030\001\000\000\000\000\035\003\000\000\ -\000\000\000\000\000\000\094\001\000\000\050\000\000\000\055\000\ -\056\000\000\000\058\000\059\000\060\000\000\000\062\000\063\000\ -\000\000\000\000\066\000\000\000\068\000\074\000\007\002\121\000\ -\000\000\203\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\031\001\032\001\162\002\112\001\226\001\000\000\000\000\000\000\ -\000\000\000\000\000\000\036\003\000\000\093\000\092\000\000\000\ -\100\000\101\000\000\000\000\000\106\000\000\000\095\000\096\000\ -\097\000\098\000\000\000\102\000\000\000\114\000\199\000\005\000\ -\000\000\037\003\000\000\000\000\000\000\007\000\000\000\013\000\ -\000\000\038\003\000\000\000\000\000\000\010\000\011\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\177\002\063\002\039\003\000\000\080\002\055\002\000\000\ -\064\002\051\002\000\000\000\000\000\000\040\003\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\122\002\000\000\000\000\ -\000\000\000\000\177\001\041\003\000\000\000\000\198\001\171\001\ -\000\000\000\000\115\002\175\001\176\001\000\000\161\001\000\000\ -\183\001\000\000\000\000\000\000\000\000\121\002\120\002\193\002\ -\079\001\033\001\034\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\133\001\000\000\083\001\110\002\000\000\ -\000\000\000\000\166\002\000\000\000\000\069\001\000\000\223\002\ -\224\002\225\002\226\002\227\002\228\002\229\002\230\002\231\002\ -\232\002\233\002\234\002\235\002\236\002\237\002\238\002\239\002\ -\240\002\241\002\242\002\243\002\244\002\245\002\246\002\247\002\ -\221\002\248\002\249\002\250\002\251\002\252\002\253\002\254\002\ -\255\002\000\003\001\003\002\003\003\003\004\003\005\003\006\003\ -\007\003\008\003\009\003\010\003\222\002\011\003\012\003\013\003\ -\014\003\015\003\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\125\002\152\002\151\002\000\000\150\002\000\000\153\002\ -\146\002\148\002\128\002\129\002\130\002\131\002\132\002\000\000\ -\147\002\000\000\000\000\000\000\149\002\155\002\000\000\000\000\ -\154\002\000\000\167\002\139\002\145\002\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\212\002\000\000\078\001\ -\052\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\ -\000\000\000\000\053\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\029\001\000\000\000\000\113\001\ -\000\000\227\001\000\000\075\000\000\000\122\000\000\000\204\000\ -\067\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\095\001\098\001\000\000\000\000\ -\000\000\012\001\013\001\000\000\000\000\000\000\000\000\090\000\ -\000\000\002\000\105\000\091\000\000\000\115\000\000\000\200\000\ -\000\000\003\000\004\000\006\000\009\000\014\000\000\000\000\000\ -\000\000\019\000\000\000\018\000\000\000\173\002\000\000\085\002\ -\000\000\000\000\214\002\000\000\076\002\000\000\106\002\068\002\ -\000\000\000\000\000\000\000\000\000\000\000\000\103\002\000\000\ -\000\000\000\000\000\000\000\000\000\000\062\002\184\002\000\000\ -\069\002\020\000\052\002\000\000\000\000\000\000\000\000\000\000\ -\000\000\065\002\021\000\000\000\000\000\171\002\000\000\000\000\ -\000\000\000\000\000\000\000\000\204\001\000\000\140\002\000\000\ -\144\002\000\000\000\000\142\002\127\002\000\000\117\002\116\002\ -\119\002\118\002\182\001\000\000\000\000\000\000\000\000\022\000\ -\160\001\000\000\172\001\173\001\000\000\000\000\000\000\000\000\ -\026\003\000\000\000\000\000\000\000\000\038\001\000\000\000\000\ -\205\002\000\000\160\002\000\000\000\000\161\002\156\002\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\218\000\180\001\181\001\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\035\000\037\000\000\000\000\000\000\000\ -\000\000\000\000\150\001\000\000\064\001\063\001\000\000\000\000\ -\082\001\081\001\000\000\139\001\000\000\000\000\000\000\000\000\ -\000\000\030\003\000\000\000\000\000\000\000\000\000\000\000\000\ -\195\002\000\000\168\002\000\000\000\000\000\000\126\002\000\000\ -\036\001\035\001\000\000\124\002\123\002\000\000\000\000\000\000\ -\000\000\000\000\080\001\000\000\000\000\151\000\000\000\000\000\ -\197\002\000\000\000\000\000\000\000\000\049\000\022\003\000\000\ -\000\000\000\000\000\000\000\000\176\002\163\002\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\209\000\000\000\000\000\230\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\103\001\ -\101\001\087\001\000\000\100\001\096\001\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\087\000\078\000\ -\180\002\000\000\000\000\000\000\000\000\000\000\000\000\191\002\ -\188\002\187\002\192\002\000\000\189\002\017\000\000\000\016\000\ -\012\000\084\002\000\000\082\002\000\000\087\002\072\002\000\000\ -\000\000\000\000\000\000\109\002\067\002\100\002\101\002\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\098\002\000\000\ -\174\002\178\002\000\000\000\000\000\000\070\002\159\001\174\001\ -\000\000\000\000\000\000\200\001\199\001\000\000\000\000\000\000\ -\000\000\000\000\191\001\000\000\190\001\153\001\152\001\158\001\ -\000\000\156\001\000\000\208\001\000\000\000\000\000\000\184\001\ -\000\000\179\001\000\000\027\003\024\003\000\000\000\000\000\000\ -\000\000\041\001\000\000\000\000\000\000\039\001\037\001\000\000\ -\000\000\000\000\157\002\000\000\158\002\000\000\000\000\000\000\ -\000\000\143\002\000\000\141\002\000\000\000\000\217\000\000\000\ -\219\000\000\000\220\000\214\000\225\000\000\000\212\000\000\000\ -\216\000\000\000\000\000\000\000\000\000\235\000\000\000\000\000\ -\121\001\000\000\000\000\000\000\000\000\000\000\000\000\069\000\ -\033\000\036\000\000\000\000\000\132\001\148\001\000\000\149\001\ -\000\000\000\000\135\001\000\000\140\001\000\000\074\001\073\001\ -\068\001\067\001\031\003\000\000\000\000\028\003\017\003\029\003\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\170\001\000\000\000\000\000\000\000\000\000\000\040\001\020\003\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\028\001\027\001\000\000\000\000\000\000\000\000\254\001\ -\253\001\000\000\244\001\000\000\000\000\000\000\000\000\000\000\ -\085\001\000\000\076\001\000\000\071\001\000\000\000\000\000\000\ -\043\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\108\000\088\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\015\000\000\000\073\002\088\002\ -\000\000\000\000\000\000\077\002\075\002\000\000\000\000\000\000\ -\049\002\000\000\000\000\000\000\000\000\000\000\066\002\000\000\ -\000\000\185\002\000\000\000\000\179\002\054\002\172\002\000\000\ -\000\000\000\000\217\001\000\000\202\001\201\001\205\001\203\001\ -\000\000\194\001\000\000\185\001\189\001\186\001\000\000\018\003\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\002\000\000\159\002\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\012\002\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\126\001\128\001\000\000\000\000\000\000\000\000\ -\028\000\000\000\000\000\041\000\000\000\040\000\000\000\034\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\114\001\ -\000\000\000\000\000\000\000\000\000\000\106\001\000\000\000\000\ -\000\000\000\000\000\000\169\001\000\000\000\000\138\002\136\002\ -\134\002\000\000\089\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\023\000\025\000\026\000\000\000\072\000\073\000\000\000\ -\148\000\000\000\000\000\000\000\000\000\000\000\000\000\159\000\ -\152\000\107\000\239\000\000\000\247\001\000\000\000\000\000\000\ -\000\000\250\001\246\001\000\000\000\000\019\003\066\001\065\001\ -\086\001\084\001\000\000\000\000\165\002\000\000\044\001\042\001\ -\210\000\115\001\000\000\000\000\000\000\000\000\000\000\062\001\ -\048\001\000\000\046\001\000\000\000\000\000\000\000\000\000\000\ -\054\001\000\000\050\001\000\000\052\001\000\000\000\000\000\000\ -\086\000\085\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\037\002\000\000\181\002\000\000\000\000\000\000\000\000\000\000\ -\112\000\000\000\000\000\000\000\083\002\090\002\000\000\074\002\ -\092\002\000\000\000\000\000\000\000\000\000\000\000\000\079\002\ -\071\002\000\000\099\002\000\000\216\002\216\001\000\000\195\001\ -\193\001\192\001\188\001\187\001\061\001\047\001\045\001\000\000\ -\000\000\000\000\053\001\049\001\051\001\000\000\000\000\129\000\ -\000\000\251\001\000\000\000\000\000\000\000\000\203\002\000\000\ -\000\000\017\002\000\000\000\000\000\000\000\000\009\002\000\000\ -\199\002\198\002\000\000\105\001\000\000\000\000\000\000\000\000\ -\000\000\000\000\215\000\000\000\000\000\125\001\123\001\000\000\ -\122\001\000\000\000\000\027\000\000\000\000\000\031\000\030\000\ -\000\000\034\003\232\000\010\002\000\000\000\000\000\000\000\000\ -\118\001\000\000\000\000\116\001\119\001\000\000\163\001\162\001\ -\168\001\000\000\166\001\000\000\211\001\000\000\110\001\000\000\ -\000\000\091\001\000\000\000\000\000\000\120\000\076\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\158\000\000\000\000\000\245\001\000\000\231\001\000\000\ -\249\001\222\001\245\000\077\001\075\001\072\001\070\001\000\000\ -\231\001\077\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\080\000\079\000\000\000\000\000\000\000\000\000\113\000\111\000\ -\000\000\000\000\000\000\000\000\000\000\086\002\078\002\093\002\ -\050\002\046\002\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\001\002\255\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\177\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\138\000\000\000\000\000\000\000\ -\140\000\123\000\127\000\000\000\016\002\019\002\013\002\000\000\ -\008\002\000\000\000\000\000\000\236\000\000\000\222\000\213\000\ -\211\000\000\000\127\001\000\000\000\000\000\000\000\000\048\000\ -\000\000\000\000\042\000\039\000\038\000\231\000\233\000\000\000\ -\000\000\000\000\000\000\107\001\000\000\090\001\000\000\000\000\ -\149\000\000\000\000\000\000\000\000\000\000\000\155\000\000\000\ -\154\000\248\001\000\000\237\001\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\002\002\003\002\000\000\000\000\201\002\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\060\001\000\000\056\001\000\000\058\001\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\038\002\ -\116\000\000\000\000\000\117\000\000\000\091\002\108\002\197\001\ -\196\001\059\001\055\001\057\001\000\000\182\002\181\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\180\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\137\000\000\000\000\000\224\001\225\001\000\000\ -\129\001\124\001\046\000\000\000\047\000\000\000\000\000\000\000\ -\000\000\117\001\111\001\024\000\000\000\156\000\000\000\157\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\238\001\ -\000\000\000\000\000\000\000\000\004\002\000\000\000\000\228\001\ -\000\000\000\000\000\000\024\002\025\002\026\002\027\002\093\001\ -\000\000\229\001\124\000\000\000\000\000\000\000\000\000\201\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\030\002\031\002\000\000\205\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\186\000\000\000\000\000\000\000\175\000\ -\000\000\000\000\133\000\000\000\000\000\146\000\000\000\145\000\ -\000\000\000\000\000\000\000\000\000\000\043\000\045\000\000\000\ -\000\000\120\001\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\005\002\000\000\ -\230\001\000\000\000\000\000\000\022\002\028\002\029\002\092\001\ -\206\000\000\000\000\000\000\000\040\002\044\002\231\001\110\000\ -\000\000\023\002\032\002\202\000\183\002\176\000\000\000\000\000\ -\000\000\179\000\178\000\000\000\173\000\000\000\000\000\131\000\ -\139\000\000\000\000\000\142\000\141\000\000\000\246\000\000\000\ -\000\000\108\001\160\000\153\000\000\000\000\000\000\000\168\000\ -\000\000\000\000\000\000\000\000\006\002\241\001\000\000\000\000\ -\239\001\000\000\000\000\000\000\000\000\033\002\000\000\000\000\ -\174\000\184\000\000\000\000\000\000\000\000\000\000\000\193\000\ -\187\000\000\000\000\000\000\000\144\000\143\000\000\000\044\000\ -\109\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\164\000\000\000\000\000\000\000\000\000\034\002\035\002\ -\000\000\000\000\000\000\000\000\000\000\192\000\172\000\000\000\ -\021\002\166\000\167\000\000\000\000\000\000\000\000\000\000\000\ -\165\000\242\001\036\002\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\169\000\ -\000\000\191\000\188\000\209\002\210\002\000\000\000\000\000\000\ -\000\000\189\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\170\000\190\000\000\000\000\000" +type class_type_declaration = + { clty_params: type_expr list; + clty_type: class_type; + clty_path: Path.t; + clty_variance: Variance.t list; + clty_loc: Location.t; + clty_attributes: Parsetree.attributes; + } -let yydgoto = "\008\000\ -\055\000\100\000\122\000\130\000\148\000\158\000\172\000\034\002\ -\101\000\123\000\131\000\057\000\072\001\126\000\058\000\134\000\ -\135\000\178\001\214\001\055\003\245\003\131\003\202\003\005\003\ -\059\000\233\001\012\002\101\001\060\000\061\000\132\003\062\000\ -\160\000\064\000\065\000\066\000\067\000\068\000\069\000\070\000\ -\071\000\072\000\073\000\074\000\075\000\076\000\077\000\025\001\ -\056\003\078\000\108\001\136\002\056\004\110\000\111\000\079\000\ -\113\000\114\000\115\000\116\000\117\000\063\001\112\003\118\000\ -\142\001\238\003\137\002\080\000\110\001\242\001\226\002\109\004\ -\007\005\251\004\253\002\169\003\211\005\008\005\123\001\179\001\ -\009\005\061\002\062\002\060\003\001\004\229\005\185\004\183\004\ -\051\005\081\000\112\004\155\004\070\006\066\005\156\004\187\003\ -\252\004\151\000\254\004\203\005\204\005\012\006\057\006\109\006\ -\105\006\241\005\119\000\144\001\082\000\112\001\019\001\190\003\ -\128\004\191\003\189\003\244\002\176\000\083\000\033\003\164\001\ -\000\003\254\002\084\000\085\000\086\000\123\004\087\000\088\000\ -\210\000\089\000\090\000\211\000\221\000\028\002\217\000\125\001\ -\126\001\121\002\037\003\091\000\071\006\039\003\181\000\092\000\ -\104\001\042\002\157\004\001\003\152\000\212\000\213\000\020\002\ -\218\000\182\000\183\000\042\003\184\000\153\000\185\000\201\001\ -\204\001\202\001\187\002\019\005\093\000\106\001\066\002\066\003\ -\191\004\071\005\067\005\113\004\067\003\006\004\068\003\011\004\ -\171\003\106\004\068\005\069\005\070\005\233\002\176\003\177\003\ -\114\004\115\004\128\003\171\005\193\005\172\005\173\005\174\005\ -\175\005\057\004\189\005\154\000\155\000\156\000\157\000\172\001\ -\154\002\155\002\156\002\074\004\121\003\071\004\173\001\174\001\ -\175\001\055\001\020\001\035\002\073\001" +(* Type expressions for the module language *) -let yysindex = "\141\009\ -\228\067\075\007\170\051\083\051\204\051\233\070\196\074\000\000\ -\155\005\110\002\080\074\155\005\000\000\184\003\155\005\155\005\ -\000\000\000\000\155\005\155\005\155\005\155\005\155\005\000\000\ -\155\005\225\076\083\004\058\068\146\068\170\063\170\063\014\004\ -\000\000\024\061\170\063\155\005\000\000\000\000\087\005\155\005\ -\155\005\134\255\000\000\000\000\080\074\228\067\000\000\000\000\ -\155\005\155\005\000\000\000\000\155\005\155\005\000\000\160\000\ -\229\255\096\018\048\000\000\000\151\080\000\000\108\004\000\000\ -\000\000\195\000\000\000\000\000\000\000\075\001\000\000\000\000\ -\110\001\176\001\000\000\229\255\000\000\000\000\000\000\000\000\ -\171\000\000\000\105\076\218\001\080\074\080\074\233\070\233\070\ -\000\000\000\000\000\000\000\000\000\000\184\003\155\005\155\005\ -\087\005\075\007\155\005\000\000\049\003\000\000\000\000\195\000\ -\000\000\000\000\176\001\229\255\000\000\075\007\000\000\000\000\ -\000\000\000\000\128\002\000\000\177\002\000\000\000\000\000\000\ -\110\002\000\000\137\002\160\002\229\255\000\000\143\005\000\000\ -\035\052\000\000\171\007\229\255\171\007\000\000\000\000\151\044\ -\000\004\085\255\082\013\202\003\041\048\204\051\206\003\110\002\ -\058\003\000\000\000\000\000\000\070\000\000\000\000\000\222\003\ -\000\000\000\000\030\002\126\001\097\003\000\000\071\005\108\004\ -\155\005\155\005\208\003\199\073\006\074\000\000\136\065\090\003\ -\235\005\069\004\000\000\000\000\175\000\106\004\000\000\000\000\ -\196\074\196\074\000\000\000\000\000\000\162\004\000\000\154\004\ -\000\000\170\063\170\063\116\004\080\074\000\000\000\000\000\000\ -\000\000\000\000\000\000\231\068\155\005\147\004\023\002\116\003\ -\196\074\244\072\000\004\233\070\143\002\080\074\000\000\002\005\ -\070\001\197\003\149\255\000\000\241\004\000\000\000\000\092\005\ -\146\004\046\005\000\000\110\081\057\005\000\000\057\005\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\141\067\192\005\141\067\155\005\155\005\134\255\ -\162\005\000\000\000\000\000\000\080\074\000\000\154\005\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\203\006\ -\000\000\000\000\000\000\131\001\000\000\000\000\000\000\000\000\ -\000\000\080\074\000\000\000\000\000\000\156\000\166\255\141\067\ -\233\070\155\005\184\005\058\003\001\006\000\000\155\005\000\000\ -\000\000\233\070\211\005\116\003\233\070\000\000\170\063\096\018\ -\229\255\155\005\000\000\075\006\209\005\233\070\233\070\233\070\ -\233\070\233\070\233\070\233\070\233\070\233\070\233\070\233\070\ -\233\070\233\070\233\070\233\070\233\070\233\070\233\070\233\070\ -\233\070\233\070\060\069\233\070\000\000\116\004\233\070\000\000\ -\116\004\000\000\116\004\000\000\116\004\000\000\116\004\000\000\ -\000\000\233\070\169\004\225\006\080\074\080\074\027\006\068\006\ -\080\074\027\006\165\076\043\002\000\000\000\000\233\070\043\002\ -\043\002\000\000\000\000\147\004\023\002\075\004\236\005\000\000\ -\211\005\000\000\000\000\000\000\116\004\000\000\116\004\000\000\ -\195\003\000\000\000\000\000\000\000\000\000\000\171\007\229\255\ -\171\007\000\000\171\007\000\000\136\012\000\000\130\005\000\000\ -\042\006\138\006\000\000\136\012\000\000\136\012\000\000\000\000\ -\000\000\134\006\060\006\133\006\170\040\170\040\000\000\204\051\ -\155\005\116\004\009\001\104\006\167\006\000\000\000\000\164\006\ -\000\000\000\000\000\000\216\041\077\004\081\006\098\006\204\051\ -\058\003\000\000\000\000\196\074\009\076\000\000\173\006\179\006\ -\206\255\107\006\070\005\109\006\000\000\109\006\000\000\090\003\ -\000\000\131\001\235\005\000\000\000\000\102\002\000\000\000\000\ -\000\000\000\000\000\000\033\002\031\066\092\066\153\066\000\000\ -\000\000\176\003\000\000\000\000\196\074\242\001\141\067\116\004\ -\000\000\116\004\043\002\058\005\231\006\000\000\041\003\147\004\ -\000\000\153\006\000\000\119\006\140\000\000\000\000\000\078\002\ -\188\077\208\006\178\003\009\076\059\064\125\002\245\005\050\006\ -\048\072\000\000\000\000\000\000\196\074\110\006\116\004\254\003\ -\116\004\026\007\205\006\000\000\000\000\043\002\255\007\208\003\ -\202\009\124\017\000\000\202\006\000\000\000\000\208\003\233\070\ -\000\000\000\000\068\006\000\000\233\070\104\255\211\004\013\082\ -\196\074\000\000\149\006\170\063\155\006\023\002\142\006\155\005\ -\000\000\116\075\000\000\157\006\161\006\175\006\000\000\143\002\ -\000\000\000\000\182\006\000\000\000\000\163\006\166\006\110\002\ -\158\006\084\003\000\000\196\074\120\003\000\000\186\006\189\006\ -\000\000\092\006\252\006\006\007\141\067\000\000\000\000\225\076\ -\038\005\145\069\233\069\135\061\000\000\000\000\235\081\235\081\ -\203\081\110\013\110\081\203\081\184\012\184\012\184\012\184\012\ -\053\004\255\006\255\006\184\012\053\004\053\004\203\081\255\006\ -\053\004\053\004\053\004\170\063\000\000\255\006\116\075\000\000\ -\092\006\207\006\147\004\147\004\110\081\233\070\233\070\233\070\ -\252\001\249\006\233\070\233\070\233\070\043\002\043\002\000\000\ -\000\000\000\000\065\004\000\000\000\000\203\081\153\006\151\255\ -\116\004\075\004\213\006\116\004\000\000\163\002\000\000\000\000\ -\000\000\175\002\216\006\041\004\092\006\221\006\147\004\000\000\ -\000\000\000\000\000\000\055\007\000\000\000\000\171\007\000\000\ -\000\000\000\000\253\255\000\000\078\007\000\000\000\000\136\012\ -\127\001\112\000\120\054\000\000\000\000\000\000\000\000\008\007\ -\075\004\204\051\015\005\204\051\204\051\135\004\000\000\239\006\ -\000\000\000\000\220\001\110\002\022\007\000\000\000\000\000\000\ -\194\004\204\051\070\007\000\000\000\000\203\004\196\074\174\000\ -\024\006\247\006\000\000\254\046\000\000\000\000\000\000\000\000\ -\141\002\000\000\091\007\000\000\035\002\067\074\226\065\000\000\ -\035\002\000\000\015\007\000\000\000\000\233\070\233\070\233\070\ -\160\005\000\000\233\070\233\070\233\070\000\000\000\000\153\006\ -\237\005\044\007\000\000\018\007\000\000\013\041\179\002\013\041\ -\116\004\000\000\114\007\000\000\204\051\233\070\000\000\051\007\ -\000\000\196\074\000\000\000\000\000\000\053\007\000\000\053\007\ -\000\000\216\041\170\064\233\070\048\072\000\000\182\255\111\007\ -\000\000\233\070\056\007\116\004\033\001\228\067\247\002\000\000\ -\000\000\000\000\017\007\000\000\000\000\000\000\108\255\000\000\ -\116\004\233\070\000\000\110\081\000\000\110\081\000\000\000\000\ -\000\000\000\000\000\000\116\004\247\000\000\000\000\000\000\000\ -\087\007\151\255\084\003\186\006\229\255\216\071\239\004\115\007\ -\000\000\110\007\068\007\069\007\071\007\139\001\000\000\000\000\ -\000\004\109\007\084\003\075\004\143\002\150\005\084\003\229\255\ -\210\002\000\000\000\000\167\001\183\002\018\000\237\005\000\000\ -\000\000\209\004\000\000\136\002\204\051\233\070\047\007\242\255\ -\000\000\251\004\000\000\057\005\000\000\057\005\046\007\131\001\ -\000\000\184\255\233\070\229\255\077\007\084\003\153\006\153\006\ -\212\080\151\001\192\000\194\255\245\006\233\070\011\078\043\078\ -\121\078\080\007\056\007\119\255\063\007\075\007\075\004\060\255\ -\000\000\000\000\028\005\131\007\075\004\186\006\205\005\229\255\ -\209\004\134\007\153\006\017\003\000\000\136\012\000\000\000\000\ -\204\051\218\000\144\007\000\000\000\000\110\002\111\001\116\004\ -\000\000\204\051\255\002\058\007\116\004\058\003\000\000\022\007\ -\081\007\000\000\216\041\048\007\000\000\000\000\000\000\116\004\ -\196\074\065\007\000\000\070\005\000\000\000\000\000\000\000\000\ -\087\001\000\000\129\255\000\000\000\000\000\000\053\003\000\000\ -\017\081\048\001\246\255\020\007\153\078\231\078\007\079\102\007\ -\129\001\082\007\000\000\129\072\000\000\092\007\000\000\095\007\ -\239\006\083\007\144\001\151\007\116\004\000\000\229\255\245\001\ -\102\000\051\007\084\007\108\006\150\007\150\007\165\007\093\007\ -\108\007\051\007\000\000\000\000\063\070\233\070\196\074\049\081\ -\000\000\201\003\233\070\000\000\075\004\000\000\150\003\000\000\ -\204\051\110\081\233\070\233\070\116\004\142\007\228\004\000\000\ -\162\015\233\070\025\065\021\072\164\007\000\000\152\002\214\066\ -\019\067\080\067\233\070\000\000\204\051\196\074\000\000\000\000\ -\000\000\122\000\000\000\196\074\075\004\229\255\229\255\107\001\ -\053\006\000\000\000\000\000\000\180\007\000\000\000\000\204\051\ -\000\000\116\004\134\255\116\004\134\255\134\255\229\255\000\000\ -\000\000\000\000\000\000\196\074\000\000\207\001\168\007\112\007\ -\110\002\000\000\000\000\151\006\175\007\000\000\000\000\000\000\ -\000\000\000\000\060\001\168\006\000\000\143\002\000\000\000\000\ -\000\000\000\000\168\007\229\255\137\007\139\007\147\007\000\000\ -\000\000\148\007\000\000\154\007\233\070\233\070\233\070\110\081\ -\000\000\157\007\000\000\158\007\000\000\159\007\199\007\033\006\ -\000\000\000\000\116\004\159\004\255\002\186\006\092\006\219\007\ -\000\000\000\000\000\000\075\004\255\002\183\002\098\002\211\007\ -\000\000\140\007\075\004\163\007\000\000\000\000\072\001\000\000\ -\000\000\172\255\000\000\204\051\110\002\138\007\022\007\000\000\ -\000\000\204\051\000\000\070\005\000\000\000\000\075\004\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\233\070\ -\233\070\233\070\000\000\000\000\000\000\202\007\237\005\000\000\ -\110\002\000\000\136\050\096\005\229\255\129\072\000\000\068\006\ -\141\007\000\000\092\007\216\041\009\002\229\255\000\000\135\007\ -\000\000\000\000\233\070\000\000\048\072\204\051\233\070\146\007\ -\149\007\204\051\000\000\233\070\152\007\000\000\000\000\162\007\ -\000\000\233\070\143\002\000\000\100\077\137\255\000\000\000\000\ -\116\004\000\000\000\000\000\000\233\070\233\070\051\007\142\001\ -\000\000\051\007\214\007\000\000\000\000\233\070\000\000\000\000\ -\000\000\141\002\000\000\091\007\000\000\035\002\000\000\121\002\ -\035\002\000\000\156\007\111\007\255\002\000\000\000\000\143\002\ -\075\004\248\003\204\051\116\004\233\070\116\004\229\255\116\004\ -\229\255\000\000\111\007\237\005\000\000\031\077\000\000\160\007\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\209\002\ -\000\000\000\000\129\072\215\007\233\070\233\070\233\070\094\079\ -\126\079\204\079\233\070\233\070\233\070\136\050\075\004\143\002\ -\000\000\000\000\148\006\208\003\060\255\163\002\000\000\000\000\ -\075\004\160\007\163\002\224\007\204\051\000\000\000\000\000\000\ -\000\000\000\000\116\004\022\007\059\000\236\079\058\080\090\080\ -\163\005\000\000\000\000\054\012\173\007\230\007\116\004\216\041\ -\190\007\000\000\231\007\116\004\186\007\000\000\190\002\116\004\ -\204\051\217\005\096\005\116\004\000\000\249\004\116\004\165\076\ -\000\000\000\000\000\000\246\007\000\000\000\000\000\000\247\007\ -\000\000\135\007\229\255\241\007\000\000\116\004\000\000\000\000\ -\000\000\116\004\000\000\048\072\233\070\110\081\053\006\000\000\ -\243\000\237\002\000\000\000\000\000\000\000\000\000\000\242\007\ -\204\051\172\007\233\070\000\000\233\070\000\000\053\006\100\005\ -\000\000\250\002\229\255\096\005\229\255\195\001\000\000\234\004\ -\000\000\000\000\023\002\000\000\127\049\148\014\097\047\000\000\ -\096\003\217\007\007\008\000\000\000\000\151\255\063\002\000\000\ -\150\255\078\003\063\002\229\255\163\005\110\081\110\081\110\081\ -\000\000\216\007\000\000\218\007\000\000\221\007\110\081\110\081\ -\110\081\229\255\255\002\053\006\081\006\081\006\043\005\000\000\ -\000\000\079\006\174\255\000\000\136\050\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\204\051\000\000\000\000\151\006\ -\229\002\190\001\222\003\134\255\216\041\208\007\203\007\014\008\ -\096\005\000\000\136\050\045\005\049\073\202\001\134\255\166\000\ -\001\006\096\005\000\000\165\076\120\054\000\000\000\000\233\070\ -\000\000\000\000\000\000\249\255\000\000\193\007\204\051\215\003\ -\021\072\000\000\000\000\000\000\204\051\000\000\025\001\000\000\ -\177\007\160\007\068\006\181\007\092\007\068\006\151\255\000\000\ -\116\004\007\008\160\007\092\007\000\000\116\004\204\051\000\000\ -\023\002\082\002\194\001\000\000\000\000\000\000\000\000\000\000\ -\201\007\000\000\000\000\151\006\233\070\233\070\233\070\000\000\ -\168\003\168\003\204\051\228\007\204\051\098\002\023\002\151\255\ -\248\001\000\000\000\000\229\255\000\000\053\005\068\005\116\004\ -\223\007\204\051\200\004\000\000\136\050\216\041\116\004\000\000\ -\000\000\217\072\000\000\058\003\116\004\000\000\136\050\000\000\ -\026\005\116\004\116\004\022\008\075\004\000\000\000\000\008\004\ -\233\070\000\000\116\004\238\007\229\255\068\006\068\006\156\072\ -\068\006\068\006\103\006\116\004\101\003\212\007\000\000\052\004\ -\000\000\246\002\179\002\116\004\000\000\000\000\000\000\000\000\ -\000\000\110\081\110\081\110\081\000\000\000\000\000\000\000\000\ -\151\255\000\000\000\000\000\000\000\000\000\000\186\006\136\050\ -\103\004\000\000\000\000\158\001\000\000\234\007\096\005\000\000\ -\000\000\186\006\159\000\000\000\000\000\222\007\000\000\227\007\ -\233\070\000\000\000\000\000\000\048\008\052\008\140\048\000\000\ -\054\008\056\008\233\070\050\008\000\000\000\000\092\007\007\008\ -\000\000\204\051\179\002\116\004\116\004\000\000\060\008\036\005\ -\000\000\000\000\116\004\116\004\116\004\116\004\229\255\000\000\ -\000\000\136\050\116\004\088\005\000\000\000\000\116\004\000\000\ -\000\000\120\054\120\054\051\007\116\004\053\008\238\001\204\051\ -\204\051\000\000\233\070\240\007\116\004\116\004\000\000\000\000\ -\163\005\204\051\163\005\220\003\033\003\000\000\000\000\096\005\ -\000\000\000\000\000\000\062\008\233\070\204\051\116\004\116\004\ -\000\000\000\000\000\000\116\004\229\255\151\006\225\007\250\007\ -\068\006\147\004\092\007\073\008\229\255\116\004\204\051\000\000\ -\116\004\000\000\000\000\000\000\000\000\074\008\068\006\068\006\ -\204\051\000\000\057\004\120\054\077\008\079\008\116\004\233\070\ -\229\255\204\051\204\051\000\000\000\000\116\004\116\004" +type module_type = + Mty_ident of Path.t + | Mty_signature of signature + | Mty_functor of Ident.t * module_type option * module_type + | Mty_alias of alias_presence * Path.t -let yyrindex = "\000\000\ -\094\009\095\009\000\008\000\000\000\000\000\000\000\000\000\000\ -\232\076\000\000\000\000\148\070\000\000\022\003\029\003\171\006\ -\000\000\000\000\001\075\076\073\135\074\062\071\230\002\000\000\ -\232\076\000\000\000\000\000\000\000\000\000\000\000\000\028\075\ -\012\019\000\000\000\000\062\071\000\000\000\000\246\005\069\005\ -\015\002\042\004\000\000\000\000\000\000\099\000\000\000\000\000\ -\062\071\149\008\000\000\000\000\171\006\062\071\000\000\000\000\ -\176\040\099\000\128\019\000\000\016\046\000\000\149\013\000\000\ -\000\000\114\015\000\000\000\000\000\000\113\059\000\000\000\000\ -\122\059\171\059\000\000\215\059\000\000\000\000\000\000\000\000\ -\000\000\000\000\058\027\174\027\081\026\197\026\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\022\003\029\003\131\004\ -\246\005\116\000\149\008\000\000\000\000\000\000\000\000\222\041\ -\000\000\000\000\065\042\012\043\000\000\116\000\000\000\000\000\ -\000\000\000\000\111\043\000\000\058\044\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\002\008\000\000\000\008\000\000\ -\000\000\000\000\000\000\247\008\000\000\000\000\000\000\000\000\ -\134\014\134\014\000\000\079\010\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\247\010\ -\000\000\000\000\000\000\060\049\114\018\000\000\000\000\000\000\ -\001\075\036\076\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\150\052\000\000\000\000\ -\253\002\225\005\000\000\000\000\000\000\139\006\000\000\002\053\ -\000\000\000\000\000\000\165\060\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\022\003\239\255\000\000\000\000\ -\000\000\000\000\089\075\000\000\000\000\000\000\067\002\124\002\ -\000\000\227\255\000\000\000\000\037\000\000\000\000\000\170\255\ -\000\000\142\005\000\000\117\255\095\001\000\000\199\006\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\008\008\052\060\008\008\029\003\251\007\042\004\ -\177\075\000\000\000\000\000\000\167\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\076\062\162\062\230\002\000\000\000\000\248\062\078\063\ -\000\000\185\000\000\000\000\000\000\000\000\000\000\000\008\008\ -\000\000\069\005\000\000\000\000\002\004\000\000\251\007\000\000\ -\000\000\000\000\079\005\000\000\000\000\000\000\000\000\099\000\ -\222\055\028\075\000\000\149\013\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\220\035\000\000\000\000\204\075\000\000\000\000\ -\212\004\000\000\252\007\000\000\108\003\000\000\108\003\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\237\017\244\024\000\000\000\000\000\000\034\028\ -\151\028\000\000\000\000\239\255\000\000\000\000\000\000\000\000\ -\079\005\000\000\000\000\000\000\252\007\000\000\108\003\000\000\ -\059\014\000\000\000\000\000\000\000\000\000\000\000\000\247\008\ -\000\000\000\000\000\000\000\000\000\000\000\000\153\001\000\000\ -\095\008\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\207\255\000\000\076\008\000\000\078\008\084\008\000\000\000\000\ -\131\004\096\001\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\036\000\ -\000\000\146\000\068\000\095\001\000\000\199\006\000\000\235\000\ -\000\000\251\007\238\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\008\008\165\060\ -\000\000\229\050\011\029\000\000\000\000\000\000\000\000\239\255\ -\000\000\045\008\000\000\000\000\000\000\000\000\000\000\221\057\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\057\008\000\000\ -\246\061\215\059\064\004\000\000\000\000\127\029\000\000\000\000\ -\000\000\000\000\000\000\146\255\000\000\000\000\228\000\000\000\ -\000\000\000\000\148\005\000\000\090\001\000\000\000\000\018\008\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\251\007\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\175\004\000\000\000\000\008\008\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\138\038\242\038\ -\090\039\034\016\245\040\194\039\080\036\197\036\057\037\173\037\ -\034\033\244\029\104\030\034\038\150\033\011\034\042\040\220\030\ -\127\034\243\034\104\035\000\000\000\000\081\031\000\000\000\000\ -\085\001\000\000\239\255\239\255\088\041\000\000\000\000\000\000\ -\000\000\244\019\000\000\000\000\000\000\104\025\221\025\000\000\ -\000\000\000\000\128\024\000\000\000\000\146\040\045\008\117\011\ -\057\008\000\000\000\000\124\012\096\007\012\043\000\000\000\000\ -\000\000\000\000\000\000\000\000\175\004\000\000\239\255\000\000\ -\000\000\000\000\000\000\061\014\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\173\061\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\230\046\000\000\000\000\000\000\000\000\073\047\ -\000\000\000\000\000\000\000\000\172\047\000\000\000\000\000\000\ -\000\000\000\000\156\255\000\000\000\000\245\000\090\001\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\016\001\000\000\067\006\000\000\202\000\000\000\000\000\000\000\ -\118\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\045\008\ -\023\008\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\139\058\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\197\031\ -\000\000\000\000\000\000\147\071\000\000\204\005\000\000\000\000\ -\000\000\000\000\000\000\086\002\000\000\000\000\217\255\000\000\ -\067\000\000\000\000\000\006\000\000\000\144\000\000\000\000\000\ -\000\000\000\000\000\000\155\006\029\008\000\000\000\000\000\000\ -\000\000\170\005\000\000\000\000\230\057\028\007\000\000\188\006\ -\000\000\019\004\003\001\018\001\062\001\000\000\000\000\000\000\ -\089\075\204\058\000\000\000\000\000\000\000\000\000\000\215\059\ -\000\000\000\000\000\000\216\005\215\059\089\075\159\005\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\095\001\000\000\199\006\000\000\230\002\ -\000\000\000\000\000\000\230\057\000\000\000\000\045\008\045\008\ -\000\000\142\081\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\219\005\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\012\043\ -\000\000\000\000\045\008\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\230\001\ -\000\000\000\000\008\001\000\000\147\001\000\000\000\000\017\048\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\182\000\ -\000\000\002\001\000\000\217\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\069\008\187\054\000\000\ -\106\055\000\000\000\000\189\007\139\058\000\000\215\059\000\000\ -\000\000\009\000\000\000\250\255\040\008\040\008\254\255\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\120\046\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\172\000\000\000\000\000\083\008\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\215\059\253\058\000\000\ -\138\008\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\148\077\018\005\147\071\079\002\134\003\168\004\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\182\009\000\000\ -\000\000\000\000\000\000\215\059\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\082\056\253\058\000\000\000\000\105\020\000\000\ -\000\000\221\020\000\000\081\021\000\000\000\000\000\000\192\041\ -\000\000\198\021\000\000\058\022\000\000\174\022\000\000\000\000\ -\000\000\000\000\252\004\000\000\197\006\000\000\175\004\246\006\ -\000\000\089\008\000\000\000\000\252\052\012\043\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\153\001\000\000\ -\000\000\000\000\238\063\000\000\000\000\099\008\116\048\000\000\ -\000\000\000\000\000\000\230\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\023\008\000\000\ -\000\000\000\000\000\000\000\000\253\058\000\000\000\000\000\000\ -\000\000\000\000\085\005\000\000\000\000\215\059\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\197\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\152\006\000\000\170\003\000\000\032\006\000\000\000\000\ -\117\006\000\000\000\000\057\032\007\059\000\000\000\000\000\000\ -\000\000\000\000\000\000\248\005\000\000\038\004\168\004\117\004\ -\168\004\000\000\174\032\159\005\000\000\087\008\000\000\208\255\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\019\041\000\000\000\000\ -\000\000\208\255\019\041\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\144\016\215\048\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\037\015\059\008\000\000\ -\000\000\236\054\000\000\189\011\000\000\000\000\000\000\137\073\ -\000\000\028\075\000\000\047\003\000\000\000\000\027\058\110\053\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\069\059\215\059\000\000\000\000\058\000\000\000\000\000\ -\000\000\017\002\000\000\000\000\000\000\035\042\001\017\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\131\056\000\000\ -\000\000\000\000\168\004\000\000\168\004\072\008\000\000\069\008\ -\000\000\000\000\000\000\000\000\000\000\000\000\100\008\245\011\ -\184\056\000\000\237\056\000\000\000\000\147\016\253\058\000\000\ -\000\000\000\000\253\058\253\058\000\000\134\042\238\042\081\043\ -\000\000\035\023\000\000\151\023\000\000\011\024\180\043\028\044\ -\127\044\019\041\079\017\116\050\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\253\058\ -\000\000\000\000\119\002\146\003\000\000\194\002\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\146\003\000\000\ -\002\004\000\000\000\000\182\053\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\020\006\000\000\ -\094\008\072\008\000\000\101\008\069\008\000\000\147\016\000\000\ -\056\057\109\057\162\003\069\008\000\000\024\056\000\000\000\000\ -\000\000\234\012\215\059\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\253\058\000\000\000\000\000\000\000\000\ -\136\049\194\049\000\000\010\078\000\000\000\000\000\000\118\057\ -\012\043\000\000\000\000\019\041\000\000\000\000\000\000\252\007\ -\000\000\000\000\000\000\000\000\000\000\000\000\080\058\000\000\ -\030\055\000\000\000\000\000\000\252\007\000\000\000\000\000\000\ -\000\000\240\053\219\002\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\172\006\000\000\168\004\000\000\000\000\000\000\ -\000\000\000\000\000\000\024\056\000\000\000\000\000\000\000\000\ -\000\000\234\012\000\000\129\058\000\000\000\000\000\000\000\000\ -\000\000\226\044\074\045\173\045\000\000\000\000\000\000\000\000\ -\118\057\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\253\005\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\046\008\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\069\008\168\057\ -\000\000\000\000\000\000\129\058\129\058\000\000\252\049\000\000\ -\000\000\000\000\148\077\223\005\038\004\117\004\005\004\000\000\ -\000\000\000\000\042\054\000\000\000\000\000\000\111\005\000\000\ -\000\000\000\000\000\000\000\000\193\004\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\058\050\129\058\000\000\000\000\ -\000\000\000\000\000\000\104\008\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\077\009\186\010\ -\000\000\000\000\000\000\164\055\005\004\005\004\107\008\109\008\ -\000\000\110\008\069\008\000\000\005\004\100\054\000\000\000\000\ -\164\005\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\095\004\000\000\ -\005\004\000\000\000\000\000\000\000\000\050\009\222\010" +and alias_presence = + | Mta_present + | Mta_absent -let yygindex = "\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\033\000\ -\215\255\000\000\089\000\072\000\013\006\049\009\060\000\000\000\ -\214\255\126\000\233\001\099\253\000\000\217\254\078\006\071\255\ -\127\008\195\013\029\254\247\255\098\004\194\013\074\252\051\000\ -\093\000\023\000\026\000\034\000\000\000\000\000\000\000\000\000\ -\045\000\047\000\000\000\049\000\000\000\002\000\013\000\088\007\ -\093\001\000\000\000\000\000\000\000\000\000\000\000\000\052\000\ -\000\000\000\000\000\000\000\000\000\000\014\255\005\252\000\000\ -\000\000\000\000\027\000\000\000\000\000\142\254\251\253\032\252\ -\115\251\156\251\083\255\000\000\226\003\000\000\176\004\175\251\ -\113\255\059\004\000\000\000\000\000\000\000\000\000\000\000\000\ -\107\003\015\000\026\251\047\255\103\253\199\251\017\253\135\252\ -\095\251\043\254\247\003\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\046\000\200\006\ -\003\006\006\006\000\000\000\000\078\255\022\000\000\000\168\255\ -\184\001\059\253\000\254\108\010\156\012\000\000\000\000\000\000\ -\110\255\049\008\009\013\119\007\031\000\094\255\207\000\159\254\ -\000\000\080\008\100\007\216\011\115\253\000\000\078\254\000\000\ -\000\000\000\000\050\004\009\006\163\255\164\004\000\000\000\000\ -\000\000\000\000\073\000\000\000\235\007\157\255\254\007\021\007\ -\045\009\000\000\000\000\198\004\000\000\000\000\085\008\213\253\ -\190\005\138\251\021\251\213\251\011\253\000\000\097\253\000\000\ -\122\005\000\000\000\000\046\251\066\255\001\253\251\006\041\008\ -\000\000\000\000\099\004\000\000\000\000\137\004\078\252\000\000\ -\066\004\017\005\000\000\146\253\235\012\133\255\000\000\071\006\ -\128\255\220\254\141\255\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\082\255\000\000" +and signature = signature_item list -let yytablesize = 21372 -let yytable = "\188\000\ -\019\002\185\001\188\000\108\000\188\000\188\000\188\000\161\001\ -\248\001\188\000\188\000\188\000\188\000\188\000\109\000\188\000\ -\200\001\127\002\180\001\010\002\162\001\127\003\188\000\002\002\ -\102\000\125\002\188\000\103\000\001\002\188\000\188\000\188\000\ -\193\000\056\000\213\003\104\000\192\000\040\002\009\003\188\000\ -\188\000\216\000\160\001\188\000\188\000\171\001\105\000\209\000\ -\106\000\166\001\107\000\171\004\129\003\112\000\222\003\196\003\ -\136\001\194\001\030\002\223\000\031\002\085\003\127\000\133\000\ -\124\004\170\003\064\001\224\004\140\001\186\001\219\001\014\005\ -\133\004\005\004\125\000\132\000\021\001\159\000\065\001\112\005\ -\056\001\158\005\075\005\162\005\188\000\188\000\188\000\188\000\ -\154\001\188\000\156\001\124\000\163\001\063\000\134\002\063\000\ -\063\000\113\003\051\000\108\000\051\002\201\003\037\002\023\003\ -\124\001\054\001\128\001\129\001\075\001\090\003\109\000\108\000\ -\165\005\090\005\005\002\089\000\143\001\128\005\049\004\040\003\ -\102\000\098\003\109\000\103\000\209\003\224\002\143\001\161\002\ -\089\004\162\002\149\000\104\000\102\000\054\004\073\005\103\000\ -\036\005\054\002\063\000\187\001\062\001\011\005\105\000\104\000\ -\106\000\138\001\107\000\145\001\021\002\112\000\076\001\188\000\ -\188\000\170\001\105\000\219\001\106\000\169\005\107\000\070\001\ -\237\004\112\000\114\005\225\001\230\002\052\002\151\005\055\004\ -\099\005\142\001\182\001\180\005\059\002\186\000\224\001\126\005\ -\165\001\010\000\234\001\243\001\040\003\191\005\234\005\023\004\ -\186\000\220\001\127\000\188\000\153\001\221\001\133\000\103\003\ -\133\000\035\004\186\000\024\003\222\001\201\003\128\002\223\001\ -\152\001\207\001\186\000\243\001\244\001\188\002\142\001\165\005\ -\143\001\103\003\235\001\143\001\050\004\090\003\245\001\200\002\ -\145\001\151\001\168\003\076\001\110\002\063\000\090\004\076\001\ -\114\002\076\001\151\001\014\002\244\001\232\002\037\005\231\001\ -\232\001\104\003\076\005\207\005\138\001\200\002\245\001\022\002\ -\138\001\015\004\173\002\145\001\218\005\035\004\219\001\186\000\ -\087\003\088\003\219\001\104\003\155\005\151\001\197\003\246\001\ -\196\005\040\006\247\001\053\002\118\003\141\001\200\002\231\004\ -\142\001\221\005\070\004\239\001\188\000\188\000\173\002\157\001\ -\200\002\003\004\184\002\006\002\226\000\024\004\208\005\246\001\ -\223\000\163\001\247\001\114\005\115\003\040\005\104\001\036\004\ -\042\005\009\003\188\000\221\001\134\001\204\002\198\003\071\001\ -\189\002\192\002\141\001\193\002\140\004\173\002\204\002\173\002\ -\188\000\182\002\193\000\145\001\168\002\188\000\145\001\145\001\ -\211\002\200\002\104\005\173\002\200\002\151\001\221\001\160\001\ -\188\000\151\001\147\001\212\001\181\002\077\001\160\001\064\001\ -\160\001\239\002\009\003\152\004\016\004\212\001\002\002\171\001\ -\171\001\029\004\030\004\095\004\227\000\165\005\222\005\226\000\ -\119\003\218\002\100\003\223\000\234\001\147\001\175\002\234\001\ -\231\005\234\001\051\000\234\001\141\001\234\001\104\001\034\003\ -\013\006\237\005\140\005\142\005\150\002\068\004\152\002\063\000\ -\153\002\063\000\019\006\089\000\069\002\206\001\046\003\118\003\ -\238\005\170\004\070\002\122\003\051\000\121\004\221\001\134\001\ -\055\002\059\006\221\001\234\001\120\006\234\001\122\002\186\000\ -\047\006\064\002\118\002\119\002\068\002\089\000\123\002\144\001\ -\124\001\214\001\140\004\177\005\063\000\234\001\071\003\227\000\ -\105\005\144\001\228\002\049\002\129\002\147\001\061\006\212\001\ -\147\001\147\001\212\001\049\006\076\001\214\005\140\002\188\000\ -\187\001\017\002\101\002\137\001\018\002\149\003\104\002\100\006\ -\195\005\102\006\220\001\215\005\030\000\220\001\221\001\021\005\ -\127\002\190\000\130\002\170\001\170\001\222\001\051\000\033\004\ -\223\001\225\001\000\006\131\002\146\001\105\001\058\005\170\003\ -\188\000\207\001\110\006\125\003\225\001\207\001\122\004\089\000\ -\220\001\207\001\133\000\207\001\133\000\087\006\133\000\207\001\ -\213\001\225\001\225\001\207\001\132\002\233\004\234\001\146\001\ -\234\001\118\003\213\001\136\001\207\001\218\001\133\002\186\000\ -\114\001\229\002\143\002\144\001\214\001\141\002\144\001\173\000\ -\186\000\225\001\139\005\076\001\215\001\076\001\027\003\076\001\ -\246\005\050\002\220\001\076\006\062\006\234\001\221\001\234\001\ -\010\003\215\002\137\002\216\005\140\002\222\001\137\001\081\002\ -\223\001\150\003\137\001\220\004\240\003\009\003\003\006\157\001\ -\220\001\135\002\207\001\157\001\220\001\129\002\127\002\157\001\ -\081\002\157\001\170\002\034\004\228\005\157\001\188\000\146\001\ -\204\003\108\000\146\001\146\001\207\001\207\001\024\006\207\001\ -\207\001\216\000\157\001\200\001\109\000\030\000\205\003\033\004\ -\136\003\137\003\190\000\130\002\213\001\072\004\102\000\213\001\ -\186\000\103\000\207\001\196\004\131\002\133\002\136\001\053\004\ -\218\001\104\000\160\001\063\000\218\001\061\004\166\005\135\003\ -\143\002\229\004\002\002\141\002\105\000\107\001\106\000\215\001\ -\107\000\031\003\050\003\112\000\221\003\132\002\137\005\216\000\ -\157\001\216\002\186\000\236\001\215\002\209\000\215\002\133\002\ -\137\002\007\003\186\000\216\002\087\004\081\002\171\002\211\003\ -\076\003\078\003\157\001\157\001\117\003\157\001\157\001\135\002\ -\109\001\096\002\041\003\002\002\237\001\206\001\102\005\234\001\ -\220\003\206\001\234\001\241\003\106\003\206\001\206\003\206\001\ -\157\001\191\001\047\002\206\001\076\004\176\004\118\003\206\001\ -\175\003\186\000\175\002\094\004\203\001\203\001\015\003\017\003\ -\206\001\083\003\103\004\082\003\243\001\253\004\032\004\197\004\ -\234\003\227\001\228\001\133\002\193\003\028\003\031\001\236\005\ -\023\003\063\000\123\003\041\005\097\002\142\004\120\001\121\001\ -\127\001\019\004\244\005\020\004\186\000\225\001\252\001\041\003\ -\051\006\251\001\111\001\103\003\088\004\216\002\091\003\092\003\ -\016\002\250\003\215\002\096\002\023\003\096\002\206\001\225\001\ -\244\005\225\001\252\001\225\001\186\000\173\004\192\001\225\001\ -\077\004\169\005\092\006\007\003\186\000\052\006\142\003\170\002\ -\206\001\206\001\133\000\206\001\206\001\187\000\251\003\252\003\ -\236\003\031\000\124\003\170\002\104\004\104\003\008\004\234\001\ -\188\004\035\000\031\000\053\006\009\003\004\004\206\001\077\004\ -\235\003\021\003\035\000\127\001\253\003\051\001\097\002\086\004\ -\097\002\140\003\044\006\076\001\023\003\225\001\081\004\127\003\ -\032\006\002\002\234\001\010\003\180\001\013\000\110\004\191\005\ -\253\004\044\006\069\004\094\006\071\001\187\001\079\004\187\001\ -\180\004\023\003\182\004\184\004\054\006\066\004\025\003\120\004\ -\018\000\185\002\187\001\225\001\222\004\254\003\129\003\074\003\ -\160\001\199\005\153\005\227\004\190\001\228\003\162\003\163\003\ -\198\002\025\003\119\005\024\000\010\003\212\005\207\003\133\003\ -\025\003\002\002\093\003\224\000\189\004\083\004\220\003\225\001\ -\138\001\222\001\154\005\189\001\243\001\185\003\186\000\144\003\ -\168\000\141\003\071\001\009\003\052\004\255\003\025\003\025\003\ -\236\001\155\003\171\002\195\003\023\003\169\000\188\000\077\004\ -\000\004\016\005\025\003\009\003\253\005\244\001\255\005\025\003\ -\171\002\167\005\025\003\171\002\025\003\172\002\047\000\245\001\ -\122\002\237\001\106\003\230\002\200\004\171\002\190\001\230\002\ -\166\000\249\001\063\000\172\002\186\000\195\002\172\002\108\000\ -\231\002\220\001\184\003\122\002\243\005\221\001\224\000\109\003\ -\172\002\122\002\109\000\196\002\222\001\077\002\234\001\223\001\ -\009\003\106\003\094\002\187\001\102\000\025\003\085\002\103\000\ -\246\001\071\001\141\001\247\001\122\002\059\004\187\001\104\000\ -\094\002\048\005\225\001\120\001\121\001\013\004\211\002\253\004\ -\211\002\187\001\105\000\045\005\106\000\225\001\107\000\159\004\ -\075\004\112\000\025\004\222\001\232\002\171\002\223\001\201\005\ -\232\002\171\002\111\003\122\002\122\002\253\004\211\002\186\000\ -\090\006\091\006\164\002\234\001\183\002\190\000\187\001\091\005\ -\172\002\007\002\225\001\143\001\172\002\122\002\122\002\122\002\ -\094\002\098\005\186\000\002\002\241\002\242\002\211\002\094\002\ -\110\004\185\000\012\004\197\002\107\003\201\002\203\002\205\002\ -\122\002\030\000\002\002\234\001\011\003\209\002\186\000\008\002\ -\017\000\031\005\094\002\124\005\185\000\220\001\236\004\166\000\ -\249\001\221\001\191\000\185\000\164\002\164\002\074\005\248\003\ -\222\001\009\004\129\006\223\001\186\000\071\001\106\003\010\003\ -\146\001\178\003\243\002\103\003\141\005\255\002\164\002\190\001\ -\234\001\185\000\234\001\179\003\009\002\010\004\047\005\253\004\ -\014\006\071\001\198\005\051\000\180\001\185\000\190\001\147\001\ -\180\001\253\004\187\001\230\002\180\001\185\000\180\001\185\000\ -\025\003\029\003\180\001\180\001\135\004\136\004\180\001\129\002\ -\043\006\007\003\186\000\186\000\149\005\104\003\015\005\180\001\ -\002\002\007\002\146\004\147\004\048\000\110\004\092\005\051\000\ -\025\003\153\004\125\002\193\004\057\003\190\001\025\003\030\000\ -\222\002\234\001\167\004\106\003\190\000\130\002\023\003\249\003\ -\185\000\030\000\253\004\106\003\091\004\023\003\131\002\008\002\ -\220\001\023\003\025\003\186\000\221\001\234\001\180\001\029\000\ -\186\000\023\003\223\002\222\001\232\002\180\001\223\001\103\003\ -\023\003\095\005\225\001\025\003\025\003\176\005\145\004\132\002\ -\166\000\249\001\025\003\025\003\208\003\025\003\015\003\180\001\ -\180\001\133\002\180\001\180\001\009\002\025\003\023\003\023\003\ -\215\000\052\003\168\004\051\000\253\004\004\003\150\000\234\004\ -\175\000\002\002\023\003\106\006\059\005\180\001\053\003\023\003\ -\129\002\104\003\023\003\161\001\023\003\178\004\186\000\058\003\ -\215\001\183\001\163\005\038\006\159\005\077\002\012\005\214\003\ -\162\001\200\005\243\001\243\004\106\003\025\003\025\003\187\001\ -\030\000\025\003\170\005\216\001\213\005\190\000\130\002\239\003\ -\107\006\059\003\092\004\246\003\054\003\143\004\115\005\131\002\ -\225\001\039\006\225\001\244\001\225\001\023\003\187\001\225\001\ -\158\001\186\000\023\003\106\003\192\005\245\001\051\000\148\003\ -\187\001\200\002\234\001\023\003\234\001\165\001\234\001\144\004\ -\132\002\165\001\028\004\166\000\249\001\220\001\203\001\159\003\ -\200\002\221\001\133\002\165\001\161\001\140\003\010\003\200\002\ -\222\001\193\001\020\005\223\001\165\001\211\002\023\005\211\002\ -\006\005\162\001\002\002\027\005\238\002\146\000\246\001\210\005\ -\211\002\247\001\017\002\211\002\106\003\018\002\200\002\176\001\ -\200\002\106\003\188\003\023\003\038\005\039\005\002\002\160\001\ -\144\002\234\001\200\002\220\003\163\000\044\005\206\002\165\000\ -\190\001\150\000\242\005\165\001\150\000\234\001\150\000\150\000\ -\207\002\225\005\122\005\186\000\145\002\211\002\234\001\119\006\ -\188\000\186\000\234\001\022\005\053\005\131\005\211\002\026\005\ -\001\006\150\000\166\000\249\001\021\003\175\000\175\000\163\001\ -\175\000\054\003\187\000\200\002\187\001\181\001\200\002\198\001\ -\187\001\139\004\175\000\175\000\150\000\010\003\164\001\021\003\ -\186\000\036\006\164\001\150\000\077\002\124\001\021\003\002\002\ -\007\002\164\001\025\006\197\000\210\005\010\003\106\003\146\002\ -\187\001\022\001\175\000\175\000\147\002\164\001\013\002\051\000\ -\050\005\150\000\150\000\103\006\021\003\002\002\109\003\187\001\ -\030\000\186\000\220\003\065\005\051\000\150\000\008\002\029\000\ -\021\003\188\001\029\000\110\003\017\006\150\000\195\001\150\000\ -\021\003\186\000\021\003\104\006\029\000\029\000\042\006\186\000\ -\029\000\106\003\010\003\128\006\164\001\049\005\236\001\023\001\ -\106\003\029\000\029\000\029\000\029\000\024\001\196\000\006\005\ -\187\000\089\001\090\001\009\002\138\005\023\003\122\005\029\000\ -\029\000\111\003\051\000\211\002\004\003\129\002\102\001\237\001\ -\150\000\196\000\146\005\021\003\147\005\186\000\131\005\214\000\ -\196\000\084\004\186\000\029\000\211\002\023\003\029\000\226\001\ -\029\000\029\000\029\000\029\000\158\001\030\000\187\001\095\001\ -\029\000\029\000\190\000\130\002\177\002\131\005\196\000\029\000\ -\006\005\025\002\215\000\103\001\131\002\023\003\211\002\187\001\ -\100\001\124\001\196\000\029\000\234\001\029\000\217\004\029\000\ -\029\000\196\000\196\000\172\004\196\000\025\003\144\005\021\003\ -\186\000\232\005\122\005\029\000\235\005\132\002\029\000\255\002\ -\230\001\146\000\029\000\229\001\023\003\186\000\026\002\133\002\ -\218\004\178\002\021\003\187\004\161\005\025\003\234\001\023\003\ -\047\002\021\003\025\003\025\003\050\006\131\005\138\003\010\006\ -\162\004\164\004\166\004\234\001\025\003\196\000\169\004\220\005\ -\131\005\234\001\025\003\047\002\255\002\006\005\187\001\021\003\ -\021\003\187\001\047\002\047\002\026\003\110\002\006\005\111\002\ -\181\001\011\006\234\001\021\003\023\003\025\003\187\001\135\002\ -\198\001\112\002\234\001\021\003\255\002\021\003\243\001\025\003\ -\047\002\047\002\223\003\077\002\029\006\030\006\224\003\033\006\ -\034\006\011\003\017\004\102\001\047\002\225\003\150\000\187\001\ -\226\003\143\003\241\001\047\002\047\002\150\000\047\002\150\000\ -\252\001\227\003\198\001\150\004\224\005\055\006\150\000\150\000\ -\007\004\150\000\227\005\023\003\023\003\051\000\021\003\015\002\ -\056\006\020\006\023\003\243\001\252\001\150\000\023\003\018\004\ -\130\005\150\000\234\001\234\001\240\005\175\000\175\000\023\003\ -\026\006\234\001\234\001\234\001\234\001\023\003\077\002\047\002\ -\186\000\131\005\211\002\021\006\156\005\234\001\023\003\051\000\ -\146\003\011\003\187\005\187\001\023\003\146\000\175\000\175\000\ -\175\000\023\003\155\001\187\001\234\001\188\005\175\000\009\006\ -\211\002\220\001\073\003\081\006\211\002\221\001\158\001\023\002\ -\211\002\211\002\211\002\211\002\222\001\187\001\187\001\223\001\ -\113\001\157\005\122\005\190\000\122\005\175\000\175\000\211\002\ -\065\006\023\003\175\000\108\006\131\005\215\000\175\000\187\001\ -\023\003\013\002\074\006\006\005\209\005\011\003\214\002\134\003\ -\215\002\187\001\150\000\150\000\005\006\187\001\024\002\118\006\ -\139\001\198\001\216\002\146\000\187\001\187\001\211\002\088\006\ -\000\005\150\000\175\000\110\005\025\003\125\006\126\006\186\000\ -\058\004\148\001\154\001\175\000\027\002\215\002\196\002\196\002\ -\155\001\013\002\097\006\216\002\202\002\196\002\001\005\029\002\ -\186\000\178\002\030\000\014\000\069\006\175\000\002\005\183\001\ -\003\005\178\002\196\002\048\002\112\006\186\000\051\000\077\006\ -\196\002\187\000\015\000\016\000\103\003\004\005\023\003\018\002\ -\146\000\025\003\215\002\013\003\006\005\185\002\048\002\023\000\ -\216\002\023\003\019\003\196\002\196\002\048\002\048\002\069\006\ -\069\006\148\005\058\001\186\000\082\000\095\006\096\006\132\006\ -\175\000\023\003\031\000\051\000\051\000\074\001\164\003\050\005\ -\157\002\011\002\035\000\048\002\048\002\036\002\104\003\147\000\ -\039\000\109\005\089\000\113\006\186\000\030\000\042\000\048\002\ -\181\001\245\004\110\005\135\002\181\001\051\000\048\002\048\002\ -\181\001\048\002\181\001\011\002\123\006\187\000\181\001\181\001\ -\247\004\147\000\181\001\242\003\089\000\083\000\127\006\043\002\ -\252\001\069\006\050\000\181\001\183\000\053\000\041\002\134\006\ -\135\006\150\000\243\003\244\003\150\000\072\002\073\002\074\002\ -\075\002\217\001\135\002\150\000\252\001\150\000\150\000\146\000\ -\166\000\076\002\048\002\161\000\057\002\023\003\183\000\151\003\ -\023\003\023\003\186\000\150\000\218\001\023\003\023\003\065\002\ -\175\000\152\003\181\001\210\001\058\002\150\000\161\000\210\001\ -\127\005\181\001\063\004\187\000\023\003\161\000\023\003\175\000\ -\175\000\210\001\023\003\064\003\245\002\246\002\023\003\023\003\ -\023\003\064\004\210\001\181\001\181\001\077\002\181\001\181\001\ -\065\003\060\002\155\001\161\000\161\000\023\003\155\001\150\000\ -\139\002\150\000\155\001\023\003\155\001\102\001\150\000\161\000\ -\155\001\181\001\025\003\175\000\155\001\071\002\161\000\161\000\ -\140\002\161\000\120\002\150\000\175\000\155\001\175\000\120\002\ -\189\000\054\003\025\003\196\000\023\003\198\000\199\000\200\000\ -\013\002\215\004\201\000\202\000\203\000\204\000\205\000\220\001\ -\206\000\245\002\248\002\221\001\017\002\007\003\186\000\018\002\ -\209\001\126\004\222\001\057\001\209\001\223\001\059\001\060\001\ -\061\001\035\006\161\000\215\000\155\001\159\002\209\001\175\000\ -\066\001\067\001\154\001\155\001\068\001\069\001\154\001\209\001\ -\186\000\160\002\154\001\163\002\154\001\135\002\013\002\103\003\ -\154\001\154\001\164\002\167\001\063\003\155\001\155\001\167\001\ -\155\001\155\001\064\003\093\005\151\002\154\001\150\000\198\004\ -\165\002\011\003\128\000\198\000\190\005\186\000\094\005\065\003\ -\172\002\199\004\167\001\155\001\173\002\132\001\133\001\134\001\ -\135\001\174\002\137\001\180\002\164\002\146\000\198\000\176\001\ -\186\002\104\003\185\002\176\001\082\000\198\000\215\002\082\000\ -\135\002\190\002\176\001\191\002\154\001\176\001\135\002\225\002\ -\215\002\082\000\227\002\154\001\002\003\082\000\176\001\150\000\ -\186\000\071\001\150\000\198\000\198\000\237\002\082\000\082\000\ -\082\000\082\000\011\003\150\000\018\003\154\001\154\001\198\000\ -\154\001\154\001\025\003\025\003\150\000\082\000\198\000\198\000\ -\030\003\198\000\175\000\166\002\167\002\083\000\032\003\043\003\ -\196\001\197\001\035\003\154\001\044\003\176\001\048\003\044\002\ -\082\000\045\002\083\000\082\000\247\002\249\002\083\000\082\000\ -\082\000\069\003\051\003\046\002\045\003\175\000\082\000\083\000\ -\083\000\083\000\083\000\047\003\082\000\115\002\008\003\116\002\ -\049\003\070\003\198\000\219\002\240\001\220\002\083\000\175\001\ -\082\000\117\002\082\000\175\001\082\000\082\000\051\000\221\002\ -\175\000\037\004\175\001\038\004\090\001\175\001\135\002\062\003\ -\082\000\083\000\150\000\082\000\083\000\039\004\094\003\083\000\ -\083\000\083\000\150\000\086\003\175\000\175\000\083\000\083\000\ -\101\003\175\000\175\000\175\000\108\003\083\000\150\000\175\000\ -\096\004\114\003\097\004\135\002\116\003\175\000\135\002\120\003\ -\130\003\083\000\139\003\083\000\098\004\083\000\083\000\094\000\ -\120\002\150\000\007\003\186\000\071\001\175\001\192\001\120\002\ -\145\003\083\000\120\002\153\003\083\000\175\000\095\000\016\000\ -\083\000\222\001\160\003\172\003\120\002\038\002\039\002\173\003\ -\120\002\047\002\186\003\096\000\245\002\177\002\199\003\013\002\ -\054\003\120\002\120\002\120\002\120\002\077\002\212\003\230\003\ -\229\003\231\003\232\003\048\002\233\003\174\000\031\000\237\003\ -\120\002\070\000\014\004\021\004\027\004\051\004\035\000\047\004\ -\060\004\056\002\105\003\067\004\097\000\010\000\063\002\080\004\ -\208\000\082\004\042\000\120\002\178\002\135\002\120\002\085\004\ -\177\002\120\002\120\002\120\002\135\002\102\004\111\004\116\004\ -\120\002\120\002\098\000\105\004\117\004\150\000\219\000\120\002\ -\127\004\125\004\130\004\150\000\132\004\149\004\099\000\014\000\ -\135\002\053\000\131\004\120\002\164\002\120\002\158\004\120\002\ -\120\002\177\004\190\004\195\004\164\002\192\004\015\000\016\000\ -\203\004\164\002\204\004\120\002\250\004\005\005\120\002\175\000\ -\205\004\206\004\120\002\023\000\214\004\150\000\164\002\207\004\ -\164\002\164\002\211\004\212\004\213\004\221\004\175\000\150\000\ -\225\004\226\004\228\004\150\000\241\004\164\002\031\000\013\005\ -\235\004\074\001\029\005\018\005\013\002\101\005\035\000\024\005\ -\043\005\077\005\025\005\117\005\039\000\028\005\021\003\072\005\ -\164\002\046\005\042\000\164\002\116\005\120\005\164\002\164\002\ -\164\002\121\005\123\005\133\005\136\005\079\003\164\002\143\005\ -\169\002\145\005\129\000\121\000\164\002\164\005\059\005\184\001\ -\202\005\013\002\135\002\205\005\150\000\181\005\050\000\182\005\ -\164\002\053\000\183\005\206\005\164\002\164\002\223\005\150\000\ -\230\005\199\001\174\000\174\000\233\005\174\000\248\005\008\006\ -\164\002\194\002\023\006\164\002\175\000\027\006\041\006\174\000\ -\174\000\216\003\058\006\072\002\073\002\074\002\075\002\250\004\ -\135\002\013\002\023\003\254\005\063\006\066\006\012\003\076\002\ -\064\006\067\006\135\002\072\006\247\003\073\006\150\000\174\000\ -\174\000\002\004\098\006\011\002\075\006\023\003\167\005\093\006\ -\116\006\117\006\111\005\111\006\023\003\150\000\121\006\124\006\ -\120\002\150\000\130\006\120\002\131\006\051\000\089\000\008\000\ -\026\004\021\003\150\000\051\000\005\005\120\002\084\002\025\003\ -\023\003\120\002\023\003\077\002\128\000\089\000\178\002\105\002\ -\252\001\102\002\120\002\120\002\120\002\120\002\023\003\104\002\ -\033\003\023\003\023\003\023\003\065\004\175\000\023\003\036\003\ -\023\003\120\002\135\002\135\002\202\002\221\000\107\002\200\002\ -\020\002\070\000\150\000\200\002\070\000\001\000\002\000\003\000\ -\004\000\005\000\006\000\007\000\120\002\005\005\070\000\120\002\ -\201\002\178\002\120\002\120\002\120\002\201\002\150\000\150\000\ -\150\000\120\002\120\002\070\000\203\002\070\000\070\000\206\002\ -\120\002\023\003\207\002\135\002\208\002\204\002\111\005\149\001\ -\048\004\070\000\070\000\016\006\120\002\232\001\120\002\132\005\ -\120\002\120\002\184\001\217\005\101\006\006\006\072\003\192\003\ -\129\004\149\002\226\005\119\004\120\002\070\000\250\004\120\002\ -\070\000\124\002\084\003\120\002\070\000\070\000\150\000\137\004\ -\210\002\206\001\147\003\070\000\025\003\025\003\150\000\134\005\ -\201\004\070\000\005\005\025\003\250\004\141\002\175\000\208\002\ -\242\004\025\003\182\003\005\005\176\002\070\000\150\000\219\005\ -\025\003\070\000\070\000\194\005\247\005\096\005\025\003\000\000\ -\150\000\113\002\175\000\000\000\000\000\070\000\150\000\000\000\ -\070\000\000\000\174\004\175\004\000\000\000\000\000\000\000\000\ -\000\000\025\003\025\003\021\003\000\000\000\000\000\000\000\000\ -\150\000\000\000\000\000\186\004\000\000\000\000\000\000\148\002\ -\000\000\000\000\021\003\021\003\000\000\000\000\000\000\000\000\ -\194\004\000\000\000\000\000\000\150\000\000\000\150\000\021\003\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\202\004\000\000\000\000\150\000\000\000\000\000\250\004\150\000\ -\000\000\195\000\021\003\175\000\000\000\021\003\000\000\000\000\ -\250\004\000\000\021\003\000\000\000\000\000\000\135\002\184\001\ -\021\003\000\000\174\000\174\000\195\000\000\000\021\003\000\000\ -\000\000\175\000\223\004\195\000\162\000\000\000\173\002\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\021\003\021\003\ -\000\000\000\000\000\000\174\000\174\000\174\000\000\000\162\000\ -\000\000\195\000\021\003\174\000\000\000\021\003\162\000\000\000\ -\000\000\250\004\217\002\000\000\000\000\195\000\000\000\000\000\ -\005\005\000\000\177\000\000\000\195\000\195\000\194\000\195\000\ -\000\000\010\005\174\000\174\000\162\000\162\000\000\000\174\000\ -\150\000\000\000\017\005\174\000\000\000\194\000\011\002\000\000\ -\162\000\000\000\000\000\150\000\000\000\000\000\199\001\162\000\ -\162\000\000\000\162\000\000\000\000\000\199\001\000\000\000\000\ -\194\000\000\000\000\000\250\004\000\000\000\000\000\000\174\000\ -\195\000\000\000\000\000\150\000\150\000\000\000\000\000\022\004\ -\174\000\150\000\150\000\000\000\000\000\000\000\011\002\000\000\ -\000\000\000\000\111\005\150\000\111\005\232\001\000\000\000\000\ -\232\001\005\005\174\000\162\000\000\000\061\003\194\000\150\000\ -\194\000\194\000\232\001\055\005\000\000\057\005\208\000\000\000\ -\232\001\014\003\000\000\000\000\000\000\000\000\000\000\232\001\ -\150\000\232\001\232\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\150\000\000\000\000\000\150\000\232\001\000\000\ -\000\000\000\000\000\000\150\000\150\000\174\000\000\000\000\000\ -\000\000\000\000\097\005\000\000\000\000\000\000\000\000\100\005\ -\000\000\232\001\000\000\000\000\232\001\000\000\094\002\000\000\ -\232\001\232\001\000\000\000\000\000\000\000\000\000\000\232\001\ -\136\000\000\000\137\000\138\000\030\000\232\001\139\000\000\000\ -\000\000\140\000\141\000\173\002\000\000\000\000\000\000\177\000\ -\177\000\232\001\177\000\000\000\000\000\232\001\232\001\000\000\ -\000\000\000\000\142\000\000\000\177\000\177\000\000\000\135\005\ -\000\000\232\001\143\000\144\000\232\001\000\000\000\000\000\000\ -\194\000\000\000\145\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\177\000\003\002\146\000\147\000\ -\000\000\194\000\000\000\000\000\199\001\174\000\000\000\150\005\ -\000\000\152\005\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\174\000\174\000\173\002\000\000\ -\173\002\173\002\173\002\168\005\000\000\000\000\173\002\178\005\ -\179\005\000\000\000\000\173\002\000\000\000\000\000\000\173\002\ -\173\002\173\002\000\000\000\000\000\000\180\003\184\005\000\000\ -\173\002\173\002\173\002\173\002\000\000\000\000\000\000\000\000\ -\174\000\000\000\173\002\000\000\011\002\000\000\000\000\173\002\ -\000\000\174\000\000\000\174\000\197\005\000\000\173\002\173\002\ -\000\000\000\000\000\000\000\000\000\000\011\002\000\000\000\000\ -\194\000\000\000\173\002\000\000\000\000\173\002\173\002\000\000\ -\173\002\173\002\173\002\000\000\173\002\000\000\000\000\173\002\ -\173\002\000\000\000\000\000\000\000\000\194\000\173\002\000\000\ -\000\000\000\000\215\003\000\000\174\000\000\000\000\000\000\000\ -\000\000\173\002\173\002\000\000\173\002\173\002\173\002\173\002\ -\000\000\000\000\173\002\011\002\000\000\000\000\000\000\245\005\ -\000\000\163\000\173\002\173\002\171\000\173\002\000\000\000\000\ -\249\005\173\002\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\163\000\002\006\000\000\000\000\ -\004\006\000\000\000\000\163\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\194\000\180\000\000\000\ -\194\000\194\000\000\000\000\000\194\000\000\000\194\000\000\000\ -\000\000\163\000\163\000\000\000\062\004\000\000\000\000\000\000\ -\194\000\028\006\000\000\000\000\156\002\163\000\094\002\194\000\ -\094\002\094\002\094\002\000\000\163\000\163\000\094\002\163\000\ -\000\000\000\000\000\000\094\002\184\001\000\000\000\000\094\002\ -\094\002\094\002\000\000\000\000\000\000\194\000\000\000\174\000\ -\094\002\094\002\094\002\094\002\000\000\000\000\000\000\000\000\ -\000\000\194\000\094\002\000\000\000\000\000\000\000\000\094\002\ -\194\000\194\000\000\000\194\000\000\000\000\000\094\002\094\002\ -\163\000\000\000\174\000\000\000\000\000\000\000\000\000\177\000\ -\003\002\000\000\094\002\000\000\000\000\094\002\000\000\000\000\ -\094\002\094\002\094\002\000\000\094\002\000\000\000\000\094\002\ -\094\002\000\000\000\000\086\006\000\000\174\000\094\002\000\000\ -\177\000\177\000\177\000\000\000\194\000\000\000\000\000\000\000\ -\177\000\094\002\094\002\000\000\094\002\094\002\094\002\094\002\ -\000\000\174\000\174\000\000\000\000\000\000\000\174\000\174\000\ -\174\000\000\000\094\002\000\000\174\000\094\002\000\000\003\002\ -\177\000\094\002\174\000\000\000\003\002\000\000\000\000\000\000\ -\177\000\114\006\115\006\000\000\011\002\000\000\000\000\000\000\ -\000\000\122\006\000\000\180\000\180\000\000\000\180\000\000\000\ -\000\000\011\002\174\000\000\000\000\000\000\000\000\000\000\000\ -\180\000\180\000\000\000\000\000\177\000\133\006\011\002\000\000\ -\011\002\011\002\000\000\000\000\011\002\177\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\011\002\000\000\250\001\ -\180\000\180\000\178\000\000\000\000\000\000\000\195\000\177\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\011\002\000\000\000\000\194\000\219\004\195\000\011\002\011\002\ -\011\002\000\000\000\000\000\000\171\000\000\000\011\002\171\000\ -\000\000\000\000\000\000\000\000\011\002\000\000\000\000\000\000\ -\195\000\171\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\011\002\000\000\177\000\000\000\011\002\000\000\171\000\171\000\ -\171\000\171\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\011\002\000\000\000\000\011\002\000\000\171\000\000\000\000\000\ -\000\000\011\002\184\001\000\000\174\000\000\000\195\000\000\000\ -\195\000\195\000\000\000\000\000\156\002\000\000\000\000\156\002\ -\171\000\000\000\000\000\174\000\156\002\000\000\000\000\171\000\ -\171\000\156\002\156\002\000\000\000\000\000\000\171\000\156\002\ -\000\000\011\002\177\002\000\000\171\000\000\000\156\002\179\000\ -\156\002\156\002\000\000\000\000\000\000\000\000\000\000\000\000\ -\171\000\000\000\171\000\067\002\171\000\156\002\000\000\000\000\ -\000\000\000\000\000\000\159\001\078\002\000\000\000\000\000\000\ -\171\000\000\000\177\000\171\000\000\000\000\000\011\002\000\000\ -\156\002\000\000\000\000\156\002\000\000\177\002\156\002\156\002\ -\156\002\177\000\177\000\010\000\000\000\157\001\156\002\178\000\ -\178\000\000\000\178\000\156\002\156\002\000\000\000\000\000\000\ -\000\000\174\000\000\000\000\000\178\000\178\000\000\000\000\000\ -\156\002\000\000\181\003\000\000\156\002\156\002\011\002\000\000\ -\195\000\000\000\199\001\000\000\000\000\177\000\000\000\000\000\ -\156\002\000\000\000\000\156\002\178\000\004\002\177\000\000\000\ -\003\002\195\000\000\000\000\000\136\000\000\000\137\000\138\000\ -\030\000\000\000\139\000\000\000\000\000\140\000\141\000\000\000\ -\000\000\000\000\000\000\023\003\000\000\000\000\000\000\000\000\ -\000\000\184\001\000\000\000\000\000\000\000\000\142\000\000\000\ -\023\003\000\000\000\000\000\000\000\000\010\000\143\000\144\000\ -\000\000\003\002\000\000\000\000\054\000\023\003\145\000\023\003\ -\023\003\000\000\174\000\180\000\180\000\000\000\000\000\000\000\ -\000\000\000\000\146\000\147\000\023\003\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\179\000\179\000\000\000\179\000\ -\000\000\000\000\184\001\199\002\180\000\180\000\180\000\023\003\ -\195\000\179\000\179\000\000\000\180\000\000\000\136\000\023\003\ -\137\000\138\000\030\000\000\000\139\000\023\003\081\001\158\001\ -\141\000\000\000\000\000\023\003\000\000\195\000\000\000\000\000\ -\000\000\179\000\179\000\180\000\180\000\000\000\000\000\000\000\ -\180\000\000\000\000\000\023\003\180\000\220\000\220\000\000\000\ -\000\000\144\000\087\001\088\001\089\001\090\001\078\002\023\003\ -\145\000\011\002\023\003\000\000\000\000\000\000\000\000\000\000\ -\000\000\011\002\000\000\000\000\146\000\147\000\011\002\184\001\ -\180\000\186\000\000\000\174\000\177\000\000\000\092\001\093\001\ -\184\001\038\003\000\000\011\002\000\000\011\002\011\002\000\000\ -\000\000\000\000\095\001\096\001\097\001\098\001\000\000\174\000\ -\195\000\195\000\011\002\180\000\195\000\000\000\195\000\003\002\ -\130\001\131\001\000\000\100\001\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\011\002\000\000\000\000\ -\011\002\000\000\000\000\011\002\011\002\011\002\000\000\000\000\ -\000\000\000\000\177\000\011\002\000\000\000\000\000\000\000\000\ -\159\001\011\002\186\002\000\000\190\002\000\000\038\003\159\001\ -\000\000\159\001\000\000\000\000\000\000\011\002\177\000\003\002\ -\000\000\011\002\011\002\177\000\177\000\177\000\000\000\000\000\ -\174\000\177\000\184\001\000\000\000\000\011\002\000\000\177\000\ -\011\002\000\000\000\000\000\000\000\000\000\000\000\000\178\000\ -\004\002\000\000\000\000\000\000\000\000\000\000\174\000\000\000\ -\167\001\000\000\000\000\000\000\000\000\000\000\000\000\177\000\ -\138\002\180\003\000\000\000\000\000\000\168\001\000\000\000\000\ -\178\000\178\000\178\000\000\000\081\001\000\000\000\000\000\000\ -\178\000\000\000\000\000\000\000\000\000\048\006\000\000\000\000\ -\136\000\000\000\137\000\138\000\030\000\184\001\139\000\000\000\ -\060\006\169\001\141\000\000\000\054\000\000\000\180\000\004\002\ -\178\000\088\001\089\001\090\001\004\002\000\000\000\000\000\000\ -\178\000\054\000\000\000\000\000\000\000\180\000\180\000\000\000\ -\179\002\180\003\000\000\144\000\000\000\000\000\054\000\000\000\ -\054\000\054\000\145\000\000\000\092\001\093\001\000\000\000\000\ -\000\000\000\000\000\000\000\000\178\000\054\000\146\000\147\000\ -\095\001\096\001\097\001\098\001\000\000\178\000\000\000\000\000\ -\000\000\180\000\000\000\000\000\179\000\179\000\000\000\000\000\ -\054\000\100\001\180\000\054\000\180\000\000\000\184\001\178\000\ -\054\000\003\002\000\000\000\000\000\000\000\000\054\000\000\000\ -\000\000\000\000\000\000\195\000\054\000\179\000\179\000\179\000\ -\003\002\000\000\000\000\000\000\000\000\179\000\179\000\000\000\ -\054\000\000\000\000\000\000\000\054\000\054\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\180\000\000\000\000\000\ -\054\000\000\000\178\000\054\000\179\000\179\000\000\000\000\000\ -\000\000\179\000\000\000\000\000\000\000\179\000\000\000\079\002\ -\080\002\081\002\082\002\083\002\084\002\085\002\086\002\087\002\ -\088\002\089\002\090\002\091\002\092\002\093\002\094\002\095\002\ -\096\002\097\002\098\002\099\002\182\002\102\002\000\000\000\000\ -\103\002\179\000\000\000\105\002\000\000\106\002\000\000\107\002\ -\000\000\108\002\179\000\109\002\000\000\000\000\003\002\000\000\ -\000\000\000\000\000\000\159\001\000\000\000\000\000\000\000\000\ -\126\002\000\000\000\000\000\000\179\000\000\000\000\000\186\002\ -\000\000\190\002\000\000\078\002\000\000\000\000\000\000\142\002\ -\000\000\143\002\000\000\000\000\000\000\000\000\186\002\186\002\ -\190\002\190\002\178\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\158\002\000\000\186\002\000\000\190\002\000\000\000\000\ -\180\000\178\000\178\000\000\000\138\002\000\000\000\000\179\000\ -\000\000\057\000\000\000\194\000\000\000\000\000\186\002\000\000\ -\190\002\186\002\000\000\190\002\000\000\000\000\186\002\000\000\ -\190\002\000\000\000\000\180\000\186\002\000\000\190\002\003\002\ -\000\000\000\000\186\002\213\002\190\002\178\000\000\000\000\000\ -\000\000\000\000\000\000\138\002\000\000\000\000\178\000\000\000\ -\004\002\000\000\186\002\186\002\190\002\190\002\180\000\000\000\ -\000\000\000\000\228\002\000\000\000\000\000\000\186\002\000\000\ -\190\002\186\002\212\002\190\002\213\002\000\000\000\000\000\000\ -\000\000\000\000\180\000\180\000\000\000\000\000\160\004\180\000\ -\180\000\180\000\000\000\000\000\213\002\180\000\213\002\213\002\ -\213\002\004\002\213\002\180\000\000\000\213\002\213\002\179\000\ -\000\000\003\003\136\000\006\003\137\000\138\000\030\000\000\000\ -\139\000\000\000\000\000\140\000\141\000\000\000\179\000\179\000\ -\000\000\020\003\000\000\180\000\000\000\177\001\022\003\213\002\ -\000\000\000\000\000\000\000\000\142\000\000\000\213\002\000\000\ -\003\002\000\000\000\000\000\000\143\000\144\000\000\000\194\000\ -\000\000\229\002\213\002\213\002\145\000\000\000\000\000\000\000\ -\000\000\000\000\179\000\000\000\003\002\000\000\000\000\000\000\ -\146\000\147\000\000\000\179\000\000\000\179\000\000\000\000\000\ -\000\000\000\000\000\000\220\000\220\000\000\000\000\000\000\000\ -\000\000\159\001\000\000\000\000\000\000\000\000\073\004\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\138\002\000\000\ -\000\000\247\000\000\000\000\000\182\002\000\000\000\000\182\002\ -\000\000\000\000\000\000\000\000\178\000\000\000\179\000\089\003\ -\000\000\182\002\000\000\000\000\095\003\096\003\097\003\000\000\ -\000\000\000\000\000\000\000\000\000\000\003\002\182\002\182\002\ -\182\002\182\002\000\000\099\003\000\000\180\000\102\003\004\002\ -\000\000\000\000\000\000\000\000\000\000\182\002\000\000\000\000\ -\000\000\138\002\000\000\003\002\180\000\000\000\000\000\138\002\ -\000\000\000\000\000\000\000\000\000\000\000\000\045\006\000\000\ -\182\002\000\000\178\000\000\000\173\002\000\000\182\002\182\002\ -\182\002\000\000\000\000\000\000\000\000\173\002\182\002\000\000\ -\000\000\057\000\000\000\000\000\182\002\000\000\178\000\004\002\ -\000\000\000\000\000\000\178\000\178\000\178\000\057\000\000\000\ -\182\002\178\000\182\002\000\000\182\002\173\002\000\000\178\000\ -\173\002\000\000\000\000\057\000\000\000\057\000\057\000\000\000\ -\182\002\173\002\011\002\182\002\000\000\000\000\078\006\161\003\ -\000\000\179\000\057\000\000\000\165\003\166\003\167\003\178\000\ -\000\000\014\003\180\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\183\003\000\000\057\000\000\000\000\000\ -\057\000\000\000\000\000\000\000\179\000\057\000\000\000\138\002\ -\000\000\000\000\000\000\057\000\000\000\000\000\000\000\000\000\ -\000\000\057\000\000\000\200\003\000\000\000\000\203\003\000\000\ -\000\000\000\000\000\000\000\000\000\000\057\000\000\000\179\000\ -\000\000\057\000\057\000\210\003\138\002\000\000\000\000\138\002\ -\136\000\000\000\137\000\138\000\030\000\057\000\139\000\000\000\ -\057\000\140\000\141\000\179\000\179\000\232\004\000\000\000\000\ -\179\000\179\000\179\000\000\000\000\000\000\000\179\000\000\000\ -\000\000\000\000\142\000\180\000\179\000\000\000\000\000\000\000\ -\000\000\000\000\143\000\126\003\000\000\000\000\000\000\000\000\ -\032\000\000\000\145\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\004\002\000\000\000\000\179\000\151\004\146\000\147\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\004\002\000\000\000\000\000\000\000\000\000\000\000\000\040\004\ -\000\000\247\000\247\000\247\000\247\000\000\000\138\002\000\000\ -\000\000\247\000\247\000\247\000\000\000\138\002\247\000\247\000\ -\000\000\247\000\247\000\247\000\247\000\247\000\247\000\000\000\ -\000\000\247\000\247\000\247\000\247\000\247\000\247\000\000\000\ -\000\000\138\002\078\004\000\000\000\000\247\000\247\000\000\000\ -\000\000\247\000\247\000\247\000\247\000\000\000\081\000\000\000\ -\000\000\247\000\247\000\000\000\180\000\255\004\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\247\000\247\000\000\000\ -\247\000\000\000\000\000\247\000\247\000\247\000\004\002\247\000\ -\180\000\000\000\247\000\247\000\000\000\000\000\000\000\000\000\ -\000\000\247\000\000\000\247\000\000\000\000\000\179\000\118\004\ -\000\000\000\000\000\000\000\000\247\000\247\000\000\000\247\000\ -\247\000\247\000\247\000\000\000\000\000\179\000\000\000\000\000\ -\247\000\000\000\247\000\000\000\141\004\247\000\000\000\159\001\ -\247\000\000\000\011\002\000\000\247\000\011\002\000\000\148\004\ -\000\000\000\000\011\002\138\002\000\000\000\000\000\000\011\002\ -\000\000\000\000\000\000\195\000\000\000\011\002\023\003\000\000\ -\000\000\180\000\000\000\000\000\011\002\000\000\011\002\011\002\ -\000\000\000\000\000\000\023\003\000\000\000\000\000\000\004\002\ -\000\000\000\000\000\000\011\002\179\004\000\000\181\004\180\000\ -\255\004\138\002\000\000\000\000\000\000\000\000\023\003\000\000\ -\023\003\023\003\023\003\138\002\023\003\000\000\011\002\023\003\ -\023\003\011\002\000\000\179\000\011\002\011\002\011\002\000\000\ -\159\001\000\000\000\000\113\005\011\002\000\000\000\000\000\000\ -\000\000\000\000\011\002\000\000\000\000\000\000\208\004\209\004\ -\210\004\023\003\000\000\000\000\229\000\000\000\011\002\000\000\ -\023\003\000\000\011\002\011\002\000\000\216\004\000\000\000\000\ -\000\000\000\000\000\000\000\000\023\003\023\003\011\002\000\000\ -\032\000\011\002\000\000\032\000\000\000\000\000\000\000\000\000\ -\000\000\230\004\000\000\138\002\138\002\032\000\032\000\000\000\ -\000\000\032\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\004\002\000\000\032\000\032\000\032\000\032\000\000\000\195\000\ -\000\000\238\004\239\004\240\004\179\000\000\000\000\000\000\000\ -\032\000\032\000\000\000\000\000\004\002\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\138\002\000\000\000\000\113\005\ -\000\000\000\000\000\000\000\000\032\000\000\000\000\000\032\000\ -\000\000\000\000\000\000\032\000\032\000\000\000\000\000\185\005\ -\186\005\032\000\032\000\030\005\000\000\000\000\081\000\255\004\ -\032\000\081\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\081\000\032\000\000\000\032\000\081\000\ -\032\000\032\000\000\000\000\000\000\000\255\004\000\000\000\000\ -\081\000\081\000\081\000\081\000\032\000\004\002\000\000\032\000\ -\000\000\060\002\000\000\032\000\000\000\000\000\052\005\081\000\ -\054\005\000\000\056\005\016\003\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\004\002\000\000\179\000\000\000\000\000\ -\000\000\000\000\081\000\000\000\000\000\081\000\078\005\079\005\ -\080\005\081\000\081\000\000\000\087\005\088\005\089\005\000\000\ -\081\000\179\000\000\000\000\000\000\000\000\000\081\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\081\000\000\000\081\000\103\005\081\000\081\000\ -\000\000\113\005\136\000\000\000\137\000\138\000\030\000\255\004\ -\139\000\118\005\081\000\140\000\141\000\081\000\000\000\000\000\ -\000\000\255\004\125\005\000\000\000\000\000\000\129\005\138\002\ -\000\000\000\000\000\000\000\000\142\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\143\000\144\000\000\000\000\000\ -\000\000\000\000\179\000\000\000\145\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\146\000\147\000\000\000\000\000\229\000\229\000\229\000\229\000\ -\179\000\000\000\255\004\000\000\229\000\229\000\229\000\000\000\ -\000\000\229\000\229\000\229\000\229\000\229\000\229\000\229\000\ -\229\000\229\000\000\000\000\000\229\000\229\000\229\000\229\000\ -\229\000\229\000\000\000\122\002\000\000\000\000\000\000\000\000\ -\229\000\229\000\000\000\000\000\229\000\229\000\229\000\229\000\ -\229\000\229\000\229\000\000\000\229\000\229\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\255\004\000\000\000\000\000\000\ -\229\000\229\000\000\000\229\000\000\000\000\000\229\000\229\000\ -\229\000\000\000\229\000\229\000\229\000\229\000\229\000\000\000\ -\000\000\000\000\000\000\113\005\229\000\113\005\229\000\229\000\ -\229\000\229\000\229\000\000\000\000\000\000\000\000\000\229\000\ -\229\000\000\000\229\000\229\000\229\000\229\000\000\000\000\000\ -\229\000\000\000\000\000\229\000\000\000\229\000\000\000\000\000\ -\229\000\000\000\000\000\229\000\000\000\000\000\000\000\229\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\239\005\000\000\000\000\000\000\014\000\000\000\000\000\000\000\ -\000\000\060\002\000\000\060\002\060\002\060\002\250\005\251\005\ -\252\005\060\002\000\000\015\000\016\000\000\000\060\002\164\002\ -\000\000\000\000\060\002\060\002\060\002\000\000\000\000\000\000\ -\023\000\000\000\007\006\060\002\060\002\060\002\060\002\000\000\ -\000\000\000\000\000\000\000\000\000\000\060\002\000\000\018\006\ -\000\000\060\002\060\002\031\000\000\000\022\006\074\001\000\000\ -\000\000\060\002\060\002\035\000\000\000\000\000\000\000\000\000\ -\000\000\039\000\000\000\000\000\000\000\060\002\037\006\042\000\ -\060\002\000\000\000\000\060\002\060\002\060\002\046\006\060\002\ -\000\000\000\000\060\002\060\002\000\000\000\000\000\000\046\000\ -\000\000\060\002\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\050\000\060\002\060\002\053\000\060\002\ -\060\002\060\002\000\000\000\000\000\000\060\002\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\060\002\000\000\000\000\ -\060\002\000\000\000\000\000\000\060\002\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\079\006\080\006\ -\000\000\000\000\000\000\041\001\000\000\082\006\083\006\084\006\ -\085\006\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\089\006\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\122\002\122\002\122\002\122\002\000\000\ -\099\006\122\002\122\002\122\002\122\002\122\002\122\002\122\002\ -\122\002\122\002\122\002\122\002\122\002\122\002\122\002\122\002\ -\122\002\122\002\000\000\122\002\122\002\122\002\122\002\122\002\ -\122\002\122\002\122\002\000\000\000\000\000\000\000\000\122\002\ -\122\002\000\000\000\000\122\002\122\002\122\002\122\002\122\002\ -\122\002\122\002\122\002\122\002\122\002\122\002\122\002\000\000\ -\122\002\122\002\122\002\122\002\000\000\000\000\122\002\122\002\ -\122\002\110\002\122\002\122\002\122\002\122\002\122\002\122\002\ -\000\000\122\002\122\002\122\002\122\002\122\002\000\000\122\002\ -\000\000\000\000\000\000\122\002\122\002\122\002\122\002\122\002\ -\122\002\122\002\122\002\000\000\122\002\000\000\122\002\122\002\ -\061\001\122\002\122\002\122\002\122\002\122\002\000\000\122\002\ -\122\002\000\000\122\002\122\002\122\002\122\002\000\000\122\002\ -\122\002\000\000\122\002\000\000\000\000\000\000\122\002\164\002\ -\164\002\164\002\164\002\164\002\000\000\164\002\164\002\164\002\ -\164\002\164\002\164\002\164\002\164\002\164\002\164\002\164\002\ -\164\002\164\002\164\002\164\002\164\002\000\000\000\000\164\002\ -\164\002\164\002\164\002\164\002\164\002\164\002\164\002\000\000\ -\000\000\000\000\000\000\164\002\164\002\000\000\000\000\164\002\ -\164\002\164\002\164\002\164\002\164\002\164\002\164\002\164\002\ -\164\002\164\002\164\002\000\000\164\002\164\002\164\002\164\002\ -\000\000\000\000\164\002\164\002\164\002\000\000\164\002\164\002\ -\164\002\164\002\164\002\164\002\000\000\164\002\164\002\164\002\ -\164\002\164\002\000\000\164\002\000\000\000\000\000\000\164\002\ -\164\002\164\002\164\002\164\002\164\002\164\002\164\002\000\000\ -\164\002\000\000\164\002\164\002\047\001\164\002\164\002\164\002\ -\164\002\164\002\000\000\164\002\164\002\000\000\164\002\164\002\ -\164\002\164\002\000\000\164\002\164\002\000\000\164\002\000\000\ -\000\000\000\000\164\002\041\001\041\001\041\001\041\001\000\000\ -\000\000\041\001\041\001\041\001\041\001\041\001\041\001\041\001\ -\041\001\041\001\041\001\041\001\041\001\041\001\041\001\041\001\ -\041\001\041\001\000\000\041\001\041\001\041\001\041\001\041\001\ -\041\001\041\001\041\001\000\000\000\000\000\000\000\000\041\001\ -\041\001\000\000\000\000\041\001\041\001\041\001\041\001\041\001\ -\041\001\041\001\041\001\041\001\041\001\041\001\041\001\000\000\ -\041\001\041\001\041\001\041\001\000\000\000\000\041\001\041\001\ -\041\001\000\000\041\001\041\001\041\001\041\001\041\001\041\001\ -\000\000\041\001\041\001\041\001\041\001\041\001\000\000\041\001\ -\000\000\000\000\000\000\041\001\041\001\041\001\041\001\041\001\ -\041\001\041\001\041\001\000\000\041\001\000\000\041\001\041\001\ -\045\001\041\001\041\001\041\001\041\001\041\001\000\000\041\001\ -\041\001\000\000\041\001\041\001\041\001\041\001\000\000\041\001\ -\041\001\000\000\041\001\000\000\000\000\000\000\041\001\000\000\ -\061\001\061\001\061\001\061\001\000\000\000\000\061\001\061\001\ -\061\001\061\001\061\001\061\001\061\001\061\001\061\001\061\001\ -\061\001\061\001\061\001\061\001\061\001\061\001\061\001\000\000\ -\061\001\061\001\061\001\061\001\061\001\061\001\061\001\061\001\ -\000\000\000\000\000\000\000\000\061\001\061\001\000\000\000\000\ -\061\001\061\001\061\001\061\001\061\001\061\001\061\001\061\001\ -\061\001\061\001\061\001\061\001\000\000\061\001\061\001\061\001\ -\061\001\000\000\000\000\061\001\061\001\061\001\000\000\061\001\ -\061\001\061\001\061\001\061\001\061\001\000\000\061\001\061\001\ -\061\001\061\001\061\001\000\000\061\001\000\000\000\000\000\000\ -\061\001\061\001\061\001\061\001\061\001\061\001\061\001\061\001\ -\000\000\061\001\000\000\061\001\061\001\053\001\061\001\061\001\ -\061\001\061\001\061\001\000\000\061\001\061\001\000\000\061\001\ -\061\001\061\001\061\001\000\000\061\001\061\001\000\000\061\001\ -\000\000\000\000\000\000\061\001\047\001\047\001\047\001\047\001\ -\000\000\000\000\047\001\047\001\047\001\047\001\047\001\047\001\ -\047\001\047\001\047\001\047\001\047\001\047\001\047\001\047\001\ -\047\001\047\001\047\001\000\000\047\001\047\001\047\001\047\001\ -\047\001\047\001\047\001\047\001\000\000\000\000\000\000\000\000\ -\047\001\047\001\000\000\000\000\047\001\047\001\047\001\047\001\ -\047\001\047\001\047\001\047\001\047\001\047\001\047\001\047\001\ -\000\000\047\001\047\001\047\001\047\001\000\000\000\000\047\001\ -\047\001\047\001\000\000\047\001\047\001\047\001\047\001\047\001\ -\047\001\000\000\047\001\047\001\047\001\047\001\047\001\000\000\ -\047\001\000\000\000\000\000\000\047\001\047\001\047\001\047\001\ -\047\001\047\001\047\001\047\001\000\000\047\001\000\000\047\001\ -\047\001\049\001\047\001\047\001\047\001\047\001\047\001\000\000\ -\047\001\047\001\000\000\047\001\047\001\047\001\047\001\000\000\ -\047\001\047\001\000\000\047\001\000\000\000\000\000\000\047\001\ -\045\001\045\001\045\001\045\001\000\000\000\000\045\001\045\001\ -\045\001\045\001\045\001\045\001\045\001\045\001\045\001\045\001\ -\045\001\045\001\045\001\045\001\045\001\045\001\045\001\000\000\ -\045\001\045\001\045\001\045\001\045\001\045\001\045\001\045\001\ -\000\000\000\000\000\000\000\000\045\001\045\001\000\000\000\000\ -\045\001\045\001\045\001\045\001\045\001\045\001\045\001\045\001\ -\045\001\045\001\045\001\045\001\000\000\045\001\045\001\045\001\ -\045\001\000\000\000\000\045\001\045\001\045\001\000\000\045\001\ -\045\001\045\001\045\001\045\001\045\001\000\000\045\001\045\001\ -\045\001\045\001\045\001\000\000\045\001\000\000\000\000\000\000\ -\045\001\045\001\045\001\045\001\045\001\045\001\045\001\045\001\ -\000\000\045\001\000\000\045\001\045\001\051\001\045\001\045\001\ -\045\001\045\001\045\001\000\000\045\001\045\001\000\000\045\001\ -\045\001\045\001\045\001\000\000\045\001\045\001\000\000\045\001\ -\000\000\000\000\000\000\045\001\000\000\053\001\053\001\053\001\ -\053\001\000\000\000\000\053\001\053\001\053\001\053\001\053\001\ -\053\001\053\001\053\001\053\001\053\001\053\001\053\001\053\001\ -\053\001\053\001\053\001\053\001\000\000\053\001\053\001\053\001\ -\053\001\053\001\053\001\053\001\053\001\000\000\000\000\000\000\ -\000\000\053\001\053\001\000\000\000\000\053\001\053\001\053\001\ -\053\001\053\001\053\001\053\001\053\001\053\001\053\001\053\001\ -\053\001\000\000\053\001\053\001\053\001\053\001\000\000\000\000\ -\053\001\053\001\053\001\000\000\053\001\053\001\053\001\053\001\ -\053\001\053\001\000\000\053\001\053\001\053\001\053\001\053\001\ -\000\000\053\001\000\000\000\000\000\000\053\001\053\001\053\001\ -\053\001\053\001\053\001\053\001\053\001\000\000\053\001\000\000\ -\053\001\053\001\059\001\053\001\053\001\053\001\053\001\053\001\ -\000\000\053\001\053\001\000\000\053\001\053\001\053\001\053\001\ -\000\000\053\001\053\001\000\000\053\001\000\000\000\000\000\000\ -\053\001\049\001\049\001\049\001\049\001\000\000\000\000\049\001\ -\049\001\049\001\049\001\049\001\049\001\049\001\049\001\049\001\ -\049\001\049\001\049\001\049\001\049\001\049\001\049\001\049\001\ -\000\000\049\001\049\001\049\001\049\001\049\001\049\001\049\001\ -\049\001\000\000\000\000\000\000\000\000\049\001\049\001\000\000\ -\000\000\049\001\049\001\049\001\049\001\049\001\049\001\049\001\ -\049\001\049\001\049\001\049\001\049\001\000\000\049\001\049\001\ -\049\001\049\001\000\000\000\000\049\001\049\001\049\001\000\000\ -\049\001\049\001\049\001\049\001\049\001\049\001\000\000\049\001\ -\049\001\049\001\049\001\049\001\000\000\049\001\000\000\000\000\ -\000\000\049\001\049\001\049\001\049\001\049\001\049\001\049\001\ -\049\001\000\000\049\001\000\000\049\001\049\001\055\001\049\001\ -\049\001\049\001\049\001\049\001\000\000\049\001\049\001\000\000\ -\049\001\049\001\049\001\049\001\000\000\049\001\049\001\000\000\ -\049\001\000\000\000\000\000\000\049\001\051\001\051\001\051\001\ -\051\001\000\000\000\000\051\001\051\001\051\001\051\001\051\001\ -\051\001\051\001\051\001\051\001\051\001\051\001\051\001\051\001\ -\051\001\051\001\051\001\051\001\000\000\051\001\051\001\051\001\ -\051\001\051\001\051\001\051\001\051\001\000\000\000\000\000\000\ -\000\000\051\001\051\001\000\000\000\000\051\001\051\001\051\001\ -\051\001\051\001\051\001\051\001\051\001\051\001\051\001\051\001\ -\051\001\000\000\051\001\051\001\051\001\051\001\000\000\000\000\ -\051\001\051\001\051\001\000\000\051\001\051\001\051\001\051\001\ -\051\001\051\001\000\000\051\001\051\001\051\001\051\001\051\001\ -\000\000\051\001\000\000\000\000\000\000\051\001\051\001\051\001\ -\051\001\051\001\051\001\051\001\051\001\000\000\051\001\000\000\ -\051\001\051\001\057\001\051\001\051\001\051\001\051\001\051\001\ -\000\000\051\001\051\001\000\000\051\001\051\001\051\001\051\001\ -\000\000\051\001\051\001\000\000\051\001\000\000\000\000\000\000\ -\051\001\000\000\059\001\059\001\059\001\059\001\000\000\000\000\ -\059\001\059\001\059\001\059\001\059\001\059\001\059\001\059\001\ -\059\001\059\001\059\001\059\001\059\001\059\001\059\001\059\001\ -\059\001\000\000\059\001\059\001\059\001\059\001\059\001\059\001\ -\059\001\059\001\000\000\000\000\000\000\000\000\059\001\059\001\ -\000\000\000\000\059\001\059\001\059\001\059\001\059\001\059\001\ -\059\001\059\001\059\001\059\001\059\001\059\001\000\000\059\001\ -\059\001\059\001\059\001\000\000\000\000\059\001\059\001\059\001\ -\000\000\059\001\059\001\059\001\059\001\059\001\059\001\000\000\ -\059\001\059\001\059\001\059\001\059\001\000\000\059\001\000\000\ -\000\000\000\000\059\001\059\001\059\001\059\001\059\001\059\001\ -\059\001\059\001\000\000\059\001\000\000\059\001\059\001\088\001\ -\059\001\059\001\059\001\059\001\059\001\000\000\059\001\059\001\ -\000\000\059\001\059\001\059\001\059\001\000\000\059\001\059\001\ -\000\000\059\001\000\000\000\000\000\000\059\001\055\001\055\001\ -\055\001\055\001\000\000\000\000\055\001\055\001\055\001\055\001\ -\055\001\055\001\055\001\055\001\055\001\055\001\055\001\055\001\ -\055\001\055\001\055\001\055\001\055\001\000\000\055\001\055\001\ -\055\001\055\001\055\001\055\001\055\001\055\001\000\000\000\000\ -\000\000\000\000\055\001\055\001\000\000\000\000\055\001\055\001\ -\055\001\055\001\055\001\055\001\055\001\055\001\055\001\055\001\ -\055\001\055\001\000\000\055\001\055\001\055\001\055\001\000\000\ -\000\000\055\001\055\001\055\001\000\000\055\001\055\001\055\001\ -\055\001\055\001\055\001\000\000\055\001\055\001\055\001\055\001\ -\055\001\000\000\055\001\000\000\000\000\000\000\055\001\055\001\ -\055\001\055\001\055\001\055\001\055\001\055\001\000\000\055\001\ -\000\000\055\001\055\001\097\001\055\001\055\001\055\001\055\001\ -\055\001\000\000\055\001\055\001\000\000\055\001\055\001\055\001\ -\055\001\000\000\055\001\055\001\000\000\055\001\000\000\000\000\ -\000\000\055\001\057\001\057\001\057\001\057\001\000\000\000\000\ -\057\001\057\001\057\001\057\001\057\001\057\001\057\001\057\001\ -\057\001\057\001\057\001\057\001\057\001\057\001\057\001\057\001\ -\057\001\000\000\057\001\057\001\057\001\057\001\057\001\057\001\ -\057\001\057\001\000\000\000\000\000\000\000\000\057\001\057\001\ -\000\000\000\000\057\001\057\001\057\001\057\001\057\001\057\001\ -\057\001\057\001\057\001\057\001\057\001\057\001\000\000\057\001\ -\057\001\057\001\057\001\000\000\000\000\057\001\057\001\057\001\ -\000\000\057\001\057\001\057\001\057\001\057\001\057\001\000\000\ -\057\001\057\001\057\001\057\001\057\001\000\000\057\001\000\000\ -\000\000\000\000\057\001\057\001\057\001\057\001\057\001\057\001\ -\057\001\057\001\000\000\057\001\000\000\057\001\057\001\099\001\ -\057\001\057\001\057\001\057\001\057\001\000\000\057\001\057\001\ -\000\000\057\001\057\001\057\001\057\001\000\000\057\001\057\001\ -\000\000\057\001\000\000\000\000\000\000\057\001\000\000\088\001\ -\088\001\088\001\088\001\088\001\000\000\088\001\088\001\088\001\ -\088\001\088\001\088\001\088\001\088\001\088\001\088\001\088\001\ -\088\001\088\001\088\001\088\001\088\001\000\000\000\000\088\001\ -\088\001\088\001\088\001\088\001\088\001\088\001\088\001\000\000\ -\000\000\000\000\000\000\088\001\088\001\000\000\000\000\088\001\ -\088\001\088\001\088\001\088\001\088\001\088\001\000\000\088\001\ -\088\001\088\001\088\001\000\000\088\001\088\001\088\001\088\001\ -\000\000\000\000\088\001\088\001\088\001\000\000\088\001\088\001\ -\088\001\088\001\088\001\088\001\000\000\088\001\088\001\088\001\ -\088\001\088\001\000\000\088\001\000\000\000\000\000\000\088\001\ -\088\001\088\001\088\001\088\001\088\001\088\001\088\001\000\000\ -\088\001\000\000\088\001\088\001\102\001\088\001\088\001\088\001\ -\088\001\088\001\000\000\088\001\088\001\000\000\088\001\088\001\ -\088\001\088\001\000\000\088\001\088\001\000\000\088\001\000\000\ -\000\000\000\000\088\001\097\001\097\001\097\001\097\001\097\001\ -\000\000\097\001\097\001\097\001\097\001\097\001\097\001\097\001\ -\097\001\097\001\097\001\097\001\097\001\097\001\097\001\097\001\ -\097\001\000\000\000\000\097\001\097\001\097\001\097\001\097\001\ -\097\001\097\001\097\001\000\000\000\000\000\000\000\000\097\001\ -\097\001\000\000\000\000\097\001\097\001\097\001\097\001\097\001\ -\097\001\097\001\000\000\097\001\097\001\097\001\097\001\000\000\ -\097\001\097\001\097\001\097\001\000\000\000\000\097\001\097\001\ -\097\001\000\000\097\001\097\001\097\001\097\001\097\001\097\001\ -\000\000\097\001\097\001\097\001\097\001\097\001\000\000\097\001\ -\000\000\000\000\000\000\097\001\097\001\097\001\097\001\097\001\ -\097\001\097\001\097\001\000\000\097\001\000\000\097\001\097\001\ -\033\001\097\001\097\001\097\001\000\000\000\000\000\000\097\001\ -\097\001\000\000\097\001\097\001\097\001\097\001\000\000\097\001\ -\097\001\000\000\097\001\000\000\000\000\000\000\097\001\099\001\ -\099\001\099\001\099\001\099\001\000\000\099\001\099\001\099\001\ -\099\001\099\001\099\001\099\001\099\001\099\001\099\001\099\001\ -\099\001\099\001\099\001\099\001\099\001\000\000\000\000\099\001\ -\099\001\099\001\099\001\099\001\099\001\099\001\099\001\000\000\ -\000\000\000\000\000\000\099\001\099\001\000\000\000\000\099\001\ -\099\001\099\001\099\001\099\001\099\001\099\001\000\000\099\001\ -\099\001\099\001\099\001\000\000\099\001\099\001\099\001\099\001\ -\000\000\000\000\099\001\099\001\099\001\000\000\099\001\099\001\ -\099\001\099\001\099\001\099\001\000\000\099\001\099\001\099\001\ -\099\001\099\001\000\000\099\001\000\000\000\000\000\000\099\001\ -\099\001\099\001\099\001\099\001\099\001\099\001\099\001\000\000\ -\099\001\000\000\099\001\099\001\034\001\099\001\099\001\099\001\ -\000\000\000\000\000\000\099\001\099\001\000\000\099\001\099\001\ -\099\001\099\001\000\000\099\001\099\001\000\000\099\001\000\000\ -\000\000\000\000\099\001\000\000\102\001\102\001\102\001\102\001\ -\102\001\000\000\102\001\102\001\102\001\102\001\102\001\102\001\ -\102\001\102\001\102\001\102\001\102\001\102\001\102\001\102\001\ -\102\001\102\001\000\000\000\000\102\001\102\001\102\001\102\001\ -\102\001\102\001\102\001\102\001\000\000\000\000\000\000\000\000\ -\102\001\102\001\000\000\000\000\102\001\102\001\102\001\102\001\ -\102\001\102\001\102\001\000\000\102\001\102\001\102\001\102\001\ -\000\000\102\001\102\001\102\001\102\001\000\000\000\000\102\001\ -\102\001\102\001\000\000\102\001\102\001\102\001\102\001\102\001\ -\102\001\000\000\102\001\102\001\102\001\102\001\102\001\000\000\ -\102\001\000\000\000\000\000\000\102\001\102\001\102\001\102\001\ -\102\001\102\001\102\001\102\001\000\000\102\001\000\000\102\001\ -\102\001\228\000\102\001\102\001\102\001\000\000\000\000\000\000\ -\102\001\102\001\000\000\102\001\102\001\102\001\102\001\000\000\ -\102\001\102\001\000\000\102\001\000\000\000\000\000\000\102\001\ -\033\001\033\001\033\001\033\001\000\000\000\000\000\000\000\000\ -\033\001\033\001\033\001\000\000\000\000\033\001\033\001\033\001\ -\033\001\033\001\033\001\033\001\033\001\033\001\033\001\000\000\ -\033\001\033\001\033\001\033\001\033\001\033\001\000\000\000\000\ -\000\000\000\000\000\000\000\000\033\001\033\001\000\000\000\000\ -\033\001\033\001\033\001\033\001\033\001\033\001\033\001\033\001\ -\033\001\033\001\000\000\033\001\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\033\001\033\001\000\000\033\001\ -\000\000\000\000\033\001\033\001\033\001\000\000\033\001\033\001\ -\033\001\033\001\033\001\000\000\000\000\000\000\000\000\000\000\ -\033\001\033\001\033\001\033\001\033\001\033\001\033\001\000\000\ -\000\000\033\001\000\000\033\001\033\001\240\000\033\001\033\001\ -\033\001\033\001\033\001\000\000\033\001\000\000\000\000\033\001\ -\033\001\033\001\000\000\000\000\033\001\000\000\000\000\033\001\ -\000\000\000\000\000\000\033\001\034\001\034\001\034\001\034\001\ -\000\000\000\000\000\000\000\000\034\001\034\001\034\001\000\000\ -\000\000\034\001\034\001\034\001\034\001\034\001\034\001\034\001\ -\034\001\034\001\034\001\000\000\034\001\034\001\034\001\034\001\ -\034\001\034\001\000\000\000\000\000\000\000\000\000\000\000\000\ -\034\001\034\001\000\000\000\000\034\001\034\001\034\001\034\001\ -\034\001\034\001\034\001\034\001\034\001\034\001\000\000\034\001\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\034\001\034\001\000\000\034\001\000\000\000\000\034\001\034\001\ -\034\001\000\000\034\001\034\001\034\001\034\001\034\001\000\000\ -\000\000\000\000\000\000\000\000\034\001\034\001\034\001\034\001\ -\034\001\034\001\034\001\000\000\000\000\034\001\000\000\034\001\ -\034\001\241\000\034\001\034\001\034\001\034\001\034\001\000\000\ -\034\001\000\000\000\000\034\001\034\001\034\001\000\000\000\000\ -\034\001\000\000\000\000\034\001\000\000\000\000\000\000\034\001\ -\000\000\228\000\228\000\228\000\228\000\000\000\000\000\000\000\ -\000\000\228\000\228\000\228\000\000\000\000\000\228\000\228\000\ -\228\000\228\000\228\000\228\000\228\000\228\000\228\000\000\000\ -\000\000\228\000\228\000\228\000\228\000\228\000\228\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\228\000\228\000\000\000\ -\000\000\228\000\228\000\228\000\228\000\228\000\228\000\228\000\ -\000\000\228\000\228\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\228\000\228\000\000\000\ -\228\000\000\000\000\000\228\000\228\000\228\000\000\000\228\000\ -\228\000\228\000\228\000\228\000\000\000\000\000\000\000\000\000\ -\000\000\228\000\000\000\228\000\228\000\228\000\228\000\228\000\ -\000\000\000\000\000\000\000\000\228\000\228\000\242\000\228\000\ -\228\000\228\000\000\000\000\000\000\000\228\000\000\000\000\000\ -\228\000\000\000\228\000\000\000\000\000\228\000\000\000\000\000\ -\228\000\000\000\000\000\000\000\228\000\240\000\240\000\240\000\ -\240\000\000\000\000\000\000\000\000\000\240\000\240\000\240\000\ -\000\000\000\000\240\000\240\000\240\000\240\000\240\000\000\000\ -\240\000\240\000\240\000\000\000\000\000\240\000\240\000\240\000\ -\240\000\240\000\240\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\240\000\240\000\000\000\000\000\240\000\240\000\240\000\ -\240\000\240\000\240\000\240\000\000\000\240\000\240\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\240\000\240\000\000\000\240\000\000\000\000\000\240\000\ -\240\000\240\000\000\000\240\000\240\000\240\000\240\000\240\000\ -\000\000\000\000\000\000\000\000\000\000\240\000\000\000\240\000\ -\240\000\240\000\240\000\240\000\000\000\000\000\000\000\000\000\ -\240\000\240\000\025\001\240\000\240\000\240\000\240\000\000\000\ -\000\000\240\000\000\000\000\000\240\000\000\000\240\000\000\000\ -\000\000\240\000\000\000\000\000\240\000\000\000\000\000\000\000\ -\240\000\241\000\241\000\241\000\241\000\000\000\000\000\000\000\ -\000\000\241\000\241\000\241\000\000\000\000\000\241\000\241\000\ -\241\000\241\000\241\000\241\000\241\000\241\000\241\000\000\000\ -\000\000\241\000\241\000\241\000\241\000\241\000\241\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\241\000\241\000\000\000\ -\000\000\241\000\241\000\241\000\241\000\241\000\241\000\241\000\ -\000\000\241\000\241\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\241\000\241\000\000\000\ -\241\000\000\000\000\000\241\000\241\000\241\000\000\000\241\000\ -\241\000\241\000\241\000\241\000\000\000\000\000\000\000\000\000\ -\000\000\241\000\000\000\241\000\241\000\241\000\241\000\241\000\ -\000\000\000\000\000\000\000\000\241\000\241\000\026\001\241\000\ -\241\000\241\000\000\000\000\000\000\000\241\000\000\000\000\000\ -\241\000\000\000\241\000\000\000\000\000\241\000\000\000\000\000\ -\241\000\000\000\000\000\000\000\241\000\000\000\242\000\242\000\ -\242\000\242\000\000\000\000\000\000\000\000\000\242\000\242\000\ -\242\000\000\000\000\000\242\000\242\000\242\000\242\000\242\000\ -\242\000\242\000\242\000\242\000\000\000\000\000\242\000\242\000\ -\242\000\242\000\242\000\242\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\242\000\242\000\000\000\000\000\242\000\242\000\ -\242\000\242\000\242\000\242\000\242\000\000\000\242\000\242\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\242\000\242\000\000\000\242\000\000\000\000\000\ -\242\000\242\000\242\000\000\000\242\000\242\000\242\000\242\000\ -\242\000\000\000\000\000\000\000\000\000\000\000\242\000\000\000\ -\242\000\242\000\242\000\242\000\242\000\000\000\000\000\000\000\ -\000\000\242\000\242\000\251\000\242\000\242\000\242\000\000\000\ -\000\000\000\000\242\000\000\000\000\000\242\000\000\000\242\000\ -\000\000\000\000\242\000\000\000\000\000\242\000\000\000\000\000\ -\000\000\242\000\025\001\025\001\025\001\025\001\000\000\000\000\ -\000\000\000\000\025\001\025\001\025\001\000\000\000\000\025\001\ -\025\001\025\001\025\001\025\001\025\001\025\001\025\001\025\001\ -\000\000\000\000\025\001\025\001\025\001\025\001\025\001\025\001\ -\000\000\000\000\000\000\000\000\000\000\000\000\025\001\025\001\ -\000\000\000\000\025\001\025\001\025\001\025\001\025\001\025\001\ -\025\001\000\000\025\001\025\001\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\025\001\025\001\ -\000\000\025\001\000\000\000\000\025\001\025\001\025\001\000\000\ -\025\001\025\001\025\001\025\001\025\001\000\000\000\000\000\000\ -\000\000\000\000\025\001\000\000\025\001\025\001\025\001\025\001\ -\025\001\000\000\000\000\000\000\000\000\025\001\025\001\252\000\ -\025\001\025\001\025\001\000\000\000\000\000\000\025\001\000\000\ -\000\000\025\001\000\000\025\001\000\000\000\000\025\001\000\000\ -\000\000\025\001\000\000\000\000\000\000\025\001\026\001\026\001\ -\026\001\026\001\000\000\000\000\000\000\000\000\026\001\026\001\ -\026\001\000\000\000\000\026\001\026\001\026\001\026\001\026\001\ -\026\001\026\001\026\001\026\001\000\000\000\000\026\001\026\001\ -\026\001\026\001\026\001\026\001\000\000\000\000\000\000\000\000\ -\000\000\000\000\026\001\026\001\000\000\000\000\026\001\026\001\ -\026\001\026\001\026\001\026\001\026\001\000\000\026\001\026\001\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\026\001\026\001\000\000\026\001\000\000\000\000\ -\026\001\026\001\026\001\000\000\026\001\026\001\026\001\026\001\ -\026\001\000\000\000\000\000\000\000\000\000\000\026\001\000\000\ -\026\001\026\001\026\001\026\001\026\001\000\000\000\000\000\000\ -\000\000\026\001\026\001\003\001\026\001\026\001\026\001\000\000\ -\000\000\000\000\026\001\000\000\000\000\026\001\000\000\026\001\ -\000\000\000\000\026\001\000\000\000\000\026\001\000\000\000\000\ -\000\000\026\001\000\000\251\000\251\000\251\000\251\000\000\000\ -\000\000\000\000\000\000\251\000\251\000\251\000\000\000\000\000\ -\251\000\251\000\251\000\251\000\251\000\251\000\251\000\251\000\ -\251\000\000\000\000\000\251\000\251\000\251\000\251\000\251\000\ -\251\000\000\000\000\000\000\000\000\000\000\000\000\000\251\000\ -\251\000\000\000\000\000\251\000\251\000\251\000\251\000\251\000\ -\251\000\000\000\000\000\251\000\251\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\251\000\ -\251\000\000\000\251\000\000\000\000\000\251\000\251\000\251\000\ -\000\000\251\000\251\000\251\000\251\000\251\000\000\000\000\000\ -\000\000\000\000\000\000\251\000\000\000\251\000\251\000\251\000\ -\251\000\251\000\000\000\000\000\000\000\000\000\251\000\251\000\ -\002\001\251\000\251\000\251\000\251\000\000\000\000\000\251\000\ -\000\000\000\000\251\000\000\000\251\000\000\000\000\000\251\000\ -\000\000\000\000\251\000\000\000\000\000\000\000\251\000\252\000\ -\252\000\252\000\252\000\000\000\000\000\000\000\000\000\252\000\ -\252\000\252\000\000\000\000\000\252\000\252\000\252\000\252\000\ -\252\000\252\000\252\000\252\000\252\000\000\000\000\000\252\000\ -\252\000\252\000\252\000\252\000\252\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\252\000\252\000\000\000\000\000\252\000\ -\252\000\252\000\252\000\252\000\252\000\000\000\000\000\252\000\ -\252\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\252\000\252\000\000\000\252\000\000\000\ -\000\000\252\000\252\000\252\000\000\000\252\000\252\000\252\000\ -\252\000\252\000\000\000\000\000\000\000\000\000\000\000\252\000\ -\000\000\252\000\252\000\252\000\252\000\252\000\000\000\000\000\ -\000\000\000\000\252\000\252\000\234\000\252\000\252\000\252\000\ -\252\000\000\000\000\000\252\000\000\000\000\000\252\000\000\000\ -\252\000\000\000\000\000\252\000\000\000\000\000\252\000\000\000\ -\000\000\000\000\252\000\003\001\003\001\003\001\003\001\000\000\ -\000\000\000\000\000\000\003\001\003\001\003\001\000\000\000\000\ -\003\001\003\001\003\001\003\001\003\001\003\001\003\001\003\001\ -\003\001\000\000\000\000\003\001\003\001\003\001\003\001\003\001\ -\003\001\000\000\000\000\000\000\000\000\000\000\000\000\003\001\ -\003\001\000\000\000\000\003\001\003\001\003\001\003\001\003\001\ -\003\001\000\000\000\000\003\001\003\001\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\003\001\ -\003\001\000\000\003\001\000\000\000\000\003\001\003\001\003\001\ -\000\000\003\001\003\001\003\001\003\001\003\001\000\000\000\000\ -\000\000\000\000\000\000\003\001\000\000\003\001\003\001\003\001\ -\003\001\003\001\000\000\000\000\000\000\000\000\003\001\003\001\ -\237\000\003\001\003\001\003\001\003\001\000\000\000\000\003\001\ -\000\000\000\000\003\001\000\000\003\001\000\000\000\000\003\001\ -\000\000\000\000\003\001\000\000\000\000\000\000\003\001\000\000\ -\002\001\002\001\002\001\002\001\000\000\000\000\000\000\000\000\ -\002\001\002\001\002\001\000\000\000\000\002\001\002\001\002\001\ -\002\001\002\001\002\001\002\001\002\001\002\001\000\000\000\000\ -\002\001\002\001\002\001\002\001\002\001\002\001\000\000\000\000\ -\000\000\000\000\000\000\000\000\002\001\002\001\000\000\000\000\ -\002\001\002\001\002\001\002\001\002\001\002\001\000\000\000\000\ -\002\001\002\001\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\002\001\002\001\000\000\002\001\ -\000\000\000\000\002\001\002\001\002\001\000\000\002\001\002\001\ -\002\001\002\001\002\001\000\000\000\000\000\000\000\000\000\000\ -\002\001\000\000\002\001\002\001\002\001\002\001\002\001\000\000\ -\000\000\000\000\000\000\002\001\002\001\238\000\002\001\002\001\ -\002\001\002\001\000\000\000\000\002\001\000\000\000\000\002\001\ -\000\000\002\001\000\000\000\000\002\001\000\000\000\000\002\001\ -\000\000\000\000\000\000\002\001\234\000\234\000\234\000\234\000\ -\000\000\000\000\000\000\000\000\000\000\234\000\234\000\000\000\ -\000\000\234\000\234\000\234\000\234\000\234\000\234\000\234\000\ -\234\000\234\000\000\000\000\000\234\000\234\000\234\000\234\000\ -\234\000\234\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\234\000\234\000\000\000\000\000\234\000\234\000\234\000\234\000\ -\234\000\234\000\234\000\000\000\234\000\234\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\234\000\234\000\000\000\234\000\000\000\000\000\234\000\234\000\ -\234\000\000\000\234\000\234\000\234\000\234\000\234\000\000\000\ -\000\000\000\000\000\000\000\000\234\000\000\000\234\000\234\000\ -\234\000\234\000\234\000\000\000\000\000\000\000\000\000\234\000\ -\234\000\250\000\234\000\234\000\234\000\234\000\000\000\000\000\ -\234\000\000\000\000\000\234\000\000\000\234\000\000\000\000\000\ -\234\000\000\000\000\000\234\000\000\000\000\000\000\000\234\000\ -\237\000\237\000\237\000\237\000\000\000\000\000\000\000\000\000\ -\000\000\237\000\237\000\000\000\000\000\237\000\237\000\237\000\ -\237\000\237\000\237\000\237\000\237\000\237\000\000\000\000\000\ -\237\000\237\000\237\000\237\000\237\000\237\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\237\000\237\000\000\000\000\000\ -\237\000\237\000\237\000\237\000\237\000\237\000\237\000\000\000\ -\237\000\237\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\237\000\237\000\000\000\237\000\ -\000\000\000\000\237\000\237\000\237\000\000\000\237\000\237\000\ -\237\000\237\000\237\000\000\000\000\000\000\000\000\000\000\000\ -\237\000\000\000\237\000\237\000\237\000\237\000\237\000\000\000\ -\000\000\000\000\000\000\237\000\237\000\000\001\237\000\237\000\ -\237\000\237\000\000\000\000\000\237\000\000\000\000\000\237\000\ -\000\000\237\000\000\000\000\000\237\000\000\000\000\000\237\000\ -\000\000\000\000\000\000\237\000\000\000\238\000\238\000\238\000\ -\238\000\000\000\000\000\000\000\000\000\000\000\238\000\238\000\ -\000\000\000\000\238\000\238\000\238\000\238\000\238\000\238\000\ -\238\000\238\000\238\000\000\000\000\000\238\000\238\000\238\000\ -\238\000\238\000\238\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\238\000\238\000\000\000\000\000\238\000\238\000\238\000\ -\238\000\238\000\238\000\238\000\000\000\238\000\238\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\238\000\238\000\000\000\238\000\000\000\000\000\238\000\ -\238\000\238\000\000\000\238\000\238\000\238\000\238\000\238\000\ -\000\000\000\000\000\000\000\000\000\000\238\000\000\000\238\000\ -\238\000\238\000\238\000\238\000\000\000\000\000\000\000\000\000\ -\238\000\238\000\001\001\238\000\238\000\238\000\238\000\000\000\ -\000\000\238\000\000\000\000\000\238\000\000\000\238\000\000\000\ -\000\000\238\000\000\000\000\000\238\000\000\000\000\000\000\000\ -\238\000\250\000\250\000\250\000\250\000\000\000\000\000\000\000\ -\000\000\250\000\250\000\250\000\000\000\000\000\250\000\250\000\ -\250\000\250\000\250\000\250\000\250\000\250\000\250\000\000\000\ -\000\000\250\000\250\000\250\000\250\000\250\000\250\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\250\000\250\000\000\000\ -\000\000\250\000\250\000\250\000\250\000\250\000\000\000\000\000\ -\000\000\250\000\250\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\250\000\250\000\000\000\ -\250\000\000\000\000\000\250\000\250\000\250\000\000\000\250\000\ -\250\000\250\000\250\000\250\000\000\000\000\000\000\000\000\000\ -\000\000\250\000\000\000\250\000\000\000\250\000\250\000\250\000\ -\000\000\000\000\000\000\000\000\250\000\250\000\253\000\250\000\ -\250\000\250\000\250\000\000\000\000\000\000\000\000\000\000\000\ -\250\000\000\000\250\000\000\000\000\000\250\000\000\000\000\000\ -\250\000\000\000\000\000\000\000\250\000\000\001\000\001\000\001\ -\000\001\000\000\000\000\000\000\000\000\000\001\000\001\000\001\ -\000\000\000\000\000\001\000\001\000\001\000\001\000\001\000\001\ -\000\001\000\001\000\001\000\000\000\000\000\001\000\001\000\001\ -\000\001\000\001\000\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\001\000\001\000\000\000\000\000\001\000\001\000\001\ -\000\001\000\001\000\000\000\000\000\000\000\001\000\001\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\001\000\001\000\000\000\001\000\000\000\000\000\001\ -\000\001\000\001\000\000\000\001\000\001\000\001\000\001\000\001\ -\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\001\ -\000\000\000\001\000\001\000\001\000\000\000\000\000\000\000\000\ -\000\001\000\001\254\000\000\001\000\001\000\001\000\001\000\000\ -\000\000\000\000\000\000\000\000\000\001\000\000\000\001\000\000\ -\000\000\000\001\000\000\000\000\000\001\000\000\000\000\000\000\ -\000\001\000\000\001\001\001\001\001\001\001\001\000\000\000\000\ -\000\000\000\000\001\001\001\001\001\001\000\000\000\000\001\001\ -\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\ -\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\ -\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\ -\000\000\000\000\001\001\001\001\001\001\001\001\001\001\000\000\ -\000\000\000\000\001\001\001\001\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\ -\000\000\001\001\000\000\000\000\001\001\001\001\001\001\000\000\ -\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\ -\000\000\000\000\001\001\000\000\001\001\000\000\001\001\001\001\ -\001\001\000\000\000\000\000\000\000\000\001\001\001\001\255\000\ -\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\ -\000\000\001\001\000\000\001\001\000\000\000\000\001\001\000\000\ -\000\000\001\001\000\000\000\000\000\000\001\001\253\000\253\000\ -\253\000\253\000\000\000\000\000\000\000\000\000\253\000\253\000\ -\253\000\000\000\000\000\253\000\253\000\253\000\253\000\253\000\ -\253\000\253\000\253\000\253\000\000\000\000\000\253\000\253\000\ -\253\000\253\000\253\000\253\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\253\000\253\000\000\000\000\000\253\000\253\000\ -\253\000\253\000\253\000\000\000\000\000\000\000\253\000\253\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\253\000\253\000\000\000\253\000\000\000\000\000\ -\253\000\253\000\253\000\000\000\253\000\253\000\253\000\253\000\ -\253\000\000\000\000\000\000\000\000\000\000\000\253\000\000\000\ -\253\000\000\000\253\000\253\000\253\000\000\000\000\000\000\000\ -\000\000\253\000\253\000\208\000\253\000\253\000\253\000\253\000\ -\000\000\000\000\000\000\000\000\000\000\253\000\000\000\253\000\ -\000\000\000\000\253\000\000\000\000\000\253\000\000\000\000\000\ -\000\000\253\000\254\000\254\000\254\000\254\000\000\000\000\000\ -\000\000\000\000\254\000\254\000\254\000\000\000\000\000\254\000\ -\254\000\254\000\254\000\254\000\254\000\254\000\254\000\254\000\ -\000\000\000\000\254\000\254\000\254\000\254\000\254\000\254\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\254\000\254\000\ -\000\000\000\000\254\000\254\000\254\000\254\000\254\000\000\000\ -\000\000\000\000\254\000\254\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\254\000\254\000\ -\000\000\254\000\000\000\000\000\254\000\254\000\254\000\000\000\ -\254\000\254\000\254\000\254\000\254\000\000\000\000\000\000\000\ -\000\000\000\000\254\000\000\000\254\000\000\000\254\000\254\000\ -\254\000\000\000\000\000\000\000\000\000\254\000\254\000\004\001\ -\254\000\254\000\254\000\254\000\000\000\000\000\000\000\000\000\ -\000\000\254\000\000\000\254\000\000\000\000\000\254\000\000\000\ -\000\000\254\000\000\000\000\000\000\000\254\000\000\000\255\000\ -\255\000\255\000\255\000\000\000\000\000\000\000\000\000\255\000\ -\255\000\255\000\000\000\000\000\255\000\255\000\255\000\255\000\ -\255\000\255\000\255\000\255\000\255\000\000\000\000\000\255\000\ -\255\000\255\000\255\000\255\000\255\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\255\000\255\000\000\000\000\000\255\000\ -\255\000\255\000\255\000\255\000\000\000\000\000\000\000\255\000\ -\255\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\255\000\255\000\000\000\255\000\000\000\ -\000\000\255\000\255\000\255\000\000\000\255\000\255\000\255\000\ -\255\000\255\000\000\000\000\000\000\000\000\000\000\000\255\000\ -\000\000\255\000\000\000\255\000\255\000\255\000\000\000\000\000\ -\000\000\000\000\255\000\255\000\006\001\255\000\255\000\255\000\ -\255\000\000\000\000\000\000\000\000\000\000\000\255\000\000\000\ -\255\000\000\000\000\000\255\000\000\000\000\000\255\000\000\000\ -\000\000\000\000\255\000\208\000\208\000\208\000\208\000\000\000\ -\000\000\000\000\000\000\208\000\208\000\208\000\000\000\000\000\ -\208\000\208\000\208\000\208\000\208\000\208\000\208\000\208\000\ -\208\000\000\000\000\000\208\000\208\000\208\000\208\000\208\000\ -\208\000\000\000\000\000\000\000\000\000\000\000\000\000\208\000\ -\208\000\000\000\000\000\208\000\208\000\208\000\208\000\208\000\ -\208\000\208\000\000\000\208\000\208\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\208\000\ -\208\000\000\000\000\000\000\000\000\000\208\000\208\000\208\000\ -\000\000\208\000\000\000\000\000\208\000\208\000\000\000\000\000\ -\000\000\000\000\000\000\208\000\000\000\208\000\000\000\000\000\ -\000\000\208\000\000\000\000\000\000\000\000\000\208\000\208\000\ -\248\000\208\000\208\000\208\000\208\000\000\000\000\000\208\000\ -\000\000\000\000\208\000\000\000\208\000\000\000\000\000\208\000\ -\000\000\000\000\208\000\000\000\000\000\000\000\208\000\004\001\ -\004\001\004\001\004\001\000\000\000\000\000\000\000\000\004\001\ -\004\001\004\001\000\000\000\000\004\001\004\001\000\000\004\001\ -\004\001\004\001\004\001\004\001\004\001\000\000\000\000\004\001\ -\004\001\004\001\004\001\004\001\004\001\000\000\000\000\000\000\ -\000\000\000\000\000\000\004\001\004\001\000\000\000\000\004\001\ -\004\001\004\001\000\000\000\000\000\000\000\000\000\000\004\001\ -\004\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\004\001\004\001\000\000\004\001\000\000\ -\000\000\000\000\004\001\004\001\000\000\004\001\000\000\000\000\ -\004\001\004\001\000\000\000\000\000\000\000\000\000\000\004\001\ -\000\000\004\001\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\004\001\004\001\249\000\004\001\004\001\004\001\ -\004\001\000\000\000\000\000\000\000\000\000\000\004\001\000\000\ -\004\001\000\000\000\000\004\001\000\000\000\000\004\001\000\000\ -\000\000\000\000\004\001\000\000\006\001\006\001\006\001\006\001\ -\000\000\000\000\000\000\000\000\006\001\006\001\006\001\000\000\ -\000\000\006\001\006\001\000\000\006\001\006\001\006\001\006\001\ -\006\001\006\001\000\000\000\000\006\001\006\001\006\001\006\001\ -\006\001\006\001\000\000\000\000\000\000\000\000\000\000\000\000\ -\006\001\006\001\000\000\000\000\006\001\006\001\006\001\000\000\ -\000\000\000\000\000\000\000\000\006\001\006\001\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\006\001\006\001\000\000\006\001\000\000\000\000\000\000\006\001\ -\006\001\000\000\006\001\000\000\000\000\006\001\006\001\000\000\ -\000\000\000\000\000\000\000\000\006\001\000\000\006\001\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\006\001\ -\006\001\005\001\006\001\006\001\006\001\006\001\000\000\000\000\ -\000\000\000\000\000\000\006\001\000\000\006\001\000\000\000\000\ -\006\001\000\000\000\000\006\001\000\000\000\000\000\000\006\001\ -\248\000\248\000\248\000\248\000\000\000\000\000\000\000\000\000\ -\248\000\248\000\248\000\000\000\000\000\248\000\248\000\000\000\ -\248\000\248\000\248\000\248\000\248\000\248\000\000\000\000\000\ -\248\000\248\000\248\000\248\000\248\000\248\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\248\000\248\000\000\000\000\000\ -\248\000\248\000\248\000\000\000\000\000\000\000\000\000\000\000\ -\248\000\248\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\248\000\248\000\000\000\248\000\ -\000\000\000\000\000\000\248\000\248\000\000\000\248\000\000\000\ -\000\000\248\000\248\000\000\000\000\000\000\000\000\000\000\000\ -\248\000\010\001\248\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\248\000\248\000\000\000\248\000\248\000\ -\248\000\248\000\000\000\000\000\000\000\000\000\000\000\248\000\ -\000\000\248\000\000\000\000\000\248\000\000\000\000\000\248\000\ -\000\000\000\000\000\000\248\000\249\000\249\000\249\000\249\000\ -\000\000\000\000\000\000\000\000\249\000\249\000\249\000\000\000\ -\000\000\249\000\249\000\000\000\249\000\249\000\249\000\249\000\ -\249\000\249\000\000\000\000\000\249\000\249\000\249\000\249\000\ -\249\000\249\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\249\000\249\000\000\000\000\000\249\000\249\000\249\000\000\000\ -\000\000\000\000\000\000\000\000\249\000\249\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\249\000\249\000\000\000\249\000\000\000\000\000\000\000\249\000\ -\249\000\009\001\249\000\000\000\000\000\249\000\249\000\000\000\ -\000\000\000\000\000\000\000\000\249\000\000\000\249\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\249\000\ -\249\000\000\000\249\000\249\000\249\000\249\000\000\000\000\000\ -\000\000\000\000\000\000\249\000\000\000\249\000\000\000\000\000\ -\249\000\000\000\000\000\249\000\000\000\000\000\000\000\249\000\ -\000\000\005\001\005\001\005\001\005\001\000\000\000\000\000\000\ -\000\000\005\001\005\001\005\001\000\000\000\000\005\001\005\001\ -\000\000\005\001\005\001\005\001\005\001\005\001\005\001\000\000\ -\000\000\005\001\005\001\005\001\005\001\005\001\005\001\000\000\ -\000\000\000\000\000\000\000\000\000\000\005\001\005\001\000\000\ -\000\000\005\001\005\001\005\001\000\000\000\000\000\000\000\000\ -\000\000\005\001\005\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\008\001\000\000\000\000\000\000\005\001\005\001\000\000\ -\005\001\000\000\000\000\000\000\005\001\005\001\000\000\005\001\ -\000\000\000\000\005\001\005\001\000\000\000\000\000\000\000\000\ -\000\000\005\001\000\000\005\001\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\005\001\005\001\000\000\005\001\ -\005\001\005\001\005\001\000\000\000\000\000\000\000\000\000\000\ -\005\001\010\001\005\001\000\000\010\001\005\001\000\000\000\000\ -\005\001\010\001\010\001\010\001\005\001\000\000\010\001\010\001\ -\000\000\010\001\010\001\010\001\010\001\010\001\010\001\000\000\ -\000\000\010\001\010\001\010\001\000\000\010\001\010\001\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\010\001\000\000\ -\000\000\010\001\010\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\010\001\010\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\131\001\000\000\000\000\000\000\010\001\000\000\000\000\ -\010\001\000\000\000\000\000\000\010\001\010\001\000\000\010\001\ -\000\000\000\000\010\001\010\001\000\000\000\000\000\000\000\000\ -\000\000\010\001\000\000\010\001\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\010\001\010\001\000\000\010\001\ -\010\001\010\001\010\001\000\000\000\000\000\000\000\000\000\000\ -\010\001\009\001\010\001\000\000\009\001\010\001\000\000\000\000\ -\010\001\009\001\009\001\009\001\010\001\000\000\009\001\009\001\ -\000\000\009\001\009\001\009\001\009\001\009\001\009\001\000\000\ -\000\000\009\001\009\001\009\001\000\000\009\001\009\001\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\009\001\000\000\ -\000\000\009\001\009\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\009\001\009\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\007\001\000\000\000\000\000\000\009\001\000\000\000\000\ -\009\001\000\000\000\000\000\000\009\001\009\001\000\000\009\001\ -\000\000\000\000\009\001\009\001\000\000\000\000\000\000\000\000\ -\000\000\009\001\000\000\009\001\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\009\001\009\001\000\000\009\001\ -\009\001\009\001\009\001\000\000\000\000\000\000\000\000\000\000\ -\009\001\008\001\009\001\000\000\008\001\009\001\000\000\000\000\ -\009\001\008\001\000\000\008\001\009\001\000\000\008\001\008\001\ -\000\000\008\001\008\001\008\001\008\001\008\001\008\001\000\000\ -\000\000\008\001\008\001\008\001\000\000\008\001\008\001\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\008\001\000\000\ -\000\000\008\001\008\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\008\001\008\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\130\001\000\000\000\000\000\000\008\001\000\000\000\000\ -\008\001\000\000\000\000\000\000\008\001\008\001\000\000\008\001\ -\000\000\000\000\008\001\008\001\000\000\000\000\000\000\000\000\ -\000\000\008\001\000\000\000\000\000\000\000\000\000\000\021\003\ -\000\000\000\000\000\000\000\000\008\001\008\001\000\000\008\001\ -\008\001\008\001\008\001\000\000\000\000\000\000\000\000\000\000\ -\008\001\131\001\008\001\000\000\131\001\008\001\000\000\000\000\ -\008\001\131\001\000\000\131\001\008\001\000\000\131\001\131\001\ -\000\000\131\001\131\001\131\001\131\001\131\001\131\001\000\000\ -\000\000\131\001\131\001\131\001\000\000\131\001\131\001\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\131\001\000\000\ -\000\000\131\001\131\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\131\001\131\001\000\000\011\001\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\131\001\000\000\000\000\ -\131\001\000\000\000\000\000\000\131\001\131\001\000\000\131\001\ -\000\000\000\000\131\001\131\001\000\000\000\000\000\000\000\000\ -\000\000\131\001\021\003\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\131\001\131\001\000\000\131\001\ -\131\001\131\001\131\001\000\000\000\000\000\000\000\000\000\000\ -\131\001\007\001\131\001\000\000\007\001\131\001\000\000\000\000\ -\131\001\007\001\000\000\007\001\131\001\000\000\007\001\007\001\ -\000\000\007\001\007\001\007\001\007\001\007\001\007\001\000\000\ -\000\000\007\001\007\001\007\001\000\000\007\001\007\001\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\007\001\000\000\ -\000\000\007\001\007\001\000\000\000\000\000\000\000\000\024\001\ -\000\000\007\001\007\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\007\001\000\000\000\000\ -\007\001\000\000\000\000\000\000\007\001\007\001\000\000\007\001\ -\000\000\000\000\007\001\007\001\000\000\000\000\000\000\000\000\ -\000\000\007\001\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\007\001\007\001\000\000\007\001\ -\007\001\007\001\007\001\000\000\000\000\000\000\000\000\000\000\ -\007\001\130\001\007\001\000\000\130\001\007\001\000\000\000\000\ -\007\001\130\001\000\000\130\001\007\001\000\000\130\001\130\001\ -\000\000\130\001\130\001\130\001\130\001\130\001\130\001\000\000\ -\000\000\130\001\130\001\130\001\000\000\130\001\130\001\021\003\ -\000\000\000\000\000\000\000\000\000\000\000\000\130\001\000\000\ -\000\000\130\001\130\001\000\000\021\003\000\000\000\000\014\001\ -\167\001\130\001\130\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\021\003\000\000\021\003\021\003\130\001\000\000\000\000\ -\130\001\000\000\000\000\000\000\130\001\130\001\000\000\130\001\ -\021\003\000\000\130\001\130\001\000\000\094\000\000\000\000\000\ -\136\000\130\001\137\000\138\000\030\000\000\000\139\000\000\000\ -\000\000\169\001\141\000\021\003\130\001\130\001\021\003\130\001\ -\130\001\130\001\130\001\021\003\011\001\000\000\000\000\011\001\ -\130\001\021\003\130\001\000\000\011\001\130\001\011\001\021\003\ -\130\001\011\001\011\001\144\000\130\001\011\001\000\000\011\001\ -\011\001\011\001\145\000\021\003\011\001\011\001\011\001\021\003\ -\011\001\011\001\021\003\000\000\000\000\021\003\146\000\147\000\ -\000\000\011\001\000\000\021\003\011\001\011\001\021\003\021\003\ -\000\000\000\000\243\000\000\000\011\001\011\001\000\000\000\000\ -\000\000\000\000\000\000\000\000\021\003\000\000\021\003\021\003\ -\011\001\000\000\000\000\011\001\000\000\000\000\000\000\011\001\ -\011\001\000\000\011\001\021\003\000\000\011\001\011\001\000\000\ -\104\000\174\003\000\000\136\000\011\001\137\000\138\000\030\000\ -\000\000\139\000\000\000\000\000\158\001\141\000\021\003\011\001\ -\011\001\000\000\011\001\011\001\011\001\011\001\021\003\024\001\ -\000\000\000\000\024\001\011\001\021\003\011\001\000\000\024\001\ -\011\001\024\001\021\003\011\001\024\001\024\001\144\000\011\001\ -\024\001\000\000\024\001\024\001\024\001\145\000\021\003\024\001\ -\024\001\024\001\021\003\024\001\024\001\000\000\000\000\000\000\ -\000\000\146\000\147\000\000\000\024\001\000\000\021\003\024\001\ -\024\001\021\003\000\000\000\000\000\000\017\001\000\000\024\001\ -\024\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\024\001\000\000\000\000\024\001\000\000\ -\000\000\000\000\024\001\024\001\000\000\024\001\000\000\000\000\ -\024\001\024\001\000\000\000\000\000\000\000\000\000\000\024\001\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\024\001\024\001\000\000\024\001\024\001\024\001\ -\024\001\000\000\000\000\000\000\000\000\000\000\024\001\014\001\ -\024\001\000\000\014\001\024\001\000\000\000\000\024\001\014\001\ -\000\000\014\001\024\001\000\000\014\001\014\001\000\000\000\000\ -\014\001\000\000\014\001\014\001\014\001\000\000\000\000\014\001\ -\014\001\014\001\000\000\014\001\014\001\094\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\014\001\000\000\000\000\014\001\ -\014\001\000\000\094\000\000\000\000\000\016\001\000\000\014\001\ -\014\001\000\000\000\000\000\000\000\000\000\000\000\000\094\000\ -\000\000\094\000\094\000\014\001\000\000\000\000\014\001\000\000\ -\000\000\000\000\014\001\014\001\000\000\014\001\094\000\000\000\ -\014\001\014\001\000\000\021\003\000\000\000\000\136\000\014\001\ -\137\000\138\000\030\000\000\000\139\000\000\000\000\000\158\001\ -\141\000\094\000\014\001\014\001\000\000\014\001\014\001\014\001\ -\014\001\094\000\243\000\000\000\000\000\243\000\014\001\094\000\ -\014\001\000\000\243\000\014\001\243\000\094\000\014\001\243\000\ -\243\000\144\000\014\001\243\000\000\000\243\000\243\000\243\000\ -\145\000\094\000\243\000\243\000\243\000\094\000\243\000\243\000\ -\104\000\000\000\000\000\000\000\146\000\147\000\000\000\243\000\ -\000\000\094\000\243\000\243\000\094\000\104\000\000\000\000\000\ -\015\001\000\000\243\000\243\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\104\000\000\000\104\000\104\000\243\000\000\000\ -\000\000\243\000\000\000\000\000\000\000\243\000\243\000\000\000\ -\243\000\104\000\000\000\243\000\243\000\000\000\099\000\000\000\ -\000\000\000\000\243\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\104\000\243\000\243\000\000\000\ -\243\000\243\000\243\000\243\000\104\000\017\001\000\000\000\000\ -\017\001\243\000\104\000\243\000\000\000\017\001\243\000\017\001\ -\104\000\243\000\017\001\017\001\000\000\243\000\017\001\000\000\ -\017\001\017\001\017\001\000\000\104\000\017\001\017\001\017\001\ -\104\000\017\001\017\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\017\001\000\000\104\000\017\001\017\001\104\000\ -\000\000\000\000\000\000\020\001\000\000\017\001\017\001\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\017\001\000\000\000\000\017\001\000\000\000\000\000\000\ -\017\001\017\001\000\000\017\001\000\000\000\000\017\001\017\001\ -\000\000\000\000\000\000\000\000\000\000\017\001\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\017\001\017\001\000\000\017\001\017\001\017\001\017\001\000\000\ -\000\000\000\000\000\000\000\000\017\001\016\001\017\001\000\000\ -\016\001\017\001\000\000\000\000\017\001\016\001\000\000\016\001\ -\017\001\000\000\016\001\016\001\000\000\000\000\016\001\000\000\ -\016\001\016\001\016\001\000\000\000\000\016\001\016\001\016\001\ -\000\000\016\001\016\001\021\003\000\000\000\000\000\000\000\000\ -\000\000\000\000\016\001\000\000\000\000\016\001\016\001\000\000\ -\021\003\000\000\000\000\018\001\000\000\016\001\016\001\000\000\ -\000\000\000\000\000\000\000\000\000\000\021\003\000\000\021\003\ -\021\003\016\001\000\000\000\000\016\001\000\000\000\000\000\000\ -\016\001\016\001\000\000\016\001\021\003\000\000\016\001\016\001\ -\000\000\103\000\000\000\000\000\000\000\016\001\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\021\003\ -\016\001\016\001\000\000\016\001\016\001\016\001\016\001\021\003\ -\015\001\000\000\000\000\015\001\016\001\021\003\016\001\000\000\ -\015\001\016\001\015\001\021\003\016\001\015\001\015\001\000\000\ -\016\001\015\001\000\000\015\001\015\001\015\001\000\000\021\003\ -\015\001\015\001\015\001\021\003\015\001\015\001\099\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\015\001\000\000\021\003\ -\015\001\015\001\021\003\099\000\000\000\000\000\019\001\000\000\ -\015\001\015\001\000\000\000\000\000\000\000\000\000\000\000\000\ -\099\000\000\000\099\000\099\000\015\001\000\000\000\000\015\001\ -\000\000\000\000\000\000\015\001\015\001\000\000\015\001\099\000\ -\000\000\015\001\015\001\000\000\000\000\000\000\000\000\000\000\ -\015\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\099\000\015\001\015\001\000\000\015\001\015\001\ -\015\001\015\001\099\000\020\001\000\000\000\000\020\001\015\001\ -\099\000\015\001\000\000\020\001\015\001\020\001\099\000\015\001\ -\020\001\020\001\000\000\015\001\020\001\000\000\020\001\020\001\ -\020\001\000\000\099\000\020\001\020\001\020\001\099\000\020\001\ -\020\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\020\001\000\000\099\000\020\001\020\001\099\000\000\000\000\000\ -\000\000\023\001\000\000\020\001\020\001\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\020\001\ -\000\000\000\000\020\001\000\000\000\000\000\000\020\001\020\001\ -\000\000\020\001\000\000\000\000\020\001\020\001\000\000\000\000\ -\000\000\000\000\000\000\020\001\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\020\001\020\001\ -\000\000\020\001\020\001\020\001\020\001\000\000\000\000\000\000\ -\000\000\000\000\020\001\018\001\020\001\000\000\018\001\020\001\ -\000\000\000\000\020\001\018\001\000\000\018\001\020\001\000\000\ -\018\001\018\001\000\000\000\000\018\001\000\000\018\001\018\001\ -\018\001\000\000\000\000\018\001\018\001\018\001\000\000\018\001\ -\018\001\103\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\018\001\000\000\000\000\018\001\018\001\000\000\103\000\000\000\ -\000\000\021\001\000\000\018\001\018\001\000\000\000\000\000\000\ -\000\000\000\000\000\000\103\000\000\000\103\000\103\000\018\001\ -\000\000\000\000\018\001\000\000\000\000\000\000\018\001\018\001\ -\000\000\018\001\103\000\000\000\018\001\018\001\000\000\000\000\ -\000\000\000\000\000\000\018\001\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\103\000\018\001\018\001\ -\000\000\018\001\018\001\018\001\018\001\103\000\019\001\000\000\ -\000\000\019\001\018\001\103\000\018\001\000\000\019\001\018\001\ -\019\001\103\000\018\001\019\001\019\001\000\000\018\001\019\001\ -\000\000\019\001\019\001\019\001\000\000\103\000\019\001\019\001\ -\019\001\103\000\019\001\019\001\010\000\000\000\157\001\000\000\ -\000\000\000\000\000\000\019\001\000\000\103\000\019\001\019\001\ -\103\000\000\000\000\000\000\000\022\001\000\000\019\001\019\001\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\019\001\000\000\000\000\019\001\000\000\000\000\ -\000\000\019\001\019\001\000\000\019\001\000\000\000\000\019\001\ -\019\001\000\000\000\000\000\000\000\000\136\000\019\001\137\000\ -\138\000\030\000\000\000\139\000\000\000\000\000\158\001\141\000\ -\000\000\019\001\019\001\000\000\019\001\019\001\019\001\019\001\ -\000\000\023\001\000\000\000\000\023\001\019\001\000\000\019\001\ -\000\000\023\001\019\001\023\001\000\000\019\001\023\001\023\001\ -\144\000\019\001\023\001\000\000\023\001\023\001\023\001\145\000\ -\000\000\023\001\023\001\023\001\000\000\023\001\023\001\000\000\ -\000\000\000\000\000\000\146\000\147\000\000\000\023\001\000\000\ -\000\000\023\001\023\001\000\000\000\000\000\000\000\000\207\000\ -\000\000\023\001\023\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\023\001\000\000\000\000\ -\023\001\000\000\000\000\000\000\023\001\023\001\000\000\023\001\ -\000\000\000\000\023\001\023\001\000\000\000\000\000\000\000\000\ -\000\000\023\001\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\023\001\023\001\000\000\023\001\ -\023\001\023\001\023\001\000\000\000\000\000\000\000\000\000\000\ -\023\001\021\001\023\001\000\000\021\001\023\001\000\000\000\000\ -\023\001\021\001\000\000\021\001\023\001\000\000\021\001\021\001\ -\000\000\000\000\021\001\000\000\021\001\021\001\021\001\000\000\ -\000\000\021\001\021\001\021\001\000\000\021\001\021\001\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\021\001\000\000\ -\000\000\021\001\021\001\000\000\000\000\000\000\000\000\244\000\ -\000\000\021\001\021\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\021\001\000\000\000\000\ -\021\001\000\000\000\000\000\000\021\001\021\001\000\000\021\001\ -\000\000\000\000\021\001\021\001\000\000\000\000\000\000\000\000\ -\000\000\021\001\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\021\001\021\001\000\000\021\001\ -\021\001\021\001\021\001\000\000\022\001\000\000\000\000\022\001\ -\021\001\000\000\021\001\000\000\022\001\021\001\022\001\000\000\ -\021\001\022\001\022\001\000\000\021\001\022\001\000\000\022\001\ -\022\001\022\001\000\000\000\000\022\001\022\001\022\001\000\000\ -\022\001\022\001\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\022\001\000\000\000\000\022\001\022\001\000\000\000\000\ -\000\000\000\000\000\000\000\000\022\001\022\001\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\061\002\000\000\000\000\ -\022\001\000\000\000\000\022\001\000\000\000\000\000\000\022\001\ -\022\001\000\000\022\001\000\000\000\000\022\001\022\001\000\000\ -\000\000\000\000\000\000\000\000\022\001\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\022\001\ -\022\001\000\000\022\001\022\001\022\001\022\001\000\000\207\000\ -\000\000\000\000\207\000\022\001\000\000\022\001\000\000\207\000\ -\022\001\207\000\000\000\022\001\207\000\207\000\000\000\022\001\ -\207\000\000\000\207\000\207\000\207\000\000\000\000\000\207\000\ -\207\000\207\000\000\000\207\000\207\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\207\000\000\000\000\000\207\000\ -\207\000\000\000\000\000\000\000\000\000\000\000\000\000\207\000\ -\207\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\095\002\000\000\000\000\207\000\000\000\000\000\207\000\000\000\ -\000\000\000\000\207\000\207\000\000\000\207\000\000\000\000\000\ -\207\000\207\000\000\000\000\000\000\000\000\000\000\000\207\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\207\000\207\000\000\000\207\000\000\000\207\000\ -\207\000\000\000\000\000\000\000\000\000\000\000\207\000\244\000\ -\207\000\000\000\244\000\207\000\000\000\000\000\207\000\244\000\ -\000\000\244\000\207\000\000\000\244\000\244\000\000\000\000\000\ -\244\000\000\000\244\000\244\000\244\000\000\000\000\000\244\000\ -\000\000\244\000\000\000\244\000\244\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\244\000\000\000\000\000\244\000\ -\244\000\000\000\000\000\000\000\000\000\000\000\000\000\244\000\ -\244\000\000\000\000\000\059\002\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\244\000\000\000\000\000\244\000\000\000\ -\000\000\000\000\244\000\244\000\000\000\244\000\000\000\000\000\ -\244\000\244\000\000\000\000\000\000\000\000\000\000\000\244\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\244\000\244\000\000\000\244\000\244\000\244\000\ -\244\000\000\000\000\000\000\000\000\000\000\000\244\000\000\000\ -\244\000\000\000\000\000\244\000\000\000\061\002\244\000\061\002\ -\061\002\061\002\244\000\000\000\000\000\061\002\000\000\000\000\ -\000\000\000\000\061\002\000\000\000\000\000\000\061\002\061\002\ -\061\002\000\000\000\000\000\000\000\000\154\003\000\000\061\002\ -\061\002\061\002\061\002\000\000\000\000\000\000\000\000\000\000\ -\000\000\061\002\000\000\000\000\000\000\061\002\061\002\000\000\ -\057\002\000\000\000\000\000\000\000\000\061\002\061\002\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\061\002\000\000\000\000\061\002\000\000\000\000\061\002\ -\061\002\061\002\000\000\061\002\000\000\000\000\061\002\061\002\ -\000\000\000\000\000\000\000\000\136\000\061\002\137\000\138\000\ -\030\000\000\000\139\000\000\000\000\000\140\000\141\000\000\000\ -\061\002\061\002\000\000\061\002\061\002\061\002\000\000\000\000\ -\095\002\061\002\095\002\095\002\095\002\000\000\142\000\000\000\ -\095\002\061\002\000\000\000\000\061\002\095\002\143\000\144\000\ -\061\002\095\002\095\002\095\002\000\000\000\000\145\000\000\000\ -\000\000\000\000\095\002\095\002\095\002\095\002\000\000\000\000\ -\059\005\000\000\146\000\147\000\095\002\000\000\000\000\000\000\ -\000\000\095\002\000\000\058\002\000\000\000\000\000\000\160\005\ -\095\002\095\002\000\000\000\000\000\000\000\000\243\001\000\000\ -\000\000\000\000\000\000\000\000\095\002\000\000\000\000\095\002\ -\000\000\000\000\095\002\095\002\095\002\000\000\095\002\000\000\ -\000\000\095\002\095\002\000\000\000\000\000\000\000\000\061\005\ -\095\002\137\000\138\000\030\000\000\000\139\000\000\000\000\000\ -\140\000\062\005\000\000\095\002\095\002\000\000\095\002\095\002\ -\095\002\095\002\000\000\059\002\000\000\059\002\059\002\059\002\ -\000\000\142\000\000\000\059\002\095\002\000\000\000\000\095\002\ -\059\002\143\000\144\000\095\002\059\002\059\002\059\002\000\000\ -\000\000\145\000\000\000\000\000\000\000\059\002\059\002\059\002\ -\059\002\000\000\246\001\000\000\000\000\064\005\147\000\059\002\ -\000\000\000\000\000\000\000\000\059\002\000\000\056\002\000\000\ -\000\000\000\000\000\000\059\002\059\002\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\059\002\ -\000\000\000\000\059\002\000\000\000\000\059\002\059\002\059\002\ -\000\000\059\002\000\000\000\000\000\000\059\002\000\000\000\000\ -\000\000\000\000\000\000\059\002\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\059\002\059\002\ -\000\000\059\002\059\002\059\002\059\002\000\000\000\000\000\000\ -\057\002\000\000\057\002\057\002\057\002\000\000\000\000\059\002\ -\057\002\000\000\059\002\000\000\000\000\057\002\059\002\000\000\ -\000\000\057\002\057\002\057\002\000\000\000\000\000\000\000\000\ -\000\000\000\000\057\002\057\002\057\002\057\002\000\000\000\000\ -\000\000\000\000\000\000\000\000\057\002\000\000\000\000\000\000\ -\000\000\057\002\000\000\053\002\000\000\000\000\000\000\000\000\ -\057\002\057\002\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\057\002\000\000\000\000\057\002\ -\000\000\000\000\057\002\057\002\057\002\000\000\057\002\000\000\ -\000\000\000\000\057\002\000\000\000\000\000\000\000\000\136\000\ -\057\002\137\000\138\000\030\000\000\000\139\000\000\000\000\000\ -\140\000\141\000\000\000\057\002\057\002\000\000\057\002\057\002\ -\057\002\057\002\177\001\058\002\000\000\058\002\058\002\058\002\ -\000\000\142\000\000\000\058\002\057\002\000\000\000\000\057\002\ -\058\002\143\000\144\000\057\002\058\002\058\002\058\002\042\002\ -\000\000\145\000\000\000\000\000\000\000\058\002\058\002\058\002\ -\058\002\000\000\000\000\000\000\000\000\146\000\147\000\058\002\ -\000\000\000\000\000\000\000\000\058\002\000\000\000\000\000\000\ -\000\000\000\000\000\000\058\002\058\002\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\058\002\ -\000\000\000\000\058\002\000\000\000\000\058\002\058\002\058\002\ -\000\000\058\002\000\000\000\000\000\000\058\002\000\000\000\000\ -\000\000\041\002\136\000\058\002\137\000\138\000\030\000\000\000\ -\139\000\000\000\000\000\140\000\141\000\000\000\058\002\058\002\ -\000\000\058\002\058\002\058\002\058\002\000\000\056\002\000\000\ -\056\002\056\002\056\002\000\000\142\000\000\000\056\002\058\002\ -\000\000\000\000\058\002\056\002\143\000\126\003\058\002\056\002\ -\056\002\056\002\000\000\000\000\145\000\000\000\000\000\000\000\ -\056\002\056\002\056\002\056\002\000\000\000\000\000\000\068\006\ -\146\000\147\000\056\002\039\002\000\000\000\000\000\000\056\002\ -\000\000\000\000\000\000\000\000\000\000\000\000\056\002\056\002\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\056\002\000\000\000\000\056\002\000\000\000\000\ -\056\002\056\002\056\002\000\000\056\002\000\000\000\000\000\000\ -\056\002\000\000\000\000\000\000\000\000\000\000\056\002\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\056\002\056\002\000\000\056\002\056\002\056\002\056\002\ -\000\000\197\000\000\000\053\002\000\000\053\002\053\002\000\000\ -\000\000\000\000\056\002\053\002\000\000\056\002\000\000\000\000\ -\053\002\056\002\000\000\000\000\053\002\053\002\053\002\000\000\ -\000\000\000\000\000\000\000\000\000\000\053\002\053\002\053\002\ -\053\002\000\000\000\000\000\000\000\000\000\000\000\000\053\002\ -\000\000\000\000\000\000\000\000\053\002\000\000\000\000\000\000\ -\000\000\000\000\000\000\053\002\053\002\000\000\000\000\000\000\ -\000\000\000\000\000\000\084\000\000\000\000\000\000\000\053\002\ -\000\000\000\000\053\002\000\000\000\000\053\002\053\002\053\002\ -\000\000\053\002\000\000\000\000\010\000\053\002\157\001\042\002\ -\000\000\000\000\042\002\053\002\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\042\002\000\000\053\002\053\002\ -\042\002\053\002\053\002\053\002\053\002\000\000\000\000\000\000\ -\000\000\042\002\042\002\042\002\042\002\000\000\000\000\053\002\ -\000\000\000\000\053\002\000\000\000\000\000\000\053\002\000\000\ -\042\002\000\000\000\000\000\000\000\000\136\000\000\000\137\000\ -\138\000\030\000\000\000\139\000\000\000\000\000\158\001\141\000\ -\000\000\041\002\000\000\042\002\041\002\000\000\042\002\000\000\ -\000\000\042\002\042\002\042\002\000\000\000\000\041\002\000\000\ -\042\002\042\002\041\002\000\000\000\000\000\000\000\000\042\002\ -\144\000\000\000\227\002\041\002\041\002\041\002\041\002\145\000\ -\000\000\000\000\000\000\042\002\023\003\042\002\000\000\042\002\ -\042\002\000\000\041\002\146\000\147\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\042\002\000\000\000\000\042\002\000\000\ -\000\000\000\000\042\002\039\002\000\000\041\002\039\002\000\000\ -\041\002\000\000\000\000\041\002\041\002\041\002\000\000\000\000\ -\039\002\000\000\041\002\041\002\039\002\000\000\000\000\000\000\ -\000\000\041\002\000\000\000\000\000\000\039\002\039\002\039\002\ -\039\002\000\000\000\000\000\000\000\000\041\002\000\000\041\002\ -\000\000\041\002\041\002\000\000\039\002\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\041\002\000\000\000\000\ -\041\002\000\000\000\000\000\000\041\002\000\000\000\000\039\002\ -\000\000\197\000\039\002\000\000\197\000\039\002\039\002\039\002\ -\000\000\000\000\000\000\000\000\039\002\039\002\197\000\000\000\ -\000\000\000\000\197\000\039\002\197\000\000\000\000\000\000\000\ -\000\000\000\000\128\000\197\000\197\000\197\000\197\000\039\002\ -\000\000\039\002\000\000\039\002\039\002\000\000\000\000\000\000\ -\000\000\000\000\197\000\000\000\000\000\000\000\000\000\039\002\ -\000\000\000\000\039\002\000\000\000\000\000\000\039\002\000\000\ -\000\000\000\000\000\000\084\000\000\000\197\000\084\000\000\000\ -\197\000\000\000\000\000\000\000\197\000\197\000\000\000\000\000\ -\084\000\000\000\197\000\197\000\084\000\000\000\000\000\000\000\ -\000\000\197\000\000\000\000\000\000\000\084\000\084\000\084\000\ -\084\000\000\000\000\000\000\000\000\000\197\000\000\000\197\000\ -\000\000\197\000\197\000\000\000\084\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\197\000\000\000\000\000\ -\197\000\120\000\000\000\000\000\197\000\000\000\000\000\084\000\ -\000\000\000\000\084\000\000\000\000\000\000\000\084\000\084\000\ -\000\000\000\000\000\000\000\000\084\000\084\000\244\004\000\000\ -\137\000\138\000\030\000\084\000\139\000\000\000\245\004\246\004\ -\141\000\000\000\000\000\000\000\000\000\000\000\000\000\084\000\ -\000\000\084\000\000\000\084\000\084\000\247\004\000\000\000\000\ -\248\004\000\000\000\000\000\000\000\000\000\000\000\000\084\000\ -\249\004\144\000\084\000\000\000\023\003\000\000\084\000\023\003\ -\145\000\023\003\023\003\023\003\023\003\000\000\000\000\023\003\ -\023\003\023\003\000\000\000\000\146\000\147\000\000\000\023\003\ -\000\000\000\000\000\000\023\003\000\000\000\000\023\003\000\000\ -\023\003\023\003\023\003\023\003\023\003\023\003\023\003\023\003\ -\023\003\000\000\000\000\023\003\023\003\023\003\000\000\000\000\ -\000\000\000\000\000\000\000\000\023\003\023\003\023\003\023\003\ -\023\003\023\003\023\003\023\003\023\003\023\003\023\003\023\003\ -\023\003\023\003\150\001\023\003\023\003\023\003\000\000\023\003\ -\023\003\023\003\023\003\023\003\023\003\000\000\023\003\023\003\ -\023\003\023\003\023\003\000\000\023\003\023\003\000\000\000\000\ -\023\003\023\003\000\000\023\003\023\003\023\003\023\003\023\003\ -\023\003\023\003\000\000\023\003\023\003\023\003\000\000\023\003\ -\000\000\023\003\023\003\000\000\023\003\000\000\023\003\023\003\ -\023\003\023\003\023\003\023\003\023\003\000\000\023\003\009\000\ -\010\000\011\000\000\000\000\000\000\000\012\000\013\000\014\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\015\000\016\000\ -\017\000\018\000\019\000\020\000\021\000\000\000\000\000\000\000\ -\000\000\022\000\000\000\023\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\024\000\000\000\025\000\026\000\ -\027\000\028\000\029\000\000\000\000\000\030\000\031\000\000\000\ -\000\000\032\000\033\000\034\000\000\000\164\002\035\000\036\000\ -\000\000\037\000\038\000\000\000\039\000\000\000\040\000\000\000\ -\041\000\000\000\042\000\000\000\000\000\000\000\043\000\044\000\ -\000\000\045\000\000\000\000\000\000\000\000\000\009\000\010\000\ -\011\000\000\000\129\000\121\000\012\000\013\000\014\000\047\000\ -\000\000\000\000\000\000\000\000\048\000\049\000\050\000\051\000\ -\052\000\053\000\000\000\000\000\054\000\015\000\016\000\017\000\ -\018\000\019\000\020\000\021\000\000\000\000\000\000\000\000\000\ -\022\000\000\000\023\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\024\000\000\000\025\000\026\000\027\000\ -\028\000\029\000\000\000\000\000\030\000\031\000\000\000\000\000\ -\032\000\033\000\034\000\000\000\000\000\035\000\036\000\000\000\ -\037\000\038\000\000\000\039\000\000\000\040\000\000\000\041\000\ -\000\000\042\000\000\000\109\000\000\000\043\000\044\000\000\000\ -\045\000\178\001\136\000\000\000\137\000\138\000\030\000\000\000\ -\139\000\000\000\121\000\140\000\141\000\000\000\047\000\000\000\ -\000\000\000\000\000\000\048\000\049\000\050\000\051\000\052\000\ -\053\000\000\000\000\000\054\000\142\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\143\000\144\000\000\000\009\000\ -\010\000\011\000\000\000\000\000\145\000\012\000\013\000\014\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\146\000\147\000\000\000\000\000\000\000\000\000\015\000\016\000\ -\017\000\018\000\019\000\020\000\021\000\000\000\000\000\000\000\ -\000\000\022\000\000\000\023\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\024\000\000\000\025\000\026\000\ -\027\000\028\000\029\000\000\000\000\000\030\000\031\000\000\000\ -\000\000\032\000\033\000\034\000\000\000\000\000\035\000\036\000\ -\000\000\037\000\038\000\000\000\039\000\132\000\040\000\000\000\ -\041\000\000\000\042\000\000\000\000\000\000\000\043\000\044\000\ -\000\000\045\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\121\000\000\000\000\000\000\000\047\000\ -\000\000\000\000\000\000\000\000\048\000\049\000\050\000\051\000\ -\052\000\053\000\000\000\000\000\054\000\164\002\000\000\000\000\ -\000\000\164\002\000\000\164\002\000\000\164\002\000\000\164\002\ -\000\000\164\002\000\000\164\002\164\002\000\000\164\002\164\002\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\164\002\164\002\000\000\164\002\164\002\134\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\164\002\ -\164\002\164\002\164\002\000\000\164\002\164\002\000\000\000\000\ -\164\002\000\000\000\000\000\000\000\000\164\002\164\002\164\002\ -\000\000\000\000\000\000\000\000\164\002\000\000\164\002\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\164\002\000\000\ -\000\000\164\002\000\000\000\000\000\000\000\000\164\002\135\000\ -\164\002\164\002\000\000\164\002\164\002\000\000\164\002\000\000\ -\000\000\000\000\164\002\109\000\000\000\164\002\000\000\164\002\ -\000\000\178\001\164\002\164\002\000\000\178\001\164\002\178\001\ -\109\000\178\001\000\000\178\001\000\000\178\001\000\000\178\001\ -\178\001\000\000\178\001\178\001\000\000\109\000\000\000\109\000\ -\109\000\000\000\000\000\000\000\178\001\000\000\000\000\178\001\ -\178\001\000\000\000\000\000\000\109\000\000\000\000\000\000\000\ -\000\000\130\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\178\001\178\001\000\000\178\001\109\000\ -\178\001\178\001\000\000\000\000\178\001\000\000\109\000\109\000\ -\000\000\178\001\178\001\178\001\000\000\109\000\000\000\000\000\ -\178\001\000\000\178\001\109\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\178\001\000\000\000\000\178\001\000\000\109\000\ -\000\000\000\000\178\001\109\000\178\001\178\001\000\000\178\001\ -\178\001\000\000\178\001\136\000\000\000\000\000\178\001\109\000\ -\000\000\178\001\109\000\178\001\000\000\132\000\178\001\178\001\ -\132\000\132\000\178\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\132\000\132\000\000\000\000\000\000\000\000\000\ -\132\000\000\000\000\000\000\000\000\000\000\000\000\000\132\000\ -\000\000\132\000\132\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\132\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\132\000\132\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\132\000\000\000\000\000\132\000\000\000\000\000\132\000\ -\132\000\132\000\000\000\132\000\000\000\134\000\000\000\132\000\ -\134\000\134\000\014\002\000\000\000\000\132\000\000\000\000\000\ -\000\000\000\000\134\000\134\000\000\000\000\000\000\000\000\000\ -\134\000\132\000\000\000\132\000\000\000\132\000\132\000\134\000\ -\000\000\134\000\134\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\132\000\000\000\000\000\132\000\000\000\134\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\134\000\134\000\000\000\ -\000\000\000\000\000\000\181\000\000\000\000\000\000\000\135\000\ -\000\000\134\000\135\000\135\000\134\000\000\000\000\000\134\000\ -\134\000\134\000\000\000\134\000\135\000\135\000\000\000\134\000\ -\000\000\000\000\135\000\000\000\000\000\134\000\000\000\000\000\ -\000\000\135\000\000\000\135\000\135\000\000\000\000\000\000\000\ -\000\000\134\000\000\000\134\000\000\000\134\000\134\000\000\000\ -\135\000\000\000\000\000\000\000\000\000\183\002\000\000\135\000\ -\135\000\134\000\000\000\000\000\134\000\000\000\000\000\000\000\ -\000\000\130\000\000\000\135\000\130\000\130\000\135\000\000\000\ -\000\000\000\000\135\000\135\000\000\000\135\000\130\000\130\000\ -\000\000\135\000\000\000\000\000\130\000\000\000\000\000\135\000\ -\000\000\000\000\000\000\130\000\000\000\130\000\130\000\000\000\ -\000\000\000\000\000\000\135\000\000\000\135\000\000\000\135\000\ -\135\000\000\000\130\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\130\000\130\000\135\000\000\000\000\000\135\000\000\000\ -\000\000\000\000\000\000\136\000\000\000\130\000\136\000\136\000\ -\130\000\015\002\000\000\000\000\130\000\130\000\000\000\130\000\ -\136\000\136\000\000\000\130\000\000\000\000\000\136\000\000\000\ -\000\000\130\000\000\000\000\000\000\000\136\000\000\000\136\000\ -\136\000\000\000\000\000\000\000\000\000\130\000\000\000\130\000\ -\000\000\130\000\130\000\000\000\136\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\136\000\136\000\130\000\000\000\000\000\ -\130\000\000\000\000\000\000\000\000\000\000\000\000\000\136\000\ -\000\000\000\000\136\000\182\000\000\000\000\000\136\000\136\000\ -\000\000\136\000\000\000\000\000\000\000\136\000\136\000\000\000\ -\137\000\138\000\030\000\136\000\139\000\000\000\000\000\140\000\ -\141\000\000\000\014\002\000\000\000\000\014\002\000\000\136\000\ -\000\000\136\000\014\002\136\000\136\000\000\000\000\000\014\002\ -\142\000\000\000\000\000\000\000\000\000\014\002\000\000\136\000\ -\143\000\126\003\136\000\000\000\014\002\000\000\014\002\014\002\ -\145\000\000\000\000\000\000\000\000\000\021\003\000\000\000\000\ -\000\000\000\000\014\002\014\002\146\000\147\000\000\000\000\000\ -\000\000\000\000\000\000\181\000\000\000\000\000\181\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\014\002\000\000\ -\181\000\014\002\000\000\000\000\014\002\014\002\014\002\000\000\ -\000\000\000\000\000\000\098\002\014\002\181\000\181\000\181\000\ -\181\000\000\000\014\002\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\181\000\000\000\014\002\023\003\ -\000\000\000\000\014\002\014\002\000\000\183\002\098\002\000\000\ -\183\002\000\000\000\000\000\000\000\000\000\000\014\002\181\000\ -\000\000\014\002\183\002\080\002\000\000\181\000\181\000\181\000\ -\000\000\000\000\000\000\000\000\080\002\181\000\000\000\183\002\ -\183\002\183\002\183\002\181\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\183\002\181\000\ -\000\000\181\000\000\000\181\000\080\002\000\000\000\000\080\002\ -\000\000\232\001\000\000\000\000\000\000\000\000\000\000\181\000\ -\080\002\183\002\181\000\000\000\000\000\174\002\000\000\183\002\ -\183\002\183\002\000\000\000\000\000\000\000\000\174\002\183\002\ -\000\000\015\002\000\000\000\000\015\002\183\002\000\000\000\000\ -\000\000\015\002\000\000\000\000\000\000\000\000\015\002\000\000\ -\000\000\183\002\000\000\183\002\015\002\183\002\174\002\000\000\ -\000\000\174\002\071\000\015\002\000\000\015\002\015\002\000\000\ -\000\000\183\002\174\002\000\000\183\002\000\000\000\000\000\000\ -\000\000\015\002\015\002\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\182\000\000\000\015\002\182\000\000\000\ -\015\002\000\000\000\000\015\002\015\002\015\002\000\000\000\000\ -\182\000\000\000\015\002\015\002\000\000\000\000\182\000\233\001\ -\000\000\015\002\000\000\000\000\000\000\182\000\182\000\182\000\ -\182\000\000\000\000\000\000\000\000\000\015\002\000\000\000\000\ -\000\000\015\002\015\002\000\000\182\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\182\000\000\000\015\002\000\000\000\000\ -\015\002\000\000\000\000\000\000\000\000\021\003\000\000\182\000\ -\021\003\000\000\182\000\000\000\000\000\000\000\182\000\182\000\ -\000\000\182\000\021\003\000\000\235\001\182\000\000\000\000\000\ -\021\003\000\000\000\000\182\000\000\000\000\000\000\000\021\003\ -\000\000\021\003\021\003\000\000\000\000\000\000\000\000\182\000\ -\000\000\182\000\000\000\182\000\182\000\021\003\021\003\000\000\ -\000\000\000\000\000\000\000\000\000\000\021\003\021\003\182\000\ -\000\000\000\000\182\000\000\000\000\000\000\000\000\000\023\003\ -\000\000\021\003\023\003\000\000\021\003\000\000\000\000\023\003\ -\000\000\021\003\000\000\021\003\023\003\000\000\000\000\021\003\ -\000\000\000\000\023\003\000\000\000\000\021\003\000\000\000\000\ -\000\000\023\003\000\000\023\003\023\003\000\000\000\000\234\001\ -\000\000\021\003\000\000\000\000\000\000\021\003\021\003\000\000\ -\023\003\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\021\003\000\000\000\000\021\003\000\000\000\000\000\000\ -\000\000\232\001\000\000\023\003\232\001\000\000\023\003\000\000\ -\000\000\000\000\023\003\023\003\000\000\000\000\232\001\000\000\ -\000\000\023\003\000\000\000\000\232\001\000\000\000\000\023\003\ -\000\000\000\000\000\000\232\001\236\001\232\001\232\001\000\000\ -\000\000\000\000\000\000\023\003\000\000\011\002\000\000\023\003\ -\023\003\000\000\232\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\071\000\023\003\000\000\071\000\023\003\000\000\ -\000\000\000\000\000\000\000\000\000\000\232\001\000\000\071\000\ -\232\001\000\000\000\000\000\000\232\001\232\001\000\000\000\000\ -\000\000\000\000\000\000\232\001\071\000\000\000\071\000\071\000\ -\000\000\232\001\000\000\000\000\000\000\000\000\000\000\240\001\ -\000\000\000\000\071\000\071\000\000\000\232\001\000\000\000\000\ -\000\000\232\001\232\001\000\000\000\000\000\000\000\000\233\001\ -\000\000\000\000\233\001\000\000\000\000\232\001\071\000\000\000\ -\232\001\071\000\000\000\000\000\233\001\071\000\071\000\000\000\ -\000\000\000\000\233\001\000\000\071\000\000\000\000\000\000\000\ -\000\000\233\001\071\000\233\001\233\001\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\011\002\000\000\071\000\000\000\ -\233\001\000\000\071\000\071\000\000\000\021\003\000\000\000\000\ -\000\000\000\000\000\000\000\000\235\001\000\000\071\000\235\001\ -\000\000\071\000\000\000\233\001\000\000\000\000\233\001\000\000\ -\000\000\235\001\233\001\233\001\000\000\000\000\000\000\235\001\ -\000\000\233\001\000\000\000\000\000\000\000\000\235\001\233\001\ -\235\001\235\001\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\233\001\000\000\235\001\000\000\233\001\ -\233\001\000\000\125\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\233\001\000\000\000\000\233\001\000\000\ -\235\001\000\000\000\000\235\001\000\000\000\000\000\000\235\001\ -\235\001\000\000\000\000\000\000\000\000\000\000\235\001\234\001\ -\000\000\000\000\234\001\000\000\235\001\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\234\001\000\000\000\000\000\000\ -\235\001\000\000\234\001\000\000\235\001\235\001\000\000\126\000\ -\000\000\234\001\000\000\234\001\234\001\000\000\000\000\000\000\ -\235\001\000\000\000\000\235\001\000\000\000\000\000\000\000\000\ -\234\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\236\001\000\000\000\000\236\001\ -\000\000\000\000\000\000\234\001\000\000\011\002\234\001\000\000\ -\000\000\236\001\234\001\234\001\000\000\011\002\000\000\236\001\ -\023\003\234\001\011\002\000\000\000\000\000\000\236\001\234\001\ -\236\001\236\001\023\003\000\000\000\000\000\000\000\000\011\002\ -\000\000\011\002\011\002\234\001\000\000\236\001\000\000\234\001\ -\234\001\000\000\000\000\000\000\000\000\000\000\011\002\000\000\ -\000\000\000\000\000\000\234\001\000\000\000\000\234\001\240\001\ -\236\001\000\000\240\001\236\001\000\000\000\000\000\000\236\001\ -\236\001\011\002\000\000\000\000\240\001\000\000\236\001\011\002\ -\011\002\011\002\240\001\000\000\236\001\000\000\000\000\011\002\ -\000\000\240\001\000\000\240\001\240\001\011\002\000\000\000\000\ -\236\001\000\000\000\000\118\000\236\001\236\001\000\000\000\000\ -\240\001\011\002\000\000\000\000\000\000\011\002\000\000\000\000\ -\236\001\000\000\000\000\236\001\011\002\000\000\000\000\000\000\ -\000\000\011\002\000\000\240\001\011\002\021\003\240\001\000\000\ -\021\003\011\002\240\001\240\001\000\000\000\000\000\000\000\000\ -\000\000\240\001\021\003\000\000\000\000\000\000\011\002\240\001\ -\011\002\011\002\000\000\000\000\021\003\000\000\000\000\021\003\ -\000\000\021\003\021\003\240\001\000\000\011\002\119\000\240\001\ -\240\001\000\000\000\000\000\000\000\000\021\003\021\003\000\000\ -\000\000\000\000\000\000\240\001\000\000\000\000\240\001\000\000\ -\011\002\000\000\125\000\011\002\000\000\125\000\011\002\011\002\ -\011\002\021\003\000\000\000\000\021\003\000\000\011\002\125\000\ -\000\000\021\003\000\000\000\000\011\002\000\000\000\000\021\003\ -\000\000\000\000\000\000\000\000\125\000\021\003\125\000\125\000\ -\011\002\000\000\000\000\000\000\011\002\011\002\000\000\000\000\ -\000\000\021\003\000\000\125\000\223\001\021\003\021\003\000\000\ -\011\002\000\000\000\000\011\002\000\000\000\000\000\000\126\000\ -\000\000\021\003\126\000\000\000\021\003\000\000\125\000\000\000\ -\000\000\125\000\000\000\000\000\126\000\125\000\125\000\000\000\ -\000\000\000\000\000\000\000\000\125\000\000\000\000\000\000\000\ -\000\000\126\000\125\000\126\000\126\000\000\000\000\000\000\000\ -\061\000\000\000\000\000\000\000\000\000\000\000\125\000\000\000\ -\126\000\064\000\125\000\125\000\000\000\000\000\000\000\000\000\ -\023\003\000\000\000\000\000\000\000\000\000\000\125\000\000\000\ -\023\003\125\000\023\003\126\000\000\000\023\003\126\000\000\000\ -\000\000\000\000\126\000\126\000\000\000\000\000\000\000\023\003\ -\000\000\126\000\023\003\000\000\023\003\023\003\000\000\126\000\ -\000\000\000\000\000\000\000\000\023\003\000\000\023\003\023\003\ -\000\000\023\003\065\000\126\000\000\000\000\000\000\000\126\000\ -\126\000\000\000\000\000\023\003\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\126\000\023\003\000\000\126\000\023\003\ -\000\000\000\000\000\000\023\003\023\003\000\000\023\003\000\000\ -\000\000\023\003\023\003\118\000\000\000\023\003\023\003\000\000\ -\023\003\000\000\000\000\000\000\023\003\000\000\021\003\000\000\ -\118\000\000\000\023\003\000\000\023\003\000\000\000\000\000\000\ -\023\003\023\003\000\000\000\000\000\000\118\000\023\003\118\000\ -\118\000\000\000\023\003\023\003\023\003\000\000\000\000\023\003\ -\000\000\000\000\000\000\000\000\118\000\000\000\023\003\000\000\ -\000\000\023\003\000\000\000\000\021\003\000\000\000\000\021\003\ -\000\000\000\000\000\000\000\000\000\000\000\000\119\000\118\000\ -\000\000\021\003\118\000\000\000\000\000\000\000\118\000\118\000\ -\000\000\000\000\000\000\119\000\000\000\118\000\021\003\000\000\ -\021\003\021\003\000\000\118\000\000\000\000\000\000\000\000\000\ -\119\000\000\000\119\000\119\000\000\000\021\003\000\000\118\000\ -\000\000\000\000\000\000\118\000\118\000\000\000\000\000\119\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\118\000\ -\021\003\000\000\118\000\021\003\000\000\000\000\000\000\000\000\ -\021\003\000\000\119\000\000\000\223\001\119\000\021\003\000\000\ -\000\000\119\000\119\000\000\000\021\003\000\000\000\000\000\000\ -\119\000\223\001\000\000\000\000\000\000\000\000\119\000\000\000\ -\021\003\000\000\000\000\000\000\021\003\021\003\223\001\000\000\ -\223\001\223\001\119\000\000\000\000\000\000\000\119\000\119\000\ -\021\003\000\000\000\000\021\003\000\000\223\001\000\000\000\000\ -\061\000\000\000\119\000\000\000\000\000\119\000\000\000\000\000\ -\000\000\064\000\000\000\000\000\000\000\061\000\000\000\000\000\ -\223\001\000\000\000\000\223\001\000\000\000\000\064\000\223\001\ -\223\001\000\000\061\000\000\000\061\000\061\000\223\001\000\000\ -\000\000\000\000\000\000\064\000\223\001\064\000\064\000\000\000\ -\000\000\061\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\223\001\000\000\064\000\000\000\223\001\223\001\000\000\000\000\ -\000\000\000\000\065\000\000\000\061\000\000\000\000\000\061\000\ -\223\001\000\000\000\000\223\001\061\000\064\000\000\000\065\000\ -\064\000\000\000\061\000\000\000\000\000\064\000\000\000\000\000\ -\061\000\000\000\000\000\064\000\065\000\000\000\065\000\065\000\ -\000\000\064\000\000\000\000\000\061\000\000\000\000\000\000\000\ -\061\000\061\000\000\000\065\000\000\000\064\000\021\003\000\000\ -\000\000\064\000\064\000\000\000\061\000\000\000\000\000\061\000\ -\000\000\000\000\000\000\021\003\000\000\064\000\065\000\000\000\ -\064\000\065\000\000\000\000\000\000\000\000\000\065\000\000\000\ -\021\003\000\000\021\003\021\003\065\000\000\000\000\000\000\000\ -\000\000\000\000\065\000\000\000\000\000\000\000\000\000\021\003\ -\000\000\000\000\000\000\000\000\000\000\000\000\065\000\000\000\ -\000\000\000\000\065\000\065\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\021\003\000\000\000\000\021\003\065\000\000\000\ -\000\000\065\000\021\003\000\000\000\000\000\000\000\000\000\000\ -\021\003\000\000\000\000\000\000\000\000\000\000\021\003\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\021\003\016\003\000\000\000\000\021\003\021\003\ -\016\003\016\003\016\003\016\003\000\000\000\000\016\003\016\003\ -\016\003\016\003\021\003\000\000\000\000\021\003\016\003\000\000\ -\000\000\000\000\000\000\000\000\000\000\016\003\000\000\016\003\ -\016\003\016\003\016\003\016\003\016\003\016\003\016\003\000\000\ -\000\000\000\000\016\003\000\000\016\003\000\000\000\000\000\000\ -\000\000\000\000\000\000\016\003\016\003\016\003\016\003\016\003\ -\016\003\016\003\016\003\016\003\000\000\000\000\016\003\016\003\ -\000\000\000\000\016\003\016\003\016\003\016\003\000\000\016\003\ -\016\003\016\003\016\003\016\003\000\000\016\003\000\000\016\003\ -\016\003\016\003\000\000\016\003\016\003\000\000\000\000\016\003\ -\016\003\000\000\016\003\000\000\016\003\016\003\000\000\016\003\ -\016\003\000\000\000\000\016\003\016\003\000\000\016\003\000\000\ -\016\003\016\003\000\000\016\003\000\000\016\003\016\003\016\003\ -\016\003\016\003\016\003\016\003\023\003\016\003\000\000\000\000\ -\000\000\023\003\023\003\023\003\023\003\000\000\000\000\023\003\ -\023\003\000\000\000\000\000\000\000\000\000\000\000\000\023\003\ -\000\000\000\000\000\000\000\000\000\000\000\000\023\003\000\000\ -\023\003\000\000\023\003\023\003\023\003\023\003\023\003\023\003\ -\000\000\000\000\000\000\023\003\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\023\003\023\003\023\003\023\003\ -\023\003\023\003\023\003\023\003\023\003\000\000\000\000\023\003\ -\023\003\000\000\000\000\023\003\023\003\023\003\000\000\000\000\ -\023\003\023\003\023\003\023\003\023\003\000\000\023\003\000\000\ -\023\003\023\003\023\003\000\000\000\000\023\003\000\000\000\000\ -\023\003\023\003\000\000\023\003\000\000\023\003\023\003\000\000\ -\000\000\023\003\000\000\000\000\000\000\023\003\000\000\023\003\ -\000\000\023\003\023\003\000\000\023\003\000\000\023\003\023\003\ -\000\000\023\003\023\003\023\003\023\003\000\000\023\003\026\001\ -\027\001\028\001\000\000\000\000\009\000\010\000\029\001\000\000\ -\030\001\000\000\012\000\013\000\000\000\000\000\031\001\032\001\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\033\001\000\000\000\000\017\000\018\000\019\000\ -\020\000\021\000\000\000\034\001\000\000\000\000\022\000\000\000\ -\000\000\035\001\036\001\037\001\038\001\039\001\040\001\000\000\ -\000\000\024\000\000\000\025\000\026\000\027\000\028\000\029\000\ -\000\000\000\000\030\000\000\000\041\001\000\000\032\000\033\000\ -\034\000\000\000\000\000\000\000\036\000\000\000\042\001\043\001\ -\000\000\044\001\000\000\040\000\000\000\041\000\000\000\000\000\ -\000\000\045\001\046\001\047\001\048\001\049\001\050\001\000\000\ -\000\000\000\000\000\000\000\000\000\000\051\001\000\000\000\000\ -\000\000\052\001\000\000\053\001\047\000\000\000\000\000\000\000\ -\000\000\048\000\049\000\000\000\051\000\052\000\026\001\027\001\ -\028\001\054\000\000\000\009\000\010\000\029\001\000\000\030\001\ -\000\000\012\000\013\000\000\000\000\000\079\003\032\001\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\033\001\000\000\000\000\017\000\018\000\019\000\020\000\ -\021\000\000\000\034\001\000\000\000\000\022\000\000\000\000\000\ -\035\001\036\001\037\001\038\001\039\001\040\001\000\000\000\000\ -\024\000\000\000\025\000\026\000\027\000\028\000\029\000\000\000\ -\000\000\030\000\000\000\041\001\000\000\032\000\033\000\034\000\ -\000\000\000\000\000\000\036\000\000\000\042\001\043\001\000\000\ -\080\003\000\000\040\000\000\000\041\000\000\000\000\000\000\000\ -\045\001\046\001\047\001\048\001\049\001\050\001\000\000\000\000\ -\000\000\000\000\000\000\089\002\081\003\089\002\089\002\089\002\ -\052\001\089\002\053\001\047\000\089\002\089\002\000\000\000\000\ -\048\000\049\000\000\000\051\000\052\000\023\003\000\000\000\000\ -\054\000\000\000\023\003\023\003\023\003\089\002\000\000\000\000\ -\023\003\023\003\023\003\000\000\000\000\089\002\089\002\000\000\ -\000\000\000\000\000\000\000\000\000\000\089\002\000\000\023\003\ -\000\000\023\003\023\003\023\003\023\003\023\003\023\003\023\003\ -\000\000\089\002\089\002\000\000\023\003\000\000\023\003\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\023\003\ -\000\000\023\003\023\003\023\003\023\003\023\003\000\000\000\000\ -\023\003\023\003\000\000\000\000\023\003\023\003\023\003\000\000\ -\000\000\023\003\023\003\000\000\023\003\023\003\000\000\023\003\ -\000\000\023\003\000\000\023\003\000\000\023\003\000\000\000\000\ -\000\000\023\003\023\003\143\002\023\003\000\000\000\000\000\000\ -\217\002\217\002\217\002\000\000\000\000\023\003\217\002\217\002\ -\000\000\000\000\023\003\000\000\000\000\000\000\000\000\023\003\ -\023\003\023\003\023\003\023\003\023\003\000\000\000\000\023\003\ -\000\000\217\002\217\002\217\002\217\002\217\002\000\000\000\000\ -\000\000\000\000\217\002\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\217\002\000\000\217\002\ -\217\002\217\002\217\002\217\002\000\000\000\000\217\002\000\000\ -\000\000\000\000\217\002\217\002\217\002\000\000\000\000\000\000\ -\217\002\000\000\217\002\217\002\000\000\000\000\000\000\217\002\ -\000\000\217\002\000\000\000\000\000\000\000\000\000\000\217\002\ -\217\002\144\002\217\002\000\000\000\000\000\000\218\002\218\002\ -\218\002\143\002\000\000\000\000\218\002\218\002\000\000\000\000\ -\217\002\000\000\000\000\000\000\000\000\217\002\217\002\000\000\ -\217\002\217\002\000\000\000\000\000\000\217\002\000\000\218\002\ -\218\002\218\002\218\002\218\002\000\000\000\000\000\000\000\000\ -\218\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\218\002\000\000\218\002\218\002\218\002\ -\218\002\218\002\000\000\000\000\218\002\000\000\000\000\000\000\ -\218\002\218\002\218\002\000\000\000\000\000\000\218\002\000\000\ -\218\002\218\002\000\000\000\000\000\000\218\002\000\000\218\002\ -\000\000\000\000\000\000\000\000\000\000\218\002\218\002\141\002\ -\218\002\000\000\000\000\000\000\219\002\219\002\219\002\144\002\ -\000\000\000\000\219\002\219\002\000\000\000\000\218\002\000\000\ -\000\000\000\000\000\000\218\002\218\002\000\000\218\002\218\002\ -\000\000\000\000\000\000\218\002\000\000\219\002\219\002\219\002\ -\219\002\219\002\000\000\000\000\000\000\000\000\219\002\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\219\002\000\000\219\002\219\002\219\002\219\002\219\002\ -\000\000\000\000\219\002\000\000\000\000\000\000\219\002\219\002\ -\219\002\000\000\000\000\000\000\219\002\000\000\219\002\219\002\ -\000\000\000\000\000\000\219\002\000\000\219\002\000\000\000\000\ -\000\000\000\000\000\000\219\002\219\002\142\002\219\002\000\000\ -\000\000\000\000\220\002\220\002\220\002\141\002\000\000\000\000\ -\220\002\220\002\000\000\000\000\219\002\000\000\000\000\000\000\ -\000\000\219\002\219\002\000\000\219\002\219\002\000\000\000\000\ -\000\000\219\002\000\000\220\002\220\002\220\002\220\002\220\002\ -\000\000\000\000\000\000\000\000\220\002\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\220\002\ -\000\000\220\002\220\002\220\002\220\002\220\002\000\000\000\000\ -\220\002\000\000\000\000\000\000\220\002\220\002\220\002\000\000\ -\000\000\000\000\220\002\000\000\220\002\220\002\000\000\000\000\ -\000\000\220\002\000\000\220\002\000\000\000\000\000\000\000\000\ -\000\000\220\002\220\002\000\000\220\002\000\000\000\000\000\000\ -\000\000\000\000\000\000\142\002\224\000\225\000\226\000\000\000\ -\000\000\000\000\220\002\000\000\227\000\000\000\228\000\220\002\ -\220\002\000\000\220\002\220\002\229\000\230\000\231\000\220\002\ -\000\000\232\000\233\000\234\000\000\000\235\000\236\000\237\000\ -\000\000\238\000\239\000\240\000\241\000\000\000\000\000\000\000\ -\242\000\243\000\244\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\245\000\246\000\000\000\000\000\247\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\248\000\249\000\000\000\000\000\000\000\062\002\250\000\251\000\ -\000\000\062\002\000\000\252\000\253\000\254\000\255\000\000\001\ -\001\001\002\001\000\000\003\001\000\000\000\000\062\002\000\000\ -\062\002\004\001\000\000\045\002\000\000\000\000\005\001\062\002\ -\062\002\000\000\000\000\000\000\006\001\000\000\000\000\007\001\ -\008\001\062\002\009\001\010\001\011\001\012\001\013\001\000\000\ -\014\001\015\001\016\001\017\001\018\001\062\002\062\002\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\062\002\000\000\000\000\000\000\062\002\000\000\062\002\ -\062\002\062\002\000\000\062\002\000\000\000\000\062\002\000\000\ -\000\000\000\000\026\001\027\001\028\001\000\000\000\000\000\000\ -\010\000\207\001\000\000\030\001\000\000\000\000\013\000\045\002\ -\062\002\031\001\032\001\000\000\062\002\000\000\062\002\000\000\ -\000\000\062\002\000\000\000\000\000\000\033\001\161\000\000\000\ -\017\000\018\000\062\002\000\000\062\002\000\000\034\001\000\000\ -\000\000\000\000\000\000\000\000\035\001\036\001\037\001\038\001\ -\039\001\040\001\000\000\000\000\024\000\000\000\162\000\163\000\ -\000\000\164\000\165\000\000\000\000\000\030\000\000\000\041\001\ -\000\000\000\000\166\000\167\000\000\000\000\000\000\000\000\000\ -\000\000\208\001\209\001\000\000\210\001\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\045\001\046\001\211\001\212\001\ -\049\001\213\001\000\000\000\000\000\000\000\000\000\000\000\000\ -\051\001\000\000\000\000\170\000\052\001\000\000\053\001\047\000\ -\000\000\000\000\000\000\000\000\048\000\000\000\240\002\051\000\ -\171\000\026\001\027\001\028\001\000\000\000\000\000\000\010\000\ -\207\001\000\000\030\001\000\000\000\000\013\000\000\000\000\000\ -\031\001\032\001\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\033\001\161\000\000\000\017\000\ -\018\000\000\000\000\000\000\000\000\000\034\001\000\000\000\000\ -\000\000\000\000\000\000\035\001\036\001\037\001\038\001\039\001\ -\040\001\000\000\000\000\024\000\000\000\162\000\163\000\000\000\ -\164\000\165\000\000\000\000\000\030\000\000\000\041\001\000\000\ -\000\000\166\000\167\000\000\000\000\000\000\000\000\000\000\000\ -\208\001\209\001\000\000\210\001\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\045\001\046\001\211\001\212\001\049\001\ -\213\001\000\000\000\000\000\000\000\000\000\000\000\000\051\001\ -\000\000\000\000\170\000\052\001\000\000\053\001\047\000\000\000\ -\000\000\000\000\000\000\048\000\000\000\194\003\051\000\171\000\ -\026\001\027\001\028\001\000\000\000\000\000\000\010\000\207\001\ -\000\000\030\001\000\000\000\000\013\000\000\000\000\000\031\001\ -\032\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\033\001\161\000\000\000\017\000\018\000\ -\000\000\000\000\000\000\000\000\034\001\000\000\000\000\000\000\ -\000\000\000\000\035\001\036\001\037\001\038\001\039\001\040\001\ -\000\000\000\000\024\000\000\000\162\000\163\000\000\000\164\000\ -\165\000\000\000\000\000\030\000\000\000\041\001\000\000\000\000\ -\166\000\167\000\000\000\000\000\000\000\000\000\000\000\208\001\ -\209\001\000\000\210\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\045\001\046\001\211\001\212\001\049\001\213\001\ -\000\000\000\000\000\000\000\000\000\000\000\000\051\001\000\000\ -\000\000\170\000\052\001\000\000\053\001\047\000\000\000\000\000\ -\000\000\000\000\048\000\000\000\154\004\051\000\171\000\026\001\ -\027\001\028\001\000\000\000\000\000\000\010\000\207\001\000\000\ -\030\001\000\000\000\000\013\000\000\000\000\000\031\001\032\001\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\033\001\161\000\000\000\017\000\018\000\000\000\ -\000\000\000\000\000\000\034\001\000\000\000\000\000\000\000\000\ -\000\000\035\001\036\001\037\001\038\001\039\001\040\001\000\000\ -\000\000\024\000\000\000\162\000\163\000\000\000\164\000\165\000\ -\000\000\000\000\030\000\000\000\041\001\000\000\000\000\166\000\ -\167\000\000\000\000\000\000\000\000\000\000\000\208\001\209\001\ -\000\000\210\001\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\045\001\046\001\211\001\212\001\049\001\213\001\000\000\ -\000\000\157\003\000\000\000\000\000\000\051\001\000\000\010\000\ -\170\000\052\001\000\000\053\001\047\000\013\000\000\000\000\000\ -\079\003\048\000\000\000\000\000\051\000\171\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\161\000\000\000\017\000\ -\018\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\024\000\000\000\162\000\163\000\000\000\ -\164\000\165\000\000\000\000\000\030\000\000\000\200\002\000\000\ -\000\000\166\000\167\000\000\000\010\000\000\000\000\000\000\000\ -\168\000\000\000\013\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\169\000\000\000\000\000\ -\000\000\000\000\161\000\000\000\017\000\018\000\000\000\158\003\ -\000\000\000\000\170\000\000\000\000\000\000\000\047\000\000\000\ -\000\000\000\000\000\000\048\000\000\000\000\000\051\000\171\000\ -\024\000\000\000\162\000\163\000\000\000\164\000\165\000\000\000\ -\000\000\030\000\000\000\202\002\000\000\000\000\166\000\167\000\ -\000\000\010\000\000\000\000\000\000\000\168\000\000\000\013\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\169\000\000\000\000\000\000\000\000\000\161\000\ -\000\000\017\000\018\000\000\000\000\000\000\000\000\000\170\000\ -\000\000\000\000\000\000\047\000\000\000\000\000\000\000\000\000\ -\048\000\000\000\000\000\051\000\171\000\024\000\000\000\162\000\ -\163\000\000\000\164\000\165\000\000\000\000\000\030\000\000\000\ -\204\002\000\000\000\000\166\000\167\000\000\000\010\000\000\000\ -\000\000\000\000\168\000\000\000\013\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\169\000\ -\000\000\000\000\000\000\000\000\161\000\000\000\017\000\018\000\ -\000\000\000\000\000\000\000\000\170\000\000\000\000\000\000\000\ -\047\000\000\000\000\000\000\000\000\000\048\000\000\000\000\000\ -\051\000\171\000\024\000\000\000\162\000\163\000\000\000\164\000\ -\165\000\000\000\000\000\030\000\000\000\161\004\000\000\000\000\ -\166\000\167\000\000\000\010\000\000\000\000\000\000\000\168\000\ -\000\000\013\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\169\000\000\000\000\000\000\000\ -\000\000\161\000\000\000\017\000\018\000\000\000\000\000\000\000\ -\000\000\170\000\000\000\000\000\000\000\047\000\000\000\000\000\ -\000\000\000\000\048\000\000\000\000\000\051\000\171\000\024\000\ -\000\000\162\000\163\000\000\000\164\000\165\000\000\000\000\000\ -\030\000\000\000\163\004\000\000\000\000\166\000\167\000\000\000\ -\010\000\000\000\000\000\000\000\168\000\000\000\013\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\169\000\000\000\000\000\000\000\000\000\161\000\000\000\ -\017\000\018\000\000\000\000\000\000\000\000\000\170\000\000\000\ -\000\000\000\000\047\000\000\000\000\000\000\000\000\000\048\000\ -\000\000\000\000\051\000\171\000\024\000\000\000\162\000\163\000\ -\000\000\164\000\165\000\000\000\000\000\030\000\000\000\165\004\ -\000\000\000\000\166\000\167\000\000\000\010\000\000\000\000\000\ -\000\000\168\000\000\000\013\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\169\000\000\000\ -\000\000\000\000\000\000\161\000\000\000\017\000\018\000\000\000\ -\000\000\000\000\000\000\170\000\000\000\000\000\000\000\047\000\ -\000\000\000\000\000\000\000\000\048\000\000\000\000\000\051\000\ -\171\000\024\000\000\000\162\000\163\000\000\000\164\000\165\000\ -\000\000\000\000\030\000\000\000\000\000\000\000\000\000\166\000\ -\167\000\009\000\010\000\011\000\000\000\000\000\168\000\012\000\ -\013\000\014\000\032\002\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\169\000\000\000\000\000\000\000\000\000\ -\015\000\016\000\017\000\018\000\019\000\020\000\021\000\000\000\ -\170\000\000\000\000\000\022\000\047\000\023\000\000\000\000\000\ -\000\000\048\000\000\000\000\000\051\000\171\000\024\000\000\000\ -\025\000\026\000\027\000\028\000\029\000\000\000\000\000\030\000\ -\031\000\000\000\000\000\032\000\033\000\034\000\000\000\000\000\ -\035\000\036\000\000\000\037\000\038\000\000\000\039\000\000\000\ -\040\000\000\000\041\000\000\000\042\000\000\000\000\000\000\000\ -\043\000\044\000\000\000\045\000\000\000\033\002\000\000\000\000\ -\009\000\010\000\011\000\000\000\046\000\000\000\012\000\013\000\ -\014\000\047\000\000\000\000\000\000\000\000\000\048\000\049\000\ -\050\000\051\000\052\000\053\000\000\000\000\000\054\000\015\000\ -\016\000\017\000\018\000\019\000\020\000\021\000\000\000\000\000\ -\000\000\000\000\022\000\000\000\023\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\024\000\000\000\025\000\ -\026\000\027\000\028\000\029\000\000\000\000\000\030\000\031\000\ -\000\000\000\000\032\000\033\000\034\000\000\000\000\000\035\000\ -\036\000\000\000\037\000\038\000\000\000\039\000\000\000\040\000\ -\000\000\041\000\000\000\042\000\000\000\000\000\000\000\043\000\ -\044\000\000\000\045\000\000\000\000\000\000\000\009\000\010\000\ -\011\000\000\000\000\000\046\000\012\000\013\000\000\000\000\000\ -\047\000\000\000\000\000\000\000\000\000\048\000\049\000\050\000\ -\051\000\052\000\053\000\000\000\000\000\054\000\000\000\017\000\ -\018\000\019\000\020\000\021\000\000\000\000\000\000\000\000\000\ -\022\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\024\000\000\000\025\000\026\000\027\000\ -\028\000\029\000\000\000\000\000\030\000\000\000\000\000\000\000\ -\032\000\033\000\034\000\000\000\000\000\000\000\036\000\000\000\ -\037\000\038\000\000\000\000\000\000\000\040\000\000\000\041\000\ -\000\000\000\000\000\000\000\000\000\000\043\000\044\000\000\000\ -\045\000\000\000\000\000\000\000\000\000\219\000\009\000\010\000\ -\011\000\000\000\000\000\222\000\012\000\013\000\047\000\000\000\ -\000\000\000\000\000\000\048\000\049\000\000\000\051\000\052\000\ -\000\000\000\000\000\000\054\000\000\000\000\000\000\000\017\000\ -\018\000\019\000\020\000\021\000\000\000\000\000\000\000\000\000\ -\022\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\024\000\000\000\025\000\026\000\027\000\ -\028\000\029\000\000\000\000\000\030\000\000\000\000\000\000\000\ -\032\000\033\000\034\000\000\000\000\000\000\000\036\000\000\000\ -\037\000\038\000\000\000\000\000\000\000\040\000\000\000\041\000\ -\000\000\000\000\000\000\000\000\000\000\043\000\044\000\000\000\ -\045\000\000\000\000\000\009\000\010\000\011\000\000\000\000\000\ -\000\000\012\000\013\000\000\000\000\000\000\000\047\000\000\000\ -\000\000\000\000\000\000\048\000\049\000\000\000\051\000\052\000\ -\238\001\000\000\000\000\054\000\017\000\018\000\019\000\020\000\ -\021\000\000\000\000\000\000\000\000\000\022\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\024\000\000\000\025\000\026\000\027\000\028\000\029\000\000\000\ -\000\000\030\000\000\000\000\000\000\000\032\000\033\000\034\000\ -\000\000\000\000\000\000\036\000\000\000\037\000\038\000\000\000\ -\000\000\000\000\040\000\000\000\041\000\000\000\000\000\000\000\ -\000\000\000\000\043\000\044\000\000\000\045\000\000\000\000\000\ -\009\000\010\000\011\000\000\000\000\000\000\000\012\000\013\000\ -\000\000\000\000\000\000\047\000\000\000\000\000\000\000\000\000\ -\048\000\049\000\000\000\051\000\052\000\000\000\000\000\000\000\ -\054\000\017\000\018\000\019\000\020\000\021\000\000\000\000\000\ -\000\000\000\000\022\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\024\000\000\000\025\000\ -\026\000\027\000\028\000\029\000\000\000\000\000\030\000\000\000\ -\000\000\000\000\032\000\033\000\034\000\000\000\000\000\000\000\ -\036\000\000\000\037\000\038\000\000\000\000\000\000\000\040\000\ -\000\000\041\000\000\000\000\000\000\000\000\000\100\002\043\000\ -\044\000\000\000\045\000\000\000\000\000\009\000\010\000\011\000\ -\000\000\000\000\000\000\012\000\013\000\000\000\000\000\000\000\ -\047\000\000\000\000\000\000\000\000\000\048\000\049\000\000\000\ -\051\000\052\000\000\000\000\000\000\000\054\000\017\000\018\000\ -\019\000\020\000\021\000\000\000\000\000\000\000\000\000\022\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\024\000\000\000\025\000\026\000\027\000\028\000\ -\029\000\000\000\000\000\030\000\000\000\000\000\000\000\032\000\ -\033\000\034\000\000\000\000\000\000\000\036\000\000\000\037\000\ -\038\000\000\000\000\000\000\000\040\000\000\000\041\000\000\000\ -\000\000\000\000\000\000\000\000\043\000\044\000\000\000\045\000\ -\000\000\000\000\000\000\000\000\075\003\009\000\010\000\011\000\ -\000\000\000\000\077\003\012\000\013\000\047\000\000\000\000\000\ -\000\000\000\000\048\000\049\000\000\000\051\000\052\000\000\000\ -\000\000\000\000\054\000\000\000\000\000\000\000\017\000\018\000\ -\019\000\020\000\021\000\000\000\000\000\000\000\000\000\022\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\024\000\000\000\025\000\026\000\027\000\028\000\ -\029\000\000\000\000\000\030\000\000\000\000\000\000\000\032\000\ -\033\000\034\000\000\000\000\000\000\000\036\000\000\000\037\000\ -\038\000\000\000\000\000\000\000\040\000\000\000\041\000\000\000\ -\000\000\000\000\000\000\000\000\043\000\044\000\000\000\045\000\ -\000\000\000\000\000\000\009\000\010\000\011\000\000\000\000\000\ -\000\000\012\000\013\000\000\000\000\000\047\000\000\000\000\000\ -\000\000\000\000\048\000\049\000\134\004\051\000\052\000\000\000\ -\000\000\000\000\054\000\000\000\017\000\018\000\019\000\020\000\ -\021\000\000\000\000\000\000\000\000\000\022\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\024\000\000\000\025\000\026\000\027\000\028\000\029\000\000\000\ -\000\000\030\000\000\000\000\000\000\000\032\000\033\000\034\000\ -\000\000\000\000\000\000\036\000\000\000\037\000\038\000\000\000\ -\000\000\000\000\040\000\000\000\041\000\000\000\000\000\000\000\ -\000\000\000\000\043\000\044\000\000\000\045\000\000\000\000\000\ -\025\003\025\003\025\003\000\000\000\000\000\000\025\003\025\003\ -\000\000\000\000\000\000\047\000\000\000\000\000\000\000\000\000\ -\048\000\049\000\000\000\051\000\052\000\025\003\000\000\000\000\ -\054\000\025\003\025\003\025\003\025\003\025\003\000\000\000\000\ -\000\000\000\000\025\003\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\025\003\000\000\025\003\ -\025\003\025\003\025\003\025\003\000\000\000\000\025\003\000\000\ -\000\000\000\000\025\003\025\003\025\003\000\000\000\000\000\000\ -\025\003\000\000\025\003\025\003\000\000\000\000\000\000\025\003\ -\000\000\025\003\000\000\000\000\000\000\000\000\000\000\025\003\ -\025\003\000\000\025\003\000\000\000\000\009\000\010\000\011\000\ -\000\000\000\000\000\000\012\000\013\000\000\000\000\000\000\000\ -\025\003\000\000\000\000\000\000\000\000\025\003\025\003\000\000\ -\025\003\025\003\000\000\000\000\000\000\025\003\017\000\018\000\ -\019\000\020\000\021\000\000\000\000\000\000\000\000\000\022\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\024\000\000\000\025\000\026\000\027\000\028\000\ -\029\000\000\000\000\000\030\000\000\000\000\000\000\000\032\000\ -\033\000\034\000\000\000\000\000\000\000\036\000\000\000\037\000\ -\038\000\000\000\000\000\000\000\040\000\000\000\041\000\000\000\ -\000\000\000\000\000\000\000\000\043\000\044\000\000\000\045\000\ -\000\000\000\000\025\003\025\003\025\003\000\000\000\000\000\000\ -\025\003\025\003\000\000\000\000\000\000\047\000\000\000\000\000\ -\000\000\000\000\048\000\049\000\000\000\051\000\052\000\000\000\ -\000\000\000\000\054\000\025\003\025\003\025\003\025\003\025\003\ -\000\000\000\000\000\000\000\000\025\003\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\025\003\ -\000\000\025\003\025\003\025\003\025\003\025\003\000\000\000\000\ -\025\003\000\000\000\000\000\000\025\003\025\003\025\003\000\000\ -\000\000\000\000\025\003\000\000\025\003\025\003\000\000\000\000\ -\000\000\025\003\000\000\025\003\000\000\000\000\000\000\000\000\ -\000\000\025\003\025\003\000\000\025\003\000\000\000\000\023\003\ -\023\003\023\003\000\000\000\000\000\000\023\003\023\003\000\000\ -\000\000\000\000\025\003\000\000\000\000\000\000\000\000\025\003\ -\025\003\000\000\025\003\025\003\000\000\000\000\000\000\025\003\ -\023\003\023\003\023\003\023\003\023\003\000\000\000\000\000\000\ -\000\000\023\003\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\023\003\000\000\023\003\023\003\ -\023\003\023\003\023\003\000\000\000\000\023\003\000\000\000\000\ -\000\000\023\003\023\003\023\003\000\000\000\000\000\000\023\003\ -\000\000\023\003\023\003\000\000\000\000\010\000\023\003\000\000\ -\023\003\000\000\000\000\013\000\000\000\217\003\023\003\023\003\ -\018\002\023\003\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\218\003\000\000\000\000\017\000\018\000\023\003\ -\000\000\000\000\000\000\000\000\023\003\023\003\000\000\023\003\ -\023\003\000\000\000\000\000\000\023\003\000\000\000\000\000\000\ -\000\000\024\000\252\001\000\000\163\000\000\000\164\000\165\000\ -\000\000\000\000\030\000\000\000\000\000\000\000\000\000\166\000\ -\219\003\000\000\010\000\000\000\000\000\000\000\168\000\000\000\ -\013\000\000\000\017\002\000\000\000\000\018\002\000\000\000\000\ -\254\001\000\000\000\000\169\000\000\000\000\000\000\000\218\003\ -\255\001\000\000\017\000\018\000\000\000\010\000\000\000\000\000\ -\170\000\000\000\000\000\013\000\047\000\250\002\000\000\000\002\ -\000\000\048\000\000\000\000\000\051\000\171\000\024\000\252\001\ -\000\000\163\000\000\000\164\000\165\000\017\000\018\000\030\000\ -\000\000\000\000\000\000\000\000\166\000\219\003\000\000\000\000\ -\000\000\000\000\000\000\168\000\000\000\000\000\000\000\000\000\ -\000\000\024\000\252\001\000\000\163\000\254\001\164\000\165\000\ -\169\000\000\000\030\000\000\000\000\000\255\001\000\000\166\000\ -\251\002\000\000\000\000\000\000\000\000\170\000\168\000\000\000\ -\252\002\047\000\000\000\000\000\000\002\000\000\048\000\000\000\ -\254\001\051\000\171\000\169\000\000\000\000\000\010\000\000\000\ -\255\001\000\000\000\000\000\000\013\000\000\000\107\004\000\000\ -\170\000\000\000\000\000\000\000\047\000\000\000\000\000\000\002\ -\000\000\048\000\000\000\108\004\051\000\171\000\017\000\018\000\ -\000\000\010\000\000\000\000\000\000\000\000\000\000\000\013\000\ -\000\000\031\006\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\024\000\252\001\000\000\163\000\218\003\164\000\ -\165\000\017\000\018\000\030\000\000\000\000\000\000\000\000\000\ -\166\000\167\000\000\000\000\000\000\000\000\000\000\000\168\000\ -\000\000\000\000\000\000\000\000\000\000\024\000\252\001\000\000\ -\163\000\254\001\164\000\165\000\169\000\000\000\030\000\000\000\ -\000\000\255\001\000\000\166\000\219\003\000\000\010\000\000\000\ -\000\000\170\000\168\000\000\000\013\000\047\000\000\000\000\000\ -\000\002\000\000\048\000\000\000\254\001\051\000\171\000\169\000\ -\000\000\000\000\000\000\000\000\255\001\000\000\017\000\018\000\ -\000\000\010\000\000\000\000\000\170\000\000\000\000\000\013\000\ -\047\000\000\000\000\000\000\002\000\000\048\000\000\000\000\000\ -\051\000\171\000\024\000\252\001\000\000\163\000\000\000\164\000\ -\165\000\017\000\018\000\030\000\000\000\000\000\000\000\000\000\ -\166\000\167\000\000\000\000\000\000\000\000\000\000\000\168\000\ -\000\000\015\006\000\000\000\000\000\000\024\000\252\001\000\000\ -\163\000\254\001\164\000\165\000\169\000\000\000\030\000\000\000\ -\000\000\255\001\000\000\166\000\253\001\000\000\010\000\000\000\ -\000\000\170\000\168\000\000\000\013\000\047\000\000\000\000\000\ -\000\002\000\000\048\000\000\000\254\001\051\000\171\000\169\000\ -\000\000\000\000\000\000\000\000\255\001\000\000\017\000\018\000\ -\000\000\025\003\000\000\000\000\170\000\000\000\000\000\025\003\ -\047\000\000\000\000\000\000\002\000\000\048\000\000\000\000\000\ -\051\000\171\000\024\000\252\001\000\000\163\000\000\000\164\000\ -\165\000\025\003\025\003\030\000\000\000\000\000\000\000\000\000\ -\166\000\167\000\000\000\000\000\000\000\000\000\000\000\168\000\ -\000\000\000\000\000\000\000\000\000\000\025\003\025\003\000\000\ -\025\003\254\001\025\003\025\003\169\000\000\000\025\003\000\000\ -\000\000\255\001\000\000\025\003\025\003\000\000\023\003\000\000\ -\000\000\170\000\025\003\000\000\023\003\047\000\000\000\000\000\ -\000\002\000\000\048\000\000\000\025\003\051\000\171\000\025\003\ -\000\000\000\000\000\000\000\000\025\003\000\000\023\003\023\003\ -\000\000\000\000\000\000\000\000\025\003\000\000\000\000\000\000\ -\025\003\000\000\000\000\025\003\000\000\025\003\000\000\000\000\ -\025\003\025\003\023\003\023\003\000\000\023\003\000\000\023\003\ -\023\003\000\000\000\000\023\003\000\000\000\000\000\000\000\000\ -\023\003\023\003\000\000\000\000\010\000\000\000\000\000\023\003\ -\000\000\000\000\013\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\023\003\000\000\000\000\023\003\000\000\000\000\000\000\ -\000\000\023\003\161\000\000\000\017\000\018\000\000\000\000\000\ -\000\000\023\003\000\000\000\000\000\000\023\003\000\000\000\000\ -\023\003\000\000\023\003\000\000\000\000\023\003\023\003\000\000\ -\024\000\000\000\162\000\163\000\000\000\164\000\165\000\000\000\ -\000\000\030\000\000\000\000\000\000\000\000\000\166\000\167\000\ -\000\000\000\000\000\000\010\000\000\000\168\000\000\000\205\001\ -\000\000\013\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\169\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\161\000\219\000\017\000\018\000\000\000\000\000\170\000\ -\000\000\000\000\000\000\047\000\000\000\000\000\000\000\000\000\ -\048\000\000\000\000\000\051\000\171\000\000\000\000\000\024\000\ -\000\000\162\000\163\000\000\000\164\000\165\000\000\000\000\000\ -\030\000\000\000\000\000\000\000\000\000\166\000\167\000\000\000\ -\010\000\000\000\000\000\000\000\168\000\000\000\013\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\010\000\011\000\000\000\ -\000\000\169\000\012\000\013\000\000\000\000\000\161\000\000\000\ -\017\000\018\000\000\000\000\000\000\000\000\000\170\000\000\000\ -\000\000\000\000\047\000\000\000\000\000\017\000\018\000\048\000\ -\000\000\000\000\051\000\171\000\024\000\000\000\162\000\163\000\ -\000\000\164\000\165\000\000\000\000\000\030\000\000\000\000\000\ -\000\000\024\000\166\000\167\000\026\000\027\000\028\000\029\000\ -\000\000\168\000\030\000\000\000\025\003\000\000\025\003\166\000\ -\034\000\000\000\025\003\000\000\000\000\000\000\169\000\000\000\ -\000\000\000\000\000\000\040\000\000\000\000\000\156\003\000\000\ -\000\000\000\000\025\003\170\000\025\003\025\003\045\000\047\000\ -\000\000\000\000\000\000\000\000\048\000\000\000\000\000\051\000\ -\171\000\000\000\000\000\000\000\047\000\000\000\000\000\000\000\ -\025\003\048\000\025\003\025\003\051\000\025\003\025\003\000\000\ -\000\000\025\003\000\000\000\000\000\000\000\000\025\003\025\003\ -\000\000\010\000\000\000\000\000\000\000\025\003\000\000\013\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\025\003\000\000\000\000\000\000\000\000\161\000\ -\000\000\017\000\018\000\000\000\000\000\000\000\000\000\025\003\ -\000\000\000\000\000\000\025\003\000\000\000\000\000\000\000\000\ -\025\003\000\000\000\000\025\003\025\003\024\000\000\000\162\000\ -\163\000\000\000\164\000\165\000\000\000\000\000\030\000\000\000\ -\000\000\000\000\000\000\166\000\167\000\000\000\025\003\000\000\ -\000\000\000\000\168\000\000\000\025\003\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\169\000\ -\000\000\000\000\000\000\000\000\025\003\000\000\025\003\025\003\ -\000\000\025\003\000\000\000\000\170\000\000\000\000\000\025\003\ -\047\000\000\000\000\000\000\000\000\000\048\000\000\000\000\000\ -\051\000\171\000\025\003\000\000\025\003\025\003\000\000\025\003\ -\025\003\025\003\025\003\025\003\000\000\000\000\000\000\000\000\ -\025\003\025\003\000\000\000\000\000\000\000\000\000\000\025\003\ -\000\000\000\000\000\000\000\000\000\000\025\003\000\000\025\003\ -\025\003\000\000\025\003\025\003\025\003\000\000\025\003\000\000\ -\000\000\000\000\000\000\025\003\025\003\000\000\213\002\000\000\ -\000\000\025\003\025\003\000\000\213\002\025\003\000\000\000\000\ -\000\000\000\000\025\003\000\000\000\000\025\003\025\003\025\003\ -\000\000\000\000\000\000\000\000\213\002\000\000\213\002\213\002\ -\025\003\010\000\000\000\000\000\025\003\000\000\000\000\013\000\ -\025\003\000\000\000\000\000\000\000\000\025\003\000\000\000\000\ -\025\003\025\003\213\002\000\000\213\002\213\002\000\000\213\002\ -\213\002\017\000\018\000\213\002\000\000\000\000\000\000\000\000\ -\213\002\213\002\000\000\000\000\000\000\000\000\000\000\213\002\ -\000\000\000\000\000\000\000\000\000\000\024\000\000\000\162\000\ -\163\000\000\000\164\000\165\000\213\002\000\000\030\000\000\000\ -\000\000\000\000\000\000\166\000\167\000\000\000\194\002\000\000\ -\000\000\213\002\168\000\000\000\194\002\213\002\000\000\000\000\ -\000\000\000\000\213\002\000\000\000\000\213\002\213\002\169\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\194\002\194\002\ -\000\000\023\003\000\000\000\000\170\000\000\000\000\000\023\003\ -\047\000\000\000\000\000\000\000\000\000\048\000\000\000\000\000\ -\051\000\171\000\194\002\000\000\194\002\194\002\000\000\194\002\ -\194\002\023\003\023\003\194\002\000\000\000\000\000\000\000\000\ -\194\002\194\002\000\000\000\000\000\000\000\000\000\000\194\002\ -\000\000\000\000\000\000\000\000\000\000\023\003\000\000\023\003\ -\023\003\000\000\023\003\023\003\194\002\000\000\023\003\000\000\ -\000\000\000\000\000\000\023\003\023\003\000\000\010\000\000\000\ -\000\000\194\002\023\003\000\000\013\000\194\002\000\000\000\000\ -\000\000\000\000\194\002\000\000\000\000\194\002\194\002\023\003\ -\000\000\000\000\000\000\000\000\000\000\000\000\017\000\018\000\ -\000\000\025\003\000\000\000\000\023\003\000\000\000\000\025\003\ -\023\003\000\000\000\000\000\000\000\000\023\003\000\000\000\000\ -\023\003\023\003\024\000\000\000\000\000\163\000\000\000\164\000\ -\165\000\025\003\025\003\030\000\000\000\000\000\000\000\000\000\ -\166\000\167\000\000\000\000\000\000\000\000\000\000\000\168\000\ -\000\000\000\000\000\000\000\000\000\000\025\003\000\000\000\000\ -\025\003\000\000\025\003\025\003\169\000\000\000\025\003\000\000\ -\000\000\000\000\000\000\025\003\025\003\000\000\000\000\000\000\ -\000\000\170\000\025\003\000\000\000\000\047\000\010\000\011\000\ -\000\000\000\000\048\000\012\000\013\000\051\000\171\000\025\003\ -\000\000\000\000\000\000\000\000\000\000\000\000\115\001\000\000\ -\000\000\000\000\000\000\000\000\025\003\000\000\017\000\018\000\ -\025\003\000\000\000\000\000\000\000\000\025\003\000\000\000\000\ -\025\003\025\003\000\000\000\000\000\000\000\000\000\000\116\001\ -\000\000\000\000\024\000\117\001\000\000\026\000\027\000\028\000\ -\029\000\000\000\000\000\030\000\000\000\000\000\000\000\000\000\ -\166\000\034\000\010\000\011\000\000\000\000\000\000\000\012\000\ -\013\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\ -\000\000\118\001\000\000\000\000\000\000\000\000\000\000\045\000\ -\000\000\119\001\017\000\018\000\000\000\000\000\000\000\000\000\ -\000\000\120\001\121\001\000\000\000\000\047\000\000\000\000\000\ -\122\001\000\000\048\000\000\000\000\000\051\000\024\000\117\001\ -\000\000\026\000\027\000\028\000\029\000\000\000\000\000\030\000\ -\000\000\000\000\000\000\000\000\166\000\034\000\010\000\011\000\ -\000\000\000\000\000\000\012\000\013\000\025\003\025\003\000\000\ -\040\000\000\000\025\003\025\003\000\000\118\001\000\000\000\000\ -\000\000\000\000\000\000\045\000\000\000\119\001\017\000\018\000\ -\000\000\000\000\000\000\000\000\000\000\025\003\025\003\000\000\ -\000\000\047\000\000\000\000\000\122\001\000\000\048\000\000\000\ -\000\000\051\000\024\000\000\000\000\000\026\000\027\000\028\000\ -\029\000\025\003\000\000\030\000\025\003\025\003\025\003\025\003\ -\207\000\034\000\025\003\000\000\000\000\000\000\059\005\025\003\ -\025\003\000\000\000\000\000\000\040\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\025\003\000\000\060\005\000\000\045\000\ -\000\000\000\000\000\000\000\000\243\001\000\000\025\003\000\000\ -\000\000\000\000\000\000\000\000\000\000\047\000\000\000\000\000\ -\000\000\000\000\048\000\000\000\025\003\051\000\000\000\000\000\ -\000\000\025\003\000\000\000\000\025\003\061\005\000\000\137\000\ -\138\000\030\000\000\000\139\000\000\000\000\000\140\000\062\005\ -\000\000\000\000\000\000\032\005\078\001\079\001\000\000\000\000\ -\000\000\000\000\000\000\000\000\080\001\000\000\000\000\142\000\ -\000\000\033\005\081\001\082\001\034\005\083\001\063\005\143\000\ -\144\000\000\000\000\000\000\000\000\000\000\000\084\001\145\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\085\001\ -\246\001\000\000\000\000\064\005\147\000\086\001\087\001\088\001\ -\089\001\090\001\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\091\001\000\000\000\000\000\000\000\000\186\000\000\000\000\000\ -\000\000\000\000\092\001\093\001\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\094\001\095\001\096\001\ -\097\001\098\001\000\000\026\001\027\001\028\001\000\000\000\000\ -\000\000\035\005\207\001\000\000\030\001\000\000\000\000\100\001\ -\000\000\000\000\023\003\032\001\023\003\023\003\023\003\000\000\ -\023\003\000\000\000\000\023\003\023\003\000\000\033\001\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\034\001\ -\000\000\000\000\000\000\000\000\023\003\035\001\036\001\037\001\ -\038\001\039\001\040\001\000\000\023\003\023\003\000\000\000\000\ -\000\000\000\000\000\000\000\000\023\003\000\000\000\000\000\000\ -\041\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\023\003\023\003\234\002\209\001\000\000\235\002\000\000\000\000\ -\000\000\000\000\041\004\078\001\079\001\045\001\046\001\236\002\ -\212\001\049\001\213\001\080\001\000\000\000\000\000\000\000\000\ -\000\000\081\001\082\001\000\000\083\001\052\001\000\000\053\001\ -\000\000\000\000\000\000\000\000\000\000\084\001\000\000\000\000\ -\000\000\000\000\043\004\078\001\079\001\000\000\085\001\000\000\ -\000\000\000\000\000\000\080\001\086\001\087\001\088\001\089\001\ -\090\001\081\001\082\001\000\000\083\001\000\000\000\000\000\000\ -\043\002\000\000\043\002\043\002\043\002\084\001\043\002\091\001\ -\000\000\043\002\043\002\000\000\186\000\000\000\085\001\000\000\ -\000\000\092\001\093\001\000\000\086\001\087\001\088\001\089\001\ -\090\001\000\000\043\002\000\000\094\001\095\001\096\001\097\001\ -\098\001\000\000\043\002\043\002\000\000\042\004\000\000\091\001\ -\000\000\000\000\043\002\000\000\186\000\000\000\100\001\000\000\ -\000\000\092\001\093\001\000\000\000\000\000\000\043\002\043\002\ -\045\004\078\001\079\001\000\000\094\001\095\001\096\001\097\001\ -\098\001\080\001\000\000\000\000\000\000\000\000\044\004\081\001\ -\082\001\000\000\083\001\000\000\000\000\000\000\100\001\000\000\ -\000\000\000\000\000\000\084\001\000\000\000\000\000\000\000\000\ -\041\004\078\001\079\001\000\000\085\001\000\000\000\000\000\000\ -\000\000\080\001\086\001\087\001\088\001\089\001\090\001\081\001\ -\082\001\000\000\083\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\084\001\000\000\091\001\000\000\000\000\ -\000\000\000\000\186\000\000\000\085\001\000\000\000\000\092\001\ -\093\001\000\000\086\001\087\001\088\001\089\001\090\001\000\000\ -\000\000\000\000\094\001\095\001\096\001\097\001\098\001\000\000\ -\000\000\000\000\000\000\000\000\000\000\091\001\046\004\000\000\ -\000\000\000\000\186\000\000\000\100\001\000\000\000\000\092\001\ -\093\001\000\000\000\000\000\000\000\000\000\000\043\004\078\001\ -\079\001\000\000\094\001\095\001\096\001\097\001\098\001\080\001\ -\000\000\000\000\000\000\099\004\000\000\081\001\082\001\000\000\ -\083\001\000\000\000\000\000\000\100\001\000\000\000\000\000\000\ -\000\000\084\001\000\000\000\000\000\000\000\000\045\004\078\001\ -\079\001\000\000\085\001\000\000\000\000\000\000\000\000\080\001\ -\086\001\087\001\088\001\089\001\090\001\081\001\082\001\000\000\ -\083\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\084\001\000\000\091\001\000\000\000\000\000\000\000\000\ -\186\000\000\000\085\001\000\000\000\000\092\001\093\001\000\000\ -\086\001\087\001\088\001\089\001\090\001\000\000\000\000\000\000\ -\094\001\095\001\096\001\097\001\098\001\000\000\000\000\000\000\ -\000\000\000\000\100\004\091\001\000\000\000\000\000\000\000\000\ -\186\000\000\000\100\001\000\000\000\000\092\001\093\001\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\094\001\095\001\096\001\097\001\098\001\081\005\078\001\079\001\ -\000\000\000\000\000\000\000\000\101\004\000\000\080\001\000\000\ -\000\000\000\000\100\001\000\000\081\001\082\001\000\000\083\001\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\084\001\000\000\000\000\000\000\000\000\083\005\078\001\079\001\ -\000\000\085\001\000\000\000\000\000\000\000\000\080\001\086\001\ -\087\001\088\001\089\001\090\001\081\001\082\001\000\000\083\001\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\084\001\000\000\091\001\000\000\000\000\000\000\000\000\186\000\ -\000\000\085\001\000\000\000\000\092\001\093\001\000\000\086\001\ -\087\001\088\001\089\001\090\001\000\000\000\000\000\000\094\001\ -\095\001\096\001\097\001\098\001\000\000\000\000\000\000\000\000\ -\082\005\000\000\091\001\000\000\000\000\000\000\000\000\186\000\ -\000\000\100\001\000\000\000\000\092\001\093\001\000\000\000\000\ -\000\000\000\000\000\000\085\005\078\001\079\001\000\000\094\001\ -\095\001\096\001\097\001\098\001\080\001\000\000\000\000\000\000\ -\000\000\084\005\081\001\082\001\000\000\083\001\000\000\000\000\ -\000\000\100\001\000\000\000\000\000\000\000\000\084\001\000\000\ -\000\000\000\000\000\000\081\005\078\001\079\001\000\000\085\001\ -\000\000\000\000\000\000\000\000\080\001\086\001\087\001\088\001\ -\089\001\090\001\081\001\082\001\000\000\083\001\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\084\001\000\000\ -\091\001\000\000\000\000\000\000\000\000\186\000\000\000\085\001\ -\000\000\000\000\092\001\093\001\000\000\086\001\087\001\088\001\ -\089\001\090\001\000\000\000\000\000\000\094\001\095\001\096\001\ -\097\001\098\001\000\000\000\000\000\000\000\000\000\000\000\000\ -\091\001\086\005\000\000\000\000\000\000\186\000\000\000\100\001\ -\000\000\000\000\092\001\093\001\000\000\000\000\000\000\000\000\ -\000\000\083\005\078\001\079\001\000\000\094\001\095\001\096\001\ -\097\001\098\001\080\001\000\000\000\000\000\000\106\005\000\000\ -\081\001\082\001\000\000\083\001\000\000\000\000\000\000\100\001\ -\000\000\000\000\000\000\000\000\084\001\000\000\000\000\000\000\ -\000\000\085\005\078\001\079\001\000\000\085\001\000\000\000\000\ -\000\000\000\000\080\001\086\001\087\001\088\001\089\001\090\001\ -\081\001\082\001\000\000\083\001\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\084\001\000\000\091\001\000\000\ -\000\000\000\000\000\000\186\000\000\000\085\001\000\000\000\000\ -\092\001\093\001\000\000\086\001\087\001\088\001\089\001\090\001\ -\000\000\000\000\000\000\094\001\095\001\096\001\097\001\098\001\ -\000\000\000\000\000\000\000\000\000\000\107\005\091\001\078\001\ -\079\001\000\000\000\000\186\000\000\000\100\001\000\000\080\001\ -\092\001\093\001\000\000\000\000\000\000\081\001\082\001\000\000\ -\083\001\000\000\000\000\094\001\095\001\096\001\097\001\098\001\ -\000\000\084\001\000\000\000\000\000\000\000\000\000\000\108\005\ -\000\000\000\000\085\001\000\000\000\000\100\001\000\000\000\000\ -\086\001\087\001\088\001\089\001\090\001\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\091\001\078\001\079\001\000\000\000\000\ -\186\000\000\000\000\000\000\000\080\001\092\001\093\001\000\000\ -\000\000\000\000\081\001\082\001\000\000\083\001\000\000\000\000\ -\094\001\095\001\096\001\097\001\098\001\000\000\084\001\000\000\ -\000\000\000\000\000\000\000\000\000\000\099\001\000\000\085\001\ -\000\000\000\000\100\001\000\000\000\000\086\001\087\001\088\001\ -\089\001\090\001\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\091\001\078\001\079\001\000\000\000\000\186\000\000\000\000\000\ -\000\000\080\001\092\001\093\001\000\000\000\000\000\000\081\001\ -\082\001\000\000\083\001\000\000\000\000\094\001\095\001\096\001\ -\097\001\098\001\000\000\084\001\000\000\000\000\031\004\000\000\ -\000\000\078\001\079\001\000\000\085\001\000\000\000\000\100\001\ -\000\000\080\001\086\001\087\001\088\001\089\001\090\001\081\001\ -\082\001\000\000\083\001\000\000\000\000\000\000\000\000\000\000\ -\000\000\138\004\000\000\084\001\000\000\091\001\000\000\000\000\ -\000\000\000\000\186\000\000\000\085\001\000\000\000\000\092\001\ -\093\001\000\000\086\001\087\001\088\001\089\001\090\001\000\000\ -\000\000\000\000\094\001\095\001\096\001\097\001\098\001\000\000\ -\000\000\000\000\000\000\093\004\000\000\091\001\078\001\079\001\ -\000\000\000\000\186\000\000\000\100\001\000\000\080\001\092\001\ -\093\001\000\000\000\000\000\000\081\001\082\001\000\000\083\001\ -\000\000\000\000\094\001\095\001\096\001\097\001\098\001\000\000\ -\084\001\000\000\000\000\000\000\000\000\000\000\240\000\240\000\ -\000\000\085\001\000\000\000\000\100\001\000\000\240\000\086\001\ -\087\001\088\001\089\001\090\001\240\000\240\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\240\000\000\000\091\001\000\000\000\000\000\000\000\000\186\000\ -\000\000\240\000\000\000\000\000\092\001\093\001\000\000\240\000\ -\240\000\240\000\240\000\240\000\000\000\000\000\000\000\094\001\ -\095\001\096\001\097\001\098\001\000\000\000\000\000\000\000\000\ -\000\000\000\000\240\000\078\001\079\001\000\000\000\000\240\000\ -\000\000\100\001\000\000\080\001\240\000\240\000\000\000\000\000\ -\000\000\081\001\000\000\000\000\000\000\000\000\000\000\240\000\ -\240\000\240\000\240\000\240\000\000\000\084\001\000\000\000\000\ -\240\000\000\000\000\000\078\001\079\001\000\000\085\001\000\000\ -\000\000\240\000\000\000\000\000\086\001\087\001\088\001\089\001\ -\090\001\081\001\000\000\000\000\000\000\000\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\084\001\000\000\091\001\ -\000\000\000\000\000\000\000\000\186\000\000\000\085\001\000\000\ -\000\000\092\001\093\001\000\000\086\001\087\001\088\001\089\001\ -\090\001\094\000\000\000\000\000\094\001\095\001\096\001\097\001\ -\098\001\000\000\000\000\000\000\000\000\000\000\000\000\091\001\ -\095\000\016\000\000\000\000\000\186\000\000\000\100\001\000\000\ -\000\000\092\001\093\001\000\000\000\000\096\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\095\001\096\001\097\001\ -\098\001\000\000\000\000\136\000\000\000\137\000\138\000\030\000\ -\031\000\139\000\000\000\000\000\140\000\141\000\100\001\000\000\ -\035\000\000\000\000\000\000\000\000\000\000\000\097\000\000\000\ -\000\000\000\000\000\000\000\000\042\000\142\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\143\000\144\000\000\000\ -\000\000\000\000\000\000\000\000\098\000\145\000\000\000\000\000\ -\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ -\099\000\146\000\147\000\053\000" - -let yycheck = "\009\000\ -\210\000\145\000\012\000\002\000\014\000\015\000\016\000\136\000\ -\199\000\019\000\020\000\021\000\022\000\023\000\002\000\025\000\ -\163\000\132\001\142\000\205\000\136\000\163\002\032\000\202\000\ -\002\000\123\001\036\000\002\000\202\000\039\000\040\000\041\000\ -\011\000\001\000\034\003\002\000\010\000\024\001\010\002\049\000\ -\050\000\027\000\136\000\053\000\054\000\139\000\002\000\026\000\ -\002\000\138\000\002\000\234\003\163\002\002\000\038\003\253\002\ -\098\000\157\000\221\000\029\000\223\000\105\002\003\000\004\000\ -\186\003\225\002\045\000\063\004\110\000\000\000\170\000\115\004\ -\194\003\063\003\003\000\004\000\031\000\006\000\046\000\241\004\ -\035\000\056\005\201\004\063\005\094\000\095\000\096\000\097\000\ -\131\000\099\000\133\000\003\000\008\001\001\000\134\001\003\000\ -\004\000\141\002\000\000\098\000\054\001\003\003\021\001\000\001\ -\083\000\034\000\085\000\086\000\058\000\110\002\098\000\110\000\ -\067\005\214\004\203\000\000\000\000\001\003\005\000\001\042\002\ -\098\000\127\002\110\000\098\000\017\001\240\001\010\001\164\001\ -\000\001\166\001\005\000\098\000\110\000\074\001\192\004\110\000\ -\000\001\056\001\046\000\149\000\007\001\110\004\098\000\110\000\ -\098\000\000\001\098\000\121\000\000\001\098\000\058\000\161\000\ -\162\000\139\000\110\000\000\001\110\000\008\001\110\000\000\000\ -\087\004\110\000\244\004\173\000\014\001\000\001\052\005\108\001\ -\226\004\000\001\144\000\077\005\060\001\066\001\000\000\001\005\ -\092\001\006\001\188\000\030\001\103\002\008\001\157\005\000\001\ -\066\001\004\001\127\000\197\000\129\000\008\001\131\000\073\001\ -\133\000\000\001\066\001\092\001\015\001\099\003\133\001\018\001\ -\129\000\000\000\066\001\030\001\055\001\000\001\037\001\162\005\ -\092\001\073\001\189\000\095\001\094\001\214\002\065\001\008\001\ -\000\001\129\000\224\002\127\000\014\001\129\000\094\001\131\000\ -\115\001\133\000\000\001\206\000\055\001\079\001\094\001\186\000\ -\187\000\115\001\203\004\121\005\091\001\030\001\065\001\091\001\ -\095\001\000\001\036\001\027\001\130\005\000\001\091\001\066\001\ -\107\002\108\002\095\001\115\001\054\005\027\001\073\001\106\001\ -\101\005\237\005\109\001\094\001\008\001\000\001\055\001\092\001\ -\095\001\017\001\121\003\196\000\022\001\023\001\064\001\000\000\ -\065\001\000\001\197\001\204\000\027\001\094\001\123\005\106\001\ -\027\001\008\001\109\001\109\005\143\002\151\004\022\001\094\001\ -\154\004\005\003\044\001\000\001\000\001\055\001\113\001\067\001\ -\091\001\204\001\037\001\206\001\202\003\095\001\064\001\097\001\ -\058\001\193\001\029\001\091\001\176\001\063\001\094\001\095\001\ -\231\001\106\001\000\001\109\001\109\001\091\001\027\001\157\001\ -\074\001\095\001\000\001\000\001\192\001\022\001\164\001\050\001\ -\166\001\252\001\046\003\217\003\091\001\010\001\001\002\173\001\ -\174\001\087\003\088\003\094\001\027\001\040\006\094\001\094\001\ -\092\001\236\001\130\002\094\001\102\001\027\001\188\001\105\001\ -\154\005\107\001\000\001\109\001\095\001\111\001\094\001\038\002\ -\205\005\163\005\033\005\034\005\151\001\115\003\153\001\019\001\ -\155\001\021\001\215\005\000\001\071\001\000\000\048\002\008\001\ -\164\005\000\001\072\001\160\002\026\001\024\001\091\001\091\001\ -\057\001\015\006\095\001\141\001\107\006\143\001\120\001\066\001\ -\255\005\066\001\117\001\118\001\069\001\026\001\121\001\000\001\ -\123\001\000\001\048\004\074\005\056\001\159\001\069\002\094\001\ -\094\001\010\001\015\001\000\001\035\001\091\001\000\001\092\001\ -\094\001\095\001\095\001\008\006\072\001\000\001\000\001\177\001\ -\178\001\014\001\099\001\000\001\017\001\000\001\103\001\081\006\ -\099\005\083\006\004\001\014\001\059\001\000\001\008\001\125\004\ -\000\001\064\001\065\001\173\001\174\001\015\001\092\001\000\001\ -\018\001\203\001\190\005\074\001\000\001\003\001\188\004\103\004\ -\210\001\000\001\088\006\092\001\214\001\004\001\105\001\092\001\ -\027\001\008\001\151\001\010\001\153\001\058\006\155\001\014\001\ -\000\001\227\001\228\001\018\001\099\001\076\004\232\001\027\001\ -\234\001\008\001\010\001\000\001\027\001\000\001\109\001\066\001\ -\062\001\094\001\000\001\092\001\091\001\000\001\095\001\007\000\ -\066\001\251\001\000\001\151\001\000\001\153\001\032\002\155\001\ -\171\005\094\001\004\001\039\006\094\001\007\002\008\001\009\002\ -\010\002\000\001\000\001\094\001\094\001\015\001\091\001\000\001\ -\018\001\092\001\095\001\055\004\052\003\241\003\193\005\000\001\ -\091\001\000\001\073\001\004\001\095\001\035\001\094\001\008\001\ -\017\001\010\001\018\001\092\001\004\001\014\001\040\002\091\001\ -\000\001\032\002\094\001\095\001\091\001\092\001\221\005\094\001\ -\095\001\027\002\027\001\190\002\032\002\059\001\014\001\000\001\ -\172\002\173\002\064\001\065\001\092\001\092\001\032\002\095\001\ -\066\001\032\002\113\001\000\001\074\001\000\001\091\001\103\003\ -\091\001\032\002\160\002\231\001\095\001\109\003\070\005\171\002\ -\094\001\002\001\253\002\094\001\032\002\003\001\032\002\091\001\ -\032\002\036\002\056\002\032\002\038\003\099\001\028\005\073\002\ -\073\001\000\001\066\001\022\001\091\001\072\002\000\001\109\001\ -\094\001\065\001\066\001\010\001\014\001\094\001\094\001\113\001\ -\074\002\075\002\091\001\092\001\151\002\094\001\095\001\094\001\ -\003\001\018\001\042\002\038\003\047\001\000\001\229\004\129\002\ -\038\003\004\001\132\002\053\003\134\002\008\001\094\001\010\001\ -\113\001\004\001\000\001\014\001\022\001\027\001\008\001\018\001\ -\230\002\066\001\232\002\092\001\164\000\165\000\017\002\018\002\ -\027\001\100\002\018\001\076\002\064\001\107\004\000\001\092\001\ -\014\001\177\000\178\000\094\001\250\002\032\002\015\001\159\005\ -\008\001\069\002\036\001\022\001\018\001\205\003\097\001\098\001\ -\018\001\076\003\170\005\078\003\066\001\183\002\090\001\103\002\ -\019\001\201\000\003\001\073\001\094\001\092\001\111\002\112\002\ -\115\001\019\001\092\001\092\001\036\001\094\001\073\001\201\002\ -\192\005\203\002\110\001\205\002\066\001\237\003\073\001\209\002\ -\090\001\008\001\068\006\065\001\066\001\048\001\180\002\018\001\ -\091\001\092\001\151\002\094\001\095\001\083\001\048\001\049\001\ -\049\003\060\001\092\001\018\001\092\001\115\001\066\003\233\002\ -\018\001\068\001\060\001\070\001\200\004\062\003\113\001\090\001\ -\094\001\027\002\068\001\018\001\070\001\094\001\092\001\146\003\ -\094\001\022\001\242\005\151\002\092\001\255\002\134\003\133\005\ -\232\005\172\003\004\003\005\003\000\000\012\001\172\003\008\001\ -\214\004\001\006\118\003\022\001\067\001\015\003\130\003\017\003\ -\251\003\036\001\253\003\254\003\111\001\113\003\000\001\027\001\ -\031\001\022\001\028\003\029\003\060\004\111\001\133\005\073\002\ -\118\003\092\001\088\001\067\004\065\001\039\003\215\002\216\002\ -\000\001\019\001\248\004\050\001\046\003\092\001\006\003\170\002\ -\026\001\220\003\047\001\027\001\094\001\139\003\220\003\057\003\ -\000\000\015\001\112\001\022\001\030\001\238\002\066\001\186\002\ -\071\001\094\001\067\001\031\005\102\003\060\003\048\001\049\001\ -\022\001\196\002\000\001\252\002\095\001\084\001\080\003\090\001\ -\060\003\065\001\060\001\047\005\187\005\055\001\189\005\065\001\ -\014\001\019\001\068\001\017\001\070\001\000\001\101\001\065\001\ -\022\001\047\001\100\003\014\001\022\004\027\001\065\001\014\001\ -\064\001\065\001\006\003\014\001\066\001\000\001\017\001\102\003\ -\027\001\004\001\237\002\022\001\027\001\008\001\094\001\014\001\ -\027\001\047\001\102\003\014\001\015\001\109\001\128\003\018\001\ -\092\005\131\003\004\001\133\003\102\003\111\001\008\001\102\003\ -\106\001\067\001\003\001\109\001\047\001\107\003\144\003\102\003\ -\018\001\177\004\148\003\097\001\098\001\070\003\064\001\101\005\ -\066\001\155\003\102\003\027\001\102\003\159\003\102\003\000\001\ -\126\003\102\003\083\003\015\001\079\001\091\001\018\001\117\005\ -\079\001\095\001\065\001\097\001\098\001\123\005\088\001\066\001\ -\066\006\067\006\047\001\181\003\196\001\064\001\184\003\215\004\ -\091\001\035\001\188\003\003\001\095\001\115\001\097\001\098\001\ -\066\001\225\004\066\001\110\004\064\001\065\001\112\001\073\001\ -\110\004\000\001\069\003\094\001\022\001\221\001\222\001\223\001\ -\115\001\059\001\125\004\213\003\022\001\229\001\066\001\065\001\ -\030\001\139\004\092\001\022\001\019\001\004\001\082\004\064\001\ -\065\001\008\001\109\001\026\001\097\001\098\001\014\001\014\001\ -\015\001\090\001\124\006\018\001\066\001\067\001\240\003\241\003\ -\096\001\055\001\110\001\073\001\000\001\005\002\115\001\065\001\ -\250\003\048\001\252\003\065\001\102\001\110\001\176\004\205\005\ -\206\005\067\001\022\001\109\001\000\001\060\001\065\001\096\001\ -\004\001\215\005\012\004\014\001\008\001\068\001\010\001\070\001\ -\035\001\033\002\014\001\015\001\197\003\198\003\018\001\035\001\ -\027\001\065\001\066\001\066\001\027\001\115\001\116\004\027\001\ -\203\004\035\001\211\003\212\003\106\001\203\004\216\004\109\001\ -\059\001\218\003\132\005\009\004\060\002\065\001\065\001\059\001\ -\000\001\051\004\227\003\053\004\064\001\065\001\000\001\094\001\ -\111\001\059\001\008\006\061\004\000\001\091\001\074\001\065\001\ -\004\001\095\001\030\001\066\001\008\001\071\004\066\001\000\000\ -\066\001\019\001\026\001\015\001\079\001\073\001\018\001\073\001\ -\026\001\220\004\084\004\102\001\055\001\000\001\209\003\099\001\ -\064\001\065\001\109\001\055\001\094\001\064\001\217\003\091\001\ -\092\001\109\001\094\001\095\001\102\001\065\001\048\001\049\001\ -\064\001\014\001\229\003\109\001\058\006\111\001\005\000\077\004\ -\007\000\028\005\060\001\075\001\008\001\113\001\027\001\065\001\ -\035\001\115\001\068\001\244\004\070\001\248\003\066\001\000\001\ -\031\001\064\001\027\001\023\001\059\005\109\001\112\004\035\003\ -\244\004\116\005\030\001\105\004\142\004\112\001\106\001\145\004\ -\059\001\109\001\073\005\050\001\127\005\064\001\065\001\051\003\ -\112\001\026\001\094\001\055\003\065\001\000\001\244\004\074\001\ -\162\004\053\001\164\004\055\001\166\004\111\001\168\004\169\004\ -\064\001\066\001\055\001\173\004\099\005\065\001\109\001\191\002\ -\178\004\008\001\180\004\064\001\182\004\004\001\184\004\026\001\ -\099\001\008\001\086\003\064\001\065\001\004\001\206\002\207\002\ -\023\001\008\001\109\001\018\001\061\005\022\001\200\004\030\001\ -\015\001\097\001\123\004\018\001\027\001\064\001\127\004\066\001\ -\108\004\061\005\125\005\132\004\027\001\109\001\106\001\125\005\ -\075\001\109\001\014\001\066\001\222\004\017\001\053\001\014\001\ -\055\001\227\004\242\002\112\001\149\004\150\004\145\005\061\005\ -\030\001\235\004\065\001\145\005\053\001\158\004\055\001\056\001\ -\065\001\136\000\169\005\066\001\139\000\247\004\141\000\142\000\ -\065\001\027\001\252\004\066\001\050\001\112\001\000\005\106\006\ -\002\005\066\001\004\005\126\004\181\004\007\005\109\001\130\004\ -\191\005\000\001\064\001\065\001\000\001\164\000\165\000\008\001\ -\167\000\065\001\083\001\106\001\022\005\064\001\109\001\064\001\ -\026\005\073\001\177\000\178\000\019\001\031\005\004\001\019\001\ -\066\001\235\005\008\001\026\001\109\001\008\005\026\001\210\005\ -\035\001\015\001\027\001\108\001\210\005\047\005\048\005\101\001\ -\050\005\028\001\201\000\202\000\106\001\027\001\205\000\109\001\ -\179\004\048\001\049\001\088\001\048\001\232\005\014\001\065\005\ -\059\001\066\001\232\005\190\004\109\001\060\001\065\001\000\001\ -\060\001\100\001\003\001\027\001\212\005\068\001\000\000\070\001\ -\068\001\066\001\070\001\112\001\013\001\014\001\027\001\066\001\ -\017\001\091\005\092\005\027\001\066\001\094\001\022\001\074\001\ -\098\005\026\001\027\001\028\001\029\001\080\001\000\001\003\005\ -\083\001\045\001\046\001\102\001\029\005\064\001\112\005\040\001\ -\041\001\065\001\109\001\066\001\111\001\035\001\003\001\047\001\ -\111\001\019\001\043\005\111\001\045\005\066\001\128\005\037\001\ -\026\001\145\003\066\001\060\001\083\001\088\001\063\001\022\001\ -\065\001\066\001\067\001\068\001\064\001\059\001\144\005\083\001\ -\073\001\074\001\064\001\065\001\064\001\151\005\048\001\080\001\ -\052\005\000\001\064\001\040\001\074\001\112\001\109\001\161\005\ -\100\001\132\005\060\001\092\001\166\005\094\001\000\001\096\001\ -\097\001\067\001\068\001\236\003\070\001\035\001\041\005\000\001\ -\066\001\155\005\180\005\108\001\158\005\099\001\111\001\199\003\ -\023\001\109\001\115\001\018\001\064\001\066\001\037\001\109\001\ -\026\001\109\001\019\001\004\004\063\005\059\001\200\005\075\001\ -\000\001\026\001\064\001\065\001\094\001\207\005\064\001\000\001\ -\224\003\225\003\226\003\213\005\074\001\111\001\230\003\136\005\ -\218\005\219\005\000\001\019\001\236\003\121\005\224\005\048\001\ -\049\001\227\005\026\001\027\001\010\001\053\001\130\005\055\001\ -\000\000\026\001\236\005\060\001\112\001\099\001\240\005\134\001\ -\064\001\065\001\244\005\068\001\004\004\070\001\064\001\109\001\ -\048\001\049\001\004\001\109\001\230\005\231\005\008\001\233\005\ -\234\005\022\001\000\001\003\001\060\001\015\001\157\001\009\006\ -\018\001\064\001\112\001\067\001\068\001\164\001\070\001\166\001\ -\090\001\027\001\064\001\040\001\143\005\012\006\173\001\174\001\ -\064\001\176\001\149\005\064\001\065\001\109\001\111\001\022\001\ -\012\006\000\001\071\001\109\001\110\001\188\001\035\001\037\001\ -\040\001\192\001\044\006\045\006\167\005\196\001\197\001\084\001\ -\225\005\051\006\052\006\053\006\054\006\090\001\109\001\111\001\ -\066\001\059\006\033\001\026\001\075\001\063\006\059\001\109\001\ -\110\001\022\001\016\001\069\006\065\001\109\001\221\001\222\001\ -\223\001\110\001\000\000\077\006\078\006\027\001\229\001\202\005\ -\055\001\004\001\037\001\040\001\059\001\008\001\064\001\095\001\ -\063\001\064\001\065\001\066\001\015\001\095\006\096\006\018\001\ -\076\000\112\001\100\006\064\001\102\006\252\001\253\001\078\001\ -\025\006\102\001\001\002\085\006\110\006\064\001\005\002\113\006\ -\109\001\008\002\035\006\015\006\064\001\022\001\053\001\097\001\ -\055\001\123\006\017\002\018\002\064\001\127\006\027\001\105\006\ -\108\000\064\001\065\001\109\001\134\006\135\006\109\001\040\001\ -\033\001\032\002\033\002\064\001\064\001\119\006\120\006\066\001\ -\109\001\125\000\000\000\042\002\095\001\000\001\064\001\065\001\ -\132\000\048\002\075\006\000\001\064\001\071\001\055\001\095\001\ -\066\001\109\001\059\001\013\001\031\006\060\002\063\001\064\001\ -\065\001\109\001\084\001\000\001\093\006\066\001\109\001\042\006\ -\090\001\083\001\028\001\029\001\073\001\078\001\064\001\091\001\ -\109\001\109\001\037\001\016\002\088\006\022\001\019\001\041\001\ -\037\001\075\001\023\002\109\001\110\001\026\001\027\001\066\006\ -\067\006\094\001\108\001\066\001\000\000\072\006\073\006\128\006\ -\103\002\091\001\060\001\000\001\109\001\063\001\047\001\082\006\ -\079\001\040\001\068\001\048\001\049\001\022\001\115\001\000\001\ -\074\001\055\001\000\001\094\006\066\001\059\001\080\001\060\001\ -\000\001\063\001\064\001\130\002\004\001\026\001\067\001\068\001\ -\008\001\070\001\010\001\066\001\111\006\083\001\014\001\015\001\ -\078\001\026\001\018\001\094\001\026\001\000\000\121\006\094\001\ -\090\001\124\006\108\001\027\001\000\001\111\001\093\001\130\006\ -\131\006\160\002\109\001\110\001\163\002\053\001\054\001\055\001\ -\056\001\031\001\169\002\170\002\110\001\172\002\173\002\109\001\ -\064\001\065\001\111\001\000\001\093\001\055\001\026\001\000\001\ -\033\001\059\001\066\001\186\002\050\001\063\001\064\001\077\001\ -\191\002\010\001\066\001\004\001\109\001\196\002\019\001\008\001\ -\080\001\073\001\094\001\083\001\078\001\026\001\055\001\206\002\ -\207\002\018\001\059\001\071\001\064\001\065\001\063\001\064\001\ -\065\001\109\001\027\001\091\001\092\001\109\001\094\001\095\001\ -\084\001\065\001\000\001\048\001\049\001\078\001\004\001\230\002\ -\093\001\232\002\008\001\109\001\010\001\003\001\237\002\060\001\ -\014\001\113\001\093\001\242\002\018\001\073\001\067\001\068\001\ -\109\001\070\001\064\001\250\002\251\002\027\001\253\002\000\000\ -\009\000\065\001\109\001\012\000\109\001\014\000\015\000\016\000\ -\007\003\073\001\019\000\020\000\021\000\022\000\023\000\004\001\ -\025\000\064\001\065\001\008\001\014\001\065\001\066\001\017\001\ -\004\001\014\001\015\001\036\000\008\001\018\001\039\000\040\000\ -\041\000\027\001\111\001\064\001\066\001\092\001\018\001\038\003\ -\049\000\050\000\000\001\073\001\053\000\054\000\004\001\027\001\ -\066\001\008\001\008\001\014\001\010\001\052\003\053\003\073\001\ -\014\001\015\001\095\001\004\001\065\001\091\001\092\001\008\001\ -\094\001\095\001\071\001\016\001\152\001\027\001\069\003\000\001\ -\036\001\022\001\000\000\000\001\094\001\066\001\027\001\084\001\ -\073\001\010\001\027\001\113\001\014\001\094\000\095\000\096\000\ -\097\000\022\001\099\000\090\001\000\000\109\001\019\001\004\001\ -\014\001\115\001\022\001\008\001\000\001\026\001\000\001\003\001\ -\103\003\095\001\015\001\095\001\066\001\018\001\109\003\055\001\ -\010\001\013\001\092\001\073\001\103\001\017\001\027\001\118\003\ -\066\001\067\001\121\003\048\001\049\001\014\001\026\001\027\001\ -\028\001\029\001\022\001\130\003\027\001\091\001\092\001\060\001\ -\094\001\095\001\064\001\065\001\139\003\041\001\067\001\068\001\ -\092\001\070\001\145\003\173\001\174\001\000\001\092\001\091\001\ -\161\000\162\000\109\001\113\001\092\001\066\001\092\001\053\001\ -\060\001\055\001\013\001\063\001\255\001\000\002\017\001\067\001\ -\068\001\014\001\109\001\065\001\094\001\172\003\074\001\026\001\ -\027\001\028\001\029\001\094\001\080\001\053\001\010\002\055\001\ -\115\001\020\001\111\001\053\001\197\000\055\001\041\001\004\001\ -\092\001\065\001\094\001\008\001\096\001\097\001\109\001\065\001\ -\199\003\053\001\015\001\055\001\046\001\018\001\205\003\115\001\ -\108\001\060\001\209\003\111\001\063\001\065\001\062\001\066\001\ -\067\001\068\001\217\003\109\001\219\003\220\003\073\001\074\001\ -\108\001\224\003\225\003\226\003\109\001\080\001\229\003\230\003\ -\053\001\109\001\055\001\234\003\022\001\236\003\237\003\002\001\ -\073\001\092\001\100\001\094\001\065\001\096\001\097\001\013\001\ -\000\000\248\003\065\001\066\001\067\001\066\001\073\001\000\001\ -\027\001\108\001\003\001\109\001\111\001\004\004\028\001\029\001\ -\115\001\015\001\092\001\064\001\013\001\022\001\023\001\094\001\ -\017\001\000\001\064\001\041\001\064\001\022\001\008\001\022\004\ -\065\001\026\001\027\001\028\001\029\001\109\001\040\001\018\001\ -\014\001\062\001\062\001\044\001\062\001\007\000\060\001\027\001\ -\041\001\000\000\092\001\094\001\064\001\079\001\068\001\064\001\ -\014\001\058\001\134\002\014\001\074\001\006\001\063\001\094\001\ -\026\000\073\001\080\001\060\001\109\001\060\004\063\001\095\001\ -\065\001\066\001\067\001\068\001\067\004\064\001\075\001\073\001\ -\073\001\074\001\096\001\090\001\022\001\076\004\092\001\080\001\ -\027\001\094\001\014\001\082\004\073\001\040\001\108\001\013\001\ -\087\004\111\001\094\001\092\001\000\001\094\001\027\001\096\001\ -\097\001\014\001\027\001\021\001\008\001\086\001\028\001\029\001\ -\064\001\013\001\064\001\108\001\107\004\108\004\111\001\110\004\ -\062\001\062\001\115\001\041\001\014\001\116\004\026\001\062\001\ -\028\001\029\001\062\001\062\001\062\001\003\001\125\004\126\004\ -\014\001\086\001\064\001\130\004\027\001\041\001\060\001\091\001\ -\095\001\063\001\073\001\101\001\139\004\014\001\068\001\094\001\ -\027\001\027\001\094\001\014\001\074\001\094\001\000\000\088\001\ -\060\001\094\001\080\001\063\001\080\001\064\001\066\001\067\001\ -\068\001\027\001\073\001\014\001\020\001\015\001\074\001\022\001\ -\177\001\094\001\096\001\097\001\080\001\053\001\008\001\145\000\ -\065\001\176\004\177\004\073\001\179\004\062\001\108\001\062\001\ -\092\001\111\001\062\001\014\001\096\001\097\001\094\001\190\004\ -\112\001\163\000\164\000\165\000\112\001\167\000\094\001\073\001\ -\108\001\210\001\021\001\111\001\203\004\064\001\091\001\177\000\ -\178\000\037\003\073\001\053\001\054\001\055\001\056\001\214\004\ -\215\004\216\004\000\001\088\001\095\001\014\001\064\001\065\001\ -\094\001\014\001\225\004\014\001\056\003\014\001\229\004\201\000\ -\202\000\061\003\091\001\205\000\027\001\019\001\019\001\027\001\ -\112\001\088\001\241\004\022\001\026\001\244\004\014\001\014\001\ -\000\001\248\004\014\001\003\001\014\001\000\000\000\000\096\001\ -\084\003\096\001\001\005\092\001\003\005\013\001\008\001\109\001\ -\109\001\017\001\048\001\109\001\064\001\092\001\022\001\036\001\ -\090\001\036\001\026\001\027\001\028\001\029\001\060\001\036\001\ -\092\001\065\001\040\001\065\001\112\003\028\005\068\001\040\002\ -\070\001\041\001\033\005\034\005\064\001\094\001\036\001\064\001\ -\091\001\000\001\041\005\053\001\003\001\001\000\002\000\003\000\ -\004\000\005\000\006\000\007\000\060\001\052\005\013\001\063\001\ -\053\001\065\001\066\001\067\001\068\001\064\001\061\005\062\005\ -\063\005\073\001\074\001\026\001\064\001\028\001\029\001\064\001\ -\080\001\111\001\064\001\074\005\064\001\064\001\077\005\127\000\ -\099\003\040\001\041\001\210\005\092\001\000\000\094\001\008\005\ -\096\001\097\001\060\001\129\005\082\006\199\005\072\002\248\002\ -\190\003\145\001\145\005\183\003\108\001\060\001\101\005\111\001\ -\063\001\122\001\103\002\115\001\067\001\068\001\109\005\199\003\ -\230\001\165\000\190\002\074\001\064\001\065\001\117\005\018\005\ -\027\004\080\001\121\005\071\001\123\005\137\001\125\005\226\001\ -\103\004\077\001\232\002\130\005\188\001\092\001\133\005\133\005\ -\084\001\096\001\097\001\099\005\171\005\221\004\090\001\255\255\ -\143\005\115\001\145\005\255\255\255\255\108\001\149\005\255\255\ -\111\001\255\255\238\003\239\003\255\255\255\255\255\255\255\255\ -\255\255\109\001\110\001\013\001\255\255\255\255\255\255\255\255\ -\167\005\255\255\255\255\255\003\255\255\255\255\255\255\145\001\ -\255\255\255\255\028\001\029\001\255\255\255\255\255\255\255\255\ -\012\004\255\255\255\255\255\255\187\005\255\255\189\005\041\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\028\004\255\255\255\255\202\005\255\255\255\255\205\005\206\005\ -\255\255\000\001\060\001\210\005\255\255\063\001\255\255\255\255\ -\215\005\255\255\068\001\255\255\255\255\255\255\221\005\193\001\ -\074\001\255\255\196\001\197\001\019\001\255\255\080\001\255\255\ -\255\255\232\005\062\004\026\001\000\001\255\255\000\000\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\096\001\097\001\ -\255\255\255\255\255\255\221\001\222\001\223\001\255\255\019\001\ -\255\255\048\001\108\001\229\001\255\255\111\001\026\001\255\255\ -\255\255\008\006\236\001\255\255\255\255\060\001\255\255\255\255\ -\015\006\255\255\007\000\255\255\067\001\068\001\011\000\070\001\ -\255\255\109\004\252\001\253\001\048\001\049\001\255\255\001\002\ -\031\006\255\255\118\004\005\002\255\255\026\000\008\002\255\255\ -\060\001\255\255\255\255\042\006\255\255\255\255\016\002\067\001\ -\068\001\255\255\070\001\255\255\255\255\023\002\255\255\255\255\ -\045\000\255\255\255\255\058\006\255\255\255\255\255\255\033\002\ -\111\001\255\255\255\255\066\006\067\006\255\255\255\255\080\003\ -\042\002\072\006\073\006\255\255\255\255\255\255\048\002\255\255\ -\255\255\255\255\081\006\082\006\083\006\000\001\255\255\255\255\ -\003\001\088\006\060\002\111\001\255\255\063\002\083\000\094\006\ -\085\000\086\000\013\001\183\004\255\255\185\004\072\002\255\255\ -\019\001\000\001\255\255\255\255\255\255\255\255\255\255\026\001\ -\111\006\028\001\029\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\121\006\255\255\255\255\124\006\041\001\255\255\ -\255\255\255\255\255\255\130\006\131\006\103\002\255\255\255\255\ -\255\255\255\255\222\004\255\255\255\255\255\255\255\255\227\004\ -\255\255\060\001\255\255\255\255\063\001\255\255\000\000\255\255\ -\067\001\068\001\255\255\255\255\255\255\255\255\255\255\074\001\ -\055\001\255\255\057\001\058\001\059\001\080\001\061\001\255\255\ -\255\255\064\001\065\001\086\001\255\255\255\255\255\255\164\000\ -\165\000\092\001\167\000\255\255\255\255\096\001\097\001\255\255\ -\255\255\255\255\081\001\255\255\177\000\178\000\255\255\019\005\ -\255\255\108\001\089\001\090\001\111\001\255\255\255\255\255\255\ -\189\000\255\255\097\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\201\000\202\000\109\001\110\001\ -\255\255\206\000\255\255\255\255\190\002\191\002\255\255\051\005\ -\255\255\053\005\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\206\002\207\002\000\001\255\255\ -\002\001\003\001\004\001\071\005\255\255\255\255\008\001\075\005\ -\076\005\255\255\255\255\013\001\255\255\255\255\255\255\017\001\ -\018\001\019\001\255\255\255\255\255\255\231\002\090\005\255\255\ -\026\001\027\001\028\001\029\001\255\255\255\255\255\255\255\255\ -\242\002\255\255\036\001\255\255\000\000\255\255\255\255\041\001\ -\255\255\251\002\255\255\253\002\112\005\255\255\048\001\049\001\ -\255\255\255\255\255\255\255\255\255\255\007\003\255\255\255\255\ -\029\001\255\255\060\001\255\255\255\255\063\001\064\001\255\255\ -\066\001\067\001\068\001\255\255\070\001\255\255\255\255\073\001\ -\074\001\255\255\255\255\255\255\255\255\050\001\080\001\255\255\ -\255\255\255\255\036\003\255\255\038\003\255\255\255\255\255\255\ -\255\255\091\001\092\001\255\255\094\001\095\001\096\001\097\001\ -\255\255\255\255\100\001\053\003\255\255\255\255\255\255\171\005\ -\255\255\000\001\108\001\109\001\000\000\111\001\255\255\255\255\ -\180\005\115\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\019\001\193\005\255\255\255\255\ -\196\005\255\255\255\255\026\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\000\001\007\000\255\255\ -\117\001\118\001\255\255\255\255\121\001\255\255\123\001\255\255\ -\255\255\048\001\049\001\255\255\110\003\255\255\255\255\255\255\ -\019\001\229\005\255\255\255\255\000\000\060\001\000\001\026\001\ -\002\001\003\001\004\001\255\255\067\001\068\001\008\001\070\001\ -\255\255\255\255\255\255\013\001\134\003\255\255\255\255\017\001\ -\018\001\019\001\255\255\255\255\255\255\048\001\255\255\145\003\ -\026\001\027\001\028\001\029\001\255\255\255\255\255\255\255\255\ -\255\255\060\001\036\001\255\255\255\255\255\255\255\255\041\001\ -\067\001\068\001\255\255\070\001\255\255\255\255\048\001\049\001\ -\111\001\255\255\172\003\255\255\255\255\255\255\255\255\196\001\ -\197\001\255\255\060\001\255\255\255\255\063\001\255\255\255\255\ -\066\001\067\001\068\001\255\255\070\001\255\255\255\255\073\001\ -\074\001\255\255\255\255\055\006\255\255\199\003\080\001\255\255\ -\221\001\222\001\223\001\255\255\111\001\255\255\255\255\255\255\ -\229\001\091\001\092\001\255\255\094\001\095\001\096\001\097\001\ -\255\255\219\003\220\003\255\255\255\255\255\255\224\003\225\003\ -\226\003\255\255\108\001\255\255\230\003\111\001\255\255\252\001\ -\253\001\115\001\236\003\255\255\001\002\255\255\255\255\255\255\ -\005\002\101\006\102\006\255\255\000\001\255\255\255\255\255\255\ -\255\255\109\006\255\255\164\000\165\000\255\255\167\000\255\255\ -\255\255\013\001\004\004\255\255\255\255\255\255\255\255\255\255\ -\177\000\178\000\255\255\255\255\033\002\129\006\026\001\255\255\ -\028\001\029\001\255\255\255\255\022\004\042\002\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\041\001\255\255\200\000\ -\201\000\202\000\007\000\255\255\255\255\255\255\011\000\060\002\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\060\001\255\255\255\255\072\002\054\004\026\000\066\001\067\001\ -\068\001\255\255\255\255\255\255\000\001\255\255\074\001\003\001\ -\255\255\255\255\255\255\255\255\080\001\255\255\255\255\255\255\ -\045\000\013\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\092\001\255\255\103\002\255\255\096\001\255\255\026\001\027\001\ -\028\001\029\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\108\001\255\255\255\255\111\001\255\255\041\001\255\255\255\255\ -\255\255\000\000\108\004\255\255\110\004\255\255\083\000\255\255\ -\085\000\086\000\255\255\255\255\000\001\255\255\255\255\003\001\ -\060\001\255\255\255\255\125\004\008\001\255\255\255\255\067\001\ -\068\001\013\001\014\001\255\255\255\255\255\255\074\001\019\001\ -\255\255\139\004\022\001\255\255\080\001\255\255\026\001\007\000\ -\028\001\029\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\092\001\255\255\094\001\068\001\096\001\041\001\255\255\255\255\ -\255\255\255\255\255\255\136\000\077\001\255\255\255\255\255\255\ -\108\001\255\255\191\002\111\001\255\255\255\255\176\004\255\255\ -\060\001\255\255\255\255\063\001\255\255\065\001\066\001\067\001\ -\068\001\206\002\207\002\006\001\255\255\008\001\074\001\164\000\ -\165\000\255\255\167\000\079\001\080\001\255\255\255\255\255\255\ -\255\255\203\004\255\255\255\255\177\000\178\000\255\255\255\255\ -\092\001\255\255\231\002\255\255\096\001\097\001\216\004\255\255\ -\189\000\255\255\220\004\255\255\255\255\242\002\255\255\255\255\ -\108\001\255\255\255\255\111\001\201\000\202\000\251\002\255\255\ -\253\002\206\000\255\255\255\255\055\001\255\255\057\001\058\001\ -\059\001\255\255\061\001\255\255\255\255\064\001\065\001\255\255\ -\255\255\255\255\255\255\000\001\255\255\255\255\255\255\255\255\ -\255\255\003\005\255\255\255\255\255\255\255\255\081\001\255\255\ -\013\001\255\255\255\255\255\255\255\255\006\001\089\001\090\001\ -\255\255\038\003\255\255\255\255\000\000\026\001\097\001\028\001\ -\029\001\255\255\028\005\196\001\197\001\255\255\255\255\255\255\ -\255\255\255\255\109\001\110\001\041\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\164\000\165\000\255\255\167\000\ -\255\255\255\255\052\005\220\001\221\001\222\001\223\001\060\001\ -\029\001\177\000\178\000\255\255\229\001\255\255\055\001\068\001\ -\057\001\058\001\059\001\255\255\061\001\074\001\015\001\064\001\ -\065\001\255\255\255\255\080\001\255\255\050\001\255\255\255\255\ -\255\255\201\000\202\000\252\001\253\001\255\255\255\255\255\255\ -\001\002\255\255\255\255\096\001\005\002\028\000\029\000\255\255\ -\255\255\090\001\043\001\044\001\045\001\046\001\015\002\108\001\ -\097\001\000\001\111\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\008\001\255\255\255\255\109\001\110\001\013\001\121\005\ -\033\002\066\001\255\255\125\005\145\003\255\255\071\001\072\001\ -\130\005\042\002\255\255\026\001\255\255\028\001\029\001\255\255\ -\255\255\255\255\083\001\084\001\085\001\086\001\255\255\145\005\ -\117\001\118\001\041\001\060\002\121\001\255\255\123\001\172\003\ -\087\000\088\000\255\255\100\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\060\001\255\255\255\255\ -\063\001\255\255\255\255\066\001\067\001\068\001\255\255\255\255\ -\255\255\255\255\199\003\074\001\255\255\255\255\255\255\255\255\ -\157\001\080\001\000\000\255\255\000\000\255\255\103\002\164\001\ -\255\255\166\001\255\255\255\255\255\255\092\001\219\003\220\003\ -\255\255\096\001\097\001\224\003\225\003\226\003\255\255\255\255\ -\210\005\230\003\212\005\255\255\255\255\108\001\255\255\236\003\ -\111\001\255\255\255\255\255\255\255\255\255\255\255\255\196\001\ -\197\001\255\255\255\255\255\255\255\255\255\255\232\005\255\255\ -\023\001\255\255\255\255\255\255\255\255\255\255\255\255\004\004\ -\134\001\243\005\255\255\255\255\255\255\036\001\255\255\255\255\ -\221\001\222\001\223\001\255\255\015\001\255\255\255\255\255\255\ -\229\001\255\255\255\255\255\255\255\255\007\006\255\255\255\255\ -\055\001\255\255\057\001\058\001\059\001\015\006\061\001\255\255\ -\018\006\064\001\065\001\255\255\000\001\255\255\191\002\252\001\ -\253\001\044\001\045\001\046\001\001\002\255\255\255\255\255\255\ -\005\002\013\001\255\255\255\255\255\255\206\002\207\002\255\255\ -\190\001\043\006\255\255\090\001\255\255\255\255\026\001\255\255\ -\028\001\029\001\097\001\255\255\071\001\072\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\033\002\041\001\109\001\110\001\ -\083\001\084\001\085\001\086\001\255\255\042\002\255\255\255\255\ -\255\255\242\002\255\255\255\255\196\001\197\001\255\255\255\255\ -\060\001\100\001\251\002\063\001\253\002\255\255\088\006\060\002\ -\068\001\110\004\255\255\255\255\255\255\255\255\074\001\255\255\ -\255\255\255\255\255\255\072\002\080\001\221\001\222\001\223\001\ -\125\004\255\255\255\255\255\255\255\255\229\001\230\001\255\255\ -\092\001\255\255\255\255\255\255\096\001\097\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\038\003\255\255\255\255\ -\108\001\255\255\103\002\111\001\252\001\253\001\255\255\255\255\ -\255\255\001\002\255\255\255\255\255\255\005\002\255\255\078\001\ -\079\001\080\001\081\001\082\001\083\001\084\001\085\001\086\001\ -\087\001\088\001\089\001\090\001\091\001\092\001\093\001\094\001\ -\095\001\096\001\097\001\098\001\000\000\100\001\255\255\255\255\ -\102\001\033\002\255\255\105\001\255\255\107\001\255\255\109\001\ -\255\255\111\001\042\002\114\001\255\255\255\255\203\004\255\255\ -\255\255\255\255\255\255\160\002\255\255\255\255\255\255\255\255\ -\127\001\255\255\255\255\255\255\060\002\255\255\255\255\013\001\ -\255\255\013\001\255\255\116\003\255\255\255\255\255\255\141\001\ -\255\255\143\001\255\255\255\255\255\255\255\255\028\001\029\001\ -\028\001\029\001\191\002\255\255\255\255\255\255\255\255\255\255\ -\255\255\159\001\255\255\041\001\255\255\041\001\255\255\255\255\ -\145\003\206\002\207\002\255\255\130\002\255\255\255\255\103\002\ -\255\255\000\000\255\255\008\005\255\255\255\255\060\001\255\255\ -\060\001\063\001\255\255\063\001\255\255\255\255\068\001\255\255\ -\068\001\255\255\255\255\172\003\074\001\255\255\074\001\028\005\ -\255\255\255\255\080\001\006\001\080\001\242\002\255\255\255\255\ -\255\255\255\255\255\255\169\002\255\255\255\255\251\002\255\255\ -\253\002\255\255\096\001\097\001\096\001\097\001\199\003\255\255\ -\255\255\255\255\015\001\255\255\255\255\255\255\108\001\255\255\ -\108\001\111\001\232\001\111\001\234\001\255\255\255\255\255\255\ -\255\255\255\255\219\003\220\003\255\255\255\255\223\003\224\003\ -\225\003\226\003\255\255\255\255\055\001\230\003\057\001\058\001\ -\059\001\038\003\061\001\236\003\255\255\064\001\065\001\191\002\ -\255\255\007\002\055\001\009\002\057\001\058\001\059\001\255\255\ -\061\001\255\255\255\255\064\001\065\001\255\255\206\002\207\002\ -\255\255\024\002\255\255\004\004\255\255\074\001\029\002\090\001\ -\255\255\255\255\255\255\255\255\081\001\255\255\097\001\255\255\ -\125\005\255\255\255\255\255\255\089\001\090\001\255\255\132\005\ -\255\255\094\001\109\001\110\001\097\001\255\255\255\255\255\255\ -\255\255\255\255\242\002\255\255\145\005\255\255\255\255\255\255\ -\109\001\110\001\255\255\251\002\255\255\253\002\255\255\255\255\ -\255\255\255\255\255\255\074\002\075\002\255\255\255\255\255\255\ -\255\255\118\003\255\255\255\255\255\255\255\255\123\003\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\052\003\255\255\ -\255\255\000\000\255\255\255\255\000\001\255\255\255\255\003\001\ -\255\255\255\255\255\255\255\255\145\003\255\255\038\003\110\002\ -\255\255\013\001\255\255\255\255\115\002\116\002\117\002\255\255\ -\255\255\255\255\255\255\255\255\255\255\210\005\026\001\027\001\ -\028\001\029\001\255\255\129\002\255\255\110\004\132\002\172\003\ -\255\255\255\255\255\255\255\255\255\255\041\001\255\255\255\255\ -\255\255\103\003\255\255\232\005\125\004\255\255\255\255\109\003\ -\255\255\255\255\255\255\255\255\255\255\255\255\243\005\255\255\ -\060\001\255\255\199\003\255\255\064\001\255\255\066\001\067\001\ -\068\001\255\255\255\255\255\255\255\255\073\001\074\001\255\255\ -\255\255\000\001\255\255\255\255\080\001\255\255\219\003\220\003\ -\255\255\255\255\255\255\224\003\225\003\226\003\013\001\255\255\ -\092\001\230\003\094\001\255\255\096\001\097\001\255\255\236\003\ -\100\001\255\255\255\255\026\001\255\255\028\001\029\001\255\255\ -\108\001\109\001\000\000\111\001\255\255\255\255\043\006\214\002\ -\255\255\145\003\041\001\255\255\219\002\220\002\221\002\004\004\ -\255\255\000\001\203\004\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\233\002\255\255\060\001\255\255\255\255\ -\063\001\255\255\255\255\255\255\172\003\068\001\255\255\205\003\ -\255\255\255\255\255\255\074\001\255\255\255\255\255\255\255\255\ -\255\255\080\001\255\255\002\003\255\255\255\255\004\003\255\255\ -\255\255\255\255\255\255\255\255\255\255\092\001\255\255\199\003\ -\255\255\096\001\097\001\018\003\234\003\255\255\255\255\237\003\ -\055\001\255\255\057\001\058\001\059\001\108\001\061\001\255\255\ -\111\001\064\001\065\001\219\003\220\003\074\004\255\255\255\255\ -\224\003\225\003\226\003\255\255\255\255\255\255\230\003\255\255\ -\255\255\255\255\081\001\028\005\236\003\255\255\255\255\255\255\ -\255\255\255\255\089\001\090\001\255\255\255\255\255\255\255\255\ -\000\000\255\255\097\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\110\004\255\255\255\255\004\004\108\001\109\001\110\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\125\004\255\255\255\255\255\255\255\255\255\255\255\255\094\003\ -\255\255\000\001\001\001\002\001\003\001\255\255\060\004\255\255\ -\255\255\008\001\009\001\010\001\255\255\067\004\013\001\014\001\ -\255\255\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ -\255\255\024\001\025\001\026\001\027\001\028\001\029\001\255\255\ -\255\255\087\004\128\003\255\255\255\255\036\001\037\001\255\255\ -\255\255\040\001\041\001\042\001\043\001\255\255\000\000\255\255\ -\255\255\048\001\049\001\255\255\125\005\107\004\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\060\001\061\001\255\255\ -\063\001\255\255\255\255\066\001\067\001\068\001\203\004\070\001\ -\145\005\255\255\073\001\074\001\255\255\255\255\255\255\255\255\ -\255\255\080\001\255\255\082\001\255\255\255\255\110\004\181\003\ -\255\255\255\255\255\255\255\255\091\001\092\001\255\255\094\001\ -\095\001\096\001\097\001\255\255\255\255\125\004\255\255\255\255\ -\103\001\255\255\105\001\255\255\203\003\108\001\255\255\244\004\ -\111\001\255\255\000\001\255\255\115\001\003\001\255\255\213\003\ -\255\255\255\255\008\001\177\004\255\255\255\255\255\255\013\001\ -\255\255\255\255\255\255\008\005\255\255\019\001\023\001\255\255\ -\255\255\210\005\255\255\255\255\026\001\255\255\028\001\029\001\ -\255\255\255\255\255\255\036\001\255\255\255\255\255\255\028\005\ -\255\255\255\255\255\255\041\001\250\003\255\255\252\003\232\005\ -\214\004\215\004\255\255\255\255\255\255\255\255\055\001\255\255\ -\057\001\058\001\059\001\225\004\061\001\255\255\060\001\064\001\ -\065\001\063\001\255\255\203\004\066\001\067\001\068\001\255\255\ -\061\005\255\255\255\255\241\004\074\001\255\255\255\255\255\255\ -\255\255\255\255\080\001\255\255\255\255\255\255\037\004\038\004\ -\039\004\090\001\255\255\255\255\000\000\255\255\092\001\255\255\ -\097\001\255\255\096\001\097\001\255\255\051\004\255\255\255\255\ -\255\255\255\255\255\255\255\255\109\001\110\001\108\001\255\255\ -\000\001\111\001\255\255\003\001\255\255\255\255\255\255\255\255\ -\255\255\071\004\255\255\033\005\034\005\013\001\014\001\255\255\ -\255\255\017\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\125\005\255\255\026\001\027\001\028\001\029\001\255\255\132\005\ -\255\255\096\004\097\004\098\004\028\005\255\255\255\255\255\255\ -\040\001\041\001\255\255\255\255\145\005\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\074\005\255\255\255\255\077\005\ -\255\255\255\255\255\255\255\255\060\001\255\255\255\255\063\001\ -\255\255\255\255\255\255\067\001\068\001\255\255\255\255\093\005\ -\094\005\073\001\074\001\138\004\255\255\255\255\000\001\101\005\ -\080\001\003\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\013\001\092\001\255\255\094\001\017\001\ -\096\001\097\001\255\255\255\255\255\255\123\005\255\255\255\255\ -\026\001\027\001\028\001\029\001\108\001\210\005\255\255\111\001\ -\255\255\000\000\255\255\115\001\255\255\255\255\180\004\041\001\ -\182\004\255\255\184\004\000\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\232\005\255\255\125\005\255\255\255\255\ -\255\255\255\255\060\001\255\255\255\255\063\001\205\004\206\004\ -\207\004\067\001\068\001\255\255\211\004\212\004\213\004\255\255\ -\074\001\145\005\255\255\255\255\255\255\255\255\080\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\092\001\255\255\094\001\235\004\096\001\097\001\ -\255\255\199\005\055\001\255\255\057\001\058\001\059\001\205\005\ -\061\001\247\004\108\001\064\001\065\001\111\001\255\255\255\255\ -\255\255\215\005\000\005\255\255\255\255\255\255\004\005\221\005\ -\255\255\255\255\255\255\255\255\081\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\089\001\090\001\255\255\255\255\ -\255\255\255\255\210\005\255\255\097\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\109\001\110\001\255\255\255\255\000\001\001\001\002\001\003\001\ -\232\005\255\255\008\006\255\255\008\001\009\001\010\001\255\255\ -\255\255\013\001\014\001\015\001\016\001\017\001\018\001\019\001\ -\020\001\021\001\255\255\255\255\024\001\025\001\026\001\027\001\ -\028\001\029\001\255\255\000\000\255\255\255\255\255\255\255\255\ -\036\001\037\001\255\255\255\255\040\001\041\001\042\001\043\001\ -\044\001\045\001\046\001\255\255\048\001\049\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\058\006\255\255\255\255\255\255\ -\060\001\061\001\255\255\063\001\255\255\255\255\066\001\067\001\ -\068\001\255\255\070\001\071\001\072\001\073\001\074\001\255\255\ -\255\255\255\255\255\255\081\006\080\001\083\006\082\001\083\001\ -\084\001\085\001\086\001\255\255\255\255\255\255\255\255\091\001\ -\092\001\255\255\094\001\095\001\096\001\097\001\255\255\255\255\ -\100\001\255\255\255\255\103\001\255\255\105\001\255\255\255\255\ -\108\001\255\255\255\255\111\001\255\255\255\255\255\255\115\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\166\005\255\255\255\255\255\255\013\001\255\255\255\255\255\255\ -\255\255\000\001\255\255\002\001\003\001\004\001\181\005\182\005\ -\183\005\008\001\255\255\028\001\029\001\255\255\013\001\000\000\ -\255\255\255\255\017\001\018\001\019\001\255\255\255\255\255\255\ -\041\001\255\255\200\005\026\001\027\001\028\001\029\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\036\001\255\255\213\005\ -\255\255\040\001\041\001\060\001\255\255\219\005\063\001\255\255\ -\255\255\048\001\049\001\068\001\255\255\255\255\255\255\255\255\ -\255\255\074\001\255\255\255\255\255\255\060\001\236\005\080\001\ -\063\001\255\255\255\255\066\001\067\001\068\001\244\005\070\001\ -\255\255\255\255\073\001\074\001\255\255\255\255\255\255\096\001\ -\255\255\080\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\108\001\091\001\092\001\111\001\094\001\ -\095\001\096\001\255\255\255\255\255\255\100\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\108\001\255\255\255\255\ -\111\001\255\255\255\255\255\255\115\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\044\006\045\006\ -\255\255\255\255\255\255\000\000\255\255\051\006\052\006\053\006\ -\054\006\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\063\006\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\000\001\001\001\002\001\003\001\255\255\ -\078\006\006\001\007\001\008\001\009\001\010\001\011\001\012\001\ -\013\001\014\001\015\001\016\001\017\001\018\001\019\001\020\001\ -\021\001\022\001\255\255\024\001\025\001\026\001\027\001\028\001\ -\029\001\030\001\031\001\255\255\255\255\255\255\255\255\036\001\ -\037\001\255\255\255\255\040\001\041\001\042\001\043\001\044\001\ -\045\001\046\001\047\001\048\001\049\001\050\001\051\001\255\255\ -\053\001\054\001\055\001\056\001\255\255\255\255\059\001\060\001\ -\061\001\062\001\063\001\064\001\065\001\066\001\067\001\068\001\ -\255\255\070\001\071\001\072\001\073\001\074\001\255\255\076\001\ -\255\255\255\255\255\255\080\001\081\001\082\001\083\001\084\001\ -\085\001\086\001\087\001\255\255\089\001\255\255\091\001\092\001\ -\000\000\094\001\095\001\096\001\097\001\098\001\255\255\100\001\ -\101\001\255\255\103\001\104\001\105\001\106\001\255\255\108\001\ -\109\001\255\255\111\001\255\255\255\255\255\255\115\001\000\001\ -\001\001\002\001\003\001\004\001\255\255\006\001\007\001\008\001\ -\009\001\010\001\011\001\012\001\013\001\014\001\015\001\016\001\ -\017\001\018\001\019\001\020\001\021\001\255\255\255\255\024\001\ -\025\001\026\001\027\001\028\001\029\001\030\001\031\001\255\255\ -\255\255\255\255\255\255\036\001\037\001\255\255\255\255\040\001\ -\041\001\042\001\043\001\044\001\045\001\046\001\047\001\048\001\ -\049\001\050\001\051\001\255\255\053\001\054\001\055\001\056\001\ -\255\255\255\255\059\001\060\001\061\001\255\255\063\001\064\001\ -\065\001\066\001\067\001\068\001\255\255\070\001\071\001\072\001\ -\073\001\074\001\255\255\076\001\255\255\255\255\255\255\080\001\ -\081\001\082\001\083\001\084\001\085\001\086\001\087\001\255\255\ -\089\001\255\255\091\001\092\001\000\000\094\001\095\001\096\001\ -\097\001\098\001\255\255\100\001\101\001\255\255\103\001\104\001\ -\105\001\106\001\255\255\108\001\109\001\255\255\111\001\255\255\ -\255\255\255\255\115\001\000\001\001\001\002\001\003\001\255\255\ -\255\255\006\001\007\001\008\001\009\001\010\001\011\001\012\001\ -\013\001\014\001\015\001\016\001\017\001\018\001\019\001\020\001\ -\021\001\022\001\255\255\024\001\025\001\026\001\027\001\028\001\ -\029\001\030\001\031\001\255\255\255\255\255\255\255\255\036\001\ -\037\001\255\255\255\255\040\001\041\001\042\001\043\001\044\001\ -\045\001\046\001\047\001\048\001\049\001\050\001\051\001\255\255\ -\053\001\054\001\055\001\056\001\255\255\255\255\059\001\060\001\ -\061\001\255\255\063\001\064\001\065\001\066\001\067\001\068\001\ -\255\255\070\001\071\001\072\001\073\001\074\001\255\255\076\001\ -\255\255\255\255\255\255\080\001\081\001\082\001\083\001\084\001\ -\085\001\086\001\087\001\255\255\089\001\255\255\091\001\092\001\ -\000\000\094\001\095\001\096\001\097\001\098\001\255\255\100\001\ -\101\001\255\255\103\001\104\001\105\001\106\001\255\255\108\001\ -\109\001\255\255\111\001\255\255\255\255\255\255\115\001\255\255\ -\000\001\001\001\002\001\003\001\255\255\255\255\006\001\007\001\ -\008\001\009\001\010\001\011\001\012\001\013\001\014\001\015\001\ -\016\001\017\001\018\001\019\001\020\001\021\001\022\001\255\255\ -\024\001\025\001\026\001\027\001\028\001\029\001\030\001\031\001\ -\255\255\255\255\255\255\255\255\036\001\037\001\255\255\255\255\ -\040\001\041\001\042\001\043\001\044\001\045\001\046\001\047\001\ -\048\001\049\001\050\001\051\001\255\255\053\001\054\001\055\001\ -\056\001\255\255\255\255\059\001\060\001\061\001\255\255\063\001\ -\064\001\065\001\066\001\067\001\068\001\255\255\070\001\071\001\ -\072\001\073\001\074\001\255\255\076\001\255\255\255\255\255\255\ -\080\001\081\001\082\001\083\001\084\001\085\001\086\001\087\001\ -\255\255\089\001\255\255\091\001\092\001\000\000\094\001\095\001\ -\096\001\097\001\098\001\255\255\100\001\101\001\255\255\103\001\ -\104\001\105\001\106\001\255\255\108\001\109\001\255\255\111\001\ -\255\255\255\255\255\255\115\001\000\001\001\001\002\001\003\001\ -\255\255\255\255\006\001\007\001\008\001\009\001\010\001\011\001\ -\012\001\013\001\014\001\015\001\016\001\017\001\018\001\019\001\ -\020\001\021\001\022\001\255\255\024\001\025\001\026\001\027\001\ -\028\001\029\001\030\001\031\001\255\255\255\255\255\255\255\255\ -\036\001\037\001\255\255\255\255\040\001\041\001\042\001\043\001\ -\044\001\045\001\046\001\047\001\048\001\049\001\050\001\051\001\ -\255\255\053\001\054\001\055\001\056\001\255\255\255\255\059\001\ -\060\001\061\001\255\255\063\001\064\001\065\001\066\001\067\001\ -\068\001\255\255\070\001\071\001\072\001\073\001\074\001\255\255\ -\076\001\255\255\255\255\255\255\080\001\081\001\082\001\083\001\ -\084\001\085\001\086\001\087\001\255\255\089\001\255\255\091\001\ -\092\001\000\000\094\001\095\001\096\001\097\001\098\001\255\255\ -\100\001\101\001\255\255\103\001\104\001\105\001\106\001\255\255\ -\108\001\109\001\255\255\111\001\255\255\255\255\255\255\115\001\ -\000\001\001\001\002\001\003\001\255\255\255\255\006\001\007\001\ -\008\001\009\001\010\001\011\001\012\001\013\001\014\001\015\001\ -\016\001\017\001\018\001\019\001\020\001\021\001\022\001\255\255\ -\024\001\025\001\026\001\027\001\028\001\029\001\030\001\031\001\ -\255\255\255\255\255\255\255\255\036\001\037\001\255\255\255\255\ -\040\001\041\001\042\001\043\001\044\001\045\001\046\001\047\001\ -\048\001\049\001\050\001\051\001\255\255\053\001\054\001\055\001\ -\056\001\255\255\255\255\059\001\060\001\061\001\255\255\063\001\ -\064\001\065\001\066\001\067\001\068\001\255\255\070\001\071\001\ -\072\001\073\001\074\001\255\255\076\001\255\255\255\255\255\255\ -\080\001\081\001\082\001\083\001\084\001\085\001\086\001\087\001\ -\255\255\089\001\255\255\091\001\092\001\000\000\094\001\095\001\ -\096\001\097\001\098\001\255\255\100\001\101\001\255\255\103\001\ -\104\001\105\001\106\001\255\255\108\001\109\001\255\255\111\001\ -\255\255\255\255\255\255\115\001\255\255\000\001\001\001\002\001\ -\003\001\255\255\255\255\006\001\007\001\008\001\009\001\010\001\ -\011\001\012\001\013\001\014\001\015\001\016\001\017\001\018\001\ -\019\001\020\001\021\001\022\001\255\255\024\001\025\001\026\001\ -\027\001\028\001\029\001\030\001\031\001\255\255\255\255\255\255\ -\255\255\036\001\037\001\255\255\255\255\040\001\041\001\042\001\ -\043\001\044\001\045\001\046\001\047\001\048\001\049\001\050\001\ -\051\001\255\255\053\001\054\001\055\001\056\001\255\255\255\255\ -\059\001\060\001\061\001\255\255\063\001\064\001\065\001\066\001\ -\067\001\068\001\255\255\070\001\071\001\072\001\073\001\074\001\ -\255\255\076\001\255\255\255\255\255\255\080\001\081\001\082\001\ -\083\001\084\001\085\001\086\001\087\001\255\255\089\001\255\255\ -\091\001\092\001\000\000\094\001\095\001\096\001\097\001\098\001\ -\255\255\100\001\101\001\255\255\103\001\104\001\105\001\106\001\ -\255\255\108\001\109\001\255\255\111\001\255\255\255\255\255\255\ -\115\001\000\001\001\001\002\001\003\001\255\255\255\255\006\001\ -\007\001\008\001\009\001\010\001\011\001\012\001\013\001\014\001\ -\015\001\016\001\017\001\018\001\019\001\020\001\021\001\022\001\ -\255\255\024\001\025\001\026\001\027\001\028\001\029\001\030\001\ -\031\001\255\255\255\255\255\255\255\255\036\001\037\001\255\255\ -\255\255\040\001\041\001\042\001\043\001\044\001\045\001\046\001\ -\047\001\048\001\049\001\050\001\051\001\255\255\053\001\054\001\ -\055\001\056\001\255\255\255\255\059\001\060\001\061\001\255\255\ -\063\001\064\001\065\001\066\001\067\001\068\001\255\255\070\001\ -\071\001\072\001\073\001\074\001\255\255\076\001\255\255\255\255\ -\255\255\080\001\081\001\082\001\083\001\084\001\085\001\086\001\ -\087\001\255\255\089\001\255\255\091\001\092\001\000\000\094\001\ -\095\001\096\001\097\001\098\001\255\255\100\001\101\001\255\255\ -\103\001\104\001\105\001\106\001\255\255\108\001\109\001\255\255\ -\111\001\255\255\255\255\255\255\115\001\000\001\001\001\002\001\ -\003\001\255\255\255\255\006\001\007\001\008\001\009\001\010\001\ -\011\001\012\001\013\001\014\001\015\001\016\001\017\001\018\001\ -\019\001\020\001\021\001\022\001\255\255\024\001\025\001\026\001\ -\027\001\028\001\029\001\030\001\031\001\255\255\255\255\255\255\ -\255\255\036\001\037\001\255\255\255\255\040\001\041\001\042\001\ -\043\001\044\001\045\001\046\001\047\001\048\001\049\001\050\001\ -\051\001\255\255\053\001\054\001\055\001\056\001\255\255\255\255\ -\059\001\060\001\061\001\255\255\063\001\064\001\065\001\066\001\ -\067\001\068\001\255\255\070\001\071\001\072\001\073\001\074\001\ -\255\255\076\001\255\255\255\255\255\255\080\001\081\001\082\001\ -\083\001\084\001\085\001\086\001\087\001\255\255\089\001\255\255\ -\091\001\092\001\000\000\094\001\095\001\096\001\097\001\098\001\ -\255\255\100\001\101\001\255\255\103\001\104\001\105\001\106\001\ -\255\255\108\001\109\001\255\255\111\001\255\255\255\255\255\255\ -\115\001\255\255\000\001\001\001\002\001\003\001\255\255\255\255\ -\006\001\007\001\008\001\009\001\010\001\011\001\012\001\013\001\ -\014\001\015\001\016\001\017\001\018\001\019\001\020\001\021\001\ -\022\001\255\255\024\001\025\001\026\001\027\001\028\001\029\001\ -\030\001\031\001\255\255\255\255\255\255\255\255\036\001\037\001\ -\255\255\255\255\040\001\041\001\042\001\043\001\044\001\045\001\ -\046\001\047\001\048\001\049\001\050\001\051\001\255\255\053\001\ -\054\001\055\001\056\001\255\255\255\255\059\001\060\001\061\001\ -\255\255\063\001\064\001\065\001\066\001\067\001\068\001\255\255\ -\070\001\071\001\072\001\073\001\074\001\255\255\076\001\255\255\ -\255\255\255\255\080\001\081\001\082\001\083\001\084\001\085\001\ -\086\001\087\001\255\255\089\001\255\255\091\001\092\001\000\000\ -\094\001\095\001\096\001\097\001\098\001\255\255\100\001\101\001\ -\255\255\103\001\104\001\105\001\106\001\255\255\108\001\109\001\ -\255\255\111\001\255\255\255\255\255\255\115\001\000\001\001\001\ -\002\001\003\001\255\255\255\255\006\001\007\001\008\001\009\001\ -\010\001\011\001\012\001\013\001\014\001\015\001\016\001\017\001\ -\018\001\019\001\020\001\021\001\022\001\255\255\024\001\025\001\ -\026\001\027\001\028\001\029\001\030\001\031\001\255\255\255\255\ -\255\255\255\255\036\001\037\001\255\255\255\255\040\001\041\001\ -\042\001\043\001\044\001\045\001\046\001\047\001\048\001\049\001\ -\050\001\051\001\255\255\053\001\054\001\055\001\056\001\255\255\ -\255\255\059\001\060\001\061\001\255\255\063\001\064\001\065\001\ -\066\001\067\001\068\001\255\255\070\001\071\001\072\001\073\001\ -\074\001\255\255\076\001\255\255\255\255\255\255\080\001\081\001\ -\082\001\083\001\084\001\085\001\086\001\087\001\255\255\089\001\ -\255\255\091\001\092\001\000\000\094\001\095\001\096\001\097\001\ -\098\001\255\255\100\001\101\001\255\255\103\001\104\001\105\001\ -\106\001\255\255\108\001\109\001\255\255\111\001\255\255\255\255\ -\255\255\115\001\000\001\001\001\002\001\003\001\255\255\255\255\ -\006\001\007\001\008\001\009\001\010\001\011\001\012\001\013\001\ -\014\001\015\001\016\001\017\001\018\001\019\001\020\001\021\001\ -\022\001\255\255\024\001\025\001\026\001\027\001\028\001\029\001\ -\030\001\031\001\255\255\255\255\255\255\255\255\036\001\037\001\ -\255\255\255\255\040\001\041\001\042\001\043\001\044\001\045\001\ -\046\001\047\001\048\001\049\001\050\001\051\001\255\255\053\001\ -\054\001\055\001\056\001\255\255\255\255\059\001\060\001\061\001\ -\255\255\063\001\064\001\065\001\066\001\067\001\068\001\255\255\ -\070\001\071\001\072\001\073\001\074\001\255\255\076\001\255\255\ -\255\255\255\255\080\001\081\001\082\001\083\001\084\001\085\001\ -\086\001\087\001\255\255\089\001\255\255\091\001\092\001\000\000\ -\094\001\095\001\096\001\097\001\098\001\255\255\100\001\101\001\ -\255\255\103\001\104\001\105\001\106\001\255\255\108\001\109\001\ -\255\255\111\001\255\255\255\255\255\255\115\001\255\255\000\001\ -\001\001\002\001\003\001\004\001\255\255\006\001\007\001\008\001\ -\009\001\010\001\011\001\012\001\013\001\014\001\015\001\016\001\ -\017\001\018\001\019\001\020\001\021\001\255\255\255\255\024\001\ -\025\001\026\001\027\001\028\001\029\001\030\001\031\001\255\255\ -\255\255\255\255\255\255\036\001\037\001\255\255\255\255\040\001\ -\041\001\042\001\043\001\044\001\045\001\046\001\255\255\048\001\ -\049\001\050\001\051\001\255\255\053\001\054\001\055\001\056\001\ -\255\255\255\255\059\001\060\001\061\001\255\255\063\001\064\001\ -\065\001\066\001\067\001\068\001\255\255\070\001\071\001\072\001\ -\073\001\074\001\255\255\076\001\255\255\255\255\255\255\080\001\ -\081\001\082\001\083\001\084\001\085\001\086\001\087\001\255\255\ -\089\001\255\255\091\001\092\001\000\000\094\001\095\001\096\001\ -\097\001\098\001\255\255\100\001\101\001\255\255\103\001\104\001\ -\105\001\106\001\255\255\108\001\109\001\255\255\111\001\255\255\ -\255\255\255\255\115\001\000\001\001\001\002\001\003\001\004\001\ -\255\255\006\001\007\001\008\001\009\001\010\001\011\001\012\001\ -\013\001\014\001\015\001\016\001\017\001\018\001\019\001\020\001\ -\021\001\255\255\255\255\024\001\025\001\026\001\027\001\028\001\ -\029\001\030\001\031\001\255\255\255\255\255\255\255\255\036\001\ -\037\001\255\255\255\255\040\001\041\001\042\001\043\001\044\001\ -\045\001\046\001\255\255\048\001\049\001\050\001\051\001\255\255\ -\053\001\054\001\055\001\056\001\255\255\255\255\059\001\060\001\ -\061\001\255\255\063\001\064\001\065\001\066\001\067\001\068\001\ -\255\255\070\001\071\001\072\001\073\001\074\001\255\255\076\001\ -\255\255\255\255\255\255\080\001\081\001\082\001\083\001\084\001\ -\085\001\086\001\087\001\255\255\089\001\255\255\091\001\092\001\ -\000\000\094\001\095\001\096\001\255\255\255\255\255\255\100\001\ -\101\001\255\255\103\001\104\001\105\001\106\001\255\255\108\001\ -\109\001\255\255\111\001\255\255\255\255\255\255\115\001\000\001\ -\001\001\002\001\003\001\004\001\255\255\006\001\007\001\008\001\ -\009\001\010\001\011\001\012\001\013\001\014\001\015\001\016\001\ -\017\001\018\001\019\001\020\001\021\001\255\255\255\255\024\001\ -\025\001\026\001\027\001\028\001\029\001\030\001\031\001\255\255\ -\255\255\255\255\255\255\036\001\037\001\255\255\255\255\040\001\ -\041\001\042\001\043\001\044\001\045\001\046\001\255\255\048\001\ -\049\001\050\001\051\001\255\255\053\001\054\001\055\001\056\001\ -\255\255\255\255\059\001\060\001\061\001\255\255\063\001\064\001\ -\065\001\066\001\067\001\068\001\255\255\070\001\071\001\072\001\ -\073\001\074\001\255\255\076\001\255\255\255\255\255\255\080\001\ -\081\001\082\001\083\001\084\001\085\001\086\001\087\001\255\255\ -\089\001\255\255\091\001\092\001\000\000\094\001\095\001\096\001\ -\255\255\255\255\255\255\100\001\101\001\255\255\103\001\104\001\ -\105\001\106\001\255\255\108\001\109\001\255\255\111\001\255\255\ -\255\255\255\255\115\001\255\255\000\001\001\001\002\001\003\001\ -\004\001\255\255\006\001\007\001\008\001\009\001\010\001\011\001\ -\012\001\013\001\014\001\015\001\016\001\017\001\018\001\019\001\ -\020\001\021\001\255\255\255\255\024\001\025\001\026\001\027\001\ -\028\001\029\001\030\001\031\001\255\255\255\255\255\255\255\255\ -\036\001\037\001\255\255\255\255\040\001\041\001\042\001\043\001\ -\044\001\045\001\046\001\255\255\048\001\049\001\050\001\051\001\ -\255\255\053\001\054\001\055\001\056\001\255\255\255\255\059\001\ -\060\001\061\001\255\255\063\001\064\001\065\001\066\001\067\001\ -\068\001\255\255\070\001\071\001\072\001\073\001\074\001\255\255\ -\076\001\255\255\255\255\255\255\080\001\081\001\082\001\083\001\ -\084\001\085\001\086\001\087\001\255\255\089\001\255\255\091\001\ -\092\001\000\000\094\001\095\001\096\001\255\255\255\255\255\255\ -\100\001\101\001\255\255\103\001\104\001\105\001\106\001\255\255\ -\108\001\109\001\255\255\111\001\255\255\255\255\255\255\115\001\ -\000\001\001\001\002\001\003\001\255\255\255\255\255\255\255\255\ -\008\001\009\001\010\001\255\255\255\255\013\001\014\001\015\001\ -\016\001\017\001\018\001\019\001\020\001\021\001\022\001\255\255\ -\024\001\025\001\026\001\027\001\028\001\029\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\036\001\037\001\255\255\255\255\ -\040\001\041\001\042\001\043\001\044\001\045\001\046\001\047\001\ -\048\001\049\001\255\255\051\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\060\001\061\001\255\255\063\001\ -\255\255\255\255\066\001\067\001\068\001\255\255\070\001\071\001\ -\072\001\073\001\074\001\255\255\255\255\255\255\255\255\255\255\ -\080\001\081\001\082\001\083\001\084\001\085\001\086\001\255\255\ -\255\255\089\001\255\255\091\001\092\001\000\000\094\001\095\001\ -\096\001\097\001\098\001\255\255\100\001\255\255\255\255\103\001\ -\104\001\105\001\255\255\255\255\108\001\255\255\255\255\111\001\ -\255\255\255\255\255\255\115\001\000\001\001\001\002\001\003\001\ -\255\255\255\255\255\255\255\255\008\001\009\001\010\001\255\255\ -\255\255\013\001\014\001\015\001\016\001\017\001\018\001\019\001\ -\020\001\021\001\022\001\255\255\024\001\025\001\026\001\027\001\ -\028\001\029\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\036\001\037\001\255\255\255\255\040\001\041\001\042\001\043\001\ -\044\001\045\001\046\001\047\001\048\001\049\001\255\255\051\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\060\001\061\001\255\255\063\001\255\255\255\255\066\001\067\001\ -\068\001\255\255\070\001\071\001\072\001\073\001\074\001\255\255\ -\255\255\255\255\255\255\255\255\080\001\081\001\082\001\083\001\ -\084\001\085\001\086\001\255\255\255\255\089\001\255\255\091\001\ -\092\001\000\000\094\001\095\001\096\001\097\001\098\001\255\255\ -\100\001\255\255\255\255\103\001\104\001\105\001\255\255\255\255\ -\108\001\255\255\255\255\111\001\255\255\255\255\255\255\115\001\ -\255\255\000\001\001\001\002\001\003\001\255\255\255\255\255\255\ -\255\255\008\001\009\001\010\001\255\255\255\255\013\001\014\001\ -\015\001\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ -\255\255\024\001\025\001\026\001\027\001\028\001\029\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\036\001\037\001\255\255\ -\255\255\040\001\041\001\042\001\043\001\044\001\045\001\046\001\ -\255\255\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\060\001\061\001\255\255\ -\063\001\255\255\255\255\066\001\067\001\068\001\255\255\070\001\ -\071\001\072\001\073\001\074\001\255\255\255\255\255\255\255\255\ -\255\255\080\001\255\255\082\001\083\001\084\001\085\001\086\001\ -\255\255\255\255\255\255\255\255\091\001\092\001\000\000\094\001\ -\095\001\096\001\255\255\255\255\255\255\100\001\255\255\255\255\ -\103\001\255\255\105\001\255\255\255\255\108\001\255\255\255\255\ -\111\001\255\255\255\255\255\255\115\001\000\001\001\001\002\001\ -\003\001\255\255\255\255\255\255\255\255\008\001\009\001\010\001\ -\255\255\255\255\013\001\014\001\015\001\016\001\017\001\255\255\ -\019\001\020\001\021\001\255\255\255\255\024\001\025\001\026\001\ -\027\001\028\001\029\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\036\001\037\001\255\255\255\255\040\001\041\001\042\001\ -\043\001\044\001\045\001\046\001\255\255\048\001\049\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\060\001\061\001\255\255\063\001\255\255\255\255\066\001\ -\067\001\068\001\255\255\070\001\071\001\072\001\073\001\074\001\ -\255\255\255\255\255\255\255\255\255\255\080\001\255\255\082\001\ -\083\001\084\001\085\001\086\001\255\255\255\255\255\255\255\255\ -\091\001\092\001\000\000\094\001\095\001\096\001\097\001\255\255\ -\255\255\100\001\255\255\255\255\103\001\255\255\105\001\255\255\ -\255\255\108\001\255\255\255\255\111\001\255\255\255\255\255\255\ -\115\001\000\001\001\001\002\001\003\001\255\255\255\255\255\255\ -\255\255\008\001\009\001\010\001\255\255\255\255\013\001\014\001\ -\015\001\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ -\255\255\024\001\025\001\026\001\027\001\028\001\029\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\036\001\037\001\255\255\ -\255\255\040\001\041\001\042\001\043\001\044\001\045\001\046\001\ -\255\255\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\060\001\061\001\255\255\ -\063\001\255\255\255\255\066\001\067\001\068\001\255\255\070\001\ -\071\001\072\001\073\001\074\001\255\255\255\255\255\255\255\255\ -\255\255\080\001\255\255\082\001\083\001\084\001\085\001\086\001\ -\255\255\255\255\255\255\255\255\091\001\092\001\000\000\094\001\ -\095\001\096\001\255\255\255\255\255\255\100\001\255\255\255\255\ -\103\001\255\255\105\001\255\255\255\255\108\001\255\255\255\255\ -\111\001\255\255\255\255\255\255\115\001\255\255\000\001\001\001\ -\002\001\003\001\255\255\255\255\255\255\255\255\008\001\009\001\ -\010\001\255\255\255\255\013\001\014\001\015\001\016\001\017\001\ -\018\001\019\001\020\001\021\001\255\255\255\255\024\001\025\001\ -\026\001\027\001\028\001\029\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\036\001\037\001\255\255\255\255\040\001\041\001\ -\042\001\043\001\044\001\045\001\046\001\255\255\048\001\049\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\060\001\061\001\255\255\063\001\255\255\255\255\ -\066\001\067\001\068\001\255\255\070\001\071\001\072\001\073\001\ -\074\001\255\255\255\255\255\255\255\255\255\255\080\001\255\255\ -\082\001\083\001\084\001\085\001\086\001\255\255\255\255\255\255\ -\255\255\091\001\092\001\000\000\094\001\095\001\096\001\255\255\ -\255\255\255\255\100\001\255\255\255\255\103\001\255\255\105\001\ -\255\255\255\255\108\001\255\255\255\255\111\001\255\255\255\255\ -\255\255\115\001\000\001\001\001\002\001\003\001\255\255\255\255\ -\255\255\255\255\008\001\009\001\010\001\255\255\255\255\013\001\ -\014\001\015\001\016\001\017\001\018\001\019\001\020\001\021\001\ -\255\255\255\255\024\001\025\001\026\001\027\001\028\001\029\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\036\001\037\001\ -\255\255\255\255\040\001\041\001\042\001\043\001\044\001\045\001\ -\046\001\255\255\048\001\049\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\060\001\061\001\ -\255\255\063\001\255\255\255\255\066\001\067\001\068\001\255\255\ -\070\001\071\001\072\001\073\001\074\001\255\255\255\255\255\255\ -\255\255\255\255\080\001\255\255\082\001\083\001\084\001\085\001\ -\086\001\255\255\255\255\255\255\255\255\091\001\092\001\000\000\ -\094\001\095\001\096\001\255\255\255\255\255\255\100\001\255\255\ -\255\255\103\001\255\255\105\001\255\255\255\255\108\001\255\255\ -\255\255\111\001\255\255\255\255\255\255\115\001\000\001\001\001\ -\002\001\003\001\255\255\255\255\255\255\255\255\008\001\009\001\ -\010\001\255\255\255\255\013\001\014\001\015\001\016\001\017\001\ -\018\001\019\001\020\001\021\001\255\255\255\255\024\001\025\001\ -\026\001\027\001\028\001\029\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\036\001\037\001\255\255\255\255\040\001\041\001\ -\042\001\043\001\044\001\045\001\046\001\255\255\048\001\049\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\060\001\061\001\255\255\063\001\255\255\255\255\ -\066\001\067\001\068\001\255\255\070\001\071\001\072\001\073\001\ -\074\001\255\255\255\255\255\255\255\255\255\255\080\001\255\255\ -\082\001\083\001\084\001\085\001\086\001\255\255\255\255\255\255\ -\255\255\091\001\092\001\000\000\094\001\095\001\096\001\255\255\ -\255\255\255\255\100\001\255\255\255\255\103\001\255\255\105\001\ -\255\255\255\255\108\001\255\255\255\255\111\001\255\255\255\255\ -\255\255\115\001\255\255\000\001\001\001\002\001\003\001\255\255\ -\255\255\255\255\255\255\008\001\009\001\010\001\255\255\255\255\ -\013\001\014\001\015\001\016\001\017\001\018\001\019\001\020\001\ -\021\001\255\255\255\255\024\001\025\001\026\001\027\001\028\001\ -\029\001\255\255\255\255\255\255\255\255\255\255\255\255\036\001\ -\037\001\255\255\255\255\040\001\041\001\042\001\043\001\044\001\ -\045\001\255\255\255\255\048\001\049\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\060\001\ -\061\001\255\255\063\001\255\255\255\255\066\001\067\001\068\001\ -\255\255\070\001\071\001\072\001\073\001\074\001\255\255\255\255\ -\255\255\255\255\255\255\080\001\255\255\082\001\083\001\084\001\ -\085\001\086\001\255\255\255\255\255\255\255\255\091\001\092\001\ -\000\000\094\001\095\001\096\001\097\001\255\255\255\255\100\001\ -\255\255\255\255\103\001\255\255\105\001\255\255\255\255\108\001\ -\255\255\255\255\111\001\255\255\255\255\255\255\115\001\000\001\ -\001\001\002\001\003\001\255\255\255\255\255\255\255\255\008\001\ -\009\001\010\001\255\255\255\255\013\001\014\001\015\001\016\001\ -\017\001\018\001\019\001\020\001\021\001\255\255\255\255\024\001\ -\025\001\026\001\027\001\028\001\029\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\036\001\037\001\255\255\255\255\040\001\ -\041\001\042\001\043\001\044\001\045\001\255\255\255\255\048\001\ -\049\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\060\001\061\001\255\255\063\001\255\255\ -\255\255\066\001\067\001\068\001\255\255\070\001\071\001\072\001\ -\073\001\074\001\255\255\255\255\255\255\255\255\255\255\080\001\ -\255\255\082\001\083\001\084\001\085\001\086\001\255\255\255\255\ -\255\255\255\255\091\001\092\001\000\000\094\001\095\001\096\001\ -\097\001\255\255\255\255\100\001\255\255\255\255\103\001\255\255\ -\105\001\255\255\255\255\108\001\255\255\255\255\111\001\255\255\ -\255\255\255\255\115\001\000\001\001\001\002\001\003\001\255\255\ -\255\255\255\255\255\255\008\001\009\001\010\001\255\255\255\255\ -\013\001\014\001\015\001\016\001\017\001\018\001\019\001\020\001\ -\021\001\255\255\255\255\024\001\025\001\026\001\027\001\028\001\ -\029\001\255\255\255\255\255\255\255\255\255\255\255\255\036\001\ -\037\001\255\255\255\255\040\001\041\001\042\001\043\001\044\001\ -\045\001\255\255\255\255\048\001\049\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\060\001\ -\061\001\255\255\063\001\255\255\255\255\066\001\067\001\068\001\ -\255\255\070\001\071\001\072\001\073\001\074\001\255\255\255\255\ -\255\255\255\255\255\255\080\001\255\255\082\001\083\001\084\001\ -\085\001\086\001\255\255\255\255\255\255\255\255\091\001\092\001\ -\000\000\094\001\095\001\096\001\097\001\255\255\255\255\100\001\ -\255\255\255\255\103\001\255\255\105\001\255\255\255\255\108\001\ -\255\255\255\255\111\001\255\255\255\255\255\255\115\001\255\255\ -\000\001\001\001\002\001\003\001\255\255\255\255\255\255\255\255\ -\008\001\009\001\010\001\255\255\255\255\013\001\014\001\015\001\ -\016\001\017\001\018\001\019\001\020\001\021\001\255\255\255\255\ -\024\001\025\001\026\001\027\001\028\001\029\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\036\001\037\001\255\255\255\255\ -\040\001\041\001\042\001\043\001\044\001\045\001\255\255\255\255\ -\048\001\049\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\060\001\061\001\255\255\063\001\ -\255\255\255\255\066\001\067\001\068\001\255\255\070\001\071\001\ -\072\001\073\001\074\001\255\255\255\255\255\255\255\255\255\255\ -\080\001\255\255\082\001\083\001\084\001\085\001\086\001\255\255\ -\255\255\255\255\255\255\091\001\092\001\000\000\094\001\095\001\ -\096\001\097\001\255\255\255\255\100\001\255\255\255\255\103\001\ -\255\255\105\001\255\255\255\255\108\001\255\255\255\255\111\001\ -\255\255\255\255\255\255\115\001\000\001\001\001\002\001\003\001\ -\255\255\255\255\255\255\255\255\255\255\009\001\010\001\255\255\ -\255\255\013\001\014\001\015\001\016\001\017\001\018\001\019\001\ -\020\001\021\001\255\255\255\255\024\001\025\001\026\001\027\001\ -\028\001\029\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\036\001\037\001\255\255\255\255\040\001\041\001\042\001\043\001\ -\044\001\045\001\046\001\255\255\048\001\049\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\060\001\061\001\255\255\063\001\255\255\255\255\066\001\067\001\ -\068\001\255\255\070\001\071\001\072\001\073\001\074\001\255\255\ -\255\255\255\255\255\255\255\255\080\001\255\255\082\001\083\001\ -\084\001\085\001\086\001\255\255\255\255\255\255\255\255\091\001\ -\092\001\000\000\094\001\095\001\096\001\097\001\255\255\255\255\ -\100\001\255\255\255\255\103\001\255\255\105\001\255\255\255\255\ -\108\001\255\255\255\255\111\001\255\255\255\255\255\255\115\001\ -\000\001\001\001\002\001\003\001\255\255\255\255\255\255\255\255\ -\255\255\009\001\010\001\255\255\255\255\013\001\014\001\015\001\ -\016\001\017\001\018\001\019\001\020\001\021\001\255\255\255\255\ -\024\001\025\001\026\001\027\001\028\001\029\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\036\001\037\001\255\255\255\255\ -\040\001\041\001\042\001\043\001\044\001\045\001\046\001\255\255\ -\048\001\049\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\060\001\061\001\255\255\063\001\ -\255\255\255\255\066\001\067\001\068\001\255\255\070\001\071\001\ -\072\001\073\001\074\001\255\255\255\255\255\255\255\255\255\255\ -\080\001\255\255\082\001\083\001\084\001\085\001\086\001\255\255\ -\255\255\255\255\255\255\091\001\092\001\000\000\094\001\095\001\ -\096\001\097\001\255\255\255\255\100\001\255\255\255\255\103\001\ -\255\255\105\001\255\255\255\255\108\001\255\255\255\255\111\001\ -\255\255\255\255\255\255\115\001\255\255\000\001\001\001\002\001\ -\003\001\255\255\255\255\255\255\255\255\255\255\009\001\010\001\ -\255\255\255\255\013\001\014\001\015\001\016\001\017\001\018\001\ -\019\001\020\001\021\001\255\255\255\255\024\001\025\001\026\001\ -\027\001\028\001\029\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\036\001\037\001\255\255\255\255\040\001\041\001\042\001\ -\043\001\044\001\045\001\046\001\255\255\048\001\049\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\060\001\061\001\255\255\063\001\255\255\255\255\066\001\ -\067\001\068\001\255\255\070\001\071\001\072\001\073\001\074\001\ -\255\255\255\255\255\255\255\255\255\255\080\001\255\255\082\001\ -\083\001\084\001\085\001\086\001\255\255\255\255\255\255\255\255\ -\091\001\092\001\000\000\094\001\095\001\096\001\097\001\255\255\ -\255\255\100\001\255\255\255\255\103\001\255\255\105\001\255\255\ -\255\255\108\001\255\255\255\255\111\001\255\255\255\255\255\255\ -\115\001\000\001\001\001\002\001\003\001\255\255\255\255\255\255\ -\255\255\008\001\009\001\010\001\255\255\255\255\013\001\014\001\ -\015\001\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ -\255\255\024\001\025\001\026\001\027\001\028\001\029\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\036\001\037\001\255\255\ -\255\255\040\001\041\001\042\001\043\001\044\001\255\255\255\255\ -\255\255\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\060\001\061\001\255\255\ -\063\001\255\255\255\255\066\001\067\001\068\001\255\255\070\001\ -\071\001\072\001\073\001\074\001\255\255\255\255\255\255\255\255\ -\255\255\080\001\255\255\082\001\255\255\084\001\085\001\086\001\ -\255\255\255\255\255\255\255\255\091\001\092\001\000\000\094\001\ -\095\001\096\001\097\001\255\255\255\255\255\255\255\255\255\255\ -\103\001\255\255\105\001\255\255\255\255\108\001\255\255\255\255\ -\111\001\255\255\255\255\255\255\115\001\000\001\001\001\002\001\ -\003\001\255\255\255\255\255\255\255\255\008\001\009\001\010\001\ -\255\255\255\255\013\001\014\001\015\001\016\001\017\001\018\001\ -\019\001\020\001\021\001\255\255\255\255\024\001\025\001\026\001\ -\027\001\028\001\029\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\036\001\037\001\255\255\255\255\040\001\041\001\042\001\ -\043\001\044\001\255\255\255\255\255\255\048\001\049\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\060\001\061\001\255\255\063\001\255\255\255\255\066\001\ -\067\001\068\001\255\255\070\001\071\001\072\001\073\001\074\001\ -\255\255\255\255\255\255\255\255\255\255\080\001\255\255\082\001\ -\255\255\084\001\085\001\086\001\255\255\255\255\255\255\255\255\ -\091\001\092\001\000\000\094\001\095\001\096\001\097\001\255\255\ -\255\255\255\255\255\255\255\255\103\001\255\255\105\001\255\255\ -\255\255\108\001\255\255\255\255\111\001\255\255\255\255\255\255\ -\115\001\255\255\000\001\001\001\002\001\003\001\255\255\255\255\ -\255\255\255\255\008\001\009\001\010\001\255\255\255\255\013\001\ -\014\001\015\001\016\001\017\001\018\001\019\001\020\001\021\001\ -\255\255\255\255\024\001\025\001\026\001\027\001\028\001\029\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\036\001\037\001\ -\255\255\255\255\040\001\041\001\042\001\043\001\044\001\255\255\ -\255\255\255\255\048\001\049\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\060\001\061\001\ -\255\255\063\001\255\255\255\255\066\001\067\001\068\001\255\255\ -\070\001\071\001\072\001\073\001\074\001\255\255\255\255\255\255\ -\255\255\255\255\080\001\255\255\082\001\255\255\084\001\085\001\ -\086\001\255\255\255\255\255\255\255\255\091\001\092\001\000\000\ -\094\001\095\001\096\001\097\001\255\255\255\255\255\255\255\255\ -\255\255\103\001\255\255\105\001\255\255\255\255\108\001\255\255\ -\255\255\111\001\255\255\255\255\255\255\115\001\000\001\001\001\ -\002\001\003\001\255\255\255\255\255\255\255\255\008\001\009\001\ -\010\001\255\255\255\255\013\001\014\001\015\001\016\001\017\001\ -\018\001\019\001\020\001\021\001\255\255\255\255\024\001\025\001\ -\026\001\027\001\028\001\029\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\036\001\037\001\255\255\255\255\040\001\041\001\ -\042\001\043\001\044\001\255\255\255\255\255\255\048\001\049\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\060\001\061\001\255\255\063\001\255\255\255\255\ -\066\001\067\001\068\001\255\255\070\001\071\001\072\001\073\001\ -\074\001\255\255\255\255\255\255\255\255\255\255\080\001\255\255\ -\082\001\255\255\084\001\085\001\086\001\255\255\255\255\255\255\ -\255\255\091\001\092\001\000\000\094\001\095\001\096\001\097\001\ -\255\255\255\255\255\255\255\255\255\255\103\001\255\255\105\001\ -\255\255\255\255\108\001\255\255\255\255\111\001\255\255\255\255\ -\255\255\115\001\000\001\001\001\002\001\003\001\255\255\255\255\ -\255\255\255\255\008\001\009\001\010\001\255\255\255\255\013\001\ -\014\001\015\001\016\001\017\001\018\001\019\001\020\001\021\001\ -\255\255\255\255\024\001\025\001\026\001\027\001\028\001\029\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\036\001\037\001\ -\255\255\255\255\040\001\041\001\042\001\043\001\044\001\255\255\ -\255\255\255\255\048\001\049\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\060\001\061\001\ -\255\255\063\001\255\255\255\255\066\001\067\001\068\001\255\255\ -\070\001\071\001\072\001\073\001\074\001\255\255\255\255\255\255\ -\255\255\255\255\080\001\255\255\082\001\255\255\084\001\085\001\ -\086\001\255\255\255\255\255\255\255\255\091\001\092\001\000\000\ -\094\001\095\001\096\001\097\001\255\255\255\255\255\255\255\255\ -\255\255\103\001\255\255\105\001\255\255\255\255\108\001\255\255\ -\255\255\111\001\255\255\255\255\255\255\115\001\255\255\000\001\ -\001\001\002\001\003\001\255\255\255\255\255\255\255\255\008\001\ -\009\001\010\001\255\255\255\255\013\001\014\001\015\001\016\001\ -\017\001\018\001\019\001\020\001\021\001\255\255\255\255\024\001\ -\025\001\026\001\027\001\028\001\029\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\036\001\037\001\255\255\255\255\040\001\ -\041\001\042\001\043\001\044\001\255\255\255\255\255\255\048\001\ -\049\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\060\001\061\001\255\255\063\001\255\255\ -\255\255\066\001\067\001\068\001\255\255\070\001\071\001\072\001\ -\073\001\074\001\255\255\255\255\255\255\255\255\255\255\080\001\ -\255\255\082\001\255\255\084\001\085\001\086\001\255\255\255\255\ -\255\255\255\255\091\001\092\001\000\000\094\001\095\001\096\001\ -\097\001\255\255\255\255\255\255\255\255\255\255\103\001\255\255\ -\105\001\255\255\255\255\108\001\255\255\255\255\111\001\255\255\ -\255\255\255\255\115\001\000\001\001\001\002\001\003\001\255\255\ -\255\255\255\255\255\255\008\001\009\001\010\001\255\255\255\255\ -\013\001\014\001\015\001\016\001\017\001\018\001\019\001\020\001\ -\021\001\255\255\255\255\024\001\025\001\026\001\027\001\028\001\ -\029\001\255\255\255\255\255\255\255\255\255\255\255\255\036\001\ -\037\001\255\255\255\255\040\001\041\001\042\001\043\001\044\001\ -\045\001\046\001\255\255\048\001\049\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\060\001\ -\061\001\255\255\255\255\255\255\255\255\066\001\067\001\068\001\ -\255\255\070\001\255\255\255\255\073\001\074\001\255\255\255\255\ -\255\255\255\255\255\255\080\001\255\255\082\001\255\255\255\255\ -\255\255\086\001\255\255\255\255\255\255\255\255\091\001\092\001\ -\000\000\094\001\095\001\096\001\097\001\255\255\255\255\100\001\ -\255\255\255\255\103\001\255\255\105\001\255\255\255\255\108\001\ -\255\255\255\255\111\001\255\255\255\255\255\255\115\001\000\001\ -\001\001\002\001\003\001\255\255\255\255\255\255\255\255\008\001\ -\009\001\010\001\255\255\255\255\013\001\014\001\255\255\016\001\ -\017\001\018\001\019\001\020\001\021\001\255\255\255\255\024\001\ -\025\001\026\001\027\001\028\001\029\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\036\001\037\001\255\255\255\255\040\001\ -\041\001\042\001\255\255\255\255\255\255\255\255\255\255\048\001\ -\049\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\060\001\061\001\255\255\063\001\255\255\ -\255\255\255\255\067\001\068\001\255\255\070\001\255\255\255\255\ -\073\001\074\001\255\255\255\255\255\255\255\255\255\255\080\001\ -\255\255\082\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\091\001\092\001\000\000\094\001\095\001\096\001\ -\097\001\255\255\255\255\255\255\255\255\255\255\103\001\255\255\ -\105\001\255\255\255\255\108\001\255\255\255\255\111\001\255\255\ -\255\255\255\255\115\001\255\255\000\001\001\001\002\001\003\001\ -\255\255\255\255\255\255\255\255\008\001\009\001\010\001\255\255\ -\255\255\013\001\014\001\255\255\016\001\017\001\018\001\019\001\ -\020\001\021\001\255\255\255\255\024\001\025\001\026\001\027\001\ -\028\001\029\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\036\001\037\001\255\255\255\255\040\001\041\001\042\001\255\255\ -\255\255\255\255\255\255\255\255\048\001\049\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\060\001\061\001\255\255\063\001\255\255\255\255\255\255\067\001\ -\068\001\255\255\070\001\255\255\255\255\073\001\074\001\255\255\ -\255\255\255\255\255\255\255\255\080\001\255\255\082\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\091\001\ -\092\001\000\000\094\001\095\001\096\001\097\001\255\255\255\255\ -\255\255\255\255\255\255\103\001\255\255\105\001\255\255\255\255\ -\108\001\255\255\255\255\111\001\255\255\255\255\255\255\115\001\ -\000\001\001\001\002\001\003\001\255\255\255\255\255\255\255\255\ -\008\001\009\001\010\001\255\255\255\255\013\001\014\001\255\255\ -\016\001\017\001\018\001\019\001\020\001\021\001\255\255\255\255\ -\024\001\025\001\026\001\027\001\028\001\029\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\036\001\037\001\255\255\255\255\ -\040\001\041\001\042\001\255\255\255\255\255\255\255\255\255\255\ -\048\001\049\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\060\001\061\001\255\255\063\001\ -\255\255\255\255\255\255\067\001\068\001\255\255\070\001\255\255\ -\255\255\073\001\074\001\255\255\255\255\255\255\255\255\255\255\ -\080\001\000\000\082\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\091\001\092\001\255\255\094\001\095\001\ -\096\001\097\001\255\255\255\255\255\255\255\255\255\255\103\001\ -\255\255\105\001\255\255\255\255\108\001\255\255\255\255\111\001\ -\255\255\255\255\255\255\115\001\000\001\001\001\002\001\003\001\ -\255\255\255\255\255\255\255\255\008\001\009\001\010\001\255\255\ -\255\255\013\001\014\001\255\255\016\001\017\001\018\001\019\001\ -\020\001\021\001\255\255\255\255\024\001\025\001\026\001\027\001\ -\028\001\029\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\036\001\037\001\255\255\255\255\040\001\041\001\042\001\255\255\ -\255\255\255\255\255\255\255\255\048\001\049\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\060\001\061\001\255\255\063\001\255\255\255\255\255\255\067\001\ -\068\001\000\000\070\001\255\255\255\255\073\001\074\001\255\255\ -\255\255\255\255\255\255\255\255\080\001\255\255\082\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\091\001\ -\092\001\255\255\094\001\095\001\096\001\097\001\255\255\255\255\ -\255\255\255\255\255\255\103\001\255\255\105\001\255\255\255\255\ -\108\001\255\255\255\255\111\001\255\255\255\255\255\255\115\001\ -\255\255\000\001\001\001\002\001\003\001\255\255\255\255\255\255\ -\255\255\008\001\009\001\010\001\255\255\255\255\013\001\014\001\ -\255\255\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ -\255\255\024\001\025\001\026\001\027\001\028\001\029\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\036\001\037\001\255\255\ -\255\255\040\001\041\001\042\001\255\255\255\255\255\255\255\255\ -\255\255\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\000\000\255\255\255\255\255\255\060\001\061\001\255\255\ -\063\001\255\255\255\255\255\255\067\001\068\001\255\255\070\001\ -\255\255\255\255\073\001\074\001\255\255\255\255\255\255\255\255\ -\255\255\080\001\255\255\082\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\091\001\092\001\255\255\094\001\ -\095\001\096\001\097\001\255\255\255\255\255\255\255\255\255\255\ -\103\001\000\001\105\001\255\255\003\001\108\001\255\255\255\255\ -\111\001\008\001\009\001\010\001\115\001\255\255\013\001\014\001\ -\255\255\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ -\255\255\024\001\025\001\026\001\255\255\028\001\029\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\037\001\255\255\ -\255\255\040\001\041\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\000\000\255\255\255\255\255\255\060\001\255\255\255\255\ -\063\001\255\255\255\255\255\255\067\001\068\001\255\255\070\001\ -\255\255\255\255\073\001\074\001\255\255\255\255\255\255\255\255\ -\255\255\080\001\255\255\082\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\091\001\092\001\255\255\094\001\ -\095\001\096\001\097\001\255\255\255\255\255\255\255\255\255\255\ -\103\001\000\001\105\001\255\255\003\001\108\001\255\255\255\255\ -\111\001\008\001\009\001\010\001\115\001\255\255\013\001\014\001\ -\255\255\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ -\255\255\024\001\025\001\026\001\255\255\028\001\029\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\037\001\255\255\ -\255\255\040\001\041\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\000\000\255\255\255\255\255\255\060\001\255\255\255\255\ -\063\001\255\255\255\255\255\255\067\001\068\001\255\255\070\001\ -\255\255\255\255\073\001\074\001\255\255\255\255\255\255\255\255\ -\255\255\080\001\255\255\082\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\091\001\092\001\255\255\094\001\ -\095\001\096\001\097\001\255\255\255\255\255\255\255\255\255\255\ -\103\001\000\001\105\001\255\255\003\001\108\001\255\255\255\255\ -\111\001\008\001\255\255\010\001\115\001\255\255\013\001\014\001\ -\255\255\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ -\255\255\024\001\025\001\026\001\255\255\028\001\029\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\037\001\255\255\ -\255\255\040\001\041\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\000\000\255\255\255\255\255\255\060\001\255\255\255\255\ -\063\001\255\255\255\255\255\255\067\001\068\001\255\255\070\001\ -\255\255\255\255\073\001\074\001\255\255\255\255\255\255\255\255\ -\255\255\080\001\255\255\255\255\255\255\255\255\255\255\000\000\ -\255\255\255\255\255\255\255\255\091\001\092\001\255\255\094\001\ -\095\001\096\001\097\001\255\255\255\255\255\255\255\255\255\255\ -\103\001\000\001\105\001\255\255\003\001\108\001\255\255\255\255\ -\111\001\008\001\255\255\010\001\115\001\255\255\013\001\014\001\ -\255\255\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ -\255\255\024\001\025\001\026\001\255\255\028\001\029\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\037\001\255\255\ -\255\255\040\001\041\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\048\001\049\001\255\255\000\000\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\060\001\255\255\255\255\ -\063\001\255\255\255\255\255\255\067\001\068\001\255\255\070\001\ -\255\255\255\255\073\001\074\001\255\255\255\255\255\255\255\255\ -\255\255\080\001\000\000\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\091\001\092\001\255\255\094\001\ -\095\001\096\001\097\001\255\255\255\255\255\255\255\255\255\255\ -\103\001\000\001\105\001\255\255\003\001\108\001\255\255\255\255\ -\111\001\008\001\255\255\010\001\115\001\255\255\013\001\014\001\ -\255\255\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ -\255\255\024\001\025\001\026\001\255\255\028\001\029\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\037\001\255\255\ -\255\255\040\001\041\001\255\255\255\255\255\255\255\255\000\000\ -\255\255\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\060\001\255\255\255\255\ -\063\001\255\255\255\255\255\255\067\001\068\001\255\255\070\001\ -\255\255\255\255\073\001\074\001\255\255\255\255\255\255\255\255\ -\255\255\080\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\091\001\092\001\255\255\094\001\ -\095\001\096\001\097\001\255\255\255\255\255\255\255\255\255\255\ -\103\001\000\001\105\001\255\255\003\001\108\001\255\255\255\255\ -\111\001\008\001\255\255\010\001\115\001\255\255\013\001\014\001\ -\255\255\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ -\255\255\024\001\025\001\026\001\255\255\028\001\029\001\000\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\037\001\255\255\ -\255\255\040\001\041\001\255\255\013\001\255\255\255\255\000\000\ -\023\001\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\026\001\255\255\028\001\029\001\060\001\255\255\255\255\ -\063\001\255\255\255\255\255\255\067\001\068\001\255\255\070\001\ -\041\001\255\255\073\001\074\001\255\255\000\000\255\255\255\255\ -\055\001\080\001\057\001\058\001\059\001\255\255\061\001\255\255\ -\255\255\064\001\065\001\060\001\091\001\092\001\063\001\094\001\ -\095\001\096\001\097\001\068\001\000\001\255\255\255\255\003\001\ -\103\001\074\001\105\001\255\255\008\001\108\001\010\001\080\001\ -\111\001\013\001\014\001\090\001\115\001\017\001\255\255\019\001\ -\020\001\021\001\097\001\092\001\024\001\025\001\026\001\096\001\ -\028\001\029\001\000\001\255\255\255\255\003\001\109\001\110\001\ -\255\255\037\001\255\255\108\001\040\001\041\001\111\001\013\001\ -\255\255\255\255\000\000\255\255\048\001\049\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\026\001\255\255\028\001\029\001\ -\060\001\255\255\255\255\063\001\255\255\255\255\255\255\067\001\ -\068\001\255\255\070\001\041\001\255\255\073\001\074\001\255\255\ -\000\000\053\001\255\255\055\001\080\001\057\001\058\001\059\001\ -\255\255\061\001\255\255\255\255\064\001\065\001\060\001\091\001\ -\092\001\255\255\094\001\095\001\096\001\097\001\068\001\000\001\ -\255\255\255\255\003\001\103\001\074\001\105\001\255\255\008\001\ -\108\001\010\001\080\001\111\001\013\001\014\001\090\001\115\001\ -\017\001\255\255\019\001\020\001\021\001\097\001\092\001\024\001\ -\025\001\026\001\096\001\028\001\029\001\255\255\255\255\255\255\ -\255\255\109\001\110\001\255\255\037\001\255\255\108\001\040\001\ -\041\001\111\001\255\255\255\255\255\255\000\000\255\255\048\001\ -\049\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\060\001\255\255\255\255\063\001\255\255\ -\255\255\255\255\067\001\068\001\255\255\070\001\255\255\255\255\ -\073\001\074\001\255\255\255\255\255\255\255\255\255\255\080\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\091\001\092\001\255\255\094\001\095\001\096\001\ -\097\001\255\255\255\255\255\255\255\255\255\255\103\001\000\001\ -\105\001\255\255\003\001\108\001\255\255\255\255\111\001\008\001\ -\255\255\010\001\115\001\255\255\013\001\014\001\255\255\255\255\ -\017\001\255\255\019\001\020\001\021\001\255\255\255\255\024\001\ -\025\001\026\001\255\255\028\001\029\001\000\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\037\001\255\255\255\255\040\001\ -\041\001\255\255\013\001\255\255\255\255\000\000\255\255\048\001\ -\049\001\255\255\255\255\255\255\255\255\255\255\255\255\026\001\ -\255\255\028\001\029\001\060\001\255\255\255\255\063\001\255\255\ -\255\255\255\255\067\001\068\001\255\255\070\001\041\001\255\255\ -\073\001\074\001\255\255\000\000\255\255\255\255\055\001\080\001\ -\057\001\058\001\059\001\255\255\061\001\255\255\255\255\064\001\ -\065\001\060\001\091\001\092\001\255\255\094\001\095\001\096\001\ -\097\001\068\001\000\001\255\255\255\255\003\001\103\001\074\001\ -\105\001\255\255\008\001\108\001\010\001\080\001\111\001\013\001\ -\014\001\090\001\115\001\017\001\255\255\019\001\020\001\021\001\ -\097\001\092\001\024\001\025\001\026\001\096\001\028\001\029\001\ -\000\001\255\255\255\255\255\255\109\001\110\001\255\255\037\001\ -\255\255\108\001\040\001\041\001\111\001\013\001\255\255\255\255\ -\000\000\255\255\048\001\049\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\026\001\255\255\028\001\029\001\060\001\255\255\ -\255\255\063\001\255\255\255\255\255\255\067\001\068\001\255\255\ -\070\001\041\001\255\255\073\001\074\001\255\255\000\000\255\255\ -\255\255\255\255\080\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\060\001\091\001\092\001\255\255\ -\094\001\095\001\096\001\097\001\068\001\000\001\255\255\255\255\ -\003\001\103\001\074\001\105\001\255\255\008\001\108\001\010\001\ -\080\001\111\001\013\001\014\001\255\255\115\001\017\001\255\255\ -\019\001\020\001\021\001\255\255\092\001\024\001\025\001\026\001\ -\096\001\028\001\029\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\037\001\255\255\108\001\040\001\041\001\111\001\ -\255\255\255\255\255\255\000\000\255\255\048\001\049\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\060\001\255\255\255\255\063\001\255\255\255\255\255\255\ -\067\001\068\001\255\255\070\001\255\255\255\255\073\001\074\001\ -\255\255\255\255\255\255\255\255\255\255\080\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\091\001\092\001\255\255\094\001\095\001\096\001\097\001\255\255\ -\255\255\255\255\255\255\255\255\103\001\000\001\105\001\255\255\ -\003\001\108\001\255\255\255\255\111\001\008\001\255\255\010\001\ -\115\001\255\255\013\001\014\001\255\255\255\255\017\001\255\255\ -\019\001\020\001\021\001\255\255\255\255\024\001\025\001\026\001\ -\255\255\028\001\029\001\000\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\037\001\255\255\255\255\040\001\041\001\255\255\ -\013\001\255\255\255\255\000\000\255\255\048\001\049\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\026\001\255\255\028\001\ -\029\001\060\001\255\255\255\255\063\001\255\255\255\255\255\255\ -\067\001\068\001\255\255\070\001\041\001\255\255\073\001\074\001\ -\255\255\000\000\255\255\255\255\255\255\080\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\060\001\ -\091\001\092\001\255\255\094\001\095\001\096\001\097\001\068\001\ -\000\001\255\255\255\255\003\001\103\001\074\001\105\001\255\255\ -\008\001\108\001\010\001\080\001\111\001\013\001\014\001\255\255\ -\115\001\017\001\255\255\019\001\020\001\021\001\255\255\092\001\ -\024\001\025\001\026\001\096\001\028\001\029\001\000\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\037\001\255\255\108\001\ -\040\001\041\001\111\001\013\001\255\255\255\255\000\000\255\255\ -\048\001\049\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\026\001\255\255\028\001\029\001\060\001\255\255\255\255\063\001\ -\255\255\255\255\255\255\067\001\068\001\255\255\070\001\041\001\ -\255\255\073\001\074\001\255\255\255\255\255\255\255\255\255\255\ -\080\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\060\001\091\001\092\001\255\255\094\001\095\001\ -\096\001\097\001\068\001\000\001\255\255\255\255\003\001\103\001\ -\074\001\105\001\255\255\008\001\108\001\010\001\080\001\111\001\ -\013\001\014\001\255\255\115\001\017\001\255\255\019\001\020\001\ -\021\001\255\255\092\001\024\001\025\001\026\001\096\001\028\001\ -\029\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\037\001\255\255\108\001\040\001\041\001\111\001\255\255\255\255\ -\255\255\000\000\255\255\048\001\049\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\060\001\ -\255\255\255\255\063\001\255\255\255\255\255\255\067\001\068\001\ -\255\255\070\001\255\255\255\255\073\001\074\001\255\255\255\255\ -\255\255\255\255\255\255\080\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\091\001\092\001\ -\255\255\094\001\095\001\096\001\097\001\255\255\255\255\255\255\ -\255\255\255\255\103\001\000\001\105\001\255\255\003\001\108\001\ -\255\255\255\255\111\001\008\001\255\255\010\001\115\001\255\255\ -\013\001\014\001\255\255\255\255\017\001\255\255\019\001\020\001\ -\021\001\255\255\255\255\024\001\025\001\026\001\255\255\028\001\ -\029\001\000\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\037\001\255\255\255\255\040\001\041\001\255\255\013\001\255\255\ -\255\255\000\000\255\255\048\001\049\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\026\001\255\255\028\001\029\001\060\001\ -\255\255\255\255\063\001\255\255\255\255\255\255\067\001\068\001\ -\255\255\070\001\041\001\255\255\073\001\074\001\255\255\255\255\ -\255\255\255\255\255\255\080\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\060\001\091\001\092\001\ -\255\255\094\001\095\001\096\001\097\001\068\001\000\001\255\255\ -\255\255\003\001\103\001\074\001\105\001\255\255\008\001\108\001\ -\010\001\080\001\111\001\013\001\014\001\255\255\115\001\017\001\ -\255\255\019\001\020\001\021\001\255\255\092\001\024\001\025\001\ -\026\001\096\001\028\001\029\001\006\001\255\255\008\001\255\255\ -\255\255\255\255\255\255\037\001\255\255\108\001\040\001\041\001\ -\111\001\255\255\255\255\255\255\000\000\255\255\048\001\049\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\060\001\255\255\255\255\063\001\255\255\255\255\ -\255\255\067\001\068\001\255\255\070\001\255\255\255\255\073\001\ -\074\001\255\255\255\255\255\255\255\255\055\001\080\001\057\001\ -\058\001\059\001\255\255\061\001\255\255\255\255\064\001\065\001\ -\255\255\091\001\092\001\255\255\094\001\095\001\096\001\097\001\ -\255\255\000\001\255\255\255\255\003\001\103\001\255\255\105\001\ -\255\255\008\001\108\001\010\001\255\255\111\001\013\001\014\001\ -\090\001\115\001\017\001\255\255\019\001\020\001\021\001\097\001\ -\255\255\024\001\025\001\026\001\255\255\028\001\029\001\255\255\ -\255\255\255\255\255\255\109\001\110\001\255\255\037\001\255\255\ -\255\255\040\001\041\001\255\255\255\255\255\255\255\255\000\000\ -\255\255\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\060\001\255\255\255\255\ -\063\001\255\255\255\255\255\255\067\001\068\001\255\255\070\001\ -\255\255\255\255\073\001\074\001\255\255\255\255\255\255\255\255\ -\255\255\080\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\091\001\092\001\255\255\094\001\ -\095\001\096\001\097\001\255\255\255\255\255\255\255\255\255\255\ -\103\001\000\001\105\001\255\255\003\001\108\001\255\255\255\255\ -\111\001\008\001\255\255\010\001\115\001\255\255\013\001\014\001\ -\255\255\255\255\017\001\255\255\019\001\020\001\021\001\255\255\ -\255\255\024\001\025\001\026\001\255\255\028\001\029\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\037\001\255\255\ -\255\255\040\001\041\001\255\255\255\255\255\255\255\255\000\000\ -\255\255\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\060\001\255\255\255\255\ -\063\001\255\255\255\255\255\255\067\001\068\001\255\255\070\001\ -\255\255\255\255\073\001\074\001\255\255\255\255\255\255\255\255\ -\255\255\080\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\091\001\092\001\255\255\094\001\ -\095\001\096\001\097\001\255\255\000\001\255\255\255\255\003\001\ -\103\001\255\255\105\001\255\255\008\001\108\001\010\001\255\255\ -\111\001\013\001\014\001\255\255\115\001\017\001\255\255\019\001\ -\020\001\021\001\255\255\255\255\024\001\025\001\026\001\255\255\ -\028\001\029\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\037\001\255\255\255\255\040\001\041\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\048\001\049\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\000\000\255\255\255\255\ -\060\001\255\255\255\255\063\001\255\255\255\255\255\255\067\001\ -\068\001\255\255\070\001\255\255\255\255\073\001\074\001\255\255\ -\255\255\255\255\255\255\255\255\080\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\091\001\ -\092\001\255\255\094\001\095\001\096\001\097\001\255\255\000\001\ -\255\255\255\255\003\001\103\001\255\255\105\001\255\255\008\001\ -\108\001\010\001\255\255\111\001\013\001\014\001\255\255\115\001\ -\017\001\255\255\019\001\020\001\021\001\255\255\255\255\024\001\ -\025\001\026\001\255\255\028\001\029\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\037\001\255\255\255\255\040\001\ -\041\001\255\255\255\255\255\255\255\255\255\255\255\255\048\001\ -\049\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\000\000\255\255\255\255\060\001\255\255\255\255\063\001\255\255\ -\255\255\255\255\067\001\068\001\255\255\070\001\255\255\255\255\ -\073\001\074\001\255\255\255\255\255\255\255\255\255\255\080\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\091\001\092\001\255\255\094\001\255\255\096\001\ -\097\001\255\255\255\255\255\255\255\255\255\255\103\001\000\001\ -\105\001\255\255\003\001\108\001\255\255\255\255\111\001\008\001\ -\255\255\010\001\115\001\255\255\013\001\014\001\255\255\255\255\ -\017\001\255\255\019\001\020\001\021\001\255\255\255\255\024\001\ -\255\255\026\001\255\255\028\001\029\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\037\001\255\255\255\255\040\001\ -\041\001\255\255\255\255\255\255\255\255\255\255\255\255\048\001\ -\049\001\255\255\255\255\000\000\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\060\001\255\255\255\255\063\001\255\255\ -\255\255\255\255\067\001\068\001\255\255\070\001\255\255\255\255\ -\073\001\074\001\255\255\255\255\255\255\255\255\255\255\080\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\091\001\092\001\255\255\094\001\095\001\096\001\ -\097\001\255\255\255\255\255\255\255\255\255\255\103\001\255\255\ -\105\001\255\255\255\255\108\001\255\255\000\001\111\001\002\001\ -\003\001\004\001\115\001\255\255\255\255\008\001\255\255\255\255\ -\255\255\255\255\013\001\255\255\255\255\255\255\017\001\018\001\ -\019\001\255\255\255\255\255\255\255\255\000\001\255\255\026\001\ -\027\001\028\001\029\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\036\001\255\255\255\255\255\255\040\001\041\001\255\255\ -\000\000\255\255\255\255\255\255\255\255\048\001\049\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\060\001\255\255\255\255\063\001\255\255\255\255\066\001\ -\067\001\068\001\255\255\070\001\255\255\255\255\073\001\074\001\ -\255\255\255\255\255\255\255\255\055\001\080\001\057\001\058\001\ -\059\001\255\255\061\001\255\255\255\255\064\001\065\001\255\255\ -\091\001\092\001\255\255\094\001\095\001\096\001\255\255\255\255\ -\000\001\100\001\002\001\003\001\004\001\255\255\081\001\255\255\ -\008\001\108\001\255\255\255\255\111\001\013\001\089\001\090\001\ -\115\001\017\001\018\001\019\001\255\255\255\255\097\001\255\255\ -\255\255\255\255\026\001\027\001\028\001\029\001\255\255\255\255\ -\008\001\255\255\109\001\110\001\036\001\255\255\255\255\255\255\ -\255\255\041\001\255\255\000\000\255\255\255\255\255\255\023\001\ -\048\001\049\001\255\255\255\255\255\255\255\255\030\001\255\255\ -\255\255\255\255\255\255\255\255\060\001\255\255\255\255\063\001\ -\255\255\255\255\066\001\067\001\068\001\255\255\070\001\255\255\ -\255\255\073\001\074\001\255\255\255\255\255\255\255\255\055\001\ -\080\001\057\001\058\001\059\001\255\255\061\001\255\255\255\255\ -\064\001\065\001\255\255\091\001\092\001\255\255\094\001\095\001\ -\096\001\097\001\255\255\000\001\255\255\002\001\003\001\004\001\ -\255\255\081\001\255\255\008\001\108\001\255\255\255\255\111\001\ -\013\001\089\001\090\001\115\001\017\001\018\001\019\001\255\255\ -\255\255\097\001\255\255\255\255\255\255\026\001\027\001\028\001\ -\029\001\255\255\106\001\255\255\255\255\109\001\110\001\036\001\ -\255\255\255\255\255\255\255\255\041\001\255\255\000\000\255\255\ -\255\255\255\255\255\255\048\001\049\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\060\001\ -\255\255\255\255\063\001\255\255\255\255\066\001\067\001\068\001\ -\255\255\070\001\255\255\255\255\255\255\074\001\255\255\255\255\ -\255\255\255\255\255\255\080\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\091\001\092\001\ -\255\255\094\001\095\001\096\001\097\001\255\255\255\255\255\255\ -\000\001\255\255\002\001\003\001\004\001\255\255\255\255\108\001\ -\008\001\255\255\111\001\255\255\255\255\013\001\115\001\255\255\ -\255\255\017\001\018\001\019\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\026\001\027\001\028\001\029\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\036\001\255\255\255\255\255\255\ -\255\255\041\001\255\255\000\000\255\255\255\255\255\255\255\255\ -\048\001\049\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\060\001\255\255\255\255\063\001\ -\255\255\255\255\066\001\067\001\068\001\255\255\070\001\255\255\ -\255\255\255\255\074\001\255\255\255\255\255\255\255\255\055\001\ -\080\001\057\001\058\001\059\001\255\255\061\001\255\255\255\255\ -\064\001\065\001\255\255\091\001\092\001\255\255\094\001\095\001\ -\096\001\097\001\074\001\000\001\255\255\002\001\003\001\004\001\ -\255\255\081\001\255\255\008\001\108\001\255\255\255\255\111\001\ -\013\001\089\001\090\001\115\001\017\001\018\001\019\001\000\000\ -\255\255\097\001\255\255\255\255\255\255\026\001\027\001\028\001\ -\029\001\255\255\255\255\255\255\255\255\109\001\110\001\036\001\ -\255\255\255\255\255\255\255\255\041\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\048\001\049\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\060\001\ -\255\255\255\255\063\001\255\255\255\255\066\001\067\001\068\001\ -\255\255\070\001\255\255\255\255\255\255\074\001\255\255\255\255\ -\255\255\000\000\055\001\080\001\057\001\058\001\059\001\255\255\ -\061\001\255\255\255\255\064\001\065\001\255\255\091\001\092\001\ -\255\255\094\001\095\001\096\001\097\001\255\255\000\001\255\255\ -\002\001\003\001\004\001\255\255\081\001\255\255\008\001\108\001\ -\255\255\255\255\111\001\013\001\089\001\090\001\115\001\017\001\ -\018\001\019\001\255\255\255\255\097\001\255\255\255\255\255\255\ -\026\001\027\001\028\001\029\001\255\255\255\255\255\255\108\001\ -\109\001\110\001\036\001\000\000\255\255\255\255\255\255\041\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\048\001\049\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\060\001\255\255\255\255\063\001\255\255\255\255\ -\066\001\067\001\068\001\255\255\070\001\255\255\255\255\255\255\ -\074\001\255\255\255\255\255\255\255\255\255\255\080\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\091\001\092\001\255\255\094\001\095\001\096\001\097\001\ -\255\255\000\000\255\255\000\001\255\255\002\001\003\001\255\255\ -\255\255\255\255\108\001\008\001\255\255\111\001\255\255\255\255\ -\013\001\115\001\255\255\255\255\017\001\018\001\019\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\026\001\027\001\028\001\ -\029\001\255\255\255\255\255\255\255\255\255\255\255\255\036\001\ -\255\255\255\255\255\255\255\255\041\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\048\001\049\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\000\000\255\255\255\255\255\255\060\001\ -\255\255\255\255\063\001\255\255\255\255\066\001\067\001\068\001\ -\255\255\070\001\255\255\255\255\006\001\074\001\008\001\000\001\ -\255\255\255\255\003\001\080\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\013\001\255\255\091\001\092\001\ -\017\001\094\001\095\001\096\001\097\001\255\255\255\255\255\255\ -\255\255\026\001\027\001\028\001\029\001\255\255\255\255\108\001\ -\255\255\255\255\111\001\255\255\255\255\255\255\115\001\255\255\ -\041\001\255\255\255\255\255\255\255\255\055\001\255\255\057\001\ -\058\001\059\001\255\255\061\001\255\255\255\255\064\001\065\001\ -\255\255\000\001\255\255\060\001\003\001\255\255\063\001\255\255\ -\255\255\066\001\067\001\068\001\255\255\255\255\013\001\255\255\ -\073\001\074\001\017\001\255\255\255\255\255\255\255\255\080\001\ -\090\001\255\255\092\001\026\001\027\001\028\001\029\001\097\001\ -\255\255\255\255\255\255\092\001\000\000\094\001\255\255\096\001\ -\097\001\255\255\041\001\109\001\110\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\108\001\255\255\255\255\111\001\255\255\ -\255\255\255\255\115\001\000\001\255\255\060\001\003\001\255\255\ -\063\001\255\255\255\255\066\001\067\001\068\001\255\255\255\255\ -\013\001\255\255\073\001\074\001\017\001\255\255\255\255\255\255\ -\255\255\080\001\255\255\255\255\255\255\026\001\027\001\028\001\ -\029\001\255\255\255\255\255\255\255\255\092\001\255\255\094\001\ -\255\255\096\001\097\001\255\255\041\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\108\001\255\255\255\255\ -\111\001\255\255\255\255\255\255\115\001\255\255\255\255\060\001\ -\255\255\000\001\063\001\255\255\003\001\066\001\067\001\068\001\ -\255\255\255\255\255\255\255\255\073\001\074\001\013\001\255\255\ -\255\255\255\255\017\001\080\001\019\001\255\255\255\255\255\255\ -\255\255\255\255\000\000\026\001\027\001\028\001\029\001\092\001\ -\255\255\094\001\255\255\096\001\097\001\255\255\255\255\255\255\ -\255\255\255\255\041\001\255\255\255\255\255\255\255\255\108\001\ -\255\255\255\255\111\001\255\255\255\255\255\255\115\001\255\255\ -\255\255\255\255\255\255\000\001\255\255\060\001\003\001\255\255\ -\063\001\255\255\255\255\255\255\067\001\068\001\255\255\255\255\ -\013\001\255\255\073\001\074\001\017\001\255\255\255\255\255\255\ -\255\255\080\001\255\255\255\255\255\255\026\001\027\001\028\001\ -\029\001\255\255\255\255\255\255\255\255\092\001\255\255\094\001\ -\255\255\096\001\097\001\255\255\041\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\108\001\255\255\255\255\ -\111\001\000\000\255\255\255\255\115\001\255\255\255\255\060\001\ -\255\255\255\255\063\001\255\255\255\255\255\255\067\001\068\001\ -\255\255\255\255\255\255\255\255\073\001\074\001\055\001\255\255\ -\057\001\058\001\059\001\080\001\061\001\255\255\063\001\064\001\ -\065\001\255\255\255\255\255\255\255\255\255\255\255\255\092\001\ -\255\255\094\001\255\255\096\001\097\001\078\001\255\255\255\255\ -\081\001\255\255\255\255\255\255\255\255\255\255\255\255\108\001\ -\089\001\090\001\111\001\255\255\000\001\255\255\115\001\003\001\ -\097\001\005\001\006\001\007\001\008\001\255\255\255\255\011\001\ -\012\001\013\001\255\255\255\255\109\001\110\001\255\255\019\001\ -\255\255\255\255\255\255\023\001\255\255\255\255\026\001\255\255\ -\028\001\029\001\030\001\031\001\032\001\033\001\034\001\035\001\ -\036\001\255\255\255\255\039\001\040\001\041\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\048\001\049\001\050\001\051\001\ -\052\001\053\001\054\001\055\001\056\001\057\001\058\001\059\001\ -\060\001\061\001\000\000\063\001\064\001\065\001\255\255\067\001\ -\068\001\069\001\070\001\071\001\072\001\255\255\074\001\075\001\ -\076\001\077\001\078\001\255\255\080\001\081\001\255\255\255\255\ -\084\001\085\001\255\255\087\001\088\001\089\001\090\001\091\001\ -\092\001\093\001\255\255\095\001\096\001\097\001\255\255\099\001\ -\255\255\101\001\102\001\255\255\104\001\255\255\106\001\107\001\ -\108\001\109\001\110\001\111\001\112\001\255\255\114\001\005\001\ -\006\001\007\001\255\255\255\255\255\255\011\001\012\001\013\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\028\001\029\001\ -\030\001\031\001\032\001\033\001\034\001\255\255\255\255\255\255\ -\255\255\039\001\255\255\041\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\050\001\255\255\052\001\053\001\ -\054\001\055\001\056\001\255\255\255\255\059\001\060\001\255\255\ -\255\255\063\001\064\001\065\001\255\255\000\000\068\001\069\001\ -\255\255\071\001\072\001\255\255\074\001\255\255\076\001\255\255\ -\078\001\255\255\080\001\255\255\255\255\255\255\084\001\085\001\ -\255\255\087\001\255\255\255\255\255\255\255\255\005\001\006\001\ -\007\001\255\255\096\001\097\001\011\001\012\001\013\001\101\001\ -\255\255\255\255\255\255\255\255\106\001\107\001\108\001\109\001\ -\110\001\111\001\255\255\255\255\114\001\028\001\029\001\030\001\ -\031\001\032\001\033\001\034\001\255\255\255\255\255\255\255\255\ -\039\001\255\255\041\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\050\001\255\255\052\001\053\001\054\001\ -\055\001\056\001\255\255\255\255\059\001\060\001\255\255\255\255\ -\063\001\064\001\065\001\255\255\255\255\068\001\069\001\255\255\ -\071\001\072\001\255\255\074\001\255\255\076\001\255\255\078\001\ -\255\255\080\001\255\255\000\000\255\255\084\001\085\001\255\255\ -\087\001\000\000\055\001\255\255\057\001\058\001\059\001\255\255\ -\061\001\255\255\097\001\064\001\065\001\255\255\101\001\255\255\ -\255\255\255\255\255\255\106\001\107\001\108\001\109\001\110\001\ -\111\001\255\255\255\255\114\001\081\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\089\001\090\001\255\255\005\001\ -\006\001\007\001\255\255\255\255\097\001\011\001\012\001\013\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\109\001\110\001\255\255\255\255\255\255\255\255\028\001\029\001\ -\030\001\031\001\032\001\033\001\034\001\255\255\255\255\255\255\ -\255\255\039\001\255\255\041\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\050\001\255\255\052\001\053\001\ -\054\001\055\001\056\001\255\255\255\255\059\001\060\001\255\255\ -\255\255\063\001\064\001\065\001\255\255\255\255\068\001\069\001\ -\255\255\071\001\072\001\255\255\074\001\000\000\076\001\255\255\ -\078\001\255\255\080\001\255\255\255\255\255\255\084\001\085\001\ -\255\255\087\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\097\001\255\255\255\255\255\255\101\001\ -\255\255\255\255\255\255\255\255\106\001\107\001\108\001\109\001\ -\110\001\111\001\255\255\255\255\114\001\000\001\255\255\255\255\ -\255\255\004\001\255\255\006\001\255\255\008\001\255\255\010\001\ -\255\255\012\001\255\255\014\001\015\001\255\255\017\001\018\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\027\001\028\001\255\255\030\001\031\001\000\000\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\050\001\ -\051\001\052\001\053\001\255\255\055\001\056\001\255\255\255\255\ -\059\001\255\255\255\255\255\255\255\255\064\001\065\001\066\001\ -\255\255\255\255\255\255\255\255\071\001\255\255\073\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\081\001\255\255\ -\255\255\084\001\255\255\255\255\255\255\255\255\089\001\000\000\ -\091\001\092\001\255\255\094\001\095\001\255\255\097\001\255\255\ -\255\255\255\255\101\001\000\001\255\255\104\001\255\255\106\001\ -\255\255\000\001\109\001\110\001\255\255\004\001\113\001\006\001\ -\013\001\008\001\255\255\010\001\255\255\012\001\255\255\014\001\ -\015\001\255\255\017\001\018\001\255\255\026\001\255\255\028\001\ -\029\001\255\255\255\255\255\255\027\001\255\255\255\255\030\001\ -\031\001\255\255\255\255\255\255\041\001\255\255\255\255\255\255\ -\255\255\000\000\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\050\001\051\001\255\255\053\001\060\001\ -\055\001\056\001\255\255\255\255\059\001\255\255\067\001\068\001\ -\255\255\064\001\065\001\066\001\255\255\074\001\255\255\255\255\ -\071\001\255\255\073\001\080\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\081\001\255\255\255\255\084\001\255\255\092\001\ -\255\255\255\255\089\001\096\001\091\001\092\001\255\255\094\001\ -\095\001\255\255\097\001\000\000\255\255\255\255\101\001\108\001\ -\255\255\104\001\111\001\106\001\255\255\000\001\109\001\110\001\ -\003\001\004\001\113\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\013\001\014\001\255\255\255\255\255\255\255\255\ -\019\001\255\255\255\255\255\255\255\255\255\255\255\255\026\001\ -\255\255\028\001\029\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\041\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\048\001\049\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\060\001\255\255\255\255\063\001\255\255\255\255\066\001\ -\067\001\068\001\255\255\070\001\255\255\000\001\255\255\074\001\ -\003\001\004\001\000\000\255\255\255\255\080\001\255\255\255\255\ -\255\255\255\255\013\001\014\001\255\255\255\255\255\255\255\255\ -\019\001\092\001\255\255\094\001\255\255\096\001\097\001\026\001\ -\255\255\028\001\029\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\108\001\255\255\255\255\111\001\255\255\041\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\048\001\049\001\255\255\ -\255\255\255\255\255\255\000\000\255\255\255\255\255\255\000\001\ -\255\255\060\001\003\001\004\001\063\001\255\255\255\255\066\001\ -\067\001\068\001\255\255\070\001\013\001\014\001\255\255\074\001\ -\255\255\255\255\019\001\255\255\255\255\080\001\255\255\255\255\ -\255\255\026\001\255\255\028\001\029\001\255\255\255\255\255\255\ -\255\255\092\001\255\255\094\001\255\255\096\001\097\001\255\255\ -\041\001\255\255\255\255\255\255\255\255\000\000\255\255\048\001\ -\049\001\108\001\255\255\255\255\111\001\255\255\255\255\255\255\ -\255\255\000\001\255\255\060\001\003\001\004\001\063\001\255\255\ -\255\255\255\255\067\001\068\001\255\255\070\001\013\001\014\001\ -\255\255\074\001\255\255\255\255\019\001\255\255\255\255\080\001\ -\255\255\255\255\255\255\026\001\255\255\028\001\029\001\255\255\ -\255\255\255\255\255\255\092\001\255\255\094\001\255\255\096\001\ -\097\001\255\255\041\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\048\001\049\001\108\001\255\255\255\255\111\001\255\255\ -\255\255\255\255\255\255\000\001\255\255\060\001\003\001\004\001\ -\063\001\000\000\255\255\255\255\067\001\068\001\255\255\070\001\ -\013\001\014\001\255\255\074\001\255\255\255\255\019\001\255\255\ -\255\255\080\001\255\255\255\255\255\255\026\001\255\255\028\001\ -\029\001\255\255\255\255\255\255\255\255\092\001\255\255\094\001\ -\255\255\096\001\097\001\255\255\041\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\048\001\049\001\108\001\255\255\255\255\ -\111\001\255\255\255\255\255\255\255\255\255\255\255\255\060\001\ -\255\255\255\255\063\001\000\000\255\255\255\255\067\001\068\001\ -\255\255\070\001\255\255\255\255\255\255\074\001\055\001\255\255\ -\057\001\058\001\059\001\080\001\061\001\255\255\255\255\064\001\ -\065\001\255\255\000\001\255\255\255\255\003\001\255\255\092\001\ -\255\255\094\001\008\001\096\001\097\001\255\255\255\255\013\001\ -\081\001\255\255\255\255\255\255\255\255\019\001\255\255\108\001\ -\089\001\090\001\111\001\255\255\026\001\255\255\028\001\029\001\ -\097\001\255\255\255\255\255\255\255\255\000\000\255\255\255\255\ -\255\255\255\255\040\001\041\001\109\001\110\001\255\255\255\255\ -\255\255\255\255\255\255\000\001\255\255\255\255\003\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\060\001\255\255\ -\013\001\063\001\255\255\255\255\066\001\067\001\068\001\255\255\ -\255\255\255\255\255\255\073\001\074\001\026\001\027\001\028\001\ -\029\001\255\255\080\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\041\001\255\255\092\001\000\000\ -\255\255\255\255\096\001\097\001\255\255\000\001\100\001\255\255\ -\003\001\255\255\255\255\255\255\255\255\255\255\108\001\060\001\ -\255\255\111\001\013\001\064\001\255\255\066\001\067\001\068\001\ -\255\255\255\255\255\255\255\255\073\001\074\001\255\255\026\001\ -\027\001\028\001\029\001\080\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\041\001\092\001\ -\255\255\094\001\255\255\096\001\097\001\255\255\255\255\100\001\ -\255\255\000\000\255\255\255\255\255\255\255\255\255\255\108\001\ -\109\001\060\001\111\001\255\255\255\255\064\001\255\255\066\001\ -\067\001\068\001\255\255\255\255\255\255\255\255\073\001\074\001\ -\255\255\000\001\255\255\255\255\003\001\080\001\255\255\255\255\ -\255\255\008\001\255\255\255\255\255\255\255\255\013\001\255\255\ -\255\255\092\001\255\255\094\001\019\001\096\001\097\001\255\255\ -\255\255\100\001\000\000\026\001\255\255\028\001\029\001\255\255\ -\255\255\108\001\109\001\255\255\111\001\255\255\255\255\255\255\ -\255\255\040\001\041\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\000\001\255\255\060\001\003\001\255\255\ -\063\001\255\255\255\255\066\001\067\001\068\001\255\255\255\255\ -\013\001\255\255\073\001\074\001\255\255\255\255\019\001\000\000\ -\255\255\080\001\255\255\255\255\255\255\026\001\027\001\028\001\ -\029\001\255\255\255\255\255\255\255\255\092\001\255\255\255\255\ -\255\255\096\001\097\001\255\255\041\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\048\001\255\255\108\001\255\255\255\255\ -\111\001\255\255\255\255\255\255\255\255\000\001\255\255\060\001\ -\003\001\255\255\063\001\255\255\255\255\255\255\067\001\068\001\ -\255\255\070\001\013\001\255\255\000\000\074\001\255\255\255\255\ -\019\001\255\255\255\255\080\001\255\255\255\255\255\255\026\001\ -\255\255\028\001\029\001\255\255\255\255\255\255\255\255\092\001\ -\255\255\094\001\255\255\096\001\097\001\040\001\041\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\048\001\049\001\108\001\ -\255\255\255\255\111\001\255\255\255\255\255\255\255\255\000\001\ -\255\255\060\001\003\001\255\255\063\001\255\255\255\255\008\001\ -\255\255\068\001\255\255\070\001\013\001\255\255\255\255\074\001\ -\255\255\255\255\019\001\255\255\255\255\080\001\255\255\255\255\ -\255\255\026\001\255\255\028\001\029\001\255\255\255\255\000\000\ -\255\255\092\001\255\255\255\255\255\255\096\001\097\001\255\255\ -\041\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\108\001\255\255\255\255\111\001\255\255\255\255\255\255\ -\255\255\000\001\255\255\060\001\003\001\255\255\063\001\255\255\ -\255\255\255\255\067\001\068\001\255\255\255\255\013\001\255\255\ -\255\255\074\001\255\255\255\255\019\001\255\255\255\255\080\001\ -\255\255\255\255\255\255\026\001\000\000\028\001\029\001\255\255\ -\255\255\255\255\255\255\092\001\255\255\000\000\255\255\096\001\ -\097\001\255\255\041\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\000\001\108\001\255\255\003\001\111\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\060\001\255\255\013\001\ -\063\001\255\255\255\255\255\255\067\001\068\001\255\255\255\255\ -\255\255\255\255\255\255\074\001\026\001\255\255\028\001\029\001\ -\255\255\080\001\255\255\255\255\255\255\255\255\255\255\000\000\ -\255\255\255\255\040\001\041\001\255\255\092\001\255\255\255\255\ -\255\255\096\001\097\001\255\255\255\255\255\255\255\255\000\001\ -\255\255\255\255\003\001\255\255\255\255\108\001\060\001\255\255\ -\111\001\063\001\255\255\255\255\013\001\067\001\068\001\255\255\ -\255\255\255\255\019\001\255\255\074\001\255\255\255\255\255\255\ -\255\255\026\001\080\001\028\001\029\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\000\000\255\255\092\001\255\255\ -\041\001\255\255\096\001\097\001\255\255\000\000\255\255\255\255\ -\255\255\255\255\255\255\255\255\000\001\255\255\108\001\003\001\ -\255\255\111\001\255\255\060\001\255\255\255\255\063\001\255\255\ -\255\255\013\001\067\001\068\001\255\255\255\255\255\255\019\001\ -\255\255\074\001\255\255\255\255\255\255\255\255\026\001\080\001\ -\028\001\029\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\092\001\255\255\041\001\255\255\096\001\ -\097\001\255\255\000\000\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\108\001\255\255\255\255\111\001\255\255\ -\060\001\255\255\255\255\063\001\255\255\255\255\255\255\067\001\ -\068\001\255\255\255\255\255\255\255\255\255\255\074\001\000\001\ -\255\255\255\255\003\001\255\255\080\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\013\001\255\255\255\255\255\255\ -\092\001\255\255\019\001\255\255\096\001\097\001\255\255\000\000\ -\255\255\026\001\255\255\028\001\029\001\255\255\255\255\255\255\ -\108\001\255\255\255\255\111\001\255\255\255\255\255\255\255\255\ -\041\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\000\001\255\255\255\255\003\001\ -\255\255\255\255\255\255\060\001\255\255\000\001\063\001\255\255\ -\255\255\013\001\067\001\068\001\255\255\008\001\255\255\019\001\ -\000\000\074\001\013\001\255\255\255\255\255\255\026\001\080\001\ -\028\001\029\001\000\000\255\255\255\255\255\255\255\255\026\001\ -\255\255\028\001\029\001\092\001\255\255\041\001\255\255\096\001\ -\097\001\255\255\255\255\255\255\255\255\255\255\041\001\255\255\ -\255\255\255\255\255\255\108\001\255\255\255\255\111\001\000\001\ -\060\001\255\255\003\001\063\001\255\255\255\255\255\255\067\001\ -\068\001\060\001\255\255\255\255\013\001\255\255\074\001\066\001\ -\067\001\068\001\019\001\255\255\080\001\255\255\255\255\074\001\ -\255\255\026\001\255\255\028\001\029\001\080\001\255\255\255\255\ -\092\001\255\255\255\255\000\000\096\001\097\001\255\255\255\255\ -\041\001\092\001\255\255\255\255\255\255\096\001\255\255\255\255\ -\108\001\255\255\255\255\111\001\000\001\255\255\255\255\255\255\ -\255\255\108\001\255\255\060\001\111\001\000\001\063\001\255\255\ -\003\001\013\001\067\001\068\001\255\255\255\255\255\255\255\255\ -\255\255\074\001\013\001\255\255\255\255\255\255\026\001\080\001\ -\028\001\029\001\255\255\255\255\000\000\255\255\255\255\026\001\ -\255\255\028\001\029\001\092\001\255\255\041\001\000\000\096\001\ -\097\001\255\255\255\255\255\255\255\255\040\001\041\001\255\255\ -\255\255\255\255\255\255\108\001\255\255\255\255\111\001\255\255\ -\060\001\255\255\000\001\063\001\255\255\003\001\066\001\067\001\ -\068\001\060\001\255\255\255\255\063\001\255\255\074\001\013\001\ -\255\255\068\001\255\255\255\255\080\001\255\255\255\255\074\001\ -\255\255\255\255\255\255\255\255\026\001\080\001\028\001\029\001\ -\092\001\255\255\255\255\255\255\096\001\097\001\255\255\255\255\ -\255\255\092\001\255\255\041\001\000\000\096\001\097\001\255\255\ -\108\001\255\255\255\255\111\001\255\255\255\255\255\255\000\001\ -\255\255\108\001\003\001\255\255\111\001\255\255\060\001\255\255\ -\255\255\063\001\255\255\255\255\013\001\067\001\068\001\255\255\ -\255\255\255\255\255\255\255\255\074\001\255\255\255\255\255\255\ -\255\255\026\001\080\001\028\001\029\001\255\255\255\255\255\255\ -\000\000\255\255\255\255\255\255\255\255\255\255\092\001\255\255\ -\041\001\000\000\096\001\097\001\255\255\255\255\255\255\255\255\ -\000\001\255\255\255\255\255\255\255\255\255\255\108\001\255\255\ -\008\001\111\001\000\001\060\001\255\255\013\001\063\001\255\255\ -\255\255\255\255\067\001\068\001\255\255\255\255\255\255\013\001\ -\255\255\074\001\026\001\255\255\028\001\029\001\255\255\080\001\ -\255\255\255\255\255\255\255\255\026\001\255\255\028\001\029\001\ -\255\255\041\001\000\000\092\001\255\255\255\255\255\255\096\001\ -\097\001\255\255\255\255\041\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\108\001\060\001\255\255\111\001\063\001\ -\255\255\255\255\255\255\067\001\068\001\255\255\060\001\255\255\ -\255\255\063\001\074\001\000\001\255\255\067\001\068\001\255\255\ -\080\001\255\255\255\255\255\255\074\001\255\255\000\000\255\255\ -\013\001\255\255\080\001\255\255\092\001\255\255\255\255\255\255\ -\096\001\097\001\255\255\255\255\255\255\026\001\092\001\028\001\ -\029\001\255\255\096\001\097\001\108\001\255\255\255\255\111\001\ -\255\255\255\255\255\255\255\255\041\001\255\255\108\001\255\255\ -\255\255\111\001\255\255\255\255\000\001\255\255\255\255\003\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\000\001\060\001\ -\255\255\013\001\063\001\255\255\255\255\255\255\067\001\068\001\ -\255\255\255\255\255\255\013\001\255\255\074\001\026\001\255\255\ -\028\001\029\001\255\255\080\001\255\255\255\255\255\255\255\255\ -\026\001\255\255\028\001\029\001\255\255\041\001\255\255\092\001\ -\255\255\255\255\255\255\096\001\097\001\255\255\255\255\041\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\108\001\ -\060\001\255\255\111\001\063\001\255\255\255\255\255\255\255\255\ -\068\001\255\255\060\001\255\255\000\001\063\001\074\001\255\255\ -\255\255\067\001\068\001\255\255\080\001\255\255\255\255\255\255\ -\074\001\013\001\255\255\255\255\255\255\255\255\080\001\255\255\ -\092\001\255\255\255\255\255\255\096\001\097\001\026\001\255\255\ -\028\001\029\001\092\001\255\255\255\255\255\255\096\001\097\001\ -\108\001\255\255\255\255\111\001\255\255\041\001\255\255\255\255\ -\000\001\255\255\108\001\255\255\255\255\111\001\255\255\255\255\ -\255\255\000\001\255\255\255\255\255\255\013\001\255\255\255\255\ -\060\001\255\255\255\255\063\001\255\255\255\255\013\001\067\001\ -\068\001\255\255\026\001\255\255\028\001\029\001\074\001\255\255\ -\255\255\255\255\255\255\026\001\080\001\028\001\029\001\255\255\ -\255\255\041\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\092\001\255\255\041\001\255\255\096\001\097\001\255\255\255\255\ -\255\255\255\255\000\001\255\255\060\001\255\255\255\255\063\001\ -\108\001\255\255\255\255\111\001\068\001\060\001\255\255\013\001\ -\063\001\255\255\074\001\255\255\255\255\068\001\255\255\255\255\ -\080\001\255\255\255\255\074\001\026\001\255\255\028\001\029\001\ -\255\255\080\001\255\255\255\255\092\001\255\255\255\255\255\255\ -\096\001\097\001\255\255\041\001\255\255\092\001\000\001\255\255\ -\255\255\096\001\097\001\255\255\108\001\255\255\255\255\111\001\ -\255\255\255\255\255\255\013\001\255\255\108\001\060\001\255\255\ -\111\001\063\001\255\255\255\255\255\255\255\255\068\001\255\255\ -\026\001\255\255\028\001\029\001\074\001\255\255\255\255\255\255\ -\255\255\255\255\080\001\255\255\255\255\255\255\255\255\041\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\092\001\255\255\ -\255\255\255\255\096\001\097\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\060\001\255\255\255\255\063\001\108\001\255\255\ -\255\255\111\001\068\001\255\255\255\255\255\255\255\255\255\255\ -\074\001\255\255\255\255\255\255\255\255\255\255\080\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\092\001\000\001\255\255\255\255\096\001\097\001\ -\005\001\006\001\007\001\008\001\255\255\255\255\011\001\012\001\ -\013\001\014\001\108\001\255\255\255\255\111\001\019\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\026\001\255\255\028\001\ -\029\001\030\001\031\001\032\001\033\001\034\001\035\001\255\255\ -\255\255\255\255\039\001\255\255\041\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\048\001\049\001\050\001\051\001\052\001\ -\053\001\054\001\055\001\056\001\255\255\255\255\059\001\060\001\ -\255\255\255\255\063\001\064\001\065\001\066\001\255\255\068\001\ -\069\001\070\001\071\001\072\001\255\255\074\001\255\255\076\001\ -\077\001\078\001\255\255\080\001\081\001\255\255\255\255\084\001\ -\085\001\255\255\087\001\255\255\089\001\090\001\255\255\092\001\ -\093\001\255\255\255\255\096\001\097\001\255\255\099\001\255\255\ -\101\001\102\001\255\255\104\001\255\255\106\001\107\001\108\001\ -\109\001\110\001\111\001\112\001\000\001\114\001\255\255\255\255\ -\255\255\005\001\006\001\007\001\008\001\255\255\255\255\011\001\ -\012\001\255\255\255\255\255\255\255\255\255\255\255\255\019\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\026\001\255\255\ -\028\001\255\255\030\001\031\001\032\001\033\001\034\001\035\001\ -\255\255\255\255\255\255\039\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\048\001\049\001\050\001\051\001\ -\052\001\053\001\054\001\055\001\056\001\255\255\255\255\059\001\ -\060\001\255\255\255\255\063\001\064\001\065\001\255\255\255\255\ -\068\001\069\001\070\001\071\001\072\001\255\255\074\001\255\255\ -\076\001\077\001\078\001\255\255\255\255\081\001\255\255\255\255\ -\084\001\085\001\255\255\087\001\255\255\089\001\090\001\255\255\ -\255\255\093\001\255\255\255\255\255\255\097\001\255\255\099\001\ -\255\255\101\001\102\001\255\255\104\001\255\255\106\001\107\001\ -\255\255\109\001\110\001\111\001\112\001\255\255\114\001\000\001\ -\001\001\002\001\255\255\255\255\005\001\006\001\007\001\255\255\ -\009\001\255\255\011\001\012\001\255\255\255\255\015\001\016\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\027\001\255\255\255\255\030\001\031\001\032\001\ -\033\001\034\001\255\255\036\001\255\255\255\255\039\001\255\255\ -\255\255\042\001\043\001\044\001\045\001\046\001\047\001\255\255\ -\255\255\050\001\255\255\052\001\053\001\054\001\055\001\056\001\ -\255\255\255\255\059\001\255\255\061\001\255\255\063\001\064\001\ -\065\001\255\255\255\255\255\255\069\001\255\255\071\001\072\001\ -\255\255\074\001\255\255\076\001\255\255\078\001\255\255\255\255\ -\255\255\082\001\083\001\084\001\085\001\086\001\087\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\094\001\255\255\255\255\ -\255\255\098\001\255\255\100\001\101\001\255\255\255\255\255\255\ -\255\255\106\001\107\001\255\255\109\001\110\001\000\001\001\001\ -\002\001\114\001\255\255\005\001\006\001\007\001\255\255\009\001\ -\255\255\011\001\012\001\255\255\255\255\015\001\016\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\027\001\255\255\255\255\030\001\031\001\032\001\033\001\ -\034\001\255\255\036\001\255\255\255\255\039\001\255\255\255\255\ -\042\001\043\001\044\001\045\001\046\001\047\001\255\255\255\255\ -\050\001\255\255\052\001\053\001\054\001\055\001\056\001\255\255\ -\255\255\059\001\255\255\061\001\255\255\063\001\064\001\065\001\ -\255\255\255\255\255\255\069\001\255\255\071\001\072\001\255\255\ -\074\001\255\255\076\001\255\255\078\001\255\255\255\255\255\255\ -\082\001\083\001\084\001\085\001\086\001\087\001\255\255\255\255\ -\255\255\255\255\255\255\055\001\094\001\057\001\058\001\059\001\ -\098\001\061\001\100\001\101\001\064\001\065\001\255\255\255\255\ -\106\001\107\001\255\255\109\001\110\001\000\001\255\255\255\255\ -\114\001\255\255\005\001\006\001\007\001\081\001\255\255\255\255\ -\011\001\012\001\013\001\255\255\255\255\089\001\090\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\097\001\255\255\026\001\ -\255\255\028\001\029\001\030\001\031\001\032\001\033\001\034\001\ -\255\255\109\001\110\001\255\255\039\001\255\255\041\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\050\001\ -\255\255\052\001\053\001\054\001\055\001\056\001\255\255\255\255\ -\059\001\060\001\255\255\255\255\063\001\064\001\065\001\255\255\ -\255\255\068\001\069\001\255\255\071\001\072\001\255\255\074\001\ -\255\255\076\001\255\255\078\001\255\255\080\001\255\255\255\255\ -\255\255\084\001\085\001\000\001\087\001\255\255\255\255\255\255\ -\005\001\006\001\007\001\255\255\255\255\096\001\011\001\012\001\ -\255\255\255\255\101\001\255\255\255\255\255\255\255\255\106\001\ -\107\001\108\001\109\001\110\001\111\001\255\255\255\255\114\001\ -\255\255\030\001\031\001\032\001\033\001\034\001\255\255\255\255\ -\255\255\255\255\039\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\050\001\255\255\052\001\ -\053\001\054\001\055\001\056\001\255\255\255\255\059\001\255\255\ -\255\255\255\255\063\001\064\001\065\001\255\255\255\255\255\255\ -\069\001\255\255\071\001\072\001\255\255\255\255\255\255\076\001\ -\255\255\078\001\255\255\255\255\255\255\255\255\255\255\084\001\ -\085\001\000\001\087\001\255\255\255\255\255\255\005\001\006\001\ -\007\001\094\001\255\255\255\255\011\001\012\001\255\255\255\255\ -\101\001\255\255\255\255\255\255\255\255\106\001\107\001\255\255\ -\109\001\110\001\255\255\255\255\255\255\114\001\255\255\030\001\ -\031\001\032\001\033\001\034\001\255\255\255\255\255\255\255\255\ -\039\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\050\001\255\255\052\001\053\001\054\001\ -\055\001\056\001\255\255\255\255\059\001\255\255\255\255\255\255\ -\063\001\064\001\065\001\255\255\255\255\255\255\069\001\255\255\ -\071\001\072\001\255\255\255\255\255\255\076\001\255\255\078\001\ -\255\255\255\255\255\255\255\255\255\255\084\001\085\001\000\001\ -\087\001\255\255\255\255\255\255\005\001\006\001\007\001\094\001\ -\255\255\255\255\011\001\012\001\255\255\255\255\101\001\255\255\ -\255\255\255\255\255\255\106\001\107\001\255\255\109\001\110\001\ -\255\255\255\255\255\255\114\001\255\255\030\001\031\001\032\001\ -\033\001\034\001\255\255\255\255\255\255\255\255\039\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\050\001\255\255\052\001\053\001\054\001\055\001\056\001\ -\255\255\255\255\059\001\255\255\255\255\255\255\063\001\064\001\ -\065\001\255\255\255\255\255\255\069\001\255\255\071\001\072\001\ -\255\255\255\255\255\255\076\001\255\255\078\001\255\255\255\255\ -\255\255\255\255\255\255\084\001\085\001\000\001\087\001\255\255\ -\255\255\255\255\005\001\006\001\007\001\094\001\255\255\255\255\ -\011\001\012\001\255\255\255\255\101\001\255\255\255\255\255\255\ -\255\255\106\001\107\001\255\255\109\001\110\001\255\255\255\255\ -\255\255\114\001\255\255\030\001\031\001\032\001\033\001\034\001\ -\255\255\255\255\255\255\255\255\039\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\050\001\ -\255\255\052\001\053\001\054\001\055\001\056\001\255\255\255\255\ -\059\001\255\255\255\255\255\255\063\001\064\001\065\001\255\255\ -\255\255\255\255\069\001\255\255\071\001\072\001\255\255\255\255\ -\255\255\076\001\255\255\078\001\255\255\255\255\255\255\255\255\ -\255\255\084\001\085\001\255\255\087\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\094\001\003\001\004\001\005\001\255\255\ -\255\255\255\255\101\001\255\255\011\001\255\255\013\001\106\001\ -\107\001\255\255\109\001\110\001\019\001\020\001\021\001\114\001\ -\255\255\024\001\025\001\026\001\255\255\028\001\029\001\030\001\ -\255\255\032\001\033\001\034\001\035\001\255\255\255\255\255\255\ -\039\001\040\001\041\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\048\001\049\001\255\255\255\255\052\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\063\001\064\001\255\255\255\255\255\255\000\001\069\001\070\001\ -\255\255\004\001\255\255\074\001\075\001\076\001\077\001\078\001\ -\079\001\080\001\255\255\082\001\255\255\255\255\017\001\255\255\ -\019\001\088\001\255\255\022\001\255\255\255\255\093\001\026\001\ -\027\001\255\255\255\255\255\255\099\001\255\255\255\255\102\001\ -\103\001\036\001\105\001\106\001\107\001\108\001\109\001\255\255\ -\111\001\112\001\113\001\114\001\115\001\048\001\049\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\060\001\255\255\255\255\255\255\064\001\255\255\066\001\ -\067\001\068\001\255\255\070\001\255\255\255\255\073\001\255\255\ -\255\255\255\255\000\001\001\001\002\001\255\255\255\255\255\255\ -\006\001\007\001\255\255\009\001\255\255\255\255\012\001\090\001\ -\091\001\015\001\016\001\255\255\095\001\255\255\097\001\255\255\ -\255\255\100\001\255\255\255\255\255\255\027\001\028\001\255\255\ -\030\001\031\001\109\001\255\255\111\001\255\255\036\001\255\255\ -\255\255\255\255\255\255\255\255\042\001\043\001\044\001\045\001\ -\046\001\047\001\255\255\255\255\050\001\255\255\052\001\053\001\ -\255\255\055\001\056\001\255\255\255\255\059\001\255\255\061\001\ -\255\255\255\255\064\001\065\001\255\255\255\255\255\255\255\255\ -\255\255\071\001\072\001\255\255\074\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\082\001\083\001\084\001\085\001\ -\086\001\087\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\094\001\255\255\255\255\097\001\098\001\255\255\100\001\101\001\ -\255\255\255\255\255\255\255\255\106\001\255\255\108\001\109\001\ -\110\001\000\001\001\001\002\001\255\255\255\255\255\255\006\001\ -\007\001\255\255\009\001\255\255\255\255\012\001\255\255\255\255\ -\015\001\016\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\027\001\028\001\255\255\030\001\ -\031\001\255\255\255\255\255\255\255\255\036\001\255\255\255\255\ -\255\255\255\255\255\255\042\001\043\001\044\001\045\001\046\001\ -\047\001\255\255\255\255\050\001\255\255\052\001\053\001\255\255\ -\055\001\056\001\255\255\255\255\059\001\255\255\061\001\255\255\ -\255\255\064\001\065\001\255\255\255\255\255\255\255\255\255\255\ -\071\001\072\001\255\255\074\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\082\001\083\001\084\001\085\001\086\001\ -\087\001\255\255\255\255\255\255\255\255\255\255\255\255\094\001\ -\255\255\255\255\097\001\098\001\255\255\100\001\101\001\255\255\ -\255\255\255\255\255\255\106\001\255\255\108\001\109\001\110\001\ -\000\001\001\001\002\001\255\255\255\255\255\255\006\001\007\001\ -\255\255\009\001\255\255\255\255\012\001\255\255\255\255\015\001\ -\016\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\027\001\028\001\255\255\030\001\031\001\ -\255\255\255\255\255\255\255\255\036\001\255\255\255\255\255\255\ -\255\255\255\255\042\001\043\001\044\001\045\001\046\001\047\001\ -\255\255\255\255\050\001\255\255\052\001\053\001\255\255\055\001\ -\056\001\255\255\255\255\059\001\255\255\061\001\255\255\255\255\ -\064\001\065\001\255\255\255\255\255\255\255\255\255\255\071\001\ -\072\001\255\255\074\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\082\001\083\001\084\001\085\001\086\001\087\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\094\001\255\255\ -\255\255\097\001\098\001\255\255\100\001\101\001\255\255\255\255\ -\255\255\255\255\106\001\255\255\108\001\109\001\110\001\000\001\ -\001\001\002\001\255\255\255\255\255\255\006\001\007\001\255\255\ -\009\001\255\255\255\255\012\001\255\255\255\255\015\001\016\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\027\001\028\001\255\255\030\001\031\001\255\255\ -\255\255\255\255\255\255\036\001\255\255\255\255\255\255\255\255\ -\255\255\042\001\043\001\044\001\045\001\046\001\047\001\255\255\ -\255\255\050\001\255\255\052\001\053\001\255\255\055\001\056\001\ -\255\255\255\255\059\001\255\255\061\001\255\255\255\255\064\001\ -\065\001\255\255\255\255\255\255\255\255\255\255\071\001\072\001\ -\255\255\074\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\082\001\083\001\084\001\085\001\086\001\087\001\255\255\ -\255\255\000\001\255\255\255\255\255\255\094\001\255\255\006\001\ -\097\001\098\001\255\255\100\001\101\001\012\001\255\255\255\255\ -\015\001\106\001\255\255\255\255\109\001\110\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\028\001\255\255\030\001\ -\031\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\050\001\255\255\052\001\053\001\255\255\ -\055\001\056\001\255\255\255\255\059\001\255\255\000\001\255\255\ -\255\255\064\001\065\001\255\255\006\001\255\255\255\255\255\255\ -\071\001\255\255\012\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\084\001\255\255\255\255\ -\255\255\255\255\028\001\255\255\030\001\031\001\255\255\094\001\ -\255\255\255\255\097\001\255\255\255\255\255\255\101\001\255\255\ -\255\255\255\255\255\255\106\001\255\255\255\255\109\001\110\001\ -\050\001\255\255\052\001\053\001\255\255\055\001\056\001\255\255\ -\255\255\059\001\255\255\000\001\255\255\255\255\064\001\065\001\ -\255\255\006\001\255\255\255\255\255\255\071\001\255\255\012\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\084\001\255\255\255\255\255\255\255\255\028\001\ -\255\255\030\001\031\001\255\255\255\255\255\255\255\255\097\001\ -\255\255\255\255\255\255\101\001\255\255\255\255\255\255\255\255\ -\106\001\255\255\255\255\109\001\110\001\050\001\255\255\052\001\ -\053\001\255\255\055\001\056\001\255\255\255\255\059\001\255\255\ -\000\001\255\255\255\255\064\001\065\001\255\255\006\001\255\255\ -\255\255\255\255\071\001\255\255\012\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\084\001\ -\255\255\255\255\255\255\255\255\028\001\255\255\030\001\031\001\ -\255\255\255\255\255\255\255\255\097\001\255\255\255\255\255\255\ -\101\001\255\255\255\255\255\255\255\255\106\001\255\255\255\255\ -\109\001\110\001\050\001\255\255\052\001\053\001\255\255\055\001\ -\056\001\255\255\255\255\059\001\255\255\000\001\255\255\255\255\ -\064\001\065\001\255\255\006\001\255\255\255\255\255\255\071\001\ -\255\255\012\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\084\001\255\255\255\255\255\255\ -\255\255\028\001\255\255\030\001\031\001\255\255\255\255\255\255\ -\255\255\097\001\255\255\255\255\255\255\101\001\255\255\255\255\ -\255\255\255\255\106\001\255\255\255\255\109\001\110\001\050\001\ -\255\255\052\001\053\001\255\255\055\001\056\001\255\255\255\255\ -\059\001\255\255\000\001\255\255\255\255\064\001\065\001\255\255\ -\006\001\255\255\255\255\255\255\071\001\255\255\012\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\084\001\255\255\255\255\255\255\255\255\028\001\255\255\ -\030\001\031\001\255\255\255\255\255\255\255\255\097\001\255\255\ -\255\255\255\255\101\001\255\255\255\255\255\255\255\255\106\001\ -\255\255\255\255\109\001\110\001\050\001\255\255\052\001\053\001\ -\255\255\055\001\056\001\255\255\255\255\059\001\255\255\000\001\ -\255\255\255\255\064\001\065\001\255\255\006\001\255\255\255\255\ -\255\255\071\001\255\255\012\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\084\001\255\255\ -\255\255\255\255\255\255\028\001\255\255\030\001\031\001\255\255\ -\255\255\255\255\255\255\097\001\255\255\255\255\255\255\101\001\ -\255\255\255\255\255\255\255\255\106\001\255\255\255\255\109\001\ -\110\001\050\001\255\255\052\001\053\001\255\255\055\001\056\001\ -\255\255\255\255\059\001\255\255\255\255\255\255\255\255\064\001\ -\065\001\005\001\006\001\007\001\255\255\255\255\071\001\011\001\ -\012\001\013\001\014\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\084\001\255\255\255\255\255\255\255\255\ -\028\001\029\001\030\001\031\001\032\001\033\001\034\001\255\255\ -\097\001\255\255\255\255\039\001\101\001\041\001\255\255\255\255\ -\255\255\106\001\255\255\255\255\109\001\110\001\050\001\255\255\ -\052\001\053\001\054\001\055\001\056\001\255\255\255\255\059\001\ -\060\001\255\255\255\255\063\001\064\001\065\001\255\255\255\255\ -\068\001\069\001\255\255\071\001\072\001\255\255\074\001\255\255\ -\076\001\255\255\078\001\255\255\080\001\255\255\255\255\255\255\ -\084\001\085\001\255\255\087\001\255\255\089\001\255\255\255\255\ -\005\001\006\001\007\001\255\255\096\001\255\255\011\001\012\001\ -\013\001\101\001\255\255\255\255\255\255\255\255\106\001\107\001\ -\108\001\109\001\110\001\111\001\255\255\255\255\114\001\028\001\ -\029\001\030\001\031\001\032\001\033\001\034\001\255\255\255\255\ -\255\255\255\255\039\001\255\255\041\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\050\001\255\255\052\001\ -\053\001\054\001\055\001\056\001\255\255\255\255\059\001\060\001\ -\255\255\255\255\063\001\064\001\065\001\255\255\255\255\068\001\ -\069\001\255\255\071\001\072\001\255\255\074\001\255\255\076\001\ -\255\255\078\001\255\255\080\001\255\255\255\255\255\255\084\001\ -\085\001\255\255\087\001\255\255\255\255\255\255\005\001\006\001\ -\007\001\255\255\255\255\096\001\011\001\012\001\255\255\255\255\ -\101\001\255\255\255\255\255\255\255\255\106\001\107\001\108\001\ -\109\001\110\001\111\001\255\255\255\255\114\001\255\255\030\001\ -\031\001\032\001\033\001\034\001\255\255\255\255\255\255\255\255\ -\039\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\050\001\255\255\052\001\053\001\054\001\ -\055\001\056\001\255\255\255\255\059\001\255\255\255\255\255\255\ -\063\001\064\001\065\001\255\255\255\255\255\255\069\001\255\255\ -\071\001\072\001\255\255\255\255\255\255\076\001\255\255\078\001\ -\255\255\255\255\255\255\255\255\255\255\084\001\085\001\255\255\ -\087\001\255\255\255\255\255\255\255\255\092\001\005\001\006\001\ -\007\001\255\255\255\255\010\001\011\001\012\001\101\001\255\255\ -\255\255\255\255\255\255\106\001\107\001\255\255\109\001\110\001\ -\255\255\255\255\255\255\114\001\255\255\255\255\255\255\030\001\ -\031\001\032\001\033\001\034\001\255\255\255\255\255\255\255\255\ -\039\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\050\001\255\255\052\001\053\001\054\001\ -\055\001\056\001\255\255\255\255\059\001\255\255\255\255\255\255\ -\063\001\064\001\065\001\255\255\255\255\255\255\069\001\255\255\ -\071\001\072\001\255\255\255\255\255\255\076\001\255\255\078\001\ -\255\255\255\255\255\255\255\255\255\255\084\001\085\001\255\255\ -\087\001\255\255\255\255\005\001\006\001\007\001\255\255\255\255\ -\255\255\011\001\012\001\255\255\255\255\255\255\101\001\255\255\ -\255\255\255\255\255\255\106\001\107\001\255\255\109\001\110\001\ -\026\001\255\255\255\255\114\001\030\001\031\001\032\001\033\001\ -\034\001\255\255\255\255\255\255\255\255\039\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\050\001\255\255\052\001\053\001\054\001\055\001\056\001\255\255\ -\255\255\059\001\255\255\255\255\255\255\063\001\064\001\065\001\ -\255\255\255\255\255\255\069\001\255\255\071\001\072\001\255\255\ -\255\255\255\255\076\001\255\255\078\001\255\255\255\255\255\255\ -\255\255\255\255\084\001\085\001\255\255\087\001\255\255\255\255\ -\005\001\006\001\007\001\255\255\255\255\255\255\011\001\012\001\ -\255\255\255\255\255\255\101\001\255\255\255\255\255\255\255\255\ -\106\001\107\001\255\255\109\001\110\001\255\255\255\255\255\255\ -\114\001\030\001\031\001\032\001\033\001\034\001\255\255\255\255\ -\255\255\255\255\039\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\050\001\255\255\052\001\ -\053\001\054\001\055\001\056\001\255\255\255\255\059\001\255\255\ -\255\255\255\255\063\001\064\001\065\001\255\255\255\255\255\255\ -\069\001\255\255\071\001\072\001\255\255\255\255\255\255\076\001\ -\255\255\078\001\255\255\255\255\255\255\255\255\083\001\084\001\ -\085\001\255\255\087\001\255\255\255\255\005\001\006\001\007\001\ -\255\255\255\255\255\255\011\001\012\001\255\255\255\255\255\255\ -\101\001\255\255\255\255\255\255\255\255\106\001\107\001\255\255\ -\109\001\110\001\255\255\255\255\255\255\114\001\030\001\031\001\ -\032\001\033\001\034\001\255\255\255\255\255\255\255\255\039\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\050\001\255\255\052\001\053\001\054\001\055\001\ -\056\001\255\255\255\255\059\001\255\255\255\255\255\255\063\001\ -\064\001\065\001\255\255\255\255\255\255\069\001\255\255\071\001\ -\072\001\255\255\255\255\255\255\076\001\255\255\078\001\255\255\ -\255\255\255\255\255\255\255\255\084\001\085\001\255\255\087\001\ -\255\255\255\255\255\255\255\255\092\001\005\001\006\001\007\001\ -\255\255\255\255\010\001\011\001\012\001\101\001\255\255\255\255\ -\255\255\255\255\106\001\107\001\255\255\109\001\110\001\255\255\ -\255\255\255\255\114\001\255\255\255\255\255\255\030\001\031\001\ -\032\001\033\001\034\001\255\255\255\255\255\255\255\255\039\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\050\001\255\255\052\001\053\001\054\001\055\001\ -\056\001\255\255\255\255\059\001\255\255\255\255\255\255\063\001\ -\064\001\065\001\255\255\255\255\255\255\069\001\255\255\071\001\ -\072\001\255\255\255\255\255\255\076\001\255\255\078\001\255\255\ -\255\255\255\255\255\255\255\255\084\001\085\001\255\255\087\001\ -\255\255\255\255\255\255\005\001\006\001\007\001\255\255\255\255\ -\255\255\011\001\012\001\255\255\255\255\101\001\255\255\255\255\ -\255\255\255\255\106\001\107\001\022\001\109\001\110\001\255\255\ -\255\255\255\255\114\001\255\255\030\001\031\001\032\001\033\001\ -\034\001\255\255\255\255\255\255\255\255\039\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\050\001\255\255\052\001\053\001\054\001\055\001\056\001\255\255\ -\255\255\059\001\255\255\255\255\255\255\063\001\064\001\065\001\ -\255\255\255\255\255\255\069\001\255\255\071\001\072\001\255\255\ -\255\255\255\255\076\001\255\255\078\001\255\255\255\255\255\255\ -\255\255\255\255\084\001\085\001\255\255\087\001\255\255\255\255\ -\005\001\006\001\007\001\255\255\255\255\255\255\011\001\012\001\ -\255\255\255\255\255\255\101\001\255\255\255\255\255\255\255\255\ -\106\001\107\001\255\255\109\001\110\001\026\001\255\255\255\255\ -\114\001\030\001\031\001\032\001\033\001\034\001\255\255\255\255\ -\255\255\255\255\039\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\050\001\255\255\052\001\ -\053\001\054\001\055\001\056\001\255\255\255\255\059\001\255\255\ -\255\255\255\255\063\001\064\001\065\001\255\255\255\255\255\255\ -\069\001\255\255\071\001\072\001\255\255\255\255\255\255\076\001\ -\255\255\078\001\255\255\255\255\255\255\255\255\255\255\084\001\ -\085\001\255\255\087\001\255\255\255\255\005\001\006\001\007\001\ -\255\255\255\255\255\255\011\001\012\001\255\255\255\255\255\255\ -\101\001\255\255\255\255\255\255\255\255\106\001\107\001\255\255\ -\109\001\110\001\255\255\255\255\255\255\114\001\030\001\031\001\ -\032\001\033\001\034\001\255\255\255\255\255\255\255\255\039\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\050\001\255\255\052\001\053\001\054\001\055\001\ -\056\001\255\255\255\255\059\001\255\255\255\255\255\255\063\001\ -\064\001\065\001\255\255\255\255\255\255\069\001\255\255\071\001\ -\072\001\255\255\255\255\255\255\076\001\255\255\078\001\255\255\ -\255\255\255\255\255\255\255\255\084\001\085\001\255\255\087\001\ -\255\255\255\255\005\001\006\001\007\001\255\255\255\255\255\255\ -\011\001\012\001\255\255\255\255\255\255\101\001\255\255\255\255\ -\255\255\255\255\106\001\107\001\255\255\109\001\110\001\255\255\ -\255\255\255\255\114\001\030\001\031\001\032\001\033\001\034\001\ -\255\255\255\255\255\255\255\255\039\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\050\001\ -\255\255\052\001\053\001\054\001\055\001\056\001\255\255\255\255\ -\059\001\255\255\255\255\255\255\063\001\064\001\065\001\255\255\ -\255\255\255\255\069\001\255\255\071\001\072\001\255\255\255\255\ -\255\255\076\001\255\255\078\001\255\255\255\255\255\255\255\255\ -\255\255\084\001\085\001\255\255\087\001\255\255\255\255\005\001\ -\006\001\007\001\255\255\255\255\255\255\011\001\012\001\255\255\ -\255\255\255\255\101\001\255\255\255\255\255\255\255\255\106\001\ -\107\001\255\255\109\001\110\001\255\255\255\255\255\255\114\001\ -\030\001\031\001\032\001\033\001\034\001\255\255\255\255\255\255\ -\255\255\039\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\050\001\255\255\052\001\053\001\ -\054\001\055\001\056\001\255\255\255\255\059\001\255\255\255\255\ -\255\255\063\001\064\001\065\001\255\255\255\255\255\255\069\001\ -\255\255\071\001\072\001\255\255\255\255\006\001\076\001\255\255\ -\078\001\255\255\255\255\012\001\255\255\014\001\084\001\085\001\ -\017\001\087\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\027\001\255\255\255\255\030\001\031\001\101\001\ -\255\255\255\255\255\255\255\255\106\001\107\001\255\255\109\001\ -\110\001\255\255\255\255\255\255\114\001\255\255\255\255\255\255\ -\255\255\050\001\051\001\255\255\053\001\255\255\055\001\056\001\ -\255\255\255\255\059\001\255\255\255\255\255\255\255\255\064\001\ -\065\001\255\255\006\001\255\255\255\255\255\255\071\001\255\255\ -\012\001\255\255\014\001\255\255\255\255\017\001\255\255\255\255\ -\081\001\255\255\255\255\084\001\255\255\255\255\255\255\027\001\ -\089\001\255\255\030\001\031\001\255\255\006\001\255\255\255\255\ -\097\001\255\255\255\255\012\001\101\001\014\001\255\255\104\001\ -\255\255\106\001\255\255\255\255\109\001\110\001\050\001\051\001\ -\255\255\053\001\255\255\055\001\056\001\030\001\031\001\059\001\ -\255\255\255\255\255\255\255\255\064\001\065\001\255\255\255\255\ -\255\255\255\255\255\255\071\001\255\255\255\255\255\255\255\255\ -\255\255\050\001\051\001\255\255\053\001\081\001\055\001\056\001\ -\084\001\255\255\059\001\255\255\255\255\089\001\255\255\064\001\ -\065\001\255\255\255\255\255\255\255\255\097\001\071\001\255\255\ -\073\001\101\001\255\255\255\255\104\001\255\255\106\001\255\255\ -\081\001\109\001\110\001\084\001\255\255\255\255\006\001\255\255\ -\089\001\255\255\255\255\255\255\012\001\255\255\014\001\255\255\ -\097\001\255\255\255\255\255\255\101\001\255\255\255\255\104\001\ -\255\255\106\001\255\255\027\001\109\001\110\001\030\001\031\001\ -\255\255\006\001\255\255\255\255\255\255\255\255\255\255\012\001\ -\255\255\014\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\050\001\051\001\255\255\053\001\027\001\055\001\ -\056\001\030\001\031\001\059\001\255\255\255\255\255\255\255\255\ -\064\001\065\001\255\255\255\255\255\255\255\255\255\255\071\001\ -\255\255\255\255\255\255\255\255\255\255\050\001\051\001\255\255\ -\053\001\081\001\055\001\056\001\084\001\255\255\059\001\255\255\ -\255\255\089\001\255\255\064\001\065\001\255\255\006\001\255\255\ -\255\255\097\001\071\001\255\255\012\001\101\001\255\255\255\255\ -\104\001\255\255\106\001\255\255\081\001\109\001\110\001\084\001\ -\255\255\255\255\255\255\255\255\089\001\255\255\030\001\031\001\ -\255\255\006\001\255\255\255\255\097\001\255\255\255\255\012\001\ -\101\001\255\255\255\255\104\001\255\255\106\001\255\255\255\255\ -\109\001\110\001\050\001\051\001\255\255\053\001\255\255\055\001\ -\056\001\030\001\031\001\059\001\255\255\255\255\255\255\255\255\ -\064\001\065\001\255\255\255\255\255\255\255\255\255\255\071\001\ -\255\255\073\001\255\255\255\255\255\255\050\001\051\001\255\255\ -\053\001\081\001\055\001\056\001\084\001\255\255\059\001\255\255\ -\255\255\089\001\255\255\064\001\065\001\255\255\006\001\255\255\ -\255\255\097\001\071\001\255\255\012\001\101\001\255\255\255\255\ -\104\001\255\255\106\001\255\255\081\001\109\001\110\001\084\001\ -\255\255\255\255\255\255\255\255\089\001\255\255\030\001\031\001\ -\255\255\006\001\255\255\255\255\097\001\255\255\255\255\012\001\ -\101\001\255\255\255\255\104\001\255\255\106\001\255\255\255\255\ -\109\001\110\001\050\001\051\001\255\255\053\001\255\255\055\001\ -\056\001\030\001\031\001\059\001\255\255\255\255\255\255\255\255\ -\064\001\065\001\255\255\255\255\255\255\255\255\255\255\071\001\ -\255\255\255\255\255\255\255\255\255\255\050\001\051\001\255\255\ -\053\001\081\001\055\001\056\001\084\001\255\255\059\001\255\255\ -\255\255\089\001\255\255\064\001\065\001\255\255\006\001\255\255\ -\255\255\097\001\071\001\255\255\012\001\101\001\255\255\255\255\ -\104\001\255\255\106\001\255\255\081\001\109\001\110\001\084\001\ -\255\255\255\255\255\255\255\255\089\001\255\255\030\001\031\001\ -\255\255\255\255\255\255\255\255\097\001\255\255\255\255\255\255\ -\101\001\255\255\255\255\104\001\255\255\106\001\255\255\255\255\ -\109\001\110\001\050\001\051\001\255\255\053\001\255\255\055\001\ -\056\001\255\255\255\255\059\001\255\255\255\255\255\255\255\255\ -\064\001\065\001\255\255\255\255\006\001\255\255\255\255\071\001\ -\255\255\255\255\012\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\081\001\255\255\255\255\084\001\255\255\255\255\255\255\ -\255\255\089\001\028\001\255\255\030\001\031\001\255\255\255\255\ -\255\255\097\001\255\255\255\255\255\255\101\001\255\255\255\255\ -\104\001\255\255\106\001\255\255\255\255\109\001\110\001\255\255\ -\050\001\255\255\052\001\053\001\255\255\055\001\056\001\255\255\ -\255\255\059\001\255\255\255\255\255\255\255\255\064\001\065\001\ -\255\255\255\255\255\255\006\001\255\255\071\001\255\255\010\001\ -\255\255\012\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\084\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\028\001\092\001\030\001\031\001\255\255\255\255\097\001\ -\255\255\255\255\255\255\101\001\255\255\255\255\255\255\255\255\ -\106\001\255\255\255\255\109\001\110\001\255\255\255\255\050\001\ -\255\255\052\001\053\001\255\255\055\001\056\001\255\255\255\255\ -\059\001\255\255\255\255\255\255\255\255\064\001\065\001\255\255\ -\006\001\255\255\255\255\255\255\071\001\255\255\012\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\006\001\007\001\255\255\ -\255\255\084\001\011\001\012\001\255\255\255\255\028\001\255\255\ -\030\001\031\001\255\255\255\255\255\255\255\255\097\001\255\255\ -\255\255\255\255\101\001\255\255\255\255\030\001\031\001\106\001\ -\255\255\255\255\109\001\110\001\050\001\255\255\052\001\053\001\ -\255\255\055\001\056\001\255\255\255\255\059\001\255\255\255\255\ -\255\255\050\001\064\001\065\001\053\001\054\001\055\001\056\001\ -\255\255\071\001\059\001\255\255\006\001\255\255\008\001\064\001\ -\065\001\255\255\012\001\255\255\255\255\255\255\084\001\255\255\ -\255\255\255\255\255\255\076\001\255\255\255\255\092\001\255\255\ -\255\255\255\255\028\001\097\001\030\001\031\001\087\001\101\001\ -\255\255\255\255\255\255\255\255\106\001\255\255\255\255\109\001\ -\110\001\255\255\255\255\255\255\101\001\255\255\255\255\255\255\ -\050\001\106\001\052\001\053\001\109\001\055\001\056\001\255\255\ -\255\255\059\001\255\255\255\255\255\255\255\255\064\001\065\001\ -\255\255\006\001\255\255\255\255\255\255\071\001\255\255\012\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\084\001\255\255\255\255\255\255\255\255\028\001\ -\255\255\030\001\031\001\255\255\255\255\255\255\255\255\097\001\ -\255\255\255\255\255\255\101\001\255\255\255\255\255\255\255\255\ -\106\001\255\255\255\255\109\001\110\001\050\001\255\255\052\001\ -\053\001\255\255\055\001\056\001\255\255\255\255\059\001\255\255\ -\255\255\255\255\255\255\064\001\065\001\255\255\006\001\255\255\ -\255\255\255\255\071\001\255\255\012\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\084\001\ -\255\255\255\255\255\255\255\255\028\001\255\255\030\001\031\001\ -\255\255\006\001\255\255\255\255\097\001\255\255\255\255\012\001\ -\101\001\255\255\255\255\255\255\255\255\106\001\255\255\255\255\ -\109\001\110\001\050\001\255\255\052\001\053\001\255\255\055\001\ -\056\001\030\001\031\001\059\001\255\255\255\255\255\255\255\255\ -\064\001\065\001\255\255\255\255\255\255\255\255\255\255\071\001\ -\255\255\255\255\255\255\255\255\255\255\050\001\255\255\052\001\ -\053\001\255\255\055\001\056\001\084\001\255\255\059\001\255\255\ -\255\255\255\255\255\255\064\001\065\001\255\255\006\001\255\255\ -\255\255\097\001\071\001\255\255\012\001\101\001\255\255\255\255\ -\255\255\255\255\106\001\255\255\255\255\109\001\110\001\084\001\ -\255\255\255\255\255\255\255\255\028\001\255\255\030\001\031\001\ -\093\001\006\001\255\255\255\255\097\001\255\255\255\255\012\001\ -\101\001\255\255\255\255\255\255\255\255\106\001\255\255\255\255\ -\109\001\110\001\050\001\255\255\052\001\053\001\255\255\055\001\ -\056\001\030\001\031\001\059\001\255\255\255\255\255\255\255\255\ -\064\001\065\001\255\255\255\255\255\255\255\255\255\255\071\001\ -\255\255\255\255\255\255\255\255\255\255\050\001\255\255\052\001\ -\053\001\255\255\055\001\056\001\084\001\255\255\059\001\255\255\ -\255\255\255\255\255\255\064\001\065\001\255\255\006\001\255\255\ -\255\255\097\001\071\001\255\255\012\001\101\001\255\255\255\255\ -\255\255\255\255\106\001\255\255\255\255\109\001\110\001\084\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\030\001\031\001\ -\255\255\006\001\255\255\255\255\097\001\255\255\255\255\012\001\ -\101\001\255\255\255\255\255\255\255\255\106\001\255\255\255\255\ -\109\001\110\001\050\001\255\255\052\001\053\001\255\255\055\001\ -\056\001\030\001\031\001\059\001\255\255\255\255\255\255\255\255\ -\064\001\065\001\255\255\255\255\255\255\255\255\255\255\071\001\ -\255\255\255\255\255\255\255\255\255\255\050\001\255\255\052\001\ -\053\001\255\255\055\001\056\001\084\001\255\255\059\001\255\255\ -\255\255\255\255\255\255\064\001\065\001\255\255\006\001\255\255\ -\255\255\097\001\071\001\255\255\012\001\101\001\255\255\255\255\ -\255\255\255\255\106\001\255\255\255\255\109\001\110\001\084\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\030\001\031\001\ -\255\255\006\001\255\255\255\255\097\001\255\255\255\255\012\001\ -\101\001\255\255\255\255\255\255\255\255\106\001\255\255\255\255\ -\109\001\110\001\050\001\255\255\255\255\053\001\255\255\055\001\ -\056\001\030\001\031\001\059\001\255\255\255\255\255\255\255\255\ -\064\001\065\001\255\255\255\255\255\255\255\255\255\255\071\001\ -\255\255\255\255\255\255\255\255\255\255\050\001\255\255\255\255\ -\053\001\255\255\055\001\056\001\084\001\255\255\059\001\255\255\ -\255\255\255\255\255\255\064\001\065\001\255\255\255\255\255\255\ -\255\255\097\001\071\001\255\255\255\255\101\001\006\001\007\001\ -\255\255\255\255\106\001\011\001\012\001\109\001\110\001\084\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\022\001\255\255\ -\255\255\255\255\255\255\255\255\097\001\255\255\030\001\031\001\ -\101\001\255\255\255\255\255\255\255\255\106\001\255\255\255\255\ -\109\001\110\001\255\255\255\255\255\255\255\255\255\255\047\001\ -\255\255\255\255\050\001\051\001\255\255\053\001\054\001\055\001\ -\056\001\255\255\255\255\059\001\255\255\255\255\255\255\255\255\ -\064\001\065\001\006\001\007\001\255\255\255\255\255\255\011\001\ -\012\001\255\255\255\255\255\255\076\001\255\255\255\255\255\255\ -\255\255\081\001\255\255\255\255\255\255\255\255\255\255\087\001\ -\255\255\089\001\030\001\031\001\255\255\255\255\255\255\255\255\ -\255\255\097\001\098\001\255\255\255\255\101\001\255\255\255\255\ -\104\001\255\255\106\001\255\255\255\255\109\001\050\001\051\001\ -\255\255\053\001\054\001\055\001\056\001\255\255\255\255\059\001\ -\255\255\255\255\255\255\255\255\064\001\065\001\006\001\007\001\ -\255\255\255\255\255\255\011\001\012\001\006\001\007\001\255\255\ -\076\001\255\255\011\001\012\001\255\255\081\001\255\255\255\255\ -\255\255\255\255\255\255\087\001\255\255\089\001\030\001\031\001\ -\255\255\255\255\255\255\255\255\255\255\030\001\031\001\255\255\ -\255\255\101\001\255\255\255\255\104\001\255\255\106\001\255\255\ -\255\255\109\001\050\001\255\255\255\255\053\001\054\001\055\001\ -\056\001\050\001\255\255\059\001\053\001\054\001\055\001\056\001\ -\064\001\065\001\059\001\255\255\255\255\255\255\008\001\064\001\ -\065\001\255\255\255\255\255\255\076\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\076\001\255\255\023\001\255\255\087\001\ -\255\255\255\255\255\255\255\255\030\001\255\255\087\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\101\001\255\255\255\255\ -\255\255\255\255\106\001\255\255\101\001\109\001\255\255\255\255\ -\255\255\106\001\255\255\255\255\109\001\055\001\255\255\057\001\ -\058\001\059\001\255\255\061\001\255\255\255\255\064\001\065\001\ -\255\255\255\255\255\255\000\001\001\001\002\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\009\001\255\255\255\255\081\001\ -\255\255\014\001\015\001\016\001\017\001\018\001\088\001\089\001\ -\090\001\255\255\255\255\255\255\255\255\255\255\027\001\097\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\036\001\ -\106\001\255\255\255\255\109\001\110\001\042\001\043\001\044\001\ -\045\001\046\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\061\001\255\255\255\255\255\255\255\255\066\001\255\255\255\255\ -\255\255\255\255\071\001\072\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\082\001\083\001\084\001\ -\085\001\086\001\255\255\000\001\001\001\002\001\255\255\255\255\ -\255\255\094\001\007\001\255\255\009\001\255\255\255\255\100\001\ -\255\255\255\255\055\001\016\001\057\001\058\001\059\001\255\255\ -\061\001\255\255\255\255\064\001\065\001\255\255\027\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\036\001\ -\255\255\255\255\255\255\255\255\081\001\042\001\043\001\044\001\ -\045\001\046\001\047\001\255\255\089\001\090\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\097\001\255\255\255\255\255\255\ -\061\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\109\001\110\001\071\001\072\001\255\255\074\001\255\255\255\255\ -\255\255\255\255\000\001\001\001\002\001\082\001\083\001\084\001\ -\085\001\086\001\087\001\009\001\255\255\255\255\255\255\255\255\ -\255\255\015\001\016\001\255\255\018\001\098\001\255\255\100\001\ -\255\255\255\255\255\255\255\255\255\255\027\001\255\255\255\255\ -\255\255\255\255\000\001\001\001\002\001\255\255\036\001\255\255\ -\255\255\255\255\255\255\009\001\042\001\043\001\044\001\045\001\ -\046\001\015\001\016\001\255\255\018\001\255\255\255\255\255\255\ -\055\001\255\255\057\001\058\001\059\001\027\001\061\001\061\001\ -\255\255\064\001\065\001\255\255\066\001\255\255\036\001\255\255\ -\255\255\071\001\072\001\255\255\042\001\043\001\044\001\045\001\ -\046\001\255\255\081\001\255\255\082\001\083\001\084\001\085\001\ -\086\001\255\255\089\001\090\001\255\255\091\001\255\255\061\001\ -\255\255\255\255\097\001\255\255\066\001\255\255\100\001\255\255\ -\255\255\071\001\072\001\255\255\255\255\255\255\109\001\110\001\ -\000\001\001\001\002\001\255\255\082\001\083\001\084\001\085\001\ -\086\001\009\001\255\255\255\255\255\255\255\255\092\001\015\001\ -\016\001\255\255\018\001\255\255\255\255\255\255\100\001\255\255\ -\255\255\255\255\255\255\027\001\255\255\255\255\255\255\255\255\ -\000\001\001\001\002\001\255\255\036\001\255\255\255\255\255\255\ -\255\255\009\001\042\001\043\001\044\001\045\001\046\001\015\001\ -\016\001\255\255\018\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\027\001\255\255\061\001\255\255\255\255\ -\255\255\255\255\066\001\255\255\036\001\255\255\255\255\071\001\ -\072\001\255\255\042\001\043\001\044\001\045\001\046\001\255\255\ -\255\255\255\255\082\001\083\001\084\001\085\001\086\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\061\001\094\001\255\255\ -\255\255\255\255\066\001\255\255\100\001\255\255\255\255\071\001\ -\072\001\255\255\255\255\255\255\255\255\255\255\000\001\001\001\ -\002\001\255\255\082\001\083\001\084\001\085\001\086\001\009\001\ -\255\255\255\255\255\255\091\001\255\255\015\001\016\001\255\255\ -\018\001\255\255\255\255\255\255\100\001\255\255\255\255\255\255\ -\255\255\027\001\255\255\255\255\255\255\255\255\000\001\001\001\ -\002\001\255\255\036\001\255\255\255\255\255\255\255\255\009\001\ -\042\001\043\001\044\001\045\001\046\001\015\001\016\001\255\255\ -\018\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\027\001\255\255\061\001\255\255\255\255\255\255\255\255\ -\066\001\255\255\036\001\255\255\255\255\071\001\072\001\255\255\ -\042\001\043\001\044\001\045\001\046\001\255\255\255\255\255\255\ -\082\001\083\001\084\001\085\001\086\001\255\255\255\255\255\255\ -\255\255\255\255\092\001\061\001\255\255\255\255\255\255\255\255\ -\066\001\255\255\100\001\255\255\255\255\071\001\072\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\082\001\083\001\084\001\085\001\086\001\000\001\001\001\002\001\ -\255\255\255\255\255\255\255\255\094\001\255\255\009\001\255\255\ -\255\255\255\255\100\001\255\255\015\001\016\001\255\255\018\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\027\001\255\255\255\255\255\255\255\255\000\001\001\001\002\001\ -\255\255\036\001\255\255\255\255\255\255\255\255\009\001\042\001\ -\043\001\044\001\045\001\046\001\015\001\016\001\255\255\018\001\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\027\001\255\255\061\001\255\255\255\255\255\255\255\255\066\001\ -\255\255\036\001\255\255\255\255\071\001\072\001\255\255\042\001\ -\043\001\044\001\045\001\046\001\255\255\255\255\255\255\082\001\ -\083\001\084\001\085\001\086\001\255\255\255\255\255\255\255\255\ -\091\001\255\255\061\001\255\255\255\255\255\255\255\255\066\001\ -\255\255\100\001\255\255\255\255\071\001\072\001\255\255\255\255\ -\255\255\255\255\255\255\000\001\001\001\002\001\255\255\082\001\ -\083\001\084\001\085\001\086\001\009\001\255\255\255\255\255\255\ -\255\255\092\001\015\001\016\001\255\255\018\001\255\255\255\255\ -\255\255\100\001\255\255\255\255\255\255\255\255\027\001\255\255\ -\255\255\255\255\255\255\000\001\001\001\002\001\255\255\036\001\ -\255\255\255\255\255\255\255\255\009\001\042\001\043\001\044\001\ -\045\001\046\001\015\001\016\001\255\255\018\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\027\001\255\255\ -\061\001\255\255\255\255\255\255\255\255\066\001\255\255\036\001\ -\255\255\255\255\071\001\072\001\255\255\042\001\043\001\044\001\ -\045\001\046\001\255\255\255\255\255\255\082\001\083\001\084\001\ -\085\001\086\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\061\001\094\001\255\255\255\255\255\255\066\001\255\255\100\001\ -\255\255\255\255\071\001\072\001\255\255\255\255\255\255\255\255\ -\255\255\000\001\001\001\002\001\255\255\082\001\083\001\084\001\ -\085\001\086\001\009\001\255\255\255\255\255\255\091\001\255\255\ -\015\001\016\001\255\255\018\001\255\255\255\255\255\255\100\001\ -\255\255\255\255\255\255\255\255\027\001\255\255\255\255\255\255\ -\255\255\000\001\001\001\002\001\255\255\036\001\255\255\255\255\ -\255\255\255\255\009\001\042\001\043\001\044\001\045\001\046\001\ -\015\001\016\001\255\255\018\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\027\001\255\255\061\001\255\255\ -\255\255\255\255\255\255\066\001\255\255\036\001\255\255\255\255\ -\071\001\072\001\255\255\042\001\043\001\044\001\045\001\046\001\ -\255\255\255\255\255\255\082\001\083\001\084\001\085\001\086\001\ -\255\255\255\255\255\255\255\255\255\255\092\001\061\001\001\001\ -\002\001\255\255\255\255\066\001\255\255\100\001\255\255\009\001\ -\071\001\072\001\255\255\255\255\255\255\015\001\016\001\255\255\ -\018\001\255\255\255\255\082\001\083\001\084\001\085\001\086\001\ -\255\255\027\001\255\255\255\255\255\255\255\255\255\255\094\001\ -\255\255\255\255\036\001\255\255\255\255\100\001\255\255\255\255\ -\042\001\043\001\044\001\045\001\046\001\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\061\001\001\001\002\001\255\255\255\255\ -\066\001\255\255\255\255\255\255\009\001\071\001\072\001\255\255\ -\255\255\255\255\015\001\016\001\255\255\018\001\255\255\255\255\ -\082\001\083\001\084\001\085\001\086\001\255\255\027\001\255\255\ -\255\255\255\255\255\255\255\255\255\255\095\001\255\255\036\001\ -\255\255\255\255\100\001\255\255\255\255\042\001\043\001\044\001\ -\045\001\046\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\061\001\001\001\002\001\255\255\255\255\066\001\255\255\255\255\ -\255\255\009\001\071\001\072\001\255\255\255\255\255\255\015\001\ -\016\001\255\255\018\001\255\255\255\255\082\001\083\001\084\001\ -\085\001\086\001\255\255\027\001\255\255\255\255\091\001\255\255\ -\255\255\001\001\002\001\255\255\036\001\255\255\255\255\100\001\ -\255\255\009\001\042\001\043\001\044\001\045\001\046\001\015\001\ -\016\001\255\255\018\001\255\255\255\255\255\255\255\255\255\255\ -\255\255\025\001\255\255\027\001\255\255\061\001\255\255\255\255\ -\255\255\255\255\066\001\255\255\036\001\255\255\255\255\071\001\ -\072\001\255\255\042\001\043\001\044\001\045\001\046\001\255\255\ -\255\255\255\255\082\001\083\001\084\001\085\001\086\001\255\255\ -\255\255\255\255\255\255\091\001\255\255\061\001\001\001\002\001\ -\255\255\255\255\066\001\255\255\100\001\255\255\009\001\071\001\ -\072\001\255\255\255\255\255\255\015\001\016\001\255\255\018\001\ -\255\255\255\255\082\001\083\001\084\001\085\001\086\001\255\255\ -\027\001\255\255\255\255\255\255\255\255\255\255\001\001\002\001\ -\255\255\036\001\255\255\255\255\100\001\255\255\009\001\042\001\ -\043\001\044\001\045\001\046\001\015\001\016\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\027\001\255\255\061\001\255\255\255\255\255\255\255\255\066\001\ -\255\255\036\001\255\255\255\255\071\001\072\001\255\255\042\001\ -\043\001\044\001\045\001\046\001\255\255\255\255\255\255\082\001\ -\083\001\084\001\085\001\086\001\255\255\255\255\255\255\255\255\ -\255\255\255\255\061\001\001\001\002\001\255\255\255\255\066\001\ -\255\255\100\001\255\255\009\001\071\001\072\001\255\255\255\255\ -\255\255\015\001\255\255\255\255\255\255\255\255\255\255\082\001\ -\083\001\084\001\085\001\086\001\255\255\027\001\255\255\255\255\ -\091\001\255\255\255\255\001\001\002\001\255\255\036\001\255\255\ -\255\255\100\001\255\255\255\255\042\001\043\001\044\001\045\001\ -\046\001\015\001\255\255\255\255\255\255\255\255\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\027\001\255\255\061\001\ -\255\255\255\255\255\255\255\255\066\001\255\255\036\001\255\255\ -\255\255\071\001\072\001\255\255\042\001\043\001\044\001\045\001\ -\046\001\013\001\255\255\255\255\082\001\083\001\084\001\085\001\ -\086\001\255\255\255\255\255\255\255\255\255\255\255\255\061\001\ -\028\001\029\001\255\255\255\255\066\001\255\255\100\001\255\255\ -\255\255\071\001\072\001\255\255\255\255\041\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\083\001\084\001\085\001\ -\086\001\255\255\255\255\055\001\255\255\057\001\058\001\059\001\ -\060\001\061\001\255\255\255\255\064\001\065\001\100\001\255\255\ -\068\001\255\255\255\255\255\255\255\255\255\255\074\001\255\255\ -\255\255\255\255\255\255\255\255\080\001\081\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\089\001\090\001\255\255\ -\255\255\255\255\255\255\255\255\096\001\097\001\255\255\255\255\ -\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ -\108\001\109\001\110\001\111\001" - -let yynames_const = "\ - AMPERAMPER\000\ - AMPERSAND\000\ - AND\000\ - AS\000\ - ASSERT\000\ - BACKQUOTE\000\ - BANG\000\ - BAR\000\ - BARBAR\000\ - BARRBRACKET\000\ - BEGIN\000\ - CLASS\000\ - COLON\000\ - COLONCOLON\000\ - COLONEQUAL\000\ - COLONGREATER\000\ - COMMA\000\ - CONSTRAINT\000\ - DO\000\ - DONE\000\ - DOT\000\ - DOTDOT\000\ - DOWNTO\000\ - ELSE\000\ - END\000\ - EOF\000\ - EQUAL\000\ - EXCEPTION\000\ - EXTERNAL\000\ - FALSE\000\ - FOR\000\ - FUN\000\ - FUNCTION\000\ - FUNCTOR\000\ - GREATER\000\ - GREATERRBRACE\000\ - GREATERRBRACKET\000\ - IF\000\ - IN\000\ - INCLUDE\000\ - INHERIT\000\ - INITIALIZER\000\ - LAZY\000\ - LBRACE\000\ - LBRACELESS\000\ - LBRACKET\000\ - LBRACKETBAR\000\ - LBRACKETLESS\000\ - LBRACKETGREATER\000\ - LBRACKETPERCENT\000\ - LBRACKETPERCENTPERCENT\000\ - LESS\000\ - LESSMINUS\000\ - LET\000\ - LPAREN\000\ - LBRACKETAT\000\ - LBRACKETATAT\000\ - LBRACKETATATAT\000\ - MATCH\000\ - METHOD\000\ - MINUS\000\ - MINUSDOT\000\ - MINUSGREATER\000\ - MODULE\000\ - MUTABLE\000\ - NEW\000\ - NONREC\000\ - OBJECT\000\ - OF\000\ - OPEN\000\ - OR\000\ - PERCENT\000\ - PLUS\000\ - PLUSDOT\000\ - PLUSEQ\000\ - PRIVATE\000\ - QUESTION\000\ - QUOTE\000\ - RBRACE\000\ - RBRACKET\000\ - REC\000\ - RPAREN\000\ - SEMI\000\ - SEMISEMI\000\ - HASH\000\ - SIG\000\ - STAR\000\ - STRUCT\000\ - THEN\000\ - TILDE\000\ - TO\000\ - TRUE\000\ - TRY\000\ - TYPE\000\ - UNDERSCORE\000\ - VAL\000\ - VIRTUAL\000\ - WHEN\000\ - WHILE\000\ - WITH\000\ - EOL\000\ - " - -let yynames_block = "\ - CHAR\000\ - FLOAT\000\ - INFIXOP0\000\ - INFIXOP1\000\ - INFIXOP2\000\ - INFIXOP3\000\ - INFIXOP4\000\ - DOTOP\000\ - INT\000\ - LABEL\000\ - LIDENT\000\ - OPTLABEL\000\ - PREFIXOP\000\ - HASHOP\000\ - STRING\000\ - UIDENT\000\ - COMMENT\000\ - DOCSTRING\000\ - " - -let yyact = [| - (fun _ -> failwith "parser") -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'structure) in - Obj.repr( -# 630 "parsing/parser.mly" - ( extra_str 1 _1 ) -# 7030 "parsing/parser.ml" - : Parsetree.structure)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'signature) in - Obj.repr( -# 633 "parsing/parser.mly" - ( extra_sig 1 _1 ) -# 7037 "parsing/parser.ml" - : Parsetree.signature)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'top_structure) in - Obj.repr( -# 636 "parsing/parser.mly" - ( Ptop_def (extra_str 1 _1) ) -# 7044 "parsing/parser.ml" - : Parsetree.toplevel_phrase)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'toplevel_directive) in - Obj.repr( -# 637 "parsing/parser.mly" - ( _1 ) -# 7051 "parsing/parser.ml" - : Parsetree.toplevel_phrase)) -; (fun __caml_parser_env -> - Obj.repr( -# 638 "parsing/parser.mly" - ( raise End_of_file ) -# 7057 "parsing/parser.ml" - : Parsetree.toplevel_phrase)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 642 "parsing/parser.mly" - ( (text_str 1) @ [mkstrexp _1 _2] ) -# 7065 "parsing/parser.ml" - : 'top_structure)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'top_structure_tail) in - Obj.repr( -# 644 "parsing/parser.mly" - ( _1 ) -# 7072 "parsing/parser.ml" - : 'top_structure)) -; (fun __caml_parser_env -> - Obj.repr( -# 647 "parsing/parser.mly" - ( [] ) -# 7078 "parsing/parser.ml" - : 'top_structure_tail)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'structure_item) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'top_structure_tail) in - Obj.repr( -# 648 "parsing/parser.mly" - ( (text_str 1) @ _1 :: _2 ) -# 7086 "parsing/parser.ml" - : 'top_structure_tail)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'use_file_body) in - Obj.repr( -# 651 "parsing/parser.mly" - ( extra_def 1 _1 ) -# 7093 "parsing/parser.ml" - : Parsetree.toplevel_phrase list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'use_file_tail) in - Obj.repr( -# 654 "parsing/parser.mly" - ( _1 ) -# 7100 "parsing/parser.ml" - : 'use_file_body)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'seq_expr) in - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'post_item_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'use_file_tail) in - Obj.repr( -# 656 "parsing/parser.mly" - ( (text_def 1) @ Ptop_def[mkstrexp _1 _2] :: _3 ) -# 7109 "parsing/parser.ml" - : 'use_file_body)) -; (fun __caml_parser_env -> - Obj.repr( -# 660 "parsing/parser.mly" - ( [] ) -# 7115 "parsing/parser.ml" - : 'use_file_tail)) -; (fun __caml_parser_env -> - Obj.repr( -# 662 "parsing/parser.mly" - ( text_def 1 ) -# 7121 "parsing/parser.ml" - : 'use_file_tail)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'seq_expr) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'post_item_attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'use_file_tail) in - Obj.repr( -# 664 "parsing/parser.mly" - ( mark_rhs_docs 2 3; - (text_def 1) @ (text_def 2) @ Ptop_def[mkstrexp _2 _3] :: _4 ) -# 7131 "parsing/parser.ml" - : 'use_file_tail)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'structure_item) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'use_file_tail) in - Obj.repr( -# 667 "parsing/parser.mly" - ( (text_def 1) @ (text_def 2) @ Ptop_def[_2] :: _3 ) -# 7139 "parsing/parser.ml" - : 'use_file_tail)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'toplevel_directive) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'use_file_tail) in - Obj.repr( -# 669 "parsing/parser.mly" - ( mark_rhs_docs 2 3; - (text_def 1) @ (text_def 2) @ _2 :: _3 ) -# 7148 "parsing/parser.ml" - : 'use_file_tail)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'structure_item) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'use_file_tail) in - Obj.repr( -# 672 "parsing/parser.mly" - ( (text_def 1) @ Ptop_def[_1] :: _2 ) -# 7156 "parsing/parser.ml" - : 'use_file_tail)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'toplevel_directive) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'use_file_tail) in - Obj.repr( -# 674 "parsing/parser.mly" - ( mark_rhs_docs 1 1; - (text_def 1) @ _1 :: _2 ) -# 7165 "parsing/parser.ml" - : 'use_file_tail)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'core_type) in - Obj.repr( -# 678 "parsing/parser.mly" - ( _1 ) -# 7172 "parsing/parser.ml" - : Parsetree.core_type)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in - Obj.repr( -# 681 "parsing/parser.mly" - ( _1 ) -# 7179 "parsing/parser.ml" - : Parsetree.expression)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'pattern) in - Obj.repr( -# 684 "parsing/parser.mly" - ( _1 ) -# 7186 "parsing/parser.ml" - : Parsetree.pattern)) -; (fun __caml_parser_env -> - Obj.repr( -# 691 "parsing/parser.mly" - ( mkrhs "*" 2, None ) -# 7192 "parsing/parser.ml" - : 'functor_arg)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'functor_arg_name) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'module_type) in - Obj.repr( -# 693 "parsing/parser.mly" - ( mkrhs _2 2, Some _4 ) -# 7200 "parsing/parser.ml" - : 'functor_arg)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 697 "parsing/parser.mly" - ( _1 ) -# 7207 "parsing/parser.ml" - : 'functor_arg_name)) -; (fun __caml_parser_env -> - Obj.repr( -# 698 "parsing/parser.mly" - ( "_" ) -# 7213 "parsing/parser.ml" - : 'functor_arg_name)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'functor_args) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'functor_arg) in - Obj.repr( -# 703 "parsing/parser.mly" - ( _2 :: _1 ) -# 7221 "parsing/parser.ml" - : 'functor_args)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'functor_arg) in - Obj.repr( -# 705 "parsing/parser.mly" - ( [ _1 ] ) -# 7228 "parsing/parser.ml" - : 'functor_args)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'mod_longident) in - Obj.repr( -# 710 "parsing/parser.mly" - ( mkmod(Pmod_ident (mkrhs _1 1)) ) -# 7235 "parsing/parser.ml" - : 'module_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'structure) in - Obj.repr( -# 712 "parsing/parser.mly" - ( mkmod ~attrs:_2 (Pmod_structure(extra_str 3 _3)) ) -# 7243 "parsing/parser.ml" - : 'module_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'structure) in - Obj.repr( -# 714 "parsing/parser.mly" - ( unclosed "struct" 1 "end" 4 ) -# 7251 "parsing/parser.ml" - : 'module_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'functor_args) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'module_expr) in - Obj.repr( -# 716 "parsing/parser.mly" - ( let modexp = - List.fold_left - (fun acc (n, t) -> mkmod(Pmod_functor(n, t, acc))) - _5 _3 - in wrap_mod_attrs modexp _2 ) -# 7264 "parsing/parser.ml" - : 'module_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'module_expr) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'paren_module_expr) in - Obj.repr( -# 722 "parsing/parser.mly" - ( mkmod(Pmod_apply(_1, _2)) ) -# 7272 "parsing/parser.ml" - : 'module_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'module_expr) in - Obj.repr( -# 724 "parsing/parser.mly" - ( mkmod(Pmod_apply(_1, mkmod (Pmod_structure []))) ) -# 7279 "parsing/parser.ml" - : 'module_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'paren_module_expr) in - Obj.repr( -# 726 "parsing/parser.mly" - ( _1 ) -# 7286 "parsing/parser.ml" - : 'module_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'module_expr) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attribute) in - Obj.repr( -# 728 "parsing/parser.mly" - ( Mod.attr _1 _2 ) -# 7294 "parsing/parser.ml" - : 'module_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'extension) in - Obj.repr( -# 730 "parsing/parser.mly" - ( mkmod(Pmod_extension _1) ) -# 7301 "parsing/parser.ml" - : 'module_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'module_expr) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'module_type) in - Obj.repr( -# 735 "parsing/parser.mly" - ( mkmod(Pmod_constraint(_2, _4)) ) -# 7309 "parsing/parser.ml" - : 'paren_module_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'module_expr) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'module_type) in - Obj.repr( -# 737 "parsing/parser.mly" - ( unclosed "(" 1 ")" 5 ) -# 7317 "parsing/parser.ml" - : 'paren_module_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'module_expr) in - Obj.repr( -# 739 "parsing/parser.mly" - ( _2 ) -# 7324 "parsing/parser.ml" - : 'paren_module_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'module_expr) in - Obj.repr( -# 741 "parsing/parser.mly" - ( unclosed "(" 1 ")" 3 ) -# 7331 "parsing/parser.ml" - : 'paren_module_expr)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in - Obj.repr( -# 743 "parsing/parser.mly" - ( mkmod ~attrs:_3 (Pmod_unpack _4)) -# 7339 "parsing/parser.ml" - : 'paren_module_expr)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : 'expr) in - let _6 = (Parsing.peek_val __caml_parser_env 1 : 'package_type) in - Obj.repr( -# 745 "parsing/parser.mly" - ( mkmod ~attrs:_3 - (Pmod_unpack( - ghexp(Pexp_constraint(_4, ghtyp(Ptyp_package _6))))) ) -# 7350 "parsing/parser.ml" - : 'paren_module_expr)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 6 : 'attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 5 : 'expr) in - let _6 = (Parsing.peek_val __caml_parser_env 3 : 'package_type) in - let _8 = (Parsing.peek_val __caml_parser_env 1 : 'package_type) in - Obj.repr( -# 750 "parsing/parser.mly" - ( mkmod ~attrs:_3 - (Pmod_unpack( - ghexp(Pexp_coerce(_4, Some(ghtyp(Ptyp_package _6)), - ghtyp(Ptyp_package _8))))) ) -# 7363 "parsing/parser.ml" - : 'paren_module_expr)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : 'expr) in - let _6 = (Parsing.peek_val __caml_parser_env 1 : 'package_type) in - Obj.repr( -# 755 "parsing/parser.mly" - ( mkmod ~attrs:_3 - (Pmod_unpack( - ghexp(Pexp_coerce(_4, None, ghtyp(Ptyp_package _6))))) ) -# 7374 "parsing/parser.ml" - : 'paren_module_expr)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 3 : 'attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - Obj.repr( -# 759 "parsing/parser.mly" - ( unclosed "(" 1 ")" 6 ) -# 7382 "parsing/parser.ml" - : 'paren_module_expr)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 3 : 'attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - Obj.repr( -# 761 "parsing/parser.mly" - ( unclosed "(" 1 ")" 6 ) -# 7390 "parsing/parser.ml" - : 'paren_module_expr)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in - Obj.repr( -# 763 "parsing/parser.mly" - ( unclosed "(" 1 ")" 5 ) -# 7398 "parsing/parser.ml" - : 'paren_module_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'seq_expr) in - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'post_item_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'structure_tail) in - Obj.repr( -# 768 "parsing/parser.mly" - ( mark_rhs_docs 1 2; - (text_str 1) @ mkstrexp _1 _2 :: _3 ) -# 7408 "parsing/parser.ml" - : 'structure)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'structure_tail) in - Obj.repr( -# 770 "parsing/parser.mly" - ( _1 ) -# 7415 "parsing/parser.ml" - : 'structure)) -; (fun __caml_parser_env -> - Obj.repr( -# 773 "parsing/parser.mly" - ( [] ) -# 7421 "parsing/parser.ml" - : 'structure_tail)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'structure) in - Obj.repr( -# 774 "parsing/parser.mly" - ( (text_str 1) @ _2 ) -# 7428 "parsing/parser.ml" - : 'structure_tail)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'structure_item) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'structure_tail) in - Obj.repr( -# 775 "parsing/parser.mly" - ( (text_str 1) @ _1 :: _2 ) -# 7436 "parsing/parser.ml" - : 'structure_tail)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'let_bindings) in - Obj.repr( -# 779 "parsing/parser.mly" - ( val_of_let_bindings _1 ) -# 7443 "parsing/parser.ml" - : 'structure_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'primitive_declaration) in - Obj.repr( -# 781 "parsing/parser.mly" - ( let (body, ext) = _1 in mkstr_ext (Pstr_primitive body) ext ) -# 7450 "parsing/parser.ml" - : 'structure_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'value_description) in - Obj.repr( -# 783 "parsing/parser.mly" - ( let (body, ext) = _1 in mkstr_ext (Pstr_primitive body) ext ) -# 7457 "parsing/parser.ml" - : 'structure_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'type_declarations) in - Obj.repr( -# 785 "parsing/parser.mly" - ( let (nr, l, ext ) = _1 in mkstr_ext (Pstr_type (nr, List.rev l)) ext ) -# 7464 "parsing/parser.ml" - : 'structure_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'str_type_extension) in - Obj.repr( -# 787 "parsing/parser.mly" - ( let (l, ext) = _1 in mkstr_ext (Pstr_typext l) ext ) -# 7471 "parsing/parser.ml" - : 'structure_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'str_exception_declaration) in - Obj.repr( -# 789 "parsing/parser.mly" - ( let (l, ext) = _1 in mkstr_ext (Pstr_exception l) ext ) -# 7478 "parsing/parser.ml" - : 'structure_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'module_binding) in - Obj.repr( -# 791 "parsing/parser.mly" - ( let (body, ext) = _1 in mkstr_ext (Pstr_module body) ext ) -# 7485 "parsing/parser.ml" - : 'structure_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'rec_module_bindings) in - Obj.repr( -# 793 "parsing/parser.mly" - ( let (l, ext) = _1 in mkstr_ext (Pstr_recmodule(List.rev l)) ext ) -# 7492 "parsing/parser.ml" - : 'structure_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'module_type_declaration) in - Obj.repr( -# 795 "parsing/parser.mly" - ( let (body, ext) = _1 in mkstr_ext (Pstr_modtype body) ext ) -# 7499 "parsing/parser.ml" - : 'structure_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'open_statement) in - Obj.repr( -# 797 "parsing/parser.mly" - ( let (body, ext) = _1 in mkstr_ext (Pstr_open body) ext ) -# 7506 "parsing/parser.ml" - : 'structure_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'class_declarations) in - Obj.repr( -# 799 "parsing/parser.mly" - ( let (l, ext) = _1 in mkstr_ext (Pstr_class (List.rev l)) ext ) -# 7513 "parsing/parser.ml" - : 'structure_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'class_type_declarations) in - Obj.repr( -# 801 "parsing/parser.mly" - ( let (l, ext) = _1 in mkstr_ext (Pstr_class_type (List.rev l)) ext ) -# 7520 "parsing/parser.ml" - : 'structure_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'str_include_statement) in - Obj.repr( -# 803 "parsing/parser.mly" - ( let (body, ext) = _1 in mkstr_ext (Pstr_include body) ext ) -# 7527 "parsing/parser.ml" - : 'structure_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'item_extension) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 805 "parsing/parser.mly" - ( mkstr(Pstr_extension (_1, (add_docs_attrs (symbol_docs ()) _2))) ) -# 7535 "parsing/parser.ml" - : 'structure_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'floating_attribute) in - Obj.repr( -# 807 "parsing/parser.mly" - ( mark_symbol_docs (); - mkstr(Pstr_attribute _1) ) -# 7543 "parsing/parser.ml" - : 'structure_item)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'module_expr) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 812 "parsing/parser.mly" - ( let (ext, attrs) = _2 in - Incl.mk _3 ~attrs:(attrs@_4) - ~loc:(symbol_rloc()) ~docs:(symbol_docs ()) - , ext ) -# 7555 "parsing/parser.ml" - : 'str_include_statement)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'module_expr) in - Obj.repr( -# 819 "parsing/parser.mly" - ( _2 ) -# 7562 "parsing/parser.ml" - : 'module_binding_body)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'module_type) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'module_expr) in - Obj.repr( -# 821 "parsing/parser.mly" - ( mkmod(Pmod_constraint(_4, _2)) ) -# 7570 "parsing/parser.ml" - : 'module_binding_body)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'functor_arg) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'module_binding_body) in - Obj.repr( -# 823 "parsing/parser.mly" - ( mkmod(Pmod_functor(fst _1, snd _1, _2)) ) -# 7578 "parsing/parser.ml" - : 'module_binding_body)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 2 : string) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'module_binding_body) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 827 "parsing/parser.mly" - ( let (ext, attrs) = _2 in - Mb.mk (mkrhs _3 3) _4 ~attrs:(attrs@_5) - ~loc:(symbol_rloc ()) ~docs:(symbol_docs ()) - , ext ) -# 7591 "parsing/parser.ml" - : 'module_binding)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'rec_module_binding) in - Obj.repr( -# 833 "parsing/parser.mly" - ( let (b, ext) = _1 in ([b], ext) ) -# 7598 "parsing/parser.ml" - : 'rec_module_bindings)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'rec_module_bindings) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'and_module_binding) in - Obj.repr( -# 835 "parsing/parser.mly" - ( let (l, ext) = _1 in (_2 :: l, ext) ) -# 7606 "parsing/parser.ml" - : 'rec_module_bindings)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 2 : string) in - let _5 = (Parsing.peek_val __caml_parser_env 1 : 'module_binding_body) in - let _6 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 839 "parsing/parser.mly" - ( let (ext, attrs) = _2 in - Mb.mk (mkrhs _4 4) _5 ~attrs:(attrs@_6) - ~loc:(symbol_rloc ()) ~docs:(symbol_docs ()) - , ext ) -# 7619 "parsing/parser.ml" - : 'rec_module_binding)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 2 : string) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'module_binding_body) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 846 "parsing/parser.mly" - ( Mb.mk (mkrhs _3 3) _4 ~attrs:(_2@_5) ~loc:(symbol_rloc ()) - ~text:(symbol_text ()) ~docs:(symbol_docs ()) ) -# 7630 "parsing/parser.ml" - : 'and_module_binding)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'mty_longident) in - Obj.repr( -# 854 "parsing/parser.mly" - ( mkmty(Pmty_ident (mkrhs _1 1)) ) -# 7637 "parsing/parser.ml" - : 'module_type)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'signature) in - Obj.repr( -# 856 "parsing/parser.mly" - ( mkmty ~attrs:_2 (Pmty_signature (extra_sig 3 _3)) ) -# 7645 "parsing/parser.ml" - : 'module_type)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'signature) in - Obj.repr( -# 858 "parsing/parser.mly" - ( unclosed "sig" 1 "end" 4 ) -# 7653 "parsing/parser.ml" - : 'module_type)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'functor_args) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'module_type) in - Obj.repr( -# 861 "parsing/parser.mly" - ( let mty = - List.fold_left - (fun acc (n, t) -> mkmty(Pmty_functor(n, t, acc))) - _5 _3 - in wrap_mty_attrs mty _2 ) -# 7666 "parsing/parser.ml" - : 'module_type)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'module_type) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'module_type) in - Obj.repr( -# 868 "parsing/parser.mly" - ( mkmty(Pmty_functor(mknoloc "_", Some _1, _3)) ) -# 7674 "parsing/parser.ml" - : 'module_type)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'module_type) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'with_constraints) in - Obj.repr( -# 870 "parsing/parser.mly" - ( mkmty(Pmty_with(_1, List.rev _3)) ) -# 7682 "parsing/parser.ml" - : 'module_type)) -; (fun __caml_parser_env -> - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'attributes) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'module_expr) in - Obj.repr( -# 872 "parsing/parser.mly" - ( mkmty ~attrs:_4 (Pmty_typeof _5) ) -# 7690 "parsing/parser.ml" - : 'module_type)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'module_type) in - Obj.repr( -# 876 "parsing/parser.mly" - ( _2 ) -# 7697 "parsing/parser.ml" - : 'module_type)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'module_type) in - Obj.repr( -# 878 "parsing/parser.mly" - ( unclosed "(" 1 ")" 3 ) -# 7704 "parsing/parser.ml" - : 'module_type)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'extension) in - Obj.repr( -# 880 "parsing/parser.mly" - ( mkmty(Pmty_extension _1) ) -# 7711 "parsing/parser.ml" - : 'module_type)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'module_type) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attribute) in - Obj.repr( -# 882 "parsing/parser.mly" - ( Mty.attr _1 _2 ) -# 7719 "parsing/parser.ml" - : 'module_type)) -; (fun __caml_parser_env -> - Obj.repr( -# 885 "parsing/parser.mly" - ( [] ) -# 7725 "parsing/parser.ml" - : 'signature)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'signature) in - Obj.repr( -# 886 "parsing/parser.mly" - ( (text_sig 1) @ _2 ) -# 7732 "parsing/parser.ml" - : 'signature)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'signature_item) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'signature) in - Obj.repr( -# 887 "parsing/parser.mly" - ( (text_sig 1) @ _1 :: _2 ) -# 7740 "parsing/parser.ml" - : 'signature)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'value_description) in - Obj.repr( -# 891 "parsing/parser.mly" - ( let (body, ext) = _1 in mksig_ext (Psig_value body) ext ) -# 7747 "parsing/parser.ml" - : 'signature_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'primitive_declaration) in - Obj.repr( -# 893 "parsing/parser.mly" - ( let (body, ext) = _1 in mksig_ext (Psig_value body) ext) -# 7754 "parsing/parser.ml" - : 'signature_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'type_declarations) in - Obj.repr( -# 895 "parsing/parser.mly" - ( let (nr, l, ext) = _1 in mksig_ext (Psig_type (nr, List.rev l)) ext ) -# 7761 "parsing/parser.ml" - : 'signature_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'sig_type_extension) in - Obj.repr( -# 897 "parsing/parser.mly" - ( let (l, ext) = _1 in mksig_ext (Psig_typext l) ext ) -# 7768 "parsing/parser.ml" - : 'signature_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'sig_exception_declaration) in - Obj.repr( -# 899 "parsing/parser.mly" - ( let (l, ext) = _1 in mksig_ext (Psig_exception l) ext ) -# 7775 "parsing/parser.ml" - : 'signature_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'module_declaration) in - Obj.repr( -# 901 "parsing/parser.mly" - ( let (body, ext) = _1 in mksig_ext (Psig_module body) ext ) -# 7782 "parsing/parser.ml" - : 'signature_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'module_alias) in - Obj.repr( -# 903 "parsing/parser.mly" - ( let (body, ext) = _1 in mksig_ext (Psig_module body) ext ) -# 7789 "parsing/parser.ml" - : 'signature_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'rec_module_declarations) in - Obj.repr( -# 905 "parsing/parser.mly" - ( let (l, ext) = _1 in mksig_ext (Psig_recmodule (List.rev l)) ext ) -# 7796 "parsing/parser.ml" - : 'signature_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'module_type_declaration) in - Obj.repr( -# 907 "parsing/parser.mly" - ( let (body, ext) = _1 in mksig_ext (Psig_modtype body) ext ) -# 7803 "parsing/parser.ml" - : 'signature_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'open_statement) in - Obj.repr( -# 909 "parsing/parser.mly" - ( let (body, ext) = _1 in mksig_ext (Psig_open body) ext ) -# 7810 "parsing/parser.ml" - : 'signature_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'sig_include_statement) in - Obj.repr( -# 911 "parsing/parser.mly" - ( let (body, ext) = _1 in mksig_ext (Psig_include body) ext ) -# 7817 "parsing/parser.ml" - : 'signature_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'class_descriptions) in - Obj.repr( -# 913 "parsing/parser.mly" - ( let (l, ext) = _1 in mksig_ext (Psig_class (List.rev l)) ext ) -# 7824 "parsing/parser.ml" - : 'signature_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'class_type_declarations) in - Obj.repr( -# 915 "parsing/parser.mly" - ( let (l, ext) = _1 in mksig_ext (Psig_class_type (List.rev l)) ext ) -# 7831 "parsing/parser.ml" - : 'signature_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'item_extension) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 917 "parsing/parser.mly" - ( mksig(Psig_extension (_1, (add_docs_attrs (symbol_docs ()) _2))) ) -# 7839 "parsing/parser.ml" - : 'signature_item)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'floating_attribute) in - Obj.repr( -# 919 "parsing/parser.mly" - ( mark_symbol_docs (); - mksig(Psig_attribute _1) ) -# 7847 "parsing/parser.ml" - : 'signature_item)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'override_flag) in - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'mod_longident) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 924 "parsing/parser.mly" - ( let (ext, attrs) = _3 in - Opn.mk (mkrhs _4 4) ~override:_2 ~attrs:(attrs@_5) - ~loc:(symbol_rloc()) ~docs:(symbol_docs ()) - , ext) -# 7860 "parsing/parser.ml" - : 'open_statement)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'module_type) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 931 "parsing/parser.mly" - ( let (ext, attrs) = _2 in - Incl.mk _3 ~attrs:(attrs@_4) - ~loc:(symbol_rloc()) ~docs:(symbol_docs ()) - , ext) -# 7872 "parsing/parser.ml" - : 'sig_include_statement)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'module_type) in - Obj.repr( -# 938 "parsing/parser.mly" - ( _2 ) -# 7879 "parsing/parser.ml" - : 'module_declaration_body)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 4 : string) in - let _4 = (Parsing.peek_val __caml_parser_env 2 : 'module_type) in - let _6 = (Parsing.peek_val __caml_parser_env 0 : 'module_declaration_body) in - Obj.repr( -# 940 "parsing/parser.mly" - ( mkmty(Pmty_functor(mkrhs _2 2, Some _4, _6)) ) -# 7888 "parsing/parser.ml" - : 'module_declaration_body)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'module_declaration_body) in - Obj.repr( -# 942 "parsing/parser.mly" - ( mkmty(Pmty_functor(mkrhs "*" 1, None, _3)) ) -# 7895 "parsing/parser.ml" - : 'module_declaration_body)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 2 : string) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'module_declaration_body) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 946 "parsing/parser.mly" - ( let (ext, attrs) = _2 in - Md.mk (mkrhs _3 3) _4 ~attrs:(attrs@_5) - ~loc:(symbol_rloc()) ~docs:(symbol_docs ()) - , ext ) -# 7908 "parsing/parser.ml" - : 'module_declaration)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _5 = (Parsing.peek_val __caml_parser_env 1 : 'mod_longident) in - let _6 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 953 "parsing/parser.mly" - ( let (ext, attrs) = _2 in - Md.mk (mkrhs _3 3) - (Mty.alias ~loc:(rhs_loc 5) (mkrhs _5 5)) ~attrs:(attrs@_6) - ~loc:(symbol_rloc()) ~docs:(symbol_docs ()) - , ext ) -# 7922 "parsing/parser.ml" - : 'module_alias)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'rec_module_declaration) in - Obj.repr( -# 961 "parsing/parser.mly" - ( let (body, ext) = _1 in ([body], ext) ) -# 7929 "parsing/parser.ml" - : 'rec_module_declarations)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'rec_module_declarations) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'and_module_declaration) in - Obj.repr( -# 963 "parsing/parser.mly" - ( let (l, ext) = _1 in (_2 :: l, ext) ) -# 7937 "parsing/parser.ml" - : 'rec_module_declarations)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 5 : 'ext_attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _6 = (Parsing.peek_val __caml_parser_env 1 : 'module_type) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 967 "parsing/parser.mly" - ( let (ext, attrs) = _2 in - Md.mk (mkrhs _4 4) _6 ~attrs:(attrs@_7) - ~loc:(symbol_rloc()) ~docs:(symbol_docs ()) - , ext) -# 7950 "parsing/parser.ml" - : 'rec_module_declaration)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 4 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _5 = (Parsing.peek_val __caml_parser_env 1 : 'module_type) in - let _6 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 974 "parsing/parser.mly" - ( Md.mk (mkrhs _3 3) _5 ~attrs:(_2@_6) ~loc:(symbol_rloc()) - ~text:(symbol_text()) ~docs:(symbol_docs()) ) -# 7961 "parsing/parser.ml" - : 'and_module_declaration)) -; (fun __caml_parser_env -> - Obj.repr( -# 978 "parsing/parser.mly" - ( None ) -# 7967 "parsing/parser.ml" - : 'module_type_declaration_body)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'module_type) in - Obj.repr( -# 979 "parsing/parser.mly" - ( Some _2 ) -# 7974 "parsing/parser.ml" - : 'module_type_declaration_body)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 3 : 'ext_attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 2 : 'ident) in - let _5 = (Parsing.peek_val __caml_parser_env 1 : 'module_type_declaration_body) in - let _6 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 984 "parsing/parser.mly" - ( let (ext, attrs) = _3 in - Mtd.mk (mkrhs _4 4) ?typ:_5 ~attrs:(attrs@_6) - ~loc:(symbol_rloc()) ~docs:(symbol_docs ()) - , ext ) -# 7987 "parsing/parser.ml" - : 'module_type_declaration)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'class_declaration) in - Obj.repr( -# 993 "parsing/parser.mly" - ( let (body, ext) = _1 in ([body], ext) ) -# 7994 "parsing/parser.ml" - : 'class_declarations)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'class_declarations) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'and_class_declaration) in - Obj.repr( -# 995 "parsing/parser.mly" - ( let (l, ext) = _1 in (_2 :: l, ext) ) -# 8002 "parsing/parser.ml" - : 'class_declarations)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 5 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'virtual_flag) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : 'class_type_parameters) in - let _5 = (Parsing.peek_val __caml_parser_env 2 : string) in - let _6 = (Parsing.peek_val __caml_parser_env 1 : 'class_fun_binding) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1000 "parsing/parser.mly" - ( let (ext, attrs) = _2 in - Ci.mk (mkrhs _5 5) _6 ~virt:_3 ~params:_4 ~attrs:(attrs@_7) - ~loc:(symbol_rloc ()) ~docs:(symbol_docs ()) - , ext ) -# 8017 "parsing/parser.ml" - : 'class_declaration)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 5 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'virtual_flag) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : 'class_type_parameters) in - let _5 = (Parsing.peek_val __caml_parser_env 2 : string) in - let _6 = (Parsing.peek_val __caml_parser_env 1 : 'class_fun_binding) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1008 "parsing/parser.mly" - ( Ci.mk (mkrhs _5 5) _6 ~virt:_3 ~params:_4 - ~attrs:(_2@_7) ~loc:(symbol_rloc ()) - ~text:(symbol_text ()) ~docs:(symbol_docs ()) ) -# 8031 "parsing/parser.ml" - : 'and_class_declaration)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'class_expr) in - Obj.repr( -# 1014 "parsing/parser.mly" - ( _2 ) -# 8038 "parsing/parser.ml" - : 'class_fun_binding)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'class_type) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'class_expr) in - Obj.repr( -# 1016 "parsing/parser.mly" - ( mkclass(Pcl_constraint(_4, _2)) ) -# 8046 "parsing/parser.ml" - : 'class_fun_binding)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'labeled_simple_pattern) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'class_fun_binding) in - Obj.repr( -# 1018 "parsing/parser.mly" - ( let (l,o,p) = _1 in mkclass(Pcl_fun(l, o, p, _2)) ) -# 8054 "parsing/parser.ml" - : 'class_fun_binding)) -; (fun __caml_parser_env -> - Obj.repr( -# 1021 "parsing/parser.mly" - ( [] ) -# 8060 "parsing/parser.ml" - : 'class_type_parameters)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'type_parameter_list) in - Obj.repr( -# 1022 "parsing/parser.mly" - ( List.rev _2 ) -# 8067 "parsing/parser.ml" - : 'class_type_parameters)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'labeled_simple_pattern) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'class_expr) in - Obj.repr( -# 1026 "parsing/parser.mly" - ( let (l,o,p) = _1 in mkclass(Pcl_fun(l, o, p, _3)) ) -# 8075 "parsing/parser.ml" - : 'class_fun_def)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'labeled_simple_pattern) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'class_fun_def) in - Obj.repr( -# 1028 "parsing/parser.mly" - ( let (l,o,p) = _1 in mkclass(Pcl_fun(l, o, p, _2)) ) -# 8083 "parsing/parser.ml" - : 'class_fun_def)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'class_simple_expr) in - Obj.repr( -# 1032 "parsing/parser.mly" - ( _1 ) -# 8090 "parsing/parser.ml" - : 'class_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'class_fun_def) in - Obj.repr( -# 1034 "parsing/parser.mly" - ( wrap_class_attrs _3 _2 ) -# 8098 "parsing/parser.ml" - : 'class_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'class_simple_expr) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'simple_labeled_expr_list) in - Obj.repr( -# 1036 "parsing/parser.mly" - ( mkclass(Pcl_apply(_1, List.rev _2)) ) -# 8106 "parsing/parser.ml" - : 'class_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'let_bindings) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'class_expr) in - Obj.repr( -# 1038 "parsing/parser.mly" - ( class_of_let_bindings _1 _3 ) -# 8114 "parsing/parser.ml" - : 'class_expr)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'override_flag) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : 'attributes) in - let _5 = (Parsing.peek_val __caml_parser_env 2 : 'mod_longident) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'class_expr) in - Obj.repr( -# 1040 "parsing/parser.mly" - ( wrap_class_attrs (mkclass(Pcl_open(_3, mkrhs _5 5, _7))) _4 ) -# 8124 "parsing/parser.ml" - : 'class_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'class_expr) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attribute) in - Obj.repr( -# 1042 "parsing/parser.mly" - ( Cl.attr _1 _2 ) -# 8132 "parsing/parser.ml" - : 'class_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'extension) in - Obj.repr( -# 1044 "parsing/parser.mly" - ( mkclass(Pcl_extension _1) ) -# 8139 "parsing/parser.ml" - : 'class_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'core_type_comma_list) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'class_longident) in - Obj.repr( -# 1048 "parsing/parser.mly" - ( mkclass(Pcl_constr(mkloc _4 (rhs_loc 4), List.rev _2)) ) -# 8147 "parsing/parser.ml" - : 'class_simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'class_longident) in - Obj.repr( -# 1050 "parsing/parser.mly" - ( mkclass(Pcl_constr(mkrhs _1 1, [])) ) -# 8154 "parsing/parser.ml" - : 'class_simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'class_structure) in - Obj.repr( -# 1052 "parsing/parser.mly" - ( mkclass ~attrs:_2 (Pcl_structure _3) ) -# 8162 "parsing/parser.ml" - : 'class_simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'class_structure) in - Obj.repr( -# 1054 "parsing/parser.mly" - ( unclosed "object" 1 "end" 4 ) -# 8170 "parsing/parser.ml" - : 'class_simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'class_expr) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'class_type) in - Obj.repr( -# 1056 "parsing/parser.mly" - ( mkclass(Pcl_constraint(_2, _4)) ) -# 8178 "parsing/parser.ml" - : 'class_simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'class_expr) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'class_type) in - Obj.repr( -# 1058 "parsing/parser.mly" - ( unclosed "(" 1 ")" 5 ) -# 8186 "parsing/parser.ml" - : 'class_simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'class_expr) in - Obj.repr( -# 1060 "parsing/parser.mly" - ( _2 ) -# 8193 "parsing/parser.ml" - : 'class_simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'class_expr) in - Obj.repr( -# 1062 "parsing/parser.mly" - ( unclosed "(" 1 ")" 3 ) -# 8200 "parsing/parser.ml" - : 'class_simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'class_self_pattern) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'class_fields) in - Obj.repr( -# 1066 "parsing/parser.mly" - ( Cstr.mk _1 (extra_cstr 2 (List.rev _2)) ) -# 8208 "parsing/parser.ml" - : 'class_structure)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'pattern) in - Obj.repr( -# 1070 "parsing/parser.mly" - ( reloc_pat _2 ) -# 8215 "parsing/parser.ml" - : 'class_self_pattern)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'pattern) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'core_type) in - Obj.repr( -# 1072 "parsing/parser.mly" - ( mkpat(Ppat_constraint(_2, _4)) ) -# 8223 "parsing/parser.ml" - : 'class_self_pattern)) -; (fun __caml_parser_env -> - Obj.repr( -# 1074 "parsing/parser.mly" - ( ghpat(Ppat_any) ) -# 8229 "parsing/parser.ml" - : 'class_self_pattern)) -; (fun __caml_parser_env -> - Obj.repr( -# 1078 "parsing/parser.mly" - ( [] ) -# 8235 "parsing/parser.ml" - : 'class_fields)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'class_fields) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'class_field) in - Obj.repr( -# 1080 "parsing/parser.mly" - ( _2 :: (text_cstr 2) @ _1 ) -# 8243 "parsing/parser.ml" - : 'class_fields)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 4 : 'override_flag) in - let _3 = (Parsing.peek_val __caml_parser_env 3 : 'attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 2 : 'class_expr) in - let _5 = (Parsing.peek_val __caml_parser_env 1 : 'parent_binder) in - let _6 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1085 "parsing/parser.mly" - ( mkcf (Pcf_inherit (_2, _4, _5)) ~attrs:(_3@_6) ~docs:(symbol_docs ()) ) -# 8254 "parsing/parser.ml" - : 'class_field)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'value) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1087 "parsing/parser.mly" - ( let v, attrs = _2 in - mkcf (Pcf_val v) ~attrs:(attrs@_3) ~docs:(symbol_docs ()) ) -# 8263 "parsing/parser.ml" - : 'class_field)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'method_) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1090 "parsing/parser.mly" - ( let meth, attrs = _2 in - mkcf (Pcf_method meth) ~attrs:(attrs@_3) ~docs:(symbol_docs ()) ) -# 8272 "parsing/parser.ml" - : 'class_field)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'constrain_field) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1093 "parsing/parser.mly" - ( mkcf (Pcf_constraint _3) ~attrs:(_2@_4) ~docs:(symbol_docs ()) ) -# 8281 "parsing/parser.ml" - : 'class_field)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1095 "parsing/parser.mly" - ( mkcf (Pcf_initializer _3) ~attrs:(_2@_4) ~docs:(symbol_docs ()) ) -# 8290 "parsing/parser.ml" - : 'class_field)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'item_extension) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1097 "parsing/parser.mly" - ( mkcf (Pcf_extension _1) ~attrs:_2 ~docs:(symbol_docs ()) ) -# 8298 "parsing/parser.ml" - : 'class_field)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'floating_attribute) in - Obj.repr( -# 1099 "parsing/parser.mly" - ( mark_symbol_docs (); - mkcf (Pcf_attribute _1) ) -# 8306 "parsing/parser.ml" - : 'class_field)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 1104 "parsing/parser.mly" - ( Some (mkrhs _2 2) ) -# 8313 "parsing/parser.ml" - : 'parent_binder)) -; (fun __caml_parser_env -> - Obj.repr( -# 1106 "parsing/parser.mly" - ( None ) -# 8319 "parsing/parser.ml" - : 'parent_binder)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 6 : 'override_flag) in - let _2 = (Parsing.peek_val __caml_parser_env 5 : 'attributes) in - let _5 = (Parsing.peek_val __caml_parser_env 2 : 'label) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in - Obj.repr( -# 1111 "parsing/parser.mly" - ( if _1 = Override then syntax_error (); - (mkloc _5 (rhs_loc 5), Mutable, Cfk_virtual _7), _2 ) -# 8330 "parsing/parser.ml" - : 'value)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 6 : 'override_flag) in - let _2 = (Parsing.peek_val __caml_parser_env 5 : 'attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : 'mutable_flag) in - let _5 = (Parsing.peek_val __caml_parser_env 2 : 'label) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in - Obj.repr( -# 1114 "parsing/parser.mly" - ( if _1 = Override then syntax_error (); - (mkrhs _5 5, _4, Cfk_virtual _7), _2 ) -# 8342 "parsing/parser.ml" - : 'value)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 5 : 'override_flag) in - let _2 = (Parsing.peek_val __caml_parser_env 4 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 3 : 'mutable_flag) in - let _4 = (Parsing.peek_val __caml_parser_env 2 : 'label) in - let _6 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1117 "parsing/parser.mly" - ( (mkrhs _4 4, _3, Cfk_concrete (_1, _6)), _2 ) -# 8353 "parsing/parser.ml" - : 'value)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 6 : 'override_flag) in - let _2 = (Parsing.peek_val __caml_parser_env 5 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'mutable_flag) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : 'label) in - let _5 = (Parsing.peek_val __caml_parser_env 2 : 'type_constraint) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1119 "parsing/parser.mly" - ( - let e = mkexp_constraint _7 _5 in - (mkrhs _4 4, _3, Cfk_concrete (_1, e)), _2 - ) -# 8368 "parsing/parser.ml" - : 'value)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 6 : 'override_flag) in - let _2 = (Parsing.peek_val __caml_parser_env 5 : 'attributes) in - let _5 = (Parsing.peek_val __caml_parser_env 2 : 'label) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'poly_type) in - Obj.repr( -# 1127 "parsing/parser.mly" - ( if _1 = Override then syntax_error (); - (mkloc _5 (rhs_loc 5), Private, Cfk_virtual _7), _2 ) -# 8379 "parsing/parser.ml" - : 'method_)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 6 : 'override_flag) in - let _2 = (Parsing.peek_val __caml_parser_env 5 : 'attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : 'private_flag) in - let _5 = (Parsing.peek_val __caml_parser_env 2 : 'label) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'poly_type) in - Obj.repr( -# 1130 "parsing/parser.mly" - ( if _1 = Override then syntax_error (); - (mkloc _5 (rhs_loc 5), _4, Cfk_virtual _7), _2 ) -# 8391 "parsing/parser.ml" - : 'method_)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'override_flag) in - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'private_flag) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'label) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'strict_binding) in - Obj.repr( -# 1133 "parsing/parser.mly" - ( (mkloc _4 (rhs_loc 4), _3, - Cfk_concrete (_1, ghexp(Pexp_poly (_5, None)))), _2 ) -# 8403 "parsing/parser.ml" - : 'method_)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 7 : 'override_flag) in - let _2 = (Parsing.peek_val __caml_parser_env 6 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 5 : 'private_flag) in - let _4 = (Parsing.peek_val __caml_parser_env 4 : 'label) in - let _6 = (Parsing.peek_val __caml_parser_env 2 : 'poly_type) in - let _8 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1136 "parsing/parser.mly" - ( (mkloc _4 (rhs_loc 4), _3, - Cfk_concrete (_1, ghexp(Pexp_poly(_8, Some _6)))), _2 ) -# 8416 "parsing/parser.ml" - : 'method_)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 10 : 'override_flag) in - let _2 = (Parsing.peek_val __caml_parser_env 9 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 8 : 'private_flag) in - let _4 = (Parsing.peek_val __caml_parser_env 7 : 'label) in - let _7 = (Parsing.peek_val __caml_parser_env 4 : 'lident_list) in - let _9 = (Parsing.peek_val __caml_parser_env 2 : 'core_type) in - let _11 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1140 "parsing/parser.mly" - ( let exp, poly = wrap_type_annotation _7 _9 _11 in - (mkloc _4 (rhs_loc 4), _3, - Cfk_concrete (_1, ghexp(Pexp_poly(exp, Some poly)))), _2 ) -# 8431 "parsing/parser.ml" - : 'method_)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'class_signature) in - Obj.repr( -# 1149 "parsing/parser.mly" - ( _1 ) -# 8438 "parsing/parser.ml" - : 'class_type)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 4 : string) in - let _4 = (Parsing.peek_val __caml_parser_env 2 : 'simple_core_type_or_tuple) in - let _6 = (Parsing.peek_val __caml_parser_env 0 : 'class_type) in - Obj.repr( -# 1152 "parsing/parser.mly" - ( mkcty(Pcty_arrow(Optional _2 , _4, _6)) ) -# 8447 "parsing/parser.ml" - : 'class_type)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'simple_core_type_or_tuple) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'class_type) in - Obj.repr( -# 1154 "parsing/parser.mly" - ( mkcty(Pcty_arrow(Optional _1, _2, _4)) ) -# 8456 "parsing/parser.ml" - : 'class_type)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : string) in - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'simple_core_type_or_tuple) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'class_type) in - Obj.repr( -# 1156 "parsing/parser.mly" - ( mkcty(Pcty_arrow(Labelled _1, _3, _5)) ) -# 8465 "parsing/parser.ml" - : 'class_type)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'simple_core_type_or_tuple) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'class_type) in - Obj.repr( -# 1158 "parsing/parser.mly" - ( mkcty(Pcty_arrow(Nolabel, _1, _3)) ) -# 8473 "parsing/parser.ml" - : 'class_type)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'core_type_comma_list) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'clty_longident) in - Obj.repr( -# 1162 "parsing/parser.mly" - ( mkcty(Pcty_constr (mkloc _4 (rhs_loc 4), List.rev _2)) ) -# 8481 "parsing/parser.ml" - : 'class_signature)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'clty_longident) in - Obj.repr( -# 1164 "parsing/parser.mly" - ( mkcty(Pcty_constr (mkrhs _1 1, [])) ) -# 8488 "parsing/parser.ml" - : 'class_signature)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'class_sig_body) in - Obj.repr( -# 1166 "parsing/parser.mly" - ( mkcty ~attrs:_2 (Pcty_signature _3) ) -# 8496 "parsing/parser.ml" - : 'class_signature)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'class_sig_body) in - Obj.repr( -# 1168 "parsing/parser.mly" - ( unclosed "object" 1 "end" 4 ) -# 8504 "parsing/parser.ml" - : 'class_signature)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'class_signature) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attribute) in - Obj.repr( -# 1170 "parsing/parser.mly" - ( Cty.attr _1 _2 ) -# 8512 "parsing/parser.ml" - : 'class_signature)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'extension) in - Obj.repr( -# 1172 "parsing/parser.mly" - ( mkcty(Pcty_extension _1) ) -# 8519 "parsing/parser.ml" - : 'class_signature)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'override_flag) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : 'attributes) in - let _5 = (Parsing.peek_val __caml_parser_env 2 : 'mod_longident) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'class_signature) in - Obj.repr( -# 1174 "parsing/parser.mly" - ( wrap_class_type_attrs (mkcty(Pcty_open(_3, mkrhs _5 5, _7))) _4 ) -# 8529 "parsing/parser.ml" - : 'class_signature)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'class_self_type) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'class_sig_fields) in - Obj.repr( -# 1178 "parsing/parser.mly" - ( Csig.mk _1 (extra_csig 2 (List.rev _2)) ) -# 8537 "parsing/parser.ml" - : 'class_sig_body)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'core_type) in - Obj.repr( -# 1182 "parsing/parser.mly" - ( _2 ) -# 8544 "parsing/parser.ml" - : 'class_self_type)) -; (fun __caml_parser_env -> - Obj.repr( -# 1184 "parsing/parser.mly" - ( mktyp(Ptyp_any) ) -# 8550 "parsing/parser.ml" - : 'class_self_type)) -; (fun __caml_parser_env -> - Obj.repr( -# 1187 "parsing/parser.mly" - ( [] ) -# 8556 "parsing/parser.ml" - : 'class_sig_fields)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'class_sig_fields) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'class_sig_field) in - Obj.repr( -# 1188 "parsing/parser.mly" - ( _2 :: (text_csig 2) @ _1 ) -# 8564 "parsing/parser.ml" - : 'class_sig_fields)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'class_signature) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1192 "parsing/parser.mly" - ( mkctf (Pctf_inherit _3) ~attrs:(_2@_4) ~docs:(symbol_docs ()) ) -# 8573 "parsing/parser.ml" - : 'class_sig_field)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'value_type) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1194 "parsing/parser.mly" - ( mkctf (Pctf_val _3) ~attrs:(_2@_4) ~docs:(symbol_docs ()) ) -# 8582 "parsing/parser.ml" - : 'class_sig_field)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 5 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'private_virtual_flags) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : 'label) in - let _6 = (Parsing.peek_val __caml_parser_env 1 : 'poly_type) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1197 "parsing/parser.mly" - ( - let (p, v) = _3 in - mkctf (Pctf_method (mkrhs _4 4, p, v, _6)) ~attrs:(_2@_7) ~docs:(symbol_docs ()) - ) -# 8596 "parsing/parser.ml" - : 'class_sig_field)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'constrain_field) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1202 "parsing/parser.mly" - ( mkctf (Pctf_constraint _3) ~attrs:(_2@_4) ~docs:(symbol_docs ()) ) -# 8605 "parsing/parser.ml" - : 'class_sig_field)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'item_extension) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1204 "parsing/parser.mly" - ( mkctf (Pctf_extension _1) ~attrs:_2 ~docs:(symbol_docs ()) ) -# 8613 "parsing/parser.ml" - : 'class_sig_field)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'floating_attribute) in - Obj.repr( -# 1206 "parsing/parser.mly" - ( mark_symbol_docs (); - mkctf(Pctf_attribute _1) ) -# 8621 "parsing/parser.ml" - : 'class_sig_field)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'mutable_flag) in - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'label) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in - Obj.repr( -# 1211 "parsing/parser.mly" - ( mkrhs _3 3, _2, Virtual, _5 ) -# 8630 "parsing/parser.ml" - : 'value_type)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'virtual_flag) in - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'label) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in - Obj.repr( -# 1213 "parsing/parser.mly" - ( mkrhs _3 3, Mutable, _2, _5 ) -# 8639 "parsing/parser.ml" - : 'value_type)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'label) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in - Obj.repr( -# 1215 "parsing/parser.mly" - ( mkrhs _1 1, Immutable, Concrete, _3 ) -# 8647 "parsing/parser.ml" - : 'value_type)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'core_type) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in - Obj.repr( -# 1218 "parsing/parser.mly" - ( _1, _3, symbol_rloc() ) -# 8655 "parsing/parser.ml" - : 'constrain)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'core_type) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in - Obj.repr( -# 1221 "parsing/parser.mly" - ( _1, _3 ) -# 8663 "parsing/parser.ml" - : 'constrain_field)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'class_description) in - Obj.repr( -# 1225 "parsing/parser.mly" - ( let (body, ext) = _1 in ([body],ext) ) -# 8670 "parsing/parser.ml" - : 'class_descriptions)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'class_descriptions) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'and_class_description) in - Obj.repr( -# 1227 "parsing/parser.mly" - ( let (l, ext) = _1 in (_2 :: l, ext) ) -# 8678 "parsing/parser.ml" - : 'class_descriptions)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 6 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 5 : 'virtual_flag) in - let _4 = (Parsing.peek_val __caml_parser_env 4 : 'class_type_parameters) in - let _5 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _7 = (Parsing.peek_val __caml_parser_env 1 : 'class_type) in - let _8 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1232 "parsing/parser.mly" - ( let (ext, attrs) = _2 in - Ci.mk (mkrhs _5 5) _7 ~virt:_3 ~params:_4 ~attrs:(attrs @ _8) - ~loc:(symbol_rloc ()) ~docs:(symbol_docs ()) - , ext ) -# 8693 "parsing/parser.ml" - : 'class_description)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 6 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 5 : 'virtual_flag) in - let _4 = (Parsing.peek_val __caml_parser_env 4 : 'class_type_parameters) in - let _5 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _7 = (Parsing.peek_val __caml_parser_env 1 : 'class_type) in - let _8 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1240 "parsing/parser.mly" - ( Ci.mk (mkrhs _5 5) _7 ~virt:_3 ~params:_4 - ~attrs:(_2@_8) ~loc:(symbol_rloc ()) - ~text:(symbol_text ()) ~docs:(symbol_docs ()) ) -# 8707 "parsing/parser.ml" - : 'and_class_description)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'class_type_declaration) in - Obj.repr( -# 1246 "parsing/parser.mly" - ( let (body, ext) = _1 in ([body],ext) ) -# 8714 "parsing/parser.ml" - : 'class_type_declarations)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'class_type_declarations) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'and_class_type_declaration) in - Obj.repr( -# 1248 "parsing/parser.mly" - ( let (l, ext) = _1 in (_2 :: l, ext) ) -# 8722 "parsing/parser.ml" - : 'class_type_declarations)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 6 : 'ext_attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 5 : 'virtual_flag) in - let _5 = (Parsing.peek_val __caml_parser_env 4 : 'class_type_parameters) in - let _6 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _8 = (Parsing.peek_val __caml_parser_env 1 : 'class_signature) in - let _9 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1253 "parsing/parser.mly" - ( let (ext, attrs) = _3 in - Ci.mk (mkrhs _6 6) _8 ~virt:_4 ~params:_5 ~attrs:(attrs@_9) - ~loc:(symbol_rloc ()) ~docs:(symbol_docs ()) - , ext) -# 8737 "parsing/parser.ml" - : 'class_type_declaration)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 6 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 5 : 'virtual_flag) in - let _4 = (Parsing.peek_val __caml_parser_env 4 : 'class_type_parameters) in - let _5 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _7 = (Parsing.peek_val __caml_parser_env 1 : 'class_signature) in - let _8 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1261 "parsing/parser.mly" - ( Ci.mk (mkrhs _5 5) _7 ~virt:_3 ~params:_4 - ~attrs:(_2@_8) ~loc:(symbol_rloc ()) - ~text:(symbol_text ()) ~docs:(symbol_docs ()) ) -# 8751 "parsing/parser.ml" - : 'and_class_type_declaration)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1269 "parsing/parser.mly" - ( _1 ) -# 8758 "parsing/parser.ml" - : 'seq_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in - Obj.repr( -# 1270 "parsing/parser.mly" - ( _1 ) -# 8765 "parsing/parser.ml" - : 'seq_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1271 "parsing/parser.mly" - ( mkexp(Pexp_sequence(_1, _3)) ) -# 8773 "parsing/parser.ml" - : 'seq_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'expr) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'attr_id) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1273 "parsing/parser.mly" - ( let seq = mkexp(Pexp_sequence (_1, _5)) in - let payload = PStr [mkstrexp seq []] in - mkexp (Pexp_extension (_4, payload)) ) -# 8784 "parsing/parser.ml" - : 'seq_expr)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'label_let_pattern) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'opt_default) in - Obj.repr( -# 1279 "parsing/parser.mly" - ( (Optional (fst _3), _4, snd _3) ) -# 8792 "parsing/parser.ml" - : 'labeled_simple_pattern)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'label_var) in - Obj.repr( -# 1281 "parsing/parser.mly" - ( (Optional (fst _2), None, snd _2) ) -# 8799 "parsing/parser.ml" - : 'labeled_simple_pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : string) in - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'let_pattern) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'opt_default) in - Obj.repr( -# 1283 "parsing/parser.mly" - ( (Optional _1, _4, _3) ) -# 8808 "parsing/parser.ml" - : 'labeled_simple_pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : string) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'pattern_var) in - Obj.repr( -# 1285 "parsing/parser.mly" - ( (Optional _1, None, _2) ) -# 8816 "parsing/parser.ml" - : 'labeled_simple_pattern)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'label_let_pattern) in - Obj.repr( -# 1287 "parsing/parser.mly" - ( (Labelled (fst _3), None, snd _3) ) -# 8823 "parsing/parser.ml" - : 'labeled_simple_pattern)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'label_var) in - Obj.repr( -# 1289 "parsing/parser.mly" - ( (Labelled (fst _2), None, snd _2) ) -# 8830 "parsing/parser.ml" - : 'labeled_simple_pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : string) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'simple_pattern) in - Obj.repr( -# 1291 "parsing/parser.mly" - ( (Labelled _1, None, _2) ) -# 8838 "parsing/parser.ml" - : 'labeled_simple_pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_pattern) in - Obj.repr( -# 1293 "parsing/parser.mly" - ( (Nolabel, None, _1) ) -# 8845 "parsing/parser.ml" - : 'labeled_simple_pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 1296 "parsing/parser.mly" - ( mkpat(Ppat_var (mkrhs _1 1)) ) -# 8852 "parsing/parser.ml" - : 'pattern_var)) -; (fun __caml_parser_env -> - Obj.repr( -# 1297 "parsing/parser.mly" - ( mkpat Ppat_any ) -# 8858 "parsing/parser.ml" - : 'pattern_var)) -; (fun __caml_parser_env -> - Obj.repr( -# 1300 "parsing/parser.mly" - ( None ) -# 8864 "parsing/parser.ml" - : 'opt_default)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1301 "parsing/parser.mly" - ( Some _2 ) -# 8871 "parsing/parser.ml" - : 'opt_default)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'label_var) in - Obj.repr( -# 1305 "parsing/parser.mly" - ( _1 ) -# 8878 "parsing/parser.ml" - : 'label_let_pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'label_var) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in - Obj.repr( -# 1307 "parsing/parser.mly" - ( let (lab, pat) = _1 in (lab, mkpat(Ppat_constraint(pat, _3))) ) -# 8886 "parsing/parser.ml" - : 'label_let_pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 1310 "parsing/parser.mly" - ( (_1, mkpat(Ppat_var (mkrhs _1 1))) ) -# 8893 "parsing/parser.ml" - : 'label_var)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in - Obj.repr( -# 1314 "parsing/parser.mly" - ( _1 ) -# 8900 "parsing/parser.ml" - : 'let_pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in - Obj.repr( -# 1316 "parsing/parser.mly" - ( mkpat(Ppat_constraint(_1, _3)) ) -# 8908 "parsing/parser.ml" - : 'let_pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in - Obj.repr( -# 1320 "parsing/parser.mly" - ( _1 ) -# 8915 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'simple_expr) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'simple_labeled_expr_list) in - Obj.repr( -# 1322 "parsing/parser.mly" - ( mkexp(Pexp_apply(_1, List.rev _2)) ) -# 8923 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'let_bindings) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1324 "parsing/parser.mly" - ( expr_of_let_bindings _1 _3 ) -# 8931 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _5 = (Parsing.peek_val __caml_parser_env 2 : 'module_binding_body) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1326 "parsing/parser.mly" - ( mkexp_attrs (Pexp_letmodule(mkrhs _4 4, _5, _7)) _3 ) -# 8941 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 3 : 'ext_attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 2 : 'let_exception_declaration) in - let _6 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1328 "parsing/parser.mly" - ( mkexp_attrs (Pexp_letexception(_4, _6)) _3 ) -# 8950 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'override_flag) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : 'ext_attributes) in - let _5 = (Parsing.peek_val __caml_parser_env 2 : 'mod_longident) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1330 "parsing/parser.mly" - ( mkexp_attrs (Pexp_open(_3, mkrhs _5 5, _7)) _4 ) -# 8960 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'opt_bar) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'match_cases) in - Obj.repr( -# 1332 "parsing/parser.mly" - ( mkexp_attrs (Pexp_function(List.rev _4)) _2 ) -# 8969 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'labeled_simple_pattern) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'fun_def) in - Obj.repr( -# 1334 "parsing/parser.mly" - ( let (l,o,p) = _3 in - mkexp_attrs (Pexp_fun(l, o, p, _4)) _2 ) -# 8979 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 5 : 'ext_attributes) in - let _5 = (Parsing.peek_val __caml_parser_env 2 : 'lident_list) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'fun_def) in - Obj.repr( -# 1337 "parsing/parser.mly" - ( mkexp_attrs (mk_newtypes _5 _7).pexp_desc _2 ) -# 8988 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 3 : 'seq_expr) in - let _5 = (Parsing.peek_val __caml_parser_env 1 : 'opt_bar) in - let _6 = (Parsing.peek_val __caml_parser_env 0 : 'match_cases) in - Obj.repr( -# 1339 "parsing/parser.mly" - ( mkexp_attrs (Pexp_match(_3, List.rev _6)) _2 ) -# 8998 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 3 : 'seq_expr) in - let _5 = (Parsing.peek_val __caml_parser_env 1 : 'opt_bar) in - let _6 = (Parsing.peek_val __caml_parser_env 0 : 'match_cases) in - Obj.repr( -# 1341 "parsing/parser.mly" - ( mkexp_attrs (Pexp_try(_3, List.rev _6)) _2 ) -# 9008 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'seq_expr) in - Obj.repr( -# 1343 "parsing/parser.mly" - ( syntax_error() ) -# 9016 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'expr_comma_list) in - Obj.repr( -# 1345 "parsing/parser.mly" - ( mkexp(Pexp_tuple(List.rev _1)) ) -# 9023 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'constr_longident) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in - Obj.repr( -# 1347 "parsing/parser.mly" - ( mkexp(Pexp_construct(mkrhs _1 1, Some _2)) ) -# 9031 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'name_tag) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in - Obj.repr( -# 1349 "parsing/parser.mly" - ( mkexp(Pexp_variant(_1, Some _2)) ) -# 9039 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 5 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'seq_expr) in - let _5 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1351 "parsing/parser.mly" - ( mkexp_attrs(Pexp_ifthenelse(_3, _5, Some _7)) _2 ) -# 9049 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'seq_expr) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1353 "parsing/parser.mly" - ( mkexp_attrs (Pexp_ifthenelse(_3, _5, None)) _2 ) -# 9058 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 3 : 'seq_expr) in - let _5 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in - Obj.repr( -# 1355 "parsing/parser.mly" - ( mkexp_attrs (Pexp_while(_3, _5)) _2 ) -# 9067 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 8 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 7 : 'pattern) in - let _5 = (Parsing.peek_val __caml_parser_env 5 : 'seq_expr) in - let _6 = (Parsing.peek_val __caml_parser_env 4 : 'direction_flag) in - let _7 = (Parsing.peek_val __caml_parser_env 3 : 'seq_expr) in - let _9 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in - Obj.repr( -# 1358 "parsing/parser.mly" - ( mkexp_attrs(Pexp_for(_3, _5, _7, _6, _9)) _2 ) -# 9079 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1360 "parsing/parser.mly" - ( mkexp_cons (rhs_loc 2) (ghexp(Pexp_tuple[_1;_3])) (symbol_rloc()) ) -# 9087 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _2 = (Parsing.peek_val __caml_parser_env 1 : string) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1362 "parsing/parser.mly" - ( mkinfix _1 _2 _3 ) -# 9096 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _2 = (Parsing.peek_val __caml_parser_env 1 : string) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1364 "parsing/parser.mly" - ( mkinfix _1 _2 _3 ) -# 9105 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _2 = (Parsing.peek_val __caml_parser_env 1 : string) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1366 "parsing/parser.mly" - ( mkinfix _1 _2 _3 ) -# 9114 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _2 = (Parsing.peek_val __caml_parser_env 1 : string) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1368 "parsing/parser.mly" - ( mkinfix _1 _2 _3 ) -# 9123 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _2 = (Parsing.peek_val __caml_parser_env 1 : string) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1370 "parsing/parser.mly" - ( mkinfix _1 _2 _3 ) -# 9132 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1372 "parsing/parser.mly" - ( mkinfix _1 "+" _3 ) -# 9140 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1374 "parsing/parser.mly" - ( mkinfix _1 "+." _3 ) -# 9148 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1376 "parsing/parser.mly" - ( mkinfix _1 "+=" _3 ) -# 9156 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1378 "parsing/parser.mly" - ( mkinfix _1 "-" _3 ) -# 9164 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1380 "parsing/parser.mly" - ( mkinfix _1 "-." _3 ) -# 9172 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1382 "parsing/parser.mly" - ( mkinfix _1 "*" _3 ) -# 9180 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1384 "parsing/parser.mly" - ( mkinfix _1 "%" _3 ) -# 9188 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1386 "parsing/parser.mly" - ( mkinfix _1 "=" _3 ) -# 9196 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1388 "parsing/parser.mly" - ( mkinfix _1 "<" _3 ) -# 9204 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1390 "parsing/parser.mly" - ( mkinfix _1 ">" _3 ) -# 9212 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1392 "parsing/parser.mly" - ( mkinfix _1 "or" _3 ) -# 9220 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1394 "parsing/parser.mly" - ( mkinfix _1 "||" _3 ) -# 9228 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1396 "parsing/parser.mly" - ( mkinfix _1 "&" _3 ) -# 9236 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1398 "parsing/parser.mly" - ( mkinfix _1 "&&" _3 ) -# 9244 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1400 "parsing/parser.mly" - ( mkinfix _1 ":=" _3 ) -# 9252 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'subtractive) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1402 "parsing/parser.mly" - ( mkuminus _1 _2 ) -# 9260 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'additive) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1404 "parsing/parser.mly" - ( mkuplus _1 _2 ) -# 9268 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'label_longident) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1406 "parsing/parser.mly" - ( mkexp(Pexp_setfield(_1, mkrhs _3 3, _5)) ) -# 9277 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : 'seq_expr) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1408 "parsing/parser.mly" - ( mkexp(Pexp_apply(ghexp(Pexp_ident(array_function "Array" "set")), - [Nolabel,_1; Nolabel,_4; Nolabel,_7])) ) -# 9287 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : 'seq_expr) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1411 "parsing/parser.mly" - ( mkexp(Pexp_apply(ghexp(Pexp_ident(array_function "String" "set")), - [Nolabel,_1; Nolabel,_4; Nolabel,_7])) ) -# 9297 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : 'expr) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1414 "parsing/parser.mly" - ( bigarray_set _1 _4 _7 ) -# 9306 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in - let _2 = (Parsing.peek_val __caml_parser_env 5 : string) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : 'expr) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1416 "parsing/parser.mly" - ( let id = mkexp @@ Pexp_ident( ghloc @@ Lident ("." ^ _2 ^ "[]<-")) in - mkexp @@ Pexp_apply(id , [Nolabel, _1; Nolabel, _4; Nolabel, _7]) ) -# 9317 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in - let _2 = (Parsing.peek_val __caml_parser_env 5 : string) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : 'expr) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1419 "parsing/parser.mly" - ( let id = mkexp @@ Pexp_ident( ghloc @@ Lident ("." ^ _2 ^ "()<-")) in - mkexp @@ Pexp_apply(id , [Nolabel, _1; Nolabel, _4; Nolabel, _7]) ) -# 9328 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in - let _2 = (Parsing.peek_val __caml_parser_env 5 : string) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : 'expr) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1422 "parsing/parser.mly" - ( let id = mkexp @@ Pexp_ident( ghloc @@ Lident ("." ^ _2 ^ "{}<-")) in - mkexp @@ Pexp_apply(id , [Nolabel, _1; Nolabel, _4; Nolabel, _7]) ) -# 9339 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 8 : 'simple_expr) in - let _3 = (Parsing.peek_val __caml_parser_env 6 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 5 : string) in - let _6 = (Parsing.peek_val __caml_parser_env 3 : 'expr) in - let _9 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1425 "parsing/parser.mly" - ( let id = mkexp @@ Pexp_ident( ghloc @@ Ldot(_3,"." ^ _4 ^ "[]<-")) in - mkexp @@ Pexp_apply(id , [Nolabel, _1; Nolabel, _6; Nolabel, _9]) ) -# 9351 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 8 : 'simple_expr) in - let _3 = (Parsing.peek_val __caml_parser_env 6 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 5 : string) in - let _6 = (Parsing.peek_val __caml_parser_env 3 : 'expr) in - let _9 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1428 "parsing/parser.mly" - ( let id = mkexp @@ Pexp_ident( ghloc @@ Ldot(_3, "." ^ _4 ^ "()<-")) in - mkexp @@ Pexp_apply(id , [Nolabel, _1; Nolabel, _6; Nolabel, _9]) ) -# 9363 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 8 : 'simple_expr) in - let _3 = (Parsing.peek_val __caml_parser_env 6 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 5 : string) in - let _6 = (Parsing.peek_val __caml_parser_env 3 : 'expr) in - let _9 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1431 "parsing/parser.mly" - ( let id = mkexp @@ Pexp_ident( ghloc @@ Ldot(_3, "." ^ _4 ^ "{}<-")) in - mkexp @@ Pexp_apply(id , [Nolabel, _1; Nolabel, _6; Nolabel, _9]) ) -# 9375 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'label) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1434 "parsing/parser.mly" - ( mkexp(Pexp_setinstvar(mkrhs _1 1, _3)) ) -# 9383 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in - Obj.repr( -# 1436 "parsing/parser.mly" - ( mkexp_attrs (Pexp_assert _3) _2 ) -# 9391 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in - Obj.repr( -# 1438 "parsing/parser.mly" - ( mkexp_attrs (Pexp_lazy _3) _2 ) -# 9399 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'class_structure) in - Obj.repr( -# 1440 "parsing/parser.mly" - ( mkexp_attrs (Pexp_object _3) _2 ) -# 9407 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'class_structure) in - Obj.repr( -# 1442 "parsing/parser.mly" - ( unclosed "object" 1 "end" 4 ) -# 9415 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attribute) in - Obj.repr( -# 1444 "parsing/parser.mly" - ( Exp.attr _1 _2 ) -# 9423 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - Obj.repr( -# 1446 "parsing/parser.mly" - ( not_expecting 1 "wildcard \"_\"" ) -# 9429 "parsing/parser.ml" - : 'expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'val_longident) in - Obj.repr( -# 1450 "parsing/parser.mly" - ( mkexp(Pexp_ident (mkrhs _1 1)) ) -# 9436 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'constant) in - Obj.repr( -# 1452 "parsing/parser.mly" - ( mkexp(Pexp_constant _1) ) -# 9443 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'constr_longident) in - Obj.repr( -# 1454 "parsing/parser.mly" - ( mkexp(Pexp_construct(mkrhs _1 1, None)) ) -# 9450 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'name_tag) in - Obj.repr( -# 1456 "parsing/parser.mly" - ( mkexp(Pexp_variant(_1, None)) ) -# 9457 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in - Obj.repr( -# 1458 "parsing/parser.mly" - ( reloc_exp _2 ) -# 9464 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in - Obj.repr( -# 1460 "parsing/parser.mly" - ( unclosed "(" 1 ")" 3 ) -# 9471 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in - Obj.repr( -# 1462 "parsing/parser.mly" - ( wrap_exp_attrs (reloc_exp _3) _2 (* check location *) ) -# 9479 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ext_attributes) in - Obj.repr( -# 1464 "parsing/parser.mly" - ( mkexp_attrs (Pexp_construct (mkloc (Lident "()") (symbol_rloc ()), - None)) _2 ) -# 9487 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in - Obj.repr( -# 1467 "parsing/parser.mly" - ( unclosed "begin" 1 "end" 4 ) -# 9495 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'seq_expr) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'type_constraint) in - Obj.repr( -# 1469 "parsing/parser.mly" - ( mkexp_constraint _2 _3 ) -# 9503 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'simple_expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'label_longident) in - Obj.repr( -# 1471 "parsing/parser.mly" - ( mkexp(Pexp_field(_1, mkrhs _3 3)) ) -# 9511 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in - Obj.repr( -# 1473 "parsing/parser.mly" - ( mkexp(Pexp_open(Fresh, mkrhs _1 1, _4)) ) -# 9519 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 3 : 'mod_longident) in - Obj.repr( -# 1475 "parsing/parser.mly" - ( mkexp(Pexp_open(Fresh, mkrhs _1 1, - mkexp(Pexp_construct(mkrhs (Lident "()") 1, None)))) ) -# 9527 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in - Obj.repr( -# 1478 "parsing/parser.mly" - ( unclosed "(" 3 ")" 5 ) -# 9535 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in - Obj.repr( -# 1480 "parsing/parser.mly" - ( mkexp(Pexp_apply(ghexp(Pexp_ident(array_function "Array" "get")), - [Nolabel,_1; Nolabel,_4])) ) -# 9544 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in - Obj.repr( -# 1483 "parsing/parser.mly" - ( unclosed "(" 3 ")" 5 ) -# 9552 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in - Obj.repr( -# 1485 "parsing/parser.mly" - ( mkexp(Pexp_apply(ghexp(Pexp_ident(array_function "String" "get")), - [Nolabel,_1; Nolabel,_4])) ) -# 9561 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in - Obj.repr( -# 1488 "parsing/parser.mly" - ( unclosed "[" 3 "]" 5 ) -# 9569 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in - let _2 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in - Obj.repr( -# 1490 "parsing/parser.mly" - ( let id = mkexp @@ Pexp_ident( ghloc @@ Lident ("." ^ _2 ^ "[]")) in - mkexp @@ Pexp_apply(id, [Nolabel, _1; Nolabel, _4]) ) -# 9579 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in - let _2 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in - Obj.repr( -# 1493 "parsing/parser.mly" - ( unclosed "[" 3 "]" 5 ) -# 9588 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in - let _2 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in - Obj.repr( -# 1495 "parsing/parser.mly" - ( let id = mkexp @@ Pexp_ident( ghloc @@ Lident ("." ^ _2 ^ "()")) in - mkexp @@ Pexp_apply(id, [Nolabel, _1; Nolabel, _4]) ) -# 9598 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in - let _2 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in - Obj.repr( -# 1498 "parsing/parser.mly" - ( unclosed "(" 3 ")" 5 ) -# 9607 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in - let _2 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in - Obj.repr( -# 1500 "parsing/parser.mly" - ( let id = mkexp @@ Pexp_ident( ghloc @@ Lident ("." ^ _2 ^ "{}")) in - mkexp @@ Pexp_apply(id, [Nolabel, _1; Nolabel, _4]) ) -# 9617 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in - let _2 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in - Obj.repr( -# 1503 "parsing/parser.mly" - ( unclosed "{" 3 "}" 5 ) -# 9626 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _6 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in - Obj.repr( -# 1505 "parsing/parser.mly" - ( let id = mkexp @@ Pexp_ident( ghloc @@ Ldot(_3, "." ^ _4 ^ "[]")) in - mkexp @@ Pexp_apply(id, [Nolabel, _1; Nolabel, _6]) ) -# 9637 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _6 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in - Obj.repr( -# 1508 "parsing/parser.mly" - ( unclosed "[" 5 "]" 7 ) -# 9647 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _6 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in - Obj.repr( -# 1510 "parsing/parser.mly" - ( let id = mkexp @@ Pexp_ident( ghloc @@ Ldot(_3, "." ^ _4 ^ "()")) in - mkexp @@ Pexp_apply(id, [Nolabel, _1; Nolabel, _6]) ) -# 9658 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _6 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in - Obj.repr( -# 1513 "parsing/parser.mly" - ( unclosed "(" 5 ")" 7 ) -# 9668 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _6 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in - Obj.repr( -# 1515 "parsing/parser.mly" - ( let id = mkexp @@ Pexp_ident( ghloc @@ Ldot(_3, "." ^ _4 ^ "{}")) in - mkexp @@ Pexp_apply(id, [Nolabel, _1; Nolabel, _6]) ) -# 9679 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _6 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in - Obj.repr( -# 1518 "parsing/parser.mly" - ( unclosed "{" 5 "}" 7 ) -# 9689 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in - Obj.repr( -# 1520 "parsing/parser.mly" - ( bigarray_get _1 _4 ) -# 9697 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'expr_comma_list) in - Obj.repr( -# 1522 "parsing/parser.mly" - ( unclosed "{" 3 "}" 5 ) -# 9705 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'record_expr) in - Obj.repr( -# 1524 "parsing/parser.mly" - ( let (exten, fields) = _2 in mkexp (Pexp_record(fields, exten)) ) -# 9712 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'record_expr) in - Obj.repr( -# 1526 "parsing/parser.mly" - ( unclosed "{" 1 "}" 3 ) -# 9719 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'record_expr) in - Obj.repr( -# 1528 "parsing/parser.mly" - ( let (exten, fields) = _4 in - let rec_exp = mkexp(Pexp_record(fields, exten)) in - mkexp(Pexp_open(Fresh, mkrhs _1 1, rec_exp)) ) -# 9729 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'record_expr) in - Obj.repr( -# 1532 "parsing/parser.mly" - ( unclosed "{" 3 "}" 5 ) -# 9737 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'expr_semi_list) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in - Obj.repr( -# 1534 "parsing/parser.mly" - ( mkexp (Pexp_array(List.rev _2)) ) -# 9745 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'expr_semi_list) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in - Obj.repr( -# 1536 "parsing/parser.mly" - ( unclosed "[|" 1 "|]" 4 ) -# 9753 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - Obj.repr( -# 1538 "parsing/parser.mly" - ( mkexp (Pexp_array []) ) -# 9759 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 5 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 2 : 'expr_semi_list) in - let _5 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in - Obj.repr( -# 1540 "parsing/parser.mly" - ( mkexp(Pexp_open(Fresh, mkrhs _1 1, mkexp(Pexp_array(List.rev _4)))) ) -# 9768 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 3 : 'mod_longident) in - Obj.repr( -# 1542 "parsing/parser.mly" - ( mkexp(Pexp_open(Fresh, mkrhs _1 1, mkexp(Pexp_array []))) ) -# 9775 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 5 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 2 : 'expr_semi_list) in - let _5 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in - Obj.repr( -# 1544 "parsing/parser.mly" - ( unclosed "[|" 3 "|]" 6 ) -# 9784 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'expr_semi_list) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in - Obj.repr( -# 1546 "parsing/parser.mly" - ( reloc_exp (mktailexp (rhs_loc 4) (List.rev _2)) ) -# 9792 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'expr_semi_list) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in - Obj.repr( -# 1548 "parsing/parser.mly" - ( unclosed "[" 1 "]" 4 ) -# 9800 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 5 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 2 : 'expr_semi_list) in - let _5 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in - Obj.repr( -# 1550 "parsing/parser.mly" - ( let list_exp = reloc_exp (mktailexp (rhs_loc 6) (List.rev _4)) in - mkexp(Pexp_open(Fresh, mkrhs _1 1, list_exp)) ) -# 9810 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 3 : 'mod_longident) in - Obj.repr( -# 1553 "parsing/parser.mly" - ( mkexp(Pexp_open(Fresh, mkrhs _1 1, - mkexp(Pexp_construct(mkrhs (Lident "[]") 1, None)))) ) -# 9818 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 5 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 2 : 'expr_semi_list) in - let _5 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in - Obj.repr( -# 1556 "parsing/parser.mly" - ( unclosed "[" 3 "]" 6 ) -# 9827 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : string) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in - Obj.repr( -# 1558 "parsing/parser.mly" - ( mkexp(Pexp_apply(mkoperator _1 1, [Nolabel,_2])) ) -# 9835 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in - Obj.repr( -# 1560 "parsing/parser.mly" - ( mkexp(Pexp_apply(mkoperator "!" 1, [Nolabel,_2])) ) -# 9842 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'class_longident) in - Obj.repr( -# 1562 "parsing/parser.mly" - ( mkexp_attrs (Pexp_new(mkrhs _3 3)) _2 ) -# 9850 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'field_expr_list) in - Obj.repr( -# 1564 "parsing/parser.mly" - ( mkexp (Pexp_override _2) ) -# 9857 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'field_expr_list) in - Obj.repr( -# 1566 "parsing/parser.mly" - ( unclosed "{<" 1 ">}" 3 ) -# 9864 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - Obj.repr( -# 1568 "parsing/parser.mly" - ( mkexp (Pexp_override [])) -# 9870 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'field_expr_list) in - Obj.repr( -# 1570 "parsing/parser.mly" - ( mkexp(Pexp_open(Fresh, mkrhs _1 1, mkexp (Pexp_override _4)))) -# 9878 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 3 : 'mod_longident) in - Obj.repr( -# 1572 "parsing/parser.mly" - ( mkexp(Pexp_open(Fresh, mkrhs _1 1, mkexp (Pexp_override [])))) -# 9885 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'field_expr_list) in - Obj.repr( -# 1574 "parsing/parser.mly" - ( unclosed "{<" 3 ">}" 5 ) -# 9893 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'simple_expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'label) in - Obj.repr( -# 1576 "parsing/parser.mly" - ( mkexp(Pexp_send(_1, mkrhs _3 3)) ) -# 9901 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'simple_expr) in - let _2 = (Parsing.peek_val __caml_parser_env 1 : string) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in - Obj.repr( -# 1578 "parsing/parser.mly" - ( mkinfix _1 _2 _3 ) -# 9910 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'module_expr) in - Obj.repr( -# 1580 "parsing/parser.mly" - ( mkexp_attrs (Pexp_pack _4) _3 ) -# 9918 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : 'module_expr) in - let _6 = (Parsing.peek_val __caml_parser_env 1 : 'package_type) in - Obj.repr( -# 1582 "parsing/parser.mly" - ( mkexp_attrs (Pexp_constraint (ghexp (Pexp_pack _4), - ghtyp (Ptyp_package _6))) - _3 ) -# 9929 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 3 : 'ext_attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 2 : 'module_expr) in - Obj.repr( -# 1586 "parsing/parser.mly" - ( unclosed "(" 1 ")" 6 ) -# 9937 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 8 : 'mod_longident) in - let _5 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in - let _6 = (Parsing.peek_val __caml_parser_env 3 : 'module_expr) in - let _8 = (Parsing.peek_val __caml_parser_env 1 : 'package_type) in - Obj.repr( -# 1589 "parsing/parser.mly" - ( mkexp(Pexp_open(Fresh, mkrhs _1 1, - mkexp_attrs (Pexp_constraint (ghexp (Pexp_pack _6), - ghtyp (Ptyp_package _8))) - _5 )) ) -# 9950 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 7 : 'mod_longident) in - let _5 = (Parsing.peek_val __caml_parser_env 3 : 'ext_attributes) in - let _6 = (Parsing.peek_val __caml_parser_env 2 : 'module_expr) in - Obj.repr( -# 1594 "parsing/parser.mly" - ( unclosed "(" 3 ")" 8 ) -# 9959 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'extension) in - Obj.repr( -# 1596 "parsing/parser.mly" - ( mkexp (Pexp_extension _1) ) -# 9966 "parsing/parser.ml" - : 'simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'labeled_simple_expr) in - Obj.repr( -# 1600 "parsing/parser.mly" - ( [_1] ) -# 9973 "parsing/parser.ml" - : 'simple_labeled_expr_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'simple_labeled_expr_list) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'labeled_simple_expr) in - Obj.repr( -# 1602 "parsing/parser.mly" - ( _2 :: _1 ) -# 9981 "parsing/parser.ml" - : 'simple_labeled_expr_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in - Obj.repr( -# 1606 "parsing/parser.mly" - ( (Nolabel, _1) ) -# 9988 "parsing/parser.ml" - : 'labeled_simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'label_expr) in - Obj.repr( -# 1608 "parsing/parser.mly" - ( _1 ) -# 9995 "parsing/parser.ml" - : 'labeled_simple_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : string) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in - Obj.repr( -# 1612 "parsing/parser.mly" - ( (Labelled _1, _2) ) -# 10003 "parsing/parser.ml" - : 'label_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'label_ident) in - Obj.repr( -# 1614 "parsing/parser.mly" - ( (Labelled (fst _2), snd _2) ) -# 10010 "parsing/parser.ml" - : 'label_expr)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'label_ident) in - Obj.repr( -# 1616 "parsing/parser.mly" - ( (Optional (fst _2), snd _2) ) -# 10017 "parsing/parser.ml" - : 'label_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : string) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in - Obj.repr( -# 1618 "parsing/parser.mly" - ( (Optional _1, _2) ) -# 10025 "parsing/parser.ml" - : 'label_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 1621 "parsing/parser.mly" - ( (_1, mkexp(Pexp_ident(mkrhs (Lident _1) 1))) ) -# 10032 "parsing/parser.ml" - : 'label_ident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 1624 "parsing/parser.mly" - ( [mkrhs _1 1] ) -# 10039 "parsing/parser.ml" - : 'lident_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : string) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'lident_list) in - Obj.repr( -# 1625 "parsing/parser.mly" - ( mkrhs _1 1 :: _2 ) -# 10047 "parsing/parser.ml" - : 'lident_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'val_ident) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'strict_binding) in - Obj.repr( -# 1629 "parsing/parser.mly" - ( (mkpatvar _1 1, _2) ) -# 10055 "parsing/parser.ml" - : 'let_binding_body)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 3 : 'val_ident) in - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'type_constraint) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1631 "parsing/parser.mly" - ( let v = mkpatvar _1 1 in (* PR#7344 *) - let t = - match _2 with - Some t, None -> t - | _, Some t -> t - | _ -> assert false - in - (ghpat(Ppat_constraint(v, ghtyp(Ptyp_poly([],t)))), - mkexp_constraint _4 _2) ) -# 10072 "parsing/parser.ml" - : 'let_binding_body)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 6 : 'val_ident) in - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'typevar_list) in - let _5 = (Parsing.peek_val __caml_parser_env 2 : 'core_type) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1641 "parsing/parser.mly" - ( (ghpat(Ppat_constraint(mkpatvar _1 1, - ghtyp(Ptyp_poly(List.rev _3,_5)))), - _7) ) -# 10084 "parsing/parser.ml" - : 'let_binding_body)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 7 : 'val_ident) in - let _4 = (Parsing.peek_val __caml_parser_env 4 : 'lident_list) in - let _6 = (Parsing.peek_val __caml_parser_env 2 : 'core_type) in - let _8 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1645 "parsing/parser.mly" - ( let exp, poly = wrap_type_annotation _4 _6 _8 in - (ghpat(Ppat_constraint(mkpatvar _1 1, poly)), exp) ) -# 10095 "parsing/parser.ml" - : 'let_binding_body)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_no_exn) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1648 "parsing/parser.mly" - ( (_1, _3) ) -# 10103 "parsing/parser.ml" - : 'let_binding_body)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_pattern_not_ident) in - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'core_type) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1650 "parsing/parser.mly" - ( (ghpat(Ppat_constraint(_1, _3)), _5) ) -# 10112 "parsing/parser.ml" - : 'let_binding_body)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'let_binding) in - Obj.repr( -# 1653 "parsing/parser.mly" - ( _1 ) -# 10119 "parsing/parser.ml" - : 'let_bindings)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'let_bindings) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'and_let_binding) in - Obj.repr( -# 1654 "parsing/parser.mly" - ( addlb _1 _2 ) -# 10127 "parsing/parser.ml" - : 'let_bindings)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'rec_flag) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'let_binding_body) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1658 "parsing/parser.mly" - ( let (ext, attr) = _2 in - mklbs ext _3 (mklb true _4 (attr@_5)) ) -# 10138 "parsing/parser.ml" - : 'let_binding)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'let_binding_body) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1663 "parsing/parser.mly" - ( mklb false _3 (_2@_4) ) -# 10147 "parsing/parser.ml" - : 'and_let_binding)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'strict_binding) in - Obj.repr( -# 1667 "parsing/parser.mly" - ( _1 ) -# 10154 "parsing/parser.ml" - : 'fun_binding)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'type_constraint) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1669 "parsing/parser.mly" - ( mkexp_constraint _3 _1 ) -# 10162 "parsing/parser.ml" - : 'fun_binding)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1673 "parsing/parser.mly" - ( _2 ) -# 10169 "parsing/parser.ml" - : 'strict_binding)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'labeled_simple_pattern) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'fun_binding) in - Obj.repr( -# 1675 "parsing/parser.mly" - ( let (l, o, p) = _1 in ghexp(Pexp_fun(l, o, p, _2)) ) -# 10177 "parsing/parser.ml" - : 'strict_binding)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'lident_list) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'fun_binding) in - Obj.repr( -# 1677 "parsing/parser.mly" - ( mk_newtypes _3 _5 ) -# 10185 "parsing/parser.ml" - : 'strict_binding)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'match_case) in - Obj.repr( -# 1680 "parsing/parser.mly" - ( [_1] ) -# 10192 "parsing/parser.ml" - : 'match_cases)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'match_cases) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'match_case) in - Obj.repr( -# 1681 "parsing/parser.mly" - ( _3 :: _1 ) -# 10200 "parsing/parser.ml" - : 'match_cases)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1685 "parsing/parser.mly" - ( Exp.case _1 _3 ) -# 10208 "parsing/parser.ml" - : 'match_case)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'pattern) in - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'seq_expr) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1687 "parsing/parser.mly" - ( Exp.case _1 ~guard:_3 _5 ) -# 10217 "parsing/parser.ml" - : 'match_case)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in - Obj.repr( -# 1689 "parsing/parser.mly" - ( Exp.case _1 (Exp.unreachable ~loc:(rhs_loc 3) ())) -# 10224 "parsing/parser.ml" - : 'match_case)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1693 "parsing/parser.mly" - ( _2 ) -# 10231 "parsing/parser.ml" - : 'fun_def)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'simple_core_type) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 1695 "parsing/parser.mly" - ( mkexp (Pexp_constraint (_4, _2)) ) -# 10239 "parsing/parser.ml" - : 'fun_def)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'labeled_simple_pattern) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'fun_def) in - Obj.repr( -# 1698 "parsing/parser.mly" - ( - let (l,o,p) = _1 in - ghexp(Pexp_fun(l, o, p, _2)) - ) -# 10250 "parsing/parser.ml" - : 'fun_def)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'lident_list) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'fun_def) in - Obj.repr( -# 1703 "parsing/parser.mly" - ( mk_newtypes _3 _5 ) -# 10258 "parsing/parser.ml" - : 'fun_def)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr_comma_list) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1706 "parsing/parser.mly" - ( _3 :: _1 ) -# 10266 "parsing/parser.ml" - : 'expr_comma_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1707 "parsing/parser.mly" - ( [_3; _1] ) -# 10274 "parsing/parser.ml" - : 'expr_comma_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'simple_expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'lbl_expr_list) in - Obj.repr( -# 1710 "parsing/parser.mly" - ( (Some _1, _3) ) -# 10282 "parsing/parser.ml" - : 'record_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'lbl_expr_list) in - Obj.repr( -# 1711 "parsing/parser.mly" - ( (None, _1) ) -# 10289 "parsing/parser.ml" - : 'record_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'lbl_expr) in - Obj.repr( -# 1714 "parsing/parser.mly" - ( [_1] ) -# 10296 "parsing/parser.ml" - : 'lbl_expr_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'lbl_expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'lbl_expr_list) in - Obj.repr( -# 1715 "parsing/parser.mly" - ( _1 :: _3 ) -# 10304 "parsing/parser.ml" - : 'lbl_expr_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'lbl_expr) in - Obj.repr( -# 1716 "parsing/parser.mly" - ( [_1] ) -# 10311 "parsing/parser.ml" - : 'lbl_expr_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 3 : 'label_longident) in - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'opt_type_constraint) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1720 "parsing/parser.mly" - ( (mkrhs _1 1, mkexp_opt_constraint _4 _2) ) -# 10320 "parsing/parser.ml" - : 'lbl_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'label_longident) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'opt_type_constraint) in - Obj.repr( -# 1722 "parsing/parser.mly" - ( (mkrhs _1 1, mkexp_opt_constraint (exp_of_label _1 1) _2) ) -# 10328 "parsing/parser.ml" - : 'lbl_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'field_expr) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'opt_semi) in - Obj.repr( -# 1725 "parsing/parser.mly" - ( [_1] ) -# 10336 "parsing/parser.ml" - : 'field_expr_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'field_expr) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'field_expr_list) in - Obj.repr( -# 1726 "parsing/parser.mly" - ( _1 :: _3 ) -# 10344 "parsing/parser.ml" - : 'field_expr_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'label) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1730 "parsing/parser.mly" - ( (mkrhs _1 1, _3) ) -# 10352 "parsing/parser.ml" - : 'field_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'label) in - Obj.repr( -# 1732 "parsing/parser.mly" - ( (mkrhs _1 1, exp_of_label (Lident _1) 1) ) -# 10359 "parsing/parser.ml" - : 'field_expr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1735 "parsing/parser.mly" - ( [_1] ) -# 10366 "parsing/parser.ml" - : 'expr_semi_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr_semi_list) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in - Obj.repr( -# 1736 "parsing/parser.mly" - ( _3 :: _1 ) -# 10374 "parsing/parser.ml" - : 'expr_semi_list)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in - Obj.repr( -# 1739 "parsing/parser.mly" - ( (Some _2, None) ) -# 10381 "parsing/parser.ml" - : 'type_constraint)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'core_type) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in - Obj.repr( -# 1740 "parsing/parser.mly" - ( (Some _2, Some _4) ) -# 10389 "parsing/parser.ml" - : 'type_constraint)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in - Obj.repr( -# 1741 "parsing/parser.mly" - ( (None, Some _2) ) -# 10396 "parsing/parser.ml" - : 'type_constraint)) -; (fun __caml_parser_env -> - Obj.repr( -# 1742 "parsing/parser.mly" - ( syntax_error() ) -# 10402 "parsing/parser.ml" - : 'type_constraint)) -; (fun __caml_parser_env -> - Obj.repr( -# 1743 "parsing/parser.mly" - ( syntax_error() ) -# 10408 "parsing/parser.ml" - : 'type_constraint)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'type_constraint) in - Obj.repr( -# 1746 "parsing/parser.mly" - ( Some _1 ) -# 10415 "parsing/parser.ml" - : 'opt_type_constraint)) -; (fun __caml_parser_env -> - Obj.repr( -# 1747 "parsing/parser.mly" - ( None ) -# 10421 "parsing/parser.ml" - : 'opt_type_constraint)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'val_ident) in - Obj.repr( -# 1754 "parsing/parser.mly" - ( mkpat(Ppat_alias(_1, mkrhs _3 3)) ) -# 10429 "parsing/parser.ml" - : 'pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in - Obj.repr( -# 1756 "parsing/parser.mly" - ( expecting 3 "identifier" ) -# 10436 "parsing/parser.ml" - : 'pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'pattern_comma_list) in - Obj.repr( -# 1758 "parsing/parser.mly" - ( mkpat(Ppat_tuple(List.rev _1)) ) -# 10443 "parsing/parser.ml" - : 'pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in - Obj.repr( -# 1760 "parsing/parser.mly" - ( mkpat_cons (rhs_loc 2) (ghpat(Ppat_tuple[_1;_3])) (symbol_rloc()) ) -# 10451 "parsing/parser.ml" - : 'pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in - Obj.repr( -# 1762 "parsing/parser.mly" - ( expecting 3 "pattern" ) -# 10458 "parsing/parser.ml" - : 'pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in - Obj.repr( -# 1764 "parsing/parser.mly" - ( mkpat(Ppat_or(_1, _3)) ) -# 10466 "parsing/parser.ml" - : 'pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in - Obj.repr( -# 1766 "parsing/parser.mly" - ( expecting 3 "pattern" ) -# 10473 "parsing/parser.ml" - : 'pattern)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in - Obj.repr( -# 1768 "parsing/parser.mly" - ( mkpat_attrs (Ppat_exception _3) _2) -# 10481 "parsing/parser.ml" - : 'pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'pattern) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attribute) in - Obj.repr( -# 1770 "parsing/parser.mly" - ( Pat.attr _1 _2 ) -# 10489 "parsing/parser.ml" - : 'pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'pattern_gen) in - Obj.repr( -# 1771 "parsing/parser.mly" - ( _1 ) -# 10496 "parsing/parser.ml" - : 'pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_no_exn) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'val_ident) in - Obj.repr( -# 1775 "parsing/parser.mly" - ( mkpat(Ppat_alias(_1, mkrhs _3 3)) ) -# 10504 "parsing/parser.ml" - : 'pattern_no_exn)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_no_exn) in - Obj.repr( -# 1777 "parsing/parser.mly" - ( expecting 3 "identifier" ) -# 10511 "parsing/parser.ml" - : 'pattern_no_exn)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'pattern_no_exn_comma_list) in - Obj.repr( -# 1779 "parsing/parser.mly" - ( mkpat(Ppat_tuple(List.rev _1)) ) -# 10518 "parsing/parser.ml" - : 'pattern_no_exn)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_no_exn) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in - Obj.repr( -# 1781 "parsing/parser.mly" - ( mkpat_cons (rhs_loc 2) (ghpat(Ppat_tuple[_1;_3])) (symbol_rloc()) ) -# 10526 "parsing/parser.ml" - : 'pattern_no_exn)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_no_exn) in - Obj.repr( -# 1783 "parsing/parser.mly" - ( expecting 3 "pattern" ) -# 10533 "parsing/parser.ml" - : 'pattern_no_exn)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_no_exn) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in - Obj.repr( -# 1785 "parsing/parser.mly" - ( mkpat(Ppat_or(_1, _3)) ) -# 10541 "parsing/parser.ml" - : 'pattern_no_exn)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_no_exn) in - Obj.repr( -# 1787 "parsing/parser.mly" - ( expecting 3 "pattern" ) -# 10548 "parsing/parser.ml" - : 'pattern_no_exn)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'pattern_no_exn) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attribute) in - Obj.repr( -# 1789 "parsing/parser.mly" - ( Pat.attr _1 _2 ) -# 10556 "parsing/parser.ml" - : 'pattern_no_exn)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'pattern_gen) in - Obj.repr( -# 1790 "parsing/parser.mly" - ( _1 ) -# 10563 "parsing/parser.ml" - : 'pattern_no_exn)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_pattern) in - Obj.repr( -# 1794 "parsing/parser.mly" - ( _1 ) -# 10570 "parsing/parser.ml" - : 'pattern_gen)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'constr_longident) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in - Obj.repr( -# 1796 "parsing/parser.mly" - ( mkpat(Ppat_construct(mkrhs _1 1, Some _2)) ) -# 10578 "parsing/parser.ml" - : 'pattern_gen)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'name_tag) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in - Obj.repr( -# 1798 "parsing/parser.mly" - ( mkpat(Ppat_variant(_1, Some _2)) ) -# 10586 "parsing/parser.ml" - : 'pattern_gen)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'simple_pattern) in - Obj.repr( -# 1800 "parsing/parser.mly" - ( mkpat_attrs (Ppat_lazy _3) _2) -# 10594 "parsing/parser.ml" - : 'pattern_gen)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'val_ident) in - Obj.repr( -# 1804 "parsing/parser.mly" - ( mkpat(Ppat_var (mkrhs _1 1)) ) -# 10601 "parsing/parser.ml" - : 'simple_pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_pattern_not_ident) in - Obj.repr( -# 1805 "parsing/parser.mly" - ( _1 ) -# 10608 "parsing/parser.ml" - : 'simple_pattern)) -; (fun __caml_parser_env -> - Obj.repr( -# 1809 "parsing/parser.mly" - ( mkpat(Ppat_any) ) -# 10614 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'signed_constant) in - Obj.repr( -# 1811 "parsing/parser.mly" - ( mkpat(Ppat_constant _1) ) -# 10621 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'signed_constant) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'signed_constant) in - Obj.repr( -# 1813 "parsing/parser.mly" - ( mkpat(Ppat_interval (_1, _3)) ) -# 10629 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'constr_longident) in - Obj.repr( -# 1815 "parsing/parser.mly" - ( mkpat(Ppat_construct(mkrhs _1 1, None)) ) -# 10636 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'name_tag) in - Obj.repr( -# 1817 "parsing/parser.mly" - ( mkpat(Ppat_variant(_1, None)) ) -# 10643 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'type_longident) in - Obj.repr( -# 1819 "parsing/parser.mly" - ( mkpat(Ppat_type (mkrhs _2 2)) ) -# 10650 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_delimited_pattern) in - Obj.repr( -# 1821 "parsing/parser.mly" - ( _1 ) -# 10657 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'mod_longident) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'simple_delimited_pattern) in - Obj.repr( -# 1823 "parsing/parser.mly" - ( mkpat @@ Ppat_open(mkrhs _1 1, _3) ) -# 10665 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 3 : 'mod_longident) in - Obj.repr( -# 1825 "parsing/parser.mly" - ( mkpat @@ Ppat_open(mkrhs _1 1, mkpat @@ - Ppat_construct ( mkrhs (Lident "[]") 4, None)) ) -# 10673 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 3 : 'mod_longident) in - Obj.repr( -# 1828 "parsing/parser.mly" - ( mkpat @@ Ppat_open( mkrhs _1 1, mkpat @@ - Ppat_construct ( mkrhs (Lident "()") 4, None) ) ) -# 10681 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'pattern) in - Obj.repr( -# 1831 "parsing/parser.mly" - ( mkpat @@ Ppat_open (mkrhs _1 1, _4)) -# 10689 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'pattern) in - Obj.repr( -# 1833 "parsing/parser.mly" - (unclosed "(" 3 ")" 5 ) -# 10697 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 3 : 'mod_longident) in - Obj.repr( -# 1835 "parsing/parser.mly" - ( expecting 4 "pattern" ) -# 10704 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'pattern) in - Obj.repr( -# 1837 "parsing/parser.mly" - ( reloc_pat _2 ) -# 10711 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'pattern) in - Obj.repr( -# 1839 "parsing/parser.mly" - ( unclosed "(" 1 ")" 3 ) -# 10718 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'pattern) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'core_type) in - Obj.repr( -# 1841 "parsing/parser.mly" - ( mkpat(Ppat_constraint(_2, _4)) ) -# 10726 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'pattern) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'core_type) in - Obj.repr( -# 1843 "parsing/parser.mly" - ( unclosed "(" 1 ")" 5 ) -# 10734 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in - Obj.repr( -# 1845 "parsing/parser.mly" - ( expecting 4 "type" ) -# 10741 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : string) in - Obj.repr( -# 1847 "parsing/parser.mly" - ( mkpat_attrs (Ppat_unpack (mkrhs _4 4)) _3 ) -# 10749 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _6 = (Parsing.peek_val __caml_parser_env 1 : 'package_type) in - Obj.repr( -# 1849 "parsing/parser.mly" - ( mkpat_attrs - (Ppat_constraint(mkpat(Ppat_unpack (mkrhs _4 4)), - ghtyp(Ptyp_package _6))) - _3 ) -# 10761 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _6 = (Parsing.peek_val __caml_parser_env 1 : 'package_type) in - Obj.repr( -# 1854 "parsing/parser.mly" - ( unclosed "(" 1 ")" 7 ) -# 10770 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'extension) in - Obj.repr( -# 1856 "parsing/parser.mly" - ( mkpat(Ppat_extension _1) ) -# 10777 "parsing/parser.ml" - : 'simple_pattern_not_ident)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'lbl_pattern_list) in - Obj.repr( -# 1861 "parsing/parser.mly" - ( let (fields, closed) = _2 in mkpat(Ppat_record(fields, closed)) ) -# 10784 "parsing/parser.ml" - : 'simple_delimited_pattern)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'lbl_pattern_list) in - Obj.repr( -# 1863 "parsing/parser.mly" - ( unclosed "{" 1 "}" 3 ) -# 10791 "parsing/parser.ml" - : 'simple_delimited_pattern)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_semi_list) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in - Obj.repr( -# 1865 "parsing/parser.mly" - ( reloc_pat (mktailpat (rhs_loc 4) (List.rev _2)) ) -# 10799 "parsing/parser.ml" - : 'simple_delimited_pattern)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_semi_list) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in - Obj.repr( -# 1867 "parsing/parser.mly" - ( unclosed "[" 1 "]" 4 ) -# 10807 "parsing/parser.ml" - : 'simple_delimited_pattern)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_semi_list) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in - Obj.repr( -# 1869 "parsing/parser.mly" - ( mkpat(Ppat_array(List.rev _2)) ) -# 10815 "parsing/parser.ml" - : 'simple_delimited_pattern)) -; (fun __caml_parser_env -> - Obj.repr( -# 1871 "parsing/parser.mly" - ( mkpat(Ppat_array []) ) -# 10821 "parsing/parser.ml" - : 'simple_delimited_pattern)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_semi_list) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in - Obj.repr( -# 1873 "parsing/parser.mly" - ( unclosed "[|" 1 "|]" 4 ) -# 10829 "parsing/parser.ml" - : 'simple_delimited_pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_comma_list) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in - Obj.repr( -# 1876 "parsing/parser.mly" - ( _3 :: _1 ) -# 10837 "parsing/parser.ml" - : 'pattern_comma_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in - Obj.repr( -# 1877 "parsing/parser.mly" - ( [_3; _1] ) -# 10845 "parsing/parser.ml" - : 'pattern_comma_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in - Obj.repr( -# 1878 "parsing/parser.mly" - ( expecting 3 "pattern" ) -# 10852 "parsing/parser.ml" - : 'pattern_comma_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_no_exn_comma_list) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in - Obj.repr( -# 1881 "parsing/parser.mly" - ( _3 :: _1 ) -# 10860 "parsing/parser.ml" - : 'pattern_no_exn_comma_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_no_exn) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in - Obj.repr( -# 1882 "parsing/parser.mly" - ( [_3; _1] ) -# 10868 "parsing/parser.ml" - : 'pattern_no_exn_comma_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_no_exn) in - Obj.repr( -# 1883 "parsing/parser.mly" - ( expecting 3 "pattern" ) -# 10875 "parsing/parser.ml" - : 'pattern_no_exn_comma_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in - Obj.repr( -# 1886 "parsing/parser.mly" - ( [_1] ) -# 10882 "parsing/parser.ml" - : 'pattern_semi_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_semi_list) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in - Obj.repr( -# 1887 "parsing/parser.mly" - ( _3 :: _1 ) -# 10890 "parsing/parser.ml" - : 'pattern_semi_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'lbl_pattern) in - Obj.repr( -# 1890 "parsing/parser.mly" - ( [_1], Closed ) -# 10897 "parsing/parser.ml" - : 'lbl_pattern_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'lbl_pattern) in - Obj.repr( -# 1891 "parsing/parser.mly" - ( [_1], Closed ) -# 10904 "parsing/parser.ml" - : 'lbl_pattern_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 3 : 'lbl_pattern) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'opt_semi) in - Obj.repr( -# 1892 "parsing/parser.mly" - ( [_1], Open ) -# 10912 "parsing/parser.ml" - : 'lbl_pattern_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'lbl_pattern) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'lbl_pattern_list) in - Obj.repr( -# 1894 "parsing/parser.mly" - ( let (fields, closed) = _3 in _1 :: fields, closed ) -# 10920 "parsing/parser.ml" - : 'lbl_pattern_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 3 : 'label_longident) in - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'opt_pattern_type_constraint) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in - Obj.repr( -# 1898 "parsing/parser.mly" - ( (mkrhs _1 1, mkpat_opt_constraint _4 _2) ) -# 10929 "parsing/parser.ml" - : 'lbl_pattern)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'label_longident) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'opt_pattern_type_constraint) in - Obj.repr( -# 1900 "parsing/parser.mly" - ( (mkrhs _1 1, mkpat_opt_constraint (pat_of_label _1 1) _2) ) -# 10937 "parsing/parser.ml" - : 'lbl_pattern)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in - Obj.repr( -# 1903 "parsing/parser.mly" - ( Some _2 ) -# 10944 "parsing/parser.ml" - : 'opt_pattern_type_constraint)) -; (fun __caml_parser_env -> - Obj.repr( -# 1904 "parsing/parser.mly" - ( None ) -# 10950 "parsing/parser.ml" - : 'opt_pattern_type_constraint)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 3 : 'val_ident) in - let _5 = (Parsing.peek_val __caml_parser_env 1 : 'core_type) in - let _6 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1911 "parsing/parser.mly" - ( let (ext, attrs) = _2 in - Val.mk (mkrhs _3 3) _5 ~attrs:(attrs@_6) - ~loc:(symbol_rloc()) ~docs:(symbol_docs ()) - , ext ) -# 10963 "parsing/parser.ml" - : 'value_description)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string * string option) in - Obj.repr( -# 1920 "parsing/parser.mly" - ( [fst _1] ) -# 10970 "parsing/parser.ml" - : 'primitive_declaration_body)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : string * string option) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'primitive_declaration_body) in - Obj.repr( -# 1921 "parsing/parser.mly" - ( fst _1 :: _2 ) -# 10978 "parsing/parser.ml" - : 'primitive_declaration_body)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 6 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 5 : 'val_ident) in - let _5 = (Parsing.peek_val __caml_parser_env 3 : 'core_type) in - let _7 = (Parsing.peek_val __caml_parser_env 1 : 'primitive_declaration_body) in - let _8 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1926 "parsing/parser.mly" - ( let (ext, attrs) = _2 in - Val.mk (mkrhs _3 3) _5 ~prim:_7 ~attrs:(attrs@_8) - ~loc:(symbol_rloc ()) ~docs:(symbol_docs ()) - , ext ) -# 10992 "parsing/parser.ml" - : 'primitive_declaration)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'type_declaration) in - Obj.repr( -# 1936 "parsing/parser.mly" - ( let (nonrec_flag, ty, ext) = _1 in (nonrec_flag, [ty], ext) ) -# 10999 "parsing/parser.ml" - : 'type_declarations)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'type_declarations) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'and_type_declaration) in - Obj.repr( -# 1938 "parsing/parser.mly" - ( let (nonrec_flag, tys, ext) = _1 in (nonrec_flag, _2 :: tys, ext) ) -# 11007 "parsing/parser.ml" - : 'type_declarations)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 6 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 5 : 'nonrec_flag) in - let _4 = (Parsing.peek_val __caml_parser_env 4 : 'optional_type_parameters) in - let _5 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _6 = (Parsing.peek_val __caml_parser_env 2 : 'type_kind) in - let _7 = (Parsing.peek_val __caml_parser_env 1 : 'constraints) in - let _8 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1944 "parsing/parser.mly" - ( let (kind, priv, manifest) = _6 in - let (ext, attrs) = _2 in - let ty = - Type.mk (mkrhs _5 5) ~params:_4 ~cstrs:(List.rev _7) ~kind - ~priv ?manifest ~attrs:(attrs@_8) - ~loc:(symbol_rloc ()) ~docs:(symbol_docs ()) - in - (_3, ty, ext) ) -# 11027 "parsing/parser.ml" - : 'type_declaration)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 5 : 'attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'optional_type_parameters) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _5 = (Parsing.peek_val __caml_parser_env 2 : 'type_kind) in - let _6 = (Parsing.peek_val __caml_parser_env 1 : 'constraints) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 1956 "parsing/parser.mly" - ( let (kind, priv, manifest) = _5 in - Type.mk (mkrhs _4 4) ~params:_3 ~cstrs:(List.rev _6) - ~kind ~priv ?manifest ~attrs:(_2@_7) ~loc:(symbol_rloc ()) - ~text:(symbol_text ()) ~docs:(symbol_docs ()) ) -# 11042 "parsing/parser.ml" - : 'and_type_declaration)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'constraints) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'constrain) in - Obj.repr( -# 1962 "parsing/parser.mly" - ( _3 :: _1 ) -# 11050 "parsing/parser.ml" - : 'constraints)) -; (fun __caml_parser_env -> - Obj.repr( -# 1963 "parsing/parser.mly" - ( [] ) -# 11056 "parsing/parser.ml" - : 'constraints)) -; (fun __caml_parser_env -> - Obj.repr( -# 1967 "parsing/parser.mly" - ( (Ptype_abstract, Public, None) ) -# 11062 "parsing/parser.ml" - : 'type_kind)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in - Obj.repr( -# 1969 "parsing/parser.mly" - ( (Ptype_abstract, Public, Some _2) ) -# 11069 "parsing/parser.ml" - : 'type_kind)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in - Obj.repr( -# 1971 "parsing/parser.mly" - ( (Ptype_abstract, Private, Some _3) ) -# 11076 "parsing/parser.ml" - : 'type_kind)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'constructor_declarations) in - Obj.repr( -# 1973 "parsing/parser.mly" - ( (Ptype_variant(List.rev _2), Public, None) ) -# 11083 "parsing/parser.ml" - : 'type_kind)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'constructor_declarations) in - Obj.repr( -# 1975 "parsing/parser.mly" - ( (Ptype_variant(List.rev _3), Private, None) ) -# 11090 "parsing/parser.ml" - : 'type_kind)) -; (fun __caml_parser_env -> - Obj.repr( -# 1977 "parsing/parser.mly" - ( (Ptype_open, Public, None) ) -# 11096 "parsing/parser.ml" - : 'type_kind)) -; (fun __caml_parser_env -> - Obj.repr( -# 1979 "parsing/parser.mly" - ( (Ptype_open, Private, None) ) -# 11102 "parsing/parser.ml" - : 'type_kind)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'private_flag) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'label_declarations) in - Obj.repr( -# 1981 "parsing/parser.mly" - ( (Ptype_record _4, _2, None) ) -# 11110 "parsing/parser.ml" - : 'type_kind)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'core_type) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'private_flag) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'constructor_declarations) in - Obj.repr( -# 1983 "parsing/parser.mly" - ( (Ptype_variant(List.rev _5), _4, Some _2) ) -# 11119 "parsing/parser.ml" - : 'type_kind)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'core_type) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'private_flag) in - Obj.repr( -# 1985 "parsing/parser.mly" - ( (Ptype_open, _4, Some _2) ) -# 11127 "parsing/parser.ml" - : 'type_kind)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 5 : 'core_type) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : 'private_flag) in - let _6 = (Parsing.peek_val __caml_parser_env 1 : 'label_declarations) in - Obj.repr( -# 1987 "parsing/parser.mly" - ( (Ptype_record _6, _4, Some _2) ) -# 11136 "parsing/parser.ml" - : 'type_kind)) -; (fun __caml_parser_env -> - Obj.repr( -# 1990 "parsing/parser.mly" - ( [] ) -# 11142 "parsing/parser.ml" - : 'optional_type_parameters)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'optional_type_parameter) in - Obj.repr( -# 1991 "parsing/parser.mly" - ( [_1] ) -# 11149 "parsing/parser.ml" - : 'optional_type_parameters)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'optional_type_parameter_list) in - Obj.repr( -# 1992 "parsing/parser.mly" - ( List.rev _2 ) -# 11156 "parsing/parser.ml" - : 'optional_type_parameters)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'type_variance) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'optional_type_variable) in - Obj.repr( -# 1995 "parsing/parser.mly" - ( _2, _1 ) -# 11164 "parsing/parser.ml" - : 'optional_type_parameter)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'optional_type_parameter) in - Obj.repr( -# 1998 "parsing/parser.mly" - ( [_1] ) -# 11171 "parsing/parser.ml" - : 'optional_type_parameter_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'optional_type_parameter_list) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'optional_type_parameter) in - Obj.repr( -# 1999 "parsing/parser.mly" - ( _3 :: _1 ) -# 11179 "parsing/parser.ml" - : 'optional_type_parameter_list)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'ident) in - Obj.repr( -# 2002 "parsing/parser.mly" - ( mktyp(Ptyp_var _2) ) -# 11186 "parsing/parser.ml" - : 'optional_type_variable)) -; (fun __caml_parser_env -> - Obj.repr( -# 2003 "parsing/parser.mly" - ( mktyp(Ptyp_any) ) -# 11192 "parsing/parser.ml" - : 'optional_type_variable)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'type_variance) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'type_variable) in - Obj.repr( -# 2008 "parsing/parser.mly" - ( _2, _1 ) -# 11200 "parsing/parser.ml" - : 'type_parameter)) -; (fun __caml_parser_env -> - Obj.repr( -# 2011 "parsing/parser.mly" - ( Invariant ) -# 11206 "parsing/parser.ml" - : 'type_variance)) -; (fun __caml_parser_env -> - Obj.repr( -# 2012 "parsing/parser.mly" - ( Covariant ) -# 11212 "parsing/parser.ml" - : 'type_variance)) -; (fun __caml_parser_env -> - Obj.repr( -# 2013 "parsing/parser.mly" - ( Contravariant ) -# 11218 "parsing/parser.ml" - : 'type_variance)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'ident) in - Obj.repr( -# 2016 "parsing/parser.mly" - ( mktyp(Ptyp_var _2) ) -# 11225 "parsing/parser.ml" - : 'type_variable)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'type_parameter) in - Obj.repr( -# 2019 "parsing/parser.mly" - ( [_1] ) -# 11232 "parsing/parser.ml" - : 'type_parameter_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'type_parameter_list) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'type_parameter) in - Obj.repr( -# 2020 "parsing/parser.mly" - ( _3 :: _1 ) -# 11240 "parsing/parser.ml" - : 'type_parameter_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'constructor_declaration) in - Obj.repr( -# 2023 "parsing/parser.mly" - ( [_1] ) -# 11247 "parsing/parser.ml" - : 'constructor_declarations)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'bar_constructor_declaration) in - Obj.repr( -# 2024 "parsing/parser.mly" - ( [_1] ) -# 11254 "parsing/parser.ml" - : 'constructor_declarations)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'constructor_declarations) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'bar_constructor_declaration) in - Obj.repr( -# 2025 "parsing/parser.mly" - ( _2 :: _1 ) -# 11262 "parsing/parser.ml" - : 'constructor_declarations)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'constr_ident) in - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'generalized_constructor_arguments) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in - Obj.repr( -# 2029 "parsing/parser.mly" - ( - let args,res = _2 in - Type.constructor (mkrhs _1 1) ~args ?res ~attrs:_3 - ~loc:(symbol_rloc()) ~info:(symbol_info ()) - ) -# 11275 "parsing/parser.ml" - : 'constructor_declaration)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'constr_ident) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'generalized_constructor_arguments) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in - Obj.repr( -# 2037 "parsing/parser.mly" - ( - let args,res = _3 in - Type.constructor (mkrhs _2 2) ~args ?res ~attrs:_4 - ~loc:(symbol_rloc()) ~info:(symbol_info ()) - ) -# 11288 "parsing/parser.ml" - : 'bar_constructor_declaration)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'sig_exception_declaration) in - Obj.repr( -# 2044 "parsing/parser.mly" - ( _1 ) -# 11295 "parsing/parser.ml" - : 'str_exception_declaration)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 5 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 4 : 'constr_ident) in - let _5 = (Parsing.peek_val __caml_parser_env 2 : 'constr_longident) in - let _6 = (Parsing.peek_val __caml_parser_env 1 : 'attributes) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 2047 "parsing/parser.mly" - ( let (ext,attrs) = _2 in - Te.rebind (mkrhs _3 3) (mkrhs _5 5) ~attrs:(attrs @ _6 @ _7) - ~loc:(symbol_rloc()) ~docs:(symbol_docs ()) - , ext ) -# 11309 "parsing/parser.ml" - : 'str_exception_declaration)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 3 : 'constr_ident) in - let _4 = (Parsing.peek_val __caml_parser_env 2 : 'generalized_constructor_arguments) in - let _5 = (Parsing.peek_val __caml_parser_env 1 : 'attributes) in - let _6 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 2055 "parsing/parser.mly" - ( let args, res = _4 in - let (ext,attrs) = _2 in - Te.decl (mkrhs _3 3) ~args ?res ~attrs:(attrs @ _5 @ _6) - ~loc:(symbol_rloc()) ~docs:(symbol_docs ()) - , ext ) -# 11324 "parsing/parser.ml" - : 'sig_exception_declaration)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'constr_ident) in - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'generalized_constructor_arguments) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in - Obj.repr( -# 2063 "parsing/parser.mly" - ( let args, res = _2 in - Te.decl (mkrhs _1 1) ~args ?res ~attrs:_3 ~loc:(symbol_rloc()) ) -# 11334 "parsing/parser.ml" - : 'let_exception_declaration)) -; (fun __caml_parser_env -> - Obj.repr( -# 2067 "parsing/parser.mly" - ( (Pcstr_tuple [],None) ) -# 11340 "parsing/parser.ml" - : 'generalized_constructor_arguments)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'constructor_arguments) in - Obj.repr( -# 2068 "parsing/parser.mly" - ( (_2,None) ) -# 11347 "parsing/parser.ml" - : 'generalized_constructor_arguments)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'constructor_arguments) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'simple_core_type) in - Obj.repr( -# 2070 "parsing/parser.mly" - ( (_2,Some _4) ) -# 11355 "parsing/parser.ml" - : 'generalized_constructor_arguments)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'simple_core_type) in - Obj.repr( -# 2072 "parsing/parser.mly" - ( (Pcstr_tuple [],Some _2) ) -# 11362 "parsing/parser.ml" - : 'generalized_constructor_arguments)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'core_type_list) in - Obj.repr( -# 2076 "parsing/parser.mly" - ( Pcstr_tuple (List.rev _1) ) -# 11369 "parsing/parser.ml" - : 'constructor_arguments)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'label_declarations) in - Obj.repr( -# 2077 "parsing/parser.mly" - ( Pcstr_record _2 ) -# 11376 "parsing/parser.ml" - : 'constructor_arguments)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'label_declaration) in - Obj.repr( -# 2080 "parsing/parser.mly" - ( [_1] ) -# 11383 "parsing/parser.ml" - : 'label_declarations)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'label_declaration_semi) in - Obj.repr( -# 2081 "parsing/parser.mly" - ( [_1] ) -# 11390 "parsing/parser.ml" - : 'label_declarations)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'label_declaration_semi) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'label_declarations) in - Obj.repr( -# 2082 "parsing/parser.mly" - ( _1 :: _2 ) -# 11398 "parsing/parser.ml" - : 'label_declarations)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'mutable_flag) in - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'label) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'poly_type_no_attr) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in - Obj.repr( -# 2086 "parsing/parser.mly" - ( - Type.field (mkrhs _2 2) _4 ~mut:_1 ~attrs:_5 - ~loc:(symbol_rloc()) ~info:(symbol_info ()) - ) -# 11411 "parsing/parser.ml" - : 'label_declaration)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 6 : 'mutable_flag) in - let _2 = (Parsing.peek_val __caml_parser_env 5 : 'label) in - let _4 = (Parsing.peek_val __caml_parser_env 3 : 'poly_type_no_attr) in - let _5 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in - let _7 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in - Obj.repr( -# 2093 "parsing/parser.mly" - ( - let info = - match rhs_info 5 with - | Some _ as info_before_semi -> info_before_semi - | None -> symbol_info () - in - Type.field (mkrhs _2 2) _4 ~mut:_1 ~attrs:(_5 @ _7) - ~loc:(symbol_rloc()) ~info - ) -# 11430 "parsing/parser.ml" - : 'label_declaration_semi)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 7 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 6 : 'nonrec_flag) in - let _4 = (Parsing.peek_val __caml_parser_env 5 : 'optional_type_parameters) in - let _5 = (Parsing.peek_val __caml_parser_env 4 : 'type_longident) in - let _7 = (Parsing.peek_val __caml_parser_env 2 : 'private_flag) in - let _8 = (Parsing.peek_val __caml_parser_env 1 : 'str_extension_constructors) in - let _9 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 2109 "parsing/parser.mly" - ( let (ext, attrs) = _2 in - if _3 <> Recursive then not_expecting 3 "nonrec flag"; - Te.mk (mkrhs _5 5) (List.rev _8) ~params:_4 ~priv:_7 - ~attrs:(attrs@_9) ~docs:(symbol_docs ()) - , ext ) -# 11447 "parsing/parser.ml" - : 'str_type_extension)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 7 : 'ext_attributes) in - let _3 = (Parsing.peek_val __caml_parser_env 6 : 'nonrec_flag) in - let _4 = (Parsing.peek_val __caml_parser_env 5 : 'optional_type_parameters) in - let _5 = (Parsing.peek_val __caml_parser_env 4 : 'type_longident) in - let _7 = (Parsing.peek_val __caml_parser_env 2 : 'private_flag) in - let _8 = (Parsing.peek_val __caml_parser_env 1 : 'sig_extension_constructors) in - let _9 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 2118 "parsing/parser.mly" - ( let (ext, attrs) = _2 in - if _3 <> Recursive then not_expecting 3 "nonrec flag"; - Te.mk (mkrhs _5 5) (List.rev _8) ~params:_4 ~priv:_7 - ~attrs:(attrs @ _9) ~docs:(symbol_docs ()) - , ext ) -# 11464 "parsing/parser.ml" - : 'sig_type_extension)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'extension_constructor_declaration) in - Obj.repr( -# 2125 "parsing/parser.mly" - ( [_1] ) -# 11471 "parsing/parser.ml" - : 'str_extension_constructors)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'bar_extension_constructor_declaration) in - Obj.repr( -# 2126 "parsing/parser.mly" - ( [_1] ) -# 11478 "parsing/parser.ml" - : 'str_extension_constructors)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'extension_constructor_rebind) in - Obj.repr( -# 2127 "parsing/parser.mly" - ( [_1] ) -# 11485 "parsing/parser.ml" - : 'str_extension_constructors)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'bar_extension_constructor_rebind) in - Obj.repr( -# 2128 "parsing/parser.mly" - ( [_1] ) -# 11492 "parsing/parser.ml" - : 'str_extension_constructors)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'str_extension_constructors) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'bar_extension_constructor_declaration) in - Obj.repr( -# 2130 "parsing/parser.mly" - ( _2 :: _1 ) -# 11500 "parsing/parser.ml" - : 'str_extension_constructors)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'str_extension_constructors) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'bar_extension_constructor_rebind) in - Obj.repr( -# 2132 "parsing/parser.mly" - ( _2 :: _1 ) -# 11508 "parsing/parser.ml" - : 'str_extension_constructors)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'extension_constructor_declaration) in - Obj.repr( -# 2135 "parsing/parser.mly" - ( [_1] ) -# 11515 "parsing/parser.ml" - : 'sig_extension_constructors)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'bar_extension_constructor_declaration) in - Obj.repr( -# 2136 "parsing/parser.mly" - ( [_1] ) -# 11522 "parsing/parser.ml" - : 'sig_extension_constructors)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'sig_extension_constructors) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'bar_extension_constructor_declaration) in - Obj.repr( -# 2138 "parsing/parser.mly" - ( _2 :: _1 ) -# 11530 "parsing/parser.ml" - : 'sig_extension_constructors)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'constr_ident) in - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'generalized_constructor_arguments) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in - Obj.repr( -# 2142 "parsing/parser.mly" - ( let args, res = _2 in - Te.decl (mkrhs _1 1) ~args ?res ~attrs:_3 - ~loc:(symbol_rloc()) ~info:(symbol_info ()) ) -# 11541 "parsing/parser.ml" - : 'extension_constructor_declaration)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'constr_ident) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'generalized_constructor_arguments) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in - Obj.repr( -# 2148 "parsing/parser.mly" - ( let args, res = _3 in - Te.decl (mkrhs _2 2) ~args ?res ~attrs:_4 - ~loc:(symbol_rloc()) ~info:(symbol_info ()) ) -# 11552 "parsing/parser.ml" - : 'bar_extension_constructor_declaration)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 3 : 'constr_ident) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'constr_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in - Obj.repr( -# 2154 "parsing/parser.mly" - ( Te.rebind (mkrhs _1 1) (mkrhs _3 3) ~attrs:_4 - ~loc:(symbol_rloc()) ~info:(symbol_info ()) ) -# 11562 "parsing/parser.ml" - : 'extension_constructor_rebind)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'constr_ident) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'constr_longident) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in - Obj.repr( -# 2159 "parsing/parser.mly" - ( Te.rebind (mkrhs _2 2) (mkrhs _4 4) ~attrs:_5 - ~loc:(symbol_rloc()) ~info:(symbol_info ()) ) -# 11572 "parsing/parser.ml" - : 'bar_extension_constructor_rebind)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'with_constraint) in - Obj.repr( -# 2166 "parsing/parser.mly" - ( [_1] ) -# 11579 "parsing/parser.ml" - : 'with_constraints)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'with_constraints) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'with_constraint) in - Obj.repr( -# 2167 "parsing/parser.mly" - ( _3 :: _1 ) -# 11587 "parsing/parser.ml" - : 'with_constraints)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 4 : 'optional_type_parameters) in - let _3 = (Parsing.peek_val __caml_parser_env 3 : 'label_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 2 : 'with_type_binder) in - let _5 = (Parsing.peek_val __caml_parser_env 1 : 'core_type_no_attr) in - let _6 = (Parsing.peek_val __caml_parser_env 0 : 'constraints) in - Obj.repr( -# 2172 "parsing/parser.mly" - ( Pwith_type - (mkrhs _3 3, - (Type.mk (mkrhs (Longident.last _3) 3) - ~params:_2 - ~cstrs:(List.rev _6) - ~manifest:_5 - ~priv:_4 - ~loc:(symbol_rloc()))) ) -# 11605 "parsing/parser.ml" - : 'with_constraint)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'optional_type_parameters) in - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'label_longident) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'core_type_no_attr) in - Obj.repr( -# 2183 "parsing/parser.mly" - ( Pwith_typesubst - (mkrhs _3 3, - (Type.mk (mkrhs (Longident.last _3) 3) - ~params:_2 - ~manifest:_5 - ~loc:(symbol_rloc()))) ) -# 11619 "parsing/parser.ml" - : 'with_constraint)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'mod_ext_longident) in - Obj.repr( -# 2190 "parsing/parser.mly" - ( Pwith_module (mkrhs _2 2, mkrhs _4 4) ) -# 11627 "parsing/parser.ml" - : 'with_constraint)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'mod_longident) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'mod_ext_longident) in - Obj.repr( -# 2192 "parsing/parser.mly" - ( Pwith_modsubst (mkrhs _2 2, mkrhs _4 4) ) -# 11635 "parsing/parser.ml" - : 'with_constraint)) -; (fun __caml_parser_env -> - Obj.repr( -# 2195 "parsing/parser.mly" - ( Public ) -# 11641 "parsing/parser.ml" - : 'with_type_binder)) -; (fun __caml_parser_env -> - Obj.repr( -# 2196 "parsing/parser.mly" - ( Private ) -# 11647 "parsing/parser.ml" - : 'with_type_binder)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'ident) in - Obj.repr( -# 2202 "parsing/parser.mly" - ( [mkrhs _2 2] ) -# 11654 "parsing/parser.ml" - : 'typevar_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'typevar_list) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'ident) in - Obj.repr( -# 2203 "parsing/parser.mly" - ( mkrhs _3 3 :: _1 ) -# 11662 "parsing/parser.ml" - : 'typevar_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in - Obj.repr( -# 2207 "parsing/parser.mly" - ( _1 ) -# 11669 "parsing/parser.ml" - : 'poly_type)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'typevar_list) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in - Obj.repr( -# 2209 "parsing/parser.mly" - ( mktyp(Ptyp_poly(List.rev _1, _3)) ) -# 11677 "parsing/parser.ml" - : 'poly_type)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'core_type_no_attr) in - Obj.repr( -# 2213 "parsing/parser.mly" - ( _1 ) -# 11684 "parsing/parser.ml" - : 'poly_type_no_attr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'typevar_list) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type_no_attr) in - Obj.repr( -# 2215 "parsing/parser.mly" - ( mktyp(Ptyp_poly(List.rev _1, _3)) ) -# 11692 "parsing/parser.ml" - : 'poly_type_no_attr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'core_type_no_attr) in - Obj.repr( -# 2222 "parsing/parser.mly" - ( _1 ) -# 11699 "parsing/parser.ml" - : 'core_type)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'core_type) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attribute) in - Obj.repr( -# 2224 "parsing/parser.mly" - ( Typ.attr _1 _2 ) -# 11707 "parsing/parser.ml" - : 'core_type)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'core_type2) in - Obj.repr( -# 2228 "parsing/parser.mly" - ( _1 ) -# 11714 "parsing/parser.ml" - : 'core_type_no_attr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 3 : 'core_type2) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'ident) in - Obj.repr( -# 2230 "parsing/parser.mly" - ( mktyp(Ptyp_alias(_1, _4)) ) -# 11722 "parsing/parser.ml" - : 'core_type_no_attr)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_core_type_or_tuple) in - Obj.repr( -# 2234 "parsing/parser.mly" - ( _1 ) -# 11729 "parsing/parser.ml" - : 'core_type2)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 4 : string) in - let _4 = (Parsing.peek_val __caml_parser_env 2 : 'core_type2) in - let _6 = (Parsing.peek_val __caml_parser_env 0 : 'core_type2) in - Obj.repr( -# 2236 "parsing/parser.mly" - ( let param = extra_rhs_core_type _4 ~pos:4 in - mktyp (Ptyp_arrow(Optional _2 , param, _6)) ) -# 11739 "parsing/parser.ml" - : 'core_type2)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 3 : string) in - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'core_type2) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'core_type2) in - Obj.repr( -# 2239 "parsing/parser.mly" - ( let param = extra_rhs_core_type _2 ~pos:2 in - mktyp(Ptyp_arrow(Optional _1 , param, _4)) - ) -# 11750 "parsing/parser.ml" - : 'core_type2)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : string) in - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'core_type2) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'core_type2) in - Obj.repr( -# 2243 "parsing/parser.mly" - ( let param = extra_rhs_core_type _3 ~pos:3 in - mktyp(Ptyp_arrow(Labelled _1, param, _5)) ) -# 11760 "parsing/parser.ml" - : 'core_type2)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'core_type2) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type2) in - Obj.repr( -# 2246 "parsing/parser.mly" - ( let param = extra_rhs_core_type _1 ~pos:1 in - mktyp(Ptyp_arrow(Nolabel, param, _3)) ) -# 11769 "parsing/parser.ml" - : 'core_type2)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_core_type2) in - Obj.repr( -# 2252 "parsing/parser.mly" - ( _1 ) -# 11776 "parsing/parser.ml" - : 'simple_core_type)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'core_type_comma_list) in - Obj.repr( -# 2254 "parsing/parser.mly" - ( match _2 with [sty] -> sty | _ -> raise Parse_error ) -# 11783 "parsing/parser.ml" - : 'simple_core_type)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'ident) in - Obj.repr( -# 2259 "parsing/parser.mly" - ( mktyp(Ptyp_var _2) ) -# 11790 "parsing/parser.ml" - : 'simple_core_type2)) -; (fun __caml_parser_env -> - Obj.repr( -# 2261 "parsing/parser.mly" - ( mktyp(Ptyp_any) ) -# 11796 "parsing/parser.ml" - : 'simple_core_type2)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'type_longident) in - Obj.repr( -# 2263 "parsing/parser.mly" - ( mktyp(Ptyp_constr(mkrhs _1 1, [])) ) -# 11803 "parsing/parser.ml" - : 'simple_core_type2)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'simple_core_type2) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'type_longident) in - Obj.repr( -# 2265 "parsing/parser.mly" - ( mktyp(Ptyp_constr(mkrhs _2 2, [_1])) ) -# 11811 "parsing/parser.ml" - : 'simple_core_type2)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'core_type_comma_list) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'type_longident) in - Obj.repr( -# 2267 "parsing/parser.mly" - ( mktyp(Ptyp_constr(mkrhs _4 4, List.rev _2)) ) -# 11819 "parsing/parser.ml" - : 'simple_core_type2)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'meth_list) in - Obj.repr( -# 2269 "parsing/parser.mly" - ( let (f, c) = _2 in mktyp(Ptyp_object (f, c)) ) -# 11826 "parsing/parser.ml" - : 'simple_core_type2)) -; (fun __caml_parser_env -> - Obj.repr( -# 2271 "parsing/parser.mly" - ( mktyp(Ptyp_object ([], Closed)) ) -# 11832 "parsing/parser.ml" - : 'simple_core_type2)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'class_longident) in - Obj.repr( -# 2273 "parsing/parser.mly" - ( mktyp(Ptyp_class(mkrhs _2 2, [])) ) -# 11839 "parsing/parser.ml" - : 'simple_core_type2)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'simple_core_type2) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'class_longident) in - Obj.repr( -# 2275 "parsing/parser.mly" - ( mktyp(Ptyp_class(mkrhs _3 3, [_1])) ) -# 11847 "parsing/parser.ml" - : 'simple_core_type2)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'core_type_comma_list) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'class_longident) in - Obj.repr( -# 2277 "parsing/parser.mly" - ( mktyp(Ptyp_class(mkrhs _5 5, List.rev _2)) ) -# 11855 "parsing/parser.ml" - : 'simple_core_type2)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'tag_field) in - Obj.repr( -# 2279 "parsing/parser.mly" - ( mktyp(Ptyp_variant([_2], Closed, None)) ) -# 11862 "parsing/parser.ml" - : 'simple_core_type2)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'row_field_list) in - Obj.repr( -# 2285 "parsing/parser.mly" - ( mktyp(Ptyp_variant(List.rev _3, Closed, None)) ) -# 11869 "parsing/parser.ml" - : 'simple_core_type2)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 3 : 'row_field) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'row_field_list) in - Obj.repr( -# 2287 "parsing/parser.mly" - ( mktyp(Ptyp_variant(_2 :: List.rev _4, Closed, None)) ) -# 11877 "parsing/parser.ml" - : 'simple_core_type2)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'opt_bar) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'row_field_list) in - Obj.repr( -# 2289 "parsing/parser.mly" - ( mktyp(Ptyp_variant(List.rev _3, Open, None)) ) -# 11885 "parsing/parser.ml" - : 'simple_core_type2)) -; (fun __caml_parser_env -> - Obj.repr( -# 2291 "parsing/parser.mly" - ( mktyp(Ptyp_variant([], Open, None)) ) -# 11891 "parsing/parser.ml" - : 'simple_core_type2)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'opt_bar) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'row_field_list) in - Obj.repr( -# 2293 "parsing/parser.mly" - ( mktyp(Ptyp_variant(List.rev _3, Closed, Some [])) ) -# 11899 "parsing/parser.ml" - : 'simple_core_type2)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 4 : 'opt_bar) in - let _3 = (Parsing.peek_val __caml_parser_env 3 : 'row_field_list) in - let _5 = (Parsing.peek_val __caml_parser_env 1 : 'name_tag_list) in - Obj.repr( -# 2295 "parsing/parser.mly" - ( mktyp(Ptyp_variant(List.rev _3, Closed, Some (List.rev _5))) ) -# 11908 "parsing/parser.ml" - : 'simple_core_type2)) -; (fun __caml_parser_env -> - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'package_type) in - Obj.repr( -# 2297 "parsing/parser.mly" - ( mktyp_attrs (Ptyp_package _4) _3 ) -# 11916 "parsing/parser.ml" - : 'simple_core_type2)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'extension) in - Obj.repr( -# 2299 "parsing/parser.mly" - ( mktyp (Ptyp_extension _1) ) -# 11923 "parsing/parser.ml" - : 'simple_core_type2)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'module_type) in - Obj.repr( -# 2302 "parsing/parser.mly" - ( package_type_of_module_type _1 ) -# 11930 "parsing/parser.ml" - : 'package_type)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'row_field) in - Obj.repr( -# 2305 "parsing/parser.mly" - ( [_1] ) -# 11937 "parsing/parser.ml" - : 'row_field_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'row_field_list) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'row_field) in - Obj.repr( -# 2306 "parsing/parser.mly" - ( _3 :: _1 ) -# 11945 "parsing/parser.ml" - : 'row_field_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'tag_field) in - Obj.repr( -# 2309 "parsing/parser.mly" - ( _1 ) -# 11952 "parsing/parser.ml" - : 'row_field)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_core_type) in - Obj.repr( -# 2310 "parsing/parser.mly" - ( Rinherit _1 ) -# 11959 "parsing/parser.ml" - : 'row_field)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'name_tag) in - let _3 = (Parsing.peek_val __caml_parser_env 2 : 'opt_ampersand) in - let _4 = (Parsing.peek_val __caml_parser_env 1 : 'amper_type_list) in - let _5 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in - Obj.repr( -# 2314 "parsing/parser.mly" - ( Rtag (mkrhs _1 1, add_info_attrs (symbol_info ()) _5, - _3, List.rev _4) ) -# 11970 "parsing/parser.ml" - : 'tag_field)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'name_tag) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in - Obj.repr( -# 2317 "parsing/parser.mly" - ( Rtag (mkrhs _1 1, add_info_attrs (symbol_info ()) _2, true, []) ) -# 11978 "parsing/parser.ml" - : 'tag_field)) -; (fun __caml_parser_env -> - Obj.repr( -# 2320 "parsing/parser.mly" - ( true ) -# 11984 "parsing/parser.ml" - : 'opt_ampersand)) -; (fun __caml_parser_env -> - Obj.repr( -# 2321 "parsing/parser.mly" - ( false ) -# 11990 "parsing/parser.ml" - : 'opt_ampersand)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'core_type_no_attr) in - Obj.repr( -# 2324 "parsing/parser.mly" - ( [_1] ) -# 11997 "parsing/parser.ml" - : 'amper_type_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'amper_type_list) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type_no_attr) in - Obj.repr( -# 2325 "parsing/parser.mly" - ( _3 :: _1 ) -# 12005 "parsing/parser.ml" - : 'amper_type_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'name_tag) in - Obj.repr( -# 2328 "parsing/parser.mly" - ( [_1] ) -# 12012 "parsing/parser.ml" - : 'name_tag_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'name_tag_list) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'name_tag) in - Obj.repr( -# 2329 "parsing/parser.mly" - ( _2 :: _1 ) -# 12020 "parsing/parser.ml" - : 'name_tag_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_core_type) in - Obj.repr( -# 2332 "parsing/parser.mly" - ( _1 ) -# 12027 "parsing/parser.ml" - : 'simple_core_type_or_tuple)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'simple_core_type) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type_list) in - Obj.repr( -# 2334 "parsing/parser.mly" - ( mktyp(Ptyp_tuple(_1 :: List.rev _3)) ) -# 12035 "parsing/parser.ml" - : 'simple_core_type_or_tuple)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in - Obj.repr( -# 2337 "parsing/parser.mly" - ( [_1] ) -# 12042 "parsing/parser.ml" - : 'core_type_comma_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'core_type_comma_list) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in - Obj.repr( -# 2338 "parsing/parser.mly" - ( _3 :: _1 ) -# 12050 "parsing/parser.ml" - : 'core_type_comma_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_core_type) in - Obj.repr( -# 2341 "parsing/parser.mly" - ( [_1] ) -# 12057 "parsing/parser.ml" - : 'core_type_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'core_type_list) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'simple_core_type) in - Obj.repr( -# 2342 "parsing/parser.mly" - ( _3 :: _1 ) -# 12065 "parsing/parser.ml" - : 'core_type_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'field_semi) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'meth_list) in - Obj.repr( -# 2345 "parsing/parser.mly" - ( let (f, c) = _2 in (_1 :: f, c) ) -# 12073 "parsing/parser.ml" - : 'meth_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'inherit_field_semi) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'meth_list) in - Obj.repr( -# 2346 "parsing/parser.mly" - ( let (f, c) = _2 in (_1 :: f, c) ) -# 12081 "parsing/parser.ml" - : 'meth_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'field_semi) in - Obj.repr( -# 2347 "parsing/parser.mly" - ( [_1], Closed ) -# 12088 "parsing/parser.ml" - : 'meth_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'field) in - Obj.repr( -# 2348 "parsing/parser.mly" - ( [_1], Closed ) -# 12095 "parsing/parser.ml" - : 'meth_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'inherit_field_semi) in - Obj.repr( -# 2349 "parsing/parser.mly" - ( [_1], Closed ) -# 12102 "parsing/parser.ml" - : 'meth_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_core_type) in - Obj.repr( -# 2350 "parsing/parser.mly" - ( [Oinherit _1], Closed ) -# 12109 "parsing/parser.ml" - : 'meth_list)) -; (fun __caml_parser_env -> - Obj.repr( -# 2351 "parsing/parser.mly" - ( [], Open ) -# 12115 "parsing/parser.ml" - : 'meth_list)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 3 : 'label) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'poly_type_no_attr) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in - Obj.repr( -# 2355 "parsing/parser.mly" - ( Otag (mkrhs _1 1, add_info_attrs (symbol_info ()) _4, _3) ) -# 12124 "parsing/parser.ml" - : 'field)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 5 : 'label) in - let _3 = (Parsing.peek_val __caml_parser_env 3 : 'poly_type_no_attr) in - let _4 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in - let _6 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in - Obj.repr( -# 2360 "parsing/parser.mly" - ( let info = - match rhs_info 4 with - | Some _ as info_before_semi -> info_before_semi - | None -> symbol_info () - in - ( Otag (mkrhs _1 1, add_info_attrs info (_4 @ _6), _3)) ) -# 12139 "parsing/parser.ml" - : 'field_semi)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'simple_core_type) in - Obj.repr( -# 2369 "parsing/parser.mly" - ( Oinherit _1 ) -# 12146 "parsing/parser.ml" - : 'inherit_field_semi)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2372 "parsing/parser.mly" - ( _1 ) -# 12153 "parsing/parser.ml" - : 'label)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string * char option) in - Obj.repr( -# 2378 "parsing/parser.mly" - ( let (n, m) = _1 in Pconst_integer (n, m) ) -# 12160 "parsing/parser.ml" - : 'constant)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : char) in - Obj.repr( -# 2379 "parsing/parser.mly" - ( Pconst_char _1 ) -# 12167 "parsing/parser.ml" - : 'constant)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string * string option) in - Obj.repr( -# 2380 "parsing/parser.mly" - ( let (s, d) = _1 in Pconst_string (s, d) ) -# 12174 "parsing/parser.ml" - : 'constant)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string * char option) in - Obj.repr( -# 2381 "parsing/parser.mly" - ( let (f, m) = _1 in Pconst_float (f, m) ) -# 12181 "parsing/parser.ml" - : 'constant)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'constant) in - Obj.repr( -# 2384 "parsing/parser.mly" - ( _1 ) -# 12188 "parsing/parser.ml" - : 'signed_constant)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : string * char option) in - Obj.repr( -# 2385 "parsing/parser.mly" - ( let (n, m) = _2 in Pconst_integer("-" ^ n, m) ) -# 12195 "parsing/parser.ml" - : 'signed_constant)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : string * char option) in - Obj.repr( -# 2386 "parsing/parser.mly" - ( let (f, m) = _2 in Pconst_float("-" ^ f, m) ) -# 12202 "parsing/parser.ml" - : 'signed_constant)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : string * char option) in - Obj.repr( -# 2387 "parsing/parser.mly" - ( let (n, m) = _2 in Pconst_integer (n, m) ) -# 12209 "parsing/parser.ml" - : 'signed_constant)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : string * char option) in - Obj.repr( -# 2388 "parsing/parser.mly" - ( let (f, m) = _2 in Pconst_float(f, m) ) -# 12216 "parsing/parser.ml" - : 'signed_constant)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2394 "parsing/parser.mly" - ( _1 ) -# 12223 "parsing/parser.ml" - : 'ident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2395 "parsing/parser.mly" - ( _1 ) -# 12230 "parsing/parser.ml" - : 'ident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2398 "parsing/parser.mly" - ( _1 ) -# 12237 "parsing/parser.ml" - : 'val_ident)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'operator) in - Obj.repr( -# 2399 "parsing/parser.mly" - ( _2 ) -# 12244 "parsing/parser.ml" - : 'val_ident)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'operator) in - Obj.repr( -# 2400 "parsing/parser.mly" - ( unclosed "(" 1 ")" 3 ) -# 12251 "parsing/parser.ml" - : 'val_ident)) -; (fun __caml_parser_env -> - Obj.repr( -# 2401 "parsing/parser.mly" - ( expecting 2 "operator" ) -# 12257 "parsing/parser.ml" - : 'val_ident)) -; (fun __caml_parser_env -> - Obj.repr( -# 2402 "parsing/parser.mly" - ( expecting 3 "module-expr" ) -# 12263 "parsing/parser.ml" - : 'val_ident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2405 "parsing/parser.mly" - ( _1 ) -# 12270 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2406 "parsing/parser.mly" - ( _1 ) -# 12277 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2407 "parsing/parser.mly" - ( _1 ) -# 12284 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2408 "parsing/parser.mly" - ( _1 ) -# 12291 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2409 "parsing/parser.mly" - ( _1 ) -# 12298 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2410 "parsing/parser.mly" - ( _1 ) -# 12305 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : string) in - Obj.repr( -# 2411 "parsing/parser.mly" - ( "."^ _1 ^"()" ) -# 12312 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 3 : string) in - Obj.repr( -# 2412 "parsing/parser.mly" - ( "."^ _1 ^ "()<-" ) -# 12319 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : string) in - Obj.repr( -# 2413 "parsing/parser.mly" - ( "."^ _1 ^"[]" ) -# 12326 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 3 : string) in - Obj.repr( -# 2414 "parsing/parser.mly" - ( "."^ _1 ^ "[]<-" ) -# 12333 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : string) in - Obj.repr( -# 2415 "parsing/parser.mly" - ( "."^ _1 ^"{}" ) -# 12340 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 3 : string) in - Obj.repr( -# 2416 "parsing/parser.mly" - ( "."^ _1 ^ "{}<-" ) -# 12347 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2417 "parsing/parser.mly" - ( _1 ) -# 12354 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - Obj.repr( -# 2418 "parsing/parser.mly" - ( "!" ) -# 12360 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - Obj.repr( -# 2419 "parsing/parser.mly" - ( "+" ) -# 12366 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - Obj.repr( -# 2420 "parsing/parser.mly" - ( "+." ) -# 12372 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - Obj.repr( -# 2421 "parsing/parser.mly" - ( "-" ) -# 12378 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - Obj.repr( -# 2422 "parsing/parser.mly" - ( "-." ) -# 12384 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - Obj.repr( -# 2423 "parsing/parser.mly" - ( "*" ) -# 12390 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - Obj.repr( -# 2424 "parsing/parser.mly" - ( "=" ) -# 12396 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - Obj.repr( -# 2425 "parsing/parser.mly" - ( "<" ) -# 12402 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - Obj.repr( -# 2426 "parsing/parser.mly" - ( ">" ) -# 12408 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - Obj.repr( -# 2427 "parsing/parser.mly" - ( "or" ) -# 12414 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - Obj.repr( -# 2428 "parsing/parser.mly" - ( "||" ) -# 12420 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - Obj.repr( -# 2429 "parsing/parser.mly" - ( "&" ) -# 12426 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - Obj.repr( -# 2430 "parsing/parser.mly" - ( "&&" ) -# 12432 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - Obj.repr( -# 2431 "parsing/parser.mly" - ( ":=" ) -# 12438 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - Obj.repr( -# 2432 "parsing/parser.mly" - ( "+=" ) -# 12444 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - Obj.repr( -# 2433 "parsing/parser.mly" - ( "%" ) -# 12450 "parsing/parser.ml" - : 'operator)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2436 "parsing/parser.mly" - ( _1 ) -# 12457 "parsing/parser.ml" - : 'constr_ident)) -; (fun __caml_parser_env -> - Obj.repr( -# 2437 "parsing/parser.mly" - ( "[]" ) -# 12463 "parsing/parser.ml" - : 'constr_ident)) -; (fun __caml_parser_env -> - Obj.repr( -# 2438 "parsing/parser.mly" - ( "()" ) -# 12469 "parsing/parser.ml" - : 'constr_ident)) -; (fun __caml_parser_env -> - Obj.repr( -# 2439 "parsing/parser.mly" - ( "::" ) -# 12475 "parsing/parser.ml" - : 'constr_ident)) -; (fun __caml_parser_env -> - Obj.repr( -# 2440 "parsing/parser.mly" - ( "false" ) -# 12481 "parsing/parser.ml" - : 'constr_ident)) -; (fun __caml_parser_env -> - Obj.repr( -# 2441 "parsing/parser.mly" - ( "true" ) -# 12487 "parsing/parser.ml" - : 'constr_ident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'val_ident) in - Obj.repr( -# 2445 "parsing/parser.mly" - ( Lident _1 ) -# 12494 "parsing/parser.ml" - : 'val_longident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'mod_longident) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'val_ident) in - Obj.repr( -# 2446 "parsing/parser.mly" - ( Ldot(_1, _3) ) -# 12502 "parsing/parser.ml" - : 'val_longident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'mod_longident) in - Obj.repr( -# 2449 "parsing/parser.mly" - ( _1 ) -# 12509 "parsing/parser.ml" - : 'constr_longident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in - Obj.repr( -# 2450 "parsing/parser.mly" - ( Ldot(_1,"::") ) -# 12516 "parsing/parser.ml" - : 'constr_longident)) -; (fun __caml_parser_env -> - Obj.repr( -# 2451 "parsing/parser.mly" - ( Lident "[]" ) -# 12522 "parsing/parser.ml" - : 'constr_longident)) -; (fun __caml_parser_env -> - Obj.repr( -# 2452 "parsing/parser.mly" - ( Lident "()" ) -# 12528 "parsing/parser.ml" - : 'constr_longident)) -; (fun __caml_parser_env -> - Obj.repr( -# 2453 "parsing/parser.mly" - ( Lident "::" ) -# 12534 "parsing/parser.ml" - : 'constr_longident)) -; (fun __caml_parser_env -> - Obj.repr( -# 2454 "parsing/parser.mly" - ( Lident "false" ) -# 12540 "parsing/parser.ml" - : 'constr_longident)) -; (fun __caml_parser_env -> - Obj.repr( -# 2455 "parsing/parser.mly" - ( Lident "true" ) -# 12546 "parsing/parser.ml" - : 'constr_longident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2458 "parsing/parser.mly" - ( Lident _1 ) -# 12553 "parsing/parser.ml" - : 'label_longident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'mod_longident) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2459 "parsing/parser.mly" - ( Ldot(_1, _3) ) -# 12561 "parsing/parser.ml" - : 'label_longident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2462 "parsing/parser.mly" - ( Lident _1 ) -# 12568 "parsing/parser.ml" - : 'type_longident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'mod_ext_longident) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2463 "parsing/parser.mly" - ( Ldot(_1, _3) ) -# 12576 "parsing/parser.ml" - : 'type_longident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2466 "parsing/parser.mly" - ( Lident _1 ) -# 12583 "parsing/parser.ml" - : 'mod_longident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'mod_longident) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2467 "parsing/parser.mly" - ( Ldot(_1, _3) ) -# 12591 "parsing/parser.ml" - : 'mod_longident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2470 "parsing/parser.mly" - ( Lident _1 ) -# 12598 "parsing/parser.ml" - : 'mod_ext_longident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'mod_ext_longident) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2471 "parsing/parser.mly" - ( Ldot(_1, _3) ) -# 12606 "parsing/parser.ml" - : 'mod_ext_longident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 3 : 'mod_ext_longident) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'mod_ext_longident) in - Obj.repr( -# 2472 "parsing/parser.mly" - ( lapply _1 _3 ) -# 12614 "parsing/parser.ml" - : 'mod_ext_longident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'ident) in - Obj.repr( -# 2475 "parsing/parser.mly" - ( Lident _1 ) -# 12621 "parsing/parser.ml" - : 'mty_longident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'mod_ext_longident) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'ident) in - Obj.repr( -# 2476 "parsing/parser.mly" - ( Ldot(_1, _3) ) -# 12629 "parsing/parser.ml" - : 'mty_longident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2479 "parsing/parser.mly" - ( Lident _1 ) -# 12636 "parsing/parser.ml" - : 'clty_longident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'mod_ext_longident) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2480 "parsing/parser.mly" - ( Ldot(_1, _3) ) -# 12644 "parsing/parser.ml" - : 'clty_longident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2483 "parsing/parser.mly" - ( Lident _1 ) -# 12651 "parsing/parser.ml" - : 'class_longident)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'mod_longident) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2484 "parsing/parser.mly" - ( Ldot(_1, _3) ) -# 12659 "parsing/parser.ml" - : 'class_longident)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'ident) in - Obj.repr( -# 2490 "parsing/parser.mly" - ( Ptop_dir(_2, Pdir_none) ) -# 12666 "parsing/parser.ml" - : 'toplevel_directive)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ident) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : string * string option) in - Obj.repr( -# 2491 "parsing/parser.mly" - ( Ptop_dir(_2, Pdir_string (fst _3)) ) -# 12674 "parsing/parser.ml" - : 'toplevel_directive)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ident) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : string * char option) in - Obj.repr( -# 2492 "parsing/parser.mly" - ( let (n, m) = _3 in - Ptop_dir(_2, Pdir_int (n ,m)) ) -# 12683 "parsing/parser.ml" - : 'toplevel_directive)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ident) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'val_longident) in - Obj.repr( -# 2494 "parsing/parser.mly" - ( Ptop_dir(_2, Pdir_ident _3) ) -# 12691 "parsing/parser.ml" - : 'toplevel_directive)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ident) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'mod_longident) in - Obj.repr( -# 2495 "parsing/parser.mly" - ( Ptop_dir(_2, Pdir_ident _3) ) -# 12699 "parsing/parser.ml" - : 'toplevel_directive)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ident) in - Obj.repr( -# 2496 "parsing/parser.mly" - ( Ptop_dir(_2, Pdir_bool false) ) -# 12706 "parsing/parser.ml" - : 'toplevel_directive)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ident) in - Obj.repr( -# 2497 "parsing/parser.mly" - ( Ptop_dir(_2, Pdir_bool true) ) -# 12713 "parsing/parser.ml" - : 'toplevel_directive)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'ident) in - Obj.repr( -# 2503 "parsing/parser.mly" - ( _2 ) -# 12720 "parsing/parser.ml" - : 'name_tag)) -; (fun __caml_parser_env -> - Obj.repr( -# 2506 "parsing/parser.mly" - ( Nonrecursive ) -# 12726 "parsing/parser.ml" - : 'rec_flag)) -; (fun __caml_parser_env -> - Obj.repr( -# 2507 "parsing/parser.mly" - ( Recursive ) -# 12732 "parsing/parser.ml" - : 'rec_flag)) -; (fun __caml_parser_env -> - Obj.repr( -# 2510 "parsing/parser.mly" - ( Recursive ) -# 12738 "parsing/parser.ml" - : 'nonrec_flag)) -; (fun __caml_parser_env -> - Obj.repr( -# 2511 "parsing/parser.mly" - ( Nonrecursive ) -# 12744 "parsing/parser.ml" - : 'nonrec_flag)) -; (fun __caml_parser_env -> - Obj.repr( -# 2514 "parsing/parser.mly" - ( Upto ) -# 12750 "parsing/parser.ml" - : 'direction_flag)) -; (fun __caml_parser_env -> - Obj.repr( -# 2515 "parsing/parser.mly" - ( Downto ) -# 12756 "parsing/parser.ml" - : 'direction_flag)) -; (fun __caml_parser_env -> - Obj.repr( -# 2518 "parsing/parser.mly" - ( Public ) -# 12762 "parsing/parser.ml" - : 'private_flag)) -; (fun __caml_parser_env -> - Obj.repr( -# 2519 "parsing/parser.mly" - ( Private ) -# 12768 "parsing/parser.ml" - : 'private_flag)) -; (fun __caml_parser_env -> - Obj.repr( -# 2522 "parsing/parser.mly" - ( Immutable ) -# 12774 "parsing/parser.ml" - : 'mutable_flag)) -; (fun __caml_parser_env -> - Obj.repr( -# 2523 "parsing/parser.mly" - ( Mutable ) -# 12780 "parsing/parser.ml" - : 'mutable_flag)) -; (fun __caml_parser_env -> - Obj.repr( -# 2526 "parsing/parser.mly" - ( Concrete ) -# 12786 "parsing/parser.ml" - : 'virtual_flag)) -; (fun __caml_parser_env -> - Obj.repr( -# 2527 "parsing/parser.mly" - ( Virtual ) -# 12792 "parsing/parser.ml" - : 'virtual_flag)) -; (fun __caml_parser_env -> - Obj.repr( -# 2530 "parsing/parser.mly" - ( Public, Concrete ) -# 12798 "parsing/parser.ml" - : 'private_virtual_flags)) -; (fun __caml_parser_env -> - Obj.repr( -# 2531 "parsing/parser.mly" - ( Private, Concrete ) -# 12804 "parsing/parser.ml" - : 'private_virtual_flags)) -; (fun __caml_parser_env -> - Obj.repr( -# 2532 "parsing/parser.mly" - ( Public, Virtual ) -# 12810 "parsing/parser.ml" - : 'private_virtual_flags)) -; (fun __caml_parser_env -> - Obj.repr( -# 2533 "parsing/parser.mly" - ( Private, Virtual ) -# 12816 "parsing/parser.ml" - : 'private_virtual_flags)) -; (fun __caml_parser_env -> - Obj.repr( -# 2534 "parsing/parser.mly" - ( Private, Virtual ) -# 12822 "parsing/parser.ml" - : 'private_virtual_flags)) -; (fun __caml_parser_env -> - Obj.repr( -# 2537 "parsing/parser.mly" - ( Fresh ) -# 12828 "parsing/parser.ml" - : 'override_flag)) -; (fun __caml_parser_env -> - Obj.repr( -# 2538 "parsing/parser.mly" - ( Override ) -# 12834 "parsing/parser.ml" - : 'override_flag)) -; (fun __caml_parser_env -> - Obj.repr( -# 2541 "parsing/parser.mly" - ( () ) -# 12840 "parsing/parser.ml" - : 'opt_bar)) -; (fun __caml_parser_env -> - Obj.repr( -# 2542 "parsing/parser.mly" - ( () ) -# 12846 "parsing/parser.ml" - : 'opt_bar)) -; (fun __caml_parser_env -> - Obj.repr( -# 2545 "parsing/parser.mly" - ( () ) -# 12852 "parsing/parser.ml" - : 'opt_semi)) -; (fun __caml_parser_env -> - Obj.repr( -# 2546 "parsing/parser.mly" - ( () ) -# 12858 "parsing/parser.ml" - : 'opt_semi)) -; (fun __caml_parser_env -> - Obj.repr( -# 2549 "parsing/parser.mly" - ( "-" ) -# 12864 "parsing/parser.ml" - : 'subtractive)) -; (fun __caml_parser_env -> - Obj.repr( -# 2550 "parsing/parser.mly" - ( "-." ) -# 12870 "parsing/parser.ml" - : 'subtractive)) -; (fun __caml_parser_env -> - Obj.repr( -# 2553 "parsing/parser.mly" - ( "+" ) -# 12876 "parsing/parser.ml" - : 'additive)) -; (fun __caml_parser_env -> - Obj.repr( -# 2554 "parsing/parser.mly" - ( "+." ) -# 12882 "parsing/parser.ml" - : 'additive)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2560 "parsing/parser.mly" - ( _1 ) -# 12889 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in - Obj.repr( -# 2561 "parsing/parser.mly" - ( _1 ) -# 12896 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2562 "parsing/parser.mly" - ( "and" ) -# 12902 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2563 "parsing/parser.mly" - ( "as" ) -# 12908 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2564 "parsing/parser.mly" - ( "assert" ) -# 12914 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2565 "parsing/parser.mly" - ( "begin" ) -# 12920 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2566 "parsing/parser.mly" - ( "class" ) -# 12926 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2567 "parsing/parser.mly" - ( "constraint" ) -# 12932 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2568 "parsing/parser.mly" - ( "do" ) -# 12938 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2569 "parsing/parser.mly" - ( "done" ) -# 12944 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2570 "parsing/parser.mly" - ( "downto" ) -# 12950 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2571 "parsing/parser.mly" - ( "else" ) -# 12956 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2572 "parsing/parser.mly" - ( "end" ) -# 12962 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2573 "parsing/parser.mly" - ( "exception" ) -# 12968 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2574 "parsing/parser.mly" - ( "external" ) -# 12974 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2575 "parsing/parser.mly" - ( "false" ) -# 12980 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2576 "parsing/parser.mly" - ( "for" ) -# 12986 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2577 "parsing/parser.mly" - ( "fun" ) -# 12992 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2578 "parsing/parser.mly" - ( "function" ) -# 12998 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2579 "parsing/parser.mly" - ( "functor" ) -# 13004 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2580 "parsing/parser.mly" - ( "if" ) -# 13010 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2581 "parsing/parser.mly" - ( "in" ) -# 13016 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2582 "parsing/parser.mly" - ( "include" ) -# 13022 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2583 "parsing/parser.mly" - ( "inherit" ) -# 13028 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2584 "parsing/parser.mly" - ( "initializer" ) -# 13034 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2585 "parsing/parser.mly" - ( "lazy" ) -# 13040 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2586 "parsing/parser.mly" - ( "let" ) -# 13046 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2587 "parsing/parser.mly" - ( "match" ) -# 13052 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2588 "parsing/parser.mly" - ( "method" ) -# 13058 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2589 "parsing/parser.mly" - ( "module" ) -# 13064 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2590 "parsing/parser.mly" - ( "mutable" ) -# 13070 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2591 "parsing/parser.mly" - ( "new" ) -# 13076 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2592 "parsing/parser.mly" - ( "nonrec" ) -# 13082 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2593 "parsing/parser.mly" - ( "object" ) -# 13088 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2594 "parsing/parser.mly" - ( "of" ) -# 13094 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2595 "parsing/parser.mly" - ( "open" ) -# 13100 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2596 "parsing/parser.mly" - ( "or" ) -# 13106 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2597 "parsing/parser.mly" - ( "private" ) -# 13112 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2598 "parsing/parser.mly" - ( "rec" ) -# 13118 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2599 "parsing/parser.mly" - ( "sig" ) -# 13124 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2600 "parsing/parser.mly" - ( "struct" ) -# 13130 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2601 "parsing/parser.mly" - ( "then" ) -# 13136 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2602 "parsing/parser.mly" - ( "to" ) -# 13142 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2603 "parsing/parser.mly" - ( "true" ) -# 13148 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2604 "parsing/parser.mly" - ( "try" ) -# 13154 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2605 "parsing/parser.mly" - ( "type" ) -# 13160 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2606 "parsing/parser.mly" - ( "val" ) -# 13166 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2607 "parsing/parser.mly" - ( "virtual" ) -# 13172 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2608 "parsing/parser.mly" - ( "when" ) -# 13178 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2609 "parsing/parser.mly" - ( "while" ) -# 13184 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - Obj.repr( -# 2610 "parsing/parser.mly" - ( "with" ) -# 13190 "parsing/parser.ml" - : 'single_attr_id)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'single_attr_id) in - Obj.repr( -# 2615 "parsing/parser.mly" - ( mkloc _1 (symbol_rloc()) ) -# 13197 "parsing/parser.ml" - : 'attr_id)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 2 : 'single_attr_id) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'attr_id) in - Obj.repr( -# 2616 "parsing/parser.mly" - ( mkloc (_1 ^ "." ^ _3.txt) (symbol_rloc())) -# 13205 "parsing/parser.ml" - : 'attr_id)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attr_id) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'payload) in - Obj.repr( -# 2619 "parsing/parser.mly" - ( (_2, _3) ) -# 13213 "parsing/parser.ml" - : 'attribute)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attr_id) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'payload) in - Obj.repr( -# 2622 "parsing/parser.mly" - ( (_2, _3) ) -# 13221 "parsing/parser.ml" - : 'post_item_attribute)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attr_id) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'payload) in - Obj.repr( -# 2625 "parsing/parser.mly" - ( (_2, _3) ) -# 13229 "parsing/parser.ml" - : 'floating_attribute)) -; (fun __caml_parser_env -> - Obj.repr( -# 2628 "parsing/parser.mly" - ( [] ) -# 13235 "parsing/parser.ml" - : 'post_item_attributes)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'post_item_attribute) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in - Obj.repr( -# 2629 "parsing/parser.mly" - ( _1 :: _2 ) -# 13243 "parsing/parser.ml" - : 'post_item_attributes)) -; (fun __caml_parser_env -> - Obj.repr( -# 2632 "parsing/parser.mly" - ( [] ) -# 13249 "parsing/parser.ml" - : 'attributes)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'attribute) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in - Obj.repr( -# 2633 "parsing/parser.mly" - ( _1 :: _2 ) -# 13257 "parsing/parser.ml" - : 'attributes)) -; (fun __caml_parser_env -> - Obj.repr( -# 2636 "parsing/parser.mly" - ( None, [] ) -# 13263 "parsing/parser.ml" - : 'ext_attributes)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 1 : 'attribute) in - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in - Obj.repr( -# 2637 "parsing/parser.mly" - ( None, _1 :: _2 ) -# 13271 "parsing/parser.ml" - : 'ext_attributes)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 1 : 'attr_id) in - let _3 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in - Obj.repr( -# 2638 "parsing/parser.mly" - ( Some _2, _3 ) -# 13279 "parsing/parser.ml" - : 'ext_attributes)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attr_id) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'payload) in - Obj.repr( -# 2641 "parsing/parser.mly" - ( (_2, _3) ) -# 13287 "parsing/parser.ml" - : 'extension)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attr_id) in - let _3 = (Parsing.peek_val __caml_parser_env 1 : 'payload) in - Obj.repr( -# 2644 "parsing/parser.mly" - ( (_2, _3) ) -# 13295 "parsing/parser.ml" - : 'item_extension)) -; (fun __caml_parser_env -> - let _1 = (Parsing.peek_val __caml_parser_env 0 : 'structure) in - Obj.repr( -# 2647 "parsing/parser.mly" - ( PStr _1 ) -# 13302 "parsing/parser.ml" - : 'payload)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'signature) in - Obj.repr( -# 2648 "parsing/parser.mly" - ( PSig _2 ) -# 13309 "parsing/parser.ml" - : 'payload)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in - Obj.repr( -# 2649 "parsing/parser.mly" - ( PTyp _2 ) -# 13316 "parsing/parser.ml" - : 'payload)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in - Obj.repr( -# 2650 "parsing/parser.mly" - ( PPat (_2, None) ) -# 13323 "parsing/parser.ml" - : 'payload)) -; (fun __caml_parser_env -> - let _2 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in - let _4 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in - Obj.repr( -# 2651 "parsing/parser.mly" - ( PPat (_2, Some _4) ) -# 13331 "parsing/parser.ml" - : 'payload)) -(* Entry implementation *) -; (fun __caml_parser_env -> raise (Parsing.YYexit (Parsing.peek_val __caml_parser_env 0))) -(* Entry interface *) -; (fun __caml_parser_env -> raise (Parsing.YYexit (Parsing.peek_val __caml_parser_env 0))) -(* Entry toplevel_phrase *) -; (fun __caml_parser_env -> raise (Parsing.YYexit (Parsing.peek_val __caml_parser_env 0))) -(* Entry use_file *) -; (fun __caml_parser_env -> raise (Parsing.YYexit (Parsing.peek_val __caml_parser_env 0))) -(* Entry parse_core_type *) -; (fun __caml_parser_env -> raise (Parsing.YYexit (Parsing.peek_val __caml_parser_env 0))) -(* Entry parse_expression *) -; (fun __caml_parser_env -> raise (Parsing.YYexit (Parsing.peek_val __caml_parser_env 0))) -(* Entry parse_pattern *) -; (fun __caml_parser_env -> raise (Parsing.YYexit (Parsing.peek_val __caml_parser_env 0))) -|] -let yytables = - { Parsing.actions=yyact; - Parsing.transl_const=yytransl_const; - Parsing.transl_block=yytransl_block; - Parsing.lhs=yylhs; - Parsing.len=yylen; - Parsing.defred=yydefred; - Parsing.dgoto=yydgoto; - Parsing.sindex=yysindex; - Parsing.rindex=yyrindex; - Parsing.gindex=yygindex; - Parsing.tablesize=yytablesize; - Parsing.table=yytable; - Parsing.check=yycheck; - Parsing.error_function=parse_error; - Parsing.names_const=yynames_const; - Parsing.names_block=yynames_block } -let implementation (lexfun : Lexing.lexbuf -> token) (lexbuf : Lexing.lexbuf) = - (Parsing.yyparse yytables 1 lexfun lexbuf : Parsetree.structure) -let interface (lexfun : Lexing.lexbuf -> token) (lexbuf : Lexing.lexbuf) = - (Parsing.yyparse yytables 2 lexfun lexbuf : Parsetree.signature) -let toplevel_phrase (lexfun : Lexing.lexbuf -> token) (lexbuf : Lexing.lexbuf) = - (Parsing.yyparse yytables 3 lexfun lexbuf : Parsetree.toplevel_phrase) -let use_file (lexfun : Lexing.lexbuf -> token) (lexbuf : Lexing.lexbuf) = - (Parsing.yyparse yytables 4 lexfun lexbuf : Parsetree.toplevel_phrase list) -let parse_core_type (lexfun : Lexing.lexbuf -> token) (lexbuf : Lexing.lexbuf) = - (Parsing.yyparse yytables 5 lexfun lexbuf : Parsetree.core_type) -let parse_expression (lexfun : Lexing.lexbuf -> token) (lexbuf : Lexing.lexbuf) = - (Parsing.yyparse yytables 6 lexfun lexbuf : Parsetree.expression) -let parse_pattern (lexfun : Lexing.lexbuf -> token) (lexbuf : Lexing.lexbuf) = - (Parsing.yyparse yytables 7 lexfun lexbuf : Parsetree.pattern) -;; - -end -module Lexer : sig -#1 "lexer.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) - -(* The lexical analyzer *) - -val init : unit -> unit -val token: Lexing.lexbuf -> Parser.token -val skip_hash_bang: Lexing.lexbuf -> unit - -type directive_type - -type error = - | Illegal_character of char - | Illegal_escape of string - | Unterminated_comment of Location.t - | Unterminated_string - | Unterminated_string_in_comment of Location.t * Location.t - | Keyword_as_label of string - | Invalid_literal of string - | Invalid_directive of string * string option - | Unterminated_paren_in_conditional - | Unterminated_if - | Unterminated_else - | Unexpected_token_in_conditional - | Expect_hash_then_in_conditional - | Illegal_semver of string - | Unexpected_directive - | Conditional_expr_expected_type of directive_type * directive_type -;; - -exception Error of error * Location.t - -open Format - -val report_error: formatter -> error -> unit - (* Deprecated. Use Location.{error_of_exn, report_error}. *) - -val in_comment : unit -> bool;; -val in_string : unit -> bool;; - - -val print_warnings : bool ref -val handle_docstrings: bool ref -val comments : unit -> (string * Location.t) list -val token_with_comments : Lexing.lexbuf -> Parser.token - -(* - [set_preprocessor init preprocessor] registers [init] as the function -to call to initialize the preprocessor when the lexer is initialized, -and [preprocessor] a function that is called when a new token is needed -by the parser, as [preprocessor lexer lexbuf] where [lexer] is the -lexing function. - -When a preprocessor is configured by calling [set_preprocessor], the lexer -changes its behavior to accept backslash-newline as a token-separating blank. -*) - -val set_preprocessor : - (unit -> unit) -> - ((Lexing.lexbuf -> Parser.token) -> Lexing.lexbuf -> Parser.token) -> - unit - -(** semantic version predicate *) -val semver : Location.t -> string -> string -> bool - -val filter_directive_from_lexbuf : Lexing.lexbuf -> (int * int) list - -val replace_directive_int : string -> int -> unit -val replace_directive_string : string -> string -> unit -val replace_directive_bool : string -> bool -> unit -val remove_directive_built_in_value : string -> unit - -(** @return false means failed to define *) -val define_key_value : string -> string -> bool -val list_variables : Format.formatter -> unit - -end = struct -#1 "lexer.ml" -# 18 "parsing/lexer.mll" - -open Lexing -open Misc -open Parser - -type directive_value = - | Dir_bool of bool - | Dir_float of float - | Dir_int of int - | Dir_string of string - | Dir_null - -type directive_type = - | Dir_type_bool - | Dir_type_float - | Dir_type_int - | Dir_type_string - | Dir_type_null - -let type_of_directive x = - match x with - | Dir_bool _ -> Dir_type_bool - | Dir_float _ -> Dir_type_float - | Dir_int _ -> Dir_type_int - | Dir_string _ -> Dir_type_string - | Dir_null -> Dir_type_null - -let string_of_type_directive x = - match x with - | Dir_type_bool -> "bool" - | Dir_type_float -> "float" - | Dir_type_int -> "int" - | Dir_type_string -> "string" - | Dir_type_null -> "null" - -type error = - | Illegal_character of char - | Illegal_escape of string - | Unterminated_comment of Location.t - | Unterminated_string - | Unterminated_string_in_comment of Location.t * Location.t - | Keyword_as_label of string - | Invalid_literal of string - | Invalid_directive of string * string option - | Unterminated_paren_in_conditional - | Unterminated_if - | Unterminated_else - | Unexpected_token_in_conditional - | Expect_hash_then_in_conditional - | Illegal_semver of string - | Unexpected_directive - | Conditional_expr_expected_type of directive_type * directive_type - -;; - -exception Error of error * Location.t;; - -let assert_same_type lexbuf x y = - let lhs = type_of_directive x in let rhs = type_of_directive y in - if lhs <> rhs then - raise (Error(Conditional_expr_expected_type(lhs,rhs), Location.curr lexbuf)) - else y - -let directive_built_in_values = - Hashtbl.create 51 - - -let replace_directive_built_in_value k v = - Hashtbl.replace directive_built_in_values k v - -let remove_directive_built_in_value k = - Hashtbl.replace directive_built_in_values k Dir_null - -let replace_directive_int k v = - Hashtbl.replace directive_built_in_values k (Dir_int v) - -let replace_directive_bool k v = - Hashtbl.replace directive_built_in_values k (Dir_bool v) - -let replace_directive_string k v = - Hashtbl.replace directive_built_in_values k (Dir_string v) - -let () = - (* Note we use {!Config} instead of {!Sys} becasue - we want to overwrite in some cases with the - same stdlib - *) - let version = - Config.version (* so that it can be overridden*) - in - replace_directive_built_in_value "OCAML_VERSION" - (Dir_string version); - replace_directive_built_in_value "OCAML_PATCH" - (Dir_string - (match String.rindex version '+' with - | exception Not_found -> "" - | i -> - String.sub version (i + 1) - (String.length version - i - 1))) - ; - replace_directive_built_in_value "OS_TYPE" - (Dir_string Sys.os_type); - replace_directive_built_in_value "BIG_ENDIAN" - (Dir_bool Sys.big_endian); - replace_directive_built_in_value "WORD_SIZE" - (Dir_int Sys.word_size) - -let find_directive_built_in_value k = - Hashtbl.find directive_built_in_values k - -let iter_directive_built_in_value f = Hashtbl.iter f directive_built_in_values - -(* - {[ - # semver 0 "12";; - - : int * int * int * string = (12, 0, 0, "");; - # semver 0 "12.3";; - - : int * int * int * string = (12, 3, 0, "");; - semver 0 "12.3.10";; - - : int * int * int * string = (12, 3, 10, "");; - # semver 0 "12.3.10+x";; - - : int * int * int * string = (12, 3, 10, "+x") - ]} -*) -let zero = Char.code '0' -let dot = Char.code '.' -let semantic_version_parse str start last_index = - let rec aux start acc last_index = - if start <= last_index then - let c = Char.code (String.unsafe_get str start) in - if c = dot then (acc, start + 1) (* consume [4.] instead of [4]*) - else - let v = c - zero in - if v >=0 && v <= 9 then - aux (start + 1) (acc * 10 + v) last_index - else (acc , start) - else (acc, start) - in - let major, major_end = aux start 0 last_index in - let minor, minor_end = aux major_end 0 last_index in - let patch, patch_end = aux minor_end 0 last_index in - let additional = String.sub str patch_end (last_index - patch_end +1) in - (major, minor, patch), additional - -(** - {[ - semver Location.none "1.2.3" "~1.3.0" = false;; - semver Location.none "1.2.3" "^1.3.0" = true ;; - semver Location.none "1.2.3" ">1.3.0" = false ;; - semver Location.none "1.2.3" ">=1.3.0" = false ;; - semver Location.none "1.2.3" "<1.3.0" = true ;; - semver Location.none "1.2.3" "<=1.3.0" = true ;; - ]} -*) -let semver loc lhs str = - let last_index = String.length str - 1 in - if last_index < 0 then raise (Error(Illegal_semver str, loc)) - else - let pred, ((major, minor, _patch) as version, _) = - let v = String.unsafe_get str 0 in - match v with - | '>' -> - if last_index = 0 then raise (Error(Illegal_semver str, loc)) else - if String.unsafe_get str 1 = '=' then - `Ge, semantic_version_parse str 2 last_index - else `Gt, semantic_version_parse str 1 last_index - | '<' - -> - if last_index = 0 then raise (Error(Illegal_semver str, loc)) else - if String.unsafe_get str 1 = '=' then - `Le, semantic_version_parse str 2 last_index - else `Lt, semantic_version_parse str 1 last_index - | '^' - -> `Compatible, semantic_version_parse str 1 last_index - | '~' -> `Approximate, semantic_version_parse str 1 last_index - | _ -> `Exact, semantic_version_parse str 0 last_index - in - let ((l_major, l_minor, _l_patch) as lversion,_) = - semantic_version_parse lhs 0 (String.length lhs - 1) in - match pred with - | `Ge -> lversion >= version - | `Gt -> lversion > version - | `Le -> lversion <= version - | `Lt -> lversion < version - | `Approximate -> major = l_major && minor = l_minor - | `Compatible -> major = l_major - | `Exact -> lversion = version - - -let pp_directive_value fmt (x : directive_value) = - match x with - | Dir_bool b -> Format.pp_print_bool fmt b - | Dir_int b -> Format.pp_print_int fmt b - | Dir_float b -> Format.pp_print_float fmt b - | Dir_string s -> Format.fprintf fmt "%S" s - | Dir_null -> Format.pp_print_string fmt "null" - -let list_variables fmt = - iter_directive_built_in_value - (fun s dir_value -> - Format.fprintf - fmt "@[%s@ %a@]@." - s pp_directive_value dir_value - ) - -let defined str = - begin match find_directive_built_in_value str with - | Dir_null -> false - | _ -> true - | exception _ -> - try ignore @@ Sys.getenv str; true with _ -> false - end - -let query _loc str = - begin match find_directive_built_in_value str with - | Dir_null -> Dir_bool false - | v -> v - | exception Not_found -> - begin match Sys.getenv str with - | v -> - begin - try Dir_bool (bool_of_string v) with - _ -> - begin - try Dir_int (int_of_string v ) - with - _ -> - begin try (Dir_float (float_of_string v)) - with _ -> Dir_string v - end - end - end - | exception Not_found -> - Dir_bool false - end - end - - -let define_key_value key v = - if String.length key > 0 - && Char.uppercase_ascii (key.[0]) = key.[0] then - begin - replace_directive_built_in_value key - begin - (* NEED Sync up across {!lexer.mll} {!bspp.ml} and here, - TODO: put it in {!lexer.mll} - *) - try Dir_bool (bool_of_string v) with - _ -> - begin - try Dir_int (int_of_string v ) - with - _ -> - begin try (Dir_float (float_of_string v)) - with _ -> Dir_string v - end - end - end; - true - end - else false - -let cvt_int_literal s = - - int_of_string ("-" ^ s) - -let value_of_token loc (t : Parser.token) = - match t with - | INT (i,None) -> Dir_int (cvt_int_literal i) - | STRING (s,_) -> Dir_string s - | FLOAT (s,None) -> Dir_float (float_of_string s) - | TRUE -> Dir_bool true - | FALSE -> Dir_bool false - | UIDENT s -> query loc s - | _ -> raise (Error (Unexpected_token_in_conditional, loc)) - - -let directive_parse token_with_comments lexbuf = - let look_ahead = ref None in - let token () : Parser.token = - let v = !look_ahead in - match v with - | Some v -> - look_ahead := None ; - v - | None -> - let rec skip () = - match token_with_comments lexbuf with - | COMMENT _ - | DOCSTRING _ - | EOL -> skip () - | EOF -> raise (Error (Unterminated_if, Location.curr lexbuf)) - | t -> t - in skip () - in - let push e = - (* INVARIANT: only look at most one token *) - assert (!look_ahead = None); - look_ahead := Some e - in - let rec - token_op calc ~no lhs = - match token () with - | (LESS - | GREATER - | INFIXOP0 "<=" - | INFIXOP0 ">=" - | EQUAL - | INFIXOP0 "<>" as op) -> - let f = - match op with - | LESS -> (<) - | GREATER -> (>) - | INFIXOP0 "<=" -> (<=) - | EQUAL -> (=) - | INFIXOP0 "<>" -> (<>) - | _ -> assert false - in - let curr_loc = Location.curr lexbuf in - let rhs = value_of_token curr_loc (token ()) in - not calc || - f lhs (assert_same_type lexbuf lhs rhs) - | INFIXOP0 "=~" -> - not calc || - begin match lhs with - | Dir_string s -> - let curr_loc = Location.curr lexbuf in - let rhs = value_of_token curr_loc (token ()) in - begin match rhs with - | Dir_string rhs -> - semver curr_loc s rhs - | _ -> - raise - (Error - ( Conditional_expr_expected_type - (Dir_type_string, type_of_directive lhs), Location.curr lexbuf)) - end - | _ -> raise - (Error - ( Conditional_expr_expected_type - (Dir_type_string, type_of_directive lhs), Location.curr lexbuf)) - end - | e -> no e - and - parse_or calc : bool = - parse_or_aux calc (parse_and calc) - and (* a || (b || (c || d))*) - parse_or_aux calc v : bool = - (* let l = v in *) - match token () with - | BARBAR -> - let b = parse_or (calc && not v) in - v || b - | e -> push e ; v - and parse_and calc = - parse_and_aux calc (parse_relation calc) - and parse_and_aux calc v = (* a && (b && (c && d)) *) - (* let l = v in *) - match token () with - | AMPERAMPER -> - let b = parse_and (calc && v) in - v && b - | e -> push e ; v - and parse_relation (calc : bool) : bool = - let curr_token = token () in - let curr_loc = Location.curr lexbuf in - match curr_token with - | TRUE -> true - | FALSE -> false - | UIDENT v -> - let value_v = query curr_loc v in - token_op calc - ~no:(fun e -> push e ; - match value_v with - | Dir_bool b -> b - | _ -> - let ty = type_of_directive value_v in - raise - (Error(Conditional_expr_expected_type (Dir_type_bool, ty), - curr_loc))) - value_v - | INT (v,None) -> - let num_v = cvt_int_literal v in - token_op calc - ~no:(fun e -> - push e; - num_v <> 0 - ) - (Dir_int num_v) - | FLOAT (v,None) -> - token_op calc - ~no:(fun _e -> - raise (Error(Conditional_expr_expected_type(Dir_type_bool, Dir_type_float), - curr_loc))) - (Dir_float (float_of_string v)) - | STRING (v,_) -> - token_op calc - ~no:(fun _e -> - raise (Error - (Conditional_expr_expected_type(Dir_type_bool, Dir_type_string), - curr_loc))) - (Dir_string v) - | LIDENT ("defined" | "undefined" as r) -> - let t = token () in - let loc = Location.curr lexbuf in - begin match t with - | UIDENT s -> - not calc || - if r.[0] = 'u' then - not @@ defined s - else defined s - | _ -> raise (Error (Unexpected_token_in_conditional, loc)) - end - | LPAREN -> - let v = parse_or calc in - begin match token () with - | RPAREN -> v - | _ -> raise (Error(Unterminated_paren_in_conditional, Location.curr lexbuf)) - end - - | _ -> raise (Error (Unexpected_token_in_conditional, curr_loc)) - in - let v = parse_or true in - begin match token () with - | THEN -> v - | _ -> raise (Error (Expect_hash_then_in_conditional, Location.curr lexbuf)) - end - - -type dir_conditional = - | Dir_if_true - | Dir_if_false - | Dir_out - -(* let string_of_dir_conditional (x : dir_conditional) = *) -(* match x with *) -(* | Dir_if_true -> "Dir_if_true" *) -(* | Dir_if_false -> "Dir_if_false" *) -(* | Dir_out -> "Dir_out" *) - -let is_elif (i : Parser.token ) = - match i with - | LIDENT "elif" -> true - | _ -> false (* avoid polymorphic equal *) - - -(* The table of keywords *) - -let keyword_table = - create_hashtable 149 [ - "and", AND; - "as", AS; - "assert", ASSERT; - "begin", BEGIN; - "class", CLASS; - "constraint", CONSTRAINT; - "do", DO; - "done", DONE; - "downto", DOWNTO; - "else", ELSE; - "end", END; - "exception", EXCEPTION; - "external", EXTERNAL; - "false", FALSE; - "for", FOR; - "fun", FUN; - "function", FUNCTION; - "functor", FUNCTOR; - "if", IF; - "in", IN; - "include", INCLUDE; - "inherit", INHERIT; - "initializer", INITIALIZER; - "lazy", LAZY; - "let", LET; - "match", MATCH; - "method", METHOD; - "module", MODULE; - "mutable", MUTABLE; - "new", NEW; - "nonrec", NONREC; - "object", OBJECT; - "of", OF; - "open", OPEN; - "or", OR; -(* "parser", PARSER; *) - "private", PRIVATE; - "rec", REC; - "sig", SIG; - "struct", STRUCT; - "then", THEN; - "to", TO; - "true", TRUE; - "try", TRY; - "type", TYPE; - "val", VAL; - "virtual", VIRTUAL; - "when", WHEN; - "while", WHILE; - "with", WITH; - - "lor", INFIXOP3("lor"); (* Should be INFIXOP2 *) - "lxor", INFIXOP3("lxor"); (* Should be INFIXOP2 *) - "mod", INFIXOP3("mod"); - "land", INFIXOP3("land"); - "lsl", INFIXOP4("lsl"); - "lsr", INFIXOP4("lsr"); - "asr", INFIXOP4("asr") -] - -(* To buffer string literals *) - -let string_buffer = Buffer.create 256 -let reset_string_buffer () = Buffer.reset string_buffer -let get_stored_string () = Buffer.contents string_buffer - -let store_string_char c = Buffer.add_char string_buffer c -let store_string_utf_8_uchar u = Buffer.add_utf_8_uchar string_buffer u -let store_string s = Buffer.add_string string_buffer s -let store_lexeme lexbuf = store_string (Lexing.lexeme lexbuf) - -(* To store the position of the beginning of a string and comment *) -let string_start_loc = ref Location.none;; -let comment_start_loc = ref [];; -let in_comment () = !comment_start_loc <> [];; -let is_in_string = ref false -let in_string () = !is_in_string -let print_warnings = ref true -let if_then_else = ref Dir_out -let sharp_look_ahead = ref None -let update_if_then_else v = - (* Format.fprintf Format.err_formatter "@[update %s \n@]@." (string_of_dir_conditional v); *) - if_then_else := v - -(* Escaped chars are interpreted in strings unless they are in comments. *) -let store_escaped_char lexbuf c = - if in_comment () then store_lexeme lexbuf else store_string_char c - -let store_escaped_uchar lexbuf u = - if in_comment () then store_lexeme lexbuf else store_string_utf_8_uchar u - -let with_comment_buffer comment lexbuf = - let start_loc = Location.curr lexbuf in - comment_start_loc := [start_loc]; - reset_string_buffer (); - let end_loc = comment lexbuf in - let s = get_stored_string () in - reset_string_buffer (); - let loc = { start_loc with Location.loc_end = end_loc.Location.loc_end } in - s, loc - -(* To translate escape sequences *) - -let hex_digit_value d = (* assert (d in '0'..'9' 'a'..'f' 'A'..'F') *) - let d = Char.code d in - if d >= 97 then d - 87 else - if d >= 65 then d - 55 else - d - 48 - -let hex_num_value lexbuf ~first ~last = - let rec loop acc i = match i > last with - | true -> acc - | false -> - let value = hex_digit_value (Lexing.lexeme_char lexbuf i) in - loop (16 * acc + value) (i + 1) - in - loop 0 first - -let char_for_backslash = function - | 'n' -> '\010' - | 'r' -> '\013' - | 'b' -> '\008' - | 't' -> '\009' - | c -> c - -let char_for_decimal_code lexbuf i = - let c = 100 * (Char.code(Lexing.lexeme_char lexbuf i) - 48) + - 10 * (Char.code(Lexing.lexeme_char lexbuf (i+1)) - 48) + - (Char.code(Lexing.lexeme_char lexbuf (i+2)) - 48) in - if (c < 0 || c > 255) then - if in_comment () - then 'x' - else raise (Error(Illegal_escape (Lexing.lexeme lexbuf), - Location.curr lexbuf)) - else Char.chr c - -let char_for_octal_code lexbuf i = - let c = 64 * (Char.code(Lexing.lexeme_char lexbuf i) - 48) + - 8 * (Char.code(Lexing.lexeme_char lexbuf (i+1)) - 48) + - (Char.code(Lexing.lexeme_char lexbuf (i+2)) - 48) in - Char.chr c - -let char_for_hexadecimal_code lexbuf i = - let byte = hex_num_value lexbuf ~first:i ~last:(i+1) in - Char.chr byte - -let uchar_for_uchar_escape lexbuf = - let err e = - raise - (Error (Illegal_escape (Lexing.lexeme lexbuf ^ e), Location.curr lexbuf)) - in - let len = Lexing.lexeme_end lexbuf - Lexing.lexeme_start lexbuf in - let first = 3 (* skip opening \u{ *) in - let last = len - 2 (* skip closing } *) in - let digit_count = last - first + 1 in - match digit_count > 6 with - | true -> err ", too many digits, expected 1 to 6 hexadecimal digits" - | false -> - let cp = hex_num_value lexbuf ~first ~last in - if Uchar.is_valid cp then Uchar.unsafe_of_int cp else - err (", " ^ Printf.sprintf "%X" cp ^ " is not a Unicode scalar value") - -(* recover the name from a LABEL or OPTLABEL token *) - -let get_label_name lexbuf = - let s = Lexing.lexeme lexbuf in - let name = String.sub s 1 (String.length s - 2) in - if Hashtbl.mem keyword_table name then - raise (Error(Keyword_as_label name, Location.curr lexbuf)); - name -;; - -(* Update the current location with file name and line number. *) - -let update_loc lexbuf file line absolute chars = - let pos = lexbuf.lex_curr_p in - let new_file = match file with - | None -> pos.pos_fname - | Some s -> s - in - lexbuf.lex_curr_p <- { pos with - pos_fname = new_file; - pos_lnum = if absolute then line else pos.pos_lnum + line; - pos_bol = pos.pos_cnum - chars; - } -;; - -let preprocessor = ref None - -let escaped_newlines = ref false - -(* Warn about Latin-1 characters used in idents *) - -let warn_latin1 lexbuf = - Location.deprecated (Location.curr lexbuf)"ISO-Latin1 characters in identifiers" - -let handle_docstrings = ref true -let comment_list = ref [] - -let add_comment com = - comment_list := com :: !comment_list - -let add_docstring_comment ds = - let com = - ("*" ^ Docstrings.docstring_body ds, Docstrings.docstring_loc ds) - in - add_comment com - -let comments () = List.rev !comment_list - -(* Error report *) - -open Format - -let report_error ppf = function - | Illegal_character c -> - fprintf ppf "Illegal character (%s)" (Char.escaped c) - | Illegal_escape s -> - fprintf ppf "Illegal backslash escape in string or character (%s)" s - | Unterminated_comment _ -> - fprintf ppf "Comment not terminated" - | Unterminated_string -> - fprintf ppf "String literal not terminated" - | Unterminated_string_in_comment (_, loc) -> - fprintf ppf "This comment contains an unterminated string literal@.\ - %aString literal begins here" - Location.print_error loc - | Keyword_as_label kwd -> - fprintf ppf "`%s' is a keyword, it cannot be used as label name" kwd - | Invalid_literal s -> - fprintf ppf "Invalid literal %s" s - | Invalid_directive (dir, explanation) -> - fprintf ppf "Invalid lexer directive %S" dir; - begin match explanation with - | None -> () - | Some expl -> fprintf ppf ": %s" expl - end - | Unterminated_if -> - fprintf ppf "#if not terminated" - | Unterminated_else -> - fprintf ppf "#else not terminated" - | Unexpected_directive -> fprintf ppf "Unexpected directive" - | Unexpected_token_in_conditional -> - fprintf ppf "Unexpected token in conditional predicate" - | Unterminated_paren_in_conditional -> - fprintf ppf "Unterminated parens in conditional predicate" - | Expect_hash_then_in_conditional -> - fprintf ppf "Expect `then` after conditional predicate" - | Conditional_expr_expected_type (a,b) -> - fprintf ppf "Conditional expression type mismatch (%s,%s)" - (string_of_type_directive a ) - (string_of_type_directive b ) - | Illegal_semver s -> - fprintf ppf "Illegal semantic version string %s" s - -let () = - Location.register_error_of_exn - (function - | Error (err, loc) -> - Some (Location.error_of_printer loc report_error err) - | _ -> - None - ) - - -# 717 "parsing/lexer.ml" -let __ocaml_lex_tables = { - Lexing.lex_base = - "\000\000\162\255\163\255\224\000\003\001\038\001\073\001\108\001\ - \143\001\186\255\178\001\215\001\194\255\091\000\252\001\031\002\ - \068\000\071\000\065\002\100\002\212\255\214\255\217\255\135\002\ - \230\002\009\003\088\000\255\000\039\003\236\255\123\003\207\003\ - \035\004\243\004\195\005\147\006\114\007\206\007\158\008\122\000\ - \254\255\001\000\005\000\255\255\006\000\007\000\125\009\155\009\ - \107\010\250\255\249\255\059\011\011\012\247\255\246\255\219\012\ - \047\013\131\013\215\013\043\014\127\014\211\014\039\015\123\015\ - \207\015\035\016\087\000\119\016\203\016\031\017\115\017\199\017\ - \108\000\192\255\235\255\007\003\034\018\106\000\107\000\011\000\ - \234\255\233\255\228\255\152\002\099\000\118\000\113\000\232\255\ - \128\000\147\000\231\255\224\000\003\001\148\000\230\255\110\004\ - \149\000\229\255\148\000\224\255\217\000\223\255\222\000\034\018\ - \222\255\073\018\101\005\009\003\221\255\012\000\014\001\080\001\ - \115\001\024\001\221\255\013\000\119\018\158\018\193\018\231\018\ - \010\019\209\255\204\255\205\255\206\255\202\255\045\019\154\000\ - \183\000\195\255\196\255\197\255\217\000\182\255\180\255\189\255\ - \080\019\185\255\187\255\115\019\150\019\185\019\220\019\130\005\ - \243\255\244\255\017\000\245\255\174\001\223\005\253\255\248\000\ - \249\000\255\255\254\255\252\255\005\006\238\019\003\001\004\001\ - \018\000\251\255\250\255\249\255\222\006\026\003\005\001\248\255\ - \036\003\008\001\247\255\066\008\020\001\246\255\059\001\234\001\ - \245\255\246\255\247\255\060\001\055\020\255\255\248\255\193\000\ - \233\008\038\001\133\004\253\255\073\001\094\001\113\001\143\004\ - \252\255\192\002\027\004\251\255\230\009\250\255\182\010\089\020\ - \249\255\129\001\130\001\252\255\085\007\254\255\255\255\146\001\ - \147\001\253\255\177\007\033\001\044\001\148\001\151\001\045\001\ - \153\001\044\001\019\000\255\255"; - Lexing.lex_backtrk = - "\255\255\255\255\255\255\090\000\089\000\086\000\085\000\078\000\ - \076\000\255\255\067\000\064\000\255\255\057\000\056\000\054\000\ - \052\000\048\000\045\000\081\000\255\255\255\255\255\255\036\000\ - \035\000\042\000\040\000\039\000\062\000\255\255\014\000\014\000\ - \013\000\012\000\011\000\010\000\007\000\004\000\003\000\002\000\ - \255\255\093\000\093\000\255\255\255\255\255\255\084\000\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\018\000\ - \018\000\016\000\015\000\018\000\015\000\015\000\014\000\016\000\ - \015\000\016\000\255\255\017\000\017\000\014\000\014\000\016\000\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\027\000\027\000\027\000\027\000\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\028\000\255\255\029\000\255\255\030\000\088\000\ - \255\255\091\000\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\037\000\087\000\082\000\044\000\ - \047\000\255\255\255\255\255\255\255\255\255\255\055\000\074\000\ - \071\000\255\255\255\255\255\255\072\000\255\255\255\255\255\255\ - \065\000\255\255\255\255\083\000\077\000\080\000\079\000\255\255\ - \255\255\255\255\012\000\255\255\012\000\012\000\255\255\012\000\ - \012\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\010\000\010\000\255\255\255\255\007\000\ - \007\000\007\000\007\000\255\255\001\000\007\000\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\003\000\255\255\255\255\003\000\ - \255\255\255\255\255\255\002\000\255\255\255\255\001\000\255\255\ - \255\255\255\255\255\255\255\255"; - Lexing.lex_default = - "\001\000\000\000\000\000\255\255\255\255\255\255\255\255\255\255\ - \255\255\000\000\255\255\255\255\000\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\000\000\000\000\000\000\255\255\ - \255\255\255\255\255\255\077\000\255\255\000\000\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \000\000\255\255\255\255\000\000\255\255\255\255\255\255\255\255\ - \255\255\000\000\000\000\255\255\255\255\000\000\000\000\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\000\000\000\000\255\255\082\000\255\255\255\255\255\255\ - \000\000\000\000\000\000\255\255\255\255\255\255\255\255\000\000\ - \255\255\255\255\000\000\255\255\255\255\255\255\000\000\255\255\ - \255\255\000\000\255\255\000\000\255\255\000\000\255\255\255\255\ - \000\000\255\255\110\000\255\255\000\000\255\255\110\000\111\000\ - \110\000\113\000\000\000\255\255\255\255\255\255\255\255\255\255\ - \255\255\000\000\000\000\000\000\000\000\000\000\255\255\255\255\ - \255\255\000\000\000\000\000\000\255\255\000\000\000\000\000\000\ - \255\255\000\000\000\000\255\255\255\255\255\255\255\255\144\000\ - \000\000\000\000\255\255\000\000\158\000\255\255\000\000\255\255\ - \255\255\000\000\000\000\000\000\255\255\255\255\255\255\255\255\ - \255\255\000\000\000\000\000\000\255\255\255\255\255\255\000\000\ - \255\255\255\255\000\000\255\255\255\255\000\000\255\255\176\000\ - \000\000\000\000\000\000\255\255\182\000\000\000\000\000\255\255\ - \255\255\255\255\255\255\000\000\255\255\255\255\255\255\255\255\ - \000\000\255\255\255\255\000\000\255\255\000\000\255\255\255\255\ - \000\000\255\255\203\000\000\000\255\255\000\000\000\000\255\255\ - \255\255\000\000\255\255\255\255\255\255\213\000\216\000\255\255\ - \216\000\255\255\255\255\000\000"; - Lexing.lex_trans = - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\039\000\040\000\040\000\039\000\041\000\045\000\043\000\ - \043\000\040\000\044\000\044\000\045\000\078\000\108\000\114\000\ - \079\000\109\000\115\000\145\000\159\000\219\000\174\000\160\000\ - \039\000\008\000\029\000\024\000\006\000\004\000\023\000\027\000\ - \026\000\021\000\025\000\007\000\020\000\019\000\018\000\003\000\ - \031\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ - \030\000\030\000\017\000\016\000\015\000\014\000\010\000\036\000\ - \005\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\013\000\042\000\012\000\005\000\038\000\ - \022\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\028\000\011\000\009\000\037\000\125\000\ - \127\000\124\000\098\000\039\000\123\000\122\000\039\000\065\000\ - \065\000\065\000\065\000\065\000\065\000\065\000\065\000\065\000\ - \065\000\081\000\080\000\091\000\091\000\091\000\091\000\130\000\ - \087\000\129\000\039\000\128\000\071\000\071\000\071\000\071\000\ - \071\000\071\000\071\000\071\000\071\000\071\000\088\000\088\000\ - \088\000\088\000\088\000\088\000\088\000\088\000\088\000\088\000\ - \089\000\089\000\089\000\089\000\089\000\089\000\089\000\089\000\ - \089\000\089\000\090\000\094\000\097\000\099\000\100\000\134\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\131\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\132\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \002\000\003\000\101\000\102\000\003\000\003\000\003\000\101\000\ - \102\000\078\000\003\000\003\000\079\000\003\000\003\000\003\000\ - \092\000\092\000\092\000\092\000\092\000\092\000\092\000\092\000\ - \108\000\133\000\003\000\109\000\003\000\003\000\003\000\003\000\ - \003\000\154\000\114\000\153\000\003\000\115\000\255\255\003\000\ - \003\000\003\000\163\000\162\000\167\000\003\000\003\000\170\000\ - \003\000\003\000\003\000\093\000\093\000\093\000\093\000\093\000\ - \093\000\093\000\093\000\173\000\198\000\003\000\003\000\003\000\ - \003\000\003\000\003\000\003\000\212\000\145\000\178\000\005\000\ - \174\000\201\000\005\000\005\000\005\000\213\000\217\000\218\000\ - \005\000\005\000\188\000\005\000\005\000\005\000\193\000\193\000\ - \193\000\193\000\108\000\076\000\003\000\109\000\003\000\000\000\ - \005\000\003\000\005\000\005\000\005\000\005\000\005\000\000\000\ - \188\000\188\000\006\000\190\000\000\000\006\000\006\000\006\000\ - \000\000\000\000\113\000\006\000\006\000\000\000\006\000\006\000\ - \006\000\000\000\000\000\188\000\112\000\108\000\190\000\003\000\ - \109\000\003\000\000\000\006\000\005\000\006\000\006\000\006\000\ - \006\000\006\000\000\000\178\000\206\000\117\000\201\000\207\000\ - \117\000\117\000\117\000\112\000\000\000\111\000\117\000\117\000\ - \000\000\117\000\142\000\117\000\206\000\206\000\214\000\208\000\ - \208\000\215\000\005\000\215\000\005\000\000\000\117\000\006\000\ - \117\000\141\000\117\000\117\000\117\000\000\000\000\000\000\000\ - \139\000\000\000\000\000\139\000\139\000\139\000\000\000\000\000\ - \159\000\139\000\139\000\160\000\139\000\139\000\139\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\006\000\000\000\006\000\ - \000\000\139\000\117\000\139\000\140\000\139\000\139\000\139\000\ - \000\000\000\000\000\000\006\000\000\000\161\000\006\000\006\000\ - \006\000\000\000\000\000\000\000\006\000\006\000\000\000\006\000\ - \006\000\006\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \117\000\000\000\117\000\000\000\006\000\139\000\006\000\006\000\ - \006\000\006\000\006\000\000\000\178\000\000\000\000\000\179\000\ - \006\000\000\000\000\000\006\000\006\000\006\000\204\000\255\255\ - \000\000\006\000\006\000\000\000\006\000\006\000\006\000\000\000\ - \000\000\000\000\157\000\139\000\181\000\139\000\255\255\138\000\ - \006\000\006\000\000\000\006\000\006\000\006\000\006\000\006\000\ - \255\255\000\000\000\000\000\000\000\000\006\000\000\000\000\000\ - \006\000\006\000\006\000\000\000\000\000\000\000\006\000\006\000\ - \000\000\006\000\006\000\006\000\000\000\000\000\006\000\137\000\ - \006\000\000\000\000\000\000\000\135\000\006\000\006\000\000\000\ - \006\000\006\000\006\000\006\000\006\000\000\000\000\000\000\000\ - \006\000\000\000\000\000\006\000\006\000\006\000\180\000\000\000\ - \000\000\006\000\006\000\000\000\126\000\006\000\006\000\000\000\ - \255\255\000\000\000\000\136\000\000\000\006\000\000\000\000\000\ - \000\000\006\000\006\000\006\000\006\000\006\000\006\000\006\000\ - \000\000\000\000\120\000\000\000\000\000\120\000\120\000\120\000\ - \000\000\000\000\000\000\120\000\120\000\000\000\120\000\121\000\ - \120\000\000\000\000\000\255\255\000\000\000\000\000\000\000\000\ - \006\000\000\000\006\000\120\000\000\000\006\000\120\000\120\000\ - \120\000\120\000\205\000\000\000\000\000\117\000\000\000\000\000\ - \117\000\117\000\117\000\000\000\000\000\000\000\117\000\117\000\ - \000\000\117\000\118\000\117\000\255\255\000\000\000\000\255\255\ - \000\000\255\255\000\000\006\000\000\000\006\000\117\000\120\000\ - \117\000\117\000\119\000\117\000\117\000\000\000\000\000\000\000\ - \006\000\000\000\000\000\006\000\006\000\116\000\255\255\000\000\ - \000\000\006\000\006\000\000\000\006\000\006\000\006\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\120\000\000\000\120\000\ - \000\000\006\000\117\000\006\000\006\000\006\000\006\000\006\000\ - \095\000\095\000\095\000\095\000\095\000\095\000\095\000\095\000\ - \095\000\095\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\095\000\095\000\095\000\095\000\095\000\095\000\000\000\ - \117\000\000\000\117\000\000\000\000\000\006\000\000\000\000\000\ - \000\000\000\000\177\000\000\000\000\000\000\000\000\000\107\000\ - \194\000\194\000\194\000\194\000\194\000\194\000\194\000\194\000\ - \000\000\095\000\095\000\095\000\095\000\095\000\095\000\000\000\ - \000\000\000\000\000\000\006\000\000\000\006\000\107\000\105\000\ - \000\000\105\000\105\000\105\000\105\000\000\000\000\000\000\000\ - \105\000\105\000\107\000\105\000\105\000\105\000\106\000\106\000\ - \106\000\106\000\106\000\106\000\106\000\106\000\106\000\106\000\ - \105\000\000\000\105\000\105\000\105\000\105\000\105\000\000\000\ - \000\000\107\000\003\000\000\000\000\000\003\000\003\000\003\000\ - \000\000\000\000\104\000\103\000\003\000\000\000\003\000\003\000\ - \003\000\106\000\106\000\106\000\106\000\106\000\106\000\106\000\ - \106\000\106\000\106\000\003\000\105\000\003\000\003\000\003\000\ - \003\000\003\000\168\000\168\000\168\000\168\000\168\000\168\000\ - \168\000\168\000\168\000\168\000\169\000\169\000\169\000\169\000\ - \169\000\169\000\169\000\169\000\169\000\169\000\000\000\000\000\ - \000\000\000\000\105\000\073\000\105\000\000\000\075\000\003\000\ - \075\000\075\000\075\000\075\000\075\000\075\000\075\000\075\000\ - \075\000\075\000\075\000\075\000\075\000\075\000\075\000\075\000\ - \075\000\075\000\075\000\075\000\075\000\075\000\075\000\075\000\ - \075\000\075\000\000\000\074\000\000\000\003\000\075\000\003\000\ - \075\000\075\000\075\000\075\000\075\000\075\000\075\000\075\000\ - \075\000\075\000\075\000\075\000\075\000\075\000\075\000\075\000\ - \075\000\075\000\075\000\075\000\075\000\075\000\075\000\075\000\ - \075\000\075\000\055\000\074\000\000\000\000\000\000\000\000\000\ - \000\000\057\000\000\000\030\000\030\000\030\000\030\000\030\000\ - \030\000\030\000\030\000\030\000\030\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\055\000\055\000\055\000\055\000\ - \056\000\055\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\000\000\000\000\ - \000\000\000\000\030\000\000\000\055\000\055\000\055\000\055\000\ - \056\000\055\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\055\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\057\000\000\000\030\000\ - \030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ - \030\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \055\000\059\000\055\000\055\000\056\000\055\000\058\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\060\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\061\000\ - \058\000\058\000\000\000\000\000\000\000\000\000\030\000\000\000\ - \055\000\059\000\055\000\055\000\056\000\055\000\058\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\060\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\061\000\ - \058\000\058\000\032\000\195\000\195\000\195\000\195\000\195\000\ - \195\000\195\000\195\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\000\000\000\000\ - \000\000\000\000\032\000\000\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\096\000\096\000\ - \096\000\096\000\096\000\096\000\096\000\096\000\096\000\096\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\096\000\ - \096\000\096\000\096\000\096\000\096\000\191\000\191\000\191\000\ - \191\000\191\000\191\000\191\000\191\000\191\000\191\000\192\000\ - \192\000\192\000\192\000\192\000\192\000\192\000\192\000\192\000\ - \192\000\000\000\000\000\000\000\000\000\000\000\000\000\096\000\ - \096\000\096\000\096\000\096\000\096\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\000\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\033\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\033\000\000\000\000\000\ - \000\000\000\000\033\000\000\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\033\000\112\000\108\000\ - \000\000\000\000\109\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\112\000\000\000\111\000\ - \000\000\000\000\000\000\000\000\145\000\000\000\000\000\146\000\ - \000\000\000\000\000\000\000\000\000\000\106\000\106\000\106\000\ - \106\000\106\000\106\000\106\000\106\000\106\000\106\000\000\000\ - \000\000\000\000\000\000\000\000\150\000\000\000\000\000\000\000\ - \000\000\148\000\152\000\000\000\151\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\000\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\034\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\149\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\000\000\000\000\ - \000\000\000\000\034\000\000\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\156\000\000\000\ - \156\000\156\000\156\000\156\000\156\000\156\000\156\000\156\000\ - \156\000\156\000\156\000\156\000\156\000\156\000\156\000\156\000\ - \156\000\156\000\156\000\156\000\156\000\156\000\156\000\156\000\ - \156\000\156\000\000\000\155\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\156\000\255\255\156\000\156\000\ - \156\000\156\000\156\000\156\000\156\000\156\000\156\000\156\000\ - \156\000\156\000\156\000\156\000\156\000\156\000\156\000\156\000\ - \156\000\156\000\156\000\156\000\156\000\156\000\156\000\156\000\ - \000\000\155\000\147\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\000\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\035\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\000\000\000\000\ - \000\000\000\000\035\000\000\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\171\000\171\000\ - \171\000\171\000\171\000\171\000\171\000\171\000\171\000\171\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\171\000\ - \171\000\171\000\171\000\171\000\171\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\171\000\ - \171\000\171\000\171\000\171\000\171\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\000\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\000\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\046\000\000\000\000\000\046\000\046\000\ - \046\000\000\000\000\000\000\000\046\000\046\000\000\000\046\000\ - \046\000\046\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\046\000\000\000\046\000\046\000\ - \046\000\046\000\046\000\000\000\210\000\000\000\210\000\210\000\ - \210\000\210\000\210\000\210\000\210\000\210\000\210\000\210\000\ - \210\000\210\000\210\000\210\000\210\000\210\000\210\000\210\000\ - \210\000\210\000\210\000\210\000\210\000\210\000\210\000\210\000\ - \046\000\052\000\209\000\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\000\000\046\000\046\000\ - \046\000\000\000\046\000\046\000\046\000\000\000\000\000\000\000\ - \046\000\046\000\000\000\046\000\046\000\046\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \046\000\000\000\046\000\046\000\046\000\046\000\046\000\000\000\ - \210\000\000\000\210\000\210\000\210\000\210\000\210\000\210\000\ - \210\000\210\000\210\000\210\000\210\000\210\000\210\000\210\000\ - \210\000\210\000\210\000\210\000\210\000\210\000\210\000\210\000\ - \210\000\210\000\210\000\210\000\046\000\048\000\209\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ - \048\000\000\000\046\000\000\000\046\000\000\000\000\000\000\000\ - \000\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\000\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\172\000\172\000\172\000\172\000\172\000\172\000\ - \172\000\172\000\172\000\172\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\172\000\172\000\172\000\172\000\172\000\ - \172\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\172\000\172\000\172\000\172\000\172\000\ - \172\000\000\000\000\000\000\000\000\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\035\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\000\000\000\000\000\000\000\000\035\000\000\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\196\000\196\000\196\000\196\000\196\000\196\000\196\000\ - \196\000\196\000\196\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\196\000\196\000\196\000\196\000\196\000\196\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\196\000\196\000\196\000\196\000\196\000\196\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\000\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\000\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\046\000\000\000\ - \000\000\046\000\046\000\046\000\000\000\000\000\000\000\046\000\ - \046\000\000\000\046\000\046\000\046\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\046\000\ - \000\000\046\000\046\000\046\000\046\000\046\000\000\000\000\000\ - \000\000\000\000\047\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\050\000\000\000\000\000\ - \000\000\000\000\000\000\046\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\000\000\000\000\ - \000\000\046\000\047\000\046\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\197\000\197\000\ - \197\000\197\000\197\000\197\000\197\000\197\000\197\000\197\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\197\000\ - \197\000\197\000\197\000\197\000\197\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\197\000\ - \197\000\197\000\197\000\197\000\197\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\000\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\048\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\048\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\049\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\000\000\000\000\ - \000\000\000\000\048\000\000\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\199\000\199\000\ - \199\000\199\000\199\000\199\000\199\000\199\000\199\000\199\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\199\000\ - \199\000\199\000\199\000\199\000\199\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\199\000\ - \199\000\199\000\199\000\199\000\199\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\000\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\051\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\054\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\000\000\000\000\ - \000\000\000\000\051\000\000\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\000\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\052\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\053\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\052\000\000\000\000\000\ - \000\000\000\000\052\000\000\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\052\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\000\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\055\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\000\000\000\000\ - \000\000\000\000\055\000\000\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\000\000\ - \000\000\000\000\072\000\000\000\072\000\000\000\000\000\071\000\ - \071\000\071\000\071\000\071\000\071\000\071\000\071\000\071\000\ - \071\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\000\000\000\000\000\000\000\000\055\000\000\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\057\000\057\000\057\000\057\000\057\000\ - \057\000\057\000\057\000\057\000\057\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\055\000\055\000\055\000\055\000\ - \056\000\055\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\067\000\067\000\067\000\067\000\000\000\000\000\ - \000\000\000\000\057\000\000\000\055\000\055\000\055\000\055\000\ - \056\000\055\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\067\000\067\000\067\000\067\000\055\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\000\000\000\000\000\000\000\000\055\000\000\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\070\000\070\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\000\000\000\000\ - \000\000\000\000\055\000\000\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\069\000\ - \069\000\069\000\069\000\069\000\069\000\069\000\069\000\055\000\ - \055\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\000\000\000\000\000\000\000\000\055\000\000\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\062\000\062\000\062\000\062\000\062\000\ - \062\000\062\000\062\000\062\000\062\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\062\000\062\000\062\000\062\000\ - \062\000\062\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\000\000\000\000\ - \000\000\000\000\055\000\000\000\062\000\062\000\062\000\062\000\ - \062\000\062\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\063\000\000\000\062\000\ - \062\000\062\000\062\000\062\000\062\000\062\000\062\000\062\000\ - \062\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \062\000\062\000\062\000\062\000\062\000\062\000\058\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\064\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\058\000\000\000\000\000\000\000\000\000\062\000\000\000\ - \062\000\062\000\062\000\062\000\062\000\062\000\058\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\064\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\058\000\055\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\063\000\063\000\063\000\063\000\063\000\ - \063\000\063\000\063\000\063\000\063\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\063\000\063\000\063\000\063\000\ - \063\000\063\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\067\000\068\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\067\000\067\000\067\000\067\000\000\000\000\000\ - \000\000\000\000\063\000\000\000\063\000\063\000\063\000\063\000\ - \063\000\063\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\067\000\068\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\067\000\067\000\067\000\067\000\055\000\000\000\ - \000\000\000\000\066\000\000\000\066\000\000\000\000\000\065\000\ - \065\000\065\000\065\000\065\000\065\000\065\000\065\000\065\000\ - \065\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\000\000\000\000\000\000\000\000\055\000\000\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\065\000\065\000\065\000\065\000\065\000\ - \065\000\065\000\065\000\065\000\065\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\067\000\067\000\067\000\067\000\000\000\000\000\ - \000\000\000\000\065\000\000\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\067\000\067\000\067\000\067\000\055\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\000\000\000\000\000\000\000\000\055\000\000\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\000\000\000\000\000\000\066\000\000\000\ - \066\000\000\000\000\000\065\000\065\000\065\000\065\000\065\000\ - \065\000\065\000\065\000\065\000\065\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\000\000\000\000\ - \000\000\000\000\055\000\000\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\069\000\ - \069\000\069\000\069\000\069\000\069\000\069\000\069\000\055\000\ - \055\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\058\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\058\000\000\000\000\000\000\000\000\000\069\000\000\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\058\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\058\000\055\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\070\000\070\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\000\000\000\000\ - \000\000\000\000\070\000\000\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\055\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\071\000\ - \071\000\071\000\071\000\071\000\071\000\071\000\071\000\071\000\ - \071\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\067\000\067\000\ - \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\000\000\000\000\000\000\000\000\071\000\000\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\067\000\067\000\ - \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\086\000\103\000\086\000\000\000\103\000\103\000\ - \103\000\086\000\000\000\000\000\103\000\103\000\000\000\103\000\ - \103\000\103\000\085\000\085\000\085\000\085\000\085\000\085\000\ - \085\000\085\000\085\000\085\000\103\000\000\000\103\000\103\000\ - \103\000\103\000\103\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\105\000\000\000\105\000\105\000\105\000\105\000\ - \000\000\000\000\000\000\105\000\105\000\000\000\105\000\105\000\ - \105\000\000\000\000\000\000\000\000\000\000\000\086\000\000\000\ - \103\000\000\000\000\000\105\000\086\000\105\000\105\000\105\000\ - \105\000\105\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \086\000\084\000\000\000\000\000\086\000\000\000\086\000\000\000\ - \006\000\000\000\083\000\006\000\006\000\006\000\103\000\000\000\ - \103\000\006\000\006\000\000\000\006\000\006\000\006\000\105\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\006\000\000\000\006\000\006\000\006\000\006\000\006\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\117\000\ - \000\000\000\000\117\000\117\000\117\000\105\000\000\000\105\000\ - \117\000\117\000\000\000\117\000\117\000\117\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\006\000\000\000\000\000\ - \117\000\000\000\117\000\117\000\117\000\117\000\117\000\000\000\ - \000\000\000\000\117\000\000\000\000\000\117\000\117\000\117\000\ - \000\000\000\000\000\000\117\000\117\000\000\000\117\000\117\000\ - \117\000\000\000\000\000\006\000\000\000\006\000\000\000\000\000\ - \000\000\000\000\000\000\117\000\117\000\117\000\117\000\117\000\ - \117\000\117\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \117\000\000\000\000\000\117\000\117\000\117\000\000\000\000\000\ - \000\000\117\000\117\000\000\000\117\000\117\000\117\000\000\000\ - \000\000\000\000\117\000\000\000\117\000\000\000\000\000\117\000\ - \000\000\117\000\255\255\117\000\117\000\117\000\117\000\117\000\ - \000\000\000\000\000\000\120\000\000\000\000\000\120\000\120\000\ - \120\000\000\000\000\000\000\000\120\000\120\000\000\000\120\000\ - \120\000\120\000\000\000\000\000\000\000\117\000\000\000\117\000\ - \000\000\000\000\000\000\000\000\120\000\117\000\120\000\120\000\ - \120\000\120\000\120\000\000\000\000\000\000\000\006\000\000\000\ - \000\000\006\000\006\000\006\000\000\000\000\000\000\000\006\000\ - \006\000\000\000\006\000\006\000\006\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\117\000\000\000\117\000\000\000\006\000\ - \120\000\006\000\006\000\006\000\006\000\006\000\000\000\000\000\ - \000\000\006\000\000\000\000\000\006\000\006\000\006\000\000\000\ - \000\000\000\000\006\000\006\000\000\000\006\000\006\000\006\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\120\000\000\000\ - \120\000\000\000\006\000\006\000\006\000\006\000\006\000\006\000\ - \006\000\000\000\000\000\000\000\139\000\000\000\000\000\139\000\ - \139\000\139\000\000\000\000\000\000\000\139\000\139\000\000\000\ - \139\000\139\000\139\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\006\000\000\000\006\000\000\000\139\000\006\000\139\000\ - \139\000\139\000\139\000\139\000\000\000\000\000\000\000\139\000\ - \000\000\000\000\139\000\139\000\139\000\000\000\000\000\000\000\ - \139\000\139\000\000\000\139\000\139\000\139\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\006\000\000\000\006\000\000\000\ - \139\000\139\000\139\000\139\000\139\000\139\000\139\000\000\000\ - \000\000\000\000\117\000\000\000\000\000\117\000\117\000\117\000\ - \000\000\000\000\000\000\117\000\117\000\000\000\117\000\117\000\ - \117\000\000\000\000\000\000\000\000\000\000\000\000\000\139\000\ - \000\000\139\000\000\000\117\000\139\000\117\000\117\000\117\000\ - \117\000\117\000\000\000\000\000\000\000\117\000\000\000\000\000\ - \117\000\117\000\117\000\000\000\000\000\000\000\117\000\117\000\ - \000\000\117\000\117\000\117\000\000\000\000\000\166\000\000\000\ - \166\000\000\000\139\000\000\000\139\000\166\000\117\000\117\000\ - \117\000\117\000\117\000\117\000\117\000\000\000\165\000\165\000\ - \165\000\165\000\165\000\165\000\165\000\165\000\165\000\165\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\117\000\000\000\117\000\ - \000\000\000\000\117\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\188\000\000\000\000\000\189\000\000\000\000\000\000\000\ - \000\000\000\000\166\000\000\000\000\000\000\000\000\000\000\000\ - \166\000\000\000\000\000\000\000\000\000\000\000\000\000\187\000\ - \117\000\187\000\117\000\000\000\166\000\000\000\187\000\000\000\ - \166\000\000\000\166\000\000\000\000\000\000\000\164\000\186\000\ - \186\000\186\000\186\000\186\000\186\000\186\000\186\000\186\000\ - \186\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\199\000\199\000\199\000\199\000\199\000\199\000\199\000\ - \199\000\199\000\199\000\187\000\000\000\000\000\000\000\000\000\ - \000\000\187\000\199\000\199\000\199\000\199\000\199\000\199\000\ - \000\000\000\000\000\000\000\000\000\000\187\000\185\000\000\000\ - \000\000\187\000\000\000\187\000\183\000\000\000\000\000\184\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\199\000\199\000\199\000\199\000\199\000\199\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\200\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\255\255\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000"; - Lexing.lex_check = - "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\000\000\000\000\041\000\000\000\000\000\041\000\042\000\ - \044\000\045\000\042\000\044\000\045\000\079\000\109\000\115\000\ - \079\000\109\000\115\000\146\000\160\000\218\000\146\000\160\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\016\000\ - \013\000\017\000\026\000\039\000\017\000\017\000\039\000\066\000\ - \066\000\066\000\066\000\066\000\066\000\066\000\066\000\066\000\ - \066\000\077\000\078\000\084\000\084\000\084\000\084\000\013\000\ - \086\000\013\000\039\000\013\000\072\000\072\000\072\000\072\000\ - \072\000\072\000\072\000\072\000\072\000\072\000\085\000\085\000\ - \085\000\085\000\085\000\085\000\085\000\085\000\085\000\085\000\ - \088\000\088\000\088\000\088\000\088\000\088\000\088\000\088\000\ - \088\000\088\000\089\000\093\000\096\000\098\000\098\000\127\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\013\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\003\000\100\000\100\000\003\000\003\000\003\000\102\000\ - \102\000\027\000\003\000\003\000\027\000\003\000\003\000\003\000\ - \091\000\091\000\091\000\091\000\091\000\091\000\091\000\091\000\ - \110\000\132\000\003\000\110\000\003\000\003\000\003\000\003\000\ - \003\000\151\000\113\000\152\000\004\000\113\000\027\000\004\000\ - \004\000\004\000\158\000\159\000\166\000\004\000\004\000\169\000\ - \004\000\004\000\004\000\092\000\092\000\092\000\092\000\092\000\ - \092\000\092\000\092\000\172\000\183\000\004\000\003\000\004\000\ - \004\000\004\000\004\000\004\000\211\000\174\000\179\000\005\000\ - \174\000\179\000\005\000\005\000\005\000\212\000\215\000\217\000\ - \005\000\005\000\188\000\005\000\005\000\005\000\185\000\185\000\ - \185\000\185\000\111\000\027\000\003\000\111\000\003\000\255\255\ - \005\000\004\000\005\000\005\000\005\000\005\000\005\000\255\255\ - \189\000\188\000\006\000\189\000\255\255\006\000\006\000\006\000\ - \255\255\255\255\111\000\006\000\006\000\255\255\006\000\006\000\ - \006\000\255\255\255\255\190\000\112\000\112\000\190\000\004\000\ - \112\000\004\000\255\255\006\000\005\000\006\000\006\000\006\000\ - \006\000\006\000\255\255\201\000\202\000\007\000\201\000\202\000\ - \007\000\007\000\007\000\112\000\255\255\112\000\007\000\007\000\ - \255\255\007\000\007\000\007\000\207\000\208\000\213\000\207\000\ - \208\000\214\000\005\000\216\000\005\000\255\255\007\000\006\000\ - \007\000\007\000\007\000\007\000\007\000\255\255\255\255\255\255\ - \008\000\255\255\255\255\008\000\008\000\008\000\255\255\255\255\ - \148\000\008\000\008\000\148\000\008\000\008\000\008\000\255\255\ - \255\255\255\255\255\255\255\255\255\255\006\000\255\255\006\000\ - \255\255\008\000\007\000\008\000\008\000\008\000\008\000\008\000\ - \255\255\255\255\255\255\010\000\255\255\148\000\010\000\010\000\ - \010\000\255\255\255\255\255\255\010\000\010\000\255\255\010\000\ - \010\000\010\000\255\255\255\255\255\255\255\255\255\255\255\255\ - \007\000\255\255\007\000\255\255\010\000\008\000\010\000\010\000\ - \010\000\010\000\010\000\255\255\175\000\255\255\255\255\175\000\ - \011\000\255\255\255\255\011\000\011\000\011\000\202\000\027\000\ - \255\255\011\000\011\000\255\255\011\000\011\000\011\000\255\255\ - \255\255\255\255\148\000\008\000\175\000\008\000\110\000\010\000\ - \010\000\011\000\255\255\011\000\011\000\011\000\011\000\011\000\ - \113\000\255\255\255\255\255\255\255\255\014\000\255\255\255\255\ - \014\000\014\000\014\000\255\255\255\255\255\255\014\000\014\000\ - \255\255\014\000\014\000\014\000\255\255\255\255\010\000\010\000\ - \010\000\255\255\255\255\255\255\011\000\011\000\014\000\255\255\ - \014\000\014\000\014\000\014\000\014\000\255\255\255\255\255\255\ - \015\000\255\255\255\255\015\000\015\000\015\000\175\000\255\255\ - \255\255\015\000\015\000\255\255\015\000\015\000\015\000\255\255\ - \111\000\255\255\255\255\011\000\255\255\011\000\255\255\255\255\ - \255\255\015\000\014\000\015\000\015\000\015\000\015\000\015\000\ - \255\255\255\255\018\000\255\255\255\255\018\000\018\000\018\000\ - \255\255\255\255\255\255\018\000\018\000\255\255\018\000\018\000\ - \018\000\255\255\255\255\112\000\255\255\255\255\255\255\255\255\ - \014\000\255\255\014\000\018\000\255\255\015\000\018\000\018\000\ - \018\000\018\000\202\000\255\255\255\255\019\000\255\255\255\255\ - \019\000\019\000\019\000\255\255\255\255\255\255\019\000\019\000\ - \255\255\019\000\019\000\019\000\213\000\255\255\255\255\214\000\ - \255\255\216\000\255\255\015\000\255\255\015\000\019\000\018\000\ - \019\000\019\000\019\000\019\000\019\000\255\255\255\255\255\255\ - \023\000\255\255\255\255\023\000\023\000\023\000\148\000\255\255\ - \255\255\023\000\023\000\255\255\023\000\023\000\023\000\255\255\ - \255\255\255\255\255\255\255\255\255\255\018\000\255\255\018\000\ - \255\255\023\000\019\000\023\000\023\000\023\000\023\000\023\000\ - \083\000\083\000\083\000\083\000\083\000\083\000\083\000\083\000\ - \083\000\083\000\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\083\000\083\000\083\000\083\000\083\000\083\000\255\255\ - \019\000\255\255\019\000\255\255\255\255\023\000\255\255\255\255\ - \255\255\255\255\175\000\255\255\255\255\255\255\255\255\024\000\ - \193\000\193\000\193\000\193\000\193\000\193\000\193\000\193\000\ - \255\255\083\000\083\000\083\000\083\000\083\000\083\000\255\255\ - \255\255\255\255\255\255\023\000\255\255\023\000\024\000\024\000\ - \255\255\024\000\024\000\024\000\024\000\255\255\255\255\255\255\ - \024\000\024\000\107\000\024\000\024\000\024\000\024\000\024\000\ - \024\000\024\000\024\000\024\000\024\000\024\000\024\000\024\000\ - \024\000\255\255\024\000\024\000\024\000\024\000\024\000\255\255\ - \255\255\107\000\025\000\255\255\255\255\025\000\025\000\025\000\ - \255\255\255\255\025\000\025\000\025\000\255\255\025\000\025\000\ - \025\000\107\000\107\000\107\000\107\000\107\000\107\000\107\000\ - \107\000\107\000\107\000\025\000\024\000\025\000\025\000\025\000\ - \025\000\025\000\165\000\165\000\165\000\165\000\165\000\165\000\ - \165\000\165\000\165\000\165\000\168\000\168\000\168\000\168\000\ - \168\000\168\000\168\000\168\000\168\000\168\000\255\255\255\255\ - \255\255\255\255\024\000\028\000\024\000\255\255\075\000\025\000\ - \075\000\075\000\075\000\075\000\075\000\075\000\075\000\075\000\ - \075\000\075\000\075\000\075\000\075\000\075\000\075\000\075\000\ - \075\000\075\000\075\000\075\000\075\000\075\000\075\000\075\000\ - \075\000\075\000\255\255\075\000\255\255\025\000\028\000\025\000\ - \028\000\028\000\028\000\028\000\028\000\028\000\028\000\028\000\ - \028\000\028\000\028\000\028\000\028\000\028\000\028\000\028\000\ - \028\000\028\000\028\000\028\000\028\000\028\000\028\000\028\000\ - \028\000\028\000\030\000\028\000\255\255\255\255\255\255\255\255\ - \255\255\030\000\255\255\030\000\030\000\030\000\030\000\030\000\ - \030\000\030\000\030\000\030\000\030\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\030\000\030\000\030\000\030\000\ - \030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ - \030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ - \030\000\030\000\030\000\030\000\030\000\030\000\255\255\255\255\ - \255\255\255\255\030\000\255\255\030\000\030\000\030\000\030\000\ - \030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ - \030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ - \030\000\030\000\030\000\030\000\030\000\030\000\031\000\255\255\ - \255\255\255\255\255\255\255\255\255\255\031\000\255\255\031\000\ - \031\000\031\000\031\000\031\000\031\000\031\000\031\000\031\000\ - \031\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \031\000\031\000\031\000\031\000\031\000\031\000\031\000\031\000\ - \031\000\031\000\031\000\031\000\031\000\031\000\031\000\031\000\ - \031\000\031\000\031\000\031\000\031\000\031\000\031\000\031\000\ - \031\000\031\000\255\255\255\255\255\255\255\255\031\000\255\255\ - \031\000\031\000\031\000\031\000\031\000\031\000\031\000\031\000\ - \031\000\031\000\031\000\031\000\031\000\031\000\031\000\031\000\ - \031\000\031\000\031\000\031\000\031\000\031\000\031\000\031\000\ - \031\000\031\000\032\000\194\000\194\000\194\000\194\000\194\000\ - \194\000\194\000\194\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\255\255\255\255\ - \255\255\255\255\032\000\255\255\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\095\000\095\000\ - \095\000\095\000\095\000\095\000\095\000\095\000\095\000\095\000\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\095\000\ - \095\000\095\000\095\000\095\000\095\000\186\000\186\000\186\000\ - \186\000\186\000\186\000\186\000\186\000\186\000\186\000\191\000\ - \191\000\191\000\191\000\191\000\191\000\191\000\191\000\191\000\ - \191\000\255\255\255\255\255\255\255\255\255\255\255\255\095\000\ - \095\000\095\000\095\000\095\000\095\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\255\255\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\033\000\032\000\032\000\032\000\032\000\032\000\ - \032\000\032\000\032\000\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\033\000\255\255\255\255\ - \255\255\255\255\033\000\255\255\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\033\000\106\000\106\000\ - \255\255\255\255\106\000\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\106\000\255\255\106\000\ - \255\255\255\255\255\255\255\255\143\000\255\255\255\255\143\000\ - \255\255\255\255\255\255\255\255\255\255\106\000\106\000\106\000\ - \106\000\106\000\106\000\106\000\106\000\106\000\106\000\255\255\ - \255\255\255\255\255\255\255\255\143\000\255\255\255\255\255\255\ - \255\255\143\000\143\000\255\255\143\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\255\255\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\034\000\033\000\033\000\033\000\033\000\033\000\ - \033\000\033\000\033\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\143\000\255\255\255\255\ - \255\255\255\255\255\255\255\255\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\255\255\255\255\ - \255\255\255\255\034\000\255\255\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\149\000\255\255\ - \149\000\149\000\149\000\149\000\149\000\149\000\149\000\149\000\ - \149\000\149\000\149\000\149\000\149\000\149\000\149\000\149\000\ - \149\000\149\000\149\000\149\000\149\000\149\000\149\000\149\000\ - \149\000\149\000\255\255\149\000\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\156\000\106\000\156\000\156\000\ - \156\000\156\000\156\000\156\000\156\000\156\000\156\000\156\000\ - \156\000\156\000\156\000\156\000\156\000\156\000\156\000\156\000\ - \156\000\156\000\156\000\156\000\156\000\156\000\156\000\156\000\ - \255\255\156\000\143\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\255\255\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\035\000\034\000\034\000\034\000\034\000\034\000\ - \034\000\034\000\034\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\255\255\255\255\ - \255\255\255\255\035\000\255\255\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\164\000\164\000\ - \164\000\164\000\164\000\164\000\164\000\164\000\164\000\164\000\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\164\000\ - \164\000\164\000\164\000\164\000\164\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\164\000\ - \164\000\164\000\164\000\164\000\164\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\255\255\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\255\255\035\000\035\000\035\000\035\000\035\000\ - \035\000\035\000\035\000\036\000\255\255\255\255\036\000\036\000\ - \036\000\255\255\255\255\255\255\036\000\036\000\255\255\036\000\ - \036\000\036\000\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\036\000\255\255\036\000\036\000\ - \036\000\036\000\036\000\255\255\204\000\255\255\204\000\204\000\ - \204\000\204\000\204\000\204\000\204\000\204\000\204\000\204\000\ - \204\000\204\000\204\000\204\000\204\000\204\000\204\000\204\000\ - \204\000\204\000\204\000\204\000\204\000\204\000\204\000\204\000\ - \036\000\036\000\204\000\036\000\036\000\036\000\036\000\036\000\ - \036\000\036\000\036\000\036\000\036\000\036\000\036\000\036\000\ - \036\000\036\000\036\000\036\000\036\000\036\000\036\000\036\000\ - \036\000\036\000\036\000\036\000\036\000\255\255\036\000\037\000\ - \036\000\255\255\037\000\037\000\037\000\255\255\255\255\255\255\ - \037\000\037\000\255\255\037\000\037\000\037\000\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \037\000\255\255\037\000\037\000\037\000\037\000\037\000\255\255\ - \210\000\255\255\210\000\210\000\210\000\210\000\210\000\210\000\ - \210\000\210\000\210\000\210\000\210\000\210\000\210\000\210\000\ - \210\000\210\000\210\000\210\000\210\000\210\000\210\000\210\000\ - \210\000\210\000\210\000\210\000\037\000\037\000\210\000\037\000\ - \037\000\037\000\037\000\037\000\037\000\037\000\037\000\037\000\ - \037\000\037\000\037\000\037\000\037\000\037\000\037\000\037\000\ - \037\000\037\000\037\000\037\000\037\000\037\000\037\000\037\000\ - \037\000\255\255\037\000\255\255\037\000\255\255\255\255\255\255\ - \255\255\036\000\036\000\036\000\036\000\036\000\036\000\036\000\ - \036\000\036\000\036\000\036\000\036\000\036\000\036\000\036\000\ - \036\000\036\000\036\000\036\000\036\000\036\000\036\000\036\000\ - \036\000\255\255\036\000\036\000\036\000\036\000\036\000\036\000\ - \036\000\036\000\171\000\171\000\171\000\171\000\171\000\171\000\ - \171\000\171\000\171\000\171\000\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\171\000\171\000\171\000\171\000\171\000\ - \171\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\171\000\171\000\171\000\171\000\171\000\ - \171\000\255\255\255\255\255\255\255\255\037\000\037\000\037\000\ - \037\000\037\000\037\000\037\000\037\000\037\000\037\000\037\000\ - \037\000\037\000\037\000\037\000\037\000\037\000\037\000\037\000\ - \037\000\037\000\037\000\037\000\037\000\038\000\037\000\037\000\ - \037\000\037\000\037\000\037\000\037\000\037\000\038\000\038\000\ - \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\038\000\ - \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ - \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ - \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ - \038\000\255\255\255\255\255\255\255\255\038\000\255\255\038\000\ - \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ - \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ - \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ - \038\000\184\000\184\000\184\000\184\000\184\000\184\000\184\000\ - \184\000\184\000\184\000\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\184\000\184\000\184\000\184\000\184\000\184\000\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\184\000\184\000\184\000\184\000\184\000\184\000\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\038\000\038\000\ - \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ - \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ - \038\000\038\000\038\000\038\000\038\000\255\255\038\000\038\000\ - \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ - \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ - \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ - \038\000\038\000\038\000\038\000\038\000\255\255\038\000\038\000\ - \038\000\038\000\038\000\038\000\038\000\038\000\046\000\255\255\ - \255\255\046\000\046\000\046\000\255\255\255\255\255\255\046\000\ - \046\000\255\255\046\000\046\000\046\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\046\000\ - \255\255\046\000\046\000\046\000\046\000\046\000\255\255\255\255\ - \255\255\255\255\047\000\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\255\255\255\255\ - \255\255\255\255\255\255\046\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\255\255\255\255\ - \255\255\046\000\047\000\046\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\196\000\196\000\ - \196\000\196\000\196\000\196\000\196\000\196\000\196\000\196\000\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\196\000\ - \196\000\196\000\196\000\196\000\196\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\196\000\ - \196\000\196\000\196\000\196\000\196\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\255\255\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\048\000\047\000\047\000\047\000\047\000\047\000\ - \047\000\047\000\047\000\048\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\255\255\255\255\ - \255\255\255\255\255\255\255\255\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\255\255\255\255\ - \255\255\255\255\048\000\255\255\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\198\000\198\000\ - \198\000\198\000\198\000\198\000\198\000\198\000\198\000\198\000\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\198\000\ - \198\000\198\000\198\000\198\000\198\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\198\000\ - \198\000\198\000\198\000\198\000\198\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\048\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\255\255\048\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\051\000\048\000\048\000\048\000\048\000\048\000\ - \048\000\048\000\048\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\255\255\255\255\ - \255\255\255\255\255\255\255\255\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\255\255\255\255\ - \255\255\255\255\051\000\255\255\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\255\255\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\052\000\051\000\051\000\051\000\051\000\051\000\ - \051\000\051\000\051\000\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\052\000\255\255\255\255\ - \255\255\255\255\255\255\255\255\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\052\000\255\255\255\255\ - \255\255\255\255\052\000\255\255\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\052\000\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\255\255\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\055\000\052\000\052\000\052\000\052\000\052\000\ - \052\000\052\000\052\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\255\255\255\255\ - \255\255\255\255\055\000\255\255\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ - \055\000\055\000\055\000\055\000\055\000\055\000\056\000\255\255\ - \255\255\255\255\056\000\255\255\056\000\255\255\255\255\056\000\ - \056\000\056\000\056\000\056\000\056\000\056\000\056\000\056\000\ - \056\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \056\000\056\000\056\000\056\000\056\000\056\000\056\000\056\000\ - \056\000\056\000\056\000\056\000\056\000\056\000\056\000\056\000\ - \056\000\056\000\056\000\056\000\056\000\056\000\056\000\056\000\ - \056\000\056\000\255\255\255\255\255\255\255\255\056\000\255\255\ - \056\000\056\000\056\000\056\000\056\000\056\000\056\000\056\000\ - \056\000\056\000\056\000\056\000\056\000\056\000\056\000\056\000\ - \056\000\056\000\056\000\056\000\056\000\056\000\056\000\056\000\ - \056\000\056\000\057\000\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\057\000\057\000\057\000\057\000\057\000\ - \057\000\057\000\057\000\057\000\057\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\057\000\057\000\057\000\057\000\ - \057\000\057\000\057\000\057\000\057\000\057\000\057\000\057\000\ - \057\000\057\000\057\000\057\000\057\000\057\000\057\000\057\000\ - \057\000\057\000\057\000\057\000\057\000\057\000\255\255\255\255\ - \255\255\255\255\057\000\255\255\057\000\057\000\057\000\057\000\ - \057\000\057\000\057\000\057\000\057\000\057\000\057\000\057\000\ - \057\000\057\000\057\000\057\000\057\000\057\000\057\000\057\000\ - \057\000\057\000\057\000\057\000\057\000\057\000\058\000\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\058\000\255\255\255\255\255\255\255\255\058\000\255\255\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ - \058\000\058\000\059\000\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\059\000\059\000\059\000\059\000\059\000\ - \059\000\059\000\059\000\059\000\059\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\059\000\059\000\059\000\059\000\ - \059\000\059\000\059\000\059\000\059\000\059\000\059\000\059\000\ - \059\000\059\000\059\000\059\000\059\000\059\000\059\000\059\000\ - \059\000\059\000\059\000\059\000\059\000\059\000\255\255\255\255\ - \255\255\255\255\059\000\255\255\059\000\059\000\059\000\059\000\ - \059\000\059\000\059\000\059\000\059\000\059\000\059\000\059\000\ - \059\000\059\000\059\000\059\000\059\000\059\000\059\000\059\000\ - \059\000\059\000\059\000\059\000\059\000\059\000\060\000\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\060\000\ - \060\000\060\000\060\000\060\000\060\000\060\000\060\000\060\000\ - \060\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \060\000\060\000\060\000\060\000\060\000\060\000\060\000\060\000\ - \060\000\060\000\060\000\060\000\060\000\060\000\060\000\060\000\ - \060\000\060\000\060\000\060\000\060\000\060\000\060\000\060\000\ - \060\000\060\000\255\255\255\255\255\255\255\255\060\000\255\255\ - \060\000\060\000\060\000\060\000\060\000\060\000\060\000\060\000\ - \060\000\060\000\060\000\060\000\060\000\060\000\060\000\060\000\ - \060\000\060\000\060\000\060\000\060\000\060\000\060\000\060\000\ - \060\000\060\000\061\000\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\061\000\061\000\061\000\061\000\061\000\ - \061\000\061\000\061\000\061\000\061\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\061\000\061\000\061\000\061\000\ - \061\000\061\000\061\000\061\000\061\000\061\000\061\000\061\000\ - \061\000\061\000\061\000\061\000\061\000\061\000\061\000\061\000\ - \061\000\061\000\061\000\061\000\061\000\061\000\255\255\255\255\ - \255\255\255\255\061\000\255\255\061\000\061\000\061\000\061\000\ - \061\000\061\000\061\000\061\000\061\000\061\000\061\000\061\000\ - \061\000\061\000\061\000\061\000\061\000\061\000\061\000\061\000\ - \061\000\061\000\061\000\061\000\061\000\061\000\062\000\255\255\ - \255\255\255\255\255\255\255\255\255\255\062\000\255\255\062\000\ - \062\000\062\000\062\000\062\000\062\000\062\000\062\000\062\000\ - \062\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \062\000\062\000\062\000\062\000\062\000\062\000\062\000\062\000\ - \062\000\062\000\062\000\062\000\062\000\062\000\062\000\062\000\ - \062\000\062\000\062\000\062\000\062\000\062\000\062\000\062\000\ - \062\000\062\000\255\255\255\255\255\255\255\255\062\000\255\255\ - \062\000\062\000\062\000\062\000\062\000\062\000\062\000\062\000\ - \062\000\062\000\062\000\062\000\062\000\062\000\062\000\062\000\ - \062\000\062\000\062\000\062\000\062\000\062\000\062\000\062\000\ - \062\000\062\000\063\000\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\063\000\063\000\063\000\063\000\063\000\ - \063\000\063\000\063\000\063\000\063\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\063\000\063\000\063\000\063\000\ - \063\000\063\000\063\000\063\000\063\000\063\000\063\000\063\000\ - \063\000\063\000\063\000\063\000\063\000\063\000\063\000\063\000\ - \063\000\063\000\063\000\063\000\063\000\063\000\255\255\255\255\ - \255\255\255\255\063\000\255\255\063\000\063\000\063\000\063\000\ - \063\000\063\000\063\000\063\000\063\000\063\000\063\000\063\000\ - \063\000\063\000\063\000\063\000\063\000\063\000\063\000\063\000\ - \063\000\063\000\063\000\063\000\063\000\063\000\064\000\255\255\ - \255\255\255\255\064\000\255\255\064\000\255\255\255\255\064\000\ - \064\000\064\000\064\000\064\000\064\000\064\000\064\000\064\000\ - \064\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \064\000\064\000\064\000\064\000\064\000\064\000\064\000\064\000\ - \064\000\064\000\064\000\064\000\064\000\064\000\064\000\064\000\ - \064\000\064\000\064\000\064\000\064\000\064\000\064\000\064\000\ - \064\000\064\000\255\255\255\255\255\255\255\255\064\000\255\255\ - \064\000\064\000\064\000\064\000\064\000\064\000\064\000\064\000\ - \064\000\064\000\064\000\064\000\064\000\064\000\064\000\064\000\ - \064\000\064\000\064\000\064\000\064\000\064\000\064\000\064\000\ - \064\000\064\000\065\000\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\065\000\065\000\065\000\065\000\065\000\ - \065\000\065\000\065\000\065\000\065\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\065\000\065\000\065\000\065\000\ - \065\000\065\000\065\000\065\000\065\000\065\000\065\000\065\000\ - \065\000\065\000\065\000\065\000\065\000\065\000\065\000\065\000\ - \065\000\065\000\065\000\065\000\065\000\065\000\255\255\255\255\ - \255\255\255\255\065\000\255\255\065\000\065\000\065\000\065\000\ - \065\000\065\000\065\000\065\000\065\000\065\000\065\000\065\000\ - \065\000\065\000\065\000\065\000\065\000\065\000\065\000\065\000\ - \065\000\065\000\065\000\065\000\065\000\065\000\067\000\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\067\000\ - \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\255\255\255\255\255\255\255\255\067\000\255\255\ - \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ - \067\000\067\000\068\000\255\255\255\255\255\255\068\000\255\255\ - \068\000\255\255\255\255\068\000\068\000\068\000\068\000\068\000\ - \068\000\068\000\068\000\068\000\068\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\068\000\068\000\068\000\068\000\ - \068\000\068\000\068\000\068\000\068\000\068\000\068\000\068\000\ - \068\000\068\000\068\000\068\000\068\000\068\000\068\000\068\000\ - \068\000\068\000\068\000\068\000\068\000\068\000\255\255\255\255\ - \255\255\255\255\068\000\255\255\068\000\068\000\068\000\068\000\ - \068\000\068\000\068\000\068\000\068\000\068\000\068\000\068\000\ - \068\000\068\000\068\000\068\000\068\000\068\000\068\000\068\000\ - \068\000\068\000\068\000\068\000\068\000\068\000\069\000\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\069\000\ - \069\000\069\000\069\000\069\000\069\000\069\000\069\000\069\000\ - \069\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \069\000\069\000\069\000\069\000\069\000\069\000\069\000\069\000\ - \069\000\069\000\069\000\069\000\069\000\069\000\069\000\069\000\ - \069\000\069\000\069\000\069\000\069\000\069\000\069\000\069\000\ - \069\000\069\000\255\255\255\255\255\255\255\255\069\000\255\255\ - \069\000\069\000\069\000\069\000\069\000\069\000\069\000\069\000\ - \069\000\069\000\069\000\069\000\069\000\069\000\069\000\069\000\ - \069\000\069\000\069\000\069\000\069\000\069\000\069\000\069\000\ - \069\000\069\000\070\000\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\070\000\070\000\070\000\070\000\070\000\ - \070\000\070\000\070\000\070\000\070\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\070\000\070\000\070\000\070\000\ - \070\000\070\000\070\000\070\000\070\000\070\000\070\000\070\000\ - \070\000\070\000\070\000\070\000\070\000\070\000\070\000\070\000\ - \070\000\070\000\070\000\070\000\070\000\070\000\255\255\255\255\ - \255\255\255\255\070\000\255\255\070\000\070\000\070\000\070\000\ - \070\000\070\000\070\000\070\000\070\000\070\000\070\000\070\000\ - \070\000\070\000\070\000\070\000\070\000\070\000\070\000\070\000\ - \070\000\070\000\070\000\070\000\070\000\070\000\071\000\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\071\000\ - \071\000\071\000\071\000\071\000\071\000\071\000\071\000\071\000\ - \071\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \071\000\071\000\071\000\071\000\071\000\071\000\071\000\071\000\ - \071\000\071\000\071\000\071\000\071\000\071\000\071\000\071\000\ - \071\000\071\000\071\000\071\000\071\000\071\000\071\000\071\000\ - \071\000\071\000\255\255\255\255\255\255\255\255\071\000\255\255\ - \071\000\071\000\071\000\071\000\071\000\071\000\071\000\071\000\ - \071\000\071\000\071\000\071\000\071\000\071\000\071\000\071\000\ - \071\000\071\000\071\000\071\000\071\000\071\000\071\000\071\000\ - \071\000\071\000\076\000\103\000\076\000\255\255\103\000\103\000\ - \103\000\076\000\255\255\255\255\103\000\103\000\255\255\103\000\ - \103\000\103\000\076\000\076\000\076\000\076\000\076\000\076\000\ - \076\000\076\000\076\000\076\000\103\000\255\255\103\000\103\000\ - \103\000\103\000\103\000\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\105\000\255\255\105\000\105\000\105\000\105\000\ - \255\255\255\255\255\255\105\000\105\000\255\255\105\000\105\000\ - \105\000\255\255\255\255\255\255\255\255\255\255\076\000\255\255\ - \103\000\255\255\255\255\105\000\076\000\105\000\105\000\105\000\ - \105\000\105\000\255\255\255\255\255\255\255\255\255\255\255\255\ - \076\000\076\000\255\255\255\255\076\000\255\255\076\000\255\255\ - \116\000\255\255\076\000\116\000\116\000\116\000\103\000\255\255\ - \103\000\116\000\116\000\255\255\116\000\116\000\116\000\105\000\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\116\000\255\255\116\000\116\000\116\000\116\000\116\000\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\117\000\ - \255\255\255\255\117\000\117\000\117\000\105\000\255\255\105\000\ - \117\000\117\000\255\255\117\000\117\000\117\000\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\116\000\255\255\255\255\ - \117\000\255\255\117\000\117\000\117\000\117\000\117\000\255\255\ - \255\255\255\255\118\000\255\255\255\255\118\000\118\000\118\000\ - \255\255\255\255\255\255\118\000\118\000\255\255\118\000\118\000\ - \118\000\255\255\255\255\116\000\255\255\116\000\255\255\255\255\ - \255\255\255\255\255\255\118\000\117\000\118\000\118\000\118\000\ - \118\000\118\000\255\255\255\255\255\255\255\255\255\255\255\255\ - \119\000\255\255\255\255\119\000\119\000\119\000\255\255\255\255\ - \255\255\119\000\119\000\255\255\119\000\119\000\119\000\255\255\ - \255\255\255\255\117\000\255\255\117\000\255\255\255\255\118\000\ - \255\255\119\000\076\000\119\000\119\000\119\000\119\000\119\000\ - \255\255\255\255\255\255\120\000\255\255\255\255\120\000\120\000\ - \120\000\255\255\255\255\255\255\120\000\120\000\255\255\120\000\ - \120\000\120\000\255\255\255\255\255\255\118\000\255\255\118\000\ - \255\255\255\255\255\255\255\255\120\000\119\000\120\000\120\000\ - \120\000\120\000\120\000\255\255\255\255\255\255\126\000\255\255\ - \255\255\126\000\126\000\126\000\255\255\255\255\255\255\126\000\ - \126\000\255\255\126\000\126\000\126\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\119\000\255\255\119\000\255\255\126\000\ - \120\000\126\000\126\000\126\000\126\000\126\000\255\255\255\255\ - \255\255\136\000\255\255\255\255\136\000\136\000\136\000\255\255\ - \255\255\255\255\136\000\136\000\255\255\136\000\136\000\136\000\ - \255\255\255\255\255\255\255\255\255\255\255\255\120\000\255\255\ - \120\000\255\255\136\000\126\000\136\000\136\000\136\000\136\000\ - \136\000\255\255\255\255\255\255\139\000\255\255\255\255\139\000\ - \139\000\139\000\255\255\255\255\255\255\139\000\139\000\255\255\ - \139\000\139\000\139\000\255\255\255\255\255\255\255\255\255\255\ - \255\255\126\000\255\255\126\000\255\255\139\000\136\000\139\000\ - \139\000\139\000\139\000\139\000\255\255\255\255\255\255\140\000\ - \255\255\255\255\140\000\140\000\140\000\255\255\255\255\255\255\ - \140\000\140\000\255\255\140\000\140\000\140\000\255\255\255\255\ - \255\255\255\255\255\255\255\255\136\000\255\255\136\000\255\255\ - \140\000\139\000\140\000\140\000\140\000\140\000\140\000\255\255\ - \255\255\255\255\141\000\255\255\255\255\141\000\141\000\141\000\ - \255\255\255\255\255\255\141\000\141\000\255\255\141\000\141\000\ - \141\000\255\255\255\255\255\255\255\255\255\255\255\255\139\000\ - \255\255\139\000\255\255\141\000\140\000\141\000\141\000\141\000\ - \141\000\141\000\255\255\255\255\255\255\142\000\255\255\255\255\ - \142\000\142\000\142\000\255\255\255\255\255\255\142\000\142\000\ - \255\255\142\000\142\000\142\000\255\255\255\255\157\000\255\255\ - \157\000\255\255\140\000\255\255\140\000\157\000\142\000\141\000\ - \142\000\142\000\142\000\142\000\142\000\255\255\157\000\157\000\ - \157\000\157\000\157\000\157\000\157\000\157\000\157\000\157\000\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\141\000\255\255\141\000\ - \255\255\255\255\142\000\255\255\255\255\255\255\255\255\255\255\ - \255\255\180\000\255\255\255\255\180\000\255\255\255\255\255\255\ - \255\255\255\255\157\000\255\255\255\255\255\255\255\255\255\255\ - \157\000\255\255\255\255\255\255\255\255\255\255\255\255\180\000\ - \142\000\180\000\142\000\255\255\157\000\255\255\180\000\255\255\ - \157\000\255\255\157\000\255\255\255\255\255\255\157\000\180\000\ - \180\000\180\000\180\000\180\000\180\000\180\000\180\000\180\000\ - \180\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\199\000\199\000\199\000\199\000\199\000\199\000\199\000\ - \199\000\199\000\199\000\180\000\255\255\255\255\255\255\255\255\ - \255\255\180\000\199\000\199\000\199\000\199\000\199\000\199\000\ - \255\255\255\255\255\255\255\255\255\255\180\000\180\000\255\255\ - \255\255\180\000\255\255\180\000\180\000\255\255\255\255\180\000\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\199\000\199\000\199\000\199\000\199\000\199\000\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\199\000\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\180\000\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255"; - Lexing.lex_base_code = - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\010\000\036\000\022\000\000\000\000\000\000\000\ - \005\000\000\000\039\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\002\000\005\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000"; - Lexing.lex_backtrk_code = - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\053\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000"; - Lexing.lex_default_code = - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\031\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000"; - Lexing.lex_trans_code = - "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\001\000\000\000\050\000\050\000\000\000\009\000\050\000\ - \000\000\000\000\000\000\009\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \001\000\000\000\009\000\001\000\000\000\009\000\000\000\034\000\ - \000\000\000\000\009\000\000\000\012\000\001\000\000\000\000\000\ - \004\000\004\000\004\000\004\000\004\000\004\000\004\000\004\000\ - \004\000\004\000\017\000\017\000\017\000\017\000\017\000\017\000\ - \017\000\017\000\017\000\017\000\001\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\017\000\017\000\017\000\017\000\ - \017\000\017\000\017\000\017\000\017\000\017\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ - \000\000\000\000\000\000\000\000\000\000"; - Lexing.lex_check_code = - "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\024\000\111\000\180\000\189\000\111\000\112\000\190\000\ - \255\255\255\255\255\255\106\000\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \024\000\255\255\111\000\000\000\255\255\112\000\255\255\112\000\ - \255\255\255\255\106\000\255\255\106\000\107\000\255\255\255\255\ - \024\000\024\000\024\000\024\000\024\000\024\000\024\000\024\000\ - \024\000\024\000\106\000\106\000\106\000\106\000\106\000\106\000\ - \106\000\106\000\106\000\106\000\107\000\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\107\000\107\000\107\000\107\000\ - \107\000\107\000\107\000\107\000\107\000\107\000\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \111\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ - \255\255\255\255\255\255\255\255\255\255"; - Lexing.lex_code = - "\255\005\255\255\007\255\006\255\255\007\255\255\009\255\008\255\ - \255\006\255\007\255\255\004\255\000\005\001\006\002\007\255\009\ - \255\255\008\255\009\255\255\000\005\001\006\004\008\003\009\002\ - \007\255\001\255\255\000\001\255"; -} +and signature_item = + Sig_value of Ident.t * value_description + | Sig_type of Ident.t * type_declaration * rec_status + | Sig_typext of Ident.t * extension_constructor * ext_status + | Sig_module of Ident.t * module_declaration * rec_status + | Sig_modtype of Ident.t * modtype_declaration + | Sig_class of Ident.t * class_declaration * rec_status + | Sig_class_type of Ident.t * class_type_declaration * rec_status -let rec token lexbuf = - lexbuf.Lexing.lex_mem <- Array.make 10 (-1); __ocaml_lex_token_rec lexbuf 0 -and __ocaml_lex_token_rec lexbuf __ocaml_lex_state = - match Lexing.new_engine __ocaml_lex_tables __ocaml_lex_state lexbuf with - | 0 -> -# 770 "parsing/lexer.mll" - ( - if not !escaped_newlines then - raise (Error(Illegal_character (Lexing.lexeme_char lexbuf 0), - Location.curr lexbuf)); - update_loc lexbuf None 1 false 0; - token lexbuf ) -# 2358 "parsing/lexer.ml" +and module_declaration = + { + md_type: module_type; + md_attributes: Parsetree.attributes; + md_loc: Location.t; + } - | 1 -> -# 777 "parsing/lexer.mll" - ( update_loc lexbuf None 1 false 0; - EOL ) -# 2364 "parsing/lexer.ml" +and modtype_declaration = + { + mtd_type: module_type option; (* Note: abstract *) + mtd_attributes: Parsetree.attributes; + mtd_loc: Location.t; + } - | 2 -> -# 780 "parsing/lexer.mll" - ( token lexbuf ) -# 2369 "parsing/lexer.ml" +and rec_status = + Trec_not (* first in a nonrecursive group *) + | Trec_first (* first in a recursive group *) + | Trec_next (* not first in a recursive/nonrecursive group *) - | 3 -> -# 782 "parsing/lexer.mll" - ( UNDERSCORE ) -# 2374 "parsing/lexer.ml" +and ext_status = + Text_first (* first constructor of an extension *) + | Text_next (* not first constructor of an extension *) + | Text_exception (* an exception *) - | 4 -> -# 784 "parsing/lexer.mll" - ( TILDE ) -# 2379 "parsing/lexer.ml" - | 5 -> -# 786 "parsing/lexer.mll" - ( LABEL (get_label_name lexbuf) ) -# 2384 "parsing/lexer.ml" +(* Constructor and record label descriptions inserted held in typing + environments *) - | 6 -> -# 788 "parsing/lexer.mll" - ( warn_latin1 lexbuf; LABEL (get_label_name lexbuf) ) -# 2389 "parsing/lexer.ml" +type constructor_description = + { cstr_name: string; (* Constructor name *) + cstr_res: type_expr; (* Type of the result *) + cstr_existentials: type_expr list; (* list of existentials *) + cstr_args: type_expr list; (* Type of the arguments *) + cstr_arity: int; (* Number of arguments *) + cstr_tag: constructor_tag; (* Tag for heap blocks *) + cstr_consts: int; (* Number of constant constructors *) + cstr_nonconsts: int; (* Number of non-const constructors *) + cstr_normal: int; (* Number of non generalized constrs *) + cstr_generalized: bool; (* Constrained return type? *) + cstr_private: private_flag; (* Read-only constructor? *) + cstr_loc: Location.t; + cstr_attributes: Parsetree.attributes; + cstr_inlined: type_declaration option; + } - | 7 -> -# 790 "parsing/lexer.mll" - ( QUESTION ) -# 2394 "parsing/lexer.ml" +and constructor_tag = + Cstr_constant of int (* Constant constructor (an int) *) + | Cstr_block of int (* Regular constructor (a block) *) + | Cstr_unboxed (* Constructor of an unboxed type *) + | Cstr_extension of Path.t * bool (* Extension constructor + true if a constant false if a block*) - | 8 -> -# 792 "parsing/lexer.mll" - ( OPTLABEL (get_label_name lexbuf) ) -# 2399 "parsing/lexer.ml" +let equal_tag t1 t2 = + match (t1, t2) with + | Cstr_constant i1, Cstr_constant i2 -> i2 = i1 + | Cstr_block i1, Cstr_block i2 -> i2 = i1 + | Cstr_unboxed, Cstr_unboxed -> true + | Cstr_extension (path1, b1), Cstr_extension (path2, b2) -> + Path.same path1 path2 && b1 = b2 + | (Cstr_constant _|Cstr_block _|Cstr_unboxed|Cstr_extension _), _ -> false - | 9 -> -# 794 "parsing/lexer.mll" - ( warn_latin1 lexbuf; OPTLABEL (get_label_name lexbuf) ) -# 2404 "parsing/lexer.ml" +let may_equal_constr c1 c2 = match c1.cstr_tag,c2.cstr_tag with +| Cstr_extension _,Cstr_extension _ -> c1.cstr_arity = c2.cstr_arity +| tag1,tag2 -> equal_tag tag1 tag2 - | 10 -> -# 796 "parsing/lexer.mll" - ( let s = Lexing.lexeme lexbuf in - try Hashtbl.find keyword_table s - with Not_found -> LIDENT s ) -# 2411 "parsing/lexer.ml" +type label_description = + { lbl_name: string; (* Short name *) + lbl_res: type_expr; (* Type of the result *) + lbl_arg: type_expr; (* Type of the argument *) + lbl_mut: mutable_flag; (* Is this a mutable field? *) + lbl_pos: int; (* Position in block *) + lbl_all: label_description array; (* All the labels in this type *) + lbl_repres: record_representation; (* Representation for this record *) + lbl_private: private_flag; (* Read-only field? *) + lbl_loc: Location.t; + lbl_attributes: Parsetree.attributes; + } - | 11 -> -# 800 "parsing/lexer.mll" - ( warn_latin1 lexbuf; LIDENT (Lexing.lexeme lexbuf) ) -# 2416 "parsing/lexer.ml" +end +module Btype : sig +#1 "btype.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) - | 12 -> -# 802 "parsing/lexer.mll" - ( UIDENT(Lexing.lexeme lexbuf) ) -# 2421 "parsing/lexer.ml" +(* Basic operations on core types *) - | 13 -> -# 804 "parsing/lexer.mll" - ( warn_latin1 lexbuf; UIDENT(Lexing.lexeme lexbuf) ) -# 2426 "parsing/lexer.ml" +open Asttypes +open Types - | 14 -> -# 805 "parsing/lexer.mll" - ( INT (Lexing.lexeme lexbuf, None) ) -# 2431 "parsing/lexer.ml" +(**** Sets, maps and hashtables of types ****) - | 15 -> -let -# 806 "parsing/lexer.mll" - lit -# 2437 "parsing/lexer.ml" -= Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_start_pos (lexbuf.Lexing.lex_curr_pos + -1) -and -# 806 "parsing/lexer.mll" - modif -# 2442 "parsing/lexer.ml" -= Lexing.sub_lexeme_char lexbuf (lexbuf.Lexing.lex_curr_pos + -1) in -# 807 "parsing/lexer.mll" - ( INT (lit, Some modif) ) -# 2446 "parsing/lexer.ml" +module TypeSet : Set.S with type elt = type_expr +module TypeMap : Map.S with type key = type_expr +module TypeHash : Hashtbl.S with type key = type_expr - | 16 -> -# 809 "parsing/lexer.mll" - ( FLOAT (Lexing.lexeme lexbuf, None) ) -# 2451 "parsing/lexer.ml" +(**** Levels ****) - | 17 -> -let -# 810 "parsing/lexer.mll" - lit -# 2457 "parsing/lexer.ml" -= Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_start_pos (lexbuf.Lexing.lex_curr_pos + -1) -and -# 810 "parsing/lexer.mll" - modif -# 2462 "parsing/lexer.ml" -= Lexing.sub_lexeme_char lexbuf (lexbuf.Lexing.lex_curr_pos + -1) in -# 811 "parsing/lexer.mll" - ( FLOAT (lit, Some modif) ) -# 2466 "parsing/lexer.ml" +val generic_level: int - | 18 -> -# 813 "parsing/lexer.mll" - ( raise (Error(Invalid_literal (Lexing.lexeme lexbuf), - Location.curr lexbuf)) ) -# 2472 "parsing/lexer.ml" +val newty2: int -> type_desc -> type_expr + (* Create a type *) +val newgenty: type_desc -> type_expr + (* Create a generic type *) +val newgenvar: ?name:string -> unit -> type_expr + (* Return a fresh generic variable *) - | 19 -> -# 816 "parsing/lexer.mll" - ( reset_string_buffer(); - is_in_string := true; - let string_start = lexbuf.lex_start_p in - string_start_loc := Location.curr lexbuf; - string lexbuf; - is_in_string := false; - lexbuf.lex_start_p <- string_start; - STRING (get_stored_string(), None) ) -# 2484 "parsing/lexer.ml" +(* Use Tsubst instead +val newmarkedvar: int -> type_expr + (* Return a fresh marked variable *) +val newmarkedgenvar: unit -> type_expr + (* Return a fresh marked generic variable *) +*) - | 20 -> -# 825 "parsing/lexer.mll" - ( reset_string_buffer(); - let delim = Lexing.lexeme lexbuf in - let delim = String.sub delim 1 (String.length delim - 2) in - is_in_string := true; - let string_start = lexbuf.lex_start_p in - string_start_loc := Location.curr lexbuf; - quoted_string delim lexbuf; - is_in_string := false; - lexbuf.lex_start_p <- string_start; - STRING (get_stored_string(), Some delim) ) -# 2498 "parsing/lexer.ml" +(**** Types ****) - | 21 -> -# 836 "parsing/lexer.mll" - ( update_loc lexbuf None 1 false 1; - CHAR (Lexing.lexeme_char lexbuf 1) ) -# 2504 "parsing/lexer.ml" +val is_Tvar: type_expr -> bool +val is_Tunivar: type_expr -> bool +val is_Tconstr: type_expr -> bool +val dummy_method: label +val default_mty: module_type option -> module_type - | 22 -> -# 839 "parsing/lexer.mll" - ( CHAR(Lexing.lexeme_char lexbuf 1) ) -# 2509 "parsing/lexer.ml" +val repr: type_expr -> type_expr + (* Return the canonical representative of a type. *) - | 23 -> -# 841 "parsing/lexer.mll" - ( CHAR(char_for_backslash (Lexing.lexeme_char lexbuf 2)) ) -# 2514 "parsing/lexer.ml" +val field_kind_repr: field_kind -> field_kind + (* Return the canonical representative of an object field + kind. *) - | 24 -> -# 843 "parsing/lexer.mll" - ( CHAR(char_for_decimal_code lexbuf 2) ) -# 2519 "parsing/lexer.ml" +val commu_repr: commutable -> commutable + (* Return the canonical representative of a commutation lock *) - | 25 -> -# 845 "parsing/lexer.mll" - ( CHAR(char_for_octal_code lexbuf 3) ) -# 2524 "parsing/lexer.ml" +(**** polymorphic variants ****) - | 26 -> -# 847 "parsing/lexer.mll" - ( CHAR(char_for_hexadecimal_code lexbuf 3) ) -# 2529 "parsing/lexer.ml" +val row_repr: row_desc -> row_desc + (* Return the canonical representative of a row description *) +val row_field_repr: row_field -> row_field +val row_field: label -> row_desc -> row_field + (* Return the canonical representative of a row field *) +val row_more: row_desc -> type_expr + (* Return the extension variable of the row *) +val row_fixed: row_desc -> bool + (* Return whether the row should be treated as fixed or not *) +val static_row: row_desc -> bool + (* Return whether the row is static or not *) +val hash_variant: label -> int + (* Hash function for variant tags *) - | 27 -> -# 849 "parsing/lexer.mll" - ( let l = Lexing.lexeme lexbuf in - let esc = String.sub l 1 (String.length l - 1) in - raise (Error(Illegal_escape esc, Location.curr lexbuf)) - ) -# 2537 "parsing/lexer.ml" +val proxy: type_expr -> type_expr + (* Return the proxy representative of the type: either itself + or a row variable *) + +(**** Utilities for private abbreviations with fixed rows ****) +val row_of_type: type_expr -> type_expr +val has_constr_row: type_expr -> bool +val is_row_name: string -> bool +val is_constr_row: allow_ident:bool -> type_expr -> bool + +(**** Utilities for type traversal ****) + +val iter_type_expr: (type_expr -> unit) -> type_expr -> unit + (* Iteration on types *) +val iter_row: (type_expr -> unit) -> row_desc -> unit + (* Iteration on types in a row *) +val iter_abbrev: (type_expr -> unit) -> abbrev_memo -> unit + (* Iteration on types in an abbreviation list *) - | 28 -> -# 854 "parsing/lexer.mll" - ( let s, loc = with_comment_buffer comment lexbuf in - COMMENT (s, loc) ) -# 2543 "parsing/lexer.ml" +type type_iterators = + { it_signature: type_iterators -> signature -> unit; + it_signature_item: type_iterators -> signature_item -> unit; + it_value_description: type_iterators -> value_description -> unit; + it_type_declaration: type_iterators -> type_declaration -> unit; + it_extension_constructor: type_iterators -> extension_constructor -> unit; + it_module_declaration: type_iterators -> module_declaration -> unit; + it_modtype_declaration: type_iterators -> modtype_declaration -> unit; + it_class_declaration: type_iterators -> class_declaration -> unit; + it_class_type_declaration: type_iterators -> class_type_declaration -> unit; + it_module_type: type_iterators -> module_type -> unit; + it_class_type: type_iterators -> class_type -> unit; + it_type_kind: type_iterators -> type_kind -> unit; + it_do_type_expr: type_iterators -> type_expr -> unit; + it_type_expr: type_iterators -> type_expr -> unit; + it_path: Path.t -> unit; } +val type_iterators: type_iterators + (* Iteration on arbitrary type information. + [it_type_expr] calls [mark_type_node] to avoid loops. *) +val unmark_iterators: type_iterators + (* Unmark any structure containing types. See [unmark_type] below. *) - | 29 -> -# 857 "parsing/lexer.mll" - ( let s, loc = with_comment_buffer comment lexbuf in - if !handle_docstrings then - DOCSTRING (Docstrings.docstring s loc) - else - COMMENT ("*" ^ s, loc) - ) -# 2553 "parsing/lexer.ml" +val copy_type_desc: + ?keep_names:bool -> (type_expr -> type_expr) -> type_desc -> type_desc + (* Copy on types *) +val copy_row: + (type_expr -> type_expr) -> + bool -> row_desc -> bool -> type_expr -> row_desc +val copy_kind: field_kind -> field_kind - | 30 -> -let -# 863 "parsing/lexer.mll" - stars -# 2559 "parsing/lexer.ml" -= Lexing.sub_lexeme lexbuf (lexbuf.Lexing.lex_start_pos + 3) lexbuf.Lexing.lex_curr_pos in -# 864 "parsing/lexer.mll" - ( let s, loc = - with_comment_buffer - (fun lexbuf -> - store_string ("*" ^ stars); - comment lexbuf) - lexbuf - in - COMMENT (s, loc) ) -# 2570 "parsing/lexer.ml" +val save_desc: type_expr -> type_desc -> unit + (* Save a type description *) +val dup_kind: field_kind option ref -> unit + (* Save a None field_kind, and make it point to a fresh Fvar *) +val cleanup_types: unit -> unit + (* Restore type descriptions *) - | 31 -> -# 873 "parsing/lexer.mll" - ( if !print_warnings then - Location.prerr_warning (Location.curr lexbuf) Warnings.Comment_start; - let s, loc = with_comment_buffer comment lexbuf in - COMMENT (s, loc) ) -# 2578 "parsing/lexer.ml" +val lowest_level: int + (* Marked type: ty.level < lowest_level *) +val pivot_level: int + (* Type marking: ty.level <- pivot_level - ty.level *) +val mark_type: type_expr -> unit + (* Mark a type *) +val mark_type_node: type_expr -> unit + (* Mark a type node (but not its sons) *) +val mark_type_params: type_expr -> unit + (* Mark the sons of a type node *) +val unmark_type: type_expr -> unit +val unmark_type_decl: type_declaration -> unit +val unmark_extension_constructor: extension_constructor -> unit +val unmark_class_type: class_type -> unit +val unmark_class_signature: class_signature -> unit + (* Remove marks from a type *) - | 32 -> -let -# 877 "parsing/lexer.mll" - stars -# 2584 "parsing/lexer.ml" -= Lexing.sub_lexeme lexbuf (lexbuf.Lexing.lex_start_pos + 2) (lexbuf.Lexing.lex_curr_pos + -2) in -# 878 "parsing/lexer.mll" - ( if !handle_docstrings && stars="" then - (* (**) is an empty docstring *) - DOCSTRING(Docstrings.docstring "" (Location.curr lexbuf)) - else - COMMENT (stars, Location.curr lexbuf) ) -# 2592 "parsing/lexer.ml" +(**** Memorization of abbreviation expansion ****) - | 33 -> -# 884 "parsing/lexer.mll" - ( let loc = Location.curr lexbuf in - Location.prerr_warning loc Warnings.Comment_not_end; - lexbuf.Lexing.lex_curr_pos <- lexbuf.Lexing.lex_curr_pos - 1; - let curpos = lexbuf.lex_curr_p in - lexbuf.lex_curr_p <- { curpos with pos_cnum = curpos.pos_cnum - 1 }; - STAR - ) -# 2603 "parsing/lexer.ml" +val find_expans: private_flag -> Path.t -> abbrev_memo -> type_expr option + (* Look up a memorized abbreviation *) +val cleanup_abbrev: unit -> unit + (* Flush the cache of abbreviation expansions. + When some types are saved (using [output_value]), this + function MUST be called just before. *) +val memorize_abbrev: + abbrev_memo ref -> + private_flag -> Path.t -> type_expr -> type_expr -> unit + (* Add an expansion in the cache *) +val forget_abbrev: + abbrev_memo ref -> Path.t -> unit + (* Remove an abbreviation from the cache *) - | 34 -> -let -# 891 "parsing/lexer.mll" - num -# 2609 "parsing/lexer.ml" -= Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_mem.(0) lexbuf.Lexing.lex_mem.(1) -and -# 892 "parsing/lexer.mll" - name -# 2614 "parsing/lexer.ml" -= Lexing.sub_lexeme_opt lexbuf lexbuf.Lexing.lex_mem.(4) lexbuf.Lexing.lex_mem.(3) -and -# 892 "parsing/lexer.mll" - directive -# 2619 "parsing/lexer.ml" -= Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_start_pos lexbuf.Lexing.lex_mem.(2) in -# 894 "parsing/lexer.mll" - ( - match int_of_string num with - | exception _ -> - (* PR#7165 *) - let loc = Location.curr lexbuf in - let explanation = "line number out of range" in - let error = Invalid_directive (directive, Some explanation) in - raise (Error (error, loc)) - | line_num -> - (* Documentation says that the line number should be - positive, but we have never guarded against this and it - might have useful hackish uses. *) - update_loc lexbuf name line_num true 0; - token lexbuf - ) -# 2637 "parsing/lexer.ml" +(**** Utilities for labels ****) - | 35 -> -# 909 "parsing/lexer.mll" - ( HASH ) -# 2642 "parsing/lexer.ml" +val is_optional : arg_label -> bool +val label_name : arg_label -> label - | 36 -> -# 910 "parsing/lexer.mll" - ( AMPERSAND ) -# 2647 "parsing/lexer.ml" +(* Returns the label name with first character '?' or '~' as appropriate. *) +val prefixed_label_name : arg_label -> label - | 37 -> -# 911 "parsing/lexer.mll" - ( AMPERAMPER ) -# 2652 "parsing/lexer.ml" +val extract_label : + label -> (arg_label * 'a) list -> + arg_label * 'a * (arg_label * 'a) list * (arg_label * 'a) list + (* actual label, value, before list, after list *) - | 38 -> -# 912 "parsing/lexer.mll" - ( BACKQUOTE ) -# 2657 "parsing/lexer.ml" +(**** Utilities for backtracking ****) - | 39 -> -# 913 "parsing/lexer.mll" - ( QUOTE ) -# 2662 "parsing/lexer.ml" +type snapshot + (* A snapshot for backtracking *) +val snapshot: unit -> snapshot + (* Make a snapshot for later backtracking. Costs nothing *) +val backtrack: snapshot -> unit + (* Backtrack to a given snapshot. Only possible if you have + not already backtracked to a previous snapshot. + Calls [cleanup_abbrev] internally *) +val undo_compress: snapshot -> unit + (* Backtrack only path compression. Only meaningful if you have + not already backtracked to a previous snapshot. + Does not call [cleanup_abbrev] *) - | 40 -> -# 914 "parsing/lexer.mll" - ( LPAREN ) -# 2667 "parsing/lexer.ml" +(* Functions to use when modifying a type (only Ctype?) *) +val link_type: type_expr -> type_expr -> unit + (* Set the desc field of [t1] to [Tlink t2], logging the old + value if there is an active snapshot *) +val set_level: type_expr -> int -> unit +val set_name: + (Path.t * type_expr list) option ref -> + (Path.t * type_expr list) option -> unit +val set_row_field: row_field option ref -> row_field -> unit +val set_univar: type_expr option ref -> type_expr -> unit +val set_kind: field_kind option ref -> field_kind -> unit +val set_commu: commutable ref -> commutable -> unit +val set_typeset: TypeSet.t ref -> TypeSet.t -> unit + (* Set references, logging the old value *) +val log_type: type_expr -> unit + (* Log the old value of a type, before modifying it by hand *) - | 41 -> -# 915 "parsing/lexer.mll" - ( RPAREN ) -# 2672 "parsing/lexer.ml" +(**** Forward declarations ****) +val print_raw: (Format.formatter -> type_expr -> unit) ref - | 42 -> -# 916 "parsing/lexer.mll" - ( STAR ) -# 2677 "parsing/lexer.ml" +val iter_type_expr_kind: (type_expr -> unit) -> (type_kind -> unit) - | 43 -> -# 917 "parsing/lexer.mll" - ( COMMA ) -# 2682 "parsing/lexer.ml" +val iter_type_expr_cstr_args: (type_expr -> unit) -> + (constructor_arguments -> unit) +val map_type_expr_cstr_args: (type_expr -> type_expr) -> + (constructor_arguments -> constructor_arguments) - | 44 -> -# 918 "parsing/lexer.mll" - ( MINUSGREATER ) -# 2687 "parsing/lexer.ml" +end = struct +#1 "btype.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy and Jerome Vouillon, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) - | 45 -> -# 919 "parsing/lexer.mll" - ( DOT ) -# 2692 "parsing/lexer.ml" +(* Basic operations on core types *) - | 46 -> -# 920 "parsing/lexer.mll" - ( DOTDOT ) -# 2697 "parsing/lexer.ml" +open Misc +open Asttypes +open Types - | 47 -> -let -# 921 "parsing/lexer.mll" - s -# 2703 "parsing/lexer.ml" -= Lexing.sub_lexeme lexbuf (lexbuf.Lexing.lex_start_pos + 1) lexbuf.Lexing.lex_curr_pos in -# 921 "parsing/lexer.mll" - ( DOTOP s ) -# 2707 "parsing/lexer.ml" +(**** Sets, maps and hashtables of types ****) - | 48 -> -# 922 "parsing/lexer.mll" - ( COLON ) -# 2712 "parsing/lexer.ml" +module TypeSet = Set.Make(TypeOps) +module TypeMap = Map.Make (TypeOps) +module TypeHash = Hashtbl.Make(TypeOps) - | 49 -> -# 923 "parsing/lexer.mll" - ( COLONCOLON ) -# 2717 "parsing/lexer.ml" +(**** Forward declarations ****) - | 50 -> -# 924 "parsing/lexer.mll" - ( COLONEQUAL ) -# 2722 "parsing/lexer.ml" +let print_raw = + ref (fun _ -> assert false : Format.formatter -> type_expr -> unit) - | 51 -> -# 925 "parsing/lexer.mll" - ( COLONGREATER ) -# 2727 "parsing/lexer.ml" +(**** Type level management ****) - | 52 -> -# 926 "parsing/lexer.mll" - ( SEMI ) -# 2732 "parsing/lexer.ml" +let generic_level = 100000000 - | 53 -> -# 927 "parsing/lexer.mll" - ( SEMISEMI ) -# 2737 "parsing/lexer.ml" +(* Used to mark a type during a traversal. *) +let lowest_level = 0 +let pivot_level = 2 * lowest_level - 1 + (* pivot_level - lowest_level < lowest_level *) - | 54 -> -# 928 "parsing/lexer.mll" - ( LESS ) -# 2742 "parsing/lexer.ml" +(**** Some type creators ****) - | 55 -> -# 929 "parsing/lexer.mll" - ( LESSMINUS ) -# 2747 "parsing/lexer.ml" +let new_id = ref (-1) - | 56 -> -# 930 "parsing/lexer.mll" - ( EQUAL ) -# 2752 "parsing/lexer.ml" +let newty2 level desc = + incr new_id; { desc; level; id = !new_id } +let newgenty desc = newty2 generic_level desc +let newgenvar ?name () = newgenty (Tvar name) +(* +let newmarkedvar level = + incr new_id; { desc = Tvar; level = pivot_level - level; id = !new_id } +let newmarkedgenvar () = + incr new_id; + { desc = Tvar; level = pivot_level - generic_level; id = !new_id } +*) - | 57 -> -# 931 "parsing/lexer.mll" - ( LBRACKET ) -# 2757 "parsing/lexer.ml" +(**** Check some types ****) - | 58 -> -# 932 "parsing/lexer.mll" - ( LBRACKETBAR ) -# 2762 "parsing/lexer.ml" +let is_Tvar = function {desc=Tvar _} -> true | _ -> false +let is_Tunivar = function {desc=Tunivar _} -> true | _ -> false +let is_Tconstr = function {desc=Tconstr _} -> true | _ -> false - | 59 -> -# 933 "parsing/lexer.mll" - ( LBRACKETLESS ) -# 2767 "parsing/lexer.ml" +let dummy_method = "*dummy method*" +let default_mty = function + Some mty -> mty + | None -> Mty_signature [] - | 60 -> -# 934 "parsing/lexer.mll" - ( LBRACKETGREATER ) -# 2772 "parsing/lexer.ml" +(**** Definitions for backtracking ****) - | 61 -> -# 935 "parsing/lexer.mll" - ( RBRACKET ) -# 2777 "parsing/lexer.ml" +type change = + Ctype of type_expr * type_desc + | Ccompress of type_expr * type_desc * type_desc + | Clevel of type_expr * int + | Cname of + (Path.t * type_expr list) option ref * (Path.t * type_expr list) option + | Crow of row_field option ref * row_field option + | Ckind of field_kind option ref * field_kind option + | Ccommu of commutable ref * commutable + | Cuniv of type_expr option ref * type_expr option + | Ctypeset of TypeSet.t ref * TypeSet.t - | 62 -> -# 936 "parsing/lexer.mll" - ( LBRACE ) -# 2782 "parsing/lexer.ml" +type changes = + Change of change * changes ref + | Unchanged + | Invalid - | 63 -> -# 937 "parsing/lexer.mll" - ( LBRACELESS ) -# 2787 "parsing/lexer.ml" +let trail = Weak.create 1 - | 64 -> -# 938 "parsing/lexer.mll" - ( BAR ) -# 2792 "parsing/lexer.ml" +let log_change ch = + match Weak.get trail 0 with None -> () + | Some r -> + let r' = ref Unchanged in + r := Change (ch, r'); + Weak.set trail 0 (Some r') - | 65 -> -# 939 "parsing/lexer.mll" - ( BARBAR ) -# 2797 "parsing/lexer.ml" +(**** Representative of a type ****) - | 66 -> -# 940 "parsing/lexer.mll" - ( BARRBRACKET ) -# 2802 "parsing/lexer.ml" +let rec field_kind_repr = + function + Fvar {contents = Some kind} -> field_kind_repr kind + | kind -> kind - | 67 -> -# 941 "parsing/lexer.mll" - ( GREATER ) -# 2807 "parsing/lexer.ml" +let rec repr_link compress t d = + function + {desc = Tlink t' as d'} -> + repr_link true t d' t' + | {desc = Tfield (_, k, _, t') as d'} when field_kind_repr k = Fabsent -> + repr_link true t d' t' + | t' -> + if compress then begin + log_change (Ccompress (t, t.desc, d)); t.desc <- d + end; + t' - | 68 -> -# 942 "parsing/lexer.mll" - ( GREATERRBRACKET ) -# 2812 "parsing/lexer.ml" +let repr t = + match t.desc with + Tlink t' as d -> + repr_link false t d t' + | Tfield (_, k, _, t') as d when field_kind_repr k = Fabsent -> + repr_link false t d t' + | _ -> t - | 69 -> -# 943 "parsing/lexer.mll" - ( RBRACE ) -# 2817 "parsing/lexer.ml" +let rec commu_repr = function + Clink r when !r <> Cunknown -> commu_repr !r + | c -> c - | 70 -> -# 944 "parsing/lexer.mll" - ( GREATERRBRACE ) -# 2822 "parsing/lexer.ml" +let rec row_field_repr_aux tl = function + Reither(_, tl', _, {contents = Some fi}) -> + row_field_repr_aux (tl@tl') fi + | Reither(c, tl', m, r) -> + Reither(c, tl@tl', m, r) + | Rpresent (Some _) when tl <> [] -> + Rpresent (Some (List.hd tl)) + | fi -> fi - | 71 -> -# 945 "parsing/lexer.mll" - ( LBRACKETAT ) -# 2827 "parsing/lexer.ml" +let row_field_repr fi = row_field_repr_aux [] fi - | 72 -> -# 946 "parsing/lexer.mll" - ( LBRACKETATAT ) -# 2832 "parsing/lexer.ml" +let rec rev_concat l ll = + match ll with + [] -> l + | l'::ll -> rev_concat (l'@l) ll - | 73 -> -# 947 "parsing/lexer.mll" - ( LBRACKETATATAT ) -# 2837 "parsing/lexer.ml" +let rec row_repr_aux ll row = + match (repr row.row_more).desc with + | Tvariant row' -> + let f = row.row_fields in + row_repr_aux (if f = [] then ll else f::ll) row' + | _ -> + if ll = [] then row else + {row with row_fields = rev_concat row.row_fields ll} - | 74 -> -# 948 "parsing/lexer.mll" - ( LBRACKETPERCENT ) -# 2842 "parsing/lexer.ml" +let row_repr row = row_repr_aux [] row - | 75 -> -# 949 "parsing/lexer.mll" - ( LBRACKETPERCENTPERCENT ) -# 2847 "parsing/lexer.ml" +let rec row_field tag row = + let rec find = function + | (tag',f) :: fields -> + if tag = tag' then row_field_repr f else find fields + | [] -> + match repr row.row_more with + | {desc=Tvariant row'} -> row_field tag row' + | _ -> Rabsent + in find row.row_fields + +let rec row_more row = + match repr row.row_more with + | {desc=Tvariant row'} -> row_more row' + | ty -> ty - | 76 -> -# 950 "parsing/lexer.mll" - ( BANG ) -# 2852 "parsing/lexer.ml" +let row_fixed row = + let row = row_repr row in + row.row_fixed || + match (repr row.row_more).desc with + Tvar _ | Tnil -> false + | Tunivar _ | Tconstr _ -> true + | _ -> assert false - | 77 -> -# 951 "parsing/lexer.mll" - ( INFIXOP0 "!=" ) -# 2857 "parsing/lexer.ml" +let static_row row = + let row = row_repr row in + row.row_closed && + List.for_all + (fun (_,f) -> match row_field_repr f with Reither _ -> false | _ -> true) + row.row_fields - | 78 -> -# 952 "parsing/lexer.mll" - ( PLUS ) -# 2862 "parsing/lexer.ml" +let hash_variant s = + let accu = ref 0 in + for i = 0 to String.length s - 1 do + accu := 223 * !accu + Char.code s.[i] + done; + (* reduce to 31 bits *) + accu := !accu land (1 lsl 31 - 1); + (* make it signed for 64 bits architectures *) + if !accu > 0x3FFFFFFF then !accu - (1 lsl 31) else !accu - | 79 -> -# 953 "parsing/lexer.mll" - ( PLUSDOT ) -# 2867 "parsing/lexer.ml" +let proxy ty = + let ty0 = repr ty in + match ty0.desc with + | Tvariant row when not (static_row row) -> + row_more row + | Tobject (ty, _) -> + let rec proxy_obj ty = + match ty.desc with + Tfield (_, _, _, ty) | Tlink ty -> proxy_obj ty + | Tvar _ | Tunivar _ | Tconstr _ -> ty + | Tnil -> ty0 + | _ -> assert false + in proxy_obj ty + | _ -> ty0 - | 80 -> -# 954 "parsing/lexer.mll" - ( PLUSEQ ) -# 2872 "parsing/lexer.ml" +(**** Utilities for fixed row private types ****) - | 81 -> -# 955 "parsing/lexer.mll" - ( MINUS ) -# 2877 "parsing/lexer.ml" +let row_of_type t = + match (repr t).desc with + Tobject(t,_) -> + let rec get_row t = + let t = repr t in + match t.desc with + Tfield(_,_,_,t) -> get_row t + | _ -> t + in get_row t + | Tvariant row -> + row_more row + | _ -> + t - | 82 -> -# 956 "parsing/lexer.mll" - ( MINUSDOT ) -# 2882 "parsing/lexer.ml" +let has_constr_row t = + not (is_Tconstr t) && is_Tconstr (row_of_type t) - | 83 -> -# 959 "parsing/lexer.mll" - ( PREFIXOP(Lexing.lexeme lexbuf) ) -# 2887 "parsing/lexer.ml" +let is_row_name s = + let l = String.length s in + if l < 4 then false else String.sub s (l-4) 4 = "#row" - | 84 -> -# 961 "parsing/lexer.mll" - ( PREFIXOP(Lexing.lexeme lexbuf) ) -# 2892 "parsing/lexer.ml" +let is_constr_row ~allow_ident t = + match t.desc with + Tconstr (Path.Pident id, _, _) when allow_ident -> + is_row_name (Ident.name id) + | Tconstr (Path.Pdot (_, s, _), _, _) -> is_row_name s + | _ -> false - | 85 -> -# 963 "parsing/lexer.mll" - ( INFIXOP0(Lexing.lexeme lexbuf) ) -# 2897 "parsing/lexer.ml" - | 86 -> -# 965 "parsing/lexer.mll" - ( INFIXOP1(Lexing.lexeme lexbuf) ) -# 2902 "parsing/lexer.ml" + (**********************************) + (* Utilities for type traversal *) + (**********************************) - | 87 -> -# 967 "parsing/lexer.mll" - ( INFIXOP2(Lexing.lexeme lexbuf) ) -# 2907 "parsing/lexer.ml" +let rec iter_row f row = + List.iter + (fun (_, fi) -> + match row_field_repr fi with + | Rpresent(Some ty) -> f ty + | Reither(_, tl, _, _) -> List.iter f tl + | _ -> ()) + row.row_fields; + match (repr row.row_more).desc with + Tvariant row -> iter_row f row + | Tvar _ | Tunivar _ | Tsubst _ | Tconstr _ | Tnil -> + Misc.may (fun (_,l) -> List.iter f l) row.row_name + | _ -> assert false - | 88 -> -# 969 "parsing/lexer.mll" - ( INFIXOP4(Lexing.lexeme lexbuf) ) -# 2912 "parsing/lexer.ml" +let iter_type_expr f ty = + match ty.desc with + Tvar _ -> () + | Tarrow (_, ty1, ty2, _) -> f ty1; f ty2 + | Ttuple l -> List.iter f l + | Tconstr (_, l, _) -> List.iter f l + | Tobject(ty, {contents = Some (_, p)}) + -> f ty; List.iter f p + | Tobject (ty, _) -> f ty + | Tvariant row -> iter_row f row; f (row_more row) + | Tfield (_, _, ty1, ty2) -> f ty1; f ty2 + | Tnil -> () + | Tlink ty -> f ty + | Tsubst ty -> f ty + | Tunivar _ -> () + | Tpoly (ty, tyl) -> f ty; List.iter f tyl + | Tpackage (_, _, l) -> List.iter f l - | 89 -> -# 970 "parsing/lexer.mll" - ( PERCENT ) -# 2917 "parsing/lexer.ml" +let rec iter_abbrev f = function + Mnil -> () + | Mcons(_, _, ty, ty', rem) -> f ty; f ty'; iter_abbrev f rem + | Mlink rem -> iter_abbrev f !rem - | 90 -> -# 972 "parsing/lexer.mll" - ( INFIXOP3(Lexing.lexeme lexbuf) ) -# 2922 "parsing/lexer.ml" +type type_iterators = + { it_signature: type_iterators -> signature -> unit; + it_signature_item: type_iterators -> signature_item -> unit; + it_value_description: type_iterators -> value_description -> unit; + it_type_declaration: type_iterators -> type_declaration -> unit; + it_extension_constructor: type_iterators -> extension_constructor -> unit; + it_module_declaration: type_iterators -> module_declaration -> unit; + it_modtype_declaration: type_iterators -> modtype_declaration -> unit; + it_class_declaration: type_iterators -> class_declaration -> unit; + it_class_type_declaration: type_iterators -> class_type_declaration -> unit; + it_module_type: type_iterators -> module_type -> unit; + it_class_type: type_iterators -> class_type -> unit; + it_type_kind: type_iterators -> type_kind -> unit; + it_do_type_expr: type_iterators -> type_expr -> unit; + it_type_expr: type_iterators -> type_expr -> unit; + it_path: Path.t -> unit; } - | 91 -> -# 974 "parsing/lexer.mll" - ( HASHOP(Lexing.lexeme lexbuf) ) -# 2927 "parsing/lexer.ml" +let iter_type_expr_cstr_args f = function + | Cstr_tuple tl -> List.iter f tl + | Cstr_record lbls -> List.iter (fun d -> f d.ld_type) lbls - | 92 -> -# 975 "parsing/lexer.mll" - ( - if !if_then_else <> Dir_out then - if !if_then_else = Dir_if_true then - raise (Error (Unterminated_if, Location.curr lexbuf)) - else raise (Error(Unterminated_else, Location.curr lexbuf)) - else - EOF +let map_type_expr_cstr_args f = function + | Cstr_tuple tl -> Cstr_tuple (List.map f tl) + | Cstr_record lbls -> + Cstr_record (List.map (fun d -> {d with ld_type=f d.ld_type}) lbls) - ) -# 2940 "parsing/lexer.ml" +let iter_type_expr_kind f = function + | Type_abstract -> () + | Type_variant cstrs -> + List.iter + (fun cd -> + iter_type_expr_cstr_args f cd.cd_args; + Misc.may f cd.cd_res + ) + cstrs + | Type_record(lbls, _) -> + List.iter (fun d -> f d.ld_type) lbls + | Type_open -> + () - | 93 -> -# 985 "parsing/lexer.mll" - ( raise (Error(Illegal_character (Lexing.lexeme_char lexbuf 0), - Location.curr lexbuf)) - ) -# 2947 "parsing/lexer.ml" - | __ocaml_lex_state -> lexbuf.Lexing.refill_buff lexbuf; - __ocaml_lex_token_rec lexbuf __ocaml_lex_state +let type_iterators = + let it_signature it = + List.iter (it.it_signature_item it) + and it_signature_item it = function + Sig_value (_, vd) -> it.it_value_description it vd + | Sig_type (_, td, _) -> it.it_type_declaration it td + | Sig_typext (_, td, _) -> it.it_extension_constructor it td + | Sig_module (_, md, _) -> it.it_module_declaration it md + | Sig_modtype (_, mtd) -> it.it_modtype_declaration it mtd + | Sig_class (_, cd, _) -> it.it_class_declaration it cd + | Sig_class_type (_, ctd, _) -> it.it_class_type_declaration it ctd + and it_value_description it vd = + it.it_type_expr it vd.val_type + and it_type_declaration it td = + List.iter (it.it_type_expr it) td.type_params; + may (it.it_type_expr it) td.type_manifest; + it.it_type_kind it td.type_kind + and it_extension_constructor it td = + it.it_path td.ext_type_path; + List.iter (it.it_type_expr it) td.ext_type_params; + iter_type_expr_cstr_args (it.it_type_expr it) td.ext_args; + may (it.it_type_expr it) td.ext_ret_type + and it_module_declaration it md = + it.it_module_type it md.md_type + and it_modtype_declaration it mtd = + may (it.it_module_type it) mtd.mtd_type + and it_class_declaration it cd = + List.iter (it.it_type_expr it) cd.cty_params; + it.it_class_type it cd.cty_type; + may (it.it_type_expr it) cd.cty_new; + it.it_path cd.cty_path + and it_class_type_declaration it ctd = + List.iter (it.it_type_expr it) ctd.clty_params; + it.it_class_type it ctd.clty_type; + it.it_path ctd.clty_path + and it_module_type it = function + Mty_ident p + | Mty_alias(_, p) -> it.it_path p + | Mty_signature sg -> it.it_signature it sg + | Mty_functor (_, mto, mt) -> + may (it.it_module_type it) mto; + it.it_module_type it mt + and it_class_type it = function + Cty_constr (p, tyl, cty) -> + it.it_path p; + List.iter (it.it_type_expr it) tyl; + it.it_class_type it cty + | Cty_signature cs -> + it.it_type_expr it cs.csig_self; + Vars.iter (fun _ (_,_,ty) -> it.it_type_expr it ty) cs.csig_vars; + List.iter + (fun (p, tl) -> it.it_path p; List.iter (it.it_type_expr it) tl) + cs.csig_inher + | Cty_arrow (_, ty, cty) -> + it.it_type_expr it ty; + it.it_class_type it cty + and it_type_kind it kind = + iter_type_expr_kind (it.it_type_expr it) kind + and it_do_type_expr it ty = + iter_type_expr (it.it_type_expr it) ty; + match ty.desc with + Tconstr (p, _, _) + | Tobject (_, {contents=Some (p, _)}) + | Tpackage (p, _, _) -> + it.it_path p + | Tvariant row -> + may (fun (p,_) -> it.it_path p) (row_repr row).row_name + | _ -> () + and it_path _p = () + in + { it_path; it_type_expr = it_do_type_expr; it_do_type_expr; + it_type_kind; it_class_type; it_module_type; + it_signature; it_class_type_declaration; it_class_declaration; + it_modtype_declaration; it_module_declaration; it_extension_constructor; + it_type_declaration; it_value_description; it_signature_item; } -and comment lexbuf = - __ocaml_lex_comment_rec lexbuf 143 -and __ocaml_lex_comment_rec lexbuf __ocaml_lex_state = - match Lexing.engine __ocaml_lex_tables __ocaml_lex_state lexbuf with - | 0 -> -# 991 "parsing/lexer.mll" - ( comment_start_loc := (Location.curr lexbuf) :: !comment_start_loc; - store_lexeme lexbuf; - comment lexbuf - ) -# 2962 "parsing/lexer.ml" +let copy_row f fixed row keep more = + let fields = List.map + (fun (l, fi) -> l, + match row_field_repr fi with + | Rpresent(Some ty) -> Rpresent(Some(f ty)) + | Reither(c, tl, m, e) -> + let e = if keep then e else ref None in + let m = if row.row_fixed then fixed else m in + let tl = List.map f tl in + Reither(c, tl, m, e) + | _ -> fi) + row.row_fields in + let name = + match row.row_name with None -> None + | Some (path, tl) -> Some (path, List.map f tl) in + { row_fields = fields; row_more = more; + row_bound = (); row_fixed = row.row_fixed && fixed; + row_closed = row.row_closed; row_name = name; } - | 1 -> -# 996 "parsing/lexer.mll" - ( match !comment_start_loc with - | [] -> assert false - | [_] -> comment_start_loc := []; Location.curr lexbuf - | _ :: l -> comment_start_loc := l; - store_lexeme lexbuf; - comment lexbuf - ) -# 2973 "parsing/lexer.ml" +let rec copy_kind = function + Fvar{contents = Some k} -> copy_kind k + | Fvar _ -> Fvar (ref None) + | Fpresent -> Fpresent + | Fabsent -> assert false - | 2 -> -# 1004 "parsing/lexer.mll" - ( - string_start_loc := Location.curr lexbuf; - store_string_char '\"'; - is_in_string := true; - begin try string lexbuf - with Error (Unterminated_string, str_start) -> - match !comment_start_loc with - | [] -> assert false - | loc :: _ -> - let start = List.hd (List.rev !comment_start_loc) in - comment_start_loc := []; - raise (Error (Unterminated_string_in_comment (start, str_start), - loc)) - end; - is_in_string := false; - store_string_char '\"'; - comment lexbuf ) -# 2994 "parsing/lexer.ml" +let copy_commu c = + if commu_repr c = Cok then Cok else Clink (ref Cunknown) - | 3 -> -# 1022 "parsing/lexer.mll" - ( - let delim = Lexing.lexeme lexbuf in - let delim = String.sub delim 1 (String.length delim - 2) in - string_start_loc := Location.curr lexbuf; - store_lexeme lexbuf; - is_in_string := true; - begin try quoted_string delim lexbuf - with Error (Unterminated_string, str_start) -> - match !comment_start_loc with - | [] -> assert false - | loc :: _ -> - let start = List.hd (List.rev !comment_start_loc) in - comment_start_loc := []; - raise (Error (Unterminated_string_in_comment (start, str_start), - loc)) - end; - is_in_string := false; - store_string_char '|'; - store_string delim; - store_string_char '}'; - comment lexbuf ) -# 3019 "parsing/lexer.ml" +(* Since univars may be used as row variables, we need to do some + encoding during substitution *) +let rec norm_univar ty = + match ty.desc with + Tunivar _ | Tsubst _ -> ty + | Tlink ty -> norm_univar ty + | Ttuple (ty :: _) -> norm_univar ty + | _ -> assert false - | 4 -> -# 1045 "parsing/lexer.mll" - ( store_lexeme lexbuf; comment lexbuf ) -# 3024 "parsing/lexer.ml" +let rec copy_type_desc ?(keep_names=false) f = function + Tvar _ as ty -> if keep_names then ty else Tvar None + | Tarrow (p, ty1, ty2, c)-> Tarrow (p, f ty1, f ty2, copy_commu c) + | Ttuple l -> Ttuple (List.map f l) + | Tconstr (p, l, _) -> Tconstr (p, List.map f l, ref Mnil) + | Tobject(ty, {contents = Some (p, tl)}) + -> Tobject (f ty, ref (Some(p, List.map f tl))) + | Tobject (ty, _) -> Tobject (f ty, ref None) + | Tvariant _ -> assert false (* too ambiguous *) + | Tfield (p, k, ty1, ty2) -> (* the kind is kept shared *) + Tfield (p, field_kind_repr k, f ty1, f ty2) + | Tnil -> Tnil + | Tlink ty -> copy_type_desc f ty.desc + | Tsubst _ -> assert false + | Tunivar _ as ty -> ty (* always keep the name *) + | Tpoly (ty, tyl) -> + let tyl = List.map (fun x -> norm_univar (f x)) tyl in + Tpoly (f ty, tyl) + | Tpackage (p, n, l) -> Tpackage (p, n, List.map f l) - | 5 -> -# 1047 "parsing/lexer.mll" - ( update_loc lexbuf None 1 false 1; - store_lexeme lexbuf; - comment lexbuf - ) -# 3032 "parsing/lexer.ml" +(* Utilities for copying *) - | 6 -> -# 1052 "parsing/lexer.mll" - ( store_lexeme lexbuf; comment lexbuf ) -# 3037 "parsing/lexer.ml" +let saved_desc = ref [] + (* Saved association of generic nodes with their description. *) - | 7 -> -# 1054 "parsing/lexer.mll" - ( store_lexeme lexbuf; comment lexbuf ) -# 3042 "parsing/lexer.ml" +let save_desc ty desc = + saved_desc := (ty, desc)::!saved_desc - | 8 -> -# 1056 "parsing/lexer.mll" - ( store_lexeme lexbuf; comment lexbuf ) -# 3047 "parsing/lexer.ml" +let saved_kinds = ref [] (* duplicated kind variables *) +let new_kinds = ref [] (* new kind variables *) +let dup_kind r = + (match !r with None -> () | Some _ -> assert false); + if not (List.memq r !new_kinds) then begin + saved_kinds := r :: !saved_kinds; + let r' = ref None in + new_kinds := r' :: !new_kinds; + r := Some (Fvar r') + end - | 9 -> -# 1058 "parsing/lexer.mll" - ( store_lexeme lexbuf; comment lexbuf ) -# 3052 "parsing/lexer.ml" +(* Restored type descriptions. *) +let cleanup_types () = + List.iter (fun (ty, desc) -> ty.desc <- desc) !saved_desc; + List.iter (fun r -> r := None) !saved_kinds; + saved_desc := []; saved_kinds := []; new_kinds := [] - | 10 -> -# 1060 "parsing/lexer.mll" - ( match !comment_start_loc with - | [] -> assert false - | loc :: _ -> - let start = List.hd (List.rev !comment_start_loc) in - comment_start_loc := []; - raise (Error (Unterminated_comment start, loc)) - ) -# 3063 "parsing/lexer.ml" +(* Mark a type. *) +let rec mark_type ty = + let ty = repr ty in + if ty.level >= lowest_level then begin + ty.level <- pivot_level - ty.level; + iter_type_expr mark_type ty + end - | 11 -> -# 1068 "parsing/lexer.mll" - ( update_loc lexbuf None 1 false 0; - store_lexeme lexbuf; - comment lexbuf - ) -# 3071 "parsing/lexer.ml" +let mark_type_node ty = + let ty = repr ty in + if ty.level >= lowest_level then begin + ty.level <- pivot_level - ty.level; + end - | 12 -> -# 1073 "parsing/lexer.mll" - ( store_lexeme lexbuf; comment lexbuf ) -# 3076 "parsing/lexer.ml" +let mark_type_params ty = + iter_type_expr mark_type ty - | __ocaml_lex_state -> lexbuf.Lexing.refill_buff lexbuf; - __ocaml_lex_comment_rec lexbuf __ocaml_lex_state +let type_iterators = + let it_type_expr it ty = + let ty = repr ty in + if ty.level >= lowest_level then begin + mark_type_node ty; + it.it_do_type_expr it ty; + end + in + {type_iterators with it_type_expr} -and string lexbuf = - lexbuf.Lexing.lex_mem <- Array.make 2 (-1); __ocaml_lex_string_rec lexbuf 175 -and __ocaml_lex_string_rec lexbuf __ocaml_lex_state = - match Lexing.new_engine __ocaml_lex_tables __ocaml_lex_state lexbuf with - | 0 -> -# 1077 "parsing/lexer.mll" - ( () ) -# 3088 "parsing/lexer.ml" - | 1 -> -let -# 1078 "parsing/lexer.mll" - space -# 3094 "parsing/lexer.ml" -= Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_mem.(0) lexbuf.Lexing.lex_curr_pos in -# 1079 "parsing/lexer.mll" - ( update_loc lexbuf None 1 false (String.length space); - if in_comment () then store_lexeme lexbuf; - string lexbuf - ) -# 3101 "parsing/lexer.ml" +(* Remove marks from a type. *) +let rec unmark_type ty = + let ty = repr ty in + if ty.level < lowest_level then begin + ty.level <- pivot_level - ty.level; + iter_type_expr unmark_type ty + end + +let unmark_iterators = + let it_type_expr _it ty = unmark_type ty in + {type_iterators with it_type_expr} - | 2 -> -# 1084 "parsing/lexer.mll" - ( store_escaped_char lexbuf - (char_for_backslash(Lexing.lexeme_char lexbuf 1)); - string lexbuf ) -# 3108 "parsing/lexer.ml" +let unmark_type_decl decl = + unmark_iterators.it_type_declaration unmark_iterators decl - | 3 -> -# 1088 "parsing/lexer.mll" - ( store_escaped_char lexbuf (char_for_decimal_code lexbuf 1); - string lexbuf ) -# 3114 "parsing/lexer.ml" +let unmark_extension_constructor ext = + List.iter unmark_type ext.ext_type_params; + iter_type_expr_cstr_args unmark_type ext.ext_args; + Misc.may unmark_type ext.ext_ret_type - | 4 -> -# 1091 "parsing/lexer.mll" - ( store_escaped_char lexbuf (char_for_octal_code lexbuf 2); - string lexbuf ) -# 3120 "parsing/lexer.ml" +let unmark_class_signature sign = + unmark_type sign.csig_self; + Vars.iter (fun _l (_m, _v, t) -> unmark_type t) sign.csig_vars - | 5 -> -# 1094 "parsing/lexer.mll" - ( store_escaped_char lexbuf (char_for_hexadecimal_code lexbuf 2); - string lexbuf ) -# 3126 "parsing/lexer.ml" +let unmark_class_type cty = + unmark_iterators.it_class_type unmark_iterators cty - | 6 -> -# 1097 "parsing/lexer.mll" - ( store_escaped_uchar lexbuf (uchar_for_uchar_escape lexbuf); - string lexbuf ) -# 3132 "parsing/lexer.ml" - | 7 -> -# 1100 "parsing/lexer.mll" - ( if not (in_comment ()) then begin -(* Should be an error, but we are very lax. - raise (Error (Illegal_escape (Lexing.lexeme lexbuf), - Location.curr lexbuf)) -*) - let loc = Location.curr lexbuf in - Location.prerr_warning loc Warnings.Illegal_backslash; - end; - store_lexeme lexbuf; - string lexbuf - ) -# 3147 "parsing/lexer.ml" + (*******************************************) + (* Memorization of abbreviation expansion *) + (*******************************************) - | 8 -> -# 1112 "parsing/lexer.mll" - ( if not (in_comment ()) then - Location.prerr_warning (Location.curr lexbuf) Warnings.Eol_in_string; - update_loc lexbuf None 1 false 0; - store_lexeme lexbuf; - string lexbuf - ) -# 3157 "parsing/lexer.ml" +(* Search whether the expansion has been memorized. *) - | 9 -> -# 1119 "parsing/lexer.mll" - ( is_in_string := false; - raise (Error (Unterminated_string, !string_start_loc)) ) -# 3163 "parsing/lexer.ml" +let lte_public p1 p2 = (* Private <= Public *) + match p1, p2 with + | Private, _ | _, Public -> true + | Public, Private -> false - | 10 -> -# 1122 "parsing/lexer.mll" - ( store_string_char(Lexing.lexeme_char lexbuf 0); - string lexbuf ) -# 3169 "parsing/lexer.ml" +let rec find_expans priv p1 = function + Mnil -> None + | Mcons (priv', p2, _ty0, ty, _) + when lte_public priv priv' && Path.same p1 p2 -> Some ty + | Mcons (_, _, _, _, rem) -> find_expans priv p1 rem + | Mlink {contents = rem} -> find_expans priv p1 rem - | __ocaml_lex_state -> lexbuf.Lexing.refill_buff lexbuf; - __ocaml_lex_string_rec lexbuf __ocaml_lex_state +(* debug: check for cycles in abbreviation. only works with -principal +let rec check_expans visited ty = + let ty = repr ty in + assert (not (List.memq ty visited)); + match ty.desc with + Tconstr (path, args, abbrev) -> + begin match find_expans path !abbrev with + Some ty' -> check_expans (ty :: visited) ty' + | None -> () + end + | _ -> () +*) -and quoted_string delim lexbuf = - __ocaml_lex_quoted_string_rec delim lexbuf 202 -and __ocaml_lex_quoted_string_rec delim lexbuf __ocaml_lex_state = - match Lexing.engine __ocaml_lex_tables __ocaml_lex_state lexbuf with - | 0 -> -# 1127 "parsing/lexer.mll" - ( update_loc lexbuf None 1 false 0; - store_lexeme lexbuf; - quoted_string delim lexbuf - ) -# 3184 "parsing/lexer.ml" +let memo = ref [] + (* Contains the list of saved abbreviation expansions. *) - | 1 -> -# 1132 "parsing/lexer.mll" - ( is_in_string := false; - raise (Error (Unterminated_string, !string_start_loc)) ) -# 3190 "parsing/lexer.ml" +let cleanup_abbrev () = + (* Remove all memorized abbreviation expansions. *) + List.iter (fun abbr -> abbr := Mnil) !memo; + memo := [] - | 2 -> -# 1135 "parsing/lexer.mll" - ( - let edelim = Lexing.lexeme lexbuf in - let edelim = String.sub edelim 1 (String.length edelim - 2) in - if delim = edelim then () - else (store_lexeme lexbuf; quoted_string delim lexbuf) - ) -# 3200 "parsing/lexer.ml" +let memorize_abbrev mem priv path v v' = + (* Memorize the expansion of an abbreviation. *) + mem := Mcons (priv, path, v, v', !mem); + (* check_expans [] v; *) + memo := mem :: !memo - | 3 -> -# 1142 "parsing/lexer.mll" - ( store_string_char(Lexing.lexeme_char lexbuf 0); - quoted_string delim lexbuf ) -# 3206 "parsing/lexer.ml" +let rec forget_abbrev_rec mem path = + match mem with + Mnil -> + assert false + | Mcons (_, path', _, _, rem) when Path.same path path' -> + rem + | Mcons (priv, path', v, v', rem) -> + Mcons (priv, path', v, v', forget_abbrev_rec rem path) + | Mlink mem' -> + mem' := forget_abbrev_rec !mem' path; + raise Exit - | __ocaml_lex_state -> lexbuf.Lexing.refill_buff lexbuf; - __ocaml_lex_quoted_string_rec delim lexbuf __ocaml_lex_state +let forget_abbrev mem path = + try mem := forget_abbrev_rec !mem path with Exit -> () -and skip_hash_bang lexbuf = - __ocaml_lex_skip_hash_bang_rec lexbuf 211 -and __ocaml_lex_skip_hash_bang_rec lexbuf __ocaml_lex_state = - match Lexing.engine __ocaml_lex_tables __ocaml_lex_state lexbuf with - | 0 -> -# 1147 "parsing/lexer.mll" - ( update_loc lexbuf None 3 false 0 ) -# 3218 "parsing/lexer.ml" +(* debug: check for invalid abbreviations +let rec check_abbrev_rec = function + Mnil -> true + | Mcons (_, ty1, ty2, rem) -> + repr ty1 != repr ty2 + | Mlink mem' -> + check_abbrev_rec !mem' - | 1 -> -# 1149 "parsing/lexer.mll" - ( update_loc lexbuf None 1 false 0 ) -# 3223 "parsing/lexer.ml" +let check_memorized_abbrevs () = + List.for_all (fun mem -> check_abbrev_rec !mem) !memo +*) - | 2 -> -# 1150 "parsing/lexer.mll" - ( () ) -# 3228 "parsing/lexer.ml" + (**********************************) + (* Utilities for labels *) + (**********************************) - | __ocaml_lex_state -> lexbuf.Lexing.refill_buff lexbuf; - __ocaml_lex_skip_hash_bang_rec lexbuf __ocaml_lex_state +let is_optional = function Optional _ -> true | _ -> false -;; +let label_name = function + Nolabel -> "" + | Labelled s + | Optional s -> s -# 1152 "parsing/lexer.mll" - - let at_bol lexbuf = - let pos = Lexing.lexeme_start_p lexbuf in - pos.pos_cnum = pos.pos_bol +let prefixed_label_name = function + Nolabel -> "" + | Labelled s -> "~" ^ s + | Optional s -> "?" ^ s - let token_with_comments lexbuf = - match !preprocessor with - | None -> token lexbuf - | Some (_init, preprocess) -> preprocess token lexbuf +let rec extract_label_aux hd l = function + [] -> raise Not_found + | (l',t as p) :: ls -> + if label_name l' = l then (l', t, List.rev hd, ls) + else extract_label_aux (p::hd) l ls - type newline_state = - | NoLine (* There have been no blank lines yet. *) - | NewLine - (* There have been no blank lines, and the previous - token was a newline. *) - | BlankLine (* There have been blank lines. *) +let extract_label l ls = extract_label_aux [] l ls - type doc_state = - | Initial (* There have been no docstrings yet *) - | After of docstring list - (* There have been docstrings, none of which were - preceded by a blank line *) - | Before of docstring list * docstring list * docstring list - (* There have been docstrings, some of which were - preceded by a blank line *) - and docstring = Docstrings.docstring + (**********************************) + (* Utilities for backtracking *) + (**********************************) - let interpret_directive lexbuf cont look_ahead = - let if_then_else = !if_then_else in - begin match token_with_comments lexbuf, if_then_else with - | IF, Dir_out -> - let rec skip_from_if_false () = - let token = token_with_comments lexbuf in - if token = EOF then - raise (Error (Unterminated_if, Location.curr lexbuf)) else - if token = HASH && at_bol lexbuf then - begin - let token = token_with_comments lexbuf in - match token with - | END -> - begin - update_if_then_else Dir_out; - cont lexbuf - end - | ELSE -> - begin - update_if_then_else Dir_if_false; - cont lexbuf - end - | IF -> - raise (Error (Unexpected_directive, Location.curr lexbuf)) - | _ -> - if is_elif token && - directive_parse token_with_comments lexbuf then - begin - update_if_then_else Dir_if_true; - cont lexbuf - end - else skip_from_if_false () - end - else skip_from_if_false () in - if directive_parse token_with_comments lexbuf then - begin - update_if_then_else Dir_if_true (* Next state: ELSE *); - cont lexbuf - end - else - skip_from_if_false () - | IF, (Dir_if_false | Dir_if_true)-> - raise (Error(Unexpected_directive, Location.curr lexbuf)) - | LIDENT "elif", (Dir_if_false | Dir_out) - -> (* when the predicate is false, it will continue eating `elif` *) - raise (Error(Unexpected_directive, Location.curr lexbuf)) - | (LIDENT "elif" | ELSE as token), Dir_if_true -> - (* looking for #end, however, it can not see #if anymore *) - let rec skip_from_if_true else_seen = - let token = token_with_comments lexbuf in - if token = EOF then - raise (Error (Unterminated_else, Location.curr lexbuf)) else - if token = HASH && at_bol lexbuf then - begin - let token = token_with_comments lexbuf in - match token with - | END -> - begin - update_if_then_else Dir_out; - cont lexbuf - end - | IF -> - raise (Error (Unexpected_directive, Location.curr lexbuf)) - | ELSE -> - if else_seen then - raise (Error (Unexpected_directive, Location.curr lexbuf)) - else - skip_from_if_true true - | _ -> - if else_seen && is_elif token then - raise (Error (Unexpected_directive, Location.curr lexbuf)) - else - skip_from_if_true else_seen - end - else skip_from_if_true else_seen in - skip_from_if_true (token = ELSE) - | ELSE, Dir_if_false - | ELSE, Dir_out -> - raise (Error(Unexpected_directive, Location.curr lexbuf)) - | END, (Dir_if_false | Dir_if_true ) -> - update_if_then_else Dir_out; - cont lexbuf - | END, Dir_out -> - raise (Error(Unexpected_directive, Location.curr lexbuf)) - | token, (Dir_if_true | Dir_if_false | Dir_out) -> - look_ahead token - end +let undo_change = function + Ctype (ty, desc) -> ty.desc <- desc + | Ccompress (ty, desc, _) -> ty.desc <- desc + | Clevel (ty, level) -> ty.level <- level + | Cname (r, v) -> r := v + | Crow (r, v) -> r := v + | Ckind (r, v) -> r := v + | Ccommu (r, v) -> r := v + | Cuniv (r, v) -> r := v + | Ctypeset (r, v) -> r := v - let token lexbuf = - let post_pos = lexeme_end_p lexbuf in - let attach lines docs pre_pos = - let open Docstrings in - match docs, lines with - | Initial, _ -> () - | After a, (NoLine | NewLine) -> - set_post_docstrings post_pos (List.rev a); - set_pre_docstrings pre_pos a; - | After a, BlankLine -> - set_post_docstrings post_pos (List.rev a); - set_pre_extra_docstrings pre_pos (List.rev a) - | Before(a, f, b), (NoLine | NewLine) -> - set_post_docstrings post_pos (List.rev a); - set_post_extra_docstrings post_pos - (List.rev_append f (List.rev b)); - set_floating_docstrings pre_pos (List.rev f); - set_pre_extra_docstrings pre_pos (List.rev a); - set_pre_docstrings pre_pos b - | Before(a, f, b), BlankLine -> - set_post_docstrings post_pos (List.rev a); - set_post_extra_docstrings post_pos - (List.rev_append f (List.rev b)); - set_floating_docstrings pre_pos - (List.rev_append f (List.rev b)); - set_pre_extra_docstrings pre_pos (List.rev a) - in - let rec loop lines docs lexbuf = - match token_with_comments lexbuf with - | COMMENT (s, loc) -> - add_comment (s, loc); - let lines' = - match lines with - | NoLine -> NoLine - | NewLine -> NoLine - | BlankLine -> BlankLine - in - loop lines' docs lexbuf - | EOL -> - let lines' = - match lines with - | NoLine -> NewLine - | NewLine -> BlankLine - | BlankLine -> BlankLine - in - loop lines' docs lexbuf - | HASH when at_bol lexbuf -> - interpret_directive lexbuf - (fun lexbuf -> loop lines docs lexbuf) - (fun token -> sharp_look_ahead := Some token; HASH) - | DOCSTRING doc -> - Docstrings.register doc; - add_docstring_comment doc; - let docs' = - if Docstrings.docstring_body doc = "/*" then - match docs with - | Initial -> Before([], [doc], []) - | After a -> Before (a, [doc], []) - | Before(a, f, b) -> Before(a, doc :: b @ f, []) - else - match docs, lines with - | Initial, (NoLine | NewLine) -> After [doc] - | Initial, BlankLine -> Before([], [], [doc]) - | After a, (NoLine | NewLine) -> After (doc :: a) - | After a, BlankLine -> Before (a, [], [doc]) - | Before(a, f, b), (NoLine | NewLine) -> Before(a, f, doc :: b) - | Before(a, f, b), BlankLine -> Before(a, b @ f, [doc]) - in - loop NoLine docs' lexbuf - | tok -> - attach lines docs (lexeme_start_p lexbuf); - tok - in - match !sharp_look_ahead with - | None -> - loop NoLine Initial lexbuf - | Some token -> - sharp_look_ahead := None ; - token +type snapshot = changes ref * int +let last_snapshot = ref 0 - let init () = - sharp_look_ahead := None; - update_if_then_else Dir_out; - is_in_string := false; - comment_start_loc := []; - comment_list := []; - match !preprocessor with - | None -> () - | Some (init, _preprocess) -> init () +let log_type ty = + if ty.id <= !last_snapshot then log_change (Ctype (ty, ty.desc)) +let link_type ty ty' = + log_type ty; + let desc = ty.desc in + ty.desc <- Tlink ty'; + (* Name is a user-supplied name for this unification variable (obtained + * through a type annotation for instance). *) + match desc, ty'.desc with + Tvar name, Tvar name' -> + begin match name, name' with + | Some _, None -> log_type ty'; ty'.desc <- Tvar name + | None, Some _ -> () + | Some _, Some _ -> + if ty.level < ty'.level then (log_type ty'; ty'.desc <- Tvar name) + | None, None -> () + end + | _ -> () + (* ; assert (check_memorized_abbrevs ()) *) + (* ; check_expans [] ty' *) +let set_level ty level = + if ty.id <= !last_snapshot then log_change (Clevel (ty, ty.level)); + ty.level <- level +let set_univar rty ty = + log_change (Cuniv (rty, !rty)); rty := Some ty +let set_name nm v = + log_change (Cname (nm, !nm)); nm := v +let set_row_field e v = + log_change (Crow (e, !e)); e := Some v +let set_kind rk k = + log_change (Ckind (rk, !rk)); rk := Some k +let set_commu rc c = + log_change (Ccommu (rc, !rc)); rc := c +let set_typeset rs s = + log_change (Ctypeset (rs, !rs)); rs := s - let rec filter_directive pos acc lexbuf : (int * int ) list = - match token_with_comments lexbuf with - | HASH when at_bol lexbuf -> - (* ^[start_pos]#if ... #then^[end_pos] *) - let start_pos = Lexing.lexeme_start lexbuf in - interpret_directive lexbuf - (fun lexbuf -> - filter_directive - (Lexing.lexeme_end lexbuf) - ((pos, start_pos) :: acc) - lexbuf - - ) - (fun _token -> filter_directive pos acc lexbuf ) - | EOF -> (pos, Lexing.lexeme_end lexbuf) :: acc - | _ -> filter_directive pos acc lexbuf +let snapshot () = + let old = !last_snapshot in + last_snapshot := !new_id; + match Weak.get trail 0 with Some r -> (r, old) + | None -> + let r = ref Unchanged in + Weak.set trail 0 (Some r); + (r, old) - let filter_directive_from_lexbuf lexbuf = - List.rev (filter_directive 0 [] lexbuf ) +let rec rev_log accu = function + Unchanged -> accu + | Invalid -> assert false + | Change (ch, next) -> + let d = !next in + next := Invalid; + rev_log (ch::accu) d - let set_preprocessor init preprocess = - escaped_newlines := true; - preprocessor := Some (init, preprocess) +let backtrack (changes, old) = + match !changes with + Unchanged -> last_snapshot := old + | Invalid -> failwith "Btype.backtrack" + | Change _ as change -> + cleanup_abbrev (); + let backlog = rev_log [] change in + List.iter undo_change backlog; + changes := Unchanged; + last_snapshot := old; + Weak.set trail 0 (Some changes) +let rec rev_compress_log log r = + match !r with + Unchanged | Invalid -> + log + | Change (Ccompress _, next) -> + rev_compress_log (r::log) next + | Change (_, next) -> + rev_compress_log log next -# 3467 "parsing/lexer.ml" +let undo_compress (changes, _old) = + match !changes with + Unchanged + | Invalid -> () + | Change _ -> + let log = rev_compress_log [] changes in + List.iter + (fun r -> match !r with + Change (Ccompress (ty, desc, d), next) when ty.desc == d -> + ty.desc <- desc; r := !next + | _ -> ()) + log end -(** Interface as module *) -module Outcometree -= struct -#1 "outcometree.mli" +module Cmi_format : sig +#1 "cmi_format.mli" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Daniel de Rauglaudre, projet Cristal, INRIA Rocquencourt *) +(* Fabrice Le Fessant, INRIA Saclay *) (* *) -(* Copyright 2001 Institut National de Recherche en Informatique et *) +(* Copyright 2012 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -27222,180 +11649,52 @@ module Outcometree (* *) (**************************************************************************) -(* Module [Outcometree]: results displayed by the toplevel *) - -(* These types represent messages that the toplevel displays as normal - results or errors. The real displaying is customisable using the hooks: - [Toploop.print_out_value] - [Toploop.print_out_type] - [Toploop.print_out_sig_item] - [Toploop.print_out_phrase] *) - -type out_ident = - | Oide_apply of out_ident * out_ident - | Oide_dot of out_ident * string - | Oide_ident of string - -type out_string = - | Ostr_string - | Ostr_bytes +type pers_flags = + | Rectypes + | Deprecated of string + | Opaque + | Unsafe_string -type out_attribute = - { oattr_name: string } +type cmi_infos = { + cmi_name : string; + cmi_sign : Types.signature_item list; + cmi_crcs : (string * Digest.t option) list; + cmi_flags : pers_flags list; +} -type out_value = - | Oval_array of out_value list - | Oval_char of char - | Oval_constr of out_ident * out_value list - | Oval_ellipsis - | Oval_float of float - | Oval_int of int - | Oval_int32 of int32 - | Oval_int64 of int64 - | Oval_nativeint of nativeint - | Oval_list of out_value list - | Oval_printer of (Format.formatter -> unit) - | Oval_record of (out_ident * out_value) list - | Oval_string of string * int * out_string (* string, size-to-print, kind *) - | Oval_stuff of string - | Oval_tuple of out_value list - | Oval_variant of string * out_value option +(* write the magic + the cmi information *) +val output_cmi : string -> out_channel -> cmi_infos -> Digest.t -type out_type = - | Otyp_abstract - | Otyp_open - | Otyp_alias of out_type * string - | Otyp_arrow of string * out_type * out_type - | Otyp_class of bool * out_ident * out_type list - | Otyp_constr of out_ident * out_type list - | Otyp_manifest of out_type * out_type - | Otyp_object of (string * out_type) list * bool option - | Otyp_record of (string * bool * out_type) list - | Otyp_stuff of string - | Otyp_sum of (string * out_type list * out_type option) list - | Otyp_tuple of out_type list - | Otyp_var of bool * string - | Otyp_variant of - bool * out_variant * bool * (string list) option - | Otyp_poly of string list * out_type - | Otyp_module of string * string list * out_type list - | Otyp_attribute of out_type * out_attribute +val create_cmi : ?check_exists:unit -> string -> cmi_infos -> Digest.t -and out_variant = - | Ovar_fields of (string * bool * out_type list) list - | Ovar_typ of out_type +(* read the cmi information (the magic is supposed to have already been read) *) +val input_cmi : in_channel -> cmi_infos -type out_class_type = - | Octy_constr of out_ident * out_type list - | Octy_arrow of string * out_type * out_class_type - | Octy_signature of out_type option * out_class_sig_item list -and out_class_sig_item = - | Ocsg_constraint of out_type * out_type - | Ocsg_method of string * bool * bool * out_type - | Ocsg_value of string * bool * bool * out_type +(* read a cmi from a filename, checking the magic *) +val read_cmi : string -> cmi_infos -type out_module_type = - | Omty_abstract - | Omty_functor of string * out_module_type option * out_module_type - | Omty_ident of out_ident - | Omty_signature of out_sig_item list - | Omty_alias of out_ident -and out_sig_item = - | Osig_class of - bool * string * (string * (bool * bool)) list * out_class_type * - out_rec_status - | Osig_class_type of - bool * string * (string * (bool * bool)) list * out_class_type * - out_rec_status - | Osig_typext of out_extension_constructor * out_ext_status - | Osig_modtype of string * out_module_type - | Osig_module of string * out_module_type * out_rec_status - | Osig_type of out_type_decl * out_rec_status - | Osig_value of out_val_decl - | Osig_ellipsis -and out_type_decl = - { otype_name: string; - otype_params: (string * (bool * bool)) list; - otype_type: out_type; - otype_private: Asttypes.private_flag; - otype_immediate: bool; - otype_unboxed: bool; - otype_cstrs: (out_type * out_type) list } -and out_extension_constructor = - { oext_name: string; - oext_type_name: string; - oext_type_params: string list; - oext_args: out_type list; - oext_ret_type: out_type option; - oext_private: Asttypes.private_flag } -and out_type_extension = - { otyext_name: string; - otyext_params: string list; - otyext_constructors: (string * out_type list * out_type option) list; - otyext_private: Asttypes.private_flag } -and out_val_decl = - { oval_name: string; - oval_type: out_type; - oval_prims: string list; - oval_attributes: out_attribute list } -and out_rec_status = - | Orec_not - | Orec_first - | Orec_next -and out_ext_status = - | Oext_first - | Oext_next - | Oext_exception +(* Error report *) -type out_phrase = - | Ophr_eval of out_value * out_type - | Ophr_signature of (out_sig_item * out_value option) list - | Ophr_exception of (exn * out_value) +type error = + Not_an_interface of string + | Wrong_version_interface of string * string + | Corrupted_interface of string -end -module Oprint : sig -#1 "oprint.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 2002 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +exception Error of error open Format -open Outcometree - - -val out_ident : (formatter -> string -> unit) ref - -val out_value : (formatter -> out_value -> unit) ref -val out_type : (formatter -> out_type -> unit) ref -val out_class_type : (formatter -> out_class_type -> unit) ref -val out_module_type : (formatter -> out_module_type -> unit) ref -val out_sig_item : (formatter -> out_sig_item -> unit) ref -val out_signature : (formatter -> out_sig_item list -> unit) ref -val out_type_extension : (formatter -> out_type_extension -> unit) ref -val out_phrase : (formatter -> out_phrase -> unit) ref -val parenthesized_ident : string -> bool +val report_error: formatter -> error -> unit end = struct -#1 "oprint.ml" +#1 "cmi_format.ml" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Projet Cristal, INRIA Rocquencourt *) +(* Fabrice Le Fessant, INRIA Saclay *) (* *) -(* Copyright 2002 Institut National de Recherche en Informatique et *) +(* Copyright 2012 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -27404,943 +11703,619 @@ end = struct (* *) (**************************************************************************) -open Format -open Outcometree - -exception Ellipsis - -let cautious f ppf arg = - try f ppf arg with - Ellipsis -> fprintf ppf "..." - - -let out_ident = ref pp_print_string - - -let print_lident ppf = function - | "::" -> !out_ident ppf "(::)" - | s -> !out_ident ppf s - -let rec print_ident ppf = - function - Oide_ident s -> print_lident ppf s - | Oide_dot (id, s) -> - print_ident ppf id; pp_print_char ppf '.'; print_lident ppf s - | Oide_apply (id1, id2) -> - fprintf ppf "%a(%a)" print_ident id1 print_ident id2 - -let parenthesized_ident name = - (List.mem name ["or"; "mod"; "land"; "lor"; "lxor"; "lsl"; "lsr"; "asr"]) - || - (match name.[0] with - 'a'..'z' | 'A'..'Z' | '\223'..'\246' | '\248'..'\255' | '_' -> - false - | _ -> true) - -let value_ident ppf name = - if parenthesized_ident name then - fprintf ppf "( %s )" name - else - pp_print_string ppf name - -(* Values *) - -let valid_float_lexeme s = - let l = String.length s in - let rec loop i = - if i >= l then s ^ "." else - match s.[i] with - | '0' .. '9' | '-' -> loop (i+1) - | _ -> s - in loop 0 - -let float_repres f = - match classify_float f with - FP_nan -> "nan" - | FP_infinite -> - if f < 0.0 then "neg_infinity" else "infinity" - | _ -> - let float_val = - let s1 = Printf.sprintf "%.12g" f in - if f = float_of_string s1 then s1 else - let s2 = Printf.sprintf "%.15g" f in - if f = float_of_string s2 then s2 else - Printf.sprintf "%.18g" f - in valid_float_lexeme float_val +type pers_flags = + | Rectypes + | Deprecated of string + | Opaque + | Unsafe_string -let parenthesize_if_neg ppf fmt v isneg = - if isneg then pp_print_char ppf '('; - fprintf ppf fmt v; - if isneg then pp_print_char ppf ')' +type error = + Not_an_interface of string + | Wrong_version_interface of string * string + | Corrupted_interface of string -let escape_string s = - (* Escape only C0 control characters (bytes <= 0x1F), DEL(0x7F), '\\' and '"' *) - let n = ref 0 in - for i = 0 to String.length s - 1 do - n := !n + - (match String.unsafe_get s i with - | '\"' | '\\' | '\n' | '\t' | '\r' | '\b' -> 2 - | '\x00' .. '\x1F' - | '\x7F' -> 4 - | _ -> 1) - done; - if !n = String.length s then s else begin - let s' = Bytes.create !n in - n := 0; - for i = 0 to String.length s - 1 do - begin match String.unsafe_get s i with - | ('\"' | '\\') as c -> - Bytes.unsafe_set s' !n '\\'; incr n; Bytes.unsafe_set s' !n c - | '\n' -> - Bytes.unsafe_set s' !n '\\'; incr n; Bytes.unsafe_set s' !n 'n' - | '\t' -> - Bytes.unsafe_set s' !n '\\'; incr n; Bytes.unsafe_set s' !n 't' - | '\r' -> - Bytes.unsafe_set s' !n '\\'; incr n; Bytes.unsafe_set s' !n 'r' - | '\b' -> - Bytes.unsafe_set s' !n '\\'; incr n; Bytes.unsafe_set s' !n 'b' - | '\x00' .. '\x1F' | '\x7F' as c -> - let a = Char.code c in - Bytes.unsafe_set s' !n '\\'; - incr n; - Bytes.unsafe_set s' !n (Char.chr (48 + a / 100)); - incr n; - Bytes.unsafe_set s' !n (Char.chr (48 + (a / 10) mod 10)); - incr n; - Bytes.unsafe_set s' !n (Char.chr (48 + a mod 10)); - | c -> Bytes.unsafe_set s' !n c - end; - incr n - done; - Bytes.to_string s' - end +exception Error of error +type cmi_infos = { + cmi_name : string; + cmi_sign : Types.signature_item list; + cmi_crcs : (string * Digest.t option) list; + cmi_flags : pers_flags list; +} -let print_out_string ppf s = - let not_escaped = - (* let the user dynamically choose if strings should be escaped: *) - match Sys.getenv_opt "OCAMLTOP_UTF_8" with - | None -> true - | Some x -> - match bool_of_string_opt x with - | None -> true - | Some f -> f in - if not_escaped then - fprintf ppf "\"%s\"" (escape_string s) - else - fprintf ppf "%S" s +let input_cmi ic = + let (name, sign) = input_value ic in + let crcs = input_value ic in + let flags = input_value ic in + { + cmi_name = name; + cmi_sign = sign; + cmi_crcs = crcs; + cmi_flags = flags; + } -let print_out_value ppf tree = - let rec print_tree_1 ppf = - function - | Oval_constr (name, [param]) -> - fprintf ppf "@[<1>%a@ %a@]" print_ident name print_constr_param param - | Oval_constr (name, (_ :: _ as params)) -> - fprintf ppf "@[<1>%a@ (%a)@]" print_ident name - (print_tree_list print_tree_1 ",") params - | Oval_variant (name, Some param) -> - fprintf ppf "@[<2>`%s@ %a@]" name print_constr_param param - | tree -> print_simple_tree ppf tree - and print_constr_param ppf = function - | Oval_int i -> parenthesize_if_neg ppf "%i" i (i < 0) - | Oval_int32 i -> parenthesize_if_neg ppf "%lil" i (i < 0l) - | Oval_int64 i -> parenthesize_if_neg ppf "%LiL" i (i < 0L) - | Oval_nativeint i -> parenthesize_if_neg ppf "%nin" i (i < 0n) - | Oval_float f -> parenthesize_if_neg ppf "%s" (float_repres f) (f < 0.0) - | Oval_string (_,_, Ostr_bytes) as tree -> - pp_print_char ppf '('; - print_simple_tree ppf tree; - pp_print_char ppf ')'; - | tree -> print_simple_tree ppf tree - and print_simple_tree ppf = - function - Oval_int i -> fprintf ppf "%i" i - | Oval_int32 i -> fprintf ppf "%lil" i - | Oval_int64 i -> fprintf ppf "%LiL" i - | Oval_nativeint i -> fprintf ppf "%nin" i - | Oval_float f -> pp_print_string ppf (float_repres f) - | Oval_char c -> fprintf ppf "%C" c - | Oval_string (s, maxlen, kind) -> - begin try - let len = String.length s in - let s = if len > maxlen then String.sub s 0 maxlen else s in - begin match kind with - | Ostr_bytes -> fprintf ppf "Bytes.of_string %S" s - | Ostr_string -> print_out_string ppf s - end; - (if len > maxlen then - fprintf ppf - "... (* string length %d; truncated *)" len - ) - with - Invalid_argument _ (* "String.create" *)-> fprintf ppf "" - end - | Oval_list tl -> - fprintf ppf "@[<1>[%a]@]" (print_tree_list print_tree_1 ";") tl - | Oval_array tl -> - fprintf ppf "@[<2>[|%a|]@]" (print_tree_list print_tree_1 ";") tl - | Oval_constr (name, []) -> print_ident ppf name - | Oval_variant (name, None) -> fprintf ppf "`%s" name - | Oval_stuff s -> pp_print_string ppf s - | Oval_record fel -> - fprintf ppf "@[<1>{%a}@]" (cautious (print_fields true)) fel - | Oval_ellipsis -> raise Ellipsis - | Oval_printer f -> f ppf - | Oval_tuple tree_list -> - fprintf ppf "@[<1>(%a)@]" (print_tree_list print_tree_1 ",") tree_list - | tree -> fprintf ppf "@[<1>(%a)@]" (cautious print_tree_1) tree - and print_fields first ppf = - function - [] -> () - | (name, tree) :: fields -> - if not first then fprintf ppf ";@ "; - fprintf ppf "@[<1>%a@ =@ %a@]" print_ident name (cautious print_tree_1) - tree; - print_fields false ppf fields - and print_tree_list print_item sep ppf tree_list = - let rec print_list first ppf = - function - [] -> () - | tree :: tree_list -> - if not first then fprintf ppf "%s@ " sep; - print_item ppf tree; - print_list false ppf tree_list +let read_cmi filename = + let ic = open_in_bin filename in + try + let buffer = + really_input_string ic (String.length Config.cmi_magic_number) in - cautious (print_list true) ppf tree_list - in - cautious print_tree_1 ppf tree - -let out_value = ref print_out_value - -(* Types *) - -let rec print_list_init pr sep ppf = - function - [] -> () - | a :: l -> sep ppf; pr ppf a; print_list_init pr sep ppf l + if buffer <> Config.cmi_magic_number then begin + close_in ic; + let pre_len = String.length Config.cmi_magic_number - 3 in + if String.sub buffer 0 pre_len + = String.sub Config.cmi_magic_number 0 pre_len then + begin + let msg = + if buffer < Config.cmi_magic_number then "an older" else "a newer" in + raise (Error (Wrong_version_interface (filename, msg))) + end else begin + raise(Error(Not_an_interface filename)) + end + end; + let cmi = input_cmi ic in + close_in ic; + cmi + with End_of_file | Failure _ -> + close_in ic; + raise(Error(Corrupted_interface(filename))) + | Error e -> + close_in ic; + raise (Error e) -let rec print_list pr sep ppf = - function - [] -> () - | [a] -> pr ppf a - | a :: l -> pr ppf a; sep ppf; print_list pr sep ppf l +let output_cmi filename oc cmi = +(* beware: the provided signature must have been substituted for saving *) + output_string oc Config.cmi_magic_number; + output_value oc (cmi.cmi_name, cmi.cmi_sign); + flush oc; + let crc = Digest.file filename in + let crcs = (cmi.cmi_name, Some crc) :: cmi.cmi_crcs in + output_value oc crcs; + output_value oc cmi.cmi_flags; + crc -let pr_present = - print_list (fun ppf s -> fprintf ppf "`%s" s) (fun ppf -> fprintf ppf "@ ") -let pr_vars = - print_list (fun ppf s -> fprintf ppf "'%s" s) (fun ppf -> fprintf ppf "@ ") +(* This function is also called by [save_cmt] as cmi_format is subset of + cmt_format, so dont close the channel yet +*) +let create_cmi ?check_exists filename (cmi : cmi_infos) = + (* beware: the provided signature must have been substituted for saving *) + let content = + Config.cmi_magic_number ^ Marshal.to_string (cmi.cmi_name, cmi.cmi_sign) [] + (* checkout [output_value] in {!Pervasives} module *) + in + let crc = Digest.string content in + let cmi_infos = + if check_exists <> None && Sys.file_exists filename then + Some (read_cmi filename) + else None in + match cmi_infos with + | Some {cmi_name = _; cmi_sign = _; cmi_crcs = (old_name, Some old_crc)::rest ; cmi_flags} + (* TODO: design the cmi format so that we don't need read the whole cmi *) + when + cmi.cmi_name = old_name && + crc = old_crc && + cmi.cmi_crcs = rest && + cmi_flags = cmi.cmi_flags -> + crc + | _ -> + let crcs = (cmi.cmi_name, Some crc) :: cmi.cmi_crcs in + let oc = open_out_bin filename in + output_string oc content; + output_value oc crcs; + output_value oc cmi.cmi_flags; + close_out oc; + crc -let rec print_out_type ppf = - function - | Otyp_alias (ty, s) -> - fprintf ppf "@[%a@ as '%s@]" print_out_type ty s - | Otyp_poly (sl, ty) -> - fprintf ppf "@[%a.@ %a@]" - pr_vars sl - print_out_type ty - | ty -> - print_out_type_1 ppf ty -and print_out_type_1 ppf = - function - Otyp_arrow (lab, ty1, ty2) -> - pp_open_box ppf 0; - if lab <> "" then (pp_print_string ppf lab; pp_print_char ppf ':'); - print_out_type_2 ppf ty1; - pp_print_string ppf " ->"; - pp_print_space ppf (); - print_out_type_1 ppf ty2; - pp_close_box ppf () - | ty -> print_out_type_2 ppf ty -and print_out_type_2 ppf = - function - Otyp_tuple tyl -> - fprintf ppf "@[<0>%a@]" (print_typlist print_simple_out_type " *") tyl - | ty -> print_simple_out_type ppf ty -and print_simple_out_type ppf = - function - Otyp_class (ng, id, tyl) -> - fprintf ppf "@[%a%s#%a@]" print_typargs tyl (if ng then "_" else "") - print_ident id - - | Otyp_constr ( (Oide_dot (((Oide_dot (Oide_ident "Js", "Internal"))| (Oide_ident "Js_internal")), - ("fn" | "meth" as name )) as id) , - ([Otyp_variant(_,Ovar_fields [ variant, _, tys], _,_); result] as tyl)) - -> - (* Otyp_arrow*) - let make tys result = - if tys = [] then - Otyp_arrow ("", Otyp_constr (Oide_ident "unit", []),result) - else - match tys with - | [ Otyp_tuple tys as single] -> - if variant = "Arity_1" then - Otyp_arrow ("", single, result) - else - List.fold_right (fun x acc -> Otyp_arrow("",x,acc) ) tys result - | [single] -> - Otyp_arrow ("", single, result) - | _ -> - raise_notrace Not_found - in - begin match (make tys result) with - | exception _ -> - begin - pp_open_box ppf 0; - print_typargs ppf tyl; - print_ident ppf id; - pp_close_box ppf () - end - | res -> - begin match name with - | "fn" -> - fprintf ppf "@[<0>(%a@ [@bs])@]" print_out_type_1 res - | "meth" -> - fprintf ppf "@[<0>(%a@ [@bs.meth])@]" print_out_type_1 res - | _ -> assert false - end - end - | Otyp_constr ((Oide_dot ((Oide_dot (Oide_ident "Js", "Internal") | (Oide_ident "Js_internal")), "meth_callback" ) as id) , - ([Otyp_variant(_,Ovar_fields [ variant, _, tys], _,_); result] as tyl)) - -> - let make tys result = - match tys with - | [ Otyp_tuple tys as single ] -> - if variant = "Arity_1" then Otyp_arrow ("", single, result) - else - List.fold_right (fun x acc -> Otyp_arrow("",x,acc) ) tys result - | [single] -> - Otyp_arrow ("", single, result) - | _ -> - raise_notrace Not_found - in - begin match (make tys result) with - | exception _ -> - begin - pp_open_box ppf 0; - print_typargs ppf tyl; - print_ident ppf id; - pp_close_box ppf () - end - | res -> - fprintf ppf "@[<0>(%a@ [@bs.this])@]" print_out_type_1 res - end - - | Otyp_constr (id, tyl) -> - pp_open_box ppf 0; - print_typargs ppf tyl; - print_ident ppf id; - pp_close_box ppf () - | Otyp_object (fields, rest) -> - fprintf ppf "@[<2>< %a >@]" (print_fields rest) fields - | Otyp_stuff s -> pp_print_string ppf s - | Otyp_var (ng, s) -> fprintf ppf "'%s%s" (if ng then "_" else "") s - | Otyp_variant (non_gen, row_fields, closed, tags) -> - let print_present ppf = - function - None | Some [] -> () - | Some l -> fprintf ppf "@;<1 -2>> @[%a@]" pr_present l - in - let print_fields ppf = - function - Ovar_fields fields -> - print_list print_row_field (fun ppf -> fprintf ppf "@;<1 -2>| ") - ppf fields - | Ovar_typ typ -> - print_simple_out_type ppf typ - in - fprintf ppf "%s[%s@[@[%a@]%a ]@]" (if non_gen then "_" else "") - (if closed then if tags = None then " " else "< " - else if tags = None then "> " else "? ") - print_fields row_fields - print_present tags - | Otyp_alias _ | Otyp_poly _ | Otyp_arrow _ | Otyp_tuple _ as ty -> - pp_open_box ppf 1; - pp_print_char ppf '('; - print_out_type ppf ty; - pp_print_char ppf ')'; - pp_close_box ppf () - | Otyp_abstract | Otyp_open - | Otyp_sum _ | Otyp_manifest (_, _) -> () - | Otyp_record lbls -> print_record_decl ppf lbls - | Otyp_module (p, n, tyl) -> - fprintf ppf "@[<1>(module %s" p; - let first = ref true in - List.iter2 - (fun s t -> - let sep = if !first then (first := false; "with") else "and" in - fprintf ppf " %s type %s = %a" sep s print_out_type t - ) - n tyl; - fprintf ppf ")@]" - | Otyp_attribute (t, attr) -> - fprintf ppf "@[<1>(%a [@@%s])@]" print_out_type t attr.oattr_name -and print_record_decl ppf lbls = - fprintf ppf "{%a@;<1 -2>}" - (print_list_init print_out_label (fun ppf -> fprintf ppf "@ ")) lbls -and print_fields rest ppf = - function - [] -> - begin match rest with - Some non_gen -> fprintf ppf "%s.." (if non_gen then "_" else "") - | None -> () - end - | [s, t] -> - fprintf ppf "%s : %a" s print_out_type t; - begin match rest with - Some _ -> fprintf ppf ";@ " - | None -> () - end; - print_fields rest ppf [] - | (s, t) :: l -> - fprintf ppf "%s : %a;@ %a" s print_out_type t (print_fields rest) l -and print_row_field ppf (l, opt_amp, tyl) = - let pr_of ppf = - if opt_amp then fprintf ppf " of@ &@ " - else if tyl <> [] then fprintf ppf " of@ " - else fprintf ppf "" - in - fprintf ppf "@[`%s%t%a@]" l pr_of (print_typlist print_out_type " &") - tyl -and print_typlist print_elem sep ppf = - function - [] -> () - | [ty] -> print_elem ppf ty - | ty :: tyl -> - print_elem ppf ty; - pp_print_string ppf sep; - pp_print_space ppf (); - print_typlist print_elem sep ppf tyl -and print_typargs ppf = - function - [] -> () - | [ty1] -> print_simple_out_type ppf ty1; pp_print_space ppf () - | tyl -> - pp_open_box ppf 1; - pp_print_char ppf '('; - print_typlist print_out_type "," ppf tyl; - pp_print_char ppf ')'; - pp_close_box ppf (); - pp_print_space ppf () -and print_out_label ppf (name, mut, arg) = - fprintf ppf "@[<2>%s%s :@ %a@];" (if mut then "mutable " else "") name - print_out_type arg + +(* Error report *) -let out_type = ref print_out_type +open Format -(* Class types *) +let report_error ppf = function + | Not_an_interface filename -> + fprintf ppf "%a@ is not a compiled interface" + Location.print_filename filename + | Wrong_version_interface (filename, older_newer) -> + fprintf ppf + "%a@ is not a compiled interface for this version of OCaml.@.\ + It seems to be for %s version of OCaml." + Location.print_filename filename older_newer + | Corrupted_interface filename -> + fprintf ppf "Corrupted compiled interface@ %a" + Location.print_filename filename -let type_parameter ppf (ty, (co, cn)) = - fprintf ppf "%s%s" - (if not cn then "+" else if not co then "-" else "") - (if ty = "_" then ty else "'"^ty) +let () = + Location.register_error_of_exn + (function + | Error err -> Some (Location.error_of_printer_file report_error err) + | _ -> None + ) -let print_out_class_params ppf = - function - [] -> () - | tyl -> - fprintf ppf "@[<1>[%a]@]@ " - (print_list type_parameter (fun ppf -> fprintf ppf ", ")) - tyl +end +module Consistbl : sig +#1 "consistbl.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 2002 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -let rec print_out_class_type ppf = - function - Octy_constr (id, tyl) -> - let pr_tyl ppf = - function - [] -> () - | tyl -> - fprintf ppf "@[<1>[%a]@]@ " (print_typlist !out_type ",") tyl - in - fprintf ppf "@[%a%a@]" pr_tyl tyl print_ident id - | Octy_arrow (lab, ty, cty) -> - fprintf ppf "@[%s%a ->@ %a@]" (if lab <> "" then lab ^ ":" else "") - print_out_type_2 ty print_out_class_type cty - | Octy_signature (self_ty, csil) -> - let pr_param ppf = - function - Some ty -> fprintf ppf "@ @[(%a)@]" !out_type ty - | None -> () - in - fprintf ppf "@[@[<2>object%a@]@ %a@;<1 -2>end@]" pr_param self_ty - (print_list print_out_class_sig_item (fun ppf -> fprintf ppf "@ ")) - csil -and print_out_class_sig_item ppf = - function - Ocsg_constraint (ty1, ty2) -> - fprintf ppf "@[<2>constraint %a =@ %a@]" !out_type ty1 - !out_type ty2 - | Ocsg_method (name, priv, virt, ty) -> - fprintf ppf "@[<2>method %s%s%s :@ %a@]" - (if priv then "private " else "") (if virt then "virtual " else "") - name !out_type ty - | Ocsg_value (name, mut, vr, ty) -> - fprintf ppf "@[<2>val %s%s%s :@ %a@]" - (if mut then "mutable " else "") - (if vr then "virtual " else "") - name !out_type ty +(* Consistency tables: for checking consistency of module CRCs *) -let out_class_type = ref print_out_class_type +type t -(* Signature *) +val create: unit -> t -let out_module_type = ref (fun _ -> failwith "Oprint.out_module_type") -let out_sig_item = ref (fun _ -> failwith "Oprint.out_sig_item") -let out_signature = ref (fun _ -> failwith "Oprint.out_signature") -let out_type_extension = ref (fun _ -> failwith "Oprint.out_type_extension") +val clear: t -> unit -let rec print_out_functor funct ppf = - function - Omty_functor (_, None, mty_res) -> - if funct then fprintf ppf "() %a" (print_out_functor true) mty_res - else fprintf ppf "functor@ () %a" (print_out_functor true) mty_res - | Omty_functor (name, Some mty_arg, mty_res) -> begin - match name, funct with - | "_", true -> - fprintf ppf "->@ %a ->@ %a" - print_out_module_type mty_arg (print_out_functor false) mty_res - | "_", false -> - fprintf ppf "%a ->@ %a" - print_out_module_type mty_arg (print_out_functor false) mty_res - | name, true -> - fprintf ppf "(%s : %a) %a" name - print_out_module_type mty_arg (print_out_functor true) mty_res - | name, false -> - fprintf ppf "functor@ (%s : %a) %a" name - print_out_module_type mty_arg (print_out_functor true) mty_res - end - | m -> - if funct then fprintf ppf "->@ %a" print_out_module_type m - else print_out_module_type ppf m +val check: t -> string -> Digest.t -> string -> unit + (* [check tbl name crc source] + checks consistency of ([name], [crc]) with infos previously + stored in [tbl]. If no CRC was previously associated with + [name], record ([name], [crc]) in [tbl]. + [source] is the name of the file from which the information + comes from. This is used for error reporting. *) -and print_out_module_type ppf = - function - Omty_abstract -> () - | Omty_functor _ as t -> - fprintf ppf "@[<2>%a@]" (print_out_functor false) t - | Omty_ident id -> fprintf ppf "%a" print_ident id - | Omty_signature sg -> - fprintf ppf "@[sig@ %a@;<1 -2>end@]" !out_signature sg - | Omty_alias id -> fprintf ppf "(module %a)" print_ident id -and print_out_signature ppf = - function - [] -> () - | [item] -> !out_sig_item ppf item - | Osig_typext(ext, Oext_first) :: items -> - (* Gather together the extension constructors *) - let rec gather_extensions acc items = - match items with - Osig_typext(ext, Oext_next) :: items -> - gather_extensions - ((ext.oext_name, ext.oext_args, ext.oext_ret_type) :: acc) - items - | _ -> (List.rev acc, items) - in - let exts, items = - gather_extensions - [(ext.oext_name, ext.oext_args, ext.oext_ret_type)] - items - in - let te = - { otyext_name = ext.oext_type_name; - otyext_params = ext.oext_type_params; - otyext_constructors = exts; - otyext_private = ext.oext_private } - in - fprintf ppf "%a@ %a" !out_type_extension te print_out_signature items - | item :: items -> - fprintf ppf "%a@ %a" !out_sig_item item print_out_signature items -and print_out_sig_item ppf = - function - Osig_class (vir_flag, name, params, clt, rs) -> - fprintf ppf "@[<2>%s%s@ %a%s@ :@ %a@]" - (if rs = Orec_next then "and" else "class") - (if vir_flag then " virtual" else "") print_out_class_params params - name !out_class_type clt - | Osig_class_type (vir_flag, name, params, clt, rs) -> - fprintf ppf "@[<2>%s%s@ %a%s@ =@ %a@]" - (if rs = Orec_next then "and" else "class type") - (if vir_flag then " virtual" else "") print_out_class_params params - name !out_class_type clt - | Osig_typext (ext, Oext_exception) -> - fprintf ppf "@[<2>exception %a@]" - print_out_constr (ext.oext_name, ext.oext_args, ext.oext_ret_type) - | Osig_typext (ext, _es) -> - print_out_extension_constructor ppf ext - | Osig_modtype (name, Omty_abstract) -> - fprintf ppf "@[<2>module type %s@]" name - | Osig_modtype (name, mty) -> - fprintf ppf "@[<2>module type %s =@ %a@]" name !out_module_type mty - | Osig_module (name, Omty_alias id, _) -> - fprintf ppf "@[<2>module %s =@ %a@]" name print_ident id - | Osig_module (name, mty, rs) -> - fprintf ppf "@[<2>%s %s :@ %a@]" - (match rs with Orec_not -> "module" - | Orec_first -> "module rec" - | Orec_next -> "and") - name !out_module_type mty - | Osig_type(td, rs) -> - print_out_type_decl - (match rs with - | Orec_not -> "type nonrec" - | Orec_first -> "type" - | Orec_next -> "and") - ppf td - | Osig_value vd -> - let kwd = if vd.oval_prims = [] then "val" else "external" in - let pr_prims ppf = - function - [] -> () - | s :: sl -> - fprintf ppf "@ = \"%s\"" s; - List.iter (fun s -> -(* TODO: in general, we should print bs attributes, some attributes like - bs.splice does need it *) +val check_noadd: t -> string -> Digest.t -> string -> unit + (* Same as [check], but raise [Not_available] if no CRC was previously + associated with [name]. *) - let len = String.length s in - if len >= 3 && s.[0] = 'B' && s.[1] = 'S' && s.[2] = ':' then - fprintf ppf "@ \"BS-EXTERNAL\"" - else - fprintf ppf "@ \"%s\"" s - - ) sl - in - fprintf ppf "@[<2>%s %a :@ %a%a%a@]" kwd value_ident vd.oval_name - !out_type vd.oval_type pr_prims vd.oval_prims - (fun ppf -> List.iter (fun a -> fprintf ppf "@ [@@@@%s]" a.oattr_name)) - vd.oval_attributes - | Osig_ellipsis -> - fprintf ppf "..." +val set: t -> string -> Digest.t -> string -> unit + (* [set tbl name crc source] forcefully associates [name] with + [crc] in [tbl], even if [name] already had a different CRC + associated with [name] in [tbl]. *) -and print_out_type_decl kwd ppf td = - let print_constraints ppf = - List.iter - (fun (ty1, ty2) -> - fprintf ppf "@ @[<2>constraint %a =@ %a@]" !out_type ty1 - !out_type ty2) - td.otype_cstrs - in - let type_defined ppf = - match td.otype_params with - [] -> pp_print_string ppf td.otype_name - | [param] -> fprintf ppf "@[%a@ %s@]" type_parameter param td.otype_name - | _ -> - fprintf ppf "@[(@[%a)@]@ %s@]" - (print_list type_parameter (fun ppf -> fprintf ppf ",@ ")) - td.otype_params - td.otype_name - in - let print_manifest ppf = - function - Otyp_manifest (ty, _) -> fprintf ppf " =@ %a" !out_type ty - | _ -> () - in - let print_name_params ppf = - fprintf ppf "%s %t%a" kwd type_defined print_manifest td.otype_type - in - let ty = - match td.otype_type with - Otyp_manifest (_, ty) -> ty - | _ -> td.otype_type - in - let print_private ppf = function - Asttypes.Private -> fprintf ppf " private" - | Asttypes.Public -> () - in - let print_immediate ppf = - if td.otype_immediate then fprintf ppf " [%@%@immediate]" else () - in - let print_unboxed ppf = - if td.otype_unboxed then fprintf ppf " [%@%@unboxed]" else () - in - let print_out_tkind ppf = function - | Otyp_abstract -> () - | Otyp_record lbls -> - fprintf ppf " =%a %a" - print_private td.otype_private - print_record_decl lbls - | Otyp_sum constrs -> - fprintf ppf " =%a@;<1 2>%a" - print_private td.otype_private - (print_list print_out_constr (fun ppf -> fprintf ppf "@ | ")) constrs - | Otyp_open -> - fprintf ppf " =%a .." - print_private td.otype_private - | ty -> - fprintf ppf " =%a@;<1 2>%a" - print_private td.otype_private - !out_type ty - in - fprintf ppf "@[<2>@[%t%a@]%t%t%t@]" - print_name_params - print_out_tkind ty - print_constraints - print_immediate - print_unboxed +val source: t -> string -> string + (* [source tbl name] returns the file name associated with [name] + if the latter has an associated CRC in [tbl]. + Raise [Not_found] otherwise. *) -and print_out_constr ppf (name, tyl,ret_type_opt) = - let name = - match name with - | "::" -> "(::)" (* #7200 *) - | s -> s - in - match ret_type_opt with - | None -> - begin match tyl with - | [] -> - pp_print_string ppf name - | _ -> - fprintf ppf "@[<2>%s of@ %a@]" name - (print_typlist print_simple_out_type " *") tyl - end - | Some ret_type -> - begin match tyl with - | [] -> - fprintf ppf "@[<2>%s :@ %a@]" name print_simple_out_type ret_type - | _ -> - fprintf ppf "@[<2>%s :@ %a -> %a@]" name - (print_typlist print_simple_out_type " *") - tyl print_simple_out_type ret_type - end +val extract: string list -> t -> (string * Digest.t option) list + (* [extract tbl names] returns an associative list mapping each string + in [names] to the CRC associated with it in [tbl]. If no CRC is + associated with a name then it is mapped to [None]. *) -and print_out_extension_constructor ppf ext = - let print_extended_type ppf = - let print_type_parameter ppf ty = - fprintf ppf "%s" - (if ty = "_" then ty else "'"^ty) - in - match ext.oext_type_params with - [] -> fprintf ppf "%s" ext.oext_type_name - | [ty_param] -> - fprintf ppf "@[%a@ %s@]" - print_type_parameter - ty_param - ext.oext_type_name - | _ -> - fprintf ppf "@[(@[%a)@]@ %s@]" - (print_list print_type_parameter (fun ppf -> fprintf ppf ",@ ")) - ext.oext_type_params - ext.oext_type_name - in - fprintf ppf "@[type %t +=%s@;<1 2>%a@]" - print_extended_type - (if ext.oext_private = Asttypes.Private then " private" else "") - print_out_constr (ext.oext_name, ext.oext_args, ext.oext_ret_type) +val filter: (string -> bool) -> t -> unit + (* [filter pred tbl] removes from [tbl] table all (name, CRC) pairs + such that [pred name] is [false]. *) -and print_out_type_extension ppf te = - let print_extended_type ppf = - let print_type_parameter ppf ty = - fprintf ppf "%s" - (if ty = "_" then ty else "'"^ty) - in - match te.otyext_params with - [] -> fprintf ppf "%s" te.otyext_name - | [param] -> - fprintf ppf "@[%a@ %s@]" - print_type_parameter param - te.otyext_name - | _ -> - fprintf ppf "@[(@[%a)@]@ %s@]" - (print_list print_type_parameter (fun ppf -> fprintf ppf ",@ ")) - te.otyext_params - te.otyext_name - in - fprintf ppf "@[type %t +=%s@;<1 2>%a@]" - print_extended_type - (if te.otyext_private = Asttypes.Private then " private" else "") - (print_list print_out_constr (fun ppf -> fprintf ppf "@ | ")) - te.otyext_constructors +exception Inconsistency of string * string * string + (* Raised by [check] when a CRC mismatch is detected. + First string is the name of the compilation unit. + Second string is the source that caused the inconsistency. + Third string is the source that set the CRC. *) -let _ = out_module_type := print_out_module_type -let _ = out_signature := print_out_signature -let _ = out_sig_item := print_out_sig_item -let _ = out_type_extension := print_out_type_extension +exception Not_available of string + (* Raised by [check_noadd] when a name doesn't have an associated CRC. *) -(* Phrases *) +end = struct +#1 "consistbl.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 2002 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -let print_out_exception ppf exn outv = - match exn with - Sys.Break -> fprintf ppf "Interrupted.@." - | Out_of_memory -> fprintf ppf "Out of memory during evaluation.@." - | Stack_overflow -> - fprintf ppf "Stack overflow during evaluation (looping recursion?).@." - | _ -> fprintf ppf "@[Exception:@ %a.@]@." !out_value outv +(* Consistency tables: for checking consistency of module CRCs *) -let rec print_items ppf = - function - [] -> () - | (Osig_typext(ext, Oext_first), None) :: items -> - (* Gather together extension constructors *) - let rec gather_extensions acc items = - match items with - (Osig_typext(ext, Oext_next), None) :: items -> - gather_extensions - ((ext.oext_name, ext.oext_args, ext.oext_ret_type) :: acc) - items - | _ -> (List.rev acc, items) - in - let exts, items = - gather_extensions - [(ext.oext_name, ext.oext_args, ext.oext_ret_type)] - items - in - let te = - { otyext_name = ext.oext_type_name; - otyext_params = ext.oext_type_params; - otyext_constructors = exts; - otyext_private = ext.oext_private } - in - fprintf ppf "@[%a@]" !out_type_extension te; - if items <> [] then fprintf ppf "@ %a" print_items items - | (tree, valopt) :: items -> - begin match valopt with - Some v -> - fprintf ppf "@[<2>%a =@ %a@]" !out_sig_item tree - !out_value v - | None -> fprintf ppf "@[%a@]" !out_sig_item tree - end; - if items <> [] then fprintf ppf "@ %a" print_items items +type t = (string, Digest.t * string) Hashtbl.t -let print_out_phrase ppf = - function - Ophr_eval (outv, ty) -> - fprintf ppf "@[- : %a@ =@ %a@]@." !out_type ty !out_value outv - | Ophr_signature [] -> () - | Ophr_signature items -> fprintf ppf "@[%a@]@." print_items items - | Ophr_exception (exn, outv) -> print_out_exception ppf exn outv +let create () = Hashtbl.create 13 -let out_phrase = ref print_out_phrase +let clear = Hashtbl.clear + +exception Inconsistency of string * string * string + +exception Not_available of string + +let check tbl name crc source = + try + let (old_crc, old_source) = Hashtbl.find tbl name in + if crc <> old_crc then raise(Inconsistency(name, source, old_source)) + with Not_found -> + Hashtbl.add tbl name (crc, source) + +let check_noadd tbl name crc source = + try + let (old_crc, old_source) = Hashtbl.find tbl name in + if crc <> old_crc then raise(Inconsistency(name, source, old_source)) + with Not_found -> + raise (Not_available name) + +let set tbl name crc source = Hashtbl.add tbl name (crc, source) + +let source tbl name = snd (Hashtbl.find tbl name) + +let extract l tbl = + let l = List.sort_uniq String.compare l in + List.fold_left + (fun assc name -> + try + let (crc, _) = Hashtbl.find tbl name in + (name, Some crc) :: assc + with Not_found -> + (name, None) :: assc) + [] l + +let filter p tbl = + let to_remove = ref [] in + Hashtbl.iter + (fun name _ -> + if not (p name) then to_remove := name :: !to_remove) + tbl; + List.iter + (fun name -> + while Hashtbl.mem tbl name do Hashtbl.remove tbl name done) + !to_remove end -module Ext_buffer : sig -#1 "ext_buffer.mli" -(***********************************************************************) -(* *) -(* OCaml *) -(* *) -(* Pierre Weis and Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1999 Institut National de Recherche en Informatique et *) -(* en Automatique. All rights reserved. This file is distributed *) -(* under the terms of the GNU Library General Public License, with *) -(* the special exception on linking described in file ../LICENSE. *) -(* *) -(***********************************************************************) +module Datarepr : sig +#1 "datarepr.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -(** Extensible buffers. +(* Compute constructor and label descriptions from type declarations, + determining their representation. *) - This module implements buffers that automatically expand - as necessary. It provides accumulative concatenation of strings - in quasi-linear time (instead of quadratic time when strings are - concatenated pairwise). -*) +open Types -(* BuckleScript customization: customized for efficient digest *) +val constructor_has_optional_shape: + Types.constructor_description -> bool -type t -(** The abstract type of buffers. *) +val extension_descr: + Path.t -> extension_constructor -> constructor_description -val create : int -> t -(** [create n] returns a fresh buffer, initially empty. - The [n] parameter is the initial size of the internal byte sequence - that holds the buffer contents. That byte sequence is automatically - reallocated when more than [n] characters are stored in the buffer, - but shrinks back to [n] characters when [reset] is called. - For best performance, [n] should be of the same order of magnitude - as the number of characters that are expected to be stored in - the buffer (for instance, 80 for a buffer that holds one output - line). Nothing bad will happen if the buffer grows beyond that - limit, however. In doubt, take [n = 16] for instance. - If [n] is not between 1 and {!Sys.max_string_length}, it will - be clipped to that interval. *) +val labels_of_type: + Path.t -> type_declaration -> + (Ident.t * label_description) list +val constructors_of_type: + Path.t -> type_declaration -> + (Ident.t * constructor_description) list -val contents : t -> string -(** Return a copy of the current contents of the buffer. - The buffer itself is unchanged. *) -val length : t -> int -(** Return the number of characters currently contained in the buffer. *) +exception Constr_not_found -val is_empty : t -> bool +val find_constr_by_tag: + constructor_tag -> constructor_declaration list -> + constructor_declaration -val clear : t -> unit -(** Empty the buffer. *) +val constructor_existentials : + constructor_arguments -> type_expr option -> type_expr list * type_expr list +(** Takes [cd_args] and [cd_res] from a [constructor_declaration] and + returns: + - the types of the constructor's arguments + - the existential variables introduced by the constructor + *) -val add_char : t -> char -> unit -(** [add_char b c] appends the character [c] at the end of the buffer [b]. *) +(* Set the polymorphic variant row_name field *) +val set_row_name : type_declaration -> Path.t -> unit -val add_string : t -> string -> unit -(** [add_string b s] appends the string [s] at the end of the buffer [b]. *) +end = struct +#1 "datarepr.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -val add_bytes : t -> bytes -> unit -(** [add_string b s] appends the string [s] at the end of the buffer [b]. - @since 4.02 *) +(* Compute constructor and label descriptions from type declarations, + determining their representation. *) -val add_substring : t -> string -> int -> int -> unit -(** [add_substring b s ofs len] takes [len] characters from offset - [ofs] in string [s] and appends them at the end of the buffer [b]. *) +open Asttypes +open Types +open Btype -val add_subbytes : t -> bytes -> int -> int -> unit -(** [add_substring b s ofs len] takes [len] characters from offset - [ofs] in byte sequence [s] and appends them at the end of the buffer [b]. - @since 4.02 *) +(* Simplified version of Ctype.free_vars *) +let free_vars ?(param=false) ty = + let ret = ref TypeSet.empty in + let rec loop ty = + let ty = repr ty in + if ty.level >= lowest_level then begin + ty.level <- pivot_level - ty.level; + match ty.desc with + | Tvar _ -> + ret := TypeSet.add ty !ret + | Tvariant row -> + let row = row_repr row in + iter_row loop row; + if not (static_row row) then begin + match row.row_more.desc with + | Tvar _ when param -> ret := TypeSet.add ty !ret + | _ -> loop row.row_more + end + (* XXX: What about Tobject ? *) + | _ -> + iter_type_expr loop ty + end + in + loop ty; + unmark_type ty; + !ret -val add_buffer : t -> t -> unit -(** [add_buffer b1 b2] appends the current contents of buffer [b2] - at the end of buffer [b1]. [b2] is not modified. *) +let newgenconstr path tyl = newgenty (Tconstr (path, tyl, ref Mnil)) -val add_channel : t -> in_channel -> int -> unit -(** [add_channel b ic n] reads exactly [n] character from the - input channel [ic] and stores them at the end of buffer [b]. - Raise [End_of_file] if the channel contains fewer than [n] - characters. *) +let constructor_existentials cd_args cd_res = + let tyl = + match cd_args with + | Cstr_tuple l -> l + | Cstr_record l -> List.map (fun l -> l.ld_type) l + in + let existentials = + match cd_res with + | None -> [] + | Some type_ret -> + let arg_vars_set = free_vars (newgenty (Ttuple tyl)) in + let res_vars = free_vars type_ret in + TypeSet.elements (TypeSet.diff arg_vars_set res_vars) + in + (tyl, existentials) + +let constructor_args priv cd_args cd_res path rep = + let tyl, existentials = constructor_existentials cd_args cd_res in + match cd_args with + | Cstr_tuple l -> existentials, l, None + | Cstr_record lbls -> + let arg_vars_set = free_vars ~param:true (newgenty (Ttuple tyl)) in + let type_params = TypeSet.elements arg_vars_set in + let type_unboxed = + match rep with + | Record_unboxed _ -> unboxed_true_default_false + | _ -> unboxed_false_default_false + in + let tdecl = + { + type_params; + type_arity = List.length type_params; + type_kind = Type_record (lbls, rep); + type_private = priv; + type_manifest = None; + type_variance = List.map (fun _ -> Variance.full) type_params; + type_newtype_level = None; + type_loc = Location.none; + type_attributes = []; + type_immediate = false; + type_unboxed; + } + in + existentials, + [ newgenconstr path type_params ], + Some tdecl + +let internal_optional = "internal.optional" + +let optional_shape : Parsetree.attribute = + {txt = internal_optional ; loc = Location.none}, Parsetree.PStr [] + +let constructor_has_optional_shape ({cstr_attributes = attrs} : constructor_description) = + List.exists (fun (x,_) -> x.txt = internal_optional) attrs + + +let constructor_descrs ty_path decl cstrs = + let ty_res = newgenconstr ty_path decl.type_params in + let num_consts = ref 0 and num_nonconsts = ref 0 and num_normal = ref 0 in + List.iter + (fun {cd_args; cd_res; _} -> + if cd_args = Cstr_tuple [] then incr num_consts else incr num_nonconsts; + if cd_res = None then incr num_normal) + cstrs; + let rec describe_constructors idx_const idx_nonconst = function + [] -> [] + | {cd_id; cd_args; cd_res; cd_loc; cd_attributes} :: rem -> + let ty_res = + match cd_res with + | Some ty_res' -> ty_res' + | None -> ty_res + in + let (tag, descr_rem) = + match cd_args with + | _ when decl.type_unboxed.unboxed -> + assert (rem = []); + (Cstr_unboxed, []) + | Cstr_tuple [] -> (Cstr_constant idx_const, + describe_constructors (idx_const+1) idx_nonconst rem) + | _ -> (Cstr_block idx_nonconst, + describe_constructors idx_const (idx_nonconst+1) rem) in + let cstr_name = Ident.name cd_id in + let existentials, cstr_args, cstr_inlined = + let representation = + if decl.type_unboxed.unboxed + then Record_unboxed true + else Record_inlined {tag = idx_nonconst; name = cstr_name; num_nonconsts = !num_nonconsts} + in + constructor_args decl.type_private cd_args cd_res + (Path.Pdot (ty_path, cstr_name, Path.nopos)) representation + in + let cstr = + { cstr_name; + cstr_res = ty_res; + cstr_existentials = existentials; + cstr_args; + cstr_arity = List.length cstr_args; + cstr_tag = tag; + cstr_consts = !num_consts; + cstr_nonconsts = !num_nonconsts; + cstr_normal = !num_normal; + cstr_private = decl.type_private; + cstr_generalized = cd_res <> None; + cstr_loc = cd_loc; + cstr_attributes = cd_attributes; + cstr_inlined; + } in + (cd_id, cstr) :: descr_rem in + let result = describe_constructors 0 0 cstrs in + match result with + | ( + [ ({Ident.name = "None"} as a_id, ({cstr_args = []} as a_descr) ) ; + ({Ident.name = "Some"} as b_id, ({ cstr_args = [_]} as b_descr)) + ] | + [ ({Ident.name = "Some"} as a_id, ({cstr_args = [_]} as a_descr) ) ; + ({Ident.name = "None"} as b_id, ({ cstr_args = []} as b_descr)) + ] + ) + -> + [ + (a_id, {a_descr with + cstr_attributes = + optional_shape :: a_descr.cstr_attributes}); + (b_id, {b_descr with + cstr_attributes = + optional_shape :: b_descr.cstr_attributes + }) + ] + | _ -> result + +let extension_descr path_ext ext = + let ty_res = + match ext.ext_ret_type with + Some type_ret -> type_ret + | None -> newgenconstr ext.ext_type_path ext.ext_type_params + in + let existentials, cstr_args, cstr_inlined = + constructor_args ext.ext_private ext.ext_args ext.ext_ret_type + path_ext Record_extension + in + { cstr_name = Path.last path_ext; + cstr_res = ty_res; + cstr_existentials = existentials; + cstr_args; + cstr_arity = List.length cstr_args; + cstr_tag = Cstr_extension(path_ext, cstr_args = []); + cstr_consts = -1; + cstr_nonconsts = -1; + cstr_private = ext.ext_private; + cstr_normal = -1; + cstr_generalized = ext.ext_ret_type <> None; + cstr_loc = ext.ext_loc; + cstr_attributes = ext.ext_attributes; + cstr_inlined; + } -val output_buffer : out_channel -> t -> unit -(** [output_buffer oc b] writes the current contents of buffer [b] - on the output channel [oc]. *) +let none = {desc = Ttuple []; level = -1; id = -1} + (* Clearly ill-formed type *) +let dummy_label = + { lbl_name = ""; lbl_res = none; lbl_arg = none; lbl_mut = Immutable; + lbl_pos = (-1); lbl_all = [||]; lbl_repres = Record_regular; + lbl_private = Public; + lbl_loc = Location.none; + lbl_attributes = []; + } -val digest : t -> Digest.t +let label_descrs ty_res lbls repres priv = + let all_labels = Array.make (List.length lbls) dummy_label in + let rec describe_labels num = function + [] -> [] + | l :: rest -> + let lbl = + { lbl_name = Ident.name l.ld_id; + lbl_res = ty_res; + lbl_arg = l.ld_type; + lbl_mut = l.ld_mutable; + lbl_pos = num; + lbl_all = all_labels; + lbl_repres = repres; + lbl_private = priv; + lbl_loc = l.ld_loc; + lbl_attributes = l.ld_attributes; + } in + all_labels.(num) <- lbl; + (l.ld_id, lbl) :: describe_labels (num+1) rest in + describe_labels 0 lbls -val not_equal : - t -> - string -> - bool +exception Constr_not_found -val add_int_1 : - t -> int -> unit +let rec find_constr tag num_const num_nonconst = function + [] -> + raise Constr_not_found + | {cd_args = Cstr_tuple []; _} as c :: rem -> + if tag = Cstr_constant num_const + then c + else find_constr tag (num_const + 1) num_nonconst rem + | c :: rem -> + if tag = Cstr_block num_nonconst || tag = Cstr_unboxed + then c + else find_constr tag num_const (num_nonconst + 1) rem -val add_int_2 : - t -> int -> unit +let find_constr_by_tag tag cstrlist = + find_constr tag 0 0 cstrlist -val add_int_3 : - t -> int -> unit +let constructors_of_type ty_path decl = + match decl.type_kind with + | Type_variant cstrs -> constructor_descrs ty_path decl cstrs + | Type_record _ | Type_abstract | Type_open -> [] -val add_int_4 : - t -> int -> unit +let labels_of_type ty_path decl = + match decl.type_kind with + | Type_record(labels, rep) -> + label_descrs (newgenconstr ty_path decl.type_params) + labels rep decl.type_private + | Type_variant _ | Type_abstract | Type_open -> [] -val add_string_char : - t -> - string -> - char -> - unit +(* Set row_name in Env, cf. GPR#1204/1329 *) +let set_row_name decl path = + match decl.type_manifest with + None -> () + | Some ty -> + let ty = repr ty in + match ty.desc with + Tvariant row when static_row row -> + let row = {(row_repr row) with + row_name = Some (path, decl.type_params)} in + ty.desc <- Tvariant row + | _ -> () -val add_char_string : - t -> - char -> - string -> - unit -end = struct -#1 "ext_buffer.ml" +end +module Predef : sig +#1 "predef.mli" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Pierre Weis and Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) (* *) -(* Copyright 1999 Institut National de Recherche en Informatique et *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -28349,1049 +12324,899 @@ end = struct (* *) (**************************************************************************) -(* Extensible buffers *) - -type t = - {mutable buffer : bytes; - mutable position : int; - mutable length : int; - initial_buffer : bytes} - -let create n = - let n = if n < 1 then 1 else n in - - let n = if n > Sys.max_string_length then Sys.max_string_length else n in - - let s = Bytes.create n in - {buffer = s; position = 0; length = n; initial_buffer = s} - -let contents b = Bytes.sub_string b.buffer 0 b.position -let to_bytes b = Bytes.sub b.buffer 0 b.position +(* Predefined type constructors (with special typing rules in typecore) *) -let sub b ofs len = - if ofs < 0 || len < 0 || ofs > b.position - len - then invalid_arg "Ext_buffer.sub" - else Bytes.sub_string b.buffer ofs len +open Types +val type_int: type_expr +val type_char: type_expr +val type_string: type_expr +val type_bytes: type_expr +val type_float: type_expr +val type_bool: type_expr +val type_unit: type_expr +val type_exn: type_expr +val type_array: type_expr -> type_expr +val type_list: type_expr -> type_expr +val type_option: type_expr -> type_expr +val type_nativeint: type_expr +val type_int32: type_expr +val type_int64: type_expr +val type_lazy_t: type_expr -> type_expr +val type_extension_constructor:type_expr +val type_floatarray:type_expr -let blit src srcoff dst dstoff len = - if len < 0 || srcoff < 0 || srcoff > src.position - len - || dstoff < 0 || dstoff > (Bytes.length dst) - len - then invalid_arg "Ext_buffer.blit" - else - Bytes.unsafe_blit src.buffer srcoff dst dstoff len +val path_int: Path.t +val path_char: Path.t +val path_string: Path.t +val path_bytes: Path.t +val path_float: Path.t +val path_bool: Path.t +val path_unit: Path.t +val path_exn: Path.t +val path_array: Path.t +val path_list: Path.t +val path_option: Path.t +val path_nativeint: Path.t +val path_int32: Path.t +val path_int64: Path.t +val path_lazy_t: Path.t +val path_extension_constructor: Path.t +val path_floatarray: Path.t -let length b = b.position -let is_empty b = b.position = 0 -let clear b = b.position <- 0 +val path_match_failure: Path.t +val path_assert_failure : Path.t +val path_undefined_recursive_module : Path.t -let reset b = - b.position <- 0; b.buffer <- b.initial_buffer; - b.length <- Bytes.length b.buffer +(* To build the initial environment. Since there is a nasty mutual + recursion between predef and env, we break it by parameterizing + over Env.t, Env.add_type and Env.add_extension. *) -let resize b more = - let len = b.length in - let new_len = ref len in - while b.position + more > !new_len do new_len := 2 * !new_len done; - - if !new_len > Sys.max_string_length then begin - if b.position + more <= Sys.max_string_length - then new_len := Sys.max_string_length - else failwith "Ext_buffer.add: cannot grow buffer" - end; - - let new_buffer = Bytes.create !new_len in - (* PR#6148: let's keep using [blit] rather than [unsafe_blit] in - this tricky function that is slow anyway. *) - Bytes.blit b.buffer 0 new_buffer 0 b.position; - b.buffer <- new_buffer; - b.length <- !new_len ; - assert (b.position + more <= b.length) +val build_initial_env: + (Ident.t -> type_declaration -> 'a -> 'a) -> + (Ident.t -> extension_constructor -> 'a -> 'a) -> + 'a -> 'a * 'a -let add_char b c = - let pos = b.position in - if pos >= b.length then resize b 1; - Bytes.unsafe_set b.buffer pos c; - b.position <- pos + 1 +(* To initialize linker tables *) -let add_substring b s offset len = - if offset < 0 || len < 0 || offset > String.length s - len - then invalid_arg "Ext_buffer.add_substring/add_subbytes"; - let new_position = b.position + len in - if new_position > b.length then resize b len; - Ext_bytes.unsafe_blit_string s offset b.buffer b.position len; - b.position <- new_position +val builtin_values: (string * Ident.t) list +val builtin_idents: (string * Ident.t) list +(** All predefined exceptions, exposed as [Ident.t] for flambda (for + building value approximations). + The [Ident.t] for division by zero is also exported explicitly + so flambda can generate code to raise it. *) +val ident_division_by_zero: Ident.t +val all_predef_exns : Ident.t list -let add_subbytes b s offset len = - add_substring b (Bytes.unsafe_to_string s) offset len +val type_is_builtin_path_but_option : Path.t -> bool -let add_string b s = - let len = String.length s in - let new_position = b.position + len in - if new_position > b.length then resize b len; - Ext_bytes.unsafe_blit_string s 0 b.buffer b.position len; - b.position <- new_position +end = struct +#1 "predef.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -(* TODO: micro-optimzie *) -let add_string_char b s c = - let s_len = String.length s in - let len = s_len + 1 in - let new_position = b.position + len in - if new_position > b.length then resize b len; - let b_buffer = b.buffer in - Ext_bytes.unsafe_blit_string s 0 b_buffer b.position s_len; - Bytes.unsafe_set b_buffer (new_position - 1) c; - b.position <- new_position +(* Predefined type constructors (with special typing rules in typecore) *) -let add_char_string b c s = - let s_len = String.length s in - let len = s_len + 1 in - let new_position = b.position + len in - if new_position > b.length then resize b len; - let b_buffer = b.buffer in - let b_position = b.position in - Bytes.unsafe_set b_buffer b_position c ; - Ext_bytes.unsafe_blit_string s 0 b_buffer (b_position + 1) s_len; - b.position <- new_position +open Path +open Types +open Btype +let builtin_idents = ref [] -let add_bytes b s = add_string b (Bytes.unsafe_to_string s) +let wrap create s = + let id = create s in + builtin_idents := (s, id) :: !builtin_idents; + id -let add_buffer b bs = - add_subbytes b bs.buffer 0 bs.position +let ident_create = wrap Ident.create +let ident_create_predef_exn = wrap Ident.create_predef_exn -let add_channel b ic len = - if len < 0 +let ident_int = ident_create "int" +and ident_char = ident_create "char" +and ident_bytes = ident_create "bytes" +and ident_float = ident_create "float" +and ident_bool = ident_create "bool" +and ident_unit = ident_create "unit" +and ident_exn = ident_create "exn" +and ident_array = ident_create "array" +and ident_list = ident_create "list" +and ident_option = ident_create "option" +and ident_nativeint = ident_create "nativeint" +and ident_int32 = ident_create "int32" +and ident_int64 = ident_create "int64" +and ident_lazy_t = ident_create "lazy_t" +and ident_string = ident_create "string" +and ident_extension_constructor = ident_create "extension_constructor" +and ident_floatarray = ident_create "floatarray" - || len > Sys.max_string_length +let type_is_builtin_path_but_option (p : Path.t) = + match p with + | Pident {Ident.stamp} -> + stamp >= ident_int.Ident.stamp + && stamp <= ident_floatarray.Ident.stamp + && (stamp <> ident_option.Ident.stamp) + | _ -> false - then (* PR#5004 *) - invalid_arg "Ext_buffer.add_channel"; - if b.position + len > b.length then resize b len; - really_input ic b.buffer b.position len; - b.position <- b.position + len +let path_int = Pident ident_int +and path_char = Pident ident_char +and path_bytes = Pident ident_bytes +and path_float = Pident ident_float +and path_bool = Pident ident_bool +and path_unit = Pident ident_unit +and path_exn = Pident ident_exn +and path_array = Pident ident_array +and path_list = Pident ident_list +and path_option = Pident ident_option +and path_nativeint = Pident ident_nativeint +and path_int32 = Pident ident_int32 +and path_int64 = Pident ident_int64 +and path_lazy_t = Pident ident_lazy_t +and path_string = Pident ident_string +and path_extension_constructor = Pident ident_extension_constructor +and path_floatarray = Pident ident_floatarray -let output_buffer oc b = - output oc b.buffer 0 b.position +let type_int = newgenty (Tconstr(path_int, [], ref Mnil)) +and type_char = newgenty (Tconstr(path_char, [], ref Mnil)) +and type_bytes = newgenty (Tconstr(path_bytes, [], ref Mnil)) +and type_float = newgenty (Tconstr(path_float, [], ref Mnil)) +and type_bool = newgenty (Tconstr(path_bool, [], ref Mnil)) +and type_unit = newgenty (Tconstr(path_unit, [], ref Mnil)) +and type_exn = newgenty (Tconstr(path_exn, [], ref Mnil)) +and type_array t = newgenty (Tconstr(path_array, [t], ref Mnil)) +and type_list t = newgenty (Tconstr(path_list, [t], ref Mnil)) +and type_option t = newgenty (Tconstr(path_option, [t], ref Mnil)) +and type_nativeint = newgenty (Tconstr(path_nativeint, [], ref Mnil)) +and type_int32 = newgenty (Tconstr(path_int32, [], ref Mnil)) +and type_int64 = newgenty (Tconstr(path_int64, [], ref Mnil)) +and type_lazy_t t = newgenty (Tconstr(path_lazy_t, [t], ref Mnil)) +and type_string = newgenty (Tconstr(path_string, [], ref Mnil)) +and type_extension_constructor = + newgenty (Tconstr(path_extension_constructor, [], ref Mnil)) +and type_floatarray = newgenty (Tconstr(path_floatarray, [], ref Mnil)) -external unsafe_string: bytes -> int -> int -> Digest.t = "caml_md5_string" +let ident_match_failure = ident_create_predef_exn "Match_failure" +and ident_out_of_memory = ident_create_predef_exn "Out_of_memory" +and ident_invalid_argument = ident_create_predef_exn "Invalid_argument" +and ident_failure = ident_create_predef_exn "Failure" +and ident_not_found = ident_create_predef_exn "Not_found" +and ident_sys_error = ident_create_predef_exn "Sys_error" +and ident_end_of_file = ident_create_predef_exn "End_of_file" +and ident_division_by_zero = ident_create_predef_exn "Division_by_zero" +and ident_stack_overflow = ident_create_predef_exn "Stack_overflow" +and ident_sys_blocked_io = ident_create_predef_exn "Sys_blocked_io" +and ident_assert_failure = ident_create_predef_exn "Assert_failure" +and ident_undefined_recursive_module = + ident_create_predef_exn "Undefined_recursive_module" -let digest b = - unsafe_string - b.buffer 0 b.position +let all_predef_exns = [ + ident_match_failure; + ident_out_of_memory; + ident_invalid_argument; + ident_failure; + ident_not_found; + ident_sys_error; + ident_end_of_file; + ident_division_by_zero; + ident_stack_overflow; + ident_sys_blocked_io; + ident_assert_failure; + ident_undefined_recursive_module; +] -let rec not_equal_aux (b : bytes) (s : string) i len = - if i >= len then false - else - (Bytes.unsafe_get b i - <> - String.unsafe_get s i ) - || not_equal_aux b s (i + 1) len +let path_match_failure = Pident ident_match_failure +and path_assert_failure = Pident ident_assert_failure +and path_undefined_recursive_module = Pident ident_undefined_recursive_module -(** avoid a large copy *) -let not_equal (b : t) (s : string) = - let b_len = b.position in - let s_len = String.length s in - b_len <> s_len - || not_equal_aux b.buffer s 0 s_len +let decl_abstr = + {type_params = []; + type_arity = 0; + type_kind = Type_abstract; + type_loc = Location.none; + type_private = Asttypes.Public; + type_manifest = None; + type_variance = []; + type_newtype_level = None; + type_attributes = []; + type_immediate = false; + type_unboxed = unboxed_false_default_false; + } +let decl_abstr_imm = {decl_abstr with type_immediate = true} -(** - It could be one byte, two bytes, three bytes and four bytes - TODO: inline for better performance -*) -let add_int_1 (b : t ) (x : int ) = - let c = (Char.unsafe_chr (x land 0xff)) in - let pos = b.position in - if pos >= b.length then resize b 1; - Bytes.unsafe_set b.buffer pos c; - b.position <- pos + 1 - -let add_int_2 (b : t ) (x : int ) = - let c1 = (Char.unsafe_chr (x land 0xff)) in - let c2 = (Char.unsafe_chr (x lsr 8 land 0xff)) in - let pos = b.position in - if pos + 1 >= b.length then resize b 2; - let b_buffer = b.buffer in - Bytes.unsafe_set b_buffer pos c1; - Bytes.unsafe_set b_buffer (pos + 1) c2; - b.position <- pos + 2 +let cstr id args = + { + cd_id = id; + cd_args = Cstr_tuple args; + cd_res = None; + cd_loc = Location.none; + cd_attributes = []; + } -let add_int_3 (b : t ) (x : int ) = - let c1 = (Char.unsafe_chr (x land 0xff)) in - let c2 = (Char.unsafe_chr (x lsr 8 land 0xff)) in - let c3 = (Char.unsafe_chr (x lsr 16 land 0xff)) in - let pos = b.position in - if pos + 2 >= b.length then resize b 3; - let b_buffer = b.buffer in - Bytes.unsafe_set b_buffer pos c1; - Bytes.unsafe_set b_buffer (pos + 1) c2; - Bytes.unsafe_set b_buffer (pos + 2) c3; - b.position <- pos + 3 +let ident_false = ident_create "false" +and ident_true = ident_create "true" +and ident_void = ident_create "()" +and ident_nil = ident_create "[]" +and ident_cons = ident_create "::" +and ident_none = ident_create "None" +and ident_some = ident_create "Some" +let common_initial_env add_type add_extension empty_env = + let decl_bool = + {decl_abstr with + type_kind = Type_variant([cstr ident_false []; cstr ident_true []]); + type_immediate = true} + and decl_unit = + {decl_abstr with + type_kind = Type_variant([cstr ident_void []]); + type_immediate = true} + and decl_exn = + {decl_abstr with + type_kind = Type_open} + and decl_array = + let tvar = newgenvar() in + {decl_abstr with + type_params = [tvar]; + type_arity = 1; + type_variance = [Variance.full]} + and decl_list = + let tvar = newgenvar() in + {decl_abstr with + type_params = [tvar]; + type_arity = 1; + type_kind = + Type_variant([cstr ident_nil []; cstr ident_cons [tvar; type_list tvar]]); + type_variance = [Variance.covariant]} + and decl_option = + let tvar = newgenvar() in + {decl_abstr with + type_params = [tvar]; + type_arity = 1; + type_kind = Type_variant([cstr ident_none []; cstr ident_some [tvar]]); + type_variance = [Variance.covariant]} + and decl_lazy_t = + let tvar = newgenvar() in + {decl_abstr with + type_params = [tvar]; + type_arity = 1; + type_variance = [Variance.covariant]} + in + let add_extension id l = + add_extension id + { ext_type_path = path_exn; + ext_type_params = []; + ext_args = Cstr_tuple l; + ext_ret_type = None; + ext_private = Asttypes.Public; + ext_loc = Location.none; + ext_attributes = [{Asttypes.txt="ocaml.warn_on_literal_pattern"; + loc=Location.none}, + Parsetree.PStr[]] } + in + add_extension ident_match_failure + [newgenty (Ttuple[type_string; type_int; type_int])] ( + add_extension ident_out_of_memory [] ( + add_extension ident_stack_overflow [] ( + add_extension ident_invalid_argument [type_string] ( + add_extension ident_failure [type_string] ( + add_extension ident_not_found [] ( + add_extension ident_sys_blocked_io [] ( + add_extension ident_sys_error [type_string] ( + add_extension ident_end_of_file [] ( + add_extension ident_division_by_zero [] ( + add_extension ident_assert_failure + [newgenty (Ttuple[type_string; type_int; type_int])] ( + add_extension ident_undefined_recursive_module + [newgenty (Ttuple[type_string; type_int; type_int])] ( + add_type ident_int64 decl_abstr ( + add_type ident_int32 decl_abstr ( + add_type ident_nativeint decl_abstr ( + add_type ident_lazy_t decl_lazy_t ( + add_type ident_option decl_option ( + add_type ident_list decl_list ( + add_type ident_array decl_array ( + add_type ident_exn decl_exn ( + add_type ident_unit decl_unit ( + add_type ident_bool decl_bool ( + add_type ident_float decl_abstr ( + add_type ident_string decl_abstr ( + add_type ident_char decl_abstr_imm ( + add_type ident_int decl_abstr_imm ( + add_type ident_extension_constructor decl_abstr ( + add_type ident_floatarray decl_abstr ( + empty_env)))))))))))))))))))))))))))) -let add_int_4 (b : t ) (x : int ) = - let c1 = (Char.unsafe_chr (x land 0xff)) in - let c2 = (Char.unsafe_chr (x lsr 8 land 0xff)) in - let c3 = (Char.unsafe_chr (x lsr 16 land 0xff)) in - let c4 = (Char.unsafe_chr (x lsr 24 land 0xff)) in - let pos = b.position in - if pos + 3 >= b.length then resize b 4; - let b_buffer = b.buffer in - Bytes.unsafe_set b_buffer pos c1; - Bytes.unsafe_set b_buffer (pos + 1) c2; - Bytes.unsafe_set b_buffer (pos + 2) c3; - Bytes.unsafe_set b_buffer (pos + 3) c4; - b.position <- pos + 4 +let build_initial_env add_type add_exception empty_env = + let common = common_initial_env add_type add_exception empty_env in + let safe_string = add_type ident_bytes decl_abstr common in + let decl_bytes_unsafe = {decl_abstr with type_manifest = Some type_string} in + let unsafe_string = add_type ident_bytes decl_bytes_unsafe common in + (safe_string, unsafe_string) +let builtin_values = + List.map (fun id -> Ident.make_global id; (Ident.name id, id)) + [ident_match_failure; ident_out_of_memory; ident_stack_overflow; + ident_invalid_argument; + ident_failure; ident_not_found; ident_sys_error; ident_end_of_file; + ident_division_by_zero; ident_sys_blocked_io; + ident_assert_failure; ident_undefined_recursive_module ] +(* Start non-predef identifiers at 1000. This way, more predefs can + be defined in this file (above!) without breaking .cmi + compatibility. *) +let _ = Ident.set_current_time 999 +let builtin_idents = List.rev !builtin_idents end -module Ext_char : sig -#1 "ext_char.mli" -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) - - +module Docstrings : sig +#1 "docstrings.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Leo White *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) +(** Documentation comments *) +(** (Re)Initialise all docstring state *) +val init : unit -> unit +(** Emit warnings for unattached and ambiguous docstrings *) +val warn_bad_docstrings : unit -> unit -(** Extension to Standard char module, avoid locale sensitivity *) +(** {2 Docstrings} *) -val escaped : char -> string +(** Documentation comments *) +type docstring +(** Create a docstring *) +val docstring : string -> Location.t -> docstring -val valid_hex : char -> bool +(** Register a docstring *) +val register : docstring -> unit -val is_lower_case : char -> bool +(** Get the text of a docstring *) +val docstring_body : docstring -> string -val uppercase_ascii : char -> char +(** Get the location of a docstring *) +val docstring_loc : docstring -> Location.t -val lowercase_ascii : char -> char -end = struct -#1 "ext_char.ml" -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +(** {2 Set functions} + These functions are used by the lexer to associate docstrings to + the locations of tokens. *) +(** Docstrings immediately preceding a token *) +val set_pre_docstrings : Lexing.position -> docstring list -> unit +(** Docstrings immediately following a token *) +val set_post_docstrings : Lexing.position -> docstring list -> unit +(** Docstrings not immediately adjacent to a token *) +val set_floating_docstrings : Lexing.position -> docstring list -> unit -(** {!Char.escaped} is locale sensitive in 4.02.3, fixed in the trunk, - backport it here - *) - -let escaped = Char.escaped +(** Docstrings immediately following the token which precedes this one *) +val set_pre_extra_docstrings : Lexing.position -> docstring list -> unit +(** Docstrings immediately preceding the token which follows this one *) +val set_post_extra_docstrings : Lexing.position -> docstring list -> unit -let valid_hex x = - match x with - | '0' .. '9' - | 'a' .. 'f' - | 'A' .. 'F' -> true - | _ -> false +(** {2 Items} + The {!docs} type represents documentation attached to an item. *) +type docs = + { docs_pre: docstring option; + docs_post: docstring option; } -let is_lower_case c = - (c >= 'a' && c <= 'z') - || (c >= '\224' && c <= '\246') - || (c >= '\248' && c <= '\254') -let uppercase_ascii = +val empty_docs : docs - Char.uppercase_ascii - +val docs_attr : docstring -> Parsetree.attribute -let lowercase_ascii = +(** Convert item documentation to attributes and add them to an + attribute list *) +val add_docs_attrs : docs -> Parsetree.attributes -> Parsetree.attributes - Char.lowercase_ascii - +(** Fetch the item documentation for the current symbol. This also + marks this documentation (for ambiguity warnings). *) +val symbol_docs : unit -> docs +val symbol_docs_lazy : unit -> docs Lazy.t -end -module Literals : sig -#1 "literals.mli" -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +(** Fetch the item documentation for the symbols between two + positions. This also marks this documentation (for ambiguity + warnings). *) +val rhs_docs : int -> int -> docs +val rhs_docs_lazy : int -> int -> docs Lazy.t +(** Mark the item documentation for the current symbol (for ambiguity + warnings). *) +val mark_symbol_docs : unit -> unit +(** Mark as associated the item documentation for the symbols between + two positions (for ambiguity warnings) *) +val mark_rhs_docs : int -> int -> unit +(** {2 Fields and constructors} + The {!info} type represents documentation attached to a field or + constructor. *) +type info = docstring option -val js_array_ctor : string -val js_type_number : string -val js_type_string : string -val js_type_object : string -val js_type_boolean : string -val js_undefined : string -val js_prop_length : string +val empty_info : info -val param : string -val partial_arg : string -val prim : string +val info_attr : docstring -> Parsetree.attribute -(**temporary varaible used in {!Js_ast_util} *) -val tmp : string +(** Convert field info to attributes and add them to an + attribute list *) +val add_info_attrs : info -> Parsetree.attributes -> Parsetree.attributes -val create : string -val runtime : string -val stdlib : string -val imul : string +(** Fetch the field info for the current symbol. *) +val symbol_info : unit -> info -val setter_suffix : string -val setter_suffix_len : int +(** Fetch the field info following the symbol at a given position. *) +val rhs_info : int -> info +(** {2 Unattached comments} -val debugger : string -val raw_expr : string -val raw_stmt : string -val raw_function : string -val unsafe_downgrade : string -val fn_run : string -val method_run : string -val fn_method : string -val fn_mk : string + The {!text} type represents documentation which is not attached to + anything. *) -(** callback actually, not exposed to user yet *) -(* val js_fn_runmethod : string *) +type text = docstring list -val bs_deriving : string -val bs_deriving_dot : string -val bs_type : string +val empty_text : text +val empty_text_lazy : text Lazy.t -(** nodejs *) +val text_attr : docstring -> Parsetree.attribute -val node_modules : string -val node_modules_length : int -val package_json : string -val bsconfig_json : string -val build_ninja : string +(** Convert text to attributes and add them to an attribute list *) +val add_text_attrs : text -> Parsetree.attributes -> Parsetree.attributes -(* Name of the library file created for each external dependency. *) -val library_file : string +(** Fetch the text preceding the current symbol. *) +val symbol_text : unit -> text +val symbol_text_lazy : unit -> text Lazy.t -val suffix_a : string -val suffix_cmj : string -val suffix_cmo : string -val suffix_cma : string -val suffix_cmi : string -val suffix_cmx : string -val suffix_cmxa : string -val suffix_ml : string -val suffix_mlast : string -val suffix_mlast_simple : string -val suffix_mliast : string -val suffix_reast : string -val suffix_reiast : string +(** Fetch the text preceding the symbol at the given position. *) +val rhs_text : int -> text +val rhs_text_lazy : int -> text Lazy.t -val suffix_mliast_simple : string -val suffix_mlmap : string -val suffix_mll : string -val suffix_re : string -val suffix_rei : string +(** {2 Extra text} -val suffix_d : string -val suffix_js : string -val suffix_bs_js : string -(* val suffix_re_js : string *) -val suffix_gen_js : string -val suffix_gen_tsx: string + There may be additional text attached to the delimiters of a block + (e.g. [struct] and [end]). This is fetched by the following + functions, which are applied to the contents of the block rather + than the delimiters. *) -val suffix_tsx : string +(** Fetch additional text preceding the current symbol *) +val symbol_pre_extra_text : unit -> text -val suffix_mli : string -val suffix_cmt : string -val suffix_cmti : string +(** Fetch additional text following the current symbol *) +val symbol_post_extra_text : unit -> text -val commonjs : string +(** Fetch additional text preceding the symbol at the given position *) +val rhs_pre_extra_text : int -> text -val es6 : string -val es6_global : string +(** Fetch additional text following the symbol at the given position *) +val rhs_post_extra_text : int -> text -val unused_attribute : string -val dash_nostdlib : string +end = struct +#1 "docstrings.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Leo White *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -val reactjs_jsx_ppx_2_exe : string -val reactjs_jsx_ppx_3_exe : string +open Location -val native : string -val bytecode : string -val js : string +(* Docstrings *) -val node_sep : string -val node_parent : string -val node_current : string -val gentype_import : string +(* A docstring is "attached" if it has been inserted in the AST. This + is used for generating unexpected docstring warnings. *) +type ds_attached = + | Unattached (* Not yet attached anything.*) + | Info (* Attached to a field or constructor. *) + | Docs (* Attached to an item or as floating text. *) -val bsbuild_cache : string +(* A docstring is "associated" with an item if there are no blank lines between + them. This is used for generating docstring ambiguity warnings. *) +type ds_associated = + | Zero (* Not associated with an item *) + | One (* Associated with one item *) + | Many (* Associated with multiple items (ambiguity) *) -val sourcedirs_meta : string -end = struct -#1 "literals.ml" -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +type docstring = + { ds_body: string; + ds_loc: Location.t; + mutable ds_attached: ds_attached; + mutable ds_associated: ds_associated; } +(* List of docstrings *) +let docstrings : docstring list ref = ref [] +(* Warn for unused and ambiguous docstrings *) +let warn_bad_docstrings () = + if Warnings.is_active (Warnings.Bad_docstring true) then begin + List.iter + (fun ds -> + match ds.ds_attached with + | Info -> () + | Unattached -> + prerr_warning ds.ds_loc (Warnings.Bad_docstring true) + | Docs -> + match ds.ds_associated with + | Zero | One -> () + | Many -> + prerr_warning ds.ds_loc (Warnings.Bad_docstring false)) + (List.rev !docstrings) +end +(* Docstring constructors and destructors *) +let docstring body loc = + let ds = + { ds_body = body; + ds_loc = loc; + ds_attached = Unattached; + ds_associated = Zero; } + in + ds -let js_array_ctor = "Array" -let js_type_number = "number" -let js_type_string = "string" -let js_type_object = "object" -let js_type_boolean = "boolean" -let js_undefined = "undefined" -let js_prop_length = "length" +let register ds = + docstrings := ds :: !docstrings -let prim = "prim" -let param = "param" -let partial_arg = "partial_arg" -let tmp = "tmp" +let docstring_body ds = ds.ds_body -let create = "create" (* {!Caml_exceptions.create}*) +let docstring_loc ds = ds.ds_loc -let runtime = "runtime" (* runtime directory *) +(* Docstrings attached to items *) -let stdlib = "stdlib" +type docs = + { docs_pre: docstring option; + docs_post: docstring option; } -let imul = "imul" (* signed int32 mul *) +let empty_docs = { docs_pre = None; docs_post = None } -let setter_suffix = "#=" -let setter_suffix_len = String.length setter_suffix +let doc_loc = {txt = "ocaml.doc"; loc = Location.none} -let debugger = "debugger" -let raw_expr = "raw_expr" -let raw_stmt = "raw_stmt" -let raw_function = "raw_function" -let unsafe_downgrade = "unsafe_downgrade" -let fn_run = "fn_run" -let method_run = "method_run" +let docs_attr ds = + let open Parsetree in + let exp = + { pexp_desc = Pexp_constant (Pconst_string(ds.ds_body, None)); + pexp_loc = ds.ds_loc; + pexp_attributes = []; } + in + let item = + { pstr_desc = Pstr_eval (exp, []); pstr_loc = exp.pexp_loc } + in + (doc_loc, PStr [item]) -let fn_method = "fn_method" -let fn_mk = "fn_mk" -(*let js_fn_runmethod = "js_fn_runmethod"*) +let add_docs_attrs docs attrs = + let attrs = + match docs.docs_pre with + | None | Some { ds_body=""; _ } -> attrs + | Some ds -> docs_attr ds :: attrs + in + let attrs = + match docs.docs_post with + | None | Some { ds_body=""; _ } -> attrs + | Some ds -> attrs @ [docs_attr ds] + in + attrs -let bs_deriving = "bs.deriving" -let bs_deriving_dot = "bs.deriving." -let bs_type = "bs.type" +(* Docstrings attached to constructors or fields *) +type info = docstring option -(** nodejs *) -let node_modules = "node_modules" -let node_modules_length = String.length "node_modules" -let package_json = "package.json" -let bsconfig_json = "bsconfig.json" -let build_ninja = "build.ninja" +let empty_info = None -(* Name of the library file created for each external dependency. *) -let library_file = "lib" +let info_attr = docs_attr -let suffix_a = ".a" -let suffix_cmj = ".cmj" -let suffix_cmo = ".cmo" -let suffix_cma = ".cma" -let suffix_cmi = ".cmi" -let suffix_cmx = ".cmx" -let suffix_cmxa = ".cmxa" -let suffix_mll = ".mll" -let suffix_ml = ".ml" -let suffix_mli = ".mli" -let suffix_re = ".re" -let suffix_rei = ".rei" -let suffix_mlmap = ".mlmap" +let add_info_attrs info attrs = + match info with + | None | Some {ds_body=""; _} -> attrs + | Some ds -> attrs @ [info_attr ds] -let suffix_cmt = ".cmt" -let suffix_cmti = ".cmti" -let suffix_mlast = ".mlast" -let suffix_mlast_simple = ".mlast_simple" -let suffix_mliast = ".mliast" -let suffix_reast = ".reast" -let suffix_reiast = ".reiast" -let suffix_mliast_simple = ".mliast_simple" -let suffix_d = ".d" -let suffix_js = ".js" -let suffix_bs_js = ".bs.js" -(* let suffix_re_js = ".re.js" *) -let suffix_gen_js = ".gen.js" -let suffix_gen_tsx = ".gen.tsx" -let suffix_tsx = ".tsx" +(* Docstrings not attached to a specific item *) -let commonjs = "commonjs" +type text = docstring list -let es6 = "es6" -let es6_global = "es6-global" +let empty_text = [] +let empty_text_lazy = lazy [] -let unused_attribute = "Unused attribute " -let dash_nostdlib = "-nostdlib" +let text_loc = {txt = "ocaml.text"; loc = Location.none} -let reactjs_jsx_ppx_2_exe = "reactjs_jsx_ppx_2.exe" -let reactjs_jsx_ppx_3_exe = "reactjs_jsx_ppx_3.exe" +let text_attr ds = + let open Parsetree in + let exp = + { pexp_desc = Pexp_constant (Pconst_string(ds.ds_body, None)); + pexp_loc = ds.ds_loc; + pexp_attributes = []; } + in + let item = + { pstr_desc = Pstr_eval (exp, []); pstr_loc = exp.pexp_loc } + in + (text_loc, PStr [item]) -let native = "native" -let bytecode = "bytecode" -let js = "js" +let add_text_attrs dsl attrs = + let fdsl = List.filter (function {ds_body=""} -> false| _ ->true) dsl in + (List.map text_attr fdsl) @ attrs +(* Find the first non-info docstring in a list, attach it and return it *) +let get_docstring ~info dsl = + let rec loop = function + | [] -> None + | {ds_attached = Info; _} :: rest -> loop rest + | ds :: _ -> + ds.ds_attached <- if info then Info else Docs; + Some ds + in + loop dsl +(* Find all the non-info docstrings in a list, attach them and return them *) +let get_docstrings dsl = + let rec loop acc = function + | [] -> List.rev acc + | {ds_attached = Info; _} :: rest -> loop acc rest + | ds :: rest -> + ds.ds_attached <- Docs; + loop (ds :: acc) rest + in + loop [] dsl -(** Used when produce node compatible paths *) -let node_sep = "/" -let node_parent = ".." -let node_current = "." +(* "Associate" all the docstrings in a list *) +let associate_docstrings dsl = + List.iter + (fun ds -> + match ds.ds_associated with + | Zero -> ds.ds_associated <- One + | (One | Many) -> ds.ds_associated <- Many) + dsl -let gentype_import = "genType.import" +(* Map from positions to pre docstrings *) -let bsbuild_cache = ".bsbuild" +let pre_table : (Lexing.position, docstring list) Hashtbl.t = + Hashtbl.create 50 -let sourcedirs_meta = ".sourcedirs.json" -end -module Ext_namespace : sig -#1 "ext_namespace.mli" -(* Copyright (C) 2017- Authors of BuckleScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +let set_pre_docstrings pos dsl = + if dsl <> [] then Hashtbl.add pre_table pos dsl -(** [make ~ns:"Ns" "a" ] - A typical example would return "a-Ns" - Note the namespace comes from the output of [namespace_of_package_name] -*) -val make : - ?ns:string -> string -> string +let get_pre_docs pos = + try + let dsl = Hashtbl.find pre_table pos in + associate_docstrings dsl; + get_docstring ~info:false dsl + with Not_found -> None -val try_split_module_name : - string -> (string * string ) option +let mark_pre_docs pos = + try + let dsl = Hashtbl.find pre_table pos in + associate_docstrings dsl + with Not_found -> () +(* Map from positions to post docstrings *) +let post_table : (Lexing.position, docstring list) Hashtbl.t = + Hashtbl.create 50 -(* Note we have to output uncapitalized file Name, - or at least be consistent, since by reading cmi file on Case insensitive OS, we don't really know it is `list.cmi` or `List.cmi`, so that `require (./list.js)` or `require(./List.js)` - relevant issues: #1609, #913 +let set_post_docstrings pos dsl = + if dsl <> [] then Hashtbl.add post_table pos dsl - #1933 when removing ns suffix, don't pass the bound - of basename -*) -val change_ext_ns_suffix : - string -> - string -> - string +let get_post_docs pos = + try + let dsl = Hashtbl.find post_table pos in + associate_docstrings dsl; + get_docstring ~info:false dsl + with Not_found -> None -type file_kind = - | Upper_js - | Upper_bs - | Little_js - | Little_bs - (** [js_name_of_modulename ~little A-Ns] - *) -val js_name_of_modulename : - string -> - file_kind -> - string +let mark_post_docs pos = + try + let dsl = Hashtbl.find post_table pos in + associate_docstrings dsl + with Not_found -> () -(* TODO handle cases like - '@angular/core' - its directory structure is like - {[ - @angular - |-------- core - ]} -*) -val is_valid_npm_package_name : string -> bool +let get_info pos = + try + let dsl = Hashtbl.find post_table pos in + get_docstring ~info:true dsl + with Not_found -> None -val namespace_of_package_name : string -> string +(* Map from positions to floating docstrings *) -end = struct -#1 "ext_namespace.ml" +let floating_table : (Lexing.position, docstring list) Hashtbl.t = + Hashtbl.create 50 -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +let set_floating_docstrings pos dsl = + if dsl <> [] then Hashtbl.add floating_table pos dsl +let get_text pos = + try + let dsl = Hashtbl.find floating_table pos in + get_docstrings dsl + with Not_found -> [] -(* Note the build system should check the validity of filenames - espeically, it should not contain '-' -*) -let ns_sep_char = '-' -let ns_sep = "-" +(* Maps from positions to extra docstrings *) -let make ?ns cunit = - match ns with - | None -> cunit - | Some ns -> cunit ^ ns_sep ^ ns +let pre_extra_table : (Lexing.position, docstring list) Hashtbl.t = + Hashtbl.create 50 +let set_pre_extra_docstrings pos dsl = + if dsl <> [] then Hashtbl.add pre_extra_table pos dsl -let rec rindex_rec s i = - if i < 0 then i else - let char = String.unsafe_get s i in - if Ext_filename.is_dir_sep char then -1 - else if char = ns_sep_char then i - else - rindex_rec s (i - 1) +let get_pre_extra_text pos = + try + let dsl = Hashtbl.find pre_extra_table pos in + get_docstrings dsl + with Not_found -> [] -let change_ext_ns_suffix name ext = - let i = rindex_rec name (String.length name - 1) in - if i < 0 then name ^ ext - else String.sub name 0 i ^ ext (* FIXME: micro-optimizaiton*) +let post_extra_table : (Lexing.position, docstring list) Hashtbl.t = + Hashtbl.create 50 -let try_split_module_name name = - let len = String.length name in - let i = rindex_rec name (len - 1) in - if i < 0 then None - else - Some (String.sub name (i+1) (len - i - 1), - String.sub name 0 i ) -type file_kind = - | Upper_js - | Upper_bs - | Little_js - | Little_bs +let set_post_extra_docstrings pos dsl = + if dsl <> [] then Hashtbl.add post_extra_table pos dsl +let get_post_extra_text pos = + try + let dsl = Hashtbl.find post_extra_table pos in + get_docstrings dsl + with Not_found -> [] - -(* let js_name_of_basename bs_suffix s = - change_ext_ns_suffix s - (if bs_suffix then Literals.suffix_bs_js else Literals.suffix_js ) *) +(* Docstrings from parser actions *) -let js_name_of_modulename s little = - match little with - | Little_js -> - change_ext_ns_suffix (Ext_string.uncapitalize_ascii s) Literals.suffix_js - | Little_bs -> - change_ext_ns_suffix (Ext_string.uncapitalize_ascii s) Literals.suffix_bs_js - | Upper_js -> - change_ext_ns_suffix s Literals.suffix_js - | Upper_bs -> - change_ext_ns_suffix s Literals.suffix_bs_js +let symbol_docs () = + { docs_pre = get_pre_docs (Parsing.symbol_start_pos ()); + docs_post = get_post_docs (Parsing.symbol_end_pos ()); } -(* https://docs.npmjs.com/files/package.json - Some rules: - The name must be less than or equal to 214 characters. This includes the scope for scoped packages. - The name can't start with a dot or an underscore. - New packages must not have uppercase letters in the name. - The name ends up being part of a URL, an argument on the command line, and a folder name. Therefore, the name can't contain any non-URL-safe characters. -*) -let is_valid_npm_package_name (s : string) = - let len = String.length s in - len <= 214 && (* magic number forced by npm *) - len > 0 && - match String.unsafe_get s 0 with - | 'a' .. 'z' | '@' -> - Ext_string.for_all_from s 1 - (fun x -> - match x with - | 'a'..'z' | '0'..'9' | '_' | '-' -> true - | _ -> false ) - | _ -> false +let symbol_docs_lazy () = + let p1 = Parsing.symbol_start_pos () in + let p2 = Parsing.symbol_end_pos () in + lazy { docs_pre = get_pre_docs p1; + docs_post = get_post_docs p2; } +let rhs_docs pos1 pos2 = + { docs_pre = get_pre_docs (Parsing.rhs_start_pos pos1); + docs_post = get_post_docs (Parsing.rhs_end_pos pos2); } -let namespace_of_package_name (s : string) : string = - let len = String.length s in - let buf = Ext_buffer.create len in - let add capital ch = - Ext_buffer.add_char buf - (if capital then - (Ext_char.uppercase_ascii ch) - else ch) in - let rec aux capital off len = - if off >= len then () - else - let ch = String.unsafe_get s off in - match ch with - | 'a' .. 'z' - | 'A' .. 'Z' - | '0' .. '9' - -> - add capital ch ; - aux false (off + 1) len - | '/' - | '-' -> - aux true (off + 1) len - | _ -> aux capital (off+1) len - in - aux true 0 len ; - Ext_buffer.contents buf +let rhs_docs_lazy pos1 pos2 = + let p1 = Parsing.rhs_start_pos pos1 in + let p2 = Parsing.rhs_end_pos pos2 in + lazy { docs_pre = get_pre_docs p1; + docs_post = get_post_docs p2; } -end -module Outcome_printer_ns : sig -#1 "outcome_printer_ns.mli" -(* Copyright (C) 2017 Authors of BuckleScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +let mark_symbol_docs () = + mark_pre_docs (Parsing.symbol_start_pos ()); + mark_post_docs (Parsing.symbol_end_pos ()) -(** This funciton is used to - reverse namespace printing to - avoid namespace leaking -*) - val out_ident : - Format.formatter -> string -> unit -end = struct -#1 "outcome_printer_ns.ml" -(* Copyright (C) 2017 Authors of BuckleScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +let mark_rhs_docs pos1 pos2 = + mark_pre_docs (Parsing.rhs_start_pos pos1); + mark_post_docs (Parsing.rhs_end_pos pos2) -let ps = Format.pp_print_string +let symbol_info () = + get_info (Parsing.symbol_end_pos ()) -let out_ident ppf s = - ps ppf ( - match s with - | "Js_null" - -> "Js.Null" - | "Js_undefined" - -> "Js.Undefined" - | "Js_null_undefined" - -> "Js.Nullable" - | "Js_exn" - -> "Js.Exn" - | "Js_array" - -> "Js.Array" - | "Js_string" - -> "Js.String" - | "Js_re" - -> "Js.Re" - | "Js_promise" - -> "Js.Promise" - | "Js_date" - -> "Js.Date" - | "Js_dict" - -> "Js.Dict" - | "Js_global" - -> "Js.Global" - | "Js_json" - -> "Js.Json" - | "Js_math" - -> "Js.Math" - | "Js_obj" - -> "Js.Obj" - | "Js_typed_array" - -> "Js.Typed_array" - | "Js_types" - -> "Js.Types" - | "Js_float" - -> "Js.Float" - | "Js_int" - -> "Js.Int" - | "Js_option" - -> "Js.Option" - | "Js_result" - -> "Js.Result" - |"Js_list" - -> "Js.List" - | "Js_vector" - -> "Js.Vector" -(* Belt_libs *) - | "Belt_Id" -> "Belt.Id" - | "Belt_Array" -> "Belt.Array" +let rhs_info pos = + get_info (Parsing.rhs_end_pos pos) - | "Belt_SortArray" -> "Belt.SortArray" - | "Belt_SortArrayInt" -> "Belt.SortArray.Int" - | "Belt_SortArrayString" -> "Belt.SortArray.String" - - | "Belt_MutableQueue" -> "Belt.MutableQueue" - | "Belt_MutableStack" -> "Belt.MutableStack" - | "Belt_List" -> "Belt.List" - | "Belt_Range" -> "Belt.Range" - - | "Belt_Set" -> "Belt.Set" - | "Belt_SetInt" -> "Belt.Set.Int" - | "Belt_SetString" -> "Belt.Set.String" +let symbol_text () = + get_text (Parsing.symbol_start_pos ()) - | "Belt_Map" -> "Belt.Map" - | "Belt_MapInt" -> "Belt.Map.Int" - | "Belt_MapString" -> "Belt.Map.String" +let symbol_text_lazy () = + let pos = Parsing.symbol_start_pos () in + lazy (get_text pos) + +let rhs_text pos = + get_text (Parsing.rhs_start_pos pos) - | "Belt_Option" -> "Belt.Option" +let rhs_text_lazy pos = + let pos = Parsing.rhs_start_pos pos in + lazy (get_text pos) - | "Belt_MutableSet" -> "Belt.MutableSet" - | "Belt_MutableSetInt" -> "Belt.MutableSet.Int" - | "Belt_MutableSetString" -> "Belt.MutableSet.String" +let symbol_pre_extra_text () = + get_pre_extra_text (Parsing.symbol_start_pos ()) - | "Belt_MutableMap" -> "Belt.MutableMap" - | "Belt_MutableMapInt" -> "Belt.MutableMap.Int" - | "Belt_MutableMapString" -> "Belt.MutableMap.String" - - | "Belt_HashSet" -> "Belt.HashSet" - | "Belt_HashSetInt" -> "Belt.HashSet.Int" - | "Belt_HashSetString" -> "Belt.HashSet.String" - - | "Belt_HashMap" -> "Belt.HashMap" - | "Belt_HashMapString" -> "Belt.HashMap.String" - | "Belt_HashMapInt" -> "Belt.HashMap.Int" - | "Belt_Debug" -> "Belt.Debug" - | s -> - (match Ext_namespace.try_split_module_name s with - | None -> s - | Some (ns,m) - -> ns ^ "."^ m - ) - ) +let symbol_post_extra_text () = + get_post_extra_text (Parsing.symbol_end_pos ()) +let rhs_pre_extra_text pos = + get_pre_extra_text (Parsing.rhs_start_pos pos) +let rhs_post_extra_text pos = + get_post_extra_text (Parsing.rhs_end_pos pos) -end -module Bs_conditional_initial : sig -#1 "bs_conditional_initial.mli" -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -(** This function set up built in compile time variables used in - conditional compilation so that - {[ - #if BS then - #elif .. then - #end - ]} - Is understood, also make sure the playground do the same initialization. -*) -val setup_env : unit -> unit +(* (Re)Initialise all comment state *) +let init () = + docstrings := []; + Hashtbl.reset pre_table; + Hashtbl.reset post_table; + Hashtbl.reset floating_table; + Hashtbl.reset pre_extra_table; + Hashtbl.reset post_extra_table -end = struct -#1 "bs_conditional_initial.ml" -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +end +module Syntaxerr : sig +#1 "syntaxerr.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1997 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) +(** Auxiliary type for reporting syntax errors *) -let setup_env () = - Clflags.compile_only := true; - Clflags.bs_only := true; - Clflags.no_implicit_current_dir := true; - (* default true - otherwise [bsc -I sc src/hello.ml ] will include current directory to search path - *) - Clflags.assume_no_mli := Clflags.Mli_non_exists; - Clflags.unsafe_string := false; - Clflags.debug := true; - Clflags.record_event_when_debug := false; - Clflags.binary_annotations := true; - (* Turn on [-no-alias-deps] by default -- double check *) - Oprint.out_ident := Outcome_printer_ns.out_ident; +open Format + +type error = + Unclosed of Location.t * string * Location.t * string + | Expecting of Location.t * string + | Not_expecting of Location.t * string + | Applicative_path of Location.t + | Variable_in_scope of Location.t * string + | Other of Location.t + | Ill_formed_ast of Location.t * string + | Invalid_package_type of Location.t * string +exception Error of error +exception Escape_error - Lexer.replace_directive_bool "BS" true; - Lexer.replace_directive_string "BS_VERSION" Bs_version.version - +val report_error: formatter -> error -> unit + (** @deprecated Use {!Location.error_of_exn}, {!Location.report_error}. *) +val location_of_error: error -> Location.t +val ill_formed_ast: Location.t -> string -> 'a -end -module Ident : sig -#1 "ident.mli" +end = struct +#1 "syntaxerr.ml" (**************************************************************************) (* *) (* OCaml *) (* *) (* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) (* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* Copyright 1997 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -29400,74 +13225,89 @@ module Ident : sig (* *) (**************************************************************************) -(* Identifiers (unique names) *) - -type t = { stamp: int; name: string; mutable flags: int } +(* Auxiliary type for reporting syntax errors *) -include Identifiable.S with type t := t -(* Notes: - - [equal] compares identifiers by name - - [compare x y] is 0 if [same x y] is true. - - [compare] compares identifiers by binding location -*) +type error = + Unclosed of Location.t * string * Location.t * string + | Expecting of Location.t * string + | Not_expecting of Location.t * string + | Applicative_path of Location.t + | Variable_in_scope of Location.t * string + | Other of Location.t + | Ill_formed_ast of Location.t * string + | Invalid_package_type of Location.t * string +exception Error of error +exception Escape_error -val create: string -> t -val create_persistent: string -> t -val create_predef_exn: string -> t -val rename: t -> t -val name: t -> string -val unique_name: t -> string -val unique_toplevel_name: t -> string -val persistent: t -> bool -val same: t -> t -> bool - (* Compare identifiers by binding location. - Two identifiers are the same either if they are both - non-persistent and have been created by the same call to - [new], or if they are both persistent and have the same - name. *) -val compare: t -> t -> int -val hide: t -> t - (* Return an identifier with same name as the given identifier, - but stamp different from any stamp returned by new. - When put in a 'a tbl, this identifier can only be looked - up by name. *) +let prepare_error = function + | Unclosed(opening_loc, opening, closing_loc, closing) -> + Location.errorf ~loc:closing_loc + ~sub:[ + Location.errorf ~loc:opening_loc + "This '%s' might be unmatched" opening + ] + ~if_highlight: + (Printf.sprintf "Syntax error: '%s' expected, \ + the highlighted '%s' might be unmatched" + closing opening) + "Syntax error: '%s' expected" closing -val make_global: t -> unit -val global: t -> bool -val is_predef_exn: t -> bool + | Expecting (loc, nonterm) -> + Location.errorf ~loc "Syntax error: %s expected." nonterm + | Not_expecting (loc, nonterm) -> + Location.errorf ~loc "Syntax error: %s not expected." nonterm + | Applicative_path loc -> + Location.errorf ~loc + "Syntax error: applicative paths of the form F(X).t \ + are not supported when the option -no-app-func is set." + | Variable_in_scope (loc, var) -> + Location.errorf ~loc + "In this scoped type, variable '%s \ + is reserved for the local type %s." + var var + | Other loc -> + Location.errorf ~loc "Syntax error" + | Ill_formed_ast (loc, s) -> + Location.errorf ~loc "broken invariant in parsetree: %s" s + | Invalid_package_type (loc, s) -> + Location.errorf ~loc "invalid package type: %s" s -val binding_time: t -> int -val current_time: unit -> int -val set_current_time: int -> unit -val reinit: unit -> unit +let () = + Location.register_error_of_exn + (function + | Error err -> Some (prepare_error err) + | _ -> None + ) -type 'a tbl - (* Association tables from identifiers to type 'a. *) -val empty: 'a tbl -val add: t -> 'a -> 'a tbl -> 'a tbl -val find_same: t -> 'a tbl -> 'a -val find_name: string -> 'a tbl -> t * 'a -val find_all: string -> 'a tbl -> (t * 'a) list -val fold_name: (t -> 'a -> 'b -> 'b) -> 'a tbl -> 'b -> 'b -val fold_all: (t -> 'a -> 'b -> 'b) -> 'a tbl -> 'b -> 'b -val iter: (t -> 'a -> unit) -> 'a tbl -> unit +let report_error ppf err = + Location.report_error ppf (prepare_error err) +let location_of_error = function + | Unclosed(l,_,_,_) + | Applicative_path l + | Variable_in_scope(l,_) + | Other l + | Not_expecting (l, _) + | Ill_formed_ast (l, _) + | Invalid_package_type (l, _) + | Expecting (l, _) -> l -(* Idents for sharing keys *) -val make_key_generator : unit -> (t -> t) +let ill_formed_ast loc s = + raise (Error (Ill_formed_ast (loc, s))) -end = struct -#1 "ident.ml" +end +module Ast_helper : sig +#1 "ast_helper.mli" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* Alain Frisch, LexiFi *) (* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* Copyright 2012 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -29476,251 +13316,443 @@ end = struct (* *) (**************************************************************************) -open Format +(** Helpers to produce Parsetree fragments *) -type t = { stamp: int; name: string; mutable flags: int } +open Asttypes +open Docstrings +open Parsetree -let global_flag = 1 -let predef_exn_flag = 2 +type lid = Longident.t loc +type str = string loc +type loc = Location.t +type attrs = attribute list -(* A stamp of 0 denotes a persistent identifier *) +(** {1 Default locations} *) -let currentstamp = ref 0 +val default_loc: loc ref + (** Default value for all optional location arguments. *) -let create s = - incr currentstamp; - { name = s; stamp = !currentstamp; flags = 0 } +val with_default_loc: loc -> (unit -> 'a) -> 'a + (** Set the [default_loc] within the scope of the execution + of the provided function. *) -let create_predef_exn s = - incr currentstamp; - { name = s; stamp = !currentstamp; flags = predef_exn_flag } +(** {1 Constants} *) -let create_persistent s = - { name = s; stamp = 0; flags = global_flag } +module Const : sig + val char : char -> constant + val string : ?quotation_delimiter:string -> string -> constant + val integer : ?suffix:char -> string -> constant + val int : ?suffix:char -> int -> constant + val int32 : ?suffix:char -> int32 -> constant + val int64 : ?suffix:char -> int64 -> constant + val nativeint : ?suffix:char -> nativeint -> constant + val float : ?suffix:char -> string -> constant +end -let rename i = - incr currentstamp; - { i with stamp = !currentstamp } +(** {1 Core language} *) -let name i = i.name +(** Type expressions *) +module Typ : + sig + val mk: ?loc:loc -> ?attrs:attrs -> core_type_desc -> core_type + val attr: core_type -> attribute -> core_type -let unique_name i = i.name ^ "_" ^ string_of_int i.stamp + val any: ?loc:loc -> ?attrs:attrs -> unit -> core_type + val var: ?loc:loc -> ?attrs:attrs -> string -> core_type + val arrow: ?loc:loc -> ?attrs:attrs -> arg_label -> core_type -> core_type + -> core_type + val tuple: ?loc:loc -> ?attrs:attrs -> core_type list -> core_type + val constr: ?loc:loc -> ?attrs:attrs -> lid -> core_type list -> core_type + val object_: ?loc:loc -> ?attrs:attrs -> object_field list + -> closed_flag -> core_type + val class_: ?loc:loc -> ?attrs:attrs -> lid -> core_type list -> core_type + val alias: ?loc:loc -> ?attrs:attrs -> core_type -> string -> core_type + val variant: ?loc:loc -> ?attrs:attrs -> row_field list -> closed_flag + -> label list option -> core_type + val poly: ?loc:loc -> ?attrs:attrs -> str list -> core_type -> core_type + val package: ?loc:loc -> ?attrs:attrs -> lid -> (lid * core_type) list + -> core_type + val extension: ?loc:loc -> ?attrs:attrs -> extension -> core_type -let unique_toplevel_name i = i.name ^ "/" ^ string_of_int i.stamp + val force_poly: core_type -> core_type -let persistent i = (i.stamp = 0) + val varify_constructors: str list -> core_type -> core_type + (** [varify_constructors newtypes te] is type expression [te], of which + any of nullary type constructor [tc] is replaced by type variable of + the same name, if [tc]'s name appears in [newtypes]. + Raise [Syntaxerr.Variable_in_scope] if any type variable inside [te] + appears in [newtypes]. + @since 4.05 + *) + end -let equal i1 i2 = i1.name = i2.name +(** Patterns *) +module Pat: + sig + val mk: ?loc:loc -> ?attrs:attrs -> pattern_desc -> pattern + val attr:pattern -> attribute -> pattern -let same i1 i2 = i1 = i2 - (* Possibly more efficient version (with a real compiler, at least): - if i1.stamp <> 0 - then i1.stamp = i2.stamp - else i2.stamp = 0 && i1.name = i2.name *) + val any: ?loc:loc -> ?attrs:attrs -> unit -> pattern + val var: ?loc:loc -> ?attrs:attrs -> str -> pattern + val alias: ?loc:loc -> ?attrs:attrs -> pattern -> str -> pattern + val constant: ?loc:loc -> ?attrs:attrs -> constant -> pattern + val interval: ?loc:loc -> ?attrs:attrs -> constant -> constant -> pattern + val tuple: ?loc:loc -> ?attrs:attrs -> pattern list -> pattern + val construct: ?loc:loc -> ?attrs:attrs -> lid -> pattern option -> pattern + val variant: ?loc:loc -> ?attrs:attrs -> label -> pattern option -> pattern + val record: ?loc:loc -> ?attrs:attrs -> (lid * pattern) list -> closed_flag + -> pattern + val array: ?loc:loc -> ?attrs:attrs -> pattern list -> pattern + val or_: ?loc:loc -> ?attrs:attrs -> pattern -> pattern -> pattern + val constraint_: ?loc:loc -> ?attrs:attrs -> pattern -> core_type -> pattern + val type_: ?loc:loc -> ?attrs:attrs -> lid -> pattern + val lazy_: ?loc:loc -> ?attrs:attrs -> pattern -> pattern + val unpack: ?loc:loc -> ?attrs:attrs -> str -> pattern + val open_: ?loc:loc -> ?attrs:attrs -> lid -> pattern -> pattern + val exception_: ?loc:loc -> ?attrs:attrs -> pattern -> pattern + val extension: ?loc:loc -> ?attrs:attrs -> extension -> pattern + end -let compare i1 i2 = Pervasives.compare i1 i2 +(** Expressions *) +module Exp: + sig + val mk: ?loc:loc -> ?attrs:attrs -> expression_desc -> expression + val attr: expression -> attribute -> expression -let binding_time i = i.stamp + val ident: ?loc:loc -> ?attrs:attrs -> lid -> expression + val constant: ?loc:loc -> ?attrs:attrs -> constant -> expression + val let_: ?loc:loc -> ?attrs:attrs -> rec_flag -> value_binding list + -> expression -> expression + val fun_: ?loc:loc -> ?attrs:attrs -> arg_label -> expression option + -> pattern -> expression -> expression + val function_: ?loc:loc -> ?attrs:attrs -> case list -> expression + val apply: ?loc:loc -> ?attrs:attrs -> expression + -> (arg_label * expression) list -> expression + val match_: ?loc:loc -> ?attrs:attrs -> expression -> case list + -> expression + val try_: ?loc:loc -> ?attrs:attrs -> expression -> case list -> expression + val tuple: ?loc:loc -> ?attrs:attrs -> expression list -> expression + val construct: ?loc:loc -> ?attrs:attrs -> lid -> expression option + -> expression + val variant: ?loc:loc -> ?attrs:attrs -> label -> expression option + -> expression + val record: ?loc:loc -> ?attrs:attrs -> (lid * expression) list + -> expression option -> expression + val field: ?loc:loc -> ?attrs:attrs -> expression -> lid -> expression + val setfield: ?loc:loc -> ?attrs:attrs -> expression -> lid -> expression + -> expression + val array: ?loc:loc -> ?attrs:attrs -> expression list -> expression + val ifthenelse: ?loc:loc -> ?attrs:attrs -> expression -> expression + -> expression option -> expression + val sequence: ?loc:loc -> ?attrs:attrs -> expression -> expression + -> expression + val while_: ?loc:loc -> ?attrs:attrs -> expression -> expression + -> expression + val for_: ?loc:loc -> ?attrs:attrs -> pattern -> expression -> expression + -> direction_flag -> expression -> expression + val coerce: ?loc:loc -> ?attrs:attrs -> expression -> core_type option + -> core_type -> expression + val constraint_: ?loc:loc -> ?attrs:attrs -> expression -> core_type + -> expression + val send: ?loc:loc -> ?attrs:attrs -> expression -> str -> expression + val new_: ?loc:loc -> ?attrs:attrs -> lid -> expression + val setinstvar: ?loc:loc -> ?attrs:attrs -> str -> expression -> expression + val override: ?loc:loc -> ?attrs:attrs -> (str * expression) list + -> expression + val letmodule: ?loc:loc -> ?attrs:attrs -> str -> module_expr -> expression + -> expression + val letexception: + ?loc:loc -> ?attrs:attrs -> extension_constructor -> expression + -> expression + val assert_: ?loc:loc -> ?attrs:attrs -> expression -> expression + val lazy_: ?loc:loc -> ?attrs:attrs -> expression -> expression + val poly: ?loc:loc -> ?attrs:attrs -> expression -> core_type option + -> expression + val object_: ?loc:loc -> ?attrs:attrs -> class_structure -> expression + val newtype: ?loc:loc -> ?attrs:attrs -> str -> expression -> expression + val pack: ?loc:loc -> ?attrs:attrs -> module_expr -> expression + val open_: ?loc:loc -> ?attrs:attrs -> override_flag -> lid -> expression + -> expression + val extension: ?loc:loc -> ?attrs:attrs -> extension -> expression + val unreachable: ?loc:loc -> ?attrs:attrs -> unit -> expression -let current_time() = !currentstamp -let set_current_time t = currentstamp := max !currentstamp t + val case: pattern -> ?guard:expression -> expression -> case + end -let reinit_level = ref (-1) +(** Value declarations *) +module Val: + sig + val mk: ?loc:loc -> ?attrs:attrs -> ?docs:docs -> + ?prim:string list -> str -> core_type -> value_description + end -let reinit () = - if !reinit_level < 0 - then reinit_level := !currentstamp - else currentstamp := !reinit_level +(** Type declarations *) +module Type: + sig + val mk: ?loc:loc -> ?attrs:attrs -> ?docs:docs -> ?text:text -> + ?params:(core_type * variance) list -> + ?cstrs:(core_type * core_type * loc) list -> + ?kind:type_kind -> ?priv:private_flag -> ?manifest:core_type -> str -> + type_declaration -let hide i = - { i with stamp = -1 } + val constructor: ?loc:loc -> ?attrs:attrs -> ?info:info -> + ?args:constructor_arguments -> ?res:core_type -> str -> + constructor_declaration + val field: ?loc:loc -> ?attrs:attrs -> ?info:info -> + ?mut:mutable_flag -> str -> core_type -> label_declaration + end -let make_global i = - i.flags <- i.flags lor global_flag +(** Type extensions *) +module Te: + sig + val mk: ?attrs:attrs -> ?docs:docs -> + ?params:(core_type * variance) list -> ?priv:private_flag -> + lid -> extension_constructor list -> type_extension + + val constructor: ?loc:loc -> ?attrs:attrs -> ?docs:docs -> ?info:info -> + str -> extension_constructor_kind -> extension_constructor + + val decl: ?loc:loc -> ?attrs:attrs -> ?docs:docs -> ?info:info -> + ?args:constructor_arguments -> ?res:core_type -> str -> + extension_constructor + val rebind: ?loc:loc -> ?attrs:attrs -> ?docs:docs -> ?info:info -> + str -> lid -> extension_constructor + end + +(** {1 Module language} *) + +(** Module type expressions *) +module Mty: + sig + val mk: ?loc:loc -> ?attrs:attrs -> module_type_desc -> module_type + val attr: module_type -> attribute -> module_type + + val ident: ?loc:loc -> ?attrs:attrs -> lid -> module_type + val alias: ?loc:loc -> ?attrs:attrs -> lid -> module_type + val signature: ?loc:loc -> ?attrs:attrs -> signature -> module_type + val functor_: ?loc:loc -> ?attrs:attrs -> + str -> module_type option -> module_type -> module_type + val with_: ?loc:loc -> ?attrs:attrs -> module_type -> + with_constraint list -> module_type + val typeof_: ?loc:loc -> ?attrs:attrs -> module_expr -> module_type + val extension: ?loc:loc -> ?attrs:attrs -> extension -> module_type + end -let global i = - (i.flags land global_flag) <> 0 +(** Module expressions *) +module Mod: + sig + val mk: ?loc:loc -> ?attrs:attrs -> module_expr_desc -> module_expr + val attr: module_expr -> attribute -> module_expr -let is_predef_exn i = - (i.flags land predef_exn_flag) <> 0 + val ident: ?loc:loc -> ?attrs:attrs -> lid -> module_expr + val structure: ?loc:loc -> ?attrs:attrs -> structure -> module_expr + val functor_: ?loc:loc -> ?attrs:attrs -> + str -> module_type option -> module_expr -> module_expr + val apply: ?loc:loc -> ?attrs:attrs -> module_expr -> module_expr -> + module_expr + val constraint_: ?loc:loc -> ?attrs:attrs -> module_expr -> module_type -> + module_expr + val unpack: ?loc:loc -> ?attrs:attrs -> expression -> module_expr + val extension: ?loc:loc -> ?attrs:attrs -> extension -> module_expr + end -let print ppf i = - match i.stamp with - | 0 -> fprintf ppf "%s!" i.name - | -1 -> fprintf ppf "%s#" i.name - | n -> fprintf ppf "%s/%i%s" i.name n (if global i then "g" else "") +(** Signature items *) +module Sig: + sig + val mk: ?loc:loc -> signature_item_desc -> signature_item -type 'a tbl = - Empty - | Node of 'a tbl * 'a data * 'a tbl * int + val value: ?loc:loc -> value_description -> signature_item + val type_: ?loc:loc -> rec_flag -> type_declaration list -> signature_item + val type_extension: ?loc:loc -> type_extension -> signature_item + val exception_: ?loc:loc -> extension_constructor -> signature_item + val module_: ?loc:loc -> module_declaration -> signature_item + val rec_module: ?loc:loc -> module_declaration list -> signature_item + val modtype: ?loc:loc -> module_type_declaration -> signature_item + val open_: ?loc:loc -> open_description -> signature_item + val include_: ?loc:loc -> include_description -> signature_item + val class_: ?loc:loc -> class_description list -> signature_item + val class_type: ?loc:loc -> class_type_declaration list -> signature_item + val extension: ?loc:loc -> ?attrs:attrs -> extension -> signature_item + val attribute: ?loc:loc -> attribute -> signature_item + val text: text -> signature_item list + end -and 'a data = - { ident: t; - data: 'a; - previous: 'a data option } +(** Structure items *) +module Str: + sig + val mk: ?loc:loc -> structure_item_desc -> structure_item -let empty = Empty + val eval: ?loc:loc -> ?attrs:attributes -> expression -> structure_item + val value: ?loc:loc -> rec_flag -> value_binding list -> structure_item + val primitive: ?loc:loc -> value_description -> structure_item + val type_: ?loc:loc -> rec_flag -> type_declaration list -> structure_item + val type_extension: ?loc:loc -> type_extension -> structure_item + val exception_: ?loc:loc -> extension_constructor -> structure_item + val module_: ?loc:loc -> module_binding -> structure_item + val rec_module: ?loc:loc -> module_binding list -> structure_item + val modtype: ?loc:loc -> module_type_declaration -> structure_item + val open_: ?loc:loc -> open_description -> structure_item + val class_: ?loc:loc -> class_declaration list -> structure_item + val class_type: ?loc:loc -> class_type_declaration list -> structure_item + val include_: ?loc:loc -> include_declaration -> structure_item + val extension: ?loc:loc -> ?attrs:attrs -> extension -> structure_item + val attribute: ?loc:loc -> attribute -> structure_item + val text: text -> structure_item list + end -(* Inline expansion of height for better speed - * let height = function - * Empty -> 0 - * | Node(_,_,_,h) -> h - *) +(** Module declarations *) +module Md: + sig + val mk: ?loc:loc -> ?attrs:attrs -> ?docs:docs -> ?text:text -> + str -> module_type -> module_declaration + end -let mknode l d r = - let hl = match l with Empty -> 0 | Node(_,_,_,h) -> h - and hr = match r with Empty -> 0 | Node(_,_,_,h) -> h in - Node(l, d, r, (if hl >= hr then hl + 1 else hr + 1)) +(** Module type declarations *) +module Mtd: + sig + val mk: ?loc:loc -> ?attrs:attrs -> ?docs:docs -> ?text:text -> + ?typ:module_type -> str -> module_type_declaration + end -let balance l d r = - let hl = match l with Empty -> 0 | Node(_,_,_,h) -> h - and hr = match r with Empty -> 0 | Node(_,_,_,h) -> h in - if hl > hr + 1 then - match l with - | Node (ll, ld, lr, _) - when (match ll with Empty -> 0 | Node(_,_,_,h) -> h) >= - (match lr with Empty -> 0 | Node(_,_,_,h) -> h) -> - mknode ll ld (mknode lr d r) - | Node (ll, ld, Node(lrl, lrd, lrr, _), _) -> - mknode (mknode ll ld lrl) lrd (mknode lrr d r) - | _ -> assert false - else if hr > hl + 1 then - match r with - | Node (rl, rd, rr, _) - when (match rr with Empty -> 0 | Node(_,_,_,h) -> h) >= - (match rl with Empty -> 0 | Node(_,_,_,h) -> h) -> - mknode (mknode l d rl) rd rr - | Node (Node (rll, rld, rlr, _), rd, rr, _) -> - mknode (mknode l d rll) rld (mknode rlr rd rr) - | _ -> assert false - else - mknode l d r +(** Module bindings *) +module Mb: + sig + val mk: ?loc:loc -> ?attrs:attrs -> ?docs:docs -> ?text:text -> + str -> module_expr -> module_binding + end -let rec add id data = function - Empty -> - Node(Empty, {ident = id; data = data; previous = None}, Empty, 1) - | Node(l, k, r, h) -> - let c = compare id.name k.ident.name in - if c = 0 then - Node(l, {ident = id; data = data; previous = Some k}, r, h) - else if c < 0 then - balance (add id data l) k r - else - balance l k (add id data r) +(** Opens *) +module Opn: + sig + val mk: ?loc: loc -> ?attrs:attrs -> ?docs:docs -> + ?override:override_flag -> lid -> open_description + end -let rec find_stamp s = function - None -> - raise Not_found - | Some k -> - if k.ident.stamp = s then k.data else find_stamp s k.previous +(** Includes *) +module Incl: + sig + val mk: ?loc: loc -> ?attrs:attrs -> ?docs:docs -> 'a -> 'a include_infos + end -let rec find_same id = function - Empty -> - raise Not_found - | Node(l, k, r, _) -> - let c = compare id.name k.ident.name in - if c = 0 then - if id.stamp = k.ident.stamp - then k.data - else find_stamp id.stamp k.previous - else - find_same id (if c < 0 then l else r) +(** Value bindings *) +module Vb: + sig + val mk: ?loc: loc -> ?attrs:attrs -> ?docs:docs -> ?text:text -> + pattern -> expression -> value_binding + end -let rec find_name name = function - Empty -> - raise Not_found - | Node(l, k, r, _) -> - let c = compare name k.ident.name in - if c = 0 then - k.ident, k.data - else - find_name name (if c < 0 then l else r) -let rec get_all = function - | None -> [] - | Some k -> (k.ident, k.data) :: get_all k.previous +(** {1 Class language} *) -let rec find_all name = function - Empty -> - [] - | Node(l, k, r, _) -> - let c = compare name k.ident.name in - if c = 0 then - (k.ident, k.data) :: get_all k.previous - else - find_all name (if c < 0 then l else r) +(** Class type expressions *) +module Cty: + sig + val mk: ?loc:loc -> ?attrs:attrs -> class_type_desc -> class_type + val attr: class_type -> attribute -> class_type -let rec fold_aux f stack accu = function - Empty -> - begin match stack with - [] -> accu - | a :: l -> fold_aux f l accu a - end - | Node(l, k, r, _) -> - fold_aux f (l :: stack) (f k accu) r + val constr: ?loc:loc -> ?attrs:attrs -> lid -> core_type list -> class_type + val signature: ?loc:loc -> ?attrs:attrs -> class_signature -> class_type + val arrow: ?loc:loc -> ?attrs:attrs -> arg_label -> core_type -> + class_type -> class_type + val extension: ?loc:loc -> ?attrs:attrs -> extension -> class_type + val open_: ?loc:loc -> ?attrs:attrs -> override_flag -> lid -> class_type + -> class_type + end -let fold_name f tbl accu = fold_aux (fun k -> f k.ident k.data) [] accu tbl +(** Class type fields *) +module Ctf: + sig + val mk: ?loc:loc -> ?attrs:attrs -> ?docs:docs -> + class_type_field_desc -> class_type_field + val attr: class_type_field -> attribute -> class_type_field -let rec fold_data f d accu = - match d with - None -> accu - | Some k -> f k.ident k.data (fold_data f k.previous accu) + val inherit_: ?loc:loc -> ?attrs:attrs -> class_type -> class_type_field + val val_: ?loc:loc -> ?attrs:attrs -> str -> mutable_flag -> + virtual_flag -> core_type -> class_type_field + val method_: ?loc:loc -> ?attrs:attrs -> str -> private_flag -> + virtual_flag -> core_type -> class_type_field + val constraint_: ?loc:loc -> ?attrs:attrs -> core_type -> core_type -> + class_type_field + val extension: ?loc:loc -> ?attrs:attrs -> extension -> class_type_field + val attribute: ?loc:loc -> attribute -> class_type_field + val text: text -> class_type_field list + end -let fold_all f tbl accu = - fold_aux (fun k -> fold_data f (Some k)) [] accu tbl +(** Class expressions *) +module Cl: + sig + val mk: ?loc:loc -> ?attrs:attrs -> class_expr_desc -> class_expr + val attr: class_expr -> attribute -> class_expr -(* let keys tbl = fold_name (fun k _ accu -> k::accu) tbl [] *) + val constr: ?loc:loc -> ?attrs:attrs -> lid -> core_type list -> class_expr + val structure: ?loc:loc -> ?attrs:attrs -> class_structure -> class_expr + val fun_: ?loc:loc -> ?attrs:attrs -> arg_label -> expression option -> + pattern -> class_expr -> class_expr + val apply: ?loc:loc -> ?attrs:attrs -> class_expr -> + (arg_label * expression) list -> class_expr + val let_: ?loc:loc -> ?attrs:attrs -> rec_flag -> value_binding list -> + class_expr -> class_expr + val constraint_: ?loc:loc -> ?attrs:attrs -> class_expr -> class_type -> + class_expr + val extension: ?loc:loc -> ?attrs:attrs -> extension -> class_expr + val open_: ?loc:loc -> ?attrs:attrs -> override_flag -> lid -> class_expr + -> class_expr + end -let rec iter f = function - Empty -> () - | Node(l, k, r, _) -> - iter f l; f k.ident k.data; iter f r +(** Class fields *) +module Cf: + sig + val mk: ?loc:loc -> ?attrs:attrs -> ?docs:docs -> class_field_desc -> + class_field + val attr: class_field -> attribute -> class_field -(* Idents for sharing keys *) + val inherit_: ?loc:loc -> ?attrs:attrs -> override_flag -> class_expr -> + str option -> class_field + val val_: ?loc:loc -> ?attrs:attrs -> str -> mutable_flag -> + class_field_kind -> class_field + val method_: ?loc:loc -> ?attrs:attrs -> str -> private_flag -> + class_field_kind -> class_field + val constraint_: ?loc:loc -> ?attrs:attrs -> core_type -> core_type -> + class_field + val initializer_: ?loc:loc -> ?attrs:attrs -> expression -> class_field + val extension: ?loc:loc -> ?attrs:attrs -> extension -> class_field + val attribute: ?loc:loc -> attribute -> class_field + val text: text -> class_field list -(* They should be 'totally fresh' -> neg numbers *) -let key_name = "" + val virtual_: core_type -> class_field_kind + val concrete: override_flag -> expression -> class_field_kind -let make_key_generator () = - let c = ref 1 in - fun id -> - let stamp = !c in - decr c ; - { id with name = key_name; stamp = stamp; } + end -let compare x y = - let c = x.stamp - y.stamp in - if c <> 0 then c - else - let c = compare x.name y.name in - if c <> 0 then c - else - compare x.flags y.flags +(** Classes *) +module Ci: + sig + val mk: ?loc:loc -> ?attrs:attrs -> ?docs:docs -> ?text:text -> + ?virt:virtual_flag -> ?params:(core_type * variance) list -> + str -> 'a -> 'a class_infos + end -let output oc id = output_string oc (unique_name id) -let hash i = (Char.code i.name.[0]) lxor i.stamp +(** Class signatures *) +module Csig: + sig + val mk: core_type -> class_type_field list -> class_signature + end -let original_equal = equal -include Identifiable.Make (struct - type nonrec t = t - let compare = compare - let output = output - let print = print - let hash = hash - let equal = same -end) -let equal = original_equal +(** Class structures *) +module Cstr: + sig + val mk: pattern -> class_field list -> class_structure + end -end -module Path : sig -#1 "path.mli" +end = struct +#1 "ast_helper.ml" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* Alain Frisch, LexiFi *) (* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* Copyright 2012 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -29729,257 +13761,563 @@ module Path : sig (* *) (**************************************************************************) -(* Access paths *) +(** Helpers to produce Parsetree fragments *) + +open Asttypes +open Parsetree +open Docstrings + +type lid = Longident.t loc +type str = string loc +type loc = Location.t +type attrs = attribute list + +let default_loc = ref Location.none + +let with_default_loc l f = + let old = !default_loc in + default_loc := l; + try let r = f () in default_loc := old; r + with exn -> default_loc := old; raise exn + +module Const = struct + let integer ?suffix i = Pconst_integer (i, suffix) + let int ?suffix i = integer ?suffix (string_of_int i) + let int32 ?(suffix='l') i = integer ~suffix (Int32.to_string i) + let int64 ?(suffix='L') i = integer ~suffix (Int64.to_string i) + let nativeint ?(suffix='n') i = integer ~suffix (Nativeint.to_string i) + let float ?suffix f = Pconst_float (f, suffix) + let char c = Pconst_char c + let string ?quotation_delimiter s = Pconst_string (s, quotation_delimiter) +end + +module Typ = struct + let mk ?(loc = !default_loc) ?(attrs = []) d = + {ptyp_desc = d; ptyp_loc = loc; ptyp_attributes = attrs} + let attr d a = {d with ptyp_attributes = d.ptyp_attributes @ [a]} + + let any ?loc ?attrs () = mk ?loc ?attrs Ptyp_any + let var ?loc ?attrs a = mk ?loc ?attrs (Ptyp_var a) + let arrow ?loc ?attrs a b c = mk ?loc ?attrs (Ptyp_arrow (a, b, c)) + let tuple ?loc ?attrs a = mk ?loc ?attrs (Ptyp_tuple a) + let constr ?loc ?attrs a b = mk ?loc ?attrs (Ptyp_constr (a, b)) + let object_ ?loc ?attrs a b = mk ?loc ?attrs (Ptyp_object (a, b)) + let class_ ?loc ?attrs a b = mk ?loc ?attrs (Ptyp_class (a, b)) + let alias ?loc ?attrs a b = mk ?loc ?attrs (Ptyp_alias (a, b)) + let variant ?loc ?attrs a b c = mk ?loc ?attrs (Ptyp_variant (a, b, c)) + let poly ?loc ?attrs a b = mk ?loc ?attrs (Ptyp_poly (a, b)) + let package ?loc ?attrs a b = mk ?loc ?attrs (Ptyp_package (a, b)) + let extension ?loc ?attrs a = mk ?loc ?attrs (Ptyp_extension a) + + let force_poly t = + match t.ptyp_desc with + | Ptyp_poly _ -> t + | _ -> poly ~loc:t.ptyp_loc [] t (* -> ghost? *) + + let varify_constructors var_names t = + let check_variable vl loc v = + if List.mem v vl then + raise Syntaxerr.(Error(Variable_in_scope(loc,v))) in + let var_names = List.map (fun v -> v.txt) var_names in + let rec loop t = + let desc = + match t.ptyp_desc with + | Ptyp_any -> Ptyp_any + | Ptyp_var x -> + check_variable var_names t.ptyp_loc x; + Ptyp_var x + | Ptyp_arrow (label,core_type,core_type') -> + Ptyp_arrow(label, loop core_type, loop core_type') + | Ptyp_tuple lst -> Ptyp_tuple (List.map loop lst) + | Ptyp_constr( { txt = Longident.Lident s }, []) + when List.mem s var_names -> + Ptyp_var s + | Ptyp_constr(longident, lst) -> + Ptyp_constr(longident, List.map loop lst) + | Ptyp_object (lst, o) -> + Ptyp_object (List.map loop_object_field lst, o) + | Ptyp_class (longident, lst) -> + Ptyp_class (longident, List.map loop lst) + | Ptyp_alias(core_type, string) -> + check_variable var_names t.ptyp_loc string; + Ptyp_alias(loop core_type, string) + | Ptyp_variant(row_field_list, flag, lbl_lst_option) -> + Ptyp_variant(List.map loop_row_field row_field_list, + flag, lbl_lst_option) + | Ptyp_poly(string_lst, core_type) -> + List.iter (fun v -> + check_variable var_names t.ptyp_loc v.txt) string_lst; + Ptyp_poly(string_lst, loop core_type) + | Ptyp_package(longident,lst) -> + Ptyp_package(longident,List.map (fun (n,typ) -> (n,loop typ) ) lst) + | Ptyp_extension (s, arg) -> + Ptyp_extension (s, arg) + in + {t with ptyp_desc = desc} + and loop_row_field = + function + | Rtag(label,attrs,flag,lst) -> + Rtag(label,attrs,flag,List.map loop lst) + | Rinherit t -> + Rinherit (loop t) + and loop_object_field = + function + | Otag(label, attrs, t) -> + Otag(label, attrs, loop t) + | Oinherit t -> + Oinherit (loop t) + in + loop t + +end + +module Pat = struct + let mk ?(loc = !default_loc) ?(attrs = []) d = + {ppat_desc = d; ppat_loc = loc; ppat_attributes = attrs} + let attr d a = {d with ppat_attributes = d.ppat_attributes @ [a]} + + let any ?loc ?attrs () = mk ?loc ?attrs Ppat_any + let var ?loc ?attrs a = mk ?loc ?attrs (Ppat_var a) + let alias ?loc ?attrs a b = mk ?loc ?attrs (Ppat_alias (a, b)) + let constant ?loc ?attrs a = mk ?loc ?attrs (Ppat_constant a) + let interval ?loc ?attrs a b = mk ?loc ?attrs (Ppat_interval (a, b)) + let tuple ?loc ?attrs a = mk ?loc ?attrs (Ppat_tuple a) + let construct ?loc ?attrs a b = mk ?loc ?attrs (Ppat_construct (a, b)) + let variant ?loc ?attrs a b = mk ?loc ?attrs (Ppat_variant (a, b)) + let record ?loc ?attrs a b = mk ?loc ?attrs (Ppat_record (a, b)) + let array ?loc ?attrs a = mk ?loc ?attrs (Ppat_array a) + let or_ ?loc ?attrs a b = mk ?loc ?attrs (Ppat_or (a, b)) + let constraint_ ?loc ?attrs a b = mk ?loc ?attrs (Ppat_constraint (a, b)) + let type_ ?loc ?attrs a = mk ?loc ?attrs (Ppat_type a) + let lazy_ ?loc ?attrs a = mk ?loc ?attrs (Ppat_lazy a) + let unpack ?loc ?attrs a = mk ?loc ?attrs (Ppat_unpack a) + let open_ ?loc ?attrs a b = mk ?loc ?attrs (Ppat_open (a, b)) + let exception_ ?loc ?attrs a = mk ?loc ?attrs (Ppat_exception a) + let extension ?loc ?attrs a = mk ?loc ?attrs (Ppat_extension a) +end + +module Exp = struct + let mk ?(loc = !default_loc) ?(attrs = []) d = + {pexp_desc = d; pexp_loc = loc; pexp_attributes = attrs} + let attr d a = {d with pexp_attributes = d.pexp_attributes @ [a]} + + let ident ?loc ?attrs a = mk ?loc ?attrs (Pexp_ident a) + let constant ?loc ?attrs a = mk ?loc ?attrs (Pexp_constant a) + let let_ ?loc ?attrs a b c = mk ?loc ?attrs (Pexp_let (a, b, c)) + let fun_ ?loc ?attrs a b c d = mk ?loc ?attrs (Pexp_fun (a, b, c, d)) + let function_ ?loc ?attrs a = mk ?loc ?attrs (Pexp_function a) + let apply ?loc ?attrs a b = mk ?loc ?attrs (Pexp_apply (a, b)) + let match_ ?loc ?attrs a b = mk ?loc ?attrs (Pexp_match (a, b)) + let try_ ?loc ?attrs a b = mk ?loc ?attrs (Pexp_try (a, b)) + let tuple ?loc ?attrs a = mk ?loc ?attrs (Pexp_tuple a) + let construct ?loc ?attrs a b = mk ?loc ?attrs (Pexp_construct (a, b)) + let variant ?loc ?attrs a b = mk ?loc ?attrs (Pexp_variant (a, b)) + let record ?loc ?attrs a b = mk ?loc ?attrs (Pexp_record (a, b)) + let field ?loc ?attrs a b = mk ?loc ?attrs (Pexp_field (a, b)) + let setfield ?loc ?attrs a b c = mk ?loc ?attrs (Pexp_setfield (a, b, c)) + let array ?loc ?attrs a = mk ?loc ?attrs (Pexp_array a) + let ifthenelse ?loc ?attrs a b c = mk ?loc ?attrs (Pexp_ifthenelse (a, b, c)) + let sequence ?loc ?attrs a b = mk ?loc ?attrs (Pexp_sequence (a, b)) + let while_ ?loc ?attrs a b = mk ?loc ?attrs (Pexp_while (a, b)) + let for_ ?loc ?attrs a b c d e = mk ?loc ?attrs (Pexp_for (a, b, c, d, e)) + let constraint_ ?loc ?attrs a b = mk ?loc ?attrs (Pexp_constraint (a, b)) + let coerce ?loc ?attrs a b c = mk ?loc ?attrs (Pexp_coerce (a, b, c)) + let send ?loc ?attrs a b = mk ?loc ?attrs (Pexp_send (a, b)) + let new_ ?loc ?attrs a = mk ?loc ?attrs (Pexp_new a) + let setinstvar ?loc ?attrs a b = mk ?loc ?attrs (Pexp_setinstvar (a, b)) + let override ?loc ?attrs a = mk ?loc ?attrs (Pexp_override a) + let letmodule ?loc ?attrs a b c= mk ?loc ?attrs (Pexp_letmodule (a, b, c)) + let letexception ?loc ?attrs a b = mk ?loc ?attrs (Pexp_letexception (a, b)) + let assert_ ?loc ?attrs a = mk ?loc ?attrs (Pexp_assert a) + let lazy_ ?loc ?attrs a = mk ?loc ?attrs (Pexp_lazy a) + let poly ?loc ?attrs a b = mk ?loc ?attrs (Pexp_poly (a, b)) + let object_ ?loc ?attrs a = mk ?loc ?attrs (Pexp_object a) + let newtype ?loc ?attrs a b = mk ?loc ?attrs (Pexp_newtype (a, b)) + let pack ?loc ?attrs a = mk ?loc ?attrs (Pexp_pack a) + let open_ ?loc ?attrs a b c = mk ?loc ?attrs (Pexp_open (a, b, c)) + let extension ?loc ?attrs a = mk ?loc ?attrs (Pexp_extension a) + let unreachable ?loc ?attrs () = mk ?loc ?attrs Pexp_unreachable -type t = - Pident of Ident.t - | Pdot of t * string * int - | Papply of t * t + let case lhs ?guard rhs = + { + pc_lhs = lhs; + pc_guard = guard; + pc_rhs = rhs; + } +end -val same: t -> t -> bool -val compare: t -> t -> int -val isfree: Ident.t -> t -> bool -val binding_time: t -> int -val flatten : t -> [ `Contains_apply | `Ok of Ident.t * string list ] +module Mty = struct + let mk ?(loc = !default_loc) ?(attrs = []) d = + {pmty_desc = d; pmty_loc = loc; pmty_attributes = attrs} + let attr d a = {d with pmty_attributes = d.pmty_attributes @ [a]} -val nopos: int + let ident ?loc ?attrs a = mk ?loc ?attrs (Pmty_ident a) + let alias ?loc ?attrs a = mk ?loc ?attrs (Pmty_alias a) + let signature ?loc ?attrs a = mk ?loc ?attrs (Pmty_signature a) + let functor_ ?loc ?attrs a b c = mk ?loc ?attrs (Pmty_functor (a, b, c)) + let with_ ?loc ?attrs a b = mk ?loc ?attrs (Pmty_with (a, b)) + let typeof_ ?loc ?attrs a = mk ?loc ?attrs (Pmty_typeof a) + let extension ?loc ?attrs a = mk ?loc ?attrs (Pmty_extension a) +end -val name: ?paren:(string -> bool) -> t -> string - (* [paren] tells whether a path suffix needs parentheses *) -val head: t -> Ident.t +module Mod = struct +let mk ?(loc = !default_loc) ?(attrs = []) d = + {pmod_desc = d; pmod_loc = loc; pmod_attributes = attrs} + let attr d a = {d with pmod_attributes = d.pmod_attributes @ [a]} -val heads: t -> Ident.t list + let ident ?loc ?attrs x = mk ?loc ?attrs (Pmod_ident x) + let structure ?loc ?attrs x = mk ?loc ?attrs (Pmod_structure x) + let functor_ ?loc ?attrs arg arg_ty body = + mk ?loc ?attrs (Pmod_functor (arg, arg_ty, body)) + let apply ?loc ?attrs m1 m2 = mk ?loc ?attrs (Pmod_apply (m1, m2)) + let constraint_ ?loc ?attrs m mty = mk ?loc ?attrs (Pmod_constraint (m, mty)) + let unpack ?loc ?attrs e = mk ?loc ?attrs (Pmod_unpack e) + let extension ?loc ?attrs a = mk ?loc ?attrs (Pmod_extension a) +end -val last: t -> string +module Sig = struct + let mk ?(loc = !default_loc) d = {psig_desc = d; psig_loc = loc} -type typath = - | Regular of t - | Ext of t * string - | LocalExt of Ident.t - | Cstr of t * string + let value ?loc a = mk ?loc (Psig_value a) + let type_ ?loc rec_flag a = mk ?loc (Psig_type (rec_flag, a)) + let type_extension ?loc a = mk ?loc (Psig_typext a) + let exception_ ?loc a = mk ?loc (Psig_exception a) + let module_ ?loc a = mk ?loc (Psig_module a) + let rec_module ?loc a = mk ?loc (Psig_recmodule a) + let modtype ?loc a = mk ?loc (Psig_modtype a) + let open_ ?loc a = mk ?loc (Psig_open a) + let include_ ?loc a = mk ?loc (Psig_include a) + let class_ ?loc a = mk ?loc (Psig_class a) + let class_type ?loc a = mk ?loc (Psig_class_type a) + let extension ?loc ?(attrs = []) a = mk ?loc (Psig_extension (a, attrs)) + let attribute ?loc a = mk ?loc (Psig_attribute a) + let text txt = + let f_txt = List.filter (fun ds -> docstring_body ds <> "") txt in + List.map + (fun ds -> attribute ~loc:(docstring_loc ds) (text_attr ds)) + f_txt +end -val constructor_typath: t -> typath -val is_constructor_typath: t -> bool +module Str = struct + let mk ?(loc = !default_loc) d = {pstr_desc = d; pstr_loc = loc} -end = struct -#1 "path.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) + let eval ?loc ?(attrs = []) a = mk ?loc (Pstr_eval (a, attrs)) + let value ?loc a b = mk ?loc (Pstr_value (a, b)) + let primitive ?loc a = mk ?loc (Pstr_primitive a) + let type_ ?loc rec_flag a = mk ?loc (Pstr_type (rec_flag, a)) + let type_extension ?loc a = mk ?loc (Pstr_typext a) + let exception_ ?loc a = mk ?loc (Pstr_exception a) + let module_ ?loc a = mk ?loc (Pstr_module a) + let rec_module ?loc a = mk ?loc (Pstr_recmodule a) + let modtype ?loc a = mk ?loc (Pstr_modtype a) + let open_ ?loc a = mk ?loc (Pstr_open a) + let class_ ?loc a = mk ?loc (Pstr_class a) + let class_type ?loc a = mk ?loc (Pstr_class_type a) + let include_ ?loc a = mk ?loc (Pstr_include a) + let extension ?loc ?(attrs = []) a = mk ?loc (Pstr_extension (a, attrs)) + let attribute ?loc a = mk ?loc (Pstr_attribute a) + let text txt = + let f_txt = List.filter (fun ds -> docstring_body ds <> "") txt in + List.map + (fun ds -> attribute ~loc:(docstring_loc ds) (text_attr ds)) + f_txt +end -type t = - Pident of Ident.t - | Pdot of t * string * int - | Papply of t * t +module Cl = struct + let mk ?(loc = !default_loc) ?(attrs = []) d = + { + pcl_desc = d; + pcl_loc = loc; + pcl_attributes = attrs; + } + let attr d a = {d with pcl_attributes = d.pcl_attributes @ [a]} -let nopos = -1 + let constr ?loc ?attrs a b = mk ?loc ?attrs (Pcl_constr (a, b)) + let structure ?loc ?attrs a = mk ?loc ?attrs (Pcl_structure a) + let fun_ ?loc ?attrs a b c d = mk ?loc ?attrs (Pcl_fun (a, b, c, d)) + let apply ?loc ?attrs a b = mk ?loc ?attrs (Pcl_apply (a, b)) + let let_ ?loc ?attrs a b c = mk ?loc ?attrs (Pcl_let (a, b, c)) + let constraint_ ?loc ?attrs a b = mk ?loc ?attrs (Pcl_constraint (a, b)) + let extension ?loc ?attrs a = mk ?loc ?attrs (Pcl_extension a) + let open_ ?loc ?attrs a b c = mk ?loc ?attrs (Pcl_open (a, b, c)) +end -let rec same p1 p2 = - match (p1, p2) with - (Pident id1, Pident id2) -> Ident.same id1 id2 - | (Pdot(p1, s1, _pos1), Pdot(p2, s2, _pos2)) -> s1 = s2 && same p1 p2 - | (Papply(fun1, arg1), Papply(fun2, arg2)) -> - same fun1 fun2 && same arg1 arg2 - | (_, _) -> false +module Cty = struct + let mk ?(loc = !default_loc) ?(attrs = []) d = + { + pcty_desc = d; + pcty_loc = loc; + pcty_attributes = attrs; + } + let attr d a = {d with pcty_attributes = d.pcty_attributes @ [a]} -let rec compare p1 p2 = - match (p1, p2) with - (Pident id1, Pident id2) -> Ident.compare id1 id2 - | (Pdot(p1, s1, _pos1), Pdot(p2, s2, _pos2)) -> - let h = compare p1 p2 in - if h <> 0 then h else String.compare s1 s2 - | (Papply(fun1, arg1), Papply(fun2, arg2)) -> - let h = compare fun1 fun2 in - if h <> 0 then h else compare arg1 arg2 - | ((Pident _ | Pdot _), (Pdot _ | Papply _)) -> -1 - | ((Pdot _ | Papply _), (Pident _ | Pdot _)) -> 1 + let constr ?loc ?attrs a b = mk ?loc ?attrs (Pcty_constr (a, b)) + let signature ?loc ?attrs a = mk ?loc ?attrs (Pcty_signature a) + let arrow ?loc ?attrs a b c = mk ?loc ?attrs (Pcty_arrow (a, b, c)) + let extension ?loc ?attrs a = mk ?loc ?attrs (Pcty_extension a) + let open_ ?loc ?attrs a b c = mk ?loc ?attrs (Pcty_open (a, b, c)) +end -let rec isfree id = function - Pident id' -> Ident.same id id' - | Pdot(p, _s, _pos) -> isfree id p - | Papply(p1, p2) -> isfree id p1 || isfree id p2 +module Ctf = struct + let mk ?(loc = !default_loc) ?(attrs = []) + ?(docs = empty_docs) d = + { + pctf_desc = d; + pctf_loc = loc; + pctf_attributes = add_docs_attrs docs attrs; + } -let rec binding_time = function - Pident id -> Ident.binding_time id - | Pdot(p, _s, _pos) -> binding_time p - | Papply(p1, p2) -> max (binding_time p1) (binding_time p2) + let inherit_ ?loc ?attrs a = mk ?loc ?attrs (Pctf_inherit a) + let val_ ?loc ?attrs a b c d = mk ?loc ?attrs (Pctf_val (a, b, c, d)) + let method_ ?loc ?attrs a b c d = mk ?loc ?attrs (Pctf_method (a, b, c, d)) + let constraint_ ?loc ?attrs a b = mk ?loc ?attrs (Pctf_constraint (a, b)) + let extension ?loc ?attrs a = mk ?loc ?attrs (Pctf_extension a) + let attribute ?loc a = mk ?loc (Pctf_attribute a) + let text txt = + let f_txt = List.filter (fun ds -> docstring_body ds <> "") txt in + List.map + (fun ds -> attribute ~loc:(docstring_loc ds) (text_attr ds)) + f_txt -let kfalse _ = false + let attr d a = {d with pctf_attributes = d.pctf_attributes @ [a]} -let rec name ?(paren=kfalse) = function - Pident id -> Ident.name id - | Pdot(p, s, _pos) -> - name ~paren p ^ if paren s then ".( " ^ s ^ " )" else "." ^ s - | Papply(p1, p2) -> name ~paren p1 ^ "(" ^ name ~paren p2 ^ ")" +end -let rec head = function - Pident id -> id - | Pdot(p, _s, _pos) -> head p - | Papply _ -> assert false +module Cf = struct + let mk ?(loc = !default_loc) ?(attrs = []) + ?(docs = empty_docs) d = + { + pcf_desc = d; + pcf_loc = loc; + pcf_attributes = add_docs_attrs docs attrs; + } -let flatten = - let rec flatten acc = function - | Pident id -> `Ok (id, acc) - | Pdot (p, s, _) -> flatten (s :: acc) p - | Papply _ -> `Contains_apply - in - fun t -> flatten [] t + let inherit_ ?loc ?attrs a b c = mk ?loc ?attrs (Pcf_inherit (a, b, c)) + let val_ ?loc ?attrs a b c = mk ?loc ?attrs (Pcf_val (a, b, c)) + let method_ ?loc ?attrs a b c = mk ?loc ?attrs (Pcf_method (a, b, c)) + let constraint_ ?loc ?attrs a b = mk ?loc ?attrs (Pcf_constraint (a, b)) + let initializer_ ?loc ?attrs a = mk ?loc ?attrs (Pcf_initializer a) + let extension ?loc ?attrs a = mk ?loc ?attrs (Pcf_extension a) + let attribute ?loc a = mk ?loc (Pcf_attribute a) + let text txt = + let f_txt = List.filter (fun ds -> docstring_body ds <> "") txt in + List.map + (fun ds -> attribute ~loc:(docstring_loc ds) (text_attr ds)) + f_txt -let heads p = - let rec heads p acc = match p with - | Pident id -> id :: acc - | Pdot (p, _s, _pos) -> heads p acc - | Papply(p1, p2) -> - heads p1 (heads p2 acc) - in heads p [] + let virtual_ ct = Cfk_virtual ct + let concrete o e = Cfk_concrete (o, e) -let rec last = function - | Pident id -> Ident.name id - | Pdot(_, s, _) -> s - | Papply(_, p) -> last p + let attr d a = {d with pcf_attributes = d.pcf_attributes @ [a]} -let is_uident s = - assert (s <> ""); - match s.[0] with - | 'A'..'Z' -> true - | _ -> false +end -type typath = - | Regular of t - | Ext of t * string - | LocalExt of Ident.t - | Cstr of t * string +module Val = struct + let mk ?(loc = !default_loc) ?(attrs = []) ?(docs = empty_docs) + ?(prim = []) name typ = + { + pval_name = name; + pval_type = typ; + pval_attributes = add_docs_attrs docs attrs; + pval_loc = loc; + pval_prim = prim; + } +end -let constructor_typath = function - | Pident id when is_uident (Ident.name id) -> LocalExt id - | Pdot(ty_path, s, _) when is_uident s -> - if is_uident (last ty_path) then Ext (ty_path, s) - else Cstr (ty_path, s) - | p -> Regular p +module Md = struct + let mk ?(loc = !default_loc) ?(attrs = []) + ?(docs = empty_docs) ?(text = []) name typ = + { + pmd_name = name; + pmd_type = typ; + pmd_attributes = + add_text_attrs text (add_docs_attrs docs attrs); + pmd_loc = loc; + } +end -let is_constructor_typath p = - match constructor_typath p with - | Regular _ -> false - | _ -> true +module Mtd = struct + let mk ?(loc = !default_loc) ?(attrs = []) + ?(docs = empty_docs) ?(text = []) ?typ name = + { + pmtd_name = name; + pmtd_type = typ; + pmtd_attributes = + add_text_attrs text (add_docs_attrs docs attrs); + pmtd_loc = loc; + } +end +module Mb = struct + let mk ?(loc = !default_loc) ?(attrs = []) + ?(docs = empty_docs) ?(text = []) name expr = + { + pmb_name = name; + pmb_expr = expr; + pmb_attributes = + add_text_attrs text (add_docs_attrs docs attrs); + pmb_loc = loc; + } end -module Attr_helper : sig -#1 "attr_helper.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Jeremie Dimino, Jane Street Europe *) -(* *) -(* Copyright 2015 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) -(** Helpers for attributes *) +module Opn = struct + let mk ?(loc = !default_loc) ?(attrs = []) ?(docs = empty_docs) + ?(override = Fresh) lid = + { + popen_lid = lid; + popen_override = override; + popen_loc = loc; + popen_attributes = add_docs_attrs docs attrs; + } +end -open Asttypes -open Parsetree +module Incl = struct + let mk ?(loc = !default_loc) ?(attrs = []) ?(docs = empty_docs) mexpr = + { + pincl_mod = mexpr; + pincl_loc = loc; + pincl_attributes = add_docs_attrs docs attrs; + } -type error = - | Multiple_attributes of string - | No_payload_expected of string +end -(** The [string list] argument of the following functions is a list of - alternative names for the attribute we are looking for. For instance: +module Vb = struct + let mk ?(loc = !default_loc) ?(attrs = []) ?(docs = empty_docs) + ?(text = []) pat expr = + { + pvb_pat = pat; + pvb_expr = expr; + pvb_attributes = + add_text_attrs text (add_docs_attrs docs attrs); + pvb_loc = loc; + } +end - {[ - ["foo"; "ocaml.foo"] - ]} *) -val get_no_payload_attribute : string list -> attributes -> string loc option -val has_no_payload_attribute : string list -> attributes -> bool +module Ci = struct + let mk ?(loc = !default_loc) ?(attrs = []) + ?(docs = empty_docs) ?(text = []) + ?(virt = Concrete) ?(params = []) name expr = + { + pci_virt = virt; + pci_params = params; + pci_name = name; + pci_expr = expr; + pci_attributes = + add_text_attrs text (add_docs_attrs docs attrs); + pci_loc = loc; + } +end -exception Error of Location.t * error +module Type = struct + let mk ?(loc = !default_loc) ?(attrs = []) + ?(docs = empty_docs) ?(text = []) + ?(params = []) + ?(cstrs = []) + ?(kind = Ptype_abstract) + ?(priv = Public) + ?manifest + name = + { + ptype_name = name; + ptype_params = params; + ptype_cstrs = cstrs; + ptype_kind = kind; + ptype_private = priv; + ptype_manifest = manifest; + ptype_attributes = + add_text_attrs text (add_docs_attrs docs attrs); + ptype_loc = loc; + } -val report_error: Format.formatter -> error -> unit + let constructor ?(loc = !default_loc) ?(attrs = []) ?(info = empty_info) + ?(args = Pcstr_tuple []) ?res name = + { + pcd_name = name; + pcd_args = args; + pcd_res = res; + pcd_loc = loc; + pcd_attributes = add_info_attrs info attrs; + } -end = struct -#1 "attr_helper.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Jeremie Dimino, Jane Street Europe *) -(* *) -(* Copyright 2015 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) + let field ?(loc = !default_loc) ?(attrs = []) ?(info = empty_info) + ?(mut = Immutable) name typ = + { + pld_name = name; + pld_mutable = mut; + pld_type = typ; + pld_loc = loc; + pld_attributes = add_info_attrs info attrs; + } -open Asttypes -open Parsetree +end -type error = - | Multiple_attributes of string - | No_payload_expected of string +(** Type extensions *) +module Te = struct + let mk ?(attrs = []) ?(docs = empty_docs) + ?(params = []) ?(priv = Public) path constructors = + { + ptyext_path = path; + ptyext_params = params; + ptyext_constructors = constructors; + ptyext_private = priv; + ptyext_attributes = add_docs_attrs docs attrs; + } -exception Error of Location.t * error + let constructor ?(loc = !default_loc) ?(attrs = []) + ?(docs = empty_docs) ?(info = empty_info) name kind = + { + pext_name = name; + pext_kind = kind; + pext_loc = loc; + pext_attributes = add_docs_attrs docs (add_info_attrs info attrs); + } -let get_no_payload_attribute alt_names attrs = - match List.filter (fun (n, _) -> List.mem n.txt alt_names) attrs with - | [] -> None - | [ (name, PStr []) ] -> Some name - | [ (name, _) ] -> - raise (Error (name.loc, No_payload_expected name.txt)) - | _ :: (name, _) :: _ -> - raise (Error (name.loc, Multiple_attributes name.txt)) + let decl ?(loc = !default_loc) ?(attrs = []) ?(docs = empty_docs) + ?(info = empty_info) ?(args = Pcstr_tuple []) ?res name = + { + pext_name = name; + pext_kind = Pext_decl(args, res); + pext_loc = loc; + pext_attributes = add_docs_attrs docs (add_info_attrs info attrs); + } -let has_no_payload_attribute alt_names attrs = - match get_no_payload_attribute alt_names attrs with - | None -> false - | Some _ -> true + let rebind ?(loc = !default_loc) ?(attrs = []) + ?(docs = empty_docs) ?(info = empty_info) name lid = + { + pext_name = name; + pext_kind = Pext_rebind lid; + pext_loc = loc; + pext_attributes = add_docs_attrs docs (add_info_attrs info attrs); + } -open Format +end -let report_error ppf = function - | Multiple_attributes name -> - fprintf ppf "Too many `%s' attributes" name - | No_payload_expected name -> - fprintf ppf "Attribute `%s' does not accept a payload" name +module Csig = struct + let mk self fields = + { + pcsig_self = self; + pcsig_fields = fields; + } +end -let () = - Location.register_error_of_exn - (function - | Error (loc, err) -> - Some (Location.error_of_printer loc report_error err) - | _ -> - None - ) +module Cstr = struct + let mk self fields = + { + pcstr_self = self; + pcstr_fields = fields; + } +end end -module Primitive : sig -#1 "primitive.mli" +module Ast_mapper : sig +#1 "ast_mapper.mli" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* Alain Frisch, LexiFi *) (* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* Copyright 2012 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -29988,298 +14326,201 @@ module Primitive : sig (* *) (**************************************************************************) -(* Description of primitive functions *) +(** The interface of a -ppx rewriter -type boxed_integer = Pnativeint | Pint32 | Pint64 + A -ppx rewriter is a program that accepts a serialized abstract syntax + tree and outputs another, possibly modified, abstract syntax tree. + This module encapsulates the interface between the compiler and + the -ppx rewriters, handling such details as the serialization format, + forwarding of command-line flags, and storing state. -(* Representation of arguments/result for the native code version - of a primitive *) -type native_repr = - | Same_as_ocaml_repr - | Unboxed_float - | Unboxed_integer of boxed_integer - | Untagged_int + {!mapper} allows to implement AST rewriting using open recursion. + A typical mapper would be based on {!default_mapper}, a deep + identity mapper, and will fall back on it for handling the syntax it + does not modify. For example: -type description = private - { prim_name: string; (* Name of primitive or C function *) - prim_arity: int; (* Number of arguments *) - prim_alloc: bool; (* Does it allocates or raise? *) - prim_native_name: string; (* Name of C function for the nat. code gen. *) - prim_native_repr_args: native_repr list; - prim_native_repr_res: native_repr } + {[ +open Asttypes +open Parsetree +open Ast_mapper -(* Invariant [List.length d.prim_native_repr_args = d.prim_arity] *) +let test_mapper argv = + { default_mapper with + expr = fun mapper expr -> + match expr with + | { pexp_desc = Pexp_extension ({ txt = "test" }, PStr [])} -> + Ast_helper.Exp.constant (Const_int 42) + | other -> default_mapper.expr mapper other; } -val simple - : name:string - -> arity:int - -> alloc:bool - -> description +let () = + register "ppx_test" test_mapper]} -val make - : name:string - -> alloc:bool - -> native_name:string - -> native_repr_args: native_repr list - -> native_repr_res: native_repr - -> description + This -ppx rewriter, which replaces [[%test]] in expressions with + the constant [42], can be compiled using + [ocamlc -o ppx_test -I +compiler-libs ocamlcommon.cma ppx_test.ml]. -val parse_declaration - : Parsetree.value_description - -> native_repr_args:native_repr list - -> native_repr_res:native_repr - -> description + *) -val print - : description - -> Outcometree.out_val_decl - -> Outcometree.out_val_decl +open Parsetree -val native_name: description -> string -val byte_name: description -> string +(** {1 A generic Parsetree mapper} *) -type error = - | Old_style_float_with_native_repr_attribute - | Old_style_noalloc_with_noalloc_attribute - | No_native_primitive_with_repr_attribute +type mapper = { + attribute: mapper -> attribute -> attribute; + attributes: mapper -> attribute list -> attribute list; + case: mapper -> case -> case; + cases: mapper -> case list -> case list; + class_declaration: mapper -> class_declaration -> class_declaration; + class_description: mapper -> class_description -> class_description; + class_expr: mapper -> class_expr -> class_expr; + class_field: mapper -> class_field -> class_field; + class_signature: mapper -> class_signature -> class_signature; + class_structure: mapper -> class_structure -> class_structure; + class_type: mapper -> class_type -> class_type; + class_type_declaration: mapper -> class_type_declaration + -> class_type_declaration; + class_type_field: mapper -> class_type_field -> class_type_field; + constructor_declaration: mapper -> constructor_declaration + -> constructor_declaration; + expr: mapper -> expression -> expression; + extension: mapper -> extension -> extension; + extension_constructor: mapper -> extension_constructor + -> extension_constructor; + include_declaration: mapper -> include_declaration -> include_declaration; + include_description: mapper -> include_description -> include_description; + label_declaration: mapper -> label_declaration -> label_declaration; + location: mapper -> Location.t -> Location.t; + module_binding: mapper -> module_binding -> module_binding; + module_declaration: mapper -> module_declaration -> module_declaration; + module_expr: mapper -> module_expr -> module_expr; + module_type: mapper -> module_type -> module_type; + module_type_declaration: mapper -> module_type_declaration + -> module_type_declaration; + open_description: mapper -> open_description -> open_description; + pat: mapper -> pattern -> pattern; + payload: mapper -> payload -> payload; + signature: mapper -> signature -> signature; + signature_item: mapper -> signature_item -> signature_item; + structure: mapper -> structure -> structure; + structure_item: mapper -> structure_item -> structure_item; + typ: mapper -> core_type -> core_type; + type_declaration: mapper -> type_declaration -> type_declaration; + type_extension: mapper -> type_extension -> type_extension; + type_kind: mapper -> type_kind -> type_kind; + value_binding: mapper -> value_binding -> value_binding; + value_description: mapper -> value_description -> value_description; + with_constraint: mapper -> with_constraint -> with_constraint; +} +(** A mapper record implements one "method" per syntactic category, + using an open recursion style: each method takes as its first + argument the mapper to be applied to children in the syntax + tree. *) -exception Error of Location.t * error +val default_mapper: mapper +(** A default mapper, which implements a "deep identity" mapping. *) -end = struct -#1 "primitive.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +(** {1 Apply mappers to compilation units} *) -(* Description of primitive functions *) +val tool_name: unit -> string +(** Can be used within a ppx preprocessor to know which tool is + calling it ["ocamlc"], ["ocamlopt"], ["ocamldoc"], ["ocamldep"], + ["ocaml"], ... Some global variables that reflect command-line + options are automatically synchronized between the calling tool + and the ppx preprocessor: {!Clflags.include_dirs}, + {!Config.load_path}, {!Clflags.open_modules}, {!Clflags.for_package}, + {!Clflags.debug}. *) -open Misc -open Parsetree -type boxed_integer = Pnativeint | Pint32 | Pint64 +val apply: source:string -> target:string -> mapper -> unit +(** Apply a mapper (parametrized by the unit name) to a dumped + parsetree found in the [source] file and put the result in the + [target] file. The [structure] or [signature] field of the mapper + is applied to the implementation or interface. *) -type native_repr = - | Same_as_ocaml_repr - | Unboxed_float - | Unboxed_integer of boxed_integer - | Untagged_int +val run_main: (string list -> mapper) -> unit +(** Entry point to call to implement a standalone -ppx rewriter from a + mapper, parametrized by the command line arguments. The current + unit name can be obtained from {!Location.input_name}. This + function implements proper error reporting for uncaught + exceptions. *) -type description = - { prim_name: string; (* Name of primitive or C function *) - prim_arity: int; (* Number of arguments *) - prim_alloc: bool; (* Does it allocates or raise? *) - prim_native_name: string; (* Name of C function for the nat. code gen. *) - prim_native_repr_args: native_repr list; - prim_native_repr_res: native_repr } +(** {1 Registration API} *) -type error = - | Old_style_float_with_native_repr_attribute - | Old_style_noalloc_with_noalloc_attribute - | No_native_primitive_with_repr_attribute +val register_function: (string -> (string list -> mapper) -> unit) ref -exception Error of Location.t * error +val register: string -> (string list -> mapper) -> unit +(** Apply the [register_function]. The default behavior is to run the + mapper immediately, taking arguments from the process command + line. This is to support a scenario where a mapper is linked as a + stand-alone executable. -let is_ocaml_repr = function - | Same_as_ocaml_repr -> true - | Unboxed_float - | Unboxed_integer _ - | Untagged_int -> false + It is possible to overwrite the [register_function] to define + "-ppx drivers", which combine several mappers in a single process. + Typically, a driver starts by defining [register_function] to a + custom implementation, then lets ppx rewriters (linked statically + or dynamically) register themselves, and then run all or some of + them. It is also possible to have -ppx drivers apply rewriters to + only specific parts of an AST. -let is_unboxed = function - | Same_as_ocaml_repr - | Untagged_int -> false - | Unboxed_float - | Unboxed_integer _ -> true + The first argument to [register] is a symbolic name to be used by + the ppx driver. *) -let is_untagged = function - | Untagged_int -> true - | Same_as_ocaml_repr - | Unboxed_float - | Unboxed_integer _ -> false -let rec make_native_repr_args arity x = - if arity = 0 then - [] - else - x :: make_native_repr_args (arity - 1) x +(** {1 Convenience functions to write mappers} *) -let simple ~name ~arity ~alloc = - {prim_name = name; - prim_arity = arity; - prim_alloc = alloc; - prim_native_name = ""; - prim_native_repr_args = make_native_repr_args arity Same_as_ocaml_repr; - prim_native_repr_res = Same_as_ocaml_repr} +val map_opt: ('a -> 'b) -> 'a option -> 'b option -let make ~name ~alloc ~native_name ~native_repr_args ~native_repr_res = - {prim_name = name; - prim_arity = List.length native_repr_args; - prim_alloc = alloc; - prim_native_name = native_name; - prim_native_repr_args = native_repr_args; - prim_native_repr_res = native_repr_res} +val extension_of_error: Location.error -> extension +(** Encode an error into an 'ocaml.error' extension node which can be + inserted in a generated Parsetree. The compiler will be + responsible for reporting the error. *) -let parse_declaration valdecl ~native_repr_args ~native_repr_res = - let arity = List.length native_repr_args in - let name, native_name, old_style_noalloc, old_style_float = - match valdecl.pval_prim with - | name :: "noalloc" :: name2 :: "float" :: _ -> (name, name2, true, true) - | name :: "noalloc" :: name2 :: _ -> (name, name2, true, false) - | name :: name2 :: "float" :: _ -> (name, name2, false, true) - | name :: "noalloc" :: _ -> (name, "", true, false) - | name :: name2 :: _ -> (name, name2, false, false) - | name :: _ -> (name, "", false, false) - | [] -> - fatal_error "Primitive.parse_declaration" - in - let noalloc_attribute = - Attr_helper.has_no_payload_attribute ["noalloc"; "ocaml.noalloc"] - valdecl.pval_attributes - in - if old_style_float && - not (List.for_all is_ocaml_repr native_repr_args && - is_ocaml_repr native_repr_res) then - raise (Error (valdecl.pval_loc, - Old_style_float_with_native_repr_attribute)); - if old_style_noalloc && noalloc_attribute then - raise (Error (valdecl.pval_loc, - Old_style_noalloc_with_noalloc_attribute)); - (* The compiler used to assume "noalloc" with "float", we just make this - explicit now (GPR#167): *) - let old_style_noalloc = old_style_noalloc || old_style_float in - if old_style_float then - Location.deprecated valdecl.pval_loc - "[@@unboxed] + [@@noalloc] should be used instead of \"float\"" - else if old_style_noalloc then - Location.deprecated valdecl.pval_loc - "[@@noalloc] should be used instead of \"noalloc\""; - if native_name = "" && - not (List.for_all is_ocaml_repr native_repr_args && - is_ocaml_repr native_repr_res) then - raise (Error (valdecl.pval_loc, - No_native_primitive_with_repr_attribute)); - let noalloc = old_style_noalloc || noalloc_attribute in - let native_repr_args, native_repr_res = - if old_style_float then - (make_native_repr_args arity Unboxed_float, Unboxed_float) - else - (native_repr_args, native_repr_res) - in - {prim_name = name; - prim_arity = arity; - prim_alloc = not noalloc; - prim_native_name = native_name; - prim_native_repr_args = native_repr_args; - prim_native_repr_res = native_repr_res} +val attribute_of_warning: Location.t -> string -> attribute +(** Encode a warning message into an 'ocaml.ppwarning' attribute which can be + inserted in a generated Parsetree. The compiler will be + responsible for reporting the warning. *) -open Outcometree +(** {1 Helper functions to call external mappers} *) -let rec add_native_repr_attributes ty attrs = - match ty, attrs with - | Otyp_arrow (label, a, b), attr_opt :: rest -> - let b = add_native_repr_attributes b rest in - let a = - match attr_opt with - | None -> a - | Some attr -> Otyp_attribute (a, attr) - in - Otyp_arrow (label, a, b) - | _, [Some attr] -> Otyp_attribute (ty, attr) - | _ -> - assert (List.for_all (fun x -> x = None) attrs); - ty +val add_ppx_context_str: + tool_name:string -> Parsetree.structure -> Parsetree.structure +(** Extract information from the current environment and encode it + into an attribute which is prepended to the list of structure + items in order to pass the information to an external + processor. *) -let oattr_unboxed = { oattr_name = "unboxed" } -let oattr_untagged = { oattr_name = "untagged" } -let oattr_noalloc = { oattr_name = "noalloc" } +val add_ppx_context_sig: + tool_name:string -> Parsetree.signature -> Parsetree.signature +(** Same as [add_ppx_context_str], but for signatures. *) -let print p osig_val_decl = - let prims = - if p.prim_native_name <> "" then - [p.prim_name; p.prim_native_name] - else - [p.prim_name] - in - let for_all f = - List.for_all f p.prim_native_repr_args && f p.prim_native_repr_res - in - let all_unboxed = for_all is_unboxed in - let all_untagged = for_all is_untagged in - let attrs = if p.prim_alloc then [] else [oattr_noalloc] in - let attrs = - if all_unboxed then - oattr_unboxed :: attrs - else if all_untagged then - oattr_untagged :: attrs - else - attrs - in - let attr_of_native_repr = function - | Same_as_ocaml_repr -> None - | Unboxed_float - | Unboxed_integer _ -> if all_unboxed then None else Some oattr_unboxed - | Untagged_int -> if all_untagged then None else Some oattr_untagged - in - let type_attrs = - List.map attr_of_native_repr p.prim_native_repr_args @ - [attr_of_native_repr p.prim_native_repr_res] - in - { osig_val_decl with - oval_prims = prims; - oval_type = add_native_repr_attributes osig_val_decl.oval_type type_attrs; - oval_attributes = attrs } +val drop_ppx_context_str: + restore:bool -> Parsetree.structure -> Parsetree.structure +(** Drop the ocaml.ppx.context attribute from a structure. If + [restore] is true, also restore the associated data in the current + process. *) -let native_name p = - if p.prim_native_name <> "" - then p.prim_native_name - else p.prim_name +val drop_ppx_context_sig: + restore:bool -> Parsetree.signature -> Parsetree.signature +(** Same as [drop_ppx_context_str], but for signatures. *) -let byte_name p = - p.prim_name +(** {1 Cookies} *) -let report_error ppf err = - match err with - | Old_style_float_with_native_repr_attribute -> - Format.fprintf ppf "Cannot use \"float\" in conjunction with \ - [%@unboxed]/[%@untagged]" - | Old_style_noalloc_with_noalloc_attribute -> - Format.fprintf ppf "Cannot use \"noalloc\" in conjunction with \ - [%@%@noalloc]" - | No_native_primitive_with_repr_attribute -> - Format.fprintf ppf - "The native code version of the primitive is mandatory when \ - attributes [%@untagged] or [%@unboxed] are present" +(** Cookies are used to pass information from a ppx processor to + a further invocation of itself, when called from the OCaml + toplevel (or other tools that support cookies). *) -let () = - Location.register_error_of_exn - (function - | Error (loc, err) -> - Some (Location.error_of_printer loc report_error err) - | _ -> - None - ) +val set_cookie: string -> Parsetree.expression -> unit +val get_cookie: string -> Parsetree.expression option -end -module Types : sig -#1 "types.mli" +end = struct +#1 "ast_mapper.ml" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* Alain Frisch, LexiFi *) (* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* Copyright 2012 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -30288,488 +14529,939 @@ module Types : sig (* *) (**************************************************************************) -(** {0 Representation of types and declarations} *) - -(** [Types] defines the representation of types and declarations (that is, the - content of module signatures). +(* A generic Parsetree mapping class *) - CMI files are made of marshalled types. +(* +[@@@ocaml.warning "+9"] + (* Ensure that record patterns don't miss any field. *) *) -(** Asttypes exposes basic definitions shared both by Parsetree and Types. *) -open Asttypes -(** Type expressions for the core language. +open Parsetree +open Ast_helper +open Location + +type mapper = { + attribute: mapper -> attribute -> attribute; + attributes: mapper -> attribute list -> attribute list; + case: mapper -> case -> case; + cases: mapper -> case list -> case list; + class_declaration: mapper -> class_declaration -> class_declaration; + class_description: mapper -> class_description -> class_description; + class_expr: mapper -> class_expr -> class_expr; + class_field: mapper -> class_field -> class_field; + class_signature: mapper -> class_signature -> class_signature; + class_structure: mapper -> class_structure -> class_structure; + class_type: mapper -> class_type -> class_type; + class_type_declaration: mapper -> class_type_declaration + -> class_type_declaration; + class_type_field: mapper -> class_type_field -> class_type_field; + constructor_declaration: mapper -> constructor_declaration + -> constructor_declaration; + expr: mapper -> expression -> expression; + extension: mapper -> extension -> extension; + extension_constructor: mapper -> extension_constructor + -> extension_constructor; + include_declaration: mapper -> include_declaration -> include_declaration; + include_description: mapper -> include_description -> include_description; + label_declaration: mapper -> label_declaration -> label_declaration; + location: mapper -> Location.t -> Location.t; + module_binding: mapper -> module_binding -> module_binding; + module_declaration: mapper -> module_declaration -> module_declaration; + module_expr: mapper -> module_expr -> module_expr; + module_type: mapper -> module_type -> module_type; + module_type_declaration: mapper -> module_type_declaration + -> module_type_declaration; + open_description: mapper -> open_description -> open_description; + pat: mapper -> pattern -> pattern; + payload: mapper -> payload -> payload; + signature: mapper -> signature -> signature; + signature_item: mapper -> signature_item -> signature_item; + structure: mapper -> structure -> structure; + structure_item: mapper -> structure_item -> structure_item; + typ: mapper -> core_type -> core_type; + type_declaration: mapper -> type_declaration -> type_declaration; + type_extension: mapper -> type_extension -> type_extension; + type_kind: mapper -> type_kind -> type_kind; + value_binding: mapper -> value_binding -> value_binding; + value_description: mapper -> value_description -> value_description; + with_constraint: mapper -> with_constraint -> with_constraint; +} + +let map_fst f (x, y) = (f x, y) +let map_snd f (x, y) = (x, f y) +let map_tuple f1 f2 (x, y) = (f1 x, f2 y) +let map_tuple3 f1 f2 f3 (x, y, z) = (f1 x, f2 y, f3 z) +let map_opt f = function None -> None | Some x -> Some (f x) + +let map_loc sub {loc; txt} = {loc = sub.location sub loc; txt} + +module T = struct + (* Type expressions for the core language *) + + let row_field sub = function + | Rtag (l, attrs, b, tl) -> + Rtag (map_loc sub l, sub.attributes sub attrs, + b, List.map (sub.typ sub) tl) + | Rinherit t -> Rinherit (sub.typ sub t) + + let object_field sub = function + | Otag (l, attrs, t) -> + Otag (map_loc sub l, sub.attributes sub attrs, sub.typ sub t) + | Oinherit t -> Oinherit (sub.typ sub t) - The [type_desc] variant defines all the possible type expressions one can - find in OCaml. [type_expr] wraps this with some annotations. + let map sub {ptyp_desc = desc; ptyp_loc = loc; ptyp_attributes = attrs} = + let open Typ in + let loc = sub.location sub loc in + let attrs = sub.attributes sub attrs in + match desc with + | Ptyp_any -> any ~loc ~attrs () + | Ptyp_var s -> var ~loc ~attrs s + | Ptyp_arrow (lab, t1, t2) -> + arrow ~loc ~attrs lab (sub.typ sub t1) (sub.typ sub t2) + | Ptyp_tuple tyl -> tuple ~loc ~attrs (List.map (sub.typ sub) tyl) + | Ptyp_constr (lid, tl) -> + constr ~loc ~attrs (map_loc sub lid) (List.map (sub.typ sub) tl) + | Ptyp_object (l, o) -> + object_ ~loc ~attrs (List.map (object_field sub) l) o + | Ptyp_class (lid, tl) -> + class_ ~loc ~attrs (map_loc sub lid) (List.map (sub.typ sub) tl) + | Ptyp_alias (t, s) -> alias ~loc ~attrs (sub.typ sub t) s + | Ptyp_variant (rl, b, ll) -> + variant ~loc ~attrs (List.map (row_field sub) rl) b ll + | Ptyp_poly (sl, t) -> poly ~loc ~attrs + (List.map (map_loc sub) sl) (sub.typ sub t) + | Ptyp_package (lid, l) -> + package ~loc ~attrs (map_loc sub lid) + (List.map (map_tuple (map_loc sub) (sub.typ sub)) l) + | Ptyp_extension x -> extension ~loc ~attrs (sub.extension sub x) - The [level] field tracks the level of polymorphism associated to a type, - guiding the generalization algorithm. - Put shortly, when referring to a type in a given environment, both the type - and the environment have a level. If the type has an higher level, then it - can be considered fully polymorphic (type variables will be printed as - ['a]), otherwise it'll be weakly polymorphic, or non generalized (type - variables printed as ['_a]). - See [http://okmij.org/ftp/ML/generalization.html] for more information. + let map_type_declaration sub + {ptype_name; ptype_params; ptype_cstrs; + ptype_kind; + ptype_private; + ptype_manifest; + ptype_attributes; + ptype_loc} = + Type.mk (map_loc sub ptype_name) + ~params:(List.map (map_fst (sub.typ sub)) ptype_params) + ~priv:ptype_private + ~cstrs:(List.map + (map_tuple3 (sub.typ sub) (sub.typ sub) (sub.location sub)) + ptype_cstrs) + ~kind:(sub.type_kind sub ptype_kind) + ?manifest:(map_opt (sub.typ sub) ptype_manifest) + ~loc:(sub.location sub ptype_loc) + ~attrs:(sub.attributes sub ptype_attributes) - Note about [type_declaration]: one should not make the confusion between - [type_expr] and [type_declaration]. + let map_type_kind sub = function + | Ptype_abstract -> Ptype_abstract + | Ptype_variant l -> + Ptype_variant (List.map (sub.constructor_declaration sub) l) + | Ptype_record l -> Ptype_record (List.map (sub.label_declaration sub) l) + | Ptype_open -> Ptype_open - [type_declaration] refers specifically to the [type] construct in OCaml - language, where you create and name a new type or type alias. + let map_constructor_arguments sub = function + | Pcstr_tuple l -> Pcstr_tuple (List.map (sub.typ sub) l) + | Pcstr_record l -> + Pcstr_record (List.map (sub.label_declaration sub) l) - [type_expr] is used when you refer to existing types, e.g. when annotating - the expected type of a value. + let map_type_extension sub + {ptyext_path; ptyext_params; + ptyext_constructors; + ptyext_private; + ptyext_attributes} = + Te.mk + (map_loc sub ptyext_path) + (List.map (sub.extension_constructor sub) ptyext_constructors) + ~params:(List.map (map_fst (sub.typ sub)) ptyext_params) + ~priv:ptyext_private + ~attrs:(sub.attributes sub ptyext_attributes) - Also, as the type system of OCaml is generative, a [type_declaration] can - have the side-effect of introducing a new type constructor, different from - all other known types. - Whereas [type_expr] is a pure construct which allows referring to existing - types. + let map_extension_constructor_kind sub = function + Pext_decl(ctl, cto) -> + Pext_decl(map_constructor_arguments sub ctl, map_opt (sub.typ sub) cto) + | Pext_rebind li -> + Pext_rebind (map_loc sub li) - Note on mutability: TBD. - *) -type type_expr = - { mutable desc: type_desc; - mutable level: int; - id: int } + let map_extension_constructor sub + {pext_name; + pext_kind; + pext_loc; + pext_attributes} = + Te.constructor + (map_loc sub pext_name) + (map_extension_constructor_kind sub pext_kind) + ~loc:(sub.location sub pext_loc) + ~attrs:(sub.attributes sub pext_attributes) -and type_desc = - | Tvar of string option - (** [Tvar (Some "a")] ==> ['a] or ['_a] - [Tvar None] ==> [_] *) +end - | Tarrow of arg_label * type_expr * type_expr * commutable - (** [Tarrow (Nolabel, e1, e2, c)] ==> [e1 -> e2] - [Tarrow (Labelled "l", e1, e2, c)] ==> [l:e1 -> e2] - [Tarrow (Optional "l", e1, e2, c)] ==> [?l:e1 -> e2] +module CT = struct + (* Type expressions for the class language *) - See [commutable] for the last argument. *) + let map sub {pcty_loc = loc; pcty_desc = desc; pcty_attributes = attrs} = + let open Cty in + let loc = sub.location sub loc in + let attrs = sub.attributes sub attrs in + match desc with + | Pcty_constr (lid, tys) -> + constr ~loc ~attrs (map_loc sub lid) (List.map (sub.typ sub) tys) + | Pcty_signature x -> signature ~loc ~attrs (sub.class_signature sub x) + | Pcty_arrow (lab, t, ct) -> + arrow ~loc ~attrs lab (sub.typ sub t) (sub.class_type sub ct) + | Pcty_extension x -> extension ~loc ~attrs (sub.extension sub x) + | Pcty_open (ovf, lid, ct) -> + open_ ~loc ~attrs ovf (map_loc sub lid) (sub.class_type sub ct) - | Ttuple of type_expr list - (** [Ttuple [t1;...;tn]] ==> [(t1 * ... * tn)] *) + let map_field sub {pctf_desc = desc; pctf_loc = loc; pctf_attributes = attrs} + = + let open Ctf in + let loc = sub.location sub loc in + let attrs = sub.attributes sub attrs in + match desc with + | Pctf_inherit ct -> inherit_ ~loc ~attrs (sub.class_type sub ct) + | Pctf_val (s, m, v, t) -> + val_ ~loc ~attrs (map_loc sub s) m v (sub.typ sub t) + | Pctf_method (s, p, v, t) -> + method_ ~loc ~attrs (map_loc sub s) p v (sub.typ sub t) + | Pctf_constraint (t1, t2) -> + constraint_ ~loc ~attrs (sub.typ sub t1) (sub.typ sub t2) + | Pctf_attribute x -> attribute ~loc (sub.attribute sub x) + | Pctf_extension x -> extension ~loc ~attrs (sub.extension sub x) - | Tconstr of Path.t * type_expr list * abbrev_memo ref - (** [Tconstr (`A.B.t', [t1;...;tn], _)] ==> [(t1,...,tn) A.B.t] - The last parameter keep tracks of known expansions, see [abbrev_memo]. *) + let map_signature sub {pcsig_self; pcsig_fields} = + Csig.mk + (sub.typ sub pcsig_self) + (List.map (sub.class_type_field sub) pcsig_fields) +end - | Tobject of type_expr * (Path.t * type_expr list) option ref - (** [Tobject (`f1:t1;...;fn: tn', `None')] ==> [< f1: t1; ...; fn: tn >] - f1, fn are represented as a linked list of types using Tfield and Tnil - constructors. +module MT = struct + (* Type expressions for the module language *) - [Tobject (_, `Some (`A.ct', [t1;...;tn]')] ==> [(t1, ..., tn) A.ct]. - where A.ct is the type of some class. + let map sub {pmty_desc = desc; pmty_loc = loc; pmty_attributes = attrs} = + let open Mty in + let loc = sub.location sub loc in + let attrs = sub.attributes sub attrs in + match desc with + | Pmty_ident s -> ident ~loc ~attrs (map_loc sub s) + | Pmty_alias s -> alias ~loc ~attrs (map_loc sub s) + | Pmty_signature sg -> signature ~loc ~attrs (sub.signature sub sg) + | Pmty_functor (s, mt1, mt2) -> + functor_ ~loc ~attrs (map_loc sub s) + (Misc.may_map (sub.module_type sub) mt1) + (sub.module_type sub mt2) + | Pmty_with (mt, l) -> + with_ ~loc ~attrs (sub.module_type sub mt) + (List.map (sub.with_constraint sub) l) + | Pmty_typeof me -> typeof_ ~loc ~attrs (sub.module_expr sub me) + | Pmty_extension x -> extension ~loc ~attrs (sub.extension sub x) - There are also special cases for so-called "class-types", cf. [Typeclass] - and [Ctype.set_object_name]: + let map_with_constraint sub = function + | Pwith_type (lid, d) -> + Pwith_type (map_loc sub lid, sub.type_declaration sub d) + | Pwith_module (lid, lid2) -> + Pwith_module (map_loc sub lid, map_loc sub lid2) + | Pwith_typesubst (lid, d) -> + Pwith_typesubst (map_loc sub lid, sub.type_declaration sub d) + | Pwith_modsubst (s, lid) -> + Pwith_modsubst (map_loc sub s, map_loc sub lid) - [Tobject (Tfield(_,_,...(Tfield(_,_,rv)...), - Some(`A.#ct`, [rv;t1;...;tn])] - ==> [(t1, ..., tn) #A.ct] - [Tobject (_, Some(`A.#ct`, [Tnil;t1;...;tn])] ==> [(t1, ..., tn) A.ct] + let map_signature_item sub {psig_desc = desc; psig_loc = loc} = + let open Sig in + let loc = sub.location sub loc in + match desc with + | Psig_value vd -> value ~loc (sub.value_description sub vd) + | Psig_type (rf, l) -> type_ ~loc rf (List.map (sub.type_declaration sub) l) + | Psig_typext te -> type_extension ~loc (sub.type_extension sub te) + | Psig_exception ed -> exception_ ~loc (sub.extension_constructor sub ed) + | Psig_module x -> module_ ~loc (sub.module_declaration sub x) + | Psig_recmodule l -> + rec_module ~loc (List.map (sub.module_declaration sub) l) + | Psig_modtype x -> modtype ~loc (sub.module_type_declaration sub x) + | Psig_open x -> open_ ~loc (sub.open_description sub x) + | Psig_include x -> include_ ~loc (sub.include_description sub x) + | Psig_class l -> class_ ~loc (List.map (sub.class_description sub) l) + | Psig_class_type l -> + class_type ~loc (List.map (sub.class_type_declaration sub) l) + | Psig_extension (x, attrs) -> + extension ~loc (sub.extension sub x) ~attrs:(sub.attributes sub attrs) + | Psig_attribute x -> attribute ~loc (sub.attribute sub x) +end - where [rv] is the hidden row variable. - *) - | Tfield of string * field_kind * type_expr * type_expr - (** [Tfield ("foo", Fpresent, t, ts)] ==> [<...; foo : t; ts>] *) +module M = struct + (* Value expressions for the module language *) - | Tnil - (** [Tnil] ==> [<...; >] *) + let map sub {pmod_loc = loc; pmod_desc = desc; pmod_attributes = attrs} = + let open Mod in + let loc = sub.location sub loc in + let attrs = sub.attributes sub attrs in + match desc with + | Pmod_ident x -> ident ~loc ~attrs (map_loc sub x) + | Pmod_structure str -> structure ~loc ~attrs (sub.structure sub str) + | Pmod_functor (arg, arg_ty, body) -> + functor_ ~loc ~attrs (map_loc sub arg) + (Misc.may_map (sub.module_type sub) arg_ty) + (sub.module_expr sub body) + | Pmod_apply (m1, m2) -> + apply ~loc ~attrs (sub.module_expr sub m1) (sub.module_expr sub m2) + | Pmod_constraint (m, mty) -> + constraint_ ~loc ~attrs (sub.module_expr sub m) + (sub.module_type sub mty) + | Pmod_unpack e -> unpack ~loc ~attrs (sub.expr sub e) + | Pmod_extension x -> extension ~loc ~attrs (sub.extension sub x) - | Tlink of type_expr - (** Indirection used by unification engine. *) + let map_structure_item sub {pstr_loc = loc; pstr_desc = desc} = + let open Str in + let loc = sub.location sub loc in + match desc with + | Pstr_eval (x, attrs) -> + eval ~loc ~attrs:(sub.attributes sub attrs) (sub.expr sub x) + | Pstr_value (r, vbs) -> value ~loc r (List.map (sub.value_binding sub) vbs) + | Pstr_primitive vd -> primitive ~loc (sub.value_description sub vd) + | Pstr_type (rf, l) -> type_ ~loc rf (List.map (sub.type_declaration sub) l) + | Pstr_typext te -> type_extension ~loc (sub.type_extension sub te) + | Pstr_exception ed -> exception_ ~loc (sub.extension_constructor sub ed) + | Pstr_module x -> module_ ~loc (sub.module_binding sub x) + | Pstr_recmodule l -> rec_module ~loc (List.map (sub.module_binding sub) l) + | Pstr_modtype x -> modtype ~loc (sub.module_type_declaration sub x) + | Pstr_open x -> open_ ~loc (sub.open_description sub x) + | Pstr_class l -> class_ ~loc (List.map (sub.class_declaration sub) l) + | Pstr_class_type l -> + class_type ~loc (List.map (sub.class_type_declaration sub) l) + | Pstr_include x -> include_ ~loc (sub.include_declaration sub x) + | Pstr_extension (x, attrs) -> + extension ~loc (sub.extension sub x) ~attrs:(sub.attributes sub attrs) + | Pstr_attribute x -> attribute ~loc (sub.attribute sub x) +end - | Tsubst of type_expr (* for copying *) - (** [Tsubst] is used temporarily to store information in low-level - functions manipulating representation of types, such as - instantiation or copy. - This constructor should not appear outside of these cases. *) +module E = struct + (* Value expressions for the core language *) - | Tvariant of row_desc - (** Representation of polymorphic variants, see [row_desc]. *) + let map sub {pexp_loc = loc; pexp_desc = desc; pexp_attributes = attrs} = + let open Exp in + let loc = sub.location sub loc in + let attrs = sub.attributes sub attrs in + match desc with + | Pexp_ident x -> ident ~loc ~attrs (map_loc sub x) + | Pexp_constant x -> constant ~loc ~attrs x + | Pexp_let (r, vbs, e) -> + let_ ~loc ~attrs r (List.map (sub.value_binding sub) vbs) + (sub.expr sub e) + | Pexp_fun (lab, def, p, e) -> + fun_ ~loc ~attrs lab (map_opt (sub.expr sub) def) (sub.pat sub p) + (sub.expr sub e) + | Pexp_function pel -> function_ ~loc ~attrs (sub.cases sub pel) + | Pexp_apply (e, l) -> + apply ~loc ~attrs (sub.expr sub e) (List.map (map_snd (sub.expr sub)) l) + | Pexp_match (e, pel) -> + match_ ~loc ~attrs (sub.expr sub e) (sub.cases sub pel) + | Pexp_try (e, pel) -> try_ ~loc ~attrs (sub.expr sub e) (sub.cases sub pel) + | Pexp_tuple el -> tuple ~loc ~attrs (List.map (sub.expr sub) el) + | Pexp_construct (lid, arg) -> + construct ~loc ~attrs (map_loc sub lid) (map_opt (sub.expr sub) arg) + | Pexp_variant (lab, eo) -> + variant ~loc ~attrs lab (map_opt (sub.expr sub) eo) + | Pexp_record (l, eo) -> + record ~loc ~attrs (List.map (map_tuple (map_loc sub) (sub.expr sub)) l) + (map_opt (sub.expr sub) eo) + | Pexp_field (e, lid) -> + field ~loc ~attrs (sub.expr sub e) (map_loc sub lid) + | Pexp_setfield (e1, lid, e2) -> + setfield ~loc ~attrs (sub.expr sub e1) (map_loc sub lid) + (sub.expr sub e2) + | Pexp_array el -> array ~loc ~attrs (List.map (sub.expr sub) el) + | Pexp_ifthenelse (e1, e2, e3) -> + ifthenelse ~loc ~attrs (sub.expr sub e1) (sub.expr sub e2) + (map_opt (sub.expr sub) e3) + | Pexp_sequence (e1, e2) -> + sequence ~loc ~attrs (sub.expr sub e1) (sub.expr sub e2) + | Pexp_while (e1, e2) -> + while_ ~loc ~attrs (sub.expr sub e1) (sub.expr sub e2) + | Pexp_for (p, e1, e2, d, e3) -> + for_ ~loc ~attrs (sub.pat sub p) (sub.expr sub e1) (sub.expr sub e2) d + (sub.expr sub e3) + | Pexp_coerce (e, t1, t2) -> + coerce ~loc ~attrs (sub.expr sub e) (map_opt (sub.typ sub) t1) + (sub.typ sub t2) + | Pexp_constraint (e, t) -> + constraint_ ~loc ~attrs (sub.expr sub e) (sub.typ sub t) + | Pexp_send (e, s) -> + send ~loc ~attrs (sub.expr sub e) (map_loc sub s) + | Pexp_new lid -> new_ ~loc ~attrs (map_loc sub lid) + | Pexp_setinstvar (s, e) -> + setinstvar ~loc ~attrs (map_loc sub s) (sub.expr sub e) + | Pexp_override sel -> + override ~loc ~attrs + (List.map (map_tuple (map_loc sub) (sub.expr sub)) sel) + | Pexp_letmodule (s, me, e) -> + letmodule ~loc ~attrs (map_loc sub s) (sub.module_expr sub me) + (sub.expr sub e) + | Pexp_letexception (cd, e) -> + letexception ~loc ~attrs + (sub.extension_constructor sub cd) + (sub.expr sub e) + | Pexp_assert e -> assert_ ~loc ~attrs (sub.expr sub e) + | Pexp_lazy e -> lazy_ ~loc ~attrs (sub.expr sub e) + | Pexp_poly (e, t) -> + poly ~loc ~attrs (sub.expr sub e) (map_opt (sub.typ sub) t) + | Pexp_object cls -> object_ ~loc ~attrs (sub.class_structure sub cls) + | Pexp_newtype (s, e) -> + newtype ~loc ~attrs (map_loc sub s) (sub.expr sub e) + | Pexp_pack me -> pack ~loc ~attrs (sub.module_expr sub me) + | Pexp_open (ovf, lid, e) -> + open_ ~loc ~attrs ovf (map_loc sub lid) (sub.expr sub e) + | Pexp_extension x -> extension ~loc ~attrs (sub.extension sub x) + | Pexp_unreachable -> unreachable ~loc ~attrs () +end - | Tunivar of string option - (** Occurrence of a type variable introduced by a - forall quantifier / [Tpoly]. *) +module P = struct + (* Patterns *) - | Tpoly of type_expr * type_expr list - (** [Tpoly (ty,tyl)] ==> ['a1... 'an. ty], - where 'a1 ... 'an are names given to types in tyl - and occurrences of those types in ty. *) + let map sub {ppat_desc = desc; ppat_loc = loc; ppat_attributes = attrs} = + let open Pat in + let loc = sub.location sub loc in + let attrs = sub.attributes sub attrs in + match desc with + | Ppat_any -> any ~loc ~attrs () + | Ppat_var s -> var ~loc ~attrs (map_loc sub s) + | Ppat_alias (p, s) -> alias ~loc ~attrs (sub.pat sub p) (map_loc sub s) + | Ppat_constant c -> constant ~loc ~attrs c + | Ppat_interval (c1, c2) -> interval ~loc ~attrs c1 c2 + | Ppat_tuple pl -> tuple ~loc ~attrs (List.map (sub.pat sub) pl) + | Ppat_construct (l, p) -> + construct ~loc ~attrs (map_loc sub l) (map_opt (sub.pat sub) p) + | Ppat_variant (l, p) -> variant ~loc ~attrs l (map_opt (sub.pat sub) p) + | Ppat_record (lpl, cf) -> + record ~loc ~attrs + (List.map (map_tuple (map_loc sub) (sub.pat sub)) lpl) cf + | Ppat_array pl -> array ~loc ~attrs (List.map (sub.pat sub) pl) + | Ppat_or (p1, p2) -> or_ ~loc ~attrs (sub.pat sub p1) (sub.pat sub p2) + | Ppat_constraint (p, t) -> + constraint_ ~loc ~attrs (sub.pat sub p) (sub.typ sub t) + | Ppat_type s -> type_ ~loc ~attrs (map_loc sub s) + | Ppat_lazy p -> lazy_ ~loc ~attrs (sub.pat sub p) + | Ppat_unpack s -> unpack ~loc ~attrs (map_loc sub s) + | Ppat_open (lid,p) -> open_ ~loc ~attrs (map_loc sub lid) (sub.pat sub p) + | Ppat_exception p -> exception_ ~loc ~attrs (sub.pat sub p) + | Ppat_extension x -> extension ~loc ~attrs (sub.extension sub x) +end - | Tpackage of Path.t * Longident.t list * type_expr list - (** Type of a first-class module (a.k.a package). *) +module CE = struct + (* Value expressions for the class language *) -(** [ `X | `Y ] (row_closed = true) - [< `X | `Y ] (row_closed = true) - [> `X | `Y ] (row_closed = false) - [< `X | `Y > `X ] (row_closed = true) + let map sub {pcl_loc = loc; pcl_desc = desc; pcl_attributes = attrs} = + let open Cl in + let loc = sub.location sub loc in + let attrs = sub.attributes sub attrs in + match desc with + | Pcl_constr (lid, tys) -> + constr ~loc ~attrs (map_loc sub lid) (List.map (sub.typ sub) tys) + | Pcl_structure s -> + structure ~loc ~attrs (sub.class_structure sub s) + | Pcl_fun (lab, e, p, ce) -> + fun_ ~loc ~attrs lab + (map_opt (sub.expr sub) e) + (sub.pat sub p) + (sub.class_expr sub ce) + | Pcl_apply (ce, l) -> + apply ~loc ~attrs (sub.class_expr sub ce) + (List.map (map_snd (sub.expr sub)) l) + | Pcl_let (r, vbs, ce) -> + let_ ~loc ~attrs r (List.map (sub.value_binding sub) vbs) + (sub.class_expr sub ce) + | Pcl_constraint (ce, ct) -> + constraint_ ~loc ~attrs (sub.class_expr sub ce) (sub.class_type sub ct) + | Pcl_extension x -> extension ~loc ~attrs (sub.extension sub x) + | Pcl_open (ovf, lid, ce) -> + open_ ~loc ~attrs ovf (map_loc sub lid) (sub.class_expr sub ce) - type t = [> `X ] as 'a (row_more = Tvar a) - type t = private [> `X ] (row_more = Tconstr (t#row, [], ref Mnil) + let map_kind sub = function + | Cfk_concrete (o, e) -> Cfk_concrete (o, sub.expr sub e) + | Cfk_virtual t -> Cfk_virtual (sub.typ sub t) - And for: + let map_field sub {pcf_desc = desc; pcf_loc = loc; pcf_attributes = attrs} = + let open Cf in + let loc = sub.location sub loc in + let attrs = sub.attributes sub attrs in + match desc with + | Pcf_inherit (o, ce, s) -> + inherit_ ~loc ~attrs o (sub.class_expr sub ce) + (map_opt (map_loc sub) s) + | Pcf_val (s, m, k) -> val_ ~loc ~attrs (map_loc sub s) m (map_kind sub k) + | Pcf_method (s, p, k) -> + method_ ~loc ~attrs (map_loc sub s) p (map_kind sub k) + | Pcf_constraint (t1, t2) -> + constraint_ ~loc ~attrs (sub.typ sub t1) (sub.typ sub t2) + | Pcf_initializer e -> initializer_ ~loc ~attrs (sub.expr sub e) + | Pcf_attribute x -> attribute ~loc (sub.attribute sub x) + | Pcf_extension x -> extension ~loc ~attrs (sub.extension sub x) - let f = function `X -> `X -> | `Y -> `X + let map_structure sub {pcstr_self; pcstr_fields} = + { + pcstr_self = sub.pat sub pcstr_self; + pcstr_fields = List.map (sub.class_field sub) pcstr_fields; + } - the type of "f" will be a [Tarrow] whose lhs will (basically) be: + let class_infos sub f {pci_virt; pci_params = pl; pci_name; pci_expr; + pci_loc; pci_attributes} = + Ci.mk + ~virt:pci_virt + ~params:(List.map (map_fst (sub.typ sub)) pl) + (map_loc sub pci_name) + (f pci_expr) + ~loc:(sub.location sub pci_loc) + ~attrs:(sub.attributes sub pci_attributes) +end - Tvariant { row_fields = [("X", _)]; - row_more = - Tvariant { row_fields = [("Y", _)]; - row_more = - Tvariant { row_fields = []; - row_more = _; - _ }; - _ }; - _ - } +(* Now, a generic AST mapper, to be extended to cover all kinds and + cases of the OCaml grammar. The default behavior of the mapper is + the identity. *) -*) -and row_desc = - { row_fields: (label * row_field) list; - row_more: type_expr; - row_bound: unit; (* kept for compatibility *) - row_closed: bool; - row_fixed: bool; - row_name: (Path.t * type_expr list) option } +let default_mapper = + { + structure = (fun this l -> List.map (this.structure_item this) l); + structure_item = M.map_structure_item; + module_expr = M.map; + signature = (fun this l -> List.map (this.signature_item this) l); + signature_item = MT.map_signature_item; + module_type = MT.map; + with_constraint = MT.map_with_constraint; + class_declaration = + (fun this -> CE.class_infos this (this.class_expr this)); + class_expr = CE.map; + class_field = CE.map_field; + class_structure = CE.map_structure; + class_type = CT.map; + class_type_field = CT.map_field; + class_signature = CT.map_signature; + class_type_declaration = + (fun this -> CE.class_infos this (this.class_type this)); + class_description = + (fun this -> CE.class_infos this (this.class_type this)); + type_declaration = T.map_type_declaration; + type_kind = T.map_type_kind; + typ = T.map; + type_extension = T.map_type_extension; + extension_constructor = T.map_extension_constructor; + value_description = + (fun this {pval_name; pval_type; pval_prim; pval_loc; + pval_attributes} -> + Val.mk + (map_loc this pval_name) + (this.typ this pval_type) + ~attrs:(this.attributes this pval_attributes) + ~loc:(this.location this pval_loc) + ~prim:pval_prim + ); -and row_field = - Rpresent of type_expr option - | Reither of bool * type_expr list * bool * row_field option ref - (* 1st true denotes a constant constructor *) - (* 2nd true denotes a tag in a pattern matching, and - is erased later *) - | Rabsent + pat = P.map; + expr = E.map; -(** [abbrev_memo] allows one to keep track of different expansions of a type - alias. This is done for performance purposes. + module_declaration = + (fun this {pmd_name; pmd_type; pmd_attributes; pmd_loc} -> + Md.mk + (map_loc this pmd_name) + (this.module_type this pmd_type) + ~attrs:(this.attributes this pmd_attributes) + ~loc:(this.location this pmd_loc) + ); - For instance, when defining [type 'a pair = 'a * 'a], when one refers to an - ['a pair], it is just a shortcut for the ['a * 'a] type. - This expansion will be stored in the [abbrev_memo] of the corresponding - [Tconstr] node. + module_type_declaration = + (fun this {pmtd_name; pmtd_type; pmtd_attributes; pmtd_loc} -> + Mtd.mk + (map_loc this pmtd_name) + ?typ:(map_opt (this.module_type this) pmtd_type) + ~attrs:(this.attributes this pmtd_attributes) + ~loc:(this.location this pmtd_loc) + ); - In practice, [abbrev_memo] behaves like list of expansions with a mutable - tail. + module_binding = + (fun this {pmb_name; pmb_expr; pmb_attributes; pmb_loc} -> + Mb.mk (map_loc this pmb_name) (this.module_expr this pmb_expr) + ~attrs:(this.attributes this pmb_attributes) + ~loc:(this.location this pmb_loc) + ); - Note on marshalling: [abbrev_memo] must not appear in saved types. - [Btype], with [cleanup_abbrev] and [memo], takes care of tracking and - removing abbreviations. -*) -and abbrev_memo = - | Mnil (** No known abbreviation *) - | Mcons of private_flag * Path.t * type_expr * type_expr * abbrev_memo - (** Found one abbreviation. - A valid abbreviation should be at least as visible and reachable by the - same path. - The first expression is the abbreviation and the second the expansion. *) + open_description = + (fun this {popen_lid; popen_override; popen_attributes; popen_loc} -> + Opn.mk (map_loc this popen_lid) + ~override:popen_override + ~loc:(this.location this popen_loc) + ~attrs:(this.attributes this popen_attributes) + ); - | Mlink of abbrev_memo ref - (** Abbreviations can be found after this indirection *) -and field_kind = - Fvar of field_kind option ref - | Fpresent - | Fabsent + include_description = + (fun this {pincl_mod; pincl_attributes; pincl_loc} -> + Incl.mk (this.module_type this pincl_mod) + ~loc:(this.location this pincl_loc) + ~attrs:(this.attributes this pincl_attributes) + ); -(** [commutable] is a flag appended to every arrow type. + include_declaration = + (fun this {pincl_mod; pincl_attributes; pincl_loc} -> + Incl.mk (this.module_expr this pincl_mod) + ~loc:(this.location this pincl_loc) + ~attrs:(this.attributes this pincl_attributes) + ); - When typing an application, if the type of the functional is - known, its type is instantiated with [Cok] arrows, otherwise as - [Clink (ref Cunknown)]. - When the type is not known, the application will be used to infer - the actual type. This is fragile in presence of labels where - there is no principal type. + value_binding = + (fun this {pvb_pat; pvb_expr; pvb_attributes; pvb_loc} -> + Vb.mk + (this.pat this pvb_pat) + (this.expr this pvb_expr) + ~loc:(this.location this pvb_loc) + ~attrs:(this.attributes this pvb_attributes) + ); - Two incompatible applications relying on [Cunknown] arrows will - trigger an error. - let f g = - g ~a:() ~b:(); - g ~b:() ~a:(); + constructor_declaration = + (fun this {pcd_name; pcd_args; pcd_res; pcd_loc; pcd_attributes} -> + Type.constructor + (map_loc this pcd_name) + ~args:(T.map_constructor_arguments this pcd_args) + ?res:(map_opt (this.typ this) pcd_res) + ~loc:(this.location this pcd_loc) + ~attrs:(this.attributes this pcd_attributes) + ); - Error: This function is applied to arguments - in an order different from other calls. - This is only allowed when the real type is known. -*) -and commutable = - Cok - | Cunknown - | Clink of commutable ref + label_declaration = + (fun this {pld_name; pld_type; pld_loc; pld_mutable; pld_attributes} -> + Type.field + (map_loc this pld_name) + (this.typ this pld_type) + ~mut:pld_mutable + ~loc:(this.location this pld_loc) + ~attrs:(this.attributes this pld_attributes) + ); -module TypeOps : sig - type t = type_expr - val compare : t -> t -> int - val equal : t -> t -> bool - val hash : t -> int -end + cases = (fun this l -> List.map (this.case this) l); + case = + (fun this {pc_lhs; pc_guard; pc_rhs} -> + { + pc_lhs = this.pat this pc_lhs; + pc_guard = map_opt (this.expr this) pc_guard; + pc_rhs = this.expr this pc_rhs; + } + ); -(* Maps of methods and instance variables *) -module Meths : Map.S with type key = string -module Vars : Map.S with type key = string -(* Value descriptions *) + location = (fun _this l -> l); -type value_description = - { val_type: type_expr; (* Type of the value *) - val_kind: value_kind; - val_loc: Location.t; - val_attributes: Parsetree.attributes; - } + extension = (fun this (s, e) -> (map_loc this s, this.payload this e)); + attribute = (fun this (s, e) -> (map_loc this s, this.payload this e)); + attributes = (fun this l -> List.map (this.attribute this) l); + payload = + (fun this -> function + | PStr x -> PStr (this.structure this x) + | PSig x -> PSig (this.signature this x) + | PTyp x -> PTyp (this.typ this x) + | PPat (x, g) -> PPat (this.pat this x, map_opt (this.expr this) g) + ); + } -and value_kind = - Val_reg (* Regular value *) - | Val_prim of Primitive.description (* Primitive *) - | Val_ivar of mutable_flag * string (* Instance variable (mutable ?) *) - | Val_self of (Ident.t * type_expr) Meths.t ref * - (Ident.t * mutable_flag * virtual_flag * type_expr) Vars.t ref * - string * type_expr - (* Self *) - | Val_anc of (string * Ident.t) list * string - (* Ancestor *) - | Val_unbound (* Unbound variable *) +let rec extension_of_error {loc; msg; if_highlight; sub} = + { loc; txt = "ocaml.error" }, + PStr ([Str.eval (Exp.constant (Pconst_string (msg, None))); + Str.eval (Exp.constant (Pconst_string (if_highlight, None)))] @ + (List.map (fun ext -> Str.extension (extension_of_error ext)) sub)) -(* Variance *) +let attribute_of_warning loc s = + { loc; txt = "ocaml.ppwarning" }, + PStr ([Str.eval ~loc (Exp.constant (Pconst_string (s, None)))]) -module Variance : sig - type t - type f = May_pos | May_neg | May_weak | Inj | Pos | Neg | Inv - val null : t (* no occurrence *) - val full : t (* strictly invariant *) - val covariant : t (* strictly covariant *) - val may_inv : t (* maybe invariant *) - val union : t -> t -> t - val inter : t -> t -> t - val subset : t -> t -> bool - val set : f -> bool -> t -> t - val mem : f -> t -> bool - val conjugate : t -> t (* exchange positive and negative *) - val get_upper : t -> bool * bool (* may_pos, may_neg *) - val get_lower : t -> bool * bool * bool * bool (* pos, neg, inv, inj *) -end +module StringMap = Map.Make(struct + type t = string + let compare = compare +end) -(* Type definitions *) +let cookies = ref StringMap.empty -type type_declaration = - { type_params: type_expr list; - type_arity: int; - type_kind: type_kind; - type_private: private_flag; - type_manifest: type_expr option; - type_variance: Variance.t list; - (* covariant, contravariant, weakly contravariant, injective *) - type_newtype_level: (int * int) option; - (* definition level * expansion level *) - type_loc: Location.t; - type_attributes: Parsetree.attributes; - type_immediate: bool; (* true iff type should not be a pointer *) - type_unboxed: unboxed_status; - } +let get_cookie k = + try Some (StringMap.find k !cookies) + with Not_found -> None -and type_kind = - Type_abstract - | Type_record of label_declaration list * record_representation - | Type_variant of constructor_declaration list - | Type_open +let set_cookie k v = + cookies := StringMap.add k v !cookies -and record_representation = - Record_regular (* All fields are boxed / tagged *) - | Record_float (* All fields are floats *) - | Record_unboxed of bool (* Unboxed single-field record, inlined or not *) - | Record_inlined of { tag : int ; name : string; num_nonconsts : int} (* Inlined record *) - | Record_extension (* Inlined record under extension *) +let tool_name_ref = ref "_none_" -and label_declaration = - { - ld_id: Ident.t; - ld_mutable: mutable_flag; - ld_type: type_expr; - ld_loc: Location.t; - ld_attributes: Parsetree.attributes; - } +let tool_name () = !tool_name_ref -and constructor_declaration = - { - cd_id: Ident.t; - cd_args: constructor_arguments; - cd_res: type_expr option; - cd_loc: Location.t; - cd_attributes: Parsetree.attributes; - } -and constructor_arguments = - | Cstr_tuple of type_expr list - | Cstr_record of label_declaration list +module PpxContext = struct + open Longident + open Asttypes + open Ast_helper -and unboxed_status = private - (* This type must be private in order to ensure perfect sharing of the - four possible values. Otherwise, ocamlc.byte and ocamlc.opt produce - different executables. *) - { - unboxed: bool; - default: bool; (* True for unannotated unboxable types. *) - } + let lid name = { txt = Lident name; loc = Location.none } -val unboxed_false_default_false : unboxed_status -val unboxed_false_default_true : unboxed_status -val unboxed_true_default_false : unboxed_status -val unboxed_true_default_true : unboxed_status + let make_string x = Exp.constant (Pconst_string (x, None)) -type extension_constructor = - { - ext_type_path: Path.t; - ext_type_params: type_expr list; - ext_args: constructor_arguments; - ext_ret_type: type_expr option; - ext_private: private_flag; - ext_loc: Location.t; - ext_attributes: Parsetree.attributes; - } + let make_bool x = + if x + then Exp.construct (lid "true") None + else Exp.construct (lid "false") None -and type_transparence = - Type_public (* unrestricted expansion *) - | Type_new (* "new" type *) - | Type_private (* private type *) + let rec make_list f lst = + match lst with + | x :: rest -> + Exp.construct (lid "::") (Some (Exp.tuple [f x; make_list f rest])) + | [] -> + Exp.construct (lid "[]") None -(* Type expressions for the class language *) + let make_pair f1 f2 (x1, x2) = + Exp.tuple [f1 x1; f2 x2] -module Concr : Set.S with type elt = string + let make_option f opt = + match opt with + | Some x -> Exp.construct (lid "Some") (Some (f x)) + | None -> Exp.construct (lid "None") None -type class_type = - Cty_constr of Path.t * type_expr list * class_type - | Cty_signature of class_signature - | Cty_arrow of arg_label * type_expr * class_type + let get_cookies () = + lid "cookies", + make_list (make_pair make_string (fun x -> x)) + (StringMap.bindings !cookies) -and class_signature = - { csig_self: type_expr; - csig_vars: - (Asttypes.mutable_flag * Asttypes.virtual_flag * type_expr) Vars.t; - csig_concr: Concr.t; - csig_inher: (Path.t * type_expr list) list } + let mk fields = + { txt = "ocaml.ppx.context"; loc = Location.none }, + Parsetree.PStr [Str.eval (Exp.record fields None)] -type class_declaration = - { cty_params: type_expr list; - mutable cty_type: class_type; - cty_path: Path.t; - cty_new: type_expr option; - cty_variance: Variance.t list; - cty_loc: Location.t; - cty_attributes: Parsetree.attributes; - } + let make ~tool_name () = + let fields = + [ + lid "tool_name", make_string tool_name; + lid "include_dirs", make_list make_string !Clflags.include_dirs; + lid "load_path", make_list make_string !Config.load_path; + lid "open_modules", make_list make_string !Clflags.open_modules; + lid "for_package", make_option make_string !Clflags.for_package; + lid "debug", make_bool !Clflags.debug; + lid "use_threads", make_bool !Clflags.use_threads; + lid "use_vmthreads", make_bool !Clflags.use_vmthreads; + get_cookies () + ] + in + mk fields -type class_type_declaration = - { clty_params: type_expr list; - clty_type: class_type; - clty_path: Path.t; - clty_variance: Variance.t list; - clty_loc: Location.t; - clty_attributes: Parsetree.attributes; - } + let get_fields = function + | PStr [{pstr_desc = Pstr_eval + ({ pexp_desc = Pexp_record (fields, None) }, [])}] -> + fields + | _ -> + raise_errorf "Internal error: invalid [@@@ocaml.ppx.context] syntax" -(* Type expressions for the module language *) + let restore fields = + let field name payload = + let rec get_string = function + | { pexp_desc = Pexp_constant (Pconst_string (str, None)) } -> str + | _ -> raise_errorf "Internal error: invalid [@@@ocaml.ppx.context \ + { %s }] string syntax" name + and get_bool pexp = + match pexp with + | {pexp_desc = Pexp_construct ({txt = Longident.Lident "true"}, + None)} -> + true + | {pexp_desc = Pexp_construct ({txt = Longident.Lident "false"}, + None)} -> + false + | _ -> raise_errorf "Internal error: invalid [@@@ocaml.ppx.context \ + { %s }] bool syntax" name + and get_list elem = function + | {pexp_desc = + Pexp_construct ({txt = Longident.Lident "::"}, + Some {pexp_desc = Pexp_tuple [exp; rest]}) } -> + elem exp :: get_list elem rest + | {pexp_desc = + Pexp_construct ({txt = Longident.Lident "[]"}, None)} -> + [] + | _ -> raise_errorf "Internal error: invalid [@@@ocaml.ppx.context \ + { %s }] list syntax" name + and get_pair f1 f2 = function + | {pexp_desc = Pexp_tuple [e1; e2]} -> + (f1 e1, f2 e2) + | _ -> raise_errorf "Internal error: invalid [@@@ocaml.ppx.context \ + { %s }] pair syntax" name + and get_option elem = function + | { pexp_desc = + Pexp_construct ({ txt = Longident.Lident "Some" }, Some exp) } -> + Some (elem exp) + | { pexp_desc = + Pexp_construct ({ txt = Longident.Lident "None" }, None) } -> + None + | _ -> raise_errorf "Internal error: invalid [@@@ocaml.ppx.context \ + { %s }] option syntax" name + in + match name with + | "tool_name" -> + tool_name_ref := get_string payload + | "include_dirs" -> + Clflags.include_dirs := get_list get_string payload + | "load_path" -> + Config.load_path := get_list get_string payload + | "open_modules" -> + Clflags.open_modules := get_list get_string payload + | "for_package" -> + Clflags.for_package := get_option get_string payload + | "debug" -> + Clflags.debug := get_bool payload + | "use_threads" -> + Clflags.use_threads := get_bool payload + | "use_vmthreads" -> + Clflags.use_vmthreads := get_bool payload + | "cookies" -> + let l = get_list (get_pair get_string (fun x -> x)) payload in + cookies := + List.fold_left + (fun s (k, v) -> StringMap.add k v s) StringMap.empty + l + | _ -> + () + in + List.iter (function ({txt=Lident name}, x) -> field name x | _ -> ()) fields -type module_type = - Mty_ident of Path.t - | Mty_signature of signature - | Mty_functor of Ident.t * module_type option * module_type - | Mty_alias of alias_presence * Path.t + let update_cookies fields = + let fields = + List.filter + (function ({txt=Lident "cookies"}, _) -> false | _ -> true) + fields + in + fields @ [get_cookies ()] +end -and alias_presence = - | Mta_present - | Mta_absent +let ppx_context = PpxContext.make -and signature = signature_item list +let extension_of_exn exn = + match error_of_exn exn with + | Some (`Ok error) -> extension_of_error error + | Some `Already_displayed -> { loc = Location.none; txt = "ocaml.error" }, PStr [] + | None -> raise exn -and signature_item = - Sig_value of Ident.t * value_description - | Sig_type of Ident.t * type_declaration * rec_status - | Sig_typext of Ident.t * extension_constructor * ext_status - | Sig_module of Ident.t * module_declaration * rec_status - | Sig_modtype of Ident.t * modtype_declaration - | Sig_class of Ident.t * class_declaration * rec_status - | Sig_class_type of Ident.t * class_type_declaration * rec_status -and module_declaration = - { - md_type: module_type; - md_attributes: Parsetree.attributes; - md_loc: Location.t; - } +let apply_lazy ~source ~target mapper = + let implem ast = + let fields, ast = + match ast with + | {pstr_desc = Pstr_attribute ({txt = "ocaml.ppx.context"}, x)} :: l -> + PpxContext.get_fields x, l + | _ -> [], ast + in + PpxContext.restore fields; + let ast = + try + let mapper = mapper () in + mapper.structure mapper ast + with exn -> + [{pstr_desc = Pstr_extension (extension_of_exn exn, []); + pstr_loc = Location.none}] + in + let fields = PpxContext.update_cookies fields in + Str.attribute (PpxContext.mk fields) :: ast + in + let iface ast = + let fields, ast = + match ast with + | {psig_desc = Psig_attribute ({txt = "ocaml.ppx.context"}, x)} :: l -> + PpxContext.get_fields x, l + | _ -> [], ast + in + PpxContext.restore fields; + let ast = + try + let mapper = mapper () in + mapper.signature mapper ast + with exn -> + [{psig_desc = Psig_extension (extension_of_exn exn, []); + psig_loc = Location.none}] + in + let fields = PpxContext.update_cookies fields in + Sig.attribute (PpxContext.mk fields) :: ast + in -and modtype_declaration = - { - mtd_type: module_type option; (* None: abstract *) - mtd_attributes: Parsetree.attributes; - mtd_loc: Location.t; - } + let ic = open_in_bin source in + let magic = + really_input_string ic (String.length Config.ast_impl_magic_number) + in -and rec_status = - Trec_not (* first in a nonrecursive group *) - | Trec_first (* first in a recursive group *) - | Trec_next (* not first in a recursive/nonrecursive group *) + let rewrite transform = + Location.set_input_name @@ input_value ic; + let ast = input_value ic in + close_in ic; + let ast = transform ast in + let oc = open_out_bin target in + output_string oc magic; + output_value oc !Location.input_name; + output_value oc ast; + close_out oc + and fail () = + close_in ic; + failwith "Ast_mapper: OCaml version mismatch or malformed input"; + in -and ext_status = - Text_first (* first constructor in an extension *) - | Text_next (* not first constructor in an extension *) - | Text_exception + if magic = Config.ast_impl_magic_number then + rewrite (implem : structure -> structure) + else if magic = Config.ast_intf_magic_number then + rewrite (iface : signature -> signature) + else fail () +let drop_ppx_context_str ~restore = function + | {pstr_desc = Pstr_attribute({Location.txt = "ocaml.ppx.context"}, a)} + :: items -> + if restore then + PpxContext.restore (PpxContext.get_fields a); + items + | items -> items -(* Constructor and record label descriptions inserted held in typing - environments *) +let drop_ppx_context_sig ~restore = function + | {psig_desc = Psig_attribute({Location.txt = "ocaml.ppx.context"}, a)} + :: items -> + if restore then + PpxContext.restore (PpxContext.get_fields a); + items + | items -> items -type constructor_description = - { cstr_name: string; (* Constructor name *) - cstr_res: type_expr; (* Type of the result *) - cstr_existentials: type_expr list; (* list of existentials *) - cstr_args: type_expr list; (* Type of the arguments *) - cstr_arity: int; (* Number of arguments *) - cstr_tag: constructor_tag; (* Tag for heap blocks *) - cstr_consts: int; (* Number of constant constructors *) - cstr_nonconsts: int; (* Number of non-const constructors *) - cstr_normal: int; (* Number of non generalized constrs *) - cstr_generalized: bool; (* Constrained return type? *) - cstr_private: private_flag; (* Read-only constructor? *) - cstr_loc: Location.t; - cstr_attributes: Parsetree.attributes; - cstr_inlined: type_declaration option; - } +let add_ppx_context_str ~tool_name ast = + Ast_helper.Str.attribute (ppx_context ~tool_name ()) :: ast -and constructor_tag = - Cstr_constant of int (* Constant constructor (an int) *) - | Cstr_block of int (* Regular constructor (a block) *) - | Cstr_unboxed (* Constructor of an unboxed type *) - | Cstr_extension of Path.t * bool (* Extension constructor - true if a constant false if a block*) +let add_ppx_context_sig ~tool_name ast = + Ast_helper.Sig.attribute (ppx_context ~tool_name ()) :: ast -(* Constructors are the same *) -val equal_tag : constructor_tag -> constructor_tag -> bool -(* Constructors may be the same, given potential rebinding *) -val may_equal_constr : - constructor_description -> constructor_description -> bool +let apply ~source ~target mapper = + apply_lazy ~source ~target (fun () -> mapper) -type label_description = - { lbl_name: string; (* Short name *) - lbl_res: type_expr; (* Type of the result *) - lbl_arg: type_expr; (* Type of the argument *) - lbl_mut: mutable_flag; (* Is this a mutable field? *) - lbl_pos: int; (* Position in block *) - lbl_all: label_description array; (* All the labels in this type *) - lbl_repres: record_representation; (* Representation for this record *) - lbl_private: private_flag; (* Read-only field? *) - lbl_loc: Location.t; - lbl_attributes: Parsetree.attributes; - } +let run_main mapper = + try + let a = Sys.argv in + let n = Array.length a in + if n > 2 then + let mapper () = + try mapper (Array.to_list (Array.sub a 1 (n - 3))) + with exn -> + (* PR#6463 *) + let f _ _ = raise exn in + {default_mapper with structure = f; signature = f} + in + apply_lazy ~source:a.(n - 2) ~target:a.(n - 1) mapper + else begin + Printf.eprintf "Usage: %s [extra_args] \n%!" + Sys.executable_name; + exit 2 + end + with exn -> + prerr_endline (Printexc.to_string exn); + exit 2 -end = struct -#1 "types.ml" +let register_function = ref (fun _name f -> run_main f) +let register name f = !register_function name f + +end +module Tbl : sig +#1 "tbl.mli" (**************************************************************************) (* *) (* OCaml *) @@ -30785,351 +15477,162 @@ end = struct (* *) (**************************************************************************) -(* Representation of types and declarations *) - -open Asttypes - -(* Type expressions for the core language *) - -type type_expr = - { mutable desc: type_desc; - mutable level: int; - id: int } - -and type_desc = - Tvar of string option - | Tarrow of arg_label * type_expr * type_expr * commutable - | Ttuple of type_expr list - | Tconstr of Path.t * type_expr list * abbrev_memo ref - | Tobject of type_expr * (Path.t * type_expr list) option ref - | Tfield of string * field_kind * type_expr * type_expr - | Tnil - | Tlink of type_expr - | Tsubst of type_expr (* for copying *) - | Tvariant of row_desc - | Tunivar of string option - | Tpoly of type_expr * type_expr list - | Tpackage of Path.t * Longident.t list * type_expr list - -and row_desc = - { row_fields: (label * row_field) list; - row_more: type_expr; - row_bound: unit; - row_closed: bool; - row_fixed: bool; - row_name: (Path.t * type_expr list) option } - -and row_field = - Rpresent of type_expr option - | Reither of bool * type_expr list * bool * row_field option ref - (* 1st true denotes a constant constructor *) - (* 2nd true denotes a tag in a pattern matching, and - is erased later *) - | Rabsent - -and abbrev_memo = - Mnil - | Mcons of private_flag * Path.t * type_expr * type_expr * abbrev_memo - | Mlink of abbrev_memo ref - -and field_kind = - Fvar of field_kind option ref - | Fpresent - | Fabsent - -and commutable = - Cok - | Cunknown - | Clink of commutable ref - -module TypeOps = struct - type t = type_expr - let compare t1 t2 = t1.id - t2.id - let hash t = t.id - let equal t1 t2 = t1 == t2 -end - -(* Maps of methods and instance variables *) - -module OrderedString = - struct type t = string let compare (x:t) y = compare x y end -module Meths = Map.Make(OrderedString) -module Vars = Meths - -(* Value descriptions *) - -type value_description = - { val_type: type_expr; (* Type of the value *) - val_kind: value_kind; - val_loc: Location.t; - val_attributes: Parsetree.attributes; - } - -and value_kind = - Val_reg (* Regular value *) - | Val_prim of Primitive.description (* Primitive *) - | Val_ivar of mutable_flag * string (* Instance variable (mutable ?) *) - | Val_self of (Ident.t * type_expr) Meths.t ref * - (Ident.t * Asttypes.mutable_flag * - Asttypes.virtual_flag * type_expr) Vars.t ref * - string * type_expr - (* Self *) - | Val_anc of (string * Ident.t) list * string - (* Ancestor *) - | Val_unbound (* Unbound variable *) - -(* Variance *) - -module Variance = struct - type t = int - type f = May_pos | May_neg | May_weak | Inj | Pos | Neg | Inv - let single = function - | May_pos -> 1 - | May_neg -> 2 - | May_weak -> 4 - | Inj -> 8 - | Pos -> 16 - | Neg -> 32 - | Inv -> 64 - let union v1 v2 = v1 lor v2 - let inter v1 v2 = v1 land v2 - let subset v1 v2 = (v1 land v2 = v1) - let set x b v = - if b then v lor single x else v land (lnot (single x)) - let mem x = subset (single x) - let null = 0 - let may_inv = 7 - let full = 127 - let covariant = single May_pos lor single Pos lor single Inj - let swap f1 f2 v = - let v' = set f1 (mem f2 v) v in set f2 (mem f1 v) v' - let conjugate v = swap May_pos May_neg (swap Pos Neg v) - let get_upper v = (mem May_pos v, mem May_neg v) - let get_lower v = (mem Pos v, mem Neg v, mem Inv v, mem Inj v) -end - -(* Type definitions *) - -type type_declaration = - { type_params: type_expr list; - type_arity: int; - type_kind: type_kind; - type_private: private_flag; - type_manifest: type_expr option; - type_variance: Variance.t list; - type_newtype_level: (int * int) option; - type_loc: Location.t; - type_attributes: Parsetree.attributes; - type_immediate: bool; - type_unboxed: unboxed_status; - } - -and type_kind = - Type_abstract - | Type_record of label_declaration list * record_representation - | Type_variant of constructor_declaration list - | Type_open - -and record_representation = - Record_regular (* All fields are boxed / tagged *) - | Record_float (* All fields are floats *) - | Record_unboxed of bool (* Unboxed single-field record, inlined or not *) - | Record_inlined of {tag : int; name : string; num_nonconsts : int} (* Inlined record *) - | Record_extension (* Inlined record under extension *) - -and label_declaration = - { - ld_id: Ident.t; - ld_mutable: mutable_flag; - ld_type: type_expr; - ld_loc: Location.t; - ld_attributes: Parsetree.attributes; - } - -and constructor_declaration = - { - cd_id: Ident.t; - cd_args: constructor_arguments; - cd_res: type_expr option; - cd_loc: Location.t; - cd_attributes: Parsetree.attributes; - } - -and constructor_arguments = - | Cstr_tuple of type_expr list - | Cstr_record of label_declaration list - -and unboxed_status = - { - unboxed: bool; - default: bool; (* False if the unboxed field was set from an attribute. *) - } - -let unboxed_false_default_false = {unboxed = false; default = false} -let unboxed_false_default_true = {unboxed = false; default = true} -let unboxed_true_default_false = {unboxed = true; default = false} -let unboxed_true_default_true = {unboxed = true; default = true} - -type extension_constructor = - { ext_type_path: Path.t; - ext_type_params: type_expr list; - ext_args: constructor_arguments; - ext_ret_type: type_expr option; - ext_private: private_flag; - ext_loc: Location.t; - ext_attributes: Parsetree.attributes; } - -and type_transparence = - Type_public (* unrestricted expansion *) - | Type_new (* "new" type *) - | Type_private (* private type *) - -(* Type expressions for the class language *) - -module Concr = Set.Make(OrderedString) +(* Association tables from any ordered type to any type. + We use the generic ordering to compare keys. *) -type class_type = - Cty_constr of Path.t * type_expr list * class_type - | Cty_signature of class_signature - | Cty_arrow of arg_label * type_expr * class_type +type ('k, 'v) t -and class_signature = - { csig_self: type_expr; - csig_vars: - (Asttypes.mutable_flag * Asttypes.virtual_flag * type_expr) Vars.t; - csig_concr: Concr.t; - csig_inher: (Path.t * type_expr list) list } +val empty: ('k, 'v) t +val add: 'k -> 'v -> ('k, 'v) t -> ('k, 'v) t +val find: 'k -> ('k, 'v) t -> 'v +val find_str: string -> (string, 'v) t -> 'v +val mem: 'k -> ('k, 'v) t -> bool +val remove: 'k -> ('k, 'v) t -> ('k, 'v) t +val iter: ('k -> 'v -> unit) -> ('k, 'v) t -> unit +val map: ('k -> 'v1 -> 'v2) -> ('k, 'v1) t -> ('k, 'v2) t +val fold: ('k -> 'v -> 'acc -> 'acc) -> ('k, 'v) t -> 'acc -> 'acc -type class_declaration = - { cty_params: type_expr list; - mutable cty_type: class_type; - cty_path: Path.t; - cty_new: type_expr option; - cty_variance: Variance.t list; - cty_loc: Location.t; - cty_attributes: Parsetree.attributes; - } +open Format -type class_type_declaration = - { clty_params: type_expr list; - clty_type: class_type; - clty_path: Path.t; - clty_variance: Variance.t list; - clty_loc: Location.t; - clty_attributes: Parsetree.attributes; - } +val print: (formatter -> 'k -> unit) -> (formatter -> 'v -> unit) -> + formatter -> ('k, 'v) t -> unit -(* Type expressions for the module language *) +end = struct +#1 "tbl.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -type module_type = - Mty_ident of Path.t - | Mty_signature of signature - | Mty_functor of Ident.t * module_type option * module_type - | Mty_alias of alias_presence * Path.t +type ('k, 'v) t = + Empty + | Node of ('k, 'v) t * 'k * 'v * ('k, 'v) t * int -and alias_presence = - | Mta_present - | Mta_absent +let empty = Empty -and signature = signature_item list +let height = function + Empty -> 0 + | Node(_,_,_,_,h) -> h -and signature_item = - Sig_value of Ident.t * value_description - | Sig_type of Ident.t * type_declaration * rec_status - | Sig_typext of Ident.t * extension_constructor * ext_status - | Sig_module of Ident.t * module_declaration * rec_status - | Sig_modtype of Ident.t * modtype_declaration - | Sig_class of Ident.t * class_declaration * rec_status - | Sig_class_type of Ident.t * class_type_declaration * rec_status +let create l x d r = + let hl = height l and hr = height r in + Node(l, x, d, r, (if hl >= hr then hl + 1 else hr + 1)) -and module_declaration = - { - md_type: module_type; - md_attributes: Parsetree.attributes; - md_loc: Location.t; - } +let bal l x d r = + let hl = height l and hr = height r in + if hl > hr + 1 then + match l with + | Node (ll, lv, ld, lr, _) when height ll >= height lr -> + create ll lv ld (create lr x d r) + | Node (ll, lv, ld, Node (lrl, lrv, lrd, lrr, _), _) -> + create (create ll lv ld lrl) lrv lrd (create lrr x d r) + | _ -> assert false + else if hr > hl + 1 then + match r with + | Node (rl, rv, rd, rr, _) when height rr >= height rl -> + create (create l x d rl) rv rd rr + | Node (Node (rll, rlv, rld, rlr, _), rv, rd, rr, _) -> + create (create l x d rll) rlv rld (create rlr rv rd rr) + | _ -> assert false + else + create l x d r -and modtype_declaration = - { - mtd_type: module_type option; (* Note: abstract *) - mtd_attributes: Parsetree.attributes; - mtd_loc: Location.t; - } +let rec add x data = function + Empty -> + Node(Empty, x, data, Empty, 1) + | Node(l, v, d, r, h) -> + let c = compare x v in + if c = 0 then + Node(l, x, data, r, h) + else if c < 0 then + bal (add x data l) v d r + else + bal l v d (add x data r) -and rec_status = - Trec_not (* first in a nonrecursive group *) - | Trec_first (* first in a recursive group *) - | Trec_next (* not first in a recursive/nonrecursive group *) +let rec find x = function + Empty -> + raise Not_found + | Node(l, v, d, r, _) -> + let c = compare x v in + if c = 0 then d + else find x (if c < 0 then l else r) -and ext_status = - Text_first (* first constructor of an extension *) - | Text_next (* not first constructor of an extension *) - | Text_exception (* an exception *) +let rec find_str (x : string) = function + Empty -> + raise Not_found + | Node(l, v, d, r, _) -> + let c = compare x v in + if c = 0 then d + else find_str x (if c < 0 then l else r) +let rec mem x = function + Empty -> false + | Node(l, v, _d, r, _) -> + let c = compare x v in + c = 0 || mem x (if c < 0 then l else r) -(* Constructor and record label descriptions inserted held in typing - environments *) +let rec merge t1 t2 = + match (t1, t2) with + (Empty, t) -> t + | (t, Empty) -> t + | (Node(l1, v1, d1, r1, _h1), Node(l2, v2, d2, r2, _h2)) -> + bal l1 v1 d1 (bal (merge r1 l2) v2 d2 r2) -type constructor_description = - { cstr_name: string; (* Constructor name *) - cstr_res: type_expr; (* Type of the result *) - cstr_existentials: type_expr list; (* list of existentials *) - cstr_args: type_expr list; (* Type of the arguments *) - cstr_arity: int; (* Number of arguments *) - cstr_tag: constructor_tag; (* Tag for heap blocks *) - cstr_consts: int; (* Number of constant constructors *) - cstr_nonconsts: int; (* Number of non-const constructors *) - cstr_normal: int; (* Number of non generalized constrs *) - cstr_generalized: bool; (* Constrained return type? *) - cstr_private: private_flag; (* Read-only constructor? *) - cstr_loc: Location.t; - cstr_attributes: Parsetree.attributes; - cstr_inlined: type_declaration option; - } +let rec remove x = function + Empty -> + Empty + | Node(l, v, d, r, _h) -> + let c = compare x v in + if c = 0 then + merge l r + else if c < 0 then + bal (remove x l) v d r + else + bal l v d (remove x r) -and constructor_tag = - Cstr_constant of int (* Constant constructor (an int) *) - | Cstr_block of int (* Regular constructor (a block) *) - | Cstr_unboxed (* Constructor of an unboxed type *) - | Cstr_extension of Path.t * bool (* Extension constructor - true if a constant false if a block*) +let rec iter f = function + Empty -> () + | Node(l, v, d, r, _) -> + iter f l; f v d; iter f r -let equal_tag t1 t2 = - match (t1, t2) with - | Cstr_constant i1, Cstr_constant i2 -> i2 = i1 - | Cstr_block i1, Cstr_block i2 -> i2 = i1 - | Cstr_unboxed, Cstr_unboxed -> true - | Cstr_extension (path1, b1), Cstr_extension (path2, b2) -> - Path.same path1 path2 && b1 = b2 - | (Cstr_constant _|Cstr_block _|Cstr_unboxed|Cstr_extension _), _ -> false +let rec map f = function + Empty -> Empty + | Node(l, v, d, r, h) -> Node(map f l, v, f v d, map f r, h) -let may_equal_constr c1 c2 = match c1.cstr_tag,c2.cstr_tag with -| Cstr_extension _,Cstr_extension _ -> c1.cstr_arity = c2.cstr_arity -| tag1,tag2 -> equal_tag tag1 tag2 +let rec fold f m accu = + match m with + | Empty -> accu + | Node(l, v, d, r, _) -> + fold f r (f v d (fold f l accu)) -type label_description = - { lbl_name: string; (* Short name *) - lbl_res: type_expr; (* Type of the result *) - lbl_arg: type_expr; (* Type of the argument *) - lbl_mut: mutable_flag; (* Is this a mutable field? *) - lbl_pos: int; (* Position in block *) - lbl_all: label_description array; (* All the labels in this type *) - lbl_repres: record_representation; (* Representation for this record *) - lbl_private: private_flag; (* Read-only field? *) - lbl_loc: Location.t; - lbl_attributes: Parsetree.attributes; - } +open Format + +let print print_key print_data ppf tbl = + let print_tbl ppf tbl = + iter (fun k d -> fprintf ppf "@[<2>%a ->@ %a;@]@ " print_key k print_data d) + tbl in + fprintf ppf "@[[[%a]]@]" print_tbl tbl end -module Cmi_format : sig -#1 "cmi_format.mli" +module Subst : sig +#1 "subst.mli" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Fabrice Le Fessant, INRIA Saclay *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) (* *) -(* Copyright 2012 Institut National de Recherche en Informatique et *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -31138,52 +15641,71 @@ module Cmi_format : sig (* *) (**************************************************************************) -type pers_flags = - | Rectypes - | Deprecated of string - | Opaque - | Unsafe_string +(* Substitutions *) -type cmi_infos = { - cmi_name : string; - cmi_sign : Types.signature_item list; - cmi_crcs : (string * Digest.t option) list; - cmi_flags : pers_flags list; -} +open Types -(* write the magic + the cmi information *) -val output_cmi : string -> out_channel -> cmi_infos -> Digest.t +type t -val create_cmi : ?check_exists:unit -> string -> cmi_infos -> Digest.t +(* + Substitutions are used to translate a type from one context to + another. This requires substituting paths for identifiers, and + possibly also lowering the level of non-generic variables so that + they are inferior to the maximum level of the new context. -(* read the cmi information (the magic is supposed to have already been read) *) -val input_cmi : in_channel -> cmi_infos + Substitutions can also be used to create a "clean" copy of a type. + Indeed, non-variable node of a type are duplicated, with their + levels set to generic level. That way, the resulting type is + well-formed (decreasing levels), even if the original one was not. +*) -(* read a cmi from a filename, checking the magic *) -val read_cmi : string -> cmi_infos +val identity: t -(* Error report *) +val add_type: Ident.t -> Path.t -> t -> t +val add_type_path: Path.t -> Path.t -> t -> t +val add_type_function: + Path.t -> params:type_expr list -> body:type_expr -> t -> t +val add_module: Ident.t -> Path.t -> t -> t +val add_module_path: Path.t -> Path.t -> t -> t +val add_modtype: Ident.t -> module_type -> t -> t +val for_saving: t -> t +val reset_for_saving: unit -> unit -type error = - Not_an_interface of string - | Wrong_version_interface of string * string - | Corrupted_interface of string +val module_path: t -> Path.t -> Path.t +val type_path: t -> Path.t -> Path.t -exception Error of error +val type_expr: t -> type_expr -> type_expr +val class_type: t -> class_type -> class_type +val value_description: t -> value_description -> value_description +val type_declaration: t -> type_declaration -> type_declaration +val extension_constructor: + t -> extension_constructor -> extension_constructor +val class_declaration: t -> class_declaration -> class_declaration +val cltype_declaration: t -> class_type_declaration -> class_type_declaration +val modtype: t -> module_type -> module_type +val signature: t -> signature -> signature +val modtype_declaration: t -> modtype_declaration -> modtype_declaration +val module_declaration: t -> module_declaration -> module_declaration +val typexp : t -> Types.type_expr -> Types.type_expr +val class_signature: t -> class_signature -> class_signature -open Format +(* Composition of substitutions: + apply (compose s1 s2) x = apply s2 (apply s1 x) *) +val compose: t -> t -> t -val report_error: formatter -> error -> unit +(* A forward reference to be filled in ctype.ml. *) +val ctype_apply_env_empty: + (type_expr list -> type_expr -> type_expr list -> type_expr) ref end = struct -#1 "cmi_format.ml" +#1 "subst.ml" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Fabrice Le Fessant, INRIA Saclay *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) (* *) -(* Copyright 2012 Institut National de Recherche en Informatique et *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -31192,391 +15714,493 @@ end = struct (* *) (**************************************************************************) -type pers_flags = - | Rectypes - | Deprecated of string - | Opaque - | Unsafe_string +(* Substitutions *) -type error = - Not_an_interface of string - | Wrong_version_interface of string * string - | Corrupted_interface of string +open Misc +open Path +open Types +open Btype -exception Error of error +type type_replacement = + | Path of Path.t + | Type_function of { params : type_expr list; body : type_expr } -type cmi_infos = { - cmi_name : string; - cmi_sign : Types.signature_item list; - cmi_crcs : (string * Digest.t option) list; - cmi_flags : pers_flags list; -} +module PathMap = Map.Make(Path) -let input_cmi ic = - let (name, sign) = input_value ic in - let crcs = input_value ic in - let flags = input_value ic in - { - cmi_name = name; - cmi_sign = sign; - cmi_crcs = crcs; - cmi_flags = flags; - } +type t = + { types: type_replacement PathMap.t; + modules: Path.t PathMap.t; + modtypes: (Ident.t, module_type) Tbl.t; + for_saving: bool; + } -let read_cmi filename = - let ic = open_in_bin filename in - try - let buffer = - really_input_string ic (String.length Config.cmi_magic_number) - in - if buffer <> Config.cmi_magic_number then begin - close_in ic; - let pre_len = String.length Config.cmi_magic_number - 3 in - if String.sub buffer 0 pre_len - = String.sub Config.cmi_magic_number 0 pre_len then - begin - let msg = - if buffer < Config.cmi_magic_number then "an older" else "a newer" in - raise (Error (Wrong_version_interface (filename, msg))) - end else begin - raise(Error(Not_an_interface filename)) - end - end; - let cmi = input_cmi ic in - close_in ic; - cmi - with End_of_file | Failure _ -> - close_in ic; - raise(Error(Corrupted_interface(filename))) - | Error e -> - close_in ic; - raise (Error e) +let identity = + { types = PathMap.empty; + modules = PathMap.empty; + modtypes = Tbl.empty; + for_saving = false; + } -let output_cmi filename oc cmi = -(* beware: the provided signature must have been substituted for saving *) - output_string oc Config.cmi_magic_number; - output_value oc (cmi.cmi_name, cmi.cmi_sign); - flush oc; - let crc = Digest.file filename in - let crcs = (cmi.cmi_name, Some crc) :: cmi.cmi_crcs in - output_value oc crcs; - output_value oc cmi.cmi_flags; - crc +let add_type_path id p s = { s with types = PathMap.add id (Path p) s.types } +let add_type id p s = add_type_path (Pident id) p s +let add_type_function id ~params ~body s = + { s with types = PathMap.add id (Type_function { params; body }) s.types } -(* This function is also called by [save_cmt] as cmi_format is subset of - cmt_format, so dont close the channel yet -*) -let create_cmi ?check_exists filename (cmi : cmi_infos) = - (* beware: the provided signature must have been substituted for saving *) - let content = - Config.cmi_magic_number ^ Marshal.to_string (cmi.cmi_name, cmi.cmi_sign) [] - (* checkout [output_value] in {!Pervasives} module *) - in - let crc = Digest.string content in - let cmi_infos = - if check_exists <> None && Sys.file_exists filename then - Some (read_cmi filename) - else None in - match cmi_infos with - | Some {cmi_name = _; cmi_sign = _; cmi_crcs = (old_name, Some old_crc)::rest ; cmi_flags} - (* TODO: design the cmi format so that we don't need read the whole cmi *) - when - cmi.cmi_name = old_name && - crc = old_crc && - cmi.cmi_crcs = rest && - cmi_flags = cmi.cmi_flags -> - crc - | _ -> - let crcs = (cmi.cmi_name, Some crc) :: cmi.cmi_crcs in - let oc = open_out_bin filename in - output_string oc content; - output_value oc crcs; - output_value oc cmi.cmi_flags; - close_out oc; - crc +let add_module_path id p s = { s with modules = PathMap.add id p s.modules } +let add_module id p s = add_module_path (Pident id) p s +let add_modtype id ty s = { s with modtypes = Tbl.add id ty s.modtypes } +let for_saving s = { s with for_saving = true } - -(* Error report *) +let loc s x = + if s.for_saving && not !Clflags.keep_locs then Location.none else x -open Format +let remove_loc = + let open Ast_mapper in + {default_mapper with location = (fun _this _loc -> Location.none)} -let report_error ppf = function - | Not_an_interface filename -> - fprintf ppf "%a@ is not a compiled interface" - Location.print_filename filename - | Wrong_version_interface (filename, older_newer) -> - fprintf ppf - "%a@ is not a compiled interface for this version of OCaml.@.\ - It seems to be for %s version of OCaml." - Location.print_filename filename older_newer - | Corrupted_interface filename -> - fprintf ppf "Corrupted compiled interface@ %a" - Location.print_filename filename +let is_not_doc = function + | ({Location.txt = "ocaml.doc"}, _) -> false + | ({Location.txt = "ocaml.text"}, _) -> false + | ({Location.txt = "doc"}, _) -> false + | ({Location.txt = "text"}, _) -> false + | _ -> true -let () = - Location.register_error_of_exn - (function - | Error err -> Some (Location.error_of_printer_file report_error err) - | _ -> None - ) +let attrs s x = + let x = + if s.for_saving && not !Clflags.keep_docs then + List.filter is_not_doc x + else x + in + if s.for_saving && not !Clflags.keep_locs + then remove_loc.Ast_mapper.attributes remove_loc x + else x -end -module Ccomp : sig -#1 "ccomp.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let rec module_path s path = + try PathMap.find path s.modules + with Not_found -> + match path with + | Pident _ -> path + | Pdot(p, n, pos) -> + Pdot(module_path s p, n, pos) + | Papply(p1, p2) -> + Papply(module_path s p1, module_path s p2) + +let modtype_path s = function + Pident id as p -> + begin try + match Tbl.find id s.modtypes with + | Mty_ident p -> p + | _ -> fatal_error "Subst.modtype_path" + with Not_found -> p end + | Pdot(p, n, pos) -> + Pdot(module_path s p, n, pos) + | Papply _ -> + fatal_error "Subst.modtype_path" + +let type_path s path = + match PathMap.find path s.types with + | Path p -> p + | Type_function _ -> assert false + | exception Not_found -> + match path with + | Pident _ -> path + | Pdot(p, n, pos) -> + Pdot(module_path s p, n, pos) + | Papply _ -> + fatal_error "Subst.type_path" + +let type_path s p = + match Path.constructor_typath p with + | Regular p -> type_path s p + | Cstr (ty_path, cstr) -> Pdot(type_path s ty_path, cstr, nopos) + | LocalExt _ -> type_path s p + | Ext (p, cstr) -> Pdot(module_path s p, cstr, nopos) + +let to_subst_by_type_function s p = + match PathMap.find p s.types with + | Path _ -> false + | Type_function _ -> true + | exception Not_found -> false + +(* Special type ids for saved signatures *) + +let new_id = ref (-1) +let reset_for_saving () = new_id := -1 + +let newpersty desc = + decr new_id; + { desc = desc; level = generic_level; id = !new_id } + +(* ensure that all occurrences of 'Tvar None' are physically shared *) +let tvar_none = Tvar None +let tunivar_none = Tunivar None +let norm = function + | Tvar None -> tvar_none + | Tunivar None -> tunivar_none + | d -> d + +let ctype_apply_env_empty = ref (fun _ -> assert false) + +(* Similar to [Ctype.nondep_type_rec]. *) +let rec typexp s ty = + let ty = repr ty in + match ty.desc with + Tvar _ | Tunivar _ as desc -> + if s.for_saving || ty.id < 0 then + let ty' = + if s.for_saving then newpersty (norm desc) + else newty2 ty.level desc + in + save_desc ty desc; ty.desc <- Tsubst ty'; ty' + else ty + | Tsubst ty -> + ty + | Tfield (m, k, _t1, _t2) when not s.for_saving && m = dummy_method + && field_kind_repr k <> Fabsent && (repr ty).level < generic_level -> + (* do not copy the type of self when it is not generalized *) + ty +(* cannot do it, since it would omit substitution + | Tvariant row when not (static_row row) -> + ty +*) + | _ -> + let desc = ty.desc in + save_desc ty desc; + let tm = row_of_type ty in + let has_fixed_row = + not (is_Tconstr ty) && is_constr_row ~allow_ident:false tm in + (* Make a stub *) + let ty' = if s.for_saving then newpersty (Tvar None) else newgenvar () in + ty.desc <- Tsubst ty'; + ty'.desc <- + begin if has_fixed_row then + match tm.desc with (* PR#7348 *) + Tconstr (Pdot(m,i,pos), tl, _abbrev) -> + let i' = String.sub i 0 (String.length i - 4) in + Tconstr(type_path s (Pdot(m,i',pos)), tl, ref Mnil) + | _ -> assert false + else match desc with + | Tconstr (p, args, _abbrev) -> + let args = List.map (typexp s) args in + begin match PathMap.find p s.types with + | exception Not_found -> Tconstr(type_path s p, args, ref Mnil) + | Path _ -> Tconstr(type_path s p, args, ref Mnil) + | Type_function { params; body } -> + (!ctype_apply_env_empty params body args).desc + end + | Tpackage(p, n, tl) -> + Tpackage(modtype_path s p, n, List.map (typexp s) tl) + | Tobject (t1, name) -> + Tobject (typexp s t1, + ref (match !name with + None -> None + | Some (p, tl) -> + if to_subst_by_type_function s p + then None + else Some (type_path s p, List.map (typexp s) tl))) + | Tvariant row -> + let row = row_repr row in + let more = repr row.row_more in + (* We must substitute in a subtle way *) + (* Tsubst takes a tuple containing the row var and the variant *) + begin match more.desc with + Tsubst {desc = Ttuple [_;ty2]} -> + (* This variant type has been already copied *) + ty.desc <- Tsubst ty2; (* avoid Tlink in the new type *) + Tlink ty2 + | _ -> + let dup = + s.for_saving || more.level = generic_level || static_row row || + match more.desc with Tconstr _ -> true | _ -> false in + (* Various cases for the row variable *) + let more' = + match more.desc with + Tsubst ty -> ty + | Tconstr _ | Tnil -> typexp s more + | Tunivar _ | Tvar _ -> + save_desc more more.desc; + if s.for_saving then newpersty (norm more.desc) else + if dup && is_Tvar more then newgenty more.desc else more + | _ -> assert false + in + (* Register new type first for recursion *) + more.desc <- Tsubst(newgenty(Ttuple[more';ty'])); + (* Return a new copy *) + let row = + copy_row (typexp s) true row (not dup) more' in + match row.row_name with + | Some (p, tl) -> + Tvariant {row with row_name = + if to_subst_by_type_function s p + then None + else Some (type_path s p, tl)} + | None -> + Tvariant row + end + | Tfield(_label, kind, _t1, t2) when field_kind_repr kind = Fabsent -> + Tlink (typexp s t2) + | _ -> copy_type_desc (typexp s) desc + end; + ty' + +(* + Always make a copy of the type. If this is not done, type levels + might not be correct. +*) +let type_expr s ty = + let ty' = typexp s ty in + cleanup_types (); + ty' + +let label_declaration s l = + { + ld_id = l.ld_id; + ld_mutable = l.ld_mutable; + ld_type = typexp s l.ld_type; + ld_loc = loc s l.ld_loc; + ld_attributes = attrs s l.ld_attributes; + } + +let constructor_arguments s = function + | Cstr_tuple l -> + Cstr_tuple (List.map (typexp s) l) + | Cstr_record l -> + Cstr_record (List.map (label_declaration s) l) -(* Compiling C files and building C libraries *) +let constructor_declaration s c = + { + cd_id = c.cd_id; + cd_args = constructor_arguments s c.cd_args; + cd_res = may_map (typexp s) c.cd_res; + cd_loc = loc s c.cd_loc; + cd_attributes = attrs s c.cd_attributes; + } -val command: string -> int -val run_command: string -> unit -val compile_file: ?output:string -> ?opt:string -> string -> int -val create_archive: string -> string list -> int -val expand_libname: string -> string -val quote_files: string list -> string -val quote_optfile: string option -> string -(*val make_link_options: string list -> string*) +let type_declaration s decl = + let decl = + { type_params = List.map (typexp s) decl.type_params; + type_arity = decl.type_arity; + type_kind = + begin match decl.type_kind with + Type_abstract -> Type_abstract + | Type_variant cstrs -> + Type_variant (List.map (constructor_declaration s) cstrs) + | Type_record(lbls, rep) -> + Type_record (List.map (label_declaration s) lbls, rep) + | Type_open -> Type_open + end; + type_manifest = + begin + match decl.type_manifest with + None -> None + | Some ty -> Some(typexp s ty) + end; + type_private = decl.type_private; + type_variance = decl.type_variance; + type_newtype_level = None; + type_loc = loc s decl.type_loc; + type_attributes = attrs s decl.type_attributes; + type_immediate = decl.type_immediate; + type_unboxed = decl.type_unboxed; + } + in + cleanup_types (); + decl -type link_mode = - | Exe - | Dll - | MainDll - | Partial +let class_signature s sign = + { csig_self = typexp s sign.csig_self; + csig_vars = + Vars.map (function (m, v, t) -> (m, v, typexp s t)) sign.csig_vars; + csig_concr = sign.csig_concr; + csig_inher = + List.map (fun (p, tl) -> (type_path s p, List.map (typexp s) tl)) + sign.csig_inher; + } -val call_linker: link_mode -> string -> string list -> string -> bool +let rec class_type s = + function + Cty_constr (p, tyl, cty) -> + Cty_constr (type_path s p, List.map (typexp s) tyl, class_type s cty) + | Cty_signature sign -> + Cty_signature (class_signature s sign) + | Cty_arrow (l, ty, cty) -> + Cty_arrow (l, typexp s ty, class_type s cty) -end = struct -#1 "ccomp.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let class_declaration s decl = + let decl = + { cty_params = List.map (typexp s) decl.cty_params; + cty_variance = decl.cty_variance; + cty_type = class_type s decl.cty_type; + cty_path = type_path s decl.cty_path; + cty_new = + begin match decl.cty_new with + None -> None + | Some ty -> Some (typexp s ty) + end; + cty_loc = loc s decl.cty_loc; + cty_attributes = attrs s decl.cty_attributes; + } + in + (* Do not clean up if saving: next is cltype_declaration *) + if not s.for_saving then cleanup_types (); + decl -(* Compiling C files and building C libraries *) +let cltype_declaration s decl = + let decl = + { clty_params = List.map (typexp s) decl.clty_params; + clty_variance = decl.clty_variance; + clty_type = class_type s decl.clty_type; + clty_path = type_path s decl.clty_path; + clty_loc = loc s decl.clty_loc; + clty_attributes = attrs s decl.clty_attributes; + } + in + (* Do clean up even if saving: type_declaration may be recursive *) + cleanup_types (); + decl -let command cmdline = - if !Clflags.verbose then begin - prerr_string "+ "; - prerr_string cmdline; - prerr_newline() - end; - Sys.command cmdline +let class_type s cty = + let cty = class_type s cty in + cleanup_types (); + cty -let run_command cmdline = ignore(command cmdline) +let value_description s descr = + { val_type = type_expr s descr.val_type; + val_kind = descr.val_kind; + val_loc = loc s descr.val_loc; + val_attributes = attrs s descr.val_attributes; + } -(* Build @responsefile to work around Windows limitations on - command-line length *) -let build_diversion lst = - let (responsefile, oc) = Filename.open_temp_file "camlresp" "" in - List.iter (fun f -> Printf.fprintf oc "%s\n" f) lst; - close_out oc; - at_exit (fun () -> Misc.remove_file responsefile); - "@" ^ responsefile +let extension_constructor s ext = + let ext = + { ext_type_path = type_path s ext.ext_type_path; + ext_type_params = List.map (typexp s) ext.ext_type_params; + ext_args = constructor_arguments s ext.ext_args; + ext_ret_type = may_map (typexp s) ext.ext_ret_type; + ext_private = ext.ext_private; + ext_attributes = attrs s ext.ext_attributes; + ext_loc = if s.for_saving then Location.none else ext.ext_loc; } + in + cleanup_types (); + ext -let quote_files lst = - let lst = List.filter (fun f -> f <> "") lst in - let quoted = List.map Filename.quote lst in - let s = String.concat " " quoted in - if String.length s >= 4096 && Sys.os_type = "Win32" - then build_diversion quoted - else s +let rec rename_bound_idents s idents = function + [] -> (List.rev idents, s) + | Sig_type(id, _, _) :: sg -> + let id' = Ident.rename id in + rename_bound_idents (add_type id (Pident id') s) (id' :: idents) sg + | Sig_module(id, _, _) :: sg -> + let id' = Ident.rename id in + rename_bound_idents (add_module id (Pident id') s) (id' :: idents) sg + | Sig_modtype(id, _) :: sg -> + let id' = Ident.rename id in + rename_bound_idents (add_modtype id (Mty_ident(Pident id')) s) + (id' :: idents) sg + | (Sig_class(id, _, _) | Sig_class_type(id, _, _)) :: sg -> + (* cheat and pretend they are types cf. PR#6650 *) + let id' = Ident.rename id in + rename_bound_idents (add_type id (Pident id') s) (id' :: idents) sg + | (Sig_value(id, _) | Sig_typext(id, _, _)) :: sg -> + let id' = Ident.rename id in + rename_bound_idents s (id' :: idents) sg -let quote_prefixed pr lst = - let lst = List.filter (fun f -> f <> "") lst in - let lst = List.map (fun f -> pr ^ f) lst in - quote_files lst +let rec modtype s = function + Mty_ident p as mty -> + begin match p with + Pident id -> + begin try Tbl.find id s.modtypes with Not_found -> mty end + | Pdot(p, n, pos) -> + Mty_ident(Pdot(module_path s p, n, pos)) + | Papply _ -> + fatal_error "Subst.modtype" + end + | Mty_signature sg -> + Mty_signature(signature s sg) + | Mty_functor(id, arg, res) -> + let id' = Ident.rename id in + Mty_functor(id', may_map (modtype s) arg, + modtype (add_module id (Pident id') s) res) + | Mty_alias(pres, p) -> + Mty_alias(pres, module_path s p) -let quote_optfile = function - | None -> "" - | Some f -> Filename.quote f +and signature s sg = + (* Components of signature may be mutually recursive (e.g. type declarations + or class and type declarations), so first build global renaming + substitution... *) + let (new_idents, s') = rename_bound_idents s [] sg in + (* ... then apply it to each signature component in turn *) + List.map2 (signature_component s') sg new_idents -let display_msvc_output file name = - let c = open_in file in - try - let first = input_line c in - if first <> Filename.basename name then - print_string first; - while true do - print_string (input_line c) - done - with _ -> - close_in c; - Sys.remove file +and signature_component s comp newid = + match comp with + Sig_value(_id, d) -> + Sig_value(newid, value_description s d) + | Sig_type(_id, d, rs) -> + Sig_type(newid, type_declaration s d, rs) + | Sig_typext(_id, ext, es) -> + Sig_typext(newid, extension_constructor s ext, es) + | Sig_module(_id, d, rs) -> + Sig_module(newid, module_declaration s d, rs) + | Sig_modtype(_id, d) -> + Sig_modtype(newid, modtype_declaration s d) + | Sig_class(_id, d, rs) -> + Sig_class(newid, class_declaration s d, rs) + | Sig_class_type(_id, d, rs) -> + Sig_class_type(newid, cltype_declaration s d, rs) -let compile_file ?output ?(opt="") name = - let (pipe, file) = - if Config.ccomp_type = "msvc" && not !Clflags.verbose then - try - let (t, c) = Filename.open_temp_file "msvc" "stdout" in - close_out c; - (Printf.sprintf " > %s" (Filename.quote t), t) - with _ -> - ("", "") - else - ("", "") in - let exit = - command - (Printf.sprintf - "%s %s %s -c %s %s %s %s %s%s" - (match !Clflags.c_compiler with - | Some cc -> cc - | None -> - let (cflags, cppflags) = - if !Clflags.native_code - then (Config.ocamlopt_cflags, Config.ocamlopt_cppflags) - else (Config.ocamlc_cflags, Config.ocamlc_cppflags) in - (String.concat " " [Config.c_compiler; cflags; cppflags])) - (match output with - | None -> "" - | Some o -> Printf.sprintf "%s%s" Config.c_output_obj o) - opt - (if !Clflags.debug && Config.ccomp_type <> "msvc" then "-g" else "") - (String.concat " " (List.rev !Clflags.all_ccopts)) - (quote_prefixed "-I" (List.rev !Clflags.include_dirs)) - (Clflags.std_include_flag "-I") - (Filename.quote name) - (* cl tediously includes the name of the C file as the first thing it - outputs (in fairness, the tedious thing is that there's no switch to - disable this behaviour). In the absence of the Unix module, use - a temporary file to filter the output (cannot pipe the output to a - filter because this removes the exit status of cl, which is wanted. - *) - pipe) in - if pipe <> "" - then display_msvc_output file name; - exit +and module_declaration s decl = + { + md_type = modtype s decl.md_type; + md_attributes = attrs s decl.md_attributes; + md_loc = loc s decl.md_loc; + } -let macos_create_empty_archive ~quoted_archive = - let result = - command (Printf.sprintf "%s rc %s /dev/null" Config.ar quoted_archive) - in - if result <> 0 then result - else - let result = - command (Printf.sprintf "%s %s 2> /dev/null" Config.ranlib quoted_archive) - in - if result <> 0 then result - else - command (Printf.sprintf "%s d %s /dev/null" Config.ar quoted_archive) +and modtype_declaration s decl = + { + mtd_type = may_map (modtype s) decl.mtd_type; + mtd_attributes = attrs s decl.mtd_attributes; + mtd_loc = loc s decl.mtd_loc; + } -let create_archive archive file_list = - Misc.remove_file archive; - let quoted_archive = Filename.quote archive in - match Config.ccomp_type with - "msvc" -> - command(Printf.sprintf "link /lib /nologo /out:%s %s" - quoted_archive (quote_files file_list)) - | _ -> - assert(String.length Config.ar > 0); - let is_macosx = - match Config.system with - | "macosx" -> true - | _ -> false - in - if is_macosx && file_list = [] then (* PR#6550 *) - macos_create_empty_archive ~quoted_archive - else - let r1 = - command(Printf.sprintf "%s rc %s %s" - Config.ar quoted_archive (quote_files file_list)) in - if r1 <> 0 || String.length Config.ranlib = 0 - then r1 - else command(Config.ranlib ^ " " ^ quoted_archive) +(* For every binding k |-> d of m1, add k |-> f d to m2 + and return resulting merged map. *) -let expand_libname name = - if String.length name < 2 || String.sub name 0 2 <> "-l" - then name - else begin - let libname = - "lib" ^ String.sub name 2 (String.length name - 2) ^ Config.ext_lib in - try - Misc.find_in_path !Config.load_path libname - with Not_found -> - libname - end +let merge_tbls f m1 m2 = + Tbl.fold (fun k d accu -> Tbl.add k (f d) accu) m1 m2 -type link_mode = - | Exe - | Dll - | MainDll - | Partial +let merge_path_maps f m1 m2 = + PathMap.fold (fun k d accu -> PathMap.add k (f d) accu) m1 m2 -let remove_Wl cclibs = - cclibs |> List.map (fun cclib -> - (* -Wl,-foo,bar -> -foo bar *) - if String.length cclib >= 4 && "-Wl," = String.sub cclib 0 4 then - String.map (function ',' -> ' ' | c -> c) - (String.sub cclib 4 (String.length cclib - 4)) - else cclib) +let type_replacement s = function + | Path p -> Path (type_path s p) + | Type_function { params; body } -> + let params = List.map (typexp s) params in + let body = typexp s body in + Type_function { params; body } -let call_linker mode output_name files extra = - let cmd = - if mode = Partial then - let l_prefix = - match Config.ccomp_type with - | "msvc" -> "/libpath:" - | _ -> "-L" - in - Printf.sprintf "%s%s %s %s %s" - Config.native_pack_linker - (Filename.quote output_name) - (quote_prefixed l_prefix !Config.load_path) - (quote_files (remove_Wl files)) - extra - else - Printf.sprintf "%s -o %s %s %s %s %s %s %s" - (match !Clflags.c_compiler, mode with - | Some cc, _ -> cc - | None, Exe -> Config.mkexe - | None, Dll -> Config.mkdll - | None, MainDll -> Config.mkmaindll - | None, Partial -> assert false - ) - (Filename.quote output_name) - (if !Clflags.gprofile then Config.cc_profile else "") - "" (*(Clflags.std_include_flag "-I")*) - (quote_prefixed "-L" !Config.load_path) - (String.concat " " (List.rev !Clflags.all_ccopts)) - (quote_files files) - extra - in - command cmd = 0 +(* Composition of substitutions: + apply (compose s1 s2) x = apply s2 (apply s1 x) *) + +let compose s1 s2 = + { types = merge_path_maps (type_replacement s2) s1.types s2.types; + modules = merge_path_maps (module_path s2) s1.modules s2.modules; + modtypes = merge_tbls (modtype s2) s1.modtypes s2.modtypes; + for_saving = s1.for_saving || s2.for_saving; + } end -module Compenv : sig -#1 "compenv.mli" +module Env : sig +#1 "env.mli" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Fabrice Le Fessant, EPI Gallium, INRIA Paris-Rocquencourt *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) (* *) -(* Copyright 2013 Institut National de Recherche en Informatique et *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -31585,4976 +16209,18820 @@ module Compenv : sig (* *) (**************************************************************************) -val module_of_filename : Format.formatter -> string -> string -> string +(* Environment handling *) -val output_prefix : string -> string -val extract_output : string option -> string -val default_output : string option -> string +open Types -val print_version_and_library : string -> 'a -val print_version_string : unit -> 'a -val print_standard_library : unit -> 'a -val fatal : string -> 'a +module PathMap : Map.S with type key = Path.t + and type 'a t = 'a Map.Make(Path).t -val first_ccopts : string list ref -val first_ppx : string list ref -val first_include_dirs : string list ref -val last_include_dirs : string list ref -val implicit_modules : string list ref +type summary = + Env_empty + | Env_value of summary * Ident.t * value_description + | Env_type of summary * Ident.t * type_declaration + | Env_extension of summary * Ident.t * extension_constructor + | Env_module of summary * Ident.t * module_declaration + | Env_modtype of summary * Ident.t * modtype_declaration + | Env_class of summary * Ident.t * class_declaration + | Env_cltype of summary * Ident.t * class_type_declaration + | Env_open of summary * Path.t + | Env_functor_arg of summary * Ident.t + | Env_constraints of summary * type_declaration PathMap.t + | Env_copy_types of summary * string list -(* function to call on plugin=XXX *) -val load_plugin : (string -> unit) ref +type t -(* return the list of objfiles, after OCAMLPARAM and List.rev *) -val get_objfiles : with_ocamlparam:bool -> string list -val last_objfiles : string list ref -val first_objfiles : string list ref +val empty: t +val initial_safe_string: t +val initial_unsafe_string: t +val diff: t -> t -> Ident.t list +val copy_local: from:t -> t -> t -type filename = string +type type_descriptions = + constructor_description list * label_description list -type readenv_position = - Before_args | Before_compile of filename | Before_link +(* For short-paths *) +type iter_cont +val iter_types: + (Path.t -> Path.t * (type_declaration * type_descriptions) -> unit) -> + t -> iter_cont +val run_iter_cont: iter_cont list -> (Path.t * iter_cont) list +val same_types: t -> t -> bool +val used_persistent: unit -> Concr.t +val find_shadowed_types: Path.t -> t -> Path.t list +val without_cmis: ('a -> 'b) -> 'a -> 'b + (* [without_cmis f arg] applies [f] to [arg], but does not + allow opening cmis during its execution *) -val readenv : Format.formatter -> readenv_position -> unit +(* Lookup by paths *) + +val find_value: Path.t -> t -> value_description +val find_type: Path.t -> t -> type_declaration +val find_type_descrs: Path.t -> t -> type_descriptions +val find_module: Path.t -> t -> module_declaration +val find_modtype: Path.t -> t -> modtype_declaration +val find_class: Path.t -> t -> class_declaration +val find_cltype: Path.t -> t -> class_type_declaration + +val find_type_expansion: + Path.t -> t -> type_expr list * type_expr * int option +val find_type_expansion_opt: + Path.t -> t -> type_expr list * type_expr * int option +(* Find the manifest type information associated to a type for the sake + of the compiler's type-based optimisations. *) +val find_modtype_expansion: Path.t -> t -> module_type +val add_functor_arg: Ident.t -> t -> t +val is_functor_arg: Path.t -> t -> bool +val normalize_path: Location.t option -> t -> Path.t -> Path.t +(* Normalize the path to a concrete value or module. + If the option is None, allow returning dangling paths. + Otherwise raise a Missing_module error, and may add forgotten + head as required global. *) +val normalize_path_prefix: Location.t option -> t -> Path.t -> Path.t +(* Only normalize the prefix part of the path *) +val reset_required_globals: unit -> unit +val get_required_globals: unit -> Ident.t list +val add_required_global: Ident.t -> unit + +val has_local_constraints: t -> bool +val add_gadt_instance_level: int -> t -> t +val gadt_instance_level: t -> type_expr -> int option +val add_gadt_instances: t -> int -> type_expr list -> unit +val add_gadt_instance_chain: t -> int -> type_expr -> unit -(* [is_unit_name name] returns true only if [name] can be used as a - correct module name *) -val is_unit_name : string -> bool -(* [check_unit_name ppf filename name] prints a warning in [filename] - on [ppf] if [name] should not be used as a module name. *) -val check_unit_name : Format.formatter -> string -> string -> unit +(* Lookup by long identifiers *) -(* Deferred actions of the compiler, while parsing arguments *) +(* ?loc is used to report 'deprecated module' warnings *) -type deferred_action = - | ProcessImplementation of string - | ProcessInterface of string - | ProcessCFile of string - | ProcessOtherFile of string - | ProcessObjects of string list - | ProcessDLLs of string list +val lookup_value: + ?loc:Location.t -> Longident.t -> t -> Path.t * value_description +val lookup_constructor: + ?loc:Location.t -> Longident.t -> t -> constructor_description +val lookup_all_constructors: + ?loc:Location.t -> + Longident.t -> t -> (constructor_description * (unit -> unit)) list +val lookup_label: + ?loc:Location.t -> Longident.t -> t -> label_description +val lookup_all_labels: + ?loc:Location.t -> + Longident.t -> t -> (label_description * (unit -> unit)) list +val lookup_type: + ?loc:Location.t -> Longident.t -> t -> Path.t + (* Since 4.04, this function no longer returns [type_description]. + To obtain it, you should either call [Env.find_type], or replace + it by [Typetexp.find_type] *) +val lookup_module: + load:bool -> ?loc:Location.t -> Longident.t -> t -> Path.t +val lookup_modtype: + ?loc:Location.t -> Longident.t -> t -> Path.t * modtype_declaration +val lookup_class: + ?loc:Location.t -> Longident.t -> t -> Path.t * class_declaration +val lookup_cltype: + ?loc:Location.t -> Longident.t -> t -> Path.t * class_type_declaration -val c_object_of_filename : string -> string +val copy_types: string list -> t -> t + (* Used only in Typecore.duplicate_ident_types. *) -val defer : deferred_action -> unit -val anonymous : string -> unit -val impl : string -> unit -val intf : string -> unit +exception Recmodule + (* Raise by lookup_module when the identifier refers + to one of the modules of a recursive definition + during the computation of its approximation (see #5965). *) -val process_deferred_actions : - Format.formatter * - (Format.formatter -> string -> string -> unit) * (* compile implementation *) - (Format.formatter -> string -> string -> unit) * (* compile interface *) - string * (* ocaml module extension *) - string -> (* ocaml library extension *) - unit +(* Insertion by identifier *) -end = struct -#1 "compenv.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Fabrice Le Fessant, EPI Gallium, INRIA Paris-Rocquencourt *) -(* *) -(* Copyright 2013 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +val add_value: + ?check:(string -> Warnings.t) -> Ident.t -> value_description -> t -> t +val add_type: check:bool -> Ident.t -> type_declaration -> t -> t +val add_extension: check:bool -> Ident.t -> extension_constructor -> t -> t +val add_module: ?arg:bool -> Ident.t -> module_type -> t -> t +val add_module_declaration: ?arg:bool -> check:bool -> Ident.t -> + module_declaration -> t -> t +val add_modtype: Ident.t -> modtype_declaration -> t -> t +val add_class: Ident.t -> class_declaration -> t -> t +val add_cltype: Ident.t -> class_type_declaration -> t -> t +val add_local_constraint: Path.t -> type_declaration -> int -> t -> t +val add_local_type: Path.t -> type_declaration -> t -> t -open Clflags +(* Insertion of all fields of a signature. *) -let output_prefix name = - let oname = - match !output_name with - | None -> name - | Some n -> if !compile_only then (output_name := None; n) else name in - Filename.remove_extension oname +val add_item: signature_item -> t -> t +val add_signature: signature -> t -> t -let print_version_and_library compiler = - Printf.printf "The OCaml %s, version " compiler; - print_string Config.version; print_newline(); - print_string "Standard library directory: "; - print_string Config.standard_library; print_newline(); - exit 0 +(* Insertion of all fields of a signature, relative to the given path. + Used to implement open. Returns None if the path refers to a functor, + not a structure. *) +val open_signature: + ?used_slot:bool ref -> + ?loc:Location.t -> ?toplevel:bool -> Asttypes.override_flag -> Path.t -> + t -> t option -let print_version_string () = - print_string Config.version; print_newline(); exit 0 +val open_pers_signature: string -> t -> t -let print_standard_library () = - print_string Config.standard_library; print_newline(); exit 0 +(* Insertion by name *) -let fatal err = - prerr_endline err; - exit 2 +val enter_value: + ?check:(string -> Warnings.t) -> + string -> value_description -> t -> Ident.t * t +val enter_type: string -> type_declaration -> t -> Ident.t * t +val enter_extension: string -> extension_constructor -> t -> Ident.t * t +val enter_module: ?arg:bool -> string -> module_type -> t -> Ident.t * t +val enter_module_declaration: + ?arg:bool -> Ident.t -> module_declaration -> t -> t +val enter_modtype: string -> modtype_declaration -> t -> Ident.t * t +val enter_class: string -> class_declaration -> t -> Ident.t * t +val enter_cltype: string -> class_type_declaration -> t -> Ident.t * t -let extract_output = function - | Some s -> s - | None -> - fatal "Please specify the name of the output file, using option -o" +(* Initialize the cache of in-core module interfaces. *) +val reset_cache: unit -> unit -let default_output = function - | Some s -> s - | None -> Config.default_executable_name +(* To be called before each toplevel phrase. *) +val reset_cache_toplevel: unit -> unit -let implicit_modules = ref [] -let first_include_dirs = ref [] -let last_include_dirs = ref [] -let first_ccopts = ref [] -let last_ccopts = ref [] -let first_ppx = ref [] -let last_ppx = ref [] -let first_objfiles = ref [] -let last_objfiles = ref [] +(* Remember the name of the current compilation unit. *) +val set_unit_name: string -> unit +val get_unit_name: unit -> string -(* Check validity of module name *) -let is_unit_name name = - try - if name = "" then raise Exit; - begin match name.[0] with - | 'A'..'Z' -> () - | _ -> - raise Exit; - end; - for i = 1 to String.length name - 1 do - match name.[i] with - | 'A'..'Z' | 'a'..'z' | '0'..'9' | '_' | '\'' -> () - | _ -> - raise Exit; - done; - true - with Exit -> false -;; +(* Read, save a signature to/from a file *) -let check_unit_name ppf filename name = +val read_signature: string -> string -> signature + (* Arguments: module name, file name. Results: signature. *) +val save_signature: + ?check_exists:unit -> + deprecated:string option -> signature -> string -> string -> Cmi_format.cmi_infos + (* Arguments: signature, module name, file name. *) +val save_signature_with_imports: + ?check_exists:unit -> + deprecated:string option -> + signature -> string -> string -> (string * Digest.t option) list + -> Cmi_format.cmi_infos + (* Arguments: signature, module name, file name, + imported units with their CRCs. *) - let _ = ppf in - let _ = filename in - let _ = name in - () +(* Return the CRC of the interface of the given compilation unit *) +val crc_of_unit: string -> Digest.t -(* Compute name of module from output file name *) -let module_of_filename ppf inputfile outputprefix = - let basename = Filename.basename outputprefix in - let name = - try - let pos = String.index basename '.' in - String.sub basename 0 pos - with Not_found -> basename - in - let name = String.capitalize_ascii name in - check_unit_name ppf inputfile name; - name -;; +(* Return the set of compilation units imported, with their CRC *) -type filename = string +val imports: unit -> (string * Digest.t option) list -type readenv_position = - Before_args | Before_compile of filename | Before_link +(* [is_imported_opaque md] returns true if [md] is an opaque imported module *) +val is_imported_opaque: string -> bool -(* Syntax of OCAMLPARAM: (name=VALUE,)* _ (,name=VALUE)* - where VALUE should not contain ',' *) -exception SyntaxError of string +(* Direct access to the table of imported compilation units with their CRC *) -let parse_args s = - let args = String.split_on_char ',' s in - let rec iter is_after args before after = - match args with - [] -> - if not is_after then - raise (SyntaxError "no '_' separator found") - else - (List.rev before, List.rev after) - | "_" :: _ when is_after -> raise (SyntaxError "too many '_' separators") - | "_" :: tail -> iter true tail before after - | arg :: tail -> - let binding = try - Misc.cut_at arg '=' - with Not_found -> - raise (SyntaxError ("missing '=' in " ^ arg)) - in - if is_after then - iter is_after tail before (binding :: after) - else - iter is_after tail (binding :: before) after - in - iter false args [] [] +val crc_units: Consistbl.t +val add_import: string -> unit -let setter ppf f name options s = - try - let bool = match s with - | "0" -> false - | "1" -> true - | _ -> raise Not_found - in - List.iter (fun b -> b := f bool) options - with Not_found -> - Location.print_warning Location.none ppf - (Warnings.Bad_env_variable ("OCAMLPARAM", - Printf.sprintf "bad value for %s" name)) +(* Summaries -- compact representation of an environment, to be + exported in debugging information. *) -let int_setter ppf name option s = - try - option := int_of_string s - with _ -> - Location.print_warning Location.none ppf - (Warnings.Bad_env_variable - ("OCAMLPARAM", Printf.sprintf "non-integer parameter for \"%s\"" name)) +val summary: t -> summary -let int_option_setter ppf name option s = - try - option := Some (int_of_string s) - with _ -> - Location.print_warning Location.none ppf - (Warnings.Bad_env_variable - ("OCAMLPARAM", Printf.sprintf "non-integer parameter for \"%s\"" name)) +(* Return an equivalent environment where all fields have been reset, + except the summary. The initial environment can be rebuilt from the + summary, using Envaux.env_of_only_summary. *) -(* -let float_setter ppf name option s = - try - option := float_of_string s - with _ -> - Location.print_warning Location.none ppf - (Warnings.Bad_env_variable - ("OCAMLPARAM", Printf.sprintf "non-float parameter for \"%s\"" name)) -*) +val keep_only_summary : t -> t +val env_of_only_summary : (summary -> Subst.t -> t) -> t -> t -let load_plugin = ref (fun _ -> ()) +(* Error report *) -let check_bool ppf name s = - match s with - | "0" -> false - | "1" -> true - | _ -> - Location.print_warning Location.none ppf - (Warnings.Bad_env_variable ("OCAMLPARAM", - Printf.sprintf "bad value for %s" name)); - false +type error = + | Illegal_renaming of string * string * string + | Inconsistent_import of string * string * string + | Need_recursive_types of string * string + | Depend_on_unsafe_string_unit of string * string + | Missing_module of Location.t * Path.t * Path.t + | Illegal_value_name of Location.t * string -(* 'can-discard=' specifies which arguments can be discarded without warning - because they are not understood by some versions of OCaml. *) -let can_discard = ref [] +exception Error of error -let read_one_param ppf position name v = - let set name options s = setter ppf (fun b -> b) name options s in - let clear name options s = setter ppf (fun b -> not b) name options s in - match name with - | "g" -> set "g" [ Clflags.debug ] v - | "p" -> set "p" [ Clflags.gprofile ] v - | "bin-annot" -> set "bin-annot" [ Clflags.binary_annotations ] v - | "afl-instrument" -> set "afl-instrument" [ Clflags.afl_instrument ] v - | "afl-inst-ratio" -> - int_setter ppf "afl-inst-ratio" afl_inst_ratio v - | "annot" -> set "annot" [ Clflags.annotations ] v - | "absname" -> set "absname" [ Location.absname ] v - | "compat-32" -> set "compat-32" [ bytecode_compatible_32 ] v - | "noassert" -> set "noassert" [ noassert ] v - | "noautolink" -> set "noautolink" [ no_auto_link ] v - | "nostdlib" -> set "nostdlib" [ no_std_include ] v - | "linkall" -> set "linkall" [ link_everything ] v - | "nolabels" -> set "nolabels" [ classic ] v - | "principal" -> set "principal" [ principal ] v - | "rectypes" -> set "rectypes" [ recursive_types ] v - | "safe-string" -> clear "safe-string" [ unsafe_string ] v - | "strict-sequence" -> set "strict-sequence" [ strict_sequence ] v - | "strict-formats" -> set "strict-formats" [ strict_formats ] v - | "thread" -> set "thread" [ use_threads ] v - | "unboxed-types" -> set "unboxed-types" [ unboxed_types ] v - | "unsafe" -> set "unsafe" [ fast ] v - | "verbose" -> set "verbose" [ verbose ] v - | "nopervasives" -> set "nopervasives" [ nopervasives ] v - | "slash" -> set "slash" [ force_slash ] v (* for ocamldep *) - | "keep-docs" -> set "keep-docs" [ Clflags.keep_docs ] v - | "keep-locs" -> set "keep-locs" [ Clflags.keep_locs ] v +open Format - | "compact" -> clear "compact" [ optimize_for_speed ] v - | "no-app-funct" -> clear "no-app-funct" [ applicative_functors ] v - | "nodynlink" -> clear "nodynlink" [ dlcode ] v - | "short-paths" -> clear "short-paths" [ real_paths ] v - | "trans-mod" -> set "trans-mod" [ transparent_modules ] v - | "opaque" -> set "opaque" [ opaque ] v +val report_error: formatter -> error -> unit - | "pp" -> preprocessor := Some v - | "runtime-variant" -> runtime_variant := v - | "cc" -> c_compiler := Some v - | "clambda-checks" -> set "clambda-checks" [ clambda_checks ] v +val mark_value_used: t -> string -> value_description -> unit +val mark_module_used: t -> string -> Location.t -> unit +val mark_type_used: t -> string -> type_declaration -> unit - (* assembly sources *) - | "s" -> - set "s" [ Clflags.keep_asm_file ; Clflags.keep_startup_file ] v - | "S" -> set "S" [ Clflags.keep_asm_file ] v - | "dstartup" -> set "dstartup" [ Clflags.keep_startup_file ] v +type constructor_usage = Positive | Pattern | Privatize +val mark_constructor_used: + constructor_usage -> t -> string -> type_declaration -> string -> unit +val mark_constructor: + constructor_usage -> t -> string -> constructor_description -> unit +val mark_extension_used: + constructor_usage -> t -> extension_constructor -> string -> unit - (* warn-errors *) - | "we" | "warn-error" -> Warnings.parse_options true v - (* warnings *) - | "w" -> Warnings.parse_options false v - (* warn-errors *) - | "wwe" -> Warnings.parse_options false v +val in_signature: bool -> t -> t +val implicit_coercion: t -> t - (* inlining *) - | "inline" -> - let module F = Float_arg_helper in - begin match F.parse_no_error v inline_threshold with - | F.Ok -> () - | F.Parse_failed exn -> - let error = - Printf.sprintf "bad syntax for \"inline\": %s" - (Printexc.to_string exn) - in - Location.print_warning Location.none ppf - (Warnings.Bad_env_variable ("OCAMLPARAM", error)) - end +val is_in_signature: t -> bool - | "inline-toplevel" -> - Int_arg_helper.parse v - "Bad syntax in OCAMLPARAM for 'inline-toplevel'" - inline_toplevel_threshold +val set_value_used_callback: + string -> value_description -> (unit -> unit) -> unit +val set_type_used_callback: + string -> type_declaration -> ((unit -> unit) -> unit) -> unit - | "rounds" -> int_option_setter ppf "rounds" simplify_rounds v - | "inline-max-unroll" -> - Int_arg_helper.parse v "Bad syntax in OCAMLPARAM for 'inline-max-unroll'" - inline_max_unroll - | "inline-call-cost" -> - Int_arg_helper.parse v - "Bad syntax in OCAMLPARAM for 'inline-call-cost'" - inline_call_cost - | "inline-alloc-cost" -> - Int_arg_helper.parse v - "Bad syntax in OCAMLPARAM for 'inline-alloc-cost'" - inline_alloc_cost - | "inline-prim-cost" -> - Int_arg_helper.parse v - "Bad syntax in OCAMLPARAM for 'inline-prim-cost'" - inline_prim_cost - | "inline-branch-cost" -> - Int_arg_helper.parse v - "Bad syntax in OCAMLPARAM for 'inline-branch-cost'" - inline_branch_cost - | "inline-indirect-cost" -> - Int_arg_helper.parse v - "Bad syntax in OCAMLPARAM for 'inline-indirect-cost'" - inline_indirect_cost - | "inline-lifting-benefit" -> - Int_arg_helper.parse v - "Bad syntax in OCAMLPARAM for 'inline-lifting-benefit'" - inline_lifting_benefit - | "inline-branch-factor" -> - Float_arg_helper.parse v - "Bad syntax in OCAMLPARAM for 'inline-branch-factor'" - inline_branch_factor - | "inline-max-depth" -> - Int_arg_helper.parse v - "Bad syntax in OCAMLPARAM for 'inline-max-depth'" - inline_max_depth +(* Forward declaration to break mutual recursion with Includemod. *) +val check_modtype_inclusion: + (loc:Location.t -> t -> module_type -> Path.t -> module_type -> unit) ref +(* Forward declaration to break mutual recursion with Typecore. *) +val add_delayed_check_forward: ((unit -> unit) -> unit) ref +(* Forward declaration to break mutual recursion with Mtype. *) +val strengthen: + (aliasable:bool -> t -> module_type -> Path.t -> module_type) ref +(* Forward declaration to break mutual recursion with Ctype. *) +val same_constr: (t -> type_expr -> type_expr -> bool) ref - | "Oclassic" -> - set "Oclassic" [ classic_inlining ] v - | "O2" -> - if check_bool ppf "O2" v then begin - default_simplify_rounds := 2; - use_inlining_arguments_set o2_arguments; - use_inlining_arguments_set ~round:0 o1_arguments - end +(** Folding over all identifiers (for analysis purpose) *) - | "O3" -> - if check_bool ppf "O3" v then begin - default_simplify_rounds := 3; - use_inlining_arguments_set o3_arguments; - use_inlining_arguments_set ~round:1 o2_arguments; - use_inlining_arguments_set ~round:0 o1_arguments - end - | "unbox-closures" -> - set "unbox-closures" [ unbox_closures ] v - | "unbox-closures-factor" -> - int_setter ppf "unbox-closures-factor" unbox_closures_factor v - | "remove-unused-arguments" -> - set "remove-unused-arguments" [ remove_unused_arguments ] v +val fold_values: + (string -> Path.t -> value_description -> 'a -> 'a) -> + Longident.t option -> t -> 'a -> 'a +val fold_types: + (string -> Path.t -> type_declaration * type_descriptions -> 'a -> 'a) -> + Longident.t option -> t -> 'a -> 'a +val fold_constructors: + (constructor_description -> 'a -> 'a) -> + Longident.t option -> t -> 'a -> 'a +val fold_labels: + (label_description -> 'a -> 'a) -> + Longident.t option -> t -> 'a -> 'a - | "inlining-report" -> - if !native_code then - set "inlining-report" [ inlining_report ] v +(** Persistent structures are only traversed if they are already loaded. *) +val fold_modules: + (string -> Path.t -> module_declaration -> 'a -> 'a) -> + Longident.t option -> t -> 'a -> 'a - | "flambda-verbose" -> - set "flambda-verbose" [ dump_flambda_verbose ] v - | "flambda-invariants" -> - set "flambda-invariants" [ flambda_invariant_checks ] v +val fold_modtypes: + (string -> Path.t -> modtype_declaration -> 'a -> 'a) -> + Longident.t option -> t -> 'a -> 'a +val fold_classs: + (string -> Path.t -> class_declaration -> 'a -> 'a) -> + Longident.t option -> t -> 'a -> 'a +val fold_cltypes: + (string -> Path.t -> class_type_declaration -> 'a -> 'a) -> + Longident.t option -> t -> 'a -> 'a - (* color output *) - | "color" -> - begin match parse_color_setting v with - | None -> - Location.print_warning Location.none ppf - (Warnings.Bad_env_variable ("OCAMLPARAM", - "bad value for \"color\", \ - (expected \"auto\", \"always\" or \"never\")")) - | Some setting -> color := Some setting - end +(** Utilities *) +val scrape_alias: t -> module_type -> module_type +val check_value_name: string -> Location.t -> unit - | "intf-suffix" -> Config.interface_suffix := v +module Persistent_signature : sig + type t = + { filename : string; (** Name of the file containing the signature. *) + cmi : Cmi_format.cmi_infos } - | "I" -> begin - match position with - | Before_args -> first_include_dirs := v :: !first_include_dirs - | Before_link | Before_compile _ -> - last_include_dirs := v :: !last_include_dirs - end + (** Function used to load a persistent signature. The default is to look for + the .cmi file in the load path. This function can be overridden to load + it from memory, for instance to build a self-contained toplevel. *) + val load : (unit_name:string -> t option) ref +end - | "cclib" -> - begin - match position with - | Before_compile _ -> () - | Before_link | Before_args -> - ccobjs := Misc.rev_split_words v @ !ccobjs - end +end = struct +#1 "env.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) - | "ccopts" -> - begin - match position with - | Before_link | Before_compile _ -> - last_ccopts := v :: !last_ccopts - | Before_args -> - first_ccopts := v :: !first_ccopts - end +(* Environment handling *) - | "ppx" -> - begin - match position with - | Before_link | Before_compile _ -> - last_ppx := v :: !last_ppx - | Before_args -> - first_ppx := v :: !first_ppx - end +open Cmi_format +open Config +open Misc +open Asttypes +open Longident +open Path +open Types +open Btype +let add_delayed_check_forward = ref (fun _ -> assert false) - | "cmo" | "cma" -> - if not !native_code then - begin - match position with - | Before_link | Before_compile _ -> - last_objfiles := v ::! last_objfiles - | Before_args -> - first_objfiles := v :: !first_objfiles - end +let value_declarations : ((string * Location.t), (unit -> unit)) Hashtbl.t = + Hashtbl.create 16 + (* This table is used to usage of value declarations. A declaration is + identified with its name and location. The callback attached to a + declaration is called whenever the value is used explicitly + (lookup_value) or implicitly (inclusion test between signatures, + cf Includemod.value_descriptions). *) - | "cmx" | "cmxa" -> - if !native_code then - begin - match position with - | Before_link | Before_compile _ -> - last_objfiles := v ::! last_objfiles - | Before_args -> - first_objfiles := v :: !first_objfiles - end +let type_declarations = Hashtbl.create 16 +let module_declarations = Hashtbl.create 16 - | "pic" -> - if !native_code then - set "pic" [ pic_code ] v +type constructor_usage = Positive | Pattern | Privatize +type constructor_usages = + { + mutable cu_positive: bool; + mutable cu_pattern: bool; + mutable cu_privatize: bool; + } +let add_constructor_usage cu = function + | Positive -> cu.cu_positive <- true + | Pattern -> cu.cu_pattern <- true + | Privatize -> cu.cu_privatize <- true +let constructor_usages () = + {cu_positive = false; cu_pattern = false; cu_privatize = false} - | "can-discard" -> - can_discard := v ::!can_discard +let used_constructors : + (string * Location.t * string, (constructor_usage -> unit)) Hashtbl.t + = Hashtbl.create 16 - | "timings" | "profile" -> - let if_on = if name = "timings" then [ `Time ] else Profile.all_columns in - profile_columns := if check_bool ppf name v then if_on else [] +let prefixed_sg = Hashtbl.create 113 - | "plugin" -> !load_plugin v +type error = + | Illegal_renaming of string * string * string + | Inconsistent_import of string * string * string + | Need_recursive_types of string * string + | Depend_on_unsafe_string_unit of string * string + | Missing_module of Location.t * Path.t * Path.t + | Illegal_value_name of Location.t * string - | _ -> - if not (List.mem name !can_discard) then begin - can_discard := name :: !can_discard; - Printf.eprintf - "Warning: discarding value of variable %S in OCAMLPARAM\n%!" - name - end +exception Error of error -let read_OCAMLPARAM ppf position = - try - let s = Sys.getenv "OCAMLPARAM" in - let (before, after) = - try - parse_args s - with SyntaxError s -> - Location.print_warning Location.none ppf - (Warnings.Bad_env_variable ("OCAMLPARAM", s)); - [],[] - in - List.iter (fun (name, v) -> read_one_param ppf position name v) - (match position with - Before_args -> before - | Before_compile _ | Before_link -> after) - with Not_found -> () +let error err = raise (Error err) -(* OCAMLPARAM passed as file *) +module EnvLazy : sig + type ('a,'b) t -type pattern = - | Filename of string - | Any + type log -type file_option = { - pattern : pattern; - name : string; - value : string; -} + val force : ('a -> 'b) -> ('a,'b) t -> 'b + val create : 'a -> ('a,'b) t + val get_arg : ('a,'b) t -> 'a option -let scan_line ic = - Scanf.bscanf ic "%[0-9a-zA-Z_.*] : %[a-zA-Z_-] = %s " - (fun pattern name value -> - let pattern = - match pattern with - | "*" -> Any - | _ -> Filename pattern - in - { pattern; name; value }) + (* [force_logged log f t] is equivalent to [force f t] but if [f] returns [None] then + [t] is recorded in [log]. [backtrack log] will then reset all the recorded [t]s back + to their original state. *) + val log : unit -> log + val force_logged : log -> ('a -> 'b option) -> ('a,'b option) t -> 'b option + val backtrack : log -> unit -let load_config ppf filename = - match open_in_bin filename with - | exception e -> - Location.print_error ppf (Location.in_file filename); - Format.fprintf ppf "Cannot open file %s@." (Printexc.to_string e); - raise Exit - | ic -> - let sic = Scanf.Scanning.from_channel ic in - let rec read line_number line_start acc = - match scan_line sic with - | exception End_of_file -> - close_in ic; - acc - | exception Scanf.Scan_failure error -> - let position = Lexing.{ - pos_fname = filename; - pos_lnum = line_number; - pos_bol = line_start; - pos_cnum = pos_in ic; - } - in - let loc = Location.{ - loc_start = position; - loc_end = position; - loc_ghost = false; - } - in - Location.print_error ppf loc; - Format.fprintf ppf "Configuration file error %s@." error; - close_in ic; - raise Exit - | line -> - read (line_number + 1) (pos_in ic) (line :: acc) - in - let lines = read 0 0 [] in - lines +end = struct -let matching_filename filename { pattern } = - match pattern with - | Any -> true - | Filename pattern -> - let filename = String.lowercase_ascii filename in - let pattern = String.lowercase_ascii pattern in - filename = pattern + type ('a,'b) t = ('a,'b) eval ref -let apply_config_file ppf position = - let config_file = - Filename.concat Config.standard_library "ocaml_compiler_internal_params" - in - let config = - if Sys.file_exists config_file then - load_config ppf config_file - else - [] - in - let config = - match position with - | Before_compile filename -> - List.filter (matching_filename filename) config - | Before_args | Before_link -> - List.filter (fun { pattern } -> pattern = Any) config - in - List.iter (fun { name; value } -> read_one_param ppf position name value) - config + and ('a,'b) eval = + | Done of 'b + | Raise of exn + | Thunk of 'a -let readenv ppf position = - last_include_dirs := []; - last_ccopts := []; - last_ppx := []; - last_objfiles := []; - apply_config_file ppf position; - read_OCAMLPARAM ppf position; - all_ccopts := !last_ccopts @ !first_ccopts; - all_ppx := !last_ppx @ !first_ppx + type undo = + | Nil + | Cons : ('a, 'b) t * 'a * undo -> undo -let get_objfiles ~with_ocamlparam = - if with_ocamlparam then - List.rev (!last_objfiles @ !objfiles @ !first_objfiles) - else - List.rev !objfiles + type log = undo ref + let force f x = + match !x with + | Done x -> x + | Raise e -> raise e + | Thunk e -> + match f e with + | y -> + x := Done y; + y + | exception e -> + x := Raise e; + raise e + let get_arg x = + match !x with Thunk a -> Some a | _ -> None + let create x = + ref (Thunk x) + let log () = + ref Nil + let force_logged log f x = + match !x with + | Done x -> x + | Raise e -> raise e + | Thunk e -> + match f e with + | None -> + x := Done None; + log := Cons(x, e, !log); + None + | Some _ as y -> + x := Done y; + y + | exception e -> + x := Raise e; + raise e -type deferred_action = - | ProcessImplementation of string - | ProcessInterface of string - | ProcessCFile of string - | ProcessOtherFile of string - | ProcessObjects of string list - | ProcessDLLs of string list + let backtrack log = + let rec loop = function + | Nil -> () + | Cons(x, e, rest) -> + x := Thunk e; + loop rest + in + loop !log -let c_object_of_filename name = - Filename.chop_suffix (Filename.basename name) ".c" ^ Config.ext_obj +end -let process_action - (ppf, implementation, interface, ocaml_mod_ext, ocaml_lib_ext) action = - match action with - | ProcessImplementation name -> - readenv ppf (Before_compile name); - let opref = output_prefix name in - implementation ppf name opref; - objfiles := (opref ^ ocaml_mod_ext) :: !objfiles - | ProcessInterface name -> - readenv ppf (Before_compile name); - let opref = output_prefix name in - interface ppf name opref; - if !make_package then objfiles := (opref ^ ".cmi") :: !objfiles - | ProcessCFile name -> - readenv ppf (Before_compile name); - Location.set_input_name name; - if Ccomp.compile_file name <> 0 then exit 2; - ccobjs := c_object_of_filename name :: !ccobjs - | ProcessObjects names -> - ccobjs := names @ !ccobjs - | ProcessDLLs names -> - dllibs := names @ !dllibs - | ProcessOtherFile name -> - if Filename.check_suffix name ocaml_mod_ext - || Filename.check_suffix name ocaml_lib_ext then - objfiles := name :: !objfiles - else if Filename.check_suffix name ".cmi" && !make_package then - objfiles := name :: !objfiles - else if Filename.check_suffix name Config.ext_obj - || Filename.check_suffix name Config.ext_lib then - ccobjs := name :: !ccobjs - else if not !native_code && Filename.check_suffix name Config.ext_dll then - dllibs := name :: !dllibs - else - raise(Arg.Bad("don't know what to do with " ^ name)) +module PathMap = Map.Make(Path) +type summary = + Env_empty + | Env_value of summary * Ident.t * value_description + | Env_type of summary * Ident.t * type_declaration + | Env_extension of summary * Ident.t * extension_constructor + | Env_module of summary * Ident.t * module_declaration + | Env_modtype of summary * Ident.t * modtype_declaration + | Env_class of summary * Ident.t * class_declaration + | Env_cltype of summary * Ident.t * class_type_declaration + | Env_open of summary * Path.t + | Env_functor_arg of summary * Ident.t + | Env_constraints of summary * type_declaration PathMap.t + | Env_copy_types of summary * string list -let action_of_file name = - if Filename.check_suffix name ".ml" - || Filename.check_suffix name ".mlt" then - ProcessImplementation name - else if Filename.check_suffix name !Config.interface_suffix then - ProcessInterface name - else if Filename.check_suffix name ".c" then - ProcessCFile name - else - ProcessOtherFile name +module TycompTbl = + struct + (** This module is used to store components of types (i.e. labels + and constructors). We keep a representation of each nested + "open" and the set of local bindings between each of them. *) -let deferred_actions = ref [] -let defer action = - deferred_actions := action :: !deferred_actions + type 'a t = { + current: 'a Ident.tbl; + (** Local bindings since the last open. *) -let anonymous filename = defer (action_of_file filename) -let impl filename = defer (ProcessImplementation filename) -let intf filename = defer (ProcessInterface filename) + opened: 'a opened option; + (** Symbolic representation of the last (innermost) open, if any. *) + } -let process_deferred_actions env = - let final_output_name = !output_name in - (* Make sure the intermediate products don't clash with the final one - when we're invoked like: ocamlopt -o foo bar.c baz.ml. *) - if not !compile_only then output_name := None; - begin - match final_output_name with - | None -> () - | Some output_name -> - if !compile_only then begin - if List.filter (function - | ProcessCFile name -> c_object_of_filename name <> output_name - | _ -> false) !deferred_actions <> [] then - fatal "Options -c and -o are incompatible when compiling C files"; + and 'a opened = { + components: (string, 'a list) Tbl.t; + (** Components from the opened module. We keep a list of + bindings for each name, as in comp_labels and + comp_constrs. *) - if List.length (List.filter (function - | ProcessImplementation _ - | ProcessInterface _ - | _ -> false) !deferred_actions) > 1 then - fatal "Options -c -o are incompatible with compiling multiple files" - end; - end; - if !make_archive && List.exists (function - | ProcessOtherFile name -> Filename.check_suffix name ".cmxa" - | _ -> false) !deferred_actions then - fatal "Option -a cannot be used with .cmxa input files."; - List.iter (process_action env) (List.rev !deferred_actions); - output_name := final_output_name; + using: (string -> ('a * 'a) option -> unit) option; + (** A callback to be applied when a component is used from this + "open". This is used to detect unused "opens". The + arguments are used to detect shadowing. *) -end -module Ext_pervasives : sig -#1 "ext_pervasives.mli" -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) + next: 'a t; + (** The table before opening the module. *) + } + let empty = { current = Ident.empty; opened = None } + let add id x tbl = + {tbl with current = Ident.add id x tbl.current} + let add_open slot wrap components next = + let using = + match slot with + | None -> None + | Some f -> Some (fun s x -> f s (wrap x)) + in + { + current = Ident.empty; + opened = Some {using; components; next}; + } + let rec find_same id tbl = + try Ident.find_same id tbl.current + with Not_found as exn -> + begin match tbl.opened with + | Some {next; _} -> find_same id next + | None -> raise exn + end + let nothing = fun () -> () + let mk_callback rest name desc = function + | None -> nothing + | Some f -> + (fun () -> + match rest with + | [] -> f name None + | (hidden, _) :: _ -> f name (Some (desc, hidden)) + ) + let rec find_all name tbl = + List.map (fun (_id, desc) -> desc, nothing) + (Ident.find_all name tbl.current) @ + match tbl.opened with + | None -> [] + | Some {using; next; components} -> + let rest = find_all name next in + match Tbl.find_str name components with + | exception Not_found -> rest + | opened -> + List.map + (fun desc -> desc, mk_callback rest name desc using) + opened + @ rest -(** Extension to standard library [Pervavives] module, safe to open - *) + let rec fold_name f tbl acc = + let acc = Ident.fold_name (fun _id d -> f d) tbl.current acc in + match tbl.opened with + | Some {using = _; next; components} -> + acc + |> Tbl.fold + (fun _name -> List.fold_right (fun desc -> f desc)) + components + |> fold_name f next + | None -> + acc -external reraise: exn -> 'a = "%reraise" + let rec local_keys tbl acc = + let acc = Ident.fold_all (fun k _ accu -> k::accu) tbl.current acc in + match tbl.opened with + | Some o -> local_keys o.next acc + | None -> acc -val finally : - 'a -> - clean:('a -> 'c) -> - ('a -> 'b) -> 'b + let diff_keys is_local tbl1 tbl2 = + let keys2 = local_keys tbl2 [] in + List.filter + (fun id -> + is_local (find_same id tbl2) && + try ignore (find_same id tbl1); false + with Not_found -> true) + keys2 -val try_it : (unit -> 'a) -> unit + end -val with_file_as_chan : string -> (out_channel -> 'a) -> 'a +module IdTbl = + struct + (** This module is used to store all kinds of components except + (labels and constructors) in environments. We keep a + representation of each nested "open" and the set of local + bindings between each of them. *) + type 'a t = { + current: 'a Ident.tbl; + (** Local bindings since the last open *) + opened: 'a opened option; + (** Symbolic representation of the last (innermost) open, if any. *) + } + and 'a opened = { + root: Path.t; + (** The path of the opened module, to be prefixed in front of + its local names to produce a valid path in the current + environment. *) + components: (string, 'a * int) Tbl.t; + (** Components from the opened module. *) + using: (string -> ('a * 'a) option -> unit) option; + (** A callback to be applied when a component is used from this + "open". This is used to detect unused "opens". The + arguments are used to detect shadowing. *) + next: 'a t; + (** The table before opening the module. *) + } + let empty = { current = Ident.empty; opened = None } + let add id x tbl = + {tbl with current = Ident.add id x tbl.current} + let add_open slot wrap root components next = + let using = + match slot with + | None -> None + | Some f -> Some (fun s x -> f s (wrap x)) + in + { + current = Ident.empty; + opened = Some {using; root; components; next}; + } + let rec find_same id tbl = + try Ident.find_same id tbl.current + with Not_found as exn -> + begin match tbl.opened with + | Some {next; _} -> find_same id next + | None -> raise exn + end -external id : 'a -> 'a = "%identity" + let rec find_name mark name tbl = + try + let (id, desc) = Ident.find_name name tbl.current in + Pident id, desc + with Not_found as exn -> + begin match tbl.opened with + | Some {using; root; next; components} -> + begin try + let (descr, pos) = Tbl.find_str name components in + let res = Pdot (root, name, pos), descr in + if mark then begin match using with + | None -> () + | Some f -> + begin try f name (Some (snd (find_name false name next), snd res)) + with Not_found -> f name None + end + end; + res + with Not_found -> + find_name mark name next + end + | None -> + raise exn + end -(** Copied from {!Btype.hash_variant}: - need sync up and add test case - *) -val hash_variant : string -> int + let find_name name tbl = find_name true name tbl -val todo : string -> 'a + let rec update name f tbl = + try + let (id, desc) = Ident.find_name name tbl.current in + let new_desc = f desc in + {tbl with current = Ident.add id new_desc tbl.current} + with Not_found -> + begin match tbl.opened with + | Some {root; using; next; components} -> + begin try + let (desc, pos) = Tbl.find_str name components in + let new_desc = f desc in + let components = Tbl.add name (new_desc, pos) components in + {tbl with opened = Some {root; using; next; components}} + with Not_found -> + let next = update name f next in + {tbl with opened = Some {root; using; next; components}} + end + | None -> + tbl + end -val nat_of_string_exn : string -> int -val parse_nat_of_string: - string -> - int ref -> - int -end = struct -#1 "ext_pervasives.ml" -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) + let rec find_all name tbl = + List.map (fun (id, desc) -> Pident id, desc) (Ident.find_all name tbl.current) @ + match tbl.opened with + | None -> [] + | Some {root; using = _; next; components} -> + try + let (desc, pos) = Tbl.find_str name components in + (Pdot (root, name, pos), desc) :: find_all name next + with Not_found -> + find_all name next + let rec fold_name f tbl acc = + let acc = Ident.fold_name (fun id d -> f (Ident.name id) (Pident id, d)) tbl.current acc in + match tbl.opened with + | Some {root; using = _; next; components} -> + acc + |> Tbl.fold + (fun name (desc, pos) -> f name (Pdot (root, name, pos), desc)) + components + |> fold_name f next + | None -> + acc + let rec local_keys tbl acc = + let acc = Ident.fold_all (fun k _ accu -> k::accu) tbl.current acc in + match tbl.opened with + | Some o -> local_keys o.next acc + | None -> acc + let rec iter f tbl = + Ident.iter (fun id desc -> f id (Pident id, desc)) tbl.current; + match tbl.opened with + | Some {root; using = _; next; components} -> + Tbl.iter + (fun s (x, pos) -> f (Ident.hide (Ident.create s) (* ??? *)) (Pdot (root, s, pos), x)) + components; + iter f next + | None -> () -external reraise: exn -> 'a = "%reraise" + let diff_keys tbl1 tbl2 = + let keys2 = local_keys tbl2 [] in + List.filter + (fun id -> + try ignore (find_same id tbl1); false + with Not_found -> true) + keys2 -let finally v ~clean:action f = - match f v with - | exception e -> - action v ; - reraise e - | e -> action v ; e -let try_it f = - try ignore (f ()) with _ -> () + end -let with_file_as_chan filename f = - finally (open_out_bin filename) ~clean:close_out f +type type_descriptions = + constructor_description list * label_description list +let in_signature_flag = 0x01 +let implicit_coercion_flag = 0x02 +type t = { + values: value_description IdTbl.t; + constrs: constructor_description TycompTbl.t; + labels: label_description TycompTbl.t; + types: (type_declaration * type_descriptions) IdTbl.t; + modules: (Subst.t * module_declaration, module_declaration) EnvLazy.t IdTbl.t; + modtypes: modtype_declaration IdTbl.t; + components: module_components IdTbl.t; + classes: class_declaration IdTbl.t; + cltypes: class_type_declaration IdTbl.t; + functor_args: unit Ident.tbl; + summary: summary; + local_constraints: type_declaration PathMap.t; + gadt_instances: (int * TypeSet.t ref) list; + flags: int; +} +and module_components = + { + deprecated: string option; + loc: Location.t; + comps: + (t * Subst.t * Path.t * Types.module_type, module_components_repr option) + EnvLazy.t; + } +and module_components_repr = + Structure_comps of structure_components + | Functor_comps of functor_components +and 'a comp_tbl = (string, ('a * int)) Tbl.t -external id : 'a -> 'a = "%identity" +and structure_components = { + mutable comp_values: value_description comp_tbl; + mutable comp_constrs: (string, constructor_description list) Tbl.t; + mutable comp_labels: (string, label_description list) Tbl.t; + mutable comp_types: (type_declaration * type_descriptions) comp_tbl; + mutable comp_modules: + (Subst.t * module_declaration, module_declaration) EnvLazy.t comp_tbl; + mutable comp_modtypes: modtype_declaration comp_tbl; + mutable comp_components: module_components comp_tbl; + mutable comp_classes: class_declaration comp_tbl; + mutable comp_cltypes: class_type_declaration comp_tbl; +} +and functor_components = { + fcomp_param: Ident.t; (* Formal parameter *) + fcomp_arg: module_type option; (* Argument signature *) + fcomp_res: module_type; (* Result signature *) + fcomp_cache: (Path.t, module_components) Hashtbl.t; (* For memoization *) + fcomp_subst_cache: (Path.t, module_type) Hashtbl.t +} -let hash_variant s = - let accu = ref 0 in - for i = 0 to String.length s - 1 do - accu := 223 * !accu + Char.code s.[i] - done; - (* reduce to 31 bits *) - accu := !accu land (1 lsl 31 - 1); - (* make it signed for 64 bits architectures *) - if !accu > 0x3FFFFFFF then !accu - (1 lsl 31) else !accu +let copy_local ~from env = + { env with + local_constraints = from.local_constraints; + gadt_instances = from.gadt_instances; + flags = from.flags } -let todo loc = - failwith (loc ^ " Not supported yet") +let same_constr = ref (fun _ _ _ -> assert false) +(* Helper to decide whether to report an identifier shadowing + by some 'open'. For labels and constructors, we do not report + if the two elements are from the same re-exported declaration. + Later, one could also interpret some attributes on value and + type declarations to silence the shadowing warnings. *) +let check_shadowing env = function + | `Constructor (Some (c1, c2)) + when not (!same_constr env c1.cstr_res c2.cstr_res) -> + Some "constructor" + | `Label (Some (l1, l2)) + when not (!same_constr env l1.lbl_res l2.lbl_res) -> + Some "label" + | `Value (Some _) -> Some "value" + | `Type (Some _) -> Some "type" + | `Module (Some _) | `Component (Some _) -> Some "module" + | `Module_type (Some _) -> Some "module type" + | `Class (Some _) -> Some "class" + | `Class_type (Some _) -> Some "class type" + | `Constructor _ | `Label _ + | `Value None | `Type None | `Module None | `Module_type None + | `Class None | `Class_type None | `Component None -> + None -let rec int_of_string_aux s acc off len = - if off >= len then acc - else - let d = (Char.code (String.unsafe_get s off) - 48) in - if d >=0 && d <= 9 then - int_of_string_aux s (10*acc + d) (off + 1) len - else -1 (* error *) +let subst_modtype_maker (subst, md) = + if subst == Subst.identity then md + else {md with md_type = Subst.modtype subst md.md_type} -let nat_of_string_exn (s : string) = - let acc = int_of_string_aux s 0 0 (String.length s) in - if acc < 0 then invalid_arg s - else acc +let empty = { + values = IdTbl.empty; constrs = TycompTbl.empty; + labels = TycompTbl.empty; types = IdTbl.empty; + modules = IdTbl.empty; modtypes = IdTbl.empty; + components = IdTbl.empty; classes = IdTbl.empty; + cltypes = IdTbl.empty; + summary = Env_empty; local_constraints = PathMap.empty; gadt_instances = []; + flags = 0; + functor_args = Ident.empty; + } +let in_signature b env = + let flags = + if b then env.flags lor in_signature_flag + else env.flags land (lnot in_signature_flag) + in + {env with flags} -(** return index *) -let parse_nat_of_string (s : string) (cursor : int ref) = - let current = !cursor in - assert (current >= 0); - let acc = ref 0 in - let s_len = String.length s in - let todo = ref true in - let cur = ref current in - while !todo && !cursor < s_len do - let d = Char.code (String.unsafe_get s !cur) - 48 in - if d >=0 && d <= 9 then begin - acc := 10* !acc + d; - incr cur - end else todo := false - done ; - cursor := !cur; - !acc -end -module Ext_io : sig -#1 "ext_io.mli" -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +let implicit_coercion env = + {env with flags = env.flags lor implicit_coercion_flag} -val load_file : string -> string +let is_in_signature env = env.flags land in_signature_flag <> 0 +let is_implicit_coercion env = env.flags land implicit_coercion_flag <> 0 -val rev_lines_of_file : string -> string list +let is_ident = function + Pident _ -> true + | Pdot _ | Papply _ -> false -val rev_lines_of_chann : in_channel -> string list +let is_local_ext = function + | {cstr_tag = Cstr_extension(p, _)} -> is_ident p + | _ -> false -val write_file : string -> string -> unit +let diff env1 env2 = + IdTbl.diff_keys env1.values env2.values @ + TycompTbl.diff_keys is_local_ext env1.constrs env2.constrs @ + IdTbl.diff_keys env1.modules env2.modules @ + IdTbl.diff_keys env1.classes env2.classes -end = struct -#1 "ext_io.ml" -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +type can_load_cmis = + | Can_load_cmis + | Cannot_load_cmis of EnvLazy.log +let can_load_cmis = ref Can_load_cmis -(** on 32 bit , there are 16M limitation *) -let load_file f = - Ext_pervasives.finally (open_in_bin f) ~clean:close_in begin fun ic -> - let n = in_channel_length ic in - let s = Bytes.create n in - really_input ic s 0 n; - Bytes.unsafe_to_string s - end +let without_cmis f x = + let log = EnvLazy.log () in + let res = + Misc.(protect_refs + [R (can_load_cmis, Cannot_load_cmis log)] + (fun () -> f x)) + in + EnvLazy.backtrack log; + res +(* Forward declarations *) -let rev_lines_of_chann chan = - let rec loop acc chan = - match input_line chan with - | line -> loop (line :: acc) chan - | exception End_of_file -> close_in chan ; acc in - loop [] chan +let components_of_module' = + ref ((fun ~deprecated:_ ~loc:_ _env _sub _path _mty -> assert false) : + deprecated:string option -> loc:Location.t -> t -> Subst.t -> + Path.t -> module_type -> + module_components) +let components_of_module_maker' = + ref ((fun (_env, _sub, _path, _mty) -> assert false) : + t * Subst.t * Path.t * module_type -> module_components_repr option) +let components_of_functor_appl' = + ref ((fun _f _env _p1 _p2 -> assert false) : + functor_components -> t -> Path.t -> Path.t -> module_components) +let check_modtype_inclusion = + (* to be filled with Includemod.check_modtype_inclusion *) + ref ((fun ~loc:_ _env _mty1 _path1 _mty2 -> assert false) : + loc:Location.t -> t -> module_type -> Path.t -> module_type -> unit) +let strengthen = + (* to be filled with Mtype.strengthen *) + ref ((fun ~aliasable:_ _env _mty _path -> assert false) : + aliasable:bool -> t -> module_type -> Path.t -> module_type) +let md md_type = + {md_type; md_attributes=[]; md_loc=Location.none} -let rev_lines_of_file file = - Ext_pervasives.finally - ~clean:close_in - (open_in_bin file) rev_lines_of_chann +let get_components_opt c = + match !can_load_cmis with + | Can_load_cmis -> + EnvLazy.force !components_of_module_maker' c.comps + | Cannot_load_cmis log -> + EnvLazy.force_logged log !components_of_module_maker' c.comps +let empty_structure = + Structure_comps { + comp_values = Tbl.empty; + comp_constrs = Tbl.empty; + comp_labels = Tbl.empty; + comp_types = Tbl.empty; + comp_modules = Tbl.empty; comp_modtypes = Tbl.empty; + comp_components = Tbl.empty; comp_classes = Tbl.empty; + comp_cltypes = Tbl.empty } -let write_file f content = - Ext_pervasives.finally ~clean:close_out - (open_out_bin f) begin fun oc -> - output_string oc content - end +let get_components c = + match get_components_opt c with + | None -> empty_structure + | Some c -> c -end -module Bs_exception : sig -#1 "bs_exception.mli" -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +(* The name of the compilation unit currently compiled. + "" if outside a compilation unit. *) -type error = - | Cmj_not_found of string - | Js_not_found of string - | Bs_cyclic_depends of string list - | Bs_duplicated_module of string * string - | Bs_duplicate_exports of string (* gpr_974 *) - | Bs_package_not_found of string - | Bs_main_not_exist of string - | Bs_invalid_path of string - | Missing_ml_dependency of string - | Dependency_script_module_dependent_not of string -(* -TODO: In the futrue, we should refine dependency [bsb] -should not rely on such exception, it should have its own exception handling -*) +let current_unit = ref "" -(* exception Error of error *) +(* Persistent structure descriptions *) -(* val report_error : Format.formatter -> error -> unit *) +type pers_struct = + { ps_name: string; + ps_sig: signature Lazy.t; + ps_comps: module_components; + ps_crcs: (string * Digest.t option) list; + ps_filename: string; + ps_flags: pers_flags list } -val error : error -> 'a +let persistent_structures = + (Hashtbl.create 17 : (string, pers_struct option) Hashtbl.t) -end = struct -#1 "bs_exception.ml" -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +(* Consistency between persistent structures *) +let crc_units = Consistbl.create() -type error = - | Cmj_not_found of string - | Js_not_found of string - | Bs_cyclic_depends of string list - | Bs_duplicated_module of string * string - | Bs_duplicate_exports of string (* gpr_974 *) - | Bs_package_not_found of string - | Bs_main_not_exist of string - | Bs_invalid_path of string - | Missing_ml_dependency of string - | Dependency_script_module_dependent_not of string - (** TODO: we need add location handling *) -exception Error of error +module StringSet = + Set.Make(struct type t = string let compare = String.compare end) -let error err = raise (Error err) +let imported_units = ref StringSet.empty -let report_error ppf = function - | Dependency_script_module_dependent_not s - -> - Format.fprintf ppf - "%s is compiled in script mode while its dependent is not" - s - | Missing_ml_dependency s -> - Format.fprintf ppf "Missing dependency %s in search path" s - | Cmj_not_found s -> - Format.fprintf ppf "%s not found, it means either the module does not exist or it is a namespace" s - | Js_not_found s -> - Format.fprintf ppf "%s not found, needed in script mode " s - | Bs_cyclic_depends str - -> - Format.fprintf ppf "Cyclic depends : @[%a@]" - (Format.pp_print_list ~pp_sep:Format.pp_print_space - Format.pp_print_string) - str - | Bs_duplicate_exports str -> - Format.fprintf ppf "%s are exported as twice" str - | Bs_duplicated_module (a,b) - -> - Format.fprintf ppf "The build system does not support two files with same names yet %s, %s" a b - | Bs_main_not_exist main - -> - Format.fprintf ppf "File %s not found " main +let add_import s = + imported_units := StringSet.add s !imported_units - | Bs_package_not_found package - -> - Format.fprintf ppf "Package %s not found or %s/lib/ocaml does not exist or please set npm_config_prefix correctly" - package package - | Bs_invalid_path path - -> Format.pp_print_string ppf ("Invalid path: " ^ path ) +let imported_opaque_units = ref StringSet.empty + +let add_imported_opaque s = + imported_opaque_units := StringSet.add s !imported_opaque_units +let clear_imports () = + Consistbl.clear crc_units; + imported_units := StringSet.empty; + imported_opaque_units := StringSet.empty -let () = - Location.register_error_of_exn +let check_consistency ps = + try + List.iter + (fun (name, crco) -> + match crco with + None -> () + | Some crc -> + add_import name; + Consistbl.check crc_units name crc ps.ps_filename) + ps.ps_crcs; + with Consistbl.Inconsistency(name, source, auth) -> + error (Inconsistent_import(name, auth, source)) + +(* Reading persistent structures from .cmi files *) + +let save_pers_struct crc ps = + let modname = ps.ps_name in + Hashtbl.add persistent_structures modname (Some ps); + List.iter (function - | Error err - -> Some (Location.error_of_printer_file report_error err) - | _ -> None - ) + | Rectypes -> () + | Deprecated _ -> () + | Unsafe_string -> () + | Opaque -> add_imported_opaque modname) + ps.ps_flags; + Consistbl.set crc_units modname crc ps.ps_filename; + add_import modname + +module Persistent_signature = struct + type t = + { filename : string; + cmi : Cmi_format.cmi_infos } + let load = ref (fun ~unit_name -> + match find_in_path_uncap !load_path (unit_name ^ ".cmi") with + | filename -> Some { filename; cmi = read_cmi filename } + | exception Not_found -> None) end -module Builtin_attributes : sig -#1 "builtin_attributes.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Alain Frisch, LexiFi *) -(* *) -(* Copyright 2012 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) -(* Support for some of the builtin attributes: +let acknowledge_pers_struct check modname + { Persistent_signature.filename; cmi } = + let name = cmi.cmi_name in + let sign = cmi.cmi_sign in + let crcs = cmi.cmi_crcs in + let flags = cmi.cmi_flags in + let deprecated = + List.fold_left (fun acc -> function Deprecated s -> Some s | _ -> acc) None + flags + in + let comps = + !components_of_module' ~deprecated ~loc:Location.none + empty Subst.identity + (Pident(Ident.create_persistent name)) + (Mty_signature sign) + in + let ps = { ps_name = name; + ps_sig = lazy (Subst.signature Subst.identity sign); + ps_comps = comps; + ps_crcs = crcs; + ps_filename = filename; + ps_flags = flags; + } in + if ps.ps_name <> modname then + error (Illegal_renaming(modname, ps.ps_name, filename)); - ocaml.deprecated - ocaml.error - ocaml.ppwarning - ocaml.warning - ocaml.warnerror - ocaml.explicit_arity (for camlp4/camlp5) - ocaml.warn_on_literal_pattern - ocaml.deprecated_mutable - ocaml.immediate - ocaml.boxed / ocaml.unboxed -*) + List.iter + (function + | Rectypes -> + if not !Clflags.recursive_types then + error (Need_recursive_types(ps.ps_name, !current_unit)) + | Unsafe_string -> + if Config.safe_string then + error (Depend_on_unsafe_string_unit (ps.ps_name, !current_unit)); + | Deprecated _ -> () + | Opaque -> add_imported_opaque modname) + ps.ps_flags; + if check then check_consistency ps; + Hashtbl.add persistent_structures modname (Some ps); + ps +let read_pers_struct check modname filename = + add_import modname; + let cmi = read_cmi filename in + acknowledge_pers_struct check modname + { Persistent_signature.filename; cmi } -val check_deprecated: Location.t -> Parsetree.attributes -> string -> unit -val check_deprecated_inclusion: - def:Location.t -> use:Location.t -> Location.t -> Parsetree.attributes -> - Parsetree.attributes -> string -> unit -val deprecated_of_attrs: Parsetree.attributes -> string option -val deprecated_of_sig: Parsetree.signature -> string option -val deprecated_of_str: Parsetree.structure -> string option +let find_pers_struct check name = + if name = "*predef*" then raise Not_found; + match Hashtbl.find persistent_structures name with + | Some ps -> ps + | None -> raise Not_found + | exception Not_found -> + match !can_load_cmis with + | Cannot_load_cmis _ -> raise Not_found + | Can_load_cmis -> + let ps = + match !Persistent_signature.load ~unit_name:name with + | Some ps -> ps + | None -> + Hashtbl.add persistent_structures name None; + raise Not_found + in + add_import name; + acknowledge_pers_struct check name ps -val check_deprecated_mutable: - Location.t -> Parsetree.attributes -> string -> unit -val check_deprecated_mutable_inclusion: - def:Location.t -> use:Location.t -> Location.t -> Parsetree.attributes -> - Parsetree.attributes -> string -> unit +(* Emits a warning if there is no valid cmi for name *) +let check_pers_struct name = + try + ignore (find_pers_struct false name) + with + | Not_found -> + let warn = Warnings.No_cmi_file(name, None) in + Location.prerr_warning Location.none warn + | Cmi_format.Error err -> + let msg = Format.asprintf "%a" Cmi_format.report_error err in + let warn = Warnings.No_cmi_file(name, Some msg) in + Location.prerr_warning Location.none warn + | Error err -> + let msg = + match err with + | Illegal_renaming(name, ps_name, filename) -> + Format.asprintf + " %a@ contains the compiled interface for @ \ + %s when %s was expected" + Location.print_filename filename ps_name name + | Inconsistent_import _ -> assert false + | Need_recursive_types(name, _) -> + Format.sprintf + "%s uses recursive types" + name + | Depend_on_unsafe_string_unit (name, _) -> + Printf.sprintf "%s uses -unsafe-string" + name + | Missing_module _ -> assert false + | Illegal_value_name _ -> assert false + in + let warn = Warnings.No_cmi_file(name, Some msg) in + Location.prerr_warning Location.none warn -val error_of_extension: Parsetree.extension -> Location.error +let read_pers_struct modname filename = + read_pers_struct true modname filename -val warning_attribute: ?ppwarning:bool -> Parsetree.attribute -> unit - (** Apply warning settings from the specified attribute. - "ocaml.warning"/"ocaml.warnerror" (and variants without the prefix) - are processed and other attributes are ignored. +let find_pers_struct name = + find_pers_struct true name - Also implement ocaml.ppwarning (unless ~ppwarning:false is - passed). - *) +let check_pers_struct name = + if not (Hashtbl.mem persistent_structures name) then begin + (* PR#6843: record the weak dependency ([add_import]) regardless of + whether the check succeeds, to help make builds more + deterministic. *) + add_import name; + if (Warnings.is_active (Warnings.No_cmi_file("", None))) then + !add_delayed_check_forward + (fun () -> check_pers_struct name) + end -val warning_scope: - ?ppwarning:bool -> - Parsetree.attributes -> (unit -> 'a) -> 'a - (** Execute a function in a new scope for warning settings. This - means that the effect of any call to [warning_attribute] during - the execution of this function will be discarded after - execution. +let reset_cache () = + current_unit := ""; + Hashtbl.clear persistent_structures; + clear_imports (); + Hashtbl.clear value_declarations; + Hashtbl.clear type_declarations; + Hashtbl.clear module_declarations; + Hashtbl.clear used_constructors; + Hashtbl.clear prefixed_sg - The function also takes a list of attributes which are processed - with [warning_attribute] in the fresh scope before the function - is executed. - *) +let reset_cache_toplevel () = + (* Delete 'missing cmi' entries from the cache. *) + let l = + Hashtbl.fold + (fun name r acc -> if r = None then name :: acc else acc) + persistent_structures [] + in + List.iter (Hashtbl.remove persistent_structures) l; + Hashtbl.clear value_declarations; + Hashtbl.clear type_declarations; + Hashtbl.clear module_declarations; + Hashtbl.clear used_constructors; + Hashtbl.clear prefixed_sg -val warn_on_literal_pattern: Parsetree.attributes -> bool -val explicit_arity: Parsetree.attributes -> bool +let set_unit_name name = + current_unit := name -val immediate: Parsetree.attributes -> bool +let get_unit_name () = + !current_unit -val has_unboxed: Parsetree.attributes -> bool -val has_boxed: Parsetree.attributes -> bool +(* Lookup by identifier *) -end = struct -#1 "builtin_attributes.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Alain Frisch, LexiFi *) -(* *) -(* Copyright 2012 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let rec find_module_descr path env = + match path with + Pident id -> + begin try + IdTbl.find_same id env.components + with Not_found -> + if Ident.persistent id && not (Ident.name id = !current_unit) + then (find_pers_struct (Ident.name id)).ps_comps + else raise Not_found + end + | Pdot(p, s, _pos) -> + begin match get_components (find_module_descr p env) with + Structure_comps c -> + let (descr, _pos) = Tbl.find_str s c.comp_components in + descr + | Functor_comps _ -> + raise Not_found + end + | Papply(p1, p2) -> + begin match get_components (find_module_descr p1 env) with + Functor_comps f -> + !components_of_functor_appl' f env p1 p2 + | Structure_comps _ -> + raise Not_found + end -open Asttypes -open Parsetree +let find proj1 proj2 path env = + match path with + Pident id -> + IdTbl.find_same id (proj1 env) + | Pdot(p, s, _pos) -> + begin match get_components (find_module_descr p env) with + Structure_comps c -> + let (data, _pos) = Tbl.find_str s (proj2 c) in data + | Functor_comps _ -> + raise Not_found + end + | Papply _ -> + raise Not_found -let string_of_cst = function - | Pconst_string(s, _) -> Some s - | _ -> None +let find_value = + find (fun env -> env.values) (fun sc -> sc.comp_values) +and find_type_full = + find (fun env -> env.types) (fun sc -> sc.comp_types) +and find_modtype = + find (fun env -> env.modtypes) (fun sc -> sc.comp_modtypes) +and find_class = + find (fun env -> env.classes) (fun sc -> sc.comp_classes) +and find_cltype = + find (fun env -> env.cltypes) (fun sc -> sc.comp_cltypes) -let string_of_payload = function - | PStr[{pstr_desc=Pstr_eval({pexp_desc=Pexp_constant c},_)}] -> - string_of_cst c - | _ -> None +let type_of_cstr path = function + | {cstr_inlined = Some d; _} -> + (d, ([], List.map snd (Datarepr.labels_of_type path d))) + | _ -> + assert false -let string_of_opt_payload p = - match string_of_payload p with - | Some s -> s - | None -> "" +let find_type_full path env = + match Path.constructor_typath path with + | Regular p -> + (try (PathMap.find p env.local_constraints, ([], [])) + with Not_found -> find_type_full p env) + | Cstr (ty_path, s) -> + let (_, (cstrs, _)) = + try find_type_full ty_path env + with Not_found -> assert false + in + let cstr = + try List.find (fun cstr -> cstr.cstr_name = s) cstrs + with Not_found -> assert false + in + type_of_cstr path cstr + | LocalExt id -> + let cstr = + try TycompTbl.find_same id env.constrs + with Not_found -> assert false + in + type_of_cstr path cstr + | Ext (mod_path, s) -> + let comps = + try find_module_descr mod_path env + with Not_found -> assert false + in + let comps = + match get_components comps with + | Structure_comps c -> c + | Functor_comps _ -> assert false + in + let exts = + List.filter + (function {cstr_tag=Cstr_extension _} -> true | _ -> false) + (try Tbl.find_str s comps.comp_constrs + with Not_found -> assert false) + in + match exts with + | [cstr] -> type_of_cstr path cstr + | _ -> assert false -let rec error_of_extension ext = - match ext with - | ({txt = ("ocaml.error"|"error") as txt; loc}, p) -> - let rec sub_from inner = - match inner with - | {pstr_desc=Pstr_extension (ext, _)} :: rest -> - error_of_extension ext :: sub_from rest - | _ :: rest -> - (Location.errorf ~loc - "Invalid syntax for sub-error of extension '%s'." txt) :: - sub_from rest - | [] -> [] - in - begin match p with - | PStr [] -> raise Location.Already_displayed_error - | PStr({pstr_desc=Pstr_eval - ({pexp_desc=Pexp_constant(Pconst_string(msg,_))}, _)}:: - {pstr_desc=Pstr_eval - ({pexp_desc=Pexp_constant(Pconst_string(if_highlight,_))}, _)}:: - inner) -> - Location.error ~loc ~if_highlight ~sub:(sub_from inner) msg - | PStr({pstr_desc=Pstr_eval - ({pexp_desc=Pexp_constant(Pconst_string(msg,_))}, _)}::inner) -> - Location.error ~loc ~sub:(sub_from inner) msg - | _ -> Location.errorf ~loc "Invalid syntax for extension '%s'." txt - end - | ({txt; loc}, _) -> - Location.errorf ~loc "Uninterpreted extension '%s'." txt +let find_type p env = + fst (find_type_full p env) +let find_type_descrs p env = + snd (find_type_full p env) -let cat s1 s2 = - if s2 = "" then s1 else - - if Clflags.bs_vscode then s1 ^ " " ^ s2 - else s1 ^ "\n" ^ s2 - +let find_module ~alias path env = + match path with + Pident id -> + begin try + let data = IdTbl.find_same id env.modules in + EnvLazy.force subst_modtype_maker data + with Not_found -> + if Ident.persistent id && not (Ident.name id = !current_unit) then + let ps = find_pers_struct (Ident.name id) in + md (Mty_signature(Lazy.force ps.ps_sig)) + else raise Not_found + end + | Pdot(p, s, _pos) -> + begin match get_components (find_module_descr p env) with + Structure_comps c -> + let (data, _pos) = Tbl.find_str s c.comp_modules in + EnvLazy.force subst_modtype_maker data + | Functor_comps _ -> + raise Not_found + end + | Papply(p1, p2) -> + let desc1 = find_module_descr p1 env in + begin match get_components desc1 with + Functor_comps f -> + md begin match f.fcomp_res with + | Mty_alias _ as mty -> mty + | mty -> + if alias then mty else + try + Hashtbl.find f.fcomp_subst_cache p2 + with Not_found -> + let mty = + Subst.modtype + (Subst.add_module f.fcomp_param p2 Subst.identity) + f.fcomp_res in + Hashtbl.add f.fcomp_subst_cache p2 mty; + mty + end + | Structure_comps _ -> + raise Not_found + end -let rec deprecated_of_attrs = function - | [] -> None - | ({txt = "ocaml.deprecated"|"deprecated"; _}, p) :: _ -> - Some (string_of_opt_payload p) - | _ :: tl -> deprecated_of_attrs tl +let required_globals = ref [] +let reset_required_globals () = required_globals := [] +let get_required_globals () = !required_globals +let add_required_global id = + if Ident.global id && not !Clflags.transparent_modules + && not (List.exists (Ident.same id) !required_globals) + then required_globals := id :: !required_globals -let check_deprecated loc attrs s = - match deprecated_of_attrs attrs with - | None -> () - | Some txt -> Location.deprecated loc (cat s txt) +let rec normalize_path lax env path = + let path = + match path with + Pdot(p, s, pos) -> + Pdot(normalize_path lax env p, s, pos) + | Papply(p1, p2) -> + Papply(normalize_path lax env p1, normalize_path true env p2) + | _ -> path + in + try match find_module ~alias:true path env with + {md_type=Mty_alias(_, path1)} -> + let path' = normalize_path lax env path1 in + if lax || !Clflags.transparent_modules then path' else + let id = Path.head path in + if Ident.global id && not (Ident.same id (Path.head path')) + then add_required_global id; + path' + | _ -> path + with Not_found when lax + || (match path with Pident id -> not (Ident.persistent id) | _ -> true) -> + path -let check_deprecated_inclusion ~def ~use loc attrs1 attrs2 s = - match deprecated_of_attrs attrs1, deprecated_of_attrs attrs2 with - | None, _ | Some _, Some _ -> () - | Some txt, None -> Location.deprecated ~def ~use loc (cat s txt) +let normalize_path oloc env path = + try normalize_path (oloc = None) env path + with Not_found -> + match oloc with None -> assert false + | Some loc -> + raise (Error(Missing_module(loc, path, normalize_path true env path))) -let rec deprecated_mutable_of_attrs = function - | [] -> None - | ({txt = "ocaml.deprecated_mutable"|"deprecated_mutable"; _}, p) :: _ -> - Some (string_of_opt_payload p) - | _ :: tl -> deprecated_mutable_of_attrs tl +let normalize_path_prefix oloc env path = + match path with + Pdot(p, s, pos) -> + Pdot(normalize_path oloc env p, s, pos) + | Pident _ -> + path + | Papply _ -> + assert false -let check_deprecated_mutable loc attrs s = - match deprecated_mutable_of_attrs attrs with - | None -> () - | Some txt -> - Location.deprecated loc (Printf.sprintf "mutating field %s" (cat s txt)) -let check_deprecated_mutable_inclusion ~def ~use loc attrs1 attrs2 s = - match deprecated_mutable_of_attrs attrs1, - deprecated_mutable_of_attrs attrs2 - with - | None, _ | Some _, Some _ -> () - | Some txt, None -> - Location.deprecated ~def ~use loc - (Printf.sprintf "mutating field %s" (cat s txt)) +let find_module = find_module ~alias:false -let rec deprecated_of_sig = function - | {psig_desc = Psig_attribute a} :: tl -> - begin match deprecated_of_attrs [a] with - | None -> deprecated_of_sig tl - | Some _ as r -> r - end - | _ -> None +(* Find the manifest type associated to a type when appropriate: + - the type should be public or should have a private row, + - the type should have an associated manifest type. *) +let find_type_expansion path env = + let decl = find_type path env in + match decl.type_manifest with + | Some body when decl.type_private = Public + || decl.type_kind <> Type_abstract + || Btype.has_constr_row body -> + (decl.type_params, body, may_map snd decl.type_newtype_level) + (* The manifest type of Private abstract data types without + private row are still considered unknown to the type system. + Hence, this case is caught by the following clause that also handles + purely abstract data types without manifest type definition. *) + | _ -> raise Not_found +(* Find the manifest type information associated to a type, i.e. + the necessary information for the compiler's type-based optimisations. + In particular, the manifest type associated to a private abstract type + is revealed for the sake of compiler's type-based optimisations. *) +let find_type_expansion_opt path env = + let decl = find_type path env in + match decl.type_manifest with + (* The manifest type of Private abstract data types can still get + an approximation using their manifest type. *) + | Some body -> (decl.type_params, body, may_map snd decl.type_newtype_level) + | _ -> raise Not_found -let rec deprecated_of_str = function - | {pstr_desc = Pstr_attribute a} :: tl -> - begin match deprecated_of_attrs [a] with - | None -> deprecated_of_str tl - | Some _ as r -> r - end - | _ -> None +let find_modtype_expansion path env = + match (find_modtype path env).mtd_type with + | None -> raise Not_found + | Some mty -> mty +let rec is_functor_arg path env = + match path with + Pident id -> + begin try Ident.find_same id env.functor_args; true + with Not_found -> false + end + | Pdot (p, _s, _) -> is_functor_arg p env + | Papply _ -> true -let warning_attribute ?(ppwarning = true) = - let process loc txt errflag payload = - match string_of_payload payload with - | Some s -> - begin try Warnings.parse_options errflag s - with Arg.Bad _ -> - Location.prerr_warning loc - (Warnings.Attribute_payload - (txt, "Ill-formed list of warnings")) - end - | None -> - Location.prerr_warning loc - (Warnings.Attribute_payload - (txt, "A single string literal is expected")) - in - function - | ({txt = ("ocaml.warning"|"warning") as txt; loc}, payload) -> - process loc txt false payload - | ({txt = ("ocaml.warnerror"|"warnerror") as txt; loc}, payload) -> - process loc txt true payload - | {txt="ocaml.ppwarning"|"ppwarning"}, - PStr[{pstr_desc=Pstr_eval({pexp_desc=Pexp_constant - (Pconst_string (s, _))},_); - pstr_loc}] when ppwarning -> - Location.prerr_warning pstr_loc (Warnings.Preprocessor s) - | _ -> - () +(* Lookup by name *) -let warning_scope ?ppwarning attrs f = - let prev = Warnings.backup () in - try - List.iter (warning_attribute ?ppwarning) (List.rev attrs); - let ret = f () in - Warnings.restore prev; - ret - with exn -> - Warnings.restore prev; - raise exn +exception Recmodule +let report_deprecated ?loc p deprecated = + match loc, deprecated with + | Some loc, Some txt -> + let txt = if txt = "" then "" else "\n" ^ txt in + Location.deprecated loc (Printf.sprintf "module %s%s" (Path.name p) txt) + | _ -> () -let warn_on_literal_pattern = - List.exists - (function - | ({txt="ocaml.warn_on_literal_pattern"|"warn_on_literal_pattern"; _}, _) - -> true - | _ -> false - ) +let mark_module_used env name loc = + if not (is_implicit_coercion env) then + try Hashtbl.find module_declarations (name, loc) () + with Not_found -> () -let explicit_arity = - List.exists - (function - | ({txt="ocaml.explicit_arity"|"explicit_arity"; _}, _) -> true - | _ -> false - ) +let rec lookup_module_descr_aux ?loc lid env = + match lid with + Lident s -> + begin try + IdTbl.find_name s env.components + with Not_found -> + if s = !current_unit then raise Not_found; + let ps = find_pers_struct s in + (Pident(Ident.create_persistent s), ps.ps_comps) + end + | Ldot(l, s) -> + let (p, descr) = lookup_module_descr ?loc l env in + begin match get_components descr with + Structure_comps c -> + let (descr, pos) = Tbl.find_str s c.comp_components in + (Pdot(p, s, pos), descr) + | Functor_comps _ -> + raise Not_found + end + | Lapply(l1, l2) -> + let (p1, desc1) = lookup_module_descr ?loc l1 env in + let p2 = lookup_module ~load:true ?loc l2 env in + let {md_type=mty2} = find_module p2 env in + begin match get_components desc1 with + Functor_comps f -> + let loc = match loc with Some l -> l | None -> Location.none in + Misc.may (!check_modtype_inclusion ~loc env mty2 p2) f.fcomp_arg; + (Papply(p1, p2), !components_of_functor_appl' f env p1 p2) + | Structure_comps _ -> + raise Not_found + end -let immediate = - List.exists - (function - | ({txt="ocaml.immediate"|"immediate"; _}, _) -> true - | _ -> false - ) +and lookup_module_descr ?loc lid env = + let (p, comps) as res = lookup_module_descr_aux ?loc lid env in + mark_module_used env (Path.last p) comps.loc; +(* + Format.printf "USE module %s at %a@." (Path.last p) + Location.print comps.loc; +*) + report_deprecated ?loc p comps.deprecated; + res -(* The "ocaml.boxed (default)" and "ocaml.unboxed (default)" - attributes cannot be input by the user, they are added by the - compiler when applying the default setting. This is done to record - in the .cmi the default used by the compiler when compiling the - source file because the default can change between compiler - invocations. *) +and lookup_module ~load ?loc lid env : Path.t = + match lid with + Lident s -> + begin try + let (p, data) = IdTbl.find_name s env.modules in + let {md_loc; md_attributes; md_type} = + EnvLazy.force subst_modtype_maker data + in + mark_module_used env s md_loc; + begin match md_type with + | Mty_ident (Path.Pident id) when Ident.name id = "#recmod#" -> + (* see #5965 *) + raise Recmodule + + | Mty_alias (_, Path.Pident id) -> + if !Clflags.bs_only && not !Clflags.transparent_modules && Ident.persistent id then + find_pers_struct (Ident.name id) |> ignore + + | _ -> () + end; + report_deprecated ?loc p + (Builtin_attributes.deprecated_of_attrs md_attributes); + p + with Not_found -> + if s = !current_unit then raise Not_found; + let p = Pident(Ident.create_persistent s) in + if !Clflags.transparent_modules && not load then check_pers_struct s + else begin + let ps = find_pers_struct s in + report_deprecated ?loc p ps.ps_comps.deprecated + end; + p + end + | Ldot(l, s) -> + let (p, descr) = lookup_module_descr ?loc l env in + begin match get_components descr with + Structure_comps c -> + let (_data, pos) = Tbl.find_str s c.comp_modules in + let (comps, _) = Tbl.find_str s c.comp_components in + mark_module_used env s comps.loc; + let p = Pdot(p, s, pos) in + report_deprecated ?loc p comps.deprecated; + p + | Functor_comps _ -> + raise Not_found + end + | Lapply(l1, l2) -> + let (p1, desc1) = lookup_module_descr ?loc l1 env in + let p2 = lookup_module ~load:true ?loc l2 env in + let {md_type=mty2} = find_module p2 env in + let p = Papply(p1, p2) in + begin match get_components desc1 with + Functor_comps f -> + let loc = match loc with Some l -> l | None -> Location.none in + Misc.may (!check_modtype_inclusion ~loc env mty2 p2) f.fcomp_arg; + p + | Structure_comps _ -> + raise Not_found + end -let check l (x, _) = List.mem x.txt l +let lookup proj1 proj2 ?loc lid env = + match lid with + Lident s -> + IdTbl.find_name s (proj1 env) + | Ldot(l, s) -> + let (p, desc) = lookup_module_descr ?loc l env in + begin match get_components desc with + Structure_comps c -> + let (data, pos) = Tbl.find_str s (proj2 c) in + (Pdot(p, s, pos), data) + | Functor_comps _ -> + raise Not_found + end + | Lapply _ -> + raise Not_found -let has_unboxed attr = - List.exists (check ["ocaml.unboxed"; "unboxed"]) - attr +let lookup_all_simple proj1 proj2 shadow ?loc lid env = + match lid with + Lident s -> + let xl = TycompTbl.find_all s (proj1 env) in + let rec do_shadow = + function + | [] -> [] + | ((x, f) :: xs) -> + (x, f) :: + (do_shadow (List.filter (fun (y, _) -> not (shadow x y)) xs)) + in + do_shadow xl + | Ldot(l, s) -> + let (_p, desc) = lookup_module_descr ?loc l env in + begin match get_components desc with + Structure_comps c -> + let comps = + try Tbl.find_str s (proj2 c) with Not_found -> [] + in + List.map + (fun data -> (data, (fun () -> ()))) + comps + | Functor_comps _ -> + raise Not_found + end + | Lapply _ -> + raise Not_found -let has_boxed attr = - List.exists (check ["ocaml.boxed"; "boxed"]) attr +let has_local_constraints env = not (PathMap.is_empty env.local_constraints) -end -module Depend : sig -#1 "depend.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1999 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let cstr_shadow cstr1 cstr2 = + match cstr1.cstr_tag, cstr2.cstr_tag with + | Cstr_extension _, Cstr_extension _ -> true + | _ -> false -(** Module dependencies. *) +let lbl_shadow _lbl1 _lbl2 = false -module StringSet : Set.S with type elt = string -module StringMap : Map.S with type key = string +let lookup_value = + lookup (fun env -> env.values) (fun sc -> sc.comp_values) +let lookup_all_constructors = + lookup_all_simple (fun env -> env.constrs) (fun sc -> sc.comp_constrs) + cstr_shadow +let lookup_all_labels = + lookup_all_simple (fun env -> env.labels) (fun sc -> sc.comp_labels) + lbl_shadow +let lookup_type = + lookup (fun env -> env.types) (fun sc -> sc.comp_types) +let lookup_modtype = + lookup (fun env -> env.modtypes) (fun sc -> sc.comp_modtypes) +let lookup_class = + lookup (fun env -> env.classes) (fun sc -> sc.comp_classes) +let lookup_cltype = + lookup (fun env -> env.cltypes) (fun sc -> sc.comp_cltypes) -type map_tree = Node of StringSet.t * bound_map -and bound_map = map_tree StringMap.t -val make_leaf : string -> map_tree -val make_node : bound_map -> map_tree -val weaken_map : StringSet.t -> map_tree -> map_tree +let copy_types l env = + let f desc = {desc with val_type = Subst.type_expr Subst.identity desc.val_type} in + let values = List.fold_left (fun env s -> IdTbl.update s f env) env.values l in + {env with values; summary = Env_copy_types (env.summary, l)} -val free_structure_names : StringSet.t ref +let mark_value_used env name vd = + if not (is_implicit_coercion env) then + try Hashtbl.find value_declarations (name, vd.val_loc) () + with Not_found -> () -(* dependencies found by preprocessing tools (plugins) *) -val pp_deps : string list ref +let mark_type_used env name vd = + if not (is_implicit_coercion env) then + try Hashtbl.find type_declarations (name, vd.type_loc) () + with Not_found -> () -val open_module : bound_map -> Longident.t -> bound_map +let mark_constructor_used usage env name vd constr = + if not (is_implicit_coercion env) then + try Hashtbl.find used_constructors (name, vd.type_loc, constr) usage + with Not_found -> () -val add_use_file : bound_map -> Parsetree.toplevel_phrase list -> unit +let mark_extension_used usage env ext name = + if not (is_implicit_coercion env) then + let ty_name = Path.last ext.ext_type_path in + try Hashtbl.find used_constructors (ty_name, ext.ext_loc, name) usage + with Not_found -> () -val add_signature : bound_map -> Parsetree.signature -> unit +let set_value_used_callback name vd callback = + let key = (name, vd.val_loc) in + try + let old = Hashtbl.find value_declarations key in + Hashtbl.replace value_declarations key (fun () -> old (); callback ()) + (* this is to support cases like: + let x = let x = 1 in x in x + where the two declarations have the same location + (e.g. resulting from Camlp4 expansion of grammar entries) *) + with Not_found -> + Hashtbl.add value_declarations key callback -val add_implementation : bound_map -> Parsetree.structure -> unit +let set_type_used_callback name td callback = + let loc = td.type_loc in + if loc.Location.loc_ghost then () + else let key = (name, loc) in + let old = + try Hashtbl.find type_declarations key + with Not_found -> assert false + in + Hashtbl.replace type_declarations key (fun () -> callback old) -val add_implementation_binding : bound_map -> Parsetree.structure -> bound_map -val add_signature_binding : bound_map -> Parsetree.signature -> bound_map +let lookup_value ?loc lid env = + let (_, desc) as r = lookup_value ?loc lid env in + mark_value_used env (Longident.last lid) desc; + r -end = struct -#1 "depend.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1999 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let lookup_type ?loc lid env = + let (path, (decl, _)) = lookup_type ?loc lid env in + mark_type_used env (Longident.last lid) decl; + path -open Asttypes -open Location -open Longident -open Parsetree +let mark_type_path env path = + try + let decl = find_type path env in + mark_type_used env (Path.last path) decl + with Not_found -> () -let pp_deps = ref [] +let ty_path t = + match repr t with + | {desc=Tconstr(path, _, _)} -> path + | _ -> assert false -module StringSet = Set.Make(struct type t = string let compare = compare end) -module StringMap = Map.Make(String) +let lookup_constructor ?loc lid env = + match lookup_all_constructors ?loc lid env with + [] -> raise Not_found + | (desc, use) :: _ -> + mark_type_path env (ty_path desc.cstr_res); + use (); + desc -(* Module resolution map *) -(* Node (set of imports for this path, map for submodules) *) -type map_tree = Node of StringSet.t * bound_map -and bound_map = map_tree StringMap.t -let bound = Node (StringSet.empty, StringMap.empty) +let is_lident = function + Lident _ -> true + | _ -> false -(*let get_free (Node (s, _m)) = s*) -let get_map (Node (_s, m)) = m -let make_leaf s = Node (StringSet.singleton s, StringMap.empty) -let make_node m = Node (StringSet.empty, m) -let rec weaken_map s (Node(s0,m0)) = - Node (StringSet.union s s0, StringMap.map (weaken_map s) m0) -let rec collect_free (Node (s, m)) = - StringMap.fold (fun _ n -> StringSet.union (collect_free n)) m s +let lookup_all_constructors ?loc lid env = + try + let cstrs = lookup_all_constructors ?loc lid env in + let wrap_use desc use () = + mark_type_path env (ty_path desc.cstr_res); + use () + in + List.map (fun (cstr, use) -> (cstr, wrap_use cstr use)) cstrs + with + Not_found when is_lident lid -> [] -(* Returns the imports required to access the structure at path p *) -(* Only raises Not_found if the head of p is not in the toplevel map *) -let rec lookup_free p m = - match p with +let mark_constructor usage env name desc = + if not (is_implicit_coercion env) + then match desc.cstr_tag with + | Cstr_extension _ -> + begin + let ty_path = ty_path desc.cstr_res in + let ty_name = Path.last ty_path in + try Hashtbl.find used_constructors (ty_name, desc.cstr_loc, name) usage + with Not_found -> () + end + | _ -> + let ty_path = ty_path desc.cstr_res in + let ty_decl = try find_type ty_path env with Not_found -> assert false in + let ty_name = Path.last ty_path in + mark_constructor_used usage env ty_name ty_decl name + +let lookup_label ?loc lid env = + match lookup_all_labels ?loc lid env with [] -> raise Not_found - | s::p -> - let Node (f, m') = StringMap.find s m in - try lookup_free p m' with Not_found -> f + | (desc, use) :: _ -> + mark_type_path env (ty_path desc.lbl_res); + use (); + desc -(* Returns the node corresponding to the structure at path p *) -let rec lookup_map lid m = - match lid with - Lident s -> StringMap.find s m - | Ldot (l, s) -> StringMap.find s (get_map (lookup_map l m)) - | Lapply _ -> raise Not_found +let lookup_all_labels ?loc lid env = + try + let lbls = lookup_all_labels ?loc lid env in + let wrap_use desc use () = + mark_type_path env (ty_path desc.lbl_res); + use () + in + List.map (fun (lbl, use) -> (lbl, wrap_use lbl use)) lbls + with + Not_found when is_lident lid -> [] -(* Collect free module identifiers in the a.s.t. *) +let lookup_class ?loc lid env = + let (_, desc) as r = lookup_class ?loc lid env in + (* special support for Typeclass.unbound_class *) + if Path.name desc.cty_path = "" then ignore (lookup_type ?loc lid env) + else mark_type_path env desc.cty_path; + r -let free_structure_names = ref StringSet.empty +let lookup_cltype ?loc lid env = + let (_, desc) as r = lookup_cltype ?loc lid env in + if Path.name desc.clty_path = "" then ignore (lookup_type ?loc lid env) + else mark_type_path env desc.clty_path; + mark_type_path env desc.clty_path; + r -let add_names s = - free_structure_names := StringSet.union s !free_structure_names +(* Iter on an environment (ignoring the body of functors and + not yet evaluated structures) *) -let rec add_path bv ?(p=[]) = function - | Lident s -> - let free = - try lookup_free (s::p) bv with Not_found -> StringSet.singleton s +type iter_cont = unit -> unit +let iter_env_cont = ref [] + +let rec scrape_alias_for_visit env mty = + match mty with + | Mty_alias(_, Pident id) + when Ident.persistent id + && not (Hashtbl.mem persistent_structures (Ident.name id)) -> false + | Mty_alias(_, path) -> (* PR#6600: find_module may raise Not_found *) + begin try scrape_alias_for_visit env (find_module path env).md_type + with Not_found -> false + end + | _ -> true + +let iter_env proj1 proj2 f env () = + IdTbl.iter (fun id x -> f (Pident id) x) (proj1 env); + let rec iter_components path path' mcomps = + let cont () = + let visit = + match EnvLazy.get_arg mcomps.comps with + | None -> true + | Some (env, _sub, _path, mty) -> scrape_alias_for_visit env mty in - (*StringSet.iter (fun s -> Printf.eprintf "%s " s) free; - prerr_endline "";*) - add_names free - | Ldot(l, s) -> add_path bv ~p:(s::p) l - | Lapply(l1, l2) -> add_path bv l1; add_path bv l2 + if not visit then () else + match get_components mcomps with + Structure_comps comps -> + Tbl.iter + (fun s (d, n) -> f (Pdot (path, s, n)) (Pdot (path', s, n), d)) + (proj2 comps); + Tbl.iter + (fun s (c, n) -> + iter_components (Pdot (path, s, n)) (Pdot (path', s, n)) c) + comps.comp_components + | Functor_comps _ -> () + in iter_env_cont := (path, cont) :: !iter_env_cont + in + Hashtbl.iter + (fun s pso -> + match pso with None -> () + | Some ps -> + let id = Pident (Ident.create_persistent s) in + iter_components id id ps.ps_comps) + persistent_structures; + IdTbl.iter + (fun id (path, comps) -> iter_components (Pident id) path comps) + env.components -let open_module bv lid = - match lookup_map lid bv with - | Node (s, m) -> - add_names s; - StringMap.fold StringMap.add m bv - | exception Not_found -> - add_path bv lid; bv +let run_iter_cont l = + iter_env_cont := []; + List.iter (fun c -> c ()) l; + let cont = List.rev !iter_env_cont in + iter_env_cont := []; + cont -let add_parent bv lid = - match lid.txt with - Ldot(l, _s) -> add_path bv l - | _ -> () +let iter_types f = iter_env (fun env -> env.types) (fun sc -> sc.comp_types) f -let add = add_parent +let same_types env1 env2 = + env1.types == env2.types && env1.components == env2.components -let addmodule bv lid = add_path bv lid.txt +let used_persistent () = + let r = ref Concr.empty in + Hashtbl.iter (fun s pso -> if pso != None then r := Concr.add s !r) + persistent_structures; + !r -let handle_extension ext = - match (fst ext).txt with - | "error" | "ocaml.error" -> - raise (Location.Error - (Builtin_attributes.error_of_extension ext)) - | _ -> - () +let find_all_comps proj s (p,mcomps) = + match get_components mcomps with + Functor_comps _ -> [] + | Structure_comps comps -> + try let (c,n) = Tbl.find_str s (proj comps) in [Pdot(p,s,n), c] + with Not_found -> [] -let rec add_type bv ty = - match ty.ptyp_desc with - Ptyp_any -> () - | Ptyp_var _ -> () - | Ptyp_arrow(_, t1, t2) -> add_type bv t1; add_type bv t2 - | Ptyp_tuple tl -> List.iter (add_type bv) tl - | Ptyp_constr(c, tl) -> add bv c; List.iter (add_type bv) tl - | Ptyp_object (fl, _) -> - List.iter - (function Otag (_, _, t) -> add_type bv t - | Oinherit t -> add_type bv t) fl - | Ptyp_class(c, tl) -> add bv c; List.iter (add_type bv) tl - | Ptyp_alias(t, _) -> add_type bv t - | Ptyp_variant(fl, _, _) -> - List.iter - (function Rtag(_,_,_,stl) -> List.iter (add_type bv) stl - | Rinherit sty -> add_type bv sty) - fl - | Ptyp_poly(_, t) -> add_type bv t - | Ptyp_package pt -> add_package_type bv pt - | Ptyp_extension e -> handle_extension e +let rec find_shadowed_comps path env = + match path with + Pident id -> + IdTbl.find_all (Ident.name id) env.components + | Pdot (p, s, _) -> + let l = find_shadowed_comps p env in + let l' = + List.map (find_all_comps (fun comps -> comps.comp_components) s) l in + List.flatten l' + | Papply _ -> [] -and add_package_type bv (lid, l) = - add bv lid; - List.iter (add_type bv) (List.map (fun (_, e) -> e) l) +let find_shadowed proj1 proj2 path env = + match path with + Pident id -> + IdTbl.find_all (Ident.name id) (proj1 env) + | Pdot (p, s, _) -> + let l = find_shadowed_comps p env in + let l' = List.map (find_all_comps proj2 s) l in + List.flatten l' + | Papply _ -> [] -let add_opt add_fn bv = function - None -> () - | Some x -> add_fn bv x +let find_shadowed_types path env = + List.map fst + (find_shadowed + (fun env -> env.types) (fun comps -> comps.comp_types) path env) -let add_constructor_arguments bv = function - | Pcstr_tuple l -> List.iter (add_type bv) l - | Pcstr_record l -> List.iter (fun l -> add_type bv l.pld_type) l -let add_constructor_decl bv pcd = - add_constructor_arguments bv pcd.pcd_args; - Misc.may (add_type bv) pcd.pcd_res +(* GADT instance tracking *) -let add_type_declaration bv td = - List.iter - (fun (ty1, ty2, _) -> add_type bv ty1; add_type bv ty2) - td.ptype_cstrs; - add_opt add_type bv td.ptype_manifest; - let add_tkind = function - Ptype_abstract -> () - | Ptype_variant cstrs -> - List.iter (add_constructor_decl bv) cstrs - | Ptype_record lbls -> - List.iter (fun pld -> add_type bv pld.pld_type) lbls - | Ptype_open -> () in - add_tkind td.ptype_kind +let add_gadt_instance_level lv env = + {env with + gadt_instances = (lv, ref TypeSet.empty) :: env.gadt_instances} -let add_extension_constructor bv ext = - match ext.pext_kind with - Pext_decl(args, rty) -> - add_constructor_arguments bv args; - Misc.may (add_type bv) rty - | Pext_rebind lid -> add bv lid +let is_Tlink = function {desc = Tlink _} -> true | _ -> false -let add_type_extension bv te = - add bv te.ptyext_path; - List.iter (add_extension_constructor bv) te.ptyext_constructors +let gadt_instance_level env t = + let rec find_instance = function + [] -> None + | (lv, r) :: rem -> + if TypeSet.exists is_Tlink !r then + (* Should we use set_typeset ? *) + r := TypeSet.fold (fun ty -> TypeSet.add (repr ty)) !r TypeSet.empty; + if TypeSet.mem t !r then Some lv else find_instance rem + in find_instance env.gadt_instances -let rec add_class_type bv cty = - match cty.pcty_desc with - Pcty_constr(l, tyl) -> - add bv l; List.iter (add_type bv) tyl - | Pcty_signature { pcsig_self = ty; pcsig_fields = fieldl } -> - add_type bv ty; - List.iter (add_class_type_field bv) fieldl - | Pcty_arrow(_, ty1, cty2) -> - add_type bv ty1; add_class_type bv cty2 - | Pcty_extension e -> handle_extension e - | Pcty_open (_ovf, m, e) -> - let bv = open_module bv m.txt in add_class_type bv e +let add_gadt_instances env lv tl = + let r = + try List.assoc lv env.gadt_instances with Not_found -> assert false in + (* Format.eprintf "Added"; + List.iter (fun ty -> Format.eprintf "@ %a" !Btype.print_raw ty) tl; + Format.eprintf "@."; *) + set_typeset r (List.fold_right TypeSet.add tl !r) -and add_class_type_field bv pctf = - match pctf.pctf_desc with - Pctf_inherit cty -> add_class_type bv cty - | Pctf_val(_, _, _, ty) -> add_type bv ty - | Pctf_method(_, _, _, ty) -> add_type bv ty - | Pctf_constraint(ty1, ty2) -> add_type bv ty1; add_type bv ty2 - | Pctf_attribute _ -> () - | Pctf_extension e -> handle_extension e +(* Only use this after expand_head! *) +let add_gadt_instance_chain env lv t = + let r = + try List.assoc lv env.gadt_instances with Not_found -> assert false in + let rec add_instance t = + let t = repr t in + if not (TypeSet.mem t !r) then begin + (* Format.eprintf "@ %a" !Btype.print_raw t; *) + set_typeset r (TypeSet.add t !r); + match t.desc with + Tconstr (p, _, memo) -> + may add_instance (find_expans Private p !memo) + | _ -> () + end + in + (* Format.eprintf "Added chain"; *) + add_instance t + (* Format.eprintf "@." *) -let add_class_description bv infos = - add_class_type bv infos.pci_expr +(* Expand manifest module type names at the top of the given module type *) -let add_class_type_declaration = add_class_description +let rec scrape_alias env ?path mty = + match mty, path with + Mty_ident p, _ -> + begin try + scrape_alias env (find_modtype_expansion p env) ?path + with Not_found -> + mty + end + | Mty_alias(_, path), _ -> + begin try + scrape_alias env (find_module path env).md_type ~path + with Not_found -> + (*Location.prerr_warning Location.none + (Warnings.No_cmi_file (Path.name path));*) + mty + end + | mty, Some path -> + !strengthen ~aliasable:true env mty path + | _ -> mty -let pattern_bv = ref StringMap.empty +let scrape_alias env mty = scrape_alias env mty -let rec add_pattern bv pat = - match pat.ppat_desc with - Ppat_any -> () - | Ppat_var _ -> () - | Ppat_alias(p, _) -> add_pattern bv p - | Ppat_interval _ - | Ppat_constant _ -> () - | Ppat_tuple pl -> List.iter (add_pattern bv) pl - | Ppat_construct(c, op) -> add bv c; add_opt add_pattern bv op - | Ppat_record(pl, _) -> - List.iter (fun (lbl, p) -> add bv lbl; add_pattern bv p) pl - | Ppat_array pl -> List.iter (add_pattern bv) pl - | Ppat_or(p1, p2) -> add_pattern bv p1; add_pattern bv p2 - | Ppat_constraint(p, ty) -> add_pattern bv p; add_type bv ty - | Ppat_variant(_, op) -> add_opt add_pattern bv op - | Ppat_type li -> add bv li - | Ppat_lazy p -> add_pattern bv p - | Ppat_unpack id -> pattern_bv := StringMap.add id.txt bound !pattern_bv - | Ppat_open ( m, p) -> let bv = open_module bv m.txt in add_pattern bv p - | Ppat_exception p -> add_pattern bv p - | Ppat_extension e -> handle_extension e +(* Given a signature and a root path, prefix all idents in the signature + by the root path and build the corresponding substitution. *) -let add_pattern bv pat = - pattern_bv := bv; - add_pattern bv pat; - !pattern_bv +let rec prefix_idents root pos sub = function + [] -> ([], sub) + | Sig_value(id, decl) :: rem -> + let p = Pdot(root, Ident.name id, pos) in + let nextpos = match decl.val_kind with Val_prim _ -> pos | _ -> pos+1 in + let (pl, final_sub) = prefix_idents root nextpos sub rem in + (p::pl, final_sub) + | Sig_type(id, _, _) :: rem -> + let p = Pdot(root, Ident.name id, nopos) in + let (pl, final_sub) = + prefix_idents root pos (Subst.add_type id p sub) rem in + (p::pl, final_sub) + | Sig_typext(id, _, _) :: rem -> + let p = Pdot(root, Ident.name id, pos) in + (* we extend the substitution in case of an inlined record *) + let (pl, final_sub) = + prefix_idents root (pos+1) (Subst.add_type id p sub) rem in + (p::pl, final_sub) + | Sig_module(id, _, _) :: rem -> + let p = Pdot(root, Ident.name id, pos) in + let (pl, final_sub) = + prefix_idents root (pos+1) (Subst.add_module id p sub) rem in + (p::pl, final_sub) + | Sig_modtype(id, _) :: rem -> + let p = Pdot(root, Ident.name id, nopos) in + let (pl, final_sub) = + prefix_idents root pos + (Subst.add_modtype id (Mty_ident p) sub) rem in + (p::pl, final_sub) + | Sig_class(id, _, _) :: rem -> + (* pretend this is a type, cf. PR#6650 *) + let p = Pdot(root, Ident.name id, pos) in + let (pl, final_sub) = + prefix_idents root (pos + 1) (Subst.add_type id p sub) rem in + (p::pl, final_sub) + | Sig_class_type(id, _, _) :: rem -> + let p = Pdot(root, Ident.name id, nopos) in + let (pl, final_sub) = + prefix_idents root pos (Subst.add_type id p sub) rem in + (p::pl, final_sub) -let rec add_expr bv exp = - match exp.pexp_desc with - Pexp_ident l -> add bv l - | Pexp_constant _ -> () - | Pexp_let(rf, pel, e) -> - let bv = add_bindings rf bv pel in add_expr bv e - | Pexp_fun (_, opte, p, e) -> - add_opt add_expr bv opte; add_expr (add_pattern bv p) e - | Pexp_function pel -> - add_cases bv pel - | Pexp_apply(e, el) -> - add_expr bv e; List.iter (fun (_,e) -> add_expr bv e) el - | Pexp_match(e, pel) -> add_expr bv e; add_cases bv pel - | Pexp_try(e, pel) -> add_expr bv e; add_cases bv pel - | Pexp_tuple el -> List.iter (add_expr bv) el - | Pexp_construct(c, opte) -> add bv c; add_opt add_expr bv opte - | Pexp_variant(_, opte) -> add_opt add_expr bv opte - | Pexp_record(lblel, opte) -> - List.iter (fun (lbl, e) -> add bv lbl; add_expr bv e) lblel; - add_opt add_expr bv opte - | Pexp_field(e, fld) -> add_expr bv e; add bv fld - | Pexp_setfield(e1, fld, e2) -> add_expr bv e1; add bv fld; add_expr bv e2 - | Pexp_array el -> List.iter (add_expr bv) el - | Pexp_ifthenelse(e1, e2, opte3) -> - add_expr bv e1; add_expr bv e2; add_opt add_expr bv opte3 - | Pexp_sequence(e1, e2) -> add_expr bv e1; add_expr bv e2 - | Pexp_while(e1, e2) -> add_expr bv e1; add_expr bv e2 - | Pexp_for( _, e1, e2, _, e3) -> - add_expr bv e1; add_expr bv e2; add_expr bv e3 - | Pexp_coerce(e1, oty2, ty3) -> - add_expr bv e1; - add_opt add_type bv oty2; - add_type bv ty3 - | Pexp_constraint(e1, ty2) -> - add_expr bv e1; - add_type bv ty2 - | Pexp_send(e, _m) -> add_expr bv e - | Pexp_new li -> add bv li - | Pexp_setinstvar(_v, e) -> add_expr bv e - | Pexp_override sel -> List.iter (fun (_s, e) -> add_expr bv e) sel - | Pexp_letmodule(id, m, e) -> - let b = add_module_binding bv m in - add_expr (StringMap.add id.txt b bv) e - | Pexp_letexception(_, e) -> add_expr bv e - | Pexp_assert (e) -> add_expr bv e - | Pexp_lazy (e) -> add_expr bv e - | Pexp_poly (e, t) -> add_expr bv e; add_opt add_type bv t - | Pexp_object { pcstr_self = pat; pcstr_fields = fieldl } -> - let bv = add_pattern bv pat in List.iter (add_class_field bv) fieldl - | Pexp_newtype (_, e) -> add_expr bv e - | Pexp_pack m -> add_module bv m - | Pexp_open (_ovf, m, e) -> - let bv = open_module bv m.txt in add_expr bv e - | Pexp_extension (({ txt = ("ocaml.extension_constructor"| - "extension_constructor"); _ }, - PStr [item]) as e) -> - begin match item.pstr_desc with - | Pstr_eval ({ pexp_desc = Pexp_construct (c, None) }, _) -> add bv c - | _ -> handle_extension e - end - | Pexp_extension e -> handle_extension e - | Pexp_unreachable -> () +let prefix_idents root sub sg = + if sub = Subst.identity then + let sgs = + try + Hashtbl.find prefixed_sg root + with Not_found -> + let sgs = ref [] in + Hashtbl.add prefixed_sg root sgs; + sgs + in + try + List.assq sg !sgs + with Not_found -> + let r = prefix_idents root 0 sub sg in + sgs := (sg, r) :: !sgs; + r + else + prefix_idents root 0 sub sg -and add_cases bv cases = - List.iter (add_case bv) cases +(* Compute structure descriptions *) -and add_case bv {pc_lhs; pc_guard; pc_rhs} = - let bv = add_pattern bv pc_lhs in - add_opt add_expr bv pc_guard; - add_expr bv pc_rhs +let add_to_tbl id decl tbl = + let decls = + try Tbl.find_str id tbl with Not_found -> [] in + Tbl.add id (decl :: decls) tbl -and add_bindings recf bv pel = - let bv' = List.fold_left (fun bv x -> add_pattern bv x.pvb_pat) bv pel in - let bv = if recf = Recursive then bv' else bv in - List.iter (fun x -> add_expr bv x.pvb_expr) pel; - bv' +let rec components_of_module ~deprecated ~loc env sub path mty = + { + deprecated; + loc; + comps = EnvLazy.create (env, sub, path, mty) + } -and add_modtype bv mty = - match mty.pmty_desc with - Pmty_ident l -> add bv l - | Pmty_alias l -> addmodule bv l - | Pmty_signature s -> add_signature bv s - | Pmty_functor(id, mty1, mty2) -> - Misc.may (add_modtype bv) mty1; - add_modtype (StringMap.add id.txt bound bv) mty2 - | Pmty_with(mty, cstrl) -> - add_modtype bv mty; - List.iter - (function - | Pwith_type (_, td) -> add_type_declaration bv td - | Pwith_module (_, lid) -> addmodule bv lid - | Pwith_typesubst (_, td) -> add_type_declaration bv td - | Pwith_modsubst (_, lid) -> addmodule bv lid - ) - cstrl - | Pmty_typeof m -> add_module bv m - | Pmty_extension e -> handle_extension e +and components_of_module_maker (env, sub, path, mty) = + match scrape_alias env mty with + Mty_signature sg -> + let c = + { comp_values = Tbl.empty; + comp_constrs = Tbl.empty; + comp_labels = Tbl.empty; comp_types = Tbl.empty; + comp_modules = Tbl.empty; comp_modtypes = Tbl.empty; + comp_components = Tbl.empty; comp_classes = Tbl.empty; + comp_cltypes = Tbl.empty } in + let pl, sub = prefix_idents path sub sg in + let env = ref env in + let pos = ref 0 in + List.iter2 (fun item path -> + match item with + Sig_value(id, decl) -> + let decl' = Subst.value_description sub decl in + c.comp_values <- + Tbl.add (Ident.name id) (decl', !pos) c.comp_values; + begin match decl.val_kind with + Val_prim _ -> () | _ -> incr pos + end + | Sig_type(id, decl, _) -> + let decl' = Subst.type_declaration sub decl in + Datarepr.set_row_name decl' (Subst.type_path sub (Path.Pident id)); + let constructors = + List.map snd (Datarepr.constructors_of_type path decl') in + let labels = + List.map snd (Datarepr.labels_of_type path decl') in + c.comp_types <- + Tbl.add (Ident.name id) + ((decl', (constructors, labels)), nopos) + c.comp_types; + List.iter + (fun descr -> + c.comp_constrs <- + add_to_tbl descr.cstr_name descr c.comp_constrs) + constructors; + List.iter + (fun descr -> + c.comp_labels <- + add_to_tbl descr.lbl_name descr c.comp_labels) + labels; + env := store_type_infos id decl !env + | Sig_typext(id, ext, _) -> + let ext' = Subst.extension_constructor sub ext in + let descr = Datarepr.extension_descr path ext' in + c.comp_constrs <- + add_to_tbl (Ident.name id) descr c.comp_constrs; + incr pos + | Sig_module(id, md, _) -> + let md' = EnvLazy.create (sub, md) in + c.comp_modules <- + Tbl.add (Ident.name id) (md', !pos) c.comp_modules; + let deprecated = + Builtin_attributes.deprecated_of_attrs md.md_attributes + in + let comps = + components_of_module ~deprecated ~loc:md.md_loc !env sub path + md.md_type + in + c.comp_components <- + Tbl.add (Ident.name id) (comps, !pos) c.comp_components; + env := store_module ~check:false id md !env; + incr pos + | Sig_modtype(id, decl) -> + let decl' = Subst.modtype_declaration sub decl in + c.comp_modtypes <- + Tbl.add (Ident.name id) (decl', nopos) c.comp_modtypes; + env := store_modtype id decl !env + | Sig_class(id, decl, _) -> + let decl' = Subst.class_declaration sub decl in + c.comp_classes <- + Tbl.add (Ident.name id) (decl', !pos) c.comp_classes; + incr pos + | Sig_class_type(id, decl, _) -> + let decl' = Subst.cltype_declaration sub decl in + c.comp_cltypes <- + Tbl.add (Ident.name id) (decl', !pos) c.comp_cltypes) + sg pl; + Some (Structure_comps c) + | Mty_functor(param, ty_arg, ty_res) -> + Some (Functor_comps { + fcomp_param = param; + (* fcomp_arg and fcomp_res must be prefixed eagerly, because + they are interpreted in the outer environment *) + fcomp_arg = may_map (Subst.modtype sub) ty_arg; + fcomp_res = Subst.modtype sub ty_res; + fcomp_cache = Hashtbl.create 17; + fcomp_subst_cache = Hashtbl.create 17 }) + | Mty_ident _ + | Mty_alias _ -> None -and add_module_alias bv l = - try - add_parent bv l; - lookup_map l.txt bv - with Not_found -> - match l.txt with - Lident s -> make_leaf s - | _ -> addmodule bv l; bound (* cannot delay *) +(* Insertion of bindings by identifier + path *) -and add_modtype_binding bv mty = - if not !Clflags.transparent_modules then add_modtype bv mty; - match mty.pmty_desc with - Pmty_alias l -> - add_module_alias bv l - | Pmty_signature s -> - make_node (add_signature_binding bv s) - | Pmty_typeof modl -> - add_module_binding bv modl - | _ -> - if !Clflags.transparent_modules then add_modtype bv mty; bound +and check_usage loc id warn tbl = + if not loc.Location.loc_ghost && Warnings.is_active (warn "") then begin + let name = Ident.name id in + let key = (name, loc) in + if Hashtbl.mem tbl key then () + else let used = ref false in + Hashtbl.add tbl key (fun () -> used := true); + if not (name = "" || name.[0] = '_' || name.[0] = '#') + then + !add_delayed_check_forward + (fun () -> if not !used then Location.prerr_warning loc (warn name)) + end; -and add_signature bv sg = - ignore (add_signature_binding bv sg) +and check_value_name name loc = + (* Note: we could also check here general validity of the + identifier, to protect against bad identifiers forged by -pp or + -ppx preprocessors. *) + if !Clflags.bs_only && name = "|." then raise (Error(Illegal_value_name(loc, name))) + else if String.length name > 0 && (name.[0] = '#') then + for i = 1 to String.length name - 1 do + if name.[i] = '#' then + raise (Error(Illegal_value_name(loc, name))) + done -and add_signature_binding bv sg = - snd (List.fold_left add_sig_item (bv, StringMap.empty) sg) -and add_sig_item (bv, m) item = - match item.psig_desc with - Psig_value vd -> - add_type bv vd.pval_type; (bv, m) - | Psig_type (_, dcls) -> - List.iter (add_type_declaration bv) dcls; (bv, m) - | Psig_typext te -> - add_type_extension bv te; (bv, m) - | Psig_exception pext -> - add_extension_constructor bv pext; (bv, m) - | Psig_module pmd -> - let m' = add_modtype_binding bv pmd.pmd_type in - let add = StringMap.add pmd.pmd_name.txt m' in - (add bv, add m) - | Psig_recmodule decls -> - let add = - List.fold_right (fun pmd -> StringMap.add pmd.pmd_name.txt bound) - decls - in - let bv' = add bv and m' = add m in - List.iter (fun pmd -> add_modtype bv' pmd.pmd_type) decls; - (bv', m') - | Psig_modtype x -> - begin match x.pmtd_type with - None -> () - | Some mty -> add_modtype bv mty - end; - (bv, m) - | Psig_open od -> - (open_module bv od.popen_lid.txt, m) - | Psig_include incl -> - let Node (s, m') = add_modtype_binding bv incl.pincl_mod in - add_names s; - let add = StringMap.fold StringMap.add m' in - (add bv, add m) - | Psig_class cdl -> - List.iter (add_class_description bv) cdl; (bv, m) - | Psig_class_type cdtl -> - List.iter (add_class_type_declaration bv) cdtl; (bv, m) - | Psig_attribute _ -> (bv, m) - | Psig_extension (e, _) -> - handle_extension e; - (bv, m) +and store_value ?check id decl env = + check_value_name (Ident.name id) decl.val_loc; + may (fun f -> check_usage decl.val_loc id f value_declarations) check; + { env with + values = IdTbl.add id decl env.values; + summary = Env_value(env.summary, id, decl) } -and add_module_binding bv modl = - if not !Clflags.transparent_modules then add_module bv modl; - match modl.pmod_desc with - Pmod_ident l -> - begin try - add_parent bv l; - lookup_map l.txt bv - with Not_found -> - match l.txt with - Lident s -> make_leaf s - | _ -> addmodule bv l; bound +and store_type ~check id info env = + let loc = info.type_loc in + if check then + check_usage loc id (fun s -> Warnings.Unused_type_declaration s) + type_declarations; + let path = Pident id in + let constructors = Datarepr.constructors_of_type path info in + let labels = Datarepr.labels_of_type path info in + let descrs = (List.map snd constructors, List.map snd labels) in + + if check && not loc.Location.loc_ghost && + Warnings.is_active (Warnings.Unused_constructor ("", false, false)) + then begin + let ty = Ident.name id in + List.iter + begin fun (_, {cstr_name = c; _}) -> + let k = (ty, loc, c) in + if not (Hashtbl.mem used_constructors k) then + let used = constructor_usages () in + Hashtbl.add used_constructors k (add_constructor_usage used); + if not (ty = "" || ty.[0] = '_') + then !add_delayed_check_forward + (fun () -> + if not (is_in_signature env) && not used.cu_positive then + Location.prerr_warning loc + (Warnings.Unused_constructor + (c, used.cu_pattern, used.cu_privatize))) end - | Pmod_structure s -> - make_node (snd (add_structure_binding bv s)) - | _ -> - if !Clflags.transparent_modules then add_module bv modl; bound + constructors + end; + { env with + constrs = + List.fold_right + (fun (id, descr) constrs -> TycompTbl.add id descr constrs) + constructors + env.constrs; + labels = + List.fold_right + (fun (id, descr) labels -> TycompTbl.add id descr labels) + labels + env.labels; + types = + IdTbl.add id (info, descrs) env.types; + summary = Env_type(env.summary, id, info) } -and add_module bv modl = - match modl.pmod_desc with - Pmod_ident l -> addmodule bv l - | Pmod_structure s -> ignore (add_structure bv s) - | Pmod_functor(id, mty, modl) -> - Misc.may (add_modtype bv) mty; - add_module (StringMap.add id.txt bound bv) modl - | Pmod_apply(mod1, mod2) -> - add_module bv mod1; add_module bv mod2 - | Pmod_constraint(modl, mty) -> - add_module bv modl; add_modtype bv mty - | Pmod_unpack(e) -> - add_expr bv e - | Pmod_extension e -> - handle_extension e +and store_type_infos id info env = + (* Simplified version of store_type that doesn't compute and store + constructor and label infos, but simply record the arity and + manifest-ness of the type. Used in components_of_module to + keep track of type abbreviations (e.g. type t = float) in the + computation of label representations. *) + { env with + types = IdTbl.add id (info,([],[])) + env.types; + summary = Env_type(env.summary, id, info) } -and add_structure bv item_list = - let (bv, m) = add_structure_binding bv item_list in - add_names (collect_free (make_node m)); - bv +and store_extension ~check id ext env = + let loc = ext.ext_loc in + if check && not loc.Location.loc_ghost && + Warnings.is_active (Warnings.Unused_extension ("", false, false, false)) + then begin + let is_exception = Path.same ext.ext_type_path Predef.path_exn in + let ty = Path.last ext.ext_type_path in + let n = Ident.name id in + let k = (ty, loc, n) in + if not (Hashtbl.mem used_constructors k) then begin + let used = constructor_usages () in + Hashtbl.add used_constructors k (add_constructor_usage used); + !add_delayed_check_forward + (fun () -> + if not (is_in_signature env) && not used.cu_positive then + Location.prerr_warning loc + (Warnings.Unused_extension + (n, is_exception, used.cu_pattern, used.cu_privatize) + ) + ) + end; + end; + { env with + constrs = TycompTbl.add id + (Datarepr.extension_descr (Pident id) ext) + env.constrs; + summary = Env_extension(env.summary, id, ext) } -and add_structure_binding bv item_list = - List.fold_left add_struct_item (bv, StringMap.empty) item_list +and store_module ~check id md env = + let loc = md.md_loc in + if check then + check_usage loc id (fun s -> Warnings.Unused_module s) + module_declarations; -and add_struct_item (bv, m) item : _ StringMap.t * _ StringMap.t = - match item.pstr_desc with - Pstr_eval (e, _attrs) -> - add_expr bv e; (bv, m) - | Pstr_value(rf, pel) -> - let bv = add_bindings rf bv pel in (bv, m) - | Pstr_primitive vd -> - add_type bv vd.pval_type; (bv, m) - | Pstr_type (_, dcls) -> - List.iter (add_type_declaration bv) dcls; (bv, m) - | Pstr_typext te -> - add_type_extension bv te; - (bv, m) - | Pstr_exception pext -> - add_extension_constructor bv pext; (bv, m) - | Pstr_module x -> - let b = add_module_binding bv x.pmb_expr in - let add = StringMap.add x.pmb_name.txt b in - (add bv, add m) - | Pstr_recmodule bindings -> - let add = - List.fold_right (fun x -> StringMap.add x.pmb_name.txt bound) bindings - in - let bv' = add bv and m = add m in - List.iter - (fun x -> add_module bv' x.pmb_expr) - bindings; - (bv', m) - | Pstr_modtype x -> - begin match x.pmtd_type with - None -> () - | Some mty -> add_modtype bv mty - end; - (bv, m) - | Pstr_open od -> - (open_module bv od.popen_lid.txt, m) - | Pstr_class cdl -> - List.iter (add_class_declaration bv) cdl; (bv, m) - | Pstr_class_type cdtl -> - List.iter (add_class_type_declaration bv) cdtl; (bv, m) - | Pstr_include incl -> - let Node (s, m') = add_module_binding bv incl.pincl_mod in - add_names s; - let add = StringMap.fold StringMap.add m' in - (add bv, add m) - | Pstr_attribute _ -> (bv, m) - | Pstr_extension (e, _) -> - handle_extension e; - (bv, m) + let deprecated = Builtin_attributes.deprecated_of_attrs md.md_attributes in + { env with + modules = IdTbl.add id (EnvLazy.create (Subst.identity, md)) env.modules; + components = + IdTbl.add id + (components_of_module ~deprecated ~loc:md.md_loc + env Subst.identity (Pident id) md.md_type) + env.components; + summary = Env_module(env.summary, id, md) } -and add_use_file bv top_phrs = - ignore (List.fold_left add_top_phrase bv top_phrs) +and store_modtype id info env = + { env with + modtypes = IdTbl.add id info env.modtypes; + summary = Env_modtype(env.summary, id, info) } -and add_implementation bv l = - if !Clflags.transparent_modules then - ignore (add_structure_binding bv l) - else ignore (add_structure bv l) +and store_class id desc env = + { env with + classes = IdTbl.add id desc env.classes; + summary = Env_class(env.summary, id, desc) } -and add_implementation_binding bv l = - snd (add_structure_binding bv l) +and store_cltype id desc env = + { env with + cltypes = IdTbl.add id desc env.cltypes; + summary = Env_cltype(env.summary, id, desc) } -and add_top_phrase bv = function - | Ptop_def str -> add_structure bv str - | Ptop_dir (_, _) -> bv +(* Compute the components of a functor application in a path. *) -and add_class_expr bv ce = - match ce.pcl_desc with - Pcl_constr(l, tyl) -> - add bv l; List.iter (add_type bv) tyl - | Pcl_structure { pcstr_self = pat; pcstr_fields = fieldl } -> - let bv = add_pattern bv pat in List.iter (add_class_field bv) fieldl - | Pcl_fun(_, opte, pat, ce) -> - add_opt add_expr bv opte; - let bv = add_pattern bv pat in add_class_expr bv ce - | Pcl_apply(ce, exprl) -> - add_class_expr bv ce; List.iter (fun (_,e) -> add_expr bv e) exprl - | Pcl_let(rf, pel, ce) -> - let bv = add_bindings rf bv pel in add_class_expr bv ce - | Pcl_constraint(ce, ct) -> - add_class_expr bv ce; add_class_type bv ct - | Pcl_extension e -> handle_extension e - | Pcl_open (_ovf, m, e) -> - let bv = open_module bv m.txt in add_class_expr bv e +let components_of_functor_appl f env p1 p2 = + try + Hashtbl.find f.fcomp_cache p2 + with Not_found -> + let p = Papply(p1, p2) in + let sub = Subst.add_module f.fcomp_param p2 Subst.identity in + let mty = Subst.modtype sub f.fcomp_res in + let comps = components_of_module ~deprecated:None ~loc:Location.none + (*???*) + env Subst.identity p mty in + Hashtbl.add f.fcomp_cache p2 comps; + comps -and add_class_field bv pcf = - match pcf.pcf_desc with - Pcf_inherit(_, ce, _) -> add_class_expr bv ce - | Pcf_val(_, _, Cfk_concrete (_, e)) - | Pcf_method(_, _, Cfk_concrete (_, e)) -> add_expr bv e - | Pcf_val(_, _, Cfk_virtual ty) - | Pcf_method(_, _, Cfk_virtual ty) -> add_type bv ty - | Pcf_constraint(ty1, ty2) -> add_type bv ty1; add_type bv ty2 - | Pcf_initializer e -> add_expr bv e - | Pcf_attribute _ -> () - | Pcf_extension e -> handle_extension e +(* Define forward functions *) -and add_class_declaration bv decl = - add_class_expr bv decl.pci_expr +let _ = + components_of_module' := components_of_module; + components_of_functor_appl' := components_of_functor_appl; + components_of_module_maker' := components_of_module_maker -end -module Ext_array : sig -#1 "ext_array.mli" -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +(* Insertion of bindings by identifier *) +let add_functor_arg id env = + {env with + functor_args = Ident.add id () env.functor_args; + summary = Env_functor_arg (env.summary, id)} +let add_value ?check id desc env = + store_value ?check id desc env +let add_type ~check id info env = + store_type ~check id info env +and add_extension ~check id ext env = + store_extension ~check id ext env +and add_module_declaration ?(arg=false) ~check id md env = + let env = store_module ~check id md env in + if arg then add_functor_arg id env else env -(** Some utilities for {!Array} operations *) -val reverse_range : 'a array -> int -> int -> unit -val reverse_in_place : 'a array -> unit -val reverse : 'a array -> 'a array -val reverse_of_list : 'a list -> 'a array +and add_modtype id info env = + store_modtype id info env -val filter : ('a -> bool) -> 'a array -> 'a array +and add_class id ty env = + store_class id ty env -val filter_map : ('a -> 'b option) -> 'a array -> 'b array +and add_cltype id ty env = + store_cltype id ty env -val range : int -> int -> int array +let add_module ?arg id mty env = + add_module_declaration ~check:false ?arg id (md mty) env -val map2i : (int -> 'a -> 'b -> 'c ) -> 'a array -> 'b array -> 'c array +let add_local_type path info env = + { env with + local_constraints = PathMap.add path info env.local_constraints } -val to_list_f : - 'a array -> - ('a -> 'b) -> - 'b list +let add_local_constraint path info elv env = + match info with + {type_manifest = Some _; type_newtype_level = Some (lv, _)} -> + (* elv is the expansion level, lv is the definition level *) + let info = {info with type_newtype_level = Some (lv, elv)} in + add_local_type path info env + | _ -> assert false -val to_list_map : ('a -> 'b option) -> 'a array -> 'b list -val to_list_map_acc : - 'a array -> - 'b list -> - ('a -> 'b option) -> - 'b list +(* Insertion of bindings by name *) -val of_list_map : - 'a list -> - ('a -> 'b) -> - 'b array +let enter store_fun name data env = + let id = Ident.create name in (id, store_fun id data env) -val rfind_with_index : 'a array -> ('a -> 'b -> bool) -> 'b -> int +let enter_value ?check = enter (store_value ?check) +and enter_type = enter (store_type ~check:true) +and enter_extension = enter (store_extension ~check:true) +and enter_module_declaration ?arg id md env = + add_module_declaration ?arg ~check:true id md env + (* let (id, env) = enter store_module name md env in + (id, add_functor_arg ?arg id env) *) +and enter_modtype = enter store_modtype +and enter_class = enter store_class +and enter_cltype = enter store_cltype +let enter_module ?arg s mty env = + let id = Ident.create s in + (id, enter_module_declaration ?arg id (md mty) env) -type 'a split = [ `No_split | `Split of 'a array * 'a array ] +(* Insertion of all components of a signature *) -val rfind_and_split : - 'a array -> - ('a -> 'b -> bool) -> - 'b -> 'a split +let add_item comp env = + match comp with + Sig_value(id, decl) -> add_value id decl env + | Sig_type(id, decl, _) -> add_type ~check:false id decl env + | Sig_typext(id, ext, _) -> add_extension ~check:false id ext env + | Sig_module(id, md, _) -> add_module_declaration ~check:false id md env + | Sig_modtype(id, decl) -> add_modtype id decl env + | Sig_class(id, decl, _) -> add_class id decl env + | Sig_class_type(id, decl, _) -> add_cltype id decl env -val find_and_split : - 'a array -> - ('a -> 'b -> bool) -> - 'b -> 'a split +let rec add_signature sg env = + match sg with + [] -> env + | comp :: rem -> add_signature rem (add_item comp env) -val exists : ('a -> bool) -> 'a array -> bool +(* Open a signature path *) -val is_empty : 'a array -> bool +let add_components slot root env0 comps = + let add_l w comps env0 = + TycompTbl.add_open slot w comps env0 + in -val for_all2_no_exn : - 'a array -> - 'b array -> - ('a -> 'b -> bool) -> - bool + let add w comps env0 = IdTbl.add_open slot w root comps env0 in -val map : - 'a array -> - ('a -> 'b) -> - 'b array + let constrs = + add_l (fun x -> `Constructor x) comps.comp_constrs env0.constrs + in + let labels = + add_l (fun x -> `Label x) comps.comp_labels env0.labels + in -val iter : - 'a array -> - ('a -> unit) -> - unit + let values = + add (fun x -> `Value x) comps.comp_values env0.values + in + let types = + add (fun x -> `Type x) comps.comp_types env0.types + in + let modtypes = + add (fun x -> `Module_type x) comps.comp_modtypes env0.modtypes + in + let classes = + add (fun x -> `Class x) comps.comp_classes env0.classes + in + let cltypes = + add (fun x -> `Class_type x) comps.comp_cltypes env0.cltypes + in + let components = + add (fun x -> `Component x) comps.comp_components env0.components + in -val fold_left : - 'b array -> - 'a -> - ('a -> 'b -> 'a) -> - 'a + let modules = + add (fun x -> `Module x) comps.comp_modules env0.modules + in -val get_or : - 'a array -> - int -> - (unit -> 'a) -> - 'a -end = struct -#1 "ext_array.ml" -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) + { env0 with + summary = Env_open(env0.summary, root); + constrs; + labels; + values; + types; + modtypes; + classes; + cltypes; + components; + modules; + } +let open_signature slot root env0 = + match get_components (find_module_descr root env0) with + | Functor_comps _ -> None + | Structure_comps comps -> Some (add_components slot root env0 comps) +(* Open a signature from a file *) +let open_pers_signature name env = + match open_signature None (Pident(Ident.create_persistent name)) env with + | Some env -> env + | None -> assert false (* a compilation unit cannot refer to a functor *) -let reverse_range a i len = - if len = 0 then () - else - for k = 0 to (len-1)/2 do - let t = Array.unsafe_get a (i+k) in - Array.unsafe_set a (i+k) ( Array.unsafe_get a (i+len-1-k)); - Array.unsafe_set a (i+len-1-k) t; - done +let open_signature + ?(used_slot = ref false) + ?(loc = Location.none) ?(toplevel = false) ovf root env = + if not toplevel && ovf = Asttypes.Fresh && not loc.Location.loc_ghost + && (Warnings.is_active (Warnings.Unused_open "") + || Warnings.is_active (Warnings.Open_shadow_identifier ("", "")) + || Warnings.is_active (Warnings.Open_shadow_label_constructor ("",""))) + then begin + let used = used_slot in + !add_delayed_check_forward + (fun () -> + if not !used then begin + used := true; + Location.prerr_warning loc (Warnings.Unused_open (Path.name root)) + end + ); + let shadowed = ref [] in + let slot s b = + begin match check_shadowing env b with + | Some kind when not (List.mem (kind, s) !shadowed) -> + shadowed := (kind, s) :: !shadowed; + let w = + match kind with + | "label" | "constructor" -> + Warnings.Open_shadow_label_constructor (kind, s) + | _ -> Warnings.Open_shadow_identifier (kind, s) + in + Location.prerr_warning loc w + | _ -> () + end; + used := true + in + open_signature (Some slot) root env + end + else open_signature None root env +(* Read a signature from a file *) -let reverse_in_place a = - reverse_range a 0 (Array.length a) +let read_signature modname filename = + let ps = read_pers_struct modname filename in + Lazy.force ps.ps_sig -let reverse a = - let b_len = Array.length a in - if b_len = 0 then [||] else - let b = Array.copy a in - for i = 0 to b_len - 1 do - Array.unsafe_set b i (Array.unsafe_get a (b_len - 1 -i )) - done; - b +(* Return the CRC of the interface of the given compilation unit *) -let reverse_of_list = function - | [] -> [||] - | hd::tl as l -> - let len = List.length l in - let a = Array.make len hd in - let rec fill i = function - | [] -> a - | hd::tl -> Array.unsafe_set a (len - i - 2) hd; fill (i+1) tl in - fill 0 tl +let crc_of_unit name = + let ps = find_pers_struct name in + let crco = + try + List.assoc name ps.ps_crcs + with Not_found -> + assert false + in + match crco with + None -> assert false + | Some crc -> crc -let filter f a = - let arr_len = Array.length a in - let rec aux acc i = - if i = arr_len - then reverse_of_list acc - else - let v = Array.unsafe_get a i in - if f v then - aux (v::acc) (i+1) - else aux acc (i + 1) - in aux [] 0 +(* Return the list of imported interfaces with their CRCs *) +let imports () = + + let dont_record_crc_unit = !Clflags.dont_record_crc_unit in + match dont_record_crc_unit with + | None -> Consistbl.extract (StringSet.elements !imported_units) crc_units + | Some x -> + Consistbl.extract + (StringSet.fold + (fun m acc -> if m = x then acc else m::acc) + !imported_units []) crc_units -let filter_map (f : _ -> _ option) a = - let arr_len = Array.length a in - let rec aux acc i = - if i = arr_len - then reverse_of_list acc - else - let v = Array.unsafe_get a i in - match f v with - | Some v -> - aux (v::acc) (i+1) - | None -> - aux acc (i + 1) - in aux [] 0 +(* Returns true if [s] is an opaque imported module *) +let is_imported_opaque s = + StringSet.mem s !imported_opaque_units -let range from to_ = - if from > to_ then invalid_arg "Ext_array.range" - else Array.init (to_ - from + 1) (fun i -> i + from) +(* Save a signature to a file *) -let map2i f a b = - let len = Array.length a in - if len <> Array.length b then - invalid_arg "Ext_array.map2i" - else - Array.mapi (fun i a -> f i a ( Array.unsafe_get b i )) a +let save_signature_with_imports ?check_exists ~deprecated sg modname filename imports = + (*prerr_endline filename; + List.iter (fun (name, crc) -> prerr_endline name) imports;*) + Btype.cleanup_abbrev (); + Subst.reset_for_saving (); + let sg = Subst.signature (Subst.for_saving Subst.identity) sg in + let flags = + List.concat [ + if !Clflags.recursive_types then [Cmi_format.Rectypes] else []; + if !Clflags.opaque then [Cmi_format.Opaque] else []; + (if !Clflags.unsafe_string then [Cmi_format.Unsafe_string] else []); + (match deprecated with Some s -> [Deprecated s] | None -> []); + ] + in + try + let cmi = { + cmi_name = modname; + cmi_sign = sg; + cmi_crcs = imports; + cmi_flags = flags; + } in + let crc = -let rec tolist_f_aux a f i res = - if i < 0 then res else - let v = Array.unsafe_get a i in - tolist_f_aux a f (i - 1) - (f v :: res) - -let to_list_f a f = tolist_f_aux a f (Array.length a - 1) [] + create_cmi ?check_exists filename cmi in -let rec tolist_aux a f i res = - if i < 0 then res else - let v = Array.unsafe_get a i in - tolist_aux a f (i - 1) - (match f v with - | Some v -> v :: res - | None -> res) + (* Enter signature in persistent table so that imported_unit() + will also return its crc *) + let comps = + components_of_module ~deprecated ~loc:Location.none + empty Subst.identity + (Pident(Ident.create_persistent modname)) (Mty_signature sg) in + let ps = + { ps_name = modname; + ps_sig = lazy (Subst.signature Subst.identity sg); + ps_comps = comps; + ps_crcs = (cmi.cmi_name, Some crc) :: imports; + ps_filename = filename; + ps_flags = cmi.cmi_flags; + } in + save_pers_struct crc ps; + cmi + with exn -> + remove_file filename; + raise exn -let to_list_map f a = - tolist_aux a f (Array.length a - 1) [] +let save_signature ?check_exists ~deprecated sg modname filename = + save_signature_with_imports ?check_exists ~deprecated sg modname filename (imports()) -let to_list_map_acc a acc f = - tolist_aux a f (Array.length a - 1) acc +(* Folding on environments *) +let find_all proj1 proj2 f lid env acc = + match lid with + | None -> + IdTbl.fold_name + (fun name (p, data) acc -> f name p data acc) + (proj1 env) acc + | Some l -> + let p, desc = lookup_module_descr l env in + begin match get_components desc with + Structure_comps c -> + Tbl.fold + (fun s (data, pos) acc -> f s (Pdot (p, s, pos)) data acc) + (proj2 c) acc + | Functor_comps _ -> + acc + end -let of_list_map a f = - match a with - | [] -> [||] - | [a0] -> - let b0 = f a0 in - [|b0|] - | [a0;a1] -> - let b0 = f a0 in - let b1 = f a1 in - [|b0;b1|] - | [a0;a1;a2] -> - let b0 = f a0 in - let b1 = f a1 in - let b2 = f a2 in - [|b0;b1;b2|] - | [a0;a1;a2;a3] -> - let b0 = f a0 in - let b1 = f a1 in - let b2 = f a2 in - let b3 = f a3 in - [|b0;b1;b2;b3|] - | [a0;a1;a2;a3;a4] -> - let b0 = f a0 in - let b1 = f a1 in - let b2 = f a2 in - let b3 = f a3 in - let b4 = f a4 in - [|b0;b1;b2;b3;b4|] +let find_all_simple_list proj1 proj2 f lid env acc = + match lid with + | None -> + TycompTbl.fold_name + (fun data acc -> f data acc) + (proj1 env) acc + | Some l -> + let (_p, desc) = lookup_module_descr l env in + begin match get_components desc with + Structure_comps c -> + Tbl.fold + (fun _s comps acc -> + match comps with + [] -> acc + | data :: _ -> + f data acc) + (proj2 c) acc + | Functor_comps _ -> + acc + end + +let fold_modules f lid env acc = + match lid with + | None -> + let acc = + IdTbl.fold_name + (fun name (p, data) acc -> + let data = EnvLazy.force subst_modtype_maker data in + f name p data acc + ) + env.modules + acc + in + Hashtbl.fold + (fun name ps acc -> + match ps with + None -> acc + | Some ps -> + f name (Pident(Ident.create_persistent name)) + (md (Mty_signature (Lazy.force ps.ps_sig))) acc) + persistent_structures + acc + | Some l -> + let p, desc = lookup_module_descr l env in + begin match get_components desc with + Structure_comps c -> + Tbl.fold + (fun s (data, pos) acc -> + f s (Pdot (p, s, pos)) + (EnvLazy.force subst_modtype_maker data) acc) + c.comp_modules + acc + | Functor_comps _ -> + acc + end + +let fold_values f = + find_all (fun env -> env.values) (fun sc -> sc.comp_values) f +and fold_constructors f = + find_all_simple_list (fun env -> env.constrs) (fun sc -> sc.comp_constrs) f +and fold_labels f = + find_all_simple_list (fun env -> env.labels) (fun sc -> sc.comp_labels) f +and fold_types f = + find_all (fun env -> env.types) (fun sc -> sc.comp_types) f +and fold_modtypes f = + find_all (fun env -> env.modtypes) (fun sc -> sc.comp_modtypes) f +and fold_classs f = + find_all (fun env -> env.classes) (fun sc -> sc.comp_classes) f +and fold_cltypes f = + find_all (fun env -> env.cltypes) (fun sc -> sc.comp_cltypes) f + + +(* Make the initial environment *) +let (initial_safe_string, initial_unsafe_string) = + Predef.build_initial_env + (add_type ~check:false) + (add_extension ~check:false) + empty + +(* Return the environment summary *) - | a0::a1::a2::a3::a4::tl -> - let b0 = f a0 in - let b1 = f a1 in - let b2 = f a2 in - let b3 = f a3 in - let b4 = f a4 in - let len = List.length tl + 5 in - let arr = Array.make len b0 in - Array.unsafe_set arr 1 b1 ; - Array.unsafe_set arr 2 b2 ; - Array.unsafe_set arr 3 b3 ; - Array.unsafe_set arr 4 b4 ; - let rec fill i = function - | [] -> arr - | hd :: tl -> - Array.unsafe_set arr i (f hd); - fill (i + 1) tl in - fill 5 tl +let summary env = + if PathMap.is_empty env.local_constraints then env.summary + else Env_constraints (env.summary, env.local_constraints) -(** - {[ - # rfind_with_index [|1;2;3|] (=) 2;; - - : int = 1 - # rfind_with_index [|1;2;3|] (=) 1;; - - : int = 0 - # rfind_with_index [|1;2;3|] (=) 3;; - - : int = 2 - # rfind_with_index [|1;2;3|] (=) 4;; - - : int = -1 - ]} -*) -let rfind_with_index arr cmp v = - let len = Array.length arr in - let rec aux i = - if i < 0 then i - else if cmp (Array.unsafe_get arr i) v then i - else aux (i - 1) in - aux (len - 1) +let last_env = ref empty +let last_reduced_env = ref empty -type 'a split = [ `No_split | `Split of 'a array * 'a array ] -let rfind_and_split arr cmp v : _ split = - let i = rfind_with_index arr cmp v in - if i < 0 then - `No_split - else - `Split (Array.sub arr 0 i , Array.sub arr (i + 1 ) (Array.length arr - i - 1 )) +let keep_only_summary env = + if !last_env == env then !last_reduced_env + else begin + let new_env = + { + empty with + summary = env.summary; + local_constraints = env.local_constraints; + flags = env.flags; + } + in + last_env := env; + last_reduced_env := new_env; + new_env + end -let find_with_index arr cmp v = - let len = Array.length arr in - let rec aux i len = - if i >= len then -1 - else if cmp (Array.unsafe_get arr i ) v then i - else aux (i + 1) len in - aux 0 len +let env_of_only_summary env_from_summary env = + let new_env = env_from_summary env.summary Subst.identity in + { new_env with + local_constraints = env.local_constraints; + flags = env.flags; + } -let find_and_split arr cmp v : _ split = - let i = find_with_index arr cmp v in - if i < 0 then - `No_split - else - `Split (Array.sub arr 0 i, Array.sub arr (i + 1 ) (Array.length arr - i - 1)) +(* Error report *) -(** TODO: available since 4.03, use {!Array.exists} *) +open Format -let exists p a = - let n = Array.length a in - let rec loop i = - if i = n then false - else if p (Array.unsafe_get a i) then true - else loop (succ i) in - loop 0 +let report_error ppf = function + | Illegal_renaming(modname, ps_name, filename) -> fprintf ppf + "Wrong file naming: %a@ contains the compiled interface for @ \ + %s when %s was expected" + Location.print_filename filename ps_name modname + | Inconsistent_import(name, source1, source2) -> fprintf ppf + "@[The files %a@ and %a@ \ + make inconsistent assumptions@ over interface %s@]" + Location.print_filename source1 Location.print_filename source2 name + | Need_recursive_types(import, export) -> + fprintf ppf + "@[Unit %s imports from %s, which uses recursive types.@ %s@]" + export import "The compilation flag -rectypes is required" + | Depend_on_unsafe_string_unit(import, export) -> + fprintf ppf + "@[Unit %s imports from %s, compiled with -unsafe-string.@ %s@]" + export import "This compiler has been configured in strict \ + safe-string mode (-force-safe-string)" + | Missing_module(_, path1, path2) -> + fprintf ppf "@[@["; + if Path.same path1 path2 then + fprintf ppf "Internal path@ %s@ is dangling." (Path.name path1) + else + fprintf ppf "Internal path@ %s@ expands to@ %s@ which is dangling." + (Path.name path1) (Path.name path2); + fprintf ppf "@]@ @[%s@ %s@ %s.@]@]" + "The compiled interface for module" (Ident.name (Path.head path2)) + "was not found" + | Illegal_value_name(_loc, name) -> + fprintf ppf "'%s' is not a valid value identifier." + name + +let () = + Location.register_error_of_exn + (function + | Error (Missing_module (loc, _, _) + | Illegal_value_name (loc, _) + as err) when loc <> Location.none -> + Some (Location.error_of_printer loc report_error err) + | Error err -> Some (Location.error_of_printer_file report_error err) + | _ -> None + ) +end +module Typedtree : sig +#1 "typedtree.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -let is_empty arr = - Array.length arr = 0 +(** Abstract syntax tree after typing *) -let rec unsafe_loop index len p xs ys = - if index >= len then true - else - p - (Array.unsafe_get xs index) - (Array.unsafe_get ys index) && - unsafe_loop (succ index) len p xs ys +(** By comparison with {!Parsetree}: + - Every {!Longindent.t} is accompanied by a resolved {!Path.t}. -let for_all2_no_exn xs ys p = - let len_xs = Array.length xs in - let len_ys = Array.length ys in - len_xs = len_ys && - unsafe_loop 0 len_xs p xs ys +*) +open Asttypes +open Types -let map a f = - let open Array in - let l = length a in - if l = 0 then [||] else begin - let r = make l (f(unsafe_get a 0)) in - for i = 1 to l - 1 do - unsafe_set r i (f(unsafe_get a i)) - done; - r - end +(* Value expressions for the core language *) -let iter a f = - let open Array in - for i = 0 to length a - 1 do f(unsafe_get a i) done +type partial = Partial | Total +(** {1 Extension points} *) - let fold_left a x f = - let open Array in - let r = ref x in - for i = 0 to length a - 1 do - r := f !r (unsafe_get a i) - done; - !r - -let get_or arr i cb = - if i >=0 && i < Array.length arr then - Array.unsafe_get arr i - else cb () -end -module Ext_format : sig -#1 "ext_format.mli" -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +type attribute = Parsetree.attribute +type attributes = attribute list +(** {1 Core language} *) + +type pattern = + { pat_desc: pattern_desc; + pat_loc: Location.t; + pat_extra : (pat_extra * Location.t * attributes) list; + pat_type: type_expr; + mutable pat_env: Env.t; + pat_attributes: attributes; + } +and pat_extra = + | Tpat_constraint of core_type + (** P : T { pat_desc = P + ; pat_extra = (Tpat_constraint T, _, _) :: ... } + *) + | Tpat_type of Path.t * Longident.t loc + (** #tconst { pat_desc = disjunction + ; pat_extra = (Tpat_type (P, "tconst"), _, _) :: ...} + where [disjunction] is a [Tpat_or _] representing the + branches of [tconst]. + *) + | Tpat_open of Path.t * Longident.t loc * Env.t + | Tpat_unpack + (** (module P) { pat_desc = Tpat_var "P" + ; pat_extra = (Tpat_unpack, _, _) :: ... } + *) +and pattern_desc = + Tpat_any + (** _ *) + | Tpat_var of Ident.t * string loc + (** x *) + | Tpat_alias of pattern * Ident.t * string loc + (** P as a *) + | Tpat_constant of constant + (** 1, 'a', "true", 1.0, 1l, 1L, 1n *) + | Tpat_tuple of pattern list + (** (P1, ..., Pn) + Invariant: n >= 2 + *) + | Tpat_construct of + Longident.t loc * constructor_description * pattern list + (** C [] + C P [P] + C (P1, ..., Pn) [P1; ...; Pn] + *) + | Tpat_variant of label * pattern option * row_desc ref + (** `A (None) + `A P (Some P) + See {!Types.row_desc} for an explanation of the last parameter. + *) + | Tpat_record of + (Longident.t loc * label_description * pattern) list * + closed_flag + (** { l1=P1; ...; ln=Pn } (flag = Closed) + { l1=P1; ...; ln=Pn; _} (flag = Open) + Invariant: n > 0 + *) + | Tpat_array of pattern list + (** [| P1; ...; Pn |] *) + | Tpat_or of pattern * pattern * row_desc option + (** P1 | P2 -(** Simplified wrapper module for the standard library [Format] module. - *) + [row_desc] = [Some _] when translating [Ppat_type _], + [None] otherwise. + *) + | Tpat_lazy of pattern + (** lazy P *) -type t = private Format.formatter +and expression = + { exp_desc: expression_desc; + exp_loc: Location.t; + exp_extra: (exp_extra * Location.t * attributes) list; + exp_type: type_expr; + exp_env: Env.t; + exp_attributes: attributes; + } -val string : t -> string -> unit +and exp_extra = + | Texp_constraint of core_type + (** E : T *) + | Texp_coerce of core_type option * core_type + (** E :> T [Texp_coerce (None, T)] + E : T0 :> T [Texp_coerce (Some T0, T)] + *) + | Texp_open of override_flag * Path.t * Longident.t loc * Env.t + (** let open[!] M in [Texp_open (!, P, M, env)] + where [env] is the environment after opening [P] + *) + | Texp_poly of core_type option + (** Used for method bodies. *) + | Texp_newtype of string + (** fun (type t) -> *) -val break : t -> unit +and expression_desc = + Texp_ident of Path.t * Longident.t loc * Types.value_description + (** x + M.x + *) + | Texp_constant of constant + (** 1, 'a', "true", 1.0, 1l, 1L, 1n *) + | Texp_let of rec_flag * value_binding list * expression + (** let P1 = E1 and ... and Pn = EN in E (flag = Nonrecursive) + let rec P1 = E1 and ... and Pn = EN in E (flag = Recursive) + *) + | Texp_function of { arg_label : arg_label; param : Ident.t; + cases : case list; partial : partial; } + (** [Pexp_fun] and [Pexp_function] both translate to [Texp_function]. + See {!Parsetree} for more details. -val break1 : t -> unit + [param] is the identifier that is to be used to name the + parameter of the function. -val space : t -> unit + partial = + [Partial] if the pattern match is partial + [Total] otherwise. + *) + | Texp_apply of expression * (arg_label * expression option) list + (** E0 ~l1:E1 ... ~ln:En -val group : t -> int -> (unit -> 'a) -> 'a -(** [group] will record current indentation - and indent futher - *) + The expression can be None if the expression is abstracted over + this argument. It currently appears when a label is applied. -val vgroup : t -> int -> (unit -> 'a) -> 'a + For example: + let f x ~y = x + y in + f ~y:3 -val paren : t -> (unit -> 'a) -> 'a + The resulting typedtree for the application is: + Texp_apply (Texp_ident "f/1037", + [(Nolabel, None); + (Labelled "y", Some (Texp_constant Const_int 3)) + ]) + *) + | Texp_match of expression * case list * case list * partial + (** match E0 with + | P1 -> E1 + | P2 -> E2 + | exception P3 -> E3 -val paren_group : t -> int -> (unit -> 'a) -> 'a + [Texp_match (E0, [(P1, E1); (P2, E2)], [(P3, E3)], _)] + *) + | Texp_try of expression * case list + (** try E with P1 -> E1 | ... | PN -> EN *) + | Texp_tuple of expression list + (** (E1, ..., EN) *) + | Texp_construct of + Longident.t loc * constructor_description * expression list + (** C [] + C E [E] + C (E1, ..., En) [E1;...;En] + *) + | Texp_variant of label * expression option + | Texp_record of { + fields : ( Types.label_description * record_label_definition ) array; + representation : Types.record_representation; + extended_expression : expression option; + } + (** { l1=P1; ...; ln=Pn } (extended_expression = None) + { E0 with l1=P1; ...; ln=Pn } (extended_expression = Some E0) -val brace_group : t -> int -> (unit -> 'a) -> 'a + Invariant: n > 0 -val brace_vgroup : t -> int -> (unit -> 'a) -> 'a + If the type is { l1: t1; l2: t2 }, the expression + { E0 with t2=P2 } is represented as + Texp_record + { fields = [| l1, Kept t1; l2 Override P2 |]; representation; + extended_expression = Some E0 } + *) + | Texp_field of expression * Longident.t loc * label_description + | Texp_setfield of + expression * Longident.t loc * label_description * expression + | Texp_array of expression list + | Texp_ifthenelse of expression * expression * expression option + | Texp_sequence of expression * expression + | Texp_while of expression * expression + | Texp_for of + Ident.t * Parsetree.pattern * expression * expression * direction_flag * + expression + | Texp_send of expression * meth * expression option + | Texp_new of Path.t * Longident.t loc * Types.class_declaration + | Texp_instvar of Path.t * Path.t * string loc + | Texp_setinstvar of Path.t * Path.t * string loc * expression + | Texp_override of Path.t * (Path.t * string loc * expression) list + | Texp_letmodule of Ident.t * string loc * module_expr * expression + | Texp_letexception of extension_constructor * expression + | Texp_assert of expression + | Texp_lazy of expression + | Texp_object of class_structure * string list + | Texp_pack of module_expr + | Texp_unreachable + | Texp_extension_constructor of Longident.t loc * Path.t -val bracket_group : t -> int -> (unit -> 'a) -> 'a +and meth = + Tmeth_name of string + | Tmeth_val of Ident.t -val newline : t -> unit +and case = + { + c_lhs: pattern; + c_guard: expression option; + c_rhs: expression; + } -val to_out_channel : out_channel -> t +and record_label_definition = + | Kept of Types.type_expr + | Overridden of Longident.t loc * expression -val flush : t -> unit -> unit +(* Value expressions for the class language *) -val pp_print_queue : - ?pp_sep:(Format.formatter -> unit -> unit) -> - (Format.formatter -> 'a -> unit) -> Format.formatter -> 'a Queue.t -> unit +and class_expr = + { + cl_desc: class_expr_desc; + cl_loc: Location.t; + cl_type: Types.class_type; + cl_env: Env.t; + cl_attributes: attributes; + } -end = struct -#1 "ext_format.ml" -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +and class_expr_desc = + Tcl_ident of Path.t * Longident.t loc * core_type list + | Tcl_structure of class_structure + | Tcl_fun of + arg_label * pattern * (Ident.t * string loc * expression) list + * class_expr * partial + | Tcl_apply of class_expr * (arg_label * expression option) list + | Tcl_let of rec_flag * value_binding list * + (Ident.t * string loc * expression) list * class_expr + | Tcl_constraint of + class_expr * class_type option * string list * string list * Concr.t + (* Visible instance variables, methods and concrete methods *) + | Tcl_open of override_flag * Path.t * Longident.t loc * Env.t * class_expr +and class_structure = + { + cstr_self: pattern; + cstr_fields: class_field list; + cstr_type: Types.class_signature; + cstr_meths: Ident.t Meths.t; + } +and class_field = + { + cf_desc: class_field_desc; + cf_loc: Location.t; + cf_attributes: attributes; + } +and class_field_kind = + | Tcfk_virtual of core_type + | Tcfk_concrete of override_flag * expression +and class_field_desc = + Tcf_inherit of + override_flag * class_expr * string option * (string * Ident.t) list * + (string * Ident.t) list + (* Inherited instance variables and concrete methods *) + | Tcf_val of string loc * mutable_flag * Ident.t * class_field_kind * bool + | Tcf_method of string loc * private_flag * class_field_kind + | Tcf_constraint of core_type * core_type + | Tcf_initializer of expression + | Tcf_attribute of attribute +(* Value expressions for the module language *) +and module_expr = + { mod_desc: module_expr_desc; + mod_loc: Location.t; + mod_type: Types.module_type; + mod_env: Env.t; + mod_attributes: attributes; + } +(** Annotations for [Tmod_constraint]. *) +and module_type_constraint = + | Tmodtype_implicit + (** The module type constraint has been synthesized during typechecking. *) + | Tmodtype_explicit of module_type + (** The module type was in the source file. *) -open Format +and module_expr_desc = + Tmod_ident of Path.t * Longident.t loc + | Tmod_structure of structure + | Tmod_functor of Ident.t * string loc * module_type option * module_expr + | Tmod_apply of module_expr * module_expr * module_coercion + | Tmod_constraint of + module_expr * Types.module_type * module_type_constraint * module_coercion + (** ME (constraint = Tmodtype_implicit) + (ME : MT) (constraint = Tmodtype_explicit MT) + *) + | Tmod_unpack of expression * Types.module_type -type t = formatter +and structure = { + str_items : structure_item list; + str_type : Types.signature; + str_final_env : Env.t; +} -let string = pp_print_string +and structure_item = + { str_desc : structure_item_desc; + str_loc : Location.t; + str_env : Env.t + } -let break = fun fmt -> pp_print_break fmt 0 0 +and structure_item_desc = + Tstr_eval of expression * attributes + | Tstr_value of rec_flag * value_binding list + | Tstr_primitive of value_description + | Tstr_type of rec_flag * type_declaration list + | Tstr_typext of type_extension + | Tstr_exception of extension_constructor + | Tstr_module of module_binding + | Tstr_recmodule of module_binding list + | Tstr_modtype of module_type_declaration + | Tstr_open of open_description + | Tstr_class of (class_declaration * string list) list + | Tstr_class_type of (Ident.t * string loc * class_type_declaration) list + | Tstr_include of include_declaration + | Tstr_attribute of attribute -let break1 = - fun fmt -> pp_print_break fmt 0 1 +and module_binding = + { + mb_id: Ident.t; + mb_name: string loc; + mb_expr: module_expr; + mb_attributes: attributes; + mb_loc: Location.t; + } -let space fmt = - pp_print_break fmt 1 0 +and value_binding = + { + vb_pat: pattern; + vb_expr: expression; + vb_attributes: attributes; + vb_loc: Location.t; + } -let vgroup fmt indent u = - pp_open_vbox fmt indent; - let v = u () in - pp_close_box fmt (); - v +and module_coercion = + Tcoerce_none + | Tcoerce_structure of (int * module_coercion) list * + (Ident.t * int * module_coercion) list * + string list (* runtime fields *) + | Tcoerce_functor of module_coercion * module_coercion + | Tcoerce_primitive of primitive_coercion + | Tcoerce_alias of Path.t * module_coercion -let group fmt indent u = - pp_open_hovbox fmt indent; - let v = u () in - pp_close_box fmt (); - v - -let paren fmt u = - string fmt "("; - let v = u () in - string fmt ")"; - v +and module_type = + { mty_desc: module_type_desc; + mty_type : Types.module_type; + mty_env : Env.t; + mty_loc: Location.t; + mty_attributes: attributes; + } -let brace fmt u = - string fmt "{"; - (* break1 fmt ; *) - let v = u () in - string fmt "}"; - v +and module_type_desc = + Tmty_ident of Path.t * Longident.t loc + | Tmty_signature of signature + | Tmty_functor of Ident.t * string loc * module_type option * module_type + | Tmty_with of module_type * (Path.t * Longident.t loc * with_constraint) list + | Tmty_typeof of module_expr + | Tmty_alias of Path.t * Longident.t loc -let bracket fmt u = - string fmt "["; - let v = u () in - string fmt "]"; - v +and primitive_coercion = + { + pc_desc: Primitive.description; + pc_type: type_expr; + pc_env: Env.t; + pc_loc : Location.t; + + pc_id : Ident.t; + + } -let paren_group st n action = - group st n (fun _ -> paren st action) +and signature = { + sig_items : signature_item list; + sig_type : Types.signature; + sig_final_env : Env.t; +} -let brace_group st n action = - group st n (fun _ -> brace st action ) +and signature_item = + { sig_desc: signature_item_desc; + sig_env : Env.t; (* BINANNOT ADDED *) + sig_loc: Location.t } -let brace_vgroup st n action = - vgroup st n (fun _ -> - string st "{"; - pp_print_break st 0 2; - let v = vgroup st 0 action in - pp_print_break st 0 0; - string st "}"; - v - ) -let bracket_group st n action = - group st n (fun _ -> bracket st action) +and signature_item_desc = + Tsig_value of value_description + | Tsig_type of rec_flag * type_declaration list + | Tsig_typext of type_extension + | Tsig_exception of extension_constructor + | Tsig_module of module_declaration + | Tsig_recmodule of module_declaration list + | Tsig_modtype of module_type_declaration + | Tsig_open of open_description + | Tsig_include of include_description + | Tsig_class of class_description list + | Tsig_class_type of class_type_declaration list + | Tsig_attribute of attribute -let newline fmt = pp_print_newline fmt () +and module_declaration = + { + md_id: Ident.t; + md_name: string loc; + md_type: module_type; + md_attributes: attributes; + md_loc: Location.t; + } -let to_out_channel = formatter_of_out_channel +and module_type_declaration = + { + mtd_id: Ident.t; + mtd_name: string loc; + mtd_type: module_type option; + mtd_attributes: attributes; + mtd_loc: Location.t; + } -(* let non_breaking_space fmt = string fmt " " *) -(* let set_needed_space_function _ _ = () *) -let flush = pp_print_flush +and open_description = + { + open_path: Path.t; + open_txt: Longident.t loc; + open_override: override_flag; + open_loc: Location.t; + open_attributes: attribute list; + } -let list = pp_print_list +and 'a include_infos = + { + incl_mod: 'a; + incl_type: Types.signature; + incl_loc: Location.t; + incl_attributes: attribute list; + } -let rec pp_print_queue ?(pp_sep = pp_print_cut) pp_v ppf q = - Queue.iter (fun q -> pp_v ppf q ; pp_sep ppf ()) q +and include_description = module_type include_infos -end -module Ext_fmt -= struct -#1 "ext_fmt.ml" +and include_declaration = module_expr include_infos +and with_constraint = + Twith_type of type_declaration + | Twith_module of Path.t * Longident.t loc + | Twith_typesubst of type_declaration + | Twith_modsubst of Path.t * Longident.t loc -let with_file_as_pp filename f = - Ext_pervasives.finally (open_out_bin filename) ~clean:close_out - (fun chan -> - let fmt = Format.formatter_of_out_channel chan in - let v = f fmt in - Format.pp_print_flush fmt (); - v - ) +and core_type = + { mutable ctyp_desc : core_type_desc; + (** mutable because of [Typeclass.declare_method] *) + mutable ctyp_type : type_expr; + (** mutable because of [Typeclass.declare_method] *) + ctyp_env : Env.t; (* BINANNOT ADDED *) + ctyp_loc : Location.t; + ctyp_attributes: attributes; + } +and core_type_desc = + Ttyp_any + | Ttyp_var of string + | Ttyp_arrow of arg_label * core_type * core_type + | Ttyp_tuple of core_type list + | Ttyp_constr of Path.t * Longident.t loc * core_type list + | Ttyp_object of object_field list * closed_flag + | Ttyp_class of Path.t * Longident.t loc * core_type list + | Ttyp_alias of core_type * string + | Ttyp_variant of row_field list * closed_flag * label list option + | Ttyp_poly of string list * core_type + | Ttyp_package of package_type +and package_type = { + pack_path : Path.t; + pack_fields : (Longident.t loc * core_type) list; + pack_type : Types.module_type; + pack_txt : Longident.t loc; +} -let failwithf ~loc fmt = Format.ksprintf (fun s -> failwith (loc ^ s)) - fmt - -let invalid_argf fmt = Format.ksprintf invalid_arg fmt +and row_field = + Ttag of string loc * attributes * bool * core_type list + | Tinherit of core_type +and object_field = + | OTtag of string loc * attributes * core_type + | OTinherit of core_type -end -module Ext_sys : sig -#1 "ext_sys.mli" -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +and value_description = + { val_id: Ident.t; + val_name: string loc; + val_desc: core_type; + val_val: Types.value_description; + val_prim: string list; + val_loc: Location.t; + val_attributes: attributes; + } +and type_declaration = + { + typ_id: Ident.t; + typ_name: string loc; + typ_params: (core_type * variance) list; + typ_type: Types.type_declaration; + typ_cstrs: (core_type * core_type * Location.t) list; + typ_kind: type_kind; + typ_private: private_flag; + typ_manifest: core_type option; + typ_loc: Location.t; + typ_attributes: attributes; + } -(* Not used yet *) -(* val is_directory_no_exn : string -> bool *) +and type_kind = + Ttype_abstract + | Ttype_variant of constructor_declaration list + | Ttype_record of label_declaration list + | Ttype_open +and label_declaration = + { + ld_id: Ident.t; + ld_name: string loc; + ld_mutable: mutable_flag; + ld_type: core_type; + ld_loc: Location.t; + ld_attributes: attributes; + } -val is_windows_or_cygwin : bool +and constructor_declaration = + { + cd_id: Ident.t; + cd_name: string loc; + cd_args: constructor_arguments; + cd_res: core_type option; + cd_loc: Location.t; + cd_attributes: attributes; + } -val getenv_opt : - string -> - string option -end = struct -#1 "ext_sys.ml" -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +and constructor_arguments = + | Cstr_tuple of core_type list + | Cstr_record of label_declaration list -(** TODO: not exported yet, wait for Windows Fix*) -let is_directory_no_exn f = - try Sys.is_directory f with _ -> false +and type_extension = + { + tyext_path: Path.t; + tyext_txt: Longident.t loc; + tyext_params: (core_type * variance) list; + tyext_constructors: extension_constructor list; + tyext_private: private_flag; + tyext_attributes: attributes; + } +and extension_constructor = + { + ext_id: Ident.t; + ext_name: string loc; + ext_type : Types.extension_constructor; + ext_kind : extension_constructor_kind; + ext_loc : Location.t; + ext_attributes: attributes; + } -let is_windows_or_cygwin = Sys.win32 || Sys.cygwin +and extension_constructor_kind = + Text_decl of constructor_arguments * core_type option + | Text_rebind of Path.t * Longident.t loc +and class_type = + { + cltyp_desc: class_type_desc; + cltyp_type: Types.class_type; + cltyp_env: Env.t; + cltyp_loc: Location.t; + cltyp_attributes: attributes; + } -let getenv_opt = Sys.getenv_opt +and class_type_desc = + Tcty_constr of Path.t * Longident.t loc * core_type list + | Tcty_signature of class_signature + | Tcty_arrow of arg_label * core_type * class_type + | Tcty_open of override_flag * Path.t * Longident.t loc * Env.t * class_type -end -module Ext_path : sig -#1 "ext_path.mli" -(* Copyright (C) 2017 Authors of BuckleScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +and class_signature = { + csig_self : core_type; + csig_fields : class_type_field list; + csig_type : Types.class_signature; + } -type t +and class_type_field = { + ctf_desc: class_type_field_desc; + ctf_loc: Location.t; + ctf_attributes: attributes; + } +and class_type_field_desc = + | Tctf_inherit of class_type + | Tctf_val of (string * mutable_flag * virtual_flag * core_type) + | Tctf_method of (string * private_flag * virtual_flag * core_type) + | Tctf_constraint of (core_type * core_type) + | Tctf_attribute of attribute -(** Js_output is node style, which means - separator is only '/' +and class_declaration = + class_expr class_infos - if the path contains 'node_modules', - [node_relative_path] will discard its prefix and - just treat it as a library instead -*) -val simple_convert_node_path_to_os_path : string -> string +and class_description = + class_type class_infos +and class_type_declaration = + class_type class_infos +and 'a class_infos = + { ci_virt: virtual_flag; + ci_params: (core_type * variance) list; + ci_id_name : string loc; + ci_id_class: Ident.t; + ci_id_class_type : Ident.t; + ci_id_object : Ident.t; + ci_id_typehash : Ident.t; + ci_expr: 'a; + ci_decl: Types.class_declaration; + ci_type_decl : Types.class_type_declaration; + ci_loc: Location.t; + ci_attributes: attributes; + } -(** - [combine path1 path2] - 1. add some simplifications when concatenating - 2. when [path2] is absolute, return [path2] -*) -val combine : - string -> - string -> - string +(* Auxiliary functions over the a.s.t. *) +val iter_pattern_desc: (pattern -> unit) -> pattern_desc -> unit +val map_pattern_desc: (pattern -> pattern) -> pattern_desc -> pattern_desc +val let_bound_idents: value_binding list -> Ident.t list +val rev_let_bound_idents: value_binding list -> Ident.t list -(** - {[ - get_extension "a.txt" = ".txt" - get_extension "a" = "" - ]} -*) +val let_bound_idents_with_loc: + value_binding list -> (Ident.t * string loc) list +(** Alpha conversion of patterns *) +val alpha_pat: (Ident.t * Ident.t) list -> pattern -> pattern +val mknoloc: 'a -> 'a Asttypes.loc +val mkloc: 'a -> Location.t -> 'a Asttypes.loc +val pat_bound_idents: pattern -> Ident.t list +end = struct +#1 "typedtree.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -val node_rebase_file : - from:string -> - to_:string -> - string -> - string +(* Abstract syntax tree after typing *) -(** - TODO: could be highly optimized - if [from] and [to] resolve to the same path, a zero-length string is returned - Given that two paths are directory +open Misc +open Asttypes +open Types - A typical use case is - {[ - Filename.concat - (rel_normalized_absolute_path cwd (Filename.dirname a)) - (Filename.basename a) - ]} -*) -val rel_normalized_absolute_path : from:string -> string -> string +(* Value expressions for the core language *) +type partial = Partial | Total -val normalize_absolute_path : string -> string +type attribute = Parsetree.attribute +type attributes = attribute list +type pattern = + { pat_desc: pattern_desc; + pat_loc: Location.t; + pat_extra : (pat_extra * Location.t * attribute list) list; + pat_type: type_expr; + mutable pat_env: Env.t; + pat_attributes: attribute list; + } -val absolute_cwd_path : string -> string +and pat_extra = + | Tpat_constraint of core_type + | Tpat_type of Path.t * Longident.t loc + | Tpat_open of Path.t * Longident.t loc * Env.t + | Tpat_unpack -(** [concat dirname filename] - The same as {!Filename.concat} except a tiny optimization - for current directory simplification -*) -val concat : string -> string -> string +and pattern_desc = + Tpat_any + | Tpat_var of Ident.t * string loc + | Tpat_alias of pattern * Ident.t * string loc + | Tpat_constant of constant + | Tpat_tuple of pattern list + | Tpat_construct of + Longident.t loc * constructor_description * pattern list + | Tpat_variant of label * pattern option * row_desc ref + | Tpat_record of + (Longident.t loc * label_description * pattern) list * + closed_flag + | Tpat_array of pattern list + | Tpat_or of pattern * pattern * row_desc option + | Tpat_lazy of pattern -val check_suffix_case : - string -> string -> bool +and expression = + { exp_desc: expression_desc; + exp_loc: Location.t; + exp_extra: (exp_extra * Location.t * attribute list) list; + exp_type: type_expr; + exp_env: Env.t; + exp_attributes: attribute list; + } +and exp_extra = + | Texp_constraint of core_type + | Texp_coerce of core_type option * core_type + | Texp_open of override_flag * Path.t * Longident.t loc * Env.t + | Texp_poly of core_type option + | Texp_newtype of string +and expression_desc = + Texp_ident of Path.t * Longident.t loc * Types.value_description + | Texp_constant of constant + | Texp_let of rec_flag * value_binding list * expression + | Texp_function of { arg_label : arg_label; param : Ident.t; + cases : case list; partial : partial; } + | Texp_apply of expression * (arg_label * expression option) list + | Texp_match of expression * case list * case list * partial + | Texp_try of expression * case list + | Texp_tuple of expression list + | Texp_construct of + Longident.t loc * constructor_description * expression list + | Texp_variant of label * expression option + | Texp_record of { + fields : ( Types.label_description * record_label_definition ) array; + representation : Types.record_representation; + extended_expression : expression option; + } + | Texp_field of expression * Longident.t loc * label_description + | Texp_setfield of + expression * Longident.t loc * label_description * expression + | Texp_array of expression list + | Texp_ifthenelse of expression * expression * expression option + | Texp_sequence of expression * expression + | Texp_while of expression * expression + | Texp_for of + Ident.t * Parsetree.pattern * expression * expression * direction_flag * + expression + | Texp_send of expression * meth * expression option + | Texp_new of Path.t * Longident.t loc * Types.class_declaration + | Texp_instvar of Path.t * Path.t * string loc + | Texp_setinstvar of Path.t * Path.t * string loc * expression + | Texp_override of Path.t * (Path.t * string loc * expression) list + | Texp_letmodule of Ident.t * string loc * module_expr * expression + | Texp_letexception of extension_constructor * expression + | Texp_assert of expression + | Texp_lazy of expression + | Texp_object of class_structure * string list + | Texp_pack of module_expr + | Texp_unreachable + | Texp_extension_constructor of Longident.t loc * Path.t -(* It is lazy so that it will not hit errors when in script mode *) -val package_dir : string Lazy.t +and meth = + Tmeth_name of string + | Tmeth_val of Ident.t -end = struct -#1 "ext_path.ml" -(* Copyright (C) 2017 Authors of BuckleScript - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +and case = + { + c_lhs: pattern; + c_guard: expression option; + c_rhs: expression; + } -type t = - | File of string - | Dir of string +and record_label_definition = + | Kept of Types.type_expr + | Overridden of Longident.t loc * expression +(* Value expressions for the class language *) -let simple_convert_node_path_to_os_path = - if Sys.unix then fun x -> x - else if Sys.win32 || Sys.cygwin then - Ext_string.replace_slash_backward - else failwith ("Unknown OS : " ^ Sys.os_type) +and class_expr = + { + cl_desc: class_expr_desc; + cl_loc: Location.t; + cl_type: Types.class_type; + cl_env: Env.t; + cl_attributes: attribute list; + } +and class_expr_desc = + Tcl_ident of Path.t * Longident.t loc * core_type list + | Tcl_structure of class_structure + | Tcl_fun of + arg_label * pattern * (Ident.t * string loc * expression) list + * class_expr * partial + | Tcl_apply of class_expr * (arg_label * expression option) list + | Tcl_let of rec_flag * value_binding list * + (Ident.t * string loc * expression) list * class_expr + | Tcl_constraint of + class_expr * class_type option * string list * string list * Concr.t + (* Visible instance variables, methods and concrete methods *) + | Tcl_open of override_flag * Path.t * Longident.t loc * Env.t * class_expr -let cwd = lazy (Sys.getcwd()) +and class_structure = + { + cstr_self: pattern; + cstr_fields: class_field list; + cstr_type: Types.class_signature; + cstr_meths: Ident.t Meths.t; + } -let split_by_sep_per_os : string -> string list = - if Ext_sys.is_windows_or_cygwin then - fun x -> - (* on Windows, we can still accept -bs-package-output lib/js *) - Ext_string.split_by - (fun x -> match x with |'/' |'\\' -> true | _ -> false) x - else - fun x -> Ext_string.split x '/' +and class_field = + { + cf_desc: class_field_desc; + cf_loc: Location.t; + cf_attributes: attribute list; + } -(** example - {[ - "/bb/mbigc/mbig2899/bgit/bucklescript/jscomp/stdlib/external/pervasives.cmj" - "/bb/mbigc/mbig2899/bgit/bucklescript/jscomp/stdlib/ocaml_array.ml" - ]} +and class_field_kind = + | Tcfk_virtual of core_type + | Tcfk_concrete of override_flag * expression - The other way - {[ +and class_field_desc = + Tcf_inherit of + override_flag * class_expr * string option * (string * Ident.t) list * + (string * Ident.t) list + (* Inherited instance variables and concrete methods *) + | Tcf_val of string loc * mutable_flag * Ident.t * class_field_kind * bool + | Tcf_method of string loc * private_flag * class_field_kind + | Tcf_constraint of core_type * core_type + | Tcf_initializer of expression + | Tcf_attribute of attribute - "/bb/mbigc/mbig2899/bgit/bucklescript/jscomp/stdlib/ocaml_array.ml" - "/bb/mbigc/mbig2899/bgit/bucklescript/jscomp/stdlib/external/pervasives.cmj" - ]} - {[ - "/bb/mbigc/mbig2899/bgit/bucklescript/jscomp/stdlib//ocaml_array.ml" - ]} - {[ - /a/b - /c/d - ]} -*) -let node_relative_path - ~from:(file_or_dir_2 : t ) - (file_or_dir_1 : t) - = - let relevant_dir1 = - match file_or_dir_1 with - | Dir x -> x - | File file1 -> Filename.dirname file1 in - let relevant_dir2 = - match file_or_dir_2 with - | Dir x -> x - | File file2 -> Filename.dirname file2 in - let dir1 = split_by_sep_per_os relevant_dir1 in - let dir2 = split_by_sep_per_os relevant_dir2 in - let rec go (dir1 : string list) (dir2 : string list) = - match dir1, dir2 with - | "." :: xs, ys -> go xs ys - | xs , "." :: ys -> go xs ys - | x::xs , y :: ys when x = y - -> go xs ys - | _, _ -> - Ext_list.map_append dir2 dir1 (fun _ -> Literals.node_parent) - in - match go dir1 dir2 with - | (x :: _ ) as ys when x = Literals.node_parent -> - String.concat Literals.node_sep ys - | ys -> - String.concat Literals.node_sep - @@ Literals.node_current :: ys +(* Value expressions for the module language *) +and module_expr = + { mod_desc: module_expr_desc; + mod_loc: Location.t; + mod_type: Types.module_type; + mod_env: Env.t; + mod_attributes: attribute list; + } -let node_concat ~dir base = - dir ^ Literals.node_sep ^ base +and module_type_constraint = + Tmodtype_implicit +| Tmodtype_explicit of module_type -let node_rebase_file ~from ~to_ file = - - node_concat - ~dir:( - if from = to_ then Literals.node_current - else node_relative_path ~from:(Dir from) (Dir to_)) - file - - -(*** - {[ - Filename.concat "." "";; - "./" - ]} -*) -let combine path1 path2 = - if Filename.is_relative path2 then - if Ext_string.is_empty path2 then - path1 - else - if path1 = Filename.current_dir_name then - path2 - else - if path2 = Filename.current_dir_name - then path1 - else - Filename.concat path1 path2 - else - path2 +and module_expr_desc = + Tmod_ident of Path.t * Longident.t loc + | Tmod_structure of structure + | Tmod_functor of Ident.t * string loc * module_type option * module_expr + | Tmod_apply of module_expr * module_expr * module_coercion + | Tmod_constraint of + module_expr * Types.module_type * module_type_constraint * module_coercion + | Tmod_unpack of expression * Types.module_type +and structure = { + str_items : structure_item list; + str_type : Types.signature; + str_final_env : Env.t; +} +and structure_item = + { str_desc : structure_item_desc; + str_loc : Location.t; + str_env : Env.t + } +and structure_item_desc = + Tstr_eval of expression * attributes + | Tstr_value of rec_flag * value_binding list + | Tstr_primitive of value_description + | Tstr_type of rec_flag * type_declaration list + | Tstr_typext of type_extension + | Tstr_exception of extension_constructor + | Tstr_module of module_binding + | Tstr_recmodule of module_binding list + | Tstr_modtype of module_type_declaration + | Tstr_open of open_description + | Tstr_class of (class_declaration * string list) list + | Tstr_class_type of (Ident.t * string loc * class_type_declaration) list + | Tstr_include of include_declaration + | Tstr_attribute of attribute +and module_binding = + { + mb_id: Ident.t; + mb_name: string loc; + mb_expr: module_expr; + mb_attributes: attribute list; + mb_loc: Location.t; + } +and value_binding = + { + vb_pat: pattern; + vb_expr: expression; + vb_attributes: attributes; + vb_loc: Location.t; + } +and module_coercion = + Tcoerce_none + | Tcoerce_structure of (int * module_coercion) list * + (Ident.t * int * module_coercion) list * + string list (* runtime fields *) + | Tcoerce_functor of module_coercion * module_coercion + | Tcoerce_primitive of primitive_coercion + | Tcoerce_alias of Path.t * module_coercion +and module_type = + { mty_desc: module_type_desc; + mty_type : Types.module_type; + mty_env : Env.t; + mty_loc: Location.t; + mty_attributes: attribute list; + } -let (//) x y = - if x = Filename.current_dir_name then y - else if y = Filename.current_dir_name then x - else Filename.concat x y +and module_type_desc = + Tmty_ident of Path.t * Longident.t loc + | Tmty_signature of signature + | Tmty_functor of Ident.t * string loc * module_type option * module_type + | Tmty_with of module_type * (Path.t * Longident.t loc * with_constraint) list + | Tmty_typeof of module_expr + | Tmty_alias of Path.t * Longident.t loc -(** - {[ - split_aux "//ghosg//ghsogh/";; - - : string * string list = ("/", ["ghosg"; "ghsogh"]) - ]} - Note that - {[ - Filename.dirname "/a/" = "/" - Filename.dirname "/a/b/" = Filename.dirname "/a/b" = "/a" - ]} - Special case: - {[ - basename "//" = "/" - basename "///" = "/" - ]} - {[ - basename "" = "." - basename "" = "." - dirname "" = "." - dirname "" = "." - ]} -*) -let split_aux p = - let rec go p acc = - let dir = Filename.dirname p in - if dir = p then dir, acc - else - let new_path = Filename.basename p in - if Ext_string.equal new_path Filename.dir_sep then - go dir acc - (* We could do more path simplification here - leave to [rel_normalized_absolute_path] - *) - else - go dir (new_path :: acc) +(* Keep primitive type information for type-based lambda-code specialization *) +and primitive_coercion = + { + pc_desc: Primitive.description; + pc_type: type_expr; + pc_env: Env.t; + pc_loc : Location.t; + + pc_id : Ident.t; - in go p [] + } +and signature = { + sig_items : signature_item list; + sig_type : Types.signature; + sig_final_env : Env.t; +} +and signature_item = + { sig_desc: signature_item_desc; + sig_env : Env.t; (* BINANNOT ADDED *) + sig_loc: Location.t } +and signature_item_desc = + Tsig_value of value_description + | Tsig_type of rec_flag * type_declaration list + | Tsig_typext of type_extension + | Tsig_exception of extension_constructor + | Tsig_module of module_declaration + | Tsig_recmodule of module_declaration list + | Tsig_modtype of module_type_declaration + | Tsig_open of open_description + | Tsig_include of include_description + | Tsig_class of class_description list + | Tsig_class_type of class_type_declaration list + | Tsig_attribute of attribute +and module_declaration = + { + md_id: Ident.t; + md_name: string loc; + md_type: module_type; + md_attributes: attribute list; + md_loc: Location.t; + } -(** - TODO: optimization - if [from] and [to] resolve to the same path, a zero-length string is returned +and module_type_declaration = + { + mtd_id: Ident.t; + mtd_name: string loc; + mtd_type: module_type option; + mtd_attributes: attribute list; + mtd_loc: Location.t; + } - This function is useed in [es6-global] and - [amdjs-global] format and tailored for `rollup` -*) -let rel_normalized_absolute_path ~from to_ = - let root1, paths1 = split_aux from in - let root2, paths2 = split_aux to_ in - if root1 <> root2 then root2 - else - let rec go xss yss = - match xss, yss with - | x::xs, y::ys -> - if Ext_string.equal x y then go xs ys - else if x = Filename.current_dir_name then go xs yss - else if y = Filename.current_dir_name then go xss ys - else - let start = - Ext_list.fold_left xs Ext_string.parent_dir_lit (fun acc _ -> acc // Ext_string.parent_dir_lit ) - in - Ext_list.fold_left yss start (fun acc v -> acc // v) - | [], [] -> Ext_string.empty - | [], y::ys -> Ext_list.fold_left ys y (fun acc x -> acc // x) - | x::xs, [] -> - Ext_list.fold_left xs Ext_string.parent_dir_lit (fun acc _ -> acc // Ext_string.parent_dir_lit ) - in - let v = go paths1 paths2 in +and open_description = + { + open_path: Path.t; + open_txt: Longident.t loc; + open_override: override_flag; + open_loc: Location.t; + open_attributes: attribute list; + } - if Ext_string.is_empty v then Literals.node_current - else - if - v = "." - || v = ".." - || Ext_string.starts_with v "./" - || Ext_string.starts_with v "../" - then v - else "./" ^ v +and 'a include_infos = + { + incl_mod: 'a; + incl_type: Types.signature; + incl_loc: Location.t; + incl_attributes: attribute list; + } -(*TODO: could be hgighly optimized later - {[ - normalize_absolute_path "/gsho/./..";; +and include_description = module_type include_infos - normalize_absolute_path "/a/b/../c../d/e/f";; +and include_declaration = module_expr include_infos - normalize_absolute_path "/gsho/./..";; +and with_constraint = + Twith_type of type_declaration + | Twith_module of Path.t * Longident.t loc + | Twith_typesubst of type_declaration + | Twith_modsubst of Path.t * Longident.t loc - normalize_absolute_path "/gsho/./../..";; +and core_type = +(* mutable because of [Typeclass.declare_method] *) + { mutable ctyp_desc : core_type_desc; + mutable ctyp_type : type_expr; + ctyp_env : Env.t; (* BINANNOT ADDED *) + ctyp_loc : Location.t; + ctyp_attributes: attribute list; + } - normalize_absolute_path "/a/b/c/d";; +and core_type_desc = + Ttyp_any + | Ttyp_var of string + | Ttyp_arrow of arg_label * core_type * core_type + | Ttyp_tuple of core_type list + | Ttyp_constr of Path.t * Longident.t loc * core_type list + | Ttyp_object of object_field list * closed_flag + | Ttyp_class of Path.t * Longident.t loc * core_type list + | Ttyp_alias of core_type * string + | Ttyp_variant of row_field list * closed_flag * label list option + | Ttyp_poly of string list * core_type + | Ttyp_package of package_type - normalize_absolute_path "/a/b/c/d/";; +and package_type = { + pack_path : Path.t; + pack_fields : (Longident.t loc * core_type) list; + pack_type : Types.module_type; + pack_txt : Longident.t loc; +} - normalize_absolute_path "/a/";; +and row_field = + Ttag of string loc * attributes * bool * core_type list + | Tinherit of core_type - normalize_absolute_path "/a";; - ]} -*) -(** See tests in {!Ounit_path_tests} *) -let normalize_absolute_path x = - let drop_if_exist xs = - match xs with - | [] -> [] - | _ :: xs -> xs in - let rec normalize_list acc paths = - match paths with - | [] -> acc - | x :: xs -> - if Ext_string.equal x Ext_string.current_dir_lit then - normalize_list acc xs - else if Ext_string.equal x Ext_string.parent_dir_lit then - normalize_list (drop_if_exist acc ) xs - else - normalize_list (x::acc) xs - in - let root, paths = split_aux x in - let rev_paths = normalize_list [] paths in - let rec go acc rev_paths = - match rev_paths with - | [] -> Filename.concat root acc - | last::rest -> go (Filename.concat last acc ) rest in - match rev_paths with - | [] -> root - | last :: rest -> go last rest +and object_field = + | OTtag of string loc * attributes * core_type + | OTinherit of core_type +and value_description = + { val_id: Ident.t; + val_name: string loc; + val_desc: core_type; + val_val: Types.value_description; + val_prim: string list; + val_loc: Location.t; + val_attributes: attribute list; + } +and type_declaration = + { typ_id: Ident.t; + typ_name: string loc; + typ_params: (core_type * variance) list; + typ_type: Types.type_declaration; + typ_cstrs: (core_type * core_type * Location.t) list; + typ_kind: type_kind; + typ_private: private_flag; + typ_manifest: core_type option; + typ_loc: Location.t; + typ_attributes: attribute list; + } +and type_kind = + Ttype_abstract + | Ttype_variant of constructor_declaration list + | Ttype_record of label_declaration list + | Ttype_open -let absolute_path cwd s = - let process s = - let s = - if Filename.is_relative s then - Lazy.force cwd // s - else s in - (* Now simplify . and .. components *) - let rec aux s = - let base,dir = Filename.basename s, Filename.dirname s in - if dir = s then dir - else if base = Filename.current_dir_name then aux dir - else if base = Filename.parent_dir_name then Filename.dirname (aux dir) - else aux dir // base - in aux s in - process s +and label_declaration = + { + ld_id: Ident.t; + ld_name: string loc; + ld_mutable: mutable_flag; + ld_type: core_type; + ld_loc: Location.t; + ld_attributes: attribute list; + } -let absolute_cwd_path s = - absolute_path cwd s +and constructor_declaration = + { + cd_id: Ident.t; + cd_name: string loc; + cd_args: constructor_arguments; + cd_res: core_type option; + cd_loc: Location.t; + cd_attributes: attribute list; + } -let absolute cwd s = - match s with - | File x -> File (absolute_path cwd x ) - | Dir x -> Dir (absolute_path cwd x) +and constructor_arguments = + | Cstr_tuple of core_type list + | Cstr_record of label_declaration list -let concat dirname filename = - if filename = Filename.current_dir_name then dirname - else if dirname = Filename.current_dir_name then filename - else Filename.concat dirname filename - +and type_extension = + { + tyext_path: Path.t; + tyext_txt: Longident.t loc; + tyext_params: (core_type * variance) list; + tyext_constructors: extension_constructor list; + tyext_private: private_flag; + tyext_attributes: attribute list; + } -let check_suffix_case = - Ext_string.ends_with +and extension_constructor = + { + ext_id: Ident.t; + ext_name: string loc; + ext_type: Types.extension_constructor; + ext_kind: extension_constructor_kind; + ext_loc: Location.t; + ext_attributes: attribute list; + } -(* Input must be absolute directory *) -let rec find_root_filename ~cwd filename = - if Sys.file_exists ( Filename.concat cwd filename) then cwd - else - let cwd' = Filename.dirname cwd in - if String.length cwd' < String.length cwd then - find_root_filename ~cwd:cwd' filename - else - Ext_fmt.failwithf - ~loc:__LOC__ - "%s not found from %s" filename cwd +and extension_constructor_kind = + Text_decl of constructor_arguments * core_type option + | Text_rebind of Path.t * Longident.t loc +and class_type = + { + cltyp_desc: class_type_desc; + cltyp_type: Types.class_type; + cltyp_env: Env.t; + cltyp_loc: Location.t; + cltyp_attributes: attribute list; + } -let find_package_json_dir cwd = - find_root_filename ~cwd Literals.bsconfig_json +and class_type_desc = + Tcty_constr of Path.t * Longident.t loc * core_type list + | Tcty_signature of class_signature + | Tcty_arrow of arg_label * core_type * class_type + | Tcty_open of override_flag * Path.t * Longident.t loc * Env.t * class_type -let package_dir = lazy (find_package_json_dir (Lazy.force cwd)) +and class_signature = { + csig_self: core_type; + csig_fields: class_type_field list; + csig_type: Types.class_signature; + } -end -module Ext_ref : sig -#1 "ext_ref.mli" -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +and class_type_field = { + ctf_desc: class_type_field_desc; + ctf_loc: Location.t; + ctf_attributes: attribute list; + } -(** [non_exn_protect ref value f] assusme [f()] - would not raise -*) +and class_type_field_desc = + | Tctf_inherit of class_type + | Tctf_val of (string * mutable_flag * virtual_flag * core_type) + | Tctf_method of (string * private_flag * virtual_flag * core_type) + | Tctf_constraint of (core_type * core_type) + | Tctf_attribute of attribute -val non_exn_protect : 'a ref -> 'a -> (unit -> 'b) -> 'b -val protect : 'a ref -> 'a -> (unit -> 'b) -> 'b +and class_declaration = + class_expr class_infos -val protect2 : 'a ref -> 'b ref -> 'a -> 'b -> (unit -> 'c) -> 'c +and class_description = + class_type class_infos -(** [non_exn_protect2 refa refb va vb f ] - assume [f ()] would not raise -*) -val non_exn_protect2 : 'a ref -> 'b ref -> 'a -> 'b -> (unit -> 'c) -> 'c +and class_type_declaration = + class_type class_infos -val protect_list : ('a ref * 'a) list -> (unit -> 'b) -> 'b +and 'a class_infos = + { ci_virt: virtual_flag; + ci_params: (core_type * variance) list; + ci_id_name: string loc; + ci_id_class: Ident.t; + ci_id_class_type: Ident.t; + ci_id_object: Ident.t; + ci_id_typehash: Ident.t; + ci_expr: 'a; + ci_decl: Types.class_declaration; + ci_type_decl: Types.class_type_declaration; + ci_loc: Location.t; + ci_attributes: attribute list; + } -end = struct -#1 "ext_ref.ml" -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +(* Auxiliary functions over the a.s.t. *) -let non_exn_protect r v body = - let old = !r in - r := v; - let res = body() in - r := old; - res +let iter_pattern_desc f = function + | Tpat_alias(p, _, _) -> f p + | Tpat_tuple patl -> List.iter f patl + | Tpat_construct(_, _, patl) -> List.iter f patl + | Tpat_variant(_, pat, _) -> may f pat + | Tpat_record (lbl_pat_list, _) -> + List.iter (fun (_, _, pat) -> f pat) lbl_pat_list + | Tpat_array patl -> List.iter f patl + | Tpat_or(p1, p2, _) -> f p1; f p2 + | Tpat_lazy p -> f p + | Tpat_any + | Tpat_var _ + | Tpat_constant _ -> () -let protect r v body = - let old = !r in - try - r := v; - let res = body() in - r := old; - res - with x -> - r := old; - raise x +let map_pattern_desc f d = + match d with + | Tpat_alias (p1, id, s) -> + Tpat_alias (f p1, id, s) + | Tpat_tuple pats -> + Tpat_tuple (List.map f pats) + | Tpat_record (lpats, closed) -> + Tpat_record (List.map (fun (lid, l,p) -> lid, l, f p) lpats, closed) + | Tpat_construct (lid, c,pats) -> + Tpat_construct (lid, c, List.map f pats) + | Tpat_array pats -> + Tpat_array (List.map f pats) + | Tpat_lazy p1 -> Tpat_lazy (f p1) + | Tpat_variant (x1, Some p1, x2) -> + Tpat_variant (x1, Some (f p1), x2) + | Tpat_or (p1,p2,path) -> + Tpat_or (f p1, f p2, path) + | Tpat_var _ + | Tpat_constant _ + | Tpat_any + | Tpat_variant (_,None,_) -> d -let non_exn_protect2 r1 r2 v1 v2 body = - let old1 = !r1 in - let old2 = !r2 in - r1 := v1; - r2 := v2; - let res = body() in - r1 := old1; - r2 := old2; - res +(* List the identifiers bound by a pattern or a let *) -let protect2 r1 r2 v1 v2 body = - let old1 = !r1 in - let old2 = !r2 in - try - r1 := v1; - r2 := v2; - let res = body() in - r1 := old1; - r2 := old2; - res - with x -> - r1 := old1; - r2 := old2; - raise x +let idents = ref([]: (Ident.t * string loc) list) -let protect_list rvs body = - let olds = Ext_list.map rvs (fun (x,y) -> !x) in - let () = List.iter (fun (x,y) -> x:=y) rvs in - try - let res = body () in - List.iter2 (fun (x,_) old -> x := old) rvs olds; - res - with e -> - List.iter2 (fun (x,_) old -> x := old) rvs olds; - raise e +let rec bound_idents pat = + match pat.pat_desc with + | Tpat_var (id,s) -> idents := (id,s) :: !idents + | Tpat_alias(p, id, s ) -> + bound_idents p; idents := (id,s) :: !idents + | Tpat_or(p1, _, _) -> + (* Invariant : both arguments binds the same variables *) + bound_idents p1 + | d -> iter_pattern_desc bound_idents d -end -module Ml_binary : sig -#1 "ml_binary.mli" -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +let pat_bound_idents pat = + idents := []; + bound_idents pat; + let res = !idents in + idents := []; + List.map fst res +let rev_let_bound_idents_with_loc bindings = + idents := []; + List.iter (fun vb -> bound_idents vb.vb_pat) bindings; + let res = !idents in idents := []; res +let let_bound_idents_with_loc pat_expr_list = + List.rev(rev_let_bound_idents_with_loc pat_expr_list) -type _ kind = - | Ml : Parsetree.structure kind - | Mli : Parsetree.signature kind +let rev_let_bound_idents pat = List.map fst (rev_let_bound_idents_with_loc pat) +let let_bound_idents pat = List.map fst (let_bound_idents_with_loc pat) +let alpha_var env id = List.assoc id env -val read_ast : 'a kind -> in_channel -> 'a +let rec alpha_pat env p = match p.pat_desc with +| Tpat_var (id, s) -> (* note the ``Not_found'' case *) + {p with pat_desc = + try Tpat_var (alpha_var env id, s) with + | Not_found -> Tpat_any} +| Tpat_alias (p1, id, s) -> + let new_p = alpha_pat env p1 in + begin try + {p with pat_desc = Tpat_alias (new_p, alpha_var env id, s)} + with + | Not_found -> new_p + end +| d -> + {p with pat_desc = map_pattern_desc (alpha_pat env) d} -val write_ast : - 'a kind -> string -> 'a -> out_channel -> unit -end = struct -#1 "ml_binary.ml" -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +let mkloc = Location.mkloc +let mknoloc = Location.mknoloc +end +module Lambda : sig +#1 "lambda.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -type _ kind = - | Ml : Parsetree.structure kind - | Mli : Parsetree.signature kind +(* The "lambda" intermediate code *) -(** [read_ast kind ic] assume [ic] channel is - in the right position *) -let read_ast (type t ) (kind : t kind) ic : t = - let magic = - match kind with - | Ml -> Config.ast_impl_magic_number - | Mli -> Config.ast_intf_magic_number in - let buffer = really_input_string ic (String.length magic) in - assert(buffer = magic); (* already checked by apply_rewriter *) - Location.set_input_name @@ input_value ic; - input_value ic +open Asttypes -let write_ast (type t) (kind : t kind) - (fname : string) - (pt : t) oc = - let magic = - match kind with - | Ml -> Config.ast_impl_magic_number - | Mli -> Config.ast_intf_magic_number in - output_string oc magic ; - output_value oc fname; - output_value oc pt -end -module Bs_hash_stubs -= struct -#1 "bs_hash_stubs.ml" +type compile_time_constant = + | Big_endian + | Word_size + | Int_size + | Max_wosize + | Ostype_unix + | Ostype_win32 + | Ostype_cygwin + | Backend_type - (* not suporting nested if here..*) -external hash_string : string -> int = "caml_bs_hash_string" [@@noalloc];; +type loc_kind = + | Loc_FILE + | Loc_LINE + | Loc_MODULE + | Loc_LOC + | Loc_POS -external hash_string_int : string -> int -> int = "caml_bs_hash_string_and_int" [@@noalloc];; +type tag_info = + | Blk_constructor of string * int (* Number of non-const constructors*) + | Blk_tuple + | Blk_array + | Blk_variant of string + | Blk_record of string array + | Blk_module of string list + | Blk_module_export of Ident.t list + | Blk_extension_slot + | Blk_extension + (* underlying is the same as tuple, immutable block + {[ + exception A of int * int + ]} + is translated into + {[ + [A, x, y] + ]} -external hash_string_small_int : string -> int -> int = "caml_bs_hash_string_and_small_int" [@@noalloc];; + *) + | Blk_na of string (* This string only for debugging*) + | Blk_some + | Blk_some_not_nested (* ['a option] where ['a] can not inhabit a non-like value *) + | Blk_record_inlined of string array * string * int + | Blk_record_ext of string array + | Blk_lazy_general + | Blk_lazy_forward + | Blk_class (* ocaml style class *) -external hash_stamp_and_name : int -> string -> int = "caml_bs_hash_stamp_and_name" [@@noalloc];; +val blk_record : + ( + (Types.label_description* Typedtree.record_label_definition) array -> + tag_info + ) ref + +val blk_record_ext : + ( + (Types.label_description* Typedtree.record_label_definition) array -> + tag_info + ) ref + +val blk_record_inlined : + ( + (Types.label_description* Typedtree.record_label_definition) array -> + string -> + int -> + tag_info + ) ref -external hash_small_int : int -> int = "caml_bs_hash_small_int" [@@noalloc];; +val default_tag_info : tag_info -external hash_int : int -> int = "caml_bs_hash_int" [@@noalloc];; +val ref_tag_info : tag_info -external string_length_based_compare : string -> string -> int = "caml_string_length_based_compare" [@@noalloc];; +type field_dbg_info = + | Fld_na + | Fld_record of {name : string; mutable_flag : Asttypes.mutable_flag} + | Fld_module of string + | Fld_record_inline of string + | Fld_record_extension of string + | Fld_tuple +val fld_record : + (Types.label_description -> + field_dbg_info) ref -external - int_unsafe_blit : - int array -> int -> int array -> int -> int -> unit = "caml_int_array_blit" [@@noalloc];; - - +val ref_field_info : field_dbg_info -end -module Ext_util : sig -#1 "ext_util.mli" -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +type set_field_dbg_info = + | Fld_set_na + | Fld_record_set of string + | Fld_record_inline_set of string + | Fld_record_extension_set of string +val ref_field_set_info : set_field_dbg_info - -val power_2_above : int -> int -> int +val fld_record_set : + (Types.label_description -> + set_field_dbg_info) ref +type immediate_or_pointer = + | Immediate + | Pointer -val stats_to_string : Hashtbl.statistics -> string -end = struct -#1 "ext_util.ml" -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +type initialization_or_assignment = + | Assignment + (* Initialization of in heap values, like [caml_initialize] C primitive. The + field should not have been read before and initialization should happen + only once. *) + | Heap_initialization + (* Initialization of roots only. Compiles to a simple store. + No checks are done to preserve GC invariants. *) + | Root_initialization -(** - {[ - (power_2_above 16 63 = 64) - (power_2_above 16 76 = 128) - ]} -*) -let rec power_2_above x n = - if x >= n then x - else if x * 2 > Sys.max_array_length then x - else power_2_above (x * 2) n +type is_safe = + | Safe + | Unsafe +type pointer_info = + | Pt_constructor of string + | Pt_variant of string + | Pt_module_alias + | Pt_builtin_boolean + | Pt_shape_none + | Pt_na -let stats_to_string ({num_bindings; num_buckets; max_bucket_length; bucket_histogram} : Hashtbl.statistics) = - Printf.sprintf - "bindings: %d,buckets: %d, longest: %d, hist:[%s]" - num_bindings - num_buckets - max_bucket_length - (String.concat "," (Array.to_list (Array.map string_of_int bucket_histogram))) -end -module Hashtbl_gen -= struct -#1 "hashtbl_gen.ml" -(***********************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. All rights reserved. This file is distributed *) -(* under the terms of the GNU Library General Public License, with *) -(* the special exception on linking described in file ../LICENSE. *) -(* *) -(***********************************************************************) +val default_pointer_info : pointer_info -(* Hash tables *) +type primitive = + | Pidentity + | Pbytes_to_string + | Pbytes_of_string + | Pignore + | Prevapply + | Pdirapply + | Ploc of loc_kind + (* Globals *) + | Pgetglobal of Ident.t + | Psetglobal of Ident.t + (* Operations on heap blocks *) + | Pmakeblock of int * tag_info * mutable_flag * block_shape + | Pfield of int * field_dbg_info + | Pfield_computed + | Psetfield of int * immediate_or_pointer * initialization_or_assignment * set_field_dbg_info + | Psetfield_computed of immediate_or_pointer * initialization_or_assignment + | Pfloatfield of int * field_dbg_info + | Psetfloatfield of int * initialization_or_assignment * set_field_dbg_info + | Pduprecord of Types.record_representation * int + (* Force lazy values *) + | Plazyforce + (* External call *) + | Pccall of Primitive.description + (* Exceptions *) + | Praise of raise_kind + (* Boolean operations *) + | Psequand | Psequor | Pnot + (* Integer operations *) + | Pnegint | Paddint | Psubint | Pmulint + | Pdivint of is_safe | Pmodint of is_safe + | Pandint | Porint | Pxorint + | Plslint | Plsrint | Pasrint + | Pintcomp of comparison + | Poffsetint of int + | Poffsetref of int + (* Float operations *) + | Pintoffloat | Pfloatofint + | Pnegfloat | Pabsfloat + | Paddfloat | Psubfloat | Pmulfloat | Pdivfloat + | Pfloatcomp of comparison + (* String operations *) + | Pstringlength | Pstringrefu | Pstringrefs + | Pbyteslength | Pbytesrefu | Pbytessetu | Pbytesrefs | Pbytessets + (* Array operations *) + | Pmakearray of array_kind * mutable_flag + | Pduparray of array_kind * mutable_flag + (** For [Pduparray], the argument must be an immutable array. + The arguments of [Pduparray] give the kind and mutability of the + array being *produced* by the duplication. *) + | Parraylength of array_kind + | Parrayrefu of array_kind + | Parraysetu of array_kind + | Parrayrefs of array_kind + | Parraysets of array_kind + (* Test if the argument is a block or an immediate integer *) + | Pisint + (* Test if the (integer) argument is outside an interval *) + | Pisout + (* Bitvect operations *) + | Pbittest + (* Operations on boxed integers (Nativeint.t, Int32.t, Int64.t) *) + | Pbintofint of boxed_integer + | Pintofbint of boxed_integer + | Pcvtbint of boxed_integer (*source*) * boxed_integer (*destination*) + | Pnegbint of boxed_integer + | Paddbint of boxed_integer + | Psubbint of boxed_integer + | Pmulbint of boxed_integer + | Pdivbint of { size : boxed_integer; is_safe : is_safe } + | Pmodbint of { size : boxed_integer; is_safe : is_safe } + | Pandbint of boxed_integer + | Porbint of boxed_integer + | Pxorbint of boxed_integer + | Plslbint of boxed_integer + | Plsrbint of boxed_integer + | Pasrbint of boxed_integer + | Pbintcomp of boxed_integer * comparison + (* Operations on big arrays: (unsafe, #dimensions, kind, layout) *) + | Pbigarrayref of bool * int * bigarray_kind * bigarray_layout + | Pbigarrayset of bool * int * bigarray_kind * bigarray_layout + (* size of the nth dimension of a big array *) + | Pbigarraydim of int + (* load/set 16,32,64 bits from a string: (unsafe)*) + | Pstring_load_16 of bool + | Pstring_load_32 of bool + | Pstring_load_64 of bool + | Pstring_set_16 of bool + | Pstring_set_32 of bool + | Pstring_set_64 of bool + (* load/set 16,32,64 bits from a + (char, int8_unsigned_elt, c_layout) Bigarray.Array1.t : (unsafe) *) + | Pbigstring_load_16 of bool + | Pbigstring_load_32 of bool + | Pbigstring_load_64 of bool + | Pbigstring_set_16 of bool + | Pbigstring_set_32 of bool + | Pbigstring_set_64 of bool + (* Compile time constants *) + | Pctconst of compile_time_constant + (* byte swap *) + | Pbswap16 + | Pbbswap of boxed_integer + (* Integer to external pointer *) + | Pint_as_pointer + (* Inhibition of optimisation *) + | Popaque +and comparison = + Ceq | Cneq | Clt | Cgt | Cle | Cge +and array_kind = + Pgenarray | Paddrarray | Pintarray | Pfloatarray -module type S = sig - type key - type 'a t - val create: int -> 'a t - val clear: 'a t -> unit - val reset: 'a t -> unit - val copy: 'a t -> 'a t - val add: 'a t -> key -> 'a -> unit - val modify_or_init: 'a t -> key -> ('a -> unit) -> (unit -> 'a) -> unit - val remove: 'a t -> key -> unit - val find_exn: 'a t -> key -> 'a - val find_all: 'a t -> key -> 'a list - val find_opt: 'a t -> key -> 'a option - - (** return the key found in the hashtbl. - Use case: when you find the key existed in hashtbl, - you want to use the one stored in the hashtbl. - (they are semantically equivlanent, but may have other information different) - *) - val find_key_opt: 'a t -> key -> key option +and value_kind = + Pgenval | Pfloatval | Pboxedintval of boxed_integer | Pintval - val find_default: 'a t -> key -> 'a -> 'a +and block_shape = + value_kind list option - val replace: 'a t -> key -> 'a -> unit - val mem: 'a t -> key -> bool - val iter: 'a t -> (key -> 'a -> unit) -> unit - val fold: (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b - val length: 'a t -> int - val stats: 'a t -> Hashtbl.statistics - val to_list : 'a t -> (key -> 'a -> 'c) -> 'c list - val of_list2: key list -> 'a list -> 'a t -end +and boxed_integer = Primitive.boxed_integer = + Pnativeint | Pint32 | Pint64 -(* We do dynamic hashing, and resize the table and rehash the elements - when buckets become too long. *) +and bigarray_kind = + Pbigarray_unknown + | Pbigarray_float32 | Pbigarray_float64 + | Pbigarray_sint8 | Pbigarray_uint8 + | Pbigarray_sint16 | Pbigarray_uint16 + | Pbigarray_int32 | Pbigarray_int64 + | Pbigarray_caml_int | Pbigarray_native_int + | Pbigarray_complex32 | Pbigarray_complex64 -type ('a, 'b) t = - { mutable size: int; (* number of entries *) - mutable data: ('a, 'b) bucketlist array; (* the buckets *) - mutable seed: int; (* for randomization *) - initial_size: int; (* initial array size *) - } +and bigarray_layout = + Pbigarray_unknown_layout + | Pbigarray_c_layout + | Pbigarray_fortran_layout -and ('a, 'b) bucketlist = - | Empty - | Cons of 'a * 'b * ('a, 'b) bucketlist +and raise_kind = + | Raise_regular + | Raise_reraise + | Raise_notrace +type structured_constant = + Const_base of constant + | Const_pointer of int * pointer_info + | Const_block of int * tag_info * structured_constant list + | Const_float_array of string list + | Const_immstring of string -let create initial_size = - let s = Ext_util.power_2_above 16 initial_size in - { initial_size = s; size = 0; seed = 0; data = Array.make s Empty } +type inline_attribute = + | Always_inline (* [@inline] or [@inline always] *) + | Never_inline (* [@inline never] *) + | Unroll of int (* [@unroll x] *) + | Default_inline (* no [@inline] attribute *) -let clear h = - h.size <- 0; - let len = Array.length h.data in - for i = 0 to len - 1 do - h.data.(i) <- Empty - done +type specialise_attribute = + | Always_specialise (* [@specialise] or [@specialise always] *) + | Never_specialise (* [@specialise never] *) + | Default_specialise (* no [@specialise] attribute *) -let reset h = - h.size <- 0; - h.data <- Array.make h.initial_size Empty +type function_kind = Curried | Tupled +type let_kind = Strict | Alias | StrictOpt | Variable +(* Meaning of kinds for let x = e in e': + Strict: e may have side-effects; always evaluate e first + (If e is a simple expression, e.g. a variable or constant, + we may still substitute e'[x/e].) + Alias: e is pure, we can substitute e'[x/e] if x has 0 or 1 occurrences + in e' + StrictOpt: e does not have side-effects, but depend on the store; + we can discard e if x does not appear in e' + Variable: the variable x is assigned later in e' + *) -let copy h = { h with data = Array.copy h.data } +type public_info = string option (* label name *) -let length h = h.size +type meth_kind = Self | Public of public_info | Cached -let resize indexfun h = - let odata = h.data in - let osize = Array.length odata in - let nsize = osize * 2 in - if nsize < Sys.max_array_length then begin - let ndata = Array.make nsize Empty in - h.data <- ndata; (* so that indexfun sees the new bucket count *) - let rec insert_bucket = function - Empty -> () - | Cons(key, data, rest) -> - insert_bucket rest; (* preserve original order of elements *) - let nidx = indexfun h key in - ndata.(nidx) <- Cons(key, data, ndata.(nidx)) in - for i = 0 to osize - 1 do - insert_bucket (Array.unsafe_get odata i) - done - end +type shared_code = (int * int) list (* stack size -> code label *) +type function_attribute = { + inline : inline_attribute; + specialise : specialise_attribute; + is_a_functor: bool; + stub: bool; +} +type switch_names = {consts: string array; blocks: string array} -let iter h f = - let rec do_bucket = function - | Empty -> - () - | Cons(k, d, rest) -> - f k d; do_bucket rest in - let d = h.data in - for i = 0 to Array.length d - 1 do - do_bucket (Array.unsafe_get d i) - done +type lambda = + Lvar of Ident.t + | Lconst of structured_constant + | Lapply of lambda_apply + | Lfunction of lfunction + | Llet of let_kind * value_kind * Ident.t * lambda * lambda + | Lletrec of (Ident.t * lambda) list * lambda + | Lprim of primitive * lambda list * Location.t + | Lswitch of lambda * lambda_switch * Location.t +(* switch on strings, clauses are sorted by string order, + strings are pairwise distinct *) + | Lstringswitch of + lambda * (string * lambda) list * lambda option * Location.t + | Lstaticraise of int * lambda list + | Lstaticcatch of lambda * (int * Ident.t list) * lambda + | Ltrywith of lambda * Ident.t * lambda + | Lifthenelse of lambda * lambda * lambda + | Lsequence of lambda * lambda + | Lwhile of lambda * lambda + | Lfor of Ident.t * lambda * lambda * direction_flag * lambda + | Lassign of Ident.t * lambda + | Lsend of meth_kind * lambda * lambda * lambda list * Location.t + | Levent of lambda * lambda_event + | Lifused of Ident.t * lambda -let to_list h f = - let rec do_bucket bucket acc = - match bucket with - | Empty -> - acc - | Cons(k, d, rest) -> - do_bucket rest (f k d :: acc) in - let d = h.data in - let acc = ref [] in - for i = 0 to Array.length d - 1 do - acc := do_bucket (Array.unsafe_get d i) !acc - done; - !acc +and lfunction = + { kind: function_kind; + params: Ident.t list; + body: lambda; + attr: function_attribute; (* specified with [@inline] attribute *) + loc : Location.t; } -let fold f h init = - let rec do_bucket b accu = - match b with - Empty -> - accu - | Cons(k, d, rest) -> - do_bucket rest (f k d accu) in - let d = h.data in - let accu = ref init in - for i = 0 to Array.length d - 1 do - accu := do_bucket d.(i) !accu - done; - !accu +and lambda_apply = + { ap_func : lambda; + ap_args : lambda list; + ap_loc : Location.t; + ap_should_be_tailcall : bool; (* true if [@tailcall] was specified *) + ap_inlined : inline_attribute; (* specified with the [@inlined] attribute *) + ap_specialised : specialise_attribute; } -let rec bucket_length accu = function - | Empty -> accu - | Cons(_, _, rest) -> bucket_length (accu + 1) rest +and lambda_switch = + { sw_numconsts: int; (* Number of integer cases *) + sw_consts: (int * lambda) list; (* Integer cases *) + sw_numblocks: int; (* Number of tag block cases *) + sw_blocks: (int * lambda) list; (* Tag block cases *) + sw_failaction : lambda option; (* Action to take if failure *) + sw_names: switch_names option } +and lambda_event = + { lev_loc: Location.t; + lev_kind: lambda_event_kind; + lev_repr: int ref option; + lev_env: Env.summary } -let stats h = - let mbl = - Ext_array.fold_left h.data 0 (fun m b -> max m (bucket_length 0 b)) in - let histo = Array.make (mbl + 1) 0 in - Ext_array.iter h.data - (fun b -> - let l = bucket_length 0 b in - histo.(l) <- histo.(l) + 1) - ; - {Hashtbl. - num_bindings = h.size; - num_buckets = Array.length h.data; - max_bucket_length = mbl; - bucket_histogram = histo } +and lambda_event_kind = + Lev_before + | Lev_after of Types.type_expr + | Lev_function + | Lev_pseudo + | Lev_module_definition of Ident.t +type program = + { module_ident : Ident.t; + main_module_block_size : int; + required_globals : Ident.Set.t; (* Modules whose initializer side effects + must occur before [code]. *) + code : lambda } +(* Lambda code for the middle-end. + * In the closure case the code is a sequence of assignments to a + preallocated block of size [main_module_block_size] using + (Setfield(Getglobal(module_ident))). The size is used to preallocate + the block. + * In the flambda case the code is an expression returning a block + value of size [main_module_block_size]. The size is used to build + the module root as an initialize_symbol + Initialize_symbol(module_name, 0, + [getfield 0; ...; getfield (main_module_block_size - 1)]) +*) +(* Sharing key *) +val make_key: lambda -> lambda option -let rec small_bucket_mem eq key (lst : _ bucketlist) = - match lst with - | Empty -> false - | Cons(k1,_,rest1) -> - eq key k1 || - match rest1 with - | Empty -> false - | Cons(k2,_,rest2) -> - eq key k2 || - match rest2 with - | Empty -> false - | Cons(k3,_,rest3) -> - eq key k3 || - small_bucket_mem eq key rest3 +val const_unit: structured_constant +val lambda_assert_false: lambda +val lambda_unit: lambda +val name_lambda: let_kind -> lambda -> (Ident.t -> lambda) -> lambda +val name_lambda_list: lambda list -> (lambda list -> lambda) -> lambda +val iter: (lambda -> unit) -> lambda -> unit +module IdentSet: Set.S with type elt = Ident.t +val free_variables: lambda -> IdentSet.t +val free_methods: lambda -> IdentSet.t -let rec small_bucket_opt eq key (lst : _ bucketlist) : _ option = - match lst with - | Empty -> None - | Cons(k1,d1,rest1) -> - if eq key k1 then Some d1 else - match rest1 with - | Empty -> None - | Cons(k2,d2,rest2) -> - if eq key k2 then Some d2 else - match rest2 with - | Empty -> None - | Cons(k3,d3,rest3) -> - if eq key k3 then Some d3 else - small_bucket_opt eq key rest3 +val transl_normal_path: Path.t -> lambda (* Path.t is already normal *) +val transl_path: ?loc:Location.t -> Env.t -> Path.t -> lambda +[@@ocaml.deprecated "use transl_{module,value,extension,class}_path instead"] +val transl_module_path: ?loc:Location.t -> Env.t -> Path.t -> lambda +val transl_value_path: ?loc:Location.t -> Env.t -> Path.t -> lambda +val transl_extension_path: ?loc:Location.t -> Env.t -> Path.t -> lambda +val transl_class_path: ?loc:Location.t -> Env.t -> Path.t -> lambda -let rec small_bucket_key_opt eq key (lst : _ bucketlist) : _ option = - match lst with - | Empty -> None - | Cons(k1,d1,rest1) -> - if eq key k1 then Some k1 else - match rest1 with - | Empty -> None - | Cons(k2,d2,rest2) -> - if eq key k2 then Some k2 else - match rest2 with - | Empty -> None - | Cons(k3,d3,rest3) -> - if eq key k3 then Some k3 else - small_bucket_key_opt eq key rest3 +val make_sequence: ('a -> lambda) -> 'a list -> lambda +val subst_lambda: lambda Ident.tbl -> lambda -> lambda +val map : (lambda -> lambda) -> lambda -> lambda +val bind : let_kind -> Ident.t -> lambda -> lambda -> lambda -let rec small_bucket_default eq key default (lst : _ bucketlist) = - match lst with - | Empty -> default - | Cons(k1,d1,rest1) -> - if eq key k1 then d1 else - match rest1 with - | Empty -> default - | Cons(k2,d2,rest2) -> - if eq key k2 then d2 else - match rest2 with - | Empty -> default - | Cons(k3,d3,rest3) -> - if eq key k3 then d3 else - small_bucket_default eq key default rest3 +val commute_comparison : comparison -> comparison +val negate_comparison : comparison -> comparison -end -module String_hashtbl : sig -#1 "string_hashtbl.mli" -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +val default_function_attribute : function_attribute +val default_stub_attribute : function_attribute +(***********************) +(* For static failures *) +(***********************) -include Hashtbl_gen.S with type key = string +(* Get a new static failure ident *) +val next_raise_count : unit -> int +val next_negative_raise_count : unit -> int + (* Negative raise counts are used to compile 'match ... with + exception x -> ...'. This disabled some simplifications + performed by the Simplif module that assume that static raises + are in tail position in their handler. *) + +val staticfail : lambda (* Anticipated static failure *) + +(* Check anticipated failure, substitute its final value *) +val is_guarded: lambda -> bool +val patch_guarded : lambda -> lambda -> lambda +val raise_kind: raise_kind -> string +val lam_of_loc : loc_kind -> Location.t -> lambda +val merge_inline_attributes + : inline_attribute + -> inline_attribute + -> inline_attribute option +val reset: unit -> unit end = struct -#1 "string_hashtbl.ml" -# 9 "ext/hashtbl.cppo.ml" -type key = string -type 'a t = (key, 'a) Hashtbl_gen.t -let key_index (h : _ t ) (key : key) = - (Bs_hash_stubs.hash_string key ) land (Array.length h.data - 1) -let eq_key = Ext_string.equal +#1 "lambda.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -# 33 "ext/hashtbl.cppo.ml" -type ('a, 'b) bucketlist = ('a,'b) Hashtbl_gen.bucketlist -let create = Hashtbl_gen.create -let clear = Hashtbl_gen.clear -let reset = Hashtbl_gen.reset -let copy = Hashtbl_gen.copy -let iter = Hashtbl_gen.iter -let to_list = Hashtbl_gen.to_list -let fold = Hashtbl_gen.fold -let length = Hashtbl_gen.length -let stats = Hashtbl_gen.stats +open Misc +open Path +open Asttypes +type compile_time_constant = + | Big_endian + | Word_size + | Int_size + | Max_wosize + | Ostype_unix + | Ostype_win32 + | Ostype_cygwin + | Backend_type +type loc_kind = + | Loc_FILE + | Loc_LINE + | Loc_MODULE + | Loc_LOC + | Loc_POS -let add (h : _ t) key info = - let i = key_index h key in - let h_data = h.data in - Array.unsafe_set h_data i (Cons(key, info, (Array.unsafe_get h_data i))); - h.size <- h.size + 1; - if h.size > Array.length h_data lsl 1 then Hashtbl_gen.resize key_index h +type tag_info = + | Blk_constructor of string * int (* Number of non-const constructors*) + | Blk_tuple + | Blk_array + | Blk_variant of string + | Blk_record of string array (* when its empty means we dont get such information *) + | Blk_module of string list + | Blk_module_export of Ident.t list + | Blk_extension_slot + | Blk_extension + | Blk_na of string + | Blk_some + | Blk_some_not_nested (* ['a option] where ['a] can not inhabit a non-like value *) + | Blk_record_inlined of string array * string * int + | Blk_record_ext of string array + | Blk_lazy_general + | Blk_lazy_forward + | Blk_class (* Ocaml style class*) -(* after upgrade to 4.04 we should provide an efficient [replace_or_init] *) -let modify_or_init (h : _ t) key modf default = - let rec find_bucket (bucketlist : _ bucketlist) = - match bucketlist with - | Cons(k,i,next) -> - if eq_key k key then begin modf i; false end - else find_bucket next - | Empty -> true in - let i = key_index h key in - let h_data = h.data in - if find_bucket (Array.unsafe_get h_data i) then - begin - Array.unsafe_set h_data i (Cons(key,default (), Array.unsafe_get h_data i)); - h.size <- h.size + 1 ; - if h.size > Array.length h_data lsl 1 then Hashtbl_gen.resize key_index h - end +let default_tag_info : tag_info = Blk_na "" +let blk_record = ref (fun fields -> + let all_labels_info = fields |> Array.map (fun (x,_) -> x.Types.lbl_name) in + Blk_record all_labels_info + ) +let blk_record_ext = ref (fun fields -> + let all_labels_info = fields |> Array.map (fun (x,_) -> x.Types.lbl_name) in + Blk_record_ext all_labels_info + ) -let rec remove_bucket key (h : _ t) (bucketlist : _ bucketlist) : _ bucketlist = - match bucketlist with - | Empty -> - Empty - | Cons(k, i, next) -> - if eq_key k key - then begin h.size <- h.size - 1; next end - else Cons(k, i, remove_bucket key h next) +let blk_record_inlined = ref (fun fields name num_nonconsts -> + let all_labels_info = fields |> Array.map (fun (x,_) -> x.Types.lbl_name) in + Blk_record_inlined (all_labels_info, name, num_nonconsts) +) -let remove (h : _ t ) key = - let i = key_index h key in - let h_data = h.data in - let old_h_szie = h.size in - let new_bucket = remove_bucket key h (Array.unsafe_get h_data i) in - if old_h_szie <> h.size then - Array.unsafe_set h_data i new_bucket +let ref_tag_info : tag_info = Blk_record [| "contents" |] + +type field_dbg_info = + | Fld_na + | Fld_record of {name : string; mutable_flag : Asttypes.mutable_flag} + | Fld_module of string + | Fld_record_inline of string + | Fld_record_extension of string + | Fld_tuple -let rec find_rec key (bucketlist : _ bucketlist) = match bucketlist with - | Empty -> - raise Not_found - | Cons(k, d, rest) -> - if eq_key key k then d else find_rec key rest +let fld_record = ref (fun (lbl : Types.label_description) -> + Fld_record {name = lbl.lbl_name; mutable_flag = Mutable}) -let find_exn (h : _ t) key = - match Array.unsafe_get h.data (key_index h key) with - | Empty -> raise Not_found - | Cons(k1, d1, rest1) -> - if eq_key key k1 then d1 else - match rest1 with - | Empty -> raise Not_found - | Cons(k2, d2, rest2) -> - if eq_key key k2 then d2 else - match rest2 with - | Empty -> raise Not_found - | Cons(k3, d3, rest3) -> - if eq_key key k3 then d3 else find_rec key rest3 +let ref_field_info : field_dbg_info = + Fld_record { name = "contents"; mutable_flag = Mutable} -let find_opt (h : _ t) key = - Hashtbl_gen.small_bucket_opt eq_key key (Array.unsafe_get h.data (key_index h key)) +type set_field_dbg_info = + | Fld_set_na + | Fld_record_set of string + | Fld_record_inline_set of string + | Fld_record_extension_set of string -let find_key_opt (h : _ t) key = - Hashtbl_gen.small_bucket_key_opt eq_key key (Array.unsafe_get h.data (key_index h key)) - -let find_default (h : _ t) key default = - Hashtbl_gen.small_bucket_default eq_key key default (Array.unsafe_get h.data (key_index h key)) -let find_all (h : _ t) key = - let rec find_in_bucket (bucketlist : _ bucketlist) = match bucketlist with - | Empty -> - [] - | Cons(k, d, rest) -> - if eq_key k key - then d :: find_in_bucket rest - else find_in_bucket rest in - find_in_bucket (Array.unsafe_get h.data (key_index h key)) +let ref_field_set_info : set_field_dbg_info = Fld_record_set "contents" +let fld_record_set = ref ( fun (lbl : Types.label_description) -> + Fld_record_set lbl.lbl_name ) -let replace h key info = - let rec replace_bucket (bucketlist : _ bucketlist) : _ bucketlist = match bucketlist with - | Empty -> - raise_notrace Not_found - | Cons(k, i, next) -> - if eq_key k key - then Cons(key, info, next) - else Cons(k, i, replace_bucket next) in - let i = key_index h key in - let h_data = h.data in - let l = Array.unsafe_get h_data i in - try - Array.unsafe_set h_data i (replace_bucket l) - with Not_found -> - begin - Array.unsafe_set h_data i (Cons(key, info, l)); - h.size <- h.size + 1; - if h.size > Array.length h_data lsl 1 then Hashtbl_gen.resize key_index h; - end +type immediate_or_pointer = + | Immediate + | Pointer -let mem (h : _ t) key = - let rec mem_in_bucket (bucketlist : _ bucketlist) = match bucketlist with - | Empty -> - false - | Cons(k, d, rest) -> - eq_key k key || mem_in_bucket rest in - mem_in_bucket (Array.unsafe_get h.data (key_index h key)) +type initialization_or_assignment = + | Assignment + | Heap_initialization + | Root_initialization +type is_safe = + | Safe + | Unsafe -let of_list2 ks vs = - let len = List.length ks in - let map = create len in - List.iter2 (fun k v -> add map k v) ks vs ; - map +type primitive = + | Pidentity + | Pbytes_to_string + | Pbytes_of_string + | Pignore + | Prevapply + | Pdirapply + | Ploc of loc_kind + (* Globals *) + | Pgetglobal of Ident.t + | Psetglobal of Ident.t + (* Operations on heap blocks *) + | Pmakeblock of int * tag_info * mutable_flag * block_shape + | Pfield of int * field_dbg_info + | Pfield_computed + | Psetfield of int * immediate_or_pointer * initialization_or_assignment * set_field_dbg_info + | Psetfield_computed of immediate_or_pointer * initialization_or_assignment + | Pfloatfield of int * field_dbg_info + | Psetfloatfield of int * initialization_or_assignment * set_field_dbg_info + | Pduprecord of Types.record_representation * int + (* Force lazy values *) + | Plazyforce + (* External call *) + | Pccall of Primitive.description + (* Exceptions *) + | Praise of raise_kind + (* Boolean operations *) + | Psequand | Psequor | Pnot + (* Integer operations *) + | Pnegint | Paddint | Psubint | Pmulint + | Pdivint of is_safe | Pmodint of is_safe + | Pandint | Porint | Pxorint + | Plslint | Plsrint | Pasrint + | Pintcomp of comparison + | Poffsetint of int + | Poffsetref of int + (* Float operations *) + | Pintoffloat | Pfloatofint + | Pnegfloat | Pabsfloat + | Paddfloat | Psubfloat | Pmulfloat | Pdivfloat + | Pfloatcomp of comparison + (* String operations *) + | Pstringlength | Pstringrefu | Pstringrefs + | Pbyteslength | Pbytesrefu | Pbytessetu | Pbytesrefs | Pbytessets + (* Array operations *) + | Pmakearray of array_kind * mutable_flag + | Pduparray of array_kind * mutable_flag + | Parraylength of array_kind + | Parrayrefu of array_kind + | Parraysetu of array_kind + | Parrayrefs of array_kind + | Parraysets of array_kind + (* Test if the argument is a block or an immediate integer *) + | Pisint + (* Test if the (integer) argument is outside an interval *) + | Pisout + (* Bitvect operations *) + | Pbittest + (* Operations on boxed integers (Nativeint.t, Int32.t, Int64.t) *) + | Pbintofint of boxed_integer + | Pintofbint of boxed_integer + | Pcvtbint of boxed_integer (*source*) * boxed_integer (*destination*) + | Pnegbint of boxed_integer + | Paddbint of boxed_integer + | Psubbint of boxed_integer + | Pmulbint of boxed_integer + | Pdivbint of { size : boxed_integer; is_safe : is_safe } + | Pmodbint of { size : boxed_integer; is_safe : is_safe } + | Pandbint of boxed_integer + | Porbint of boxed_integer + | Pxorbint of boxed_integer + | Plslbint of boxed_integer + | Plsrbint of boxed_integer + | Pasrbint of boxed_integer + | Pbintcomp of boxed_integer * comparison + (* Operations on big arrays: (unsafe, #dimensions, kind, layout) *) + | Pbigarrayref of bool * int * bigarray_kind * bigarray_layout + | Pbigarrayset of bool * int * bigarray_kind * bigarray_layout + (* size of the nth dimension of a big array *) + | Pbigarraydim of int + (* load/set 16,32,64 bits from a string: (unsafe)*) + | Pstring_load_16 of bool + | Pstring_load_32 of bool + | Pstring_load_64 of bool + | Pstring_set_16 of bool + | Pstring_set_32 of bool + | Pstring_set_64 of bool + (* load/set 16,32,64 bits from a + (char, int8_unsigned_elt, c_layout) Bigarray.Array1.t : (unsafe) *) + | Pbigstring_load_16 of bool + | Pbigstring_load_32 of bool + | Pbigstring_load_64 of bool + | Pbigstring_set_16 of bool + | Pbigstring_set_32 of bool + | Pbigstring_set_64 of bool + (* Compile time constants *) + | Pctconst of compile_time_constant + (* byte swap *) + | Pbswap16 + | Pbbswap of boxed_integer + (* Integer to external pointer *) + | Pint_as_pointer + (* Inhibition of optimisation *) + | Popaque + +and comparison = + Ceq | Cneq | Clt | Cgt | Cle | Cge +and value_kind = + Pgenval | Pfloatval | Pboxedintval of boxed_integer | Pintval -end -module Map_gen -= struct -#1 "map_gen.ml" -(***********************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. All rights reserved. This file is distributed *) -(* under the terms of the GNU Library General Public License, with *) -(* the special exception on linking described in file ../LICENSE. *) -(* *) -(***********************************************************************) -(** adapted from stdlib *) +and block_shape = + value_kind list option -type ('key,'a) t = - | Empty - | Node of ('key,'a) t * 'key * 'a * ('key,'a) t * int +and array_kind = + Pgenarray | Paddrarray | Pintarray | Pfloatarray -type ('key,'a) enumeration = - | End - | More of 'key * 'a * ('key,'a) t * ('key, 'a) enumeration +and boxed_integer = Primitive.boxed_integer = + Pnativeint | Pint32 | Pint64 -let rec cardinal_aux acc = function - | Empty -> acc - | Node (l,_,_,r, _) -> - cardinal_aux (cardinal_aux (acc + 1) r ) l +and bigarray_kind = + Pbigarray_unknown + | Pbigarray_float32 | Pbigarray_float64 + | Pbigarray_sint8 | Pbigarray_uint8 + | Pbigarray_sint16 | Pbigarray_uint16 + | Pbigarray_int32 | Pbigarray_int64 + | Pbigarray_caml_int | Pbigarray_native_int + | Pbigarray_complex32 | Pbigarray_complex64 -let cardinal s = cardinal_aux 0 s +and bigarray_layout = + Pbigarray_unknown_layout + | Pbigarray_c_layout + | Pbigarray_fortran_layout -let rec bindings_aux accu = function - | Empty -> accu - | Node(l, v, d, r, _) -> bindings_aux ((v, d) :: bindings_aux accu r) l +and raise_kind = + | Raise_regular + | Raise_reraise + | Raise_notrace -let bindings s = - bindings_aux [] s +type pointer_info = + | Pt_constructor of string + | Pt_variant of string + | Pt_module_alias + | Pt_builtin_boolean + | Pt_shape_none + | Pt_na +let default_pointer_info = Pt_na -let rec fill_array_aux (s : _ t) i arr : int = - match s with - | Empty -> i - | Node (l,k,v,r,_) -> - let inext = fill_array_aux l i arr in - Array.unsafe_set arr inext (k,v); - fill_array_aux r (inext + 1) arr +type structured_constant = + Const_base of constant + | Const_pointer of int * pointer_info + | Const_block of int * tag_info * structured_constant list + | Const_float_array of string list + | Const_immstring of string -let to_sorted_array (s : ('key,'a) t) : ('key * 'a ) array = - match s with - | Empty -> [||] - | Node(l,k,v,r,_) -> - let len = - cardinal_aux (cardinal_aux 1 r) l in - let arr = - Array.make len (k,v) in - ignore (fill_array_aux s 0 arr : int); - arr -let rec keys_aux accu = function - Empty -> accu - | Node(l, v, _, r, _) -> keys_aux (v :: keys_aux accu r) l -let keys s = keys_aux [] s +type inline_attribute = + | Always_inline (* [@inline] or [@inline always] *) + | Never_inline (* [@inline never] *) + | Unroll of int (* [@unroll x] *) + | Default_inline (* no [@inline] attribute *) +type specialise_attribute = + | Always_specialise (* [@specialise] or [@specialise always] *) + | Never_specialise (* [@specialise never] *) + | Default_specialise (* no [@specialise] attribute *) +type function_kind = Curried | Tupled -let rec cons_enum m e = - match m with - Empty -> e - | Node(l, v, d, r, _) -> cons_enum l (More(v, d, r, e)) +type let_kind = Strict | Alias | StrictOpt | Variable +type public_info = string option (* label name *) -let height = function - | Empty -> 0 - | Node(_,_,_,_,h) -> h +type meth_kind = Self | Public of public_info | Cached -let create l x d r = - let hl = height l and hr = height r in - Node(l, x, d, r, (if hl >= hr then hl + 1 else hr + 1)) +type shared_code = (int * int) list -let singleton x d = Node(Empty, x, d, Empty, 1) +type function_attribute = { + inline : inline_attribute; + specialise : specialise_attribute; + is_a_functor: bool; + stub: bool; +} +type switch_names = {consts: string array; blocks: string array} -let bal l x d r = - let hl = match l with Empty -> 0 | Node(_,_,_,_,h) -> h in - let hr = match r with Empty -> 0 | Node(_,_,_,_,h) -> h in - if hl > hr + 2 then begin - match l with - Empty -> invalid_arg "Map.bal" - | Node(ll, lv, ld, lr, _) -> - if height ll >= height lr then - create ll lv ld (create lr x d r) - else begin - match lr with - Empty -> invalid_arg "Map.bal" - | Node(lrl, lrv, lrd, lrr, _)-> - create (create ll lv ld lrl) lrv lrd (create lrr x d r) - end - end else if hr > hl + 2 then begin - match r with - Empty -> invalid_arg "Map.bal" - | Node(rl, rv, rd, rr, _) -> - if height rr >= height rl then - create (create l x d rl) rv rd rr - else begin - match rl with - Empty -> invalid_arg "Map.bal" - | Node(rll, rlv, rld, rlr, _) -> - create (create l x d rll) rlv rld (create rlr rv rd rr) - end - end else - Node(l, x, d, r, (if hl >= hr then hl + 1 else hr + 1)) +type lambda = + Lvar of Ident.t + | Lconst of structured_constant + | Lapply of lambda_apply + | Lfunction of lfunction + | Llet of let_kind * value_kind * Ident.t * lambda * lambda + | Lletrec of (Ident.t * lambda) list * lambda + | Lprim of primitive * lambda list * Location.t + | Lswitch of lambda * lambda_switch * Location.t + | Lstringswitch of + lambda * (string * lambda) list * lambda option * Location.t + | Lstaticraise of int * lambda list + | Lstaticcatch of lambda * (int * Ident.t list) * lambda + | Ltrywith of lambda * Ident.t * lambda + | Lifthenelse of lambda * lambda * lambda + | Lsequence of lambda * lambda + | Lwhile of lambda * lambda + | Lfor of Ident.t * lambda * lambda * direction_flag * lambda + | Lassign of Ident.t * lambda + | Lsend of meth_kind * lambda * lambda * lambda list * Location.t + | Levent of lambda * lambda_event + | Lifused of Ident.t * lambda -let empty = Empty +and lfunction = + { kind: function_kind; + params: Ident.t list; + body: lambda; + attr: function_attribute; (* specified with [@inline] attribute *) + loc: Location.t; } -let is_empty = function Empty -> true | _ -> false +and lambda_apply = + { ap_func : lambda; + ap_args : lambda list; + ap_loc : Location.t; + ap_should_be_tailcall : bool; + ap_inlined : inline_attribute; + ap_specialised : specialise_attribute; } -let rec min_binding_exn = function - Empty -> raise Not_found - | Node(Empty, x, d, r, _) -> (x, d) - | Node(l, x, d, r, _) -> min_binding_exn l +and lambda_switch = + { sw_numconsts: int; + sw_consts: (int * lambda) list; + sw_numblocks: int; + sw_blocks: (int * lambda) list; + sw_failaction : lambda option; + sw_names: switch_names option } -let choose = min_binding_exn +and lambda_event = + { lev_loc: Location.t; + lev_kind: lambda_event_kind; + lev_repr: int ref option; + lev_env: Env.summary } -let rec max_binding_exn = function - Empty -> raise Not_found - | Node(l, x, d, Empty, _) -> (x, d) - | Node(l, x, d, r, _) -> max_binding_exn r +and lambda_event_kind = + Lev_before + | Lev_after of Types.type_expr + | Lev_function + | Lev_pseudo + | Lev_module_definition of Ident.t -let rec remove_min_binding = function - Empty -> invalid_arg "Map.remove_min_elt" - | Node(Empty, x, d, r, _) -> r - | Node(l, x, d, r, _) -> bal (remove_min_binding l) x d r +type program = + { module_ident : Ident.t; + main_module_block_size : int; + required_globals : Ident.Set.t; + code : lambda } -let merge t1 t2 = - match (t1, t2) with - (Empty, t) -> t - | (t, Empty) -> t - | (_, _) -> - let (x, d) = min_binding_exn t2 in - bal t1 x d (remove_min_binding t2) +let const_unit = Const_pointer(0, default_pointer_info) +let lambda_assert_false = Lconst (Const_pointer(0, Pt_constructor "assert false")) -let rec iter x f = match x with - Empty -> () - | Node(l, v, d, r, _) -> - iter l f; f v d; iter r f -let rec map x f = match x with - Empty -> - Empty - | Node(l, v, d, r, h) -> - let l' = map l f in - let d' = f d in - let r' = map r f in - Node(l', v, d', r', h) +let lambda_unit = Lconst const_unit -let rec mapi x f = match x with - Empty -> - Empty - | Node(l, v, d, r, h) -> - let l' = mapi l f in - let d' = f v d in - let r' = mapi r f in - Node(l', v, d', r', h) +let default_function_attribute = { + inline = Default_inline; + specialise = Default_specialise; + is_a_functor = false; + stub = false; +} -let rec fold m accu f = - match m with - Empty -> accu - | Node(l, v, d, r, _) -> - fold r (f v d (fold l accu f)) f +let default_stub_attribute = + { default_function_attribute with stub = true } -let rec for_all x p = match x with - Empty -> true - | Node(l, v, d, r, _) -> p v d && for_all l p && for_all r p +(* Build sharing keys *) +(* + Those keys are later compared with Pervasives.compare. + For that reason, they should not include cycles. +*) -let rec exists x p = match x with - Empty -> false - | Node(l, v, d, r, _) -> p v d || exists l p || exists r p +exception Not_simple -(* Beware: those two functions assume that the added k is *strictly* - smaller (or bigger) than all the present keys in the tree; it - does not test for equality with the current min (or max) key. +let max_raw = 32 - Indeed, they are only used during the "join" operation which - respects this precondition. -*) +let make_key e = + let count = ref 0 (* Used for controling size *) + and make_key = Ident.make_key_generator () in + (* make_key is used for normalizing let-bound variables *) + let rec tr_rec env e = + incr count ; + if !count > max_raw then raise Not_simple ; (* Too big ! *) + match e with + | Lvar id -> + begin + try Ident.find_same id env + with Not_found -> e + end + | Lconst (Const_base (Const_string _)) -> + (* Mutable constants are not shared *) + raise Not_simple + | Lconst _ -> e + | Lapply ap -> + Lapply {ap with ap_func = tr_rec env ap.ap_func; + ap_args = tr_recs env ap.ap_args; + ap_loc = Location.none} + | Llet (Alias,_k,x,ex,e) -> (* Ignore aliases -> substitute *) + let ex = tr_rec env ex in + tr_rec (Ident.add x ex env) e + | Llet ((Strict | StrictOpt),_k,x,ex,Lvar v) when Ident.same v x -> + tr_rec env ex + | Llet (str,k,x,ex,e) -> + (* Because of side effects, keep other lets with normalized names *) + let ex = tr_rec env ex in + let y = make_key x in + Llet (str,k,y,ex,tr_rec (Ident.add x (Lvar y) env) e) + | Lprim (p,es,_) -> + Lprim (p,tr_recs env es, Location.none) + | Lswitch (e,sw,loc) -> + Lswitch (tr_rec env e,tr_sw env sw,loc) + | Lstringswitch (e,sw,d,_) -> + Lstringswitch + (tr_rec env e, + List.map (fun (s,e) -> s,tr_rec env e) sw, + tr_opt env d, + Location.none) + | Lstaticraise (i,es) -> + Lstaticraise (i,tr_recs env es) + | Lstaticcatch (e1,xs,e2) -> + Lstaticcatch (tr_rec env e1,xs,tr_rec env e2) + | Ltrywith (e1,x,e2) -> + Ltrywith (tr_rec env e1,x,tr_rec env e2) + | Lifthenelse (cond,ifso,ifnot) -> + Lifthenelse (tr_rec env cond,tr_rec env ifso,tr_rec env ifnot) + | Lsequence (e1,e2) -> + Lsequence (tr_rec env e1,tr_rec env e2) + | Lassign (x,e) -> + Lassign (x,tr_rec env e) + | Lsend (m,e1,e2,es,_loc) -> + Lsend (m,tr_rec env e1,tr_rec env e2,tr_recs env es,Location.none) + | Lifused (id,e) -> Lifused (id,tr_rec env e) + | Lletrec _|Lfunction _ + | Lfor _ | Lwhile _ +(* Beware: (PR#6412) the event argument to Levent + may include cyclic structure of type Type.typexpr *) + | Levent _ -> + raise Not_simple -let rec add_min_binding k v = function - | Empty -> singleton k v - | Node (l, x, d, r, h) -> - bal (add_min_binding k v l) x d r + and tr_recs env es = List.map (tr_rec env) es -let rec add_max_binding k v = function - | Empty -> singleton k v - | Node (l, x, d, r, h) -> - bal l x d (add_max_binding k v r) + and tr_sw env sw = + { sw with + sw_consts = List.map (fun (i,e) -> i,tr_rec env e) sw.sw_consts ; + sw_blocks = List.map (fun (i,e) -> i,tr_rec env e) sw.sw_blocks ; + sw_failaction = tr_opt env sw.sw_failaction ; } -(* Same as create and bal, but no assumptions are made on the - relative heights of l and r. *) + and tr_opt env = function + | None -> None + | Some e -> Some (tr_rec env e) in -let rec join l v d r = - match (l, r) with - (Empty, _) -> add_min_binding v d r - | (_, Empty) -> add_max_binding v d l - | (Node(ll, lv, ld, lr, lh), Node(rl, rv, rd, rr, rh)) -> - if lh > rh + 2 then bal ll lv ld (join lr v d r) else - if rh > lh + 2 then bal (join l v d rl) rv rd rr else - create l v d r + try + Some (tr_rec Ident.empty e) + with Not_simple -> None -(* Merge two trees l and r into one. - All elements of l must precede the elements of r. - No assumption on the heights of l and r. *) +(***************) -let concat t1 t2 = - match (t1, t2) with - (Empty, t) -> t - | (t, Empty) -> t - | (_, _) -> - let (x, d) = min_binding_exn t2 in - join t1 x d (remove_min_binding t2) +let name_lambda strict arg fn = + match arg with + Lvar id -> fn id + | _ -> let id = Ident.create "let" in Llet(strict, Pgenval, id, arg, fn id) -let concat_or_join t1 v d t2 = - match d with - | Some d -> join t1 v d t2 - | None -> concat t1 t2 +let name_lambda_list args fn = + let rec name_list names = function + [] -> fn (List.rev names) + | (Lvar _ as arg) :: rem -> + name_list (arg :: names) rem + | arg :: rem -> + let id = Ident.create "let" in + Llet(Strict, Pgenval, id, arg, name_list (Lvar id :: names) rem) in + name_list [] args -let rec filter x p = match x with - Empty -> Empty - | Node(l, v, d, r, _) -> - (* call [p] in the expected left-to-right order *) - let l' = filter l p in - let pvd = p v d in - let r' = filter r p in - if pvd then join l' v d r' else concat l' r' -let rec partition x p = match x with - Empty -> (Empty, Empty) - | Node(l, v, d, r, _) -> - (* call [p] in the expected left-to-right order *) - let (lt, lf) = partition l p in - let pvd = p v d in - let (rt, rf) = partition r p in - if pvd - then (join lt v d rt, concat lf rf) - else (concat lt rt, join lf v d rf) +let iter_opt f = function + | None -> () + | Some e -> f e -let compare compare_key cmp_val m1 m2 = - let rec compare_aux e1 e2 = - match (e1, e2) with - (End, End) -> 0 - | (End, _) -> -1 - | (_, End) -> 1 - | (More(v1, d1, r1, e1), More(v2, d2, r2, e2)) -> - let c = compare_key v1 v2 in - if c <> 0 then c else - let c = cmp_val d1 d2 in - if c <> 0 then c else - compare_aux (cons_enum r1 e1) (cons_enum r2 e2) - in compare_aux (cons_enum m1 End) (cons_enum m2 End) +let iter f = function + Lvar _ + | Lconst _ -> () + | Lapply{ap_func = fn; ap_args = args} -> + f fn; List.iter f args + | Lfunction{body} -> + f body + | Llet(_str, _k, _id, arg, body) -> + f arg; f body + | Lletrec(decl, body) -> + f body; + List.iter (fun (_id, exp) -> f exp) decl + | Lprim(_p, args, _loc) -> + List.iter f args + | Lswitch(arg, sw,_) -> + f arg; + List.iter (fun (_key, case) -> f case) sw.sw_consts; + List.iter (fun (_key, case) -> f case) sw.sw_blocks; + iter_opt f sw.sw_failaction + | Lstringswitch (arg,cases,default,_) -> + f arg ; + List.iter (fun (_,act) -> f act) cases ; + iter_opt f default + | Lstaticraise (_,args) -> + List.iter f args + | Lstaticcatch(e1, _, e2) -> + f e1; f e2 + | Ltrywith(e1, _, e2) -> + f e1; f e2 + | Lifthenelse(e1, e2, e3) -> + f e1; f e2; f e3 + | Lsequence(e1, e2) -> + f e1; f e2 + | Lwhile(e1, e2) -> + f e1; f e2 + | Lfor(_v, e1, e2, _dir, e3) -> + f e1; f e2; f e3 + | Lassign(_, e) -> + f e + | Lsend (_k, met, obj, args, _) -> + List.iter f (met::obj::args) + | Levent (lam, _evt) -> + f lam + | Lifused (_v, e) -> + f e -let equal compare_key cmp m1 m2 = - let rec equal_aux e1 e2 = - match (e1, e2) with - (End, End) -> true - | (End, _) -> false - | (_, End) -> false - | (More(v1, d1, r1, e1), More(v2, d2, r2, e2)) -> - compare_key v1 v2 = 0 && cmp d1 d2 && - equal_aux (cons_enum r1 e1) (cons_enum r2 e2) - in equal_aux (cons_enum m1 End) (cons_enum m2 End) +module IdentSet = Set.Make(Ident) + +let free_ids get l = + let fv = ref IdentSet.empty in + let rec free l = + iter free l; + fv := List.fold_right IdentSet.add (get l) !fv; + match l with + Lfunction{params} -> + List.iter (fun param -> fv := IdentSet.remove param !fv) params + | Llet(_str, _k, id, _arg, _body) -> + fv := IdentSet.remove id !fv + | Lletrec(decl, _body) -> + List.iter (fun (id, _exp) -> fv := IdentSet.remove id !fv) decl + | Lstaticcatch(_e1, (_,vars), _e2) -> + List.iter (fun id -> fv := IdentSet.remove id !fv) vars + | Ltrywith(_e1, exn, _e2) -> + fv := IdentSet.remove exn !fv + | Lfor(v, _e1, _e2, _dir, _e3) -> + fv := IdentSet.remove v !fv + | Lassign(id, _e) -> + fv := IdentSet.add id !fv + | Lvar _ | Lconst _ | Lapply _ + | Lprim _ | Lswitch _ | Lstringswitch _ | Lstaticraise _ + | Lifthenelse _ | Lsequence _ | Lwhile _ + | Lsend _ | Levent _ | Lifused _ -> () + in free l; !fv +let free_variables l = + free_ids (function Lvar id -> [id] | _ -> []) l - -module type S = - sig - type key - type +'a t - val empty: 'a t - val compare_key: key -> key -> int - val is_empty: 'a t -> bool - val mem: 'a t -> key -> bool - val to_sorted_array : - 'a t -> (key * 'a ) array - val add: 'a t -> key -> 'a -> 'a t - (** [add x y m] - If [x] was already bound in [m], its previous binding disappears. *) - val adjust: 'a t -> key -> ('a option-> 'a) -> 'a t - (** [adjust acc k replace ] if not exist [add (replace None ], otherwise - [add k v (replace (Some old))] - *) - val singleton: key -> 'a -> 'a t +let free_methods l = + free_ids (function Lsend(Self, Lvar meth, _, _, _) -> [meth] | _ -> []) l - val remove: 'a t -> key -> 'a t - (** [remove x m] returns a map containing the same bindings as - [m], except for [x] which is unbound in the returned map. *) +(* Check if an action has a "when" guard *) +let raise_count = ref 0 - val merge: - 'a t -> 'b t -> - (key -> 'a option -> 'b option -> 'c option) -> 'c t - (** [merge f m1 m2] computes a map whose keys is a subset of keys of [m1] - and of [m2]. The presence of each such binding, and the corresponding - value, is determined with the function [f]. - @since 3.12.0 - *) +let next_raise_count () = + incr raise_count ; + !raise_count - val disjoint_merge : 'a t -> 'a t -> 'a t - (* merge two maps, will raise if they have the same key *) - val compare: 'a t -> 'a t -> ('a -> 'a -> int) -> int - (** Total ordering between maps. The first argument is a total ordering - used to compare data associated with equal keys in the two maps. *) +let negative_raise_count = ref 0 - val equal: 'a t -> 'a t -> ('a -> 'a -> bool) -> bool +let next_negative_raise_count () = + decr negative_raise_count ; + !negative_raise_count - val iter: 'a t -> (key -> 'a -> unit) -> unit - (** [iter f m] applies [f] to all bindings in map [m]. - The bindings are passed to [f] in increasing order. *) +(* Anticipated staticraise, for guards *) +let staticfail = Lstaticraise (0,[]) - val fold: 'a t -> 'b -> (key -> 'a -> 'b -> 'b) -> 'b - (** [fold f m a] computes [(f kN dN ... (f k1 d1 a)...)], - where [k1 ... kN] are the keys of all bindings in [m] - (in increasing order) *) +let rec is_guarded = function + | Lifthenelse(_cond, _body, Lstaticraise (0,[])) -> true + | Llet(_str, _k, _id, _lam, body) -> is_guarded body + | Levent(lam, _ev) -> is_guarded lam + | _ -> false - val for_all: 'a t -> (key -> 'a -> bool) -> bool - (** [for_all p m] checks if all the bindings of the map. - order unspecified - *) +let rec patch_guarded patch = function + | Lifthenelse (cond, body, Lstaticraise (0,[])) -> + Lifthenelse (cond, body, patch) + | Llet(str, k, id, lam, body) -> + Llet (str, k, id, lam, patch_guarded patch body) + | Levent(lam, ev) -> + Levent (patch_guarded patch lam, ev) + | _ -> fatal_error "Lambda.patch_guarded" - val exists: 'a t -> (key -> 'a -> bool) -> bool - (** [exists p m] checks if at least one binding of the map - satisfy the predicate [p]. - order unspecified - *) +(* Translate an access path *) - val filter: 'a t -> (key -> 'a -> bool) -> 'a t - (** [filter p m] returns the map with all the bindings in [m] - that satisfy predicate [p]. - order unspecified - *) +let rec transl_normal_path = function + Pident id -> + if Ident.global id + then Lprim(Pgetglobal id, [], Location.none) + else Lvar id + | Pdot(p, s, pos) -> + Lprim(Pfield (pos, Fld_module s), [transl_normal_path p], Location.none) + | Papply _ -> + fatal_error "Lambda.transl_path" - val partition: 'a t -> (key -> 'a -> bool) -> 'a t * 'a t - (** [partition p m] returns a pair of maps [(m1, m2)], where - [m1] contains all the bindings of [s] that satisfy the - predicate [p], and [m2] is the map with all the bindings of - [s] that do not satisfy [p]. - *) +(* Translation of identifiers *) - val cardinal: 'a t -> int - (** Return the number of bindings of a map. *) +let transl_module_path ?(loc=Location.none) env path = + transl_normal_path (Env.normalize_path (Some loc) env path) - val bindings: 'a t -> (key * 'a) list - (** Return the list of all bindings of the given map. - The returned list is sorted in increasing order with respect - to the ordering *) - val keys : 'a t -> key list - (* Increasing order *) +let transl_value_path ?(loc=Location.none) env path = + transl_normal_path (Env.normalize_path_prefix (Some loc) env path) - val min_binding_exn: 'a t -> (key * 'a) - (** raise [Not_found] if the map is empty. *) +let transl_class_path = transl_value_path +let transl_extension_path = transl_value_path - val max_binding_exn: 'a t -> (key * 'a) - (** Same as {!Map.S.min_binding} *) +(* compatibility alias, deprecated in the .mli *) +let transl_path = transl_value_path - val choose: 'a t -> (key * 'a) - (** Return one binding of the given map, or raise [Not_found] if - the map is empty. Which binding is chosen is unspecified, - but equal bindings will be chosen for equal maps. - *) +(* Compile a sequence of expressions *) - val split: 'a t -> key -> 'a t * 'a option * 'a t - (** [split x m] returns a triple [(l, data, r)], where - [l] is the map with all the bindings of [m] whose key - is strictly less than [x]; - [r] is the map with all the bindings of [m] whose key - is strictly greater than [x]; - [data] is [None] if [m] contains no binding for [x], - or [Some v] if [m] binds [v] to [x]. - @since 3.12.0 - *) +let rec make_sequence fn = function + [] -> lambda_unit + | [x] -> fn x + | x::rem -> + let lam = fn x in Lsequence(lam, make_sequence fn rem) - val find_exn: 'a t -> key -> 'a - (** [find x m] returns the current binding of [x] in [m], - or raises [Not_found] if no such binding exists. *) - val find_opt: 'a t -> key ->'a option - val find_default: 'a t -> key -> 'a -> 'a - val map: 'a t -> ('a -> 'b) -> 'b t - (** [map f m] returns a map with same domain as [m], where the - associated value [a] of all bindings of [m] has been - replaced by the result of the application of [f] to [a]. - The bindings are passed to [f] in increasing order - with respect to the ordering over the type of the keys. *) +(* Apply a substitution to a lambda-term. + Assumes that the bound variables of the lambda-term do not + belong to the domain of the substitution. + Assumes that the image of the substitution is out of reach + of the bound variables of the lambda-term (no capture). *) - val mapi: 'a t -> (key -> 'a -> 'b) -> 'b t - (** Same as {!Map.S.map}, but the function receives as arguments both the - key and the associated value for each binding of the map. *) +let subst_lambda s lam = + let rec subst = function + Lvar id as l -> + begin try Ident.find_same id s with Not_found -> l end + | Lconst _ as l -> l + | Lapply ap -> + Lapply{ap with ap_func = subst ap.ap_func; + ap_args = List.map subst ap.ap_args} + | Lfunction{kind; params; body; attr; loc} -> + Lfunction{kind; params; body = subst body; attr; loc} + | Llet(str, k, id, arg, body) -> Llet(str, k, id, subst arg, subst body) + | Lletrec(decl, body) -> Lletrec(List.map subst_decl decl, subst body) + | Lprim(p, args, loc) -> Lprim(p, List.map subst args, loc) + | Lswitch(arg, sw, loc) -> + Lswitch(subst arg, + {sw with sw_consts = List.map subst_case sw.sw_consts; + sw_blocks = List.map subst_case sw.sw_blocks; + sw_failaction = subst_opt sw.sw_failaction; }, + loc) + | Lstringswitch (arg,cases,default,loc) -> + Lstringswitch + (subst arg,List.map subst_strcase cases,subst_opt default,loc) + | Lstaticraise (i,args) -> Lstaticraise (i, List.map subst args) + | Lstaticcatch(e1, io, e2) -> Lstaticcatch(subst e1, io, subst e2) + | Ltrywith(e1, exn, e2) -> Ltrywith(subst e1, exn, subst e2) + | Lifthenelse(e1, e2, e3) -> Lifthenelse(subst e1, subst e2, subst e3) + | Lsequence(e1, e2) -> Lsequence(subst e1, subst e2) + | Lwhile(e1, e2) -> Lwhile(subst e1, subst e2) + | Lfor(v, e1, e2, dir, e3) -> Lfor(v, subst e1, subst e2, dir, subst e3) + | Lassign(id, e) -> Lassign(id, subst e) + | Lsend (k, met, obj, args, loc) -> + Lsend (k, subst met, subst obj, List.map subst args, loc) + | Levent (lam, evt) -> Levent (subst lam, evt) + | Lifused (v, e) -> Lifused (v, subst e) + and subst_decl (id, exp) = (id, subst exp) + and subst_case (key, case) = (key, subst case) + and subst_strcase (key, case) = (key, subst case) + and subst_opt = function + | None -> None + | Some e -> Some (subst e) + in subst lam - val of_list : (key * 'a) list -> 'a t - val of_array : (key * 'a ) array -> 'a t - val add_list : (key * 'b) list -> 'b t -> 'b t +let rec map f lam = + let lam = + match lam with + | Lvar _ -> lam + | Lconst _ -> lam + | Lapply { ap_func; ap_args; ap_loc; ap_should_be_tailcall; + ap_inlined; ap_specialised } -> + Lapply { + ap_func = map f ap_func; + ap_args = List.map (map f) ap_args; + ap_loc; + ap_should_be_tailcall; + ap_inlined; + ap_specialised; + } + | Lfunction { kind; params; body; attr; loc; } -> + Lfunction { kind; params; body = map f body; attr; loc; } + | Llet (str, k, v, e1, e2) -> + Llet (str, k, v, map f e1, map f e2) + | Lletrec (idel, e2) -> + Lletrec (List.map (fun (v, e) -> (v, map f e)) idel, map f e2) + | Lprim (p, el, loc) -> + Lprim (p, List.map (map f) el, loc) + | Lswitch (e, sw, loc) -> + Lswitch (map f e, + { sw_numconsts = sw.sw_numconsts; + sw_consts = List.map (fun (n, e) -> (n, map f e)) sw.sw_consts; + sw_numblocks = sw.sw_numblocks; + sw_blocks = List.map (fun (n, e) -> (n, map f e)) sw.sw_blocks; + sw_failaction = Misc.may_map (map f) sw.sw_failaction; + sw_names = sw.sw_names + }, + loc) + | Lstringswitch (e, sw, default, loc) -> + Lstringswitch ( + map f e, + List.map (fun (s, e) -> (s, map f e)) sw, + Misc.may_map (map f) default, + loc) + | Lstaticraise (i, args) -> + Lstaticraise (i, List.map (map f) args) + | Lstaticcatch (body, id, handler) -> + Lstaticcatch (map f body, id, map f handler) + | Ltrywith (e1, v, e2) -> + Ltrywith (map f e1, v, map f e2) + | Lifthenelse (e1, e2, e3) -> + Lifthenelse (map f e1, map f e2, map f e3) + | Lsequence (e1, e2) -> + Lsequence (map f e1, map f e2) + | Lwhile (e1, e2) -> + Lwhile (map f e1, map f e2) + | Lfor (v, e1, e2, dir, e3) -> + Lfor (v, map f e1, map f e2, dir, map f e3) + | Lassign (v, e) -> + Lassign (v, map f e) + | Lsend (k, m, o, el, loc) -> + Lsend (k, map f m, map f o, List.map (map f) el, loc) + | Levent (l, ev) -> + Levent (map f l, ev) + | Lifused (v, e) -> + Lifused (v, map f e) + in + f lam - end +(* To let-bind expressions to variables *) -end -module String_map : sig -#1 "string_map.mli" -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +let bind str var exp body = + match exp with + Lvar var' when Ident.same var var' -> body + | _ -> Llet(str, Pgenval, var, exp, body) +and commute_comparison = function +| Ceq -> Ceq| Cneq -> Cneq +| Clt -> Cgt | Cle -> Cge +| Cgt -> Clt | Cge -> Cle -include Map_gen.S with type key = string +and negate_comparison = function +| Ceq -> Cneq| Cneq -> Ceq +| Clt -> Cge | Cle -> Cgt +| Cgt -> Cle | Cge -> Clt -end = struct -#1 "string_map.ml" +let raise_kind = function + | Raise_regular -> "raise" + | Raise_reraise -> "reraise" + | Raise_notrace -> "raise_notrace" -# 2 "ext/map.cppo.ml" -(* we don't create [map_poly], since some operations require raise an exception which carries [key] *) +let lam_of_loc kind loc = + let loc_start = loc.Location.loc_start in + let (file, lnum, cnum) = Location.get_pos_info loc_start in + + let file = Filename.basename file in + let enum = loc.Location.loc_end.Lexing.pos_cnum - + loc_start.Lexing.pos_cnum + cnum in + match kind with + | Loc_POS -> + Lconst (Const_block (0, Blk_tuple, [ + Const_immstring file; + Const_base (Const_int lnum); + Const_base (Const_int cnum); + Const_base (Const_int enum); + ])) + | Loc_FILE -> Lconst (Const_immstring file) + | Loc_MODULE -> + let filename = Filename.basename file in + let name = Env.get_unit_name () in + let module_name = if name = "" then "//"^filename^"//" else name in + Lconst (Const_immstring module_name) + | Loc_LOC -> + let loc = Printf.sprintf "File %S, line %d, characters %d-%d" + file lnum cnum enum in + Lconst (Const_immstring loc) + | Loc_LINE -> Lconst (Const_base (Const_int lnum)) - -# 10 "ext/map.cppo.ml" - type key = string - let compare_key = Ext_string.compare +let merge_inline_attributes attr1 attr2 = + match attr1, attr2 with + | Default_inline, _ -> Some attr2 + | _, Default_inline -> Some attr1 + | _, _ -> + if attr1 = attr2 then Some attr1 + else None -# 22 "ext/map.cppo.ml" -type 'a t = (key,'a) Map_gen.t -exception Duplicate_key of key +let reset () = + raise_count := 0 -let empty = Map_gen.empty -let is_empty = Map_gen.is_empty -let iter = Map_gen.iter -let fold = Map_gen.fold -let for_all = Map_gen.for_all -let exists = Map_gen.exists -let singleton = Map_gen.singleton -let cardinal = Map_gen.cardinal -let bindings = Map_gen.bindings -let to_sorted_array = Map_gen.to_sorted_array -let keys = Map_gen.keys -let choose = Map_gen.choose -let partition = Map_gen.partition -let filter = Map_gen.filter -let map = Map_gen.map -let mapi = Map_gen.mapi -let bal = Map_gen.bal -let height = Map_gen.height -let max_binding_exn = Map_gen.max_binding_exn -let min_binding_exn = Map_gen.min_binding_exn +end +module Parser : sig +#1 "parser.mli" +type token = + | AMPERAMPER + | AMPERSAND + | AND + | AS + | ASSERT + | BACKQUOTE + | BANG + | BAR + | BARBAR + | BARRBRACKET + | BEGIN + | CHAR of (char) + | CLASS + | COLON + | COLONCOLON + | COLONEQUAL + | COLONGREATER + | COMMA + | CONSTRAINT + | DO + | DONE + | DOT + | DOTDOT + | DOWNTO + | ELSE + | END + | EOF + | EQUAL + | EXCEPTION + | EXTERNAL + | FALSE + | FLOAT of (string * char option) + | FOR + | FUN + | FUNCTION + | FUNCTOR + | GREATER + | GREATERRBRACE + | GREATERRBRACKET + | IF + | IN + | INCLUDE + | INFIXOP0 of (string) + | INFIXOP1 of (string) + | INFIXOP2 of (string) + | INFIXOP3 of (string) + | INFIXOP4 of (string) + | DOTOP of (string) + | INHERIT + | INITIALIZER + | INT of (string * char option) + | LABEL of (string) + | LAZY + | LBRACE + | LBRACELESS + | LBRACKET + | LBRACKETBAR + | LBRACKETLESS + | LBRACKETGREATER + | LBRACKETPERCENT + | LBRACKETPERCENTPERCENT + | LESS + | LESSMINUS + | LET + | LIDENT of (string) + | LPAREN + | LBRACKETAT + | LBRACKETATAT + | LBRACKETATATAT + | MATCH + | METHOD + | MINUS + | MINUSDOT + | MINUSGREATER + | MODULE + | MUTABLE + | NEW + | NONREC + | OBJECT + | OF + | OPEN + | OPTLABEL of (string) + | OR + | PERCENT + | PLUS + | PLUSDOT + | PLUSEQ + | PREFIXOP of (string) + | PRIVATE + | QUESTION + | QUOTE + | RBRACE + | RBRACKET + | REC + | RPAREN + | SEMI + | SEMISEMI + | HASH + | HASHOP of (string) + | SIG + | STAR + | STRING of (string * string option) + | STRUCT + | THEN + | TILDE + | TO + | TRUE + | TRY + | TYPE + | UIDENT of (string) + | UNDERSCORE + | VAL + | VIRTUAL + | WHEN + | WHILE + | WITH + | COMMENT of (string * Location.t) + | DOCSTRING of (Docstrings.docstring) + | EOL +val implementation : + (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Parsetree.structure +val interface : + (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Parsetree.signature +val toplevel_phrase : + (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Parsetree.toplevel_phrase +val use_file : + (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Parsetree.toplevel_phrase list +val parse_core_type : + (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Parsetree.core_type +val parse_expression : + (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Parsetree.expression +val parse_pattern : + (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Parsetree.pattern -let rec add (tree : _ Map_gen.t as 'a) x data : 'a = match tree with - | Empty -> - Node(Empty, x, data, Empty, 1) - | Node(l, v, d, r, h) -> - let c = compare_key x v in - if c = 0 then - Node(l, x, data, r, h) - else if c < 0 then - bal (add l x data ) v d r - else - bal l v d (add r x data ) +end = struct +#1 "parser.ml" +type token = + | AMPERAMPER + | AMPERSAND + | AND + | AS + | ASSERT + | BACKQUOTE + | BANG + | BAR + | BARBAR + | BARRBRACKET + | BEGIN + | CHAR of (char) + | CLASS + | COLON + | COLONCOLON + | COLONEQUAL + | COLONGREATER + | COMMA + | CONSTRAINT + | DO + | DONE + | DOT + | DOTDOT + | DOWNTO + | ELSE + | END + | EOF + | EQUAL + | EXCEPTION + | EXTERNAL + | FALSE + | FLOAT of (string * char option) + | FOR + | FUN + | FUNCTION + | FUNCTOR + | GREATER + | GREATERRBRACE + | GREATERRBRACKET + | IF + | IN + | INCLUDE + | INFIXOP0 of (string) + | INFIXOP1 of (string) + | INFIXOP2 of (string) + | INFIXOP3 of (string) + | INFIXOP4 of (string) + | DOTOP of (string) + | INHERIT + | INITIALIZER + | INT of (string * char option) + | LABEL of (string) + | LAZY + | LBRACE + | LBRACELESS + | LBRACKET + | LBRACKETBAR + | LBRACKETLESS + | LBRACKETGREATER + | LBRACKETPERCENT + | LBRACKETPERCENTPERCENT + | LESS + | LESSMINUS + | LET + | LIDENT of (string) + | LPAREN + | LBRACKETAT + | LBRACKETATAT + | LBRACKETATATAT + | MATCH + | METHOD + | MINUS + | MINUSDOT + | MINUSGREATER + | MODULE + | MUTABLE + | NEW + | NONREC + | OBJECT + | OF + | OPEN + | OPTLABEL of (string) + | OR + | PERCENT + | PLUS + | PLUSDOT + | PLUSEQ + | PREFIXOP of (string) + | PRIVATE + | QUESTION + | QUOTE + | RBRACE + | RBRACKET + | REC + | RPAREN + | SEMI + | SEMISEMI + | HASH + | HASHOP of (string) + | SIG + | STAR + | STRING of (string * string option) + | STRUCT + | THEN + | TILDE + | TO + | TRUE + | TRY + | TYPE + | UIDENT of (string) + | UNDERSCORE + | VAL + | VIRTUAL + | WHEN + | WHILE + | WITH + | COMMENT of (string * Location.t) + | DOCSTRING of (Docstrings.docstring) + | EOL +open Parsing;; +let _ = parse_error;; +# 19 "parsing/parser.mly" +open Location +open Asttypes +open Longident +open Parsetree +open Ast_helper +open Docstrings -let rec adjust (tree : _ Map_gen.t as 'a) x replace : 'a = - match tree with - | Empty -> - Node(Empty, x, replace None, Empty, 1) - | Node(l, v, d, r, h) -> - let c = compare_key x v in - if c = 0 then - Node(l, x, replace (Some d) , r, h) - else if c < 0 then - bal (adjust l x replace ) v d r - else - bal l v d (adjust r x replace ) +let mktyp d = Typ.mk ~loc:(symbol_rloc()) d +let mkpat d = Pat.mk ~loc:(symbol_rloc()) d +let mkexp d = Exp.mk ~loc:(symbol_rloc()) d +let mkmty ?attrs d = Mty.mk ~loc:(symbol_rloc()) ?attrs d +let mksig d = Sig.mk ~loc:(symbol_rloc()) d +let mkmod ?attrs d = Mod.mk ~loc:(symbol_rloc()) ?attrs d +let mkstr d = Str.mk ~loc:(symbol_rloc()) d +let mkclass ?attrs d = Cl.mk ~loc:(symbol_rloc()) ?attrs d +let mkcty ?attrs d = Cty.mk ~loc:(symbol_rloc()) ?attrs d +let mkctf ?attrs ?docs d = + Ctf.mk ~loc:(symbol_rloc()) ?attrs ?docs d +let mkcf ?attrs ?docs d = + Cf.mk ~loc:(symbol_rloc()) ?attrs ?docs d +let mkrhs rhs pos = mkloc rhs (rhs_loc pos) -let rec find_exn (tree : _ Map_gen.t ) x = match tree with - | Empty -> - raise Not_found - | Node(l, v, d, r, _) -> - let c = compare_key x v in - if c = 0 then d - else find_exn (if c < 0 then l else r) x +let reloc_pat x = { x with ppat_loc = symbol_rloc () };; +let reloc_exp x = { x with pexp_loc = symbol_rloc () };; -let rec find_opt (tree : _ Map_gen.t ) x = match tree with - | Empty -> None - | Node(l, v, d, r, _) -> - let c = compare_key x v in - if c = 0 then Some d - else find_opt (if c < 0 then l else r) x +let mkoperator name pos = + let loc = rhs_loc pos in + Exp.mk ~loc (Pexp_ident(mkloc (Lident name) loc)) -let rec find_default (tree : _ Map_gen.t ) x default = match tree with - | Empty -> default - | Node(l, v, d, r, _) -> - let c = compare_key x v in - if c = 0 then d - else find_default (if c < 0 then l else r) x default +let mkpatvar name pos = + Pat.mk ~loc:(rhs_loc pos) (Ppat_var (mkrhs name pos)) -let rec mem (tree : _ Map_gen.t ) x= match tree with - | Empty -> - false - | Node(l, v, d, r, _) -> - let c = compare_key x v in - c = 0 || mem (if c < 0 then l else r) x +(* + Ghost expressions and patterns: + expressions and patterns that do not appear explicitly in the + source file they have the loc_ghost flag set to true. + Then the profiler will not try to instrument them and the + -annot option will not try to display their type. -let rec remove (tree : _ Map_gen.t as 'a) x : 'a = match tree with - | Empty -> - Empty - | Node(l, v, d, r, h) -> - let c = compare_key x v in - if c = 0 then - Map_gen.merge l r - else if c < 0 then - bal (remove l x) v d r - else - bal l v d (remove r x ) + Every grammar rule that generates an element with a location must + make at most one non-ghost element, the topmost one. + How to tell whether your location must be ghost: + A location corresponds to a range of characters in the source file. + If the location contains a piece of code that is syntactically + valid (according to the documentation), and corresponds to the + AST node, then the location must be real; in all other cases, + it must be ghost. +*) +let ghexp d = Exp.mk ~loc:(symbol_gloc ()) d +let ghpat d = Pat.mk ~loc:(symbol_gloc ()) d +let ghtyp d = Typ.mk ~loc:(symbol_gloc ()) d +let ghloc d = { txt = d; loc = symbol_gloc () } +let ghstr d = Str.mk ~loc:(symbol_gloc()) d +let ghsig d = Sig.mk ~loc:(symbol_gloc()) d -let rec split (tree : _ Map_gen.t as 'a) x : 'a * _ option * 'a = match tree with - | Empty -> - (Empty, None, Empty) - | Node(l, v, d, r, _) -> - let c = compare_key x v in - if c = 0 then (l, Some d, r) - else if c < 0 then - let (ll, pres, rl) = split l x in (ll, pres, Map_gen.join rl v d r) - else - let (lr, pres, rr) = split r x in (Map_gen.join l v d lr, pres, rr) +let mkinfix arg1 name arg2 = + mkexp(Pexp_apply(mkoperator name 2, [Nolabel, arg1; Nolabel, arg2])) -let rec merge (s1 : _ Map_gen.t) (s2 : _ Map_gen.t) f : _ Map_gen.t = - match (s1, s2) with - | (Empty, Empty) -> Empty - | (Node (l1, v1, d1, r1, h1), _) when h1 >= height s2 -> - let (l2, d2, r2) = split s2 v1 in - Map_gen.concat_or_join (merge l1 l2 f) v1 (f v1 (Some d1) d2) (merge r1 r2 f) - | (_, Node (l2, v2, d2, r2, h2)) -> - let (l1, d1, r1) = split s1 v2 in - Map_gen.concat_or_join (merge l1 l2 f) v2 (f v2 d1 (Some d2)) (merge r1 r2 f) - | _ -> - assert false +let neg_string f = + if String.length f > 0 && f.[0] = '-' + then String.sub f 1 (String.length f - 1) + else "-" ^ f -let rec disjoint_merge (s1 : _ Map_gen.t) (s2 : _ Map_gen.t) : _ Map_gen.t = - match (s1, s2) with - | (Empty, Empty) -> Empty - | (Node (l1, v1, d1, r1, h1), _) when h1 >= height s2 -> - begin match split s2 v1 with - | l2, None, r2 -> - Map_gen.join (disjoint_merge l1 l2) v1 d1 (disjoint_merge r1 r2) - | _, Some _, _ -> - raise (Duplicate_key v1) - end - | (_, Node (l2, v2, d2, r2, h2)) -> - begin match split s1 v2 with - | (l1, None, r1) -> - Map_gen.join (disjoint_merge l1 l2) v2 d2 (disjoint_merge r1 r2) - | (_, Some _, _) -> - raise (Duplicate_key v2) - end +let mkuminus name arg = + match name, arg.pexp_desc with + | "-", Pexp_constant(Pconst_integer (n,m)) -> + mkexp(Pexp_constant(Pconst_integer(neg_string n,m))) + | ("-" | "-."), Pexp_constant(Pconst_float (f, m)) -> + mkexp(Pexp_constant(Pconst_float(neg_string f, m))) | _ -> - assert false - - - -let compare m1 m2 cmp = Map_gen.compare compare_key cmp m1 m2 - -let equal m1 m2 cmp = Map_gen.equal compare_key cmp m1 m2 - -let add_list (xs : _ list ) init = - Ext_list.fold_left xs init (fun acc (k,v) -> add acc k v ) - -let of_list xs = add_list xs empty - -let of_array xs = - Ext_array.fold_left xs empty (fun acc (k,v) -> add acc k v ) - -end -module Ast_extract : sig -#1 "ast_extract.mli" -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) - - - - - - - + mkexp(Pexp_apply(mkoperator ("~" ^ name) 1, [Nolabel, arg])) +let mkuplus name arg = + let desc = arg.pexp_desc in + match name, desc with + | "+", Pexp_constant(Pconst_integer _) + | ("+" | "+."), Pexp_constant(Pconst_float _) -> mkexp desc + | _ -> + mkexp(Pexp_apply(mkoperator ("~" ^ name) 1, [Nolabel, arg])) -module String_set = Depend.StringSet +let mkexp_cons consloc args loc = + Exp.mk ~loc (Pexp_construct(mkloc (Lident "::") consloc, Some args)) -val read_parse_and_extract : 'a Ml_binary.kind -> 'a -> String_set.t +let mkpat_cons consloc args loc = + Pat.mk ~loc (Ppat_construct(mkloc (Lident "::") consloc, Some args)) -type ('a,'b) t +let rec mktailexp nilloc = function + [] -> + let loc = { nilloc with loc_ghost = true } in + let nil = { txt = Lident "[]"; loc = loc } in + Exp.mk ~loc (Pexp_construct (nil, None)) + | e1 :: el -> + let exp_el = mktailexp nilloc el in + let loc = {loc_start = e1.pexp_loc.loc_start; + loc_end = exp_el.pexp_loc.loc_end; + loc_ghost = true} + in + let arg = Exp.mk ~loc (Pexp_tuple [e1; exp_el]) in + mkexp_cons {loc with loc_ghost = true} arg loc -val sort_files_by_dependencies : - domain:String_set.t -> String_set.t String_map.t -> string Queue.t +let rec mktailpat nilloc = function + [] -> + let loc = { nilloc with loc_ghost = true } in + let nil = { txt = Lident "[]"; loc = loc } in + Pat.mk ~loc (Ppat_construct (nil, None)) + | p1 :: pl -> + let pat_pl = mktailpat nilloc pl in + let loc = {loc_start = p1.ppat_loc.loc_start; + loc_end = pat_pl.ppat_loc.loc_end; + loc_ghost = true} + in + let arg = Pat.mk ~loc (Ppat_tuple [p1; pat_pl]) in + mkpat_cons {loc with loc_ghost = true} arg loc +let mkstrexp e attrs = + { pstr_desc = Pstr_eval (e, attrs); pstr_loc = e.pexp_loc } -val sort : - ('a -> Parsetree.structure) -> - ('b -> Parsetree.signature) -> - ('a, 'b) t String_map.t -> string Queue.t +let mkexp_constraint e (t1, t2) = + match t1, t2 with + | Some t, None -> ghexp(Pexp_constraint(e, t)) + | _, Some t -> ghexp(Pexp_coerce(e, t1, t)) + | None, None -> assert false +let mkexp_opt_constraint e = function + | None -> e + | Some constraint_ -> mkexp_constraint e constraint_ +let mkpat_opt_constraint p = function + | None -> p + | Some typ -> mkpat (Ppat_constraint(p, typ)) -(** - [build fmt files parse_implementation parse_interface] - Given a list of files return an ast table -*) -val collect_ast_map : - Format.formatter -> - string list -> - (Format.formatter -> string -> 'a) -> - (Format.formatter -> string -> 'b) -> - ('a, 'b) t String_map.t +let array_function str name = + ghloc (Ldot(Lident str, (if !Clflags.fast then "unsafe_" ^ name else name))) -type dir_spec = - { dir : string ; - mutable excludes : string list - } +let syntax_error () = + raise Syntaxerr.Escape_error -(** If the genereated queue is empty, it means - 1. The main module does not exist (does not exist due to typo) - 2. It does exist but not in search path - The order matters from head to tail -*) -val collect_from_main : - ?extra_dirs:dir_spec list -> - ?excludes : string list -> - ?alias_map: string String_hashtbl.t -> - Format.formatter -> - (Format.formatter -> string -> 'a) -> - (Format.formatter -> string -> 'b) -> - ('a -> Parsetree.structure) -> - ('b -> Parsetree.signature) -> - string -> ('a, 'b) t String_map.t * string Queue.t +let unclosed opening_name opening_num closing_name closing_num = + raise(Syntaxerr.Error(Syntaxerr.Unclosed(rhs_loc opening_num, opening_name, + rhs_loc closing_num, closing_name))) -val build_queue : - Format.formatter -> - string Queue.t -> - ('b, 'c) t String_map.t -> - (Format.formatter -> string -> string -> 'b -> unit) -> - (Format.formatter -> string -> string -> 'c -> unit) -> unit - -val handle_queue : - Format.formatter -> - string Queue.t -> - ('a, 'b) t String_map.t -> - (string -> string -> 'a -> unit) -> - (string -> string -> 'b -> unit) -> - (string -> string -> string -> 'b -> 'a -> unit) -> unit +let expecting pos nonterm = + raise Syntaxerr.(Error(Expecting(rhs_loc pos, nonterm))) +let not_expecting pos nonterm = + raise Syntaxerr.(Error(Not_expecting(rhs_loc pos, nonterm))) -val build_lazy_queue : - Format.formatter -> - string Queue.t -> - (Parsetree.structure lazy_t, Parsetree.signature lazy_t) t String_map.t -> - (Format.formatter -> string -> string -> Parsetree.structure -> unit) -> - (Format.formatter -> string -> string -> Parsetree.signature -> unit) -> unit +let bigarray_function str name = + ghloc (Ldot(Ldot(Lident "Bigarray", str), name)) +let bigarray_untuplify = function + { pexp_desc = Pexp_tuple explist; pexp_loc = _ } -> explist + | exp -> [exp] +let bigarray_get arr arg = + let get = if !Clflags.fast then "unsafe_get" else "get" in + match bigarray_untuplify arg with + [c1] -> + mkexp(Pexp_apply(ghexp(Pexp_ident(bigarray_function "Array1" get)), + [Nolabel, arr; Nolabel, c1])) + | [c1;c2] -> + mkexp(Pexp_apply(ghexp(Pexp_ident(bigarray_function "Array2" get)), + [Nolabel, arr; Nolabel, c1; Nolabel, c2])) + | [c1;c2;c3] -> + mkexp(Pexp_apply(ghexp(Pexp_ident(bigarray_function "Array3" get)), + [Nolabel, arr; Nolabel, c1; Nolabel, c2; Nolabel, c3])) + | coords -> + mkexp(Pexp_apply(ghexp(Pexp_ident(bigarray_function "Genarray" "get")), + [Nolabel, arr; Nolabel, ghexp(Pexp_array coords)])) -end = struct -#1 "ast_extract.ml" -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +let bigarray_set arr arg newval = + let set = if !Clflags.fast then "unsafe_set" else "set" in + match bigarray_untuplify arg with + [c1] -> + mkexp(Pexp_apply(ghexp(Pexp_ident(bigarray_function "Array1" set)), + [Nolabel, arr; Nolabel, c1; Nolabel, newval])) + | [c1;c2] -> + mkexp(Pexp_apply(ghexp(Pexp_ident(bigarray_function "Array2" set)), + [Nolabel, arr; Nolabel, c1; + Nolabel, c2; Nolabel, newval])) + | [c1;c2;c3] -> + mkexp(Pexp_apply(ghexp(Pexp_ident(bigarray_function "Array3" set)), + [Nolabel, arr; Nolabel, c1; + Nolabel, c2; Nolabel, c3; Nolabel, newval])) + | coords -> + mkexp(Pexp_apply(ghexp(Pexp_ident(bigarray_function "Genarray" "set")), + [Nolabel, arr; + Nolabel, ghexp(Pexp_array coords); + Nolabel, newval])) -type module_name = private string +let lapply p1 p2 = + if !Clflags.applicative_functors + then Lapply(p1, p2) + else raise (Syntaxerr.Error(Syntaxerr.Applicative_path (symbol_rloc()))) -module String_set = Depend.StringSet +let exp_of_label lbl pos = + mkexp (Pexp_ident(mkrhs (Lident(Longident.last lbl)) pos)) -(* FIXME: [Clflags.open_modules] seems not to be properly used *) - -module SMap = Depend.StringMap -let bound_vars = SMap.empty +let pat_of_label lbl pos = + mkpat (Ppat_var (mkrhs (Longident.last lbl) pos)) +let mk_newtypes newtypes exp = + List.fold_right (fun newtype exp -> mkexp (Pexp_newtype (newtype, exp))) + newtypes exp -type 'a kind = 'a Ml_binary.kind +let wrap_type_annotation newtypes core_type body = + let exp = mkexp(Pexp_constraint(body,core_type)) in + let exp = mk_newtypes newtypes exp in + (exp, ghtyp(Ptyp_poly(newtypes, Typ.varify_constructors newtypes core_type))) +let wrap_exp_attrs body (ext, attrs) = + (* todo: keep exact location for the entire attribute *) + let body = {body with pexp_attributes = attrs @ body.pexp_attributes} in + match ext with + | None -> body + | Some id -> ghexp(Pexp_extension (id, PStr [mkstrexp body []])) -let read_parse_and_extract (type t) (k : t kind) (ast : t) : String_set.t = - Depend.free_structure_names := String_set.empty; - Ext_ref.protect Clflags.transparent_modules false begin fun _ -> - List.iter (* check *) - (fun modname -> +let mkexp_attrs d attrs = + wrap_exp_attrs (mkexp d) attrs - ignore @@ - - Depend.open_module bound_vars (Longident.Lident modname)) - (!Clflags.open_modules); - (match k with - | Ml_binary.Ml -> Depend.add_implementation bound_vars ast - | Ml_binary.Mli -> Depend.add_signature bound_vars ast ); - !Depend.free_structure_names - end +let wrap_typ_attrs typ (ext, attrs) = + (* todo: keep exact location for the entire attribute *) + let typ = {typ with ptyp_attributes = attrs @ typ.ptyp_attributes} in + match ext with + | None -> typ + | Some id -> ghtyp(Ptyp_extension (id, PTyp typ)) -type ('a,'b) ast_info = - | Ml of - string * (* sourcefile *) - 'a * - string (* opref *) - | Mli of string * (* sourcefile *) - 'b * - string (* opref *) - | Ml_mli of - string * (* sourcefile *) - 'a * - string * (* opref1 *) - string * (* sourcefile *) - 'b * - string (* opref2*) +let mktyp_attrs d attrs = + wrap_typ_attrs (mktyp d) attrs -type ('a,'b) t = - { module_name : string ; ast_info : ('a,'b) ast_info } +let wrap_pat_attrs pat (ext, attrs) = + (* todo: keep exact location for the entire attribute *) + let pat = {pat with ppat_attributes = attrs @ pat.ppat_attributes} in + match ext with + | None -> pat + | Some id -> ghpat(Ppat_extension (id, PPat (pat, None))) +let mkpat_attrs d attrs = + wrap_pat_attrs (mkpat d) attrs -(* only visit nodes that are currently in the domain *) -(* https://en.wikipedia.org/wiki/Topological_sorting *) -(* dfs *) -let sort_files_by_dependencies ~(domain : String_set.t) (dependency_graph : String_set.t String_map.t) : - string Queue.t = - let next current = - String_map.find_exn dependency_graph current in - let worklist = ref domain in - let result = Queue.create () in - let rec visit (visiting : String_set.t) path (current : string) = - let next_path = current :: path in - if String_set.mem current visiting then - Bs_exception.error (Bs_cyclic_depends next_path) - else if String_set.mem current !worklist then - begin - let next_set = String_set.add current visiting in - next current |> - String_set.iter - (fun node -> - if String_map.mem dependency_graph node then - visit next_set next_path node) - ; - worklist := String_set.remove current !worklist; - Queue.push current result ; - end in - while not (String_set.is_empty !worklist) do - visit String_set.empty [] (String_set.choose !worklist) - done; - if Js_config.get_diagnose () then - Format.fprintf Format.err_formatter - "Order: @[%a@]@." - (Ext_format.pp_print_queue - ~pp_sep:Format.pp_print_space - Format.pp_print_string) - result ; - result -;; +let wrap_class_attrs body attrs = + {body with pcl_attributes = attrs @ body.pcl_attributes} +let wrap_class_type_attrs body attrs = + {body with pcty_attributes = attrs @ body.pcty_attributes} +let wrap_mod_attrs body attrs = + {body with pmod_attributes = attrs @ body.pmod_attributes} +let wrap_mty_attrs body attrs = + {body with pmty_attributes = attrs @ body.pmty_attributes} +let wrap_str_ext body ext = + match ext with + | None -> body + | Some id -> ghstr(Pstr_extension ((id, PStr [body]), [])) +let mkstr_ext d ext = + wrap_str_ext (mkstr d) ext -let sort project_ml project_mli (ast_table : _ t String_map.t) = - let domain = - String_map.fold ast_table String_set.empty - (fun k _ acc -> String_set.add k acc) - in - let h = - String_map.map ast_table - (fun - ({ast_info}) - -> - match ast_info with - | Ml (_, ast, _) - -> - read_parse_and_extract Ml (project_ml ast) - | Mli (_, ast, _) - -> - read_parse_and_extract Mli (project_mli ast) - | Ml_mli (_, impl, _, _, intf, _) - -> - String_set.union - (read_parse_and_extract Ml (project_ml impl)) - (read_parse_and_extract Mli (project_mli intf)) - ) in - sort_files_by_dependencies ~domain h +let wrap_sig_ext body ext = + match ext with + | None -> body + | Some id -> ghsig(Psig_extension ((id, PSig [body]), [])) -(** same as {!Ocaml_parse.check_suffix} but does not care with [-c -o] option*) -let check_suffix name = - if Ext_path.check_suffix_case name ".ml" then - `Ml, - Ext_filename.chop_extension_maybe name - else if Ext_path.check_suffix_case name !Config.interface_suffix then - `Mli, Ext_filename.chop_extension_maybe name - else - raise(Arg.Bad("don't know what to do with " ^ name)) +let mksig_ext d ext = + wrap_sig_ext (mksig d) ext +let text_str pos = Str.text (rhs_text pos) +let text_sig pos = Sig.text (rhs_text pos) +let text_cstr pos = Cf.text (rhs_text pos) +let text_csig pos = Ctf.text (rhs_text pos) +let text_def pos = [Ptop_def (Str.text (rhs_text pos))] -let collect_ast_map ppf files parse_implementation parse_interface = - Ext_list.fold_left files String_map.empty - (fun acc source_file -> - match check_suffix source_file with - | `Ml, opref -> - let module_name = Ext_filename.module_name source_file in - begin match String_map.find_exn acc module_name with - | exception Not_found -> - String_map.add acc module_name - {ast_info = - (Ml (source_file, parse_implementation - ppf source_file, opref)); - module_name ; - } - | {ast_info = (Ml (source_file2, _, _) - | Ml_mli(source_file2, _, _,_,_,_))} -> - Bs_exception.error - (Bs_duplicated_module (source_file, source_file2)) - | {ast_info = Mli (source_file2, intf, opref2)} - -> - String_map.add acc module_name - {ast_info = - Ml_mli (source_file, - parse_implementation ppf source_file, - opref, - source_file2, - intf, - opref2 - ); - module_name} - end - | `Mli, opref -> - let module_name = Ext_filename.module_name source_file in - begin match String_map.find_exn acc module_name with - | exception Not_found -> - String_map.add acc module_name - {ast_info = (Mli (source_file, parse_interface - ppf source_file, opref)); - module_name } - | {ast_info = - (Mli (source_file2, _, _) | - Ml_mli(_,_,_,source_file2,_,_)) } -> - Bs_exception.error - (Bs_duplicated_module (source_file, source_file2)) - | {ast_info = Ml (source_file2, impl, opref2)} - -> - String_map.add acc module_name - {ast_info = - Ml_mli - (source_file2, - impl, - opref2, - source_file, - parse_interface ppf source_file, - opref - ); - module_name} - end - ) -;; -type dir_spec = - { dir : string ; - mutable excludes : string list - } +let extra_text text pos items = + let pre_extras = rhs_pre_extra_text pos in + let post_extras = rhs_post_extra_text pos in + text pre_extras @ items @ text post_extras -let collect_from_main - ?(extra_dirs=[]) - ?(excludes=[]) - ?alias_map - (ppf : Format.formatter) - parse_implementation - parse_interface - project_impl - project_intf - main_module = - let files = - Ext_list.fold_left extra_dirs [] (fun acc dir_spec -> - let dirname, excludes = - match dir_spec with - | { dir = dirname; excludes = dir_excludes} -> - (* dirname, excludes *) - (* | `Dir_with_excludes (dirname, dir_excludes) -> *) - dirname, - (Ext_list.flat_map_append - dir_excludes excludes - (fun x -> [x ^ ".ml" ; x ^ ".mli" ]) - ) - in - Ext_array.fold_left (Sys.readdir dirname) acc (fun acc source_file -> - if (Ext_string.ends_with source_file ".ml" || - Ext_string.ends_with source_file ".mli" ) - && (* not_excluded source_file *) (not (Ext_list.mem_string excludes source_file )) - then - (Filename.concat dirname source_file) :: acc else acc - ) ) - in - let ast_table = collect_ast_map ppf files parse_implementation parse_interface in - let visited = String_hashtbl.create 31 in - let result = Queue.create () in - let next module_name : String_set.t = - let module_set = - match String_map.find_exn ast_table module_name with - | exception _ -> String_set.empty - | {ast_info = Ml (_, impl, _)} -> - read_parse_and_extract Ml (project_impl impl) - | {ast_info = Mli (_, intf,_)} -> - read_parse_and_extract Mli (project_intf intf) - | {ast_info = Ml_mli(_, impl, _, _, intf, _)} - -> - String_set.union - (read_parse_and_extract Ml (project_impl impl)) - (read_parse_and_extract Mli (project_intf intf)) - in - match alias_map with - | None -> module_set - | Some map -> - String_set.fold (fun x acc -> String_set.add (String_hashtbl.find_default map x x) acc ) module_set String_set.empty - in - let rec visit visiting path current = - if String_set.mem current visiting then - Bs_exception.error (Bs_cyclic_depends (current::path)) - else - if not (String_hashtbl.mem visited current) - && String_map.mem ast_table current then - begin - String_set.iter - (visit - (String_set.add current visiting) - (current::path)) - (next current) ; - Queue.push current result; - String_hashtbl.add visited current (); - end in - visit (String_set.empty) [] main_module ; - ast_table, result +let extra_str pos items = extra_text Str.text pos items +let extra_sig pos items = extra_text Sig.text pos items +let extra_cstr pos items = extra_text Cf.text pos items +let extra_csig pos items = extra_text Ctf.text pos items +let extra_def pos items = + extra_text (fun txt -> [Ptop_def (Str.text txt)]) pos items +let extra_rhs_core_type ct ~pos = + let docs = rhs_info pos in + { ct with ptyp_attributes = add_info_attrs docs ct.ptyp_attributes } -let build_queue ppf queue - (ast_table : _ t String_map.t) - after_parsing_impl - after_parsing_sig - = - queue - |> Queue.iter - (fun modname -> - match String_map.find_exn ast_table modname with - | {ast_info = Ml(source_file,ast, opref)} - -> - after_parsing_impl ppf source_file - opref ast - | {ast_info = Mli (source_file,ast,opref) ; } - -> - after_parsing_sig ppf source_file - opref ast - | {ast_info = Ml_mli(source_file1,impl,opref1,source_file2,intf,opref2)} - -> - after_parsing_sig ppf source_file1 opref1 intf ; - after_parsing_impl ppf source_file2 opref2 impl - | exception Not_found -> assert false - ) +type let_binding = + { lb_pattern: pattern; + lb_expression: expression; + lb_attributes: attributes; + lb_docs: docs Lazy.t; + lb_text: text Lazy.t; + lb_loc: Location.t; } +type let_bindings = + { lbs_bindings: let_binding list; + lbs_rec: rec_flag; + lbs_extension: string Asttypes.loc option; + lbs_loc: Location.t } -let handle_queue - ppf - queue ast_table - decorate_module_only - decorate_interface_only - decorate_module = - queue - |> Queue.iter - (fun base -> - match (String_map.find_exn ast_table base ).ast_info with - | exception Not_found -> assert false - | Ml (ml_name, ml_content, _) - -> - decorate_module_only base ml_name ml_content - | Mli (mli_name , mli_content, _) -> - decorate_interface_only base mli_name mli_content - | Ml_mli (ml_name, ml_content, _, mli_name, mli_content, _) - -> - decorate_module base mli_name ml_name mli_content ml_content +let mklb first (p, e) attrs = + { lb_pattern = p; + lb_expression = e; + lb_attributes = attrs; + lb_docs = symbol_docs_lazy (); + lb_text = if first then empty_text_lazy + else symbol_text_lazy (); + lb_loc = symbol_rloc (); } - ) +let mklbs ext rf lb = + { lbs_bindings = [lb]; + lbs_rec = rf; + lbs_extension = ext ; + lbs_loc = symbol_rloc (); } +let addlb lbs lb = + { lbs with lbs_bindings = lb :: lbs.lbs_bindings } +let val_of_let_bindings lbs = + let bindings = + List.map + (fun lb -> + Vb.mk ~loc:lb.lb_loc ~attrs:lb.lb_attributes + ~docs:(Lazy.force lb.lb_docs) + ~text:(Lazy.force lb.lb_text) + lb.lb_pattern lb.lb_expression) + lbs.lbs_bindings + in + let str = mkstr(Pstr_value(lbs.lbs_rec, List.rev bindings)) in + match lbs.lbs_extension with + | None -> str + | Some id -> ghstr (Pstr_extension((id, PStr [str]), [])) -let build_lazy_queue ppf queue (ast_table : _ t String_map.t) - after_parsing_impl - after_parsing_sig - = - queue |> Queue.iter (fun modname -> - match String_map.find_exn ast_table modname with - | {ast_info = Ml(source_file,lazy ast, opref)} - -> - after_parsing_impl ppf source_file opref ast - | {ast_info = Mli (source_file,lazy ast,opref) ; } - -> - after_parsing_sig ppf source_file opref ast - | {ast_info = Ml_mli(source_file1,lazy impl,opref1,source_file2,lazy intf,opref2)} - -> - after_parsing_sig ppf source_file1 opref1 intf ; - after_parsing_impl ppf source_file2 opref2 impl - | exception Not_found -> assert false - ) +let expr_of_let_bindings lbs body = + let bindings = + List.map + (fun lb -> + Vb.mk ~loc:lb.lb_loc ~attrs:lb.lb_attributes + lb.lb_pattern lb.lb_expression) + lbs.lbs_bindings + in + mkexp_attrs (Pexp_let(lbs.lbs_rec, List.rev bindings, body)) + (lbs.lbs_extension, []) +let class_of_let_bindings lbs body = + let bindings = + List.map + (fun lb -> + Vb.mk ~loc:lb.lb_loc ~attrs:lb.lb_attributes + lb.lb_pattern lb.lb_expression) + lbs.lbs_bindings + in + if lbs.lbs_extension <> None then + raise Syntaxerr.(Error(Not_expecting(lbs.lbs_loc, "extension"))); + mkclass(Pcl_let (lbs.lbs_rec, List.rev bindings, body)) -end -module Binary_ast : sig -#1 "binary_ast.mli" -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +(* Alternatively, we could keep the generic module type in the Parsetree + and extract the package type during type-checking. In that case, + the assertions below should be turned into explicit checks. *) +let package_type_of_module_type pmty = + let err loc s = + raise (Syntaxerr.Error (Syntaxerr.Invalid_package_type (loc, s))) + in + let map_cstr = function + | Pwith_type (lid, ptyp) -> + let loc = ptyp.ptype_loc in + if ptyp.ptype_params <> [] then + err loc "parametrized types are not supported"; + if ptyp.ptype_cstrs <> [] then + err loc "constrained types are not supported"; + if ptyp.ptype_private <> Public then + err loc "private types are not supported"; + + (* restrictions below are checked by the 'with_constraint' rule *) + assert (ptyp.ptype_kind = Ptype_abstract); + assert (ptyp.ptype_attributes = []); + let ty = + match ptyp.ptype_manifest with + | Some ty -> ty + | None -> assert false + in + (lid, ty) + | _ -> + err pmty.pmty_loc "only 'with type t =' constraints are supported" + in + match pmty with + | {pmty_desc = Pmty_ident lid} -> (lid, []) + | {pmty_desc = Pmty_with({pmty_desc = Pmty_ident lid}, cstrs)} -> + (lid, List.map map_cstr cstrs) + | _ -> + err pmty.pmty_loc + "only module type identifier and 'with type' constraints are supported" -val read_ast : 'a Ml_binary.kind -> string -> 'a +# 524 "parsing/parser.ml" +let yytransl_const = [| + 257 (* AMPERAMPER *); + 258 (* AMPERSAND *); + 259 (* AND *); + 260 (* AS *); + 261 (* ASSERT *); + 262 (* BACKQUOTE *); + 263 (* BANG *); + 264 (* BAR *); + 265 (* BARBAR *); + 266 (* BARRBRACKET *); + 267 (* BEGIN *); + 269 (* CLASS *); + 270 (* COLON *); + 271 (* COLONCOLON *); + 272 (* COLONEQUAL *); + 273 (* COLONGREATER *); + 274 (* COMMA *); + 275 (* CONSTRAINT *); + 276 (* DO *); + 277 (* DONE *); + 278 (* DOT *); + 279 (* DOTDOT *); + 280 (* DOWNTO *); + 281 (* ELSE *); + 282 (* END *); + 0 (* EOF *); + 283 (* EQUAL *); + 284 (* EXCEPTION *); + 285 (* EXTERNAL *); + 286 (* FALSE *); + 288 (* FOR *); + 289 (* FUN *); + 290 (* FUNCTION *); + 291 (* FUNCTOR *); + 292 (* GREATER *); + 293 (* GREATERRBRACE *); + 294 (* GREATERRBRACKET *); + 295 (* IF *); + 296 (* IN *); + 297 (* INCLUDE *); + 304 (* INHERIT *); + 305 (* INITIALIZER *); + 308 (* LAZY *); + 309 (* LBRACE *); + 310 (* LBRACELESS *); + 311 (* LBRACKET *); + 312 (* LBRACKETBAR *); + 313 (* LBRACKETLESS *); + 314 (* LBRACKETGREATER *); + 315 (* LBRACKETPERCENT *); + 316 (* LBRACKETPERCENTPERCENT *); + 317 (* LESS *); + 318 (* LESSMINUS *); + 319 (* LET *); + 321 (* LPAREN *); + 322 (* LBRACKETAT *); + 323 (* LBRACKETATAT *); + 324 (* LBRACKETATATAT *); + 325 (* MATCH *); + 326 (* METHOD *); + 327 (* MINUS *); + 328 (* MINUSDOT *); + 329 (* MINUSGREATER *); + 330 (* MODULE *); + 331 (* MUTABLE *); + 332 (* NEW *); + 333 (* NONREC *); + 334 (* OBJECT *); + 335 (* OF *); + 336 (* OPEN *); + 338 (* OR *); + 339 (* PERCENT *); + 340 (* PLUS *); + 341 (* PLUSDOT *); + 342 (* PLUSEQ *); + 344 (* PRIVATE *); + 345 (* QUESTION *); + 346 (* QUOTE *); + 347 (* RBRACE *); + 348 (* RBRACKET *); + 349 (* REC *); + 350 (* RPAREN *); + 351 (* SEMI *); + 352 (* SEMISEMI *); + 353 (* HASH *); + 355 (* SIG *); + 356 (* STAR *); + 358 (* STRUCT *); + 359 (* THEN *); + 360 (* TILDE *); + 361 (* TO *); + 362 (* TRUE *); + 363 (* TRY *); + 364 (* TYPE *); + 366 (* UNDERSCORE *); + 367 (* VAL *); + 368 (* VIRTUAL *); + 369 (* WHEN *); + 370 (* WHILE *); + 371 (* WITH *); + 374 (* EOL *); + 0|] -val magic_sep_char : char +let yytransl_block = [| + 268 (* CHAR *); + 287 (* FLOAT *); + 298 (* INFIXOP0 *); + 299 (* INFIXOP1 *); + 300 (* INFIXOP2 *); + 301 (* INFIXOP3 *); + 302 (* INFIXOP4 *); + 303 (* DOTOP *); + 306 (* INT *); + 307 (* LABEL *); + 320 (* LIDENT *); + 337 (* OPTLABEL *); + 343 (* PREFIXOP *); + 354 (* HASHOP *); + 357 (* STRING *); + 365 (* UIDENT *); + 372 (* COMMENT *); + 373 (* DOCSTRING *); + 0|] -(** - Check out {!Bsb_depfile_gen} for set decoding - The [.ml] file can be recognized as an ast directly, the format - is - { - magic number; - filename; - ast - } - when [fname] is "-" it means the file is from an standard input or pipe. - An empty name would marshallized. +let yylhs = "\255\255\ +\001\000\002\000\003\000\003\000\003\000\010\000\010\000\014\000\ +\014\000\004\000\016\000\016\000\017\000\017\000\017\000\017\000\ +\017\000\017\000\017\000\005\000\006\000\007\000\020\000\020\000\ +\021\000\021\000\023\000\023\000\024\000\024\000\024\000\024\000\ +\024\000\024\000\024\000\024\000\024\000\027\000\027\000\027\000\ +\027\000\027\000\027\000\027\000\027\000\027\000\027\000\027\000\ +\008\000\008\000\032\000\032\000\032\000\015\000\015\000\015\000\ +\015\000\015\000\015\000\015\000\015\000\015\000\015\000\015\000\ +\015\000\015\000\015\000\015\000\045\000\049\000\049\000\049\000\ +\039\000\040\000\040\000\050\000\051\000\022\000\022\000\022\000\ +\022\000\022\000\022\000\022\000\022\000\022\000\022\000\022\000\ +\009\000\009\000\009\000\054\000\054\000\054\000\054\000\054\000\ +\054\000\054\000\054\000\054\000\054\000\054\000\054\000\054\000\ +\054\000\054\000\042\000\060\000\063\000\063\000\063\000\057\000\ +\058\000\059\000\059\000\064\000\065\000\066\000\066\000\041\000\ +\043\000\043\000\068\000\069\000\072\000\072\000\072\000\071\000\ +\071\000\077\000\077\000\073\000\073\000\073\000\073\000\073\000\ +\073\000\073\000\078\000\078\000\078\000\078\000\078\000\078\000\ +\078\000\078\000\082\000\083\000\083\000\083\000\084\000\084\000\ +\085\000\085\000\085\000\085\000\085\000\085\000\085\000\086\000\ +\086\000\087\000\087\000\087\000\087\000\088\000\088\000\088\000\ +\088\000\088\000\074\000\074\000\074\000\074\000\074\000\097\000\ +\097\000\097\000\097\000\097\000\097\000\097\000\100\000\101\000\ +\101\000\102\000\102\000\103\000\103\000\103\000\103\000\103\000\ +\103\000\104\000\104\000\104\000\106\000\089\000\061\000\061\000\ +\107\000\108\000\044\000\044\000\109\000\110\000\012\000\012\000\ +\012\000\012\000\075\000\075\000\075\000\075\000\075\000\075\000\ +\075\000\075\000\116\000\116\000\113\000\113\000\112\000\112\000\ +\114\000\115\000\115\000\030\000\030\000\030\000\030\000\030\000\ +\030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ +\030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ +\030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ +\030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ +\030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ +\030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ +\030\000\030\000\030\000\030\000\030\000\030\000\118\000\118\000\ +\118\000\118\000\118\000\118\000\118\000\118\000\118\000\118\000\ +\118\000\118\000\118\000\118\000\118\000\118\000\118\000\118\000\ +\118\000\118\000\118\000\118\000\118\000\118\000\118\000\118\000\ +\118\000\118\000\118\000\118\000\118\000\118\000\118\000\118\000\ +\118\000\118\000\118\000\118\000\118\000\118\000\118\000\118\000\ +\118\000\118\000\118\000\118\000\118\000\118\000\118\000\118\000\ +\118\000\118\000\118\000\118\000\118\000\118\000\118\000\118\000\ +\118\000\118\000\118\000\118\000\118\000\118\000\079\000\079\000\ +\136\000\136\000\137\000\137\000\137\000\137\000\138\000\096\000\ +\096\000\139\000\139\000\139\000\139\000\139\000\139\000\033\000\ +\033\000\144\000\145\000\147\000\147\000\095\000\095\000\095\000\ +\121\000\121\000\148\000\148\000\148\000\122\000\122\000\122\000\ +\122\000\123\000\123\000\132\000\132\000\150\000\150\000\150\000\ +\151\000\151\000\135\000\135\000\153\000\153\000\133\000\133\000\ +\092\000\092\000\092\000\092\000\092\000\152\000\152\000\019\000\ +\019\000\019\000\019\000\019\000\019\000\019\000\019\000\019\000\ +\019\000\142\000\142\000\142\000\142\000\142\000\142\000\142\000\ +\142\000\142\000\155\000\155\000\155\000\155\000\117\000\117\000\ +\143\000\143\000\143\000\143\000\143\000\143\000\143\000\143\000\ +\143\000\143\000\143\000\143\000\143\000\143\000\143\000\143\000\ +\143\000\143\000\143\000\143\000\143\000\143\000\159\000\159\000\ +\159\000\159\000\159\000\159\000\159\000\154\000\154\000\154\000\ +\156\000\156\000\156\000\161\000\161\000\160\000\160\000\160\000\ +\160\000\162\000\162\000\163\000\163\000\035\000\164\000\164\000\ +\034\000\036\000\036\000\165\000\166\000\170\000\170\000\169\000\ +\169\000\169\000\169\000\169\000\169\000\169\000\169\000\169\000\ +\169\000\169\000\168\000\168\000\168\000\173\000\174\000\174\000\ +\176\000\176\000\177\000\175\000\175\000\175\000\178\000\076\000\ +\076\000\171\000\171\000\171\000\179\000\180\000\038\000\038\000\ +\056\000\119\000\182\000\182\000\182\000\182\000\183\000\183\000\ +\172\000\172\000\172\000\185\000\186\000\037\000\055\000\188\000\ +\188\000\188\000\188\000\188\000\188\000\189\000\189\000\189\000\ +\190\000\191\000\192\000\193\000\053\000\053\000\194\000\194\000\ +\194\000\194\000\195\000\195\000\141\000\141\000\093\000\093\000\ +\187\000\187\000\018\000\018\000\196\000\196\000\198\000\198\000\ +\198\000\198\000\198\000\149\000\149\000\199\000\199\000\199\000\ +\199\000\199\000\199\000\199\000\199\000\199\000\199\000\199\000\ +\199\000\199\000\199\000\199\000\199\000\199\000\199\000\199\000\ +\031\000\202\000\202\000\203\000\203\000\201\000\201\000\205\000\ +\205\000\206\000\206\000\204\000\204\000\098\000\098\000\080\000\ +\080\000\184\000\184\000\200\000\200\000\200\000\200\000\200\000\ +\200\000\200\000\209\000\207\000\208\000\090\000\131\000\131\000\ +\131\000\131\000\157\000\157\000\157\000\157\000\157\000\067\000\ +\067\000\140\000\140\000\140\000\140\000\140\000\210\000\210\000\ +\210\000\210\000\210\000\210\000\210\000\210\000\210\000\210\000\ +\210\000\210\000\210\000\210\000\210\000\210\000\210\000\210\000\ +\210\000\210\000\210\000\210\000\210\000\210\000\210\000\210\000\ +\210\000\210\000\210\000\181\000\181\000\181\000\181\000\181\000\ +\181\000\130\000\130\000\124\000\124\000\124\000\124\000\124\000\ +\124\000\124\000\129\000\129\000\158\000\158\000\025\000\025\000\ +\197\000\197\000\197\000\052\000\052\000\099\000\099\000\081\000\ +\081\000\011\000\011\000\011\000\011\000\011\000\011\000\011\000\ +\125\000\146\000\146\000\167\000\167\000\126\000\126\000\094\000\ +\094\000\091\000\091\000\070\000\070\000\105\000\105\000\105\000\ +\105\000\105\000\062\000\062\000\120\000\120\000\134\000\134\000\ +\127\000\127\000\128\000\128\000\211\000\211\000\211\000\211\000\ +\211\000\211\000\211\000\211\000\211\000\211\000\211\000\211\000\ +\211\000\211\000\211\000\211\000\211\000\211\000\211\000\211\000\ +\211\000\211\000\211\000\211\000\211\000\211\000\211\000\211\000\ +\211\000\211\000\211\000\211\000\211\000\211\000\211\000\211\000\ +\211\000\211\000\211\000\211\000\211\000\211\000\211\000\211\000\ +\211\000\211\000\211\000\211\000\211\000\211\000\211\000\111\000\ +\111\000\028\000\213\000\047\000\013\000\013\000\026\000\026\000\ +\048\000\048\000\048\000\029\000\046\000\212\000\212\000\212\000\ +\212\000\212\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000" - Use case cat - | fan -printer -impl - - redirect the standard input to fan - *) -val write_ast : sourcefile:string -> output:string -> 'a Ml_binary.kind -> 'a -> unit +let yylen = "\002\000\ +\002\000\002\000\002\000\002\000\001\000\002\000\001\000\000\000\ +\002\000\001\000\001\000\003\000\001\000\002\000\004\000\003\000\ +\003\000\002\000\002\000\002\000\002\000\002\000\002\000\005\000\ +\001\000\001\000\002\000\001\000\001\000\004\000\004\000\005\000\ +\002\000\003\000\001\000\002\000\001\000\005\000\005\000\003\000\ +\003\000\005\000\007\000\009\000\007\000\006\000\006\000\005\000\ +\003\000\001\000\000\000\002\000\002\000\001\000\001\000\001\000\ +\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\ +\001\000\001\000\002\000\001\000\004\000\002\000\004\000\002\000\ +\005\000\001\000\002\000\006\000\005\000\001\000\004\000\004\000\ +\005\000\003\000\003\000\005\000\003\000\003\000\001\000\002\000\ +\000\000\002\000\002\000\001\000\001\000\001\000\001\000\001\000\ +\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\ +\002\000\001\000\005\000\004\000\002\000\006\000\003\000\005\000\ +\006\000\001\000\002\000\007\000\006\000\000\000\002\000\006\000\ +\001\000\002\000\007\000\007\000\002\000\004\000\002\000\000\000\ +\003\000\003\000\002\000\001\000\003\000\002\000\003\000\007\000\ +\002\000\001\000\004\000\001\000\004\000\004\000\005\000\005\000\ +\003\000\003\000\002\000\003\000\005\000\000\000\000\000\002\000\ +\006\000\003\000\003\000\004\000\004\000\002\000\001\000\002\000\ +\000\000\007\000\007\000\006\000\007\000\007\000\007\000\005\000\ +\008\000\011\000\001\000\006\000\004\000\005\000\003\000\004\000\ +\001\000\004\000\004\000\002\000\001\000\007\000\002\000\003\000\ +\000\000\000\000\002\000\004\000\004\000\007\000\004\000\002\000\ +\001\000\005\000\005\000\003\000\003\000\003\000\001\000\002\000\ +\008\000\008\000\001\000\002\000\009\000\008\000\001\000\002\000\ +\003\000\005\000\005\000\002\000\005\000\002\000\004\000\002\000\ +\002\000\001\000\001\000\001\000\000\000\002\000\001\000\003\000\ +\001\000\001\000\003\000\001\000\002\000\003\000\007\000\006\000\ +\007\000\004\000\004\000\007\000\006\000\006\000\005\000\001\000\ +\002\000\002\000\007\000\005\000\006\000\010\000\003\000\003\000\ +\003\000\003\000\003\000\003\000\003\000\003\000\003\000\003\000\ +\003\000\003\000\003\000\003\000\003\000\003\000\003\000\003\000\ +\003\000\003\000\003\000\002\000\002\000\005\000\007\000\007\000\ +\007\000\007\000\007\000\007\000\009\000\009\000\009\000\003\000\ +\003\000\003\000\004\000\004\000\002\000\001\000\001\000\001\000\ +\001\000\001\000\003\000\003\000\004\000\003\000\004\000\004\000\ +\003\000\005\000\004\000\005\000\005\000\005\000\005\000\005\000\ +\005\000\005\000\005\000\005\000\005\000\005\000\007\000\007\000\ +\007\000\007\000\007\000\007\000\005\000\005\000\003\000\003\000\ +\005\000\005\000\004\000\004\000\002\000\006\000\004\000\006\000\ +\004\000\004\000\006\000\004\000\006\000\002\000\002\000\003\000\ +\003\000\003\000\002\000\005\000\004\000\005\000\003\000\003\000\ +\005\000\007\000\006\000\009\000\008\000\001\000\001\000\002\000\ +\001\000\001\000\002\000\002\000\002\000\002\000\001\000\001\000\ +\002\000\002\000\004\000\007\000\008\000\003\000\005\000\001\000\ +\002\000\005\000\004\000\001\000\003\000\002\000\002\000\005\000\ +\001\000\003\000\003\000\005\000\003\000\002\000\004\000\002\000\ +\005\000\003\000\003\000\003\000\001\000\001\000\003\000\002\000\ +\004\000\002\000\002\000\003\000\003\000\001\000\001\000\003\000\ +\002\000\004\000\002\000\002\000\002\000\001\000\000\000\003\000\ +\003\000\001\000\003\000\003\000\003\000\003\000\003\000\002\000\ +\001\000\003\000\003\000\001\000\003\000\003\000\003\000\003\000\ +\002\000\001\000\001\000\002\000\002\000\003\000\001\000\001\000\ +\001\000\001\000\003\000\001\000\001\000\002\000\001\000\003\000\ +\004\000\004\000\005\000\005\000\004\000\003\000\003\000\005\000\ +\005\000\004\000\005\000\007\000\007\000\001\000\003\000\003\000\ +\004\000\004\000\004\000\002\000\004\000\003\000\003\000\003\000\ +\003\000\003\000\003\000\001\000\003\000\001\000\002\000\004\000\ +\003\000\004\000\002\000\002\000\000\000\006\000\001\000\002\000\ +\008\000\001\000\002\000\008\000\007\000\003\000\000\000\000\000\ +\002\000\003\000\002\000\003\000\002\000\003\000\005\000\005\000\ +\005\000\007\000\000\000\001\000\003\000\002\000\001\000\003\000\ +\002\000\001\000\002\000\000\000\001\000\001\000\002\000\001\000\ +\003\000\001\000\001\000\002\000\003\000\004\000\001\000\007\000\ +\006\000\003\000\000\000\002\000\004\000\002\000\001\000\003\000\ +\001\000\001\000\002\000\005\000\007\000\009\000\009\000\001\000\ +\001\000\001\000\001\000\002\000\002\000\001\000\001\000\002\000\ +\003\000\004\000\004\000\005\000\001\000\003\000\006\000\005\000\ +\004\000\004\000\001\000\002\000\002\000\003\000\001\000\003\000\ +\001\000\003\000\001\000\002\000\001\000\004\000\001\000\006\000\ +\004\000\005\000\003\000\001\000\003\000\002\000\001\000\001\000\ +\002\000\004\000\003\000\002\000\002\000\003\000\005\000\003\000\ +\004\000\005\000\004\000\002\000\004\000\006\000\005\000\001\000\ +\001\000\001\000\003\000\001\000\001\000\005\000\002\000\001\000\ +\000\000\001\000\003\000\001\000\002\000\001\000\003\000\001\000\ +\003\000\001\000\003\000\002\000\002\000\001\000\001\000\001\000\ +\001\000\001\000\004\000\006\000\002\000\001\000\001\000\001\000\ +\001\000\001\000\001\000\002\000\002\000\002\000\002\000\001\000\ +\001\000\001\000\003\000\003\000\002\000\003\000\001\000\001\000\ +\001\000\001\000\001\000\001\000\003\000\004\000\003\000\004\000\ +\003\000\004\000\001\000\001\000\001\000\001\000\001\000\001\000\ +\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\ +\001\000\001\000\001\000\001\000\002\000\002\000\003\000\001\000\ +\001\000\001\000\003\000\001\000\005\000\002\000\002\000\003\000\ +\001\000\001\000\001\000\003\000\001\000\003\000\001\000\003\000\ +\001\000\003\000\004\000\001\000\003\000\001\000\003\000\001\000\ +\003\000\002\000\003\000\003\000\003\000\003\000\003\000\003\000\ +\002\000\000\000\001\000\000\000\001\000\001\000\001\000\000\000\ +\001\000\000\000\001\000\000\000\001\000\000\000\001\000\001\000\ +\002\000\002\000\000\000\001\000\000\000\001\000\000\000\001\000\ +\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\ +\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\ +\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\ +\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\ +\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\ +\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\ +\001\000\001\000\001\000\001\000\001\000\001\000\001\000\001\000\ +\003\000\004\000\004\000\004\000\000\000\002\000\000\000\002\000\ +\000\000\002\000\003\000\004\000\004\000\001\000\002\000\002\000\ +\002\000\004\000\002\000\002\000\002\000\002\000\002\000\002\000\ +\002\000" +let yydefred = "\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\112\002\000\000\000\000\000\000\ +\169\002\114\002\000\000\000\000\000\000\000\000\000\000\111\002\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\217\002\218\002\000\000\000\000\ +\000\000\000\000\219\002\220\002\000\000\000\000\113\002\170\002\ +\000\000\000\000\175\002\030\001\000\000\000\000\035\003\000\000\ +\000\000\000\000\000\000\094\001\000\000\050\000\000\000\055\000\ +\056\000\000\000\058\000\059\000\060\000\000\000\062\000\063\000\ +\000\000\000\000\066\000\000\000\068\000\074\000\007\002\121\000\ +\000\000\203\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\031\001\032\001\162\002\112\001\226\001\000\000\000\000\000\000\ +\000\000\000\000\000\000\036\003\000\000\093\000\092\000\000\000\ +\100\000\101\000\000\000\000\000\106\000\000\000\095\000\096\000\ +\097\000\098\000\000\000\102\000\000\000\114\000\199\000\005\000\ +\000\000\037\003\000\000\000\000\000\000\007\000\000\000\013\000\ +\000\000\038\003\000\000\000\000\000\000\010\000\011\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\177\002\063\002\039\003\000\000\080\002\055\002\000\000\ +\064\002\051\002\000\000\000\000\000\000\040\003\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\122\002\000\000\000\000\ +\000\000\000\000\177\001\041\003\000\000\000\000\198\001\171\001\ +\000\000\000\000\115\002\175\001\176\001\000\000\161\001\000\000\ +\183\001\000\000\000\000\000\000\000\000\121\002\120\002\193\002\ +\079\001\033\001\034\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\133\001\000\000\083\001\110\002\000\000\ +\000\000\000\000\166\002\000\000\000\000\069\001\000\000\223\002\ +\224\002\225\002\226\002\227\002\228\002\229\002\230\002\231\002\ +\232\002\233\002\234\002\235\002\236\002\237\002\238\002\239\002\ +\240\002\241\002\242\002\243\002\244\002\245\002\246\002\247\002\ +\221\002\248\002\249\002\250\002\251\002\252\002\253\002\254\002\ +\255\002\000\003\001\003\002\003\003\003\004\003\005\003\006\003\ +\007\003\008\003\009\003\010\003\222\002\011\003\012\003\013\003\ +\014\003\015\003\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\125\002\152\002\151\002\000\000\150\002\000\000\153\002\ +\146\002\148\002\128\002\129\002\130\002\131\002\132\002\000\000\ +\147\002\000\000\000\000\000\000\149\002\155\002\000\000\000\000\ +\154\002\000\000\167\002\139\002\145\002\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\212\002\000\000\078\001\ +\052\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\ +\000\000\000\000\053\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\029\001\000\000\000\000\113\001\ +\000\000\227\001\000\000\075\000\000\000\122\000\000\000\204\000\ +\067\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\095\001\098\001\000\000\000\000\ +\000\000\012\001\013\001\000\000\000\000\000\000\000\000\090\000\ +\000\000\002\000\105\000\091\000\000\000\115\000\000\000\200\000\ +\000\000\003\000\004\000\006\000\009\000\014\000\000\000\000\000\ +\000\000\019\000\000\000\018\000\000\000\173\002\000\000\085\002\ +\000\000\000\000\214\002\000\000\076\002\000\000\106\002\068\002\ +\000\000\000\000\000\000\000\000\000\000\000\000\103\002\000\000\ +\000\000\000\000\000\000\000\000\000\000\062\002\184\002\000\000\ +\069\002\020\000\052\002\000\000\000\000\000\000\000\000\000\000\ +\000\000\065\002\021\000\000\000\000\000\171\002\000\000\000\000\ +\000\000\000\000\000\000\000\000\204\001\000\000\140\002\000\000\ +\144\002\000\000\000\000\142\002\127\002\000\000\117\002\116\002\ +\119\002\118\002\182\001\000\000\000\000\000\000\000\000\022\000\ +\160\001\000\000\172\001\173\001\000\000\000\000\000\000\000\000\ +\026\003\000\000\000\000\000\000\000\000\038\001\000\000\000\000\ +\205\002\000\000\160\002\000\000\000\000\161\002\156\002\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\218\000\180\001\181\001\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\035\000\037\000\000\000\000\000\000\000\ +\000\000\000\000\150\001\000\000\064\001\063\001\000\000\000\000\ +\082\001\081\001\000\000\139\001\000\000\000\000\000\000\000\000\ +\000\000\030\003\000\000\000\000\000\000\000\000\000\000\000\000\ +\195\002\000\000\168\002\000\000\000\000\000\000\126\002\000\000\ +\036\001\035\001\000\000\124\002\123\002\000\000\000\000\000\000\ +\000\000\000\000\080\001\000\000\000\000\151\000\000\000\000\000\ +\197\002\000\000\000\000\000\000\000\000\049\000\022\003\000\000\ +\000\000\000\000\000\000\000\000\176\002\163\002\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\209\000\000\000\000\000\230\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\103\001\ +\101\001\087\001\000\000\100\001\096\001\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\087\000\078\000\ +\180\002\000\000\000\000\000\000\000\000\000\000\000\000\191\002\ +\188\002\187\002\192\002\000\000\189\002\017\000\000\000\016\000\ +\012\000\084\002\000\000\082\002\000\000\087\002\072\002\000\000\ +\000\000\000\000\000\000\109\002\067\002\100\002\101\002\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\098\002\000\000\ +\174\002\178\002\000\000\000\000\000\000\070\002\159\001\174\001\ +\000\000\000\000\000\000\200\001\199\001\000\000\000\000\000\000\ +\000\000\000\000\191\001\000\000\190\001\153\001\152\001\158\001\ +\000\000\156\001\000\000\208\001\000\000\000\000\000\000\184\001\ +\000\000\179\001\000\000\027\003\024\003\000\000\000\000\000\000\ +\000\000\041\001\000\000\000\000\000\000\039\001\037\001\000\000\ +\000\000\000\000\157\002\000\000\158\002\000\000\000\000\000\000\ +\000\000\143\002\000\000\141\002\000\000\000\000\217\000\000\000\ +\219\000\000\000\220\000\214\000\225\000\000\000\212\000\000\000\ +\216\000\000\000\000\000\000\000\000\000\235\000\000\000\000\000\ +\121\001\000\000\000\000\000\000\000\000\000\000\000\000\069\000\ +\033\000\036\000\000\000\000\000\132\001\148\001\000\000\149\001\ +\000\000\000\000\135\001\000\000\140\001\000\000\074\001\073\001\ +\068\001\067\001\031\003\000\000\000\000\028\003\017\003\029\003\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\170\001\000\000\000\000\000\000\000\000\000\000\040\001\020\003\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\028\001\027\001\000\000\000\000\000\000\000\000\254\001\ +\253\001\000\000\244\001\000\000\000\000\000\000\000\000\000\000\ +\085\001\000\000\076\001\000\000\071\001\000\000\000\000\000\000\ +\043\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\108\000\088\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\015\000\000\000\073\002\088\002\ +\000\000\000\000\000\000\077\002\075\002\000\000\000\000\000\000\ +\049\002\000\000\000\000\000\000\000\000\000\000\066\002\000\000\ +\000\000\185\002\000\000\000\000\179\002\054\002\172\002\000\000\ +\000\000\000\000\217\001\000\000\202\001\201\001\205\001\203\001\ +\000\000\194\001\000\000\185\001\189\001\186\001\000\000\018\003\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\002\000\000\159\002\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\012\002\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\126\001\128\001\000\000\000\000\000\000\000\000\ +\028\000\000\000\000\000\041\000\000\000\040\000\000\000\034\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\114\001\ +\000\000\000\000\000\000\000\000\000\000\106\001\000\000\000\000\ +\000\000\000\000\000\000\169\001\000\000\000\000\138\002\136\002\ +\134\002\000\000\089\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\023\000\025\000\026\000\000\000\072\000\073\000\000\000\ +\148\000\000\000\000\000\000\000\000\000\000\000\000\000\159\000\ +\152\000\107\000\239\000\000\000\247\001\000\000\000\000\000\000\ +\000\000\250\001\246\001\000\000\000\000\019\003\066\001\065\001\ +\086\001\084\001\000\000\000\000\165\002\000\000\044\001\042\001\ +\210\000\115\001\000\000\000\000\000\000\000\000\000\000\062\001\ +\048\001\000\000\046\001\000\000\000\000\000\000\000\000\000\000\ +\054\001\000\000\050\001\000\000\052\001\000\000\000\000\000\000\ +\086\000\085\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\037\002\000\000\181\002\000\000\000\000\000\000\000\000\000\000\ +\112\000\000\000\000\000\000\000\083\002\090\002\000\000\074\002\ +\092\002\000\000\000\000\000\000\000\000\000\000\000\000\079\002\ +\071\002\000\000\099\002\000\000\216\002\216\001\000\000\195\001\ +\193\001\192\001\188\001\187\001\061\001\047\001\045\001\000\000\ +\000\000\000\000\053\001\049\001\051\001\000\000\000\000\129\000\ +\000\000\251\001\000\000\000\000\000\000\000\000\203\002\000\000\ +\000\000\017\002\000\000\000\000\000\000\000\000\009\002\000\000\ +\199\002\198\002\000\000\105\001\000\000\000\000\000\000\000\000\ +\000\000\000\000\215\000\000\000\000\000\125\001\123\001\000\000\ +\122\001\000\000\000\000\027\000\000\000\000\000\031\000\030\000\ +\000\000\034\003\232\000\010\002\000\000\000\000\000\000\000\000\ +\118\001\000\000\000\000\116\001\119\001\000\000\163\001\162\001\ +\168\001\000\000\166\001\000\000\211\001\000\000\110\001\000\000\ +\000\000\091\001\000\000\000\000\000\000\120\000\076\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\158\000\000\000\000\000\245\001\000\000\231\001\000\000\ +\249\001\222\001\245\000\077\001\075\001\072\001\070\001\000\000\ +\231\001\077\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\080\000\079\000\000\000\000\000\000\000\000\000\113\000\111\000\ +\000\000\000\000\000\000\000\000\000\000\086\002\078\002\093\002\ +\050\002\046\002\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\001\002\255\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\177\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\138\000\000\000\000\000\000\000\ +\140\000\123\000\127\000\000\000\016\002\019\002\013\002\000\000\ +\008\002\000\000\000\000\000\000\236\000\000\000\222\000\213\000\ +\211\000\000\000\127\001\000\000\000\000\000\000\000\000\048\000\ +\000\000\000\000\042\000\039\000\038\000\231\000\233\000\000\000\ +\000\000\000\000\000\000\107\001\000\000\090\001\000\000\000\000\ +\149\000\000\000\000\000\000\000\000\000\000\000\155\000\000\000\ +\154\000\248\001\000\000\237\001\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\002\002\003\002\000\000\000\000\201\002\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\060\001\000\000\056\001\000\000\058\001\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\038\002\ +\116\000\000\000\000\000\117\000\000\000\091\002\108\002\197\001\ +\196\001\059\001\055\001\057\001\000\000\182\002\181\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\180\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\137\000\000\000\000\000\224\001\225\001\000\000\ +\129\001\124\001\046\000\000\000\047\000\000\000\000\000\000\000\ +\000\000\117\001\111\001\024\000\000\000\156\000\000\000\157\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\238\001\ +\000\000\000\000\000\000\000\000\004\002\000\000\000\000\228\001\ +\000\000\000\000\000\000\024\002\025\002\026\002\027\002\093\001\ +\000\000\229\001\124\000\000\000\000\000\000\000\000\000\201\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\030\002\031\002\000\000\205\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\186\000\000\000\000\000\000\000\175\000\ +\000\000\000\000\133\000\000\000\000\000\146\000\000\000\145\000\ +\000\000\000\000\000\000\000\000\000\000\043\000\045\000\000\000\ +\000\000\120\001\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\005\002\000\000\ +\230\001\000\000\000\000\000\000\022\002\028\002\029\002\092\001\ +\206\000\000\000\000\000\000\000\040\002\044\002\231\001\110\000\ +\000\000\023\002\032\002\202\000\183\002\176\000\000\000\000\000\ +\000\000\179\000\178\000\000\000\173\000\000\000\000\000\131\000\ +\139\000\000\000\000\000\142\000\141\000\000\000\246\000\000\000\ +\000\000\108\001\160\000\153\000\000\000\000\000\000\000\168\000\ +\000\000\000\000\000\000\000\000\006\002\241\001\000\000\000\000\ +\239\001\000\000\000\000\000\000\000\000\033\002\000\000\000\000\ +\174\000\184\000\000\000\000\000\000\000\000\000\000\000\193\000\ +\187\000\000\000\000\000\000\000\144\000\143\000\000\000\044\000\ +\109\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\164\000\000\000\000\000\000\000\000\000\034\002\035\002\ +\000\000\000\000\000\000\000\000\000\000\192\000\172\000\000\000\ +\021\002\166\000\167\000\000\000\000\000\000\000\000\000\000\000\ +\165\000\242\001\036\002\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\169\000\ +\000\000\191\000\188\000\209\002\210\002\000\000\000\000\000\000\ +\000\000\189\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\170\000\190\000\000\000\000\000" -end = struct -#1 "binary_ast.ml" +let yydgoto = "\008\000\ +\055\000\100\000\122\000\130\000\148\000\158\000\172\000\034\002\ +\101\000\123\000\131\000\057\000\072\001\126\000\058\000\134\000\ +\135\000\178\001\214\001\055\003\245\003\131\003\202\003\005\003\ +\059\000\233\001\012\002\101\001\060\000\061\000\132\003\062\000\ +\160\000\064\000\065\000\066\000\067\000\068\000\069\000\070\000\ +\071\000\072\000\073\000\074\000\075\000\076\000\077\000\025\001\ +\056\003\078\000\108\001\136\002\056\004\110\000\111\000\079\000\ +\113\000\114\000\115\000\116\000\117\000\063\001\112\003\118\000\ +\142\001\238\003\137\002\080\000\110\001\242\001\226\002\109\004\ +\007\005\251\004\253\002\169\003\211\005\008\005\123\001\179\001\ +\009\005\061\002\062\002\060\003\001\004\229\005\185\004\183\004\ +\051\005\081\000\112\004\155\004\070\006\066\005\156\004\187\003\ +\252\004\151\000\254\004\203\005\204\005\012\006\057\006\109\006\ +\105\006\241\005\119\000\144\001\082\000\112\001\019\001\190\003\ +\128\004\191\003\189\003\244\002\176\000\083\000\033\003\164\001\ +\000\003\254\002\084\000\085\000\086\000\123\004\087\000\088\000\ +\210\000\089\000\090\000\211\000\221\000\028\002\217\000\125\001\ +\126\001\121\002\037\003\091\000\071\006\039\003\181\000\092\000\ +\104\001\042\002\157\004\001\003\152\000\212\000\213\000\020\002\ +\218\000\182\000\183\000\042\003\184\000\153\000\185\000\201\001\ +\204\001\202\001\187\002\019\005\093\000\106\001\066\002\066\003\ +\191\004\071\005\067\005\113\004\067\003\006\004\068\003\011\004\ +\171\003\106\004\068\005\069\005\070\005\233\002\176\003\177\003\ +\114\004\115\004\128\003\171\005\193\005\172\005\173\005\174\005\ +\175\005\057\004\189\005\154\000\155\000\156\000\157\000\172\001\ +\154\002\155\002\156\002\074\004\121\003\071\004\173\001\174\001\ +\175\001\055\001\020\001\035\002\073\001" -(* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * In addition to the permissions granted to you by the LGPL, you may combine - * or link a "work that uses the Library" with a publicly distributed version - * of this file to produce a combined library or application, then distribute - * that combined work under the terms of your choosing, with no requirement - * to comply with the obligations normally placed on you by section 4 of the - * LGPL version 3 (or the corresponding section of a later version of the LGPL - * should you choose to use a later version). - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +let yysindex = "\141\009\ +\228\067\075\007\170\051\083\051\204\051\233\070\196\074\000\000\ +\155\005\110\002\080\074\155\005\000\000\184\003\155\005\155\005\ +\000\000\000\000\155\005\155\005\155\005\155\005\155\005\000\000\ +\155\005\225\076\083\004\058\068\146\068\170\063\170\063\014\004\ +\000\000\024\061\170\063\155\005\000\000\000\000\087\005\155\005\ +\155\005\134\255\000\000\000\000\080\074\228\067\000\000\000\000\ +\155\005\155\005\000\000\000\000\155\005\155\005\000\000\160\000\ +\229\255\096\018\048\000\000\000\151\080\000\000\108\004\000\000\ +\000\000\195\000\000\000\000\000\000\000\075\001\000\000\000\000\ +\110\001\176\001\000\000\229\255\000\000\000\000\000\000\000\000\ +\171\000\000\000\105\076\218\001\080\074\080\074\233\070\233\070\ +\000\000\000\000\000\000\000\000\000\000\184\003\155\005\155\005\ +\087\005\075\007\155\005\000\000\049\003\000\000\000\000\195\000\ +\000\000\000\000\176\001\229\255\000\000\075\007\000\000\000\000\ +\000\000\000\000\128\002\000\000\177\002\000\000\000\000\000\000\ +\110\002\000\000\137\002\160\002\229\255\000\000\143\005\000\000\ +\035\052\000\000\171\007\229\255\171\007\000\000\000\000\151\044\ +\000\004\085\255\082\013\202\003\041\048\204\051\206\003\110\002\ +\058\003\000\000\000\000\000\000\070\000\000\000\000\000\222\003\ +\000\000\000\000\030\002\126\001\097\003\000\000\071\005\108\004\ +\155\005\155\005\208\003\199\073\006\074\000\000\136\065\090\003\ +\235\005\069\004\000\000\000\000\175\000\106\004\000\000\000\000\ +\196\074\196\074\000\000\000\000\000\000\162\004\000\000\154\004\ +\000\000\170\063\170\063\116\004\080\074\000\000\000\000\000\000\ +\000\000\000\000\000\000\231\068\155\005\147\004\023\002\116\003\ +\196\074\244\072\000\004\233\070\143\002\080\074\000\000\002\005\ +\070\001\197\003\149\255\000\000\241\004\000\000\000\000\092\005\ +\146\004\046\005\000\000\110\081\057\005\000\000\057\005\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\141\067\192\005\141\067\155\005\155\005\134\255\ +\162\005\000\000\000\000\000\000\080\074\000\000\154\005\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\203\006\ +\000\000\000\000\000\000\131\001\000\000\000\000\000\000\000\000\ +\000\000\080\074\000\000\000\000\000\000\156\000\166\255\141\067\ +\233\070\155\005\184\005\058\003\001\006\000\000\155\005\000\000\ +\000\000\233\070\211\005\116\003\233\070\000\000\170\063\096\018\ +\229\255\155\005\000\000\075\006\209\005\233\070\233\070\233\070\ +\233\070\233\070\233\070\233\070\233\070\233\070\233\070\233\070\ +\233\070\233\070\233\070\233\070\233\070\233\070\233\070\233\070\ +\233\070\233\070\060\069\233\070\000\000\116\004\233\070\000\000\ +\116\004\000\000\116\004\000\000\116\004\000\000\116\004\000\000\ +\000\000\233\070\169\004\225\006\080\074\080\074\027\006\068\006\ +\080\074\027\006\165\076\043\002\000\000\000\000\233\070\043\002\ +\043\002\000\000\000\000\147\004\023\002\075\004\236\005\000\000\ +\211\005\000\000\000\000\000\000\116\004\000\000\116\004\000\000\ +\195\003\000\000\000\000\000\000\000\000\000\000\171\007\229\255\ +\171\007\000\000\171\007\000\000\136\012\000\000\130\005\000\000\ +\042\006\138\006\000\000\136\012\000\000\136\012\000\000\000\000\ +\000\000\134\006\060\006\133\006\170\040\170\040\000\000\204\051\ +\155\005\116\004\009\001\104\006\167\006\000\000\000\000\164\006\ +\000\000\000\000\000\000\216\041\077\004\081\006\098\006\204\051\ +\058\003\000\000\000\000\196\074\009\076\000\000\173\006\179\006\ +\206\255\107\006\070\005\109\006\000\000\109\006\000\000\090\003\ +\000\000\131\001\235\005\000\000\000\000\102\002\000\000\000\000\ +\000\000\000\000\000\000\033\002\031\066\092\066\153\066\000\000\ +\000\000\176\003\000\000\000\000\196\074\242\001\141\067\116\004\ +\000\000\116\004\043\002\058\005\231\006\000\000\041\003\147\004\ +\000\000\153\006\000\000\119\006\140\000\000\000\000\000\078\002\ +\188\077\208\006\178\003\009\076\059\064\125\002\245\005\050\006\ +\048\072\000\000\000\000\000\000\196\074\110\006\116\004\254\003\ +\116\004\026\007\205\006\000\000\000\000\043\002\255\007\208\003\ +\202\009\124\017\000\000\202\006\000\000\000\000\208\003\233\070\ +\000\000\000\000\068\006\000\000\233\070\104\255\211\004\013\082\ +\196\074\000\000\149\006\170\063\155\006\023\002\142\006\155\005\ +\000\000\116\075\000\000\157\006\161\006\175\006\000\000\143\002\ +\000\000\000\000\182\006\000\000\000\000\163\006\166\006\110\002\ +\158\006\084\003\000\000\196\074\120\003\000\000\186\006\189\006\ +\000\000\092\006\252\006\006\007\141\067\000\000\000\000\225\076\ +\038\005\145\069\233\069\135\061\000\000\000\000\235\081\235\081\ +\203\081\110\013\110\081\203\081\184\012\184\012\184\012\184\012\ +\053\004\255\006\255\006\184\012\053\004\053\004\203\081\255\006\ +\053\004\053\004\053\004\170\063\000\000\255\006\116\075\000\000\ +\092\006\207\006\147\004\147\004\110\081\233\070\233\070\233\070\ +\252\001\249\006\233\070\233\070\233\070\043\002\043\002\000\000\ +\000\000\000\000\065\004\000\000\000\000\203\081\153\006\151\255\ +\116\004\075\004\213\006\116\004\000\000\163\002\000\000\000\000\ +\000\000\175\002\216\006\041\004\092\006\221\006\147\004\000\000\ +\000\000\000\000\000\000\055\007\000\000\000\000\171\007\000\000\ +\000\000\000\000\253\255\000\000\078\007\000\000\000\000\136\012\ +\127\001\112\000\120\054\000\000\000\000\000\000\000\000\008\007\ +\075\004\204\051\015\005\204\051\204\051\135\004\000\000\239\006\ +\000\000\000\000\220\001\110\002\022\007\000\000\000\000\000\000\ +\194\004\204\051\070\007\000\000\000\000\203\004\196\074\174\000\ +\024\006\247\006\000\000\254\046\000\000\000\000\000\000\000\000\ +\141\002\000\000\091\007\000\000\035\002\067\074\226\065\000\000\ +\035\002\000\000\015\007\000\000\000\000\233\070\233\070\233\070\ +\160\005\000\000\233\070\233\070\233\070\000\000\000\000\153\006\ +\237\005\044\007\000\000\018\007\000\000\013\041\179\002\013\041\ +\116\004\000\000\114\007\000\000\204\051\233\070\000\000\051\007\ +\000\000\196\074\000\000\000\000\000\000\053\007\000\000\053\007\ +\000\000\216\041\170\064\233\070\048\072\000\000\182\255\111\007\ +\000\000\233\070\056\007\116\004\033\001\228\067\247\002\000\000\ +\000\000\000\000\017\007\000\000\000\000\000\000\108\255\000\000\ +\116\004\233\070\000\000\110\081\000\000\110\081\000\000\000\000\ +\000\000\000\000\000\000\116\004\247\000\000\000\000\000\000\000\ +\087\007\151\255\084\003\186\006\229\255\216\071\239\004\115\007\ +\000\000\110\007\068\007\069\007\071\007\139\001\000\000\000\000\ +\000\004\109\007\084\003\075\004\143\002\150\005\084\003\229\255\ +\210\002\000\000\000\000\167\001\183\002\018\000\237\005\000\000\ +\000\000\209\004\000\000\136\002\204\051\233\070\047\007\242\255\ +\000\000\251\004\000\000\057\005\000\000\057\005\046\007\131\001\ +\000\000\184\255\233\070\229\255\077\007\084\003\153\006\153\006\ +\212\080\151\001\192\000\194\255\245\006\233\070\011\078\043\078\ +\121\078\080\007\056\007\119\255\063\007\075\007\075\004\060\255\ +\000\000\000\000\028\005\131\007\075\004\186\006\205\005\229\255\ +\209\004\134\007\153\006\017\003\000\000\136\012\000\000\000\000\ +\204\051\218\000\144\007\000\000\000\000\110\002\111\001\116\004\ +\000\000\204\051\255\002\058\007\116\004\058\003\000\000\022\007\ +\081\007\000\000\216\041\048\007\000\000\000\000\000\000\116\004\ +\196\074\065\007\000\000\070\005\000\000\000\000\000\000\000\000\ +\087\001\000\000\129\255\000\000\000\000\000\000\053\003\000\000\ +\017\081\048\001\246\255\020\007\153\078\231\078\007\079\102\007\ +\129\001\082\007\000\000\129\072\000\000\092\007\000\000\095\007\ +\239\006\083\007\144\001\151\007\116\004\000\000\229\255\245\001\ +\102\000\051\007\084\007\108\006\150\007\150\007\165\007\093\007\ +\108\007\051\007\000\000\000\000\063\070\233\070\196\074\049\081\ +\000\000\201\003\233\070\000\000\075\004\000\000\150\003\000\000\ +\204\051\110\081\233\070\233\070\116\004\142\007\228\004\000\000\ +\162\015\233\070\025\065\021\072\164\007\000\000\152\002\214\066\ +\019\067\080\067\233\070\000\000\204\051\196\074\000\000\000\000\ +\000\000\122\000\000\000\196\074\075\004\229\255\229\255\107\001\ +\053\006\000\000\000\000\000\000\180\007\000\000\000\000\204\051\ +\000\000\116\004\134\255\116\004\134\255\134\255\229\255\000\000\ +\000\000\000\000\000\000\196\074\000\000\207\001\168\007\112\007\ +\110\002\000\000\000\000\151\006\175\007\000\000\000\000\000\000\ +\000\000\000\000\060\001\168\006\000\000\143\002\000\000\000\000\ +\000\000\000\000\168\007\229\255\137\007\139\007\147\007\000\000\ +\000\000\148\007\000\000\154\007\233\070\233\070\233\070\110\081\ +\000\000\157\007\000\000\158\007\000\000\159\007\199\007\033\006\ +\000\000\000\000\116\004\159\004\255\002\186\006\092\006\219\007\ +\000\000\000\000\000\000\075\004\255\002\183\002\098\002\211\007\ +\000\000\140\007\075\004\163\007\000\000\000\000\072\001\000\000\ +\000\000\172\255\000\000\204\051\110\002\138\007\022\007\000\000\ +\000\000\204\051\000\000\070\005\000\000\000\000\075\004\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\233\070\ +\233\070\233\070\000\000\000\000\000\000\202\007\237\005\000\000\ +\110\002\000\000\136\050\096\005\229\255\129\072\000\000\068\006\ +\141\007\000\000\092\007\216\041\009\002\229\255\000\000\135\007\ +\000\000\000\000\233\070\000\000\048\072\204\051\233\070\146\007\ +\149\007\204\051\000\000\233\070\152\007\000\000\000\000\162\007\ +\000\000\233\070\143\002\000\000\100\077\137\255\000\000\000\000\ +\116\004\000\000\000\000\000\000\233\070\233\070\051\007\142\001\ +\000\000\051\007\214\007\000\000\000\000\233\070\000\000\000\000\ +\000\000\141\002\000\000\091\007\000\000\035\002\000\000\121\002\ +\035\002\000\000\156\007\111\007\255\002\000\000\000\000\143\002\ +\075\004\248\003\204\051\116\004\233\070\116\004\229\255\116\004\ +\229\255\000\000\111\007\237\005\000\000\031\077\000\000\160\007\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\209\002\ +\000\000\000\000\129\072\215\007\233\070\233\070\233\070\094\079\ +\126\079\204\079\233\070\233\070\233\070\136\050\075\004\143\002\ +\000\000\000\000\148\006\208\003\060\255\163\002\000\000\000\000\ +\075\004\160\007\163\002\224\007\204\051\000\000\000\000\000\000\ +\000\000\000\000\116\004\022\007\059\000\236\079\058\080\090\080\ +\163\005\000\000\000\000\054\012\173\007\230\007\116\004\216\041\ +\190\007\000\000\231\007\116\004\186\007\000\000\190\002\116\004\ +\204\051\217\005\096\005\116\004\000\000\249\004\116\004\165\076\ +\000\000\000\000\000\000\246\007\000\000\000\000\000\000\247\007\ +\000\000\135\007\229\255\241\007\000\000\116\004\000\000\000\000\ +\000\000\116\004\000\000\048\072\233\070\110\081\053\006\000\000\ +\243\000\237\002\000\000\000\000\000\000\000\000\000\000\242\007\ +\204\051\172\007\233\070\000\000\233\070\000\000\053\006\100\005\ +\000\000\250\002\229\255\096\005\229\255\195\001\000\000\234\004\ +\000\000\000\000\023\002\000\000\127\049\148\014\097\047\000\000\ +\096\003\217\007\007\008\000\000\000\000\151\255\063\002\000\000\ +\150\255\078\003\063\002\229\255\163\005\110\081\110\081\110\081\ +\000\000\216\007\000\000\218\007\000\000\221\007\110\081\110\081\ +\110\081\229\255\255\002\053\006\081\006\081\006\043\005\000\000\ +\000\000\079\006\174\255\000\000\136\050\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\204\051\000\000\000\000\151\006\ +\229\002\190\001\222\003\134\255\216\041\208\007\203\007\014\008\ +\096\005\000\000\136\050\045\005\049\073\202\001\134\255\166\000\ +\001\006\096\005\000\000\165\076\120\054\000\000\000\000\233\070\ +\000\000\000\000\000\000\249\255\000\000\193\007\204\051\215\003\ +\021\072\000\000\000\000\000\000\204\051\000\000\025\001\000\000\ +\177\007\160\007\068\006\181\007\092\007\068\006\151\255\000\000\ +\116\004\007\008\160\007\092\007\000\000\116\004\204\051\000\000\ +\023\002\082\002\194\001\000\000\000\000\000\000\000\000\000\000\ +\201\007\000\000\000\000\151\006\233\070\233\070\233\070\000\000\ +\168\003\168\003\204\051\228\007\204\051\098\002\023\002\151\255\ +\248\001\000\000\000\000\229\255\000\000\053\005\068\005\116\004\ +\223\007\204\051\200\004\000\000\136\050\216\041\116\004\000\000\ +\000\000\217\072\000\000\058\003\116\004\000\000\136\050\000\000\ +\026\005\116\004\116\004\022\008\075\004\000\000\000\000\008\004\ +\233\070\000\000\116\004\238\007\229\255\068\006\068\006\156\072\ +\068\006\068\006\103\006\116\004\101\003\212\007\000\000\052\004\ +\000\000\246\002\179\002\116\004\000\000\000\000\000\000\000\000\ +\000\000\110\081\110\081\110\081\000\000\000\000\000\000\000\000\ +\151\255\000\000\000\000\000\000\000\000\000\000\186\006\136\050\ +\103\004\000\000\000\000\158\001\000\000\234\007\096\005\000\000\ +\000\000\186\006\159\000\000\000\000\000\222\007\000\000\227\007\ +\233\070\000\000\000\000\000\000\048\008\052\008\140\048\000\000\ +\054\008\056\008\233\070\050\008\000\000\000\000\092\007\007\008\ +\000\000\204\051\179\002\116\004\116\004\000\000\060\008\036\005\ +\000\000\000\000\116\004\116\004\116\004\116\004\229\255\000\000\ +\000\000\136\050\116\004\088\005\000\000\000\000\116\004\000\000\ +\000\000\120\054\120\054\051\007\116\004\053\008\238\001\204\051\ +\204\051\000\000\233\070\240\007\116\004\116\004\000\000\000\000\ +\163\005\204\051\163\005\220\003\033\003\000\000\000\000\096\005\ +\000\000\000\000\000\000\062\008\233\070\204\051\116\004\116\004\ +\000\000\000\000\000\000\116\004\229\255\151\006\225\007\250\007\ +\068\006\147\004\092\007\073\008\229\255\116\004\204\051\000\000\ +\116\004\000\000\000\000\000\000\000\000\074\008\068\006\068\006\ +\204\051\000\000\057\004\120\054\077\008\079\008\116\004\233\070\ +\229\255\204\051\204\051\000\000\000\000\116\004\116\004" - (** Synced up with module {!Bsb_helper_depfile_gen} *) -module String_set = Ast_extract.String_set +let yyrindex = "\000\000\ +\094\009\095\009\000\008\000\000\000\000\000\000\000\000\000\000\ +\232\076\000\000\000\000\148\070\000\000\022\003\029\003\171\006\ +\000\000\000\000\001\075\076\073\135\074\062\071\230\002\000\000\ +\232\076\000\000\000\000\000\000\000\000\000\000\000\000\028\075\ +\012\019\000\000\000\000\062\071\000\000\000\000\246\005\069\005\ +\015\002\042\004\000\000\000\000\000\000\099\000\000\000\000\000\ +\062\071\149\008\000\000\000\000\171\006\062\071\000\000\000\000\ +\176\040\099\000\128\019\000\000\016\046\000\000\149\013\000\000\ +\000\000\114\015\000\000\000\000\000\000\113\059\000\000\000\000\ +\122\059\171\059\000\000\215\059\000\000\000\000\000\000\000\000\ +\000\000\000\000\058\027\174\027\081\026\197\026\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\022\003\029\003\131\004\ +\246\005\116\000\149\008\000\000\000\000\000\000\000\000\222\041\ +\000\000\000\000\065\042\012\043\000\000\116\000\000\000\000\000\ +\000\000\000\000\111\043\000\000\058\044\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\002\008\000\000\000\008\000\000\ +\000\000\000\000\000\000\247\008\000\000\000\000\000\000\000\000\ +\134\014\134\014\000\000\079\010\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\247\010\ +\000\000\000\000\000\000\060\049\114\018\000\000\000\000\000\000\ +\001\075\036\076\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\150\052\000\000\000\000\ +\253\002\225\005\000\000\000\000\000\000\139\006\000\000\002\053\ +\000\000\000\000\000\000\165\060\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\022\003\239\255\000\000\000\000\ +\000\000\000\000\089\075\000\000\000\000\000\000\067\002\124\002\ +\000\000\227\255\000\000\000\000\037\000\000\000\000\000\170\255\ +\000\000\142\005\000\000\117\255\095\001\000\000\199\006\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\008\008\052\060\008\008\029\003\251\007\042\004\ +\177\075\000\000\000\000\000\000\167\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\076\062\162\062\230\002\000\000\000\000\248\062\078\063\ +\000\000\185\000\000\000\000\000\000\000\000\000\000\000\008\008\ +\000\000\069\005\000\000\000\000\002\004\000\000\251\007\000\000\ +\000\000\000\000\079\005\000\000\000\000\000\000\000\000\099\000\ +\222\055\028\075\000\000\149\013\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\220\035\000\000\000\000\204\075\000\000\000\000\ +\212\004\000\000\252\007\000\000\108\003\000\000\108\003\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\237\017\244\024\000\000\000\000\000\000\034\028\ +\151\028\000\000\000\000\239\255\000\000\000\000\000\000\000\000\ +\079\005\000\000\000\000\000\000\252\007\000\000\108\003\000\000\ +\059\014\000\000\000\000\000\000\000\000\000\000\000\000\247\008\ +\000\000\000\000\000\000\000\000\000\000\000\000\153\001\000\000\ +\095\008\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\207\255\000\000\076\008\000\000\078\008\084\008\000\000\000\000\ +\131\004\096\001\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\036\000\ +\000\000\146\000\068\000\095\001\000\000\199\006\000\000\235\000\ +\000\000\251\007\238\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\008\008\165\060\ +\000\000\229\050\011\029\000\000\000\000\000\000\000\000\239\255\ +\000\000\045\008\000\000\000\000\000\000\000\000\000\000\221\057\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\057\008\000\000\ +\246\061\215\059\064\004\000\000\000\000\127\029\000\000\000\000\ +\000\000\000\000\000\000\146\255\000\000\000\000\228\000\000\000\ +\000\000\000\000\148\005\000\000\090\001\000\000\000\000\018\008\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\251\007\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\175\004\000\000\000\000\008\008\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\138\038\242\038\ +\090\039\034\016\245\040\194\039\080\036\197\036\057\037\173\037\ +\034\033\244\029\104\030\034\038\150\033\011\034\042\040\220\030\ +\127\034\243\034\104\035\000\000\000\000\081\031\000\000\000\000\ +\085\001\000\000\239\255\239\255\088\041\000\000\000\000\000\000\ +\000\000\244\019\000\000\000\000\000\000\104\025\221\025\000\000\ +\000\000\000\000\128\024\000\000\000\000\146\040\045\008\117\011\ +\057\008\000\000\000\000\124\012\096\007\012\043\000\000\000\000\ +\000\000\000\000\000\000\000\000\175\004\000\000\239\255\000\000\ +\000\000\000\000\000\000\061\014\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\173\061\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\230\046\000\000\000\000\000\000\000\000\073\047\ +\000\000\000\000\000\000\000\000\172\047\000\000\000\000\000\000\ +\000\000\000\000\156\255\000\000\000\000\245\000\090\001\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\016\001\000\000\067\006\000\000\202\000\000\000\000\000\000\000\ +\118\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\045\008\ +\023\008\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\139\058\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\197\031\ +\000\000\000\000\000\000\147\071\000\000\204\005\000\000\000\000\ +\000\000\000\000\000\000\086\002\000\000\000\000\217\255\000\000\ +\067\000\000\000\000\000\006\000\000\000\144\000\000\000\000\000\ +\000\000\000\000\000\000\155\006\029\008\000\000\000\000\000\000\ +\000\000\170\005\000\000\000\000\230\057\028\007\000\000\188\006\ +\000\000\019\004\003\001\018\001\062\001\000\000\000\000\000\000\ +\089\075\204\058\000\000\000\000\000\000\000\000\000\000\215\059\ +\000\000\000\000\000\000\216\005\215\059\089\075\159\005\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\095\001\000\000\199\006\000\000\230\002\ +\000\000\000\000\000\000\230\057\000\000\000\000\045\008\045\008\ +\000\000\142\081\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\219\005\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\012\043\ +\000\000\000\000\045\008\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\230\001\ +\000\000\000\000\008\001\000\000\147\001\000\000\000\000\017\048\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\182\000\ +\000\000\002\001\000\000\217\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\069\008\187\054\000\000\ +\106\055\000\000\000\000\189\007\139\058\000\000\215\059\000\000\ +\000\000\009\000\000\000\250\255\040\008\040\008\254\255\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\120\046\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\172\000\000\000\000\000\083\008\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\215\059\253\058\000\000\ +\138\008\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\148\077\018\005\147\071\079\002\134\003\168\004\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\182\009\000\000\ +\000\000\000\000\000\000\215\059\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\082\056\253\058\000\000\000\000\105\020\000\000\ +\000\000\221\020\000\000\081\021\000\000\000\000\000\000\192\041\ +\000\000\198\021\000\000\058\022\000\000\174\022\000\000\000\000\ +\000\000\000\000\252\004\000\000\197\006\000\000\175\004\246\006\ +\000\000\089\008\000\000\000\000\252\052\012\043\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\153\001\000\000\ +\000\000\000\000\238\063\000\000\000\000\099\008\116\048\000\000\ +\000\000\000\000\000\000\230\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\023\008\000\000\ +\000\000\000\000\000\000\000\000\253\058\000\000\000\000\000\000\ +\000\000\000\000\085\005\000\000\000\000\215\059\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\197\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\152\006\000\000\170\003\000\000\032\006\000\000\000\000\ +\117\006\000\000\000\000\057\032\007\059\000\000\000\000\000\000\ +\000\000\000\000\000\000\248\005\000\000\038\004\168\004\117\004\ +\168\004\000\000\174\032\159\005\000\000\087\008\000\000\208\255\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\019\041\000\000\000\000\ +\000\000\208\255\019\041\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\144\016\215\048\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\037\015\059\008\000\000\ +\000\000\236\054\000\000\189\011\000\000\000\000\000\000\137\073\ +\000\000\028\075\000\000\047\003\000\000\000\000\027\058\110\053\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\069\059\215\059\000\000\000\000\058\000\000\000\000\000\ +\000\000\017\002\000\000\000\000\000\000\035\042\001\017\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\131\056\000\000\ +\000\000\000\000\168\004\000\000\168\004\072\008\000\000\069\008\ +\000\000\000\000\000\000\000\000\000\000\000\000\100\008\245\011\ +\184\056\000\000\237\056\000\000\000\000\147\016\253\058\000\000\ +\000\000\000\000\253\058\253\058\000\000\134\042\238\042\081\043\ +\000\000\035\023\000\000\151\023\000\000\011\024\180\043\028\044\ +\127\044\019\041\079\017\116\050\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\253\058\ +\000\000\000\000\119\002\146\003\000\000\194\002\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\146\003\000\000\ +\002\004\000\000\000\000\182\053\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\020\006\000\000\ +\094\008\072\008\000\000\101\008\069\008\000\000\147\016\000\000\ +\056\057\109\057\162\003\069\008\000\000\024\056\000\000\000\000\ +\000\000\234\012\215\059\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\253\058\000\000\000\000\000\000\000\000\ +\136\049\194\049\000\000\010\078\000\000\000\000\000\000\118\057\ +\012\043\000\000\000\000\019\041\000\000\000\000\000\000\252\007\ +\000\000\000\000\000\000\000\000\000\000\000\000\080\058\000\000\ +\030\055\000\000\000\000\000\000\252\007\000\000\000\000\000\000\ +\000\000\240\053\219\002\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\172\006\000\000\168\004\000\000\000\000\000\000\ +\000\000\000\000\000\000\024\056\000\000\000\000\000\000\000\000\ +\000\000\234\012\000\000\129\058\000\000\000\000\000\000\000\000\ +\000\000\226\044\074\045\173\045\000\000\000\000\000\000\000\000\ +\118\057\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\253\005\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\046\008\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\069\008\168\057\ +\000\000\000\000\000\000\129\058\129\058\000\000\252\049\000\000\ +\000\000\000\000\148\077\223\005\038\004\117\004\005\004\000\000\ +\000\000\000\000\042\054\000\000\000\000\000\000\111\005\000\000\ +\000\000\000\000\000\000\000\000\193\004\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\058\050\129\058\000\000\000\000\ +\000\000\000\000\000\000\104\008\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\077\009\186\010\ +\000\000\000\000\000\000\164\055\005\004\005\004\107\008\109\008\ +\000\000\110\008\069\008\000\000\005\004\100\054\000\000\000\000\ +\164\005\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\095\004\000\000\ +\005\004\000\000\000\000\000\000\000\000\050\009\222\010" +let yygindex = "\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\033\000\ +\215\255\000\000\089\000\072\000\013\006\049\009\060\000\000\000\ +\214\255\126\000\233\001\099\253\000\000\217\254\078\006\071\255\ +\127\008\195\013\029\254\247\255\098\004\194\013\074\252\051\000\ +\093\000\023\000\026\000\034\000\000\000\000\000\000\000\000\000\ +\045\000\047\000\000\000\049\000\000\000\002\000\013\000\088\007\ +\093\001\000\000\000\000\000\000\000\000\000\000\000\000\052\000\ +\000\000\000\000\000\000\000\000\000\000\014\255\005\252\000\000\ +\000\000\000\000\027\000\000\000\000\000\142\254\251\253\032\252\ +\115\251\156\251\083\255\000\000\226\003\000\000\176\004\175\251\ +\113\255\059\004\000\000\000\000\000\000\000\000\000\000\000\000\ +\107\003\015\000\026\251\047\255\103\253\199\251\017\253\135\252\ +\095\251\043\254\247\003\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\046\000\200\006\ +\003\006\006\006\000\000\000\000\078\255\022\000\000\000\168\255\ +\184\001\059\253\000\254\108\010\156\012\000\000\000\000\000\000\ +\110\255\049\008\009\013\119\007\031\000\094\255\207\000\159\254\ +\000\000\080\008\100\007\216\011\115\253\000\000\078\254\000\000\ +\000\000\000\000\050\004\009\006\163\255\164\004\000\000\000\000\ +\000\000\000\000\073\000\000\000\235\007\157\255\254\007\021\007\ +\045\009\000\000\000\000\198\004\000\000\000\000\085\008\213\253\ +\190\005\138\251\021\251\213\251\011\253\000\000\097\253\000\000\ +\122\005\000\000\000\000\046\251\066\255\001\253\251\006\041\008\ +\000\000\000\000\099\004\000\000\000\000\137\004\078\252\000\000\ +\066\004\017\005\000\000\146\253\235\012\133\255\000\000\071\006\ +\128\255\220\254\141\255\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\082\255\000\000" +let yytablesize = 21372 +let yytable = "\188\000\ +\019\002\185\001\188\000\108\000\188\000\188\000\188\000\161\001\ +\248\001\188\000\188\000\188\000\188\000\188\000\109\000\188\000\ +\200\001\127\002\180\001\010\002\162\001\127\003\188\000\002\002\ +\102\000\125\002\188\000\103\000\001\002\188\000\188\000\188\000\ +\193\000\056\000\213\003\104\000\192\000\040\002\009\003\188\000\ +\188\000\216\000\160\001\188\000\188\000\171\001\105\000\209\000\ +\106\000\166\001\107\000\171\004\129\003\112\000\222\003\196\003\ +\136\001\194\001\030\002\223\000\031\002\085\003\127\000\133\000\ +\124\004\170\003\064\001\224\004\140\001\186\001\219\001\014\005\ +\133\004\005\004\125\000\132\000\021\001\159\000\065\001\112\005\ +\056\001\158\005\075\005\162\005\188\000\188\000\188\000\188\000\ +\154\001\188\000\156\001\124\000\163\001\063\000\134\002\063\000\ +\063\000\113\003\051\000\108\000\051\002\201\003\037\002\023\003\ +\124\001\054\001\128\001\129\001\075\001\090\003\109\000\108\000\ +\165\005\090\005\005\002\089\000\143\001\128\005\049\004\040\003\ +\102\000\098\003\109\000\103\000\209\003\224\002\143\001\161\002\ +\089\004\162\002\149\000\104\000\102\000\054\004\073\005\103\000\ +\036\005\054\002\063\000\187\001\062\001\011\005\105\000\104\000\ +\106\000\138\001\107\000\145\001\021\002\112\000\076\001\188\000\ +\188\000\170\001\105\000\219\001\106\000\169\005\107\000\070\001\ +\237\004\112\000\114\005\225\001\230\002\052\002\151\005\055\004\ +\099\005\142\001\182\001\180\005\059\002\186\000\224\001\126\005\ +\165\001\010\000\234\001\243\001\040\003\191\005\234\005\023\004\ +\186\000\220\001\127\000\188\000\153\001\221\001\133\000\103\003\ +\133\000\035\004\186\000\024\003\222\001\201\003\128\002\223\001\ +\152\001\207\001\186\000\243\001\244\001\188\002\142\001\165\005\ +\143\001\103\003\235\001\143\001\050\004\090\003\245\001\200\002\ +\145\001\151\001\168\003\076\001\110\002\063\000\090\004\076\001\ +\114\002\076\001\151\001\014\002\244\001\232\002\037\005\231\001\ +\232\001\104\003\076\005\207\005\138\001\200\002\245\001\022\002\ +\138\001\015\004\173\002\145\001\218\005\035\004\219\001\186\000\ +\087\003\088\003\219\001\104\003\155\005\151\001\197\003\246\001\ +\196\005\040\006\247\001\053\002\118\003\141\001\200\002\231\004\ +\142\001\221\005\070\004\239\001\188\000\188\000\173\002\157\001\ +\200\002\003\004\184\002\006\002\226\000\024\004\208\005\246\001\ +\223\000\163\001\247\001\114\005\115\003\040\005\104\001\036\004\ +\042\005\009\003\188\000\221\001\134\001\204\002\198\003\071\001\ +\189\002\192\002\141\001\193\002\140\004\173\002\204\002\173\002\ +\188\000\182\002\193\000\145\001\168\002\188\000\145\001\145\001\ +\211\002\200\002\104\005\173\002\200\002\151\001\221\001\160\001\ +\188\000\151\001\147\001\212\001\181\002\077\001\160\001\064\001\ +\160\001\239\002\009\003\152\004\016\004\212\001\002\002\171\001\ +\171\001\029\004\030\004\095\004\227\000\165\005\222\005\226\000\ +\119\003\218\002\100\003\223\000\234\001\147\001\175\002\234\001\ +\231\005\234\001\051\000\234\001\141\001\234\001\104\001\034\003\ +\013\006\237\005\140\005\142\005\150\002\068\004\152\002\063\000\ +\153\002\063\000\019\006\089\000\069\002\206\001\046\003\118\003\ +\238\005\170\004\070\002\122\003\051\000\121\004\221\001\134\001\ +\055\002\059\006\221\001\234\001\120\006\234\001\122\002\186\000\ +\047\006\064\002\118\002\119\002\068\002\089\000\123\002\144\001\ +\124\001\214\001\140\004\177\005\063\000\234\001\071\003\227\000\ +\105\005\144\001\228\002\049\002\129\002\147\001\061\006\212\001\ +\147\001\147\001\212\001\049\006\076\001\214\005\140\002\188\000\ +\187\001\017\002\101\002\137\001\018\002\149\003\104\002\100\006\ +\195\005\102\006\220\001\215\005\030\000\220\001\221\001\021\005\ +\127\002\190\000\130\002\170\001\170\001\222\001\051\000\033\004\ +\223\001\225\001\000\006\131\002\146\001\105\001\058\005\170\003\ +\188\000\207\001\110\006\125\003\225\001\207\001\122\004\089\000\ +\220\001\207\001\133\000\207\001\133\000\087\006\133\000\207\001\ +\213\001\225\001\225\001\207\001\132\002\233\004\234\001\146\001\ +\234\001\118\003\213\001\136\001\207\001\218\001\133\002\186\000\ +\114\001\229\002\143\002\144\001\214\001\141\002\144\001\173\000\ +\186\000\225\001\139\005\076\001\215\001\076\001\027\003\076\001\ +\246\005\050\002\220\001\076\006\062\006\234\001\221\001\234\001\ +\010\003\215\002\137\002\216\005\140\002\222\001\137\001\081\002\ +\223\001\150\003\137\001\220\004\240\003\009\003\003\006\157\001\ +\220\001\135\002\207\001\157\001\220\001\129\002\127\002\157\001\ +\081\002\157\001\170\002\034\004\228\005\157\001\188\000\146\001\ +\204\003\108\000\146\001\146\001\207\001\207\001\024\006\207\001\ +\207\001\216\000\157\001\200\001\109\000\030\000\205\003\033\004\ +\136\003\137\003\190\000\130\002\213\001\072\004\102\000\213\001\ +\186\000\103\000\207\001\196\004\131\002\133\002\136\001\053\004\ +\218\001\104\000\160\001\063\000\218\001\061\004\166\005\135\003\ +\143\002\229\004\002\002\141\002\105\000\107\001\106\000\215\001\ +\107\000\031\003\050\003\112\000\221\003\132\002\137\005\216\000\ +\157\001\216\002\186\000\236\001\215\002\209\000\215\002\133\002\ +\137\002\007\003\186\000\216\002\087\004\081\002\171\002\211\003\ +\076\003\078\003\157\001\157\001\117\003\157\001\157\001\135\002\ +\109\001\096\002\041\003\002\002\237\001\206\001\102\005\234\001\ +\220\003\206\001\234\001\241\003\106\003\206\001\206\003\206\001\ +\157\001\191\001\047\002\206\001\076\004\176\004\118\003\206\001\ +\175\003\186\000\175\002\094\004\203\001\203\001\015\003\017\003\ +\206\001\083\003\103\004\082\003\243\001\253\004\032\004\197\004\ +\234\003\227\001\228\001\133\002\193\003\028\003\031\001\236\005\ +\023\003\063\000\123\003\041\005\097\002\142\004\120\001\121\001\ +\127\001\019\004\244\005\020\004\186\000\225\001\252\001\041\003\ +\051\006\251\001\111\001\103\003\088\004\216\002\091\003\092\003\ +\016\002\250\003\215\002\096\002\023\003\096\002\206\001\225\001\ +\244\005\225\001\252\001\225\001\186\000\173\004\192\001\225\001\ +\077\004\169\005\092\006\007\003\186\000\052\006\142\003\170\002\ +\206\001\206\001\133\000\206\001\206\001\187\000\251\003\252\003\ +\236\003\031\000\124\003\170\002\104\004\104\003\008\004\234\001\ +\188\004\035\000\031\000\053\006\009\003\004\004\206\001\077\004\ +\235\003\021\003\035\000\127\001\253\003\051\001\097\002\086\004\ +\097\002\140\003\044\006\076\001\023\003\225\001\081\004\127\003\ +\032\006\002\002\234\001\010\003\180\001\013\000\110\004\191\005\ +\253\004\044\006\069\004\094\006\071\001\187\001\079\004\187\001\ +\180\004\023\003\182\004\184\004\054\006\066\004\025\003\120\004\ +\018\000\185\002\187\001\225\001\222\004\254\003\129\003\074\003\ +\160\001\199\005\153\005\227\004\190\001\228\003\162\003\163\003\ +\198\002\025\003\119\005\024\000\010\003\212\005\207\003\133\003\ +\025\003\002\002\093\003\224\000\189\004\083\004\220\003\225\001\ +\138\001\222\001\154\005\189\001\243\001\185\003\186\000\144\003\ +\168\000\141\003\071\001\009\003\052\004\255\003\025\003\025\003\ +\236\001\155\003\171\002\195\003\023\003\169\000\188\000\077\004\ +\000\004\016\005\025\003\009\003\253\005\244\001\255\005\025\003\ +\171\002\167\005\025\003\171\002\025\003\172\002\047\000\245\001\ +\122\002\237\001\106\003\230\002\200\004\171\002\190\001\230\002\ +\166\000\249\001\063\000\172\002\186\000\195\002\172\002\108\000\ +\231\002\220\001\184\003\122\002\243\005\221\001\224\000\109\003\ +\172\002\122\002\109\000\196\002\222\001\077\002\234\001\223\001\ +\009\003\106\003\094\002\187\001\102\000\025\003\085\002\103\000\ +\246\001\071\001\141\001\247\001\122\002\059\004\187\001\104\000\ +\094\002\048\005\225\001\120\001\121\001\013\004\211\002\253\004\ +\211\002\187\001\105\000\045\005\106\000\225\001\107\000\159\004\ +\075\004\112\000\025\004\222\001\232\002\171\002\223\001\201\005\ +\232\002\171\002\111\003\122\002\122\002\253\004\211\002\186\000\ +\090\006\091\006\164\002\234\001\183\002\190\000\187\001\091\005\ +\172\002\007\002\225\001\143\001\172\002\122\002\122\002\122\002\ +\094\002\098\005\186\000\002\002\241\002\242\002\211\002\094\002\ +\110\004\185\000\012\004\197\002\107\003\201\002\203\002\205\002\ +\122\002\030\000\002\002\234\001\011\003\209\002\186\000\008\002\ +\017\000\031\005\094\002\124\005\185\000\220\001\236\004\166\000\ +\249\001\221\001\191\000\185\000\164\002\164\002\074\005\248\003\ +\222\001\009\004\129\006\223\001\186\000\071\001\106\003\010\003\ +\146\001\178\003\243\002\103\003\141\005\255\002\164\002\190\001\ +\234\001\185\000\234\001\179\003\009\002\010\004\047\005\253\004\ +\014\006\071\001\198\005\051\000\180\001\185\000\190\001\147\001\ +\180\001\253\004\187\001\230\002\180\001\185\000\180\001\185\000\ +\025\003\029\003\180\001\180\001\135\004\136\004\180\001\129\002\ +\043\006\007\003\186\000\186\000\149\005\104\003\015\005\180\001\ +\002\002\007\002\146\004\147\004\048\000\110\004\092\005\051\000\ +\025\003\153\004\125\002\193\004\057\003\190\001\025\003\030\000\ +\222\002\234\001\167\004\106\003\190\000\130\002\023\003\249\003\ +\185\000\030\000\253\004\106\003\091\004\023\003\131\002\008\002\ +\220\001\023\003\025\003\186\000\221\001\234\001\180\001\029\000\ +\186\000\023\003\223\002\222\001\232\002\180\001\223\001\103\003\ +\023\003\095\005\225\001\025\003\025\003\176\005\145\004\132\002\ +\166\000\249\001\025\003\025\003\208\003\025\003\015\003\180\001\ +\180\001\133\002\180\001\180\001\009\002\025\003\023\003\023\003\ +\215\000\052\003\168\004\051\000\253\004\004\003\150\000\234\004\ +\175\000\002\002\023\003\106\006\059\005\180\001\053\003\023\003\ +\129\002\104\003\023\003\161\001\023\003\178\004\186\000\058\003\ +\215\001\183\001\163\005\038\006\159\005\077\002\012\005\214\003\ +\162\001\200\005\243\001\243\004\106\003\025\003\025\003\187\001\ +\030\000\025\003\170\005\216\001\213\005\190\000\130\002\239\003\ +\107\006\059\003\092\004\246\003\054\003\143\004\115\005\131\002\ +\225\001\039\006\225\001\244\001\225\001\023\003\187\001\225\001\ +\158\001\186\000\023\003\106\003\192\005\245\001\051\000\148\003\ +\187\001\200\002\234\001\023\003\234\001\165\001\234\001\144\004\ +\132\002\165\001\028\004\166\000\249\001\220\001\203\001\159\003\ +\200\002\221\001\133\002\165\001\161\001\140\003\010\003\200\002\ +\222\001\193\001\020\005\223\001\165\001\211\002\023\005\211\002\ +\006\005\162\001\002\002\027\005\238\002\146\000\246\001\210\005\ +\211\002\247\001\017\002\211\002\106\003\018\002\200\002\176\001\ +\200\002\106\003\188\003\023\003\038\005\039\005\002\002\160\001\ +\144\002\234\001\200\002\220\003\163\000\044\005\206\002\165\000\ +\190\001\150\000\242\005\165\001\150\000\234\001\150\000\150\000\ +\207\002\225\005\122\005\186\000\145\002\211\002\234\001\119\006\ +\188\000\186\000\234\001\022\005\053\005\131\005\211\002\026\005\ +\001\006\150\000\166\000\249\001\021\003\175\000\175\000\163\001\ +\175\000\054\003\187\000\200\002\187\001\181\001\200\002\198\001\ +\187\001\139\004\175\000\175\000\150\000\010\003\164\001\021\003\ +\186\000\036\006\164\001\150\000\077\002\124\001\021\003\002\002\ +\007\002\164\001\025\006\197\000\210\005\010\003\106\003\146\002\ +\187\001\022\001\175\000\175\000\147\002\164\001\013\002\051\000\ +\050\005\150\000\150\000\103\006\021\003\002\002\109\003\187\001\ +\030\000\186\000\220\003\065\005\051\000\150\000\008\002\029\000\ +\021\003\188\001\029\000\110\003\017\006\150\000\195\001\150\000\ +\021\003\186\000\021\003\104\006\029\000\029\000\042\006\186\000\ +\029\000\106\003\010\003\128\006\164\001\049\005\236\001\023\001\ +\106\003\029\000\029\000\029\000\029\000\024\001\196\000\006\005\ +\187\000\089\001\090\001\009\002\138\005\023\003\122\005\029\000\ +\029\000\111\003\051\000\211\002\004\003\129\002\102\001\237\001\ +\150\000\196\000\146\005\021\003\147\005\186\000\131\005\214\000\ +\196\000\084\004\186\000\029\000\211\002\023\003\029\000\226\001\ +\029\000\029\000\029\000\029\000\158\001\030\000\187\001\095\001\ +\029\000\029\000\190\000\130\002\177\002\131\005\196\000\029\000\ +\006\005\025\002\215\000\103\001\131\002\023\003\211\002\187\001\ +\100\001\124\001\196\000\029\000\234\001\029\000\217\004\029\000\ +\029\000\196\000\196\000\172\004\196\000\025\003\144\005\021\003\ +\186\000\232\005\122\005\029\000\235\005\132\002\029\000\255\002\ +\230\001\146\000\029\000\229\001\023\003\186\000\026\002\133\002\ +\218\004\178\002\021\003\187\004\161\005\025\003\234\001\023\003\ +\047\002\021\003\025\003\025\003\050\006\131\005\138\003\010\006\ +\162\004\164\004\166\004\234\001\025\003\196\000\169\004\220\005\ +\131\005\234\001\025\003\047\002\255\002\006\005\187\001\021\003\ +\021\003\187\001\047\002\047\002\026\003\110\002\006\005\111\002\ +\181\001\011\006\234\001\021\003\023\003\025\003\187\001\135\002\ +\198\001\112\002\234\001\021\003\255\002\021\003\243\001\025\003\ +\047\002\047\002\223\003\077\002\029\006\030\006\224\003\033\006\ +\034\006\011\003\017\004\102\001\047\002\225\003\150\000\187\001\ +\226\003\143\003\241\001\047\002\047\002\150\000\047\002\150\000\ +\252\001\227\003\198\001\150\004\224\005\055\006\150\000\150\000\ +\007\004\150\000\227\005\023\003\023\003\051\000\021\003\015\002\ +\056\006\020\006\023\003\243\001\252\001\150\000\023\003\018\004\ +\130\005\150\000\234\001\234\001\240\005\175\000\175\000\023\003\ +\026\006\234\001\234\001\234\001\234\001\023\003\077\002\047\002\ +\186\000\131\005\211\002\021\006\156\005\234\001\023\003\051\000\ +\146\003\011\003\187\005\187\001\023\003\146\000\175\000\175\000\ +\175\000\023\003\155\001\187\001\234\001\188\005\175\000\009\006\ +\211\002\220\001\073\003\081\006\211\002\221\001\158\001\023\002\ +\211\002\211\002\211\002\211\002\222\001\187\001\187\001\223\001\ +\113\001\157\005\122\005\190\000\122\005\175\000\175\000\211\002\ +\065\006\023\003\175\000\108\006\131\005\215\000\175\000\187\001\ +\023\003\013\002\074\006\006\005\209\005\011\003\214\002\134\003\ +\215\002\187\001\150\000\150\000\005\006\187\001\024\002\118\006\ +\139\001\198\001\216\002\146\000\187\001\187\001\211\002\088\006\ +\000\005\150\000\175\000\110\005\025\003\125\006\126\006\186\000\ +\058\004\148\001\154\001\175\000\027\002\215\002\196\002\196\002\ +\155\001\013\002\097\006\216\002\202\002\196\002\001\005\029\002\ +\186\000\178\002\030\000\014\000\069\006\175\000\002\005\183\001\ +\003\005\178\002\196\002\048\002\112\006\186\000\051\000\077\006\ +\196\002\187\000\015\000\016\000\103\003\004\005\023\003\018\002\ +\146\000\025\003\215\002\013\003\006\005\185\002\048\002\023\000\ +\216\002\023\003\019\003\196\002\196\002\048\002\048\002\069\006\ +\069\006\148\005\058\001\186\000\082\000\095\006\096\006\132\006\ +\175\000\023\003\031\000\051\000\051\000\074\001\164\003\050\005\ +\157\002\011\002\035\000\048\002\048\002\036\002\104\003\147\000\ +\039\000\109\005\089\000\113\006\186\000\030\000\042\000\048\002\ +\181\001\245\004\110\005\135\002\181\001\051\000\048\002\048\002\ +\181\001\048\002\181\001\011\002\123\006\187\000\181\001\181\001\ +\247\004\147\000\181\001\242\003\089\000\083\000\127\006\043\002\ +\252\001\069\006\050\000\181\001\183\000\053\000\041\002\134\006\ +\135\006\150\000\243\003\244\003\150\000\072\002\073\002\074\002\ +\075\002\217\001\135\002\150\000\252\001\150\000\150\000\146\000\ +\166\000\076\002\048\002\161\000\057\002\023\003\183\000\151\003\ +\023\003\023\003\186\000\150\000\218\001\023\003\023\003\065\002\ +\175\000\152\003\181\001\210\001\058\002\150\000\161\000\210\001\ +\127\005\181\001\063\004\187\000\023\003\161\000\023\003\175\000\ +\175\000\210\001\023\003\064\003\245\002\246\002\023\003\023\003\ +\023\003\064\004\210\001\181\001\181\001\077\002\181\001\181\001\ +\065\003\060\002\155\001\161\000\161\000\023\003\155\001\150\000\ +\139\002\150\000\155\001\023\003\155\001\102\001\150\000\161\000\ +\155\001\181\001\025\003\175\000\155\001\071\002\161\000\161\000\ +\140\002\161\000\120\002\150\000\175\000\155\001\175\000\120\002\ +\189\000\054\003\025\003\196\000\023\003\198\000\199\000\200\000\ +\013\002\215\004\201\000\202\000\203\000\204\000\205\000\220\001\ +\206\000\245\002\248\002\221\001\017\002\007\003\186\000\018\002\ +\209\001\126\004\222\001\057\001\209\001\223\001\059\001\060\001\ +\061\001\035\006\161\000\215\000\155\001\159\002\209\001\175\000\ +\066\001\067\001\154\001\155\001\068\001\069\001\154\001\209\001\ +\186\000\160\002\154\001\163\002\154\001\135\002\013\002\103\003\ +\154\001\154\001\164\002\167\001\063\003\155\001\155\001\167\001\ +\155\001\155\001\064\003\093\005\151\002\154\001\150\000\198\004\ +\165\002\011\003\128\000\198\000\190\005\186\000\094\005\065\003\ +\172\002\199\004\167\001\155\001\173\002\132\001\133\001\134\001\ +\135\001\174\002\137\001\180\002\164\002\146\000\198\000\176\001\ +\186\002\104\003\185\002\176\001\082\000\198\000\215\002\082\000\ +\135\002\190\002\176\001\191\002\154\001\176\001\135\002\225\002\ +\215\002\082\000\227\002\154\001\002\003\082\000\176\001\150\000\ +\186\000\071\001\150\000\198\000\198\000\237\002\082\000\082\000\ +\082\000\082\000\011\003\150\000\018\003\154\001\154\001\198\000\ +\154\001\154\001\025\003\025\003\150\000\082\000\198\000\198\000\ +\030\003\198\000\175\000\166\002\167\002\083\000\032\003\043\003\ +\196\001\197\001\035\003\154\001\044\003\176\001\048\003\044\002\ +\082\000\045\002\083\000\082\000\247\002\249\002\083\000\082\000\ +\082\000\069\003\051\003\046\002\045\003\175\000\082\000\083\000\ +\083\000\083\000\083\000\047\003\082\000\115\002\008\003\116\002\ +\049\003\070\003\198\000\219\002\240\001\220\002\083\000\175\001\ +\082\000\117\002\082\000\175\001\082\000\082\000\051\000\221\002\ +\175\000\037\004\175\001\038\004\090\001\175\001\135\002\062\003\ +\082\000\083\000\150\000\082\000\083\000\039\004\094\003\083\000\ +\083\000\083\000\150\000\086\003\175\000\175\000\083\000\083\000\ +\101\003\175\000\175\000\175\000\108\003\083\000\150\000\175\000\ +\096\004\114\003\097\004\135\002\116\003\175\000\135\002\120\003\ +\130\003\083\000\139\003\083\000\098\004\083\000\083\000\094\000\ +\120\002\150\000\007\003\186\000\071\001\175\001\192\001\120\002\ +\145\003\083\000\120\002\153\003\083\000\175\000\095\000\016\000\ +\083\000\222\001\160\003\172\003\120\002\038\002\039\002\173\003\ +\120\002\047\002\186\003\096\000\245\002\177\002\199\003\013\002\ +\054\003\120\002\120\002\120\002\120\002\077\002\212\003\230\003\ +\229\003\231\003\232\003\048\002\233\003\174\000\031\000\237\003\ +\120\002\070\000\014\004\021\004\027\004\051\004\035\000\047\004\ +\060\004\056\002\105\003\067\004\097\000\010\000\063\002\080\004\ +\208\000\082\004\042\000\120\002\178\002\135\002\120\002\085\004\ +\177\002\120\002\120\002\120\002\135\002\102\004\111\004\116\004\ +\120\002\120\002\098\000\105\004\117\004\150\000\219\000\120\002\ +\127\004\125\004\130\004\150\000\132\004\149\004\099\000\014\000\ +\135\002\053\000\131\004\120\002\164\002\120\002\158\004\120\002\ +\120\002\177\004\190\004\195\004\164\002\192\004\015\000\016\000\ +\203\004\164\002\204\004\120\002\250\004\005\005\120\002\175\000\ +\205\004\206\004\120\002\023\000\214\004\150\000\164\002\207\004\ +\164\002\164\002\211\004\212\004\213\004\221\004\175\000\150\000\ +\225\004\226\004\228\004\150\000\241\004\164\002\031\000\013\005\ +\235\004\074\001\029\005\018\005\013\002\101\005\035\000\024\005\ +\043\005\077\005\025\005\117\005\039\000\028\005\021\003\072\005\ +\164\002\046\005\042\000\164\002\116\005\120\005\164\002\164\002\ +\164\002\121\005\123\005\133\005\136\005\079\003\164\002\143\005\ +\169\002\145\005\129\000\121\000\164\002\164\005\059\005\184\001\ +\202\005\013\002\135\002\205\005\150\000\181\005\050\000\182\005\ +\164\002\053\000\183\005\206\005\164\002\164\002\223\005\150\000\ +\230\005\199\001\174\000\174\000\233\005\174\000\248\005\008\006\ +\164\002\194\002\023\006\164\002\175\000\027\006\041\006\174\000\ +\174\000\216\003\058\006\072\002\073\002\074\002\075\002\250\004\ +\135\002\013\002\023\003\254\005\063\006\066\006\012\003\076\002\ +\064\006\067\006\135\002\072\006\247\003\073\006\150\000\174\000\ +\174\000\002\004\098\006\011\002\075\006\023\003\167\005\093\006\ +\116\006\117\006\111\005\111\006\023\003\150\000\121\006\124\006\ +\120\002\150\000\130\006\120\002\131\006\051\000\089\000\008\000\ +\026\004\021\003\150\000\051\000\005\005\120\002\084\002\025\003\ +\023\003\120\002\023\003\077\002\128\000\089\000\178\002\105\002\ +\252\001\102\002\120\002\120\002\120\002\120\002\023\003\104\002\ +\033\003\023\003\023\003\023\003\065\004\175\000\023\003\036\003\ +\023\003\120\002\135\002\135\002\202\002\221\000\107\002\200\002\ +\020\002\070\000\150\000\200\002\070\000\001\000\002\000\003\000\ +\004\000\005\000\006\000\007\000\120\002\005\005\070\000\120\002\ +\201\002\178\002\120\002\120\002\120\002\201\002\150\000\150\000\ +\150\000\120\002\120\002\070\000\203\002\070\000\070\000\206\002\ +\120\002\023\003\207\002\135\002\208\002\204\002\111\005\149\001\ +\048\004\070\000\070\000\016\006\120\002\232\001\120\002\132\005\ +\120\002\120\002\184\001\217\005\101\006\006\006\072\003\192\003\ +\129\004\149\002\226\005\119\004\120\002\070\000\250\004\120\002\ +\070\000\124\002\084\003\120\002\070\000\070\000\150\000\137\004\ +\210\002\206\001\147\003\070\000\025\003\025\003\150\000\134\005\ +\201\004\070\000\005\005\025\003\250\004\141\002\175\000\208\002\ +\242\004\025\003\182\003\005\005\176\002\070\000\150\000\219\005\ +\025\003\070\000\070\000\194\005\247\005\096\005\025\003\000\000\ +\150\000\113\002\175\000\000\000\000\000\070\000\150\000\000\000\ +\070\000\000\000\174\004\175\004\000\000\000\000\000\000\000\000\ +\000\000\025\003\025\003\021\003\000\000\000\000\000\000\000\000\ +\150\000\000\000\000\000\186\004\000\000\000\000\000\000\148\002\ +\000\000\000\000\021\003\021\003\000\000\000\000\000\000\000\000\ +\194\004\000\000\000\000\000\000\150\000\000\000\150\000\021\003\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\202\004\000\000\000\000\150\000\000\000\000\000\250\004\150\000\ +\000\000\195\000\021\003\175\000\000\000\021\003\000\000\000\000\ +\250\004\000\000\021\003\000\000\000\000\000\000\135\002\184\001\ +\021\003\000\000\174\000\174\000\195\000\000\000\021\003\000\000\ +\000\000\175\000\223\004\195\000\162\000\000\000\173\002\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\021\003\021\003\ +\000\000\000\000\000\000\174\000\174\000\174\000\000\000\162\000\ +\000\000\195\000\021\003\174\000\000\000\021\003\162\000\000\000\ +\000\000\250\004\217\002\000\000\000\000\195\000\000\000\000\000\ +\005\005\000\000\177\000\000\000\195\000\195\000\194\000\195\000\ +\000\000\010\005\174\000\174\000\162\000\162\000\000\000\174\000\ +\150\000\000\000\017\005\174\000\000\000\194\000\011\002\000\000\ +\162\000\000\000\000\000\150\000\000\000\000\000\199\001\162\000\ +\162\000\000\000\162\000\000\000\000\000\199\001\000\000\000\000\ +\194\000\000\000\000\000\250\004\000\000\000\000\000\000\174\000\ +\195\000\000\000\000\000\150\000\150\000\000\000\000\000\022\004\ +\174\000\150\000\150\000\000\000\000\000\000\000\011\002\000\000\ +\000\000\000\000\111\005\150\000\111\005\232\001\000\000\000\000\ +\232\001\005\005\174\000\162\000\000\000\061\003\194\000\150\000\ +\194\000\194\000\232\001\055\005\000\000\057\005\208\000\000\000\ +\232\001\014\003\000\000\000\000\000\000\000\000\000\000\232\001\ +\150\000\232\001\232\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\150\000\000\000\000\000\150\000\232\001\000\000\ +\000\000\000\000\000\000\150\000\150\000\174\000\000\000\000\000\ +\000\000\000\000\097\005\000\000\000\000\000\000\000\000\100\005\ +\000\000\232\001\000\000\000\000\232\001\000\000\094\002\000\000\ +\232\001\232\001\000\000\000\000\000\000\000\000\000\000\232\001\ +\136\000\000\000\137\000\138\000\030\000\232\001\139\000\000\000\ +\000\000\140\000\141\000\173\002\000\000\000\000\000\000\177\000\ +\177\000\232\001\177\000\000\000\000\000\232\001\232\001\000\000\ +\000\000\000\000\142\000\000\000\177\000\177\000\000\000\135\005\ +\000\000\232\001\143\000\144\000\232\001\000\000\000\000\000\000\ +\194\000\000\000\145\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\177\000\003\002\146\000\147\000\ +\000\000\194\000\000\000\000\000\199\001\174\000\000\000\150\005\ +\000\000\152\005\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\174\000\174\000\173\002\000\000\ +\173\002\173\002\173\002\168\005\000\000\000\000\173\002\178\005\ +\179\005\000\000\000\000\173\002\000\000\000\000\000\000\173\002\ +\173\002\173\002\000\000\000\000\000\000\180\003\184\005\000\000\ +\173\002\173\002\173\002\173\002\000\000\000\000\000\000\000\000\ +\174\000\000\000\173\002\000\000\011\002\000\000\000\000\173\002\ +\000\000\174\000\000\000\174\000\197\005\000\000\173\002\173\002\ +\000\000\000\000\000\000\000\000\000\000\011\002\000\000\000\000\ +\194\000\000\000\173\002\000\000\000\000\173\002\173\002\000\000\ +\173\002\173\002\173\002\000\000\173\002\000\000\000\000\173\002\ +\173\002\000\000\000\000\000\000\000\000\194\000\173\002\000\000\ +\000\000\000\000\215\003\000\000\174\000\000\000\000\000\000\000\ +\000\000\173\002\173\002\000\000\173\002\173\002\173\002\173\002\ +\000\000\000\000\173\002\011\002\000\000\000\000\000\000\245\005\ +\000\000\163\000\173\002\173\002\171\000\173\002\000\000\000\000\ +\249\005\173\002\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\163\000\002\006\000\000\000\000\ +\004\006\000\000\000\000\163\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\194\000\180\000\000\000\ +\194\000\194\000\000\000\000\000\194\000\000\000\194\000\000\000\ +\000\000\163\000\163\000\000\000\062\004\000\000\000\000\000\000\ +\194\000\028\006\000\000\000\000\156\002\163\000\094\002\194\000\ +\094\002\094\002\094\002\000\000\163\000\163\000\094\002\163\000\ +\000\000\000\000\000\000\094\002\184\001\000\000\000\000\094\002\ +\094\002\094\002\000\000\000\000\000\000\194\000\000\000\174\000\ +\094\002\094\002\094\002\094\002\000\000\000\000\000\000\000\000\ +\000\000\194\000\094\002\000\000\000\000\000\000\000\000\094\002\ +\194\000\194\000\000\000\194\000\000\000\000\000\094\002\094\002\ +\163\000\000\000\174\000\000\000\000\000\000\000\000\000\177\000\ +\003\002\000\000\094\002\000\000\000\000\094\002\000\000\000\000\ +\094\002\094\002\094\002\000\000\094\002\000\000\000\000\094\002\ +\094\002\000\000\000\000\086\006\000\000\174\000\094\002\000\000\ +\177\000\177\000\177\000\000\000\194\000\000\000\000\000\000\000\ +\177\000\094\002\094\002\000\000\094\002\094\002\094\002\094\002\ +\000\000\174\000\174\000\000\000\000\000\000\000\174\000\174\000\ +\174\000\000\000\094\002\000\000\174\000\094\002\000\000\003\002\ +\177\000\094\002\174\000\000\000\003\002\000\000\000\000\000\000\ +\177\000\114\006\115\006\000\000\011\002\000\000\000\000\000\000\ +\000\000\122\006\000\000\180\000\180\000\000\000\180\000\000\000\ +\000\000\011\002\174\000\000\000\000\000\000\000\000\000\000\000\ +\180\000\180\000\000\000\000\000\177\000\133\006\011\002\000\000\ +\011\002\011\002\000\000\000\000\011\002\177\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\011\002\000\000\250\001\ +\180\000\180\000\178\000\000\000\000\000\000\000\195\000\177\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\011\002\000\000\000\000\194\000\219\004\195\000\011\002\011\002\ +\011\002\000\000\000\000\000\000\171\000\000\000\011\002\171\000\ +\000\000\000\000\000\000\000\000\011\002\000\000\000\000\000\000\ +\195\000\171\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\011\002\000\000\177\000\000\000\011\002\000\000\171\000\171\000\ +\171\000\171\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\011\002\000\000\000\000\011\002\000\000\171\000\000\000\000\000\ +\000\000\011\002\184\001\000\000\174\000\000\000\195\000\000\000\ +\195\000\195\000\000\000\000\000\156\002\000\000\000\000\156\002\ +\171\000\000\000\000\000\174\000\156\002\000\000\000\000\171\000\ +\171\000\156\002\156\002\000\000\000\000\000\000\171\000\156\002\ +\000\000\011\002\177\002\000\000\171\000\000\000\156\002\179\000\ +\156\002\156\002\000\000\000\000\000\000\000\000\000\000\000\000\ +\171\000\000\000\171\000\067\002\171\000\156\002\000\000\000\000\ +\000\000\000\000\000\000\159\001\078\002\000\000\000\000\000\000\ +\171\000\000\000\177\000\171\000\000\000\000\000\011\002\000\000\ +\156\002\000\000\000\000\156\002\000\000\177\002\156\002\156\002\ +\156\002\177\000\177\000\010\000\000\000\157\001\156\002\178\000\ +\178\000\000\000\178\000\156\002\156\002\000\000\000\000\000\000\ +\000\000\174\000\000\000\000\000\178\000\178\000\000\000\000\000\ +\156\002\000\000\181\003\000\000\156\002\156\002\011\002\000\000\ +\195\000\000\000\199\001\000\000\000\000\177\000\000\000\000\000\ +\156\002\000\000\000\000\156\002\178\000\004\002\177\000\000\000\ +\003\002\195\000\000\000\000\000\136\000\000\000\137\000\138\000\ +\030\000\000\000\139\000\000\000\000\000\140\000\141\000\000\000\ +\000\000\000\000\000\000\023\003\000\000\000\000\000\000\000\000\ +\000\000\184\001\000\000\000\000\000\000\000\000\142\000\000\000\ +\023\003\000\000\000\000\000\000\000\000\010\000\143\000\144\000\ +\000\000\003\002\000\000\000\000\054\000\023\003\145\000\023\003\ +\023\003\000\000\174\000\180\000\180\000\000\000\000\000\000\000\ +\000\000\000\000\146\000\147\000\023\003\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\179\000\179\000\000\000\179\000\ +\000\000\000\000\184\001\199\002\180\000\180\000\180\000\023\003\ +\195\000\179\000\179\000\000\000\180\000\000\000\136\000\023\003\ +\137\000\138\000\030\000\000\000\139\000\023\003\081\001\158\001\ +\141\000\000\000\000\000\023\003\000\000\195\000\000\000\000\000\ +\000\000\179\000\179\000\180\000\180\000\000\000\000\000\000\000\ +\180\000\000\000\000\000\023\003\180\000\220\000\220\000\000\000\ +\000\000\144\000\087\001\088\001\089\001\090\001\078\002\023\003\ +\145\000\011\002\023\003\000\000\000\000\000\000\000\000\000\000\ +\000\000\011\002\000\000\000\000\146\000\147\000\011\002\184\001\ +\180\000\186\000\000\000\174\000\177\000\000\000\092\001\093\001\ +\184\001\038\003\000\000\011\002\000\000\011\002\011\002\000\000\ +\000\000\000\000\095\001\096\001\097\001\098\001\000\000\174\000\ +\195\000\195\000\011\002\180\000\195\000\000\000\195\000\003\002\ +\130\001\131\001\000\000\100\001\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\011\002\000\000\000\000\ +\011\002\000\000\000\000\011\002\011\002\011\002\000\000\000\000\ +\000\000\000\000\177\000\011\002\000\000\000\000\000\000\000\000\ +\159\001\011\002\186\002\000\000\190\002\000\000\038\003\159\001\ +\000\000\159\001\000\000\000\000\000\000\011\002\177\000\003\002\ +\000\000\011\002\011\002\177\000\177\000\177\000\000\000\000\000\ +\174\000\177\000\184\001\000\000\000\000\011\002\000\000\177\000\ +\011\002\000\000\000\000\000\000\000\000\000\000\000\000\178\000\ +\004\002\000\000\000\000\000\000\000\000\000\000\174\000\000\000\ +\167\001\000\000\000\000\000\000\000\000\000\000\000\000\177\000\ +\138\002\180\003\000\000\000\000\000\000\168\001\000\000\000\000\ +\178\000\178\000\178\000\000\000\081\001\000\000\000\000\000\000\ +\178\000\000\000\000\000\000\000\000\000\048\006\000\000\000\000\ +\136\000\000\000\137\000\138\000\030\000\184\001\139\000\000\000\ +\060\006\169\001\141\000\000\000\054\000\000\000\180\000\004\002\ +\178\000\088\001\089\001\090\001\004\002\000\000\000\000\000\000\ +\178\000\054\000\000\000\000\000\000\000\180\000\180\000\000\000\ +\179\002\180\003\000\000\144\000\000\000\000\000\054\000\000\000\ +\054\000\054\000\145\000\000\000\092\001\093\001\000\000\000\000\ +\000\000\000\000\000\000\000\000\178\000\054\000\146\000\147\000\ +\095\001\096\001\097\001\098\001\000\000\178\000\000\000\000\000\ +\000\000\180\000\000\000\000\000\179\000\179\000\000\000\000\000\ +\054\000\100\001\180\000\054\000\180\000\000\000\184\001\178\000\ +\054\000\003\002\000\000\000\000\000\000\000\000\054\000\000\000\ +\000\000\000\000\000\000\195\000\054\000\179\000\179\000\179\000\ +\003\002\000\000\000\000\000\000\000\000\179\000\179\000\000\000\ +\054\000\000\000\000\000\000\000\054\000\054\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\180\000\000\000\000\000\ +\054\000\000\000\178\000\054\000\179\000\179\000\000\000\000\000\ +\000\000\179\000\000\000\000\000\000\000\179\000\000\000\079\002\ +\080\002\081\002\082\002\083\002\084\002\085\002\086\002\087\002\ +\088\002\089\002\090\002\091\002\092\002\093\002\094\002\095\002\ +\096\002\097\002\098\002\099\002\182\002\102\002\000\000\000\000\ +\103\002\179\000\000\000\105\002\000\000\106\002\000\000\107\002\ +\000\000\108\002\179\000\109\002\000\000\000\000\003\002\000\000\ +\000\000\000\000\000\000\159\001\000\000\000\000\000\000\000\000\ +\126\002\000\000\000\000\000\000\179\000\000\000\000\000\186\002\ +\000\000\190\002\000\000\078\002\000\000\000\000\000\000\142\002\ +\000\000\143\002\000\000\000\000\000\000\000\000\186\002\186\002\ +\190\002\190\002\178\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\158\002\000\000\186\002\000\000\190\002\000\000\000\000\ +\180\000\178\000\178\000\000\000\138\002\000\000\000\000\179\000\ +\000\000\057\000\000\000\194\000\000\000\000\000\186\002\000\000\ +\190\002\186\002\000\000\190\002\000\000\000\000\186\002\000\000\ +\190\002\000\000\000\000\180\000\186\002\000\000\190\002\003\002\ +\000\000\000\000\186\002\213\002\190\002\178\000\000\000\000\000\ +\000\000\000\000\000\000\138\002\000\000\000\000\178\000\000\000\ +\004\002\000\000\186\002\186\002\190\002\190\002\180\000\000\000\ +\000\000\000\000\228\002\000\000\000\000\000\000\186\002\000\000\ +\190\002\186\002\212\002\190\002\213\002\000\000\000\000\000\000\ +\000\000\000\000\180\000\180\000\000\000\000\000\160\004\180\000\ +\180\000\180\000\000\000\000\000\213\002\180\000\213\002\213\002\ +\213\002\004\002\213\002\180\000\000\000\213\002\213\002\179\000\ +\000\000\003\003\136\000\006\003\137\000\138\000\030\000\000\000\ +\139\000\000\000\000\000\140\000\141\000\000\000\179\000\179\000\ +\000\000\020\003\000\000\180\000\000\000\177\001\022\003\213\002\ +\000\000\000\000\000\000\000\000\142\000\000\000\213\002\000\000\ +\003\002\000\000\000\000\000\000\143\000\144\000\000\000\194\000\ +\000\000\229\002\213\002\213\002\145\000\000\000\000\000\000\000\ +\000\000\000\000\179\000\000\000\003\002\000\000\000\000\000\000\ +\146\000\147\000\000\000\179\000\000\000\179\000\000\000\000\000\ +\000\000\000\000\000\000\220\000\220\000\000\000\000\000\000\000\ +\000\000\159\001\000\000\000\000\000\000\000\000\073\004\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\138\002\000\000\ +\000\000\247\000\000\000\000\000\182\002\000\000\000\000\182\002\ +\000\000\000\000\000\000\000\000\178\000\000\000\179\000\089\003\ +\000\000\182\002\000\000\000\000\095\003\096\003\097\003\000\000\ +\000\000\000\000\000\000\000\000\000\000\003\002\182\002\182\002\ +\182\002\182\002\000\000\099\003\000\000\180\000\102\003\004\002\ +\000\000\000\000\000\000\000\000\000\000\182\002\000\000\000\000\ +\000\000\138\002\000\000\003\002\180\000\000\000\000\000\138\002\ +\000\000\000\000\000\000\000\000\000\000\000\000\045\006\000\000\ +\182\002\000\000\178\000\000\000\173\002\000\000\182\002\182\002\ +\182\002\000\000\000\000\000\000\000\000\173\002\182\002\000\000\ +\000\000\057\000\000\000\000\000\182\002\000\000\178\000\004\002\ +\000\000\000\000\000\000\178\000\178\000\178\000\057\000\000\000\ +\182\002\178\000\182\002\000\000\182\002\173\002\000\000\178\000\ +\173\002\000\000\000\000\057\000\000\000\057\000\057\000\000\000\ +\182\002\173\002\011\002\182\002\000\000\000\000\078\006\161\003\ +\000\000\179\000\057\000\000\000\165\003\166\003\167\003\178\000\ +\000\000\014\003\180\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\183\003\000\000\057\000\000\000\000\000\ +\057\000\000\000\000\000\000\000\179\000\057\000\000\000\138\002\ +\000\000\000\000\000\000\057\000\000\000\000\000\000\000\000\000\ +\000\000\057\000\000\000\200\003\000\000\000\000\203\003\000\000\ +\000\000\000\000\000\000\000\000\000\000\057\000\000\000\179\000\ +\000\000\057\000\057\000\210\003\138\002\000\000\000\000\138\002\ +\136\000\000\000\137\000\138\000\030\000\057\000\139\000\000\000\ +\057\000\140\000\141\000\179\000\179\000\232\004\000\000\000\000\ +\179\000\179\000\179\000\000\000\000\000\000\000\179\000\000\000\ +\000\000\000\000\142\000\180\000\179\000\000\000\000\000\000\000\ +\000\000\000\000\143\000\126\003\000\000\000\000\000\000\000\000\ +\032\000\000\000\145\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\004\002\000\000\000\000\179\000\151\004\146\000\147\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\004\002\000\000\000\000\000\000\000\000\000\000\000\000\040\004\ +\000\000\247\000\247\000\247\000\247\000\000\000\138\002\000\000\ +\000\000\247\000\247\000\247\000\000\000\138\002\247\000\247\000\ +\000\000\247\000\247\000\247\000\247\000\247\000\247\000\000\000\ +\000\000\247\000\247\000\247\000\247\000\247\000\247\000\000\000\ +\000\000\138\002\078\004\000\000\000\000\247\000\247\000\000\000\ +\000\000\247\000\247\000\247\000\247\000\000\000\081\000\000\000\ +\000\000\247\000\247\000\000\000\180\000\255\004\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\247\000\247\000\000\000\ +\247\000\000\000\000\000\247\000\247\000\247\000\004\002\247\000\ +\180\000\000\000\247\000\247\000\000\000\000\000\000\000\000\000\ +\000\000\247\000\000\000\247\000\000\000\000\000\179\000\118\004\ +\000\000\000\000\000\000\000\000\247\000\247\000\000\000\247\000\ +\247\000\247\000\247\000\000\000\000\000\179\000\000\000\000\000\ +\247\000\000\000\247\000\000\000\141\004\247\000\000\000\159\001\ +\247\000\000\000\011\002\000\000\247\000\011\002\000\000\148\004\ +\000\000\000\000\011\002\138\002\000\000\000\000\000\000\011\002\ +\000\000\000\000\000\000\195\000\000\000\011\002\023\003\000\000\ +\000\000\180\000\000\000\000\000\011\002\000\000\011\002\011\002\ +\000\000\000\000\000\000\023\003\000\000\000\000\000\000\004\002\ +\000\000\000\000\000\000\011\002\179\004\000\000\181\004\180\000\ +\255\004\138\002\000\000\000\000\000\000\000\000\023\003\000\000\ +\023\003\023\003\023\003\138\002\023\003\000\000\011\002\023\003\ +\023\003\011\002\000\000\179\000\011\002\011\002\011\002\000\000\ +\159\001\000\000\000\000\113\005\011\002\000\000\000\000\000\000\ +\000\000\000\000\011\002\000\000\000\000\000\000\208\004\209\004\ +\210\004\023\003\000\000\000\000\229\000\000\000\011\002\000\000\ +\023\003\000\000\011\002\011\002\000\000\216\004\000\000\000\000\ +\000\000\000\000\000\000\000\000\023\003\023\003\011\002\000\000\ +\032\000\011\002\000\000\032\000\000\000\000\000\000\000\000\000\ +\000\000\230\004\000\000\138\002\138\002\032\000\032\000\000\000\ +\000\000\032\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\004\002\000\000\032\000\032\000\032\000\032\000\000\000\195\000\ +\000\000\238\004\239\004\240\004\179\000\000\000\000\000\000\000\ +\032\000\032\000\000\000\000\000\004\002\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\138\002\000\000\000\000\113\005\ +\000\000\000\000\000\000\000\000\032\000\000\000\000\000\032\000\ +\000\000\000\000\000\000\032\000\032\000\000\000\000\000\185\005\ +\186\005\032\000\032\000\030\005\000\000\000\000\081\000\255\004\ +\032\000\081\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\081\000\032\000\000\000\032\000\081\000\ +\032\000\032\000\000\000\000\000\000\000\255\004\000\000\000\000\ +\081\000\081\000\081\000\081\000\032\000\004\002\000\000\032\000\ +\000\000\060\002\000\000\032\000\000\000\000\000\052\005\081\000\ +\054\005\000\000\056\005\016\003\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\004\002\000\000\179\000\000\000\000\000\ +\000\000\000\000\081\000\000\000\000\000\081\000\078\005\079\005\ +\080\005\081\000\081\000\000\000\087\005\088\005\089\005\000\000\ +\081\000\179\000\000\000\000\000\000\000\000\000\081\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\081\000\000\000\081\000\103\005\081\000\081\000\ +\000\000\113\005\136\000\000\000\137\000\138\000\030\000\255\004\ +\139\000\118\005\081\000\140\000\141\000\081\000\000\000\000\000\ +\000\000\255\004\125\005\000\000\000\000\000\000\129\005\138\002\ +\000\000\000\000\000\000\000\000\142\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\143\000\144\000\000\000\000\000\ +\000\000\000\000\179\000\000\000\145\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\146\000\147\000\000\000\000\000\229\000\229\000\229\000\229\000\ +\179\000\000\000\255\004\000\000\229\000\229\000\229\000\000\000\ +\000\000\229\000\229\000\229\000\229\000\229\000\229\000\229\000\ +\229\000\229\000\000\000\000\000\229\000\229\000\229\000\229\000\ +\229\000\229\000\000\000\122\002\000\000\000\000\000\000\000\000\ +\229\000\229\000\000\000\000\000\229\000\229\000\229\000\229\000\ +\229\000\229\000\229\000\000\000\229\000\229\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\255\004\000\000\000\000\000\000\ +\229\000\229\000\000\000\229\000\000\000\000\000\229\000\229\000\ +\229\000\000\000\229\000\229\000\229\000\229\000\229\000\000\000\ +\000\000\000\000\000\000\113\005\229\000\113\005\229\000\229\000\ +\229\000\229\000\229\000\000\000\000\000\000\000\000\000\229\000\ +\229\000\000\000\229\000\229\000\229\000\229\000\000\000\000\000\ +\229\000\000\000\000\000\229\000\000\000\229\000\000\000\000\000\ +\229\000\000\000\000\000\229\000\000\000\000\000\000\000\229\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\239\005\000\000\000\000\000\000\014\000\000\000\000\000\000\000\ +\000\000\060\002\000\000\060\002\060\002\060\002\250\005\251\005\ +\252\005\060\002\000\000\015\000\016\000\000\000\060\002\164\002\ +\000\000\000\000\060\002\060\002\060\002\000\000\000\000\000\000\ +\023\000\000\000\007\006\060\002\060\002\060\002\060\002\000\000\ +\000\000\000\000\000\000\000\000\000\000\060\002\000\000\018\006\ +\000\000\060\002\060\002\031\000\000\000\022\006\074\001\000\000\ +\000\000\060\002\060\002\035\000\000\000\000\000\000\000\000\000\ +\000\000\039\000\000\000\000\000\000\000\060\002\037\006\042\000\ +\060\002\000\000\000\000\060\002\060\002\060\002\046\006\060\002\ +\000\000\000\000\060\002\060\002\000\000\000\000\000\000\046\000\ +\000\000\060\002\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\050\000\060\002\060\002\053\000\060\002\ +\060\002\060\002\000\000\000\000\000\000\060\002\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\060\002\000\000\000\000\ +\060\002\000\000\000\000\000\000\060\002\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\079\006\080\006\ +\000\000\000\000\000\000\041\001\000\000\082\006\083\006\084\006\ +\085\006\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\089\006\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\122\002\122\002\122\002\122\002\000\000\ +\099\006\122\002\122\002\122\002\122\002\122\002\122\002\122\002\ +\122\002\122\002\122\002\122\002\122\002\122\002\122\002\122\002\ +\122\002\122\002\000\000\122\002\122\002\122\002\122\002\122\002\ +\122\002\122\002\122\002\000\000\000\000\000\000\000\000\122\002\ +\122\002\000\000\000\000\122\002\122\002\122\002\122\002\122\002\ +\122\002\122\002\122\002\122\002\122\002\122\002\122\002\000\000\ +\122\002\122\002\122\002\122\002\000\000\000\000\122\002\122\002\ +\122\002\110\002\122\002\122\002\122\002\122\002\122\002\122\002\ +\000\000\122\002\122\002\122\002\122\002\122\002\000\000\122\002\ +\000\000\000\000\000\000\122\002\122\002\122\002\122\002\122\002\ +\122\002\122\002\122\002\000\000\122\002\000\000\122\002\122\002\ +\061\001\122\002\122\002\122\002\122\002\122\002\000\000\122\002\ +\122\002\000\000\122\002\122\002\122\002\122\002\000\000\122\002\ +\122\002\000\000\122\002\000\000\000\000\000\000\122\002\164\002\ +\164\002\164\002\164\002\164\002\000\000\164\002\164\002\164\002\ +\164\002\164\002\164\002\164\002\164\002\164\002\164\002\164\002\ +\164\002\164\002\164\002\164\002\164\002\000\000\000\000\164\002\ +\164\002\164\002\164\002\164\002\164\002\164\002\164\002\000\000\ +\000\000\000\000\000\000\164\002\164\002\000\000\000\000\164\002\ +\164\002\164\002\164\002\164\002\164\002\164\002\164\002\164\002\ +\164\002\164\002\164\002\000\000\164\002\164\002\164\002\164\002\ +\000\000\000\000\164\002\164\002\164\002\000\000\164\002\164\002\ +\164\002\164\002\164\002\164\002\000\000\164\002\164\002\164\002\ +\164\002\164\002\000\000\164\002\000\000\000\000\000\000\164\002\ +\164\002\164\002\164\002\164\002\164\002\164\002\164\002\000\000\ +\164\002\000\000\164\002\164\002\047\001\164\002\164\002\164\002\ +\164\002\164\002\000\000\164\002\164\002\000\000\164\002\164\002\ +\164\002\164\002\000\000\164\002\164\002\000\000\164\002\000\000\ +\000\000\000\000\164\002\041\001\041\001\041\001\041\001\000\000\ +\000\000\041\001\041\001\041\001\041\001\041\001\041\001\041\001\ +\041\001\041\001\041\001\041\001\041\001\041\001\041\001\041\001\ +\041\001\041\001\000\000\041\001\041\001\041\001\041\001\041\001\ +\041\001\041\001\041\001\000\000\000\000\000\000\000\000\041\001\ +\041\001\000\000\000\000\041\001\041\001\041\001\041\001\041\001\ +\041\001\041\001\041\001\041\001\041\001\041\001\041\001\000\000\ +\041\001\041\001\041\001\041\001\000\000\000\000\041\001\041\001\ +\041\001\000\000\041\001\041\001\041\001\041\001\041\001\041\001\ +\000\000\041\001\041\001\041\001\041\001\041\001\000\000\041\001\ +\000\000\000\000\000\000\041\001\041\001\041\001\041\001\041\001\ +\041\001\041\001\041\001\000\000\041\001\000\000\041\001\041\001\ +\045\001\041\001\041\001\041\001\041\001\041\001\000\000\041\001\ +\041\001\000\000\041\001\041\001\041\001\041\001\000\000\041\001\ +\041\001\000\000\041\001\000\000\000\000\000\000\041\001\000\000\ +\061\001\061\001\061\001\061\001\000\000\000\000\061\001\061\001\ +\061\001\061\001\061\001\061\001\061\001\061\001\061\001\061\001\ +\061\001\061\001\061\001\061\001\061\001\061\001\061\001\000\000\ +\061\001\061\001\061\001\061\001\061\001\061\001\061\001\061\001\ +\000\000\000\000\000\000\000\000\061\001\061\001\000\000\000\000\ +\061\001\061\001\061\001\061\001\061\001\061\001\061\001\061\001\ +\061\001\061\001\061\001\061\001\000\000\061\001\061\001\061\001\ +\061\001\000\000\000\000\061\001\061\001\061\001\000\000\061\001\ +\061\001\061\001\061\001\061\001\061\001\000\000\061\001\061\001\ +\061\001\061\001\061\001\000\000\061\001\000\000\000\000\000\000\ +\061\001\061\001\061\001\061\001\061\001\061\001\061\001\061\001\ +\000\000\061\001\000\000\061\001\061\001\053\001\061\001\061\001\ +\061\001\061\001\061\001\000\000\061\001\061\001\000\000\061\001\ +\061\001\061\001\061\001\000\000\061\001\061\001\000\000\061\001\ +\000\000\000\000\000\000\061\001\047\001\047\001\047\001\047\001\ +\000\000\000\000\047\001\047\001\047\001\047\001\047\001\047\001\ +\047\001\047\001\047\001\047\001\047\001\047\001\047\001\047\001\ +\047\001\047\001\047\001\000\000\047\001\047\001\047\001\047\001\ +\047\001\047\001\047\001\047\001\000\000\000\000\000\000\000\000\ +\047\001\047\001\000\000\000\000\047\001\047\001\047\001\047\001\ +\047\001\047\001\047\001\047\001\047\001\047\001\047\001\047\001\ +\000\000\047\001\047\001\047\001\047\001\000\000\000\000\047\001\ +\047\001\047\001\000\000\047\001\047\001\047\001\047\001\047\001\ +\047\001\000\000\047\001\047\001\047\001\047\001\047\001\000\000\ +\047\001\000\000\000\000\000\000\047\001\047\001\047\001\047\001\ +\047\001\047\001\047\001\047\001\000\000\047\001\000\000\047\001\ +\047\001\049\001\047\001\047\001\047\001\047\001\047\001\000\000\ +\047\001\047\001\000\000\047\001\047\001\047\001\047\001\000\000\ +\047\001\047\001\000\000\047\001\000\000\000\000\000\000\047\001\ +\045\001\045\001\045\001\045\001\000\000\000\000\045\001\045\001\ +\045\001\045\001\045\001\045\001\045\001\045\001\045\001\045\001\ +\045\001\045\001\045\001\045\001\045\001\045\001\045\001\000\000\ +\045\001\045\001\045\001\045\001\045\001\045\001\045\001\045\001\ +\000\000\000\000\000\000\000\000\045\001\045\001\000\000\000\000\ +\045\001\045\001\045\001\045\001\045\001\045\001\045\001\045\001\ +\045\001\045\001\045\001\045\001\000\000\045\001\045\001\045\001\ +\045\001\000\000\000\000\045\001\045\001\045\001\000\000\045\001\ +\045\001\045\001\045\001\045\001\045\001\000\000\045\001\045\001\ +\045\001\045\001\045\001\000\000\045\001\000\000\000\000\000\000\ +\045\001\045\001\045\001\045\001\045\001\045\001\045\001\045\001\ +\000\000\045\001\000\000\045\001\045\001\051\001\045\001\045\001\ +\045\001\045\001\045\001\000\000\045\001\045\001\000\000\045\001\ +\045\001\045\001\045\001\000\000\045\001\045\001\000\000\045\001\ +\000\000\000\000\000\000\045\001\000\000\053\001\053\001\053\001\ +\053\001\000\000\000\000\053\001\053\001\053\001\053\001\053\001\ +\053\001\053\001\053\001\053\001\053\001\053\001\053\001\053\001\ +\053\001\053\001\053\001\053\001\000\000\053\001\053\001\053\001\ +\053\001\053\001\053\001\053\001\053\001\000\000\000\000\000\000\ +\000\000\053\001\053\001\000\000\000\000\053\001\053\001\053\001\ +\053\001\053\001\053\001\053\001\053\001\053\001\053\001\053\001\ +\053\001\000\000\053\001\053\001\053\001\053\001\000\000\000\000\ +\053\001\053\001\053\001\000\000\053\001\053\001\053\001\053\001\ +\053\001\053\001\000\000\053\001\053\001\053\001\053\001\053\001\ +\000\000\053\001\000\000\000\000\000\000\053\001\053\001\053\001\ +\053\001\053\001\053\001\053\001\053\001\000\000\053\001\000\000\ +\053\001\053\001\059\001\053\001\053\001\053\001\053\001\053\001\ +\000\000\053\001\053\001\000\000\053\001\053\001\053\001\053\001\ +\000\000\053\001\053\001\000\000\053\001\000\000\000\000\000\000\ +\053\001\049\001\049\001\049\001\049\001\000\000\000\000\049\001\ +\049\001\049\001\049\001\049\001\049\001\049\001\049\001\049\001\ +\049\001\049\001\049\001\049\001\049\001\049\001\049\001\049\001\ +\000\000\049\001\049\001\049\001\049\001\049\001\049\001\049\001\ +\049\001\000\000\000\000\000\000\000\000\049\001\049\001\000\000\ +\000\000\049\001\049\001\049\001\049\001\049\001\049\001\049\001\ +\049\001\049\001\049\001\049\001\049\001\000\000\049\001\049\001\ +\049\001\049\001\000\000\000\000\049\001\049\001\049\001\000\000\ +\049\001\049\001\049\001\049\001\049\001\049\001\000\000\049\001\ +\049\001\049\001\049\001\049\001\000\000\049\001\000\000\000\000\ +\000\000\049\001\049\001\049\001\049\001\049\001\049\001\049\001\ +\049\001\000\000\049\001\000\000\049\001\049\001\055\001\049\001\ +\049\001\049\001\049\001\049\001\000\000\049\001\049\001\000\000\ +\049\001\049\001\049\001\049\001\000\000\049\001\049\001\000\000\ +\049\001\000\000\000\000\000\000\049\001\051\001\051\001\051\001\ +\051\001\000\000\000\000\051\001\051\001\051\001\051\001\051\001\ +\051\001\051\001\051\001\051\001\051\001\051\001\051\001\051\001\ +\051\001\051\001\051\001\051\001\000\000\051\001\051\001\051\001\ +\051\001\051\001\051\001\051\001\051\001\000\000\000\000\000\000\ +\000\000\051\001\051\001\000\000\000\000\051\001\051\001\051\001\ +\051\001\051\001\051\001\051\001\051\001\051\001\051\001\051\001\ +\051\001\000\000\051\001\051\001\051\001\051\001\000\000\000\000\ +\051\001\051\001\051\001\000\000\051\001\051\001\051\001\051\001\ +\051\001\051\001\000\000\051\001\051\001\051\001\051\001\051\001\ +\000\000\051\001\000\000\000\000\000\000\051\001\051\001\051\001\ +\051\001\051\001\051\001\051\001\051\001\000\000\051\001\000\000\ +\051\001\051\001\057\001\051\001\051\001\051\001\051\001\051\001\ +\000\000\051\001\051\001\000\000\051\001\051\001\051\001\051\001\ +\000\000\051\001\051\001\000\000\051\001\000\000\000\000\000\000\ +\051\001\000\000\059\001\059\001\059\001\059\001\000\000\000\000\ +\059\001\059\001\059\001\059\001\059\001\059\001\059\001\059\001\ +\059\001\059\001\059\001\059\001\059\001\059\001\059\001\059\001\ +\059\001\000\000\059\001\059\001\059\001\059\001\059\001\059\001\ +\059\001\059\001\000\000\000\000\000\000\000\000\059\001\059\001\ +\000\000\000\000\059\001\059\001\059\001\059\001\059\001\059\001\ +\059\001\059\001\059\001\059\001\059\001\059\001\000\000\059\001\ +\059\001\059\001\059\001\000\000\000\000\059\001\059\001\059\001\ +\000\000\059\001\059\001\059\001\059\001\059\001\059\001\000\000\ +\059\001\059\001\059\001\059\001\059\001\000\000\059\001\000\000\ +\000\000\000\000\059\001\059\001\059\001\059\001\059\001\059\001\ +\059\001\059\001\000\000\059\001\000\000\059\001\059\001\088\001\ +\059\001\059\001\059\001\059\001\059\001\000\000\059\001\059\001\ +\000\000\059\001\059\001\059\001\059\001\000\000\059\001\059\001\ +\000\000\059\001\000\000\000\000\000\000\059\001\055\001\055\001\ +\055\001\055\001\000\000\000\000\055\001\055\001\055\001\055\001\ +\055\001\055\001\055\001\055\001\055\001\055\001\055\001\055\001\ +\055\001\055\001\055\001\055\001\055\001\000\000\055\001\055\001\ +\055\001\055\001\055\001\055\001\055\001\055\001\000\000\000\000\ +\000\000\000\000\055\001\055\001\000\000\000\000\055\001\055\001\ +\055\001\055\001\055\001\055\001\055\001\055\001\055\001\055\001\ +\055\001\055\001\000\000\055\001\055\001\055\001\055\001\000\000\ +\000\000\055\001\055\001\055\001\000\000\055\001\055\001\055\001\ +\055\001\055\001\055\001\000\000\055\001\055\001\055\001\055\001\ +\055\001\000\000\055\001\000\000\000\000\000\000\055\001\055\001\ +\055\001\055\001\055\001\055\001\055\001\055\001\000\000\055\001\ +\000\000\055\001\055\001\097\001\055\001\055\001\055\001\055\001\ +\055\001\000\000\055\001\055\001\000\000\055\001\055\001\055\001\ +\055\001\000\000\055\001\055\001\000\000\055\001\000\000\000\000\ +\000\000\055\001\057\001\057\001\057\001\057\001\000\000\000\000\ +\057\001\057\001\057\001\057\001\057\001\057\001\057\001\057\001\ +\057\001\057\001\057\001\057\001\057\001\057\001\057\001\057\001\ +\057\001\000\000\057\001\057\001\057\001\057\001\057\001\057\001\ +\057\001\057\001\000\000\000\000\000\000\000\000\057\001\057\001\ +\000\000\000\000\057\001\057\001\057\001\057\001\057\001\057\001\ +\057\001\057\001\057\001\057\001\057\001\057\001\000\000\057\001\ +\057\001\057\001\057\001\000\000\000\000\057\001\057\001\057\001\ +\000\000\057\001\057\001\057\001\057\001\057\001\057\001\000\000\ +\057\001\057\001\057\001\057\001\057\001\000\000\057\001\000\000\ +\000\000\000\000\057\001\057\001\057\001\057\001\057\001\057\001\ +\057\001\057\001\000\000\057\001\000\000\057\001\057\001\099\001\ +\057\001\057\001\057\001\057\001\057\001\000\000\057\001\057\001\ +\000\000\057\001\057\001\057\001\057\001\000\000\057\001\057\001\ +\000\000\057\001\000\000\000\000\000\000\057\001\000\000\088\001\ +\088\001\088\001\088\001\088\001\000\000\088\001\088\001\088\001\ +\088\001\088\001\088\001\088\001\088\001\088\001\088\001\088\001\ +\088\001\088\001\088\001\088\001\088\001\000\000\000\000\088\001\ +\088\001\088\001\088\001\088\001\088\001\088\001\088\001\000\000\ +\000\000\000\000\000\000\088\001\088\001\000\000\000\000\088\001\ +\088\001\088\001\088\001\088\001\088\001\088\001\000\000\088\001\ +\088\001\088\001\088\001\000\000\088\001\088\001\088\001\088\001\ +\000\000\000\000\088\001\088\001\088\001\000\000\088\001\088\001\ +\088\001\088\001\088\001\088\001\000\000\088\001\088\001\088\001\ +\088\001\088\001\000\000\088\001\000\000\000\000\000\000\088\001\ +\088\001\088\001\088\001\088\001\088\001\088\001\088\001\000\000\ +\088\001\000\000\088\001\088\001\102\001\088\001\088\001\088\001\ +\088\001\088\001\000\000\088\001\088\001\000\000\088\001\088\001\ +\088\001\088\001\000\000\088\001\088\001\000\000\088\001\000\000\ +\000\000\000\000\088\001\097\001\097\001\097\001\097\001\097\001\ +\000\000\097\001\097\001\097\001\097\001\097\001\097\001\097\001\ +\097\001\097\001\097\001\097\001\097\001\097\001\097\001\097\001\ +\097\001\000\000\000\000\097\001\097\001\097\001\097\001\097\001\ +\097\001\097\001\097\001\000\000\000\000\000\000\000\000\097\001\ +\097\001\000\000\000\000\097\001\097\001\097\001\097\001\097\001\ +\097\001\097\001\000\000\097\001\097\001\097\001\097\001\000\000\ +\097\001\097\001\097\001\097\001\000\000\000\000\097\001\097\001\ +\097\001\000\000\097\001\097\001\097\001\097\001\097\001\097\001\ +\000\000\097\001\097\001\097\001\097\001\097\001\000\000\097\001\ +\000\000\000\000\000\000\097\001\097\001\097\001\097\001\097\001\ +\097\001\097\001\097\001\000\000\097\001\000\000\097\001\097\001\ +\033\001\097\001\097\001\097\001\000\000\000\000\000\000\097\001\ +\097\001\000\000\097\001\097\001\097\001\097\001\000\000\097\001\ +\097\001\000\000\097\001\000\000\000\000\000\000\097\001\099\001\ +\099\001\099\001\099\001\099\001\000\000\099\001\099\001\099\001\ +\099\001\099\001\099\001\099\001\099\001\099\001\099\001\099\001\ +\099\001\099\001\099\001\099\001\099\001\000\000\000\000\099\001\ +\099\001\099\001\099\001\099\001\099\001\099\001\099\001\000\000\ +\000\000\000\000\000\000\099\001\099\001\000\000\000\000\099\001\ +\099\001\099\001\099\001\099\001\099\001\099\001\000\000\099\001\ +\099\001\099\001\099\001\000\000\099\001\099\001\099\001\099\001\ +\000\000\000\000\099\001\099\001\099\001\000\000\099\001\099\001\ +\099\001\099\001\099\001\099\001\000\000\099\001\099\001\099\001\ +\099\001\099\001\000\000\099\001\000\000\000\000\000\000\099\001\ +\099\001\099\001\099\001\099\001\099\001\099\001\099\001\000\000\ +\099\001\000\000\099\001\099\001\034\001\099\001\099\001\099\001\ +\000\000\000\000\000\000\099\001\099\001\000\000\099\001\099\001\ +\099\001\099\001\000\000\099\001\099\001\000\000\099\001\000\000\ +\000\000\000\000\099\001\000\000\102\001\102\001\102\001\102\001\ +\102\001\000\000\102\001\102\001\102\001\102\001\102\001\102\001\ +\102\001\102\001\102\001\102\001\102\001\102\001\102\001\102\001\ +\102\001\102\001\000\000\000\000\102\001\102\001\102\001\102\001\ +\102\001\102\001\102\001\102\001\000\000\000\000\000\000\000\000\ +\102\001\102\001\000\000\000\000\102\001\102\001\102\001\102\001\ +\102\001\102\001\102\001\000\000\102\001\102\001\102\001\102\001\ +\000\000\102\001\102\001\102\001\102\001\000\000\000\000\102\001\ +\102\001\102\001\000\000\102\001\102\001\102\001\102\001\102\001\ +\102\001\000\000\102\001\102\001\102\001\102\001\102\001\000\000\ +\102\001\000\000\000\000\000\000\102\001\102\001\102\001\102\001\ +\102\001\102\001\102\001\102\001\000\000\102\001\000\000\102\001\ +\102\001\228\000\102\001\102\001\102\001\000\000\000\000\000\000\ +\102\001\102\001\000\000\102\001\102\001\102\001\102\001\000\000\ +\102\001\102\001\000\000\102\001\000\000\000\000\000\000\102\001\ +\033\001\033\001\033\001\033\001\000\000\000\000\000\000\000\000\ +\033\001\033\001\033\001\000\000\000\000\033\001\033\001\033\001\ +\033\001\033\001\033\001\033\001\033\001\033\001\033\001\000\000\ +\033\001\033\001\033\001\033\001\033\001\033\001\000\000\000\000\ +\000\000\000\000\000\000\000\000\033\001\033\001\000\000\000\000\ +\033\001\033\001\033\001\033\001\033\001\033\001\033\001\033\001\ +\033\001\033\001\000\000\033\001\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\033\001\033\001\000\000\033\001\ +\000\000\000\000\033\001\033\001\033\001\000\000\033\001\033\001\ +\033\001\033\001\033\001\000\000\000\000\000\000\000\000\000\000\ +\033\001\033\001\033\001\033\001\033\001\033\001\033\001\000\000\ +\000\000\033\001\000\000\033\001\033\001\240\000\033\001\033\001\ +\033\001\033\001\033\001\000\000\033\001\000\000\000\000\033\001\ +\033\001\033\001\000\000\000\000\033\001\000\000\000\000\033\001\ +\000\000\000\000\000\000\033\001\034\001\034\001\034\001\034\001\ +\000\000\000\000\000\000\000\000\034\001\034\001\034\001\000\000\ +\000\000\034\001\034\001\034\001\034\001\034\001\034\001\034\001\ +\034\001\034\001\034\001\000\000\034\001\034\001\034\001\034\001\ +\034\001\034\001\000\000\000\000\000\000\000\000\000\000\000\000\ +\034\001\034\001\000\000\000\000\034\001\034\001\034\001\034\001\ +\034\001\034\001\034\001\034\001\034\001\034\001\000\000\034\001\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\034\001\034\001\000\000\034\001\000\000\000\000\034\001\034\001\ +\034\001\000\000\034\001\034\001\034\001\034\001\034\001\000\000\ +\000\000\000\000\000\000\000\000\034\001\034\001\034\001\034\001\ +\034\001\034\001\034\001\000\000\000\000\034\001\000\000\034\001\ +\034\001\241\000\034\001\034\001\034\001\034\001\034\001\000\000\ +\034\001\000\000\000\000\034\001\034\001\034\001\000\000\000\000\ +\034\001\000\000\000\000\034\001\000\000\000\000\000\000\034\001\ +\000\000\228\000\228\000\228\000\228\000\000\000\000\000\000\000\ +\000\000\228\000\228\000\228\000\000\000\000\000\228\000\228\000\ +\228\000\228\000\228\000\228\000\228\000\228\000\228\000\000\000\ +\000\000\228\000\228\000\228\000\228\000\228\000\228\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\228\000\228\000\000\000\ +\000\000\228\000\228\000\228\000\228\000\228\000\228\000\228\000\ +\000\000\228\000\228\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\228\000\228\000\000\000\ +\228\000\000\000\000\000\228\000\228\000\228\000\000\000\228\000\ +\228\000\228\000\228\000\228\000\000\000\000\000\000\000\000\000\ +\000\000\228\000\000\000\228\000\228\000\228\000\228\000\228\000\ +\000\000\000\000\000\000\000\000\228\000\228\000\242\000\228\000\ +\228\000\228\000\000\000\000\000\000\000\228\000\000\000\000\000\ +\228\000\000\000\228\000\000\000\000\000\228\000\000\000\000\000\ +\228\000\000\000\000\000\000\000\228\000\240\000\240\000\240\000\ +\240\000\000\000\000\000\000\000\000\000\240\000\240\000\240\000\ +\000\000\000\000\240\000\240\000\240\000\240\000\240\000\000\000\ +\240\000\240\000\240\000\000\000\000\000\240\000\240\000\240\000\ +\240\000\240\000\240\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\240\000\240\000\000\000\000\000\240\000\240\000\240\000\ +\240\000\240\000\240\000\240\000\000\000\240\000\240\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\240\000\240\000\000\000\240\000\000\000\000\000\240\000\ +\240\000\240\000\000\000\240\000\240\000\240\000\240\000\240\000\ +\000\000\000\000\000\000\000\000\000\000\240\000\000\000\240\000\ +\240\000\240\000\240\000\240\000\000\000\000\000\000\000\000\000\ +\240\000\240\000\025\001\240\000\240\000\240\000\240\000\000\000\ +\000\000\240\000\000\000\000\000\240\000\000\000\240\000\000\000\ +\000\000\240\000\000\000\000\000\240\000\000\000\000\000\000\000\ +\240\000\241\000\241\000\241\000\241\000\000\000\000\000\000\000\ +\000\000\241\000\241\000\241\000\000\000\000\000\241\000\241\000\ +\241\000\241\000\241\000\241\000\241\000\241\000\241\000\000\000\ +\000\000\241\000\241\000\241\000\241\000\241\000\241\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\241\000\241\000\000\000\ +\000\000\241\000\241\000\241\000\241\000\241\000\241\000\241\000\ +\000\000\241\000\241\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\241\000\241\000\000\000\ +\241\000\000\000\000\000\241\000\241\000\241\000\000\000\241\000\ +\241\000\241\000\241\000\241\000\000\000\000\000\000\000\000\000\ +\000\000\241\000\000\000\241\000\241\000\241\000\241\000\241\000\ +\000\000\000\000\000\000\000\000\241\000\241\000\026\001\241\000\ +\241\000\241\000\000\000\000\000\000\000\241\000\000\000\000\000\ +\241\000\000\000\241\000\000\000\000\000\241\000\000\000\000\000\ +\241\000\000\000\000\000\000\000\241\000\000\000\242\000\242\000\ +\242\000\242\000\000\000\000\000\000\000\000\000\242\000\242\000\ +\242\000\000\000\000\000\242\000\242\000\242\000\242\000\242\000\ +\242\000\242\000\242\000\242\000\000\000\000\000\242\000\242\000\ +\242\000\242\000\242\000\242\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\242\000\242\000\000\000\000\000\242\000\242\000\ +\242\000\242\000\242\000\242\000\242\000\000\000\242\000\242\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\242\000\242\000\000\000\242\000\000\000\000\000\ +\242\000\242\000\242\000\000\000\242\000\242\000\242\000\242\000\ +\242\000\000\000\000\000\000\000\000\000\000\000\242\000\000\000\ +\242\000\242\000\242\000\242\000\242\000\000\000\000\000\000\000\ +\000\000\242\000\242\000\251\000\242\000\242\000\242\000\000\000\ +\000\000\000\000\242\000\000\000\000\000\242\000\000\000\242\000\ +\000\000\000\000\242\000\000\000\000\000\242\000\000\000\000\000\ +\000\000\242\000\025\001\025\001\025\001\025\001\000\000\000\000\ +\000\000\000\000\025\001\025\001\025\001\000\000\000\000\025\001\ +\025\001\025\001\025\001\025\001\025\001\025\001\025\001\025\001\ +\000\000\000\000\025\001\025\001\025\001\025\001\025\001\025\001\ +\000\000\000\000\000\000\000\000\000\000\000\000\025\001\025\001\ +\000\000\000\000\025\001\025\001\025\001\025\001\025\001\025\001\ +\025\001\000\000\025\001\025\001\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\025\001\025\001\ +\000\000\025\001\000\000\000\000\025\001\025\001\025\001\000\000\ +\025\001\025\001\025\001\025\001\025\001\000\000\000\000\000\000\ +\000\000\000\000\025\001\000\000\025\001\025\001\025\001\025\001\ +\025\001\000\000\000\000\000\000\000\000\025\001\025\001\252\000\ +\025\001\025\001\025\001\000\000\000\000\000\000\025\001\000\000\ +\000\000\025\001\000\000\025\001\000\000\000\000\025\001\000\000\ +\000\000\025\001\000\000\000\000\000\000\025\001\026\001\026\001\ +\026\001\026\001\000\000\000\000\000\000\000\000\026\001\026\001\ +\026\001\000\000\000\000\026\001\026\001\026\001\026\001\026\001\ +\026\001\026\001\026\001\026\001\000\000\000\000\026\001\026\001\ +\026\001\026\001\026\001\026\001\000\000\000\000\000\000\000\000\ +\000\000\000\000\026\001\026\001\000\000\000\000\026\001\026\001\ +\026\001\026\001\026\001\026\001\026\001\000\000\026\001\026\001\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\026\001\026\001\000\000\026\001\000\000\000\000\ +\026\001\026\001\026\001\000\000\026\001\026\001\026\001\026\001\ +\026\001\000\000\000\000\000\000\000\000\000\000\026\001\000\000\ +\026\001\026\001\026\001\026\001\026\001\000\000\000\000\000\000\ +\000\000\026\001\026\001\003\001\026\001\026\001\026\001\000\000\ +\000\000\000\000\026\001\000\000\000\000\026\001\000\000\026\001\ +\000\000\000\000\026\001\000\000\000\000\026\001\000\000\000\000\ +\000\000\026\001\000\000\251\000\251\000\251\000\251\000\000\000\ +\000\000\000\000\000\000\251\000\251\000\251\000\000\000\000\000\ +\251\000\251\000\251\000\251\000\251\000\251\000\251\000\251\000\ +\251\000\000\000\000\000\251\000\251\000\251\000\251\000\251\000\ +\251\000\000\000\000\000\000\000\000\000\000\000\000\000\251\000\ +\251\000\000\000\000\000\251\000\251\000\251\000\251\000\251\000\ +\251\000\000\000\000\000\251\000\251\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\251\000\ +\251\000\000\000\251\000\000\000\000\000\251\000\251\000\251\000\ +\000\000\251\000\251\000\251\000\251\000\251\000\000\000\000\000\ +\000\000\000\000\000\000\251\000\000\000\251\000\251\000\251\000\ +\251\000\251\000\000\000\000\000\000\000\000\000\251\000\251\000\ +\002\001\251\000\251\000\251\000\251\000\000\000\000\000\251\000\ +\000\000\000\000\251\000\000\000\251\000\000\000\000\000\251\000\ +\000\000\000\000\251\000\000\000\000\000\000\000\251\000\252\000\ +\252\000\252\000\252\000\000\000\000\000\000\000\000\000\252\000\ +\252\000\252\000\000\000\000\000\252\000\252\000\252\000\252\000\ +\252\000\252\000\252\000\252\000\252\000\000\000\000\000\252\000\ +\252\000\252\000\252\000\252\000\252\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\252\000\252\000\000\000\000\000\252\000\ +\252\000\252\000\252\000\252\000\252\000\000\000\000\000\252\000\ +\252\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\252\000\252\000\000\000\252\000\000\000\ +\000\000\252\000\252\000\252\000\000\000\252\000\252\000\252\000\ +\252\000\252\000\000\000\000\000\000\000\000\000\000\000\252\000\ +\000\000\252\000\252\000\252\000\252\000\252\000\000\000\000\000\ +\000\000\000\000\252\000\252\000\234\000\252\000\252\000\252\000\ +\252\000\000\000\000\000\252\000\000\000\000\000\252\000\000\000\ +\252\000\000\000\000\000\252\000\000\000\000\000\252\000\000\000\ +\000\000\000\000\252\000\003\001\003\001\003\001\003\001\000\000\ +\000\000\000\000\000\000\003\001\003\001\003\001\000\000\000\000\ +\003\001\003\001\003\001\003\001\003\001\003\001\003\001\003\001\ +\003\001\000\000\000\000\003\001\003\001\003\001\003\001\003\001\ +\003\001\000\000\000\000\000\000\000\000\000\000\000\000\003\001\ +\003\001\000\000\000\000\003\001\003\001\003\001\003\001\003\001\ +\003\001\000\000\000\000\003\001\003\001\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\003\001\ +\003\001\000\000\003\001\000\000\000\000\003\001\003\001\003\001\ +\000\000\003\001\003\001\003\001\003\001\003\001\000\000\000\000\ +\000\000\000\000\000\000\003\001\000\000\003\001\003\001\003\001\ +\003\001\003\001\000\000\000\000\000\000\000\000\003\001\003\001\ +\237\000\003\001\003\001\003\001\003\001\000\000\000\000\003\001\ +\000\000\000\000\003\001\000\000\003\001\000\000\000\000\003\001\ +\000\000\000\000\003\001\000\000\000\000\000\000\003\001\000\000\ +\002\001\002\001\002\001\002\001\000\000\000\000\000\000\000\000\ +\002\001\002\001\002\001\000\000\000\000\002\001\002\001\002\001\ +\002\001\002\001\002\001\002\001\002\001\002\001\000\000\000\000\ +\002\001\002\001\002\001\002\001\002\001\002\001\000\000\000\000\ +\000\000\000\000\000\000\000\000\002\001\002\001\000\000\000\000\ +\002\001\002\001\002\001\002\001\002\001\002\001\000\000\000\000\ +\002\001\002\001\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\002\001\002\001\000\000\002\001\ +\000\000\000\000\002\001\002\001\002\001\000\000\002\001\002\001\ +\002\001\002\001\002\001\000\000\000\000\000\000\000\000\000\000\ +\002\001\000\000\002\001\002\001\002\001\002\001\002\001\000\000\ +\000\000\000\000\000\000\002\001\002\001\238\000\002\001\002\001\ +\002\001\002\001\000\000\000\000\002\001\000\000\000\000\002\001\ +\000\000\002\001\000\000\000\000\002\001\000\000\000\000\002\001\ +\000\000\000\000\000\000\002\001\234\000\234\000\234\000\234\000\ +\000\000\000\000\000\000\000\000\000\000\234\000\234\000\000\000\ +\000\000\234\000\234\000\234\000\234\000\234\000\234\000\234\000\ +\234\000\234\000\000\000\000\000\234\000\234\000\234\000\234\000\ +\234\000\234\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\234\000\234\000\000\000\000\000\234\000\234\000\234\000\234\000\ +\234\000\234\000\234\000\000\000\234\000\234\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\234\000\234\000\000\000\234\000\000\000\000\000\234\000\234\000\ +\234\000\000\000\234\000\234\000\234\000\234\000\234\000\000\000\ +\000\000\000\000\000\000\000\000\234\000\000\000\234\000\234\000\ +\234\000\234\000\234\000\000\000\000\000\000\000\000\000\234\000\ +\234\000\250\000\234\000\234\000\234\000\234\000\000\000\000\000\ +\234\000\000\000\000\000\234\000\000\000\234\000\000\000\000\000\ +\234\000\000\000\000\000\234\000\000\000\000\000\000\000\234\000\ +\237\000\237\000\237\000\237\000\000\000\000\000\000\000\000\000\ +\000\000\237\000\237\000\000\000\000\000\237\000\237\000\237\000\ +\237\000\237\000\237\000\237\000\237\000\237\000\000\000\000\000\ +\237\000\237\000\237\000\237\000\237\000\237\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\237\000\237\000\000\000\000\000\ +\237\000\237\000\237\000\237\000\237\000\237\000\237\000\000\000\ +\237\000\237\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\237\000\237\000\000\000\237\000\ +\000\000\000\000\237\000\237\000\237\000\000\000\237\000\237\000\ +\237\000\237\000\237\000\000\000\000\000\000\000\000\000\000\000\ +\237\000\000\000\237\000\237\000\237\000\237\000\237\000\000\000\ +\000\000\000\000\000\000\237\000\237\000\000\001\237\000\237\000\ +\237\000\237\000\000\000\000\000\237\000\000\000\000\000\237\000\ +\000\000\237\000\000\000\000\000\237\000\000\000\000\000\237\000\ +\000\000\000\000\000\000\237\000\000\000\238\000\238\000\238\000\ +\238\000\000\000\000\000\000\000\000\000\000\000\238\000\238\000\ +\000\000\000\000\238\000\238\000\238\000\238\000\238\000\238\000\ +\238\000\238\000\238\000\000\000\000\000\238\000\238\000\238\000\ +\238\000\238\000\238\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\238\000\238\000\000\000\000\000\238\000\238\000\238\000\ +\238\000\238\000\238\000\238\000\000\000\238\000\238\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\238\000\238\000\000\000\238\000\000\000\000\000\238\000\ +\238\000\238\000\000\000\238\000\238\000\238\000\238\000\238\000\ +\000\000\000\000\000\000\000\000\000\000\238\000\000\000\238\000\ +\238\000\238\000\238\000\238\000\000\000\000\000\000\000\000\000\ +\238\000\238\000\001\001\238\000\238\000\238\000\238\000\000\000\ +\000\000\238\000\000\000\000\000\238\000\000\000\238\000\000\000\ +\000\000\238\000\000\000\000\000\238\000\000\000\000\000\000\000\ +\238\000\250\000\250\000\250\000\250\000\000\000\000\000\000\000\ +\000\000\250\000\250\000\250\000\000\000\000\000\250\000\250\000\ +\250\000\250\000\250\000\250\000\250\000\250\000\250\000\000\000\ +\000\000\250\000\250\000\250\000\250\000\250\000\250\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\250\000\250\000\000\000\ +\000\000\250\000\250\000\250\000\250\000\250\000\000\000\000\000\ +\000\000\250\000\250\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\250\000\250\000\000\000\ +\250\000\000\000\000\000\250\000\250\000\250\000\000\000\250\000\ +\250\000\250\000\250\000\250\000\000\000\000\000\000\000\000\000\ +\000\000\250\000\000\000\250\000\000\000\250\000\250\000\250\000\ +\000\000\000\000\000\000\000\000\250\000\250\000\253\000\250\000\ +\250\000\250\000\250\000\000\000\000\000\000\000\000\000\000\000\ +\250\000\000\000\250\000\000\000\000\000\250\000\000\000\000\000\ +\250\000\000\000\000\000\000\000\250\000\000\001\000\001\000\001\ +\000\001\000\000\000\000\000\000\000\000\000\001\000\001\000\001\ +\000\000\000\000\000\001\000\001\000\001\000\001\000\001\000\001\ +\000\001\000\001\000\001\000\000\000\000\000\001\000\001\000\001\ +\000\001\000\001\000\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\001\000\001\000\000\000\000\000\001\000\001\000\001\ +\000\001\000\001\000\000\000\000\000\000\000\001\000\001\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\001\000\001\000\000\000\001\000\000\000\000\000\001\ +\000\001\000\001\000\000\000\001\000\001\000\001\000\001\000\001\ +\000\000\000\000\000\000\000\000\000\000\000\001\000\000\000\001\ +\000\000\000\001\000\001\000\001\000\000\000\000\000\000\000\000\ +\000\001\000\001\254\000\000\001\000\001\000\001\000\001\000\000\ +\000\000\000\000\000\000\000\000\000\001\000\000\000\001\000\000\ +\000\000\000\001\000\000\000\000\000\001\000\000\000\000\000\000\ +\000\001\000\000\001\001\001\001\001\001\001\001\000\000\000\000\ +\000\000\000\000\001\001\001\001\001\001\000\000\000\000\001\001\ +\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\001\ +\000\000\000\000\001\001\001\001\001\001\001\001\001\001\001\001\ +\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\ +\000\000\000\000\001\001\001\001\001\001\001\001\001\001\000\000\ +\000\000\000\000\001\001\001\001\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\001\001\001\001\ +\000\000\001\001\000\000\000\000\001\001\001\001\001\001\000\000\ +\001\001\001\001\001\001\001\001\001\001\000\000\000\000\000\000\ +\000\000\000\000\001\001\000\000\001\001\000\000\001\001\001\001\ +\001\001\000\000\000\000\000\000\000\000\001\001\001\001\255\000\ +\001\001\001\001\001\001\001\001\000\000\000\000\000\000\000\000\ +\000\000\001\001\000\000\001\001\000\000\000\000\001\001\000\000\ +\000\000\001\001\000\000\000\000\000\000\001\001\253\000\253\000\ +\253\000\253\000\000\000\000\000\000\000\000\000\253\000\253\000\ +\253\000\000\000\000\000\253\000\253\000\253\000\253\000\253\000\ +\253\000\253\000\253\000\253\000\000\000\000\000\253\000\253\000\ +\253\000\253\000\253\000\253\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\253\000\253\000\000\000\000\000\253\000\253\000\ +\253\000\253\000\253\000\000\000\000\000\000\000\253\000\253\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\253\000\253\000\000\000\253\000\000\000\000\000\ +\253\000\253\000\253\000\000\000\253\000\253\000\253\000\253\000\ +\253\000\000\000\000\000\000\000\000\000\000\000\253\000\000\000\ +\253\000\000\000\253\000\253\000\253\000\000\000\000\000\000\000\ +\000\000\253\000\253\000\208\000\253\000\253\000\253\000\253\000\ +\000\000\000\000\000\000\000\000\000\000\253\000\000\000\253\000\ +\000\000\000\000\253\000\000\000\000\000\253\000\000\000\000\000\ +\000\000\253\000\254\000\254\000\254\000\254\000\000\000\000\000\ +\000\000\000\000\254\000\254\000\254\000\000\000\000\000\254\000\ +\254\000\254\000\254\000\254\000\254\000\254\000\254\000\254\000\ +\000\000\000\000\254\000\254\000\254\000\254\000\254\000\254\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\254\000\254\000\ +\000\000\000\000\254\000\254\000\254\000\254\000\254\000\000\000\ +\000\000\000\000\254\000\254\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\254\000\254\000\ +\000\000\254\000\000\000\000\000\254\000\254\000\254\000\000\000\ +\254\000\254\000\254\000\254\000\254\000\000\000\000\000\000\000\ +\000\000\000\000\254\000\000\000\254\000\000\000\254\000\254\000\ +\254\000\000\000\000\000\000\000\000\000\254\000\254\000\004\001\ +\254\000\254\000\254\000\254\000\000\000\000\000\000\000\000\000\ +\000\000\254\000\000\000\254\000\000\000\000\000\254\000\000\000\ +\000\000\254\000\000\000\000\000\000\000\254\000\000\000\255\000\ +\255\000\255\000\255\000\000\000\000\000\000\000\000\000\255\000\ +\255\000\255\000\000\000\000\000\255\000\255\000\255\000\255\000\ +\255\000\255\000\255\000\255\000\255\000\000\000\000\000\255\000\ +\255\000\255\000\255\000\255\000\255\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\255\000\255\000\000\000\000\000\255\000\ +\255\000\255\000\255\000\255\000\000\000\000\000\000\000\255\000\ +\255\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\255\000\255\000\000\000\255\000\000\000\ +\000\000\255\000\255\000\255\000\000\000\255\000\255\000\255\000\ +\255\000\255\000\000\000\000\000\000\000\000\000\000\000\255\000\ +\000\000\255\000\000\000\255\000\255\000\255\000\000\000\000\000\ +\000\000\000\000\255\000\255\000\006\001\255\000\255\000\255\000\ +\255\000\000\000\000\000\000\000\000\000\000\000\255\000\000\000\ +\255\000\000\000\000\000\255\000\000\000\000\000\255\000\000\000\ +\000\000\000\000\255\000\208\000\208\000\208\000\208\000\000\000\ +\000\000\000\000\000\000\208\000\208\000\208\000\000\000\000\000\ +\208\000\208\000\208\000\208\000\208\000\208\000\208\000\208\000\ +\208\000\000\000\000\000\208\000\208\000\208\000\208\000\208\000\ +\208\000\000\000\000\000\000\000\000\000\000\000\000\000\208\000\ +\208\000\000\000\000\000\208\000\208\000\208\000\208\000\208\000\ +\208\000\208\000\000\000\208\000\208\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\208\000\ +\208\000\000\000\000\000\000\000\000\000\208\000\208\000\208\000\ +\000\000\208\000\000\000\000\000\208\000\208\000\000\000\000\000\ +\000\000\000\000\000\000\208\000\000\000\208\000\000\000\000\000\ +\000\000\208\000\000\000\000\000\000\000\000\000\208\000\208\000\ +\248\000\208\000\208\000\208\000\208\000\000\000\000\000\208\000\ +\000\000\000\000\208\000\000\000\208\000\000\000\000\000\208\000\ +\000\000\000\000\208\000\000\000\000\000\000\000\208\000\004\001\ +\004\001\004\001\004\001\000\000\000\000\000\000\000\000\004\001\ +\004\001\004\001\000\000\000\000\004\001\004\001\000\000\004\001\ +\004\001\004\001\004\001\004\001\004\001\000\000\000\000\004\001\ +\004\001\004\001\004\001\004\001\004\001\000\000\000\000\000\000\ +\000\000\000\000\000\000\004\001\004\001\000\000\000\000\004\001\ +\004\001\004\001\000\000\000\000\000\000\000\000\000\000\004\001\ +\004\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\004\001\004\001\000\000\004\001\000\000\ +\000\000\000\000\004\001\004\001\000\000\004\001\000\000\000\000\ +\004\001\004\001\000\000\000\000\000\000\000\000\000\000\004\001\ +\000\000\004\001\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\004\001\004\001\249\000\004\001\004\001\004\001\ +\004\001\000\000\000\000\000\000\000\000\000\000\004\001\000\000\ +\004\001\000\000\000\000\004\001\000\000\000\000\004\001\000\000\ +\000\000\000\000\004\001\000\000\006\001\006\001\006\001\006\001\ +\000\000\000\000\000\000\000\000\006\001\006\001\006\001\000\000\ +\000\000\006\001\006\001\000\000\006\001\006\001\006\001\006\001\ +\006\001\006\001\000\000\000\000\006\001\006\001\006\001\006\001\ +\006\001\006\001\000\000\000\000\000\000\000\000\000\000\000\000\ +\006\001\006\001\000\000\000\000\006\001\006\001\006\001\000\000\ +\000\000\000\000\000\000\000\000\006\001\006\001\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\006\001\006\001\000\000\006\001\000\000\000\000\000\000\006\001\ +\006\001\000\000\006\001\000\000\000\000\006\001\006\001\000\000\ +\000\000\000\000\000\000\000\000\006\001\000\000\006\001\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\006\001\ +\006\001\005\001\006\001\006\001\006\001\006\001\000\000\000\000\ +\000\000\000\000\000\000\006\001\000\000\006\001\000\000\000\000\ +\006\001\000\000\000\000\006\001\000\000\000\000\000\000\006\001\ +\248\000\248\000\248\000\248\000\000\000\000\000\000\000\000\000\ +\248\000\248\000\248\000\000\000\000\000\248\000\248\000\000\000\ +\248\000\248\000\248\000\248\000\248\000\248\000\000\000\000\000\ +\248\000\248\000\248\000\248\000\248\000\248\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\248\000\248\000\000\000\000\000\ +\248\000\248\000\248\000\000\000\000\000\000\000\000\000\000\000\ +\248\000\248\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\248\000\248\000\000\000\248\000\ +\000\000\000\000\000\000\248\000\248\000\000\000\248\000\000\000\ +\000\000\248\000\248\000\000\000\000\000\000\000\000\000\000\000\ +\248\000\010\001\248\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\248\000\248\000\000\000\248\000\248\000\ +\248\000\248\000\000\000\000\000\000\000\000\000\000\000\248\000\ +\000\000\248\000\000\000\000\000\248\000\000\000\000\000\248\000\ +\000\000\000\000\000\000\248\000\249\000\249\000\249\000\249\000\ +\000\000\000\000\000\000\000\000\249\000\249\000\249\000\000\000\ +\000\000\249\000\249\000\000\000\249\000\249\000\249\000\249\000\ +\249\000\249\000\000\000\000\000\249\000\249\000\249\000\249\000\ +\249\000\249\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\249\000\249\000\000\000\000\000\249\000\249\000\249\000\000\000\ +\000\000\000\000\000\000\000\000\249\000\249\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\249\000\249\000\000\000\249\000\000\000\000\000\000\000\249\000\ +\249\000\009\001\249\000\000\000\000\000\249\000\249\000\000\000\ +\000\000\000\000\000\000\000\000\249\000\000\000\249\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\249\000\ +\249\000\000\000\249\000\249\000\249\000\249\000\000\000\000\000\ +\000\000\000\000\000\000\249\000\000\000\249\000\000\000\000\000\ +\249\000\000\000\000\000\249\000\000\000\000\000\000\000\249\000\ +\000\000\005\001\005\001\005\001\005\001\000\000\000\000\000\000\ +\000\000\005\001\005\001\005\001\000\000\000\000\005\001\005\001\ +\000\000\005\001\005\001\005\001\005\001\005\001\005\001\000\000\ +\000\000\005\001\005\001\005\001\005\001\005\001\005\001\000\000\ +\000\000\000\000\000\000\000\000\000\000\005\001\005\001\000\000\ +\000\000\005\001\005\001\005\001\000\000\000\000\000\000\000\000\ +\000\000\005\001\005\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\008\001\000\000\000\000\000\000\005\001\005\001\000\000\ +\005\001\000\000\000\000\000\000\005\001\005\001\000\000\005\001\ +\000\000\000\000\005\001\005\001\000\000\000\000\000\000\000\000\ +\000\000\005\001\000\000\005\001\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\005\001\005\001\000\000\005\001\ +\005\001\005\001\005\001\000\000\000\000\000\000\000\000\000\000\ +\005\001\010\001\005\001\000\000\010\001\005\001\000\000\000\000\ +\005\001\010\001\010\001\010\001\005\001\000\000\010\001\010\001\ +\000\000\010\001\010\001\010\001\010\001\010\001\010\001\000\000\ +\000\000\010\001\010\001\010\001\000\000\010\001\010\001\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\010\001\000\000\ +\000\000\010\001\010\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\010\001\010\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\131\001\000\000\000\000\000\000\010\001\000\000\000\000\ +\010\001\000\000\000\000\000\000\010\001\010\001\000\000\010\001\ +\000\000\000\000\010\001\010\001\000\000\000\000\000\000\000\000\ +\000\000\010\001\000\000\010\001\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\010\001\010\001\000\000\010\001\ +\010\001\010\001\010\001\000\000\000\000\000\000\000\000\000\000\ +\010\001\009\001\010\001\000\000\009\001\010\001\000\000\000\000\ +\010\001\009\001\009\001\009\001\010\001\000\000\009\001\009\001\ +\000\000\009\001\009\001\009\001\009\001\009\001\009\001\000\000\ +\000\000\009\001\009\001\009\001\000\000\009\001\009\001\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\009\001\000\000\ +\000\000\009\001\009\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\009\001\009\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\007\001\000\000\000\000\000\000\009\001\000\000\000\000\ +\009\001\000\000\000\000\000\000\009\001\009\001\000\000\009\001\ +\000\000\000\000\009\001\009\001\000\000\000\000\000\000\000\000\ +\000\000\009\001\000\000\009\001\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\009\001\009\001\000\000\009\001\ +\009\001\009\001\009\001\000\000\000\000\000\000\000\000\000\000\ +\009\001\008\001\009\001\000\000\008\001\009\001\000\000\000\000\ +\009\001\008\001\000\000\008\001\009\001\000\000\008\001\008\001\ +\000\000\008\001\008\001\008\001\008\001\008\001\008\001\000\000\ +\000\000\008\001\008\001\008\001\000\000\008\001\008\001\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\008\001\000\000\ +\000\000\008\001\008\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\008\001\008\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\130\001\000\000\000\000\000\000\008\001\000\000\000\000\ +\008\001\000\000\000\000\000\000\008\001\008\001\000\000\008\001\ +\000\000\000\000\008\001\008\001\000\000\000\000\000\000\000\000\ +\000\000\008\001\000\000\000\000\000\000\000\000\000\000\021\003\ +\000\000\000\000\000\000\000\000\008\001\008\001\000\000\008\001\ +\008\001\008\001\008\001\000\000\000\000\000\000\000\000\000\000\ +\008\001\131\001\008\001\000\000\131\001\008\001\000\000\000\000\ +\008\001\131\001\000\000\131\001\008\001\000\000\131\001\131\001\ +\000\000\131\001\131\001\131\001\131\001\131\001\131\001\000\000\ +\000\000\131\001\131\001\131\001\000\000\131\001\131\001\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\131\001\000\000\ +\000\000\131\001\131\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\131\001\131\001\000\000\011\001\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\131\001\000\000\000\000\ +\131\001\000\000\000\000\000\000\131\001\131\001\000\000\131\001\ +\000\000\000\000\131\001\131\001\000\000\000\000\000\000\000\000\ +\000\000\131\001\021\003\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\131\001\131\001\000\000\131\001\ +\131\001\131\001\131\001\000\000\000\000\000\000\000\000\000\000\ +\131\001\007\001\131\001\000\000\007\001\131\001\000\000\000\000\ +\131\001\007\001\000\000\007\001\131\001\000\000\007\001\007\001\ +\000\000\007\001\007\001\007\001\007\001\007\001\007\001\000\000\ +\000\000\007\001\007\001\007\001\000\000\007\001\007\001\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\007\001\000\000\ +\000\000\007\001\007\001\000\000\000\000\000\000\000\000\024\001\ +\000\000\007\001\007\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\007\001\000\000\000\000\ +\007\001\000\000\000\000\000\000\007\001\007\001\000\000\007\001\ +\000\000\000\000\007\001\007\001\000\000\000\000\000\000\000\000\ +\000\000\007\001\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\007\001\007\001\000\000\007\001\ +\007\001\007\001\007\001\000\000\000\000\000\000\000\000\000\000\ +\007\001\130\001\007\001\000\000\130\001\007\001\000\000\000\000\ +\007\001\130\001\000\000\130\001\007\001\000\000\130\001\130\001\ +\000\000\130\001\130\001\130\001\130\001\130\001\130\001\000\000\ +\000\000\130\001\130\001\130\001\000\000\130\001\130\001\021\003\ +\000\000\000\000\000\000\000\000\000\000\000\000\130\001\000\000\ +\000\000\130\001\130\001\000\000\021\003\000\000\000\000\014\001\ +\167\001\130\001\130\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\021\003\000\000\021\003\021\003\130\001\000\000\000\000\ +\130\001\000\000\000\000\000\000\130\001\130\001\000\000\130\001\ +\021\003\000\000\130\001\130\001\000\000\094\000\000\000\000\000\ +\136\000\130\001\137\000\138\000\030\000\000\000\139\000\000\000\ +\000\000\169\001\141\000\021\003\130\001\130\001\021\003\130\001\ +\130\001\130\001\130\001\021\003\011\001\000\000\000\000\011\001\ +\130\001\021\003\130\001\000\000\011\001\130\001\011\001\021\003\ +\130\001\011\001\011\001\144\000\130\001\011\001\000\000\011\001\ +\011\001\011\001\145\000\021\003\011\001\011\001\011\001\021\003\ +\011\001\011\001\021\003\000\000\000\000\021\003\146\000\147\000\ +\000\000\011\001\000\000\021\003\011\001\011\001\021\003\021\003\ +\000\000\000\000\243\000\000\000\011\001\011\001\000\000\000\000\ +\000\000\000\000\000\000\000\000\021\003\000\000\021\003\021\003\ +\011\001\000\000\000\000\011\001\000\000\000\000\000\000\011\001\ +\011\001\000\000\011\001\021\003\000\000\011\001\011\001\000\000\ +\104\000\174\003\000\000\136\000\011\001\137\000\138\000\030\000\ +\000\000\139\000\000\000\000\000\158\001\141\000\021\003\011\001\ +\011\001\000\000\011\001\011\001\011\001\011\001\021\003\024\001\ +\000\000\000\000\024\001\011\001\021\003\011\001\000\000\024\001\ +\011\001\024\001\021\003\011\001\024\001\024\001\144\000\011\001\ +\024\001\000\000\024\001\024\001\024\001\145\000\021\003\024\001\ +\024\001\024\001\021\003\024\001\024\001\000\000\000\000\000\000\ +\000\000\146\000\147\000\000\000\024\001\000\000\021\003\024\001\ +\024\001\021\003\000\000\000\000\000\000\017\001\000\000\024\001\ +\024\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\024\001\000\000\000\000\024\001\000\000\ +\000\000\000\000\024\001\024\001\000\000\024\001\000\000\000\000\ +\024\001\024\001\000\000\000\000\000\000\000\000\000\000\024\001\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\024\001\024\001\000\000\024\001\024\001\024\001\ +\024\001\000\000\000\000\000\000\000\000\000\000\024\001\014\001\ +\024\001\000\000\014\001\024\001\000\000\000\000\024\001\014\001\ +\000\000\014\001\024\001\000\000\014\001\014\001\000\000\000\000\ +\014\001\000\000\014\001\014\001\014\001\000\000\000\000\014\001\ +\014\001\014\001\000\000\014\001\014\001\094\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\014\001\000\000\000\000\014\001\ +\014\001\000\000\094\000\000\000\000\000\016\001\000\000\014\001\ +\014\001\000\000\000\000\000\000\000\000\000\000\000\000\094\000\ +\000\000\094\000\094\000\014\001\000\000\000\000\014\001\000\000\ +\000\000\000\000\014\001\014\001\000\000\014\001\094\000\000\000\ +\014\001\014\001\000\000\021\003\000\000\000\000\136\000\014\001\ +\137\000\138\000\030\000\000\000\139\000\000\000\000\000\158\001\ +\141\000\094\000\014\001\014\001\000\000\014\001\014\001\014\001\ +\014\001\094\000\243\000\000\000\000\000\243\000\014\001\094\000\ +\014\001\000\000\243\000\014\001\243\000\094\000\014\001\243\000\ +\243\000\144\000\014\001\243\000\000\000\243\000\243\000\243\000\ +\145\000\094\000\243\000\243\000\243\000\094\000\243\000\243\000\ +\104\000\000\000\000\000\000\000\146\000\147\000\000\000\243\000\ +\000\000\094\000\243\000\243\000\094\000\104\000\000\000\000\000\ +\015\001\000\000\243\000\243\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\104\000\000\000\104\000\104\000\243\000\000\000\ +\000\000\243\000\000\000\000\000\000\000\243\000\243\000\000\000\ +\243\000\104\000\000\000\243\000\243\000\000\000\099\000\000\000\ +\000\000\000\000\243\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\104\000\243\000\243\000\000\000\ +\243\000\243\000\243\000\243\000\104\000\017\001\000\000\000\000\ +\017\001\243\000\104\000\243\000\000\000\017\001\243\000\017\001\ +\104\000\243\000\017\001\017\001\000\000\243\000\017\001\000\000\ +\017\001\017\001\017\001\000\000\104\000\017\001\017\001\017\001\ +\104\000\017\001\017\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\017\001\000\000\104\000\017\001\017\001\104\000\ +\000\000\000\000\000\000\020\001\000\000\017\001\017\001\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\017\001\000\000\000\000\017\001\000\000\000\000\000\000\ +\017\001\017\001\000\000\017\001\000\000\000\000\017\001\017\001\ +\000\000\000\000\000\000\000\000\000\000\017\001\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\017\001\017\001\000\000\017\001\017\001\017\001\017\001\000\000\ +\000\000\000\000\000\000\000\000\017\001\016\001\017\001\000\000\ +\016\001\017\001\000\000\000\000\017\001\016\001\000\000\016\001\ +\017\001\000\000\016\001\016\001\000\000\000\000\016\001\000\000\ +\016\001\016\001\016\001\000\000\000\000\016\001\016\001\016\001\ +\000\000\016\001\016\001\021\003\000\000\000\000\000\000\000\000\ +\000\000\000\000\016\001\000\000\000\000\016\001\016\001\000\000\ +\021\003\000\000\000\000\018\001\000\000\016\001\016\001\000\000\ +\000\000\000\000\000\000\000\000\000\000\021\003\000\000\021\003\ +\021\003\016\001\000\000\000\000\016\001\000\000\000\000\000\000\ +\016\001\016\001\000\000\016\001\021\003\000\000\016\001\016\001\ +\000\000\103\000\000\000\000\000\000\000\016\001\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\021\003\ +\016\001\016\001\000\000\016\001\016\001\016\001\016\001\021\003\ +\015\001\000\000\000\000\015\001\016\001\021\003\016\001\000\000\ +\015\001\016\001\015\001\021\003\016\001\015\001\015\001\000\000\ +\016\001\015\001\000\000\015\001\015\001\015\001\000\000\021\003\ +\015\001\015\001\015\001\021\003\015\001\015\001\099\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\015\001\000\000\021\003\ +\015\001\015\001\021\003\099\000\000\000\000\000\019\001\000\000\ +\015\001\015\001\000\000\000\000\000\000\000\000\000\000\000\000\ +\099\000\000\000\099\000\099\000\015\001\000\000\000\000\015\001\ +\000\000\000\000\000\000\015\001\015\001\000\000\015\001\099\000\ +\000\000\015\001\015\001\000\000\000\000\000\000\000\000\000\000\ +\015\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\099\000\015\001\015\001\000\000\015\001\015\001\ +\015\001\015\001\099\000\020\001\000\000\000\000\020\001\015\001\ +\099\000\015\001\000\000\020\001\015\001\020\001\099\000\015\001\ +\020\001\020\001\000\000\015\001\020\001\000\000\020\001\020\001\ +\020\001\000\000\099\000\020\001\020\001\020\001\099\000\020\001\ +\020\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\020\001\000\000\099\000\020\001\020\001\099\000\000\000\000\000\ +\000\000\023\001\000\000\020\001\020\001\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\020\001\ +\000\000\000\000\020\001\000\000\000\000\000\000\020\001\020\001\ +\000\000\020\001\000\000\000\000\020\001\020\001\000\000\000\000\ +\000\000\000\000\000\000\020\001\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\020\001\020\001\ +\000\000\020\001\020\001\020\001\020\001\000\000\000\000\000\000\ +\000\000\000\000\020\001\018\001\020\001\000\000\018\001\020\001\ +\000\000\000\000\020\001\018\001\000\000\018\001\020\001\000\000\ +\018\001\018\001\000\000\000\000\018\001\000\000\018\001\018\001\ +\018\001\000\000\000\000\018\001\018\001\018\001\000\000\018\001\ +\018\001\103\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\018\001\000\000\000\000\018\001\018\001\000\000\103\000\000\000\ +\000\000\021\001\000\000\018\001\018\001\000\000\000\000\000\000\ +\000\000\000\000\000\000\103\000\000\000\103\000\103\000\018\001\ +\000\000\000\000\018\001\000\000\000\000\000\000\018\001\018\001\ +\000\000\018\001\103\000\000\000\018\001\018\001\000\000\000\000\ +\000\000\000\000\000\000\018\001\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\103\000\018\001\018\001\ +\000\000\018\001\018\001\018\001\018\001\103\000\019\001\000\000\ +\000\000\019\001\018\001\103\000\018\001\000\000\019\001\018\001\ +\019\001\103\000\018\001\019\001\019\001\000\000\018\001\019\001\ +\000\000\019\001\019\001\019\001\000\000\103\000\019\001\019\001\ +\019\001\103\000\019\001\019\001\010\000\000\000\157\001\000\000\ +\000\000\000\000\000\000\019\001\000\000\103\000\019\001\019\001\ +\103\000\000\000\000\000\000\000\022\001\000\000\019\001\019\001\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\019\001\000\000\000\000\019\001\000\000\000\000\ +\000\000\019\001\019\001\000\000\019\001\000\000\000\000\019\001\ +\019\001\000\000\000\000\000\000\000\000\136\000\019\001\137\000\ +\138\000\030\000\000\000\139\000\000\000\000\000\158\001\141\000\ +\000\000\019\001\019\001\000\000\019\001\019\001\019\001\019\001\ +\000\000\023\001\000\000\000\000\023\001\019\001\000\000\019\001\ +\000\000\023\001\019\001\023\001\000\000\019\001\023\001\023\001\ +\144\000\019\001\023\001\000\000\023\001\023\001\023\001\145\000\ +\000\000\023\001\023\001\023\001\000\000\023\001\023\001\000\000\ +\000\000\000\000\000\000\146\000\147\000\000\000\023\001\000\000\ +\000\000\023\001\023\001\000\000\000\000\000\000\000\000\207\000\ +\000\000\023\001\023\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\023\001\000\000\000\000\ +\023\001\000\000\000\000\000\000\023\001\023\001\000\000\023\001\ +\000\000\000\000\023\001\023\001\000\000\000\000\000\000\000\000\ +\000\000\023\001\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\023\001\023\001\000\000\023\001\ +\023\001\023\001\023\001\000\000\000\000\000\000\000\000\000\000\ +\023\001\021\001\023\001\000\000\021\001\023\001\000\000\000\000\ +\023\001\021\001\000\000\021\001\023\001\000\000\021\001\021\001\ +\000\000\000\000\021\001\000\000\021\001\021\001\021\001\000\000\ +\000\000\021\001\021\001\021\001\000\000\021\001\021\001\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\021\001\000\000\ +\000\000\021\001\021\001\000\000\000\000\000\000\000\000\244\000\ +\000\000\021\001\021\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\021\001\000\000\000\000\ +\021\001\000\000\000\000\000\000\021\001\021\001\000\000\021\001\ +\000\000\000\000\021\001\021\001\000\000\000\000\000\000\000\000\ +\000\000\021\001\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\021\001\021\001\000\000\021\001\ +\021\001\021\001\021\001\000\000\022\001\000\000\000\000\022\001\ +\021\001\000\000\021\001\000\000\022\001\021\001\022\001\000\000\ +\021\001\022\001\022\001\000\000\021\001\022\001\000\000\022\001\ +\022\001\022\001\000\000\000\000\022\001\022\001\022\001\000\000\ +\022\001\022\001\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\022\001\000\000\000\000\022\001\022\001\000\000\000\000\ +\000\000\000\000\000\000\000\000\022\001\022\001\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\061\002\000\000\000\000\ +\022\001\000\000\000\000\022\001\000\000\000\000\000\000\022\001\ +\022\001\000\000\022\001\000\000\000\000\022\001\022\001\000\000\ +\000\000\000\000\000\000\000\000\022\001\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\022\001\ +\022\001\000\000\022\001\022\001\022\001\022\001\000\000\207\000\ +\000\000\000\000\207\000\022\001\000\000\022\001\000\000\207\000\ +\022\001\207\000\000\000\022\001\207\000\207\000\000\000\022\001\ +\207\000\000\000\207\000\207\000\207\000\000\000\000\000\207\000\ +\207\000\207\000\000\000\207\000\207\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\207\000\000\000\000\000\207\000\ +\207\000\000\000\000\000\000\000\000\000\000\000\000\000\207\000\ +\207\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\095\002\000\000\000\000\207\000\000\000\000\000\207\000\000\000\ +\000\000\000\000\207\000\207\000\000\000\207\000\000\000\000\000\ +\207\000\207\000\000\000\000\000\000\000\000\000\000\000\207\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\207\000\207\000\000\000\207\000\000\000\207\000\ +\207\000\000\000\000\000\000\000\000\000\000\000\207\000\244\000\ +\207\000\000\000\244\000\207\000\000\000\000\000\207\000\244\000\ +\000\000\244\000\207\000\000\000\244\000\244\000\000\000\000\000\ +\244\000\000\000\244\000\244\000\244\000\000\000\000\000\244\000\ +\000\000\244\000\000\000\244\000\244\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\244\000\000\000\000\000\244\000\ +\244\000\000\000\000\000\000\000\000\000\000\000\000\000\244\000\ +\244\000\000\000\000\000\059\002\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\244\000\000\000\000\000\244\000\000\000\ +\000\000\000\000\244\000\244\000\000\000\244\000\000\000\000\000\ +\244\000\244\000\000\000\000\000\000\000\000\000\000\000\244\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\244\000\244\000\000\000\244\000\244\000\244\000\ +\244\000\000\000\000\000\000\000\000\000\000\000\244\000\000\000\ +\244\000\000\000\000\000\244\000\000\000\061\002\244\000\061\002\ +\061\002\061\002\244\000\000\000\000\000\061\002\000\000\000\000\ +\000\000\000\000\061\002\000\000\000\000\000\000\061\002\061\002\ +\061\002\000\000\000\000\000\000\000\000\154\003\000\000\061\002\ +\061\002\061\002\061\002\000\000\000\000\000\000\000\000\000\000\ +\000\000\061\002\000\000\000\000\000\000\061\002\061\002\000\000\ +\057\002\000\000\000\000\000\000\000\000\061\002\061\002\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\061\002\000\000\000\000\061\002\000\000\000\000\061\002\ +\061\002\061\002\000\000\061\002\000\000\000\000\061\002\061\002\ +\000\000\000\000\000\000\000\000\136\000\061\002\137\000\138\000\ +\030\000\000\000\139\000\000\000\000\000\140\000\141\000\000\000\ +\061\002\061\002\000\000\061\002\061\002\061\002\000\000\000\000\ +\095\002\061\002\095\002\095\002\095\002\000\000\142\000\000\000\ +\095\002\061\002\000\000\000\000\061\002\095\002\143\000\144\000\ +\061\002\095\002\095\002\095\002\000\000\000\000\145\000\000\000\ +\000\000\000\000\095\002\095\002\095\002\095\002\000\000\000\000\ +\059\005\000\000\146\000\147\000\095\002\000\000\000\000\000\000\ +\000\000\095\002\000\000\058\002\000\000\000\000\000\000\160\005\ +\095\002\095\002\000\000\000\000\000\000\000\000\243\001\000\000\ +\000\000\000\000\000\000\000\000\095\002\000\000\000\000\095\002\ +\000\000\000\000\095\002\095\002\095\002\000\000\095\002\000\000\ +\000\000\095\002\095\002\000\000\000\000\000\000\000\000\061\005\ +\095\002\137\000\138\000\030\000\000\000\139\000\000\000\000\000\ +\140\000\062\005\000\000\095\002\095\002\000\000\095\002\095\002\ +\095\002\095\002\000\000\059\002\000\000\059\002\059\002\059\002\ +\000\000\142\000\000\000\059\002\095\002\000\000\000\000\095\002\ +\059\002\143\000\144\000\095\002\059\002\059\002\059\002\000\000\ +\000\000\145\000\000\000\000\000\000\000\059\002\059\002\059\002\ +\059\002\000\000\246\001\000\000\000\000\064\005\147\000\059\002\ +\000\000\000\000\000\000\000\000\059\002\000\000\056\002\000\000\ +\000\000\000\000\000\000\059\002\059\002\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\059\002\ +\000\000\000\000\059\002\000\000\000\000\059\002\059\002\059\002\ +\000\000\059\002\000\000\000\000\000\000\059\002\000\000\000\000\ +\000\000\000\000\000\000\059\002\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\059\002\059\002\ +\000\000\059\002\059\002\059\002\059\002\000\000\000\000\000\000\ +\057\002\000\000\057\002\057\002\057\002\000\000\000\000\059\002\ +\057\002\000\000\059\002\000\000\000\000\057\002\059\002\000\000\ +\000\000\057\002\057\002\057\002\000\000\000\000\000\000\000\000\ +\000\000\000\000\057\002\057\002\057\002\057\002\000\000\000\000\ +\000\000\000\000\000\000\000\000\057\002\000\000\000\000\000\000\ +\000\000\057\002\000\000\053\002\000\000\000\000\000\000\000\000\ +\057\002\057\002\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\057\002\000\000\000\000\057\002\ +\000\000\000\000\057\002\057\002\057\002\000\000\057\002\000\000\ +\000\000\000\000\057\002\000\000\000\000\000\000\000\000\136\000\ +\057\002\137\000\138\000\030\000\000\000\139\000\000\000\000\000\ +\140\000\141\000\000\000\057\002\057\002\000\000\057\002\057\002\ +\057\002\057\002\177\001\058\002\000\000\058\002\058\002\058\002\ +\000\000\142\000\000\000\058\002\057\002\000\000\000\000\057\002\ +\058\002\143\000\144\000\057\002\058\002\058\002\058\002\042\002\ +\000\000\145\000\000\000\000\000\000\000\058\002\058\002\058\002\ +\058\002\000\000\000\000\000\000\000\000\146\000\147\000\058\002\ +\000\000\000\000\000\000\000\000\058\002\000\000\000\000\000\000\ +\000\000\000\000\000\000\058\002\058\002\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\058\002\ +\000\000\000\000\058\002\000\000\000\000\058\002\058\002\058\002\ +\000\000\058\002\000\000\000\000\000\000\058\002\000\000\000\000\ +\000\000\041\002\136\000\058\002\137\000\138\000\030\000\000\000\ +\139\000\000\000\000\000\140\000\141\000\000\000\058\002\058\002\ +\000\000\058\002\058\002\058\002\058\002\000\000\056\002\000\000\ +\056\002\056\002\056\002\000\000\142\000\000\000\056\002\058\002\ +\000\000\000\000\058\002\056\002\143\000\126\003\058\002\056\002\ +\056\002\056\002\000\000\000\000\145\000\000\000\000\000\000\000\ +\056\002\056\002\056\002\056\002\000\000\000\000\000\000\068\006\ +\146\000\147\000\056\002\039\002\000\000\000\000\000\000\056\002\ +\000\000\000\000\000\000\000\000\000\000\000\000\056\002\056\002\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\056\002\000\000\000\000\056\002\000\000\000\000\ +\056\002\056\002\056\002\000\000\056\002\000\000\000\000\000\000\ +\056\002\000\000\000\000\000\000\000\000\000\000\056\002\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\056\002\056\002\000\000\056\002\056\002\056\002\056\002\ +\000\000\197\000\000\000\053\002\000\000\053\002\053\002\000\000\ +\000\000\000\000\056\002\053\002\000\000\056\002\000\000\000\000\ +\053\002\056\002\000\000\000\000\053\002\053\002\053\002\000\000\ +\000\000\000\000\000\000\000\000\000\000\053\002\053\002\053\002\ +\053\002\000\000\000\000\000\000\000\000\000\000\000\000\053\002\ +\000\000\000\000\000\000\000\000\053\002\000\000\000\000\000\000\ +\000\000\000\000\000\000\053\002\053\002\000\000\000\000\000\000\ +\000\000\000\000\000\000\084\000\000\000\000\000\000\000\053\002\ +\000\000\000\000\053\002\000\000\000\000\053\002\053\002\053\002\ +\000\000\053\002\000\000\000\000\010\000\053\002\157\001\042\002\ +\000\000\000\000\042\002\053\002\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\042\002\000\000\053\002\053\002\ +\042\002\053\002\053\002\053\002\053\002\000\000\000\000\000\000\ +\000\000\042\002\042\002\042\002\042\002\000\000\000\000\053\002\ +\000\000\000\000\053\002\000\000\000\000\000\000\053\002\000\000\ +\042\002\000\000\000\000\000\000\000\000\136\000\000\000\137\000\ +\138\000\030\000\000\000\139\000\000\000\000\000\158\001\141\000\ +\000\000\041\002\000\000\042\002\041\002\000\000\042\002\000\000\ +\000\000\042\002\042\002\042\002\000\000\000\000\041\002\000\000\ +\042\002\042\002\041\002\000\000\000\000\000\000\000\000\042\002\ +\144\000\000\000\227\002\041\002\041\002\041\002\041\002\145\000\ +\000\000\000\000\000\000\042\002\023\003\042\002\000\000\042\002\ +\042\002\000\000\041\002\146\000\147\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\042\002\000\000\000\000\042\002\000\000\ +\000\000\000\000\042\002\039\002\000\000\041\002\039\002\000\000\ +\041\002\000\000\000\000\041\002\041\002\041\002\000\000\000\000\ +\039\002\000\000\041\002\041\002\039\002\000\000\000\000\000\000\ +\000\000\041\002\000\000\000\000\000\000\039\002\039\002\039\002\ +\039\002\000\000\000\000\000\000\000\000\041\002\000\000\041\002\ +\000\000\041\002\041\002\000\000\039\002\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\041\002\000\000\000\000\ +\041\002\000\000\000\000\000\000\041\002\000\000\000\000\039\002\ +\000\000\197\000\039\002\000\000\197\000\039\002\039\002\039\002\ +\000\000\000\000\000\000\000\000\039\002\039\002\197\000\000\000\ +\000\000\000\000\197\000\039\002\197\000\000\000\000\000\000\000\ +\000\000\000\000\128\000\197\000\197\000\197\000\197\000\039\002\ +\000\000\039\002\000\000\039\002\039\002\000\000\000\000\000\000\ +\000\000\000\000\197\000\000\000\000\000\000\000\000\000\039\002\ +\000\000\000\000\039\002\000\000\000\000\000\000\039\002\000\000\ +\000\000\000\000\000\000\084\000\000\000\197\000\084\000\000\000\ +\197\000\000\000\000\000\000\000\197\000\197\000\000\000\000\000\ +\084\000\000\000\197\000\197\000\084\000\000\000\000\000\000\000\ +\000\000\197\000\000\000\000\000\000\000\084\000\084\000\084\000\ +\084\000\000\000\000\000\000\000\000\000\197\000\000\000\197\000\ +\000\000\197\000\197\000\000\000\084\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\197\000\000\000\000\000\ +\197\000\120\000\000\000\000\000\197\000\000\000\000\000\084\000\ +\000\000\000\000\084\000\000\000\000\000\000\000\084\000\084\000\ +\000\000\000\000\000\000\000\000\084\000\084\000\244\004\000\000\ +\137\000\138\000\030\000\084\000\139\000\000\000\245\004\246\004\ +\141\000\000\000\000\000\000\000\000\000\000\000\000\000\084\000\ +\000\000\084\000\000\000\084\000\084\000\247\004\000\000\000\000\ +\248\004\000\000\000\000\000\000\000\000\000\000\000\000\084\000\ +\249\004\144\000\084\000\000\000\023\003\000\000\084\000\023\003\ +\145\000\023\003\023\003\023\003\023\003\000\000\000\000\023\003\ +\023\003\023\003\000\000\000\000\146\000\147\000\000\000\023\003\ +\000\000\000\000\000\000\023\003\000\000\000\000\023\003\000\000\ +\023\003\023\003\023\003\023\003\023\003\023\003\023\003\023\003\ +\023\003\000\000\000\000\023\003\023\003\023\003\000\000\000\000\ +\000\000\000\000\000\000\000\000\023\003\023\003\023\003\023\003\ +\023\003\023\003\023\003\023\003\023\003\023\003\023\003\023\003\ +\023\003\023\003\150\001\023\003\023\003\023\003\000\000\023\003\ +\023\003\023\003\023\003\023\003\023\003\000\000\023\003\023\003\ +\023\003\023\003\023\003\000\000\023\003\023\003\000\000\000\000\ +\023\003\023\003\000\000\023\003\023\003\023\003\023\003\023\003\ +\023\003\023\003\000\000\023\003\023\003\023\003\000\000\023\003\ +\000\000\023\003\023\003\000\000\023\003\000\000\023\003\023\003\ +\023\003\023\003\023\003\023\003\023\003\000\000\023\003\009\000\ +\010\000\011\000\000\000\000\000\000\000\012\000\013\000\014\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\015\000\016\000\ +\017\000\018\000\019\000\020\000\021\000\000\000\000\000\000\000\ +\000\000\022\000\000\000\023\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\024\000\000\000\025\000\026\000\ +\027\000\028\000\029\000\000\000\000\000\030\000\031\000\000\000\ +\000\000\032\000\033\000\034\000\000\000\164\002\035\000\036\000\ +\000\000\037\000\038\000\000\000\039\000\000\000\040\000\000\000\ +\041\000\000\000\042\000\000\000\000\000\000\000\043\000\044\000\ +\000\000\045\000\000\000\000\000\000\000\000\000\009\000\010\000\ +\011\000\000\000\129\000\121\000\012\000\013\000\014\000\047\000\ +\000\000\000\000\000\000\000\000\048\000\049\000\050\000\051\000\ +\052\000\053\000\000\000\000\000\054\000\015\000\016\000\017\000\ +\018\000\019\000\020\000\021\000\000\000\000\000\000\000\000\000\ +\022\000\000\000\023\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\024\000\000\000\025\000\026\000\027\000\ +\028\000\029\000\000\000\000\000\030\000\031\000\000\000\000\000\ +\032\000\033\000\034\000\000\000\000\000\035\000\036\000\000\000\ +\037\000\038\000\000\000\039\000\000\000\040\000\000\000\041\000\ +\000\000\042\000\000\000\109\000\000\000\043\000\044\000\000\000\ +\045\000\178\001\136\000\000\000\137\000\138\000\030\000\000\000\ +\139\000\000\000\121\000\140\000\141\000\000\000\047\000\000\000\ +\000\000\000\000\000\000\048\000\049\000\050\000\051\000\052\000\ +\053\000\000\000\000\000\054\000\142\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\143\000\144\000\000\000\009\000\ +\010\000\011\000\000\000\000\000\145\000\012\000\013\000\014\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\146\000\147\000\000\000\000\000\000\000\000\000\015\000\016\000\ +\017\000\018\000\019\000\020\000\021\000\000\000\000\000\000\000\ +\000\000\022\000\000\000\023\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\024\000\000\000\025\000\026\000\ +\027\000\028\000\029\000\000\000\000\000\030\000\031\000\000\000\ +\000\000\032\000\033\000\034\000\000\000\000\000\035\000\036\000\ +\000\000\037\000\038\000\000\000\039\000\132\000\040\000\000\000\ +\041\000\000\000\042\000\000\000\000\000\000\000\043\000\044\000\ +\000\000\045\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\121\000\000\000\000\000\000\000\047\000\ +\000\000\000\000\000\000\000\000\048\000\049\000\050\000\051\000\ +\052\000\053\000\000\000\000\000\054\000\164\002\000\000\000\000\ +\000\000\164\002\000\000\164\002\000\000\164\002\000\000\164\002\ +\000\000\164\002\000\000\164\002\164\002\000\000\164\002\164\002\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\164\002\164\002\000\000\164\002\164\002\134\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\164\002\ +\164\002\164\002\164\002\000\000\164\002\164\002\000\000\000\000\ +\164\002\000\000\000\000\000\000\000\000\164\002\164\002\164\002\ +\000\000\000\000\000\000\000\000\164\002\000\000\164\002\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\164\002\000\000\ +\000\000\164\002\000\000\000\000\000\000\000\000\164\002\135\000\ +\164\002\164\002\000\000\164\002\164\002\000\000\164\002\000\000\ +\000\000\000\000\164\002\109\000\000\000\164\002\000\000\164\002\ +\000\000\178\001\164\002\164\002\000\000\178\001\164\002\178\001\ +\109\000\178\001\000\000\178\001\000\000\178\001\000\000\178\001\ +\178\001\000\000\178\001\178\001\000\000\109\000\000\000\109\000\ +\109\000\000\000\000\000\000\000\178\001\000\000\000\000\178\001\ +\178\001\000\000\000\000\000\000\109\000\000\000\000\000\000\000\ +\000\000\130\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\178\001\178\001\000\000\178\001\109\000\ +\178\001\178\001\000\000\000\000\178\001\000\000\109\000\109\000\ +\000\000\178\001\178\001\178\001\000\000\109\000\000\000\000\000\ +\178\001\000\000\178\001\109\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\178\001\000\000\000\000\178\001\000\000\109\000\ +\000\000\000\000\178\001\109\000\178\001\178\001\000\000\178\001\ +\178\001\000\000\178\001\136\000\000\000\000\000\178\001\109\000\ +\000\000\178\001\109\000\178\001\000\000\132\000\178\001\178\001\ +\132\000\132\000\178\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\132\000\132\000\000\000\000\000\000\000\000\000\ +\132\000\000\000\000\000\000\000\000\000\000\000\000\000\132\000\ +\000\000\132\000\132\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\132\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\132\000\132\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\132\000\000\000\000\000\132\000\000\000\000\000\132\000\ +\132\000\132\000\000\000\132\000\000\000\134\000\000\000\132\000\ +\134\000\134\000\014\002\000\000\000\000\132\000\000\000\000\000\ +\000\000\000\000\134\000\134\000\000\000\000\000\000\000\000\000\ +\134\000\132\000\000\000\132\000\000\000\132\000\132\000\134\000\ +\000\000\134\000\134\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\132\000\000\000\000\000\132\000\000\000\134\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\134\000\134\000\000\000\ +\000\000\000\000\000\000\181\000\000\000\000\000\000\000\135\000\ +\000\000\134\000\135\000\135\000\134\000\000\000\000\000\134\000\ +\134\000\134\000\000\000\134\000\135\000\135\000\000\000\134\000\ +\000\000\000\000\135\000\000\000\000\000\134\000\000\000\000\000\ +\000\000\135\000\000\000\135\000\135\000\000\000\000\000\000\000\ +\000\000\134\000\000\000\134\000\000\000\134\000\134\000\000\000\ +\135\000\000\000\000\000\000\000\000\000\183\002\000\000\135\000\ +\135\000\134\000\000\000\000\000\134\000\000\000\000\000\000\000\ +\000\000\130\000\000\000\135\000\130\000\130\000\135\000\000\000\ +\000\000\000\000\135\000\135\000\000\000\135\000\130\000\130\000\ +\000\000\135\000\000\000\000\000\130\000\000\000\000\000\135\000\ +\000\000\000\000\000\000\130\000\000\000\130\000\130\000\000\000\ +\000\000\000\000\000\000\135\000\000\000\135\000\000\000\135\000\ +\135\000\000\000\130\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\130\000\130\000\135\000\000\000\000\000\135\000\000\000\ +\000\000\000\000\000\000\136\000\000\000\130\000\136\000\136\000\ +\130\000\015\002\000\000\000\000\130\000\130\000\000\000\130\000\ +\136\000\136\000\000\000\130\000\000\000\000\000\136\000\000\000\ +\000\000\130\000\000\000\000\000\000\000\136\000\000\000\136\000\ +\136\000\000\000\000\000\000\000\000\000\130\000\000\000\130\000\ +\000\000\130\000\130\000\000\000\136\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\136\000\136\000\130\000\000\000\000\000\ +\130\000\000\000\000\000\000\000\000\000\000\000\000\000\136\000\ +\000\000\000\000\136\000\182\000\000\000\000\000\136\000\136\000\ +\000\000\136\000\000\000\000\000\000\000\136\000\136\000\000\000\ +\137\000\138\000\030\000\136\000\139\000\000\000\000\000\140\000\ +\141\000\000\000\014\002\000\000\000\000\014\002\000\000\136\000\ +\000\000\136\000\014\002\136\000\136\000\000\000\000\000\014\002\ +\142\000\000\000\000\000\000\000\000\000\014\002\000\000\136\000\ +\143\000\126\003\136\000\000\000\014\002\000\000\014\002\014\002\ +\145\000\000\000\000\000\000\000\000\000\021\003\000\000\000\000\ +\000\000\000\000\014\002\014\002\146\000\147\000\000\000\000\000\ +\000\000\000\000\000\000\181\000\000\000\000\000\181\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\014\002\000\000\ +\181\000\014\002\000\000\000\000\014\002\014\002\014\002\000\000\ +\000\000\000\000\000\000\098\002\014\002\181\000\181\000\181\000\ +\181\000\000\000\014\002\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\181\000\000\000\014\002\023\003\ +\000\000\000\000\014\002\014\002\000\000\183\002\098\002\000\000\ +\183\002\000\000\000\000\000\000\000\000\000\000\014\002\181\000\ +\000\000\014\002\183\002\080\002\000\000\181\000\181\000\181\000\ +\000\000\000\000\000\000\000\000\080\002\181\000\000\000\183\002\ +\183\002\183\002\183\002\181\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\183\002\181\000\ +\000\000\181\000\000\000\181\000\080\002\000\000\000\000\080\002\ +\000\000\232\001\000\000\000\000\000\000\000\000\000\000\181\000\ +\080\002\183\002\181\000\000\000\000\000\174\002\000\000\183\002\ +\183\002\183\002\000\000\000\000\000\000\000\000\174\002\183\002\ +\000\000\015\002\000\000\000\000\015\002\183\002\000\000\000\000\ +\000\000\015\002\000\000\000\000\000\000\000\000\015\002\000\000\ +\000\000\183\002\000\000\183\002\015\002\183\002\174\002\000\000\ +\000\000\174\002\071\000\015\002\000\000\015\002\015\002\000\000\ +\000\000\183\002\174\002\000\000\183\002\000\000\000\000\000\000\ +\000\000\015\002\015\002\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\182\000\000\000\015\002\182\000\000\000\ +\015\002\000\000\000\000\015\002\015\002\015\002\000\000\000\000\ +\182\000\000\000\015\002\015\002\000\000\000\000\182\000\233\001\ +\000\000\015\002\000\000\000\000\000\000\182\000\182\000\182\000\ +\182\000\000\000\000\000\000\000\000\000\015\002\000\000\000\000\ +\000\000\015\002\015\002\000\000\182\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\182\000\000\000\015\002\000\000\000\000\ +\015\002\000\000\000\000\000\000\000\000\021\003\000\000\182\000\ +\021\003\000\000\182\000\000\000\000\000\000\000\182\000\182\000\ +\000\000\182\000\021\003\000\000\235\001\182\000\000\000\000\000\ +\021\003\000\000\000\000\182\000\000\000\000\000\000\000\021\003\ +\000\000\021\003\021\003\000\000\000\000\000\000\000\000\182\000\ +\000\000\182\000\000\000\182\000\182\000\021\003\021\003\000\000\ +\000\000\000\000\000\000\000\000\000\000\021\003\021\003\182\000\ +\000\000\000\000\182\000\000\000\000\000\000\000\000\000\023\003\ +\000\000\021\003\023\003\000\000\021\003\000\000\000\000\023\003\ +\000\000\021\003\000\000\021\003\023\003\000\000\000\000\021\003\ +\000\000\000\000\023\003\000\000\000\000\021\003\000\000\000\000\ +\000\000\023\003\000\000\023\003\023\003\000\000\000\000\234\001\ +\000\000\021\003\000\000\000\000\000\000\021\003\021\003\000\000\ +\023\003\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\021\003\000\000\000\000\021\003\000\000\000\000\000\000\ +\000\000\232\001\000\000\023\003\232\001\000\000\023\003\000\000\ +\000\000\000\000\023\003\023\003\000\000\000\000\232\001\000\000\ +\000\000\023\003\000\000\000\000\232\001\000\000\000\000\023\003\ +\000\000\000\000\000\000\232\001\236\001\232\001\232\001\000\000\ +\000\000\000\000\000\000\023\003\000\000\011\002\000\000\023\003\ +\023\003\000\000\232\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\071\000\023\003\000\000\071\000\023\003\000\000\ +\000\000\000\000\000\000\000\000\000\000\232\001\000\000\071\000\ +\232\001\000\000\000\000\000\000\232\001\232\001\000\000\000\000\ +\000\000\000\000\000\000\232\001\071\000\000\000\071\000\071\000\ +\000\000\232\001\000\000\000\000\000\000\000\000\000\000\240\001\ +\000\000\000\000\071\000\071\000\000\000\232\001\000\000\000\000\ +\000\000\232\001\232\001\000\000\000\000\000\000\000\000\233\001\ +\000\000\000\000\233\001\000\000\000\000\232\001\071\000\000\000\ +\232\001\071\000\000\000\000\000\233\001\071\000\071\000\000\000\ +\000\000\000\000\233\001\000\000\071\000\000\000\000\000\000\000\ +\000\000\233\001\071\000\233\001\233\001\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\011\002\000\000\071\000\000\000\ +\233\001\000\000\071\000\071\000\000\000\021\003\000\000\000\000\ +\000\000\000\000\000\000\000\000\235\001\000\000\071\000\235\001\ +\000\000\071\000\000\000\233\001\000\000\000\000\233\001\000\000\ +\000\000\235\001\233\001\233\001\000\000\000\000\000\000\235\001\ +\000\000\233\001\000\000\000\000\000\000\000\000\235\001\233\001\ +\235\001\235\001\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\233\001\000\000\235\001\000\000\233\001\ +\233\001\000\000\125\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\233\001\000\000\000\000\233\001\000\000\ +\235\001\000\000\000\000\235\001\000\000\000\000\000\000\235\001\ +\235\001\000\000\000\000\000\000\000\000\000\000\235\001\234\001\ +\000\000\000\000\234\001\000\000\235\001\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\234\001\000\000\000\000\000\000\ +\235\001\000\000\234\001\000\000\235\001\235\001\000\000\126\000\ +\000\000\234\001\000\000\234\001\234\001\000\000\000\000\000\000\ +\235\001\000\000\000\000\235\001\000\000\000\000\000\000\000\000\ +\234\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\236\001\000\000\000\000\236\001\ +\000\000\000\000\000\000\234\001\000\000\011\002\234\001\000\000\ +\000\000\236\001\234\001\234\001\000\000\011\002\000\000\236\001\ +\023\003\234\001\011\002\000\000\000\000\000\000\236\001\234\001\ +\236\001\236\001\023\003\000\000\000\000\000\000\000\000\011\002\ +\000\000\011\002\011\002\234\001\000\000\236\001\000\000\234\001\ +\234\001\000\000\000\000\000\000\000\000\000\000\011\002\000\000\ +\000\000\000\000\000\000\234\001\000\000\000\000\234\001\240\001\ +\236\001\000\000\240\001\236\001\000\000\000\000\000\000\236\001\ +\236\001\011\002\000\000\000\000\240\001\000\000\236\001\011\002\ +\011\002\011\002\240\001\000\000\236\001\000\000\000\000\011\002\ +\000\000\240\001\000\000\240\001\240\001\011\002\000\000\000\000\ +\236\001\000\000\000\000\118\000\236\001\236\001\000\000\000\000\ +\240\001\011\002\000\000\000\000\000\000\011\002\000\000\000\000\ +\236\001\000\000\000\000\236\001\011\002\000\000\000\000\000\000\ +\000\000\011\002\000\000\240\001\011\002\021\003\240\001\000\000\ +\021\003\011\002\240\001\240\001\000\000\000\000\000\000\000\000\ +\000\000\240\001\021\003\000\000\000\000\000\000\011\002\240\001\ +\011\002\011\002\000\000\000\000\021\003\000\000\000\000\021\003\ +\000\000\021\003\021\003\240\001\000\000\011\002\119\000\240\001\ +\240\001\000\000\000\000\000\000\000\000\021\003\021\003\000\000\ +\000\000\000\000\000\000\240\001\000\000\000\000\240\001\000\000\ +\011\002\000\000\125\000\011\002\000\000\125\000\011\002\011\002\ +\011\002\021\003\000\000\000\000\021\003\000\000\011\002\125\000\ +\000\000\021\003\000\000\000\000\011\002\000\000\000\000\021\003\ +\000\000\000\000\000\000\000\000\125\000\021\003\125\000\125\000\ +\011\002\000\000\000\000\000\000\011\002\011\002\000\000\000\000\ +\000\000\021\003\000\000\125\000\223\001\021\003\021\003\000\000\ +\011\002\000\000\000\000\011\002\000\000\000\000\000\000\126\000\ +\000\000\021\003\126\000\000\000\021\003\000\000\125\000\000\000\ +\000\000\125\000\000\000\000\000\126\000\125\000\125\000\000\000\ +\000\000\000\000\000\000\000\000\125\000\000\000\000\000\000\000\ +\000\000\126\000\125\000\126\000\126\000\000\000\000\000\000\000\ +\061\000\000\000\000\000\000\000\000\000\000\000\125\000\000\000\ +\126\000\064\000\125\000\125\000\000\000\000\000\000\000\000\000\ +\023\003\000\000\000\000\000\000\000\000\000\000\125\000\000\000\ +\023\003\125\000\023\003\126\000\000\000\023\003\126\000\000\000\ +\000\000\000\000\126\000\126\000\000\000\000\000\000\000\023\003\ +\000\000\126\000\023\003\000\000\023\003\023\003\000\000\126\000\ +\000\000\000\000\000\000\000\000\023\003\000\000\023\003\023\003\ +\000\000\023\003\065\000\126\000\000\000\000\000\000\000\126\000\ +\126\000\000\000\000\000\023\003\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\126\000\023\003\000\000\126\000\023\003\ +\000\000\000\000\000\000\023\003\023\003\000\000\023\003\000\000\ +\000\000\023\003\023\003\118\000\000\000\023\003\023\003\000\000\ +\023\003\000\000\000\000\000\000\023\003\000\000\021\003\000\000\ +\118\000\000\000\023\003\000\000\023\003\000\000\000\000\000\000\ +\023\003\023\003\000\000\000\000\000\000\118\000\023\003\118\000\ +\118\000\000\000\023\003\023\003\023\003\000\000\000\000\023\003\ +\000\000\000\000\000\000\000\000\118\000\000\000\023\003\000\000\ +\000\000\023\003\000\000\000\000\021\003\000\000\000\000\021\003\ +\000\000\000\000\000\000\000\000\000\000\000\000\119\000\118\000\ +\000\000\021\003\118\000\000\000\000\000\000\000\118\000\118\000\ +\000\000\000\000\000\000\119\000\000\000\118\000\021\003\000\000\ +\021\003\021\003\000\000\118\000\000\000\000\000\000\000\000\000\ +\119\000\000\000\119\000\119\000\000\000\021\003\000\000\118\000\ +\000\000\000\000\000\000\118\000\118\000\000\000\000\000\119\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\118\000\ +\021\003\000\000\118\000\021\003\000\000\000\000\000\000\000\000\ +\021\003\000\000\119\000\000\000\223\001\119\000\021\003\000\000\ +\000\000\119\000\119\000\000\000\021\003\000\000\000\000\000\000\ +\119\000\223\001\000\000\000\000\000\000\000\000\119\000\000\000\ +\021\003\000\000\000\000\000\000\021\003\021\003\223\001\000\000\ +\223\001\223\001\119\000\000\000\000\000\000\000\119\000\119\000\ +\021\003\000\000\000\000\021\003\000\000\223\001\000\000\000\000\ +\061\000\000\000\119\000\000\000\000\000\119\000\000\000\000\000\ +\000\000\064\000\000\000\000\000\000\000\061\000\000\000\000\000\ +\223\001\000\000\000\000\223\001\000\000\000\000\064\000\223\001\ +\223\001\000\000\061\000\000\000\061\000\061\000\223\001\000\000\ +\000\000\000\000\000\000\064\000\223\001\064\000\064\000\000\000\ +\000\000\061\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\223\001\000\000\064\000\000\000\223\001\223\001\000\000\000\000\ +\000\000\000\000\065\000\000\000\061\000\000\000\000\000\061\000\ +\223\001\000\000\000\000\223\001\061\000\064\000\000\000\065\000\ +\064\000\000\000\061\000\000\000\000\000\064\000\000\000\000\000\ +\061\000\000\000\000\000\064\000\065\000\000\000\065\000\065\000\ +\000\000\064\000\000\000\000\000\061\000\000\000\000\000\000\000\ +\061\000\061\000\000\000\065\000\000\000\064\000\021\003\000\000\ +\000\000\064\000\064\000\000\000\061\000\000\000\000\000\061\000\ +\000\000\000\000\000\000\021\003\000\000\064\000\065\000\000\000\ +\064\000\065\000\000\000\000\000\000\000\000\000\065\000\000\000\ +\021\003\000\000\021\003\021\003\065\000\000\000\000\000\000\000\ +\000\000\000\000\065\000\000\000\000\000\000\000\000\000\021\003\ +\000\000\000\000\000\000\000\000\000\000\000\000\065\000\000\000\ +\000\000\000\000\065\000\065\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\021\003\000\000\000\000\021\003\065\000\000\000\ +\000\000\065\000\021\003\000\000\000\000\000\000\000\000\000\000\ +\021\003\000\000\000\000\000\000\000\000\000\000\021\003\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\021\003\016\003\000\000\000\000\021\003\021\003\ +\016\003\016\003\016\003\016\003\000\000\000\000\016\003\016\003\ +\016\003\016\003\021\003\000\000\000\000\021\003\016\003\000\000\ +\000\000\000\000\000\000\000\000\000\000\016\003\000\000\016\003\ +\016\003\016\003\016\003\016\003\016\003\016\003\016\003\000\000\ +\000\000\000\000\016\003\000\000\016\003\000\000\000\000\000\000\ +\000\000\000\000\000\000\016\003\016\003\016\003\016\003\016\003\ +\016\003\016\003\016\003\016\003\000\000\000\000\016\003\016\003\ +\000\000\000\000\016\003\016\003\016\003\016\003\000\000\016\003\ +\016\003\016\003\016\003\016\003\000\000\016\003\000\000\016\003\ +\016\003\016\003\000\000\016\003\016\003\000\000\000\000\016\003\ +\016\003\000\000\016\003\000\000\016\003\016\003\000\000\016\003\ +\016\003\000\000\000\000\016\003\016\003\000\000\016\003\000\000\ +\016\003\016\003\000\000\016\003\000\000\016\003\016\003\016\003\ +\016\003\016\003\016\003\016\003\023\003\016\003\000\000\000\000\ +\000\000\023\003\023\003\023\003\023\003\000\000\000\000\023\003\ +\023\003\000\000\000\000\000\000\000\000\000\000\000\000\023\003\ +\000\000\000\000\000\000\000\000\000\000\000\000\023\003\000\000\ +\023\003\000\000\023\003\023\003\023\003\023\003\023\003\023\003\ +\000\000\000\000\000\000\023\003\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\023\003\023\003\023\003\023\003\ +\023\003\023\003\023\003\023\003\023\003\000\000\000\000\023\003\ +\023\003\000\000\000\000\023\003\023\003\023\003\000\000\000\000\ +\023\003\023\003\023\003\023\003\023\003\000\000\023\003\000\000\ +\023\003\023\003\023\003\000\000\000\000\023\003\000\000\000\000\ +\023\003\023\003\000\000\023\003\000\000\023\003\023\003\000\000\ +\000\000\023\003\000\000\000\000\000\000\023\003\000\000\023\003\ +\000\000\023\003\023\003\000\000\023\003\000\000\023\003\023\003\ +\000\000\023\003\023\003\023\003\023\003\000\000\023\003\026\001\ +\027\001\028\001\000\000\000\000\009\000\010\000\029\001\000\000\ +\030\001\000\000\012\000\013\000\000\000\000\000\031\001\032\001\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\033\001\000\000\000\000\017\000\018\000\019\000\ +\020\000\021\000\000\000\034\001\000\000\000\000\022\000\000\000\ +\000\000\035\001\036\001\037\001\038\001\039\001\040\001\000\000\ +\000\000\024\000\000\000\025\000\026\000\027\000\028\000\029\000\ +\000\000\000\000\030\000\000\000\041\001\000\000\032\000\033\000\ +\034\000\000\000\000\000\000\000\036\000\000\000\042\001\043\001\ +\000\000\044\001\000\000\040\000\000\000\041\000\000\000\000\000\ +\000\000\045\001\046\001\047\001\048\001\049\001\050\001\000\000\ +\000\000\000\000\000\000\000\000\000\000\051\001\000\000\000\000\ +\000\000\052\001\000\000\053\001\047\000\000\000\000\000\000\000\ +\000\000\048\000\049\000\000\000\051\000\052\000\026\001\027\001\ +\028\001\054\000\000\000\009\000\010\000\029\001\000\000\030\001\ +\000\000\012\000\013\000\000\000\000\000\079\003\032\001\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\033\001\000\000\000\000\017\000\018\000\019\000\020\000\ +\021\000\000\000\034\001\000\000\000\000\022\000\000\000\000\000\ +\035\001\036\001\037\001\038\001\039\001\040\001\000\000\000\000\ +\024\000\000\000\025\000\026\000\027\000\028\000\029\000\000\000\ +\000\000\030\000\000\000\041\001\000\000\032\000\033\000\034\000\ +\000\000\000\000\000\000\036\000\000\000\042\001\043\001\000\000\ +\080\003\000\000\040\000\000\000\041\000\000\000\000\000\000\000\ +\045\001\046\001\047\001\048\001\049\001\050\001\000\000\000\000\ +\000\000\000\000\000\000\089\002\081\003\089\002\089\002\089\002\ +\052\001\089\002\053\001\047\000\089\002\089\002\000\000\000\000\ +\048\000\049\000\000\000\051\000\052\000\023\003\000\000\000\000\ +\054\000\000\000\023\003\023\003\023\003\089\002\000\000\000\000\ +\023\003\023\003\023\003\000\000\000\000\089\002\089\002\000\000\ +\000\000\000\000\000\000\000\000\000\000\089\002\000\000\023\003\ +\000\000\023\003\023\003\023\003\023\003\023\003\023\003\023\003\ +\000\000\089\002\089\002\000\000\023\003\000\000\023\003\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\023\003\ +\000\000\023\003\023\003\023\003\023\003\023\003\000\000\000\000\ +\023\003\023\003\000\000\000\000\023\003\023\003\023\003\000\000\ +\000\000\023\003\023\003\000\000\023\003\023\003\000\000\023\003\ +\000\000\023\003\000\000\023\003\000\000\023\003\000\000\000\000\ +\000\000\023\003\023\003\143\002\023\003\000\000\000\000\000\000\ +\217\002\217\002\217\002\000\000\000\000\023\003\217\002\217\002\ +\000\000\000\000\023\003\000\000\000\000\000\000\000\000\023\003\ +\023\003\023\003\023\003\023\003\023\003\000\000\000\000\023\003\ +\000\000\217\002\217\002\217\002\217\002\217\002\000\000\000\000\ +\000\000\000\000\217\002\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\217\002\000\000\217\002\ +\217\002\217\002\217\002\217\002\000\000\000\000\217\002\000\000\ +\000\000\000\000\217\002\217\002\217\002\000\000\000\000\000\000\ +\217\002\000\000\217\002\217\002\000\000\000\000\000\000\217\002\ +\000\000\217\002\000\000\000\000\000\000\000\000\000\000\217\002\ +\217\002\144\002\217\002\000\000\000\000\000\000\218\002\218\002\ +\218\002\143\002\000\000\000\000\218\002\218\002\000\000\000\000\ +\217\002\000\000\000\000\000\000\000\000\217\002\217\002\000\000\ +\217\002\217\002\000\000\000\000\000\000\217\002\000\000\218\002\ +\218\002\218\002\218\002\218\002\000\000\000\000\000\000\000\000\ +\218\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\218\002\000\000\218\002\218\002\218\002\ +\218\002\218\002\000\000\000\000\218\002\000\000\000\000\000\000\ +\218\002\218\002\218\002\000\000\000\000\000\000\218\002\000\000\ +\218\002\218\002\000\000\000\000\000\000\218\002\000\000\218\002\ +\000\000\000\000\000\000\000\000\000\000\218\002\218\002\141\002\ +\218\002\000\000\000\000\000\000\219\002\219\002\219\002\144\002\ +\000\000\000\000\219\002\219\002\000\000\000\000\218\002\000\000\ +\000\000\000\000\000\000\218\002\218\002\000\000\218\002\218\002\ +\000\000\000\000\000\000\218\002\000\000\219\002\219\002\219\002\ +\219\002\219\002\000\000\000\000\000\000\000\000\219\002\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\219\002\000\000\219\002\219\002\219\002\219\002\219\002\ +\000\000\000\000\219\002\000\000\000\000\000\000\219\002\219\002\ +\219\002\000\000\000\000\000\000\219\002\000\000\219\002\219\002\ +\000\000\000\000\000\000\219\002\000\000\219\002\000\000\000\000\ +\000\000\000\000\000\000\219\002\219\002\142\002\219\002\000\000\ +\000\000\000\000\220\002\220\002\220\002\141\002\000\000\000\000\ +\220\002\220\002\000\000\000\000\219\002\000\000\000\000\000\000\ +\000\000\219\002\219\002\000\000\219\002\219\002\000\000\000\000\ +\000\000\219\002\000\000\220\002\220\002\220\002\220\002\220\002\ +\000\000\000\000\000\000\000\000\220\002\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\220\002\ +\000\000\220\002\220\002\220\002\220\002\220\002\000\000\000\000\ +\220\002\000\000\000\000\000\000\220\002\220\002\220\002\000\000\ +\000\000\000\000\220\002\000\000\220\002\220\002\000\000\000\000\ +\000\000\220\002\000\000\220\002\000\000\000\000\000\000\000\000\ +\000\000\220\002\220\002\000\000\220\002\000\000\000\000\000\000\ +\000\000\000\000\000\000\142\002\224\000\225\000\226\000\000\000\ +\000\000\000\000\220\002\000\000\227\000\000\000\228\000\220\002\ +\220\002\000\000\220\002\220\002\229\000\230\000\231\000\220\002\ +\000\000\232\000\233\000\234\000\000\000\235\000\236\000\237\000\ +\000\000\238\000\239\000\240\000\241\000\000\000\000\000\000\000\ +\242\000\243\000\244\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\245\000\246\000\000\000\000\000\247\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\248\000\249\000\000\000\000\000\000\000\062\002\250\000\251\000\ +\000\000\062\002\000\000\252\000\253\000\254\000\255\000\000\001\ +\001\001\002\001\000\000\003\001\000\000\000\000\062\002\000\000\ +\062\002\004\001\000\000\045\002\000\000\000\000\005\001\062\002\ +\062\002\000\000\000\000\000\000\006\001\000\000\000\000\007\001\ +\008\001\062\002\009\001\010\001\011\001\012\001\013\001\000\000\ +\014\001\015\001\016\001\017\001\018\001\062\002\062\002\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\062\002\000\000\000\000\000\000\062\002\000\000\062\002\ +\062\002\062\002\000\000\062\002\000\000\000\000\062\002\000\000\ +\000\000\000\000\026\001\027\001\028\001\000\000\000\000\000\000\ +\010\000\207\001\000\000\030\001\000\000\000\000\013\000\045\002\ +\062\002\031\001\032\001\000\000\062\002\000\000\062\002\000\000\ +\000\000\062\002\000\000\000\000\000\000\033\001\161\000\000\000\ +\017\000\018\000\062\002\000\000\062\002\000\000\034\001\000\000\ +\000\000\000\000\000\000\000\000\035\001\036\001\037\001\038\001\ +\039\001\040\001\000\000\000\000\024\000\000\000\162\000\163\000\ +\000\000\164\000\165\000\000\000\000\000\030\000\000\000\041\001\ +\000\000\000\000\166\000\167\000\000\000\000\000\000\000\000\000\ +\000\000\208\001\209\001\000\000\210\001\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\045\001\046\001\211\001\212\001\ +\049\001\213\001\000\000\000\000\000\000\000\000\000\000\000\000\ +\051\001\000\000\000\000\170\000\052\001\000\000\053\001\047\000\ +\000\000\000\000\000\000\000\000\048\000\000\000\240\002\051\000\ +\171\000\026\001\027\001\028\001\000\000\000\000\000\000\010\000\ +\207\001\000\000\030\001\000\000\000\000\013\000\000\000\000\000\ +\031\001\032\001\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\033\001\161\000\000\000\017\000\ +\018\000\000\000\000\000\000\000\000\000\034\001\000\000\000\000\ +\000\000\000\000\000\000\035\001\036\001\037\001\038\001\039\001\ +\040\001\000\000\000\000\024\000\000\000\162\000\163\000\000\000\ +\164\000\165\000\000\000\000\000\030\000\000\000\041\001\000\000\ +\000\000\166\000\167\000\000\000\000\000\000\000\000\000\000\000\ +\208\001\209\001\000\000\210\001\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\045\001\046\001\211\001\212\001\049\001\ +\213\001\000\000\000\000\000\000\000\000\000\000\000\000\051\001\ +\000\000\000\000\170\000\052\001\000\000\053\001\047\000\000\000\ +\000\000\000\000\000\000\048\000\000\000\194\003\051\000\171\000\ +\026\001\027\001\028\001\000\000\000\000\000\000\010\000\207\001\ +\000\000\030\001\000\000\000\000\013\000\000\000\000\000\031\001\ +\032\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\033\001\161\000\000\000\017\000\018\000\ +\000\000\000\000\000\000\000\000\034\001\000\000\000\000\000\000\ +\000\000\000\000\035\001\036\001\037\001\038\001\039\001\040\001\ +\000\000\000\000\024\000\000\000\162\000\163\000\000\000\164\000\ +\165\000\000\000\000\000\030\000\000\000\041\001\000\000\000\000\ +\166\000\167\000\000\000\000\000\000\000\000\000\000\000\208\001\ +\209\001\000\000\210\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\045\001\046\001\211\001\212\001\049\001\213\001\ +\000\000\000\000\000\000\000\000\000\000\000\000\051\001\000\000\ +\000\000\170\000\052\001\000\000\053\001\047\000\000\000\000\000\ +\000\000\000\000\048\000\000\000\154\004\051\000\171\000\026\001\ +\027\001\028\001\000\000\000\000\000\000\010\000\207\001\000\000\ +\030\001\000\000\000\000\013\000\000\000\000\000\031\001\032\001\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\033\001\161\000\000\000\017\000\018\000\000\000\ +\000\000\000\000\000\000\034\001\000\000\000\000\000\000\000\000\ +\000\000\035\001\036\001\037\001\038\001\039\001\040\001\000\000\ +\000\000\024\000\000\000\162\000\163\000\000\000\164\000\165\000\ +\000\000\000\000\030\000\000\000\041\001\000\000\000\000\166\000\ +\167\000\000\000\000\000\000\000\000\000\000\000\208\001\209\001\ +\000\000\210\001\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\045\001\046\001\211\001\212\001\049\001\213\001\000\000\ +\000\000\157\003\000\000\000\000\000\000\051\001\000\000\010\000\ +\170\000\052\001\000\000\053\001\047\000\013\000\000\000\000\000\ +\079\003\048\000\000\000\000\000\051\000\171\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\161\000\000\000\017\000\ +\018\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\024\000\000\000\162\000\163\000\000\000\ +\164\000\165\000\000\000\000\000\030\000\000\000\200\002\000\000\ +\000\000\166\000\167\000\000\000\010\000\000\000\000\000\000\000\ +\168\000\000\000\013\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\169\000\000\000\000\000\ +\000\000\000\000\161\000\000\000\017\000\018\000\000\000\158\003\ +\000\000\000\000\170\000\000\000\000\000\000\000\047\000\000\000\ +\000\000\000\000\000\000\048\000\000\000\000\000\051\000\171\000\ +\024\000\000\000\162\000\163\000\000\000\164\000\165\000\000\000\ +\000\000\030\000\000\000\202\002\000\000\000\000\166\000\167\000\ +\000\000\010\000\000\000\000\000\000\000\168\000\000\000\013\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\169\000\000\000\000\000\000\000\000\000\161\000\ +\000\000\017\000\018\000\000\000\000\000\000\000\000\000\170\000\ +\000\000\000\000\000\000\047\000\000\000\000\000\000\000\000\000\ +\048\000\000\000\000\000\051\000\171\000\024\000\000\000\162\000\ +\163\000\000\000\164\000\165\000\000\000\000\000\030\000\000\000\ +\204\002\000\000\000\000\166\000\167\000\000\000\010\000\000\000\ +\000\000\000\000\168\000\000\000\013\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\169\000\ +\000\000\000\000\000\000\000\000\161\000\000\000\017\000\018\000\ +\000\000\000\000\000\000\000\000\170\000\000\000\000\000\000\000\ +\047\000\000\000\000\000\000\000\000\000\048\000\000\000\000\000\ +\051\000\171\000\024\000\000\000\162\000\163\000\000\000\164\000\ +\165\000\000\000\000\000\030\000\000\000\161\004\000\000\000\000\ +\166\000\167\000\000\000\010\000\000\000\000\000\000\000\168\000\ +\000\000\013\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\169\000\000\000\000\000\000\000\ +\000\000\161\000\000\000\017\000\018\000\000\000\000\000\000\000\ +\000\000\170\000\000\000\000\000\000\000\047\000\000\000\000\000\ +\000\000\000\000\048\000\000\000\000\000\051\000\171\000\024\000\ +\000\000\162\000\163\000\000\000\164\000\165\000\000\000\000\000\ +\030\000\000\000\163\004\000\000\000\000\166\000\167\000\000\000\ +\010\000\000\000\000\000\000\000\168\000\000\000\013\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\169\000\000\000\000\000\000\000\000\000\161\000\000\000\ +\017\000\018\000\000\000\000\000\000\000\000\000\170\000\000\000\ +\000\000\000\000\047\000\000\000\000\000\000\000\000\000\048\000\ +\000\000\000\000\051\000\171\000\024\000\000\000\162\000\163\000\ +\000\000\164\000\165\000\000\000\000\000\030\000\000\000\165\004\ +\000\000\000\000\166\000\167\000\000\000\010\000\000\000\000\000\ +\000\000\168\000\000\000\013\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\169\000\000\000\ +\000\000\000\000\000\000\161\000\000\000\017\000\018\000\000\000\ +\000\000\000\000\000\000\170\000\000\000\000\000\000\000\047\000\ +\000\000\000\000\000\000\000\000\048\000\000\000\000\000\051\000\ +\171\000\024\000\000\000\162\000\163\000\000\000\164\000\165\000\ +\000\000\000\000\030\000\000\000\000\000\000\000\000\000\166\000\ +\167\000\009\000\010\000\011\000\000\000\000\000\168\000\012\000\ +\013\000\014\000\032\002\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\169\000\000\000\000\000\000\000\000\000\ +\015\000\016\000\017\000\018\000\019\000\020\000\021\000\000\000\ +\170\000\000\000\000\000\022\000\047\000\023\000\000\000\000\000\ +\000\000\048\000\000\000\000\000\051\000\171\000\024\000\000\000\ +\025\000\026\000\027\000\028\000\029\000\000\000\000\000\030\000\ +\031\000\000\000\000\000\032\000\033\000\034\000\000\000\000\000\ +\035\000\036\000\000\000\037\000\038\000\000\000\039\000\000\000\ +\040\000\000\000\041\000\000\000\042\000\000\000\000\000\000\000\ +\043\000\044\000\000\000\045\000\000\000\033\002\000\000\000\000\ +\009\000\010\000\011\000\000\000\046\000\000\000\012\000\013\000\ +\014\000\047\000\000\000\000\000\000\000\000\000\048\000\049\000\ +\050\000\051\000\052\000\053\000\000\000\000\000\054\000\015\000\ +\016\000\017\000\018\000\019\000\020\000\021\000\000\000\000\000\ +\000\000\000\000\022\000\000\000\023\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\024\000\000\000\025\000\ +\026\000\027\000\028\000\029\000\000\000\000\000\030\000\031\000\ +\000\000\000\000\032\000\033\000\034\000\000\000\000\000\035\000\ +\036\000\000\000\037\000\038\000\000\000\039\000\000\000\040\000\ +\000\000\041\000\000\000\042\000\000\000\000\000\000\000\043\000\ +\044\000\000\000\045\000\000\000\000\000\000\000\009\000\010\000\ +\011\000\000\000\000\000\046\000\012\000\013\000\000\000\000\000\ +\047\000\000\000\000\000\000\000\000\000\048\000\049\000\050\000\ +\051\000\052\000\053\000\000\000\000\000\054\000\000\000\017\000\ +\018\000\019\000\020\000\021\000\000\000\000\000\000\000\000\000\ +\022\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\024\000\000\000\025\000\026\000\027\000\ +\028\000\029\000\000\000\000\000\030\000\000\000\000\000\000\000\ +\032\000\033\000\034\000\000\000\000\000\000\000\036\000\000\000\ +\037\000\038\000\000\000\000\000\000\000\040\000\000\000\041\000\ +\000\000\000\000\000\000\000\000\000\000\043\000\044\000\000\000\ +\045\000\000\000\000\000\000\000\000\000\219\000\009\000\010\000\ +\011\000\000\000\000\000\222\000\012\000\013\000\047\000\000\000\ +\000\000\000\000\000\000\048\000\049\000\000\000\051\000\052\000\ +\000\000\000\000\000\000\054\000\000\000\000\000\000\000\017\000\ +\018\000\019\000\020\000\021\000\000\000\000\000\000\000\000\000\ +\022\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\024\000\000\000\025\000\026\000\027\000\ +\028\000\029\000\000\000\000\000\030\000\000\000\000\000\000\000\ +\032\000\033\000\034\000\000\000\000\000\000\000\036\000\000\000\ +\037\000\038\000\000\000\000\000\000\000\040\000\000\000\041\000\ +\000\000\000\000\000\000\000\000\000\000\043\000\044\000\000\000\ +\045\000\000\000\000\000\009\000\010\000\011\000\000\000\000\000\ +\000\000\012\000\013\000\000\000\000\000\000\000\047\000\000\000\ +\000\000\000\000\000\000\048\000\049\000\000\000\051\000\052\000\ +\238\001\000\000\000\000\054\000\017\000\018\000\019\000\020\000\ +\021\000\000\000\000\000\000\000\000\000\022\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\024\000\000\000\025\000\026\000\027\000\028\000\029\000\000\000\ +\000\000\030\000\000\000\000\000\000\000\032\000\033\000\034\000\ +\000\000\000\000\000\000\036\000\000\000\037\000\038\000\000\000\ +\000\000\000\000\040\000\000\000\041\000\000\000\000\000\000\000\ +\000\000\000\000\043\000\044\000\000\000\045\000\000\000\000\000\ +\009\000\010\000\011\000\000\000\000\000\000\000\012\000\013\000\ +\000\000\000\000\000\000\047\000\000\000\000\000\000\000\000\000\ +\048\000\049\000\000\000\051\000\052\000\000\000\000\000\000\000\ +\054\000\017\000\018\000\019\000\020\000\021\000\000\000\000\000\ +\000\000\000\000\022\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\024\000\000\000\025\000\ +\026\000\027\000\028\000\029\000\000\000\000\000\030\000\000\000\ +\000\000\000\000\032\000\033\000\034\000\000\000\000\000\000\000\ +\036\000\000\000\037\000\038\000\000\000\000\000\000\000\040\000\ +\000\000\041\000\000\000\000\000\000\000\000\000\100\002\043\000\ +\044\000\000\000\045\000\000\000\000\000\009\000\010\000\011\000\ +\000\000\000\000\000\000\012\000\013\000\000\000\000\000\000\000\ +\047\000\000\000\000\000\000\000\000\000\048\000\049\000\000\000\ +\051\000\052\000\000\000\000\000\000\000\054\000\017\000\018\000\ +\019\000\020\000\021\000\000\000\000\000\000\000\000\000\022\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\024\000\000\000\025\000\026\000\027\000\028\000\ +\029\000\000\000\000\000\030\000\000\000\000\000\000\000\032\000\ +\033\000\034\000\000\000\000\000\000\000\036\000\000\000\037\000\ +\038\000\000\000\000\000\000\000\040\000\000\000\041\000\000\000\ +\000\000\000\000\000\000\000\000\043\000\044\000\000\000\045\000\ +\000\000\000\000\000\000\000\000\075\003\009\000\010\000\011\000\ +\000\000\000\000\077\003\012\000\013\000\047\000\000\000\000\000\ +\000\000\000\000\048\000\049\000\000\000\051\000\052\000\000\000\ +\000\000\000\000\054\000\000\000\000\000\000\000\017\000\018\000\ +\019\000\020\000\021\000\000\000\000\000\000\000\000\000\022\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\024\000\000\000\025\000\026\000\027\000\028\000\ +\029\000\000\000\000\000\030\000\000\000\000\000\000\000\032\000\ +\033\000\034\000\000\000\000\000\000\000\036\000\000\000\037\000\ +\038\000\000\000\000\000\000\000\040\000\000\000\041\000\000\000\ +\000\000\000\000\000\000\000\000\043\000\044\000\000\000\045\000\ +\000\000\000\000\000\000\009\000\010\000\011\000\000\000\000\000\ +\000\000\012\000\013\000\000\000\000\000\047\000\000\000\000\000\ +\000\000\000\000\048\000\049\000\134\004\051\000\052\000\000\000\ +\000\000\000\000\054\000\000\000\017\000\018\000\019\000\020\000\ +\021\000\000\000\000\000\000\000\000\000\022\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\024\000\000\000\025\000\026\000\027\000\028\000\029\000\000\000\ +\000\000\030\000\000\000\000\000\000\000\032\000\033\000\034\000\ +\000\000\000\000\000\000\036\000\000\000\037\000\038\000\000\000\ +\000\000\000\000\040\000\000\000\041\000\000\000\000\000\000\000\ +\000\000\000\000\043\000\044\000\000\000\045\000\000\000\000\000\ +\025\003\025\003\025\003\000\000\000\000\000\000\025\003\025\003\ +\000\000\000\000\000\000\047\000\000\000\000\000\000\000\000\000\ +\048\000\049\000\000\000\051\000\052\000\025\003\000\000\000\000\ +\054\000\025\003\025\003\025\003\025\003\025\003\000\000\000\000\ +\000\000\000\000\025\003\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\025\003\000\000\025\003\ +\025\003\025\003\025\003\025\003\000\000\000\000\025\003\000\000\ +\000\000\000\000\025\003\025\003\025\003\000\000\000\000\000\000\ +\025\003\000\000\025\003\025\003\000\000\000\000\000\000\025\003\ +\000\000\025\003\000\000\000\000\000\000\000\000\000\000\025\003\ +\025\003\000\000\025\003\000\000\000\000\009\000\010\000\011\000\ +\000\000\000\000\000\000\012\000\013\000\000\000\000\000\000\000\ +\025\003\000\000\000\000\000\000\000\000\025\003\025\003\000\000\ +\025\003\025\003\000\000\000\000\000\000\025\003\017\000\018\000\ +\019\000\020\000\021\000\000\000\000\000\000\000\000\000\022\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\024\000\000\000\025\000\026\000\027\000\028\000\ +\029\000\000\000\000\000\030\000\000\000\000\000\000\000\032\000\ +\033\000\034\000\000\000\000\000\000\000\036\000\000\000\037\000\ +\038\000\000\000\000\000\000\000\040\000\000\000\041\000\000\000\ +\000\000\000\000\000\000\000\000\043\000\044\000\000\000\045\000\ +\000\000\000\000\025\003\025\003\025\003\000\000\000\000\000\000\ +\025\003\025\003\000\000\000\000\000\000\047\000\000\000\000\000\ +\000\000\000\000\048\000\049\000\000\000\051\000\052\000\000\000\ +\000\000\000\000\054\000\025\003\025\003\025\003\025\003\025\003\ +\000\000\000\000\000\000\000\000\025\003\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\025\003\ +\000\000\025\003\025\003\025\003\025\003\025\003\000\000\000\000\ +\025\003\000\000\000\000\000\000\025\003\025\003\025\003\000\000\ +\000\000\000\000\025\003\000\000\025\003\025\003\000\000\000\000\ +\000\000\025\003\000\000\025\003\000\000\000\000\000\000\000\000\ +\000\000\025\003\025\003\000\000\025\003\000\000\000\000\023\003\ +\023\003\023\003\000\000\000\000\000\000\023\003\023\003\000\000\ +\000\000\000\000\025\003\000\000\000\000\000\000\000\000\025\003\ +\025\003\000\000\025\003\025\003\000\000\000\000\000\000\025\003\ +\023\003\023\003\023\003\023\003\023\003\000\000\000\000\000\000\ +\000\000\023\003\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\023\003\000\000\023\003\023\003\ +\023\003\023\003\023\003\000\000\000\000\023\003\000\000\000\000\ +\000\000\023\003\023\003\023\003\000\000\000\000\000\000\023\003\ +\000\000\023\003\023\003\000\000\000\000\010\000\023\003\000\000\ +\023\003\000\000\000\000\013\000\000\000\217\003\023\003\023\003\ +\018\002\023\003\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\218\003\000\000\000\000\017\000\018\000\023\003\ +\000\000\000\000\000\000\000\000\023\003\023\003\000\000\023\003\ +\023\003\000\000\000\000\000\000\023\003\000\000\000\000\000\000\ +\000\000\024\000\252\001\000\000\163\000\000\000\164\000\165\000\ +\000\000\000\000\030\000\000\000\000\000\000\000\000\000\166\000\ +\219\003\000\000\010\000\000\000\000\000\000\000\168\000\000\000\ +\013\000\000\000\017\002\000\000\000\000\018\002\000\000\000\000\ +\254\001\000\000\000\000\169\000\000\000\000\000\000\000\218\003\ +\255\001\000\000\017\000\018\000\000\000\010\000\000\000\000\000\ +\170\000\000\000\000\000\013\000\047\000\250\002\000\000\000\002\ +\000\000\048\000\000\000\000\000\051\000\171\000\024\000\252\001\ +\000\000\163\000\000\000\164\000\165\000\017\000\018\000\030\000\ +\000\000\000\000\000\000\000\000\166\000\219\003\000\000\000\000\ +\000\000\000\000\000\000\168\000\000\000\000\000\000\000\000\000\ +\000\000\024\000\252\001\000\000\163\000\254\001\164\000\165\000\ +\169\000\000\000\030\000\000\000\000\000\255\001\000\000\166\000\ +\251\002\000\000\000\000\000\000\000\000\170\000\168\000\000\000\ +\252\002\047\000\000\000\000\000\000\002\000\000\048\000\000\000\ +\254\001\051\000\171\000\169\000\000\000\000\000\010\000\000\000\ +\255\001\000\000\000\000\000\000\013\000\000\000\107\004\000\000\ +\170\000\000\000\000\000\000\000\047\000\000\000\000\000\000\002\ +\000\000\048\000\000\000\108\004\051\000\171\000\017\000\018\000\ +\000\000\010\000\000\000\000\000\000\000\000\000\000\000\013\000\ +\000\000\031\006\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\024\000\252\001\000\000\163\000\218\003\164\000\ +\165\000\017\000\018\000\030\000\000\000\000\000\000\000\000\000\ +\166\000\167\000\000\000\000\000\000\000\000\000\000\000\168\000\ +\000\000\000\000\000\000\000\000\000\000\024\000\252\001\000\000\ +\163\000\254\001\164\000\165\000\169\000\000\000\030\000\000\000\ +\000\000\255\001\000\000\166\000\219\003\000\000\010\000\000\000\ +\000\000\170\000\168\000\000\000\013\000\047\000\000\000\000\000\ +\000\002\000\000\048\000\000\000\254\001\051\000\171\000\169\000\ +\000\000\000\000\000\000\000\000\255\001\000\000\017\000\018\000\ +\000\000\010\000\000\000\000\000\170\000\000\000\000\000\013\000\ +\047\000\000\000\000\000\000\002\000\000\048\000\000\000\000\000\ +\051\000\171\000\024\000\252\001\000\000\163\000\000\000\164\000\ +\165\000\017\000\018\000\030\000\000\000\000\000\000\000\000\000\ +\166\000\167\000\000\000\000\000\000\000\000\000\000\000\168\000\ +\000\000\015\006\000\000\000\000\000\000\024\000\252\001\000\000\ +\163\000\254\001\164\000\165\000\169\000\000\000\030\000\000\000\ +\000\000\255\001\000\000\166\000\253\001\000\000\010\000\000\000\ +\000\000\170\000\168\000\000\000\013\000\047\000\000\000\000\000\ +\000\002\000\000\048\000\000\000\254\001\051\000\171\000\169\000\ +\000\000\000\000\000\000\000\000\255\001\000\000\017\000\018\000\ +\000\000\025\003\000\000\000\000\170\000\000\000\000\000\025\003\ +\047\000\000\000\000\000\000\002\000\000\048\000\000\000\000\000\ +\051\000\171\000\024\000\252\001\000\000\163\000\000\000\164\000\ +\165\000\025\003\025\003\030\000\000\000\000\000\000\000\000\000\ +\166\000\167\000\000\000\000\000\000\000\000\000\000\000\168\000\ +\000\000\000\000\000\000\000\000\000\000\025\003\025\003\000\000\ +\025\003\254\001\025\003\025\003\169\000\000\000\025\003\000\000\ +\000\000\255\001\000\000\025\003\025\003\000\000\023\003\000\000\ +\000\000\170\000\025\003\000\000\023\003\047\000\000\000\000\000\ +\000\002\000\000\048\000\000\000\025\003\051\000\171\000\025\003\ +\000\000\000\000\000\000\000\000\025\003\000\000\023\003\023\003\ +\000\000\000\000\000\000\000\000\025\003\000\000\000\000\000\000\ +\025\003\000\000\000\000\025\003\000\000\025\003\000\000\000\000\ +\025\003\025\003\023\003\023\003\000\000\023\003\000\000\023\003\ +\023\003\000\000\000\000\023\003\000\000\000\000\000\000\000\000\ +\023\003\023\003\000\000\000\000\010\000\000\000\000\000\023\003\ +\000\000\000\000\013\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\023\003\000\000\000\000\023\003\000\000\000\000\000\000\ +\000\000\023\003\161\000\000\000\017\000\018\000\000\000\000\000\ +\000\000\023\003\000\000\000\000\000\000\023\003\000\000\000\000\ +\023\003\000\000\023\003\000\000\000\000\023\003\023\003\000\000\ +\024\000\000\000\162\000\163\000\000\000\164\000\165\000\000\000\ +\000\000\030\000\000\000\000\000\000\000\000\000\166\000\167\000\ +\000\000\000\000\000\000\010\000\000\000\168\000\000\000\205\001\ +\000\000\013\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\169\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\161\000\219\000\017\000\018\000\000\000\000\000\170\000\ +\000\000\000\000\000\000\047\000\000\000\000\000\000\000\000\000\ +\048\000\000\000\000\000\051\000\171\000\000\000\000\000\024\000\ +\000\000\162\000\163\000\000\000\164\000\165\000\000\000\000\000\ +\030\000\000\000\000\000\000\000\000\000\166\000\167\000\000\000\ +\010\000\000\000\000\000\000\000\168\000\000\000\013\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\010\000\011\000\000\000\ +\000\000\169\000\012\000\013\000\000\000\000\000\161\000\000\000\ +\017\000\018\000\000\000\000\000\000\000\000\000\170\000\000\000\ +\000\000\000\000\047\000\000\000\000\000\017\000\018\000\048\000\ +\000\000\000\000\051\000\171\000\024\000\000\000\162\000\163\000\ +\000\000\164\000\165\000\000\000\000\000\030\000\000\000\000\000\ +\000\000\024\000\166\000\167\000\026\000\027\000\028\000\029\000\ +\000\000\168\000\030\000\000\000\025\003\000\000\025\003\166\000\ +\034\000\000\000\025\003\000\000\000\000\000\000\169\000\000\000\ +\000\000\000\000\000\000\040\000\000\000\000\000\156\003\000\000\ +\000\000\000\000\025\003\170\000\025\003\025\003\045\000\047\000\ +\000\000\000\000\000\000\000\000\048\000\000\000\000\000\051\000\ +\171\000\000\000\000\000\000\000\047\000\000\000\000\000\000\000\ +\025\003\048\000\025\003\025\003\051\000\025\003\025\003\000\000\ +\000\000\025\003\000\000\000\000\000\000\000\000\025\003\025\003\ +\000\000\010\000\000\000\000\000\000\000\025\003\000\000\013\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\025\003\000\000\000\000\000\000\000\000\161\000\ +\000\000\017\000\018\000\000\000\000\000\000\000\000\000\025\003\ +\000\000\000\000\000\000\025\003\000\000\000\000\000\000\000\000\ +\025\003\000\000\000\000\025\003\025\003\024\000\000\000\162\000\ +\163\000\000\000\164\000\165\000\000\000\000\000\030\000\000\000\ +\000\000\000\000\000\000\166\000\167\000\000\000\025\003\000\000\ +\000\000\000\000\168\000\000\000\025\003\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\169\000\ +\000\000\000\000\000\000\000\000\025\003\000\000\025\003\025\003\ +\000\000\025\003\000\000\000\000\170\000\000\000\000\000\025\003\ +\047\000\000\000\000\000\000\000\000\000\048\000\000\000\000\000\ +\051\000\171\000\025\003\000\000\025\003\025\003\000\000\025\003\ +\025\003\025\003\025\003\025\003\000\000\000\000\000\000\000\000\ +\025\003\025\003\000\000\000\000\000\000\000\000\000\000\025\003\ +\000\000\000\000\000\000\000\000\000\000\025\003\000\000\025\003\ +\025\003\000\000\025\003\025\003\025\003\000\000\025\003\000\000\ +\000\000\000\000\000\000\025\003\025\003\000\000\213\002\000\000\ +\000\000\025\003\025\003\000\000\213\002\025\003\000\000\000\000\ +\000\000\000\000\025\003\000\000\000\000\025\003\025\003\025\003\ +\000\000\000\000\000\000\000\000\213\002\000\000\213\002\213\002\ +\025\003\010\000\000\000\000\000\025\003\000\000\000\000\013\000\ +\025\003\000\000\000\000\000\000\000\000\025\003\000\000\000\000\ +\025\003\025\003\213\002\000\000\213\002\213\002\000\000\213\002\ +\213\002\017\000\018\000\213\002\000\000\000\000\000\000\000\000\ +\213\002\213\002\000\000\000\000\000\000\000\000\000\000\213\002\ +\000\000\000\000\000\000\000\000\000\000\024\000\000\000\162\000\ +\163\000\000\000\164\000\165\000\213\002\000\000\030\000\000\000\ +\000\000\000\000\000\000\166\000\167\000\000\000\194\002\000\000\ +\000\000\213\002\168\000\000\000\194\002\213\002\000\000\000\000\ +\000\000\000\000\213\002\000\000\000\000\213\002\213\002\169\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\194\002\194\002\ +\000\000\023\003\000\000\000\000\170\000\000\000\000\000\023\003\ +\047\000\000\000\000\000\000\000\000\000\048\000\000\000\000\000\ +\051\000\171\000\194\002\000\000\194\002\194\002\000\000\194\002\ +\194\002\023\003\023\003\194\002\000\000\000\000\000\000\000\000\ +\194\002\194\002\000\000\000\000\000\000\000\000\000\000\194\002\ +\000\000\000\000\000\000\000\000\000\000\023\003\000\000\023\003\ +\023\003\000\000\023\003\023\003\194\002\000\000\023\003\000\000\ +\000\000\000\000\000\000\023\003\023\003\000\000\010\000\000\000\ +\000\000\194\002\023\003\000\000\013\000\194\002\000\000\000\000\ +\000\000\000\000\194\002\000\000\000\000\194\002\194\002\023\003\ +\000\000\000\000\000\000\000\000\000\000\000\000\017\000\018\000\ +\000\000\025\003\000\000\000\000\023\003\000\000\000\000\025\003\ +\023\003\000\000\000\000\000\000\000\000\023\003\000\000\000\000\ +\023\003\023\003\024\000\000\000\000\000\163\000\000\000\164\000\ +\165\000\025\003\025\003\030\000\000\000\000\000\000\000\000\000\ +\166\000\167\000\000\000\000\000\000\000\000\000\000\000\168\000\ +\000\000\000\000\000\000\000\000\000\000\025\003\000\000\000\000\ +\025\003\000\000\025\003\025\003\169\000\000\000\025\003\000\000\ +\000\000\000\000\000\000\025\003\025\003\000\000\000\000\000\000\ +\000\000\170\000\025\003\000\000\000\000\047\000\010\000\011\000\ +\000\000\000\000\048\000\012\000\013\000\051\000\171\000\025\003\ +\000\000\000\000\000\000\000\000\000\000\000\000\115\001\000\000\ +\000\000\000\000\000\000\000\000\025\003\000\000\017\000\018\000\ +\025\003\000\000\000\000\000\000\000\000\025\003\000\000\000\000\ +\025\003\025\003\000\000\000\000\000\000\000\000\000\000\116\001\ +\000\000\000\000\024\000\117\001\000\000\026\000\027\000\028\000\ +\029\000\000\000\000\000\030\000\000\000\000\000\000\000\000\000\ +\166\000\034\000\010\000\011\000\000\000\000\000\000\000\012\000\ +\013\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\ +\000\000\118\001\000\000\000\000\000\000\000\000\000\000\045\000\ +\000\000\119\001\017\000\018\000\000\000\000\000\000\000\000\000\ +\000\000\120\001\121\001\000\000\000\000\047\000\000\000\000\000\ +\122\001\000\000\048\000\000\000\000\000\051\000\024\000\117\001\ +\000\000\026\000\027\000\028\000\029\000\000\000\000\000\030\000\ +\000\000\000\000\000\000\000\000\166\000\034\000\010\000\011\000\ +\000\000\000\000\000\000\012\000\013\000\025\003\025\003\000\000\ +\040\000\000\000\025\003\025\003\000\000\118\001\000\000\000\000\ +\000\000\000\000\000\000\045\000\000\000\119\001\017\000\018\000\ +\000\000\000\000\000\000\000\000\000\000\025\003\025\003\000\000\ +\000\000\047\000\000\000\000\000\122\001\000\000\048\000\000\000\ +\000\000\051\000\024\000\000\000\000\000\026\000\027\000\028\000\ +\029\000\025\003\000\000\030\000\025\003\025\003\025\003\025\003\ +\207\000\034\000\025\003\000\000\000\000\000\000\059\005\025\003\ +\025\003\000\000\000\000\000\000\040\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\025\003\000\000\060\005\000\000\045\000\ +\000\000\000\000\000\000\000\000\243\001\000\000\025\003\000\000\ +\000\000\000\000\000\000\000\000\000\000\047\000\000\000\000\000\ +\000\000\000\000\048\000\000\000\025\003\051\000\000\000\000\000\ +\000\000\025\003\000\000\000\000\025\003\061\005\000\000\137\000\ +\138\000\030\000\000\000\139\000\000\000\000\000\140\000\062\005\ +\000\000\000\000\000\000\032\005\078\001\079\001\000\000\000\000\ +\000\000\000\000\000\000\000\000\080\001\000\000\000\000\142\000\ +\000\000\033\005\081\001\082\001\034\005\083\001\063\005\143\000\ +\144\000\000\000\000\000\000\000\000\000\000\000\084\001\145\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\085\001\ +\246\001\000\000\000\000\064\005\147\000\086\001\087\001\088\001\ +\089\001\090\001\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\091\001\000\000\000\000\000\000\000\000\186\000\000\000\000\000\ +\000\000\000\000\092\001\093\001\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\094\001\095\001\096\001\ +\097\001\098\001\000\000\026\001\027\001\028\001\000\000\000\000\ +\000\000\035\005\207\001\000\000\030\001\000\000\000\000\100\001\ +\000\000\000\000\023\003\032\001\023\003\023\003\023\003\000\000\ +\023\003\000\000\000\000\023\003\023\003\000\000\033\001\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\034\001\ +\000\000\000\000\000\000\000\000\023\003\035\001\036\001\037\001\ +\038\001\039\001\040\001\000\000\023\003\023\003\000\000\000\000\ +\000\000\000\000\000\000\000\000\023\003\000\000\000\000\000\000\ +\041\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\023\003\023\003\234\002\209\001\000\000\235\002\000\000\000\000\ +\000\000\000\000\041\004\078\001\079\001\045\001\046\001\236\002\ +\212\001\049\001\213\001\080\001\000\000\000\000\000\000\000\000\ +\000\000\081\001\082\001\000\000\083\001\052\001\000\000\053\001\ +\000\000\000\000\000\000\000\000\000\000\084\001\000\000\000\000\ +\000\000\000\000\043\004\078\001\079\001\000\000\085\001\000\000\ +\000\000\000\000\000\000\080\001\086\001\087\001\088\001\089\001\ +\090\001\081\001\082\001\000\000\083\001\000\000\000\000\000\000\ +\043\002\000\000\043\002\043\002\043\002\084\001\043\002\091\001\ +\000\000\043\002\043\002\000\000\186\000\000\000\085\001\000\000\ +\000\000\092\001\093\001\000\000\086\001\087\001\088\001\089\001\ +\090\001\000\000\043\002\000\000\094\001\095\001\096\001\097\001\ +\098\001\000\000\043\002\043\002\000\000\042\004\000\000\091\001\ +\000\000\000\000\043\002\000\000\186\000\000\000\100\001\000\000\ +\000\000\092\001\093\001\000\000\000\000\000\000\043\002\043\002\ +\045\004\078\001\079\001\000\000\094\001\095\001\096\001\097\001\ +\098\001\080\001\000\000\000\000\000\000\000\000\044\004\081\001\ +\082\001\000\000\083\001\000\000\000\000\000\000\100\001\000\000\ +\000\000\000\000\000\000\084\001\000\000\000\000\000\000\000\000\ +\041\004\078\001\079\001\000\000\085\001\000\000\000\000\000\000\ +\000\000\080\001\086\001\087\001\088\001\089\001\090\001\081\001\ +\082\001\000\000\083\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\084\001\000\000\091\001\000\000\000\000\ +\000\000\000\000\186\000\000\000\085\001\000\000\000\000\092\001\ +\093\001\000\000\086\001\087\001\088\001\089\001\090\001\000\000\ +\000\000\000\000\094\001\095\001\096\001\097\001\098\001\000\000\ +\000\000\000\000\000\000\000\000\000\000\091\001\046\004\000\000\ +\000\000\000\000\186\000\000\000\100\001\000\000\000\000\092\001\ +\093\001\000\000\000\000\000\000\000\000\000\000\043\004\078\001\ +\079\001\000\000\094\001\095\001\096\001\097\001\098\001\080\001\ +\000\000\000\000\000\000\099\004\000\000\081\001\082\001\000\000\ +\083\001\000\000\000\000\000\000\100\001\000\000\000\000\000\000\ +\000\000\084\001\000\000\000\000\000\000\000\000\045\004\078\001\ +\079\001\000\000\085\001\000\000\000\000\000\000\000\000\080\001\ +\086\001\087\001\088\001\089\001\090\001\081\001\082\001\000\000\ +\083\001\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\084\001\000\000\091\001\000\000\000\000\000\000\000\000\ +\186\000\000\000\085\001\000\000\000\000\092\001\093\001\000\000\ +\086\001\087\001\088\001\089\001\090\001\000\000\000\000\000\000\ +\094\001\095\001\096\001\097\001\098\001\000\000\000\000\000\000\ +\000\000\000\000\100\004\091\001\000\000\000\000\000\000\000\000\ +\186\000\000\000\100\001\000\000\000\000\092\001\093\001\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\094\001\095\001\096\001\097\001\098\001\081\005\078\001\079\001\ +\000\000\000\000\000\000\000\000\101\004\000\000\080\001\000\000\ +\000\000\000\000\100\001\000\000\081\001\082\001\000\000\083\001\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\084\001\000\000\000\000\000\000\000\000\083\005\078\001\079\001\ +\000\000\085\001\000\000\000\000\000\000\000\000\080\001\086\001\ +\087\001\088\001\089\001\090\001\081\001\082\001\000\000\083\001\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\084\001\000\000\091\001\000\000\000\000\000\000\000\000\186\000\ +\000\000\085\001\000\000\000\000\092\001\093\001\000\000\086\001\ +\087\001\088\001\089\001\090\001\000\000\000\000\000\000\094\001\ +\095\001\096\001\097\001\098\001\000\000\000\000\000\000\000\000\ +\082\005\000\000\091\001\000\000\000\000\000\000\000\000\186\000\ +\000\000\100\001\000\000\000\000\092\001\093\001\000\000\000\000\ +\000\000\000\000\000\000\085\005\078\001\079\001\000\000\094\001\ +\095\001\096\001\097\001\098\001\080\001\000\000\000\000\000\000\ +\000\000\084\005\081\001\082\001\000\000\083\001\000\000\000\000\ +\000\000\100\001\000\000\000\000\000\000\000\000\084\001\000\000\ +\000\000\000\000\000\000\081\005\078\001\079\001\000\000\085\001\ +\000\000\000\000\000\000\000\000\080\001\086\001\087\001\088\001\ +\089\001\090\001\081\001\082\001\000\000\083\001\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\084\001\000\000\ +\091\001\000\000\000\000\000\000\000\000\186\000\000\000\085\001\ +\000\000\000\000\092\001\093\001\000\000\086\001\087\001\088\001\ +\089\001\090\001\000\000\000\000\000\000\094\001\095\001\096\001\ +\097\001\098\001\000\000\000\000\000\000\000\000\000\000\000\000\ +\091\001\086\005\000\000\000\000\000\000\186\000\000\000\100\001\ +\000\000\000\000\092\001\093\001\000\000\000\000\000\000\000\000\ +\000\000\083\005\078\001\079\001\000\000\094\001\095\001\096\001\ +\097\001\098\001\080\001\000\000\000\000\000\000\106\005\000\000\ +\081\001\082\001\000\000\083\001\000\000\000\000\000\000\100\001\ +\000\000\000\000\000\000\000\000\084\001\000\000\000\000\000\000\ +\000\000\085\005\078\001\079\001\000\000\085\001\000\000\000\000\ +\000\000\000\000\080\001\086\001\087\001\088\001\089\001\090\001\ +\081\001\082\001\000\000\083\001\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\084\001\000\000\091\001\000\000\ +\000\000\000\000\000\000\186\000\000\000\085\001\000\000\000\000\ +\092\001\093\001\000\000\086\001\087\001\088\001\089\001\090\001\ +\000\000\000\000\000\000\094\001\095\001\096\001\097\001\098\001\ +\000\000\000\000\000\000\000\000\000\000\107\005\091\001\078\001\ +\079\001\000\000\000\000\186\000\000\000\100\001\000\000\080\001\ +\092\001\093\001\000\000\000\000\000\000\081\001\082\001\000\000\ +\083\001\000\000\000\000\094\001\095\001\096\001\097\001\098\001\ +\000\000\084\001\000\000\000\000\000\000\000\000\000\000\108\005\ +\000\000\000\000\085\001\000\000\000\000\100\001\000\000\000\000\ +\086\001\087\001\088\001\089\001\090\001\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\091\001\078\001\079\001\000\000\000\000\ +\186\000\000\000\000\000\000\000\080\001\092\001\093\001\000\000\ +\000\000\000\000\081\001\082\001\000\000\083\001\000\000\000\000\ +\094\001\095\001\096\001\097\001\098\001\000\000\084\001\000\000\ +\000\000\000\000\000\000\000\000\000\000\099\001\000\000\085\001\ +\000\000\000\000\100\001\000\000\000\000\086\001\087\001\088\001\ +\089\001\090\001\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\091\001\078\001\079\001\000\000\000\000\186\000\000\000\000\000\ +\000\000\080\001\092\001\093\001\000\000\000\000\000\000\081\001\ +\082\001\000\000\083\001\000\000\000\000\094\001\095\001\096\001\ +\097\001\098\001\000\000\084\001\000\000\000\000\031\004\000\000\ +\000\000\078\001\079\001\000\000\085\001\000\000\000\000\100\001\ +\000\000\080\001\086\001\087\001\088\001\089\001\090\001\081\001\ +\082\001\000\000\083\001\000\000\000\000\000\000\000\000\000\000\ +\000\000\138\004\000\000\084\001\000\000\091\001\000\000\000\000\ +\000\000\000\000\186\000\000\000\085\001\000\000\000\000\092\001\ +\093\001\000\000\086\001\087\001\088\001\089\001\090\001\000\000\ +\000\000\000\000\094\001\095\001\096\001\097\001\098\001\000\000\ +\000\000\000\000\000\000\093\004\000\000\091\001\078\001\079\001\ +\000\000\000\000\186\000\000\000\100\001\000\000\080\001\092\001\ +\093\001\000\000\000\000\000\000\081\001\082\001\000\000\083\001\ +\000\000\000\000\094\001\095\001\096\001\097\001\098\001\000\000\ +\084\001\000\000\000\000\000\000\000\000\000\000\240\000\240\000\ +\000\000\085\001\000\000\000\000\100\001\000\000\240\000\086\001\ +\087\001\088\001\089\001\090\001\240\000\240\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\240\000\000\000\091\001\000\000\000\000\000\000\000\000\186\000\ +\000\000\240\000\000\000\000\000\092\001\093\001\000\000\240\000\ +\240\000\240\000\240\000\240\000\000\000\000\000\000\000\094\001\ +\095\001\096\001\097\001\098\001\000\000\000\000\000\000\000\000\ +\000\000\000\000\240\000\078\001\079\001\000\000\000\000\240\000\ +\000\000\100\001\000\000\080\001\240\000\240\000\000\000\000\000\ +\000\000\081\001\000\000\000\000\000\000\000\000\000\000\240\000\ +\240\000\240\000\240\000\240\000\000\000\084\001\000\000\000\000\ +\240\000\000\000\000\000\078\001\079\001\000\000\085\001\000\000\ +\000\000\240\000\000\000\000\000\086\001\087\001\088\001\089\001\ +\090\001\081\001\000\000\000\000\000\000\000\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\084\001\000\000\091\001\ +\000\000\000\000\000\000\000\000\186\000\000\000\085\001\000\000\ +\000\000\092\001\093\001\000\000\086\001\087\001\088\001\089\001\ +\090\001\094\000\000\000\000\000\094\001\095\001\096\001\097\001\ +\098\001\000\000\000\000\000\000\000\000\000\000\000\000\091\001\ +\095\000\016\000\000\000\000\000\186\000\000\000\100\001\000\000\ +\000\000\092\001\093\001\000\000\000\000\096\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\095\001\096\001\097\001\ +\098\001\000\000\000\000\136\000\000\000\137\000\138\000\030\000\ +\031\000\139\000\000\000\000\000\140\000\141\000\100\001\000\000\ +\035\000\000\000\000\000\000\000\000\000\000\000\097\000\000\000\ +\000\000\000\000\000\000\000\000\042\000\142\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\143\000\144\000\000\000\ +\000\000\000\000\000\000\000\000\098\000\145\000\000\000\000\000\ +\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ +\099\000\146\000\147\000\053\000" -let read_ast (type t ) (kind : t Ml_binary.kind) fn : t = - let ic = open_in_bin fn in - try - let dep_size = input_binary_int ic in - seek_in ic (pos_in ic + dep_size) ; - let ast = Ml_binary.read_ast kind ic in - close_in ic; - ast - with exn -> - close_in ic; - raise exn +let yycheck = "\009\000\ +\210\000\145\000\012\000\002\000\014\000\015\000\016\000\136\000\ +\199\000\019\000\020\000\021\000\022\000\023\000\002\000\025\000\ +\163\000\132\001\142\000\205\000\136\000\163\002\032\000\202\000\ +\002\000\123\001\036\000\002\000\202\000\039\000\040\000\041\000\ +\011\000\001\000\034\003\002\000\010\000\024\001\010\002\049\000\ +\050\000\027\000\136\000\053\000\054\000\139\000\002\000\026\000\ +\002\000\138\000\002\000\234\003\163\002\002\000\038\003\253\002\ +\098\000\157\000\221\000\029\000\223\000\105\002\003\000\004\000\ +\186\003\225\002\045\000\063\004\110\000\000\000\170\000\115\004\ +\194\003\063\003\003\000\004\000\031\000\006\000\046\000\241\004\ +\035\000\056\005\201\004\063\005\094\000\095\000\096\000\097\000\ +\131\000\099\000\133\000\003\000\008\001\001\000\134\001\003\000\ +\004\000\141\002\000\000\098\000\054\001\003\003\021\001\000\001\ +\083\000\034\000\085\000\086\000\058\000\110\002\098\000\110\000\ +\067\005\214\004\203\000\000\000\000\001\003\005\000\001\042\002\ +\098\000\127\002\110\000\098\000\017\001\240\001\010\001\164\001\ +\000\001\166\001\005\000\098\000\110\000\074\001\192\004\110\000\ +\000\001\056\001\046\000\149\000\007\001\110\004\098\000\110\000\ +\098\000\000\001\098\000\121\000\000\001\098\000\058\000\161\000\ +\162\000\139\000\110\000\000\001\110\000\008\001\110\000\000\000\ +\087\004\110\000\244\004\173\000\014\001\000\001\052\005\108\001\ +\226\004\000\001\144\000\077\005\060\001\066\001\000\000\001\005\ +\092\001\006\001\188\000\030\001\103\002\008\001\157\005\000\001\ +\066\001\004\001\127\000\197\000\129\000\008\001\131\000\073\001\ +\133\000\000\001\066\001\092\001\015\001\099\003\133\001\018\001\ +\129\000\000\000\066\001\030\001\055\001\000\001\037\001\162\005\ +\092\001\073\001\189\000\095\001\094\001\214\002\065\001\008\001\ +\000\001\129\000\224\002\127\000\014\001\129\000\094\001\131\000\ +\115\001\133\000\000\001\206\000\055\001\079\001\094\001\186\000\ +\187\000\115\001\203\004\121\005\091\001\030\001\065\001\091\001\ +\095\001\000\001\036\001\027\001\130\005\000\001\091\001\066\001\ +\107\002\108\002\095\001\115\001\054\005\027\001\073\001\106\001\ +\101\005\237\005\109\001\094\001\008\001\000\001\055\001\092\001\ +\095\001\017\001\121\003\196\000\022\001\023\001\064\001\000\000\ +\065\001\000\001\197\001\204\000\027\001\094\001\123\005\106\001\ +\027\001\008\001\109\001\109\005\143\002\151\004\022\001\094\001\ +\154\004\005\003\044\001\000\001\000\001\055\001\113\001\067\001\ +\091\001\204\001\037\001\206\001\202\003\095\001\064\001\097\001\ +\058\001\193\001\029\001\091\001\176\001\063\001\094\001\095\001\ +\231\001\106\001\000\001\109\001\109\001\091\001\027\001\157\001\ +\074\001\095\001\000\001\000\001\192\001\022\001\164\001\050\001\ +\166\001\252\001\046\003\217\003\091\001\010\001\001\002\173\001\ +\174\001\087\003\088\003\094\001\027\001\040\006\094\001\094\001\ +\092\001\236\001\130\002\094\001\102\001\027\001\188\001\105\001\ +\154\005\107\001\000\001\109\001\095\001\111\001\094\001\038\002\ +\205\005\163\005\033\005\034\005\151\001\115\003\153\001\019\001\ +\155\001\021\001\215\005\000\001\071\001\000\000\048\002\008\001\ +\164\005\000\001\072\001\160\002\026\001\024\001\091\001\091\001\ +\057\001\015\006\095\001\141\001\107\006\143\001\120\001\066\001\ +\255\005\066\001\117\001\118\001\069\001\026\001\121\001\000\001\ +\123\001\000\001\048\004\074\005\056\001\159\001\069\002\094\001\ +\094\001\010\001\015\001\000\001\035\001\091\001\000\001\092\001\ +\094\001\095\001\095\001\008\006\072\001\000\001\000\001\177\001\ +\178\001\014\001\099\001\000\001\017\001\000\001\103\001\081\006\ +\099\005\083\006\004\001\014\001\059\001\000\001\008\001\125\004\ +\000\001\064\001\065\001\173\001\174\001\015\001\092\001\000\001\ +\018\001\203\001\190\005\074\001\000\001\003\001\188\004\103\004\ +\210\001\000\001\088\006\092\001\214\001\004\001\105\001\092\001\ +\027\001\008\001\151\001\010\001\153\001\058\006\155\001\014\001\ +\000\001\227\001\228\001\018\001\099\001\076\004\232\001\027\001\ +\234\001\008\001\010\001\000\001\027\001\000\001\109\001\066\001\ +\062\001\094\001\000\001\092\001\091\001\000\001\095\001\007\000\ +\066\001\251\001\000\001\151\001\000\001\153\001\032\002\155\001\ +\171\005\094\001\004\001\039\006\094\001\007\002\008\001\009\002\ +\010\002\000\001\000\001\094\001\094\001\015\001\091\001\000\001\ +\018\001\092\001\095\001\055\004\052\003\241\003\193\005\000\001\ +\091\001\000\001\073\001\004\001\095\001\035\001\094\001\008\001\ +\017\001\010\001\018\001\092\001\004\001\014\001\040\002\091\001\ +\000\001\032\002\094\001\095\001\091\001\092\001\221\005\094\001\ +\095\001\027\002\027\001\190\002\032\002\059\001\014\001\000\001\ +\172\002\173\002\064\001\065\001\092\001\092\001\032\002\095\001\ +\066\001\032\002\113\001\000\001\074\001\000\001\091\001\103\003\ +\091\001\032\002\160\002\231\001\095\001\109\003\070\005\171\002\ +\094\001\002\001\253\002\094\001\032\002\003\001\032\002\091\001\ +\032\002\036\002\056\002\032\002\038\003\099\001\028\005\073\002\ +\073\001\000\001\066\001\022\001\091\001\072\002\000\001\109\001\ +\094\001\065\001\066\001\010\001\014\001\094\001\094\001\113\001\ +\074\002\075\002\091\001\092\001\151\002\094\001\095\001\094\001\ +\003\001\018\001\042\002\038\003\047\001\000\001\229\004\129\002\ +\038\003\004\001\132\002\053\003\134\002\008\001\094\001\010\001\ +\113\001\004\001\000\001\014\001\022\001\027\001\008\001\018\001\ +\230\002\066\001\232\002\092\001\164\000\165\000\017\002\018\002\ +\027\001\100\002\018\001\076\002\064\001\107\004\000\001\092\001\ +\014\001\177\000\178\000\094\001\250\002\032\002\015\001\159\005\ +\008\001\069\002\036\001\022\001\018\001\205\003\097\001\098\001\ +\018\001\076\003\170\005\078\003\066\001\183\002\090\001\103\002\ +\019\001\201\000\003\001\073\001\094\001\092\001\111\002\112\002\ +\115\001\019\001\092\001\092\001\036\001\094\001\073\001\201\002\ +\192\005\203\002\110\001\205\002\066\001\237\003\073\001\209\002\ +\090\001\008\001\068\006\065\001\066\001\048\001\180\002\018\001\ +\091\001\092\001\151\002\094\001\095\001\083\001\048\001\049\001\ +\049\003\060\001\092\001\018\001\092\001\115\001\066\003\233\002\ +\018\001\068\001\060\001\070\001\200\004\062\003\113\001\090\001\ +\094\001\027\002\068\001\018\001\070\001\094\001\092\001\146\003\ +\094\001\022\001\242\005\151\002\092\001\255\002\134\003\133\005\ +\232\005\172\003\004\003\005\003\000\000\012\001\172\003\008\001\ +\214\004\001\006\118\003\022\001\067\001\015\003\130\003\017\003\ +\251\003\036\001\253\003\254\003\111\001\113\003\000\001\027\001\ +\031\001\022\001\028\003\029\003\060\004\111\001\133\005\073\002\ +\118\003\092\001\088\001\067\004\065\001\039\003\215\002\216\002\ +\000\001\019\001\248\004\050\001\046\003\092\001\006\003\170\002\ +\026\001\220\003\047\001\027\001\094\001\139\003\220\003\057\003\ +\000\000\015\001\112\001\022\001\030\001\238\002\066\001\186\002\ +\071\001\094\001\067\001\031\005\102\003\060\003\048\001\049\001\ +\022\001\196\002\000\001\252\002\095\001\084\001\080\003\090\001\ +\060\003\065\001\060\001\047\005\187\005\055\001\189\005\065\001\ +\014\001\019\001\068\001\017\001\070\001\000\001\101\001\065\001\ +\022\001\047\001\100\003\014\001\022\004\027\001\065\001\014\001\ +\064\001\065\001\006\003\014\001\066\001\000\001\017\001\102\003\ +\027\001\004\001\237\002\022\001\027\001\008\001\094\001\014\001\ +\027\001\047\001\102\003\014\001\015\001\109\001\128\003\018\001\ +\092\005\131\003\004\001\133\003\102\003\111\001\008\001\102\003\ +\106\001\067\001\003\001\109\001\047\001\107\003\144\003\102\003\ +\018\001\177\004\148\003\097\001\098\001\070\003\064\001\101\005\ +\066\001\155\003\102\003\027\001\102\003\159\003\102\003\000\001\ +\126\003\102\003\083\003\015\001\079\001\091\001\018\001\117\005\ +\079\001\095\001\065\001\097\001\098\001\123\005\088\001\066\001\ +\066\006\067\006\047\001\181\003\196\001\064\001\184\003\215\004\ +\091\001\035\001\188\003\003\001\095\001\115\001\097\001\098\001\ +\066\001\225\004\066\001\110\004\064\001\065\001\112\001\073\001\ +\110\004\000\001\069\003\094\001\022\001\221\001\222\001\223\001\ +\115\001\059\001\125\004\213\003\022\001\229\001\066\001\065\001\ +\030\001\139\004\092\001\022\001\019\001\004\001\082\004\064\001\ +\065\001\008\001\109\001\026\001\097\001\098\001\014\001\014\001\ +\015\001\090\001\124\006\018\001\066\001\067\001\240\003\241\003\ +\096\001\055\001\110\001\073\001\000\001\005\002\115\001\065\001\ +\250\003\048\001\252\003\065\001\102\001\110\001\176\004\205\005\ +\206\005\067\001\022\001\109\001\000\001\060\001\065\001\096\001\ +\004\001\215\005\012\004\014\001\008\001\068\001\010\001\070\001\ +\035\001\033\002\014\001\015\001\197\003\198\003\018\001\035\001\ +\027\001\065\001\066\001\066\001\027\001\115\001\116\004\027\001\ +\203\004\035\001\211\003\212\003\106\001\203\004\216\004\109\001\ +\059\001\218\003\132\005\009\004\060\002\065\001\065\001\059\001\ +\000\001\051\004\227\003\053\004\064\001\065\001\000\001\094\001\ +\111\001\059\001\008\006\061\004\000\001\091\001\074\001\065\001\ +\004\001\095\001\030\001\066\001\008\001\071\004\066\001\000\000\ +\066\001\019\001\026\001\015\001\079\001\073\001\018\001\073\001\ +\026\001\220\004\084\004\102\001\055\001\000\001\209\003\099\001\ +\064\001\065\001\109\001\055\001\094\001\064\001\217\003\091\001\ +\092\001\109\001\094\001\095\001\102\001\065\001\048\001\049\001\ +\064\001\014\001\229\003\109\001\058\006\111\001\005\000\077\004\ +\007\000\028\005\060\001\075\001\008\001\113\001\027\001\065\001\ +\035\001\115\001\068\001\244\004\070\001\248\003\066\001\000\001\ +\031\001\064\001\027\001\023\001\059\005\109\001\112\004\035\003\ +\244\004\116\005\030\001\105\004\142\004\112\001\106\001\145\004\ +\059\001\109\001\073\005\050\001\127\005\064\001\065\001\051\003\ +\112\001\026\001\094\001\055\003\065\001\000\001\244\004\074\001\ +\162\004\053\001\164\004\055\001\166\004\111\001\168\004\169\004\ +\064\001\066\001\055\001\173\004\099\005\065\001\109\001\191\002\ +\178\004\008\001\180\004\064\001\182\004\004\001\184\004\026\001\ +\099\001\008\001\086\003\064\001\065\001\004\001\206\002\207\002\ +\023\001\008\001\109\001\018\001\061\005\022\001\200\004\030\001\ +\015\001\097\001\123\004\018\001\027\001\064\001\127\004\066\001\ +\108\004\061\005\125\005\132\004\027\001\109\001\106\001\125\005\ +\075\001\109\001\014\001\066\001\222\004\017\001\053\001\014\001\ +\055\001\227\004\242\002\112\001\149\004\150\004\145\005\061\005\ +\030\001\235\004\065\001\145\005\053\001\158\004\055\001\056\001\ +\065\001\136\000\169\005\066\001\139\000\247\004\141\000\142\000\ +\065\001\027\001\252\004\066\001\050\001\112\001\000\005\106\006\ +\002\005\066\001\004\005\126\004\181\004\007\005\109\001\130\004\ +\191\005\000\001\064\001\065\001\000\001\164\000\165\000\008\001\ +\167\000\065\001\083\001\106\001\022\005\064\001\109\001\064\001\ +\026\005\073\001\177\000\178\000\019\001\031\005\004\001\019\001\ +\066\001\235\005\008\001\026\001\109\001\008\005\026\001\210\005\ +\035\001\015\001\027\001\108\001\210\005\047\005\048\005\101\001\ +\050\005\028\001\201\000\202\000\106\001\027\001\205\000\109\001\ +\179\004\048\001\049\001\088\001\048\001\232\005\014\001\065\005\ +\059\001\066\001\232\005\190\004\109\001\060\001\065\001\000\001\ +\060\001\100\001\003\001\027\001\212\005\068\001\000\000\070\001\ +\068\001\066\001\070\001\112\001\013\001\014\001\027\001\066\001\ +\017\001\091\005\092\005\027\001\066\001\094\001\022\001\074\001\ +\098\005\026\001\027\001\028\001\029\001\080\001\000\001\003\005\ +\083\001\045\001\046\001\102\001\029\005\064\001\112\005\040\001\ +\041\001\065\001\109\001\066\001\111\001\035\001\003\001\047\001\ +\111\001\019\001\043\005\111\001\045\005\066\001\128\005\037\001\ +\026\001\145\003\066\001\060\001\083\001\088\001\063\001\022\001\ +\065\001\066\001\067\001\068\001\064\001\059\001\144\005\083\001\ +\073\001\074\001\064\001\065\001\064\001\151\005\048\001\080\001\ +\052\005\000\001\064\001\040\001\074\001\112\001\109\001\161\005\ +\100\001\132\005\060\001\092\001\166\005\094\001\000\001\096\001\ +\097\001\067\001\068\001\236\003\070\001\035\001\041\005\000\001\ +\066\001\155\005\180\005\108\001\158\005\099\001\111\001\199\003\ +\023\001\109\001\115\001\018\001\064\001\066\001\037\001\109\001\ +\026\001\109\001\019\001\004\004\063\005\059\001\200\005\075\001\ +\000\001\026\001\064\001\065\001\094\001\207\005\064\001\000\001\ +\224\003\225\003\226\003\213\005\074\001\111\001\230\003\136\005\ +\218\005\219\005\000\001\019\001\236\003\121\005\224\005\048\001\ +\049\001\227\005\026\001\027\001\010\001\053\001\130\005\055\001\ +\000\000\026\001\236\005\060\001\112\001\099\001\240\005\134\001\ +\064\001\065\001\244\005\068\001\004\004\070\001\064\001\109\001\ +\048\001\049\001\004\001\109\001\230\005\231\005\008\001\233\005\ +\234\005\022\001\000\001\003\001\060\001\015\001\157\001\009\006\ +\018\001\064\001\112\001\067\001\068\001\164\001\070\001\166\001\ +\090\001\027\001\064\001\040\001\143\005\012\006\173\001\174\001\ +\064\001\176\001\149\005\064\001\065\001\109\001\111\001\022\001\ +\012\006\000\001\071\001\109\001\110\001\188\001\035\001\037\001\ +\040\001\192\001\044\006\045\006\167\005\196\001\197\001\084\001\ +\225\005\051\006\052\006\053\006\054\006\090\001\109\001\111\001\ +\066\001\059\006\033\001\026\001\075\001\063\006\059\001\109\001\ +\110\001\022\001\016\001\069\006\065\001\109\001\221\001\222\001\ +\223\001\110\001\000\000\077\006\078\006\027\001\229\001\202\005\ +\055\001\004\001\037\001\040\001\059\001\008\001\064\001\095\001\ +\063\001\064\001\065\001\066\001\015\001\095\006\096\006\018\001\ +\076\000\112\001\100\006\064\001\102\006\252\001\253\001\078\001\ +\025\006\102\001\001\002\085\006\110\006\064\001\005\002\113\006\ +\109\001\008\002\035\006\015\006\064\001\022\001\053\001\097\001\ +\055\001\123\006\017\002\018\002\064\001\127\006\027\001\105\006\ +\108\000\064\001\065\001\109\001\134\006\135\006\109\001\040\001\ +\033\001\032\002\033\002\064\001\064\001\119\006\120\006\066\001\ +\109\001\125\000\000\000\042\002\095\001\000\001\064\001\065\001\ +\132\000\048\002\075\006\000\001\064\001\071\001\055\001\095\001\ +\066\001\109\001\059\001\013\001\031\006\060\002\063\001\064\001\ +\065\001\109\001\084\001\000\001\093\006\066\001\109\001\042\006\ +\090\001\083\001\028\001\029\001\073\001\078\001\064\001\091\001\ +\109\001\109\001\037\001\016\002\088\006\022\001\019\001\041\001\ +\037\001\075\001\023\002\109\001\110\001\026\001\027\001\066\006\ +\067\006\094\001\108\001\066\001\000\000\072\006\073\006\128\006\ +\103\002\091\001\060\001\000\001\109\001\063\001\047\001\082\006\ +\079\001\040\001\068\001\048\001\049\001\022\001\115\001\000\001\ +\074\001\055\001\000\001\094\006\066\001\059\001\080\001\060\001\ +\000\001\063\001\064\001\130\002\004\001\026\001\067\001\068\001\ +\008\001\070\001\010\001\066\001\111\006\083\001\014\001\015\001\ +\078\001\026\001\018\001\094\001\026\001\000\000\121\006\094\001\ +\090\001\124\006\108\001\027\001\000\001\111\001\093\001\130\006\ +\131\006\160\002\109\001\110\001\163\002\053\001\054\001\055\001\ +\056\001\031\001\169\002\170\002\110\001\172\002\173\002\109\001\ +\064\001\065\001\111\001\000\001\093\001\055\001\026\001\000\001\ +\033\001\059\001\066\001\186\002\050\001\063\001\064\001\077\001\ +\191\002\010\001\066\001\004\001\109\001\196\002\019\001\008\001\ +\080\001\073\001\094\001\083\001\078\001\026\001\055\001\206\002\ +\207\002\018\001\059\001\071\001\064\001\065\001\063\001\064\001\ +\065\001\109\001\027\001\091\001\092\001\109\001\094\001\095\001\ +\084\001\065\001\000\001\048\001\049\001\078\001\004\001\230\002\ +\093\001\232\002\008\001\109\001\010\001\003\001\237\002\060\001\ +\014\001\113\001\093\001\242\002\018\001\073\001\067\001\068\001\ +\109\001\070\001\064\001\250\002\251\002\027\001\253\002\000\000\ +\009\000\065\001\109\001\012\000\109\001\014\000\015\000\016\000\ +\007\003\073\001\019\000\020\000\021\000\022\000\023\000\004\001\ +\025\000\064\001\065\001\008\001\014\001\065\001\066\001\017\001\ +\004\001\014\001\015\001\036\000\008\001\018\001\039\000\040\000\ +\041\000\027\001\111\001\064\001\066\001\092\001\018\001\038\003\ +\049\000\050\000\000\001\073\001\053\000\054\000\004\001\027\001\ +\066\001\008\001\008\001\014\001\010\001\052\003\053\003\073\001\ +\014\001\015\001\095\001\004\001\065\001\091\001\092\001\008\001\ +\094\001\095\001\071\001\016\001\152\001\027\001\069\003\000\001\ +\036\001\022\001\000\000\000\001\094\001\066\001\027\001\084\001\ +\073\001\010\001\027\001\113\001\014\001\094\000\095\000\096\000\ +\097\000\022\001\099\000\090\001\000\000\109\001\019\001\004\001\ +\014\001\115\001\022\001\008\001\000\001\026\001\000\001\003\001\ +\103\003\095\001\015\001\095\001\066\001\018\001\109\003\055\001\ +\010\001\013\001\092\001\073\001\103\001\017\001\027\001\118\003\ +\066\001\067\001\121\003\048\001\049\001\014\001\026\001\027\001\ +\028\001\029\001\022\001\130\003\027\001\091\001\092\001\060\001\ +\094\001\095\001\064\001\065\001\139\003\041\001\067\001\068\001\ +\092\001\070\001\145\003\173\001\174\001\000\001\092\001\091\001\ +\161\000\162\000\109\001\113\001\092\001\066\001\092\001\053\001\ +\060\001\055\001\013\001\063\001\255\001\000\002\017\001\067\001\ +\068\001\014\001\109\001\065\001\094\001\172\003\074\001\026\001\ +\027\001\028\001\029\001\094\001\080\001\053\001\010\002\055\001\ +\115\001\020\001\111\001\053\001\197\000\055\001\041\001\004\001\ +\092\001\065\001\094\001\008\001\096\001\097\001\109\001\065\001\ +\199\003\053\001\015\001\055\001\046\001\018\001\205\003\115\001\ +\108\001\060\001\209\003\111\001\063\001\065\001\062\001\066\001\ +\067\001\068\001\217\003\109\001\219\003\220\003\073\001\074\001\ +\108\001\224\003\225\003\226\003\109\001\080\001\229\003\230\003\ +\053\001\109\001\055\001\234\003\022\001\236\003\237\003\002\001\ +\073\001\092\001\100\001\094\001\065\001\096\001\097\001\013\001\ +\000\000\248\003\065\001\066\001\067\001\066\001\073\001\000\001\ +\027\001\108\001\003\001\109\001\111\001\004\004\028\001\029\001\ +\115\001\015\001\092\001\064\001\013\001\022\001\023\001\094\001\ +\017\001\000\001\064\001\041\001\064\001\022\001\008\001\022\004\ +\065\001\026\001\027\001\028\001\029\001\109\001\040\001\018\001\ +\014\001\062\001\062\001\044\001\062\001\007\000\060\001\027\001\ +\041\001\000\000\092\001\094\001\064\001\079\001\068\001\064\001\ +\014\001\058\001\134\002\014\001\074\001\006\001\063\001\094\001\ +\026\000\073\001\080\001\060\001\109\001\060\004\063\001\095\001\ +\065\001\066\001\067\001\068\001\067\004\064\001\075\001\073\001\ +\073\001\074\001\096\001\090\001\022\001\076\004\092\001\080\001\ +\027\001\094\001\014\001\082\004\073\001\040\001\108\001\013\001\ +\087\004\111\001\094\001\092\001\000\001\094\001\027\001\096\001\ +\097\001\014\001\027\001\021\001\008\001\086\001\028\001\029\001\ +\064\001\013\001\064\001\108\001\107\004\108\004\111\001\110\004\ +\062\001\062\001\115\001\041\001\014\001\116\004\026\001\062\001\ +\028\001\029\001\062\001\062\001\062\001\003\001\125\004\126\004\ +\014\001\086\001\064\001\130\004\027\001\041\001\060\001\091\001\ +\095\001\063\001\073\001\101\001\139\004\014\001\068\001\094\001\ +\027\001\027\001\094\001\014\001\074\001\094\001\000\000\088\001\ +\060\001\094\001\080\001\063\001\080\001\064\001\066\001\067\001\ +\068\001\027\001\073\001\014\001\020\001\015\001\074\001\022\001\ +\177\001\094\001\096\001\097\001\080\001\053\001\008\001\145\000\ +\065\001\176\004\177\004\073\001\179\004\062\001\108\001\062\001\ +\092\001\111\001\062\001\014\001\096\001\097\001\094\001\190\004\ +\112\001\163\000\164\000\165\000\112\001\167\000\094\001\073\001\ +\108\001\210\001\021\001\111\001\203\004\064\001\091\001\177\000\ +\178\000\037\003\073\001\053\001\054\001\055\001\056\001\214\004\ +\215\004\216\004\000\001\088\001\095\001\014\001\064\001\065\001\ +\094\001\014\001\225\004\014\001\056\003\014\001\229\004\201\000\ +\202\000\061\003\091\001\205\000\027\001\019\001\019\001\027\001\ +\112\001\088\001\241\004\022\001\026\001\244\004\014\001\014\001\ +\000\001\248\004\014\001\003\001\014\001\000\000\000\000\096\001\ +\084\003\096\001\001\005\092\001\003\005\013\001\008\001\109\001\ +\109\001\017\001\048\001\109\001\064\001\092\001\022\001\036\001\ +\090\001\036\001\026\001\027\001\028\001\029\001\060\001\036\001\ +\092\001\065\001\040\001\065\001\112\003\028\005\068\001\040\002\ +\070\001\041\001\033\005\034\005\064\001\094\001\036\001\064\001\ +\091\001\000\001\041\005\053\001\003\001\001\000\002\000\003\000\ +\004\000\005\000\006\000\007\000\060\001\052\005\013\001\063\001\ +\053\001\065\001\066\001\067\001\068\001\064\001\061\005\062\005\ +\063\005\073\001\074\001\026\001\064\001\028\001\029\001\064\001\ +\080\001\111\001\064\001\074\005\064\001\064\001\077\005\127\000\ +\099\003\040\001\041\001\210\005\092\001\000\000\094\001\008\005\ +\096\001\097\001\060\001\129\005\082\006\199\005\072\002\248\002\ +\190\003\145\001\145\005\183\003\108\001\060\001\101\005\111\001\ +\063\001\122\001\103\002\115\001\067\001\068\001\109\005\199\003\ +\230\001\165\000\190\002\074\001\064\001\065\001\117\005\018\005\ +\027\004\080\001\121\005\071\001\123\005\137\001\125\005\226\001\ +\103\004\077\001\232\002\130\005\188\001\092\001\133\005\133\005\ +\084\001\096\001\097\001\099\005\171\005\221\004\090\001\255\255\ +\143\005\115\001\145\005\255\255\255\255\108\001\149\005\255\255\ +\111\001\255\255\238\003\239\003\255\255\255\255\255\255\255\255\ +\255\255\109\001\110\001\013\001\255\255\255\255\255\255\255\255\ +\167\005\255\255\255\255\255\003\255\255\255\255\255\255\145\001\ +\255\255\255\255\028\001\029\001\255\255\255\255\255\255\255\255\ +\012\004\255\255\255\255\255\255\187\005\255\255\189\005\041\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\028\004\255\255\255\255\202\005\255\255\255\255\205\005\206\005\ +\255\255\000\001\060\001\210\005\255\255\063\001\255\255\255\255\ +\215\005\255\255\068\001\255\255\255\255\255\255\221\005\193\001\ +\074\001\255\255\196\001\197\001\019\001\255\255\080\001\255\255\ +\255\255\232\005\062\004\026\001\000\001\255\255\000\000\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\096\001\097\001\ +\255\255\255\255\255\255\221\001\222\001\223\001\255\255\019\001\ +\255\255\048\001\108\001\229\001\255\255\111\001\026\001\255\255\ +\255\255\008\006\236\001\255\255\255\255\060\001\255\255\255\255\ +\015\006\255\255\007\000\255\255\067\001\068\001\011\000\070\001\ +\255\255\109\004\252\001\253\001\048\001\049\001\255\255\001\002\ +\031\006\255\255\118\004\005\002\255\255\026\000\008\002\255\255\ +\060\001\255\255\255\255\042\006\255\255\255\255\016\002\067\001\ +\068\001\255\255\070\001\255\255\255\255\023\002\255\255\255\255\ +\045\000\255\255\255\255\058\006\255\255\255\255\255\255\033\002\ +\111\001\255\255\255\255\066\006\067\006\255\255\255\255\080\003\ +\042\002\072\006\073\006\255\255\255\255\255\255\048\002\255\255\ +\255\255\255\255\081\006\082\006\083\006\000\001\255\255\255\255\ +\003\001\088\006\060\002\111\001\255\255\063\002\083\000\094\006\ +\085\000\086\000\013\001\183\004\255\255\185\004\072\002\255\255\ +\019\001\000\001\255\255\255\255\255\255\255\255\255\255\026\001\ +\111\006\028\001\029\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\121\006\255\255\255\255\124\006\041\001\255\255\ +\255\255\255\255\255\255\130\006\131\006\103\002\255\255\255\255\ +\255\255\255\255\222\004\255\255\255\255\255\255\255\255\227\004\ +\255\255\060\001\255\255\255\255\063\001\255\255\000\000\255\255\ +\067\001\068\001\255\255\255\255\255\255\255\255\255\255\074\001\ +\055\001\255\255\057\001\058\001\059\001\080\001\061\001\255\255\ +\255\255\064\001\065\001\086\001\255\255\255\255\255\255\164\000\ +\165\000\092\001\167\000\255\255\255\255\096\001\097\001\255\255\ +\255\255\255\255\081\001\255\255\177\000\178\000\255\255\019\005\ +\255\255\108\001\089\001\090\001\111\001\255\255\255\255\255\255\ +\189\000\255\255\097\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\201\000\202\000\109\001\110\001\ +\255\255\206\000\255\255\255\255\190\002\191\002\255\255\051\005\ +\255\255\053\005\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\206\002\207\002\000\001\255\255\ +\002\001\003\001\004\001\071\005\255\255\255\255\008\001\075\005\ +\076\005\255\255\255\255\013\001\255\255\255\255\255\255\017\001\ +\018\001\019\001\255\255\255\255\255\255\231\002\090\005\255\255\ +\026\001\027\001\028\001\029\001\255\255\255\255\255\255\255\255\ +\242\002\255\255\036\001\255\255\000\000\255\255\255\255\041\001\ +\255\255\251\002\255\255\253\002\112\005\255\255\048\001\049\001\ +\255\255\255\255\255\255\255\255\255\255\007\003\255\255\255\255\ +\029\001\255\255\060\001\255\255\255\255\063\001\064\001\255\255\ +\066\001\067\001\068\001\255\255\070\001\255\255\255\255\073\001\ +\074\001\255\255\255\255\255\255\255\255\050\001\080\001\255\255\ +\255\255\255\255\036\003\255\255\038\003\255\255\255\255\255\255\ +\255\255\091\001\092\001\255\255\094\001\095\001\096\001\097\001\ +\255\255\255\255\100\001\053\003\255\255\255\255\255\255\171\005\ +\255\255\000\001\108\001\109\001\000\000\111\001\255\255\255\255\ +\180\005\115\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\019\001\193\005\255\255\255\255\ +\196\005\255\255\255\255\026\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\000\001\007\000\255\255\ +\117\001\118\001\255\255\255\255\121\001\255\255\123\001\255\255\ +\255\255\048\001\049\001\255\255\110\003\255\255\255\255\255\255\ +\019\001\229\005\255\255\255\255\000\000\060\001\000\001\026\001\ +\002\001\003\001\004\001\255\255\067\001\068\001\008\001\070\001\ +\255\255\255\255\255\255\013\001\134\003\255\255\255\255\017\001\ +\018\001\019\001\255\255\255\255\255\255\048\001\255\255\145\003\ +\026\001\027\001\028\001\029\001\255\255\255\255\255\255\255\255\ +\255\255\060\001\036\001\255\255\255\255\255\255\255\255\041\001\ +\067\001\068\001\255\255\070\001\255\255\255\255\048\001\049\001\ +\111\001\255\255\172\003\255\255\255\255\255\255\255\255\196\001\ +\197\001\255\255\060\001\255\255\255\255\063\001\255\255\255\255\ +\066\001\067\001\068\001\255\255\070\001\255\255\255\255\073\001\ +\074\001\255\255\255\255\055\006\255\255\199\003\080\001\255\255\ +\221\001\222\001\223\001\255\255\111\001\255\255\255\255\255\255\ +\229\001\091\001\092\001\255\255\094\001\095\001\096\001\097\001\ +\255\255\219\003\220\003\255\255\255\255\255\255\224\003\225\003\ +\226\003\255\255\108\001\255\255\230\003\111\001\255\255\252\001\ +\253\001\115\001\236\003\255\255\001\002\255\255\255\255\255\255\ +\005\002\101\006\102\006\255\255\000\001\255\255\255\255\255\255\ +\255\255\109\006\255\255\164\000\165\000\255\255\167\000\255\255\ +\255\255\013\001\004\004\255\255\255\255\255\255\255\255\255\255\ +\177\000\178\000\255\255\255\255\033\002\129\006\026\001\255\255\ +\028\001\029\001\255\255\255\255\022\004\042\002\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\041\001\255\255\200\000\ +\201\000\202\000\007\000\255\255\255\255\255\255\011\000\060\002\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\060\001\255\255\255\255\072\002\054\004\026\000\066\001\067\001\ +\068\001\255\255\255\255\255\255\000\001\255\255\074\001\003\001\ +\255\255\255\255\255\255\255\255\080\001\255\255\255\255\255\255\ +\045\000\013\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\092\001\255\255\103\002\255\255\096\001\255\255\026\001\027\001\ +\028\001\029\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\108\001\255\255\255\255\111\001\255\255\041\001\255\255\255\255\ +\255\255\000\000\108\004\255\255\110\004\255\255\083\000\255\255\ +\085\000\086\000\255\255\255\255\000\001\255\255\255\255\003\001\ +\060\001\255\255\255\255\125\004\008\001\255\255\255\255\067\001\ +\068\001\013\001\014\001\255\255\255\255\255\255\074\001\019\001\ +\255\255\139\004\022\001\255\255\080\001\255\255\026\001\007\000\ +\028\001\029\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\092\001\255\255\094\001\068\001\096\001\041\001\255\255\255\255\ +\255\255\255\255\255\255\136\000\077\001\255\255\255\255\255\255\ +\108\001\255\255\191\002\111\001\255\255\255\255\176\004\255\255\ +\060\001\255\255\255\255\063\001\255\255\065\001\066\001\067\001\ +\068\001\206\002\207\002\006\001\255\255\008\001\074\001\164\000\ +\165\000\255\255\167\000\079\001\080\001\255\255\255\255\255\255\ +\255\255\203\004\255\255\255\255\177\000\178\000\255\255\255\255\ +\092\001\255\255\231\002\255\255\096\001\097\001\216\004\255\255\ +\189\000\255\255\220\004\255\255\255\255\242\002\255\255\255\255\ +\108\001\255\255\255\255\111\001\201\000\202\000\251\002\255\255\ +\253\002\206\000\255\255\255\255\055\001\255\255\057\001\058\001\ +\059\001\255\255\061\001\255\255\255\255\064\001\065\001\255\255\ +\255\255\255\255\255\255\000\001\255\255\255\255\255\255\255\255\ +\255\255\003\005\255\255\255\255\255\255\255\255\081\001\255\255\ +\013\001\255\255\255\255\255\255\255\255\006\001\089\001\090\001\ +\255\255\038\003\255\255\255\255\000\000\026\001\097\001\028\001\ +\029\001\255\255\028\005\196\001\197\001\255\255\255\255\255\255\ +\255\255\255\255\109\001\110\001\041\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\164\000\165\000\255\255\167\000\ +\255\255\255\255\052\005\220\001\221\001\222\001\223\001\060\001\ +\029\001\177\000\178\000\255\255\229\001\255\255\055\001\068\001\ +\057\001\058\001\059\001\255\255\061\001\074\001\015\001\064\001\ +\065\001\255\255\255\255\080\001\255\255\050\001\255\255\255\255\ +\255\255\201\000\202\000\252\001\253\001\255\255\255\255\255\255\ +\001\002\255\255\255\255\096\001\005\002\028\000\029\000\255\255\ +\255\255\090\001\043\001\044\001\045\001\046\001\015\002\108\001\ +\097\001\000\001\111\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\008\001\255\255\255\255\109\001\110\001\013\001\121\005\ +\033\002\066\001\255\255\125\005\145\003\255\255\071\001\072\001\ +\130\005\042\002\255\255\026\001\255\255\028\001\029\001\255\255\ +\255\255\255\255\083\001\084\001\085\001\086\001\255\255\145\005\ +\117\001\118\001\041\001\060\002\121\001\255\255\123\001\172\003\ +\087\000\088\000\255\255\100\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\060\001\255\255\255\255\ +\063\001\255\255\255\255\066\001\067\001\068\001\255\255\255\255\ +\255\255\255\255\199\003\074\001\255\255\255\255\255\255\255\255\ +\157\001\080\001\000\000\255\255\000\000\255\255\103\002\164\001\ +\255\255\166\001\255\255\255\255\255\255\092\001\219\003\220\003\ +\255\255\096\001\097\001\224\003\225\003\226\003\255\255\255\255\ +\210\005\230\003\212\005\255\255\255\255\108\001\255\255\236\003\ +\111\001\255\255\255\255\255\255\255\255\255\255\255\255\196\001\ +\197\001\255\255\255\255\255\255\255\255\255\255\232\005\255\255\ +\023\001\255\255\255\255\255\255\255\255\255\255\255\255\004\004\ +\134\001\243\005\255\255\255\255\255\255\036\001\255\255\255\255\ +\221\001\222\001\223\001\255\255\015\001\255\255\255\255\255\255\ +\229\001\255\255\255\255\255\255\255\255\007\006\255\255\255\255\ +\055\001\255\255\057\001\058\001\059\001\015\006\061\001\255\255\ +\018\006\064\001\065\001\255\255\000\001\255\255\191\002\252\001\ +\253\001\044\001\045\001\046\001\001\002\255\255\255\255\255\255\ +\005\002\013\001\255\255\255\255\255\255\206\002\207\002\255\255\ +\190\001\043\006\255\255\090\001\255\255\255\255\026\001\255\255\ +\028\001\029\001\097\001\255\255\071\001\072\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\033\002\041\001\109\001\110\001\ +\083\001\084\001\085\001\086\001\255\255\042\002\255\255\255\255\ +\255\255\242\002\255\255\255\255\196\001\197\001\255\255\255\255\ +\060\001\100\001\251\002\063\001\253\002\255\255\088\006\060\002\ +\068\001\110\004\255\255\255\255\255\255\255\255\074\001\255\255\ +\255\255\255\255\255\255\072\002\080\001\221\001\222\001\223\001\ +\125\004\255\255\255\255\255\255\255\255\229\001\230\001\255\255\ +\092\001\255\255\255\255\255\255\096\001\097\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\038\003\255\255\255\255\ +\108\001\255\255\103\002\111\001\252\001\253\001\255\255\255\255\ +\255\255\001\002\255\255\255\255\255\255\005\002\255\255\078\001\ +\079\001\080\001\081\001\082\001\083\001\084\001\085\001\086\001\ +\087\001\088\001\089\001\090\001\091\001\092\001\093\001\094\001\ +\095\001\096\001\097\001\098\001\000\000\100\001\255\255\255\255\ +\102\001\033\002\255\255\105\001\255\255\107\001\255\255\109\001\ +\255\255\111\001\042\002\114\001\255\255\255\255\203\004\255\255\ +\255\255\255\255\255\255\160\002\255\255\255\255\255\255\255\255\ +\127\001\255\255\255\255\255\255\060\002\255\255\255\255\013\001\ +\255\255\013\001\255\255\116\003\255\255\255\255\255\255\141\001\ +\255\255\143\001\255\255\255\255\255\255\255\255\028\001\029\001\ +\028\001\029\001\191\002\255\255\255\255\255\255\255\255\255\255\ +\255\255\159\001\255\255\041\001\255\255\041\001\255\255\255\255\ +\145\003\206\002\207\002\255\255\130\002\255\255\255\255\103\002\ +\255\255\000\000\255\255\008\005\255\255\255\255\060\001\255\255\ +\060\001\063\001\255\255\063\001\255\255\255\255\068\001\255\255\ +\068\001\255\255\255\255\172\003\074\001\255\255\074\001\028\005\ +\255\255\255\255\080\001\006\001\080\001\242\002\255\255\255\255\ +\255\255\255\255\255\255\169\002\255\255\255\255\251\002\255\255\ +\253\002\255\255\096\001\097\001\096\001\097\001\199\003\255\255\ +\255\255\255\255\015\001\255\255\255\255\255\255\108\001\255\255\ +\108\001\111\001\232\001\111\001\234\001\255\255\255\255\255\255\ +\255\255\255\255\219\003\220\003\255\255\255\255\223\003\224\003\ +\225\003\226\003\255\255\255\255\055\001\230\003\057\001\058\001\ +\059\001\038\003\061\001\236\003\255\255\064\001\065\001\191\002\ +\255\255\007\002\055\001\009\002\057\001\058\001\059\001\255\255\ +\061\001\255\255\255\255\064\001\065\001\255\255\206\002\207\002\ +\255\255\024\002\255\255\004\004\255\255\074\001\029\002\090\001\ +\255\255\255\255\255\255\255\255\081\001\255\255\097\001\255\255\ +\125\005\255\255\255\255\255\255\089\001\090\001\255\255\132\005\ +\255\255\094\001\109\001\110\001\097\001\255\255\255\255\255\255\ +\255\255\255\255\242\002\255\255\145\005\255\255\255\255\255\255\ +\109\001\110\001\255\255\251\002\255\255\253\002\255\255\255\255\ +\255\255\255\255\255\255\074\002\075\002\255\255\255\255\255\255\ +\255\255\118\003\255\255\255\255\255\255\255\255\123\003\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\052\003\255\255\ +\255\255\000\000\255\255\255\255\000\001\255\255\255\255\003\001\ +\255\255\255\255\255\255\255\255\145\003\255\255\038\003\110\002\ +\255\255\013\001\255\255\255\255\115\002\116\002\117\002\255\255\ +\255\255\255\255\255\255\255\255\255\255\210\005\026\001\027\001\ +\028\001\029\001\255\255\129\002\255\255\110\004\132\002\172\003\ +\255\255\255\255\255\255\255\255\255\255\041\001\255\255\255\255\ +\255\255\103\003\255\255\232\005\125\004\255\255\255\255\109\003\ +\255\255\255\255\255\255\255\255\255\255\255\255\243\005\255\255\ +\060\001\255\255\199\003\255\255\064\001\255\255\066\001\067\001\ +\068\001\255\255\255\255\255\255\255\255\073\001\074\001\255\255\ +\255\255\000\001\255\255\255\255\080\001\255\255\219\003\220\003\ +\255\255\255\255\255\255\224\003\225\003\226\003\013\001\255\255\ +\092\001\230\003\094\001\255\255\096\001\097\001\255\255\236\003\ +\100\001\255\255\255\255\026\001\255\255\028\001\029\001\255\255\ +\108\001\109\001\000\000\111\001\255\255\255\255\043\006\214\002\ +\255\255\145\003\041\001\255\255\219\002\220\002\221\002\004\004\ +\255\255\000\001\203\004\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\233\002\255\255\060\001\255\255\255\255\ +\063\001\255\255\255\255\255\255\172\003\068\001\255\255\205\003\ +\255\255\255\255\255\255\074\001\255\255\255\255\255\255\255\255\ +\255\255\080\001\255\255\002\003\255\255\255\255\004\003\255\255\ +\255\255\255\255\255\255\255\255\255\255\092\001\255\255\199\003\ +\255\255\096\001\097\001\018\003\234\003\255\255\255\255\237\003\ +\055\001\255\255\057\001\058\001\059\001\108\001\061\001\255\255\ +\111\001\064\001\065\001\219\003\220\003\074\004\255\255\255\255\ +\224\003\225\003\226\003\255\255\255\255\255\255\230\003\255\255\ +\255\255\255\255\081\001\028\005\236\003\255\255\255\255\255\255\ +\255\255\255\255\089\001\090\001\255\255\255\255\255\255\255\255\ +\000\000\255\255\097\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\110\004\255\255\255\255\004\004\108\001\109\001\110\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\125\004\255\255\255\255\255\255\255\255\255\255\255\255\094\003\ +\255\255\000\001\001\001\002\001\003\001\255\255\060\004\255\255\ +\255\255\008\001\009\001\010\001\255\255\067\004\013\001\014\001\ +\255\255\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ +\255\255\024\001\025\001\026\001\027\001\028\001\029\001\255\255\ +\255\255\087\004\128\003\255\255\255\255\036\001\037\001\255\255\ +\255\255\040\001\041\001\042\001\043\001\255\255\000\000\255\255\ +\255\255\048\001\049\001\255\255\125\005\107\004\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\060\001\061\001\255\255\ +\063\001\255\255\255\255\066\001\067\001\068\001\203\004\070\001\ +\145\005\255\255\073\001\074\001\255\255\255\255\255\255\255\255\ +\255\255\080\001\255\255\082\001\255\255\255\255\110\004\181\003\ +\255\255\255\255\255\255\255\255\091\001\092\001\255\255\094\001\ +\095\001\096\001\097\001\255\255\255\255\125\004\255\255\255\255\ +\103\001\255\255\105\001\255\255\203\003\108\001\255\255\244\004\ +\111\001\255\255\000\001\255\255\115\001\003\001\255\255\213\003\ +\255\255\255\255\008\001\177\004\255\255\255\255\255\255\013\001\ +\255\255\255\255\255\255\008\005\255\255\019\001\023\001\255\255\ +\255\255\210\005\255\255\255\255\026\001\255\255\028\001\029\001\ +\255\255\255\255\255\255\036\001\255\255\255\255\255\255\028\005\ +\255\255\255\255\255\255\041\001\250\003\255\255\252\003\232\005\ +\214\004\215\004\255\255\255\255\255\255\255\255\055\001\255\255\ +\057\001\058\001\059\001\225\004\061\001\255\255\060\001\064\001\ +\065\001\063\001\255\255\203\004\066\001\067\001\068\001\255\255\ +\061\005\255\255\255\255\241\004\074\001\255\255\255\255\255\255\ +\255\255\255\255\080\001\255\255\255\255\255\255\037\004\038\004\ +\039\004\090\001\255\255\255\255\000\000\255\255\092\001\255\255\ +\097\001\255\255\096\001\097\001\255\255\051\004\255\255\255\255\ +\255\255\255\255\255\255\255\255\109\001\110\001\108\001\255\255\ +\000\001\111\001\255\255\003\001\255\255\255\255\255\255\255\255\ +\255\255\071\004\255\255\033\005\034\005\013\001\014\001\255\255\ +\255\255\017\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\125\005\255\255\026\001\027\001\028\001\029\001\255\255\132\005\ +\255\255\096\004\097\004\098\004\028\005\255\255\255\255\255\255\ +\040\001\041\001\255\255\255\255\145\005\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\074\005\255\255\255\255\077\005\ +\255\255\255\255\255\255\255\255\060\001\255\255\255\255\063\001\ +\255\255\255\255\255\255\067\001\068\001\255\255\255\255\093\005\ +\094\005\073\001\074\001\138\004\255\255\255\255\000\001\101\005\ +\080\001\003\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\013\001\092\001\255\255\094\001\017\001\ +\096\001\097\001\255\255\255\255\255\255\123\005\255\255\255\255\ +\026\001\027\001\028\001\029\001\108\001\210\005\255\255\111\001\ +\255\255\000\000\255\255\115\001\255\255\255\255\180\004\041\001\ +\182\004\255\255\184\004\000\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\232\005\255\255\125\005\255\255\255\255\ +\255\255\255\255\060\001\255\255\255\255\063\001\205\004\206\004\ +\207\004\067\001\068\001\255\255\211\004\212\004\213\004\255\255\ +\074\001\145\005\255\255\255\255\255\255\255\255\080\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\092\001\255\255\094\001\235\004\096\001\097\001\ +\255\255\199\005\055\001\255\255\057\001\058\001\059\001\205\005\ +\061\001\247\004\108\001\064\001\065\001\111\001\255\255\255\255\ +\255\255\215\005\000\005\255\255\255\255\255\255\004\005\221\005\ +\255\255\255\255\255\255\255\255\081\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\089\001\090\001\255\255\255\255\ +\255\255\255\255\210\005\255\255\097\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\109\001\110\001\255\255\255\255\000\001\001\001\002\001\003\001\ +\232\005\255\255\008\006\255\255\008\001\009\001\010\001\255\255\ +\255\255\013\001\014\001\015\001\016\001\017\001\018\001\019\001\ +\020\001\021\001\255\255\255\255\024\001\025\001\026\001\027\001\ +\028\001\029\001\255\255\000\000\255\255\255\255\255\255\255\255\ +\036\001\037\001\255\255\255\255\040\001\041\001\042\001\043\001\ +\044\001\045\001\046\001\255\255\048\001\049\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\058\006\255\255\255\255\255\255\ +\060\001\061\001\255\255\063\001\255\255\255\255\066\001\067\001\ +\068\001\255\255\070\001\071\001\072\001\073\001\074\001\255\255\ +\255\255\255\255\255\255\081\006\080\001\083\006\082\001\083\001\ +\084\001\085\001\086\001\255\255\255\255\255\255\255\255\091\001\ +\092\001\255\255\094\001\095\001\096\001\097\001\255\255\255\255\ +\100\001\255\255\255\255\103\001\255\255\105\001\255\255\255\255\ +\108\001\255\255\255\255\111\001\255\255\255\255\255\255\115\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\166\005\255\255\255\255\255\255\013\001\255\255\255\255\255\255\ +\255\255\000\001\255\255\002\001\003\001\004\001\181\005\182\005\ +\183\005\008\001\255\255\028\001\029\001\255\255\013\001\000\000\ +\255\255\255\255\017\001\018\001\019\001\255\255\255\255\255\255\ +\041\001\255\255\200\005\026\001\027\001\028\001\029\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\036\001\255\255\213\005\ +\255\255\040\001\041\001\060\001\255\255\219\005\063\001\255\255\ +\255\255\048\001\049\001\068\001\255\255\255\255\255\255\255\255\ +\255\255\074\001\255\255\255\255\255\255\060\001\236\005\080\001\ +\063\001\255\255\255\255\066\001\067\001\068\001\244\005\070\001\ +\255\255\255\255\073\001\074\001\255\255\255\255\255\255\096\001\ +\255\255\080\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\108\001\091\001\092\001\111\001\094\001\ +\095\001\096\001\255\255\255\255\255\255\100\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\108\001\255\255\255\255\ +\111\001\255\255\255\255\255\255\115\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\044\006\045\006\ +\255\255\255\255\255\255\000\000\255\255\051\006\052\006\053\006\ +\054\006\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\063\006\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\000\001\001\001\002\001\003\001\255\255\ +\078\006\006\001\007\001\008\001\009\001\010\001\011\001\012\001\ +\013\001\014\001\015\001\016\001\017\001\018\001\019\001\020\001\ +\021\001\022\001\255\255\024\001\025\001\026\001\027\001\028\001\ +\029\001\030\001\031\001\255\255\255\255\255\255\255\255\036\001\ +\037\001\255\255\255\255\040\001\041\001\042\001\043\001\044\001\ +\045\001\046\001\047\001\048\001\049\001\050\001\051\001\255\255\ +\053\001\054\001\055\001\056\001\255\255\255\255\059\001\060\001\ +\061\001\062\001\063\001\064\001\065\001\066\001\067\001\068\001\ +\255\255\070\001\071\001\072\001\073\001\074\001\255\255\076\001\ +\255\255\255\255\255\255\080\001\081\001\082\001\083\001\084\001\ +\085\001\086\001\087\001\255\255\089\001\255\255\091\001\092\001\ +\000\000\094\001\095\001\096\001\097\001\098\001\255\255\100\001\ +\101\001\255\255\103\001\104\001\105\001\106\001\255\255\108\001\ +\109\001\255\255\111\001\255\255\255\255\255\255\115\001\000\001\ +\001\001\002\001\003\001\004\001\255\255\006\001\007\001\008\001\ +\009\001\010\001\011\001\012\001\013\001\014\001\015\001\016\001\ +\017\001\018\001\019\001\020\001\021\001\255\255\255\255\024\001\ +\025\001\026\001\027\001\028\001\029\001\030\001\031\001\255\255\ +\255\255\255\255\255\255\036\001\037\001\255\255\255\255\040\001\ +\041\001\042\001\043\001\044\001\045\001\046\001\047\001\048\001\ +\049\001\050\001\051\001\255\255\053\001\054\001\055\001\056\001\ +\255\255\255\255\059\001\060\001\061\001\255\255\063\001\064\001\ +\065\001\066\001\067\001\068\001\255\255\070\001\071\001\072\001\ +\073\001\074\001\255\255\076\001\255\255\255\255\255\255\080\001\ +\081\001\082\001\083\001\084\001\085\001\086\001\087\001\255\255\ +\089\001\255\255\091\001\092\001\000\000\094\001\095\001\096\001\ +\097\001\098\001\255\255\100\001\101\001\255\255\103\001\104\001\ +\105\001\106\001\255\255\108\001\109\001\255\255\111\001\255\255\ +\255\255\255\255\115\001\000\001\001\001\002\001\003\001\255\255\ +\255\255\006\001\007\001\008\001\009\001\010\001\011\001\012\001\ +\013\001\014\001\015\001\016\001\017\001\018\001\019\001\020\001\ +\021\001\022\001\255\255\024\001\025\001\026\001\027\001\028\001\ +\029\001\030\001\031\001\255\255\255\255\255\255\255\255\036\001\ +\037\001\255\255\255\255\040\001\041\001\042\001\043\001\044\001\ +\045\001\046\001\047\001\048\001\049\001\050\001\051\001\255\255\ +\053\001\054\001\055\001\056\001\255\255\255\255\059\001\060\001\ +\061\001\255\255\063\001\064\001\065\001\066\001\067\001\068\001\ +\255\255\070\001\071\001\072\001\073\001\074\001\255\255\076\001\ +\255\255\255\255\255\255\080\001\081\001\082\001\083\001\084\001\ +\085\001\086\001\087\001\255\255\089\001\255\255\091\001\092\001\ +\000\000\094\001\095\001\096\001\097\001\098\001\255\255\100\001\ +\101\001\255\255\103\001\104\001\105\001\106\001\255\255\108\001\ +\109\001\255\255\111\001\255\255\255\255\255\255\115\001\255\255\ +\000\001\001\001\002\001\003\001\255\255\255\255\006\001\007\001\ +\008\001\009\001\010\001\011\001\012\001\013\001\014\001\015\001\ +\016\001\017\001\018\001\019\001\020\001\021\001\022\001\255\255\ +\024\001\025\001\026\001\027\001\028\001\029\001\030\001\031\001\ +\255\255\255\255\255\255\255\255\036\001\037\001\255\255\255\255\ +\040\001\041\001\042\001\043\001\044\001\045\001\046\001\047\001\ +\048\001\049\001\050\001\051\001\255\255\053\001\054\001\055\001\ +\056\001\255\255\255\255\059\001\060\001\061\001\255\255\063\001\ +\064\001\065\001\066\001\067\001\068\001\255\255\070\001\071\001\ +\072\001\073\001\074\001\255\255\076\001\255\255\255\255\255\255\ +\080\001\081\001\082\001\083\001\084\001\085\001\086\001\087\001\ +\255\255\089\001\255\255\091\001\092\001\000\000\094\001\095\001\ +\096\001\097\001\098\001\255\255\100\001\101\001\255\255\103\001\ +\104\001\105\001\106\001\255\255\108\001\109\001\255\255\111\001\ +\255\255\255\255\255\255\115\001\000\001\001\001\002\001\003\001\ +\255\255\255\255\006\001\007\001\008\001\009\001\010\001\011\001\ +\012\001\013\001\014\001\015\001\016\001\017\001\018\001\019\001\ +\020\001\021\001\022\001\255\255\024\001\025\001\026\001\027\001\ +\028\001\029\001\030\001\031\001\255\255\255\255\255\255\255\255\ +\036\001\037\001\255\255\255\255\040\001\041\001\042\001\043\001\ +\044\001\045\001\046\001\047\001\048\001\049\001\050\001\051\001\ +\255\255\053\001\054\001\055\001\056\001\255\255\255\255\059\001\ +\060\001\061\001\255\255\063\001\064\001\065\001\066\001\067\001\ +\068\001\255\255\070\001\071\001\072\001\073\001\074\001\255\255\ +\076\001\255\255\255\255\255\255\080\001\081\001\082\001\083\001\ +\084\001\085\001\086\001\087\001\255\255\089\001\255\255\091\001\ +\092\001\000\000\094\001\095\001\096\001\097\001\098\001\255\255\ +\100\001\101\001\255\255\103\001\104\001\105\001\106\001\255\255\ +\108\001\109\001\255\255\111\001\255\255\255\255\255\255\115\001\ +\000\001\001\001\002\001\003\001\255\255\255\255\006\001\007\001\ +\008\001\009\001\010\001\011\001\012\001\013\001\014\001\015\001\ +\016\001\017\001\018\001\019\001\020\001\021\001\022\001\255\255\ +\024\001\025\001\026\001\027\001\028\001\029\001\030\001\031\001\ +\255\255\255\255\255\255\255\255\036\001\037\001\255\255\255\255\ +\040\001\041\001\042\001\043\001\044\001\045\001\046\001\047\001\ +\048\001\049\001\050\001\051\001\255\255\053\001\054\001\055\001\ +\056\001\255\255\255\255\059\001\060\001\061\001\255\255\063\001\ +\064\001\065\001\066\001\067\001\068\001\255\255\070\001\071\001\ +\072\001\073\001\074\001\255\255\076\001\255\255\255\255\255\255\ +\080\001\081\001\082\001\083\001\084\001\085\001\086\001\087\001\ +\255\255\089\001\255\255\091\001\092\001\000\000\094\001\095\001\ +\096\001\097\001\098\001\255\255\100\001\101\001\255\255\103\001\ +\104\001\105\001\106\001\255\255\108\001\109\001\255\255\111\001\ +\255\255\255\255\255\255\115\001\255\255\000\001\001\001\002\001\ +\003\001\255\255\255\255\006\001\007\001\008\001\009\001\010\001\ +\011\001\012\001\013\001\014\001\015\001\016\001\017\001\018\001\ +\019\001\020\001\021\001\022\001\255\255\024\001\025\001\026\001\ +\027\001\028\001\029\001\030\001\031\001\255\255\255\255\255\255\ +\255\255\036\001\037\001\255\255\255\255\040\001\041\001\042\001\ +\043\001\044\001\045\001\046\001\047\001\048\001\049\001\050\001\ +\051\001\255\255\053\001\054\001\055\001\056\001\255\255\255\255\ +\059\001\060\001\061\001\255\255\063\001\064\001\065\001\066\001\ +\067\001\068\001\255\255\070\001\071\001\072\001\073\001\074\001\ +\255\255\076\001\255\255\255\255\255\255\080\001\081\001\082\001\ +\083\001\084\001\085\001\086\001\087\001\255\255\089\001\255\255\ +\091\001\092\001\000\000\094\001\095\001\096\001\097\001\098\001\ +\255\255\100\001\101\001\255\255\103\001\104\001\105\001\106\001\ +\255\255\108\001\109\001\255\255\111\001\255\255\255\255\255\255\ +\115\001\000\001\001\001\002\001\003\001\255\255\255\255\006\001\ +\007\001\008\001\009\001\010\001\011\001\012\001\013\001\014\001\ +\015\001\016\001\017\001\018\001\019\001\020\001\021\001\022\001\ +\255\255\024\001\025\001\026\001\027\001\028\001\029\001\030\001\ +\031\001\255\255\255\255\255\255\255\255\036\001\037\001\255\255\ +\255\255\040\001\041\001\042\001\043\001\044\001\045\001\046\001\ +\047\001\048\001\049\001\050\001\051\001\255\255\053\001\054\001\ +\055\001\056\001\255\255\255\255\059\001\060\001\061\001\255\255\ +\063\001\064\001\065\001\066\001\067\001\068\001\255\255\070\001\ +\071\001\072\001\073\001\074\001\255\255\076\001\255\255\255\255\ +\255\255\080\001\081\001\082\001\083\001\084\001\085\001\086\001\ +\087\001\255\255\089\001\255\255\091\001\092\001\000\000\094\001\ +\095\001\096\001\097\001\098\001\255\255\100\001\101\001\255\255\ +\103\001\104\001\105\001\106\001\255\255\108\001\109\001\255\255\ +\111\001\255\255\255\255\255\255\115\001\000\001\001\001\002\001\ +\003\001\255\255\255\255\006\001\007\001\008\001\009\001\010\001\ +\011\001\012\001\013\001\014\001\015\001\016\001\017\001\018\001\ +\019\001\020\001\021\001\022\001\255\255\024\001\025\001\026\001\ +\027\001\028\001\029\001\030\001\031\001\255\255\255\255\255\255\ +\255\255\036\001\037\001\255\255\255\255\040\001\041\001\042\001\ +\043\001\044\001\045\001\046\001\047\001\048\001\049\001\050\001\ +\051\001\255\255\053\001\054\001\055\001\056\001\255\255\255\255\ +\059\001\060\001\061\001\255\255\063\001\064\001\065\001\066\001\ +\067\001\068\001\255\255\070\001\071\001\072\001\073\001\074\001\ +\255\255\076\001\255\255\255\255\255\255\080\001\081\001\082\001\ +\083\001\084\001\085\001\086\001\087\001\255\255\089\001\255\255\ +\091\001\092\001\000\000\094\001\095\001\096\001\097\001\098\001\ +\255\255\100\001\101\001\255\255\103\001\104\001\105\001\106\001\ +\255\255\108\001\109\001\255\255\111\001\255\255\255\255\255\255\ +\115\001\255\255\000\001\001\001\002\001\003\001\255\255\255\255\ +\006\001\007\001\008\001\009\001\010\001\011\001\012\001\013\001\ +\014\001\015\001\016\001\017\001\018\001\019\001\020\001\021\001\ +\022\001\255\255\024\001\025\001\026\001\027\001\028\001\029\001\ +\030\001\031\001\255\255\255\255\255\255\255\255\036\001\037\001\ +\255\255\255\255\040\001\041\001\042\001\043\001\044\001\045\001\ +\046\001\047\001\048\001\049\001\050\001\051\001\255\255\053\001\ +\054\001\055\001\056\001\255\255\255\255\059\001\060\001\061\001\ +\255\255\063\001\064\001\065\001\066\001\067\001\068\001\255\255\ +\070\001\071\001\072\001\073\001\074\001\255\255\076\001\255\255\ +\255\255\255\255\080\001\081\001\082\001\083\001\084\001\085\001\ +\086\001\087\001\255\255\089\001\255\255\091\001\092\001\000\000\ +\094\001\095\001\096\001\097\001\098\001\255\255\100\001\101\001\ +\255\255\103\001\104\001\105\001\106\001\255\255\108\001\109\001\ +\255\255\111\001\255\255\255\255\255\255\115\001\000\001\001\001\ +\002\001\003\001\255\255\255\255\006\001\007\001\008\001\009\001\ +\010\001\011\001\012\001\013\001\014\001\015\001\016\001\017\001\ +\018\001\019\001\020\001\021\001\022\001\255\255\024\001\025\001\ +\026\001\027\001\028\001\029\001\030\001\031\001\255\255\255\255\ +\255\255\255\255\036\001\037\001\255\255\255\255\040\001\041\001\ +\042\001\043\001\044\001\045\001\046\001\047\001\048\001\049\001\ +\050\001\051\001\255\255\053\001\054\001\055\001\056\001\255\255\ +\255\255\059\001\060\001\061\001\255\255\063\001\064\001\065\001\ +\066\001\067\001\068\001\255\255\070\001\071\001\072\001\073\001\ +\074\001\255\255\076\001\255\255\255\255\255\255\080\001\081\001\ +\082\001\083\001\084\001\085\001\086\001\087\001\255\255\089\001\ +\255\255\091\001\092\001\000\000\094\001\095\001\096\001\097\001\ +\098\001\255\255\100\001\101\001\255\255\103\001\104\001\105\001\ +\106\001\255\255\108\001\109\001\255\255\111\001\255\255\255\255\ +\255\255\115\001\000\001\001\001\002\001\003\001\255\255\255\255\ +\006\001\007\001\008\001\009\001\010\001\011\001\012\001\013\001\ +\014\001\015\001\016\001\017\001\018\001\019\001\020\001\021\001\ +\022\001\255\255\024\001\025\001\026\001\027\001\028\001\029\001\ +\030\001\031\001\255\255\255\255\255\255\255\255\036\001\037\001\ +\255\255\255\255\040\001\041\001\042\001\043\001\044\001\045\001\ +\046\001\047\001\048\001\049\001\050\001\051\001\255\255\053\001\ +\054\001\055\001\056\001\255\255\255\255\059\001\060\001\061\001\ +\255\255\063\001\064\001\065\001\066\001\067\001\068\001\255\255\ +\070\001\071\001\072\001\073\001\074\001\255\255\076\001\255\255\ +\255\255\255\255\080\001\081\001\082\001\083\001\084\001\085\001\ +\086\001\087\001\255\255\089\001\255\255\091\001\092\001\000\000\ +\094\001\095\001\096\001\097\001\098\001\255\255\100\001\101\001\ +\255\255\103\001\104\001\105\001\106\001\255\255\108\001\109\001\ +\255\255\111\001\255\255\255\255\255\255\115\001\255\255\000\001\ +\001\001\002\001\003\001\004\001\255\255\006\001\007\001\008\001\ +\009\001\010\001\011\001\012\001\013\001\014\001\015\001\016\001\ +\017\001\018\001\019\001\020\001\021\001\255\255\255\255\024\001\ +\025\001\026\001\027\001\028\001\029\001\030\001\031\001\255\255\ +\255\255\255\255\255\255\036\001\037\001\255\255\255\255\040\001\ +\041\001\042\001\043\001\044\001\045\001\046\001\255\255\048\001\ +\049\001\050\001\051\001\255\255\053\001\054\001\055\001\056\001\ +\255\255\255\255\059\001\060\001\061\001\255\255\063\001\064\001\ +\065\001\066\001\067\001\068\001\255\255\070\001\071\001\072\001\ +\073\001\074\001\255\255\076\001\255\255\255\255\255\255\080\001\ +\081\001\082\001\083\001\084\001\085\001\086\001\087\001\255\255\ +\089\001\255\255\091\001\092\001\000\000\094\001\095\001\096\001\ +\097\001\098\001\255\255\100\001\101\001\255\255\103\001\104\001\ +\105\001\106\001\255\255\108\001\109\001\255\255\111\001\255\255\ +\255\255\255\255\115\001\000\001\001\001\002\001\003\001\004\001\ +\255\255\006\001\007\001\008\001\009\001\010\001\011\001\012\001\ +\013\001\014\001\015\001\016\001\017\001\018\001\019\001\020\001\ +\021\001\255\255\255\255\024\001\025\001\026\001\027\001\028\001\ +\029\001\030\001\031\001\255\255\255\255\255\255\255\255\036\001\ +\037\001\255\255\255\255\040\001\041\001\042\001\043\001\044\001\ +\045\001\046\001\255\255\048\001\049\001\050\001\051\001\255\255\ +\053\001\054\001\055\001\056\001\255\255\255\255\059\001\060\001\ +\061\001\255\255\063\001\064\001\065\001\066\001\067\001\068\001\ +\255\255\070\001\071\001\072\001\073\001\074\001\255\255\076\001\ +\255\255\255\255\255\255\080\001\081\001\082\001\083\001\084\001\ +\085\001\086\001\087\001\255\255\089\001\255\255\091\001\092\001\ +\000\000\094\001\095\001\096\001\255\255\255\255\255\255\100\001\ +\101\001\255\255\103\001\104\001\105\001\106\001\255\255\108\001\ +\109\001\255\255\111\001\255\255\255\255\255\255\115\001\000\001\ +\001\001\002\001\003\001\004\001\255\255\006\001\007\001\008\001\ +\009\001\010\001\011\001\012\001\013\001\014\001\015\001\016\001\ +\017\001\018\001\019\001\020\001\021\001\255\255\255\255\024\001\ +\025\001\026\001\027\001\028\001\029\001\030\001\031\001\255\255\ +\255\255\255\255\255\255\036\001\037\001\255\255\255\255\040\001\ +\041\001\042\001\043\001\044\001\045\001\046\001\255\255\048\001\ +\049\001\050\001\051\001\255\255\053\001\054\001\055\001\056\001\ +\255\255\255\255\059\001\060\001\061\001\255\255\063\001\064\001\ +\065\001\066\001\067\001\068\001\255\255\070\001\071\001\072\001\ +\073\001\074\001\255\255\076\001\255\255\255\255\255\255\080\001\ +\081\001\082\001\083\001\084\001\085\001\086\001\087\001\255\255\ +\089\001\255\255\091\001\092\001\000\000\094\001\095\001\096\001\ +\255\255\255\255\255\255\100\001\101\001\255\255\103\001\104\001\ +\105\001\106\001\255\255\108\001\109\001\255\255\111\001\255\255\ +\255\255\255\255\115\001\255\255\000\001\001\001\002\001\003\001\ +\004\001\255\255\006\001\007\001\008\001\009\001\010\001\011\001\ +\012\001\013\001\014\001\015\001\016\001\017\001\018\001\019\001\ +\020\001\021\001\255\255\255\255\024\001\025\001\026\001\027\001\ +\028\001\029\001\030\001\031\001\255\255\255\255\255\255\255\255\ +\036\001\037\001\255\255\255\255\040\001\041\001\042\001\043\001\ +\044\001\045\001\046\001\255\255\048\001\049\001\050\001\051\001\ +\255\255\053\001\054\001\055\001\056\001\255\255\255\255\059\001\ +\060\001\061\001\255\255\063\001\064\001\065\001\066\001\067\001\ +\068\001\255\255\070\001\071\001\072\001\073\001\074\001\255\255\ +\076\001\255\255\255\255\255\255\080\001\081\001\082\001\083\001\ +\084\001\085\001\086\001\087\001\255\255\089\001\255\255\091\001\ +\092\001\000\000\094\001\095\001\096\001\255\255\255\255\255\255\ +\100\001\101\001\255\255\103\001\104\001\105\001\106\001\255\255\ +\108\001\109\001\255\255\111\001\255\255\255\255\255\255\115\001\ +\000\001\001\001\002\001\003\001\255\255\255\255\255\255\255\255\ +\008\001\009\001\010\001\255\255\255\255\013\001\014\001\015\001\ +\016\001\017\001\018\001\019\001\020\001\021\001\022\001\255\255\ +\024\001\025\001\026\001\027\001\028\001\029\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\036\001\037\001\255\255\255\255\ +\040\001\041\001\042\001\043\001\044\001\045\001\046\001\047\001\ +\048\001\049\001\255\255\051\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\060\001\061\001\255\255\063\001\ +\255\255\255\255\066\001\067\001\068\001\255\255\070\001\071\001\ +\072\001\073\001\074\001\255\255\255\255\255\255\255\255\255\255\ +\080\001\081\001\082\001\083\001\084\001\085\001\086\001\255\255\ +\255\255\089\001\255\255\091\001\092\001\000\000\094\001\095\001\ +\096\001\097\001\098\001\255\255\100\001\255\255\255\255\103\001\ +\104\001\105\001\255\255\255\255\108\001\255\255\255\255\111\001\ +\255\255\255\255\255\255\115\001\000\001\001\001\002\001\003\001\ +\255\255\255\255\255\255\255\255\008\001\009\001\010\001\255\255\ +\255\255\013\001\014\001\015\001\016\001\017\001\018\001\019\001\ +\020\001\021\001\022\001\255\255\024\001\025\001\026\001\027\001\ +\028\001\029\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\036\001\037\001\255\255\255\255\040\001\041\001\042\001\043\001\ +\044\001\045\001\046\001\047\001\048\001\049\001\255\255\051\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\060\001\061\001\255\255\063\001\255\255\255\255\066\001\067\001\ +\068\001\255\255\070\001\071\001\072\001\073\001\074\001\255\255\ +\255\255\255\255\255\255\255\255\080\001\081\001\082\001\083\001\ +\084\001\085\001\086\001\255\255\255\255\089\001\255\255\091\001\ +\092\001\000\000\094\001\095\001\096\001\097\001\098\001\255\255\ +\100\001\255\255\255\255\103\001\104\001\105\001\255\255\255\255\ +\108\001\255\255\255\255\111\001\255\255\255\255\255\255\115\001\ +\255\255\000\001\001\001\002\001\003\001\255\255\255\255\255\255\ +\255\255\008\001\009\001\010\001\255\255\255\255\013\001\014\001\ +\015\001\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ +\255\255\024\001\025\001\026\001\027\001\028\001\029\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\036\001\037\001\255\255\ +\255\255\040\001\041\001\042\001\043\001\044\001\045\001\046\001\ +\255\255\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\060\001\061\001\255\255\ +\063\001\255\255\255\255\066\001\067\001\068\001\255\255\070\001\ +\071\001\072\001\073\001\074\001\255\255\255\255\255\255\255\255\ +\255\255\080\001\255\255\082\001\083\001\084\001\085\001\086\001\ +\255\255\255\255\255\255\255\255\091\001\092\001\000\000\094\001\ +\095\001\096\001\255\255\255\255\255\255\100\001\255\255\255\255\ +\103\001\255\255\105\001\255\255\255\255\108\001\255\255\255\255\ +\111\001\255\255\255\255\255\255\115\001\000\001\001\001\002\001\ +\003\001\255\255\255\255\255\255\255\255\008\001\009\001\010\001\ +\255\255\255\255\013\001\014\001\015\001\016\001\017\001\255\255\ +\019\001\020\001\021\001\255\255\255\255\024\001\025\001\026\001\ +\027\001\028\001\029\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\036\001\037\001\255\255\255\255\040\001\041\001\042\001\ +\043\001\044\001\045\001\046\001\255\255\048\001\049\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\060\001\061\001\255\255\063\001\255\255\255\255\066\001\ +\067\001\068\001\255\255\070\001\071\001\072\001\073\001\074\001\ +\255\255\255\255\255\255\255\255\255\255\080\001\255\255\082\001\ +\083\001\084\001\085\001\086\001\255\255\255\255\255\255\255\255\ +\091\001\092\001\000\000\094\001\095\001\096\001\097\001\255\255\ +\255\255\100\001\255\255\255\255\103\001\255\255\105\001\255\255\ +\255\255\108\001\255\255\255\255\111\001\255\255\255\255\255\255\ +\115\001\000\001\001\001\002\001\003\001\255\255\255\255\255\255\ +\255\255\008\001\009\001\010\001\255\255\255\255\013\001\014\001\ +\015\001\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ +\255\255\024\001\025\001\026\001\027\001\028\001\029\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\036\001\037\001\255\255\ +\255\255\040\001\041\001\042\001\043\001\044\001\045\001\046\001\ +\255\255\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\060\001\061\001\255\255\ +\063\001\255\255\255\255\066\001\067\001\068\001\255\255\070\001\ +\071\001\072\001\073\001\074\001\255\255\255\255\255\255\255\255\ +\255\255\080\001\255\255\082\001\083\001\084\001\085\001\086\001\ +\255\255\255\255\255\255\255\255\091\001\092\001\000\000\094\001\ +\095\001\096\001\255\255\255\255\255\255\100\001\255\255\255\255\ +\103\001\255\255\105\001\255\255\255\255\108\001\255\255\255\255\ +\111\001\255\255\255\255\255\255\115\001\255\255\000\001\001\001\ +\002\001\003\001\255\255\255\255\255\255\255\255\008\001\009\001\ +\010\001\255\255\255\255\013\001\014\001\015\001\016\001\017\001\ +\018\001\019\001\020\001\021\001\255\255\255\255\024\001\025\001\ +\026\001\027\001\028\001\029\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\036\001\037\001\255\255\255\255\040\001\041\001\ +\042\001\043\001\044\001\045\001\046\001\255\255\048\001\049\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\060\001\061\001\255\255\063\001\255\255\255\255\ +\066\001\067\001\068\001\255\255\070\001\071\001\072\001\073\001\ +\074\001\255\255\255\255\255\255\255\255\255\255\080\001\255\255\ +\082\001\083\001\084\001\085\001\086\001\255\255\255\255\255\255\ +\255\255\091\001\092\001\000\000\094\001\095\001\096\001\255\255\ +\255\255\255\255\100\001\255\255\255\255\103\001\255\255\105\001\ +\255\255\255\255\108\001\255\255\255\255\111\001\255\255\255\255\ +\255\255\115\001\000\001\001\001\002\001\003\001\255\255\255\255\ +\255\255\255\255\008\001\009\001\010\001\255\255\255\255\013\001\ +\014\001\015\001\016\001\017\001\018\001\019\001\020\001\021\001\ +\255\255\255\255\024\001\025\001\026\001\027\001\028\001\029\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\036\001\037\001\ +\255\255\255\255\040\001\041\001\042\001\043\001\044\001\045\001\ +\046\001\255\255\048\001\049\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\060\001\061\001\ +\255\255\063\001\255\255\255\255\066\001\067\001\068\001\255\255\ +\070\001\071\001\072\001\073\001\074\001\255\255\255\255\255\255\ +\255\255\255\255\080\001\255\255\082\001\083\001\084\001\085\001\ +\086\001\255\255\255\255\255\255\255\255\091\001\092\001\000\000\ +\094\001\095\001\096\001\255\255\255\255\255\255\100\001\255\255\ +\255\255\103\001\255\255\105\001\255\255\255\255\108\001\255\255\ +\255\255\111\001\255\255\255\255\255\255\115\001\000\001\001\001\ +\002\001\003\001\255\255\255\255\255\255\255\255\008\001\009\001\ +\010\001\255\255\255\255\013\001\014\001\015\001\016\001\017\001\ +\018\001\019\001\020\001\021\001\255\255\255\255\024\001\025\001\ +\026\001\027\001\028\001\029\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\036\001\037\001\255\255\255\255\040\001\041\001\ +\042\001\043\001\044\001\045\001\046\001\255\255\048\001\049\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\060\001\061\001\255\255\063\001\255\255\255\255\ +\066\001\067\001\068\001\255\255\070\001\071\001\072\001\073\001\ +\074\001\255\255\255\255\255\255\255\255\255\255\080\001\255\255\ +\082\001\083\001\084\001\085\001\086\001\255\255\255\255\255\255\ +\255\255\091\001\092\001\000\000\094\001\095\001\096\001\255\255\ +\255\255\255\255\100\001\255\255\255\255\103\001\255\255\105\001\ +\255\255\255\255\108\001\255\255\255\255\111\001\255\255\255\255\ +\255\255\115\001\255\255\000\001\001\001\002\001\003\001\255\255\ +\255\255\255\255\255\255\008\001\009\001\010\001\255\255\255\255\ +\013\001\014\001\015\001\016\001\017\001\018\001\019\001\020\001\ +\021\001\255\255\255\255\024\001\025\001\026\001\027\001\028\001\ +\029\001\255\255\255\255\255\255\255\255\255\255\255\255\036\001\ +\037\001\255\255\255\255\040\001\041\001\042\001\043\001\044\001\ +\045\001\255\255\255\255\048\001\049\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\060\001\ +\061\001\255\255\063\001\255\255\255\255\066\001\067\001\068\001\ +\255\255\070\001\071\001\072\001\073\001\074\001\255\255\255\255\ +\255\255\255\255\255\255\080\001\255\255\082\001\083\001\084\001\ +\085\001\086\001\255\255\255\255\255\255\255\255\091\001\092\001\ +\000\000\094\001\095\001\096\001\097\001\255\255\255\255\100\001\ +\255\255\255\255\103\001\255\255\105\001\255\255\255\255\108\001\ +\255\255\255\255\111\001\255\255\255\255\255\255\115\001\000\001\ +\001\001\002\001\003\001\255\255\255\255\255\255\255\255\008\001\ +\009\001\010\001\255\255\255\255\013\001\014\001\015\001\016\001\ +\017\001\018\001\019\001\020\001\021\001\255\255\255\255\024\001\ +\025\001\026\001\027\001\028\001\029\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\036\001\037\001\255\255\255\255\040\001\ +\041\001\042\001\043\001\044\001\045\001\255\255\255\255\048\001\ +\049\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\060\001\061\001\255\255\063\001\255\255\ +\255\255\066\001\067\001\068\001\255\255\070\001\071\001\072\001\ +\073\001\074\001\255\255\255\255\255\255\255\255\255\255\080\001\ +\255\255\082\001\083\001\084\001\085\001\086\001\255\255\255\255\ +\255\255\255\255\091\001\092\001\000\000\094\001\095\001\096\001\ +\097\001\255\255\255\255\100\001\255\255\255\255\103\001\255\255\ +\105\001\255\255\255\255\108\001\255\255\255\255\111\001\255\255\ +\255\255\255\255\115\001\000\001\001\001\002\001\003\001\255\255\ +\255\255\255\255\255\255\008\001\009\001\010\001\255\255\255\255\ +\013\001\014\001\015\001\016\001\017\001\018\001\019\001\020\001\ +\021\001\255\255\255\255\024\001\025\001\026\001\027\001\028\001\ +\029\001\255\255\255\255\255\255\255\255\255\255\255\255\036\001\ +\037\001\255\255\255\255\040\001\041\001\042\001\043\001\044\001\ +\045\001\255\255\255\255\048\001\049\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\060\001\ +\061\001\255\255\063\001\255\255\255\255\066\001\067\001\068\001\ +\255\255\070\001\071\001\072\001\073\001\074\001\255\255\255\255\ +\255\255\255\255\255\255\080\001\255\255\082\001\083\001\084\001\ +\085\001\086\001\255\255\255\255\255\255\255\255\091\001\092\001\ +\000\000\094\001\095\001\096\001\097\001\255\255\255\255\100\001\ +\255\255\255\255\103\001\255\255\105\001\255\255\255\255\108\001\ +\255\255\255\255\111\001\255\255\255\255\255\255\115\001\255\255\ +\000\001\001\001\002\001\003\001\255\255\255\255\255\255\255\255\ +\008\001\009\001\010\001\255\255\255\255\013\001\014\001\015\001\ +\016\001\017\001\018\001\019\001\020\001\021\001\255\255\255\255\ +\024\001\025\001\026\001\027\001\028\001\029\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\036\001\037\001\255\255\255\255\ +\040\001\041\001\042\001\043\001\044\001\045\001\255\255\255\255\ +\048\001\049\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\060\001\061\001\255\255\063\001\ +\255\255\255\255\066\001\067\001\068\001\255\255\070\001\071\001\ +\072\001\073\001\074\001\255\255\255\255\255\255\255\255\255\255\ +\080\001\255\255\082\001\083\001\084\001\085\001\086\001\255\255\ +\255\255\255\255\255\255\091\001\092\001\000\000\094\001\095\001\ +\096\001\097\001\255\255\255\255\100\001\255\255\255\255\103\001\ +\255\255\105\001\255\255\255\255\108\001\255\255\255\255\111\001\ +\255\255\255\255\255\255\115\001\000\001\001\001\002\001\003\001\ +\255\255\255\255\255\255\255\255\255\255\009\001\010\001\255\255\ +\255\255\013\001\014\001\015\001\016\001\017\001\018\001\019\001\ +\020\001\021\001\255\255\255\255\024\001\025\001\026\001\027\001\ +\028\001\029\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\036\001\037\001\255\255\255\255\040\001\041\001\042\001\043\001\ +\044\001\045\001\046\001\255\255\048\001\049\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\060\001\061\001\255\255\063\001\255\255\255\255\066\001\067\001\ +\068\001\255\255\070\001\071\001\072\001\073\001\074\001\255\255\ +\255\255\255\255\255\255\255\255\080\001\255\255\082\001\083\001\ +\084\001\085\001\086\001\255\255\255\255\255\255\255\255\091\001\ +\092\001\000\000\094\001\095\001\096\001\097\001\255\255\255\255\ +\100\001\255\255\255\255\103\001\255\255\105\001\255\255\255\255\ +\108\001\255\255\255\255\111\001\255\255\255\255\255\255\115\001\ +\000\001\001\001\002\001\003\001\255\255\255\255\255\255\255\255\ +\255\255\009\001\010\001\255\255\255\255\013\001\014\001\015\001\ +\016\001\017\001\018\001\019\001\020\001\021\001\255\255\255\255\ +\024\001\025\001\026\001\027\001\028\001\029\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\036\001\037\001\255\255\255\255\ +\040\001\041\001\042\001\043\001\044\001\045\001\046\001\255\255\ +\048\001\049\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\060\001\061\001\255\255\063\001\ +\255\255\255\255\066\001\067\001\068\001\255\255\070\001\071\001\ +\072\001\073\001\074\001\255\255\255\255\255\255\255\255\255\255\ +\080\001\255\255\082\001\083\001\084\001\085\001\086\001\255\255\ +\255\255\255\255\255\255\091\001\092\001\000\000\094\001\095\001\ +\096\001\097\001\255\255\255\255\100\001\255\255\255\255\103\001\ +\255\255\105\001\255\255\255\255\108\001\255\255\255\255\111\001\ +\255\255\255\255\255\255\115\001\255\255\000\001\001\001\002\001\ +\003\001\255\255\255\255\255\255\255\255\255\255\009\001\010\001\ +\255\255\255\255\013\001\014\001\015\001\016\001\017\001\018\001\ +\019\001\020\001\021\001\255\255\255\255\024\001\025\001\026\001\ +\027\001\028\001\029\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\036\001\037\001\255\255\255\255\040\001\041\001\042\001\ +\043\001\044\001\045\001\046\001\255\255\048\001\049\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\060\001\061\001\255\255\063\001\255\255\255\255\066\001\ +\067\001\068\001\255\255\070\001\071\001\072\001\073\001\074\001\ +\255\255\255\255\255\255\255\255\255\255\080\001\255\255\082\001\ +\083\001\084\001\085\001\086\001\255\255\255\255\255\255\255\255\ +\091\001\092\001\000\000\094\001\095\001\096\001\097\001\255\255\ +\255\255\100\001\255\255\255\255\103\001\255\255\105\001\255\255\ +\255\255\108\001\255\255\255\255\111\001\255\255\255\255\255\255\ +\115\001\000\001\001\001\002\001\003\001\255\255\255\255\255\255\ +\255\255\008\001\009\001\010\001\255\255\255\255\013\001\014\001\ +\015\001\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ +\255\255\024\001\025\001\026\001\027\001\028\001\029\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\036\001\037\001\255\255\ +\255\255\040\001\041\001\042\001\043\001\044\001\255\255\255\255\ +\255\255\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\060\001\061\001\255\255\ +\063\001\255\255\255\255\066\001\067\001\068\001\255\255\070\001\ +\071\001\072\001\073\001\074\001\255\255\255\255\255\255\255\255\ +\255\255\080\001\255\255\082\001\255\255\084\001\085\001\086\001\ +\255\255\255\255\255\255\255\255\091\001\092\001\000\000\094\001\ +\095\001\096\001\097\001\255\255\255\255\255\255\255\255\255\255\ +\103\001\255\255\105\001\255\255\255\255\108\001\255\255\255\255\ +\111\001\255\255\255\255\255\255\115\001\000\001\001\001\002\001\ +\003\001\255\255\255\255\255\255\255\255\008\001\009\001\010\001\ +\255\255\255\255\013\001\014\001\015\001\016\001\017\001\018\001\ +\019\001\020\001\021\001\255\255\255\255\024\001\025\001\026\001\ +\027\001\028\001\029\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\036\001\037\001\255\255\255\255\040\001\041\001\042\001\ +\043\001\044\001\255\255\255\255\255\255\048\001\049\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\060\001\061\001\255\255\063\001\255\255\255\255\066\001\ +\067\001\068\001\255\255\070\001\071\001\072\001\073\001\074\001\ +\255\255\255\255\255\255\255\255\255\255\080\001\255\255\082\001\ +\255\255\084\001\085\001\086\001\255\255\255\255\255\255\255\255\ +\091\001\092\001\000\000\094\001\095\001\096\001\097\001\255\255\ +\255\255\255\255\255\255\255\255\103\001\255\255\105\001\255\255\ +\255\255\108\001\255\255\255\255\111\001\255\255\255\255\255\255\ +\115\001\255\255\000\001\001\001\002\001\003\001\255\255\255\255\ +\255\255\255\255\008\001\009\001\010\001\255\255\255\255\013\001\ +\014\001\015\001\016\001\017\001\018\001\019\001\020\001\021\001\ +\255\255\255\255\024\001\025\001\026\001\027\001\028\001\029\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\036\001\037\001\ +\255\255\255\255\040\001\041\001\042\001\043\001\044\001\255\255\ +\255\255\255\255\048\001\049\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\060\001\061\001\ +\255\255\063\001\255\255\255\255\066\001\067\001\068\001\255\255\ +\070\001\071\001\072\001\073\001\074\001\255\255\255\255\255\255\ +\255\255\255\255\080\001\255\255\082\001\255\255\084\001\085\001\ +\086\001\255\255\255\255\255\255\255\255\091\001\092\001\000\000\ +\094\001\095\001\096\001\097\001\255\255\255\255\255\255\255\255\ +\255\255\103\001\255\255\105\001\255\255\255\255\108\001\255\255\ +\255\255\111\001\255\255\255\255\255\255\115\001\000\001\001\001\ +\002\001\003\001\255\255\255\255\255\255\255\255\008\001\009\001\ +\010\001\255\255\255\255\013\001\014\001\015\001\016\001\017\001\ +\018\001\019\001\020\001\021\001\255\255\255\255\024\001\025\001\ +\026\001\027\001\028\001\029\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\036\001\037\001\255\255\255\255\040\001\041\001\ +\042\001\043\001\044\001\255\255\255\255\255\255\048\001\049\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\060\001\061\001\255\255\063\001\255\255\255\255\ +\066\001\067\001\068\001\255\255\070\001\071\001\072\001\073\001\ +\074\001\255\255\255\255\255\255\255\255\255\255\080\001\255\255\ +\082\001\255\255\084\001\085\001\086\001\255\255\255\255\255\255\ +\255\255\091\001\092\001\000\000\094\001\095\001\096\001\097\001\ +\255\255\255\255\255\255\255\255\255\255\103\001\255\255\105\001\ +\255\255\255\255\108\001\255\255\255\255\111\001\255\255\255\255\ +\255\255\115\001\000\001\001\001\002\001\003\001\255\255\255\255\ +\255\255\255\255\008\001\009\001\010\001\255\255\255\255\013\001\ +\014\001\015\001\016\001\017\001\018\001\019\001\020\001\021\001\ +\255\255\255\255\024\001\025\001\026\001\027\001\028\001\029\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\036\001\037\001\ +\255\255\255\255\040\001\041\001\042\001\043\001\044\001\255\255\ +\255\255\255\255\048\001\049\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\060\001\061\001\ +\255\255\063\001\255\255\255\255\066\001\067\001\068\001\255\255\ +\070\001\071\001\072\001\073\001\074\001\255\255\255\255\255\255\ +\255\255\255\255\080\001\255\255\082\001\255\255\084\001\085\001\ +\086\001\255\255\255\255\255\255\255\255\091\001\092\001\000\000\ +\094\001\095\001\096\001\097\001\255\255\255\255\255\255\255\255\ +\255\255\103\001\255\255\105\001\255\255\255\255\108\001\255\255\ +\255\255\111\001\255\255\255\255\255\255\115\001\255\255\000\001\ +\001\001\002\001\003\001\255\255\255\255\255\255\255\255\008\001\ +\009\001\010\001\255\255\255\255\013\001\014\001\015\001\016\001\ +\017\001\018\001\019\001\020\001\021\001\255\255\255\255\024\001\ +\025\001\026\001\027\001\028\001\029\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\036\001\037\001\255\255\255\255\040\001\ +\041\001\042\001\043\001\044\001\255\255\255\255\255\255\048\001\ +\049\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\060\001\061\001\255\255\063\001\255\255\ +\255\255\066\001\067\001\068\001\255\255\070\001\071\001\072\001\ +\073\001\074\001\255\255\255\255\255\255\255\255\255\255\080\001\ +\255\255\082\001\255\255\084\001\085\001\086\001\255\255\255\255\ +\255\255\255\255\091\001\092\001\000\000\094\001\095\001\096\001\ +\097\001\255\255\255\255\255\255\255\255\255\255\103\001\255\255\ +\105\001\255\255\255\255\108\001\255\255\255\255\111\001\255\255\ +\255\255\255\255\115\001\000\001\001\001\002\001\003\001\255\255\ +\255\255\255\255\255\255\008\001\009\001\010\001\255\255\255\255\ +\013\001\014\001\015\001\016\001\017\001\018\001\019\001\020\001\ +\021\001\255\255\255\255\024\001\025\001\026\001\027\001\028\001\ +\029\001\255\255\255\255\255\255\255\255\255\255\255\255\036\001\ +\037\001\255\255\255\255\040\001\041\001\042\001\043\001\044\001\ +\045\001\046\001\255\255\048\001\049\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\060\001\ +\061\001\255\255\255\255\255\255\255\255\066\001\067\001\068\001\ +\255\255\070\001\255\255\255\255\073\001\074\001\255\255\255\255\ +\255\255\255\255\255\255\080\001\255\255\082\001\255\255\255\255\ +\255\255\086\001\255\255\255\255\255\255\255\255\091\001\092\001\ +\000\000\094\001\095\001\096\001\097\001\255\255\255\255\100\001\ +\255\255\255\255\103\001\255\255\105\001\255\255\255\255\108\001\ +\255\255\255\255\111\001\255\255\255\255\255\255\115\001\000\001\ +\001\001\002\001\003\001\255\255\255\255\255\255\255\255\008\001\ +\009\001\010\001\255\255\255\255\013\001\014\001\255\255\016\001\ +\017\001\018\001\019\001\020\001\021\001\255\255\255\255\024\001\ +\025\001\026\001\027\001\028\001\029\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\036\001\037\001\255\255\255\255\040\001\ +\041\001\042\001\255\255\255\255\255\255\255\255\255\255\048\001\ +\049\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\060\001\061\001\255\255\063\001\255\255\ +\255\255\255\255\067\001\068\001\255\255\070\001\255\255\255\255\ +\073\001\074\001\255\255\255\255\255\255\255\255\255\255\080\001\ +\255\255\082\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\091\001\092\001\000\000\094\001\095\001\096\001\ +\097\001\255\255\255\255\255\255\255\255\255\255\103\001\255\255\ +\105\001\255\255\255\255\108\001\255\255\255\255\111\001\255\255\ +\255\255\255\255\115\001\255\255\000\001\001\001\002\001\003\001\ +\255\255\255\255\255\255\255\255\008\001\009\001\010\001\255\255\ +\255\255\013\001\014\001\255\255\016\001\017\001\018\001\019\001\ +\020\001\021\001\255\255\255\255\024\001\025\001\026\001\027\001\ +\028\001\029\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\036\001\037\001\255\255\255\255\040\001\041\001\042\001\255\255\ +\255\255\255\255\255\255\255\255\048\001\049\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\060\001\061\001\255\255\063\001\255\255\255\255\255\255\067\001\ +\068\001\255\255\070\001\255\255\255\255\073\001\074\001\255\255\ +\255\255\255\255\255\255\255\255\080\001\255\255\082\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\091\001\ +\092\001\000\000\094\001\095\001\096\001\097\001\255\255\255\255\ +\255\255\255\255\255\255\103\001\255\255\105\001\255\255\255\255\ +\108\001\255\255\255\255\111\001\255\255\255\255\255\255\115\001\ +\000\001\001\001\002\001\003\001\255\255\255\255\255\255\255\255\ +\008\001\009\001\010\001\255\255\255\255\013\001\014\001\255\255\ +\016\001\017\001\018\001\019\001\020\001\021\001\255\255\255\255\ +\024\001\025\001\026\001\027\001\028\001\029\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\036\001\037\001\255\255\255\255\ +\040\001\041\001\042\001\255\255\255\255\255\255\255\255\255\255\ +\048\001\049\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\060\001\061\001\255\255\063\001\ +\255\255\255\255\255\255\067\001\068\001\255\255\070\001\255\255\ +\255\255\073\001\074\001\255\255\255\255\255\255\255\255\255\255\ +\080\001\000\000\082\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\091\001\092\001\255\255\094\001\095\001\ +\096\001\097\001\255\255\255\255\255\255\255\255\255\255\103\001\ +\255\255\105\001\255\255\255\255\108\001\255\255\255\255\111\001\ +\255\255\255\255\255\255\115\001\000\001\001\001\002\001\003\001\ +\255\255\255\255\255\255\255\255\008\001\009\001\010\001\255\255\ +\255\255\013\001\014\001\255\255\016\001\017\001\018\001\019\001\ +\020\001\021\001\255\255\255\255\024\001\025\001\026\001\027\001\ +\028\001\029\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\036\001\037\001\255\255\255\255\040\001\041\001\042\001\255\255\ +\255\255\255\255\255\255\255\255\048\001\049\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\060\001\061\001\255\255\063\001\255\255\255\255\255\255\067\001\ +\068\001\000\000\070\001\255\255\255\255\073\001\074\001\255\255\ +\255\255\255\255\255\255\255\255\080\001\255\255\082\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\091\001\ +\092\001\255\255\094\001\095\001\096\001\097\001\255\255\255\255\ +\255\255\255\255\255\255\103\001\255\255\105\001\255\255\255\255\ +\108\001\255\255\255\255\111\001\255\255\255\255\255\255\115\001\ +\255\255\000\001\001\001\002\001\003\001\255\255\255\255\255\255\ +\255\255\008\001\009\001\010\001\255\255\255\255\013\001\014\001\ +\255\255\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ +\255\255\024\001\025\001\026\001\027\001\028\001\029\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\036\001\037\001\255\255\ +\255\255\040\001\041\001\042\001\255\255\255\255\255\255\255\255\ +\255\255\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\000\000\255\255\255\255\255\255\060\001\061\001\255\255\ +\063\001\255\255\255\255\255\255\067\001\068\001\255\255\070\001\ +\255\255\255\255\073\001\074\001\255\255\255\255\255\255\255\255\ +\255\255\080\001\255\255\082\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\091\001\092\001\255\255\094\001\ +\095\001\096\001\097\001\255\255\255\255\255\255\255\255\255\255\ +\103\001\000\001\105\001\255\255\003\001\108\001\255\255\255\255\ +\111\001\008\001\009\001\010\001\115\001\255\255\013\001\014\001\ +\255\255\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ +\255\255\024\001\025\001\026\001\255\255\028\001\029\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\037\001\255\255\ +\255\255\040\001\041\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\000\000\255\255\255\255\255\255\060\001\255\255\255\255\ +\063\001\255\255\255\255\255\255\067\001\068\001\255\255\070\001\ +\255\255\255\255\073\001\074\001\255\255\255\255\255\255\255\255\ +\255\255\080\001\255\255\082\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\091\001\092\001\255\255\094\001\ +\095\001\096\001\097\001\255\255\255\255\255\255\255\255\255\255\ +\103\001\000\001\105\001\255\255\003\001\108\001\255\255\255\255\ +\111\001\008\001\009\001\010\001\115\001\255\255\013\001\014\001\ +\255\255\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ +\255\255\024\001\025\001\026\001\255\255\028\001\029\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\037\001\255\255\ +\255\255\040\001\041\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\000\000\255\255\255\255\255\255\060\001\255\255\255\255\ +\063\001\255\255\255\255\255\255\067\001\068\001\255\255\070\001\ +\255\255\255\255\073\001\074\001\255\255\255\255\255\255\255\255\ +\255\255\080\001\255\255\082\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\091\001\092\001\255\255\094\001\ +\095\001\096\001\097\001\255\255\255\255\255\255\255\255\255\255\ +\103\001\000\001\105\001\255\255\003\001\108\001\255\255\255\255\ +\111\001\008\001\255\255\010\001\115\001\255\255\013\001\014\001\ +\255\255\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ +\255\255\024\001\025\001\026\001\255\255\028\001\029\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\037\001\255\255\ +\255\255\040\001\041\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\000\000\255\255\255\255\255\255\060\001\255\255\255\255\ +\063\001\255\255\255\255\255\255\067\001\068\001\255\255\070\001\ +\255\255\255\255\073\001\074\001\255\255\255\255\255\255\255\255\ +\255\255\080\001\255\255\255\255\255\255\255\255\255\255\000\000\ +\255\255\255\255\255\255\255\255\091\001\092\001\255\255\094\001\ +\095\001\096\001\097\001\255\255\255\255\255\255\255\255\255\255\ +\103\001\000\001\105\001\255\255\003\001\108\001\255\255\255\255\ +\111\001\008\001\255\255\010\001\115\001\255\255\013\001\014\001\ +\255\255\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ +\255\255\024\001\025\001\026\001\255\255\028\001\029\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\037\001\255\255\ +\255\255\040\001\041\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\048\001\049\001\255\255\000\000\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\060\001\255\255\255\255\ +\063\001\255\255\255\255\255\255\067\001\068\001\255\255\070\001\ +\255\255\255\255\073\001\074\001\255\255\255\255\255\255\255\255\ +\255\255\080\001\000\000\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\091\001\092\001\255\255\094\001\ +\095\001\096\001\097\001\255\255\255\255\255\255\255\255\255\255\ +\103\001\000\001\105\001\255\255\003\001\108\001\255\255\255\255\ +\111\001\008\001\255\255\010\001\115\001\255\255\013\001\014\001\ +\255\255\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ +\255\255\024\001\025\001\026\001\255\255\028\001\029\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\037\001\255\255\ +\255\255\040\001\041\001\255\255\255\255\255\255\255\255\000\000\ +\255\255\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\060\001\255\255\255\255\ +\063\001\255\255\255\255\255\255\067\001\068\001\255\255\070\001\ +\255\255\255\255\073\001\074\001\255\255\255\255\255\255\255\255\ +\255\255\080\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\091\001\092\001\255\255\094\001\ +\095\001\096\001\097\001\255\255\255\255\255\255\255\255\255\255\ +\103\001\000\001\105\001\255\255\003\001\108\001\255\255\255\255\ +\111\001\008\001\255\255\010\001\115\001\255\255\013\001\014\001\ +\255\255\016\001\017\001\018\001\019\001\020\001\021\001\255\255\ +\255\255\024\001\025\001\026\001\255\255\028\001\029\001\000\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\037\001\255\255\ +\255\255\040\001\041\001\255\255\013\001\255\255\255\255\000\000\ +\023\001\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\026\001\255\255\028\001\029\001\060\001\255\255\255\255\ +\063\001\255\255\255\255\255\255\067\001\068\001\255\255\070\001\ +\041\001\255\255\073\001\074\001\255\255\000\000\255\255\255\255\ +\055\001\080\001\057\001\058\001\059\001\255\255\061\001\255\255\ +\255\255\064\001\065\001\060\001\091\001\092\001\063\001\094\001\ +\095\001\096\001\097\001\068\001\000\001\255\255\255\255\003\001\ +\103\001\074\001\105\001\255\255\008\001\108\001\010\001\080\001\ +\111\001\013\001\014\001\090\001\115\001\017\001\255\255\019\001\ +\020\001\021\001\097\001\092\001\024\001\025\001\026\001\096\001\ +\028\001\029\001\000\001\255\255\255\255\003\001\109\001\110\001\ +\255\255\037\001\255\255\108\001\040\001\041\001\111\001\013\001\ +\255\255\255\255\000\000\255\255\048\001\049\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\026\001\255\255\028\001\029\001\ +\060\001\255\255\255\255\063\001\255\255\255\255\255\255\067\001\ +\068\001\255\255\070\001\041\001\255\255\073\001\074\001\255\255\ +\000\000\053\001\255\255\055\001\080\001\057\001\058\001\059\001\ +\255\255\061\001\255\255\255\255\064\001\065\001\060\001\091\001\ +\092\001\255\255\094\001\095\001\096\001\097\001\068\001\000\001\ +\255\255\255\255\003\001\103\001\074\001\105\001\255\255\008\001\ +\108\001\010\001\080\001\111\001\013\001\014\001\090\001\115\001\ +\017\001\255\255\019\001\020\001\021\001\097\001\092\001\024\001\ +\025\001\026\001\096\001\028\001\029\001\255\255\255\255\255\255\ +\255\255\109\001\110\001\255\255\037\001\255\255\108\001\040\001\ +\041\001\111\001\255\255\255\255\255\255\000\000\255\255\048\001\ +\049\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\060\001\255\255\255\255\063\001\255\255\ +\255\255\255\255\067\001\068\001\255\255\070\001\255\255\255\255\ +\073\001\074\001\255\255\255\255\255\255\255\255\255\255\080\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\091\001\092\001\255\255\094\001\095\001\096\001\ +\097\001\255\255\255\255\255\255\255\255\255\255\103\001\000\001\ +\105\001\255\255\003\001\108\001\255\255\255\255\111\001\008\001\ +\255\255\010\001\115\001\255\255\013\001\014\001\255\255\255\255\ +\017\001\255\255\019\001\020\001\021\001\255\255\255\255\024\001\ +\025\001\026\001\255\255\028\001\029\001\000\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\037\001\255\255\255\255\040\001\ +\041\001\255\255\013\001\255\255\255\255\000\000\255\255\048\001\ +\049\001\255\255\255\255\255\255\255\255\255\255\255\255\026\001\ +\255\255\028\001\029\001\060\001\255\255\255\255\063\001\255\255\ +\255\255\255\255\067\001\068\001\255\255\070\001\041\001\255\255\ +\073\001\074\001\255\255\000\000\255\255\255\255\055\001\080\001\ +\057\001\058\001\059\001\255\255\061\001\255\255\255\255\064\001\ +\065\001\060\001\091\001\092\001\255\255\094\001\095\001\096\001\ +\097\001\068\001\000\001\255\255\255\255\003\001\103\001\074\001\ +\105\001\255\255\008\001\108\001\010\001\080\001\111\001\013\001\ +\014\001\090\001\115\001\017\001\255\255\019\001\020\001\021\001\ +\097\001\092\001\024\001\025\001\026\001\096\001\028\001\029\001\ +\000\001\255\255\255\255\255\255\109\001\110\001\255\255\037\001\ +\255\255\108\001\040\001\041\001\111\001\013\001\255\255\255\255\ +\000\000\255\255\048\001\049\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\026\001\255\255\028\001\029\001\060\001\255\255\ +\255\255\063\001\255\255\255\255\255\255\067\001\068\001\255\255\ +\070\001\041\001\255\255\073\001\074\001\255\255\000\000\255\255\ +\255\255\255\255\080\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\060\001\091\001\092\001\255\255\ +\094\001\095\001\096\001\097\001\068\001\000\001\255\255\255\255\ +\003\001\103\001\074\001\105\001\255\255\008\001\108\001\010\001\ +\080\001\111\001\013\001\014\001\255\255\115\001\017\001\255\255\ +\019\001\020\001\021\001\255\255\092\001\024\001\025\001\026\001\ +\096\001\028\001\029\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\037\001\255\255\108\001\040\001\041\001\111\001\ +\255\255\255\255\255\255\000\000\255\255\048\001\049\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\060\001\255\255\255\255\063\001\255\255\255\255\255\255\ +\067\001\068\001\255\255\070\001\255\255\255\255\073\001\074\001\ +\255\255\255\255\255\255\255\255\255\255\080\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\091\001\092\001\255\255\094\001\095\001\096\001\097\001\255\255\ +\255\255\255\255\255\255\255\255\103\001\000\001\105\001\255\255\ +\003\001\108\001\255\255\255\255\111\001\008\001\255\255\010\001\ +\115\001\255\255\013\001\014\001\255\255\255\255\017\001\255\255\ +\019\001\020\001\021\001\255\255\255\255\024\001\025\001\026\001\ +\255\255\028\001\029\001\000\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\037\001\255\255\255\255\040\001\041\001\255\255\ +\013\001\255\255\255\255\000\000\255\255\048\001\049\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\026\001\255\255\028\001\ +\029\001\060\001\255\255\255\255\063\001\255\255\255\255\255\255\ +\067\001\068\001\255\255\070\001\041\001\255\255\073\001\074\001\ +\255\255\000\000\255\255\255\255\255\255\080\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\060\001\ +\091\001\092\001\255\255\094\001\095\001\096\001\097\001\068\001\ +\000\001\255\255\255\255\003\001\103\001\074\001\105\001\255\255\ +\008\001\108\001\010\001\080\001\111\001\013\001\014\001\255\255\ +\115\001\017\001\255\255\019\001\020\001\021\001\255\255\092\001\ +\024\001\025\001\026\001\096\001\028\001\029\001\000\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\037\001\255\255\108\001\ +\040\001\041\001\111\001\013\001\255\255\255\255\000\000\255\255\ +\048\001\049\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\026\001\255\255\028\001\029\001\060\001\255\255\255\255\063\001\ +\255\255\255\255\255\255\067\001\068\001\255\255\070\001\041\001\ +\255\255\073\001\074\001\255\255\255\255\255\255\255\255\255\255\ +\080\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\060\001\091\001\092\001\255\255\094\001\095\001\ +\096\001\097\001\068\001\000\001\255\255\255\255\003\001\103\001\ +\074\001\105\001\255\255\008\001\108\001\010\001\080\001\111\001\ +\013\001\014\001\255\255\115\001\017\001\255\255\019\001\020\001\ +\021\001\255\255\092\001\024\001\025\001\026\001\096\001\028\001\ +\029\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\037\001\255\255\108\001\040\001\041\001\111\001\255\255\255\255\ +\255\255\000\000\255\255\048\001\049\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\060\001\ +\255\255\255\255\063\001\255\255\255\255\255\255\067\001\068\001\ +\255\255\070\001\255\255\255\255\073\001\074\001\255\255\255\255\ +\255\255\255\255\255\255\080\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\091\001\092\001\ +\255\255\094\001\095\001\096\001\097\001\255\255\255\255\255\255\ +\255\255\255\255\103\001\000\001\105\001\255\255\003\001\108\001\ +\255\255\255\255\111\001\008\001\255\255\010\001\115\001\255\255\ +\013\001\014\001\255\255\255\255\017\001\255\255\019\001\020\001\ +\021\001\255\255\255\255\024\001\025\001\026\001\255\255\028\001\ +\029\001\000\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\037\001\255\255\255\255\040\001\041\001\255\255\013\001\255\255\ +\255\255\000\000\255\255\048\001\049\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\026\001\255\255\028\001\029\001\060\001\ +\255\255\255\255\063\001\255\255\255\255\255\255\067\001\068\001\ +\255\255\070\001\041\001\255\255\073\001\074\001\255\255\255\255\ +\255\255\255\255\255\255\080\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\060\001\091\001\092\001\ +\255\255\094\001\095\001\096\001\097\001\068\001\000\001\255\255\ +\255\255\003\001\103\001\074\001\105\001\255\255\008\001\108\001\ +\010\001\080\001\111\001\013\001\014\001\255\255\115\001\017\001\ +\255\255\019\001\020\001\021\001\255\255\092\001\024\001\025\001\ +\026\001\096\001\028\001\029\001\006\001\255\255\008\001\255\255\ +\255\255\255\255\255\255\037\001\255\255\108\001\040\001\041\001\ +\111\001\255\255\255\255\255\255\000\000\255\255\048\001\049\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\060\001\255\255\255\255\063\001\255\255\255\255\ +\255\255\067\001\068\001\255\255\070\001\255\255\255\255\073\001\ +\074\001\255\255\255\255\255\255\255\255\055\001\080\001\057\001\ +\058\001\059\001\255\255\061\001\255\255\255\255\064\001\065\001\ +\255\255\091\001\092\001\255\255\094\001\095\001\096\001\097\001\ +\255\255\000\001\255\255\255\255\003\001\103\001\255\255\105\001\ +\255\255\008\001\108\001\010\001\255\255\111\001\013\001\014\001\ +\090\001\115\001\017\001\255\255\019\001\020\001\021\001\097\001\ +\255\255\024\001\025\001\026\001\255\255\028\001\029\001\255\255\ +\255\255\255\255\255\255\109\001\110\001\255\255\037\001\255\255\ +\255\255\040\001\041\001\255\255\255\255\255\255\255\255\000\000\ +\255\255\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\060\001\255\255\255\255\ +\063\001\255\255\255\255\255\255\067\001\068\001\255\255\070\001\ +\255\255\255\255\073\001\074\001\255\255\255\255\255\255\255\255\ +\255\255\080\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\091\001\092\001\255\255\094\001\ +\095\001\096\001\097\001\255\255\255\255\255\255\255\255\255\255\ +\103\001\000\001\105\001\255\255\003\001\108\001\255\255\255\255\ +\111\001\008\001\255\255\010\001\115\001\255\255\013\001\014\001\ +\255\255\255\255\017\001\255\255\019\001\020\001\021\001\255\255\ +\255\255\024\001\025\001\026\001\255\255\028\001\029\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\037\001\255\255\ +\255\255\040\001\041\001\255\255\255\255\255\255\255\255\000\000\ +\255\255\048\001\049\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\060\001\255\255\255\255\ +\063\001\255\255\255\255\255\255\067\001\068\001\255\255\070\001\ +\255\255\255\255\073\001\074\001\255\255\255\255\255\255\255\255\ +\255\255\080\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\091\001\092\001\255\255\094\001\ +\095\001\096\001\097\001\255\255\000\001\255\255\255\255\003\001\ +\103\001\255\255\105\001\255\255\008\001\108\001\010\001\255\255\ +\111\001\013\001\014\001\255\255\115\001\017\001\255\255\019\001\ +\020\001\021\001\255\255\255\255\024\001\025\001\026\001\255\255\ +\028\001\029\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\037\001\255\255\255\255\040\001\041\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\048\001\049\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\000\000\255\255\255\255\ +\060\001\255\255\255\255\063\001\255\255\255\255\255\255\067\001\ +\068\001\255\255\070\001\255\255\255\255\073\001\074\001\255\255\ +\255\255\255\255\255\255\255\255\080\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\091\001\ +\092\001\255\255\094\001\095\001\096\001\097\001\255\255\000\001\ +\255\255\255\255\003\001\103\001\255\255\105\001\255\255\008\001\ +\108\001\010\001\255\255\111\001\013\001\014\001\255\255\115\001\ +\017\001\255\255\019\001\020\001\021\001\255\255\255\255\024\001\ +\025\001\026\001\255\255\028\001\029\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\037\001\255\255\255\255\040\001\ +\041\001\255\255\255\255\255\255\255\255\255\255\255\255\048\001\ +\049\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\000\000\255\255\255\255\060\001\255\255\255\255\063\001\255\255\ +\255\255\255\255\067\001\068\001\255\255\070\001\255\255\255\255\ +\073\001\074\001\255\255\255\255\255\255\255\255\255\255\080\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\091\001\092\001\255\255\094\001\255\255\096\001\ +\097\001\255\255\255\255\255\255\255\255\255\255\103\001\000\001\ +\105\001\255\255\003\001\108\001\255\255\255\255\111\001\008\001\ +\255\255\010\001\115\001\255\255\013\001\014\001\255\255\255\255\ +\017\001\255\255\019\001\020\001\021\001\255\255\255\255\024\001\ +\255\255\026\001\255\255\028\001\029\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\037\001\255\255\255\255\040\001\ +\041\001\255\255\255\255\255\255\255\255\255\255\255\255\048\001\ +\049\001\255\255\255\255\000\000\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\060\001\255\255\255\255\063\001\255\255\ +\255\255\255\255\067\001\068\001\255\255\070\001\255\255\255\255\ +\073\001\074\001\255\255\255\255\255\255\255\255\255\255\080\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\091\001\092\001\255\255\094\001\095\001\096\001\ +\097\001\255\255\255\255\255\255\255\255\255\255\103\001\255\255\ +\105\001\255\255\255\255\108\001\255\255\000\001\111\001\002\001\ +\003\001\004\001\115\001\255\255\255\255\008\001\255\255\255\255\ +\255\255\255\255\013\001\255\255\255\255\255\255\017\001\018\001\ +\019\001\255\255\255\255\255\255\255\255\000\001\255\255\026\001\ +\027\001\028\001\029\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\036\001\255\255\255\255\255\255\040\001\041\001\255\255\ +\000\000\255\255\255\255\255\255\255\255\048\001\049\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\060\001\255\255\255\255\063\001\255\255\255\255\066\001\ +\067\001\068\001\255\255\070\001\255\255\255\255\073\001\074\001\ +\255\255\255\255\255\255\255\255\055\001\080\001\057\001\058\001\ +\059\001\255\255\061\001\255\255\255\255\064\001\065\001\255\255\ +\091\001\092\001\255\255\094\001\095\001\096\001\255\255\255\255\ +\000\001\100\001\002\001\003\001\004\001\255\255\081\001\255\255\ +\008\001\108\001\255\255\255\255\111\001\013\001\089\001\090\001\ +\115\001\017\001\018\001\019\001\255\255\255\255\097\001\255\255\ +\255\255\255\255\026\001\027\001\028\001\029\001\255\255\255\255\ +\008\001\255\255\109\001\110\001\036\001\255\255\255\255\255\255\ +\255\255\041\001\255\255\000\000\255\255\255\255\255\255\023\001\ +\048\001\049\001\255\255\255\255\255\255\255\255\030\001\255\255\ +\255\255\255\255\255\255\255\255\060\001\255\255\255\255\063\001\ +\255\255\255\255\066\001\067\001\068\001\255\255\070\001\255\255\ +\255\255\073\001\074\001\255\255\255\255\255\255\255\255\055\001\ +\080\001\057\001\058\001\059\001\255\255\061\001\255\255\255\255\ +\064\001\065\001\255\255\091\001\092\001\255\255\094\001\095\001\ +\096\001\097\001\255\255\000\001\255\255\002\001\003\001\004\001\ +\255\255\081\001\255\255\008\001\108\001\255\255\255\255\111\001\ +\013\001\089\001\090\001\115\001\017\001\018\001\019\001\255\255\ +\255\255\097\001\255\255\255\255\255\255\026\001\027\001\028\001\ +\029\001\255\255\106\001\255\255\255\255\109\001\110\001\036\001\ +\255\255\255\255\255\255\255\255\041\001\255\255\000\000\255\255\ +\255\255\255\255\255\255\048\001\049\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\060\001\ +\255\255\255\255\063\001\255\255\255\255\066\001\067\001\068\001\ +\255\255\070\001\255\255\255\255\255\255\074\001\255\255\255\255\ +\255\255\255\255\255\255\080\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\091\001\092\001\ +\255\255\094\001\095\001\096\001\097\001\255\255\255\255\255\255\ +\000\001\255\255\002\001\003\001\004\001\255\255\255\255\108\001\ +\008\001\255\255\111\001\255\255\255\255\013\001\115\001\255\255\ +\255\255\017\001\018\001\019\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\026\001\027\001\028\001\029\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\036\001\255\255\255\255\255\255\ +\255\255\041\001\255\255\000\000\255\255\255\255\255\255\255\255\ +\048\001\049\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\060\001\255\255\255\255\063\001\ +\255\255\255\255\066\001\067\001\068\001\255\255\070\001\255\255\ +\255\255\255\255\074\001\255\255\255\255\255\255\255\255\055\001\ +\080\001\057\001\058\001\059\001\255\255\061\001\255\255\255\255\ +\064\001\065\001\255\255\091\001\092\001\255\255\094\001\095\001\ +\096\001\097\001\074\001\000\001\255\255\002\001\003\001\004\001\ +\255\255\081\001\255\255\008\001\108\001\255\255\255\255\111\001\ +\013\001\089\001\090\001\115\001\017\001\018\001\019\001\000\000\ +\255\255\097\001\255\255\255\255\255\255\026\001\027\001\028\001\ +\029\001\255\255\255\255\255\255\255\255\109\001\110\001\036\001\ +\255\255\255\255\255\255\255\255\041\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\048\001\049\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\060\001\ +\255\255\255\255\063\001\255\255\255\255\066\001\067\001\068\001\ +\255\255\070\001\255\255\255\255\255\255\074\001\255\255\255\255\ +\255\255\000\000\055\001\080\001\057\001\058\001\059\001\255\255\ +\061\001\255\255\255\255\064\001\065\001\255\255\091\001\092\001\ +\255\255\094\001\095\001\096\001\097\001\255\255\000\001\255\255\ +\002\001\003\001\004\001\255\255\081\001\255\255\008\001\108\001\ +\255\255\255\255\111\001\013\001\089\001\090\001\115\001\017\001\ +\018\001\019\001\255\255\255\255\097\001\255\255\255\255\255\255\ +\026\001\027\001\028\001\029\001\255\255\255\255\255\255\108\001\ +\109\001\110\001\036\001\000\000\255\255\255\255\255\255\041\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\048\001\049\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\060\001\255\255\255\255\063\001\255\255\255\255\ +\066\001\067\001\068\001\255\255\070\001\255\255\255\255\255\255\ +\074\001\255\255\255\255\255\255\255\255\255\255\080\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\091\001\092\001\255\255\094\001\095\001\096\001\097\001\ +\255\255\000\000\255\255\000\001\255\255\002\001\003\001\255\255\ +\255\255\255\255\108\001\008\001\255\255\111\001\255\255\255\255\ +\013\001\115\001\255\255\255\255\017\001\018\001\019\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\026\001\027\001\028\001\ +\029\001\255\255\255\255\255\255\255\255\255\255\255\255\036\001\ +\255\255\255\255\255\255\255\255\041\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\048\001\049\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\000\000\255\255\255\255\255\255\060\001\ +\255\255\255\255\063\001\255\255\255\255\066\001\067\001\068\001\ +\255\255\070\001\255\255\255\255\006\001\074\001\008\001\000\001\ +\255\255\255\255\003\001\080\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\013\001\255\255\091\001\092\001\ +\017\001\094\001\095\001\096\001\097\001\255\255\255\255\255\255\ +\255\255\026\001\027\001\028\001\029\001\255\255\255\255\108\001\ +\255\255\255\255\111\001\255\255\255\255\255\255\115\001\255\255\ +\041\001\255\255\255\255\255\255\255\255\055\001\255\255\057\001\ +\058\001\059\001\255\255\061\001\255\255\255\255\064\001\065\001\ +\255\255\000\001\255\255\060\001\003\001\255\255\063\001\255\255\ +\255\255\066\001\067\001\068\001\255\255\255\255\013\001\255\255\ +\073\001\074\001\017\001\255\255\255\255\255\255\255\255\080\001\ +\090\001\255\255\092\001\026\001\027\001\028\001\029\001\097\001\ +\255\255\255\255\255\255\092\001\000\000\094\001\255\255\096\001\ +\097\001\255\255\041\001\109\001\110\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\108\001\255\255\255\255\111\001\255\255\ +\255\255\255\255\115\001\000\001\255\255\060\001\003\001\255\255\ +\063\001\255\255\255\255\066\001\067\001\068\001\255\255\255\255\ +\013\001\255\255\073\001\074\001\017\001\255\255\255\255\255\255\ +\255\255\080\001\255\255\255\255\255\255\026\001\027\001\028\001\ +\029\001\255\255\255\255\255\255\255\255\092\001\255\255\094\001\ +\255\255\096\001\097\001\255\255\041\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\108\001\255\255\255\255\ +\111\001\255\255\255\255\255\255\115\001\255\255\255\255\060\001\ +\255\255\000\001\063\001\255\255\003\001\066\001\067\001\068\001\ +\255\255\255\255\255\255\255\255\073\001\074\001\013\001\255\255\ +\255\255\255\255\017\001\080\001\019\001\255\255\255\255\255\255\ +\255\255\255\255\000\000\026\001\027\001\028\001\029\001\092\001\ +\255\255\094\001\255\255\096\001\097\001\255\255\255\255\255\255\ +\255\255\255\255\041\001\255\255\255\255\255\255\255\255\108\001\ +\255\255\255\255\111\001\255\255\255\255\255\255\115\001\255\255\ +\255\255\255\255\255\255\000\001\255\255\060\001\003\001\255\255\ +\063\001\255\255\255\255\255\255\067\001\068\001\255\255\255\255\ +\013\001\255\255\073\001\074\001\017\001\255\255\255\255\255\255\ +\255\255\080\001\255\255\255\255\255\255\026\001\027\001\028\001\ +\029\001\255\255\255\255\255\255\255\255\092\001\255\255\094\001\ +\255\255\096\001\097\001\255\255\041\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\108\001\255\255\255\255\ +\111\001\000\000\255\255\255\255\115\001\255\255\255\255\060\001\ +\255\255\255\255\063\001\255\255\255\255\255\255\067\001\068\001\ +\255\255\255\255\255\255\255\255\073\001\074\001\055\001\255\255\ +\057\001\058\001\059\001\080\001\061\001\255\255\063\001\064\001\ +\065\001\255\255\255\255\255\255\255\255\255\255\255\255\092\001\ +\255\255\094\001\255\255\096\001\097\001\078\001\255\255\255\255\ +\081\001\255\255\255\255\255\255\255\255\255\255\255\255\108\001\ +\089\001\090\001\111\001\255\255\000\001\255\255\115\001\003\001\ +\097\001\005\001\006\001\007\001\008\001\255\255\255\255\011\001\ +\012\001\013\001\255\255\255\255\109\001\110\001\255\255\019\001\ +\255\255\255\255\255\255\023\001\255\255\255\255\026\001\255\255\ +\028\001\029\001\030\001\031\001\032\001\033\001\034\001\035\001\ +\036\001\255\255\255\255\039\001\040\001\041\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\048\001\049\001\050\001\051\001\ +\052\001\053\001\054\001\055\001\056\001\057\001\058\001\059\001\ +\060\001\061\001\000\000\063\001\064\001\065\001\255\255\067\001\ +\068\001\069\001\070\001\071\001\072\001\255\255\074\001\075\001\ +\076\001\077\001\078\001\255\255\080\001\081\001\255\255\255\255\ +\084\001\085\001\255\255\087\001\088\001\089\001\090\001\091\001\ +\092\001\093\001\255\255\095\001\096\001\097\001\255\255\099\001\ +\255\255\101\001\102\001\255\255\104\001\255\255\106\001\107\001\ +\108\001\109\001\110\001\111\001\112\001\255\255\114\001\005\001\ +\006\001\007\001\255\255\255\255\255\255\011\001\012\001\013\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\028\001\029\001\ +\030\001\031\001\032\001\033\001\034\001\255\255\255\255\255\255\ +\255\255\039\001\255\255\041\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\050\001\255\255\052\001\053\001\ +\054\001\055\001\056\001\255\255\255\255\059\001\060\001\255\255\ +\255\255\063\001\064\001\065\001\255\255\000\000\068\001\069\001\ +\255\255\071\001\072\001\255\255\074\001\255\255\076\001\255\255\ +\078\001\255\255\080\001\255\255\255\255\255\255\084\001\085\001\ +\255\255\087\001\255\255\255\255\255\255\255\255\005\001\006\001\ +\007\001\255\255\096\001\097\001\011\001\012\001\013\001\101\001\ +\255\255\255\255\255\255\255\255\106\001\107\001\108\001\109\001\ +\110\001\111\001\255\255\255\255\114\001\028\001\029\001\030\001\ +\031\001\032\001\033\001\034\001\255\255\255\255\255\255\255\255\ +\039\001\255\255\041\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\050\001\255\255\052\001\053\001\054\001\ +\055\001\056\001\255\255\255\255\059\001\060\001\255\255\255\255\ +\063\001\064\001\065\001\255\255\255\255\068\001\069\001\255\255\ +\071\001\072\001\255\255\074\001\255\255\076\001\255\255\078\001\ +\255\255\080\001\255\255\000\000\255\255\084\001\085\001\255\255\ +\087\001\000\000\055\001\255\255\057\001\058\001\059\001\255\255\ +\061\001\255\255\097\001\064\001\065\001\255\255\101\001\255\255\ +\255\255\255\255\255\255\106\001\107\001\108\001\109\001\110\001\ +\111\001\255\255\255\255\114\001\081\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\089\001\090\001\255\255\005\001\ +\006\001\007\001\255\255\255\255\097\001\011\001\012\001\013\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\109\001\110\001\255\255\255\255\255\255\255\255\028\001\029\001\ +\030\001\031\001\032\001\033\001\034\001\255\255\255\255\255\255\ +\255\255\039\001\255\255\041\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\050\001\255\255\052\001\053\001\ +\054\001\055\001\056\001\255\255\255\255\059\001\060\001\255\255\ +\255\255\063\001\064\001\065\001\255\255\255\255\068\001\069\001\ +\255\255\071\001\072\001\255\255\074\001\000\000\076\001\255\255\ +\078\001\255\255\080\001\255\255\255\255\255\255\084\001\085\001\ +\255\255\087\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\097\001\255\255\255\255\255\255\101\001\ +\255\255\255\255\255\255\255\255\106\001\107\001\108\001\109\001\ +\110\001\111\001\255\255\255\255\114\001\000\001\255\255\255\255\ +\255\255\004\001\255\255\006\001\255\255\008\001\255\255\010\001\ +\255\255\012\001\255\255\014\001\015\001\255\255\017\001\018\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\027\001\028\001\255\255\030\001\031\001\000\000\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\050\001\ +\051\001\052\001\053\001\255\255\055\001\056\001\255\255\255\255\ +\059\001\255\255\255\255\255\255\255\255\064\001\065\001\066\001\ +\255\255\255\255\255\255\255\255\071\001\255\255\073\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\081\001\255\255\ +\255\255\084\001\255\255\255\255\255\255\255\255\089\001\000\000\ +\091\001\092\001\255\255\094\001\095\001\255\255\097\001\255\255\ +\255\255\255\255\101\001\000\001\255\255\104\001\255\255\106\001\ +\255\255\000\001\109\001\110\001\255\255\004\001\113\001\006\001\ +\013\001\008\001\255\255\010\001\255\255\012\001\255\255\014\001\ +\015\001\255\255\017\001\018\001\255\255\026\001\255\255\028\001\ +\029\001\255\255\255\255\255\255\027\001\255\255\255\255\030\001\ +\031\001\255\255\255\255\255\255\041\001\255\255\255\255\255\255\ +\255\255\000\000\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\050\001\051\001\255\255\053\001\060\001\ +\055\001\056\001\255\255\255\255\059\001\255\255\067\001\068\001\ +\255\255\064\001\065\001\066\001\255\255\074\001\255\255\255\255\ +\071\001\255\255\073\001\080\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\081\001\255\255\255\255\084\001\255\255\092\001\ +\255\255\255\255\089\001\096\001\091\001\092\001\255\255\094\001\ +\095\001\255\255\097\001\000\000\255\255\255\255\101\001\108\001\ +\255\255\104\001\111\001\106\001\255\255\000\001\109\001\110\001\ +\003\001\004\001\113\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\013\001\014\001\255\255\255\255\255\255\255\255\ +\019\001\255\255\255\255\255\255\255\255\255\255\255\255\026\001\ +\255\255\028\001\029\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\041\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\048\001\049\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\060\001\255\255\255\255\063\001\255\255\255\255\066\001\ +\067\001\068\001\255\255\070\001\255\255\000\001\255\255\074\001\ +\003\001\004\001\000\000\255\255\255\255\080\001\255\255\255\255\ +\255\255\255\255\013\001\014\001\255\255\255\255\255\255\255\255\ +\019\001\092\001\255\255\094\001\255\255\096\001\097\001\026\001\ +\255\255\028\001\029\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\108\001\255\255\255\255\111\001\255\255\041\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\048\001\049\001\255\255\ +\255\255\255\255\255\255\000\000\255\255\255\255\255\255\000\001\ +\255\255\060\001\003\001\004\001\063\001\255\255\255\255\066\001\ +\067\001\068\001\255\255\070\001\013\001\014\001\255\255\074\001\ +\255\255\255\255\019\001\255\255\255\255\080\001\255\255\255\255\ +\255\255\026\001\255\255\028\001\029\001\255\255\255\255\255\255\ +\255\255\092\001\255\255\094\001\255\255\096\001\097\001\255\255\ +\041\001\255\255\255\255\255\255\255\255\000\000\255\255\048\001\ +\049\001\108\001\255\255\255\255\111\001\255\255\255\255\255\255\ +\255\255\000\001\255\255\060\001\003\001\004\001\063\001\255\255\ +\255\255\255\255\067\001\068\001\255\255\070\001\013\001\014\001\ +\255\255\074\001\255\255\255\255\019\001\255\255\255\255\080\001\ +\255\255\255\255\255\255\026\001\255\255\028\001\029\001\255\255\ +\255\255\255\255\255\255\092\001\255\255\094\001\255\255\096\001\ +\097\001\255\255\041\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\048\001\049\001\108\001\255\255\255\255\111\001\255\255\ +\255\255\255\255\255\255\000\001\255\255\060\001\003\001\004\001\ +\063\001\000\000\255\255\255\255\067\001\068\001\255\255\070\001\ +\013\001\014\001\255\255\074\001\255\255\255\255\019\001\255\255\ +\255\255\080\001\255\255\255\255\255\255\026\001\255\255\028\001\ +\029\001\255\255\255\255\255\255\255\255\092\001\255\255\094\001\ +\255\255\096\001\097\001\255\255\041\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\048\001\049\001\108\001\255\255\255\255\ +\111\001\255\255\255\255\255\255\255\255\255\255\255\255\060\001\ +\255\255\255\255\063\001\000\000\255\255\255\255\067\001\068\001\ +\255\255\070\001\255\255\255\255\255\255\074\001\055\001\255\255\ +\057\001\058\001\059\001\080\001\061\001\255\255\255\255\064\001\ +\065\001\255\255\000\001\255\255\255\255\003\001\255\255\092\001\ +\255\255\094\001\008\001\096\001\097\001\255\255\255\255\013\001\ +\081\001\255\255\255\255\255\255\255\255\019\001\255\255\108\001\ +\089\001\090\001\111\001\255\255\026\001\255\255\028\001\029\001\ +\097\001\255\255\255\255\255\255\255\255\000\000\255\255\255\255\ +\255\255\255\255\040\001\041\001\109\001\110\001\255\255\255\255\ +\255\255\255\255\255\255\000\001\255\255\255\255\003\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\060\001\255\255\ +\013\001\063\001\255\255\255\255\066\001\067\001\068\001\255\255\ +\255\255\255\255\255\255\073\001\074\001\026\001\027\001\028\001\ +\029\001\255\255\080\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\041\001\255\255\092\001\000\000\ +\255\255\255\255\096\001\097\001\255\255\000\001\100\001\255\255\ +\003\001\255\255\255\255\255\255\255\255\255\255\108\001\060\001\ +\255\255\111\001\013\001\064\001\255\255\066\001\067\001\068\001\ +\255\255\255\255\255\255\255\255\073\001\074\001\255\255\026\001\ +\027\001\028\001\029\001\080\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\041\001\092\001\ +\255\255\094\001\255\255\096\001\097\001\255\255\255\255\100\001\ +\255\255\000\000\255\255\255\255\255\255\255\255\255\255\108\001\ +\109\001\060\001\111\001\255\255\255\255\064\001\255\255\066\001\ +\067\001\068\001\255\255\255\255\255\255\255\255\073\001\074\001\ +\255\255\000\001\255\255\255\255\003\001\080\001\255\255\255\255\ +\255\255\008\001\255\255\255\255\255\255\255\255\013\001\255\255\ +\255\255\092\001\255\255\094\001\019\001\096\001\097\001\255\255\ +\255\255\100\001\000\000\026\001\255\255\028\001\029\001\255\255\ +\255\255\108\001\109\001\255\255\111\001\255\255\255\255\255\255\ +\255\255\040\001\041\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\000\001\255\255\060\001\003\001\255\255\ +\063\001\255\255\255\255\066\001\067\001\068\001\255\255\255\255\ +\013\001\255\255\073\001\074\001\255\255\255\255\019\001\000\000\ +\255\255\080\001\255\255\255\255\255\255\026\001\027\001\028\001\ +\029\001\255\255\255\255\255\255\255\255\092\001\255\255\255\255\ +\255\255\096\001\097\001\255\255\041\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\048\001\255\255\108\001\255\255\255\255\ +\111\001\255\255\255\255\255\255\255\255\000\001\255\255\060\001\ +\003\001\255\255\063\001\255\255\255\255\255\255\067\001\068\001\ +\255\255\070\001\013\001\255\255\000\000\074\001\255\255\255\255\ +\019\001\255\255\255\255\080\001\255\255\255\255\255\255\026\001\ +\255\255\028\001\029\001\255\255\255\255\255\255\255\255\092\001\ +\255\255\094\001\255\255\096\001\097\001\040\001\041\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\048\001\049\001\108\001\ +\255\255\255\255\111\001\255\255\255\255\255\255\255\255\000\001\ +\255\255\060\001\003\001\255\255\063\001\255\255\255\255\008\001\ +\255\255\068\001\255\255\070\001\013\001\255\255\255\255\074\001\ +\255\255\255\255\019\001\255\255\255\255\080\001\255\255\255\255\ +\255\255\026\001\255\255\028\001\029\001\255\255\255\255\000\000\ +\255\255\092\001\255\255\255\255\255\255\096\001\097\001\255\255\ +\041\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\108\001\255\255\255\255\111\001\255\255\255\255\255\255\ +\255\255\000\001\255\255\060\001\003\001\255\255\063\001\255\255\ +\255\255\255\255\067\001\068\001\255\255\255\255\013\001\255\255\ +\255\255\074\001\255\255\255\255\019\001\255\255\255\255\080\001\ +\255\255\255\255\255\255\026\001\000\000\028\001\029\001\255\255\ +\255\255\255\255\255\255\092\001\255\255\000\000\255\255\096\001\ +\097\001\255\255\041\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\000\001\108\001\255\255\003\001\111\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\060\001\255\255\013\001\ +\063\001\255\255\255\255\255\255\067\001\068\001\255\255\255\255\ +\255\255\255\255\255\255\074\001\026\001\255\255\028\001\029\001\ +\255\255\080\001\255\255\255\255\255\255\255\255\255\255\000\000\ +\255\255\255\255\040\001\041\001\255\255\092\001\255\255\255\255\ +\255\255\096\001\097\001\255\255\255\255\255\255\255\255\000\001\ +\255\255\255\255\003\001\255\255\255\255\108\001\060\001\255\255\ +\111\001\063\001\255\255\255\255\013\001\067\001\068\001\255\255\ +\255\255\255\255\019\001\255\255\074\001\255\255\255\255\255\255\ +\255\255\026\001\080\001\028\001\029\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\000\000\255\255\092\001\255\255\ +\041\001\255\255\096\001\097\001\255\255\000\000\255\255\255\255\ +\255\255\255\255\255\255\255\255\000\001\255\255\108\001\003\001\ +\255\255\111\001\255\255\060\001\255\255\255\255\063\001\255\255\ +\255\255\013\001\067\001\068\001\255\255\255\255\255\255\019\001\ +\255\255\074\001\255\255\255\255\255\255\255\255\026\001\080\001\ +\028\001\029\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\092\001\255\255\041\001\255\255\096\001\ +\097\001\255\255\000\000\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\108\001\255\255\255\255\111\001\255\255\ +\060\001\255\255\255\255\063\001\255\255\255\255\255\255\067\001\ +\068\001\255\255\255\255\255\255\255\255\255\255\074\001\000\001\ +\255\255\255\255\003\001\255\255\080\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\013\001\255\255\255\255\255\255\ +\092\001\255\255\019\001\255\255\096\001\097\001\255\255\000\000\ +\255\255\026\001\255\255\028\001\029\001\255\255\255\255\255\255\ +\108\001\255\255\255\255\111\001\255\255\255\255\255\255\255\255\ +\041\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\000\001\255\255\255\255\003\001\ +\255\255\255\255\255\255\060\001\255\255\000\001\063\001\255\255\ +\255\255\013\001\067\001\068\001\255\255\008\001\255\255\019\001\ +\000\000\074\001\013\001\255\255\255\255\255\255\026\001\080\001\ +\028\001\029\001\000\000\255\255\255\255\255\255\255\255\026\001\ +\255\255\028\001\029\001\092\001\255\255\041\001\255\255\096\001\ +\097\001\255\255\255\255\255\255\255\255\255\255\041\001\255\255\ +\255\255\255\255\255\255\108\001\255\255\255\255\111\001\000\001\ +\060\001\255\255\003\001\063\001\255\255\255\255\255\255\067\001\ +\068\001\060\001\255\255\255\255\013\001\255\255\074\001\066\001\ +\067\001\068\001\019\001\255\255\080\001\255\255\255\255\074\001\ +\255\255\026\001\255\255\028\001\029\001\080\001\255\255\255\255\ +\092\001\255\255\255\255\000\000\096\001\097\001\255\255\255\255\ +\041\001\092\001\255\255\255\255\255\255\096\001\255\255\255\255\ +\108\001\255\255\255\255\111\001\000\001\255\255\255\255\255\255\ +\255\255\108\001\255\255\060\001\111\001\000\001\063\001\255\255\ +\003\001\013\001\067\001\068\001\255\255\255\255\255\255\255\255\ +\255\255\074\001\013\001\255\255\255\255\255\255\026\001\080\001\ +\028\001\029\001\255\255\255\255\000\000\255\255\255\255\026\001\ +\255\255\028\001\029\001\092\001\255\255\041\001\000\000\096\001\ +\097\001\255\255\255\255\255\255\255\255\040\001\041\001\255\255\ +\255\255\255\255\255\255\108\001\255\255\255\255\111\001\255\255\ +\060\001\255\255\000\001\063\001\255\255\003\001\066\001\067\001\ +\068\001\060\001\255\255\255\255\063\001\255\255\074\001\013\001\ +\255\255\068\001\255\255\255\255\080\001\255\255\255\255\074\001\ +\255\255\255\255\255\255\255\255\026\001\080\001\028\001\029\001\ +\092\001\255\255\255\255\255\255\096\001\097\001\255\255\255\255\ +\255\255\092\001\255\255\041\001\000\000\096\001\097\001\255\255\ +\108\001\255\255\255\255\111\001\255\255\255\255\255\255\000\001\ +\255\255\108\001\003\001\255\255\111\001\255\255\060\001\255\255\ +\255\255\063\001\255\255\255\255\013\001\067\001\068\001\255\255\ +\255\255\255\255\255\255\255\255\074\001\255\255\255\255\255\255\ +\255\255\026\001\080\001\028\001\029\001\255\255\255\255\255\255\ +\000\000\255\255\255\255\255\255\255\255\255\255\092\001\255\255\ +\041\001\000\000\096\001\097\001\255\255\255\255\255\255\255\255\ +\000\001\255\255\255\255\255\255\255\255\255\255\108\001\255\255\ +\008\001\111\001\000\001\060\001\255\255\013\001\063\001\255\255\ +\255\255\255\255\067\001\068\001\255\255\255\255\255\255\013\001\ +\255\255\074\001\026\001\255\255\028\001\029\001\255\255\080\001\ +\255\255\255\255\255\255\255\255\026\001\255\255\028\001\029\001\ +\255\255\041\001\000\000\092\001\255\255\255\255\255\255\096\001\ +\097\001\255\255\255\255\041\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\108\001\060\001\255\255\111\001\063\001\ +\255\255\255\255\255\255\067\001\068\001\255\255\060\001\255\255\ +\255\255\063\001\074\001\000\001\255\255\067\001\068\001\255\255\ +\080\001\255\255\255\255\255\255\074\001\255\255\000\000\255\255\ +\013\001\255\255\080\001\255\255\092\001\255\255\255\255\255\255\ +\096\001\097\001\255\255\255\255\255\255\026\001\092\001\028\001\ +\029\001\255\255\096\001\097\001\108\001\255\255\255\255\111\001\ +\255\255\255\255\255\255\255\255\041\001\255\255\108\001\255\255\ +\255\255\111\001\255\255\255\255\000\001\255\255\255\255\003\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\000\001\060\001\ +\255\255\013\001\063\001\255\255\255\255\255\255\067\001\068\001\ +\255\255\255\255\255\255\013\001\255\255\074\001\026\001\255\255\ +\028\001\029\001\255\255\080\001\255\255\255\255\255\255\255\255\ +\026\001\255\255\028\001\029\001\255\255\041\001\255\255\092\001\ +\255\255\255\255\255\255\096\001\097\001\255\255\255\255\041\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\108\001\ +\060\001\255\255\111\001\063\001\255\255\255\255\255\255\255\255\ +\068\001\255\255\060\001\255\255\000\001\063\001\074\001\255\255\ +\255\255\067\001\068\001\255\255\080\001\255\255\255\255\255\255\ +\074\001\013\001\255\255\255\255\255\255\255\255\080\001\255\255\ +\092\001\255\255\255\255\255\255\096\001\097\001\026\001\255\255\ +\028\001\029\001\092\001\255\255\255\255\255\255\096\001\097\001\ +\108\001\255\255\255\255\111\001\255\255\041\001\255\255\255\255\ +\000\001\255\255\108\001\255\255\255\255\111\001\255\255\255\255\ +\255\255\000\001\255\255\255\255\255\255\013\001\255\255\255\255\ +\060\001\255\255\255\255\063\001\255\255\255\255\013\001\067\001\ +\068\001\255\255\026\001\255\255\028\001\029\001\074\001\255\255\ +\255\255\255\255\255\255\026\001\080\001\028\001\029\001\255\255\ +\255\255\041\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\092\001\255\255\041\001\255\255\096\001\097\001\255\255\255\255\ +\255\255\255\255\000\001\255\255\060\001\255\255\255\255\063\001\ +\108\001\255\255\255\255\111\001\068\001\060\001\255\255\013\001\ +\063\001\255\255\074\001\255\255\255\255\068\001\255\255\255\255\ +\080\001\255\255\255\255\074\001\026\001\255\255\028\001\029\001\ +\255\255\080\001\255\255\255\255\092\001\255\255\255\255\255\255\ +\096\001\097\001\255\255\041\001\255\255\092\001\000\001\255\255\ +\255\255\096\001\097\001\255\255\108\001\255\255\255\255\111\001\ +\255\255\255\255\255\255\013\001\255\255\108\001\060\001\255\255\ +\111\001\063\001\255\255\255\255\255\255\255\255\068\001\255\255\ +\026\001\255\255\028\001\029\001\074\001\255\255\255\255\255\255\ +\255\255\255\255\080\001\255\255\255\255\255\255\255\255\041\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\092\001\255\255\ +\255\255\255\255\096\001\097\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\060\001\255\255\255\255\063\001\108\001\255\255\ +\255\255\111\001\068\001\255\255\255\255\255\255\255\255\255\255\ +\074\001\255\255\255\255\255\255\255\255\255\255\080\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\092\001\000\001\255\255\255\255\096\001\097\001\ +\005\001\006\001\007\001\008\001\255\255\255\255\011\001\012\001\ +\013\001\014\001\108\001\255\255\255\255\111\001\019\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\026\001\255\255\028\001\ +\029\001\030\001\031\001\032\001\033\001\034\001\035\001\255\255\ +\255\255\255\255\039\001\255\255\041\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\048\001\049\001\050\001\051\001\052\001\ +\053\001\054\001\055\001\056\001\255\255\255\255\059\001\060\001\ +\255\255\255\255\063\001\064\001\065\001\066\001\255\255\068\001\ +\069\001\070\001\071\001\072\001\255\255\074\001\255\255\076\001\ +\077\001\078\001\255\255\080\001\081\001\255\255\255\255\084\001\ +\085\001\255\255\087\001\255\255\089\001\090\001\255\255\092\001\ +\093\001\255\255\255\255\096\001\097\001\255\255\099\001\255\255\ +\101\001\102\001\255\255\104\001\255\255\106\001\107\001\108\001\ +\109\001\110\001\111\001\112\001\000\001\114\001\255\255\255\255\ +\255\255\005\001\006\001\007\001\008\001\255\255\255\255\011\001\ +\012\001\255\255\255\255\255\255\255\255\255\255\255\255\019\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\026\001\255\255\ +\028\001\255\255\030\001\031\001\032\001\033\001\034\001\035\001\ +\255\255\255\255\255\255\039\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\048\001\049\001\050\001\051\001\ +\052\001\053\001\054\001\055\001\056\001\255\255\255\255\059\001\ +\060\001\255\255\255\255\063\001\064\001\065\001\255\255\255\255\ +\068\001\069\001\070\001\071\001\072\001\255\255\074\001\255\255\ +\076\001\077\001\078\001\255\255\255\255\081\001\255\255\255\255\ +\084\001\085\001\255\255\087\001\255\255\089\001\090\001\255\255\ +\255\255\093\001\255\255\255\255\255\255\097\001\255\255\099\001\ +\255\255\101\001\102\001\255\255\104\001\255\255\106\001\107\001\ +\255\255\109\001\110\001\111\001\112\001\255\255\114\001\000\001\ +\001\001\002\001\255\255\255\255\005\001\006\001\007\001\255\255\ +\009\001\255\255\011\001\012\001\255\255\255\255\015\001\016\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\027\001\255\255\255\255\030\001\031\001\032\001\ +\033\001\034\001\255\255\036\001\255\255\255\255\039\001\255\255\ +\255\255\042\001\043\001\044\001\045\001\046\001\047\001\255\255\ +\255\255\050\001\255\255\052\001\053\001\054\001\055\001\056\001\ +\255\255\255\255\059\001\255\255\061\001\255\255\063\001\064\001\ +\065\001\255\255\255\255\255\255\069\001\255\255\071\001\072\001\ +\255\255\074\001\255\255\076\001\255\255\078\001\255\255\255\255\ +\255\255\082\001\083\001\084\001\085\001\086\001\087\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\094\001\255\255\255\255\ +\255\255\098\001\255\255\100\001\101\001\255\255\255\255\255\255\ +\255\255\106\001\107\001\255\255\109\001\110\001\000\001\001\001\ +\002\001\114\001\255\255\005\001\006\001\007\001\255\255\009\001\ +\255\255\011\001\012\001\255\255\255\255\015\001\016\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\027\001\255\255\255\255\030\001\031\001\032\001\033\001\ +\034\001\255\255\036\001\255\255\255\255\039\001\255\255\255\255\ +\042\001\043\001\044\001\045\001\046\001\047\001\255\255\255\255\ +\050\001\255\255\052\001\053\001\054\001\055\001\056\001\255\255\ +\255\255\059\001\255\255\061\001\255\255\063\001\064\001\065\001\ +\255\255\255\255\255\255\069\001\255\255\071\001\072\001\255\255\ +\074\001\255\255\076\001\255\255\078\001\255\255\255\255\255\255\ +\082\001\083\001\084\001\085\001\086\001\087\001\255\255\255\255\ +\255\255\255\255\255\255\055\001\094\001\057\001\058\001\059\001\ +\098\001\061\001\100\001\101\001\064\001\065\001\255\255\255\255\ +\106\001\107\001\255\255\109\001\110\001\000\001\255\255\255\255\ +\114\001\255\255\005\001\006\001\007\001\081\001\255\255\255\255\ +\011\001\012\001\013\001\255\255\255\255\089\001\090\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\097\001\255\255\026\001\ +\255\255\028\001\029\001\030\001\031\001\032\001\033\001\034\001\ +\255\255\109\001\110\001\255\255\039\001\255\255\041\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\050\001\ +\255\255\052\001\053\001\054\001\055\001\056\001\255\255\255\255\ +\059\001\060\001\255\255\255\255\063\001\064\001\065\001\255\255\ +\255\255\068\001\069\001\255\255\071\001\072\001\255\255\074\001\ +\255\255\076\001\255\255\078\001\255\255\080\001\255\255\255\255\ +\255\255\084\001\085\001\000\001\087\001\255\255\255\255\255\255\ +\005\001\006\001\007\001\255\255\255\255\096\001\011\001\012\001\ +\255\255\255\255\101\001\255\255\255\255\255\255\255\255\106\001\ +\107\001\108\001\109\001\110\001\111\001\255\255\255\255\114\001\ +\255\255\030\001\031\001\032\001\033\001\034\001\255\255\255\255\ +\255\255\255\255\039\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\050\001\255\255\052\001\ +\053\001\054\001\055\001\056\001\255\255\255\255\059\001\255\255\ +\255\255\255\255\063\001\064\001\065\001\255\255\255\255\255\255\ +\069\001\255\255\071\001\072\001\255\255\255\255\255\255\076\001\ +\255\255\078\001\255\255\255\255\255\255\255\255\255\255\084\001\ +\085\001\000\001\087\001\255\255\255\255\255\255\005\001\006\001\ +\007\001\094\001\255\255\255\255\011\001\012\001\255\255\255\255\ +\101\001\255\255\255\255\255\255\255\255\106\001\107\001\255\255\ +\109\001\110\001\255\255\255\255\255\255\114\001\255\255\030\001\ +\031\001\032\001\033\001\034\001\255\255\255\255\255\255\255\255\ +\039\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\050\001\255\255\052\001\053\001\054\001\ +\055\001\056\001\255\255\255\255\059\001\255\255\255\255\255\255\ +\063\001\064\001\065\001\255\255\255\255\255\255\069\001\255\255\ +\071\001\072\001\255\255\255\255\255\255\076\001\255\255\078\001\ +\255\255\255\255\255\255\255\255\255\255\084\001\085\001\000\001\ +\087\001\255\255\255\255\255\255\005\001\006\001\007\001\094\001\ +\255\255\255\255\011\001\012\001\255\255\255\255\101\001\255\255\ +\255\255\255\255\255\255\106\001\107\001\255\255\109\001\110\001\ +\255\255\255\255\255\255\114\001\255\255\030\001\031\001\032\001\ +\033\001\034\001\255\255\255\255\255\255\255\255\039\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\050\001\255\255\052\001\053\001\054\001\055\001\056\001\ +\255\255\255\255\059\001\255\255\255\255\255\255\063\001\064\001\ +\065\001\255\255\255\255\255\255\069\001\255\255\071\001\072\001\ +\255\255\255\255\255\255\076\001\255\255\078\001\255\255\255\255\ +\255\255\255\255\255\255\084\001\085\001\000\001\087\001\255\255\ +\255\255\255\255\005\001\006\001\007\001\094\001\255\255\255\255\ +\011\001\012\001\255\255\255\255\101\001\255\255\255\255\255\255\ +\255\255\106\001\107\001\255\255\109\001\110\001\255\255\255\255\ +\255\255\114\001\255\255\030\001\031\001\032\001\033\001\034\001\ +\255\255\255\255\255\255\255\255\039\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\050\001\ +\255\255\052\001\053\001\054\001\055\001\056\001\255\255\255\255\ +\059\001\255\255\255\255\255\255\063\001\064\001\065\001\255\255\ +\255\255\255\255\069\001\255\255\071\001\072\001\255\255\255\255\ +\255\255\076\001\255\255\078\001\255\255\255\255\255\255\255\255\ +\255\255\084\001\085\001\255\255\087\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\094\001\003\001\004\001\005\001\255\255\ +\255\255\255\255\101\001\255\255\011\001\255\255\013\001\106\001\ +\107\001\255\255\109\001\110\001\019\001\020\001\021\001\114\001\ +\255\255\024\001\025\001\026\001\255\255\028\001\029\001\030\001\ +\255\255\032\001\033\001\034\001\035\001\255\255\255\255\255\255\ +\039\001\040\001\041\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\048\001\049\001\255\255\255\255\052\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\063\001\064\001\255\255\255\255\255\255\000\001\069\001\070\001\ +\255\255\004\001\255\255\074\001\075\001\076\001\077\001\078\001\ +\079\001\080\001\255\255\082\001\255\255\255\255\017\001\255\255\ +\019\001\088\001\255\255\022\001\255\255\255\255\093\001\026\001\ +\027\001\255\255\255\255\255\255\099\001\255\255\255\255\102\001\ +\103\001\036\001\105\001\106\001\107\001\108\001\109\001\255\255\ +\111\001\112\001\113\001\114\001\115\001\048\001\049\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\060\001\255\255\255\255\255\255\064\001\255\255\066\001\ +\067\001\068\001\255\255\070\001\255\255\255\255\073\001\255\255\ +\255\255\255\255\000\001\001\001\002\001\255\255\255\255\255\255\ +\006\001\007\001\255\255\009\001\255\255\255\255\012\001\090\001\ +\091\001\015\001\016\001\255\255\095\001\255\255\097\001\255\255\ +\255\255\100\001\255\255\255\255\255\255\027\001\028\001\255\255\ +\030\001\031\001\109\001\255\255\111\001\255\255\036\001\255\255\ +\255\255\255\255\255\255\255\255\042\001\043\001\044\001\045\001\ +\046\001\047\001\255\255\255\255\050\001\255\255\052\001\053\001\ +\255\255\055\001\056\001\255\255\255\255\059\001\255\255\061\001\ +\255\255\255\255\064\001\065\001\255\255\255\255\255\255\255\255\ +\255\255\071\001\072\001\255\255\074\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\082\001\083\001\084\001\085\001\ +\086\001\087\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\094\001\255\255\255\255\097\001\098\001\255\255\100\001\101\001\ +\255\255\255\255\255\255\255\255\106\001\255\255\108\001\109\001\ +\110\001\000\001\001\001\002\001\255\255\255\255\255\255\006\001\ +\007\001\255\255\009\001\255\255\255\255\012\001\255\255\255\255\ +\015\001\016\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\027\001\028\001\255\255\030\001\ +\031\001\255\255\255\255\255\255\255\255\036\001\255\255\255\255\ +\255\255\255\255\255\255\042\001\043\001\044\001\045\001\046\001\ +\047\001\255\255\255\255\050\001\255\255\052\001\053\001\255\255\ +\055\001\056\001\255\255\255\255\059\001\255\255\061\001\255\255\ +\255\255\064\001\065\001\255\255\255\255\255\255\255\255\255\255\ +\071\001\072\001\255\255\074\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\082\001\083\001\084\001\085\001\086\001\ +\087\001\255\255\255\255\255\255\255\255\255\255\255\255\094\001\ +\255\255\255\255\097\001\098\001\255\255\100\001\101\001\255\255\ +\255\255\255\255\255\255\106\001\255\255\108\001\109\001\110\001\ +\000\001\001\001\002\001\255\255\255\255\255\255\006\001\007\001\ +\255\255\009\001\255\255\255\255\012\001\255\255\255\255\015\001\ +\016\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\027\001\028\001\255\255\030\001\031\001\ +\255\255\255\255\255\255\255\255\036\001\255\255\255\255\255\255\ +\255\255\255\255\042\001\043\001\044\001\045\001\046\001\047\001\ +\255\255\255\255\050\001\255\255\052\001\053\001\255\255\055\001\ +\056\001\255\255\255\255\059\001\255\255\061\001\255\255\255\255\ +\064\001\065\001\255\255\255\255\255\255\255\255\255\255\071\001\ +\072\001\255\255\074\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\082\001\083\001\084\001\085\001\086\001\087\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\094\001\255\255\ +\255\255\097\001\098\001\255\255\100\001\101\001\255\255\255\255\ +\255\255\255\255\106\001\255\255\108\001\109\001\110\001\000\001\ +\001\001\002\001\255\255\255\255\255\255\006\001\007\001\255\255\ +\009\001\255\255\255\255\012\001\255\255\255\255\015\001\016\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\027\001\028\001\255\255\030\001\031\001\255\255\ +\255\255\255\255\255\255\036\001\255\255\255\255\255\255\255\255\ +\255\255\042\001\043\001\044\001\045\001\046\001\047\001\255\255\ +\255\255\050\001\255\255\052\001\053\001\255\255\055\001\056\001\ +\255\255\255\255\059\001\255\255\061\001\255\255\255\255\064\001\ +\065\001\255\255\255\255\255\255\255\255\255\255\071\001\072\001\ +\255\255\074\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\082\001\083\001\084\001\085\001\086\001\087\001\255\255\ +\255\255\000\001\255\255\255\255\255\255\094\001\255\255\006\001\ +\097\001\098\001\255\255\100\001\101\001\012\001\255\255\255\255\ +\015\001\106\001\255\255\255\255\109\001\110\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\028\001\255\255\030\001\ +\031\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\050\001\255\255\052\001\053\001\255\255\ +\055\001\056\001\255\255\255\255\059\001\255\255\000\001\255\255\ +\255\255\064\001\065\001\255\255\006\001\255\255\255\255\255\255\ +\071\001\255\255\012\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\084\001\255\255\255\255\ +\255\255\255\255\028\001\255\255\030\001\031\001\255\255\094\001\ +\255\255\255\255\097\001\255\255\255\255\255\255\101\001\255\255\ +\255\255\255\255\255\255\106\001\255\255\255\255\109\001\110\001\ +\050\001\255\255\052\001\053\001\255\255\055\001\056\001\255\255\ +\255\255\059\001\255\255\000\001\255\255\255\255\064\001\065\001\ +\255\255\006\001\255\255\255\255\255\255\071\001\255\255\012\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\084\001\255\255\255\255\255\255\255\255\028\001\ +\255\255\030\001\031\001\255\255\255\255\255\255\255\255\097\001\ +\255\255\255\255\255\255\101\001\255\255\255\255\255\255\255\255\ +\106\001\255\255\255\255\109\001\110\001\050\001\255\255\052\001\ +\053\001\255\255\055\001\056\001\255\255\255\255\059\001\255\255\ +\000\001\255\255\255\255\064\001\065\001\255\255\006\001\255\255\ +\255\255\255\255\071\001\255\255\012\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\084\001\ +\255\255\255\255\255\255\255\255\028\001\255\255\030\001\031\001\ +\255\255\255\255\255\255\255\255\097\001\255\255\255\255\255\255\ +\101\001\255\255\255\255\255\255\255\255\106\001\255\255\255\255\ +\109\001\110\001\050\001\255\255\052\001\053\001\255\255\055\001\ +\056\001\255\255\255\255\059\001\255\255\000\001\255\255\255\255\ +\064\001\065\001\255\255\006\001\255\255\255\255\255\255\071\001\ +\255\255\012\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\084\001\255\255\255\255\255\255\ +\255\255\028\001\255\255\030\001\031\001\255\255\255\255\255\255\ +\255\255\097\001\255\255\255\255\255\255\101\001\255\255\255\255\ +\255\255\255\255\106\001\255\255\255\255\109\001\110\001\050\001\ +\255\255\052\001\053\001\255\255\055\001\056\001\255\255\255\255\ +\059\001\255\255\000\001\255\255\255\255\064\001\065\001\255\255\ +\006\001\255\255\255\255\255\255\071\001\255\255\012\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\084\001\255\255\255\255\255\255\255\255\028\001\255\255\ +\030\001\031\001\255\255\255\255\255\255\255\255\097\001\255\255\ +\255\255\255\255\101\001\255\255\255\255\255\255\255\255\106\001\ +\255\255\255\255\109\001\110\001\050\001\255\255\052\001\053\001\ +\255\255\055\001\056\001\255\255\255\255\059\001\255\255\000\001\ +\255\255\255\255\064\001\065\001\255\255\006\001\255\255\255\255\ +\255\255\071\001\255\255\012\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\084\001\255\255\ +\255\255\255\255\255\255\028\001\255\255\030\001\031\001\255\255\ +\255\255\255\255\255\255\097\001\255\255\255\255\255\255\101\001\ +\255\255\255\255\255\255\255\255\106\001\255\255\255\255\109\001\ +\110\001\050\001\255\255\052\001\053\001\255\255\055\001\056\001\ +\255\255\255\255\059\001\255\255\255\255\255\255\255\255\064\001\ +\065\001\005\001\006\001\007\001\255\255\255\255\071\001\011\001\ +\012\001\013\001\014\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\084\001\255\255\255\255\255\255\255\255\ +\028\001\029\001\030\001\031\001\032\001\033\001\034\001\255\255\ +\097\001\255\255\255\255\039\001\101\001\041\001\255\255\255\255\ +\255\255\106\001\255\255\255\255\109\001\110\001\050\001\255\255\ +\052\001\053\001\054\001\055\001\056\001\255\255\255\255\059\001\ +\060\001\255\255\255\255\063\001\064\001\065\001\255\255\255\255\ +\068\001\069\001\255\255\071\001\072\001\255\255\074\001\255\255\ +\076\001\255\255\078\001\255\255\080\001\255\255\255\255\255\255\ +\084\001\085\001\255\255\087\001\255\255\089\001\255\255\255\255\ +\005\001\006\001\007\001\255\255\096\001\255\255\011\001\012\001\ +\013\001\101\001\255\255\255\255\255\255\255\255\106\001\107\001\ +\108\001\109\001\110\001\111\001\255\255\255\255\114\001\028\001\ +\029\001\030\001\031\001\032\001\033\001\034\001\255\255\255\255\ +\255\255\255\255\039\001\255\255\041\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\050\001\255\255\052\001\ +\053\001\054\001\055\001\056\001\255\255\255\255\059\001\060\001\ +\255\255\255\255\063\001\064\001\065\001\255\255\255\255\068\001\ +\069\001\255\255\071\001\072\001\255\255\074\001\255\255\076\001\ +\255\255\078\001\255\255\080\001\255\255\255\255\255\255\084\001\ +\085\001\255\255\087\001\255\255\255\255\255\255\005\001\006\001\ +\007\001\255\255\255\255\096\001\011\001\012\001\255\255\255\255\ +\101\001\255\255\255\255\255\255\255\255\106\001\107\001\108\001\ +\109\001\110\001\111\001\255\255\255\255\114\001\255\255\030\001\ +\031\001\032\001\033\001\034\001\255\255\255\255\255\255\255\255\ +\039\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\050\001\255\255\052\001\053\001\054\001\ +\055\001\056\001\255\255\255\255\059\001\255\255\255\255\255\255\ +\063\001\064\001\065\001\255\255\255\255\255\255\069\001\255\255\ +\071\001\072\001\255\255\255\255\255\255\076\001\255\255\078\001\ +\255\255\255\255\255\255\255\255\255\255\084\001\085\001\255\255\ +\087\001\255\255\255\255\255\255\255\255\092\001\005\001\006\001\ +\007\001\255\255\255\255\010\001\011\001\012\001\101\001\255\255\ +\255\255\255\255\255\255\106\001\107\001\255\255\109\001\110\001\ +\255\255\255\255\255\255\114\001\255\255\255\255\255\255\030\001\ +\031\001\032\001\033\001\034\001\255\255\255\255\255\255\255\255\ +\039\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\050\001\255\255\052\001\053\001\054\001\ +\055\001\056\001\255\255\255\255\059\001\255\255\255\255\255\255\ +\063\001\064\001\065\001\255\255\255\255\255\255\069\001\255\255\ +\071\001\072\001\255\255\255\255\255\255\076\001\255\255\078\001\ +\255\255\255\255\255\255\255\255\255\255\084\001\085\001\255\255\ +\087\001\255\255\255\255\005\001\006\001\007\001\255\255\255\255\ +\255\255\011\001\012\001\255\255\255\255\255\255\101\001\255\255\ +\255\255\255\255\255\255\106\001\107\001\255\255\109\001\110\001\ +\026\001\255\255\255\255\114\001\030\001\031\001\032\001\033\001\ +\034\001\255\255\255\255\255\255\255\255\039\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\050\001\255\255\052\001\053\001\054\001\055\001\056\001\255\255\ +\255\255\059\001\255\255\255\255\255\255\063\001\064\001\065\001\ +\255\255\255\255\255\255\069\001\255\255\071\001\072\001\255\255\ +\255\255\255\255\076\001\255\255\078\001\255\255\255\255\255\255\ +\255\255\255\255\084\001\085\001\255\255\087\001\255\255\255\255\ +\005\001\006\001\007\001\255\255\255\255\255\255\011\001\012\001\ +\255\255\255\255\255\255\101\001\255\255\255\255\255\255\255\255\ +\106\001\107\001\255\255\109\001\110\001\255\255\255\255\255\255\ +\114\001\030\001\031\001\032\001\033\001\034\001\255\255\255\255\ +\255\255\255\255\039\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\050\001\255\255\052\001\ +\053\001\054\001\055\001\056\001\255\255\255\255\059\001\255\255\ +\255\255\255\255\063\001\064\001\065\001\255\255\255\255\255\255\ +\069\001\255\255\071\001\072\001\255\255\255\255\255\255\076\001\ +\255\255\078\001\255\255\255\255\255\255\255\255\083\001\084\001\ +\085\001\255\255\087\001\255\255\255\255\005\001\006\001\007\001\ +\255\255\255\255\255\255\011\001\012\001\255\255\255\255\255\255\ +\101\001\255\255\255\255\255\255\255\255\106\001\107\001\255\255\ +\109\001\110\001\255\255\255\255\255\255\114\001\030\001\031\001\ +\032\001\033\001\034\001\255\255\255\255\255\255\255\255\039\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\050\001\255\255\052\001\053\001\054\001\055\001\ +\056\001\255\255\255\255\059\001\255\255\255\255\255\255\063\001\ +\064\001\065\001\255\255\255\255\255\255\069\001\255\255\071\001\ +\072\001\255\255\255\255\255\255\076\001\255\255\078\001\255\255\ +\255\255\255\255\255\255\255\255\084\001\085\001\255\255\087\001\ +\255\255\255\255\255\255\255\255\092\001\005\001\006\001\007\001\ +\255\255\255\255\010\001\011\001\012\001\101\001\255\255\255\255\ +\255\255\255\255\106\001\107\001\255\255\109\001\110\001\255\255\ +\255\255\255\255\114\001\255\255\255\255\255\255\030\001\031\001\ +\032\001\033\001\034\001\255\255\255\255\255\255\255\255\039\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\050\001\255\255\052\001\053\001\054\001\055\001\ +\056\001\255\255\255\255\059\001\255\255\255\255\255\255\063\001\ +\064\001\065\001\255\255\255\255\255\255\069\001\255\255\071\001\ +\072\001\255\255\255\255\255\255\076\001\255\255\078\001\255\255\ +\255\255\255\255\255\255\255\255\084\001\085\001\255\255\087\001\ +\255\255\255\255\255\255\005\001\006\001\007\001\255\255\255\255\ +\255\255\011\001\012\001\255\255\255\255\101\001\255\255\255\255\ +\255\255\255\255\106\001\107\001\022\001\109\001\110\001\255\255\ +\255\255\255\255\114\001\255\255\030\001\031\001\032\001\033\001\ +\034\001\255\255\255\255\255\255\255\255\039\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\050\001\255\255\052\001\053\001\054\001\055\001\056\001\255\255\ +\255\255\059\001\255\255\255\255\255\255\063\001\064\001\065\001\ +\255\255\255\255\255\255\069\001\255\255\071\001\072\001\255\255\ +\255\255\255\255\076\001\255\255\078\001\255\255\255\255\255\255\ +\255\255\255\255\084\001\085\001\255\255\087\001\255\255\255\255\ +\005\001\006\001\007\001\255\255\255\255\255\255\011\001\012\001\ +\255\255\255\255\255\255\101\001\255\255\255\255\255\255\255\255\ +\106\001\107\001\255\255\109\001\110\001\026\001\255\255\255\255\ +\114\001\030\001\031\001\032\001\033\001\034\001\255\255\255\255\ +\255\255\255\255\039\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\050\001\255\255\052\001\ +\053\001\054\001\055\001\056\001\255\255\255\255\059\001\255\255\ +\255\255\255\255\063\001\064\001\065\001\255\255\255\255\255\255\ +\069\001\255\255\071\001\072\001\255\255\255\255\255\255\076\001\ +\255\255\078\001\255\255\255\255\255\255\255\255\255\255\084\001\ +\085\001\255\255\087\001\255\255\255\255\005\001\006\001\007\001\ +\255\255\255\255\255\255\011\001\012\001\255\255\255\255\255\255\ +\101\001\255\255\255\255\255\255\255\255\106\001\107\001\255\255\ +\109\001\110\001\255\255\255\255\255\255\114\001\030\001\031\001\ +\032\001\033\001\034\001\255\255\255\255\255\255\255\255\039\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\050\001\255\255\052\001\053\001\054\001\055\001\ +\056\001\255\255\255\255\059\001\255\255\255\255\255\255\063\001\ +\064\001\065\001\255\255\255\255\255\255\069\001\255\255\071\001\ +\072\001\255\255\255\255\255\255\076\001\255\255\078\001\255\255\ +\255\255\255\255\255\255\255\255\084\001\085\001\255\255\087\001\ +\255\255\255\255\005\001\006\001\007\001\255\255\255\255\255\255\ +\011\001\012\001\255\255\255\255\255\255\101\001\255\255\255\255\ +\255\255\255\255\106\001\107\001\255\255\109\001\110\001\255\255\ +\255\255\255\255\114\001\030\001\031\001\032\001\033\001\034\001\ +\255\255\255\255\255\255\255\255\039\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\050\001\ +\255\255\052\001\053\001\054\001\055\001\056\001\255\255\255\255\ +\059\001\255\255\255\255\255\255\063\001\064\001\065\001\255\255\ +\255\255\255\255\069\001\255\255\071\001\072\001\255\255\255\255\ +\255\255\076\001\255\255\078\001\255\255\255\255\255\255\255\255\ +\255\255\084\001\085\001\255\255\087\001\255\255\255\255\005\001\ +\006\001\007\001\255\255\255\255\255\255\011\001\012\001\255\255\ +\255\255\255\255\101\001\255\255\255\255\255\255\255\255\106\001\ +\107\001\255\255\109\001\110\001\255\255\255\255\255\255\114\001\ +\030\001\031\001\032\001\033\001\034\001\255\255\255\255\255\255\ +\255\255\039\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\050\001\255\255\052\001\053\001\ +\054\001\055\001\056\001\255\255\255\255\059\001\255\255\255\255\ +\255\255\063\001\064\001\065\001\255\255\255\255\255\255\069\001\ +\255\255\071\001\072\001\255\255\255\255\006\001\076\001\255\255\ +\078\001\255\255\255\255\012\001\255\255\014\001\084\001\085\001\ +\017\001\087\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\027\001\255\255\255\255\030\001\031\001\101\001\ +\255\255\255\255\255\255\255\255\106\001\107\001\255\255\109\001\ +\110\001\255\255\255\255\255\255\114\001\255\255\255\255\255\255\ +\255\255\050\001\051\001\255\255\053\001\255\255\055\001\056\001\ +\255\255\255\255\059\001\255\255\255\255\255\255\255\255\064\001\ +\065\001\255\255\006\001\255\255\255\255\255\255\071\001\255\255\ +\012\001\255\255\014\001\255\255\255\255\017\001\255\255\255\255\ +\081\001\255\255\255\255\084\001\255\255\255\255\255\255\027\001\ +\089\001\255\255\030\001\031\001\255\255\006\001\255\255\255\255\ +\097\001\255\255\255\255\012\001\101\001\014\001\255\255\104\001\ +\255\255\106\001\255\255\255\255\109\001\110\001\050\001\051\001\ +\255\255\053\001\255\255\055\001\056\001\030\001\031\001\059\001\ +\255\255\255\255\255\255\255\255\064\001\065\001\255\255\255\255\ +\255\255\255\255\255\255\071\001\255\255\255\255\255\255\255\255\ +\255\255\050\001\051\001\255\255\053\001\081\001\055\001\056\001\ +\084\001\255\255\059\001\255\255\255\255\089\001\255\255\064\001\ +\065\001\255\255\255\255\255\255\255\255\097\001\071\001\255\255\ +\073\001\101\001\255\255\255\255\104\001\255\255\106\001\255\255\ +\081\001\109\001\110\001\084\001\255\255\255\255\006\001\255\255\ +\089\001\255\255\255\255\255\255\012\001\255\255\014\001\255\255\ +\097\001\255\255\255\255\255\255\101\001\255\255\255\255\104\001\ +\255\255\106\001\255\255\027\001\109\001\110\001\030\001\031\001\ +\255\255\006\001\255\255\255\255\255\255\255\255\255\255\012\001\ +\255\255\014\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\050\001\051\001\255\255\053\001\027\001\055\001\ +\056\001\030\001\031\001\059\001\255\255\255\255\255\255\255\255\ +\064\001\065\001\255\255\255\255\255\255\255\255\255\255\071\001\ +\255\255\255\255\255\255\255\255\255\255\050\001\051\001\255\255\ +\053\001\081\001\055\001\056\001\084\001\255\255\059\001\255\255\ +\255\255\089\001\255\255\064\001\065\001\255\255\006\001\255\255\ +\255\255\097\001\071\001\255\255\012\001\101\001\255\255\255\255\ +\104\001\255\255\106\001\255\255\081\001\109\001\110\001\084\001\ +\255\255\255\255\255\255\255\255\089\001\255\255\030\001\031\001\ +\255\255\006\001\255\255\255\255\097\001\255\255\255\255\012\001\ +\101\001\255\255\255\255\104\001\255\255\106\001\255\255\255\255\ +\109\001\110\001\050\001\051\001\255\255\053\001\255\255\055\001\ +\056\001\030\001\031\001\059\001\255\255\255\255\255\255\255\255\ +\064\001\065\001\255\255\255\255\255\255\255\255\255\255\071\001\ +\255\255\073\001\255\255\255\255\255\255\050\001\051\001\255\255\ +\053\001\081\001\055\001\056\001\084\001\255\255\059\001\255\255\ +\255\255\089\001\255\255\064\001\065\001\255\255\006\001\255\255\ +\255\255\097\001\071\001\255\255\012\001\101\001\255\255\255\255\ +\104\001\255\255\106\001\255\255\081\001\109\001\110\001\084\001\ +\255\255\255\255\255\255\255\255\089\001\255\255\030\001\031\001\ +\255\255\006\001\255\255\255\255\097\001\255\255\255\255\012\001\ +\101\001\255\255\255\255\104\001\255\255\106\001\255\255\255\255\ +\109\001\110\001\050\001\051\001\255\255\053\001\255\255\055\001\ +\056\001\030\001\031\001\059\001\255\255\255\255\255\255\255\255\ +\064\001\065\001\255\255\255\255\255\255\255\255\255\255\071\001\ +\255\255\255\255\255\255\255\255\255\255\050\001\051\001\255\255\ +\053\001\081\001\055\001\056\001\084\001\255\255\059\001\255\255\ +\255\255\089\001\255\255\064\001\065\001\255\255\006\001\255\255\ +\255\255\097\001\071\001\255\255\012\001\101\001\255\255\255\255\ +\104\001\255\255\106\001\255\255\081\001\109\001\110\001\084\001\ +\255\255\255\255\255\255\255\255\089\001\255\255\030\001\031\001\ +\255\255\255\255\255\255\255\255\097\001\255\255\255\255\255\255\ +\101\001\255\255\255\255\104\001\255\255\106\001\255\255\255\255\ +\109\001\110\001\050\001\051\001\255\255\053\001\255\255\055\001\ +\056\001\255\255\255\255\059\001\255\255\255\255\255\255\255\255\ +\064\001\065\001\255\255\255\255\006\001\255\255\255\255\071\001\ +\255\255\255\255\012\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\081\001\255\255\255\255\084\001\255\255\255\255\255\255\ +\255\255\089\001\028\001\255\255\030\001\031\001\255\255\255\255\ +\255\255\097\001\255\255\255\255\255\255\101\001\255\255\255\255\ +\104\001\255\255\106\001\255\255\255\255\109\001\110\001\255\255\ +\050\001\255\255\052\001\053\001\255\255\055\001\056\001\255\255\ +\255\255\059\001\255\255\255\255\255\255\255\255\064\001\065\001\ +\255\255\255\255\255\255\006\001\255\255\071\001\255\255\010\001\ +\255\255\012\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\084\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\028\001\092\001\030\001\031\001\255\255\255\255\097\001\ +\255\255\255\255\255\255\101\001\255\255\255\255\255\255\255\255\ +\106\001\255\255\255\255\109\001\110\001\255\255\255\255\050\001\ +\255\255\052\001\053\001\255\255\055\001\056\001\255\255\255\255\ +\059\001\255\255\255\255\255\255\255\255\064\001\065\001\255\255\ +\006\001\255\255\255\255\255\255\071\001\255\255\012\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\006\001\007\001\255\255\ +\255\255\084\001\011\001\012\001\255\255\255\255\028\001\255\255\ +\030\001\031\001\255\255\255\255\255\255\255\255\097\001\255\255\ +\255\255\255\255\101\001\255\255\255\255\030\001\031\001\106\001\ +\255\255\255\255\109\001\110\001\050\001\255\255\052\001\053\001\ +\255\255\055\001\056\001\255\255\255\255\059\001\255\255\255\255\ +\255\255\050\001\064\001\065\001\053\001\054\001\055\001\056\001\ +\255\255\071\001\059\001\255\255\006\001\255\255\008\001\064\001\ +\065\001\255\255\012\001\255\255\255\255\255\255\084\001\255\255\ +\255\255\255\255\255\255\076\001\255\255\255\255\092\001\255\255\ +\255\255\255\255\028\001\097\001\030\001\031\001\087\001\101\001\ +\255\255\255\255\255\255\255\255\106\001\255\255\255\255\109\001\ +\110\001\255\255\255\255\255\255\101\001\255\255\255\255\255\255\ +\050\001\106\001\052\001\053\001\109\001\055\001\056\001\255\255\ +\255\255\059\001\255\255\255\255\255\255\255\255\064\001\065\001\ +\255\255\006\001\255\255\255\255\255\255\071\001\255\255\012\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\084\001\255\255\255\255\255\255\255\255\028\001\ +\255\255\030\001\031\001\255\255\255\255\255\255\255\255\097\001\ +\255\255\255\255\255\255\101\001\255\255\255\255\255\255\255\255\ +\106\001\255\255\255\255\109\001\110\001\050\001\255\255\052\001\ +\053\001\255\255\055\001\056\001\255\255\255\255\059\001\255\255\ +\255\255\255\255\255\255\064\001\065\001\255\255\006\001\255\255\ +\255\255\255\255\071\001\255\255\012\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\084\001\ +\255\255\255\255\255\255\255\255\028\001\255\255\030\001\031\001\ +\255\255\006\001\255\255\255\255\097\001\255\255\255\255\012\001\ +\101\001\255\255\255\255\255\255\255\255\106\001\255\255\255\255\ +\109\001\110\001\050\001\255\255\052\001\053\001\255\255\055\001\ +\056\001\030\001\031\001\059\001\255\255\255\255\255\255\255\255\ +\064\001\065\001\255\255\255\255\255\255\255\255\255\255\071\001\ +\255\255\255\255\255\255\255\255\255\255\050\001\255\255\052\001\ +\053\001\255\255\055\001\056\001\084\001\255\255\059\001\255\255\ +\255\255\255\255\255\255\064\001\065\001\255\255\006\001\255\255\ +\255\255\097\001\071\001\255\255\012\001\101\001\255\255\255\255\ +\255\255\255\255\106\001\255\255\255\255\109\001\110\001\084\001\ +\255\255\255\255\255\255\255\255\028\001\255\255\030\001\031\001\ +\093\001\006\001\255\255\255\255\097\001\255\255\255\255\012\001\ +\101\001\255\255\255\255\255\255\255\255\106\001\255\255\255\255\ +\109\001\110\001\050\001\255\255\052\001\053\001\255\255\055\001\ +\056\001\030\001\031\001\059\001\255\255\255\255\255\255\255\255\ +\064\001\065\001\255\255\255\255\255\255\255\255\255\255\071\001\ +\255\255\255\255\255\255\255\255\255\255\050\001\255\255\052\001\ +\053\001\255\255\055\001\056\001\084\001\255\255\059\001\255\255\ +\255\255\255\255\255\255\064\001\065\001\255\255\006\001\255\255\ +\255\255\097\001\071\001\255\255\012\001\101\001\255\255\255\255\ +\255\255\255\255\106\001\255\255\255\255\109\001\110\001\084\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\030\001\031\001\ +\255\255\006\001\255\255\255\255\097\001\255\255\255\255\012\001\ +\101\001\255\255\255\255\255\255\255\255\106\001\255\255\255\255\ +\109\001\110\001\050\001\255\255\052\001\053\001\255\255\055\001\ +\056\001\030\001\031\001\059\001\255\255\255\255\255\255\255\255\ +\064\001\065\001\255\255\255\255\255\255\255\255\255\255\071\001\ +\255\255\255\255\255\255\255\255\255\255\050\001\255\255\052\001\ +\053\001\255\255\055\001\056\001\084\001\255\255\059\001\255\255\ +\255\255\255\255\255\255\064\001\065\001\255\255\006\001\255\255\ +\255\255\097\001\071\001\255\255\012\001\101\001\255\255\255\255\ +\255\255\255\255\106\001\255\255\255\255\109\001\110\001\084\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\030\001\031\001\ +\255\255\006\001\255\255\255\255\097\001\255\255\255\255\012\001\ +\101\001\255\255\255\255\255\255\255\255\106\001\255\255\255\255\ +\109\001\110\001\050\001\255\255\255\255\053\001\255\255\055\001\ +\056\001\030\001\031\001\059\001\255\255\255\255\255\255\255\255\ +\064\001\065\001\255\255\255\255\255\255\255\255\255\255\071\001\ +\255\255\255\255\255\255\255\255\255\255\050\001\255\255\255\255\ +\053\001\255\255\055\001\056\001\084\001\255\255\059\001\255\255\ +\255\255\255\255\255\255\064\001\065\001\255\255\255\255\255\255\ +\255\255\097\001\071\001\255\255\255\255\101\001\006\001\007\001\ +\255\255\255\255\106\001\011\001\012\001\109\001\110\001\084\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\022\001\255\255\ +\255\255\255\255\255\255\255\255\097\001\255\255\030\001\031\001\ +\101\001\255\255\255\255\255\255\255\255\106\001\255\255\255\255\ +\109\001\110\001\255\255\255\255\255\255\255\255\255\255\047\001\ +\255\255\255\255\050\001\051\001\255\255\053\001\054\001\055\001\ +\056\001\255\255\255\255\059\001\255\255\255\255\255\255\255\255\ +\064\001\065\001\006\001\007\001\255\255\255\255\255\255\011\001\ +\012\001\255\255\255\255\255\255\076\001\255\255\255\255\255\255\ +\255\255\081\001\255\255\255\255\255\255\255\255\255\255\087\001\ +\255\255\089\001\030\001\031\001\255\255\255\255\255\255\255\255\ +\255\255\097\001\098\001\255\255\255\255\101\001\255\255\255\255\ +\104\001\255\255\106\001\255\255\255\255\109\001\050\001\051\001\ +\255\255\053\001\054\001\055\001\056\001\255\255\255\255\059\001\ +\255\255\255\255\255\255\255\255\064\001\065\001\006\001\007\001\ +\255\255\255\255\255\255\011\001\012\001\006\001\007\001\255\255\ +\076\001\255\255\011\001\012\001\255\255\081\001\255\255\255\255\ +\255\255\255\255\255\255\087\001\255\255\089\001\030\001\031\001\ +\255\255\255\255\255\255\255\255\255\255\030\001\031\001\255\255\ +\255\255\101\001\255\255\255\255\104\001\255\255\106\001\255\255\ +\255\255\109\001\050\001\255\255\255\255\053\001\054\001\055\001\ +\056\001\050\001\255\255\059\001\053\001\054\001\055\001\056\001\ +\064\001\065\001\059\001\255\255\255\255\255\255\008\001\064\001\ +\065\001\255\255\255\255\255\255\076\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\076\001\255\255\023\001\255\255\087\001\ +\255\255\255\255\255\255\255\255\030\001\255\255\087\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\101\001\255\255\255\255\ +\255\255\255\255\106\001\255\255\101\001\109\001\255\255\255\255\ +\255\255\106\001\255\255\255\255\109\001\055\001\255\255\057\001\ +\058\001\059\001\255\255\061\001\255\255\255\255\064\001\065\001\ +\255\255\255\255\255\255\000\001\001\001\002\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\009\001\255\255\255\255\081\001\ +\255\255\014\001\015\001\016\001\017\001\018\001\088\001\089\001\ +\090\001\255\255\255\255\255\255\255\255\255\255\027\001\097\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\036\001\ +\106\001\255\255\255\255\109\001\110\001\042\001\043\001\044\001\ +\045\001\046\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\061\001\255\255\255\255\255\255\255\255\066\001\255\255\255\255\ +\255\255\255\255\071\001\072\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\082\001\083\001\084\001\ +\085\001\086\001\255\255\000\001\001\001\002\001\255\255\255\255\ +\255\255\094\001\007\001\255\255\009\001\255\255\255\255\100\001\ +\255\255\255\255\055\001\016\001\057\001\058\001\059\001\255\255\ +\061\001\255\255\255\255\064\001\065\001\255\255\027\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\036\001\ +\255\255\255\255\255\255\255\255\081\001\042\001\043\001\044\001\ +\045\001\046\001\047\001\255\255\089\001\090\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\097\001\255\255\255\255\255\255\ +\061\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\109\001\110\001\071\001\072\001\255\255\074\001\255\255\255\255\ +\255\255\255\255\000\001\001\001\002\001\082\001\083\001\084\001\ +\085\001\086\001\087\001\009\001\255\255\255\255\255\255\255\255\ +\255\255\015\001\016\001\255\255\018\001\098\001\255\255\100\001\ +\255\255\255\255\255\255\255\255\255\255\027\001\255\255\255\255\ +\255\255\255\255\000\001\001\001\002\001\255\255\036\001\255\255\ +\255\255\255\255\255\255\009\001\042\001\043\001\044\001\045\001\ +\046\001\015\001\016\001\255\255\018\001\255\255\255\255\255\255\ +\055\001\255\255\057\001\058\001\059\001\027\001\061\001\061\001\ +\255\255\064\001\065\001\255\255\066\001\255\255\036\001\255\255\ +\255\255\071\001\072\001\255\255\042\001\043\001\044\001\045\001\ +\046\001\255\255\081\001\255\255\082\001\083\001\084\001\085\001\ +\086\001\255\255\089\001\090\001\255\255\091\001\255\255\061\001\ +\255\255\255\255\097\001\255\255\066\001\255\255\100\001\255\255\ +\255\255\071\001\072\001\255\255\255\255\255\255\109\001\110\001\ +\000\001\001\001\002\001\255\255\082\001\083\001\084\001\085\001\ +\086\001\009\001\255\255\255\255\255\255\255\255\092\001\015\001\ +\016\001\255\255\018\001\255\255\255\255\255\255\100\001\255\255\ +\255\255\255\255\255\255\027\001\255\255\255\255\255\255\255\255\ +\000\001\001\001\002\001\255\255\036\001\255\255\255\255\255\255\ +\255\255\009\001\042\001\043\001\044\001\045\001\046\001\015\001\ +\016\001\255\255\018\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\027\001\255\255\061\001\255\255\255\255\ +\255\255\255\255\066\001\255\255\036\001\255\255\255\255\071\001\ +\072\001\255\255\042\001\043\001\044\001\045\001\046\001\255\255\ +\255\255\255\255\082\001\083\001\084\001\085\001\086\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\061\001\094\001\255\255\ +\255\255\255\255\066\001\255\255\100\001\255\255\255\255\071\001\ +\072\001\255\255\255\255\255\255\255\255\255\255\000\001\001\001\ +\002\001\255\255\082\001\083\001\084\001\085\001\086\001\009\001\ +\255\255\255\255\255\255\091\001\255\255\015\001\016\001\255\255\ +\018\001\255\255\255\255\255\255\100\001\255\255\255\255\255\255\ +\255\255\027\001\255\255\255\255\255\255\255\255\000\001\001\001\ +\002\001\255\255\036\001\255\255\255\255\255\255\255\255\009\001\ +\042\001\043\001\044\001\045\001\046\001\015\001\016\001\255\255\ +\018\001\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\027\001\255\255\061\001\255\255\255\255\255\255\255\255\ +\066\001\255\255\036\001\255\255\255\255\071\001\072\001\255\255\ +\042\001\043\001\044\001\045\001\046\001\255\255\255\255\255\255\ +\082\001\083\001\084\001\085\001\086\001\255\255\255\255\255\255\ +\255\255\255\255\092\001\061\001\255\255\255\255\255\255\255\255\ +\066\001\255\255\100\001\255\255\255\255\071\001\072\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\082\001\083\001\084\001\085\001\086\001\000\001\001\001\002\001\ +\255\255\255\255\255\255\255\255\094\001\255\255\009\001\255\255\ +\255\255\255\255\100\001\255\255\015\001\016\001\255\255\018\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\027\001\255\255\255\255\255\255\255\255\000\001\001\001\002\001\ +\255\255\036\001\255\255\255\255\255\255\255\255\009\001\042\001\ +\043\001\044\001\045\001\046\001\015\001\016\001\255\255\018\001\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\027\001\255\255\061\001\255\255\255\255\255\255\255\255\066\001\ +\255\255\036\001\255\255\255\255\071\001\072\001\255\255\042\001\ +\043\001\044\001\045\001\046\001\255\255\255\255\255\255\082\001\ +\083\001\084\001\085\001\086\001\255\255\255\255\255\255\255\255\ +\091\001\255\255\061\001\255\255\255\255\255\255\255\255\066\001\ +\255\255\100\001\255\255\255\255\071\001\072\001\255\255\255\255\ +\255\255\255\255\255\255\000\001\001\001\002\001\255\255\082\001\ +\083\001\084\001\085\001\086\001\009\001\255\255\255\255\255\255\ +\255\255\092\001\015\001\016\001\255\255\018\001\255\255\255\255\ +\255\255\100\001\255\255\255\255\255\255\255\255\027\001\255\255\ +\255\255\255\255\255\255\000\001\001\001\002\001\255\255\036\001\ +\255\255\255\255\255\255\255\255\009\001\042\001\043\001\044\001\ +\045\001\046\001\015\001\016\001\255\255\018\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\027\001\255\255\ +\061\001\255\255\255\255\255\255\255\255\066\001\255\255\036\001\ +\255\255\255\255\071\001\072\001\255\255\042\001\043\001\044\001\ +\045\001\046\001\255\255\255\255\255\255\082\001\083\001\084\001\ +\085\001\086\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\061\001\094\001\255\255\255\255\255\255\066\001\255\255\100\001\ +\255\255\255\255\071\001\072\001\255\255\255\255\255\255\255\255\ +\255\255\000\001\001\001\002\001\255\255\082\001\083\001\084\001\ +\085\001\086\001\009\001\255\255\255\255\255\255\091\001\255\255\ +\015\001\016\001\255\255\018\001\255\255\255\255\255\255\100\001\ +\255\255\255\255\255\255\255\255\027\001\255\255\255\255\255\255\ +\255\255\000\001\001\001\002\001\255\255\036\001\255\255\255\255\ +\255\255\255\255\009\001\042\001\043\001\044\001\045\001\046\001\ +\015\001\016\001\255\255\018\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\027\001\255\255\061\001\255\255\ +\255\255\255\255\255\255\066\001\255\255\036\001\255\255\255\255\ +\071\001\072\001\255\255\042\001\043\001\044\001\045\001\046\001\ +\255\255\255\255\255\255\082\001\083\001\084\001\085\001\086\001\ +\255\255\255\255\255\255\255\255\255\255\092\001\061\001\001\001\ +\002\001\255\255\255\255\066\001\255\255\100\001\255\255\009\001\ +\071\001\072\001\255\255\255\255\255\255\015\001\016\001\255\255\ +\018\001\255\255\255\255\082\001\083\001\084\001\085\001\086\001\ +\255\255\027\001\255\255\255\255\255\255\255\255\255\255\094\001\ +\255\255\255\255\036\001\255\255\255\255\100\001\255\255\255\255\ +\042\001\043\001\044\001\045\001\046\001\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\061\001\001\001\002\001\255\255\255\255\ +\066\001\255\255\255\255\255\255\009\001\071\001\072\001\255\255\ +\255\255\255\255\015\001\016\001\255\255\018\001\255\255\255\255\ +\082\001\083\001\084\001\085\001\086\001\255\255\027\001\255\255\ +\255\255\255\255\255\255\255\255\255\255\095\001\255\255\036\001\ +\255\255\255\255\100\001\255\255\255\255\042\001\043\001\044\001\ +\045\001\046\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\061\001\001\001\002\001\255\255\255\255\066\001\255\255\255\255\ +\255\255\009\001\071\001\072\001\255\255\255\255\255\255\015\001\ +\016\001\255\255\018\001\255\255\255\255\082\001\083\001\084\001\ +\085\001\086\001\255\255\027\001\255\255\255\255\091\001\255\255\ +\255\255\001\001\002\001\255\255\036\001\255\255\255\255\100\001\ +\255\255\009\001\042\001\043\001\044\001\045\001\046\001\015\001\ +\016\001\255\255\018\001\255\255\255\255\255\255\255\255\255\255\ +\255\255\025\001\255\255\027\001\255\255\061\001\255\255\255\255\ +\255\255\255\255\066\001\255\255\036\001\255\255\255\255\071\001\ +\072\001\255\255\042\001\043\001\044\001\045\001\046\001\255\255\ +\255\255\255\255\082\001\083\001\084\001\085\001\086\001\255\255\ +\255\255\255\255\255\255\091\001\255\255\061\001\001\001\002\001\ +\255\255\255\255\066\001\255\255\100\001\255\255\009\001\071\001\ +\072\001\255\255\255\255\255\255\015\001\016\001\255\255\018\001\ +\255\255\255\255\082\001\083\001\084\001\085\001\086\001\255\255\ +\027\001\255\255\255\255\255\255\255\255\255\255\001\001\002\001\ +\255\255\036\001\255\255\255\255\100\001\255\255\009\001\042\001\ +\043\001\044\001\045\001\046\001\015\001\016\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\027\001\255\255\061\001\255\255\255\255\255\255\255\255\066\001\ +\255\255\036\001\255\255\255\255\071\001\072\001\255\255\042\001\ +\043\001\044\001\045\001\046\001\255\255\255\255\255\255\082\001\ +\083\001\084\001\085\001\086\001\255\255\255\255\255\255\255\255\ +\255\255\255\255\061\001\001\001\002\001\255\255\255\255\066\001\ +\255\255\100\001\255\255\009\001\071\001\072\001\255\255\255\255\ +\255\255\015\001\255\255\255\255\255\255\255\255\255\255\082\001\ +\083\001\084\001\085\001\086\001\255\255\027\001\255\255\255\255\ +\091\001\255\255\255\255\001\001\002\001\255\255\036\001\255\255\ +\255\255\100\001\255\255\255\255\042\001\043\001\044\001\045\001\ +\046\001\015\001\255\255\255\255\255\255\255\255\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\027\001\255\255\061\001\ +\255\255\255\255\255\255\255\255\066\001\255\255\036\001\255\255\ +\255\255\071\001\072\001\255\255\042\001\043\001\044\001\045\001\ +\046\001\013\001\255\255\255\255\082\001\083\001\084\001\085\001\ +\086\001\255\255\255\255\255\255\255\255\255\255\255\255\061\001\ +\028\001\029\001\255\255\255\255\066\001\255\255\100\001\255\255\ +\255\255\071\001\072\001\255\255\255\255\041\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\083\001\084\001\085\001\ +\086\001\255\255\255\255\055\001\255\255\057\001\058\001\059\001\ +\060\001\061\001\255\255\255\255\064\001\065\001\100\001\255\255\ +\068\001\255\255\255\255\255\255\255\255\255\255\074\001\255\255\ +\255\255\255\255\255\255\255\255\080\001\081\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\089\001\090\001\255\255\ +\255\255\255\255\255\255\255\255\096\001\097\001\255\255\255\255\ +\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ +\108\001\109\001\110\001\111\001" -let magic_sep_char = '\n' -(* - Reasons that we don't [output_value] the set: - 1. for performance , easy skipping and calcuate the length - 2. cut dependency, otherwise its type is {!Ast_extract.String_set.t} -*) -let write_ast (type t) ~(sourcefile : string) ~output (kind : t Ml_binary.kind) ( pt : t) : unit = - let oc = open_out_bin output in - let output_set = Ast_extract.read_parse_and_extract kind pt in - let buf = Ext_buffer.create 1000 in +let yynames_const = "\ + AMPERAMPER\000\ + AMPERSAND\000\ + AND\000\ + AS\000\ + ASSERT\000\ + BACKQUOTE\000\ + BANG\000\ + BAR\000\ + BARBAR\000\ + BARRBRACKET\000\ + BEGIN\000\ + CLASS\000\ + COLON\000\ + COLONCOLON\000\ + COLONEQUAL\000\ + COLONGREATER\000\ + COMMA\000\ + CONSTRAINT\000\ + DO\000\ + DONE\000\ + DOT\000\ + DOTDOT\000\ + DOWNTO\000\ + ELSE\000\ + END\000\ + EOF\000\ + EQUAL\000\ + EXCEPTION\000\ + EXTERNAL\000\ + FALSE\000\ + FOR\000\ + FUN\000\ + FUNCTION\000\ + FUNCTOR\000\ + GREATER\000\ + GREATERRBRACE\000\ + GREATERRBRACKET\000\ + IF\000\ + IN\000\ + INCLUDE\000\ + INHERIT\000\ + INITIALIZER\000\ + LAZY\000\ + LBRACE\000\ + LBRACELESS\000\ + LBRACKET\000\ + LBRACKETBAR\000\ + LBRACKETLESS\000\ + LBRACKETGREATER\000\ + LBRACKETPERCENT\000\ + LBRACKETPERCENTPERCENT\000\ + LESS\000\ + LESSMINUS\000\ + LET\000\ + LPAREN\000\ + LBRACKETAT\000\ + LBRACKETATAT\000\ + LBRACKETATATAT\000\ + MATCH\000\ + METHOD\000\ + MINUS\000\ + MINUSDOT\000\ + MINUSGREATER\000\ + MODULE\000\ + MUTABLE\000\ + NEW\000\ + NONREC\000\ + OBJECT\000\ + OF\000\ + OPEN\000\ + OR\000\ + PERCENT\000\ + PLUS\000\ + PLUSDOT\000\ + PLUSEQ\000\ + PRIVATE\000\ + QUESTION\000\ + QUOTE\000\ + RBRACE\000\ + RBRACKET\000\ + REC\000\ + RPAREN\000\ + SEMI\000\ + SEMISEMI\000\ + HASH\000\ + SIG\000\ + STAR\000\ + STRUCT\000\ + THEN\000\ + TILDE\000\ + TO\000\ + TRUE\000\ + TRY\000\ + TYPE\000\ + UNDERSCORE\000\ + VAL\000\ + VIRTUAL\000\ + WHEN\000\ + WHILE\000\ + WITH\000\ + EOL\000\ + " - Ext_buffer.add_char buf magic_sep_char; - String_set.iter (fun s -> - if s <> "" && s.[0] <> '*' then begin (* filter *predef* *) - Ext_buffer.add_string_char buf s magic_sep_char; - end - ) output_set ; - output_binary_int oc (Ext_buffer.length buf); - Ext_buffer.output_buffer oc buf; - Ml_binary.write_ast kind sourcefile pt oc; - close_out oc +let yynames_block = "\ + CHAR\000\ + FLOAT\000\ + INFIXOP0\000\ + INFIXOP1\000\ + INFIXOP2\000\ + INFIXOP3\000\ + INFIXOP4\000\ + DOTOP\000\ + INT\000\ + LABEL\000\ + LIDENT\000\ + OPTLABEL\000\ + PREFIXOP\000\ + HASHOP\000\ + STRING\000\ + UIDENT\000\ + COMMENT\000\ + DOCSTRING\000\ + " +let yyact = [| + (fun _ -> failwith "parser") +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'structure) in + Obj.repr( +# 630 "parsing/parser.mly" + ( extra_str 1 _1 ) +# 7030 "parsing/parser.ml" + : Parsetree.structure)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'signature) in + Obj.repr( +# 633 "parsing/parser.mly" + ( extra_sig 1 _1 ) +# 7037 "parsing/parser.ml" + : Parsetree.signature)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'top_structure) in + Obj.repr( +# 636 "parsing/parser.mly" + ( Ptop_def (extra_str 1 _1) ) +# 7044 "parsing/parser.ml" + : Parsetree.toplevel_phrase)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'toplevel_directive) in + Obj.repr( +# 637 "parsing/parser.mly" + ( _1 ) +# 7051 "parsing/parser.ml" + : Parsetree.toplevel_phrase)) +; (fun __caml_parser_env -> + Obj.repr( +# 638 "parsing/parser.mly" + ( raise End_of_file ) +# 7057 "parsing/parser.ml" + : Parsetree.toplevel_phrase)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 642 "parsing/parser.mly" + ( (text_str 1) @ [mkstrexp _1 _2] ) +# 7065 "parsing/parser.ml" + : 'top_structure)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'top_structure_tail) in + Obj.repr( +# 644 "parsing/parser.mly" + ( _1 ) +# 7072 "parsing/parser.ml" + : 'top_structure)) +; (fun __caml_parser_env -> + Obj.repr( +# 647 "parsing/parser.mly" + ( [] ) +# 7078 "parsing/parser.ml" + : 'top_structure_tail)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'structure_item) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'top_structure_tail) in + Obj.repr( +# 648 "parsing/parser.mly" + ( (text_str 1) @ _1 :: _2 ) +# 7086 "parsing/parser.ml" + : 'top_structure_tail)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'use_file_body) in + Obj.repr( +# 651 "parsing/parser.mly" + ( extra_def 1 _1 ) +# 7093 "parsing/parser.ml" + : Parsetree.toplevel_phrase list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'use_file_tail) in + Obj.repr( +# 654 "parsing/parser.mly" + ( _1 ) +# 7100 "parsing/parser.ml" + : 'use_file_body)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'seq_expr) in + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'post_item_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'use_file_tail) in + Obj.repr( +# 656 "parsing/parser.mly" + ( (text_def 1) @ Ptop_def[mkstrexp _1 _2] :: _3 ) +# 7109 "parsing/parser.ml" + : 'use_file_body)) +; (fun __caml_parser_env -> + Obj.repr( +# 660 "parsing/parser.mly" + ( [] ) +# 7115 "parsing/parser.ml" + : 'use_file_tail)) +; (fun __caml_parser_env -> + Obj.repr( +# 662 "parsing/parser.mly" + ( text_def 1 ) +# 7121 "parsing/parser.ml" + : 'use_file_tail)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'seq_expr) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'post_item_attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'use_file_tail) in + Obj.repr( +# 664 "parsing/parser.mly" + ( mark_rhs_docs 2 3; + (text_def 1) @ (text_def 2) @ Ptop_def[mkstrexp _2 _3] :: _4 ) +# 7131 "parsing/parser.ml" + : 'use_file_tail)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'structure_item) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'use_file_tail) in + Obj.repr( +# 667 "parsing/parser.mly" + ( (text_def 1) @ (text_def 2) @ Ptop_def[_2] :: _3 ) +# 7139 "parsing/parser.ml" + : 'use_file_tail)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'toplevel_directive) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'use_file_tail) in + Obj.repr( +# 669 "parsing/parser.mly" + ( mark_rhs_docs 2 3; + (text_def 1) @ (text_def 2) @ _2 :: _3 ) +# 7148 "parsing/parser.ml" + : 'use_file_tail)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'structure_item) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'use_file_tail) in + Obj.repr( +# 672 "parsing/parser.mly" + ( (text_def 1) @ Ptop_def[_1] :: _2 ) +# 7156 "parsing/parser.ml" + : 'use_file_tail)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'toplevel_directive) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'use_file_tail) in + Obj.repr( +# 674 "parsing/parser.mly" + ( mark_rhs_docs 1 1; + (text_def 1) @ _1 :: _2 ) +# 7165 "parsing/parser.ml" + : 'use_file_tail)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'core_type) in + Obj.repr( +# 678 "parsing/parser.mly" + ( _1 ) +# 7172 "parsing/parser.ml" + : Parsetree.core_type)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in + Obj.repr( +# 681 "parsing/parser.mly" + ( _1 ) +# 7179 "parsing/parser.ml" + : Parsetree.expression)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'pattern) in + Obj.repr( +# 684 "parsing/parser.mly" + ( _1 ) +# 7186 "parsing/parser.ml" + : Parsetree.pattern)) +; (fun __caml_parser_env -> + Obj.repr( +# 691 "parsing/parser.mly" + ( mkrhs "*" 2, None ) +# 7192 "parsing/parser.ml" + : 'functor_arg)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'functor_arg_name) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'module_type) in + Obj.repr( +# 693 "parsing/parser.mly" + ( mkrhs _2 2, Some _4 ) +# 7200 "parsing/parser.ml" + : 'functor_arg)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 697 "parsing/parser.mly" + ( _1 ) +# 7207 "parsing/parser.ml" + : 'functor_arg_name)) +; (fun __caml_parser_env -> + Obj.repr( +# 698 "parsing/parser.mly" + ( "_" ) +# 7213 "parsing/parser.ml" + : 'functor_arg_name)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'functor_args) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'functor_arg) in + Obj.repr( +# 703 "parsing/parser.mly" + ( _2 :: _1 ) +# 7221 "parsing/parser.ml" + : 'functor_args)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'functor_arg) in + Obj.repr( +# 705 "parsing/parser.mly" + ( [ _1 ] ) +# 7228 "parsing/parser.ml" + : 'functor_args)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'mod_longident) in + Obj.repr( +# 710 "parsing/parser.mly" + ( mkmod(Pmod_ident (mkrhs _1 1)) ) +# 7235 "parsing/parser.ml" + : 'module_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'structure) in + Obj.repr( +# 712 "parsing/parser.mly" + ( mkmod ~attrs:_2 (Pmod_structure(extra_str 3 _3)) ) +# 7243 "parsing/parser.ml" + : 'module_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'structure) in + Obj.repr( +# 714 "parsing/parser.mly" + ( unclosed "struct" 1 "end" 4 ) +# 7251 "parsing/parser.ml" + : 'module_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'functor_args) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'module_expr) in + Obj.repr( +# 716 "parsing/parser.mly" + ( let modexp = + List.fold_left + (fun acc (n, t) -> mkmod(Pmod_functor(n, t, acc))) + _5 _3 + in wrap_mod_attrs modexp _2 ) +# 7264 "parsing/parser.ml" + : 'module_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'module_expr) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'paren_module_expr) in + Obj.repr( +# 722 "parsing/parser.mly" + ( mkmod(Pmod_apply(_1, _2)) ) +# 7272 "parsing/parser.ml" + : 'module_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'module_expr) in + Obj.repr( +# 724 "parsing/parser.mly" + ( mkmod(Pmod_apply(_1, mkmod (Pmod_structure []))) ) +# 7279 "parsing/parser.ml" + : 'module_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'paren_module_expr) in + Obj.repr( +# 726 "parsing/parser.mly" + ( _1 ) +# 7286 "parsing/parser.ml" + : 'module_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'module_expr) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attribute) in + Obj.repr( +# 728 "parsing/parser.mly" + ( Mod.attr _1 _2 ) +# 7294 "parsing/parser.ml" + : 'module_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'extension) in + Obj.repr( +# 730 "parsing/parser.mly" + ( mkmod(Pmod_extension _1) ) +# 7301 "parsing/parser.ml" + : 'module_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'module_expr) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'module_type) in + Obj.repr( +# 735 "parsing/parser.mly" + ( mkmod(Pmod_constraint(_2, _4)) ) +# 7309 "parsing/parser.ml" + : 'paren_module_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'module_expr) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'module_type) in + Obj.repr( +# 737 "parsing/parser.mly" + ( unclosed "(" 1 ")" 5 ) +# 7317 "parsing/parser.ml" + : 'paren_module_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'module_expr) in + Obj.repr( +# 739 "parsing/parser.mly" + ( _2 ) +# 7324 "parsing/parser.ml" + : 'paren_module_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'module_expr) in + Obj.repr( +# 741 "parsing/parser.mly" + ( unclosed "(" 1 ")" 3 ) +# 7331 "parsing/parser.ml" + : 'paren_module_expr)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in + Obj.repr( +# 743 "parsing/parser.mly" + ( mkmod ~attrs:_3 (Pmod_unpack _4)) +# 7339 "parsing/parser.ml" + : 'paren_module_expr)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : 'expr) in + let _6 = (Parsing.peek_val __caml_parser_env 1 : 'package_type) in + Obj.repr( +# 745 "parsing/parser.mly" + ( mkmod ~attrs:_3 + (Pmod_unpack( + ghexp(Pexp_constraint(_4, ghtyp(Ptyp_package _6))))) ) +# 7350 "parsing/parser.ml" + : 'paren_module_expr)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 6 : 'attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 5 : 'expr) in + let _6 = (Parsing.peek_val __caml_parser_env 3 : 'package_type) in + let _8 = (Parsing.peek_val __caml_parser_env 1 : 'package_type) in + Obj.repr( +# 750 "parsing/parser.mly" + ( mkmod ~attrs:_3 + (Pmod_unpack( + ghexp(Pexp_coerce(_4, Some(ghtyp(Ptyp_package _6)), + ghtyp(Ptyp_package _8))))) ) +# 7363 "parsing/parser.ml" + : 'paren_module_expr)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : 'expr) in + let _6 = (Parsing.peek_val __caml_parser_env 1 : 'package_type) in + Obj.repr( +# 755 "parsing/parser.mly" + ( mkmod ~attrs:_3 + (Pmod_unpack( + ghexp(Pexp_coerce(_4, None, ghtyp(Ptyp_package _6))))) ) +# 7374 "parsing/parser.ml" + : 'paren_module_expr)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 3 : 'attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + Obj.repr( +# 759 "parsing/parser.mly" + ( unclosed "(" 1 ")" 6 ) +# 7382 "parsing/parser.ml" + : 'paren_module_expr)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 3 : 'attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + Obj.repr( +# 761 "parsing/parser.mly" + ( unclosed "(" 1 ")" 6 ) +# 7390 "parsing/parser.ml" + : 'paren_module_expr)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in + Obj.repr( +# 763 "parsing/parser.mly" + ( unclosed "(" 1 ")" 5 ) +# 7398 "parsing/parser.ml" + : 'paren_module_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'seq_expr) in + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'post_item_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'structure_tail) in + Obj.repr( +# 768 "parsing/parser.mly" + ( mark_rhs_docs 1 2; + (text_str 1) @ mkstrexp _1 _2 :: _3 ) +# 7408 "parsing/parser.ml" + : 'structure)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'structure_tail) in + Obj.repr( +# 770 "parsing/parser.mly" + ( _1 ) +# 7415 "parsing/parser.ml" + : 'structure)) +; (fun __caml_parser_env -> + Obj.repr( +# 773 "parsing/parser.mly" + ( [] ) +# 7421 "parsing/parser.ml" + : 'structure_tail)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'structure) in + Obj.repr( +# 774 "parsing/parser.mly" + ( (text_str 1) @ _2 ) +# 7428 "parsing/parser.ml" + : 'structure_tail)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'structure_item) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'structure_tail) in + Obj.repr( +# 775 "parsing/parser.mly" + ( (text_str 1) @ _1 :: _2 ) +# 7436 "parsing/parser.ml" + : 'structure_tail)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'let_bindings) in + Obj.repr( +# 779 "parsing/parser.mly" + ( val_of_let_bindings _1 ) +# 7443 "parsing/parser.ml" + : 'structure_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'primitive_declaration) in + Obj.repr( +# 781 "parsing/parser.mly" + ( let (body, ext) = _1 in mkstr_ext (Pstr_primitive body) ext ) +# 7450 "parsing/parser.ml" + : 'structure_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'value_description) in + Obj.repr( +# 783 "parsing/parser.mly" + ( let (body, ext) = _1 in mkstr_ext (Pstr_primitive body) ext ) +# 7457 "parsing/parser.ml" + : 'structure_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'type_declarations) in + Obj.repr( +# 785 "parsing/parser.mly" + ( let (nr, l, ext ) = _1 in mkstr_ext (Pstr_type (nr, List.rev l)) ext ) +# 7464 "parsing/parser.ml" + : 'structure_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'str_type_extension) in + Obj.repr( +# 787 "parsing/parser.mly" + ( let (l, ext) = _1 in mkstr_ext (Pstr_typext l) ext ) +# 7471 "parsing/parser.ml" + : 'structure_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'str_exception_declaration) in + Obj.repr( +# 789 "parsing/parser.mly" + ( let (l, ext) = _1 in mkstr_ext (Pstr_exception l) ext ) +# 7478 "parsing/parser.ml" + : 'structure_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'module_binding) in + Obj.repr( +# 791 "parsing/parser.mly" + ( let (body, ext) = _1 in mkstr_ext (Pstr_module body) ext ) +# 7485 "parsing/parser.ml" + : 'structure_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'rec_module_bindings) in + Obj.repr( +# 793 "parsing/parser.mly" + ( let (l, ext) = _1 in mkstr_ext (Pstr_recmodule(List.rev l)) ext ) +# 7492 "parsing/parser.ml" + : 'structure_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'module_type_declaration) in + Obj.repr( +# 795 "parsing/parser.mly" + ( let (body, ext) = _1 in mkstr_ext (Pstr_modtype body) ext ) +# 7499 "parsing/parser.ml" + : 'structure_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'open_statement) in + Obj.repr( +# 797 "parsing/parser.mly" + ( let (body, ext) = _1 in mkstr_ext (Pstr_open body) ext ) +# 7506 "parsing/parser.ml" + : 'structure_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'class_declarations) in + Obj.repr( +# 799 "parsing/parser.mly" + ( let (l, ext) = _1 in mkstr_ext (Pstr_class (List.rev l)) ext ) +# 7513 "parsing/parser.ml" + : 'structure_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'class_type_declarations) in + Obj.repr( +# 801 "parsing/parser.mly" + ( let (l, ext) = _1 in mkstr_ext (Pstr_class_type (List.rev l)) ext ) +# 7520 "parsing/parser.ml" + : 'structure_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'str_include_statement) in + Obj.repr( +# 803 "parsing/parser.mly" + ( let (body, ext) = _1 in mkstr_ext (Pstr_include body) ext ) +# 7527 "parsing/parser.ml" + : 'structure_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'item_extension) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 805 "parsing/parser.mly" + ( mkstr(Pstr_extension (_1, (add_docs_attrs (symbol_docs ()) _2))) ) +# 7535 "parsing/parser.ml" + : 'structure_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'floating_attribute) in + Obj.repr( +# 807 "parsing/parser.mly" + ( mark_symbol_docs (); + mkstr(Pstr_attribute _1) ) +# 7543 "parsing/parser.ml" + : 'structure_item)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'module_expr) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 812 "parsing/parser.mly" + ( let (ext, attrs) = _2 in + Incl.mk _3 ~attrs:(attrs@_4) + ~loc:(symbol_rloc()) ~docs:(symbol_docs ()) + , ext ) +# 7555 "parsing/parser.ml" + : 'str_include_statement)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'module_expr) in + Obj.repr( +# 819 "parsing/parser.mly" + ( _2 ) +# 7562 "parsing/parser.ml" + : 'module_binding_body)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'module_type) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'module_expr) in + Obj.repr( +# 821 "parsing/parser.mly" + ( mkmod(Pmod_constraint(_4, _2)) ) +# 7570 "parsing/parser.ml" + : 'module_binding_body)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'functor_arg) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'module_binding_body) in + Obj.repr( +# 823 "parsing/parser.mly" + ( mkmod(Pmod_functor(fst _1, snd _1, _2)) ) +# 7578 "parsing/parser.ml" + : 'module_binding_body)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 2 : string) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'module_binding_body) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 827 "parsing/parser.mly" + ( let (ext, attrs) = _2 in + Mb.mk (mkrhs _3 3) _4 ~attrs:(attrs@_5) + ~loc:(symbol_rloc ()) ~docs:(symbol_docs ()) + , ext ) +# 7591 "parsing/parser.ml" + : 'module_binding)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'rec_module_binding) in + Obj.repr( +# 833 "parsing/parser.mly" + ( let (b, ext) = _1 in ([b], ext) ) +# 7598 "parsing/parser.ml" + : 'rec_module_bindings)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'rec_module_bindings) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'and_module_binding) in + Obj.repr( +# 835 "parsing/parser.mly" + ( let (l, ext) = _1 in (_2 :: l, ext) ) +# 7606 "parsing/parser.ml" + : 'rec_module_bindings)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 2 : string) in + let _5 = (Parsing.peek_val __caml_parser_env 1 : 'module_binding_body) in + let _6 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 839 "parsing/parser.mly" + ( let (ext, attrs) = _2 in + Mb.mk (mkrhs _4 4) _5 ~attrs:(attrs@_6) + ~loc:(symbol_rloc ()) ~docs:(symbol_docs ()) + , ext ) +# 7619 "parsing/parser.ml" + : 'rec_module_binding)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 2 : string) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'module_binding_body) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 846 "parsing/parser.mly" + ( Mb.mk (mkrhs _3 3) _4 ~attrs:(_2@_5) ~loc:(symbol_rloc ()) + ~text:(symbol_text ()) ~docs:(symbol_docs ()) ) +# 7630 "parsing/parser.ml" + : 'and_module_binding)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'mty_longident) in + Obj.repr( +# 854 "parsing/parser.mly" + ( mkmty(Pmty_ident (mkrhs _1 1)) ) +# 7637 "parsing/parser.ml" + : 'module_type)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'signature) in + Obj.repr( +# 856 "parsing/parser.mly" + ( mkmty ~attrs:_2 (Pmty_signature (extra_sig 3 _3)) ) +# 7645 "parsing/parser.ml" + : 'module_type)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'signature) in + Obj.repr( +# 858 "parsing/parser.mly" + ( unclosed "sig" 1 "end" 4 ) +# 7653 "parsing/parser.ml" + : 'module_type)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'functor_args) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'module_type) in + Obj.repr( +# 861 "parsing/parser.mly" + ( let mty = + List.fold_left + (fun acc (n, t) -> mkmty(Pmty_functor(n, t, acc))) + _5 _3 + in wrap_mty_attrs mty _2 ) +# 7666 "parsing/parser.ml" + : 'module_type)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'module_type) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'module_type) in + Obj.repr( +# 868 "parsing/parser.mly" + ( mkmty(Pmty_functor(mknoloc "_", Some _1, _3)) ) +# 7674 "parsing/parser.ml" + : 'module_type)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'module_type) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'with_constraints) in + Obj.repr( +# 870 "parsing/parser.mly" + ( mkmty(Pmty_with(_1, List.rev _3)) ) +# 7682 "parsing/parser.ml" + : 'module_type)) +; (fun __caml_parser_env -> + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'attributes) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'module_expr) in + Obj.repr( +# 872 "parsing/parser.mly" + ( mkmty ~attrs:_4 (Pmty_typeof _5) ) +# 7690 "parsing/parser.ml" + : 'module_type)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'module_type) in + Obj.repr( +# 876 "parsing/parser.mly" + ( _2 ) +# 7697 "parsing/parser.ml" + : 'module_type)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'module_type) in + Obj.repr( +# 878 "parsing/parser.mly" + ( unclosed "(" 1 ")" 3 ) +# 7704 "parsing/parser.ml" + : 'module_type)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'extension) in + Obj.repr( +# 880 "parsing/parser.mly" + ( mkmty(Pmty_extension _1) ) +# 7711 "parsing/parser.ml" + : 'module_type)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'module_type) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attribute) in + Obj.repr( +# 882 "parsing/parser.mly" + ( Mty.attr _1 _2 ) +# 7719 "parsing/parser.ml" + : 'module_type)) +; (fun __caml_parser_env -> + Obj.repr( +# 885 "parsing/parser.mly" + ( [] ) +# 7725 "parsing/parser.ml" + : 'signature)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'signature) in + Obj.repr( +# 886 "parsing/parser.mly" + ( (text_sig 1) @ _2 ) +# 7732 "parsing/parser.ml" + : 'signature)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'signature_item) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'signature) in + Obj.repr( +# 887 "parsing/parser.mly" + ( (text_sig 1) @ _1 :: _2 ) +# 7740 "parsing/parser.ml" + : 'signature)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'value_description) in + Obj.repr( +# 891 "parsing/parser.mly" + ( let (body, ext) = _1 in mksig_ext (Psig_value body) ext ) +# 7747 "parsing/parser.ml" + : 'signature_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'primitive_declaration) in + Obj.repr( +# 893 "parsing/parser.mly" + ( let (body, ext) = _1 in mksig_ext (Psig_value body) ext) +# 7754 "parsing/parser.ml" + : 'signature_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'type_declarations) in + Obj.repr( +# 895 "parsing/parser.mly" + ( let (nr, l, ext) = _1 in mksig_ext (Psig_type (nr, List.rev l)) ext ) +# 7761 "parsing/parser.ml" + : 'signature_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'sig_type_extension) in + Obj.repr( +# 897 "parsing/parser.mly" + ( let (l, ext) = _1 in mksig_ext (Psig_typext l) ext ) +# 7768 "parsing/parser.ml" + : 'signature_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'sig_exception_declaration) in + Obj.repr( +# 899 "parsing/parser.mly" + ( let (l, ext) = _1 in mksig_ext (Psig_exception l) ext ) +# 7775 "parsing/parser.ml" + : 'signature_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'module_declaration) in + Obj.repr( +# 901 "parsing/parser.mly" + ( let (body, ext) = _1 in mksig_ext (Psig_module body) ext ) +# 7782 "parsing/parser.ml" + : 'signature_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'module_alias) in + Obj.repr( +# 903 "parsing/parser.mly" + ( let (body, ext) = _1 in mksig_ext (Psig_module body) ext ) +# 7789 "parsing/parser.ml" + : 'signature_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'rec_module_declarations) in + Obj.repr( +# 905 "parsing/parser.mly" + ( let (l, ext) = _1 in mksig_ext (Psig_recmodule (List.rev l)) ext ) +# 7796 "parsing/parser.ml" + : 'signature_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'module_type_declaration) in + Obj.repr( +# 907 "parsing/parser.mly" + ( let (body, ext) = _1 in mksig_ext (Psig_modtype body) ext ) +# 7803 "parsing/parser.ml" + : 'signature_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'open_statement) in + Obj.repr( +# 909 "parsing/parser.mly" + ( let (body, ext) = _1 in mksig_ext (Psig_open body) ext ) +# 7810 "parsing/parser.ml" + : 'signature_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'sig_include_statement) in + Obj.repr( +# 911 "parsing/parser.mly" + ( let (body, ext) = _1 in mksig_ext (Psig_include body) ext ) +# 7817 "parsing/parser.ml" + : 'signature_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'class_descriptions) in + Obj.repr( +# 913 "parsing/parser.mly" + ( let (l, ext) = _1 in mksig_ext (Psig_class (List.rev l)) ext ) +# 7824 "parsing/parser.ml" + : 'signature_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'class_type_declarations) in + Obj.repr( +# 915 "parsing/parser.mly" + ( let (l, ext) = _1 in mksig_ext (Psig_class_type (List.rev l)) ext ) +# 7831 "parsing/parser.ml" + : 'signature_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'item_extension) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 917 "parsing/parser.mly" + ( mksig(Psig_extension (_1, (add_docs_attrs (symbol_docs ()) _2))) ) +# 7839 "parsing/parser.ml" + : 'signature_item)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'floating_attribute) in + Obj.repr( +# 919 "parsing/parser.mly" + ( mark_symbol_docs (); + mksig(Psig_attribute _1) ) +# 7847 "parsing/parser.ml" + : 'signature_item)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'override_flag) in + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'mod_longident) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 924 "parsing/parser.mly" + ( let (ext, attrs) = _3 in + Opn.mk (mkrhs _4 4) ~override:_2 ~attrs:(attrs@_5) + ~loc:(symbol_rloc()) ~docs:(symbol_docs ()) + , ext) +# 7860 "parsing/parser.ml" + : 'open_statement)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'module_type) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 931 "parsing/parser.mly" + ( let (ext, attrs) = _2 in + Incl.mk _3 ~attrs:(attrs@_4) + ~loc:(symbol_rloc()) ~docs:(symbol_docs ()) + , ext) +# 7872 "parsing/parser.ml" + : 'sig_include_statement)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'module_type) in + Obj.repr( +# 938 "parsing/parser.mly" + ( _2 ) +# 7879 "parsing/parser.ml" + : 'module_declaration_body)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 4 : string) in + let _4 = (Parsing.peek_val __caml_parser_env 2 : 'module_type) in + let _6 = (Parsing.peek_val __caml_parser_env 0 : 'module_declaration_body) in + Obj.repr( +# 940 "parsing/parser.mly" + ( mkmty(Pmty_functor(mkrhs _2 2, Some _4, _6)) ) +# 7888 "parsing/parser.ml" + : 'module_declaration_body)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'module_declaration_body) in + Obj.repr( +# 942 "parsing/parser.mly" + ( mkmty(Pmty_functor(mkrhs "*" 1, None, _3)) ) +# 7895 "parsing/parser.ml" + : 'module_declaration_body)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 2 : string) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'module_declaration_body) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 946 "parsing/parser.mly" + ( let (ext, attrs) = _2 in + Md.mk (mkrhs _3 3) _4 ~attrs:(attrs@_5) + ~loc:(symbol_rloc()) ~docs:(symbol_docs ()) + , ext ) +# 7908 "parsing/parser.ml" + : 'module_declaration)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _5 = (Parsing.peek_val __caml_parser_env 1 : 'mod_longident) in + let _6 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 953 "parsing/parser.mly" + ( let (ext, attrs) = _2 in + Md.mk (mkrhs _3 3) + (Mty.alias ~loc:(rhs_loc 5) (mkrhs _5 5)) ~attrs:(attrs@_6) + ~loc:(symbol_rloc()) ~docs:(symbol_docs ()) + , ext ) +# 7922 "parsing/parser.ml" + : 'module_alias)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'rec_module_declaration) in + Obj.repr( +# 961 "parsing/parser.mly" + ( let (body, ext) = _1 in ([body], ext) ) +# 7929 "parsing/parser.ml" + : 'rec_module_declarations)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'rec_module_declarations) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'and_module_declaration) in + Obj.repr( +# 963 "parsing/parser.mly" + ( let (l, ext) = _1 in (_2 :: l, ext) ) +# 7937 "parsing/parser.ml" + : 'rec_module_declarations)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 5 : 'ext_attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _6 = (Parsing.peek_val __caml_parser_env 1 : 'module_type) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 967 "parsing/parser.mly" + ( let (ext, attrs) = _2 in + Md.mk (mkrhs _4 4) _6 ~attrs:(attrs@_7) + ~loc:(symbol_rloc()) ~docs:(symbol_docs ()) + , ext) +# 7950 "parsing/parser.ml" + : 'rec_module_declaration)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 4 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _5 = (Parsing.peek_val __caml_parser_env 1 : 'module_type) in + let _6 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 974 "parsing/parser.mly" + ( Md.mk (mkrhs _3 3) _5 ~attrs:(_2@_6) ~loc:(symbol_rloc()) + ~text:(symbol_text()) ~docs:(symbol_docs()) ) +# 7961 "parsing/parser.ml" + : 'and_module_declaration)) +; (fun __caml_parser_env -> + Obj.repr( +# 978 "parsing/parser.mly" + ( None ) +# 7967 "parsing/parser.ml" + : 'module_type_declaration_body)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'module_type) in + Obj.repr( +# 979 "parsing/parser.mly" + ( Some _2 ) +# 7974 "parsing/parser.ml" + : 'module_type_declaration_body)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 3 : 'ext_attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 2 : 'ident) in + let _5 = (Parsing.peek_val __caml_parser_env 1 : 'module_type_declaration_body) in + let _6 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 984 "parsing/parser.mly" + ( let (ext, attrs) = _3 in + Mtd.mk (mkrhs _4 4) ?typ:_5 ~attrs:(attrs@_6) + ~loc:(symbol_rloc()) ~docs:(symbol_docs ()) + , ext ) +# 7987 "parsing/parser.ml" + : 'module_type_declaration)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'class_declaration) in + Obj.repr( +# 993 "parsing/parser.mly" + ( let (body, ext) = _1 in ([body], ext) ) +# 7994 "parsing/parser.ml" + : 'class_declarations)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'class_declarations) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'and_class_declaration) in + Obj.repr( +# 995 "parsing/parser.mly" + ( let (l, ext) = _1 in (_2 :: l, ext) ) +# 8002 "parsing/parser.ml" + : 'class_declarations)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 5 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'virtual_flag) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : 'class_type_parameters) in + let _5 = (Parsing.peek_val __caml_parser_env 2 : string) in + let _6 = (Parsing.peek_val __caml_parser_env 1 : 'class_fun_binding) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1000 "parsing/parser.mly" + ( let (ext, attrs) = _2 in + Ci.mk (mkrhs _5 5) _6 ~virt:_3 ~params:_4 ~attrs:(attrs@_7) + ~loc:(symbol_rloc ()) ~docs:(symbol_docs ()) + , ext ) +# 8017 "parsing/parser.ml" + : 'class_declaration)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 5 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'virtual_flag) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : 'class_type_parameters) in + let _5 = (Parsing.peek_val __caml_parser_env 2 : string) in + let _6 = (Parsing.peek_val __caml_parser_env 1 : 'class_fun_binding) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1008 "parsing/parser.mly" + ( Ci.mk (mkrhs _5 5) _6 ~virt:_3 ~params:_4 + ~attrs:(_2@_7) ~loc:(symbol_rloc ()) + ~text:(symbol_text ()) ~docs:(symbol_docs ()) ) +# 8031 "parsing/parser.ml" + : 'and_class_declaration)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'class_expr) in + Obj.repr( +# 1014 "parsing/parser.mly" + ( _2 ) +# 8038 "parsing/parser.ml" + : 'class_fun_binding)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'class_type) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'class_expr) in + Obj.repr( +# 1016 "parsing/parser.mly" + ( mkclass(Pcl_constraint(_4, _2)) ) +# 8046 "parsing/parser.ml" + : 'class_fun_binding)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'labeled_simple_pattern) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'class_fun_binding) in + Obj.repr( +# 1018 "parsing/parser.mly" + ( let (l,o,p) = _1 in mkclass(Pcl_fun(l, o, p, _2)) ) +# 8054 "parsing/parser.ml" + : 'class_fun_binding)) +; (fun __caml_parser_env -> + Obj.repr( +# 1021 "parsing/parser.mly" + ( [] ) +# 8060 "parsing/parser.ml" + : 'class_type_parameters)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'type_parameter_list) in + Obj.repr( +# 1022 "parsing/parser.mly" + ( List.rev _2 ) +# 8067 "parsing/parser.ml" + : 'class_type_parameters)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'labeled_simple_pattern) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'class_expr) in + Obj.repr( +# 1026 "parsing/parser.mly" + ( let (l,o,p) = _1 in mkclass(Pcl_fun(l, o, p, _3)) ) +# 8075 "parsing/parser.ml" + : 'class_fun_def)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'labeled_simple_pattern) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'class_fun_def) in + Obj.repr( +# 1028 "parsing/parser.mly" + ( let (l,o,p) = _1 in mkclass(Pcl_fun(l, o, p, _2)) ) +# 8083 "parsing/parser.ml" + : 'class_fun_def)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'class_simple_expr) in + Obj.repr( +# 1032 "parsing/parser.mly" + ( _1 ) +# 8090 "parsing/parser.ml" + : 'class_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'class_fun_def) in + Obj.repr( +# 1034 "parsing/parser.mly" + ( wrap_class_attrs _3 _2 ) +# 8098 "parsing/parser.ml" + : 'class_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'class_simple_expr) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'simple_labeled_expr_list) in + Obj.repr( +# 1036 "parsing/parser.mly" + ( mkclass(Pcl_apply(_1, List.rev _2)) ) +# 8106 "parsing/parser.ml" + : 'class_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'let_bindings) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'class_expr) in + Obj.repr( +# 1038 "parsing/parser.mly" + ( class_of_let_bindings _1 _3 ) +# 8114 "parsing/parser.ml" + : 'class_expr)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'override_flag) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : 'attributes) in + let _5 = (Parsing.peek_val __caml_parser_env 2 : 'mod_longident) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'class_expr) in + Obj.repr( +# 1040 "parsing/parser.mly" + ( wrap_class_attrs (mkclass(Pcl_open(_3, mkrhs _5 5, _7))) _4 ) +# 8124 "parsing/parser.ml" + : 'class_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'class_expr) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attribute) in + Obj.repr( +# 1042 "parsing/parser.mly" + ( Cl.attr _1 _2 ) +# 8132 "parsing/parser.ml" + : 'class_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'extension) in + Obj.repr( +# 1044 "parsing/parser.mly" + ( mkclass(Pcl_extension _1) ) +# 8139 "parsing/parser.ml" + : 'class_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'core_type_comma_list) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'class_longident) in + Obj.repr( +# 1048 "parsing/parser.mly" + ( mkclass(Pcl_constr(mkloc _4 (rhs_loc 4), List.rev _2)) ) +# 8147 "parsing/parser.ml" + : 'class_simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'class_longident) in + Obj.repr( +# 1050 "parsing/parser.mly" + ( mkclass(Pcl_constr(mkrhs _1 1, [])) ) +# 8154 "parsing/parser.ml" + : 'class_simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'class_structure) in + Obj.repr( +# 1052 "parsing/parser.mly" + ( mkclass ~attrs:_2 (Pcl_structure _3) ) +# 8162 "parsing/parser.ml" + : 'class_simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'class_structure) in + Obj.repr( +# 1054 "parsing/parser.mly" + ( unclosed "object" 1 "end" 4 ) +# 8170 "parsing/parser.ml" + : 'class_simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'class_expr) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'class_type) in + Obj.repr( +# 1056 "parsing/parser.mly" + ( mkclass(Pcl_constraint(_2, _4)) ) +# 8178 "parsing/parser.ml" + : 'class_simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'class_expr) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'class_type) in + Obj.repr( +# 1058 "parsing/parser.mly" + ( unclosed "(" 1 ")" 5 ) +# 8186 "parsing/parser.ml" + : 'class_simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'class_expr) in + Obj.repr( +# 1060 "parsing/parser.mly" + ( _2 ) +# 8193 "parsing/parser.ml" + : 'class_simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'class_expr) in + Obj.repr( +# 1062 "parsing/parser.mly" + ( unclosed "(" 1 ")" 3 ) +# 8200 "parsing/parser.ml" + : 'class_simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'class_self_pattern) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'class_fields) in + Obj.repr( +# 1066 "parsing/parser.mly" + ( Cstr.mk _1 (extra_cstr 2 (List.rev _2)) ) +# 8208 "parsing/parser.ml" + : 'class_structure)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'pattern) in + Obj.repr( +# 1070 "parsing/parser.mly" + ( reloc_pat _2 ) +# 8215 "parsing/parser.ml" + : 'class_self_pattern)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'pattern) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'core_type) in + Obj.repr( +# 1072 "parsing/parser.mly" + ( mkpat(Ppat_constraint(_2, _4)) ) +# 8223 "parsing/parser.ml" + : 'class_self_pattern)) +; (fun __caml_parser_env -> + Obj.repr( +# 1074 "parsing/parser.mly" + ( ghpat(Ppat_any) ) +# 8229 "parsing/parser.ml" + : 'class_self_pattern)) +; (fun __caml_parser_env -> + Obj.repr( +# 1078 "parsing/parser.mly" + ( [] ) +# 8235 "parsing/parser.ml" + : 'class_fields)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'class_fields) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'class_field) in + Obj.repr( +# 1080 "parsing/parser.mly" + ( _2 :: (text_cstr 2) @ _1 ) +# 8243 "parsing/parser.ml" + : 'class_fields)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 4 : 'override_flag) in + let _3 = (Parsing.peek_val __caml_parser_env 3 : 'attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 2 : 'class_expr) in + let _5 = (Parsing.peek_val __caml_parser_env 1 : 'parent_binder) in + let _6 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1085 "parsing/parser.mly" + ( mkcf (Pcf_inherit (_2, _4, _5)) ~attrs:(_3@_6) ~docs:(symbol_docs ()) ) +# 8254 "parsing/parser.ml" + : 'class_field)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'value) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1087 "parsing/parser.mly" + ( let v, attrs = _2 in + mkcf (Pcf_val v) ~attrs:(attrs@_3) ~docs:(symbol_docs ()) ) +# 8263 "parsing/parser.ml" + : 'class_field)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'method_) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1090 "parsing/parser.mly" + ( let meth, attrs = _2 in + mkcf (Pcf_method meth) ~attrs:(attrs@_3) ~docs:(symbol_docs ()) ) +# 8272 "parsing/parser.ml" + : 'class_field)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'constrain_field) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1093 "parsing/parser.mly" + ( mkcf (Pcf_constraint _3) ~attrs:(_2@_4) ~docs:(symbol_docs ()) ) +# 8281 "parsing/parser.ml" + : 'class_field)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1095 "parsing/parser.mly" + ( mkcf (Pcf_initializer _3) ~attrs:(_2@_4) ~docs:(symbol_docs ()) ) +# 8290 "parsing/parser.ml" + : 'class_field)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'item_extension) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1097 "parsing/parser.mly" + ( mkcf (Pcf_extension _1) ~attrs:_2 ~docs:(symbol_docs ()) ) +# 8298 "parsing/parser.ml" + : 'class_field)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'floating_attribute) in + Obj.repr( +# 1099 "parsing/parser.mly" + ( mark_symbol_docs (); + mkcf (Pcf_attribute _1) ) +# 8306 "parsing/parser.ml" + : 'class_field)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 1104 "parsing/parser.mly" + ( Some (mkrhs _2 2) ) +# 8313 "parsing/parser.ml" + : 'parent_binder)) +; (fun __caml_parser_env -> + Obj.repr( +# 1106 "parsing/parser.mly" + ( None ) +# 8319 "parsing/parser.ml" + : 'parent_binder)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 6 : 'override_flag) in + let _2 = (Parsing.peek_val __caml_parser_env 5 : 'attributes) in + let _5 = (Parsing.peek_val __caml_parser_env 2 : 'label) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in + Obj.repr( +# 1111 "parsing/parser.mly" + ( if _1 = Override then syntax_error (); + (mkloc _5 (rhs_loc 5), Mutable, Cfk_virtual _7), _2 ) +# 8330 "parsing/parser.ml" + : 'value)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 6 : 'override_flag) in + let _2 = (Parsing.peek_val __caml_parser_env 5 : 'attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : 'mutable_flag) in + let _5 = (Parsing.peek_val __caml_parser_env 2 : 'label) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in + Obj.repr( +# 1114 "parsing/parser.mly" + ( if _1 = Override then syntax_error (); + (mkrhs _5 5, _4, Cfk_virtual _7), _2 ) +# 8342 "parsing/parser.ml" + : 'value)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 5 : 'override_flag) in + let _2 = (Parsing.peek_val __caml_parser_env 4 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 3 : 'mutable_flag) in + let _4 = (Parsing.peek_val __caml_parser_env 2 : 'label) in + let _6 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1117 "parsing/parser.mly" + ( (mkrhs _4 4, _3, Cfk_concrete (_1, _6)), _2 ) +# 8353 "parsing/parser.ml" + : 'value)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 6 : 'override_flag) in + let _2 = (Parsing.peek_val __caml_parser_env 5 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'mutable_flag) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : 'label) in + let _5 = (Parsing.peek_val __caml_parser_env 2 : 'type_constraint) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1119 "parsing/parser.mly" + ( + let e = mkexp_constraint _7 _5 in + (mkrhs _4 4, _3, Cfk_concrete (_1, e)), _2 + ) +# 8368 "parsing/parser.ml" + : 'value)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 6 : 'override_flag) in + let _2 = (Parsing.peek_val __caml_parser_env 5 : 'attributes) in + let _5 = (Parsing.peek_val __caml_parser_env 2 : 'label) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'poly_type) in + Obj.repr( +# 1127 "parsing/parser.mly" + ( if _1 = Override then syntax_error (); + (mkloc _5 (rhs_loc 5), Private, Cfk_virtual _7), _2 ) +# 8379 "parsing/parser.ml" + : 'method_)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 6 : 'override_flag) in + let _2 = (Parsing.peek_val __caml_parser_env 5 : 'attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : 'private_flag) in + let _5 = (Parsing.peek_val __caml_parser_env 2 : 'label) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'poly_type) in + Obj.repr( +# 1130 "parsing/parser.mly" + ( if _1 = Override then syntax_error (); + (mkloc _5 (rhs_loc 5), _4, Cfk_virtual _7), _2 ) +# 8391 "parsing/parser.ml" + : 'method_)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'override_flag) in + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'private_flag) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'label) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'strict_binding) in + Obj.repr( +# 1133 "parsing/parser.mly" + ( (mkloc _4 (rhs_loc 4), _3, + Cfk_concrete (_1, ghexp(Pexp_poly (_5, None)))), _2 ) +# 8403 "parsing/parser.ml" + : 'method_)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 7 : 'override_flag) in + let _2 = (Parsing.peek_val __caml_parser_env 6 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 5 : 'private_flag) in + let _4 = (Parsing.peek_val __caml_parser_env 4 : 'label) in + let _6 = (Parsing.peek_val __caml_parser_env 2 : 'poly_type) in + let _8 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1136 "parsing/parser.mly" + ( (mkloc _4 (rhs_loc 4), _3, + Cfk_concrete (_1, ghexp(Pexp_poly(_8, Some _6)))), _2 ) +# 8416 "parsing/parser.ml" + : 'method_)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 10 : 'override_flag) in + let _2 = (Parsing.peek_val __caml_parser_env 9 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 8 : 'private_flag) in + let _4 = (Parsing.peek_val __caml_parser_env 7 : 'label) in + let _7 = (Parsing.peek_val __caml_parser_env 4 : 'lident_list) in + let _9 = (Parsing.peek_val __caml_parser_env 2 : 'core_type) in + let _11 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1140 "parsing/parser.mly" + ( let exp, poly = wrap_type_annotation _7 _9 _11 in + (mkloc _4 (rhs_loc 4), _3, + Cfk_concrete (_1, ghexp(Pexp_poly(exp, Some poly)))), _2 ) +# 8431 "parsing/parser.ml" + : 'method_)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'class_signature) in + Obj.repr( +# 1149 "parsing/parser.mly" + ( _1 ) +# 8438 "parsing/parser.ml" + : 'class_type)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 4 : string) in + let _4 = (Parsing.peek_val __caml_parser_env 2 : 'simple_core_type_or_tuple) in + let _6 = (Parsing.peek_val __caml_parser_env 0 : 'class_type) in + Obj.repr( +# 1152 "parsing/parser.mly" + ( mkcty(Pcty_arrow(Optional _2 , _4, _6)) ) +# 8447 "parsing/parser.ml" + : 'class_type)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'simple_core_type_or_tuple) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'class_type) in + Obj.repr( +# 1154 "parsing/parser.mly" + ( mkcty(Pcty_arrow(Optional _1, _2, _4)) ) +# 8456 "parsing/parser.ml" + : 'class_type)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : string) in + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'simple_core_type_or_tuple) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'class_type) in + Obj.repr( +# 1156 "parsing/parser.mly" + ( mkcty(Pcty_arrow(Labelled _1, _3, _5)) ) +# 8465 "parsing/parser.ml" + : 'class_type)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'simple_core_type_or_tuple) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'class_type) in + Obj.repr( +# 1158 "parsing/parser.mly" + ( mkcty(Pcty_arrow(Nolabel, _1, _3)) ) +# 8473 "parsing/parser.ml" + : 'class_type)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'core_type_comma_list) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'clty_longident) in + Obj.repr( +# 1162 "parsing/parser.mly" + ( mkcty(Pcty_constr (mkloc _4 (rhs_loc 4), List.rev _2)) ) +# 8481 "parsing/parser.ml" + : 'class_signature)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'clty_longident) in + Obj.repr( +# 1164 "parsing/parser.mly" + ( mkcty(Pcty_constr (mkrhs _1 1, [])) ) +# 8488 "parsing/parser.ml" + : 'class_signature)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'class_sig_body) in + Obj.repr( +# 1166 "parsing/parser.mly" + ( mkcty ~attrs:_2 (Pcty_signature _3) ) +# 8496 "parsing/parser.ml" + : 'class_signature)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'class_sig_body) in + Obj.repr( +# 1168 "parsing/parser.mly" + ( unclosed "object" 1 "end" 4 ) +# 8504 "parsing/parser.ml" + : 'class_signature)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'class_signature) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attribute) in + Obj.repr( +# 1170 "parsing/parser.mly" + ( Cty.attr _1 _2 ) +# 8512 "parsing/parser.ml" + : 'class_signature)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'extension) in + Obj.repr( +# 1172 "parsing/parser.mly" + ( mkcty(Pcty_extension _1) ) +# 8519 "parsing/parser.ml" + : 'class_signature)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'override_flag) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : 'attributes) in + let _5 = (Parsing.peek_val __caml_parser_env 2 : 'mod_longident) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'class_signature) in + Obj.repr( +# 1174 "parsing/parser.mly" + ( wrap_class_type_attrs (mkcty(Pcty_open(_3, mkrhs _5 5, _7))) _4 ) +# 8529 "parsing/parser.ml" + : 'class_signature)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'class_self_type) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'class_sig_fields) in + Obj.repr( +# 1178 "parsing/parser.mly" + ( Csig.mk _1 (extra_csig 2 (List.rev _2)) ) +# 8537 "parsing/parser.ml" + : 'class_sig_body)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'core_type) in + Obj.repr( +# 1182 "parsing/parser.mly" + ( _2 ) +# 8544 "parsing/parser.ml" + : 'class_self_type)) +; (fun __caml_parser_env -> + Obj.repr( +# 1184 "parsing/parser.mly" + ( mktyp(Ptyp_any) ) +# 8550 "parsing/parser.ml" + : 'class_self_type)) +; (fun __caml_parser_env -> + Obj.repr( +# 1187 "parsing/parser.mly" + ( [] ) +# 8556 "parsing/parser.ml" + : 'class_sig_fields)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'class_sig_fields) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'class_sig_field) in + Obj.repr( +# 1188 "parsing/parser.mly" + ( _2 :: (text_csig 2) @ _1 ) +# 8564 "parsing/parser.ml" + : 'class_sig_fields)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'class_signature) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1192 "parsing/parser.mly" + ( mkctf (Pctf_inherit _3) ~attrs:(_2@_4) ~docs:(symbol_docs ()) ) +# 8573 "parsing/parser.ml" + : 'class_sig_field)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'value_type) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1194 "parsing/parser.mly" + ( mkctf (Pctf_val _3) ~attrs:(_2@_4) ~docs:(symbol_docs ()) ) +# 8582 "parsing/parser.ml" + : 'class_sig_field)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 5 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'private_virtual_flags) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : 'label) in + let _6 = (Parsing.peek_val __caml_parser_env 1 : 'poly_type) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1197 "parsing/parser.mly" + ( + let (p, v) = _3 in + mkctf (Pctf_method (mkrhs _4 4, p, v, _6)) ~attrs:(_2@_7) ~docs:(symbol_docs ()) + ) +# 8596 "parsing/parser.ml" + : 'class_sig_field)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'constrain_field) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1202 "parsing/parser.mly" + ( mkctf (Pctf_constraint _3) ~attrs:(_2@_4) ~docs:(symbol_docs ()) ) +# 8605 "parsing/parser.ml" + : 'class_sig_field)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'item_extension) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1204 "parsing/parser.mly" + ( mkctf (Pctf_extension _1) ~attrs:_2 ~docs:(symbol_docs ()) ) +# 8613 "parsing/parser.ml" + : 'class_sig_field)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'floating_attribute) in + Obj.repr( +# 1206 "parsing/parser.mly" + ( mark_symbol_docs (); + mkctf(Pctf_attribute _1) ) +# 8621 "parsing/parser.ml" + : 'class_sig_field)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'mutable_flag) in + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'label) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in + Obj.repr( +# 1211 "parsing/parser.mly" + ( mkrhs _3 3, _2, Virtual, _5 ) +# 8630 "parsing/parser.ml" + : 'value_type)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'virtual_flag) in + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'label) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in + Obj.repr( +# 1213 "parsing/parser.mly" + ( mkrhs _3 3, Mutable, _2, _5 ) +# 8639 "parsing/parser.ml" + : 'value_type)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'label) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in + Obj.repr( +# 1215 "parsing/parser.mly" + ( mkrhs _1 1, Immutable, Concrete, _3 ) +# 8647 "parsing/parser.ml" + : 'value_type)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'core_type) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in + Obj.repr( +# 1218 "parsing/parser.mly" + ( _1, _3, symbol_rloc() ) +# 8655 "parsing/parser.ml" + : 'constrain)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'core_type) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in + Obj.repr( +# 1221 "parsing/parser.mly" + ( _1, _3 ) +# 8663 "parsing/parser.ml" + : 'constrain_field)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'class_description) in + Obj.repr( +# 1225 "parsing/parser.mly" + ( let (body, ext) = _1 in ([body],ext) ) +# 8670 "parsing/parser.ml" + : 'class_descriptions)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'class_descriptions) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'and_class_description) in + Obj.repr( +# 1227 "parsing/parser.mly" + ( let (l, ext) = _1 in (_2 :: l, ext) ) +# 8678 "parsing/parser.ml" + : 'class_descriptions)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 6 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 5 : 'virtual_flag) in + let _4 = (Parsing.peek_val __caml_parser_env 4 : 'class_type_parameters) in + let _5 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _7 = (Parsing.peek_val __caml_parser_env 1 : 'class_type) in + let _8 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1232 "parsing/parser.mly" + ( let (ext, attrs) = _2 in + Ci.mk (mkrhs _5 5) _7 ~virt:_3 ~params:_4 ~attrs:(attrs @ _8) + ~loc:(symbol_rloc ()) ~docs:(symbol_docs ()) + , ext ) +# 8693 "parsing/parser.ml" + : 'class_description)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 6 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 5 : 'virtual_flag) in + let _4 = (Parsing.peek_val __caml_parser_env 4 : 'class_type_parameters) in + let _5 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _7 = (Parsing.peek_val __caml_parser_env 1 : 'class_type) in + let _8 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1240 "parsing/parser.mly" + ( Ci.mk (mkrhs _5 5) _7 ~virt:_3 ~params:_4 + ~attrs:(_2@_8) ~loc:(symbol_rloc ()) + ~text:(symbol_text ()) ~docs:(symbol_docs ()) ) +# 8707 "parsing/parser.ml" + : 'and_class_description)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'class_type_declaration) in + Obj.repr( +# 1246 "parsing/parser.mly" + ( let (body, ext) = _1 in ([body],ext) ) +# 8714 "parsing/parser.ml" + : 'class_type_declarations)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'class_type_declarations) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'and_class_type_declaration) in + Obj.repr( +# 1248 "parsing/parser.mly" + ( let (l, ext) = _1 in (_2 :: l, ext) ) +# 8722 "parsing/parser.ml" + : 'class_type_declarations)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 6 : 'ext_attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 5 : 'virtual_flag) in + let _5 = (Parsing.peek_val __caml_parser_env 4 : 'class_type_parameters) in + let _6 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _8 = (Parsing.peek_val __caml_parser_env 1 : 'class_signature) in + let _9 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1253 "parsing/parser.mly" + ( let (ext, attrs) = _3 in + Ci.mk (mkrhs _6 6) _8 ~virt:_4 ~params:_5 ~attrs:(attrs@_9) + ~loc:(symbol_rloc ()) ~docs:(symbol_docs ()) + , ext) +# 8737 "parsing/parser.ml" + : 'class_type_declaration)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 6 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 5 : 'virtual_flag) in + let _4 = (Parsing.peek_val __caml_parser_env 4 : 'class_type_parameters) in + let _5 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _7 = (Parsing.peek_val __caml_parser_env 1 : 'class_signature) in + let _8 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1261 "parsing/parser.mly" + ( Ci.mk (mkrhs _5 5) _7 ~virt:_3 ~params:_4 + ~attrs:(_2@_8) ~loc:(symbol_rloc ()) + ~text:(symbol_text ()) ~docs:(symbol_docs ()) ) +# 8751 "parsing/parser.ml" + : 'and_class_type_declaration)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1269 "parsing/parser.mly" + ( _1 ) +# 8758 "parsing/parser.ml" + : 'seq_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in + Obj.repr( +# 1270 "parsing/parser.mly" + ( _1 ) +# 8765 "parsing/parser.ml" + : 'seq_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1271 "parsing/parser.mly" + ( mkexp(Pexp_sequence(_1, _3)) ) +# 8773 "parsing/parser.ml" + : 'seq_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'expr) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'attr_id) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1273 "parsing/parser.mly" + ( let seq = mkexp(Pexp_sequence (_1, _5)) in + let payload = PStr [mkstrexp seq []] in + mkexp (Pexp_extension (_4, payload)) ) +# 8784 "parsing/parser.ml" + : 'seq_expr)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'label_let_pattern) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'opt_default) in + Obj.repr( +# 1279 "parsing/parser.mly" + ( (Optional (fst _3), _4, snd _3) ) +# 8792 "parsing/parser.ml" + : 'labeled_simple_pattern)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'label_var) in + Obj.repr( +# 1281 "parsing/parser.mly" + ( (Optional (fst _2), None, snd _2) ) +# 8799 "parsing/parser.ml" + : 'labeled_simple_pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : string) in + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'let_pattern) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'opt_default) in + Obj.repr( +# 1283 "parsing/parser.mly" + ( (Optional _1, _4, _3) ) +# 8808 "parsing/parser.ml" + : 'labeled_simple_pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : string) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'pattern_var) in + Obj.repr( +# 1285 "parsing/parser.mly" + ( (Optional _1, None, _2) ) +# 8816 "parsing/parser.ml" + : 'labeled_simple_pattern)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'label_let_pattern) in + Obj.repr( +# 1287 "parsing/parser.mly" + ( (Labelled (fst _3), None, snd _3) ) +# 8823 "parsing/parser.ml" + : 'labeled_simple_pattern)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'label_var) in + Obj.repr( +# 1289 "parsing/parser.mly" + ( (Labelled (fst _2), None, snd _2) ) +# 8830 "parsing/parser.ml" + : 'labeled_simple_pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : string) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'simple_pattern) in + Obj.repr( +# 1291 "parsing/parser.mly" + ( (Labelled _1, None, _2) ) +# 8838 "parsing/parser.ml" + : 'labeled_simple_pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_pattern) in + Obj.repr( +# 1293 "parsing/parser.mly" + ( (Nolabel, None, _1) ) +# 8845 "parsing/parser.ml" + : 'labeled_simple_pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 1296 "parsing/parser.mly" + ( mkpat(Ppat_var (mkrhs _1 1)) ) +# 8852 "parsing/parser.ml" + : 'pattern_var)) +; (fun __caml_parser_env -> + Obj.repr( +# 1297 "parsing/parser.mly" + ( mkpat Ppat_any ) +# 8858 "parsing/parser.ml" + : 'pattern_var)) +; (fun __caml_parser_env -> + Obj.repr( +# 1300 "parsing/parser.mly" + ( None ) +# 8864 "parsing/parser.ml" + : 'opt_default)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1301 "parsing/parser.mly" + ( Some _2 ) +# 8871 "parsing/parser.ml" + : 'opt_default)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'label_var) in + Obj.repr( +# 1305 "parsing/parser.mly" + ( _1 ) +# 8878 "parsing/parser.ml" + : 'label_let_pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'label_var) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in + Obj.repr( +# 1307 "parsing/parser.mly" + ( let (lab, pat) = _1 in (lab, mkpat(Ppat_constraint(pat, _3))) ) +# 8886 "parsing/parser.ml" + : 'label_let_pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 1310 "parsing/parser.mly" + ( (_1, mkpat(Ppat_var (mkrhs _1 1))) ) +# 8893 "parsing/parser.ml" + : 'label_var)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in + Obj.repr( +# 1314 "parsing/parser.mly" + ( _1 ) +# 8900 "parsing/parser.ml" + : 'let_pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in + Obj.repr( +# 1316 "parsing/parser.mly" + ( mkpat(Ppat_constraint(_1, _3)) ) +# 8908 "parsing/parser.ml" + : 'let_pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in + Obj.repr( +# 1320 "parsing/parser.mly" + ( _1 ) +# 8915 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'simple_expr) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'simple_labeled_expr_list) in + Obj.repr( +# 1322 "parsing/parser.mly" + ( mkexp(Pexp_apply(_1, List.rev _2)) ) +# 8923 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'let_bindings) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1324 "parsing/parser.mly" + ( expr_of_let_bindings _1 _3 ) +# 8931 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _5 = (Parsing.peek_val __caml_parser_env 2 : 'module_binding_body) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1326 "parsing/parser.mly" + ( mkexp_attrs (Pexp_letmodule(mkrhs _4 4, _5, _7)) _3 ) +# 8941 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 3 : 'ext_attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 2 : 'let_exception_declaration) in + let _6 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1328 "parsing/parser.mly" + ( mkexp_attrs (Pexp_letexception(_4, _6)) _3 ) +# 8950 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'override_flag) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : 'ext_attributes) in + let _5 = (Parsing.peek_val __caml_parser_env 2 : 'mod_longident) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1330 "parsing/parser.mly" + ( mkexp_attrs (Pexp_open(_3, mkrhs _5 5, _7)) _4 ) +# 8960 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'opt_bar) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'match_cases) in + Obj.repr( +# 1332 "parsing/parser.mly" + ( mkexp_attrs (Pexp_function(List.rev _4)) _2 ) +# 8969 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'labeled_simple_pattern) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'fun_def) in + Obj.repr( +# 1334 "parsing/parser.mly" + ( let (l,o,p) = _3 in + mkexp_attrs (Pexp_fun(l, o, p, _4)) _2 ) +# 8979 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 5 : 'ext_attributes) in + let _5 = (Parsing.peek_val __caml_parser_env 2 : 'lident_list) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'fun_def) in + Obj.repr( +# 1337 "parsing/parser.mly" + ( mkexp_attrs (mk_newtypes _5 _7).pexp_desc _2 ) +# 8988 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 3 : 'seq_expr) in + let _5 = (Parsing.peek_val __caml_parser_env 1 : 'opt_bar) in + let _6 = (Parsing.peek_val __caml_parser_env 0 : 'match_cases) in + Obj.repr( +# 1339 "parsing/parser.mly" + ( mkexp_attrs (Pexp_match(_3, List.rev _6)) _2 ) +# 8998 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 3 : 'seq_expr) in + let _5 = (Parsing.peek_val __caml_parser_env 1 : 'opt_bar) in + let _6 = (Parsing.peek_val __caml_parser_env 0 : 'match_cases) in + Obj.repr( +# 1341 "parsing/parser.mly" + ( mkexp_attrs (Pexp_try(_3, List.rev _6)) _2 ) +# 9008 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'seq_expr) in + Obj.repr( +# 1343 "parsing/parser.mly" + ( syntax_error() ) +# 9016 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'expr_comma_list) in + Obj.repr( +# 1345 "parsing/parser.mly" + ( mkexp(Pexp_tuple(List.rev _1)) ) +# 9023 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'constr_longident) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in + Obj.repr( +# 1347 "parsing/parser.mly" + ( mkexp(Pexp_construct(mkrhs _1 1, Some _2)) ) +# 9031 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'name_tag) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in + Obj.repr( +# 1349 "parsing/parser.mly" + ( mkexp(Pexp_variant(_1, Some _2)) ) +# 9039 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 5 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'seq_expr) in + let _5 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1351 "parsing/parser.mly" + ( mkexp_attrs(Pexp_ifthenelse(_3, _5, Some _7)) _2 ) +# 9049 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'seq_expr) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1353 "parsing/parser.mly" + ( mkexp_attrs (Pexp_ifthenelse(_3, _5, None)) _2 ) +# 9058 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 3 : 'seq_expr) in + let _5 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in + Obj.repr( +# 1355 "parsing/parser.mly" + ( mkexp_attrs (Pexp_while(_3, _5)) _2 ) +# 9067 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 8 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 7 : 'pattern) in + let _5 = (Parsing.peek_val __caml_parser_env 5 : 'seq_expr) in + let _6 = (Parsing.peek_val __caml_parser_env 4 : 'direction_flag) in + let _7 = (Parsing.peek_val __caml_parser_env 3 : 'seq_expr) in + let _9 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in + Obj.repr( +# 1358 "parsing/parser.mly" + ( mkexp_attrs(Pexp_for(_3, _5, _7, _6, _9)) _2 ) +# 9079 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1360 "parsing/parser.mly" + ( mkexp_cons (rhs_loc 2) (ghexp(Pexp_tuple[_1;_3])) (symbol_rloc()) ) +# 9087 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _2 = (Parsing.peek_val __caml_parser_env 1 : string) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1362 "parsing/parser.mly" + ( mkinfix _1 _2 _3 ) +# 9096 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _2 = (Parsing.peek_val __caml_parser_env 1 : string) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1364 "parsing/parser.mly" + ( mkinfix _1 _2 _3 ) +# 9105 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _2 = (Parsing.peek_val __caml_parser_env 1 : string) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1366 "parsing/parser.mly" + ( mkinfix _1 _2 _3 ) +# 9114 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _2 = (Parsing.peek_val __caml_parser_env 1 : string) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1368 "parsing/parser.mly" + ( mkinfix _1 _2 _3 ) +# 9123 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _2 = (Parsing.peek_val __caml_parser_env 1 : string) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1370 "parsing/parser.mly" + ( mkinfix _1 _2 _3 ) +# 9132 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1372 "parsing/parser.mly" + ( mkinfix _1 "+" _3 ) +# 9140 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1374 "parsing/parser.mly" + ( mkinfix _1 "+." _3 ) +# 9148 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1376 "parsing/parser.mly" + ( mkinfix _1 "+=" _3 ) +# 9156 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1378 "parsing/parser.mly" + ( mkinfix _1 "-" _3 ) +# 9164 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1380 "parsing/parser.mly" + ( mkinfix _1 "-." _3 ) +# 9172 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1382 "parsing/parser.mly" + ( mkinfix _1 "*" _3 ) +# 9180 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1384 "parsing/parser.mly" + ( mkinfix _1 "%" _3 ) +# 9188 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1386 "parsing/parser.mly" + ( mkinfix _1 "=" _3 ) +# 9196 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1388 "parsing/parser.mly" + ( mkinfix _1 "<" _3 ) +# 9204 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1390 "parsing/parser.mly" + ( mkinfix _1 ">" _3 ) +# 9212 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1392 "parsing/parser.mly" + ( mkinfix _1 "or" _3 ) +# 9220 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1394 "parsing/parser.mly" + ( mkinfix _1 "||" _3 ) +# 9228 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1396 "parsing/parser.mly" + ( mkinfix _1 "&" _3 ) +# 9236 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1398 "parsing/parser.mly" + ( mkinfix _1 "&&" _3 ) +# 9244 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1400 "parsing/parser.mly" + ( mkinfix _1 ":=" _3 ) +# 9252 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'subtractive) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1402 "parsing/parser.mly" + ( mkuminus _1 _2 ) +# 9260 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'additive) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1404 "parsing/parser.mly" + ( mkuplus _1 _2 ) +# 9268 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'label_longident) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1406 "parsing/parser.mly" + ( mkexp(Pexp_setfield(_1, mkrhs _3 3, _5)) ) +# 9277 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : 'seq_expr) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1408 "parsing/parser.mly" + ( mkexp(Pexp_apply(ghexp(Pexp_ident(array_function "Array" "set")), + [Nolabel,_1; Nolabel,_4; Nolabel,_7])) ) +# 9287 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : 'seq_expr) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1411 "parsing/parser.mly" + ( mkexp(Pexp_apply(ghexp(Pexp_ident(array_function "String" "set")), + [Nolabel,_1; Nolabel,_4; Nolabel,_7])) ) +# 9297 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : 'expr) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1414 "parsing/parser.mly" + ( bigarray_set _1 _4 _7 ) +# 9306 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in + let _2 = (Parsing.peek_val __caml_parser_env 5 : string) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : 'expr) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1416 "parsing/parser.mly" + ( let id = mkexp @@ Pexp_ident( ghloc @@ Lident ("." ^ _2 ^ "[]<-")) in + mkexp @@ Pexp_apply(id , [Nolabel, _1; Nolabel, _4; Nolabel, _7]) ) +# 9317 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in + let _2 = (Parsing.peek_val __caml_parser_env 5 : string) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : 'expr) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1419 "parsing/parser.mly" + ( let id = mkexp @@ Pexp_ident( ghloc @@ Lident ("." ^ _2 ^ "()<-")) in + mkexp @@ Pexp_apply(id , [Nolabel, _1; Nolabel, _4; Nolabel, _7]) ) +# 9328 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in + let _2 = (Parsing.peek_val __caml_parser_env 5 : string) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : 'expr) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1422 "parsing/parser.mly" + ( let id = mkexp @@ Pexp_ident( ghloc @@ Lident ("." ^ _2 ^ "{}<-")) in + mkexp @@ Pexp_apply(id , [Nolabel, _1; Nolabel, _4; Nolabel, _7]) ) +# 9339 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 8 : 'simple_expr) in + let _3 = (Parsing.peek_val __caml_parser_env 6 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 5 : string) in + let _6 = (Parsing.peek_val __caml_parser_env 3 : 'expr) in + let _9 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1425 "parsing/parser.mly" + ( let id = mkexp @@ Pexp_ident( ghloc @@ Ldot(_3,"." ^ _4 ^ "[]<-")) in + mkexp @@ Pexp_apply(id , [Nolabel, _1; Nolabel, _6; Nolabel, _9]) ) +# 9351 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 8 : 'simple_expr) in + let _3 = (Parsing.peek_val __caml_parser_env 6 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 5 : string) in + let _6 = (Parsing.peek_val __caml_parser_env 3 : 'expr) in + let _9 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1428 "parsing/parser.mly" + ( let id = mkexp @@ Pexp_ident( ghloc @@ Ldot(_3, "." ^ _4 ^ "()<-")) in + mkexp @@ Pexp_apply(id , [Nolabel, _1; Nolabel, _6; Nolabel, _9]) ) +# 9363 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 8 : 'simple_expr) in + let _3 = (Parsing.peek_val __caml_parser_env 6 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 5 : string) in + let _6 = (Parsing.peek_val __caml_parser_env 3 : 'expr) in + let _9 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1431 "parsing/parser.mly" + ( let id = mkexp @@ Pexp_ident( ghloc @@ Ldot(_3, "." ^ _4 ^ "{}<-")) in + mkexp @@ Pexp_apply(id , [Nolabel, _1; Nolabel, _6; Nolabel, _9]) ) +# 9375 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'label) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1434 "parsing/parser.mly" + ( mkexp(Pexp_setinstvar(mkrhs _1 1, _3)) ) +# 9383 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in + Obj.repr( +# 1436 "parsing/parser.mly" + ( mkexp_attrs (Pexp_assert _3) _2 ) +# 9391 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in + Obj.repr( +# 1438 "parsing/parser.mly" + ( mkexp_attrs (Pexp_lazy _3) _2 ) +# 9399 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'class_structure) in + Obj.repr( +# 1440 "parsing/parser.mly" + ( mkexp_attrs (Pexp_object _3) _2 ) +# 9407 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'class_structure) in + Obj.repr( +# 1442 "parsing/parser.mly" + ( unclosed "object" 1 "end" 4 ) +# 9415 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attribute) in + Obj.repr( +# 1444 "parsing/parser.mly" + ( Exp.attr _1 _2 ) +# 9423 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + Obj.repr( +# 1446 "parsing/parser.mly" + ( not_expecting 1 "wildcard \"_\"" ) +# 9429 "parsing/parser.ml" + : 'expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'val_longident) in + Obj.repr( +# 1450 "parsing/parser.mly" + ( mkexp(Pexp_ident (mkrhs _1 1)) ) +# 9436 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'constant) in + Obj.repr( +# 1452 "parsing/parser.mly" + ( mkexp(Pexp_constant _1) ) +# 9443 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'constr_longident) in + Obj.repr( +# 1454 "parsing/parser.mly" + ( mkexp(Pexp_construct(mkrhs _1 1, None)) ) +# 9450 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'name_tag) in + Obj.repr( +# 1456 "parsing/parser.mly" + ( mkexp(Pexp_variant(_1, None)) ) +# 9457 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in + Obj.repr( +# 1458 "parsing/parser.mly" + ( reloc_exp _2 ) +# 9464 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in + Obj.repr( +# 1460 "parsing/parser.mly" + ( unclosed "(" 1 ")" 3 ) +# 9471 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in + Obj.repr( +# 1462 "parsing/parser.mly" + ( wrap_exp_attrs (reloc_exp _3) _2 (* check location *) ) +# 9479 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ext_attributes) in + Obj.repr( +# 1464 "parsing/parser.mly" + ( mkexp_attrs (Pexp_construct (mkloc (Lident "()") (symbol_rloc ()), + None)) _2 ) +# 9487 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in + Obj.repr( +# 1467 "parsing/parser.mly" + ( unclosed "begin" 1 "end" 4 ) +# 9495 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'seq_expr) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'type_constraint) in + Obj.repr( +# 1469 "parsing/parser.mly" + ( mkexp_constraint _2 _3 ) +# 9503 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'simple_expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'label_longident) in + Obj.repr( +# 1471 "parsing/parser.mly" + ( mkexp(Pexp_field(_1, mkrhs _3 3)) ) +# 9511 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in + Obj.repr( +# 1473 "parsing/parser.mly" + ( mkexp(Pexp_open(Fresh, mkrhs _1 1, _4)) ) +# 9519 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 3 : 'mod_longident) in + Obj.repr( +# 1475 "parsing/parser.mly" + ( mkexp(Pexp_open(Fresh, mkrhs _1 1, + mkexp(Pexp_construct(mkrhs (Lident "()") 1, None)))) ) +# 9527 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in + Obj.repr( +# 1478 "parsing/parser.mly" + ( unclosed "(" 3 ")" 5 ) +# 9535 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in + Obj.repr( +# 1480 "parsing/parser.mly" + ( mkexp(Pexp_apply(ghexp(Pexp_ident(array_function "Array" "get")), + [Nolabel,_1; Nolabel,_4])) ) +# 9544 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in + Obj.repr( +# 1483 "parsing/parser.mly" + ( unclosed "(" 3 ")" 5 ) +# 9552 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in + Obj.repr( +# 1485 "parsing/parser.mly" + ( mkexp(Pexp_apply(ghexp(Pexp_ident(array_function "String" "get")), + [Nolabel,_1; Nolabel,_4])) ) +# 9561 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'seq_expr) in + Obj.repr( +# 1488 "parsing/parser.mly" + ( unclosed "[" 3 "]" 5 ) +# 9569 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in + let _2 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in + Obj.repr( +# 1490 "parsing/parser.mly" + ( let id = mkexp @@ Pexp_ident( ghloc @@ Lident ("." ^ _2 ^ "[]")) in + mkexp @@ Pexp_apply(id, [Nolabel, _1; Nolabel, _4]) ) +# 9579 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in + let _2 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in + Obj.repr( +# 1493 "parsing/parser.mly" + ( unclosed "[" 3 "]" 5 ) +# 9588 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in + let _2 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in + Obj.repr( +# 1495 "parsing/parser.mly" + ( let id = mkexp @@ Pexp_ident( ghloc @@ Lident ("." ^ _2 ^ "()")) in + mkexp @@ Pexp_apply(id, [Nolabel, _1; Nolabel, _4]) ) +# 9598 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in + let _2 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in + Obj.repr( +# 1498 "parsing/parser.mly" + ( unclosed "(" 3 ")" 5 ) +# 9607 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in + let _2 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in + Obj.repr( +# 1500 "parsing/parser.mly" + ( let id = mkexp @@ Pexp_ident( ghloc @@ Lident ("." ^ _2 ^ "{}")) in + mkexp @@ Pexp_apply(id, [Nolabel, _1; Nolabel, _4]) ) +# 9617 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in + let _2 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in + Obj.repr( +# 1503 "parsing/parser.mly" + ( unclosed "{" 3 "}" 5 ) +# 9626 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _6 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in + Obj.repr( +# 1505 "parsing/parser.mly" + ( let id = mkexp @@ Pexp_ident( ghloc @@ Ldot(_3, "." ^ _4 ^ "[]")) in + mkexp @@ Pexp_apply(id, [Nolabel, _1; Nolabel, _6]) ) +# 9637 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _6 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in + Obj.repr( +# 1508 "parsing/parser.mly" + ( unclosed "[" 5 "]" 7 ) +# 9647 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _6 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in + Obj.repr( +# 1510 "parsing/parser.mly" + ( let id = mkexp @@ Pexp_ident( ghloc @@ Ldot(_3, "." ^ _4 ^ "()")) in + mkexp @@ Pexp_apply(id, [Nolabel, _1; Nolabel, _6]) ) +# 9658 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _6 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in + Obj.repr( +# 1513 "parsing/parser.mly" + ( unclosed "(" 5 ")" 7 ) +# 9668 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _6 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in + Obj.repr( +# 1515 "parsing/parser.mly" + ( let id = mkexp @@ Pexp_ident( ghloc @@ Ldot(_3, "." ^ _4 ^ "{}")) in + mkexp @@ Pexp_apply(id, [Nolabel, _1; Nolabel, _6]) ) +# 9679 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 6 : 'simple_expr) in + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _6 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in + Obj.repr( +# 1518 "parsing/parser.mly" + ( unclosed "{" 5 "}" 7 ) +# 9689 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'expr) in + Obj.repr( +# 1520 "parsing/parser.mly" + ( bigarray_get _1 _4 ) +# 9697 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_expr) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'expr_comma_list) in + Obj.repr( +# 1522 "parsing/parser.mly" + ( unclosed "{" 3 "}" 5 ) +# 9705 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'record_expr) in + Obj.repr( +# 1524 "parsing/parser.mly" + ( let (exten, fields) = _2 in mkexp (Pexp_record(fields, exten)) ) +# 9712 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'record_expr) in + Obj.repr( +# 1526 "parsing/parser.mly" + ( unclosed "{" 1 "}" 3 ) +# 9719 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'record_expr) in + Obj.repr( +# 1528 "parsing/parser.mly" + ( let (exten, fields) = _4 in + let rec_exp = mkexp(Pexp_record(fields, exten)) in + mkexp(Pexp_open(Fresh, mkrhs _1 1, rec_exp)) ) +# 9729 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'record_expr) in + Obj.repr( +# 1532 "parsing/parser.mly" + ( unclosed "{" 3 "}" 5 ) +# 9737 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'expr_semi_list) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in + Obj.repr( +# 1534 "parsing/parser.mly" + ( mkexp (Pexp_array(List.rev _2)) ) +# 9745 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'expr_semi_list) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in + Obj.repr( +# 1536 "parsing/parser.mly" + ( unclosed "[|" 1 "|]" 4 ) +# 9753 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + Obj.repr( +# 1538 "parsing/parser.mly" + ( mkexp (Pexp_array []) ) +# 9759 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 5 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 2 : 'expr_semi_list) in + let _5 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in + Obj.repr( +# 1540 "parsing/parser.mly" + ( mkexp(Pexp_open(Fresh, mkrhs _1 1, mkexp(Pexp_array(List.rev _4)))) ) +# 9768 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 3 : 'mod_longident) in + Obj.repr( +# 1542 "parsing/parser.mly" + ( mkexp(Pexp_open(Fresh, mkrhs _1 1, mkexp(Pexp_array []))) ) +# 9775 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 5 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 2 : 'expr_semi_list) in + let _5 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in + Obj.repr( +# 1544 "parsing/parser.mly" + ( unclosed "[|" 3 "|]" 6 ) +# 9784 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'expr_semi_list) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in + Obj.repr( +# 1546 "parsing/parser.mly" + ( reloc_exp (mktailexp (rhs_loc 4) (List.rev _2)) ) +# 9792 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'expr_semi_list) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in + Obj.repr( +# 1548 "parsing/parser.mly" + ( unclosed "[" 1 "]" 4 ) +# 9800 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 5 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 2 : 'expr_semi_list) in + let _5 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in + Obj.repr( +# 1550 "parsing/parser.mly" + ( let list_exp = reloc_exp (mktailexp (rhs_loc 6) (List.rev _4)) in + mkexp(Pexp_open(Fresh, mkrhs _1 1, list_exp)) ) +# 9810 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 3 : 'mod_longident) in + Obj.repr( +# 1553 "parsing/parser.mly" + ( mkexp(Pexp_open(Fresh, mkrhs _1 1, + mkexp(Pexp_construct(mkrhs (Lident "[]") 1, None)))) ) +# 9818 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 5 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 2 : 'expr_semi_list) in + let _5 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in + Obj.repr( +# 1556 "parsing/parser.mly" + ( unclosed "[" 3 "]" 6 ) +# 9827 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : string) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in + Obj.repr( +# 1558 "parsing/parser.mly" + ( mkexp(Pexp_apply(mkoperator _1 1, [Nolabel,_2])) ) +# 9835 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in + Obj.repr( +# 1560 "parsing/parser.mly" + ( mkexp(Pexp_apply(mkoperator "!" 1, [Nolabel,_2])) ) +# 9842 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'class_longident) in + Obj.repr( +# 1562 "parsing/parser.mly" + ( mkexp_attrs (Pexp_new(mkrhs _3 3)) _2 ) +# 9850 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'field_expr_list) in + Obj.repr( +# 1564 "parsing/parser.mly" + ( mkexp (Pexp_override _2) ) +# 9857 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'field_expr_list) in + Obj.repr( +# 1566 "parsing/parser.mly" + ( unclosed "{<" 1 ">}" 3 ) +# 9864 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + Obj.repr( +# 1568 "parsing/parser.mly" + ( mkexp (Pexp_override [])) +# 9870 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'field_expr_list) in + Obj.repr( +# 1570 "parsing/parser.mly" + ( mkexp(Pexp_open(Fresh, mkrhs _1 1, mkexp (Pexp_override _4)))) +# 9878 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 3 : 'mod_longident) in + Obj.repr( +# 1572 "parsing/parser.mly" + ( mkexp(Pexp_open(Fresh, mkrhs _1 1, mkexp (Pexp_override [])))) +# 9885 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'field_expr_list) in + Obj.repr( +# 1574 "parsing/parser.mly" + ( unclosed "{<" 3 ">}" 5 ) +# 9893 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'simple_expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'label) in + Obj.repr( +# 1576 "parsing/parser.mly" + ( mkexp(Pexp_send(_1, mkrhs _3 3)) ) +# 9901 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'simple_expr) in + let _2 = (Parsing.peek_val __caml_parser_env 1 : string) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in + Obj.repr( +# 1578 "parsing/parser.mly" + ( mkinfix _1 _2 _3 ) +# 9910 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'module_expr) in + Obj.repr( +# 1580 "parsing/parser.mly" + ( mkexp_attrs (Pexp_pack _4) _3 ) +# 9918 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : 'module_expr) in + let _6 = (Parsing.peek_val __caml_parser_env 1 : 'package_type) in + Obj.repr( +# 1582 "parsing/parser.mly" + ( mkexp_attrs (Pexp_constraint (ghexp (Pexp_pack _4), + ghtyp (Ptyp_package _6))) + _3 ) +# 9929 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 3 : 'ext_attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 2 : 'module_expr) in + Obj.repr( +# 1586 "parsing/parser.mly" + ( unclosed "(" 1 ")" 6 ) +# 9937 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 8 : 'mod_longident) in + let _5 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in + let _6 = (Parsing.peek_val __caml_parser_env 3 : 'module_expr) in + let _8 = (Parsing.peek_val __caml_parser_env 1 : 'package_type) in + Obj.repr( +# 1589 "parsing/parser.mly" + ( mkexp(Pexp_open(Fresh, mkrhs _1 1, + mkexp_attrs (Pexp_constraint (ghexp (Pexp_pack _6), + ghtyp (Ptyp_package _8))) + _5 )) ) +# 9950 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 7 : 'mod_longident) in + let _5 = (Parsing.peek_val __caml_parser_env 3 : 'ext_attributes) in + let _6 = (Parsing.peek_val __caml_parser_env 2 : 'module_expr) in + Obj.repr( +# 1594 "parsing/parser.mly" + ( unclosed "(" 3 ")" 8 ) +# 9959 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'extension) in + Obj.repr( +# 1596 "parsing/parser.mly" + ( mkexp (Pexp_extension _1) ) +# 9966 "parsing/parser.ml" + : 'simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'labeled_simple_expr) in + Obj.repr( +# 1600 "parsing/parser.mly" + ( [_1] ) +# 9973 "parsing/parser.ml" + : 'simple_labeled_expr_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'simple_labeled_expr_list) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'labeled_simple_expr) in + Obj.repr( +# 1602 "parsing/parser.mly" + ( _2 :: _1 ) +# 9981 "parsing/parser.ml" + : 'simple_labeled_expr_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in + Obj.repr( +# 1606 "parsing/parser.mly" + ( (Nolabel, _1) ) +# 9988 "parsing/parser.ml" + : 'labeled_simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'label_expr) in + Obj.repr( +# 1608 "parsing/parser.mly" + ( _1 ) +# 9995 "parsing/parser.ml" + : 'labeled_simple_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : string) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in + Obj.repr( +# 1612 "parsing/parser.mly" + ( (Labelled _1, _2) ) +# 10003 "parsing/parser.ml" + : 'label_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'label_ident) in + Obj.repr( +# 1614 "parsing/parser.mly" + ( (Labelled (fst _2), snd _2) ) +# 10010 "parsing/parser.ml" + : 'label_expr)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'label_ident) in + Obj.repr( +# 1616 "parsing/parser.mly" + ( (Optional (fst _2), snd _2) ) +# 10017 "parsing/parser.ml" + : 'label_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : string) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'simple_expr) in + Obj.repr( +# 1618 "parsing/parser.mly" + ( (Optional _1, _2) ) +# 10025 "parsing/parser.ml" + : 'label_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 1621 "parsing/parser.mly" + ( (_1, mkexp(Pexp_ident(mkrhs (Lident _1) 1))) ) +# 10032 "parsing/parser.ml" + : 'label_ident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 1624 "parsing/parser.mly" + ( [mkrhs _1 1] ) +# 10039 "parsing/parser.ml" + : 'lident_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : string) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'lident_list) in + Obj.repr( +# 1625 "parsing/parser.mly" + ( mkrhs _1 1 :: _2 ) +# 10047 "parsing/parser.ml" + : 'lident_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'val_ident) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'strict_binding) in + Obj.repr( +# 1629 "parsing/parser.mly" + ( (mkpatvar _1 1, _2) ) +# 10055 "parsing/parser.ml" + : 'let_binding_body)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 3 : 'val_ident) in + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'type_constraint) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1631 "parsing/parser.mly" + ( let v = mkpatvar _1 1 in (* PR#7344 *) + let t = + match _2 with + Some t, None -> t + | _, Some t -> t + | _ -> assert false + in + (ghpat(Ppat_constraint(v, ghtyp(Ptyp_poly([],t)))), + mkexp_constraint _4 _2) ) +# 10072 "parsing/parser.ml" + : 'let_binding_body)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 6 : 'val_ident) in + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'typevar_list) in + let _5 = (Parsing.peek_val __caml_parser_env 2 : 'core_type) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1641 "parsing/parser.mly" + ( (ghpat(Ppat_constraint(mkpatvar _1 1, + ghtyp(Ptyp_poly(List.rev _3,_5)))), + _7) ) +# 10084 "parsing/parser.ml" + : 'let_binding_body)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 7 : 'val_ident) in + let _4 = (Parsing.peek_val __caml_parser_env 4 : 'lident_list) in + let _6 = (Parsing.peek_val __caml_parser_env 2 : 'core_type) in + let _8 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1645 "parsing/parser.mly" + ( let exp, poly = wrap_type_annotation _4 _6 _8 in + (ghpat(Ppat_constraint(mkpatvar _1 1, poly)), exp) ) +# 10095 "parsing/parser.ml" + : 'let_binding_body)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_no_exn) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1648 "parsing/parser.mly" + ( (_1, _3) ) +# 10103 "parsing/parser.ml" + : 'let_binding_body)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'simple_pattern_not_ident) in + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'core_type) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1650 "parsing/parser.mly" + ( (ghpat(Ppat_constraint(_1, _3)), _5) ) +# 10112 "parsing/parser.ml" + : 'let_binding_body)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'let_binding) in + Obj.repr( +# 1653 "parsing/parser.mly" + ( _1 ) +# 10119 "parsing/parser.ml" + : 'let_bindings)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'let_bindings) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'and_let_binding) in + Obj.repr( +# 1654 "parsing/parser.mly" + ( addlb _1 _2 ) +# 10127 "parsing/parser.ml" + : 'let_bindings)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'rec_flag) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'let_binding_body) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1658 "parsing/parser.mly" + ( let (ext, attr) = _2 in + mklbs ext _3 (mklb true _4 (attr@_5)) ) +# 10138 "parsing/parser.ml" + : 'let_binding)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'let_binding_body) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1663 "parsing/parser.mly" + ( mklb false _3 (_2@_4) ) +# 10147 "parsing/parser.ml" + : 'and_let_binding)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'strict_binding) in + Obj.repr( +# 1667 "parsing/parser.mly" + ( _1 ) +# 10154 "parsing/parser.ml" + : 'fun_binding)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'type_constraint) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1669 "parsing/parser.mly" + ( mkexp_constraint _3 _1 ) +# 10162 "parsing/parser.ml" + : 'fun_binding)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1673 "parsing/parser.mly" + ( _2 ) +# 10169 "parsing/parser.ml" + : 'strict_binding)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'labeled_simple_pattern) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'fun_binding) in + Obj.repr( +# 1675 "parsing/parser.mly" + ( let (l, o, p) = _1 in ghexp(Pexp_fun(l, o, p, _2)) ) +# 10177 "parsing/parser.ml" + : 'strict_binding)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'lident_list) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'fun_binding) in + Obj.repr( +# 1677 "parsing/parser.mly" + ( mk_newtypes _3 _5 ) +# 10185 "parsing/parser.ml" + : 'strict_binding)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'match_case) in + Obj.repr( +# 1680 "parsing/parser.mly" + ( [_1] ) +# 10192 "parsing/parser.ml" + : 'match_cases)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'match_cases) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'match_case) in + Obj.repr( +# 1681 "parsing/parser.mly" + ( _3 :: _1 ) +# 10200 "parsing/parser.ml" + : 'match_cases)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1685 "parsing/parser.mly" + ( Exp.case _1 _3 ) +# 10208 "parsing/parser.ml" + : 'match_case)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'pattern) in + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'seq_expr) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1687 "parsing/parser.mly" + ( Exp.case _1 ~guard:_3 _5 ) +# 10217 "parsing/parser.ml" + : 'match_case)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in + Obj.repr( +# 1689 "parsing/parser.mly" + ( Exp.case _1 (Exp.unreachable ~loc:(rhs_loc 3) ())) +# 10224 "parsing/parser.ml" + : 'match_case)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1693 "parsing/parser.mly" + ( _2 ) +# 10231 "parsing/parser.ml" + : 'fun_def)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'simple_core_type) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 1695 "parsing/parser.mly" + ( mkexp (Pexp_constraint (_4, _2)) ) +# 10239 "parsing/parser.ml" + : 'fun_def)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'labeled_simple_pattern) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'fun_def) in + Obj.repr( +# 1698 "parsing/parser.mly" + ( + let (l,o,p) = _1 in + ghexp(Pexp_fun(l, o, p, _2)) + ) +# 10250 "parsing/parser.ml" + : 'fun_def)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'lident_list) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'fun_def) in + Obj.repr( +# 1703 "parsing/parser.mly" + ( mk_newtypes _3 _5 ) +# 10258 "parsing/parser.ml" + : 'fun_def)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr_comma_list) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1706 "parsing/parser.mly" + ( _3 :: _1 ) +# 10266 "parsing/parser.ml" + : 'expr_comma_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1707 "parsing/parser.mly" + ( [_3; _1] ) +# 10274 "parsing/parser.ml" + : 'expr_comma_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'simple_expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'lbl_expr_list) in + Obj.repr( +# 1710 "parsing/parser.mly" + ( (Some _1, _3) ) +# 10282 "parsing/parser.ml" + : 'record_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'lbl_expr_list) in + Obj.repr( +# 1711 "parsing/parser.mly" + ( (None, _1) ) +# 10289 "parsing/parser.ml" + : 'record_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'lbl_expr) in + Obj.repr( +# 1714 "parsing/parser.mly" + ( [_1] ) +# 10296 "parsing/parser.ml" + : 'lbl_expr_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'lbl_expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'lbl_expr_list) in + Obj.repr( +# 1715 "parsing/parser.mly" + ( _1 :: _3 ) +# 10304 "parsing/parser.ml" + : 'lbl_expr_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'lbl_expr) in + Obj.repr( +# 1716 "parsing/parser.mly" + ( [_1] ) +# 10311 "parsing/parser.ml" + : 'lbl_expr_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 3 : 'label_longident) in + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'opt_type_constraint) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1720 "parsing/parser.mly" + ( (mkrhs _1 1, mkexp_opt_constraint _4 _2) ) +# 10320 "parsing/parser.ml" + : 'lbl_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'label_longident) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'opt_type_constraint) in + Obj.repr( +# 1722 "parsing/parser.mly" + ( (mkrhs _1 1, mkexp_opt_constraint (exp_of_label _1 1) _2) ) +# 10328 "parsing/parser.ml" + : 'lbl_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'field_expr) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'opt_semi) in + Obj.repr( +# 1725 "parsing/parser.mly" + ( [_1] ) +# 10336 "parsing/parser.ml" + : 'field_expr_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'field_expr) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'field_expr_list) in + Obj.repr( +# 1726 "parsing/parser.mly" + ( _1 :: _3 ) +# 10344 "parsing/parser.ml" + : 'field_expr_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'label) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1730 "parsing/parser.mly" + ( (mkrhs _1 1, _3) ) +# 10352 "parsing/parser.ml" + : 'field_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'label) in + Obj.repr( +# 1732 "parsing/parser.mly" + ( (mkrhs _1 1, exp_of_label (Lident _1) 1) ) +# 10359 "parsing/parser.ml" + : 'field_expr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1735 "parsing/parser.mly" + ( [_1] ) +# 10366 "parsing/parser.ml" + : 'expr_semi_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'expr_semi_list) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'expr) in + Obj.repr( +# 1736 "parsing/parser.mly" + ( _3 :: _1 ) +# 10374 "parsing/parser.ml" + : 'expr_semi_list)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in + Obj.repr( +# 1739 "parsing/parser.mly" + ( (Some _2, None) ) +# 10381 "parsing/parser.ml" + : 'type_constraint)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'core_type) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in + Obj.repr( +# 1740 "parsing/parser.mly" + ( (Some _2, Some _4) ) +# 10389 "parsing/parser.ml" + : 'type_constraint)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in + Obj.repr( +# 1741 "parsing/parser.mly" + ( (None, Some _2) ) +# 10396 "parsing/parser.ml" + : 'type_constraint)) +; (fun __caml_parser_env -> + Obj.repr( +# 1742 "parsing/parser.mly" + ( syntax_error() ) +# 10402 "parsing/parser.ml" + : 'type_constraint)) +; (fun __caml_parser_env -> + Obj.repr( +# 1743 "parsing/parser.mly" + ( syntax_error() ) +# 10408 "parsing/parser.ml" + : 'type_constraint)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'type_constraint) in + Obj.repr( +# 1746 "parsing/parser.mly" + ( Some _1 ) +# 10415 "parsing/parser.ml" + : 'opt_type_constraint)) +; (fun __caml_parser_env -> + Obj.repr( +# 1747 "parsing/parser.mly" + ( None ) +# 10421 "parsing/parser.ml" + : 'opt_type_constraint)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'val_ident) in + Obj.repr( +# 1754 "parsing/parser.mly" + ( mkpat(Ppat_alias(_1, mkrhs _3 3)) ) +# 10429 "parsing/parser.ml" + : 'pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in + Obj.repr( +# 1756 "parsing/parser.mly" + ( expecting 3 "identifier" ) +# 10436 "parsing/parser.ml" + : 'pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'pattern_comma_list) in + Obj.repr( +# 1758 "parsing/parser.mly" + ( mkpat(Ppat_tuple(List.rev _1)) ) +# 10443 "parsing/parser.ml" + : 'pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in + Obj.repr( +# 1760 "parsing/parser.mly" + ( mkpat_cons (rhs_loc 2) (ghpat(Ppat_tuple[_1;_3])) (symbol_rloc()) ) +# 10451 "parsing/parser.ml" + : 'pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in + Obj.repr( +# 1762 "parsing/parser.mly" + ( expecting 3 "pattern" ) +# 10458 "parsing/parser.ml" + : 'pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in + Obj.repr( +# 1764 "parsing/parser.mly" + ( mkpat(Ppat_or(_1, _3)) ) +# 10466 "parsing/parser.ml" + : 'pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in + Obj.repr( +# 1766 "parsing/parser.mly" + ( expecting 3 "pattern" ) +# 10473 "parsing/parser.ml" + : 'pattern)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in + Obj.repr( +# 1768 "parsing/parser.mly" + ( mkpat_attrs (Ppat_exception _3) _2) +# 10481 "parsing/parser.ml" + : 'pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'pattern) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attribute) in + Obj.repr( +# 1770 "parsing/parser.mly" + ( Pat.attr _1 _2 ) +# 10489 "parsing/parser.ml" + : 'pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'pattern_gen) in + Obj.repr( +# 1771 "parsing/parser.mly" + ( _1 ) +# 10496 "parsing/parser.ml" + : 'pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_no_exn) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'val_ident) in + Obj.repr( +# 1775 "parsing/parser.mly" + ( mkpat(Ppat_alias(_1, mkrhs _3 3)) ) +# 10504 "parsing/parser.ml" + : 'pattern_no_exn)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_no_exn) in + Obj.repr( +# 1777 "parsing/parser.mly" + ( expecting 3 "identifier" ) +# 10511 "parsing/parser.ml" + : 'pattern_no_exn)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'pattern_no_exn_comma_list) in + Obj.repr( +# 1779 "parsing/parser.mly" + ( mkpat(Ppat_tuple(List.rev _1)) ) +# 10518 "parsing/parser.ml" + : 'pattern_no_exn)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_no_exn) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in + Obj.repr( +# 1781 "parsing/parser.mly" + ( mkpat_cons (rhs_loc 2) (ghpat(Ppat_tuple[_1;_3])) (symbol_rloc()) ) +# 10526 "parsing/parser.ml" + : 'pattern_no_exn)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_no_exn) in + Obj.repr( +# 1783 "parsing/parser.mly" + ( expecting 3 "pattern" ) +# 10533 "parsing/parser.ml" + : 'pattern_no_exn)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_no_exn) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in + Obj.repr( +# 1785 "parsing/parser.mly" + ( mkpat(Ppat_or(_1, _3)) ) +# 10541 "parsing/parser.ml" + : 'pattern_no_exn)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_no_exn) in + Obj.repr( +# 1787 "parsing/parser.mly" + ( expecting 3 "pattern" ) +# 10548 "parsing/parser.ml" + : 'pattern_no_exn)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'pattern_no_exn) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attribute) in + Obj.repr( +# 1789 "parsing/parser.mly" + ( Pat.attr _1 _2 ) +# 10556 "parsing/parser.ml" + : 'pattern_no_exn)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'pattern_gen) in + Obj.repr( +# 1790 "parsing/parser.mly" + ( _1 ) +# 10563 "parsing/parser.ml" + : 'pattern_no_exn)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_pattern) in + Obj.repr( +# 1794 "parsing/parser.mly" + ( _1 ) +# 10570 "parsing/parser.ml" + : 'pattern_gen)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'constr_longident) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in + Obj.repr( +# 1796 "parsing/parser.mly" + ( mkpat(Ppat_construct(mkrhs _1 1, Some _2)) ) +# 10578 "parsing/parser.ml" + : 'pattern_gen)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'name_tag) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in + Obj.repr( +# 1798 "parsing/parser.mly" + ( mkpat(Ppat_variant(_1, Some _2)) ) +# 10586 "parsing/parser.ml" + : 'pattern_gen)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'simple_pattern) in + Obj.repr( +# 1800 "parsing/parser.mly" + ( mkpat_attrs (Ppat_lazy _3) _2) +# 10594 "parsing/parser.ml" + : 'pattern_gen)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'val_ident) in + Obj.repr( +# 1804 "parsing/parser.mly" + ( mkpat(Ppat_var (mkrhs _1 1)) ) +# 10601 "parsing/parser.ml" + : 'simple_pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_pattern_not_ident) in + Obj.repr( +# 1805 "parsing/parser.mly" + ( _1 ) +# 10608 "parsing/parser.ml" + : 'simple_pattern)) +; (fun __caml_parser_env -> + Obj.repr( +# 1809 "parsing/parser.mly" + ( mkpat(Ppat_any) ) +# 10614 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'signed_constant) in + Obj.repr( +# 1811 "parsing/parser.mly" + ( mkpat(Ppat_constant _1) ) +# 10621 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'signed_constant) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'signed_constant) in + Obj.repr( +# 1813 "parsing/parser.mly" + ( mkpat(Ppat_interval (_1, _3)) ) +# 10629 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'constr_longident) in + Obj.repr( +# 1815 "parsing/parser.mly" + ( mkpat(Ppat_construct(mkrhs _1 1, None)) ) +# 10636 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'name_tag) in + Obj.repr( +# 1817 "parsing/parser.mly" + ( mkpat(Ppat_variant(_1, None)) ) +# 10643 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'type_longident) in + Obj.repr( +# 1819 "parsing/parser.mly" + ( mkpat(Ppat_type (mkrhs _2 2)) ) +# 10650 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_delimited_pattern) in + Obj.repr( +# 1821 "parsing/parser.mly" + ( _1 ) +# 10657 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'mod_longident) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'simple_delimited_pattern) in + Obj.repr( +# 1823 "parsing/parser.mly" + ( mkpat @@ Ppat_open(mkrhs _1 1, _3) ) +# 10665 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 3 : 'mod_longident) in + Obj.repr( +# 1825 "parsing/parser.mly" + ( mkpat @@ Ppat_open(mkrhs _1 1, mkpat @@ + Ppat_construct ( mkrhs (Lident "[]") 4, None)) ) +# 10673 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 3 : 'mod_longident) in + Obj.repr( +# 1828 "parsing/parser.mly" + ( mkpat @@ Ppat_open( mkrhs _1 1, mkpat @@ + Ppat_construct ( mkrhs (Lident "()") 4, None) ) ) +# 10681 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'pattern) in + Obj.repr( +# 1831 "parsing/parser.mly" + ( mkpat @@ Ppat_open (mkrhs _1 1, _4)) +# 10689 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'pattern) in + Obj.repr( +# 1833 "parsing/parser.mly" + (unclosed "(" 3 ")" 5 ) +# 10697 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 3 : 'mod_longident) in + Obj.repr( +# 1835 "parsing/parser.mly" + ( expecting 4 "pattern" ) +# 10704 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'pattern) in + Obj.repr( +# 1837 "parsing/parser.mly" + ( reloc_pat _2 ) +# 10711 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'pattern) in + Obj.repr( +# 1839 "parsing/parser.mly" + ( unclosed "(" 1 ")" 3 ) +# 10718 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'pattern) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'core_type) in + Obj.repr( +# 1841 "parsing/parser.mly" + ( mkpat(Ppat_constraint(_2, _4)) ) +# 10726 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'pattern) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'core_type) in + Obj.repr( +# 1843 "parsing/parser.mly" + ( unclosed "(" 1 ")" 5 ) +# 10734 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in + Obj.repr( +# 1845 "parsing/parser.mly" + ( expecting 4 "type" ) +# 10741 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : string) in + Obj.repr( +# 1847 "parsing/parser.mly" + ( mkpat_attrs (Ppat_unpack (mkrhs _4 4)) _3 ) +# 10749 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _6 = (Parsing.peek_val __caml_parser_env 1 : 'package_type) in + Obj.repr( +# 1849 "parsing/parser.mly" + ( mkpat_attrs + (Ppat_constraint(mkpat(Ppat_unpack (mkrhs _4 4)), + ghtyp(Ptyp_package _6))) + _3 ) +# 10761 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _6 = (Parsing.peek_val __caml_parser_env 1 : 'package_type) in + Obj.repr( +# 1854 "parsing/parser.mly" + ( unclosed "(" 1 ")" 7 ) +# 10770 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'extension) in + Obj.repr( +# 1856 "parsing/parser.mly" + ( mkpat(Ppat_extension _1) ) +# 10777 "parsing/parser.ml" + : 'simple_pattern_not_ident)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'lbl_pattern_list) in + Obj.repr( +# 1861 "parsing/parser.mly" + ( let (fields, closed) = _2 in mkpat(Ppat_record(fields, closed)) ) +# 10784 "parsing/parser.ml" + : 'simple_delimited_pattern)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'lbl_pattern_list) in + Obj.repr( +# 1863 "parsing/parser.mly" + ( unclosed "{" 1 "}" 3 ) +# 10791 "parsing/parser.ml" + : 'simple_delimited_pattern)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_semi_list) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in + Obj.repr( +# 1865 "parsing/parser.mly" + ( reloc_pat (mktailpat (rhs_loc 4) (List.rev _2)) ) +# 10799 "parsing/parser.ml" + : 'simple_delimited_pattern)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_semi_list) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in + Obj.repr( +# 1867 "parsing/parser.mly" + ( unclosed "[" 1 "]" 4 ) +# 10807 "parsing/parser.ml" + : 'simple_delimited_pattern)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_semi_list) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in + Obj.repr( +# 1869 "parsing/parser.mly" + ( mkpat(Ppat_array(List.rev _2)) ) +# 10815 "parsing/parser.ml" + : 'simple_delimited_pattern)) +; (fun __caml_parser_env -> + Obj.repr( +# 1871 "parsing/parser.mly" + ( mkpat(Ppat_array []) ) +# 10821 "parsing/parser.ml" + : 'simple_delimited_pattern)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_semi_list) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'opt_semi) in + Obj.repr( +# 1873 "parsing/parser.mly" + ( unclosed "[|" 1 "|]" 4 ) +# 10829 "parsing/parser.ml" + : 'simple_delimited_pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_comma_list) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in + Obj.repr( +# 1876 "parsing/parser.mly" + ( _3 :: _1 ) +# 10837 "parsing/parser.ml" + : 'pattern_comma_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in + Obj.repr( +# 1877 "parsing/parser.mly" + ( [_3; _1] ) +# 10845 "parsing/parser.ml" + : 'pattern_comma_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in + Obj.repr( +# 1878 "parsing/parser.mly" + ( expecting 3 "pattern" ) +# 10852 "parsing/parser.ml" + : 'pattern_comma_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_no_exn_comma_list) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in + Obj.repr( +# 1881 "parsing/parser.mly" + ( _3 :: _1 ) +# 10860 "parsing/parser.ml" + : 'pattern_no_exn_comma_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_no_exn) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in + Obj.repr( +# 1882 "parsing/parser.mly" + ( [_3; _1] ) +# 10868 "parsing/parser.ml" + : 'pattern_no_exn_comma_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_no_exn) in + Obj.repr( +# 1883 "parsing/parser.mly" + ( expecting 3 "pattern" ) +# 10875 "parsing/parser.ml" + : 'pattern_no_exn_comma_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in + Obj.repr( +# 1886 "parsing/parser.mly" + ( [_1] ) +# 10882 "parsing/parser.ml" + : 'pattern_semi_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'pattern_semi_list) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in + Obj.repr( +# 1887 "parsing/parser.mly" + ( _3 :: _1 ) +# 10890 "parsing/parser.ml" + : 'pattern_semi_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'lbl_pattern) in + Obj.repr( +# 1890 "parsing/parser.mly" + ( [_1], Closed ) +# 10897 "parsing/parser.ml" + : 'lbl_pattern_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'lbl_pattern) in + Obj.repr( +# 1891 "parsing/parser.mly" + ( [_1], Closed ) +# 10904 "parsing/parser.ml" + : 'lbl_pattern_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 3 : 'lbl_pattern) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'opt_semi) in + Obj.repr( +# 1892 "parsing/parser.mly" + ( [_1], Open ) +# 10912 "parsing/parser.ml" + : 'lbl_pattern_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'lbl_pattern) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'lbl_pattern_list) in + Obj.repr( +# 1894 "parsing/parser.mly" + ( let (fields, closed) = _3 in _1 :: fields, closed ) +# 10920 "parsing/parser.ml" + : 'lbl_pattern_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 3 : 'label_longident) in + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'opt_pattern_type_constraint) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in + Obj.repr( +# 1898 "parsing/parser.mly" + ( (mkrhs _1 1, mkpat_opt_constraint _4 _2) ) +# 10929 "parsing/parser.ml" + : 'lbl_pattern)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'label_longident) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'opt_pattern_type_constraint) in + Obj.repr( +# 1900 "parsing/parser.mly" + ( (mkrhs _1 1, mkpat_opt_constraint (pat_of_label _1 1) _2) ) +# 10937 "parsing/parser.ml" + : 'lbl_pattern)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in + Obj.repr( +# 1903 "parsing/parser.mly" + ( Some _2 ) +# 10944 "parsing/parser.ml" + : 'opt_pattern_type_constraint)) +; (fun __caml_parser_env -> + Obj.repr( +# 1904 "parsing/parser.mly" + ( None ) +# 10950 "parsing/parser.ml" + : 'opt_pattern_type_constraint)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 3 : 'val_ident) in + let _5 = (Parsing.peek_val __caml_parser_env 1 : 'core_type) in + let _6 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1911 "parsing/parser.mly" + ( let (ext, attrs) = _2 in + Val.mk (mkrhs _3 3) _5 ~attrs:(attrs@_6) + ~loc:(symbol_rloc()) ~docs:(symbol_docs ()) + , ext ) +# 10963 "parsing/parser.ml" + : 'value_description)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string * string option) in + Obj.repr( +# 1920 "parsing/parser.mly" + ( [fst _1] ) +# 10970 "parsing/parser.ml" + : 'primitive_declaration_body)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : string * string option) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'primitive_declaration_body) in + Obj.repr( +# 1921 "parsing/parser.mly" + ( fst _1 :: _2 ) +# 10978 "parsing/parser.ml" + : 'primitive_declaration_body)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 6 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 5 : 'val_ident) in + let _5 = (Parsing.peek_val __caml_parser_env 3 : 'core_type) in + let _7 = (Parsing.peek_val __caml_parser_env 1 : 'primitive_declaration_body) in + let _8 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1926 "parsing/parser.mly" + ( let (ext, attrs) = _2 in + Val.mk (mkrhs _3 3) _5 ~prim:_7 ~attrs:(attrs@_8) + ~loc:(symbol_rloc ()) ~docs:(symbol_docs ()) + , ext ) +# 10992 "parsing/parser.ml" + : 'primitive_declaration)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'type_declaration) in + Obj.repr( +# 1936 "parsing/parser.mly" + ( let (nonrec_flag, ty, ext) = _1 in (nonrec_flag, [ty], ext) ) +# 10999 "parsing/parser.ml" + : 'type_declarations)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'type_declarations) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'and_type_declaration) in + Obj.repr( +# 1938 "parsing/parser.mly" + ( let (nonrec_flag, tys, ext) = _1 in (nonrec_flag, _2 :: tys, ext) ) +# 11007 "parsing/parser.ml" + : 'type_declarations)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 6 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 5 : 'nonrec_flag) in + let _4 = (Parsing.peek_val __caml_parser_env 4 : 'optional_type_parameters) in + let _5 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _6 = (Parsing.peek_val __caml_parser_env 2 : 'type_kind) in + let _7 = (Parsing.peek_val __caml_parser_env 1 : 'constraints) in + let _8 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1944 "parsing/parser.mly" + ( let (kind, priv, manifest) = _6 in + let (ext, attrs) = _2 in + let ty = + Type.mk (mkrhs _5 5) ~params:_4 ~cstrs:(List.rev _7) ~kind + ~priv ?manifest ~attrs:(attrs@_8) + ~loc:(symbol_rloc ()) ~docs:(symbol_docs ()) + in + (_3, ty, ext) ) +# 11027 "parsing/parser.ml" + : 'type_declaration)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 5 : 'attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'optional_type_parameters) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _5 = (Parsing.peek_val __caml_parser_env 2 : 'type_kind) in + let _6 = (Parsing.peek_val __caml_parser_env 1 : 'constraints) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 1956 "parsing/parser.mly" + ( let (kind, priv, manifest) = _5 in + Type.mk (mkrhs _4 4) ~params:_3 ~cstrs:(List.rev _6) + ~kind ~priv ?manifest ~attrs:(_2@_7) ~loc:(symbol_rloc ()) + ~text:(symbol_text ()) ~docs:(symbol_docs ()) ) +# 11042 "parsing/parser.ml" + : 'and_type_declaration)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'constraints) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'constrain) in + Obj.repr( +# 1962 "parsing/parser.mly" + ( _3 :: _1 ) +# 11050 "parsing/parser.ml" + : 'constraints)) +; (fun __caml_parser_env -> + Obj.repr( +# 1963 "parsing/parser.mly" + ( [] ) +# 11056 "parsing/parser.ml" + : 'constraints)) +; (fun __caml_parser_env -> + Obj.repr( +# 1967 "parsing/parser.mly" + ( (Ptype_abstract, Public, None) ) +# 11062 "parsing/parser.ml" + : 'type_kind)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in + Obj.repr( +# 1969 "parsing/parser.mly" + ( (Ptype_abstract, Public, Some _2) ) +# 11069 "parsing/parser.ml" + : 'type_kind)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in + Obj.repr( +# 1971 "parsing/parser.mly" + ( (Ptype_abstract, Private, Some _3) ) +# 11076 "parsing/parser.ml" + : 'type_kind)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'constructor_declarations) in + Obj.repr( +# 1973 "parsing/parser.mly" + ( (Ptype_variant(List.rev _2), Public, None) ) +# 11083 "parsing/parser.ml" + : 'type_kind)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'constructor_declarations) in + Obj.repr( +# 1975 "parsing/parser.mly" + ( (Ptype_variant(List.rev _3), Private, None) ) +# 11090 "parsing/parser.ml" + : 'type_kind)) +; (fun __caml_parser_env -> + Obj.repr( +# 1977 "parsing/parser.mly" + ( (Ptype_open, Public, None) ) +# 11096 "parsing/parser.ml" + : 'type_kind)) +; (fun __caml_parser_env -> + Obj.repr( +# 1979 "parsing/parser.mly" + ( (Ptype_open, Private, None) ) +# 11102 "parsing/parser.ml" + : 'type_kind)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'private_flag) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'label_declarations) in + Obj.repr( +# 1981 "parsing/parser.mly" + ( (Ptype_record _4, _2, None) ) +# 11110 "parsing/parser.ml" + : 'type_kind)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'core_type) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'private_flag) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'constructor_declarations) in + Obj.repr( +# 1983 "parsing/parser.mly" + ( (Ptype_variant(List.rev _5), _4, Some _2) ) +# 11119 "parsing/parser.ml" + : 'type_kind)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'core_type) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'private_flag) in + Obj.repr( +# 1985 "parsing/parser.mly" + ( (Ptype_open, _4, Some _2) ) +# 11127 "parsing/parser.ml" + : 'type_kind)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 5 : 'core_type) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : 'private_flag) in + let _6 = (Parsing.peek_val __caml_parser_env 1 : 'label_declarations) in + Obj.repr( +# 1987 "parsing/parser.mly" + ( (Ptype_record _6, _4, Some _2) ) +# 11136 "parsing/parser.ml" + : 'type_kind)) +; (fun __caml_parser_env -> + Obj.repr( +# 1990 "parsing/parser.mly" + ( [] ) +# 11142 "parsing/parser.ml" + : 'optional_type_parameters)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'optional_type_parameter) in + Obj.repr( +# 1991 "parsing/parser.mly" + ( [_1] ) +# 11149 "parsing/parser.ml" + : 'optional_type_parameters)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'optional_type_parameter_list) in + Obj.repr( +# 1992 "parsing/parser.mly" + ( List.rev _2 ) +# 11156 "parsing/parser.ml" + : 'optional_type_parameters)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'type_variance) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'optional_type_variable) in + Obj.repr( +# 1995 "parsing/parser.mly" + ( _2, _1 ) +# 11164 "parsing/parser.ml" + : 'optional_type_parameter)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'optional_type_parameter) in + Obj.repr( +# 1998 "parsing/parser.mly" + ( [_1] ) +# 11171 "parsing/parser.ml" + : 'optional_type_parameter_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'optional_type_parameter_list) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'optional_type_parameter) in + Obj.repr( +# 1999 "parsing/parser.mly" + ( _3 :: _1 ) +# 11179 "parsing/parser.ml" + : 'optional_type_parameter_list)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'ident) in + Obj.repr( +# 2002 "parsing/parser.mly" + ( mktyp(Ptyp_var _2) ) +# 11186 "parsing/parser.ml" + : 'optional_type_variable)) +; (fun __caml_parser_env -> + Obj.repr( +# 2003 "parsing/parser.mly" + ( mktyp(Ptyp_any) ) +# 11192 "parsing/parser.ml" + : 'optional_type_variable)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'type_variance) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'type_variable) in + Obj.repr( +# 2008 "parsing/parser.mly" + ( _2, _1 ) +# 11200 "parsing/parser.ml" + : 'type_parameter)) +; (fun __caml_parser_env -> + Obj.repr( +# 2011 "parsing/parser.mly" + ( Invariant ) +# 11206 "parsing/parser.ml" + : 'type_variance)) +; (fun __caml_parser_env -> + Obj.repr( +# 2012 "parsing/parser.mly" + ( Covariant ) +# 11212 "parsing/parser.ml" + : 'type_variance)) +; (fun __caml_parser_env -> + Obj.repr( +# 2013 "parsing/parser.mly" + ( Contravariant ) +# 11218 "parsing/parser.ml" + : 'type_variance)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'ident) in + Obj.repr( +# 2016 "parsing/parser.mly" + ( mktyp(Ptyp_var _2) ) +# 11225 "parsing/parser.ml" + : 'type_variable)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'type_parameter) in + Obj.repr( +# 2019 "parsing/parser.mly" + ( [_1] ) +# 11232 "parsing/parser.ml" + : 'type_parameter_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'type_parameter_list) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'type_parameter) in + Obj.repr( +# 2020 "parsing/parser.mly" + ( _3 :: _1 ) +# 11240 "parsing/parser.ml" + : 'type_parameter_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'constructor_declaration) in + Obj.repr( +# 2023 "parsing/parser.mly" + ( [_1] ) +# 11247 "parsing/parser.ml" + : 'constructor_declarations)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'bar_constructor_declaration) in + Obj.repr( +# 2024 "parsing/parser.mly" + ( [_1] ) +# 11254 "parsing/parser.ml" + : 'constructor_declarations)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'constructor_declarations) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'bar_constructor_declaration) in + Obj.repr( +# 2025 "parsing/parser.mly" + ( _2 :: _1 ) +# 11262 "parsing/parser.ml" + : 'constructor_declarations)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'constr_ident) in + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'generalized_constructor_arguments) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in + Obj.repr( +# 2029 "parsing/parser.mly" + ( + let args,res = _2 in + Type.constructor (mkrhs _1 1) ~args ?res ~attrs:_3 + ~loc:(symbol_rloc()) ~info:(symbol_info ()) + ) +# 11275 "parsing/parser.ml" + : 'constructor_declaration)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'constr_ident) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'generalized_constructor_arguments) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in + Obj.repr( +# 2037 "parsing/parser.mly" + ( + let args,res = _3 in + Type.constructor (mkrhs _2 2) ~args ?res ~attrs:_4 + ~loc:(symbol_rloc()) ~info:(symbol_info ()) + ) +# 11288 "parsing/parser.ml" + : 'bar_constructor_declaration)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'sig_exception_declaration) in + Obj.repr( +# 2044 "parsing/parser.mly" + ( _1 ) +# 11295 "parsing/parser.ml" + : 'str_exception_declaration)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 5 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 4 : 'constr_ident) in + let _5 = (Parsing.peek_val __caml_parser_env 2 : 'constr_longident) in + let _6 = (Parsing.peek_val __caml_parser_env 1 : 'attributes) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 2047 "parsing/parser.mly" + ( let (ext,attrs) = _2 in + Te.rebind (mkrhs _3 3) (mkrhs _5 5) ~attrs:(attrs @ _6 @ _7) + ~loc:(symbol_rloc()) ~docs:(symbol_docs ()) + , ext ) +# 11309 "parsing/parser.ml" + : 'str_exception_declaration)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 4 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 3 : 'constr_ident) in + let _4 = (Parsing.peek_val __caml_parser_env 2 : 'generalized_constructor_arguments) in + let _5 = (Parsing.peek_val __caml_parser_env 1 : 'attributes) in + let _6 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 2055 "parsing/parser.mly" + ( let args, res = _4 in + let (ext,attrs) = _2 in + Te.decl (mkrhs _3 3) ~args ?res ~attrs:(attrs @ _5 @ _6) + ~loc:(symbol_rloc()) ~docs:(symbol_docs ()) + , ext ) +# 11324 "parsing/parser.ml" + : 'sig_exception_declaration)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'constr_ident) in + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'generalized_constructor_arguments) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in + Obj.repr( +# 2063 "parsing/parser.mly" + ( let args, res = _2 in + Te.decl (mkrhs _1 1) ~args ?res ~attrs:_3 ~loc:(symbol_rloc()) ) +# 11334 "parsing/parser.ml" + : 'let_exception_declaration)) +; (fun __caml_parser_env -> + Obj.repr( +# 2067 "parsing/parser.mly" + ( (Pcstr_tuple [],None) ) +# 11340 "parsing/parser.ml" + : 'generalized_constructor_arguments)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'constructor_arguments) in + Obj.repr( +# 2068 "parsing/parser.mly" + ( (_2,None) ) +# 11347 "parsing/parser.ml" + : 'generalized_constructor_arguments)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'constructor_arguments) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'simple_core_type) in + Obj.repr( +# 2070 "parsing/parser.mly" + ( (_2,Some _4) ) +# 11355 "parsing/parser.ml" + : 'generalized_constructor_arguments)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'simple_core_type) in + Obj.repr( +# 2072 "parsing/parser.mly" + ( (Pcstr_tuple [],Some _2) ) +# 11362 "parsing/parser.ml" + : 'generalized_constructor_arguments)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'core_type_list) in + Obj.repr( +# 2076 "parsing/parser.mly" + ( Pcstr_tuple (List.rev _1) ) +# 11369 "parsing/parser.ml" + : 'constructor_arguments)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'label_declarations) in + Obj.repr( +# 2077 "parsing/parser.mly" + ( Pcstr_record _2 ) +# 11376 "parsing/parser.ml" + : 'constructor_arguments)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'label_declaration) in + Obj.repr( +# 2080 "parsing/parser.mly" + ( [_1] ) +# 11383 "parsing/parser.ml" + : 'label_declarations)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'label_declaration_semi) in + Obj.repr( +# 2081 "parsing/parser.mly" + ( [_1] ) +# 11390 "parsing/parser.ml" + : 'label_declarations)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'label_declaration_semi) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'label_declarations) in + Obj.repr( +# 2082 "parsing/parser.mly" + ( _1 :: _2 ) +# 11398 "parsing/parser.ml" + : 'label_declarations)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'mutable_flag) in + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'label) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'poly_type_no_attr) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in + Obj.repr( +# 2086 "parsing/parser.mly" + ( + Type.field (mkrhs _2 2) _4 ~mut:_1 ~attrs:_5 + ~loc:(symbol_rloc()) ~info:(symbol_info ()) + ) +# 11411 "parsing/parser.ml" + : 'label_declaration)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 6 : 'mutable_flag) in + let _2 = (Parsing.peek_val __caml_parser_env 5 : 'label) in + let _4 = (Parsing.peek_val __caml_parser_env 3 : 'poly_type_no_attr) in + let _5 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in + let _7 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in + Obj.repr( +# 2093 "parsing/parser.mly" + ( + let info = + match rhs_info 5 with + | Some _ as info_before_semi -> info_before_semi + | None -> symbol_info () + in + Type.field (mkrhs _2 2) _4 ~mut:_1 ~attrs:(_5 @ _7) + ~loc:(symbol_rloc()) ~info + ) +# 11430 "parsing/parser.ml" + : 'label_declaration_semi)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 7 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 6 : 'nonrec_flag) in + let _4 = (Parsing.peek_val __caml_parser_env 5 : 'optional_type_parameters) in + let _5 = (Parsing.peek_val __caml_parser_env 4 : 'type_longident) in + let _7 = (Parsing.peek_val __caml_parser_env 2 : 'private_flag) in + let _8 = (Parsing.peek_val __caml_parser_env 1 : 'str_extension_constructors) in + let _9 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 2109 "parsing/parser.mly" + ( let (ext, attrs) = _2 in + if _3 <> Recursive then not_expecting 3 "nonrec flag"; + Te.mk (mkrhs _5 5) (List.rev _8) ~params:_4 ~priv:_7 + ~attrs:(attrs@_9) ~docs:(symbol_docs ()) + , ext ) +# 11447 "parsing/parser.ml" + : 'str_type_extension)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 7 : 'ext_attributes) in + let _3 = (Parsing.peek_val __caml_parser_env 6 : 'nonrec_flag) in + let _4 = (Parsing.peek_val __caml_parser_env 5 : 'optional_type_parameters) in + let _5 = (Parsing.peek_val __caml_parser_env 4 : 'type_longident) in + let _7 = (Parsing.peek_val __caml_parser_env 2 : 'private_flag) in + let _8 = (Parsing.peek_val __caml_parser_env 1 : 'sig_extension_constructors) in + let _9 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 2118 "parsing/parser.mly" + ( let (ext, attrs) = _2 in + if _3 <> Recursive then not_expecting 3 "nonrec flag"; + Te.mk (mkrhs _5 5) (List.rev _8) ~params:_4 ~priv:_7 + ~attrs:(attrs @ _9) ~docs:(symbol_docs ()) + , ext ) +# 11464 "parsing/parser.ml" + : 'sig_type_extension)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'extension_constructor_declaration) in + Obj.repr( +# 2125 "parsing/parser.mly" + ( [_1] ) +# 11471 "parsing/parser.ml" + : 'str_extension_constructors)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'bar_extension_constructor_declaration) in + Obj.repr( +# 2126 "parsing/parser.mly" + ( [_1] ) +# 11478 "parsing/parser.ml" + : 'str_extension_constructors)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'extension_constructor_rebind) in + Obj.repr( +# 2127 "parsing/parser.mly" + ( [_1] ) +# 11485 "parsing/parser.ml" + : 'str_extension_constructors)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'bar_extension_constructor_rebind) in + Obj.repr( +# 2128 "parsing/parser.mly" + ( [_1] ) +# 11492 "parsing/parser.ml" + : 'str_extension_constructors)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'str_extension_constructors) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'bar_extension_constructor_declaration) in + Obj.repr( +# 2130 "parsing/parser.mly" + ( _2 :: _1 ) +# 11500 "parsing/parser.ml" + : 'str_extension_constructors)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'str_extension_constructors) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'bar_extension_constructor_rebind) in + Obj.repr( +# 2132 "parsing/parser.mly" + ( _2 :: _1 ) +# 11508 "parsing/parser.ml" + : 'str_extension_constructors)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'extension_constructor_declaration) in + Obj.repr( +# 2135 "parsing/parser.mly" + ( [_1] ) +# 11515 "parsing/parser.ml" + : 'sig_extension_constructors)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'bar_extension_constructor_declaration) in + Obj.repr( +# 2136 "parsing/parser.mly" + ( [_1] ) +# 11522 "parsing/parser.ml" + : 'sig_extension_constructors)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'sig_extension_constructors) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'bar_extension_constructor_declaration) in + Obj.repr( +# 2138 "parsing/parser.mly" + ( _2 :: _1 ) +# 11530 "parsing/parser.ml" + : 'sig_extension_constructors)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'constr_ident) in + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'generalized_constructor_arguments) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in + Obj.repr( +# 2142 "parsing/parser.mly" + ( let args, res = _2 in + Te.decl (mkrhs _1 1) ~args ?res ~attrs:_3 + ~loc:(symbol_rloc()) ~info:(symbol_info ()) ) +# 11541 "parsing/parser.ml" + : 'extension_constructor_declaration)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'constr_ident) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'generalized_constructor_arguments) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in + Obj.repr( +# 2148 "parsing/parser.mly" + ( let args, res = _3 in + Te.decl (mkrhs _2 2) ~args ?res ~attrs:_4 + ~loc:(symbol_rloc()) ~info:(symbol_info ()) ) +# 11552 "parsing/parser.ml" + : 'bar_extension_constructor_declaration)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 3 : 'constr_ident) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'constr_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in + Obj.repr( +# 2154 "parsing/parser.mly" + ( Te.rebind (mkrhs _1 1) (mkrhs _3 3) ~attrs:_4 + ~loc:(symbol_rloc()) ~info:(symbol_info ()) ) +# 11562 "parsing/parser.ml" + : 'extension_constructor_rebind)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'constr_ident) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'constr_longident) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in + Obj.repr( +# 2159 "parsing/parser.mly" + ( Te.rebind (mkrhs _2 2) (mkrhs _4 4) ~attrs:_5 + ~loc:(symbol_rloc()) ~info:(symbol_info ()) ) +# 11572 "parsing/parser.ml" + : 'bar_extension_constructor_rebind)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'with_constraint) in + Obj.repr( +# 2166 "parsing/parser.mly" + ( [_1] ) +# 11579 "parsing/parser.ml" + : 'with_constraints)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'with_constraints) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'with_constraint) in + Obj.repr( +# 2167 "parsing/parser.mly" + ( _3 :: _1 ) +# 11587 "parsing/parser.ml" + : 'with_constraints)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 4 : 'optional_type_parameters) in + let _3 = (Parsing.peek_val __caml_parser_env 3 : 'label_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 2 : 'with_type_binder) in + let _5 = (Parsing.peek_val __caml_parser_env 1 : 'core_type_no_attr) in + let _6 = (Parsing.peek_val __caml_parser_env 0 : 'constraints) in + Obj.repr( +# 2172 "parsing/parser.mly" + ( Pwith_type + (mkrhs _3 3, + (Type.mk (mkrhs (Longident.last _3) 3) + ~params:_2 + ~cstrs:(List.rev _6) + ~manifest:_5 + ~priv:_4 + ~loc:(symbol_rloc()))) ) +# 11605 "parsing/parser.ml" + : 'with_constraint)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'optional_type_parameters) in + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'label_longident) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'core_type_no_attr) in + Obj.repr( +# 2183 "parsing/parser.mly" + ( Pwith_typesubst + (mkrhs _3 3, + (Type.mk (mkrhs (Longident.last _3) 3) + ~params:_2 + ~manifest:_5 + ~loc:(symbol_rloc()))) ) +# 11619 "parsing/parser.ml" + : 'with_constraint)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'mod_ext_longident) in + Obj.repr( +# 2190 "parsing/parser.mly" + ( Pwith_module (mkrhs _2 2, mkrhs _4 4) ) +# 11627 "parsing/parser.ml" + : 'with_constraint)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'mod_longident) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'mod_ext_longident) in + Obj.repr( +# 2192 "parsing/parser.mly" + ( Pwith_modsubst (mkrhs _2 2, mkrhs _4 4) ) +# 11635 "parsing/parser.ml" + : 'with_constraint)) +; (fun __caml_parser_env -> + Obj.repr( +# 2195 "parsing/parser.mly" + ( Public ) +# 11641 "parsing/parser.ml" + : 'with_type_binder)) +; (fun __caml_parser_env -> + Obj.repr( +# 2196 "parsing/parser.mly" + ( Private ) +# 11647 "parsing/parser.ml" + : 'with_type_binder)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'ident) in + Obj.repr( +# 2202 "parsing/parser.mly" + ( [mkrhs _2 2] ) +# 11654 "parsing/parser.ml" + : 'typevar_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'typevar_list) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'ident) in + Obj.repr( +# 2203 "parsing/parser.mly" + ( mkrhs _3 3 :: _1 ) +# 11662 "parsing/parser.ml" + : 'typevar_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in + Obj.repr( +# 2207 "parsing/parser.mly" + ( _1 ) +# 11669 "parsing/parser.ml" + : 'poly_type)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'typevar_list) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in + Obj.repr( +# 2209 "parsing/parser.mly" + ( mktyp(Ptyp_poly(List.rev _1, _3)) ) +# 11677 "parsing/parser.ml" + : 'poly_type)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'core_type_no_attr) in + Obj.repr( +# 2213 "parsing/parser.mly" + ( _1 ) +# 11684 "parsing/parser.ml" + : 'poly_type_no_attr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'typevar_list) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type_no_attr) in + Obj.repr( +# 2215 "parsing/parser.mly" + ( mktyp(Ptyp_poly(List.rev _1, _3)) ) +# 11692 "parsing/parser.ml" + : 'poly_type_no_attr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'core_type_no_attr) in + Obj.repr( +# 2222 "parsing/parser.mly" + ( _1 ) +# 11699 "parsing/parser.ml" + : 'core_type)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'core_type) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attribute) in + Obj.repr( +# 2224 "parsing/parser.mly" + ( Typ.attr _1 _2 ) +# 11707 "parsing/parser.ml" + : 'core_type)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'core_type2) in + Obj.repr( +# 2228 "parsing/parser.mly" + ( _1 ) +# 11714 "parsing/parser.ml" + : 'core_type_no_attr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 3 : 'core_type2) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'ident) in + Obj.repr( +# 2230 "parsing/parser.mly" + ( mktyp(Ptyp_alias(_1, _4)) ) +# 11722 "parsing/parser.ml" + : 'core_type_no_attr)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_core_type_or_tuple) in + Obj.repr( +# 2234 "parsing/parser.mly" + ( _1 ) +# 11729 "parsing/parser.ml" + : 'core_type2)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 4 : string) in + let _4 = (Parsing.peek_val __caml_parser_env 2 : 'core_type2) in + let _6 = (Parsing.peek_val __caml_parser_env 0 : 'core_type2) in + Obj.repr( +# 2236 "parsing/parser.mly" + ( let param = extra_rhs_core_type _4 ~pos:4 in + mktyp (Ptyp_arrow(Optional _2 , param, _6)) ) +# 11739 "parsing/parser.ml" + : 'core_type2)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 3 : string) in + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'core_type2) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'core_type2) in + Obj.repr( +# 2239 "parsing/parser.mly" + ( let param = extra_rhs_core_type _2 ~pos:2 in + mktyp(Ptyp_arrow(Optional _1 , param, _4)) + ) +# 11750 "parsing/parser.ml" + : 'core_type2)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : string) in + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'core_type2) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'core_type2) in + Obj.repr( +# 2243 "parsing/parser.mly" + ( let param = extra_rhs_core_type _3 ~pos:3 in + mktyp(Ptyp_arrow(Labelled _1, param, _5)) ) +# 11760 "parsing/parser.ml" + : 'core_type2)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'core_type2) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type2) in + Obj.repr( +# 2246 "parsing/parser.mly" + ( let param = extra_rhs_core_type _1 ~pos:1 in + mktyp(Ptyp_arrow(Nolabel, param, _3)) ) +# 11769 "parsing/parser.ml" + : 'core_type2)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_core_type2) in + Obj.repr( +# 2252 "parsing/parser.mly" + ( _1 ) +# 11776 "parsing/parser.ml" + : 'simple_core_type)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'core_type_comma_list) in + Obj.repr( +# 2254 "parsing/parser.mly" + ( match _2 with [sty] -> sty | _ -> raise Parse_error ) +# 11783 "parsing/parser.ml" + : 'simple_core_type)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'ident) in + Obj.repr( +# 2259 "parsing/parser.mly" + ( mktyp(Ptyp_var _2) ) +# 11790 "parsing/parser.ml" + : 'simple_core_type2)) +; (fun __caml_parser_env -> + Obj.repr( +# 2261 "parsing/parser.mly" + ( mktyp(Ptyp_any) ) +# 11796 "parsing/parser.ml" + : 'simple_core_type2)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'type_longident) in + Obj.repr( +# 2263 "parsing/parser.mly" + ( mktyp(Ptyp_constr(mkrhs _1 1, [])) ) +# 11803 "parsing/parser.ml" + : 'simple_core_type2)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'simple_core_type2) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'type_longident) in + Obj.repr( +# 2265 "parsing/parser.mly" + ( mktyp(Ptyp_constr(mkrhs _2 2, [_1])) ) +# 11811 "parsing/parser.ml" + : 'simple_core_type2)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'core_type_comma_list) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'type_longident) in + Obj.repr( +# 2267 "parsing/parser.mly" + ( mktyp(Ptyp_constr(mkrhs _4 4, List.rev _2)) ) +# 11819 "parsing/parser.ml" + : 'simple_core_type2)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'meth_list) in + Obj.repr( +# 2269 "parsing/parser.mly" + ( let (f, c) = _2 in mktyp(Ptyp_object (f, c)) ) +# 11826 "parsing/parser.ml" + : 'simple_core_type2)) +; (fun __caml_parser_env -> + Obj.repr( +# 2271 "parsing/parser.mly" + ( mktyp(Ptyp_object ([], Closed)) ) +# 11832 "parsing/parser.ml" + : 'simple_core_type2)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'class_longident) in + Obj.repr( +# 2273 "parsing/parser.mly" + ( mktyp(Ptyp_class(mkrhs _2 2, [])) ) +# 11839 "parsing/parser.ml" + : 'simple_core_type2)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'simple_core_type2) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'class_longident) in + Obj.repr( +# 2275 "parsing/parser.mly" + ( mktyp(Ptyp_class(mkrhs _3 3, [_1])) ) +# 11847 "parsing/parser.ml" + : 'simple_core_type2)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'core_type_comma_list) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'class_longident) in + Obj.repr( +# 2277 "parsing/parser.mly" + ( mktyp(Ptyp_class(mkrhs _5 5, List.rev _2)) ) +# 11855 "parsing/parser.ml" + : 'simple_core_type2)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'tag_field) in + Obj.repr( +# 2279 "parsing/parser.mly" + ( mktyp(Ptyp_variant([_2], Closed, None)) ) +# 11862 "parsing/parser.ml" + : 'simple_core_type2)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'row_field_list) in + Obj.repr( +# 2285 "parsing/parser.mly" + ( mktyp(Ptyp_variant(List.rev _3, Closed, None)) ) +# 11869 "parsing/parser.ml" + : 'simple_core_type2)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 3 : 'row_field) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'row_field_list) in + Obj.repr( +# 2287 "parsing/parser.mly" + ( mktyp(Ptyp_variant(_2 :: List.rev _4, Closed, None)) ) +# 11877 "parsing/parser.ml" + : 'simple_core_type2)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'opt_bar) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'row_field_list) in + Obj.repr( +# 2289 "parsing/parser.mly" + ( mktyp(Ptyp_variant(List.rev _3, Open, None)) ) +# 11885 "parsing/parser.ml" + : 'simple_core_type2)) +; (fun __caml_parser_env -> + Obj.repr( +# 2291 "parsing/parser.mly" + ( mktyp(Ptyp_variant([], Open, None)) ) +# 11891 "parsing/parser.ml" + : 'simple_core_type2)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'opt_bar) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'row_field_list) in + Obj.repr( +# 2293 "parsing/parser.mly" + ( mktyp(Ptyp_variant(List.rev _3, Closed, Some [])) ) +# 11899 "parsing/parser.ml" + : 'simple_core_type2)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 4 : 'opt_bar) in + let _3 = (Parsing.peek_val __caml_parser_env 3 : 'row_field_list) in + let _5 = (Parsing.peek_val __caml_parser_env 1 : 'name_tag_list) in + Obj.repr( +# 2295 "parsing/parser.mly" + ( mktyp(Ptyp_variant(List.rev _3, Closed, Some (List.rev _5))) ) +# 11908 "parsing/parser.ml" + : 'simple_core_type2)) +; (fun __caml_parser_env -> + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'ext_attributes) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'package_type) in + Obj.repr( +# 2297 "parsing/parser.mly" + ( mktyp_attrs (Ptyp_package _4) _3 ) +# 11916 "parsing/parser.ml" + : 'simple_core_type2)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'extension) in + Obj.repr( +# 2299 "parsing/parser.mly" + ( mktyp (Ptyp_extension _1) ) +# 11923 "parsing/parser.ml" + : 'simple_core_type2)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'module_type) in + Obj.repr( +# 2302 "parsing/parser.mly" + ( package_type_of_module_type _1 ) +# 11930 "parsing/parser.ml" + : 'package_type)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'row_field) in + Obj.repr( +# 2305 "parsing/parser.mly" + ( [_1] ) +# 11937 "parsing/parser.ml" + : 'row_field_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'row_field_list) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'row_field) in + Obj.repr( +# 2306 "parsing/parser.mly" + ( _3 :: _1 ) +# 11945 "parsing/parser.ml" + : 'row_field_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'tag_field) in + Obj.repr( +# 2309 "parsing/parser.mly" + ( _1 ) +# 11952 "parsing/parser.ml" + : 'row_field)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_core_type) in + Obj.repr( +# 2310 "parsing/parser.mly" + ( Rinherit _1 ) +# 11959 "parsing/parser.ml" + : 'row_field)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'name_tag) in + let _3 = (Parsing.peek_val __caml_parser_env 2 : 'opt_ampersand) in + let _4 = (Parsing.peek_val __caml_parser_env 1 : 'amper_type_list) in + let _5 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in + Obj.repr( +# 2314 "parsing/parser.mly" + ( Rtag (mkrhs _1 1, add_info_attrs (symbol_info ()) _5, + _3, List.rev _4) ) +# 11970 "parsing/parser.ml" + : 'tag_field)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'name_tag) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in + Obj.repr( +# 2317 "parsing/parser.mly" + ( Rtag (mkrhs _1 1, add_info_attrs (symbol_info ()) _2, true, []) ) +# 11978 "parsing/parser.ml" + : 'tag_field)) +; (fun __caml_parser_env -> + Obj.repr( +# 2320 "parsing/parser.mly" + ( true ) +# 11984 "parsing/parser.ml" + : 'opt_ampersand)) +; (fun __caml_parser_env -> + Obj.repr( +# 2321 "parsing/parser.mly" + ( false ) +# 11990 "parsing/parser.ml" + : 'opt_ampersand)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'core_type_no_attr) in + Obj.repr( +# 2324 "parsing/parser.mly" + ( [_1] ) +# 11997 "parsing/parser.ml" + : 'amper_type_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'amper_type_list) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type_no_attr) in + Obj.repr( +# 2325 "parsing/parser.mly" + ( _3 :: _1 ) +# 12005 "parsing/parser.ml" + : 'amper_type_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'name_tag) in + Obj.repr( +# 2328 "parsing/parser.mly" + ( [_1] ) +# 12012 "parsing/parser.ml" + : 'name_tag_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'name_tag_list) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'name_tag) in + Obj.repr( +# 2329 "parsing/parser.mly" + ( _2 :: _1 ) +# 12020 "parsing/parser.ml" + : 'name_tag_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_core_type) in + Obj.repr( +# 2332 "parsing/parser.mly" + ( _1 ) +# 12027 "parsing/parser.ml" + : 'simple_core_type_or_tuple)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'simple_core_type) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type_list) in + Obj.repr( +# 2334 "parsing/parser.mly" + ( mktyp(Ptyp_tuple(_1 :: List.rev _3)) ) +# 12035 "parsing/parser.ml" + : 'simple_core_type_or_tuple)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in + Obj.repr( +# 2337 "parsing/parser.mly" + ( [_1] ) +# 12042 "parsing/parser.ml" + : 'core_type_comma_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'core_type_comma_list) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in + Obj.repr( +# 2338 "parsing/parser.mly" + ( _3 :: _1 ) +# 12050 "parsing/parser.ml" + : 'core_type_comma_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_core_type) in + Obj.repr( +# 2341 "parsing/parser.mly" + ( [_1] ) +# 12057 "parsing/parser.ml" + : 'core_type_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'core_type_list) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'simple_core_type) in + Obj.repr( +# 2342 "parsing/parser.mly" + ( _3 :: _1 ) +# 12065 "parsing/parser.ml" + : 'core_type_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'field_semi) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'meth_list) in + Obj.repr( +# 2345 "parsing/parser.mly" + ( let (f, c) = _2 in (_1 :: f, c) ) +# 12073 "parsing/parser.ml" + : 'meth_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'inherit_field_semi) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'meth_list) in + Obj.repr( +# 2346 "parsing/parser.mly" + ( let (f, c) = _2 in (_1 :: f, c) ) +# 12081 "parsing/parser.ml" + : 'meth_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'field_semi) in + Obj.repr( +# 2347 "parsing/parser.mly" + ( [_1], Closed ) +# 12088 "parsing/parser.ml" + : 'meth_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'field) in + Obj.repr( +# 2348 "parsing/parser.mly" + ( [_1], Closed ) +# 12095 "parsing/parser.ml" + : 'meth_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'inherit_field_semi) in + Obj.repr( +# 2349 "parsing/parser.mly" + ( [_1], Closed ) +# 12102 "parsing/parser.ml" + : 'meth_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'simple_core_type) in + Obj.repr( +# 2350 "parsing/parser.mly" + ( [Oinherit _1], Closed ) +# 12109 "parsing/parser.ml" + : 'meth_list)) +; (fun __caml_parser_env -> + Obj.repr( +# 2351 "parsing/parser.mly" + ( [], Open ) +# 12115 "parsing/parser.ml" + : 'meth_list)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 3 : 'label) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'poly_type_no_attr) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in + Obj.repr( +# 2355 "parsing/parser.mly" + ( Otag (mkrhs _1 1, add_info_attrs (symbol_info ()) _4, _3) ) +# 12124 "parsing/parser.ml" + : 'field)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 5 : 'label) in + let _3 = (Parsing.peek_val __caml_parser_env 3 : 'poly_type_no_attr) in + let _4 = (Parsing.peek_val __caml_parser_env 2 : 'attributes) in + let _6 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in + Obj.repr( +# 2360 "parsing/parser.mly" + ( let info = + match rhs_info 4 with + | Some _ as info_before_semi -> info_before_semi + | None -> symbol_info () + in + ( Otag (mkrhs _1 1, add_info_attrs info (_4 @ _6), _3)) ) +# 12139 "parsing/parser.ml" + : 'field_semi)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'simple_core_type) in + Obj.repr( +# 2369 "parsing/parser.mly" + ( Oinherit _1 ) +# 12146 "parsing/parser.ml" + : 'inherit_field_semi)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2372 "parsing/parser.mly" + ( _1 ) +# 12153 "parsing/parser.ml" + : 'label)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string * char option) in + Obj.repr( +# 2378 "parsing/parser.mly" + ( let (n, m) = _1 in Pconst_integer (n, m) ) +# 12160 "parsing/parser.ml" + : 'constant)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : char) in + Obj.repr( +# 2379 "parsing/parser.mly" + ( Pconst_char _1 ) +# 12167 "parsing/parser.ml" + : 'constant)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string * string option) in + Obj.repr( +# 2380 "parsing/parser.mly" + ( let (s, d) = _1 in Pconst_string (s, d) ) +# 12174 "parsing/parser.ml" + : 'constant)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string * char option) in + Obj.repr( +# 2381 "parsing/parser.mly" + ( let (f, m) = _1 in Pconst_float (f, m) ) +# 12181 "parsing/parser.ml" + : 'constant)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'constant) in + Obj.repr( +# 2384 "parsing/parser.mly" + ( _1 ) +# 12188 "parsing/parser.ml" + : 'signed_constant)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : string * char option) in + Obj.repr( +# 2385 "parsing/parser.mly" + ( let (n, m) = _2 in Pconst_integer("-" ^ n, m) ) +# 12195 "parsing/parser.ml" + : 'signed_constant)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : string * char option) in + Obj.repr( +# 2386 "parsing/parser.mly" + ( let (f, m) = _2 in Pconst_float("-" ^ f, m) ) +# 12202 "parsing/parser.ml" + : 'signed_constant)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : string * char option) in + Obj.repr( +# 2387 "parsing/parser.mly" + ( let (n, m) = _2 in Pconst_integer (n, m) ) +# 12209 "parsing/parser.ml" + : 'signed_constant)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : string * char option) in + Obj.repr( +# 2388 "parsing/parser.mly" + ( let (f, m) = _2 in Pconst_float(f, m) ) +# 12216 "parsing/parser.ml" + : 'signed_constant)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2394 "parsing/parser.mly" + ( _1 ) +# 12223 "parsing/parser.ml" + : 'ident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2395 "parsing/parser.mly" + ( _1 ) +# 12230 "parsing/parser.ml" + : 'ident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2398 "parsing/parser.mly" + ( _1 ) +# 12237 "parsing/parser.ml" + : 'val_ident)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'operator) in + Obj.repr( +# 2399 "parsing/parser.mly" + ( _2 ) +# 12244 "parsing/parser.ml" + : 'val_ident)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'operator) in + Obj.repr( +# 2400 "parsing/parser.mly" + ( unclosed "(" 1 ")" 3 ) +# 12251 "parsing/parser.ml" + : 'val_ident)) +; (fun __caml_parser_env -> + Obj.repr( +# 2401 "parsing/parser.mly" + ( expecting 2 "operator" ) +# 12257 "parsing/parser.ml" + : 'val_ident)) +; (fun __caml_parser_env -> + Obj.repr( +# 2402 "parsing/parser.mly" + ( expecting 3 "module-expr" ) +# 12263 "parsing/parser.ml" + : 'val_ident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2405 "parsing/parser.mly" + ( _1 ) +# 12270 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2406 "parsing/parser.mly" + ( _1 ) +# 12277 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2407 "parsing/parser.mly" + ( _1 ) +# 12284 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2408 "parsing/parser.mly" + ( _1 ) +# 12291 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2409 "parsing/parser.mly" + ( _1 ) +# 12298 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2410 "parsing/parser.mly" + ( _1 ) +# 12305 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : string) in + Obj.repr( +# 2411 "parsing/parser.mly" + ( "."^ _1 ^"()" ) +# 12312 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 3 : string) in + Obj.repr( +# 2412 "parsing/parser.mly" + ( "."^ _1 ^ "()<-" ) +# 12319 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : string) in + Obj.repr( +# 2413 "parsing/parser.mly" + ( "."^ _1 ^"[]" ) +# 12326 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 3 : string) in + Obj.repr( +# 2414 "parsing/parser.mly" + ( "."^ _1 ^ "[]<-" ) +# 12333 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : string) in + Obj.repr( +# 2415 "parsing/parser.mly" + ( "."^ _1 ^"{}" ) +# 12340 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 3 : string) in + Obj.repr( +# 2416 "parsing/parser.mly" + ( "."^ _1 ^ "{}<-" ) +# 12347 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2417 "parsing/parser.mly" + ( _1 ) +# 12354 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + Obj.repr( +# 2418 "parsing/parser.mly" + ( "!" ) +# 12360 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + Obj.repr( +# 2419 "parsing/parser.mly" + ( "+" ) +# 12366 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + Obj.repr( +# 2420 "parsing/parser.mly" + ( "+." ) +# 12372 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + Obj.repr( +# 2421 "parsing/parser.mly" + ( "-" ) +# 12378 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + Obj.repr( +# 2422 "parsing/parser.mly" + ( "-." ) +# 12384 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + Obj.repr( +# 2423 "parsing/parser.mly" + ( "*" ) +# 12390 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + Obj.repr( +# 2424 "parsing/parser.mly" + ( "=" ) +# 12396 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + Obj.repr( +# 2425 "parsing/parser.mly" + ( "<" ) +# 12402 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + Obj.repr( +# 2426 "parsing/parser.mly" + ( ">" ) +# 12408 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + Obj.repr( +# 2427 "parsing/parser.mly" + ( "or" ) +# 12414 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + Obj.repr( +# 2428 "parsing/parser.mly" + ( "||" ) +# 12420 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + Obj.repr( +# 2429 "parsing/parser.mly" + ( "&" ) +# 12426 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + Obj.repr( +# 2430 "parsing/parser.mly" + ( "&&" ) +# 12432 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + Obj.repr( +# 2431 "parsing/parser.mly" + ( ":=" ) +# 12438 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + Obj.repr( +# 2432 "parsing/parser.mly" + ( "+=" ) +# 12444 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + Obj.repr( +# 2433 "parsing/parser.mly" + ( "%" ) +# 12450 "parsing/parser.ml" + : 'operator)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2436 "parsing/parser.mly" + ( _1 ) +# 12457 "parsing/parser.ml" + : 'constr_ident)) +; (fun __caml_parser_env -> + Obj.repr( +# 2437 "parsing/parser.mly" + ( "[]" ) +# 12463 "parsing/parser.ml" + : 'constr_ident)) +; (fun __caml_parser_env -> + Obj.repr( +# 2438 "parsing/parser.mly" + ( "()" ) +# 12469 "parsing/parser.ml" + : 'constr_ident)) +; (fun __caml_parser_env -> + Obj.repr( +# 2439 "parsing/parser.mly" + ( "::" ) +# 12475 "parsing/parser.ml" + : 'constr_ident)) +; (fun __caml_parser_env -> + Obj.repr( +# 2440 "parsing/parser.mly" + ( "false" ) +# 12481 "parsing/parser.ml" + : 'constr_ident)) +; (fun __caml_parser_env -> + Obj.repr( +# 2441 "parsing/parser.mly" + ( "true" ) +# 12487 "parsing/parser.ml" + : 'constr_ident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'val_ident) in + Obj.repr( +# 2445 "parsing/parser.mly" + ( Lident _1 ) +# 12494 "parsing/parser.ml" + : 'val_longident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'mod_longident) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'val_ident) in + Obj.repr( +# 2446 "parsing/parser.mly" + ( Ldot(_1, _3) ) +# 12502 "parsing/parser.ml" + : 'val_longident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'mod_longident) in + Obj.repr( +# 2449 "parsing/parser.mly" + ( _1 ) +# 12509 "parsing/parser.ml" + : 'constr_longident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 4 : 'mod_longident) in + Obj.repr( +# 2450 "parsing/parser.mly" + ( Ldot(_1,"::") ) +# 12516 "parsing/parser.ml" + : 'constr_longident)) +; (fun __caml_parser_env -> + Obj.repr( +# 2451 "parsing/parser.mly" + ( Lident "[]" ) +# 12522 "parsing/parser.ml" + : 'constr_longident)) +; (fun __caml_parser_env -> + Obj.repr( +# 2452 "parsing/parser.mly" + ( Lident "()" ) +# 12528 "parsing/parser.ml" + : 'constr_longident)) +; (fun __caml_parser_env -> + Obj.repr( +# 2453 "parsing/parser.mly" + ( Lident "::" ) +# 12534 "parsing/parser.ml" + : 'constr_longident)) +; (fun __caml_parser_env -> + Obj.repr( +# 2454 "parsing/parser.mly" + ( Lident "false" ) +# 12540 "parsing/parser.ml" + : 'constr_longident)) +; (fun __caml_parser_env -> + Obj.repr( +# 2455 "parsing/parser.mly" + ( Lident "true" ) +# 12546 "parsing/parser.ml" + : 'constr_longident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2458 "parsing/parser.mly" + ( Lident _1 ) +# 12553 "parsing/parser.ml" + : 'label_longident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'mod_longident) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2459 "parsing/parser.mly" + ( Ldot(_1, _3) ) +# 12561 "parsing/parser.ml" + : 'label_longident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2462 "parsing/parser.mly" + ( Lident _1 ) +# 12568 "parsing/parser.ml" + : 'type_longident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'mod_ext_longident) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2463 "parsing/parser.mly" + ( Ldot(_1, _3) ) +# 12576 "parsing/parser.ml" + : 'type_longident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2466 "parsing/parser.mly" + ( Lident _1 ) +# 12583 "parsing/parser.ml" + : 'mod_longident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'mod_longident) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2467 "parsing/parser.mly" + ( Ldot(_1, _3) ) +# 12591 "parsing/parser.ml" + : 'mod_longident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2470 "parsing/parser.mly" + ( Lident _1 ) +# 12598 "parsing/parser.ml" + : 'mod_ext_longident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'mod_ext_longident) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2471 "parsing/parser.mly" + ( Ldot(_1, _3) ) +# 12606 "parsing/parser.ml" + : 'mod_ext_longident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 3 : 'mod_ext_longident) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'mod_ext_longident) in + Obj.repr( +# 2472 "parsing/parser.mly" + ( lapply _1 _3 ) +# 12614 "parsing/parser.ml" + : 'mod_ext_longident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'ident) in + Obj.repr( +# 2475 "parsing/parser.mly" + ( Lident _1 ) +# 12621 "parsing/parser.ml" + : 'mty_longident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'mod_ext_longident) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'ident) in + Obj.repr( +# 2476 "parsing/parser.mly" + ( Ldot(_1, _3) ) +# 12629 "parsing/parser.ml" + : 'mty_longident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2479 "parsing/parser.mly" + ( Lident _1 ) +# 12636 "parsing/parser.ml" + : 'clty_longident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'mod_ext_longident) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2480 "parsing/parser.mly" + ( Ldot(_1, _3) ) +# 12644 "parsing/parser.ml" + : 'clty_longident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2483 "parsing/parser.mly" + ( Lident _1 ) +# 12651 "parsing/parser.ml" + : 'class_longident)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'mod_longident) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2484 "parsing/parser.mly" + ( Ldot(_1, _3) ) +# 12659 "parsing/parser.ml" + : 'class_longident)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'ident) in + Obj.repr( +# 2490 "parsing/parser.mly" + ( Ptop_dir(_2, Pdir_none) ) +# 12666 "parsing/parser.ml" + : 'toplevel_directive)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ident) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : string * string option) in + Obj.repr( +# 2491 "parsing/parser.mly" + ( Ptop_dir(_2, Pdir_string (fst _3)) ) +# 12674 "parsing/parser.ml" + : 'toplevel_directive)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ident) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : string * char option) in + Obj.repr( +# 2492 "parsing/parser.mly" + ( let (n, m) = _3 in + Ptop_dir(_2, Pdir_int (n ,m)) ) +# 12683 "parsing/parser.ml" + : 'toplevel_directive)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ident) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'val_longident) in + Obj.repr( +# 2494 "parsing/parser.mly" + ( Ptop_dir(_2, Pdir_ident _3) ) +# 12691 "parsing/parser.ml" + : 'toplevel_directive)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ident) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'mod_longident) in + Obj.repr( +# 2495 "parsing/parser.mly" + ( Ptop_dir(_2, Pdir_ident _3) ) +# 12699 "parsing/parser.ml" + : 'toplevel_directive)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ident) in + Obj.repr( +# 2496 "parsing/parser.mly" + ( Ptop_dir(_2, Pdir_bool false) ) +# 12706 "parsing/parser.ml" + : 'toplevel_directive)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'ident) in + Obj.repr( +# 2497 "parsing/parser.mly" + ( Ptop_dir(_2, Pdir_bool true) ) +# 12713 "parsing/parser.ml" + : 'toplevel_directive)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'ident) in + Obj.repr( +# 2503 "parsing/parser.mly" + ( _2 ) +# 12720 "parsing/parser.ml" + : 'name_tag)) +; (fun __caml_parser_env -> + Obj.repr( +# 2506 "parsing/parser.mly" + ( Nonrecursive ) +# 12726 "parsing/parser.ml" + : 'rec_flag)) +; (fun __caml_parser_env -> + Obj.repr( +# 2507 "parsing/parser.mly" + ( Recursive ) +# 12732 "parsing/parser.ml" + : 'rec_flag)) +; (fun __caml_parser_env -> + Obj.repr( +# 2510 "parsing/parser.mly" + ( Recursive ) +# 12738 "parsing/parser.ml" + : 'nonrec_flag)) +; (fun __caml_parser_env -> + Obj.repr( +# 2511 "parsing/parser.mly" + ( Nonrecursive ) +# 12744 "parsing/parser.ml" + : 'nonrec_flag)) +; (fun __caml_parser_env -> + Obj.repr( +# 2514 "parsing/parser.mly" + ( Upto ) +# 12750 "parsing/parser.ml" + : 'direction_flag)) +; (fun __caml_parser_env -> + Obj.repr( +# 2515 "parsing/parser.mly" + ( Downto ) +# 12756 "parsing/parser.ml" + : 'direction_flag)) +; (fun __caml_parser_env -> + Obj.repr( +# 2518 "parsing/parser.mly" + ( Public ) +# 12762 "parsing/parser.ml" + : 'private_flag)) +; (fun __caml_parser_env -> + Obj.repr( +# 2519 "parsing/parser.mly" + ( Private ) +# 12768 "parsing/parser.ml" + : 'private_flag)) +; (fun __caml_parser_env -> + Obj.repr( +# 2522 "parsing/parser.mly" + ( Immutable ) +# 12774 "parsing/parser.ml" + : 'mutable_flag)) +; (fun __caml_parser_env -> + Obj.repr( +# 2523 "parsing/parser.mly" + ( Mutable ) +# 12780 "parsing/parser.ml" + : 'mutable_flag)) +; (fun __caml_parser_env -> + Obj.repr( +# 2526 "parsing/parser.mly" + ( Concrete ) +# 12786 "parsing/parser.ml" + : 'virtual_flag)) +; (fun __caml_parser_env -> + Obj.repr( +# 2527 "parsing/parser.mly" + ( Virtual ) +# 12792 "parsing/parser.ml" + : 'virtual_flag)) +; (fun __caml_parser_env -> + Obj.repr( +# 2530 "parsing/parser.mly" + ( Public, Concrete ) +# 12798 "parsing/parser.ml" + : 'private_virtual_flags)) +; (fun __caml_parser_env -> + Obj.repr( +# 2531 "parsing/parser.mly" + ( Private, Concrete ) +# 12804 "parsing/parser.ml" + : 'private_virtual_flags)) +; (fun __caml_parser_env -> + Obj.repr( +# 2532 "parsing/parser.mly" + ( Public, Virtual ) +# 12810 "parsing/parser.ml" + : 'private_virtual_flags)) +; (fun __caml_parser_env -> + Obj.repr( +# 2533 "parsing/parser.mly" + ( Private, Virtual ) +# 12816 "parsing/parser.ml" + : 'private_virtual_flags)) +; (fun __caml_parser_env -> + Obj.repr( +# 2534 "parsing/parser.mly" + ( Private, Virtual ) +# 12822 "parsing/parser.ml" + : 'private_virtual_flags)) +; (fun __caml_parser_env -> + Obj.repr( +# 2537 "parsing/parser.mly" + ( Fresh ) +# 12828 "parsing/parser.ml" + : 'override_flag)) +; (fun __caml_parser_env -> + Obj.repr( +# 2538 "parsing/parser.mly" + ( Override ) +# 12834 "parsing/parser.ml" + : 'override_flag)) +; (fun __caml_parser_env -> + Obj.repr( +# 2541 "parsing/parser.mly" + ( () ) +# 12840 "parsing/parser.ml" + : 'opt_bar)) +; (fun __caml_parser_env -> + Obj.repr( +# 2542 "parsing/parser.mly" + ( () ) +# 12846 "parsing/parser.ml" + : 'opt_bar)) +; (fun __caml_parser_env -> + Obj.repr( +# 2545 "parsing/parser.mly" + ( () ) +# 12852 "parsing/parser.ml" + : 'opt_semi)) +; (fun __caml_parser_env -> + Obj.repr( +# 2546 "parsing/parser.mly" + ( () ) +# 12858 "parsing/parser.ml" + : 'opt_semi)) +; (fun __caml_parser_env -> + Obj.repr( +# 2549 "parsing/parser.mly" + ( "-" ) +# 12864 "parsing/parser.ml" + : 'subtractive)) +; (fun __caml_parser_env -> + Obj.repr( +# 2550 "parsing/parser.mly" + ( "-." ) +# 12870 "parsing/parser.ml" + : 'subtractive)) +; (fun __caml_parser_env -> + Obj.repr( +# 2553 "parsing/parser.mly" + ( "+" ) +# 12876 "parsing/parser.ml" + : 'additive)) +; (fun __caml_parser_env -> + Obj.repr( +# 2554 "parsing/parser.mly" + ( "+." ) +# 12882 "parsing/parser.ml" + : 'additive)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2560 "parsing/parser.mly" + ( _1 ) +# 12889 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : string) in + Obj.repr( +# 2561 "parsing/parser.mly" + ( _1 ) +# 12896 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2562 "parsing/parser.mly" + ( "and" ) +# 12902 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2563 "parsing/parser.mly" + ( "as" ) +# 12908 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2564 "parsing/parser.mly" + ( "assert" ) +# 12914 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2565 "parsing/parser.mly" + ( "begin" ) +# 12920 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2566 "parsing/parser.mly" + ( "class" ) +# 12926 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2567 "parsing/parser.mly" + ( "constraint" ) +# 12932 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2568 "parsing/parser.mly" + ( "do" ) +# 12938 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2569 "parsing/parser.mly" + ( "done" ) +# 12944 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2570 "parsing/parser.mly" + ( "downto" ) +# 12950 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2571 "parsing/parser.mly" + ( "else" ) +# 12956 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2572 "parsing/parser.mly" + ( "end" ) +# 12962 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2573 "parsing/parser.mly" + ( "exception" ) +# 12968 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2574 "parsing/parser.mly" + ( "external" ) +# 12974 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2575 "parsing/parser.mly" + ( "false" ) +# 12980 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2576 "parsing/parser.mly" + ( "for" ) +# 12986 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2577 "parsing/parser.mly" + ( "fun" ) +# 12992 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2578 "parsing/parser.mly" + ( "function" ) +# 12998 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2579 "parsing/parser.mly" + ( "functor" ) +# 13004 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2580 "parsing/parser.mly" + ( "if" ) +# 13010 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2581 "parsing/parser.mly" + ( "in" ) +# 13016 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2582 "parsing/parser.mly" + ( "include" ) +# 13022 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2583 "parsing/parser.mly" + ( "inherit" ) +# 13028 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2584 "parsing/parser.mly" + ( "initializer" ) +# 13034 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2585 "parsing/parser.mly" + ( "lazy" ) +# 13040 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2586 "parsing/parser.mly" + ( "let" ) +# 13046 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2587 "parsing/parser.mly" + ( "match" ) +# 13052 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2588 "parsing/parser.mly" + ( "method" ) +# 13058 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2589 "parsing/parser.mly" + ( "module" ) +# 13064 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2590 "parsing/parser.mly" + ( "mutable" ) +# 13070 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2591 "parsing/parser.mly" + ( "new" ) +# 13076 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2592 "parsing/parser.mly" + ( "nonrec" ) +# 13082 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2593 "parsing/parser.mly" + ( "object" ) +# 13088 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2594 "parsing/parser.mly" + ( "of" ) +# 13094 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2595 "parsing/parser.mly" + ( "open" ) +# 13100 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2596 "parsing/parser.mly" + ( "or" ) +# 13106 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2597 "parsing/parser.mly" + ( "private" ) +# 13112 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2598 "parsing/parser.mly" + ( "rec" ) +# 13118 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2599 "parsing/parser.mly" + ( "sig" ) +# 13124 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2600 "parsing/parser.mly" + ( "struct" ) +# 13130 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2601 "parsing/parser.mly" + ( "then" ) +# 13136 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2602 "parsing/parser.mly" + ( "to" ) +# 13142 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2603 "parsing/parser.mly" + ( "true" ) +# 13148 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2604 "parsing/parser.mly" + ( "try" ) +# 13154 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2605 "parsing/parser.mly" + ( "type" ) +# 13160 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2606 "parsing/parser.mly" + ( "val" ) +# 13166 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2607 "parsing/parser.mly" + ( "virtual" ) +# 13172 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2608 "parsing/parser.mly" + ( "when" ) +# 13178 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2609 "parsing/parser.mly" + ( "while" ) +# 13184 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + Obj.repr( +# 2610 "parsing/parser.mly" + ( "with" ) +# 13190 "parsing/parser.ml" + : 'single_attr_id)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'single_attr_id) in + Obj.repr( +# 2615 "parsing/parser.mly" + ( mkloc _1 (symbol_rloc()) ) +# 13197 "parsing/parser.ml" + : 'attr_id)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 2 : 'single_attr_id) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'attr_id) in + Obj.repr( +# 2616 "parsing/parser.mly" + ( mkloc (_1 ^ "." ^ _3.txt) (symbol_rloc())) +# 13205 "parsing/parser.ml" + : 'attr_id)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attr_id) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'payload) in + Obj.repr( +# 2619 "parsing/parser.mly" + ( (_2, _3) ) +# 13213 "parsing/parser.ml" + : 'attribute)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attr_id) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'payload) in + Obj.repr( +# 2622 "parsing/parser.mly" + ( (_2, _3) ) +# 13221 "parsing/parser.ml" + : 'post_item_attribute)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attr_id) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'payload) in + Obj.repr( +# 2625 "parsing/parser.mly" + ( (_2, _3) ) +# 13229 "parsing/parser.ml" + : 'floating_attribute)) +; (fun __caml_parser_env -> + Obj.repr( +# 2628 "parsing/parser.mly" + ( [] ) +# 13235 "parsing/parser.ml" + : 'post_item_attributes)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'post_item_attribute) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'post_item_attributes) in + Obj.repr( +# 2629 "parsing/parser.mly" + ( _1 :: _2 ) +# 13243 "parsing/parser.ml" + : 'post_item_attributes)) +; (fun __caml_parser_env -> + Obj.repr( +# 2632 "parsing/parser.mly" + ( [] ) +# 13249 "parsing/parser.ml" + : 'attributes)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'attribute) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in + Obj.repr( +# 2633 "parsing/parser.mly" + ( _1 :: _2 ) +# 13257 "parsing/parser.ml" + : 'attributes)) +; (fun __caml_parser_env -> + Obj.repr( +# 2636 "parsing/parser.mly" + ( None, [] ) +# 13263 "parsing/parser.ml" + : 'ext_attributes)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 1 : 'attribute) in + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in + Obj.repr( +# 2637 "parsing/parser.mly" + ( None, _1 :: _2 ) +# 13271 "parsing/parser.ml" + : 'ext_attributes)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 1 : 'attr_id) in + let _3 = (Parsing.peek_val __caml_parser_env 0 : 'attributes) in + Obj.repr( +# 2638 "parsing/parser.mly" + ( Some _2, _3 ) +# 13279 "parsing/parser.ml" + : 'ext_attributes)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attr_id) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'payload) in + Obj.repr( +# 2641 "parsing/parser.mly" + ( (_2, _3) ) +# 13287 "parsing/parser.ml" + : 'extension)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'attr_id) in + let _3 = (Parsing.peek_val __caml_parser_env 1 : 'payload) in + Obj.repr( +# 2644 "parsing/parser.mly" + ( (_2, _3) ) +# 13295 "parsing/parser.ml" + : 'item_extension)) +; (fun __caml_parser_env -> + let _1 = (Parsing.peek_val __caml_parser_env 0 : 'structure) in + Obj.repr( +# 2647 "parsing/parser.mly" + ( PStr _1 ) +# 13302 "parsing/parser.ml" + : 'payload)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'signature) in + Obj.repr( +# 2648 "parsing/parser.mly" + ( PSig _2 ) +# 13309 "parsing/parser.ml" + : 'payload)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'core_type) in + Obj.repr( +# 2649 "parsing/parser.mly" + ( PTyp _2 ) +# 13316 "parsing/parser.ml" + : 'payload)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 0 : 'pattern) in + Obj.repr( +# 2650 "parsing/parser.mly" + ( PPat (_2, None) ) +# 13323 "parsing/parser.ml" + : 'payload)) +; (fun __caml_parser_env -> + let _2 = (Parsing.peek_val __caml_parser_env 2 : 'pattern) in + let _4 = (Parsing.peek_val __caml_parser_env 0 : 'seq_expr) in + Obj.repr( +# 2651 "parsing/parser.mly" + ( PPat (_2, Some _4) ) +# 13331 "parsing/parser.ml" + : 'payload)) +(* Entry implementation *) +; (fun __caml_parser_env -> raise (Parsing.YYexit (Parsing.peek_val __caml_parser_env 0))) +(* Entry interface *) +; (fun __caml_parser_env -> raise (Parsing.YYexit (Parsing.peek_val __caml_parser_env 0))) +(* Entry toplevel_phrase *) +; (fun __caml_parser_env -> raise (Parsing.YYexit (Parsing.peek_val __caml_parser_env 0))) +(* Entry use_file *) +; (fun __caml_parser_env -> raise (Parsing.YYexit (Parsing.peek_val __caml_parser_env 0))) +(* Entry parse_core_type *) +; (fun __caml_parser_env -> raise (Parsing.YYexit (Parsing.peek_val __caml_parser_env 0))) +(* Entry parse_expression *) +; (fun __caml_parser_env -> raise (Parsing.YYexit (Parsing.peek_val __caml_parser_env 0))) +(* Entry parse_pattern *) +; (fun __caml_parser_env -> raise (Parsing.YYexit (Parsing.peek_val __caml_parser_env 0))) +|] +let yytables = + { Parsing.actions=yyact; + Parsing.transl_const=yytransl_const; + Parsing.transl_block=yytransl_block; + Parsing.lhs=yylhs; + Parsing.len=yylen; + Parsing.defred=yydefred; + Parsing.dgoto=yydgoto; + Parsing.sindex=yysindex; + Parsing.rindex=yyrindex; + Parsing.gindex=yygindex; + Parsing.tablesize=yytablesize; + Parsing.table=yytable; + Parsing.check=yycheck; + Parsing.error_function=parse_error; + Parsing.names_const=yynames_const; + Parsing.names_block=yynames_block } +let implementation (lexfun : Lexing.lexbuf -> token) (lexbuf : Lexing.lexbuf) = + (Parsing.yyparse yytables 1 lexfun lexbuf : Parsetree.structure) +let interface (lexfun : Lexing.lexbuf -> token) (lexbuf : Lexing.lexbuf) = + (Parsing.yyparse yytables 2 lexfun lexbuf : Parsetree.signature) +let toplevel_phrase (lexfun : Lexing.lexbuf -> token) (lexbuf : Lexing.lexbuf) = + (Parsing.yyparse yytables 3 lexfun lexbuf : Parsetree.toplevel_phrase) +let use_file (lexfun : Lexing.lexbuf -> token) (lexbuf : Lexing.lexbuf) = + (Parsing.yyparse yytables 4 lexfun lexbuf : Parsetree.toplevel_phrase list) +let parse_core_type (lexfun : Lexing.lexbuf -> token) (lexbuf : Lexing.lexbuf) = + (Parsing.yyparse yytables 5 lexfun lexbuf : Parsetree.core_type) +let parse_expression (lexfun : Lexing.lexbuf -> token) (lexbuf : Lexing.lexbuf) = + (Parsing.yyparse yytables 6 lexfun lexbuf : Parsetree.expression) +let parse_pattern (lexfun : Lexing.lexbuf -> token) (lexbuf : Lexing.lexbuf) = + (Parsing.yyparse yytables 7 lexfun lexbuf : Parsetree.pattern) +;; end -module Btype : sig -#1 "btype.mli" +module Lexer : sig +#1 "lexer.mli" (**************************************************************************) (* *) (* OCaml *) @@ -36570,3177 +35038,4537 @@ module Btype : sig (* *) (**************************************************************************) -(* Basic operations on core types *) - -open Asttypes -open Types - -(**** Sets, maps and hashtables of types ****) - -module TypeSet : Set.S with type elt = type_expr -module TypeMap : Map.S with type key = type_expr -module TypeHash : Hashtbl.S with type key = type_expr - -(**** Levels ****) - -val generic_level: int - -val newty2: int -> type_desc -> type_expr - (* Create a type *) -val newgenty: type_desc -> type_expr - (* Create a generic type *) -val newgenvar: ?name:string -> unit -> type_expr - (* Return a fresh generic variable *) - -(* Use Tsubst instead -val newmarkedvar: int -> type_expr - (* Return a fresh marked variable *) -val newmarkedgenvar: unit -> type_expr - (* Return a fresh marked generic variable *) -*) - -(**** Types ****) - -val is_Tvar: type_expr -> bool -val is_Tunivar: type_expr -> bool -val is_Tconstr: type_expr -> bool -val dummy_method: label -val default_mty: module_type option -> module_type - -val repr: type_expr -> type_expr - (* Return the canonical representative of a type. *) - -val field_kind_repr: field_kind -> field_kind - (* Return the canonical representative of an object field - kind. *) - -val commu_repr: commutable -> commutable - (* Return the canonical representative of a commutation lock *) - -(**** polymorphic variants ****) - -val row_repr: row_desc -> row_desc - (* Return the canonical representative of a row description *) -val row_field_repr: row_field -> row_field -val row_field: label -> row_desc -> row_field - (* Return the canonical representative of a row field *) -val row_more: row_desc -> type_expr - (* Return the extension variable of the row *) -val row_fixed: row_desc -> bool - (* Return whether the row should be treated as fixed or not *) -val static_row: row_desc -> bool - (* Return whether the row is static or not *) -val hash_variant: label -> int - (* Hash function for variant tags *) - -val proxy: type_expr -> type_expr - (* Return the proxy representative of the type: either itself - or a row variable *) - -(**** Utilities for private abbreviations with fixed rows ****) -val row_of_type: type_expr -> type_expr -val has_constr_row: type_expr -> bool -val is_row_name: string -> bool -val is_constr_row: allow_ident:bool -> type_expr -> bool - -(**** Utilities for type traversal ****) - -val iter_type_expr: (type_expr -> unit) -> type_expr -> unit - (* Iteration on types *) -val iter_row: (type_expr -> unit) -> row_desc -> unit - (* Iteration on types in a row *) -val iter_abbrev: (type_expr -> unit) -> abbrev_memo -> unit - (* Iteration on types in an abbreviation list *) - -type type_iterators = - { it_signature: type_iterators -> signature -> unit; - it_signature_item: type_iterators -> signature_item -> unit; - it_value_description: type_iterators -> value_description -> unit; - it_type_declaration: type_iterators -> type_declaration -> unit; - it_extension_constructor: type_iterators -> extension_constructor -> unit; - it_module_declaration: type_iterators -> module_declaration -> unit; - it_modtype_declaration: type_iterators -> modtype_declaration -> unit; - it_class_declaration: type_iterators -> class_declaration -> unit; - it_class_type_declaration: type_iterators -> class_type_declaration -> unit; - it_module_type: type_iterators -> module_type -> unit; - it_class_type: type_iterators -> class_type -> unit; - it_type_kind: type_iterators -> type_kind -> unit; - it_do_type_expr: type_iterators -> type_expr -> unit; - it_type_expr: type_iterators -> type_expr -> unit; - it_path: Path.t -> unit; } -val type_iterators: type_iterators - (* Iteration on arbitrary type information. - [it_type_expr] calls [mark_type_node] to avoid loops. *) -val unmark_iterators: type_iterators - (* Unmark any structure containing types. See [unmark_type] below. *) - -val copy_type_desc: - ?keep_names:bool -> (type_expr -> type_expr) -> type_desc -> type_desc - (* Copy on types *) -val copy_row: - (type_expr -> type_expr) -> - bool -> row_desc -> bool -> type_expr -> row_desc -val copy_kind: field_kind -> field_kind - -val save_desc: type_expr -> type_desc -> unit - (* Save a type description *) -val dup_kind: field_kind option ref -> unit - (* Save a None field_kind, and make it point to a fresh Fvar *) -val cleanup_types: unit -> unit - (* Restore type descriptions *) - -val lowest_level: int - (* Marked type: ty.level < lowest_level *) -val pivot_level: int - (* Type marking: ty.level <- pivot_level - ty.level *) -val mark_type: type_expr -> unit - (* Mark a type *) -val mark_type_node: type_expr -> unit - (* Mark a type node (but not its sons) *) -val mark_type_params: type_expr -> unit - (* Mark the sons of a type node *) -val unmark_type: type_expr -> unit -val unmark_type_decl: type_declaration -> unit -val unmark_extension_constructor: extension_constructor -> unit -val unmark_class_type: class_type -> unit -val unmark_class_signature: class_signature -> unit - (* Remove marks from a type *) - -(**** Memorization of abbreviation expansion ****) - -val find_expans: private_flag -> Path.t -> abbrev_memo -> type_expr option - (* Look up a memorized abbreviation *) -val cleanup_abbrev: unit -> unit - (* Flush the cache of abbreviation expansions. - When some types are saved (using [output_value]), this - function MUST be called just before. *) -val memorize_abbrev: - abbrev_memo ref -> - private_flag -> Path.t -> type_expr -> type_expr -> unit - (* Add an expansion in the cache *) -val forget_abbrev: - abbrev_memo ref -> Path.t -> unit - (* Remove an abbreviation from the cache *) - -(**** Utilities for labels ****) - -val is_optional : arg_label -> bool -val label_name : arg_label -> label - -(* Returns the label name with first character '?' or '~' as appropriate. *) -val prefixed_label_name : arg_label -> label - -val extract_label : - label -> (arg_label * 'a) list -> - arg_label * 'a * (arg_label * 'a) list * (arg_label * 'a) list - (* actual label, value, before list, after list *) - -(**** Utilities for backtracking ****) - -type snapshot - (* A snapshot for backtracking *) -val snapshot: unit -> snapshot - (* Make a snapshot for later backtracking. Costs nothing *) -val backtrack: snapshot -> unit - (* Backtrack to a given snapshot. Only possible if you have - not already backtracked to a previous snapshot. - Calls [cleanup_abbrev] internally *) -val undo_compress: snapshot -> unit - (* Backtrack only path compression. Only meaningful if you have - not already backtracked to a previous snapshot. - Does not call [cleanup_abbrev] *) - -(* Functions to use when modifying a type (only Ctype?) *) -val link_type: type_expr -> type_expr -> unit - (* Set the desc field of [t1] to [Tlink t2], logging the old - value if there is an active snapshot *) -val set_level: type_expr -> int -> unit -val set_name: - (Path.t * type_expr list) option ref -> - (Path.t * type_expr list) option -> unit -val set_row_field: row_field option ref -> row_field -> unit -val set_univar: type_expr option ref -> type_expr -> unit -val set_kind: field_kind option ref -> field_kind -> unit -val set_commu: commutable ref -> commutable -> unit -val set_typeset: TypeSet.t ref -> TypeSet.t -> unit - (* Set references, logging the old value *) -val log_type: type_expr -> unit - (* Log the old value of a type, before modifying it by hand *) - -(**** Forward declarations ****) -val print_raw: (Format.formatter -> type_expr -> unit) ref - -val iter_type_expr_kind: (type_expr -> unit) -> (type_kind -> unit) - -val iter_type_expr_cstr_args: (type_expr -> unit) -> - (constructor_arguments -> unit) -val map_type_expr_cstr_args: (type_expr -> type_expr) -> - (constructor_arguments -> constructor_arguments) - -end = struct -#1 "btype.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy and Jerome Vouillon, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) - -(* Basic operations on core types *) - -open Misc -open Asttypes -open Types - -(**** Sets, maps and hashtables of types ****) - -module TypeSet = Set.Make(TypeOps) -module TypeMap = Map.Make (TypeOps) -module TypeHash = Hashtbl.Make(TypeOps) - -(**** Forward declarations ****) - -let print_raw = - ref (fun _ -> assert false : Format.formatter -> type_expr -> unit) - -(**** Type level management ****) - -let generic_level = 100000000 - -(* Used to mark a type during a traversal. *) -let lowest_level = 0 -let pivot_level = 2 * lowest_level - 1 - (* pivot_level - lowest_level < lowest_level *) - -(**** Some type creators ****) - -let new_id = ref (-1) - -let newty2 level desc = - incr new_id; { desc; level; id = !new_id } -let newgenty desc = newty2 generic_level desc -let newgenvar ?name () = newgenty (Tvar name) -(* -let newmarkedvar level = - incr new_id; { desc = Tvar; level = pivot_level - level; id = !new_id } -let newmarkedgenvar () = - incr new_id; - { desc = Tvar; level = pivot_level - generic_level; id = !new_id } -*) - -(**** Check some types ****) - -let is_Tvar = function {desc=Tvar _} -> true | _ -> false -let is_Tunivar = function {desc=Tunivar _} -> true | _ -> false -let is_Tconstr = function {desc=Tconstr _} -> true | _ -> false - -let dummy_method = "*dummy method*" -let default_mty = function - Some mty -> mty - | None -> Mty_signature [] - -(**** Definitions for backtracking ****) - -type change = - Ctype of type_expr * type_desc - | Ccompress of type_expr * type_desc * type_desc - | Clevel of type_expr * int - | Cname of - (Path.t * type_expr list) option ref * (Path.t * type_expr list) option - | Crow of row_field option ref * row_field option - | Ckind of field_kind option ref * field_kind option - | Ccommu of commutable ref * commutable - | Cuniv of type_expr option ref * type_expr option - | Ctypeset of TypeSet.t ref * TypeSet.t - -type changes = - Change of change * changes ref - | Unchanged - | Invalid - -let trail = Weak.create 1 - -let log_change ch = - match Weak.get trail 0 with None -> () - | Some r -> - let r' = ref Unchanged in - r := Change (ch, r'); - Weak.set trail 0 (Some r') - -(**** Representative of a type ****) - -let rec field_kind_repr = - function - Fvar {contents = Some kind} -> field_kind_repr kind - | kind -> kind - -let rec repr_link compress t d = - function - {desc = Tlink t' as d'} -> - repr_link true t d' t' - | {desc = Tfield (_, k, _, t') as d'} when field_kind_repr k = Fabsent -> - repr_link true t d' t' - | t' -> - if compress then begin - log_change (Ccompress (t, t.desc, d)); t.desc <- d - end; - t' - -let repr t = - match t.desc with - Tlink t' as d -> - repr_link false t d t' - | Tfield (_, k, _, t') as d when field_kind_repr k = Fabsent -> - repr_link false t d t' - | _ -> t - -let rec commu_repr = function - Clink r when !r <> Cunknown -> commu_repr !r - | c -> c - -let rec row_field_repr_aux tl = function - Reither(_, tl', _, {contents = Some fi}) -> - row_field_repr_aux (tl@tl') fi - | Reither(c, tl', m, r) -> - Reither(c, tl@tl', m, r) - | Rpresent (Some _) when tl <> [] -> - Rpresent (Some (List.hd tl)) - | fi -> fi - -let row_field_repr fi = row_field_repr_aux [] fi - -let rec rev_concat l ll = - match ll with - [] -> l - | l'::ll -> rev_concat (l'@l) ll +(* The lexical analyzer *) -let rec row_repr_aux ll row = - match (repr row.row_more).desc with - | Tvariant row' -> - let f = row.row_fields in - row_repr_aux (if f = [] then ll else f::ll) row' - | _ -> - if ll = [] then row else - {row with row_fields = rev_concat row.row_fields ll} +val init : unit -> unit +val token: Lexing.lexbuf -> Parser.token +val skip_hash_bang: Lexing.lexbuf -> unit -let row_repr row = row_repr_aux [] row +type directive_type -let rec row_field tag row = - let rec find = function - | (tag',f) :: fields -> - if tag = tag' then row_field_repr f else find fields - | [] -> - match repr row.row_more with - | {desc=Tvariant row'} -> row_field tag row' - | _ -> Rabsent - in find row.row_fields +type error = + | Illegal_character of char + | Illegal_escape of string + | Unterminated_comment of Location.t + | Unterminated_string + | Unterminated_string_in_comment of Location.t * Location.t + | Keyword_as_label of string + | Invalid_literal of string + | Invalid_directive of string * string option + | Unterminated_paren_in_conditional + | Unterminated_if + | Unterminated_else + | Unexpected_token_in_conditional + | Expect_hash_then_in_conditional + | Illegal_semver of string + | Unexpected_directive + | Conditional_expr_expected_type of directive_type * directive_type +;; -let rec row_more row = - match repr row.row_more with - | {desc=Tvariant row'} -> row_more row' - | ty -> ty +exception Error of error * Location.t -let row_fixed row = - let row = row_repr row in - row.row_fixed || - match (repr row.row_more).desc with - Tvar _ | Tnil -> false - | Tunivar _ | Tconstr _ -> true - | _ -> assert false +open Format -let static_row row = - let row = row_repr row in - row.row_closed && - List.for_all - (fun (_,f) -> match row_field_repr f with Reither _ -> false | _ -> true) - row.row_fields +val report_error: formatter -> error -> unit + (* Deprecated. Use Location.{error_of_exn, report_error}. *) -let hash_variant s = - let accu = ref 0 in - for i = 0 to String.length s - 1 do - accu := 223 * !accu + Char.code s.[i] - done; - (* reduce to 31 bits *) - accu := !accu land (1 lsl 31 - 1); - (* make it signed for 64 bits architectures *) - if !accu > 0x3FFFFFFF then !accu - (1 lsl 31) else !accu +val in_comment : unit -> bool;; +val in_string : unit -> bool;; -let proxy ty = - let ty0 = repr ty in - match ty0.desc with - | Tvariant row when not (static_row row) -> - row_more row - | Tobject (ty, _) -> - let rec proxy_obj ty = - match ty.desc with - Tfield (_, _, _, ty) | Tlink ty -> proxy_obj ty - | Tvar _ | Tunivar _ | Tconstr _ -> ty - | Tnil -> ty0 - | _ -> assert false - in proxy_obj ty - | _ -> ty0 -(**** Utilities for fixed row private types ****) +val print_warnings : bool ref +val handle_docstrings: bool ref +val comments : unit -> (string * Location.t) list +val token_with_comments : Lexing.lexbuf -> Parser.token -let row_of_type t = - match (repr t).desc with - Tobject(t,_) -> - let rec get_row t = - let t = repr t in - match t.desc with - Tfield(_,_,_,t) -> get_row t - | _ -> t - in get_row t - | Tvariant row -> - row_more row - | _ -> - t +(* + [set_preprocessor init preprocessor] registers [init] as the function +to call to initialize the preprocessor when the lexer is initialized, +and [preprocessor] a function that is called when a new token is needed +by the parser, as [preprocessor lexer lexbuf] where [lexer] is the +lexing function. -let has_constr_row t = - not (is_Tconstr t) && is_Tconstr (row_of_type t) +When a preprocessor is configured by calling [set_preprocessor], the lexer +changes its behavior to accept backslash-newline as a token-separating blank. +*) -let is_row_name s = - let l = String.length s in - if l < 4 then false else String.sub s (l-4) 4 = "#row" +val set_preprocessor : + (unit -> unit) -> + ((Lexing.lexbuf -> Parser.token) -> Lexing.lexbuf -> Parser.token) -> + unit -let is_constr_row ~allow_ident t = - match t.desc with - Tconstr (Path.Pident id, _, _) when allow_ident -> - is_row_name (Ident.name id) - | Tconstr (Path.Pdot (_, s, _), _, _) -> is_row_name s - | _ -> false +(** semantic version predicate *) +val semver : Location.t -> string -> string -> bool +val filter_directive_from_lexbuf : Lexing.lexbuf -> (int * int) list - (**********************************) - (* Utilities for type traversal *) - (**********************************) +val replace_directive_int : string -> int -> unit +val replace_directive_string : string -> string -> unit +val replace_directive_bool : string -> bool -> unit +val remove_directive_built_in_value : string -> unit -let rec iter_row f row = - List.iter - (fun (_, fi) -> - match row_field_repr fi with - | Rpresent(Some ty) -> f ty - | Reither(_, tl, _, _) -> List.iter f tl - | _ -> ()) - row.row_fields; - match (repr row.row_more).desc with - Tvariant row -> iter_row f row - | Tvar _ | Tunivar _ | Tsubst _ | Tconstr _ | Tnil -> - Misc.may (fun (_,l) -> List.iter f l) row.row_name - | _ -> assert false +(** @return false means failed to define *) +val define_key_value : string -> string -> bool +val list_variables : Format.formatter -> unit -let iter_type_expr f ty = - match ty.desc with - Tvar _ -> () - | Tarrow (_, ty1, ty2, _) -> f ty1; f ty2 - | Ttuple l -> List.iter f l - | Tconstr (_, l, _) -> List.iter f l - | Tobject(ty, {contents = Some (_, p)}) - -> f ty; List.iter f p - | Tobject (ty, _) -> f ty - | Tvariant row -> iter_row f row; f (row_more row) - | Tfield (_, _, ty1, ty2) -> f ty1; f ty2 - | Tnil -> () - | Tlink ty -> f ty - | Tsubst ty -> f ty - | Tunivar _ -> () - | Tpoly (ty, tyl) -> f ty; List.iter f tyl - | Tpackage (_, _, l) -> List.iter f l +end = struct +#1 "lexer.ml" +# 18 "parsing/lexer.mll" + +open Lexing +open Misc +open Parser -let rec iter_abbrev f = function - Mnil -> () - | Mcons(_, _, ty, ty', rem) -> f ty; f ty'; iter_abbrev f rem - | Mlink rem -> iter_abbrev f !rem +type directive_value = + | Dir_bool of bool + | Dir_float of float + | Dir_int of int + | Dir_string of string + | Dir_null -type type_iterators = - { it_signature: type_iterators -> signature -> unit; - it_signature_item: type_iterators -> signature_item -> unit; - it_value_description: type_iterators -> value_description -> unit; - it_type_declaration: type_iterators -> type_declaration -> unit; - it_extension_constructor: type_iterators -> extension_constructor -> unit; - it_module_declaration: type_iterators -> module_declaration -> unit; - it_modtype_declaration: type_iterators -> modtype_declaration -> unit; - it_class_declaration: type_iterators -> class_declaration -> unit; - it_class_type_declaration: type_iterators -> class_type_declaration -> unit; - it_module_type: type_iterators -> module_type -> unit; - it_class_type: type_iterators -> class_type -> unit; - it_type_kind: type_iterators -> type_kind -> unit; - it_do_type_expr: type_iterators -> type_expr -> unit; - it_type_expr: type_iterators -> type_expr -> unit; - it_path: Path.t -> unit; } +type directive_type = + | Dir_type_bool + | Dir_type_float + | Dir_type_int + | Dir_type_string + | Dir_type_null -let iter_type_expr_cstr_args f = function - | Cstr_tuple tl -> List.iter f tl - | Cstr_record lbls -> List.iter (fun d -> f d.ld_type) lbls +let type_of_directive x = + match x with + | Dir_bool _ -> Dir_type_bool + | Dir_float _ -> Dir_type_float + | Dir_int _ -> Dir_type_int + | Dir_string _ -> Dir_type_string + | Dir_null -> Dir_type_null -let map_type_expr_cstr_args f = function - | Cstr_tuple tl -> Cstr_tuple (List.map f tl) - | Cstr_record lbls -> - Cstr_record (List.map (fun d -> {d with ld_type=f d.ld_type}) lbls) +let string_of_type_directive x = + match x with + | Dir_type_bool -> "bool" + | Dir_type_float -> "float" + | Dir_type_int -> "int" + | Dir_type_string -> "string" + | Dir_type_null -> "null" -let iter_type_expr_kind f = function - | Type_abstract -> () - | Type_variant cstrs -> - List.iter - (fun cd -> - iter_type_expr_cstr_args f cd.cd_args; - Misc.may f cd.cd_res - ) - cstrs - | Type_record(lbls, _) -> - List.iter (fun d -> f d.ld_type) lbls - | Type_open -> - () +type error = + | Illegal_character of char + | Illegal_escape of string + | Unterminated_comment of Location.t + | Unterminated_string + | Unterminated_string_in_comment of Location.t * Location.t + | Keyword_as_label of string + | Invalid_literal of string + | Invalid_directive of string * string option + | Unterminated_paren_in_conditional + | Unterminated_if + | Unterminated_else + | Unexpected_token_in_conditional + | Expect_hash_then_in_conditional + | Illegal_semver of string + | Unexpected_directive + | Conditional_expr_expected_type of directive_type * directive_type + +;; +exception Error of error * Location.t;; -let type_iterators = - let it_signature it = - List.iter (it.it_signature_item it) - and it_signature_item it = function - Sig_value (_, vd) -> it.it_value_description it vd - | Sig_type (_, td, _) -> it.it_type_declaration it td - | Sig_typext (_, td, _) -> it.it_extension_constructor it td - | Sig_module (_, md, _) -> it.it_module_declaration it md - | Sig_modtype (_, mtd) -> it.it_modtype_declaration it mtd - | Sig_class (_, cd, _) -> it.it_class_declaration it cd - | Sig_class_type (_, ctd, _) -> it.it_class_type_declaration it ctd - and it_value_description it vd = - it.it_type_expr it vd.val_type - and it_type_declaration it td = - List.iter (it.it_type_expr it) td.type_params; - may (it.it_type_expr it) td.type_manifest; - it.it_type_kind it td.type_kind - and it_extension_constructor it td = - it.it_path td.ext_type_path; - List.iter (it.it_type_expr it) td.ext_type_params; - iter_type_expr_cstr_args (it.it_type_expr it) td.ext_args; - may (it.it_type_expr it) td.ext_ret_type - and it_module_declaration it md = - it.it_module_type it md.md_type - and it_modtype_declaration it mtd = - may (it.it_module_type it) mtd.mtd_type - and it_class_declaration it cd = - List.iter (it.it_type_expr it) cd.cty_params; - it.it_class_type it cd.cty_type; - may (it.it_type_expr it) cd.cty_new; - it.it_path cd.cty_path - and it_class_type_declaration it ctd = - List.iter (it.it_type_expr it) ctd.clty_params; - it.it_class_type it ctd.clty_type; - it.it_path ctd.clty_path - and it_module_type it = function - Mty_ident p - | Mty_alias(_, p) -> it.it_path p - | Mty_signature sg -> it.it_signature it sg - | Mty_functor (_, mto, mt) -> - may (it.it_module_type it) mto; - it.it_module_type it mt - and it_class_type it = function - Cty_constr (p, tyl, cty) -> - it.it_path p; - List.iter (it.it_type_expr it) tyl; - it.it_class_type it cty - | Cty_signature cs -> - it.it_type_expr it cs.csig_self; - Vars.iter (fun _ (_,_,ty) -> it.it_type_expr it ty) cs.csig_vars; - List.iter - (fun (p, tl) -> it.it_path p; List.iter (it.it_type_expr it) tl) - cs.csig_inher - | Cty_arrow (_, ty, cty) -> - it.it_type_expr it ty; - it.it_class_type it cty - and it_type_kind it kind = - iter_type_expr_kind (it.it_type_expr it) kind - and it_do_type_expr it ty = - iter_type_expr (it.it_type_expr it) ty; - match ty.desc with - Tconstr (p, _, _) - | Tobject (_, {contents=Some (p, _)}) - | Tpackage (p, _, _) -> - it.it_path p - | Tvariant row -> - may (fun (p,_) -> it.it_path p) (row_repr row).row_name - | _ -> () - and it_path _p = () - in - { it_path; it_type_expr = it_do_type_expr; it_do_type_expr; - it_type_kind; it_class_type; it_module_type; - it_signature; it_class_type_declaration; it_class_declaration; - it_modtype_declaration; it_module_declaration; it_extension_constructor; - it_type_declaration; it_value_description; it_signature_item; } +let assert_same_type lexbuf x y = + let lhs = type_of_directive x in let rhs = type_of_directive y in + if lhs <> rhs then + raise (Error(Conditional_expr_expected_type(lhs,rhs), Location.curr lexbuf)) + else y -let copy_row f fixed row keep more = - let fields = List.map - (fun (l, fi) -> l, - match row_field_repr fi with - | Rpresent(Some ty) -> Rpresent(Some(f ty)) - | Reither(c, tl, m, e) -> - let e = if keep then e else ref None in - let m = if row.row_fixed then fixed else m in - let tl = List.map f tl in - Reither(c, tl, m, e) - | _ -> fi) - row.row_fields in - let name = - match row.row_name with None -> None - | Some (path, tl) -> Some (path, List.map f tl) in - { row_fields = fields; row_more = more; - row_bound = (); row_fixed = row.row_fixed && fixed; - row_closed = row.row_closed; row_name = name; } +let directive_built_in_values = + Hashtbl.create 51 -let rec copy_kind = function - Fvar{contents = Some k} -> copy_kind k - | Fvar _ -> Fvar (ref None) - | Fpresent -> Fpresent - | Fabsent -> assert false -let copy_commu c = - if commu_repr c = Cok then Cok else Clink (ref Cunknown) +let replace_directive_built_in_value k v = + Hashtbl.replace directive_built_in_values k v -(* Since univars may be used as row variables, we need to do some - encoding during substitution *) -let rec norm_univar ty = - match ty.desc with - Tunivar _ | Tsubst _ -> ty - | Tlink ty -> norm_univar ty - | Ttuple (ty :: _) -> norm_univar ty - | _ -> assert false +let remove_directive_built_in_value k = + Hashtbl.replace directive_built_in_values k Dir_null -let rec copy_type_desc ?(keep_names=false) f = function - Tvar _ as ty -> if keep_names then ty else Tvar None - | Tarrow (p, ty1, ty2, c)-> Tarrow (p, f ty1, f ty2, copy_commu c) - | Ttuple l -> Ttuple (List.map f l) - | Tconstr (p, l, _) -> Tconstr (p, List.map f l, ref Mnil) - | Tobject(ty, {contents = Some (p, tl)}) - -> Tobject (f ty, ref (Some(p, List.map f tl))) - | Tobject (ty, _) -> Tobject (f ty, ref None) - | Tvariant _ -> assert false (* too ambiguous *) - | Tfield (p, k, ty1, ty2) -> (* the kind is kept shared *) - Tfield (p, field_kind_repr k, f ty1, f ty2) - | Tnil -> Tnil - | Tlink ty -> copy_type_desc f ty.desc - | Tsubst _ -> assert false - | Tunivar _ as ty -> ty (* always keep the name *) - | Tpoly (ty, tyl) -> - let tyl = List.map (fun x -> norm_univar (f x)) tyl in - Tpoly (f ty, tyl) - | Tpackage (p, n, l) -> Tpackage (p, n, List.map f l) +let replace_directive_int k v = + Hashtbl.replace directive_built_in_values k (Dir_int v) -(* Utilities for copying *) +let replace_directive_bool k v = + Hashtbl.replace directive_built_in_values k (Dir_bool v) -let saved_desc = ref [] - (* Saved association of generic nodes with their description. *) +let replace_directive_string k v = + Hashtbl.replace directive_built_in_values k (Dir_string v) -let save_desc ty desc = - saved_desc := (ty, desc)::!saved_desc +let () = + (* Note we use {!Config} instead of {!Sys} becasue + we want to overwrite in some cases with the + same stdlib + *) + let version = + Config.version (* so that it can be overridden*) + in + replace_directive_built_in_value "OCAML_VERSION" + (Dir_string version); + replace_directive_built_in_value "OCAML_PATCH" + (Dir_string + (match String.rindex version '+' with + | exception Not_found -> "" + | i -> + String.sub version (i + 1) + (String.length version - i - 1))) + ; + replace_directive_built_in_value "OS_TYPE" + (Dir_string Sys.os_type); + replace_directive_built_in_value "BIG_ENDIAN" + (Dir_bool Sys.big_endian); + replace_directive_built_in_value "WORD_SIZE" + (Dir_int Sys.word_size) -let saved_kinds = ref [] (* duplicated kind variables *) -let new_kinds = ref [] (* new kind variables *) -let dup_kind r = - (match !r with None -> () | Some _ -> assert false); - if not (List.memq r !new_kinds) then begin - saved_kinds := r :: !saved_kinds; - let r' = ref None in - new_kinds := r' :: !new_kinds; - r := Some (Fvar r') - end +let find_directive_built_in_value k = + Hashtbl.find directive_built_in_values k -(* Restored type descriptions. *) -let cleanup_types () = - List.iter (fun (ty, desc) -> ty.desc <- desc) !saved_desc; - List.iter (fun r -> r := None) !saved_kinds; - saved_desc := []; saved_kinds := []; new_kinds := [] +let iter_directive_built_in_value f = Hashtbl.iter f directive_built_in_values -(* Mark a type. *) -let rec mark_type ty = - let ty = repr ty in - if ty.level >= lowest_level then begin - ty.level <- pivot_level - ty.level; - iter_type_expr mark_type ty - end +(* + {[ + # semver 0 "12";; + - : int * int * int * string = (12, 0, 0, "");; + # semver 0 "12.3";; + - : int * int * int * string = (12, 3, 0, "");; + semver 0 "12.3.10";; + - : int * int * int * string = (12, 3, 10, "");; + # semver 0 "12.3.10+x";; + - : int * int * int * string = (12, 3, 10, "+x") + ]} +*) +let zero = Char.code '0' +let dot = Char.code '.' +let semantic_version_parse str start last_index = + let rec aux start acc last_index = + if start <= last_index then + let c = Char.code (String.unsafe_get str start) in + if c = dot then (acc, start + 1) (* consume [4.] instead of [4]*) + else + let v = c - zero in + if v >=0 && v <= 9 then + aux (start + 1) (acc * 10 + v) last_index + else (acc , start) + else (acc, start) + in + let major, major_end = aux start 0 last_index in + let minor, minor_end = aux major_end 0 last_index in + let patch, patch_end = aux minor_end 0 last_index in + let additional = String.sub str patch_end (last_index - patch_end +1) in + (major, minor, patch), additional -let mark_type_node ty = - let ty = repr ty in - if ty.level >= lowest_level then begin - ty.level <- pivot_level - ty.level; - end +(** + {[ + semver Location.none "1.2.3" "~1.3.0" = false;; + semver Location.none "1.2.3" "^1.3.0" = true ;; + semver Location.none "1.2.3" ">1.3.0" = false ;; + semver Location.none "1.2.3" ">=1.3.0" = false ;; + semver Location.none "1.2.3" "<1.3.0" = true ;; + semver Location.none "1.2.3" "<=1.3.0" = true ;; + ]} +*) +let semver loc lhs str = + let last_index = String.length str - 1 in + if last_index < 0 then raise (Error(Illegal_semver str, loc)) + else + let pred, ((major, minor, _patch) as version, _) = + let v = String.unsafe_get str 0 in + match v with + | '>' -> + if last_index = 0 then raise (Error(Illegal_semver str, loc)) else + if String.unsafe_get str 1 = '=' then + `Ge, semantic_version_parse str 2 last_index + else `Gt, semantic_version_parse str 1 last_index + | '<' + -> + if last_index = 0 then raise (Error(Illegal_semver str, loc)) else + if String.unsafe_get str 1 = '=' then + `Le, semantic_version_parse str 2 last_index + else `Lt, semantic_version_parse str 1 last_index + | '^' + -> `Compatible, semantic_version_parse str 1 last_index + | '~' -> `Approximate, semantic_version_parse str 1 last_index + | _ -> `Exact, semantic_version_parse str 0 last_index + in + let ((l_major, l_minor, _l_patch) as lversion,_) = + semantic_version_parse lhs 0 (String.length lhs - 1) in + match pred with + | `Ge -> lversion >= version + | `Gt -> lversion > version + | `Le -> lversion <= version + | `Lt -> lversion < version + | `Approximate -> major = l_major && minor = l_minor + | `Compatible -> major = l_major + | `Exact -> lversion = version -let mark_type_params ty = - iter_type_expr mark_type ty -let type_iterators = - let it_type_expr it ty = - let ty = repr ty in - if ty.level >= lowest_level then begin - mark_type_node ty; - it.it_do_type_expr it ty; - end - in - {type_iterators with it_type_expr} +let pp_directive_value fmt (x : directive_value) = + match x with + | Dir_bool b -> Format.pp_print_bool fmt b + | Dir_int b -> Format.pp_print_int fmt b + | Dir_float b -> Format.pp_print_float fmt b + | Dir_string s -> Format.fprintf fmt "%S" s + | Dir_null -> Format.pp_print_string fmt "null" +let list_variables fmt = + iter_directive_built_in_value + (fun s dir_value -> + Format.fprintf + fmt "@[%s@ %a@]@." + s pp_directive_value dir_value + ) -(* Remove marks from a type. *) -let rec unmark_type ty = - let ty = repr ty in - if ty.level < lowest_level then begin - ty.level <- pivot_level - ty.level; - iter_type_expr unmark_type ty +let defined str = + begin match find_directive_built_in_value str with + | Dir_null -> false + | _ -> true + | exception _ -> + try ignore @@ Sys.getenv str; true with _ -> false end -let unmark_iterators = - let it_type_expr _it ty = unmark_type ty in - {type_iterators with it_type_expr} - -let unmark_type_decl decl = - unmark_iterators.it_type_declaration unmark_iterators decl - -let unmark_extension_constructor ext = - List.iter unmark_type ext.ext_type_params; - iter_type_expr_cstr_args unmark_type ext.ext_args; - Misc.may unmark_type ext.ext_ret_type - -let unmark_class_signature sign = - unmark_type sign.csig_self; - Vars.iter (fun _l (_m, _v, t) -> unmark_type t) sign.csig_vars - -let unmark_class_type cty = - unmark_iterators.it_class_type unmark_iterators cty - - - (*******************************************) - (* Memorization of abbreviation expansion *) - (*******************************************) - -(* Search whether the expansion has been memorized. *) - -let lte_public p1 p2 = (* Private <= Public *) - match p1, p2 with - | Private, _ | _, Public -> true - | Public, Private -> false - -let rec find_expans priv p1 = function - Mnil -> None - | Mcons (priv', p2, _ty0, ty, _) - when lte_public priv priv' && Path.same p1 p2 -> Some ty - | Mcons (_, _, _, _, rem) -> find_expans priv p1 rem - | Mlink {contents = rem} -> find_expans priv p1 rem - -(* debug: check for cycles in abbreviation. only works with -principal -let rec check_expans visited ty = - let ty = repr ty in - assert (not (List.memq ty visited)); - match ty.desc with - Tconstr (path, args, abbrev) -> - begin match find_expans path !abbrev with - Some ty' -> check_expans (ty :: visited) ty' - | None -> () +let query _loc str = + begin match find_directive_built_in_value str with + | Dir_null -> Dir_bool false + | v -> v + | exception Not_found -> + begin match Sys.getenv str with + | v -> + begin + try Dir_bool (bool_of_string v) with + _ -> + begin + try Dir_int (int_of_string v ) + with + _ -> + begin try (Dir_float (float_of_string v)) + with _ -> Dir_string v + end + end + end + | exception Not_found -> + Dir_bool false end - | _ -> () -*) - -let memo = ref [] - (* Contains the list of saved abbreviation expansions. *) - -let cleanup_abbrev () = - (* Remove all memorized abbreviation expansions. *) - List.iter (fun abbr -> abbr := Mnil) !memo; - memo := [] - -let memorize_abbrev mem priv path v v' = - (* Memorize the expansion of an abbreviation. *) - mem := Mcons (priv, path, v, v', !mem); - (* check_expans [] v; *) - memo := mem :: !memo + end -let rec forget_abbrev_rec mem path = - match mem with - Mnil -> - assert false - | Mcons (_, path', _, _, rem) when Path.same path path' -> - rem - | Mcons (priv, path', v, v', rem) -> - Mcons (priv, path', v, v', forget_abbrev_rec rem path) - | Mlink mem' -> - mem' := forget_abbrev_rec !mem' path; - raise Exit -let forget_abbrev mem path = - try mem := forget_abbrev_rec !mem path with Exit -> () +let define_key_value key v = + if String.length key > 0 + && Char.uppercase_ascii (key.[0]) = key.[0] then + begin + replace_directive_built_in_value key + begin + (* NEED Sync up across {!lexer.mll} {!bspp.ml} and here, + TODO: put it in {!lexer.mll} + *) + try Dir_bool (bool_of_string v) with + _ -> + begin + try Dir_int (int_of_string v ) + with + _ -> + begin try (Dir_float (float_of_string v)) + with _ -> Dir_string v + end + end + end; + true + end + else false -(* debug: check for invalid abbreviations -let rec check_abbrev_rec = function - Mnil -> true - | Mcons (_, ty1, ty2, rem) -> - repr ty1 != repr ty2 - | Mlink mem' -> - check_abbrev_rec !mem' +let cvt_int_literal s = + - int_of_string ("-" ^ s) + +let value_of_token loc (t : Parser.token) = + match t with + | INT (i,None) -> Dir_int (cvt_int_literal i) + | STRING (s,_) -> Dir_string s + | FLOAT (s,None) -> Dir_float (float_of_string s) + | TRUE -> Dir_bool true + | FALSE -> Dir_bool false + | UIDENT s -> query loc s + | _ -> raise (Error (Unexpected_token_in_conditional, loc)) -let check_memorized_abbrevs () = - List.for_all (fun mem -> check_abbrev_rec !mem) !memo -*) - (**********************************) - (* Utilities for labels *) - (**********************************) +let directive_parse token_with_comments lexbuf = + let look_ahead = ref None in + let token () : Parser.token = + let v = !look_ahead in + match v with + | Some v -> + look_ahead := None ; + v + | None -> + let rec skip () = + match token_with_comments lexbuf with + | COMMENT _ + | DOCSTRING _ + | EOL -> skip () + | EOF -> raise (Error (Unterminated_if, Location.curr lexbuf)) + | t -> t + in skip () + in + let push e = + (* INVARIANT: only look at most one token *) + assert (!look_ahead = None); + look_ahead := Some e + in + let rec + token_op calc ~no lhs = + match token () with + | (LESS + | GREATER + | INFIXOP0 "<=" + | INFIXOP0 ">=" + | EQUAL + | INFIXOP0 "<>" as op) -> + let f = + match op with + | LESS -> (<) + | GREATER -> (>) + | INFIXOP0 "<=" -> (<=) + | EQUAL -> (=) + | INFIXOP0 "<>" -> (<>) + | _ -> assert false + in + let curr_loc = Location.curr lexbuf in + let rhs = value_of_token curr_loc (token ()) in + not calc || + f lhs (assert_same_type lexbuf lhs rhs) + | INFIXOP0 "=~" -> + not calc || + begin match lhs with + | Dir_string s -> + let curr_loc = Location.curr lexbuf in + let rhs = value_of_token curr_loc (token ()) in + begin match rhs with + | Dir_string rhs -> + semver curr_loc s rhs + | _ -> + raise + (Error + ( Conditional_expr_expected_type + (Dir_type_string, type_of_directive lhs), Location.curr lexbuf)) + end + | _ -> raise + (Error + ( Conditional_expr_expected_type + (Dir_type_string, type_of_directive lhs), Location.curr lexbuf)) + end + | e -> no e + and + parse_or calc : bool = + parse_or_aux calc (parse_and calc) + and (* a || (b || (c || d))*) + parse_or_aux calc v : bool = + (* let l = v in *) + match token () with + | BARBAR -> + let b = parse_or (calc && not v) in + v || b + | e -> push e ; v + and parse_and calc = + parse_and_aux calc (parse_relation calc) + and parse_and_aux calc v = (* a && (b && (c && d)) *) + (* let l = v in *) + match token () with + | AMPERAMPER -> + let b = parse_and (calc && v) in + v && b + | e -> push e ; v + and parse_relation (calc : bool) : bool = + let curr_token = token () in + let curr_loc = Location.curr lexbuf in + match curr_token with + | TRUE -> true + | FALSE -> false + | UIDENT v -> + let value_v = query curr_loc v in + token_op calc + ~no:(fun e -> push e ; + match value_v with + | Dir_bool b -> b + | _ -> + let ty = type_of_directive value_v in + raise + (Error(Conditional_expr_expected_type (Dir_type_bool, ty), + curr_loc))) + value_v + | INT (v,None) -> + let num_v = cvt_int_literal v in + token_op calc + ~no:(fun e -> + push e; + num_v <> 0 + ) + (Dir_int num_v) + | FLOAT (v,None) -> + token_op calc + ~no:(fun _e -> + raise (Error(Conditional_expr_expected_type(Dir_type_bool, Dir_type_float), + curr_loc))) + (Dir_float (float_of_string v)) + | STRING (v,_) -> + token_op calc + ~no:(fun _e -> + raise (Error + (Conditional_expr_expected_type(Dir_type_bool, Dir_type_string), + curr_loc))) + (Dir_string v) + | LIDENT ("defined" | "undefined" as r) -> + let t = token () in + let loc = Location.curr lexbuf in + begin match t with + | UIDENT s -> + not calc || + if r.[0] = 'u' then + not @@ defined s + else defined s + | _ -> raise (Error (Unexpected_token_in_conditional, loc)) + end + | LPAREN -> + let v = parse_or calc in + begin match token () with + | RPAREN -> v + | _ -> raise (Error(Unterminated_paren_in_conditional, Location.curr lexbuf)) + end -let is_optional = function Optional _ -> true | _ -> false + | _ -> raise (Error (Unexpected_token_in_conditional, curr_loc)) + in + let v = parse_or true in + begin match token () with + | THEN -> v + | _ -> raise (Error (Expect_hash_then_in_conditional, Location.curr lexbuf)) + end -let label_name = function - Nolabel -> "" - | Labelled s - | Optional s -> s -let prefixed_label_name = function - Nolabel -> "" - | Labelled s -> "~" ^ s - | Optional s -> "?" ^ s +type dir_conditional = + | Dir_if_true + | Dir_if_false + | Dir_out -let rec extract_label_aux hd l = function - [] -> raise Not_found - | (l',t as p) :: ls -> - if label_name l' = l then (l', t, List.rev hd, ls) - else extract_label_aux (p::hd) l ls +(* let string_of_dir_conditional (x : dir_conditional) = *) +(* match x with *) +(* | Dir_if_true -> "Dir_if_true" *) +(* | Dir_if_false -> "Dir_if_false" *) +(* | Dir_out -> "Dir_out" *) -let extract_label l ls = extract_label_aux [] l ls +let is_elif (i : Parser.token ) = + match i with + | LIDENT "elif" -> true + | _ -> false (* avoid polymorphic equal *) - (**********************************) - (* Utilities for backtracking *) - (**********************************) +(* The table of keywords *) -let undo_change = function - Ctype (ty, desc) -> ty.desc <- desc - | Ccompress (ty, desc, _) -> ty.desc <- desc - | Clevel (ty, level) -> ty.level <- level - | Cname (r, v) -> r := v - | Crow (r, v) -> r := v - | Ckind (r, v) -> r := v - | Ccommu (r, v) -> r := v - | Cuniv (r, v) -> r := v - | Ctypeset (r, v) -> r := v +let keyword_table = + create_hashtable 149 [ + "and", AND; + "as", AS; + "assert", ASSERT; + "begin", BEGIN; + "class", CLASS; + "constraint", CONSTRAINT; + "do", DO; + "done", DONE; + "downto", DOWNTO; + "else", ELSE; + "end", END; + "exception", EXCEPTION; + "external", EXTERNAL; + "false", FALSE; + "for", FOR; + "fun", FUN; + "function", FUNCTION; + "functor", FUNCTOR; + "if", IF; + "in", IN; + "include", INCLUDE; + "inherit", INHERIT; + "initializer", INITIALIZER; + "lazy", LAZY; + "let", LET; + "match", MATCH; + "method", METHOD; + "module", MODULE; + "mutable", MUTABLE; + "new", NEW; + "nonrec", NONREC; + "object", OBJECT; + "of", OF; + "open", OPEN; + "or", OR; +(* "parser", PARSER; *) + "private", PRIVATE; + "rec", REC; + "sig", SIG; + "struct", STRUCT; + "then", THEN; + "to", TO; + "true", TRUE; + "try", TRY; + "type", TYPE; + "val", VAL; + "virtual", VIRTUAL; + "when", WHEN; + "while", WHILE; + "with", WITH; -type snapshot = changes ref * int -let last_snapshot = ref 0 + "lor", INFIXOP3("lor"); (* Should be INFIXOP2 *) + "lxor", INFIXOP3("lxor"); (* Should be INFIXOP2 *) + "mod", INFIXOP3("mod"); + "land", INFIXOP3("land"); + "lsl", INFIXOP4("lsl"); + "lsr", INFIXOP4("lsr"); + "asr", INFIXOP4("asr") +] -let log_type ty = - if ty.id <= !last_snapshot then log_change (Ctype (ty, ty.desc)) -let link_type ty ty' = - log_type ty; - let desc = ty.desc in - ty.desc <- Tlink ty'; - (* Name is a user-supplied name for this unification variable (obtained - * through a type annotation for instance). *) - match desc, ty'.desc with - Tvar name, Tvar name' -> - begin match name, name' with - | Some _, None -> log_type ty'; ty'.desc <- Tvar name - | None, Some _ -> () - | Some _, Some _ -> - if ty.level < ty'.level then (log_type ty'; ty'.desc <- Tvar name) - | None, None -> () - end - | _ -> () - (* ; assert (check_memorized_abbrevs ()) *) - (* ; check_expans [] ty' *) -let set_level ty level = - if ty.id <= !last_snapshot then log_change (Clevel (ty, ty.level)); - ty.level <- level -let set_univar rty ty = - log_change (Cuniv (rty, !rty)); rty := Some ty -let set_name nm v = - log_change (Cname (nm, !nm)); nm := v -let set_row_field e v = - log_change (Crow (e, !e)); e := Some v -let set_kind rk k = - log_change (Ckind (rk, !rk)); rk := Some k -let set_commu rc c = - log_change (Ccommu (rc, !rc)); rc := c -let set_typeset rs s = - log_change (Ctypeset (rs, !rs)); rs := s +(* To buffer string literals *) -let snapshot () = - let old = !last_snapshot in - last_snapshot := !new_id; - match Weak.get trail 0 with Some r -> (r, old) - | None -> - let r = ref Unchanged in - Weak.set trail 0 (Some r); - (r, old) +let string_buffer = Buffer.create 256 +let reset_string_buffer () = Buffer.reset string_buffer +let get_stored_string () = Buffer.contents string_buffer -let rec rev_log accu = function - Unchanged -> accu - | Invalid -> assert false - | Change (ch, next) -> - let d = !next in - next := Invalid; - rev_log (ch::accu) d +let store_string_char c = Buffer.add_char string_buffer c +let store_string_utf_8_uchar u = Buffer.add_utf_8_uchar string_buffer u +let store_string s = Buffer.add_string string_buffer s +let store_lexeme lexbuf = store_string (Lexing.lexeme lexbuf) -let backtrack (changes, old) = - match !changes with - Unchanged -> last_snapshot := old - | Invalid -> failwith "Btype.backtrack" - | Change _ as change -> - cleanup_abbrev (); - let backlog = rev_log [] change in - List.iter undo_change backlog; - changes := Unchanged; - last_snapshot := old; - Weak.set trail 0 (Some changes) +(* To store the position of the beginning of a string and comment *) +let string_start_loc = ref Location.none;; +let comment_start_loc = ref [];; +let in_comment () = !comment_start_loc <> [];; +let is_in_string = ref false +let in_string () = !is_in_string +let print_warnings = ref true +let if_then_else = ref Dir_out +let sharp_look_ahead = ref None +let update_if_then_else v = + (* Format.fprintf Format.err_formatter "@[update %s \n@]@." (string_of_dir_conditional v); *) + if_then_else := v -let rec rev_compress_log log r = - match !r with - Unchanged | Invalid -> - log - | Change (Ccompress _, next) -> - rev_compress_log (r::log) next - | Change (_, next) -> - rev_compress_log log next +(* Escaped chars are interpreted in strings unless they are in comments. *) +let store_escaped_char lexbuf c = + if in_comment () then store_lexeme lexbuf else store_string_char c -let undo_compress (changes, _old) = - match !changes with - Unchanged - | Invalid -> () - | Change _ -> - let log = rev_compress_log [] changes in - List.iter - (fun r -> match !r with - Change (Ccompress (ty, desc, d), next) when ty.desc == d -> - ty.desc <- desc; r := !next - | _ -> ()) - log +let store_escaped_uchar lexbuf u = + if in_comment () then store_lexeme lexbuf else store_string_utf_8_uchar u -end -module Consistbl : sig -#1 "consistbl.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 2002 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let with_comment_buffer comment lexbuf = + let start_loc = Location.curr lexbuf in + comment_start_loc := [start_loc]; + reset_string_buffer (); + let end_loc = comment lexbuf in + let s = get_stored_string () in + reset_string_buffer (); + let loc = { start_loc with Location.loc_end = end_loc.Location.loc_end } in + s, loc -(* Consistency tables: for checking consistency of module CRCs *) +(* To translate escape sequences *) -type t +let hex_digit_value d = (* assert (d in '0'..'9' 'a'..'f' 'A'..'F') *) + let d = Char.code d in + if d >= 97 then d - 87 else + if d >= 65 then d - 55 else + d - 48 -val create: unit -> t +let hex_num_value lexbuf ~first ~last = + let rec loop acc i = match i > last with + | true -> acc + | false -> + let value = hex_digit_value (Lexing.lexeme_char lexbuf i) in + loop (16 * acc + value) (i + 1) + in + loop 0 first -val clear: t -> unit +let char_for_backslash = function + | 'n' -> '\010' + | 'r' -> '\013' + | 'b' -> '\008' + | 't' -> '\009' + | c -> c -val check: t -> string -> Digest.t -> string -> unit - (* [check tbl name crc source] - checks consistency of ([name], [crc]) with infos previously - stored in [tbl]. If no CRC was previously associated with - [name], record ([name], [crc]) in [tbl]. - [source] is the name of the file from which the information - comes from. This is used for error reporting. *) +let char_for_decimal_code lexbuf i = + let c = 100 * (Char.code(Lexing.lexeme_char lexbuf i) - 48) + + 10 * (Char.code(Lexing.lexeme_char lexbuf (i+1)) - 48) + + (Char.code(Lexing.lexeme_char lexbuf (i+2)) - 48) in + if (c < 0 || c > 255) then + if in_comment () + then 'x' + else raise (Error(Illegal_escape (Lexing.lexeme lexbuf), + Location.curr lexbuf)) + else Char.chr c -val check_noadd: t -> string -> Digest.t -> string -> unit - (* Same as [check], but raise [Not_available] if no CRC was previously - associated with [name]. *) +let char_for_octal_code lexbuf i = + let c = 64 * (Char.code(Lexing.lexeme_char lexbuf i) - 48) + + 8 * (Char.code(Lexing.lexeme_char lexbuf (i+1)) - 48) + + (Char.code(Lexing.lexeme_char lexbuf (i+2)) - 48) in + Char.chr c -val set: t -> string -> Digest.t -> string -> unit - (* [set tbl name crc source] forcefully associates [name] with - [crc] in [tbl], even if [name] already had a different CRC - associated with [name] in [tbl]. *) +let char_for_hexadecimal_code lexbuf i = + let byte = hex_num_value lexbuf ~first:i ~last:(i+1) in + Char.chr byte -val source: t -> string -> string - (* [source tbl name] returns the file name associated with [name] - if the latter has an associated CRC in [tbl]. - Raise [Not_found] otherwise. *) +let uchar_for_uchar_escape lexbuf = + let err e = + raise + (Error (Illegal_escape (Lexing.lexeme lexbuf ^ e), Location.curr lexbuf)) + in + let len = Lexing.lexeme_end lexbuf - Lexing.lexeme_start lexbuf in + let first = 3 (* skip opening \u{ *) in + let last = len - 2 (* skip closing } *) in + let digit_count = last - first + 1 in + match digit_count > 6 with + | true -> err ", too many digits, expected 1 to 6 hexadecimal digits" + | false -> + let cp = hex_num_value lexbuf ~first ~last in + if Uchar.is_valid cp then Uchar.unsafe_of_int cp else + err (", " ^ Printf.sprintf "%X" cp ^ " is not a Unicode scalar value") -val extract: string list -> t -> (string * Digest.t option) list - (* [extract tbl names] returns an associative list mapping each string - in [names] to the CRC associated with it in [tbl]. If no CRC is - associated with a name then it is mapped to [None]. *) +(* recover the name from a LABEL or OPTLABEL token *) -val filter: (string -> bool) -> t -> unit - (* [filter pred tbl] removes from [tbl] table all (name, CRC) pairs - such that [pred name] is [false]. *) +let get_label_name lexbuf = + let s = Lexing.lexeme lexbuf in + let name = String.sub s 1 (String.length s - 2) in + if Hashtbl.mem keyword_table name then + raise (Error(Keyword_as_label name, Location.curr lexbuf)); + name +;; -exception Inconsistency of string * string * string - (* Raised by [check] when a CRC mismatch is detected. - First string is the name of the compilation unit. - Second string is the source that caused the inconsistency. - Third string is the source that set the CRC. *) +(* Update the current location with file name and line number. *) -exception Not_available of string - (* Raised by [check_noadd] when a name doesn't have an associated CRC. *) +let update_loc lexbuf file line absolute chars = + let pos = lexbuf.lex_curr_p in + let new_file = match file with + | None -> pos.pos_fname + | Some s -> s + in + lexbuf.lex_curr_p <- { pos with + pos_fname = new_file; + pos_lnum = if absolute then line else pos.pos_lnum + line; + pos_bol = pos.pos_cnum - chars; + } +;; -end = struct -#1 "consistbl.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 2002 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let preprocessor = ref None -(* Consistency tables: for checking consistency of module CRCs *) +let escaped_newlines = ref false -type t = (string, Digest.t * string) Hashtbl.t +(* Warn about Latin-1 characters used in idents *) -let create () = Hashtbl.create 13 +let warn_latin1 lexbuf = + Location.deprecated (Location.curr lexbuf)"ISO-Latin1 characters in identifiers" -let clear = Hashtbl.clear +let handle_docstrings = ref true +let comment_list = ref [] -exception Inconsistency of string * string * string +let add_comment com = + comment_list := com :: !comment_list -exception Not_available of string +let add_docstring_comment ds = + let com = + ("*" ^ Docstrings.docstring_body ds, Docstrings.docstring_loc ds) + in + add_comment com -let check tbl name crc source = - try - let (old_crc, old_source) = Hashtbl.find tbl name in - if crc <> old_crc then raise(Inconsistency(name, source, old_source)) - with Not_found -> - Hashtbl.add tbl name (crc, source) +let comments () = List.rev !comment_list -let check_noadd tbl name crc source = - try - let (old_crc, old_source) = Hashtbl.find tbl name in - if crc <> old_crc then raise(Inconsistency(name, source, old_source)) - with Not_found -> - raise (Not_available name) +(* Error report *) -let set tbl name crc source = Hashtbl.add tbl name (crc, source) +open Format -let source tbl name = snd (Hashtbl.find tbl name) +let report_error ppf = function + | Illegal_character c -> + fprintf ppf "Illegal character (%s)" (Char.escaped c) + | Illegal_escape s -> + fprintf ppf "Illegal backslash escape in string or character (%s)" s + | Unterminated_comment _ -> + fprintf ppf "Comment not terminated" + | Unterminated_string -> + fprintf ppf "String literal not terminated" + | Unterminated_string_in_comment (_, loc) -> + fprintf ppf "This comment contains an unterminated string literal@.\ + %aString literal begins here" + Location.print_error loc + | Keyword_as_label kwd -> + fprintf ppf "`%s' is a keyword, it cannot be used as label name" kwd + | Invalid_literal s -> + fprintf ppf "Invalid literal %s" s + | Invalid_directive (dir, explanation) -> + fprintf ppf "Invalid lexer directive %S" dir; + begin match explanation with + | None -> () + | Some expl -> fprintf ppf ": %s" expl + end + | Unterminated_if -> + fprintf ppf "#if not terminated" + | Unterminated_else -> + fprintf ppf "#else not terminated" + | Unexpected_directive -> fprintf ppf "Unexpected directive" + | Unexpected_token_in_conditional -> + fprintf ppf "Unexpected token in conditional predicate" + | Unterminated_paren_in_conditional -> + fprintf ppf "Unterminated parens in conditional predicate" + | Expect_hash_then_in_conditional -> + fprintf ppf "Expect `then` after conditional predicate" + | Conditional_expr_expected_type (a,b) -> + fprintf ppf "Conditional expression type mismatch (%s,%s)" + (string_of_type_directive a ) + (string_of_type_directive b ) + | Illegal_semver s -> + fprintf ppf "Illegal semantic version string %s" s -let extract l tbl = - let l = List.sort_uniq String.compare l in - List.fold_left - (fun assc name -> - try - let (crc, _) = Hashtbl.find tbl name in - (name, Some crc) :: assc - with Not_found -> - (name, None) :: assc) - [] l +let () = + Location.register_error_of_exn + (function + | Error (err, loc) -> + Some (Location.error_of_printer loc report_error err) + | _ -> + None + ) -let filter p tbl = - let to_remove = ref [] in - Hashtbl.iter - (fun name _ -> - if not (p name) then to_remove := name :: !to_remove) - tbl; - List.iter - (fun name -> - while Hashtbl.mem tbl name do Hashtbl.remove tbl name done) - !to_remove -end -module Datarepr : sig -#1 "datarepr.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +# 717 "parsing/lexer.ml" +let __ocaml_lex_tables = { + Lexing.lex_base = + "\000\000\162\255\163\255\224\000\003\001\038\001\073\001\108\001\ + \143\001\186\255\178\001\215\001\194\255\091\000\252\001\031\002\ + \068\000\071\000\065\002\100\002\212\255\214\255\217\255\135\002\ + \230\002\009\003\088\000\255\000\039\003\236\255\123\003\207\003\ + \035\004\243\004\195\005\147\006\114\007\206\007\158\008\122\000\ + \254\255\001\000\005\000\255\255\006\000\007\000\125\009\155\009\ + \107\010\250\255\249\255\059\011\011\012\247\255\246\255\219\012\ + \047\013\131\013\215\013\043\014\127\014\211\014\039\015\123\015\ + \207\015\035\016\087\000\119\016\203\016\031\017\115\017\199\017\ + \108\000\192\255\235\255\007\003\034\018\106\000\107\000\011\000\ + \234\255\233\255\228\255\152\002\099\000\118\000\113\000\232\255\ + \128\000\147\000\231\255\224\000\003\001\148\000\230\255\110\004\ + \149\000\229\255\148\000\224\255\217\000\223\255\222\000\034\018\ + \222\255\073\018\101\005\009\003\221\255\012\000\014\001\080\001\ + \115\001\024\001\221\255\013\000\119\018\158\018\193\018\231\018\ + \010\019\209\255\204\255\205\255\206\255\202\255\045\019\154\000\ + \183\000\195\255\196\255\197\255\217\000\182\255\180\255\189\255\ + \080\019\185\255\187\255\115\019\150\019\185\019\220\019\130\005\ + \243\255\244\255\017\000\245\255\174\001\223\005\253\255\248\000\ + \249\000\255\255\254\255\252\255\005\006\238\019\003\001\004\001\ + \018\000\251\255\250\255\249\255\222\006\026\003\005\001\248\255\ + \036\003\008\001\247\255\066\008\020\001\246\255\059\001\234\001\ + \245\255\246\255\247\255\060\001\055\020\255\255\248\255\193\000\ + \233\008\038\001\133\004\253\255\073\001\094\001\113\001\143\004\ + \252\255\192\002\027\004\251\255\230\009\250\255\182\010\089\020\ + \249\255\129\001\130\001\252\255\085\007\254\255\255\255\146\001\ + \147\001\253\255\177\007\033\001\044\001\148\001\151\001\045\001\ + \153\001\044\001\019\000\255\255"; + Lexing.lex_backtrk = + "\255\255\255\255\255\255\090\000\089\000\086\000\085\000\078\000\ + \076\000\255\255\067\000\064\000\255\255\057\000\056\000\054\000\ + \052\000\048\000\045\000\081\000\255\255\255\255\255\255\036\000\ + \035\000\042\000\040\000\039\000\062\000\255\255\014\000\014\000\ + \013\000\012\000\011\000\010\000\007\000\004\000\003\000\002\000\ + \255\255\093\000\093\000\255\255\255\255\255\255\084\000\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\018\000\ + \018\000\016\000\015\000\018\000\015\000\015\000\014\000\016\000\ + \015\000\016\000\255\255\017\000\017\000\014\000\014\000\016\000\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\027\000\027\000\027\000\027\000\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\028\000\255\255\029\000\255\255\030\000\088\000\ + \255\255\091\000\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\037\000\087\000\082\000\044\000\ + \047\000\255\255\255\255\255\255\255\255\255\255\055\000\074\000\ + \071\000\255\255\255\255\255\255\072\000\255\255\255\255\255\255\ + \065\000\255\255\255\255\083\000\077\000\080\000\079\000\255\255\ + \255\255\255\255\012\000\255\255\012\000\012\000\255\255\012\000\ + \012\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\010\000\010\000\255\255\255\255\007\000\ + \007\000\007\000\007\000\255\255\001\000\007\000\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\003\000\255\255\255\255\003\000\ + \255\255\255\255\255\255\002\000\255\255\255\255\001\000\255\255\ + \255\255\255\255\255\255\255\255"; + Lexing.lex_default = + "\001\000\000\000\000\000\255\255\255\255\255\255\255\255\255\255\ + \255\255\000\000\255\255\255\255\000\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\000\000\000\000\000\000\255\255\ + \255\255\255\255\255\255\077\000\255\255\000\000\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \000\000\255\255\255\255\000\000\255\255\255\255\255\255\255\255\ + \255\255\000\000\000\000\255\255\255\255\000\000\000\000\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\000\000\000\000\255\255\082\000\255\255\255\255\255\255\ + \000\000\000\000\000\000\255\255\255\255\255\255\255\255\000\000\ + \255\255\255\255\000\000\255\255\255\255\255\255\000\000\255\255\ + \255\255\000\000\255\255\000\000\255\255\000\000\255\255\255\255\ + \000\000\255\255\110\000\255\255\000\000\255\255\110\000\111\000\ + \110\000\113\000\000\000\255\255\255\255\255\255\255\255\255\255\ + \255\255\000\000\000\000\000\000\000\000\000\000\255\255\255\255\ + \255\255\000\000\000\000\000\000\255\255\000\000\000\000\000\000\ + \255\255\000\000\000\000\255\255\255\255\255\255\255\255\144\000\ + \000\000\000\000\255\255\000\000\158\000\255\255\000\000\255\255\ + \255\255\000\000\000\000\000\000\255\255\255\255\255\255\255\255\ + \255\255\000\000\000\000\000\000\255\255\255\255\255\255\000\000\ + \255\255\255\255\000\000\255\255\255\255\000\000\255\255\176\000\ + \000\000\000\000\000\000\255\255\182\000\000\000\000\000\255\255\ + \255\255\255\255\255\255\000\000\255\255\255\255\255\255\255\255\ + \000\000\255\255\255\255\000\000\255\255\000\000\255\255\255\255\ + \000\000\255\255\203\000\000\000\255\255\000\000\000\000\255\255\ + \255\255\000\000\255\255\255\255\255\255\213\000\216\000\255\255\ + \216\000\255\255\255\255\000\000"; + Lexing.lex_trans = + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\039\000\040\000\040\000\039\000\041\000\045\000\043\000\ + \043\000\040\000\044\000\044\000\045\000\078\000\108\000\114\000\ + \079\000\109\000\115\000\145\000\159\000\219\000\174\000\160\000\ + \039\000\008\000\029\000\024\000\006\000\004\000\023\000\027\000\ + \026\000\021\000\025\000\007\000\020\000\019\000\018\000\003\000\ + \031\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ + \030\000\030\000\017\000\016\000\015\000\014\000\010\000\036\000\ + \005\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\013\000\042\000\012\000\005\000\038\000\ + \022\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\028\000\011\000\009\000\037\000\125\000\ + \127\000\124\000\098\000\039\000\123\000\122\000\039\000\065\000\ + \065\000\065\000\065\000\065\000\065\000\065\000\065\000\065\000\ + \065\000\081\000\080\000\091\000\091\000\091\000\091\000\130\000\ + \087\000\129\000\039\000\128\000\071\000\071\000\071\000\071\000\ + \071\000\071\000\071\000\071\000\071\000\071\000\088\000\088\000\ + \088\000\088\000\088\000\088\000\088\000\088\000\088\000\088\000\ + \089\000\089\000\089\000\089\000\089\000\089\000\089\000\089\000\ + \089\000\089\000\090\000\094\000\097\000\099\000\100\000\134\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\131\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\132\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \002\000\003\000\101\000\102\000\003\000\003\000\003\000\101\000\ + \102\000\078\000\003\000\003\000\079\000\003\000\003\000\003\000\ + \092\000\092\000\092\000\092\000\092\000\092\000\092\000\092\000\ + \108\000\133\000\003\000\109\000\003\000\003\000\003\000\003\000\ + \003\000\154\000\114\000\153\000\003\000\115\000\255\255\003\000\ + \003\000\003\000\163\000\162\000\167\000\003\000\003\000\170\000\ + \003\000\003\000\003\000\093\000\093\000\093\000\093\000\093\000\ + \093\000\093\000\093\000\173\000\198\000\003\000\003\000\003\000\ + \003\000\003\000\003\000\003\000\212\000\145\000\178\000\005\000\ + \174\000\201\000\005\000\005\000\005\000\213\000\217\000\218\000\ + \005\000\005\000\188\000\005\000\005\000\005\000\193\000\193\000\ + \193\000\193\000\108\000\076\000\003\000\109\000\003\000\000\000\ + \005\000\003\000\005\000\005\000\005\000\005\000\005\000\000\000\ + \188\000\188\000\006\000\190\000\000\000\006\000\006\000\006\000\ + \000\000\000\000\113\000\006\000\006\000\000\000\006\000\006\000\ + \006\000\000\000\000\000\188\000\112\000\108\000\190\000\003\000\ + \109\000\003\000\000\000\006\000\005\000\006\000\006\000\006\000\ + \006\000\006\000\000\000\178\000\206\000\117\000\201\000\207\000\ + \117\000\117\000\117\000\112\000\000\000\111\000\117\000\117\000\ + \000\000\117\000\142\000\117\000\206\000\206\000\214\000\208\000\ + \208\000\215\000\005\000\215\000\005\000\000\000\117\000\006\000\ + \117\000\141\000\117\000\117\000\117\000\000\000\000\000\000\000\ + \139\000\000\000\000\000\139\000\139\000\139\000\000\000\000\000\ + \159\000\139\000\139\000\160\000\139\000\139\000\139\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\006\000\000\000\006\000\ + \000\000\139\000\117\000\139\000\140\000\139\000\139\000\139\000\ + \000\000\000\000\000\000\006\000\000\000\161\000\006\000\006\000\ + \006\000\000\000\000\000\000\000\006\000\006\000\000\000\006\000\ + \006\000\006\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \117\000\000\000\117\000\000\000\006\000\139\000\006\000\006\000\ + \006\000\006\000\006\000\000\000\178\000\000\000\000\000\179\000\ + \006\000\000\000\000\000\006\000\006\000\006\000\204\000\255\255\ + \000\000\006\000\006\000\000\000\006\000\006\000\006\000\000\000\ + \000\000\000\000\157\000\139\000\181\000\139\000\255\255\138\000\ + \006\000\006\000\000\000\006\000\006\000\006\000\006\000\006\000\ + \255\255\000\000\000\000\000\000\000\000\006\000\000\000\000\000\ + \006\000\006\000\006\000\000\000\000\000\000\000\006\000\006\000\ + \000\000\006\000\006\000\006\000\000\000\000\000\006\000\137\000\ + \006\000\000\000\000\000\000\000\135\000\006\000\006\000\000\000\ + \006\000\006\000\006\000\006\000\006\000\000\000\000\000\000\000\ + \006\000\000\000\000\000\006\000\006\000\006\000\180\000\000\000\ + \000\000\006\000\006\000\000\000\126\000\006\000\006\000\000\000\ + \255\255\000\000\000\000\136\000\000\000\006\000\000\000\000\000\ + \000\000\006\000\006\000\006\000\006\000\006\000\006\000\006\000\ + \000\000\000\000\120\000\000\000\000\000\120\000\120\000\120\000\ + \000\000\000\000\000\000\120\000\120\000\000\000\120\000\121\000\ + \120\000\000\000\000\000\255\255\000\000\000\000\000\000\000\000\ + \006\000\000\000\006\000\120\000\000\000\006\000\120\000\120\000\ + \120\000\120\000\205\000\000\000\000\000\117\000\000\000\000\000\ + \117\000\117\000\117\000\000\000\000\000\000\000\117\000\117\000\ + \000\000\117\000\118\000\117\000\255\255\000\000\000\000\255\255\ + \000\000\255\255\000\000\006\000\000\000\006\000\117\000\120\000\ + \117\000\117\000\119\000\117\000\117\000\000\000\000\000\000\000\ + \006\000\000\000\000\000\006\000\006\000\116\000\255\255\000\000\ + \000\000\006\000\006\000\000\000\006\000\006\000\006\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\120\000\000\000\120\000\ + \000\000\006\000\117\000\006\000\006\000\006\000\006\000\006\000\ + \095\000\095\000\095\000\095\000\095\000\095\000\095\000\095\000\ + \095\000\095\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\095\000\095\000\095\000\095\000\095\000\095\000\000\000\ + \117\000\000\000\117\000\000\000\000\000\006\000\000\000\000\000\ + \000\000\000\000\177\000\000\000\000\000\000\000\000\000\107\000\ + \194\000\194\000\194\000\194\000\194\000\194\000\194\000\194\000\ + \000\000\095\000\095\000\095\000\095\000\095\000\095\000\000\000\ + \000\000\000\000\000\000\006\000\000\000\006\000\107\000\105\000\ + \000\000\105\000\105\000\105\000\105\000\000\000\000\000\000\000\ + \105\000\105\000\107\000\105\000\105\000\105\000\106\000\106\000\ + \106\000\106\000\106\000\106\000\106\000\106\000\106\000\106\000\ + \105\000\000\000\105\000\105\000\105\000\105\000\105\000\000\000\ + \000\000\107\000\003\000\000\000\000\000\003\000\003\000\003\000\ + \000\000\000\000\104\000\103\000\003\000\000\000\003\000\003\000\ + \003\000\106\000\106\000\106\000\106\000\106\000\106\000\106\000\ + \106\000\106\000\106\000\003\000\105\000\003\000\003\000\003\000\ + \003\000\003\000\168\000\168\000\168\000\168\000\168\000\168\000\ + \168\000\168\000\168\000\168\000\169\000\169\000\169\000\169\000\ + \169\000\169\000\169\000\169\000\169\000\169\000\000\000\000\000\ + \000\000\000\000\105\000\073\000\105\000\000\000\075\000\003\000\ + \075\000\075\000\075\000\075\000\075\000\075\000\075\000\075\000\ + \075\000\075\000\075\000\075\000\075\000\075\000\075\000\075\000\ + \075\000\075\000\075\000\075\000\075\000\075\000\075\000\075\000\ + \075\000\075\000\000\000\074\000\000\000\003\000\075\000\003\000\ + \075\000\075\000\075\000\075\000\075\000\075\000\075\000\075\000\ + \075\000\075\000\075\000\075\000\075\000\075\000\075\000\075\000\ + \075\000\075\000\075\000\075\000\075\000\075\000\075\000\075\000\ + \075\000\075\000\055\000\074\000\000\000\000\000\000\000\000\000\ + \000\000\057\000\000\000\030\000\030\000\030\000\030\000\030\000\ + \030\000\030\000\030\000\030\000\030\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\055\000\055\000\055\000\055\000\ + \056\000\055\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\000\000\000\000\ + \000\000\000\000\030\000\000\000\055\000\055\000\055\000\055\000\ + \056\000\055\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\055\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\057\000\000\000\030\000\ + \030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ + \030\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \055\000\059\000\055\000\055\000\056\000\055\000\058\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\060\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\061\000\ + \058\000\058\000\000\000\000\000\000\000\000\000\030\000\000\000\ + \055\000\059\000\055\000\055\000\056\000\055\000\058\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\060\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\061\000\ + \058\000\058\000\032\000\195\000\195\000\195\000\195\000\195\000\ + \195\000\195\000\195\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\000\000\000\000\ + \000\000\000\000\032\000\000\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\096\000\096\000\ + \096\000\096\000\096\000\096\000\096\000\096\000\096\000\096\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\096\000\ + \096\000\096\000\096\000\096\000\096\000\191\000\191\000\191\000\ + \191\000\191\000\191\000\191\000\191\000\191\000\191\000\192\000\ + \192\000\192\000\192\000\192\000\192\000\192\000\192\000\192\000\ + \192\000\000\000\000\000\000\000\000\000\000\000\000\000\096\000\ + \096\000\096\000\096\000\096\000\096\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\000\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\033\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\033\000\000\000\000\000\ + \000\000\000\000\033\000\000\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\033\000\112\000\108\000\ + \000\000\000\000\109\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\112\000\000\000\111\000\ + \000\000\000\000\000\000\000\000\145\000\000\000\000\000\146\000\ + \000\000\000\000\000\000\000\000\000\000\106\000\106\000\106\000\ + \106\000\106\000\106\000\106\000\106\000\106\000\106\000\000\000\ + \000\000\000\000\000\000\000\000\150\000\000\000\000\000\000\000\ + \000\000\148\000\152\000\000\000\151\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\000\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\034\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\149\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\000\000\000\000\ + \000\000\000\000\034\000\000\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\156\000\000\000\ + \156\000\156\000\156\000\156\000\156\000\156\000\156\000\156\000\ + \156\000\156\000\156\000\156\000\156\000\156\000\156\000\156\000\ + \156\000\156\000\156\000\156\000\156\000\156\000\156\000\156\000\ + \156\000\156\000\000\000\155\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\156\000\255\255\156\000\156\000\ + \156\000\156\000\156\000\156\000\156\000\156\000\156\000\156\000\ + \156\000\156\000\156\000\156\000\156\000\156\000\156\000\156\000\ + \156\000\156\000\156\000\156\000\156\000\156\000\156\000\156\000\ + \000\000\155\000\147\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\000\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\035\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\000\000\000\000\ + \000\000\000\000\035\000\000\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\171\000\171\000\ + \171\000\171\000\171\000\171\000\171\000\171\000\171\000\171\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\171\000\ + \171\000\171\000\171\000\171\000\171\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\171\000\ + \171\000\171\000\171\000\171\000\171\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\000\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\000\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\046\000\000\000\000\000\046\000\046\000\ + \046\000\000\000\000\000\000\000\046\000\046\000\000\000\046\000\ + \046\000\046\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\046\000\000\000\046\000\046\000\ + \046\000\046\000\046\000\000\000\210\000\000\000\210\000\210\000\ + \210\000\210\000\210\000\210\000\210\000\210\000\210\000\210\000\ + \210\000\210\000\210\000\210\000\210\000\210\000\210\000\210\000\ + \210\000\210\000\210\000\210\000\210\000\210\000\210\000\210\000\ + \046\000\052\000\209\000\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\000\000\046\000\046\000\ + \046\000\000\000\046\000\046\000\046\000\000\000\000\000\000\000\ + \046\000\046\000\000\000\046\000\046\000\046\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \046\000\000\000\046\000\046\000\046\000\046\000\046\000\000\000\ + \210\000\000\000\210\000\210\000\210\000\210\000\210\000\210\000\ + \210\000\210\000\210\000\210\000\210\000\210\000\210\000\210\000\ + \210\000\210\000\210\000\210\000\210\000\210\000\210\000\210\000\ + \210\000\210\000\210\000\210\000\046\000\048\000\209\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ + \048\000\000\000\046\000\000\000\046\000\000\000\000\000\000\000\ + \000\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\000\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\172\000\172\000\172\000\172\000\172\000\172\000\ + \172\000\172\000\172\000\172\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\172\000\172\000\172\000\172\000\172\000\ + \172\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\172\000\172\000\172\000\172\000\172\000\ + \172\000\000\000\000\000\000\000\000\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\035\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\000\000\000\000\000\000\000\000\035\000\000\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\196\000\196\000\196\000\196\000\196\000\196\000\196\000\ + \196\000\196\000\196\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\196\000\196\000\196\000\196\000\196\000\196\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\196\000\196\000\196\000\196\000\196\000\196\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\000\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\000\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\046\000\000\000\ + \000\000\046\000\046\000\046\000\000\000\000\000\000\000\046\000\ + \046\000\000\000\046\000\046\000\046\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\046\000\ + \000\000\046\000\046\000\046\000\046\000\046\000\000\000\000\000\ + \000\000\000\000\047\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\050\000\000\000\000\000\ + \000\000\000\000\000\000\046\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\000\000\000\000\ + \000\000\046\000\047\000\046\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\197\000\197\000\ + \197\000\197\000\197\000\197\000\197\000\197\000\197\000\197\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\197\000\ + \197\000\197\000\197\000\197\000\197\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\197\000\ + \197\000\197\000\197\000\197\000\197\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\000\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\048\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\048\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\049\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\000\000\000\000\ + \000\000\000\000\048\000\000\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\199\000\199\000\ + \199\000\199\000\199\000\199\000\199\000\199\000\199\000\199\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\199\000\ + \199\000\199\000\199\000\199\000\199\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\199\000\ + \199\000\199\000\199\000\199\000\199\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\000\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\051\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\054\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\000\000\000\000\ + \000\000\000\000\051\000\000\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\000\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\052\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\053\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\052\000\000\000\000\000\ + \000\000\000\000\052\000\000\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\052\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\000\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\055\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\000\000\000\000\ + \000\000\000\000\055\000\000\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\000\000\ + \000\000\000\000\072\000\000\000\072\000\000\000\000\000\071\000\ + \071\000\071\000\071\000\071\000\071\000\071\000\071\000\071\000\ + \071\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\000\000\000\000\000\000\000\000\055\000\000\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\057\000\057\000\057\000\057\000\057\000\ + \057\000\057\000\057\000\057\000\057\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\055\000\055\000\055\000\055\000\ + \056\000\055\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\067\000\067\000\067\000\067\000\000\000\000\000\ + \000\000\000\000\057\000\000\000\055\000\055\000\055\000\055\000\ + \056\000\055\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\067\000\067\000\067\000\067\000\055\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\000\000\000\000\000\000\000\000\055\000\000\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\070\000\070\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\000\000\000\000\ + \000\000\000\000\055\000\000\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\069\000\ + \069\000\069\000\069\000\069\000\069\000\069\000\069\000\055\000\ + \055\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\000\000\000\000\000\000\000\000\055\000\000\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\062\000\062\000\062\000\062\000\062\000\ + \062\000\062\000\062\000\062\000\062\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\062\000\062\000\062\000\062\000\ + \062\000\062\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\000\000\000\000\ + \000\000\000\000\055\000\000\000\062\000\062\000\062\000\062\000\ + \062\000\062\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\063\000\000\000\062\000\ + \062\000\062\000\062\000\062\000\062\000\062\000\062\000\062\000\ + \062\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \062\000\062\000\062\000\062\000\062\000\062\000\058\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\064\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\058\000\000\000\000\000\000\000\000\000\062\000\000\000\ + \062\000\062\000\062\000\062\000\062\000\062\000\058\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\064\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\058\000\055\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\063\000\063\000\063\000\063\000\063\000\ + \063\000\063\000\063\000\063\000\063\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\063\000\063\000\063\000\063\000\ + \063\000\063\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\067\000\068\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\067\000\067\000\067\000\067\000\000\000\000\000\ + \000\000\000\000\063\000\000\000\063\000\063\000\063\000\063\000\ + \063\000\063\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\067\000\068\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\067\000\067\000\067\000\067\000\055\000\000\000\ + \000\000\000\000\066\000\000\000\066\000\000\000\000\000\065\000\ + \065\000\065\000\065\000\065\000\065\000\065\000\065\000\065\000\ + \065\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\000\000\000\000\000\000\000\000\055\000\000\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\065\000\065\000\065\000\065\000\065\000\ + \065\000\065\000\065\000\065\000\065\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\067\000\067\000\067\000\067\000\000\000\000\000\ + \000\000\000\000\065\000\000\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\067\000\067\000\067\000\067\000\055\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\000\000\000\000\000\000\000\000\055\000\000\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\000\000\000\000\000\000\066\000\000\000\ + \066\000\000\000\000\000\065\000\065\000\065\000\065\000\065\000\ + \065\000\065\000\065\000\065\000\065\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\000\000\000\000\ + \000\000\000\000\055\000\000\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\069\000\ + \069\000\069\000\069\000\069\000\069\000\069\000\069\000\055\000\ + \055\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\058\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\058\000\000\000\000\000\000\000\000\000\069\000\000\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\058\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\058\000\055\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\070\000\070\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\000\000\000\000\ + \000\000\000\000\070\000\000\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\055\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\071\000\ + \071\000\071\000\071\000\071\000\071\000\071\000\071\000\071\000\ + \071\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\067\000\067\000\ + \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\000\000\000\000\000\000\000\000\071\000\000\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\067\000\067\000\ + \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\086\000\103\000\086\000\000\000\103\000\103\000\ + \103\000\086\000\000\000\000\000\103\000\103\000\000\000\103\000\ + \103\000\103\000\085\000\085\000\085\000\085\000\085\000\085\000\ + \085\000\085\000\085\000\085\000\103\000\000\000\103\000\103\000\ + \103\000\103\000\103\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\105\000\000\000\105\000\105\000\105\000\105\000\ + \000\000\000\000\000\000\105\000\105\000\000\000\105\000\105\000\ + \105\000\000\000\000\000\000\000\000\000\000\000\086\000\000\000\ + \103\000\000\000\000\000\105\000\086\000\105\000\105\000\105\000\ + \105\000\105\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \086\000\084\000\000\000\000\000\086\000\000\000\086\000\000\000\ + \006\000\000\000\083\000\006\000\006\000\006\000\103\000\000\000\ + \103\000\006\000\006\000\000\000\006\000\006\000\006\000\105\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\006\000\000\000\006\000\006\000\006\000\006\000\006\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\117\000\ + \000\000\000\000\117\000\117\000\117\000\105\000\000\000\105\000\ + \117\000\117\000\000\000\117\000\117\000\117\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\006\000\000\000\000\000\ + \117\000\000\000\117\000\117\000\117\000\117\000\117\000\000\000\ + \000\000\000\000\117\000\000\000\000\000\117\000\117\000\117\000\ + \000\000\000\000\000\000\117\000\117\000\000\000\117\000\117\000\ + \117\000\000\000\000\000\006\000\000\000\006\000\000\000\000\000\ + \000\000\000\000\000\000\117\000\117\000\117\000\117\000\117\000\ + \117\000\117\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \117\000\000\000\000\000\117\000\117\000\117\000\000\000\000\000\ + \000\000\117\000\117\000\000\000\117\000\117\000\117\000\000\000\ + \000\000\000\000\117\000\000\000\117\000\000\000\000\000\117\000\ + \000\000\117\000\255\255\117\000\117\000\117\000\117\000\117\000\ + \000\000\000\000\000\000\120\000\000\000\000\000\120\000\120\000\ + \120\000\000\000\000\000\000\000\120\000\120\000\000\000\120\000\ + \120\000\120\000\000\000\000\000\000\000\117\000\000\000\117\000\ + \000\000\000\000\000\000\000\000\120\000\117\000\120\000\120\000\ + \120\000\120\000\120\000\000\000\000\000\000\000\006\000\000\000\ + \000\000\006\000\006\000\006\000\000\000\000\000\000\000\006\000\ + \006\000\000\000\006\000\006\000\006\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\117\000\000\000\117\000\000\000\006\000\ + \120\000\006\000\006\000\006\000\006\000\006\000\000\000\000\000\ + \000\000\006\000\000\000\000\000\006\000\006\000\006\000\000\000\ + \000\000\000\000\006\000\006\000\000\000\006\000\006\000\006\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\120\000\000\000\ + \120\000\000\000\006\000\006\000\006\000\006\000\006\000\006\000\ + \006\000\000\000\000\000\000\000\139\000\000\000\000\000\139\000\ + \139\000\139\000\000\000\000\000\000\000\139\000\139\000\000\000\ + \139\000\139\000\139\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\006\000\000\000\006\000\000\000\139\000\006\000\139\000\ + \139\000\139\000\139\000\139\000\000\000\000\000\000\000\139\000\ + \000\000\000\000\139\000\139\000\139\000\000\000\000\000\000\000\ + \139\000\139\000\000\000\139\000\139\000\139\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\006\000\000\000\006\000\000\000\ + \139\000\139\000\139\000\139\000\139\000\139\000\139\000\000\000\ + \000\000\000\000\117\000\000\000\000\000\117\000\117\000\117\000\ + \000\000\000\000\000\000\117\000\117\000\000\000\117\000\117\000\ + \117\000\000\000\000\000\000\000\000\000\000\000\000\000\139\000\ + \000\000\139\000\000\000\117\000\139\000\117\000\117\000\117\000\ + \117\000\117\000\000\000\000\000\000\000\117\000\000\000\000\000\ + \117\000\117\000\117\000\000\000\000\000\000\000\117\000\117\000\ + \000\000\117\000\117\000\117\000\000\000\000\000\166\000\000\000\ + \166\000\000\000\139\000\000\000\139\000\166\000\117\000\117\000\ + \117\000\117\000\117\000\117\000\117\000\000\000\165\000\165\000\ + \165\000\165\000\165\000\165\000\165\000\165\000\165\000\165\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\117\000\000\000\117\000\ + \000\000\000\000\117\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\188\000\000\000\000\000\189\000\000\000\000\000\000\000\ + \000\000\000\000\166\000\000\000\000\000\000\000\000\000\000\000\ + \166\000\000\000\000\000\000\000\000\000\000\000\000\000\187\000\ + \117\000\187\000\117\000\000\000\166\000\000\000\187\000\000\000\ + \166\000\000\000\166\000\000\000\000\000\000\000\164\000\186\000\ + \186\000\186\000\186\000\186\000\186\000\186\000\186\000\186\000\ + \186\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\199\000\199\000\199\000\199\000\199\000\199\000\199\000\ + \199\000\199\000\199\000\187\000\000\000\000\000\000\000\000\000\ + \000\000\187\000\199\000\199\000\199\000\199\000\199\000\199\000\ + \000\000\000\000\000\000\000\000\000\000\187\000\185\000\000\000\ + \000\000\187\000\000\000\187\000\183\000\000\000\000\000\184\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\199\000\199\000\199\000\199\000\199\000\199\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\200\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\255\255\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000"; + Lexing.lex_check = + "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\000\000\000\000\041\000\000\000\000\000\041\000\042\000\ + \044\000\045\000\042\000\044\000\045\000\079\000\109\000\115\000\ + \079\000\109\000\115\000\146\000\160\000\218\000\146\000\160\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\016\000\ + \013\000\017\000\026\000\039\000\017\000\017\000\039\000\066\000\ + \066\000\066\000\066\000\066\000\066\000\066\000\066\000\066\000\ + \066\000\077\000\078\000\084\000\084\000\084\000\084\000\013\000\ + \086\000\013\000\039\000\013\000\072\000\072\000\072\000\072\000\ + \072\000\072\000\072\000\072\000\072\000\072\000\085\000\085\000\ + \085\000\085\000\085\000\085\000\085\000\085\000\085\000\085\000\ + \088\000\088\000\088\000\088\000\088\000\088\000\088\000\088\000\ + \088\000\088\000\089\000\093\000\096\000\098\000\098\000\127\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\013\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\128\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\003\000\100\000\100\000\003\000\003\000\003\000\102\000\ + \102\000\027\000\003\000\003\000\027\000\003\000\003\000\003\000\ + \091\000\091\000\091\000\091\000\091\000\091\000\091\000\091\000\ + \110\000\132\000\003\000\110\000\003\000\003\000\003\000\003\000\ + \003\000\151\000\113\000\152\000\004\000\113\000\027\000\004\000\ + \004\000\004\000\158\000\159\000\166\000\004\000\004\000\169\000\ + \004\000\004\000\004\000\092\000\092\000\092\000\092\000\092\000\ + \092\000\092\000\092\000\172\000\183\000\004\000\003\000\004\000\ + \004\000\004\000\004\000\004\000\211\000\174\000\179\000\005\000\ + \174\000\179\000\005\000\005\000\005\000\212\000\215\000\217\000\ + \005\000\005\000\188\000\005\000\005\000\005\000\185\000\185\000\ + \185\000\185\000\111\000\027\000\003\000\111\000\003\000\255\255\ + \005\000\004\000\005\000\005\000\005\000\005\000\005\000\255\255\ + \189\000\188\000\006\000\189\000\255\255\006\000\006\000\006\000\ + \255\255\255\255\111\000\006\000\006\000\255\255\006\000\006\000\ + \006\000\255\255\255\255\190\000\112\000\112\000\190\000\004\000\ + \112\000\004\000\255\255\006\000\005\000\006\000\006\000\006\000\ + \006\000\006\000\255\255\201\000\202\000\007\000\201\000\202\000\ + \007\000\007\000\007\000\112\000\255\255\112\000\007\000\007\000\ + \255\255\007\000\007\000\007\000\207\000\208\000\213\000\207\000\ + \208\000\214\000\005\000\216\000\005\000\255\255\007\000\006\000\ + \007\000\007\000\007\000\007\000\007\000\255\255\255\255\255\255\ + \008\000\255\255\255\255\008\000\008\000\008\000\255\255\255\255\ + \148\000\008\000\008\000\148\000\008\000\008\000\008\000\255\255\ + \255\255\255\255\255\255\255\255\255\255\006\000\255\255\006\000\ + \255\255\008\000\007\000\008\000\008\000\008\000\008\000\008\000\ + \255\255\255\255\255\255\010\000\255\255\148\000\010\000\010\000\ + \010\000\255\255\255\255\255\255\010\000\010\000\255\255\010\000\ + \010\000\010\000\255\255\255\255\255\255\255\255\255\255\255\255\ + \007\000\255\255\007\000\255\255\010\000\008\000\010\000\010\000\ + \010\000\010\000\010\000\255\255\175\000\255\255\255\255\175\000\ + \011\000\255\255\255\255\011\000\011\000\011\000\202\000\027\000\ + \255\255\011\000\011\000\255\255\011\000\011\000\011\000\255\255\ + \255\255\255\255\148\000\008\000\175\000\008\000\110\000\010\000\ + \010\000\011\000\255\255\011\000\011\000\011\000\011\000\011\000\ + \113\000\255\255\255\255\255\255\255\255\014\000\255\255\255\255\ + \014\000\014\000\014\000\255\255\255\255\255\255\014\000\014\000\ + \255\255\014\000\014\000\014\000\255\255\255\255\010\000\010\000\ + \010\000\255\255\255\255\255\255\011\000\011\000\014\000\255\255\ + \014\000\014\000\014\000\014\000\014\000\255\255\255\255\255\255\ + \015\000\255\255\255\255\015\000\015\000\015\000\175\000\255\255\ + \255\255\015\000\015\000\255\255\015\000\015\000\015\000\255\255\ + \111\000\255\255\255\255\011\000\255\255\011\000\255\255\255\255\ + \255\255\015\000\014\000\015\000\015\000\015\000\015\000\015\000\ + \255\255\255\255\018\000\255\255\255\255\018\000\018\000\018\000\ + \255\255\255\255\255\255\018\000\018\000\255\255\018\000\018\000\ + \018\000\255\255\255\255\112\000\255\255\255\255\255\255\255\255\ + \014\000\255\255\014\000\018\000\255\255\015\000\018\000\018\000\ + \018\000\018\000\202\000\255\255\255\255\019\000\255\255\255\255\ + \019\000\019\000\019\000\255\255\255\255\255\255\019\000\019\000\ + \255\255\019\000\019\000\019\000\213\000\255\255\255\255\214\000\ + \255\255\216\000\255\255\015\000\255\255\015\000\019\000\018\000\ + \019\000\019\000\019\000\019\000\019\000\255\255\255\255\255\255\ + \023\000\255\255\255\255\023\000\023\000\023\000\148\000\255\255\ + \255\255\023\000\023\000\255\255\023\000\023\000\023\000\255\255\ + \255\255\255\255\255\255\255\255\255\255\018\000\255\255\018\000\ + \255\255\023\000\019\000\023\000\023\000\023\000\023\000\023\000\ + \083\000\083\000\083\000\083\000\083\000\083\000\083\000\083\000\ + \083\000\083\000\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\083\000\083\000\083\000\083\000\083\000\083\000\255\255\ + \019\000\255\255\019\000\255\255\255\255\023\000\255\255\255\255\ + \255\255\255\255\175\000\255\255\255\255\255\255\255\255\024\000\ + \193\000\193\000\193\000\193\000\193\000\193\000\193\000\193\000\ + \255\255\083\000\083\000\083\000\083\000\083\000\083\000\255\255\ + \255\255\255\255\255\255\023\000\255\255\023\000\024\000\024\000\ + \255\255\024\000\024\000\024\000\024\000\255\255\255\255\255\255\ + \024\000\024\000\107\000\024\000\024\000\024\000\024\000\024\000\ + \024\000\024\000\024\000\024\000\024\000\024\000\024\000\024\000\ + \024\000\255\255\024\000\024\000\024\000\024\000\024\000\255\255\ + \255\255\107\000\025\000\255\255\255\255\025\000\025\000\025\000\ + \255\255\255\255\025\000\025\000\025\000\255\255\025\000\025\000\ + \025\000\107\000\107\000\107\000\107\000\107\000\107\000\107\000\ + \107\000\107\000\107\000\025\000\024\000\025\000\025\000\025\000\ + \025\000\025\000\165\000\165\000\165\000\165\000\165\000\165\000\ + \165\000\165\000\165\000\165\000\168\000\168\000\168\000\168\000\ + \168\000\168\000\168\000\168\000\168\000\168\000\255\255\255\255\ + \255\255\255\255\024\000\028\000\024\000\255\255\075\000\025\000\ + \075\000\075\000\075\000\075\000\075\000\075\000\075\000\075\000\ + \075\000\075\000\075\000\075\000\075\000\075\000\075\000\075\000\ + \075\000\075\000\075\000\075\000\075\000\075\000\075\000\075\000\ + \075\000\075\000\255\255\075\000\255\255\025\000\028\000\025\000\ + \028\000\028\000\028\000\028\000\028\000\028\000\028\000\028\000\ + \028\000\028\000\028\000\028\000\028\000\028\000\028\000\028\000\ + \028\000\028\000\028\000\028\000\028\000\028\000\028\000\028\000\ + \028\000\028\000\030\000\028\000\255\255\255\255\255\255\255\255\ + \255\255\030\000\255\255\030\000\030\000\030\000\030\000\030\000\ + \030\000\030\000\030\000\030\000\030\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\030\000\030\000\030\000\030\000\ + \030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ + \030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ + \030\000\030\000\030\000\030\000\030\000\030\000\255\255\255\255\ + \255\255\255\255\030\000\255\255\030\000\030\000\030\000\030\000\ + \030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ + \030\000\030\000\030\000\030\000\030\000\030\000\030\000\030\000\ + \030\000\030\000\030\000\030\000\030\000\030\000\031\000\255\255\ + \255\255\255\255\255\255\255\255\255\255\031\000\255\255\031\000\ + \031\000\031\000\031\000\031\000\031\000\031\000\031\000\031\000\ + \031\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \031\000\031\000\031\000\031\000\031\000\031\000\031\000\031\000\ + \031\000\031\000\031\000\031\000\031\000\031\000\031\000\031\000\ + \031\000\031\000\031\000\031\000\031\000\031\000\031\000\031\000\ + \031\000\031\000\255\255\255\255\255\255\255\255\031\000\255\255\ + \031\000\031\000\031\000\031\000\031\000\031\000\031\000\031\000\ + \031\000\031\000\031\000\031\000\031\000\031\000\031\000\031\000\ + \031\000\031\000\031\000\031\000\031\000\031\000\031\000\031\000\ + \031\000\031\000\032\000\194\000\194\000\194\000\194\000\194\000\ + \194\000\194\000\194\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\255\255\255\255\ + \255\255\255\255\032\000\255\255\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\095\000\095\000\ + \095\000\095\000\095\000\095\000\095\000\095\000\095\000\095\000\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\095\000\ + \095\000\095\000\095\000\095\000\095\000\186\000\186\000\186\000\ + \186\000\186\000\186\000\186\000\186\000\186\000\186\000\191\000\ + \191\000\191\000\191\000\191\000\191\000\191\000\191\000\191\000\ + \191\000\255\255\255\255\255\255\255\255\255\255\255\255\095\000\ + \095\000\095\000\095\000\095\000\095\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\255\255\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\033\000\032\000\032\000\032\000\032\000\032\000\ + \032\000\032\000\032\000\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\033\000\255\255\255\255\ + \255\255\255\255\033\000\255\255\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\033\000\106\000\106\000\ + \255\255\255\255\106\000\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\106\000\255\255\106\000\ + \255\255\255\255\255\255\255\255\143\000\255\255\255\255\143\000\ + \255\255\255\255\255\255\255\255\255\255\106\000\106\000\106\000\ + \106\000\106\000\106\000\106\000\106\000\106\000\106\000\255\255\ + \255\255\255\255\255\255\255\255\143\000\255\255\255\255\255\255\ + \255\255\143\000\143\000\255\255\143\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\255\255\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\034\000\033\000\033\000\033\000\033\000\033\000\ + \033\000\033\000\033\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\143\000\255\255\255\255\ + \255\255\255\255\255\255\255\255\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\255\255\255\255\ + \255\255\255\255\034\000\255\255\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\149\000\255\255\ + \149\000\149\000\149\000\149\000\149\000\149\000\149\000\149\000\ + \149\000\149\000\149\000\149\000\149\000\149\000\149\000\149\000\ + \149\000\149\000\149\000\149\000\149\000\149\000\149\000\149\000\ + \149\000\149\000\255\255\149\000\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\156\000\106\000\156\000\156\000\ + \156\000\156\000\156\000\156\000\156\000\156\000\156\000\156\000\ + \156\000\156\000\156\000\156\000\156\000\156\000\156\000\156\000\ + \156\000\156\000\156\000\156\000\156\000\156\000\156\000\156\000\ + \255\255\156\000\143\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\255\255\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\035\000\034\000\034\000\034\000\034\000\034\000\ + \034\000\034\000\034\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\255\255\255\255\ + \255\255\255\255\035\000\255\255\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\164\000\164\000\ + \164\000\164\000\164\000\164\000\164\000\164\000\164\000\164\000\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\164\000\ + \164\000\164\000\164\000\164\000\164\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\164\000\ + \164\000\164\000\164\000\164\000\164\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\255\255\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\255\255\035\000\035\000\035\000\035\000\035\000\ + \035\000\035\000\035\000\036\000\255\255\255\255\036\000\036\000\ + \036\000\255\255\255\255\255\255\036\000\036\000\255\255\036\000\ + \036\000\036\000\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\036\000\255\255\036\000\036\000\ + \036\000\036\000\036\000\255\255\204\000\255\255\204\000\204\000\ + \204\000\204\000\204\000\204\000\204\000\204\000\204\000\204\000\ + \204\000\204\000\204\000\204\000\204\000\204\000\204\000\204\000\ + \204\000\204\000\204\000\204\000\204\000\204\000\204\000\204\000\ + \036\000\036\000\204\000\036\000\036\000\036\000\036\000\036\000\ + \036\000\036\000\036\000\036\000\036\000\036\000\036\000\036\000\ + \036\000\036\000\036\000\036\000\036\000\036\000\036\000\036\000\ + \036\000\036\000\036\000\036\000\036\000\255\255\036\000\037\000\ + \036\000\255\255\037\000\037\000\037\000\255\255\255\255\255\255\ + \037\000\037\000\255\255\037\000\037\000\037\000\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \037\000\255\255\037\000\037\000\037\000\037\000\037\000\255\255\ + \210\000\255\255\210\000\210\000\210\000\210\000\210\000\210\000\ + \210\000\210\000\210\000\210\000\210\000\210\000\210\000\210\000\ + \210\000\210\000\210\000\210\000\210\000\210\000\210\000\210\000\ + \210\000\210\000\210\000\210\000\037\000\037\000\210\000\037\000\ + \037\000\037\000\037\000\037\000\037\000\037\000\037\000\037\000\ + \037\000\037\000\037\000\037\000\037\000\037\000\037\000\037\000\ + \037\000\037\000\037\000\037\000\037\000\037\000\037\000\037\000\ + \037\000\255\255\037\000\255\255\037\000\255\255\255\255\255\255\ + \255\255\036\000\036\000\036\000\036\000\036\000\036\000\036\000\ + \036\000\036\000\036\000\036\000\036\000\036\000\036\000\036\000\ + \036\000\036\000\036\000\036\000\036\000\036\000\036\000\036\000\ + \036\000\255\255\036\000\036\000\036\000\036\000\036\000\036\000\ + \036\000\036\000\171\000\171\000\171\000\171\000\171\000\171\000\ + \171\000\171\000\171\000\171\000\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\171\000\171\000\171\000\171\000\171\000\ + \171\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\171\000\171\000\171\000\171\000\171\000\ + \171\000\255\255\255\255\255\255\255\255\037\000\037\000\037\000\ + \037\000\037\000\037\000\037\000\037\000\037\000\037\000\037\000\ + \037\000\037\000\037\000\037\000\037\000\037\000\037\000\037\000\ + \037\000\037\000\037\000\037\000\037\000\038\000\037\000\037\000\ + \037\000\037\000\037\000\037\000\037\000\037\000\038\000\038\000\ + \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\038\000\ + \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ + \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ + \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ + \038\000\255\255\255\255\255\255\255\255\038\000\255\255\038\000\ + \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ + \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ + \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ + \038\000\184\000\184\000\184\000\184\000\184\000\184\000\184\000\ + \184\000\184\000\184\000\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\184\000\184\000\184\000\184\000\184\000\184\000\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\184\000\184\000\184\000\184\000\184\000\184\000\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\038\000\038\000\ + \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ + \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ + \038\000\038\000\038\000\038\000\038\000\255\255\038\000\038\000\ + \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ + \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ + \038\000\038\000\038\000\038\000\038\000\038\000\038\000\038\000\ + \038\000\038\000\038\000\038\000\038\000\255\255\038\000\038\000\ + \038\000\038\000\038\000\038\000\038\000\038\000\046\000\255\255\ + \255\255\046\000\046\000\046\000\255\255\255\255\255\255\046\000\ + \046\000\255\255\046\000\046\000\046\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\046\000\ + \255\255\046\000\046\000\046\000\046\000\046\000\255\255\255\255\ + \255\255\255\255\047\000\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\255\255\255\255\ + \255\255\255\255\255\255\046\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\255\255\255\255\ + \255\255\046\000\047\000\046\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\196\000\196\000\ + \196\000\196\000\196\000\196\000\196\000\196\000\196\000\196\000\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\196\000\ + \196\000\196\000\196\000\196\000\196\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\196\000\ + \196\000\196\000\196\000\196\000\196\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\255\255\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\048\000\047\000\047\000\047\000\047\000\047\000\ + \047\000\047\000\047\000\048\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\255\255\255\255\ + \255\255\255\255\255\255\255\255\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\255\255\255\255\ + \255\255\255\255\048\000\255\255\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\198\000\198\000\ + \198\000\198\000\198\000\198\000\198\000\198\000\198\000\198\000\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\198\000\ + \198\000\198\000\198\000\198\000\198\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\198\000\ + \198\000\198\000\198\000\198\000\198\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\048\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\255\255\048\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\048\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\051\000\048\000\048\000\048\000\048\000\048\000\ + \048\000\048\000\048\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\255\255\255\255\ + \255\255\255\255\255\255\255\255\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\255\255\255\255\ + \255\255\255\255\051\000\255\255\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\255\255\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\052\000\051\000\051\000\051\000\051\000\051\000\ + \051\000\051\000\051\000\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\052\000\255\255\255\255\ + \255\255\255\255\255\255\255\255\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\052\000\255\255\255\255\ + \255\255\255\255\052\000\255\255\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\052\000\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\255\255\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\055\000\052\000\052\000\052\000\052\000\052\000\ + \052\000\052\000\052\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\255\255\255\255\ + \255\255\255\255\055\000\255\255\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\055\000\055\000\ + \055\000\055\000\055\000\055\000\055\000\055\000\056\000\255\255\ + \255\255\255\255\056\000\255\255\056\000\255\255\255\255\056\000\ + \056\000\056\000\056\000\056\000\056\000\056\000\056\000\056\000\ + \056\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \056\000\056\000\056\000\056\000\056\000\056\000\056\000\056\000\ + \056\000\056\000\056\000\056\000\056\000\056\000\056\000\056\000\ + \056\000\056\000\056\000\056\000\056\000\056\000\056\000\056\000\ + \056\000\056\000\255\255\255\255\255\255\255\255\056\000\255\255\ + \056\000\056\000\056\000\056\000\056\000\056\000\056\000\056\000\ + \056\000\056\000\056\000\056\000\056\000\056\000\056\000\056\000\ + \056\000\056\000\056\000\056\000\056\000\056\000\056\000\056\000\ + \056\000\056\000\057\000\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\057\000\057\000\057\000\057\000\057\000\ + \057\000\057\000\057\000\057\000\057\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\057\000\057\000\057\000\057\000\ + \057\000\057\000\057\000\057\000\057\000\057\000\057\000\057\000\ + \057\000\057\000\057\000\057\000\057\000\057\000\057\000\057\000\ + \057\000\057\000\057\000\057\000\057\000\057\000\255\255\255\255\ + \255\255\255\255\057\000\255\255\057\000\057\000\057\000\057\000\ + \057\000\057\000\057\000\057\000\057\000\057\000\057\000\057\000\ + \057\000\057\000\057\000\057\000\057\000\057\000\057\000\057\000\ + \057\000\057\000\057\000\057\000\057\000\057\000\058\000\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\058\000\255\255\255\255\255\255\255\255\058\000\255\255\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\058\000\058\000\058\000\058\000\058\000\058\000\058\000\ + \058\000\058\000\059\000\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\059\000\059\000\059\000\059\000\059\000\ + \059\000\059\000\059\000\059\000\059\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\059\000\059\000\059\000\059\000\ + \059\000\059\000\059\000\059\000\059\000\059\000\059\000\059\000\ + \059\000\059\000\059\000\059\000\059\000\059\000\059\000\059\000\ + \059\000\059\000\059\000\059\000\059\000\059\000\255\255\255\255\ + \255\255\255\255\059\000\255\255\059\000\059\000\059\000\059\000\ + \059\000\059\000\059\000\059\000\059\000\059\000\059\000\059\000\ + \059\000\059\000\059\000\059\000\059\000\059\000\059\000\059\000\ + \059\000\059\000\059\000\059\000\059\000\059\000\060\000\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\060\000\ + \060\000\060\000\060\000\060\000\060\000\060\000\060\000\060\000\ + \060\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \060\000\060\000\060\000\060\000\060\000\060\000\060\000\060\000\ + \060\000\060\000\060\000\060\000\060\000\060\000\060\000\060\000\ + \060\000\060\000\060\000\060\000\060\000\060\000\060\000\060\000\ + \060\000\060\000\255\255\255\255\255\255\255\255\060\000\255\255\ + \060\000\060\000\060\000\060\000\060\000\060\000\060\000\060\000\ + \060\000\060\000\060\000\060\000\060\000\060\000\060\000\060\000\ + \060\000\060\000\060\000\060\000\060\000\060\000\060\000\060\000\ + \060\000\060\000\061\000\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\061\000\061\000\061\000\061\000\061\000\ + \061\000\061\000\061\000\061\000\061\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\061\000\061\000\061\000\061\000\ + \061\000\061\000\061\000\061\000\061\000\061\000\061\000\061\000\ + \061\000\061\000\061\000\061\000\061\000\061\000\061\000\061\000\ + \061\000\061\000\061\000\061\000\061\000\061\000\255\255\255\255\ + \255\255\255\255\061\000\255\255\061\000\061\000\061\000\061\000\ + \061\000\061\000\061\000\061\000\061\000\061\000\061\000\061\000\ + \061\000\061\000\061\000\061\000\061\000\061\000\061\000\061\000\ + \061\000\061\000\061\000\061\000\061\000\061\000\062\000\255\255\ + \255\255\255\255\255\255\255\255\255\255\062\000\255\255\062\000\ + \062\000\062\000\062\000\062\000\062\000\062\000\062\000\062\000\ + \062\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \062\000\062\000\062\000\062\000\062\000\062\000\062\000\062\000\ + \062\000\062\000\062\000\062\000\062\000\062\000\062\000\062\000\ + \062\000\062\000\062\000\062\000\062\000\062\000\062\000\062\000\ + \062\000\062\000\255\255\255\255\255\255\255\255\062\000\255\255\ + \062\000\062\000\062\000\062\000\062\000\062\000\062\000\062\000\ + \062\000\062\000\062\000\062\000\062\000\062\000\062\000\062\000\ + \062\000\062\000\062\000\062\000\062\000\062\000\062\000\062\000\ + \062\000\062\000\063\000\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\063\000\063\000\063\000\063\000\063\000\ + \063\000\063\000\063\000\063\000\063\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\063\000\063\000\063\000\063\000\ + \063\000\063\000\063\000\063\000\063\000\063\000\063\000\063\000\ + \063\000\063\000\063\000\063\000\063\000\063\000\063\000\063\000\ + \063\000\063\000\063\000\063\000\063\000\063\000\255\255\255\255\ + \255\255\255\255\063\000\255\255\063\000\063\000\063\000\063\000\ + \063\000\063\000\063\000\063\000\063\000\063\000\063\000\063\000\ + \063\000\063\000\063\000\063\000\063\000\063\000\063\000\063\000\ + \063\000\063\000\063\000\063\000\063\000\063\000\064\000\255\255\ + \255\255\255\255\064\000\255\255\064\000\255\255\255\255\064\000\ + \064\000\064\000\064\000\064\000\064\000\064\000\064\000\064\000\ + \064\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \064\000\064\000\064\000\064\000\064\000\064\000\064\000\064\000\ + \064\000\064\000\064\000\064\000\064\000\064\000\064\000\064\000\ + \064\000\064\000\064\000\064\000\064\000\064\000\064\000\064\000\ + \064\000\064\000\255\255\255\255\255\255\255\255\064\000\255\255\ + \064\000\064\000\064\000\064\000\064\000\064\000\064\000\064\000\ + \064\000\064\000\064\000\064\000\064\000\064\000\064\000\064\000\ + \064\000\064\000\064\000\064\000\064\000\064\000\064\000\064\000\ + \064\000\064\000\065\000\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\065\000\065\000\065\000\065\000\065\000\ + \065\000\065\000\065\000\065\000\065\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\065\000\065\000\065\000\065\000\ + \065\000\065\000\065\000\065\000\065\000\065\000\065\000\065\000\ + \065\000\065\000\065\000\065\000\065\000\065\000\065\000\065\000\ + \065\000\065\000\065\000\065\000\065\000\065\000\255\255\255\255\ + \255\255\255\255\065\000\255\255\065\000\065\000\065\000\065\000\ + \065\000\065\000\065\000\065\000\065\000\065\000\065\000\065\000\ + \065\000\065\000\065\000\065\000\065\000\065\000\065\000\065\000\ + \065\000\065\000\065\000\065\000\065\000\065\000\067\000\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\067\000\ + \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\255\255\255\255\255\255\255\255\067\000\255\255\ + \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\067\000\067\000\067\000\067\000\067\000\067\000\ + \067\000\067\000\068\000\255\255\255\255\255\255\068\000\255\255\ + \068\000\255\255\255\255\068\000\068\000\068\000\068\000\068\000\ + \068\000\068\000\068\000\068\000\068\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\068\000\068\000\068\000\068\000\ + \068\000\068\000\068\000\068\000\068\000\068\000\068\000\068\000\ + \068\000\068\000\068\000\068\000\068\000\068\000\068\000\068\000\ + \068\000\068\000\068\000\068\000\068\000\068\000\255\255\255\255\ + \255\255\255\255\068\000\255\255\068\000\068\000\068\000\068\000\ + \068\000\068\000\068\000\068\000\068\000\068\000\068\000\068\000\ + \068\000\068\000\068\000\068\000\068\000\068\000\068\000\068\000\ + \068\000\068\000\068\000\068\000\068\000\068\000\069\000\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\069\000\ + \069\000\069\000\069\000\069\000\069\000\069\000\069\000\069\000\ + \069\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \069\000\069\000\069\000\069\000\069\000\069\000\069\000\069\000\ + \069\000\069\000\069\000\069\000\069\000\069\000\069\000\069\000\ + \069\000\069\000\069\000\069\000\069\000\069\000\069\000\069\000\ + \069\000\069\000\255\255\255\255\255\255\255\255\069\000\255\255\ + \069\000\069\000\069\000\069\000\069\000\069\000\069\000\069\000\ + \069\000\069\000\069\000\069\000\069\000\069\000\069\000\069\000\ + \069\000\069\000\069\000\069\000\069\000\069\000\069\000\069\000\ + \069\000\069\000\070\000\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\070\000\070\000\070\000\070\000\070\000\ + \070\000\070\000\070\000\070\000\070\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\070\000\070\000\070\000\070\000\ + \070\000\070\000\070\000\070\000\070\000\070\000\070\000\070\000\ + \070\000\070\000\070\000\070\000\070\000\070\000\070\000\070\000\ + \070\000\070\000\070\000\070\000\070\000\070\000\255\255\255\255\ + \255\255\255\255\070\000\255\255\070\000\070\000\070\000\070\000\ + \070\000\070\000\070\000\070\000\070\000\070\000\070\000\070\000\ + \070\000\070\000\070\000\070\000\070\000\070\000\070\000\070\000\ + \070\000\070\000\070\000\070\000\070\000\070\000\071\000\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\071\000\ + \071\000\071\000\071\000\071\000\071\000\071\000\071\000\071\000\ + \071\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \071\000\071\000\071\000\071\000\071\000\071\000\071\000\071\000\ + \071\000\071\000\071\000\071\000\071\000\071\000\071\000\071\000\ + \071\000\071\000\071\000\071\000\071\000\071\000\071\000\071\000\ + \071\000\071\000\255\255\255\255\255\255\255\255\071\000\255\255\ + \071\000\071\000\071\000\071\000\071\000\071\000\071\000\071\000\ + \071\000\071\000\071\000\071\000\071\000\071\000\071\000\071\000\ + \071\000\071\000\071\000\071\000\071\000\071\000\071\000\071\000\ + \071\000\071\000\076\000\103\000\076\000\255\255\103\000\103\000\ + \103\000\076\000\255\255\255\255\103\000\103\000\255\255\103\000\ + \103\000\103\000\076\000\076\000\076\000\076\000\076\000\076\000\ + \076\000\076\000\076\000\076\000\103\000\255\255\103\000\103\000\ + \103\000\103\000\103\000\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\105\000\255\255\105\000\105\000\105\000\105\000\ + \255\255\255\255\255\255\105\000\105\000\255\255\105\000\105\000\ + \105\000\255\255\255\255\255\255\255\255\255\255\076\000\255\255\ + \103\000\255\255\255\255\105\000\076\000\105\000\105\000\105\000\ + \105\000\105\000\255\255\255\255\255\255\255\255\255\255\255\255\ + \076\000\076\000\255\255\255\255\076\000\255\255\076\000\255\255\ + \116\000\255\255\076\000\116\000\116\000\116\000\103\000\255\255\ + \103\000\116\000\116\000\255\255\116\000\116\000\116\000\105\000\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\116\000\255\255\116\000\116\000\116\000\116\000\116\000\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\117\000\ + \255\255\255\255\117\000\117\000\117\000\105\000\255\255\105\000\ + \117\000\117\000\255\255\117\000\117\000\117\000\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\116\000\255\255\255\255\ + \117\000\255\255\117\000\117\000\117\000\117\000\117\000\255\255\ + \255\255\255\255\118\000\255\255\255\255\118\000\118\000\118\000\ + \255\255\255\255\255\255\118\000\118\000\255\255\118\000\118\000\ + \118\000\255\255\255\255\116\000\255\255\116\000\255\255\255\255\ + \255\255\255\255\255\255\118\000\117\000\118\000\118\000\118\000\ + \118\000\118\000\255\255\255\255\255\255\255\255\255\255\255\255\ + \119\000\255\255\255\255\119\000\119\000\119\000\255\255\255\255\ + \255\255\119\000\119\000\255\255\119\000\119\000\119\000\255\255\ + \255\255\255\255\117\000\255\255\117\000\255\255\255\255\118\000\ + \255\255\119\000\076\000\119\000\119\000\119\000\119\000\119\000\ + \255\255\255\255\255\255\120\000\255\255\255\255\120\000\120\000\ + \120\000\255\255\255\255\255\255\120\000\120\000\255\255\120\000\ + \120\000\120\000\255\255\255\255\255\255\118\000\255\255\118\000\ + \255\255\255\255\255\255\255\255\120\000\119\000\120\000\120\000\ + \120\000\120\000\120\000\255\255\255\255\255\255\126\000\255\255\ + \255\255\126\000\126\000\126\000\255\255\255\255\255\255\126\000\ + \126\000\255\255\126\000\126\000\126\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\119\000\255\255\119\000\255\255\126\000\ + \120\000\126\000\126\000\126\000\126\000\126\000\255\255\255\255\ + \255\255\136\000\255\255\255\255\136\000\136\000\136\000\255\255\ + \255\255\255\255\136\000\136\000\255\255\136\000\136\000\136\000\ + \255\255\255\255\255\255\255\255\255\255\255\255\120\000\255\255\ + \120\000\255\255\136\000\126\000\136\000\136\000\136\000\136\000\ + \136\000\255\255\255\255\255\255\139\000\255\255\255\255\139\000\ + \139\000\139\000\255\255\255\255\255\255\139\000\139\000\255\255\ + \139\000\139\000\139\000\255\255\255\255\255\255\255\255\255\255\ + \255\255\126\000\255\255\126\000\255\255\139\000\136\000\139\000\ + \139\000\139\000\139\000\139\000\255\255\255\255\255\255\140\000\ + \255\255\255\255\140\000\140\000\140\000\255\255\255\255\255\255\ + \140\000\140\000\255\255\140\000\140\000\140\000\255\255\255\255\ + \255\255\255\255\255\255\255\255\136\000\255\255\136\000\255\255\ + \140\000\139\000\140\000\140\000\140\000\140\000\140\000\255\255\ + \255\255\255\255\141\000\255\255\255\255\141\000\141\000\141\000\ + \255\255\255\255\255\255\141\000\141\000\255\255\141\000\141\000\ + \141\000\255\255\255\255\255\255\255\255\255\255\255\255\139\000\ + \255\255\139\000\255\255\141\000\140\000\141\000\141\000\141\000\ + \141\000\141\000\255\255\255\255\255\255\142\000\255\255\255\255\ + \142\000\142\000\142\000\255\255\255\255\255\255\142\000\142\000\ + \255\255\142\000\142\000\142\000\255\255\255\255\157\000\255\255\ + \157\000\255\255\140\000\255\255\140\000\157\000\142\000\141\000\ + \142\000\142\000\142\000\142\000\142\000\255\255\157\000\157\000\ + \157\000\157\000\157\000\157\000\157\000\157\000\157\000\157\000\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\141\000\255\255\141\000\ + \255\255\255\255\142\000\255\255\255\255\255\255\255\255\255\255\ + \255\255\180\000\255\255\255\255\180\000\255\255\255\255\255\255\ + \255\255\255\255\157\000\255\255\255\255\255\255\255\255\255\255\ + \157\000\255\255\255\255\255\255\255\255\255\255\255\255\180\000\ + \142\000\180\000\142\000\255\255\157\000\255\255\180\000\255\255\ + \157\000\255\255\157\000\255\255\255\255\255\255\157\000\180\000\ + \180\000\180\000\180\000\180\000\180\000\180\000\180\000\180\000\ + \180\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\199\000\199\000\199\000\199\000\199\000\199\000\199\000\ + \199\000\199\000\199\000\180\000\255\255\255\255\255\255\255\255\ + \255\255\180\000\199\000\199\000\199\000\199\000\199\000\199\000\ + \255\255\255\255\255\255\255\255\255\255\180\000\180\000\255\255\ + \255\255\180\000\255\255\180\000\180\000\255\255\255\255\180\000\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\199\000\199\000\199\000\199\000\199\000\199\000\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\199\000\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\180\000\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255"; + Lexing.lex_base_code = + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\010\000\036\000\022\000\000\000\000\000\000\000\ + \005\000\000\000\039\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\002\000\005\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000"; + Lexing.lex_backtrk_code = + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\053\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000"; + Lexing.lex_default_code = + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\031\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000"; + Lexing.lex_trans_code = + "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\001\000\000\000\050\000\050\000\000\000\009\000\050\000\ + \000\000\000\000\000\000\009\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \001\000\000\000\009\000\001\000\000\000\009\000\000\000\034\000\ + \000\000\000\000\009\000\000\000\012\000\001\000\000\000\000\000\ + \004\000\004\000\004\000\004\000\004\000\004\000\004\000\004\000\ + \004\000\004\000\017\000\017\000\017\000\017\000\017\000\017\000\ + \017\000\017\000\017\000\017\000\001\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\017\000\017\000\017\000\017\000\ + \017\000\017\000\017\000\017\000\017\000\017\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\ + \000\000\000\000\000\000\000\000\000\000"; + Lexing.lex_check_code = + "\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\024\000\111\000\180\000\189\000\111\000\112\000\190\000\ + \255\255\255\255\255\255\106\000\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \024\000\255\255\111\000\000\000\255\255\112\000\255\255\112\000\ + \255\255\255\255\106\000\255\255\106\000\107\000\255\255\255\255\ + \024\000\024\000\024\000\024\000\024\000\024\000\024\000\024\000\ + \024\000\024\000\106\000\106\000\106\000\106\000\106\000\106\000\ + \106\000\106\000\106\000\106\000\107\000\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\107\000\107\000\107\000\107\000\ + \107\000\107\000\107\000\107\000\107\000\107\000\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \111\000\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\ + \255\255\255\255\255\255\255\255\255\255"; + Lexing.lex_code = + "\255\005\255\255\007\255\006\255\255\007\255\255\009\255\008\255\ + \255\006\255\007\255\255\004\255\000\005\001\006\002\007\255\009\ + \255\255\008\255\009\255\255\000\005\001\006\004\008\003\009\002\ + \007\255\001\255\255\000\001\255"; +} -(* Compute constructor and label descriptions from type declarations, - determining their representation. *) +let rec token lexbuf = + lexbuf.Lexing.lex_mem <- Array.make 10 (-1); __ocaml_lex_token_rec lexbuf 0 +and __ocaml_lex_token_rec lexbuf __ocaml_lex_state = + match Lexing.new_engine __ocaml_lex_tables __ocaml_lex_state lexbuf with + | 0 -> +# 770 "parsing/lexer.mll" + ( + if not !escaped_newlines then + raise (Error(Illegal_character (Lexing.lexeme_char lexbuf 0), + Location.curr lexbuf)); + update_loc lexbuf None 1 false 0; + token lexbuf ) +# 2358 "parsing/lexer.ml" -open Types + | 1 -> +# 777 "parsing/lexer.mll" + ( update_loc lexbuf None 1 false 0; + EOL ) +# 2364 "parsing/lexer.ml" -val constructor_has_optional_shape: - Types.constructor_description -> bool + | 2 -> +# 780 "parsing/lexer.mll" + ( token lexbuf ) +# 2369 "parsing/lexer.ml" -val extension_descr: - Path.t -> extension_constructor -> constructor_description + | 3 -> +# 782 "parsing/lexer.mll" + ( UNDERSCORE ) +# 2374 "parsing/lexer.ml" -val labels_of_type: - Path.t -> type_declaration -> - (Ident.t * label_description) list -val constructors_of_type: - Path.t -> type_declaration -> - (Ident.t * constructor_description) list + | 4 -> +# 784 "parsing/lexer.mll" + ( TILDE ) +# 2379 "parsing/lexer.ml" + | 5 -> +# 786 "parsing/lexer.mll" + ( LABEL (get_label_name lexbuf) ) +# 2384 "parsing/lexer.ml" -exception Constr_not_found + | 6 -> +# 788 "parsing/lexer.mll" + ( warn_latin1 lexbuf; LABEL (get_label_name lexbuf) ) +# 2389 "parsing/lexer.ml" -val find_constr_by_tag: - constructor_tag -> constructor_declaration list -> - constructor_declaration + | 7 -> +# 790 "parsing/lexer.mll" + ( QUESTION ) +# 2394 "parsing/lexer.ml" -val constructor_existentials : - constructor_arguments -> type_expr option -> type_expr list * type_expr list -(** Takes [cd_args] and [cd_res] from a [constructor_declaration] and - returns: - - the types of the constructor's arguments - - the existential variables introduced by the constructor - *) + | 8 -> +# 792 "parsing/lexer.mll" + ( OPTLABEL (get_label_name lexbuf) ) +# 2399 "parsing/lexer.ml" + | 9 -> +# 794 "parsing/lexer.mll" + ( warn_latin1 lexbuf; OPTLABEL (get_label_name lexbuf) ) +# 2404 "parsing/lexer.ml" -(* Set the polymorphic variant row_name field *) -val set_row_name : type_declaration -> Path.t -> unit + | 10 -> +# 796 "parsing/lexer.mll" + ( let s = Lexing.lexeme lexbuf in + try Hashtbl.find keyword_table s + with Not_found -> LIDENT s ) +# 2411 "parsing/lexer.ml" -end = struct -#1 "datarepr.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) + | 11 -> +# 800 "parsing/lexer.mll" + ( warn_latin1 lexbuf; LIDENT (Lexing.lexeme lexbuf) ) +# 2416 "parsing/lexer.ml" -(* Compute constructor and label descriptions from type declarations, - determining their representation. *) + | 12 -> +# 802 "parsing/lexer.mll" + ( UIDENT(Lexing.lexeme lexbuf) ) +# 2421 "parsing/lexer.ml" -open Asttypes -open Types -open Btype + | 13 -> +# 804 "parsing/lexer.mll" + ( warn_latin1 lexbuf; UIDENT(Lexing.lexeme lexbuf) ) +# 2426 "parsing/lexer.ml" -(* Simplified version of Ctype.free_vars *) -let free_vars ?(param=false) ty = - let ret = ref TypeSet.empty in - let rec loop ty = - let ty = repr ty in - if ty.level >= lowest_level then begin - ty.level <- pivot_level - ty.level; - match ty.desc with - | Tvar _ -> - ret := TypeSet.add ty !ret - | Tvariant row -> - let row = row_repr row in - iter_row loop row; - if not (static_row row) then begin - match row.row_more.desc with - | Tvar _ when param -> ret := TypeSet.add ty !ret - | _ -> loop row.row_more - end - (* XXX: What about Tobject ? *) - | _ -> - iter_type_expr loop ty - end - in - loop ty; - unmark_type ty; - !ret + | 14 -> +# 805 "parsing/lexer.mll" + ( INT (Lexing.lexeme lexbuf, None) ) +# 2431 "parsing/lexer.ml" -let newgenconstr path tyl = newgenty (Tconstr (path, tyl, ref Mnil)) + | 15 -> +let +# 806 "parsing/lexer.mll" + lit +# 2437 "parsing/lexer.ml" += Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_start_pos (lexbuf.Lexing.lex_curr_pos + -1) +and +# 806 "parsing/lexer.mll" + modif +# 2442 "parsing/lexer.ml" += Lexing.sub_lexeme_char lexbuf (lexbuf.Lexing.lex_curr_pos + -1) in +# 807 "parsing/lexer.mll" + ( INT (lit, Some modif) ) +# 2446 "parsing/lexer.ml" -let constructor_existentials cd_args cd_res = - let tyl = - match cd_args with - | Cstr_tuple l -> l - | Cstr_record l -> List.map (fun l -> l.ld_type) l - in - let existentials = - match cd_res with - | None -> [] - | Some type_ret -> - let arg_vars_set = free_vars (newgenty (Ttuple tyl)) in - let res_vars = free_vars type_ret in - TypeSet.elements (TypeSet.diff arg_vars_set res_vars) - in - (tyl, existentials) + | 16 -> +# 809 "parsing/lexer.mll" + ( FLOAT (Lexing.lexeme lexbuf, None) ) +# 2451 "parsing/lexer.ml" -let constructor_args priv cd_args cd_res path rep = - let tyl, existentials = constructor_existentials cd_args cd_res in - match cd_args with - | Cstr_tuple l -> existentials, l, None - | Cstr_record lbls -> - let arg_vars_set = free_vars ~param:true (newgenty (Ttuple tyl)) in - let type_params = TypeSet.elements arg_vars_set in - let type_unboxed = - match rep with - | Record_unboxed _ -> unboxed_true_default_false - | _ -> unboxed_false_default_false - in - let tdecl = - { - type_params; - type_arity = List.length type_params; - type_kind = Type_record (lbls, rep); - type_private = priv; - type_manifest = None; - type_variance = List.map (fun _ -> Variance.full) type_params; - type_newtype_level = None; - type_loc = Location.none; - type_attributes = []; - type_immediate = false; - type_unboxed; - } - in - existentials, - [ newgenconstr path type_params ], - Some tdecl + | 17 -> +let +# 810 "parsing/lexer.mll" + lit +# 2457 "parsing/lexer.ml" += Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_start_pos (lexbuf.Lexing.lex_curr_pos + -1) +and +# 810 "parsing/lexer.mll" + modif +# 2462 "parsing/lexer.ml" += Lexing.sub_lexeme_char lexbuf (lexbuf.Lexing.lex_curr_pos + -1) in +# 811 "parsing/lexer.mll" + ( FLOAT (lit, Some modif) ) +# 2466 "parsing/lexer.ml" -let internal_optional = "internal.optional" - -let optional_shape : Parsetree.attribute = - {txt = internal_optional ; loc = Location.none}, Parsetree.PStr [] + | 18 -> +# 813 "parsing/lexer.mll" + ( raise (Error(Invalid_literal (Lexing.lexeme lexbuf), + Location.curr lexbuf)) ) +# 2472 "parsing/lexer.ml" -let constructor_has_optional_shape ({cstr_attributes = attrs} : constructor_description) = - List.exists (fun (x,_) -> x.txt = internal_optional) attrs + | 19 -> +# 816 "parsing/lexer.mll" + ( reset_string_buffer(); + is_in_string := true; + let string_start = lexbuf.lex_start_p in + string_start_loc := Location.curr lexbuf; + string lexbuf; + is_in_string := false; + lexbuf.lex_start_p <- string_start; + STRING (get_stored_string(), None) ) +# 2484 "parsing/lexer.ml" + | 20 -> +# 825 "parsing/lexer.mll" + ( reset_string_buffer(); + let delim = Lexing.lexeme lexbuf in + let delim = String.sub delim 1 (String.length delim - 2) in + is_in_string := true; + let string_start = lexbuf.lex_start_p in + string_start_loc := Location.curr lexbuf; + quoted_string delim lexbuf; + is_in_string := false; + lexbuf.lex_start_p <- string_start; + STRING (get_stored_string(), Some delim) ) +# 2498 "parsing/lexer.ml" -let constructor_descrs ty_path decl cstrs = - let ty_res = newgenconstr ty_path decl.type_params in - let num_consts = ref 0 and num_nonconsts = ref 0 and num_normal = ref 0 in - List.iter - (fun {cd_args; cd_res; _} -> - if cd_args = Cstr_tuple [] then incr num_consts else incr num_nonconsts; - if cd_res = None then incr num_normal) - cstrs; - let rec describe_constructors idx_const idx_nonconst = function - [] -> [] - | {cd_id; cd_args; cd_res; cd_loc; cd_attributes} :: rem -> - let ty_res = - match cd_res with - | Some ty_res' -> ty_res' - | None -> ty_res - in - let (tag, descr_rem) = - match cd_args with - | _ when decl.type_unboxed.unboxed -> - assert (rem = []); - (Cstr_unboxed, []) - | Cstr_tuple [] -> (Cstr_constant idx_const, - describe_constructors (idx_const+1) idx_nonconst rem) - | _ -> (Cstr_block idx_nonconst, - describe_constructors idx_const (idx_nonconst+1) rem) in - let cstr_name = Ident.name cd_id in - let existentials, cstr_args, cstr_inlined = - let representation = - if decl.type_unboxed.unboxed - then Record_unboxed true - else Record_inlined {tag = idx_nonconst; name = cstr_name; num_nonconsts = !num_nonconsts} - in - constructor_args decl.type_private cd_args cd_res - (Path.Pdot (ty_path, cstr_name, Path.nopos)) representation - in - let cstr = - { cstr_name; - cstr_res = ty_res; - cstr_existentials = existentials; - cstr_args; - cstr_arity = List.length cstr_args; - cstr_tag = tag; - cstr_consts = !num_consts; - cstr_nonconsts = !num_nonconsts; - cstr_normal = !num_normal; - cstr_private = decl.type_private; - cstr_generalized = cd_res <> None; - cstr_loc = cd_loc; - cstr_attributes = cd_attributes; - cstr_inlined; - } in - (cd_id, cstr) :: descr_rem in - let result = describe_constructors 0 0 cstrs in - match result with - | ( - [ ({Ident.name = "None"} as a_id, ({cstr_args = []} as a_descr) ) ; - ({Ident.name = "Some"} as b_id, ({ cstr_args = [_]} as b_descr)) - ] | - [ ({Ident.name = "Some"} as a_id, ({cstr_args = [_]} as a_descr) ) ; - ({Ident.name = "None"} as b_id, ({ cstr_args = []} as b_descr)) - ] - ) - -> - [ - (a_id, {a_descr with - cstr_attributes = - optional_shape :: a_descr.cstr_attributes}); - (b_id, {b_descr with - cstr_attributes = - optional_shape :: b_descr.cstr_attributes - }) - ] - | _ -> result + | 21 -> +# 836 "parsing/lexer.mll" + ( update_loc lexbuf None 1 false 1; + CHAR (Lexing.lexeme_char lexbuf 1) ) +# 2504 "parsing/lexer.ml" -let extension_descr path_ext ext = - let ty_res = - match ext.ext_ret_type with - Some type_ret -> type_ret - | None -> newgenconstr ext.ext_type_path ext.ext_type_params - in - let existentials, cstr_args, cstr_inlined = - constructor_args ext.ext_private ext.ext_args ext.ext_ret_type - path_ext Record_extension - in - { cstr_name = Path.last path_ext; - cstr_res = ty_res; - cstr_existentials = existentials; - cstr_args; - cstr_arity = List.length cstr_args; - cstr_tag = Cstr_extension(path_ext, cstr_args = []); - cstr_consts = -1; - cstr_nonconsts = -1; - cstr_private = ext.ext_private; - cstr_normal = -1; - cstr_generalized = ext.ext_ret_type <> None; - cstr_loc = ext.ext_loc; - cstr_attributes = ext.ext_attributes; - cstr_inlined; - } + | 22 -> +# 839 "parsing/lexer.mll" + ( CHAR(Lexing.lexeme_char lexbuf 1) ) +# 2509 "parsing/lexer.ml" -let none = {desc = Ttuple []; level = -1; id = -1} - (* Clearly ill-formed type *) -let dummy_label = - { lbl_name = ""; lbl_res = none; lbl_arg = none; lbl_mut = Immutable; - lbl_pos = (-1); lbl_all = [||]; lbl_repres = Record_regular; - lbl_private = Public; - lbl_loc = Location.none; - lbl_attributes = []; - } + | 23 -> +# 841 "parsing/lexer.mll" + ( CHAR(char_for_backslash (Lexing.lexeme_char lexbuf 2)) ) +# 2514 "parsing/lexer.ml" -let label_descrs ty_res lbls repres priv = - let all_labels = Array.make (List.length lbls) dummy_label in - let rec describe_labels num = function - [] -> [] - | l :: rest -> - let lbl = - { lbl_name = Ident.name l.ld_id; - lbl_res = ty_res; - lbl_arg = l.ld_type; - lbl_mut = l.ld_mutable; - lbl_pos = num; - lbl_all = all_labels; - lbl_repres = repres; - lbl_private = priv; - lbl_loc = l.ld_loc; - lbl_attributes = l.ld_attributes; - } in - all_labels.(num) <- lbl; - (l.ld_id, lbl) :: describe_labels (num+1) rest in - describe_labels 0 lbls + | 24 -> +# 843 "parsing/lexer.mll" + ( CHAR(char_for_decimal_code lexbuf 2) ) +# 2519 "parsing/lexer.ml" -exception Constr_not_found + | 25 -> +# 845 "parsing/lexer.mll" + ( CHAR(char_for_octal_code lexbuf 3) ) +# 2524 "parsing/lexer.ml" -let rec find_constr tag num_const num_nonconst = function - [] -> - raise Constr_not_found - | {cd_args = Cstr_tuple []; _} as c :: rem -> - if tag = Cstr_constant num_const - then c - else find_constr tag (num_const + 1) num_nonconst rem - | c :: rem -> - if tag = Cstr_block num_nonconst || tag = Cstr_unboxed - then c - else find_constr tag num_const (num_nonconst + 1) rem + | 26 -> +# 847 "parsing/lexer.mll" + ( CHAR(char_for_hexadecimal_code lexbuf 3) ) +# 2529 "parsing/lexer.ml" -let find_constr_by_tag tag cstrlist = - find_constr tag 0 0 cstrlist + | 27 -> +# 849 "parsing/lexer.mll" + ( let l = Lexing.lexeme lexbuf in + let esc = String.sub l 1 (String.length l - 1) in + raise (Error(Illegal_escape esc, Location.curr lexbuf)) + ) +# 2537 "parsing/lexer.ml" -let constructors_of_type ty_path decl = - match decl.type_kind with - | Type_variant cstrs -> constructor_descrs ty_path decl cstrs - | Type_record _ | Type_abstract | Type_open -> [] + | 28 -> +# 854 "parsing/lexer.mll" + ( let s, loc = with_comment_buffer comment lexbuf in + COMMENT (s, loc) ) +# 2543 "parsing/lexer.ml" -let labels_of_type ty_path decl = - match decl.type_kind with - | Type_record(labels, rep) -> - label_descrs (newgenconstr ty_path decl.type_params) - labels rep decl.type_private - | Type_variant _ | Type_abstract | Type_open -> [] + | 29 -> +# 857 "parsing/lexer.mll" + ( let s, loc = with_comment_buffer comment lexbuf in + if !handle_docstrings then + DOCSTRING (Docstrings.docstring s loc) + else + COMMENT ("*" ^ s, loc) + ) +# 2553 "parsing/lexer.ml" -(* Set row_name in Env, cf. GPR#1204/1329 *) -let set_row_name decl path = - match decl.type_manifest with - None -> () - | Some ty -> - let ty = repr ty in - match ty.desc with - Tvariant row when static_row row -> - let row = {(row_repr row) with - row_name = Some (path, decl.type_params)} in - ty.desc <- Tvariant row - | _ -> () + | 30 -> +let +# 863 "parsing/lexer.mll" + stars +# 2559 "parsing/lexer.ml" += Lexing.sub_lexeme lexbuf (lexbuf.Lexing.lex_start_pos + 3) lexbuf.Lexing.lex_curr_pos in +# 864 "parsing/lexer.mll" + ( let s, loc = + with_comment_buffer + (fun lexbuf -> + store_string ("*" ^ stars); + comment lexbuf) + lexbuf + in + COMMENT (s, loc) ) +# 2570 "parsing/lexer.ml" -end -module Predef : sig -#1 "predef.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) + | 31 -> +# 873 "parsing/lexer.mll" + ( if !print_warnings then + Location.prerr_warning (Location.curr lexbuf) Warnings.Comment_start; + let s, loc = with_comment_buffer comment lexbuf in + COMMENT (s, loc) ) +# 2578 "parsing/lexer.ml" -(* Predefined type constructors (with special typing rules in typecore) *) + | 32 -> +let +# 877 "parsing/lexer.mll" + stars +# 2584 "parsing/lexer.ml" += Lexing.sub_lexeme lexbuf (lexbuf.Lexing.lex_start_pos + 2) (lexbuf.Lexing.lex_curr_pos + -2) in +# 878 "parsing/lexer.mll" + ( if !handle_docstrings && stars="" then + (* (**) is an empty docstring *) + DOCSTRING(Docstrings.docstring "" (Location.curr lexbuf)) + else + COMMENT (stars, Location.curr lexbuf) ) +# 2592 "parsing/lexer.ml" -open Types + | 33 -> +# 884 "parsing/lexer.mll" + ( let loc = Location.curr lexbuf in + Location.prerr_warning loc Warnings.Comment_not_end; + lexbuf.Lexing.lex_curr_pos <- lexbuf.Lexing.lex_curr_pos - 1; + let curpos = lexbuf.lex_curr_p in + lexbuf.lex_curr_p <- { curpos with pos_cnum = curpos.pos_cnum - 1 }; + STAR + ) +# 2603 "parsing/lexer.ml" -val type_int: type_expr -val type_char: type_expr -val type_string: type_expr -val type_bytes: type_expr -val type_float: type_expr -val type_bool: type_expr -val type_unit: type_expr -val type_exn: type_expr -val type_array: type_expr -> type_expr -val type_list: type_expr -> type_expr -val type_option: type_expr -> type_expr -val type_nativeint: type_expr -val type_int32: type_expr -val type_int64: type_expr -val type_lazy_t: type_expr -> type_expr -val type_extension_constructor:type_expr -val type_floatarray:type_expr + | 34 -> +let +# 891 "parsing/lexer.mll" + num +# 2609 "parsing/lexer.ml" += Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_mem.(0) lexbuf.Lexing.lex_mem.(1) +and +# 892 "parsing/lexer.mll" + name +# 2614 "parsing/lexer.ml" += Lexing.sub_lexeme_opt lexbuf lexbuf.Lexing.lex_mem.(4) lexbuf.Lexing.lex_mem.(3) +and +# 892 "parsing/lexer.mll" + directive +# 2619 "parsing/lexer.ml" += Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_start_pos lexbuf.Lexing.lex_mem.(2) in +# 894 "parsing/lexer.mll" + ( + match int_of_string num with + | exception _ -> + (* PR#7165 *) + let loc = Location.curr lexbuf in + let explanation = "line number out of range" in + let error = Invalid_directive (directive, Some explanation) in + raise (Error (error, loc)) + | line_num -> + (* Documentation says that the line number should be + positive, but we have never guarded against this and it + might have useful hackish uses. *) + update_loc lexbuf name line_num true 0; + token lexbuf + ) +# 2637 "parsing/lexer.ml" -val path_int: Path.t -val path_char: Path.t -val path_string: Path.t -val path_bytes: Path.t -val path_float: Path.t -val path_bool: Path.t -val path_unit: Path.t -val path_exn: Path.t -val path_array: Path.t -val path_list: Path.t -val path_option: Path.t -val path_nativeint: Path.t -val path_int32: Path.t -val path_int64: Path.t -val path_lazy_t: Path.t -val path_extension_constructor: Path.t -val path_floatarray: Path.t + | 35 -> +# 909 "parsing/lexer.mll" + ( HASH ) +# 2642 "parsing/lexer.ml" -val path_match_failure: Path.t -val path_assert_failure : Path.t -val path_undefined_recursive_module : Path.t + | 36 -> +# 910 "parsing/lexer.mll" + ( AMPERSAND ) +# 2647 "parsing/lexer.ml" -(* To build the initial environment. Since there is a nasty mutual - recursion between predef and env, we break it by parameterizing - over Env.t, Env.add_type and Env.add_extension. *) + | 37 -> +# 911 "parsing/lexer.mll" + ( AMPERAMPER ) +# 2652 "parsing/lexer.ml" -val build_initial_env: - (Ident.t -> type_declaration -> 'a -> 'a) -> - (Ident.t -> extension_constructor -> 'a -> 'a) -> - 'a -> 'a * 'a + | 38 -> +# 912 "parsing/lexer.mll" + ( BACKQUOTE ) +# 2657 "parsing/lexer.ml" + + | 39 -> +# 913 "parsing/lexer.mll" + ( QUOTE ) +# 2662 "parsing/lexer.ml" -(* To initialize linker tables *) + | 40 -> +# 914 "parsing/lexer.mll" + ( LPAREN ) +# 2667 "parsing/lexer.ml" -val builtin_values: (string * Ident.t) list -val builtin_idents: (string * Ident.t) list + | 41 -> +# 915 "parsing/lexer.mll" + ( RPAREN ) +# 2672 "parsing/lexer.ml" -(** All predefined exceptions, exposed as [Ident.t] for flambda (for - building value approximations). - The [Ident.t] for division by zero is also exported explicitly - so flambda can generate code to raise it. *) -val ident_division_by_zero: Ident.t -val all_predef_exns : Ident.t list + | 42 -> +# 916 "parsing/lexer.mll" + ( STAR ) +# 2677 "parsing/lexer.ml" -val type_is_builtin_path_but_option : Path.t -> bool + | 43 -> +# 917 "parsing/lexer.mll" + ( COMMA ) +# 2682 "parsing/lexer.ml" -end = struct -#1 "predef.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) + | 44 -> +# 918 "parsing/lexer.mll" + ( MINUSGREATER ) +# 2687 "parsing/lexer.ml" -(* Predefined type constructors (with special typing rules in typecore) *) + | 45 -> +# 919 "parsing/lexer.mll" + ( DOT ) +# 2692 "parsing/lexer.ml" -open Path -open Types -open Btype + | 46 -> +# 920 "parsing/lexer.mll" + ( DOTDOT ) +# 2697 "parsing/lexer.ml" -let builtin_idents = ref [] + | 47 -> +let +# 921 "parsing/lexer.mll" + s +# 2703 "parsing/lexer.ml" += Lexing.sub_lexeme lexbuf (lexbuf.Lexing.lex_start_pos + 1) lexbuf.Lexing.lex_curr_pos in +# 921 "parsing/lexer.mll" + ( DOTOP s ) +# 2707 "parsing/lexer.ml" -let wrap create s = - let id = create s in - builtin_idents := (s, id) :: !builtin_idents; - id + | 48 -> +# 922 "parsing/lexer.mll" + ( COLON ) +# 2712 "parsing/lexer.ml" -let ident_create = wrap Ident.create -let ident_create_predef_exn = wrap Ident.create_predef_exn + | 49 -> +# 923 "parsing/lexer.mll" + ( COLONCOLON ) +# 2717 "parsing/lexer.ml" -let ident_int = ident_create "int" -and ident_char = ident_create "char" -and ident_bytes = ident_create "bytes" -and ident_float = ident_create "float" -and ident_bool = ident_create "bool" -and ident_unit = ident_create "unit" -and ident_exn = ident_create "exn" -and ident_array = ident_create "array" -and ident_list = ident_create "list" -and ident_option = ident_create "option" -and ident_nativeint = ident_create "nativeint" -and ident_int32 = ident_create "int32" -and ident_int64 = ident_create "int64" -and ident_lazy_t = ident_create "lazy_t" -and ident_string = ident_create "string" -and ident_extension_constructor = ident_create "extension_constructor" -and ident_floatarray = ident_create "floatarray" + | 50 -> +# 924 "parsing/lexer.mll" + ( COLONEQUAL ) +# 2722 "parsing/lexer.ml" -let type_is_builtin_path_but_option (p : Path.t) = - match p with - | Pident {Ident.stamp} -> - stamp >= ident_int.Ident.stamp - && stamp <= ident_floatarray.Ident.stamp - && (stamp <> ident_option.Ident.stamp) - | _ -> false + | 51 -> +# 925 "parsing/lexer.mll" + ( COLONGREATER ) +# 2727 "parsing/lexer.ml" -let path_int = Pident ident_int -and path_char = Pident ident_char -and path_bytes = Pident ident_bytes -and path_float = Pident ident_float -and path_bool = Pident ident_bool -and path_unit = Pident ident_unit -and path_exn = Pident ident_exn -and path_array = Pident ident_array -and path_list = Pident ident_list -and path_option = Pident ident_option -and path_nativeint = Pident ident_nativeint -and path_int32 = Pident ident_int32 -and path_int64 = Pident ident_int64 -and path_lazy_t = Pident ident_lazy_t -and path_string = Pident ident_string -and path_extension_constructor = Pident ident_extension_constructor -and path_floatarray = Pident ident_floatarray + | 52 -> +# 926 "parsing/lexer.mll" + ( SEMI ) +# 2732 "parsing/lexer.ml" -let type_int = newgenty (Tconstr(path_int, [], ref Mnil)) -and type_char = newgenty (Tconstr(path_char, [], ref Mnil)) -and type_bytes = newgenty (Tconstr(path_bytes, [], ref Mnil)) -and type_float = newgenty (Tconstr(path_float, [], ref Mnil)) -and type_bool = newgenty (Tconstr(path_bool, [], ref Mnil)) -and type_unit = newgenty (Tconstr(path_unit, [], ref Mnil)) -and type_exn = newgenty (Tconstr(path_exn, [], ref Mnil)) -and type_array t = newgenty (Tconstr(path_array, [t], ref Mnil)) -and type_list t = newgenty (Tconstr(path_list, [t], ref Mnil)) -and type_option t = newgenty (Tconstr(path_option, [t], ref Mnil)) -and type_nativeint = newgenty (Tconstr(path_nativeint, [], ref Mnil)) -and type_int32 = newgenty (Tconstr(path_int32, [], ref Mnil)) -and type_int64 = newgenty (Tconstr(path_int64, [], ref Mnil)) -and type_lazy_t t = newgenty (Tconstr(path_lazy_t, [t], ref Mnil)) -and type_string = newgenty (Tconstr(path_string, [], ref Mnil)) -and type_extension_constructor = - newgenty (Tconstr(path_extension_constructor, [], ref Mnil)) -and type_floatarray = newgenty (Tconstr(path_floatarray, [], ref Mnil)) + | 53 -> +# 927 "parsing/lexer.mll" + ( SEMISEMI ) +# 2737 "parsing/lexer.ml" -let ident_match_failure = ident_create_predef_exn "Match_failure" -and ident_out_of_memory = ident_create_predef_exn "Out_of_memory" -and ident_invalid_argument = ident_create_predef_exn "Invalid_argument" -and ident_failure = ident_create_predef_exn "Failure" -and ident_not_found = ident_create_predef_exn "Not_found" -and ident_sys_error = ident_create_predef_exn "Sys_error" -and ident_end_of_file = ident_create_predef_exn "End_of_file" -and ident_division_by_zero = ident_create_predef_exn "Division_by_zero" -and ident_stack_overflow = ident_create_predef_exn "Stack_overflow" -and ident_sys_blocked_io = ident_create_predef_exn "Sys_blocked_io" -and ident_assert_failure = ident_create_predef_exn "Assert_failure" -and ident_undefined_recursive_module = - ident_create_predef_exn "Undefined_recursive_module" + | 54 -> +# 928 "parsing/lexer.mll" + ( LESS ) +# 2742 "parsing/lexer.ml" -let all_predef_exns = [ - ident_match_failure; - ident_out_of_memory; - ident_invalid_argument; - ident_failure; - ident_not_found; - ident_sys_error; - ident_end_of_file; - ident_division_by_zero; - ident_stack_overflow; - ident_sys_blocked_io; - ident_assert_failure; - ident_undefined_recursive_module; -] + | 55 -> +# 929 "parsing/lexer.mll" + ( LESSMINUS ) +# 2747 "parsing/lexer.ml" -let path_match_failure = Pident ident_match_failure -and path_assert_failure = Pident ident_assert_failure -and path_undefined_recursive_module = Pident ident_undefined_recursive_module + | 56 -> +# 930 "parsing/lexer.mll" + ( EQUAL ) +# 2752 "parsing/lexer.ml" -let decl_abstr = - {type_params = []; - type_arity = 0; - type_kind = Type_abstract; - type_loc = Location.none; - type_private = Asttypes.Public; - type_manifest = None; - type_variance = []; - type_newtype_level = None; - type_attributes = []; - type_immediate = false; - type_unboxed = unboxed_false_default_false; - } + | 57 -> +# 931 "parsing/lexer.mll" + ( LBRACKET ) +# 2757 "parsing/lexer.ml" -let decl_abstr_imm = {decl_abstr with type_immediate = true} + | 58 -> +# 932 "parsing/lexer.mll" + ( LBRACKETBAR ) +# 2762 "parsing/lexer.ml" -let cstr id args = - { - cd_id = id; - cd_args = Cstr_tuple args; - cd_res = None; - cd_loc = Location.none; - cd_attributes = []; - } + | 59 -> +# 933 "parsing/lexer.mll" + ( LBRACKETLESS ) +# 2767 "parsing/lexer.ml" -let ident_false = ident_create "false" -and ident_true = ident_create "true" -and ident_void = ident_create "()" -and ident_nil = ident_create "[]" -and ident_cons = ident_create "::" -and ident_none = ident_create "None" -and ident_some = ident_create "Some" -let common_initial_env add_type add_extension empty_env = - let decl_bool = - {decl_abstr with - type_kind = Type_variant([cstr ident_false []; cstr ident_true []]); - type_immediate = true} - and decl_unit = - {decl_abstr with - type_kind = Type_variant([cstr ident_void []]); - type_immediate = true} - and decl_exn = - {decl_abstr with - type_kind = Type_open} - and decl_array = - let tvar = newgenvar() in - {decl_abstr with - type_params = [tvar]; - type_arity = 1; - type_variance = [Variance.full]} - and decl_list = - let tvar = newgenvar() in - {decl_abstr with - type_params = [tvar]; - type_arity = 1; - type_kind = - Type_variant([cstr ident_nil []; cstr ident_cons [tvar; type_list tvar]]); - type_variance = [Variance.covariant]} - and decl_option = - let tvar = newgenvar() in - {decl_abstr with - type_params = [tvar]; - type_arity = 1; - type_kind = Type_variant([cstr ident_none []; cstr ident_some [tvar]]); - type_variance = [Variance.covariant]} - and decl_lazy_t = - let tvar = newgenvar() in - {decl_abstr with - type_params = [tvar]; - type_arity = 1; - type_variance = [Variance.covariant]} - in + | 60 -> +# 934 "parsing/lexer.mll" + ( LBRACKETGREATER ) +# 2772 "parsing/lexer.ml" - let add_extension id l = - add_extension id - { ext_type_path = path_exn; - ext_type_params = []; - ext_args = Cstr_tuple l; - ext_ret_type = None; - ext_private = Asttypes.Public; - ext_loc = Location.none; - ext_attributes = [{Asttypes.txt="ocaml.warn_on_literal_pattern"; - loc=Location.none}, - Parsetree.PStr[]] } - in - add_extension ident_match_failure - [newgenty (Ttuple[type_string; type_int; type_int])] ( - add_extension ident_out_of_memory [] ( - add_extension ident_stack_overflow [] ( - add_extension ident_invalid_argument [type_string] ( - add_extension ident_failure [type_string] ( - add_extension ident_not_found [] ( - add_extension ident_sys_blocked_io [] ( - add_extension ident_sys_error [type_string] ( - add_extension ident_end_of_file [] ( - add_extension ident_division_by_zero [] ( - add_extension ident_assert_failure - [newgenty (Ttuple[type_string; type_int; type_int])] ( - add_extension ident_undefined_recursive_module - [newgenty (Ttuple[type_string; type_int; type_int])] ( - add_type ident_int64 decl_abstr ( - add_type ident_int32 decl_abstr ( - add_type ident_nativeint decl_abstr ( - add_type ident_lazy_t decl_lazy_t ( - add_type ident_option decl_option ( - add_type ident_list decl_list ( - add_type ident_array decl_array ( - add_type ident_exn decl_exn ( - add_type ident_unit decl_unit ( - add_type ident_bool decl_bool ( - add_type ident_float decl_abstr ( - add_type ident_string decl_abstr ( - add_type ident_char decl_abstr_imm ( - add_type ident_int decl_abstr_imm ( - add_type ident_extension_constructor decl_abstr ( - add_type ident_floatarray decl_abstr ( - empty_env)))))))))))))))))))))))))))) + | 61 -> +# 935 "parsing/lexer.mll" + ( RBRACKET ) +# 2777 "parsing/lexer.ml" -let build_initial_env add_type add_exception empty_env = - let common = common_initial_env add_type add_exception empty_env in - let safe_string = add_type ident_bytes decl_abstr common in - let decl_bytes_unsafe = {decl_abstr with type_manifest = Some type_string} in - let unsafe_string = add_type ident_bytes decl_bytes_unsafe common in - (safe_string, unsafe_string) + | 62 -> +# 936 "parsing/lexer.mll" + ( LBRACE ) +# 2782 "parsing/lexer.ml" -let builtin_values = - List.map (fun id -> Ident.make_global id; (Ident.name id, id)) - [ident_match_failure; ident_out_of_memory; ident_stack_overflow; - ident_invalid_argument; - ident_failure; ident_not_found; ident_sys_error; ident_end_of_file; - ident_division_by_zero; ident_sys_blocked_io; - ident_assert_failure; ident_undefined_recursive_module ] + | 63 -> +# 937 "parsing/lexer.mll" + ( LBRACELESS ) +# 2787 "parsing/lexer.ml" -(* Start non-predef identifiers at 1000. This way, more predefs can - be defined in this file (above!) without breaking .cmi - compatibility. *) + | 64 -> +# 938 "parsing/lexer.mll" + ( BAR ) +# 2792 "parsing/lexer.ml" -let _ = Ident.set_current_time 999 -let builtin_idents = List.rev !builtin_idents + | 65 -> +# 939 "parsing/lexer.mll" + ( BARBAR ) +# 2797 "parsing/lexer.ml" -end -module Ast_mapper : sig -#1 "ast_mapper.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Alain Frisch, LexiFi *) -(* *) -(* Copyright 2012 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) + | 66 -> +# 940 "parsing/lexer.mll" + ( BARRBRACKET ) +# 2802 "parsing/lexer.ml" -(** The interface of a -ppx rewriter + | 67 -> +# 941 "parsing/lexer.mll" + ( GREATER ) +# 2807 "parsing/lexer.ml" - A -ppx rewriter is a program that accepts a serialized abstract syntax - tree and outputs another, possibly modified, abstract syntax tree. - This module encapsulates the interface between the compiler and - the -ppx rewriters, handling such details as the serialization format, - forwarding of command-line flags, and storing state. + | 68 -> +# 942 "parsing/lexer.mll" + ( GREATERRBRACKET ) +# 2812 "parsing/lexer.ml" - {!mapper} allows to implement AST rewriting using open recursion. - A typical mapper would be based on {!default_mapper}, a deep - identity mapper, and will fall back on it for handling the syntax it - does not modify. For example: + | 69 -> +# 943 "parsing/lexer.mll" + ( RBRACE ) +# 2817 "parsing/lexer.ml" - {[ -open Asttypes -open Parsetree -open Ast_mapper + | 70 -> +# 944 "parsing/lexer.mll" + ( GREATERRBRACE ) +# 2822 "parsing/lexer.ml" -let test_mapper argv = - { default_mapper with - expr = fun mapper expr -> - match expr with - | { pexp_desc = Pexp_extension ({ txt = "test" }, PStr [])} -> - Ast_helper.Exp.constant (Const_int 42) - | other -> default_mapper.expr mapper other; } + | 71 -> +# 945 "parsing/lexer.mll" + ( LBRACKETAT ) +# 2827 "parsing/lexer.ml" -let () = - register "ppx_test" test_mapper]} + | 72 -> +# 946 "parsing/lexer.mll" + ( LBRACKETATAT ) +# 2832 "parsing/lexer.ml" - This -ppx rewriter, which replaces [[%test]] in expressions with - the constant [42], can be compiled using - [ocamlc -o ppx_test -I +compiler-libs ocamlcommon.cma ppx_test.ml]. + | 73 -> +# 947 "parsing/lexer.mll" + ( LBRACKETATATAT ) +# 2837 "parsing/lexer.ml" - *) + | 74 -> +# 948 "parsing/lexer.mll" + ( LBRACKETPERCENT ) +# 2842 "parsing/lexer.ml" -open Parsetree + | 75 -> +# 949 "parsing/lexer.mll" + ( LBRACKETPERCENTPERCENT ) +# 2847 "parsing/lexer.ml" -(** {1 A generic Parsetree mapper} *) + | 76 -> +# 950 "parsing/lexer.mll" + ( BANG ) +# 2852 "parsing/lexer.ml" -type mapper = { - attribute: mapper -> attribute -> attribute; - attributes: mapper -> attribute list -> attribute list; - case: mapper -> case -> case; - cases: mapper -> case list -> case list; - class_declaration: mapper -> class_declaration -> class_declaration; - class_description: mapper -> class_description -> class_description; - class_expr: mapper -> class_expr -> class_expr; - class_field: mapper -> class_field -> class_field; - class_signature: mapper -> class_signature -> class_signature; - class_structure: mapper -> class_structure -> class_structure; - class_type: mapper -> class_type -> class_type; - class_type_declaration: mapper -> class_type_declaration - -> class_type_declaration; - class_type_field: mapper -> class_type_field -> class_type_field; - constructor_declaration: mapper -> constructor_declaration - -> constructor_declaration; - expr: mapper -> expression -> expression; - extension: mapper -> extension -> extension; - extension_constructor: mapper -> extension_constructor - -> extension_constructor; - include_declaration: mapper -> include_declaration -> include_declaration; - include_description: mapper -> include_description -> include_description; - label_declaration: mapper -> label_declaration -> label_declaration; - location: mapper -> Location.t -> Location.t; - module_binding: mapper -> module_binding -> module_binding; - module_declaration: mapper -> module_declaration -> module_declaration; - module_expr: mapper -> module_expr -> module_expr; - module_type: mapper -> module_type -> module_type; - module_type_declaration: mapper -> module_type_declaration - -> module_type_declaration; - open_description: mapper -> open_description -> open_description; - pat: mapper -> pattern -> pattern; - payload: mapper -> payload -> payload; - signature: mapper -> signature -> signature; - signature_item: mapper -> signature_item -> signature_item; - structure: mapper -> structure -> structure; - structure_item: mapper -> structure_item -> structure_item; - typ: mapper -> core_type -> core_type; - type_declaration: mapper -> type_declaration -> type_declaration; - type_extension: mapper -> type_extension -> type_extension; - type_kind: mapper -> type_kind -> type_kind; - value_binding: mapper -> value_binding -> value_binding; - value_description: mapper -> value_description -> value_description; - with_constraint: mapper -> with_constraint -> with_constraint; -} -(** A mapper record implements one "method" per syntactic category, - using an open recursion style: each method takes as its first - argument the mapper to be applied to children in the syntax - tree. *) + | 77 -> +# 951 "parsing/lexer.mll" + ( INFIXOP0 "!=" ) +# 2857 "parsing/lexer.ml" -val default_mapper: mapper -(** A default mapper, which implements a "deep identity" mapping. *) + | 78 -> +# 952 "parsing/lexer.mll" + ( PLUS ) +# 2862 "parsing/lexer.ml" -(** {1 Apply mappers to compilation units} *) + | 79 -> +# 953 "parsing/lexer.mll" + ( PLUSDOT ) +# 2867 "parsing/lexer.ml" -val tool_name: unit -> string -(** Can be used within a ppx preprocessor to know which tool is - calling it ["ocamlc"], ["ocamlopt"], ["ocamldoc"], ["ocamldep"], - ["ocaml"], ... Some global variables that reflect command-line - options are automatically synchronized between the calling tool - and the ppx preprocessor: {!Clflags.include_dirs}, - {!Config.load_path}, {!Clflags.open_modules}, {!Clflags.for_package}, - {!Clflags.debug}. *) + | 80 -> +# 954 "parsing/lexer.mll" + ( PLUSEQ ) +# 2872 "parsing/lexer.ml" + | 81 -> +# 955 "parsing/lexer.mll" + ( MINUS ) +# 2877 "parsing/lexer.ml" -val apply: source:string -> target:string -> mapper -> unit -(** Apply a mapper (parametrized by the unit name) to a dumped - parsetree found in the [source] file and put the result in the - [target] file. The [structure] or [signature] field of the mapper - is applied to the implementation or interface. *) + | 82 -> +# 956 "parsing/lexer.mll" + ( MINUSDOT ) +# 2882 "parsing/lexer.ml" -val run_main: (string list -> mapper) -> unit -(** Entry point to call to implement a standalone -ppx rewriter from a - mapper, parametrized by the command line arguments. The current - unit name can be obtained from {!Location.input_name}. This - function implements proper error reporting for uncaught - exceptions. *) + | 83 -> +# 959 "parsing/lexer.mll" + ( PREFIXOP(Lexing.lexeme lexbuf) ) +# 2887 "parsing/lexer.ml" -(** {1 Registration API} *) + | 84 -> +# 961 "parsing/lexer.mll" + ( PREFIXOP(Lexing.lexeme lexbuf) ) +# 2892 "parsing/lexer.ml" -val register_function: (string -> (string list -> mapper) -> unit) ref + | 85 -> +# 963 "parsing/lexer.mll" + ( INFIXOP0(Lexing.lexeme lexbuf) ) +# 2897 "parsing/lexer.ml" -val register: string -> (string list -> mapper) -> unit -(** Apply the [register_function]. The default behavior is to run the - mapper immediately, taking arguments from the process command - line. This is to support a scenario where a mapper is linked as a - stand-alone executable. + | 86 -> +# 965 "parsing/lexer.mll" + ( INFIXOP1(Lexing.lexeme lexbuf) ) +# 2902 "parsing/lexer.ml" - It is possible to overwrite the [register_function] to define - "-ppx drivers", which combine several mappers in a single process. - Typically, a driver starts by defining [register_function] to a - custom implementation, then lets ppx rewriters (linked statically - or dynamically) register themselves, and then run all or some of - them. It is also possible to have -ppx drivers apply rewriters to - only specific parts of an AST. + | 87 -> +# 967 "parsing/lexer.mll" + ( INFIXOP2(Lexing.lexeme lexbuf) ) +# 2907 "parsing/lexer.ml" - The first argument to [register] is a symbolic name to be used by - the ppx driver. *) + | 88 -> +# 969 "parsing/lexer.mll" + ( INFIXOP4(Lexing.lexeme lexbuf) ) +# 2912 "parsing/lexer.ml" + | 89 -> +# 970 "parsing/lexer.mll" + ( PERCENT ) +# 2917 "parsing/lexer.ml" -(** {1 Convenience functions to write mappers} *) + | 90 -> +# 972 "parsing/lexer.mll" + ( INFIXOP3(Lexing.lexeme lexbuf) ) +# 2922 "parsing/lexer.ml" -val map_opt: ('a -> 'b) -> 'a option -> 'b option + | 91 -> +# 974 "parsing/lexer.mll" + ( HASHOP(Lexing.lexeme lexbuf) ) +# 2927 "parsing/lexer.ml" -val extension_of_error: Location.error -> extension -(** Encode an error into an 'ocaml.error' extension node which can be - inserted in a generated Parsetree. The compiler will be - responsible for reporting the error. *) + | 92 -> +# 975 "parsing/lexer.mll" + ( + if !if_then_else <> Dir_out then + if !if_then_else = Dir_if_true then + raise (Error (Unterminated_if, Location.curr lexbuf)) + else raise (Error(Unterminated_else, Location.curr lexbuf)) + else + EOF -val attribute_of_warning: Location.t -> string -> attribute -(** Encode a warning message into an 'ocaml.ppwarning' attribute which can be - inserted in a generated Parsetree. The compiler will be - responsible for reporting the warning. *) + ) +# 2940 "parsing/lexer.ml" -(** {1 Helper functions to call external mappers} *) + | 93 -> +# 985 "parsing/lexer.mll" + ( raise (Error(Illegal_character (Lexing.lexeme_char lexbuf 0), + Location.curr lexbuf)) + ) +# 2947 "parsing/lexer.ml" -val add_ppx_context_str: - tool_name:string -> Parsetree.structure -> Parsetree.structure -(** Extract information from the current environment and encode it - into an attribute which is prepended to the list of structure - items in order to pass the information to an external - processor. *) + | __ocaml_lex_state -> lexbuf.Lexing.refill_buff lexbuf; + __ocaml_lex_token_rec lexbuf __ocaml_lex_state -val add_ppx_context_sig: - tool_name:string -> Parsetree.signature -> Parsetree.signature -(** Same as [add_ppx_context_str], but for signatures. *) +and comment lexbuf = + __ocaml_lex_comment_rec lexbuf 143 +and __ocaml_lex_comment_rec lexbuf __ocaml_lex_state = + match Lexing.engine __ocaml_lex_tables __ocaml_lex_state lexbuf with + | 0 -> +# 991 "parsing/lexer.mll" + ( comment_start_loc := (Location.curr lexbuf) :: !comment_start_loc; + store_lexeme lexbuf; + comment lexbuf + ) +# 2962 "parsing/lexer.ml" -val drop_ppx_context_str: - restore:bool -> Parsetree.structure -> Parsetree.structure -(** Drop the ocaml.ppx.context attribute from a structure. If - [restore] is true, also restore the associated data in the current - process. *) + | 1 -> +# 996 "parsing/lexer.mll" + ( match !comment_start_loc with + | [] -> assert false + | [_] -> comment_start_loc := []; Location.curr lexbuf + | _ :: l -> comment_start_loc := l; + store_lexeme lexbuf; + comment lexbuf + ) +# 2973 "parsing/lexer.ml" -val drop_ppx_context_sig: - restore:bool -> Parsetree.signature -> Parsetree.signature -(** Same as [drop_ppx_context_str], but for signatures. *) + | 2 -> +# 1004 "parsing/lexer.mll" + ( + string_start_loc := Location.curr lexbuf; + store_string_char '\"'; + is_in_string := true; + begin try string lexbuf + with Error (Unterminated_string, str_start) -> + match !comment_start_loc with + | [] -> assert false + | loc :: _ -> + let start = List.hd (List.rev !comment_start_loc) in + comment_start_loc := []; + raise (Error (Unterminated_string_in_comment (start, str_start), + loc)) + end; + is_in_string := false; + store_string_char '\"'; + comment lexbuf ) +# 2994 "parsing/lexer.ml" -(** {1 Cookies} *) + | 3 -> +# 1022 "parsing/lexer.mll" + ( + let delim = Lexing.lexeme lexbuf in + let delim = String.sub delim 1 (String.length delim - 2) in + string_start_loc := Location.curr lexbuf; + store_lexeme lexbuf; + is_in_string := true; + begin try quoted_string delim lexbuf + with Error (Unterminated_string, str_start) -> + match !comment_start_loc with + | [] -> assert false + | loc :: _ -> + let start = List.hd (List.rev !comment_start_loc) in + comment_start_loc := []; + raise (Error (Unterminated_string_in_comment (start, str_start), + loc)) + end; + is_in_string := false; + store_string_char '|'; + store_string delim; + store_string_char '}'; + comment lexbuf ) +# 3019 "parsing/lexer.ml" -(** Cookies are used to pass information from a ppx processor to - a further invocation of itself, when called from the OCaml - toplevel (or other tools that support cookies). *) + | 4 -> +# 1045 "parsing/lexer.mll" + ( store_lexeme lexbuf; comment lexbuf ) +# 3024 "parsing/lexer.ml" -val set_cookie: string -> Parsetree.expression -> unit -val get_cookie: string -> Parsetree.expression option + | 5 -> +# 1047 "parsing/lexer.mll" + ( update_loc lexbuf None 1 false 1; + store_lexeme lexbuf; + comment lexbuf + ) +# 3032 "parsing/lexer.ml" -end = struct -#1 "ast_mapper.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Alain Frisch, LexiFi *) -(* *) -(* Copyright 2012 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) + | 6 -> +# 1052 "parsing/lexer.mll" + ( store_lexeme lexbuf; comment lexbuf ) +# 3037 "parsing/lexer.ml" -(* A generic Parsetree mapping class *) + | 7 -> +# 1054 "parsing/lexer.mll" + ( store_lexeme lexbuf; comment lexbuf ) +# 3042 "parsing/lexer.ml" -(* -[@@@ocaml.warning "+9"] - (* Ensure that record patterns don't miss any field. *) -*) + | 8 -> +# 1056 "parsing/lexer.mll" + ( store_lexeme lexbuf; comment lexbuf ) +# 3047 "parsing/lexer.ml" + | 9 -> +# 1058 "parsing/lexer.mll" + ( store_lexeme lexbuf; comment lexbuf ) +# 3052 "parsing/lexer.ml" -open Parsetree -open Ast_helper -open Location + | 10 -> +# 1060 "parsing/lexer.mll" + ( match !comment_start_loc with + | [] -> assert false + | loc :: _ -> + let start = List.hd (List.rev !comment_start_loc) in + comment_start_loc := []; + raise (Error (Unterminated_comment start, loc)) + ) +# 3063 "parsing/lexer.ml" -type mapper = { - attribute: mapper -> attribute -> attribute; - attributes: mapper -> attribute list -> attribute list; - case: mapper -> case -> case; - cases: mapper -> case list -> case list; - class_declaration: mapper -> class_declaration -> class_declaration; - class_description: mapper -> class_description -> class_description; - class_expr: mapper -> class_expr -> class_expr; - class_field: mapper -> class_field -> class_field; - class_signature: mapper -> class_signature -> class_signature; - class_structure: mapper -> class_structure -> class_structure; - class_type: mapper -> class_type -> class_type; - class_type_declaration: mapper -> class_type_declaration - -> class_type_declaration; - class_type_field: mapper -> class_type_field -> class_type_field; - constructor_declaration: mapper -> constructor_declaration - -> constructor_declaration; - expr: mapper -> expression -> expression; - extension: mapper -> extension -> extension; - extension_constructor: mapper -> extension_constructor - -> extension_constructor; - include_declaration: mapper -> include_declaration -> include_declaration; - include_description: mapper -> include_description -> include_description; - label_declaration: mapper -> label_declaration -> label_declaration; - location: mapper -> Location.t -> Location.t; - module_binding: mapper -> module_binding -> module_binding; - module_declaration: mapper -> module_declaration -> module_declaration; - module_expr: mapper -> module_expr -> module_expr; - module_type: mapper -> module_type -> module_type; - module_type_declaration: mapper -> module_type_declaration - -> module_type_declaration; - open_description: mapper -> open_description -> open_description; - pat: mapper -> pattern -> pattern; - payload: mapper -> payload -> payload; - signature: mapper -> signature -> signature; - signature_item: mapper -> signature_item -> signature_item; - structure: mapper -> structure -> structure; - structure_item: mapper -> structure_item -> structure_item; - typ: mapper -> core_type -> core_type; - type_declaration: mapper -> type_declaration -> type_declaration; - type_extension: mapper -> type_extension -> type_extension; - type_kind: mapper -> type_kind -> type_kind; - value_binding: mapper -> value_binding -> value_binding; - value_description: mapper -> value_description -> value_description; - with_constraint: mapper -> with_constraint -> with_constraint; -} + | 11 -> +# 1068 "parsing/lexer.mll" + ( update_loc lexbuf None 1 false 0; + store_lexeme lexbuf; + comment lexbuf + ) +# 3071 "parsing/lexer.ml" -let map_fst f (x, y) = (f x, y) -let map_snd f (x, y) = (x, f y) -let map_tuple f1 f2 (x, y) = (f1 x, f2 y) -let map_tuple3 f1 f2 f3 (x, y, z) = (f1 x, f2 y, f3 z) -let map_opt f = function None -> None | Some x -> Some (f x) + | 12 -> +# 1073 "parsing/lexer.mll" + ( store_lexeme lexbuf; comment lexbuf ) +# 3076 "parsing/lexer.ml" -let map_loc sub {loc; txt} = {loc = sub.location sub loc; txt} + | __ocaml_lex_state -> lexbuf.Lexing.refill_buff lexbuf; + __ocaml_lex_comment_rec lexbuf __ocaml_lex_state -module T = struct - (* Type expressions for the core language *) +and string lexbuf = + lexbuf.Lexing.lex_mem <- Array.make 2 (-1); __ocaml_lex_string_rec lexbuf 175 +and __ocaml_lex_string_rec lexbuf __ocaml_lex_state = + match Lexing.new_engine __ocaml_lex_tables __ocaml_lex_state lexbuf with + | 0 -> +# 1077 "parsing/lexer.mll" + ( () ) +# 3088 "parsing/lexer.ml" - let row_field sub = function - | Rtag (l, attrs, b, tl) -> - Rtag (map_loc sub l, sub.attributes sub attrs, - b, List.map (sub.typ sub) tl) - | Rinherit t -> Rinherit (sub.typ sub t) + | 1 -> +let +# 1078 "parsing/lexer.mll" + space +# 3094 "parsing/lexer.ml" += Lexing.sub_lexeme lexbuf lexbuf.Lexing.lex_mem.(0) lexbuf.Lexing.lex_curr_pos in +# 1079 "parsing/lexer.mll" + ( update_loc lexbuf None 1 false (String.length space); + if in_comment () then store_lexeme lexbuf; + string lexbuf + ) +# 3101 "parsing/lexer.ml" - let object_field sub = function - | Otag (l, attrs, t) -> - Otag (map_loc sub l, sub.attributes sub attrs, sub.typ sub t) - | Oinherit t -> Oinherit (sub.typ sub t) + | 2 -> +# 1084 "parsing/lexer.mll" + ( store_escaped_char lexbuf + (char_for_backslash(Lexing.lexeme_char lexbuf 1)); + string lexbuf ) +# 3108 "parsing/lexer.ml" - let map sub {ptyp_desc = desc; ptyp_loc = loc; ptyp_attributes = attrs} = - let open Typ in - let loc = sub.location sub loc in - let attrs = sub.attributes sub attrs in - match desc with - | Ptyp_any -> any ~loc ~attrs () - | Ptyp_var s -> var ~loc ~attrs s - | Ptyp_arrow (lab, t1, t2) -> - arrow ~loc ~attrs lab (sub.typ sub t1) (sub.typ sub t2) - | Ptyp_tuple tyl -> tuple ~loc ~attrs (List.map (sub.typ sub) tyl) - | Ptyp_constr (lid, tl) -> - constr ~loc ~attrs (map_loc sub lid) (List.map (sub.typ sub) tl) - | Ptyp_object (l, o) -> - object_ ~loc ~attrs (List.map (object_field sub) l) o - | Ptyp_class (lid, tl) -> - class_ ~loc ~attrs (map_loc sub lid) (List.map (sub.typ sub) tl) - | Ptyp_alias (t, s) -> alias ~loc ~attrs (sub.typ sub t) s - | Ptyp_variant (rl, b, ll) -> - variant ~loc ~attrs (List.map (row_field sub) rl) b ll - | Ptyp_poly (sl, t) -> poly ~loc ~attrs - (List.map (map_loc sub) sl) (sub.typ sub t) - | Ptyp_package (lid, l) -> - package ~loc ~attrs (map_loc sub lid) - (List.map (map_tuple (map_loc sub) (sub.typ sub)) l) - | Ptyp_extension x -> extension ~loc ~attrs (sub.extension sub x) + | 3 -> +# 1088 "parsing/lexer.mll" + ( store_escaped_char lexbuf (char_for_decimal_code lexbuf 1); + string lexbuf ) +# 3114 "parsing/lexer.ml" - let map_type_declaration sub - {ptype_name; ptype_params; ptype_cstrs; - ptype_kind; - ptype_private; - ptype_manifest; - ptype_attributes; - ptype_loc} = - Type.mk (map_loc sub ptype_name) - ~params:(List.map (map_fst (sub.typ sub)) ptype_params) - ~priv:ptype_private - ~cstrs:(List.map - (map_tuple3 (sub.typ sub) (sub.typ sub) (sub.location sub)) - ptype_cstrs) - ~kind:(sub.type_kind sub ptype_kind) - ?manifest:(map_opt (sub.typ sub) ptype_manifest) - ~loc:(sub.location sub ptype_loc) - ~attrs:(sub.attributes sub ptype_attributes) + | 4 -> +# 1091 "parsing/lexer.mll" + ( store_escaped_char lexbuf (char_for_octal_code lexbuf 2); + string lexbuf ) +# 3120 "parsing/lexer.ml" - let map_type_kind sub = function - | Ptype_abstract -> Ptype_abstract - | Ptype_variant l -> - Ptype_variant (List.map (sub.constructor_declaration sub) l) - | Ptype_record l -> Ptype_record (List.map (sub.label_declaration sub) l) - | Ptype_open -> Ptype_open + | 5 -> +# 1094 "parsing/lexer.mll" + ( store_escaped_char lexbuf (char_for_hexadecimal_code lexbuf 2); + string lexbuf ) +# 3126 "parsing/lexer.ml" - let map_constructor_arguments sub = function - | Pcstr_tuple l -> Pcstr_tuple (List.map (sub.typ sub) l) - | Pcstr_record l -> - Pcstr_record (List.map (sub.label_declaration sub) l) + | 6 -> +# 1097 "parsing/lexer.mll" + ( store_escaped_uchar lexbuf (uchar_for_uchar_escape lexbuf); + string lexbuf ) +# 3132 "parsing/lexer.ml" - let map_type_extension sub - {ptyext_path; ptyext_params; - ptyext_constructors; - ptyext_private; - ptyext_attributes} = - Te.mk - (map_loc sub ptyext_path) - (List.map (sub.extension_constructor sub) ptyext_constructors) - ~params:(List.map (map_fst (sub.typ sub)) ptyext_params) - ~priv:ptyext_private - ~attrs:(sub.attributes sub ptyext_attributes) + | 7 -> +# 1100 "parsing/lexer.mll" + ( if not (in_comment ()) then begin +(* Should be an error, but we are very lax. + raise (Error (Illegal_escape (Lexing.lexeme lexbuf), + Location.curr lexbuf)) +*) + let loc = Location.curr lexbuf in + Location.prerr_warning loc Warnings.Illegal_backslash; + end; + store_lexeme lexbuf; + string lexbuf + ) +# 3147 "parsing/lexer.ml" - let map_extension_constructor_kind sub = function - Pext_decl(ctl, cto) -> - Pext_decl(map_constructor_arguments sub ctl, map_opt (sub.typ sub) cto) - | Pext_rebind li -> - Pext_rebind (map_loc sub li) + | 8 -> +# 1112 "parsing/lexer.mll" + ( if not (in_comment ()) then + Location.prerr_warning (Location.curr lexbuf) Warnings.Eol_in_string; + update_loc lexbuf None 1 false 0; + store_lexeme lexbuf; + string lexbuf + ) +# 3157 "parsing/lexer.ml" - let map_extension_constructor sub - {pext_name; - pext_kind; - pext_loc; - pext_attributes} = - Te.constructor - (map_loc sub pext_name) - (map_extension_constructor_kind sub pext_kind) - ~loc:(sub.location sub pext_loc) - ~attrs:(sub.attributes sub pext_attributes) + | 9 -> +# 1119 "parsing/lexer.mll" + ( is_in_string := false; + raise (Error (Unterminated_string, !string_start_loc)) ) +# 3163 "parsing/lexer.ml" -end + | 10 -> +# 1122 "parsing/lexer.mll" + ( store_string_char(Lexing.lexeme_char lexbuf 0); + string lexbuf ) +# 3169 "parsing/lexer.ml" + + | __ocaml_lex_state -> lexbuf.Lexing.refill_buff lexbuf; + __ocaml_lex_string_rec lexbuf __ocaml_lex_state + +and quoted_string delim lexbuf = + __ocaml_lex_quoted_string_rec delim lexbuf 202 +and __ocaml_lex_quoted_string_rec delim lexbuf __ocaml_lex_state = + match Lexing.engine __ocaml_lex_tables __ocaml_lex_state lexbuf with + | 0 -> +# 1127 "parsing/lexer.mll" + ( update_loc lexbuf None 1 false 0; + store_lexeme lexbuf; + quoted_string delim lexbuf + ) +# 3184 "parsing/lexer.ml" -module CT = struct - (* Type expressions for the class language *) + | 1 -> +# 1132 "parsing/lexer.mll" + ( is_in_string := false; + raise (Error (Unterminated_string, !string_start_loc)) ) +# 3190 "parsing/lexer.ml" - let map sub {pcty_loc = loc; pcty_desc = desc; pcty_attributes = attrs} = - let open Cty in - let loc = sub.location sub loc in - let attrs = sub.attributes sub attrs in - match desc with - | Pcty_constr (lid, tys) -> - constr ~loc ~attrs (map_loc sub lid) (List.map (sub.typ sub) tys) - | Pcty_signature x -> signature ~loc ~attrs (sub.class_signature sub x) - | Pcty_arrow (lab, t, ct) -> - arrow ~loc ~attrs lab (sub.typ sub t) (sub.class_type sub ct) - | Pcty_extension x -> extension ~loc ~attrs (sub.extension sub x) - | Pcty_open (ovf, lid, ct) -> - open_ ~loc ~attrs ovf (map_loc sub lid) (sub.class_type sub ct) + | 2 -> +# 1135 "parsing/lexer.mll" + ( + let edelim = Lexing.lexeme lexbuf in + let edelim = String.sub edelim 1 (String.length edelim - 2) in + if delim = edelim then () + else (store_lexeme lexbuf; quoted_string delim lexbuf) + ) +# 3200 "parsing/lexer.ml" - let map_field sub {pctf_desc = desc; pctf_loc = loc; pctf_attributes = attrs} - = - let open Ctf in - let loc = sub.location sub loc in - let attrs = sub.attributes sub attrs in - match desc with - | Pctf_inherit ct -> inherit_ ~loc ~attrs (sub.class_type sub ct) - | Pctf_val (s, m, v, t) -> - val_ ~loc ~attrs (map_loc sub s) m v (sub.typ sub t) - | Pctf_method (s, p, v, t) -> - method_ ~loc ~attrs (map_loc sub s) p v (sub.typ sub t) - | Pctf_constraint (t1, t2) -> - constraint_ ~loc ~attrs (sub.typ sub t1) (sub.typ sub t2) - | Pctf_attribute x -> attribute ~loc (sub.attribute sub x) - | Pctf_extension x -> extension ~loc ~attrs (sub.extension sub x) + | 3 -> +# 1142 "parsing/lexer.mll" + ( store_string_char(Lexing.lexeme_char lexbuf 0); + quoted_string delim lexbuf ) +# 3206 "parsing/lexer.ml" - let map_signature sub {pcsig_self; pcsig_fields} = - Csig.mk - (sub.typ sub pcsig_self) - (List.map (sub.class_type_field sub) pcsig_fields) -end + | __ocaml_lex_state -> lexbuf.Lexing.refill_buff lexbuf; + __ocaml_lex_quoted_string_rec delim lexbuf __ocaml_lex_state -module MT = struct - (* Type expressions for the module language *) +and skip_hash_bang lexbuf = + __ocaml_lex_skip_hash_bang_rec lexbuf 211 +and __ocaml_lex_skip_hash_bang_rec lexbuf __ocaml_lex_state = + match Lexing.engine __ocaml_lex_tables __ocaml_lex_state lexbuf with + | 0 -> +# 1147 "parsing/lexer.mll" + ( update_loc lexbuf None 3 false 0 ) +# 3218 "parsing/lexer.ml" - let map sub {pmty_desc = desc; pmty_loc = loc; pmty_attributes = attrs} = - let open Mty in - let loc = sub.location sub loc in - let attrs = sub.attributes sub attrs in - match desc with - | Pmty_ident s -> ident ~loc ~attrs (map_loc sub s) - | Pmty_alias s -> alias ~loc ~attrs (map_loc sub s) - | Pmty_signature sg -> signature ~loc ~attrs (sub.signature sub sg) - | Pmty_functor (s, mt1, mt2) -> - functor_ ~loc ~attrs (map_loc sub s) - (Misc.may_map (sub.module_type sub) mt1) - (sub.module_type sub mt2) - | Pmty_with (mt, l) -> - with_ ~loc ~attrs (sub.module_type sub mt) - (List.map (sub.with_constraint sub) l) - | Pmty_typeof me -> typeof_ ~loc ~attrs (sub.module_expr sub me) - | Pmty_extension x -> extension ~loc ~attrs (sub.extension sub x) + | 1 -> +# 1149 "parsing/lexer.mll" + ( update_loc lexbuf None 1 false 0 ) +# 3223 "parsing/lexer.ml" - let map_with_constraint sub = function - | Pwith_type (lid, d) -> - Pwith_type (map_loc sub lid, sub.type_declaration sub d) - | Pwith_module (lid, lid2) -> - Pwith_module (map_loc sub lid, map_loc sub lid2) - | Pwith_typesubst (lid, d) -> - Pwith_typesubst (map_loc sub lid, sub.type_declaration sub d) - | Pwith_modsubst (s, lid) -> - Pwith_modsubst (map_loc sub s, map_loc sub lid) + | 2 -> +# 1150 "parsing/lexer.mll" + ( () ) +# 3228 "parsing/lexer.ml" - let map_signature_item sub {psig_desc = desc; psig_loc = loc} = - let open Sig in - let loc = sub.location sub loc in - match desc with - | Psig_value vd -> value ~loc (sub.value_description sub vd) - | Psig_type (rf, l) -> type_ ~loc rf (List.map (sub.type_declaration sub) l) - | Psig_typext te -> type_extension ~loc (sub.type_extension sub te) - | Psig_exception ed -> exception_ ~loc (sub.extension_constructor sub ed) - | Psig_module x -> module_ ~loc (sub.module_declaration sub x) - | Psig_recmodule l -> - rec_module ~loc (List.map (sub.module_declaration sub) l) - | Psig_modtype x -> modtype ~loc (sub.module_type_declaration sub x) - | Psig_open x -> open_ ~loc (sub.open_description sub x) - | Psig_include x -> include_ ~loc (sub.include_description sub x) - | Psig_class l -> class_ ~loc (List.map (sub.class_description sub) l) - | Psig_class_type l -> - class_type ~loc (List.map (sub.class_type_declaration sub) l) - | Psig_extension (x, attrs) -> - extension ~loc (sub.extension sub x) ~attrs:(sub.attributes sub attrs) - | Psig_attribute x -> attribute ~loc (sub.attribute sub x) -end + | __ocaml_lex_state -> lexbuf.Lexing.refill_buff lexbuf; + __ocaml_lex_skip_hash_bang_rec lexbuf __ocaml_lex_state +;; -module M = struct - (* Value expressions for the module language *) +# 1152 "parsing/lexer.mll" + + let at_bol lexbuf = + let pos = Lexing.lexeme_start_p lexbuf in + pos.pos_cnum = pos.pos_bol - let map sub {pmod_loc = loc; pmod_desc = desc; pmod_attributes = attrs} = - let open Mod in - let loc = sub.location sub loc in - let attrs = sub.attributes sub attrs in - match desc with - | Pmod_ident x -> ident ~loc ~attrs (map_loc sub x) - | Pmod_structure str -> structure ~loc ~attrs (sub.structure sub str) - | Pmod_functor (arg, arg_ty, body) -> - functor_ ~loc ~attrs (map_loc sub arg) - (Misc.may_map (sub.module_type sub) arg_ty) - (sub.module_expr sub body) - | Pmod_apply (m1, m2) -> - apply ~loc ~attrs (sub.module_expr sub m1) (sub.module_expr sub m2) - | Pmod_constraint (m, mty) -> - constraint_ ~loc ~attrs (sub.module_expr sub m) - (sub.module_type sub mty) - | Pmod_unpack e -> unpack ~loc ~attrs (sub.expr sub e) - | Pmod_extension x -> extension ~loc ~attrs (sub.extension sub x) + let token_with_comments lexbuf = + match !preprocessor with + | None -> token lexbuf + | Some (_init, preprocess) -> preprocess token lexbuf - let map_structure_item sub {pstr_loc = loc; pstr_desc = desc} = - let open Str in - let loc = sub.location sub loc in - match desc with - | Pstr_eval (x, attrs) -> - eval ~loc ~attrs:(sub.attributes sub attrs) (sub.expr sub x) - | Pstr_value (r, vbs) -> value ~loc r (List.map (sub.value_binding sub) vbs) - | Pstr_primitive vd -> primitive ~loc (sub.value_description sub vd) - | Pstr_type (rf, l) -> type_ ~loc rf (List.map (sub.type_declaration sub) l) - | Pstr_typext te -> type_extension ~loc (sub.type_extension sub te) - | Pstr_exception ed -> exception_ ~loc (sub.extension_constructor sub ed) - | Pstr_module x -> module_ ~loc (sub.module_binding sub x) - | Pstr_recmodule l -> rec_module ~loc (List.map (sub.module_binding sub) l) - | Pstr_modtype x -> modtype ~loc (sub.module_type_declaration sub x) - | Pstr_open x -> open_ ~loc (sub.open_description sub x) - | Pstr_class l -> class_ ~loc (List.map (sub.class_declaration sub) l) - | Pstr_class_type l -> - class_type ~loc (List.map (sub.class_type_declaration sub) l) - | Pstr_include x -> include_ ~loc (sub.include_declaration sub x) - | Pstr_extension (x, attrs) -> - extension ~loc (sub.extension sub x) ~attrs:(sub.attributes sub attrs) - | Pstr_attribute x -> attribute ~loc (sub.attribute sub x) -end + type newline_state = + | NoLine (* There have been no blank lines yet. *) + | NewLine + (* There have been no blank lines, and the previous + token was a newline. *) + | BlankLine (* There have been blank lines. *) -module E = struct - (* Value expressions for the core language *) + type doc_state = + | Initial (* There have been no docstrings yet *) + | After of docstring list + (* There have been docstrings, none of which were + preceded by a blank line *) + | Before of docstring list * docstring list * docstring list + (* There have been docstrings, some of which were + preceded by a blank line *) - let map sub {pexp_loc = loc; pexp_desc = desc; pexp_attributes = attrs} = - let open Exp in - let loc = sub.location sub loc in - let attrs = sub.attributes sub attrs in - match desc with - | Pexp_ident x -> ident ~loc ~attrs (map_loc sub x) - | Pexp_constant x -> constant ~loc ~attrs x - | Pexp_let (r, vbs, e) -> - let_ ~loc ~attrs r (List.map (sub.value_binding sub) vbs) - (sub.expr sub e) - | Pexp_fun (lab, def, p, e) -> - fun_ ~loc ~attrs lab (map_opt (sub.expr sub) def) (sub.pat sub p) - (sub.expr sub e) - | Pexp_function pel -> function_ ~loc ~attrs (sub.cases sub pel) - | Pexp_apply (e, l) -> - apply ~loc ~attrs (sub.expr sub e) (List.map (map_snd (sub.expr sub)) l) - | Pexp_match (e, pel) -> - match_ ~loc ~attrs (sub.expr sub e) (sub.cases sub pel) - | Pexp_try (e, pel) -> try_ ~loc ~attrs (sub.expr sub e) (sub.cases sub pel) - | Pexp_tuple el -> tuple ~loc ~attrs (List.map (sub.expr sub) el) - | Pexp_construct (lid, arg) -> - construct ~loc ~attrs (map_loc sub lid) (map_opt (sub.expr sub) arg) - | Pexp_variant (lab, eo) -> - variant ~loc ~attrs lab (map_opt (sub.expr sub) eo) - | Pexp_record (l, eo) -> - record ~loc ~attrs (List.map (map_tuple (map_loc sub) (sub.expr sub)) l) - (map_opt (sub.expr sub) eo) - | Pexp_field (e, lid) -> - field ~loc ~attrs (sub.expr sub e) (map_loc sub lid) - | Pexp_setfield (e1, lid, e2) -> - setfield ~loc ~attrs (sub.expr sub e1) (map_loc sub lid) - (sub.expr sub e2) - | Pexp_array el -> array ~loc ~attrs (List.map (sub.expr sub) el) - | Pexp_ifthenelse (e1, e2, e3) -> - ifthenelse ~loc ~attrs (sub.expr sub e1) (sub.expr sub e2) - (map_opt (sub.expr sub) e3) - | Pexp_sequence (e1, e2) -> - sequence ~loc ~attrs (sub.expr sub e1) (sub.expr sub e2) - | Pexp_while (e1, e2) -> - while_ ~loc ~attrs (sub.expr sub e1) (sub.expr sub e2) - | Pexp_for (p, e1, e2, d, e3) -> - for_ ~loc ~attrs (sub.pat sub p) (sub.expr sub e1) (sub.expr sub e2) d - (sub.expr sub e3) - | Pexp_coerce (e, t1, t2) -> - coerce ~loc ~attrs (sub.expr sub e) (map_opt (sub.typ sub) t1) - (sub.typ sub t2) - | Pexp_constraint (e, t) -> - constraint_ ~loc ~attrs (sub.expr sub e) (sub.typ sub t) - | Pexp_send (e, s) -> - send ~loc ~attrs (sub.expr sub e) (map_loc sub s) - | Pexp_new lid -> new_ ~loc ~attrs (map_loc sub lid) - | Pexp_setinstvar (s, e) -> - setinstvar ~loc ~attrs (map_loc sub s) (sub.expr sub e) - | Pexp_override sel -> - override ~loc ~attrs - (List.map (map_tuple (map_loc sub) (sub.expr sub)) sel) - | Pexp_letmodule (s, me, e) -> - letmodule ~loc ~attrs (map_loc sub s) (sub.module_expr sub me) - (sub.expr sub e) - | Pexp_letexception (cd, e) -> - letexception ~loc ~attrs - (sub.extension_constructor sub cd) - (sub.expr sub e) - | Pexp_assert e -> assert_ ~loc ~attrs (sub.expr sub e) - | Pexp_lazy e -> lazy_ ~loc ~attrs (sub.expr sub e) - | Pexp_poly (e, t) -> - poly ~loc ~attrs (sub.expr sub e) (map_opt (sub.typ sub) t) - | Pexp_object cls -> object_ ~loc ~attrs (sub.class_structure sub cls) - | Pexp_newtype (s, e) -> - newtype ~loc ~attrs (map_loc sub s) (sub.expr sub e) - | Pexp_pack me -> pack ~loc ~attrs (sub.module_expr sub me) - | Pexp_open (ovf, lid, e) -> - open_ ~loc ~attrs ovf (map_loc sub lid) (sub.expr sub e) - | Pexp_extension x -> extension ~loc ~attrs (sub.extension sub x) - | Pexp_unreachable -> unreachable ~loc ~attrs () -end + and docstring = Docstrings.docstring -module P = struct - (* Patterns *) + let interpret_directive lexbuf cont look_ahead = + let if_then_else = !if_then_else in + begin match token_with_comments lexbuf, if_then_else with + | IF, Dir_out -> + let rec skip_from_if_false () = + let token = token_with_comments lexbuf in + if token = EOF then + raise (Error (Unterminated_if, Location.curr lexbuf)) else + if token = HASH && at_bol lexbuf then + begin + let token = token_with_comments lexbuf in + match token with + | END -> + begin + update_if_then_else Dir_out; + cont lexbuf + end + | ELSE -> + begin + update_if_then_else Dir_if_false; + cont lexbuf + end + | IF -> + raise (Error (Unexpected_directive, Location.curr lexbuf)) + | _ -> + if is_elif token && + directive_parse token_with_comments lexbuf then + begin + update_if_then_else Dir_if_true; + cont lexbuf + end + else skip_from_if_false () + end + else skip_from_if_false () in + if directive_parse token_with_comments lexbuf then + begin + update_if_then_else Dir_if_true (* Next state: ELSE *); + cont lexbuf + end + else + skip_from_if_false () + | IF, (Dir_if_false | Dir_if_true)-> + raise (Error(Unexpected_directive, Location.curr lexbuf)) + | LIDENT "elif", (Dir_if_false | Dir_out) + -> (* when the predicate is false, it will continue eating `elif` *) + raise (Error(Unexpected_directive, Location.curr lexbuf)) + | (LIDENT "elif" | ELSE as token), Dir_if_true -> + (* looking for #end, however, it can not see #if anymore *) + let rec skip_from_if_true else_seen = + let token = token_with_comments lexbuf in + if token = EOF then + raise (Error (Unterminated_else, Location.curr lexbuf)) else + if token = HASH && at_bol lexbuf then + begin + let token = token_with_comments lexbuf in + match token with + | END -> + begin + update_if_then_else Dir_out; + cont lexbuf + end + | IF -> + raise (Error (Unexpected_directive, Location.curr lexbuf)) + | ELSE -> + if else_seen then + raise (Error (Unexpected_directive, Location.curr lexbuf)) + else + skip_from_if_true true + | _ -> + if else_seen && is_elif token then + raise (Error (Unexpected_directive, Location.curr lexbuf)) + else + skip_from_if_true else_seen + end + else skip_from_if_true else_seen in + skip_from_if_true (token = ELSE) + | ELSE, Dir_if_false + | ELSE, Dir_out -> + raise (Error(Unexpected_directive, Location.curr lexbuf)) + | END, (Dir_if_false | Dir_if_true ) -> + update_if_then_else Dir_out; + cont lexbuf + | END, Dir_out -> + raise (Error(Unexpected_directive, Location.curr lexbuf)) + | token, (Dir_if_true | Dir_if_false | Dir_out) -> + look_ahead token + end - let map sub {ppat_desc = desc; ppat_loc = loc; ppat_attributes = attrs} = - let open Pat in - let loc = sub.location sub loc in - let attrs = sub.attributes sub attrs in - match desc with - | Ppat_any -> any ~loc ~attrs () - | Ppat_var s -> var ~loc ~attrs (map_loc sub s) - | Ppat_alias (p, s) -> alias ~loc ~attrs (sub.pat sub p) (map_loc sub s) - | Ppat_constant c -> constant ~loc ~attrs c - | Ppat_interval (c1, c2) -> interval ~loc ~attrs c1 c2 - | Ppat_tuple pl -> tuple ~loc ~attrs (List.map (sub.pat sub) pl) - | Ppat_construct (l, p) -> - construct ~loc ~attrs (map_loc sub l) (map_opt (sub.pat sub) p) - | Ppat_variant (l, p) -> variant ~loc ~attrs l (map_opt (sub.pat sub) p) - | Ppat_record (lpl, cf) -> - record ~loc ~attrs - (List.map (map_tuple (map_loc sub) (sub.pat sub)) lpl) cf - | Ppat_array pl -> array ~loc ~attrs (List.map (sub.pat sub) pl) - | Ppat_or (p1, p2) -> or_ ~loc ~attrs (sub.pat sub p1) (sub.pat sub p2) - | Ppat_constraint (p, t) -> - constraint_ ~loc ~attrs (sub.pat sub p) (sub.typ sub t) - | Ppat_type s -> type_ ~loc ~attrs (map_loc sub s) - | Ppat_lazy p -> lazy_ ~loc ~attrs (sub.pat sub p) - | Ppat_unpack s -> unpack ~loc ~attrs (map_loc sub s) - | Ppat_open (lid,p) -> open_ ~loc ~attrs (map_loc sub lid) (sub.pat sub p) - | Ppat_exception p -> exception_ ~loc ~attrs (sub.pat sub p) - | Ppat_extension x -> extension ~loc ~attrs (sub.extension sub x) -end + let token lexbuf = + let post_pos = lexeme_end_p lexbuf in + let attach lines docs pre_pos = + let open Docstrings in + match docs, lines with + | Initial, _ -> () + | After a, (NoLine | NewLine) -> + set_post_docstrings post_pos (List.rev a); + set_pre_docstrings pre_pos a; + | After a, BlankLine -> + set_post_docstrings post_pos (List.rev a); + set_pre_extra_docstrings pre_pos (List.rev a) + | Before(a, f, b), (NoLine | NewLine) -> + set_post_docstrings post_pos (List.rev a); + set_post_extra_docstrings post_pos + (List.rev_append f (List.rev b)); + set_floating_docstrings pre_pos (List.rev f); + set_pre_extra_docstrings pre_pos (List.rev a); + set_pre_docstrings pre_pos b + | Before(a, f, b), BlankLine -> + set_post_docstrings post_pos (List.rev a); + set_post_extra_docstrings post_pos + (List.rev_append f (List.rev b)); + set_floating_docstrings pre_pos + (List.rev_append f (List.rev b)); + set_pre_extra_docstrings pre_pos (List.rev a) + in + let rec loop lines docs lexbuf = + match token_with_comments lexbuf with + | COMMENT (s, loc) -> + add_comment (s, loc); + let lines' = + match lines with + | NoLine -> NoLine + | NewLine -> NoLine + | BlankLine -> BlankLine + in + loop lines' docs lexbuf + | EOL -> + let lines' = + match lines with + | NoLine -> NewLine + | NewLine -> BlankLine + | BlankLine -> BlankLine + in + loop lines' docs lexbuf + | HASH when at_bol lexbuf -> + interpret_directive lexbuf + (fun lexbuf -> loop lines docs lexbuf) + (fun token -> sharp_look_ahead := Some token; HASH) + | DOCSTRING doc -> + Docstrings.register doc; + add_docstring_comment doc; + let docs' = + if Docstrings.docstring_body doc = "/*" then + match docs with + | Initial -> Before([], [doc], []) + | After a -> Before (a, [doc], []) + | Before(a, f, b) -> Before(a, doc :: b @ f, []) + else + match docs, lines with + | Initial, (NoLine | NewLine) -> After [doc] + | Initial, BlankLine -> Before([], [], [doc]) + | After a, (NoLine | NewLine) -> After (doc :: a) + | After a, BlankLine -> Before (a, [], [doc]) + | Before(a, f, b), (NoLine | NewLine) -> Before(a, f, doc :: b) + | Before(a, f, b), BlankLine -> Before(a, b @ f, [doc]) + in + loop NoLine docs' lexbuf + | tok -> + attach lines docs (lexeme_start_p lexbuf); + tok + in + match !sharp_look_ahead with + | None -> + loop NoLine Initial lexbuf + | Some token -> + sharp_look_ahead := None ; + token -module CE = struct - (* Value expressions for the class language *) + let init () = + sharp_look_ahead := None; + update_if_then_else Dir_out; + is_in_string := false; + comment_start_loc := []; + comment_list := []; + match !preprocessor with + | None -> () + | Some (init, _preprocess) -> init () - let map sub {pcl_loc = loc; pcl_desc = desc; pcl_attributes = attrs} = - let open Cl in - let loc = sub.location sub loc in - let attrs = sub.attributes sub attrs in - match desc with - | Pcl_constr (lid, tys) -> - constr ~loc ~attrs (map_loc sub lid) (List.map (sub.typ sub) tys) - | Pcl_structure s -> - structure ~loc ~attrs (sub.class_structure sub s) - | Pcl_fun (lab, e, p, ce) -> - fun_ ~loc ~attrs lab - (map_opt (sub.expr sub) e) - (sub.pat sub p) - (sub.class_expr sub ce) - | Pcl_apply (ce, l) -> - apply ~loc ~attrs (sub.class_expr sub ce) - (List.map (map_snd (sub.expr sub)) l) - | Pcl_let (r, vbs, ce) -> - let_ ~loc ~attrs r (List.map (sub.value_binding sub) vbs) - (sub.class_expr sub ce) - | Pcl_constraint (ce, ct) -> - constraint_ ~loc ~attrs (sub.class_expr sub ce) (sub.class_type sub ct) - | Pcl_extension x -> extension ~loc ~attrs (sub.extension sub x) - | Pcl_open (ovf, lid, ce) -> - open_ ~loc ~attrs ovf (map_loc sub lid) (sub.class_expr sub ce) + let rec filter_directive pos acc lexbuf : (int * int ) list = + match token_with_comments lexbuf with + | HASH when at_bol lexbuf -> + (* ^[start_pos]#if ... #then^[end_pos] *) + let start_pos = Lexing.lexeme_start lexbuf in + interpret_directive lexbuf + (fun lexbuf -> + filter_directive + (Lexing.lexeme_end lexbuf) + ((pos, start_pos) :: acc) + lexbuf + + ) + (fun _token -> filter_directive pos acc lexbuf ) + | EOF -> (pos, Lexing.lexeme_end lexbuf) :: acc + | _ -> filter_directive pos acc lexbuf - let map_kind sub = function - | Cfk_concrete (o, e) -> Cfk_concrete (o, sub.expr sub e) - | Cfk_virtual t -> Cfk_virtual (sub.typ sub t) + let filter_directive_from_lexbuf lexbuf = + List.rev (filter_directive 0 [] lexbuf ) - let map_field sub {pcf_desc = desc; pcf_loc = loc; pcf_attributes = attrs} = - let open Cf in - let loc = sub.location sub loc in - let attrs = sub.attributes sub attrs in - match desc with - | Pcf_inherit (o, ce, s) -> - inherit_ ~loc ~attrs o (sub.class_expr sub ce) - (map_opt (map_loc sub) s) - | Pcf_val (s, m, k) -> val_ ~loc ~attrs (map_loc sub s) m (map_kind sub k) - | Pcf_method (s, p, k) -> - method_ ~loc ~attrs (map_loc sub s) p (map_kind sub k) - | Pcf_constraint (t1, t2) -> - constraint_ ~loc ~attrs (sub.typ sub t1) (sub.typ sub t2) - | Pcf_initializer e -> initializer_ ~loc ~attrs (sub.expr sub e) - | Pcf_attribute x -> attribute ~loc (sub.attribute sub x) - | Pcf_extension x -> extension ~loc ~attrs (sub.extension sub x) + let set_preprocessor init preprocess = + escaped_newlines := true; + preprocessor := Some (init, preprocess) - let map_structure sub {pcstr_self; pcstr_fields} = - { - pcstr_self = sub.pat sub pcstr_self; - pcstr_fields = List.map (sub.class_field sub) pcstr_fields; - } - let class_infos sub f {pci_virt; pci_params = pl; pci_name; pci_expr; - pci_loc; pci_attributes} = - Ci.mk - ~virt:pci_virt - ~params:(List.map (map_fst (sub.typ sub)) pl) - (map_loc sub pci_name) - (f pci_expr) - ~loc:(sub.location sub pci_loc) - ~attrs:(sub.attributes sub pci_attributes) +# 3467 "parsing/lexer.ml" + end +module Oprint : sig +#1 "oprint.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 2002 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -(* Now, a generic AST mapper, to be extended to cover all kinds and - cases of the OCaml grammar. The default behavior of the mapper is - the identity. *) +open Format +open Outcometree -let default_mapper = - { - structure = (fun this l -> List.map (this.structure_item this) l); - structure_item = M.map_structure_item; - module_expr = M.map; - signature = (fun this l -> List.map (this.signature_item this) l); - signature_item = MT.map_signature_item; - module_type = MT.map; - with_constraint = MT.map_with_constraint; - class_declaration = - (fun this -> CE.class_infos this (this.class_expr this)); - class_expr = CE.map; - class_field = CE.map_field; - class_structure = CE.map_structure; - class_type = CT.map; - class_type_field = CT.map_field; - class_signature = CT.map_signature; - class_type_declaration = - (fun this -> CE.class_infos this (this.class_type this)); - class_description = - (fun this -> CE.class_infos this (this.class_type this)); - type_declaration = T.map_type_declaration; - type_kind = T.map_type_kind; - typ = T.map; - type_extension = T.map_type_extension; - extension_constructor = T.map_extension_constructor; - value_description = - (fun this {pval_name; pval_type; pval_prim; pval_loc; - pval_attributes} -> - Val.mk - (map_loc this pval_name) - (this.typ this pval_type) - ~attrs:(this.attributes this pval_attributes) - ~loc:(this.location this pval_loc) - ~prim:pval_prim - ); - pat = P.map; - expr = E.map; +val out_ident : (formatter -> string -> unit) ref - module_declaration = - (fun this {pmd_name; pmd_type; pmd_attributes; pmd_loc} -> - Md.mk - (map_loc this pmd_name) - (this.module_type this pmd_type) - ~attrs:(this.attributes this pmd_attributes) - ~loc:(this.location this pmd_loc) - ); +val out_value : (formatter -> out_value -> unit) ref +val out_type : (formatter -> out_type -> unit) ref +val out_class_type : (formatter -> out_class_type -> unit) ref +val out_module_type : (formatter -> out_module_type -> unit) ref +val out_sig_item : (formatter -> out_sig_item -> unit) ref +val out_signature : (formatter -> out_sig_item list -> unit) ref +val out_type_extension : (formatter -> out_type_extension -> unit) ref +val out_phrase : (formatter -> out_phrase -> unit) ref - module_type_declaration = - (fun this {pmtd_name; pmtd_type; pmtd_attributes; pmtd_loc} -> - Mtd.mk - (map_loc this pmtd_name) - ?typ:(map_opt (this.module_type this) pmtd_type) - ~attrs:(this.attributes this pmtd_attributes) - ~loc:(this.location this pmtd_loc) - ); +val parenthesized_ident : string -> bool - module_binding = - (fun this {pmb_name; pmb_expr; pmb_attributes; pmb_loc} -> - Mb.mk (map_loc this pmb_name) (this.module_expr this pmb_expr) - ~attrs:(this.attributes this pmb_attributes) - ~loc:(this.location this pmb_loc) - ); +end = struct +#1 "oprint.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 2002 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) +open Format +open Outcometree - open_description = - (fun this {popen_lid; popen_override; popen_attributes; popen_loc} -> - Opn.mk (map_loc this popen_lid) - ~override:popen_override - ~loc:(this.location this popen_loc) - ~attrs:(this.attributes this popen_attributes) - ); +exception Ellipsis +let cautious f ppf arg = + try f ppf arg with + Ellipsis -> fprintf ppf "..." - include_description = - (fun this {pincl_mod; pincl_attributes; pincl_loc} -> - Incl.mk (this.module_type this pincl_mod) - ~loc:(this.location this pincl_loc) - ~attrs:(this.attributes this pincl_attributes) - ); - include_declaration = - (fun this {pincl_mod; pincl_attributes; pincl_loc} -> - Incl.mk (this.module_expr this pincl_mod) - ~loc:(this.location this pincl_loc) - ~attrs:(this.attributes this pincl_attributes) - ); +let out_ident = ref pp_print_string - value_binding = - (fun this {pvb_pat; pvb_expr; pvb_attributes; pvb_loc} -> - Vb.mk - (this.pat this pvb_pat) - (this.expr this pvb_expr) - ~loc:(this.location this pvb_loc) - ~attrs:(this.attributes this pvb_attributes) - ); +let print_lident ppf = function + | "::" -> !out_ident ppf "(::)" + | s -> !out_ident ppf s +let rec print_ident ppf = + function + Oide_ident s -> print_lident ppf s + | Oide_dot (id, s) -> + print_ident ppf id; pp_print_char ppf '.'; print_lident ppf s + | Oide_apply (id1, id2) -> + fprintf ppf "%a(%a)" print_ident id1 print_ident id2 - constructor_declaration = - (fun this {pcd_name; pcd_args; pcd_res; pcd_loc; pcd_attributes} -> - Type.constructor - (map_loc this pcd_name) - ~args:(T.map_constructor_arguments this pcd_args) - ?res:(map_opt (this.typ this) pcd_res) - ~loc:(this.location this pcd_loc) - ~attrs:(this.attributes this pcd_attributes) - ); +let parenthesized_ident name = + (List.mem name ["or"; "mod"; "land"; "lor"; "lxor"; "lsl"; "lsr"; "asr"]) + || + (match name.[0] with + 'a'..'z' | 'A'..'Z' | '\223'..'\246' | '\248'..'\255' | '_' -> + false + | _ -> true) - label_declaration = - (fun this {pld_name; pld_type; pld_loc; pld_mutable; pld_attributes} -> - Type.field - (map_loc this pld_name) - (this.typ this pld_type) - ~mut:pld_mutable - ~loc:(this.location this pld_loc) - ~attrs:(this.attributes this pld_attributes) - ); +let value_ident ppf name = + if parenthesized_ident name then + fprintf ppf "( %s )" name + else + pp_print_string ppf name - cases = (fun this l -> List.map (this.case this) l); - case = - (fun this {pc_lhs; pc_guard; pc_rhs} -> - { - pc_lhs = this.pat this pc_lhs; - pc_guard = map_opt (this.expr this) pc_guard; - pc_rhs = this.expr this pc_rhs; - } - ); +(* Values *) + +let valid_float_lexeme s = + let l = String.length s in + let rec loop i = + if i >= l then s ^ "." else + match s.[i] with + | '0' .. '9' | '-' -> loop (i+1) + | _ -> s + in loop 0 +let float_repres f = + match classify_float f with + FP_nan -> "nan" + | FP_infinite -> + if f < 0.0 then "neg_infinity" else "infinity" + | _ -> + let float_val = + let s1 = Printf.sprintf "%.12g" f in + if f = float_of_string s1 then s1 else + let s2 = Printf.sprintf "%.15g" f in + if f = float_of_string s2 then s2 else + Printf.sprintf "%.18g" f + in valid_float_lexeme float_val +let parenthesize_if_neg ppf fmt v isneg = + if isneg then pp_print_char ppf '('; + fprintf ppf fmt v; + if isneg then pp_print_char ppf ')' - location = (fun _this l -> l); +let escape_string s = + (* Escape only C0 control characters (bytes <= 0x1F), DEL(0x7F), '\\' and '"' *) + let n = ref 0 in + for i = 0 to String.length s - 1 do + n := !n + + (match String.unsafe_get s i with + | '\"' | '\\' | '\n' | '\t' | '\r' | '\b' -> 2 + | '\x00' .. '\x1F' + | '\x7F' -> 4 + | _ -> 1) + done; + if !n = String.length s then s else begin + let s' = Bytes.create !n in + n := 0; + for i = 0 to String.length s - 1 do + begin match String.unsafe_get s i with + | ('\"' | '\\') as c -> + Bytes.unsafe_set s' !n '\\'; incr n; Bytes.unsafe_set s' !n c + | '\n' -> + Bytes.unsafe_set s' !n '\\'; incr n; Bytes.unsafe_set s' !n 'n' + | '\t' -> + Bytes.unsafe_set s' !n '\\'; incr n; Bytes.unsafe_set s' !n 't' + | '\r' -> + Bytes.unsafe_set s' !n '\\'; incr n; Bytes.unsafe_set s' !n 'r' + | '\b' -> + Bytes.unsafe_set s' !n '\\'; incr n; Bytes.unsafe_set s' !n 'b' + | '\x00' .. '\x1F' | '\x7F' as c -> + let a = Char.code c in + Bytes.unsafe_set s' !n '\\'; + incr n; + Bytes.unsafe_set s' !n (Char.chr (48 + a / 100)); + incr n; + Bytes.unsafe_set s' !n (Char.chr (48 + (a / 10) mod 10)); + incr n; + Bytes.unsafe_set s' !n (Char.chr (48 + a mod 10)); + | c -> Bytes.unsafe_set s' !n c + end; + incr n + done; + Bytes.to_string s' + end - extension = (fun this (s, e) -> (map_loc this s, this.payload this e)); - attribute = (fun this (s, e) -> (map_loc this s, this.payload this e)); - attributes = (fun this l -> List.map (this.attribute this) l); - payload = - (fun this -> function - | PStr x -> PStr (this.structure this x) - | PSig x -> PSig (this.signature this x) - | PTyp x -> PTyp (this.typ this x) - | PPat (x, g) -> PPat (this.pat this x, map_opt (this.expr this) g) - ); - } -let rec extension_of_error {loc; msg; if_highlight; sub} = - { loc; txt = "ocaml.error" }, - PStr ([Str.eval (Exp.constant (Pconst_string (msg, None))); - Str.eval (Exp.constant (Pconst_string (if_highlight, None)))] @ - (List.map (fun ext -> Str.extension (extension_of_error ext)) sub)) +let print_out_string ppf s = + let not_escaped = + (* let the user dynamically choose if strings should be escaped: *) + match Sys.getenv_opt "OCAMLTOP_UTF_8" with + | None -> true + | Some x -> + match bool_of_string_opt x with + | None -> true + | Some f -> f in + if not_escaped then + fprintf ppf "\"%s\"" (escape_string s) + else + fprintf ppf "%S" s -let attribute_of_warning loc s = - { loc; txt = "ocaml.ppwarning" }, - PStr ([Str.eval ~loc (Exp.constant (Pconst_string (s, None)))]) +let print_out_value ppf tree = + let rec print_tree_1 ppf = + function + | Oval_constr (name, [param]) -> + fprintf ppf "@[<1>%a@ %a@]" print_ident name print_constr_param param + | Oval_constr (name, (_ :: _ as params)) -> + fprintf ppf "@[<1>%a@ (%a)@]" print_ident name + (print_tree_list print_tree_1 ",") params + | Oval_variant (name, Some param) -> + fprintf ppf "@[<2>`%s@ %a@]" name print_constr_param param + | tree -> print_simple_tree ppf tree + and print_constr_param ppf = function + | Oval_int i -> parenthesize_if_neg ppf "%i" i (i < 0) + | Oval_int32 i -> parenthesize_if_neg ppf "%lil" i (i < 0l) + | Oval_int64 i -> parenthesize_if_neg ppf "%LiL" i (i < 0L) + | Oval_nativeint i -> parenthesize_if_neg ppf "%nin" i (i < 0n) + | Oval_float f -> parenthesize_if_neg ppf "%s" (float_repres f) (f < 0.0) + | Oval_string (_,_, Ostr_bytes) as tree -> + pp_print_char ppf '('; + print_simple_tree ppf tree; + pp_print_char ppf ')'; + | tree -> print_simple_tree ppf tree + and print_simple_tree ppf = + function + Oval_int i -> fprintf ppf "%i" i + | Oval_int32 i -> fprintf ppf "%lil" i + | Oval_int64 i -> fprintf ppf "%LiL" i + | Oval_nativeint i -> fprintf ppf "%nin" i + | Oval_float f -> pp_print_string ppf (float_repres f) + | Oval_char c -> fprintf ppf "%C" c + | Oval_string (s, maxlen, kind) -> + begin try + let len = String.length s in + let s = if len > maxlen then String.sub s 0 maxlen else s in + begin match kind with + | Ostr_bytes -> fprintf ppf "Bytes.of_string %S" s + | Ostr_string -> print_out_string ppf s + end; + (if len > maxlen then + fprintf ppf + "... (* string length %d; truncated *)" len + ) + with + Invalid_argument _ (* "String.create" *)-> fprintf ppf "" + end + | Oval_list tl -> + fprintf ppf "@[<1>[%a]@]" (print_tree_list print_tree_1 ";") tl + | Oval_array tl -> + fprintf ppf "@[<2>[|%a|]@]" (print_tree_list print_tree_1 ";") tl + | Oval_constr (name, []) -> print_ident ppf name + | Oval_variant (name, None) -> fprintf ppf "`%s" name + | Oval_stuff s -> pp_print_string ppf s + | Oval_record fel -> + fprintf ppf "@[<1>{%a}@]" (cautious (print_fields true)) fel + | Oval_ellipsis -> raise Ellipsis + | Oval_printer f -> f ppf + | Oval_tuple tree_list -> + fprintf ppf "@[<1>(%a)@]" (print_tree_list print_tree_1 ",") tree_list + | tree -> fprintf ppf "@[<1>(%a)@]" (cautious print_tree_1) tree + and print_fields first ppf = + function + [] -> () + | (name, tree) :: fields -> + if not first then fprintf ppf ";@ "; + fprintf ppf "@[<1>%a@ =@ %a@]" print_ident name (cautious print_tree_1) + tree; + print_fields false ppf fields + and print_tree_list print_item sep ppf tree_list = + let rec print_list first ppf = + function + [] -> () + | tree :: tree_list -> + if not first then fprintf ppf "%s@ " sep; + print_item ppf tree; + print_list false ppf tree_list + in + cautious (print_list true) ppf tree_list + in + cautious print_tree_1 ppf tree -module StringMap = Map.Make(struct - type t = string - let compare = compare -end) +let out_value = ref print_out_value -let cookies = ref StringMap.empty +(* Types *) -let get_cookie k = - try Some (StringMap.find k !cookies) - with Not_found -> None +let rec print_list_init pr sep ppf = + function + [] -> () + | a :: l -> sep ppf; pr ppf a; print_list_init pr sep ppf l -let set_cookie k v = - cookies := StringMap.add k v !cookies +let rec print_list pr sep ppf = + function + [] -> () + | [a] -> pr ppf a + | a :: l -> pr ppf a; sep ppf; print_list pr sep ppf l -let tool_name_ref = ref "_none_" +let pr_present = + print_list (fun ppf s -> fprintf ppf "`%s" s) (fun ppf -> fprintf ppf "@ ") -let tool_name () = !tool_name_ref +let pr_vars = + print_list (fun ppf s -> fprintf ppf "'%s" s) (fun ppf -> fprintf ppf "@ ") +let rec print_out_type ppf = + function + | Otyp_alias (ty, s) -> + fprintf ppf "@[%a@ as '%s@]" print_out_type ty s + | Otyp_poly (sl, ty) -> + fprintf ppf "@[%a.@ %a@]" + pr_vars sl + print_out_type ty + | ty -> + print_out_type_1 ppf ty -module PpxContext = struct - open Longident - open Asttypes - open Ast_helper +and print_out_type_1 ppf = + function + Otyp_arrow (lab, ty1, ty2) -> + pp_open_box ppf 0; + if lab <> "" then (pp_print_string ppf lab; pp_print_char ppf ':'); + print_out_type_2 ppf ty1; + pp_print_string ppf " ->"; + pp_print_space ppf (); + print_out_type_1 ppf ty2; + pp_close_box ppf () + | ty -> print_out_type_2 ppf ty +and print_out_type_2 ppf = + function + Otyp_tuple tyl -> + fprintf ppf "@[<0>%a@]" (print_typlist print_simple_out_type " *") tyl + | ty -> print_simple_out_type ppf ty +and print_simple_out_type ppf = + function + Otyp_class (ng, id, tyl) -> + fprintf ppf "@[%a%s#%a@]" print_typargs tyl (if ng then "_" else "") + print_ident id + + | Otyp_constr ( (Oide_dot (((Oide_dot (Oide_ident "Js", "Internal"))| (Oide_ident "Js_internal")), + ("fn" | "meth" as name )) as id) , + ([Otyp_variant(_,Ovar_fields [ variant, _, tys], _,_); result] as tyl)) + -> + (* Otyp_arrow*) + let make tys result = + if tys = [] then + Otyp_arrow ("", Otyp_constr (Oide_ident "unit", []),result) + else + match tys with + | [ Otyp_tuple tys as single] -> + if variant = "Arity_1" then + Otyp_arrow ("", single, result) + else + List.fold_right (fun x acc -> Otyp_arrow("",x,acc) ) tys result + | [single] -> + Otyp_arrow ("", single, result) + | _ -> + raise_notrace Not_found + in + begin match (make tys result) with + | exception _ -> + begin + pp_open_box ppf 0; + print_typargs ppf tyl; + print_ident ppf id; + pp_close_box ppf () + end + | res -> + begin match name with + | "fn" -> + fprintf ppf "@[<0>(%a@ [@bs])@]" print_out_type_1 res + | "meth" -> + fprintf ppf "@[<0>(%a@ [@bs.meth])@]" print_out_type_1 res + | _ -> assert false + end + end + | Otyp_constr ((Oide_dot ((Oide_dot (Oide_ident "Js", "Internal") | (Oide_ident "Js_internal")), "meth_callback" ) as id) , + ([Otyp_variant(_,Ovar_fields [ variant, _, tys], _,_); result] as tyl)) + -> + let make tys result = + match tys with + | [ Otyp_tuple tys as single ] -> + if variant = "Arity_1" then Otyp_arrow ("", single, result) + else + List.fold_right (fun x acc -> Otyp_arrow("",x,acc) ) tys result + | [single] -> + Otyp_arrow ("", single, result) + | _ -> + raise_notrace Not_found + in + begin match (make tys result) with + | exception _ -> + begin + pp_open_box ppf 0; + print_typargs ppf tyl; + print_ident ppf id; + pp_close_box ppf () + end + | res -> + fprintf ppf "@[<0>(%a@ [@bs.this])@]" print_out_type_1 res - let lid name = { txt = Lident name; loc = Location.none } + end + + | Otyp_constr (id, tyl) -> + pp_open_box ppf 0; + print_typargs ppf tyl; + print_ident ppf id; + pp_close_box ppf () + | Otyp_object (fields, rest) -> + fprintf ppf "@[<2>< %a >@]" (print_fields rest) fields + | Otyp_stuff s -> pp_print_string ppf s + | Otyp_var (ng, s) -> fprintf ppf "'%s%s" (if ng then "_" else "") s + | Otyp_variant (non_gen, row_fields, closed, tags) -> + let print_present ppf = + function + None | Some [] -> () + | Some l -> fprintf ppf "@;<1 -2>> @[%a@]" pr_present l + in + let print_fields ppf = + function + Ovar_fields fields -> + print_list print_row_field (fun ppf -> fprintf ppf "@;<1 -2>| ") + ppf fields + | Ovar_typ typ -> + print_simple_out_type ppf typ + in + fprintf ppf "%s[%s@[@[%a@]%a ]@]" (if non_gen then "_" else "") + (if closed then if tags = None then " " else "< " + else if tags = None then "> " else "? ") + print_fields row_fields + print_present tags + | Otyp_alias _ | Otyp_poly _ | Otyp_arrow _ | Otyp_tuple _ as ty -> + pp_open_box ppf 1; + pp_print_char ppf '('; + print_out_type ppf ty; + pp_print_char ppf ')'; + pp_close_box ppf () + | Otyp_abstract | Otyp_open + | Otyp_sum _ | Otyp_manifest (_, _) -> () + | Otyp_record lbls -> print_record_decl ppf lbls + | Otyp_module (p, n, tyl) -> + fprintf ppf "@[<1>(module %s" p; + let first = ref true in + List.iter2 + (fun s t -> + let sep = if !first then (first := false; "with") else "and" in + fprintf ppf " %s type %s = %a" sep s print_out_type t + ) + n tyl; + fprintf ppf ")@]" + | Otyp_attribute (t, attr) -> + fprintf ppf "@[<1>(%a [@@%s])@]" print_out_type t attr.oattr_name +and print_record_decl ppf lbls = + fprintf ppf "{%a@;<1 -2>}" + (print_list_init print_out_label (fun ppf -> fprintf ppf "@ ")) lbls +and print_fields rest ppf = + function + [] -> + begin match rest with + Some non_gen -> fprintf ppf "%s.." (if non_gen then "_" else "") + | None -> () + end + | [s, t] -> + fprintf ppf "%s : %a" s print_out_type t; + begin match rest with + Some _ -> fprintf ppf ";@ " + | None -> () + end; + print_fields rest ppf [] + | (s, t) :: l -> + fprintf ppf "%s : %a;@ %a" s print_out_type t (print_fields rest) l +and print_row_field ppf (l, opt_amp, tyl) = + let pr_of ppf = + if opt_amp then fprintf ppf " of@ &@ " + else if tyl <> [] then fprintf ppf " of@ " + else fprintf ppf "" + in + fprintf ppf "@[`%s%t%a@]" l pr_of (print_typlist print_out_type " &") + tyl +and print_typlist print_elem sep ppf = + function + [] -> () + | [ty] -> print_elem ppf ty + | ty :: tyl -> + print_elem ppf ty; + pp_print_string ppf sep; + pp_print_space ppf (); + print_typlist print_elem sep ppf tyl +and print_typargs ppf = + function + [] -> () + | [ty1] -> print_simple_out_type ppf ty1; pp_print_space ppf () + | tyl -> + pp_open_box ppf 1; + pp_print_char ppf '('; + print_typlist print_out_type "," ppf tyl; + pp_print_char ppf ')'; + pp_close_box ppf (); + pp_print_space ppf () +and print_out_label ppf (name, mut, arg) = + fprintf ppf "@[<2>%s%s :@ %a@];" (if mut then "mutable " else "") name + print_out_type arg - let make_string x = Exp.constant (Pconst_string (x, None)) +let out_type = ref print_out_type - let make_bool x = - if x - then Exp.construct (lid "true") None - else Exp.construct (lid "false") None +(* Class types *) - let rec make_list f lst = - match lst with - | x :: rest -> - Exp.construct (lid "::") (Some (Exp.tuple [f x; make_list f rest])) - | [] -> - Exp.construct (lid "[]") None +let type_parameter ppf (ty, (co, cn)) = + fprintf ppf "%s%s" + (if not cn then "+" else if not co then "-" else "") + (if ty = "_" then ty else "'"^ty) - let make_pair f1 f2 (x1, x2) = - Exp.tuple [f1 x1; f2 x2] +let print_out_class_params ppf = + function + [] -> () + | tyl -> + fprintf ppf "@[<1>[%a]@]@ " + (print_list type_parameter (fun ppf -> fprintf ppf ", ")) + tyl - let make_option f opt = - match opt with - | Some x -> Exp.construct (lid "Some") (Some (f x)) - | None -> Exp.construct (lid "None") None +let rec print_out_class_type ppf = + function + Octy_constr (id, tyl) -> + let pr_tyl ppf = + function + [] -> () + | tyl -> + fprintf ppf "@[<1>[%a]@]@ " (print_typlist !out_type ",") tyl + in + fprintf ppf "@[%a%a@]" pr_tyl tyl print_ident id + | Octy_arrow (lab, ty, cty) -> + fprintf ppf "@[%s%a ->@ %a@]" (if lab <> "" then lab ^ ":" else "") + print_out_type_2 ty print_out_class_type cty + | Octy_signature (self_ty, csil) -> + let pr_param ppf = + function + Some ty -> fprintf ppf "@ @[(%a)@]" !out_type ty + | None -> () + in + fprintf ppf "@[@[<2>object%a@]@ %a@;<1 -2>end@]" pr_param self_ty + (print_list print_out_class_sig_item (fun ppf -> fprintf ppf "@ ")) + csil +and print_out_class_sig_item ppf = + function + Ocsg_constraint (ty1, ty2) -> + fprintf ppf "@[<2>constraint %a =@ %a@]" !out_type ty1 + !out_type ty2 + | Ocsg_method (name, priv, virt, ty) -> + fprintf ppf "@[<2>method %s%s%s :@ %a@]" + (if priv then "private " else "") (if virt then "virtual " else "") + name !out_type ty + | Ocsg_value (name, mut, vr, ty) -> + fprintf ppf "@[<2>val %s%s%s :@ %a@]" + (if mut then "mutable " else "") + (if vr then "virtual " else "") + name !out_type ty - let get_cookies () = - lid "cookies", - make_list (make_pair make_string (fun x -> x)) - (StringMap.bindings !cookies) +let out_class_type = ref print_out_class_type - let mk fields = - { txt = "ocaml.ppx.context"; loc = Location.none }, - Parsetree.PStr [Str.eval (Exp.record fields None)] +(* Signature *) - let make ~tool_name () = - let fields = - [ - lid "tool_name", make_string tool_name; - lid "include_dirs", make_list make_string !Clflags.include_dirs; - lid "load_path", make_list make_string !Config.load_path; - lid "open_modules", make_list make_string !Clflags.open_modules; - lid "for_package", make_option make_string !Clflags.for_package; - lid "debug", make_bool !Clflags.debug; - lid "use_threads", make_bool !Clflags.use_threads; - lid "use_vmthreads", make_bool !Clflags.use_vmthreads; - get_cookies () - ] - in - mk fields +let out_module_type = ref (fun _ -> failwith "Oprint.out_module_type") +let out_sig_item = ref (fun _ -> failwith "Oprint.out_sig_item") +let out_signature = ref (fun _ -> failwith "Oprint.out_signature") +let out_type_extension = ref (fun _ -> failwith "Oprint.out_type_extension") - let get_fields = function - | PStr [{pstr_desc = Pstr_eval - ({ pexp_desc = Pexp_record (fields, None) }, [])}] -> - fields - | _ -> - raise_errorf "Internal error: invalid [@@@ocaml.ppx.context] syntax" +let rec print_out_functor funct ppf = + function + Omty_functor (_, None, mty_res) -> + if funct then fprintf ppf "() %a" (print_out_functor true) mty_res + else fprintf ppf "functor@ () %a" (print_out_functor true) mty_res + | Omty_functor (name, Some mty_arg, mty_res) -> begin + match name, funct with + | "_", true -> + fprintf ppf "->@ %a ->@ %a" + print_out_module_type mty_arg (print_out_functor false) mty_res + | "_", false -> + fprintf ppf "%a ->@ %a" + print_out_module_type mty_arg (print_out_functor false) mty_res + | name, true -> + fprintf ppf "(%s : %a) %a" name + print_out_module_type mty_arg (print_out_functor true) mty_res + | name, false -> + fprintf ppf "functor@ (%s : %a) %a" name + print_out_module_type mty_arg (print_out_functor true) mty_res + end + | m -> + if funct then fprintf ppf "->@ %a" print_out_module_type m + else print_out_module_type ppf m - let restore fields = - let field name payload = - let rec get_string = function - | { pexp_desc = Pexp_constant (Pconst_string (str, None)) } -> str - | _ -> raise_errorf "Internal error: invalid [@@@ocaml.ppx.context \ - { %s }] string syntax" name - and get_bool pexp = - match pexp with - | {pexp_desc = Pexp_construct ({txt = Longident.Lident "true"}, - None)} -> - true - | {pexp_desc = Pexp_construct ({txt = Longident.Lident "false"}, - None)} -> - false - | _ -> raise_errorf "Internal error: invalid [@@@ocaml.ppx.context \ - { %s }] bool syntax" name - and get_list elem = function - | {pexp_desc = - Pexp_construct ({txt = Longident.Lident "::"}, - Some {pexp_desc = Pexp_tuple [exp; rest]}) } -> - elem exp :: get_list elem rest - | {pexp_desc = - Pexp_construct ({txt = Longident.Lident "[]"}, None)} -> - [] - | _ -> raise_errorf "Internal error: invalid [@@@ocaml.ppx.context \ - { %s }] list syntax" name - and get_pair f1 f2 = function - | {pexp_desc = Pexp_tuple [e1; e2]} -> - (f1 e1, f2 e2) - | _ -> raise_errorf "Internal error: invalid [@@@ocaml.ppx.context \ - { %s }] pair syntax" name - and get_option elem = function - | { pexp_desc = - Pexp_construct ({ txt = Longident.Lident "Some" }, Some exp) } -> - Some (elem exp) - | { pexp_desc = - Pexp_construct ({ txt = Longident.Lident "None" }, None) } -> - None - | _ -> raise_errorf "Internal error: invalid [@@@ocaml.ppx.context \ - { %s }] option syntax" name +and print_out_module_type ppf = + function + Omty_abstract -> () + | Omty_functor _ as t -> + fprintf ppf "@[<2>%a@]" (print_out_functor false) t + | Omty_ident id -> fprintf ppf "%a" print_ident id + | Omty_signature sg -> + fprintf ppf "@[sig@ %a@;<1 -2>end@]" !out_signature sg + | Omty_alias id -> fprintf ppf "(module %a)" print_ident id +and print_out_signature ppf = + function + [] -> () + | [item] -> !out_sig_item ppf item + | Osig_typext(ext, Oext_first) :: items -> + (* Gather together the extension constructors *) + let rec gather_extensions acc items = + match items with + Osig_typext(ext, Oext_next) :: items -> + gather_extensions + ((ext.oext_name, ext.oext_args, ext.oext_ret_type) :: acc) + items + | _ -> (List.rev acc, items) in - match name with - | "tool_name" -> - tool_name_ref := get_string payload - | "include_dirs" -> - Clflags.include_dirs := get_list get_string payload - | "load_path" -> - Config.load_path := get_list get_string payload - | "open_modules" -> - Clflags.open_modules := get_list get_string payload - | "for_package" -> - Clflags.for_package := get_option get_string payload - | "debug" -> - Clflags.debug := get_bool payload - | "use_threads" -> - Clflags.use_threads := get_bool payload - | "use_vmthreads" -> - Clflags.use_vmthreads := get_bool payload - | "cookies" -> - let l = get_list (get_pair get_string (fun x -> x)) payload in - cookies := - List.fold_left - (fun s (k, v) -> StringMap.add k v s) StringMap.empty - l - | _ -> - () - in - List.iter (function ({txt=Lident name}, x) -> field name x | _ -> ()) fields - - let update_cookies fields = - let fields = - List.filter - (function ({txt=Lident "cookies"}, _) -> false | _ -> true) - fields - in - fields @ [get_cookies ()] -end - -let ppx_context = PpxContext.make - -let extension_of_exn exn = - match error_of_exn exn with - | Some (`Ok error) -> extension_of_error error - | Some `Already_displayed -> { loc = Location.none; txt = "ocaml.error" }, PStr [] - | None -> raise exn + let exts, items = + gather_extensions + [(ext.oext_name, ext.oext_args, ext.oext_ret_type)] + items + in + let te = + { otyext_name = ext.oext_type_name; + otyext_params = ext.oext_type_params; + otyext_constructors = exts; + otyext_private = ext.oext_private } + in + fprintf ppf "%a@ %a" !out_type_extension te print_out_signature items + | item :: items -> + fprintf ppf "%a@ %a" !out_sig_item item print_out_signature items +and print_out_sig_item ppf = + function + Osig_class (vir_flag, name, params, clt, rs) -> + fprintf ppf "@[<2>%s%s@ %a%s@ :@ %a@]" + (if rs = Orec_next then "and" else "class") + (if vir_flag then " virtual" else "") print_out_class_params params + name !out_class_type clt + | Osig_class_type (vir_flag, name, params, clt, rs) -> + fprintf ppf "@[<2>%s%s@ %a%s@ =@ %a@]" + (if rs = Orec_next then "and" else "class type") + (if vir_flag then " virtual" else "") print_out_class_params params + name !out_class_type clt + | Osig_typext (ext, Oext_exception) -> + fprintf ppf "@[<2>exception %a@]" + print_out_constr (ext.oext_name, ext.oext_args, ext.oext_ret_type) + | Osig_typext (ext, _es) -> + print_out_extension_constructor ppf ext + | Osig_modtype (name, Omty_abstract) -> + fprintf ppf "@[<2>module type %s@]" name + | Osig_modtype (name, mty) -> + fprintf ppf "@[<2>module type %s =@ %a@]" name !out_module_type mty + | Osig_module (name, Omty_alias id, _) -> + fprintf ppf "@[<2>module %s =@ %a@]" name print_ident id + | Osig_module (name, mty, rs) -> + fprintf ppf "@[<2>%s %s :@ %a@]" + (match rs with Orec_not -> "module" + | Orec_first -> "module rec" + | Orec_next -> "and") + name !out_module_type mty + | Osig_type(td, rs) -> + print_out_type_decl + (match rs with + | Orec_not -> "type nonrec" + | Orec_first -> "type" + | Orec_next -> "and") + ppf td + | Osig_value vd -> + let kwd = if vd.oval_prims = [] then "val" else "external" in + let pr_prims ppf = + function + [] -> () + | s :: sl -> + fprintf ppf "@ = \"%s\"" s; + List.iter (fun s -> +(* TODO: in general, we should print bs attributes, some attributes like + bs.splice does need it *) + let len = String.length s in + if len >= 3 && s.[0] = 'B' && s.[1] = 'S' && s.[2] = ':' then + fprintf ppf "@ \"BS-EXTERNAL\"" + else + fprintf ppf "@ \"%s\"" s + + ) sl + in + fprintf ppf "@[<2>%s %a :@ %a%a%a@]" kwd value_ident vd.oval_name + !out_type vd.oval_type pr_prims vd.oval_prims + (fun ppf -> List.iter (fun a -> fprintf ppf "@ [@@@@%s]" a.oattr_name)) + vd.oval_attributes + | Osig_ellipsis -> + fprintf ppf "..." -let apply_lazy ~source ~target mapper = - let implem ast = - let fields, ast = - match ast with - | {pstr_desc = Pstr_attribute ({txt = "ocaml.ppx.context"}, x)} :: l -> - PpxContext.get_fields x, l - | _ -> [], ast - in - PpxContext.restore fields; - let ast = - try - let mapper = mapper () in - mapper.structure mapper ast - with exn -> - [{pstr_desc = Pstr_extension (extension_of_exn exn, []); - pstr_loc = Location.none}] - in - let fields = PpxContext.update_cookies fields in - Str.attribute (PpxContext.mk fields) :: ast +and print_out_type_decl kwd ppf td = + let print_constraints ppf = + List.iter + (fun (ty1, ty2) -> + fprintf ppf "@ @[<2>constraint %a =@ %a@]" !out_type ty1 + !out_type ty2) + td.otype_cstrs in - let iface ast = - let fields, ast = - match ast with - | {psig_desc = Psig_attribute ({txt = "ocaml.ppx.context"}, x)} :: l -> - PpxContext.get_fields x, l - | _ -> [], ast - in - PpxContext.restore fields; - let ast = - try - let mapper = mapper () in - mapper.signature mapper ast - with exn -> - [{psig_desc = Psig_extension (extension_of_exn exn, []); - psig_loc = Location.none}] - in - let fields = PpxContext.update_cookies fields in - Sig.attribute (PpxContext.mk fields) :: ast + let type_defined ppf = + match td.otype_params with + [] -> pp_print_string ppf td.otype_name + | [param] -> fprintf ppf "@[%a@ %s@]" type_parameter param td.otype_name + | _ -> + fprintf ppf "@[(@[%a)@]@ %s@]" + (print_list type_parameter (fun ppf -> fprintf ppf ",@ ")) + td.otype_params + td.otype_name + in + let print_manifest ppf = + function + Otyp_manifest (ty, _) -> fprintf ppf " =@ %a" !out_type ty + | _ -> () + in + let print_name_params ppf = + fprintf ppf "%s %t%a" kwd type_defined print_manifest td.otype_type + in + let ty = + match td.otype_type with + Otyp_manifest (_, ty) -> ty + | _ -> td.otype_type + in + let print_private ppf = function + Asttypes.Private -> fprintf ppf " private" + | Asttypes.Public -> () in - - let ic = open_in_bin source in - let magic = - really_input_string ic (String.length Config.ast_impl_magic_number) + let print_immediate ppf = + if td.otype_immediate then fprintf ppf " [%@%@immediate]" else () in - - let rewrite transform = - Location.set_input_name @@ input_value ic; - let ast = input_value ic in - close_in ic; - let ast = transform ast in - let oc = open_out_bin target in - output_string oc magic; - output_value oc !Location.input_name; - output_value oc ast; - close_out oc - and fail () = - close_in ic; - failwith "Ast_mapper: OCaml version mismatch or malformed input"; + let print_unboxed ppf = + if td.otype_unboxed then fprintf ppf " [%@%@unboxed]" else () in + let print_out_tkind ppf = function + | Otyp_abstract -> () + | Otyp_record lbls -> + fprintf ppf " =%a %a" + print_private td.otype_private + print_record_decl lbls + | Otyp_sum constrs -> + fprintf ppf " =%a@;<1 2>%a" + print_private td.otype_private + (print_list print_out_constr (fun ppf -> fprintf ppf "@ | ")) constrs + | Otyp_open -> + fprintf ppf " =%a .." + print_private td.otype_private + | ty -> + fprintf ppf " =%a@;<1 2>%a" + print_private td.otype_private + !out_type ty + in + fprintf ppf "@[<2>@[%t%a@]%t%t%t@]" + print_name_params + print_out_tkind ty + print_constraints + print_immediate + print_unboxed - if magic = Config.ast_impl_magic_number then - rewrite (implem : structure -> structure) - else if magic = Config.ast_intf_magic_number then - rewrite (iface : signature -> signature) - else fail () - -let drop_ppx_context_str ~restore = function - | {pstr_desc = Pstr_attribute({Location.txt = "ocaml.ppx.context"}, a)} - :: items -> - if restore then - PpxContext.restore (PpxContext.get_fields a); - items - | items -> items +and print_out_constr ppf (name, tyl,ret_type_opt) = + let name = + match name with + | "::" -> "(::)" (* #7200 *) + | s -> s + in + match ret_type_opt with + | None -> + begin match tyl with + | [] -> + pp_print_string ppf name + | _ -> + fprintf ppf "@[<2>%s of@ %a@]" name + (print_typlist print_simple_out_type " *") tyl + end + | Some ret_type -> + begin match tyl with + | [] -> + fprintf ppf "@[<2>%s :@ %a@]" name print_simple_out_type ret_type + | _ -> + fprintf ppf "@[<2>%s :@ %a -> %a@]" name + (print_typlist print_simple_out_type " *") + tyl print_simple_out_type ret_type + end -let drop_ppx_context_sig ~restore = function - | {psig_desc = Psig_attribute({Location.txt = "ocaml.ppx.context"}, a)} - :: items -> - if restore then - PpxContext.restore (PpxContext.get_fields a); - items - | items -> items +and print_out_extension_constructor ppf ext = + let print_extended_type ppf = + let print_type_parameter ppf ty = + fprintf ppf "%s" + (if ty = "_" then ty else "'"^ty) + in + match ext.oext_type_params with + [] -> fprintf ppf "%s" ext.oext_type_name + | [ty_param] -> + fprintf ppf "@[%a@ %s@]" + print_type_parameter + ty_param + ext.oext_type_name + | _ -> + fprintf ppf "@[(@[%a)@]@ %s@]" + (print_list print_type_parameter (fun ppf -> fprintf ppf ",@ ")) + ext.oext_type_params + ext.oext_type_name + in + fprintf ppf "@[type %t +=%s@;<1 2>%a@]" + print_extended_type + (if ext.oext_private = Asttypes.Private then " private" else "") + print_out_constr (ext.oext_name, ext.oext_args, ext.oext_ret_type) -let add_ppx_context_str ~tool_name ast = - Ast_helper.Str.attribute (ppx_context ~tool_name ()) :: ast +and print_out_type_extension ppf te = + let print_extended_type ppf = + let print_type_parameter ppf ty = + fprintf ppf "%s" + (if ty = "_" then ty else "'"^ty) + in + match te.otyext_params with + [] -> fprintf ppf "%s" te.otyext_name + | [param] -> + fprintf ppf "@[%a@ %s@]" + print_type_parameter param + te.otyext_name + | _ -> + fprintf ppf "@[(@[%a)@]@ %s@]" + (print_list print_type_parameter (fun ppf -> fprintf ppf ",@ ")) + te.otyext_params + te.otyext_name + in + fprintf ppf "@[type %t +=%s@;<1 2>%a@]" + print_extended_type + (if te.otyext_private = Asttypes.Private then " private" else "") + (print_list print_out_constr (fun ppf -> fprintf ppf "@ | ")) + te.otyext_constructors -let add_ppx_context_sig ~tool_name ast = - Ast_helper.Sig.attribute (ppx_context ~tool_name ()) :: ast +let _ = out_module_type := print_out_module_type +let _ = out_signature := print_out_signature +let _ = out_sig_item := print_out_sig_item +let _ = out_type_extension := print_out_type_extension +(* Phrases *) -let apply ~source ~target mapper = - apply_lazy ~source ~target (fun () -> mapper) +let print_out_exception ppf exn outv = + match exn with + Sys.Break -> fprintf ppf "Interrupted.@." + | Out_of_memory -> fprintf ppf "Out of memory during evaluation.@." + | Stack_overflow -> + fprintf ppf "Stack overflow during evaluation (looping recursion?).@." + | _ -> fprintf ppf "@[Exception:@ %a.@]@." !out_value outv -let run_main mapper = - try - let a = Sys.argv in - let n = Array.length a in - if n > 2 then - let mapper () = - try mapper (Array.to_list (Array.sub a 1 (n - 3))) - with exn -> - (* PR#6463 *) - let f _ _ = raise exn in - {default_mapper with structure = f; signature = f} +let rec print_items ppf = + function + [] -> () + | (Osig_typext(ext, Oext_first), None) :: items -> + (* Gather together extension constructors *) + let rec gather_extensions acc items = + match items with + (Osig_typext(ext, Oext_next), None) :: items -> + gather_extensions + ((ext.oext_name, ext.oext_args, ext.oext_ret_type) :: acc) + items + | _ -> (List.rev acc, items) in - apply_lazy ~source:a.(n - 2) ~target:a.(n - 1) mapper - else begin - Printf.eprintf "Usage: %s [extra_args] \n%!" - Sys.executable_name; - exit 2 - end - with exn -> - prerr_endline (Printexc.to_string exn); - exit 2 - -let register_function = ref (fun _name f -> run_main f) -let register name f = !register_function name f - -end -module Tbl : sig -#1 "tbl.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) - -(* Association tables from any ordered type to any type. - We use the generic ordering to compare keys. *) - -type ('k, 'v) t - -val empty: ('k, 'v) t -val add: 'k -> 'v -> ('k, 'v) t -> ('k, 'v) t -val find: 'k -> ('k, 'v) t -> 'v -val find_str: string -> (string, 'v) t -> 'v -val mem: 'k -> ('k, 'v) t -> bool -val remove: 'k -> ('k, 'v) t -> ('k, 'v) t -val iter: ('k -> 'v -> unit) -> ('k, 'v) t -> unit -val map: ('k -> 'v1 -> 'v2) -> ('k, 'v1) t -> ('k, 'v2) t -val fold: ('k -> 'v -> 'acc -> 'acc) -> ('k, 'v) t -> 'acc -> 'acc - -open Format - -val print: (formatter -> 'k -> unit) -> (formatter -> 'v -> unit) -> - formatter -> ('k, 'v) t -> unit - -end = struct -#1 "tbl.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) + let exts, items = + gather_extensions + [(ext.oext_name, ext.oext_args, ext.oext_ret_type)] + items + in + let te = + { otyext_name = ext.oext_type_name; + otyext_params = ext.oext_type_params; + otyext_constructors = exts; + otyext_private = ext.oext_private } + in + fprintf ppf "@[%a@]" !out_type_extension te; + if items <> [] then fprintf ppf "@ %a" print_items items + | (tree, valopt) :: items -> + begin match valopt with + Some v -> + fprintf ppf "@[<2>%a =@ %a@]" !out_sig_item tree + !out_value v + | None -> fprintf ppf "@[%a@]" !out_sig_item tree + end; + if items <> [] then fprintf ppf "@ %a" print_items items -type ('k, 'v) t = - Empty - | Node of ('k, 'v) t * 'k * 'v * ('k, 'v) t * int +let print_out_phrase ppf = + function + Ophr_eval (outv, ty) -> + fprintf ppf "@[- : %a@ =@ %a@]@." !out_type ty !out_value outv + | Ophr_signature [] -> () + | Ophr_signature items -> fprintf ppf "@[%a@]@." print_items items + | Ophr_exception (exn, outv) -> print_out_exception ppf exn outv -let empty = Empty +let out_phrase = ref print_out_phrase -let height = function - Empty -> 0 - | Node(_,_,_,_,h) -> h +end +module Ext_buffer : sig +#1 "ext_buffer.mli" +(***********************************************************************) +(* *) +(* OCaml *) +(* *) +(* Pierre Weis and Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1999 Institut National de Recherche en Informatique et *) +(* en Automatique. All rights reserved. This file is distributed *) +(* under the terms of the GNU Library General Public License, with *) +(* the special exception on linking described in file ../LICENSE. *) +(* *) +(***********************************************************************) -let create l x d r = - let hl = height l and hr = height r in - Node(l, x, d, r, (if hl >= hr then hl + 1 else hr + 1)) +(** Extensible buffers. -let bal l x d r = - let hl = height l and hr = height r in - if hl > hr + 1 then - match l with - | Node (ll, lv, ld, lr, _) when height ll >= height lr -> - create ll lv ld (create lr x d r) - | Node (ll, lv, ld, Node (lrl, lrv, lrd, lrr, _), _) -> - create (create ll lv ld lrl) lrv lrd (create lrr x d r) - | _ -> assert false - else if hr > hl + 1 then - match r with - | Node (rl, rv, rd, rr, _) when height rr >= height rl -> - create (create l x d rl) rv rd rr - | Node (Node (rll, rlv, rld, rlr, _), rv, rd, rr, _) -> - create (create l x d rll) rlv rld (create rlr rv rd rr) - | _ -> assert false - else - create l x d r + This module implements buffers that automatically expand + as necessary. It provides accumulative concatenation of strings + in quasi-linear time (instead of quadratic time when strings are + concatenated pairwise). +*) -let rec add x data = function - Empty -> - Node(Empty, x, data, Empty, 1) - | Node(l, v, d, r, h) -> - let c = compare x v in - if c = 0 then - Node(l, x, data, r, h) - else if c < 0 then - bal (add x data l) v d r - else - bal l v d (add x data r) +(* BuckleScript customization: customized for efficient digest *) -let rec find x = function - Empty -> - raise Not_found - | Node(l, v, d, r, _) -> - let c = compare x v in - if c = 0 then d - else find x (if c < 0 then l else r) +type t +(** The abstract type of buffers. *) -let rec find_str (x : string) = function - Empty -> - raise Not_found - | Node(l, v, d, r, _) -> - let c = compare x v in - if c = 0 then d - else find_str x (if c < 0 then l else r) +val create : int -> t +(** [create n] returns a fresh buffer, initially empty. + The [n] parameter is the initial size of the internal byte sequence + that holds the buffer contents. That byte sequence is automatically + reallocated when more than [n] characters are stored in the buffer, + but shrinks back to [n] characters when [reset] is called. + For best performance, [n] should be of the same order of magnitude + as the number of characters that are expected to be stored in + the buffer (for instance, 80 for a buffer that holds one output + line). Nothing bad will happen if the buffer grows beyond that + limit, however. In doubt, take [n = 16] for instance. + If [n] is not between 1 and {!Sys.max_string_length}, it will + be clipped to that interval. *) -let rec mem x = function - Empty -> false - | Node(l, v, _d, r, _) -> - let c = compare x v in - c = 0 || mem x (if c < 0 then l else r) +val contents : t -> string +(** Return a copy of the current contents of the buffer. + The buffer itself is unchanged. *) -let rec merge t1 t2 = - match (t1, t2) with - (Empty, t) -> t - | (t, Empty) -> t - | (Node(l1, v1, d1, r1, _h1), Node(l2, v2, d2, r2, _h2)) -> - bal l1 v1 d1 (bal (merge r1 l2) v2 d2 r2) +val length : t -> int +(** Return the number of characters currently contained in the buffer. *) -let rec remove x = function - Empty -> - Empty - | Node(l, v, d, r, _h) -> - let c = compare x v in - if c = 0 then - merge l r - else if c < 0 then - bal (remove x l) v d r - else - bal l v d (remove x r) +val is_empty : t -> bool -let rec iter f = function - Empty -> () - | Node(l, v, d, r, _) -> - iter f l; f v d; iter f r +val clear : t -> unit +(** Empty the buffer. *) -let rec map f = function - Empty -> Empty - | Node(l, v, d, r, h) -> Node(map f l, v, f v d, map f r, h) -let rec fold f m accu = - match m with - | Empty -> accu - | Node(l, v, d, r, _) -> - fold f r (f v d (fold f l accu)) +val add_char : t -> char -> unit +(** [add_char b c] appends the character [c] at the end of the buffer [b]. *) -open Format +val add_string : t -> string -> unit +(** [add_string b s] appends the string [s] at the end of the buffer [b]. *) -let print print_key print_data ppf tbl = - let print_tbl ppf tbl = - iter (fun k d -> fprintf ppf "@[<2>%a ->@ %a;@]@ " print_key k print_data d) - tbl in - fprintf ppf "@[[[%a]]@]" print_tbl tbl +val add_bytes : t -> bytes -> unit +(** [add_string b s] appends the string [s] at the end of the buffer [b]. + @since 4.02 *) -end -module Subst : sig -#1 "subst.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +val add_substring : t -> string -> int -> int -> unit +(** [add_substring b s ofs len] takes [len] characters from offset + [ofs] in string [s] and appends them at the end of the buffer [b]. *) -(* Substitutions *) +val add_subbytes : t -> bytes -> int -> int -> unit +(** [add_substring b s ofs len] takes [len] characters from offset + [ofs] in byte sequence [s] and appends them at the end of the buffer [b]. + @since 4.02 *) -open Types +val add_buffer : t -> t -> unit +(** [add_buffer b1 b2] appends the current contents of buffer [b2] + at the end of buffer [b1]. [b2] is not modified. *) -type t +val add_channel : t -> in_channel -> int -> unit +(** [add_channel b ic n] reads exactly [n] character from the + input channel [ic] and stores them at the end of buffer [b]. + Raise [End_of_file] if the channel contains fewer than [n] + characters. *) -(* - Substitutions are used to translate a type from one context to - another. This requires substituting paths for identifiers, and - possibly also lowering the level of non-generic variables so that - they are inferior to the maximum level of the new context. +val output_buffer : out_channel -> t -> unit +(** [output_buffer oc b] writes the current contents of buffer [b] + on the output channel [oc]. *) - Substitutions can also be used to create a "clean" copy of a type. - Indeed, non-variable node of a type are duplicated, with their - levels set to generic level. That way, the resulting type is - well-formed (decreasing levels), even if the original one was not. -*) +val digest : t -> Digest.t -val identity: t +val not_equal : + t -> + string -> + bool -val add_type: Ident.t -> Path.t -> t -> t -val add_type_path: Path.t -> Path.t -> t -> t -val add_type_function: - Path.t -> params:type_expr list -> body:type_expr -> t -> t -val add_module: Ident.t -> Path.t -> t -> t -val add_module_path: Path.t -> Path.t -> t -> t -val add_modtype: Ident.t -> module_type -> t -> t -val for_saving: t -> t -val reset_for_saving: unit -> unit +val add_int_1 : + t -> int -> unit -val module_path: t -> Path.t -> Path.t -val type_path: t -> Path.t -> Path.t +val add_int_2 : + t -> int -> unit -val type_expr: t -> type_expr -> type_expr -val class_type: t -> class_type -> class_type -val value_description: t -> value_description -> value_description -val type_declaration: t -> type_declaration -> type_declaration -val extension_constructor: - t -> extension_constructor -> extension_constructor -val class_declaration: t -> class_declaration -> class_declaration -val cltype_declaration: t -> class_type_declaration -> class_type_declaration -val modtype: t -> module_type -> module_type -val signature: t -> signature -> signature -val modtype_declaration: t -> modtype_declaration -> modtype_declaration -val module_declaration: t -> module_declaration -> module_declaration -val typexp : t -> Types.type_expr -> Types.type_expr -val class_signature: t -> class_signature -> class_signature +val add_int_3 : + t -> int -> unit -(* Composition of substitutions: - apply (compose s1 s2) x = apply s2 (apply s1 x) *) -val compose: t -> t -> t +val add_int_4 : + t -> int -> unit -(* A forward reference to be filled in ctype.ml. *) -val ctype_apply_env_empty: - (type_expr list -> type_expr -> type_expr list -> type_expr) ref +val add_string_char : + t -> + string -> + char -> + unit +val add_char_string : + t -> + char -> + string -> + unit end = struct -#1 "subst.ml" +#1 "ext_buffer.ml" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* Pierre Weis and Xavier Leroy, projet Cristal, INRIA Rocquencourt *) (* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* Copyright 1999 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -39749,3214 +39577,2876 @@ end = struct (* *) (**************************************************************************) -(* Substitutions *) +(* Extensible buffers *) -open Misc -open Path -open Types -open Btype +type t = + {mutable buffer : bytes; + mutable position : int; + mutable length : int; + initial_buffer : bytes} -type type_replacement = - | Path of Path.t - | Type_function of { params : type_expr list; body : type_expr } +let create n = + let n = if n < 1 then 1 else n in + + let n = if n > Sys.max_string_length then Sys.max_string_length else n in + + let s = Bytes.create n in + {buffer = s; position = 0; length = n; initial_buffer = s} -module PathMap = Map.Make(Path) +let contents b = Bytes.sub_string b.buffer 0 b.position +let to_bytes b = Bytes.sub b.buffer 0 b.position -type t = - { types: type_replacement PathMap.t; - modules: Path.t PathMap.t; - modtypes: (Ident.t, module_type) Tbl.t; - for_saving: bool; - } +let sub b ofs len = + if ofs < 0 || len < 0 || ofs > b.position - len + then invalid_arg "Ext_buffer.sub" + else Bytes.sub_string b.buffer ofs len -let identity = - { types = PathMap.empty; - modules = PathMap.empty; - modtypes = Tbl.empty; - for_saving = false; - } -let add_type_path id p s = { s with types = PathMap.add id (Path p) s.types } -let add_type id p s = add_type_path (Pident id) p s +let blit src srcoff dst dstoff len = + if len < 0 || srcoff < 0 || srcoff > src.position - len + || dstoff < 0 || dstoff > (Bytes.length dst) - len + then invalid_arg "Ext_buffer.blit" + else + Bytes.unsafe_blit src.buffer srcoff dst dstoff len -let add_type_function id ~params ~body s = - { s with types = PathMap.add id (Type_function { params; body }) s.types } +let length b = b.position +let is_empty b = b.position = 0 +let clear b = b.position <- 0 -let add_module_path id p s = { s with modules = PathMap.add id p s.modules } -let add_module id p s = add_module_path (Pident id) p s +let reset b = + b.position <- 0; b.buffer <- b.initial_buffer; + b.length <- Bytes.length b.buffer -let add_modtype id ty s = { s with modtypes = Tbl.add id ty s.modtypes } +let resize b more = + let len = b.length in + let new_len = ref len in + while b.position + more > !new_len do new_len := 2 * !new_len done; + + if !new_len > Sys.max_string_length then begin + if b.position + more <= Sys.max_string_length + then new_len := Sys.max_string_length + else failwith "Ext_buffer.add: cannot grow buffer" + end; + + let new_buffer = Bytes.create !new_len in + (* PR#6148: let's keep using [blit] rather than [unsafe_blit] in + this tricky function that is slow anyway. *) + Bytes.blit b.buffer 0 new_buffer 0 b.position; + b.buffer <- new_buffer; + b.length <- !new_len ; + assert (b.position + more <= b.length) -let for_saving s = { s with for_saving = true } +let add_char b c = + let pos = b.position in + if pos >= b.length then resize b 1; + Bytes.unsafe_set b.buffer pos c; + b.position <- pos + 1 -let loc s x = - if s.for_saving && not !Clflags.keep_locs then Location.none else x +let add_substring b s offset len = + if offset < 0 || len < 0 || offset > String.length s - len + then invalid_arg "Ext_buffer.add_substring/add_subbytes"; + let new_position = b.position + len in + if new_position > b.length then resize b len; + Ext_bytes.unsafe_blit_string s offset b.buffer b.position len; + b.position <- new_position -let remove_loc = - let open Ast_mapper in - {default_mapper with location = (fun _this _loc -> Location.none)} -let is_not_doc = function - | ({Location.txt = "ocaml.doc"}, _) -> false - | ({Location.txt = "ocaml.text"}, _) -> false - | ({Location.txt = "doc"}, _) -> false - | ({Location.txt = "text"}, _) -> false - | _ -> true +let add_subbytes b s offset len = + add_substring b (Bytes.unsafe_to_string s) offset len -let attrs s x = - let x = - if s.for_saving && not !Clflags.keep_docs then - List.filter is_not_doc x - else x - in - if s.for_saving && not !Clflags.keep_locs - then remove_loc.Ast_mapper.attributes remove_loc x - else x +let add_string b s = + let len = String.length s in + let new_position = b.position + len in + if new_position > b.length then resize b len; + Ext_bytes.unsafe_blit_string s 0 b.buffer b.position len; + b.position <- new_position -let rec module_path s path = - try PathMap.find path s.modules - with Not_found -> - match path with - | Pident _ -> path - | Pdot(p, n, pos) -> - Pdot(module_path s p, n, pos) - | Papply(p1, p2) -> - Papply(module_path s p1, module_path s p2) +(* TODO: micro-optimzie *) +let add_string_char b s c = + let s_len = String.length s in + let len = s_len + 1 in + let new_position = b.position + len in + if new_position > b.length then resize b len; + let b_buffer = b.buffer in + Ext_bytes.unsafe_blit_string s 0 b_buffer b.position s_len; + Bytes.unsafe_set b_buffer (new_position - 1) c; + b.position <- new_position -let modtype_path s = function - Pident id as p -> - begin try - match Tbl.find id s.modtypes with - | Mty_ident p -> p - | _ -> fatal_error "Subst.modtype_path" - with Not_found -> p end - | Pdot(p, n, pos) -> - Pdot(module_path s p, n, pos) - | Papply _ -> - fatal_error "Subst.modtype_path" +let add_char_string b c s = + let s_len = String.length s in + let len = s_len + 1 in + let new_position = b.position + len in + if new_position > b.length then resize b len; + let b_buffer = b.buffer in + let b_position = b.position in + Bytes.unsafe_set b_buffer b_position c ; + Ext_bytes.unsafe_blit_string s 0 b_buffer (b_position + 1) s_len; + b.position <- new_position -let type_path s path = - match PathMap.find path s.types with - | Path p -> p - | Type_function _ -> assert false - | exception Not_found -> - match path with - | Pident _ -> path - | Pdot(p, n, pos) -> - Pdot(module_path s p, n, pos) - | Papply _ -> - fatal_error "Subst.type_path" -let type_path s p = - match Path.constructor_typath p with - | Regular p -> type_path s p - | Cstr (ty_path, cstr) -> Pdot(type_path s ty_path, cstr, nopos) - | LocalExt _ -> type_path s p - | Ext (p, cstr) -> Pdot(module_path s p, cstr, nopos) +let add_bytes b s = add_string b (Bytes.unsafe_to_string s) -let to_subst_by_type_function s p = - match PathMap.find p s.types with - | Path _ -> false - | Type_function _ -> true - | exception Not_found -> false +let add_buffer b bs = + add_subbytes b bs.buffer 0 bs.position -(* Special type ids for saved signatures *) +let add_channel b ic len = + if len < 0 -let new_id = ref (-1) -let reset_for_saving () = new_id := -1 + || len > Sys.max_string_length -let newpersty desc = - decr new_id; - { desc = desc; level = generic_level; id = !new_id } + then (* PR#5004 *) + invalid_arg "Ext_buffer.add_channel"; + if b.position + len > b.length then resize b len; + really_input ic b.buffer b.position len; + b.position <- b.position + len -(* ensure that all occurrences of 'Tvar None' are physically shared *) -let tvar_none = Tvar None -let tunivar_none = Tunivar None -let norm = function - | Tvar None -> tvar_none - | Tunivar None -> tunivar_none - | d -> d +let output_buffer oc b = + output oc b.buffer 0 b.position -let ctype_apply_env_empty = ref (fun _ -> assert false) +external unsafe_string: bytes -> int -> int -> Digest.t = "caml_md5_string" -(* Similar to [Ctype.nondep_type_rec]. *) -let rec typexp s ty = - let ty = repr ty in - match ty.desc with - Tvar _ | Tunivar _ as desc -> - if s.for_saving || ty.id < 0 then - let ty' = - if s.for_saving then newpersty (norm desc) - else newty2 ty.level desc - in - save_desc ty desc; ty.desc <- Tsubst ty'; ty' - else ty - | Tsubst ty -> - ty - | Tfield (m, k, _t1, _t2) when not s.for_saving && m = dummy_method - && field_kind_repr k <> Fabsent && (repr ty).level < generic_level -> - (* do not copy the type of self when it is not generalized *) - ty -(* cannot do it, since it would omit substitution - | Tvariant row when not (static_row row) -> - ty -*) - | _ -> - let desc = ty.desc in - save_desc ty desc; - let tm = row_of_type ty in - let has_fixed_row = - not (is_Tconstr ty) && is_constr_row ~allow_ident:false tm in - (* Make a stub *) - let ty' = if s.for_saving then newpersty (Tvar None) else newgenvar () in - ty.desc <- Tsubst ty'; - ty'.desc <- - begin if has_fixed_row then - match tm.desc with (* PR#7348 *) - Tconstr (Pdot(m,i,pos), tl, _abbrev) -> - let i' = String.sub i 0 (String.length i - 4) in - Tconstr(type_path s (Pdot(m,i',pos)), tl, ref Mnil) - | _ -> assert false - else match desc with - | Tconstr (p, args, _abbrev) -> - let args = List.map (typexp s) args in - begin match PathMap.find p s.types with - | exception Not_found -> Tconstr(type_path s p, args, ref Mnil) - | Path _ -> Tconstr(type_path s p, args, ref Mnil) - | Type_function { params; body } -> - (!ctype_apply_env_empty params body args).desc - end - | Tpackage(p, n, tl) -> - Tpackage(modtype_path s p, n, List.map (typexp s) tl) - | Tobject (t1, name) -> - Tobject (typexp s t1, - ref (match !name with - None -> None - | Some (p, tl) -> - if to_subst_by_type_function s p - then None - else Some (type_path s p, List.map (typexp s) tl))) - | Tvariant row -> - let row = row_repr row in - let more = repr row.row_more in - (* We must substitute in a subtle way *) - (* Tsubst takes a tuple containing the row var and the variant *) - begin match more.desc with - Tsubst {desc = Ttuple [_;ty2]} -> - (* This variant type has been already copied *) - ty.desc <- Tsubst ty2; (* avoid Tlink in the new type *) - Tlink ty2 - | _ -> - let dup = - s.for_saving || more.level = generic_level || static_row row || - match more.desc with Tconstr _ -> true | _ -> false in - (* Various cases for the row variable *) - let more' = - match more.desc with - Tsubst ty -> ty - | Tconstr _ | Tnil -> typexp s more - | Tunivar _ | Tvar _ -> - save_desc more more.desc; - if s.for_saving then newpersty (norm more.desc) else - if dup && is_Tvar more then newgenty more.desc else more - | _ -> assert false - in - (* Register new type first for recursion *) - more.desc <- Tsubst(newgenty(Ttuple[more';ty'])); - (* Return a new copy *) - let row = - copy_row (typexp s) true row (not dup) more' in - match row.row_name with - | Some (p, tl) -> - Tvariant {row with row_name = - if to_subst_by_type_function s p - then None - else Some (type_path s p, tl)} - | None -> - Tvariant row - end - | Tfield(_label, kind, _t1, t2) when field_kind_repr kind = Fabsent -> - Tlink (typexp s t2) - | _ -> copy_type_desc (typexp s) desc - end; - ty' +let digest b = + unsafe_string + b.buffer 0 b.position -(* - Always make a copy of the type. If this is not done, type levels - might not be correct. -*) -let type_expr s ty = - let ty' = typexp s ty in - cleanup_types (); - ty' +let rec not_equal_aux (b : bytes) (s : string) i len = + if i >= len then false + else + (Bytes.unsafe_get b i + <> + String.unsafe_get s i ) + || not_equal_aux b s (i + 1) len -let label_declaration s l = - { - ld_id = l.ld_id; - ld_mutable = l.ld_mutable; - ld_type = typexp s l.ld_type; - ld_loc = loc s l.ld_loc; - ld_attributes = attrs s l.ld_attributes; - } +(** avoid a large copy *) +let not_equal (b : t) (s : string) = + let b_len = b.position in + let s_len = String.length s in + b_len <> s_len + || not_equal_aux b.buffer s 0 s_len -let constructor_arguments s = function - | Cstr_tuple l -> - Cstr_tuple (List.map (typexp s) l) - | Cstr_record l -> - Cstr_record (List.map (label_declaration s) l) -let constructor_declaration s c = - { - cd_id = c.cd_id; - cd_args = constructor_arguments s c.cd_args; - cd_res = may_map (typexp s) c.cd_res; - cd_loc = loc s c.cd_loc; - cd_attributes = attrs s c.cd_attributes; - } +(** + It could be one byte, two bytes, three bytes and four bytes + TODO: inline for better performance +*) +let add_int_1 (b : t ) (x : int ) = + let c = (Char.unsafe_chr (x land 0xff)) in + let pos = b.position in + if pos >= b.length then resize b 1; + Bytes.unsafe_set b.buffer pos c; + b.position <- pos + 1 + +let add_int_2 (b : t ) (x : int ) = + let c1 = (Char.unsafe_chr (x land 0xff)) in + let c2 = (Char.unsafe_chr (x lsr 8 land 0xff)) in + let pos = b.position in + if pos + 1 >= b.length then resize b 2; + let b_buffer = b.buffer in + Bytes.unsafe_set b_buffer pos c1; + Bytes.unsafe_set b_buffer (pos + 1) c2; + b.position <- pos + 2 -let type_declaration s decl = - let decl = - { type_params = List.map (typexp s) decl.type_params; - type_arity = decl.type_arity; - type_kind = - begin match decl.type_kind with - Type_abstract -> Type_abstract - | Type_variant cstrs -> - Type_variant (List.map (constructor_declaration s) cstrs) - | Type_record(lbls, rep) -> - Type_record (List.map (label_declaration s) lbls, rep) - | Type_open -> Type_open - end; - type_manifest = - begin - match decl.type_manifest with - None -> None - | Some ty -> Some(typexp s ty) - end; - type_private = decl.type_private; - type_variance = decl.type_variance; - type_newtype_level = None; - type_loc = loc s decl.type_loc; - type_attributes = attrs s decl.type_attributes; - type_immediate = decl.type_immediate; - type_unboxed = decl.type_unboxed; - } - in - cleanup_types (); - decl +let add_int_3 (b : t ) (x : int ) = + let c1 = (Char.unsafe_chr (x land 0xff)) in + let c2 = (Char.unsafe_chr (x lsr 8 land 0xff)) in + let c3 = (Char.unsafe_chr (x lsr 16 land 0xff)) in + let pos = b.position in + if pos + 2 >= b.length then resize b 3; + let b_buffer = b.buffer in + Bytes.unsafe_set b_buffer pos c1; + Bytes.unsafe_set b_buffer (pos + 1) c2; + Bytes.unsafe_set b_buffer (pos + 2) c3; + b.position <- pos + 3 -let class_signature s sign = - { csig_self = typexp s sign.csig_self; - csig_vars = - Vars.map (function (m, v, t) -> (m, v, typexp s t)) sign.csig_vars; - csig_concr = sign.csig_concr; - csig_inher = - List.map (fun (p, tl) -> (type_path s p, List.map (typexp s) tl)) - sign.csig_inher; - } -let rec class_type s = - function - Cty_constr (p, tyl, cty) -> - Cty_constr (type_path s p, List.map (typexp s) tyl, class_type s cty) - | Cty_signature sign -> - Cty_signature (class_signature s sign) - | Cty_arrow (l, ty, cty) -> - Cty_arrow (l, typexp s ty, class_type s cty) +let add_int_4 (b : t ) (x : int ) = + let c1 = (Char.unsafe_chr (x land 0xff)) in + let c2 = (Char.unsafe_chr (x lsr 8 land 0xff)) in + let c3 = (Char.unsafe_chr (x lsr 16 land 0xff)) in + let c4 = (Char.unsafe_chr (x lsr 24 land 0xff)) in + let pos = b.position in + if pos + 3 >= b.length then resize b 4; + let b_buffer = b.buffer in + Bytes.unsafe_set b_buffer pos c1; + Bytes.unsafe_set b_buffer (pos + 1) c2; + Bytes.unsafe_set b_buffer (pos + 2) c3; + Bytes.unsafe_set b_buffer (pos + 3) c4; + b.position <- pos + 4 -let class_declaration s decl = - let decl = - { cty_params = List.map (typexp s) decl.cty_params; - cty_variance = decl.cty_variance; - cty_type = class_type s decl.cty_type; - cty_path = type_path s decl.cty_path; - cty_new = - begin match decl.cty_new with - None -> None - | Some ty -> Some (typexp s ty) - end; - cty_loc = loc s decl.cty_loc; - cty_attributes = attrs s decl.cty_attributes; - } - in - (* Do not clean up if saving: next is cltype_declaration *) - if not s.for_saving then cleanup_types (); - decl -let cltype_declaration s decl = - let decl = - { clty_params = List.map (typexp s) decl.clty_params; - clty_variance = decl.clty_variance; - clty_type = class_type s decl.clty_type; - clty_path = type_path s decl.clty_path; - clty_loc = loc s decl.clty_loc; - clty_attributes = attrs s decl.clty_attributes; - } - in - (* Do clean up even if saving: type_declaration may be recursive *) - cleanup_types (); - decl -let class_type s cty = - let cty = class_type s cty in - cleanup_types (); - cty -let value_description s descr = - { val_type = type_expr s descr.val_type; - val_kind = descr.val_kind; - val_loc = loc s descr.val_loc; - val_attributes = attrs s descr.val_attributes; - } +end +module Ext_char : sig +#1 "ext_char.mli" +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) + + -let extension_constructor s ext = - let ext = - { ext_type_path = type_path s ext.ext_type_path; - ext_type_params = List.map (typexp s) ext.ext_type_params; - ext_args = constructor_arguments s ext.ext_args; - ext_ret_type = may_map (typexp s) ext.ext_ret_type; - ext_private = ext.ext_private; - ext_attributes = attrs s ext.ext_attributes; - ext_loc = if s.for_saving then Location.none else ext.ext_loc; } - in - cleanup_types (); - ext -let rec rename_bound_idents s idents = function - [] -> (List.rev idents, s) - | Sig_type(id, _, _) :: sg -> - let id' = Ident.rename id in - rename_bound_idents (add_type id (Pident id') s) (id' :: idents) sg - | Sig_module(id, _, _) :: sg -> - let id' = Ident.rename id in - rename_bound_idents (add_module id (Pident id') s) (id' :: idents) sg - | Sig_modtype(id, _) :: sg -> - let id' = Ident.rename id in - rename_bound_idents (add_modtype id (Mty_ident(Pident id')) s) - (id' :: idents) sg - | (Sig_class(id, _, _) | Sig_class_type(id, _, _)) :: sg -> - (* cheat and pretend they are types cf. PR#6650 *) - let id' = Ident.rename id in - rename_bound_idents (add_type id (Pident id') s) (id' :: idents) sg - | (Sig_value(id, _) | Sig_typext(id, _, _)) :: sg -> - let id' = Ident.rename id in - rename_bound_idents s (id' :: idents) sg -let rec modtype s = function - Mty_ident p as mty -> - begin match p with - Pident id -> - begin try Tbl.find id s.modtypes with Not_found -> mty end - | Pdot(p, n, pos) -> - Mty_ident(Pdot(module_path s p, n, pos)) - | Papply _ -> - fatal_error "Subst.modtype" - end - | Mty_signature sg -> - Mty_signature(signature s sg) - | Mty_functor(id, arg, res) -> - let id' = Ident.rename id in - Mty_functor(id', may_map (modtype s) arg, - modtype (add_module id (Pident id') s) res) - | Mty_alias(pres, p) -> - Mty_alias(pres, module_path s p) -and signature s sg = - (* Components of signature may be mutually recursive (e.g. type declarations - or class and type declarations), so first build global renaming - substitution... *) - let (new_idents, s') = rename_bound_idents s [] sg in - (* ... then apply it to each signature component in turn *) - List.map2 (signature_component s') sg new_idents +(** Extension to Standard char module, avoid locale sensitivity *) -and signature_component s comp newid = - match comp with - Sig_value(_id, d) -> - Sig_value(newid, value_description s d) - | Sig_type(_id, d, rs) -> - Sig_type(newid, type_declaration s d, rs) - | Sig_typext(_id, ext, es) -> - Sig_typext(newid, extension_constructor s ext, es) - | Sig_module(_id, d, rs) -> - Sig_module(newid, module_declaration s d, rs) - | Sig_modtype(_id, d) -> - Sig_modtype(newid, modtype_declaration s d) - | Sig_class(_id, d, rs) -> - Sig_class(newid, class_declaration s d, rs) - | Sig_class_type(_id, d, rs) -> - Sig_class_type(newid, cltype_declaration s d, rs) +val escaped : char -> string -and module_declaration s decl = - { - md_type = modtype s decl.md_type; - md_attributes = attrs s decl.md_attributes; - md_loc = loc s decl.md_loc; - } -and modtype_declaration s decl = - { - mtd_type = may_map (modtype s) decl.mtd_type; - mtd_attributes = attrs s decl.mtd_attributes; - mtd_loc = loc s decl.mtd_loc; - } +val valid_hex : char -> bool -(* For every binding k |-> d of m1, add k |-> f d to m2 - and return resulting merged map. *) +val is_lower_case : char -> bool -let merge_tbls f m1 m2 = - Tbl.fold (fun k d accu -> Tbl.add k (f d) accu) m1 m2 +val uppercase_ascii : char -> char -let merge_path_maps f m1 m2 = - PathMap.fold (fun k d accu -> PathMap.add k (f d) accu) m1 m2 +val lowercase_ascii : char -> char +end = struct +#1 "ext_char.ml" +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -let type_replacement s = function - | Path p -> Path (type_path s p) - | Type_function { params; body } -> - let params = List.map (typexp s) params in - let body = typexp s body in - Type_function { params; body } -(* Composition of substitutions: - apply (compose s1 s2) x = apply s2 (apply s1 x) *) -let compose s1 s2 = - { types = merge_path_maps (type_replacement s2) s1.types s2.types; - modules = merge_path_maps (module_path s2) s1.modules s2.modules; - modtypes = merge_tbls (modtype s2) s1.modtypes s2.modtypes; - for_saving = s1.for_saving || s2.for_saving; - } -end -module Env : sig -#1 "env.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) -(* Environment handling *) +(** {!Char.escaped} is locale sensitive in 4.02.3, fixed in the trunk, + backport it here + *) + +let escaped = Char.escaped -open Types -module PathMap : Map.S with type key = Path.t - and type 'a t = 'a Map.Make(Path).t +let valid_hex x = + match x with + | '0' .. '9' + | 'a' .. 'f' + | 'A' .. 'F' -> true + | _ -> false -type summary = - Env_empty - | Env_value of summary * Ident.t * value_description - | Env_type of summary * Ident.t * type_declaration - | Env_extension of summary * Ident.t * extension_constructor - | Env_module of summary * Ident.t * module_declaration - | Env_modtype of summary * Ident.t * modtype_declaration - | Env_class of summary * Ident.t * class_declaration - | Env_cltype of summary * Ident.t * class_type_declaration - | Env_open of summary * Path.t - | Env_functor_arg of summary * Ident.t - | Env_constraints of summary * type_declaration PathMap.t - | Env_copy_types of summary * string list -type t -val empty: t -val initial_safe_string: t -val initial_unsafe_string: t -val diff: t -> t -> Ident.t list -val copy_local: from:t -> t -> t +let is_lower_case c = + (c >= 'a' && c <= 'z') + || (c >= '\224' && c <= '\246') + || (c >= '\248' && c <= '\254') +let uppercase_ascii = -type type_descriptions = - constructor_description list * label_description list + Char.uppercase_ascii + -(* For short-paths *) -type iter_cont -val iter_types: - (Path.t -> Path.t * (type_declaration * type_descriptions) -> unit) -> - t -> iter_cont -val run_iter_cont: iter_cont list -> (Path.t * iter_cont) list -val same_types: t -> t -> bool -val used_persistent: unit -> Concr.t -val find_shadowed_types: Path.t -> t -> Path.t list -val without_cmis: ('a -> 'b) -> 'a -> 'b - (* [without_cmis f arg] applies [f] to [arg], but does not - allow opening cmis during its execution *) +let lowercase_ascii = -(* Lookup by paths *) + Char.lowercase_ascii + -val find_value: Path.t -> t -> value_description -val find_type: Path.t -> t -> type_declaration -val find_type_descrs: Path.t -> t -> type_descriptions -val find_module: Path.t -> t -> module_declaration -val find_modtype: Path.t -> t -> modtype_declaration -val find_class: Path.t -> t -> class_declaration -val find_cltype: Path.t -> t -> class_type_declaration +end +module Literals : sig +#1 "literals.mli" +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -val find_type_expansion: - Path.t -> t -> type_expr list * type_expr * int option -val find_type_expansion_opt: - Path.t -> t -> type_expr list * type_expr * int option -(* Find the manifest type information associated to a type for the sake - of the compiler's type-based optimisations. *) -val find_modtype_expansion: Path.t -> t -> module_type -val add_functor_arg: Ident.t -> t -> t -val is_functor_arg: Path.t -> t -> bool -val normalize_path: Location.t option -> t -> Path.t -> Path.t -(* Normalize the path to a concrete value or module. - If the option is None, allow returning dangling paths. - Otherwise raise a Missing_module error, and may add forgotten - head as required global. *) -val normalize_path_prefix: Location.t option -> t -> Path.t -> Path.t -(* Only normalize the prefix part of the path *) -val reset_required_globals: unit -> unit -val get_required_globals: unit -> Ident.t list -val add_required_global: Ident.t -> unit -val has_local_constraints: t -> bool -val add_gadt_instance_level: int -> t -> t -val gadt_instance_level: t -> type_expr -> int option -val add_gadt_instances: t -> int -> type_expr list -> unit -val add_gadt_instance_chain: t -> int -> type_expr -> unit -(* Lookup by long identifiers *) -(* ?loc is used to report 'deprecated module' warnings *) -val lookup_value: - ?loc:Location.t -> Longident.t -> t -> Path.t * value_description -val lookup_constructor: - ?loc:Location.t -> Longident.t -> t -> constructor_description -val lookup_all_constructors: - ?loc:Location.t -> - Longident.t -> t -> (constructor_description * (unit -> unit)) list -val lookup_label: - ?loc:Location.t -> Longident.t -> t -> label_description -val lookup_all_labels: - ?loc:Location.t -> - Longident.t -> t -> (label_description * (unit -> unit)) list -val lookup_type: - ?loc:Location.t -> Longident.t -> t -> Path.t - (* Since 4.04, this function no longer returns [type_description]. - To obtain it, you should either call [Env.find_type], or replace - it by [Typetexp.find_type] *) -val lookup_module: - load:bool -> ?loc:Location.t -> Longident.t -> t -> Path.t -val lookup_modtype: - ?loc:Location.t -> Longident.t -> t -> Path.t * modtype_declaration -val lookup_class: - ?loc:Location.t -> Longident.t -> t -> Path.t * class_declaration -val lookup_cltype: - ?loc:Location.t -> Longident.t -> t -> Path.t * class_type_declaration -val copy_types: string list -> t -> t - (* Used only in Typecore.duplicate_ident_types. *) +val js_array_ctor : string +val js_type_number : string +val js_type_string : string +val js_type_object : string +val js_type_boolean : string +val js_undefined : string +val js_prop_length : string -exception Recmodule - (* Raise by lookup_module when the identifier refers - to one of the modules of a recursive definition - during the computation of its approximation (see #5965). *) +val param : string +val partial_arg : string +val prim : string -(* Insertion by identifier *) +(**temporary varaible used in {!Js_ast_util} *) +val tmp : string -val add_value: - ?check:(string -> Warnings.t) -> Ident.t -> value_description -> t -> t -val add_type: check:bool -> Ident.t -> type_declaration -> t -> t -val add_extension: check:bool -> Ident.t -> extension_constructor -> t -> t -val add_module: ?arg:bool -> Ident.t -> module_type -> t -> t -val add_module_declaration: ?arg:bool -> check:bool -> Ident.t -> - module_declaration -> t -> t -val add_modtype: Ident.t -> modtype_declaration -> t -> t -val add_class: Ident.t -> class_declaration -> t -> t -val add_cltype: Ident.t -> class_type_declaration -> t -> t -val add_local_constraint: Path.t -> type_declaration -> int -> t -> t -val add_local_type: Path.t -> type_declaration -> t -> t +val create : string +val runtime : string +val stdlib : string +val imul : string -(* Insertion of all fields of a signature. *) +val setter_suffix : string +val setter_suffix_len : int -val add_item: signature_item -> t -> t -val add_signature: signature -> t -> t -(* Insertion of all fields of a signature, relative to the given path. - Used to implement open. Returns None if the path refers to a functor, - not a structure. *) -val open_signature: - ?used_slot:bool ref -> - ?loc:Location.t -> ?toplevel:bool -> Asttypes.override_flag -> Path.t -> - t -> t option +val debugger : string +val raw_expr : string +val raw_stmt : string +val raw_function : string +val unsafe_downgrade : string +val fn_run : string +val method_run : string +val fn_method : string +val fn_mk : string -val open_pers_signature: string -> t -> t +(** callback actually, not exposed to user yet *) +(* val js_fn_runmethod : string *) -(* Insertion by name *) +val bs_deriving : string +val bs_deriving_dot : string +val bs_type : string -val enter_value: - ?check:(string -> Warnings.t) -> - string -> value_description -> t -> Ident.t * t -val enter_type: string -> type_declaration -> t -> Ident.t * t -val enter_extension: string -> extension_constructor -> t -> Ident.t * t -val enter_module: ?arg:bool -> string -> module_type -> t -> Ident.t * t -val enter_module_declaration: - ?arg:bool -> Ident.t -> module_declaration -> t -> t -val enter_modtype: string -> modtype_declaration -> t -> Ident.t * t -val enter_class: string -> class_declaration -> t -> Ident.t * t -val enter_cltype: string -> class_type_declaration -> t -> Ident.t * t +(** nodejs *) -(* Initialize the cache of in-core module interfaces. *) -val reset_cache: unit -> unit +val node_modules : string +val node_modules_length : int +val package_json : string +val bsconfig_json : string +val build_ninja : string -(* To be called before each toplevel phrase. *) -val reset_cache_toplevel: unit -> unit +(* Name of the library file created for each external dependency. *) +val library_file : string -(* Remember the name of the current compilation unit. *) -val set_unit_name: string -> unit -val get_unit_name: unit -> string +val suffix_a : string +val suffix_cmj : string +val suffix_cmo : string +val suffix_cma : string +val suffix_cmi : string +val suffix_cmx : string +val suffix_cmxa : string +val suffix_ml : string +val suffix_mlast : string +val suffix_mlast_simple : string +val suffix_mliast : string +val suffix_reast : string +val suffix_reiast : string -(* Read, save a signature to/from a file *) +val suffix_mliast_simple : string +val suffix_mlmap : string +val suffix_mll : string +val suffix_re : string +val suffix_rei : string -val read_signature: string -> string -> signature - (* Arguments: module name, file name. Results: signature. *) -val save_signature: - ?check_exists:unit -> - deprecated:string option -> signature -> string -> string -> Cmi_format.cmi_infos - (* Arguments: signature, module name, file name. *) -val save_signature_with_imports: - ?check_exists:unit -> - deprecated:string option -> - signature -> string -> string -> (string * Digest.t option) list - -> Cmi_format.cmi_infos - (* Arguments: signature, module name, file name, - imported units with their CRCs. *) +val suffix_d : string +val suffix_js : string +val suffix_bs_js : string +(* val suffix_re_js : string *) +val suffix_gen_js : string +val suffix_gen_tsx: string -(* Return the CRC of the interface of the given compilation unit *) +val suffix_tsx : string -val crc_of_unit: string -> Digest.t +val suffix_mli : string +val suffix_cmt : string +val suffix_cmti : string -(* Return the set of compilation units imported, with their CRC *) +val commonjs : string -val imports: unit -> (string * Digest.t option) list +val es6 : string +val es6_global : string -(* [is_imported_opaque md] returns true if [md] is an opaque imported module *) -val is_imported_opaque: string -> bool +val unused_attribute : string +val dash_nostdlib : string -(* Direct access to the table of imported compilation units with their CRC *) +val reactjs_jsx_ppx_2_exe : string +val reactjs_jsx_ppx_3_exe : string -val crc_units: Consistbl.t -val add_import: string -> unit +val native : string +val bytecode : string +val js : string -(* Summaries -- compact representation of an environment, to be - exported in debugging information. *) +val node_sep : string +val node_parent : string +val node_current : string +val gentype_import : string + +val bsbuild_cache : string + +val sourcedirs_meta : string +end = struct +#1 "literals.ml" +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -val summary: t -> summary -(* Return an equivalent environment where all fields have been reset, - except the summary. The initial environment can be rebuilt from the - summary, using Envaux.env_of_only_summary. *) -val keep_only_summary : t -> t -val env_of_only_summary : (summary -> Subst.t -> t) -> t -> t -(* Error report *) -type error = - | Illegal_renaming of string * string * string - | Inconsistent_import of string * string * string - | Need_recursive_types of string * string - | Depend_on_unsafe_string_unit of string * string - | Missing_module of Location.t * Path.t * Path.t - | Illegal_value_name of Location.t * string -exception Error of error -open Format +let js_array_ctor = "Array" +let js_type_number = "number" +let js_type_string = "string" +let js_type_object = "object" +let js_type_boolean = "boolean" +let js_undefined = "undefined" +let js_prop_length = "length" -val report_error: formatter -> error -> unit +let prim = "prim" +let param = "param" +let partial_arg = "partial_arg" +let tmp = "tmp" +let create = "create" (* {!Caml_exceptions.create}*) -val mark_value_used: t -> string -> value_description -> unit -val mark_module_used: t -> string -> Location.t -> unit -val mark_type_used: t -> string -> type_declaration -> unit +let runtime = "runtime" (* runtime directory *) -type constructor_usage = Positive | Pattern | Privatize -val mark_constructor_used: - constructor_usage -> t -> string -> type_declaration -> string -> unit -val mark_constructor: - constructor_usage -> t -> string -> constructor_description -> unit -val mark_extension_used: - constructor_usage -> t -> extension_constructor -> string -> unit +let stdlib = "stdlib" -val in_signature: bool -> t -> t -val implicit_coercion: t -> t +let imul = "imul" (* signed int32 mul *) -val is_in_signature: t -> bool +let setter_suffix = "#=" +let setter_suffix_len = String.length setter_suffix -val set_value_used_callback: - string -> value_description -> (unit -> unit) -> unit -val set_type_used_callback: - string -> type_declaration -> ((unit -> unit) -> unit) -> unit +let debugger = "debugger" +let raw_expr = "raw_expr" +let raw_stmt = "raw_stmt" +let raw_function = "raw_function" +let unsafe_downgrade = "unsafe_downgrade" +let fn_run = "fn_run" +let method_run = "method_run" -(* Forward declaration to break mutual recursion with Includemod. *) -val check_modtype_inclusion: - (loc:Location.t -> t -> module_type -> Path.t -> module_type -> unit) ref -(* Forward declaration to break mutual recursion with Typecore. *) -val add_delayed_check_forward: ((unit -> unit) -> unit) ref -(* Forward declaration to break mutual recursion with Mtype. *) -val strengthen: - (aliasable:bool -> t -> module_type -> Path.t -> module_type) ref -(* Forward declaration to break mutual recursion with Ctype. *) -val same_constr: (t -> type_expr -> type_expr -> bool) ref +let fn_method = "fn_method" +let fn_mk = "fn_mk" +(*let js_fn_runmethod = "js_fn_runmethod"*) -(** Folding over all identifiers (for analysis purpose) *) +let bs_deriving = "bs.deriving" +let bs_deriving_dot = "bs.deriving." +let bs_type = "bs.type" -val fold_values: - (string -> Path.t -> value_description -> 'a -> 'a) -> - Longident.t option -> t -> 'a -> 'a -val fold_types: - (string -> Path.t -> type_declaration * type_descriptions -> 'a -> 'a) -> - Longident.t option -> t -> 'a -> 'a -val fold_constructors: - (constructor_description -> 'a -> 'a) -> - Longident.t option -> t -> 'a -> 'a -val fold_labels: - (label_description -> 'a -> 'a) -> - Longident.t option -> t -> 'a -> 'a -(** Persistent structures are only traversed if they are already loaded. *) -val fold_modules: - (string -> Path.t -> module_declaration -> 'a -> 'a) -> - Longident.t option -> t -> 'a -> 'a +(** nodejs *) +let node_modules = "node_modules" +let node_modules_length = String.length "node_modules" +let package_json = "package.json" +let bsconfig_json = "bsconfig.json" +let build_ninja = "build.ninja" -val fold_modtypes: - (string -> Path.t -> modtype_declaration -> 'a -> 'a) -> - Longident.t option -> t -> 'a -> 'a -val fold_classs: - (string -> Path.t -> class_declaration -> 'a -> 'a) -> - Longident.t option -> t -> 'a -> 'a -val fold_cltypes: - (string -> Path.t -> class_type_declaration -> 'a -> 'a) -> - Longident.t option -> t -> 'a -> 'a +(* Name of the library file created for each external dependency. *) +let library_file = "lib" -(** Utilities *) -val scrape_alias: t -> module_type -> module_type -val check_value_name: string -> Location.t -> unit +let suffix_a = ".a" +let suffix_cmj = ".cmj" +let suffix_cmo = ".cmo" +let suffix_cma = ".cma" +let suffix_cmi = ".cmi" +let suffix_cmx = ".cmx" +let suffix_cmxa = ".cmxa" +let suffix_mll = ".mll" +let suffix_ml = ".ml" +let suffix_mli = ".mli" +let suffix_re = ".re" +let suffix_rei = ".rei" +let suffix_mlmap = ".mlmap" -module Persistent_signature : sig - type t = - { filename : string; (** Name of the file containing the signature. *) - cmi : Cmi_format.cmi_infos } +let suffix_cmt = ".cmt" +let suffix_cmti = ".cmti" +let suffix_mlast = ".mlast" +let suffix_mlast_simple = ".mlast_simple" +let suffix_mliast = ".mliast" +let suffix_reast = ".reast" +let suffix_reiast = ".reiast" +let suffix_mliast_simple = ".mliast_simple" +let suffix_d = ".d" +let suffix_js = ".js" +let suffix_bs_js = ".bs.js" +(* let suffix_re_js = ".re.js" *) +let suffix_gen_js = ".gen.js" +let suffix_gen_tsx = ".gen.tsx" +let suffix_tsx = ".tsx" - (** Function used to load a persistent signature. The default is to look for - the .cmi file in the load path. This function can be overridden to load - it from memory, for instance to build a self-contained toplevel. *) - val load : (unit_name:string -> t option) ref -end +let commonjs = "commonjs" -end = struct -#1 "env.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let es6 = "es6" +let es6_global = "es6-global" -(* Environment handling *) +let unused_attribute = "Unused attribute " +let dash_nostdlib = "-nostdlib" -open Cmi_format -open Config -open Misc -open Asttypes -open Longident -open Path -open Types -open Btype +let reactjs_jsx_ppx_2_exe = "reactjs_jsx_ppx_2.exe" +let reactjs_jsx_ppx_3_exe = "reactjs_jsx_ppx_3.exe" -let add_delayed_check_forward = ref (fun _ -> assert false) +let native = "native" +let bytecode = "bytecode" +let js = "js" -let value_declarations : ((string * Location.t), (unit -> unit)) Hashtbl.t = - Hashtbl.create 16 - (* This table is used to usage of value declarations. A declaration is - identified with its name and location. The callback attached to a - declaration is called whenever the value is used explicitly - (lookup_value) or implicitly (inclusion test between signatures, - cf Includemod.value_descriptions). *) -let type_declarations = Hashtbl.create 16 -let module_declarations = Hashtbl.create 16 -type constructor_usage = Positive | Pattern | Privatize -type constructor_usages = - { - mutable cu_positive: bool; - mutable cu_pattern: bool; - mutable cu_privatize: bool; - } -let add_constructor_usage cu = function - | Positive -> cu.cu_positive <- true - | Pattern -> cu.cu_pattern <- true - | Privatize -> cu.cu_privatize <- true -let constructor_usages () = - {cu_positive = false; cu_pattern = false; cu_privatize = false} +(** Used when produce node compatible paths *) +let node_sep = "/" +let node_parent = ".." +let node_current = "." -let used_constructors : - (string * Location.t * string, (constructor_usage -> unit)) Hashtbl.t - = Hashtbl.create 16 +let gentype_import = "genType.import" -let prefixed_sg = Hashtbl.create 113 +let bsbuild_cache = ".bsbuild" -type error = - | Illegal_renaming of string * string * string - | Inconsistent_import of string * string * string - | Need_recursive_types of string * string - | Depend_on_unsafe_string_unit of string * string - | Missing_module of Location.t * Path.t * Path.t - | Illegal_value_name of Location.t * string +let sourcedirs_meta = ".sourcedirs.json" +end +module Ext_namespace : sig +#1 "ext_namespace.mli" +(* Copyright (C) 2017- Authors of BuckleScript + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -exception Error of error +(** [make ~ns:"Ns" "a" ] + A typical example would return "a-Ns" + Note the namespace comes from the output of [namespace_of_package_name] +*) +val make : + ?ns:string -> string -> string -let error err = raise (Error err) +val try_split_module_name : + string -> (string * string ) option -module EnvLazy : sig - type ('a,'b) t - type log - val force : ('a -> 'b) -> ('a,'b) t -> 'b - val create : 'a -> ('a,'b) t - val get_arg : ('a,'b) t -> 'a option +(* Note we have to output uncapitalized file Name, + or at least be consistent, since by reading cmi file on Case insensitive OS, we don't really know it is `list.cmi` or `List.cmi`, so that `require (./list.js)` or `require(./List.js)` + relevant issues: #1609, #913 - (* [force_logged log f t] is equivalent to [force f t] but if [f] returns [None] then - [t] is recorded in [log]. [backtrack log] will then reset all the recorded [t]s back - to their original state. *) - val log : unit -> log - val force_logged : log -> ('a -> 'b option) -> ('a,'b option) t -> 'b option - val backtrack : log -> unit + #1933 when removing ns suffix, don't pass the bound + of basename +*) +val change_ext_ns_suffix : + string -> + string -> + string -end = struct +type file_kind = + | Upper_js + | Upper_bs + | Little_js + | Little_bs + (** [js_name_of_modulename ~little A-Ns] + *) +val js_name_of_modulename : + string -> + file_kind -> + string - type ('a,'b) t = ('a,'b) eval ref +(* TODO handle cases like + '@angular/core' + its directory structure is like + {[ + @angular + |-------- core + ]} +*) +val is_valid_npm_package_name : string -> bool - and ('a,'b) eval = - | Done of 'b - | Raise of exn - | Thunk of 'a +val namespace_of_package_name : string -> string - type undo = - | Nil - | Cons : ('a, 'b) t * 'a * undo -> undo +end = struct +#1 "ext_namespace.ml" - type log = undo ref +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) - let force f x = - match !x with - | Done x -> x - | Raise e -> raise e - | Thunk e -> - match f e with - | y -> - x := Done y; - y - | exception e -> - x := Raise e; - raise e - let get_arg x = - match !x with Thunk a -> Some a | _ -> None +(* Note the build system should check the validity of filenames + espeically, it should not contain '-' +*) +let ns_sep_char = '-' +let ns_sep = "-" - let create x = - ref (Thunk x) +let make ?ns cunit = + match ns with + | None -> cunit + | Some ns -> cunit ^ ns_sep ^ ns - let log () = - ref Nil - let force_logged log f x = - match !x with - | Done x -> x - | Raise e -> raise e - | Thunk e -> - match f e with - | None -> - x := Done None; - log := Cons(x, e, !log); - None - | Some _ as y -> - x := Done y; - y - | exception e -> - x := Raise e; - raise e +let rec rindex_rec s i = + if i < 0 then i else + let char = String.unsafe_get s i in + if Ext_filename.is_dir_sep char then -1 + else if char = ns_sep_char then i + else + rindex_rec s (i - 1) - let backtrack log = - let rec loop = function - | Nil -> () - | Cons(x, e, rest) -> - x := Thunk e; - loop rest - in - loop !log +let change_ext_ns_suffix name ext = + let i = rindex_rec name (String.length name - 1) in + if i < 0 then name ^ ext + else String.sub name 0 i ^ ext (* FIXME: micro-optimizaiton*) -end +let try_split_module_name name = + let len = String.length name in + let i = rindex_rec name (len - 1) in + if i < 0 then None + else + Some (String.sub name (i+1) (len - i - 1), + String.sub name 0 i ) +type file_kind = + | Upper_js + | Upper_bs + | Little_js + | Little_bs -module PathMap = Map.Make(Path) -type summary = - Env_empty - | Env_value of summary * Ident.t * value_description - | Env_type of summary * Ident.t * type_declaration - | Env_extension of summary * Ident.t * extension_constructor - | Env_module of summary * Ident.t * module_declaration - | Env_modtype of summary * Ident.t * modtype_declaration - | Env_class of summary * Ident.t * class_declaration - | Env_cltype of summary * Ident.t * class_type_declaration - | Env_open of summary * Path.t - | Env_functor_arg of summary * Ident.t - | Env_constraints of summary * type_declaration PathMap.t - | Env_copy_types of summary * string list + +(* let js_name_of_basename bs_suffix s = + change_ext_ns_suffix s + (if bs_suffix then Literals.suffix_bs_js else Literals.suffix_js ) *) -module TycompTbl = - struct - (** This module is used to store components of types (i.e. labels - and constructors). We keep a representation of each nested - "open" and the set of local bindings between each of them. *) +let js_name_of_modulename s little = + match little with + | Little_js -> + change_ext_ns_suffix (Ext_string.uncapitalize_ascii s) Literals.suffix_js + | Little_bs -> + change_ext_ns_suffix (Ext_string.uncapitalize_ascii s) Literals.suffix_bs_js + | Upper_js -> + change_ext_ns_suffix s Literals.suffix_js + | Upper_bs -> + change_ext_ns_suffix s Literals.suffix_bs_js - type 'a t = { - current: 'a Ident.tbl; - (** Local bindings since the last open. *) +(* https://docs.npmjs.com/files/package.json + Some rules: + The name must be less than or equal to 214 characters. This includes the scope for scoped packages. + The name can't start with a dot or an underscore. + New packages must not have uppercase letters in the name. + The name ends up being part of a URL, an argument on the command line, and a folder name. Therefore, the name can't contain any non-URL-safe characters. +*) +let is_valid_npm_package_name (s : string) = + let len = String.length s in + len <= 214 && (* magic number forced by npm *) + len > 0 && + match String.unsafe_get s 0 with + | 'a' .. 'z' | '@' -> + Ext_string.for_all_from s 1 + (fun x -> + match x with + | 'a'..'z' | '0'..'9' | '_' | '-' -> true + | _ -> false ) + | _ -> false - opened: 'a opened option; - (** Symbolic representation of the last (innermost) open, if any. *) - } - and 'a opened = { - components: (string, 'a list) Tbl.t; - (** Components from the opened module. We keep a list of - bindings for each name, as in comp_labels and - comp_constrs. *) +let namespace_of_package_name (s : string) : string = + let len = String.length s in + let buf = Ext_buffer.create len in + let add capital ch = + Ext_buffer.add_char buf + (if capital then + (Ext_char.uppercase_ascii ch) + else ch) in + let rec aux capital off len = + if off >= len then () + else + let ch = String.unsafe_get s off in + match ch with + | 'a' .. 'z' + | 'A' .. 'Z' + | '0' .. '9' + -> + add capital ch ; + aux false (off + 1) len + | '/' + | '-' -> + aux true (off + 1) len + | _ -> aux capital (off+1) len + in + aux true 0 len ; + Ext_buffer.contents buf + +end +module Outcome_printer_ns : sig +#1 "outcome_printer_ns.mli" +(* Copyright (C) 2017 Authors of BuckleScript + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) - using: (string -> ('a * 'a) option -> unit) option; - (** A callback to be applied when a component is used from this - "open". This is used to detect unused "opens". The - arguments are used to detect shadowing. *) +(** This funciton is used to + reverse namespace printing to + avoid namespace leaking +*) + val out_ident : + Format.formatter -> string -> unit +end = struct +#1 "outcome_printer_ns.ml" +(* Copyright (C) 2017 Authors of BuckleScript + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) - next: 'a t; - (** The table before opening the module. *) - } +let ps = Format.pp_print_string - let empty = { current = Ident.empty; opened = None } +let out_ident ppf s = + ps ppf ( + match s with + | "Js_null" + -> "Js.Null" + | "Js_undefined" + -> "Js.Undefined" + | "Js_null_undefined" + -> "Js.Nullable" + | "Js_exn" + -> "Js.Exn" + | "Js_array" + -> "Js.Array" + | "Js_string" + -> "Js.String" + | "Js_re" + -> "Js.Re" + | "Js_promise" + -> "Js.Promise" + | "Js_date" + -> "Js.Date" + | "Js_dict" + -> "Js.Dict" + | "Js_global" + -> "Js.Global" + | "Js_json" + -> "Js.Json" + | "Js_math" + -> "Js.Math" + | "Js_obj" + -> "Js.Obj" + | "Js_typed_array" + -> "Js.Typed_array" + | "Js_types" + -> "Js.Types" + | "Js_float" + -> "Js.Float" + | "Js_int" + -> "Js.Int" + | "Js_option" + -> "Js.Option" + | "Js_result" + -> "Js.Result" + |"Js_list" + -> "Js.List" + | "Js_vector" + -> "Js.Vector" +(* Belt_libs *) + | "Belt_Id" -> "Belt.Id" + | "Belt_Array" -> "Belt.Array" - let add id x tbl = - {tbl with current = Ident.add id x tbl.current} + | "Belt_SortArray" -> "Belt.SortArray" + | "Belt_SortArrayInt" -> "Belt.SortArray.Int" + | "Belt_SortArrayString" -> "Belt.SortArray.String" + + | "Belt_MutableQueue" -> "Belt.MutableQueue" + | "Belt_MutableStack" -> "Belt.MutableStack" + | "Belt_List" -> "Belt.List" + | "Belt_Range" -> "Belt.Range" + + | "Belt_Set" -> "Belt.Set" + | "Belt_SetInt" -> "Belt.Set.Int" + | "Belt_SetString" -> "Belt.Set.String" - let add_open slot wrap components next = - let using = - match slot with - | None -> None - | Some f -> Some (fun s x -> f s (wrap x)) - in - { - current = Ident.empty; - opened = Some {using; components; next}; - } + | "Belt_Map" -> "Belt.Map" + | "Belt_MapInt" -> "Belt.Map.Int" + | "Belt_MapString" -> "Belt.Map.String" - let rec find_same id tbl = - try Ident.find_same id tbl.current - with Not_found as exn -> - begin match tbl.opened with - | Some {next; _} -> find_same id next - | None -> raise exn - end + | "Belt_Option" -> "Belt.Option" - let nothing = fun () -> () + | "Belt_MutableSet" -> "Belt.MutableSet" + | "Belt_MutableSetInt" -> "Belt.MutableSet.Int" + | "Belt_MutableSetString" -> "Belt.MutableSet.String" - let mk_callback rest name desc = function - | None -> nothing - | Some f -> - (fun () -> - match rest with - | [] -> f name None - | (hidden, _) :: _ -> f name (Some (desc, hidden)) - ) + | "Belt_MutableMap" -> "Belt.MutableMap" + | "Belt_MutableMapInt" -> "Belt.MutableMap.Int" + | "Belt_MutableMapString" -> "Belt.MutableMap.String" + + | "Belt_HashSet" -> "Belt.HashSet" + | "Belt_HashSetInt" -> "Belt.HashSet.Int" + | "Belt_HashSetString" -> "Belt.HashSet.String" + + | "Belt_HashMap" -> "Belt.HashMap" + | "Belt_HashMapString" -> "Belt.HashMap.String" + | "Belt_HashMapInt" -> "Belt.HashMap.Int" + | "Belt_Debug" -> "Belt.Debug" + | s -> + (match Ext_namespace.try_split_module_name s with + | None -> s + | Some (ns,m) + -> ns ^ "."^ m + ) + ) - let rec find_all name tbl = - List.map (fun (_id, desc) -> desc, nothing) - (Ident.find_all name tbl.current) @ - match tbl.opened with - | None -> [] - | Some {using; next; components} -> - let rest = find_all name next in - match Tbl.find_str name components with - | exception Not_found -> rest - | opened -> - List.map - (fun desc -> desc, mk_callback rest name desc using) - opened - @ rest - let rec fold_name f tbl acc = - let acc = Ident.fold_name (fun _id d -> f d) tbl.current acc in - match tbl.opened with - | Some {using = _; next; components} -> - acc - |> Tbl.fold - (fun _name -> List.fold_right (fun desc -> f desc)) - components - |> fold_name f next - | None -> - acc - let rec local_keys tbl acc = - let acc = Ident.fold_all (fun k _ accu -> k::accu) tbl.current acc in - match tbl.opened with - | Some o -> local_keys o.next acc - | None -> acc +end +module Ext_array : sig +#1 "ext_array.mli" +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) - let diff_keys is_local tbl1 tbl2 = - let keys2 = local_keys tbl2 [] in - List.filter - (fun id -> - is_local (find_same id tbl2) && - try ignore (find_same id tbl1); false - with Not_found -> true) - keys2 - end -module IdTbl = - struct - (** This module is used to store all kinds of components except - (labels and constructors) in environments. We keep a - representation of each nested "open" and the set of local - bindings between each of them. *) - type 'a t = { - current: 'a Ident.tbl; - (** Local bindings since the last open *) +(** Some utilities for {!Array} operations *) +val reverse_range : 'a array -> int -> int -> unit +val reverse_in_place : 'a array -> unit +val reverse : 'a array -> 'a array +val reverse_of_list : 'a list -> 'a array - opened: 'a opened option; - (** Symbolic representation of the last (innermost) open, if any. *) - } +val filter : ('a -> bool) -> 'a array -> 'a array - and 'a opened = { - root: Path.t; - (** The path of the opened module, to be prefixed in front of - its local names to produce a valid path in the current - environment. *) +val filter_map : ('a -> 'b option) -> 'a array -> 'b array - components: (string, 'a * int) Tbl.t; - (** Components from the opened module. *) +val range : int -> int -> int array - using: (string -> ('a * 'a) option -> unit) option; - (** A callback to be applied when a component is used from this - "open". This is used to detect unused "opens". The - arguments are used to detect shadowing. *) +val map2i : (int -> 'a -> 'b -> 'c ) -> 'a array -> 'b array -> 'c array - next: 'a t; - (** The table before opening the module. *) - } +val to_list_f : + 'a array -> + ('a -> 'b) -> + 'b list - let empty = { current = Ident.empty; opened = None } +val to_list_map : ('a -> 'b option) -> 'a array -> 'b list - let add id x tbl = - {tbl with current = Ident.add id x tbl.current} +val to_list_map_acc : + 'a array -> + 'b list -> + ('a -> 'b option) -> + 'b list - let add_open slot wrap root components next = - let using = - match slot with - | None -> None - | Some f -> Some (fun s x -> f s (wrap x)) - in - { - current = Ident.empty; - opened = Some {using; root; components; next}; - } +val of_list_map : + 'a list -> + ('a -> 'b) -> + 'b array - let rec find_same id tbl = - try Ident.find_same id tbl.current - with Not_found as exn -> - begin match tbl.opened with - | Some {next; _} -> find_same id next - | None -> raise exn - end +val rfind_with_index : 'a array -> ('a -> 'b -> bool) -> 'b -> int - let rec find_name mark name tbl = - try - let (id, desc) = Ident.find_name name tbl.current in - Pident id, desc - with Not_found as exn -> - begin match tbl.opened with - | Some {using; root; next; components} -> - begin try - let (descr, pos) = Tbl.find_str name components in - let res = Pdot (root, name, pos), descr in - if mark then begin match using with - | None -> () - | Some f -> - begin try f name (Some (snd (find_name false name next), snd res)) - with Not_found -> f name None - end - end; - res - with Not_found -> - find_name mark name next - end - | None -> - raise exn - end - let find_name name tbl = find_name true name tbl +type 'a split = [ `No_split | `Split of 'a array * 'a array ] - let rec update name f tbl = - try - let (id, desc) = Ident.find_name name tbl.current in - let new_desc = f desc in - {tbl with current = Ident.add id new_desc tbl.current} - with Not_found -> - begin match tbl.opened with - | Some {root; using; next; components} -> - begin try - let (desc, pos) = Tbl.find_str name components in - let new_desc = f desc in - let components = Tbl.add name (new_desc, pos) components in - {tbl with opened = Some {root; using; next; components}} - with Not_found -> - let next = update name f next in - {tbl with opened = Some {root; using; next; components}} - end - | None -> - tbl - end +val rfind_and_split : + 'a array -> + ('a -> 'b -> bool) -> + 'b -> 'a split +val find_and_split : + 'a array -> + ('a -> 'b -> bool) -> + 'b -> 'a split +val exists : ('a -> bool) -> 'a array -> bool - let rec find_all name tbl = - List.map (fun (id, desc) -> Pident id, desc) (Ident.find_all name tbl.current) @ - match tbl.opened with - | None -> [] - | Some {root; using = _; next; components} -> - try - let (desc, pos) = Tbl.find_str name components in - (Pdot (root, name, pos), desc) :: find_all name next - with Not_found -> - find_all name next +val is_empty : 'a array -> bool - let rec fold_name f tbl acc = - let acc = Ident.fold_name (fun id d -> f (Ident.name id) (Pident id, d)) tbl.current acc in - match tbl.opened with - | Some {root; using = _; next; components} -> - acc - |> Tbl.fold - (fun name (desc, pos) -> f name (Pdot (root, name, pos), desc)) - components - |> fold_name f next - | None -> - acc +val for_all2_no_exn : + 'a array -> + 'b array -> + ('a -> 'b -> bool) -> + bool - let rec local_keys tbl acc = - let acc = Ident.fold_all (fun k _ accu -> k::accu) tbl.current acc in - match tbl.opened with - | Some o -> local_keys o.next acc - | None -> acc +val map : + 'a array -> + ('a -> 'b) -> + 'b array +val iter : + 'a array -> + ('a -> unit) -> + unit - let rec iter f tbl = - Ident.iter (fun id desc -> f id (Pident id, desc)) tbl.current; - match tbl.opened with - | Some {root; using = _; next; components} -> - Tbl.iter - (fun s (x, pos) -> f (Ident.hide (Ident.create s) (* ??? *)) (Pdot (root, s, pos), x)) - components; - iter f next - | None -> () +val fold_left : + 'b array -> + 'a -> + ('a -> 'b -> 'a) -> + 'a - let diff_keys tbl1 tbl2 = - let keys2 = local_keys tbl2 [] in - List.filter - (fun id -> - try ignore (find_same id tbl1); false - with Not_found -> true) - keys2 +val get_or : + 'a array -> + int -> + (unit -> 'a) -> + 'a +end = struct +#1 "ext_array.ml" +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) - end -type type_descriptions = - constructor_description list * label_description list -let in_signature_flag = 0x01 -let implicit_coercion_flag = 0x02 -type t = { - values: value_description IdTbl.t; - constrs: constructor_description TycompTbl.t; - labels: label_description TycompTbl.t; - types: (type_declaration * type_descriptions) IdTbl.t; - modules: (Subst.t * module_declaration, module_declaration) EnvLazy.t IdTbl.t; - modtypes: modtype_declaration IdTbl.t; - components: module_components IdTbl.t; - classes: class_declaration IdTbl.t; - cltypes: class_type_declaration IdTbl.t; - functor_args: unit Ident.tbl; - summary: summary; - local_constraints: type_declaration PathMap.t; - gadt_instances: (int * TypeSet.t ref) list; - flags: int; -} +let reverse_range a i len = + if len = 0 then () + else + for k = 0 to (len-1)/2 do + let t = Array.unsafe_get a (i+k) in + Array.unsafe_set a (i+k) ( Array.unsafe_get a (i+len-1-k)); + Array.unsafe_set a (i+len-1-k) t; + done -and module_components = - { - deprecated: string option; - loc: Location.t; - comps: - (t * Subst.t * Path.t * Types.module_type, module_components_repr option) - EnvLazy.t; - } -and module_components_repr = - Structure_comps of structure_components - | Functor_comps of functor_components +let reverse_in_place a = + reverse_range a 0 (Array.length a) -and 'a comp_tbl = (string, ('a * int)) Tbl.t +let reverse a = + let b_len = Array.length a in + if b_len = 0 then [||] else + let b = Array.copy a in + for i = 0 to b_len - 1 do + Array.unsafe_set b i (Array.unsafe_get a (b_len - 1 -i )) + done; + b -and structure_components = { - mutable comp_values: value_description comp_tbl; - mutable comp_constrs: (string, constructor_description list) Tbl.t; - mutable comp_labels: (string, label_description list) Tbl.t; - mutable comp_types: (type_declaration * type_descriptions) comp_tbl; - mutable comp_modules: - (Subst.t * module_declaration, module_declaration) EnvLazy.t comp_tbl; - mutable comp_modtypes: modtype_declaration comp_tbl; - mutable comp_components: module_components comp_tbl; - mutable comp_classes: class_declaration comp_tbl; - mutable comp_cltypes: class_type_declaration comp_tbl; -} +let reverse_of_list = function + | [] -> [||] + | hd::tl as l -> + let len = List.length l in + let a = Array.make len hd in + let rec fill i = function + | [] -> a + | hd::tl -> Array.unsafe_set a (len - i - 2) hd; fill (i+1) tl in + fill 0 tl -and functor_components = { - fcomp_param: Ident.t; (* Formal parameter *) - fcomp_arg: module_type option; (* Argument signature *) - fcomp_res: module_type; (* Result signature *) - fcomp_cache: (Path.t, module_components) Hashtbl.t; (* For memoization *) - fcomp_subst_cache: (Path.t, module_type) Hashtbl.t -} +let filter f a = + let arr_len = Array.length a in + let rec aux acc i = + if i = arr_len + then reverse_of_list acc + else + let v = Array.unsafe_get a i in + if f v then + aux (v::acc) (i+1) + else aux acc (i + 1) + in aux [] 0 -let copy_local ~from env = - { env with - local_constraints = from.local_constraints; - gadt_instances = from.gadt_instances; - flags = from.flags } -let same_constr = ref (fun _ _ _ -> assert false) +let filter_map (f : _ -> _ option) a = + let arr_len = Array.length a in + let rec aux acc i = + if i = arr_len + then reverse_of_list acc + else + let v = Array.unsafe_get a i in + match f v with + | Some v -> + aux (v::acc) (i+1) + | None -> + aux acc (i + 1) + in aux [] 0 -(* Helper to decide whether to report an identifier shadowing - by some 'open'. For labels and constructors, we do not report - if the two elements are from the same re-exported declaration. +let range from to_ = + if from > to_ then invalid_arg "Ext_array.range" + else Array.init (to_ - from + 1) (fun i -> i + from) - Later, one could also interpret some attributes on value and - type declarations to silence the shadowing warnings. *) +let map2i f a b = + let len = Array.length a in + if len <> Array.length b then + invalid_arg "Ext_array.map2i" + else + Array.mapi (fun i a -> f i a ( Array.unsafe_get b i )) a -let check_shadowing env = function - | `Constructor (Some (c1, c2)) - when not (!same_constr env c1.cstr_res c2.cstr_res) -> - Some "constructor" - | `Label (Some (l1, l2)) - when not (!same_constr env l1.lbl_res l2.lbl_res) -> - Some "label" - | `Value (Some _) -> Some "value" - | `Type (Some _) -> Some "type" - | `Module (Some _) | `Component (Some _) -> Some "module" - | `Module_type (Some _) -> Some "module type" - | `Class (Some _) -> Some "class" - | `Class_type (Some _) -> Some "class type" - | `Constructor _ | `Label _ - | `Value None | `Type None | `Module None | `Module_type None - | `Class None | `Class_type None | `Component None -> - None +let rec tolist_f_aux a f i res = + if i < 0 then res else + let v = Array.unsafe_get a i in + tolist_f_aux a f (i - 1) + (f v :: res) + +let to_list_f a f = tolist_f_aux a f (Array.length a - 1) [] -let subst_modtype_maker (subst, md) = - if subst == Subst.identity then md - else {md with md_type = Subst.modtype subst md.md_type} +let rec tolist_aux a f i res = + if i < 0 then res else + let v = Array.unsafe_get a i in + tolist_aux a f (i - 1) + (match f v with + | Some v -> v :: res + | None -> res) -let empty = { - values = IdTbl.empty; constrs = TycompTbl.empty; - labels = TycompTbl.empty; types = IdTbl.empty; - modules = IdTbl.empty; modtypes = IdTbl.empty; - components = IdTbl.empty; classes = IdTbl.empty; - cltypes = IdTbl.empty; - summary = Env_empty; local_constraints = PathMap.empty; gadt_instances = []; - flags = 0; - functor_args = Ident.empty; - } +let to_list_map f a = + tolist_aux a f (Array.length a - 1) [] -let in_signature b env = - let flags = - if b then env.flags lor in_signature_flag - else env.flags land (lnot in_signature_flag) - in - {env with flags} +let to_list_map_acc a acc f = + tolist_aux a f (Array.length a - 1) acc -let implicit_coercion env = - {env with flags = env.flags lor implicit_coercion_flag} -let is_in_signature env = env.flags land in_signature_flag <> 0 -let is_implicit_coercion env = env.flags land implicit_coercion_flag <> 0 +let of_list_map a f = + match a with + | [] -> [||] + | [a0] -> + let b0 = f a0 in + [|b0|] + | [a0;a1] -> + let b0 = f a0 in + let b1 = f a1 in + [|b0;b1|] + | [a0;a1;a2] -> + let b0 = f a0 in + let b1 = f a1 in + let b2 = f a2 in + [|b0;b1;b2|] + | [a0;a1;a2;a3] -> + let b0 = f a0 in + let b1 = f a1 in + let b2 = f a2 in + let b3 = f a3 in + [|b0;b1;b2;b3|] + | [a0;a1;a2;a3;a4] -> + let b0 = f a0 in + let b1 = f a1 in + let b2 = f a2 in + let b3 = f a3 in + let b4 = f a4 in + [|b0;b1;b2;b3;b4|] -let is_ident = function - Pident _ -> true - | Pdot _ | Papply _ -> false + | a0::a1::a2::a3::a4::tl -> + let b0 = f a0 in + let b1 = f a1 in + let b2 = f a2 in + let b3 = f a3 in + let b4 = f a4 in + let len = List.length tl + 5 in + let arr = Array.make len b0 in + Array.unsafe_set arr 1 b1 ; + Array.unsafe_set arr 2 b2 ; + Array.unsafe_set arr 3 b3 ; + Array.unsafe_set arr 4 b4 ; + let rec fill i = function + | [] -> arr + | hd :: tl -> + Array.unsafe_set arr i (f hd); + fill (i + 1) tl in + fill 5 tl -let is_local_ext = function - | {cstr_tag = Cstr_extension(p, _)} -> is_ident p - | _ -> false +(** + {[ + # rfind_with_index [|1;2;3|] (=) 2;; + - : int = 1 + # rfind_with_index [|1;2;3|] (=) 1;; + - : int = 0 + # rfind_with_index [|1;2;3|] (=) 3;; + - : int = 2 + # rfind_with_index [|1;2;3|] (=) 4;; + - : int = -1 + ]} +*) +let rfind_with_index arr cmp v = + let len = Array.length arr in + let rec aux i = + if i < 0 then i + else if cmp (Array.unsafe_get arr i) v then i + else aux (i - 1) in + aux (len - 1) -let diff env1 env2 = - IdTbl.diff_keys env1.values env2.values @ - TycompTbl.diff_keys is_local_ext env1.constrs env2.constrs @ - IdTbl.diff_keys env1.modules env2.modules @ - IdTbl.diff_keys env1.classes env2.classes +type 'a split = [ `No_split | `Split of 'a array * 'a array ] +let rfind_and_split arr cmp v : _ split = + let i = rfind_with_index arr cmp v in + if i < 0 then + `No_split + else + `Split (Array.sub arr 0 i , Array.sub arr (i + 1 ) (Array.length arr - i - 1 )) -type can_load_cmis = - | Can_load_cmis - | Cannot_load_cmis of EnvLazy.log -let can_load_cmis = ref Can_load_cmis +let find_with_index arr cmp v = + let len = Array.length arr in + let rec aux i len = + if i >= len then -1 + else if cmp (Array.unsafe_get arr i ) v then i + else aux (i + 1) len in + aux 0 len -let without_cmis f x = - let log = EnvLazy.log () in - let res = - Misc.(protect_refs - [R (can_load_cmis, Cannot_load_cmis log)] - (fun () -> f x)) - in - EnvLazy.backtrack log; - res +let find_and_split arr cmp v : _ split = + let i = find_with_index arr cmp v in + if i < 0 then + `No_split + else + `Split (Array.sub arr 0 i, Array.sub arr (i + 1 ) (Array.length arr - i - 1)) -(* Forward declarations *) +(** TODO: available since 4.03, use {!Array.exists} *) -let components_of_module' = - ref ((fun ~deprecated:_ ~loc:_ _env _sub _path _mty -> assert false) : - deprecated:string option -> loc:Location.t -> t -> Subst.t -> - Path.t -> module_type -> - module_components) -let components_of_module_maker' = - ref ((fun (_env, _sub, _path, _mty) -> assert false) : - t * Subst.t * Path.t * module_type -> module_components_repr option) -let components_of_functor_appl' = - ref ((fun _f _env _p1 _p2 -> assert false) : - functor_components -> t -> Path.t -> Path.t -> module_components) -let check_modtype_inclusion = - (* to be filled with Includemod.check_modtype_inclusion *) - ref ((fun ~loc:_ _env _mty1 _path1 _mty2 -> assert false) : - loc:Location.t -> t -> module_type -> Path.t -> module_type -> unit) -let strengthen = - (* to be filled with Mtype.strengthen *) - ref ((fun ~aliasable:_ _env _mty _path -> assert false) : - aliasable:bool -> t -> module_type -> Path.t -> module_type) +let exists p a = + let n = Array.length a in + let rec loop i = + if i = n then false + else if p (Array.unsafe_get a i) then true + else loop (succ i) in + loop 0 -let md md_type = - {md_type; md_attributes=[]; md_loc=Location.none} -let get_components_opt c = - match !can_load_cmis with - | Can_load_cmis -> - EnvLazy.force !components_of_module_maker' c.comps - | Cannot_load_cmis log -> - EnvLazy.force_logged log !components_of_module_maker' c.comps +let is_empty arr = + Array.length arr = 0 -let empty_structure = - Structure_comps { - comp_values = Tbl.empty; - comp_constrs = Tbl.empty; - comp_labels = Tbl.empty; - comp_types = Tbl.empty; - comp_modules = Tbl.empty; comp_modtypes = Tbl.empty; - comp_components = Tbl.empty; comp_classes = Tbl.empty; - comp_cltypes = Tbl.empty } -let get_components c = - match get_components_opt c with - | None -> empty_structure - | Some c -> c +let rec unsafe_loop index len p xs ys = + if index >= len then true + else + p + (Array.unsafe_get xs index) + (Array.unsafe_get ys index) && + unsafe_loop (succ index) len p xs ys -(* The name of the compilation unit currently compiled. - "" if outside a compilation unit. *) +let for_all2_no_exn xs ys p = + let len_xs = Array.length xs in + let len_ys = Array.length ys in + len_xs = len_ys && + unsafe_loop 0 len_xs p xs ys -let current_unit = ref "" -(* Persistent structure descriptions *) +let map a f = + let open Array in + let l = length a in + if l = 0 then [||] else begin + let r = make l (f(unsafe_get a 0)) in + for i = 1 to l - 1 do + unsafe_set r i (f(unsafe_get a i)) + done; + r + end -type pers_struct = - { ps_name: string; - ps_sig: signature Lazy.t; - ps_comps: module_components; - ps_crcs: (string * Digest.t option) list; - ps_filename: string; - ps_flags: pers_flags list } +let iter a f = + let open Array in + for i = 0 to length a - 1 do f(unsafe_get a i) done -let persistent_structures = - (Hashtbl.create 17 : (string, pers_struct option) Hashtbl.t) -(* Consistency between persistent structures *) + let fold_left a x f = + let open Array in + let r = ref x in + for i = 0 to length a - 1 do + r := f !r (unsafe_get a i) + done; + !r + +let get_or arr i cb = + if i >=0 && i < Array.length arr then + Array.unsafe_get arr i + else cb () +end +module Record_attributes_check += struct +#1 "record_attributes_check.ml" +(* Copyright (C) 2019- Authors of BuckleScript + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -let crc_units = Consistbl.create() +type label = Types.label_description -module StringSet = - Set.Make(struct type t = string let compare = String.compare end) +let fn = (fun (attr : Parsetree.attribute) -> +match attr with +| {txt = "bs.as"}, PStr + [{pstr_desc = Pstr_eval ({pexp_desc = Pexp_constant (Pconst_string(s,_))},_ )}] -> + (* Bs_ast_invariant.mark_used_bs_attribute attr; *) + Some s +| _ -> None +) -let imported_units = ref StringSet.empty +let fld_record (lbl : label) = + Lambda.Fld_record + {name = Ext_list.find_def lbl.lbl_attributes fn lbl.lbl_name; mutable_flag = lbl.Types.lbl_mut} + +let fld_record_set (lbl : label) = + Lambda.Fld_record_set + (Ext_list.find_def lbl.lbl_attributes fn lbl.lbl_name) + +let blk_record fields = + let all_labels_info = + Ext_array.map fields + (fun ((lbl : label),_) -> + Ext_list.find_def lbl.Types.lbl_attributes fn lbl.lbl_name) in + Lambda.Blk_record all_labels_info -let add_import s = - imported_units := StringSet.add s !imported_units +let check_bs_attributes_inclusion + (attrs1 : Parsetree.attributes) + (attrs2 : Parsetree.attributes) + lbl_name = + let a = Ext_list.find_def attrs1 fn lbl_name in + let b = Ext_list.find_def attrs2 fn lbl_name in + if a = b then None + else Some (a,b) -let imported_opaque_units = ref StringSet.empty -let add_imported_opaque s = - imported_opaque_units := StringSet.add s !imported_opaque_units -let clear_imports () = - Consistbl.clear crc_units; - imported_units := StringSet.empty; - imported_opaque_units := StringSet.empty -let check_consistency ps = - try - List.iter - (fun (name, crco) -> - match crco with - None -> () - | Some crc -> - add_import name; - Consistbl.check crc_units name crc ps.ps_filename) - ps.ps_crcs; - with Consistbl.Inconsistency(name, source, auth) -> - error (Inconsistent_import(name, auth, source)) +end +module Bs_conditional_initial : sig +#1 "bs_conditional_initial.mli" +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -(* Reading persistent structures from .cmi files *) +(** This function set up built in compile time variables used in + conditional compilation so that + {[ + #if BS then + #elif .. then + #end + ]} + Is understood, also make sure the playground do the same initialization. +*) +val setup_env : unit -> unit -let save_pers_struct crc ps = - let modname = ps.ps_name in - Hashtbl.add persistent_structures modname (Some ps); - List.iter - (function - | Rectypes -> () - | Deprecated _ -> () - | Unsafe_string -> () - | Opaque -> add_imported_opaque modname) - ps.ps_flags; - Consistbl.set crc_units modname crc ps.ps_filename; - add_import modname -module Persistent_signature = struct - type t = - { filename : string; - cmi : Cmi_format.cmi_infos } +end = struct +#1 "bs_conditional_initial.ml" +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) - let load = ref (fun ~unit_name -> - match find_in_path_uncap !load_path (unit_name ^ ".cmi") with - | filename -> Some { filename; cmi = read_cmi filename } - | exception Not_found -> None) -end -let acknowledge_pers_struct check modname - { Persistent_signature.filename; cmi } = - let name = cmi.cmi_name in - let sign = cmi.cmi_sign in - let crcs = cmi.cmi_crcs in - let flags = cmi.cmi_flags in - let deprecated = - List.fold_left (fun acc -> function Deprecated s -> Some s | _ -> acc) None - flags - in - let comps = - !components_of_module' ~deprecated ~loc:Location.none - empty Subst.identity - (Pident(Ident.create_persistent name)) - (Mty_signature sign) - in - let ps = { ps_name = name; - ps_sig = lazy (Subst.signature Subst.identity sign); - ps_comps = comps; - ps_crcs = crcs; - ps_filename = filename; - ps_flags = flags; - } in - if ps.ps_name <> modname then - error (Illegal_renaming(modname, ps.ps_name, filename)); +let setup_env () = + Clflags.compile_only := true; + Clflags.bs_only := true; + Clflags.no_implicit_current_dir := true; + (* default true + otherwise [bsc -I sc src/hello.ml ] will include current directory to search path + *) + Clflags.assume_no_mli := Clflags.Mli_non_exists; + Clflags.unsafe_string := false; + Clflags.debug := true; + Clflags.record_event_when_debug := false; + Clflags.binary_annotations := true; + (* Turn on [-no-alias-deps] by default -- double check *) + Oprint.out_ident := Outcome_printer_ns.out_ident; + Builtin_attributes.check_bs_attributes_inclusion := Record_attributes_check.check_bs_attributes_inclusion; + Lambda.fld_record := Record_attributes_check.fld_record; + Lambda.fld_record_set := Record_attributes_check.fld_record_set; + Lambda.blk_record := Record_attributes_check.blk_record; - List.iter - (function - | Rectypes -> - if not !Clflags.recursive_types then - error (Need_recursive_types(ps.ps_name, !current_unit)) - | Unsafe_string -> - if Config.safe_string then - error (Depend_on_unsafe_string_unit (ps.ps_name, !current_unit)); - | Deprecated _ -> () - | Opaque -> add_imported_opaque modname) - ps.ps_flags; - if check then check_consistency ps; - Hashtbl.add persistent_structures modname (Some ps); - ps + Lexer.replace_directive_bool "BS" true; + Lexer.replace_directive_string "BS_VERSION" Bs_version.version + -let read_pers_struct check modname filename = - add_import modname; - let cmi = read_cmi filename in - acknowledge_pers_struct check modname - { Persistent_signature.filename; cmi } -let find_pers_struct check name = - if name = "*predef*" then raise Not_found; - match Hashtbl.find persistent_structures name with - | Some ps -> ps - | None -> raise Not_found - | exception Not_found -> - match !can_load_cmis with - | Cannot_load_cmis _ -> raise Not_found - | Can_load_cmis -> - let ps = - match !Persistent_signature.load ~unit_name:name with - | Some ps -> ps - | None -> - Hashtbl.add persistent_structures name None; - raise Not_found - in - add_import name; - acknowledge_pers_struct check name ps +end +module Ccomp : sig +#1 "ccomp.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -(* Emits a warning if there is no valid cmi for name *) -let check_pers_struct name = - try - ignore (find_pers_struct false name) - with - | Not_found -> - let warn = Warnings.No_cmi_file(name, None) in - Location.prerr_warning Location.none warn - | Cmi_format.Error err -> - let msg = Format.asprintf "%a" Cmi_format.report_error err in - let warn = Warnings.No_cmi_file(name, Some msg) in - Location.prerr_warning Location.none warn - | Error err -> - let msg = - match err with - | Illegal_renaming(name, ps_name, filename) -> - Format.asprintf - " %a@ contains the compiled interface for @ \ - %s when %s was expected" - Location.print_filename filename ps_name name - | Inconsistent_import _ -> assert false - | Need_recursive_types(name, _) -> - Format.sprintf - "%s uses recursive types" - name - | Depend_on_unsafe_string_unit (name, _) -> - Printf.sprintf "%s uses -unsafe-string" - name - | Missing_module _ -> assert false - | Illegal_value_name _ -> assert false - in - let warn = Warnings.No_cmi_file(name, Some msg) in - Location.prerr_warning Location.none warn +(* Compiling C files and building C libraries *) -let read_pers_struct modname filename = - read_pers_struct true modname filename +val command: string -> int +val run_command: string -> unit +val compile_file: ?output:string -> ?opt:string -> string -> int +val create_archive: string -> string list -> int +val expand_libname: string -> string +val quote_files: string list -> string +val quote_optfile: string option -> string +(*val make_link_options: string list -> string*) -let find_pers_struct name = - find_pers_struct true name +type link_mode = + | Exe + | Dll + | MainDll + | Partial -let check_pers_struct name = - if not (Hashtbl.mem persistent_structures name) then begin - (* PR#6843: record the weak dependency ([add_import]) regardless of - whether the check succeeds, to help make builds more - deterministic. *) - add_import name; - if (Warnings.is_active (Warnings.No_cmi_file("", None))) then - !add_delayed_check_forward - (fun () -> check_pers_struct name) - end +val call_linker: link_mode -> string -> string list -> string -> bool -let reset_cache () = - current_unit := ""; - Hashtbl.clear persistent_structures; - clear_imports (); - Hashtbl.clear value_declarations; - Hashtbl.clear type_declarations; - Hashtbl.clear module_declarations; - Hashtbl.clear used_constructors; - Hashtbl.clear prefixed_sg +end = struct +#1 "ccomp.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -let reset_cache_toplevel () = - (* Delete 'missing cmi' entries from the cache. *) - let l = - Hashtbl.fold - (fun name r acc -> if r = None then name :: acc else acc) - persistent_structures [] - in - List.iter (Hashtbl.remove persistent_structures) l; - Hashtbl.clear value_declarations; - Hashtbl.clear type_declarations; - Hashtbl.clear module_declarations; - Hashtbl.clear used_constructors; - Hashtbl.clear prefixed_sg +(* Compiling C files and building C libraries *) +let command cmdline = + if !Clflags.verbose then begin + prerr_string "+ "; + prerr_string cmdline; + prerr_newline() + end; + Sys.command cmdline -let set_unit_name name = - current_unit := name +let run_command cmdline = ignore(command cmdline) -let get_unit_name () = - !current_unit +(* Build @responsefile to work around Windows limitations on + command-line length *) +let build_diversion lst = + let (responsefile, oc) = Filename.open_temp_file "camlresp" "" in + List.iter (fun f -> Printf.fprintf oc "%s\n" f) lst; + close_out oc; + at_exit (fun () -> Misc.remove_file responsefile); + "@" ^ responsefile -(* Lookup by identifier *) +let quote_files lst = + let lst = List.filter (fun f -> f <> "") lst in + let quoted = List.map Filename.quote lst in + let s = String.concat " " quoted in + if String.length s >= 4096 && Sys.os_type = "Win32" + then build_diversion quoted + else s -let rec find_module_descr path env = - match path with - Pident id -> - begin try - IdTbl.find_same id env.components - with Not_found -> - if Ident.persistent id && not (Ident.name id = !current_unit) - then (find_pers_struct (Ident.name id)).ps_comps - else raise Not_found - end - | Pdot(p, s, _pos) -> - begin match get_components (find_module_descr p env) with - Structure_comps c -> - let (descr, _pos) = Tbl.find_str s c.comp_components in - descr - | Functor_comps _ -> - raise Not_found - end - | Papply(p1, p2) -> - begin match get_components (find_module_descr p1 env) with - Functor_comps f -> - !components_of_functor_appl' f env p1 p2 - | Structure_comps _ -> - raise Not_found - end +let quote_prefixed pr lst = + let lst = List.filter (fun f -> f <> "") lst in + let lst = List.map (fun f -> pr ^ f) lst in + quote_files lst -let find proj1 proj2 path env = - match path with - Pident id -> - IdTbl.find_same id (proj1 env) - | Pdot(p, s, _pos) -> - begin match get_components (find_module_descr p env) with - Structure_comps c -> - let (data, _pos) = Tbl.find_str s (proj2 c) in data - | Functor_comps _ -> - raise Not_found - end - | Papply _ -> - raise Not_found +let quote_optfile = function + | None -> "" + | Some f -> Filename.quote f -let find_value = - find (fun env -> env.values) (fun sc -> sc.comp_values) -and find_type_full = - find (fun env -> env.types) (fun sc -> sc.comp_types) -and find_modtype = - find (fun env -> env.modtypes) (fun sc -> sc.comp_modtypes) -and find_class = - find (fun env -> env.classes) (fun sc -> sc.comp_classes) -and find_cltype = - find (fun env -> env.cltypes) (fun sc -> sc.comp_cltypes) +let display_msvc_output file name = + let c = open_in file in + try + let first = input_line c in + if first <> Filename.basename name then + print_string first; + while true do + print_string (input_line c) + done + with _ -> + close_in c; + Sys.remove file -let type_of_cstr path = function - | {cstr_inlined = Some d; _} -> - (d, ([], List.map snd (Datarepr.labels_of_type path d))) - | _ -> - assert false +let compile_file ?output ?(opt="") name = + let (pipe, file) = + if Config.ccomp_type = "msvc" && not !Clflags.verbose then + try + let (t, c) = Filename.open_temp_file "msvc" "stdout" in + close_out c; + (Printf.sprintf " > %s" (Filename.quote t), t) + with _ -> + ("", "") + else + ("", "") in + let exit = + command + (Printf.sprintf + "%s %s %s -c %s %s %s %s %s%s" + (match !Clflags.c_compiler with + | Some cc -> cc + | None -> + let (cflags, cppflags) = + if !Clflags.native_code + then (Config.ocamlopt_cflags, Config.ocamlopt_cppflags) + else (Config.ocamlc_cflags, Config.ocamlc_cppflags) in + (String.concat " " [Config.c_compiler; cflags; cppflags])) + (match output with + | None -> "" + | Some o -> Printf.sprintf "%s%s" Config.c_output_obj o) + opt + (if !Clflags.debug && Config.ccomp_type <> "msvc" then "-g" else "") + (String.concat " " (List.rev !Clflags.all_ccopts)) + (quote_prefixed "-I" (List.rev !Clflags.include_dirs)) + (Clflags.std_include_flag "-I") + (Filename.quote name) + (* cl tediously includes the name of the C file as the first thing it + outputs (in fairness, the tedious thing is that there's no switch to + disable this behaviour). In the absence of the Unix module, use + a temporary file to filter the output (cannot pipe the output to a + filter because this removes the exit status of cl, which is wanted. + *) + pipe) in + if pipe <> "" + then display_msvc_output file name; + exit -let find_type_full path env = - match Path.constructor_typath path with - | Regular p -> - (try (PathMap.find p env.local_constraints, ([], [])) - with Not_found -> find_type_full p env) - | Cstr (ty_path, s) -> - let (_, (cstrs, _)) = - try find_type_full ty_path env - with Not_found -> assert false - in - let cstr = - try List.find (fun cstr -> cstr.cstr_name = s) cstrs - with Not_found -> assert false - in - type_of_cstr path cstr - | LocalExt id -> - let cstr = - try TycompTbl.find_same id env.constrs - with Not_found -> assert false - in - type_of_cstr path cstr - | Ext (mod_path, s) -> - let comps = - try find_module_descr mod_path env - with Not_found -> assert false - in - let comps = - match get_components comps with - | Structure_comps c -> c - | Functor_comps _ -> assert false - in - let exts = - List.filter - (function {cstr_tag=Cstr_extension _} -> true | _ -> false) - (try Tbl.find_str s comps.comp_constrs - with Not_found -> assert false) +let macos_create_empty_archive ~quoted_archive = + let result = + command (Printf.sprintf "%s rc %s /dev/null" Config.ar quoted_archive) + in + if result <> 0 then result + else + let result = + command (Printf.sprintf "%s %s 2> /dev/null" Config.ranlib quoted_archive) + in + if result <> 0 then result + else + command (Printf.sprintf "%s d %s /dev/null" Config.ar quoted_archive) + +let create_archive archive file_list = + Misc.remove_file archive; + let quoted_archive = Filename.quote archive in + match Config.ccomp_type with + "msvc" -> + command(Printf.sprintf "link /lib /nologo /out:%s %s" + quoted_archive (quote_files file_list)) + | _ -> + assert(String.length Config.ar > 0); + let is_macosx = + match Config.system with + | "macosx" -> true + | _ -> false in - match exts with - | [cstr] -> type_of_cstr path cstr - | _ -> assert false + if is_macosx && file_list = [] then (* PR#6550 *) + macos_create_empty_archive ~quoted_archive + else + let r1 = + command(Printf.sprintf "%s rc %s %s" + Config.ar quoted_archive (quote_files file_list)) in + if r1 <> 0 || String.length Config.ranlib = 0 + then r1 + else command(Config.ranlib ^ " " ^ quoted_archive) -let find_type p env = - fst (find_type_full p env) -let find_type_descrs p env = - snd (find_type_full p env) +let expand_libname name = + if String.length name < 2 || String.sub name 0 2 <> "-l" + then name + else begin + let libname = + "lib" ^ String.sub name 2 (String.length name - 2) ^ Config.ext_lib in + try + Misc.find_in_path !Config.load_path libname + with Not_found -> + libname + end -let find_module ~alias path env = - match path with - Pident id -> - begin try - let data = IdTbl.find_same id env.modules in - EnvLazy.force subst_modtype_maker data - with Not_found -> - if Ident.persistent id && not (Ident.name id = !current_unit) then - let ps = find_pers_struct (Ident.name id) in - md (Mty_signature(Lazy.force ps.ps_sig)) - else raise Not_found - end - | Pdot(p, s, _pos) -> - begin match get_components (find_module_descr p env) with - Structure_comps c -> - let (data, _pos) = Tbl.find_str s c.comp_modules in - EnvLazy.force subst_modtype_maker data - | Functor_comps _ -> - raise Not_found - end - | Papply(p1, p2) -> - let desc1 = find_module_descr p1 env in - begin match get_components desc1 with - Functor_comps f -> - md begin match f.fcomp_res with - | Mty_alias _ as mty -> mty - | mty -> - if alias then mty else - try - Hashtbl.find f.fcomp_subst_cache p2 - with Not_found -> - let mty = - Subst.modtype - (Subst.add_module f.fcomp_param p2 Subst.identity) - f.fcomp_res in - Hashtbl.add f.fcomp_subst_cache p2 mty; - mty - end - | Structure_comps _ -> - raise Not_found - end +type link_mode = + | Exe + | Dll + | MainDll + | Partial -let required_globals = ref [] -let reset_required_globals () = required_globals := [] -let get_required_globals () = !required_globals -let add_required_global id = - if Ident.global id && not !Clflags.transparent_modules - && not (List.exists (Ident.same id) !required_globals) - then required_globals := id :: !required_globals +let remove_Wl cclibs = + cclibs |> List.map (fun cclib -> + (* -Wl,-foo,bar -> -foo bar *) + if String.length cclib >= 4 && "-Wl," = String.sub cclib 0 4 then + String.map (function ',' -> ' ' | c -> c) + (String.sub cclib 4 (String.length cclib - 4)) + else cclib) -let rec normalize_path lax env path = - let path = - match path with - Pdot(p, s, pos) -> - Pdot(normalize_path lax env p, s, pos) - | Papply(p1, p2) -> - Papply(normalize_path lax env p1, normalize_path true env p2) - | _ -> path +let call_linker mode output_name files extra = + let cmd = + if mode = Partial then + let l_prefix = + match Config.ccomp_type with + | "msvc" -> "/libpath:" + | _ -> "-L" + in + Printf.sprintf "%s%s %s %s %s" + Config.native_pack_linker + (Filename.quote output_name) + (quote_prefixed l_prefix !Config.load_path) + (quote_files (remove_Wl files)) + extra + else + Printf.sprintf "%s -o %s %s %s %s %s %s %s" + (match !Clflags.c_compiler, mode with + | Some cc, _ -> cc + | None, Exe -> Config.mkexe + | None, Dll -> Config.mkdll + | None, MainDll -> Config.mkmaindll + | None, Partial -> assert false + ) + (Filename.quote output_name) + (if !Clflags.gprofile then Config.cc_profile else "") + "" (*(Clflags.std_include_flag "-I")*) + (quote_prefixed "-L" !Config.load_path) + (String.concat " " (List.rev !Clflags.all_ccopts)) + (quote_files files) + extra in - try match find_module ~alias:true path env with - {md_type=Mty_alias(_, path1)} -> - let path' = normalize_path lax env path1 in - if lax || !Clflags.transparent_modules then path' else - let id = Path.head path in - if Ident.global id && not (Ident.same id (Path.head path')) - then add_required_global id; - path' - | _ -> path - with Not_found when lax - || (match path with Pident id -> not (Ident.persistent id) | _ -> true) -> - path + command cmd = 0 + +end +module Compenv : sig +#1 "compenv.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Fabrice Le Fessant, EPI Gallium, INRIA Paris-Rocquencourt *) +(* *) +(* Copyright 2013 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) + +val module_of_filename : Format.formatter -> string -> string -> string + +val output_prefix : string -> string +val extract_output : string option -> string +val default_output : string option -> string + +val print_version_and_library : string -> 'a +val print_version_string : unit -> 'a +val print_standard_library : unit -> 'a +val fatal : string -> 'a -let normalize_path oloc env path = - try normalize_path (oloc = None) env path - with Not_found -> - match oloc with None -> assert false - | Some loc -> - raise (Error(Missing_module(loc, path, normalize_path true env path))) +val first_ccopts : string list ref +val first_ppx : string list ref +val first_include_dirs : string list ref +val last_include_dirs : string list ref +val implicit_modules : string list ref -let normalize_path_prefix oloc env path = - match path with - Pdot(p, s, pos) -> - Pdot(normalize_path oloc env p, s, pos) - | Pident _ -> - path - | Papply _ -> - assert false +(* function to call on plugin=XXX *) +val load_plugin : (string -> unit) ref +(* return the list of objfiles, after OCAMLPARAM and List.rev *) +val get_objfiles : with_ocamlparam:bool -> string list +val last_objfiles : string list ref +val first_objfiles : string list ref -let find_module = find_module ~alias:false +type filename = string -(* Find the manifest type associated to a type when appropriate: - - the type should be public or should have a private row, - - the type should have an associated manifest type. *) -let find_type_expansion path env = - let decl = find_type path env in - match decl.type_manifest with - | Some body when decl.type_private = Public - || decl.type_kind <> Type_abstract - || Btype.has_constr_row body -> - (decl.type_params, body, may_map snd decl.type_newtype_level) - (* The manifest type of Private abstract data types without - private row are still considered unknown to the type system. - Hence, this case is caught by the following clause that also handles - purely abstract data types without manifest type definition. *) - | _ -> raise Not_found +type readenv_position = + Before_args | Before_compile of filename | Before_link -(* Find the manifest type information associated to a type, i.e. - the necessary information for the compiler's type-based optimisations. - In particular, the manifest type associated to a private abstract type - is revealed for the sake of compiler's type-based optimisations. *) -let find_type_expansion_opt path env = - let decl = find_type path env in - match decl.type_manifest with - (* The manifest type of Private abstract data types can still get - an approximation using their manifest type. *) - | Some body -> (decl.type_params, body, may_map snd decl.type_newtype_level) - | _ -> raise Not_found +val readenv : Format.formatter -> readenv_position -> unit -let find_modtype_expansion path env = - match (find_modtype path env).mtd_type with - | None -> raise Not_found - | Some mty -> mty +(* [is_unit_name name] returns true only if [name] can be used as a + correct module name *) +val is_unit_name : string -> bool +(* [check_unit_name ppf filename name] prints a warning in [filename] + on [ppf] if [name] should not be used as a module name. *) +val check_unit_name : Format.formatter -> string -> string -> unit -let rec is_functor_arg path env = - match path with - Pident id -> - begin try Ident.find_same id env.functor_args; true - with Not_found -> false - end - | Pdot (p, _s, _) -> is_functor_arg p env - | Papply _ -> true +(* Deferred actions of the compiler, while parsing arguments *) -(* Lookup by name *) +type deferred_action = + | ProcessImplementation of string + | ProcessInterface of string + | ProcessCFile of string + | ProcessOtherFile of string + | ProcessObjects of string list + | ProcessDLLs of string list -exception Recmodule +val c_object_of_filename : string -> string -let report_deprecated ?loc p deprecated = - match loc, deprecated with - | Some loc, Some txt -> - let txt = if txt = "" then "" else "\n" ^ txt in - Location.deprecated loc (Printf.sprintf "module %s%s" (Path.name p) txt) - | _ -> () +val defer : deferred_action -> unit +val anonymous : string -> unit +val impl : string -> unit +val intf : string -> unit -let mark_module_used env name loc = - if not (is_implicit_coercion env) then - try Hashtbl.find module_declarations (name, loc) () - with Not_found -> () +val process_deferred_actions : + Format.formatter * + (Format.formatter -> string -> string -> unit) * (* compile implementation *) + (Format.formatter -> string -> string -> unit) * (* compile interface *) + string * (* ocaml module extension *) + string -> (* ocaml library extension *) + unit -let rec lookup_module_descr_aux ?loc lid env = - match lid with - Lident s -> - begin try - IdTbl.find_name s env.components - with Not_found -> - if s = !current_unit then raise Not_found; - let ps = find_pers_struct s in - (Pident(Ident.create_persistent s), ps.ps_comps) - end - | Ldot(l, s) -> - let (p, descr) = lookup_module_descr ?loc l env in - begin match get_components descr with - Structure_comps c -> - let (descr, pos) = Tbl.find_str s c.comp_components in - (Pdot(p, s, pos), descr) - | Functor_comps _ -> - raise Not_found - end - | Lapply(l1, l2) -> - let (p1, desc1) = lookup_module_descr ?loc l1 env in - let p2 = lookup_module ~load:true ?loc l2 env in - let {md_type=mty2} = find_module p2 env in - begin match get_components desc1 with - Functor_comps f -> - let loc = match loc with Some l -> l | None -> Location.none in - Misc.may (!check_modtype_inclusion ~loc env mty2 p2) f.fcomp_arg; - (Papply(p1, p2), !components_of_functor_appl' f env p1 p2) - | Structure_comps _ -> - raise Not_found - end +end = struct +#1 "compenv.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Fabrice Le Fessant, EPI Gallium, INRIA Paris-Rocquencourt *) +(* *) +(* Copyright 2013 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -and lookup_module_descr ?loc lid env = - let (p, comps) as res = lookup_module_descr_aux ?loc lid env in - mark_module_used env (Path.last p) comps.loc; -(* - Format.printf "USE module %s at %a@." (Path.last p) - Location.print comps.loc; -*) - report_deprecated ?loc p comps.deprecated; - res +open Clflags -and lookup_module ~load ?loc lid env : Path.t = - match lid with - Lident s -> - begin try - let (p, data) = IdTbl.find_name s env.modules in - let {md_loc; md_attributes; md_type} = - EnvLazy.force subst_modtype_maker data - in - mark_module_used env s md_loc; - begin match md_type with - | Mty_ident (Path.Pident id) when Ident.name id = "#recmod#" -> - (* see #5965 *) - raise Recmodule - - | Mty_alias (_, Path.Pident id) -> - if !Clflags.bs_only && not !Clflags.transparent_modules && Ident.persistent id then - find_pers_struct (Ident.name id) |> ignore - - | _ -> () - end; - report_deprecated ?loc p - (Builtin_attributes.deprecated_of_attrs md_attributes); - p - with Not_found -> - if s = !current_unit then raise Not_found; - let p = Pident(Ident.create_persistent s) in - if !Clflags.transparent_modules && not load then check_pers_struct s - else begin - let ps = find_pers_struct s in - report_deprecated ?loc p ps.ps_comps.deprecated - end; - p - end - | Ldot(l, s) -> - let (p, descr) = lookup_module_descr ?loc l env in - begin match get_components descr with - Structure_comps c -> - let (_data, pos) = Tbl.find_str s c.comp_modules in - let (comps, _) = Tbl.find_str s c.comp_components in - mark_module_used env s comps.loc; - let p = Pdot(p, s, pos) in - report_deprecated ?loc p comps.deprecated; - p - | Functor_comps _ -> - raise Not_found - end - | Lapply(l1, l2) -> - let (p1, desc1) = lookup_module_descr ?loc l1 env in - let p2 = lookup_module ~load:true ?loc l2 env in - let {md_type=mty2} = find_module p2 env in - let p = Papply(p1, p2) in - begin match get_components desc1 with - Functor_comps f -> - let loc = match loc with Some l -> l | None -> Location.none in - Misc.may (!check_modtype_inclusion ~loc env mty2 p2) f.fcomp_arg; - p - | Structure_comps _ -> - raise Not_found - end +let output_prefix name = + let oname = + match !output_name with + | None -> name + | Some n -> if !compile_only then (output_name := None; n) else name in + Filename.remove_extension oname -let lookup proj1 proj2 ?loc lid env = - match lid with - Lident s -> - IdTbl.find_name s (proj1 env) - | Ldot(l, s) -> - let (p, desc) = lookup_module_descr ?loc l env in - begin match get_components desc with - Structure_comps c -> - let (data, pos) = Tbl.find_str s (proj2 c) in - (Pdot(p, s, pos), data) - | Functor_comps _ -> - raise Not_found - end - | Lapply _ -> - raise Not_found +let print_version_and_library compiler = + Printf.printf "The OCaml %s, version " compiler; + print_string Config.version; print_newline(); + print_string "Standard library directory: "; + print_string Config.standard_library; print_newline(); + exit 0 -let lookup_all_simple proj1 proj2 shadow ?loc lid env = - match lid with - Lident s -> - let xl = TycompTbl.find_all s (proj1 env) in - let rec do_shadow = - function - | [] -> [] - | ((x, f) :: xs) -> - (x, f) :: - (do_shadow (List.filter (fun (y, _) -> not (shadow x y)) xs)) - in - do_shadow xl - | Ldot(l, s) -> - let (_p, desc) = lookup_module_descr ?loc l env in - begin match get_components desc with - Structure_comps c -> - let comps = - try Tbl.find_str s (proj2 c) with Not_found -> [] - in - List.map - (fun data -> (data, (fun () -> ()))) - comps - | Functor_comps _ -> - raise Not_found - end - | Lapply _ -> - raise Not_found +let print_version_string () = + print_string Config.version; print_newline(); exit 0 -let has_local_constraints env = not (PathMap.is_empty env.local_constraints) +let print_standard_library () = + print_string Config.standard_library; print_newline(); exit 0 -let cstr_shadow cstr1 cstr2 = - match cstr1.cstr_tag, cstr2.cstr_tag with - | Cstr_extension _, Cstr_extension _ -> true - | _ -> false +let fatal err = + prerr_endline err; + exit 2 -let lbl_shadow _lbl1 _lbl2 = false +let extract_output = function + | Some s -> s + | None -> + fatal "Please specify the name of the output file, using option -o" -let lookup_value = - lookup (fun env -> env.values) (fun sc -> sc.comp_values) -let lookup_all_constructors = - lookup_all_simple (fun env -> env.constrs) (fun sc -> sc.comp_constrs) - cstr_shadow -let lookup_all_labels = - lookup_all_simple (fun env -> env.labels) (fun sc -> sc.comp_labels) - lbl_shadow -let lookup_type = - lookup (fun env -> env.types) (fun sc -> sc.comp_types) -let lookup_modtype = - lookup (fun env -> env.modtypes) (fun sc -> sc.comp_modtypes) -let lookup_class = - lookup (fun env -> env.classes) (fun sc -> sc.comp_classes) -let lookup_cltype = - lookup (fun env -> env.cltypes) (fun sc -> sc.comp_cltypes) +let default_output = function + | Some s -> s + | None -> Config.default_executable_name -let copy_types l env = - let f desc = {desc with val_type = Subst.type_expr Subst.identity desc.val_type} in - let values = List.fold_left (fun env s -> IdTbl.update s f env) env.values l in - {env with values; summary = Env_copy_types (env.summary, l)} +let implicit_modules = ref [] +let first_include_dirs = ref [] +let last_include_dirs = ref [] +let first_ccopts = ref [] +let last_ccopts = ref [] +let first_ppx = ref [] +let last_ppx = ref [] +let first_objfiles = ref [] +let last_objfiles = ref [] -let mark_value_used env name vd = - if not (is_implicit_coercion env) then - try Hashtbl.find value_declarations (name, vd.val_loc) () - with Not_found -> () +(* Check validity of module name *) +let is_unit_name name = + try + if name = "" then raise Exit; + begin match name.[0] with + | 'A'..'Z' -> () + | _ -> + raise Exit; + end; + for i = 1 to String.length name - 1 do + match name.[i] with + | 'A'..'Z' | 'a'..'z' | '0'..'9' | '_' | '\'' -> () + | _ -> + raise Exit; + done; + true + with Exit -> false +;; -let mark_type_used env name vd = - if not (is_implicit_coercion env) then - try Hashtbl.find type_declarations (name, vd.type_loc) () - with Not_found -> () +let check_unit_name ppf filename name = -let mark_constructor_used usage env name vd constr = - if not (is_implicit_coercion env) then - try Hashtbl.find used_constructors (name, vd.type_loc, constr) usage - with Not_found -> () + let _ = ppf in + let _ = filename in + let _ = name in + () -let mark_extension_used usage env ext name = - if not (is_implicit_coercion env) then - let ty_name = Path.last ext.ext_type_path in - try Hashtbl.find used_constructors (ty_name, ext.ext_loc, name) usage - with Not_found -> () -let set_value_used_callback name vd callback = - let key = (name, vd.val_loc) in +(* Compute name of module from output file name *) +let module_of_filename ppf inputfile outputprefix = + let basename = Filename.basename outputprefix in + let name = + try + let pos = String.index basename '.' in + String.sub basename 0 pos + with Not_found -> basename + in + let name = String.capitalize_ascii name in + check_unit_name ppf inputfile name; + name +;; + +type filename = string + +type readenv_position = + Before_args | Before_compile of filename | Before_link + +(* Syntax of OCAMLPARAM: (name=VALUE,)* _ (,name=VALUE)* + where VALUE should not contain ',' *) +exception SyntaxError of string + +let parse_args s = + let args = String.split_on_char ',' s in + let rec iter is_after args before after = + match args with + [] -> + if not is_after then + raise (SyntaxError "no '_' separator found") + else + (List.rev before, List.rev after) + | "_" :: _ when is_after -> raise (SyntaxError "too many '_' separators") + | "_" :: tail -> iter true tail before after + | arg :: tail -> + let binding = try + Misc.cut_at arg '=' + with Not_found -> + raise (SyntaxError ("missing '=' in " ^ arg)) + in + if is_after then + iter is_after tail before (binding :: after) + else + iter is_after tail (binding :: before) after + in + iter false args [] [] + +let setter ppf f name options s = try - let old = Hashtbl.find value_declarations key in - Hashtbl.replace value_declarations key (fun () -> old (); callback ()) - (* this is to support cases like: - let x = let x = 1 in x in x - where the two declarations have the same location - (e.g. resulting from Camlp4 expansion of grammar entries) *) + let bool = match s with + | "0" -> false + | "1" -> true + | _ -> raise Not_found + in + List.iter (fun b -> b := f bool) options with Not_found -> - Hashtbl.add value_declarations key callback + Location.print_warning Location.none ppf + (Warnings.Bad_env_variable ("OCAMLPARAM", + Printf.sprintf "bad value for %s" name)) + +let int_setter ppf name option s = + try + option := int_of_string s + with _ -> + Location.print_warning Location.none ppf + (Warnings.Bad_env_variable + ("OCAMLPARAM", Printf.sprintf "non-integer parameter for \"%s\"" name)) + +let int_option_setter ppf name option s = + try + option := Some (int_of_string s) + with _ -> + Location.print_warning Location.none ppf + (Warnings.Bad_env_variable + ("OCAMLPARAM", Printf.sprintf "non-integer parameter for \"%s\"" name)) + +(* +let float_setter ppf name option s = + try + option := float_of_string s + with _ -> + Location.print_warning Location.none ppf + (Warnings.Bad_env_variable + ("OCAMLPARAM", Printf.sprintf "non-float parameter for \"%s\"" name)) +*) + +let load_plugin = ref (fun _ -> ()) + +let check_bool ppf name s = + match s with + | "0" -> false + | "1" -> true + | _ -> + Location.print_warning Location.none ppf + (Warnings.Bad_env_variable ("OCAMLPARAM", + Printf.sprintf "bad value for %s" name)); + false + +(* 'can-discard=' specifies which arguments can be discarded without warning + because they are not understood by some versions of OCaml. *) +let can_discard = ref [] + +let read_one_param ppf position name v = + let set name options s = setter ppf (fun b -> b) name options s in + let clear name options s = setter ppf (fun b -> not b) name options s in + match name with + | "g" -> set "g" [ Clflags.debug ] v + | "p" -> set "p" [ Clflags.gprofile ] v + | "bin-annot" -> set "bin-annot" [ Clflags.binary_annotations ] v + | "afl-instrument" -> set "afl-instrument" [ Clflags.afl_instrument ] v + | "afl-inst-ratio" -> + int_setter ppf "afl-inst-ratio" afl_inst_ratio v + | "annot" -> set "annot" [ Clflags.annotations ] v + | "absname" -> set "absname" [ Location.absname ] v + | "compat-32" -> set "compat-32" [ bytecode_compatible_32 ] v + | "noassert" -> set "noassert" [ noassert ] v + | "noautolink" -> set "noautolink" [ no_auto_link ] v + | "nostdlib" -> set "nostdlib" [ no_std_include ] v + | "linkall" -> set "linkall" [ link_everything ] v + | "nolabels" -> set "nolabels" [ classic ] v + | "principal" -> set "principal" [ principal ] v + | "rectypes" -> set "rectypes" [ recursive_types ] v + | "safe-string" -> clear "safe-string" [ unsafe_string ] v + | "strict-sequence" -> set "strict-sequence" [ strict_sequence ] v + | "strict-formats" -> set "strict-formats" [ strict_formats ] v + | "thread" -> set "thread" [ use_threads ] v + | "unboxed-types" -> set "unboxed-types" [ unboxed_types ] v + | "unsafe" -> set "unsafe" [ fast ] v + | "verbose" -> set "verbose" [ verbose ] v + | "nopervasives" -> set "nopervasives" [ nopervasives ] v + | "slash" -> set "slash" [ force_slash ] v (* for ocamldep *) + | "keep-docs" -> set "keep-docs" [ Clflags.keep_docs ] v + | "keep-locs" -> set "keep-locs" [ Clflags.keep_locs ] v + + | "compact" -> clear "compact" [ optimize_for_speed ] v + | "no-app-funct" -> clear "no-app-funct" [ applicative_functors ] v + | "nodynlink" -> clear "nodynlink" [ dlcode ] v + | "short-paths" -> clear "short-paths" [ real_paths ] v + | "trans-mod" -> set "trans-mod" [ transparent_modules ] v + | "opaque" -> set "opaque" [ opaque ] v -let set_type_used_callback name td callback = - let loc = td.type_loc in - if loc.Location.loc_ghost then () - else let key = (name, loc) in - let old = - try Hashtbl.find type_declarations key - with Not_found -> assert false - in - Hashtbl.replace type_declarations key (fun () -> callback old) + | "pp" -> preprocessor := Some v + | "runtime-variant" -> runtime_variant := v + | "cc" -> c_compiler := Some v -let lookup_value ?loc lid env = - let (_, desc) as r = lookup_value ?loc lid env in - mark_value_used env (Longident.last lid) desc; - r + | "clambda-checks" -> set "clambda-checks" [ clambda_checks ] v -let lookup_type ?loc lid env = - let (path, (decl, _)) = lookup_type ?loc lid env in - mark_type_used env (Longident.last lid) decl; - path + (* assembly sources *) + | "s" -> + set "s" [ Clflags.keep_asm_file ; Clflags.keep_startup_file ] v + | "S" -> set "S" [ Clflags.keep_asm_file ] v + | "dstartup" -> set "dstartup" [ Clflags.keep_startup_file ] v -let mark_type_path env path = - try - let decl = find_type path env in - mark_type_used env (Path.last path) decl - with Not_found -> () + (* warn-errors *) + | "we" | "warn-error" -> Warnings.parse_options true v + (* warnings *) + | "w" -> Warnings.parse_options false v + (* warn-errors *) + | "wwe" -> Warnings.parse_options false v -let ty_path t = - match repr t with - | {desc=Tconstr(path, _, _)} -> path - | _ -> assert false + (* inlining *) + | "inline" -> + let module F = Float_arg_helper in + begin match F.parse_no_error v inline_threshold with + | F.Ok -> () + | F.Parse_failed exn -> + let error = + Printf.sprintf "bad syntax for \"inline\": %s" + (Printexc.to_string exn) + in + Location.print_warning Location.none ppf + (Warnings.Bad_env_variable ("OCAMLPARAM", error)) + end -let lookup_constructor ?loc lid env = - match lookup_all_constructors ?loc lid env with - [] -> raise Not_found - | (desc, use) :: _ -> - mark_type_path env (ty_path desc.cstr_res); - use (); - desc + | "inline-toplevel" -> + Int_arg_helper.parse v + "Bad syntax in OCAMLPARAM for 'inline-toplevel'" + inline_toplevel_threshold -let is_lident = function - Lident _ -> true - | _ -> false + | "rounds" -> int_option_setter ppf "rounds" simplify_rounds v + | "inline-max-unroll" -> + Int_arg_helper.parse v "Bad syntax in OCAMLPARAM for 'inline-max-unroll'" + inline_max_unroll + | "inline-call-cost" -> + Int_arg_helper.parse v + "Bad syntax in OCAMLPARAM for 'inline-call-cost'" + inline_call_cost + | "inline-alloc-cost" -> + Int_arg_helper.parse v + "Bad syntax in OCAMLPARAM for 'inline-alloc-cost'" + inline_alloc_cost + | "inline-prim-cost" -> + Int_arg_helper.parse v + "Bad syntax in OCAMLPARAM for 'inline-prim-cost'" + inline_prim_cost + | "inline-branch-cost" -> + Int_arg_helper.parse v + "Bad syntax in OCAMLPARAM for 'inline-branch-cost'" + inline_branch_cost + | "inline-indirect-cost" -> + Int_arg_helper.parse v + "Bad syntax in OCAMLPARAM for 'inline-indirect-cost'" + inline_indirect_cost + | "inline-lifting-benefit" -> + Int_arg_helper.parse v + "Bad syntax in OCAMLPARAM for 'inline-lifting-benefit'" + inline_lifting_benefit + | "inline-branch-factor" -> + Float_arg_helper.parse v + "Bad syntax in OCAMLPARAM for 'inline-branch-factor'" + inline_branch_factor + | "inline-max-depth" -> + Int_arg_helper.parse v + "Bad syntax in OCAMLPARAM for 'inline-max-depth'" + inline_max_depth -let lookup_all_constructors ?loc lid env = - try - let cstrs = lookup_all_constructors ?loc lid env in - let wrap_use desc use () = - mark_type_path env (ty_path desc.cstr_res); - use () - in - List.map (fun (cstr, use) -> (cstr, wrap_use cstr use)) cstrs - with - Not_found when is_lident lid -> [] + | "Oclassic" -> + set "Oclassic" [ classic_inlining ] v + | "O2" -> + if check_bool ppf "O2" v then begin + default_simplify_rounds := 2; + use_inlining_arguments_set o2_arguments; + use_inlining_arguments_set ~round:0 o1_arguments + end -let mark_constructor usage env name desc = - if not (is_implicit_coercion env) - then match desc.cstr_tag with - | Cstr_extension _ -> - begin - let ty_path = ty_path desc.cstr_res in - let ty_name = Path.last ty_path in - try Hashtbl.find used_constructors (ty_name, desc.cstr_loc, name) usage - with Not_found -> () - end - | _ -> - let ty_path = ty_path desc.cstr_res in - let ty_decl = try find_type ty_path env with Not_found -> assert false in - let ty_name = Path.last ty_path in - mark_constructor_used usage env ty_name ty_decl name + | "O3" -> + if check_bool ppf "O3" v then begin + default_simplify_rounds := 3; + use_inlining_arguments_set o3_arguments; + use_inlining_arguments_set ~round:1 o2_arguments; + use_inlining_arguments_set ~round:0 o1_arguments + end + | "unbox-closures" -> + set "unbox-closures" [ unbox_closures ] v + | "unbox-closures-factor" -> + int_setter ppf "unbox-closures-factor" unbox_closures_factor v + | "remove-unused-arguments" -> + set "remove-unused-arguments" [ remove_unused_arguments ] v -let lookup_label ?loc lid env = - match lookup_all_labels ?loc lid env with - [] -> raise Not_found - | (desc, use) :: _ -> - mark_type_path env (ty_path desc.lbl_res); - use (); - desc + | "inlining-report" -> + if !native_code then + set "inlining-report" [ inlining_report ] v -let lookup_all_labels ?loc lid env = - try - let lbls = lookup_all_labels ?loc lid env in - let wrap_use desc use () = - mark_type_path env (ty_path desc.lbl_res); - use () - in - List.map (fun (lbl, use) -> (lbl, wrap_use lbl use)) lbls - with - Not_found when is_lident lid -> [] + | "flambda-verbose" -> + set "flambda-verbose" [ dump_flambda_verbose ] v + | "flambda-invariants" -> + set "flambda-invariants" [ flambda_invariant_checks ] v -let lookup_class ?loc lid env = - let (_, desc) as r = lookup_class ?loc lid env in - (* special support for Typeclass.unbound_class *) - if Path.name desc.cty_path = "" then ignore (lookup_type ?loc lid env) - else mark_type_path env desc.cty_path; - r + (* color output *) + | "color" -> + begin match parse_color_setting v with + | None -> + Location.print_warning Location.none ppf + (Warnings.Bad_env_variable ("OCAMLPARAM", + "bad value for \"color\", \ + (expected \"auto\", \"always\" or \"never\")")) + | Some setting -> color := Some setting + end -let lookup_cltype ?loc lid env = - let (_, desc) as r = lookup_cltype ?loc lid env in - if Path.name desc.clty_path = "" then ignore (lookup_type ?loc lid env) - else mark_type_path env desc.clty_path; - mark_type_path env desc.clty_path; - r + | "intf-suffix" -> Config.interface_suffix := v -(* Iter on an environment (ignoring the body of functors and - not yet evaluated structures) *) + | "I" -> begin + match position with + | Before_args -> first_include_dirs := v :: !first_include_dirs + | Before_link | Before_compile _ -> + last_include_dirs := v :: !last_include_dirs + end -type iter_cont = unit -> unit -let iter_env_cont = ref [] + | "cclib" -> + begin + match position with + | Before_compile _ -> () + | Before_link | Before_args -> + ccobjs := Misc.rev_split_words v @ !ccobjs + end -let rec scrape_alias_for_visit env mty = - match mty with - | Mty_alias(_, Pident id) - when Ident.persistent id - && not (Hashtbl.mem persistent_structures (Ident.name id)) -> false - | Mty_alias(_, path) -> (* PR#6600: find_module may raise Not_found *) - begin try scrape_alias_for_visit env (find_module path env).md_type - with Not_found -> false - end - | _ -> true + | "ccopts" -> + begin + match position with + | Before_link | Before_compile _ -> + last_ccopts := v :: !last_ccopts + | Before_args -> + first_ccopts := v :: !first_ccopts + end -let iter_env proj1 proj2 f env () = - IdTbl.iter (fun id x -> f (Pident id) x) (proj1 env); - let rec iter_components path path' mcomps = - let cont () = - let visit = - match EnvLazy.get_arg mcomps.comps with - | None -> true - | Some (env, _sub, _path, mty) -> scrape_alias_for_visit env mty - in - if not visit then () else - match get_components mcomps with - Structure_comps comps -> - Tbl.iter - (fun s (d, n) -> f (Pdot (path, s, n)) (Pdot (path', s, n), d)) - (proj2 comps); - Tbl.iter - (fun s (c, n) -> - iter_components (Pdot (path, s, n)) (Pdot (path', s, n)) c) - comps.comp_components - | Functor_comps _ -> () - in iter_env_cont := (path, cont) :: !iter_env_cont - in - Hashtbl.iter - (fun s pso -> - match pso with None -> () - | Some ps -> - let id = Pident (Ident.create_persistent s) in - iter_components id id ps.ps_comps) - persistent_structures; - IdTbl.iter - (fun id (path, comps) -> iter_components (Pident id) path comps) - env.components + | "ppx" -> + begin + match position with + | Before_link | Before_compile _ -> + last_ppx := v :: !last_ppx + | Before_args -> + first_ppx := v :: !first_ppx + end -let run_iter_cont l = - iter_env_cont := []; - List.iter (fun c -> c ()) l; - let cont = List.rev !iter_env_cont in - iter_env_cont := []; - cont -let iter_types f = iter_env (fun env -> env.types) (fun sc -> sc.comp_types) f + | "cmo" | "cma" -> + if not !native_code then + begin + match position with + | Before_link | Before_compile _ -> + last_objfiles := v ::! last_objfiles + | Before_args -> + first_objfiles := v :: !first_objfiles + end -let same_types env1 env2 = - env1.types == env2.types && env1.components == env2.components + | "cmx" | "cmxa" -> + if !native_code then + begin + match position with + | Before_link | Before_compile _ -> + last_objfiles := v ::! last_objfiles + | Before_args -> + first_objfiles := v :: !first_objfiles + end -let used_persistent () = - let r = ref Concr.empty in - Hashtbl.iter (fun s pso -> if pso != None then r := Concr.add s !r) - persistent_structures; - !r + | "pic" -> + if !native_code then + set "pic" [ pic_code ] v -let find_all_comps proj s (p,mcomps) = - match get_components mcomps with - Functor_comps _ -> [] - | Structure_comps comps -> - try let (c,n) = Tbl.find_str s (proj comps) in [Pdot(p,s,n), c] - with Not_found -> [] + | "can-discard" -> + can_discard := v ::!can_discard -let rec find_shadowed_comps path env = - match path with - Pident id -> - IdTbl.find_all (Ident.name id) env.components - | Pdot (p, s, _) -> - let l = find_shadowed_comps p env in - let l' = - List.map (find_all_comps (fun comps -> comps.comp_components) s) l in - List.flatten l' - | Papply _ -> [] + | "timings" | "profile" -> + let if_on = if name = "timings" then [ `Time ] else Profile.all_columns in + profile_columns := if check_bool ppf name v then if_on else [] -let find_shadowed proj1 proj2 path env = - match path with - Pident id -> - IdTbl.find_all (Ident.name id) (proj1 env) - | Pdot (p, s, _) -> - let l = find_shadowed_comps p env in - let l' = List.map (find_all_comps proj2 s) l in - List.flatten l' - | Papply _ -> [] + | "plugin" -> !load_plugin v -let find_shadowed_types path env = - List.map fst - (find_shadowed - (fun env -> env.types) (fun comps -> comps.comp_types) path env) + | _ -> + if not (List.mem name !can_discard) then begin + can_discard := name :: !can_discard; + Printf.eprintf + "Warning: discarding value of variable %S in OCAMLPARAM\n%!" + name + end +let read_OCAMLPARAM ppf position = + try + let s = Sys.getenv "OCAMLPARAM" in + let (before, after) = + try + parse_args s + with SyntaxError s -> + Location.print_warning Location.none ppf + (Warnings.Bad_env_variable ("OCAMLPARAM", s)); + [],[] + in + List.iter (fun (name, v) -> read_one_param ppf position name v) + (match position with + Before_args -> before + | Before_compile _ | Before_link -> after) + with Not_found -> () -(* GADT instance tracking *) +(* OCAMLPARAM passed as file *) -let add_gadt_instance_level lv env = - {env with - gadt_instances = (lv, ref TypeSet.empty) :: env.gadt_instances} +type pattern = + | Filename of string + | Any -let is_Tlink = function {desc = Tlink _} -> true | _ -> false +type file_option = { + pattern : pattern; + name : string; + value : string; +} -let gadt_instance_level env t = - let rec find_instance = function - [] -> None - | (lv, r) :: rem -> - if TypeSet.exists is_Tlink !r then - (* Should we use set_typeset ? *) - r := TypeSet.fold (fun ty -> TypeSet.add (repr ty)) !r TypeSet.empty; - if TypeSet.mem t !r then Some lv else find_instance rem - in find_instance env.gadt_instances +let scan_line ic = + Scanf.bscanf ic "%[0-9a-zA-Z_.*] : %[a-zA-Z_-] = %s " + (fun pattern name value -> + let pattern = + match pattern with + | "*" -> Any + | _ -> Filename pattern + in + { pattern; name; value }) -let add_gadt_instances env lv tl = - let r = - try List.assoc lv env.gadt_instances with Not_found -> assert false in - (* Format.eprintf "Added"; - List.iter (fun ty -> Format.eprintf "@ %a" !Btype.print_raw ty) tl; - Format.eprintf "@."; *) - set_typeset r (List.fold_right TypeSet.add tl !r) +let load_config ppf filename = + match open_in_bin filename with + | exception e -> + Location.print_error ppf (Location.in_file filename); + Format.fprintf ppf "Cannot open file %s@." (Printexc.to_string e); + raise Exit + | ic -> + let sic = Scanf.Scanning.from_channel ic in + let rec read line_number line_start acc = + match scan_line sic with + | exception End_of_file -> + close_in ic; + acc + | exception Scanf.Scan_failure error -> + let position = Lexing.{ + pos_fname = filename; + pos_lnum = line_number; + pos_bol = line_start; + pos_cnum = pos_in ic; + } + in + let loc = Location.{ + loc_start = position; + loc_end = position; + loc_ghost = false; + } + in + Location.print_error ppf loc; + Format.fprintf ppf "Configuration file error %s@." error; + close_in ic; + raise Exit + | line -> + read (line_number + 1) (pos_in ic) (line :: acc) + in + let lines = read 0 0 [] in + lines -(* Only use this after expand_head! *) -let add_gadt_instance_chain env lv t = - let r = - try List.assoc lv env.gadt_instances with Not_found -> assert false in - let rec add_instance t = - let t = repr t in - if not (TypeSet.mem t !r) then begin - (* Format.eprintf "@ %a" !Btype.print_raw t; *) - set_typeset r (TypeSet.add t !r); - match t.desc with - Tconstr (p, _, memo) -> - may add_instance (find_expans Private p !memo) - | _ -> () - end +let matching_filename filename { pattern } = + match pattern with + | Any -> true + | Filename pattern -> + let filename = String.lowercase_ascii filename in + let pattern = String.lowercase_ascii pattern in + filename = pattern + +let apply_config_file ppf position = + let config_file = + Filename.concat Config.standard_library "ocaml_compiler_internal_params" in - (* Format.eprintf "Added chain"; *) - add_instance t - (* Format.eprintf "@." *) + let config = + if Sys.file_exists config_file then + load_config ppf config_file + else + [] + in + let config = + match position with + | Before_compile filename -> + List.filter (matching_filename filename) config + | Before_args | Before_link -> + List.filter (fun { pattern } -> pattern = Any) config + in + List.iter (fun { name; value } -> read_one_param ppf position name value) + config -(* Expand manifest module type names at the top of the given module type *) +let readenv ppf position = + last_include_dirs := []; + last_ccopts := []; + last_ppx := []; + last_objfiles := []; + apply_config_file ppf position; + read_OCAMLPARAM ppf position; + all_ccopts := !last_ccopts @ !first_ccopts; + all_ppx := !last_ppx @ !first_ppx -let rec scrape_alias env ?path mty = - match mty, path with - Mty_ident p, _ -> - begin try - scrape_alias env (find_modtype_expansion p env) ?path - with Not_found -> - mty - end - | Mty_alias(_, path), _ -> - begin try - scrape_alias env (find_module path env).md_type ~path - with Not_found -> - (*Location.prerr_warning Location.none - (Warnings.No_cmi_file (Path.name path));*) - mty - end - | mty, Some path -> - !strengthen ~aliasable:true env mty path - | _ -> mty +let get_objfiles ~with_ocamlparam = + if with_ocamlparam then + List.rev (!last_objfiles @ !objfiles @ !first_objfiles) + else + List.rev !objfiles -let scrape_alias env mty = scrape_alias env mty -(* Given a signature and a root path, prefix all idents in the signature - by the root path and build the corresponding substitution. *) -let rec prefix_idents root pos sub = function - [] -> ([], sub) - | Sig_value(id, decl) :: rem -> - let p = Pdot(root, Ident.name id, pos) in - let nextpos = match decl.val_kind with Val_prim _ -> pos | _ -> pos+1 in - let (pl, final_sub) = prefix_idents root nextpos sub rem in - (p::pl, final_sub) - | Sig_type(id, _, _) :: rem -> - let p = Pdot(root, Ident.name id, nopos) in - let (pl, final_sub) = - prefix_idents root pos (Subst.add_type id p sub) rem in - (p::pl, final_sub) - | Sig_typext(id, _, _) :: rem -> - let p = Pdot(root, Ident.name id, pos) in - (* we extend the substitution in case of an inlined record *) - let (pl, final_sub) = - prefix_idents root (pos+1) (Subst.add_type id p sub) rem in - (p::pl, final_sub) - | Sig_module(id, _, _) :: rem -> - let p = Pdot(root, Ident.name id, pos) in - let (pl, final_sub) = - prefix_idents root (pos+1) (Subst.add_module id p sub) rem in - (p::pl, final_sub) - | Sig_modtype(id, _) :: rem -> - let p = Pdot(root, Ident.name id, nopos) in - let (pl, final_sub) = - prefix_idents root pos - (Subst.add_modtype id (Mty_ident p) sub) rem in - (p::pl, final_sub) - | Sig_class(id, _, _) :: rem -> - (* pretend this is a type, cf. PR#6650 *) - let p = Pdot(root, Ident.name id, pos) in - let (pl, final_sub) = - prefix_idents root (pos + 1) (Subst.add_type id p sub) rem in - (p::pl, final_sub) - | Sig_class_type(id, _, _) :: rem -> - let p = Pdot(root, Ident.name id, nopos) in - let (pl, final_sub) = - prefix_idents root pos (Subst.add_type id p sub) rem in - (p::pl, final_sub) -let prefix_idents root sub sg = - if sub = Subst.identity then - let sgs = - try - Hashtbl.find prefixed_sg root - with Not_found -> - let sgs = ref [] in - Hashtbl.add prefixed_sg root sgs; - sgs - in - try - List.assq sg !sgs - with Not_found -> - let r = prefix_idents root 0 sub sg in - sgs := (sg, r) :: !sgs; - r - else - prefix_idents root 0 sub sg -(* Compute structure descriptions *) -let add_to_tbl id decl tbl = - let decls = - try Tbl.find_str id tbl with Not_found -> [] in - Tbl.add id (decl :: decls) tbl +type deferred_action = + | ProcessImplementation of string + | ProcessInterface of string + | ProcessCFile of string + | ProcessOtherFile of string + | ProcessObjects of string list + | ProcessDLLs of string list -let rec components_of_module ~deprecated ~loc env sub path mty = - { - deprecated; - loc; - comps = EnvLazy.create (env, sub, path, mty) - } +let c_object_of_filename name = + Filename.chop_suffix (Filename.basename name) ".c" ^ Config.ext_obj -and components_of_module_maker (env, sub, path, mty) = - match scrape_alias env mty with - Mty_signature sg -> - let c = - { comp_values = Tbl.empty; - comp_constrs = Tbl.empty; - comp_labels = Tbl.empty; comp_types = Tbl.empty; - comp_modules = Tbl.empty; comp_modtypes = Tbl.empty; - comp_components = Tbl.empty; comp_classes = Tbl.empty; - comp_cltypes = Tbl.empty } in - let pl, sub = prefix_idents path sub sg in - let env = ref env in - let pos = ref 0 in - List.iter2 (fun item path -> - match item with - Sig_value(id, decl) -> - let decl' = Subst.value_description sub decl in - c.comp_values <- - Tbl.add (Ident.name id) (decl', !pos) c.comp_values; - begin match decl.val_kind with - Val_prim _ -> () | _ -> incr pos - end - | Sig_type(id, decl, _) -> - let decl' = Subst.type_declaration sub decl in - Datarepr.set_row_name decl' (Subst.type_path sub (Path.Pident id)); - let constructors = - List.map snd (Datarepr.constructors_of_type path decl') in - let labels = - List.map snd (Datarepr.labels_of_type path decl') in - c.comp_types <- - Tbl.add (Ident.name id) - ((decl', (constructors, labels)), nopos) - c.comp_types; - List.iter - (fun descr -> - c.comp_constrs <- - add_to_tbl descr.cstr_name descr c.comp_constrs) - constructors; - List.iter - (fun descr -> - c.comp_labels <- - add_to_tbl descr.lbl_name descr c.comp_labels) - labels; - env := store_type_infos id decl !env - | Sig_typext(id, ext, _) -> - let ext' = Subst.extension_constructor sub ext in - let descr = Datarepr.extension_descr path ext' in - c.comp_constrs <- - add_to_tbl (Ident.name id) descr c.comp_constrs; - incr pos - | Sig_module(id, md, _) -> - let md' = EnvLazy.create (sub, md) in - c.comp_modules <- - Tbl.add (Ident.name id) (md', !pos) c.comp_modules; - let deprecated = - Builtin_attributes.deprecated_of_attrs md.md_attributes - in - let comps = - components_of_module ~deprecated ~loc:md.md_loc !env sub path - md.md_type - in - c.comp_components <- - Tbl.add (Ident.name id) (comps, !pos) c.comp_components; - env := store_module ~check:false id md !env; - incr pos - | Sig_modtype(id, decl) -> - let decl' = Subst.modtype_declaration sub decl in - c.comp_modtypes <- - Tbl.add (Ident.name id) (decl', nopos) c.comp_modtypes; - env := store_modtype id decl !env - | Sig_class(id, decl, _) -> - let decl' = Subst.class_declaration sub decl in - c.comp_classes <- - Tbl.add (Ident.name id) (decl', !pos) c.comp_classes; - incr pos - | Sig_class_type(id, decl, _) -> - let decl' = Subst.cltype_declaration sub decl in - c.comp_cltypes <- - Tbl.add (Ident.name id) (decl', !pos) c.comp_cltypes) - sg pl; - Some (Structure_comps c) - | Mty_functor(param, ty_arg, ty_res) -> - Some (Functor_comps { - fcomp_param = param; - (* fcomp_arg and fcomp_res must be prefixed eagerly, because - they are interpreted in the outer environment *) - fcomp_arg = may_map (Subst.modtype sub) ty_arg; - fcomp_res = Subst.modtype sub ty_res; - fcomp_cache = Hashtbl.create 17; - fcomp_subst_cache = Hashtbl.create 17 }) - | Mty_ident _ - | Mty_alias _ -> None +let process_action + (ppf, implementation, interface, ocaml_mod_ext, ocaml_lib_ext) action = + match action with + | ProcessImplementation name -> + readenv ppf (Before_compile name); + let opref = output_prefix name in + implementation ppf name opref; + objfiles := (opref ^ ocaml_mod_ext) :: !objfiles + | ProcessInterface name -> + readenv ppf (Before_compile name); + let opref = output_prefix name in + interface ppf name opref; + if !make_package then objfiles := (opref ^ ".cmi") :: !objfiles + | ProcessCFile name -> + readenv ppf (Before_compile name); + Location.set_input_name name; + if Ccomp.compile_file name <> 0 then exit 2; + ccobjs := c_object_of_filename name :: !ccobjs + | ProcessObjects names -> + ccobjs := names @ !ccobjs + | ProcessDLLs names -> + dllibs := names @ !dllibs + | ProcessOtherFile name -> + if Filename.check_suffix name ocaml_mod_ext + || Filename.check_suffix name ocaml_lib_ext then + objfiles := name :: !objfiles + else if Filename.check_suffix name ".cmi" && !make_package then + objfiles := name :: !objfiles + else if Filename.check_suffix name Config.ext_obj + || Filename.check_suffix name Config.ext_lib then + ccobjs := name :: !ccobjs + else if not !native_code && Filename.check_suffix name Config.ext_dll then + dllibs := name :: !dllibs + else + raise(Arg.Bad("don't know what to do with " ^ name)) -(* Insertion of bindings by identifier + path *) -and check_usage loc id warn tbl = - if not loc.Location.loc_ghost && Warnings.is_active (warn "") then begin - let name = Ident.name id in - let key = (name, loc) in - if Hashtbl.mem tbl key then () - else let used = ref false in - Hashtbl.add tbl key (fun () -> used := true); - if not (name = "" || name.[0] = '_' || name.[0] = '#') - then - !add_delayed_check_forward - (fun () -> if not !used then Location.prerr_warning loc (warn name)) +let action_of_file name = + if Filename.check_suffix name ".ml" + || Filename.check_suffix name ".mlt" then + ProcessImplementation name + else if Filename.check_suffix name !Config.interface_suffix then + ProcessInterface name + else if Filename.check_suffix name ".c" then + ProcessCFile name + else + ProcessOtherFile name + +let deferred_actions = ref [] +let defer action = + deferred_actions := action :: !deferred_actions + +let anonymous filename = defer (action_of_file filename) +let impl filename = defer (ProcessImplementation filename) +let intf filename = defer (ProcessInterface filename) + +let process_deferred_actions env = + let final_output_name = !output_name in + (* Make sure the intermediate products don't clash with the final one + when we're invoked like: ocamlopt -o foo bar.c baz.ml. *) + if not !compile_only then output_name := None; + begin + match final_output_name with + | None -> () + | Some output_name -> + if !compile_only then begin + if List.filter (function + | ProcessCFile name -> c_object_of_filename name <> output_name + | _ -> false) !deferred_actions <> [] then + fatal "Options -c and -o are incompatible when compiling C files"; + + if List.length (List.filter (function + | ProcessImplementation _ + | ProcessInterface _ + | _ -> false) !deferred_actions) > 1 then + fatal "Options -c -o are incompatible with compiling multiple files" + end; end; + if !make_archive && List.exists (function + | ProcessOtherFile name -> Filename.check_suffix name ".cmxa" + | _ -> false) !deferred_actions then + fatal "Option -a cannot be used with .cmxa input files."; + List.iter (process_action env) (List.rev !deferred_actions); + output_name := final_output_name; -and check_value_name name loc = - (* Note: we could also check here general validity of the - identifier, to protect against bad identifiers forged by -pp or - -ppx preprocessors. *) - if !Clflags.bs_only && name = "|." then raise (Error(Illegal_value_name(loc, name))) - else if String.length name > 0 && (name.[0] = '#') then - for i = 1 to String.length name - 1 do - if name.[i] = '#' then - raise (Error(Illegal_value_name(loc, name))) - done +end +module Ext_pervasives : sig +#1 "ext_pervasives.mli" +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -and store_value ?check id decl env = - check_value_name (Ident.name id) decl.val_loc; - may (fun f -> check_usage decl.val_loc id f value_declarations) check; - { env with - values = IdTbl.add id decl env.values; - summary = Env_value(env.summary, id, decl) } -and store_type ~check id info env = - let loc = info.type_loc in - if check then - check_usage loc id (fun s -> Warnings.Unused_type_declaration s) - type_declarations; - let path = Pident id in - let constructors = Datarepr.constructors_of_type path info in - let labels = Datarepr.labels_of_type path info in - let descrs = (List.map snd constructors, List.map snd labels) in - if check && not loc.Location.loc_ghost && - Warnings.is_active (Warnings.Unused_constructor ("", false, false)) - then begin - let ty = Ident.name id in - List.iter - begin fun (_, {cstr_name = c; _}) -> - let k = (ty, loc, c) in - if not (Hashtbl.mem used_constructors k) then - let used = constructor_usages () in - Hashtbl.add used_constructors k (add_constructor_usage used); - if not (ty = "" || ty.[0] = '_') - then !add_delayed_check_forward - (fun () -> - if not (is_in_signature env) && not used.cu_positive then - Location.prerr_warning loc - (Warnings.Unused_constructor - (c, used.cu_pattern, used.cu_privatize))) - end - constructors - end; - { env with - constrs = - List.fold_right - (fun (id, descr) constrs -> TycompTbl.add id descr constrs) - constructors - env.constrs; - labels = - List.fold_right - (fun (id, descr) labels -> TycompTbl.add id descr labels) - labels - env.labels; - types = - IdTbl.add id (info, descrs) env.types; - summary = Env_type(env.summary, id, info) } -and store_type_infos id info env = - (* Simplified version of store_type that doesn't compute and store - constructor and label infos, but simply record the arity and - manifest-ness of the type. Used in components_of_module to - keep track of type abbreviations (e.g. type t = float) in the - computation of label representations. *) - { env with - types = IdTbl.add id (info,([],[])) - env.types; - summary = Env_type(env.summary, id, info) } -and store_extension ~check id ext env = - let loc = ext.ext_loc in - if check && not loc.Location.loc_ghost && - Warnings.is_active (Warnings.Unused_extension ("", false, false, false)) - then begin - let is_exception = Path.same ext.ext_type_path Predef.path_exn in - let ty = Path.last ext.ext_type_path in - let n = Ident.name id in - let k = (ty, loc, n) in - if not (Hashtbl.mem used_constructors k) then begin - let used = constructor_usages () in - Hashtbl.add used_constructors k (add_constructor_usage used); - !add_delayed_check_forward - (fun () -> - if not (is_in_signature env) && not used.cu_positive then - Location.prerr_warning loc - (Warnings.Unused_extension - (n, is_exception, used.cu_pattern, used.cu_privatize) - ) - ) - end; - end; - { env with - constrs = TycompTbl.add id - (Datarepr.extension_descr (Pident id) ext) - env.constrs; - summary = Env_extension(env.summary, id, ext) } -and store_module ~check id md env = - let loc = md.md_loc in - if check then - check_usage loc id (fun s -> Warnings.Unused_module s) - module_declarations; - let deprecated = Builtin_attributes.deprecated_of_attrs md.md_attributes in - { env with - modules = IdTbl.add id (EnvLazy.create (Subst.identity, md)) env.modules; - components = - IdTbl.add id - (components_of_module ~deprecated ~loc:md.md_loc - env Subst.identity (Pident id) md.md_type) - env.components; - summary = Env_module(env.summary, id, md) } +(** Extension to standard library [Pervavives] module, safe to open + *) -and store_modtype id info env = - { env with - modtypes = IdTbl.add id info env.modtypes; - summary = Env_modtype(env.summary, id, info) } +external reraise: exn -> 'a = "%reraise" -and store_class id desc env = - { env with - classes = IdTbl.add id desc env.classes; - summary = Env_class(env.summary, id, desc) } +val finally : + 'a -> + clean:('a -> 'c) -> + ('a -> 'b) -> 'b -and store_cltype id desc env = - { env with - cltypes = IdTbl.add id desc env.cltypes; - summary = Env_cltype(env.summary, id, desc) } +val try_it : (unit -> 'a) -> unit -(* Compute the components of a functor application in a path. *) +val with_file_as_chan : string -> (out_channel -> 'a) -> 'a -let components_of_functor_appl f env p1 p2 = - try - Hashtbl.find f.fcomp_cache p2 - with Not_found -> - let p = Papply(p1, p2) in - let sub = Subst.add_module f.fcomp_param p2 Subst.identity in - let mty = Subst.modtype sub f.fcomp_res in - let comps = components_of_module ~deprecated:None ~loc:Location.none - (*???*) - env Subst.identity p mty in - Hashtbl.add f.fcomp_cache p2 comps; - comps -(* Define forward functions *) -let _ = - components_of_module' := components_of_module; - components_of_functor_appl' := components_of_functor_appl; - components_of_module_maker' := components_of_module_maker -(* Insertion of bindings by identifier *) -let add_functor_arg id env = - {env with - functor_args = Ident.add id () env.functor_args; - summary = Env_functor_arg (env.summary, id)} -let add_value ?check id desc env = - store_value ?check id desc env -let add_type ~check id info env = - store_type ~check id info env -and add_extension ~check id ext env = - store_extension ~check id ext env -and add_module_declaration ?(arg=false) ~check id md env = - let env = store_module ~check id md env in - if arg then add_functor_arg id env else env -and add_modtype id info env = - store_modtype id info env -and add_class id ty env = - store_class id ty env -and add_cltype id ty env = - store_cltype id ty env -let add_module ?arg id mty env = - add_module_declaration ~check:false ?arg id (md mty) env +external id : 'a -> 'a = "%identity" -let add_local_type path info env = - { env with - local_constraints = PathMap.add path info env.local_constraints } +(** Copied from {!Btype.hash_variant}: + need sync up and add test case + *) +val hash_variant : string -> int -let add_local_constraint path info elv env = - match info with - {type_manifest = Some _; type_newtype_level = Some (lv, _)} -> - (* elv is the expansion level, lv is the definition level *) - let info = {info with type_newtype_level = Some (lv, elv)} in - add_local_type path info env - | _ -> assert false +val todo : string -> 'a +val nat_of_string_exn : string -> int + +val parse_nat_of_string: + string -> + int ref -> + int +end = struct +#1 "ext_pervasives.ml" +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -(* Insertion of bindings by name *) -let enter store_fun name data env = - let id = Ident.create name in (id, store_fun id data env) -let enter_value ?check = enter (store_value ?check) -and enter_type = enter (store_type ~check:true) -and enter_extension = enter (store_extension ~check:true) -and enter_module_declaration ?arg id md env = - add_module_declaration ?arg ~check:true id md env - (* let (id, env) = enter store_module name md env in - (id, add_functor_arg ?arg id env) *) -and enter_modtype = enter store_modtype -and enter_class = enter store_class -and enter_cltype = enter store_cltype -let enter_module ?arg s mty env = - let id = Ident.create s in - (id, enter_module_declaration ?arg id (md mty) env) -(* Insertion of all components of a signature *) -let add_item comp env = - match comp with - Sig_value(id, decl) -> add_value id decl env - | Sig_type(id, decl, _) -> add_type ~check:false id decl env - | Sig_typext(id, ext, _) -> add_extension ~check:false id ext env - | Sig_module(id, md, _) -> add_module_declaration ~check:false id md env - | Sig_modtype(id, decl) -> add_modtype id decl env - | Sig_class(id, decl, _) -> add_class id decl env - | Sig_class_type(id, decl, _) -> add_cltype id decl env +external reraise: exn -> 'a = "%reraise" -let rec add_signature sg env = - match sg with - [] -> env - | comp :: rem -> add_signature rem (add_item comp env) +let finally v ~clean:action f = + match f v with + | exception e -> + action v ; + reraise e + | e -> action v ; e -(* Open a signature path *) +let try_it f = + try ignore (f ()) with _ -> () -let add_components slot root env0 comps = - let add_l w comps env0 = - TycompTbl.add_open slot w comps env0 - in +let with_file_as_chan filename f = + finally (open_out_bin filename) ~clean:close_out f - let add w comps env0 = IdTbl.add_open slot w root comps env0 in - let constrs = - add_l (fun x -> `Constructor x) comps.comp_constrs env0.constrs - in - let labels = - add_l (fun x -> `Label x) comps.comp_labels env0.labels - in - let values = - add (fun x -> `Value x) comps.comp_values env0.values - in - let types = - add (fun x -> `Type x) comps.comp_types env0.types - in - let modtypes = - add (fun x -> `Module_type x) comps.comp_modtypes env0.modtypes - in - let classes = - add (fun x -> `Class x) comps.comp_classes env0.classes - in - let cltypes = - add (fun x -> `Class_type x) comps.comp_cltypes env0.cltypes - in - let components = - add (fun x -> `Component x) comps.comp_components env0.components - in - let modules = - add (fun x -> `Module x) comps.comp_modules env0.modules - in - { env0 with - summary = Env_open(env0.summary, root); - constrs; - labels; - values; - types; - modtypes; - classes; - cltypes; - components; - modules; - } -let open_signature slot root env0 = - match get_components (find_module_descr root env0) with - | Functor_comps _ -> None - | Structure_comps comps -> Some (add_components slot root env0 comps) +external id : 'a -> 'a = "%identity" -(* Open a signature from a file *) +let hash_variant s = + let accu = ref 0 in + for i = 0 to String.length s - 1 do + accu := 223 * !accu + Char.code s.[i] + done; + (* reduce to 31 bits *) + accu := !accu land (1 lsl 31 - 1); + (* make it signed for 64 bits architectures *) + if !accu > 0x3FFFFFFF then !accu - (1 lsl 31) else !accu -let open_pers_signature name env = - match open_signature None (Pident(Ident.create_persistent name)) env with - | Some env -> env - | None -> assert false (* a compilation unit cannot refer to a functor *) +let todo loc = + failwith (loc ^ " Not supported yet") -let open_signature - ?(used_slot = ref false) - ?(loc = Location.none) ?(toplevel = false) ovf root env = - if not toplevel && ovf = Asttypes.Fresh && not loc.Location.loc_ghost - && (Warnings.is_active (Warnings.Unused_open "") - || Warnings.is_active (Warnings.Open_shadow_identifier ("", "")) - || Warnings.is_active (Warnings.Open_shadow_label_constructor ("",""))) - then begin - let used = used_slot in - !add_delayed_check_forward - (fun () -> - if not !used then begin - used := true; - Location.prerr_warning loc (Warnings.Unused_open (Path.name root)) - end - ); - let shadowed = ref [] in - let slot s b = - begin match check_shadowing env b with - | Some kind when not (List.mem (kind, s) !shadowed) -> - shadowed := (kind, s) :: !shadowed; - let w = - match kind with - | "label" | "constructor" -> - Warnings.Open_shadow_label_constructor (kind, s) - | _ -> Warnings.Open_shadow_identifier (kind, s) - in - Location.prerr_warning loc w - | _ -> () - end; - used := true - in - open_signature (Some slot) root env - end - else open_signature None root env -(* Read a signature from a file *) -let read_signature modname filename = - let ps = read_pers_struct modname filename in - Lazy.force ps.ps_sig -(* Return the CRC of the interface of the given compilation unit *) +let rec int_of_string_aux s acc off len = + if off >= len then acc + else + let d = (Char.code (String.unsafe_get s off) - 48) in + if d >=0 && d <= 9 then + int_of_string_aux s (10*acc + d) (off + 1) len + else -1 (* error *) -let crc_of_unit name = - let ps = find_pers_struct name in - let crco = - try - List.assoc name ps.ps_crcs - with Not_found -> - assert false - in - match crco with - None -> assert false - | Some crc -> crc +let nat_of_string_exn (s : string) = + let acc = int_of_string_aux s 0 0 (String.length s) in + if acc < 0 then invalid_arg s + else acc -(* Return the list of imported interfaces with their CRCs *) -let imports () = - - let dont_record_crc_unit = !Clflags.dont_record_crc_unit in - match dont_record_crc_unit with - | None -> Consistbl.extract (StringSet.elements !imported_units) crc_units - | Some x -> - Consistbl.extract - (StringSet.fold - (fun m acc -> if m = x then acc else m::acc) - !imported_units []) crc_units +(** return index *) +let parse_nat_of_string (s : string) (cursor : int ref) = + let current = !cursor in + assert (current >= 0); + let acc = ref 0 in + let s_len = String.length s in + let todo = ref true in + let cur = ref current in + while !todo && !cursor < s_len do + let d = Char.code (String.unsafe_get s !cur) - 48 in + if d >=0 && d <= 9 then begin + acc := 10* !acc + d; + incr cur + end else todo := false + done ; + cursor := !cur; + !acc +end +module Ext_io : sig +#1 "ext_io.mli" +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -(* Returns true if [s] is an opaque imported module *) -let is_imported_opaque s = - StringSet.mem s !imported_opaque_units +val load_file : string -> string -(* Save a signature to a file *) +val rev_lines_of_file : string -> string list -let save_signature_with_imports ?check_exists ~deprecated sg modname filename imports = - (*prerr_endline filename; - List.iter (fun (name, crc) -> prerr_endline name) imports;*) - Btype.cleanup_abbrev (); - Subst.reset_for_saving (); - let sg = Subst.signature (Subst.for_saving Subst.identity) sg in - let flags = - List.concat [ - if !Clflags.recursive_types then [Cmi_format.Rectypes] else []; - if !Clflags.opaque then [Cmi_format.Opaque] else []; - (if !Clflags.unsafe_string then [Cmi_format.Unsafe_string] else []); - (match deprecated with Some s -> [Deprecated s] | None -> []); - ] - in - try - let cmi = { - cmi_name = modname; - cmi_sign = sg; - cmi_crcs = imports; - cmi_flags = flags; - } in - let crc = +val rev_lines_of_chann : in_channel -> string list - create_cmi ?check_exists filename cmi in +val write_file : string -> string -> unit - (* Enter signature in persistent table so that imported_unit() - will also return its crc *) - let comps = - components_of_module ~deprecated ~loc:Location.none - empty Subst.identity - (Pident(Ident.create_persistent modname)) (Mty_signature sg) in - let ps = - { ps_name = modname; - ps_sig = lazy (Subst.signature Subst.identity sg); - ps_comps = comps; - ps_crcs = (cmi.cmi_name, Some crc) :: imports; - ps_filename = filename; - ps_flags = cmi.cmi_flags; - } in - save_pers_struct crc ps; - cmi - with exn -> - remove_file filename; - raise exn +end = struct +#1 "ext_io.ml" +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -let save_signature ?check_exists ~deprecated sg modname filename = - save_signature_with_imports ?check_exists ~deprecated sg modname filename (imports()) -(* Folding on environments *) +(** on 32 bit , there are 16M limitation *) +let load_file f = + Ext_pervasives.finally (open_in_bin f) ~clean:close_in begin fun ic -> + let n = in_channel_length ic in + let s = Bytes.create n in + really_input ic s 0 n; + Bytes.unsafe_to_string s + end -let find_all proj1 proj2 f lid env acc = - match lid with - | None -> - IdTbl.fold_name - (fun name (p, data) acc -> f name p data acc) - (proj1 env) acc - | Some l -> - let p, desc = lookup_module_descr l env in - begin match get_components desc with - Structure_comps c -> - Tbl.fold - (fun s (data, pos) acc -> f s (Pdot (p, s, pos)) data acc) - (proj2 c) acc - | Functor_comps _ -> - acc - end -let find_all_simple_list proj1 proj2 f lid env acc = - match lid with - | None -> - TycompTbl.fold_name - (fun data acc -> f data acc) - (proj1 env) acc - | Some l -> - let (_p, desc) = lookup_module_descr l env in - begin match get_components desc with - Structure_comps c -> - Tbl.fold - (fun _s comps acc -> - match comps with - [] -> acc - | data :: _ -> - f data acc) - (proj2 c) acc - | Functor_comps _ -> - acc - end +let rev_lines_of_chann chan = + let rec loop acc chan = + match input_line chan with + | line -> loop (line :: acc) chan + | exception End_of_file -> close_in chan ; acc in + loop [] chan -let fold_modules f lid env acc = - match lid with - | None -> - let acc = - IdTbl.fold_name - (fun name (p, data) acc -> - let data = EnvLazy.force subst_modtype_maker data in - f name p data acc - ) - env.modules - acc - in - Hashtbl.fold - (fun name ps acc -> - match ps with - None -> acc - | Some ps -> - f name (Pident(Ident.create_persistent name)) - (md (Mty_signature (Lazy.force ps.ps_sig))) acc) - persistent_structures - acc - | Some l -> - let p, desc = lookup_module_descr l env in - begin match get_components desc with - Structure_comps c -> - Tbl.fold - (fun s (data, pos) acc -> - f s (Pdot (p, s, pos)) - (EnvLazy.force subst_modtype_maker data) acc) - c.comp_modules - acc - | Functor_comps _ -> - acc - end -let fold_values f = - find_all (fun env -> env.values) (fun sc -> sc.comp_values) f -and fold_constructors f = - find_all_simple_list (fun env -> env.constrs) (fun sc -> sc.comp_constrs) f -and fold_labels f = - find_all_simple_list (fun env -> env.labels) (fun sc -> sc.comp_labels) f -and fold_types f = - find_all (fun env -> env.types) (fun sc -> sc.comp_types) f -and fold_modtypes f = - find_all (fun env -> env.modtypes) (fun sc -> sc.comp_modtypes) f -and fold_classs f = - find_all (fun env -> env.classes) (fun sc -> sc.comp_classes) f -and fold_cltypes f = - find_all (fun env -> env.cltypes) (fun sc -> sc.comp_cltypes) f +let rev_lines_of_file file = + Ext_pervasives.finally + ~clean:close_in + (open_in_bin file) rev_lines_of_chann -(* Make the initial environment *) -let (initial_safe_string, initial_unsafe_string) = - Predef.build_initial_env - (add_type ~check:false) - (add_extension ~check:false) - empty +let write_file f content = + Ext_pervasives.finally ~clean:close_out + (open_out_bin f) begin fun oc -> + output_string oc content + end -(* Return the environment summary *) +end +module Bs_exception : sig +#1 "bs_exception.mli" +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -let summary env = - if PathMap.is_empty env.local_constraints then env.summary - else Env_constraints (env.summary, env.local_constraints) +type error = + | Cmj_not_found of string + | Js_not_found of string + | Bs_cyclic_depends of string list + | Bs_duplicated_module of string * string + | Bs_duplicate_exports of string (* gpr_974 *) + | Bs_package_not_found of string + | Bs_main_not_exist of string + | Bs_invalid_path of string + | Missing_ml_dependency of string + | Dependency_script_module_dependent_not of string +(* +TODO: In the futrue, we should refine dependency [bsb] +should not rely on such exception, it should have its own exception handling +*) -let last_env = ref empty -let last_reduced_env = ref empty +(* exception Error of error *) -let keep_only_summary env = - if !last_env == env then !last_reduced_env - else begin - let new_env = - { - empty with - summary = env.summary; - local_constraints = env.local_constraints; - flags = env.flags; - } - in - last_env := env; - last_reduced_env := new_env; - new_env - end +(* val report_error : Format.formatter -> error -> unit *) +val error : error -> 'a -let env_of_only_summary env_from_summary env = - let new_env = env_from_summary env.summary Subst.identity in - { new_env with - local_constraints = env.local_constraints; - flags = env.flags; - } +end = struct +#1 "bs_exception.ml" +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -(* Error report *) -open Format +type error = + | Cmj_not_found of string + | Js_not_found of string + | Bs_cyclic_depends of string list + | Bs_duplicated_module of string * string + | Bs_duplicate_exports of string (* gpr_974 *) + | Bs_package_not_found of string + | Bs_main_not_exist of string + | Bs_invalid_path of string + | Missing_ml_dependency of string + | Dependency_script_module_dependent_not of string + (** TODO: we need add location handling *) +exception Error of error + +let error err = raise (Error err) let report_error ppf = function - | Illegal_renaming(modname, ps_name, filename) -> fprintf ppf - "Wrong file naming: %a@ contains the compiled interface for @ \ - %s when %s was expected" - Location.print_filename filename ps_name modname - | Inconsistent_import(name, source1, source2) -> fprintf ppf - "@[The files %a@ and %a@ \ - make inconsistent assumptions@ over interface %s@]" - Location.print_filename source1 Location.print_filename source2 name - | Need_recursive_types(import, export) -> - fprintf ppf - "@[Unit %s imports from %s, which uses recursive types.@ %s@]" - export import "The compilation flag -rectypes is required" - | Depend_on_unsafe_string_unit(import, export) -> - fprintf ppf - "@[Unit %s imports from %s, compiled with -unsafe-string.@ %s@]" - export import "This compiler has been configured in strict \ - safe-string mode (-force-safe-string)" - | Missing_module(_, path1, path2) -> - fprintf ppf "@[@["; - if Path.same path1 path2 then - fprintf ppf "Internal path@ %s@ is dangling." (Path.name path1) - else - fprintf ppf "Internal path@ %s@ expands to@ %s@ which is dangling." - (Path.name path1) (Path.name path2); - fprintf ppf "@]@ @[%s@ %s@ %s.@]@]" - "The compiled interface for module" (Ident.name (Path.head path2)) - "was not found" - | Illegal_value_name(_loc, name) -> - fprintf ppf "'%s' is not a valid value identifier." - name + | Dependency_script_module_dependent_not s + -> + Format.fprintf ppf + "%s is compiled in script mode while its dependent is not" + s + | Missing_ml_dependency s -> + Format.fprintf ppf "Missing dependency %s in search path" s + | Cmj_not_found s -> + Format.fprintf ppf "%s not found, it means either the module does not exist or it is a namespace" s + | Js_not_found s -> + Format.fprintf ppf "%s not found, needed in script mode " s + | Bs_cyclic_depends str + -> + Format.fprintf ppf "Cyclic depends : @[%a@]" + (Format.pp_print_list ~pp_sep:Format.pp_print_space + Format.pp_print_string) + str + | Bs_duplicate_exports str -> + Format.fprintf ppf "%s are exported as twice" str + | Bs_duplicated_module (a,b) + -> + Format.fprintf ppf "The build system does not support two files with same names yet %s, %s" a b + | Bs_main_not_exist main + -> + Format.fprintf ppf "File %s not found " main + + | Bs_package_not_found package + -> + Format.fprintf ppf "Package %s not found or %s/lib/ocaml does not exist or please set npm_config_prefix correctly" + package package + | Bs_invalid_path path + -> Format.pp_print_string ppf ("Invalid path: " ^ path ) + let () = Location.register_error_of_exn (function - | Error (Missing_module (loc, _, _) - | Illegal_value_name (loc, _) - as err) when loc <> Location.none -> - Some (Location.error_of_printer loc report_error err) - | Error err -> Some (Location.error_of_printer_file report_error err) + | Error err + -> Some (Location.error_of_printer_file report_error err) | _ -> None ) end -(** Interface as module *) -module Annot -= struct -#1 "annot.mli" +module Depend : sig +#1 "depend.mli" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Damien Doligez, projet Gallium, INRIA Rocquencourt *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) (* *) -(* Copyright 2007 Institut National de Recherche en Informatique et *) +(* Copyright 1999 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -42965,26 +42455,42 @@ module Annot (* *) (**************************************************************************) -(* Data types for annotations (Stypes.ml) *) +(** Module dependencies. *) -type call = Tail | Stack | Inline;; +module StringSet : Set.S with type elt = string +module StringMap : Map.S with type key = string -type ident = - | Iref_internal of Location.t (* defining occurrence *) - | Iref_external - | Idef of Location.t (* scope *) -;; +type map_tree = Node of StringSet.t * bound_map +and bound_map = map_tree StringMap.t +val make_leaf : string -> map_tree +val make_node : bound_map -> map_tree +val weaken_map : StringSet.t -> map_tree -> map_tree -end -module Typedtree : sig -#1 "typedtree.mli" +val free_structure_names : StringSet.t ref + +(* dependencies found by preprocessing tools (plugins) *) +val pp_deps : string list ref + +val open_module : bound_map -> Longident.t -> bound_map + +val add_use_file : bound_map -> Parsetree.toplevel_phrase list -> unit + +val add_signature : bound_map -> Parsetree.signature -> unit + +val add_implementation : bound_map -> Parsetree.structure -> unit + +val add_implementation_binding : bound_map -> Parsetree.structure -> bound_map +val add_signature_binding : bound_map -> Parsetree.signature -> bound_map + +end = struct +#1 "depend.ml" (**************************************************************************) (* *) (* OCaml *) (* *) (* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) (* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* Copyright 1999 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -42993,9691 +42499,9140 @@ module Typedtree : sig (* *) (**************************************************************************) -(** Abstract syntax tree after typing *) +open Asttypes +open Location +open Longident +open Parsetree +let pp_deps = ref [] -(** By comparison with {!Parsetree}: - - Every {!Longindent.t} is accompanied by a resolved {!Path.t}. +module StringSet = Set.Make(struct type t = string let compare = compare end) +module StringMap = Map.Make(String) -*) +(* Module resolution map *) +(* Node (set of imports for this path, map for submodules) *) +type map_tree = Node of StringSet.t * bound_map +and bound_map = map_tree StringMap.t +let bound = Node (StringSet.empty, StringMap.empty) -open Asttypes -open Types +(*let get_free (Node (s, _m)) = s*) +let get_map (Node (_s, m)) = m +let make_leaf s = Node (StringSet.singleton s, StringMap.empty) +let make_node m = Node (StringSet.empty, m) +let rec weaken_map s (Node(s0,m0)) = + Node (StringSet.union s s0, StringMap.map (weaken_map s) m0) +let rec collect_free (Node (s, m)) = + StringMap.fold (fun _ n -> StringSet.union (collect_free n)) m s -(* Value expressions for the core language *) +(* Returns the imports required to access the structure at path p *) +(* Only raises Not_found if the head of p is not in the toplevel map *) +let rec lookup_free p m = + match p with + [] -> raise Not_found + | s::p -> + let Node (f, m') = StringMap.find s m in + try lookup_free p m' with Not_found -> f -type partial = Partial | Total +(* Returns the node corresponding to the structure at path p *) +let rec lookup_map lid m = + match lid with + Lident s -> StringMap.find s m + | Ldot (l, s) -> StringMap.find s (get_map (lookup_map l m)) + | Lapply _ -> raise Not_found -(** {1 Extension points} *) +(* Collect free module identifiers in the a.s.t. *) -type attribute = Parsetree.attribute -type attributes = attribute list +let free_structure_names = ref StringSet.empty -(** {1 Core language} *) +let add_names s = + free_structure_names := StringSet.union s !free_structure_names -type pattern = - { pat_desc: pattern_desc; - pat_loc: Location.t; - pat_extra : (pat_extra * Location.t * attributes) list; - pat_type: type_expr; - mutable pat_env: Env.t; - pat_attributes: attributes; - } +let rec add_path bv ?(p=[]) = function + | Lident s -> + let free = + try lookup_free (s::p) bv with Not_found -> StringSet.singleton s + in + (*StringSet.iter (fun s -> Printf.eprintf "%s " s) free; + prerr_endline "";*) + add_names free + | Ldot(l, s) -> add_path bv ~p:(s::p) l + | Lapply(l1, l2) -> add_path bv l1; add_path bv l2 -and pat_extra = - | Tpat_constraint of core_type - (** P : T { pat_desc = P - ; pat_extra = (Tpat_constraint T, _, _) :: ... } - *) - | Tpat_type of Path.t * Longident.t loc - (** #tconst { pat_desc = disjunction - ; pat_extra = (Tpat_type (P, "tconst"), _, _) :: ...} +let open_module bv lid = + match lookup_map lid bv with + | Node (s, m) -> + add_names s; + StringMap.fold StringMap.add m bv + | exception Not_found -> + add_path bv lid; bv - where [disjunction] is a [Tpat_or _] representing the - branches of [tconst]. - *) - | Tpat_open of Path.t * Longident.t loc * Env.t - | Tpat_unpack - (** (module P) { pat_desc = Tpat_var "P" - ; pat_extra = (Tpat_unpack, _, _) :: ... } - *) +let add_parent bv lid = + match lid.txt with + Ldot(l, _s) -> add_path bv l + | _ -> () -and pattern_desc = - Tpat_any - (** _ *) - | Tpat_var of Ident.t * string loc - (** x *) - | Tpat_alias of pattern * Ident.t * string loc - (** P as a *) - | Tpat_constant of constant - (** 1, 'a', "true", 1.0, 1l, 1L, 1n *) - | Tpat_tuple of pattern list - (** (P1, ..., Pn) +let add = add_parent - Invariant: n >= 2 - *) - | Tpat_construct of - Longident.t loc * constructor_description * pattern list - (** C [] - C P [P] - C (P1, ..., Pn) [P1; ...; Pn] - *) - | Tpat_variant of label * pattern option * row_desc ref - (** `A (None) - `A P (Some P) +let addmodule bv lid = add_path bv lid.txt - See {!Types.row_desc} for an explanation of the last parameter. - *) - | Tpat_record of - (Longident.t loc * label_description * pattern) list * - closed_flag - (** { l1=P1; ...; ln=Pn } (flag = Closed) - { l1=P1; ...; ln=Pn; _} (flag = Open) +let handle_extension ext = + match (fst ext).txt with + | "error" | "ocaml.error" -> + raise (Location.Error + (Builtin_attributes.error_of_extension ext)) + | _ -> + () - Invariant: n > 0 - *) - | Tpat_array of pattern list - (** [| P1; ...; Pn |] *) - | Tpat_or of pattern * pattern * row_desc option - (** P1 | P2 +let rec add_type bv ty = + match ty.ptyp_desc with + Ptyp_any -> () + | Ptyp_var _ -> () + | Ptyp_arrow(_, t1, t2) -> add_type bv t1; add_type bv t2 + | Ptyp_tuple tl -> List.iter (add_type bv) tl + | Ptyp_constr(c, tl) -> add bv c; List.iter (add_type bv) tl + | Ptyp_object (fl, _) -> + List.iter + (function Otag (_, _, t) -> add_type bv t + | Oinherit t -> add_type bv t) fl + | Ptyp_class(c, tl) -> add bv c; List.iter (add_type bv) tl + | Ptyp_alias(t, _) -> add_type bv t + | Ptyp_variant(fl, _, _) -> + List.iter + (function Rtag(_,_,_,stl) -> List.iter (add_type bv) stl + | Rinherit sty -> add_type bv sty) + fl + | Ptyp_poly(_, t) -> add_type bv t + | Ptyp_package pt -> add_package_type bv pt + | Ptyp_extension e -> handle_extension e - [row_desc] = [Some _] when translating [Ppat_type _], - [None] otherwise. - *) - | Tpat_lazy of pattern - (** lazy P *) +and add_package_type bv (lid, l) = + add bv lid; + List.iter (add_type bv) (List.map (fun (_, e) -> e) l) -and expression = - { exp_desc: expression_desc; - exp_loc: Location.t; - exp_extra: (exp_extra * Location.t * attributes) list; - exp_type: type_expr; - exp_env: Env.t; - exp_attributes: attributes; - } +let add_opt add_fn bv = function + None -> () + | Some x -> add_fn bv x -and exp_extra = - | Texp_constraint of core_type - (** E : T *) - | Texp_coerce of core_type option * core_type - (** E :> T [Texp_coerce (None, T)] - E : T0 :> T [Texp_coerce (Some T0, T)] - *) - | Texp_open of override_flag * Path.t * Longident.t loc * Env.t - (** let open[!] M in [Texp_open (!, P, M, env)] - where [env] is the environment after opening [P] - *) - | Texp_poly of core_type option - (** Used for method bodies. *) - | Texp_newtype of string - (** fun (type t) -> *) +let add_constructor_arguments bv = function + | Pcstr_tuple l -> List.iter (add_type bv) l + | Pcstr_record l -> List.iter (fun l -> add_type bv l.pld_type) l -and expression_desc = - Texp_ident of Path.t * Longident.t loc * Types.value_description - (** x - M.x - *) - | Texp_constant of constant - (** 1, 'a', "true", 1.0, 1l, 1L, 1n *) - | Texp_let of rec_flag * value_binding list * expression - (** let P1 = E1 and ... and Pn = EN in E (flag = Nonrecursive) - let rec P1 = E1 and ... and Pn = EN in E (flag = Recursive) - *) - | Texp_function of { arg_label : arg_label; param : Ident.t; - cases : case list; partial : partial; } - (** [Pexp_fun] and [Pexp_function] both translate to [Texp_function]. - See {!Parsetree} for more details. +let add_constructor_decl bv pcd = + add_constructor_arguments bv pcd.pcd_args; + Misc.may (add_type bv) pcd.pcd_res - [param] is the identifier that is to be used to name the - parameter of the function. +let add_type_declaration bv td = + List.iter + (fun (ty1, ty2, _) -> add_type bv ty1; add_type bv ty2) + td.ptype_cstrs; + add_opt add_type bv td.ptype_manifest; + let add_tkind = function + Ptype_abstract -> () + | Ptype_variant cstrs -> + List.iter (add_constructor_decl bv) cstrs + | Ptype_record lbls -> + List.iter (fun pld -> add_type bv pld.pld_type) lbls + | Ptype_open -> () in + add_tkind td.ptype_kind - partial = - [Partial] if the pattern match is partial - [Total] otherwise. - *) - | Texp_apply of expression * (arg_label * expression option) list - (** E0 ~l1:E1 ... ~ln:En +let add_extension_constructor bv ext = + match ext.pext_kind with + Pext_decl(args, rty) -> + add_constructor_arguments bv args; + Misc.may (add_type bv) rty + | Pext_rebind lid -> add bv lid - The expression can be None if the expression is abstracted over - this argument. It currently appears when a label is applied. +let add_type_extension bv te = + add bv te.ptyext_path; + List.iter (add_extension_constructor bv) te.ptyext_constructors + +let rec add_class_type bv cty = + match cty.pcty_desc with + Pcty_constr(l, tyl) -> + add bv l; List.iter (add_type bv) tyl + | Pcty_signature { pcsig_self = ty; pcsig_fields = fieldl } -> + add_type bv ty; + List.iter (add_class_type_field bv) fieldl + | Pcty_arrow(_, ty1, cty2) -> + add_type bv ty1; add_class_type bv cty2 + | Pcty_extension e -> handle_extension e + | Pcty_open (_ovf, m, e) -> + let bv = open_module bv m.txt in add_class_type bv e + +and add_class_type_field bv pctf = + match pctf.pctf_desc with + Pctf_inherit cty -> add_class_type bv cty + | Pctf_val(_, _, _, ty) -> add_type bv ty + | Pctf_method(_, _, _, ty) -> add_type bv ty + | Pctf_constraint(ty1, ty2) -> add_type bv ty1; add_type bv ty2 + | Pctf_attribute _ -> () + | Pctf_extension e -> handle_extension e + +let add_class_description bv infos = + add_class_type bv infos.pci_expr + +let add_class_type_declaration = add_class_description + +let pattern_bv = ref StringMap.empty + +let rec add_pattern bv pat = + match pat.ppat_desc with + Ppat_any -> () + | Ppat_var _ -> () + | Ppat_alias(p, _) -> add_pattern bv p + | Ppat_interval _ + | Ppat_constant _ -> () + | Ppat_tuple pl -> List.iter (add_pattern bv) pl + | Ppat_construct(c, op) -> add bv c; add_opt add_pattern bv op + | Ppat_record(pl, _) -> + List.iter (fun (lbl, p) -> add bv lbl; add_pattern bv p) pl + | Ppat_array pl -> List.iter (add_pattern bv) pl + | Ppat_or(p1, p2) -> add_pattern bv p1; add_pattern bv p2 + | Ppat_constraint(p, ty) -> add_pattern bv p; add_type bv ty + | Ppat_variant(_, op) -> add_opt add_pattern bv op + | Ppat_type li -> add bv li + | Ppat_lazy p -> add_pattern bv p + | Ppat_unpack id -> pattern_bv := StringMap.add id.txt bound !pattern_bv + | Ppat_open ( m, p) -> let bv = open_module bv m.txt in add_pattern bv p + | Ppat_exception p -> add_pattern bv p + | Ppat_extension e -> handle_extension e + +let add_pattern bv pat = + pattern_bv := bv; + add_pattern bv pat; + !pattern_bv + +let rec add_expr bv exp = + match exp.pexp_desc with + Pexp_ident l -> add bv l + | Pexp_constant _ -> () + | Pexp_let(rf, pel, e) -> + let bv = add_bindings rf bv pel in add_expr bv e + | Pexp_fun (_, opte, p, e) -> + add_opt add_expr bv opte; add_expr (add_pattern bv p) e + | Pexp_function pel -> + add_cases bv pel + | Pexp_apply(e, el) -> + add_expr bv e; List.iter (fun (_,e) -> add_expr bv e) el + | Pexp_match(e, pel) -> add_expr bv e; add_cases bv pel + | Pexp_try(e, pel) -> add_expr bv e; add_cases bv pel + | Pexp_tuple el -> List.iter (add_expr bv) el + | Pexp_construct(c, opte) -> add bv c; add_opt add_expr bv opte + | Pexp_variant(_, opte) -> add_opt add_expr bv opte + | Pexp_record(lblel, opte) -> + List.iter (fun (lbl, e) -> add bv lbl; add_expr bv e) lblel; + add_opt add_expr bv opte + | Pexp_field(e, fld) -> add_expr bv e; add bv fld + | Pexp_setfield(e1, fld, e2) -> add_expr bv e1; add bv fld; add_expr bv e2 + | Pexp_array el -> List.iter (add_expr bv) el + | Pexp_ifthenelse(e1, e2, opte3) -> + add_expr bv e1; add_expr bv e2; add_opt add_expr bv opte3 + | Pexp_sequence(e1, e2) -> add_expr bv e1; add_expr bv e2 + | Pexp_while(e1, e2) -> add_expr bv e1; add_expr bv e2 + | Pexp_for( _, e1, e2, _, e3) -> + add_expr bv e1; add_expr bv e2; add_expr bv e3 + | Pexp_coerce(e1, oty2, ty3) -> + add_expr bv e1; + add_opt add_type bv oty2; + add_type bv ty3 + | Pexp_constraint(e1, ty2) -> + add_expr bv e1; + add_type bv ty2 + | Pexp_send(e, _m) -> add_expr bv e + | Pexp_new li -> add bv li + | Pexp_setinstvar(_v, e) -> add_expr bv e + | Pexp_override sel -> List.iter (fun (_s, e) -> add_expr bv e) sel + | Pexp_letmodule(id, m, e) -> + let b = add_module_binding bv m in + add_expr (StringMap.add id.txt b bv) e + | Pexp_letexception(_, e) -> add_expr bv e + | Pexp_assert (e) -> add_expr bv e + | Pexp_lazy (e) -> add_expr bv e + | Pexp_poly (e, t) -> add_expr bv e; add_opt add_type bv t + | Pexp_object { pcstr_self = pat; pcstr_fields = fieldl } -> + let bv = add_pattern bv pat in List.iter (add_class_field bv) fieldl + | Pexp_newtype (_, e) -> add_expr bv e + | Pexp_pack m -> add_module bv m + | Pexp_open (_ovf, m, e) -> + let bv = open_module bv m.txt in add_expr bv e + | Pexp_extension (({ txt = ("ocaml.extension_constructor"| + "extension_constructor"); _ }, + PStr [item]) as e) -> + begin match item.pstr_desc with + | Pstr_eval ({ pexp_desc = Pexp_construct (c, None) }, _) -> add bv c + | _ -> handle_extension e + end + | Pexp_extension e -> handle_extension e + | Pexp_unreachable -> () + +and add_cases bv cases = + List.iter (add_case bv) cases + +and add_case bv {pc_lhs; pc_guard; pc_rhs} = + let bv = add_pattern bv pc_lhs in + add_opt add_expr bv pc_guard; + add_expr bv pc_rhs + +and add_bindings recf bv pel = + let bv' = List.fold_left (fun bv x -> add_pattern bv x.pvb_pat) bv pel in + let bv = if recf = Recursive then bv' else bv in + List.iter (fun x -> add_expr bv x.pvb_expr) pel; + bv' - For example: - let f x ~y = x + y in - f ~y:3 +and add_modtype bv mty = + match mty.pmty_desc with + Pmty_ident l -> add bv l + | Pmty_alias l -> addmodule bv l + | Pmty_signature s -> add_signature bv s + | Pmty_functor(id, mty1, mty2) -> + Misc.may (add_modtype bv) mty1; + add_modtype (StringMap.add id.txt bound bv) mty2 + | Pmty_with(mty, cstrl) -> + add_modtype bv mty; + List.iter + (function + | Pwith_type (_, td) -> add_type_declaration bv td + | Pwith_module (_, lid) -> addmodule bv lid + | Pwith_typesubst (_, td) -> add_type_declaration bv td + | Pwith_modsubst (_, lid) -> addmodule bv lid + ) + cstrl + | Pmty_typeof m -> add_module bv m + | Pmty_extension e -> handle_extension e - The resulting typedtree for the application is: - Texp_apply (Texp_ident "f/1037", - [(Nolabel, None); - (Labelled "y", Some (Texp_constant Const_int 3)) - ]) - *) - | Texp_match of expression * case list * case list * partial - (** match E0 with - | P1 -> E1 - | P2 -> E2 - | exception P3 -> E3 +and add_module_alias bv l = + try + add_parent bv l; + lookup_map l.txt bv + with Not_found -> + match l.txt with + Lident s -> make_leaf s + | _ -> addmodule bv l; bound (* cannot delay *) - [Texp_match (E0, [(P1, E1); (P2, E2)], [(P3, E3)], _)] - *) - | Texp_try of expression * case list - (** try E with P1 -> E1 | ... | PN -> EN *) - | Texp_tuple of expression list - (** (E1, ..., EN) *) - | Texp_construct of - Longident.t loc * constructor_description * expression list - (** C [] - C E [E] - C (E1, ..., En) [E1;...;En] - *) - | Texp_variant of label * expression option - | Texp_record of { - fields : ( Types.label_description * record_label_definition ) array; - representation : Types.record_representation; - extended_expression : expression option; - } - (** { l1=P1; ...; ln=Pn } (extended_expression = None) - { E0 with l1=P1; ...; ln=Pn } (extended_expression = Some E0) +and add_modtype_binding bv mty = + if not !Clflags.transparent_modules then add_modtype bv mty; + match mty.pmty_desc with + Pmty_alias l -> + add_module_alias bv l + | Pmty_signature s -> + make_node (add_signature_binding bv s) + | Pmty_typeof modl -> + add_module_binding bv modl + | _ -> + if !Clflags.transparent_modules then add_modtype bv mty; bound - Invariant: n > 0 +and add_signature bv sg = + ignore (add_signature_binding bv sg) - If the type is { l1: t1; l2: t2 }, the expression - { E0 with t2=P2 } is represented as - Texp_record - { fields = [| l1, Kept t1; l2 Override P2 |]; representation; - extended_expression = Some E0 } - *) - | Texp_field of expression * Longident.t loc * label_description - | Texp_setfield of - expression * Longident.t loc * label_description * expression - | Texp_array of expression list - | Texp_ifthenelse of expression * expression * expression option - | Texp_sequence of expression * expression - | Texp_while of expression * expression - | Texp_for of - Ident.t * Parsetree.pattern * expression * expression * direction_flag * - expression - | Texp_send of expression * meth * expression option - | Texp_new of Path.t * Longident.t loc * Types.class_declaration - | Texp_instvar of Path.t * Path.t * string loc - | Texp_setinstvar of Path.t * Path.t * string loc * expression - | Texp_override of Path.t * (Path.t * string loc * expression) list - | Texp_letmodule of Ident.t * string loc * module_expr * expression - | Texp_letexception of extension_constructor * expression - | Texp_assert of expression - | Texp_lazy of expression - | Texp_object of class_structure * string list - | Texp_pack of module_expr - | Texp_unreachable - | Texp_extension_constructor of Longident.t loc * Path.t +and add_signature_binding bv sg = + snd (List.fold_left add_sig_item (bv, StringMap.empty) sg) -and meth = - Tmeth_name of string - | Tmeth_val of Ident.t +and add_sig_item (bv, m) item = + match item.psig_desc with + Psig_value vd -> + add_type bv vd.pval_type; (bv, m) + | Psig_type (_, dcls) -> + List.iter (add_type_declaration bv) dcls; (bv, m) + | Psig_typext te -> + add_type_extension bv te; (bv, m) + | Psig_exception pext -> + add_extension_constructor bv pext; (bv, m) + | Psig_module pmd -> + let m' = add_modtype_binding bv pmd.pmd_type in + let add = StringMap.add pmd.pmd_name.txt m' in + (add bv, add m) + | Psig_recmodule decls -> + let add = + List.fold_right (fun pmd -> StringMap.add pmd.pmd_name.txt bound) + decls + in + let bv' = add bv and m' = add m in + List.iter (fun pmd -> add_modtype bv' pmd.pmd_type) decls; + (bv', m') + | Psig_modtype x -> + begin match x.pmtd_type with + None -> () + | Some mty -> add_modtype bv mty + end; + (bv, m) + | Psig_open od -> + (open_module bv od.popen_lid.txt, m) + | Psig_include incl -> + let Node (s, m') = add_modtype_binding bv incl.pincl_mod in + add_names s; + let add = StringMap.fold StringMap.add m' in + (add bv, add m) + | Psig_class cdl -> + List.iter (add_class_description bv) cdl; (bv, m) + | Psig_class_type cdtl -> + List.iter (add_class_type_declaration bv) cdtl; (bv, m) + | Psig_attribute _ -> (bv, m) + | Psig_extension (e, _) -> + handle_extension e; + (bv, m) -and case = - { - c_lhs: pattern; - c_guard: expression option; - c_rhs: expression; - } +and add_module_binding bv modl = + if not !Clflags.transparent_modules then add_module bv modl; + match modl.pmod_desc with + Pmod_ident l -> + begin try + add_parent bv l; + lookup_map l.txt bv + with Not_found -> + match l.txt with + Lident s -> make_leaf s + | _ -> addmodule bv l; bound + end + | Pmod_structure s -> + make_node (snd (add_structure_binding bv s)) + | _ -> + if !Clflags.transparent_modules then add_module bv modl; bound -and record_label_definition = - | Kept of Types.type_expr - | Overridden of Longident.t loc * expression +and add_module bv modl = + match modl.pmod_desc with + Pmod_ident l -> addmodule bv l + | Pmod_structure s -> ignore (add_structure bv s) + | Pmod_functor(id, mty, modl) -> + Misc.may (add_modtype bv) mty; + add_module (StringMap.add id.txt bound bv) modl + | Pmod_apply(mod1, mod2) -> + add_module bv mod1; add_module bv mod2 + | Pmod_constraint(modl, mty) -> + add_module bv modl; add_modtype bv mty + | Pmod_unpack(e) -> + add_expr bv e + | Pmod_extension e -> + handle_extension e -(* Value expressions for the class language *) +and add_structure bv item_list = + let (bv, m) = add_structure_binding bv item_list in + add_names (collect_free (make_node m)); + bv -and class_expr = - { - cl_desc: class_expr_desc; - cl_loc: Location.t; - cl_type: Types.class_type; - cl_env: Env.t; - cl_attributes: attributes; - } +and add_structure_binding bv item_list = + List.fold_left add_struct_item (bv, StringMap.empty) item_list -and class_expr_desc = - Tcl_ident of Path.t * Longident.t loc * core_type list - | Tcl_structure of class_structure - | Tcl_fun of - arg_label * pattern * (Ident.t * string loc * expression) list - * class_expr * partial - | Tcl_apply of class_expr * (arg_label * expression option) list - | Tcl_let of rec_flag * value_binding list * - (Ident.t * string loc * expression) list * class_expr - | Tcl_constraint of - class_expr * class_type option * string list * string list * Concr.t - (* Visible instance variables, methods and concrete methods *) - | Tcl_open of override_flag * Path.t * Longident.t loc * Env.t * class_expr +and add_struct_item (bv, m) item : _ StringMap.t * _ StringMap.t = + match item.pstr_desc with + Pstr_eval (e, _attrs) -> + add_expr bv e; (bv, m) + | Pstr_value(rf, pel) -> + let bv = add_bindings rf bv pel in (bv, m) + | Pstr_primitive vd -> + add_type bv vd.pval_type; (bv, m) + | Pstr_type (_, dcls) -> + List.iter (add_type_declaration bv) dcls; (bv, m) + | Pstr_typext te -> + add_type_extension bv te; + (bv, m) + | Pstr_exception pext -> + add_extension_constructor bv pext; (bv, m) + | Pstr_module x -> + let b = add_module_binding bv x.pmb_expr in + let add = StringMap.add x.pmb_name.txt b in + (add bv, add m) + | Pstr_recmodule bindings -> + let add = + List.fold_right (fun x -> StringMap.add x.pmb_name.txt bound) bindings + in + let bv' = add bv and m = add m in + List.iter + (fun x -> add_module bv' x.pmb_expr) + bindings; + (bv', m) + | Pstr_modtype x -> + begin match x.pmtd_type with + None -> () + | Some mty -> add_modtype bv mty + end; + (bv, m) + | Pstr_open od -> + (open_module bv od.popen_lid.txt, m) + | Pstr_class cdl -> + List.iter (add_class_declaration bv) cdl; (bv, m) + | Pstr_class_type cdtl -> + List.iter (add_class_type_declaration bv) cdtl; (bv, m) + | Pstr_include incl -> + let Node (s, m') = add_module_binding bv incl.pincl_mod in + add_names s; + let add = StringMap.fold StringMap.add m' in + (add bv, add m) + | Pstr_attribute _ -> (bv, m) + | Pstr_extension (e, _) -> + handle_extension e; + (bv, m) -and class_structure = - { - cstr_self: pattern; - cstr_fields: class_field list; - cstr_type: Types.class_signature; - cstr_meths: Ident.t Meths.t; - } +and add_use_file bv top_phrs = + ignore (List.fold_left add_top_phrase bv top_phrs) -and class_field = - { - cf_desc: class_field_desc; - cf_loc: Location.t; - cf_attributes: attributes; - } +and add_implementation bv l = + if !Clflags.transparent_modules then + ignore (add_structure_binding bv l) + else ignore (add_structure bv l) -and class_field_kind = - | Tcfk_virtual of core_type - | Tcfk_concrete of override_flag * expression +and add_implementation_binding bv l = + snd (add_structure_binding bv l) -and class_field_desc = - Tcf_inherit of - override_flag * class_expr * string option * (string * Ident.t) list * - (string * Ident.t) list - (* Inherited instance variables and concrete methods *) - | Tcf_val of string loc * mutable_flag * Ident.t * class_field_kind * bool - | Tcf_method of string loc * private_flag * class_field_kind - | Tcf_constraint of core_type * core_type - | Tcf_initializer of expression - | Tcf_attribute of attribute +and add_top_phrase bv = function + | Ptop_def str -> add_structure bv str + | Ptop_dir (_, _) -> bv -(* Value expressions for the module language *) +and add_class_expr bv ce = + match ce.pcl_desc with + Pcl_constr(l, tyl) -> + add bv l; List.iter (add_type bv) tyl + | Pcl_structure { pcstr_self = pat; pcstr_fields = fieldl } -> + let bv = add_pattern bv pat in List.iter (add_class_field bv) fieldl + | Pcl_fun(_, opte, pat, ce) -> + add_opt add_expr bv opte; + let bv = add_pattern bv pat in add_class_expr bv ce + | Pcl_apply(ce, exprl) -> + add_class_expr bv ce; List.iter (fun (_,e) -> add_expr bv e) exprl + | Pcl_let(rf, pel, ce) -> + let bv = add_bindings rf bv pel in add_class_expr bv ce + | Pcl_constraint(ce, ct) -> + add_class_expr bv ce; add_class_type bv ct + | Pcl_extension e -> handle_extension e + | Pcl_open (_ovf, m, e) -> + let bv = open_module bv m.txt in add_class_expr bv e -and module_expr = - { mod_desc: module_expr_desc; - mod_loc: Location.t; - mod_type: Types.module_type; - mod_env: Env.t; - mod_attributes: attributes; - } +and add_class_field bv pcf = + match pcf.pcf_desc with + Pcf_inherit(_, ce, _) -> add_class_expr bv ce + | Pcf_val(_, _, Cfk_concrete (_, e)) + | Pcf_method(_, _, Cfk_concrete (_, e)) -> add_expr bv e + | Pcf_val(_, _, Cfk_virtual ty) + | Pcf_method(_, _, Cfk_virtual ty) -> add_type bv ty + | Pcf_constraint(ty1, ty2) -> add_type bv ty1; add_type bv ty2 + | Pcf_initializer e -> add_expr bv e + | Pcf_attribute _ -> () + | Pcf_extension e -> handle_extension e -(** Annotations for [Tmod_constraint]. *) -and module_type_constraint = - | Tmodtype_implicit - (** The module type constraint has been synthesized during typechecking. *) - | Tmodtype_explicit of module_type - (** The module type was in the source file. *) +and add_class_declaration bv decl = + add_class_expr bv decl.pci_expr -and module_expr_desc = - Tmod_ident of Path.t * Longident.t loc - | Tmod_structure of structure - | Tmod_functor of Ident.t * string loc * module_type option * module_expr - | Tmod_apply of module_expr * module_expr * module_coercion - | Tmod_constraint of - module_expr * Types.module_type * module_type_constraint * module_coercion - (** ME (constraint = Tmodtype_implicit) - (ME : MT) (constraint = Tmodtype_explicit MT) - *) - | Tmod_unpack of expression * Types.module_type +end +module Ext_format : sig +#1 "ext_format.mli" +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -and structure = { - str_items : structure_item list; - str_type : Types.signature; - str_final_env : Env.t; -} -and structure_item = - { str_desc : structure_item_desc; - str_loc : Location.t; - str_env : Env.t - } -and structure_item_desc = - Tstr_eval of expression * attributes - | Tstr_value of rec_flag * value_binding list - | Tstr_primitive of value_description - | Tstr_type of rec_flag * type_declaration list - | Tstr_typext of type_extension - | Tstr_exception of extension_constructor - | Tstr_module of module_binding - | Tstr_recmodule of module_binding list - | Tstr_modtype of module_type_declaration - | Tstr_open of open_description - | Tstr_class of (class_declaration * string list) list - | Tstr_class_type of (Ident.t * string loc * class_type_declaration) list - | Tstr_include of include_declaration - | Tstr_attribute of attribute -and module_binding = - { - mb_id: Ident.t; - mb_name: string loc; - mb_expr: module_expr; - mb_attributes: attributes; - mb_loc: Location.t; - } -and value_binding = - { - vb_pat: pattern; - vb_expr: expression; - vb_attributes: attributes; - vb_loc: Location.t; - } -and module_coercion = - Tcoerce_none - | Tcoerce_structure of (int * module_coercion) list * - (Ident.t * int * module_coercion) list * - string list (* runtime fields *) - | Tcoerce_functor of module_coercion * module_coercion - | Tcoerce_primitive of primitive_coercion - | Tcoerce_alias of Path.t * module_coercion -and module_type = - { mty_desc: module_type_desc; - mty_type : Types.module_type; - mty_env : Env.t; - mty_loc: Location.t; - mty_attributes: attributes; - } -and module_type_desc = - Tmty_ident of Path.t * Longident.t loc - | Tmty_signature of signature - | Tmty_functor of Ident.t * string loc * module_type option * module_type - | Tmty_with of module_type * (Path.t * Longident.t loc * with_constraint) list - | Tmty_typeof of module_expr - | Tmty_alias of Path.t * Longident.t loc +(** Simplified wrapper module for the standard library [Format] module. + *) -and primitive_coercion = - { - pc_desc: Primitive.description; - pc_type: type_expr; - pc_env: Env.t; - pc_loc : Location.t; - - pc_id : Ident.t; - - } +type t = private Format.formatter -and signature = { - sig_items : signature_item list; - sig_type : Types.signature; - sig_final_env : Env.t; -} +val string : t -> string -> unit -and signature_item = - { sig_desc: signature_item_desc; - sig_env : Env.t; (* BINANNOT ADDED *) - sig_loc: Location.t } +val break : t -> unit -and signature_item_desc = - Tsig_value of value_description - | Tsig_type of rec_flag * type_declaration list - | Tsig_typext of type_extension - | Tsig_exception of extension_constructor - | Tsig_module of module_declaration - | Tsig_recmodule of module_declaration list - | Tsig_modtype of module_type_declaration - | Tsig_open of open_description - | Tsig_include of include_description - | Tsig_class of class_description list - | Tsig_class_type of class_type_declaration list - | Tsig_attribute of attribute +val break1 : t -> unit -and module_declaration = - { - md_id: Ident.t; - md_name: string loc; - md_type: module_type; - md_attributes: attributes; - md_loc: Location.t; - } +val space : t -> unit -and module_type_declaration = - { - mtd_id: Ident.t; - mtd_name: string loc; - mtd_type: module_type option; - mtd_attributes: attributes; - mtd_loc: Location.t; - } +val group : t -> int -> (unit -> 'a) -> 'a +(** [group] will record current indentation + and indent futher + *) -and open_description = - { - open_path: Path.t; - open_txt: Longident.t loc; - open_override: override_flag; - open_loc: Location.t; - open_attributes: attribute list; - } +val vgroup : t -> int -> (unit -> 'a) -> 'a -and 'a include_infos = - { - incl_mod: 'a; - incl_type: Types.signature; - incl_loc: Location.t; - incl_attributes: attribute list; - } +val paren : t -> (unit -> 'a) -> 'a -and include_description = module_type include_infos +val paren_group : t -> int -> (unit -> 'a) -> 'a -and include_declaration = module_expr include_infos +val brace_group : t -> int -> (unit -> 'a) -> 'a -and with_constraint = - Twith_type of type_declaration - | Twith_module of Path.t * Longident.t loc - | Twith_typesubst of type_declaration - | Twith_modsubst of Path.t * Longident.t loc +val brace_vgroup : t -> int -> (unit -> 'a) -> 'a -and core_type = - { mutable ctyp_desc : core_type_desc; - (** mutable because of [Typeclass.declare_method] *) - mutable ctyp_type : type_expr; - (** mutable because of [Typeclass.declare_method] *) - ctyp_env : Env.t; (* BINANNOT ADDED *) - ctyp_loc : Location.t; - ctyp_attributes: attributes; - } +val bracket_group : t -> int -> (unit -> 'a) -> 'a -and core_type_desc = - Ttyp_any - | Ttyp_var of string - | Ttyp_arrow of arg_label * core_type * core_type - | Ttyp_tuple of core_type list - | Ttyp_constr of Path.t * Longident.t loc * core_type list - | Ttyp_object of object_field list * closed_flag - | Ttyp_class of Path.t * Longident.t loc * core_type list - | Ttyp_alias of core_type * string - | Ttyp_variant of row_field list * closed_flag * label list option - | Ttyp_poly of string list * core_type - | Ttyp_package of package_type +val newline : t -> unit -and package_type = { - pack_path : Path.t; - pack_fields : (Longident.t loc * core_type) list; - pack_type : Types.module_type; - pack_txt : Longident.t loc; -} +val to_out_channel : out_channel -> t -and row_field = - Ttag of string loc * attributes * bool * core_type list - | Tinherit of core_type +val flush : t -> unit -> unit -and object_field = - | OTtag of string loc * attributes * core_type - | OTinherit of core_type +val pp_print_queue : + ?pp_sep:(Format.formatter -> unit -> unit) -> + (Format.formatter -> 'a -> unit) -> Format.formatter -> 'a Queue.t -> unit -and value_description = - { val_id: Ident.t; - val_name: string loc; - val_desc: core_type; - val_val: Types.value_description; - val_prim: string list; - val_loc: Location.t; - val_attributes: attributes; - } +end = struct +#1 "ext_format.ml" +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -and type_declaration = - { - typ_id: Ident.t; - typ_name: string loc; - typ_params: (core_type * variance) list; - typ_type: Types.type_declaration; - typ_cstrs: (core_type * core_type * Location.t) list; - typ_kind: type_kind; - typ_private: private_flag; - typ_manifest: core_type option; - typ_loc: Location.t; - typ_attributes: attributes; - } -and type_kind = - Ttype_abstract - | Ttype_variant of constructor_declaration list - | Ttype_record of label_declaration list - | Ttype_open -and label_declaration = - { - ld_id: Ident.t; - ld_name: string loc; - ld_mutable: mutable_flag; - ld_type: core_type; - ld_loc: Location.t; - ld_attributes: attributes; - } -and constructor_declaration = - { - cd_id: Ident.t; - cd_name: string loc; - cd_args: constructor_arguments; - cd_res: core_type option; - cd_loc: Location.t; - cd_attributes: attributes; - } -and constructor_arguments = - | Cstr_tuple of core_type list - | Cstr_record of label_declaration list -and type_extension = - { - tyext_path: Path.t; - tyext_txt: Longident.t loc; - tyext_params: (core_type * variance) list; - tyext_constructors: extension_constructor list; - tyext_private: private_flag; - tyext_attributes: attributes; - } -and extension_constructor = - { - ext_id: Ident.t; - ext_name: string loc; - ext_type : Types.extension_constructor; - ext_kind : extension_constructor_kind; - ext_loc : Location.t; - ext_attributes: attributes; - } -and extension_constructor_kind = - Text_decl of constructor_arguments * core_type option - | Text_rebind of Path.t * Longident.t loc +open Format -and class_type = - { - cltyp_desc: class_type_desc; - cltyp_type: Types.class_type; - cltyp_env: Env.t; - cltyp_loc: Location.t; - cltyp_attributes: attributes; - } +type t = formatter -and class_type_desc = - Tcty_constr of Path.t * Longident.t loc * core_type list - | Tcty_signature of class_signature - | Tcty_arrow of arg_label * core_type * class_type - | Tcty_open of override_flag * Path.t * Longident.t loc * Env.t * class_type +let string = pp_print_string -and class_signature = { - csig_self : core_type; - csig_fields : class_type_field list; - csig_type : Types.class_signature; - } +let break = fun fmt -> pp_print_break fmt 0 0 -and class_type_field = { - ctf_desc: class_type_field_desc; - ctf_loc: Location.t; - ctf_attributes: attributes; - } +let break1 = + fun fmt -> pp_print_break fmt 0 1 -and class_type_field_desc = - | Tctf_inherit of class_type - | Tctf_val of (string * mutable_flag * virtual_flag * core_type) - | Tctf_method of (string * private_flag * virtual_flag * core_type) - | Tctf_constraint of (core_type * core_type) - | Tctf_attribute of attribute +let space fmt = + pp_print_break fmt 1 0 -and class_declaration = - class_expr class_infos +let vgroup fmt indent u = + pp_open_vbox fmt indent; + let v = u () in + pp_close_box fmt (); + v -and class_description = - class_type class_infos +let group fmt indent u = + pp_open_hovbox fmt indent; + let v = u () in + pp_close_box fmt (); + v + +let paren fmt u = + string fmt "("; + let v = u () in + string fmt ")"; + v -and class_type_declaration = - class_type class_infos +let brace fmt u = + string fmt "{"; + (* break1 fmt ; *) + let v = u () in + string fmt "}"; + v -and 'a class_infos = - { ci_virt: virtual_flag; - ci_params: (core_type * variance) list; - ci_id_name : string loc; - ci_id_class: Ident.t; - ci_id_class_type : Ident.t; - ci_id_object : Ident.t; - ci_id_typehash : Ident.t; - ci_expr: 'a; - ci_decl: Types.class_declaration; - ci_type_decl : Types.class_type_declaration; - ci_loc: Location.t; - ci_attributes: attributes; - } +let bracket fmt u = + string fmt "["; + let v = u () in + string fmt "]"; + v -(* Auxiliary functions over the a.s.t. *) +let paren_group st n action = + group st n (fun _ -> paren st action) -val iter_pattern_desc: (pattern -> unit) -> pattern_desc -> unit -val map_pattern_desc: (pattern -> pattern) -> pattern_desc -> pattern_desc +let brace_group st n action = + group st n (fun _ -> brace st action ) -val let_bound_idents: value_binding list -> Ident.t list -val rev_let_bound_idents: value_binding list -> Ident.t list +let brace_vgroup st n action = + vgroup st n (fun _ -> + string st "{"; + pp_print_break st 0 2; + let v = vgroup st 0 action in + pp_print_break st 0 0; + string st "}"; + v + ) +let bracket_group st n action = + group st n (fun _ -> bracket st action) -val let_bound_idents_with_loc: - value_binding list -> (Ident.t * string loc) list +let newline fmt = pp_print_newline fmt () -(** Alpha conversion of patterns *) -val alpha_pat: (Ident.t * Ident.t) list -> pattern -> pattern +let to_out_channel = formatter_of_out_channel -val mknoloc: 'a -> 'a Asttypes.loc -val mkloc: 'a -> Location.t -> 'a Asttypes.loc +(* let non_breaking_space fmt = string fmt " " *) +(* let set_needed_space_function _ _ = () *) +let flush = pp_print_flush -val pat_bound_idents: pattern -> Ident.t list +let list = pp_print_list -end = struct -#1 "typedtree.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let rec pp_print_queue ?(pp_sep = pp_print_cut) pp_v ppf q = + Queue.iter (fun q -> pp_v ppf q ; pp_sep ppf ()) q -(* Abstract syntax tree after typing *) +end +module Ext_fmt += struct +#1 "ext_fmt.ml" -open Misc -open Asttypes -open Types -(* Value expressions for the core language *) +let with_file_as_pp filename f = + Ext_pervasives.finally (open_out_bin filename) ~clean:close_out + (fun chan -> + let fmt = Format.formatter_of_out_channel chan in + let v = f fmt in + Format.pp_print_flush fmt (); + v + ) -type partial = Partial | Total -type attribute = Parsetree.attribute -type attributes = attribute list -type pattern = - { pat_desc: pattern_desc; - pat_loc: Location.t; - pat_extra : (pat_extra * Location.t * attribute list) list; - pat_type: type_expr; - mutable pat_env: Env.t; - pat_attributes: attribute list; - } +let failwithf ~loc fmt = Format.ksprintf (fun s -> failwith (loc ^ s)) + fmt + +let invalid_argf fmt = Format.ksprintf invalid_arg fmt -and pat_extra = - | Tpat_constraint of core_type - | Tpat_type of Path.t * Longident.t loc - | Tpat_open of Path.t * Longident.t loc * Env.t - | Tpat_unpack -and pattern_desc = - Tpat_any - | Tpat_var of Ident.t * string loc - | Tpat_alias of pattern * Ident.t * string loc - | Tpat_constant of constant - | Tpat_tuple of pattern list - | Tpat_construct of - Longident.t loc * constructor_description * pattern list - | Tpat_variant of label * pattern option * row_desc ref - | Tpat_record of - (Longident.t loc * label_description * pattern) list * - closed_flag - | Tpat_array of pattern list - | Tpat_or of pattern * pattern * row_desc option - | Tpat_lazy of pattern +end +module Ext_sys : sig +#1 "ext_sys.mli" +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -and expression = - { exp_desc: expression_desc; - exp_loc: Location.t; - exp_extra: (exp_extra * Location.t * attribute list) list; - exp_type: type_expr; - exp_env: Env.t; - exp_attributes: attribute list; - } -and exp_extra = - | Texp_constraint of core_type - | Texp_coerce of core_type option * core_type - | Texp_open of override_flag * Path.t * Longident.t loc * Env.t - | Texp_poly of core_type option - | Texp_newtype of string +(* Not used yet *) +(* val is_directory_no_exn : string -> bool *) -and expression_desc = - Texp_ident of Path.t * Longident.t loc * Types.value_description - | Texp_constant of constant - | Texp_let of rec_flag * value_binding list * expression - | Texp_function of { arg_label : arg_label; param : Ident.t; - cases : case list; partial : partial; } - | Texp_apply of expression * (arg_label * expression option) list - | Texp_match of expression * case list * case list * partial - | Texp_try of expression * case list - | Texp_tuple of expression list - | Texp_construct of - Longident.t loc * constructor_description * expression list - | Texp_variant of label * expression option - | Texp_record of { - fields : ( Types.label_description * record_label_definition ) array; - representation : Types.record_representation; - extended_expression : expression option; - } - | Texp_field of expression * Longident.t loc * label_description - | Texp_setfield of - expression * Longident.t loc * label_description * expression - | Texp_array of expression list - | Texp_ifthenelse of expression * expression * expression option - | Texp_sequence of expression * expression - | Texp_while of expression * expression - | Texp_for of - Ident.t * Parsetree.pattern * expression * expression * direction_flag * - expression - | Texp_send of expression * meth * expression option - | Texp_new of Path.t * Longident.t loc * Types.class_declaration - | Texp_instvar of Path.t * Path.t * string loc - | Texp_setinstvar of Path.t * Path.t * string loc * expression - | Texp_override of Path.t * (Path.t * string loc * expression) list - | Texp_letmodule of Ident.t * string loc * module_expr * expression - | Texp_letexception of extension_constructor * expression - | Texp_assert of expression - | Texp_lazy of expression - | Texp_object of class_structure * string list - | Texp_pack of module_expr - | Texp_unreachable - | Texp_extension_constructor of Longident.t loc * Path.t -and meth = - Tmeth_name of string - | Tmeth_val of Ident.t +val is_windows_or_cygwin : bool -and case = - { - c_lhs: pattern; - c_guard: expression option; - c_rhs: expression; - } +val getenv_opt : + string -> + string option +end = struct +#1 "ext_sys.ml" +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -and record_label_definition = - | Kept of Types.type_expr - | Overridden of Longident.t loc * expression +(** TODO: not exported yet, wait for Windows Fix*) +let is_directory_no_exn f = + try Sys.is_directory f with _ -> false -(* Value expressions for the class language *) -and class_expr = - { - cl_desc: class_expr_desc; - cl_loc: Location.t; - cl_type: Types.class_type; - cl_env: Env.t; - cl_attributes: attribute list; - } +let is_windows_or_cygwin = Sys.win32 || Sys.cygwin + + +let getenv_opt = Sys.getenv_opt + +end +module Ext_path : sig +#1 "ext_path.mli" +(* Copyright (C) 2017 Authors of BuckleScript + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -and class_expr_desc = - Tcl_ident of Path.t * Longident.t loc * core_type list - | Tcl_structure of class_structure - | Tcl_fun of - arg_label * pattern * (Ident.t * string loc * expression) list - * class_expr * partial - | Tcl_apply of class_expr * (arg_label * expression option) list - | Tcl_let of rec_flag * value_binding list * - (Ident.t * string loc * expression) list * class_expr - | Tcl_constraint of - class_expr * class_type option * string list * string list * Concr.t - (* Visible instance variables, methods and concrete methods *) - | Tcl_open of override_flag * Path.t * Longident.t loc * Env.t * class_expr +type t -and class_structure = - { - cstr_self: pattern; - cstr_fields: class_field list; - cstr_type: Types.class_signature; - cstr_meths: Ident.t Meths.t; - } -and class_field = - { - cf_desc: class_field_desc; - cf_loc: Location.t; - cf_attributes: attribute list; - } +(** Js_output is node style, which means + separator is only '/' -and class_field_kind = - | Tcfk_virtual of core_type - | Tcfk_concrete of override_flag * expression + if the path contains 'node_modules', + [node_relative_path] will discard its prefix and + just treat it as a library instead +*) +val simple_convert_node_path_to_os_path : string -> string -and class_field_desc = - Tcf_inherit of - override_flag * class_expr * string option * (string * Ident.t) list * - (string * Ident.t) list - (* Inherited instance variables and concrete methods *) - | Tcf_val of string loc * mutable_flag * Ident.t * class_field_kind * bool - | Tcf_method of string loc * private_flag * class_field_kind - | Tcf_constraint of core_type * core_type - | Tcf_initializer of expression - | Tcf_attribute of attribute -(* Value expressions for the module language *) -and module_expr = - { mod_desc: module_expr_desc; - mod_loc: Location.t; - mod_type: Types.module_type; - mod_env: Env.t; - mod_attributes: attribute list; - } +(** + [combine path1 path2] + 1. add some simplifications when concatenating + 2. when [path2] is absolute, return [path2] +*) +val combine : + string -> + string -> + string -and module_type_constraint = - Tmodtype_implicit -| Tmodtype_explicit of module_type -and module_expr_desc = - Tmod_ident of Path.t * Longident.t loc - | Tmod_structure of structure - | Tmod_functor of Ident.t * string loc * module_type option * module_expr - | Tmod_apply of module_expr * module_expr * module_coercion - | Tmod_constraint of - module_expr * Types.module_type * module_type_constraint * module_coercion - | Tmod_unpack of expression * Types.module_type -and structure = { - str_items : structure_item list; - str_type : Types.signature; - str_final_env : Env.t; -} +(** + {[ + get_extension "a.txt" = ".txt" + get_extension "a" = "" + ]} +*) -and structure_item = - { str_desc : structure_item_desc; - str_loc : Location.t; - str_env : Env.t - } -and structure_item_desc = - Tstr_eval of expression * attributes - | Tstr_value of rec_flag * value_binding list - | Tstr_primitive of value_description - | Tstr_type of rec_flag * type_declaration list - | Tstr_typext of type_extension - | Tstr_exception of extension_constructor - | Tstr_module of module_binding - | Tstr_recmodule of module_binding list - | Tstr_modtype of module_type_declaration - | Tstr_open of open_description - | Tstr_class of (class_declaration * string list) list - | Tstr_class_type of (Ident.t * string loc * class_type_declaration) list - | Tstr_include of include_declaration - | Tstr_attribute of attribute -and module_binding = - { - mb_id: Ident.t; - mb_name: string loc; - mb_expr: module_expr; - mb_attributes: attribute list; - mb_loc: Location.t; - } -and value_binding = - { - vb_pat: pattern; - vb_expr: expression; - vb_attributes: attributes; - vb_loc: Location.t; - } -and module_coercion = - Tcoerce_none - | Tcoerce_structure of (int * module_coercion) list * - (Ident.t * int * module_coercion) list * - string list (* runtime fields *) - | Tcoerce_functor of module_coercion * module_coercion - | Tcoerce_primitive of primitive_coercion - | Tcoerce_alias of Path.t * module_coercion +val node_rebase_file : + from:string -> + to_:string -> + string -> + string -and module_type = - { mty_desc: module_type_desc; - mty_type : Types.module_type; - mty_env : Env.t; - mty_loc: Location.t; - mty_attributes: attribute list; - } +(** + TODO: could be highly optimized + if [from] and [to] resolve to the same path, a zero-length string is returned + Given that two paths are directory -and module_type_desc = - Tmty_ident of Path.t * Longident.t loc - | Tmty_signature of signature - | Tmty_functor of Ident.t * string loc * module_type option * module_type - | Tmty_with of module_type * (Path.t * Longident.t loc * with_constraint) list - | Tmty_typeof of module_expr - | Tmty_alias of Path.t * Longident.t loc + A typical use case is + {[ + Filename.concat + (rel_normalized_absolute_path cwd (Filename.dirname a)) + (Filename.basename a) + ]} +*) +val rel_normalized_absolute_path : from:string -> string -> string -(* Keep primitive type information for type-based lambda-code specialization *) -and primitive_coercion = - { - pc_desc: Primitive.description; - pc_type: type_expr; - pc_env: Env.t; - pc_loc : Location.t; - - pc_id : Ident.t; - } +val normalize_absolute_path : string -> string -and signature = { - sig_items : signature_item list; - sig_type : Types.signature; - sig_final_env : Env.t; -} -and signature_item = - { sig_desc: signature_item_desc; - sig_env : Env.t; (* BINANNOT ADDED *) - sig_loc: Location.t } +val absolute_cwd_path : string -> string -and signature_item_desc = - Tsig_value of value_description - | Tsig_type of rec_flag * type_declaration list - | Tsig_typext of type_extension - | Tsig_exception of extension_constructor - | Tsig_module of module_declaration - | Tsig_recmodule of module_declaration list - | Tsig_modtype of module_type_declaration - | Tsig_open of open_description - | Tsig_include of include_description - | Tsig_class of class_description list - | Tsig_class_type of class_type_declaration list - | Tsig_attribute of attribute +(** [concat dirname filename] + The same as {!Filename.concat} except a tiny optimization + for current directory simplification +*) +val concat : string -> string -> string -and module_declaration = - { - md_id: Ident.t; - md_name: string loc; - md_type: module_type; - md_attributes: attribute list; - md_loc: Location.t; - } +val check_suffix_case : + string -> string -> bool -and module_type_declaration = - { - mtd_id: Ident.t; - mtd_name: string loc; - mtd_type: module_type option; - mtd_attributes: attribute list; - mtd_loc: Location.t; - } -and open_description = - { - open_path: Path.t; - open_txt: Longident.t loc; - open_override: override_flag; - open_loc: Location.t; - open_attributes: attribute list; - } -and 'a include_infos = - { - incl_mod: 'a; - incl_type: Types.signature; - incl_loc: Location.t; - incl_attributes: attribute list; - } +(* It is lazy so that it will not hit errors when in script mode *) +val package_dir : string Lazy.t -and include_description = module_type include_infos +end = struct +#1 "ext_path.ml" +(* Copyright (C) 2017 Authors of BuckleScript + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -and include_declaration = module_expr include_infos +type t = + | File of string + | Dir of string -and with_constraint = - Twith_type of type_declaration - | Twith_module of Path.t * Longident.t loc - | Twith_typesubst of type_declaration - | Twith_modsubst of Path.t * Longident.t loc -and core_type = -(* mutable because of [Typeclass.declare_method] *) - { mutable ctyp_desc : core_type_desc; - mutable ctyp_type : type_expr; - ctyp_env : Env.t; (* BINANNOT ADDED *) - ctyp_loc : Location.t; - ctyp_attributes: attribute list; - } +let simple_convert_node_path_to_os_path = + if Sys.unix then fun x -> x + else if Sys.win32 || Sys.cygwin then + Ext_string.replace_slash_backward + else failwith ("Unknown OS : " ^ Sys.os_type) -and core_type_desc = - Ttyp_any - | Ttyp_var of string - | Ttyp_arrow of arg_label * core_type * core_type - | Ttyp_tuple of core_type list - | Ttyp_constr of Path.t * Longident.t loc * core_type list - | Ttyp_object of object_field list * closed_flag - | Ttyp_class of Path.t * Longident.t loc * core_type list - | Ttyp_alias of core_type * string - | Ttyp_variant of row_field list * closed_flag * label list option - | Ttyp_poly of string list * core_type - | Ttyp_package of package_type -and package_type = { - pack_path : Path.t; - pack_fields : (Longident.t loc * core_type) list; - pack_type : Types.module_type; - pack_txt : Longident.t loc; -} +let cwd = lazy (Sys.getcwd()) -and row_field = - Ttag of string loc * attributes * bool * core_type list - | Tinherit of core_type +let split_by_sep_per_os : string -> string list = + if Ext_sys.is_windows_or_cygwin then + fun x -> + (* on Windows, we can still accept -bs-package-output lib/js *) + Ext_string.split_by + (fun x -> match x with |'/' |'\\' -> true | _ -> false) x + else + fun x -> Ext_string.split x '/' -and object_field = - | OTtag of string loc * attributes * core_type - | OTinherit of core_type +(** example + {[ + "/bb/mbigc/mbig2899/bgit/bucklescript/jscomp/stdlib/external/pervasives.cmj" + "/bb/mbigc/mbig2899/bgit/bucklescript/jscomp/stdlib/ocaml_array.ml" + ]} -and value_description = - { val_id: Ident.t; - val_name: string loc; - val_desc: core_type; - val_val: Types.value_description; - val_prim: string list; - val_loc: Location.t; - val_attributes: attribute list; - } + The other way + {[ -and type_declaration = - { typ_id: Ident.t; - typ_name: string loc; - typ_params: (core_type * variance) list; - typ_type: Types.type_declaration; - typ_cstrs: (core_type * core_type * Location.t) list; - typ_kind: type_kind; - typ_private: private_flag; - typ_manifest: core_type option; - typ_loc: Location.t; - typ_attributes: attribute list; - } + "/bb/mbigc/mbig2899/bgit/bucklescript/jscomp/stdlib/ocaml_array.ml" + "/bb/mbigc/mbig2899/bgit/bucklescript/jscomp/stdlib/external/pervasives.cmj" + ]} + {[ + "/bb/mbigc/mbig2899/bgit/bucklescript/jscomp/stdlib//ocaml_array.ml" + ]} + {[ + /a/b + /c/d + ]} +*) +let node_relative_path + ~from:(file_or_dir_2 : t ) + (file_or_dir_1 : t) + = + let relevant_dir1 = + match file_or_dir_1 with + | Dir x -> x + | File file1 -> Filename.dirname file1 in + let relevant_dir2 = + match file_or_dir_2 with + | Dir x -> x + | File file2 -> Filename.dirname file2 in + let dir1 = split_by_sep_per_os relevant_dir1 in + let dir2 = split_by_sep_per_os relevant_dir2 in + let rec go (dir1 : string list) (dir2 : string list) = + match dir1, dir2 with + | "." :: xs, ys -> go xs ys + | xs , "." :: ys -> go xs ys + | x::xs , y :: ys when x = y + -> go xs ys + | _, _ -> + Ext_list.map_append dir2 dir1 (fun _ -> Literals.node_parent) + in + match go dir1 dir2 with + | (x :: _ ) as ys when x = Literals.node_parent -> + String.concat Literals.node_sep ys + | ys -> + String.concat Literals.node_sep + @@ Literals.node_current :: ys -and type_kind = - Ttype_abstract - | Ttype_variant of constructor_declaration list - | Ttype_record of label_declaration list - | Ttype_open -and label_declaration = - { - ld_id: Ident.t; - ld_name: string loc; - ld_mutable: mutable_flag; - ld_type: core_type; - ld_loc: Location.t; - ld_attributes: attribute list; - } +let node_concat ~dir base = + dir ^ Literals.node_sep ^ base -and constructor_declaration = - { - cd_id: Ident.t; - cd_name: string loc; - cd_args: constructor_arguments; - cd_res: core_type option; - cd_loc: Location.t; - cd_attributes: attribute list; - } +let node_rebase_file ~from ~to_ file = + + node_concat + ~dir:( + if from = to_ then Literals.node_current + else node_relative_path ~from:(Dir from) (Dir to_)) + file + + +(*** + {[ + Filename.concat "." "";; + "./" + ]} +*) +let combine path1 path2 = + if Filename.is_relative path2 then + if Ext_string.is_empty path2 then + path1 + else + if path1 = Filename.current_dir_name then + path2 + else + if path2 = Filename.current_dir_name + then path1 + else + Filename.concat path1 path2 + else + path2 -and constructor_arguments = - | Cstr_tuple of core_type list - | Cstr_record of label_declaration list -and type_extension = - { - tyext_path: Path.t; - tyext_txt: Longident.t loc; - tyext_params: (core_type * variance) list; - tyext_constructors: extension_constructor list; - tyext_private: private_flag; - tyext_attributes: attribute list; - } -and extension_constructor = - { - ext_id: Ident.t; - ext_name: string loc; - ext_type: Types.extension_constructor; - ext_kind: extension_constructor_kind; - ext_loc: Location.t; - ext_attributes: attribute list; - } -and extension_constructor_kind = - Text_decl of constructor_arguments * core_type option - | Text_rebind of Path.t * Longident.t loc -and class_type = - { - cltyp_desc: class_type_desc; - cltyp_type: Types.class_type; - cltyp_env: Env.t; - cltyp_loc: Location.t; - cltyp_attributes: attribute list; - } -and class_type_desc = - Tcty_constr of Path.t * Longident.t loc * core_type list - | Tcty_signature of class_signature - | Tcty_arrow of arg_label * core_type * class_type - | Tcty_open of override_flag * Path.t * Longident.t loc * Env.t * class_type -and class_signature = { - csig_self: core_type; - csig_fields: class_type_field list; - csig_type: Types.class_signature; - } -and class_type_field = { - ctf_desc: class_type_field_desc; - ctf_loc: Location.t; - ctf_attributes: attribute list; - } +let (//) x y = + if x = Filename.current_dir_name then y + else if y = Filename.current_dir_name then x + else Filename.concat x y -and class_type_field_desc = - | Tctf_inherit of class_type - | Tctf_val of (string * mutable_flag * virtual_flag * core_type) - | Tctf_method of (string * private_flag * virtual_flag * core_type) - | Tctf_constraint of (core_type * core_type) - | Tctf_attribute of attribute +(** + {[ + split_aux "//ghosg//ghsogh/";; + - : string * string list = ("/", ["ghosg"; "ghsogh"]) + ]} + Note that + {[ + Filename.dirname "/a/" = "/" + Filename.dirname "/a/b/" = Filename.dirname "/a/b" = "/a" + ]} + Special case: + {[ + basename "//" = "/" + basename "///" = "/" + ]} + {[ + basename "" = "." + basename "" = "." + dirname "" = "." + dirname "" = "." + ]} +*) +let split_aux p = + let rec go p acc = + let dir = Filename.dirname p in + if dir = p then dir, acc + else + let new_path = Filename.basename p in + if Ext_string.equal new_path Filename.dir_sep then + go dir acc + (* We could do more path simplification here + leave to [rel_normalized_absolute_path] + *) + else + go dir (new_path :: acc) -and class_declaration = - class_expr class_infos + in go p [] -and class_description = - class_type class_infos -and class_type_declaration = - class_type class_infos -and 'a class_infos = - { ci_virt: virtual_flag; - ci_params: (core_type * variance) list; - ci_id_name: string loc; - ci_id_class: Ident.t; - ci_id_class_type: Ident.t; - ci_id_object: Ident.t; - ci_id_typehash: Ident.t; - ci_expr: 'a; - ci_decl: Types.class_declaration; - ci_type_decl: Types.class_type_declaration; - ci_loc: Location.t; - ci_attributes: attribute list; - } -(* Auxiliary functions over the a.s.t. *) -let iter_pattern_desc f = function - | Tpat_alias(p, _, _) -> f p - | Tpat_tuple patl -> List.iter f patl - | Tpat_construct(_, _, patl) -> List.iter f patl - | Tpat_variant(_, pat, _) -> may f pat - | Tpat_record (lbl_pat_list, _) -> - List.iter (fun (_, _, pat) -> f pat) lbl_pat_list - | Tpat_array patl -> List.iter f patl - | Tpat_or(p1, p2, _) -> f p1; f p2 - | Tpat_lazy p -> f p - | Tpat_any - | Tpat_var _ - | Tpat_constant _ -> () +(** + TODO: optimization + if [from] and [to] resolve to the same path, a zero-length string is returned -let map_pattern_desc f d = - match d with - | Tpat_alias (p1, id, s) -> - Tpat_alias (f p1, id, s) - | Tpat_tuple pats -> - Tpat_tuple (List.map f pats) - | Tpat_record (lpats, closed) -> - Tpat_record (List.map (fun (lid, l,p) -> lid, l, f p) lpats, closed) - | Tpat_construct (lid, c,pats) -> - Tpat_construct (lid, c, List.map f pats) - | Tpat_array pats -> - Tpat_array (List.map f pats) - | Tpat_lazy p1 -> Tpat_lazy (f p1) - | Tpat_variant (x1, Some p1, x2) -> - Tpat_variant (x1, Some (f p1), x2) - | Tpat_or (p1,p2,path) -> - Tpat_or (f p1, f p2, path) - | Tpat_var _ - | Tpat_constant _ - | Tpat_any - | Tpat_variant (_,None,_) -> d + This function is useed in [es6-global] and + [amdjs-global] format and tailored for `rollup` +*) +let rel_normalized_absolute_path ~from to_ = + let root1, paths1 = split_aux from in + let root2, paths2 = split_aux to_ in + if root1 <> root2 then root2 + else + let rec go xss yss = + match xss, yss with + | x::xs, y::ys -> + if Ext_string.equal x y then go xs ys + else if x = Filename.current_dir_name then go xs yss + else if y = Filename.current_dir_name then go xss ys + else + let start = + Ext_list.fold_left xs Ext_string.parent_dir_lit (fun acc _ -> acc // Ext_string.parent_dir_lit ) + in + Ext_list.fold_left yss start (fun acc v -> acc // v) + | [], [] -> Ext_string.empty + | [], y::ys -> Ext_list.fold_left ys y (fun acc x -> acc // x) + | x::xs, [] -> + Ext_list.fold_left xs Ext_string.parent_dir_lit (fun acc _ -> acc // Ext_string.parent_dir_lit ) + in + let v = go paths1 paths2 in -(* List the identifiers bound by a pattern or a let *) + if Ext_string.is_empty v then Literals.node_current + else + if + v = "." + || v = ".." + || Ext_string.starts_with v "./" + || Ext_string.starts_with v "../" + then v + else "./" ^ v -let idents = ref([]: (Ident.t * string loc) list) +(*TODO: could be hgighly optimized later + {[ + normalize_absolute_path "/gsho/./..";; -let rec bound_idents pat = - match pat.pat_desc with - | Tpat_var (id,s) -> idents := (id,s) :: !idents - | Tpat_alias(p, id, s ) -> - bound_idents p; idents := (id,s) :: !idents - | Tpat_or(p1, _, _) -> - (* Invariant : both arguments binds the same variables *) - bound_idents p1 - | d -> iter_pattern_desc bound_idents d + normalize_absolute_path "/a/b/../c../d/e/f";; -let pat_bound_idents pat = - idents := []; - bound_idents pat; - let res = !idents in - idents := []; - List.map fst res + normalize_absolute_path "/gsho/./..";; -let rev_let_bound_idents_with_loc bindings = - idents := []; - List.iter (fun vb -> bound_idents vb.vb_pat) bindings; - let res = !idents in idents := []; res + normalize_absolute_path "/gsho/./../..";; -let let_bound_idents_with_loc pat_expr_list = - List.rev(rev_let_bound_idents_with_loc pat_expr_list) + normalize_absolute_path "/a/b/c/d";; -let rev_let_bound_idents pat = List.map fst (rev_let_bound_idents_with_loc pat) -let let_bound_idents pat = List.map fst (let_bound_idents_with_loc pat) + normalize_absolute_path "/a/b/c/d/";; -let alpha_var env id = List.assoc id env + normalize_absolute_path "/a/";; -let rec alpha_pat env p = match p.pat_desc with -| Tpat_var (id, s) -> (* note the ``Not_found'' case *) - {p with pat_desc = - try Tpat_var (alpha_var env id, s) with - | Not_found -> Tpat_any} -| Tpat_alias (p1, id, s) -> - let new_p = alpha_pat env p1 in - begin try - {p with pat_desc = Tpat_alias (new_p, alpha_var env id, s)} - with - | Not_found -> new_p - end -| d -> - {p with pat_desc = map_pattern_desc (alpha_pat env) d} + normalize_absolute_path "/a";; + ]} +*) +(** See tests in {!Ounit_path_tests} *) +let normalize_absolute_path x = + let drop_if_exist xs = + match xs with + | [] -> [] + | _ :: xs -> xs in + let rec normalize_list acc paths = + match paths with + | [] -> acc + | x :: xs -> + if Ext_string.equal x Ext_string.current_dir_lit then + normalize_list acc xs + else if Ext_string.equal x Ext_string.parent_dir_lit then + normalize_list (drop_if_exist acc ) xs + else + normalize_list (x::acc) xs + in + let root, paths = split_aux x in + let rev_paths = normalize_list [] paths in + let rec go acc rev_paths = + match rev_paths with + | [] -> Filename.concat root acc + | last::rest -> go (Filename.concat last acc ) rest in + match rev_paths with + | [] -> root + | last :: rest -> go last rest -let mkloc = Location.mkloc -let mknoloc = Location.mknoloc -end -module Tast_mapper : sig -#1 "tast_mapper.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Alain Frisch, LexiFi *) -(* *) -(* Copyright 2015 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) -open Asttypes -open Typedtree -(** {1 A generic Typedtree mapper} *) +let absolute_path cwd s = + let process s = + let s = + if Filename.is_relative s then + Lazy.force cwd // s + else s in + (* Now simplify . and .. components *) + let rec aux s = + let base,dir = Filename.basename s, Filename.dirname s in + if dir = s then dir + else if base = Filename.current_dir_name then aux dir + else if base = Filename.parent_dir_name then Filename.dirname (aux dir) + else aux dir // base + in aux s in + process s -type mapper = - { - case: mapper -> case -> case; - cases: mapper -> case list -> case list; - class_declaration: mapper -> class_declaration -> class_declaration; - class_description: mapper -> class_description -> class_description; - class_expr: mapper -> class_expr -> class_expr; - class_field: mapper -> class_field -> class_field; - class_signature: mapper -> class_signature -> class_signature; - class_structure: mapper -> class_structure -> class_structure; - class_type: mapper -> class_type -> class_type; - class_type_declaration: mapper -> class_type_declaration -> - class_type_declaration; - class_type_field: mapper -> class_type_field -> class_type_field; - env: mapper -> Env.t -> Env.t; - expr: mapper -> expression -> expression; - extension_constructor: mapper -> extension_constructor -> - extension_constructor; - module_binding: mapper -> module_binding -> module_binding; - module_coercion: mapper -> module_coercion -> module_coercion; - module_declaration: mapper -> module_declaration -> module_declaration; - module_expr: mapper -> module_expr -> module_expr; - module_type: mapper -> module_type -> module_type; - module_type_declaration: - mapper -> module_type_declaration -> module_type_declaration; - package_type: mapper -> package_type -> package_type; - pat: mapper -> pattern -> pattern; - row_field: mapper -> row_field -> row_field; - object_field: mapper -> object_field -> object_field; - signature: mapper -> signature -> signature; - signature_item: mapper -> signature_item -> signature_item; - structure: mapper -> structure -> structure; - structure_item: mapper -> structure_item -> structure_item; - typ: mapper -> core_type -> core_type; - type_declaration: mapper -> type_declaration -> type_declaration; - type_declarations: mapper -> (rec_flag * type_declaration list) -> - (rec_flag * type_declaration list); - type_extension: mapper -> type_extension -> type_extension; - type_kind: mapper -> type_kind -> type_kind; - value_binding: mapper -> value_binding -> value_binding; - value_bindings: mapper -> (rec_flag * value_binding list) -> - (rec_flag * value_binding list); - value_description: mapper -> value_description -> value_description; - with_constraint: mapper -> with_constraint -> with_constraint; - } +let absolute_cwd_path s = + absolute_path cwd s +let absolute cwd s = + match s with + | File x -> File (absolute_path cwd x ) + | Dir x -> Dir (absolute_path cwd x) -val default: mapper +let concat dirname filename = + if filename = Filename.current_dir_name then dirname + else if dirname = Filename.current_dir_name then filename + else Filename.concat dirname filename + -end = struct -#1 "tast_mapper.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Alain Frisch, LexiFi *) -(* *) -(* Copyright 2015 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let check_suffix_case = + Ext_string.ends_with -open Asttypes -open Typedtree +(* Input must be absolute directory *) +let rec find_root_filename ~cwd filename = + if Sys.file_exists ( Filename.concat cwd filename) then cwd + else + let cwd' = Filename.dirname cwd in + if String.length cwd' < String.length cwd then + find_root_filename ~cwd:cwd' filename + else + Ext_fmt.failwithf + ~loc:__LOC__ + "%s not found from %s" filename cwd -(* TODO: add 'methods' for location, attribute, extension, - open_description, include_declaration, include_description *) -type mapper = - { - case: mapper -> case -> case; - cases: mapper -> case list -> case list; - class_declaration: mapper -> class_declaration -> class_declaration; - class_description: mapper -> class_description -> class_description; - class_expr: mapper -> class_expr -> class_expr; - class_field: mapper -> class_field -> class_field; - class_signature: mapper -> class_signature -> class_signature; - class_structure: mapper -> class_structure -> class_structure; - class_type: mapper -> class_type -> class_type; - class_type_declaration: mapper -> class_type_declaration -> - class_type_declaration; - class_type_field: mapper -> class_type_field -> class_type_field; - env: mapper -> Env.t -> Env.t; - expr: mapper -> expression -> expression; - extension_constructor: mapper -> extension_constructor -> - extension_constructor; - module_binding: mapper -> module_binding -> module_binding; - module_coercion: mapper -> module_coercion -> module_coercion; - module_declaration: mapper -> module_declaration -> module_declaration; - module_expr: mapper -> module_expr -> module_expr; - module_type: mapper -> module_type -> module_type; - module_type_declaration: - mapper -> module_type_declaration -> module_type_declaration; - package_type: mapper -> package_type -> package_type; - pat: mapper -> pattern -> pattern; - row_field: mapper -> row_field -> row_field; - object_field: mapper -> object_field -> object_field; - signature: mapper -> signature -> signature; - signature_item: mapper -> signature_item -> signature_item; - structure: mapper -> structure -> structure; - structure_item: mapper -> structure_item -> structure_item; - typ: mapper -> core_type -> core_type; - type_declaration: mapper -> type_declaration -> type_declaration; - type_declarations: mapper -> (rec_flag * type_declaration list) -> - (rec_flag * type_declaration list); - type_extension: mapper -> type_extension -> type_extension; - type_kind: mapper -> type_kind -> type_kind; - value_binding: mapper -> value_binding -> value_binding; - value_bindings: mapper -> (rec_flag * value_binding list) -> - (rec_flag * value_binding list); - value_description: mapper -> value_description -> value_description; - with_constraint: mapper -> with_constraint -> with_constraint; - } +let find_package_json_dir cwd = + find_root_filename ~cwd Literals.bsconfig_json -let id x = x -let tuple2 f1 f2 (x, y) = (f1 x, f2 y) -let tuple3 f1 f2 f3 (x, y, z) = (f1 x, f2 y, f3 z) -let opt f = function None -> None | Some x -> Some (f x) +let package_dir = lazy (find_package_json_dir (Lazy.force cwd)) -let structure sub {str_items; str_type; str_final_env} = - { - str_items = List.map (sub.structure_item sub) str_items; - str_final_env = sub.env sub str_final_env; - str_type; - } +end +module Ext_ref : sig +#1 "ext_ref.mli" +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -let class_infos sub f x = - {x with - ci_params = List.map (tuple2 (sub.typ sub) id) x.ci_params; - ci_expr = f x.ci_expr; - } +(** [non_exn_protect ref value f] assusme [f()] + would not raise +*) -let module_type_declaration sub x = - let mtd_type = opt (sub.module_type sub) x.mtd_type in - {x with mtd_type} +val non_exn_protect : 'a ref -> 'a -> (unit -> 'b) -> 'b +val protect : 'a ref -> 'a -> (unit -> 'b) -> 'b -let module_declaration sub x = - let md_type = sub.module_type sub x.md_type in - {x with md_type} +val protect2 : 'a ref -> 'b ref -> 'a -> 'b -> (unit -> 'c) -> 'c -let include_infos f x = {x with incl_mod = f x.incl_mod} +(** [non_exn_protect2 refa refb va vb f ] + assume [f ()] would not raise +*) +val non_exn_protect2 : 'a ref -> 'b ref -> 'a -> 'b -> (unit -> 'c) -> 'c -let class_type_declaration sub x = - class_infos sub (sub.class_type sub) x +val protect_list : ('a ref * 'a) list -> (unit -> 'b) -> 'b -let class_declaration sub x = - class_infos sub (sub.class_expr sub) x +end = struct +#1 "ext_ref.ml" +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -let structure_item sub {str_desc; str_loc; str_env} = - let str_env = sub.env sub str_env in - let str_desc = - match str_desc with - | Tstr_eval (exp, attrs) -> Tstr_eval (sub.expr sub exp, attrs) - | Tstr_value (rec_flag, list) -> - let (rec_flag, list) = sub.value_bindings sub (rec_flag, list) in - Tstr_value (rec_flag, list) - | Tstr_primitive v -> Tstr_primitive (sub.value_description sub v) - | Tstr_type (rec_flag, list) -> - let (rec_flag, list) = sub.type_declarations sub (rec_flag, list) in - Tstr_type (rec_flag, list) - | Tstr_typext te -> Tstr_typext (sub.type_extension sub te) - | Tstr_exception ext -> Tstr_exception (sub.extension_constructor sub ext) - | Tstr_module mb -> Tstr_module (sub.module_binding sub mb) - | Tstr_recmodule list -> - Tstr_recmodule (List.map (sub.module_binding sub) list) - | Tstr_modtype x -> Tstr_modtype (sub.module_type_declaration sub x) - | Tstr_class list -> - Tstr_class - (List.map (tuple2 (sub.class_declaration sub) id) list) - | Tstr_class_type list -> - Tstr_class_type - (List.map (tuple3 id id (sub.class_type_declaration sub)) list) - | Tstr_include incl -> - Tstr_include (include_infos (sub.module_expr sub) incl) - | Tstr_open _ - | Tstr_attribute _ as d -> d - in - {str_desc; str_env; str_loc} +let non_exn_protect r v body = + let old = !r in + r := v; + let res = body() in + r := old; + res -let value_description sub x = - let val_desc = sub.typ sub x.val_desc in - {x with val_desc} +let protect r v body = + let old = !r in + try + r := v; + let res = body() in + r := old; + res + with x -> + r := old; + raise x -let label_decl sub x = - let ld_type = sub.typ sub x.ld_type in - {x with ld_type} +let non_exn_protect2 r1 r2 v1 v2 body = + let old1 = !r1 in + let old2 = !r2 in + r1 := v1; + r2 := v2; + let res = body() in + r1 := old1; + r2 := old2; + res -let constructor_args sub = function - | Cstr_tuple l -> Cstr_tuple (List.map (sub.typ sub) l) - | Cstr_record l -> Cstr_record (List.map (label_decl sub) l) +let protect2 r1 r2 v1 v2 body = + let old1 = !r1 in + let old2 = !r2 in + try + r1 := v1; + r2 := v2; + let res = body() in + r1 := old1; + r2 := old2; + res + with x -> + r1 := old1; + r2 := old2; + raise x -let constructor_decl sub cd = - let cd_args = constructor_args sub cd.cd_args in - let cd_res = opt (sub.typ sub) cd.cd_res in - {cd with cd_args; cd_res} +let protect_list rvs body = + let olds = Ext_list.map rvs (fun (x,y) -> !x) in + let () = List.iter (fun (x,y) -> x:=y) rvs in + try + let res = body () in + List.iter2 (fun (x,_) old -> x := old) rvs olds; + res + with e -> + List.iter2 (fun (x,_) old -> x := old) rvs olds; + raise e -let type_kind sub = function - | Ttype_abstract -> Ttype_abstract - | Ttype_variant list -> Ttype_variant (List.map (constructor_decl sub) list) - | Ttype_record list -> Ttype_record (List.map (label_decl sub) list) - | Ttype_open -> Ttype_open +end +module Ml_binary : sig +#1 "ml_binary.mli" +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -let type_declaration sub x = - let typ_cstrs = - List.map - (tuple3 (sub.typ sub) (sub.typ sub) id) - x.typ_cstrs - in - let typ_kind = sub.type_kind sub x.typ_kind in - let typ_manifest = opt (sub.typ sub) x.typ_manifest in - let typ_params = List.map (tuple2 (sub.typ sub) id) x.typ_params in - {x with typ_cstrs; typ_kind; typ_manifest; typ_params} -let type_declarations sub (rec_flag, list) = - (rec_flag, List.map (sub.type_declaration sub) list) -let type_extension sub x = - let tyext_params = List.map (tuple2 (sub.typ sub) id) x.tyext_params in - let tyext_constructors = - List.map (sub.extension_constructor sub) x.tyext_constructors - in - {x with tyext_constructors; tyext_params} +type _ kind = + | Ml : Parsetree.structure kind + | Mli : Parsetree.signature kind -let extension_constructor sub x = - let ext_kind = - match x.ext_kind with - Text_decl(ctl, cto) -> - Text_decl(constructor_args sub ctl, opt (sub.typ sub) cto) - | Text_rebind _ as d -> d - in - {x with ext_kind} -let pat sub x = - let extra = function - | Tpat_type _ - | Tpat_unpack as d -> d - | Tpat_open (path,loc,env) -> Tpat_open (path, loc, sub.env sub env) - | Tpat_constraint ct -> Tpat_constraint (sub.typ sub ct) - in - let pat_env = sub.env sub x.pat_env in - let pat_extra = List.map (tuple3 extra id id) x.pat_extra in - let pat_desc = - match x.pat_desc with - | Tpat_any - | Tpat_var _ - | Tpat_constant _ as d -> d - | Tpat_tuple l -> Tpat_tuple (List.map (sub.pat sub) l) - | Tpat_construct (loc, cd, l) -> - Tpat_construct (loc, cd, List.map (sub.pat sub) l) - | Tpat_variant (l, po, rd) -> Tpat_variant (l, opt (sub.pat sub) po, rd) - | Tpat_record (l, closed) -> - Tpat_record (List.map (tuple3 id id (sub.pat sub)) l, closed) - | Tpat_array l -> Tpat_array (List.map (sub.pat sub) l) - | Tpat_or (p1, p2, rd) -> - Tpat_or (sub.pat sub p1, sub.pat sub p2, rd) - | Tpat_alias (p, id, s) -> Tpat_alias (sub.pat sub p, id, s) - | Tpat_lazy p -> Tpat_lazy (sub.pat sub p) - in - {x with pat_extra; pat_desc; pat_env} +val read_ast : 'a kind -> in_channel -> 'a -let expr sub x = - let extra = function - | Texp_constraint cty -> - Texp_constraint (sub.typ sub cty) - | Texp_coerce (cty1, cty2) -> - Texp_coerce (opt (sub.typ sub) cty1, sub.typ sub cty2) - | Texp_open (ovf, path, loc, env) -> - Texp_open (ovf, path, loc, sub.env sub env) - | Texp_newtype _ as d -> d - | Texp_poly cto -> Texp_poly (opt (sub.typ sub) cto) - in - let exp_extra = List.map (tuple3 extra id id) x.exp_extra in - let exp_env = sub.env sub x.exp_env in - let exp_desc = - match x.exp_desc with - | Texp_ident _ - | Texp_constant _ as d -> d - | Texp_let (rec_flag, list, exp) -> - let (rec_flag, list) = sub.value_bindings sub (rec_flag, list) in - Texp_let (rec_flag, list, sub.expr sub exp) - | Texp_function { arg_label; param; cases; partial; } -> - Texp_function { arg_label; param; cases = sub.cases sub cases; - partial; } - | Texp_apply (exp, list) -> - Texp_apply ( - sub.expr sub exp, - List.map (tuple2 id (opt (sub.expr sub))) list - ) - | Texp_match (exp, cases, exn_cases, p) -> - Texp_match ( - sub.expr sub exp, - sub.cases sub cases, - sub.cases sub exn_cases, - p - ) - | Texp_try (exp, cases) -> - Texp_try ( - sub.expr sub exp, - sub.cases sub cases - ) - | Texp_tuple list -> - Texp_tuple (List.map (sub.expr sub) list) - | Texp_construct (lid, cd, args) -> - Texp_construct (lid, cd, List.map (sub.expr sub) args) - | Texp_variant (l, expo) -> - Texp_variant (l, opt (sub.expr sub) expo) - | Texp_record { fields; representation; extended_expression } -> - let fields = Array.map (function - | label, Kept t -> label, Kept t - | label, Overridden (lid, exp) -> - label, Overridden (lid, sub.expr sub exp)) - fields - in - Texp_record { - fields; representation; - extended_expression = opt (sub.expr sub) extended_expression; - } - | Texp_field (exp, lid, ld) -> - Texp_field (sub.expr sub exp, lid, ld) - | Texp_setfield (exp1, lid, ld, exp2) -> - Texp_setfield ( - sub.expr sub exp1, - lid, - ld, - sub.expr sub exp2 - ) - | Texp_array list -> - Texp_array (List.map (sub.expr sub) list) - | Texp_ifthenelse (exp1, exp2, expo) -> - Texp_ifthenelse ( - sub.expr sub exp1, - sub.expr sub exp2, - opt (sub.expr sub) expo - ) - | Texp_sequence (exp1, exp2) -> - Texp_sequence ( - sub.expr sub exp1, - sub.expr sub exp2 - ) - | Texp_while (exp1, exp2) -> - Texp_while ( - sub.expr sub exp1, - sub.expr sub exp2 - ) - | Texp_for (id, p, exp1, exp2, dir, exp3) -> - Texp_for ( - id, - p, - sub.expr sub exp1, - sub.expr sub exp2, - dir, - sub.expr sub exp3 - ) - | Texp_send (exp, meth, expo) -> - Texp_send - ( - sub.expr sub exp, - meth, - opt (sub.expr sub) expo - ) - | Texp_new _ - | Texp_instvar _ as d -> d - | Texp_setinstvar (path1, path2, id, exp) -> - Texp_setinstvar ( - path1, - path2, - id, - sub.expr sub exp - ) - | Texp_override (path, list) -> - Texp_override ( - path, - List.map (tuple3 id id (sub.expr sub)) list - ) - | Texp_letmodule (id, s, mexpr, exp) -> - Texp_letmodule ( - id, - s, - sub.module_expr sub mexpr, - sub.expr sub exp - ) - | Texp_letexception (cd, exp) -> - Texp_letexception ( - sub.extension_constructor sub cd, - sub.expr sub exp - ) - | Texp_assert exp -> - Texp_assert (sub.expr sub exp) - | Texp_lazy exp -> - Texp_lazy (sub.expr sub exp) - | Texp_object (cl, sl) -> - Texp_object (sub.class_structure sub cl, sl) - | Texp_pack mexpr -> - Texp_pack (sub.module_expr sub mexpr) - | Texp_unreachable -> - Texp_unreachable - | Texp_extension_constructor _ as e -> - e - in - {x with exp_extra; exp_desc; exp_env} +val write_ast : + 'a kind -> string -> 'a -> out_channel -> unit +end = struct +#1 "ml_binary.ml" +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -let package_type sub x = - let pack_fields = List.map (tuple2 id (sub.typ sub)) x.pack_fields in - {x with pack_fields} +type _ kind = + | Ml : Parsetree.structure kind + | Mli : Parsetree.signature kind -let signature sub x = - let sig_final_env = sub.env sub x.sig_final_env in - let sig_items = List.map (sub.signature_item sub) x.sig_items in - {x with sig_items; sig_final_env} +(** [read_ast kind ic] assume [ic] channel is + in the right position *) +let read_ast (type t ) (kind : t kind) ic : t = + let magic = + match kind with + | Ml -> Config.ast_impl_magic_number + | Mli -> Config.ast_intf_magic_number in + let buffer = really_input_string ic (String.length magic) in + assert(buffer = magic); (* already checked by apply_rewriter *) + Location.set_input_name @@ input_value ic; + input_value ic -let signature_item sub x = - let sig_env = sub.env sub x.sig_env in - let sig_desc = - match x.sig_desc with - | Tsig_value v -> - Tsig_value (sub.value_description sub v) - | Tsig_type (rec_flag, list) -> - let (rec_flag, list) = sub.type_declarations sub (rec_flag, list) in - Tsig_type (rec_flag, list) - | Tsig_typext te -> - Tsig_typext (sub.type_extension sub te) - | Tsig_exception ext -> - Tsig_exception (sub.extension_constructor sub ext) - | Tsig_module x -> - Tsig_module (sub.module_declaration sub x) - | Tsig_recmodule list -> - Tsig_recmodule (List.map (sub.module_declaration sub) list) - | Tsig_modtype x -> - Tsig_modtype (sub.module_type_declaration sub x) - | Tsig_include incl -> - Tsig_include (include_infos (sub.module_type sub) incl) - | Tsig_class list -> - Tsig_class (List.map (sub.class_description sub) list) - | Tsig_class_type list -> - Tsig_class_type - (List.map (sub.class_type_declaration sub) list) - | Tsig_open _ - | Tsig_attribute _ as d -> d - in - {x with sig_desc; sig_env} +let write_ast (type t) (kind : t kind) + (fname : string) + (pt : t) oc = + let magic = + match kind with + | Ml -> Config.ast_impl_magic_number + | Mli -> Config.ast_intf_magic_number in + output_string oc magic ; + output_value oc fname; + output_value oc pt +end +module Bs_hash_stubs += struct +#1 "bs_hash_stubs.ml" -let class_description sub x = - class_infos sub (sub.class_type sub) x + (* not suporting nested if here..*) +external hash_string : string -> int = "caml_bs_hash_string" [@@noalloc];; -let module_type sub x = - let mty_env = sub.env sub x.mty_env in - let mty_desc = - match x.mty_desc with - | Tmty_ident _ - | Tmty_alias _ as d -> d - | Tmty_signature sg -> Tmty_signature (sub.signature sub sg) - | Tmty_functor (id, s, mtype1, mtype2) -> - Tmty_functor ( - id, - s, - opt (sub.module_type sub) mtype1, - sub.module_type sub mtype2 - ) - | Tmty_with (mtype, list) -> - Tmty_with ( - sub.module_type sub mtype, - List.map (tuple3 id id (sub.with_constraint sub)) list - ) - | Tmty_typeof mexpr -> - Tmty_typeof (sub.module_expr sub mexpr) - in - {x with mty_desc; mty_env} +external hash_string_int : string -> int -> int = "caml_bs_hash_string_and_int" [@@noalloc];; -let with_constraint sub = function - | Twith_type decl -> Twith_type (sub.type_declaration sub decl) - | Twith_typesubst decl -> Twith_typesubst (sub.type_declaration sub decl) - | Twith_module _ - | Twith_modsubst _ as d -> d +external hash_string_small_int : string -> int -> int = "caml_bs_hash_string_and_small_int" [@@noalloc];; -let module_coercion sub = function - | Tcoerce_none -> Tcoerce_none - | Tcoerce_functor (c1,c2) -> - Tcoerce_functor (sub.module_coercion sub c1, sub.module_coercion sub c2) - | Tcoerce_alias (p, c1) -> - Tcoerce_alias (p, sub.module_coercion sub c1) - | Tcoerce_structure (l1, l2, runtime_fields) -> - let l1' = List.map (fun (i,c) -> i, sub.module_coercion sub c) l1 in - let l2' = - List.map (fun (id,i,c) -> id, i, sub.module_coercion sub c) l2 - in - Tcoerce_structure (l1', l2', runtime_fields) - | Tcoerce_primitive pc -> - Tcoerce_primitive {pc with pc_env = sub.env sub pc.pc_env} +external hash_stamp_and_name : int -> string -> int = "caml_bs_hash_stamp_and_name" [@@noalloc];; -let module_expr sub x = - let mod_env = sub.env sub x.mod_env in - let mod_desc = - match x.mod_desc with - | Tmod_ident _ as d -> d - | Tmod_structure st -> Tmod_structure (sub.structure sub st) - | Tmod_functor (id, s, mtype, mexpr) -> - Tmod_functor ( - id, - s, - opt (sub.module_type sub) mtype, - sub.module_expr sub mexpr - ) - | Tmod_apply (mexp1, mexp2, c) -> - Tmod_apply ( - sub.module_expr sub mexp1, - sub.module_expr sub mexp2, - sub.module_coercion sub c - ) - | Tmod_constraint (mexpr, mt, Tmodtype_implicit, c) -> - Tmod_constraint (sub.module_expr sub mexpr, mt, Tmodtype_implicit, - sub.module_coercion sub c) - | Tmod_constraint (mexpr, mt, Tmodtype_explicit mtype, c) -> - Tmod_constraint ( - sub.module_expr sub mexpr, - mt, - Tmodtype_explicit (sub.module_type sub mtype), - sub.module_coercion sub c - ) - | Tmod_unpack (exp, mty) -> - Tmod_unpack - ( - sub.expr sub exp, - mty - ) - in - {x with mod_desc; mod_env} +external hash_small_int : int -> int = "caml_bs_hash_small_int" [@@noalloc];; -let module_binding sub x = - let mb_expr = sub.module_expr sub x.mb_expr in - {x with mb_expr} +external hash_int : int -> int = "caml_bs_hash_int" [@@noalloc];; -let class_expr sub x = - let cl_env = sub.env sub x.cl_env in - let cl_desc = - match x.cl_desc with - | Tcl_constraint (cl, clty, vals, meths, concrs) -> - Tcl_constraint ( - sub.class_expr sub cl, - opt (sub.class_type sub) clty, - vals, - meths, - concrs - ) - | Tcl_structure clstr -> - Tcl_structure (sub.class_structure sub clstr) - | Tcl_fun (label, pat, priv, cl, partial) -> - Tcl_fun ( - label, - sub.pat sub pat, - List.map (tuple3 id id (sub.expr sub)) priv, - sub.class_expr sub cl, - partial - ) - | Tcl_apply (cl, args) -> - Tcl_apply ( - sub.class_expr sub cl, - List.map (tuple2 id (opt (sub.expr sub))) args - ) - | Tcl_let (rec_flag, value_bindings, ivars, cl) -> - let (rec_flag, value_bindings) = - sub.value_bindings sub (rec_flag, value_bindings) - in - Tcl_let ( - rec_flag, - value_bindings, - List.map (tuple3 id id (sub.expr sub)) ivars, - sub.class_expr sub cl - ) - | Tcl_ident (path, lid, tyl) -> - Tcl_ident (path, lid, List.map (sub.typ sub) tyl) - | Tcl_open (ovf, p, lid, env, e) -> - Tcl_open (ovf, p, lid, sub.env sub env, sub.class_expr sub e) - in - {x with cl_desc; cl_env} +external string_length_based_compare : string -> string -> int = "caml_string_length_based_compare" [@@noalloc];; -let class_type sub x = - let cltyp_env = sub.env sub x.cltyp_env in - let cltyp_desc = - match x.cltyp_desc with - | Tcty_signature csg -> Tcty_signature (sub.class_signature sub csg) - | Tcty_constr (path, lid, list) -> - Tcty_constr ( - path, - lid, - List.map (sub.typ sub) list - ) - | Tcty_arrow (label, ct, cl) -> - Tcty_arrow - (label, - sub.typ sub ct, - sub.class_type sub cl - ) - | Tcty_open (ovf, p, lid, env, e) -> - Tcty_open (ovf, p, lid, sub.env sub env, sub.class_type sub e) - in - {x with cltyp_desc; cltyp_env} -let class_signature sub x = - let csig_self = sub.typ sub x.csig_self in - let csig_fields = List.map (sub.class_type_field sub) x.csig_fields in - {x with csig_self; csig_fields} +external + int_unsafe_blit : + int array -> int -> int array -> int -> int -> unit = "caml_int_array_blit" [@@noalloc];; + + -let class_type_field sub x = - let ctf_desc = - match x.ctf_desc with - | Tctf_inherit ct -> - Tctf_inherit (sub.class_type sub ct) - | Tctf_val (s, mut, virt, ct) -> - Tctf_val (s, mut, virt, sub.typ sub ct) - | Tctf_method (s, priv, virt, ct) -> - Tctf_method (s, priv, virt, sub.typ sub ct) - | Tctf_constraint (ct1, ct2) -> - Tctf_constraint (sub.typ sub ct1, sub.typ sub ct2) - | Tctf_attribute _ as d -> d - in - {x with ctf_desc} +end +module Ext_util : sig +#1 "ext_util.mli" +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -let typ sub x = - let ctyp_env = sub.env sub x.ctyp_env in - let ctyp_desc = - match x.ctyp_desc with - | Ttyp_any - | Ttyp_var _ as d -> d - | Ttyp_arrow (label, ct1, ct2) -> - Ttyp_arrow (label, sub.typ sub ct1, sub.typ sub ct2) - | Ttyp_tuple list -> Ttyp_tuple (List.map (sub.typ sub) list) - | Ttyp_constr (path, lid, list) -> - Ttyp_constr (path, lid, List.map (sub.typ sub) list) - | Ttyp_object (list, closed) -> - Ttyp_object ((List.map (sub.object_field sub) list), closed) - | Ttyp_class (path, lid, list) -> - Ttyp_class - (path, - lid, - List.map (sub.typ sub) list - ) - | Ttyp_alias (ct, s) -> - Ttyp_alias (sub.typ sub ct, s) - | Ttyp_variant (list, closed, labels) -> - Ttyp_variant (List.map (sub.row_field sub) list, closed, labels) - | Ttyp_poly (sl, ct) -> - Ttyp_poly (sl, sub.typ sub ct) - | Ttyp_package pack -> - Ttyp_package (sub.package_type sub pack) - in - {x with ctyp_desc; ctyp_env} -let class_structure sub x = - let cstr_self = sub.pat sub x.cstr_self in - let cstr_fields = List.map (sub.class_field sub) x.cstr_fields in - {x with cstr_self; cstr_fields} + +val power_2_above : int -> int -> int -let row_field sub = function - | Ttag (label, attrs, b, list) -> - Ttag (label, attrs, b, List.map (sub.typ sub) list) - | Tinherit ct -> Tinherit (sub.typ sub ct) -let object_field sub = function - | OTtag (label, attrs, ct) -> - OTtag (label, attrs, (sub.typ sub ct)) - | OTinherit ct -> OTinherit (sub.typ sub ct) +val stats_to_string : Hashtbl.statistics -> string +end = struct +#1 "ext_util.ml" +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -let class_field_kind sub = function - | Tcfk_virtual ct -> Tcfk_virtual (sub.typ sub ct) - | Tcfk_concrete (ovf, e) -> Tcfk_concrete (ovf, sub.expr sub e) +(** + {[ + (power_2_above 16 63 = 64) + (power_2_above 16 76 = 128) + ]} +*) +let rec power_2_above x n = + if x >= n then x + else if x * 2 > Sys.max_array_length then x + else power_2_above (x * 2) n -let class_field sub x = - let cf_desc = - match x.cf_desc with - | Tcf_inherit (ovf, cl, super, vals, meths) -> - Tcf_inherit (ovf, sub.class_expr sub cl, super, vals, meths) - | Tcf_constraint (cty, cty') -> - Tcf_constraint ( - sub.typ sub cty, - sub.typ sub cty' - ) - | Tcf_val (s, mf, id, k, b) -> - Tcf_val (s, mf, id, class_field_kind sub k, b) - | Tcf_method (s, priv, k) -> - Tcf_method (s, priv, class_field_kind sub k) - | Tcf_initializer exp -> - Tcf_initializer (sub.expr sub exp) - | Tcf_attribute _ as d -> d - in - {x with cf_desc} -let value_bindings sub (rec_flag, list) = - (rec_flag, List.map (sub.value_binding sub) list) +let stats_to_string ({num_bindings; num_buckets; max_bucket_length; bucket_histogram} : Hashtbl.statistics) = + Printf.sprintf + "bindings: %d,buckets: %d, longest: %d, hist:[%s]" + num_bindings + num_buckets + max_bucket_length + (String.concat "," (Array.to_list (Array.map string_of_int bucket_histogram))) +end +module Hashtbl_gen += struct +#1 "hashtbl_gen.ml" +(***********************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. All rights reserved. This file is distributed *) +(* under the terms of the GNU Library General Public License, with *) +(* the special exception on linking described in file ../LICENSE. *) +(* *) +(***********************************************************************) -let cases sub l = - List.map (sub.case sub) l +(* Hash tables *) -let case sub {c_lhs; c_guard; c_rhs} = - { - c_lhs = sub.pat sub c_lhs; - c_guard = opt (sub.expr sub) c_guard; - c_rhs = sub.expr sub c_rhs; - } -let value_binding sub x = - let vb_pat = sub.pat sub x.vb_pat in - let vb_expr = sub.expr sub x.vb_expr in - {x with vb_pat; vb_expr} -let env _sub x = x +module type S = sig + type key + type 'a t + val create: int -> 'a t + val clear: 'a t -> unit + val reset: 'a t -> unit + val copy: 'a t -> 'a t + val add: 'a t -> key -> 'a -> unit + val modify_or_init: 'a t -> key -> ('a -> unit) -> (unit -> 'a) -> unit + val remove: 'a t -> key -> unit + val find_exn: 'a t -> key -> 'a + val find_all: 'a t -> key -> 'a list + val find_opt: 'a t -> key -> 'a option + + (** return the key found in the hashtbl. + Use case: when you find the key existed in hashtbl, + you want to use the one stored in the hashtbl. + (they are semantically equivlanent, but may have other information different) + *) + val find_key_opt: 'a t -> key -> key option -let default = - { - case; - cases; - class_declaration; - class_description; - class_expr; - class_field; - class_signature; - class_structure; - class_type; - class_type_declaration; - class_type_field; - env; - expr; - extension_constructor; - module_binding; - module_coercion; - module_declaration; - module_expr; - module_type; - module_type_declaration; - package_type; - pat; - row_field; - object_field; - signature; - signature_item; - structure; - structure_item; - typ; - type_declaration; - type_declarations; - type_extension; - type_kind; - value_binding; - value_bindings; - value_description; - with_constraint; - } + val find_default: 'a t -> key -> 'a -> 'a + val replace: 'a t -> key -> 'a -> unit + val mem: 'a t -> key -> bool + val iter: 'a t -> (key -> 'a -> unit) -> unit + val fold: (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b + val length: 'a t -> int + val stats: 'a t -> Hashtbl.statistics + val to_list : 'a t -> (key -> 'a -> 'c) -> 'c list + val of_list2: key list -> 'a list -> 'a t end -module Cmt_format : sig -#1 "cmt_format.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Fabrice Le Fessant, INRIA Saclay *) -(* *) -(* Copyright 2012 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) -(** cmt and cmti files format. *) +(* We do dynamic hashing, and resize the table and rehash the elements + when buckets become too long. *) -(** The layout of a cmt file is as follows: - := \{\} \{cmt infos\} \{\} - where is the cmi file format: - := . - More precisely, the optional part must be present if and only if - the file is: - - a cmti, or - - a cmt, for a ml file which has no corresponding mli (hence no - corresponding cmti). +type ('a, 'b) t = + { mutable size: int; (* number of entries *) + mutable data: ('a, 'b) bucketlist array; (* the buckets *) + mutable seed: int; (* for randomization *) + initial_size: int; (* initial array size *) + } - Thus, we provide a common reading function for cmi and cmt(i) - files which returns an option for each of the three parts: cmi - info, cmt info, source info. *) +and ('a, 'b) bucketlist = + | Empty + | Cons of 'a * 'b * ('a, 'b) bucketlist -open Typedtree -type binary_annots = - | Packed of Types.signature * string list - | Implementation of structure - | Interface of signature - | Partial_implementation of binary_part array - | Partial_interface of binary_part array +let create initial_size = + let s = Ext_util.power_2_above 16 initial_size in + { initial_size = s; size = 0; seed = 0; data = Array.make s Empty } -and binary_part = - | Partial_structure of structure - | Partial_structure_item of structure_item - | Partial_expression of expression - | Partial_pattern of pattern - | Partial_class_expr of class_expr - | Partial_signature of signature - | Partial_signature_item of signature_item - | Partial_module_type of module_type +let clear h = + h.size <- 0; + let len = Array.length h.data in + for i = 0 to len - 1 do + h.data.(i) <- Empty + done -type cmt_infos = { - cmt_modname : string; - cmt_annots : binary_annots; - cmt_value_dependencies : - (Types.value_description * Types.value_description) list; - cmt_comments : (string * Location.t) list; - cmt_args : string array; - cmt_sourcefile : string option; - cmt_builddir : string; - cmt_loadpath : string list; - cmt_source_digest : string option; - cmt_initial_env : Env.t; - cmt_imports : (string * Digest.t option) list; - cmt_interface_digest : Digest.t option; - cmt_use_summaries : bool; -} +let reset h = + h.size <- 0; + h.data <- Array.make h.initial_size Empty -type error = - Not_a_typedtree of string -exception Error of error +let copy h = { h with data = Array.copy h.data } -(** [read filename] opens filename, and extract both the cmi_infos, if - it exists, and the cmt_infos, if it exists. Thus, it can be used - with .cmi, .cmt and .cmti files. +let length h = h.size - .cmti files always contain a cmi_infos at the beginning. .cmt files - only contain a cmi_infos at the beginning if there is no associated - .cmti file. -*) -val read : string -> Cmi_format.cmi_infos option * cmt_infos option +let resize indexfun h = + let odata = h.data in + let osize = Array.length odata in + let nsize = osize * 2 in + if nsize < Sys.max_array_length then begin + let ndata = Array.make nsize Empty in + h.data <- ndata; (* so that indexfun sees the new bucket count *) + let rec insert_bucket = function + Empty -> () + | Cons(key, data, rest) -> + insert_bucket rest; (* preserve original order of elements *) + let nidx = indexfun h key in + ndata.(nidx) <- Cons(key, data, ndata.(nidx)) in + for i = 0 to osize - 1 do + insert_bucket (Array.unsafe_get odata i) + done + end -val read_cmt : string -> cmt_infos -val read_cmi : string -> Cmi_format.cmi_infos -(** [save_cmt filename modname binary_annots sourcefile initial_env cmi] - writes a cmt(i) file. *) -val save_cmt : - string -> (* filename.cmt to generate *) - string -> (* module name *) - binary_annots -> - string option -> (* source file *) - Env.t -> (* initial env *) - Cmi_format.cmi_infos option -> (* if a .cmi was generated *) - unit -(* Miscellaneous functions *) +let iter h f = + let rec do_bucket = function + | Empty -> + () + | Cons(k, d, rest) -> + f k d; do_bucket rest in + let d = h.data in + for i = 0 to Array.length d - 1 do + do_bucket (Array.unsafe_get d i) + done -val read_magic_number : in_channel -> string +let to_list h f = + let rec do_bucket bucket acc = + match bucket with + | Empty -> + acc + | Cons(k, d, rest) -> + do_bucket rest (f k d :: acc) in + let d = h.data in + let acc = ref [] in + for i = 0 to Array.length d - 1 do + acc := do_bucket (Array.unsafe_get d i) !acc + done; + !acc -val clear: unit -> unit +let fold f h init = + let rec do_bucket b accu = + match b with + Empty -> + accu + | Cons(k, d, rest) -> + do_bucket rest (f k d accu) in + let d = h.data in + let accu = ref init in + for i = 0 to Array.length d - 1 do + accu := do_bucket d.(i) !accu + done; + !accu -val add_saved_type : binary_part -> unit -val get_saved_types : unit -> binary_part list -val set_saved_types : binary_part list -> unit +let rec bucket_length accu = function + | Empty -> accu + | Cons(_, _, rest) -> bucket_length (accu + 1) rest -val record_value_dependency: - Types.value_description -> Types.value_description -> unit +let stats h = + let mbl = + Ext_array.fold_left h.data 0 (fun m b -> max m (bucket_length 0 b)) in + let histo = Array.make (mbl + 1) 0 in + Ext_array.iter h.data + (fun b -> + let l = bucket_length 0 b in + histo.(l) <- histo.(l) + 1) + ; + {Hashtbl. + num_bindings = h.size; + num_buckets = Array.length h.data; + max_bucket_length = mbl; + bucket_histogram = histo } -(* - val is_magic_number : string -> bool - val read : in_channel -> Env.cmi_infos option * t - val write_magic_number : out_channel -> unit - val write : out_channel -> t -> unit +let rec small_bucket_mem eq key (lst : _ bucketlist) = + match lst with + | Empty -> false + | Cons(k1,_,rest1) -> + eq key k1 || + match rest1 with + | Empty -> false + | Cons(k2,_,rest2) -> + eq key k2 || + match rest2 with + | Empty -> false + | Cons(k3,_,rest3) -> + eq key k3 || + small_bucket_mem eq key rest3 - val find : string list -> string -> string - val read_signature : 'a -> string -> Types.signature * 'b list * 'c list -*) +let rec small_bucket_opt eq key (lst : _ bucketlist) : _ option = + match lst with + | Empty -> None + | Cons(k1,d1,rest1) -> + if eq key k1 then Some d1 else + match rest1 with + | Empty -> None + | Cons(k2,d2,rest2) -> + if eq key k2 then Some d2 else + match rest2 with + | Empty -> None + | Cons(k3,d3,rest3) -> + if eq key k3 then Some d3 else + small_bucket_opt eq key rest3 -end = struct -#1 "cmt_format.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Fabrice Le Fessant, INRIA Saclay *) -(* *) -(* Copyright 2012 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) -open Cmi_format -open Typedtree +let rec small_bucket_key_opt eq key (lst : _ bucketlist) : _ option = + match lst with + | Empty -> None + | Cons(k1,d1,rest1) -> + if eq key k1 then Some k1 else + match rest1 with + | Empty -> None + | Cons(k2,d2,rest2) -> + if eq key k2 then Some k2 else + match rest2 with + | Empty -> None + | Cons(k3,d3,rest3) -> + if eq key k3 then Some k3 else + small_bucket_key_opt eq key rest3 -(* Note that in Typerex, there is an awful hack to save a cmt file - together with the interface file that was generated by ocaml (this - is because the installed version of ocaml might differ from the one - integrated in Typerex). -*) +let rec small_bucket_default eq key default (lst : _ bucketlist) = + match lst with + | Empty -> default + | Cons(k1,d1,rest1) -> + if eq key k1 then d1 else + match rest1 with + | Empty -> default + | Cons(k2,d2,rest2) -> + if eq key k2 then d2 else + match rest2 with + | Empty -> default + | Cons(k3,d3,rest3) -> + if eq key k3 then d3 else + small_bucket_default eq key default rest3 +end +module String_hashtbl : sig +#1 "string_hashtbl.mli" +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -let read_magic_number ic = - let len_magic_number = String.length Config.cmt_magic_number in - really_input_string ic len_magic_number -type binary_annots = - | Packed of Types.signature * string list - | Implementation of structure - | Interface of signature - | Partial_implementation of binary_part array - | Partial_interface of binary_part array +include Hashtbl_gen.S with type key = string -and binary_part = -| Partial_structure of structure -| Partial_structure_item of structure_item -| Partial_expression of expression -| Partial_pattern of pattern -| Partial_class_expr of class_expr -| Partial_signature of signature -| Partial_signature_item of signature_item -| Partial_module_type of module_type -type cmt_infos = { - cmt_modname : string; - cmt_annots : binary_annots; - cmt_value_dependencies : - (Types.value_description * Types.value_description) list; - cmt_comments : (string * Location.t) list; - cmt_args : string array; - cmt_sourcefile : string option; - cmt_builddir : string; - cmt_loadpath : string list; - cmt_source_digest : Digest.t option; - cmt_initial_env : Env.t; - cmt_imports : (string * Digest.t option) list; - cmt_interface_digest : Digest.t option; - cmt_use_summaries : bool; -} -type error = - Not_a_typedtree of string -let need_to_clear_env = - try ignore (Sys.getenv "OCAML_BINANNOT_WITHENV"); false - with Not_found -> true +end = struct +#1 "string_hashtbl.ml" +# 9 "ext/hashtbl.cppo.ml" +type key = string +type 'a t = (key, 'a) Hashtbl_gen.t +let key_index (h : _ t ) (key : key) = + (Bs_hash_stubs.hash_string key ) land (Array.length h.data - 1) +let eq_key = Ext_string.equal -let keep_only_summary = Env.keep_only_summary +# 33 "ext/hashtbl.cppo.ml" +type ('a, 'b) bucketlist = ('a,'b) Hashtbl_gen.bucketlist +let create = Hashtbl_gen.create +let clear = Hashtbl_gen.clear +let reset = Hashtbl_gen.reset +let copy = Hashtbl_gen.copy +let iter = Hashtbl_gen.iter +let to_list = Hashtbl_gen.to_list +let fold = Hashtbl_gen.fold +let length = Hashtbl_gen.length +let stats = Hashtbl_gen.stats -open Tast_mapper -let cenv = - {Tast_mapper.default with env = fun _sub env -> keep_only_summary env} -let clear_part = function - | Partial_structure s -> Partial_structure (cenv.structure cenv s) - | Partial_structure_item s -> - Partial_structure_item (cenv.structure_item cenv s) - | Partial_expression e -> Partial_expression (cenv.expr cenv e) - | Partial_pattern p -> Partial_pattern (cenv.pat cenv p) - | Partial_class_expr ce -> Partial_class_expr (cenv.class_expr cenv ce) - | Partial_signature s -> Partial_signature (cenv.signature cenv s) - | Partial_signature_item s -> - Partial_signature_item (cenv.signature_item cenv s) - | Partial_module_type s -> Partial_module_type (cenv.module_type cenv s) +let add (h : _ t) key info = + let i = key_index h key in + let h_data = h.data in + Array.unsafe_set h_data i (Cons(key, info, (Array.unsafe_get h_data i))); + h.size <- h.size + 1; + if h.size > Array.length h_data lsl 1 then Hashtbl_gen.resize key_index h -let clear_env binary_annots = - if need_to_clear_env then - match binary_annots with - | Implementation s -> Implementation (cenv.structure cenv s) - | Interface s -> Interface (cenv.signature cenv s) - | Packed _ -> binary_annots - | Partial_implementation array -> - Partial_implementation (Array.map clear_part array) - | Partial_interface array -> - Partial_interface (Array.map clear_part array) +(* after upgrade to 4.04 we should provide an efficient [replace_or_init] *) +let modify_or_init (h : _ t) key modf default = + let rec find_bucket (bucketlist : _ bucketlist) = + match bucketlist with + | Cons(k,i,next) -> + if eq_key k key then begin modf i; false end + else find_bucket next + | Empty -> true in + let i = key_index h key in + let h_data = h.data in + if find_bucket (Array.unsafe_get h_data i) then + begin + Array.unsafe_set h_data i (Cons(key,default (), Array.unsafe_get h_data i)); + h.size <- h.size + 1 ; + if h.size > Array.length h_data lsl 1 then Hashtbl_gen.resize key_index h + end - else binary_annots -exception Error of error +let rec remove_bucket key (h : _ t) (bucketlist : _ bucketlist) : _ bucketlist = + match bucketlist with + | Empty -> + Empty + | Cons(k, i, next) -> + if eq_key k key + then begin h.size <- h.size - 1; next end + else Cons(k, i, remove_bucket key h next) -let input_cmt ic = (input_value ic : cmt_infos) +let remove (h : _ t ) key = + let i = key_index h key in + let h_data = h.data in + let old_h_szie = h.size in + let new_bucket = remove_bucket key h (Array.unsafe_get h_data i) in + if old_h_szie <> h.size then + Array.unsafe_set h_data i new_bucket -let output_cmt oc cmt = - output_string oc Config.cmt_magic_number; - output_value oc (cmt : cmt_infos) +let rec find_rec key (bucketlist : _ bucketlist) = match bucketlist with + | Empty -> + raise Not_found + | Cons(k, d, rest) -> + if eq_key key k then d else find_rec key rest -let read filename = -(* Printf.fprintf stderr "Cmt_format.read %s\n%!" filename; *) - let ic = open_in_bin filename in - try - let magic_number = read_magic_number ic in - let cmi, cmt = - if magic_number = Config.cmt_magic_number then - None, Some (input_cmt ic) - else if magic_number = Config.cmi_magic_number then - let cmi = Cmi_format.input_cmi ic in - let cmt = try - let magic_number = read_magic_number ic in - if magic_number = Config.cmt_magic_number then - let cmt = input_cmt ic in - Some cmt - else None - with _ -> None - in - Some cmi, cmt - else - raise(Cmi_format.Error(Cmi_format.Not_an_interface filename)) - in - close_in ic; -(* Printf.fprintf stderr "Cmt_format.read done\n%!"; *) - cmi, cmt - with e -> - close_in ic; - raise e +let find_exn (h : _ t) key = + match Array.unsafe_get h.data (key_index h key) with + | Empty -> raise Not_found + | Cons(k1, d1, rest1) -> + if eq_key key k1 then d1 else + match rest1 with + | Empty -> raise Not_found + | Cons(k2, d2, rest2) -> + if eq_key key k2 then d2 else + match rest2 with + | Empty -> raise Not_found + | Cons(k3, d3, rest3) -> + if eq_key key k3 then d3 else find_rec key rest3 -let read_cmt filename = - match read filename with - _, None -> raise (Error (Not_a_typedtree filename)) - | _, Some cmt -> cmt +let find_opt (h : _ t) key = + Hashtbl_gen.small_bucket_opt eq_key key (Array.unsafe_get h.data (key_index h key)) -let read_cmi filename = - match read filename with - None, _ -> - raise (Cmi_format.Error (Cmi_format.Not_an_interface filename)) - | Some cmi, _ -> cmi +let find_key_opt (h : _ t) key = + Hashtbl_gen.small_bucket_key_opt eq_key key (Array.unsafe_get h.data (key_index h key)) + +let find_default (h : _ t) key default = + Hashtbl_gen.small_bucket_default eq_key key default (Array.unsafe_get h.data (key_index h key)) +let find_all (h : _ t) key = + let rec find_in_bucket (bucketlist : _ bucketlist) = match bucketlist with + | Empty -> + [] + | Cons(k, d, rest) -> + if eq_key k key + then d :: find_in_bucket rest + else find_in_bucket rest in + find_in_bucket (Array.unsafe_get h.data (key_index h key)) -let saved_types = ref [] -let value_deps = ref [] +let replace h key info = + let rec replace_bucket (bucketlist : _ bucketlist) : _ bucketlist = match bucketlist with + | Empty -> + raise_notrace Not_found + | Cons(k, i, next) -> + if eq_key k key + then Cons(key, info, next) + else Cons(k, i, replace_bucket next) in + let i = key_index h key in + let h_data = h.data in + let l = Array.unsafe_get h_data i in + try + Array.unsafe_set h_data i (replace_bucket l) + with Not_found -> + begin + Array.unsafe_set h_data i (Cons(key, info, l)); + h.size <- h.size + 1; + if h.size > Array.length h_data lsl 1 then Hashtbl_gen.resize key_index h; + end -let clear () = - saved_types := []; - value_deps := [] +let mem (h : _ t) key = + let rec mem_in_bucket (bucketlist : _ bucketlist) = match bucketlist with + | Empty -> + false + | Cons(k, d, rest) -> + eq_key k key || mem_in_bucket rest in + mem_in_bucket (Array.unsafe_get h.data (key_index h key)) -let add_saved_type b = saved_types := b :: !saved_types -let get_saved_types () = !saved_types -let set_saved_types l = saved_types := l -let record_value_dependency vd1 vd2 = - if vd1.Types.val_loc <> vd2.Types.val_loc then - value_deps := (vd1, vd2) :: !value_deps +let of_list2 ks vs = + let len = List.length ks in + let map = create len in + List.iter2 (fun k v -> add map k v) ks vs ; + map -let save_cmt filename modname binary_annots sourcefile initial_env cmi = - if !Clflags.binary_annotations && not !Clflags.print_types then begin - (if !Clflags.bs_only then Misc.output_to_bin_file_directly else - Misc.output_to_file_via_temporary - ~mode:[Open_binary] ) filename - (fun temp_file_name oc -> - let this_crc = - match cmi with - | None -> None - | Some cmi -> Some (output_cmi temp_file_name oc cmi) - in - let source_digest = Misc.may_map Digest.file sourcefile in - let cmt = { - cmt_modname = modname; - cmt_annots = clear_env binary_annots; - cmt_value_dependencies = !value_deps; - cmt_comments = Lexer.comments (); - cmt_args = Sys.argv; - cmt_sourcefile = sourcefile; - cmt_builddir = Sys.getcwd (); - cmt_loadpath = !Config.load_path; - cmt_source_digest = source_digest; - cmt_initial_env = if need_to_clear_env then - keep_only_summary initial_env else initial_env; - cmt_imports = List.sort compare (Env.imports ()); - cmt_interface_digest = this_crc; - cmt_use_summaries = need_to_clear_env; - } in - output_cmt oc cmt) - end; - clear () end -module Ctype : sig -#1 "ctype.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +module Map_gen += struct +#1 "map_gen.ml" +(***********************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. All rights reserved. This file is distributed *) +(* under the terms of the GNU Library General Public License, with *) +(* the special exception on linking described in file ../LICENSE. *) +(* *) +(***********************************************************************) +(** adapted from stdlib *) -(* Operations on core types *) +type ('key,'a) t = + | Empty + | Node of ('key,'a) t * 'key * 'a * ('key,'a) t * int -open Asttypes -open Types +type ('key,'a) enumeration = + | End + | More of 'key * 'a * ('key,'a) t * ('key, 'a) enumeration -exception Unify of (type_expr * type_expr) list -exception Tags of label * label -exception Subtype of - (type_expr * type_expr) list * (type_expr * type_expr) list -exception Cannot_expand -exception Cannot_apply -exception Recursive_abbrev -exception Unification_recursive_abbrev of (type_expr * type_expr) list +let rec cardinal_aux acc = function + | Empty -> acc + | Node (l,_,_,r, _) -> + cardinal_aux (cardinal_aux (acc + 1) r ) l -val init_def: int -> unit - (* Set the initial variable level *) -val begin_def: unit -> unit - (* Raise the variable level by one at the beginning of a definition. *) -val end_def: unit -> unit - (* Lower the variable level by one at the end of a definition *) -val begin_class_def: unit -> unit -val raise_nongen_level: unit -> unit -val reset_global_level: unit -> unit - (* Reset the global level before typing an expression *) -val increase_global_level: unit -> int -val restore_global_level: int -> unit - (* This pair of functions is only used in Typetexp *) -type levels = - { current_level: int; nongen_level: int; global_level: int; - saved_level: (int * int) list; } -val save_levels: unit -> levels -val set_levels: levels -> unit +let cardinal s = cardinal_aux 0 s -val newty: type_desc -> type_expr -val newvar: ?name:string -> unit -> type_expr -val newvar2: ?name:string -> int -> type_expr - (* Return a fresh variable *) -val new_global_var: ?name:string -> unit -> type_expr - (* Return a fresh variable, bound at toplevel - (as type variables ['a] in type constraints). *) -val newobj: type_expr -> type_expr -val newconstr: Path.t -> type_expr list -> type_expr -val none: type_expr - (* A dummy type expression *) +let rec bindings_aux accu = function + | Empty -> accu + | Node(l, v, d, r, _) -> bindings_aux ((v, d) :: bindings_aux accu r) l -val repr: type_expr -> type_expr - (* Return the canonical representative of a type. *) +let bindings s = + bindings_aux [] s -val object_fields: type_expr -> type_expr -val flatten_fields: - type_expr -> (string * field_kind * type_expr) list * type_expr - (* Transform a field type into a list of pairs label-type *) - (* The fields are sorted *) -val associate_fields: - (string * field_kind * type_expr) list -> - (string * field_kind * type_expr) list -> - (string * field_kind * type_expr * field_kind * type_expr) list * - (string * field_kind * type_expr) list * - (string * field_kind * type_expr) list -val opened_object: type_expr -> bool -val close_object: type_expr -> unit -val row_variable: type_expr -> type_expr - (* Return the row variable of an open object type *) -val set_object_name: - Ident.t -> type_expr -> type_expr list -> type_expr -> unit -val remove_object_name: type_expr -> unit -val hide_private_methods: type_expr -> unit -val find_cltype_for_path: Env.t -> Path.t -> type_declaration * type_expr -val lid_of_path: ?hash:string -> Path.t -> Longident.t + +let rec fill_array_aux (s : _ t) i arr : int = + match s with + | Empty -> i + | Node (l,k,v,r,_) -> + let inext = fill_array_aux l i arr in + Array.unsafe_set arr inext (k,v); + fill_array_aux r (inext + 1) arr -val sort_row_fields: (label * row_field) list -> (label * row_field) list -val merge_row_fields: - (label * row_field) list -> (label * row_field) list -> - (label * row_field) list * (label * row_field) list * - (label * row_field * row_field) list -val filter_row_fields: - bool -> (label * row_field) list -> (label * row_field) list +let to_sorted_array (s : ('key,'a) t) : ('key * 'a ) array = + match s with + | Empty -> [||] + | Node(l,k,v,r,_) -> + let len = + cardinal_aux (cardinal_aux 1 r) l in + let arr = + Array.make len (k,v) in + ignore (fill_array_aux s 0 arr : int); + arr +let rec keys_aux accu = function + Empty -> accu + | Node(l, v, _, r, _) -> keys_aux (v :: keys_aux accu r) l -val generalize: type_expr -> unit - (* Generalize in-place the given type *) -val generalize_expansive: Env.t -> type_expr -> unit - (* Generalize the covariant part of a type, making - contravariant branches non-generalizable *) -val generalize_global: type_expr -> unit - (* Generalize the structure of a type, lowering variables - to !global_level *) -val generalize_structure: type_expr -> unit - (* Same, but variables are only lowered to !current_level *) -val generalize_spine: type_expr -> unit - (* Special function to generalize a method during inference *) -val correct_levels: type_expr -> type_expr - (* Returns a copy with decreasing levels *) -val limited_generalize: type_expr -> type_expr -> unit - (* Only generalize some part of the type - Make the remaining of the type non-generalizable *) +let keys s = keys_aux [] s -val instance: ?partial:bool -> Env.t -> type_expr -> type_expr - (* Take an instance of a type scheme *) - (* partial=None -> normal - partial=false -> newvar() for non generic subterms - partial=true -> newty2 ty.level Tvar for non generic subterms *) -val instance_def: type_expr -> type_expr - (* use defaults *) -val generic_instance: Env.t -> type_expr -> type_expr - (* Same as instance, but new nodes at generic_level *) -val instance_list: Env.t -> type_expr list -> type_expr list - (* Take an instance of a list of type schemes *) -val instance_constructor: - ?in_pattern:Env.t ref * int -> - constructor_description -> type_expr list * type_expr - (* Same, for a constructor *) -val instance_parameterized_type: - ?keep_names:bool -> - type_expr list -> type_expr -> type_expr list * type_expr -val instance_parameterized_type_2: - type_expr list -> type_expr list -> type_expr -> - type_expr list * type_expr list * type_expr -val instance_declaration: type_declaration -> type_declaration -val instance_class: - type_expr list -> class_type -> type_expr list * class_type -val instance_poly: - ?keep_names:bool -> - bool -> type_expr list -> type_expr -> type_expr list * type_expr - (* Take an instance of a type scheme containing free univars *) -val instance_label: - bool -> label_description -> type_expr list * type_expr * type_expr - (* Same, for a label *) -val apply: - Env.t -> type_expr list -> type_expr -> type_expr list -> type_expr - (* [apply [p1...pN] t [a1...aN]] match the arguments [ai] to - the parameters [pi] and returns the corresponding instance of - [t]. Exception [Cannot_apply] is raised in case of failure. *) -val expand_head_once: Env.t -> type_expr -> type_expr -val expand_head: Env.t -> type_expr -> type_expr -val try_expand_once_opt: Env.t -> type_expr -> type_expr -val expand_head_opt: Env.t -> type_expr -> type_expr -(** The compiler's own version of [expand_head] necessary for type-based - optimisations. *) -val full_expand: Env.t -> type_expr -> type_expr -val extract_concrete_typedecl: - Env.t -> type_expr -> Path.t * Path.t * type_declaration - (* Return the original path of the types, and the first concrete - type declaration found expanding it. - Raise [Not_found] if none appears or not a type constructor. *) +let rec cons_enum m e = + match m with + Empty -> e + | Node(l, v, d, r, _) -> cons_enum l (More(v, d, r, e)) + + +let height = function + | Empty -> 0 + | Node(_,_,_,_,h) -> h -val enforce_constraints: Env.t -> type_expr -> unit +let create l x d r = + let hl = height l and hr = height r in + Node(l, x, d, r, (if hl >= hr then hl + 1 else hr + 1)) -val unify: Env.t -> type_expr -> type_expr -> unit - (* Unify the two types given. Raise [Unify] if not possible. *) -val unify_gadt: newtype_level:int -> Env.t ref -> type_expr -> type_expr -> unit - (* Unify the two types given and update the environment with the - local constraints. Raise [Unify] if not possible. *) -val unify_var: Env.t -> type_expr -> type_expr -> unit - (* Same as [unify], but allow free univars when first type - is a variable. *) -val with_passive_variants: ('a -> 'b) -> ('a -> 'b) - (* Call [f] in passive_variants mode, for exhaustiveness check. *) -val filter_arrow: Env.t -> type_expr -> arg_label -> type_expr * type_expr - (* A special case of unification (with l:'a -> 'b). *) -val filter_method: Env.t -> string -> private_flag -> type_expr -> type_expr - (* A special case of unification (with {m : 'a; 'b}). *) -val check_filter_method: Env.t -> string -> private_flag -> type_expr -> unit - (* A special case of unification (with {m : 'a; 'b}), returning unit. *) -val occur_in: Env.t -> type_expr -> type_expr -> bool -val deep_occur: type_expr -> type_expr -> bool -val filter_self_method: - Env.t -> string -> private_flag -> (Ident.t * type_expr) Meths.t ref -> - type_expr -> Ident.t * type_expr -val moregeneral: Env.t -> bool -> type_expr -> type_expr -> bool - (* Check if the first type scheme is more general than the second. *) +let singleton x d = Node(Empty, x, d, Empty, 1) -val rigidify: type_expr -> type_expr list - (* "Rigidify" a type and return its type variable *) -val all_distinct_vars: Env.t -> type_expr list -> bool - (* Check those types are all distinct type variables *) -val matches: Env.t -> type_expr -> type_expr -> bool - (* Same as [moregeneral false], implemented using the two above - functions and backtracking. Ignore levels *) +let bal l x d r = + let hl = match l with Empty -> 0 | Node(_,_,_,_,h) -> h in + let hr = match r with Empty -> 0 | Node(_,_,_,_,h) -> h in + if hl > hr + 2 then begin + match l with + Empty -> invalid_arg "Map.bal" + | Node(ll, lv, ld, lr, _) -> + if height ll >= height lr then + create ll lv ld (create lr x d r) + else begin + match lr with + Empty -> invalid_arg "Map.bal" + | Node(lrl, lrv, lrd, lrr, _)-> + create (create ll lv ld lrl) lrv lrd (create lrr x d r) + end + end else if hr > hl + 2 then begin + match r with + Empty -> invalid_arg "Map.bal" + | Node(rl, rv, rd, rr, _) -> + if height rr >= height rl then + create (create l x d rl) rv rd rr + else begin + match rl with + Empty -> invalid_arg "Map.bal" + | Node(rll, rlv, rld, rlr, _) -> + create (create l x d rll) rlv rld (create rlr rv rd rr) + end + end else + Node(l, x, d, r, (if hl >= hr then hl + 1 else hr + 1)) -type class_match_failure = - CM_Virtual_class - | CM_Parameter_arity_mismatch of int * int - | CM_Type_parameter_mismatch of Env.t * (type_expr * type_expr) list - | CM_Class_type_mismatch of Env.t * class_type * class_type - | CM_Parameter_mismatch of Env.t * (type_expr * type_expr) list - | CM_Val_type_mismatch of string * Env.t * (type_expr * type_expr) list - | CM_Meth_type_mismatch of string * Env.t * (type_expr * type_expr) list - | CM_Non_mutable_value of string - | CM_Non_concrete_value of string - | CM_Missing_value of string - | CM_Missing_method of string - | CM_Hide_public of string - | CM_Hide_virtual of string * string - | CM_Public_method of string - | CM_Private_method of string - | CM_Virtual_method of string -val match_class_types: - ?trace:bool -> Env.t -> class_type -> class_type -> class_match_failure list - (* Check if the first class type is more general than the second. *) -val equal: Env.t -> bool -> type_expr list -> type_expr list -> bool - (* [equal env [x1...xn] tau [y1...yn] sigma] - checks whether the parameterized types - [/\x1.../\xn.tau] and [/\y1.../\yn.sigma] are equivalent. *) -val match_class_declarations: - Env.t -> type_expr list -> class_type -> type_expr list -> - class_type -> class_match_failure list - (* Check if the first class type is more general than the second. *) +let empty = Empty -val enlarge_type: Env.t -> type_expr -> type_expr * bool - (* Make a type larger, flag is true if some pruning had to be done *) -val subtype: Env.t -> type_expr -> type_expr -> unit -> unit - (* [subtype env t1 t2] checks that [t1] is a subtype of [t2]. - It accumulates the constraints the type variables must - enforce and returns a function that enforces this - constraints. *) +let is_empty = function Empty -> true | _ -> false -val nondep_type: Env.t -> Ident.t -> type_expr -> type_expr - (* Return a type equivalent to the given type but without - references to the given module identifier. Raise [Not_found] - if no such type exists. *) -val nondep_type_decl: - Env.t -> Ident.t -> Ident.t -> bool -> type_declaration -> - type_declaration - (* Same for type declarations. *) -val nondep_extension_constructor: - Env.t -> Ident.t -> extension_constructor -> - extension_constructor - (* Same for extension constructor *) -val nondep_class_declaration: - Env.t -> Ident.t -> class_declaration -> class_declaration - (* Same for class declarations. *) -val nondep_cltype_declaration: - Env.t -> Ident.t -> class_type_declaration -> class_type_declaration - (* Same for class type declarations. *) -(*val correct_abbrev: Env.t -> Path.t -> type_expr list -> type_expr -> unit*) -val cyclic_abbrev: Env.t -> Ident.t -> type_expr -> bool -val is_contractive: Env.t -> Path.t -> bool -val normalize_type: Env.t -> type_expr -> unit +let rec min_binding_exn = function + Empty -> raise Not_found + | Node(Empty, x, d, r, _) -> (x, d) + | Node(l, x, d, r, _) -> min_binding_exn l -val closed_schema: Env.t -> type_expr -> bool - (* Check whether the given type scheme contains no non-generic - type variables *) +let choose = min_binding_exn -val free_variables: ?env:Env.t -> type_expr -> type_expr list - (* If env present, then check for incomplete definitions too *) -val closed_type_decl: type_declaration -> type_expr option -val closed_extension_constructor: extension_constructor -> type_expr option -type closed_class_failure = - CC_Method of type_expr * bool * string * type_expr - | CC_Value of type_expr * bool * string * type_expr -val closed_class: - type_expr list -> class_signature -> closed_class_failure option - (* Check whether all type variables are bound *) +let rec max_binding_exn = function + Empty -> raise Not_found + | Node(l, x, d, Empty, _) -> (x, d) + | Node(l, x, d, r, _) -> max_binding_exn r -val unalias: type_expr -> type_expr -val signature_of_class_type: class_type -> class_signature -val self_type: class_type -> type_expr -val class_type_arity: class_type -> int -val arity: type_expr -> int - (* Return the arity (as for curried functions) of the given type. *) +let rec remove_min_binding = function + Empty -> invalid_arg "Map.remove_min_elt" + | Node(Empty, x, d, r, _) -> r + | Node(l, x, d, r, _) -> bal (remove_min_binding l) x d r -val collapse_conj_params: Env.t -> type_expr list -> unit - (* Collapse conjunctive types in class parameters *) +let merge t1 t2 = + match (t1, t2) with + (Empty, t) -> t + | (t, Empty) -> t + | (_, _) -> + let (x, d) = min_binding_exn t2 in + bal t1 x d (remove_min_binding t2) -val get_current_level: unit -> int -val wrap_trace_gadt_instances: Env.t -> ('a -> 'b) -> 'a -> 'b -val reset_reified_var_counter: unit -> unit -val maybe_pointer_type : Env.t -> type_expr -> bool - (* True if type is possibly pointer, false if definitely not a pointer *) +let rec iter x f = match x with + Empty -> () + | Node(l, v, d, r, _) -> + iter l f; f v d; iter r f -(* Stubs *) -val package_subtype : - (Env.t -> Path.t -> Longident.t list -> type_expr list -> - Path.t -> Longident.t list -> type_expr list -> bool) ref +let rec map x f = match x with + Empty -> + Empty + | Node(l, v, d, r, h) -> + let l' = map l f in + let d' = f d in + let r' = map r f in + Node(l', v, d', r', h) -end = struct -#1 "ctype.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy and Jerome Vouillon, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let rec mapi x f = match x with + Empty -> + Empty + | Node(l, v, d, r, h) -> + let l' = mapi l f in + let d' = f v d in + let r' = mapi r f in + Node(l', v, d', r', h) -(* Operations on core types *) +let rec fold m accu f = + match m with + Empty -> accu + | Node(l, v, d, r, _) -> + fold r (f v d (fold l accu f)) f -open Misc -open Asttypes -open Types -open Btype +let rec for_all x p = match x with + Empty -> true + | Node(l, v, d, r, _) -> p v d && for_all l p && for_all r p -(* - Type manipulation after type inference - ====================================== - If one wants to manipulate a type after type inference (for - instance, during code generation or in the debugger), one must - first make sure that the type levels are correct, using the - function [correct_levels]. Then, this type can be correctly - manipulated by [apply], [expand_head] and [moregeneral]. -*) +let rec exists x p = match x with + Empty -> false + | Node(l, v, d, r, _) -> p v d || exists l p || exists r p -(* - General notes - ============= - - As much sharing as possible should be kept : it makes types - smaller and better abbreviated. - When necessary, some sharing can be lost. Types will still be - printed correctly (+++ TO DO...), and abbreviations defined by a - class do not depend on sharing thanks to constrained - abbreviations. (Of course, even if some sharing is lost, typing - will still be correct.) - - All nodes of a type have a level : that way, one know whether a - node need to be duplicated or not when instantiating a type. - - Levels of a type are decreasing (generic level being considered - as greatest). - - The level of a type constructor is superior to the binding - time of its path. - - Recursive types without limitation should be handled (even if - there is still an occur check). This avoid treating specially the - case for objects, for instance. Furthermore, the occur check - policy can then be easily changed. +(* Beware: those two functions assume that the added k is *strictly* + smaller (or bigger) than all the present keys in the tree; it + does not test for equality with the current min (or max) key. + + Indeed, they are only used during the "join" operation which + respects this precondition. *) -(**** Errors ****) +let rec add_min_binding k v = function + | Empty -> singleton k v + | Node (l, x, d, r, h) -> + bal (add_min_binding k v l) x d r -exception Unify of (type_expr * type_expr) list +let rec add_max_binding k v = function + | Empty -> singleton k v + | Node (l, x, d, r, h) -> + bal l x d (add_max_binding k v r) -exception Tags of label * label +(* Same as create and bal, but no assumptions are made on the + relative heights of l and r. *) -let () = - Location.register_error_of_exn - (function - | Tags (l, l') -> - Some - Location. - (errorf ~loc:(in_file !input_name) - "In this program,@ variant constructors@ `%s and `%s@ \ - have the same hash value.@ Change one of them." l l' - ) - | _ -> None - ) +let rec join l v d r = + match (l, r) with + (Empty, _) -> add_min_binding v d r + | (_, Empty) -> add_max_binding v d l + | (Node(ll, lv, ld, lr, lh), Node(rl, rv, rd, rr, rh)) -> + if lh > rh + 2 then bal ll lv ld (join lr v d r) else + if rh > lh + 2 then bal (join l v d rl) rv rd rr else + create l v d r -exception Subtype of - (type_expr * type_expr) list * (type_expr * type_expr) list +(* Merge two trees l and r into one. + All elements of l must precede the elements of r. + No assumption on the heights of l and r. *) -exception Cannot_expand +let concat t1 t2 = + match (t1, t2) with + (Empty, t) -> t + | (t, Empty) -> t + | (_, _) -> + let (x, d) = min_binding_exn t2 in + join t1 x d (remove_min_binding t2) -exception Cannot_apply +let concat_or_join t1 v d t2 = + match d with + | Some d -> join t1 v d t2 + | None -> concat t1 t2 -exception Recursive_abbrev +let rec filter x p = match x with + Empty -> Empty + | Node(l, v, d, r, _) -> + (* call [p] in the expected left-to-right order *) + let l' = filter l p in + let pvd = p v d in + let r' = filter r p in + if pvd then join l' v d r' else concat l' r' -(* GADT: recursive abbrevs can appear as a result of local constraints *) -exception Unification_recursive_abbrev of (type_expr * type_expr) list +let rec partition x p = match x with + Empty -> (Empty, Empty) + | Node(l, v, d, r, _) -> + (* call [p] in the expected left-to-right order *) + let (lt, lf) = partition l p in + let pvd = p v d in + let (rt, rf) = partition r p in + if pvd + then (join lt v d rt, concat lf rf) + else (concat lt rt, join lf v d rf) -(**** Type level management ****) +let compare compare_key cmp_val m1 m2 = + let rec compare_aux e1 e2 = + match (e1, e2) with + (End, End) -> 0 + | (End, _) -> -1 + | (_, End) -> 1 + | (More(v1, d1, r1, e1), More(v2, d2, r2, e2)) -> + let c = compare_key v1 v2 in + if c <> 0 then c else + let c = cmp_val d1 d2 in + if c <> 0 then c else + compare_aux (cons_enum r1 e1) (cons_enum r2 e2) + in compare_aux (cons_enum m1 End) (cons_enum m2 End) -let current_level = ref 0 -let nongen_level = ref 0 -let global_level = ref 1 -let saved_level = ref [] +let equal compare_key cmp m1 m2 = + let rec equal_aux e1 e2 = + match (e1, e2) with + (End, End) -> true + | (End, _) -> false + | (_, End) -> false + | (More(v1, d1, r1, e1), More(v2, d2, r2, e2)) -> + compare_key v1 v2 = 0 && cmp d1 d2 && + equal_aux (cons_enum r1 e1) (cons_enum r2 e2) + in equal_aux (cons_enum m1 End) (cons_enum m2 End) -type levels = - { current_level: int; nongen_level: int; global_level: int; - saved_level: (int * int) list; } -let save_levels () = - { current_level = !current_level; - nongen_level = !nongen_level; - global_level = !global_level; - saved_level = !saved_level } -let set_levels l = - current_level := l.current_level; - nongen_level := l.nongen_level; - global_level := l.global_level; - saved_level := l.saved_level -let get_current_level () = !current_level -let init_def level = current_level := level; nongen_level := level -let begin_def () = - saved_level := (!current_level, !nongen_level) :: !saved_level; - incr current_level; nongen_level := !current_level -let begin_class_def () = - saved_level := (!current_level, !nongen_level) :: !saved_level; - incr current_level -let raise_nongen_level () = - saved_level := (!current_level, !nongen_level) :: !saved_level; - nongen_level := !current_level -let end_def () = - let (cl, nl) = List.hd !saved_level in - saved_level := List.tl !saved_level; - current_level := cl; nongen_level := nl -let reset_global_level () = - global_level := !current_level + 1 -let increase_global_level () = - let gl = !global_level in - global_level := !current_level; - gl -let restore_global_level gl = - global_level := gl + +module type S = + sig + type key + type +'a t + val empty: 'a t + val compare_key: key -> key -> int + val is_empty: 'a t -> bool + val mem: 'a t -> key -> bool + val to_sorted_array : + 'a t -> (key * 'a ) array + val add: 'a t -> key -> 'a -> 'a t + (** [add x y m] + If [x] was already bound in [m], its previous binding disappears. *) + val adjust: 'a t -> key -> ('a option-> 'a) -> 'a t + (** [adjust acc k replace ] if not exist [add (replace None ], otherwise + [add k v (replace (Some old))] + *) + val singleton: key -> 'a -> 'a t -(**** Whether a path points to an object type (with hidden row variable) ****) -let is_object_type path = - let name = - match path with Path.Pident id -> Ident.name id - | Path.Pdot(_, s,_) -> s - | Path.Papply _ -> assert false - in name.[0] = '#' + val remove: 'a t -> key -> 'a t + (** [remove x m] returns a map containing the same bindings as + [m], except for [x] which is unbound in the returned map. *) -(**** Control tracing of GADT instances *) + val merge: + 'a t -> 'b t -> + (key -> 'a option -> 'b option -> 'c option) -> 'c t + (** [merge f m1 m2] computes a map whose keys is a subset of keys of [m1] + and of [m2]. The presence of each such binding, and the corresponding + value, is determined with the function [f]. + @since 3.12.0 + *) -let trace_gadt_instances = ref false -let check_trace_gadt_instances env = - not !trace_gadt_instances && Env.has_local_constraints env && - (trace_gadt_instances := true; cleanup_abbrev (); true) + val disjoint_merge : 'a t -> 'a t -> 'a t + (* merge two maps, will raise if they have the same key *) + val compare: 'a t -> 'a t -> ('a -> 'a -> int) -> int + (** Total ordering between maps. The first argument is a total ordering + used to compare data associated with equal keys in the two maps. *) -let reset_trace_gadt_instances b = - if b then trace_gadt_instances := false + val equal: 'a t -> 'a t -> ('a -> 'a -> bool) -> bool -let wrap_trace_gadt_instances env f x = - let b = check_trace_gadt_instances env in - let y = f x in - reset_trace_gadt_instances b; - y + val iter: 'a t -> (key -> 'a -> unit) -> unit + (** [iter f m] applies [f] to all bindings in map [m]. + The bindings are passed to [f] in increasing order. *) -(**** Abbreviations without parameters ****) -(* Shall reset after generalizing *) + val fold: 'a t -> 'b -> (key -> 'a -> 'b -> 'b) -> 'b + (** [fold f m a] computes [(f kN dN ... (f k1 d1 a)...)], + where [k1 ... kN] are the keys of all bindings in [m] + (in increasing order) *) -let simple_abbrevs = ref Mnil + val for_all: 'a t -> (key -> 'a -> bool) -> bool + (** [for_all p m] checks if all the bindings of the map. + order unspecified + *) -let proper_abbrevs path tl abbrev = - if tl <> [] || !trace_gadt_instances || !Clflags.principal || - is_object_type path - then abbrev - else simple_abbrevs + val exists: 'a t -> (key -> 'a -> bool) -> bool + (** [exists p m] checks if at least one binding of the map + satisfy the predicate [p]. + order unspecified + *) + + val filter: 'a t -> (key -> 'a -> bool) -> 'a t + (** [filter p m] returns the map with all the bindings in [m] + that satisfy predicate [p]. + order unspecified + *) + + val partition: 'a t -> (key -> 'a -> bool) -> 'a t * 'a t + (** [partition p m] returns a pair of maps [(m1, m2)], where + [m1] contains all the bindings of [s] that satisfy the + predicate [p], and [m2] is the map with all the bindings of + [s] that do not satisfy [p]. + *) + + val cardinal: 'a t -> int + (** Return the number of bindings of a map. *) + + val bindings: 'a t -> (key * 'a) list + (** Return the list of all bindings of the given map. + The returned list is sorted in increasing order with respect + to the ordering *) + val keys : 'a t -> key list + (* Increasing order *) -(**** Some type creators ****) + val min_binding_exn: 'a t -> (key * 'a) + (** raise [Not_found] if the map is empty. *) -(* Re-export generic type creators *) + val max_binding_exn: 'a t -> (key * 'a) + (** Same as {!Map.S.min_binding} *) -let newty2 = Btype.newty2 -let newty desc = newty2 !current_level desc + val choose: 'a t -> (key * 'a) + (** Return one binding of the given map, or raise [Not_found] if + the map is empty. Which binding is chosen is unspecified, + but equal bindings will be chosen for equal maps. + *) -let newvar ?name () = newty2 !current_level (Tvar name) -let newvar2 ?name level = newty2 level (Tvar name) -let new_global_var ?name () = newty2 !global_level (Tvar name) + val split: 'a t -> key -> 'a t * 'a option * 'a t + (** [split x m] returns a triple [(l, data, r)], where + [l] is the map with all the bindings of [m] whose key + is strictly less than [x]; + [r] is the map with all the bindings of [m] whose key + is strictly greater than [x]; + [data] is [None] if [m] contains no binding for [x], + or [Some v] if [m] binds [v] to [x]. + @since 3.12.0 + *) -let newobj fields = newty (Tobject (fields, ref None)) + val find_exn: 'a t -> key -> 'a + (** [find x m] returns the current binding of [x] in [m], + or raises [Not_found] if no such binding exists. *) + val find_opt: 'a t -> key ->'a option + val find_default: 'a t -> key -> 'a -> 'a + val map: 'a t -> ('a -> 'b) -> 'b t + (** [map f m] returns a map with same domain as [m], where the + associated value [a] of all bindings of [m] has been + replaced by the result of the application of [f] to [a]. + The bindings are passed to [f] in increasing order + with respect to the ordering over the type of the keys. *) -let newconstr path tyl = newty (Tconstr (path, tyl, ref Mnil)) + val mapi: 'a t -> (key -> 'a -> 'b) -> 'b t + (** Same as {!Map.S.map}, but the function receives as arguments both the + key and the associated value for each binding of the map. *) -let none = newty (Ttuple []) (* Clearly ill-formed type *) + val of_list : (key * 'a) list -> 'a t + val of_array : (key * 'a ) array -> 'a t + val add_list : (key * 'b) list -> 'b t -> 'b t -(**** Representative of a type ****) + end -(* Re-export repr *) -let repr = repr +end +module String_map : sig +#1 "string_map.mli" +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -(**** Type maps ****) -module TypePairs = - Hashtbl.Make (struct - type t = type_expr * type_expr - let equal (t1, t1') (t2, t2') = (t1 == t2) && (t1' == t2') - let hash (t, t') = t.id + 93 * t'.id - end) +include Map_gen.S with type key = string +end = struct +#1 "string_map.ml" -(**** unification mode ****) +# 2 "ext/map.cppo.ml" +(* we don't create [map_poly], since some operations require raise an exception which carries [key] *) -type unification_mode = - | Expression (* unification in expression *) - | Pattern (* unification in pattern which may add local constraints *) -let umode = ref Expression -let generate_equations = ref false -let assume_injective = ref false + +# 10 "ext/map.cppo.ml" + type key = string + let compare_key = Ext_string.compare -let set_mode_pattern ~generate ~injective f = - let old_unification_mode = !umode - and old_gen = !generate_equations - and old_inj = !assume_injective in - try - umode := Pattern; - generate_equations := generate; - assume_injective := injective; - let ret = f () in - umode := old_unification_mode; - generate_equations := old_gen; - assume_injective := old_inj; - ret - with e -> - umode := old_unification_mode; - generate_equations := old_gen; - assume_injective := old_inj; - raise e +# 22 "ext/map.cppo.ml" +type 'a t = (key,'a) Map_gen.t +exception Duplicate_key of key -(*** Checks for type definitions ***) +let empty = Map_gen.empty +let is_empty = Map_gen.is_empty +let iter = Map_gen.iter +let fold = Map_gen.fold +let for_all = Map_gen.for_all +let exists = Map_gen.exists +let singleton = Map_gen.singleton +let cardinal = Map_gen.cardinal +let bindings = Map_gen.bindings +let to_sorted_array = Map_gen.to_sorted_array +let keys = Map_gen.keys +let choose = Map_gen.choose +let partition = Map_gen.partition +let filter = Map_gen.filter +let map = Map_gen.map +let mapi = Map_gen.mapi +let bal = Map_gen.bal +let height = Map_gen.height +let max_binding_exn = Map_gen.max_binding_exn +let min_binding_exn = Map_gen.min_binding_exn -let in_current_module = function - | Path.Pident _ -> true - | Path.Pdot _ | Path.Papply _ -> false -let in_pervasives p = - in_current_module p && - try ignore (Env.find_type p Env.initial_safe_string); true - with Not_found -> false +let rec add (tree : _ Map_gen.t as 'a) x data : 'a = match tree with + | Empty -> + Node(Empty, x, data, Empty, 1) + | Node(l, v, d, r, h) -> + let c = compare_key x v in + if c = 0 then + Node(l, x, data, r, h) + else if c < 0 then + bal (add l x data ) v d r + else + bal l v d (add r x data ) -let is_datatype decl= - match decl.type_kind with - Type_record _ | Type_variant _ | Type_open -> true - | Type_abstract -> false +let rec adjust (tree : _ Map_gen.t as 'a) x replace : 'a = + match tree with + | Empty -> + Node(Empty, x, replace None, Empty, 1) + | Node(l, v, d, r, h) -> + let c = compare_key x v in + if c = 0 then + Node(l, x, replace (Some d) , r, h) + else if c < 0 then + bal (adjust l x replace ) v d r + else + bal l v d (adjust r x replace ) - (**********************************************) - (* Miscellaneous operations on object types *) - (**********************************************) -(* Note: - We need to maintain some invariants: - * cty_self must be a Tobject - * ... -*) +let rec find_exn (tree : _ Map_gen.t ) x = match tree with + | Empty -> + raise Not_found + | Node(l, v, d, r, _) -> + let c = compare_key x v in + if c = 0 then d + else find_exn (if c < 0 then l else r) x -(**** Object field manipulation. ****) +let rec find_opt (tree : _ Map_gen.t ) x = match tree with + | Empty -> None + | Node(l, v, d, r, _) -> + let c = compare_key x v in + if c = 0 then Some d + else find_opt (if c < 0 then l else r) x -let object_fields ty = - match (repr ty).desc with - Tobject (fields, _) -> fields - | _ -> assert false +let rec find_default (tree : _ Map_gen.t ) x default = match tree with + | Empty -> default + | Node(l, v, d, r, _) -> + let c = compare_key x v in + if c = 0 then d + else find_default (if c < 0 then l else r) x default -let flatten_fields ty = - let rec flatten l ty = - let ty = repr ty in - match ty.desc with - Tfield(s, k, ty1, ty2) -> - flatten ((s, k, ty1)::l) ty2 - | _ -> - (l, ty) - in - let (l, r) = flatten [] ty in - (List.sort (fun (n, _, _) (n', _, _) -> compare n n') l, r) +let rec mem (tree : _ Map_gen.t ) x= match tree with + | Empty -> + false + | Node(l, v, d, r, _) -> + let c = compare_key x v in + c = 0 || mem (if c < 0 then l else r) x -let build_fields level = - List.fold_right - (fun (s, k, ty1) ty2 -> newty2 level (Tfield(s, k, ty1, ty2))) +let rec remove (tree : _ Map_gen.t as 'a) x : 'a = match tree with + | Empty -> + Empty + | Node(l, v, d, r, h) -> + let c = compare_key x v in + if c = 0 then + Map_gen.merge l r + else if c < 0 then + bal (remove l x) v d r + else + bal l v d (remove r x ) -let associate_fields fields1 fields2 = - let rec associate p s s' = - function - (l, []) -> - (List.rev p, (List.rev s) @ l, List.rev s') - | ([], l') -> - (List.rev p, List.rev s, (List.rev s') @ l') - | ((n, k, t)::r, (n', k', t')::r') when n = n' -> - associate ((n, k, t, k', t')::p) s s' (r, r') - | ((n, k, t)::r, ((n', _k', _t')::_ as l')) when n < n' -> - associate p ((n, k, t)::s) s' (r, l') - | (((_n, _k, _t)::_ as l), (n', k', t')::r') (* when n > n' *) -> - associate p s ((n', k', t')::s') (l, r') - in - associate [] [] [] (fields1, fields2) -(**** Check whether an object is open ****) +let rec split (tree : _ Map_gen.t as 'a) x : 'a * _ option * 'a = match tree with + | Empty -> + (Empty, None, Empty) + | Node(l, v, d, r, _) -> + let c = compare_key x v in + if c = 0 then (l, Some d, r) + else if c < 0 then + let (ll, pres, rl) = split l x in (ll, pres, Map_gen.join rl v d r) + else + let (lr, pres, rr) = split r x in (Map_gen.join l v d lr, pres, rr) -(* +++ The abbreviation should eventually be expanded *) -let rec object_row ty = - let ty = repr ty in - match ty.desc with - Tobject (t, _) -> object_row t - | Tfield(_, _, _, t) -> object_row t - | _ -> ty +let rec merge (s1 : _ Map_gen.t) (s2 : _ Map_gen.t) f : _ Map_gen.t = + match (s1, s2) with + | (Empty, Empty) -> Empty + | (Node (l1, v1, d1, r1, h1), _) when h1 >= height s2 -> + let (l2, d2, r2) = split s2 v1 in + Map_gen.concat_or_join (merge l1 l2 f) v1 (f v1 (Some d1) d2) (merge r1 r2 f) + | (_, Node (l2, v2, d2, r2, h2)) -> + let (l1, d1, r1) = split s1 v2 in + Map_gen.concat_or_join (merge l1 l2 f) v2 (f v2 d1 (Some d2)) (merge r1 r2 f) + | _ -> + assert false -let opened_object ty = - match (object_row ty).desc with - | Tvar _ | Tunivar _ | Tconstr _ -> true - | _ -> false +let rec disjoint_merge (s1 : _ Map_gen.t) (s2 : _ Map_gen.t) : _ Map_gen.t = + match (s1, s2) with + | (Empty, Empty) -> Empty + | (Node (l1, v1, d1, r1, h1), _) when h1 >= height s2 -> + begin match split s2 v1 with + | l2, None, r2 -> + Map_gen.join (disjoint_merge l1 l2) v1 d1 (disjoint_merge r1 r2) + | _, Some _, _ -> + raise (Duplicate_key v1) + end + | (_, Node (l2, v2, d2, r2, h2)) -> + begin match split s1 v2 with + | (l1, None, r1) -> + Map_gen.join (disjoint_merge l1 l2) v2 d2 (disjoint_merge r1 r2) + | (_, Some _, _) -> + raise (Duplicate_key v2) + end + | _ -> + assert false -let concrete_object ty = - match (object_row ty).desc with - | Tvar _ -> false - | _ -> true -(**** Close an object ****) -let close_object ty = - let rec close ty = - let ty = repr ty in - match ty.desc with - Tvar _ -> - link_type ty (newty2 ty.level Tnil) - | Tfield(_, _, _, ty') -> close ty' - | _ -> assert false - in - match (repr ty).desc with - Tobject (ty, _) -> close ty - | _ -> assert false +let compare m1 m2 cmp = Map_gen.compare compare_key cmp m1 m2 -(**** Row variable of an object type ****) +let equal m1 m2 cmp = Map_gen.equal compare_key cmp m1 m2 -let row_variable ty = - let rec find ty = - let ty = repr ty in - match ty.desc with - Tfield (_, _, _, ty) -> find ty - | Tvar _ -> ty - | _ -> assert false - in - match (repr ty).desc with - Tobject (fi, _) -> find fi - | _ -> assert false +let add_list (xs : _ list ) init = + Ext_list.fold_left xs init (fun acc (k,v) -> add acc k v ) -(**** Object name manipulation ****) -(* +++ Bientot obsolete *) +let of_list xs = add_list xs empty -let set_object_name id rv params ty = - match (repr ty).desc with - Tobject (_fi, nm) -> - set_name nm (Some (Path.Pident id, rv::params)) - | _ -> - assert false +let of_array xs = + Ext_array.fold_left xs empty (fun acc (k,v) -> add acc k v ) -let remove_object_name ty = - match (repr ty).desc with - Tobject (_, nm) -> set_name nm None - | Tconstr (_, _, _) -> () - | _ -> fatal_error "Ctype.remove_object_name" +end +module Ast_extract : sig +#1 "ast_extract.mli" +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -(**** Hiding of private methods ****) -let hide_private_methods ty = - match (repr ty).desc with - Tobject (fi, nm) -> - nm := None; - let (fl, _) = flatten_fields fi in - List.iter - (function (_, k, _) -> - match field_kind_repr k with - Fvar r -> set_kind r Fabsent - | _ -> ()) - fl - | _ -> - assert false - (*******************************) - (* Operations on class types *) - (*******************************) -let rec signature_of_class_type = - function - Cty_constr (_, _, cty) -> signature_of_class_type cty - | Cty_signature sign -> sign - | Cty_arrow (_, _, cty) -> signature_of_class_type cty -let self_type cty = - repr (signature_of_class_type cty).csig_self -let rec class_type_arity = - function - Cty_constr (_, _, cty) -> class_type_arity cty - | Cty_signature _ -> 0 - | Cty_arrow (_, _, cty) -> 1 + class_type_arity cty +module String_set = Depend.StringSet - (*******************************************) - (* Miscellaneous operations on row types *) - (*******************************************) +val read_parse_and_extract : 'a Ml_binary.kind -> 'a -> String_set.t -let sort_row_fields = List.sort (fun (p,_) (q,_) -> compare p q) +type ('a,'b) t -let rec merge_rf r1 r2 pairs fi1 fi2 = - match fi1, fi2 with - (l1,f1 as p1)::fi1', (l2,f2 as p2)::fi2' -> - if l1 = l2 then merge_rf r1 r2 ((l1,f1,f2)::pairs) fi1' fi2' else - if l1 < l2 then merge_rf (p1::r1) r2 pairs fi1' fi2 else - merge_rf r1 (p2::r2) pairs fi1 fi2' - | [], _ -> (List.rev r1, List.rev_append r2 fi2, pairs) - | _, [] -> (List.rev_append r1 fi1, List.rev r2, pairs) +val sort_files_by_dependencies : + domain:String_set.t -> String_set.t String_map.t -> string Queue.t -let merge_row_fields fi1 fi2 = - match fi1, fi2 with - [], _ | _, [] -> (fi1, fi2, []) - | [p1], _ when not (List.mem_assoc (fst p1) fi2) -> (fi1, fi2, []) - | _, [p2] when not (List.mem_assoc (fst p2) fi1) -> (fi1, fi2, []) - | _ -> merge_rf [] [] [] (sort_row_fields fi1) (sort_row_fields fi2) -let rec filter_row_fields erase = function - [] -> [] - | (_l,f as p)::fi -> - let fi = filter_row_fields erase fi in - match row_field_repr f with - Rabsent -> fi - | Reither(_,_,false,e) when erase -> set_row_field e Rabsent; fi - | _ -> p :: fi +val sort : + ('a -> Parsetree.structure) -> + ('b -> Parsetree.signature) -> + ('a, 'b) t String_map.t -> string Queue.t - (**************************************) - (* Check genericity of type schemes *) - (**************************************) -exception Non_closed of type_expr * bool +(** + [build fmt files parse_implementation parse_interface] + Given a list of files return an ast table +*) +val collect_ast_map : + Format.formatter -> + string list -> + (Format.formatter -> string -> 'a) -> + (Format.formatter -> string -> 'b) -> + ('a, 'b) t String_map.t -let free_variables = ref [] -let really_closed = ref None +type dir_spec = + { dir : string ; + mutable excludes : string list + } -let rec free_vars_rec real ty = - let ty = repr ty in - if ty.level >= lowest_level then begin - ty.level <- pivot_level - ty.level; - begin match ty.desc, !really_closed with - Tvar _, _ -> - free_variables := (ty, real) :: !free_variables - | Tconstr (path, tl, _), Some env -> - begin try - let (_, body, _) = Env.find_type_expansion path env in - if (repr body).level <> generic_level then - free_variables := (ty, real) :: !free_variables - with Not_found -> () - end; - List.iter (free_vars_rec true) tl -(* Do not count "virtual" free variables - | Tobject(ty, {contents = Some (_, p)}) -> - free_vars_rec false ty; List.iter (free_vars_rec true) p +(** If the genereated queue is empty, it means + 1. The main module does not exist (does not exist due to typo) + 2. It does exist but not in search path + The order matters from head to tail *) - | Tobject (ty, _), _ -> - free_vars_rec false ty - | Tfield (_, _, ty1, ty2), _ -> - free_vars_rec true ty1; free_vars_rec false ty2 - | Tvariant row, _ -> - let row = row_repr row in - iter_row (free_vars_rec true) row; - if not (static_row row) then free_vars_rec false row.row_more - | _ -> - iter_type_expr (free_vars_rec true) ty - end; - end +val collect_from_main : + ?extra_dirs:dir_spec list -> + ?excludes : string list -> + ?alias_map: string String_hashtbl.t -> + Format.formatter -> + (Format.formatter -> string -> 'a) -> + (Format.formatter -> string -> 'b) -> + ('a -> Parsetree.structure) -> + ('b -> Parsetree.signature) -> + string -> ('a, 'b) t String_map.t * string Queue.t -let free_vars ?env ty = - free_variables := []; - really_closed := env; - free_vars_rec true ty; - let res = !free_variables in - free_variables := []; - really_closed := None; - res +val build_queue : + Format.formatter -> + string Queue.t -> + ('b, 'c) t String_map.t -> + (Format.formatter -> string -> string -> 'b -> unit) -> + (Format.formatter -> string -> string -> 'c -> unit) -> unit + +val handle_queue : + Format.formatter -> + string Queue.t -> + ('a, 'b) t String_map.t -> + (string -> string -> 'a -> unit) -> + (string -> string -> 'b -> unit) -> + (string -> string -> string -> 'b -> 'a -> unit) -> unit -let free_variables ?env ty = - let tl = List.map fst (free_vars ?env ty) in - unmark_type ty; - tl -let closed_type ty = - match free_vars ty with - [] -> () - | (v, real) :: _ -> raise (Non_closed (v, real)) +val build_lazy_queue : + Format.formatter -> + string Queue.t -> + (Parsetree.structure lazy_t, Parsetree.signature lazy_t) t String_map.t -> + (Format.formatter -> string -> string -> Parsetree.structure -> unit) -> + (Format.formatter -> string -> string -> Parsetree.signature -> unit) -> unit -let closed_parameterized_type params ty = - List.iter mark_type params; - let ok = - try closed_type ty; true with Non_closed _ -> false in - List.iter unmark_type params; - unmark_type ty; - ok -let closed_type_decl decl = - try - List.iter mark_type decl.type_params; - begin match decl.type_kind with - Type_abstract -> - () - | Type_variant v -> - List.iter - (fun {cd_args; cd_res; _} -> - match cd_res with - | Some _ -> () - | None -> - match cd_args with - | Cstr_tuple l -> List.iter closed_type l - | Cstr_record l -> List.iter (fun l -> closed_type l.ld_type) l - ) - v - | Type_record(r, _rep) -> - List.iter (fun l -> closed_type l.ld_type) r - | Type_open -> () - end; - begin match decl.type_manifest with - None -> () - | Some ty -> closed_type ty - end; - unmark_type_decl decl; - None - with Non_closed (ty, _) -> - unmark_type_decl decl; - Some ty -let closed_extension_constructor ext = - try - List.iter mark_type ext.ext_type_params; - begin match ext.ext_ret_type with - | Some _ -> () - | None -> iter_type_expr_cstr_args closed_type ext.ext_args - end; - unmark_extension_constructor ext; - None - with Non_closed (ty, _) -> - unmark_extension_constructor ext; - Some ty +end = struct +#1 "ast_extract.ml" +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -type closed_class_failure = - CC_Method of type_expr * bool * string * type_expr - | CC_Value of type_expr * bool * string * type_expr +type module_name = private string -exception CCFailure of closed_class_failure +module String_set = Depend.StringSet -let closed_class params sign = - let ty = object_fields (repr sign.csig_self) in - let (fields, rest) = flatten_fields ty in - List.iter mark_type params; - mark_type rest; - List.iter - (fun (lab, _, ty) -> if lab = dummy_method then mark_type ty) - fields; - try - mark_type_node (repr sign.csig_self); - List.iter - (fun (lab, kind, ty) -> - if field_kind_repr kind = Fpresent then - try closed_type ty with Non_closed (ty0, real) -> - raise (CCFailure (CC_Method (ty0, real, lab, ty)))) - fields; - mark_type_params (repr sign.csig_self); - List.iter unmark_type params; - unmark_class_signature sign; - None - with CCFailure reason -> - mark_type_params (repr sign.csig_self); - List.iter unmark_type params; - unmark_class_signature sign; - Some reason +(* FIXME: [Clflags.open_modules] seems not to be properly used *) + +module SMap = Depend.StringMap +let bound_vars = SMap.empty - (**********************) - (* Type duplication *) - (**********************) +type 'a kind = 'a Ml_binary.kind -(* Duplicate a type, preserving only type variables *) -let duplicate_type ty = - Subst.type_expr Subst.identity ty +let read_parse_and_extract (type t) (k : t kind) (ast : t) : String_set.t = + Depend.free_structure_names := String_set.empty; + Ext_ref.protect Clflags.transparent_modules false begin fun _ -> + List.iter (* check *) + (fun modname -> -(* Same, for class types *) -let duplicate_class_type ty = - Subst.class_type Subst.identity ty + ignore @@ + + Depend.open_module bound_vars (Longident.Lident modname)) + (!Clflags.open_modules); + (match k with + | Ml_binary.Ml -> Depend.add_implementation bound_vars ast + | Ml_binary.Mli -> Depend.add_signature bound_vars ast ); + !Depend.free_structure_names + end +type ('a,'b) ast_info = + | Ml of + string * (* sourcefile *) + 'a * + string (* opref *) + | Mli of string * (* sourcefile *) + 'b * + string (* opref *) + | Ml_mli of + string * (* sourcefile *) + 'a * + string * (* opref1 *) + string * (* sourcefile *) + 'b * + string (* opref2*) - (*****************************) - (* Type level manipulation *) - (*****************************) +type ('a,'b) t = + { module_name : string ; ast_info : ('a,'b) ast_info } -(* - It would be a bit more efficient to remove abbreviation expansions - rather than generalizing them: these expansions will usually not be - used anymore. However, this is not possible in the general case, as - [expand_abbrev] (via [subst]) requires these expansions to be - preserved. Does it worth duplicating this code ? -*) -let rec generalize ty = - let ty = repr ty in - if (ty.level > !current_level) && (ty.level <> generic_level) then begin - set_level ty generic_level; - begin match ty.desc with - Tconstr (_, _, abbrev) -> - iter_abbrev generalize !abbrev - | _ -> () - end; - iter_type_expr generalize ty - end -let generalize ty = - simple_abbrevs := Mnil; - generalize ty +(* only visit nodes that are currently in the domain *) +(* https://en.wikipedia.org/wiki/Topological_sorting *) +(* dfs *) +let sort_files_by_dependencies ~(domain : String_set.t) (dependency_graph : String_set.t String_map.t) : + string Queue.t = + let next current = + String_map.find_exn dependency_graph current in + let worklist = ref domain in + let result = Queue.create () in + let rec visit (visiting : String_set.t) path (current : string) = + let next_path = current :: path in + if String_set.mem current visiting then + Bs_exception.error (Bs_cyclic_depends next_path) + else if String_set.mem current !worklist then + begin + let next_set = String_set.add current visiting in + next current |> + String_set.iter + (fun node -> + if String_map.mem dependency_graph node then + visit next_set next_path node) + ; + worklist := String_set.remove current !worklist; + Queue.push current result ; + end in + while not (String_set.is_empty !worklist) do + visit String_set.empty [] (String_set.choose !worklist) + done; + if Js_config.get_diagnose () then + Format.fprintf Format.err_formatter + "Order: @[%a@]@." + (Ext_format.pp_print_queue + ~pp_sep:Format.pp_print_space + Format.pp_print_string) + result ; + result +;; -(* Generalize the structure and lower the variables *) -let rec generalize_structure var_level ty = - let ty = repr ty in - if ty.level <> generic_level then begin - if is_Tvar ty && ty.level > var_level then - set_level ty var_level - else if - ty.level > !current_level && - match ty.desc with - Tconstr (p, _, abbrev) -> - not (is_object_type p) && (abbrev := Mnil; true) - | _ -> true - then begin - set_level ty generic_level; - iter_type_expr (generalize_structure var_level) ty - end - end -let generalize_structure var_level ty = - simple_abbrevs := Mnil; - generalize_structure var_level ty +let sort project_ml project_mli (ast_table : _ t String_map.t) = + let domain = + String_map.fold ast_table String_set.empty + (fun k _ acc -> String_set.add k acc) + in + let h = + String_map.map ast_table + (fun + ({ast_info}) + -> + match ast_info with + | Ml (_, ast, _) + -> + read_parse_and_extract Ml (project_ml ast) + | Mli (_, ast, _) + -> + read_parse_and_extract Mli (project_mli ast) + | Ml_mli (_, impl, _, _, intf, _) + -> + String_set.union + (read_parse_and_extract Ml (project_ml impl)) + (read_parse_and_extract Mli (project_mli intf)) + ) in + sort_files_by_dependencies ~domain h -(* Generalize the spine of a function, if the level >= !current_level *) +(** same as {!Ocaml_parse.check_suffix} but does not care with [-c -o] option*) +let check_suffix name = + if Ext_path.check_suffix_case name ".ml" then + `Ml, + Ext_filename.chop_extension_maybe name + else if Ext_path.check_suffix_case name !Config.interface_suffix then + `Mli, Ext_filename.chop_extension_maybe name + else + raise(Arg.Bad("don't know what to do with " ^ name)) -let rec generalize_spine ty = - let ty = repr ty in - if ty.level < !current_level || ty.level = generic_level then () else - match ty.desc with - Tarrow (_, ty1, ty2, _) -> - set_level ty generic_level; - generalize_spine ty1; - generalize_spine ty2; - | Tpoly (ty', _) -> - set_level ty generic_level; - generalize_spine ty' - | Ttuple tyl - | Tpackage (_, _, tyl) -> - set_level ty generic_level; - List.iter generalize_spine tyl - | Tconstr (p, tyl, memo) when not (is_object_type p) -> - set_level ty generic_level; - memo := Mnil; - List.iter generalize_spine tyl - | _ -> () -let forward_try_expand_once = (* Forward declaration *) - ref (fun _env _ty -> raise Cannot_expand) +let collect_ast_map ppf files parse_implementation parse_interface = + Ext_list.fold_left files String_map.empty + (fun acc source_file -> + match check_suffix source_file with + | `Ml, opref -> + let module_name = Ext_filename.module_name source_file in + begin match String_map.find_exn acc module_name with + | exception Not_found -> + String_map.add acc module_name + {ast_info = + (Ml (source_file, parse_implementation + ppf source_file, opref)); + module_name ; + } + | {ast_info = (Ml (source_file2, _, _) + | Ml_mli(source_file2, _, _,_,_,_))} -> + Bs_exception.error + (Bs_duplicated_module (source_file, source_file2)) + | {ast_info = Mli (source_file2, intf, opref2)} + -> + String_map.add acc module_name + {ast_info = + Ml_mli (source_file, + parse_implementation ppf source_file, + opref, + source_file2, + intf, + opref2 + ); + module_name} + end + | `Mli, opref -> + let module_name = Ext_filename.module_name source_file in + begin match String_map.find_exn acc module_name with + | exception Not_found -> + String_map.add acc module_name + {ast_info = (Mli (source_file, parse_interface + ppf source_file, opref)); + module_name } + | {ast_info = + (Mli (source_file2, _, _) | + Ml_mli(_,_,_,source_file2,_,_)) } -> + Bs_exception.error + (Bs_duplicated_module (source_file, source_file2)) + | {ast_info = Ml (source_file2, impl, opref2)} + -> + String_map.add acc module_name + {ast_info = + Ml_mli + (source_file2, + impl, + opref2, + source_file, + parse_interface ppf source_file, + opref + ); + module_name} + end + ) +;; +type dir_spec = + { dir : string ; + mutable excludes : string list + } -(* - Lower the levels of a type (assume [level] is not - [generic_level]). -*) -(* - The level of a type constructor must be greater than its binding - time. That way, a type constructor cannot escape the scope of its - definition, as would be the case in - let x = ref [] - module M = struct type t let _ = (x : t list ref) end - (without this constraint, the type system would actually be unsound.) -*) -let get_level env p = - try - match (Env.find_type p env).type_newtype_level with - | None -> Path.binding_time p - | Some (x, _) -> x - with - | Not_found -> - (* no newtypes in predef *) - Path.binding_time p +let collect_from_main + ?(extra_dirs=[]) + ?(excludes=[]) + ?alias_map + (ppf : Format.formatter) + parse_implementation + parse_interface + project_impl + project_intf + main_module = + let files = + Ext_list.fold_left extra_dirs [] (fun acc dir_spec -> + let dirname, excludes = + match dir_spec with + | { dir = dirname; excludes = dir_excludes} -> + (* dirname, excludes *) + (* | `Dir_with_excludes (dirname, dir_excludes) -> *) + dirname, + (Ext_list.flat_map_append + dir_excludes excludes + (fun x -> [x ^ ".ml" ; x ^ ".mli" ]) + ) + in + Ext_array.fold_left (Sys.readdir dirname) acc (fun acc source_file -> + if (Ext_string.ends_with source_file ".ml" || + Ext_string.ends_with source_file ".mli" ) + && (* not_excluded source_file *) (not (Ext_list.mem_string excludes source_file )) + then + (Filename.concat dirname source_file) :: acc else acc + ) ) + in + let ast_table = collect_ast_map ppf files parse_implementation parse_interface in + let visited = String_hashtbl.create 31 in + let result = Queue.create () in + let next module_name : String_set.t = + let module_set = + match String_map.find_exn ast_table module_name with + | exception _ -> String_set.empty + | {ast_info = Ml (_, impl, _)} -> + read_parse_and_extract Ml (project_impl impl) + | {ast_info = Mli (_, intf,_)} -> + read_parse_and_extract Mli (project_intf intf) + | {ast_info = Ml_mli(_, impl, _, _, intf, _)} + -> + String_set.union + (read_parse_and_extract Ml (project_impl impl)) + (read_parse_and_extract Mli (project_intf intf)) + in + match alias_map with + | None -> module_set + | Some map -> + String_set.fold (fun x acc -> String_set.add (String_hashtbl.find_default map x x) acc ) module_set String_set.empty + in + let rec visit visiting path current = + if String_set.mem current visiting then + Bs_exception.error (Bs_cyclic_depends (current::path)) + else + if not (String_hashtbl.mem visited current) + && String_map.mem ast_table current then + begin + String_set.iter + (visit + (String_set.add current visiting) + (current::path)) + (next current) ; + Queue.push current result; + String_hashtbl.add visited current (); + end in + visit (String_set.empty) [] main_module ; + ast_table, result + + +let build_queue ppf queue + (ast_table : _ t String_map.t) + after_parsing_impl + after_parsing_sig + = + queue + |> Queue.iter + (fun modname -> + match String_map.find_exn ast_table modname with + | {ast_info = Ml(source_file,ast, opref)} + -> + after_parsing_impl ppf source_file + opref ast + | {ast_info = Mli (source_file,ast,opref) ; } + -> + after_parsing_sig ppf source_file + opref ast + | {ast_info = Ml_mli(source_file1,impl,opref1,source_file2,intf,opref2)} + -> + after_parsing_sig ppf source_file1 opref1 intf ; + after_parsing_impl ppf source_file2 opref2 impl + | exception Not_found -> assert false + ) + + +let handle_queue + ppf + queue ast_table + decorate_module_only + decorate_interface_only + decorate_module = + queue + |> Queue.iter + (fun base -> + match (String_map.find_exn ast_table base ).ast_info with + | exception Not_found -> assert false + | Ml (ml_name, ml_content, _) + -> + decorate_module_only base ml_name ml_content + | Mli (mli_name , mli_content, _) -> + decorate_interface_only base mli_name mli_content + | Ml_mli (ml_name, ml_content, _, mli_name, mli_content, _) + -> + decorate_module base mli_name ml_name mli_content ml_content -let rec normalize_package_path env p = - let t = - try (Env.find_modtype p env).mtd_type - with Not_found -> None - in - match t with - | Some (Mty_ident p) -> normalize_package_path env p - | Some (Mty_signature _ | Mty_functor _ | Mty_alias _) | None -> - match p with - Path.Pdot (p1, s, n) -> - (* For module aliases *) - let p1' = Env.normalize_path None env p1 in - if Path.same p1 p1' then p else - normalize_package_path env (Path.Pdot (p1', s, n)) - | _ -> p + ) -let rec update_level env level expand ty = - let ty = repr ty in - if ty.level > level then begin - begin match Env.gadt_instance_level env ty with - Some lv -> if level < lv then raise (Unify [(ty, newvar2 level)]) - | None -> () - end; - match ty.desc with - Tconstr(p, _tl, _abbrev) when level < get_level env p -> - (* Try first to replace an abbreviation by its expansion. *) - begin try - (* if is_newtype env p then raise Cannot_expand; *) - link_type ty (!forward_try_expand_once env ty); - update_level env level expand ty - with Cannot_expand -> - (* +++ Levels should be restored... *) - (* Format.printf "update_level: %i < %i@." level (get_level env p); *) - if level < get_level env p then raise (Unify [(ty, newvar2 level)]); - iter_type_expr (update_level env level expand) ty - end - | Tconstr(_, _ :: _, _) when expand -> - begin try - link_type ty (!forward_try_expand_once env ty); - update_level env level expand ty - with Cannot_expand -> - set_level ty level; - iter_type_expr (update_level env level expand) ty - end - | Tpackage (p, nl, tl) when level < Path.binding_time p -> - let p' = normalize_package_path env p in - if Path.same p p' then raise (Unify [(ty, newvar2 level)]); - log_type ty; ty.desc <- Tpackage (p', nl, tl); - update_level env level expand ty - | Tobject(_, ({contents=Some(p, _tl)} as nm)) - when level < get_level env p -> - set_name nm None; - update_level env level expand ty - | Tvariant row -> - let row = row_repr row in - begin match row.row_name with - | Some (p, _tl) when level < get_level env p -> - log_type ty; - ty.desc <- Tvariant {row with row_name = None} - | _ -> () - end; - set_level ty level; - iter_type_expr (update_level env level expand) ty - | Tfield(lab, _, ty1, _) - when lab = dummy_method && (repr ty1).level > level -> - raise (Unify [(ty1, newvar2 level)]) - | _ -> - set_level ty level; - (* XXX what about abbreviations in Tconstr ? *) - iter_type_expr (update_level env level expand) ty - end -(* First try without expanding, then expand everything, - to avoid combinatorial blow-up *) -let update_level env level ty = - let ty = repr ty in - if ty.level > level then begin - let snap = snapshot () in - try - update_level env level false ty - with Unify _ -> - backtrack snap; - update_level env level true ty - end -(* Generalize and lower levels of contravariant branches simultaneously *) +let build_lazy_queue ppf queue (ast_table : _ t String_map.t) + after_parsing_impl + after_parsing_sig + = + queue |> Queue.iter (fun modname -> + match String_map.find_exn ast_table modname with + | {ast_info = Ml(source_file,lazy ast, opref)} + -> + after_parsing_impl ppf source_file opref ast + | {ast_info = Mli (source_file,lazy ast,opref) ; } + -> + after_parsing_sig ppf source_file opref ast + | {ast_info = Ml_mli(source_file1,lazy impl,opref1,source_file2,lazy intf,opref2)} + -> + after_parsing_sig ppf source_file1 opref1 intf ; + after_parsing_impl ppf source_file2 opref2 impl + | exception Not_found -> assert false + ) -let rec generalize_expansive env var_level visited ty = - let ty = repr ty in - if ty.level = generic_level || ty.level <= var_level then () else - if not (Hashtbl.mem visited ty.id) then begin - Hashtbl.add visited ty.id (); - match ty.desc with - Tconstr (path, tyl, abbrev) -> - let variance = - try (Env.find_type path env).type_variance - with Not_found -> List.map (fun _ -> Variance.may_inv) tyl in - abbrev := Mnil; - List.iter2 - (fun v t -> - if Variance.(mem May_weak v) - then generalize_structure var_level t - else generalize_expansive env var_level visited t) - variance tyl - | Tpackage (_, _, tyl) -> - List.iter (generalize_structure var_level) tyl - | Tarrow (_, t1, t2, _) -> - generalize_structure var_level t1; - generalize_expansive env var_level visited t2 - | _ -> - iter_type_expr (generalize_expansive env var_level visited) ty - end -let generalize_expansive env ty = - simple_abbrevs := Mnil; - try - generalize_expansive env !nongen_level (Hashtbl.create 7) ty - with Unify ([_, ty'] as tr) -> - raise (Unify ((ty, ty') :: tr)) +end +module Binary_ast : sig +#1 "binary_ast.mli" +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -let generalize_global ty = generalize_structure !global_level ty -let generalize_structure ty = generalize_structure !current_level ty -(* Correct the levels of type [ty]. *) -let correct_levels ty = - duplicate_type ty +val read_ast : 'a Ml_binary.kind -> string -> 'a -(* Only generalize the type ty0 in ty *) -let limited_generalize ty0 ty = - let ty0 = repr ty0 in - let graph = Hashtbl.create 17 in - let idx = ref lowest_level in - let roots = ref [] in +val magic_sep_char : char - let rec inverse pty ty = - let ty = repr ty in - if (ty.level > !current_level) || (ty.level = generic_level) then begin - decr idx; - Hashtbl.add graph !idx (ty, ref pty); - if (ty.level = generic_level) || (ty == ty0) then - roots := ty :: !roots; - set_level ty !idx; - iter_type_expr (inverse [ty]) ty - end else if ty.level < lowest_level then begin - let (_, parents) = Hashtbl.find graph ty.level in - parents := pty @ !parents - end +(** + Check out {!Bsb_depfile_gen} for set decoding + The [.ml] file can be recognized as an ast directly, the format + is + { + magic number; + filename; + ast + } + when [fname] is "-" it means the file is from an standard input or pipe. + An empty name would marshallized. - and generalize_parents ty = - let idx = ty.level in - if idx <> generic_level then begin - set_level ty generic_level; - List.iter generalize_parents !(snd (Hashtbl.find graph idx)); - (* Special case for rows: must generalize the row variable *) - match ty.desc with - Tvariant row -> - let more = row_more row in - let lv = more.level in - if (lv < lowest_level || lv > !current_level) - && lv <> generic_level then set_level more generic_level - | _ -> () - end - in + Use case cat - | fan -printer -impl - + redirect the standard input to fan + *) +val write_ast : sourcefile:string -> output:string -> 'a Ml_binary.kind -> 'a -> unit - inverse [] ty; - if ty0.level < lowest_level then - iter_type_expr (inverse []) ty0; - List.iter generalize_parents !roots; - Hashtbl.iter - (fun _ (ty, _) -> - if ty.level <> generic_level then set_level ty !current_level) - graph +end = struct +#1 "binary_ast.ml" -(* Compute statically the free univars of all nodes in a type *) -(* This avoids doing it repeatedly during instantiation *) +(* Copyright (C) 2015-2016 Bloomberg Finance L.P. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * In addition to the permissions granted to you by the LGPL, you may combine + * or link a "work that uses the Library" with a publicly distributed version + * of this file to produce a combined library or application, then distribute + * that combined work under the terms of your choosing, with no requirement + * to comply with the obligations normally placed on you by section 4 of the + * LGPL version 3 (or the corresponding section of a later version of the LGPL + * should you choose to use a later version). + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -type inv_type_expr = - { inv_type : type_expr; - mutable inv_parents : inv_type_expr list } + (** Synced up with module {!Bsb_helper_depfile_gen} *) +module String_set = Ast_extract.String_set -let rec inv_type hash pty ty = - let ty = repr ty in + + +let read_ast (type t ) (kind : t Ml_binary.kind) fn : t = + let ic = open_in_bin fn in try - let inv = TypeHash.find hash ty in - inv.inv_parents <- pty @ inv.inv_parents - with Not_found -> - let inv = { inv_type = ty; inv_parents = pty } in - TypeHash.add hash ty inv; - iter_type_expr (inv_type hash [inv]) ty + let dep_size = input_binary_int ic in + seek_in ic (pos_in ic + dep_size) ; + let ast = Ml_binary.read_ast kind ic in + close_in ic; + ast + with exn -> + close_in ic; + raise exn -let compute_univars ty = - let inverted = TypeHash.create 17 in - inv_type inverted [] ty; - let node_univars = TypeHash.create 17 in - let rec add_univar univ inv = - match inv.inv_type.desc with - Tpoly (_ty, tl) when List.memq univ (List.map repr tl) -> () - | _ -> - try - let univs = TypeHash.find node_univars inv.inv_type in - if not (TypeSet.mem univ !univs) then begin - univs := TypeSet.add univ !univs; - List.iter (add_univar univ) inv.inv_parents - end - with Not_found -> - TypeHash.add node_univars inv.inv_type (ref(TypeSet.singleton univ)); - List.iter (add_univar univ) inv.inv_parents - in - TypeHash.iter (fun ty inv -> if is_Tunivar ty then add_univar ty inv) - inverted; - fun ty -> - try !(TypeHash.find node_univars ty) with Not_found -> TypeSet.empty +let magic_sep_char = '\n' +(* + Reasons that we don't [output_value] the set: + 1. for performance , easy skipping and calcuate the length + 2. cut dependency, otherwise its type is {!Ast_extract.String_set.t} +*) +let write_ast (type t) ~(sourcefile : string) ~output (kind : t Ml_binary.kind) ( pt : t) : unit = + let oc = open_out_bin output in + let output_set = Ast_extract.read_parse_and_extract kind pt in + let buf = Ext_buffer.create 1000 in + Ext_buffer.add_char buf magic_sep_char; + String_set.iter (fun s -> + if s <> "" && s.[0] <> '*' then begin (* filter *predef* *) + Ext_buffer.add_string_char buf s magic_sep_char; + end + ) output_set ; + output_binary_int oc (Ext_buffer.length buf); + Ext_buffer.output_buffer oc buf; + Ml_binary.write_ast kind sourcefile pt oc; + close_out oc - (*******************) - (* Instantiation *) - (*******************) +end +(** Interface as module *) +module Annot += struct +#1 "annot.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Damien Doligez, projet Gallium, INRIA Rocquencourt *) +(* *) +(* Copyright 2007 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -let rec find_repr p1 = - function - Mnil -> - None - | Mcons (Public, p2, ty, _, _) when Path.same p1 p2 -> - Some ty - | Mcons (_, _, _, _, rem) -> - find_repr p1 rem - | Mlink {contents = rem} -> - find_repr p1 rem +(* Data types for annotations (Stypes.ml) *) -(* - Generic nodes are duplicated, while non-generic nodes are left - as-is. - During instantiation, the description of a generic node is first - replaced by a link to a stub ([Tsubst (newvar ())]). Once the - copy is made, it replaces the stub. - After instantiation, the description of generic node, which was - stored by [save_desc], must be put back, using [cleanup_types]. -*) +type call = Tail | Stack | Inline;; -let abbreviations = ref (ref Mnil) - (* Abbreviation memorized. *) +type ident = + | Iref_internal of Location.t (* defining occurrence *) + | Iref_external + | Idef of Location.t (* scope *) +;; -(* partial: we may not wish to copy the non generic types - before we call type_pat *) -let rec copy ?env ?partial ?keep_names ty = - let copy = copy ?env ?partial ?keep_names in - let ty = repr ty in - match ty.desc with - Tsubst ty -> ty - | _ -> - if ty.level <> generic_level && partial = None then ty else - (* We only forget types that are non generic and do not contain - free univars *) - let forget = - if ty.level = generic_level then generic_level else - match partial with - None -> assert false - | Some (free_univars, keep) -> - if TypeSet.is_empty (free_univars ty) then - if keep then ty.level else !current_level - else generic_level - in - if forget <> generic_level then newty2 forget (Tvar None) else - let desc = ty.desc in - save_desc ty desc; - let t = newvar() in (* Stub *) - begin match env with - Some env when Env.has_local_constraints env -> - begin match Env.gadt_instance_level env ty with - Some lv -> Env.add_gadt_instances env lv [t] - | None -> () - end - | _ -> () - end; - ty.desc <- Tsubst t; - t.desc <- - begin match desc with - | Tconstr (p, tl, _) -> - let abbrevs = proper_abbrevs p tl !abbreviations in - begin match find_repr p !abbrevs with - Some ty when repr ty != t -> - Tlink ty - | _ -> - (* - One must allocate a new reference, so that abbrevia- - tions belonging to different branches of a type are - independent. - Moreover, a reference containing a [Mcons] must be - shared, so that the memorized expansion of an abbrevi- - ation can be released by changing the content of just - one reference. - *) - Tconstr (p, List.map copy tl, - ref (match !(!abbreviations) with - Mcons _ -> Mlink !abbreviations - | abbrev -> abbrev)) - end - | Tvariant row0 -> - let row = row_repr row0 in - let more = repr row.row_more in - (* We must substitute in a subtle way *) - (* Tsubst takes a tuple containing the row var and the variant *) - begin match more.desc with - Tsubst {desc = Ttuple [_;ty2]} -> - (* This variant type has been already copied *) - ty.desc <- Tsubst ty2; (* avoid Tlink in the new type *) - Tlink ty2 - | _ -> - (* If the row variable is not generic, we must keep it *) - let keep = more.level <> generic_level in - let more' = - match more.desc with - Tsubst ty -> ty - | Tconstr _ | Tnil -> - if keep then save_desc more more.desc; - copy more - | Tvar _ | Tunivar _ -> - save_desc more more.desc; - if keep then more else newty more.desc - | _ -> assert false - in - let row = - match repr more' with (* PR#6163 *) - {desc=Tconstr _} when not row.row_fixed -> - {row with row_fixed = true} - | _ -> row - in - (* Open row if partial for pattern and contains Reither *) - let more', row = - match partial with - Some (free_univars, false) -> - let more' = - if more.id != more'.id then more' else - let lv = if keep then more.level else !current_level in - newty2 lv (Tvar None) - in - let not_reither (_, f) = - match row_field_repr f with - Reither _ -> false - | _ -> true - in - if row.row_closed && not row.row_fixed - && TypeSet.is_empty (free_univars ty) - && not (List.for_all not_reither row.row_fields) then - (more', - {row_fields = List.filter not_reither row.row_fields; - row_more = more'; row_bound = (); - row_closed = false; row_fixed = false; row_name = None}) - else (more', row) - | _ -> (more', row) - in - (* Register new type first for recursion *) - more.desc <- Tsubst(newgenty(Ttuple[more';t])); - (* Return a new copy *) - Tvariant (copy_row copy true row keep more') - end - | Tfield (_p, k, _ty1, ty2) -> - begin match field_kind_repr k with - Fabsent -> Tlink (copy ty2) - | Fpresent -> copy_type_desc copy desc - | Fvar r -> - dup_kind r; - copy_type_desc copy desc - end - | Tobject (ty1, _) when partial <> None -> - Tobject (copy ty1, ref None) - | _ -> copy_type_desc ?keep_names copy desc - end; - t +end +module Tast_mapper : sig +#1 "tast_mapper.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Alain Frisch, LexiFi *) +(* *) +(* Copyright 2015 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -let simple_copy t = copy t +open Asttypes +open Typedtree -(**** Variants of instantiations ****) +(** {1 A generic Typedtree mapper} *) -let gadt_env env = - if Env.has_local_constraints env - then Some env - else None +type mapper = + { + case: mapper -> case -> case; + cases: mapper -> case list -> case list; + class_declaration: mapper -> class_declaration -> class_declaration; + class_description: mapper -> class_description -> class_description; + class_expr: mapper -> class_expr -> class_expr; + class_field: mapper -> class_field -> class_field; + class_signature: mapper -> class_signature -> class_signature; + class_structure: mapper -> class_structure -> class_structure; + class_type: mapper -> class_type -> class_type; + class_type_declaration: mapper -> class_type_declaration -> + class_type_declaration; + class_type_field: mapper -> class_type_field -> class_type_field; + env: mapper -> Env.t -> Env.t; + expr: mapper -> expression -> expression; + extension_constructor: mapper -> extension_constructor -> + extension_constructor; + module_binding: mapper -> module_binding -> module_binding; + module_coercion: mapper -> module_coercion -> module_coercion; + module_declaration: mapper -> module_declaration -> module_declaration; + module_expr: mapper -> module_expr -> module_expr; + module_type: mapper -> module_type -> module_type; + module_type_declaration: + mapper -> module_type_declaration -> module_type_declaration; + package_type: mapper -> package_type -> package_type; + pat: mapper -> pattern -> pattern; + row_field: mapper -> row_field -> row_field; + object_field: mapper -> object_field -> object_field; + signature: mapper -> signature -> signature; + signature_item: mapper -> signature_item -> signature_item; + structure: mapper -> structure -> structure; + structure_item: mapper -> structure_item -> structure_item; + typ: mapper -> core_type -> core_type; + type_declaration: mapper -> type_declaration -> type_declaration; + type_declarations: mapper -> (rec_flag * type_declaration list) -> + (rec_flag * type_declaration list); + type_extension: mapper -> type_extension -> type_extension; + type_kind: mapper -> type_kind -> type_kind; + value_binding: mapper -> value_binding -> value_binding; + value_bindings: mapper -> (rec_flag * value_binding list) -> + (rec_flag * value_binding list); + value_description: mapper -> value_description -> value_description; + with_constraint: mapper -> with_constraint -> with_constraint; + } -let instance ?partial env sch = - let env = gadt_env env in - let partial = - match partial with - None -> None - | Some keep -> Some (compute_univars sch, keep) - in - let ty = copy ?env ?partial sch in - cleanup_types (); - ty -let instance_def sch = - let ty = copy sch in - cleanup_types (); - ty +val default: mapper -let generic_instance env sch = - let old = !current_level in - current_level := generic_level; - let ty = instance env sch in - current_level := old; - ty +end = struct +#1 "tast_mapper.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Alain Frisch, LexiFi *) +(* *) +(* Copyright 2015 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -let instance_list env schl = - let env = gadt_env env in - let tyl = List.map (fun t -> copy ?env t) schl in - cleanup_types (); - tyl +open Asttypes +open Typedtree -let reified_var_counter = ref Vars.empty -let reset_reified_var_counter () = - reified_var_counter := Vars.empty +(* TODO: add 'methods' for location, attribute, extension, + open_description, include_declaration, include_description *) -(* names given to new type constructors. - Used for existential types and - local constraints *) -let get_new_abstract_name s = - let index = - try Vars.find s !reified_var_counter + 1 - with Not_found -> 0 in - reified_var_counter := Vars.add s index !reified_var_counter; - if index = 0 && s <> "" && s.[String.length s - 1] <> '$' then s else - Printf.sprintf "%s%d" s index +type mapper = + { + case: mapper -> case -> case; + cases: mapper -> case list -> case list; + class_declaration: mapper -> class_declaration -> class_declaration; + class_description: mapper -> class_description -> class_description; + class_expr: mapper -> class_expr -> class_expr; + class_field: mapper -> class_field -> class_field; + class_signature: mapper -> class_signature -> class_signature; + class_structure: mapper -> class_structure -> class_structure; + class_type: mapper -> class_type -> class_type; + class_type_declaration: mapper -> class_type_declaration -> + class_type_declaration; + class_type_field: mapper -> class_type_field -> class_type_field; + env: mapper -> Env.t -> Env.t; + expr: mapper -> expression -> expression; + extension_constructor: mapper -> extension_constructor -> + extension_constructor; + module_binding: mapper -> module_binding -> module_binding; + module_coercion: mapper -> module_coercion -> module_coercion; + module_declaration: mapper -> module_declaration -> module_declaration; + module_expr: mapper -> module_expr -> module_expr; + module_type: mapper -> module_type -> module_type; + module_type_declaration: + mapper -> module_type_declaration -> module_type_declaration; + package_type: mapper -> package_type -> package_type; + pat: mapper -> pattern -> pattern; + row_field: mapper -> row_field -> row_field; + object_field: mapper -> object_field -> object_field; + signature: mapper -> signature -> signature; + signature_item: mapper -> signature_item -> signature_item; + structure: mapper -> structure -> structure; + structure_item: mapper -> structure_item -> structure_item; + typ: mapper -> core_type -> core_type; + type_declaration: mapper -> type_declaration -> type_declaration; + type_declarations: mapper -> (rec_flag * type_declaration list) -> + (rec_flag * type_declaration list); + type_extension: mapper -> type_extension -> type_extension; + type_kind: mapper -> type_kind -> type_kind; + value_binding: mapper -> value_binding -> value_binding; + value_bindings: mapper -> (rec_flag * value_binding list) -> + (rec_flag * value_binding list); + value_description: mapper -> value_description -> value_description; + with_constraint: mapper -> with_constraint -> with_constraint; + } -let new_declaration newtype manifest = +let id x = x +let tuple2 f1 f2 (x, y) = (f1 x, f2 y) +let tuple3 f1 f2 f3 (x, y, z) = (f1 x, f2 y, f3 z) +let opt f = function None -> None | Some x -> Some (f x) + +let structure sub {str_items; str_type; str_final_env} = { - type_params = []; - type_arity = 0; - type_kind = Type_abstract; - type_private = Public; - type_manifest = manifest; - type_variance = []; - type_newtype_level = newtype; - type_loc = Location.none; - type_attributes = []; - type_immediate = false; - type_unboxed = unboxed_false_default_false; + str_items = List.map (sub.structure_item sub) str_items; + str_final_env = sub.env sub str_final_env; + str_type; } -let instance_constructor ?in_pattern cstr = - begin match in_pattern with - | None -> () - | Some (env, newtype_lev) -> - let process existential = - let decl = new_declaration (Some (newtype_lev, newtype_lev)) None in - let name = - match repr existential with - {desc = Tvar (Some name)} -> "$" ^ cstr.cstr_name ^ "_'" ^ name - | _ -> "$" ^ cstr.cstr_name - in - let path = Path.Pident (Ident.create (get_new_abstract_name name)) in - let new_env = Env.add_local_type path decl !env in - env := new_env; - let to_unify = newty (Tconstr (path,[],ref Mnil)) in - let tv = copy existential in - assert (is_Tvar tv); - link_type tv to_unify - in - List.iter process cstr.cstr_existentials - end; - let ty_res = copy cstr.cstr_res in - let ty_args = List.map simple_copy cstr.cstr_args in - cleanup_types (); - (ty_args, ty_res) +let class_infos sub f x = + {x with + ci_params = List.map (tuple2 (sub.typ sub) id) x.ci_params; + ci_expr = f x.ci_expr; + } -let instance_parameterized_type ?keep_names sch_args sch = - let ty_args = List.map (fun t -> copy ?keep_names t) sch_args in - let ty = copy sch in - cleanup_types (); - (ty_args, ty) +let module_type_declaration sub x = + let mtd_type = opt (sub.module_type sub) x.mtd_type in + {x with mtd_type} -let instance_parameterized_type_2 sch_args sch_lst sch = - let ty_args = List.map simple_copy sch_args in - let ty_lst = List.map simple_copy sch_lst in - let ty = copy sch in - cleanup_types (); - (ty_args, ty_lst, ty) +let module_declaration sub x = + let md_type = sub.module_type sub x.md_type in + {x with md_type} -let map_kind f = function - | Type_abstract -> Type_abstract - | Type_open -> Type_open - | Type_variant cl -> - Type_variant ( - List.map - (fun c -> - {c with - cd_args = map_type_expr_cstr_args f c.cd_args; - cd_res = may_map f c.cd_res - }) - cl) - | Type_record (fl, rr) -> - Type_record ( - List.map - (fun l -> - {l with ld_type = f l.ld_type} - ) fl, rr) +let include_infos f x = {x with incl_mod = f x.incl_mod} +let class_type_declaration sub x = + class_infos sub (sub.class_type sub) x -let instance_declaration decl = - let decl = - {decl with type_params = List.map simple_copy decl.type_params; - type_manifest = may_map simple_copy decl.type_manifest; - type_kind = map_kind simple_copy decl.type_kind; - } +let class_declaration sub x = + class_infos sub (sub.class_expr sub) x + +let structure_item sub {str_desc; str_loc; str_env} = + let str_env = sub.env sub str_env in + let str_desc = + match str_desc with + | Tstr_eval (exp, attrs) -> Tstr_eval (sub.expr sub exp, attrs) + | Tstr_value (rec_flag, list) -> + let (rec_flag, list) = sub.value_bindings sub (rec_flag, list) in + Tstr_value (rec_flag, list) + | Tstr_primitive v -> Tstr_primitive (sub.value_description sub v) + | Tstr_type (rec_flag, list) -> + let (rec_flag, list) = sub.type_declarations sub (rec_flag, list) in + Tstr_type (rec_flag, list) + | Tstr_typext te -> Tstr_typext (sub.type_extension sub te) + | Tstr_exception ext -> Tstr_exception (sub.extension_constructor sub ext) + | Tstr_module mb -> Tstr_module (sub.module_binding sub mb) + | Tstr_recmodule list -> + Tstr_recmodule (List.map (sub.module_binding sub) list) + | Tstr_modtype x -> Tstr_modtype (sub.module_type_declaration sub x) + | Tstr_class list -> + Tstr_class + (List.map (tuple2 (sub.class_declaration sub) id) list) + | Tstr_class_type list -> + Tstr_class_type + (List.map (tuple3 id id (sub.class_type_declaration sub)) list) + | Tstr_include incl -> + Tstr_include (include_infos (sub.module_expr sub) incl) + | Tstr_open _ + | Tstr_attribute _ as d -> d in - cleanup_types (); - decl + {str_desc; str_env; str_loc} -let instance_class params cty = - let rec copy_class_type = - function - Cty_constr (path, tyl, cty) -> - Cty_constr (path, List.map simple_copy tyl, copy_class_type cty) - | Cty_signature sign -> - Cty_signature - {csig_self = copy sign.csig_self; - csig_vars = - Vars.map (function (m, v, ty) -> (m, v, copy ty)) sign.csig_vars; - csig_concr = sign.csig_concr; - csig_inher = - List.map (fun (p,tl) -> (p, List.map simple_copy tl)) - sign.csig_inher} - | Cty_arrow (l, ty, cty) -> - Cty_arrow (l, copy ty, copy_class_type cty) +let value_description sub x = + let val_desc = sub.typ sub x.val_desc in + {x with val_desc} + +let label_decl sub x = + let ld_type = sub.typ sub x.ld_type in + {x with ld_type} + +let constructor_args sub = function + | Cstr_tuple l -> Cstr_tuple (List.map (sub.typ sub) l) + | Cstr_record l -> Cstr_record (List.map (label_decl sub) l) + +let constructor_decl sub cd = + let cd_args = constructor_args sub cd.cd_args in + let cd_res = opt (sub.typ sub) cd.cd_res in + {cd with cd_args; cd_res} + +let type_kind sub = function + | Ttype_abstract -> Ttype_abstract + | Ttype_variant list -> Ttype_variant (List.map (constructor_decl sub) list) + | Ttype_record list -> Ttype_record (List.map (label_decl sub) list) + | Ttype_open -> Ttype_open + +let type_declaration sub x = + let typ_cstrs = + List.map + (tuple3 (sub.typ sub) (sub.typ sub) id) + x.typ_cstrs + in + let typ_kind = sub.type_kind sub x.typ_kind in + let typ_manifest = opt (sub.typ sub) x.typ_manifest in + let typ_params = List.map (tuple2 (sub.typ sub) id) x.typ_params in + {x with typ_cstrs; typ_kind; typ_manifest; typ_params} + +let type_declarations sub (rec_flag, list) = + (rec_flag, List.map (sub.type_declaration sub) list) + +let type_extension sub x = + let tyext_params = List.map (tuple2 (sub.typ sub) id) x.tyext_params in + let tyext_constructors = + List.map (sub.extension_constructor sub) x.tyext_constructors + in + {x with tyext_constructors; tyext_params} + +let extension_constructor sub x = + let ext_kind = + match x.ext_kind with + Text_decl(ctl, cto) -> + Text_decl(constructor_args sub ctl, opt (sub.typ sub) cto) + | Text_rebind _ as d -> d + in + {x with ext_kind} + +let pat sub x = + let extra = function + | Tpat_type _ + | Tpat_unpack as d -> d + | Tpat_open (path,loc,env) -> Tpat_open (path, loc, sub.env sub env) + | Tpat_constraint ct -> Tpat_constraint (sub.typ sub ct) + in + let pat_env = sub.env sub x.pat_env in + let pat_extra = List.map (tuple3 extra id id) x.pat_extra in + let pat_desc = + match x.pat_desc with + | Tpat_any + | Tpat_var _ + | Tpat_constant _ as d -> d + | Tpat_tuple l -> Tpat_tuple (List.map (sub.pat sub) l) + | Tpat_construct (loc, cd, l) -> + Tpat_construct (loc, cd, List.map (sub.pat sub) l) + | Tpat_variant (l, po, rd) -> Tpat_variant (l, opt (sub.pat sub) po, rd) + | Tpat_record (l, closed) -> + Tpat_record (List.map (tuple3 id id (sub.pat sub)) l, closed) + | Tpat_array l -> Tpat_array (List.map (sub.pat sub) l) + | Tpat_or (p1, p2, rd) -> + Tpat_or (sub.pat sub p1, sub.pat sub p2, rd) + | Tpat_alias (p, id, s) -> Tpat_alias (sub.pat sub p, id, s) + | Tpat_lazy p -> Tpat_lazy (sub.pat sub p) + in + {x with pat_extra; pat_desc; pat_env} + +let expr sub x = + let extra = function + | Texp_constraint cty -> + Texp_constraint (sub.typ sub cty) + | Texp_coerce (cty1, cty2) -> + Texp_coerce (opt (sub.typ sub) cty1, sub.typ sub cty2) + | Texp_open (ovf, path, loc, env) -> + Texp_open (ovf, path, loc, sub.env sub env) + | Texp_newtype _ as d -> d + | Texp_poly cto -> Texp_poly (opt (sub.typ sub) cto) + in + let exp_extra = List.map (tuple3 extra id id) x.exp_extra in + let exp_env = sub.env sub x.exp_env in + let exp_desc = + match x.exp_desc with + | Texp_ident _ + | Texp_constant _ as d -> d + | Texp_let (rec_flag, list, exp) -> + let (rec_flag, list) = sub.value_bindings sub (rec_flag, list) in + Texp_let (rec_flag, list, sub.expr sub exp) + | Texp_function { arg_label; param; cases; partial; } -> + Texp_function { arg_label; param; cases = sub.cases sub cases; + partial; } + | Texp_apply (exp, list) -> + Texp_apply ( + sub.expr sub exp, + List.map (tuple2 id (opt (sub.expr sub))) list + ) + | Texp_match (exp, cases, exn_cases, p) -> + Texp_match ( + sub.expr sub exp, + sub.cases sub cases, + sub.cases sub exn_cases, + p + ) + | Texp_try (exp, cases) -> + Texp_try ( + sub.expr sub exp, + sub.cases sub cases + ) + | Texp_tuple list -> + Texp_tuple (List.map (sub.expr sub) list) + | Texp_construct (lid, cd, args) -> + Texp_construct (lid, cd, List.map (sub.expr sub) args) + | Texp_variant (l, expo) -> + Texp_variant (l, opt (sub.expr sub) expo) + | Texp_record { fields; representation; extended_expression } -> + let fields = Array.map (function + | label, Kept t -> label, Kept t + | label, Overridden (lid, exp) -> + label, Overridden (lid, sub.expr sub exp)) + fields + in + Texp_record { + fields; representation; + extended_expression = opt (sub.expr sub) extended_expression; + } + | Texp_field (exp, lid, ld) -> + Texp_field (sub.expr sub exp, lid, ld) + | Texp_setfield (exp1, lid, ld, exp2) -> + Texp_setfield ( + sub.expr sub exp1, + lid, + ld, + sub.expr sub exp2 + ) + | Texp_array list -> + Texp_array (List.map (sub.expr sub) list) + | Texp_ifthenelse (exp1, exp2, expo) -> + Texp_ifthenelse ( + sub.expr sub exp1, + sub.expr sub exp2, + opt (sub.expr sub) expo + ) + | Texp_sequence (exp1, exp2) -> + Texp_sequence ( + sub.expr sub exp1, + sub.expr sub exp2 + ) + | Texp_while (exp1, exp2) -> + Texp_while ( + sub.expr sub exp1, + sub.expr sub exp2 + ) + | Texp_for (id, p, exp1, exp2, dir, exp3) -> + Texp_for ( + id, + p, + sub.expr sub exp1, + sub.expr sub exp2, + dir, + sub.expr sub exp3 + ) + | Texp_send (exp, meth, expo) -> + Texp_send + ( + sub.expr sub exp, + meth, + opt (sub.expr sub) expo + ) + | Texp_new _ + | Texp_instvar _ as d -> d + | Texp_setinstvar (path1, path2, id, exp) -> + Texp_setinstvar ( + path1, + path2, + id, + sub.expr sub exp + ) + | Texp_override (path, list) -> + Texp_override ( + path, + List.map (tuple3 id id (sub.expr sub)) list + ) + | Texp_letmodule (id, s, mexpr, exp) -> + Texp_letmodule ( + id, + s, + sub.module_expr sub mexpr, + sub.expr sub exp + ) + | Texp_letexception (cd, exp) -> + Texp_letexception ( + sub.extension_constructor sub cd, + sub.expr sub exp + ) + | Texp_assert exp -> + Texp_assert (sub.expr sub exp) + | Texp_lazy exp -> + Texp_lazy (sub.expr sub exp) + | Texp_object (cl, sl) -> + Texp_object (sub.class_structure sub cl, sl) + | Texp_pack mexpr -> + Texp_pack (sub.module_expr sub mexpr) + | Texp_unreachable -> + Texp_unreachable + | Texp_extension_constructor _ as e -> + e in - let params' = List.map simple_copy params in - let cty' = copy_class_type cty in - cleanup_types (); - (params', cty') - -(**** Instantiation for types with free universal variables ****) - -let rec diff_list l1 l2 = - if l1 == l2 then [] else - match l1 with [] -> invalid_arg "Ctype.diff_list" - | a :: l1 -> a :: diff_list l1 l2 - -let conflicts free bound = - let bound = List.map repr bound in - TypeSet.exists (fun t -> List.memq (repr t) bound) free + {x with exp_extra; exp_desc; exp_env} -let delayed_copy = ref [] - (* copying to do later *) -(* Copy without sharing until there are no free univars left *) -(* all free univars must be included in [visited] *) -let rec copy_sep fixed free bound visited ty = - let ty = repr ty in - let univars = free ty in - if TypeSet.is_empty univars then - if ty.level <> generic_level then ty else - let t = newvar () in - delayed_copy := - lazy (t.desc <- Tlink (copy ty)) - :: !delayed_copy; - t - else try - let t, bound_t = List.assq ty visited in - let dl = if is_Tunivar ty then [] else diff_list bound bound_t in - if dl <> [] && conflicts univars dl then raise Not_found; - t - with Not_found -> begin - let t = newvar() in (* Stub *) - let visited = - match ty.desc with - Tarrow _ | Ttuple _ | Tvariant _ | Tconstr _ | Tobject _ | Tpackage _ -> - (ty,(t,bound)) :: visited - | _ -> visited in - let copy_rec = copy_sep fixed free bound visited in - t.desc <- - begin match ty.desc with - | Tvariant row0 -> - let row = row_repr row0 in - let more = repr row.row_more in - (* We shall really check the level on the row variable *) - let keep = is_Tvar more && more.level <> generic_level in - let more' = copy_rec more in - let fixed' = fixed && is_Tvar (repr more') in - let row = copy_row copy_rec fixed' row keep more' in - Tvariant row - | Tpoly (t1, tl) -> - let tl = List.map repr tl in - let tl' = List.map (fun t -> newty t.desc) tl in - let bound = tl @ bound in - let visited = - List.map2 (fun ty t -> ty,(t,bound)) tl tl' @ visited in - Tpoly (copy_sep fixed free bound visited t1, tl') - | _ -> copy_type_desc copy_rec ty.desc - end; - t - end +let package_type sub x = + let pack_fields = List.map (tuple2 id (sub.typ sub)) x.pack_fields in + {x with pack_fields} -let instance_poly ?(keep_names=false) fixed univars sch = - let univars = List.map repr univars in - let copy_var ty = - match ty.desc with - Tunivar name -> if keep_names then newty (Tvar name) else newvar () - | _ -> assert false - in - let vars = List.map copy_var univars in - let pairs = List.map2 (fun u v -> u, (v, [])) univars vars in - delayed_copy := []; - let ty = copy_sep fixed (compute_univars sch) [] pairs sch in - List.iter Lazy.force !delayed_copy; - delayed_copy := []; - cleanup_types (); - vars, ty +let signature sub x = + let sig_final_env = sub.env sub x.sig_final_env in + let sig_items = List.map (sub.signature_item sub) x.sig_items in + {x with sig_items; sig_final_env} -let instance_label fixed lbl = - let ty_res = copy lbl.lbl_res in - let vars, ty_arg = - match repr lbl.lbl_arg with - {desc = Tpoly (ty, tl)} -> - instance_poly fixed tl ty - | _ -> - [], copy lbl.lbl_arg +let signature_item sub x = + let sig_env = sub.env sub x.sig_env in + let sig_desc = + match x.sig_desc with + | Tsig_value v -> + Tsig_value (sub.value_description sub v) + | Tsig_type (rec_flag, list) -> + let (rec_flag, list) = sub.type_declarations sub (rec_flag, list) in + Tsig_type (rec_flag, list) + | Tsig_typext te -> + Tsig_typext (sub.type_extension sub te) + | Tsig_exception ext -> + Tsig_exception (sub.extension_constructor sub ext) + | Tsig_module x -> + Tsig_module (sub.module_declaration sub x) + | Tsig_recmodule list -> + Tsig_recmodule (List.map (sub.module_declaration sub) list) + | Tsig_modtype x -> + Tsig_modtype (sub.module_type_declaration sub x) + | Tsig_include incl -> + Tsig_include (include_infos (sub.module_type sub) incl) + | Tsig_class list -> + Tsig_class (List.map (sub.class_description sub) list) + | Tsig_class_type list -> + Tsig_class_type + (List.map (sub.class_type_declaration sub) list) + | Tsig_open _ + | Tsig_attribute _ as d -> d in - cleanup_types (); - (vars, ty_arg, ty_res) - -(**** Instantiation with parameter substitution ****) - -let unify' = (* Forward declaration *) - ref (fun _env _ty1 _ty2 -> raise (Unify [])) - -let subst env level priv abbrev ty params args body = - if List.length params <> List.length args then raise (Unify []); - let old_level = !current_level in - current_level := level; - try - let body0 = newvar () in (* Stub *) - begin match ty with - None -> () - | Some ({desc = Tconstr (path, tl, _)} as ty) -> - let abbrev = proper_abbrevs path tl abbrev in - memorize_abbrev abbrev priv path ty body0 - | _ -> - assert false - end; - abbreviations := abbrev; - let (params', body') = instance_parameterized_type params body in - abbreviations := ref Mnil; - !unify' env body0 body'; - List.iter2 (!unify' env) params' args; - current_level := old_level; - body' - with Unify _ as exn -> - current_level := old_level; - raise exn - -(* - Only the shape of the type matters, not whether it is generic or - not. [generic_level] might be somewhat slower, but it ensures - invariants on types are enforced (decreasing levels), and we don't - care about efficiency here. -*) -let apply env params body args = - try - subst env generic_level Public (ref Mnil) None params args body - with - Unify _ -> raise Cannot_apply + {x with sig_desc; sig_env} -let () = Subst.ctype_apply_env_empty := apply Env.empty +let class_description sub x = + class_infos sub (sub.class_type sub) x - (****************************) - (* Abbreviation expansion *) - (****************************) +let module_type sub x = + let mty_env = sub.env sub x.mty_env in + let mty_desc = + match x.mty_desc with + | Tmty_ident _ + | Tmty_alias _ as d -> d + | Tmty_signature sg -> Tmty_signature (sub.signature sub sg) + | Tmty_functor (id, s, mtype1, mtype2) -> + Tmty_functor ( + id, + s, + opt (sub.module_type sub) mtype1, + sub.module_type sub mtype2 + ) + | Tmty_with (mtype, list) -> + Tmty_with ( + sub.module_type sub mtype, + List.map (tuple3 id id (sub.with_constraint sub)) list + ) + | Tmty_typeof mexpr -> + Tmty_typeof (sub.module_expr sub mexpr) + in + {x with mty_desc; mty_env} -(* - If the environment has changed, memorized expansions might not - be correct anymore, and so we flush the cache. This is safe but - quite pessimistic: it would be enough to flush the cache when a - type or module definition is overridden in the environment. -*) -let previous_env = ref Env.empty -(*let string_of_kind = function Public -> "public" | Private -> "private"*) -let check_abbrev_env env = - if env != !previous_env then begin - (* prerr_endline "cleanup expansion cache"; *) - cleanup_abbrev (); - previous_env := env - end +let with_constraint sub = function + | Twith_type decl -> Twith_type (sub.type_declaration sub decl) + | Twith_typesubst decl -> Twith_typesubst (sub.type_declaration sub decl) + | Twith_module _ + | Twith_modsubst _ as d -> d +let module_coercion sub = function + | Tcoerce_none -> Tcoerce_none + | Tcoerce_functor (c1,c2) -> + Tcoerce_functor (sub.module_coercion sub c1, sub.module_coercion sub c2) + | Tcoerce_alias (p, c1) -> + Tcoerce_alias (p, sub.module_coercion sub c1) + | Tcoerce_structure (l1, l2, runtime_fields) -> + let l1' = List.map (fun (i,c) -> i, sub.module_coercion sub c) l1 in + let l2' = + List.map (fun (id,i,c) -> id, i, sub.module_coercion sub c) l2 + in + Tcoerce_structure (l1', l2', runtime_fields) + | Tcoerce_primitive pc -> + Tcoerce_primitive {pc with pc_env = sub.env sub pc.pc_env} -(* Expand an abbreviation. The expansion is memorized. *) -(* - Assume the level is greater than the path binding time of the - expanded abbreviation. -*) -(* - An abbreviation expansion will fail in either of these cases: - 1. The type constructor does not correspond to a manifest type. - 2. The type constructor is defined in an external file, and this - file is not in the path (missing -I options). - 3. The type constructor is not in the "local" environment. This can - happens when a non-generic type variable has been instantiated - afterwards to the not yet defined type constructor. (Actually, - this cannot happen at the moment due to the strong constraints - between type levels and constructor binding time.) - 4. The expansion requires the expansion of another abbreviation, - and this other expansion fails. -*) -let expand_abbrev_gen kind find_type_expansion env ty = - check_abbrev_env env; - match ty with - {desc = Tconstr (path, args, abbrev); level = level} -> - let lookup_abbrev = proper_abbrevs path args abbrev in - begin match find_expans kind path !lookup_abbrev with - Some ty' -> - (* prerr_endline - ("found a "^string_of_kind kind^" expansion for "^Path.name path);*) - if level <> generic_level then - begin try - update_level env level ty' - with Unify _ -> - (* XXX This should not happen. - However, levels are not correctly restored after a - typing error *) - () - end; - let ty' = repr ty' in - (* assert (ty != ty'); *) (* PR#7324 *) - ty' - | None -> - match find_type_expansion path env with - | exception Not_found -> - (* another way to expand is to normalize the path itself *) - let path' = Env.normalize_path None env path in - if Path.same path path' then raise Cannot_expand - else newty2 level (Tconstr (path', args, abbrev)) - | (params, body, lv) -> - (* prerr_endline - ("add a "^string_of_kind kind^" expansion for "^Path.name path);*) - let ty' = subst env level kind abbrev (Some ty) params args body in - (* For gadts, remember type as non exportable *) - (* The ambiguous level registered for ty' should be the highest *) - if !trace_gadt_instances then begin - match max lv (Env.gadt_instance_level env ty) with - None -> () - | Some lv -> - if level < lv then raise (Unify [(ty, newvar2 level)]); - Env.add_gadt_instances env lv [ty; ty'] - end; - ty' - end - | _ -> - assert false +let module_expr sub x = + let mod_env = sub.env sub x.mod_env in + let mod_desc = + match x.mod_desc with + | Tmod_ident _ as d -> d + | Tmod_structure st -> Tmod_structure (sub.structure sub st) + | Tmod_functor (id, s, mtype, mexpr) -> + Tmod_functor ( + id, + s, + opt (sub.module_type sub) mtype, + sub.module_expr sub mexpr + ) + | Tmod_apply (mexp1, mexp2, c) -> + Tmod_apply ( + sub.module_expr sub mexp1, + sub.module_expr sub mexp2, + sub.module_coercion sub c + ) + | Tmod_constraint (mexpr, mt, Tmodtype_implicit, c) -> + Tmod_constraint (sub.module_expr sub mexpr, mt, Tmodtype_implicit, + sub.module_coercion sub c) + | Tmod_constraint (mexpr, mt, Tmodtype_explicit mtype, c) -> + Tmod_constraint ( + sub.module_expr sub mexpr, + mt, + Tmodtype_explicit (sub.module_type sub mtype), + sub.module_coercion sub c + ) + | Tmod_unpack (exp, mty) -> + Tmod_unpack + ( + sub.expr sub exp, + mty + ) + in + {x with mod_desc; mod_env} -(* Expand respecting privacy *) -let expand_abbrev env ty = - expand_abbrev_gen Public Env.find_type_expansion env ty +let module_binding sub x = + let mb_expr = sub.module_expr sub x.mb_expr in + {x with mb_expr} -(* Expand once the head of a type *) -let expand_head_once env ty = - try expand_abbrev env (repr ty) with Cannot_expand -> assert false +let class_expr sub x = + let cl_env = sub.env sub x.cl_env in + let cl_desc = + match x.cl_desc with + | Tcl_constraint (cl, clty, vals, meths, concrs) -> + Tcl_constraint ( + sub.class_expr sub cl, + opt (sub.class_type sub) clty, + vals, + meths, + concrs + ) + | Tcl_structure clstr -> + Tcl_structure (sub.class_structure sub clstr) + | Tcl_fun (label, pat, priv, cl, partial) -> + Tcl_fun ( + label, + sub.pat sub pat, + List.map (tuple3 id id (sub.expr sub)) priv, + sub.class_expr sub cl, + partial + ) + | Tcl_apply (cl, args) -> + Tcl_apply ( + sub.class_expr sub cl, + List.map (tuple2 id (opt (sub.expr sub))) args + ) + | Tcl_let (rec_flag, value_bindings, ivars, cl) -> + let (rec_flag, value_bindings) = + sub.value_bindings sub (rec_flag, value_bindings) + in + Tcl_let ( + rec_flag, + value_bindings, + List.map (tuple3 id id (sub.expr sub)) ivars, + sub.class_expr sub cl + ) + | Tcl_ident (path, lid, tyl) -> + Tcl_ident (path, lid, List.map (sub.typ sub) tyl) + | Tcl_open (ovf, p, lid, env, e) -> + Tcl_open (ovf, p, lid, sub.env sub env, sub.class_expr sub e) + in + {x with cl_desc; cl_env} -(* Check whether a type can be expanded *) -let safe_abbrev env ty = - let snap = Btype.snapshot () in - try ignore (expand_abbrev env ty); true - with Cannot_expand | Unify _ -> - Btype.backtrack snap; - false +let class_type sub x = + let cltyp_env = sub.env sub x.cltyp_env in + let cltyp_desc = + match x.cltyp_desc with + | Tcty_signature csg -> Tcty_signature (sub.class_signature sub csg) + | Tcty_constr (path, lid, list) -> + Tcty_constr ( + path, + lid, + List.map (sub.typ sub) list + ) + | Tcty_arrow (label, ct, cl) -> + Tcty_arrow + (label, + sub.typ sub ct, + sub.class_type sub cl + ) + | Tcty_open (ovf, p, lid, env, e) -> + Tcty_open (ovf, p, lid, sub.env sub env, sub.class_type sub e) + in + {x with cltyp_desc; cltyp_env} -(* Expand the head of a type once. - Raise Cannot_expand if the type cannot be expanded. - May raise Unify, if a recursion was hidden in the type. *) -let try_expand_once env ty = - let ty = repr ty in - match ty.desc with - Tconstr _ -> repr (expand_abbrev env ty) - | _ -> raise Cannot_expand +let class_signature sub x = + let csig_self = sub.typ sub x.csig_self in + let csig_fields = List.map (sub.class_type_field sub) x.csig_fields in + {x with csig_self; csig_fields} -(* This one only raises Cannot_expand *) -let try_expand_safe env ty = - let snap = Btype.snapshot () in - try try_expand_once env ty - with Unify _ -> - Btype.backtrack snap; raise Cannot_expand +let class_type_field sub x = + let ctf_desc = + match x.ctf_desc with + | Tctf_inherit ct -> + Tctf_inherit (sub.class_type sub ct) + | Tctf_val (s, mut, virt, ct) -> + Tctf_val (s, mut, virt, sub.typ sub ct) + | Tctf_method (s, priv, virt, ct) -> + Tctf_method (s, priv, virt, sub.typ sub ct) + | Tctf_constraint (ct1, ct2) -> + Tctf_constraint (sub.typ sub ct1, sub.typ sub ct2) + | Tctf_attribute _ as d -> d + in + {x with ctf_desc} -(* Fully expand the head of a type. *) -let rec try_expand_head try_once env ty = - let ty' = try_once env ty in - try try_expand_head try_once env ty' - with Cannot_expand -> ty' +let typ sub x = + let ctyp_env = sub.env sub x.ctyp_env in + let ctyp_desc = + match x.ctyp_desc with + | Ttyp_any + | Ttyp_var _ as d -> d + | Ttyp_arrow (label, ct1, ct2) -> + Ttyp_arrow (label, sub.typ sub ct1, sub.typ sub ct2) + | Ttyp_tuple list -> Ttyp_tuple (List.map (sub.typ sub) list) + | Ttyp_constr (path, lid, list) -> + Ttyp_constr (path, lid, List.map (sub.typ sub) list) + | Ttyp_object (list, closed) -> + Ttyp_object ((List.map (sub.object_field sub) list), closed) + | Ttyp_class (path, lid, list) -> + Ttyp_class + (path, + lid, + List.map (sub.typ sub) list + ) + | Ttyp_alias (ct, s) -> + Ttyp_alias (sub.typ sub ct, s) + | Ttyp_variant (list, closed, labels) -> + Ttyp_variant (List.map (sub.row_field sub) list, closed, labels) + | Ttyp_poly (sl, ct) -> + Ttyp_poly (sl, sub.typ sub ct) + | Ttyp_package pack -> + Ttyp_package (sub.package_type sub pack) + in + {x with ctyp_desc; ctyp_env} -let try_expand_head try_once env ty = - let ty' = try_expand_head try_once env ty in - begin match Env.gadt_instance_level env ty' with - None -> () - | Some lv -> Env.add_gadt_instance_chain env lv ty - end; - ty' +let class_structure sub x = + let cstr_self = sub.pat sub x.cstr_self in + let cstr_fields = List.map (sub.class_field sub) x.cstr_fields in + {x with cstr_self; cstr_fields} -(* Unsafe full expansion, may raise Unify. *) -let expand_head_unif env ty = - try try_expand_head try_expand_once env ty with Cannot_expand -> repr ty +let row_field sub = function + | Ttag (label, attrs, b, list) -> + Ttag (label, attrs, b, List.map (sub.typ sub) list) + | Tinherit ct -> Tinherit (sub.typ sub ct) -(* Safe version of expand_head, never fails *) -let expand_head env ty = - try try_expand_head try_expand_safe env ty with Cannot_expand -> repr ty +let object_field sub = function + | OTtag (label, attrs, ct) -> + OTtag (label, attrs, (sub.typ sub ct)) + | OTinherit ct -> OTinherit (sub.typ sub ct) -let _ = forward_try_expand_once := try_expand_safe +let class_field_kind sub = function + | Tcfk_virtual ct -> Tcfk_virtual (sub.typ sub ct) + | Tcfk_concrete (ovf, e) -> Tcfk_concrete (ovf, sub.expr sub e) +let class_field sub x = + let cf_desc = + match x.cf_desc with + | Tcf_inherit (ovf, cl, super, vals, meths) -> + Tcf_inherit (ovf, sub.class_expr sub cl, super, vals, meths) + | Tcf_constraint (cty, cty') -> + Tcf_constraint ( + sub.typ sub cty, + sub.typ sub cty' + ) + | Tcf_val (s, mf, id, k, b) -> + Tcf_val (s, mf, id, class_field_kind sub k, b) + | Tcf_method (s, priv, k) -> + Tcf_method (s, priv, class_field_kind sub k) + | Tcf_initializer exp -> + Tcf_initializer (sub.expr sub exp) + | Tcf_attribute _ as d -> d + in + {x with cf_desc} -(* Expand until we find a non-abstract type declaration *) +let value_bindings sub (rec_flag, list) = + (rec_flag, List.map (sub.value_binding sub) list) -let rec extract_concrete_typedecl env ty = - let ty = repr ty in - match ty.desc with - Tconstr (p, _, _) -> - let decl = Env.find_type p env in - if decl.type_kind <> Type_abstract then (p, p, decl) else - let ty = - try try_expand_once env ty with Cannot_expand -> raise Not_found - in - let (_, p', decl) = extract_concrete_typedecl env ty in - (p, p', decl) - | _ -> raise Not_found +let cases sub l = + List.map (sub.case sub) l -(* Implementing function [expand_head_opt], the compiler's own version of - [expand_head] used for type-based optimisations. - [expand_head_opt] uses [Env.find_type_expansion_opt] to access the - manifest type information of private abstract data types which is - normally hidden to the type-checker out of the implementation module of - the private abbreviation. *) +let case sub {c_lhs; c_guard; c_rhs} = + { + c_lhs = sub.pat sub c_lhs; + c_guard = opt (sub.expr sub) c_guard; + c_rhs = sub.expr sub c_rhs; + } -let expand_abbrev_opt = - expand_abbrev_gen Private Env.find_type_expansion_opt +let value_binding sub x = + let vb_pat = sub.pat sub x.vb_pat in + let vb_expr = sub.expr sub x.vb_expr in + {x with vb_pat; vb_expr} -let try_expand_once_opt env ty = - let ty = repr ty in - match ty.desc with - Tconstr _ -> repr (expand_abbrev_opt env ty) - | _ -> raise Cannot_expand +let env _sub x = x -let rec try_expand_head_opt env ty = - let ty' = try_expand_once_opt env ty in - begin try - try_expand_head_opt env ty' - with Cannot_expand -> - ty' - end +let default = + { + case; + cases; + class_declaration; + class_description; + class_expr; + class_field; + class_signature; + class_structure; + class_type; + class_type_declaration; + class_type_field; + env; + expr; + extension_constructor; + module_binding; + module_coercion; + module_declaration; + module_expr; + module_type; + module_type_declaration; + package_type; + pat; + row_field; + object_field; + signature; + signature_item; + structure; + structure_item; + typ; + type_declaration; + type_declarations; + type_extension; + type_kind; + value_binding; + value_bindings; + value_description; + with_constraint; + } -let expand_head_opt env ty = - let snap = Btype.snapshot () in - try try_expand_head_opt env ty - with Cannot_expand | Unify _ -> (* expand_head shall never fail *) - Btype.backtrack snap; - repr ty +end +module Cmt_format : sig +#1 "cmt_format.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Fabrice Le Fessant, INRIA Saclay *) +(* *) +(* Copyright 2012 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -(* Make sure that the type parameters of the type constructor [ty] - respect the type constraints *) -let enforce_constraints env ty = - match ty with - {desc = Tconstr (path, args, _abbrev); level = level} -> - begin try - let decl = Env.find_type path env in - ignore - (subst env level Public (ref Mnil) None decl.type_params args - (newvar2 level)) - with Not_found -> () - end - | _ -> - assert false +(** cmt and cmti files format. *) -(* Recursively expand the head of a type. - Also expand #-types. *) -let full_expand env ty = - let ty = repr (expand_head env ty) in - match ty.desc with - Tobject (fi, {contents = Some (_, v::_)}) when is_Tvar (repr v) -> - newty2 ty.level (Tobject (fi, ref None)) - | _ -> - ty +(** The layout of a cmt file is as follows: + := \{\} \{cmt infos\} \{\} + where is the cmi file format: + := . + More precisely, the optional part must be present if and only if + the file is: + - a cmti, or + - a cmt, for a ml file which has no corresponding mli (hence no + corresponding cmti). -(* - Check whether the abbreviation expands to a well-defined type. - During the typing of a class, abbreviations for correspondings - types expand to non-generic types. -*) -let generic_abbrev env path = - try - let (_, body, _) = Env.find_type_expansion path env in - (repr body).level = generic_level - with - Not_found -> - false + Thus, we provide a common reading function for cmi and cmt(i) + files which returns an option for each of the three parts: cmi + info, cmt info, source info. *) -let generic_private_abbrev env path = - try - match Env.find_type path env with - {type_kind = Type_abstract; - type_private = Private; - type_manifest = Some body} -> - (repr body).level = generic_level - | _ -> false - with Not_found -> false +open Typedtree -let is_contractive env p = - try - let decl = Env.find_type p env in - in_pervasives p && decl.type_manifest = None || is_datatype decl - with Not_found -> false +type binary_annots = + | Packed of Types.signature * string list + | Implementation of structure + | Interface of signature + | Partial_implementation of binary_part array + | Partial_interface of binary_part array +and binary_part = + | Partial_structure of structure + | Partial_structure_item of structure_item + | Partial_expression of expression + | Partial_pattern of pattern + | Partial_class_expr of class_expr + | Partial_signature of signature + | Partial_signature_item of signature_item + | Partial_module_type of module_type - (*****************) - (* Occur check *) - (*****************) +type cmt_infos = { + cmt_modname : string; + cmt_annots : binary_annots; + cmt_value_dependencies : + (Types.value_description * Types.value_description) list; + cmt_comments : (string * Location.t) list; + cmt_args : string array; + cmt_sourcefile : string option; + cmt_builddir : string; + cmt_loadpath : string list; + cmt_source_digest : string option; + cmt_initial_env : Env.t; + cmt_imports : (string * Digest.t option) list; + cmt_interface_digest : Digest.t option; + cmt_use_summaries : bool; +} +type error = + Not_a_typedtree of string -exception Occur +exception Error of error -let rec occur_rec env allow_recursive visited ty0 = function - | {desc=Tlink ty} -> - occur_rec env allow_recursive visited ty0 ty - | ty -> - if ty == ty0 then raise Occur; - match ty.desc with - Tconstr(p, _tl, _abbrev) -> - if allow_recursive && is_contractive env p then () else - begin try - if TypeSet.mem ty visited then raise Occur; - let visited = TypeSet.add ty visited in - iter_type_expr (occur_rec env allow_recursive visited ty0) ty - with Occur -> try - let ty' = try_expand_head try_expand_once env ty in - (* This call used to be inlined, but there seems no reason for it. - Message was referring to change in rev. 1.58 of the CVS repo. *) - occur_rec env allow_recursive visited ty0 ty' - with Cannot_expand -> - raise Occur - end - | Tobject _ | Tvariant _ -> - () - | _ -> - if allow_recursive || TypeSet.mem ty visited then () else begin - let visited = TypeSet.add ty visited in - iter_type_expr (occur_rec env allow_recursive visited ty0) ty - end +(** [read filename] opens filename, and extract both the cmi_infos, if + it exists, and the cmt_infos, if it exists. Thus, it can be used + with .cmi, .cmt and .cmti files. -let type_changed = ref false (* trace possible changes to the studied type *) + .cmti files always contain a cmi_infos at the beginning. .cmt files + only contain a cmi_infos at the beginning if there is no associated + .cmti file. +*) +val read : string -> Cmi_format.cmi_infos option * cmt_infos option -let merge r b = if b then r := true +val read_cmt : string -> cmt_infos +val read_cmi : string -> Cmi_format.cmi_infos -let occur env ty0 ty = - let allow_recursive = !Clflags.recursive_types || !umode = Pattern in - let old = !type_changed in - try - while - type_changed := false; - occur_rec env allow_recursive TypeSet.empty ty0 ty; - !type_changed - do () (* prerr_endline "changed" *) done; - merge type_changed old - with exn -> - merge type_changed old; - raise (match exn with Occur -> Unify [] | _ -> exn) +(** [save_cmt filename modname binary_annots sourcefile initial_env cmi] + writes a cmt(i) file. *) +val save_cmt : + string -> (* filename.cmt to generate *) + string -> (* module name *) + binary_annots -> + string option -> (* source file *) + Env.t -> (* initial env *) + Cmi_format.cmi_infos option -> (* if a .cmi was generated *) + unit -let occur_in env ty0 t = - try occur env ty0 t; false with Unify _ -> true +(* Miscellaneous functions *) -(* Check that a local constraint is well-founded *) -(* PR#6405: not needed since we allow recursion and work on normalized types *) -(* PR#6992: we actually need it for contractiveness *) -(* This is a simplified version of occur, only for the rectypes case *) +val read_magic_number : in_channel -> string -let rec local_non_recursive_abbrev strict visited env p ty = - (*Format.eprintf "@[Check %s =@ %a@]@." (Path.name p) !Btype.print_raw ty;*) - let ty = repr ty in - if not (List.memq ty visited) then begin - match ty.desc with - Tconstr(p', args, _abbrev) -> - if Path.same p p' then raise Occur; - if not strict && is_contractive env p' then () else - let visited = ty :: visited in - begin try - (* try expanding, since [p] could be hidden *) - local_non_recursive_abbrev strict visited env p - (try_expand_head try_expand_once env ty) - with Cannot_expand -> - let params = - try (Env.find_type p' env).type_params - with Not_found -> args - in - List.iter2 - (fun tv ty -> - let strict = strict || not (is_Tvar (repr tv)) in - local_non_recursive_abbrev strict visited env p ty) - params args - end - | _ -> - if strict then (* PR#7374 *) - let visited = ty :: visited in - iter_type_expr (local_non_recursive_abbrev true visited env p) ty - end +val clear: unit -> unit -let local_non_recursive_abbrev env p ty = - try (* PR#7397: need to check trace_gadt_instances *) - wrap_trace_gadt_instances env - (local_non_recursive_abbrev false [] env p) ty; - true - with Occur -> false +val add_saved_type : binary_part -> unit +val get_saved_types : unit -> binary_part list +val set_saved_types : binary_part list -> unit +val record_value_dependency: + Types.value_description -> Types.value_description -> unit - (*****************************) - (* Polymorphic Unification *) - (*****************************) -(* Since we cannot duplicate universal variables, unification must - be done at meta-level, using bindings in univar_pairs *) -let rec unify_univar t1 t2 = function - (cl1, cl2) :: rem -> - let find_univ t cl = - try - let (_, r) = List.find (fun (t',_) -> t == repr t') cl in - Some r - with Not_found -> None - in - begin match find_univ t1 cl1, find_univ t2 cl2 with - Some {contents=Some t'2}, Some _ when t2 == repr t'2 -> - () - | Some({contents=None} as r1), Some({contents=None} as r2) -> - set_univar r1 t2; set_univar r2 t1 - | None, None -> - unify_univar t1 t2 rem - | _ -> - raise (Unify []) - end - | [] -> raise (Unify []) +(* -(* Test the occurrence of free univars in a type *) -(* that's way too expensive. Must do some kind of caching *) -let occur_univar env ty = - let visited = ref TypeMap.empty in - let rec occur_rec bound ty = - let ty = repr ty in - if ty.level >= lowest_level && - if TypeSet.is_empty bound then - (ty.level <- pivot_level - ty.level; true) - else try - let bound' = TypeMap.find ty !visited in - if TypeSet.exists (fun x -> not (TypeSet.mem x bound)) bound' then - (visited := TypeMap.add ty (TypeSet.inter bound bound') !visited; - true) - else false - with Not_found -> - visited := TypeMap.add ty bound !visited; - true - then - match ty.desc with - Tunivar _ -> - if not (TypeSet.mem ty bound) then raise (Unify [ty, newgenvar ()]) - | Tpoly (ty, tyl) -> - let bound = List.fold_right TypeSet.add (List.map repr tyl) bound in - occur_rec bound ty - | Tconstr (_, [], _) -> () - | Tconstr (p, tl, _) -> - begin try - let td = Env.find_type p env in - List.iter2 - (fun t v -> - if Variance.(mem May_pos v || mem May_neg v) - then occur_rec bound t) - tl td.type_variance - with Not_found -> - List.iter (occur_rec bound) tl - end - | _ -> iter_type_expr (occur_rec bound) ty - in - try - occur_rec TypeSet.empty ty; unmark_type ty - with exn -> - unmark_type ty; raise exn + val is_magic_number : string -> bool + val read : in_channel -> Env.cmi_infos option * t + val write_magic_number : out_channel -> unit + val write : out_channel -> t -> unit -(* Grouping univars by families according to their binders *) -let add_univars = - List.fold_left (fun s (t,_) -> TypeSet.add (repr t) s) + val find : string list -> string -> string + val read_signature : 'a -> string -> Types.signature * 'b list * 'c list -let get_univar_family univar_pairs univars = - if univars = [] then TypeSet.empty else - let insert s = function - cl1, (_::_ as cl2) -> - if List.exists (fun (t1,_) -> TypeSet.mem (repr t1) s) cl1 then - add_univars s cl2 - else s - | _ -> s - in - let s = List.fold_right TypeSet.add univars TypeSet.empty in - List.fold_left insert s univar_pairs +*) -(* Whether a family of univars escapes from a type *) -let univars_escape env univar_pairs vl ty = - let family = get_univar_family univar_pairs vl in - let visited = ref TypeSet.empty in - let rec occur t = - let t = repr t in - if TypeSet.mem t !visited then () else begin - visited := TypeSet.add t !visited; - match t.desc with - Tpoly (t, tl) -> - if List.exists (fun t -> TypeSet.mem (repr t) family) tl then () - else occur t - | Tunivar _ -> - if TypeSet.mem t family then raise Occur - | Tconstr (_, [], _) -> () - | Tconstr (p, tl, _) -> - begin try - let td = Env.find_type p env in - List.iter2 - (fun t v -> - if Variance.(mem May_pos v || mem May_neg v) then occur t) - tl td.type_variance - with Not_found -> - List.iter occur tl - end - | _ -> - iter_type_expr occur t - end - in - try occur ty; false with Occur -> true +end = struct +#1 "cmt_format.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Fabrice Le Fessant, INRIA Saclay *) +(* *) +(* Copyright 2012 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -(* Wrapper checking that no variable escapes and updating univar_pairs *) -let enter_poly env univar_pairs t1 tl1 t2 tl2 f = - let old_univars = !univar_pairs in - let known_univars = - List.fold_left (fun s (cl,_) -> add_univars s cl) - TypeSet.empty old_univars - in - let tl1 = List.map repr tl1 and tl2 = List.map repr tl2 in - if List.exists (fun t -> TypeSet.mem t known_univars) tl1 && - univars_escape env old_univars tl1 (newty(Tpoly(t2,tl2))) - || List.exists (fun t -> TypeSet.mem t known_univars) tl2 && - univars_escape env old_univars tl2 (newty(Tpoly(t1,tl1))) - then raise (Unify []); - let cl1 = List.map (fun t -> t, ref None) tl1 - and cl2 = List.map (fun t -> t, ref None) tl2 in - univar_pairs := (cl1,cl2) :: (cl2,cl1) :: old_univars; - try let res = f t1 t2 in univar_pairs := old_univars; res - with exn -> univar_pairs := old_univars; raise exn +open Cmi_format +open Typedtree -let univar_pairs = ref [] +(* Note that in Typerex, there is an awful hack to save a cmt file + together with the interface file that was generated by ocaml (this + is because the installed version of ocaml might differ from the one + integrated in Typerex). +*) - (*****************) - (* Unification *) - (*****************) +let read_magic_number ic = + let len_magic_number = String.length Config.cmt_magic_number in + really_input_string ic len_magic_number +type binary_annots = + | Packed of Types.signature * string list + | Implementation of structure + | Interface of signature + | Partial_implementation of binary_part array + | Partial_interface of binary_part array -let rec has_cached_expansion p abbrev = - match abbrev with - Mnil -> false - | Mcons(_, p', _, _, rem) -> Path.same p p' || has_cached_expansion p rem - | Mlink rem -> has_cached_expansion p !rem +and binary_part = +| Partial_structure of structure +| Partial_structure_item of structure_item +| Partial_expression of expression +| Partial_pattern of pattern +| Partial_class_expr of class_expr +| Partial_signature of signature +| Partial_signature_item of signature_item +| Partial_module_type of module_type -(**** Transform error trace ****) -(* +++ Move it to some other place ? *) +type cmt_infos = { + cmt_modname : string; + cmt_annots : binary_annots; + cmt_value_dependencies : + (Types.value_description * Types.value_description) list; + cmt_comments : (string * Location.t) list; + cmt_args : string array; + cmt_sourcefile : string option; + cmt_builddir : string; + cmt_loadpath : string list; + cmt_source_digest : Digest.t option; + cmt_initial_env : Env.t; + cmt_imports : (string * Digest.t option) list; + cmt_interface_digest : Digest.t option; + cmt_use_summaries : bool; +} -let expand_trace env trace = - List.fold_right - (fun (t1, t2) rem -> - (repr t1, full_expand env t1)::(repr t2, full_expand env t2)::rem) - trace [] +type error = + Not_a_typedtree of string -(* build a dummy variant type *) -let mkvariant fields closed = - newgenty - (Tvariant - {row_fields = fields; row_closed = closed; row_more = newvar(); - row_bound = (); row_fixed = false; row_name = None }) +let need_to_clear_env = + try ignore (Sys.getenv "OCAML_BINANNOT_WITHENV"); false + with Not_found -> true -(**** Unification ****) +let keep_only_summary = Env.keep_only_summary -(* Return whether [t0] occurs in [ty]. Objects are also traversed. *) -let deep_occur t0 ty = - let rec occur_rec ty = - let ty = repr ty in - if ty.level >= lowest_level then begin - if ty == t0 then raise Occur; - ty.level <- pivot_level - ty.level; - iter_type_expr occur_rec ty - end - in - try - occur_rec ty; unmark_type ty; false - with Occur -> - unmark_type ty; true +open Tast_mapper -(* - 1. When unifying two non-abbreviated types, one type is made a link - to the other. When unifying an abbreviated type with a - non-abbreviated type, the non-abbreviated type is made a link to - the other one. When unifying to abbreviated types, these two - types are kept distincts, but they are made to (temporally) - expand to the same type. - 2. Abbreviations with at least one parameter are systematically - expanded. The overhead does not seem too high, and that way - abbreviations where some parameters does not appear in the - expansion, such as ['a t = int], are correctly handled. In - particular, for this example, unifying ['a t] with ['b t] keeps - ['a] and ['b] distincts. (Is it really important ?) - 3. Unifying an abbreviation ['a t = 'a] with ['a] should not yield - ['a t as 'a]. Indeed, the type variable would otherwise be lost. - This problem occurs for abbreviations expanding to a type - variable, but also to many other constrained abbreviations (for - instance, [(< x : 'a > -> unit) t = ]). The solution is - that, if an abbreviation is unified with some subpart of its - parameters, then the parameter actually does not get - abbreviated. It would be possible to check whether some - information is indeed lost, but it probably does not worth it. -*) +let cenv = + {Tast_mapper.default with env = fun _sub env -> keep_only_summary env} -let newtype_level = ref None +let clear_part = function + | Partial_structure s -> Partial_structure (cenv.structure cenv s) + | Partial_structure_item s -> + Partial_structure_item (cenv.structure_item cenv s) + | Partial_expression e -> Partial_expression (cenv.expr cenv e) + | Partial_pattern p -> Partial_pattern (cenv.pat cenv p) + | Partial_class_expr ce -> Partial_class_expr (cenv.class_expr cenv ce) + | Partial_signature s -> Partial_signature (cenv.signature cenv s) + | Partial_signature_item s -> + Partial_signature_item (cenv.signature_item cenv s) + | Partial_module_type s -> Partial_module_type (cenv.module_type cenv s) -let get_newtype_level () = - match !newtype_level with - | None -> assert false - | Some x -> x +let clear_env binary_annots = + if need_to_clear_env then + match binary_annots with + | Implementation s -> Implementation (cenv.structure cenv s) + | Interface s -> Interface (cenv.signature cenv s) + | Packed _ -> binary_annots + | Partial_implementation array -> + Partial_implementation (Array.map clear_part array) + | Partial_interface array -> + Partial_interface (Array.map clear_part array) -(* a local constraint can be added only if the rhs - of the constraint does not contain any Tvars. - They need to be removed using this function *) -let reify env t = - let newtype_level = get_newtype_level () in - let create_fresh_constr lev name = - let decl = new_declaration (Some (newtype_level, newtype_level)) None in - let name = match name with Some s -> "$'"^s | _ -> "$" in - let path = Path.Pident (Ident.create (get_new_abstract_name name)) in - let new_env = Env.add_local_type path decl !env in - let t = newty2 lev (Tconstr (path,[],ref Mnil)) in - env := new_env; - t - in - let visited = ref TypeSet.empty in - let rec iterator ty = - let ty = repr ty in - if TypeSet.mem ty !visited then () else begin - visited := TypeSet.add ty !visited; - match ty.desc with - Tvar o -> - let t = create_fresh_constr ty.level o in - link_type ty t; - if ty.level < newtype_level then - raise (Unify [t, newvar2 ty.level]) - | Tvariant r -> - let r = row_repr r in - if not (static_row r) then begin - if r.row_fixed then iterator (row_more r) else - let m = r.row_more in - match m.desc with - Tvar o -> - let t = create_fresh_constr m.level o in - let row = - {r with row_fields=[]; row_fixed=true; row_more = t} in - link_type m (newty2 m.level (Tvariant row)); - if m.level < newtype_level then - raise (Unify [t, newvar2 m.level]) - | _ -> assert false - end; - iter_row iterator r - | Tconstr (p, _, _) when is_object_type p -> - iter_type_expr iterator (full_expand !env ty) - | _ -> - iter_type_expr iterator ty - end - in - iterator t + else binary_annots -let is_newtype env p = - try - let decl = Env.find_type p env in - decl.type_newtype_level <> None && - decl.type_kind = Type_abstract && - decl.type_private = Public - with Not_found -> false +exception Error of error -let non_aliasable p decl = - (* in_pervasives p || (subsumed by in_current_module) *) - in_current_module p && decl.type_newtype_level = None +let input_cmt ic = (input_value ic : cmt_infos) -let is_instantiable env p = +let output_cmt oc cmt = + output_string oc Config.cmt_magic_number; + output_value oc (cmt : cmt_infos) + +let read filename = +(* Printf.fprintf stderr "Cmt_format.read %s\n%!" filename; *) + let ic = open_in_bin filename in try - let decl = Env.find_type p env in - decl.type_kind = Type_abstract && - decl.type_private = Public && - decl.type_arity = 0 && - decl.type_manifest = None && - not (non_aliasable p decl) - with Not_found -> false + let magic_number = read_magic_number ic in + let cmi, cmt = + if magic_number = Config.cmt_magic_number then + None, Some (input_cmt ic) + else if magic_number = Config.cmi_magic_number then + let cmi = Cmi_format.input_cmi ic in + let cmt = try + let magic_number = read_magic_number ic in + if magic_number = Config.cmt_magic_number then + let cmt = input_cmt ic in + Some cmt + else None + with _ -> None + in + Some cmi, cmt + else + raise(Cmi_format.Error(Cmi_format.Not_an_interface filename)) + in + close_in ic; +(* Printf.fprintf stderr "Cmt_format.read done\n%!"; *) + cmi, cmt + with e -> + close_in ic; + raise e +let read_cmt filename = + match read filename with + _, None -> raise (Error (Not_a_typedtree filename)) + | _, Some cmt -> cmt -(* PR#7113: -safe-string should be a global property *) -let compatible_paths p1 p2 = - let open Predef in - Path.same p1 p2 || - Path.same p1 path_bytes && Path.same p2 path_string || - Path.same p1 path_string && Path.same p2 path_bytes +let read_cmi filename = + match read filename with + None, _ -> + raise (Cmi_format.Error (Cmi_format.Not_an_interface filename)) + | Some cmi, _ -> cmi -(* Check for datatypes carefully; see PR#6348 *) -let rec expands_to_datatype env ty = - let ty = repr ty in - match ty.desc with - Tconstr (p, _, _) -> - begin try - is_datatype (Env.find_type p env) || - expands_to_datatype env (try_expand_once env ty) - with Not_found | Cannot_expand -> false - end - | _ -> false +let saved_types = ref [] +let value_deps = ref [] -(* mcomp type_pairs subst env t1 t2 does not raise an - exception if it is possible that t1 and t2 are actually - equal, assuming the types in type_pairs are equal and - that the mapping subst holds. - Assumes that both t1 and t2 do not contain any tvars - and that both their objects and variants are closed - *) +let clear () = + saved_types := []; + value_deps := [] -let rec mcomp type_pairs env t1 t2 = - if t1 == t2 then () else - let t1 = repr t1 in - let t2 = repr t2 in - if t1 == t2 then () else - match (t1.desc, t2.desc) with - | (Tvar _, _) - | (_, Tvar _) -> - () - | (Tconstr (p1, [], _), Tconstr (p2, [], _)) when Path.same p1 p2 -> - () - | _ -> - let t1' = expand_head_opt env t1 in - let t2' = expand_head_opt env t2 in - (* Expansion may have changed the representative of the types... *) - let t1' = repr t1' and t2' = repr t2' in - if t1' == t2' then () else - begin try TypePairs.find type_pairs (t1', t2') - with Not_found -> - TypePairs.add type_pairs (t1', t2') (); - match (t1'.desc, t2'.desc) with - (Tvar _, Tvar _) -> assert false - | (Tarrow (l1, t1, u1, _), Tarrow (l2, t2, u2, _)) - when l1 = l2 || not (is_optional l1 || is_optional l2) -> - mcomp type_pairs env t1 t2; - mcomp type_pairs env u1 u2; - | (Ttuple tl1, Ttuple tl2) -> - mcomp_list type_pairs env tl1 tl2 - | (Tconstr (p1, tl1, _), Tconstr (p2, tl2, _)) -> - mcomp_type_decl type_pairs env p1 p2 tl1 tl2 - | (Tconstr (p, _, _), _) | (_, Tconstr (p, _, _)) -> - begin try - let decl = Env.find_type p env in - if non_aliasable p decl || is_datatype decl then raise (Unify []) - with Not_found -> () - end - (* - | (Tpackage (p1, n1, tl1), Tpackage (p2, n2, tl2)) when n1 = n2 -> - mcomp_list type_pairs env tl1 tl2 - *) - | (Tpackage _, Tpackage _) -> () - | (Tvariant row1, Tvariant row2) -> - mcomp_row type_pairs env row1 row2 - | (Tobject (fi1, _), Tobject (fi2, _)) -> - mcomp_fields type_pairs env fi1 fi2 - | (Tfield _, Tfield _) -> (* Actually unused *) - mcomp_fields type_pairs env t1' t2' - | (Tnil, Tnil) -> - () - | (Tpoly (t1, []), Tpoly (t2, [])) -> - mcomp type_pairs env t1 t2 - | (Tpoly (t1, tl1), Tpoly (t2, tl2)) -> - enter_poly env univar_pairs t1 tl1 t2 tl2 - (mcomp type_pairs env) - | (Tunivar _, Tunivar _) -> - unify_univar t1' t2' !univar_pairs - | (_, _) -> - raise (Unify []) - end +let add_saved_type b = saved_types := b :: !saved_types +let get_saved_types () = !saved_types +let set_saved_types l = saved_types := l -and mcomp_list type_pairs env tl1 tl2 = - if List.length tl1 <> List.length tl2 then - raise (Unify []); - List.iter2 (mcomp type_pairs env) tl1 tl2 +let record_value_dependency vd1 vd2 = + if vd1.Types.val_loc <> vd2.Types.val_loc then + value_deps := (vd1, vd2) :: !value_deps -and mcomp_fields type_pairs env ty1 ty2 = - if not (concrete_object ty1 && concrete_object ty2) then assert false; - let (fields2, rest2) = flatten_fields ty2 in - let (fields1, rest1) = flatten_fields ty1 in - let (pairs, miss1, miss2) = associate_fields fields1 fields2 in - let has_present = - List.exists (fun (_, k, _) -> field_kind_repr k = Fpresent) in - mcomp type_pairs env rest1 rest2; - if has_present miss1 && (object_row ty2).desc = Tnil - || has_present miss2 && (object_row ty1).desc = Tnil then raise (Unify []); - List.iter - (function (_n, k1, t1, k2, t2) -> - mcomp_kind k1 k2; - mcomp type_pairs env t1 t2) - pairs +let save_cmt filename modname binary_annots sourcefile initial_env cmi = + if !Clflags.binary_annotations && not !Clflags.print_types then begin + (if !Clflags.bs_only then Misc.output_to_bin_file_directly else + Misc.output_to_file_via_temporary + ~mode:[Open_binary] ) filename + (fun temp_file_name oc -> + let this_crc = + match cmi with + | None -> None + | Some cmi -> Some (output_cmi temp_file_name oc cmi) + in + let source_digest = Misc.may_map Digest.file sourcefile in + let cmt = { + cmt_modname = modname; + cmt_annots = clear_env binary_annots; + cmt_value_dependencies = !value_deps; + cmt_comments = Lexer.comments (); + cmt_args = Sys.argv; + cmt_sourcefile = sourcefile; + cmt_builddir = Sys.getcwd (); + cmt_loadpath = !Config.load_path; + cmt_source_digest = source_digest; + cmt_initial_env = if need_to_clear_env then + keep_only_summary initial_env else initial_env; + cmt_imports = List.sort compare (Env.imports ()); + cmt_interface_digest = this_crc; + cmt_use_summaries = need_to_clear_env; + } in + output_cmt oc cmt) + end; + clear () -and mcomp_kind k1 k2 = - let k1 = field_kind_repr k1 in - let k2 = field_kind_repr k2 in - match k1, k2 with - (Fpresent, Fabsent) - | (Fabsent, Fpresent) -> raise (Unify []) - | _ -> () +end +module Ctype : sig +#1 "ctype.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -and mcomp_row type_pairs env row1 row2 = - let row1 = row_repr row1 and row2 = row_repr row2 in - let r1, r2, pairs = merge_row_fields row1.row_fields row2.row_fields in - let cannot_erase (_,f) = - match row_field_repr f with - Rpresent _ -> true - | Rabsent | Reither _ -> false - in - if row1.row_closed && List.exists cannot_erase r2 - || row2.row_closed && List.exists cannot_erase r1 then raise (Unify []); - List.iter - (fun (_,f1,f2) -> - match row_field_repr f1, row_field_repr f2 with - | Rpresent None, (Rpresent (Some _) | Reither (_, _::_, _, _) | Rabsent) - | Rpresent (Some _), (Rpresent None | Reither (true, _, _, _) | Rabsent) - | (Reither (_, _::_, _, _) | Rabsent), Rpresent None - | (Reither (true, _, _, _) | Rabsent), Rpresent (Some _) -> - raise (Unify []) - | Rpresent(Some t1), Rpresent(Some t2) -> - mcomp type_pairs env t1 t2 - | Rpresent(Some t1), Reither(false, tl2, _, _) -> - List.iter (mcomp type_pairs env t1) tl2 - | Reither(false, tl1, _, _), Rpresent(Some t2) -> - List.iter (mcomp type_pairs env t2) tl1 - | _ -> ()) - pairs +(* Operations on core types *) -and mcomp_type_decl type_pairs env p1 p2 tl1 tl2 = - try - let decl = Env.find_type p1 env in - let decl' = Env.find_type p2 env in - if compatible_paths p1 p2 then begin - let inj = - try List.map Variance.(mem Inj) (Env.find_type p1 env).type_variance - with Not_found -> List.map (fun _ -> false) tl1 - in - List.iter2 - (fun i (t1,t2) -> if i then mcomp type_pairs env t1 t2) - inj (List.combine tl1 tl2) - end else if non_aliasable p1 decl && non_aliasable p2 decl' then - raise (Unify []) - else - match decl.type_kind, decl'.type_kind with - | Type_record (lst,r), Type_record (lst',r') when r = r' -> - mcomp_list type_pairs env tl1 tl2; - mcomp_record_description type_pairs env lst lst' - | Type_variant v1, Type_variant v2 -> - mcomp_list type_pairs env tl1 tl2; - mcomp_variant_description type_pairs env v1 v2 - | Type_open, Type_open -> - mcomp_list type_pairs env tl1 tl2 - | Type_abstract, Type_abstract -> () - | Type_abstract, _ when not (non_aliasable p1 decl)-> () - | _, Type_abstract when not (non_aliasable p2 decl') -> () - | _ -> raise (Unify []) - with Not_found -> () +open Asttypes +open Types + +exception Unify of (type_expr * type_expr) list +exception Tags of label * label +exception Subtype of + (type_expr * type_expr) list * (type_expr * type_expr) list +exception Cannot_expand +exception Cannot_apply +exception Recursive_abbrev +exception Unification_recursive_abbrev of (type_expr * type_expr) list + +val init_def: int -> unit + (* Set the initial variable level *) +val begin_def: unit -> unit + (* Raise the variable level by one at the beginning of a definition. *) +val end_def: unit -> unit + (* Lower the variable level by one at the end of a definition *) +val begin_class_def: unit -> unit +val raise_nongen_level: unit -> unit +val reset_global_level: unit -> unit + (* Reset the global level before typing an expression *) +val increase_global_level: unit -> int +val restore_global_level: int -> unit + (* This pair of functions is only used in Typetexp *) +type levels = + { current_level: int; nongen_level: int; global_level: int; + saved_level: (int * int) list; } +val save_levels: unit -> levels +val set_levels: levels -> unit + +val newty: type_desc -> type_expr +val newvar: ?name:string -> unit -> type_expr +val newvar2: ?name:string -> int -> type_expr + (* Return a fresh variable *) +val new_global_var: ?name:string -> unit -> type_expr + (* Return a fresh variable, bound at toplevel + (as type variables ['a] in type constraints). *) +val newobj: type_expr -> type_expr +val newconstr: Path.t -> type_expr list -> type_expr +val none: type_expr + (* A dummy type expression *) + +val repr: type_expr -> type_expr + (* Return the canonical representative of a type. *) -and mcomp_type_option type_pairs env t t' = - match t, t' with - None, None -> () - | Some t, Some t' -> mcomp type_pairs env t t' - | _ -> raise (Unify []) +val object_fields: type_expr -> type_expr +val flatten_fields: + type_expr -> (string * field_kind * type_expr) list * type_expr + (* Transform a field type into a list of pairs label-type *) + (* The fields are sorted *) +val associate_fields: + (string * field_kind * type_expr) list -> + (string * field_kind * type_expr) list -> + (string * field_kind * type_expr * field_kind * type_expr) list * + (string * field_kind * type_expr) list * + (string * field_kind * type_expr) list +val opened_object: type_expr -> bool +val close_object: type_expr -> unit +val row_variable: type_expr -> type_expr + (* Return the row variable of an open object type *) +val set_object_name: + Ident.t -> type_expr -> type_expr list -> type_expr -> unit +val remove_object_name: type_expr -> unit +val hide_private_methods: type_expr -> unit +val find_cltype_for_path: Env.t -> Path.t -> type_declaration * type_expr +val lid_of_path: ?hash:string -> Path.t -> Longident.t -and mcomp_variant_description type_pairs env xs ys = - let rec iter = fun x y -> - match x, y with - | c1 :: xs, c2 :: ys -> - mcomp_type_option type_pairs env c1.cd_res c2.cd_res; - begin match c1.cd_args, c2.cd_args with - | Cstr_tuple l1, Cstr_tuple l2 -> mcomp_list type_pairs env l1 l2 - | Cstr_record l1, Cstr_record l2 -> - mcomp_record_description type_pairs env l1 l2 - | _ -> raise (Unify []) - end; - if Ident.name c1.cd_id = Ident.name c2.cd_id - then iter xs ys - else raise (Unify []) - | [],[] -> () - | _ -> raise (Unify []) - in - iter xs ys +val sort_row_fields: (label * row_field) list -> (label * row_field) list +val merge_row_fields: + (label * row_field) list -> (label * row_field) list -> + (label * row_field) list * (label * row_field) list * + (label * row_field * row_field) list +val filter_row_fields: + bool -> (label * row_field) list -> (label * row_field) list -and mcomp_record_description type_pairs env = - let rec iter x y = - match x, y with - | l1 :: xs, l2 :: ys -> - mcomp type_pairs env l1.ld_type l2.ld_type; - if Ident.name l1.ld_id = Ident.name l2.ld_id && - l1.ld_mutable = l2.ld_mutable - then iter xs ys - else raise (Unify []) - | [], [] -> () - | _ -> raise (Unify []) - in - iter +val generalize: type_expr -> unit + (* Generalize in-place the given type *) +val generalize_expansive: Env.t -> type_expr -> unit + (* Generalize the covariant part of a type, making + contravariant branches non-generalizable *) +val generalize_global: type_expr -> unit + (* Generalize the structure of a type, lowering variables + to !global_level *) +val generalize_structure: type_expr -> unit + (* Same, but variables are only lowered to !current_level *) +val generalize_spine: type_expr -> unit + (* Special function to generalize a method during inference *) +val correct_levels: type_expr -> type_expr + (* Returns a copy with decreasing levels *) +val limited_generalize: type_expr -> type_expr -> unit + (* Only generalize some part of the type + Make the remaining of the type non-generalizable *) -let mcomp env t1 t2 = - mcomp (TypePairs.create 4) env t1 t2 +val instance: ?partial:bool -> Env.t -> type_expr -> type_expr + (* Take an instance of a type scheme *) + (* partial=None -> normal + partial=false -> newvar() for non generic subterms + partial=true -> newty2 ty.level Tvar for non generic subterms *) +val instance_def: type_expr -> type_expr + (* use defaults *) +val generic_instance: Env.t -> type_expr -> type_expr + (* Same as instance, but new nodes at generic_level *) +val instance_list: Env.t -> type_expr list -> type_expr list + (* Take an instance of a list of type schemes *) +val instance_constructor: + ?in_pattern:Env.t ref * int -> + constructor_description -> type_expr list * type_expr + (* Same, for a constructor *) +val instance_parameterized_type: + ?keep_names:bool -> + type_expr list -> type_expr -> type_expr list * type_expr +val instance_parameterized_type_2: + type_expr list -> type_expr list -> type_expr -> + type_expr list * type_expr list * type_expr +val instance_declaration: type_declaration -> type_declaration +val instance_class: + type_expr list -> class_type -> type_expr list * class_type +val instance_poly: + ?keep_names:bool -> + bool -> type_expr list -> type_expr -> type_expr list * type_expr + (* Take an instance of a type scheme containing free univars *) +val instance_label: + bool -> label_description -> type_expr list * type_expr * type_expr + (* Same, for a label *) +val apply: + Env.t -> type_expr list -> type_expr -> type_expr list -> type_expr + (* [apply [p1...pN] t [a1...aN]] match the arguments [ai] to + the parameters [pi] and returns the corresponding instance of + [t]. Exception [Cannot_apply] is raised in case of failure. *) -(* Real unification *) +val expand_head_once: Env.t -> type_expr -> type_expr +val expand_head: Env.t -> type_expr -> type_expr +val try_expand_once_opt: Env.t -> type_expr -> type_expr +val expand_head_opt: Env.t -> type_expr -> type_expr +(** The compiler's own version of [expand_head] necessary for type-based + optimisations. *) -let find_lowest_level ty = - let lowest = ref generic_level in - let rec find ty = - let ty = repr ty in - if ty.level >= lowest_level then begin - if ty.level < !lowest then lowest := ty.level; - ty.level <- pivot_level - ty.level; - iter_type_expr find ty - end - in find ty; unmark_type ty; !lowest +val full_expand: Env.t -> type_expr -> type_expr +val extract_concrete_typedecl: + Env.t -> type_expr -> Path.t * Path.t * type_declaration + (* Return the original path of the types, and the first concrete + type declaration found expanding it. + Raise [Not_found] if none appears or not a type constructor. *) -let find_newtype_level env path = - try match (Env.find_type path env).type_newtype_level with - Some x -> x - | None -> raise Not_found - with Not_found -> let lev = Path.binding_time path in (lev, lev) +val enforce_constraints: Env.t -> type_expr -> unit -let add_gadt_equation env source destination = - if local_non_recursive_abbrev !env source destination then begin - let destination = duplicate_type destination in - let source_lev = find_newtype_level !env source in - let decl = new_declaration (Some source_lev) (Some destination) in - let newtype_level = get_newtype_level () in - env := Env.add_local_constraint source decl newtype_level !env; - cleanup_abbrev () - end +val unify: Env.t -> type_expr -> type_expr -> unit + (* Unify the two types given. Raise [Unify] if not possible. *) +val unify_gadt: newtype_level:int -> Env.t ref -> type_expr -> type_expr -> unit + (* Unify the two types given and update the environment with the + local constraints. Raise [Unify] if not possible. *) +val unify_var: Env.t -> type_expr -> type_expr -> unit + (* Same as [unify], but allow free univars when first type + is a variable. *) +val with_passive_variants: ('a -> 'b) -> ('a -> 'b) + (* Call [f] in passive_variants mode, for exhaustiveness check. *) +val filter_arrow: Env.t -> type_expr -> arg_label -> type_expr * type_expr + (* A special case of unification (with l:'a -> 'b). *) +val filter_method: Env.t -> string -> private_flag -> type_expr -> type_expr + (* A special case of unification (with {m : 'a; 'b}). *) +val check_filter_method: Env.t -> string -> private_flag -> type_expr -> unit + (* A special case of unification (with {m : 'a; 'b}), returning unit. *) +val occur_in: Env.t -> type_expr -> type_expr -> bool +val deep_occur: type_expr -> type_expr -> bool +val filter_self_method: + Env.t -> string -> private_flag -> (Ident.t * type_expr) Meths.t ref -> + type_expr -> Ident.t * type_expr +val moregeneral: Env.t -> bool -> type_expr -> type_expr -> bool + (* Check if the first type scheme is more general than the second. *) -let unify_eq_set = TypePairs.create 11 +val rigidify: type_expr -> type_expr list + (* "Rigidify" a type and return its type variable *) +val all_distinct_vars: Env.t -> type_expr list -> bool + (* Check those types are all distinct type variables *) +val matches: Env.t -> type_expr -> type_expr -> bool + (* Same as [moregeneral false], implemented using the two above + functions and backtracking. Ignore levels *) -let order_type_pair t1 t2 = - if t1.id <= t2.id then (t1, t2) else (t2, t1) +type class_match_failure = + CM_Virtual_class + | CM_Parameter_arity_mismatch of int * int + | CM_Type_parameter_mismatch of Env.t * (type_expr * type_expr) list + | CM_Class_type_mismatch of Env.t * class_type * class_type + | CM_Parameter_mismatch of Env.t * (type_expr * type_expr) list + | CM_Val_type_mismatch of string * Env.t * (type_expr * type_expr) list + | CM_Meth_type_mismatch of string * Env.t * (type_expr * type_expr) list + | CM_Non_mutable_value of string + | CM_Non_concrete_value of string + | CM_Missing_value of string + | CM_Missing_method of string + | CM_Hide_public of string + | CM_Hide_virtual of string * string + | CM_Public_method of string + | CM_Private_method of string + | CM_Virtual_method of string +val match_class_types: + ?trace:bool -> Env.t -> class_type -> class_type -> class_match_failure list + (* Check if the first class type is more general than the second. *) +val equal: Env.t -> bool -> type_expr list -> type_expr list -> bool + (* [equal env [x1...xn] tau [y1...yn] sigma] + checks whether the parameterized types + [/\x1.../\xn.tau] and [/\y1.../\yn.sigma] are equivalent. *) +val match_class_declarations: + Env.t -> type_expr list -> class_type -> type_expr list -> + class_type -> class_match_failure list + (* Check if the first class type is more general than the second. *) -let add_type_equality t1 t2 = - TypePairs.add unify_eq_set (order_type_pair t1 t2) () +val enlarge_type: Env.t -> type_expr -> type_expr * bool + (* Make a type larger, flag is true if some pruning had to be done *) +val subtype: Env.t -> type_expr -> type_expr -> unit -> unit + (* [subtype env t1 t2] checks that [t1] is a subtype of [t2]. + It accumulates the constraints the type variables must + enforce and returns a function that enforces this + constraints. *) -let eq_package_path env p1 p2 = - Path.same p1 p2 || - Path.same (normalize_package_path env p1) (normalize_package_path env p2) +val nondep_type: Env.t -> Ident.t -> type_expr -> type_expr + (* Return a type equivalent to the given type but without + references to the given module identifier. Raise [Not_found] + if no such type exists. *) +val nondep_type_decl: + Env.t -> Ident.t -> Ident.t -> bool -> type_declaration -> + type_declaration + (* Same for type declarations. *) +val nondep_extension_constructor: + Env.t -> Ident.t -> extension_constructor -> + extension_constructor + (* Same for extension constructor *) +val nondep_class_declaration: + Env.t -> Ident.t -> class_declaration -> class_declaration + (* Same for class declarations. *) +val nondep_cltype_declaration: + Env.t -> Ident.t -> class_type_declaration -> class_type_declaration + (* Same for class type declarations. *) +(*val correct_abbrev: Env.t -> Path.t -> type_expr list -> type_expr -> unit*) +val cyclic_abbrev: Env.t -> Ident.t -> type_expr -> bool +val is_contractive: Env.t -> Path.t -> bool +val normalize_type: Env.t -> type_expr -> unit -let nondep_type' = ref (fun _ _ _ -> assert false) -let package_subtype = ref (fun _ _ _ _ _ _ _ -> assert false) +val closed_schema: Env.t -> type_expr -> bool + (* Check whether the given type scheme contains no non-generic + type variables *) -let rec concat_longident lid1 = - let open Longident in - function - Lident s -> Ldot (lid1, s) - | Ldot (lid2, s) -> Ldot (concat_longident lid1 lid2, s) - | Lapply (lid2, lid) -> Lapply (concat_longident lid1 lid2, lid) +val free_variables: ?env:Env.t -> type_expr -> type_expr list + (* If env present, then check for incomplete definitions too *) +val closed_type_decl: type_declaration -> type_expr option +val closed_extension_constructor: extension_constructor -> type_expr option +type closed_class_failure = + CC_Method of type_expr * bool * string * type_expr + | CC_Value of type_expr * bool * string * type_expr +val closed_class: + type_expr list -> class_signature -> closed_class_failure option + (* Check whether all type variables are bound *) -let nondep_instance env level id ty = - let ty = !nondep_type' env id ty in - if level = generic_level then duplicate_type ty else - let old = !current_level in - current_level := level; - let ty = instance env ty in - current_level := old; - ty +val unalias: type_expr -> type_expr +val signature_of_class_type: class_type -> class_signature +val self_type: class_type -> type_expr +val class_type_arity: class_type -> int +val arity: type_expr -> int + (* Return the arity (as for curried functions) of the given type. *) -(* Find the type paths nl1 in the module type mty2, and add them to the - list (nl2, tl2). raise Not_found if impossible *) -let complete_type_list ?(allow_absent=false) env nl1 lv2 mty2 nl2 tl2 = - let id2 = Ident.create "Pkg" in - let env' = Env.add_module id2 mty2 env in - let rec complete nl1 ntl2 = - match nl1, ntl2 with - [], _ -> ntl2 - | n :: nl, (n2, _ as nt2) :: ntl' when n >= n2 -> - nt2 :: complete (if n = n2 then nl else nl1) ntl' - | n :: nl, _ -> - try - let path = - Env.lookup_type (concat_longident (Longident.Lident "Pkg") n) env' - in - match Env.find_type path env' with - {type_arity = 0; type_kind = Type_abstract; - type_private = Public; type_manifest = Some t2} -> - (n, nondep_instance env' lv2 id2 t2) :: complete nl ntl2 - | {type_arity = 0; type_kind = Type_abstract; - type_private = Public; type_manifest = None} when allow_absent -> - complete nl ntl2 - | _ -> raise Exit - with - | Not_found when allow_absent -> complete nl ntl2 - | Exit -> raise Not_found - in - complete nl1 (List.combine nl2 tl2) +val collapse_conj_params: Env.t -> type_expr list -> unit + (* Collapse conjunctive types in class parameters *) -(* raise Not_found rather than Unify if the module types are incompatible *) -let unify_package env unify_list lv1 p1 n1 tl1 lv2 p2 n2 tl2 = - let ntl2 = complete_type_list env n1 lv2 (Mty_ident p2) n2 tl2 - and ntl1 = complete_type_list env n2 lv1 (Mty_ident p1) n1 tl1 in - unify_list (List.map snd ntl1) (List.map snd ntl2); - if eq_package_path env p1 p2 - || !package_subtype env p1 n1 tl1 p2 n2 tl2 - && !package_subtype env p2 n2 tl2 p1 n1 tl1 then () else raise Not_found +val get_current_level: unit -> int +val wrap_trace_gadt_instances: Env.t -> ('a -> 'b) -> 'a -> 'b +val reset_reified_var_counter: unit -> unit +val maybe_pointer_type : Env.t -> type_expr -> bool + (* True if type is possibly pointer, false if definitely not a pointer *) -(* force unification in Reither when one side has a non-conjunctive type *) -let rigid_variants = ref false +(* Stubs *) +val package_subtype : + (Env.t -> Path.t -> Longident.t list -> type_expr list -> + Path.t -> Longident.t list -> type_expr list -> bool) ref -(* drop not force unification in Reither, even in fixed case - (not sound, only use it when checking exhaustiveness) *) -let passive_variants = ref false -let with_passive_variants f x = - if !passive_variants then f x else - match passive_variants := true; f x with - | r -> passive_variants := false; r - | exception e -> passive_variants := false; raise e +end = struct +#1 "ctype.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy and Jerome Vouillon, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -let unify_eq t1 t2 = - t1 == t2 || - match !umode with - | Expression -> false - | Pattern -> - try TypePairs.find unify_eq_set (order_type_pair t1 t2); true - with Not_found -> false +(* Operations on core types *) -let unify1_var env t1 t2 = - assert (is_Tvar t1); - occur env t1 t2; - occur_univar env t2; - let d1 = t1.desc in - link_type t1 t2; - try - update_level env t1.level t2 - with Unify _ as e -> - t1.desc <- d1; - raise e +open Misc +open Asttypes +open Types +open Btype -let rec unify (env:Env.t ref) t1 t2 = - (* First step: special cases (optimizations) *) - if t1 == t2 then () else - let t1 = repr t1 in - let t2 = repr t2 in - if unify_eq t1 t2 then () else - let reset_tracing = check_trace_gadt_instances !env in +(* + Type manipulation after type inference + ====================================== + If one wants to manipulate a type after type inference (for + instance, during code generation or in the debugger), one must + first make sure that the type levels are correct, using the + function [correct_levels]. Then, this type can be correctly + manipulated by [apply], [expand_head] and [moregeneral]. +*) - try - type_changed := true; - begin match (t1.desc, t2.desc) with - (Tvar _, Tconstr _) when deep_occur t1 t2 -> - unify2 env t1 t2 - | (Tconstr _, Tvar _) when deep_occur t2 t1 -> - unify2 env t1 t2 - | (Tvar _, _) -> - unify1_var !env t1 t2 - | (_, Tvar _) -> - unify1_var !env t2 t1 - | (Tunivar _, Tunivar _) -> - unify_univar t1 t2 !univar_pairs; - update_level !env t1.level t2; - link_type t1 t2 - | (Tconstr (p1, [], a1), Tconstr (p2, [], a2)) - when Path.same p1 p2 (* && actual_mode !env = Old *) - (* This optimization assumes that t1 does not expand to t2 - (and conversely), so we fall back to the general case - when any of the types has a cached expansion. *) - && not (has_cached_expansion p1 !a1 - || has_cached_expansion p2 !a2) -> - update_level !env t1.level t2; - link_type t1 t2 - | (Tconstr (p1, [], _), Tconstr (p2, [], _)) - when Env.has_local_constraints !env - && is_newtype !env p1 && is_newtype !env p2 -> - (* Do not use local constraints more than necessary *) - begin try - if find_newtype_level !env p1 < find_newtype_level !env p2 then - unify env t1 (try_expand_once !env t2) - else - unify env (try_expand_once !env t1) t2 - with Cannot_expand -> - unify2 env t1 t2 - end - | _ -> - unify2 env t1 t2 - end; - reset_trace_gadt_instances reset_tracing; - with Unify trace -> - reset_trace_gadt_instances reset_tracing; - raise (Unify ((t1, t2)::trace)) +(* + General notes + ============= + - As much sharing as possible should be kept : it makes types + smaller and better abbreviated. + When necessary, some sharing can be lost. Types will still be + printed correctly (+++ TO DO...), and abbreviations defined by a + class do not depend on sharing thanks to constrained + abbreviations. (Of course, even if some sharing is lost, typing + will still be correct.) + - All nodes of a type have a level : that way, one know whether a + node need to be duplicated or not when instantiating a type. + - Levels of a type are decreasing (generic level being considered + as greatest). + - The level of a type constructor is superior to the binding + time of its path. + - Recursive types without limitation should be handled (even if + there is still an occur check). This avoid treating specially the + case for objects, for instance. Furthermore, the occur check + policy can then be easily changed. +*) -and unify2 env t1 t2 = - (* Second step: expansion of abbreviations *) - (* Expansion may change the representative of the types. *) - ignore (expand_head_unif !env t1); - ignore (expand_head_unif !env t2); - let t1' = expand_head_unif !env t1 in - let t2' = expand_head_unif !env t2 in - let lv = min t1'.level t2'.level in - update_level !env lv t2; - update_level !env lv t1; - if unify_eq t1' t2' then () else +(**** Errors ****) - let t1 = repr t1 and t2 = repr t2 in - if !trace_gadt_instances then begin - (* All types in chains already have the same ambiguity levels *) - let ilevel t = - match Env.gadt_instance_level !env t with None -> 0 | Some lv -> lv in - let lv1 = ilevel t1 and lv2 = ilevel t2 in - if lv1 > lv2 then Env.add_gadt_instance_chain !env lv1 t2 else - if lv2 > lv1 then Env.add_gadt_instance_chain !env lv2 t1 - end; - let t1, t2 = - if !Clflags.principal - && (find_lowest_level t1' < lv || find_lowest_level t2' < lv) then - (* Expand abbreviations hiding a lower level *) - (* Should also do it for parameterized types, after unification... *) - (match t1.desc with Tconstr (_, [], _) -> t1' | _ -> t1), - (match t2.desc with Tconstr (_, [], _) -> t2' | _ -> t2) - else (t1, t2) - in - if unify_eq t1 t1' || not (unify_eq t2 t2') then - unify3 env t1 t1' t2 t2' - else - try unify3 env t2 t2' t1 t1' with Unify trace -> - raise (Unify (List.map (fun (x, y) -> (y, x)) trace)) +exception Unify of (type_expr * type_expr) list + +exception Tags of label * label + +let () = + Location.register_error_of_exn + (function + | Tags (l, l') -> + Some + Location. + (errorf ~loc:(in_file !input_name) + "In this program,@ variant constructors@ `%s and `%s@ \ + have the same hash value.@ Change one of them." l l' + ) + | _ -> None + ) -and unify3 env t1 t1' t2 t2' = - (* Third step: truly unification *) - (* Assumes either [t1 == t1'] or [t2 != t2'] *) - let d1 = t1'.desc and d2 = t2'.desc in - let create_recursion = (t2 != t2') && (deep_occur t1' t2) in +exception Subtype of + (type_expr * type_expr) list * (type_expr * type_expr) list - begin match (d1, d2) with (* handle vars and univars specially *) - (Tunivar _, Tunivar _) -> - unify_univar t1' t2' !univar_pairs; - link_type t1' t2' - | (Tvar _, _) -> - occur !env t1' t2; - occur_univar !env t2; - link_type t1' t2; - | (_, Tvar _) -> - occur !env t2' t1; - occur_univar !env t1; - link_type t2' t1; - | (Tfield _, Tfield _) -> (* special case for GADTs *) - unify_fields env t1' t2' - | _ -> - begin match !umode with - | Expression -> - occur !env t1' t2'; - link_type t1' t2 - | Pattern -> - add_type_equality t1' t2' - end; - try - begin match (d1, d2) with - (Tarrow (l1, t1, u1, c1), Tarrow (l2, t2, u2, c2)) when l1 = l2 || - (!Clflags.classic || !umode = Pattern) && - not (is_optional l1 || is_optional l2) -> - unify env t1 t2; unify env u1 u2; - begin match commu_repr c1, commu_repr c2 with - Clink r, c2 -> set_commu r c2 - | c1, Clink r -> set_commu r c1 - | _ -> () - end - | (Ttuple tl1, Ttuple tl2) -> - unify_list env tl1 tl2 - | (Tconstr (p1, tl1, _), Tconstr (p2, tl2, _)) when Path.same p1 p2 -> - if !umode = Expression || not !generate_equations then - unify_list env tl1 tl2 - else if !assume_injective then - set_mode_pattern ~generate:true ~injective:false - (fun () -> unify_list env tl1 tl2) - else if in_current_module p1 (* || in_pervasives p1 *) - || List.exists (expands_to_datatype !env) [t1'; t1; t2] then - unify_list env tl1 tl2 - else - let inj = - try List.map Variance.(mem Inj) - (Env.find_type p1 !env).type_variance - with Not_found -> List.map (fun _ -> false) tl1 - in - List.iter2 - (fun i (t1, t2) -> - if i then unify env t1 t2 else - set_mode_pattern ~generate:false ~injective:false - begin fun () -> - let snap = snapshot () in - try unify env t1 t2 with Unify _ -> - backtrack snap; - reify env t1; reify env t2 - end) - inj (List.combine tl1 tl2) - | (Tconstr (path,[],_), - Tconstr (path',[],_)) - when is_instantiable !env path && is_instantiable !env path' - && !generate_equations -> - let source, destination = - if find_newtype_level !env path > find_newtype_level !env path' - then path , t2' - else path', t1' - in - add_gadt_equation env source destination - | (Tconstr (path,[],_), _) - when is_instantiable !env path && !generate_equations -> - reify env t2'; - add_gadt_equation env path t2' - | (_, Tconstr (path,[],_)) - when is_instantiable !env path && !generate_equations -> - reify env t1'; - add_gadt_equation env path t1' - | (Tconstr (_,_,_), _) | (_, Tconstr (_,_,_)) when !umode = Pattern -> - reify env t1'; - reify env t2'; - if !generate_equations then mcomp !env t1' t2' - | (Tobject (fi1, nm1), Tobject (fi2, _)) -> - unify_fields env fi1 fi2; - (* Type [t2'] may have been instantiated by [unify_fields] *) - (* XXX One should do some kind of unification... *) - begin match (repr t2').desc with - Tobject (_, {contents = Some (_, va::_)}) when - (match (repr va).desc with - Tvar _|Tunivar _|Tnil -> true | _ -> false) -> () - | Tobject (_, nm2) -> set_name nm2 !nm1 - | _ -> () - end - | (Tvariant row1, Tvariant row2) -> - if !umode = Expression then - unify_row env row1 row2 - else begin - let snap = snapshot () in - try unify_row env row1 row2 - with Unify _ -> - backtrack snap; - reify env t1'; - reify env t2'; - if !generate_equations then mcomp !env t1' t2' - end - | (Tfield(f,kind,_,rem), Tnil) | (Tnil, Tfield(f,kind,_,rem)) -> - begin match field_kind_repr kind with - Fvar r when f <> dummy_method -> - set_kind r Fabsent; - if d2 = Tnil then unify env rem t2' - else unify env (newty2 rem.level Tnil) rem - | _ -> raise (Unify []) - end - | (Tnil, Tnil) -> - () - | (Tpoly (t1, []), Tpoly (t2, [])) -> - unify env t1 t2 - | (Tpoly (t1, tl1), Tpoly (t2, tl2)) -> - enter_poly !env univar_pairs t1 tl1 t2 tl2 (unify env) - | (Tpackage (p1, n1, tl1), Tpackage (p2, n2, tl2)) -> - begin try - unify_package !env (unify_list env) - t1.level p1 n1 tl1 t2.level p2 n2 tl2 - with Not_found -> - if !umode = Expression then raise (Unify []); - List.iter (reify env) (tl1 @ tl2); - (* if !generate_equations then List.iter2 (mcomp !env) tl1 tl2 *) - end - | (_, _) -> - raise (Unify []) - end; - (* XXX Commentaires + changer "create_recursion" - ||| Comments + change "create_recursion" *) - if create_recursion then - match t2.desc with - Tconstr (p, tl, abbrev) -> - forget_abbrev abbrev p; - let t2'' = expand_head_unif !env t2 in - if not (closed_parameterized_type tl t2'') then - link_type (repr t2) (repr t2') - | _ -> - () (* t2 has already been expanded by update_level *) - with Unify trace -> - t1'.desc <- d1; - raise (Unify trace) - end +exception Cannot_expand -and unify_list env tl1 tl2 = - if List.length tl1 <> List.length tl2 then - raise (Unify []); - List.iter2 (unify env) tl1 tl2 +exception Cannot_apply -(* Build a fresh row variable for unification *) -and make_rowvar level use1 rest1 use2 rest2 = - let set_name ty name = - match ty.desc with - Tvar None -> log_type ty; ty.desc <- Tvar name - | _ -> () - in - let name = - match rest1.desc, rest2.desc with - Tvar (Some _ as name1), Tvar (Some _ as name2) -> - if rest1.level <= rest2.level then name1 else name2 - | Tvar (Some _ as name), _ -> - if use2 then set_name rest2 name; name - | _, Tvar (Some _ as name) -> - if use1 then set_name rest2 name; name - | _ -> None - in - if use1 then rest1 else - if use2 then rest2 else newvar2 ?name level +exception Recursive_abbrev -and unify_fields env ty1 ty2 = (* Optimization *) - let (fields1, rest1) = flatten_fields ty1 - and (fields2, rest2) = flatten_fields ty2 in - let (pairs, miss1, miss2) = associate_fields fields1 fields2 in - let l1 = (repr ty1).level and l2 = (repr ty2).level in - let va = make_rowvar (min l1 l2) (miss2=[]) rest1 (miss1=[]) rest2 in - let d1 = rest1.desc and d2 = rest2.desc in - try - unify env (build_fields l1 miss1 va) rest2; - unify env rest1 (build_fields l2 miss2 va); - List.iter - (fun (n, k1, t1, k2, t2) -> - unify_kind k1 k2; - try - if !trace_gadt_instances then update_level !env va.level t1; - unify env t1 t2 - with Unify trace -> - raise (Unify ((newty (Tfield(n, k1, t1, newty Tnil)), - newty (Tfield(n, k2, t2, newty Tnil)))::trace))) - pairs - with exn -> - log_type rest1; rest1.desc <- d1; - log_type rest2; rest2.desc <- d2; - raise exn +(* GADT: recursive abbrevs can appear as a result of local constraints *) +exception Unification_recursive_abbrev of (type_expr * type_expr) list -and unify_kind k1 k2 = - let k1 = field_kind_repr k1 in - let k2 = field_kind_repr k2 in - if k1 == k2 then () else - match k1, k2 with - (Fvar r, (Fvar _ | Fpresent)) -> set_kind r k2 - | (Fpresent, Fvar r) -> set_kind r k1 - | (Fpresent, Fpresent) -> () - | _ -> assert false +(**** Type level management ****) -and unify_row env row1 row2 = - let row1 = row_repr row1 and row2 = row_repr row2 in - let rm1 = row_more row1 and rm2 = row_more row2 in - if unify_eq rm1 rm2 then () else - let r1, r2, pairs = merge_row_fields row1.row_fields row2.row_fields in - if r1 <> [] && r2 <> [] then begin - let ht = Hashtbl.create (List.length r1) in - List.iter (fun (l,_) -> Hashtbl.add ht (hash_variant l) l) r1; - List.iter - (fun (l,_) -> - try raise (Tags(l, Hashtbl.find ht (hash_variant l))) - with Not_found -> ()) - r2 - end; - let fixed1 = row_fixed row1 and fixed2 = row_fixed row2 in - let more = - if fixed1 then rm1 else - if fixed2 then rm2 else - newty2 (min rm1.level rm2.level) (Tvar None) in - let fixed = fixed1 || fixed2 - and closed = row1.row_closed || row2.row_closed in - let keep switch = - List.for_all - (fun (_,f1,f2) -> - let f1, f2 = switch f1 f2 in - row_field_repr f1 = Rabsent || row_field_repr f2 <> Rabsent) - pairs - in - let empty fields = - List.for_all (fun (_,f) -> row_field_repr f = Rabsent) fields in - (* Check whether we are going to build an empty type *) - if closed && (empty r1 || row2.row_closed) && (empty r2 || row1.row_closed) - && List.for_all - (fun (_,f1,f2) -> - row_field_repr f1 = Rabsent || row_field_repr f2 = Rabsent) - pairs - then raise (Unify [mkvariant [] true, mkvariant [] true]); - let name = - if row1.row_name <> None && (row1.row_closed || empty r2) && - (not row2.row_closed || keep (fun f1 f2 -> f1, f2) && empty r1) - then row1.row_name - else if row2.row_name <> None && (row2.row_closed || empty r1) && - (not row1.row_closed || keep (fun f1 f2 -> f2, f1) && empty r2) - then row2.row_name - else None - in - let row0 = {row_fields = []; row_more = more; row_bound = (); - row_closed = closed; row_fixed = fixed; row_name = name} in - let set_more row rest = - let rest = - if closed then - filter_row_fields row.row_closed rest - else rest in - if rest <> [] && (row.row_closed || row_fixed row) - || closed && row_fixed row && not row.row_closed then begin - let t1 = mkvariant [] true and t2 = mkvariant rest false in - raise (Unify [if row == row1 then (t1,t2) else (t2,t1)]) - end; - (* The following test is not principal... should rather use Tnil *) - let rm = row_more row in - (*if !trace_gadt_instances && rm.desc = Tnil then () else*) - if !trace_gadt_instances then - update_level !env rm.level (newgenty (Tvariant row)); - if row_fixed row then - if more == rm then () else - if is_Tvar rm then link_type rm more else unify env rm more - else - let ty = newgenty (Tvariant {row0 with row_fields = rest}) in - update_level !env rm.level ty; - link_type rm ty - in - let md1 = rm1.desc and md2 = rm2.desc in - begin try - set_more row2 r1; - set_more row1 r2; - List.iter - (fun (l,f1,f2) -> - try unify_row_field env fixed1 fixed2 more l f1 f2 - with Unify trace -> - raise (Unify ((mkvariant [l,f1] true, - mkvariant [l,f2] true) :: trace))) - pairs; - if static_row row1 then begin - let rm = row_more row1 in - if is_Tvar rm then link_type rm (newty2 rm.level Tnil) - end - with exn -> - log_type rm1; rm1.desc <- md1; log_type rm2; rm2.desc <- md2; raise exn - end +let current_level = ref 0 +let nongen_level = ref 0 +let global_level = ref 1 +let saved_level = ref [] -and unify_row_field env fixed1 fixed2 more l f1 f2 = - let f1 = row_field_repr f1 and f2 = row_field_repr f2 in - if f1 == f2 then () else - match f1, f2 with - Rpresent(Some t1), Rpresent(Some t2) -> unify env t1 t2 - | Rpresent None, Rpresent None -> () - | Reither(c1, tl1, m1, e1), Reither(c2, tl2, m2, e2) -> - if e1 == e2 then () else - if (fixed1 || fixed2) && not (c1 || c2) - && List.length tl1 = List.length tl2 then begin - (* PR#7496 *) - let f = Reither (c1 || c2, [], m1 || m2, ref None) in - set_row_field e1 f; set_row_field e2 f; - List.iter2 (unify env) tl1 tl2 - end - else let redo = - not !passive_variants && - (m1 || m2 || fixed1 || fixed2 || - !rigid_variants && (List.length tl1 = 1 || List.length tl2 = 1)) && - begin match tl1 @ tl2 with [] -> false - | t1 :: tl -> - if c1 || c2 then raise (Unify []); - List.iter (unify env t1) tl; - !e1 <> None || !e2 <> None - end in - if redo then unify_row_field env fixed1 fixed2 more l f1 f2 else - let tl1 = List.map repr tl1 and tl2 = List.map repr tl2 in - let rec remq tl = function [] -> [] - | ty :: tl' -> - if List.memq ty tl then remq tl tl' else ty :: remq tl tl' - in - let tl2' = remq tl2 tl1 and tl1' = remq tl1 tl2 in - (* PR#6744 *) - let split_univars = - List.partition - (fun ty -> try occur_univar !env ty; true with Unify _ -> false) in - let (tl1',tlu1) = split_univars tl1' - and (tl2',tlu2) = split_univars tl2' in - begin match tlu1, tlu2 with - [], [] -> () - | (tu1::tlu1), _ :: _ -> - (* Attempt to merge all the types containing univars *) - if not !passive_variants then - List.iter (unify env tu1) (tlu1@tlu2) - | (tu::_, []) | ([], tu::_) -> occur_univar !env tu - end; - (* Is this handling of levels really principal? *) - List.iter (update_level !env (repr more).level) (tl1' @ tl2'); - let e = ref None in - let f1' = Reither(c1 || c2, tl1', m1 || m2, e) - and f2' = Reither(c1 || c2, tl2', m1 || m2, e) in - set_row_field e1 f1'; set_row_field e2 f2'; - | Reither(_, _, false, e1), Rabsent when not fixed1 -> set_row_field e1 f2 - | Rabsent, Reither(_, _, false, e2) when not fixed2 -> set_row_field e2 f1 - | Rabsent, Rabsent -> () - | Reither(false, tl, _, e1), Rpresent(Some t2) when not fixed1 -> - set_row_field e1 f2; - update_level !env (repr more).level t2; - (try List.iter (fun t1 -> unify env t1 t2) tl - with exn -> e1 := None; raise exn) - | Rpresent(Some t1), Reither(false, tl, _, e2) when not fixed2 -> - set_row_field e2 f1; - update_level !env (repr more).level t1; - (try List.iter (unify env t1) tl - with exn -> e2 := None; raise exn) - | Reither(true, [], _, e1), Rpresent None when not fixed1 -> - set_row_field e1 f2 - | Rpresent None, Reither(true, [], _, e2) when not fixed2 -> - set_row_field e2 f1 - | _ -> raise (Unify []) +type levels = + { current_level: int; nongen_level: int; global_level: int; + saved_level: (int * int) list; } +let save_levels () = + { current_level = !current_level; + nongen_level = !nongen_level; + global_level = !global_level; + saved_level = !saved_level } +let set_levels l = + current_level := l.current_level; + nongen_level := l.nongen_level; + global_level := l.global_level; + saved_level := l.saved_level +let get_current_level () = !current_level +let init_def level = current_level := level; nongen_level := level +let begin_def () = + saved_level := (!current_level, !nongen_level) :: !saved_level; + incr current_level; nongen_level := !current_level +let begin_class_def () = + saved_level := (!current_level, !nongen_level) :: !saved_level; + incr current_level +let raise_nongen_level () = + saved_level := (!current_level, !nongen_level) :: !saved_level; + nongen_level := !current_level +let end_def () = + let (cl, nl) = List.hd !saved_level in + saved_level := List.tl !saved_level; + current_level := cl; nongen_level := nl -let unify env ty1 ty2 = - let snap = Btype.snapshot () in - try - unify env ty1 ty2 - with - Unify trace -> - undo_compress snap; - raise (Unify (expand_trace !env trace)) - | Recursive_abbrev -> - undo_compress snap; - raise (Unification_recursive_abbrev (expand_trace !env [(ty1,ty2)])) +let reset_global_level () = + global_level := !current_level + 1 +let increase_global_level () = + let gl = !global_level in + global_level := !current_level; + gl +let restore_global_level gl = + global_level := gl -let unify_gadt ~newtype_level:lev (env:Env.t ref) ty1 ty2 = - try - univar_pairs := []; - newtype_level := Some lev; - set_mode_pattern ~generate:true ~injective:true - (fun () -> unify env ty1 ty2); - newtype_level := None; - TypePairs.clear unify_eq_set; - with e -> - newtype_level := None; - TypePairs.clear unify_eq_set; - raise e +(**** Whether a path points to an object type (with hidden row variable) ****) +let is_object_type path = + let name = + match path with Path.Pident id -> Ident.name id + | Path.Pdot(_, s,_) -> s + | Path.Papply _ -> assert false + in name.[0] = '#' -let unify_var env t1 t2 = - let t1 = repr t1 and t2 = repr t2 in - if t1 == t2 then () else - match t1.desc, t2.desc with - Tvar _, Tconstr _ when deep_occur t1 t2 -> - unify (ref env) t1 t2 - | Tvar _, _ -> - let reset_tracing = check_trace_gadt_instances env in - begin try - occur env t1 t2; - update_level env t1.level t2; - link_type t1 t2; - reset_trace_gadt_instances reset_tracing; - with Unify trace -> - reset_trace_gadt_instances reset_tracing; - let expanded_trace = expand_trace env ((t1,t2)::trace) in - raise (Unify expanded_trace) - end - | _ -> - unify (ref env) t1 t2 +(**** Control tracing of GADT instances *) -let _ = unify' := unify_var +let trace_gadt_instances = ref false +let check_trace_gadt_instances env = + not !trace_gadt_instances && Env.has_local_constraints env && + (trace_gadt_instances := true; cleanup_abbrev (); true) -let unify_pairs env ty1 ty2 pairs = - univar_pairs := pairs; - unify env ty1 ty2 +let reset_trace_gadt_instances b = + if b then trace_gadt_instances := false -let unify env ty1 ty2 = - unify_pairs (ref env) ty1 ty2 [] +let wrap_trace_gadt_instances env f x = + let b = check_trace_gadt_instances env in + let y = f x in + reset_trace_gadt_instances b; + y +(**** Abbreviations without parameters ****) +(* Shall reset after generalizing *) +let simple_abbrevs = ref Mnil -(**** Special cases of unification ****) +let proper_abbrevs path tl abbrev = + if tl <> [] || !trace_gadt_instances || !Clflags.principal || + is_object_type path + then abbrev + else simple_abbrevs -let expand_head_trace env t = - let reset_tracing = check_trace_gadt_instances env in - let t = expand_head_unif env t in - reset_trace_gadt_instances reset_tracing; - t +(**** Some type creators ****) -(* - Unify [t] and [l:'a -> 'b]. Return ['a] and ['b]. - In label mode, label mismatch is accepted when - (1) the requested label is "" - (2) the original label is not optional -*) +(* Re-export generic type creators *) + +let newty2 = Btype.newty2 +let newty desc = newty2 !current_level desc + +let newvar ?name () = newty2 !current_level (Tvar name) +let newvar2 ?name level = newty2 level (Tvar name) +let new_global_var ?name () = newty2 !global_level (Tvar name) -let filter_arrow env t l = - let t = expand_head_trace env t in - match t.desc with - Tvar _ -> - let lv = t.level in - let t1 = newvar2 lv and t2 = newvar2 lv in - let t' = newty2 lv (Tarrow (l, t1, t2, Cok)) in - link_type t t'; - (t1, t2) - | Tarrow(l', t1, t2, _) - when l = l' || !Clflags.classic && l = Nolabel && not (is_optional l') -> - (t1, t2) - | _ -> - raise (Unify []) +let newobj fields = newty (Tobject (fields, ref None)) -(* Used by [filter_method]. *) -let rec filter_method_field env name priv ty = - let ty = expand_head_trace env ty in - match ty.desc with - Tvar _ -> - let level = ty.level in - let ty1 = newvar2 level and ty2 = newvar2 level in - let ty' = newty2 level (Tfield (name, - begin match priv with - Private -> Fvar (ref None) - | Public -> Fpresent - end, - ty1, ty2)) - in - link_type ty ty'; - ty1 - | Tfield(n, kind, ty1, ty2) -> - let kind = field_kind_repr kind in - if (n = name) && (kind <> Fabsent) then begin - if priv = Public then - unify_kind kind Fpresent; - ty1 - end else - filter_method_field env name priv ty2 - | _ -> - raise (Unify []) +let newconstr path tyl = newty (Tconstr (path, tyl, ref Mnil)) -(* Unify [ty] and [< name : 'a; .. >]. Return ['a]. *) -let filter_method env name priv ty = - let ty = expand_head_trace env ty in - match ty.desc with - Tvar _ -> - let ty1 = newvar () in - let ty' = newobj ty1 in - update_level env ty.level ty'; - link_type ty ty'; - filter_method_field env name priv ty1 - | Tobject(f, _) -> - filter_method_field env name priv f - | _ -> - raise (Unify []) +let none = newty (Ttuple []) (* Clearly ill-formed type *) -let check_filter_method env name priv ty = - ignore(filter_method env name priv ty) +(**** Representative of a type ****) -let filter_self_method env lab priv meths ty = - let ty' = filter_method env lab priv ty in - try - Meths.find lab !meths - with Not_found -> - let pair = (Ident.create lab, ty') in - meths := Meths.add lab pair !meths; - pair +(* Re-export repr *) +let repr = repr +(**** Type maps ****) - (***********************************) - (* Matching between type schemes *) - (***********************************) +module TypePairs = + Hashtbl.Make (struct + type t = type_expr * type_expr + let equal (t1, t1') (t2, t2') = (t1 == t2) && (t1' == t2') + let hash (t, t') = t.id + 93 * t'.id + end) -(* - Update the level of [ty]. First check that the levels of generic - variables from the subject are not lowered. -*) -let moregen_occur env level ty = - let rec occur ty = - let ty = repr ty in - if ty.level > level then begin - if is_Tvar ty && ty.level >= generic_level - 1 then raise Occur; - ty.level <- pivot_level - ty.level; - match ty.desc with - Tvariant row when static_row row -> - iter_row occur row - | _ -> - iter_type_expr occur ty - end - in - begin try - occur ty; unmark_type ty - with Occur -> - unmark_type ty; raise (Unify []) - end; - (* also check for free univars *) - occur_univar env ty; - update_level env level ty -let may_instantiate inst_nongen t1 = - if inst_nongen then t1.level <> generic_level - 1 - else t1.level = generic_level +(**** unification mode ****) -let rec moregen inst_nongen type_pairs env t1 t2 = - if t1 == t2 then () else - let t1 = repr t1 in - let t2 = repr t2 in - if t1 == t2 then () else +type unification_mode = + | Expression (* unification in expression *) + | Pattern (* unification in pattern which may add local constraints *) + +let umode = ref Expression +let generate_equations = ref false +let assume_injective = ref false +let set_mode_pattern ~generate ~injective f = + let old_unification_mode = !umode + and old_gen = !generate_equations + and old_inj = !assume_injective in try - match (t1.desc, t2.desc) with - (Tvar _, _) when may_instantiate inst_nongen t1 -> - moregen_occur env t1.level t2; - occur env t1 t2; - link_type t1 t2 - | (Tconstr (p1, [], _), Tconstr (p2, [], _)) when Path.same p1 p2 -> - () - | _ -> - let t1' = expand_head env t1 in - let t2' = expand_head env t2 in - (* Expansion may have changed the representative of the types... *) - let t1' = repr t1' and t2' = repr t2' in - if t1' == t2' then () else - begin try - TypePairs.find type_pairs (t1', t2') - with Not_found -> - TypePairs.add type_pairs (t1', t2') (); - match (t1'.desc, t2'.desc) with - (Tvar _, _) when may_instantiate inst_nongen t1' -> - moregen_occur env t1'.level t2; - link_type t1' t2 - | (Tarrow (l1, t1, u1, _), Tarrow (l2, t2, u2, _)) when l1 = l2 - || !Clflags.classic && not (is_optional l1 || is_optional l2) -> - moregen inst_nongen type_pairs env t1 t2; - moregen inst_nongen type_pairs env u1 u2 - | (Ttuple tl1, Ttuple tl2) -> - moregen_list inst_nongen type_pairs env tl1 tl2 - | (Tconstr (p1, tl1, _), Tconstr (p2, tl2, _)) - when Path.same p1 p2 -> - moregen_list inst_nongen type_pairs env tl1 tl2 - | (Tpackage (p1, n1, tl1), Tpackage (p2, n2, tl2)) -> - begin try - unify_package env (moregen_list inst_nongen type_pairs env) - t1'.level p1 n1 tl1 t2'.level p2 n2 tl2 - with Not_found -> raise (Unify []) - end - | (Tvariant row1, Tvariant row2) -> - moregen_row inst_nongen type_pairs env row1 row2 - | (Tobject (fi1, _nm1), Tobject (fi2, _nm2)) -> - moregen_fields inst_nongen type_pairs env fi1 fi2 - | (Tfield _, Tfield _) -> (* Actually unused *) - moregen_fields inst_nongen type_pairs env t1' t2' - | (Tnil, Tnil) -> - () - | (Tpoly (t1, []), Tpoly (t2, [])) -> - moregen inst_nongen type_pairs env t1 t2 - | (Tpoly (t1, tl1), Tpoly (t2, tl2)) -> - enter_poly env univar_pairs t1 tl1 t2 tl2 - (moregen inst_nongen type_pairs env) - | (Tunivar _, Tunivar _) -> - unify_univar t1' t2' !univar_pairs - | (_, _) -> - raise (Unify []) - end - with Unify trace -> - raise (Unify ((t1, t2)::trace)) + umode := Pattern; + generate_equations := generate; + assume_injective := injective; + let ret = f () in + umode := old_unification_mode; + generate_equations := old_gen; + assume_injective := old_inj; + ret + with e -> + umode := old_unification_mode; + generate_equations := old_gen; + assume_injective := old_inj; + raise e -and moregen_list inst_nongen type_pairs env tl1 tl2 = - if List.length tl1 <> List.length tl2 then - raise (Unify []); - List.iter2 (moregen inst_nongen type_pairs env) tl1 tl2 +(*** Checks for type definitions ***) -and moregen_fields inst_nongen type_pairs env ty1 ty2 = - let (fields1, rest1) = flatten_fields ty1 - and (fields2, rest2) = flatten_fields ty2 in - let (pairs, miss1, miss2) = associate_fields fields1 fields2 in - if miss1 <> [] then raise (Unify []); - moregen inst_nongen type_pairs env rest1 - (build_fields (repr ty2).level miss2 rest2); - List.iter - (fun (n, k1, t1, k2, t2) -> - moregen_kind k1 k2; - try moregen inst_nongen type_pairs env t1 t2 with Unify trace -> - raise (Unify ((newty (Tfield(n, k1, t1, rest2)), - newty (Tfield(n, k2, t2, rest2)))::trace))) - pairs +let in_current_module = function + | Path.Pident _ -> true + | Path.Pdot _ | Path.Papply _ -> false -and moregen_kind k1 k2 = - let k1 = field_kind_repr k1 in - let k2 = field_kind_repr k2 in - if k1 == k2 then () else - match k1, k2 with - (Fvar r, (Fvar _ | Fpresent)) -> set_kind r k2 - | (Fpresent, Fpresent) -> () - | _ -> raise (Unify []) +let in_pervasives p = + in_current_module p && + try ignore (Env.find_type p Env.initial_safe_string); true + with Not_found -> false -and moregen_row inst_nongen type_pairs env row1 row2 = - let row1 = row_repr row1 and row2 = row_repr row2 in - let rm1 = repr row1.row_more and rm2 = repr row2.row_more in - if rm1 == rm2 then () else - let may_inst = - is_Tvar rm1 && may_instantiate inst_nongen rm1 || rm1.desc = Tnil in - let r1, r2, pairs = merge_row_fields row1.row_fields row2.row_fields in - let r1, r2 = - if row2.row_closed then - filter_row_fields may_inst r1, filter_row_fields false r2 - else r1, r2 - in - if r1 <> [] || row1.row_closed && (not row2.row_closed || r2 <> []) - then raise (Unify []); - begin match rm1.desc, rm2.desc with - Tunivar _, Tunivar _ -> - unify_univar rm1 rm2 !univar_pairs - | Tunivar _, _ | _, Tunivar _ -> - raise (Unify []) - | _ when static_row row1 -> () - | _ when may_inst -> - let ext = - newgenty (Tvariant {row2 with row_fields = r2; row_name = None}) - in - moregen_occur env rm1.level ext; - link_type rm1 ext - | Tconstr _, Tconstr _ -> - moregen inst_nongen type_pairs env rm1 rm2 - | _ -> raise (Unify []) - end; - List.iter - (fun (_l,f1,f2) -> - let f1 = row_field_repr f1 and f2 = row_field_repr f2 in - if f1 == f2 then () else - match f1, f2 with - Rpresent(Some t1), Rpresent(Some t2) -> - moregen inst_nongen type_pairs env t1 t2 - | Rpresent None, Rpresent None -> () - | Reither(false, tl1, _, e1), Rpresent(Some t2) when may_inst -> - set_row_field e1 f2; - List.iter (fun t1 -> moregen inst_nongen type_pairs env t1 t2) tl1 - | Reither(c1, tl1, _, e1), Reither(c2, tl2, m2, e2) -> - if e1 != e2 then begin - if c1 && not c2 then raise(Unify []); - set_row_field e1 (Reither (c2, [], m2, e2)); - if List.length tl1 = List.length tl2 then - List.iter2 (moregen inst_nongen type_pairs env) tl1 tl2 - else match tl2 with - t2 :: _ -> - List.iter (fun t1 -> moregen inst_nongen type_pairs env t1 t2) - tl1 - | [] -> - if tl1 <> [] then raise (Unify []) - end - | Reither(true, [], _, e1), Rpresent None when may_inst -> - set_row_field e1 f2 - | Reither(_, _, _, e1), Rabsent when may_inst -> - set_row_field e1 f2 - | Rabsent, Rabsent -> () - | _ -> raise (Unify [])) - pairs +let is_datatype decl= + match decl.type_kind with + Type_record _ | Type_variant _ | Type_open -> true + | Type_abstract -> false -(* Must empty univar_pairs first *) -let moregen inst_nongen type_pairs env patt subj = - univar_pairs := []; - moregen inst_nongen type_pairs env patt subj -(* - Non-generic variable can be instantiated only if [inst_nongen] is - true. So, [inst_nongen] should be set to false if the subject might - contain non-generic variables (and we do not want them to be - instantiated). - Usually, the subject is given by the user, and the pattern - is unimportant. So, no need to propagate abbreviations. + (**********************************************) + (* Miscellaneous operations on object types *) + (**********************************************) + +(* Note: + We need to maintain some invariants: + * cty_self must be a Tobject + * ... *) -let moregeneral env inst_nongen pat_sch subj_sch = - let old_level = !current_level in - current_level := generic_level - 1; - (* - Generic variables are first duplicated with [instance]. So, - their levels are lowered to [generic_level - 1]. The subject is - then copied with [duplicate_type]. That way, its levels won't be - changed. - *) - let subj = duplicate_type (instance env subj_sch) in - current_level := generic_level; - (* Duplicate generic variables *) - let patt = instance env pat_sch in - let res = - try moregen inst_nongen (TypePairs.create 13) env patt subj; true with - Unify _ -> false - in - current_level := old_level; - res +(**** Object field manipulation. ****) -(* Alternative approach: "rigidify" a type scheme, - and check validity after unification *) -(* Simpler, no? *) +let object_fields ty = + match (repr ty).desc with + Tobject (fields, _) -> fields + | _ -> assert false -let rec rigidify_rec vars ty = - let ty = repr ty in - if ty.level >= lowest_level then begin - ty.level <- pivot_level - ty.level; +let flatten_fields ty = + let rec flatten l ty = + let ty = repr ty in match ty.desc with - | Tvar _ -> - if not (List.memq ty !vars) then vars := ty :: !vars - | Tvariant row -> - let row = row_repr row in - let more = repr row.row_more in - if is_Tvar more && not (row_fixed row) then begin - let more' = newty2 more.level more.desc in - let row' = {row with row_fixed=true; row_fields=[]; row_more=more'} - in link_type more (newty2 ty.level (Tvariant row')) - end; - iter_row (rigidify_rec vars) row; - (* only consider the row variable if the variant is not static *) - if not (static_row row) then rigidify_rec vars (row_more row) + Tfield(s, k, ty1, ty2) -> + flatten ((s, k, ty1)::l) ty2 | _ -> - iter_type_expr (rigidify_rec vars) ty - end - -let rigidify ty = - let vars = ref [] in - rigidify_rec vars ty; - unmark_type ty; - !vars - -let all_distinct_vars env vars = - let tyl = ref [] in - List.for_all - (fun ty -> - let ty = expand_head env ty in - if List.memq ty !tyl then false else - (tyl := ty :: !tyl; is_Tvar ty)) - vars - -let matches env ty ty' = - let snap = snapshot () in - let vars = rigidify ty in - cleanup_abbrev (); - let ok = - try unify env ty ty'; all_distinct_vars env vars - with Unify _ -> false + (l, ty) in - backtrack snap; - ok + let (l, r) = flatten [] ty in + (List.sort (fun (n, _, _) (n', _, _) -> compare n n') l, r) +let build_fields level = + List.fold_right + (fun (s, k, ty1) ty2 -> newty2 level (Tfield(s, k, ty1, ty2))) - (*********************************************) - (* Equivalence between parameterized types *) - (*********************************************) +let associate_fields fields1 fields2 = + let rec associate p s s' = + function + (l, []) -> + (List.rev p, (List.rev s) @ l, List.rev s') + | ([], l') -> + (List.rev p, List.rev s, (List.rev s') @ l') + | ((n, k, t)::r, (n', k', t')::r') when n = n' -> + associate ((n, k, t, k', t')::p) s s' (r, r') + | ((n, k, t)::r, ((n', _k', _t')::_ as l')) when n < n' -> + associate p ((n, k, t)::s) s' (r, l') + | (((_n, _k, _t)::_ as l), (n', k', t')::r') (* when n > n' *) -> + associate p s ((n', k', t')::s') (l, r') + in + associate [] [] [] (fields1, fields2) -let expand_head_rigid env ty = - let old = !rigid_variants in - rigid_variants := true; - let ty' = expand_head env ty in - rigid_variants := old; ty' +(**** Check whether an object is open ****) -let normalize_subst subst = - if List.exists - (function {desc=Tlink _}, _ | _, {desc=Tlink _} -> true | _ -> false) - !subst - then subst := List.map (fun (t1,t2) -> repr t1, repr t2) !subst +(* +++ The abbreviation should eventually be expanded *) +let rec object_row ty = + let ty = repr ty in + match ty.desc with + Tobject (t, _) -> object_row t + | Tfield(_, _, _, t) -> object_row t + | _ -> ty -let rec eqtype rename type_pairs subst env t1 t2 = - if t1 == t2 then () else - let t1 = repr t1 in - let t2 = repr t2 in - if t1 == t2 then () else +let opened_object ty = + match (object_row ty).desc with + | Tvar _ | Tunivar _ | Tconstr _ -> true + | _ -> false - try - match (t1.desc, t2.desc) with - (Tvar _, Tvar _) when rename -> - begin try - normalize_subst subst; - if List.assq t1 !subst != t2 then raise (Unify []) - with Not_found -> - if List.exists (fun (_, t) -> t == t2) !subst then raise (Unify []); - subst := (t1, t2) :: !subst - end - | (Tconstr (p1, [], _), Tconstr (p2, [], _)) when Path.same p1 p2 -> - () - | _ -> - let t1' = expand_head_rigid env t1 in - let t2' = expand_head_rigid env t2 in - (* Expansion may have changed the representative of the types... *) - let t1' = repr t1' and t2' = repr t2' in - if t1' == t2' then () else - begin try - TypePairs.find type_pairs (t1', t2') - with Not_found -> - TypePairs.add type_pairs (t1', t2') (); - match (t1'.desc, t2'.desc) with - (Tvar _, Tvar _) when rename -> - begin try - normalize_subst subst; - if List.assq t1' !subst != t2' then raise (Unify []) - with Not_found -> - if List.exists (fun (_, t) -> t == t2') !subst - then raise (Unify []); - subst := (t1', t2') :: !subst - end - | (Tarrow (l1, t1, u1, _), Tarrow (l2, t2, u2, _)) when l1 = l2 - || !Clflags.classic && not (is_optional l1 || is_optional l2) -> - eqtype rename type_pairs subst env t1 t2; - eqtype rename type_pairs subst env u1 u2; - | (Ttuple tl1, Ttuple tl2) -> - eqtype_list rename type_pairs subst env tl1 tl2 - | (Tconstr (p1, tl1, _), Tconstr (p2, tl2, _)) - when Path.same p1 p2 -> - eqtype_list rename type_pairs subst env tl1 tl2 - | (Tpackage (p1, n1, tl1), Tpackage (p2, n2, tl2)) -> - begin try - unify_package env (eqtype_list rename type_pairs subst env) - t1'.level p1 n1 tl1 t2'.level p2 n2 tl2 - with Not_found -> raise (Unify []) - end - | (Tvariant row1, Tvariant row2) -> - eqtype_row rename type_pairs subst env row1 row2 - | (Tobject (fi1, _nm1), Tobject (fi2, _nm2)) -> - eqtype_fields rename type_pairs subst env fi1 fi2 - | (Tfield _, Tfield _) -> (* Actually unused *) - eqtype_fields rename type_pairs subst env t1' t2' - | (Tnil, Tnil) -> - () - | (Tpoly (t1, []), Tpoly (t2, [])) -> - eqtype rename type_pairs subst env t1 t2 - | (Tpoly (t1, tl1), Tpoly (t2, tl2)) -> - enter_poly env univar_pairs t1 tl1 t2 tl2 - (eqtype rename type_pairs subst env) - | (Tunivar _, Tunivar _) -> - unify_univar t1' t2' !univar_pairs - | (_, _) -> - raise (Unify []) - end - with Unify trace -> - raise (Unify ((t1, t2)::trace)) +let concrete_object ty = + match (object_row ty).desc with + | Tvar _ -> false + | _ -> true -and eqtype_list rename type_pairs subst env tl1 tl2 = - if List.length tl1 <> List.length tl2 then - raise (Unify []); - List.iter2 (eqtype rename type_pairs subst env) tl1 tl2 +(**** Close an object ****) -and eqtype_fields rename type_pairs subst env ty1 ty2 = - let (fields1, rest1) = flatten_fields ty1 in - let (fields2, rest2) = flatten_fields ty2 in - (* First check if same row => already equal *) - let same_row = - rest1 == rest2 || TypePairs.mem type_pairs (rest1,rest2) || - (rename && List.mem (rest1, rest2) !subst) +let close_object ty = + let rec close ty = + let ty = repr ty in + match ty.desc with + Tvar _ -> + link_type ty (newty2 ty.level Tnil) + | Tfield(_, _, _, ty') -> close ty' + | _ -> assert false in - if same_row then () else - (* Try expansion, needed when called from Includecore.type_manifest *) - match expand_head_rigid env rest2 with - {desc=Tobject(ty2,_)} -> eqtype_fields rename type_pairs subst env ty1 ty2 - | _ -> - let (pairs, miss1, miss2) = associate_fields fields1 fields2 in - eqtype rename type_pairs subst env rest1 rest2; - if (miss1 <> []) || (miss2 <> []) then raise (Unify []); - List.iter - (function (n, k1, t1, k2, t2) -> - eqtype_kind k1 k2; - try eqtype rename type_pairs subst env t1 t2 with Unify trace -> - raise (Unify ((newty (Tfield(n, k1, t1, rest2)), - newty (Tfield(n, k2, t2, rest2)))::trace))) - pairs + match (repr ty).desc with + Tobject (ty, _) -> close ty + | _ -> assert false -and eqtype_kind k1 k2 = - let k1 = field_kind_repr k1 in - let k2 = field_kind_repr k2 in - match k1, k2 with - (Fvar _, Fvar _) - | (Fpresent, Fpresent) -> () - | _ -> raise (Unify []) +(**** Row variable of an object type ****) -and eqtype_row rename type_pairs subst env row1 row2 = - (* Try expansion, needed when called from Includecore.type_manifest *) - match expand_head_rigid env (row_more row2) with - {desc=Tvariant row2} -> eqtype_row rename type_pairs subst env row1 row2 +let row_variable ty = + let rec find ty = + let ty = repr ty in + match ty.desc with + Tfield (_, _, _, ty) -> find ty + | Tvar _ -> ty + | _ -> assert false + in + match (repr ty).desc with + Tobject (fi, _) -> find fi + | _ -> assert false + +(**** Object name manipulation ****) +(* +++ Bientot obsolete *) + +let set_object_name id rv params ty = + match (repr ty).desc with + Tobject (_fi, nm) -> + set_name nm (Some (Path.Pident id, rv::params)) | _ -> - let row1 = row_repr row1 and row2 = row_repr row2 in - let r1, r2, pairs = merge_row_fields row1.row_fields row2.row_fields in - if row1.row_closed <> row2.row_closed - || not row1.row_closed && (r1 <> [] || r2 <> []) - || filter_row_fields false (r1 @ r2) <> [] - then raise (Unify []); - if not (static_row row1) then - eqtype rename type_pairs subst env row1.row_more row2.row_more; - List.iter - (fun (_,f1,f2) -> - match row_field_repr f1, row_field_repr f2 with - Rpresent(Some t1), Rpresent(Some t2) -> - eqtype rename type_pairs subst env t1 t2 - | Reither(c1, [], _, _), Reither(c2, [], _, _) when c1 = c2 -> - () - | Reither(c1, t1::tl1, _, _), Reither(c2, t2::tl2, _, _) when c1 = c2 -> - eqtype rename type_pairs subst env t1 t2; - if List.length tl1 = List.length tl2 then - (* if same length allow different types (meaning?) *) - List.iter2 (eqtype rename type_pairs subst env) tl1 tl2 - else begin - (* otherwise everything must be equal *) - List.iter (eqtype rename type_pairs subst env t1) tl2; - List.iter (fun t1 -> eqtype rename type_pairs subst env t1 t2) tl1 - end - | Rpresent None, Rpresent None -> () - | Rabsent, Rabsent -> () - | _ -> raise (Unify [])) - pairs + assert false -(* Must empty univar_pairs first *) -let eqtype_list rename type_pairs subst env tl1 tl2 = - univar_pairs := []; - let snap = Btype.snapshot () in - try eqtype_list rename type_pairs subst env tl1 tl2; backtrack snap - with exn -> backtrack snap; raise exn +let remove_object_name ty = + match (repr ty).desc with + Tobject (_, nm) -> set_name nm None + | Tconstr (_, _, _) -> () + | _ -> fatal_error "Ctype.remove_object_name" -let eqtype rename type_pairs subst env t1 t2 = - eqtype_list rename type_pairs subst env [t1] [t2] +(**** Hiding of private methods ****) -(* Two modes: with or without renaming of variables *) -let equal env rename tyl1 tyl2 = - try - eqtype_list rename (TypePairs.create 11) (ref []) env tyl1 tyl2; true - with - Unify _ -> false +let hide_private_methods ty = + match (repr ty).desc with + Tobject (fi, nm) -> + nm := None; + let (fl, _) = flatten_fields fi in + List.iter + (function (_, k, _) -> + match field_kind_repr k with + Fvar r -> set_kind r Fabsent + | _ -> ()) + fl + | _ -> + assert false - (*************************) - (* Class type matching *) - (*************************) + (*******************************) + (* Operations on class types *) + (*******************************) -type class_match_failure = - CM_Virtual_class - | CM_Parameter_arity_mismatch of int * int - | CM_Type_parameter_mismatch of Env.t * (type_expr * type_expr) list - | CM_Class_type_mismatch of Env.t * class_type * class_type - | CM_Parameter_mismatch of Env.t * (type_expr * type_expr) list - | CM_Val_type_mismatch of string * Env.t * (type_expr * type_expr) list - | CM_Meth_type_mismatch of string * Env.t * (type_expr * type_expr) list - | CM_Non_mutable_value of string - | CM_Non_concrete_value of string - | CM_Missing_value of string - | CM_Missing_method of string - | CM_Hide_public of string - | CM_Hide_virtual of string * string - | CM_Public_method of string - | CM_Private_method of string - | CM_Virtual_method of string +let rec signature_of_class_type = + function + Cty_constr (_, _, cty) -> signature_of_class_type cty + | Cty_signature sign -> sign + | Cty_arrow (_, _, cty) -> signature_of_class_type cty -exception Failure of class_match_failure list +let self_type cty = + repr (signature_of_class_type cty).csig_self -let rec moregen_clty trace type_pairs env cty1 cty2 = - try - match cty1, cty2 with - Cty_constr (_, _, cty1), _ -> - moregen_clty true type_pairs env cty1 cty2 - | _, Cty_constr (_, _, cty2) -> - moregen_clty true type_pairs env cty1 cty2 - | Cty_arrow (l1, ty1, cty1'), Cty_arrow (l2, ty2, cty2') when l1 = l2 -> - begin try moregen true type_pairs env ty1 ty2 with Unify trace -> - raise (Failure [CM_Parameter_mismatch (env, expand_trace env trace)]) - end; - moregen_clty false type_pairs env cty1' cty2' - | Cty_signature sign1, Cty_signature sign2 -> - let ty1 = object_fields (repr sign1.csig_self) in - let ty2 = object_fields (repr sign2.csig_self) in - let (fields1, _rest1) = flatten_fields ty1 - and (fields2, _rest2) = flatten_fields ty2 in - let (pairs, _miss1, _miss2) = associate_fields fields1 fields2 in - List.iter - (fun (lab, _k1, t1, _k2, t2) -> - begin try moregen true type_pairs env t1 t2 with Unify trace -> - raise (Failure [CM_Meth_type_mismatch - (lab, env, expand_trace env trace)]) - end) - pairs; - Vars.iter - (fun lab (_mut, _v, ty) -> - let (_mut', _v', ty') = Vars.find lab sign1.csig_vars in - try moregen true type_pairs env ty' ty with Unify trace -> - raise (Failure [CM_Val_type_mismatch - (lab, env, expand_trace env trace)])) - sign2.csig_vars - | _ -> - raise (Failure []) - with - Failure error when trace || error = [] -> - raise (Failure (CM_Class_type_mismatch (env, cty1, cty2)::error)) +let rec class_type_arity = + function + Cty_constr (_, _, cty) -> class_type_arity cty + | Cty_signature _ -> 0 + | Cty_arrow (_, _, cty) -> 1 + class_type_arity cty -let match_class_types ?(trace=true) env pat_sch subj_sch = - let type_pairs = TypePairs.create 53 in - let old_level = !current_level in - current_level := generic_level - 1; - (* - Generic variables are first duplicated with [instance]. So, - their levels are lowered to [generic_level - 1]. The subject is - then copied with [duplicate_type]. That way, its levels won't be - changed. - *) - let (_, subj_inst) = instance_class [] subj_sch in - let subj = duplicate_class_type subj_inst in - current_level := generic_level; - (* Duplicate generic variables *) - let (_, patt) = instance_class [] pat_sch in - let res = - let sign1 = signature_of_class_type patt in - let sign2 = signature_of_class_type subj in - let t1 = repr sign1.csig_self in - let t2 = repr sign2.csig_self in - TypePairs.add type_pairs (t1, t2) (); - let (fields1, rest1) = flatten_fields (object_fields t1) - and (fields2, rest2) = flatten_fields (object_fields t2) in - let (pairs, miss1, miss2) = associate_fields fields1 fields2 in - let error = - List.fold_right - (fun (lab, k, _) err -> - let err = - let k = field_kind_repr k in - begin match k with - Fvar r -> set_kind r Fabsent; err - | _ -> CM_Hide_public lab::err - end - in - if Concr.mem lab sign1.csig_concr then err - else CM_Hide_virtual ("method", lab) :: err) - miss1 [] - in - let missing_method = List.map (fun (m, _, _) -> m) miss2 in - let error = - (List.map (fun m -> CM_Missing_method m) missing_method) @ error - in - (* Always succeeds *) - moregen true type_pairs env rest1 rest2; - let error = - List.fold_right - (fun (lab, k1, _t1, k2, _t2) err -> - try moregen_kind k1 k2; err with - Unify _ -> CM_Public_method lab::err) - pairs error - in - let error = - Vars.fold - (fun lab (mut, vr, _ty) err -> - try - let (mut', vr', _ty') = Vars.find lab sign1.csig_vars in - if mut = Mutable && mut' <> Mutable then - CM_Non_mutable_value lab::err - else if vr = Concrete && vr' <> Concrete then - CM_Non_concrete_value lab::err - else - err - with Not_found -> - CM_Missing_value lab::err) - sign2.csig_vars error - in - let error = - Vars.fold - (fun lab (_,vr,_) err -> - if vr = Virtual && not (Vars.mem lab sign2.csig_vars) then - CM_Hide_virtual ("instance variable", lab) :: err - else err) - sign1.csig_vars error - in - let error = - List.fold_right - (fun e l -> - if List.mem e missing_method then l else CM_Virtual_method e::l) - (Concr.elements (Concr.diff sign2.csig_concr sign1.csig_concr)) - error - in - match error with - [] -> - begin try - moregen_clty trace type_pairs env patt subj; - [] - with - Failure r -> r - end - | error -> - CM_Class_type_mismatch (env, patt, subj)::error - in - current_level := old_level; - res -let rec equal_clty trace type_pairs subst env cty1 cty2 = - try - match cty1, cty2 with - Cty_constr (_, _, cty1), Cty_constr (_, _, cty2) -> - equal_clty true type_pairs subst env cty1 cty2 - | Cty_constr (_, _, cty1), _ -> - equal_clty true type_pairs subst env cty1 cty2 - | _, Cty_constr (_, _, cty2) -> - equal_clty true type_pairs subst env cty1 cty2 - | Cty_arrow (l1, ty1, cty1'), Cty_arrow (l2, ty2, cty2') when l1 = l2 -> - begin try eqtype true type_pairs subst env ty1 ty2 with Unify trace -> - raise (Failure [CM_Parameter_mismatch (env, expand_trace env trace)]) - end; - equal_clty false type_pairs subst env cty1' cty2' - | Cty_signature sign1, Cty_signature sign2 -> - let ty1 = object_fields (repr sign1.csig_self) in - let ty2 = object_fields (repr sign2.csig_self) in - let (fields1, _rest1) = flatten_fields ty1 - and (fields2, _rest2) = flatten_fields ty2 in - let (pairs, _miss1, _miss2) = associate_fields fields1 fields2 in - List.iter - (fun (lab, _k1, t1, _k2, t2) -> - begin try eqtype true type_pairs subst env t1 t2 with - Unify trace -> - raise (Failure [CM_Meth_type_mismatch - (lab, env, expand_trace env trace)]) - end) - pairs; - Vars.iter - (fun lab (_, _, ty) -> - let (_, _, ty') = Vars.find lab sign1.csig_vars in - try eqtype true type_pairs subst env ty' ty with Unify trace -> - raise (Failure [CM_Val_type_mismatch - (lab, env, expand_trace env trace)])) - sign2.csig_vars - | _ -> - raise - (Failure (if trace then [] - else [CM_Class_type_mismatch (env, cty1, cty2)])) - with - Failure error when trace -> - raise (Failure (CM_Class_type_mismatch (env, cty1, cty2)::error)) + (*******************************************) + (* Miscellaneous operations on row types *) + (*******************************************) -let match_class_declarations env patt_params patt_type subj_params subj_type = - let type_pairs = TypePairs.create 53 in - let subst = ref [] in - let sign1 = signature_of_class_type patt_type in - let sign2 = signature_of_class_type subj_type in - let t1 = repr sign1.csig_self in - let t2 = repr sign2.csig_self in - TypePairs.add type_pairs (t1, t2) (); - let (fields1, rest1) = flatten_fields (object_fields t1) - and (fields2, rest2) = flatten_fields (object_fields t2) in - let (pairs, miss1, miss2) = associate_fields fields1 fields2 in - let error = - List.fold_right - (fun (lab, k, _) err -> - let err = - let k = field_kind_repr k in - begin match k with - Fvar _ -> err - | _ -> CM_Hide_public lab::err - end - in - if Concr.mem lab sign1.csig_concr then err - else CM_Hide_virtual ("method", lab) :: err) - miss1 [] - in - let missing_method = List.map (fun (m, _, _) -> m) miss2 in - let error = - (List.map (fun m -> CM_Missing_method m) missing_method) @ error - in - (* Always succeeds *) - eqtype true type_pairs subst env rest1 rest2; - let error = - List.fold_right - (fun (lab, k1, _t1, k2, _t2) err -> - let k1 = field_kind_repr k1 in - let k2 = field_kind_repr k2 in - match k1, k2 with - (Fvar _, Fvar _) - | (Fpresent, Fpresent) -> err - | (Fvar _, Fpresent) -> CM_Private_method lab::err - | (Fpresent, Fvar _) -> CM_Public_method lab::err - | _ -> assert false) - pairs error - in - let error = - Vars.fold - (fun lab (mut, vr, _ty) err -> - try - let (mut', vr', _ty') = Vars.find lab sign1.csig_vars in - if mut = Mutable && mut' <> Mutable then - CM_Non_mutable_value lab::err - else if vr = Concrete && vr' <> Concrete then - CM_Non_concrete_value lab::err - else - err - with Not_found -> - CM_Missing_value lab::err) - sign2.csig_vars error - in - let error = - Vars.fold - (fun lab (_,vr,_) err -> - if vr = Virtual && not (Vars.mem lab sign2.csig_vars) then - CM_Hide_virtual ("instance variable", lab) :: err - else err) - sign1.csig_vars error - in - let error = - List.fold_right - (fun e l -> - if List.mem e missing_method then l else CM_Virtual_method e::l) - (Concr.elements (Concr.diff sign2.csig_concr sign1.csig_concr)) - error - in - match error with - [] -> - begin try - let lp = List.length patt_params in - let ls = List.length subj_params in - if lp <> ls then - raise (Failure [CM_Parameter_arity_mismatch (lp, ls)]); - List.iter2 (fun p s -> - try eqtype true type_pairs subst env p s with Unify trace -> - raise (Failure [CM_Type_parameter_mismatch - (env, expand_trace env trace)])) - patt_params subj_params; - (* old code: equal_clty false type_pairs subst env patt_type subj_type; *) - equal_clty false type_pairs subst env - (Cty_signature sign1) (Cty_signature sign2); - (* Use moregeneral for class parameters, need to recheck everything to - keeps relationships (PR#4824) *) - let clty_params = - List.fold_right (fun ty cty -> Cty_arrow (Labelled "*",ty,cty)) in - match_class_types ~trace:false env - (clty_params patt_params patt_type) - (clty_params subj_params subj_type) - with - Failure r -> r - end - | error -> - error +let sort_row_fields = List.sort (fun (p,_) (q,_) -> compare p q) +let rec merge_rf r1 r2 pairs fi1 fi2 = + match fi1, fi2 with + (l1,f1 as p1)::fi1', (l2,f2 as p2)::fi2' -> + if l1 = l2 then merge_rf r1 r2 ((l1,f1,f2)::pairs) fi1' fi2' else + if l1 < l2 then merge_rf (p1::r1) r2 pairs fi1' fi2 else + merge_rf r1 (p2::r2) pairs fi1 fi2' + | [], _ -> (List.rev r1, List.rev_append r2 fi2, pairs) + | _, [] -> (List.rev_append r1 fi1, List.rev r2, pairs) - (***************) - (* Subtyping *) - (***************) +let merge_row_fields fi1 fi2 = + match fi1, fi2 with + [], _ | _, [] -> (fi1, fi2, []) + | [p1], _ when not (List.mem_assoc (fst p1) fi2) -> (fi1, fi2, []) + | _, [p2] when not (List.mem_assoc (fst p2) fi1) -> (fi1, fi2, []) + | _ -> merge_rf [] [] [] (sort_row_fields fi1) (sort_row_fields fi2) +let rec filter_row_fields erase = function + [] -> [] + | (_l,f as p)::fi -> + let fi = filter_row_fields erase fi in + match row_field_repr f with + Rabsent -> fi + | Reither(_,_,false,e) when erase -> set_row_field e Rabsent; fi + | _ -> p :: fi -(**** Build a subtype of a given type. ****) + (**************************************) + (* Check genericity of type schemes *) + (**************************************) -(* build_subtype: - [visited] traces traversed object and variant types - [loops] is a mapping from variables to variables, to reproduce - positive loops in a class type - [posi] true if the current variance is positive - [level] number of expansions/enlargement allowed on this branch *) -let warn = ref false (* whether double coercion might do better *) -let pred_expand n = if n mod 2 = 0 && n > 0 then pred n else n -let pred_enlarge n = if n mod 2 = 1 then pred n else n +exception Non_closed of type_expr * bool -type change = Unchanged | Equiv | Changed -let collect l = List.fold_left (fun c1 (_, c2) -> max c1 c2) Unchanged l +let free_variables = ref [] +let really_closed = ref None -let rec filter_visited = function - [] -> [] - | {desc=Tobject _|Tvariant _} :: _ as l -> l - | _ :: l -> filter_visited l +let rec free_vars_rec real ty = + let ty = repr ty in + if ty.level >= lowest_level then begin + ty.level <- pivot_level - ty.level; + begin match ty.desc, !really_closed with + Tvar _, _ -> + free_variables := (ty, real) :: !free_variables + | Tconstr (path, tl, _), Some env -> + begin try + let (_, body, _) = Env.find_type_expansion path env in + if (repr body).level <> generic_level then + free_variables := (ty, real) :: !free_variables + with Not_found -> () + end; + List.iter (free_vars_rec true) tl +(* Do not count "virtual" free variables + | Tobject(ty, {contents = Some (_, p)}) -> + free_vars_rec false ty; List.iter (free_vars_rec true) p +*) + | Tobject (ty, _), _ -> + free_vars_rec false ty + | Tfield (_, _, ty1, ty2), _ -> + free_vars_rec true ty1; free_vars_rec false ty2 + | Tvariant row, _ -> + let row = row_repr row in + iter_row (free_vars_rec true) row; + if not (static_row row) then free_vars_rec false row.row_more + | _ -> + iter_type_expr (free_vars_rec true) ty + end; + end -let memq_warn t visited = - if List.memq t visited then (warn := true; true) else false +let free_vars ?env ty = + free_variables := []; + really_closed := env; + free_vars_rec true ty; + let res = !free_variables in + free_variables := []; + really_closed := None; + res -let rec lid_of_path ?(hash="") = function - Path.Pident id -> - Longident.Lident (hash ^ Ident.name id) - | Path.Pdot (p1, s, _) -> - Longident.Ldot (lid_of_path p1, hash ^ s) - | Path.Papply (p1, p2) -> - Longident.Lapply (lid_of_path ~hash p1, lid_of_path p2) +let free_variables ?env ty = + let tl = List.map fst (free_vars ?env ty) in + unmark_type ty; + tl -let find_cltype_for_path env p = - let cl_path = Env.lookup_type (lid_of_path ~hash:"#" p) env in - let cl_abbr = Env.find_type cl_path env in +let closed_type ty = + match free_vars ty with + [] -> () + | (v, real) :: _ -> raise (Non_closed (v, real)) - match cl_abbr.type_manifest with - Some ty -> - begin match (repr ty).desc with - Tobject(_,{contents=Some(p',_)}) when Path.same p p' -> cl_abbr, ty - | _ -> raise Not_found - end - | None -> assert false +let closed_parameterized_type params ty = + List.iter mark_type params; + let ok = + try closed_type ty; true with Non_closed _ -> false in + List.iter unmark_type params; + unmark_type ty; + ok -let has_constr_row' env t = - has_constr_row (expand_abbrev env t) +let closed_type_decl decl = + try + List.iter mark_type decl.type_params; + begin match decl.type_kind with + Type_abstract -> + () + | Type_variant v -> + List.iter + (fun {cd_args; cd_res; _} -> + match cd_res with + | Some _ -> () + | None -> + match cd_args with + | Cstr_tuple l -> List.iter closed_type l + | Cstr_record l -> List.iter (fun l -> closed_type l.ld_type) l + ) + v + | Type_record(r, _rep) -> + List.iter (fun l -> closed_type l.ld_type) r + | Type_open -> () + end; + begin match decl.type_manifest with + None -> () + | Some ty -> closed_type ty + end; + unmark_type_decl decl; + None + with Non_closed (ty, _) -> + unmark_type_decl decl; + Some ty -let rec build_subtype env visited loops posi level t = - let t = repr t in - match t.desc with - Tvar _ -> - if posi then - try - let t' = List.assq t loops in - warn := true; - (t', Equiv) - with Not_found -> - (t, Unchanged) - else - (t, Unchanged) - | Tarrow(l, t1, t2, _) -> - if memq_warn t visited then (t, Unchanged) else - let visited = t :: visited in - let (t1', c1) = build_subtype env visited loops (not posi) level t1 in - let (t2', c2) = build_subtype env visited loops posi level t2 in - let c = max c1 c2 in - if c > Unchanged then (newty (Tarrow(l, t1', t2', Cok)), c) - else (t, Unchanged) - | Ttuple tlist -> - if memq_warn t visited then (t, Unchanged) else - let visited = t :: visited in - let tlist' = - List.map (build_subtype env visited loops posi level) tlist - in - let c = collect tlist' in - if c > Unchanged then (newty (Ttuple (List.map fst tlist')), c) - else (t, Unchanged) - | Tconstr(p, tl, abbrev) - when level > 0 && generic_abbrev env p && safe_abbrev env t - && not (has_constr_row' env t) -> - let t' = repr (expand_abbrev env t) in - let level' = pred_expand level in - begin try match t'.desc with - Tobject _ when posi && not (opened_object t') -> - let cl_abbr, body = find_cltype_for_path env p in - let ty = - subst env !current_level Public abbrev None - cl_abbr.type_params tl body in - let ty = repr ty in - let ty1, tl1 = - match ty.desc with - Tobject(ty1,{contents=Some(p',tl1)}) when Path.same p p' -> - ty1, tl1 - | _ -> raise Not_found - in - (* Fix PR#4505: do not set ty to Tvar when it appears in tl1, - as this occurrence might break the occur check. - XXX not clear whether this correct anyway... *) - if List.exists (deep_occur ty) tl1 then raise Not_found; - ty.desc <- Tvar None; - let t'' = newvar () in - let loops = (ty, t'') :: loops in - (* May discard [visited] as level is going down *) - let (ty1', c) = - build_subtype env [t'] loops posi (pred_enlarge level') ty1 in - assert (is_Tvar t''); - let nm = - if c > Equiv || deep_occur ty ty1' then None else Some(p,tl1) in - t''.desc <- Tobject (ty1', ref nm); - (try unify_var env ty t with Unify _ -> assert false); - (t'', Changed) - | _ -> raise Not_found - with Not_found -> - let (t'',c) = build_subtype env visited loops posi level' t' in - if c > Unchanged then (t'',c) - else (t, Unchanged) - end - | Tconstr(p, tl, _abbrev) -> - (* Must check recursion on constructors, since we do not always - expand them *) - if memq_warn t visited then (t, Unchanged) else - let visited = t :: visited in - begin try - let decl = Env.find_type p env in - if level = 0 && generic_abbrev env p && safe_abbrev env t - && not (has_constr_row' env t) - then warn := true; - let tl' = - List.map2 - (fun v t -> - let (co,cn) = Variance.get_upper v in - if cn then - if co then (t, Unchanged) - else build_subtype env visited loops (not posi) level t - else - if co then build_subtype env visited loops posi level t - else (newvar(), Changed)) - decl.type_variance tl - in - let c = collect tl' in - if c > Unchanged then (newconstr p (List.map fst tl'), c) - else (t, Unchanged) - with Not_found -> - (t, Unchanged) - end - | Tvariant row -> - let row = row_repr row in - if memq_warn t visited || not (static_row row) then (t, Unchanged) else - let level' = pred_enlarge level in - let visited = - t :: if level' < level then [] else filter_visited visited in - let fields = filter_row_fields false row.row_fields in - let fields = - List.map - (fun (l,f as orig) -> match row_field_repr f with - Rpresent None -> - if posi then - (l, Reither(true, [], false, ref None)), Unchanged - else - orig, Unchanged - | Rpresent(Some t) -> - let (t', c) = build_subtype env visited loops posi level' t in - let f = - if posi && level > 0 - then Reither(false, [t'], false, ref None) - else Rpresent(Some t') - in (l, f), c - | _ -> assert false) - fields - in - let c = collect fields in - let row = - { row_fields = List.map fst fields; row_more = newvar(); - row_bound = (); row_closed = posi; row_fixed = false; - row_name = if c > Unchanged then None else row.row_name } - in - (newty (Tvariant row), Changed) - | Tobject (t1, _) -> - if memq_warn t visited || opened_object t1 then (t, Unchanged) else - let level' = pred_enlarge level in - let visited = - t :: if level' < level then [] else filter_visited visited in - let (t1', c) = build_subtype env visited loops posi level' t1 in - if c > Unchanged then (newty (Tobject (t1', ref None)), c) - else (t, Unchanged) - | Tfield(s, _, t1, t2) (* Always present *) -> - let (t1', c1) = build_subtype env visited loops posi level t1 in - let (t2', c2) = build_subtype env visited loops posi level t2 in - let c = max c1 c2 in - if c > Unchanged then (newty (Tfield(s, Fpresent, t1', t2')), c) - else (t, Unchanged) - | Tnil -> - if posi then - let v = newvar () in - (v, Changed) - else begin - warn := true; - (t, Unchanged) - end - | Tsubst _ | Tlink _ -> - assert false - | Tpoly(t1, tl) -> - let (t1', c) = build_subtype env visited loops posi level t1 in - if c > Unchanged then (newty (Tpoly(t1', tl)), c) - else (t, Unchanged) - | Tunivar _ | Tpackage _ -> - (t, Unchanged) +let closed_extension_constructor ext = + try + List.iter mark_type ext.ext_type_params; + begin match ext.ext_ret_type with + | Some _ -> () + | None -> iter_type_expr_cstr_args closed_type ext.ext_args + end; + unmark_extension_constructor ext; + None + with Non_closed (ty, _) -> + unmark_extension_constructor ext; + Some ty -let enlarge_type env ty = - warn := false; - (* [level = 4] allows 2 expansions involving objects/variants *) - let (ty', _) = build_subtype env [] [] true 4 ty in - (ty', !warn) +type closed_class_failure = + CC_Method of type_expr * bool * string * type_expr + | CC_Value of type_expr * bool * string * type_expr -(**** Check whether a type is a subtype of another type. ****) +exception CCFailure of closed_class_failure -(* - During the traversal, a trace of visited types is maintained. It - is printed in case of error. - Constraints (pairs of types that must be equals) are accumulated - rather than being enforced straight. Indeed, the result would - otherwise depend on the order in which these constraints are - enforced. - A function enforcing these constraints is returned. That way, type - variables can be bound to their actual values before this function - is called (see Typecore). - Only well-defined abbreviations are expanded (hence the tests - [generic_abbrev ...]). -*) +let closed_class params sign = + let ty = object_fields (repr sign.csig_self) in + let (fields, rest) = flatten_fields ty in + List.iter mark_type params; + mark_type rest; + List.iter + (fun (lab, _, ty) -> if lab = dummy_method then mark_type ty) + fields; + try + mark_type_node (repr sign.csig_self); + List.iter + (fun (lab, kind, ty) -> + if field_kind_repr kind = Fpresent then + try closed_type ty with Non_closed (ty0, real) -> + raise (CCFailure (CC_Method (ty0, real, lab, ty)))) + fields; + mark_type_params (repr sign.csig_self); + List.iter unmark_type params; + unmark_class_signature sign; + None + with CCFailure reason -> + mark_type_params (repr sign.csig_self); + List.iter unmark_type params; + unmark_class_signature sign; + Some reason -let subtypes = TypePairs.create 17 -let subtype_error env trace = - raise (Subtype (expand_trace env (List.rev trace), [])) + (**********************) + (* Type duplication *) + (**********************) -let rec subtype_rec env trace t1 t2 cstrs = - let t1 = repr t1 in - let t2 = repr t2 in - if t1 == t2 then cstrs else - begin try - TypePairs.find subtypes (t1, t2); - cstrs - with Not_found -> - TypePairs.add subtypes (t1, t2) (); - match (t1.desc, t2.desc) with - (Tvar _, _) | (_, Tvar _) -> - (trace, t1, t2, !univar_pairs)::cstrs - | (Tarrow(l1, t1, u1, _), Tarrow(l2, t2, u2, _)) when l1 = l2 - || !Clflags.classic && not (is_optional l1 || is_optional l2) -> - let cstrs = subtype_rec env ((t2, t1)::trace) t2 t1 cstrs in - subtype_rec env ((u1, u2)::trace) u1 u2 cstrs - | (Ttuple tl1, Ttuple tl2) -> - subtype_list env trace tl1 tl2 cstrs - | (Tconstr(p1, [], _), Tconstr(p2, [], _)) when Path.same p1 p2 -> - cstrs - | (Tconstr(p1, _tl1, _abbrev1), _) - when generic_abbrev env p1 && safe_abbrev env t1 -> - subtype_rec env trace (expand_abbrev env t1) t2 cstrs - | (_, Tconstr(p2, _tl2, _abbrev2)) - when generic_abbrev env p2 && safe_abbrev env t2 -> - subtype_rec env trace t1 (expand_abbrev env t2) cstrs - | (Tconstr(p1, tl1, _), Tconstr(p2, tl2, _)) when Path.same p1 p2 -> - begin try - let decl = Env.find_type p1 env in - List.fold_left2 - (fun cstrs v (t1, t2) -> - let (co, cn) = Variance.get_upper v in - if co then - if cn then - (trace, newty2 t1.level (Ttuple[t1]), - newty2 t2.level (Ttuple[t2]), !univar_pairs) :: cstrs - else subtype_rec env ((t1, t2)::trace) t1 t2 cstrs - else - if cn then subtype_rec env ((t2, t1)::trace) t2 t1 cstrs - else cstrs) - cstrs decl.type_variance (List.combine tl1 tl2) - with Not_found -> - (trace, t1, t2, !univar_pairs)::cstrs - end - | (Tconstr(p1, _, _), _) when generic_private_abbrev env p1 -> - subtype_rec env trace (expand_abbrev_opt env t1) t2 cstrs -(* | (_, Tconstr(p2, _, _)) when generic_private_abbrev false env p2 -> - subtype_rec env trace t1 (expand_abbrev_opt env t2) cstrs *) - | (Tobject (f1, _), Tobject (f2, _)) - when is_Tvar (object_row f1) && is_Tvar (object_row f2) -> - (* Same row variable implies same object. *) - (trace, t1, t2, !univar_pairs)::cstrs - | (Tobject (f1, _), Tobject (f2, _)) -> - subtype_fields env trace f1 f2 cstrs - | (Tvariant row1, Tvariant row2) -> - begin try - subtype_row env trace row1 row2 cstrs - with Exit -> - (trace, t1, t2, !univar_pairs)::cstrs - end - | (Tpoly (u1, []), Tpoly (u2, [])) -> - subtype_rec env trace u1 u2 cstrs - | (Tpoly (u1, tl1), Tpoly (u2, [])) -> - let _, u1' = instance_poly false tl1 u1 in - subtype_rec env trace u1' u2 cstrs - | (Tpoly (u1, tl1), Tpoly (u2,tl2)) -> - begin try - enter_poly env univar_pairs u1 tl1 u2 tl2 - (fun t1 t2 -> subtype_rec env trace t1 t2 cstrs) - with Unify _ -> - (trace, t1, t2, !univar_pairs)::cstrs - end - | (Tpackage (p1, nl1, tl1), Tpackage (p2, nl2, tl2)) -> - begin try - let ntl1 = complete_type_list env nl2 t1.level (Mty_ident p1) nl1 tl1 - and ntl2 = complete_type_list env nl1 t2.level (Mty_ident p2) nl2 tl2 - ~allow_absent:true in - let cstrs' = - List.map - (fun (n2,t2) -> (trace, List.assoc n2 ntl1, t2, !univar_pairs)) - ntl2 - in - if eq_package_path env p1 p2 then cstrs' @ cstrs - else begin - (* need to check module subtyping *) - let snap = Btype.snapshot () in - try - List.iter (fun (_, t1, t2, _) -> unify env t1 t2) cstrs'; - if !package_subtype env p1 nl1 tl1 p2 nl2 tl2 - then (Btype.backtrack snap; cstrs' @ cstrs) - else raise (Unify []) - with Unify _ -> - Btype.backtrack snap; raise Not_found - end - with Not_found -> - (trace, t1, t2, !univar_pairs)::cstrs - end - | (_, _) -> - (trace, t1, t2, !univar_pairs)::cstrs - end +(* Duplicate a type, preserving only type variables *) +let duplicate_type ty = + Subst.type_expr Subst.identity ty -and subtype_list env trace tl1 tl2 cstrs = - if List.length tl1 <> List.length tl2 then - subtype_error env trace; - List.fold_left2 - (fun cstrs t1 t2 -> subtype_rec env ((t1, t2)::trace) t1 t2 cstrs) - cstrs tl1 tl2 +(* Same, for class types *) +let duplicate_class_type ty = + Subst.class_type Subst.identity ty -and subtype_fields env trace ty1 ty2 cstrs = - (* Assume that either rest1 or rest2 is not Tvar *) - let (fields1, rest1) = flatten_fields ty1 in - let (fields2, rest2) = flatten_fields ty2 in - let (pairs, miss1, miss2) = associate_fields fields1 fields2 in - let cstrs = - if rest2.desc = Tnil then cstrs else - if miss1 = [] then - subtype_rec env ((rest1, rest2)::trace) rest1 rest2 cstrs - else - (trace, build_fields (repr ty1).level miss1 rest1, rest2, - !univar_pairs) :: cstrs - in - let cstrs = - if miss2 = [] then cstrs else - (trace, rest1, build_fields (repr ty2).level miss2 (newvar ()), - !univar_pairs) :: cstrs - in - List.fold_left - (fun cstrs (_, _k1, t1, _k2, t2) -> - (* These fields are always present *) - subtype_rec env ((t1, t2)::trace) t1 t2 cstrs) - cstrs pairs -and subtype_row env trace row1 row2 cstrs = - let row1 = row_repr row1 and row2 = row_repr row2 in - let r1, r2, pairs = - merge_row_fields row1.row_fields row2.row_fields in - let more1 = repr row1.row_more - and more2 = repr row2.row_more in - match more1.desc, more2.desc with - Tconstr(p1,_,_), Tconstr(p2,_,_) when Path.same p1 p2 -> - subtype_rec env ((more1,more2)::trace) more1 more2 cstrs - | (Tvar _|Tconstr _|Tnil), (Tvar _|Tconstr _|Tnil) - when row1.row_closed && r1 = [] -> - List.fold_left - (fun cstrs (_,f1,f2) -> - match row_field_repr f1, row_field_repr f2 with - (Rpresent None|Reither(true,_,_,_)), Rpresent None -> - cstrs - | Rpresent(Some t1), Rpresent(Some t2) -> - subtype_rec env ((t1, t2)::trace) t1 t2 cstrs - | Reither(false, t1::_, _, _), Rpresent(Some t2) -> - subtype_rec env ((t1, t2)::trace) t1 t2 cstrs - | Rabsent, _ -> cstrs - | _ -> raise Exit) - cstrs pairs - | Tunivar _, Tunivar _ - when row1.row_closed = row2.row_closed && r1 = [] && r2 = [] -> - let cstrs = - subtype_rec env ((more1,more2)::trace) more1 more2 cstrs in - List.fold_left - (fun cstrs (_,f1,f2) -> - match row_field_repr f1, row_field_repr f2 with - Rpresent None, Rpresent None - | Reither(true,[],_,_), Reither(true,[],_,_) - | Rabsent, Rabsent -> - cstrs - | Rpresent(Some t1), Rpresent(Some t2) - | Reither(false,[t1],_,_), Reither(false,[t2],_,_) -> - subtype_rec env ((t1, t2)::trace) t1 t2 cstrs - | _ -> raise Exit) - cstrs pairs - | _ -> - raise Exit + (*****************************) + (* Type level manipulation *) + (*****************************) -let subtype env ty1 ty2 = - TypePairs.clear subtypes; - univar_pairs := []; - (* Build constraint set. *) - let cstrs = subtype_rec env [(ty1, ty2)] ty1 ty2 [] in - TypePairs.clear subtypes; - (* Enforce constraints. *) - function () -> - List.iter - (function (trace0, t1, t2, pairs) -> - try unify_pairs (ref env) t1 t2 pairs with Unify trace -> - raise (Subtype (expand_trace env (List.rev trace0), - List.tl (List.tl trace)))) - (List.rev cstrs) +(* + It would be a bit more efficient to remove abbreviation expansions + rather than generalizing them: these expansions will usually not be + used anymore. However, this is not possible in the general case, as + [expand_abbrev] (via [subst]) requires these expansions to be + preserved. Does it worth duplicating this code ? +*) +let rec generalize ty = + let ty = repr ty in + if (ty.level > !current_level) && (ty.level <> generic_level) then begin + set_level ty generic_level; + begin match ty.desc with + Tconstr (_, _, abbrev) -> + iter_abbrev generalize !abbrev + | _ -> () + end; + iter_type_expr generalize ty + end - (*******************) - (* Miscellaneous *) - (*******************) +let generalize ty = + simple_abbrevs := Mnil; + generalize ty -(* Utility for printing. The resulting type is not used in computation. *) -let rec unalias_object ty = +(* Generalize the structure and lower the variables *) + +let rec generalize_structure var_level ty = let ty = repr ty in - match ty.desc with - Tfield (s, k, t1, t2) -> - newty2 ty.level (Tfield (s, k, t1, unalias_object t2)) - | Tvar _ | Tnil -> - newty2 ty.level ty.desc - | Tunivar _ -> - ty - | Tconstr _ -> - newvar2 ty.level - | _ -> - assert false + if ty.level <> generic_level then begin + if is_Tvar ty && ty.level > var_level then + set_level ty var_level + else if + ty.level > !current_level && + match ty.desc with + Tconstr (p, _, abbrev) -> + not (is_object_type p) && (abbrev := Mnil; true) + | _ -> true + then begin + set_level ty generic_level; + iter_type_expr (generalize_structure var_level) ty + end + end -let unalias ty = +let generalize_structure var_level ty = + simple_abbrevs := Mnil; + generalize_structure var_level ty + +(* Generalize the spine of a function, if the level >= !current_level *) + +let rec generalize_spine ty = let ty = repr ty in + if ty.level < !current_level || ty.level = generic_level then () else match ty.desc with - Tvar _ | Tunivar _ -> - ty - | Tvariant row -> - let row = row_repr row in - let more = row.row_more in - newty2 ty.level - (Tvariant {row with row_more = newty2 more.level more.desc}) - | Tobject (ty, nm) -> - newty2 ty.level (Tobject (unalias_object ty, nm)) - | _ -> - newty2 ty.level ty.desc + Tarrow (_, ty1, ty2, _) -> + set_level ty generic_level; + generalize_spine ty1; + generalize_spine ty2; + | Tpoly (ty', _) -> + set_level ty generic_level; + generalize_spine ty' + | Ttuple tyl + | Tpackage (_, _, tyl) -> + set_level ty generic_level; + List.iter generalize_spine tyl + | Tconstr (p, tyl, memo) when not (is_object_type p) -> + set_level ty generic_level; + memo := Mnil; + List.iter generalize_spine tyl + | _ -> () -(* Return the arity (as for curried functions) of the given type. *) -let rec arity ty = - match (repr ty).desc with - Tarrow(_, _t1, t2, _) -> 1 + arity t2 - | _ -> 0 +let forward_try_expand_once = (* Forward declaration *) + ref (fun _env _ty -> raise Cannot_expand) -(* Check whether an abbreviation expands to itself. *) -let cyclic_abbrev env id ty = - let rec check_cycle seen ty = - let ty = repr ty in - match ty.desc with - Tconstr (p, _tl, _abbrev) -> - p = Path.Pident id || List.memq ty seen || - begin try - check_cycle (ty :: seen) (expand_abbrev_opt env ty) - with - Cannot_expand -> false - | Unify _ -> true - end - | _ -> - false - in check_cycle [] ty +(* + Lower the levels of a type (assume [level] is not + [generic_level]). +*) +(* + The level of a type constructor must be greater than its binding + time. That way, a type constructor cannot escape the scope of its + definition, as would be the case in + let x = ref [] + module M = struct type t let _ = (x : t list ref) end + (without this constraint, the type system would actually be unsound.) +*) +let get_level env p = + try + match (Env.find_type p env).type_newtype_level with + | None -> Path.binding_time p + | Some (x, _) -> x + with + | Not_found -> + (* no newtypes in predef *) + Path.binding_time p -(* Check for non-generalizable type variables *) -exception Non_closed0 -let visited = ref TypeSet.empty +let rec normalize_package_path env p = + let t = + try (Env.find_modtype p env).mtd_type + with Not_found -> None + in + match t with + | Some (Mty_ident p) -> normalize_package_path env p + | Some (Mty_signature _ | Mty_functor _ | Mty_alias _) | None -> + match p with + Path.Pdot (p1, s, n) -> + (* For module aliases *) + let p1' = Env.normalize_path None env p1 in + if Path.same p1 p1' then p else + normalize_package_path env (Path.Pdot (p1', s, n)) + | _ -> p -let rec closed_schema_rec env ty = +let rec update_level env level expand ty = let ty = repr ty in - if TypeSet.mem ty !visited then () else begin - visited := TypeSet.add ty !visited; + if ty.level > level then begin + begin match Env.gadt_instance_level env ty with + Some lv -> if level < lv then raise (Unify [(ty, newvar2 level)]) + | None -> () + end; match ty.desc with - Tvar _ when ty.level <> generic_level -> - raise Non_closed0 - | Tconstr _ -> - let old = !visited in - begin try iter_type_expr (closed_schema_rec env) ty - with Non_closed0 -> try - visited := old; - closed_schema_rec env (try_expand_head try_expand_safe env ty) + Tconstr(p, _tl, _abbrev) when level < get_level env p -> + (* Try first to replace an abbreviation by its expansion. *) + begin try + (* if is_newtype env p then raise Cannot_expand; *) + link_type ty (!forward_try_expand_once env ty); + update_level env level expand ty with Cannot_expand -> - raise Non_closed0 + (* +++ Levels should be restored... *) + (* Format.printf "update_level: %i < %i@." level (get_level env p); *) + if level < get_level env p then raise (Unify [(ty, newvar2 level)]); + iter_type_expr (update_level env level expand) ty end - | Tfield(_, kind, t1, t2) -> - if field_kind_repr kind = Fpresent then - closed_schema_rec env t1; - closed_schema_rec env t2 + | Tconstr(_, _ :: _, _) when expand -> + begin try + link_type ty (!forward_try_expand_once env ty); + update_level env level expand ty + with Cannot_expand -> + set_level ty level; + iter_type_expr (update_level env level expand) ty + end + | Tpackage (p, nl, tl) when level < Path.binding_time p -> + let p' = normalize_package_path env p in + if Path.same p p' then raise (Unify [(ty, newvar2 level)]); + log_type ty; ty.desc <- Tpackage (p', nl, tl); + update_level env level expand ty + | Tobject(_, ({contents=Some(p, _tl)} as nm)) + when level < get_level env p -> + set_name nm None; + update_level env level expand ty | Tvariant row -> let row = row_repr row in - iter_row (closed_schema_rec env) row; - if not (static_row row) then closed_schema_rec env row.row_more + begin match row.row_name with + | Some (p, _tl) when level < get_level env p -> + log_type ty; + ty.desc <- Tvariant {row with row_name = None} + | _ -> () + end; + set_level ty level; + iter_type_expr (update_level env level expand) ty + | Tfield(lab, _, ty1, _) + when lab = dummy_method && (repr ty1).level > level -> + raise (Unify [(ty1, newvar2 level)]) | _ -> - iter_type_expr (closed_schema_rec env) ty + set_level ty level; + (* XXX what about abbreviations in Tconstr ? *) + iter_type_expr (update_level env level expand) ty end -(* Return whether all variables of type [ty] are generic. *) -let closed_schema env ty = - visited := TypeSet.empty; - try - closed_schema_rec env ty; - visited := TypeSet.empty; - true - with Non_closed0 -> - visited := TypeSet.empty; - false +(* First try without expanding, then expand everything, + to avoid combinatorial blow-up *) +let update_level env level ty = + let ty = repr ty in + if ty.level > level then begin + let snap = snapshot () in + try + update_level env level false ty + with Unify _ -> + backtrack snap; + update_level env level true ty + end -(* Normalize a type before printing, saving... *) -(* Cannot use mark_type because deep_occur uses it too *) -let rec normalize_type_rec env visited ty = +(* Generalize and lower levels of contravariant branches simultaneously *) + +let rec generalize_expansive env var_level visited ty = let ty = repr ty in - if not (TypeSet.mem ty !visited) then begin - visited := TypeSet.add ty !visited; - let tm = row_of_type ty in - begin if not (is_Tconstr ty) && is_constr_row ~allow_ident:false tm then - match tm.desc with (* PR#7348 *) - Tconstr (Path.Pdot(m,i,pos), tl, _abbrev) -> - let i' = String.sub i 0 (String.length i - 4) in - log_type ty; - ty.desc <- Tconstr(Path.Pdot(m,i',pos), tl, ref Mnil) - | _ -> assert false - else match ty.desc with - | Tvariant row -> - let row = row_repr row in - let fields = List.map - (fun (l,f0) -> - let f = row_field_repr f0 in l, - match f with Reither(b, ty::(_::_ as tyl), m, e) -> - let tyl' = - List.fold_left - (fun tyl ty -> - if List.exists (fun ty' -> equal env false [ty] [ty']) tyl - then tyl else ty::tyl) - [ty] tyl - in - if f != f0 || List.length tyl' < List.length tyl then - Reither(b, List.rev tyl', m, e) - else f - | _ -> f) - row.row_fields in - let fields = - List.sort (fun (p,_) (q,_) -> compare p q) - (List.filter (fun (_,fi) -> fi <> Rabsent) fields) in - log_type ty; - ty.desc <- Tvariant {row with row_fields = fields} - | Tobject (fi, nm) -> - begin match !nm with - | None -> () - | Some (n, v :: l) -> - if deep_occur ty (newgenty (Ttuple l)) then - (* The abbreviation may be hiding something, so remove it *) - set_name nm None - else let v' = repr v in - begin match v'.desc with - | Tvar _ | Tunivar _ -> - if v' != v then set_name nm (Some (n, v' :: l)) - | Tnil -> - log_type ty; ty.desc <- Tconstr (n, l, ref Mnil) - | _ -> set_name nm None - end - | _ -> - fatal_error "Ctype.normalize_type_rec" - end; - let fi = repr fi in - if fi.level < lowest_level then () else - let fields, row = flatten_fields fi in - let fi' = build_fields fi.level fields row in - log_type ty; fi.desc <- fi'.desc - | _ -> () - end; - iter_type_expr (normalize_type_rec env visited) ty + if ty.level = generic_level || ty.level <= var_level then () else + if not (Hashtbl.mem visited ty.id) then begin + Hashtbl.add visited ty.id (); + match ty.desc with + Tconstr (path, tyl, abbrev) -> + let variance = + try (Env.find_type path env).type_variance + with Not_found -> List.map (fun _ -> Variance.may_inv) tyl in + abbrev := Mnil; + List.iter2 + (fun v t -> + if Variance.(mem May_weak v) + then generalize_structure var_level t + else generalize_expansive env var_level visited t) + variance tyl + | Tpackage (_, _, tyl) -> + List.iter (generalize_structure var_level) tyl + | Tarrow (_, t1, t2, _) -> + generalize_structure var_level t1; + generalize_expansive env var_level visited t2 + | _ -> + iter_type_expr (generalize_expansive env var_level visited) ty end -let normalize_type env ty = - normalize_type_rec env (ref TypeSet.empty) ty +let generalize_expansive env ty = + simple_abbrevs := Mnil; + try + generalize_expansive env !nongen_level (Hashtbl.create 7) ty + with Unify ([_, ty'] as tr) -> + raise (Unify ((ty, ty') :: tr)) +let generalize_global ty = generalize_structure !global_level ty +let generalize_structure ty = generalize_structure !current_level ty - (*************************) - (* Remove dependencies *) - (*************************) +(* Correct the levels of type [ty]. *) +let correct_levels ty = + duplicate_type ty +(* Only generalize the type ty0 in ty *) +let limited_generalize ty0 ty = + let ty0 = repr ty0 in -(* - Variables are left unchanged. Other type nodes are duplicated, with - levels set to generic level. - We cannot use Tsubst here, because unification may be called by - expand_abbrev. -*) + let graph = Hashtbl.create 17 in + let idx = ref lowest_level in + let roots = ref [] in -let nondep_hash = TypeHash.create 47 -let nondep_variants = TypeHash.create 17 -let clear_hash () = - TypeHash.clear nondep_hash; TypeHash.clear nondep_variants + let rec inverse pty ty = + let ty = repr ty in + if (ty.level > !current_level) || (ty.level = generic_level) then begin + decr idx; + Hashtbl.add graph !idx (ty, ref pty); + if (ty.level = generic_level) || (ty == ty0) then + roots := ty :: !roots; + set_level ty !idx; + iter_type_expr (inverse [ty]) ty + end else if ty.level < lowest_level then begin + let (_, parents) = Hashtbl.find graph ty.level in + parents := pty @ !parents + end -let rec nondep_type_rec env id ty = - match ty.desc with - Tvar _ | Tunivar _ -> ty - | Tlink ty -> nondep_type_rec env id ty - | _ -> try TypeHash.find nondep_hash ty - with Not_found -> - let ty' = newgenvar () in (* Stub *) - TypeHash.add nondep_hash ty ty'; - ty'.desc <- - begin match ty.desc with - | Tconstr(p, tl, _abbrev) -> - if Path.isfree id p then - begin try - Tlink (nondep_type_rec env id - (expand_abbrev env (newty2 ty.level ty.desc))) - (* - The [Tlink] is important. The expanded type may be a - variable, or may not be completely copied yet - (recursive type), so one cannot just take its - description. - *) - with Cannot_expand | Unify _ -> - raise Not_found - end - else - Tconstr(p, List.map (nondep_type_rec env id) tl, ref Mnil) - | Tpackage(p, nl, tl) when Path.isfree id p -> - let p' = normalize_package_path env p in - if Path.isfree id p' then raise Not_found; - Tpackage (p', nl, List.map (nondep_type_rec env id) tl) - | Tobject (t1, name) -> - Tobject (nondep_type_rec env id t1, - ref (match !name with - None -> None - | Some (p, tl) -> - if Path.isfree id p then None - else Some (p, List.map (nondep_type_rec env id) tl))) - | Tvariant row -> - let row = row_repr row in - let more = repr row.row_more in - (* We must keep sharing according to the row variable *) - begin try - let ty2 = TypeHash.find nondep_variants more in - (* This variant type has been already copied *) - TypeHash.add nondep_hash ty ty2; - Tlink ty2 - with Not_found -> - (* Register new type first for recursion *) - TypeHash.add nondep_variants more ty'; - let static = static_row row in - let more' = if static then newgenty Tnil else more in - (* Return a new copy *) - let row = - copy_row (nondep_type_rec env id) true row true more' in - match row.row_name with - Some (p, _tl) when Path.isfree id p -> - Tvariant {row with row_name = None} - | _ -> Tvariant row - end - | _ -> copy_type_desc (nondep_type_rec env id) ty.desc - end; - ty' + and generalize_parents ty = + let idx = ty.level in + if idx <> generic_level then begin + set_level ty generic_level; + List.iter generalize_parents !(snd (Hashtbl.find graph idx)); + (* Special case for rows: must generalize the row variable *) + match ty.desc with + Tvariant row -> + let more = row_more row in + let lv = more.level in + if (lv < lowest_level || lv > !current_level) + && lv <> generic_level then set_level more generic_level + | _ -> () + end + in -let nondep_type env id ty = - try - let ty' = nondep_type_rec env id ty in - clear_hash (); - ty' - with Not_found -> - clear_hash (); - raise Not_found + inverse [] ty; + if ty0.level < lowest_level then + iter_type_expr (inverse []) ty0; + List.iter generalize_parents !roots; + Hashtbl.iter + (fun _ (ty, _) -> + if ty.level <> generic_level then set_level ty !current_level) + graph -let () = nondep_type' := nondep_type -let unroll_abbrev id tl ty = - let ty = repr ty and path = Path.Pident id in - if is_Tvar ty || (List.exists (deep_occur ty) tl) - || is_object_type path then - ty - else - let ty' = newty2 ty.level ty.desc in - link_type ty (newty2 ty.level (Tconstr (path, tl, ref Mnil))); - ty' +(* Compute statically the free univars of all nodes in a type *) +(* This avoids doing it repeatedly during instantiation *) -(* Preserve sharing inside type declarations. *) -let nondep_type_decl env mid id is_covariant decl = - try - let params = List.map (nondep_type_rec env mid) decl.type_params in - let tk = - try map_kind (nondep_type_rec env mid) decl.type_kind - with Not_found when is_covariant -> Type_abstract - and tm = - try match decl.type_manifest with - None -> None - | Some ty -> - Some (unroll_abbrev id params (nondep_type_rec env mid ty)) - with Not_found when is_covariant -> - None - in - clear_hash (); - let priv = - match tm with - | Some ty when Btype.has_constr_row ty -> Private - | _ -> decl.type_private - in - { type_params = params; - type_arity = decl.type_arity; - type_kind = tk; - type_manifest = tm; - type_private = priv; - type_variance = decl.type_variance; - type_newtype_level = None; - type_loc = decl.type_loc; - type_attributes = decl.type_attributes; - type_immediate = decl.type_immediate; - type_unboxed = decl.type_unboxed; - } - with Not_found -> - clear_hash (); - raise Not_found +type inv_type_expr = + { inv_type : type_expr; + mutable inv_parents : inv_type_expr list } -(* Preserve sharing inside extension constructors. *) -let nondep_extension_constructor env mid ext = +let rec inv_type hash pty ty = + let ty = repr ty in try - let type_path, type_params = - if Path.isfree mid ext.ext_type_path then - begin - let ty = - newgenty (Tconstr(ext.ext_type_path, ext.ext_type_params, ref Mnil)) - in - let ty' = nondep_type_rec env mid ty in - match (repr ty').desc with - Tconstr(p, tl, _) -> p, tl - | _ -> raise Not_found - end - else - let type_params = - List.map (nondep_type_rec env mid) ext.ext_type_params - in - ext.ext_type_path, type_params - in - let args = map_type_expr_cstr_args (nondep_type_rec env mid) ext.ext_args in - let ret_type = may_map (nondep_type_rec env mid) ext.ext_ret_type in - clear_hash (); - { ext_type_path = type_path; - ext_type_params = type_params; - ext_args = args; - ext_ret_type = ret_type; - ext_private = ext.ext_private; - ext_attributes = ext.ext_attributes; - ext_loc = ext.ext_loc; - } + let inv = TypeHash.find hash ty in + inv.inv_parents <- pty @ inv.inv_parents with Not_found -> - clear_hash (); - raise Not_found + let inv = { inv_type = ty; inv_parents = pty } in + TypeHash.add hash ty inv; + iter_type_expr (inv_type hash [inv]) ty +let compute_univars ty = + let inverted = TypeHash.create 17 in + inv_type inverted [] ty; + let node_univars = TypeHash.create 17 in + let rec add_univar univ inv = + match inv.inv_type.desc with + Tpoly (_ty, tl) when List.memq univ (List.map repr tl) -> () + | _ -> + try + let univs = TypeHash.find node_univars inv.inv_type in + if not (TypeSet.mem univ !univs) then begin + univs := TypeSet.add univ !univs; + List.iter (add_univar univ) inv.inv_parents + end + with Not_found -> + TypeHash.add node_univars inv.inv_type (ref(TypeSet.singleton univ)); + List.iter (add_univar univ) inv.inv_parents + in + TypeHash.iter (fun ty inv -> if is_Tunivar ty then add_univar ty inv) + inverted; + fun ty -> + try !(TypeHash.find node_univars ty) with Not_found -> TypeSet.empty -(* Preserve sharing inside class types. *) -let nondep_class_signature env id sign = - { csig_self = nondep_type_rec env id sign.csig_self; - csig_vars = - Vars.map (function (m, v, t) -> (m, v, nondep_type_rec env id t)) - sign.csig_vars; - csig_concr = sign.csig_concr; - csig_inher = - List.map (fun (p,tl) -> (p, List.map (nondep_type_rec env id) tl)) - sign.csig_inher } -let rec nondep_class_type env id = + (*******************) + (* Instantiation *) + (*******************) + + +let rec find_repr p1 = function - Cty_constr (p, _, cty) when Path.isfree id p -> - nondep_class_type env id cty - | Cty_constr (p, tyl, cty) -> - Cty_constr (p, List.map (nondep_type_rec env id) tyl, - nondep_class_type env id cty) - | Cty_signature sign -> - Cty_signature (nondep_class_signature env id sign) - | Cty_arrow (l, ty, cty) -> - Cty_arrow (l, nondep_type_rec env id ty, nondep_class_type env id cty) + Mnil -> + None + | Mcons (Public, p2, ty, _, _) when Path.same p1 p2 -> + Some ty + | Mcons (_, _, _, _, rem) -> + find_repr p1 rem + | Mlink {contents = rem} -> + find_repr p1 rem -let nondep_class_declaration env id decl = - assert (not (Path.isfree id decl.cty_path)); - let decl = - { cty_params = List.map (nondep_type_rec env id) decl.cty_params; - cty_variance = decl.cty_variance; - cty_type = nondep_class_type env id decl.cty_type; - cty_path = decl.cty_path; - cty_new = - begin match decl.cty_new with - None -> None - | Some ty -> Some (nondep_type_rec env id ty) - end; - cty_loc = decl.cty_loc; - cty_attributes = decl.cty_attributes; - } - in - clear_hash (); - decl +(* + Generic nodes are duplicated, while non-generic nodes are left + as-is. + During instantiation, the description of a generic node is first + replaced by a link to a stub ([Tsubst (newvar ())]). Once the + copy is made, it replaces the stub. + After instantiation, the description of generic node, which was + stored by [save_desc], must be put back, using [cleanup_types]. +*) -let nondep_cltype_declaration env id decl = - assert (not (Path.isfree id decl.clty_path)); - let decl = - { clty_params = List.map (nondep_type_rec env id) decl.clty_params; - clty_variance = decl.clty_variance; - clty_type = nondep_class_type env id decl.clty_type; - clty_path = decl.clty_path; - clty_loc = decl.clty_loc; - clty_attributes = decl.clty_attributes; - } - in - clear_hash (); - decl +let abbreviations = ref (ref Mnil) + (* Abbreviation memorized. *) -(* collapse conjunctive types in class parameters *) -let rec collapse_conj env visited ty = +(* partial: we may not wish to copy the non generic types + before we call type_pat *) +let rec copy ?env ?partial ?keep_names ty = + let copy = copy ?env ?partial ?keep_names in let ty = repr ty in - if List.memq ty visited then () else - let visited = ty :: visited in match ty.desc with - Tvariant row -> - let row = row_repr row in - List.iter - (fun (_l,fi) -> - match row_field_repr fi with - Reither (c, t1::(_::_ as tl), m, e) -> - List.iter (unify env t1) tl; - set_row_field e (Reither (c, [t1], m, ref None)) - | _ -> - ()) - row.row_fields; - iter_row (collapse_conj env visited) row + Tsubst ty -> ty | _ -> - iter_type_expr (collapse_conj env visited) ty + if ty.level <> generic_level && partial = None then ty else + (* We only forget types that are non generic and do not contain + free univars *) + let forget = + if ty.level = generic_level then generic_level else + match partial with + None -> assert false + | Some (free_univars, keep) -> + if TypeSet.is_empty (free_univars ty) then + if keep then ty.level else !current_level + else generic_level + in + if forget <> generic_level then newty2 forget (Tvar None) else + let desc = ty.desc in + save_desc ty desc; + let t = newvar() in (* Stub *) + begin match env with + Some env when Env.has_local_constraints env -> + begin match Env.gadt_instance_level env ty with + Some lv -> Env.add_gadt_instances env lv [t] + | None -> () + end + | _ -> () + end; + ty.desc <- Tsubst t; + t.desc <- + begin match desc with + | Tconstr (p, tl, _) -> + let abbrevs = proper_abbrevs p tl !abbreviations in + begin match find_repr p !abbrevs with + Some ty when repr ty != t -> + Tlink ty + | _ -> + (* + One must allocate a new reference, so that abbrevia- + tions belonging to different branches of a type are + independent. + Moreover, a reference containing a [Mcons] must be + shared, so that the memorized expansion of an abbrevi- + ation can be released by changing the content of just + one reference. + *) + Tconstr (p, List.map copy tl, + ref (match !(!abbreviations) with + Mcons _ -> Mlink !abbreviations + | abbrev -> abbrev)) + end + | Tvariant row0 -> + let row = row_repr row0 in + let more = repr row.row_more in + (* We must substitute in a subtle way *) + (* Tsubst takes a tuple containing the row var and the variant *) + begin match more.desc with + Tsubst {desc = Ttuple [_;ty2]} -> + (* This variant type has been already copied *) + ty.desc <- Tsubst ty2; (* avoid Tlink in the new type *) + Tlink ty2 + | _ -> + (* If the row variable is not generic, we must keep it *) + let keep = more.level <> generic_level in + let more' = + match more.desc with + Tsubst ty -> ty + | Tconstr _ | Tnil -> + if keep then save_desc more more.desc; + copy more + | Tvar _ | Tunivar _ -> + save_desc more more.desc; + if keep then more else newty more.desc + | _ -> assert false + in + let row = + match repr more' with (* PR#6163 *) + {desc=Tconstr _} when not row.row_fixed -> + {row with row_fixed = true} + | _ -> row + in + (* Open row if partial for pattern and contains Reither *) + let more', row = + match partial with + Some (free_univars, false) -> + let more' = + if more.id != more'.id then more' else + let lv = if keep then more.level else !current_level in + newty2 lv (Tvar None) + in + let not_reither (_, f) = + match row_field_repr f with + Reither _ -> false + | _ -> true + in + if row.row_closed && not row.row_fixed + && TypeSet.is_empty (free_univars ty) + && not (List.for_all not_reither row.row_fields) then + (more', + {row_fields = List.filter not_reither row.row_fields; + row_more = more'; row_bound = (); + row_closed = false; row_fixed = false; row_name = None}) + else (more', row) + | _ -> (more', row) + in + (* Register new type first for recursion *) + more.desc <- Tsubst(newgenty(Ttuple[more';t])); + (* Return a new copy *) + Tvariant (copy_row copy true row keep more') + end + | Tfield (_p, k, _ty1, ty2) -> + begin match field_kind_repr k with + Fabsent -> Tlink (copy ty2) + | Fpresent -> copy_type_desc copy desc + | Fvar r -> + dup_kind r; + copy_type_desc copy desc + end + | Tobject (ty1, _) when partial <> None -> + Tobject (copy ty1, ref None) + | _ -> copy_type_desc ?keep_names copy desc + end; + t -let collapse_conj_params env params = - List.iter (collapse_conj env []) params +let simple_copy t = copy t -let same_constr env t1 t2 = - let t1 = expand_head env t1 in - let t2 = expand_head env t2 in - match t1.desc, t2.desc with - | Tconstr (p1, _, _), Tconstr (p2, _, _) -> Path.same p1 p2 - | _ -> false +(**** Variants of instantiations ****) -let () = - Env.same_constr := same_constr +let gadt_env env = + if Env.has_local_constraints env + then Some env + else None -let maybe_pointer_type env typ = - match (repr typ).desc with - | Tconstr(p, _args, _abbrev) -> - begin try - let type_decl = Env.find_type p env in - not type_decl.type_immediate - with Not_found -> true - (* This can happen due to e.g. missing -I options, - causing some .cmi files to be unavailable. - Maybe we should emit a warning. *) - end - | Tvariant row -> - let row = Btype.row_repr row in - (* if all labels are devoid of arguments, not a pointer *) - not row.row_closed - || List.exists - (function - | _, (Rpresent (Some _) | Reither (false, _, _, _)) -> true - | _ -> false) - row.row_fields - | _ -> true +let instance ?partial env sch = + let env = gadt_env env in + let partial = + match partial with + None -> None + | Some keep -> Some (compute_univars sch, keep) + in + let ty = copy ?env ?partial sch in + cleanup_types (); + ty -end -module Printtyp : sig -#1 "printtyp.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let instance_def sch = + let ty = copy sch in + cleanup_types (); + ty -(* Printing functions *) +let generic_instance env sch = + let old = !current_level in + current_level := generic_level; + let ty = instance env sch in + current_level := old; + ty -open Format -open Types -open Outcometree +let instance_list env schl = + let env = gadt_env env in + let tyl = List.map (fun t -> copy ?env t) schl in + cleanup_types (); + tyl -val longident: formatter -> Longident.t -> unit -val ident: formatter -> Ident.t -> unit -val tree_of_path: Path.t -> out_ident -val path: formatter -> Path.t -> unit -val string_of_path: Path.t -> string -val raw_type_expr: formatter -> type_expr -> unit -val string_of_label: Asttypes.arg_label -> string +let reified_var_counter = ref Vars.empty +let reset_reified_var_counter () = + reified_var_counter := Vars.empty -val wrap_printing_env: Env.t -> (unit -> 'a) -> 'a - (* Call the function using the environment for type path shortening *) - (* This affects all the printing functions below *) +(* names given to new type constructors. + Used for existential types and + local constraints *) +let get_new_abstract_name s = + let index = + try Vars.find s !reified_var_counter + 1 + with Not_found -> 0 in + reified_var_counter := Vars.add s index !reified_var_counter; + if index = 0 && s <> "" && s.[String.length s - 1] <> '$' then s else + Printf.sprintf "%s%d" s index -val reset: unit -> unit -val mark_loops: type_expr -> unit -val reset_and_mark_loops: type_expr -> unit -val reset_and_mark_loops_list: type_expr list -> unit -val type_expr: formatter -> type_expr -> unit -val constructor_arguments: formatter -> constructor_arguments -> unit -val tree_of_type_scheme: type_expr -> out_type -val type_sch : formatter -> type_expr -> unit -val type_scheme: formatter -> type_expr -> unit -(* Maxence *) -val reset_names: unit -> unit -val type_scheme_max: ?b_reset_names: bool -> - formatter -> type_expr -> unit -(* End Maxence *) -val tree_of_value_description: Ident.t -> value_description -> out_sig_item -val value_description: Ident.t -> formatter -> value_description -> unit -val tree_of_type_declaration: - Ident.t -> type_declaration -> rec_status -> out_sig_item -val type_declaration: Ident.t -> formatter -> type_declaration -> unit -val tree_of_extension_constructor: - Ident.t -> extension_constructor -> ext_status -> out_sig_item -val extension_constructor: - Ident.t -> formatter -> extension_constructor -> unit -val tree_of_module: - Ident.t -> ?ellipsis:bool -> module_type -> rec_status -> out_sig_item -val modtype: formatter -> module_type -> unit -val signature: formatter -> signature -> unit -val tree_of_modtype_declaration: - Ident.t -> modtype_declaration -> out_sig_item -val tree_of_signature: Types.signature -> out_sig_item list -val tree_of_typexp: bool -> type_expr -> out_type -val modtype_declaration: Ident.t -> formatter -> modtype_declaration -> unit -val class_type: formatter -> class_type -> unit -val tree_of_class_declaration: - Ident.t -> class_declaration -> rec_status -> out_sig_item -val class_declaration: Ident.t -> formatter -> class_declaration -> unit -val tree_of_cltype_declaration: - Ident.t -> class_type_declaration -> rec_status -> out_sig_item -val cltype_declaration: Ident.t -> formatter -> class_type_declaration -> unit -val type_expansion: type_expr -> Format.formatter -> type_expr -> unit -val prepare_expansion: type_expr * type_expr -> type_expr * type_expr -val trace: - bool -> bool-> string -> formatter -> (type_expr * type_expr) list -> unit -val report_unification_error: - formatter -> Env.t -> ?unif:bool -> (type_expr * type_expr) list -> - (formatter -> unit) -> (formatter -> unit) -> - unit +let new_declaration newtype manifest = + { + type_params = []; + type_arity = 0; + type_kind = Type_abstract; + type_private = Public; + type_manifest = manifest; + type_variance = []; + type_newtype_level = newtype; + type_loc = Location.none; + type_attributes = []; + type_immediate = false; + type_unboxed = unboxed_false_default_false; + } + +let instance_constructor ?in_pattern cstr = + begin match in_pattern with + | None -> () + | Some (env, newtype_lev) -> + let process existential = + let decl = new_declaration (Some (newtype_lev, newtype_lev)) None in + let name = + match repr existential with + {desc = Tvar (Some name)} -> "$" ^ cstr.cstr_name ^ "_'" ^ name + | _ -> "$" ^ cstr.cstr_name + in + let path = Path.Pident (Ident.create (get_new_abstract_name name)) in + let new_env = Env.add_local_type path decl !env in + env := new_env; + let to_unify = newty (Tconstr (path,[],ref Mnil)) in + let tv = copy existential in + assert (is_Tvar tv); + link_type tv to_unify + in + List.iter process cstr.cstr_existentials + end; + let ty_res = copy cstr.cstr_res in + let ty_args = List.map simple_copy cstr.cstr_args in + cleanup_types (); + (ty_args, ty_res) + +let instance_parameterized_type ?keep_names sch_args sch = + let ty_args = List.map (fun t -> copy ?keep_names t) sch_args in + let ty = copy sch in + cleanup_types (); + (ty_args, ty) + +let instance_parameterized_type_2 sch_args sch_lst sch = + let ty_args = List.map simple_copy sch_args in + let ty_lst = List.map simple_copy sch_lst in + let ty = copy sch in + cleanup_types (); + (ty_args, ty_lst, ty) + +let map_kind f = function + | Type_abstract -> Type_abstract + | Type_open -> Type_open + | Type_variant cl -> + Type_variant ( + List.map + (fun c -> + {c with + cd_args = map_type_expr_cstr_args f c.cd_args; + cd_res = may_map f c.cd_res + }) + cl) + | Type_record (fl, rr) -> + Type_record ( + List.map + (fun l -> + {l with ld_type = f l.ld_type} + ) fl, rr) + + +let instance_declaration decl = + let decl = + {decl with type_params = List.map simple_copy decl.type_params; + type_manifest = may_map simple_copy decl.type_manifest; + type_kind = map_kind simple_copy decl.type_kind; + } + in + cleanup_types (); + decl +let instance_class params cty = + let rec copy_class_type = + function + Cty_constr (path, tyl, cty) -> + Cty_constr (path, List.map simple_copy tyl, copy_class_type cty) + | Cty_signature sign -> + Cty_signature + {csig_self = copy sign.csig_self; + csig_vars = + Vars.map (function (m, v, ty) -> (m, v, copy ty)) sign.csig_vars; + csig_concr = sign.csig_concr; + csig_inher = + List.map (fun (p,tl) -> (p, List.map simple_copy tl)) + sign.csig_inher} + | Cty_arrow (l, ty, cty) -> + Cty_arrow (l, copy ty, copy_class_type cty) + in + let params' = List.map simple_copy params in + let cty' = copy_class_type cty in + cleanup_types (); + (params', cty') -val super_report_unification_error: - formatter -> Env.t -> ?unif:bool -> (type_expr * type_expr) list -> - (formatter -> unit) -> (formatter -> unit) -> - unit +(**** Instantiation for types with free universal variables ****) +let rec diff_list l1 l2 = + if l1 == l2 then [] else + match l1 with [] -> invalid_arg "Ctype.diff_list" + | a :: l1 -> a :: diff_list l1 l2 -val report_subtyping_error: - formatter -> Env.t -> (type_expr * type_expr) list -> - string -> (type_expr * type_expr) list -> unit -val report_ambiguous_type_error: - formatter -> Env.t -> (Path.t * Path.t) -> (Path.t * Path.t) list -> - (formatter -> unit) -> (formatter -> unit) -> (formatter -> unit) -> unit +let conflicts free bound = + let bound = List.map repr bound in + TypeSet.exists (fun t -> List.memq (repr t) bound) free -(* for toploop *) -val print_items: (Env.t -> signature_item -> 'a option) -> - Env.t -> signature_item list -> (out_sig_item * 'a option) list +let delayed_copy = ref [] + (* copying to do later *) -end = struct -#1 "printtyp.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy and Jerome Vouillon, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +(* Copy without sharing until there are no free univars left *) +(* all free univars must be included in [visited] *) +let rec copy_sep fixed free bound visited ty = + let ty = repr ty in + let univars = free ty in + if TypeSet.is_empty univars then + if ty.level <> generic_level then ty else + let t = newvar () in + delayed_copy := + lazy (t.desc <- Tlink (copy ty)) + :: !delayed_copy; + t + else try + let t, bound_t = List.assq ty visited in + let dl = if is_Tunivar ty then [] else diff_list bound bound_t in + if dl <> [] && conflicts univars dl then raise Not_found; + t + with Not_found -> begin + let t = newvar() in (* Stub *) + let visited = + match ty.desc with + Tarrow _ | Ttuple _ | Tvariant _ | Tconstr _ | Tobject _ | Tpackage _ -> + (ty,(t,bound)) :: visited + | _ -> visited in + let copy_rec = copy_sep fixed free bound visited in + t.desc <- + begin match ty.desc with + | Tvariant row0 -> + let row = row_repr row0 in + let more = repr row.row_more in + (* We shall really check the level on the row variable *) + let keep = is_Tvar more && more.level <> generic_level in + let more' = copy_rec more in + let fixed' = fixed && is_Tvar (repr more') in + let row = copy_row copy_rec fixed' row keep more' in + Tvariant row + | Tpoly (t1, tl) -> + let tl = List.map repr tl in + let tl' = List.map (fun t -> newty t.desc) tl in + let bound = tl @ bound in + let visited = + List.map2 (fun ty t -> ty,(t,bound)) tl tl' @ visited in + Tpoly (copy_sep fixed free bound visited t1, tl') + | _ -> copy_type_desc copy_rec ty.desc + end; + t + end -(* Printing functions *) +let instance_poly ?(keep_names=false) fixed univars sch = + let univars = List.map repr univars in + let copy_var ty = + match ty.desc with + Tunivar name -> if keep_names then newty (Tvar name) else newvar () + | _ -> assert false + in + let vars = List.map copy_var univars in + let pairs = List.map2 (fun u v -> u, (v, [])) univars vars in + delayed_copy := []; + let ty = copy_sep fixed (compute_univars sch) [] pairs sch in + List.iter Lazy.force !delayed_copy; + delayed_copy := []; + cleanup_types (); + vars, ty -open Misc -open Ctype -open Format -open Longident -open Path -open Asttypes -open Types -open Btype -open Outcometree +let instance_label fixed lbl = + let ty_res = copy lbl.lbl_res in + let vars, ty_arg = + match repr lbl.lbl_arg with + {desc = Tpoly (ty, tl)} -> + instance_poly fixed tl ty + | _ -> + [], copy lbl.lbl_arg + in + cleanup_types (); + (vars, ty_arg, ty_res) -(* Print a long identifier *) +(**** Instantiation with parameter substitution ****) -let rec longident ppf = function - | Lident s -> pp_print_string ppf s - | Ldot(p, s) -> fprintf ppf "%a.%s" longident p s - | Lapply(p1, p2) -> fprintf ppf "%a(%a)" longident p1 longident p2 +let unify' = (* Forward declaration *) + ref (fun _env _ty1 _ty2 -> raise (Unify [])) -(* Print an identifier *) +let subst env level priv abbrev ty params args body = + if List.length params <> List.length args then raise (Unify []); + let old_level = !current_level in + current_level := level; + try + let body0 = newvar () in (* Stub *) + begin match ty with + None -> () + | Some ({desc = Tconstr (path, tl, _)} as ty) -> + let abbrev = proper_abbrevs path tl abbrev in + memorize_abbrev abbrev priv path ty body0 + | _ -> + assert false + end; + abbreviations := abbrev; + let (params', body') = instance_parameterized_type params body in + abbreviations := ref Mnil; + !unify' env body0 body'; + List.iter2 (!unify' env) params' args; + current_level := old_level; + body' + with Unify _ as exn -> + current_level := old_level; + raise exn -let unique_names = ref Ident.empty +(* + Only the shape of the type matters, not whether it is generic or + not. [generic_level] might be somewhat slower, but it ensures + invariants on types are enforced (decreasing levels), and we don't + care about efficiency here. +*) +let apply env params body args = + try + subst env generic_level Public (ref Mnil) None params args body + with + Unify _ -> raise Cannot_apply -let ident_name id = - try Ident.find_same id !unique_names with Not_found -> Ident.name id +let () = Subst.ctype_apply_env_empty := apply Env.empty -let add_unique id = - try ignore (Ident.find_same id !unique_names) - with Not_found -> - unique_names := Ident.add id (Ident.unique_toplevel_name id) !unique_names + (****************************) + (* Abbreviation expansion *) + (****************************) -let ident ppf id = pp_print_string ppf (ident_name id) +(* + If the environment has changed, memorized expansions might not + be correct anymore, and so we flush the cache. This is safe but + quite pessimistic: it would be enough to flush the cache when a + type or module definition is overridden in the environment. +*) +let previous_env = ref Env.empty +(*let string_of_kind = function Public -> "public" | Private -> "private"*) +let check_abbrev_env env = + if env != !previous_env then begin + (* prerr_endline "cleanup expansion cache"; *) + cleanup_abbrev (); + previous_env := env + end -(* Print a path *) -let ident_pervasives = Ident.create_persistent "Pervasives" -let printing_env = ref Env.empty -let non_shadowed_pervasive = function - | Pdot(Pident id, s, _pos) as path -> - Ident.same id ident_pervasives && - (try Path.same path (Env.lookup_type (Lident s) !printing_env) - with Not_found -> true) - | _ -> false +(* Expand an abbreviation. The expansion is memorized. *) +(* + Assume the level is greater than the path binding time of the + expanded abbreviation. +*) +(* + An abbreviation expansion will fail in either of these cases: + 1. The type constructor does not correspond to a manifest type. + 2. The type constructor is defined in an external file, and this + file is not in the path (missing -I options). + 3. The type constructor is not in the "local" environment. This can + happens when a non-generic type variable has been instantiated + afterwards to the not yet defined type constructor. (Actually, + this cannot happen at the moment due to the strong constraints + between type levels and constructor binding time.) + 4. The expansion requires the expansion of another abbreviation, + and this other expansion fails. +*) +let expand_abbrev_gen kind find_type_expansion env ty = + check_abbrev_env env; + match ty with + {desc = Tconstr (path, args, abbrev); level = level} -> + let lookup_abbrev = proper_abbrevs path args abbrev in + begin match find_expans kind path !lookup_abbrev with + Some ty' -> + (* prerr_endline + ("found a "^string_of_kind kind^" expansion for "^Path.name path);*) + if level <> generic_level then + begin try + update_level env level ty' + with Unify _ -> + (* XXX This should not happen. + However, levels are not correctly restored after a + typing error *) + () + end; + let ty' = repr ty' in + (* assert (ty != ty'); *) (* PR#7324 *) + ty' + | None -> + match find_type_expansion path env with + | exception Not_found -> + (* another way to expand is to normalize the path itself *) + let path' = Env.normalize_path None env path in + if Path.same path path' then raise Cannot_expand + else newty2 level (Tconstr (path', args, abbrev)) + | (params, body, lv) -> + (* prerr_endline + ("add a "^string_of_kind kind^" expansion for "^Path.name path);*) + let ty' = subst env level kind abbrev (Some ty) params args body in + (* For gadts, remember type as non exportable *) + (* The ambiguous level registered for ty' should be the highest *) + if !trace_gadt_instances then begin + match max lv (Env.gadt_instance_level env ty) with + None -> () + | Some lv -> + if level < lv then raise (Unify [(ty, newvar2 level)]); + Env.add_gadt_instances env lv [ty; ty'] + end; + ty' + end + | _ -> + assert false -let rec tree_of_path = function - | Pident id -> - Oide_ident (ident_name id) - | Pdot(_, s, _pos) as path when non_shadowed_pervasive path -> - Oide_ident s - | Pdot(p, s, _pos) -> - Oide_dot (tree_of_path p, s) - | Papply(p1, p2) -> - Oide_apply (tree_of_path p1, tree_of_path p2) +(* Expand respecting privacy *) +let expand_abbrev env ty = + expand_abbrev_gen Public Env.find_type_expansion env ty -let rec path ppf = function - | Pident id -> - ident ppf id - | Pdot(_, s, _pos) as path when non_shadowed_pervasive path -> - pp_print_string ppf s - | Pdot(p, s, _pos) -> - path ppf p; - pp_print_char ppf '.'; - pp_print_string ppf s - | Papply(p1, p2) -> - fprintf ppf "%a(%a)" path p1 path p2 +(* Expand once the head of a type *) +let expand_head_once env ty = + try expand_abbrev env (repr ty) with Cannot_expand -> assert false -let rec string_of_out_ident = function - | Oide_ident s -> s - | Oide_dot (id, s) -> String.concat "." [string_of_out_ident id; s] - | Oide_apply (id1, id2) -> - String.concat "" - [string_of_out_ident id1; "("; string_of_out_ident id2; ")"] +(* Check whether a type can be expanded *) +let safe_abbrev env ty = + let snap = Btype.snapshot () in + try ignore (expand_abbrev env ty); true + with Cannot_expand | Unify _ -> + Btype.backtrack snap; + false -let string_of_path p = string_of_out_ident (tree_of_path p) +(* Expand the head of a type once. + Raise Cannot_expand if the type cannot be expanded. + May raise Unify, if a recursion was hidden in the type. *) +let try_expand_once env ty = + let ty = repr ty in + match ty.desc with + Tconstr _ -> repr (expand_abbrev env ty) + | _ -> raise Cannot_expand -(* Print a recursive annotation *) +(* This one only raises Cannot_expand *) +let try_expand_safe env ty = + let snap = Btype.snapshot () in + try try_expand_once env ty + with Unify _ -> + Btype.backtrack snap; raise Cannot_expand -let tree_of_rec = function - | Trec_not -> Orec_not - | Trec_first -> Orec_first - | Trec_next -> Orec_next +(* Fully expand the head of a type. *) +let rec try_expand_head try_once env ty = + let ty' = try_once env ty in + try try_expand_head try_once env ty' + with Cannot_expand -> ty' -(* Print a raw type expression, with sharing *) +let try_expand_head try_once env ty = + let ty' = try_expand_head try_once env ty in + begin match Env.gadt_instance_level env ty' with + None -> () + | Some lv -> Env.add_gadt_instance_chain env lv ty + end; + ty' -let raw_list pr ppf = function - [] -> fprintf ppf "[]" - | a :: l -> - fprintf ppf "@[<1>[%a%t]@]" pr a - (fun ppf -> List.iter (fun x -> fprintf ppf ";@,%a" pr x) l) +(* Unsafe full expansion, may raise Unify. *) +let expand_head_unif env ty = + try try_expand_head try_expand_once env ty with Cannot_expand -> repr ty -let kind_vars = ref [] -let kind_count = ref 0 +(* Safe version of expand_head, never fails *) +let expand_head env ty = + try try_expand_head try_expand_safe env ty with Cannot_expand -> repr ty -let rec safe_kind_repr v = function - Fvar {contents=Some k} -> - if List.memq k v then "Fvar loop" else - safe_kind_repr (k::v) k - | Fvar r -> - let vid = - try List.assq r !kind_vars - with Not_found -> - let c = incr kind_count; !kind_count in - kind_vars := (r,c) :: !kind_vars; - c - in - Printf.sprintf "Fvar {None}@%d" vid - | Fpresent -> "Fpresent" - | Fabsent -> "Fabsent" +let _ = forward_try_expand_once := try_expand_safe -let rec safe_commu_repr v = function - Cok -> "Cok" - | Cunknown -> "Cunknown" - | Clink r -> - if List.memq r v then "Clink loop" else - safe_commu_repr (r::v) !r -let rec safe_repr v = function - {desc = Tlink t} when not (List.memq t v) -> - safe_repr (t::v) t - | t -> t +(* Expand until we find a non-abstract type declaration *) -let rec list_of_memo = function - Mnil -> [] - | Mcons (_priv, p, _t1, _t2, rem) -> p :: list_of_memo rem - | Mlink rem -> list_of_memo !rem +let rec extract_concrete_typedecl env ty = + let ty = repr ty in + match ty.desc with + Tconstr (p, _, _) -> + let decl = Env.find_type p env in + if decl.type_kind <> Type_abstract then (p, p, decl) else + let ty = + try try_expand_once env ty with Cannot_expand -> raise Not_found + in + let (_, p', decl) = extract_concrete_typedecl env ty in + (p, p', decl) + | _ -> raise Not_found -let print_name ppf = function - None -> fprintf ppf "None" - | Some name -> fprintf ppf "\"%s\"" name +(* Implementing function [expand_head_opt], the compiler's own version of + [expand_head] used for type-based optimisations. + [expand_head_opt] uses [Env.find_type_expansion_opt] to access the + manifest type information of private abstract data types which is + normally hidden to the type-checker out of the implementation module of + the private abbreviation. *) -let string_of_label = function - Nolabel -> "" - | Labelled s -> s - | Optional s -> "?"^s +let expand_abbrev_opt = + expand_abbrev_gen Private Env.find_type_expansion_opt -let visited = ref [] -let rec raw_type ppf ty = - let ty = safe_repr [] ty in - if List.memq ty !visited then fprintf ppf "{id=%d}" ty.id else begin - visited := ty :: !visited; - fprintf ppf "@[<1>{id=%d;level=%d;desc=@,%a}@]" ty.id ty.level - raw_type_desc ty.desc +let try_expand_once_opt env ty = + let ty = repr ty in + match ty.desc with + Tconstr _ -> repr (expand_abbrev_opt env ty) + | _ -> raise Cannot_expand + +let rec try_expand_head_opt env ty = + let ty' = try_expand_once_opt env ty in + begin try + try_expand_head_opt env ty' + with Cannot_expand -> + ty' end -and raw_type_list tl = raw_list raw_type tl -and raw_type_desc ppf = function - Tvar name -> fprintf ppf "Tvar %a" print_name name - | Tarrow(l,t1,t2,c) -> - fprintf ppf "@[Tarrow(\"%s\",@,%a,@,%a,@,%s)@]" - (string_of_label l) raw_type t1 raw_type t2 - (safe_commu_repr [] c) - | Ttuple tl -> - fprintf ppf "@[<1>Ttuple@,%a@]" raw_type_list tl - | Tconstr (p, tl, abbrev) -> - fprintf ppf "@[Tconstr(@,%a,@,%a,@,%a)@]" path p - raw_type_list tl - (raw_list path) (list_of_memo !abbrev) - | Tobject (t, nm) -> - fprintf ppf "@[Tobject(@,%a,@,@[<1>ref%t@])@]" raw_type t - (fun ppf -> - match !nm with None -> fprintf ppf " None" - | Some(p,tl) -> - fprintf ppf "(Some(@,%a,@,%a))" path p raw_type_list tl) - | Tfield (f, k, t1, t2) -> - fprintf ppf "@[Tfield(@,%s,@,%s,@,%a,@;<0 -1>%a)@]" f - (safe_kind_repr [] k) - raw_type t1 raw_type t2 - | Tnil -> fprintf ppf "Tnil" - | Tlink t -> fprintf ppf "@[<1>Tlink@,%a@]" raw_type t - | Tsubst t -> fprintf ppf "@[<1>Tsubst@,%a@]" raw_type t - | Tunivar name -> fprintf ppf "Tunivar %a" print_name name - | Tpoly (t, tl) -> - fprintf ppf "@[Tpoly(@,%a,@,%a)@]" - raw_type t - raw_type_list tl - | Tvariant row -> - fprintf ppf - "@[{@[%s@,%a;@]@ @[%s@,%a;@]@ %s%B;@ %s%B;@ @[<1>%s%t@]}@]" - "row_fields=" - (raw_list (fun ppf (l, f) -> - fprintf ppf "@[%s,@ %a@]" l raw_field f)) - row.row_fields - "row_more=" raw_type row.row_more - "row_closed=" row.row_closed - "row_fixed=" row.row_fixed - "row_name=" - (fun ppf -> - match row.row_name with None -> fprintf ppf "None" - | Some(p,tl) -> - fprintf ppf "Some(@,%a,@,%a)" path p raw_type_list tl) - | Tpackage (p, _, tl) -> - fprintf ppf "@[Tpackage(@,%a@,%a)@]" path p - raw_type_list tl -and raw_field ppf = function - Rpresent None -> fprintf ppf "Rpresent None" - | Rpresent (Some t) -> fprintf ppf "@[<1>Rpresent(Some@,%a)@]" raw_type t - | Reither (c,tl,m,e) -> - fprintf ppf "@[Reither(%B,@,%a,@,%B,@,@[<1>ref%t@])@]" c - raw_type_list tl m - (fun ppf -> - match !e with None -> fprintf ppf " None" - | Some f -> fprintf ppf "@,@[<1>(%a)@]" raw_field f) - | Rabsent -> fprintf ppf "Rabsent" +let expand_head_opt env ty = + let snap = Btype.snapshot () in + try try_expand_head_opt env ty + with Cannot_expand | Unify _ -> (* expand_head shall never fail *) + Btype.backtrack snap; + repr ty -let raw_type_expr ppf t = - visited := []; kind_vars := []; kind_count := 0; - raw_type ppf t; - visited := []; kind_vars := [] +(* Make sure that the type parameters of the type constructor [ty] + respect the type constraints *) +let enforce_constraints env ty = + match ty with + {desc = Tconstr (path, args, _abbrev); level = level} -> + begin try + let decl = Env.find_type path env in + ignore + (subst env level Public (ref Mnil) None decl.type_params args + (newvar2 level)) + with Not_found -> () + end + | _ -> + assert false -let () = Btype.print_raw := raw_type_expr +(* Recursively expand the head of a type. + Also expand #-types. *) +let full_expand env ty = + let ty = repr (expand_head env ty) in + match ty.desc with + Tobject (fi, {contents = Some (_, v::_)}) when is_Tvar (repr v) -> + newty2 ty.level (Tobject (fi, ref None)) + | _ -> + ty -(* Normalize paths *) +(* + Check whether the abbreviation expands to a well-defined type. + During the typing of a class, abbreviations for correspondings + types expand to non-generic types. +*) +let generic_abbrev env path = + try + let (_, body, _) = Env.find_type_expansion path env in + (repr body).level = generic_level + with + Not_found -> + false -type param_subst = Id | Nth of int | Map of int list +let generic_private_abbrev env path = + try + match Env.find_type path env with + {type_kind = Type_abstract; + type_private = Private; + type_manifest = Some body} -> + (repr body).level = generic_level + | _ -> false + with Not_found -> false -let is_nth = function - Nth _ -> true - | _ -> false +let is_contractive env p = + try + let decl = Env.find_type p env in + in_pervasives p && decl.type_manifest = None || is_datatype decl + with Not_found -> false -let compose l1 = function - | Id -> Map l1 - | Map l2 -> Map (List.map (List.nth l1) l2) - | Nth n -> Nth (List.nth l1 n) -let apply_subst s1 tyl = - if tyl = [] then [] - (* cf. PR#7543: Typemod.type_package doesn't respect type constructor arity *) - else - match s1 with - Nth n1 -> [List.nth tyl n1] - | Map l1 -> List.map (List.nth tyl) l1 - | Id -> tyl + (*****************) + (* Occur check *) + (*****************) -type best_path = Paths of Path.t list | Best of Path.t -let printing_depth = ref 0 -let printing_cont = ref ([] : Env.iter_cont list) -let printing_old = ref Env.empty -let printing_pers = ref Concr.empty -module PathMap = Map.Make(Path) -let printing_map = ref PathMap.empty +exception Occur -let same_type t t' = repr t == repr t' +let rec occur_rec env allow_recursive visited ty0 = function + | {desc=Tlink ty} -> + occur_rec env allow_recursive visited ty0 ty + | ty -> + if ty == ty0 then raise Occur; + match ty.desc with + Tconstr(p, _tl, _abbrev) -> + if allow_recursive && is_contractive env p then () else + begin try + if TypeSet.mem ty visited then raise Occur; + let visited = TypeSet.add ty visited in + iter_type_expr (occur_rec env allow_recursive visited ty0) ty + with Occur -> try + let ty' = try_expand_head try_expand_once env ty in + (* This call used to be inlined, but there seems no reason for it. + Message was referring to change in rev. 1.58 of the CVS repo. *) + occur_rec env allow_recursive visited ty0 ty' + with Cannot_expand -> + raise Occur + end + | Tobject _ | Tvariant _ -> + () + | _ -> + if allow_recursive || TypeSet.mem ty visited then () else begin + let visited = TypeSet.add ty visited in + iter_type_expr (occur_rec env allow_recursive visited ty0) ty + end -let rec index l x = - match l with - [] -> raise Not_found - | a :: l -> if x == a then 0 else 1 + index l x +let type_changed = ref false (* trace possible changes to the studied type *) -let rec uniq = function - [] -> true - | a :: l -> not (List.memq a l) && uniq l +let merge r b = if b then r := true -let rec normalize_type_path ?(cache=false) env p = +let occur env ty0 ty = + let allow_recursive = !Clflags.recursive_types || !umode = Pattern in + let old = !type_changed in try - let (params, ty, _) = Env.find_type_expansion p env in - let params = List.map repr params in - match repr ty with - {desc = Tconstr (p1, tyl, _)} -> - let tyl = List.map repr tyl in - if List.length params = List.length tyl - && List.for_all2 (==) params tyl - then normalize_type_path ~cache env p1 - else if cache || List.length params <= List.length tyl - || not (uniq tyl) then (p, Id) - else - let l1 = List.map (index params) tyl in - let (p2, s2) = normalize_type_path ~cache env p1 in - (p2, compose l1 s2) - | ty -> - (p, Nth (index params ty)) - with - Not_found -> - (Env.normalize_path None env p, Id) + while + type_changed := false; + occur_rec env allow_recursive TypeSet.empty ty0 ty; + !type_changed + do () (* prerr_endline "changed" *) done; + merge type_changed old + with exn -> + merge type_changed old; + raise (match exn with Occur -> Unify [] | _ -> exn) -let penalty s = - if s <> "" && s.[0] = '_' then - 10 - else - try - for i = 0 to String.length s - 2 do - if s.[i] = '_' && s.[i + 1] = '_' then - raise Exit - done; - 1 - with Exit -> 10 +let occur_in env ty0 t = + try occur env ty0 t; false with Unify _ -> true -let rec path_size = function - Pident id -> - penalty (Ident.name id), -Ident.binding_time id - | Pdot (p, _, _) -> - let (l, b) = path_size p in (1+l, b) - | Papply (p1, p2) -> - let (l, b) = path_size p1 in - (l + fst (path_size p2), b) +(* Check that a local constraint is well-founded *) +(* PR#6405: not needed since we allow recursion and work on normalized types *) +(* PR#6992: we actually need it for contractiveness *) +(* This is a simplified version of occur, only for the rectypes case *) -let same_printing_env env = - let used_pers = Env.used_persistent () in - Env.same_types !printing_old env && Concr.equal !printing_pers used_pers +let rec local_non_recursive_abbrev strict visited env p ty = + (*Format.eprintf "@[Check %s =@ %a@]@." (Path.name p) !Btype.print_raw ty;*) + let ty = repr ty in + if not (List.memq ty visited) then begin + match ty.desc with + Tconstr(p', args, _abbrev) -> + if Path.same p p' then raise Occur; + if not strict && is_contractive env p' then () else + let visited = ty :: visited in + begin try + (* try expanding, since [p] could be hidden *) + local_non_recursive_abbrev strict visited env p + (try_expand_head try_expand_once env ty) + with Cannot_expand -> + let params = + try (Env.find_type p' env).type_params + with Not_found -> args + in + List.iter2 + (fun tv ty -> + let strict = strict || not (is_Tvar (repr tv)) in + local_non_recursive_abbrev strict visited env p ty) + params args + end + | _ -> + if strict then (* PR#7374 *) + let visited = ty :: visited in + iter_type_expr (local_non_recursive_abbrev true visited env p) ty + end -let set_printing_env env = - printing_env := env; - if !Clflags.real_paths - || !printing_env == Env.empty || same_printing_env env then () else - begin - (* printf "Reset printing_map@."; *) - printing_old := env; - printing_pers := Env.used_persistent (); - printing_map := PathMap.empty; - printing_depth := 0; - (* printf "Recompute printing_map.@."; *) - let cont = - Env.iter_types - (fun p (p', _decl) -> - let (p1, s1) = normalize_type_path env p' ~cache:true in - (* Format.eprintf "%a -> %a = %a@." path p path p' path p1 *) - if s1 = Id then - try - let r = PathMap.find p1 !printing_map in - match !r with - Paths l -> r := Paths (p :: l) - | Best p' -> r := Paths [p; p'] (* assert false *) +let local_non_recursive_abbrev env p ty = + try (* PR#7397: need to check trace_gadt_instances *) + wrap_trace_gadt_instances env + (local_non_recursive_abbrev false [] env p) ty; + true + with Occur -> false + + + (*****************************) + (* Polymorphic Unification *) + (*****************************) + +(* Since we cannot duplicate universal variables, unification must + be done at meta-level, using bindings in univar_pairs *) +let rec unify_univar t1 t2 = function + (cl1, cl2) :: rem -> + let find_univ t cl = + try + let (_, r) = List.find (fun (t',_) -> t == repr t') cl in + Some r + with Not_found -> None + in + begin match find_univ t1 cl1, find_univ t2 cl2 with + Some {contents=Some t'2}, Some _ when t2 == repr t'2 -> + () + | Some({contents=None} as r1), Some({contents=None} as r2) -> + set_univar r1 t2; set_univar r2 t1 + | None, None -> + unify_univar t1 t2 rem + | _ -> + raise (Unify []) + end + | [] -> raise (Unify []) + +(* Test the occurrence of free univars in a type *) +(* that's way too expensive. Must do some kind of caching *) +let occur_univar env ty = + let visited = ref TypeMap.empty in + let rec occur_rec bound ty = + let ty = repr ty in + if ty.level >= lowest_level && + if TypeSet.is_empty bound then + (ty.level <- pivot_level - ty.level; true) + else try + let bound' = TypeMap.find ty !visited in + if TypeSet.exists (fun x -> not (TypeSet.mem x bound)) bound' then + (visited := TypeMap.add ty (TypeSet.inter bound bound') !visited; + true) + else false + with Not_found -> + visited := TypeMap.add ty bound !visited; + true + then + match ty.desc with + Tunivar _ -> + if not (TypeSet.mem ty bound) then raise (Unify [ty, newgenvar ()]) + | Tpoly (ty, tyl) -> + let bound = List.fold_right TypeSet.add (List.map repr tyl) bound in + occur_rec bound ty + | Tconstr (_, [], _) -> () + | Tconstr (p, tl, _) -> + begin try + let td = Env.find_type p env in + List.iter2 + (fun t v -> + if Variance.(mem May_pos v || mem May_neg v) + then occur_rec bound t) + tl td.type_variance with Not_found -> - printing_map := PathMap.add p1 (ref (Paths [p])) !printing_map) - env in - printing_cont := [cont]; - end + List.iter (occur_rec bound) tl + end + | _ -> iter_type_expr (occur_rec bound) ty + in + try + occur_rec TypeSet.empty ty; unmark_type ty + with exn -> + unmark_type ty; raise exn -let wrap_printing_env env f = - set_printing_env env; - try_finally f (fun () -> set_printing_env Env.empty) +(* Grouping univars by families according to their binders *) +let add_univars = + List.fold_left (fun s (t,_) -> TypeSet.add (repr t) s) -let wrap_printing_env env f = - Env.without_cmis (wrap_printing_env env) f +let get_univar_family univar_pairs univars = + if univars = [] then TypeSet.empty else + let insert s = function + cl1, (_::_ as cl2) -> + if List.exists (fun (t1,_) -> TypeSet.mem (repr t1) s) cl1 then + add_univars s cl2 + else s + | _ -> s + in + let s = List.fold_right TypeSet.add univars TypeSet.empty in + List.fold_left insert s univar_pairs -let is_unambiguous path env = - let l = Env.find_shadowed_types path env in - List.exists (Path.same path) l || (* concrete paths are ok *) - match l with - [] -> true - | p :: rem -> - (* allow also coherent paths: *) - let normalize p = fst (normalize_type_path ~cache:true env p) in - let p' = normalize p in - List.for_all (fun p -> Path.same (normalize p) p') rem || - (* also allow repeatedly defining and opening (for toplevel) *) - let id = lid_of_path p in - List.for_all (fun p -> lid_of_path p = id) rem && - Path.same p (Env.lookup_type id env) +(* Whether a family of univars escapes from a type *) +let univars_escape env univar_pairs vl ty = + let family = get_univar_family univar_pairs vl in + let visited = ref TypeSet.empty in + let rec occur t = + let t = repr t in + if TypeSet.mem t !visited then () else begin + visited := TypeSet.add t !visited; + match t.desc with + Tpoly (t, tl) -> + if List.exists (fun t -> TypeSet.mem (repr t) family) tl then () + else occur t + | Tunivar _ -> + if TypeSet.mem t family then raise Occur + | Tconstr (_, [], _) -> () + | Tconstr (p, tl, _) -> + begin try + let td = Env.find_type p env in + List.iter2 + (fun t v -> + if Variance.(mem May_pos v || mem May_neg v) then occur t) + tl td.type_variance + with Not_found -> + List.iter occur tl + end + | _ -> + iter_type_expr occur t + end + in + try occur ty; false with Occur -> true -let rec get_best_path r = - match !r with - Best p' -> p' - | Paths [] -> raise Not_found - | Paths l -> - r := Paths []; - List.iter - (fun p -> - (* Format.eprintf "evaluating %a@." path p; *) - match !r with - Best p' when path_size p >= path_size p' -> () - | _ -> if is_unambiguous p !printing_env then r := Best p) - (* else Format.eprintf "%a ignored as ambiguous@." path p *) - l; - get_best_path r +(* Wrapper checking that no variable escapes and updating univar_pairs *) +let enter_poly env univar_pairs t1 tl1 t2 tl2 f = + let old_univars = !univar_pairs in + let known_univars = + List.fold_left (fun s (cl,_) -> add_univars s cl) + TypeSet.empty old_univars + in + let tl1 = List.map repr tl1 and tl2 = List.map repr tl2 in + if List.exists (fun t -> TypeSet.mem t known_univars) tl1 && + univars_escape env old_univars tl1 (newty(Tpoly(t2,tl2))) + || List.exists (fun t -> TypeSet.mem t known_univars) tl2 && + univars_escape env old_univars tl2 (newty(Tpoly(t1,tl1))) + then raise (Unify []); + let cl1 = List.map (fun t -> t, ref None) tl1 + and cl2 = List.map (fun t -> t, ref None) tl2 in + univar_pairs := (cl1,cl2) :: (cl2,cl1) :: old_univars; + try let res = f t1 t2 in univar_pairs := old_univars; res + with exn -> univar_pairs := old_univars; raise exn -let best_type_path p = - if !Clflags.real_paths || !printing_env == Env.empty - then (p, Id) - else - let (p', s) = normalize_type_path !printing_env p in - let get_path () = get_best_path (PathMap.find p' !printing_map) in - while !printing_cont <> [] && - try fst (path_size (get_path ())) > !printing_depth with Not_found -> true - do - printing_cont := List.map snd (Env.run_iter_cont !printing_cont); - incr printing_depth; - done; - let p'' = try get_path () with Not_found -> p' in - (* Format.eprintf "%a = %a -> %a@." path p path p' path p''; *) - (p'', s) +let univar_pairs = ref [] -(* Print a type expression *) -let names = ref ([] : (type_expr * string) list) -let name_counter = ref 0 -let named_vars = ref ([] : string list) + (*****************) + (* Unification *) + (*****************) -let weak_counter = ref 1 -let weak_var_map = ref TypeMap.empty -let named_weak_vars = ref StringSet.empty -let reset_names () = names := []; name_counter := 0; named_vars := [] -let add_named_var ty = - match ty.desc with - Tvar (Some name) | Tunivar (Some name) -> - if List.mem name !named_vars then () else - named_vars := name :: !named_vars - | _ -> () -let name_is_already_used name = - List.mem name !named_vars - || List.exists (fun (_, name') -> name = name') !names - || StringSet.mem name !named_weak_vars +let rec has_cached_expansion p abbrev = + match abbrev with + Mnil -> false + | Mcons(_, p', _, _, rem) -> Path.same p p' || has_cached_expansion p rem + | Mlink rem -> has_cached_expansion p !rem -let rec new_name () = - let name = - if !name_counter < 26 - then String.make 1 (Char.chr(97 + !name_counter)) - else String.make 1 (Char.chr(97 + !name_counter mod 26)) ^ - string_of_int(!name_counter / 26) in - incr name_counter; - if name_is_already_used name then new_name () else name +(**** Transform error trace ****) +(* +++ Move it to some other place ? *) + +let expand_trace env trace = + List.fold_right + (fun (t1, t2) rem -> + (repr t1, full_expand env t1)::(repr t2, full_expand env t2)::rem) + trace [] + +(* build a dummy variant type *) +let mkvariant fields closed = + newgenty + (Tvariant + {row_fields = fields; row_closed = closed; row_more = newvar(); + row_bound = (); row_fixed = false; row_name = None }) + +(**** Unification ****) + +(* Return whether [t0] occurs in [ty]. Objects are also traversed. *) +let deep_occur t0 ty = + let rec occur_rec ty = + let ty = repr ty in + if ty.level >= lowest_level then begin + if ty == t0 then raise Occur; + ty.level <- pivot_level - ty.level; + iter_type_expr occur_rec ty + end + in + try + occur_rec ty; unmark_type ty; false + with Occur -> + unmark_type ty; true + +(* + 1. When unifying two non-abbreviated types, one type is made a link + to the other. When unifying an abbreviated type with a + non-abbreviated type, the non-abbreviated type is made a link to + the other one. When unifying to abbreviated types, these two + types are kept distincts, but they are made to (temporally) + expand to the same type. + 2. Abbreviations with at least one parameter are systematically + expanded. The overhead does not seem too high, and that way + abbreviations where some parameters does not appear in the + expansion, such as ['a t = int], are correctly handled. In + particular, for this example, unifying ['a t] with ['b t] keeps + ['a] and ['b] distincts. (Is it really important ?) + 3. Unifying an abbreviation ['a t = 'a] with ['a] should not yield + ['a t as 'a]. Indeed, the type variable would otherwise be lost. + This problem occurs for abbreviations expanding to a type + variable, but also to many other constrained abbreviations (for + instance, [(< x : 'a > -> unit) t = ]). The solution is + that, if an abbreviation is unified with some subpart of its + parameters, then the parameter actually does not get + abbreviated. It would be possible to check whether some + information is indeed lost, but it probably does not worth it. +*) -let rec new_weak_name ty () = - let name = "weak" ^ string_of_int !weak_counter in - incr weak_counter; - if name_is_already_used name then new_weak_name ty () - else begin - named_weak_vars := StringSet.add name !named_weak_vars; - weak_var_map := TypeMap.add ty name !weak_var_map; - name - end +let newtype_level = ref None -let name_of_type name_generator t = - (* We've already been through repr at this stage, so t is our representative - of the union-find class. *) - try List.assq t !names with Not_found -> - try TypeMap.find t !weak_var_map with Not_found -> - let name = - match t.desc with - Tvar (Some name) | Tunivar (Some name) -> - (* Some part of the type we've already printed has assigned another - * unification variable to that name. We want to keep the name, so try - * adding a number until we find a name that's not taken. *) - let current_name = ref name in - let i = ref 0 in - while List.exists (fun (_, name') -> !current_name = name') !names do - current_name := name ^ (string_of_int !i); - i := !i + 1; - done; - !current_name +let get_newtype_level () = + match !newtype_level with + | None -> assert false + | Some x -> x + +(* a local constraint can be added only if the rhs + of the constraint does not contain any Tvars. + They need to be removed using this function *) +let reify env t = + let newtype_level = get_newtype_level () in + let create_fresh_constr lev name = + let decl = new_declaration (Some (newtype_level, newtype_level)) None in + let name = match name with Some s -> "$'"^s | _ -> "$" in + let path = Path.Pident (Ident.create (get_new_abstract_name name)) in + let new_env = Env.add_local_type path decl !env in + let t = newty2 lev (Tconstr (path,[],ref Mnil)) in + env := new_env; + t + in + let visited = ref TypeSet.empty in + let rec iterator ty = + let ty = repr ty in + if TypeSet.mem ty !visited then () else begin + visited := TypeSet.add ty !visited; + match ty.desc with + Tvar o -> + let t = create_fresh_constr ty.level o in + link_type ty t; + if ty.level < newtype_level then + raise (Unify [t, newvar2 ty.level]) + | Tvariant r -> + let r = row_repr r in + if not (static_row r) then begin + if r.row_fixed then iterator (row_more r) else + let m = r.row_more in + match m.desc with + Tvar o -> + let t = create_fresh_constr m.level o in + let row = + {r with row_fields=[]; row_fixed=true; row_more = t} in + link_type m (newty2 m.level (Tvariant row)); + if m.level < newtype_level then + raise (Unify [t, newvar2 m.level]) + | _ -> assert false + end; + iter_row iterator r + | Tconstr (p, _, _) when is_object_type p -> + iter_type_expr iterator (full_expand !env ty) | _ -> - (* No name available, create a new one *) - name_generator () - in - (* Exception for type declarations *) - if name <> "_" then names := (t, name) :: !names; - name + iter_type_expr iterator ty + end + in + iterator t -let check_name_of_type t = ignore(name_of_type new_name t) +let is_newtype env p = + try + let decl = Env.find_type p env in + decl.type_newtype_level <> None && + decl.type_kind = Type_abstract && + decl.type_private = Public + with Not_found -> false -let remove_names tyl = - let tyl = List.map repr tyl in - names := List.filter (fun (ty,_) -> not (List.memq ty tyl)) !names +let non_aliasable p decl = + (* in_pervasives p || (subsumed by in_current_module) *) + in_current_module p && decl.type_newtype_level = None -let visited_objects = ref ([] : type_expr list) -let aliased = ref ([] : type_expr list) -let delayed = ref ([] : type_expr list) +let is_instantiable env p = + try + let decl = Env.find_type p env in + decl.type_kind = Type_abstract && + decl.type_private = Public && + decl.type_arity = 0 && + decl.type_manifest = None && + not (non_aliasable p decl) + with Not_found -> false -let add_delayed t = - if not (List.memq t !delayed) then delayed := t :: !delayed -let is_aliased ty = List.memq (proxy ty) !aliased -let add_alias ty = - let px = proxy ty in - if not (is_aliased px) then begin - aliased := px :: !aliased; - add_named_var px - end +(* PR#7113: -safe-string should be a global property *) +let compatible_paths p1 p2 = + let open Predef in + Path.same p1 p2 || + Path.same p1 path_bytes && Path.same p2 path_string || + Path.same p1 path_string && Path.same p2 path_bytes -let aliasable ty = +(* Check for datatypes carefully; see PR#6348 *) +let rec expands_to_datatype env ty = + let ty = repr ty in match ty.desc with - Tvar _ | Tunivar _ | Tpoly _ -> false - | Tconstr (p, _, _) -> - not (is_nth (snd (best_type_path p))) - | _ -> true + Tconstr (p, _, _) -> + begin try + is_datatype (Env.find_type p env) || + expands_to_datatype env (try_expand_once env ty) + with Not_found | Cannot_expand -> false + end + | _ -> false -let namable_row row = - row.row_name <> None && - List.for_all - (fun (_, f) -> - match row_field_repr f with - | Reither(c, l, _, _) -> - row.row_closed && if c then l = [] else List.length l = 1 - | _ -> true) - row.row_fields +(* mcomp type_pairs subst env t1 t2 does not raise an + exception if it is possible that t1 and t2 are actually + equal, assuming the types in type_pairs are equal and + that the mapping subst holds. + Assumes that both t1 and t2 do not contain any tvars + and that both their objects and variants are closed + *) -let rec mark_loops_rec visited ty = - let ty = repr ty in - let px = proxy ty in - if List.memq px visited && aliasable ty then add_alias px else - let visited = px :: visited in - match ty.desc with - | Tvar _ -> add_named_var ty - | Tarrow(_, ty1, ty2, _) -> - mark_loops_rec visited ty1; mark_loops_rec visited ty2 - | Ttuple tyl -> List.iter (mark_loops_rec visited) tyl - | Tconstr(p, tyl, _) -> - let (_p', s) = best_type_path p in - List.iter (mark_loops_rec visited) (apply_subst s tyl) - | Tpackage (_, _, tyl) -> - List.iter (mark_loops_rec visited) tyl - | Tvariant row -> - if List.memq px !visited_objects then add_alias px else - begin - let row = row_repr row in - if not (static_row row) then - visited_objects := px :: !visited_objects; - match row.row_name with - | Some(_p, tyl) when namable_row row -> - List.iter (mark_loops_rec visited) tyl - | _ -> - iter_row (mark_loops_rec visited) row - end - | Tobject (fi, nm) -> - if List.memq px !visited_objects then add_alias px else - begin - if opened_object ty then - visited_objects := px :: !visited_objects; - begin match !nm with - | None -> - let fields, _ = flatten_fields fi in - List.iter - (fun (_, kind, ty) -> - if field_kind_repr kind = Fpresent then - mark_loops_rec visited ty) - fields - | Some (_, l) -> - List.iter (mark_loops_rec visited) (List.tl l) - end - end - | Tfield(_, kind, ty1, ty2) when field_kind_repr kind = Fpresent -> - mark_loops_rec visited ty1; mark_loops_rec visited ty2 - | Tfield(_, _, _, ty2) -> - mark_loops_rec visited ty2 - | Tnil -> () - | Tsubst ty -> mark_loops_rec visited ty - | Tlink _ -> fatal_error "Printtyp.mark_loops_rec (2)" - | Tpoly (ty, tyl) -> - List.iter (fun t -> add_alias t) tyl; - mark_loops_rec visited ty - | Tunivar _ -> add_named_var ty +let rec mcomp type_pairs env t1 t2 = + if t1 == t2 then () else + let t1 = repr t1 in + let t2 = repr t2 in + if t1 == t2 then () else + match (t1.desc, t2.desc) with + | (Tvar _, _) + | (_, Tvar _) -> + () + | (Tconstr (p1, [], _), Tconstr (p2, [], _)) when Path.same p1 p2 -> + () + | _ -> + let t1' = expand_head_opt env t1 in + let t2' = expand_head_opt env t2 in + (* Expansion may have changed the representative of the types... *) + let t1' = repr t1' and t2' = repr t2' in + if t1' == t2' then () else + begin try TypePairs.find type_pairs (t1', t2') + with Not_found -> + TypePairs.add type_pairs (t1', t2') (); + match (t1'.desc, t2'.desc) with + (Tvar _, Tvar _) -> assert false + | (Tarrow (l1, t1, u1, _), Tarrow (l2, t2, u2, _)) + when l1 = l2 || not (is_optional l1 || is_optional l2) -> + mcomp type_pairs env t1 t2; + mcomp type_pairs env u1 u2; + | (Ttuple tl1, Ttuple tl2) -> + mcomp_list type_pairs env tl1 tl2 + | (Tconstr (p1, tl1, _), Tconstr (p2, tl2, _)) -> + mcomp_type_decl type_pairs env p1 p2 tl1 tl2 + | (Tconstr (p, _, _), _) | (_, Tconstr (p, _, _)) -> + begin try + let decl = Env.find_type p env in + if non_aliasable p decl || is_datatype decl then raise (Unify []) + with Not_found -> () + end + (* + | (Tpackage (p1, n1, tl1), Tpackage (p2, n2, tl2)) when n1 = n2 -> + mcomp_list type_pairs env tl1 tl2 + *) + | (Tpackage _, Tpackage _) -> () + | (Tvariant row1, Tvariant row2) -> + mcomp_row type_pairs env row1 row2 + | (Tobject (fi1, _), Tobject (fi2, _)) -> + mcomp_fields type_pairs env fi1 fi2 + | (Tfield _, Tfield _) -> (* Actually unused *) + mcomp_fields type_pairs env t1' t2' + | (Tnil, Tnil) -> + () + | (Tpoly (t1, []), Tpoly (t2, [])) -> + mcomp type_pairs env t1 t2 + | (Tpoly (t1, tl1), Tpoly (t2, tl2)) -> + enter_poly env univar_pairs t1 tl1 t2 tl2 + (mcomp type_pairs env) + | (Tunivar _, Tunivar _) -> + unify_univar t1' t2' !univar_pairs + | (_, _) -> + raise (Unify []) + end -let mark_loops ty = - normalize_type Env.empty ty; - mark_loops_rec [] ty;; +and mcomp_list type_pairs env tl1 tl2 = + if List.length tl1 <> List.length tl2 then + raise (Unify []); + List.iter2 (mcomp type_pairs env) tl1 tl2 -let reset_loop_marks () = - visited_objects := []; aliased := []; delayed := [] +and mcomp_fields type_pairs env ty1 ty2 = + if not (concrete_object ty1 && concrete_object ty2) then assert false; + let (fields2, rest2) = flatten_fields ty2 in + let (fields1, rest1) = flatten_fields ty1 in + let (pairs, miss1, miss2) = associate_fields fields1 fields2 in + let has_present = + List.exists (fun (_, k, _) -> field_kind_repr k = Fpresent) in + mcomp type_pairs env rest1 rest2; + if has_present miss1 && (object_row ty2).desc = Tnil + || has_present miss2 && (object_row ty1).desc = Tnil then raise (Unify []); + List.iter + (function (_n, k1, t1, k2, t2) -> + mcomp_kind k1 k2; + mcomp type_pairs env t1 t2) + pairs -let reset () = - unique_names := Ident.empty; reset_names (); reset_loop_marks () +and mcomp_kind k1 k2 = + let k1 = field_kind_repr k1 in + let k2 = field_kind_repr k2 in + match k1, k2 with + (Fpresent, Fabsent) + | (Fabsent, Fpresent) -> raise (Unify []) + | _ -> () -let reset_and_mark_loops ty = - reset (); mark_loops ty +and mcomp_row type_pairs env row1 row2 = + let row1 = row_repr row1 and row2 = row_repr row2 in + let r1, r2, pairs = merge_row_fields row1.row_fields row2.row_fields in + let cannot_erase (_,f) = + match row_field_repr f with + Rpresent _ -> true + | Rabsent | Reither _ -> false + in + if row1.row_closed && List.exists cannot_erase r2 + || row2.row_closed && List.exists cannot_erase r1 then raise (Unify []); + List.iter + (fun (_,f1,f2) -> + match row_field_repr f1, row_field_repr f2 with + | Rpresent None, (Rpresent (Some _) | Reither (_, _::_, _, _) | Rabsent) + | Rpresent (Some _), (Rpresent None | Reither (true, _, _, _) | Rabsent) + | (Reither (_, _::_, _, _) | Rabsent), Rpresent None + | (Reither (true, _, _, _) | Rabsent), Rpresent (Some _) -> + raise (Unify []) + | Rpresent(Some t1), Rpresent(Some t2) -> + mcomp type_pairs env t1 t2 + | Rpresent(Some t1), Reither(false, tl2, _, _) -> + List.iter (mcomp type_pairs env t1) tl2 + | Reither(false, tl1, _, _), Rpresent(Some t2) -> + List.iter (mcomp type_pairs env t2) tl1 + | _ -> ()) + pairs -let reset_and_mark_loops_list tyl = - reset (); List.iter mark_loops tyl +and mcomp_type_decl type_pairs env p1 p2 tl1 tl2 = + try + let decl = Env.find_type p1 env in + let decl' = Env.find_type p2 env in + if compatible_paths p1 p2 then begin + let inj = + try List.map Variance.(mem Inj) (Env.find_type p1 env).type_variance + with Not_found -> List.map (fun _ -> false) tl1 + in + List.iter2 + (fun i (t1,t2) -> if i then mcomp type_pairs env t1 t2) + inj (List.combine tl1 tl2) + end else if non_aliasable p1 decl && non_aliasable p2 decl' then + raise (Unify []) + else + match decl.type_kind, decl'.type_kind with + | Type_record (lst,r), Type_record (lst',r') when r = r' -> + mcomp_list type_pairs env tl1 tl2; + mcomp_record_description type_pairs env lst lst' + | Type_variant v1, Type_variant v2 -> + mcomp_list type_pairs env tl1 tl2; + mcomp_variant_description type_pairs env v1 v2 + | Type_open, Type_open -> + mcomp_list type_pairs env tl1 tl2 + | Type_abstract, Type_abstract -> () + | Type_abstract, _ when not (non_aliasable p1 decl)-> () + | _, Type_abstract when not (non_aliasable p2 decl') -> () + | _ -> raise (Unify []) + with Not_found -> () -(* Disabled in classic mode when printing an unification error *) -let print_labels = ref true +and mcomp_type_option type_pairs env t t' = + match t, t' with + None, None -> () + | Some t, Some t' -> mcomp type_pairs env t t' + | _ -> raise (Unify []) -let rec tree_of_typexp sch ty = - let ty = repr ty in - let px = proxy ty in - if List.mem_assq px !names && not (List.memq px !delayed) then - let mark = is_non_gen sch ty in - let name = name_of_type (if mark then new_weak_name ty else new_name) px in - Otyp_var (mark, name) else +and mcomp_variant_description type_pairs env xs ys = + let rec iter = fun x y -> + match x, y with + | c1 :: xs, c2 :: ys -> + mcomp_type_option type_pairs env c1.cd_res c2.cd_res; + begin match c1.cd_args, c2.cd_args with + | Cstr_tuple l1, Cstr_tuple l2 -> mcomp_list type_pairs env l1 l2 + | Cstr_record l1, Cstr_record l2 -> + mcomp_record_description type_pairs env l1 l2 + | _ -> raise (Unify []) + end; + if Ident.name c1.cd_id = Ident.name c2.cd_id + then iter xs ys + else raise (Unify []) + | [],[] -> () + | _ -> raise (Unify []) + in + iter xs ys - let pr_typ () = - match ty.desc with - | Tvar _ -> - (*let lev = - if is_non_gen sch ty then "/" ^ string_of_int ty.level else "" in*) - let non_gen = is_non_gen sch ty in - let name_gen = if non_gen then new_weak_name ty else new_name in - Otyp_var (non_gen, name_of_type name_gen ty) - | Tarrow(l, ty1, ty2, _) -> - let pr_arrow l ty1 ty2 = - let lab = - if !print_labels || is_optional l then string_of_label l else "" - in - let t1 = - if is_optional l then - match (repr ty1).desc with - | Tconstr(path, [ty], _) - when Path.same path Predef.path_option -> - tree_of_typexp sch ty - | _ -> Otyp_stuff "" - else tree_of_typexp sch ty1 in - Otyp_arrow (lab, t1, tree_of_typexp sch ty2) in - pr_arrow l ty1 ty2 - | Ttuple tyl -> - Otyp_tuple (tree_of_typlist sch tyl) - | Tconstr(p, tyl, _abbrev) -> - let p', s = best_type_path p in - let tyl' = apply_subst s tyl in - if is_nth s && not (tyl'=[]) then tree_of_typexp sch (List.hd tyl') else - Otyp_constr (tree_of_path p', tree_of_typlist sch tyl') - | Tvariant row -> - let row = row_repr row in - let fields = - if row.row_closed then - List.filter (fun (_, f) -> row_field_repr f <> Rabsent) - row.row_fields - else row.row_fields in - let present = - List.filter - (fun (_, f) -> - match row_field_repr f with - | Rpresent _ -> true - | _ -> false) - fields in - let all_present = List.length present = List.length fields in - begin match row.row_name with - | Some(p, tyl) when namable_row row -> - let (p', s) = best_type_path p in - let id = tree_of_path p' in - let args = tree_of_typlist sch (apply_subst s tyl) in - let out_variant = - if is_nth s then List.hd args else Otyp_constr (id, args) in - if row.row_closed && all_present then - out_variant - else - let non_gen = is_non_gen sch px in - let tags = - if all_present then None else Some (List.map fst present) in - Otyp_variant (non_gen, Ovar_typ out_variant, row.row_closed, tags) - | _ -> - let non_gen = - not (row.row_closed && all_present) && is_non_gen sch px in - let fields = List.map (tree_of_row_field sch) fields in - let tags = - if all_present then None else Some (List.map fst present) in - Otyp_variant (non_gen, Ovar_fields fields, row.row_closed, tags) - end - | Tobject (fi, nm) -> - tree_of_typobject sch fi !nm - | Tnil | Tfield _ -> - tree_of_typobject sch ty None - | Tsubst ty -> - tree_of_typexp sch ty - | Tlink _ -> - fatal_error "Printtyp.tree_of_typexp" - | Tpoly (ty, []) -> - tree_of_typexp sch ty - | Tpoly (ty, tyl) -> - (*let print_names () = - List.iter (fun (_, name) -> prerr_string (name ^ " ")) !names; - prerr_string "; " in *) - let tyl = List.map repr tyl in - if tyl = [] then tree_of_typexp sch ty else begin - let old_delayed = !delayed in - (* Make the names delayed, so that the real type is - printed once when used as proxy *) - List.iter add_delayed tyl; - let tl = List.map (name_of_type new_name) tyl in - let tr = Otyp_poly (tl, tree_of_typexp sch ty) in - (* Forget names when we leave scope *) - remove_names tyl; - delayed := old_delayed; tr - end - | Tunivar _ -> - Otyp_var (false, name_of_type new_name ty) - | Tpackage (p, n, tyl) -> - let n = - List.map (fun li -> String.concat "." (Longident.flatten li)) n in - Otyp_module (Path.name p, n, tree_of_typlist sch tyl) +and mcomp_record_description type_pairs env = + let rec iter x y = + match x, y with + | l1 :: xs, l2 :: ys -> + mcomp type_pairs env l1.ld_type l2.ld_type; + if Ident.name l1.ld_id = Ident.name l2.ld_id && + l1.ld_mutable = l2.ld_mutable + then iter xs ys + else raise (Unify []) + | [], [] -> () + | _ -> raise (Unify []) in - if List.memq px !delayed then delayed := List.filter ((!=) px) !delayed; - if is_aliased px && aliasable ty then begin - check_name_of_type px; - Otyp_alias (pr_typ (), name_of_type new_name px) end - else pr_typ () + iter -and tree_of_row_field sch (l, f) = - match row_field_repr f with - | Rpresent None | Reither(true, [], _, _) -> (l, false, []) - | Rpresent(Some ty) -> (l, false, [tree_of_typexp sch ty]) - | Reither(c, tyl, _, _) -> - if c (* contradiction: constant constructor with an argument *) - then (l, true, tree_of_typlist sch tyl) - else (l, false, tree_of_typlist sch tyl) - | Rabsent -> (l, false, [] (* actually, an error *)) +let mcomp env t1 t2 = + mcomp (TypePairs.create 4) env t1 t2 -and tree_of_typlist sch tyl = - List.map (tree_of_typexp sch) tyl +(* Real unification *) -and tree_of_typobject sch fi nm = - begin match nm with - | None -> - let pr_fields fi = - let (fields, rest) = flatten_fields fi in - let present_fields = - List.fold_right - (fun (n, k, t) l -> - match field_kind_repr k with - | Fpresent -> (n, t) :: l - | _ -> l) - fields [] in - let sorted_fields = - List.sort - (fun (n, _) (n', _) -> String.compare n n') present_fields in - tree_of_typfields sch rest sorted_fields in - let (fields, rest) = pr_fields fi in - Otyp_object (fields, rest) - | Some (p, ty :: tyl) -> - let non_gen = is_non_gen sch (repr ty) in - let args = tree_of_typlist sch tyl in - let (p', s) = best_type_path p in - assert (s = Id); - Otyp_class (non_gen, tree_of_path p', args) - | _ -> - fatal_error "Printtyp.tree_of_typobject" - end +let find_lowest_level ty = + let lowest = ref generic_level in + let rec find ty = + let ty = repr ty in + if ty.level >= lowest_level then begin + if ty.level < !lowest then lowest := ty.level; + ty.level <- pivot_level - ty.level; + iter_type_expr find ty + end + in find ty; unmark_type ty; !lowest -and is_non_gen sch ty = - sch && is_Tvar ty && ty.level <> generic_level +let find_newtype_level env path = + try match (Env.find_type path env).type_newtype_level with + Some x -> x + | None -> raise Not_found + with Not_found -> let lev = Path.binding_time path in (lev, lev) -and tree_of_typfields sch rest = function - | [] -> - let rest = - match rest.desc with - | Tvar _ | Tunivar _ -> Some (is_non_gen sch rest) - | Tconstr _ -> Some false - | Tnil -> None - | _ -> fatal_error "typfields (1)" - in - ([], rest) - | (s, t) :: l -> - let field = (s, tree_of_typexp sch t) in - let (fields, rest) = tree_of_typfields sch rest l in - (field :: fields, rest) +let add_gadt_equation env source destination = + if local_non_recursive_abbrev !env source destination then begin + let destination = duplicate_type destination in + let source_lev = find_newtype_level !env source in + let decl = new_declaration (Some source_lev) (Some destination) in + let newtype_level = get_newtype_level () in + env := Env.add_local_constraint source decl newtype_level !env; + cleanup_abbrev () + end -let typexp sch ppf ty = - !Oprint.out_type ppf (tree_of_typexp sch ty) +let unify_eq_set = TypePairs.create 11 -let type_expr ppf ty = typexp false ppf ty +let order_type_pair t1 t2 = + if t1.id <= t2.id then (t1, t2) else (t2, t1) -and type_sch ppf ty = typexp true ppf ty +let add_type_equality t1 t2 = + TypePairs.add unify_eq_set (order_type_pair t1 t2) () -and type_scheme ppf ty = reset_and_mark_loops ty; typexp true ppf ty +let eq_package_path env p1 p2 = + Path.same p1 p2 || + Path.same (normalize_package_path env p1) (normalize_package_path env p2) -(* Maxence *) -let type_scheme_max ?(b_reset_names=true) ppf ty = - if b_reset_names then reset_names () ; - typexp true ppf ty -(* End Maxence *) +let nondep_type' = ref (fun _ _ _ -> assert false) +let package_subtype = ref (fun _ _ _ _ _ _ _ -> assert false) -let tree_of_type_scheme ty = reset_and_mark_loops ty; tree_of_typexp true ty +let rec concat_longident lid1 = + let open Longident in + function + Lident s -> Ldot (lid1, s) + | Ldot (lid2, s) -> Ldot (concat_longident lid1 lid2, s) + | Lapply (lid2, lid) -> Lapply (concat_longident lid1 lid2, lid) -(* Print one type declaration *) +let nondep_instance env level id ty = + let ty = !nondep_type' env id ty in + if level = generic_level then duplicate_type ty else + let old = !current_level in + current_level := level; + let ty = instance env ty in + current_level := old; + ty -let tree_of_constraints params = - List.fold_right - (fun ty list -> - let ty' = unalias ty in - if proxy ty != proxy ty' then - let tr = tree_of_typexp true ty in - (tr, tree_of_typexp true ty') :: list - else list) - params [] +(* Find the type paths nl1 in the module type mty2, and add them to the + list (nl2, tl2). raise Not_found if impossible *) +let complete_type_list ?(allow_absent=false) env nl1 lv2 mty2 nl2 tl2 = + let id2 = Ident.create "Pkg" in + let env' = Env.add_module id2 mty2 env in + let rec complete nl1 ntl2 = + match nl1, ntl2 with + [], _ -> ntl2 + | n :: nl, (n2, _ as nt2) :: ntl' when n >= n2 -> + nt2 :: complete (if n = n2 then nl else nl1) ntl' + | n :: nl, _ -> + try + let path = + Env.lookup_type (concat_longident (Longident.Lident "Pkg") n) env' + in + match Env.find_type path env' with + {type_arity = 0; type_kind = Type_abstract; + type_private = Public; type_manifest = Some t2} -> + (n, nondep_instance env' lv2 id2 t2) :: complete nl ntl2 + | {type_arity = 0; type_kind = Type_abstract; + type_private = Public; type_manifest = None} when allow_absent -> + complete nl ntl2 + | _ -> raise Exit + with + | Not_found when allow_absent -> complete nl ntl2 + | Exit -> raise Not_found + in + complete nl1 (List.combine nl2 tl2) -let filter_params tyl = - let params = - List.fold_left - (fun tyl ty -> - let ty = repr ty in - if List.memq ty tyl then Btype.newgenty (Tsubst ty) :: tyl - else ty :: tyl) - [] tyl - in List.rev params +(* raise Not_found rather than Unify if the module types are incompatible *) +let unify_package env unify_list lv1 p1 n1 tl1 lv2 p2 n2 tl2 = + let ntl2 = complete_type_list env n1 lv2 (Mty_ident p2) n2 tl2 + and ntl1 = complete_type_list env n2 lv1 (Mty_ident p1) n1 tl1 in + unify_list (List.map snd ntl1) (List.map snd ntl2); + if eq_package_path env p1 p2 + || !package_subtype env p1 n1 tl1 p2 n2 tl2 + && !package_subtype env p2 n2 tl2 p1 n1 tl1 then () else raise Not_found -let mark_loops_constructor_arguments = function - | Cstr_tuple l -> List.iter mark_loops l - | Cstr_record l -> List.iter (fun l -> mark_loops l.ld_type) l -let rec tree_of_type_decl id decl = +(* force unification in Reither when one side has a non-conjunctive type *) +let rigid_variants = ref false - reset(); +(* drop not force unification in Reither, even in fixed case + (not sound, only use it when checking exhaustiveness) *) +let passive_variants = ref false +let with_passive_variants f x = + if !passive_variants then f x else + match passive_variants := true; f x with + | r -> passive_variants := false; r + | exception e -> passive_variants := false; raise e - let params = filter_params decl.type_params in +let unify_eq t1 t2 = + t1 == t2 || + match !umode with + | Expression -> false + | Pattern -> + try TypePairs.find unify_eq_set (order_type_pair t1 t2); true + with Not_found -> false - begin match decl.type_manifest with - | Some ty -> - let vars = free_variables ty in - List.iter - (function {desc = Tvar (Some "_")} as ty -> - if List.memq ty vars then ty.desc <- Tvar None - | _ -> ()) - params - | None -> () - end; +let unify1_var env t1 t2 = + assert (is_Tvar t1); + occur env t1 t2; + occur_univar env t2; + let d1 = t1.desc in + link_type t1 t2; + try + update_level env t1.level t2 + with Unify _ as e -> + t1.desc <- d1; + raise e - List.iter add_alias params; - List.iter mark_loops params; - List.iter check_name_of_type (List.map proxy params); - let ty_manifest = - match decl.type_manifest with - | None -> None - | Some ty -> - let ty = - (* Special hack to hide variant name *) - match repr ty with {desc=Tvariant row} -> - let row = row_repr row in - begin match row.row_name with - Some (Pident id', _) when Ident.same id id' -> - newgenty (Tvariant {row with row_name = None}) - | _ -> ty - end - | _ -> ty - in - mark_loops ty; - Some ty - in - begin match decl.type_kind with - | Type_abstract -> () - | Type_variant cstrs -> - List.iter - (fun c -> - mark_loops_constructor_arguments c.cd_args; - may mark_loops c.cd_res) - cstrs - | Type_record(l, _rep) -> - List.iter (fun l -> mark_loops l.ld_type) l - | Type_open -> () - end; +let rec unify (env:Env.t ref) t1 t2 = + (* First step: special cases (optimizations) *) + if t1 == t2 then () else + let t1 = repr t1 in + let t2 = repr t2 in + if unify_eq t1 t2 then () else + let reset_tracing = check_trace_gadt_instances !env in - let type_param = - function - | Otyp_var (_, id) -> id - | _ -> "?" - in - let type_defined decl = - let abstr = - match decl.type_kind with - Type_abstract -> - decl.type_manifest = None || decl.type_private = Private - | Type_record _ -> - decl.type_private = Private - | Type_variant tll -> - decl.type_private = Private || - List.exists (fun cd -> cd.cd_res <> None) tll - | Type_open -> - decl.type_manifest = None - in - let vari = - List.map2 - (fun ty v -> - if abstr || not (is_Tvar (repr ty)) then Variance.get_upper v - else (true,true)) - decl.type_params decl.type_variance - in - (Ident.name id, - List.map2 (fun ty cocn -> type_param (tree_of_typexp false ty), cocn) - params vari) - in - let tree_of_manifest ty1 = - match ty_manifest with - | None -> ty1 - | Some ty -> Otyp_manifest (tree_of_typexp false ty, ty1) - in - let (name, args) = type_defined decl in - let constraints = tree_of_constraints params in - let ty, priv = - match decl.type_kind with - | Type_abstract -> - begin match ty_manifest with - | None -> (Otyp_abstract, Public) - | Some ty -> - tree_of_typexp false ty, decl.type_private + try + type_changed := true; + begin match (t1.desc, t2.desc) with + (Tvar _, Tconstr _) when deep_occur t1 t2 -> + unify2 env t1 t2 + | (Tconstr _, Tvar _) when deep_occur t2 t1 -> + unify2 env t1 t2 + | (Tvar _, _) -> + unify1_var !env t1 t2 + | (_, Tvar _) -> + unify1_var !env t2 t1 + | (Tunivar _, Tunivar _) -> + unify_univar t1 t2 !univar_pairs; + update_level !env t1.level t2; + link_type t1 t2 + | (Tconstr (p1, [], a1), Tconstr (p2, [], a2)) + when Path.same p1 p2 (* && actual_mode !env = Old *) + (* This optimization assumes that t1 does not expand to t2 + (and conversely), so we fall back to the general case + when any of the types has a cached expansion. *) + && not (has_cached_expansion p1 !a1 + || has_cached_expansion p2 !a2) -> + update_level !env t1.level t2; + link_type t1 t2 + | (Tconstr (p1, [], _), Tconstr (p2, [], _)) + when Env.has_local_constraints !env + && is_newtype !env p1 && is_newtype !env p2 -> + (* Do not use local constraints more than necessary *) + begin try + if find_newtype_level !env p1 < find_newtype_level !env p2 then + unify env t1 (try_expand_once !env t2) + else + unify env (try_expand_once !env t1) t2 + with Cannot_expand -> + unify2 env t1 t2 end - | Type_variant cstrs -> - tree_of_manifest (Otyp_sum (List.map tree_of_constructor cstrs)), - decl.type_private - | Type_record(lbls, _rep) -> - tree_of_manifest (Otyp_record (List.map tree_of_label lbls)), - decl.type_private - | Type_open -> - tree_of_manifest Otyp_open, - decl.type_private - in - let immediate = - Builtin_attributes.immediate decl.type_attributes - in - { otype_name = name; - otype_params = args; - otype_type = ty; - otype_private = priv; - otype_immediate = immediate; - otype_unboxed = decl.type_unboxed.unboxed; - otype_cstrs = constraints } - -and tree_of_constructor_arguments = function - | Cstr_tuple l -> tree_of_typlist false l - | Cstr_record l -> [ Otyp_record (List.map tree_of_label l) ] - -and tree_of_constructor cd = - let name = Ident.name cd.cd_id in - let arg () = tree_of_constructor_arguments cd.cd_args in - match cd.cd_res with - | None -> (name, arg (), None) - | Some res -> - let nm = !names in - names := []; - let ret = tree_of_typexp false res in - let args = arg () in - names := nm; - (name, args, Some ret) + | _ -> + unify2 env t1 t2 + end; + reset_trace_gadt_instances reset_tracing; + with Unify trace -> + reset_trace_gadt_instances reset_tracing; + raise (Unify ((t1, t2)::trace)) -and tree_of_label l = - (Ident.name l.ld_id, l.ld_mutable = Mutable, tree_of_typexp false l.ld_type) +and unify2 env t1 t2 = + (* Second step: expansion of abbreviations *) + (* Expansion may change the representative of the types. *) + ignore (expand_head_unif !env t1); + ignore (expand_head_unif !env t2); + let t1' = expand_head_unif !env t1 in + let t2' = expand_head_unif !env t2 in + let lv = min t1'.level t2'.level in + update_level !env lv t2; + update_level !env lv t1; + if unify_eq t1' t2' then () else -let tree_of_type_declaration id decl rs = - Osig_type (tree_of_type_decl id decl, tree_of_rec rs) + let t1 = repr t1 and t2 = repr t2 in + if !trace_gadt_instances then begin + (* All types in chains already have the same ambiguity levels *) + let ilevel t = + match Env.gadt_instance_level !env t with None -> 0 | Some lv -> lv in + let lv1 = ilevel t1 and lv2 = ilevel t2 in + if lv1 > lv2 then Env.add_gadt_instance_chain !env lv1 t2 else + if lv2 > lv1 then Env.add_gadt_instance_chain !env lv2 t1 + end; + let t1, t2 = + if !Clflags.principal + && (find_lowest_level t1' < lv || find_lowest_level t2' < lv) then + (* Expand abbreviations hiding a lower level *) + (* Should also do it for parameterized types, after unification... *) + (match t1.desc with Tconstr (_, [], _) -> t1' | _ -> t1), + (match t2.desc with Tconstr (_, [], _) -> t2' | _ -> t2) + else (t1, t2) + in + if unify_eq t1 t1' || not (unify_eq t2 t2') then + unify3 env t1 t1' t2 t2' + else + try unify3 env t2 t2' t1 t1' with Unify trace -> + raise (Unify (List.map (fun (x, y) -> (y, x)) trace)) -let type_declaration id ppf decl = - !Oprint.out_sig_item ppf (tree_of_type_declaration id decl Trec_first) +and unify3 env t1 t1' t2 t2' = + (* Third step: truly unification *) + (* Assumes either [t1 == t1'] or [t2 != t2'] *) + let d1 = t1'.desc and d2 = t2'.desc in + let create_recursion = (t2 != t2') && (deep_occur t1' t2) in -let constructor_arguments ppf a = - let tys = tree_of_constructor_arguments a in - !Oprint.out_type ppf (Otyp_tuple tys) + begin match (d1, d2) with (* handle vars and univars specially *) + (Tunivar _, Tunivar _) -> + unify_univar t1' t2' !univar_pairs; + link_type t1' t2' + | (Tvar _, _) -> + occur !env t1' t2; + occur_univar !env t2; + link_type t1' t2; + | (_, Tvar _) -> + occur !env t2' t1; + occur_univar !env t1; + link_type t2' t1; + | (Tfield _, Tfield _) -> (* special case for GADTs *) + unify_fields env t1' t2' + | _ -> + begin match !umode with + | Expression -> + occur !env t1' t2'; + link_type t1' t2 + | Pattern -> + add_type_equality t1' t2' + end; + try + begin match (d1, d2) with + (Tarrow (l1, t1, u1, c1), Tarrow (l2, t2, u2, c2)) when l1 = l2 || + (!Clflags.classic || !umode = Pattern) && + not (is_optional l1 || is_optional l2) -> + unify env t1 t2; unify env u1 u2; + begin match commu_repr c1, commu_repr c2 with + Clink r, c2 -> set_commu r c2 + | c1, Clink r -> set_commu r c1 + | _ -> () + end + | (Ttuple tl1, Ttuple tl2) -> + unify_list env tl1 tl2 + | (Tconstr (p1, tl1, _), Tconstr (p2, tl2, _)) when Path.same p1 p2 -> + if !umode = Expression || not !generate_equations then + unify_list env tl1 tl2 + else if !assume_injective then + set_mode_pattern ~generate:true ~injective:false + (fun () -> unify_list env tl1 tl2) + else if in_current_module p1 (* || in_pervasives p1 *) + || List.exists (expands_to_datatype !env) [t1'; t1; t2] then + unify_list env tl1 tl2 + else + let inj = + try List.map Variance.(mem Inj) + (Env.find_type p1 !env).type_variance + with Not_found -> List.map (fun _ -> false) tl1 + in + List.iter2 + (fun i (t1, t2) -> + if i then unify env t1 t2 else + set_mode_pattern ~generate:false ~injective:false + begin fun () -> + let snap = snapshot () in + try unify env t1 t2 with Unify _ -> + backtrack snap; + reify env t1; reify env t2 + end) + inj (List.combine tl1 tl2) + | (Tconstr (path,[],_), + Tconstr (path',[],_)) + when is_instantiable !env path && is_instantiable !env path' + && !generate_equations -> + let source, destination = + if find_newtype_level !env path > find_newtype_level !env path' + then path , t2' + else path', t1' + in + add_gadt_equation env source destination + | (Tconstr (path,[],_), _) + when is_instantiable !env path && !generate_equations -> + reify env t2'; + add_gadt_equation env path t2' + | (_, Tconstr (path,[],_)) + when is_instantiable !env path && !generate_equations -> + reify env t1'; + add_gadt_equation env path t1' + | (Tconstr (_,_,_), _) | (_, Tconstr (_,_,_)) when !umode = Pattern -> + reify env t1'; + reify env t2'; + if !generate_equations then mcomp !env t1' t2' + | (Tobject (fi1, nm1), Tobject (fi2, _)) -> + unify_fields env fi1 fi2; + (* Type [t2'] may have been instantiated by [unify_fields] *) + (* XXX One should do some kind of unification... *) + begin match (repr t2').desc with + Tobject (_, {contents = Some (_, va::_)}) when + (match (repr va).desc with + Tvar _|Tunivar _|Tnil -> true | _ -> false) -> () + | Tobject (_, nm2) -> set_name nm2 !nm1 + | _ -> () + end + | (Tvariant row1, Tvariant row2) -> + if !umode = Expression then + unify_row env row1 row2 + else begin + let snap = snapshot () in + try unify_row env row1 row2 + with Unify _ -> + backtrack snap; + reify env t1'; + reify env t2'; + if !generate_equations then mcomp !env t1' t2' + end + | (Tfield(f,kind,_,rem), Tnil) | (Tnil, Tfield(f,kind,_,rem)) -> + begin match field_kind_repr kind with + Fvar r when f <> dummy_method -> + set_kind r Fabsent; + if d2 = Tnil then unify env rem t2' + else unify env (newty2 rem.level Tnil) rem + | _ -> raise (Unify []) + end + | (Tnil, Tnil) -> + () + | (Tpoly (t1, []), Tpoly (t2, [])) -> + unify env t1 t2 + | (Tpoly (t1, tl1), Tpoly (t2, tl2)) -> + enter_poly !env univar_pairs t1 tl1 t2 tl2 (unify env) + | (Tpackage (p1, n1, tl1), Tpackage (p2, n2, tl2)) -> + begin try + unify_package !env (unify_list env) + t1.level p1 n1 tl1 t2.level p2 n2 tl2 + with Not_found -> + if !umode = Expression then raise (Unify []); + List.iter (reify env) (tl1 @ tl2); + (* if !generate_equations then List.iter2 (mcomp !env) tl1 tl2 *) + end + | (_, _) -> + raise (Unify []) + end; + (* XXX Commentaires + changer "create_recursion" + ||| Comments + change "create_recursion" *) + if create_recursion then + match t2.desc with + Tconstr (p, tl, abbrev) -> + forget_abbrev abbrev p; + let t2'' = expand_head_unif !env t2 in + if not (closed_parameterized_type tl t2'') then + link_type (repr t2) (repr t2') + | _ -> + () (* t2 has already been expanded by update_level *) + with Unify trace -> + t1'.desc <- d1; + raise (Unify trace) + end -(* Print an extension declaration *) +and unify_list env tl1 tl2 = + if List.length tl1 <> List.length tl2 then + raise (Unify []); + List.iter2 (unify env) tl1 tl2 -let tree_of_extension_constructor id ext es = - reset (); - let ty_name = Path.name ext.ext_type_path in - let ty_params = filter_params ext.ext_type_params in - List.iter add_alias ty_params; - List.iter mark_loops ty_params; - List.iter check_name_of_type (List.map proxy ty_params); - mark_loops_constructor_arguments ext.ext_args; - may mark_loops ext.ext_ret_type; - let type_param = - function - | Otyp_var (_, id) -> id - | _ -> "?" - in - let ty_params = - List.map (fun ty -> type_param (tree_of_typexp false ty)) ty_params - in - let name = Ident.name id in - let args, ret = - match ext.ext_ret_type with - | None -> (tree_of_constructor_arguments ext.ext_args, None) - | Some res -> - let nm = !names in - names := []; - let ret = tree_of_typexp false res in - let args = tree_of_constructor_arguments ext.ext_args in - names := nm; - (args, Some ret) - in - let ext = - { oext_name = name; - oext_type_name = ty_name; - oext_type_params = ty_params; - oext_args = args; - oext_ret_type = ret; - oext_private = ext.ext_private } +(* Build a fresh row variable for unification *) +and make_rowvar level use1 rest1 use2 rest2 = + let set_name ty name = + match ty.desc with + Tvar None -> log_type ty; ty.desc <- Tvar name + | _ -> () in - let es = - match es with - Text_first -> Oext_first - | Text_next -> Oext_next - | Text_exception -> Oext_exception + let name = + match rest1.desc, rest2.desc with + Tvar (Some _ as name1), Tvar (Some _ as name2) -> + if rest1.level <= rest2.level then name1 else name2 + | Tvar (Some _ as name), _ -> + if use2 then set_name rest2 name; name + | _, Tvar (Some _ as name) -> + if use1 then set_name rest2 name; name + | _ -> None in - Osig_typext (ext, es) + if use1 then rest1 else + if use2 then rest2 else newvar2 ?name level -let extension_constructor id ppf ext = - !Oprint.out_sig_item ppf (tree_of_extension_constructor id ext Text_first) +and unify_fields env ty1 ty2 = (* Optimization *) + let (fields1, rest1) = flatten_fields ty1 + and (fields2, rest2) = flatten_fields ty2 in + let (pairs, miss1, miss2) = associate_fields fields1 fields2 in + let l1 = (repr ty1).level and l2 = (repr ty2).level in + let va = make_rowvar (min l1 l2) (miss2=[]) rest1 (miss1=[]) rest2 in + let d1 = rest1.desc and d2 = rest2.desc in + try + unify env (build_fields l1 miss1 va) rest2; + unify env rest1 (build_fields l2 miss2 va); + List.iter + (fun (n, k1, t1, k2, t2) -> + unify_kind k1 k2; + try + if !trace_gadt_instances then update_level !env va.level t1; + unify env t1 t2 + with Unify trace -> + raise (Unify ((newty (Tfield(n, k1, t1, newty Tnil)), + newty (Tfield(n, k2, t2, newty Tnil)))::trace))) + pairs + with exn -> + log_type rest1; rest1.desc <- d1; + log_type rest2; rest2.desc <- d2; + raise exn -(* Print a value declaration *) +and unify_kind k1 k2 = + let k1 = field_kind_repr k1 in + let k2 = field_kind_repr k2 in + if k1 == k2 then () else + match k1, k2 with + (Fvar r, (Fvar _ | Fpresent)) -> set_kind r k2 + | (Fpresent, Fvar r) -> set_kind r k1 + | (Fpresent, Fpresent) -> () + | _ -> assert false -let tree_of_value_description id decl = - (* Format.eprintf "@[%a@]@." raw_type_expr decl.val_type; *) - let id = Ident.name id in - let ty = tree_of_type_scheme decl.val_type in - let vd = - { oval_name = id; - oval_type = ty; - oval_prims = []; - oval_attributes = [] } +and unify_row env row1 row2 = + let row1 = row_repr row1 and row2 = row_repr row2 in + let rm1 = row_more row1 and rm2 = row_more row2 in + if unify_eq rm1 rm2 then () else + let r1, r2, pairs = merge_row_fields row1.row_fields row2.row_fields in + if r1 <> [] && r2 <> [] then begin + let ht = Hashtbl.create (List.length r1) in + List.iter (fun (l,_) -> Hashtbl.add ht (hash_variant l) l) r1; + List.iter + (fun (l,_) -> + try raise (Tags(l, Hashtbl.find ht (hash_variant l))) + with Not_found -> ()) + r2 + end; + let fixed1 = row_fixed row1 and fixed2 = row_fixed row2 in + let more = + if fixed1 then rm1 else + if fixed2 then rm2 else + newty2 (min rm1.level rm2.level) (Tvar None) in + let fixed = fixed1 || fixed2 + and closed = row1.row_closed || row2.row_closed in + let keep switch = + List.for_all + (fun (_,f1,f2) -> + let f1, f2 = switch f1 f2 in + row_field_repr f1 = Rabsent || row_field_repr f2 <> Rabsent) + pairs in - let vd = - match decl.val_kind with - | Val_prim p -> Primitive.print p vd - | _ -> vd + let empty fields = + List.for_all (fun (_,f) -> row_field_repr f = Rabsent) fields in + (* Check whether we are going to build an empty type *) + if closed && (empty r1 || row2.row_closed) && (empty r2 || row1.row_closed) + && List.for_all + (fun (_,f1,f2) -> + row_field_repr f1 = Rabsent || row_field_repr f2 = Rabsent) + pairs + then raise (Unify [mkvariant [] true, mkvariant [] true]); + let name = + if row1.row_name <> None && (row1.row_closed || empty r2) && + (not row2.row_closed || keep (fun f1 f2 -> f1, f2) && empty r1) + then row1.row_name + else if row2.row_name <> None && (row2.row_closed || empty r1) && + (not row1.row_closed || keep (fun f1 f2 -> f2, f1) && empty r2) + then row2.row_name + else None in - Osig_value vd - -let value_description id ppf decl = - !Oprint.out_sig_item ppf (tree_of_value_description id decl) - -(* Print a class type *) - -let method_type (_, kind, ty) = - match field_kind_repr kind, repr ty with - Fpresent, {desc=Tpoly(ty, tyl)} -> (ty, tyl) - | _ , ty -> (ty, []) - -let tree_of_metho sch concrete csil (lab, kind, ty) = - if lab <> dummy_method then begin - let kind = field_kind_repr kind in - let priv = kind <> Fpresent in - let virt = not (Concr.mem lab concrete) in - let (ty, tyl) = method_type (lab, kind, ty) in - let tty = tree_of_typexp sch ty in - remove_names tyl; - Ocsg_method (lab, priv, virt, tty) :: csil + let row0 = {row_fields = []; row_more = more; row_bound = (); + row_closed = closed; row_fixed = fixed; row_name = name} in + let set_more row rest = + let rest = + if closed then + filter_row_fields row.row_closed rest + else rest in + if rest <> [] && (row.row_closed || row_fixed row) + || closed && row_fixed row && not row.row_closed then begin + let t1 = mkvariant [] true and t2 = mkvariant rest false in + raise (Unify [if row == row1 then (t1,t2) else (t2,t1)]) + end; + (* The following test is not principal... should rather use Tnil *) + let rm = row_more row in + (*if !trace_gadt_instances && rm.desc = Tnil then () else*) + if !trace_gadt_instances then + update_level !env rm.level (newgenty (Tvariant row)); + if row_fixed row then + if more == rm then () else + if is_Tvar rm then link_type rm more else unify env rm more + else + let ty = newgenty (Tvariant {row0 with row_fields = rest}) in + update_level !env rm.level ty; + link_type rm ty + in + let md1 = rm1.desc and md2 = rm2.desc in + begin try + set_more row2 r1; + set_more row1 r2; + List.iter + (fun (l,f1,f2) -> + try unify_row_field env fixed1 fixed2 more l f1 f2 + with Unify trace -> + raise (Unify ((mkvariant [l,f1] true, + mkvariant [l,f2] true) :: trace))) + pairs; + if static_row row1 then begin + let rm = row_more row1 in + if is_Tvar rm then link_type rm (newty2 rm.level Tnil) + end + with exn -> + log_type rm1; rm1.desc <- md1; log_type rm2; rm2.desc <- md2; raise exn end - else csil - -let rec prepare_class_type params = function - | Cty_constr (_p, tyl, cty) -> - let sty = Ctype.self_type cty in - if List.memq (proxy sty) !visited_objects - || not (List.for_all is_Tvar params) - || List.exists (deep_occur sty) tyl - then prepare_class_type params cty - else List.iter mark_loops tyl - | Cty_signature sign -> - let sty = repr sign.csig_self in - (* Self may have a name *) - let px = proxy sty in - if List.memq px !visited_objects then add_alias sty - else visited_objects := px :: !visited_objects; - let (fields, _) = - Ctype.flatten_fields (Ctype.object_fields sign.csig_self) - in - List.iter (fun met -> mark_loops (fst (method_type met))) fields; - Vars.iter (fun _ (_, _, ty) -> mark_loops ty) sign.csig_vars - | Cty_arrow (_, ty, cty) -> - mark_loops ty; - prepare_class_type params cty -let rec tree_of_class_type sch params = - function - | Cty_constr (p', tyl, cty) -> - let sty = Ctype.self_type cty in - if List.memq (proxy sty) !visited_objects - || not (List.for_all is_Tvar params) - then - tree_of_class_type sch params cty - else - Octy_constr (tree_of_path p', tree_of_typlist true tyl) - | Cty_signature sign -> - let sty = repr sign.csig_self in - let self_ty = - if is_aliased sty then - Some (Otyp_var (false, name_of_type new_name (proxy sty))) - else None - in - let (fields, _) = - Ctype.flatten_fields (Ctype.object_fields sign.csig_self) - in - let csil = [] in - let csil = - List.fold_left - (fun csil (ty1, ty2) -> Ocsg_constraint (ty1, ty2) :: csil) - csil (tree_of_constraints params) - in - let all_vars = - Vars.fold (fun l (m, v, t) all -> (l, m, v, t) :: all) sign.csig_vars [] - in - (* Consequence of PR#3607: order of Map.fold has changed! *) - let all_vars = List.rev all_vars in - let csil = - List.fold_left - (fun csil (l, m, v, t) -> - Ocsg_value (l, m = Mutable, v = Virtual, tree_of_typexp sch t) - :: csil) - csil all_vars - in - let csil = - List.fold_left (tree_of_metho sch sign.csig_concr) csil fields - in - Octy_signature (self_ty, List.rev csil) - | Cty_arrow (l, ty, cty) -> - let lab = - if !print_labels || is_optional l then string_of_label l else "" +and unify_row_field env fixed1 fixed2 more l f1 f2 = + let f1 = row_field_repr f1 and f2 = row_field_repr f2 in + if f1 == f2 then () else + match f1, f2 with + Rpresent(Some t1), Rpresent(Some t2) -> unify env t1 t2 + | Rpresent None, Rpresent None -> () + | Reither(c1, tl1, m1, e1), Reither(c2, tl2, m2, e2) -> + if e1 == e2 then () else + if (fixed1 || fixed2) && not (c1 || c2) + && List.length tl1 = List.length tl2 then begin + (* PR#7496 *) + let f = Reither (c1 || c2, [], m1 || m2, ref None) in + set_row_field e1 f; set_row_field e2 f; + List.iter2 (unify env) tl1 tl2 + end + else let redo = + not !passive_variants && + (m1 || m2 || fixed1 || fixed2 || + !rigid_variants && (List.length tl1 = 1 || List.length tl2 = 1)) && + begin match tl1 @ tl2 with [] -> false + | t1 :: tl -> + if c1 || c2 then raise (Unify []); + List.iter (unify env t1) tl; + !e1 <> None || !e2 <> None + end in + if redo then unify_row_field env fixed1 fixed2 more l f1 f2 else + let tl1 = List.map repr tl1 and tl2 = List.map repr tl2 in + let rec remq tl = function [] -> [] + | ty :: tl' -> + if List.memq ty tl then remq tl tl' else ty :: remq tl tl' in - let ty = - if is_optional l then - match (repr ty).desc with - | Tconstr(path, [ty], _) when Path.same path Predef.path_option -> ty - | _ -> newconstr (Path.Pident(Ident.create "")) [] - else ty in - let tr = tree_of_typexp sch ty in - Octy_arrow (lab, tr, tree_of_class_type sch params cty) - -let class_type ppf cty = - reset (); - prepare_class_type [] cty; - !Oprint.out_class_type ppf (tree_of_class_type false [] cty) - -let tree_of_class_param param variance = - (match tree_of_typexp true param with - Otyp_var (_, s) -> s - | _ -> "?"), - if is_Tvar (repr param) then (true, true) else variance - -let class_variance = - List.map Variance.(fun v -> mem May_pos v, mem May_neg v) - -let tree_of_class_declaration id cl rs = - let params = filter_params cl.cty_params in - - reset (); - List.iter add_alias params; - prepare_class_type params cl.cty_type; - let sty = Ctype.self_type cl.cty_type in - List.iter mark_loops params; + let tl2' = remq tl2 tl1 and tl1' = remq tl1 tl2 in + (* PR#6744 *) + let split_univars = + List.partition + (fun ty -> try occur_univar !env ty; true with Unify _ -> false) in + let (tl1',tlu1) = split_univars tl1' + and (tl2',tlu2) = split_univars tl2' in + begin match tlu1, tlu2 with + [], [] -> () + | (tu1::tlu1), _ :: _ -> + (* Attempt to merge all the types containing univars *) + if not !passive_variants then + List.iter (unify env tu1) (tlu1@tlu2) + | (tu::_, []) | ([], tu::_) -> occur_univar !env tu + end; + (* Is this handling of levels really principal? *) + List.iter (update_level !env (repr more).level) (tl1' @ tl2'); + let e = ref None in + let f1' = Reither(c1 || c2, tl1', m1 || m2, e) + and f2' = Reither(c1 || c2, tl2', m1 || m2, e) in + set_row_field e1 f1'; set_row_field e2 f2'; + | Reither(_, _, false, e1), Rabsent when not fixed1 -> set_row_field e1 f2 + | Rabsent, Reither(_, _, false, e2) when not fixed2 -> set_row_field e2 f1 + | Rabsent, Rabsent -> () + | Reither(false, tl, _, e1), Rpresent(Some t2) when not fixed1 -> + set_row_field e1 f2; + update_level !env (repr more).level t2; + (try List.iter (fun t1 -> unify env t1 t2) tl + with exn -> e1 := None; raise exn) + | Rpresent(Some t1), Reither(false, tl, _, e2) when not fixed2 -> + set_row_field e2 f1; + update_level !env (repr more).level t1; + (try List.iter (unify env t1) tl + with exn -> e2 := None; raise exn) + | Reither(true, [], _, e1), Rpresent None when not fixed1 -> + set_row_field e1 f2 + | Rpresent None, Reither(true, [], _, e2) when not fixed2 -> + set_row_field e2 f1 + | _ -> raise (Unify []) - List.iter check_name_of_type (List.map proxy params); - if is_aliased sty then check_name_of_type (proxy sty); - let vir_flag = cl.cty_new = None in - Osig_class - (vir_flag, Ident.name id, - List.map2 tree_of_class_param params (class_variance cl.cty_variance), - tree_of_class_type true params cl.cty_type, - tree_of_rec rs) +let unify env ty1 ty2 = + let snap = Btype.snapshot () in + try + unify env ty1 ty2 + with + Unify trace -> + undo_compress snap; + raise (Unify (expand_trace !env trace)) + | Recursive_abbrev -> + undo_compress snap; + raise (Unification_recursive_abbrev (expand_trace !env [(ty1,ty2)])) -let class_declaration id ppf cl = - !Oprint.out_sig_item ppf (tree_of_class_declaration id cl Trec_first) +let unify_gadt ~newtype_level:lev (env:Env.t ref) ty1 ty2 = + try + univar_pairs := []; + newtype_level := Some lev; + set_mode_pattern ~generate:true ~injective:true + (fun () -> unify env ty1 ty2); + newtype_level := None; + TypePairs.clear unify_eq_set; + with e -> + newtype_level := None; + TypePairs.clear unify_eq_set; + raise e -let tree_of_cltype_declaration id cl rs = - let params = List.map repr cl.clty_params in +let unify_var env t1 t2 = + let t1 = repr t1 and t2 = repr t2 in + if t1 == t2 then () else + match t1.desc, t2.desc with + Tvar _, Tconstr _ when deep_occur t1 t2 -> + unify (ref env) t1 t2 + | Tvar _, _ -> + let reset_tracing = check_trace_gadt_instances env in + begin try + occur env t1 t2; + update_level env t1.level t2; + link_type t1 t2; + reset_trace_gadt_instances reset_tracing; + with Unify trace -> + reset_trace_gadt_instances reset_tracing; + let expanded_trace = expand_trace env ((t1,t2)::trace) in + raise (Unify expanded_trace) + end + | _ -> + unify (ref env) t1 t2 - reset (); - List.iter add_alias params; - prepare_class_type params cl.clty_type; - let sty = Ctype.self_type cl.clty_type in - List.iter mark_loops params; +let _ = unify' := unify_var - List.iter check_name_of_type (List.map proxy params); - if is_aliased sty then check_name_of_type (proxy sty); +let unify_pairs env ty1 ty2 pairs = + univar_pairs := pairs; + unify env ty1 ty2 - let sign = Ctype.signature_of_class_type cl.clty_type in +let unify env ty1 ty2 = + unify_pairs (ref env) ty1 ty2 [] - let virt = - let (fields, _) = - Ctype.flatten_fields (Ctype.object_fields sign.csig_self) in - List.exists - (fun (lab, _, _) -> - not (lab = dummy_method || Concr.mem lab sign.csig_concr)) - fields - || Vars.fold (fun _ (_,vr,_) b -> vr = Virtual || b) sign.csig_vars false - in - Osig_class_type - (virt, Ident.name id, - List.map2 tree_of_class_param params (class_variance cl.clty_variance), - tree_of_class_type true params cl.clty_type, - tree_of_rec rs) -let cltype_declaration id ppf cl = - !Oprint.out_sig_item ppf (tree_of_cltype_declaration id cl Trec_first) +(**** Special cases of unification ****) -(* Print a module type *) +let expand_head_trace env t = + let reset_tracing = check_trace_gadt_instances env in + let t = expand_head_unif env t in + reset_trace_gadt_instances reset_tracing; + t -let wrap_env fenv ftree arg = - let env = !printing_env in - set_printing_env (fenv env); - let tree = ftree arg in - set_printing_env env; - tree +(* + Unify [t] and [l:'a -> 'b]. Return ['a] and ['b]. + In label mode, label mismatch is accepted when + (1) the requested label is "" + (2) the original label is not optional +*) -let filter_rem_sig item rem = - match item, rem with - | Sig_class _, ctydecl :: tydecl1 :: tydecl2 :: rem -> - ([ctydecl; tydecl1; tydecl2], rem) - | Sig_class_type _, tydecl1 :: tydecl2 :: rem -> - ([tydecl1; tydecl2], rem) +let filter_arrow env t l = + let t = expand_head_trace env t in + match t.desc with + Tvar _ -> + let lv = t.level in + let t1 = newvar2 lv and t2 = newvar2 lv in + let t' = newty2 lv (Tarrow (l, t1, t2, Cok)) in + link_type t t'; + (t1, t2) + | Tarrow(l', t1, t2, _) + when l = l' || !Clflags.classic && l = Nolabel && not (is_optional l') -> + (t1, t2) | _ -> - ([], rem) - -let dummy = - { type_params = []; type_arity = 0; type_kind = Type_abstract; - type_private = Public; type_manifest = None; type_variance = []; - type_newtype_level = None; type_loc = Location.none; - type_attributes = []; - type_immediate = false; - type_unboxed = unboxed_false_default_false; - } + raise (Unify []) -let hide_rec_items = function - | Sig_type(id, _decl, rs) ::rem - when rs = Trec_first && not !Clflags.real_paths -> - let rec get_ids = function - Sig_type (id, _, Trec_next) :: rem -> - id :: get_ids rem - | _ -> [] +(* Used by [filter_method]. *) +let rec filter_method_field env name priv ty = + let ty = expand_head_trace env ty in + match ty.desc with + Tvar _ -> + let level = ty.level in + let ty1 = newvar2 level and ty2 = newvar2 level in + let ty' = newty2 level (Tfield (name, + begin match priv with + Private -> Fvar (ref None) + | Public -> Fpresent + end, + ty1, ty2)) in - let ids = id :: get_ids rem in - set_printing_env - (List.fold_right - (fun id -> Env.add_type ~check:false (Ident.rename id) dummy) - ids !printing_env) - | _ -> () + link_type ty ty'; + ty1 + | Tfield(n, kind, ty1, ty2) -> + let kind = field_kind_repr kind in + if (n = name) && (kind <> Fabsent) then begin + if priv = Public then + unify_kind kind Fpresent; + ty1 + end else + filter_method_field env name priv ty2 + | _ -> + raise (Unify []) -let rec tree_of_modtype ?(ellipsis=false) = function - | Mty_ident p -> - Omty_ident (tree_of_path p) - | Mty_signature sg -> - Omty_signature (if ellipsis then [Osig_ellipsis] - else tree_of_signature sg) - | Mty_functor(param, ty_arg, ty_res) -> - let res = - match ty_arg with None -> tree_of_modtype ~ellipsis ty_res - | Some mty -> - wrap_env (Env.add_module ~arg:true param mty) - (tree_of_modtype ~ellipsis) ty_res - in - Omty_functor (Ident.name param, - may_map (tree_of_modtype ~ellipsis:false) ty_arg, res) - | Mty_alias(_, p) -> - Omty_alias (tree_of_path p) +(* Unify [ty] and [< name : 'a; .. >]. Return ['a]. *) +let filter_method env name priv ty = + let ty = expand_head_trace env ty in + match ty.desc with + Tvar _ -> + let ty1 = newvar () in + let ty' = newobj ty1 in + update_level env ty.level ty'; + link_type ty ty'; + filter_method_field env name priv ty1 + | Tobject(f, _) -> + filter_method_field env name priv f + | _ -> + raise (Unify []) -and tree_of_signature sg = - wrap_env (fun env -> env) (tree_of_signature_rec !printing_env false) sg +let check_filter_method env name priv ty = + ignore(filter_method env name priv ty) -and tree_of_signature_rec env' in_type_group = function - [] -> [] - | item :: rem as items -> - let in_type_group = - match in_type_group, item with - true, Sig_type (_, _, Trec_next) -> true - | _, Sig_type (_, _, (Trec_not | Trec_first)) -> - set_printing_env env'; true - | _ -> set_printing_env env'; false - in - let (sg, rem) = filter_rem_sig item rem in - hide_rec_items items; - let trees = trees_of_sigitem item in - let env' = Env.add_signature (item :: sg) env' in - trees @ tree_of_signature_rec env' in_type_group rem +let filter_self_method env lab priv meths ty = + let ty' = filter_method env lab priv ty in + try + Meths.find lab !meths + with Not_found -> + let pair = (Ident.create lab, ty') in + meths := Meths.add lab pair !meths; + pair -and trees_of_sigitem = function - | Sig_value(id, decl) -> - [tree_of_value_description id decl] - | Sig_type(id, _, _) when is_row_name (Ident.name id) -> - [] - | Sig_type(id, decl, rs) -> - [tree_of_type_declaration id decl rs] - | Sig_typext(id, ext, es) -> - [tree_of_extension_constructor id ext es] - | Sig_module(id, md, rs) -> - let ellipsis = - List.exists (function ({txt="..."}, Parsetree.PStr []) -> true - | _ -> false) - md.md_attributes in - [tree_of_module id md.md_type rs ~ellipsis] - | Sig_modtype(id, decl) -> - [tree_of_modtype_declaration id decl] - | Sig_class(id, decl, rs) -> - [tree_of_class_declaration id decl rs] - | Sig_class_type(id, decl, rs) -> - [tree_of_cltype_declaration id decl rs] -and tree_of_modtype_declaration id decl = - let mty = - match decl.mtd_type with - | None -> Omty_abstract - | Some mty -> tree_of_modtype mty + (***********************************) + (* Matching between type schemes *) + (***********************************) + +(* + Update the level of [ty]. First check that the levels of generic + variables from the subject are not lowered. +*) +let moregen_occur env level ty = + let rec occur ty = + let ty = repr ty in + if ty.level > level then begin + if is_Tvar ty && ty.level >= generic_level - 1 then raise Occur; + ty.level <- pivot_level - ty.level; + match ty.desc with + Tvariant row when static_row row -> + iter_row occur row + | _ -> + iter_type_expr occur ty + end in - Osig_modtype (Ident.name id, mty) + begin try + occur ty; unmark_type ty + with Occur -> + unmark_type ty; raise (Unify []) + end; + (* also check for free univars *) + occur_univar env ty; + update_level env level ty -and tree_of_module id ?ellipsis mty rs = - Osig_module (Ident.name id, tree_of_modtype ?ellipsis mty, tree_of_rec rs) +let may_instantiate inst_nongen t1 = + if inst_nongen then t1.level <> generic_level - 1 + else t1.level = generic_level -let modtype ppf mty = !Oprint.out_module_type ppf (tree_of_modtype mty) -let modtype_declaration id ppf decl = - !Oprint.out_sig_item ppf (tree_of_modtype_declaration id decl) +let rec moregen inst_nongen type_pairs env t1 t2 = + if t1 == t2 then () else + let t1 = repr t1 in + let t2 = repr t2 in + if t1 == t2 then () else -(* For the toplevel: merge with tree_of_signature? *) + try + match (t1.desc, t2.desc) with + (Tvar _, _) when may_instantiate inst_nongen t1 -> + moregen_occur env t1.level t2; + occur env t1 t2; + link_type t1 t2 + | (Tconstr (p1, [], _), Tconstr (p2, [], _)) when Path.same p1 p2 -> + () + | _ -> + let t1' = expand_head env t1 in + let t2' = expand_head env t2 in + (* Expansion may have changed the representative of the types... *) + let t1' = repr t1' and t2' = repr t2' in + if t1' == t2' then () else + begin try + TypePairs.find type_pairs (t1', t2') + with Not_found -> + TypePairs.add type_pairs (t1', t2') (); + match (t1'.desc, t2'.desc) with + (Tvar _, _) when may_instantiate inst_nongen t1' -> + moregen_occur env t1'.level t2; + link_type t1' t2 + | (Tarrow (l1, t1, u1, _), Tarrow (l2, t2, u2, _)) when l1 = l2 + || !Clflags.classic && not (is_optional l1 || is_optional l2) -> + moregen inst_nongen type_pairs env t1 t2; + moregen inst_nongen type_pairs env u1 u2 + | (Ttuple tl1, Ttuple tl2) -> + moregen_list inst_nongen type_pairs env tl1 tl2 + | (Tconstr (p1, tl1, _), Tconstr (p2, tl2, _)) + when Path.same p1 p2 -> + moregen_list inst_nongen type_pairs env tl1 tl2 + | (Tpackage (p1, n1, tl1), Tpackage (p2, n2, tl2)) -> + begin try + unify_package env (moregen_list inst_nongen type_pairs env) + t1'.level p1 n1 tl1 t2'.level p2 n2 tl2 + with Not_found -> raise (Unify []) + end + | (Tvariant row1, Tvariant row2) -> + moregen_row inst_nongen type_pairs env row1 row2 + | (Tobject (fi1, _nm1), Tobject (fi2, _nm2)) -> + moregen_fields inst_nongen type_pairs env fi1 fi2 + | (Tfield _, Tfield _) -> (* Actually unused *) + moregen_fields inst_nongen type_pairs env t1' t2' + | (Tnil, Tnil) -> + () + | (Tpoly (t1, []), Tpoly (t2, [])) -> + moregen inst_nongen type_pairs env t1 t2 + | (Tpoly (t1, tl1), Tpoly (t2, tl2)) -> + enter_poly env univar_pairs t1 tl1 t2 tl2 + (moregen inst_nongen type_pairs env) + | (Tunivar _, Tunivar _) -> + unify_univar t1' t2' !univar_pairs + | (_, _) -> + raise (Unify []) + end + with Unify trace -> + raise (Unify ((t1, t2)::trace)) -(* Refresh weak variable map in the toplevel *) -let refresh_weak () = - let refresh t name (m,s) = - if is_non_gen true (repr t) then - begin - TypeMap.add t name m, - StringSet.add name s - end - else m, s in - let m, s = - TypeMap.fold refresh !weak_var_map (TypeMap.empty ,StringSet.empty) in - named_weak_vars := s; - weak_var_map := m +and moregen_list inst_nongen type_pairs env tl1 tl2 = + if List.length tl1 <> List.length tl2 then + raise (Unify []); + List.iter2 (moregen inst_nongen type_pairs env) tl1 tl2 -let print_items showval env x = - refresh_weak(); - let rec print showval env = function - | [] -> [] - | item :: rem as items -> - let (_sg, rem) = filter_rem_sig item rem in - hide_rec_items items; - let trees = trees_of_sigitem item in - List.map (fun d -> (d, showval env item)) trees @ - print showval env rem in - print showval env x +and moregen_fields inst_nongen type_pairs env ty1 ty2 = + let (fields1, rest1) = flatten_fields ty1 + and (fields2, rest2) = flatten_fields ty2 in + let (pairs, miss1, miss2) = associate_fields fields1 fields2 in + if miss1 <> [] then raise (Unify []); + moregen inst_nongen type_pairs env rest1 + (build_fields (repr ty2).level miss2 rest2); + List.iter + (fun (n, k1, t1, k2, t2) -> + moregen_kind k1 k2; + try moregen inst_nongen type_pairs env t1 t2 with Unify trace -> + raise (Unify ((newty (Tfield(n, k1, t1, rest2)), + newty (Tfield(n, k2, t2, rest2)))::trace))) + pairs -(* Print a signature body (used by -i when compiling a .ml) *) +and moregen_kind k1 k2 = + let k1 = field_kind_repr k1 in + let k2 = field_kind_repr k2 in + if k1 == k2 then () else + match k1, k2 with + (Fvar r, (Fvar _ | Fpresent)) -> set_kind r k2 + | (Fpresent, Fpresent) -> () + | _ -> raise (Unify []) -let print_signature ppf tree = - fprintf ppf "@[%a@]" !Oprint.out_signature tree +and moregen_row inst_nongen type_pairs env row1 row2 = + let row1 = row_repr row1 and row2 = row_repr row2 in + let rm1 = repr row1.row_more and rm2 = repr row2.row_more in + if rm1 == rm2 then () else + let may_inst = + is_Tvar rm1 && may_instantiate inst_nongen rm1 || rm1.desc = Tnil in + let r1, r2, pairs = merge_row_fields row1.row_fields row2.row_fields in + let r1, r2 = + if row2.row_closed then + filter_row_fields may_inst r1, filter_row_fields false r2 + else r1, r2 + in + if r1 <> [] || row1.row_closed && (not row2.row_closed || r2 <> []) + then raise (Unify []); + begin match rm1.desc, rm2.desc with + Tunivar _, Tunivar _ -> + unify_univar rm1 rm2 !univar_pairs + | Tunivar _, _ | _, Tunivar _ -> + raise (Unify []) + | _ when static_row row1 -> () + | _ when may_inst -> + let ext = + newgenty (Tvariant {row2 with row_fields = r2; row_name = None}) + in + moregen_occur env rm1.level ext; + link_type rm1 ext + | Tconstr _, Tconstr _ -> + moregen inst_nongen type_pairs env rm1 rm2 + | _ -> raise (Unify []) + end; + List.iter + (fun (_l,f1,f2) -> + let f1 = row_field_repr f1 and f2 = row_field_repr f2 in + if f1 == f2 then () else + match f1, f2 with + Rpresent(Some t1), Rpresent(Some t2) -> + moregen inst_nongen type_pairs env t1 t2 + | Rpresent None, Rpresent None -> () + | Reither(false, tl1, _, e1), Rpresent(Some t2) when may_inst -> + set_row_field e1 f2; + List.iter (fun t1 -> moregen inst_nongen type_pairs env t1 t2) tl1 + | Reither(c1, tl1, _, e1), Reither(c2, tl2, m2, e2) -> + if e1 != e2 then begin + if c1 && not c2 then raise(Unify []); + set_row_field e1 (Reither (c2, [], m2, e2)); + if List.length tl1 = List.length tl2 then + List.iter2 (moregen inst_nongen type_pairs env) tl1 tl2 + else match tl2 with + t2 :: _ -> + List.iter (fun t1 -> moregen inst_nongen type_pairs env t1 t2) + tl1 + | [] -> + if tl1 <> [] then raise (Unify []) + end + | Reither(true, [], _, e1), Rpresent None when may_inst -> + set_row_field e1 f2 + | Reither(_, _, _, e1), Rabsent when may_inst -> + set_row_field e1 f2 + | Rabsent, Rabsent -> () + | _ -> raise (Unify [])) + pairs -let signature ppf sg = - fprintf ppf "%a" print_signature (tree_of_signature sg) +(* Must empty univar_pairs first *) +let moregen inst_nongen type_pairs env patt subj = + univar_pairs := []; + moregen inst_nongen type_pairs env patt subj -(* Print an unification error *) +(* + Non-generic variable can be instantiated only if [inst_nongen] is + true. So, [inst_nongen] should be set to false if the subject might + contain non-generic variables (and we do not want them to be + instantiated). + Usually, the subject is given by the user, and the pattern + is unimportant. So, no need to propagate abbreviations. +*) +let moregeneral env inst_nongen pat_sch subj_sch = + let old_level = !current_level in + current_level := generic_level - 1; + (* + Generic variables are first duplicated with [instance]. So, + their levels are lowered to [generic_level - 1]. The subject is + then copied with [duplicate_type]. That way, its levels won't be + changed. + *) + let subj = duplicate_type (instance env subj_sch) in + current_level := generic_level; + (* Duplicate generic variables *) + let patt = instance env pat_sch in + let res = + try moregen inst_nongen (TypePairs.create 13) env patt subj; true with + Unify _ -> false + in + current_level := old_level; + res -let same_path t t' = - let t = repr t and t' = repr t' in - t == t' || - match t.desc, t'.desc with - Tconstr(p,tl,_), Tconstr(p',tl',_) -> - let (p1, s1) = best_type_path p and (p2, s2) = best_type_path p' in - begin match s1, s2 with - Nth n1, Nth n2 when n1 = n2 -> true - | (Id | Map _), (Id | Map _) when Path.same p1 p2 -> - let tl = apply_subst s1 tl and tl' = apply_subst s2 tl' in - List.length tl = List.length tl' && - List.for_all2 same_type tl tl' - | _ -> false - end - | _ -> - false -let type_expansion t ppf t' = - if same_path t t' - then begin add_delayed (proxy t); type_expr ppf t end - else - let t' = if proxy t == proxy t' then unalias t' else t' in - fprintf ppf "@[<2>%a@ =@ %a@]" type_expr t type_expr t' +(* Alternative approach: "rigidify" a type scheme, + and check validity after unification *) +(* Simpler, no? *) -let type_path_expansion tp ppf tp' = - if Path.same tp tp' then path ppf tp else - fprintf ppf "@[<2>%a@ =@ %a@]" path tp path tp' +let rec rigidify_rec vars ty = + let ty = repr ty in + if ty.level >= lowest_level then begin + ty.level <- pivot_level - ty.level; + match ty.desc with + | Tvar _ -> + if not (List.memq ty !vars) then vars := ty :: !vars + | Tvariant row -> + let row = row_repr row in + let more = repr row.row_more in + if is_Tvar more && not (row_fixed row) then begin + let more' = newty2 more.level more.desc in + let row' = {row with row_fixed=true; row_fields=[]; row_more=more'} + in link_type more (newty2 ty.level (Tvariant row')) + end; + iter_row (rigidify_rec vars) row; + (* only consider the row variable if the variant is not static *) + if not (static_row row) then rigidify_rec vars (row_more row) + | _ -> + iter_type_expr (rigidify_rec vars) ty + end -let rec trace fst txt ppf = function - | (t1, t1') :: (t2, t2') :: rem -> - if not fst then fprintf ppf "@,"; - fprintf ppf "@[Type@;<1 2>%a@ %s@;<1 2>%a@] %a" - (type_expansion t1) t1' txt (type_expansion t2) t2' - (trace false txt) rem - | _ -> () +let rigidify ty = + let vars = ref [] in + rigidify_rec vars ty; + unmark_type ty; + !vars -let rec filter_trace keep_last = function - | (_, t1') :: (_, t2') :: [] when is_Tvar t1' || is_Tvar t2' -> - [] - | (t1, t1') :: (t2, t2') :: rem -> - let rem' = filter_trace keep_last rem in - if is_constr_row ~allow_ident:true t1' - || is_constr_row ~allow_ident:true t2' - || same_path t1 t1' && same_path t2 t2' && not (keep_last && rem' = []) - then rem' - else (t1, t1') :: (t2, t2') :: rem' - | _ -> [] +let all_distinct_vars env vars = + let tyl = ref [] in + List.for_all + (fun ty -> + let ty = expand_head env ty in + if List.memq ty !tyl then false else + (tyl := ty :: !tyl; is_Tvar ty)) + vars -let rec type_path_list ppf = function - | [tp, tp'] -> type_path_expansion tp ppf tp' - | (tp, tp') :: rem -> - fprintf ppf "%a@;<2 0>%a" - (type_path_expansion tp) tp' - type_path_list rem - | [] -> () +let matches env ty ty' = + let snap = snapshot () in + let vars = rigidify ty in + cleanup_abbrev (); + let ok = + try unify env ty ty'; all_distinct_vars env vars + with Unify _ -> false + in + backtrack snap; + ok -(* Hide variant name and var, to force printing the expanded type *) -let hide_variant_name t = - match repr t with - | {desc = Tvariant row} as t when (row_repr row).row_name <> None -> - newty2 t.level - (Tvariant {(row_repr row) with row_name = None; - row_more = newvar2 (row_more row).level}) - | _ -> t -let prepare_expansion (t, t') = - let t' = hide_variant_name t' in - mark_loops t; - if not (same_path t t') then mark_loops t'; - (t, t') + (*********************************************) + (* Equivalence between parameterized types *) + (*********************************************) -let may_prepare_expansion compact (t, t') = - match (repr t').desc with - Tvariant _ | Tobject _ when compact -> - mark_loops t; (t, t) - | _ -> prepare_expansion (t, t') +let expand_head_rigid env ty = + let old = !rigid_variants in + rigid_variants := true; + let ty' = expand_head env ty in + rigid_variants := old; ty' -let print_tags ppf fields = - match fields with [] -> () - | (t, _) :: fields -> - fprintf ppf "`%s" t; - List.iter (fun (t, _) -> fprintf ppf ",@ `%s" t) fields +let normalize_subst subst = + if List.exists + (function {desc=Tlink _}, _ | _, {desc=Tlink _} -> true | _ -> false) + !subst + then subst := List.map (fun (t1,t2) -> repr t1, repr t2) !subst -let has_explanation t3 t4 = - match t3.desc, t4.desc with - Tfield _, (Tnil|Tconstr _) | (Tnil|Tconstr _), Tfield _ - | Tnil, Tconstr _ | Tconstr _, Tnil - | _, Tvar _ | Tvar _, _ - | Tvariant _, Tvariant _ -> true - | Tfield (l,_,_,{desc=Tnil}), Tfield (l',_,_,{desc=Tnil}) -> l = l' - | _ -> false +let rec eqtype rename type_pairs subst env t1 t2 = + if t1 == t2 then () else + let t1 = repr t1 in + let t2 = repr t2 in + if t1 == t2 then () else -let rec mismatch = function - (_, t) :: (_, t') :: rem -> - begin match mismatch rem with - Some _ as m -> m - | None -> - if has_explanation t t' then Some(t,t') else None - end - | [] -> None - | _ -> assert false + try + match (t1.desc, t2.desc) with + (Tvar _, Tvar _) when rename -> + begin try + normalize_subst subst; + if List.assq t1 !subst != t2 then raise (Unify []) + with Not_found -> + if List.exists (fun (_, t) -> t == t2) !subst then raise (Unify []); + subst := (t1, t2) :: !subst + end + | (Tconstr (p1, [], _), Tconstr (p2, [], _)) when Path.same p1 p2 -> + () + | _ -> + let t1' = expand_head_rigid env t1 in + let t2' = expand_head_rigid env t2 in + (* Expansion may have changed the representative of the types... *) + let t1' = repr t1' and t2' = repr t2' in + if t1' == t2' then () else + begin try + TypePairs.find type_pairs (t1', t2') + with Not_found -> + TypePairs.add type_pairs (t1', t2') (); + match (t1'.desc, t2'.desc) with + (Tvar _, Tvar _) when rename -> + begin try + normalize_subst subst; + if List.assq t1' !subst != t2' then raise (Unify []) + with Not_found -> + if List.exists (fun (_, t) -> t == t2') !subst + then raise (Unify []); + subst := (t1', t2') :: !subst + end + | (Tarrow (l1, t1, u1, _), Tarrow (l2, t2, u2, _)) when l1 = l2 + || !Clflags.classic && not (is_optional l1 || is_optional l2) -> + eqtype rename type_pairs subst env t1 t2; + eqtype rename type_pairs subst env u1 u2; + | (Ttuple tl1, Ttuple tl2) -> + eqtype_list rename type_pairs subst env tl1 tl2 + | (Tconstr (p1, tl1, _), Tconstr (p2, tl2, _)) + when Path.same p1 p2 -> + eqtype_list rename type_pairs subst env tl1 tl2 + | (Tpackage (p1, n1, tl1), Tpackage (p2, n2, tl2)) -> + begin try + unify_package env (eqtype_list rename type_pairs subst env) + t1'.level p1 n1 tl1 t2'.level p2 n2 tl2 + with Not_found -> raise (Unify []) + end + | (Tvariant row1, Tvariant row2) -> + eqtype_row rename type_pairs subst env row1 row2 + | (Tobject (fi1, _nm1), Tobject (fi2, _nm2)) -> + eqtype_fields rename type_pairs subst env fi1 fi2 + | (Tfield _, Tfield _) -> (* Actually unused *) + eqtype_fields rename type_pairs subst env t1' t2' + | (Tnil, Tnil) -> + () + | (Tpoly (t1, []), Tpoly (t2, [])) -> + eqtype rename type_pairs subst env t1 t2 + | (Tpoly (t1, tl1), Tpoly (t2, tl2)) -> + enter_poly env univar_pairs t1 tl1 t2 tl2 + (eqtype rename type_pairs subst env) + | (Tunivar _, Tunivar _) -> + unify_univar t1' t2' !univar_pairs + | (_, _) -> + raise (Unify []) + end + with Unify trace -> + raise (Unify ((t1, t2)::trace)) -let explanation unif t3 t4 ppf = - match t3.desc, t4.desc with - | Ttuple [], Tvar _ | Tvar _, Ttuple [] -> - fprintf ppf "@,Self type cannot escape its class" - | Tconstr (p, _, _), Tvar _ - when unif && t4.level < Path.binding_time p -> - fprintf ppf - "@,@[The type constructor@;<1 2>%a@ would escape its scope@]" - path p - | Tvar _, Tconstr (p, _, _) - when unif && t3.level < Path.binding_time p -> - fprintf ppf - "@,@[The type constructor@;<1 2>%a@ would escape its scope@]" - path p - | Tvar _, Tunivar _ | Tunivar _, Tvar _ -> - fprintf ppf "@,The universal variable %a would escape its scope" - type_expr (if is_Tunivar t3 then t3 else t4) - | Tvar _, _ | _, Tvar _ -> - let t, t' = if is_Tvar t3 then (t3, t4) else (t4, t3) in - if occur_in Env.empty t t' then - fprintf ppf "@,@[The type variable %a occurs inside@ %a@]" - type_expr t type_expr t' - else - fprintf ppf "@,@[This instance of %a is ambiguous:@ %s@]" - type_expr t' - "it would escape the scope of its equation" - | Tfield (lab, _, _, _), _ when lab = dummy_method -> - fprintf ppf - "@,Self type cannot be unified with a closed object type" - | _, Tfield (lab, _, _, _) when lab = dummy_method -> - fprintf ppf - "@,Self type cannot be unified with a closed object type" - | Tfield (l,_,_,{desc=Tnil}), Tfield (l',_,_,{desc=Tnil}) when l = l' -> - fprintf ppf "@,Types for method %s are incompatible" l - | (Tnil|Tconstr _), Tfield (l, _, _, _) -> - fprintf ppf - "@,@[The first object type has no method %s@]" l - | Tfield (l, _, _, _), (Tnil|Tconstr _) -> - fprintf ppf - "@,@[The second object type has no method %s@]" l - | Tnil, Tconstr _ | Tconstr _, Tnil -> - fprintf ppf - "@,@[The %s object type has an abstract row, it cannot be closed@]" - (if t4.desc = Tnil then "first" else "second") - | Tvariant row1, Tvariant row2 -> - let row1 = row_repr row1 and row2 = row_repr row2 in - begin match - row1.row_fields, row1.row_closed, row2.row_fields, row2.row_closed with - | [], true, [], true -> - fprintf ppf "@,These two variant types have no intersection" - | [], true, (_::_ as fields), _ -> - fprintf ppf - "@,@[The first variant type does not allow tag(s)@ @[%a@]@]" - print_tags fields - | (_::_ as fields), _, [], true -> - fprintf ppf - "@,@[The second variant type does not allow tag(s)@ @[%a@]@]" - print_tags fields - | [l1,_], true, [l2,_], true when l1 = l2 -> - fprintf ppf "@,Types for tag `%s are incompatible" l1 - | _ -> () - end - | _ -> () +and eqtype_list rename type_pairs subst env tl1 tl2 = + if List.length tl1 <> List.length tl2 then + raise (Unify []); + List.iter2 (eqtype rename type_pairs subst env) tl1 tl2 +and eqtype_fields rename type_pairs subst env ty1 ty2 = + let (fields1, rest1) = flatten_fields ty1 in + let (fields2, rest2) = flatten_fields ty2 in + (* First check if same row => already equal *) + let same_row = + rest1 == rest2 || TypePairs.mem type_pairs (rest1,rest2) || + (rename && List.mem (rest1, rest2) !subst) + in + if same_row then () else + (* Try expansion, needed when called from Includecore.type_manifest *) + match expand_head_rigid env rest2 with + {desc=Tobject(ty2,_)} -> eqtype_fields rename type_pairs subst env ty1 ty2 + | _ -> + let (pairs, miss1, miss2) = associate_fields fields1 fields2 in + eqtype rename type_pairs subst env rest1 rest2; + if (miss1 <> []) || (miss2 <> []) then raise (Unify []); + List.iter + (function (n, k1, t1, k2, t2) -> + eqtype_kind k1 k2; + try eqtype rename type_pairs subst env t1 t2 with Unify trace -> + raise (Unify ((newty (Tfield(n, k1, t1, rest2)), + newty (Tfield(n, k2, t2, rest2)))::trace))) + pairs -let warn_on_missing_def env ppf t = - match t.desc with - | Tconstr (p,_,_) -> - begin - try - ignore(Env.find_type p env : Types.type_declaration) - with Not_found -> - fprintf ppf - "@,@[%a is abstract because no corresponding cmi file was found \ - in path.@]" path p - end - | _ -> () +and eqtype_kind k1 k2 = + let k1 = field_kind_repr k1 in + let k2 = field_kind_repr k2 in + match k1, k2 with + (Fvar _, Fvar _) + | (Fpresent, Fpresent) -> () + | _ -> raise (Unify []) -let explanation unif mis ppf = - match mis with - None -> () - | Some (t3, t4) -> explanation unif t3 t4 ppf +and eqtype_row rename type_pairs subst env row1 row2 = + (* Try expansion, needed when called from Includecore.type_manifest *) + match expand_head_rigid env (row_more row2) with + {desc=Tvariant row2} -> eqtype_row rename type_pairs subst env row1 row2 + | _ -> + let row1 = row_repr row1 and row2 = row_repr row2 in + let r1, r2, pairs = merge_row_fields row1.row_fields row2.row_fields in + if row1.row_closed <> row2.row_closed + || not row1.row_closed && (r1 <> [] || r2 <> []) + || filter_row_fields false (r1 @ r2) <> [] + then raise (Unify []); + if not (static_row row1) then + eqtype rename type_pairs subst env row1.row_more row2.row_more; + List.iter + (fun (_,f1,f2) -> + match row_field_repr f1, row_field_repr f2 with + Rpresent(Some t1), Rpresent(Some t2) -> + eqtype rename type_pairs subst env t1 t2 + | Reither(c1, [], _, _), Reither(c2, [], _, _) when c1 = c2 -> + () + | Reither(c1, t1::tl1, _, _), Reither(c2, t2::tl2, _, _) when c1 = c2 -> + eqtype rename type_pairs subst env t1 t2; + if List.length tl1 = List.length tl2 then + (* if same length allow different types (meaning?) *) + List.iter2 (eqtype rename type_pairs subst env) tl1 tl2 + else begin + (* otherwise everything must be equal *) + List.iter (eqtype rename type_pairs subst env t1) tl2; + List.iter (fun t1 -> eqtype rename type_pairs subst env t1 t2) tl1 + end + | Rpresent None, Rpresent None -> () + | Rabsent, Rabsent -> () + | _ -> raise (Unify [])) + pairs -let ident_same_name id1 id2 = - if Ident.equal id1 id2 && not (Ident.same id1 id2) then begin - add_unique id1; add_unique id2 - end +(* Must empty univar_pairs first *) +let eqtype_list rename type_pairs subst env tl1 tl2 = + univar_pairs := []; + let snap = Btype.snapshot () in + try eqtype_list rename type_pairs subst env tl1 tl2; backtrack snap + with exn -> backtrack snap; raise exn -let rec path_same_name p1 p2 = - match p1, p2 with - Pident id1, Pident id2 -> ident_same_name id1 id2 - | Pdot (p1, s1, _), Pdot (p2, s2, _) when s1 = s2 -> path_same_name p1 p2 - | Papply (p1, p1'), Papply (p2, p2') -> - path_same_name p1 p2; path_same_name p1' p2' - | _ -> () +let eqtype rename type_pairs subst env t1 t2 = + eqtype_list rename type_pairs subst env [t1] [t2] -let type_same_name t1 t2 = - match (repr t1).desc, (repr t2).desc with - Tconstr (p1, _, _), Tconstr (p2, _, _) -> - path_same_name (fst (best_type_path p1)) (fst (best_type_path p2)) - | _ -> () +(* Two modes: with or without renaming of variables *) +let equal env rename tyl1 tyl2 = + try + eqtype_list rename (TypePairs.create 11) (ref []) env tyl1 tyl2; true + with + Unify _ -> false -let rec trace_same_names = function - (t1, t1') :: (t2, t2') :: rem -> - type_same_name t1 t2; type_same_name t1' t2'; trace_same_names rem - | _ -> () -let unification_error env unif tr txt1 ppf txt2 = - reset (); - trace_same_names tr; - let tr = List.map (fun (t, t') -> (t, hide_variant_name t')) tr in - let mis = mismatch tr in - match tr with - | [] | _ :: [] -> assert false - | t1 :: t2 :: tr -> - try - let tr = filter_trace (mis = None) tr in - let t1, t1' = may_prepare_expansion (tr = []) t1 - and t2, t2' = may_prepare_expansion (tr = []) t2 in - print_labels := not !Clflags.classic; - let tr = List.map prepare_expansion tr in - fprintf ppf - "@[\ - @[%t@;<1 2>%a@ \ - %t@;<1 2>%a\ - @]%a%t\ - @]" - txt1 (type_expansion t1) t1' - txt2 (type_expansion t2) t2' - (trace false "is not compatible with type") tr - (explanation unif mis); - if env <> Env.empty - then begin - warn_on_missing_def env ppf t1; - warn_on_missing_def env ppf t2 - end; - print_labels := true - with exn -> - print_labels := true; - raise exn + (*************************) + (* Class type matching *) + (*************************) -let report_unification_error ppf env ?(unif=true) - tr txt1 txt2 = - wrap_printing_env env (fun () -> unification_error env unif tr txt1 ppf txt2) -;; +type class_match_failure = + CM_Virtual_class + | CM_Parameter_arity_mismatch of int * int + | CM_Type_parameter_mismatch of Env.t * (type_expr * type_expr) list + | CM_Class_type_mismatch of Env.t * class_type * class_type + | CM_Parameter_mismatch of Env.t * (type_expr * type_expr) list + | CM_Val_type_mismatch of string * Env.t * (type_expr * type_expr) list + | CM_Meth_type_mismatch of string * Env.t * (type_expr * type_expr) list + | CM_Non_mutable_value of string + | CM_Non_concrete_value of string + | CM_Missing_value of string + | CM_Missing_method of string + | CM_Hide_public of string + | CM_Hide_virtual of string * string + | CM_Public_method of string + | CM_Private_method of string + | CM_Virtual_method of string + +exception Failure of class_match_failure list -let super_type_expansion ~tag t ppf t' = - if same_path t t' then begin - Format.pp_open_tag ppf tag; - type_expr ppf t; - Format.pp_close_tag ppf (); - end else begin - let t' = if proxy t == proxy t' then unalias t' else t' in - fprintf ppf "@[<2>"; - Format.pp_open_tag ppf tag; - fprintf ppf "%a" type_expr t; - Format.pp_close_tag ppf (); - fprintf ppf "@ @{(defined as@}@ "; - Format.pp_open_tag ppf tag; - fprintf ppf "%a" type_expr t'; - Format.pp_close_tag ppf (); - fprintf ppf "@{)@}"; - fprintf ppf "@]"; - end +let rec moregen_clty trace type_pairs env cty1 cty2 = + try + match cty1, cty2 with + Cty_constr (_, _, cty1), _ -> + moregen_clty true type_pairs env cty1 cty2 + | _, Cty_constr (_, _, cty2) -> + moregen_clty true type_pairs env cty1 cty2 + | Cty_arrow (l1, ty1, cty1'), Cty_arrow (l2, ty2, cty2') when l1 = l2 -> + begin try moregen true type_pairs env ty1 ty2 with Unify trace -> + raise (Failure [CM_Parameter_mismatch (env, expand_trace env trace)]) + end; + moregen_clty false type_pairs env cty1' cty2' + | Cty_signature sign1, Cty_signature sign2 -> + let ty1 = object_fields (repr sign1.csig_self) in + let ty2 = object_fields (repr sign2.csig_self) in + let (fields1, _rest1) = flatten_fields ty1 + and (fields2, _rest2) = flatten_fields ty2 in + let (pairs, _miss1, _miss2) = associate_fields fields1 fields2 in + List.iter + (fun (lab, _k1, t1, _k2, t2) -> + begin try moregen true type_pairs env t1 t2 with Unify trace -> + raise (Failure [CM_Meth_type_mismatch + (lab, env, expand_trace env trace)]) + end) + pairs; + Vars.iter + (fun lab (_mut, _v, ty) -> + let (_mut', _v', ty') = Vars.find lab sign1.csig_vars in + try moregen true type_pairs env ty' ty with Unify trace -> + raise (Failure [CM_Val_type_mismatch + (lab, env, expand_trace env trace)])) + sign2.csig_vars + | _ -> + raise (Failure []) + with + Failure error when trace || error = [] -> + raise (Failure (CM_Class_type_mismatch (env, cty1, cty2)::error)) -let super_trace ppf = - let rec super_trace first_report ppf = function - | (t1, t1') :: (t2, t2') :: rem -> - fprintf ppf - "@,@,@["; - if first_report then - fprintf ppf "The incompatible parts:@," - else begin - fprintf ppf "Further expanded:@," - end; - fprintf ppf - "@[\ - @[%a@]@,\ - vs@,\ - @[%a@]\ - %a\ - @]" - (super_type_expansion ~tag:"error" t1) t1' - (super_type_expansion ~tag:"info" t2) t2' - (super_trace false) rem; - fprintf ppf "@]" - | _ -> () - in super_trace true ppf +let match_class_types ?(trace=true) env pat_sch subj_sch = + let type_pairs = TypePairs.create 53 in + let old_level = !current_level in + current_level := generic_level - 1; + (* + Generic variables are first duplicated with [instance]. So, + their levels are lowered to [generic_level - 1]. The subject is + then copied with [duplicate_type]. That way, its levels won't be + changed. + *) + let (_, subj_inst) = instance_class [] subj_sch in + let subj = duplicate_class_type subj_inst in + current_level := generic_level; + (* Duplicate generic variables *) + let (_, patt) = instance_class [] pat_sch in + let res = + let sign1 = signature_of_class_type patt in + let sign2 = signature_of_class_type subj in + let t1 = repr sign1.csig_self in + let t2 = repr sign2.csig_self in + TypePairs.add type_pairs (t1, t2) (); + let (fields1, rest1) = flatten_fields (object_fields t1) + and (fields2, rest2) = flatten_fields (object_fields t2) in + let (pairs, miss1, miss2) = associate_fields fields1 fields2 in + let error = + List.fold_right + (fun (lab, k, _) err -> + let err = + let k = field_kind_repr k in + begin match k with + Fvar r -> set_kind r Fabsent; err + | _ -> CM_Hide_public lab::err + end + in + if Concr.mem lab sign1.csig_concr then err + else CM_Hide_virtual ("method", lab) :: err) + miss1 [] + in + let missing_method = List.map (fun (m, _, _) -> m) miss2 in + let error = + (List.map (fun m -> CM_Missing_method m) missing_method) @ error + in + (* Always succeeds *) + moregen true type_pairs env rest1 rest2; + let error = + List.fold_right + (fun (lab, k1, _t1, k2, _t2) err -> + try moregen_kind k1 k2; err with + Unify _ -> CM_Public_method lab::err) + pairs error + in + let error = + Vars.fold + (fun lab (mut, vr, _ty) err -> + try + let (mut', vr', _ty') = Vars.find lab sign1.csig_vars in + if mut = Mutable && mut' <> Mutable then + CM_Non_mutable_value lab::err + else if vr = Concrete && vr' <> Concrete then + CM_Non_concrete_value lab::err + else + err + with Not_found -> + CM_Missing_value lab::err) + sign2.csig_vars error + in + let error = + Vars.fold + (fun lab (_,vr,_) err -> + if vr = Virtual && not (Vars.mem lab sign2.csig_vars) then + CM_Hide_virtual ("instance variable", lab) :: err + else err) + sign1.csig_vars error + in + let error = + List.fold_right + (fun e l -> + if List.mem e missing_method then l else CM_Virtual_method e::l) + (Concr.elements (Concr.diff sign2.csig_concr sign1.csig_concr)) + error + in + match error with + [] -> + begin try + moregen_clty trace type_pairs env patt subj; + [] + with + Failure r -> r + end + | error -> + CM_Class_type_mismatch (env, patt, subj)::error + in + current_level := old_level; + res -let super_unification_error unif tr txt1 ppf txt2 = begin - reset (); - trace_same_names tr; - let tr = List.map (fun (t, t') -> (t, hide_variant_name t')) tr in - let mis = mismatch tr in - match tr with - | [] | _ :: [] -> assert false - | t1 :: t2 :: tr -> - try - let tr = filter_trace (mis = None) tr in - let t1, t1' = may_prepare_expansion (tr = []) t1 - and t2, t2' = may_prepare_expansion (tr = []) t2 in - print_labels := not !Clflags.classic; - let tr = List.map prepare_expansion tr in - fprintf ppf - "@[\ - @[\ - %t@,\ - @[<2>%a@]\ - @]@,\ - @[\ - %t@,\ - @[<2>%a@]\ - @]\ - %a\ - %t\ - @]" - txt1 (super_type_expansion ~tag:"error" t1) t1' - txt2 (super_type_expansion ~tag:"info" t2) t2' - super_trace tr - (explanation unif mis); - print_labels := true - with exn -> - print_labels := true; - raise exn -end +let rec equal_clty trace type_pairs subst env cty1 cty2 = + try + match cty1, cty2 with + Cty_constr (_, _, cty1), Cty_constr (_, _, cty2) -> + equal_clty true type_pairs subst env cty1 cty2 + | Cty_constr (_, _, cty1), _ -> + equal_clty true type_pairs subst env cty1 cty2 + | _, Cty_constr (_, _, cty2) -> + equal_clty true type_pairs subst env cty1 cty2 + | Cty_arrow (l1, ty1, cty1'), Cty_arrow (l2, ty2, cty2') when l1 = l2 -> + begin try eqtype true type_pairs subst env ty1 ty2 with Unify trace -> + raise (Failure [CM_Parameter_mismatch (env, expand_trace env trace)]) + end; + equal_clty false type_pairs subst env cty1' cty2' + | Cty_signature sign1, Cty_signature sign2 -> + let ty1 = object_fields (repr sign1.csig_self) in + let ty2 = object_fields (repr sign2.csig_self) in + let (fields1, _rest1) = flatten_fields ty1 + and (fields2, _rest2) = flatten_fields ty2 in + let (pairs, _miss1, _miss2) = associate_fields fields1 fields2 in + List.iter + (fun (lab, _k1, t1, _k2, t2) -> + begin try eqtype true type_pairs subst env t1 t2 with + Unify trace -> + raise (Failure [CM_Meth_type_mismatch + (lab, env, expand_trace env trace)]) + end) + pairs; + Vars.iter + (fun lab (_, _, ty) -> + let (_, _, ty') = Vars.find lab sign1.csig_vars in + try eqtype true type_pairs subst env ty' ty with Unify trace -> + raise (Failure [CM_Val_type_mismatch + (lab, env, expand_trace env trace)])) + sign2.csig_vars + | _ -> + raise + (Failure (if trace then [] + else [CM_Class_type_mismatch (env, cty1, cty2)])) + with + Failure error when trace -> + raise (Failure (CM_Class_type_mismatch (env, cty1, cty2)::error)) -let super_report_unification_error ppf env ?(unif=true) - tr txt1 txt2 = - wrap_printing_env env (fun () -> super_unification_error unif tr txt1 ppf txt2) -;; +let match_class_declarations env patt_params patt_type subj_params subj_type = + let type_pairs = TypePairs.create 53 in + let subst = ref [] in + let sign1 = signature_of_class_type patt_type in + let sign2 = signature_of_class_type subj_type in + let t1 = repr sign1.csig_self in + let t2 = repr sign2.csig_self in + TypePairs.add type_pairs (t1, t2) (); + let (fields1, rest1) = flatten_fields (object_fields t1) + and (fields2, rest2) = flatten_fields (object_fields t2) in + let (pairs, miss1, miss2) = associate_fields fields1 fields2 in + let error = + List.fold_right + (fun (lab, k, _) err -> + let err = + let k = field_kind_repr k in + begin match k with + Fvar _ -> err + | _ -> CM_Hide_public lab::err + end + in + if Concr.mem lab sign1.csig_concr then err + else CM_Hide_virtual ("method", lab) :: err) + miss1 [] + in + let missing_method = List.map (fun (m, _, _) -> m) miss2 in + let error = + (List.map (fun m -> CM_Missing_method m) missing_method) @ error + in + (* Always succeeds *) + eqtype true type_pairs subst env rest1 rest2; + let error = + List.fold_right + (fun (lab, k1, _t1, k2, _t2) err -> + let k1 = field_kind_repr k1 in + let k2 = field_kind_repr k2 in + match k1, k2 with + (Fvar _, Fvar _) + | (Fpresent, Fpresent) -> err + | (Fvar _, Fpresent) -> CM_Private_method lab::err + | (Fpresent, Fvar _) -> CM_Public_method lab::err + | _ -> assert false) + pairs error + in + let error = + Vars.fold + (fun lab (mut, vr, _ty) err -> + try + let (mut', vr', _ty') = Vars.find lab sign1.csig_vars in + if mut = Mutable && mut' <> Mutable then + CM_Non_mutable_value lab::err + else if vr = Concrete && vr' <> Concrete then + CM_Non_concrete_value lab::err + else + err + with Not_found -> + CM_Missing_value lab::err) + sign2.csig_vars error + in + let error = + Vars.fold + (fun lab (_,vr,_) err -> + if vr = Virtual && not (Vars.mem lab sign2.csig_vars) then + CM_Hide_virtual ("instance variable", lab) :: err + else err) + sign1.csig_vars error + in + let error = + List.fold_right + (fun e l -> + if List.mem e missing_method then l else CM_Virtual_method e::l) + (Concr.elements (Concr.diff sign2.csig_concr sign1.csig_concr)) + error + in + match error with + [] -> + begin try + let lp = List.length patt_params in + let ls = List.length subj_params in + if lp <> ls then + raise (Failure [CM_Parameter_arity_mismatch (lp, ls)]); + List.iter2 (fun p s -> + try eqtype true type_pairs subst env p s with Unify trace -> + raise (Failure [CM_Type_parameter_mismatch + (env, expand_trace env trace)])) + patt_params subj_params; + (* old code: equal_clty false type_pairs subst env patt_type subj_type; *) + equal_clty false type_pairs subst env + (Cty_signature sign1) (Cty_signature sign2); + (* Use moregeneral for class parameters, need to recheck everything to + keeps relationships (PR#4824) *) + let clty_params = + List.fold_right (fun ty cty -> Cty_arrow (Labelled "*",ty,cty)) in + match_class_types ~trace:false env + (clty_params patt_params patt_type) + (clty_params subj_params subj_type) + with + Failure r -> r + end + | error -> + error -let trace fst keep_last txt ppf tr = - print_labels := not !Clflags.classic; - trace_same_names tr; - try match tr with - t1 :: t2 :: tr' -> - if fst then trace fst txt ppf (t1 :: t2 :: filter_trace keep_last tr') - else trace fst txt ppf (filter_trace keep_last tr); - print_labels := true - | _ -> () - with exn -> - print_labels := true; - raise exn + (***************) + (* Subtyping *) + (***************) -let report_subtyping_error ppf env tr1 txt1 tr2 = - wrap_printing_env env (fun () -> - reset (); - let tr1 = List.map prepare_expansion tr1 - and tr2 = List.map prepare_expansion tr2 in - fprintf ppf "@[%a" (trace true (tr2 = []) txt1) tr1; - if tr2 = [] then fprintf ppf "@]" else - let mis = mismatch tr2 in - fprintf ppf "%a%t@]" - (trace false (mis = None) "is not compatible with type") tr2 - (explanation true mis)) -let report_ambiguous_type_error ppf env (tp0, tp0') tpl txt1 txt2 txt3 = - wrap_printing_env env (fun () -> - reset (); - List.iter - (fun (tp, tp') -> path_same_name tp0 tp; path_same_name tp0' tp') - tpl; - match tpl with - [] -> assert false - | [tp, tp'] -> - fprintf ppf - "@[%t@;<1 2>%a@ \ - %t@;<1 2>%a\ - @]" - txt1 (type_path_expansion tp) tp' - txt3 (type_path_expansion tp0) tp0' - | _ -> - fprintf ppf - "@[%t@;<1 2>@[%a@]\ - @ %t@;<1 2>%a\ - @]" - txt2 type_path_list tpl - txt3 (type_path_expansion tp0) tp0') +(**** Build a subtype of a given type. ****) -end -module Includeclass : sig -#1 "includeclass.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Jerome Vouillon, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1997 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +(* build_subtype: + [visited] traces traversed object and variant types + [loops] is a mapping from variables to variables, to reproduce + positive loops in a class type + [posi] true if the current variance is positive + [level] number of expansions/enlargement allowed on this branch *) -(* Inclusion checks for the class language *) +let warn = ref false (* whether double coercion might do better *) +let pred_expand n = if n mod 2 = 0 && n > 0 then pred n else n +let pred_enlarge n = if n mod 2 = 1 then pred n else n -open Types -open Ctype -open Format +type change = Unchanged | Equiv | Changed +let collect l = List.fold_left (fun c1 (_, c2) -> max c1 c2) Unchanged l -val class_types: - Env.t -> class_type -> class_type -> class_match_failure list -val class_type_declarations: - loc:Location.t -> - Env.t -> class_type_declaration -> class_type_declaration -> - class_match_failure list -val class_declarations: - Env.t -> class_declaration -> class_declaration -> - class_match_failure list +let rec filter_visited = function + [] -> [] + | {desc=Tobject _|Tvariant _} :: _ as l -> l + | _ :: l -> filter_visited l -val report_error: formatter -> class_match_failure list -> unit +let memq_warn t visited = + if List.memq t visited then (warn := true; true) else false -end = struct -#1 "includeclass.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Jerome Vouillon, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1997 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let rec lid_of_path ?(hash="") = function + Path.Pident id -> + Longident.Lident (hash ^ Ident.name id) + | Path.Pdot (p1, s, _) -> + Longident.Ldot (lid_of_path p1, hash ^ s) + | Path.Papply (p1, p2) -> + Longident.Lapply (lid_of_path ~hash p1, lid_of_path p2) -(* Inclusion checks for the class language *) +let find_cltype_for_path env p = + let cl_path = Env.lookup_type (lid_of_path ~hash:"#" p) env in + let cl_abbr = Env.find_type cl_path env in -open Types + match cl_abbr.type_manifest with + Some ty -> + begin match (repr ty).desc with + Tobject(_,{contents=Some(p',_)}) when Path.same p p' -> cl_abbr, ty + | _ -> raise Not_found + end + | None -> assert false -let class_types env cty1 cty2 = - Ctype.match_class_types env cty1 cty2 +let has_constr_row' env t = + has_constr_row (expand_abbrev env t) -let class_type_declarations ~loc env cty1 cty2 = - Builtin_attributes.check_deprecated_inclusion - ~def:cty1.clty_loc - ~use:cty2.clty_loc - loc - cty1.clty_attributes cty2.clty_attributes - (Path.last cty1.clty_path); - Ctype.match_class_declarations env - cty1.clty_params cty1.clty_type - cty2.clty_params cty2.clty_type +let rec build_subtype env visited loops posi level t = + let t = repr t in + match t.desc with + Tvar _ -> + if posi then + try + let t' = List.assq t loops in + warn := true; + (t', Equiv) + with Not_found -> + (t, Unchanged) + else + (t, Unchanged) + | Tarrow(l, t1, t2, _) -> + if memq_warn t visited then (t, Unchanged) else + let visited = t :: visited in + let (t1', c1) = build_subtype env visited loops (not posi) level t1 in + let (t2', c2) = build_subtype env visited loops posi level t2 in + let c = max c1 c2 in + if c > Unchanged then (newty (Tarrow(l, t1', t2', Cok)), c) + else (t, Unchanged) + | Ttuple tlist -> + if memq_warn t visited then (t, Unchanged) else + let visited = t :: visited in + let tlist' = + List.map (build_subtype env visited loops posi level) tlist + in + let c = collect tlist' in + if c > Unchanged then (newty (Ttuple (List.map fst tlist')), c) + else (t, Unchanged) + | Tconstr(p, tl, abbrev) + when level > 0 && generic_abbrev env p && safe_abbrev env t + && not (has_constr_row' env t) -> + let t' = repr (expand_abbrev env t) in + let level' = pred_expand level in + begin try match t'.desc with + Tobject _ when posi && not (opened_object t') -> + let cl_abbr, body = find_cltype_for_path env p in + let ty = + subst env !current_level Public abbrev None + cl_abbr.type_params tl body in + let ty = repr ty in + let ty1, tl1 = + match ty.desc with + Tobject(ty1,{contents=Some(p',tl1)}) when Path.same p p' -> + ty1, tl1 + | _ -> raise Not_found + in + (* Fix PR#4505: do not set ty to Tvar when it appears in tl1, + as this occurrence might break the occur check. + XXX not clear whether this correct anyway... *) + if List.exists (deep_occur ty) tl1 then raise Not_found; + ty.desc <- Tvar None; + let t'' = newvar () in + let loops = (ty, t'') :: loops in + (* May discard [visited] as level is going down *) + let (ty1', c) = + build_subtype env [t'] loops posi (pred_enlarge level') ty1 in + assert (is_Tvar t''); + let nm = + if c > Equiv || deep_occur ty ty1' then None else Some(p,tl1) in + t''.desc <- Tobject (ty1', ref nm); + (try unify_var env ty t with Unify _ -> assert false); + (t'', Changed) + | _ -> raise Not_found + with Not_found -> + let (t'',c) = build_subtype env visited loops posi level' t' in + if c > Unchanged then (t'',c) + else (t, Unchanged) + end + | Tconstr(p, tl, _abbrev) -> + (* Must check recursion on constructors, since we do not always + expand them *) + if memq_warn t visited then (t, Unchanged) else + let visited = t :: visited in + begin try + let decl = Env.find_type p env in + if level = 0 && generic_abbrev env p && safe_abbrev env t + && not (has_constr_row' env t) + then warn := true; + let tl' = + List.map2 + (fun v t -> + let (co,cn) = Variance.get_upper v in + if cn then + if co then (t, Unchanged) + else build_subtype env visited loops (not posi) level t + else + if co then build_subtype env visited loops posi level t + else (newvar(), Changed)) + decl.type_variance tl + in + let c = collect tl' in + if c > Unchanged then (newconstr p (List.map fst tl'), c) + else (t, Unchanged) + with Not_found -> + (t, Unchanged) + end + | Tvariant row -> + let row = row_repr row in + if memq_warn t visited || not (static_row row) then (t, Unchanged) else + let level' = pred_enlarge level in + let visited = + t :: if level' < level then [] else filter_visited visited in + let fields = filter_row_fields false row.row_fields in + let fields = + List.map + (fun (l,f as orig) -> match row_field_repr f with + Rpresent None -> + if posi then + (l, Reither(true, [], false, ref None)), Unchanged + else + orig, Unchanged + | Rpresent(Some t) -> + let (t', c) = build_subtype env visited loops posi level' t in + let f = + if posi && level > 0 + then Reither(false, [t'], false, ref None) + else Rpresent(Some t') + in (l, f), c + | _ -> assert false) + fields + in + let c = collect fields in + let row = + { row_fields = List.map fst fields; row_more = newvar(); + row_bound = (); row_closed = posi; row_fixed = false; + row_name = if c > Unchanged then None else row.row_name } + in + (newty (Tvariant row), Changed) + | Tobject (t1, _) -> + if memq_warn t visited || opened_object t1 then (t, Unchanged) else + let level' = pred_enlarge level in + let visited = + t :: if level' < level then [] else filter_visited visited in + let (t1', c) = build_subtype env visited loops posi level' t1 in + if c > Unchanged then (newty (Tobject (t1', ref None)), c) + else (t, Unchanged) + | Tfield(s, _, t1, t2) (* Always present *) -> + let (t1', c1) = build_subtype env visited loops posi level t1 in + let (t2', c2) = build_subtype env visited loops posi level t2 in + let c = max c1 c2 in + if c > Unchanged then (newty (Tfield(s, Fpresent, t1', t2')), c) + else (t, Unchanged) + | Tnil -> + if posi then + let v = newvar () in + (v, Changed) + else begin + warn := true; + (t, Unchanged) + end + | Tsubst _ | Tlink _ -> + assert false + | Tpoly(t1, tl) -> + let (t1', c) = build_subtype env visited loops posi level t1 in + if c > Unchanged then (newty (Tpoly(t1', tl)), c) + else (t, Unchanged) + | Tunivar _ | Tpackage _ -> + (t, Unchanged) -let class_declarations env cty1 cty2 = - match cty1.cty_new, cty2.cty_new with - None, Some _ -> - [Ctype.CM_Virtual_class] - | _ -> - Ctype.match_class_declarations env - cty1.cty_params cty1.cty_type - cty2.cty_params cty2.cty_type +let enlarge_type env ty = + warn := false; + (* [level = 4] allows 2 expansions involving objects/variants *) + let (ty', _) = build_subtype env [] [] true 4 ty in + (ty', !warn) -open Format -open Ctype +(**** Check whether a type is a subtype of another type. ****) (* -let rec hide_params = function - Tcty_arrow ("*", _, cty) -> hide_params cty - | cty -> cty + During the traversal, a trace of visited types is maintained. It + is printed in case of error. + Constraints (pairs of types that must be equals) are accumulated + rather than being enforced straight. Indeed, the result would + otherwise depend on the order in which these constraints are + enforced. + A function enforcing these constraints is returned. That way, type + variables can be bound to their actual values before this function + is called (see Typecore). + Only well-defined abbreviations are expanded (hence the tests + [generic_abbrev ...]). *) -let include_err ppf = - function - | CM_Virtual_class -> - fprintf ppf "A class cannot be changed from virtual to concrete" - | CM_Parameter_arity_mismatch _ -> - fprintf ppf - "The classes do not have the same number of type parameters" - | CM_Type_parameter_mismatch (env, trace) -> - Printtyp.report_unification_error ppf env ~unif:false trace - (function ppf -> - fprintf ppf "A type parameter has type") - (function ppf -> - fprintf ppf "but is expected to have type") - | CM_Class_type_mismatch (env, cty1, cty2) -> - Printtyp.wrap_printing_env env (fun () -> - fprintf ppf - "@[The class type@;<1 2>%a@ %s@;<1 2>%a@]" - Printtyp.class_type cty1 - "is not matched by the class type" - Printtyp.class_type cty2) - | CM_Parameter_mismatch (env, trace) -> - Printtyp.report_unification_error ppf env ~unif:false trace - (function ppf -> - fprintf ppf "A parameter has type") - (function ppf -> - fprintf ppf "but is expected to have type") - | CM_Val_type_mismatch (lab, env, trace) -> - Printtyp.report_unification_error ppf env ~unif:false trace - (function ppf -> - fprintf ppf "The instance variable %s@ has type" lab) - (function ppf -> - fprintf ppf "but is expected to have type") - | CM_Meth_type_mismatch (lab, env, trace) -> - Printtyp.report_unification_error ppf env ~unif:false trace - (function ppf -> - fprintf ppf "The method %s@ has type" lab) - (function ppf -> - fprintf ppf "but is expected to have type") - | CM_Non_mutable_value lab -> - fprintf ppf - "@[The non-mutable instance variable %s cannot become mutable@]" lab - | CM_Non_concrete_value lab -> - fprintf ppf - "@[The virtual instance variable %s cannot become concrete@]" lab - | CM_Missing_value lab -> - fprintf ppf "@[The first class type has no instance variable %s@]" lab - | CM_Missing_method lab -> - fprintf ppf "@[The first class type has no method %s@]" lab - | CM_Hide_public lab -> - fprintf ppf "@[The public method %s cannot be hidden@]" lab - | CM_Hide_virtual (k, lab) -> - fprintf ppf "@[The virtual %s %s cannot be hidden@]" k lab - | CM_Public_method lab -> - fprintf ppf "@[The public method %s cannot become private" lab - | CM_Virtual_method lab -> - fprintf ppf "@[The virtual method %s cannot become concrete" lab - | CM_Private_method lab -> - fprintf ppf "The private method %s cannot become public" lab +let subtypes = TypePairs.create 17 -let report_error ppf = function - | [] -> () - | err :: errs -> - let print_errs ppf errs = - List.iter (fun err -> fprintf ppf "@ %a" include_err err) errs in - fprintf ppf "@[%a%a@]" include_err err print_errs errs +let subtype_error env trace = + raise (Subtype (expand_trace env (List.rev trace), [])) -end -module Includecore : sig -#1 "includecore.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let rec subtype_rec env trace t1 t2 cstrs = + let t1 = repr t1 in + let t2 = repr t2 in + if t1 == t2 then cstrs else -(* Inclusion checks for the core language *) + begin try + TypePairs.find subtypes (t1, t2); + cstrs + with Not_found -> + TypePairs.add subtypes (t1, t2) (); + match (t1.desc, t2.desc) with + (Tvar _, _) | (_, Tvar _) -> + (trace, t1, t2, !univar_pairs)::cstrs + | (Tarrow(l1, t1, u1, _), Tarrow(l2, t2, u2, _)) when l1 = l2 + || !Clflags.classic && not (is_optional l1 || is_optional l2) -> + let cstrs = subtype_rec env ((t2, t1)::trace) t2 t1 cstrs in + subtype_rec env ((u1, u2)::trace) u1 u2 cstrs + | (Ttuple tl1, Ttuple tl2) -> + subtype_list env trace tl1 tl2 cstrs + | (Tconstr(p1, [], _), Tconstr(p2, [], _)) when Path.same p1 p2 -> + cstrs + | (Tconstr(p1, _tl1, _abbrev1), _) + when generic_abbrev env p1 && safe_abbrev env t1 -> + subtype_rec env trace (expand_abbrev env t1) t2 cstrs + | (_, Tconstr(p2, _tl2, _abbrev2)) + when generic_abbrev env p2 && safe_abbrev env t2 -> + subtype_rec env trace t1 (expand_abbrev env t2) cstrs + | (Tconstr(p1, tl1, _), Tconstr(p2, tl2, _)) when Path.same p1 p2 -> + begin try + let decl = Env.find_type p1 env in + List.fold_left2 + (fun cstrs v (t1, t2) -> + let (co, cn) = Variance.get_upper v in + if co then + if cn then + (trace, newty2 t1.level (Ttuple[t1]), + newty2 t2.level (Ttuple[t2]), !univar_pairs) :: cstrs + else subtype_rec env ((t1, t2)::trace) t1 t2 cstrs + else + if cn then subtype_rec env ((t2, t1)::trace) t2 t1 cstrs + else cstrs) + cstrs decl.type_variance (List.combine tl1 tl2) + with Not_found -> + (trace, t1, t2, !univar_pairs)::cstrs + end + | (Tconstr(p1, _, _), _) when generic_private_abbrev env p1 -> + subtype_rec env trace (expand_abbrev_opt env t1) t2 cstrs +(* | (_, Tconstr(p2, _, _)) when generic_private_abbrev false env p2 -> + subtype_rec env trace t1 (expand_abbrev_opt env t2) cstrs *) + | (Tobject (f1, _), Tobject (f2, _)) + when is_Tvar (object_row f1) && is_Tvar (object_row f2) -> + (* Same row variable implies same object. *) + (trace, t1, t2, !univar_pairs)::cstrs + | (Tobject (f1, _), Tobject (f2, _)) -> + subtype_fields env trace f1 f2 cstrs + | (Tvariant row1, Tvariant row2) -> + begin try + subtype_row env trace row1 row2 cstrs + with Exit -> + (trace, t1, t2, !univar_pairs)::cstrs + end + | (Tpoly (u1, []), Tpoly (u2, [])) -> + subtype_rec env trace u1 u2 cstrs + | (Tpoly (u1, tl1), Tpoly (u2, [])) -> + let _, u1' = instance_poly false tl1 u1 in + subtype_rec env trace u1' u2 cstrs + | (Tpoly (u1, tl1), Tpoly (u2,tl2)) -> + begin try + enter_poly env univar_pairs u1 tl1 u2 tl2 + (fun t1 t2 -> subtype_rec env trace t1 t2 cstrs) + with Unify _ -> + (trace, t1, t2, !univar_pairs)::cstrs + end + | (Tpackage (p1, nl1, tl1), Tpackage (p2, nl2, tl2)) -> + begin try + let ntl1 = complete_type_list env nl2 t1.level (Mty_ident p1) nl1 tl1 + and ntl2 = complete_type_list env nl1 t2.level (Mty_ident p2) nl2 tl2 + ~allow_absent:true in + let cstrs' = + List.map + (fun (n2,t2) -> (trace, List.assoc n2 ntl1, t2, !univar_pairs)) + ntl2 + in + if eq_package_path env p1 p2 then cstrs' @ cstrs + else begin + (* need to check module subtyping *) + let snap = Btype.snapshot () in + try + List.iter (fun (_, t1, t2, _) -> unify env t1 t2) cstrs'; + if !package_subtype env p1 nl1 tl1 p2 nl2 tl2 + then (Btype.backtrack snap; cstrs' @ cstrs) + else raise (Unify []) + with Unify _ -> + Btype.backtrack snap; raise Not_found + end + with Not_found -> + (trace, t1, t2, !univar_pairs)::cstrs + end + | (_, _) -> + (trace, t1, t2, !univar_pairs)::cstrs + end -open Typedtree -open Types +and subtype_list env trace tl1 tl2 cstrs = + if List.length tl1 <> List.length tl2 then + subtype_error env trace; + List.fold_left2 + (fun cstrs t1 t2 -> subtype_rec env ((t1, t2)::trace) t1 t2 cstrs) + cstrs tl1 tl2 -exception Dont_match +and subtype_fields env trace ty1 ty2 cstrs = + (* Assume that either rest1 or rest2 is not Tvar *) + let (fields1, rest1) = flatten_fields ty1 in + let (fields2, rest2) = flatten_fields ty2 in + let (pairs, miss1, miss2) = associate_fields fields1 fields2 in + let cstrs = + if rest2.desc = Tnil then cstrs else + if miss1 = [] then + subtype_rec env ((rest1, rest2)::trace) rest1 rest2 cstrs + else + (trace, build_fields (repr ty1).level miss1 rest1, rest2, + !univar_pairs) :: cstrs + in + let cstrs = + if miss2 = [] then cstrs else + (trace, rest1, build_fields (repr ty2).level miss2 (newvar ()), + !univar_pairs) :: cstrs + in + List.fold_left + (fun cstrs (_, _k1, t1, _k2, t2) -> + (* These fields are always present *) + subtype_rec env ((t1, t2)::trace) t1 t2 cstrs) + cstrs pairs -type type_mismatch = - Arity - | Privacy - | Kind - | Constraint - | Manifest - | Variance - | Field_type of Ident.t - | Field_mutable of Ident.t - | Field_arity of Ident.t - | Field_names of int * Ident.t * Ident.t - | Field_missing of bool * Ident.t - | Record_representation of bool - | Unboxed_representation of bool - | Immediate +and subtype_row env trace row1 row2 cstrs = + let row1 = row_repr row1 and row2 = row_repr row2 in + let r1, r2, pairs = + merge_row_fields row1.row_fields row2.row_fields in + let more1 = repr row1.row_more + and more2 = repr row2.row_more in + match more1.desc, more2.desc with + Tconstr(p1,_,_), Tconstr(p2,_,_) when Path.same p1 p2 -> + subtype_rec env ((more1,more2)::trace) more1 more2 cstrs + | (Tvar _|Tconstr _|Tnil), (Tvar _|Tconstr _|Tnil) + when row1.row_closed && r1 = [] -> + List.fold_left + (fun cstrs (_,f1,f2) -> + match row_field_repr f1, row_field_repr f2 with + (Rpresent None|Reither(true,_,_,_)), Rpresent None -> + cstrs + | Rpresent(Some t1), Rpresent(Some t2) -> + subtype_rec env ((t1, t2)::trace) t1 t2 cstrs + | Reither(false, t1::_, _, _), Rpresent(Some t2) -> + subtype_rec env ((t1, t2)::trace) t1 t2 cstrs + | Rabsent, _ -> cstrs + | _ -> raise Exit) + cstrs pairs + | Tunivar _, Tunivar _ + when row1.row_closed = row2.row_closed && r1 = [] && r2 = [] -> + let cstrs = + subtype_rec env ((more1,more2)::trace) more1 more2 cstrs in + List.fold_left + (fun cstrs (_,f1,f2) -> + match row_field_repr f1, row_field_repr f2 with + Rpresent None, Rpresent None + | Reither(true,[],_,_), Reither(true,[],_,_) + | Rabsent, Rabsent -> + cstrs + | Rpresent(Some t1), Rpresent(Some t2) + | Reither(false,[t1],_,_), Reither(false,[t2],_,_) -> + subtype_rec env ((t1, t2)::trace) t1 t2 cstrs + | _ -> raise Exit) + cstrs pairs + | _ -> + raise Exit -val value_descriptions: - loc:Location.t -> Env.t -> Ident.t -> - value_description -> value_description -> module_coercion +let subtype env ty1 ty2 = + TypePairs.clear subtypes; + univar_pairs := []; + (* Build constraint set. *) + let cstrs = subtype_rec env [(ty1, ty2)] ty1 ty2 [] in + TypePairs.clear subtypes; + (* Enforce constraints. *) + function () -> + List.iter + (function (trace0, t1, t2, pairs) -> + try unify_pairs (ref env) t1 t2 pairs with Unify trace -> + raise (Subtype (expand_trace env (List.rev trace0), + List.tl (List.tl trace)))) + (List.rev cstrs) -val type_declarations: - ?equality:bool -> - loc:Location.t -> - Env.t -> string -> - type_declaration -> Ident.t -> type_declaration -> type_mismatch list + (*******************) + (* Miscellaneous *) + (*******************) -val extension_constructors: - loc:Location.t -> - Env.t -> Ident.t -> - extension_constructor -> extension_constructor -> bool -(* -val class_types: - Env.t -> class_type -> class_type -> bool -*) +(* Utility for printing. The resulting type is not used in computation. *) +let rec unalias_object ty = + let ty = repr ty in + match ty.desc with + Tfield (s, k, t1, t2) -> + newty2 ty.level (Tfield (s, k, t1, unalias_object t2)) + | Tvar _ | Tnil -> + newty2 ty.level ty.desc + | Tunivar _ -> + ty + | Tconstr _ -> + newvar2 ty.level + | _ -> + assert false -val report_type_mismatch: - string -> string -> string -> Format.formatter -> type_mismatch list -> unit +let unalias ty = + let ty = repr ty in + match ty.desc with + Tvar _ | Tunivar _ -> + ty + | Tvariant row -> + let row = row_repr row in + let more = row.row_more in + newty2 ty.level + (Tvariant {row with row_more = newty2 more.level more.desc}) + | Tobject (ty, nm) -> + newty2 ty.level (Tobject (unalias_object ty, nm)) + | _ -> + newty2 ty.level ty.desc -end = struct -#1 "includecore.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +(* Return the arity (as for curried functions) of the given type. *) +let rec arity ty = + match (repr ty).desc with + Tarrow(_, _t1, t2, _) -> 1 + arity t2 + | _ -> 0 -(* Inclusion checks for the core language *) +(* Check whether an abbreviation expands to itself. *) +let cyclic_abbrev env id ty = + let rec check_cycle seen ty = + let ty = repr ty in + match ty.desc with + Tconstr (p, _tl, _abbrev) -> + p = Path.Pident id || List.memq ty seen || + begin try + check_cycle (ty :: seen) (expand_abbrev_opt env ty) + with + Cannot_expand -> false + | Unify _ -> true + end + | _ -> + false + in check_cycle [] ty -open Asttypes -open Path -open Types -open Typedtree +(* Check for non-generalizable type variables *) +exception Non_closed0 +let visited = ref TypeSet.empty -(* Inclusion between value descriptions *) +let rec closed_schema_rec env ty = + let ty = repr ty in + if TypeSet.mem ty !visited then () else begin + visited := TypeSet.add ty !visited; + match ty.desc with + Tvar _ when ty.level <> generic_level -> + raise Non_closed0 + | Tconstr _ -> + let old = !visited in + begin try iter_type_expr (closed_schema_rec env) ty + with Non_closed0 -> try + visited := old; + closed_schema_rec env (try_expand_head try_expand_safe env ty) + with Cannot_expand -> + raise Non_closed0 + end + | Tfield(_, kind, t1, t2) -> + if field_kind_repr kind = Fpresent then + closed_schema_rec env t1; + closed_schema_rec env t2 + | Tvariant row -> + let row = row_repr row in + iter_row (closed_schema_rec env) row; + if not (static_row row) then closed_schema_rec env row.row_more + | _ -> + iter_type_expr (closed_schema_rec env) ty + end -exception Dont_match +(* Return whether all variables of type [ty] are generic. *) +let closed_schema env ty = + visited := TypeSet.empty; + try + closed_schema_rec env ty; + visited := TypeSet.empty; + true + with Non_closed0 -> + visited := TypeSet.empty; + false -let value_descriptions ~loc env name - (vd1 : Types.value_description) - (vd2 : Types.value_description) = - Builtin_attributes.check_deprecated_inclusion - ~def:vd1.val_loc - ~use:vd2.val_loc - loc - vd1.val_attributes vd2.val_attributes +(* Normalize a type before printing, saving... *) +(* Cannot use mark_type because deep_occur uses it too *) +let rec normalize_type_rec env visited ty = + let ty = repr ty in + if not (TypeSet.mem ty !visited) then begin + visited := TypeSet.add ty !visited; + let tm = row_of_type ty in + begin if not (is_Tconstr ty) && is_constr_row ~allow_ident:false tm then + match tm.desc with (* PR#7348 *) + Tconstr (Path.Pdot(m,i,pos), tl, _abbrev) -> + let i' = String.sub i 0 (String.length i - 4) in + log_type ty; + ty.desc <- Tconstr(Path.Pdot(m,i',pos), tl, ref Mnil) + | _ -> assert false + else match ty.desc with + | Tvariant row -> + let row = row_repr row in + let fields = List.map + (fun (l,f0) -> + let f = row_field_repr f0 in l, + match f with Reither(b, ty::(_::_ as tyl), m, e) -> + let tyl' = + List.fold_left + (fun tyl ty -> + if List.exists (fun ty' -> equal env false [ty] [ty']) tyl + then tyl else ty::tyl) + [ty] tyl + in + if f != f0 || List.length tyl' < List.length tyl then + Reither(b, List.rev tyl', m, e) + else f + | _ -> f) + row.row_fields in + let fields = + List.sort (fun (p,_) (q,_) -> compare p q) + (List.filter (fun (_,fi) -> fi <> Rabsent) fields) in + log_type ty; + ty.desc <- Tvariant {row with row_fields = fields} + | Tobject (fi, nm) -> + begin match !nm with + | None -> () + | Some (n, v :: l) -> + if deep_occur ty (newgenty (Ttuple l)) then + (* The abbreviation may be hiding something, so remove it *) + set_name nm None + else let v' = repr v in + begin match v'.desc with + | Tvar _ | Tunivar _ -> + if v' != v then set_name nm (Some (n, v' :: l)) + | Tnil -> + log_type ty; ty.desc <- Tconstr (n, l, ref Mnil) + | _ -> set_name nm None + end + | _ -> + fatal_error "Ctype.normalize_type_rec" + end; + let fi = repr fi in + if fi.level < lowest_level then () else + let fields, row = flatten_fields fi in + let fi' = build_fields fi.level fields row in + log_type ty; fi.desc <- fi'.desc + | _ -> () + end; + iter_type_expr (normalize_type_rec env visited) ty + end - (Ident.name name); - - if Ctype.moregeneral env true vd1.val_type vd2.val_type then begin - match (vd1.val_kind, vd2.val_kind) with - (Val_prim p1, Val_prim p2) -> - if p1 = p2 then Tcoerce_none else raise Dont_match - | (Val_prim p, _) -> - let pc = {pc_desc = p; pc_type = vd2.Types.val_type; - pc_env = env; pc_loc = vd1.Types.val_loc; +let normalize_type env ty = + normalize_type_rec env (ref TypeSet.empty) ty - pc_id = name; - } in - Tcoerce_primitive pc - | (_, Val_prim _) -> raise Dont_match - | (_, _) -> Tcoerce_none - end else - raise Dont_match + (*************************) + (* Remove dependencies *) + (*************************) -(* Inclusion between "private" annotations *) -let private_flags decl1 decl2 = - match decl1.type_private, decl2.type_private with - | Private, Public -> - decl2.type_kind = Type_abstract && - (decl2.type_manifest = None || decl1.type_kind <> Type_abstract) - | _, _ -> true +(* + Variables are left unchanged. Other type nodes are duplicated, with + levels set to generic level. + We cannot use Tsubst here, because unification may be called by + expand_abbrev. +*) -(* Inclusion between manifest types (particularly for private row types) *) +let nondep_hash = TypeHash.create 47 +let nondep_variants = TypeHash.create 17 +let clear_hash () = + TypeHash.clear nondep_hash; TypeHash.clear nondep_variants -let is_absrow env ty = +let rec nondep_type_rec env id ty = match ty.desc with - Tconstr(Pident _, _, _) -> - begin match Ctype.expand_head env ty with - {desc=Tobject _|Tvariant _} -> true - | _ -> false - end - | _ -> false - -let type_manifest env ty1 params1 ty2 params2 priv2 = - let ty1' = Ctype.expand_head env ty1 and ty2' = Ctype.expand_head env ty2 in - match ty1'.desc, ty2'.desc with - Tvariant row1, Tvariant row2 when is_absrow env (Btype.row_more row2) -> - let row1 = Btype.row_repr row1 and row2 = Btype.row_repr row2 in - Ctype.equal env true (ty1::params1) (row2.row_more::params2) && - begin match row1.row_more with - {desc=Tvar _|Tconstr _|Tnil} -> true - | _ -> false - end && - let r1, r2, pairs = - Ctype.merge_row_fields row1.row_fields row2.row_fields in - (not row2.row_closed || - row1.row_closed && Ctype.filter_row_fields false r1 = []) && - List.for_all - (fun (_,f) -> match Btype.row_field_repr f with - Rabsent | Reither _ -> true | Rpresent _ -> false) - r2 && - let to_equal = ref (List.combine params1 params2) in - List.for_all - (fun (_, f1, f2) -> - match Btype.row_field_repr f1, Btype.row_field_repr f2 with - Rpresent(Some t1), - (Rpresent(Some t2) | Reither(false, [t2], _, _)) -> - to_equal := (t1,t2) :: !to_equal; true - | Rpresent None, (Rpresent None | Reither(true, [], _, _)) -> true - | Reither(c1,tl1,_,_), Reither(c2,tl2,_,_) - when List.length tl1 = List.length tl2 && c1 = c2 -> - to_equal := List.combine tl1 tl2 @ !to_equal; true - | Rabsent, (Reither _ | Rabsent) -> true - | _ -> false) - pairs && - let tl1, tl2 = List.split !to_equal in - Ctype.equal env true tl1 tl2 - | Tobject (fi1, _), Tobject (fi2, _) - when is_absrow env (snd(Ctype.flatten_fields fi2)) -> - let (fields2,rest2) = Ctype.flatten_fields fi2 in - Ctype.equal env true (ty1::params1) (rest2::params2) && - let (fields1,rest1) = Ctype.flatten_fields fi1 in - (match rest1 with {desc=Tnil|Tvar _|Tconstr _} -> true | _ -> false) && - let pairs, _miss1, miss2 = Ctype.associate_fields fields1 fields2 in - miss2 = [] && - let tl1, tl2 = - List.split (List.map (fun (_,_,t1,_,t2) -> t1, t2) pairs) in - Ctype.equal env true (params1 @ tl1) (params2 @ tl2) - | _ -> - let rec check_super ty1 = - Ctype.equal env true (ty1 :: params1) (ty2 :: params2) || - priv2 = Private && - try check_super - (Ctype.try_expand_once_opt env (Ctype.expand_head env ty1)) - with Ctype.Cannot_expand -> false - in check_super ty1 - -(* Inclusion between type declarations *) + Tvar _ | Tunivar _ -> ty + | Tlink ty -> nondep_type_rec env id ty + | _ -> try TypeHash.find nondep_hash ty + with Not_found -> + let ty' = newgenvar () in (* Stub *) + TypeHash.add nondep_hash ty ty'; + ty'.desc <- + begin match ty.desc with + | Tconstr(p, tl, _abbrev) -> + if Path.isfree id p then + begin try + Tlink (nondep_type_rec env id + (expand_abbrev env (newty2 ty.level ty.desc))) + (* + The [Tlink] is important. The expanded type may be a + variable, or may not be completely copied yet + (recursive type), so one cannot just take its + description. + *) + with Cannot_expand | Unify _ -> + raise Not_found + end + else + Tconstr(p, List.map (nondep_type_rec env id) tl, ref Mnil) + | Tpackage(p, nl, tl) when Path.isfree id p -> + let p' = normalize_package_path env p in + if Path.isfree id p' then raise Not_found; + Tpackage (p', nl, List.map (nondep_type_rec env id) tl) + | Tobject (t1, name) -> + Tobject (nondep_type_rec env id t1, + ref (match !name with + None -> None + | Some (p, tl) -> + if Path.isfree id p then None + else Some (p, List.map (nondep_type_rec env id) tl))) + | Tvariant row -> + let row = row_repr row in + let more = repr row.row_more in + (* We must keep sharing according to the row variable *) + begin try + let ty2 = TypeHash.find nondep_variants more in + (* This variant type has been already copied *) + TypeHash.add nondep_hash ty ty2; + Tlink ty2 + with Not_found -> + (* Register new type first for recursion *) + TypeHash.add nondep_variants more ty'; + let static = static_row row in + let more' = if static then newgenty Tnil else more in + (* Return a new copy *) + let row = + copy_row (nondep_type_rec env id) true row true more' in + match row.row_name with + Some (p, _tl) when Path.isfree id p -> + Tvariant {row with row_name = None} + | _ -> Tvariant row + end + | _ -> copy_type_desc (nondep_type_rec env id) ty.desc + end; + ty' -type type_mismatch = - Arity - | Privacy - | Kind - | Constraint - | Manifest - | Variance - | Field_type of Ident.t - | Field_mutable of Ident.t - | Field_arity of Ident.t - | Field_names of int * Ident.t * Ident.t - | Field_missing of bool * Ident.t - | Record_representation of bool (* true means second one is unboxed float *) - | Unboxed_representation of bool (* true means second one is unboxed *) - | Immediate +let nondep_type env id ty = + try + let ty' = nondep_type_rec env id ty in + clear_hash (); + ty' + with Not_found -> + clear_hash (); + raise Not_found -let report_type_mismatch0 first second decl ppf err = - let pr fmt = Format.fprintf ppf fmt in - match err with - Arity -> pr "They have different arities" - | Privacy -> pr "A private type would be revealed" - | Kind -> pr "Their kinds differ" - | Constraint -> pr "Their constraints differ" - | Manifest -> () - | Variance -> pr "Their variances do not agree" - | Field_type s -> - pr "The types for field %s are not equal" (Ident.name s) - | Field_mutable s -> - pr "The mutability of field %s is different" (Ident.name s) - | Field_arity s -> - pr "The arities for field %s differ" (Ident.name s) - | Field_names (n, name1, name2) -> - pr "Fields number %i have different names, %s and %s" - n (Ident.name name1) (Ident.name name2) - | Field_missing (b, s) -> - pr "The field %s is only present in %s %s" - (Ident.name s) (if b then second else first) decl - | Record_representation b -> - pr "Their internal representations differ:@ %s %s %s" - (if b then second else first) decl - "uses unboxed float representation" - | Unboxed_representation b -> - pr "Their internal representations differ:@ %s %s %s" - (if b then second else first) decl - "uses unboxed representation" - | Immediate -> pr "%s is not an immediate type" first +let () = nondep_type' := nondep_type -let report_type_mismatch first second decl ppf = - List.iter - (fun err -> - if err = Manifest then () else - Format.fprintf ppf "@ %a." (report_type_mismatch0 first second decl) err) +let unroll_abbrev id tl ty = + let ty = repr ty and path = Path.Pident id in + if is_Tvar ty || (List.exists (deep_occur ty) tl) + || is_object_type path then + ty + else + let ty' = newty2 ty.level ty.desc in + link_type ty (newty2 ty.level (Tconstr (path, tl, ref Mnil))); + ty' -let rec compare_constructor_arguments ~loc env cstr params1 params2 arg1 arg2 = - match arg1, arg2 with - | Types.Cstr_tuple arg1, Types.Cstr_tuple arg2 -> - if List.length arg1 <> List.length arg2 then [Field_arity cstr] - else if - (* Ctype.equal must be called on all arguments at once, cf. PR#7378 *) - Ctype.equal env true (params1 @ arg1) (params2 @ arg2) - then [] else [Field_type cstr] - | Types.Cstr_record l1, Types.Cstr_record l2 -> - compare_records env ~loc params1 params2 0 l1 l2 - | _ -> [Field_type cstr] +(* Preserve sharing inside type declarations. *) +let nondep_type_decl env mid id is_covariant decl = + try + let params = List.map (nondep_type_rec env mid) decl.type_params in + let tk = + try map_kind (nondep_type_rec env mid) decl.type_kind + with Not_found when is_covariant -> Type_abstract + and tm = + try match decl.type_manifest with + None -> None + | Some ty -> + Some (unroll_abbrev id params (nondep_type_rec env mid ty)) + with Not_found when is_covariant -> + None + in + clear_hash (); + let priv = + match tm with + | Some ty when Btype.has_constr_row ty -> Private + | _ -> decl.type_private + in + { type_params = params; + type_arity = decl.type_arity; + type_kind = tk; + type_manifest = tm; + type_private = priv; + type_variance = decl.type_variance; + type_newtype_level = None; + type_loc = decl.type_loc; + type_attributes = decl.type_attributes; + type_immediate = decl.type_immediate; + type_unboxed = decl.type_unboxed; + } + with Not_found -> + clear_hash (); + raise Not_found -and compare_variants ~loc env params1 params2 n - (cstrs1 : Types.constructor_declaration list) - (cstrs2 : Types.constructor_declaration list) = - match cstrs1, cstrs2 with - [], [] -> [] - | [], c::_ -> [Field_missing (true, c.Types.cd_id)] - | c::_, [] -> [Field_missing (false, c.Types.cd_id)] - | cd1::rem1, cd2::rem2 -> - if Ident.name cd1.cd_id <> Ident.name cd2.cd_id then - [Field_names (n, cd1.cd_id, cd2.cd_id)] - else begin - Builtin_attributes.check_deprecated_inclusion - ~def:cd1.cd_loc - ~use:cd2.cd_loc - loc - cd1.cd_attributes cd2.cd_attributes - (Ident.name cd1.cd_id); - let r = - match cd1.cd_res, cd2.cd_res with - | Some r1, Some r2 -> - if Ctype.equal env true [r1] [r2] then - compare_constructor_arguments ~loc env cd1.cd_id [r1] [r2] - cd1.cd_args cd2.cd_args - else [Field_type cd1.cd_id] - | Some _, None | None, Some _ -> - [Field_type cd1.cd_id] - | _ -> - compare_constructor_arguments ~loc env cd1.cd_id - params1 params2 cd1.cd_args cd2.cd_args +(* Preserve sharing inside extension constructors. *) +let nondep_extension_constructor env mid ext = + try + let type_path, type_params = + if Path.isfree mid ext.ext_type_path then + begin + let ty = + newgenty (Tconstr(ext.ext_type_path, ext.ext_type_params, ref Mnil)) + in + let ty' = nondep_type_rec env mid ty in + match (repr ty').desc with + Tconstr(p, tl, _) -> p, tl + | _ -> raise Not_found + end + else + let type_params = + List.map (nondep_type_rec env mid) ext.ext_type_params in - if r <> [] then r - else compare_variants ~loc env params1 params2 (n+1) rem1 rem2 - end - + ext.ext_type_path, type_params + in + let args = map_type_expr_cstr_args (nondep_type_rec env mid) ext.ext_args in + let ret_type = may_map (nondep_type_rec env mid) ext.ext_ret_type in + clear_hash (); + { ext_type_path = type_path; + ext_type_params = type_params; + ext_args = args; + ext_ret_type = ret_type; + ext_private = ext.ext_private; + ext_attributes = ext.ext_attributes; + ext_loc = ext.ext_loc; + } + with Not_found -> + clear_hash (); + raise Not_found -and compare_records ~loc env params1 params2 n - (labels1 : Types.label_declaration list) - (labels2 : Types.label_declaration list) = - match labels1, labels2 with - [], [] -> [] - | [], l::_ -> [Field_missing (true, l.Types.ld_id)] - | l::_, [] -> [Field_missing (false, l.Types.ld_id)] - | ld1::rem1, ld2::rem2 -> - if Ident.name ld1.ld_id <> Ident.name ld2.ld_id - then [Field_names (n, ld1.ld_id, ld2.ld_id)] - else if ld1.ld_mutable <> ld2.ld_mutable then [Field_mutable ld1.ld_id] else begin - Builtin_attributes.check_deprecated_mutable_inclusion - ~def:ld1.ld_loc - ~use:ld2.ld_loc - loc - ld1.ld_attributes ld2.ld_attributes - (Ident.name ld1.ld_id); - if Ctype.equal env true (ld1.ld_type::params1)(ld2.ld_type::params2) - then (* add arguments to the parameters, cf. PR#7378 *) - compare_records ~loc env - (ld1.ld_type::params1) (ld2.ld_type::params2) - (n+1) - rem1 rem2 - else - [Field_type ld1.ld_id] - end -let type_declarations ?(equality = false) ~loc env name decl1 id decl2 = - Builtin_attributes.check_deprecated_inclusion - ~def:decl1.type_loc - ~use:decl2.type_loc - loc - decl1.type_attributes decl2.type_attributes - name; - if decl1.type_arity <> decl2.type_arity then [Arity] else - if not (private_flags decl1 decl2) then [Privacy] else - let err = match (decl1.type_manifest, decl2.type_manifest) with - (_, None) -> - if Ctype.equal env true decl1.type_params decl2.type_params - then [] else [Constraint] - | (Some ty1, Some ty2) -> - if type_manifest env ty1 decl1.type_params ty2 decl2.type_params - decl2.type_private - then [] else [Manifest] - | (None, Some ty2) -> - let ty1 = - Btype.newgenty (Tconstr(Pident id, decl2.type_params, ref Mnil)) - in - if Ctype.equal env true decl1.type_params decl2.type_params then - if Ctype.equal env false [ty1] [ty2] then [] - else [Manifest] - else [Constraint] - in - if err <> [] then err else - let err = - match (decl2.type_kind, decl1.type_unboxed.unboxed, - decl2.type_unboxed.unboxed) with - | Type_abstract, _, _ -> [] - | _, true, false -> [Unboxed_representation false] - | _, false, true -> [Unboxed_representation true] - | _ -> [] - in - if err <> [] then err else - let err = match (decl1.type_kind, decl2.type_kind) with - (_, Type_abstract) -> [] - | (Type_variant cstrs1, Type_variant cstrs2) -> - let mark cstrs usage name decl = - List.iter - (fun c -> - Env.mark_constructor_used usage env name decl - (Ident.name c.Types.cd_id)) - cstrs - in - let usage = - if decl1.type_private = Private || decl2.type_private = Public - then Env.Positive else Env.Privatize - in - mark cstrs1 usage name decl1; - if equality then mark cstrs2 Env.Positive (Ident.name id) decl2; - compare_variants ~loc env decl1.type_params decl2.type_params 1 cstrs1 cstrs2 - | (Type_record(labels1,rep1), Type_record(labels2,rep2)) -> - let err = compare_records ~loc env decl1.type_params decl2.type_params - 1 labels1 labels2 in - if err <> [] || rep1 = rep2 then err else - [Record_representation (rep2 = Record_float)] - | (Type_open, Type_open) -> [] - | (_, _) -> [Kind] - in - if err <> [] then err else - let abstr = decl2.type_kind = Type_abstract && decl2.type_manifest = None in - (* If attempt to assign a non-immediate type (e.g. string) to a type that - * must be immediate, then we error *) - let err = - if abstr && - not decl1.type_immediate && - decl2.type_immediate then - [Immediate] - else [] - in - if err <> [] then err else - let need_variance = - abstr || decl1.type_private = Private || decl1.type_kind = Type_open in - if not need_variance then [] else - let abstr = abstr || decl2.type_private = Private in - let opn = decl2.type_kind = Type_open && decl2.type_manifest = None in - let constrained ty = not (Btype.(is_Tvar (repr ty))) in - if List.for_all2 - (fun ty (v1,v2) -> - let open Variance in - let imp a b = not a || b in - let (co1,cn1) = get_upper v1 and (co2,cn2) = get_upper v2 in - (if abstr then (imp co1 co2 && imp cn1 cn2) - else if opn || constrained ty then (co1 = co2 && cn1 = cn2) - else true) && - let (p1,n1,i1,j1) = get_lower v1 and (p2,n2,i2,j2) = get_lower v2 in - imp abstr (imp p2 p1 && imp n2 n1 && imp i2 i1 && imp j2 j1)) - decl2.type_params (List.combine decl1.type_variance decl2.type_variance) - then [] else [Variance] +(* Preserve sharing inside class types. *) +let nondep_class_signature env id sign = + { csig_self = nondep_type_rec env id sign.csig_self; + csig_vars = + Vars.map (function (m, v, t) -> (m, v, nondep_type_rec env id t)) + sign.csig_vars; + csig_concr = sign.csig_concr; + csig_inher = + List.map (fun (p,tl) -> (p, List.map (nondep_type_rec env id) tl)) + sign.csig_inher } -(* Inclusion between extension constructors *) +let rec nondep_class_type env id = + function + Cty_constr (p, _, cty) when Path.isfree id p -> + nondep_class_type env id cty + | Cty_constr (p, tyl, cty) -> + Cty_constr (p, List.map (nondep_type_rec env id) tyl, + nondep_class_type env id cty) + | Cty_signature sign -> + Cty_signature (nondep_class_signature env id sign) + | Cty_arrow (l, ty, cty) -> + Cty_arrow (l, nondep_type_rec env id ty, nondep_class_type env id cty) -let extension_constructors ~loc env id ext1 ext2 = - let usage = - if ext1.ext_private = Private || ext2.ext_private = Public - then Env.Positive else Env.Privatize - in - Env.mark_extension_used usage env ext1 (Ident.name id); - let ty1 = - Btype.newgenty (Tconstr(ext1.ext_type_path, ext1.ext_type_params, ref Mnil)) +let nondep_class_declaration env id decl = + assert (not (Path.isfree id decl.cty_path)); + let decl = + { cty_params = List.map (nondep_type_rec env id) decl.cty_params; + cty_variance = decl.cty_variance; + cty_type = nondep_class_type env id decl.cty_type; + cty_path = decl.cty_path; + cty_new = + begin match decl.cty_new with + None -> None + | Some ty -> Some (nondep_type_rec env id ty) + end; + cty_loc = decl.cty_loc; + cty_attributes = decl.cty_attributes; + } in - let ty2 = - Btype.newgenty (Tconstr(ext2.ext_type_path, ext2.ext_type_params, ref Mnil)) + clear_hash (); + decl + +let nondep_cltype_declaration env id decl = + assert (not (Path.isfree id decl.clty_path)); + let decl = + { clty_params = List.map (nondep_type_rec env id) decl.clty_params; + clty_variance = decl.clty_variance; + clty_type = nondep_class_type env id decl.clty_type; + clty_path = decl.clty_path; + clty_loc = decl.clty_loc; + clty_attributes = decl.clty_attributes; + } in - if Ctype.equal env true - (ty1 :: ext1.ext_type_params) - (ty2 :: ext2.ext_type_params) - then - if compare_constructor_arguments ~loc env (Ident.create "") - ext1.ext_type_params ext2.ext_type_params - ext1.ext_args ext2.ext_args = [] then - if match ext1.ext_ret_type, ext2.ext_ret_type with - Some r1, Some r2 when not (Ctype.equal env true [r1] [r2]) -> false - | Some _, None | None, Some _ -> false - | _ -> true - then - match ext1.ext_private, ext2.ext_private with - Private, Public -> false - | _, _ -> true - else false - else false - else false + clear_hash (); + decl + +(* collapse conjunctive types in class parameters *) +let rec collapse_conj env visited ty = + let ty = repr ty in + if List.memq ty visited then () else + let visited = ty :: visited in + match ty.desc with + Tvariant row -> + let row = row_repr row in + List.iter + (fun (_l,fi) -> + match row_field_repr fi with + Reither (c, t1::(_::_ as tl), m, e) -> + List.iter (unify env t1) tl; + set_row_field e (Reither (c, [t1], m, ref None)) + | _ -> + ()) + row.row_fields; + iter_row (collapse_conj env visited) row + | _ -> + iter_type_expr (collapse_conj env visited) ty + +let collapse_conj_params env params = + List.iter (collapse_conj env []) params + +let same_constr env t1 t2 = + let t1 = expand_head env t1 in + let t2 = expand_head env t2 in + match t1.desc, t2.desc with + | Tconstr (p1, _, _), Tconstr (p2, _, _) -> Path.same p1 p2 + | _ -> false + +let () = + Env.same_constr := same_constr + +let maybe_pointer_type env typ = + match (repr typ).desc with + | Tconstr(p, _args, _abbrev) -> + begin try + let type_decl = Env.find_type p env in + not type_decl.type_immediate + with Not_found -> true + (* This can happen due to e.g. missing -I options, + causing some .cmi files to be unavailable. + Maybe we should emit a warning. *) + end + | Tvariant row -> + let row = Btype.row_repr row in + (* if all labels are devoid of arguments, not a pointer *) + not row.row_closed + || List.exists + (function + | _, (Rpresent (Some _) | Reither (false, _, _, _)) -> true + | _ -> false) + row.row_fields + | _ -> true end -module Mtype : sig -#1 "mtype.mli" +module Printtyp : sig +#1 "printtyp.mli" (**************************************************************************) (* *) (* OCaml *) @@ -52693,44 +51648,97 @@ module Mtype : sig (* *) (**************************************************************************) -(* Operations on module types *) +(* Printing functions *) +open Format open Types +open Outcometree -val scrape: Env.t -> module_type -> module_type - (* Expand toplevel module type abbreviations - till hitting a "hard" module type (signature, functor, - or abstract module type ident. *) -val freshen: module_type -> module_type - (* Return an alpha-equivalent copy of the given module type - where bound identifiers are fresh. *) -val strengthen: aliasable:bool -> Env.t -> module_type -> Path.t -> module_type - (* Strengthen abstract type components relative to the - given path. *) -val strengthen_decl: - aliasable:bool -> Env.t -> module_declaration -> Path.t -> module_declaration -val nondep_supertype: Env.t -> Ident.t -> module_type -> module_type - (* Return the smallest supertype of the given type - in which the given ident does not appear. - Raise [Not_found] if no such type exists. *) -val no_code_needed: Env.t -> module_type -> bool -val no_code_needed_sig: Env.t -> signature -> bool - (* Determine whether a module needs no implementation code, - i.e. consists only of type definitions. *) -val enrich_modtype: Env.t -> Path.t -> module_type -> module_type -val enrich_typedecl: Env.t -> Path.t -> type_declaration -> type_declaration -val type_paths: Env.t -> Path.t -> module_type -> Path.t list -val contains_type: Env.t -> module_type -> bool -val remove_aliases: Env.t -> module_type -> module_type -val lower_nongen: int -> module_type -> unit +val longident: formatter -> Longident.t -> unit +val ident: formatter -> Ident.t -> unit +val tree_of_path: Path.t -> out_ident +val path: formatter -> Path.t -> unit +val string_of_path: Path.t -> string +val raw_type_expr: formatter -> type_expr -> unit +val string_of_label: Asttypes.arg_label -> string + +val wrap_printing_env: Env.t -> (unit -> 'a) -> 'a + (* Call the function using the environment for type path shortening *) + (* This affects all the printing functions below *) + +val reset: unit -> unit +val mark_loops: type_expr -> unit +val reset_and_mark_loops: type_expr -> unit +val reset_and_mark_loops_list: type_expr list -> unit +val type_expr: formatter -> type_expr -> unit +val constructor_arguments: formatter -> constructor_arguments -> unit +val tree_of_type_scheme: type_expr -> out_type +val type_sch : formatter -> type_expr -> unit +val type_scheme: formatter -> type_expr -> unit +(* Maxence *) +val reset_names: unit -> unit +val type_scheme_max: ?b_reset_names: bool -> + formatter -> type_expr -> unit +(* End Maxence *) +val tree_of_value_description: Ident.t -> value_description -> out_sig_item +val value_description: Ident.t -> formatter -> value_description -> unit +val tree_of_type_declaration: + Ident.t -> type_declaration -> rec_status -> out_sig_item +val type_declaration: Ident.t -> formatter -> type_declaration -> unit +val tree_of_extension_constructor: + Ident.t -> extension_constructor -> ext_status -> out_sig_item +val extension_constructor: + Ident.t -> formatter -> extension_constructor -> unit +val tree_of_module: + Ident.t -> ?ellipsis:bool -> module_type -> rec_status -> out_sig_item +val modtype: formatter -> module_type -> unit +val signature: formatter -> signature -> unit +val tree_of_modtype_declaration: + Ident.t -> modtype_declaration -> out_sig_item +val tree_of_signature: Types.signature -> out_sig_item list +val tree_of_typexp: bool -> type_expr -> out_type +val modtype_declaration: Ident.t -> formatter -> modtype_declaration -> unit +val class_type: formatter -> class_type -> unit +val tree_of_class_declaration: + Ident.t -> class_declaration -> rec_status -> out_sig_item +val class_declaration: Ident.t -> formatter -> class_declaration -> unit +val tree_of_cltype_declaration: + Ident.t -> class_type_declaration -> rec_status -> out_sig_item +val cltype_declaration: Ident.t -> formatter -> class_type_declaration -> unit +val type_expansion: type_expr -> Format.formatter -> type_expr -> unit +val prepare_expansion: type_expr * type_expr -> type_expr * type_expr +val trace: + bool -> bool-> string -> formatter -> (type_expr * type_expr) list -> unit +val report_unification_error: + formatter -> Env.t -> ?unif:bool -> (type_expr * type_expr) list -> + (formatter -> unit) -> (formatter -> unit) -> + unit + + +val super_report_unification_error: + formatter -> Env.t -> ?unif:bool -> (type_expr * type_expr) list -> + (formatter -> unit) -> (formatter -> unit) -> + unit + + +val report_subtyping_error: + formatter -> Env.t -> (type_expr * type_expr) list -> + string -> (type_expr * type_expr) list -> unit +val report_ambiguous_type_error: + formatter -> Env.t -> (Path.t * Path.t) -> (Path.t * Path.t) list -> + (formatter -> unit) -> (formatter -> unit) -> (formatter -> unit) -> unit + +(* for toploop *) +val print_items: (Env.t -> signature_item -> 'a option) -> + Env.t -> signature_item list -> (out_sig_item * 'a option) list end = struct -#1 "mtype.ml" +#1 "printtyp.ml" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* Xavier Leroy and Jerome Vouillon, projet Cristal, INRIA Rocquencourt *) (* *) (* Copyright 1996 Institut National de Recherche en Informatique et *) (* en Automatique. *) @@ -52741,1185 +51749,1716 @@ end = struct (* *) (**************************************************************************) -(* Operations on module types *) +(* Printing functions *) -open Asttypes +open Misc +open Ctype +open Format +open Longident open Path +open Asttypes open Types +open Btype +open Outcometree +(* Print a long identifier *) -let rec scrape env mty = - match mty with - Mty_ident p -> - begin try - scrape env (Env.find_modtype_expansion p env) - with Not_found -> - mty - end - | _ -> mty +let rec longident ppf = function + | Lident s -> pp_print_string ppf s + | Ldot(p, s) -> fprintf ppf "%a.%s" longident p s + | Lapply(p1, p2) -> fprintf ppf "%a(%a)" longident p1 longident p2 -let freshen mty = - Subst.modtype Subst.identity mty +(* Print an identifier *) + +let unique_names = ref Ident.empty + +let ident_name id = + try Ident.find_same id !unique_names with Not_found -> Ident.name id + +let add_unique id = + try ignore (Ident.find_same id !unique_names) + with Not_found -> + unique_names := Ident.add id (Ident.unique_toplevel_name id) !unique_names + +let ident ppf id = pp_print_string ppf (ident_name id) + +(* Print a path *) + +let ident_pervasives = Ident.create_persistent "Pervasives" +let printing_env = ref Env.empty +let non_shadowed_pervasive = function + | Pdot(Pident id, s, _pos) as path -> + Ident.same id ident_pervasives && + (try Path.same path (Env.lookup_type (Lident s) !printing_env) + with Not_found -> true) + | _ -> false + +let rec tree_of_path = function + | Pident id -> + Oide_ident (ident_name id) + | Pdot(_, s, _pos) as path when non_shadowed_pervasive path -> + Oide_ident s + | Pdot(p, s, _pos) -> + Oide_dot (tree_of_path p, s) + | Papply(p1, p2) -> + Oide_apply (tree_of_path p1, tree_of_path p2) + +let rec path ppf = function + | Pident id -> + ident ppf id + | Pdot(_, s, _pos) as path when non_shadowed_pervasive path -> + pp_print_string ppf s + | Pdot(p, s, _pos) -> + path ppf p; + pp_print_char ppf '.'; + pp_print_string ppf s + | Papply(p1, p2) -> + fprintf ppf "%a(%a)" path p1 path p2 + +let rec string_of_out_ident = function + | Oide_ident s -> s + | Oide_dot (id, s) -> String.concat "." [string_of_out_ident id; s] + | Oide_apply (id1, id2) -> + String.concat "" + [string_of_out_ident id1; "("; string_of_out_ident id2; ")"] + +let string_of_path p = string_of_out_ident (tree_of_path p) + +(* Print a recursive annotation *) + +let tree_of_rec = function + | Trec_not -> Orec_not + | Trec_first -> Orec_first + | Trec_next -> Orec_next + +(* Print a raw type expression, with sharing *) + +let raw_list pr ppf = function + [] -> fprintf ppf "[]" + | a :: l -> + fprintf ppf "@[<1>[%a%t]@]" pr a + (fun ppf -> List.iter (fun x -> fprintf ppf ";@,%a" pr x) l) + +let kind_vars = ref [] +let kind_count = ref 0 + +let rec safe_kind_repr v = function + Fvar {contents=Some k} -> + if List.memq k v then "Fvar loop" else + safe_kind_repr (k::v) k + | Fvar r -> + let vid = + try List.assq r !kind_vars + with Not_found -> + let c = incr kind_count; !kind_count in + kind_vars := (r,c) :: !kind_vars; + c + in + Printf.sprintf "Fvar {None}@%d" vid + | Fpresent -> "Fpresent" + | Fabsent -> "Fabsent" + +let rec safe_commu_repr v = function + Cok -> "Cok" + | Cunknown -> "Cunknown" + | Clink r -> + if List.memq r v then "Clink loop" else + safe_commu_repr (r::v) !r + +let rec safe_repr v = function + {desc = Tlink t} when not (List.memq t v) -> + safe_repr (t::v) t + | t -> t + +let rec list_of_memo = function + Mnil -> [] + | Mcons (_priv, p, _t1, _t2, rem) -> p :: list_of_memo rem + | Mlink rem -> list_of_memo !rem + +let print_name ppf = function + None -> fprintf ppf "None" + | Some name -> fprintf ppf "\"%s\"" name + +let string_of_label = function + Nolabel -> "" + | Labelled s -> s + | Optional s -> "?"^s + +let visited = ref [] +let rec raw_type ppf ty = + let ty = safe_repr [] ty in + if List.memq ty !visited then fprintf ppf "{id=%d}" ty.id else begin + visited := ty :: !visited; + fprintf ppf "@[<1>{id=%d;level=%d;desc=@,%a}@]" ty.id ty.level + raw_type_desc ty.desc + end +and raw_type_list tl = raw_list raw_type tl +and raw_type_desc ppf = function + Tvar name -> fprintf ppf "Tvar %a" print_name name + | Tarrow(l,t1,t2,c) -> + fprintf ppf "@[Tarrow(\"%s\",@,%a,@,%a,@,%s)@]" + (string_of_label l) raw_type t1 raw_type t2 + (safe_commu_repr [] c) + | Ttuple tl -> + fprintf ppf "@[<1>Ttuple@,%a@]" raw_type_list tl + | Tconstr (p, tl, abbrev) -> + fprintf ppf "@[Tconstr(@,%a,@,%a,@,%a)@]" path p + raw_type_list tl + (raw_list path) (list_of_memo !abbrev) + | Tobject (t, nm) -> + fprintf ppf "@[Tobject(@,%a,@,@[<1>ref%t@])@]" raw_type t + (fun ppf -> + match !nm with None -> fprintf ppf " None" + | Some(p,tl) -> + fprintf ppf "(Some(@,%a,@,%a))" path p raw_type_list tl) + | Tfield (f, k, t1, t2) -> + fprintf ppf "@[Tfield(@,%s,@,%s,@,%a,@;<0 -1>%a)@]" f + (safe_kind_repr [] k) + raw_type t1 raw_type t2 + | Tnil -> fprintf ppf "Tnil" + | Tlink t -> fprintf ppf "@[<1>Tlink@,%a@]" raw_type t + | Tsubst t -> fprintf ppf "@[<1>Tsubst@,%a@]" raw_type t + | Tunivar name -> fprintf ppf "Tunivar %a" print_name name + | Tpoly (t, tl) -> + fprintf ppf "@[Tpoly(@,%a,@,%a)@]" + raw_type t + raw_type_list tl + | Tvariant row -> + fprintf ppf + "@[{@[%s@,%a;@]@ @[%s@,%a;@]@ %s%B;@ %s%B;@ @[<1>%s%t@]}@]" + "row_fields=" + (raw_list (fun ppf (l, f) -> + fprintf ppf "@[%s,@ %a@]" l raw_field f)) + row.row_fields + "row_more=" raw_type row.row_more + "row_closed=" row.row_closed + "row_fixed=" row.row_fixed + "row_name=" + (fun ppf -> + match row.row_name with None -> fprintf ppf "None" + | Some(p,tl) -> + fprintf ppf "Some(@,%a,@,%a)" path p raw_type_list tl) + | Tpackage (p, _, tl) -> + fprintf ppf "@[Tpackage(@,%a@,%a)@]" path p + raw_type_list tl + +and raw_field ppf = function + Rpresent None -> fprintf ppf "Rpresent None" + | Rpresent (Some t) -> fprintf ppf "@[<1>Rpresent(Some@,%a)@]" raw_type t + | Reither (c,tl,m,e) -> + fprintf ppf "@[Reither(%B,@,%a,@,%B,@,@[<1>ref%t@])@]" c + raw_type_list tl m + (fun ppf -> + match !e with None -> fprintf ppf " None" + | Some f -> fprintf ppf "@,@[<1>(%a)@]" raw_field f) + | Rabsent -> fprintf ppf "Rabsent" + +let raw_type_expr ppf t = + visited := []; kind_vars := []; kind_count := 0; + raw_type ppf t; + visited := []; kind_vars := [] + +let () = Btype.print_raw := raw_type_expr + +(* Normalize paths *) + +type param_subst = Id | Nth of int | Map of int list + +let is_nth = function + Nth _ -> true + | _ -> false + +let compose l1 = function + | Id -> Map l1 + | Map l2 -> Map (List.map (List.nth l1) l2) + | Nth n -> Nth (List.nth l1 n) + +let apply_subst s1 tyl = + if tyl = [] then [] + (* cf. PR#7543: Typemod.type_package doesn't respect type constructor arity *) + else + match s1 with + Nth n1 -> [List.nth tyl n1] + | Map l1 -> List.map (List.nth tyl) l1 + | Id -> tyl + +type best_path = Paths of Path.t list | Best of Path.t + +let printing_depth = ref 0 +let printing_cont = ref ([] : Env.iter_cont list) +let printing_old = ref Env.empty +let printing_pers = ref Concr.empty +module PathMap = Map.Make(Path) +let printing_map = ref PathMap.empty + +let same_type t t' = repr t == repr t' + +let rec index l x = + match l with + [] -> raise Not_found + | a :: l -> if x == a then 0 else 1 + index l x + +let rec uniq = function + [] -> true + | a :: l -> not (List.memq a l) && uniq l + +let rec normalize_type_path ?(cache=false) env p = + try + let (params, ty, _) = Env.find_type_expansion p env in + let params = List.map repr params in + match repr ty with + {desc = Tconstr (p1, tyl, _)} -> + let tyl = List.map repr tyl in + if List.length params = List.length tyl + && List.for_all2 (==) params tyl + then normalize_type_path ~cache env p1 + else if cache || List.length params <= List.length tyl + || not (uniq tyl) then (p, Id) + else + let l1 = List.map (index params) tyl in + let (p2, s2) = normalize_type_path ~cache env p1 in + (p2, compose l1 s2) + | ty -> + (p, Nth (index params ty)) + with + Not_found -> + (Env.normalize_path None env p, Id) -let rec strengthen ~aliasable env mty p = - match scrape env mty with - Mty_signature sg -> - Mty_signature(strengthen_sig ~aliasable env sg p 0) - | Mty_functor(param, arg, res) - when !Clflags.applicative_functors && Ident.name param <> "*" -> - Mty_functor(param, arg, - strengthen ~aliasable:false env res (Papply(p, Pident param))) - | mty -> - mty +let penalty s = + if s <> "" && s.[0] = '_' then + 10 + else + try + for i = 0 to String.length s - 2 do + if s.[i] = '_' && s.[i + 1] = '_' then + raise Exit + done; + 1 + with Exit -> 10 -and strengthen_sig ~aliasable env sg p pos = - match sg with - [] -> [] - | (Sig_value(_, desc) as sigelt) :: rem -> - let nextpos = - match desc.val_kind with - | Val_prim _ -> pos - | _ -> pos + 1 - in - sigelt :: strengthen_sig ~aliasable env rem p nextpos - | Sig_type(id, {type_kind=Type_abstract}, _) :: - (Sig_type(id', {type_private=Private}, _) :: _ as rem) - when Ident.name id = Ident.name id' ^ "#row" -> - strengthen_sig ~aliasable env rem p pos - | Sig_type(id, decl, rs) :: rem -> - let newdecl = - match decl.type_manifest, decl.type_private, decl.type_kind with - Some _, Public, _ -> decl - | Some _, Private, (Type_record _ | Type_variant _) -> decl - | _ -> - let manif = - Some(Btype.newgenty(Tconstr(Pdot(p, Ident.name id, nopos), - decl.type_params, ref Mnil))) in - if decl.type_kind = Type_abstract then - { decl with type_private = Public; type_manifest = manif } - else - { decl with type_manifest = manif } - in - Sig_type(id, newdecl, rs) :: strengthen_sig ~aliasable env rem p pos - | (Sig_typext _ as sigelt) :: rem -> - sigelt :: strengthen_sig ~aliasable env rem p (pos+1) - | Sig_module(id, md, rs) :: rem -> - let str = - strengthen_decl ~aliasable env md (Pdot(p, Ident.name id, pos)) - in - Sig_module(id, str, rs) - :: strengthen_sig ~aliasable - (Env.add_module_declaration ~check:false id md env) rem p (pos+1) - (* Need to add the module in case it defines manifest module types *) - | Sig_modtype(id, decl) :: rem -> - let newdecl = - match decl.mtd_type with - None -> - {decl with mtd_type = Some(Mty_ident(Pdot(p,Ident.name id,nopos)))} - | Some _ -> - decl - in - Sig_modtype(id, newdecl) :: - strengthen_sig ~aliasable (Env.add_modtype id decl env) rem p pos - (* Need to add the module type in case it is manifest *) - | (Sig_class _ as sigelt) :: rem -> - sigelt :: strengthen_sig ~aliasable env rem p (pos+1) - | (Sig_class_type _ as sigelt) :: rem -> - sigelt :: strengthen_sig ~aliasable env rem p pos +let rec path_size = function + Pident id -> + penalty (Ident.name id), -Ident.binding_time id + | Pdot (p, _, _) -> + let (l, b) = path_size p in (1+l, b) + | Papply (p1, p2) -> + let (l, b) = path_size p1 in + (l + fst (path_size p2), b) -and strengthen_decl ~aliasable env md p = - match md.md_type with - | Mty_alias _ -> md - | _ when aliasable -> {md with md_type = Mty_alias(Mta_present, p)} - | mty -> {md with md_type = strengthen ~aliasable env mty p} +let same_printing_env env = + let used_pers = Env.used_persistent () in + Env.same_types !printing_old env && Concr.equal !printing_pers used_pers -let () = Env.strengthen := strengthen +let set_printing_env env = + printing_env := env; + if !Clflags.real_paths + || !printing_env == Env.empty || same_printing_env env then () else + begin + (* printf "Reset printing_map@."; *) + printing_old := env; + printing_pers := Env.used_persistent (); + printing_map := PathMap.empty; + printing_depth := 0; + (* printf "Recompute printing_map.@."; *) + let cont = + Env.iter_types + (fun p (p', _decl) -> + let (p1, s1) = normalize_type_path env p' ~cache:true in + (* Format.eprintf "%a -> %a = %a@." path p path p' path p1 *) + if s1 = Id then + try + let r = PathMap.find p1 !printing_map in + match !r with + Paths l -> r := Paths (p :: l) + | Best p' -> r := Paths [p; p'] (* assert false *) + with Not_found -> + printing_map := PathMap.add p1 (ref (Paths [p])) !printing_map) + env in + printing_cont := [cont]; + end -(* In nondep_supertype, env is only used for the type it assigns to id. - Hence there is no need to keep env up-to-date by adding the bindings - traversed. *) +let wrap_printing_env env f = + set_printing_env env; + try_finally f (fun () -> set_printing_env Env.empty) -type variance = Co | Contra | Strict +let wrap_printing_env env f = + Env.without_cmis (wrap_printing_env env) f -let nondep_supertype env mid mty = +let is_unambiguous path env = + let l = Env.find_shadowed_types path env in + List.exists (Path.same path) l || (* concrete paths are ok *) + match l with + [] -> true + | p :: rem -> + (* allow also coherent paths: *) + let normalize p = fst (normalize_type_path ~cache:true env p) in + let p' = normalize p in + List.for_all (fun p -> Path.same (normalize p) p') rem || + (* also allow repeatedly defining and opening (for toplevel) *) + let id = lid_of_path p in + List.for_all (fun p -> lid_of_path p = id) rem && + Path.same p (Env.lookup_type id env) - let rec nondep_mty env va mty = - match mty with - Mty_ident p -> - if Path.isfree mid p then - nondep_mty env va (Env.find_modtype_expansion p env) - else mty - | Mty_alias(_, p) -> - if Path.isfree mid p then - nondep_mty env va (Env.find_module p env).md_type - else mty - | Mty_signature sg -> - Mty_signature(nondep_sig env va sg) - | Mty_functor(param, arg, res) -> - let var_inv = - match va with Co -> Contra | Contra -> Co | Strict -> Strict in - Mty_functor(param, Misc.may_map (nondep_mty env var_inv) arg, - nondep_mty - (Env.add_module ~arg:true param - (Btype.default_mty arg) env) va res) +let rec get_best_path r = + match !r with + Best p' -> p' + | Paths [] -> raise Not_found + | Paths l -> + r := Paths []; + List.iter + (fun p -> + (* Format.eprintf "evaluating %a@." path p; *) + match !r with + Best p' when path_size p >= path_size p' -> () + | _ -> if is_unambiguous p !printing_env then r := Best p) + (* else Format.eprintf "%a ignored as ambiguous@." path p *) + l; + get_best_path r - and nondep_sig env va = function - [] -> [] - | item :: rem -> - let rem' = nondep_sig env va rem in - match item with - Sig_value(id, d) -> - Sig_value(id, - {d with val_type = Ctype.nondep_type env mid d.val_type}) - :: rem' - | Sig_type(id, d, rs) -> - Sig_type(id, Ctype.nondep_type_decl env mid id (va = Co) d, rs) - :: rem' - | Sig_typext(id, ext, es) -> - Sig_typext(id, Ctype.nondep_extension_constructor env mid ext, es) - :: rem' - | Sig_module(id, md, rs) -> - Sig_module(id, {md with md_type=nondep_mty env va md.md_type}, rs) - :: rem' - | Sig_modtype(id, d) -> - begin try - Sig_modtype(id, nondep_modtype_decl env d) :: rem' - with Not_found -> - match va with - Co -> Sig_modtype(id, {mtd_type=None; mtd_loc=Location.none; - mtd_attributes=[]}) :: rem' - | _ -> raise Not_found - end - | Sig_class(id, d, rs) -> - Sig_class(id, Ctype.nondep_class_declaration env mid d, rs) - :: rem' - | Sig_class_type(id, d, rs) -> - Sig_class_type(id, Ctype.nondep_cltype_declaration env mid d, rs) - :: rem' +let best_type_path p = + if !Clflags.real_paths || !printing_env == Env.empty + then (p, Id) + else + let (p', s) = normalize_type_path !printing_env p in + let get_path () = get_best_path (PathMap.find p' !printing_map) in + while !printing_cont <> [] && + try fst (path_size (get_path ())) > !printing_depth with Not_found -> true + do + printing_cont := List.map snd (Env.run_iter_cont !printing_cont); + incr printing_depth; + done; + let p'' = try get_path () with Not_found -> p' in + (* Format.eprintf "%a = %a -> %a@." path p path p' path p''; *) + (p'', s) - and nondep_modtype_decl env mtd = - {mtd with mtd_type = Misc.may_map (nondep_mty env Strict) mtd.mtd_type} +(* Print a type expression *) - in - nondep_mty env Co mty +let names = ref ([] : (type_expr * string) list) +let name_counter = ref 0 +let named_vars = ref ([] : string list) -let enrich_typedecl env p decl = - match decl.type_manifest with - Some _ -> decl - | None -> - try - let orig_decl = Env.find_type p env in - if orig_decl.type_arity <> decl.type_arity - then decl - else {decl with type_manifest = - Some(Btype.newgenty(Tconstr(p, decl.type_params, ref Mnil)))} - with Not_found -> - decl +let weak_counter = ref 1 +let weak_var_map = ref TypeMap.empty +let named_weak_vars = ref StringSet.empty -let rec enrich_modtype env p mty = - match mty with - Mty_signature sg -> - Mty_signature(List.map (enrich_item env p) sg) - | _ -> - mty +let reset_names () = names := []; name_counter := 0; named_vars := [] +let add_named_var ty = + match ty.desc with + Tvar (Some name) | Tunivar (Some name) -> + if List.mem name !named_vars then () else + named_vars := name :: !named_vars + | _ -> () -and enrich_item env p = function - Sig_type(id, decl, rs) -> - Sig_type(id, - enrich_typedecl env (Pdot(p, Ident.name id, nopos)) decl, rs) - | Sig_module(id, md, rs) -> - Sig_module(id, - {md with - md_type = enrich_modtype env - (Pdot(p, Ident.name id, nopos)) md.md_type}, - rs) - | item -> item +let name_is_already_used name = + List.mem name !named_vars + || List.exists (fun (_, name') -> name = name') !names + || StringSet.mem name !named_weak_vars -let rec type_paths env p mty = - match scrape env mty with - Mty_ident _ -> [] - | Mty_alias _ -> [] - | Mty_signature sg -> type_paths_sig env p 0 sg - | Mty_functor _ -> [] +let rec new_name () = + let name = + if !name_counter < 26 + then String.make 1 (Char.chr(97 + !name_counter)) + else String.make 1 (Char.chr(97 + !name_counter mod 26)) ^ + string_of_int(!name_counter / 26) in + incr name_counter; + if name_is_already_used name then new_name () else name -and type_paths_sig env p pos sg = - match sg with - [] -> [] - | Sig_value(_id, decl) :: rem -> - let pos' = match decl.val_kind with Val_prim _ -> pos | _ -> pos + 1 in - type_paths_sig env p pos' rem - | Sig_type(id, _decl, _) :: rem -> - Pdot(p, Ident.name id, nopos) :: type_paths_sig env p pos rem - | Sig_module(id, md, _) :: rem -> - type_paths env (Pdot(p, Ident.name id, pos)) md.md_type @ - type_paths_sig (Env.add_module_declaration ~check:false id md env) - p (pos+1) rem - | Sig_modtype(id, decl) :: rem -> - type_paths_sig (Env.add_modtype id decl env) p pos rem - | (Sig_typext _ | Sig_class _) :: rem -> - type_paths_sig env p (pos+1) rem - | (Sig_class_type _) :: rem -> - type_paths_sig env p pos rem +let rec new_weak_name ty () = + let name = "weak" ^ string_of_int !weak_counter in + incr weak_counter; + if name_is_already_used name then new_weak_name ty () + else begin + named_weak_vars := StringSet.add name !named_weak_vars; + weak_var_map := TypeMap.add ty name !weak_var_map; + name + end -let rec no_code_needed env mty = - match scrape env mty with - Mty_ident _ -> false - | Mty_signature sg -> no_code_needed_sig env sg - | Mty_functor(_, _, _) -> false - | Mty_alias(Mta_absent, _) -> true - | Mty_alias(Mta_present, _) -> false +let name_of_type name_generator t = + (* We've already been through repr at this stage, so t is our representative + of the union-find class. *) + try List.assq t !names with Not_found -> + try TypeMap.find t !weak_var_map with Not_found -> + let name = + match t.desc with + Tvar (Some name) | Tunivar (Some name) -> + (* Some part of the type we've already printed has assigned another + * unification variable to that name. We want to keep the name, so try + * adding a number until we find a name that's not taken. *) + let current_name = ref name in + let i = ref 0 in + while List.exists (fun (_, name') -> !current_name = name') !names do + current_name := name ^ (string_of_int !i); + i := !i + 1; + done; + !current_name + | _ -> + (* No name available, create a new one *) + name_generator () + in + (* Exception for type declarations *) + if name <> "_" then names := (t, name) :: !names; + name -and no_code_needed_sig env sg = - match sg with - [] -> true - | Sig_value(_id, decl) :: rem -> - begin match decl.val_kind with - | Val_prim _ -> no_code_needed_sig env rem - | _ -> false - end - | Sig_module(id, md, _) :: rem -> - no_code_needed env md.md_type && - no_code_needed_sig - (Env.add_module_declaration ~check:false id md env) rem - | (Sig_type _ | Sig_modtype _ | Sig_class_type _) :: rem -> - no_code_needed_sig env rem - | (Sig_typext _ | Sig_class _) :: _ -> - false +let check_name_of_type t = ignore(name_of_type new_name t) +let remove_names tyl = + let tyl = List.map repr tyl in + names := List.filter (fun (ty,_) -> not (List.memq ty tyl)) !names -(* Check whether a module type may return types *) +let visited_objects = ref ([] : type_expr list) +let aliased = ref ([] : type_expr list) +let delayed = ref ([] : type_expr list) -let rec contains_type env = function - Mty_ident path -> - begin try match (Env.find_modtype path env).mtd_type with - | None -> raise Exit (* PR#6427 *) - | Some mty -> contains_type env mty - with Not_found -> raise Exit - end - | Mty_signature sg -> - contains_type_sig env sg - | Mty_functor (_, _, body) -> - contains_type env body - | Mty_alias _ -> - () +let add_delayed t = + if not (List.memq t !delayed) then delayed := t :: !delayed -and contains_type_sig env = List.iter (contains_type_item env) +let is_aliased ty = List.memq (proxy ty) !aliased +let add_alias ty = + let px = proxy ty in + if not (is_aliased px) then begin + aliased := px :: !aliased; + add_named_var px + end -and contains_type_item env = function - Sig_type (_,({type_manifest = None} | - {type_kind = Type_abstract; type_private = Private}),_) - | Sig_modtype _ - | Sig_typext (_, {ext_args = Cstr_record _}, _) -> - (* We consider that extension constructors with an inlined - record create a type (the inlined record), even though - it would be technically safe to ignore that considering - the current constraints which guarantee that this type - is kept local to expressions. *) - raise Exit - | Sig_module (_, {md_type = mty}, _) -> - contains_type env mty - | Sig_value _ - | Sig_type _ - | Sig_typext _ - | Sig_class _ - | Sig_class_type _ -> - () +let aliasable ty = + match ty.desc with + Tvar _ | Tunivar _ | Tpoly _ -> false + | Tconstr (p, _, _) -> + not (is_nth (snd (best_type_path p))) + | _ -> true -let contains_type env mty = - try contains_type env mty; false with Exit -> true +let namable_row row = + row.row_name <> None && + List.for_all + (fun (_, f) -> + match row_field_repr f with + | Reither(c, l, _, _) -> + row.row_closed && if c then l = [] else List.length l = 1 + | _ -> true) + row.row_fields +let rec mark_loops_rec visited ty = + let ty = repr ty in + let px = proxy ty in + if List.memq px visited && aliasable ty then add_alias px else + let visited = px :: visited in + match ty.desc with + | Tvar _ -> add_named_var ty + | Tarrow(_, ty1, ty2, _) -> + mark_loops_rec visited ty1; mark_loops_rec visited ty2 + | Ttuple tyl -> List.iter (mark_loops_rec visited) tyl + | Tconstr(p, tyl, _) -> + let (_p', s) = best_type_path p in + List.iter (mark_loops_rec visited) (apply_subst s tyl) + | Tpackage (_, _, tyl) -> + List.iter (mark_loops_rec visited) tyl + | Tvariant row -> + if List.memq px !visited_objects then add_alias px else + begin + let row = row_repr row in + if not (static_row row) then + visited_objects := px :: !visited_objects; + match row.row_name with + | Some(_p, tyl) when namable_row row -> + List.iter (mark_loops_rec visited) tyl + | _ -> + iter_row (mark_loops_rec visited) row + end + | Tobject (fi, nm) -> + if List.memq px !visited_objects then add_alias px else + begin + if opened_object ty then + visited_objects := px :: !visited_objects; + begin match !nm with + | None -> + let fields, _ = flatten_fields fi in + List.iter + (fun (_, kind, ty) -> + if field_kind_repr kind = Fpresent then + mark_loops_rec visited ty) + fields + | Some (_, l) -> + List.iter (mark_loops_rec visited) (List.tl l) + end + end + | Tfield(_, kind, ty1, ty2) when field_kind_repr kind = Fpresent -> + mark_loops_rec visited ty1; mark_loops_rec visited ty2 + | Tfield(_, _, _, ty2) -> + mark_loops_rec visited ty2 + | Tnil -> () + | Tsubst ty -> mark_loops_rec visited ty + | Tlink _ -> fatal_error "Printtyp.mark_loops_rec (2)" + | Tpoly (ty, tyl) -> + List.iter (fun t -> add_alias t) tyl; + mark_loops_rec visited ty + | Tunivar _ -> add_named_var ty -(* Remove module aliases from a signature *) +let mark_loops ty = + normalize_type Env.empty ty; + mark_loops_rec [] ty;; -module PathSet = Set.Make (Path) -module PathMap = Map.Make (Path) -module IdentSet = Set.Make (Ident) +let reset_loop_marks () = + visited_objects := []; aliased := []; delayed := [] -let rec get_prefixes = function - Pident _ -> PathSet.empty - | Pdot (p, _, _) - | Papply (p, _) -> PathSet.add p (get_prefixes p) +let reset () = + unique_names := Ident.empty; reset_names (); reset_loop_marks () -let rec get_arg_paths = function - Pident _ -> PathSet.empty - | Pdot (p, _, _) -> get_arg_paths p - | Papply (p1, p2) -> - PathSet.add p2 - (PathSet.union (get_prefixes p2) - (PathSet.union (get_arg_paths p1) (get_arg_paths p2))) +let reset_and_mark_loops ty = + reset (); mark_loops ty -let rec rollback_path subst p = - try Pident (PathMap.find p subst) - with Not_found -> - match p with - Pident _ | Papply _ -> p - | Pdot (p1, s, n) -> - let p1' = rollback_path subst p1 in - if Path.same p1 p1' then p else rollback_path subst (Pdot (p1', s, n)) +let reset_and_mark_loops_list tyl = + reset (); List.iter mark_loops tyl -let rec collect_ids subst bindings p = - begin match rollback_path subst p with - Pident id -> - let ids = - try collect_ids subst bindings (Ident.find_same id bindings) - with Not_found -> IdentSet.empty - in - IdentSet.add id ids - | _ -> IdentSet.empty - end +(* Disabled in classic mode when printing an unification error *) +let print_labels = ref true -let collect_arg_paths mty = - let open Btype in - let paths = ref PathSet.empty - and subst = ref PathMap.empty - and bindings = ref Ident.empty in - (* let rt = Ident.create "Root" in - and prefix = ref (Path.Pident rt) in *) - let it_path p = paths := PathSet.union (get_arg_paths p) !paths - and it_signature_item it si = - type_iterators.it_signature_item it si; - match si with - Sig_module (id, {md_type=Mty_alias(_, p)}, _) -> - bindings := Ident.add id p !bindings - | Sig_module (id, {md_type=Mty_signature sg}, _) -> - List.iter - (function Sig_module (id', _, _) -> - subst := - PathMap.add (Pdot (Pident id, Ident.name id', -1)) id' !subst - | _ -> ()) - sg - | _ -> () +let rec tree_of_typexp sch ty = + let ty = repr ty in + let px = proxy ty in + if List.mem_assq px !names && not (List.memq px !delayed) then + let mark = is_non_gen sch ty in + let name = name_of_type (if mark then new_weak_name ty else new_name) px in + Otyp_var (mark, name) else + + let pr_typ () = + match ty.desc with + | Tvar _ -> + (*let lev = + if is_non_gen sch ty then "/" ^ string_of_int ty.level else "" in*) + let non_gen = is_non_gen sch ty in + let name_gen = if non_gen then new_weak_name ty else new_name in + Otyp_var (non_gen, name_of_type name_gen ty) + | Tarrow(l, ty1, ty2, _) -> + let pr_arrow l ty1 ty2 = + let lab = + if !print_labels || is_optional l then string_of_label l else "" + in + let t1 = + if is_optional l then + match (repr ty1).desc with + | Tconstr(path, [ty], _) + when Path.same path Predef.path_option -> + tree_of_typexp sch ty + | _ -> Otyp_stuff "" + else tree_of_typexp sch ty1 in + Otyp_arrow (lab, t1, tree_of_typexp sch ty2) in + pr_arrow l ty1 ty2 + | Ttuple tyl -> + Otyp_tuple (tree_of_typlist sch tyl) + | Tconstr(p, tyl, _abbrev) -> + let p', s = best_type_path p in + let tyl' = apply_subst s tyl in + if is_nth s && not (tyl'=[]) then tree_of_typexp sch (List.hd tyl') else + Otyp_constr (tree_of_path p', tree_of_typlist sch tyl') + | Tvariant row -> + let row = row_repr row in + let fields = + if row.row_closed then + List.filter (fun (_, f) -> row_field_repr f <> Rabsent) + row.row_fields + else row.row_fields in + let present = + List.filter + (fun (_, f) -> + match row_field_repr f with + | Rpresent _ -> true + | _ -> false) + fields in + let all_present = List.length present = List.length fields in + begin match row.row_name with + | Some(p, tyl) when namable_row row -> + let (p', s) = best_type_path p in + let id = tree_of_path p' in + let args = tree_of_typlist sch (apply_subst s tyl) in + let out_variant = + if is_nth s then List.hd args else Otyp_constr (id, args) in + if row.row_closed && all_present then + out_variant + else + let non_gen = is_non_gen sch px in + let tags = + if all_present then None else Some (List.map fst present) in + Otyp_variant (non_gen, Ovar_typ out_variant, row.row_closed, tags) + | _ -> + let non_gen = + not (row.row_closed && all_present) && is_non_gen sch px in + let fields = List.map (tree_of_row_field sch) fields in + let tags = + if all_present then None else Some (List.map fst present) in + Otyp_variant (non_gen, Ovar_fields fields, row.row_closed, tags) + end + | Tobject (fi, nm) -> + tree_of_typobject sch fi !nm + | Tnil | Tfield _ -> + tree_of_typobject sch ty None + | Tsubst ty -> + tree_of_typexp sch ty + | Tlink _ -> + fatal_error "Printtyp.tree_of_typexp" + | Tpoly (ty, []) -> + tree_of_typexp sch ty + | Tpoly (ty, tyl) -> + (*let print_names () = + List.iter (fun (_, name) -> prerr_string (name ^ " ")) !names; + prerr_string "; " in *) + let tyl = List.map repr tyl in + if tyl = [] then tree_of_typexp sch ty else begin + let old_delayed = !delayed in + (* Make the names delayed, so that the real type is + printed once when used as proxy *) + List.iter add_delayed tyl; + let tl = List.map (name_of_type new_name) tyl in + let tr = Otyp_poly (tl, tree_of_typexp sch ty) in + (* Forget names when we leave scope *) + remove_names tyl; + delayed := old_delayed; tr + end + | Tunivar _ -> + Otyp_var (false, name_of_type new_name ty) + | Tpackage (p, n, tyl) -> + let n = + List.map (fun li -> String.concat "." (Longident.flatten li)) n in + Otyp_module (Path.name p, n, tree_of_typlist sch tyl) in - let it = {type_iterators with it_path; it_signature_item} in - it.it_module_type it mty; - it.it_module_type unmark_iterators mty; - PathSet.fold (fun p -> IdentSet.union (collect_ids !subst !bindings p)) - !paths IdentSet.empty + if List.memq px !delayed then delayed := List.filter ((!=) px) !delayed; + if is_aliased px && aliasable ty then begin + check_name_of_type px; + Otyp_alias (pr_typ (), name_of_type new_name px) end + else pr_typ () -let rec remove_aliases env excl mty = - match mty with - Mty_signature sg -> - Mty_signature (remove_aliases_sig env excl sg) - | Mty_alias _ -> - let mty' = Env.scrape_alias env mty in - if mty' = mty then mty else - remove_aliases env excl mty' - | mty -> - mty +and tree_of_row_field sch (l, f) = + match row_field_repr f with + | Rpresent None | Reither(true, [], _, _) -> (l, false, []) + | Rpresent(Some ty) -> (l, false, [tree_of_typexp sch ty]) + | Reither(c, tyl, _, _) -> + if c (* contradiction: constant constructor with an argument *) + then (l, true, tree_of_typlist sch tyl) + else (l, false, tree_of_typlist sch tyl) + | Rabsent -> (l, false, [] (* actually, an error *)) -and remove_aliases_sig env excl sg = - match sg with - [] -> [] - | Sig_module(id, md, rs) :: rem -> - let mty = - match md.md_type with - Mty_alias _ when IdentSet.mem id excl -> - md.md_type - | mty -> - remove_aliases env excl mty - in - Sig_module(id, {md with md_type = mty} , rs) :: - remove_aliases_sig (Env.add_module id mty env) excl rem - | Sig_modtype(id, mtd) :: rem -> - Sig_modtype(id, mtd) :: - remove_aliases_sig (Env.add_modtype id mtd env) excl rem - | it :: rem -> - it :: remove_aliases_sig env excl rem +and tree_of_typlist sch tyl = + List.map (tree_of_typexp sch) tyl -let remove_aliases env sg = - let excl = collect_arg_paths sg in - (* PathSet.iter (fun p -> Format.eprintf "%a@ " Printtyp.path p) excl; - Format.eprintf "@."; *) - remove_aliases env excl sg +and tree_of_typobject sch fi nm = + begin match nm with + | None -> + let pr_fields fi = + let (fields, rest) = flatten_fields fi in + let present_fields = + List.fold_right + (fun (n, k, t) l -> + match field_kind_repr k with + | Fpresent -> (n, t) :: l + | _ -> l) + fields [] in + let sorted_fields = + List.sort + (fun (n, _) (n', _) -> String.compare n n') present_fields in + tree_of_typfields sch rest sorted_fields in + let (fields, rest) = pr_fields fi in + Otyp_object (fields, rest) + | Some (p, ty :: tyl) -> + let non_gen = is_non_gen sch (repr ty) in + let args = tree_of_typlist sch tyl in + let (p', s) = best_type_path p in + assert (s = Id); + Otyp_class (non_gen, tree_of_path p', args) + | _ -> + fatal_error "Printtyp.tree_of_typobject" + end +and is_non_gen sch ty = + sch && is_Tvar ty && ty.level <> generic_level -(* Lower non-generalizable type variables *) +and tree_of_typfields sch rest = function + | [] -> + let rest = + match rest.desc with + | Tvar _ | Tunivar _ -> Some (is_non_gen sch rest) + | Tconstr _ -> Some false + | Tnil -> None + | _ -> fatal_error "typfields (1)" + in + ([], rest) + | (s, t) :: l -> + let field = (s, tree_of_typexp sch t) in + let (fields, rest) = tree_of_typfields sch rest l in + (field :: fields, rest) -let lower_nongen nglev mty = - let open Btype in - let it_type_expr it ty = - let ty = repr ty in - match ty with - {desc=Tvar _; level} -> - if level < generic_level && level > nglev then set_level ty nglev - | _ -> - type_iterators.it_type_expr it ty - in - let it = {type_iterators with it_type_expr} in - it.it_module_type it mty; - it.it_module_type unmark_iterators mty +let typexp sch ppf ty = + !Oprint.out_type ppf (tree_of_typexp sch ty) -end -module Includemod : sig -#1 "includemod.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let type_expr ppf ty = typexp false ppf ty -(* Inclusion checks for the module language *) +and type_sch ppf ty = typexp true ppf ty -open Typedtree -open Types -open Format +and type_scheme ppf ty = reset_and_mark_loops ty; typexp true ppf ty -val modtypes: - loc:Location.t -> Env.t -> - module_type -> module_type -> module_coercion +(* Maxence *) +let type_scheme_max ?(b_reset_names=true) ppf ty = + if b_reset_names then reset_names () ; + typexp true ppf ty +(* End Maxence *) -val signatures: Env.t -> signature -> signature -> module_coercion +let tree_of_type_scheme ty = reset_and_mark_loops ty; tree_of_typexp true ty -val compunit: - Env.t -> string -> signature -> string -> signature -> module_coercion +(* Print one type declaration *) -val type_declarations: - loc:Location.t -> Env.t -> - Ident.t -> type_declaration -> type_declaration -> unit +let tree_of_constraints params = + List.fold_right + (fun ty list -> + let ty' = unalias ty in + if proxy ty != proxy ty' then + let tr = tree_of_typexp true ty in + (tr, tree_of_typexp true ty') :: list + else list) + params [] -val print_coercion: formatter -> module_coercion -> unit +let filter_params tyl = + let params = + List.fold_left + (fun tyl ty -> + let ty = repr ty in + if List.memq ty tyl then Btype.newgenty (Tsubst ty) :: tyl + else ty :: tyl) + [] tyl + in List.rev params -type symptom = - Missing_field of Ident.t * Location.t * string (* kind *) - | Value_descriptions of Ident.t * value_description * value_description - | Type_declarations of Ident.t * type_declaration - * type_declaration * Includecore.type_mismatch list - | Extension_constructors of - Ident.t * extension_constructor * extension_constructor - | Module_types of module_type * module_type - | Modtype_infos of Ident.t * modtype_declaration * modtype_declaration - | Modtype_permutation - | Interface_mismatch of string * string - | Class_type_declarations of - Ident.t * class_type_declaration * class_type_declaration * - Ctype.class_match_failure list - | Class_declarations of - Ident.t * class_declaration * class_declaration * - Ctype.class_match_failure list - | Unbound_modtype_path of Path.t - | Unbound_module_path of Path.t - | Invalid_module_alias of Path.t +let mark_loops_constructor_arguments = function + | Cstr_tuple l -> List.iter mark_loops l + | Cstr_record l -> List.iter (fun l -> mark_loops l.ld_type) l -type pos = - Module of Ident.t | Modtype of Ident.t | Arg of Ident.t | Body of Ident.t -type error = pos list * Env.t * symptom +let rec tree_of_type_decl id decl = -exception Error of error list + reset(); -val report_error: formatter -> error list -> unit -val expand_module_alias: Env.t -> pos list -> Path.t -> Types.module_type + let params = filter_params decl.type_params in -end = struct -#1 "includemod.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) + begin match decl.type_manifest with + | Some ty -> + let vars = free_variables ty in + List.iter + (function {desc = Tvar (Some "_")} as ty -> + if List.memq ty vars then ty.desc <- Tvar None + | _ -> ()) + params + | None -> () + end; -(* Inclusion checks for the module language *) + List.iter add_alias params; + List.iter mark_loops params; + List.iter check_name_of_type (List.map proxy params); + let ty_manifest = + match decl.type_manifest with + | None -> None + | Some ty -> + let ty = + (* Special hack to hide variant name *) + match repr ty with {desc=Tvariant row} -> + let row = row_repr row in + begin match row.row_name with + Some (Pident id', _) when Ident.same id id' -> + newgenty (Tvariant {row with row_name = None}) + | _ -> ty + end + | _ -> ty + in + mark_loops ty; + Some ty + in + begin match decl.type_kind with + | Type_abstract -> () + | Type_variant cstrs -> + List.iter + (fun c -> + mark_loops_constructor_arguments c.cd_args; + may mark_loops c.cd_res) + cstrs + | Type_record(l, _rep) -> + List.iter (fun l -> mark_loops l.ld_type) l + | Type_open -> () + end; -open Misc -open Path -open Typedtree -open Types + let type_param = + function + | Otyp_var (_, id) -> id + | _ -> "?" + in + let type_defined decl = + let abstr = + match decl.type_kind with + Type_abstract -> + decl.type_manifest = None || decl.type_private = Private + | Type_record _ -> + decl.type_private = Private + | Type_variant tll -> + decl.type_private = Private || + List.exists (fun cd -> cd.cd_res <> None) tll + | Type_open -> + decl.type_manifest = None + in + let vari = + List.map2 + (fun ty v -> + if abstr || not (is_Tvar (repr ty)) then Variance.get_upper v + else (true,true)) + decl.type_params decl.type_variance + in + (Ident.name id, + List.map2 (fun ty cocn -> type_param (tree_of_typexp false ty), cocn) + params vari) + in + let tree_of_manifest ty1 = + match ty_manifest with + | None -> ty1 + | Some ty -> Otyp_manifest (tree_of_typexp false ty, ty1) + in + let (name, args) = type_defined decl in + let constraints = tree_of_constraints params in + let ty, priv = + match decl.type_kind with + | Type_abstract -> + begin match ty_manifest with + | None -> (Otyp_abstract, Public) + | Some ty -> + tree_of_typexp false ty, decl.type_private + end + | Type_variant cstrs -> + tree_of_manifest (Otyp_sum (List.map tree_of_constructor cstrs)), + decl.type_private + | Type_record(lbls, _rep) -> + tree_of_manifest (Otyp_record (List.map tree_of_label lbls)), + decl.type_private + | Type_open -> + tree_of_manifest Otyp_open, + decl.type_private + in + let immediate = + Builtin_attributes.immediate decl.type_attributes + in + { otype_name = name; + otype_params = args; + otype_type = ty; + otype_private = priv; + otype_immediate = immediate; + otype_unboxed = decl.type_unboxed.unboxed; + otype_cstrs = constraints } -type symptom = - Missing_field of Ident.t * Location.t * string (* kind *) - | Value_descriptions of Ident.t * value_description * value_description - | Type_declarations of Ident.t * type_declaration - * type_declaration * Includecore.type_mismatch list - | Extension_constructors of - Ident.t * extension_constructor * extension_constructor - | Module_types of module_type * module_type - | Modtype_infos of Ident.t * modtype_declaration * modtype_declaration - | Modtype_permutation - | Interface_mismatch of string * string - | Class_type_declarations of - Ident.t * class_type_declaration * class_type_declaration * - Ctype.class_match_failure list - | Class_declarations of - Ident.t * class_declaration * class_declaration * - Ctype.class_match_failure list - | Unbound_modtype_path of Path.t - | Unbound_module_path of Path.t - | Invalid_module_alias of Path.t +and tree_of_constructor_arguments = function + | Cstr_tuple l -> tree_of_typlist false l + | Cstr_record l -> [ Otyp_record (List.map tree_of_label l) ] + +and tree_of_constructor cd = + let name = Ident.name cd.cd_id in + let arg () = tree_of_constructor_arguments cd.cd_args in + match cd.cd_res with + | None -> (name, arg (), None) + | Some res -> + let nm = !names in + names := []; + let ret = tree_of_typexp false res in + let args = arg () in + names := nm; + (name, args, Some ret) -type pos = - Module of Ident.t | Modtype of Ident.t | Arg of Ident.t | Body of Ident.t -type error = pos list * Env.t * symptom +and tree_of_label l = + (Ident.name l.ld_id, l.ld_mutable = Mutable, tree_of_typexp false l.ld_type) -exception Error of error list +let tree_of_type_declaration id decl rs = + Osig_type (tree_of_type_decl id decl, tree_of_rec rs) -(* All functions "blah env x1 x2" check that x1 is included in x2, - i.e. that x1 is the type of an implementation that fulfills the - specification x2. If not, Error is raised with a backtrace of the error. *) +let type_declaration id ppf decl = + !Oprint.out_sig_item ppf (tree_of_type_declaration id decl Trec_first) -(* Inclusion between value descriptions *) +let constructor_arguments ppf a = + let tys = tree_of_constructor_arguments a in + !Oprint.out_type ppf (Otyp_tuple tys) -let value_descriptions ~loc env cxt subst id vd1 vd2 = - Cmt_format.record_value_dependency vd1 vd2; - Env.mark_value_used env (Ident.name id) vd1; - let vd2 = Subst.value_description subst vd2 in - try +(* Print an extension declaration *) - Includecore.value_descriptions ~loc env id vd1 vd2 - - with Includecore.Dont_match -> - raise(Error[cxt, env, Value_descriptions(id, vd1, vd2)]) +let tree_of_extension_constructor id ext es = + reset (); + let ty_name = Path.name ext.ext_type_path in + let ty_params = filter_params ext.ext_type_params in + List.iter add_alias ty_params; + List.iter mark_loops ty_params; + List.iter check_name_of_type (List.map proxy ty_params); + mark_loops_constructor_arguments ext.ext_args; + may mark_loops ext.ext_ret_type; + let type_param = + function + | Otyp_var (_, id) -> id + | _ -> "?" + in + let ty_params = + List.map (fun ty -> type_param (tree_of_typexp false ty)) ty_params + in + let name = Ident.name id in + let args, ret = + match ext.ext_ret_type with + | None -> (tree_of_constructor_arguments ext.ext_args, None) + | Some res -> + let nm = !names in + names := []; + let ret = tree_of_typexp false res in + let args = tree_of_constructor_arguments ext.ext_args in + names := nm; + (args, Some ret) + in + let ext = + { oext_name = name; + oext_type_name = ty_name; + oext_type_params = ty_params; + oext_args = args; + oext_ret_type = ret; + oext_private = ext.ext_private } + in + let es = + match es with + Text_first -> Oext_first + | Text_next -> Oext_next + | Text_exception -> Oext_exception + in + Osig_typext (ext, es) -(* Inclusion between type declarations *) +let extension_constructor id ppf ext = + !Oprint.out_sig_item ppf (tree_of_extension_constructor id ext Text_first) -let type_declarations ~loc env ?(old_env=env) cxt subst id decl1 decl2 = - Env.mark_type_used env (Ident.name id) decl1; - let decl2 = Subst.type_declaration subst decl2 in - let err = - Includecore.type_declarations ~loc env (Ident.name id) decl1 id decl2 +(* Print a value declaration *) + +let tree_of_value_description id decl = + (* Format.eprintf "@[%a@]@." raw_type_expr decl.val_type; *) + let id = Ident.name id in + let ty = tree_of_type_scheme decl.val_type in + let vd = + { oval_name = id; + oval_type = ty; + oval_prims = []; + oval_attributes = [] } in - if err <> [] then - raise(Error[cxt, old_env, Type_declarations(id, decl1, decl2, err)]) + let vd = + match decl.val_kind with + | Val_prim p -> Primitive.print p vd + | _ -> vd + in + Osig_value vd -(* Inclusion between extension constructors *) +let value_description id ppf decl = + !Oprint.out_sig_item ppf (tree_of_value_description id decl) -let extension_constructors ~loc env cxt subst id ext1 ext2 = - let ext2 = Subst.extension_constructor subst ext2 in - if Includecore.extension_constructors ~loc env id ext1 ext2 - then () - else raise(Error[cxt, env, Extension_constructors(id, ext1, ext2)]) +(* Print a class type *) -(* Inclusion between class declarations *) +let method_type (_, kind, ty) = + match field_kind_repr kind, repr ty with + Fpresent, {desc=Tpoly(ty, tyl)} -> (ty, tyl) + | _ , ty -> (ty, []) -let class_type_declarations ~loc ~old_env env cxt subst id decl1 decl2 = - let decl2 = Subst.cltype_declaration subst decl2 in - match Includeclass.class_type_declarations ~loc env decl1 decl2 with - [] -> () - | reason -> - raise(Error[cxt, old_env, - Class_type_declarations(id, decl1, decl2, reason)]) +let tree_of_metho sch concrete csil (lab, kind, ty) = + if lab <> dummy_method then begin + let kind = field_kind_repr kind in + let priv = kind <> Fpresent in + let virt = not (Concr.mem lab concrete) in + let (ty, tyl) = method_type (lab, kind, ty) in + let tty = tree_of_typexp sch ty in + remove_names tyl; + Ocsg_method (lab, priv, virt, tty) :: csil + end + else csil -let class_declarations ~old_env env cxt subst id decl1 decl2 = - let decl2 = Subst.class_declaration subst decl2 in - match Includeclass.class_declarations env decl1 decl2 with - [] -> () - | reason -> - raise(Error[cxt, old_env, Class_declarations(id, decl1, decl2, reason)]) +let rec prepare_class_type params = function + | Cty_constr (_p, tyl, cty) -> + let sty = Ctype.self_type cty in + if List.memq (proxy sty) !visited_objects + || not (List.for_all is_Tvar params) + || List.exists (deep_occur sty) tyl + then prepare_class_type params cty + else List.iter mark_loops tyl + | Cty_signature sign -> + let sty = repr sign.csig_self in + (* Self may have a name *) + let px = proxy sty in + if List.memq px !visited_objects then add_alias sty + else visited_objects := px :: !visited_objects; + let (fields, _) = + Ctype.flatten_fields (Ctype.object_fields sign.csig_self) + in + List.iter (fun met -> mark_loops (fst (method_type met))) fields; + Vars.iter (fun _ (_, _, ty) -> mark_loops ty) sign.csig_vars + | Cty_arrow (_, ty, cty) -> + mark_loops ty; + prepare_class_type params cty -(* Expand a module type identifier when possible *) +let rec tree_of_class_type sch params = + function + | Cty_constr (p', tyl, cty) -> + let sty = Ctype.self_type cty in + if List.memq (proxy sty) !visited_objects + || not (List.for_all is_Tvar params) + then + tree_of_class_type sch params cty + else + Octy_constr (tree_of_path p', tree_of_typlist true tyl) + | Cty_signature sign -> + let sty = repr sign.csig_self in + let self_ty = + if is_aliased sty then + Some (Otyp_var (false, name_of_type new_name (proxy sty))) + else None + in + let (fields, _) = + Ctype.flatten_fields (Ctype.object_fields sign.csig_self) + in + let csil = [] in + let csil = + List.fold_left + (fun csil (ty1, ty2) -> Ocsg_constraint (ty1, ty2) :: csil) + csil (tree_of_constraints params) + in + let all_vars = + Vars.fold (fun l (m, v, t) all -> (l, m, v, t) :: all) sign.csig_vars [] + in + (* Consequence of PR#3607: order of Map.fold has changed! *) + let all_vars = List.rev all_vars in + let csil = + List.fold_left + (fun csil (l, m, v, t) -> + Ocsg_value (l, m = Mutable, v = Virtual, tree_of_typexp sch t) + :: csil) + csil all_vars + in + let csil = + List.fold_left (tree_of_metho sch sign.csig_concr) csil fields + in + Octy_signature (self_ty, List.rev csil) + | Cty_arrow (l, ty, cty) -> + let lab = + if !print_labels || is_optional l then string_of_label l else "" + in + let ty = + if is_optional l then + match (repr ty).desc with + | Tconstr(path, [ty], _) when Path.same path Predef.path_option -> ty + | _ -> newconstr (Path.Pident(Ident.create "")) [] + else ty in + let tr = tree_of_typexp sch ty in + Octy_arrow (lab, tr, tree_of_class_type sch params cty) -exception Dont_match +let class_type ppf cty = + reset (); + prepare_class_type [] cty; + !Oprint.out_class_type ppf (tree_of_class_type false [] cty) -let may_expand_module_path env path = - try ignore (Env.find_modtype_expansion path env); true - with Not_found -> false +let tree_of_class_param param variance = + (match tree_of_typexp true param with + Otyp_var (_, s) -> s + | _ -> "?"), + if is_Tvar (repr param) then (true, true) else variance -let expand_module_path env cxt path = - try - Env.find_modtype_expansion path env - with Not_found -> - raise(Error[cxt, env, Unbound_modtype_path path]) +let class_variance = + List.map Variance.(fun v -> mem May_pos v, mem May_neg v) -let expand_module_alias env cxt path = - try (Env.find_module path env).md_type - with Not_found -> - raise(Error[cxt, env, Unbound_module_path path]) +let tree_of_class_declaration id cl rs = + let params = filter_params cl.cty_params in -(* -let rec normalize_module_path env cxt path = - match expand_module_alias env cxt path with - Mty_alias path' -> normalize_module_path env cxt path' - | _ -> path -*) + reset (); + List.iter add_alias params; + prepare_class_type params cl.cty_type; + let sty = Ctype.self_type cl.cty_type in + List.iter mark_loops params; -(* Extract name, kind and ident from a signature item *) + List.iter check_name_of_type (List.map proxy params); + if is_aliased sty then check_name_of_type (proxy sty); -type field_desc = - Field_value of string - | Field_type of string - | Field_typext of string - | Field_module of string - | Field_modtype of string - | Field_class of string - | Field_classtype of string + let vir_flag = cl.cty_new = None in + Osig_class + (vir_flag, Ident.name id, + List.map2 tree_of_class_param params (class_variance cl.cty_variance), + tree_of_class_type true params cl.cty_type, + tree_of_rec rs) -let kind_of_field_desc = function - | Field_value _ -> "value" - | Field_type _ -> "type" - | Field_typext _ -> "extension constructor" - | Field_module _ -> "module" - | Field_modtype _ -> "module type" - | Field_class _ -> "class" - | Field_classtype _ -> "class type" +let class_declaration id ppf cl = + !Oprint.out_sig_item ppf (tree_of_class_declaration id cl Trec_first) -let item_ident_name = function - Sig_value(id, d) -> (id, d.val_loc, Field_value(Ident.name id)) - | Sig_type(id, d, _) -> (id, d.type_loc, Field_type(Ident.name id)) - | Sig_typext(id, d, _) -> (id, d.ext_loc, Field_typext(Ident.name id)) - | Sig_module(id, d, _) -> (id, d.md_loc, Field_module(Ident.name id)) - | Sig_modtype(id, d) -> (id, d.mtd_loc, Field_modtype(Ident.name id)) - | Sig_class(id, d, _) -> (id, d.cty_loc, Field_class(Ident.name id)) - | Sig_class_type(id, d, _) -> (id, d.clty_loc, Field_classtype(Ident.name id)) +let tree_of_cltype_declaration id cl rs = + let params = List.map repr cl.clty_params in -let is_runtime_component = function - | Sig_value(_,{val_kind = Val_prim _}) - | Sig_type(_,_,_) - | Sig_modtype(_,_) - | Sig_class_type(_,_,_) -> false - | Sig_value(_,_) - | Sig_typext(_,_,_) - | Sig_module(_,_,_) - | Sig_class(_, _,_) -> true + reset (); + List.iter add_alias params; + prepare_class_type params cl.clty_type; + let sty = Ctype.self_type cl.clty_type in + List.iter mark_loops params; -(* Print a coercion *) + List.iter check_name_of_type (List.map proxy params); + if is_aliased sty then check_name_of_type (proxy sty); -let rec print_list pr ppf = function - [] -> () - | [a] -> pr ppf a - | a :: l -> pr ppf a; Format.fprintf ppf ";@ "; print_list pr ppf l -let print_list pr ppf l = - Format.fprintf ppf "[@[%a@]]" (print_list pr) l + let sign = Ctype.signature_of_class_type cl.clty_type in -let rec print_coercion ppf c = - let pr fmt = Format.fprintf ppf fmt in - match c with - Tcoerce_none -> pr "id" - | Tcoerce_structure (fl, nl, _) -> - pr "@[<2>struct@ %a@ %a@]" - (print_list print_coercion2) fl - (print_list print_coercion3) nl - | Tcoerce_functor (inp, out) -> - pr "@[<2>functor@ (%a)@ (%a)@]" - print_coercion inp - print_coercion out - | Tcoerce_primitive {pc_desc; pc_env = _; pc_type} -> - pr "prim %s@ (%a)" pc_desc.Primitive.prim_name - Printtyp.raw_type_expr pc_type - | Tcoerce_alias (p, c) -> - pr "@[<2>alias %a@ (%a)@]" - Printtyp.path p - print_coercion c -and print_coercion2 ppf (n, c) = - Format.fprintf ppf "@[%d,@ %a@]" n print_coercion c -and print_coercion3 ppf (i, n, c) = - Format.fprintf ppf "@[%s, %d,@ %a@]" - (Ident.unique_name i) n print_coercion c + let virt = + let (fields, _) = + Ctype.flatten_fields (Ctype.object_fields sign.csig_self) in + List.exists + (fun (lab, _, _) -> + not (lab = dummy_method || Concr.mem lab sign.csig_concr)) + fields + || Vars.fold (fun _ (_,vr,_) b -> vr = Virtual || b) sign.csig_vars false + in -(* Simplify a structure coercion *) + Osig_class_type + (virt, Ident.name id, + List.map2 tree_of_class_param params (class_variance cl.clty_variance), + tree_of_class_type true params cl.clty_type, + tree_of_rec rs) -let simplify_structure_coercion cc id_pos_list runtime_fields = - let rec is_identity_coercion pos = function - | [] -> - true - | (n, c) :: rem -> - n = pos && c = Tcoerce_none && is_identity_coercion (pos + 1) rem in - if is_identity_coercion 0 cc - then Tcoerce_none - else Tcoerce_structure (cc, id_pos_list, runtime_fields) +let cltype_declaration id ppf cl = + !Oprint.out_sig_item ppf (tree_of_cltype_declaration id cl Trec_first) -(* Inclusion between module types. - Return the restriction that transforms a value of the smaller type - into a value of the bigger type. *) +(* Print a module type *) -let rec modtypes ~loc env cxt subst mty1 mty2 = - try - try_modtypes ~loc env cxt subst mty1 mty2 - with - Dont_match -> - raise(Error[cxt, env, Module_types(mty1, Subst.modtype subst mty2)]) - | Error reasons as err -> - match mty1, mty2 with - Mty_alias _, _ - | _, Mty_alias _ -> raise err - | _ -> - raise(Error((cxt, env, Module_types(mty1, Subst.modtype subst mty2)) - :: reasons)) +let wrap_env fenv ftree arg = + let env = !printing_env in + set_printing_env (fenv env); + let tree = ftree arg in + set_printing_env env; + tree -and try_modtypes ~loc env cxt subst mty1 mty2 = - match (mty1, mty2) with - | (Mty_alias(pres1, p1), Mty_alias(pres2, p2)) -> begin - if Env.is_functor_arg p2 env then - raise (Error[cxt, env, Invalid_module_alias p2]); - if not (Path.same p1 p2) then begin - let p1 = Env.normalize_path None env p1 - and p2 = Env.normalize_path None env (Subst.module_path subst p2) in - if not (Path.same p1 p2) then raise Dont_match - end; - match pres1, pres2 with - | Mta_present, Mta_present -> Tcoerce_none - (* Should really be Tcoerce_ignore if it existed *) - | Mta_absent, Mta_absent -> Tcoerce_none - (* Should really be Tcoerce_empty if it existed *) - | Mta_present, Mta_absent -> Tcoerce_none - | Mta_absent, Mta_present -> - let p1 = try - Env.normalize_path (Some Location.none) env p1 - with Env.Error (Env.Missing_module (_, _, path)) -> - raise (Error[cxt, env, Unbound_module_path path]) - in - Tcoerce_alias (p1, Tcoerce_none) - end - | (Mty_alias(pres1, p1), _) -> begin - let p1 = try - Env.normalize_path (Some Location.none) env p1 - with Env.Error (Env.Missing_module (_, _, path)) -> - raise (Error[cxt, env, Unbound_module_path path]) - in - let mty1 = - Mtype.strengthen ~aliasable:true env - (expand_module_alias env cxt p1) p1 +let filter_rem_sig item rem = + match item, rem with + | Sig_class _, ctydecl :: tydecl1 :: tydecl2 :: rem -> + ([ctydecl; tydecl1; tydecl2], rem) + | Sig_class_type _, tydecl1 :: tydecl2 :: rem -> + ([tydecl1; tydecl2], rem) + | _ -> + ([], rem) + +let dummy = + { type_params = []; type_arity = 0; type_kind = Type_abstract; + type_private = Public; type_manifest = None; type_variance = []; + type_newtype_level = None; type_loc = Location.none; + type_attributes = []; + type_immediate = false; + type_unboxed = unboxed_false_default_false; + } + +let hide_rec_items = function + | Sig_type(id, _decl, rs) ::rem + when rs = Trec_first && not !Clflags.real_paths -> + let rec get_ids = function + Sig_type (id, _, Trec_next) :: rem -> + id :: get_ids rem + | _ -> [] in - let cc = modtypes ~loc env cxt subst mty1 mty2 in - match pres1 with - | Mta_present -> cc - | Mta_absent -> Tcoerce_alias (p1, cc) - end - | (Mty_ident p1, _) when may_expand_module_path env p1 -> - try_modtypes ~loc env cxt subst (expand_module_path env cxt p1) mty2 - | (_, Mty_ident _) -> - try_modtypes2 ~loc env cxt mty1 (Subst.modtype subst mty2) - | (Mty_signature sig1, Mty_signature sig2) -> - signatures ~loc env cxt subst sig1 sig2 - | (Mty_functor(param1, None, res1), Mty_functor(_param2, None, res2)) -> - begin match modtypes ~loc env (Body param1::cxt) subst res1 res2 with - Tcoerce_none -> Tcoerce_none - | cc -> Tcoerce_functor (Tcoerce_none, cc) - end - | (Mty_functor(param1, Some arg1, res1), - Mty_functor(param2, Some arg2, res2)) -> - let arg2' = Subst.modtype subst arg2 in - let cc_arg = modtypes ~loc env (Arg param1::cxt) Subst.identity arg2' arg1 in - let cc_res = - modtypes ~loc (Env.add_module param1 arg2' env) (Body param1::cxt) - (Subst.add_module param2 (Pident param1) subst) res1 res2 in - begin match (cc_arg, cc_res) with - (Tcoerce_none, Tcoerce_none) -> Tcoerce_none - | _ -> Tcoerce_functor(cc_arg, cc_res) - end - | (_, _) -> - raise Dont_match + let ids = id :: get_ids rem in + set_printing_env + (List.fold_right + (fun id -> Env.add_type ~check:false (Ident.rename id) dummy) + ids !printing_env) + | _ -> () -and try_modtypes2 ~loc env cxt mty1 mty2 = - (* mty2 is an identifier *) - match (mty1, mty2) with - (Mty_ident p1, Mty_ident p2) - when Path.same (Env.normalize_path_prefix None env p1) - (Env.normalize_path_prefix None env p2) -> - Tcoerce_none - | (_, Mty_ident p2) when may_expand_module_path env p2 -> - try_modtypes ~loc env cxt Subst.identity mty1 (expand_module_path env cxt p2) - | (_, _) -> - raise Dont_match +let rec tree_of_modtype ?(ellipsis=false) = function + | Mty_ident p -> + Omty_ident (tree_of_path p) + | Mty_signature sg -> + Omty_signature (if ellipsis then [Osig_ellipsis] + else tree_of_signature sg) + | Mty_functor(param, ty_arg, ty_res) -> + let res = + match ty_arg with None -> tree_of_modtype ~ellipsis ty_res + | Some mty -> + wrap_env (Env.add_module ~arg:true param mty) + (tree_of_modtype ~ellipsis) ty_res + in + Omty_functor (Ident.name param, + may_map (tree_of_modtype ~ellipsis:false) ty_arg, res) + | Mty_alias(_, p) -> + Omty_alias (tree_of_path p) -(* Inclusion between signatures *) +and tree_of_signature sg = + wrap_env (fun env -> env) (tree_of_signature_rec !printing_env false) sg -and signatures ~loc env cxt subst sig1 sig2 = - (* Environment used to check inclusion of components *) - let new_env = - Env.add_signature sig1 (Env.in_signature true env) in - (* Keep ids for module aliases *) - let (id_pos_list,_) = - List.fold_left - (fun (l,pos) -> function - Sig_module (id, _, _) -> - ((id,pos,Tcoerce_none)::l , pos+1) - | item -> (l, if is_runtime_component item then pos+1 else pos)) - ([], 0) sig1 in +and tree_of_signature_rec env' in_type_group = function + [] -> [] + | item :: rem as items -> + let in_type_group = + match in_type_group, item with + true, Sig_type (_, _, Trec_next) -> true + | _, Sig_type (_, _, (Trec_not | Trec_first)) -> + set_printing_env env'; true + | _ -> set_printing_env env'; false + in + let (sg, rem) = filter_rem_sig item rem in + hide_rec_items items; + let trees = trees_of_sigitem item in + let env' = Env.add_signature (item :: sg) env' in + trees @ tree_of_signature_rec env' in_type_group rem - let runtime_fields = - let get_id = function - | Sig_value (i,_) - | Sig_module (i,_,_) - | Sig_typext (i,_,_) - | Sig_modtype(i,_) - | Sig_class (i,_,_) - | Sig_class_type(i,_,_) - | Sig_type(i,_,_) -> Ident.name i in - List.fold_right (fun item fields -> - if is_runtime_component item then get_id item :: fields else fields) sig2 [] in +and trees_of_sigitem = function + | Sig_value(id, decl) -> + [tree_of_value_description id decl] + | Sig_type(id, _, _) when is_row_name (Ident.name id) -> + [] + | Sig_type(id, decl, rs) -> + [tree_of_type_declaration id decl rs] + | Sig_typext(id, ext, es) -> + [tree_of_extension_constructor id ext es] + | Sig_module(id, md, rs) -> + let ellipsis = + List.exists (function ({txt="..."}, Parsetree.PStr []) -> true + | _ -> false) + md.md_attributes in + [tree_of_module id md.md_type rs ~ellipsis] + | Sig_modtype(id, decl) -> + [tree_of_modtype_declaration id decl] + | Sig_class(id, decl, rs) -> + [tree_of_class_declaration id decl rs] + | Sig_class_type(id, decl, rs) -> + [tree_of_cltype_declaration id decl rs] - (* Build a table of the components of sig1, along with their positions. - The table is indexed by kind and name of component *) - let rec build_component_table pos tbl = function - [] -> pos, tbl - | item :: rem -> - let (id, _loc, name) = item_ident_name item in - let nextpos = if is_runtime_component item then pos + 1 else pos in - build_component_table nextpos - (Tbl.add name (id, item, pos) tbl) rem in - let len1, comps1 = - build_component_table 0 Tbl.empty sig1 in - let len2 = - List.fold_left - (fun n i -> if is_runtime_component i then n + 1 else n) - 0 - sig2 +and tree_of_modtype_declaration id decl = + let mty = + match decl.mtd_type with + | None -> Omty_abstract + | Some mty -> tree_of_modtype mty in - (* Pair each component of sig2 with a component of sig1, - identifying the names along the way. - Return a coercion list indicating, for all run-time components - of sig2, the position of the matching run-time components of sig1 - and the coercion to be applied to it. *) - let rec pair_components subst paired unpaired = function - [] -> - begin match unpaired with - [] -> - let cc = - signature_components ~loc env new_env cxt subst - (List.rev paired) - in - if len1 = len2 then (* see PR#5098 *) - simplify_structure_coercion cc id_pos_list runtime_fields - else - Tcoerce_structure (cc, id_pos_list, runtime_fields) - | _ -> raise(Error unpaired) - end - | item2 :: rem -> - let (id2, loc, name2) = item_ident_name item2 in - let name2, report = - match item2, name2 with - Sig_type (_, {type_manifest=None}, _), Field_type s - when Btype.is_row_name s -> - (* Do not report in case of failure, - as the main type will generate an error *) - Field_type (String.sub s 0 (String.length s - 4)), false - | _ -> name2, true - in - begin try - let (id1, item1, pos1) = Tbl.find name2 comps1 in - let new_subst = - match item2 with - Sig_type _ -> - Subst.add_type id2 (Pident id1) subst - | Sig_module _ -> - Subst.add_module id2 (Pident id1) subst - | Sig_modtype _ -> - Subst.add_modtype id2 (Mty_ident (Pident id1)) subst - | Sig_value _ | Sig_typext _ - | Sig_class _ | Sig_class_type _ -> - subst - in - pair_components new_subst - ((item1, item2, pos1) :: paired) unpaired rem - with Not_found -> - let unpaired = - if report then - (cxt, env, Missing_field (id2, loc, kind_of_field_desc name2)) :: - unpaired - else unpaired in - pair_components subst paired unpaired rem - end in - (* Do the pairing and checking, and return the final coercion *) - pair_components subst [] [] sig2 + Osig_modtype (Ident.name id, mty) -(* Inclusion between signature components *) +and tree_of_module id ?ellipsis mty rs = + Osig_module (Ident.name id, tree_of_modtype ?ellipsis mty, tree_of_rec rs) -and signature_components ~loc old_env env cxt subst paired = - let comps_rec rem = signature_components ~loc old_env env cxt subst rem in - match paired with - [] -> [] - | (Sig_value(id1, valdecl1), Sig_value(_id2, valdecl2), pos) :: rem -> - let cc = value_descriptions ~loc env cxt subst id1 valdecl1 valdecl2 in - begin match valdecl2.val_kind with - Val_prim _ -> comps_rec rem - | _ -> (pos, cc) :: comps_rec rem +let modtype ppf mty = !Oprint.out_module_type ppf (tree_of_modtype mty) +let modtype_declaration id ppf decl = + !Oprint.out_sig_item ppf (tree_of_modtype_declaration id decl) + +(* For the toplevel: merge with tree_of_signature? *) + +(* Refresh weak variable map in the toplevel *) +let refresh_weak () = + let refresh t name (m,s) = + if is_non_gen true (repr t) then + begin + TypeMap.add t name m, + StringSet.add name s + end + else m, s in + let m, s = + TypeMap.fold refresh !weak_var_map (TypeMap.empty ,StringSet.empty) in + named_weak_vars := s; + weak_var_map := m + +let print_items showval env x = + refresh_weak(); + let rec print showval env = function + | [] -> [] + | item :: rem as items -> + let (_sg, rem) = filter_rem_sig item rem in + hide_rec_items items; + let trees = trees_of_sigitem item in + List.map (fun d -> (d, showval env item)) trees @ + print showval env rem in + print showval env x + +(* Print a signature body (used by -i when compiling a .ml) *) + +let print_signature ppf tree = + fprintf ppf "@[%a@]" !Oprint.out_signature tree + +let signature ppf sg = + fprintf ppf "%a" print_signature (tree_of_signature sg) + +(* Print an unification error *) + +let same_path t t' = + let t = repr t and t' = repr t' in + t == t' || + match t.desc, t'.desc with + Tconstr(p,tl,_), Tconstr(p',tl',_) -> + let (p1, s1) = best_type_path p and (p2, s2) = best_type_path p' in + begin match s1, s2 with + Nth n1, Nth n2 when n1 = n2 -> true + | (Id | Map _), (Id | Map _) when Path.same p1 p2 -> + let tl = apply_subst s1 tl and tl' = apply_subst s2 tl' in + List.length tl = List.length tl' && + List.for_all2 same_type tl tl' + | _ -> false end - | (Sig_type(id1, tydecl1, _), Sig_type(_id2, tydecl2, _), _pos) :: rem -> - type_declarations ~loc ~old_env env cxt subst id1 tydecl1 tydecl2; - comps_rec rem - | (Sig_typext(id1, ext1, _), Sig_typext(_id2, ext2, _), pos) - :: rem -> - extension_constructors ~loc env cxt subst id1 ext1 ext2; - (pos, Tcoerce_none) :: comps_rec rem - | (Sig_module(id1, mty1, _), Sig_module(_id2, mty2, _), pos) :: rem -> - let cc = module_declarations ~loc env cxt subst id1 mty1 mty2 in - (pos, cc) :: comps_rec rem - | (Sig_modtype(id1, info1), Sig_modtype(_id2, info2), _pos) :: rem -> - modtype_infos ~loc env cxt subst id1 info1 info2; - comps_rec rem - | (Sig_class(id1, decl1, _), Sig_class(_id2, decl2, _), pos) :: rem -> - class_declarations ~old_env env cxt subst id1 decl1 decl2; - (pos, Tcoerce_none) :: comps_rec rem - | (Sig_class_type(id1, info1, _), - Sig_class_type(_id2, info2, _), _pos) :: rem -> - class_type_declarations ~loc ~old_env env cxt subst id1 info1 info2; - comps_rec rem | _ -> - assert false + false -and module_declarations ~loc env cxt subst id1 md1 md2 = - Builtin_attributes.check_deprecated_inclusion - ~def:md1.md_loc - ~use:md2.md_loc - loc - md1.md_attributes md2.md_attributes - (Ident.name id1); - let p1 = Pident id1 in - Env.mark_module_used env (Ident.name id1) md1.md_loc; - modtypes ~loc env (Module id1::cxt) subst - (Mtype.strengthen ~aliasable:true env md1.md_type p1) md2.md_type +let type_expansion t ppf t' = + if same_path t t' + then begin add_delayed (proxy t); type_expr ppf t end + else + let t' = if proxy t == proxy t' then unalias t' else t' in + fprintf ppf "@[<2>%a@ =@ %a@]" type_expr t type_expr t' -(* Inclusion between module type specifications *) +let type_path_expansion tp ppf tp' = + if Path.same tp tp' then path ppf tp else + fprintf ppf "@[<2>%a@ =@ %a@]" path tp path tp' -and modtype_infos ~loc env cxt subst id info1 info2 = - Builtin_attributes.check_deprecated_inclusion - ~def:info1.mtd_loc - ~use:info2.mtd_loc - loc - info1.mtd_attributes info2.mtd_attributes - (Ident.name id); - let info2 = Subst.modtype_declaration subst info2 in - let cxt' = Modtype id :: cxt in - try - match (info1.mtd_type, info2.mtd_type) with - (None, None) -> () - | (Some _, None) -> () - | (Some mty1, Some mty2) -> - check_modtype_equiv ~loc env cxt' mty1 mty2 - | (None, Some mty2) -> - check_modtype_equiv ~loc env cxt' (Mty_ident(Pident id)) mty2 - with Error reasons -> - raise(Error((cxt, env, Modtype_infos(id, info1, info2)) :: reasons)) +let rec trace fst txt ppf = function + | (t1, t1') :: (t2, t2') :: rem -> + if not fst then fprintf ppf "@,"; + fprintf ppf "@[Type@;<1 2>%a@ %s@;<1 2>%a@] %a" + (type_expansion t1) t1' txt (type_expansion t2) t2' + (trace false txt) rem + | _ -> () -and check_modtype_equiv ~loc env cxt mty1 mty2 = - match - (modtypes ~loc env cxt Subst.identity mty1 mty2, - modtypes ~loc env cxt Subst.identity mty2 mty1) - with - (Tcoerce_none, Tcoerce_none) -> () - | (_c1, _c2) -> - (* Format.eprintf "@[c1 = %a@ c2 = %a@]@." - print_coercion _c1 print_coercion _c2; *) - raise(Error [cxt, env, Modtype_permutation]) +let rec filter_trace keep_last = function + | (_, t1') :: (_, t2') :: [] when is_Tvar t1' || is_Tvar t2' -> + [] + | (t1, t1') :: (t2, t2') :: rem -> + let rem' = filter_trace keep_last rem in + if is_constr_row ~allow_ident:true t1' + || is_constr_row ~allow_ident:true t2' + || same_path t1 t1' && same_path t2 t2' && not (keep_last && rem' = []) + then rem' + else (t1, t1') :: (t2, t2') :: rem' + | _ -> [] -(* Simplified inclusion check between module types (for Env) *) +let rec type_path_list ppf = function + | [tp, tp'] -> type_path_expansion tp ppf tp' + | (tp, tp') :: rem -> + fprintf ppf "%a@;<2 0>%a" + (type_path_expansion tp) tp' + type_path_list rem + | [] -> () -let can_alias env path = - let rec no_apply = function - | Pident _ -> true - | Pdot(p, _, _) -> no_apply p - | Papply _ -> false - in - no_apply path && not (Env.is_functor_arg path env) +(* Hide variant name and var, to force printing the expanded type *) +let hide_variant_name t = + match repr t with + | {desc = Tvariant row} as t when (row_repr row).row_name <> None -> + newty2 t.level + (Tvariant {(row_repr row) with row_name = None; + row_more = newvar2 (row_more row).level}) + | _ -> t -let check_modtype_inclusion ~loc env mty1 path1 mty2 = - try - let aliasable = can_alias env path1 in - ignore(modtypes ~loc env [] Subst.identity - (Mtype.strengthen ~aliasable env mty1 path1) mty2) - with Error _ -> - raise Not_found +let prepare_expansion (t, t') = + let t' = hide_variant_name t' in + mark_loops t; + if not (same_path t t') then mark_loops t'; + (t, t') -let _ = Env.check_modtype_inclusion := check_modtype_inclusion +let may_prepare_expansion compact (t, t') = + match (repr t').desc with + Tvariant _ | Tobject _ when compact -> + mark_loops t; (t, t) + | _ -> prepare_expansion (t, t') -(* Check that an implementation of a compilation unit meets its - interface. *) +let print_tags ppf fields = + match fields with [] -> () + | (t, _) :: fields -> + fprintf ppf "`%s" t; + List.iter (fun (t, _) -> fprintf ppf ",@ `%s" t) fields -let compunit env impl_name impl_sig intf_name intf_sig = - try - signatures ~loc:(Location.in_file impl_name) env [] Subst.identity - impl_sig intf_sig - with Error reasons -> - raise(Error(([], Env.empty,Interface_mismatch(impl_name, intf_name)) - :: reasons)) +let has_explanation t3 t4 = + match t3.desc, t4.desc with + Tfield _, (Tnil|Tconstr _) | (Tnil|Tconstr _), Tfield _ + | Tnil, Tconstr _ | Tconstr _, Tnil + | _, Tvar _ | Tvar _, _ + | Tvariant _, Tvariant _ -> true + | Tfield (l,_,_,{desc=Tnil}), Tfield (l',_,_,{desc=Tnil}) -> l = l' + | _ -> false -(* Hide the context and substitution parameters to the outside world *) +let rec mismatch = function + (_, t) :: (_, t') :: rem -> + begin match mismatch rem with + Some _ as m -> m + | None -> + if has_explanation t t' then Some(t,t') else None + end + | [] -> None + | _ -> assert false -let modtypes ~loc env mty1 mty2 = modtypes ~loc env [] Subst.identity mty1 mty2 -let signatures env sig1 sig2 = - signatures ~loc:Location.none env [] Subst.identity sig1 sig2 -let type_declarations ~loc env id decl1 decl2 = - type_declarations ~loc env [] Subst.identity id decl1 decl2 +let explanation unif t3 t4 ppf = + match t3.desc, t4.desc with + | Ttuple [], Tvar _ | Tvar _, Ttuple [] -> + fprintf ppf "@,Self type cannot escape its class" + | Tconstr (p, _, _), Tvar _ + when unif && t4.level < Path.binding_time p -> + fprintf ppf + "@,@[The type constructor@;<1 2>%a@ would escape its scope@]" + path p + | Tvar _, Tconstr (p, _, _) + when unif && t3.level < Path.binding_time p -> + fprintf ppf + "@,@[The type constructor@;<1 2>%a@ would escape its scope@]" + path p + | Tvar _, Tunivar _ | Tunivar _, Tvar _ -> + fprintf ppf "@,The universal variable %a would escape its scope" + type_expr (if is_Tunivar t3 then t3 else t4) + | Tvar _, _ | _, Tvar _ -> + let t, t' = if is_Tvar t3 then (t3, t4) else (t4, t3) in + if occur_in Env.empty t t' then + fprintf ppf "@,@[The type variable %a occurs inside@ %a@]" + type_expr t type_expr t' + else + fprintf ppf "@,@[This instance of %a is ambiguous:@ %s@]" + type_expr t' + "it would escape the scope of its equation" + | Tfield (lab, _, _, _), _ when lab = dummy_method -> + fprintf ppf + "@,Self type cannot be unified with a closed object type" + | _, Tfield (lab, _, _, _) when lab = dummy_method -> + fprintf ppf + "@,Self type cannot be unified with a closed object type" + | Tfield (l,_,_,{desc=Tnil}), Tfield (l',_,_,{desc=Tnil}) when l = l' -> + fprintf ppf "@,Types for method %s are incompatible" l + | (Tnil|Tconstr _), Tfield (l, _, _, _) -> + fprintf ppf + "@,@[The first object type has no method %s@]" l + | Tfield (l, _, _, _), (Tnil|Tconstr _) -> + fprintf ppf + "@,@[The second object type has no method %s@]" l + | Tnil, Tconstr _ | Tconstr _, Tnil -> + fprintf ppf + "@,@[The %s object type has an abstract row, it cannot be closed@]" + (if t4.desc = Tnil then "first" else "second") + | Tvariant row1, Tvariant row2 -> + let row1 = row_repr row1 and row2 = row_repr row2 in + begin match + row1.row_fields, row1.row_closed, row2.row_fields, row2.row_closed with + | [], true, [], true -> + fprintf ppf "@,These two variant types have no intersection" + | [], true, (_::_ as fields), _ -> + fprintf ppf + "@,@[The first variant type does not allow tag(s)@ @[%a@]@]" + print_tags fields + | (_::_ as fields), _, [], true -> + fprintf ppf + "@,@[The second variant type does not allow tag(s)@ @[%a@]@]" + print_tags fields + | [l1,_], true, [l2,_], true when l1 = l2 -> + fprintf ppf "@,Types for tag `%s are incompatible" l1 + | _ -> () + end + | _ -> () -(* -let modtypes env m1 m2 = - let c = modtypes env m1 m2 in - Format.eprintf "@[<2>modtypes@ %a@ %a =@ %a@]@." - Printtyp.modtype m1 Printtyp.modtype m2 - print_coercion c; - c -*) -(* Error report *) +let warn_on_missing_def env ppf t = + match t.desc with + | Tconstr (p,_,_) -> + begin + try + ignore(Env.find_type p env : Types.type_declaration) + with Not_found -> + fprintf ppf + "@,@[%a is abstract because no corresponding cmi file was found \ + in path.@]" path p + end + | _ -> () + +let explanation unif mis ppf = + match mis with + None -> () + | Some (t3, t4) -> explanation unif t3 t4 ppf + +let ident_same_name id1 id2 = + if Ident.equal id1 id2 && not (Ident.same id1 id2) then begin + add_unique id1; add_unique id2 + end + +let rec path_same_name p1 p2 = + match p1, p2 with + Pident id1, Pident id2 -> ident_same_name id1 id2 + | Pdot (p1, s1, _), Pdot (p2, s2, _) when s1 = s2 -> path_same_name p1 p2 + | Papply (p1, p1'), Papply (p2, p2') -> + path_same_name p1 p2; path_same_name p1' p2' + | _ -> () + +let type_same_name t1 t2 = + match (repr t1).desc, (repr t2).desc with + Tconstr (p1, _, _), Tconstr (p2, _, _) -> + path_same_name (fst (best_type_path p1)) (fst (best_type_path p2)) + | _ -> () + +let rec trace_same_names = function + (t1, t1') :: (t2, t2') :: rem -> + type_same_name t1 t2; type_same_name t1' t2'; trace_same_names rem + | _ -> () + +let unification_error env unif tr txt1 ppf txt2 = + reset (); + trace_same_names tr; + let tr = List.map (fun (t, t') -> (t, hide_variant_name t')) tr in + let mis = mismatch tr in + match tr with + | [] | _ :: [] -> assert false + | t1 :: t2 :: tr -> + try + let tr = filter_trace (mis = None) tr in + let t1, t1' = may_prepare_expansion (tr = []) t1 + and t2, t2' = may_prepare_expansion (tr = []) t2 in + print_labels := not !Clflags.classic; + let tr = List.map prepare_expansion tr in + fprintf ppf + "@[\ + @[%t@;<1 2>%a@ \ + %t@;<1 2>%a\ + @]%a%t\ + @]" + txt1 (type_expansion t1) t1' + txt2 (type_expansion t2) t2' + (trace false "is not compatible with type") tr + (explanation unif mis); + if env <> Env.empty + then begin + warn_on_missing_def env ppf t1; + warn_on_missing_def env ppf t2 + end; + print_labels := true + with exn -> + print_labels := true; + raise exn -open Format -open Printtyp +let report_unification_error ppf env ?(unif=true) + tr txt1 txt2 = + wrap_printing_env env (fun () -> unification_error env unif tr txt1 ppf txt2) +;; -let show_loc msg ppf loc = - let pos = loc.Location.loc_start in - if List.mem pos.Lexing.pos_fname [""; "_none_"; "//toplevel//"] then () - else fprintf ppf "@\n@[<2>%a:@ %s@]" Location.print_loc loc msg -let show_locs ppf (loc1, loc2) = - show_loc "Expected declaration" ppf loc2; - show_loc "Actual declaration" ppf loc1 +let super_type_expansion ~tag t ppf t' = + if same_path t t' then begin + Format.pp_open_tag ppf tag; + type_expr ppf t; + Format.pp_close_tag ppf (); + end else begin + let t' = if proxy t == proxy t' then unalias t' else t' in + fprintf ppf "@[<2>"; + Format.pp_open_tag ppf tag; + fprintf ppf "%a" type_expr t; + Format.pp_close_tag ppf (); + fprintf ppf "@ @{(defined as@}@ "; + Format.pp_open_tag ppf tag; + fprintf ppf "%a" type_expr t'; + Format.pp_close_tag ppf (); + fprintf ppf "@{)@}"; + fprintf ppf "@]"; + end -let include_err ppf = function - | Missing_field (id, loc, kind) -> - fprintf ppf "The %s `%a' is required but not provided" kind ident id; - show_loc "Expected declaration" ppf loc - | Value_descriptions(id, d1, d2) -> - fprintf ppf - "@[Values do not match:@ %a@;<1 -2>is not included in@ %a@]" - (value_description id) d1 (value_description id) d2; - show_locs ppf (d1.val_loc, d2.val_loc); - | Type_declarations(id, d1, d2, errs) -> - fprintf ppf "@[@[%s:@;<1 2>%a@ %s@;<1 2>%a@]%a%a@]" - "Type declarations do not match" - (type_declaration id) d1 - "is not included in" - (type_declaration id) d2 - show_locs (d1.type_loc, d2.type_loc) - (Includecore.report_type_mismatch - "the first" "the second" "declaration") errs - | Extension_constructors(id, x1, x2) -> - fprintf ppf - "@[Extension declarations do not match:@ \ - %a@;<1 -2>is not included in@ %a@]" - (extension_constructor id) x1 - (extension_constructor id) x2; - show_locs ppf (x1.ext_loc, x2.ext_loc) - | Module_types(mty1, mty2)-> - fprintf ppf - "@[Modules do not match:@ \ - %a@;<1 -2>is not included in@ %a@]" - modtype mty1 - modtype mty2 - | Modtype_infos(id, d1, d2) -> - fprintf ppf - "@[Module type declarations do not match:@ \ - %a@;<1 -2>does not match@ %a@]" - (modtype_declaration id) d1 - (modtype_declaration id) d2 - | Modtype_permutation -> - fprintf ppf "Illegal permutation of structure fields" - | Interface_mismatch(impl_name, intf_name) -> - fprintf ppf "@[The implementation %s@ does not match the interface %s:" - impl_name intf_name - | Class_type_declarations(id, d1, d2, reason) -> +let super_trace ppf = + let rec super_trace first_report ppf = function + | (t1, t1') :: (t2, t2') :: rem -> fprintf ppf - "@[Class type declarations do not match:@ \ - %a@;<1 -2>does not match@ %a@]@ %a" - (Printtyp.cltype_declaration id) d1 - (Printtyp.cltype_declaration id) d2 - Includeclass.report_error reason - | Class_declarations(id, d1, d2, reason) -> + "@,@,@["; + if first_report then + fprintf ppf "The incompatible parts:@," + else begin + fprintf ppf "Further expanded:@," + end; fprintf ppf - "@[Class declarations do not match:@ \ - %a@;<1 -2>does not match@ %a@]@ %a" - (Printtyp.class_declaration id) d1 - (Printtyp.class_declaration id) d2 - Includeclass.report_error reason - | Unbound_modtype_path path -> - fprintf ppf "Unbound module type %a" Printtyp.path path - | Unbound_module_path path -> - fprintf ppf "Unbound module %a" Printtyp.path path - | Invalid_module_alias path -> - fprintf ppf "Module %a cannot be aliased" Printtyp.path path - -let rec context ppf = function - Module id :: rem -> - fprintf ppf "@[<2>module %a%a@]" ident id args rem - | Modtype id :: rem -> - fprintf ppf "@[<2>module type %a =@ %a@]" ident id context_mty rem - | Body x :: rem -> - fprintf ppf "functor (%s) ->@ %a" (argname x) context_mty rem - | Arg x :: rem -> - fprintf ppf "functor (%a : %a) -> ..." ident x context_mty rem - | [] -> - fprintf ppf "" -and context_mty ppf = function - (Module _ | Modtype _) :: _ as rem -> - fprintf ppf "@[<2>sig@ %a@;<1 -2>end@]" context rem - | cxt -> context ppf cxt -and args ppf = function - Body x :: rem -> - fprintf ppf "(%s)%a" (argname x) args rem - | Arg x :: rem -> - fprintf ppf "(%a :@ %a) : ..." ident x context_mty rem - | cxt -> - fprintf ppf " :@ %a" context_mty cxt -and argname x = - let s = Ident.name x in - if s = "*" then "" else s - -let path_of_context = function - Module id :: rem -> - let rec subm path = function - [] -> path - | Module id :: rem -> subm (Pdot (path, Ident.name id, -1)) rem - | _ -> assert false - in subm (Pident id) rem - | _ -> assert false + "@[\ + @[%a@]@,\ + vs@,\ + @[%a@]\ + %a\ + @]" + (super_type_expansion ~tag:"error" t1) t1' + (super_type_expansion ~tag:"info" t2) t2' + (super_trace false) rem; + fprintf ppf "@]" + | _ -> () + in super_trace true ppf -let context ppf cxt = - if cxt = [] then () else - if List.for_all (function Module _ -> true | _ -> false) cxt then - fprintf ppf "In module %a:@ " path (path_of_context cxt) - else - fprintf ppf "@[At position@ %a@]@ " context cxt +let super_unification_error unif tr txt1 ppf txt2 = begin + reset (); + trace_same_names tr; + let tr = List.map (fun (t, t') -> (t, hide_variant_name t')) tr in + let mis = mismatch tr in + match tr with + | [] | _ :: [] -> assert false + | t1 :: t2 :: tr -> + try + let tr = filter_trace (mis = None) tr in + let t1, t1' = may_prepare_expansion (tr = []) t1 + and t2, t2' = may_prepare_expansion (tr = []) t2 in + print_labels := not !Clflags.classic; + let tr = List.map prepare_expansion tr in + fprintf ppf + "@[\ + @[\ + %t@,\ + @[<2>%a@]\ + @]@,\ + @[\ + %t@,\ + @[<2>%a@]\ + @]\ + %a\ + %t\ + @]" + txt1 (super_type_expansion ~tag:"error" t1) t1' + txt2 (super_type_expansion ~tag:"info" t2) t2' + super_trace tr + (explanation unif mis); + print_labels := true + with exn -> + print_labels := true; + raise exn +end -let include_err ppf (cxt, env, err) = - Printtyp.wrap_printing_env env (fun () -> - fprintf ppf "@[%a%a@]" context (List.rev cxt) include_err err) +let super_report_unification_error ppf env ?(unif=true) + tr txt1 txt2 = + wrap_printing_env env (fun () -> super_unification_error unif tr txt1 ppf txt2) +;; -let buffer = ref Bytes.empty -let is_big obj = - let size = !Clflags.error_size in - size > 0 && - begin - if Bytes.length !buffer < size then buffer := Bytes.create size; - try ignore (Marshal.to_buffer !buffer 0 size obj []); false - with _ -> true - end -let report_error ppf errs = - if errs = [] then () else - let (errs , err) = split_last errs in - let pe = ref true in - let include_err' ppf (_,_,obj as err) = - if not (is_big obj) then fprintf ppf "%a@ " include_err err - else if !pe then (fprintf ppf "...@ "; pe := false) - in - let print_errs ppf = List.iter (include_err' ppf) in - fprintf ppf "@[%a%a@]" print_errs errs include_err err +let trace fst keep_last txt ppf tr = + print_labels := not !Clflags.classic; + trace_same_names tr; + try match tr with + t1 :: t2 :: tr' -> + if fst then trace fst txt ppf (t1 :: t2 :: filter_trace keep_last tr') + else trace fst txt ppf (filter_trace keep_last tr); + print_labels := true + | _ -> () + with exn -> + print_labels := true; + raise exn +let report_subtyping_error ppf env tr1 txt1 tr2 = + wrap_printing_env env (fun () -> + reset (); + let tr1 = List.map prepare_expansion tr1 + and tr2 = List.map prepare_expansion tr2 in + fprintf ppf "@[%a" (trace true (tr2 = []) txt1) tr1; + if tr2 = [] then fprintf ppf "@]" else + let mis = mismatch tr2 in + fprintf ppf "%a%t@]" + (trace false (mis = None) "is not compatible with type") tr2 + (explanation true mis)) -(* We could do a better job to split the individual error items - as sub-messages of the main interface mismatch on the whole unit. *) -let () = - Location.register_error_of_exn - (function - | Error err -> Some (Location.error_of_printer_file report_error err) - | _ -> None - ) +let report_ambiguous_type_error ppf env (tp0, tp0') tpl txt1 txt2 txt3 = + wrap_printing_env env (fun () -> + reset (); + List.iter + (fun (tp, tp') -> path_same_name tp0 tp; path_same_name tp0' tp') + tpl; + match tpl with + [] -> assert false + | [tp, tp'] -> + fprintf ppf + "@[%t@;<1 2>%a@ \ + %t@;<1 2>%a\ + @]" + txt1 (type_path_expansion tp) tp' + txt3 (type_path_expansion tp0) tp0' + | _ -> + fprintf ppf + "@[%t@;<1 2>@[%a@]\ + @ %t@;<1 2>%a\ + @]" + txt2 type_path_list tpl + txt3 (type_path_expansion tp0) tp0') end -module Stypes : sig -#1 "stypes.mli" +module Includeclass : sig +#1 "includeclass.mli" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Damien Doligez, projet Moscova, INRIA Rocquencourt *) +(* Jerome Vouillon, projet Cristal, INRIA Rocquencourt *) (* *) -(* Copyright 2003 Institut National de Recherche en Informatique et *) +(* Copyright 1997 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -53928,37 +53467,33 @@ module Stypes : sig (* *) (**************************************************************************) -(* Recording and dumping (partial) type information *) - -(* Clflags.save_types must be true *) - -open Typedtree;; +(* Inclusion checks for the class language *) -type annotation = - | Ti_pat of pattern - | Ti_expr of expression - | Ti_class of class_expr - | Ti_mod of module_expr - | An_call of Location.t * Annot.call - | An_ident of Location.t * string * Annot.ident -;; +open Types +open Ctype +open Format -val record : annotation -> unit;; -val record_phrase : Location.t -> unit;; -val dump : string option -> unit;; +val class_types: + Env.t -> class_type -> class_type -> class_match_failure list +val class_type_declarations: + loc:Location.t -> + Env.t -> class_type_declaration -> class_type_declaration -> + class_match_failure list +val class_declarations: + Env.t -> class_declaration -> class_declaration -> + class_match_failure list -val get_location : annotation -> Location.t;; -val get_info : unit -> annotation list;; +val report_error: formatter -> class_match_failure list -> unit end = struct -#1 "stypes.ml" +#1 "includeclass.ml" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Damien Doligez, projet Moscova, INRIA Rocquencourt *) +(* Jerome Vouillon, projet Cristal, INRIA Rocquencourt *) (* *) -(* Copyright 2003 Institut National de Recherche en Informatique et *) +(* Copyright 1997 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -53967,212 +53502,180 @@ end = struct (* *) (**************************************************************************) -(* Recording and dumping (partial) type information *) - -(* - We record all types in a list as they are created. - This means we can dump type information even if type inference fails, - which is extremely important, since type information is most - interesting in case of errors. -*) - -open Annot;; -open Lexing;; -open Location;; -open Typedtree;; - -let output_int oc i = output_string oc (string_of_int i) +(* Inclusion checks for the class language *) -type annotation = - | Ti_pat of pattern - | Ti_expr of expression - | Ti_class of class_expr - | Ti_mod of module_expr - | An_call of Location.t * Annot.call - | An_ident of Location.t * string * Annot.ident -;; +open Types -let get_location ti = - match ti with - Ti_pat p -> p.pat_loc - | Ti_expr e -> e.exp_loc - | Ti_class c -> c.cl_loc - | Ti_mod m -> m.mod_loc - | An_call (l, _k) -> l - | An_ident (l, _s, _k) -> l -;; +let class_types env cty1 cty2 = + Ctype.match_class_types env cty1 cty2 -let annotations = ref ([] : annotation list);; -let phrases = ref ([] : Location.t list);; +let class_type_declarations ~loc env cty1 cty2 = + Builtin_attributes.check_deprecated_inclusion + ~def:cty1.clty_loc + ~use:cty2.clty_loc + loc + cty1.clty_attributes cty2.clty_attributes + (Path.last cty1.clty_path); + Ctype.match_class_declarations env + cty1.clty_params cty1.clty_type + cty2.clty_params cty2.clty_type -let record ti = - if !Clflags.annotations && not (get_location ti).Location.loc_ghost then - annotations := ti :: !annotations -;; +let class_declarations env cty1 cty2 = + match cty1.cty_new, cty2.cty_new with + None, Some _ -> + [Ctype.CM_Virtual_class] + | _ -> + Ctype.match_class_declarations env + cty1.cty_params cty1.cty_type + cty2.cty_params cty2.cty_type -let record_phrase loc = - if !Clflags.annotations then phrases := loc :: !phrases; -;; +open Format +open Ctype -(* comparison order: - the intervals are sorted by order of increasing upper bound - same upper bound -> sorted by decreasing lower bound +(* +let rec hide_params = function + Tcty_arrow ("*", _, cty) -> hide_params cty + | cty -> cty *) -let cmp_loc_inner_first loc1 loc2 = - match compare loc1.loc_end.pos_cnum loc2.loc_end.pos_cnum with - | 0 -> compare loc2.loc_start.pos_cnum loc1.loc_start.pos_cnum - | x -> x -;; -let cmp_ti_inner_first ti1 ti2 = - cmp_loc_inner_first (get_location ti1) (get_location ti2) -;; -let print_position pp pos = - if pos = dummy_pos then - output_string pp "--" - else begin - output_char pp '\"'; - output_string pp (String.escaped pos.pos_fname); - output_string pp "\" "; - output_int pp pos.pos_lnum; - output_char pp ' '; - output_int pp pos.pos_bol; - output_char pp ' '; - output_int pp pos.pos_cnum; - end -;; +let include_err ppf = + function + | CM_Virtual_class -> + fprintf ppf "A class cannot be changed from virtual to concrete" + | CM_Parameter_arity_mismatch _ -> + fprintf ppf + "The classes do not have the same number of type parameters" + | CM_Type_parameter_mismatch (env, trace) -> + Printtyp.report_unification_error ppf env ~unif:false trace + (function ppf -> + fprintf ppf "A type parameter has type") + (function ppf -> + fprintf ppf "but is expected to have type") + | CM_Class_type_mismatch (env, cty1, cty2) -> + Printtyp.wrap_printing_env env (fun () -> + fprintf ppf + "@[The class type@;<1 2>%a@ %s@;<1 2>%a@]" + Printtyp.class_type cty1 + "is not matched by the class type" + Printtyp.class_type cty2) + | CM_Parameter_mismatch (env, trace) -> + Printtyp.report_unification_error ppf env ~unif:false trace + (function ppf -> + fprintf ppf "A parameter has type") + (function ppf -> + fprintf ppf "but is expected to have type") + | CM_Val_type_mismatch (lab, env, trace) -> + Printtyp.report_unification_error ppf env ~unif:false trace + (function ppf -> + fprintf ppf "The instance variable %s@ has type" lab) + (function ppf -> + fprintf ppf "but is expected to have type") + | CM_Meth_type_mismatch (lab, env, trace) -> + Printtyp.report_unification_error ppf env ~unif:false trace + (function ppf -> + fprintf ppf "The method %s@ has type" lab) + (function ppf -> + fprintf ppf "but is expected to have type") + | CM_Non_mutable_value lab -> + fprintf ppf + "@[The non-mutable instance variable %s cannot become mutable@]" lab + | CM_Non_concrete_value lab -> + fprintf ppf + "@[The virtual instance variable %s cannot become concrete@]" lab + | CM_Missing_value lab -> + fprintf ppf "@[The first class type has no instance variable %s@]" lab + | CM_Missing_method lab -> + fprintf ppf "@[The first class type has no method %s@]" lab + | CM_Hide_public lab -> + fprintf ppf "@[The public method %s cannot be hidden@]" lab + | CM_Hide_virtual (k, lab) -> + fprintf ppf "@[The virtual %s %s cannot be hidden@]" k lab + | CM_Public_method lab -> + fprintf ppf "@[The public method %s cannot become private" lab + | CM_Virtual_method lab -> + fprintf ppf "@[The virtual method %s cannot become concrete" lab + | CM_Private_method lab -> + fprintf ppf "The private method %s cannot become public" lab -let print_location pp loc = - print_position pp loc.loc_start; - output_char pp ' '; - print_position pp loc.loc_end; -;; +let report_error ppf = function + | [] -> () + | err :: errs -> + let print_errs ppf errs = + List.iter (fun err -> fprintf ppf "@ %a" include_err err) errs in + fprintf ppf "@[%a%a@]" include_err err print_errs errs -let sort_filter_phrases () = - let ph = List.sort (fun x y -> cmp_loc_inner_first y x) !phrases in - let rec loop accu cur l = - match l with - | [] -> accu - | loc :: t -> - if cur.loc_start.pos_cnum <= loc.loc_start.pos_cnum - && cur.loc_end.pos_cnum >= loc.loc_end.pos_cnum - then loop accu cur t - else loop (loc :: accu) loc t - in - phrases := loop [] Location.none ph; -;; +end +module Includecore : sig +#1 "includecore.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -let rec printtyp_reset_maybe loc = - match !phrases with - | cur :: t when cur.loc_start.pos_cnum <= loc.loc_start.pos_cnum -> - Printtyp.reset (); - phrases := t; - printtyp_reset_maybe loc; - | _ -> () -;; +(* Inclusion checks for the core language *) -let call_kind_string k = - match k with - | Tail -> "tail" - | Stack -> "stack" - | Inline -> "inline" -;; +open Typedtree +open Types -let print_ident_annot pp str k = - match k with - | Idef l -> - output_string pp "def "; - output_string pp str; - output_char pp ' '; - print_location pp l; - output_char pp '\n' - | Iref_internal l -> - output_string pp "int_ref "; - output_string pp str; - output_char pp ' '; - print_location pp l; - output_char pp '\n' - | Iref_external -> - output_string pp "ext_ref "; - output_string pp str; - output_char pp '\n' -;; +exception Dont_match -(* The format of the annotation file is documented in emacs/caml-types.el. *) +type type_mismatch = + Arity + | Privacy + | Kind + | Constraint + | Manifest + | Variance + | Field_type of Ident.t + | Field_mutable of Ident.t + | Field_arity of Ident.t + | Field_names of int * string * string + | Field_missing of bool * Ident.t + | Record_representation of bool + | Unboxed_representation of bool + | Immediate -let print_info pp prev_loc ti = - match ti with - | Ti_class _ | Ti_mod _ -> prev_loc - | Ti_pat {pat_loc = loc; pat_type = typ; pat_env = env} - | Ti_expr {exp_loc = loc; exp_type = typ; exp_env = env} -> - if loc <> prev_loc then begin - print_location pp loc; - output_char pp '\n' - end; - output_string pp "type(\n"; - printtyp_reset_maybe loc; - Printtyp.mark_loops typ; - Format.pp_print_string Format.str_formatter " "; - Printtyp.wrap_printing_env env - (fun () -> Printtyp.type_sch Format.str_formatter typ); - Format.pp_print_newline Format.str_formatter (); - let s = Format.flush_str_formatter () in - output_string pp s; - output_string pp ")\n"; - loc - | An_call (loc, k) -> - if loc <> prev_loc then begin - print_location pp loc; - output_char pp '\n' - end; - output_string pp "call(\n "; - output_string pp (call_kind_string k); - output_string pp "\n)\n"; - loc - | An_ident (loc, str, k) -> - if loc <> prev_loc then begin - print_location pp loc; - output_char pp '\n' - end; - output_string pp "ident(\n "; - print_ident_annot pp str k; - output_string pp ")\n"; - loc -;; +val value_descriptions: + loc:Location.t -> Env.t -> Ident.t -> + value_description -> value_description -> module_coercion -let get_info () = - let info = List.fast_sort cmp_ti_inner_first !annotations in - annotations := []; - info -;; +val type_declarations: + ?equality:bool -> + loc:Location.t -> + Env.t -> string -> + type_declaration -> Ident.t -> type_declaration -> type_mismatch list -let dump filename = - if !Clflags.annotations then begin - let do_dump _temp_filename pp = - let info = get_info () in - sort_filter_phrases (); - ignore (List.fold_left (print_info pp) Location.none info) in - begin match filename with - | None -> do_dump "" stdout - | Some filename -> - Misc.output_to_file_via_temporary ~mode:[Open_text] filename do_dump - end; - phrases := []; - end else begin - annotations := []; - end; -;; +val extension_constructors: + loc:Location.t -> + Env.t -> Ident.t -> + extension_constructor -> extension_constructor -> bool +(* +val class_types: + Env.t -> class_type -> class_type -> bool +*) -end -module TypedtreeIter : sig -#1 "typedtreeIter.mli" +val report_type_mismatch: + string -> string -> string -> Format.formatter -> type_mismatch list -> unit + +end = struct +#1 "includecore.ml" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Thomas Gazagnaire (OCamlPro), Fabrice Le Fessant (INRIA Saclay) *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) (* *) -(* Copyright 2007 Institut National de Recherche en Informatique et *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -54181,98 +53684,437 @@ module TypedtreeIter : sig (* *) (**************************************************************************) +(* Inclusion checks for the core language *) + open Asttypes +open Path +open Types open Typedtree +(* Inclusion between value descriptions *) -module type IteratorArgument = sig - val enter_structure : structure -> unit - val enter_value_description : value_description -> unit - val enter_type_extension : type_extension -> unit - val enter_extension_constructor : extension_constructor -> unit - val enter_pattern : pattern -> unit - val enter_expression : expression -> unit - val enter_package_type : package_type -> unit - val enter_signature : signature -> unit - val enter_signature_item : signature_item -> unit - val enter_module_type_declaration : module_type_declaration -> unit - val enter_module_type : module_type -> unit - val enter_module_expr : module_expr -> unit - val enter_with_constraint : with_constraint -> unit - val enter_class_expr : class_expr -> unit - val enter_class_signature : class_signature -> unit - val enter_class_declaration : class_declaration -> unit - val enter_class_description : class_description -> unit - val enter_class_type_declaration : class_type_declaration -> unit - val enter_class_type : class_type -> unit - val enter_class_type_field : class_type_field -> unit - val enter_core_type : core_type -> unit - val enter_class_structure : class_structure -> unit - val enter_class_field : class_field -> unit - val enter_structure_item : structure_item -> unit +exception Dont_match +let value_descriptions ~loc env name + (vd1 : Types.value_description) + (vd2 : Types.value_description) = + Builtin_attributes.check_deprecated_inclusion + ~def:vd1.val_loc + ~use:vd2.val_loc + loc + vd1.val_attributes vd2.val_attributes - val leave_structure : structure -> unit - val leave_value_description : value_description -> unit - val leave_type_extension : type_extension -> unit - val leave_extension_constructor : extension_constructor -> unit - val leave_pattern : pattern -> unit - val leave_expression : expression -> unit - val leave_package_type : package_type -> unit - val leave_signature : signature -> unit - val leave_signature_item : signature_item -> unit - val leave_module_type_declaration : module_type_declaration -> unit - val leave_module_type : module_type -> unit - val leave_module_expr : module_expr -> unit - val leave_with_constraint : with_constraint -> unit - val leave_class_expr : class_expr -> unit - val leave_class_signature : class_signature -> unit - val leave_class_declaration : class_declaration -> unit - val leave_class_description : class_description -> unit - val leave_class_type_declaration : class_type_declaration -> unit - val leave_class_type : class_type -> unit - val leave_class_type_field : class_type_field -> unit - val leave_core_type : core_type -> unit - val leave_class_structure : class_structure -> unit - val leave_class_field : class_field -> unit - val leave_structure_item : structure_item -> unit + (Ident.name name); + + if Ctype.moregeneral env true vd1.val_type vd2.val_type then begin + match (vd1.val_kind, vd2.val_kind) with + (Val_prim p1, Val_prim p2) -> + if p1 = p2 then Tcoerce_none else raise Dont_match + | (Val_prim p, _) -> + let pc = {pc_desc = p; pc_type = vd2.Types.val_type; + pc_env = env; pc_loc = vd1.Types.val_loc; + + pc_id = name; + + } in + Tcoerce_primitive pc + | (_, Val_prim _) -> raise Dont_match + | (_, _) -> Tcoerce_none + end else + raise Dont_match + +(* Inclusion between "private" annotations *) + +let private_flags decl1 decl2 = + match decl1.type_private, decl2.type_private with + | Private, Public -> + decl2.type_kind = Type_abstract && + (decl2.type_manifest = None || decl1.type_kind <> Type_abstract) + | _, _ -> true + +(* Inclusion between manifest types (particularly for private row types) *) + +let is_absrow env ty = + match ty.desc with + Tconstr(Pident _, _, _) -> + begin match Ctype.expand_head env ty with + {desc=Tobject _|Tvariant _} -> true + | _ -> false + end + | _ -> false + +let type_manifest env ty1 params1 ty2 params2 priv2 = + let ty1' = Ctype.expand_head env ty1 and ty2' = Ctype.expand_head env ty2 in + match ty1'.desc, ty2'.desc with + Tvariant row1, Tvariant row2 when is_absrow env (Btype.row_more row2) -> + let row1 = Btype.row_repr row1 and row2 = Btype.row_repr row2 in + Ctype.equal env true (ty1::params1) (row2.row_more::params2) && + begin match row1.row_more with + {desc=Tvar _|Tconstr _|Tnil} -> true + | _ -> false + end && + let r1, r2, pairs = + Ctype.merge_row_fields row1.row_fields row2.row_fields in + (not row2.row_closed || + row1.row_closed && Ctype.filter_row_fields false r1 = []) && + List.for_all + (fun (_,f) -> match Btype.row_field_repr f with + Rabsent | Reither _ -> true | Rpresent _ -> false) + r2 && + let to_equal = ref (List.combine params1 params2) in + List.for_all + (fun (_, f1, f2) -> + match Btype.row_field_repr f1, Btype.row_field_repr f2 with + Rpresent(Some t1), + (Rpresent(Some t2) | Reither(false, [t2], _, _)) -> + to_equal := (t1,t2) :: !to_equal; true + | Rpresent None, (Rpresent None | Reither(true, [], _, _)) -> true + | Reither(c1,tl1,_,_), Reither(c2,tl2,_,_) + when List.length tl1 = List.length tl2 && c1 = c2 -> + to_equal := List.combine tl1 tl2 @ !to_equal; true + | Rabsent, (Reither _ | Rabsent) -> true + | _ -> false) + pairs && + let tl1, tl2 = List.split !to_equal in + Ctype.equal env true tl1 tl2 + | Tobject (fi1, _), Tobject (fi2, _) + when is_absrow env (snd(Ctype.flatten_fields fi2)) -> + let (fields2,rest2) = Ctype.flatten_fields fi2 in + Ctype.equal env true (ty1::params1) (rest2::params2) && + let (fields1,rest1) = Ctype.flatten_fields fi1 in + (match rest1 with {desc=Tnil|Tvar _|Tconstr _} -> true | _ -> false) && + let pairs, _miss1, miss2 = Ctype.associate_fields fields1 fields2 in + miss2 = [] && + let tl1, tl2 = + List.split (List.map (fun (_,_,t1,_,t2) -> t1, t2) pairs) in + Ctype.equal env true (params1 @ tl1) (params2 @ tl2) + | _ -> + let rec check_super ty1 = + Ctype.equal env true (ty1 :: params1) (ty2 :: params2) || + priv2 = Private && + try check_super + (Ctype.try_expand_once_opt env (Ctype.expand_head env ty1)) + with Ctype.Cannot_expand -> false + in check_super ty1 + +(* Inclusion between type declarations *) + +type type_mismatch = + Arity + | Privacy + | Kind + | Constraint + | Manifest + | Variance + | Field_type of Ident.t + | Field_mutable of Ident.t + | Field_arity of Ident.t + | Field_names of int * string * string + | Field_missing of bool * Ident.t + | Record_representation of bool (* true means second one is unboxed float *) + | Unboxed_representation of bool (* true means second one is unboxed *) + | Immediate + +let report_type_mismatch0 first second decl ppf err = + let pr fmt = Format.fprintf ppf fmt in + match err with + Arity -> pr "They have different arities" + | Privacy -> pr "A private type would be revealed" + | Kind -> pr "Their kinds differ" + | Constraint -> pr "Their constraints differ" + | Manifest -> () + | Variance -> pr "Their variances do not agree" + | Field_type s -> + pr "The types for field %s are not equal" (Ident.name s) + | Field_mutable s -> + pr "The mutability of field %s is different" (Ident.name s) + | Field_arity s -> + pr "The arities for field %s differ" (Ident.name s) + | Field_names (n, name1, name2) -> + pr "Fields number %i have different names, %s and %s" + n name1 name2 + | Field_missing (b, s) -> + pr "The field %s is only present in %s %s" + (Ident.name s) (if b then second else first) decl + | Record_representation b -> + pr "Their internal representations differ:@ %s %s %s" + (if b then second else first) decl + "uses unboxed float representation" + | Unboxed_representation b -> + pr "Their internal representations differ:@ %s %s %s" + (if b then second else first) decl + "uses unboxed representation" + | Immediate -> pr "%s is not an immediate type" first + +let report_type_mismatch first second decl ppf = + List.iter + (fun err -> + if err = Manifest then () else + Format.fprintf ppf "@ %a." (report_type_mismatch0 first second decl) err) + +let rec compare_constructor_arguments ~loc env cstr params1 params2 arg1 arg2 = + match arg1, arg2 with + | Types.Cstr_tuple arg1, Types.Cstr_tuple arg2 -> + if List.length arg1 <> List.length arg2 then [Field_arity cstr] + else if + (* Ctype.equal must be called on all arguments at once, cf. PR#7378 *) + Ctype.equal env true (params1 @ arg1) (params2 @ arg2) + then [] else [Field_type cstr] + | Types.Cstr_record l1, Types.Cstr_record l2 -> + compare_records env ~loc params1 params2 0 l1 l2 + | _ -> [Field_type cstr] + +and compare_variants ~loc env params1 params2 n + (cstrs1 : Types.constructor_declaration list) + (cstrs2 : Types.constructor_declaration list) = + match cstrs1, cstrs2 with + [], [] -> [] + | [], c::_ -> [Field_missing (true, c.Types.cd_id)] + | c::_, [] -> [Field_missing (false, c.Types.cd_id)] + | cd1::rem1, cd2::rem2 -> + if Ident.name cd1.cd_id <> Ident.name cd2.cd_id then + [Field_names (n, cd1.cd_id.name, cd2.cd_id.name)] + else begin + Builtin_attributes.check_deprecated_inclusion + ~def:cd1.cd_loc + ~use:cd2.cd_loc + loc + cd1.cd_attributes cd2.cd_attributes + (Ident.name cd1.cd_id); + let r = + match cd1.cd_res, cd2.cd_res with + | Some r1, Some r2 -> + if Ctype.equal env true [r1] [r2] then + compare_constructor_arguments ~loc env cd1.cd_id [r1] [r2] + cd1.cd_args cd2.cd_args + else [Field_type cd1.cd_id] + | Some _, None | None, Some _ -> + [Field_type cd1.cd_id] + | _ -> + compare_constructor_arguments ~loc env cd1.cd_id + params1 params2 cd1.cd_args cd2.cd_args + in + if r <> [] then r + else compare_variants ~loc env params1 params2 (n+1) rem1 rem2 + end + + +and compare_records ~loc env params1 params2 n + (labels1 : Types.label_declaration list) + (labels2 : Types.label_declaration list) = + match labels1, labels2 with + [], [] -> [] + | [], l::_ -> [Field_missing (true, l.Types.ld_id)] + | l::_, [] -> [Field_missing (false, l.Types.ld_id)] + | ld1::rem1, ld2::rem2 -> + if Ident.name ld1.ld_id <> Ident.name ld2.ld_id + then [Field_names (n, ld1.ld_id.name, ld2.ld_id.name)] + else if ld1.ld_mutable <> ld2.ld_mutable then [Field_mutable ld1.ld_id] else begin + Builtin_attributes.check_deprecated_mutable_inclusion + ~def:ld1.ld_loc + ~use:ld2.ld_loc + loc + ld1.ld_attributes ld2.ld_attributes + (Ident.name ld1.ld_id); + let field_mismatch = !Builtin_attributes.check_bs_attributes_inclusion + ld1.ld_attributes ld2.ld_attributes + (Ident.name ld1.ld_id) in + match field_mismatch with + | Some (a,b) -> [Field_names (n,a,b)] + | None -> + if Ctype.equal env true (ld1.ld_type::params1)(ld2.ld_type::params2) + then (* add arguments to the parameters, cf. PR#7378 *) + compare_records ~loc env + (ld1.ld_type::params1) (ld2.ld_type::params2) + (n+1) + rem1 rem2 + else + [Field_type ld1.ld_id] + end + +let type_declarations ?(equality = false) ~loc env name decl1 id decl2 = + Builtin_attributes.check_deprecated_inclusion + ~def:decl1.type_loc + ~use:decl2.type_loc + loc + decl1.type_attributes decl2.type_attributes + name; + if decl1.type_arity <> decl2.type_arity then [Arity] else + if not (private_flags decl1 decl2) then [Privacy] else + let err = match (decl1.type_manifest, decl2.type_manifest) with + (_, None) -> + if Ctype.equal env true decl1.type_params decl2.type_params + then [] else [Constraint] + | (Some ty1, Some ty2) -> + if type_manifest env ty1 decl1.type_params ty2 decl2.type_params + decl2.type_private + then [] else [Manifest] + | (None, Some ty2) -> + let ty1 = + Btype.newgenty (Tconstr(Pident id, decl2.type_params, ref Mnil)) + in + if Ctype.equal env true decl1.type_params decl2.type_params then + if Ctype.equal env false [ty1] [ty2] then [] + else [Manifest] + else [Constraint] + in + if err <> [] then err else + let err = + match (decl2.type_kind, decl1.type_unboxed.unboxed, + decl2.type_unboxed.unboxed) with + | Type_abstract, _, _ -> [] + | _, true, false -> [Unboxed_representation false] + | _, false, true -> [Unboxed_representation true] + | _ -> [] + in + if err <> [] then err else + let err = match (decl1.type_kind, decl2.type_kind) with + (_, Type_abstract) -> [] + | (Type_variant cstrs1, Type_variant cstrs2) -> + let mark cstrs usage name decl = + List.iter + (fun c -> + Env.mark_constructor_used usage env name decl + (Ident.name c.Types.cd_id)) + cstrs + in + let usage = + if decl1.type_private = Private || decl2.type_private = Public + then Env.Positive else Env.Privatize + in + mark cstrs1 usage name decl1; + if equality then mark cstrs2 Env.Positive (Ident.name id) decl2; + compare_variants ~loc env decl1.type_params decl2.type_params 1 cstrs1 cstrs2 + | (Type_record(labels1,rep1), Type_record(labels2,rep2)) -> + let err = compare_records ~loc env decl1.type_params decl2.type_params + 1 labels1 labels2 in + if err <> [] || rep1 = rep2 then err else + [Record_representation (rep2 = Record_float)] + | (Type_open, Type_open) -> [] + | (_, _) -> [Kind] + in + if err <> [] then err else + let abstr = decl2.type_kind = Type_abstract && decl2.type_manifest = None in + (* If attempt to assign a non-immediate type (e.g. string) to a type that + * must be immediate, then we error *) + let err = + if abstr && + not decl1.type_immediate && + decl2.type_immediate then + [Immediate] + else [] + in + if err <> [] then err else + let need_variance = + abstr || decl1.type_private = Private || decl1.type_kind = Type_open in + if not need_variance then [] else + let abstr = abstr || decl2.type_private = Private in + let opn = decl2.type_kind = Type_open && decl2.type_manifest = None in + let constrained ty = not (Btype.(is_Tvar (repr ty))) in + if List.for_all2 + (fun ty (v1,v2) -> + let open Variance in + let imp a b = not a || b in + let (co1,cn1) = get_upper v1 and (co2,cn2) = get_upper v2 in + (if abstr then (imp co1 co2 && imp cn1 cn2) + else if opn || constrained ty then (co1 = co2 && cn1 = cn2) + else true) && + let (p1,n1,i1,j1) = get_lower v1 and (p2,n2,i2,j2) = get_lower v2 in + imp abstr (imp p2 p1 && imp n2 n1 && imp i2 i1 && imp j2 j1)) + decl2.type_params (List.combine decl1.type_variance decl2.type_variance) + then [] else [Variance] - val enter_bindings : rec_flag -> unit - val enter_binding : value_binding -> unit - val leave_binding : value_binding -> unit - val leave_bindings : rec_flag -> unit +(* Inclusion between extension constructors *) - val enter_type_declarations : rec_flag -> unit - val enter_type_declaration : type_declaration -> unit - val leave_type_declaration : type_declaration -> unit - val leave_type_declarations : rec_flag -> unit +let extension_constructors ~loc env id ext1 ext2 = + let usage = + if ext1.ext_private = Private || ext2.ext_private = Public + then Env.Positive else Env.Privatize + in + Env.mark_extension_used usage env ext1 (Ident.name id); + let ty1 = + Btype.newgenty (Tconstr(ext1.ext_type_path, ext1.ext_type_params, ref Mnil)) + in + let ty2 = + Btype.newgenty (Tconstr(ext2.ext_type_path, ext2.ext_type_params, ref Mnil)) + in + if Ctype.equal env true + (ty1 :: ext1.ext_type_params) + (ty2 :: ext2.ext_type_params) + then + if compare_constructor_arguments ~loc env (Ident.create "") + ext1.ext_type_params ext2.ext_type_params + ext1.ext_args ext2.ext_args = [] then + if match ext1.ext_ret_type, ext2.ext_ret_type with + Some r1, Some r2 when not (Ctype.equal env true [r1] [r2]) -> false + | Some _, None | None, Some _ -> false + | _ -> true + then + match ext1.ext_private, ext2.ext_private with + Private, Public -> false + | _, _ -> true + else false + else false + else false end +module Mtype : sig +#1 "mtype.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -module MakeIterator : - functor (Iter : IteratorArgument) -> - sig - val iter_structure : structure -> unit - val iter_signature : signature -> unit - val iter_structure_item : structure_item -> unit - val iter_signature_item : signature_item -> unit - val iter_expression : expression -> unit - val iter_module_type : module_type -> unit - val iter_pattern : pattern -> unit - val iter_class_expr : class_expr -> unit - end +(* Operations on module types *) -module DefaultIteratorArgument : IteratorArgument +open Types + +val scrape: Env.t -> module_type -> module_type + (* Expand toplevel module type abbreviations + till hitting a "hard" module type (signature, functor, + or abstract module type ident. *) +val freshen: module_type -> module_type + (* Return an alpha-equivalent copy of the given module type + where bound identifiers are fresh. *) +val strengthen: aliasable:bool -> Env.t -> module_type -> Path.t -> module_type + (* Strengthen abstract type components relative to the + given path. *) +val strengthen_decl: + aliasable:bool -> Env.t -> module_declaration -> Path.t -> module_declaration +val nondep_supertype: Env.t -> Ident.t -> module_type -> module_type + (* Return the smallest supertype of the given type + in which the given ident does not appear. + Raise [Not_found] if no such type exists. *) +val no_code_needed: Env.t -> module_type -> bool +val no_code_needed_sig: Env.t -> signature -> bool + (* Determine whether a module needs no implementation code, + i.e. consists only of type definitions. *) +val enrich_modtype: Env.t -> Path.t -> module_type -> module_type +val enrich_typedecl: Env.t -> Path.t -> type_declaration -> type_declaration +val type_paths: Env.t -> Path.t -> module_type -> Path.t list +val contains_type: Env.t -> module_type -> bool +val remove_aliases: Env.t -> module_type -> module_type +val lower_nongen: int -> module_type -> unit end = struct -#1 "typedtreeIter.ml" +#1 "mtype.ml" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Thomas Gazagnaire (OCamlPro), Fabrice Le Fessant (INRIA Saclay) *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) (* *) -(* Copyright 2007 Institut National de Recherche en Informatique et *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -54281,690 +54123,424 @@ end = struct (* *) (**************************************************************************) -(* -TODO: - - 2012/05/10: Follow camlp4 way of building map and iter using classes - and inheritance ? -*) +(* Operations on module types *) open Asttypes -open Typedtree - -module type IteratorArgument = sig - - val enter_structure : structure -> unit - val enter_value_description : value_description -> unit - val enter_type_extension : type_extension -> unit - val enter_extension_constructor : extension_constructor -> unit - val enter_pattern : pattern -> unit - val enter_expression : expression -> unit - val enter_package_type : package_type -> unit - val enter_signature : signature -> unit - val enter_signature_item : signature_item -> unit - val enter_module_type_declaration : module_type_declaration -> unit - val enter_module_type : module_type -> unit - val enter_module_expr : module_expr -> unit - val enter_with_constraint : with_constraint -> unit - val enter_class_expr : class_expr -> unit - val enter_class_signature : class_signature -> unit - val enter_class_declaration : class_declaration -> unit - val enter_class_description : class_description -> unit - val enter_class_type_declaration : class_type_declaration -> unit - val enter_class_type : class_type -> unit - val enter_class_type_field : class_type_field -> unit - val enter_core_type : core_type -> unit - val enter_class_structure : class_structure -> unit - val enter_class_field : class_field -> unit - val enter_structure_item : structure_item -> unit - - - val leave_structure : structure -> unit - val leave_value_description : value_description -> unit - val leave_type_extension : type_extension -> unit - val leave_extension_constructor : extension_constructor -> unit - val leave_pattern : pattern -> unit - val leave_expression : expression -> unit - val leave_package_type : package_type -> unit - val leave_signature : signature -> unit - val leave_signature_item : signature_item -> unit - val leave_module_type_declaration : module_type_declaration -> unit - val leave_module_type : module_type -> unit - val leave_module_expr : module_expr -> unit - val leave_with_constraint : with_constraint -> unit - val leave_class_expr : class_expr -> unit - val leave_class_signature : class_signature -> unit - val leave_class_declaration : class_declaration -> unit - val leave_class_description : class_description -> unit - val leave_class_type_declaration : class_type_declaration -> unit - val leave_class_type : class_type -> unit - val leave_class_type_field : class_type_field -> unit - val leave_core_type : core_type -> unit - val leave_class_structure : class_structure -> unit - val leave_class_field : class_field -> unit - val leave_structure_item : structure_item -> unit - - val enter_bindings : rec_flag -> unit - val enter_binding : value_binding -> unit - val leave_binding : value_binding -> unit - val leave_bindings : rec_flag -> unit +open Path +open Types - val enter_type_declarations : rec_flag -> unit - val enter_type_declaration : type_declaration -> unit - val leave_type_declaration : type_declaration -> unit - val leave_type_declarations : rec_flag -> unit +let rec scrape env mty = + match mty with + Mty_ident p -> + begin try + scrape env (Env.find_modtype_expansion p env) + with Not_found -> + mty end + | _ -> mty -module MakeIterator(Iter : IteratorArgument) : sig - - val iter_structure : structure -> unit - val iter_signature : signature -> unit - val iter_structure_item : structure_item -> unit - val iter_signature_item : signature_item -> unit - val iter_expression : expression -> unit - val iter_module_type : module_type -> unit - val iter_pattern : pattern -> unit - val iter_class_expr : class_expr -> unit - - end = struct - - let may_iter f v = - match v with - None -> () - | Some x -> f x - - - let rec iter_structure str = - Iter.enter_structure str; - List.iter iter_structure_item str.str_items; - Iter.leave_structure str - - - and iter_binding vb = - Iter.enter_binding vb; - iter_pattern vb.vb_pat; - iter_expression vb.vb_expr; - Iter.leave_binding vb - - and iter_bindings rec_flag list = - Iter.enter_bindings rec_flag; - List.iter iter_binding list; - Iter.leave_bindings rec_flag - - and iter_case {c_lhs; c_guard; c_rhs} = - iter_pattern c_lhs; - may_iter iter_expression c_guard; - iter_expression c_rhs - - and iter_cases cases = - List.iter iter_case cases - - and iter_structure_item item = - Iter.enter_structure_item item; - begin - match item.str_desc with - Tstr_eval (exp, _attrs) -> iter_expression exp - | Tstr_value (rec_flag, list) -> - iter_bindings rec_flag list - | Tstr_primitive vd -> iter_value_description vd - | Tstr_type (rf, list) -> iter_type_declarations rf list - | Tstr_typext tyext -> iter_type_extension tyext - | Tstr_exception ext -> iter_extension_constructor ext - | Tstr_module x -> iter_module_binding x - | Tstr_recmodule list -> List.iter iter_module_binding list - | Tstr_modtype mtd -> iter_module_type_declaration mtd - | Tstr_open _ -> () - | Tstr_class list -> - List.iter (fun (ci, _) -> iter_class_declaration ci) list - | Tstr_class_type list -> - List.iter - (fun (_, _, ct) -> iter_class_type_declaration ct) - list - | Tstr_include incl -> iter_module_expr incl.incl_mod - | Tstr_attribute _ -> - () - end; - Iter.leave_structure_item item - - and iter_module_binding x = - iter_module_expr x.mb_expr - - and iter_value_description v = - Iter.enter_value_description v; - iter_core_type v.val_desc; - Iter.leave_value_description v - - and iter_constructor_arguments = function - | Cstr_tuple l -> List.iter iter_core_type l - | Cstr_record l -> List.iter (fun ld -> iter_core_type ld.ld_type) l - - and iter_constructor_declaration cd = - iter_constructor_arguments cd.cd_args; - option iter_core_type cd.cd_res; - - and iter_type_parameter (ct, _v) = - iter_core_type ct - - and iter_type_declaration decl = - Iter.enter_type_declaration decl; - List.iter iter_type_parameter decl.typ_params; - List.iter (fun (ct1, ct2, _loc) -> - iter_core_type ct1; - iter_core_type ct2 - ) decl.typ_cstrs; - begin match decl.typ_kind with - Ttype_abstract -> () - | Ttype_variant list -> - List.iter iter_constructor_declaration list - | Ttype_record list -> - List.iter - (fun ld -> - iter_core_type ld.ld_type - ) list - | Ttype_open -> () - end; - option iter_core_type decl.typ_manifest; - Iter.leave_type_declaration decl - - and iter_type_declarations rec_flag decls = - Iter.enter_type_declarations rec_flag; - List.iter iter_type_declaration decls; - Iter.leave_type_declarations rec_flag - - and iter_extension_constructor ext = - Iter.enter_extension_constructor ext; - begin match ext.ext_kind with - Text_decl(args, ret) -> - iter_constructor_arguments args; - option iter_core_type ret - | Text_rebind _ -> () - end; - Iter.leave_extension_constructor ext; - - and iter_type_extension tyext = - Iter.enter_type_extension tyext; - List.iter iter_type_parameter tyext.tyext_params; - List.iter iter_extension_constructor tyext.tyext_constructors; - Iter.leave_type_extension tyext - - and iter_pattern pat = - Iter.enter_pattern pat; - List.iter (fun (cstr, _, _attrs) -> match cstr with - | Tpat_type _ -> () - | Tpat_unpack -> () - | Tpat_open _ -> () - | Tpat_constraint ct -> iter_core_type ct) pat.pat_extra; - begin - match pat.pat_desc with - Tpat_any -> () - | Tpat_var _ -> () - | Tpat_alias (pat1, _, _) -> iter_pattern pat1 - | Tpat_constant _ -> () - | Tpat_tuple list -> - List.iter iter_pattern list - | Tpat_construct (_, _, args) -> - List.iter iter_pattern args - | Tpat_variant (_, pato, _) -> - begin match pato with - None -> () - | Some pat -> iter_pattern pat - end - | Tpat_record (list, _closed) -> - List.iter (fun (_, _, pat) -> iter_pattern pat) list - | Tpat_array list -> List.iter iter_pattern list - | Tpat_or (p1, p2, _) -> iter_pattern p1; iter_pattern p2 - | Tpat_lazy p -> iter_pattern p - end; - Iter.leave_pattern pat +let freshen mty = + Subst.modtype Subst.identity mty - and option f x = match x with None -> () | Some e -> f e +let rec strengthen ~aliasable env mty p = + match scrape env mty with + Mty_signature sg -> + Mty_signature(strengthen_sig ~aliasable env sg p 0) + | Mty_functor(param, arg, res) + when !Clflags.applicative_functors && Ident.name param <> "*" -> + Mty_functor(param, arg, + strengthen ~aliasable:false env res (Papply(p, Pident param))) + | mty -> + mty - and iter_expression exp = - Iter.enter_expression exp; - List.iter (function (cstr, _, _attrs) -> - match cstr with - Texp_constraint ct -> - iter_core_type ct - | Texp_coerce (cty1, cty2) -> - option iter_core_type cty1; iter_core_type cty2 - | Texp_open _ -> () - | Texp_poly cto -> option iter_core_type cto - | Texp_newtype _ -> ()) - exp.exp_extra; - begin - match exp.exp_desc with - Texp_ident _ -> () - | Texp_constant _ -> () - | Texp_let (rec_flag, list, exp) -> - iter_bindings rec_flag list; - iter_expression exp - | Texp_function { cases; _ } -> - iter_cases cases - | Texp_apply (exp, list) -> - iter_expression exp; - List.iter (fun (_label, expo) -> - match expo with - None -> () - | Some exp -> iter_expression exp - ) list - | Texp_match (exp, list1, list2, _) -> - iter_expression exp; - iter_cases list1; - iter_cases list2; - | Texp_try (exp, list) -> - iter_expression exp; - iter_cases list - | Texp_tuple list -> - List.iter iter_expression list - | Texp_construct (_, _, args) -> - List.iter iter_expression args - | Texp_variant (_label, expo) -> - begin match expo with - None -> () - | Some exp -> iter_expression exp - end - | Texp_record { fields; extended_expression; _ } -> - Array.iter (function - | _, Kept _ -> () - | _, Overridden (_, exp) -> iter_expression exp) - fields; - begin match extended_expression with - None -> () - | Some exp -> iter_expression exp - end - | Texp_field (exp, _, _label) -> - iter_expression exp - | Texp_setfield (exp1, _, _label, exp2) -> - iter_expression exp1; - iter_expression exp2 - | Texp_array list -> - List.iter iter_expression list - | Texp_ifthenelse (exp1, exp2, expo) -> - iter_expression exp1; - iter_expression exp2; - begin match expo with - None -> () - | Some exp -> iter_expression exp - end - | Texp_sequence (exp1, exp2) -> - iter_expression exp1; - iter_expression exp2 - | Texp_while (exp1, exp2) -> - iter_expression exp1; - iter_expression exp2 - | Texp_for (_id, _, exp1, exp2, _dir, exp3) -> - iter_expression exp1; - iter_expression exp2; - iter_expression exp3 - | Texp_send (exp, _meth, expo) -> - iter_expression exp; - begin - match expo with - None -> () - | Some exp -> iter_expression exp - end - | Texp_new _ -> () - | Texp_instvar _ -> () - | Texp_setinstvar (_, _, _, exp) -> - iter_expression exp - | Texp_override (_, list) -> - List.iter (fun (_path, _, exp) -> - iter_expression exp - ) list - | Texp_letmodule (_id, _, mexpr, exp) -> - iter_module_expr mexpr; - iter_expression exp - | Texp_letexception (cd, exp) -> - iter_extension_constructor cd; - iter_expression exp - | Texp_assert exp -> iter_expression exp - | Texp_lazy exp -> iter_expression exp - | Texp_object (cl, _) -> - iter_class_structure cl - | Texp_pack (mexpr) -> - iter_module_expr mexpr - | Texp_unreachable -> - () - | Texp_extension_constructor _ -> - () - end; - Iter.leave_expression exp; +and strengthen_sig ~aliasable env sg p pos = + match sg with + [] -> [] + | (Sig_value(_, desc) as sigelt) :: rem -> + let nextpos = + match desc.val_kind with + | Val_prim _ -> pos + | _ -> pos + 1 + in + sigelt :: strengthen_sig ~aliasable env rem p nextpos + | Sig_type(id, {type_kind=Type_abstract}, _) :: + (Sig_type(id', {type_private=Private}, _) :: _ as rem) + when Ident.name id = Ident.name id' ^ "#row" -> + strengthen_sig ~aliasable env rem p pos + | Sig_type(id, decl, rs) :: rem -> + let newdecl = + match decl.type_manifest, decl.type_private, decl.type_kind with + Some _, Public, _ -> decl + | Some _, Private, (Type_record _ | Type_variant _) -> decl + | _ -> + let manif = + Some(Btype.newgenty(Tconstr(Pdot(p, Ident.name id, nopos), + decl.type_params, ref Mnil))) in + if decl.type_kind = Type_abstract then + { decl with type_private = Public; type_manifest = manif } + else + { decl with type_manifest = manif } + in + Sig_type(id, newdecl, rs) :: strengthen_sig ~aliasable env rem p pos + | (Sig_typext _ as sigelt) :: rem -> + sigelt :: strengthen_sig ~aliasable env rem p (pos+1) + | Sig_module(id, md, rs) :: rem -> + let str = + strengthen_decl ~aliasable env md (Pdot(p, Ident.name id, pos)) + in + Sig_module(id, str, rs) + :: strengthen_sig ~aliasable + (Env.add_module_declaration ~check:false id md env) rem p (pos+1) + (* Need to add the module in case it defines manifest module types *) + | Sig_modtype(id, decl) :: rem -> + let newdecl = + match decl.mtd_type with + None -> + {decl with mtd_type = Some(Mty_ident(Pdot(p,Ident.name id,nopos)))} + | Some _ -> + decl + in + Sig_modtype(id, newdecl) :: + strengthen_sig ~aliasable (Env.add_modtype id decl env) rem p pos + (* Need to add the module type in case it is manifest *) + | (Sig_class _ as sigelt) :: rem -> + sigelt :: strengthen_sig ~aliasable env rem p (pos+1) + | (Sig_class_type _ as sigelt) :: rem -> + sigelt :: strengthen_sig ~aliasable env rem p pos - and iter_package_type pack = - Iter.enter_package_type pack; - List.iter (fun (_s, ct) -> iter_core_type ct) pack.pack_fields; - Iter.leave_package_type pack; +and strengthen_decl ~aliasable env md p = + match md.md_type with + | Mty_alias _ -> md + | _ when aliasable -> {md with md_type = Mty_alias(Mta_present, p)} + | mty -> {md with md_type = strengthen ~aliasable env mty p} - and iter_signature sg = - Iter.enter_signature sg; - List.iter iter_signature_item sg.sig_items; - Iter.leave_signature sg; +let () = Env.strengthen := strengthen - and iter_signature_item item = - Iter.enter_signature_item item; - begin - match item.sig_desc with - Tsig_value vd -> - iter_value_description vd - | Tsig_type (rf, list) -> - iter_type_declarations rf list - | Tsig_exception ext -> - iter_extension_constructor ext - | Tsig_typext tyext -> - iter_type_extension tyext - | Tsig_module md -> - iter_module_type md.md_type - | Tsig_recmodule list -> - List.iter (fun md -> iter_module_type md.md_type) list - | Tsig_modtype mtd -> - iter_module_type_declaration mtd - | Tsig_open _ -> () - | Tsig_include incl -> iter_module_type incl.incl_mod - | Tsig_class list -> - List.iter iter_class_description list - | Tsig_class_type list -> - List.iter iter_class_type_declaration list - | Tsig_attribute _ -> () - end; - Iter.leave_signature_item item; +(* In nondep_supertype, env is only used for the type it assigns to id. + Hence there is no need to keep env up-to-date by adding the bindings + traversed. *) - and iter_module_type_declaration mtd = - Iter.enter_module_type_declaration mtd; - begin - match mtd.mtd_type with - | None -> () - | Some mtype -> iter_module_type mtype - end; - Iter.leave_module_type_declaration mtd +type variance = Co | Contra | Strict - and iter_class_declaration cd = - Iter.enter_class_declaration cd; - List.iter iter_type_parameter cd.ci_params; - iter_class_expr cd.ci_expr; - Iter.leave_class_declaration cd; +let nondep_supertype env mid mty = - and iter_class_description cd = - Iter.enter_class_description cd; - List.iter iter_type_parameter cd.ci_params; - iter_class_type cd.ci_expr; - Iter.leave_class_description cd; + let rec nondep_mty env va mty = + match mty with + Mty_ident p -> + if Path.isfree mid p then + nondep_mty env va (Env.find_modtype_expansion p env) + else mty + | Mty_alias(_, p) -> + if Path.isfree mid p then + nondep_mty env va (Env.find_module p env).md_type + else mty + | Mty_signature sg -> + Mty_signature(nondep_sig env va sg) + | Mty_functor(param, arg, res) -> + let var_inv = + match va with Co -> Contra | Contra -> Co | Strict -> Strict in + Mty_functor(param, Misc.may_map (nondep_mty env var_inv) arg, + nondep_mty + (Env.add_module ~arg:true param + (Btype.default_mty arg) env) va res) - and iter_class_type_declaration cd = - Iter.enter_class_type_declaration cd; - List.iter iter_type_parameter cd.ci_params; - iter_class_type cd.ci_expr; - Iter.leave_class_type_declaration cd; + and nondep_sig env va = function + [] -> [] + | item :: rem -> + let rem' = nondep_sig env va rem in + match item with + Sig_value(id, d) -> + Sig_value(id, + {d with val_type = Ctype.nondep_type env mid d.val_type}) + :: rem' + | Sig_type(id, d, rs) -> + Sig_type(id, Ctype.nondep_type_decl env mid id (va = Co) d, rs) + :: rem' + | Sig_typext(id, ext, es) -> + Sig_typext(id, Ctype.nondep_extension_constructor env mid ext, es) + :: rem' + | Sig_module(id, md, rs) -> + Sig_module(id, {md with md_type=nondep_mty env va md.md_type}, rs) + :: rem' + | Sig_modtype(id, d) -> + begin try + Sig_modtype(id, nondep_modtype_decl env d) :: rem' + with Not_found -> + match va with + Co -> Sig_modtype(id, {mtd_type=None; mtd_loc=Location.none; + mtd_attributes=[]}) :: rem' + | _ -> raise Not_found + end + | Sig_class(id, d, rs) -> + Sig_class(id, Ctype.nondep_class_declaration env mid d, rs) + :: rem' + | Sig_class_type(id, d, rs) -> + Sig_class_type(id, Ctype.nondep_cltype_declaration env mid d, rs) + :: rem' - and iter_module_type mty = - Iter.enter_module_type mty; - begin - match mty.mty_desc with - Tmty_ident _ -> () - | Tmty_alias _ -> () - | Tmty_signature sg -> iter_signature sg - | Tmty_functor (_, _, mtype1, mtype2) -> - Misc.may iter_module_type mtype1; iter_module_type mtype2 - | Tmty_with (mtype, list) -> - iter_module_type mtype; - List.iter (fun (_path, _, withc) -> - iter_with_constraint withc - ) list - | Tmty_typeof mexpr -> - iter_module_expr mexpr - end; - Iter.leave_module_type mty; + and nondep_modtype_decl env mtd = + {mtd with mtd_type = Misc.may_map (nondep_mty env Strict) mtd.mtd_type} - and iter_with_constraint cstr = - Iter.enter_with_constraint cstr; - begin - match cstr with - Twith_type decl -> iter_type_declaration decl - | Twith_module _ -> () - | Twith_typesubst decl -> iter_type_declaration decl - | Twith_modsubst _ -> () - end; - Iter.leave_with_constraint cstr; + in + nondep_mty env Co mty - and iter_module_expr mexpr = - Iter.enter_module_expr mexpr; - begin - match mexpr.mod_desc with - Tmod_ident _ -> () - | Tmod_structure st -> iter_structure st - | Tmod_functor (_, _, mtype, mexpr) -> - Misc.may iter_module_type mtype; - iter_module_expr mexpr - | Tmod_apply (mexp1, mexp2, _) -> - iter_module_expr mexp1; - iter_module_expr mexp2 - | Tmod_constraint (mexpr, _, Tmodtype_implicit, _ ) -> - iter_module_expr mexpr - | Tmod_constraint (mexpr, _, Tmodtype_explicit mtype, _) -> - iter_module_expr mexpr; - iter_module_type mtype - | Tmod_unpack (exp, _mty) -> - iter_expression exp -(* iter_module_type mty *) - end; - Iter.leave_module_expr mexpr; +let enrich_typedecl env p decl = + match decl.type_manifest with + Some _ -> decl + | None -> + try + let orig_decl = Env.find_type p env in + if orig_decl.type_arity <> decl.type_arity + then decl + else {decl with type_manifest = + Some(Btype.newgenty(Tconstr(p, decl.type_params, ref Mnil)))} + with Not_found -> + decl - and iter_class_expr cexpr = - Iter.enter_class_expr cexpr; - begin - match cexpr.cl_desc with - | Tcl_constraint (cl, None, _, _, _ ) -> - iter_class_expr cl; - | Tcl_structure clstr -> iter_class_structure clstr - | Tcl_fun (_label, pat, priv, cl, _partial) -> - iter_pattern pat; - List.iter (fun (_id, _, exp) -> iter_expression exp) priv; - iter_class_expr cl +let rec enrich_modtype env p mty = + match mty with + Mty_signature sg -> + Mty_signature(List.map (enrich_item env p) sg) + | _ -> + mty - | Tcl_apply (cl, args) -> - iter_class_expr cl; - List.iter (fun (_label, expo) -> - match expo with - None -> () - | Some exp -> iter_expression exp - ) args +and enrich_item env p = function + Sig_type(id, decl, rs) -> + Sig_type(id, + enrich_typedecl env (Pdot(p, Ident.name id, nopos)) decl, rs) + | Sig_module(id, md, rs) -> + Sig_module(id, + {md with + md_type = enrich_modtype env + (Pdot(p, Ident.name id, nopos)) md.md_type}, + rs) + | item -> item - | Tcl_let (rec_flat, bindings, ivars, cl) -> - iter_bindings rec_flat bindings; - List.iter (fun (_id, _, exp) -> iter_expression exp) ivars; - iter_class_expr cl +let rec type_paths env p mty = + match scrape env mty with + Mty_ident _ -> [] + | Mty_alias _ -> [] + | Mty_signature sg -> type_paths_sig env p 0 sg + | Mty_functor _ -> [] - | Tcl_constraint (cl, Some clty, _vals, _meths, _concrs) -> - iter_class_expr cl; - iter_class_type clty +and type_paths_sig env p pos sg = + match sg with + [] -> [] + | Sig_value(_id, decl) :: rem -> + let pos' = match decl.val_kind with Val_prim _ -> pos | _ -> pos + 1 in + type_paths_sig env p pos' rem + | Sig_type(id, _decl, _) :: rem -> + Pdot(p, Ident.name id, nopos) :: type_paths_sig env p pos rem + | Sig_module(id, md, _) :: rem -> + type_paths env (Pdot(p, Ident.name id, pos)) md.md_type @ + type_paths_sig (Env.add_module_declaration ~check:false id md env) + p (pos+1) rem + | Sig_modtype(id, decl) :: rem -> + type_paths_sig (Env.add_modtype id decl env) p pos rem + | (Sig_typext _ | Sig_class _) :: rem -> + type_paths_sig env p (pos+1) rem + | (Sig_class_type _) :: rem -> + type_paths_sig env p pos rem - | Tcl_ident (_, _, tyl) -> - List.iter iter_core_type tyl +let rec no_code_needed env mty = + match scrape env mty with + Mty_ident _ -> false + | Mty_signature sg -> no_code_needed_sig env sg + | Mty_functor(_, _, _) -> false + | Mty_alias(Mta_absent, _) -> true + | Mty_alias(Mta_present, _) -> false - | Tcl_open (_, _, _, _, e) -> - iter_class_expr e - end; - Iter.leave_class_expr cexpr; +and no_code_needed_sig env sg = + match sg with + [] -> true + | Sig_value(_id, decl) :: rem -> + begin match decl.val_kind with + | Val_prim _ -> no_code_needed_sig env rem + | _ -> false + end + | Sig_module(id, md, _) :: rem -> + no_code_needed env md.md_type && + no_code_needed_sig + (Env.add_module_declaration ~check:false id md env) rem + | (Sig_type _ | Sig_modtype _ | Sig_class_type _) :: rem -> + no_code_needed_sig env rem + | (Sig_typext _ | Sig_class _) :: _ -> + false - and iter_class_type ct = - Iter.enter_class_type ct; - begin - match ct.cltyp_desc with - Tcty_signature csg -> iter_class_signature csg - | Tcty_constr (_path, _, list) -> - List.iter iter_core_type list - | Tcty_arrow (_label, ct, cl) -> - iter_core_type ct; - iter_class_type cl - | Tcty_open (_, _, _, _, e) -> - iter_class_type e - end; - Iter.leave_class_type ct; - and iter_class_signature cs = - Iter.enter_class_signature cs; - iter_core_type cs.csig_self; - List.iter iter_class_type_field cs.csig_fields; - Iter.leave_class_signature cs +(* Check whether a module type may return types *) +let rec contains_type env = function + Mty_ident path -> + begin try match (Env.find_modtype path env).mtd_type with + | None -> raise Exit (* PR#6427 *) + | Some mty -> contains_type env mty + with Not_found -> raise Exit + end + | Mty_signature sg -> + contains_type_sig env sg + | Mty_functor (_, _, body) -> + contains_type env body + | Mty_alias _ -> + () - and iter_class_type_field ctf = - Iter.enter_class_type_field ctf; - begin - match ctf.ctf_desc with - Tctf_inherit ct -> iter_class_type ct - | Tctf_val (_s, _mut, _virt, ct) -> - iter_core_type ct - | Tctf_method (_s, _priv, _virt, ct) -> - iter_core_type ct - | Tctf_constraint (ct1, ct2) -> - iter_core_type ct1; - iter_core_type ct2 - | Tctf_attribute _ -> () - end; - Iter.leave_class_type_field ctf +and contains_type_sig env = List.iter (contains_type_item env) - and iter_core_type ct = - Iter.enter_core_type ct; - begin - match ct.ctyp_desc with - Ttyp_any -> () - | Ttyp_var _ -> () - | Ttyp_arrow (_label, ct1, ct2) -> - iter_core_type ct1; - iter_core_type ct2 - | Ttyp_tuple list -> List.iter iter_core_type list - | Ttyp_constr (_path, _, list) -> - List.iter iter_core_type list - | Ttyp_object (list, _o) -> - List.iter iter_object_field list - | Ttyp_class (_path, _, list) -> - List.iter iter_core_type list - | Ttyp_alias (ct, _s) -> - iter_core_type ct - | Ttyp_variant (list, _bool, _labels) -> - List.iter iter_row_field list - | Ttyp_poly (_list, ct) -> iter_core_type ct - | Ttyp_package pack -> iter_package_type pack - end; - Iter.leave_core_type ct +and contains_type_item env = function + Sig_type (_,({type_manifest = None} | + {type_kind = Type_abstract; type_private = Private}),_) + | Sig_modtype _ + | Sig_typext (_, {ext_args = Cstr_record _}, _) -> + (* We consider that extension constructors with an inlined + record create a type (the inlined record), even though + it would be technically safe to ignore that considering + the current constraints which guarantee that this type + is kept local to expressions. *) + raise Exit + | Sig_module (_, {md_type = mty}, _) -> + contains_type env mty + | Sig_value _ + | Sig_type _ + | Sig_typext _ + | Sig_class _ + | Sig_class_type _ -> + () - and iter_class_structure cs = - Iter.enter_class_structure cs; - iter_pattern cs.cstr_self; - List.iter iter_class_field cs.cstr_fields; - Iter.leave_class_structure cs; +let contains_type env mty = + try contains_type env mty; false with Exit -> true - and iter_row_field rf = - match rf with - Ttag (_label, _attrs, _bool, list) -> - List.iter iter_core_type list - | Tinherit ct -> iter_core_type ct +(* Remove module aliases from a signature *) - and iter_object_field ofield = - match ofield with - OTtag (_, _, ct) | OTinherit ct -> iter_core_type ct +module PathSet = Set.Make (Path) +module PathMap = Map.Make (Path) +module IdentSet = Set.Make (Ident) - and iter_class_field cf = - Iter.enter_class_field cf; - begin - match cf.cf_desc with - Tcf_inherit (_ovf, cl, _super, _vals, _meths) -> - iter_class_expr cl - | Tcf_constraint (cty, cty') -> - iter_core_type cty; - iter_core_type cty' - | Tcf_val (_lab, _, _, Tcfk_virtual cty, _) -> - iter_core_type cty - | Tcf_val (_lab, _, _, Tcfk_concrete (_, exp), _) -> - iter_expression exp - | Tcf_method (_lab, _, Tcfk_virtual cty) -> - iter_core_type cty - | Tcf_method (_lab, _, Tcfk_concrete (_, exp)) -> - iter_expression exp - | Tcf_initializer exp -> - iter_expression exp - | Tcf_attribute _ -> () - end; - Iter.leave_class_field cf; - end +let rec get_prefixes = function + Pident _ -> PathSet.empty + | Pdot (p, _, _) + | Papply (p, _) -> PathSet.add p (get_prefixes p) -module DefaultIteratorArgument = struct +let rec get_arg_paths = function + Pident _ -> PathSet.empty + | Pdot (p, _, _) -> get_arg_paths p + | Papply (p1, p2) -> + PathSet.add p2 + (PathSet.union (get_prefixes p2) + (PathSet.union (get_arg_paths p1) (get_arg_paths p2))) - let enter_structure _ = () - let enter_value_description _ = () - let enter_type_extension _ = () - let enter_extension_constructor _ = () - let enter_pattern _ = () - let enter_expression _ = () - let enter_package_type _ = () - let enter_signature _ = () - let enter_signature_item _ = () - let enter_module_type_declaration _ = () - let enter_module_type _ = () - let enter_module_expr _ = () - let enter_with_constraint _ = () - let enter_class_expr _ = () - let enter_class_signature _ = () - let enter_class_declaration _ = () - let enter_class_description _ = () - let enter_class_type_declaration _ = () - let enter_class_type _ = () - let enter_class_type_field _ = () - let enter_core_type _ = () - let enter_class_structure _ = () - let enter_class_field _ = () - let enter_structure_item _ = () +let rec rollback_path subst p = + try Pident (PathMap.find p subst) + with Not_found -> + match p with + Pident _ | Papply _ -> p + | Pdot (p1, s, n) -> + let p1' = rollback_path subst p1 in + if Path.same p1 p1' then p else rollback_path subst (Pdot (p1', s, n)) + +let rec collect_ids subst bindings p = + begin match rollback_path subst p with + Pident id -> + let ids = + try collect_ids subst bindings (Ident.find_same id bindings) + with Not_found -> IdentSet.empty + in + IdentSet.add id ids + | _ -> IdentSet.empty + end + +let collect_arg_paths mty = + let open Btype in + let paths = ref PathSet.empty + and subst = ref PathMap.empty + and bindings = ref Ident.empty in + (* let rt = Ident.create "Root" in + and prefix = ref (Path.Pident rt) in *) + let it_path p = paths := PathSet.union (get_arg_paths p) !paths + and it_signature_item it si = + type_iterators.it_signature_item it si; + match si with + Sig_module (id, {md_type=Mty_alias(_, p)}, _) -> + bindings := Ident.add id p !bindings + | Sig_module (id, {md_type=Mty_signature sg}, _) -> + List.iter + (function Sig_module (id', _, _) -> + subst := + PathMap.add (Pdot (Pident id, Ident.name id', -1)) id' !subst + | _ -> ()) + sg + | _ -> () + in + let it = {type_iterators with it_path; it_signature_item} in + it.it_module_type it mty; + it.it_module_type unmark_iterators mty; + PathSet.fold (fun p -> IdentSet.union (collect_ids !subst !bindings p)) + !paths IdentSet.empty +let rec remove_aliases env excl mty = + match mty with + Mty_signature sg -> + Mty_signature (remove_aliases_sig env excl sg) + | Mty_alias _ -> + let mty' = Env.scrape_alias env mty in + if mty' = mty then mty else + remove_aliases env excl mty' + | mty -> + mty - let leave_structure _ = () - let leave_value_description _ = () - let leave_type_extension _ = () - let leave_extension_constructor _ = () - let leave_pattern _ = () - let leave_expression _ = () - let leave_package_type _ = () - let leave_signature _ = () - let leave_signature_item _ = () - let leave_module_type_declaration _ = () - let leave_module_type _ = () - let leave_module_expr _ = () - let leave_with_constraint _ = () - let leave_class_expr _ = () - let leave_class_signature _ = () - let leave_class_declaration _ = () - let leave_class_description _ = () - let leave_class_type_declaration _ = () - let leave_class_type _ = () - let leave_class_type_field _ = () - let leave_core_type _ = () - let leave_class_structure _ = () - let leave_class_field _ = () - let leave_structure_item _ = () +and remove_aliases_sig env excl sg = + match sg with + [] -> [] + | Sig_module(id, md, rs) :: rem -> + let mty = + match md.md_type with + Mty_alias _ when IdentSet.mem id excl -> + md.md_type + | mty -> + remove_aliases env excl mty + in + Sig_module(id, {md with md_type = mty} , rs) :: + remove_aliases_sig (Env.add_module id mty env) excl rem + | Sig_modtype(id, mtd) :: rem -> + Sig_modtype(id, mtd) :: + remove_aliases_sig (Env.add_modtype id mtd env) excl rem + | it :: rem -> + it :: remove_aliases_sig env excl rem - let enter_binding _ = () - let leave_binding _ = () +let remove_aliases env sg = + let excl = collect_arg_paths sg in + (* PathSet.iter (fun p -> Format.eprintf "%a@ " Printtyp.path p) excl; + Format.eprintf "@."; *) + remove_aliases env excl sg - let enter_bindings _ = () - let leave_bindings _ = () - let enter_type_declaration _ = () - let leave_type_declaration _ = () +(* Lower non-generalizable type variables *) - let enter_type_declarations _ = () - let leave_type_declarations _ = () -end +let lower_nongen nglev mty = + let open Btype in + let it_type_expr it ty = + let ty = repr ty in + match ty with + {desc=Tvar _; level} -> + if level < generic_level && level > nglev then set_level ty nglev + | _ -> + type_iterators.it_type_expr it ty + in + let it = {type_iterators with it_type_expr} in + it.it_module_type it mty; + it.it_module_type unmark_iterators mty end -module Untypeast : sig -#1 "untypeast.mli" +module Includemod : sig +#1 "includemod.mli" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Thomas Gazagnaire (OCamlPro), Fabrice Le Fessant (INRIA Saclay) *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) (* *) -(* Copyright 2007 Institut National de Recherche en Informatique et *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -54973,80 +54549,66 @@ module Untypeast : sig (* *) (**************************************************************************) -open Parsetree +(* Inclusion checks for the module language *) -val lident_of_path : Path.t -> Longident.t +open Typedtree +open Types +open Format -type mapper = { - attribute: mapper -> Typedtree.attribute -> attribute; - attributes: mapper -> Typedtree.attribute list -> attribute list; - case: mapper -> Typedtree.case -> case; - cases: mapper -> Typedtree.case list -> case list; - class_declaration: mapper -> Typedtree.class_declaration -> class_declaration; - class_description: mapper -> Typedtree.class_description -> class_description; - class_expr: mapper -> Typedtree.class_expr -> class_expr; - class_field: mapper -> Typedtree.class_field -> class_field; - class_signature: mapper -> Typedtree.class_signature -> class_signature; - class_structure: mapper -> Typedtree.class_structure -> class_structure; - class_type: mapper -> Typedtree.class_type -> class_type; - class_type_declaration: mapper -> Typedtree.class_type_declaration - -> class_type_declaration; - class_type_field: mapper -> Typedtree.class_type_field -> class_type_field; - constructor_declaration: mapper -> Typedtree.constructor_declaration - -> constructor_declaration; - expr: mapper -> Typedtree.expression -> expression; - extension_constructor: mapper -> Typedtree.extension_constructor - -> extension_constructor; - include_declaration: - mapper -> Typedtree.include_declaration -> include_declaration; - include_description: - mapper -> Typedtree.include_description -> include_description; - label_declaration: - mapper -> Typedtree.label_declaration -> label_declaration; - location: mapper -> Location.t -> Location.t; - module_binding: mapper -> Typedtree.module_binding -> module_binding; - module_declaration: - mapper -> Typedtree.module_declaration -> module_declaration; - module_expr: mapper -> Typedtree.module_expr -> module_expr; - module_type: mapper -> Typedtree.module_type -> module_type; - module_type_declaration: - mapper -> Typedtree.module_type_declaration -> module_type_declaration; - package_type: mapper -> Typedtree.package_type -> package_type; - open_description: mapper -> Typedtree.open_description -> open_description; - pat: mapper -> Typedtree.pattern -> pattern; - row_field: mapper -> Typedtree.row_field -> row_field; - object_field: mapper -> Typedtree.object_field -> object_field; - signature: mapper -> Typedtree.signature -> signature; - signature_item: mapper -> Typedtree.signature_item -> signature_item; - structure: mapper -> Typedtree.structure -> structure; - structure_item: mapper -> Typedtree.structure_item -> structure_item; - typ: mapper -> Typedtree.core_type -> core_type; - type_declaration: mapper -> Typedtree.type_declaration -> type_declaration; - type_extension: mapper -> Typedtree.type_extension -> type_extension; - type_kind: mapper -> Typedtree.type_kind -> type_kind; - value_binding: mapper -> Typedtree.value_binding -> value_binding; - value_description: mapper -> Typedtree.value_description -> value_description; - with_constraint: - mapper -> (Path.t * Longident.t Location.loc * Typedtree.with_constraint) - -> with_constraint; -} +val modtypes: + loc:Location.t -> Env.t -> + module_type -> module_type -> module_coercion -val default_mapper : mapper +val signatures: Env.t -> signature -> signature -> module_coercion -val untype_structure : ?mapper:mapper -> Typedtree.structure -> structure -val untype_signature : ?mapper:mapper -> Typedtree.signature -> signature +val compunit: + Env.t -> string -> signature -> string -> signature -> module_coercion -val constant : Asttypes.constant -> Parsetree.constant +val type_declarations: + loc:Location.t -> Env.t -> + Ident.t -> type_declaration -> type_declaration -> unit + +val print_coercion: formatter -> module_coercion -> unit + +type symptom = + Missing_field of Ident.t * Location.t * string (* kind *) + | Value_descriptions of Ident.t * value_description * value_description + | Type_declarations of Ident.t * type_declaration + * type_declaration * Includecore.type_mismatch list + | Extension_constructors of + Ident.t * extension_constructor * extension_constructor + | Module_types of module_type * module_type + | Modtype_infos of Ident.t * modtype_declaration * modtype_declaration + | Modtype_permutation + | Interface_mismatch of string * string + | Class_type_declarations of + Ident.t * class_type_declaration * class_type_declaration * + Ctype.class_match_failure list + | Class_declarations of + Ident.t * class_declaration * class_declaration * + Ctype.class_match_failure list + | Unbound_modtype_path of Path.t + | Unbound_module_path of Path.t + | Invalid_module_alias of Path.t + +type pos = + Module of Ident.t | Modtype of Ident.t | Arg of Ident.t | Body of Ident.t +type error = pos list * Env.t * symptom + +exception Error of error list + +val report_error: formatter -> error list -> unit +val expand_module_alias: Env.t -> pos list -> Path.t -> Types.module_type end = struct -#1 "untypeast.ml" +#1 "includemod.ml" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Thomas Gazagnaire (OCamlPro), Fabrice Le Fessant (INRIA Saclay) *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) (* *) -(* Copyright 2007 Institut National de Recherche en Informatique et *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -55055,826 +54617,691 @@ end = struct (* *) (**************************************************************************) -open Longident -open Asttypes -open Parsetree -open Ast_helper - -module T = Typedtree - -type mapper = { - attribute: mapper -> T.attribute -> attribute; - attributes: mapper -> T.attribute list -> attribute list; - case: mapper -> T.case -> case; - cases: mapper -> T.case list -> case list; - class_declaration: mapper -> T.class_declaration -> class_declaration; - class_description: mapper -> T.class_description -> class_description; - class_expr: mapper -> T.class_expr -> class_expr; - class_field: mapper -> T.class_field -> class_field; - class_signature: mapper -> T.class_signature -> class_signature; - class_structure: mapper -> T.class_structure -> class_structure; - class_type: mapper -> T.class_type -> class_type; - class_type_declaration: mapper -> T.class_type_declaration - -> class_type_declaration; - class_type_field: mapper -> T.class_type_field -> class_type_field; - constructor_declaration: mapper -> T.constructor_declaration - -> constructor_declaration; - expr: mapper -> T.expression -> expression; - extension_constructor: mapper -> T.extension_constructor - -> extension_constructor; - include_declaration: mapper -> T.include_declaration -> include_declaration; - include_description: mapper -> T.include_description -> include_description; - label_declaration: mapper -> T.label_declaration -> label_declaration; - location: mapper -> Location.t -> Location.t; - module_binding: mapper -> T.module_binding -> module_binding; - module_declaration: mapper -> T.module_declaration -> module_declaration; - module_expr: mapper -> T.module_expr -> module_expr; - module_type: mapper -> T.module_type -> module_type; - module_type_declaration: - mapper -> T.module_type_declaration -> module_type_declaration; - package_type: mapper -> T.package_type -> package_type; - open_description: mapper -> T.open_description -> open_description; - pat: mapper -> T.pattern -> pattern; - row_field: mapper -> T.row_field -> row_field; - object_field: mapper -> T.object_field -> object_field; - signature: mapper -> T.signature -> signature; - signature_item: mapper -> T.signature_item -> signature_item; - structure: mapper -> T.structure -> structure; - structure_item: mapper -> T.structure_item -> structure_item; - typ: mapper -> T.core_type -> core_type; - type_declaration: mapper -> T.type_declaration -> type_declaration; - type_extension: mapper -> T.type_extension -> type_extension; - type_kind: mapper -> T.type_kind -> type_kind; - value_binding: mapper -> T.value_binding -> value_binding; - value_description: mapper -> T.value_description -> value_description; - with_constraint: - mapper -> (Path.t * Longident.t Location.loc * T.with_constraint) - -> with_constraint; -} - -open T - -(* -Some notes: +(* Inclusion checks for the module language *) - * For Pexp_function, we cannot go back to the exact original version - when there is a default argument, because the default argument is - translated in the typer. The code, if printed, will not be parsable because - new generated identifiers are not correct. +open Misc +open Path +open Typedtree +open Types - * For Pexp_apply, it is unclear whether arguments are reordered, especially - when there are optional arguments. +type symptom = + Missing_field of Ident.t * Location.t * string (* kind *) + | Value_descriptions of Ident.t * value_description * value_description + | Type_declarations of Ident.t * type_declaration + * type_declaration * Includecore.type_mismatch list + | Extension_constructors of + Ident.t * extension_constructor * extension_constructor + | Module_types of module_type * module_type + | Modtype_infos of Ident.t * modtype_declaration * modtype_declaration + | Modtype_permutation + | Interface_mismatch of string * string + | Class_type_declarations of + Ident.t * class_type_declaration * class_type_declaration * + Ctype.class_match_failure list + | Class_declarations of + Ident.t * class_declaration * class_declaration * + Ctype.class_match_failure list + | Unbound_modtype_path of Path.t + | Unbound_module_path of Path.t + | Invalid_module_alias of Path.t -*) +type pos = + Module of Ident.t | Modtype of Ident.t | Arg of Ident.t | Body of Ident.t +type error = pos list * Env.t * symptom +exception Error of error list -(** Utility functions. *) +(* All functions "blah env x1 x2" check that x1 is included in x2, + i.e. that x1 is the type of an implementation that fulfills the + specification x2. If not, Error is raised with a backtrace of the error. *) -let string_is_prefix sub str = - let sublen = String.length sub in - String.length str >= sublen && String.sub str 0 sublen = sub +(* Inclusion between value descriptions *) -let map_opt f = function None -> None | Some e -> Some (f e) +let value_descriptions ~loc env cxt subst id vd1 vd2 = + Cmt_format.record_value_dependency vd1 vd2; + Env.mark_value_used env (Ident.name id) vd1; + let vd2 = Subst.value_description subst vd2 in + try -let rec lident_of_path = function - | Path.Pident id -> Longident.Lident (Ident.name id) - | Path.Pdot (p, s, _) -> Longident.Ldot (lident_of_path p, s) - | Path.Papply (p1, p2) -> - Longident.Lapply (lident_of_path p1, lident_of_path p2) + Includecore.value_descriptions ~loc env id vd1 vd2 + + with Includecore.Dont_match -> + raise(Error[cxt, env, Value_descriptions(id, vd1, vd2)]) -let map_loc sub {loc; txt} = {loc = sub.location sub loc; txt} +(* Inclusion between type declarations *) -(** Try a name [$name$0], check if it's free, if not, increment and repeat. *) -let fresh_name s env = - let rec aux i = - let name = s ^ string_of_int i in - try - let _ = Env.lookup_value (Lident name) env in - name - with - | Not_found -> aux (i+1) +let type_declarations ~loc env ?(old_env=env) cxt subst id decl1 decl2 = + Env.mark_type_used env (Ident.name id) decl1; + let decl2 = Subst.type_declaration subst decl2 in + let err = + Includecore.type_declarations ~loc env (Ident.name id) decl1 id decl2 in - aux 0 - -(** Mapping functions. *) + if err <> [] then + raise(Error[cxt, old_env, Type_declarations(id, decl1, decl2, err)]) -let constant = function - | Const_char c -> Pconst_char c - | Const_string (s,d) -> Pconst_string (s,d) - | Const_int i -> Pconst_integer (string_of_int i, None) - | Const_int32 i -> Pconst_integer (Int32.to_string i, Some 'l') - | Const_int64 i -> Pconst_integer (Int64.to_string i, Some 'L') - | Const_nativeint i -> Pconst_integer (Nativeint.to_string i, Some 'n') - | Const_float f -> Pconst_float (f,None) +(* Inclusion between extension constructors *) -let attribute sub (s, p) = (map_loc sub s, p) -let attributes sub l = List.map (sub.attribute sub) l +let extension_constructors ~loc env cxt subst id ext1 ext2 = + let ext2 = Subst.extension_constructor subst ext2 in + if Includecore.extension_constructors ~loc env id ext1 ext2 + then () + else raise(Error[cxt, env, Extension_constructors(id, ext1, ext2)]) -let structure sub str = - List.map (sub.structure_item sub) str.str_items +(* Inclusion between class declarations *) -let open_description sub od = - let loc = sub.location sub od.open_loc in - let attrs = sub.attributes sub od.open_attributes in - Opn.mk ~loc ~attrs - ~override:od.open_override - (map_loc sub od.open_txt) +let class_type_declarations ~loc ~old_env env cxt subst id decl1 decl2 = + let decl2 = Subst.cltype_declaration subst decl2 in + match Includeclass.class_type_declarations ~loc env decl1 decl2 with + [] -> () + | reason -> + raise(Error[cxt, old_env, + Class_type_declarations(id, decl1, decl2, reason)]) -let structure_item sub item = - let loc = sub.location sub item.str_loc in - let desc = - match item.str_desc with - Tstr_eval (exp, attrs) -> Pstr_eval (sub.expr sub exp, attrs) - | Tstr_value (rec_flag, list) -> - Pstr_value (rec_flag, List.map (sub.value_binding sub) list) - | Tstr_primitive vd -> - Pstr_primitive (sub.value_description sub vd) - | Tstr_type (rec_flag, list) -> - Pstr_type (rec_flag, List.map (sub.type_declaration sub) list) - | Tstr_typext tyext -> - Pstr_typext (sub.type_extension sub tyext) - | Tstr_exception ext -> - Pstr_exception (sub.extension_constructor sub ext) - | Tstr_module mb -> - Pstr_module (sub.module_binding sub mb) - | Tstr_recmodule list -> - Pstr_recmodule (List.map (sub.module_binding sub) list) - | Tstr_modtype mtd -> - Pstr_modtype (sub.module_type_declaration sub mtd) - | Tstr_open od -> - Pstr_open (sub.open_description sub od) - | Tstr_class list -> - Pstr_class - (List.map - (fun (ci, _) -> sub.class_declaration sub ci) - list) - | Tstr_class_type list -> - Pstr_class_type - (List.map - (fun (_id, _name, ct) -> sub.class_type_declaration sub ct) - list) - | Tstr_include incl -> - Pstr_include (sub.include_declaration sub incl) - | Tstr_attribute x -> - Pstr_attribute x - in - Str.mk ~loc desc +let class_declarations ~old_env env cxt subst id decl1 decl2 = + let decl2 = Subst.class_declaration subst decl2 in + match Includeclass.class_declarations env decl1 decl2 with + [] -> () + | reason -> + raise(Error[cxt, old_env, Class_declarations(id, decl1, decl2, reason)]) -let value_description sub v = - let loc = sub.location sub v.val_loc in - let attrs = sub.attributes sub v.val_attributes in - Val.mk ~loc ~attrs - ~prim:v.val_prim - (map_loc sub v.val_name) - (sub.typ sub v.val_desc) +(* Expand a module type identifier when possible *) -let module_binding sub mb = - let loc = sub.location sub mb.mb_loc in - let attrs = sub.attributes sub mb.mb_attributes in - Mb.mk ~loc ~attrs - (map_loc sub mb.mb_name) - (sub.module_expr sub mb.mb_expr) +exception Dont_match -let type_parameter sub (ct, v) = (sub.typ sub ct, v) +let may_expand_module_path env path = + try ignore (Env.find_modtype_expansion path env); true + with Not_found -> false -let type_declaration sub decl = - let loc = sub.location sub decl.typ_loc in - let attrs = sub.attributes sub decl.typ_attributes in - Type.mk ~loc ~attrs - ~params:(List.map (type_parameter sub) decl.typ_params) - ~cstrs:( - List.map - (fun (ct1, ct2, loc) -> - (sub.typ sub ct1, sub.typ sub ct2, sub.location sub loc)) - decl.typ_cstrs) - ~kind:(sub.type_kind sub decl.typ_kind) - ~priv:decl.typ_private - ?manifest:(map_opt (sub.typ sub) decl.typ_manifest) - (map_loc sub decl.typ_name) +let expand_module_path env cxt path = + try + Env.find_modtype_expansion path env + with Not_found -> + raise(Error[cxt, env, Unbound_modtype_path path]) -let type_kind sub tk = match tk with - | Ttype_abstract -> Ptype_abstract - | Ttype_variant list -> - Ptype_variant (List.map (sub.constructor_declaration sub) list) - | Ttype_record list -> - Ptype_record (List.map (sub.label_declaration sub) list) - | Ttype_open -> Ptype_open +let expand_module_alias env cxt path = + try (Env.find_module path env).md_type + with Not_found -> + raise(Error[cxt, env, Unbound_module_path path]) -let constructor_arguments sub = function - | Cstr_tuple l -> Pcstr_tuple (List.map (sub.typ sub) l) - | Cstr_record l -> Pcstr_record (List.map (sub.label_declaration sub) l) +(* +let rec normalize_module_path env cxt path = + match expand_module_alias env cxt path with + Mty_alias path' -> normalize_module_path env cxt path' + | _ -> path +*) -let constructor_declaration sub cd = - let loc = sub.location sub cd.cd_loc in - let attrs = sub.attributes sub cd.cd_attributes in - Type.constructor ~loc ~attrs - ~args:(constructor_arguments sub cd.cd_args) - ?res:(map_opt (sub.typ sub) cd.cd_res) - (map_loc sub cd.cd_name) +(* Extract name, kind and ident from a signature item *) -let label_declaration sub ld = - let loc = sub.location sub ld.ld_loc in - let attrs = sub.attributes sub ld.ld_attributes in - Type.field ~loc ~attrs - ~mut:ld.ld_mutable - (map_loc sub ld.ld_name) - (sub.typ sub ld.ld_type) +type field_desc = + Field_value of string + | Field_type of string + | Field_typext of string + | Field_module of string + | Field_modtype of string + | Field_class of string + | Field_classtype of string -let type_extension sub tyext = - let attrs = sub.attributes sub tyext.tyext_attributes in - Te.mk ~attrs - ~params:(List.map (type_parameter sub) tyext.tyext_params) - ~priv:tyext.tyext_private - (map_loc sub tyext.tyext_txt) - (List.map (sub.extension_constructor sub) tyext.tyext_constructors) +let kind_of_field_desc = function + | Field_value _ -> "value" + | Field_type _ -> "type" + | Field_typext _ -> "extension constructor" + | Field_module _ -> "module" + | Field_modtype _ -> "module type" + | Field_class _ -> "class" + | Field_classtype _ -> "class type" -let extension_constructor sub ext = - let loc = sub.location sub ext.ext_loc in - let attrs = sub.attributes sub ext.ext_attributes in - Te.constructor ~loc ~attrs - (map_loc sub ext.ext_name) - (match ext.ext_kind with - | Text_decl (args, ret) -> - Pext_decl (constructor_arguments sub args, - map_opt (sub.typ sub) ret) - | Text_rebind (_p, lid) -> Pext_rebind (map_loc sub lid) - ) +let item_ident_name = function + Sig_value(id, d) -> (id, d.val_loc, Field_value(Ident.name id)) + | Sig_type(id, d, _) -> (id, d.type_loc, Field_type(Ident.name id)) + | Sig_typext(id, d, _) -> (id, d.ext_loc, Field_typext(Ident.name id)) + | Sig_module(id, d, _) -> (id, d.md_loc, Field_module(Ident.name id)) + | Sig_modtype(id, d) -> (id, d.mtd_loc, Field_modtype(Ident.name id)) + | Sig_class(id, d, _) -> (id, d.cty_loc, Field_class(Ident.name id)) + | Sig_class_type(id, d, _) -> (id, d.clty_loc, Field_classtype(Ident.name id)) -let pattern sub pat = - let loc = sub.location sub pat.pat_loc in - (* todo: fix attributes on extras *) - let attrs = sub.attributes sub pat.pat_attributes in - let desc = - match pat with - { pat_extra=[Tpat_unpack, _, _attrs]; pat_desc = Tpat_var (_,name); _ } -> - Ppat_unpack name - | { pat_extra=[Tpat_type (_path, lid), _, _attrs]; _ } -> - Ppat_type (map_loc sub lid) - | { pat_extra= (Tpat_constraint ct, _, _attrs) :: rem; _ } -> - Ppat_constraint (sub.pat sub { pat with pat_extra=rem }, - sub.typ sub ct) - | _ -> - match pat.pat_desc with - Tpat_any -> Ppat_any - | Tpat_var (id, name) -> - begin - match (Ident.name id).[0] with - 'A'..'Z' -> - Ppat_unpack name - | _ -> - Ppat_var name - end +let is_runtime_component = function + | Sig_value(_,{val_kind = Val_prim _}) + | Sig_type(_,_,_) + | Sig_modtype(_,_) + | Sig_class_type(_,_,_) -> false + | Sig_value(_,_) + | Sig_typext(_,_,_) + | Sig_module(_,_,_) + | Sig_class(_, _,_) -> true - (* We transform (_ as x) in x if _ and x have the same location. - The compiler transforms (x:t) into (_ as x : t). - This avoids transforming a warning 27 into a 26. - *) - | Tpat_alias ({pat_desc = Tpat_any; pat_loc}, _id, name) - when pat_loc = pat.pat_loc -> - Ppat_var name +(* Print a coercion *) - | Tpat_alias (pat, _id, name) -> - Ppat_alias (sub.pat sub pat, name) - | Tpat_constant cst -> Ppat_constant (constant cst) - | Tpat_tuple list -> - Ppat_tuple (List.map (sub.pat sub) list) - | Tpat_construct (lid, _, args) -> - Ppat_construct (map_loc sub lid, - (match args with - [] -> None - | [arg] -> Some (sub.pat sub arg) - | args -> - Some - (Pat.tuple ~loc - (List.map (sub.pat sub) args) - ) - )) - | Tpat_variant (label, pato, _) -> - Ppat_variant (label, map_opt (sub.pat sub) pato) - | Tpat_record (list, closed) -> - Ppat_record (List.map (fun (lid, _, pat) -> - map_loc sub lid, sub.pat sub pat) list, closed) - | Tpat_array list -> Ppat_array (List.map (sub.pat sub) list) - | Tpat_or (p1, p2, _) -> Ppat_or (sub.pat sub p1, sub.pat sub p2) - | Tpat_lazy p -> Ppat_lazy (sub.pat sub p) - in - Pat.mk ~loc ~attrs desc +let rec print_list pr ppf = function + [] -> () + | [a] -> pr ppf a + | a :: l -> pr ppf a; Format.fprintf ppf ";@ "; print_list pr ppf l +let print_list pr ppf l = + Format.fprintf ppf "[@[%a@]]" (print_list pr) l -let exp_extra sub (extra, loc, attrs) sexp = - let loc = sub.location sub loc in - let attrs = sub.attributes sub attrs in - let desc = - match extra with - Texp_coerce (cty1, cty2) -> - Pexp_coerce (sexp, - map_opt (sub.typ sub) cty1, - sub.typ sub cty2) - | Texp_constraint cty -> - Pexp_constraint (sexp, sub.typ sub cty) - | Texp_open (ovf, _path, lid, _) -> - Pexp_open (ovf, map_loc sub lid, sexp) - | Texp_poly cto -> Pexp_poly (sexp, map_opt (sub.typ sub) cto) - | Texp_newtype s -> Pexp_newtype (mkloc s loc, sexp) - in - Exp.mk ~loc ~attrs desc +let rec print_coercion ppf c = + let pr fmt = Format.fprintf ppf fmt in + match c with + Tcoerce_none -> pr "id" + | Tcoerce_structure (fl, nl, _) -> + pr "@[<2>struct@ %a@ %a@]" + (print_list print_coercion2) fl + (print_list print_coercion3) nl + | Tcoerce_functor (inp, out) -> + pr "@[<2>functor@ (%a)@ (%a)@]" + print_coercion inp + print_coercion out + | Tcoerce_primitive {pc_desc; pc_env = _; pc_type} -> + pr "prim %s@ (%a)" pc_desc.Primitive.prim_name + Printtyp.raw_type_expr pc_type + | Tcoerce_alias (p, c) -> + pr "@[<2>alias %a@ (%a)@]" + Printtyp.path p + print_coercion c +and print_coercion2 ppf (n, c) = + Format.fprintf ppf "@[%d,@ %a@]" n print_coercion c +and print_coercion3 ppf (i, n, c) = + Format.fprintf ppf "@[%s, %d,@ %a@]" + (Ident.unique_name i) n print_coercion c -let cases sub l = List.map (sub.case sub) l +(* Simplify a structure coercion *) -let case sub {c_lhs; c_guard; c_rhs} = - { - pc_lhs = sub.pat sub c_lhs; - pc_guard = map_opt (sub.expr sub) c_guard; - pc_rhs = sub.expr sub c_rhs; - } +let simplify_structure_coercion cc id_pos_list runtime_fields = + let rec is_identity_coercion pos = function + | [] -> + true + | (n, c) :: rem -> + n = pos && c = Tcoerce_none && is_identity_coercion (pos + 1) rem in + if is_identity_coercion 0 cc + then Tcoerce_none + else Tcoerce_structure (cc, id_pos_list, runtime_fields) -let value_binding sub vb = - let loc = sub.location sub vb.vb_loc in - let attrs = sub.attributes sub vb.vb_attributes in - Vb.mk ~loc ~attrs - (sub.pat sub vb.vb_pat) - (sub.expr sub vb.vb_expr) +(* Inclusion between module types. + Return the restriction that transforms a value of the smaller type + into a value of the bigger type. *) -let expression sub exp = - let loc = sub.location sub exp.exp_loc in - let attrs = sub.attributes sub exp.exp_attributes in - let desc = - match exp.exp_desc with - Texp_ident (_path, lid, _) -> Pexp_ident (map_loc sub lid) - | Texp_constant cst -> Pexp_constant (constant cst) - | Texp_let (rec_flag, list, exp) -> - Pexp_let (rec_flag, - List.map (sub.value_binding sub) list, - sub.expr sub exp) +let rec modtypes ~loc env cxt subst mty1 mty2 = + try + try_modtypes ~loc env cxt subst mty1 mty2 + with + Dont_match -> + raise(Error[cxt, env, Module_types(mty1, Subst.modtype subst mty2)]) + | Error reasons as err -> + match mty1, mty2 with + Mty_alias _, _ + | _, Mty_alias _ -> raise err + | _ -> + raise(Error((cxt, env, Module_types(mty1, Subst.modtype subst mty2)) + :: reasons)) - (* Pexp_function can't have a label, so we split in 3 cases. *) - (* One case, no guard: It's a fun. *) - | Texp_function { arg_label; cases = [{c_lhs=p; c_guard=None; c_rhs=e}]; - _ } -> - Pexp_fun (arg_label, None, sub.pat sub p, sub.expr sub e) - (* No label: it's a function. *) - | Texp_function { arg_label = Nolabel; cases; _; } -> - Pexp_function (sub.cases sub cases) - (* Mix of both, we generate `fun ~label:$name$ -> match $name$ with ...` *) - | Texp_function { arg_label = Labelled s | Optional s as label; cases; - _ } -> - let name = fresh_name s exp.exp_env in - Pexp_fun (label, None, Pat.var ~loc {loc;txt = name }, - Exp.match_ ~loc (Exp.ident ~loc {loc;txt= Lident name}) - (sub.cases sub cases)) - | Texp_apply (exp, list) -> - Pexp_apply (sub.expr sub exp, - List.fold_right (fun (label, expo) list -> - match expo with - None -> list - | Some exp -> (label, sub.expr sub exp) :: list - ) list []) - | Texp_match (exp, cases, exn_cases, _) -> - let merged_cases = sub.cases sub cases - @ List.map - (fun c -> - let uc = sub.case sub c in - let pat = { uc.pc_lhs - with ppat_desc = Ppat_exception uc.pc_lhs } - in - { uc with pc_lhs = pat }) - exn_cases - in - Pexp_match (sub.expr sub exp, merged_cases) - | Texp_try (exp, cases) -> - Pexp_try (sub.expr sub exp, sub.cases sub cases) - | Texp_tuple list -> - Pexp_tuple (List.map (sub.expr sub) list) - | Texp_construct (lid, _, args) -> - Pexp_construct (map_loc sub lid, - (match args with - [] -> None - | [ arg ] -> Some (sub.expr sub arg) - | args -> - Some - (Exp.tuple ~loc (List.map (sub.expr sub) args)) - )) - | Texp_variant (label, expo) -> - Pexp_variant (label, map_opt (sub.expr sub) expo) - | Texp_record { fields; extended_expression; _ } -> - let list = Array.fold_left (fun l -> function - | _, Kept _ -> l - | _, Overridden (lid, exp) -> (lid, sub.expr sub exp) :: l) - [] fields +and try_modtypes ~loc env cxt subst mty1 mty2 = + match (mty1, mty2) with + | (Mty_alias(pres1, p1), Mty_alias(pres2, p2)) -> begin + if Env.is_functor_arg p2 env then + raise (Error[cxt, env, Invalid_module_alias p2]); + if not (Path.same p1 p2) then begin + let p1 = Env.normalize_path None env p1 + and p2 = Env.normalize_path None env (Subst.module_path subst p2) in + if not (Path.same p1 p2) then raise Dont_match + end; + match pres1, pres2 with + | Mta_present, Mta_present -> Tcoerce_none + (* Should really be Tcoerce_ignore if it existed *) + | Mta_absent, Mta_absent -> Tcoerce_none + (* Should really be Tcoerce_empty if it existed *) + | Mta_present, Mta_absent -> Tcoerce_none + | Mta_absent, Mta_present -> + let p1 = try + Env.normalize_path (Some Location.none) env p1 + with Env.Error (Env.Missing_module (_, _, path)) -> + raise (Error[cxt, env, Unbound_module_path path]) in - Pexp_record (list, map_opt (sub.expr sub) extended_expression) - | Texp_field (exp, lid, _label) -> - Pexp_field (sub.expr sub exp, map_loc sub lid) - | Texp_setfield (exp1, lid, _label, exp2) -> - Pexp_setfield (sub.expr sub exp1, map_loc sub lid, - sub.expr sub exp2) - | Texp_array list -> - Pexp_array (List.map (sub.expr sub) list) - | Texp_ifthenelse (exp1, exp2, expo) -> - Pexp_ifthenelse (sub.expr sub exp1, - sub.expr sub exp2, - map_opt (sub.expr sub) expo) - | Texp_sequence (exp1, exp2) -> - Pexp_sequence (sub.expr sub exp1, sub.expr sub exp2) - | Texp_while (exp1, exp2) -> - Pexp_while (sub.expr sub exp1, sub.expr sub exp2) - | Texp_for (_id, name, exp1, exp2, dir, exp3) -> - Pexp_for (name, - sub.expr sub exp1, sub.expr sub exp2, - dir, sub.expr sub exp3) - | Texp_send (exp, meth, _) -> - Pexp_send (sub.expr sub exp, match meth with - Tmeth_name name -> mkloc name loc - | Tmeth_val id -> mkloc (Ident.name id) loc) - | Texp_new (_path, lid, _) -> Pexp_new (map_loc sub lid) - | Texp_instvar (_, path, name) -> - Pexp_ident ({loc = sub.location sub name.loc ; txt = lident_of_path path}) - | Texp_setinstvar (_, _path, lid, exp) -> - Pexp_setinstvar (map_loc sub lid, sub.expr sub exp) - | Texp_override (_, list) -> - Pexp_override (List.map (fun (_path, lid, exp) -> - (map_loc sub lid, sub.expr sub exp) - ) list) - | Texp_letmodule (_id, name, mexpr, exp) -> - Pexp_letmodule (name, sub.module_expr sub mexpr, - sub.expr sub exp) - | Texp_letexception (ext, exp) -> - Pexp_letexception (sub.extension_constructor sub ext, - sub.expr sub exp) - | Texp_assert exp -> Pexp_assert (sub.expr sub exp) - | Texp_lazy exp -> Pexp_lazy (sub.expr sub exp) - | Texp_object (cl, _) -> - Pexp_object (sub.class_structure sub cl) - | Texp_pack (mexpr) -> - Pexp_pack (sub.module_expr sub mexpr) - | Texp_unreachable -> - Pexp_unreachable - | Texp_extension_constructor (lid, _) -> - Pexp_extension ({ txt = "ocaml.extension_constructor"; loc }, - PStr [ Str.eval ~loc - (Exp.construct ~loc (map_loc sub lid) None) - ]) - in - List.fold_right (exp_extra sub) exp.exp_extra - (Exp.mk ~loc ~attrs desc) + Tcoerce_alias (p1, Tcoerce_none) + end + | (Mty_alias(pres1, p1), _) -> begin + let p1 = try + Env.normalize_path (Some Location.none) env p1 + with Env.Error (Env.Missing_module (_, _, path)) -> + raise (Error[cxt, env, Unbound_module_path path]) + in + let mty1 = + Mtype.strengthen ~aliasable:true env + (expand_module_alias env cxt p1) p1 + in + let cc = modtypes ~loc env cxt subst mty1 mty2 in + match pres1 with + | Mta_present -> cc + | Mta_absent -> Tcoerce_alias (p1, cc) + end + | (Mty_ident p1, _) when may_expand_module_path env p1 -> + try_modtypes ~loc env cxt subst (expand_module_path env cxt p1) mty2 + | (_, Mty_ident _) -> + try_modtypes2 ~loc env cxt mty1 (Subst.modtype subst mty2) + | (Mty_signature sig1, Mty_signature sig2) -> + signatures ~loc env cxt subst sig1 sig2 + | (Mty_functor(param1, None, res1), Mty_functor(_param2, None, res2)) -> + begin match modtypes ~loc env (Body param1::cxt) subst res1 res2 with + Tcoerce_none -> Tcoerce_none + | cc -> Tcoerce_functor (Tcoerce_none, cc) + end + | (Mty_functor(param1, Some arg1, res1), + Mty_functor(param2, Some arg2, res2)) -> + let arg2' = Subst.modtype subst arg2 in + let cc_arg = modtypes ~loc env (Arg param1::cxt) Subst.identity arg2' arg1 in + let cc_res = + modtypes ~loc (Env.add_module param1 arg2' env) (Body param1::cxt) + (Subst.add_module param2 (Pident param1) subst) res1 res2 in + begin match (cc_arg, cc_res) with + (Tcoerce_none, Tcoerce_none) -> Tcoerce_none + | _ -> Tcoerce_functor(cc_arg, cc_res) + end + | (_, _) -> + raise Dont_match -let package_type sub pack = - (map_loc sub pack.pack_txt, - List.map (fun (s, ct) -> - (s, sub.typ sub ct)) pack.pack_fields) +and try_modtypes2 ~loc env cxt mty1 mty2 = + (* mty2 is an identifier *) + match (mty1, mty2) with + (Mty_ident p1, Mty_ident p2) + when Path.same (Env.normalize_path_prefix None env p1) + (Env.normalize_path_prefix None env p2) -> + Tcoerce_none + | (_, Mty_ident p2) when may_expand_module_path env p2 -> + try_modtypes ~loc env cxt Subst.identity mty1 (expand_module_path env cxt p2) + | (_, _) -> + raise Dont_match -let module_type_declaration sub mtd = - let loc = sub.location sub mtd.mtd_loc in - let attrs = sub.attributes sub mtd.mtd_attributes in - Mtd.mk ~loc ~attrs - ?typ:(map_opt (sub.module_type sub) mtd.mtd_type) - (map_loc sub mtd.mtd_name) +(* Inclusion between signatures *) -let signature sub sg = - List.map (sub.signature_item sub) sg.sig_items +and signatures ~loc env cxt subst sig1 sig2 = + (* Environment used to check inclusion of components *) + let new_env = + Env.add_signature sig1 (Env.in_signature true env) in + (* Keep ids for module aliases *) + let (id_pos_list,_) = + List.fold_left + (fun (l,pos) -> function + Sig_module (id, _, _) -> + ((id,pos,Tcoerce_none)::l , pos+1) + | item -> (l, if is_runtime_component item then pos+1 else pos)) + ([], 0) sig1 in -let signature_item sub item = - let loc = sub.location sub item.sig_loc in - let desc = - match item.sig_desc with - Tsig_value v -> - Psig_value (sub.value_description sub v) - | Tsig_type (rec_flag, list) -> - Psig_type (rec_flag, List.map (sub.type_declaration sub) list) - | Tsig_typext tyext -> - Psig_typext (sub.type_extension sub tyext) - | Tsig_exception ext -> - Psig_exception (sub.extension_constructor sub ext) - | Tsig_module md -> - Psig_module (sub.module_declaration sub md) - | Tsig_recmodule list -> - Psig_recmodule (List.map (sub.module_declaration sub) list) - | Tsig_modtype mtd -> - Psig_modtype (sub.module_type_declaration sub mtd) - | Tsig_open od -> - Psig_open (sub.open_description sub od) - | Tsig_include incl -> - Psig_include (sub.include_description sub incl) - | Tsig_class list -> - Psig_class (List.map (sub.class_description sub) list) - | Tsig_class_type list -> - Psig_class_type (List.map (sub.class_type_declaration sub) list) - | Tsig_attribute x -> - Psig_attribute x - in - Sig.mk ~loc desc + let runtime_fields = + let get_id = function + | Sig_value (i,_) + | Sig_module (i,_,_) + | Sig_typext (i,_,_) + | Sig_modtype(i,_) + | Sig_class (i,_,_) + | Sig_class_type(i,_,_) + | Sig_type(i,_,_) -> Ident.name i in + List.fold_right (fun item fields -> + if is_runtime_component item then get_id item :: fields else fields) sig2 [] in -let module_declaration sub md = - let loc = sub.location sub md.md_loc in - let attrs = sub.attributes sub md.md_attributes in - Md.mk ~loc ~attrs - (map_loc sub md.md_name) - (sub.module_type sub md.md_type) + (* Build a table of the components of sig1, along with their positions. + The table is indexed by kind and name of component *) + let rec build_component_table pos tbl = function + [] -> pos, tbl + | item :: rem -> + let (id, _loc, name) = item_ident_name item in + let nextpos = if is_runtime_component item then pos + 1 else pos in + build_component_table nextpos + (Tbl.add name (id, item, pos) tbl) rem in + let len1, comps1 = + build_component_table 0 Tbl.empty sig1 in + let len2 = + List.fold_left + (fun n i -> if is_runtime_component i then n + 1 else n) + 0 + sig2 + in + (* Pair each component of sig2 with a component of sig1, + identifying the names along the way. + Return a coercion list indicating, for all run-time components + of sig2, the position of the matching run-time components of sig1 + and the coercion to be applied to it. *) + let rec pair_components subst paired unpaired = function + [] -> + begin match unpaired with + [] -> + let cc = + signature_components ~loc env new_env cxt subst + (List.rev paired) + in + if len1 = len2 then (* see PR#5098 *) + simplify_structure_coercion cc id_pos_list runtime_fields + else + Tcoerce_structure (cc, id_pos_list, runtime_fields) + | _ -> raise(Error unpaired) + end + | item2 :: rem -> + let (id2, loc, name2) = item_ident_name item2 in + let name2, report = + match item2, name2 with + Sig_type (_, {type_manifest=None}, _), Field_type s + when Btype.is_row_name s -> + (* Do not report in case of failure, + as the main type will generate an error *) + Field_type (String.sub s 0 (String.length s - 4)), false + | _ -> name2, true + in + begin try + let (id1, item1, pos1) = Tbl.find name2 comps1 in + let new_subst = + match item2 with + Sig_type _ -> + Subst.add_type id2 (Pident id1) subst + | Sig_module _ -> + Subst.add_module id2 (Pident id1) subst + | Sig_modtype _ -> + Subst.add_modtype id2 (Mty_ident (Pident id1)) subst + | Sig_value _ | Sig_typext _ + | Sig_class _ | Sig_class_type _ -> + subst + in + pair_components new_subst + ((item1, item2, pos1) :: paired) unpaired rem + with Not_found -> + let unpaired = + if report then + (cxt, env, Missing_field (id2, loc, kind_of_field_desc name2)) :: + unpaired + else unpaired in + pair_components subst paired unpaired rem + end in + (* Do the pairing and checking, and return the final coercion *) + pair_components subst [] [] sig2 -let include_infos f sub incl = - let loc = sub.location sub incl.incl_loc in - let attrs = sub.attributes sub incl.incl_attributes in - Incl.mk ~loc ~attrs - (f sub incl.incl_mod) +(* Inclusion between signature components *) -let include_declaration sub = include_infos sub.module_expr sub -let include_description sub = include_infos sub.module_type sub +and signature_components ~loc old_env env cxt subst paired = + let comps_rec rem = signature_components ~loc old_env env cxt subst rem in + match paired with + [] -> [] + | (Sig_value(id1, valdecl1), Sig_value(_id2, valdecl2), pos) :: rem -> + let cc = value_descriptions ~loc env cxt subst id1 valdecl1 valdecl2 in + begin match valdecl2.val_kind with + Val_prim _ -> comps_rec rem + | _ -> (pos, cc) :: comps_rec rem + end + | (Sig_type(id1, tydecl1, _), Sig_type(_id2, tydecl2, _), _pos) :: rem -> + type_declarations ~loc ~old_env env cxt subst id1 tydecl1 tydecl2; + comps_rec rem + | (Sig_typext(id1, ext1, _), Sig_typext(_id2, ext2, _), pos) + :: rem -> + extension_constructors ~loc env cxt subst id1 ext1 ext2; + (pos, Tcoerce_none) :: comps_rec rem + | (Sig_module(id1, mty1, _), Sig_module(_id2, mty2, _), pos) :: rem -> + let cc = module_declarations ~loc env cxt subst id1 mty1 mty2 in + (pos, cc) :: comps_rec rem + | (Sig_modtype(id1, info1), Sig_modtype(_id2, info2), _pos) :: rem -> + modtype_infos ~loc env cxt subst id1 info1 info2; + comps_rec rem + | (Sig_class(id1, decl1, _), Sig_class(_id2, decl2, _), pos) :: rem -> + class_declarations ~old_env env cxt subst id1 decl1 decl2; + (pos, Tcoerce_none) :: comps_rec rem + | (Sig_class_type(id1, info1, _), + Sig_class_type(_id2, info2, _), _pos) :: rem -> + class_type_declarations ~loc ~old_env env cxt subst id1 info1 info2; + comps_rec rem + | _ -> + assert false -let class_infos f sub ci = - let loc = sub.location sub ci.ci_loc in - let attrs = sub.attributes sub ci.ci_attributes in - Ci.mk ~loc ~attrs - ~virt:ci.ci_virt - ~params:(List.map (type_parameter sub) ci.ci_params) - (map_loc sub ci.ci_id_name) - (f sub ci.ci_expr) +and module_declarations ~loc env cxt subst id1 md1 md2 = + Builtin_attributes.check_deprecated_inclusion + ~def:md1.md_loc + ~use:md2.md_loc + loc + md1.md_attributes md2.md_attributes + (Ident.name id1); + let p1 = Pident id1 in + Env.mark_module_used env (Ident.name id1) md1.md_loc; + modtypes ~loc env (Module id1::cxt) subst + (Mtype.strengthen ~aliasable:true env md1.md_type p1) md2.md_type -let class_declaration sub = class_infos sub.class_expr sub -let class_description sub = class_infos sub.class_type sub -let class_type_declaration sub = class_infos sub.class_type sub +(* Inclusion between module type specifications *) -let module_type sub mty = - let loc = sub.location sub mty.mty_loc in - let attrs = sub.attributes sub mty.mty_attributes in - let desc = match mty.mty_desc with - Tmty_ident (_path, lid) -> Pmty_ident (map_loc sub lid) - | Tmty_alias (_path, lid) -> Pmty_alias (map_loc sub lid) - | Tmty_signature sg -> Pmty_signature (sub.signature sub sg) - | Tmty_functor (_id, name, mtype1, mtype2) -> - Pmty_functor (name, map_opt (sub.module_type sub) mtype1, - sub.module_type sub mtype2) - | Tmty_with (mtype, list) -> - Pmty_with (sub.module_type sub mtype, - List.map (sub.with_constraint sub) list) - | Tmty_typeof mexpr -> - Pmty_typeof (sub.module_expr sub mexpr) - in - Mty.mk ~loc ~attrs desc +and modtype_infos ~loc env cxt subst id info1 info2 = + Builtin_attributes.check_deprecated_inclusion + ~def:info1.mtd_loc + ~use:info2.mtd_loc + loc + info1.mtd_attributes info2.mtd_attributes + (Ident.name id); + let info2 = Subst.modtype_declaration subst info2 in + let cxt' = Modtype id :: cxt in + try + match (info1.mtd_type, info2.mtd_type) with + (None, None) -> () + | (Some _, None) -> () + | (Some mty1, Some mty2) -> + check_modtype_equiv ~loc env cxt' mty1 mty2 + | (None, Some mty2) -> + check_modtype_equiv ~loc env cxt' (Mty_ident(Pident id)) mty2 + with Error reasons -> + raise(Error((cxt, env, Modtype_infos(id, info1, info2)) :: reasons)) -let with_constraint sub (_path, lid, cstr) = - match cstr with - | Twith_type decl -> - Pwith_type (map_loc sub lid, sub.type_declaration sub decl) - | Twith_module (_path, lid2) -> - Pwith_module (map_loc sub lid, map_loc sub lid2) - | Twith_typesubst decl -> - Pwith_typesubst (map_loc sub lid, sub.type_declaration sub decl) - | Twith_modsubst (_path, lid2) -> - Pwith_modsubst (map_loc sub lid, map_loc sub lid2) +and check_modtype_equiv ~loc env cxt mty1 mty2 = + match + (modtypes ~loc env cxt Subst.identity mty1 mty2, + modtypes ~loc env cxt Subst.identity mty2 mty1) + with + (Tcoerce_none, Tcoerce_none) -> () + | (_c1, _c2) -> + (* Format.eprintf "@[c1 = %a@ c2 = %a@]@." + print_coercion _c1 print_coercion _c2; *) + raise(Error [cxt, env, Modtype_permutation]) -let module_expr sub mexpr = - let loc = sub.location sub mexpr.mod_loc in - let attrs = sub.attributes sub mexpr.mod_attributes in - match mexpr.mod_desc with - Tmod_constraint (m, _, Tmodtype_implicit, _ ) -> - sub.module_expr sub m - | _ -> - let desc = match mexpr.mod_desc with - Tmod_ident (_p, lid) -> Pmod_ident (map_loc sub lid) - | Tmod_structure st -> Pmod_structure (sub.structure sub st) - | Tmod_functor (_id, name, mtype, mexpr) -> - Pmod_functor (name, Misc.may_map (sub.module_type sub) mtype, - sub.module_expr sub mexpr) - | Tmod_apply (mexp1, mexp2, _) -> - Pmod_apply (sub.module_expr sub mexp1, sub.module_expr sub mexp2) - | Tmod_constraint (mexpr, _, Tmodtype_explicit mtype, _) -> - Pmod_constraint (sub.module_expr sub mexpr, - sub.module_type sub mtype) - | Tmod_constraint (_mexpr, _, Tmodtype_implicit, _) -> - assert false - | Tmod_unpack (exp, _pack) -> - Pmod_unpack (sub.expr sub exp) - (* TODO , sub.package_type sub pack) *) - in - Mod.mk ~loc ~attrs desc +(* Simplified inclusion check between module types (for Env) *) -let class_expr sub cexpr = - let loc = sub.location sub cexpr.cl_loc in - let attrs = sub.attributes sub cexpr.cl_attributes in - let desc = match cexpr.cl_desc with - | Tcl_constraint ( { cl_desc = Tcl_ident (_path, lid, tyl); _ }, - None, _, _, _ ) -> - Pcl_constr (map_loc sub lid, - List.map (sub.typ sub) tyl) - | Tcl_structure clstr -> Pcl_structure (sub.class_structure sub clstr) +let can_alias env path = + let rec no_apply = function + | Pident _ -> true + | Pdot(p, _, _) -> no_apply p + | Papply _ -> false + in + no_apply path && not (Env.is_functor_arg path env) - | Tcl_fun (label, pat, _pv, cl, _partial) -> - Pcl_fun (label, None, sub.pat sub pat, sub.class_expr sub cl) +let check_modtype_inclusion ~loc env mty1 path1 mty2 = + try + let aliasable = can_alias env path1 in + ignore(modtypes ~loc env [] Subst.identity + (Mtype.strengthen ~aliasable env mty1 path1) mty2) + with Error _ -> + raise Not_found - | Tcl_apply (cl, args) -> - Pcl_apply (sub.class_expr sub cl, - List.fold_right (fun (label, expo) list -> - match expo with - None -> list - | Some exp -> (label, sub.expr sub exp) :: list - ) args []) +let _ = Env.check_modtype_inclusion := check_modtype_inclusion - | Tcl_let (rec_flat, bindings, _ivars, cl) -> - Pcl_let (rec_flat, - List.map (sub.value_binding sub) bindings, - sub.class_expr sub cl) +(* Check that an implementation of a compilation unit meets its + interface. *) - | Tcl_constraint (cl, Some clty, _vals, _meths, _concrs) -> - Pcl_constraint (sub.class_expr sub cl, sub.class_type sub clty) +let compunit env impl_name impl_sig intf_name intf_sig = + try + signatures ~loc:(Location.in_file impl_name) env [] Subst.identity + impl_sig intf_sig + with Error reasons -> + raise(Error(([], Env.empty,Interface_mismatch(impl_name, intf_name)) + :: reasons)) - | Tcl_open (ovf, _p, lid, _env, e) -> - Pcl_open (ovf, lid, sub.class_expr sub e) +(* Hide the context and substitution parameters to the outside world *) - | Tcl_ident _ -> assert false - | Tcl_constraint (_, None, _, _, _) -> assert false - in - Cl.mk ~loc ~attrs desc +let modtypes ~loc env mty1 mty2 = modtypes ~loc env [] Subst.identity mty1 mty2 +let signatures env sig1 sig2 = + signatures ~loc:Location.none env [] Subst.identity sig1 sig2 +let type_declarations ~loc env id decl1 decl2 = + type_declarations ~loc env [] Subst.identity id decl1 decl2 -let class_type sub ct = - let loc = sub.location sub ct.cltyp_loc in - let attrs = sub.attributes sub ct.cltyp_attributes in - let desc = match ct.cltyp_desc with - Tcty_signature csg -> Pcty_signature (sub.class_signature sub csg) - | Tcty_constr (_path, lid, list) -> - Pcty_constr (map_loc sub lid, List.map (sub.typ sub) list) - | Tcty_arrow (label, ct, cl) -> - Pcty_arrow (label, sub.typ sub ct, sub.class_type sub cl) - | Tcty_open (ovf, _p, lid, _env, e) -> - Pcty_open (ovf, lid, sub.class_type sub e) - in - Cty.mk ~loc ~attrs desc +(* +let modtypes env m1 m2 = + let c = modtypes env m1 m2 in + Format.eprintf "@[<2>modtypes@ %a@ %a =@ %a@]@." + Printtyp.modtype m1 Printtyp.modtype m2 + print_coercion c; + c +*) -let class_signature sub cs = - { - pcsig_self = sub.typ sub cs.csig_self; - pcsig_fields = List.map (sub.class_type_field sub) cs.csig_fields; - } +(* Error report *) -let class_type_field sub ctf = - let loc = sub.location sub ctf.ctf_loc in - let attrs = sub.attributes sub ctf.ctf_attributes in - let desc = match ctf.ctf_desc with - Tctf_inherit ct -> Pctf_inherit (sub.class_type sub ct) - | Tctf_val (s, mut, virt, ct) -> - Pctf_val (mkloc s loc, mut, virt, sub.typ sub ct) - | Tctf_method (s, priv, virt, ct) -> - Pctf_method (mkloc s loc, priv, virt, sub.typ sub ct) - | Tctf_constraint (ct1, ct2) -> - Pctf_constraint (sub.typ sub ct1, sub.typ sub ct2) - | Tctf_attribute x -> Pctf_attribute x - in - Ctf.mk ~loc ~attrs desc +open Format +open Printtyp -let core_type sub ct = - let loc = sub.location sub ct.ctyp_loc in - let attrs = sub.attributes sub ct.ctyp_attributes in - let desc = match ct.ctyp_desc with - Ttyp_any -> Ptyp_any - | Ttyp_var s -> Ptyp_var s - | Ttyp_arrow (label, ct1, ct2) -> - Ptyp_arrow (label, sub.typ sub ct1, sub.typ sub ct2) - | Ttyp_tuple list -> Ptyp_tuple (List.map (sub.typ sub) list) - | Ttyp_constr (_path, lid, list) -> - Ptyp_constr (map_loc sub lid, - List.map (sub.typ sub) list) - | Ttyp_object (list, o) -> - Ptyp_object - (List.map (sub.object_field sub) list, o) - | Ttyp_class (_path, lid, list) -> - Ptyp_class (map_loc sub lid, List.map (sub.typ sub) list) - | Ttyp_alias (ct, s) -> - Ptyp_alias (sub.typ sub ct, s) - | Ttyp_variant (list, bool, labels) -> - Ptyp_variant (List.map (sub.row_field sub) list, bool, labels) - | Ttyp_poly (list, ct) -> - let list = List.map (fun v -> mkloc v loc) list in - Ptyp_poly (list, sub.typ sub ct) - | Ttyp_package pack -> Ptyp_package (sub.package_type sub pack) - in - Typ.mk ~loc ~attrs desc +let show_loc msg ppf loc = + let pos = loc.Location.loc_start in + if List.mem pos.Lexing.pos_fname [""; "_none_"; "//toplevel//"] then () + else fprintf ppf "@\n@[<2>%a:@ %s@]" Location.print_loc loc msg -let class_structure sub cs = - let rec remove_self = function - | { pat_desc = Tpat_alias (p, id, _s) } - when string_is_prefix "selfpat-" id.Ident.name -> - remove_self p - | p -> p - in - { pcstr_self = sub.pat sub (remove_self cs.cstr_self); - pcstr_fields = List.map (sub.class_field sub) cs.cstr_fields; - } +let show_locs ppf (loc1, loc2) = + show_loc "Expected declaration" ppf loc2; + show_loc "Actual declaration" ppf loc1 -let row_field sub rf = - match rf with - Ttag (label, attrs, bool, list) -> - Rtag (label, sub.attributes sub attrs, bool, List.map (sub.typ sub) list) - | Tinherit ct -> Rinherit (sub.typ sub ct) +let include_err ppf = function + | Missing_field (id, loc, kind) -> + fprintf ppf "The %s `%a' is required but not provided" kind ident id; + show_loc "Expected declaration" ppf loc + | Value_descriptions(id, d1, d2) -> + fprintf ppf + "@[Values do not match:@ %a@;<1 -2>is not included in@ %a@]" + (value_description id) d1 (value_description id) d2; + show_locs ppf (d1.val_loc, d2.val_loc); + | Type_declarations(id, d1, d2, errs) -> + fprintf ppf "@[@[%s:@;<1 2>%a@ %s@;<1 2>%a@]%a%a@]" + "Type declarations do not match" + (type_declaration id) d1 + "is not included in" + (type_declaration id) d2 + show_locs (d1.type_loc, d2.type_loc) + (Includecore.report_type_mismatch + "the first" "the second" "declaration") errs + | Extension_constructors(id, x1, x2) -> + fprintf ppf + "@[Extension declarations do not match:@ \ + %a@;<1 -2>is not included in@ %a@]" + (extension_constructor id) x1 + (extension_constructor id) x2; + show_locs ppf (x1.ext_loc, x2.ext_loc) + | Module_types(mty1, mty2)-> + fprintf ppf + "@[Modules do not match:@ \ + %a@;<1 -2>is not included in@ %a@]" + modtype mty1 + modtype mty2 + | Modtype_infos(id, d1, d2) -> + fprintf ppf + "@[Module type declarations do not match:@ \ + %a@;<1 -2>does not match@ %a@]" + (modtype_declaration id) d1 + (modtype_declaration id) d2 + | Modtype_permutation -> + fprintf ppf "Illegal permutation of structure fields" + | Interface_mismatch(impl_name, intf_name) -> + fprintf ppf "@[The implementation %s@ does not match the interface %s:" + impl_name intf_name + | Class_type_declarations(id, d1, d2, reason) -> + fprintf ppf + "@[Class type declarations do not match:@ \ + %a@;<1 -2>does not match@ %a@]@ %a" + (Printtyp.cltype_declaration id) d1 + (Printtyp.cltype_declaration id) d2 + Includeclass.report_error reason + | Class_declarations(id, d1, d2, reason) -> + fprintf ppf + "@[Class declarations do not match:@ \ + %a@;<1 -2>does not match@ %a@]@ %a" + (Printtyp.class_declaration id) d1 + (Printtyp.class_declaration id) d2 + Includeclass.report_error reason + | Unbound_modtype_path path -> + fprintf ppf "Unbound module type %a" Printtyp.path path + | Unbound_module_path path -> + fprintf ppf "Unbound module %a" Printtyp.path path + | Invalid_module_alias path -> + fprintf ppf "Module %a cannot be aliased" Printtyp.path path -let object_field sub ofield = - match ofield with - OTtag (label, attrs, ct) -> - Otag (label, sub.attributes sub attrs, sub.typ sub ct) - | OTinherit ct -> Oinherit (sub.typ sub ct) +let rec context ppf = function + Module id :: rem -> + fprintf ppf "@[<2>module %a%a@]" ident id args rem + | Modtype id :: rem -> + fprintf ppf "@[<2>module type %a =@ %a@]" ident id context_mty rem + | Body x :: rem -> + fprintf ppf "functor (%s) ->@ %a" (argname x) context_mty rem + | Arg x :: rem -> + fprintf ppf "functor (%a : %a) -> ..." ident x context_mty rem + | [] -> + fprintf ppf "" +and context_mty ppf = function + (Module _ | Modtype _) :: _ as rem -> + fprintf ppf "@[<2>sig@ %a@;<1 -2>end@]" context rem + | cxt -> context ppf cxt +and args ppf = function + Body x :: rem -> + fprintf ppf "(%s)%a" (argname x) args rem + | Arg x :: rem -> + fprintf ppf "(%a :@ %a) : ..." ident x context_mty rem + | cxt -> + fprintf ppf " :@ %a" context_mty cxt +and argname x = + let s = Ident.name x in + if s = "*" then "" else s -and is_self_pat = function - | { pat_desc = Tpat_alias(_pat, id, _) } -> - string_is_prefix "self-" (Ident.name id) - | _ -> false +let path_of_context = function + Module id :: rem -> + let rec subm path = function + [] -> path + | Module id :: rem -> subm (Pdot (path, Ident.name id, -1)) rem + | _ -> assert false + in subm (Pident id) rem + | _ -> assert false -let class_field sub cf = - let loc = sub.location sub cf.cf_loc in - let attrs = sub.attributes sub cf.cf_attributes in - let desc = match cf.cf_desc with - Tcf_inherit (ovf, cl, super, _vals, _meths) -> - Pcf_inherit (ovf, sub.class_expr sub cl, - map_opt (fun v -> mkloc v loc) super) - | Tcf_constraint (cty, cty') -> - Pcf_constraint (sub.typ sub cty, sub.typ sub cty') - | Tcf_val (lab, mut, _, Tcfk_virtual cty, _) -> - Pcf_val (lab, mut, Cfk_virtual (sub.typ sub cty)) - | Tcf_val (lab, mut, _, Tcfk_concrete (o, exp), _) -> - Pcf_val (lab, mut, Cfk_concrete (o, sub.expr sub exp)) - | Tcf_method (lab, priv, Tcfk_virtual cty) -> - Pcf_method (lab, priv, Cfk_virtual (sub.typ sub cty)) - | Tcf_method (lab, priv, Tcfk_concrete (o, exp)) -> - let remove_fun_self = function - | { exp_desc = - Texp_function { arg_label = Nolabel; cases = [case]; _ } } - when is_self_pat case.c_lhs && case.c_guard = None -> case.c_rhs - | e -> e - in - let exp = remove_fun_self exp in - Pcf_method (lab, priv, Cfk_concrete (o, sub.expr sub exp)) - | Tcf_initializer exp -> - let remove_fun_self = function - | { exp_desc = - Texp_function { arg_label = Nolabel; cases = [case]; _ } } - when is_self_pat case.c_lhs && case.c_guard = None -> case.c_rhs - | e -> e - in - let exp = remove_fun_self exp in - Pcf_initializer (sub.expr sub exp) - | Tcf_attribute x -> Pcf_attribute x - in - Cf.mk ~loc ~attrs desc +let context ppf cxt = + if cxt = [] then () else + if List.for_all (function Module _ -> true | _ -> false) cxt then + fprintf ppf "In module %a:@ " path (path_of_context cxt) + else + fprintf ppf "@[At position@ %a@]@ " context cxt -let location _sub l = l +let include_err ppf (cxt, env, err) = + Printtyp.wrap_printing_env env (fun () -> + fprintf ppf "@[%a%a@]" context (List.rev cxt) include_err err) -let default_mapper = - { - attribute = attribute ; - attributes = attributes ; - structure = structure; - structure_item = structure_item; - module_expr = module_expr; - signature = signature; - signature_item = signature_item; - module_type = module_type; - with_constraint = with_constraint; - class_declaration = class_declaration; - class_expr = class_expr; - class_field = class_field; - class_structure = class_structure; - class_type = class_type; - class_type_field = class_type_field; - class_signature = class_signature; - class_type_declaration = class_type_declaration; - class_description = class_description; - type_declaration = type_declaration; - type_kind = type_kind; - typ = core_type; - type_extension = type_extension; - extension_constructor = extension_constructor; - value_description = value_description; - pat = pattern; - expr = expression; - module_declaration = module_declaration; - module_type_declaration = module_type_declaration; - module_binding = module_binding; - package_type = package_type ; - open_description = open_description; - include_description = include_description; - include_declaration = include_declaration; - value_binding = value_binding; - constructor_declaration = constructor_declaration; - label_declaration = label_declaration; - cases = cases; - case = case; - location = location; - row_field = row_field ; - object_field = object_field ; - } +let buffer = ref Bytes.empty +let is_big obj = + let size = !Clflags.error_size in + size > 0 && + begin + if Bytes.length !buffer < size then buffer := Bytes.create size; + try ignore (Marshal.to_buffer !buffer 0 size obj []); false + with _ -> true + end -let untype_structure ?(mapper=default_mapper) structure = - mapper.structure mapper structure +let report_error ppf errs = + if errs = [] then () else + let (errs , err) = split_last errs in + let pe = ref true in + let include_err' ppf (_,_,obj as err) = + if not (is_big obj) then fprintf ppf "%a@ " include_err err + else if !pe then (fprintf ppf "...@ "; pe := false) + in + let print_errs ppf = List.iter (include_err' ppf) in + fprintf ppf "@[%a%a@]" print_errs errs include_err err -let untype_signature ?(mapper=default_mapper) signature = - mapper.signature mapper signature + +(* We could do a better job to split the individual error items + as sub-messages of the main interface mismatch on the whole unit. *) +let () = + Location.register_error_of_exn + (function + | Error err -> Some (Location.error_of_printer_file report_error err) + | _ -> None + ) end -module Parmatch : sig -#1 "parmatch.mli" +module Stypes : sig +#1 "stypes.mli" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* Damien Doligez, projet Moscova, INRIA Rocquencourt *) (* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* Copyright 2003 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -55883,101 +55310,251 @@ module Parmatch : sig (* *) (**************************************************************************) -(* Detection of partial matches and unused match cases. *) -open Asttypes -open Typedtree -open Types +(* Recording and dumping (partial) type information *) -val pretty_const : constant -> string -val top_pretty : Format.formatter -> pattern -> unit -val pretty_pat : pattern -> unit -val pretty_line : pattern list -> unit -val pretty_matrix : pattern list list -> unit +(* Clflags.save_types must be true *) -val omega : pattern -val omegas : int -> pattern list -val omega_list : 'a list -> pattern list -val normalize_pat : pattern -> pattern -val all_record_args : - (Longident.t loc * label_description * pattern) list -> - (Longident.t loc * label_description * pattern) list -val const_compare : constant -> constant -> int +open Typedtree;; -val le_pat : pattern -> pattern -> bool -val le_pats : pattern list -> pattern list -> bool +type annotation = + | Ti_pat of pattern + | Ti_expr of expression + | Ti_class of class_expr + | Ti_mod of module_expr + | An_call of Location.t * Annot.call + | An_ident of Location.t * string * Annot.ident +;; -(* Exported compatibility functor, abstracted over constructor equality *) -module Compat : - functor - (Constr: sig - val equal : - Types.constructor_description -> - Types.constructor_description -> - bool - end) -> sig - val compat : pattern -> pattern -> bool - val compats : pattern list -> pattern list -> bool - end +val record : annotation -> unit;; +val record_phrase : Location.t -> unit;; +val dump : string option -> unit;; -exception Empty -val lub : pattern -> pattern -> pattern -val lubs : pattern list -> pattern list -> pattern list +val get_location : annotation -> Location.t;; +val get_info : unit -> annotation list;; -val get_mins : ('a -> 'a -> bool) -> 'a list -> 'a list +end = struct +#1 "stypes.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Damien Doligez, projet Moscova, INRIA Rocquencourt *) +(* *) +(* Copyright 2003 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -(* Those two functions recombine one pattern and its arguments: - For instance: - (_,_)::p1::p2::rem -> (p1, p2)::rem - The second one will replace mutable arguments by '_' +(* Recording and dumping (partial) type information *) + +(* + We record all types in a list as they are created. + This means we can dump type information even if type inference fails, + which is extremely important, since type information is most + interesting in case of errors. *) -val set_args : pattern -> pattern list -> pattern list -val set_args_erase_mutable : pattern -> pattern list -> pattern list -val pat_of_constr : pattern -> constructor_description -> pattern -val complete_constrs : - pattern -> constructor_tag list -> constructor_description list -val ppat_of_type : - Env.t -> type_expr -> - Parsetree.pattern * - (string, constructor_description) Hashtbl.t * - (string, label_description) Hashtbl.t +open Annot;; +open Lexing;; +open Location;; +open Typedtree;; -val pressure_variants: Env.t -> pattern list -> unit -val check_partial_gadt: - ((string, constructor_description) Hashtbl.t -> - (string, label_description) Hashtbl.t -> - Parsetree.pattern -> pattern option) -> - Location.t -> case list -> partial -val check_unused: - (bool -> - (string, constructor_description) Hashtbl.t -> - (string, label_description) Hashtbl.t -> - Parsetree.pattern -> pattern option) -> - case list -> unit +let output_int oc i = output_string oc (string_of_int i) -(* Irrefutability tests *) -val irrefutable : pattern -> bool +type annotation = + | Ti_pat of pattern + | Ti_expr of expression + | Ti_class of class_expr + | Ti_mod of module_expr + | An_call of Location.t * Annot.call + | An_ident of Location.t * string * Annot.ident +;; -(** An inactive pattern is a pattern, matching against which can be duplicated, erased or - delayed without change in observable behavior of the program. Patterns containing - (lazy _) subpatterns or reads of mutable fields are active. *) -val inactive : partial:partial -> pattern -> bool +let get_location ti = + match ti with + Ti_pat p -> p.pat_loc + | Ti_expr e -> e.exp_loc + | Ti_class c -> c.cl_loc + | Ti_mod m -> m.mod_loc + | An_call (l, _k) -> l + | An_ident (l, _s, _k) -> l +;; -(* Ambiguous bindings *) -val check_ambiguous_bindings : case list -> unit +let annotations = ref ([] : annotation list);; +let phrases = ref ([] : Location.t list);; -(* The tag used for open polymorphic variant types *) -val some_other_tag : label +let record ti = + if !Clflags.annotations && not (get_location ti).Location.loc_ghost then + annotations := ti :: !annotations +;; -end = struct -#1 "parmatch.ml" +let record_phrase loc = + if !Clflags.annotations then phrases := loc :: !phrases; +;; + +(* comparison order: + the intervals are sorted by order of increasing upper bound + same upper bound -> sorted by decreasing lower bound +*) +let cmp_loc_inner_first loc1 loc2 = + match compare loc1.loc_end.pos_cnum loc2.loc_end.pos_cnum with + | 0 -> compare loc2.loc_start.pos_cnum loc1.loc_start.pos_cnum + | x -> x +;; +let cmp_ti_inner_first ti1 ti2 = + cmp_loc_inner_first (get_location ti1) (get_location ti2) +;; + +let print_position pp pos = + if pos = dummy_pos then + output_string pp "--" + else begin + output_char pp '\"'; + output_string pp (String.escaped pos.pos_fname); + output_string pp "\" "; + output_int pp pos.pos_lnum; + output_char pp ' '; + output_int pp pos.pos_bol; + output_char pp ' '; + output_int pp pos.pos_cnum; + end +;; + +let print_location pp loc = + print_position pp loc.loc_start; + output_char pp ' '; + print_position pp loc.loc_end; +;; + +let sort_filter_phrases () = + let ph = List.sort (fun x y -> cmp_loc_inner_first y x) !phrases in + let rec loop accu cur l = + match l with + | [] -> accu + | loc :: t -> + if cur.loc_start.pos_cnum <= loc.loc_start.pos_cnum + && cur.loc_end.pos_cnum >= loc.loc_end.pos_cnum + then loop accu cur t + else loop (loc :: accu) loc t + in + phrases := loop [] Location.none ph; +;; + +let rec printtyp_reset_maybe loc = + match !phrases with + | cur :: t when cur.loc_start.pos_cnum <= loc.loc_start.pos_cnum -> + Printtyp.reset (); + phrases := t; + printtyp_reset_maybe loc; + | _ -> () +;; + +let call_kind_string k = + match k with + | Tail -> "tail" + | Stack -> "stack" + | Inline -> "inline" +;; + +let print_ident_annot pp str k = + match k with + | Idef l -> + output_string pp "def "; + output_string pp str; + output_char pp ' '; + print_location pp l; + output_char pp '\n' + | Iref_internal l -> + output_string pp "int_ref "; + output_string pp str; + output_char pp ' '; + print_location pp l; + output_char pp '\n' + | Iref_external -> + output_string pp "ext_ref "; + output_string pp str; + output_char pp '\n' +;; + +(* The format of the annotation file is documented in emacs/caml-types.el. *) + +let print_info pp prev_loc ti = + match ti with + | Ti_class _ | Ti_mod _ -> prev_loc + | Ti_pat {pat_loc = loc; pat_type = typ; pat_env = env} + | Ti_expr {exp_loc = loc; exp_type = typ; exp_env = env} -> + if loc <> prev_loc then begin + print_location pp loc; + output_char pp '\n' + end; + output_string pp "type(\n"; + printtyp_reset_maybe loc; + Printtyp.mark_loops typ; + Format.pp_print_string Format.str_formatter " "; + Printtyp.wrap_printing_env env + (fun () -> Printtyp.type_sch Format.str_formatter typ); + Format.pp_print_newline Format.str_formatter (); + let s = Format.flush_str_formatter () in + output_string pp s; + output_string pp ")\n"; + loc + | An_call (loc, k) -> + if loc <> prev_loc then begin + print_location pp loc; + output_char pp '\n' + end; + output_string pp "call(\n "; + output_string pp (call_kind_string k); + output_string pp "\n)\n"; + loc + | An_ident (loc, str, k) -> + if loc <> prev_loc then begin + print_location pp loc; + output_char pp '\n' + end; + output_string pp "ident(\n "; + print_ident_annot pp str k; + output_string pp ")\n"; + loc +;; + +let get_info () = + let info = List.fast_sort cmp_ti_inner_first !annotations in + annotations := []; + info +;; + +let dump filename = + if !Clflags.annotations then begin + let do_dump _temp_filename pp = + let info = get_info () in + sort_filter_phrases (); + ignore (List.fold_left (print_info pp) Location.none info) in + begin match filename with + | None -> do_dump "" stdout + | Some filename -> + Misc.output_to_file_via_temporary ~mode:[Open_text] filename do_dump + end; + phrases := []; + end else begin + annotations := []; + end; +;; + +end +module TypedtreeIter : sig +#1 "typedtreeIter.mli" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* Thomas Gazagnaire (OCamlPro), Fabrice Le Fessant (INRIA Saclay) *) (* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* Copyright 2007 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -55986,4445 +55563,4448 @@ end = struct (* *) (**************************************************************************) -(* Detection of partial matches and unused match cases. *) - -open Misc open Asttypes -open Types open Typedtree -(*************************************) -(* Utilities for building patterns *) -(*************************************) - -let make_pat desc ty tenv = - {pat_desc = desc; pat_loc = Location.none; pat_extra = []; - pat_type = ty ; pat_env = tenv; - pat_attributes = []; - } - -let omega = make_pat Tpat_any Ctype.none Env.empty - -let extra_pat = - make_pat - (Tpat_var (Ident.create "+", mknoloc "+")) - Ctype.none Env.empty - -let rec omegas i = - if i <= 0 then [] else omega :: omegas (i-1) - -let omega_list l = List.map (fun _ -> omega) l - -let zero = make_pat (Tpat_constant (Const_int 0)) Ctype.none Env.empty - -(*******************) -(* Coherence check *) -(*******************) -(* For some of the operations we do in this module, we would like (because it - simplifies matters) to assume that patterns appearing on a given column in a - pattern matrix are /coherent/ (think "of the same type"). - Unfortunately that is not always true. +module type IteratorArgument = sig + val enter_structure : structure -> unit + val enter_value_description : value_description -> unit + val enter_type_extension : type_extension -> unit + val enter_extension_constructor : extension_constructor -> unit + val enter_pattern : pattern -> unit + val enter_expression : expression -> unit + val enter_package_type : package_type -> unit + val enter_signature : signature -> unit + val enter_signature_item : signature_item -> unit + val enter_module_type_declaration : module_type_declaration -> unit + val enter_module_type : module_type -> unit + val enter_module_expr : module_expr -> unit + val enter_with_constraint : with_constraint -> unit + val enter_class_expr : class_expr -> unit + val enter_class_signature : class_signature -> unit + val enter_class_declaration : class_declaration -> unit + val enter_class_description : class_description -> unit + val enter_class_type_declaration : class_type_declaration -> unit + val enter_class_type : class_type -> unit + val enter_class_type_field : class_type_field -> unit + val enter_core_type : core_type -> unit + val enter_class_structure : class_structure -> unit + val enter_class_field : class_field -> unit + val enter_structure_item : structure_item -> unit - Consider the following (well-typed) example: - {[ - type _ t = S : string t | U : unit t - let f (type a) (t1 : a t) (t2 : a t) (a : a) = - match t1, t2, a with - | U, _, () -> () - | _, S, "" -> () - ]} + val leave_structure : structure -> unit + val leave_value_description : value_description -> unit + val leave_type_extension : type_extension -> unit + val leave_extension_constructor : extension_constructor -> unit + val leave_pattern : pattern -> unit + val leave_expression : expression -> unit + val leave_package_type : package_type -> unit + val leave_signature : signature -> unit + val leave_signature_item : signature_item -> unit + val leave_module_type_declaration : module_type_declaration -> unit + val leave_module_type : module_type -> unit + val leave_module_expr : module_expr -> unit + val leave_with_constraint : with_constraint -> unit + val leave_class_expr : class_expr -> unit + val leave_class_signature : class_signature -> unit + val leave_class_declaration : class_declaration -> unit + val leave_class_description : class_description -> unit + val leave_class_type_declaration : class_type_declaration -> unit + val leave_class_type : class_type -> unit + val leave_class_type_field : class_type_field -> unit + val leave_core_type : core_type -> unit + val leave_class_structure : class_structure -> unit + val leave_class_field : class_field -> unit + val leave_structure_item : structure_item -> unit - Clearly the 3rd column contains incoherent patterns. + val enter_bindings : rec_flag -> unit + val enter_binding : value_binding -> unit + val leave_binding : value_binding -> unit + val leave_bindings : rec_flag -> unit - On the example above, most of the algorithms will explore the pattern matrix - as illustrated by the following tree: + val enter_type_declarations : rec_flag -> unit + val enter_type_declaration : type_declaration -> unit + val leave_type_declaration : type_declaration -> unit + val leave_type_declarations : rec_flag -> unit - {v - S - -------> | "" | - U | S, "" | __/ | () | - --------> | _, () | \ ¬ S - | U, _, () | __/ -------> | () | - | _, S, "" | \ - ---------> | S, "" | ----------> | "" | - ¬ U S - v} +end - where following an edge labelled by a pattern P means "assuming the value I - am matching on is filtered by [P] on the column I am currently looking at, - then the following submatrix is still reachable". +module MakeIterator : + functor (Iter : IteratorArgument) -> + sig + val iter_structure : structure -> unit + val iter_signature : signature -> unit + val iter_structure_item : structure_item -> unit + val iter_signature_item : signature_item -> unit + val iter_expression : expression -> unit + val iter_module_type : module_type -> unit + val iter_pattern : pattern -> unit + val iter_class_expr : class_expr -> unit + end - Notice that at any point of that tree, if the first column of a matrix is - incoherent, then the branch leading to it can only be taken if the scrutinee - is ill-typed. - In the example above the only case where we have a matrix with an incoherent - first column is when we consider [t1, t2, a] to be [U, S, ...]. However such - a value would be ill-typed, so we can never actually get there. +module DefaultIteratorArgument : IteratorArgument - Checking the first column at each step of the recursion and making the - concious decision of "aborting" the algorithm whenever the first column - becomes incoherent, allows us to retain the initial assumption in later - stages of the algorithms. +end = struct +#1 "typedtreeIter.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Thomas Gazagnaire (OCamlPro), Fabrice Le Fessant (INRIA Saclay) *) +(* *) +(* Copyright 2007 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) - --- +(* +TODO: + - 2012/05/10: Follow camlp4 way of building map and iter using classes + and inheritance ? +*) - N.B. two patterns can be considered coherent even though they might not be of - the same type. +open Asttypes +open Typedtree - That's in part because we only care about the "head" of patterns and leave - checking coherence of subpatterns for the next steps of the algorithm: - ('a', 'b') and (1, ()) will be deemed coherent because they are both a tuples - of arity 2 (we'll notice at a later stage the incoherence of 'a' and 1). +module type IteratorArgument = sig - But also because it can be hard/costly to determine exactly whether two - patterns are of the same type or not (eg. in the example above with _ and S, - but see also the module [Coherence_illustration] in - testsuite/tests/basic-more/robustmatch.ml). + val enter_structure : structure -> unit + val enter_value_description : value_description -> unit + val enter_type_extension : type_extension -> unit + val enter_extension_constructor : extension_constructor -> unit + val enter_pattern : pattern -> unit + val enter_expression : expression -> unit + val enter_package_type : package_type -> unit + val enter_signature : signature -> unit + val enter_signature_item : signature_item -> unit + val enter_module_type_declaration : module_type_declaration -> unit + val enter_module_type : module_type -> unit + val enter_module_expr : module_expr -> unit + val enter_with_constraint : with_constraint -> unit + val enter_class_expr : class_expr -> unit + val enter_class_signature : class_signature -> unit + val enter_class_declaration : class_declaration -> unit + val enter_class_description : class_description -> unit + val enter_class_type_declaration : class_type_declaration -> unit + val enter_class_type : class_type -> unit + val enter_class_type_field : class_type_field -> unit + val enter_core_type : core_type -> unit + val enter_class_structure : class_structure -> unit + val enter_class_field : class_field -> unit + val enter_structure_item : structure_item -> unit - For the moment our weak, loosely-syntactic, coherence check seems to be - enough and we leave it to each user to consider (and document!) what happens - when an "incoherence" is not detected by this check. -*) + val leave_structure : structure -> unit + val leave_value_description : value_description -> unit + val leave_type_extension : type_extension -> unit + val leave_extension_constructor : extension_constructor -> unit + val leave_pattern : pattern -> unit + val leave_expression : expression -> unit + val leave_package_type : package_type -> unit + val leave_signature : signature -> unit + val leave_signature_item : signature_item -> unit + val leave_module_type_declaration : module_type_declaration -> unit + val leave_module_type : module_type -> unit + val leave_module_expr : module_expr -> unit + val leave_with_constraint : with_constraint -> unit + val leave_class_expr : class_expr -> unit + val leave_class_signature : class_signature -> unit + val leave_class_declaration : class_declaration -> unit + val leave_class_description : class_description -> unit + val leave_class_type_declaration : class_type_declaration -> unit + val leave_class_type : class_type -> unit + val leave_class_type_field : class_type_field -> unit + val leave_core_type : core_type -> unit + val leave_class_structure : class_structure -> unit + val leave_class_field : class_field -> unit + val leave_structure_item : structure_item -> unit -let simplify_head_pat p k = - let rec simplify_head_pat p k = - match p.pat_desc with - | Tpat_alias (p,_,_) -> simplify_head_pat p k - | Tpat_var (_,_) -> omega :: k - | Tpat_or (p1,p2,_) -> simplify_head_pat p1 (simplify_head_pat p2 k) - | _ -> p :: k - in simplify_head_pat p k + val enter_bindings : rec_flag -> unit + val enter_binding : value_binding -> unit + val leave_binding : value_binding -> unit + val leave_bindings : rec_flag -> unit -let rec simplified_first_col = function - | [] -> [] - | [] :: _ -> assert false (* the rows are non-empty! *) - | (p::_) :: rows -> - simplify_head_pat p (simplified_first_col rows) + val enter_type_declarations : rec_flag -> unit + val enter_type_declaration : type_declaration -> unit + val leave_type_declaration : type_declaration -> unit + val leave_type_declarations : rec_flag -> unit -(* Given the simplified first column of a matrix, this function first looks for - a "discriminating" pattern on that column (i.e. a non-omega one) and then - check that every other head pattern in the column is coherent with that one. -*) -let all_coherent column = - let coherent_heads hp1 hp2 = - match hp1.pat_desc, hp2.pat_desc with - | (Tpat_var _ | Tpat_alias _ | Tpat_or _), _ - | _, (Tpat_var _ | Tpat_alias _ | Tpat_or _) -> - assert false - | Tpat_construct (_, c, _), Tpat_construct (_, c', _) -> - c.cstr_consts = c'.cstr_consts - && c.cstr_nonconsts = c'.cstr_nonconsts - | Tpat_constant c1, Tpat_constant c2 -> begin - match c1, c2 with - | Const_char _, Const_char _ - | Const_int _, Const_int _ - | Const_int32 _, Const_int32 _ - | Const_int64 _, Const_int64 _ - | Const_nativeint _, Const_nativeint _ - | Const_float _, Const_float _ - | Const_string _, Const_string _ -> true - | ( Const_char _ - | Const_int _ - | Const_int32 _ - | Const_int64 _ - | Const_nativeint _ - | Const_float _ - | Const_string _), _ -> false end - | Tpat_tuple l1, Tpat_tuple l2 -> List.length l1 = List.length l2 - | Tpat_record ((_, lbl1, _) :: _, _), Tpat_record ((_, lbl2, _) :: _, _) -> - Array.length lbl1.lbl_all = Array.length lbl2.lbl_all - | Tpat_any, _ - | _, Tpat_any - | Tpat_record ([], _), Tpat_record (_, _) - | Tpat_record (_, _), Tpat_record ([], _) - | Tpat_variant _, Tpat_variant _ - | Tpat_array _, Tpat_array _ - | Tpat_lazy _, Tpat_lazy _ -> true - | _, _ -> false - in - match - List.find (fun head_pat -> - match head_pat.pat_desc with - | Tpat_var _ | Tpat_alias _ | Tpat_or _ -> assert false - | Tpat_any -> false - | _ -> true - ) column - with - | exception Not_found -> - (* only omegas on the column: the column is coherent. *) - true - | discr_pat -> - List.for_all (coherent_heads discr_pat) column - -let first_column simplified_matrix = - List.map fst simplified_matrix -(***********************) -(* Compatibility check *) -(***********************) - -(* Patterns p and q compatible means: - there exists value V that matches both, However.... - - The case of extension types is dubious, as constructor rebind permits - that different constructors are the same (and are thus compatible). - - Compilation must take this into account, consider: +module MakeIterator(Iter : IteratorArgument) : sig - type t = .. - type t += A|B - type t += C=A + val iter_structure : structure -> unit + val iter_signature : signature -> unit + val iter_structure_item : structure_item -> unit + val iter_signature_item : signature_item -> unit + val iter_expression : expression -> unit + val iter_module_type : module_type -> unit + val iter_pattern : pattern -> unit + val iter_class_expr : class_expr -> unit - let f x y = match x,y with - | true,A -> '1' - | _,C -> '2' - | false,A -> '3' - | _,_ -> '_' + end = struct - As C is bound to A the value of f false A is '2' (and not '3' as it would - be in the absence of rebinding). + let may_iter f v = + match v with + None -> () + | Some x -> f x - Not considering rebinding, patterns "false,A" and "_,C" are incompatible - and the compiler can swap the second and third clause, resulting in the - (more efficiently compiled) matching - match x,y with - | true,A -> '1' - | false,A -> '3' - | _,C -> '2' - | _,_ -> '_' + let rec iter_structure str = + Iter.enter_structure str; + List.iter iter_structure_item str.str_items; + Iter.leave_structure str - This is not correct: when C is bound to A, "f false A" returns '2' (not '3') + and iter_binding vb = + Iter.enter_binding vb; + iter_pattern vb.vb_pat; + iter_expression vb.vb_expr; + Iter.leave_binding vb - However, diagnostics do not take constructor rebinding into account. - Notice, that due to module abstraction constructor rebinding is hidden. + and iter_bindings rec_flag list = + Iter.enter_bindings rec_flag; + List.iter iter_binding list; + Iter.leave_bindings rec_flag - module X : sig type t = .. type t += A|B end = struct - type t = .. - type t += A - type t += B=A - end + and iter_case {c_lhs; c_guard; c_rhs} = + iter_pattern c_lhs; + may_iter iter_expression c_guard; + iter_expression c_rhs - open X + and iter_cases cases = + List.iter iter_case cases - let f x = match x with - | A -> '1' - | B -> '2' - | _ -> '_' + and iter_structure_item item = + Iter.enter_structure_item item; + begin + match item.str_desc with + Tstr_eval (exp, _attrs) -> iter_expression exp + | Tstr_value (rec_flag, list) -> + iter_bindings rec_flag list + | Tstr_primitive vd -> iter_value_description vd + | Tstr_type (rf, list) -> iter_type_declarations rf list + | Tstr_typext tyext -> iter_type_extension tyext + | Tstr_exception ext -> iter_extension_constructor ext + | Tstr_module x -> iter_module_binding x + | Tstr_recmodule list -> List.iter iter_module_binding list + | Tstr_modtype mtd -> iter_module_type_declaration mtd + | Tstr_open _ -> () + | Tstr_class list -> + List.iter (fun (ci, _) -> iter_class_declaration ci) list + | Tstr_class_type list -> + List.iter + (fun (_, _, ct) -> iter_class_type_declaration ct) + list + | Tstr_include incl -> iter_module_expr incl.incl_mod + | Tstr_attribute _ -> + () + end; + Iter.leave_structure_item item - The second clause above will NOT (and cannot) be flagged as useless. + and iter_module_binding x = + iter_module_expr x.mb_expr - Finally, there are two compatibility fonction - compat p q ---> 'syntactic compatibility, used for diagnostics. - may_compat p q ---> a safe approximation of possible compat, - for compilation + and iter_value_description v = + Iter.enter_value_description v; + iter_core_type v.val_desc; + Iter.leave_value_description v -*) + and iter_constructor_arguments = function + | Cstr_tuple l -> List.iter iter_core_type l + | Cstr_record l -> List.iter (fun ld -> iter_core_type ld.ld_type) l + and iter_constructor_declaration cd = + iter_constructor_arguments cd.cd_args; + option iter_core_type cd.cd_res; -let is_absent tag row = Btype.row_field tag !row = Rabsent + and iter_type_parameter (ct, _v) = + iter_core_type ct -let is_absent_pat p = match p.pat_desc with -| Tpat_variant (tag, _, row) -> is_absent tag row -| _ -> false + and iter_type_declaration decl = + Iter.enter_type_declaration decl; + List.iter iter_type_parameter decl.typ_params; + List.iter (fun (ct1, ct2, _loc) -> + iter_core_type ct1; + iter_core_type ct2 + ) decl.typ_cstrs; + begin match decl.typ_kind with + Ttype_abstract -> () + | Ttype_variant list -> + List.iter iter_constructor_declaration list + | Ttype_record list -> + List.iter + (fun ld -> + iter_core_type ld.ld_type + ) list + | Ttype_open -> () + end; + option iter_core_type decl.typ_manifest; + Iter.leave_type_declaration decl -let const_compare x y = - match x,y with - | Const_float f1, Const_float f2 -> - Pervasives.compare (float_of_string f1) (float_of_string f2) - | Const_string (s1, _), Const_string (s2, _) -> - String.compare s1 s2 - | _, _ -> Pervasives.compare x y + and iter_type_declarations rec_flag decls = + Iter.enter_type_declarations rec_flag; + List.iter iter_type_declaration decls; + Iter.leave_type_declarations rec_flag -let records_args l1 l2 = - (* Invariant: fields are already sorted by Typecore.type_label_a_list *) - let rec combine r1 r2 l1 l2 = match l1,l2 with - | [],[] -> List.rev r1, List.rev r2 - | [],(_,_,p2)::rem2 -> combine (omega::r1) (p2::r2) [] rem2 - | (_,_,p1)::rem1,[] -> combine (p1::r1) (omega::r2) rem1 [] - | (_,lbl1,p1)::rem1, ( _,lbl2,p2)::rem2 -> - if lbl1.lbl_pos < lbl2.lbl_pos then - combine (p1::r1) (omega::r2) rem1 l2 - else if lbl1.lbl_pos > lbl2.lbl_pos then - combine (omega::r1) (p2::r2) l1 rem2 - else (* same label on both sides *) - combine (p1::r1) (p2::r2) rem1 rem2 in - combine [] [] l1 l2 + and iter_extension_constructor ext = + Iter.enter_extension_constructor ext; + begin match ext.ext_kind with + Text_decl(args, ret) -> + iter_constructor_arguments args; + option iter_core_type ret + | Text_rebind _ -> () + end; + Iter.leave_extension_constructor ext; + and iter_type_extension tyext = + Iter.enter_type_extension tyext; + List.iter iter_type_parameter tyext.tyext_params; + List.iter iter_extension_constructor tyext.tyext_constructors; + Iter.leave_type_extension tyext + and iter_pattern pat = + Iter.enter_pattern pat; + List.iter (fun (cstr, _, _attrs) -> match cstr with + | Tpat_type _ -> () + | Tpat_unpack -> () + | Tpat_open _ -> () + | Tpat_constraint ct -> iter_core_type ct) pat.pat_extra; + begin + match pat.pat_desc with + Tpat_any -> () + | Tpat_var _ -> () + | Tpat_alias (pat1, _, _) -> iter_pattern pat1 + | Tpat_constant _ -> () + | Tpat_tuple list -> + List.iter iter_pattern list + | Tpat_construct (_, _, args) -> + List.iter iter_pattern args + | Tpat_variant (_, pato, _) -> + begin match pato with + None -> () + | Some pat -> iter_pattern pat + end + | Tpat_record (list, _closed) -> + List.iter (fun (_, _, pat) -> iter_pattern pat) list + | Tpat_array list -> List.iter iter_pattern list + | Tpat_or (p1, p2, _) -> iter_pattern p1; iter_pattern p2 + | Tpat_lazy p -> iter_pattern p + end; + Iter.leave_pattern pat -module Compat - (Constr:sig - val equal : - Types.constructor_description -> - Types.constructor_description -> - bool - end) = struct + and option f x = match x with None -> () | Some e -> f e - let rec compat p q = match p.pat_desc,q.pat_desc with -(* Variables match any value *) - | ((Tpat_any|Tpat_var _),_) - | (_,(Tpat_any|Tpat_var _)) -> true -(* Structural induction *) - | Tpat_alias (p,_,_),_ -> compat p q - | _,Tpat_alias (q,_,_) -> compat p q - | Tpat_or (p1,p2,_),_ -> - (compat p1 q || compat p2 q) - | _,Tpat_or (q1,q2,_) -> - (compat p q1 || compat p q2) -(* Constructors, with special case for extension *) - | Tpat_construct (_, c1,ps1), Tpat_construct (_, c2,ps2) -> - Constr.equal c1 c2 && compats ps1 ps2 -(* More standard stuff *) - | Tpat_variant(l1,op1, _), Tpat_variant(l2,op2,_) -> - l1=l2 && ocompat op1 op2 - | Tpat_constant c1, Tpat_constant c2 -> - const_compare c1 c2 = 0 - | Tpat_tuple ps, Tpat_tuple qs -> compats ps qs - | Tpat_lazy p, Tpat_lazy q -> compat p q - | Tpat_record (l1,_),Tpat_record (l2,_) -> - let ps,qs = records_args l1 l2 in - compats ps qs - | Tpat_array ps, Tpat_array qs -> - List.length ps = List.length qs && - compats ps qs - | _,_ -> false + and iter_expression exp = + Iter.enter_expression exp; + List.iter (function (cstr, _, _attrs) -> + match cstr with + Texp_constraint ct -> + iter_core_type ct + | Texp_coerce (cty1, cty2) -> + option iter_core_type cty1; iter_core_type cty2 + | Texp_open _ -> () + | Texp_poly cto -> option iter_core_type cto + | Texp_newtype _ -> ()) + exp.exp_extra; + begin + match exp.exp_desc with + Texp_ident _ -> () + | Texp_constant _ -> () + | Texp_let (rec_flag, list, exp) -> + iter_bindings rec_flag list; + iter_expression exp + | Texp_function { cases; _ } -> + iter_cases cases + | Texp_apply (exp, list) -> + iter_expression exp; + List.iter (fun (_label, expo) -> + match expo with + None -> () + | Some exp -> iter_expression exp + ) list + | Texp_match (exp, list1, list2, _) -> + iter_expression exp; + iter_cases list1; + iter_cases list2; + | Texp_try (exp, list) -> + iter_expression exp; + iter_cases list + | Texp_tuple list -> + List.iter iter_expression list + | Texp_construct (_, _, args) -> + List.iter iter_expression args + | Texp_variant (_label, expo) -> + begin match expo with + None -> () + | Some exp -> iter_expression exp + end + | Texp_record { fields; extended_expression; _ } -> + Array.iter (function + | _, Kept _ -> () + | _, Overridden (_, exp) -> iter_expression exp) + fields; + begin match extended_expression with + None -> () + | Some exp -> iter_expression exp + end + | Texp_field (exp, _, _label) -> + iter_expression exp + | Texp_setfield (exp1, _, _label, exp2) -> + iter_expression exp1; + iter_expression exp2 + | Texp_array list -> + List.iter iter_expression list + | Texp_ifthenelse (exp1, exp2, expo) -> + iter_expression exp1; + iter_expression exp2; + begin match expo with + None -> () + | Some exp -> iter_expression exp + end + | Texp_sequence (exp1, exp2) -> + iter_expression exp1; + iter_expression exp2 + | Texp_while (exp1, exp2) -> + iter_expression exp1; + iter_expression exp2 + | Texp_for (_id, _, exp1, exp2, _dir, exp3) -> + iter_expression exp1; + iter_expression exp2; + iter_expression exp3 + | Texp_send (exp, _meth, expo) -> + iter_expression exp; + begin + match expo with + None -> () + | Some exp -> iter_expression exp + end + | Texp_new _ -> () + | Texp_instvar _ -> () + | Texp_setinstvar (_, _, _, exp) -> + iter_expression exp + | Texp_override (_, list) -> + List.iter (fun (_path, _, exp) -> + iter_expression exp + ) list + | Texp_letmodule (_id, _, mexpr, exp) -> + iter_module_expr mexpr; + iter_expression exp + | Texp_letexception (cd, exp) -> + iter_extension_constructor cd; + iter_expression exp + | Texp_assert exp -> iter_expression exp + | Texp_lazy exp -> iter_expression exp + | Texp_object (cl, _) -> + iter_class_structure cl + | Texp_pack (mexpr) -> + iter_module_expr mexpr + | Texp_unreachable -> + () + | Texp_extension_constructor _ -> + () + end; + Iter.leave_expression exp; - and ocompat op oq = match op,oq with - | None,None -> true - | Some p,Some q -> compat p q - | (None,Some _)|(Some _,None) -> false + and iter_package_type pack = + Iter.enter_package_type pack; + List.iter (fun (_s, ct) -> iter_core_type ct) pack.pack_fields; + Iter.leave_package_type pack; - and compats ps qs = match ps,qs with - | [], [] -> true - | p::ps, q::qs -> compat p q && compats ps qs - | _,_ -> false + and iter_signature sg = + Iter.enter_signature sg; + List.iter iter_signature_item sg.sig_items; + Iter.leave_signature sg; -end + and iter_signature_item item = + Iter.enter_signature_item item; + begin + match item.sig_desc with + Tsig_value vd -> + iter_value_description vd + | Tsig_type (rf, list) -> + iter_type_declarations rf list + | Tsig_exception ext -> + iter_extension_constructor ext + | Tsig_typext tyext -> + iter_type_extension tyext + | Tsig_module md -> + iter_module_type md.md_type + | Tsig_recmodule list -> + List.iter (fun md -> iter_module_type md.md_type) list + | Tsig_modtype mtd -> + iter_module_type_declaration mtd + | Tsig_open _ -> () + | Tsig_include incl -> iter_module_type incl.incl_mod + | Tsig_class list -> + List.iter iter_class_description list + | Tsig_class_type list -> + List.iter iter_class_type_declaration list + | Tsig_attribute _ -> () + end; + Iter.leave_signature_item item; -module SyntacticCompat = - Compat - (struct - let equal c1 c2 = Types.equal_tag c1.cstr_tag c2.cstr_tag - end) + and iter_module_type_declaration mtd = + Iter.enter_module_type_declaration mtd; + begin + match mtd.mtd_type with + | None -> () + | Some mtype -> iter_module_type mtype + end; + Iter.leave_module_type_declaration mtd -let compat = SyntacticCompat.compat -and compats = SyntacticCompat.compats + and iter_class_declaration cd = + Iter.enter_class_declaration cd; + List.iter iter_type_parameter cd.ci_params; + iter_class_expr cd.ci_expr; + Iter.leave_class_declaration cd; -(* Due to (potential) rebinding, two extension constructors - of the same arity type may equal *) + and iter_class_description cd = + Iter.enter_class_description cd; + List.iter iter_type_parameter cd.ci_params; + iter_class_type cd.ci_expr; + Iter.leave_class_description cd; -exception Empty (* Empty pattern *) + and iter_class_type_declaration cd = + Iter.enter_class_type_declaration cd; + List.iter iter_type_parameter cd.ci_params; + iter_class_type cd.ci_expr; + Iter.leave_class_type_declaration cd; -(****************************************) -(* Utilities for retrieving type paths *) -(****************************************) + and iter_module_type mty = + Iter.enter_module_type mty; + begin + match mty.mty_desc with + Tmty_ident _ -> () + | Tmty_alias _ -> () + | Tmty_signature sg -> iter_signature sg + | Tmty_functor (_, _, mtype1, mtype2) -> + Misc.may iter_module_type mtype1; iter_module_type mtype2 + | Tmty_with (mtype, list) -> + iter_module_type mtype; + List.iter (fun (_path, _, withc) -> + iter_with_constraint withc + ) list + | Tmty_typeof mexpr -> + iter_module_expr mexpr + end; + Iter.leave_module_type mty; -(* May need a clean copy, cf. PR#4745 *) -let clean_copy ty = - if ty.level = Btype.generic_level then ty - else Subst.type_expr Subst.identity ty + and iter_with_constraint cstr = + Iter.enter_with_constraint cstr; + begin + match cstr with + Twith_type decl -> iter_type_declaration decl + | Twith_module _ -> () + | Twith_typesubst decl -> iter_type_declaration decl + | Twith_modsubst _ -> () + end; + Iter.leave_with_constraint cstr; -let get_type_path ty tenv = - let ty = Ctype.repr (Ctype.expand_head tenv (clean_copy ty)) in - match ty.desc with - | Tconstr (path,_,_) -> path - | _ -> fatal_error "Parmatch.get_type_path" + and iter_module_expr mexpr = + Iter.enter_module_expr mexpr; + begin + match mexpr.mod_desc with + Tmod_ident _ -> () + | Tmod_structure st -> iter_structure st + | Tmod_functor (_, _, mtype, mexpr) -> + Misc.may iter_module_type mtype; + iter_module_expr mexpr + | Tmod_apply (mexp1, mexp2, _) -> + iter_module_expr mexp1; + iter_module_expr mexp2 + | Tmod_constraint (mexpr, _, Tmodtype_implicit, _ ) -> + iter_module_expr mexpr + | Tmod_constraint (mexpr, _, Tmodtype_explicit mtype, _) -> + iter_module_expr mexpr; + iter_module_type mtype + | Tmod_unpack (exp, _mty) -> + iter_expression exp +(* iter_module_type mty *) + end; + Iter.leave_module_expr mexpr; -(*************************************) -(* Values as patterns pretty printer *) -(*************************************) + and iter_class_expr cexpr = + Iter.enter_class_expr cexpr; + begin + match cexpr.cl_desc with + | Tcl_constraint (cl, None, _, _, _ ) -> + iter_class_expr cl; + | Tcl_structure clstr -> iter_class_structure clstr + | Tcl_fun (_label, pat, priv, cl, _partial) -> + iter_pattern pat; + List.iter (fun (_id, _, exp) -> iter_expression exp) priv; + iter_class_expr cl -open Format -;; + | Tcl_apply (cl, args) -> + iter_class_expr cl; + List.iter (fun (_label, expo) -> + match expo with + None -> () + | Some exp -> iter_expression exp + ) args -let is_cons = function -| {cstr_name = "::"} -> true -| _ -> false + | Tcl_let (rec_flat, bindings, ivars, cl) -> + iter_bindings rec_flat bindings; + List.iter (fun (_id, _, exp) -> iter_expression exp) ivars; + iter_class_expr cl -let pretty_const c = match c with -| Const_int i -> Printf.sprintf "%d" i -| Const_char c -> Printf.sprintf "%C" c -| Const_string (s, _) -> Printf.sprintf "%S" s -| Const_float f -> Printf.sprintf "%s" f -| Const_int32 i -> Printf.sprintf "%ldl" i -| Const_int64 i -> Printf.sprintf "%LdL" i -| Const_nativeint i -> Printf.sprintf "%ndn" i + | Tcl_constraint (cl, Some clty, _vals, _meths, _concrs) -> + iter_class_expr cl; + iter_class_type clty -let rec pretty_val ppf v = - match v.pat_extra with - (cstr, _loc, _attrs) :: rem -> - begin match cstr with - | Tpat_unpack -> - fprintf ppf "@[(module %a)@]" pretty_val { v with pat_extra = rem } - | Tpat_constraint _ -> - fprintf ppf "@[(%a : _)@]" pretty_val { v with pat_extra = rem } - | Tpat_type _ -> - fprintf ppf "@[(# %a)@]" pretty_val { v with pat_extra = rem } - | Tpat_open _ -> - fprintf ppf "@[(# %a)@]" pretty_val { v with pat_extra = rem } - end - | [] -> - match v.pat_desc with - | Tpat_any -> fprintf ppf "_" - | Tpat_var (x,_) -> fprintf ppf "%s" (Ident.name x) - | Tpat_constant c -> fprintf ppf "%s" (pretty_const c) - | Tpat_tuple vs -> - fprintf ppf "@[(%a)@]" (pretty_vals ",") vs - | Tpat_construct (_, cstr, []) -> - fprintf ppf "%s" cstr.cstr_name - | Tpat_construct (_, cstr, [w]) -> - fprintf ppf "@[<2>%s@ %a@]" cstr.cstr_name pretty_arg w - | Tpat_construct (_, cstr, vs) -> - let name = cstr.cstr_name in - begin match (name, vs) with - ("::", [v1;v2]) -> - fprintf ppf "@[%a::@,%a@]" pretty_car v1 pretty_cdr v2 - | _ -> - fprintf ppf "@[<2>%s@ @[(%a)@]@]" name (pretty_vals ",") vs - end - | Tpat_variant (l, None, _) -> - fprintf ppf "`%s" l - | Tpat_variant (l, Some w, _) -> - fprintf ppf "@[<2>`%s@ %a@]" l pretty_arg w - | Tpat_record (lvs,_) -> - let filtered_lvs = List.filter - (function - | (_,_,{pat_desc=Tpat_any}) -> false (* do not show lbl=_ *) - | _ -> true) lvs in - begin match filtered_lvs with - | [] -> fprintf ppf "_" - | (_, lbl, _) :: q -> - let elision_mark ppf = - (* we assume that there is no label repetitions here *) - if Array.length lbl.lbl_all > 1 + List.length q then - fprintf ppf ";@ _@ " - else () in - fprintf ppf "@[{%a%t}@]" - pretty_lvals filtered_lvs elision_mark - end - | Tpat_array vs -> - fprintf ppf "@[[| %a |]@]" (pretty_vals " ;") vs - | Tpat_lazy v -> - fprintf ppf "@[<2>lazy@ %a@]" pretty_arg v - | Tpat_alias (v, x,_) -> - fprintf ppf "@[(%a@ as %a)@]" pretty_val v Ident.print x - | Tpat_or (v,w,_) -> - fprintf ppf "@[(%a|@,%a)@]" pretty_or v pretty_or w + | Tcl_ident (_, _, tyl) -> + List.iter iter_core_type tyl -and pretty_car ppf v = match v.pat_desc with -| Tpat_construct (_,cstr, [_ ; _]) - when is_cons cstr -> - fprintf ppf "(%a)" pretty_val v -| _ -> pretty_val ppf v + | Tcl_open (_, _, _, _, e) -> + iter_class_expr e + end; + Iter.leave_class_expr cexpr; -and pretty_cdr ppf v = match v.pat_desc with -| Tpat_construct (_,cstr, [v1 ; v2]) - when is_cons cstr -> - fprintf ppf "%a::@,%a" pretty_car v1 pretty_cdr v2 -| _ -> pretty_val ppf v + and iter_class_type ct = + Iter.enter_class_type ct; + begin + match ct.cltyp_desc with + Tcty_signature csg -> iter_class_signature csg + | Tcty_constr (_path, _, list) -> + List.iter iter_core_type list + | Tcty_arrow (_label, ct, cl) -> + iter_core_type ct; + iter_class_type cl + | Tcty_open (_, _, _, _, e) -> + iter_class_type e + end; + Iter.leave_class_type ct; -and pretty_arg ppf v = match v.pat_desc with -| Tpat_construct (_,_,_::_) -| Tpat_variant (_, Some _, _) -> fprintf ppf "(%a)" pretty_val v -| _ -> pretty_val ppf v + and iter_class_signature cs = + Iter.enter_class_signature cs; + iter_core_type cs.csig_self; + List.iter iter_class_type_field cs.csig_fields; + Iter.leave_class_signature cs -and pretty_or ppf v = match v.pat_desc with -| Tpat_or (v,w,_) -> - fprintf ppf "%a|@,%a" pretty_or v pretty_or w -| _ -> pretty_val ppf v -and pretty_vals sep ppf = function - | [] -> () - | [v] -> pretty_val ppf v - | v::vs -> - fprintf ppf "%a%s@ %a" pretty_val v sep (pretty_vals sep) vs + and iter_class_type_field ctf = + Iter.enter_class_type_field ctf; + begin + match ctf.ctf_desc with + Tctf_inherit ct -> iter_class_type ct + | Tctf_val (_s, _mut, _virt, ct) -> + iter_core_type ct + | Tctf_method (_s, _priv, _virt, ct) -> + iter_core_type ct + | Tctf_constraint (ct1, ct2) -> + iter_core_type ct1; + iter_core_type ct2 + | Tctf_attribute _ -> () + end; + Iter.leave_class_type_field ctf -and pretty_lvals ppf = function - | [] -> () - | [_,lbl,v] -> - fprintf ppf "%s=%a" lbl.lbl_name pretty_val v - | (_, lbl,v)::rest -> - fprintf ppf "%s=%a;@ %a" - lbl.lbl_name pretty_val v pretty_lvals rest + and iter_core_type ct = + Iter.enter_core_type ct; + begin + match ct.ctyp_desc with + Ttyp_any -> () + | Ttyp_var _ -> () + | Ttyp_arrow (_label, ct1, ct2) -> + iter_core_type ct1; + iter_core_type ct2 + | Ttyp_tuple list -> List.iter iter_core_type list + | Ttyp_constr (_path, _, list) -> + List.iter iter_core_type list + | Ttyp_object (list, _o) -> + List.iter iter_object_field list + | Ttyp_class (_path, _, list) -> + List.iter iter_core_type list + | Ttyp_alias (ct, _s) -> + iter_core_type ct + | Ttyp_variant (list, _bool, _labels) -> + List.iter iter_row_field list + | Ttyp_poly (_list, ct) -> iter_core_type ct + | Ttyp_package pack -> iter_package_type pack + end; + Iter.leave_core_type ct -let top_pretty ppf v = - fprintf ppf "@[%a@]@?" pretty_val v + and iter_class_structure cs = + Iter.enter_class_structure cs; + iter_pattern cs.cstr_self; + List.iter iter_class_field cs.cstr_fields; + Iter.leave_class_structure cs; -let pretty_pat p = - top_pretty Format.str_formatter p ; - prerr_string (Format.flush_str_formatter ()) + and iter_row_field rf = + match rf with + Ttag (_label, _attrs, _bool, list) -> + List.iter iter_core_type list + | Tinherit ct -> iter_core_type ct -type matrix = pattern list list + and iter_object_field ofield = + match ofield with + OTtag (_, _, ct) | OTinherit ct -> iter_core_type ct -let pretty_line ps = - List.iter - (fun p -> - top_pretty Format.str_formatter p ; - prerr_string " <" ; - prerr_string (Format.flush_str_formatter ()) ; - prerr_string ">") - ps + and iter_class_field cf = + Iter.enter_class_field cf; + begin + match cf.cf_desc with + Tcf_inherit (_ovf, cl, _super, _vals, _meths) -> + iter_class_expr cl + | Tcf_constraint (cty, cty') -> + iter_core_type cty; + iter_core_type cty' + | Tcf_val (_lab, _, _, Tcfk_virtual cty, _) -> + iter_core_type cty + | Tcf_val (_lab, _, _, Tcfk_concrete (_, exp), _) -> + iter_expression exp + | Tcf_method (_lab, _, Tcfk_virtual cty) -> + iter_core_type cty + | Tcf_method (_lab, _, Tcfk_concrete (_, exp)) -> + iter_expression exp + | Tcf_initializer exp -> + iter_expression exp + | Tcf_attribute _ -> () + end; + Iter.leave_class_field cf; + end -let pretty_matrix (pss : matrix) = - prerr_endline "begin matrix" ; - List.iter - (fun ps -> - pretty_line ps ; - prerr_endline "") - pss ; - prerr_endline "end matrix" +module DefaultIteratorArgument = struct + let enter_structure _ = () + let enter_value_description _ = () + let enter_type_extension _ = () + let enter_extension_constructor _ = () + let enter_pattern _ = () + let enter_expression _ = () + let enter_package_type _ = () + let enter_signature _ = () + let enter_signature_item _ = () + let enter_module_type_declaration _ = () + let enter_module_type _ = () + let enter_module_expr _ = () + let enter_with_constraint _ = () + let enter_class_expr _ = () + let enter_class_signature _ = () + let enter_class_declaration _ = () + let enter_class_description _ = () + let enter_class_type_declaration _ = () + let enter_class_type _ = () + let enter_class_type_field _ = () + let enter_core_type _ = () + let enter_class_structure _ = () + let enter_class_field _ = () + let enter_structure_item _ = () -(****************************) -(* Utilities for matching *) -(****************************) -(* Check top matching *) -let simple_match p1 p2 = - match p1.pat_desc, p2.pat_desc with - | Tpat_construct(_, c1, _), Tpat_construct(_, c2, _) -> - Types.equal_tag c1.cstr_tag c2.cstr_tag - | Tpat_variant(l1, _, _), Tpat_variant(l2, _, _) -> - l1 = l2 - | Tpat_constant(c1), Tpat_constant(c2) -> const_compare c1 c2 = 0 - | Tpat_lazy _, Tpat_lazy _ -> true - | Tpat_record _ , Tpat_record _ -> true - | Tpat_tuple p1s, Tpat_tuple p2s - | Tpat_array p1s, Tpat_array p2s -> List.length p1s = List.length p2s - | _, (Tpat_any | Tpat_var(_)) -> true - | _, _ -> false + let leave_structure _ = () + let leave_value_description _ = () + let leave_type_extension _ = () + let leave_extension_constructor _ = () + let leave_pattern _ = () + let leave_expression _ = () + let leave_package_type _ = () + let leave_signature _ = () + let leave_signature_item _ = () + let leave_module_type_declaration _ = () + let leave_module_type _ = () + let leave_module_expr _ = () + let leave_with_constraint _ = () + let leave_class_expr _ = () + let leave_class_signature _ = () + let leave_class_declaration _ = () + let leave_class_description _ = () + let leave_class_type_declaration _ = () + let leave_class_type _ = () + let leave_class_type_field _ = () + let leave_core_type _ = () + let leave_class_structure _ = () + let leave_class_field _ = () + let leave_structure_item _ = () + let enter_binding _ = () + let leave_binding _ = () + let enter_bindings _ = () + let leave_bindings _ = () + let enter_type_declaration _ = () + let leave_type_declaration _ = () -(* extract record fields as a whole *) -let record_arg p = match p.pat_desc with -| Tpat_any -> [] -| Tpat_record (args,_) -> args -| _ -> fatal_error "Parmatch.as_record" + let enter_type_declarations _ = () + let leave_type_declarations _ = () +end +end +module Untypeast : sig +#1 "untypeast.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Thomas Gazagnaire (OCamlPro), Fabrice Le Fessant (INRIA Saclay) *) +(* *) +(* Copyright 2007 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -(* Raise Not_found when pos is not present in arg *) -let get_field pos arg = - let _,_, p = List.find (fun (_,lbl,_) -> pos = lbl.lbl_pos) arg in - p +open Parsetree -let extract_fields omegas arg = - List.map - (fun (_,lbl,_) -> - try - get_field lbl.lbl_pos arg - with Not_found -> omega) - omegas +val lident_of_path : Path.t -> Longident.t -let all_record_args lbls = match lbls with -| (_,{lbl_all=lbl_all},_)::_ -> - let t = - Array.map - (fun lbl -> mknoloc (Longident.Lident "?temp?"), lbl,omega) - lbl_all in - List.iter - (fun ((_, lbl,_) as x) -> t.(lbl.lbl_pos) <- x) - lbls ; - Array.to_list t -| _ -> fatal_error "Parmatch.all_record_args" +type mapper = { + attribute: mapper -> Typedtree.attribute -> attribute; + attributes: mapper -> Typedtree.attribute list -> attribute list; + case: mapper -> Typedtree.case -> case; + cases: mapper -> Typedtree.case list -> case list; + class_declaration: mapper -> Typedtree.class_declaration -> class_declaration; + class_description: mapper -> Typedtree.class_description -> class_description; + class_expr: mapper -> Typedtree.class_expr -> class_expr; + class_field: mapper -> Typedtree.class_field -> class_field; + class_signature: mapper -> Typedtree.class_signature -> class_signature; + class_structure: mapper -> Typedtree.class_structure -> class_structure; + class_type: mapper -> Typedtree.class_type -> class_type; + class_type_declaration: mapper -> Typedtree.class_type_declaration + -> class_type_declaration; + class_type_field: mapper -> Typedtree.class_type_field -> class_type_field; + constructor_declaration: mapper -> Typedtree.constructor_declaration + -> constructor_declaration; + expr: mapper -> Typedtree.expression -> expression; + extension_constructor: mapper -> Typedtree.extension_constructor + -> extension_constructor; + include_declaration: + mapper -> Typedtree.include_declaration -> include_declaration; + include_description: + mapper -> Typedtree.include_description -> include_description; + label_declaration: + mapper -> Typedtree.label_declaration -> label_declaration; + location: mapper -> Location.t -> Location.t; + module_binding: mapper -> Typedtree.module_binding -> module_binding; + module_declaration: + mapper -> Typedtree.module_declaration -> module_declaration; + module_expr: mapper -> Typedtree.module_expr -> module_expr; + module_type: mapper -> Typedtree.module_type -> module_type; + module_type_declaration: + mapper -> Typedtree.module_type_declaration -> module_type_declaration; + package_type: mapper -> Typedtree.package_type -> package_type; + open_description: mapper -> Typedtree.open_description -> open_description; + pat: mapper -> Typedtree.pattern -> pattern; + row_field: mapper -> Typedtree.row_field -> row_field; + object_field: mapper -> Typedtree.object_field -> object_field; + signature: mapper -> Typedtree.signature -> signature; + signature_item: mapper -> Typedtree.signature_item -> signature_item; + structure: mapper -> Typedtree.structure -> structure; + structure_item: mapper -> Typedtree.structure_item -> structure_item; + typ: mapper -> Typedtree.core_type -> core_type; + type_declaration: mapper -> Typedtree.type_declaration -> type_declaration; + type_extension: mapper -> Typedtree.type_extension -> type_extension; + type_kind: mapper -> Typedtree.type_kind -> type_kind; + value_binding: mapper -> Typedtree.value_binding -> value_binding; + value_description: mapper -> Typedtree.value_description -> value_description; + with_constraint: + mapper -> (Path.t * Longident.t Location.loc * Typedtree.with_constraint) + -> with_constraint; +} +val default_mapper : mapper -(* Build argument list when p2 >= p1, where p1 is a simple pattern *) -let rec simple_match_args p1 p2 = match p2.pat_desc with -| Tpat_alias (p2,_,_) -> simple_match_args p1 p2 -| Tpat_construct(_, _, args) -> args -| Tpat_variant(_, Some arg, _) -> [arg] -| Tpat_tuple(args) -> args -| Tpat_record(args,_) -> extract_fields (record_arg p1) args -| Tpat_array(args) -> args -| Tpat_lazy arg -> [arg] -| (Tpat_any | Tpat_var(_)) -> - begin match p1.pat_desc with - Tpat_construct(_, _,args) -> omega_list args - | Tpat_variant(_, Some _, _) -> [omega] - | Tpat_tuple(args) -> omega_list args - | Tpat_record(args,_) -> omega_list args - | Tpat_array(args) -> omega_list args - | Tpat_lazy _ -> [omega] - | _ -> [] - end -| _ -> [] +val untype_structure : ?mapper:mapper -> Typedtree.structure -> structure +val untype_signature : ?mapper:mapper -> Typedtree.signature -> signature -(* - Normalize a pattern -> - all arguments are omega (simple pattern) and no more variables -*) +val constant : Asttypes.constant -> Parsetree.constant -let rec normalize_pat q = match q.pat_desc with - | Tpat_any | Tpat_constant _ -> q - | Tpat_var _ -> make_pat Tpat_any q.pat_type q.pat_env - | Tpat_alias (p,_,_) -> normalize_pat p - | Tpat_tuple (args) -> - make_pat (Tpat_tuple (omega_list args)) q.pat_type q.pat_env - | Tpat_construct (lid, c,args) -> - make_pat - (Tpat_construct (lid, c,omega_list args)) - q.pat_type q.pat_env - | Tpat_variant (l, arg, row) -> - make_pat (Tpat_variant (l, may_map (fun _ -> omega) arg, row)) - q.pat_type q.pat_env - | Tpat_array (args) -> - make_pat (Tpat_array (omega_list args)) q.pat_type q.pat_env - | Tpat_record (largs, closed) -> - make_pat - (Tpat_record (List.map (fun (lid,lbl,_) -> - lid, lbl,omega) largs, closed)) - q.pat_type q.pat_env - | Tpat_lazy _ -> - make_pat (Tpat_lazy omega) q.pat_type q.pat_env - | Tpat_or _ -> fatal_error "Parmatch.normalize_pat" +end = struct +#1 "untypeast.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Thomas Gazagnaire (OCamlPro), Fabrice Le Fessant (INRIA Saclay) *) +(* *) +(* Copyright 2007 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -(* - Build normalized (cf. supra) discriminating pattern, - in the non-data type case -*) +open Longident +open Asttypes +open Parsetree +open Ast_helper -let discr_pat q pss = +module T = Typedtree - let rec acc_pat acc pss = match pss with - ({pat_desc = Tpat_alias (p,_,_)}::ps)::pss -> - acc_pat acc ((p::ps)::pss) - | ({pat_desc = Tpat_or (p1,p2,_)}::ps)::pss -> - acc_pat acc ((p1::ps)::(p2::ps)::pss) - | ({pat_desc = (Tpat_any | Tpat_var _)}::_)::pss -> - acc_pat acc pss - | (({pat_desc = Tpat_tuple _} as p)::_)::_ -> normalize_pat p - | (({pat_desc = Tpat_lazy _} as p)::_)::_ -> normalize_pat p - | (({pat_desc = Tpat_record (largs,closed)} as p)::_)::pss -> - let new_omegas = - List.fold_right - (fun (lid, lbl,_) r -> - try - let _ = get_field lbl.lbl_pos r in - r - with Not_found -> - (lid, lbl,omega)::r) - largs (record_arg acc) - in - acc_pat - (make_pat (Tpat_record (new_omegas, closed)) p.pat_type p.pat_env) - pss - | _ -> acc in +type mapper = { + attribute: mapper -> T.attribute -> attribute; + attributes: mapper -> T.attribute list -> attribute list; + case: mapper -> T.case -> case; + cases: mapper -> T.case list -> case list; + class_declaration: mapper -> T.class_declaration -> class_declaration; + class_description: mapper -> T.class_description -> class_description; + class_expr: mapper -> T.class_expr -> class_expr; + class_field: mapper -> T.class_field -> class_field; + class_signature: mapper -> T.class_signature -> class_signature; + class_structure: mapper -> T.class_structure -> class_structure; + class_type: mapper -> T.class_type -> class_type; + class_type_declaration: mapper -> T.class_type_declaration + -> class_type_declaration; + class_type_field: mapper -> T.class_type_field -> class_type_field; + constructor_declaration: mapper -> T.constructor_declaration + -> constructor_declaration; + expr: mapper -> T.expression -> expression; + extension_constructor: mapper -> T.extension_constructor + -> extension_constructor; + include_declaration: mapper -> T.include_declaration -> include_declaration; + include_description: mapper -> T.include_description -> include_description; + label_declaration: mapper -> T.label_declaration -> label_declaration; + location: mapper -> Location.t -> Location.t; + module_binding: mapper -> T.module_binding -> module_binding; + module_declaration: mapper -> T.module_declaration -> module_declaration; + module_expr: mapper -> T.module_expr -> module_expr; + module_type: mapper -> T.module_type -> module_type; + module_type_declaration: + mapper -> T.module_type_declaration -> module_type_declaration; + package_type: mapper -> T.package_type -> package_type; + open_description: mapper -> T.open_description -> open_description; + pat: mapper -> T.pattern -> pattern; + row_field: mapper -> T.row_field -> row_field; + object_field: mapper -> T.object_field -> object_field; + signature: mapper -> T.signature -> signature; + signature_item: mapper -> T.signature_item -> signature_item; + structure: mapper -> T.structure -> structure; + structure_item: mapper -> T.structure_item -> structure_item; + typ: mapper -> T.core_type -> core_type; + type_declaration: mapper -> T.type_declaration -> type_declaration; + type_extension: mapper -> T.type_extension -> type_extension; + type_kind: mapper -> T.type_kind -> type_kind; + value_binding: mapper -> T.value_binding -> value_binding; + value_description: mapper -> T.value_description -> value_description; + with_constraint: + mapper -> (Path.t * Longident.t Location.loc * T.with_constraint) + -> with_constraint; +} - match normalize_pat q with - | {pat_desc= (Tpat_any | Tpat_record _)} as q -> acc_pat q pss - | q -> q +open T (* - In case a matching value is found, set actual arguments - of the matching pattern. -*) - -let rec read_args xs r = match xs,r with -| [],_ -> [],r -| _::xs, arg::rest -> - let args,rest = read_args xs rest in - arg::args,rest -| _,_ -> - fatal_error "Parmatch.read_args" - -let do_set_args erase_mutable q r = match q with -| {pat_desc = Tpat_tuple omegas} -> - let args,rest = read_args omegas r in - make_pat (Tpat_tuple args) q.pat_type q.pat_env::rest -| {pat_desc = Tpat_record (omegas,closed)} -> - let args,rest = read_args omegas r in - make_pat - (Tpat_record - (List.map2 (fun (lid, lbl,_) arg -> - if - erase_mutable && - (match lbl.lbl_mut with - | Mutable -> true | Immutable -> false) - then - lid, lbl, omega - else - lid, lbl, arg) - omegas args, closed)) - q.pat_type q.pat_env:: - rest -| {pat_desc = Tpat_construct (lid, c,omegas)} -> - let args,rest = read_args omegas r in - make_pat - (Tpat_construct (lid, c,args)) - q.pat_type q.pat_env:: - rest -| {pat_desc = Tpat_variant (l, omega, row)} -> - let arg, rest = - match omega, r with - Some _, a::r -> Some a, r - | None, r -> None, r - | _ -> assert false - in - make_pat - (Tpat_variant (l, arg, row)) q.pat_type q.pat_env:: - rest -| {pat_desc = Tpat_lazy _omega} -> - begin match r with - arg::rest -> - make_pat (Tpat_lazy arg) q.pat_type q.pat_env::rest - | _ -> fatal_error "Parmatch.do_set_args (lazy)" - end -| {pat_desc = Tpat_array omegas} -> - let args,rest = read_args omegas r in - make_pat - (Tpat_array args) q.pat_type q.pat_env:: - rest -| {pat_desc=Tpat_constant _|Tpat_any} -> - q::r (* case any is used in matching.ml *) -| _ -> fatal_error "Parmatch.set_args" +Some notes: -let set_args q r = do_set_args false q r -and set_args_erase_mutable q r = do_set_args true q r + * For Pexp_function, we cannot go back to the exact original version + when there is a default argument, because the default argument is + translated in the typer. The code, if printed, will not be parsable because + new generated identifiers are not correct. -(* filter pss according to pattern q *) -let filter_one q pss = - let rec filter_rec = function - ({pat_desc = Tpat_alias(p,_,_)}::ps)::pss -> - filter_rec ((p::ps)::pss) - | ({pat_desc = Tpat_or(p1,p2,_)}::ps)::pss -> - filter_rec ((p1::ps)::(p2::ps)::pss) - | (p::ps)::pss -> - if simple_match q p - then (simple_match_args q p @ ps) :: filter_rec pss - else filter_rec pss - | _ -> [] in - filter_rec pss + * For Pexp_apply, it is unclear whether arguments are reordered, especially + when there are optional arguments. -(* - Filter pss in the ``extra case''. This applies : - - According to an extra constructor (datatype case, non-complete signature). - - According to anything (all-variables case). *) -let filter_extra pss = - let rec filter_rec = function - ({pat_desc = Tpat_alias(p,_,_)}::ps)::pss -> - filter_rec ((p::ps)::pss) - | ({pat_desc = Tpat_or(p1,p2,_)}::ps)::pss -> - filter_rec ((p1::ps)::(p2::ps)::pss) - | ({pat_desc = (Tpat_any | Tpat_var(_))} :: qs) :: pss -> - qs :: filter_rec pss - | _::pss -> filter_rec pss - | [] -> [] in - filter_rec pss -(* - Pattern p0 is the discriminating pattern, - returns [(q0,pss0) ; ... ; (qn,pssn)] - where the qi's are simple patterns and the pssi's are - matched matrices. - NOTES - * (qi,[]) is impossible. - * In the case when matching is useless (all-variable case), - returns [] -*) +(** Utility functions. *) -let filter_all pat0 pss = +let string_is_prefix sub str = + let sublen = String.length sub in + String.length str >= sublen && String.sub str 0 sublen = sub - let rec insert q qs env = - match env with - [] -> - let q0 = normalize_pat q in - [q0, [simple_match_args q0 q @ qs]] - | ((q0,pss) as c)::env -> - if simple_match q0 q - then (q0, ((simple_match_args q0 q @ qs) :: pss)) :: env - else c :: insert q qs env in +let map_opt f = function None -> None | Some e -> Some (f e) - let rec filter_rec env = function - ({pat_desc = Tpat_alias(p,_,_)}::ps)::pss -> - filter_rec env ((p::ps)::pss) - | ({pat_desc = Tpat_or(p1,p2,_)}::ps)::pss -> - filter_rec env ((p1::ps)::(p2::ps)::pss) - | ({pat_desc = (Tpat_any | Tpat_var(_))}::_)::pss -> - filter_rec env pss - | (p::ps)::pss -> - filter_rec (insert p ps env) pss - | _ -> env +let rec lident_of_path = function + | Path.Pident id -> Longident.Lident (Ident.name id) + | Path.Pdot (p, s, _) -> Longident.Ldot (lident_of_path p, s) + | Path.Papply (p1, p2) -> + Longident.Lapply (lident_of_path p1, lident_of_path p2) - and filter_omega env = function - ({pat_desc = Tpat_alias(p,_,_)}::ps)::pss -> - filter_omega env ((p::ps)::pss) - | ({pat_desc = Tpat_or(p1,p2,_)}::ps)::pss -> - filter_omega env ((p1::ps)::(p2::ps)::pss) - | ({pat_desc = (Tpat_any | Tpat_var(_))}::ps)::pss -> - filter_omega - (List.map (fun (q,qss) -> (q,(simple_match_args q omega @ ps) :: qss)) - env) - pss - | _::pss -> filter_omega env pss - | [] -> env in +let map_loc sub {loc; txt} = {loc = sub.location sub loc; txt} - filter_omega - (filter_rec - (match pat0.pat_desc with - (Tpat_record(_) | Tpat_tuple(_) | Tpat_lazy(_)) -> [pat0,[]] - | _ -> []) - pss) - pss +(** Try a name [$name$0], check if it's free, if not, increment and repeat. *) +let fresh_name s env = + let rec aux i = + let name = s ^ string_of_int i in + try + let _ = Env.lookup_value (Lident name) env in + name + with + | Not_found -> aux (i+1) + in + aux 0 -(* Variant related functions *) +(** Mapping functions. *) -let rec set_last a = function - [] -> [] - | [_] -> [a] - | x::l -> x :: set_last a l +let constant = function + | Const_char c -> Pconst_char c + | Const_string (s,d) -> Pconst_string (s,d) + | Const_int i -> Pconst_integer (string_of_int i, None) + | Const_int32 i -> Pconst_integer (Int32.to_string i, Some 'l') + | Const_int64 i -> Pconst_integer (Int64.to_string i, Some 'L') + | Const_nativeint i -> Pconst_integer (Nativeint.to_string i, Some 'n') + | Const_float f -> Pconst_float (f,None) -(* mark constructor lines for failure when they are incomplete *) -let rec mark_partial = function - ({pat_desc = Tpat_alias(p,_,_)}::ps)::pss -> - mark_partial ((p::ps)::pss) - | ({pat_desc = Tpat_or(p1,p2,_)}::ps)::pss -> - mark_partial ((p1::ps)::(p2::ps)::pss) - | ({pat_desc = (Tpat_any | Tpat_var(_))} :: _ as ps) :: pss -> - ps :: mark_partial pss - | ps::pss -> - (set_last zero ps) :: mark_partial pss - | [] -> [] +let attribute sub (s, p) = (map_loc sub s, p) +let attributes sub l = List.map (sub.attribute sub) l -let close_variant env row = - let row = Btype.row_repr row in - let nm = - List.fold_left - (fun nm (_tag,f) -> - match Btype.row_field_repr f with - | Reither(_, _, false, e) -> - (* m=false means that this tag is not explicitly matched *) - Btype.set_row_field e Rabsent; - None - | Rabsent | Reither (_, _, true, _) | Rpresent _ -> nm) - row.row_name row.row_fields in - if not row.row_closed || nm != row.row_name then begin - (* this unification cannot fail *) - Ctype.unify env row.row_more - (Btype.newgenty - (Tvariant {row with row_fields = []; row_more = Btype.newgenvar(); - row_closed = true; row_name = nm})) - end +let structure sub str = + List.map (sub.structure_item sub) str.str_items -let row_of_pat pat = - match Ctype.expand_head pat.pat_env pat.pat_type with - {desc = Tvariant row} -> Btype.row_repr row - | _ -> assert false +let open_description sub od = + let loc = sub.location sub od.open_loc in + let attrs = sub.attributes sub od.open_attributes in + Opn.mk ~loc ~attrs + ~override:od.open_override + (map_loc sub od.open_txt) -(* - Check whether the first column of env makes up a complete signature or - not. -*) +let structure_item sub item = + let loc = sub.location sub item.str_loc in + let desc = + match item.str_desc with + Tstr_eval (exp, attrs) -> Pstr_eval (sub.expr sub exp, attrs) + | Tstr_value (rec_flag, list) -> + Pstr_value (rec_flag, List.map (sub.value_binding sub) list) + | Tstr_primitive vd -> + Pstr_primitive (sub.value_description sub vd) + | Tstr_type (rec_flag, list) -> + Pstr_type (rec_flag, List.map (sub.type_declaration sub) list) + | Tstr_typext tyext -> + Pstr_typext (sub.type_extension sub tyext) + | Tstr_exception ext -> + Pstr_exception (sub.extension_constructor sub ext) + | Tstr_module mb -> + Pstr_module (sub.module_binding sub mb) + | Tstr_recmodule list -> + Pstr_recmodule (List.map (sub.module_binding sub) list) + | Tstr_modtype mtd -> + Pstr_modtype (sub.module_type_declaration sub mtd) + | Tstr_open od -> + Pstr_open (sub.open_description sub od) + | Tstr_class list -> + Pstr_class + (List.map + (fun (ci, _) -> sub.class_declaration sub ci) + list) + | Tstr_class_type list -> + Pstr_class_type + (List.map + (fun (_id, _name, ct) -> sub.class_type_declaration sub ct) + list) + | Tstr_include incl -> + Pstr_include (sub.include_declaration sub incl) + | Tstr_attribute x -> + Pstr_attribute x + in + Str.mk ~loc desc -let full_match closing env = match env with -| ({pat_desc = Tpat_construct(_,c,_)},_) :: _ -> - if c.cstr_consts < 0 then false (* extensions *) - else List.length env = c.cstr_consts + c.cstr_nonconsts -| ({pat_desc = Tpat_variant _} as p,_) :: _ -> - let fields = - List.map - (function ({pat_desc = Tpat_variant (tag, _, _)}, _) -> tag - | _ -> assert false) - env - in - let row = row_of_pat p in - if closing && not (Btype.row_fixed row) then - (* closing=true, we are considering the variant as closed *) - List.for_all - (fun (tag,f) -> - match Btype.row_field_repr f with - Rabsent | Reither(_, _, false, _) -> true - | Reither (_, _, true, _) - (* m=true, do not discard matched tags, rather warn *) - | Rpresent _ -> List.mem tag fields) - row.row_fields - else - row.row_closed && - List.for_all - (fun (tag,f) -> - Btype.row_field_repr f = Rabsent || List.mem tag fields) - row.row_fields -| ({pat_desc = Tpat_constant(Const_char _)},_) :: _ -> - List.length env = 256 -| ({pat_desc = Tpat_constant(_)},_) :: _ -> false -| ({pat_desc = Tpat_tuple(_)},_) :: _ -> true -| ({pat_desc = Tpat_record(_)},_) :: _ -> true -| ({pat_desc = Tpat_array(_)},_) :: _ -> false -| ({pat_desc = Tpat_lazy(_)},_) :: _ -> true -| ({pat_desc = (Tpat_any|Tpat_var _|Tpat_alias _|Tpat_or _)},_) :: _ -| [] - -> - assert false +let value_description sub v = + let loc = sub.location sub v.val_loc in + let attrs = sub.attributes sub v.val_attributes in + Val.mk ~loc ~attrs + ~prim:v.val_prim + (map_loc sub v.val_name) + (sub.typ sub v.val_desc) -(* Written as a non-fragile matching, PR#7451 originated from a fragile matching below. *) -let should_extend ext env = match ext with -| None -> false -| Some ext -> begin match env with - | [] -> assert false - | (p,_)::_ -> - begin match p.pat_desc with - | Tpat_construct - (_, {cstr_tag=(Cstr_constant _|Cstr_block _|Cstr_unboxed)},_) -> - let path = get_type_path p.pat_type p.pat_env in - Path.same path ext - | Tpat_construct - (_, {cstr_tag=(Cstr_extension _)},_) -> false - | Tpat_constant _|Tpat_tuple _|Tpat_variant _ - | Tpat_record _|Tpat_array _ | Tpat_lazy _ - -> false - | Tpat_any|Tpat_var _|Tpat_alias _|Tpat_or _ - -> assert false - end -end +let module_binding sub mb = + let loc = sub.location sub mb.mb_loc in + let attrs = sub.attributes sub mb.mb_attributes in + Mb.mk ~loc ~attrs + (map_loc sub mb.mb_name) + (sub.module_expr sub mb.mb_expr) + +let type_parameter sub (ct, v) = (sub.typ sub ct, v) -module ConstructorTagHashtbl = Hashtbl.Make( - struct - type t = Types.constructor_tag - let hash = Hashtbl.hash - let equal = Types.equal_tag - end -) +let type_declaration sub decl = + let loc = sub.location sub decl.typ_loc in + let attrs = sub.attributes sub decl.typ_attributes in + Type.mk ~loc ~attrs + ~params:(List.map (type_parameter sub) decl.typ_params) + ~cstrs:( + List.map + (fun (ct1, ct2, loc) -> + (sub.typ sub ct1, sub.typ sub ct2, sub.location sub loc)) + decl.typ_cstrs) + ~kind:(sub.type_kind sub decl.typ_kind) + ~priv:decl.typ_private + ?manifest:(map_opt (sub.typ sub) decl.typ_manifest) + (map_loc sub decl.typ_name) -(* complement constructor tags *) -let complete_tags nconsts nconstrs tags = - let seen_const = Array.make nconsts false - and seen_constr = Array.make nconstrs false in - List.iter - (function - | Cstr_constant i -> seen_const.(i) <- true - | Cstr_block i -> seen_constr.(i) <- true - | _ -> assert false) - tags ; - let r = ConstructorTagHashtbl.create (nconsts+nconstrs) in - for i = 0 to nconsts-1 do - if not seen_const.(i) then - ConstructorTagHashtbl.add r (Cstr_constant i) () - done ; - for i = 0 to nconstrs-1 do - if not seen_constr.(i) then - ConstructorTagHashtbl.add r (Cstr_block i) () - done ; - r +let type_kind sub tk = match tk with + | Ttype_abstract -> Ptype_abstract + | Ttype_variant list -> + Ptype_variant (List.map (sub.constructor_declaration sub) list) + | Ttype_record list -> + Ptype_record (List.map (sub.label_declaration sub) list) + | Ttype_open -> Ptype_open -(* build a pattern from a constructor list *) -let pat_of_constr ex_pat cstr = - {ex_pat with pat_desc = - Tpat_construct (mknoloc (Longident.Lident "?pat_of_constr?"), - cstr, omegas cstr.cstr_arity)} +let constructor_arguments sub = function + | Cstr_tuple l -> Pcstr_tuple (List.map (sub.typ sub) l) + | Cstr_record l -> Pcstr_record (List.map (sub.label_declaration sub) l) -let orify x y = make_pat (Tpat_or (x, y, None)) x.pat_type x.pat_env +let constructor_declaration sub cd = + let loc = sub.location sub cd.cd_loc in + let attrs = sub.attributes sub cd.cd_attributes in + Type.constructor ~loc ~attrs + ~args:(constructor_arguments sub cd.cd_args) + ?res:(map_opt (sub.typ sub) cd.cd_res) + (map_loc sub cd.cd_name) -let rec orify_many = function -| [] -> assert false -| [x] -> x -| x :: xs -> orify x (orify_many xs) +let label_declaration sub ld = + let loc = sub.location sub ld.ld_loc in + let attrs = sub.attributes sub ld.ld_attributes in + Type.field ~loc ~attrs + ~mut:ld.ld_mutable + (map_loc sub ld.ld_name) + (sub.typ sub ld.ld_type) -let pat_of_constrs ex_pat cstrs = - if cstrs = [] then raise Empty else - orify_many (List.map (pat_of_constr ex_pat) cstrs) +let type_extension sub tyext = + let attrs = sub.attributes sub tyext.tyext_attributes in + Te.mk ~attrs + ~params:(List.map (type_parameter sub) tyext.tyext_params) + ~priv:tyext.tyext_private + (map_loc sub tyext.tyext_txt) + (List.map (sub.extension_constructor sub) tyext.tyext_constructors) -let pats_of_type ?(always=false) env ty = - let ty' = Ctype.expand_head env ty in - match ty'.desc with - | Tconstr (path, _, _) -> - begin try match (Env.find_type path env).type_kind with - | Type_variant cl when always || List.length cl = 1 || - List.for_all (fun cd -> cd.Types.cd_res <> None) cl -> - let cstrs = fst (Env.find_type_descrs path env) in - List.map (pat_of_constr (make_pat Tpat_any ty env)) cstrs - | Type_record _ -> - let labels = snd (Env.find_type_descrs path env) in - let fields = - List.map (fun ld -> - mknoloc (Longident.Lident "?pat_of_label?"), ld, omega) - labels - in - [make_pat (Tpat_record (fields, Closed)) ty env] - | _ -> [omega] - with Not_found -> [omega] - end - | Ttuple tl -> - [make_pat (Tpat_tuple (omegas (List.length tl))) ty env] - | _ -> [omega] +let extension_constructor sub ext = + let loc = sub.location sub ext.ext_loc in + let attrs = sub.attributes sub ext.ext_attributes in + Te.constructor ~loc ~attrs + (map_loc sub ext.ext_name) + (match ext.ext_kind with + | Text_decl (args, ret) -> + Pext_decl (constructor_arguments sub args, + map_opt (sub.typ sub) ret) + | Text_rebind (_p, lid) -> Pext_rebind (map_loc sub lid) + ) -let rec get_variant_constructors env ty = - match (Ctype.repr ty).desc with - | Tconstr (path,_,_) -> begin - try match Env.find_type path env with - | {type_kind=Type_variant _} -> - fst (Env.find_type_descrs path env) - | {type_manifest = Some _} -> - get_variant_constructors env - (Ctype.expand_head_once env (clean_copy ty)) - | _ -> fatal_error "Parmatch.get_variant_constructors" - with Not_found -> - fatal_error "Parmatch.get_variant_constructors" - end - | _ -> fatal_error "Parmatch.get_variant_constructors" +let pattern sub pat = + let loc = sub.location sub pat.pat_loc in + (* todo: fix attributes on extras *) + let attrs = sub.attributes sub pat.pat_attributes in + let desc = + match pat with + { pat_extra=[Tpat_unpack, _, _attrs]; pat_desc = Tpat_var (_,name); _ } -> + Ppat_unpack name + | { pat_extra=[Tpat_type (_path, lid), _, _attrs]; _ } -> + Ppat_type (map_loc sub lid) + | { pat_extra= (Tpat_constraint ct, _, _attrs) :: rem; _ } -> + Ppat_constraint (sub.pat sub { pat with pat_extra=rem }, + sub.typ sub ct) + | _ -> + match pat.pat_desc with + Tpat_any -> Ppat_any + | Tpat_var (id, name) -> + begin + match (Ident.name id).[0] with + 'A'..'Z' -> + Ppat_unpack name + | _ -> + Ppat_var name + end -(* Sends back a pattern that complements constructor tags all_tag *) -let complete_constrs p all_tags = - let c = - match p.pat_desc with Tpat_construct (_, c, _) -> c | _ -> assert false in - let not_tags = complete_tags c.cstr_consts c.cstr_nonconsts all_tags in - let constrs = get_variant_constructors p.pat_env c.cstr_res in - let others = - List.filter - (fun cnstr -> ConstructorTagHashtbl.mem not_tags cnstr.cstr_tag) - constrs in - let const, nonconst = - List.partition (fun cnstr -> cnstr.cstr_arity = 0) others in - const @ nonconst + (* We transform (_ as x) in x if _ and x have the same location. + The compiler transforms (x:t) into (_ as x : t). + This avoids transforming a warning 27 into a 26. + *) + | Tpat_alias ({pat_desc = Tpat_any; pat_loc}, _id, name) + when pat_loc = pat.pat_loc -> + Ppat_var name -let build_other_constrs env p = - match p.pat_desc with - Tpat_construct (_, {cstr_tag=Cstr_constant _|Cstr_block _}, _) -> - let get_tag = function - | {pat_desc = Tpat_construct (_,c,_)} -> c.cstr_tag - | _ -> fatal_error "Parmatch.get_tag" in - let all_tags = List.map (fun (p,_) -> get_tag p) env in - pat_of_constrs p (complete_constrs p all_tags) - | _ -> extra_pat + | Tpat_alias (pat, _id, name) -> + Ppat_alias (sub.pat sub pat, name) + | Tpat_constant cst -> Ppat_constant (constant cst) + | Tpat_tuple list -> + Ppat_tuple (List.map (sub.pat sub) list) + | Tpat_construct (lid, _, args) -> + Ppat_construct (map_loc sub lid, + (match args with + [] -> None + | [arg] -> Some (sub.pat sub arg) + | args -> + Some + (Pat.tuple ~loc + (List.map (sub.pat sub) args) + ) + )) + | Tpat_variant (label, pato, _) -> + Ppat_variant (label, map_opt (sub.pat sub) pato) + | Tpat_record (list, closed) -> + Ppat_record (List.map (fun (lid, _, pat) -> + map_loc sub lid, sub.pat sub pat) list, closed) + | Tpat_array list -> Ppat_array (List.map (sub.pat sub) list) + | Tpat_or (p1, p2, _) -> Ppat_or (sub.pat sub p1, sub.pat sub p2) + | Tpat_lazy p -> Ppat_lazy (sub.pat sub p) + in + Pat.mk ~loc ~attrs desc -(* Auxiliary for build_other *) +let exp_extra sub (extra, loc, attrs) sexp = + let loc = sub.location sub loc in + let attrs = sub.attributes sub attrs in + let desc = + match extra with + Texp_coerce (cty1, cty2) -> + Pexp_coerce (sexp, + map_opt (sub.typ sub) cty1, + sub.typ sub cty2) + | Texp_constraint cty -> + Pexp_constraint (sexp, sub.typ sub cty) + | Texp_open (ovf, _path, lid, _) -> + Pexp_open (ovf, map_loc sub lid, sexp) + | Texp_poly cto -> Pexp_poly (sexp, map_opt (sub.typ sub) cto) + | Texp_newtype s -> Pexp_newtype (mkloc s loc, sexp) + in + Exp.mk ~loc ~attrs desc -let build_other_constant proj make first next p env = - let all = List.map (fun (p, _) -> proj p.pat_desc) env in - let rec try_const i = - if List.mem i all - then try_const (next i) - else make_pat (make i) p.pat_type p.pat_env - in try_const first +let cases sub l = List.map (sub.case sub) l -(* - Builds a pattern that is incompatible with all patterns in - in the first column of env -*) +let case sub {c_lhs; c_guard; c_rhs} = + { + pc_lhs = sub.pat sub c_lhs; + pc_guard = map_opt (sub.expr sub) c_guard; + pc_rhs = sub.expr sub c_rhs; + } -let some_other_tag = "" +let value_binding sub vb = + let loc = sub.location sub vb.vb_loc in + let attrs = sub.attributes sub vb.vb_attributes in + Vb.mk ~loc ~attrs + (sub.pat sub vb.vb_pat) + (sub.expr sub vb.vb_expr) -let build_other ext env = match env with -| ({pat_desc = Tpat_construct (lid, {cstr_tag=Cstr_extension _},_)},_) :: _ -> - (* let c = {c with cstr_name = "*extension*"} in *) (* PR#7330 *) - make_pat (Tpat_var (Ident.create "*extension*", - {lid with txt="*extension*"})) Ctype.none Env.empty -| ({pat_desc = Tpat_construct _} as p,_) :: _ -> - begin match ext with - | Some ext when Path.same ext (get_type_path p.pat_type p.pat_env) -> - extra_pat - | _ -> - build_other_constrs env p - end -| ({pat_desc = Tpat_variant (_,_,r)} as p,_) :: _ -> - let tags = - List.map - (function ({pat_desc = Tpat_variant (tag, _, _)}, _) -> tag - | _ -> assert false) - env - in - let row = row_of_pat p in - let make_other_pat tag const = - let arg = if const then None else Some omega in - make_pat (Tpat_variant(tag, arg, r)) p.pat_type p.pat_env in - begin match - List.fold_left - (fun others (tag,f) -> - if List.mem tag tags then others else - match Btype.row_field_repr f with - Rabsent (* | Reither _ *) -> others - (* This one is called after erasing pattern info *) - | Reither (c, _, _, _) -> make_other_pat tag c :: others - | Rpresent arg -> make_other_pat tag (arg = None) :: others) - [] row.row_fields - with - [] -> - make_other_pat some_other_tag true - | pat::other_pats -> - List.fold_left - (fun p_res pat -> - make_pat (Tpat_or (pat, p_res, None)) p.pat_type p.pat_env) - pat other_pats - end -| ({pat_desc = Tpat_constant(Const_char _)} as p,_) :: _ -> - let all_chars = - List.map - (fun (p,_) -> match p.pat_desc with - | Tpat_constant (Const_char c) -> c - | _ -> assert false) - env in +let expression sub exp = + let loc = sub.location sub exp.exp_loc in + let attrs = sub.attributes sub exp.exp_attributes in + let desc = + match exp.exp_desc with + Texp_ident (_path, lid, _) -> Pexp_ident (map_loc sub lid) + | Texp_constant cst -> Pexp_constant (constant cst) + | Texp_let (rec_flag, list, exp) -> + Pexp_let (rec_flag, + List.map (sub.value_binding sub) list, + sub.expr sub exp) - let rec find_other i imax = - if i > imax then raise Not_found - else - let ci = Char.chr i in - if List.mem ci all_chars then - find_other (i+1) imax - else - make_pat (Tpat_constant (Const_char ci)) p.pat_type p.pat_env in - let rec try_chars = function - | [] -> omega - | (c1,c2) :: rest -> - try - find_other (Char.code c1) (Char.code c2) - with - | Not_found -> try_chars rest in + (* Pexp_function can't have a label, so we split in 3 cases. *) + (* One case, no guard: It's a fun. *) + | Texp_function { arg_label; cases = [{c_lhs=p; c_guard=None; c_rhs=e}]; + _ } -> + Pexp_fun (arg_label, None, sub.pat sub p, sub.expr sub e) + (* No label: it's a function. *) + | Texp_function { arg_label = Nolabel; cases; _; } -> + Pexp_function (sub.cases sub cases) + (* Mix of both, we generate `fun ~label:$name$ -> match $name$ with ...` *) + | Texp_function { arg_label = Labelled s | Optional s as label; cases; + _ } -> + let name = fresh_name s exp.exp_env in + Pexp_fun (label, None, Pat.var ~loc {loc;txt = name }, + Exp.match_ ~loc (Exp.ident ~loc {loc;txt= Lident name}) + (sub.cases sub cases)) + | Texp_apply (exp, list) -> + Pexp_apply (sub.expr sub exp, + List.fold_right (fun (label, expo) list -> + match expo with + None -> list + | Some exp -> (label, sub.expr sub exp) :: list + ) list []) + | Texp_match (exp, cases, exn_cases, _) -> + let merged_cases = sub.cases sub cases + @ List.map + (fun c -> + let uc = sub.case sub c in + let pat = { uc.pc_lhs + with ppat_desc = Ppat_exception uc.pc_lhs } + in + { uc with pc_lhs = pat }) + exn_cases + in + Pexp_match (sub.expr sub exp, merged_cases) + | Texp_try (exp, cases) -> + Pexp_try (sub.expr sub exp, sub.cases sub cases) + | Texp_tuple list -> + Pexp_tuple (List.map (sub.expr sub) list) + | Texp_construct (lid, _, args) -> + Pexp_construct (map_loc sub lid, + (match args with + [] -> None + | [ arg ] -> Some (sub.expr sub arg) + | args -> + Some + (Exp.tuple ~loc (List.map (sub.expr sub) args)) + )) + | Texp_variant (label, expo) -> + Pexp_variant (label, map_opt (sub.expr sub) expo) + | Texp_record { fields; extended_expression; _ } -> + let list = Array.fold_left (fun l -> function + | _, Kept _ -> l + | _, Overridden (lid, exp) -> (lid, sub.expr sub exp) :: l) + [] fields + in + Pexp_record (list, map_opt (sub.expr sub) extended_expression) + | Texp_field (exp, lid, _label) -> + Pexp_field (sub.expr sub exp, map_loc sub lid) + | Texp_setfield (exp1, lid, _label, exp2) -> + Pexp_setfield (sub.expr sub exp1, map_loc sub lid, + sub.expr sub exp2) + | Texp_array list -> + Pexp_array (List.map (sub.expr sub) list) + | Texp_ifthenelse (exp1, exp2, expo) -> + Pexp_ifthenelse (sub.expr sub exp1, + sub.expr sub exp2, + map_opt (sub.expr sub) expo) + | Texp_sequence (exp1, exp2) -> + Pexp_sequence (sub.expr sub exp1, sub.expr sub exp2) + | Texp_while (exp1, exp2) -> + Pexp_while (sub.expr sub exp1, sub.expr sub exp2) + | Texp_for (_id, name, exp1, exp2, dir, exp3) -> + Pexp_for (name, + sub.expr sub exp1, sub.expr sub exp2, + dir, sub.expr sub exp3) + | Texp_send (exp, meth, _) -> + Pexp_send (sub.expr sub exp, match meth with + Tmeth_name name -> mkloc name loc + | Tmeth_val id -> mkloc (Ident.name id) loc) + | Texp_new (_path, lid, _) -> Pexp_new (map_loc sub lid) + | Texp_instvar (_, path, name) -> + Pexp_ident ({loc = sub.location sub name.loc ; txt = lident_of_path path}) + | Texp_setinstvar (_, _path, lid, exp) -> + Pexp_setinstvar (map_loc sub lid, sub.expr sub exp) + | Texp_override (_, list) -> + Pexp_override (List.map (fun (_path, lid, exp) -> + (map_loc sub lid, sub.expr sub exp) + ) list) + | Texp_letmodule (_id, name, mexpr, exp) -> + Pexp_letmodule (name, sub.module_expr sub mexpr, + sub.expr sub exp) + | Texp_letexception (ext, exp) -> + Pexp_letexception (sub.extension_constructor sub ext, + sub.expr sub exp) + | Texp_assert exp -> Pexp_assert (sub.expr sub exp) + | Texp_lazy exp -> Pexp_lazy (sub.expr sub exp) + | Texp_object (cl, _) -> + Pexp_object (sub.class_structure sub cl) + | Texp_pack (mexpr) -> + Pexp_pack (sub.module_expr sub mexpr) + | Texp_unreachable -> + Pexp_unreachable + | Texp_extension_constructor (lid, _) -> + Pexp_extension ({ txt = "ocaml.extension_constructor"; loc }, + PStr [ Str.eval ~loc + (Exp.construct ~loc (map_loc sub lid) None) + ]) + in + List.fold_right (exp_extra sub) exp.exp_extra + (Exp.mk ~loc ~attrs desc) - try_chars - [ 'a', 'z' ; 'A', 'Z' ; '0', '9' ; - ' ', '~' ; Char.chr 0 , Char.chr 255] +let package_type sub pack = + (map_loc sub pack.pack_txt, + List.map (fun (s, ct) -> + (s, sub.typ sub ct)) pack.pack_fields) -| ({pat_desc=(Tpat_constant (Const_int _))} as p,_) :: _ -> - build_other_constant - (function Tpat_constant(Const_int i) -> i | _ -> assert false) - (function i -> Tpat_constant(Const_int i)) - 0 succ p env -| ({pat_desc=(Tpat_constant (Const_int32 _))} as p,_) :: _ -> - build_other_constant - (function Tpat_constant(Const_int32 i) -> i | _ -> assert false) - (function i -> Tpat_constant(Const_int32 i)) - 0l Int32.succ p env -| ({pat_desc=(Tpat_constant (Const_int64 _))} as p,_) :: _ -> - build_other_constant - (function Tpat_constant(Const_int64 i) -> i | _ -> assert false) - (function i -> Tpat_constant(Const_int64 i)) - 0L Int64.succ p env -| ({pat_desc=(Tpat_constant (Const_nativeint _))} as p,_) :: _ -> - build_other_constant - (function Tpat_constant(Const_nativeint i) -> i | _ -> assert false) - (function i -> Tpat_constant(Const_nativeint i)) - 0n Nativeint.succ p env -| ({pat_desc=(Tpat_constant (Const_string _))} as p,_) :: _ -> - build_other_constant - (function Tpat_constant(Const_string (s, _)) -> String.length s - | _ -> assert false) - (function i -> Tpat_constant(Const_string(String.make i '*', None))) - 0 succ p env -| ({pat_desc=(Tpat_constant (Const_float _))} as p,_) :: _ -> - build_other_constant - (function Tpat_constant(Const_float f) -> float_of_string f - | _ -> assert false) - (function f -> Tpat_constant(Const_float (string_of_float f))) - 0.0 (fun f -> f +. 1.0) p env +let module_type_declaration sub mtd = + let loc = sub.location sub mtd.mtd_loc in + let attrs = sub.attributes sub mtd.mtd_attributes in + Mtd.mk ~loc ~attrs + ?typ:(map_opt (sub.module_type sub) mtd.mtd_type) + (map_loc sub mtd.mtd_name) -| ({pat_desc = Tpat_array _} as p,_)::_ -> - let all_lengths = - List.map - (fun (p,_) -> match p.pat_desc with - | Tpat_array args -> List.length args - | _ -> assert false) - env in - let rec try_arrays l = - if List.mem l all_lengths then try_arrays (l+1) - else - make_pat - (Tpat_array (omegas l)) - p.pat_type p.pat_env in - try_arrays 0 -| [] -> omega -| _ -> omega +let signature sub sg = + List.map (sub.signature_item sub) sg.sig_items -(* - Core function : - Is the last row of pattern matrix pss + qs satisfiable ? - That is : - Does there exists at least one value vector, es such that : - 1- for all ps in pss ps # es (ps and es are not compatible) - 2- qs <= es (es matches qs) -*) +let signature_item sub item = + let loc = sub.location sub item.sig_loc in + let desc = + match item.sig_desc with + Tsig_value v -> + Psig_value (sub.value_description sub v) + | Tsig_type (rec_flag, list) -> + Psig_type (rec_flag, List.map (sub.type_declaration sub) list) + | Tsig_typext tyext -> + Psig_typext (sub.type_extension sub tyext) + | Tsig_exception ext -> + Psig_exception (sub.extension_constructor sub ext) + | Tsig_module md -> + Psig_module (sub.module_declaration sub md) + | Tsig_recmodule list -> + Psig_recmodule (List.map (sub.module_declaration sub) list) + | Tsig_modtype mtd -> + Psig_modtype (sub.module_type_declaration sub mtd) + | Tsig_open od -> + Psig_open (sub.open_description sub od) + | Tsig_include incl -> + Psig_include (sub.include_description sub incl) + | Tsig_class list -> + Psig_class (List.map (sub.class_description sub) list) + | Tsig_class_type list -> + Psig_class_type (List.map (sub.class_type_declaration sub) list) + | Tsig_attribute x -> + Psig_attribute x + in + Sig.mk ~loc desc -let rec has_instance p = match p.pat_desc with - | Tpat_variant (l,_,r) when is_absent l r -> false - | Tpat_any | Tpat_var _ | Tpat_constant _ | Tpat_variant (_,None,_) -> true - | Tpat_alias (p,_,_) | Tpat_variant (_,Some p,_) -> has_instance p - | Tpat_or (p1,p2,_) -> has_instance p1 || has_instance p2 - | Tpat_construct (_,_,ps) | Tpat_tuple ps | Tpat_array ps -> - has_instances ps - | Tpat_record (lps,_) -> has_instances (List.map (fun (_,_,x) -> x) lps) - | Tpat_lazy p - -> has_instance p +let module_declaration sub md = + let loc = sub.location sub md.md_loc in + let attrs = sub.attributes sub md.md_attributes in + Md.mk ~loc ~attrs + (map_loc sub md.md_name) + (sub.module_type sub md.md_type) +let include_infos f sub incl = + let loc = sub.location sub incl.incl_loc in + let attrs = sub.attributes sub incl.incl_attributes in + Incl.mk ~loc ~attrs + (f sub incl.incl_mod) -and has_instances = function - | [] -> true - | q::rem -> has_instance q && has_instances rem +let include_declaration sub = include_infos sub.module_expr sub +let include_description sub = include_infos sub.module_type sub -(* - In two places in the following function, we check the coherence of the first - column of (pss + qs). - If it is incoherent, then we exit early saying that (pss + qs) is not - satisfiable (which is equivalent to saying "oh, we shouldn't have considered - that branch, no good result came come from here"). +let class_infos f sub ci = + let loc = sub.location sub ci.ci_loc in + let attrs = sub.attributes sub ci.ci_attributes in + Ci.mk ~loc ~attrs + ~virt:ci.ci_virt + ~params:(List.map (type_parameter sub) ci.ci_params) + (map_loc sub ci.ci_id_name) + (f sub ci.ci_expr) - But what happens if we have a coherent but ill-typed column? - - we might end up returning [false], which is equivalent to noticing the - incompatibility: clearly this is fine. - - if we end up returning [true] then we're saying that [qs] is useful while - it is not. This is sad but not the end of the world, we're just allowing dead - code to survive. -*) -let rec satisfiable pss qs = match pss with -| [] -> has_instances qs -| _ -> - match qs with - | [] -> false - | {pat_desc = Tpat_or(q1,q2,_)}::qs -> - satisfiable pss (q1::qs) || satisfiable pss (q2::qs) - | {pat_desc = Tpat_alias(q,_,_)}::qs -> - satisfiable pss (q::qs) - | {pat_desc = (Tpat_any | Tpat_var(_))}::qs -> - if not (all_coherent (simplified_first_col pss)) then - false - else begin - let q0 = discr_pat omega pss in - match filter_all q0 pss with - (* first column of pss is made of variables only *) - | [] -> satisfiable (filter_extra pss) qs - | constrs -> - if full_match false constrs then - List.exists - (fun (p,pss) -> - not (is_absent_pat p) && - satisfiable pss (simple_match_args p omega @ qs)) - constrs - else - satisfiable (filter_extra pss) qs - end - | {pat_desc=Tpat_variant (l,_,r)}::_ when is_absent l r -> false - | q::qs -> - if not (all_coherent (q :: simplified_first_col pss)) then - false - else begin - let q0 = discr_pat q pss in - satisfiable (filter_one q0 pss) (simple_match_args q0 q @ qs) - end +let class_declaration sub = class_infos sub.class_expr sub +let class_description sub = class_infos sub.class_type sub +let class_type_declaration sub = class_infos sub.class_type sub -(* Also return the remaining cases, to enable GADT handling +let module_type sub mty = + let loc = sub.location sub mty.mty_loc in + let attrs = sub.attributes sub mty.mty_attributes in + let desc = match mty.mty_desc with + Tmty_ident (_path, lid) -> Pmty_ident (map_loc sub lid) + | Tmty_alias (_path, lid) -> Pmty_alias (map_loc sub lid) + | Tmty_signature sg -> Pmty_signature (sub.signature sub sg) + | Tmty_functor (_id, name, mtype1, mtype2) -> + Pmty_functor (name, map_opt (sub.module_type sub) mtype1, + sub.module_type sub mtype2) + | Tmty_with (mtype, list) -> + Pmty_with (sub.module_type sub mtype, + List.map (sub.with_constraint sub) list) + | Tmty_typeof mexpr -> + Pmty_typeof (sub.module_expr sub mexpr) + in + Mty.mk ~loc ~attrs desc - For considerations regarding the coherence check, see the comment on - [satisfiable] above. *) -let rec satisfiables pss qs = match pss with -| [] -> if has_instances qs then [qs] else [] -| _ -> - match qs with - | [] -> [] - | {pat_desc = Tpat_or(q1,q2,_)}::qs -> - satisfiables pss (q1::qs) @ satisfiables pss (q2::qs) - | {pat_desc = Tpat_alias(q,_,_)}::qs -> - satisfiables pss (q::qs) - | {pat_desc = (Tpat_any | Tpat_var(_))}::qs -> - if not (all_coherent (simplified_first_col pss)) then - [] - else begin - let q0 = discr_pat omega pss in - let wild p = - List.map (fun qs -> p::qs) (satisfiables (filter_extra pss) qs) in - match filter_all q0 pss with - (* first column of pss is made of variables only *) - | [] -> - wild omega - | (p,_)::_ as constrs -> - let for_constrs () = - List.flatten ( - List.map - (fun (p,pss) -> - if is_absent_pat p then [] else - List.map (set_args p) - (satisfiables pss (simple_match_args p omega @ qs))) - constrs ) - in - if full_match false constrs then for_constrs () else - match p.pat_desc with - Tpat_construct _ -> - (* activate this code for checking non-gadt constructors *) - wild (build_other_constrs constrs p) @ for_constrs () - | _ -> - wild omega - end - | {pat_desc=Tpat_variant (l,_,r)}::_ when is_absent l r -> [] - | q::qs -> - if not (all_coherent (q :: simplified_first_col pss)) then - [] - else begin - let q0 = discr_pat q pss in - List.map (set_args q0) - (satisfiables (filter_one q0 pss) (simple_match_args q0 q @ qs)) - end +let with_constraint sub (_path, lid, cstr) = + match cstr with + | Twith_type decl -> + Pwith_type (map_loc sub lid, sub.type_declaration sub decl) + | Twith_module (_path, lid2) -> + Pwith_module (map_loc sub lid, map_loc sub lid2) + | Twith_typesubst decl -> + Pwith_typesubst (map_loc sub lid, sub.type_declaration sub decl) + | Twith_modsubst (_path, lid2) -> + Pwith_modsubst (map_loc sub lid, map_loc sub lid2) -(* - Now another satisfiable function that additionally - supplies an example of a matching value. +let module_expr sub mexpr = + let loc = sub.location sub mexpr.mod_loc in + let attrs = sub.attributes sub mexpr.mod_attributes in + match mexpr.mod_desc with + Tmod_constraint (m, _, Tmodtype_implicit, _ ) -> + sub.module_expr sub m + | _ -> + let desc = match mexpr.mod_desc with + Tmod_ident (_p, lid) -> Pmod_ident (map_loc sub lid) + | Tmod_structure st -> Pmod_structure (sub.structure sub st) + | Tmod_functor (_id, name, mtype, mexpr) -> + Pmod_functor (name, Misc.may_map (sub.module_type sub) mtype, + sub.module_expr sub mexpr) + | Tmod_apply (mexp1, mexp2, _) -> + Pmod_apply (sub.module_expr sub mexp1, sub.module_expr sub mexp2) + | Tmod_constraint (mexpr, _, Tmodtype_explicit mtype, _) -> + Pmod_constraint (sub.module_expr sub mexpr, + sub.module_type sub mtype) + | Tmod_constraint (_mexpr, _, Tmodtype_implicit, _) -> + assert false + | Tmod_unpack (exp, _pack) -> + Pmod_unpack (sub.expr sub exp) + (* TODO , sub.package_type sub pack) *) + in + Mod.mk ~loc ~attrs desc - This function should be called for exhaustiveness check only. -*) +let class_expr sub cexpr = + let loc = sub.location sub cexpr.cl_loc in + let attrs = sub.attributes sub cexpr.cl_attributes in + let desc = match cexpr.cl_desc with + | Tcl_constraint ( { cl_desc = Tcl_ident (_path, lid, tyl); _ }, + None, _, _, _ ) -> + Pcl_constr (map_loc sub lid, + List.map (sub.typ sub) tyl) + | Tcl_structure clstr -> Pcl_structure (sub.class_structure sub clstr) -type 'a result = - | Rnone (* No matching value *) - | Rsome of 'a (* This matching value *) + | Tcl_fun (label, pat, _pv, cl, _partial) -> + Pcl_fun (label, None, sub.pat sub pat, sub.class_expr sub cl) -(* -let rec try_many f = function - | [] -> Rnone - | (p,pss)::rest -> - match f (p,pss) with - | Rnone -> try_many f rest - | r -> r -*) + | Tcl_apply (cl, args) -> + Pcl_apply (sub.class_expr sub cl, + List.fold_right (fun (label, expo) list -> + match expo with + None -> list + | Some exp -> (label, sub.expr sub exp) :: list + ) args []) -let rappend r1 r2 = - match r1, r2 with - | Rnone, _ -> r2 - | _, Rnone -> r1 - | Rsome l1, Rsome l2 -> Rsome (l1 @ l2) + | Tcl_let (rec_flat, bindings, _ivars, cl) -> + Pcl_let (rec_flat, + List.map (sub.value_binding sub) bindings, + sub.class_expr sub cl) -let rec try_many_gadt f = function - | [] -> Rnone - | (p,pss)::rest -> - rappend (f (p, pss)) (try_many_gadt f rest) + | Tcl_constraint (cl, Some clty, _vals, _meths, _concrs) -> + Pcl_constraint (sub.class_expr sub cl, sub.class_type sub clty) -(* -let rec exhaust ext pss n = match pss with -| [] -> Rsome (omegas n) -| []::_ -> Rnone -| pss -> - let q0 = discr_pat omega pss in - begin match filter_all q0 pss with - (* first column of pss is made of variables only *) - | [] -> - begin match exhaust ext (filter_extra pss) (n-1) with - | Rsome r -> Rsome (q0::r) - | r -> r - end - | constrs -> - let try_non_omega (p,pss) = - if is_absent_pat p then - Rnone - else - match - exhaust - ext pss (List.length (simple_match_args p omega) + n - 1) - with - | Rsome r -> Rsome (set_args p r) - | r -> r in - if - full_match true false constrs && not (should_extend ext constrs) - then - try_many try_non_omega constrs - else - (* - D = filter_extra pss is the default matrix - as it is included in pss, one can avoid - recursive calls on specialized matrices, - Essentially : - * D exhaustive => pss exhaustive - * D non-exhaustive => we have a non-filtered value - *) - let r = exhaust ext (filter_extra pss) (n-1) in - match r with - | Rnone -> Rnone - | Rsome r -> - try - Rsome (build_other ext constrs::r) - with - (* cannot occur, since constructors don't make a full signature *) - | Empty -> fatal_error "Parmatch.exhaust" - end + | Tcl_open (ovf, _p, lid, _env, e) -> + Pcl_open (ovf, lid, sub.class_expr sub e) -let combinations f lst lst' = - let rec iter2 x = - function - [] -> [] - | y :: ys -> - f x y :: iter2 x ys - in - let rec iter = - function - [] -> [] - | x :: xs -> iter2 x lst' @ iter xs + | Tcl_ident _ -> assert false + | Tcl_constraint (_, None, _, _, _) -> assert false in - iter lst -*) -(* -let print_pat pat = - let rec string_of_pat pat = - match pat.pat_desc with - Tpat_var _ -> "v" - | Tpat_any -> "_" - | Tpat_alias (p, x) -> Printf.sprintf "(%s) as ?" (string_of_pat p) - | Tpat_constant n -> "0" - | Tpat_construct (_, lid, _) -> - Printf.sprintf "%s" (String.concat "." (Longident.flatten lid.txt)) - | Tpat_lazy p -> - Printf.sprintf "(lazy %s)" (string_of_pat p) - | Tpat_or (p1,p2,_) -> - Printf.sprintf "(%s | %s)" (string_of_pat p1) (string_of_pat p2) - | Tpat_tuple list -> - Printf.sprintf "(%s)" (String.concat "," (List.map string_of_pat list)) - | Tpat_variant (_, _, _) -> "variant" - | Tpat_record (_, _) -> "record" - | Tpat_array _ -> "array" + Cl.mk ~loc ~attrs desc + +let class_type sub ct = + let loc = sub.location sub ct.cltyp_loc in + let attrs = sub.attributes sub ct.cltyp_attributes in + let desc = match ct.cltyp_desc with + Tcty_signature csg -> Pcty_signature (sub.class_signature sub csg) + | Tcty_constr (_path, lid, list) -> + Pcty_constr (map_loc sub lid, List.map (sub.typ sub) list) + | Tcty_arrow (label, ct, cl) -> + Pcty_arrow (label, sub.typ sub ct, sub.class_type sub cl) + | Tcty_open (ovf, _p, lid, _env, e) -> + Pcty_open (ovf, lid, sub.class_type sub e) in - Printf.fprintf stderr "PAT[%s]\n%!" (string_of_pat pat) -*) + Cty.mk ~loc ~attrs desc -(* strictly more powerful than exhaust; however, exhaust - was kept for backwards compatibility *) -let rec exhaust_gadt (ext:Path.t option) pss n = match pss with -| [] -> Rsome [omegas n] -| []::_ -> Rnone -| pss -> - if not (all_coherent (simplified_first_col pss)) then - (* We're considering an ill-typed branch, we won't actually be able to - produce a well typed value taking that branch. *) - Rnone - else begin - (* Assuming the first column is ill-typed but considered coherent, we - might end up producing an ill-typed witness of non-exhaustivity - corresponding to the current branch. +let class_signature sub cs = + { + pcsig_self = sub.typ sub cs.csig_self; + pcsig_fields = List.map (sub.class_type_field sub) cs.csig_fields; + } - If [exhaust] has been called by [do_check_partial], then the witnesses - produced get typechecked and the ill-typed ones are discarded. +let class_type_field sub ctf = + let loc = sub.location sub ctf.ctf_loc in + let attrs = sub.attributes sub ctf.ctf_attributes in + let desc = match ctf.ctf_desc with + Tctf_inherit ct -> Pctf_inherit (sub.class_type sub ct) + | Tctf_val (s, mut, virt, ct) -> + Pctf_val (mkloc s loc, mut, virt, sub.typ sub ct) + | Tctf_method (s, priv, virt, ct) -> + Pctf_method (mkloc s loc, priv, virt, sub.typ sub ct) + | Tctf_constraint (ct1, ct2) -> + Pctf_constraint (sub.typ sub ct1, sub.typ sub ct2) + | Tctf_attribute x -> Pctf_attribute x + in + Ctf.mk ~loc ~attrs desc - If [exhaust] has been called by [do_check_fragile], then it is possible - we might fail to warn the user that the matching is fragile. See for - example testsuite/tests/warnings/w04_failure.ml. *) - let q0 = discr_pat omega pss in - match filter_all q0 pss with - (* first column of pss is made of variables only *) - | [] -> - begin match exhaust_gadt ext (filter_extra pss) (n-1) with - | Rsome r -> Rsome (List.map (fun row -> q0::row) r) - | r -> r - end - | constrs -> - let try_non_omega (p,pss) = - if is_absent_pat p then - Rnone - else - match - exhaust_gadt - ext pss (List.length (simple_match_args p omega) + n - 1) - with - | Rsome r -> Rsome (List.map (fun row -> (set_args p row)) r) - | r -> r in - let before = try_many_gadt try_non_omega constrs in - if - full_match false constrs && not (should_extend ext constrs) - then - before - else - (* - D = filter_extra pss is the default matrix - as it is included in pss, one can avoid - recursive calls on specialized matrices, - Essentially : - * D exhaustive => pss exhaustive - * D non-exhaustive => we have a non-filtered value - *) - let r = exhaust_gadt ext (filter_extra pss) (n-1) in - match r with - | Rnone -> before - | Rsome r -> - try - let p = build_other ext constrs in - let dug = List.map (fun tail -> p :: tail) r in - match before with - | Rnone -> Rsome dug - | Rsome x -> Rsome (x @ dug) - with - (* cannot occur, since constructors don't make a full signature *) - | Empty -> fatal_error "Parmatch.exhaust" - end +let core_type sub ct = + let loc = sub.location sub ct.ctyp_loc in + let attrs = sub.attributes sub ct.ctyp_attributes in + let desc = match ct.ctyp_desc with + Ttyp_any -> Ptyp_any + | Ttyp_var s -> Ptyp_var s + | Ttyp_arrow (label, ct1, ct2) -> + Ptyp_arrow (label, sub.typ sub ct1, sub.typ sub ct2) + | Ttyp_tuple list -> Ptyp_tuple (List.map (sub.typ sub) list) + | Ttyp_constr (_path, lid, list) -> + Ptyp_constr (map_loc sub lid, + List.map (sub.typ sub) list) + | Ttyp_object (list, o) -> + Ptyp_object + (List.map (sub.object_field sub) list, o) + | Ttyp_class (_path, lid, list) -> + Ptyp_class (map_loc sub lid, List.map (sub.typ sub) list) + | Ttyp_alias (ct, s) -> + Ptyp_alias (sub.typ sub ct, s) + | Ttyp_variant (list, bool, labels) -> + Ptyp_variant (List.map (sub.row_field sub) list, bool, labels) + | Ttyp_poly (list, ct) -> + let list = List.map (fun v -> mkloc v loc) list in + Ptyp_poly (list, sub.typ sub ct) + | Ttyp_package pack -> Ptyp_package (sub.package_type sub pack) + in + Typ.mk ~loc ~attrs desc -let exhaust_gadt ext pss n = - let ret = exhaust_gadt ext pss n in - match ret with - Rnone -> Rnone - | Rsome lst -> - (* The following line is needed to compile stdlib/printf.ml *) - if lst = [] then Rsome (omegas n) else - let singletons = - List.map - (function - [x] -> x - | _ -> assert false) - lst - in - Rsome [orify_many singletons] +let class_structure sub cs = + let rec remove_self = function + | { pat_desc = Tpat_alias (p, id, _s) } + when string_is_prefix "selfpat-" id.Ident.name -> + remove_self p + | p -> p + in + { pcstr_self = sub.pat sub (remove_self cs.cstr_self); + pcstr_fields = List.map (sub.class_field sub) cs.cstr_fields; + } -(* - Another exhaustiveness check, enforcing variant typing. - Note that it does not check exact exhaustiveness, but whether a - matching could be made exhaustive by closing all variant types. - When this is true of all other columns, the current column is left - open (even if it means that the whole matching is not exhaustive as - a result). - When this is false for the matrix minus the current column, and the - current column is composed of variant tags, we close the variant - (even if it doesn't help in making the matching exhaustive). -*) +let row_field sub rf = + match rf with + Ttag (label, attrs, bool, list) -> + Rtag (label, sub.attributes sub attrs, bool, List.map (sub.typ sub) list) + | Tinherit ct -> Rinherit (sub.typ sub ct) -let rec pressure_variants tdefs = function - | [] -> false - | []::_ -> true - | pss -> - if not (all_coherent (simplified_first_col pss)) then - true - else begin - let q0 = discr_pat omega pss in - match filter_all q0 pss with - [] -> pressure_variants tdefs (filter_extra pss) - | constrs -> - let rec try_non_omega = function - (_p,pss) :: rem -> - let ok = pressure_variants tdefs pss in - try_non_omega rem && ok - | [] -> true - in - if full_match (tdefs=None) constrs then - try_non_omega constrs - else if tdefs = None then - pressure_variants None (filter_extra pss) - else - let full = full_match true constrs in - let ok = - if full then try_non_omega constrs - else try_non_omega (filter_all q0 (mark_partial pss)) - in - begin match constrs, tdefs with - ({pat_desc=Tpat_variant _} as p,_):: _, Some env -> - let row = row_of_pat p in - if Btype.row_fixed row - || pressure_variants None (filter_extra pss) then () - else close_variant env row - | _ -> () - end; - ok - end +let object_field sub ofield = + match ofield with + OTtag (label, attrs, ct) -> + Otag (label, sub.attributes sub attrs, sub.typ sub ct) + | OTinherit ct -> Oinherit (sub.typ sub ct) +and is_self_pat = function + | { pat_desc = Tpat_alias(_pat, id, _) } -> + string_is_prefix "self-" (Ident.name id) + | _ -> false -(* Yet another satisfiable function *) +let class_field sub cf = + let loc = sub.location sub cf.cf_loc in + let attrs = sub.attributes sub cf.cf_attributes in + let desc = match cf.cf_desc with + Tcf_inherit (ovf, cl, super, _vals, _meths) -> + Pcf_inherit (ovf, sub.class_expr sub cl, + map_opt (fun v -> mkloc v loc) super) + | Tcf_constraint (cty, cty') -> + Pcf_constraint (sub.typ sub cty, sub.typ sub cty') + | Tcf_val (lab, mut, _, Tcfk_virtual cty, _) -> + Pcf_val (lab, mut, Cfk_virtual (sub.typ sub cty)) + | Tcf_val (lab, mut, _, Tcfk_concrete (o, exp), _) -> + Pcf_val (lab, mut, Cfk_concrete (o, sub.expr sub exp)) + | Tcf_method (lab, priv, Tcfk_virtual cty) -> + Pcf_method (lab, priv, Cfk_virtual (sub.typ sub cty)) + | Tcf_method (lab, priv, Tcfk_concrete (o, exp)) -> + let remove_fun_self = function + | { exp_desc = + Texp_function { arg_label = Nolabel; cases = [case]; _ } } + when is_self_pat case.c_lhs && case.c_guard = None -> case.c_rhs + | e -> e + in + let exp = remove_fun_self exp in + Pcf_method (lab, priv, Cfk_concrete (o, sub.expr sub exp)) + | Tcf_initializer exp -> + let remove_fun_self = function + | { exp_desc = + Texp_function { arg_label = Nolabel; cases = [case]; _ } } + when is_self_pat case.c_lhs && case.c_guard = None -> case.c_rhs + | e -> e + in + let exp = remove_fun_self exp in + Pcf_initializer (sub.expr sub exp) + | Tcf_attribute x -> Pcf_attribute x + in + Cf.mk ~loc ~attrs desc -(* - This time every_satisfiable pss qs checks the - utility of every expansion of qs. - Expansion means expansion of or-patterns inside qs -*) +let location _sub l = l -type answer = - | Used (* Useful pattern *) - | Unused (* Useless pattern *) - | Upartial of Typedtree.pattern list (* Mixed, with list of useless ones *) +let default_mapper = + { + attribute = attribute ; + attributes = attributes ; + structure = structure; + structure_item = structure_item; + module_expr = module_expr; + signature = signature; + signature_item = signature_item; + module_type = module_type; + with_constraint = with_constraint; + class_declaration = class_declaration; + class_expr = class_expr; + class_field = class_field; + class_structure = class_structure; + class_type = class_type; + class_type_field = class_type_field; + class_signature = class_signature; + class_type_declaration = class_type_declaration; + class_description = class_description; + type_declaration = type_declaration; + type_kind = type_kind; + typ = core_type; + type_extension = type_extension; + extension_constructor = extension_constructor; + value_description = value_description; + pat = pattern; + expr = expression; + module_declaration = module_declaration; + module_type_declaration = module_type_declaration; + module_binding = module_binding; + package_type = package_type ; + open_description = open_description; + include_description = include_description; + include_declaration = include_declaration; + value_binding = value_binding; + constructor_declaration = constructor_declaration; + label_declaration = label_declaration; + cases = cases; + case = case; + location = location; + row_field = row_field ; + object_field = object_field ; + } +let untype_structure ?(mapper=default_mapper) structure = + mapper.structure mapper structure +let untype_signature ?(mapper=default_mapper) signature = + mapper.signature mapper signature -(* this row type enable column processing inside the matrix - - left -> elements not to be processed, - - right -> elements to be processed -*) -type 'a row = {no_ors : 'a list ; ors : 'a list ; active : 'a list} +end +module Parmatch : sig +#1 "parmatch.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) +(* Detection of partial matches and unused match cases. *) +open Asttypes +open Typedtree +open Types -(* -let pretty_row {ors=ors ; no_ors=no_ors; active=active} = - pretty_line ors ; prerr_string " *" ; - pretty_line no_ors ; prerr_string " *" ; - pretty_line active +val pretty_const : constant -> string +val top_pretty : Format.formatter -> pattern -> unit +val pretty_pat : pattern -> unit +val pretty_line : pattern list -> unit +val pretty_matrix : pattern list list -> unit -let pretty_rows rs = - prerr_endline "begin matrix" ; - List.iter - (fun r -> - pretty_row r ; - prerr_endline "") - rs ; - prerr_endline "end matrix" -*) +val omega : pattern +val omegas : int -> pattern list +val omega_list : 'a list -> pattern list +val normalize_pat : pattern -> pattern +val all_record_args : + (Longident.t loc * label_description * pattern) list -> + (Longident.t loc * label_description * pattern) list +val const_compare : constant -> constant -> int -(* Initial build *) -let make_row ps = {ors=[] ; no_ors=[]; active=ps} +val le_pat : pattern -> pattern -> bool +val le_pats : pattern list -> pattern list -> bool -let make_rows pss = List.map make_row pss +(* Exported compatibility functor, abstracted over constructor equality *) +module Compat : + functor + (Constr: sig + val equal : + Types.constructor_description -> + Types.constructor_description -> + bool + end) -> sig + val compat : pattern -> pattern -> bool + val compats : pattern list -> pattern list -> bool + end +exception Empty +val lub : pattern -> pattern -> pattern +val lubs : pattern list -> pattern list -> pattern list -(* Useful to detect and expand or pats inside as pats *) -let rec unalias p = match p.pat_desc with -| Tpat_alias (p,_,_) -> unalias p -| _ -> p +val get_mins : ('a -> 'a -> bool) -> 'a list -> 'a list +(* Those two functions recombine one pattern and its arguments: + For instance: + (_,_)::p1::p2::rem -> (p1, p2)::rem + The second one will replace mutable arguments by '_' +*) +val set_args : pattern -> pattern list -> pattern list +val set_args_erase_mutable : pattern -> pattern list -> pattern list -let is_var p = match (unalias p).pat_desc with -| Tpat_any|Tpat_var _ -> true -| _ -> false +val pat_of_constr : pattern -> constructor_description -> pattern +val complete_constrs : + pattern -> constructor_tag list -> constructor_description list +val ppat_of_type : + Env.t -> type_expr -> + Parsetree.pattern * + (string, constructor_description) Hashtbl.t * + (string, label_description) Hashtbl.t -let is_var_column rs = - List.for_all - (fun r -> match r.active with - | p::_ -> is_var p - | [] -> assert false) - rs +val pressure_variants: Env.t -> pattern list -> unit +val check_partial_gadt: + ((string, constructor_description) Hashtbl.t -> + (string, label_description) Hashtbl.t -> + Parsetree.pattern -> pattern option) -> + Location.t -> case list -> partial +val check_unused: + (bool -> + (string, constructor_description) Hashtbl.t -> + (string, label_description) Hashtbl.t -> + Parsetree.pattern -> pattern option) -> + case list -> unit -(* Standard or-args for left-to-right matching *) -let rec or_args p = match p.pat_desc with -| Tpat_or (p1,p2,_) -> p1,p2 -| Tpat_alias (p,_,_) -> or_args p -| _ -> assert false +(* Irrefutability tests *) +val irrefutable : pattern -> bool -(* Just remove current column *) -let remove r = match r.active with -| _::rem -> {r with active=rem} -| [] -> assert false +(** An inactive pattern is a pattern, matching against which can be duplicated, erased or + delayed without change in observable behavior of the program. Patterns containing + (lazy _) subpatterns or reads of mutable fields are active. *) +val inactive : partial:partial -> pattern -> bool -let remove_column rs = List.map remove rs +(* Ambiguous bindings *) +val check_ambiguous_bindings : case list -> unit -(* Current column has been processed *) -let push_no_or r = match r.active with -| p::rem -> { r with no_ors = p::r.no_ors ; active=rem} -| [] -> assert false +(* The tag used for open polymorphic variant types *) +val some_other_tag : label -let push_or r = match r.active with -| p::rem -> { r with ors = p::r.ors ; active=rem} -| [] -> assert false +end = struct +#1 "parmatch.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -let push_or_column rs = List.map push_or rs -and push_no_or_column rs = List.map push_no_or rs +(* Detection of partial matches and unused match cases. *) -(* Those are adaptations of the previous homonymous functions that - work on the current column, instead of the first column -*) +open Misc +open Asttypes +open Types +open Typedtree -let discr_pat q rs = - discr_pat q (List.map (fun r -> r.active) rs) +(*************************************) +(* Utilities for building patterns *) +(*************************************) -let filter_one q rs = - let rec filter_rec rs = match rs with - | [] -> [] - | r::rem -> - match r.active with - | [] -> assert false - | {pat_desc = Tpat_alias(p,_,_)}::ps -> - filter_rec ({r with active = p::ps}::rem) - | {pat_desc = Tpat_or(p1,p2,_)}::ps -> - filter_rec - ({r with active = p1::ps}:: - {r with active = p2::ps}:: - rem) - | p::ps -> - if simple_match q p then - {r with active=simple_match_args q p @ ps} :: filter_rec rem - else - filter_rec rem in - filter_rec rs +let make_pat desc ty tenv = + {pat_desc = desc; pat_loc = Location.none; pat_extra = []; + pat_type = ty ; pat_env = tenv; + pat_attributes = []; + } +let omega = make_pat Tpat_any Ctype.none Env.empty -(* Back to normal matrices *) -let make_vector r = List.rev r.no_ors +let extra_pat = + make_pat + (Tpat_var (Ident.create "+", mknoloc "+")) + Ctype.none Env.empty -let make_matrix rs = List.map make_vector rs +let rec omegas i = + if i <= 0 then [] else omega :: omegas (i-1) +let omega_list l = List.map (fun _ -> omega) l -(* Standard union on answers *) -let union_res r1 r2 = match r1, r2 with -| (Unused,_) -| (_, Unused) -> Unused -| Used,_ -> r2 -| _, Used -> r1 -| Upartial u1, Upartial u2 -> Upartial (u1@u2) +let zero = make_pat (Tpat_constant (Const_int 0)) Ctype.none Env.empty -(* propose or pats for expansion *) -let extract_elements qs = - let rec do_rec seen = function - | [] -> [] - | q::rem -> - {no_ors= List.rev_append seen rem @ qs.no_ors ; - ors=[] ; - active = [q]}:: - do_rec (q::seen) rem in - do_rec [] qs.ors +(*******************) +(* Coherence check *) +(*******************) -(* idem for matrices *) -let transpose rs = match rs with -| [] -> assert false -| r::rem -> - let i = List.map (fun x -> [x]) r in - List.fold_left - (List.map2 (fun r x -> x::r)) - i rem +(* For some of the operations we do in this module, we would like (because it + simplifies matters) to assume that patterns appearing on a given column in a + pattern matrix are /coherent/ (think "of the same type"). + Unfortunately that is not always true. -let extract_columns pss qs = match pss with -| [] -> List.map (fun _ -> []) qs.ors -| _ -> - let rows = List.map extract_elements pss in - transpose rows + Consider the following (well-typed) example: + {[ + type _ t = S : string t | U : unit t -(* Core function - The idea is to first look for or patterns (recursive case), then - check or-patterns argument usefulness (terminal case) -*) -let rec simplified_first_usefulness_col = function - | [] -> [] - | row :: rows -> - match row.active with - | [] -> assert false (* the rows are non-empty! *) - | p :: _ -> simplify_head_pat p (simplified_first_usefulness_col rows) + let f (type a) (t1 : a t) (t2 : a t) (a : a) = + match t1, t2, a with + | U, _, () -> () + | _, S, "" -> () + ]} -let rec every_satisfiables pss qs = match qs.active with -| [] -> - (* qs is now partitionned, check usefulness *) - begin match qs.ors with - | [] -> (* no or-patterns *) - if satisfiable (make_matrix pss) (make_vector qs) then - Used - else - Unused - | _ -> (* n or-patterns -> 2n expansions *) - List.fold_right2 - (fun pss qs r -> match r with - | Unused -> Unused - | _ -> - match qs.active with - | [q] -> - let q1,q2 = or_args q in - let r_loc = every_both pss qs q1 q2 in - union_res r r_loc - | _ -> assert false) - (extract_columns pss qs) (extract_elements qs) - Used - end -| q::rem -> - let uq = unalias q in - begin match uq.pat_desc with - | Tpat_any | Tpat_var _ -> - if is_var_column pss then -(* forget about ``all-variable'' columns now *) - every_satisfiables (remove_column pss) (remove qs) - else -(* otherwise this is direct food for satisfiable *) - every_satisfiables (push_no_or_column pss) (push_no_or qs) - | Tpat_or (q1,q2,_) -> - if - q1.pat_loc.Location.loc_ghost && - q2.pat_loc.Location.loc_ghost - then -(* syntactically generated or-pats should not be expanded *) - every_satisfiables (push_no_or_column pss) (push_no_or qs) - else -(* this is a real or-pattern *) - every_satisfiables (push_or_column pss) (push_or qs) - | Tpat_variant (l,_,r) when is_absent l r -> (* Ah Jacques... *) - Unused - | _ -> -(* standard case, filter matrix *) - (* The handling of incoherent matrices is kept in line with - [satisfiable] *) - if not (all_coherent (uq :: simplified_first_usefulness_col pss)) then - Unused - else begin - let q0 = discr_pat q pss in - every_satisfiables - (filter_one q0 pss) - {qs with active=simple_match_args q0 q @ rem} - end - end + Clearly the 3rd column contains incoherent patterns. -(* - This function ``every_both'' performs the usefulness check - of or-pat q1|q2. - The trick is to call every_satisfied twice with - current active columns restricted to q1 and q2, - That way, - - others orpats in qs.ors will not get expanded. - - all matching work performed on qs.no_ors is not performed again. - *) -and every_both pss qs q1 q2 = - let qs1 = {qs with active=[q1]} - and qs2 = {qs with active=[q2]} in - let r1 = every_satisfiables pss qs1 - and r2 = every_satisfiables (if compat q1 q2 then qs1::pss else pss) qs2 in - match r1 with - | Unused -> - begin match r2 with - | Unused -> Unused - | Used -> Upartial [q1] - | Upartial u2 -> Upartial (q1::u2) - end - | Used -> - begin match r2 with - | Unused -> Upartial [q2] - | _ -> r2 - end - | Upartial u1 -> - begin match r2 with - | Unused -> Upartial (u1@[q2]) - | Used -> r1 - | Upartial u2 -> Upartial (u1 @ u2) - end + On the example above, most of the algorithms will explore the pattern matrix + as illustrated by the following tree: + + {v + S + -------> | "" | + U | S, "" | __/ | () | + --------> | _, () | \ ¬ S + | U, _, () | __/ -------> | () | + | _, S, "" | \ + ---------> | S, "" | ----------> | "" | + ¬ U S + v} + where following an edge labelled by a pattern P means "assuming the value I + am matching on is filtered by [P] on the column I am currently looking at, + then the following submatrix is still reachable". + Notice that at any point of that tree, if the first column of a matrix is + incoherent, then the branch leading to it can only be taken if the scrutinee + is ill-typed. + In the example above the only case where we have a matrix with an incoherent + first column is when we consider [t1, t2, a] to be [U, S, ...]. However such + a value would be ill-typed, so we can never actually get there. + Checking the first column at each step of the recursion and making the + concious decision of "aborting" the algorithm whenever the first column + becomes incoherent, allows us to retain the initial assumption in later + stages of the algorithms. -(* le_pat p q means, forall V, V matches q implies V matches p *) -let rec le_pat p q = - match (p.pat_desc, q.pat_desc) with - | (Tpat_var _|Tpat_any),_ -> true - | Tpat_alias(p,_,_), _ -> le_pat p q - | _, Tpat_alias(q,_,_) -> le_pat p q - | Tpat_constant(c1), Tpat_constant(c2) -> const_compare c1 c2 = 0 - | Tpat_construct(_,c1,ps), Tpat_construct(_,c2,qs) -> - Types.equal_tag c1.cstr_tag c2.cstr_tag && le_pats ps qs - | Tpat_variant(l1,Some p1,_), Tpat_variant(l2,Some p2,_) -> - (l1 = l2 && le_pat p1 p2) - | Tpat_variant(l1,None,_r1), Tpat_variant(l2,None,_) -> - l1 = l2 - | Tpat_variant(_,_,_), Tpat_variant(_,_,_) -> false - | Tpat_tuple(ps), Tpat_tuple(qs) -> le_pats ps qs - | Tpat_lazy p, Tpat_lazy q -> le_pat p q - | Tpat_record (l1,_), Tpat_record (l2,_) -> - let ps,qs = records_args l1 l2 in - le_pats ps qs - | Tpat_array(ps), Tpat_array(qs) -> - List.length ps = List.length qs && le_pats ps qs -(* In all other cases, enumeration is performed *) - | _,_ -> not (satisfiable [[p]] [q]) + --- -and le_pats ps qs = - match ps,qs with - p::ps, q::qs -> le_pat p q && le_pats ps qs - | _, _ -> true + N.B. two patterns can be considered coherent even though they might not be of + the same type. -let get_mins le ps = - let rec select_rec r = function - [] -> r - | p::ps -> - if List.exists (fun p0 -> le p0 p) ps - then select_rec r ps - else select_rec (p::r) ps in - select_rec [] (select_rec [] ps) + That's in part because we only care about the "head" of patterns and leave + checking coherence of subpatterns for the next steps of the algorithm: + ('a', 'b') and (1, ()) will be deemed coherent because they are both a tuples + of arity 2 (we'll notice at a later stage the incoherence of 'a' and 1). -(* - lub p q is a pattern that matches all values matched by p and q - may raise Empty, when p and q are not compatible + But also because it can be hard/costly to determine exactly whether two + patterns are of the same type or not (eg. in the example above with _ and S, + but see also the module [Coherence_illustration] in + testsuite/tests/basic-more/robustmatch.ml). + + For the moment our weak, loosely-syntactic, coherence check seems to be + enough and we leave it to each user to consider (and document!) what happens + when an "incoherence" is not detected by this check. *) -let rec lub p q = match p.pat_desc,q.pat_desc with -| Tpat_alias (p,_,_),_ -> lub p q -| _,Tpat_alias (q,_,_) -> lub p q -| (Tpat_any|Tpat_var _),_ -> q -| _,(Tpat_any|Tpat_var _) -> p -| Tpat_or (p1,p2,_),_ -> orlub p1 p2 q -| _,Tpat_or (q1,q2,_) -> orlub q1 q2 p (* Thanks god, lub is commutative *) -| Tpat_constant c1, Tpat_constant c2 when const_compare c1 c2 = 0 -> p -| Tpat_tuple ps, Tpat_tuple qs -> - let rs = lubs ps qs in - make_pat (Tpat_tuple rs) p.pat_type p.pat_env -| Tpat_lazy p, Tpat_lazy q -> - let r = lub p q in - make_pat (Tpat_lazy r) p.pat_type p.pat_env -| Tpat_construct (lid, c1,ps1), Tpat_construct (_,c2,ps2) - when Types.equal_tag c1.cstr_tag c2.cstr_tag -> - let rs = lubs ps1 ps2 in - make_pat (Tpat_construct (lid, c1,rs)) - p.pat_type p.pat_env -| Tpat_variant(l1,Some p1,row), Tpat_variant(l2,Some p2,_) - when l1=l2 -> - let r=lub p1 p2 in - make_pat (Tpat_variant (l1,Some r,row)) p.pat_type p.pat_env -| Tpat_variant (l1,None,_row), Tpat_variant(l2,None,_) - when l1 = l2 -> p -| Tpat_record (l1,closed),Tpat_record (l2,_) -> - let rs = record_lubs l1 l2 in - make_pat (Tpat_record (rs, closed)) p.pat_type p.pat_env -| Tpat_array ps, Tpat_array qs - when List.length ps = List.length qs -> - let rs = lubs ps qs in - make_pat (Tpat_array rs) p.pat_type p.pat_env -| _,_ -> - raise Empty -and orlub p1 p2 q = - try - let r1 = lub p1 q in - try - {q with pat_desc=(Tpat_or (r1,lub p2 q,None))} - with - | Empty -> r1 -with -| Empty -> lub p2 q +let simplify_head_pat p k = + let rec simplify_head_pat p k = + match p.pat_desc with + | Tpat_alias (p,_,_) -> simplify_head_pat p k + | Tpat_var (_,_) -> omega :: k + | Tpat_or (p1,p2,_) -> simplify_head_pat p1 (simplify_head_pat p2 k) + | _ -> p :: k + in simplify_head_pat p k -and record_lubs l1 l2 = - let rec lub_rec l1 l2 = match l1,l2 with - | [],_ -> l2 - | _,[] -> l1 - | (lid1, lbl1,p1)::rem1, (lid2, lbl2,p2)::rem2 -> - if lbl1.lbl_pos < lbl2.lbl_pos then - (lid1, lbl1,p1)::lub_rec rem1 l2 - else if lbl2.lbl_pos < lbl1.lbl_pos then - (lid2, lbl2,p2)::lub_rec l1 rem2 - else - (lid1, lbl1,lub p1 p2)::lub_rec rem1 rem2 in - lub_rec l1 l2 +let rec simplified_first_col = function + | [] -> [] + | [] :: _ -> assert false (* the rows are non-empty! *) + | (p::_) :: rows -> + simplify_head_pat p (simplified_first_col rows) -and lubs ps qs = match ps,qs with -| p::ps, q::qs -> lub p q :: lubs ps qs -| _,_ -> [] +(* Given the simplified first column of a matrix, this function first looks for + a "discriminating" pattern on that column (i.e. a non-omega one) and then + check that every other head pattern in the column is coherent with that one. +*) +let all_coherent column = + let coherent_heads hp1 hp2 = + match hp1.pat_desc, hp2.pat_desc with + | (Tpat_var _ | Tpat_alias _ | Tpat_or _), _ + | _, (Tpat_var _ | Tpat_alias _ | Tpat_or _) -> + assert false + | Tpat_construct (_, c, _), Tpat_construct (_, c', _) -> + c.cstr_consts = c'.cstr_consts + && c.cstr_nonconsts = c'.cstr_nonconsts + | Tpat_constant c1, Tpat_constant c2 -> begin + match c1, c2 with + | Const_char _, Const_char _ + | Const_int _, Const_int _ + | Const_int32 _, Const_int32 _ + | Const_int64 _, Const_int64 _ + | Const_nativeint _, Const_nativeint _ + | Const_float _, Const_float _ + | Const_string _, Const_string _ -> true + | ( Const_char _ + | Const_int _ + | Const_int32 _ + | Const_int64 _ + | Const_nativeint _ + | Const_float _ + | Const_string _), _ -> false + end + | Tpat_tuple l1, Tpat_tuple l2 -> List.length l1 = List.length l2 + | Tpat_record ((_, lbl1, _) :: _, _), Tpat_record ((_, lbl2, _) :: _, _) -> + Array.length lbl1.lbl_all = Array.length lbl2.lbl_all + | Tpat_any, _ + | _, Tpat_any + | Tpat_record ([], _), Tpat_record (_, _) + | Tpat_record (_, _), Tpat_record ([], _) + | Tpat_variant _, Tpat_variant _ + | Tpat_array _, Tpat_array _ + | Tpat_lazy _, Tpat_lazy _ -> true + | _, _ -> false + in + match + List.find (fun head_pat -> + match head_pat.pat_desc with + | Tpat_var _ | Tpat_alias _ | Tpat_or _ -> assert false + | Tpat_any -> false + | _ -> true + ) column + with + | exception Not_found -> + (* only omegas on the column: the column is coherent. *) + true + | discr_pat -> + List.for_all (coherent_heads discr_pat) column +let first_column simplified_matrix = + List.map fst simplified_matrix -(******************************) -(* Exported variant closing *) -(******************************) +(***********************) +(* Compatibility check *) +(***********************) -(* Apply pressure to variants *) +(* Patterns p and q compatible means: + there exists value V that matches both, However.... -let pressure_variants tdefs patl = - let pss = List.map (fun p -> [p;omega]) patl in - ignore (pressure_variants (Some tdefs) pss) + The case of extension types is dubious, as constructor rebind permits + that different constructors are the same (and are thus compatible). -(*****************************) -(* Utilities for diagnostics *) -(*****************************) + Compilation must take this into account, consider: -(* - Build up a working pattern matrix by forgetting - about guarded patterns -*) + type t = .. + type t += A|B + type t += C=A -let rec initial_matrix = function - [] -> [] - | {c_guard=Some _} :: rem -> initial_matrix rem - | {c_guard=None; c_lhs=p} :: rem -> [p] :: initial_matrix rem + let f x y = match x,y with + | true,A -> '1' + | _,C -> '2' + | false,A -> '3' + | _,_ -> '_' -(******************************************) -(* Look for a row that matches some value *) -(******************************************) + As C is bound to A the value of f false A is '2' (and not '3' as it would + be in the absence of rebinding). -(* - Useful for seeing if the example of - non-matched value can indeed be matched - (by a guarded clause) -*) + Not considering rebinding, patterns "false,A" and "_,C" are incompatible + and the compiler can swap the second and third clause, resulting in the + (more efficiently compiled) matching + match x,y with + | true,A -> '1' + | false,A -> '3' + | _,C -> '2' + | _,_ -> '_' + This is not correct: when C is bound to A, "f false A" returns '2' (not '3') -exception NoGuard -let rec initial_all no_guard = function - | [] -> - if no_guard then - raise NoGuard - else - [] - | {c_lhs=pat; c_guard; _} :: rem -> - ([pat], pat.pat_loc) :: initial_all (no_guard && c_guard = None) rem + However, diagnostics do not take constructor rebinding into account. + Notice, that due to module abstraction constructor rebinding is hidden. + module X : sig type t = .. type t += A|B end = struct + type t = .. + type t += A + type t += B=A + end -let rec do_filter_var = function - | (_::ps,loc)::rem -> (ps,loc)::do_filter_var rem - | _ -> [] + open X -let do_filter_one q pss = - let rec filter_rec = function - | ({pat_desc = Tpat_alias(p,_,_)}::ps,loc)::pss -> - filter_rec ((p::ps,loc)::pss) - | ({pat_desc = Tpat_or(p1,p2,_)}::ps,loc)::pss -> - filter_rec ((p1::ps,loc)::(p2::ps,loc)::pss) - | (p::ps,loc)::pss -> - if simple_match q p - then (simple_match_args q p @ ps, loc) :: filter_rec pss - else filter_rec pss - | _ -> [] in - filter_rec pss + let f x = match x with + | A -> '1' + | B -> '2' + | _ -> '_' -let rec do_match pss qs = match qs with -| [] -> - begin match pss with - | ([],loc)::_ -> Some loc - | _ -> None - end -| q::qs -> match q with - | {pat_desc = Tpat_or (q1,q2,_)} -> - begin match do_match pss (q1::qs) with - | None -> do_match pss (q2::qs) - | r -> r - end - | {pat_desc = Tpat_any} -> - do_match (do_filter_var pss) qs - | _ -> - let q0 = normalize_pat q in - (* [pss] will (or won't) match [q0 :: qs] regardless of the coherence of - its first column. *) - do_match (do_filter_one q0 pss) (simple_match_args q0 q @ qs) + The second clause above will NOT (and cannot) be flagged as useless. + Finally, there are two compatibility fonction + compat p q ---> 'syntactic compatibility, used for diagnostics. + may_compat p q ---> a safe approximation of possible compat, + for compilation -let check_partial_all v casel = - try - let pss = initial_all true casel in - do_match pss [v] - with - | NoGuard -> None +*) -(************************) -(* Exhaustiveness check *) -(************************) -(* conversion from Typedtree.pattern to Parsetree.pattern list *) -module Conv = struct - open Parsetree - let mkpat desc = Ast_helper.Pat.mk desc +let is_absent tag row = Btype.row_field tag !row = Rabsent - let name_counter = ref 0 - let fresh name = - let current = !name_counter in - name_counter := !name_counter + 1; - "#$" ^ name ^ string_of_int current +let is_absent_pat p = match p.pat_desc with +| Tpat_variant (tag, _, row) -> is_absent tag row +| _ -> false - let conv typed = - let constrs = Hashtbl.create 7 in - let labels = Hashtbl.create 7 in - let rec loop pat = - match pat.pat_desc with - Tpat_or (pa,pb,_) -> - mkpat (Ppat_or (loop pa, loop pb)) - | Tpat_var (_, ({txt="*extension*"} as nm)) -> (* PR#7330 *) - mkpat (Ppat_var nm) - | Tpat_any - | Tpat_var _ -> - mkpat Ppat_any - | Tpat_constant c -> - mkpat (Ppat_constant (Untypeast.constant c)) - | Tpat_alias (p,_,_) -> loop p - | Tpat_tuple lst -> - mkpat (Ppat_tuple (List.map loop lst)) - | Tpat_construct (cstr_lid, cstr, lst) -> - let id = fresh cstr.cstr_name in - let lid = { cstr_lid with txt = Longident.Lident id } in - Hashtbl.add constrs id cstr; - let arg = - match List.map loop lst with - | [] -> None - | [p] -> Some p - | lst -> Some (mkpat (Ppat_tuple lst)) - in - mkpat (Ppat_construct(lid, arg)) - | Tpat_variant(label,p_opt,_row_desc) -> - let arg = Misc.may_map loop p_opt in - mkpat (Ppat_variant(label, arg)) - | Tpat_record (subpatterns, _closed_flag) -> - let fields = - List.map - (fun (_, lbl, p) -> - let id = fresh lbl.lbl_name in - Hashtbl.add labels id lbl; - (mknoloc (Longident.Lident id), loop p)) - subpatterns - in - mkpat (Ppat_record (fields, Open)) - | Tpat_array lst -> - mkpat (Ppat_array (List.map loop lst)) - | Tpat_lazy p -> - mkpat (Ppat_lazy (loop p)) - in - let ps = loop typed in - (ps, constrs, labels) -end +let const_compare x y = + match x,y with + | Const_float f1, Const_float f2 -> + Pervasives.compare (float_of_string f1) (float_of_string f2) + | Const_string (s1, _), Const_string (s2, _) -> + String.compare s1 s2 + | _, _ -> Pervasives.compare x y +let records_args l1 l2 = + (* Invariant: fields are already sorted by Typecore.type_label_a_list *) + let rec combine r1 r2 l1 l2 = match l1,l2 with + | [],[] -> List.rev r1, List.rev r2 + | [],(_,_,p2)::rem2 -> combine (omega::r1) (p2::r2) [] rem2 + | (_,_,p1)::rem1,[] -> combine (p1::r1) (omega::r2) rem1 [] + | (_,lbl1,p1)::rem1, ( _,lbl2,p2)::rem2 -> + if lbl1.lbl_pos < lbl2.lbl_pos then + combine (p1::r1) (omega::r2) rem1 l2 + else if lbl1.lbl_pos > lbl2.lbl_pos then + combine (omega::r1) (p2::r2) l1 rem2 + else (* same label on both sides *) + combine (p1::r1) (p2::r2) rem1 rem2 in + combine [] [] l1 l2 -(* Whether the counter-example contains an extension pattern *) -let contains_extension pat = - let r = ref false in - let rec loop = function - {pat_desc=Tpat_var (_, {txt="*extension*"})} -> - r := true - | p -> Typedtree.iter_pattern_desc loop p.pat_desc - in loop pat; !r -(* Build an untyped or-pattern from its expected type *) -let ppat_of_type env ty = - match pats_of_type env ty with - [{pat_desc = Tpat_any}] -> - (Conv.mkpat Parsetree.Ppat_any, Hashtbl.create 0, Hashtbl.create 0) - | pats -> - Conv.conv (orify_many pats) -let do_check_partial ?pred exhaust loc casel pss = match pss with -| [] -> - (* - This can occur - - For empty matches generated by ocamlp4 (no warning) - - when all patterns have guards (then, casel <> []) - (specific warning) - Then match MUST be considered non-exhaustive, - otherwise compilation of PM is broken. - *) - begin match casel with - | [] -> () - | _ -> - if Warnings.is_active Warnings.All_clauses_guarded then - Location.prerr_warning loc Warnings.All_clauses_guarded - end ; - Partial -| ps::_ -> - begin match exhaust None pss (List.length ps) with - | Rnone -> Total - | Rsome [u] -> - let v = - match pred with - | Some pred -> - let (pattern,constrs,labels) = Conv.conv u in - let u' = pred constrs labels pattern in - (* pretty_pat u; - begin match u' with - None -> prerr_endline ": impossible" - | Some _ -> prerr_endline ": possible" - end; *) - u' - | None -> Some u - in - begin match v with - None -> Total - | Some v -> - if Warnings.is_active (Warnings.Partial_match "") then begin - let errmsg = - try - let buf = Buffer.create 16 in - let fmt = formatter_of_buffer buf in - top_pretty fmt v; - begin match check_partial_all v casel with - | None -> () - | Some _ -> - (* This is 'Some loc', where loc is the location of - a possibly matching clause. - Forget about loc, because printing two locations - is a pain in the top-level *) - Buffer.add_string buf - "\n(However, some guarded clause may match this value.)" - end; - if contains_extension v then - Buffer.add_string buf - "\nMatching over values of extensible variant types \ - (the *extension* above)\n\ - must include a wild card pattern in order to be exhaustive." - ; - Buffer.contents buf - with _ -> - "" - in - Location.prerr_warning loc (Warnings.Partial_match errmsg) - end; - Partial - end - | _ -> - fatal_error "Parmatch.check_partial" - end +module Compat + (Constr:sig + val equal : + Types.constructor_description -> + Types.constructor_description -> + bool + end) = struct -(* -let do_check_partial_normal loc casel pss = - do_check_partial exhaust loc casel pss - *) + let rec compat p q = match p.pat_desc,q.pat_desc with +(* Variables match any value *) + | ((Tpat_any|Tpat_var _),_) + | (_,(Tpat_any|Tpat_var _)) -> true +(* Structural induction *) + | Tpat_alias (p,_,_),_ -> compat p q + | _,Tpat_alias (q,_,_) -> compat p q + | Tpat_or (p1,p2,_),_ -> + (compat p1 q || compat p2 q) + | _,Tpat_or (q1,q2,_) -> + (compat p q1 || compat p q2) +(* Constructors, with special case for extension *) + | Tpat_construct (_, c1,ps1), Tpat_construct (_, c2,ps2) -> + Constr.equal c1 c2 && compats ps1 ps2 +(* More standard stuff *) + | Tpat_variant(l1,op1, _), Tpat_variant(l2,op2,_) -> + l1=l2 && ocompat op1 op2 + | Tpat_constant c1, Tpat_constant c2 -> + const_compare c1 c2 = 0 + | Tpat_tuple ps, Tpat_tuple qs -> compats ps qs + | Tpat_lazy p, Tpat_lazy q -> compat p q + | Tpat_record (l1,_),Tpat_record (l2,_) -> + let ps,qs = records_args l1 l2 in + compats ps qs + | Tpat_array ps, Tpat_array qs -> + List.length ps = List.length qs && + compats ps qs + | _,_ -> false -let do_check_partial_gadt pred loc casel pss = - do_check_partial ~pred exhaust_gadt loc casel pss + and ocompat op oq = match op,oq with + | None,None -> true + | Some p,Some q -> compat p q + | (None,Some _)|(Some _,None) -> false + and compats ps qs = match ps,qs with + | [], [] -> true + | p::ps, q::qs -> compat p q && compats ps qs + | _,_ -> false +end -(*****************) -(* Fragile check *) -(*****************) +module SyntacticCompat = + Compat + (struct + let equal c1 c2 = Types.equal_tag c1.cstr_tag c2.cstr_tag + end) -(* Collect all data types in a pattern *) +let compat = SyntacticCompat.compat +and compats = SyntacticCompat.compats -let rec add_path path = function - | [] -> [path] - | x::rem as paths -> - if Path.same path x then paths - else x::add_path path rem +(* Due to (potential) rebinding, two extension constructors + of the same arity type may equal *) -let extendable_path path = - not - (Path.same path Predef.path_bool || - Path.same path Predef.path_list || - Path.same path Predef.path_unit || - Path.same path Predef.path_option) +exception Empty (* Empty pattern *) -let rec collect_paths_from_pat r p = match p.pat_desc with -| Tpat_construct(_, {cstr_tag=(Cstr_constant _|Cstr_block _|Cstr_unboxed)},ps) - -> - let path = get_type_path p.pat_type p.pat_env in - List.fold_left - collect_paths_from_pat - (if extendable_path path then add_path path r else r) - ps -| Tpat_any|Tpat_var _|Tpat_constant _| Tpat_variant (_,None,_) -> r -| Tpat_tuple ps | Tpat_array ps -| Tpat_construct (_, {cstr_tag=Cstr_extension _}, ps)-> - List.fold_left collect_paths_from_pat r ps -| Tpat_record (lps,_) -> - List.fold_left - (fun r (_, _, p) -> collect_paths_from_pat r p) - r lps -| Tpat_variant (_, Some p, _) | Tpat_alias (p,_,_) -> collect_paths_from_pat r p -| Tpat_or (p1,p2,_) -> - collect_paths_from_pat (collect_paths_from_pat r p1) p2 -| Tpat_lazy p - -> - collect_paths_from_pat r p +(****************************************) +(* Utilities for retrieving type paths *) +(****************************************) +(* May need a clean copy, cf. PR#4745 *) +let clean_copy ty = + if ty.level = Btype.generic_level then ty + else Subst.type_expr Subst.identity ty -(* - Actual fragile check - 1. Collect data types in the patterns of the match. - 2. One exhaustivity check per datatype, considering that - the type is extended. -*) +let get_type_path ty tenv = + let ty = Ctype.repr (Ctype.expand_head tenv (clean_copy ty)) in + match ty.desc with + | Tconstr (path,_,_) -> path + | _ -> fatal_error "Parmatch.get_type_path" -let do_check_fragile_param exhaust loc casel pss = - let exts = - List.fold_left - (fun r c -> collect_paths_from_pat r c.c_lhs) - [] casel in - match exts with - | [] -> () - | _ -> match pss with - | [] -> () - | ps::_ -> - List.iter - (fun ext -> - match exhaust (Some ext) pss (List.length ps) with - | Rnone -> - Location.prerr_warning - loc - (Warnings.Fragile_match (Path.name ext)) - | Rsome _ -> ()) - exts +(*************************************) +(* Values as patterns pretty printer *) +(*************************************) -(*let do_check_fragile_normal = do_check_fragile_param exhaust*) -let do_check_fragile_gadt = do_check_fragile_param exhaust_gadt +open Format +;; -(********************************) -(* Exported unused clause check *) -(********************************) +let is_cons = function +| {cstr_name = "::"} -> true +| _ -> false -let check_unused pred casel = - if Warnings.is_active Warnings.Unused_match - || List.exists (fun c -> c.c_rhs.exp_desc = Texp_unreachable) casel then - let rec do_rec pref = function - | [] -> () - | {c_lhs=q; c_guard; c_rhs} :: rem -> - let qs = [q] in - begin try - let pss = - get_mins le_pats (List.filter (compats qs) pref) in - (* First look for redundant or partially redundant patterns *) - let r = every_satisfiables (make_rows pss) (make_row qs) in - let refute = (c_rhs.exp_desc = Texp_unreachable) in - (* Do not warn for unused [pat -> .] *) - if r = Unused && refute then () else - let r = - (* Do not refine if there are no other lines *) - let skip = - r = Unused || (not refute && pref = []) || - not(refute || Warnings.is_active Warnings.Unreachable_case) in - if skip then r else - (* Then look for empty patterns *) - let sfs = satisfiables pss qs in - if sfs = [] then Unused else - let sfs = - List.map (function [u] -> u | _ -> assert false) sfs in - let u = orify_many sfs in - (*Format.eprintf "%a@." pretty_val u;*) - let (pattern,constrs,labels) = Conv.conv u in - let pattern = {pattern with Parsetree.ppat_loc = q.pat_loc} in - match pred refute constrs labels pattern with - None when not refute -> - Location.prerr_warning q.pat_loc Warnings.Unreachable_case; - Used - | _ -> r - in - match r with - | Unused -> - Location.prerr_warning - q.pat_loc Warnings.Unused_match - | Upartial ps -> - List.iter - (fun p -> - Location.prerr_warning - p.pat_loc Warnings.Unused_pat) - ps - | Used -> () - with Empty | Not_found | NoGuard -> assert false - end ; +let pretty_const c = match c with +| Const_int i -> Printf.sprintf "%d" i +| Const_char c -> Printf.sprintf "%C" c +| Const_string (s, _) -> Printf.sprintf "%S" s +| Const_float f -> Printf.sprintf "%s" f +| Const_int32 i -> Printf.sprintf "%ldl" i +| Const_int64 i -> Printf.sprintf "%LdL" i +| Const_nativeint i -> Printf.sprintf "%ndn" i - if c_guard <> None then - do_rec pref rem - else - do_rec ([q]::pref) rem in +let rec pretty_val ppf v = + match v.pat_extra with + (cstr, _loc, _attrs) :: rem -> + begin match cstr with + | Tpat_unpack -> + fprintf ppf "@[(module %a)@]" pretty_val { v with pat_extra = rem } + | Tpat_constraint _ -> + fprintf ppf "@[(%a : _)@]" pretty_val { v with pat_extra = rem } + | Tpat_type _ -> + fprintf ppf "@[(# %a)@]" pretty_val { v with pat_extra = rem } + | Tpat_open _ -> + fprintf ppf "@[(# %a)@]" pretty_val { v with pat_extra = rem } + end + | [] -> + match v.pat_desc with + | Tpat_any -> fprintf ppf "_" + | Tpat_var (x,_) -> fprintf ppf "%s" (Ident.name x) + | Tpat_constant c -> fprintf ppf "%s" (pretty_const c) + | Tpat_tuple vs -> + fprintf ppf "@[(%a)@]" (pretty_vals ",") vs + | Tpat_construct (_, cstr, []) -> + fprintf ppf "%s" cstr.cstr_name + | Tpat_construct (_, cstr, [w]) -> + fprintf ppf "@[<2>%s@ %a@]" cstr.cstr_name pretty_arg w + | Tpat_construct (_, cstr, vs) -> + let name = cstr.cstr_name in + begin match (name, vs) with + ("::", [v1;v2]) -> + fprintf ppf "@[%a::@,%a@]" pretty_car v1 pretty_cdr v2 + | _ -> + fprintf ppf "@[<2>%s@ @[(%a)@]@]" name (pretty_vals ",") vs + end + | Tpat_variant (l, None, _) -> + fprintf ppf "`%s" l + | Tpat_variant (l, Some w, _) -> + fprintf ppf "@[<2>`%s@ %a@]" l pretty_arg w + | Tpat_record (lvs,_) -> + let filtered_lvs = List.filter + (function + | (_,_,{pat_desc=Tpat_any}) -> false (* do not show lbl=_ *) + | _ -> true) lvs in + begin match filtered_lvs with + | [] -> fprintf ppf "_" + | (_, lbl, _) :: q -> + let elision_mark ppf = + (* we assume that there is no label repetitions here *) + if Array.length lbl.lbl_all > 1 + List.length q then + fprintf ppf ";@ _@ " + else () in + fprintf ppf "@[{%a%t}@]" + pretty_lvals filtered_lvs elision_mark + end + | Tpat_array vs -> + fprintf ppf "@[[| %a |]@]" (pretty_vals " ;") vs + | Tpat_lazy v -> + fprintf ppf "@[<2>lazy@ %a@]" pretty_arg v + | Tpat_alias (v, x,_) -> + fprintf ppf "@[(%a@ as %a)@]" pretty_val v Ident.print x + | Tpat_or (v,w,_) -> + fprintf ppf "@[(%a|@,%a)@]" pretty_or v pretty_or w - do_rec [] casel +and pretty_car ppf v = match v.pat_desc with +| Tpat_construct (_,cstr, [_ ; _]) + when is_cons cstr -> + fprintf ppf "(%a)" pretty_val v +| _ -> pretty_val ppf v -(*********************************) -(* Exported irrefutability tests *) -(*********************************) +and pretty_cdr ppf v = match v.pat_desc with +| Tpat_construct (_,cstr, [v1 ; v2]) + when is_cons cstr -> + fprintf ppf "%a::@,%a" pretty_car v1 pretty_cdr v2 +| _ -> pretty_val ppf v -let irrefutable pat = le_pat pat omega +and pretty_arg ppf v = match v.pat_desc with +| Tpat_construct (_,_,_::_) +| Tpat_variant (_, Some _, _) -> fprintf ppf "(%a)" pretty_val v +| _ -> pretty_val ppf v -let inactive ~partial pat = - match partial with - | Partial -> false - | Total -> begin - let rec loop pat = - match pat.pat_desc with - | Tpat_lazy _ | Tpat_array _ -> - false - | Tpat_any | Tpat_var _ | Tpat_variant (_, None, _) -> - true - | Tpat_constant c -> begin - match c with - | Const_string _ -> Config.safe_string - | Const_int _ | Const_char _ | Const_float _ - | Const_int32 _ | Const_int64 _ | Const_nativeint _ -> true - end - | Tpat_tuple ps | Tpat_construct (_, _, ps) -> - List.for_all (fun p -> loop p) ps - | Tpat_alias (p,_,_) | Tpat_variant (_, Some p, _) -> - loop p - | Tpat_record (ldps,_) -> - List.for_all - (fun (_, lbl, p) -> lbl.lbl_mut = Immutable && loop p) - ldps - | Tpat_or (p,q,_) -> - loop p && loop q - in - loop pat - end +and pretty_or ppf v = match v.pat_desc with +| Tpat_or (v,w,_) -> + fprintf ppf "%a|@,%a" pretty_or v pretty_or w +| _ -> pretty_val ppf v +and pretty_vals sep ppf = function + | [] -> () + | [v] -> pretty_val ppf v + | v::vs -> + fprintf ppf "%a%s@ %a" pretty_val v sep (pretty_vals sep) vs +and pretty_lvals ppf = function + | [] -> () + | [_,lbl,v] -> + fprintf ppf "%s=%a" lbl.lbl_name pretty_val v + | (_, lbl,v)::rest -> + fprintf ppf "%s=%a;@ %a" + lbl.lbl_name pretty_val v pretty_lvals rest +let top_pretty ppf v = + fprintf ppf "@[%a@]@?" pretty_val v +let pretty_pat p = + top_pretty Format.str_formatter p ; + prerr_string (Format.flush_str_formatter ()) +type matrix = pattern list list -(*********************************) -(* Exported exhaustiveness check *) -(*********************************) +let pretty_line ps = + List.iter + (fun p -> + top_pretty Format.str_formatter p ; + prerr_string " <" ; + prerr_string (Format.flush_str_formatter ()) ; + prerr_string ">") + ps -(* - Fragile check is performed when required and - on exhaustive matches only. -*) +let pretty_matrix (pss : matrix) = + prerr_endline "begin matrix" ; + List.iter + (fun ps -> + pretty_line ps ; + prerr_endline "") + pss ; + prerr_endline "end matrix" -let check_partial_param do_check_partial do_check_fragile loc casel = - let pss = initial_matrix casel in - let pss = get_mins le_pats pss in - let total = do_check_partial loc casel pss in - if - total = Total && Warnings.is_active (Warnings.Fragile_match "") - then begin - do_check_fragile loc casel pss - end ; - total -(*let check_partial = - check_partial_param - do_check_partial_normal - do_check_fragile_normal*) +(****************************) +(* Utilities for matching *) +(****************************) -let check_partial_gadt pred loc casel = - check_partial_param (do_check_partial_gadt pred) - do_check_fragile_gadt loc casel +(* Check top matching *) +let simple_match p1 p2 = + match p1.pat_desc, p2.pat_desc with + | Tpat_construct(_, c1, _), Tpat_construct(_, c2, _) -> + Types.equal_tag c1.cstr_tag c2.cstr_tag + | Tpat_variant(l1, _, _), Tpat_variant(l2, _, _) -> + l1 = l2 + | Tpat_constant(c1), Tpat_constant(c2) -> const_compare c1 c2 = 0 + | Tpat_lazy _, Tpat_lazy _ -> true + | Tpat_record _ , Tpat_record _ -> true + | Tpat_tuple p1s, Tpat_tuple p2s + | Tpat_array p1s, Tpat_array p2s -> List.length p1s = List.length p2s + | _, (Tpat_any | Tpat_var(_)) -> true + | _, _ -> false -(*************************************) -(* Ambiguous variable in or-patterns *) -(*************************************) -(* Specification: ambiguous variables in or-patterns. - The semantics of or-patterns in OCaml is specified with - a left-to-right bias: a value [v] matches the pattern [p | q] if it - matches [p] or [q], but if it matches both, the environment - captured by the match is the environment captured by [p], never the - one captured by [q]. +(* extract record fields as a whole *) +let record_arg p = match p.pat_desc with +| Tpat_any -> [] +| Tpat_record (args,_) -> args +| _ -> fatal_error "Parmatch.as_record" - While this property is generally well-understood, one specific case - where users expect a different semantics is when a pattern is - followed by a when-guard: [| p when g -> e]. Consider for example: - | ((Const x, _) | (_, Const x)) when is_neutral x -> branch +(* Raise Not_found when pos is not present in arg *) +let get_field pos arg = + let _,_, p = List.find (fun (_,lbl,_) -> pos = lbl.lbl_pos) arg in + p - The semantics is clear: match the scrutinee against the pattern, if - it matches, test the guard, and if the guard passes, take the - branch. +let extract_fields omegas arg = + List.map + (fun (_,lbl,_) -> + try + get_field lbl.lbl_pos arg + with Not_found -> omega) + omegas - However, consider the input [(Const a, Const b)], where [a] fails - the test [is_neutral f], while [b] passes the test [is_neutral - b]. With the left-to-right semantics, the clause above is *not* - taken by its input: matching [(Const a, Const b)] against the - or-pattern succeeds in the left branch, it returns the environment - [x -> a], and then the guard [is_neutral a] is tested and fails, - the branch is not taken. Most users, however, intuitively expect - that any pair that has one side passing the test will take the - branch. They assume it is equivalent to the following: +let all_record_args lbls = match lbls with +| (_,{lbl_all=lbl_all},_)::_ -> + let t = + Array.map + (fun lbl -> mknoloc (Longident.Lident "?temp?"), lbl,omega) + lbl_all in + List.iter + (fun ((_, lbl,_) as x) -> t.(lbl.lbl_pos) <- x) + lbls ; + Array.to_list t +| _ -> fatal_error "Parmatch.all_record_args" - | (Const x, _) when is_neutral x -> branch - | (_, Const x) when is_neutral x -> branch - while it is not. +(* Build argument list when p2 >= p1, where p1 is a simple pattern *) +let rec simple_match_args p1 p2 = match p2.pat_desc with +| Tpat_alias (p2,_,_) -> simple_match_args p1 p2 +| Tpat_construct(_, _, args) -> args +| Tpat_variant(_, Some arg, _) -> [arg] +| Tpat_tuple(args) -> args +| Tpat_record(args,_) -> extract_fields (record_arg p1) args +| Tpat_array(args) -> args +| Tpat_lazy arg -> [arg] +| (Tpat_any | Tpat_var(_)) -> + begin match p1.pat_desc with + Tpat_construct(_, _,args) -> omega_list args + | Tpat_variant(_, Some _, _) -> [omega] + | Tpat_tuple(args) -> omega_list args + | Tpat_record(args,_) -> omega_list args + | Tpat_array(args) -> omega_list args + | Tpat_lazy _ -> [omega] + | _ -> [] + end +| _ -> [] - The code below is dedicated to finding these confusing cases: the - cases where a guard uses "ambiguous" variables, that are bound to - different parts of the scrutinees by different sides of - a or-pattern. In other words, it finds the cases where the - specified left-to-right semantics is not equivalent to - a non-deterministic semantics (any branch can be taken) relatively - to a specific guard. +(* + Normalize a pattern -> + all arguments are omega (simple pattern) and no more variables *) -module IdSet = Set.Make(Ident) - -let pattern_vars p = IdSet.of_list (Typedtree.pat_bound_idents p) - -(* Row for ambiguous variable search, - unseen is the traditional pattern row, - seen is a list of position bindings *) +let rec normalize_pat q = match q.pat_desc with + | Tpat_any | Tpat_constant _ -> q + | Tpat_var _ -> make_pat Tpat_any q.pat_type q.pat_env + | Tpat_alias (p,_,_) -> normalize_pat p + | Tpat_tuple (args) -> + make_pat (Tpat_tuple (omega_list args)) q.pat_type q.pat_env + | Tpat_construct (lid, c,args) -> + make_pat + (Tpat_construct (lid, c,omega_list args)) + q.pat_type q.pat_env + | Tpat_variant (l, arg, row) -> + make_pat (Tpat_variant (l, may_map (fun _ -> omega) arg, row)) + q.pat_type q.pat_env + | Tpat_array (args) -> + make_pat (Tpat_array (omega_list args)) q.pat_type q.pat_env + | Tpat_record (largs, closed) -> + make_pat + (Tpat_record (List.map (fun (lid,lbl,_) -> + lid, lbl,omega) largs, closed)) + q.pat_type q.pat_env + | Tpat_lazy _ -> + make_pat (Tpat_lazy omega) q.pat_type q.pat_env + | Tpat_or _ -> fatal_error "Parmatch.normalize_pat" -type amb_row = { unseen : pattern list ; seen : IdSet.t list; } +(* + Build normalized (cf. supra) discriminating pattern, + in the non-data type case +*) +let discr_pat q pss = -(* Push binding variables now *) + let rec acc_pat acc pss = match pss with + ({pat_desc = Tpat_alias (p,_,_)}::ps)::pss -> + acc_pat acc ((p::ps)::pss) + | ({pat_desc = Tpat_or (p1,p2,_)}::ps)::pss -> + acc_pat acc ((p1::ps)::(p2::ps)::pss) + | ({pat_desc = (Tpat_any | Tpat_var _)}::_)::pss -> + acc_pat acc pss + | (({pat_desc = Tpat_tuple _} as p)::_)::_ -> normalize_pat p + | (({pat_desc = Tpat_lazy _} as p)::_)::_ -> normalize_pat p + | (({pat_desc = Tpat_record (largs,closed)} as p)::_)::pss -> + let new_omegas = + List.fold_right + (fun (lid, lbl,_) r -> + try + let _ = get_field lbl.lbl_pos r in + r + with Not_found -> + (lid, lbl,omega)::r) + largs (record_arg acc) + in + acc_pat + (make_pat (Tpat_record (new_omegas, closed)) p.pat_type p.pat_env) + pss + | _ -> acc in -let rec do_push r p ps seen k = match p.pat_desc with -| Tpat_alias (p,x,_) -> do_push (IdSet.add x r) p ps seen k -| Tpat_var (x,_) -> - (omega,{ unseen = ps; seen=IdSet.add x r::seen; })::k -| Tpat_or (p1,p2,_) -> - do_push r p1 ps seen (do_push r p2 ps seen k) -| _ -> - (p,{ unseen = ps; seen = r::seen; })::k + match normalize_pat q with + | {pat_desc= (Tpat_any | Tpat_record _)} as q -> acc_pat q pss + | q -> q -let rec push_vars = function - | [] -> [] - | { unseen = [] }::_ -> assert false - | { unseen = p::ps; seen; }::rem -> - do_push IdSet.empty p ps seen (push_vars rem) +(* + In case a matching value is found, set actual arguments + of the matching pattern. +*) -let collect_stable = function - | [] -> assert false - | { seen=xss; _}::rem -> - let rec c_rec xss = function - | [] -> xss - | {seen=yss; _}::rem -> - let xss = List.map2 IdSet.inter xss yss in - c_rec xss rem in - let inters = c_rec xss rem in - List.fold_left IdSet.union IdSet.empty inters +let rec read_args xs r = match xs,r with +| [],_ -> [],r +| _::xs, arg::rest -> + let args,rest = read_args xs rest in + arg::args,rest +| _,_ -> + fatal_error "Parmatch.read_args" +let do_set_args erase_mutable q r = match q with +| {pat_desc = Tpat_tuple omegas} -> + let args,rest = read_args omegas r in + make_pat (Tpat_tuple args) q.pat_type q.pat_env::rest +| {pat_desc = Tpat_record (omegas,closed)} -> + let args,rest = read_args omegas r in + make_pat + (Tpat_record + (List.map2 (fun (lid, lbl,_) arg -> + if + erase_mutable && + (match lbl.lbl_mut with + | Mutable -> true | Immutable -> false) + then + lid, lbl, omega + else + lid, lbl, arg) + omegas args, closed)) + q.pat_type q.pat_env:: + rest +| {pat_desc = Tpat_construct (lid, c,omegas)} -> + let args,rest = read_args omegas r in + make_pat + (Tpat_construct (lid, c,args)) + q.pat_type q.pat_env:: + rest +| {pat_desc = Tpat_variant (l, omega, row)} -> + let arg, rest = + match omega, r with + Some _, a::r -> Some a, r + | None, r -> None, r + | _ -> assert false + in + make_pat + (Tpat_variant (l, arg, row)) q.pat_type q.pat_env:: + rest +| {pat_desc = Tpat_lazy _omega} -> + begin match r with + arg::rest -> + make_pat (Tpat_lazy arg) q.pat_type q.pat_env::rest + | _ -> fatal_error "Parmatch.do_set_args (lazy)" + end +| {pat_desc = Tpat_array omegas} -> + let args,rest = read_args omegas r in + make_pat + (Tpat_array args) q.pat_type q.pat_env:: + rest +| {pat_desc=Tpat_constant _|Tpat_any} -> + q::r (* case any is used in matching.ml *) +| _ -> fatal_error "Parmatch.set_args" -(*********************************************) -(* Filtering utilities for our specific rows *) -(*********************************************) +let set_args q r = do_set_args false q r +and set_args_erase_mutable q r = do_set_args true q r -(* Take a pattern matrix as a list (rows) of lists (columns) of patterns - | p1, p2, .., pn - | q1, q2, .., qn - | r1, r2, .., rn - | ... +(* filter pss according to pattern q *) +let filter_one q pss = + let rec filter_rec = function + ({pat_desc = Tpat_alias(p,_,_)}::ps)::pss -> + filter_rec ((p::ps)::pss) + | ({pat_desc = Tpat_or(p1,p2,_)}::ps)::pss -> + filter_rec ((p1::ps)::(p2::ps)::pss) + | (p::ps)::pss -> + if simple_match q p + then (simple_match_args q p @ ps) :: filter_rec pss + else filter_rec pss + | _ -> [] in + filter_rec pss - We split this matrix into a list of sub-matrices, one for each head - constructor appearing in the leftmost column. For each row whose - left column starts with a head constructor, remove this head - column, prepend one column for each argument of the constructor, - and add the resulting row in the sub-matrix corresponding to this - head constructor. +(* + Filter pss in the ``extra case''. This applies : + - According to an extra constructor (datatype case, non-complete signature). + - According to anything (all-variables case). +*) +let filter_extra pss = + let rec filter_rec = function + ({pat_desc = Tpat_alias(p,_,_)}::ps)::pss -> + filter_rec ((p::ps)::pss) + | ({pat_desc = Tpat_or(p1,p2,_)}::ps)::pss -> + filter_rec ((p1::ps)::(p2::ps)::pss) + | ({pat_desc = (Tpat_any | Tpat_var(_))} :: qs) :: pss -> + qs :: filter_rec pss + | _::pss -> filter_rec pss + | [] -> [] in + filter_rec pss - Rows whose left column is omega (the Any pattern _) may match any - head constructor, so they are added to all groups. +(* + Pattern p0 is the discriminating pattern, + returns [(q0,pss0) ; ... ; (qn,pssn)] + where the qi's are simple patterns and the pssi's are + matched matrices. - The list of sub-matrices is represented as a list of pair - (head constructor, submatrix) + NOTES + * (qi,[]) is impossible. + * In the case when matching is useless (all-variable case), + returns [] *) -let filter_all = - (* the head constructor (as a pattern with omega arguments) of - a pattern *) - let discr_head pat = - match pat.pat_desc with - | Tpat_record (lbls, closed) -> - (* a partial record pattern { f1 = p1; f2 = p2; _ } - needs to be expanded, otherwise matching against this head - would drop the pattern arguments for non-mentioned fields *) - let lbls = all_record_args lbls in - normalize_pat { pat with pat_desc = Tpat_record (lbls, closed) } - | _ -> normalize_pat pat - in - - (* insert a row of head [p] and rest [r] into the right group *) - let rec insert p r env = match env with - | [] -> - (* if no group matched this row, it has a head constructor that - was never seen before; add a new sub-matrix for this head *) - let p0 = discr_head p in - [p0,[{ r with unseen = simple_match_args p0 p @ r.unseen }]] - | (q0,rs) as bd::env -> - if simple_match q0 p then begin - let r = { r with unseen = simple_match_args q0 p@r.unseen; } in - (q0,r::rs)::env - end - else bd::insert p r env in +let filter_all pat0 pss = - (* insert a row of head omega into all groups *) - let insert_omega r env = - List.map - (fun (q0,rs) -> - let r = - { r with unseen = simple_match_args q0 omega @ r.unseen; } in - (q0,r::rs)) - env - in + let rec insert q qs env = + match env with + [] -> + let q0 = normalize_pat q in + [q0, [simple_match_args q0 q @ qs]] + | ((q0,pss) as c)::env -> + if simple_match q0 q + then (q0, ((simple_match_args q0 q @ qs) :: pss)) :: env + else c :: insert q qs env in let rec filter_rec env = function - | [] -> env - | ({pat_desc=(Tpat_var _|Tpat_alias _|Tpat_or _)},_)::_ -> assert false - | ({pat_desc=Tpat_any}, _)::rs -> filter_rec env rs - | (p,r)::rs -> filter_rec (insert p r env) rs in - - let rec filter_omega env = function - | [] -> env - | ({pat_desc=(Tpat_var _|Tpat_alias _|Tpat_or _)},_)::_ -> assert false - | ({pat_desc=Tpat_any},r)::rs -> filter_omega (insert_omega r env) rs - | _::rs -> filter_omega env rs in + ({pat_desc = Tpat_alias(p,_,_)}::ps)::pss -> + filter_rec env ((p::ps)::pss) + | ({pat_desc = Tpat_or(p1,p2,_)}::ps)::pss -> + filter_rec env ((p1::ps)::(p2::ps)::pss) + | ({pat_desc = (Tpat_any | Tpat_var(_))}::_)::pss -> + filter_rec env pss + | (p::ps)::pss -> + filter_rec (insert p ps env) pss + | _ -> env - fun rs -> - (* first insert the rows with head constructors, - to get the definitive list of groups *) - let env = filter_rec [] rs in - (* then add the omega rows to all groups *) - filter_omega env rs + and filter_omega env = function + ({pat_desc = Tpat_alias(p,_,_)}::ps)::pss -> + filter_omega env ((p::ps)::pss) + | ({pat_desc = Tpat_or(p1,p2,_)}::ps)::pss -> + filter_omega env ((p1::ps)::(p2::ps)::pss) + | ({pat_desc = (Tpat_any | Tpat_var(_))}::ps)::pss -> + filter_omega + (List.map (fun (q,qss) -> (q,(simple_match_args q omega @ ps) :: qss)) + env) + pss + | _::pss -> filter_omega env pss + | [] -> env in -(* Compute stable bindings *) + filter_omega + (filter_rec + (match pat0.pat_desc with + (Tpat_record(_) | Tpat_tuple(_) | Tpat_lazy(_)) -> [pat0,[]] + | _ -> []) + pss) + pss -let rec do_stable rs = match rs with -| [] -> assert false (* No empty matrix *) -| { unseen=[]; _ }::_ -> - collect_stable rs -| _ -> - let rs = push_vars rs in - if not (all_coherent (first_column rs)) then begin - (* If the first column is incoherent, then all the variables of this - matrix are stable. *) - List.fold_left (fun acc (_, { seen; _ }) -> - List.fold_left IdSet.union acc seen - ) IdSet.empty rs - end else begin - (* If the column is ill-typed but deemed coherent, we might spuriously - warn about some variables being unstable. - As sad as that might be, the warning can be silenced by splitting the - or-pattern... *) - match filter_all rs with - | [] -> - do_stable (List.map snd rs) - | (_,rs)::env -> - List.fold_left - (fun xs (_,rs) -> IdSet.inter xs (do_stable rs)) - (do_stable rs) env - end +(* Variant related functions *) -let stable p = do_stable [{unseen=[p]; seen=[];}] +let rec set_last a = function + [] -> [] + | [_] -> [a] + | x::l -> x :: set_last a l +(* mark constructor lines for failure when they are incomplete *) +let rec mark_partial = function + ({pat_desc = Tpat_alias(p,_,_)}::ps)::pss -> + mark_partial ((p::ps)::pss) + | ({pat_desc = Tpat_or(p1,p2,_)}::ps)::pss -> + mark_partial ((p1::ps)::(p2::ps)::pss) + | ({pat_desc = (Tpat_any | Tpat_var(_))} :: _ as ps) :: pss -> + ps :: mark_partial pss + | ps::pss -> + (set_last zero ps) :: mark_partial pss + | [] -> [] -(* All identifier paths that appear in an expression that occurs - as a clause right hand side or guard. +let close_variant env row = + let row = Btype.row_repr row in + let nm = + List.fold_left + (fun nm (_tag,f) -> + match Btype.row_field_repr f with + | Reither(_, _, false, e) -> + (* m=false means that this tag is not explicitly matched *) + Btype.set_row_field e Rabsent; + None + | Rabsent | Reither (_, _, true, _) | Rpresent _ -> nm) + row.row_name row.row_fields in + if not row.row_closed || nm != row.row_name then begin + (* this unification cannot fail *) + Ctype.unify env row.row_more + (Btype.newgenty + (Tvariant {row with row_fields = []; row_more = Btype.newgenvar(); + row_closed = true; row_name = nm})) + end - The function is rather complex due to the compilation of - unpack patterns by introducing code in rhs expressions - and **guards**. +let row_of_pat pat = + match Ctype.expand_head pat.pat_env pat.pat_type with + {desc = Tvariant row} -> Btype.row_repr row + | _ -> assert false - For pattern (module M:S) -> e the code is - let module M_mod = unpack M .. in e +(* + Check whether the first column of env makes up a complete signature or + not. +*) - Hence M is "free" in e iff M_mod is free in e. +let full_match closing env = match env with +| ({pat_desc = Tpat_construct(_,c,_)},_) :: _ -> + if c.cstr_consts < 0 then false (* extensions *) + else List.length env = c.cstr_consts + c.cstr_nonconsts +| ({pat_desc = Tpat_variant _} as p,_) :: _ -> + let fields = + List.map + (function ({pat_desc = Tpat_variant (tag, _, _)}, _) -> tag + | _ -> assert false) + env + in + let row = row_of_pat p in + if closing && not (Btype.row_fixed row) then + (* closing=true, we are considering the variant as closed *) + List.for_all + (fun (tag,f) -> + match Btype.row_field_repr f with + Rabsent | Reither(_, _, false, _) -> true + | Reither (_, _, true, _) + (* m=true, do not discard matched tags, rather warn *) + | Rpresent _ -> List.mem tag fields) + row.row_fields + else + row.row_closed && + List.for_all + (fun (tag,f) -> + Btype.row_field_repr f = Rabsent || List.mem tag fields) + row.row_fields +| ({pat_desc = Tpat_constant(Const_char _)},_) :: _ -> + List.length env = 256 +| ({pat_desc = Tpat_constant(_)},_) :: _ -> false +| ({pat_desc = Tpat_tuple(_)},_) :: _ -> true +| ({pat_desc = Tpat_record(_)},_) :: _ -> true +| ({pat_desc = Tpat_array(_)},_) :: _ -> false +| ({pat_desc = Tpat_lazy(_)},_) :: _ -> true +| ({pat_desc = (Tpat_any|Tpat_var _|Tpat_alias _|Tpat_or _)},_) :: _ +| [] + -> + assert false - Not doing so will yield excessive warning in - (module (M:S) } ...) when true -> .... - as M is always present in - let module M_mod = unpack M .. in true -*) +(* Written as a non-fragile matching, PR#7451 originated from a fragile matching below. *) +let should_extend ext env = match ext with +| None -> false +| Some ext -> begin match env with + | [] -> assert false + | (p,_)::_ -> + begin match p.pat_desc with + | Tpat_construct + (_, {cstr_tag=(Cstr_constant _|Cstr_block _|Cstr_unboxed)},_) -> + let path = get_type_path p.pat_type p.pat_env in + Path.same path ext + | Tpat_construct + (_, {cstr_tag=(Cstr_extension _)},_) -> false + | Tpat_constant _|Tpat_tuple _|Tpat_variant _ + | Tpat_record _|Tpat_array _ | Tpat_lazy _ + -> false + | Tpat_any|Tpat_var _|Tpat_alias _|Tpat_or _ + -> assert false + end +end -let all_rhs_idents exp = - let ids = ref IdSet.empty in - let module Iterator = TypedtreeIter.MakeIterator(struct - include TypedtreeIter.DefaultIteratorArgument - let enter_expression exp = match exp.exp_desc with - | Texp_ident (path, _lid, _descr) -> - List.iter - (fun id -> ids := IdSet.add id !ids) - (Path.heads path) - | _ -> () +module ConstructorTagHashtbl = Hashtbl.Make( + struct + type t = Types.constructor_tag + let hash = Hashtbl.hash + let equal = Types.equal_tag + end +) -(* Very hackish, detect unpack pattern compilation - and perform "indirect check for them" *) - let is_unpack exp = - List.exists - (fun (attr, _) -> attr.txt = "#modulepat") exp.exp_attributes +(* complement constructor tags *) +let complete_tags nconsts nconstrs tags = + let seen_const = Array.make nconsts false + and seen_constr = Array.make nconstrs false in + List.iter + (function + | Cstr_constant i -> seen_const.(i) <- true + | Cstr_block i -> seen_constr.(i) <- true + | _ -> assert false) + tags ; + let r = ConstructorTagHashtbl.create (nconsts+nconstrs) in + for i = 0 to nconsts-1 do + if not seen_const.(i) then + ConstructorTagHashtbl.add r (Cstr_constant i) () + done ; + for i = 0 to nconstrs-1 do + if not seen_constr.(i) then + ConstructorTagHashtbl.add r (Cstr_block i) () + done ; + r - let leave_expression exp = - if is_unpack exp then begin match exp.exp_desc with - | Texp_letmodule - (id_mod,_, - {mod_desc= - Tmod_unpack ({exp_desc=Texp_ident (Path.Pident id_exp,_,_)},_)}, - _) -> - assert (IdSet.mem id_exp !ids) ; - if not (IdSet.mem id_mod !ids) then begin - ids := IdSet.remove id_exp !ids - end - | _ -> assert false - end - end) in - Iterator.iter_expression exp; - !ids +(* build a pattern from a constructor list *) +let pat_of_constr ex_pat cstr = + {ex_pat with pat_desc = + Tpat_construct (mknoloc (Longident.Lident "?pat_of_constr?"), + cstr, omegas cstr.cstr_arity)} -let check_ambiguous_bindings = - let open Warnings in - let warn0 = Ambiguous_pattern [] in - fun cases -> - if is_active warn0 then - List.iter - (fun case -> match case with - | { c_guard=None ; _} -> () - | { c_lhs=p; c_guard=Some g; _} -> - let all = - IdSet.inter (pattern_vars p) (all_rhs_idents g) in - if not (IdSet.is_empty all) then begin - let st = stable p in - let ambiguous = IdSet.diff all st in - if not (IdSet.is_empty ambiguous) then begin - let pps = IdSet.elements ambiguous |> List.map Ident.name in - let warn = Ambiguous_pattern pps in - Location.prerr_warning p.pat_loc warn - end - end) - cases +let orify x y = make_pat (Tpat_or (x, y, None)) x.pat_type x.pat_env -end -module Ast_iterator : sig -#1 "ast_iterator.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Nicolas Ojeda Bar, LexiFi *) -(* *) -(* Copyright 2012 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let rec orify_many = function +| [] -> assert false +| [x] -> x +| x :: xs -> orify x (orify_many xs) -(** {!iterator} allows to implement AST inspection using open recursion. A - typical mapper would be based on {!default_iterator}, a trivial iterator, - and will fall back on it for handling the syntax it does not modify. *) +let pat_of_constrs ex_pat cstrs = + if cstrs = [] then raise Empty else + orify_many (List.map (pat_of_constr ex_pat) cstrs) -open Parsetree +let pats_of_type ?(always=false) env ty = + let ty' = Ctype.expand_head env ty in + match ty'.desc with + | Tconstr (path, _, _) -> + begin try match (Env.find_type path env).type_kind with + | Type_variant cl when always || List.length cl = 1 || + List.for_all (fun cd -> cd.Types.cd_res <> None) cl -> + let cstrs = fst (Env.find_type_descrs path env) in + List.map (pat_of_constr (make_pat Tpat_any ty env)) cstrs + | Type_record _ -> + let labels = snd (Env.find_type_descrs path env) in + let fields = + List.map (fun ld -> + mknoloc (Longident.Lident "?pat_of_label?"), ld, omega) + labels + in + [make_pat (Tpat_record (fields, Closed)) ty env] + | _ -> [omega] + with Not_found -> [omega] + end + | Ttuple tl -> + [make_pat (Tpat_tuple (omegas (List.length tl))) ty env] + | _ -> [omega] -(** {1 A generic Parsetree iterator} *) +let rec get_variant_constructors env ty = + match (Ctype.repr ty).desc with + | Tconstr (path,_,_) -> begin + try match Env.find_type path env with + | {type_kind=Type_variant _} -> + fst (Env.find_type_descrs path env) + | {type_manifest = Some _} -> + get_variant_constructors env + (Ctype.expand_head_once env (clean_copy ty)) + | _ -> fatal_error "Parmatch.get_variant_constructors" + with Not_found -> + fatal_error "Parmatch.get_variant_constructors" + end + | _ -> fatal_error "Parmatch.get_variant_constructors" -type iterator = { - attribute: iterator -> attribute -> unit; - attributes: iterator -> attribute list -> unit; - case: iterator -> case -> unit; - cases: iterator -> case list -> unit; - class_declaration: iterator -> class_declaration -> unit; - class_description: iterator -> class_description -> unit; - class_expr: iterator -> class_expr -> unit; - class_field: iterator -> class_field -> unit; - class_signature: iterator -> class_signature -> unit; - class_structure: iterator -> class_structure -> unit; - class_type: iterator -> class_type -> unit; - class_type_declaration: iterator -> class_type_declaration -> unit; - class_type_field: iterator -> class_type_field -> unit; - constructor_declaration: iterator -> constructor_declaration -> unit; - expr: iterator -> expression -> unit; - extension: iterator -> extension -> unit; - extension_constructor: iterator -> extension_constructor -> unit; - include_declaration: iterator -> include_declaration -> unit; - include_description: iterator -> include_description -> unit; - label_declaration: iterator -> label_declaration -> unit; - location: iterator -> Location.t -> unit; - module_binding: iterator -> module_binding -> unit; - module_declaration: iterator -> module_declaration -> unit; - module_expr: iterator -> module_expr -> unit; - module_type: iterator -> module_type -> unit; - module_type_declaration: iterator -> module_type_declaration -> unit; - open_description: iterator -> open_description -> unit; - pat: iterator -> pattern -> unit; - payload: iterator -> payload -> unit; - signature: iterator -> signature -> unit; - signature_item: iterator -> signature_item -> unit; - structure: iterator -> structure -> unit; - structure_item: iterator -> structure_item -> unit; - typ: iterator -> core_type -> unit; - type_declaration: iterator -> type_declaration -> unit; - type_extension: iterator -> type_extension -> unit; - type_kind: iterator -> type_kind -> unit; - value_binding: iterator -> value_binding -> unit; - value_description: iterator -> value_description -> unit; - with_constraint: iterator -> with_constraint -> unit; -} -(** A [iterator] record implements one "method" per syntactic category, - using an open recursion style: each method takes as its first - argument the iterator to be applied to children in the syntax - tree. *) +(* Sends back a pattern that complements constructor tags all_tag *) +let complete_constrs p all_tags = + let c = + match p.pat_desc with Tpat_construct (_, c, _) -> c | _ -> assert false in + let not_tags = complete_tags c.cstr_consts c.cstr_nonconsts all_tags in + let constrs = get_variant_constructors p.pat_env c.cstr_res in + let others = + List.filter + (fun cnstr -> ConstructorTagHashtbl.mem not_tags cnstr.cstr_tag) + constrs in + let const, nonconst = + List.partition (fun cnstr -> cnstr.cstr_arity = 0) others in + const @ nonconst -val default_iterator: iterator -(** A default iterator, which implements a "do not do anything" mapping. *) +let build_other_constrs env p = + match p.pat_desc with + Tpat_construct (_, {cstr_tag=Cstr_constant _|Cstr_block _}, _) -> + let get_tag = function + | {pat_desc = Tpat_construct (_,c,_)} -> c.cstr_tag + | _ -> fatal_error "Parmatch.get_tag" in + let all_tags = List.map (fun (p,_) -> get_tag p) env in + pat_of_constrs p (complete_constrs p all_tags) + | _ -> extra_pat -end = struct -#1 "ast_iterator.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Nicolas Ojeda Bar, LexiFi *) -(* *) -(* Copyright 2012 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +(* Auxiliary for build_other *) -(* A generic Parsetree mapping class *) +let build_other_constant proj make first next p env = + let all = List.map (fun (p, _) -> proj p.pat_desc) env in + let rec try_const i = + if List.mem i all + then try_const (next i) + else make_pat (make i) p.pat_type p.pat_env + in try_const first (* -[@@@ocaml.warning "+9"] - (* Ensure that record patterns don't miss any field. *) + Builds a pattern that is incompatible with all patterns in + in the first column of env *) +let some_other_tag = "" -open Parsetree -open Location +let build_other ext env = match env with +| ({pat_desc = Tpat_construct (lid, {cstr_tag=Cstr_extension _},_)},_) :: _ -> + (* let c = {c with cstr_name = "*extension*"} in *) (* PR#7330 *) + make_pat (Tpat_var (Ident.create "*extension*", + {lid with txt="*extension*"})) Ctype.none Env.empty +| ({pat_desc = Tpat_construct _} as p,_) :: _ -> + begin match ext with + | Some ext when Path.same ext (get_type_path p.pat_type p.pat_env) -> + extra_pat + | _ -> + build_other_constrs env p + end +| ({pat_desc = Tpat_variant (_,_,r)} as p,_) :: _ -> + let tags = + List.map + (function ({pat_desc = Tpat_variant (tag, _, _)}, _) -> tag + | _ -> assert false) + env + in + let row = row_of_pat p in + let make_other_pat tag const = + let arg = if const then None else Some omega in + make_pat (Tpat_variant(tag, arg, r)) p.pat_type p.pat_env in + begin match + List.fold_left + (fun others (tag,f) -> + if List.mem tag tags then others else + match Btype.row_field_repr f with + Rabsent (* | Reither _ *) -> others + (* This one is called after erasing pattern info *) + | Reither (c, _, _, _) -> make_other_pat tag c :: others + | Rpresent arg -> make_other_pat tag (arg = None) :: others) + [] row.row_fields + with + [] -> + make_other_pat some_other_tag true + | pat::other_pats -> + List.fold_left + (fun p_res pat -> + make_pat (Tpat_or (pat, p_res, None)) p.pat_type p.pat_env) + pat other_pats + end +| ({pat_desc = Tpat_constant(Const_char _)} as p,_) :: _ -> + let all_chars = + List.map + (fun (p,_) -> match p.pat_desc with + | Tpat_constant (Const_char c) -> c + | _ -> assert false) + env in -type iterator = { - attribute: iterator -> attribute -> unit; - attributes: iterator -> attribute list -> unit; - case: iterator -> case -> unit; - cases: iterator -> case list -> unit; - class_declaration: iterator -> class_declaration -> unit; - class_description: iterator -> class_description -> unit; - class_expr: iterator -> class_expr -> unit; - class_field: iterator -> class_field -> unit; - class_signature: iterator -> class_signature -> unit; - class_structure: iterator -> class_structure -> unit; - class_type: iterator -> class_type -> unit; - class_type_declaration: iterator -> class_type_declaration -> unit; - class_type_field: iterator -> class_type_field -> unit; - constructor_declaration: iterator -> constructor_declaration -> unit; - expr: iterator -> expression -> unit; - extension: iterator -> extension -> unit; - extension_constructor: iterator -> extension_constructor -> unit; - include_declaration: iterator -> include_declaration -> unit; - include_description: iterator -> include_description -> unit; - label_declaration: iterator -> label_declaration -> unit; - location: iterator -> Location.t -> unit; - module_binding: iterator -> module_binding -> unit; - module_declaration: iterator -> module_declaration -> unit; - module_expr: iterator -> module_expr -> unit; - module_type: iterator -> module_type -> unit; - module_type_declaration: iterator -> module_type_declaration -> unit; - open_description: iterator -> open_description -> unit; - pat: iterator -> pattern -> unit; - payload: iterator -> payload -> unit; - signature: iterator -> signature -> unit; - signature_item: iterator -> signature_item -> unit; - structure: iterator -> structure -> unit; - structure_item: iterator -> structure_item -> unit; - typ: iterator -> core_type -> unit; - type_declaration: iterator -> type_declaration -> unit; - type_extension: iterator -> type_extension -> unit; - type_kind: iterator -> type_kind -> unit; - value_binding: iterator -> value_binding -> unit; - value_description: iterator -> value_description -> unit; - with_constraint: iterator -> with_constraint -> unit; -} -(** A [iterator] record implements one "method" per syntactic category, - using an open recursion style: each method takes as its first - argument the iterator to be applied to children in the syntax - tree. *) + let rec find_other i imax = + if i > imax then raise Not_found + else + let ci = Char.chr i in + if List.mem ci all_chars then + find_other (i+1) imax + else + make_pat (Tpat_constant (Const_char ci)) p.pat_type p.pat_env in + let rec try_chars = function + | [] -> omega + | (c1,c2) :: rest -> + try + find_other (Char.code c1) (Char.code c2) + with + | Not_found -> try_chars rest in -let iter_fst f (x, _) = f x -let iter_snd f (_, y) = f y -let iter_tuple f1 f2 (x, y) = f1 x; f2 y -let iter_tuple3 f1 f2 f3 (x, y, z) = f1 x; f2 y; f3 z -let iter_opt f = function None -> () | Some x -> f x + try_chars + [ 'a', 'z' ; 'A', 'Z' ; '0', '9' ; + ' ', '~' ; Char.chr 0 , Char.chr 255] -let iter_loc sub {loc; txt = _} = sub.location sub loc +| ({pat_desc=(Tpat_constant (Const_int _))} as p,_) :: _ -> + build_other_constant + (function Tpat_constant(Const_int i) -> i | _ -> assert false) + (function i -> Tpat_constant(Const_int i)) + 0 succ p env +| ({pat_desc=(Tpat_constant (Const_int32 _))} as p,_) :: _ -> + build_other_constant + (function Tpat_constant(Const_int32 i) -> i | _ -> assert false) + (function i -> Tpat_constant(Const_int32 i)) + 0l Int32.succ p env +| ({pat_desc=(Tpat_constant (Const_int64 _))} as p,_) :: _ -> + build_other_constant + (function Tpat_constant(Const_int64 i) -> i | _ -> assert false) + (function i -> Tpat_constant(Const_int64 i)) + 0L Int64.succ p env +| ({pat_desc=(Tpat_constant (Const_nativeint _))} as p,_) :: _ -> + build_other_constant + (function Tpat_constant(Const_nativeint i) -> i | _ -> assert false) + (function i -> Tpat_constant(Const_nativeint i)) + 0n Nativeint.succ p env +| ({pat_desc=(Tpat_constant (Const_string _))} as p,_) :: _ -> + build_other_constant + (function Tpat_constant(Const_string (s, _)) -> String.length s + | _ -> assert false) + (function i -> Tpat_constant(Const_string(String.make i '*', None))) + 0 succ p env +| ({pat_desc=(Tpat_constant (Const_float _))} as p,_) :: _ -> + build_other_constant + (function Tpat_constant(Const_float f) -> float_of_string f + | _ -> assert false) + (function f -> Tpat_constant(Const_float (string_of_float f))) + 0.0 (fun f -> f +. 1.0) p env -module T = struct - (* Type expressions for the core language *) +| ({pat_desc = Tpat_array _} as p,_)::_ -> + let all_lengths = + List.map + (fun (p,_) -> match p.pat_desc with + | Tpat_array args -> List.length args + | _ -> assert false) + env in + let rec try_arrays l = + if List.mem l all_lengths then try_arrays (l+1) + else + make_pat + (Tpat_array (omegas l)) + p.pat_type p.pat_env in + try_arrays 0 +| [] -> omega +| _ -> omega - let row_field sub = function - | Rtag (_, attrs, _, tl) -> - sub.attributes sub attrs; List.iter (sub.typ sub) tl - | Rinherit t -> sub.typ sub t +(* + Core function : + Is the last row of pattern matrix pss + qs satisfiable ? + That is : + Does there exists at least one value vector, es such that : + 1- for all ps in pss ps # es (ps and es are not compatible) + 2- qs <= es (es matches qs) +*) - let object_field sub = function - | Otag (_, attrs, t) -> - sub.attributes sub attrs; sub.typ sub t - | Oinherit t -> sub.typ sub t +let rec has_instance p = match p.pat_desc with + | Tpat_variant (l,_,r) when is_absent l r -> false + | Tpat_any | Tpat_var _ | Tpat_constant _ | Tpat_variant (_,None,_) -> true + | Tpat_alias (p,_,_) | Tpat_variant (_,Some p,_) -> has_instance p + | Tpat_or (p1,p2,_) -> has_instance p1 || has_instance p2 + | Tpat_construct (_,_,ps) | Tpat_tuple ps | Tpat_array ps -> + has_instances ps + | Tpat_record (lps,_) -> has_instances (List.map (fun (_,_,x) -> x) lps) + | Tpat_lazy p + -> has_instance p - let iter sub {ptyp_desc = desc; ptyp_loc = loc; ptyp_attributes = attrs} = - sub.location sub loc; - sub.attributes sub attrs; - match desc with - | Ptyp_any - | Ptyp_var _ -> () - | Ptyp_arrow (_lab, t1, t2) -> - sub.typ sub t1; sub.typ sub t2 - | Ptyp_tuple tyl -> List.iter (sub.typ sub) tyl - | Ptyp_constr (lid, tl) -> - iter_loc sub lid; List.iter (sub.typ sub) tl - | Ptyp_object (ol, _o) -> - List.iter (object_field sub) ol - | Ptyp_class (lid, tl) -> - iter_loc sub lid; List.iter (sub.typ sub) tl - | Ptyp_alias (t, _) -> sub.typ sub t - | Ptyp_variant (rl, _b, _ll) -> - List.iter (row_field sub) rl - | Ptyp_poly (_, t) -> sub.typ sub t - | Ptyp_package (lid, l) -> - iter_loc sub lid; - List.iter (iter_tuple (iter_loc sub) (sub.typ sub)) l - | Ptyp_extension x -> sub.extension sub x - let iter_type_declaration sub - {ptype_name; ptype_params; ptype_cstrs; - ptype_kind; - ptype_private = _; - ptype_manifest; - ptype_attributes; - ptype_loc} = - iter_loc sub ptype_name; - List.iter (iter_fst (sub.typ sub)) ptype_params; - List.iter - (iter_tuple3 (sub.typ sub) (sub.typ sub) (sub.location sub)) - ptype_cstrs; - sub.type_kind sub ptype_kind; - iter_opt (sub.typ sub) ptype_manifest; - sub.location sub ptype_loc; - sub.attributes sub ptype_attributes +and has_instances = function + | [] -> true + | q::rem -> has_instance q && has_instances rem - let iter_type_kind sub = function - | Ptype_abstract -> () - | Ptype_variant l -> - List.iter (sub.constructor_declaration sub) l - | Ptype_record l -> List.iter (sub.label_declaration sub) l - | Ptype_open -> () +(* + In two places in the following function, we check the coherence of the first + column of (pss + qs). + If it is incoherent, then we exit early saying that (pss + qs) is not + satisfiable (which is equivalent to saying "oh, we shouldn't have considered + that branch, no good result came come from here"). - let iter_constructor_arguments sub = function - | Pcstr_tuple l -> List.iter (sub.typ sub) l - | Pcstr_record l -> - List.iter (sub.label_declaration sub) l + But what happens if we have a coherent but ill-typed column? + - we might end up returning [false], which is equivalent to noticing the + incompatibility: clearly this is fine. + - if we end up returning [true] then we're saying that [qs] is useful while + it is not. This is sad but not the end of the world, we're just allowing dead + code to survive. +*) +let rec satisfiable pss qs = match pss with +| [] -> has_instances qs +| _ -> + match qs with + | [] -> false + | {pat_desc = Tpat_or(q1,q2,_)}::qs -> + satisfiable pss (q1::qs) || satisfiable pss (q2::qs) + | {pat_desc = Tpat_alias(q,_,_)}::qs -> + satisfiable pss (q::qs) + | {pat_desc = (Tpat_any | Tpat_var(_))}::qs -> + if not (all_coherent (simplified_first_col pss)) then + false + else begin + let q0 = discr_pat omega pss in + match filter_all q0 pss with + (* first column of pss is made of variables only *) + | [] -> satisfiable (filter_extra pss) qs + | constrs -> + if full_match false constrs then + List.exists + (fun (p,pss) -> + not (is_absent_pat p) && + satisfiable pss (simple_match_args p omega @ qs)) + constrs + else + satisfiable (filter_extra pss) qs + end + | {pat_desc=Tpat_variant (l,_,r)}::_ when is_absent l r -> false + | q::qs -> + if not (all_coherent (q :: simplified_first_col pss)) then + false + else begin + let q0 = discr_pat q pss in + satisfiable (filter_one q0 pss) (simple_match_args q0 q @ qs) + end - let iter_type_extension sub - {ptyext_path; ptyext_params; - ptyext_constructors; - ptyext_private = _; - ptyext_attributes} = - iter_loc sub ptyext_path; - List.iter (sub.extension_constructor sub) ptyext_constructors; - List.iter (iter_fst (sub.typ sub)) ptyext_params; - sub.attributes sub ptyext_attributes +(* Also return the remaining cases, to enable GADT handling - let iter_extension_constructor_kind sub = function - Pext_decl(ctl, cto) -> - iter_constructor_arguments sub ctl; iter_opt (sub.typ sub) cto - | Pext_rebind li -> - iter_loc sub li + For considerations regarding the coherence check, see the comment on + [satisfiable] above. *) +let rec satisfiables pss qs = match pss with +| [] -> if has_instances qs then [qs] else [] +| _ -> + match qs with + | [] -> [] + | {pat_desc = Tpat_or(q1,q2,_)}::qs -> + satisfiables pss (q1::qs) @ satisfiables pss (q2::qs) + | {pat_desc = Tpat_alias(q,_,_)}::qs -> + satisfiables pss (q::qs) + | {pat_desc = (Tpat_any | Tpat_var(_))}::qs -> + if not (all_coherent (simplified_first_col pss)) then + [] + else begin + let q0 = discr_pat omega pss in + let wild p = + List.map (fun qs -> p::qs) (satisfiables (filter_extra pss) qs) in + match filter_all q0 pss with + (* first column of pss is made of variables only *) + | [] -> + wild omega + | (p,_)::_ as constrs -> + let for_constrs () = + List.flatten ( + List.map + (fun (p,pss) -> + if is_absent_pat p then [] else + List.map (set_args p) + (satisfiables pss (simple_match_args p omega @ qs))) + constrs ) + in + if full_match false constrs then for_constrs () else + match p.pat_desc with + Tpat_construct _ -> + (* activate this code for checking non-gadt constructors *) + wild (build_other_constrs constrs p) @ for_constrs () + | _ -> + wild omega + end + | {pat_desc=Tpat_variant (l,_,r)}::_ when is_absent l r -> [] + | q::qs -> + if not (all_coherent (q :: simplified_first_col pss)) then + [] + else begin + let q0 = discr_pat q pss in + List.map (set_args q0) + (satisfiables (filter_one q0 pss) (simple_match_args q0 q @ qs)) + end - let iter_extension_constructor sub - {pext_name; - pext_kind; - pext_loc; - pext_attributes} = - iter_loc sub pext_name; - iter_extension_constructor_kind sub pext_kind; - sub.location sub pext_loc; - sub.attributes sub pext_attributes +(* + Now another satisfiable function that additionally + supplies an example of a matching value. + + This function should be called for exhaustiveness check only. +*) + +type 'a result = + | Rnone (* No matching value *) + | Rsome of 'a (* This matching value *) + +(* +let rec try_many f = function + | [] -> Rnone + | (p,pss)::rest -> + match f (p,pss) with + | Rnone -> try_many f rest + | r -> r +*) + +let rappend r1 r2 = + match r1, r2 with + | Rnone, _ -> r2 + | _, Rnone -> r1 + | Rsome l1, Rsome l2 -> Rsome (l1 @ l2) -end +let rec try_many_gadt f = function + | [] -> Rnone + | (p,pss)::rest -> + rappend (f (p, pss)) (try_many_gadt f rest) -module CT = struct - (* Type expressions for the class language *) +(* +let rec exhaust ext pss n = match pss with +| [] -> Rsome (omegas n) +| []::_ -> Rnone +| pss -> + let q0 = discr_pat omega pss in + begin match filter_all q0 pss with + (* first column of pss is made of variables only *) + | [] -> + begin match exhaust ext (filter_extra pss) (n-1) with + | Rsome r -> Rsome (q0::r) + | r -> r + end + | constrs -> + let try_non_omega (p,pss) = + if is_absent_pat p then + Rnone + else + match + exhaust + ext pss (List.length (simple_match_args p omega) + n - 1) + with + | Rsome r -> Rsome (set_args p r) + | r -> r in + if + full_match true false constrs && not (should_extend ext constrs) + then + try_many try_non_omega constrs + else + (* + D = filter_extra pss is the default matrix + as it is included in pss, one can avoid + recursive calls on specialized matrices, + Essentially : + * D exhaustive => pss exhaustive + * D non-exhaustive => we have a non-filtered value + *) + let r = exhaust ext (filter_extra pss) (n-1) in + match r with + | Rnone -> Rnone + | Rsome r -> + try + Rsome (build_other ext constrs::r) + with + (* cannot occur, since constructors don't make a full signature *) + | Empty -> fatal_error "Parmatch.exhaust" + end - let iter sub {pcty_loc = loc; pcty_desc = desc; pcty_attributes = attrs} = - sub.location sub loc; - sub.attributes sub attrs; - match desc with - | Pcty_constr (lid, tys) -> - iter_loc sub lid; List.iter (sub.typ sub) tys - | Pcty_signature x -> sub.class_signature sub x - | Pcty_arrow (_lab, t, ct) -> - sub.typ sub t; sub.class_type sub ct - | Pcty_extension x -> sub.extension sub x - | Pcty_open (_ovf, lid, e) -> - iter_loc sub lid; sub.class_type sub e +let combinations f lst lst' = + let rec iter2 x = + function + [] -> [] + | y :: ys -> + f x y :: iter2 x ys + in + let rec iter = + function + [] -> [] + | x :: xs -> iter2 x lst' @ iter xs + in + iter lst +*) +(* +let print_pat pat = + let rec string_of_pat pat = + match pat.pat_desc with + Tpat_var _ -> "v" + | Tpat_any -> "_" + | Tpat_alias (p, x) -> Printf.sprintf "(%s) as ?" (string_of_pat p) + | Tpat_constant n -> "0" + | Tpat_construct (_, lid, _) -> + Printf.sprintf "%s" (String.concat "." (Longident.flatten lid.txt)) + | Tpat_lazy p -> + Printf.sprintf "(lazy %s)" (string_of_pat p) + | Tpat_or (p1,p2,_) -> + Printf.sprintf "(%s | %s)" (string_of_pat p1) (string_of_pat p2) + | Tpat_tuple list -> + Printf.sprintf "(%s)" (String.concat "," (List.map string_of_pat list)) + | Tpat_variant (_, _, _) -> "variant" + | Tpat_record (_, _) -> "record" + | Tpat_array _ -> "array" + in + Printf.fprintf stderr "PAT[%s]\n%!" (string_of_pat pat) +*) - let iter_field sub {pctf_desc = desc; pctf_loc = loc; pctf_attributes = attrs} - = - sub.location sub loc; - sub.attributes sub attrs; - match desc with - | Pctf_inherit ct -> sub.class_type sub ct - | Pctf_val (_s, _m, _v, t) -> sub.typ sub t - | Pctf_method (_s, _p, _v, t) -> sub.typ sub t - | Pctf_constraint (t1, t2) -> - sub.typ sub t1; sub.typ sub t2 - | Pctf_attribute x -> sub.attribute sub x - | Pctf_extension x -> sub.extension sub x +(* strictly more powerful than exhaust; however, exhaust + was kept for backwards compatibility *) +let rec exhaust_gadt (ext:Path.t option) pss n = match pss with +| [] -> Rsome [omegas n] +| []::_ -> Rnone +| pss -> + if not (all_coherent (simplified_first_col pss)) then + (* We're considering an ill-typed branch, we won't actually be able to + produce a well typed value taking that branch. *) + Rnone + else begin + (* Assuming the first column is ill-typed but considered coherent, we + might end up producing an ill-typed witness of non-exhaustivity + corresponding to the current branch. - let iter_signature sub {pcsig_self; pcsig_fields} = - sub.typ sub pcsig_self; - List.iter (sub.class_type_field sub) pcsig_fields -end + If [exhaust] has been called by [do_check_partial], then the witnesses + produced get typechecked and the ill-typed ones are discarded. -module MT = struct - (* Type expressions for the module language *) + If [exhaust] has been called by [do_check_fragile], then it is possible + we might fail to warn the user that the matching is fragile. See for + example testsuite/tests/warnings/w04_failure.ml. *) + let q0 = discr_pat omega pss in + match filter_all q0 pss with + (* first column of pss is made of variables only *) + | [] -> + begin match exhaust_gadt ext (filter_extra pss) (n-1) with + | Rsome r -> Rsome (List.map (fun row -> q0::row) r) + | r -> r + end + | constrs -> + let try_non_omega (p,pss) = + if is_absent_pat p then + Rnone + else + match + exhaust_gadt + ext pss (List.length (simple_match_args p omega) + n - 1) + with + | Rsome r -> Rsome (List.map (fun row -> (set_args p row)) r) + | r -> r in + let before = try_many_gadt try_non_omega constrs in + if + full_match false constrs && not (should_extend ext constrs) + then + before + else + (* + D = filter_extra pss is the default matrix + as it is included in pss, one can avoid + recursive calls on specialized matrices, + Essentially : + * D exhaustive => pss exhaustive + * D non-exhaustive => we have a non-filtered value + *) + let r = exhaust_gadt ext (filter_extra pss) (n-1) in + match r with + | Rnone -> before + | Rsome r -> + try + let p = build_other ext constrs in + let dug = List.map (fun tail -> p :: tail) r in + match before with + | Rnone -> Rsome dug + | Rsome x -> Rsome (x @ dug) + with + (* cannot occur, since constructors don't make a full signature *) + | Empty -> fatal_error "Parmatch.exhaust" + end - let iter sub {pmty_desc = desc; pmty_loc = loc; pmty_attributes = attrs} = - sub.location sub loc; - sub.attributes sub attrs; - match desc with - | Pmty_ident s -> iter_loc sub s - | Pmty_alias s -> iter_loc sub s - | Pmty_signature sg -> sub.signature sub sg - | Pmty_functor (s, mt1, mt2) -> - iter_loc sub s; - iter_opt (sub.module_type sub) mt1; - sub.module_type sub mt2 - | Pmty_with (mt, l) -> - sub.module_type sub mt; - List.iter (sub.with_constraint sub) l - | Pmty_typeof me -> sub.module_expr sub me - | Pmty_extension x -> sub.extension sub x +let exhaust_gadt ext pss n = + let ret = exhaust_gadt ext pss n in + match ret with + Rnone -> Rnone + | Rsome lst -> + (* The following line is needed to compile stdlib/printf.ml *) + if lst = [] then Rsome (omegas n) else + let singletons = + List.map + (function + [x] -> x + | _ -> assert false) + lst + in + Rsome [orify_many singletons] - let iter_with_constraint sub = function - | Pwith_type (lid, d) -> - iter_loc sub lid; sub.type_declaration sub d - | Pwith_module (lid, lid2) -> - iter_loc sub lid; iter_loc sub lid2 - | Pwith_typesubst (lid, d) -> - iter_loc sub lid; sub.type_declaration sub d - | Pwith_modsubst (s, lid) -> - iter_loc sub s; iter_loc sub lid +(* + Another exhaustiveness check, enforcing variant typing. + Note that it does not check exact exhaustiveness, but whether a + matching could be made exhaustive by closing all variant types. + When this is true of all other columns, the current column is left + open (even if it means that the whole matching is not exhaustive as + a result). + When this is false for the matrix minus the current column, and the + current column is composed of variant tags, we close the variant + (even if it doesn't help in making the matching exhaustive). +*) - let iter_signature_item sub {psig_desc = desc; psig_loc = loc} = - sub.location sub loc; - match desc with - | Psig_value vd -> sub.value_description sub vd - | Psig_type (_rf, l) -> List.iter (sub.type_declaration sub) l - | Psig_typext te -> sub.type_extension sub te - | Psig_exception ed -> sub.extension_constructor sub ed - | Psig_module x -> sub.module_declaration sub x - | Psig_recmodule l -> - List.iter (sub.module_declaration sub) l - | Psig_modtype x -> sub.module_type_declaration sub x - | Psig_open x -> sub.open_description sub x - | Psig_include x -> sub.include_description sub x - | Psig_class l -> List.iter (sub.class_description sub) l - | Psig_class_type l -> - List.iter (sub.class_type_declaration sub) l - | Psig_extension (x, attrs) -> - sub.extension sub x; sub.attributes sub attrs - | Psig_attribute x -> sub.attribute sub x -end +let rec pressure_variants tdefs = function + | [] -> false + | []::_ -> true + | pss -> + if not (all_coherent (simplified_first_col pss)) then + true + else begin + let q0 = discr_pat omega pss in + match filter_all q0 pss with + [] -> pressure_variants tdefs (filter_extra pss) + | constrs -> + let rec try_non_omega = function + (_p,pss) :: rem -> + let ok = pressure_variants tdefs pss in + try_non_omega rem && ok + | [] -> true + in + if full_match (tdefs=None) constrs then + try_non_omega constrs + else if tdefs = None then + pressure_variants None (filter_extra pss) + else + let full = full_match true constrs in + let ok = + if full then try_non_omega constrs + else try_non_omega (filter_all q0 (mark_partial pss)) + in + begin match constrs, tdefs with + ({pat_desc=Tpat_variant _} as p,_):: _, Some env -> + let row = row_of_pat p in + if Btype.row_fixed row + || pressure_variants None (filter_extra pss) then () + else close_variant env row + | _ -> () + end; + ok + end -module M = struct - (* Value expressions for the module language *) +(* Yet another satisfiable function *) - let iter sub {pmod_loc = loc; pmod_desc = desc; pmod_attributes = attrs} = - sub.location sub loc; - sub.attributes sub attrs; - match desc with - | Pmod_ident x -> iter_loc sub x - | Pmod_structure str -> sub.structure sub str - | Pmod_functor (arg, arg_ty, body) -> - iter_loc sub arg; - iter_opt (sub.module_type sub) arg_ty; - sub.module_expr sub body - | Pmod_apply (m1, m2) -> - sub.module_expr sub m1; sub.module_expr sub m2 - | Pmod_constraint (m, mty) -> - sub.module_expr sub m; sub.module_type sub mty - | Pmod_unpack e -> sub.expr sub e - | Pmod_extension x -> sub.extension sub x +(* + This time every_satisfiable pss qs checks the + utility of every expansion of qs. + Expansion means expansion of or-patterns inside qs +*) - let iter_structure_item sub {pstr_loc = loc; pstr_desc = desc} = - sub.location sub loc; - match desc with - | Pstr_eval (x, attrs) -> - sub.expr sub x; sub.attributes sub attrs - | Pstr_value (_r, vbs) -> List.iter (sub.value_binding sub) vbs - | Pstr_primitive vd -> sub.value_description sub vd - | Pstr_type (_rf, l) -> List.iter (sub.type_declaration sub) l - | Pstr_typext te -> sub.type_extension sub te - | Pstr_exception ed -> sub.extension_constructor sub ed - | Pstr_module x -> sub.module_binding sub x - | Pstr_recmodule l -> List.iter (sub.module_binding sub) l - | Pstr_modtype x -> sub.module_type_declaration sub x - | Pstr_open x -> sub.open_description sub x - | Pstr_class l -> List.iter (sub.class_declaration sub) l - | Pstr_class_type l -> - List.iter (sub.class_type_declaration sub) l - | Pstr_include x -> sub.include_declaration sub x - | Pstr_extension (x, attrs) -> - sub.extension sub x; sub.attributes sub attrs - | Pstr_attribute x -> sub.attribute sub x -end +type answer = + | Used (* Useful pattern *) + | Unused (* Useless pattern *) + | Upartial of Typedtree.pattern list (* Mixed, with list of useless ones *) -module E = struct - (* Value expressions for the core language *) - let iter sub {pexp_loc = loc; pexp_desc = desc; pexp_attributes = attrs} = - sub.location sub loc; - sub.attributes sub attrs; - match desc with - | Pexp_ident x -> iter_loc sub x - | Pexp_constant _ -> () - | Pexp_let (_r, vbs, e) -> - List.iter (sub.value_binding sub) vbs; - sub.expr sub e - | Pexp_fun (_lab, def, p, e) -> - iter_opt (sub.expr sub) def; - sub.pat sub p; - sub.expr sub e - | Pexp_function pel -> sub.cases sub pel - | Pexp_apply (e, l) -> - sub.expr sub e; List.iter (iter_snd (sub.expr sub)) l - | Pexp_match (e, pel) -> - sub.expr sub e; sub.cases sub pel - | Pexp_try (e, pel) -> sub.expr sub e; sub.cases sub pel - | Pexp_tuple el -> List.iter (sub.expr sub) el - | Pexp_construct (lid, arg) -> - iter_loc sub lid; iter_opt (sub.expr sub) arg - | Pexp_variant (_lab, eo) -> - iter_opt (sub.expr sub) eo - | Pexp_record (l, eo) -> - List.iter (iter_tuple (iter_loc sub) (sub.expr sub)) l; - iter_opt (sub.expr sub) eo - | Pexp_field (e, lid) -> - sub.expr sub e; iter_loc sub lid - | Pexp_setfield (e1, lid, e2) -> - sub.expr sub e1; iter_loc sub lid; - sub.expr sub e2 - | Pexp_array el -> List.iter (sub.expr sub) el - | Pexp_ifthenelse (e1, e2, e3) -> - sub.expr sub e1; sub.expr sub e2; - iter_opt (sub.expr sub) e3 - | Pexp_sequence (e1, e2) -> - sub.expr sub e1; sub.expr sub e2 - | Pexp_while (e1, e2) -> - sub.expr sub e1; sub.expr sub e2 - | Pexp_for (p, e1, e2, _d, e3) -> - sub.pat sub p; sub.expr sub e1; sub.expr sub e2; - sub.expr sub e3 - | Pexp_coerce (e, t1, t2) -> - sub.expr sub e; iter_opt (sub.typ sub) t1; - sub.typ sub t2 - | Pexp_constraint (e, t) -> - sub.expr sub e; sub.typ sub t - | Pexp_send (e, _s) -> sub.expr sub e - | Pexp_new lid -> iter_loc sub lid - | Pexp_setinstvar (s, e) -> - iter_loc sub s; sub.expr sub e - | Pexp_override sel -> - List.iter (iter_tuple (iter_loc sub) (sub.expr sub)) sel - | Pexp_letmodule (s, me, e) -> - iter_loc sub s; sub.module_expr sub me; - sub.expr sub e - | Pexp_letexception (cd, e) -> - sub.extension_constructor sub cd; - sub.expr sub e - | Pexp_assert e -> sub.expr sub e - | Pexp_lazy e -> sub.expr sub e - | Pexp_poly (e, t) -> - sub.expr sub e; iter_opt (sub.typ sub) t - | Pexp_object cls -> sub.class_structure sub cls - | Pexp_newtype (_s, e) -> sub.expr sub e - | Pexp_pack me -> sub.module_expr sub me - | Pexp_open (_ovf, lid, e) -> - iter_loc sub lid; sub.expr sub e - | Pexp_extension x -> sub.extension sub x - | Pexp_unreachable -> () -end -module P = struct - (* Patterns *) +(* this row type enable column processing inside the matrix + - left -> elements not to be processed, + - right -> elements to be processed +*) +type 'a row = {no_ors : 'a list ; ors : 'a list ; active : 'a list} - let iter sub {ppat_desc = desc; ppat_loc = loc; ppat_attributes = attrs} = - sub.location sub loc; - sub.attributes sub attrs; - match desc with - | Ppat_any -> () - | Ppat_var s -> iter_loc sub s - | Ppat_alias (p, s) -> sub.pat sub p; iter_loc sub s - | Ppat_constant _ -> () - | Ppat_interval _ -> () - | Ppat_tuple pl -> List.iter (sub.pat sub) pl - | Ppat_construct (l, p) -> - iter_loc sub l; iter_opt (sub.pat sub) p - | Ppat_variant (_l, p) -> iter_opt (sub.pat sub) p - | Ppat_record (lpl, _cf) -> - List.iter (iter_tuple (iter_loc sub) (sub.pat sub)) lpl - | Ppat_array pl -> List.iter (sub.pat sub) pl - | Ppat_or (p1, p2) -> sub.pat sub p1; sub.pat sub p2 - | Ppat_constraint (p, t) -> - sub.pat sub p; sub.typ sub t - | Ppat_type s -> iter_loc sub s - | Ppat_lazy p -> sub.pat sub p - | Ppat_unpack s -> iter_loc sub s - | Ppat_exception p -> sub.pat sub p - | Ppat_extension x -> sub.extension sub x - | Ppat_open (lid, p) -> - iter_loc sub lid; sub.pat sub p -end +(* +let pretty_row {ors=ors ; no_ors=no_ors; active=active} = + pretty_line ors ; prerr_string " *" ; + pretty_line no_ors ; prerr_string " *" ; + pretty_line active -module CE = struct - (* Value expressions for the class language *) +let pretty_rows rs = + prerr_endline "begin matrix" ; + List.iter + (fun r -> + pretty_row r ; + prerr_endline "") + rs ; + prerr_endline "end matrix" +*) - let iter sub {pcl_loc = loc; pcl_desc = desc; pcl_attributes = attrs} = - sub.location sub loc; - sub.attributes sub attrs; - match desc with - | Pcl_constr (lid, tys) -> - iter_loc sub lid; List.iter (sub.typ sub) tys - | Pcl_structure s -> - sub.class_structure sub s - | Pcl_fun (_lab, e, p, ce) -> - iter_opt (sub.expr sub) e; - sub.pat sub p; - sub.class_expr sub ce - | Pcl_apply (ce, l) -> - sub.class_expr sub ce; - List.iter (iter_snd (sub.expr sub)) l - | Pcl_let (_r, vbs, ce) -> - List.iter (sub.value_binding sub) vbs; - sub.class_expr sub ce - | Pcl_constraint (ce, ct) -> - sub.class_expr sub ce; sub.class_type sub ct - | Pcl_extension x -> sub.extension sub x - | Pcl_open (_ovf, lid, e) -> - iter_loc sub lid; sub.class_expr sub e +(* Initial build *) +let make_row ps = {ors=[] ; no_ors=[]; active=ps} - let iter_kind sub = function - | Cfk_concrete (_o, e) -> sub.expr sub e - | Cfk_virtual t -> sub.typ sub t +let make_rows pss = List.map make_row pss - let iter_field sub {pcf_desc = desc; pcf_loc = loc; pcf_attributes = attrs} = - sub.location sub loc; - sub.attributes sub attrs; - match desc with - | Pcf_inherit (_o, ce, _s) -> sub.class_expr sub ce - | Pcf_val (s, _m, k) -> iter_loc sub s; iter_kind sub k - | Pcf_method (s, _p, k) -> - iter_loc sub s; iter_kind sub k - | Pcf_constraint (t1, t2) -> - sub.typ sub t1; sub.typ sub t2 - | Pcf_initializer e -> sub.expr sub e - | Pcf_attribute x -> sub.attribute sub x - | Pcf_extension x -> sub.extension sub x - let iter_structure sub {pcstr_self; pcstr_fields} = - sub.pat sub pcstr_self; - List.iter (sub.class_field sub) pcstr_fields +(* Useful to detect and expand or pats inside as pats *) +let rec unalias p = match p.pat_desc with +| Tpat_alias (p,_,_) -> unalias p +| _ -> p - let class_infos sub f {pci_virt = _; pci_params = pl; pci_name; pci_expr; - pci_loc; pci_attributes} = - List.iter (iter_fst (sub.typ sub)) pl; - iter_loc sub pci_name; - f pci_expr; - sub.location sub pci_loc; - sub.attributes sub pci_attributes -end -(* Now, a generic AST mapper, to be extended to cover all kinds and - cases of the OCaml grammar. The default behavior of the mapper is - the identity. *) +let is_var p = match (unalias p).pat_desc with +| Tpat_any|Tpat_var _ -> true +| _ -> false -let default_iterator = - { - structure = (fun this l -> List.iter (this.structure_item this) l); - structure_item = M.iter_structure_item; - module_expr = M.iter; - signature = (fun this l -> List.iter (this.signature_item this) l); - signature_item = MT.iter_signature_item; - module_type = MT.iter; - with_constraint = MT.iter_with_constraint; - class_declaration = - (fun this -> CE.class_infos this (this.class_expr this)); - class_expr = CE.iter; - class_field = CE.iter_field; - class_structure = CE.iter_structure; - class_type = CT.iter; - class_type_field = CT.iter_field; - class_signature = CT.iter_signature; - class_type_declaration = - (fun this -> CE.class_infos this (this.class_type this)); - class_description = - (fun this -> CE.class_infos this (this.class_type this)); - type_declaration = T.iter_type_declaration; - type_kind = T.iter_type_kind; - typ = T.iter; - type_extension = T.iter_type_extension; - extension_constructor = T.iter_extension_constructor; - value_description = - (fun this {pval_name; pval_type; pval_prim = _; pval_loc; - pval_attributes} -> - iter_loc this pval_name; - this.typ this pval_type; - this.attributes this pval_attributes; - this.location this pval_loc - ); +let is_var_column rs = + List.for_all + (fun r -> match r.active with + | p::_ -> is_var p + | [] -> assert false) + rs - pat = P.iter; - expr = E.iter; +(* Standard or-args for left-to-right matching *) +let rec or_args p = match p.pat_desc with +| Tpat_or (p1,p2,_) -> p1,p2 +| Tpat_alias (p,_,_) -> or_args p +| _ -> assert false - module_declaration = - (fun this {pmd_name; pmd_type; pmd_attributes; pmd_loc} -> - iter_loc this pmd_name; - this.module_type this pmd_type; - this.attributes this pmd_attributes; - this.location this pmd_loc - ); +(* Just remove current column *) +let remove r = match r.active with +| _::rem -> {r with active=rem} +| [] -> assert false - module_type_declaration = - (fun this {pmtd_name; pmtd_type; pmtd_attributes; pmtd_loc} -> - iter_loc this pmtd_name; - iter_opt (this.module_type this) pmtd_type; - this.attributes this pmtd_attributes; - this.location this pmtd_loc - ); +let remove_column rs = List.map remove rs - module_binding = - (fun this {pmb_name; pmb_expr; pmb_attributes; pmb_loc} -> - iter_loc this pmb_name; this.module_expr this pmb_expr; - this.attributes this pmb_attributes; - this.location this pmb_loc - ); +(* Current column has been processed *) +let push_no_or r = match r.active with +| p::rem -> { r with no_ors = p::r.no_ors ; active=rem} +| [] -> assert false +let push_or r = match r.active with +| p::rem -> { r with ors = p::r.ors ; active=rem} +| [] -> assert false - open_description = - (fun this {popen_lid; popen_override = _; popen_attributes; popen_loc} -> - iter_loc this popen_lid; - this.location this popen_loc; - this.attributes this popen_attributes - ); +let push_or_column rs = List.map push_or rs +and push_no_or_column rs = List.map push_no_or rs +(* Those are adaptations of the previous homonymous functions that + work on the current column, instead of the first column +*) - include_description = - (fun this {pincl_mod; pincl_attributes; pincl_loc} -> - this.module_type this pincl_mod; - this.location this pincl_loc; - this.attributes this pincl_attributes - ); +let discr_pat q rs = + discr_pat q (List.map (fun r -> r.active) rs) - include_declaration = - (fun this {pincl_mod; pincl_attributes; pincl_loc} -> - this.module_expr this pincl_mod; - this.location this pincl_loc; - this.attributes this pincl_attributes - ); +let filter_one q rs = + let rec filter_rec rs = match rs with + | [] -> [] + | r::rem -> + match r.active with + | [] -> assert false + | {pat_desc = Tpat_alias(p,_,_)}::ps -> + filter_rec ({r with active = p::ps}::rem) + | {pat_desc = Tpat_or(p1,p2,_)}::ps -> + filter_rec + ({r with active = p1::ps}:: + {r with active = p2::ps}:: + rem) + | p::ps -> + if simple_match q p then + {r with active=simple_match_args q p @ ps} :: filter_rec rem + else + filter_rec rem in + filter_rec rs - value_binding = - (fun this {pvb_pat; pvb_expr; pvb_attributes; pvb_loc} -> - this.pat this pvb_pat; - this.expr this pvb_expr; - this.location this pvb_loc; - this.attributes this pvb_attributes - ); +(* Back to normal matrices *) +let make_vector r = List.rev r.no_ors +let make_matrix rs = List.map make_vector rs - constructor_declaration = - (fun this {pcd_name; pcd_args; pcd_res; pcd_loc; pcd_attributes} -> - iter_loc this pcd_name; - T.iter_constructor_arguments this pcd_args; - iter_opt (this.typ this) pcd_res; - this.location this pcd_loc; - this.attributes this pcd_attributes - ); - label_declaration = - (fun this {pld_name; pld_type; pld_loc; pld_mutable = _; pld_attributes}-> - iter_loc this pld_name; - this.typ this pld_type; - this.location this pld_loc; - this.attributes this pld_attributes - ); +(* Standard union on answers *) +let union_res r1 r2 = match r1, r2 with +| (Unused,_) +| (_, Unused) -> Unused +| Used,_ -> r2 +| _, Used -> r1 +| Upartial u1, Upartial u2 -> Upartial (u1@u2) - cases = (fun this l -> List.iter (this.case this) l); - case = - (fun this {pc_lhs; pc_guard; pc_rhs} -> - this.pat this pc_lhs; - iter_opt (this.expr this) pc_guard; - this.expr this pc_rhs - ); +(* propose or pats for expansion *) +let extract_elements qs = + let rec do_rec seen = function + | [] -> [] + | q::rem -> + {no_ors= List.rev_append seen rem @ qs.no_ors ; + ors=[] ; + active = [q]}:: + do_rec (q::seen) rem in + do_rec [] qs.ors - location = (fun _this _l -> ()); +(* idem for matrices *) +let transpose rs = match rs with +| [] -> assert false +| r::rem -> + let i = List.map (fun x -> [x]) r in + List.fold_left + (List.map2 (fun r x -> x::r)) + i rem - extension = (fun this (s, e) -> iter_loc this s; this.payload this e); - attribute = (fun this (s, e) -> iter_loc this s; this.payload this e); - attributes = (fun this l -> List.iter (this.attribute this) l); - payload = - (fun this -> function - | PStr x -> this.structure this x - | PSig x -> this.signature this x - | PTyp x -> this.typ this x - | PPat (x, g) -> this.pat this x; iter_opt (this.expr this) g - ); - } +let extract_columns pss qs = match pss with +| [] -> List.map (fun _ -> []) qs.ors +| _ -> + let rows = List.map extract_elements pss in + transpose rows -end -module Typetexp : sig -#1 "typetexp.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +(* Core function + The idea is to first look for or patterns (recursive case), then + check or-patterns argument usefulness (terminal case) +*) +let rec simplified_first_usefulness_col = function + | [] -> [] + | row :: rows -> + match row.active with + | [] -> assert false (* the rows are non-empty! *) + | p :: _ -> simplify_head_pat p (simplified_first_usefulness_col rows) -(* Typechecking of type expressions for the core language *) +let rec every_satisfiables pss qs = match qs.active with +| [] -> + (* qs is now partitionned, check usefulness *) + begin match qs.ors with + | [] -> (* no or-patterns *) + if satisfiable (make_matrix pss) (make_vector qs) then + Used + else + Unused + | _ -> (* n or-patterns -> 2n expansions *) + List.fold_right2 + (fun pss qs r -> match r with + | Unused -> Unused + | _ -> + match qs.active with + | [q] -> + let q1,q2 = or_args q in + let r_loc = every_both pss qs q1 q2 in + union_res r r_loc + | _ -> assert false) + (extract_columns pss qs) (extract_elements qs) + Used + end +| q::rem -> + let uq = unalias q in + begin match uq.pat_desc with + | Tpat_any | Tpat_var _ -> + if is_var_column pss then +(* forget about ``all-variable'' columns now *) + every_satisfiables (remove_column pss) (remove qs) + else +(* otherwise this is direct food for satisfiable *) + every_satisfiables (push_no_or_column pss) (push_no_or qs) + | Tpat_or (q1,q2,_) -> + if + q1.pat_loc.Location.loc_ghost && + q2.pat_loc.Location.loc_ghost + then +(* syntactically generated or-pats should not be expanded *) + every_satisfiables (push_no_or_column pss) (push_no_or qs) + else +(* this is a real or-pattern *) + every_satisfiables (push_or_column pss) (push_or qs) + | Tpat_variant (l,_,r) when is_absent l r -> (* Ah Jacques... *) + Unused + | _ -> +(* standard case, filter matrix *) + (* The handling of incoherent matrices is kept in line with + [satisfiable] *) + if not (all_coherent (uq :: simplified_first_usefulness_col pss)) then + Unused + else begin + let q0 = discr_pat q pss in + every_satisfiables + (filter_one q0 pss) + {qs with active=simple_match_args q0 q @ rem} + end + end -open Types +(* + This function ``every_both'' performs the usefulness check + of or-pat q1|q2. + The trick is to call every_satisfied twice with + current active columns restricted to q1 and q2, + That way, + - others orpats in qs.ors will not get expanded. + - all matching work performed on qs.no_ors is not performed again. + *) +and every_both pss qs q1 q2 = + let qs1 = {qs with active=[q1]} + and qs2 = {qs with active=[q2]} in + let r1 = every_satisfiables pss qs1 + and r2 = every_satisfiables (if compat q1 q2 then qs1::pss else pss) qs2 in + match r1 with + | Unused -> + begin match r2 with + | Unused -> Unused + | Used -> Upartial [q1] + | Upartial u2 -> Upartial (q1::u2) + end + | Used -> + begin match r2 with + | Unused -> Upartial [q2] + | _ -> r2 + end + | Upartial u1 -> + begin match r2 with + | Unused -> Upartial (u1@[q2]) + | Used -> r1 + | Upartial u2 -> Upartial (u1 @ u2) + end -val transl_simple_type: - Env.t -> bool -> Parsetree.core_type -> Typedtree.core_type -val transl_simple_type_univars: - Env.t -> Parsetree.core_type -> Typedtree.core_type -val transl_simple_type_delayed: - Env.t -> Parsetree.core_type -> Typedtree.core_type * (unit -> unit) - (* Translate a type, but leave type variables unbound. Returns - the type and a function that binds the type variable. *) -val transl_type_scheme: - Env.t -> Parsetree.core_type -> Typedtree.core_type -val reset_type_variables: unit -> unit -val type_variable: Location.t -> string -> type_expr -val transl_type_param: - Env.t -> Parsetree.core_type -> Typedtree.core_type -type variable_context -val narrow: unit -> variable_context -val widen: variable_context -> unit -exception Already_bound -type error = - Unbound_type_variable of string - | Unbound_type_constructor of Longident.t - | Unbound_type_constructor_2 of Path.t - | Type_arity_mismatch of Longident.t * int * int - | Bound_type_variable of string - | Recursive_type - | Unbound_row_variable of Longident.t - | Type_mismatch of (type_expr * type_expr) list - | Alias_type_mismatch of (type_expr * type_expr) list - | Present_has_conjunction of string - | Present_has_no_type of string - | Constructor_mismatch of type_expr * type_expr - | Not_a_variant of type_expr - | Variant_tags of string * string - | Invalid_variable_name of string - | Cannot_quantify of string * type_expr - | Multiple_constraints_on_type of Longident.t - | Method_mismatch of string * type_expr * type_expr - | Unbound_value of Longident.t - | Unbound_constructor of Longident.t - | Unbound_label of Longident.t - | Unbound_module of Longident.t - | Unbound_class of Longident.t - | Unbound_modtype of Longident.t - | Unbound_cltype of Longident.t - | Ill_typed_functor_application of Longident.t - | Illegal_reference_to_recursive_module - | Access_functor_as_structure of Longident.t - | Apply_structure_as_functor of Longident.t - | Cannot_scrape_alias of Longident.t * Path.t - | Opened_object of Path.t option - | Not_an_object of type_expr +(* le_pat p q means, forall V, V matches q implies V matches p *) +let rec le_pat p q = + match (p.pat_desc, q.pat_desc) with + | (Tpat_var _|Tpat_any),_ -> true + | Tpat_alias(p,_,_), _ -> le_pat p q + | _, Tpat_alias(q,_,_) -> le_pat p q + | Tpat_constant(c1), Tpat_constant(c2) -> const_compare c1 c2 = 0 + | Tpat_construct(_,c1,ps), Tpat_construct(_,c2,qs) -> + Types.equal_tag c1.cstr_tag c2.cstr_tag && le_pats ps qs + | Tpat_variant(l1,Some p1,_), Tpat_variant(l2,Some p2,_) -> + (l1 = l2 && le_pat p1 p2) + | Tpat_variant(l1,None,_r1), Tpat_variant(l2,None,_) -> + l1 = l2 + | Tpat_variant(_,_,_), Tpat_variant(_,_,_) -> false + | Tpat_tuple(ps), Tpat_tuple(qs) -> le_pats ps qs + | Tpat_lazy p, Tpat_lazy q -> le_pat p q + | Tpat_record (l1,_), Tpat_record (l2,_) -> + let ps,qs = records_args l1 l2 in + le_pats ps qs + | Tpat_array(ps), Tpat_array(qs) -> + List.length ps = List.length qs && le_pats ps qs +(* In all other cases, enumeration is performed *) + | _,_ -> not (satisfiable [[p]] [q]) -exception Error of Location.t * Env.t * error +and le_pats ps qs = + match ps,qs with + p::ps, q::qs -> le_pat p q && le_pats ps qs + | _, _ -> true -val report_error: Env.t -> Format.formatter -> error -> unit +let get_mins le ps = + let rec select_rec r = function + [] -> r + | p::ps -> + if List.exists (fun p0 -> le p0 p) ps + then select_rec r ps + else select_rec (p::r) ps in + select_rec [] (select_rec [] ps) -(* Support for first-class modules. *) -val transl_modtype_longident: (* from Typemod *) - (Location.t -> Env.t -> Longident.t -> Path.t) ref -val transl_modtype: (* from Typemod *) - (Env.t -> Parsetree.module_type -> Typedtree.module_type) ref -val create_package_mty: - Location.t -> Env.t -> Parsetree.package_type -> - (Longident.t Asttypes.loc * Parsetree.core_type) list * - Parsetree.module_type +(* + lub p q is a pattern that matches all values matched by p and q + may raise Empty, when p and q are not compatible +*) -val find_type: - Env.t -> Location.t -> Longident.t -> Path.t * type_declaration -val find_constructor: - Env.t -> Location.t -> Longident.t -> constructor_description -val find_all_constructors: - Env.t -> Location.t -> Longident.t -> - (constructor_description * (unit -> unit)) list -val find_label: - Env.t -> Location.t -> Longident.t -> label_description -val find_all_labels: - Env.t -> Location.t -> Longident.t -> - (label_description * (unit -> unit)) list -val find_value: - Env.t -> Location.t -> Longident.t -> Path.t * value_description -val find_class: - Env.t -> Location.t -> Longident.t -> Path.t * class_declaration -val find_module: - Env.t -> Location.t -> Longident.t -> Path.t * module_declaration -val lookup_module: - ?load:bool -> Env.t -> Location.t -> Longident.t -> Path.t -val find_modtype: - Env.t -> Location.t -> Longident.t -> Path.t * modtype_declaration -val find_class_type: - Env.t -> Location.t -> Longident.t -> Path.t * class_type_declaration +let rec lub p q = match p.pat_desc,q.pat_desc with +| Tpat_alias (p,_,_),_ -> lub p q +| _,Tpat_alias (q,_,_) -> lub p q +| (Tpat_any|Tpat_var _),_ -> q +| _,(Tpat_any|Tpat_var _) -> p +| Tpat_or (p1,p2,_),_ -> orlub p1 p2 q +| _,Tpat_or (q1,q2,_) -> orlub q1 q2 p (* Thanks god, lub is commutative *) +| Tpat_constant c1, Tpat_constant c2 when const_compare c1 c2 = 0 -> p +| Tpat_tuple ps, Tpat_tuple qs -> + let rs = lubs ps qs in + make_pat (Tpat_tuple rs) p.pat_type p.pat_env +| Tpat_lazy p, Tpat_lazy q -> + let r = lub p q in + make_pat (Tpat_lazy r) p.pat_type p.pat_env +| Tpat_construct (lid, c1,ps1), Tpat_construct (_,c2,ps2) + when Types.equal_tag c1.cstr_tag c2.cstr_tag -> + let rs = lubs ps1 ps2 in + make_pat (Tpat_construct (lid, c1,rs)) + p.pat_type p.pat_env +| Tpat_variant(l1,Some p1,row), Tpat_variant(l2,Some p2,_) + when l1=l2 -> + let r=lub p1 p2 in + make_pat (Tpat_variant (l1,Some r,row)) p.pat_type p.pat_env +| Tpat_variant (l1,None,_row), Tpat_variant(l2,None,_) + when l1 = l2 -> p +| Tpat_record (l1,closed),Tpat_record (l2,_) -> + let rs = record_lubs l1 l2 in + make_pat (Tpat_record (rs, closed)) p.pat_type p.pat_env +| Tpat_array ps, Tpat_array qs + when List.length ps = List.length qs -> + let rs = lubs ps qs in + make_pat (Tpat_array rs) p.pat_type p.pat_env +| _,_ -> + raise Empty + +and orlub p1 p2 q = + try + let r1 = lub p1 q in + try + {q with pat_desc=(Tpat_or (r1,lub p2 q,None))} + with + | Empty -> r1 +with +| Empty -> lub p2 q + +and record_lubs l1 l2 = + let rec lub_rec l1 l2 = match l1,l2 with + | [],_ -> l2 + | _,[] -> l1 + | (lid1, lbl1,p1)::rem1, (lid2, lbl2,p2)::rem2 -> + if lbl1.lbl_pos < lbl2.lbl_pos then + (lid1, lbl1,p1)::lub_rec rem1 l2 + else if lbl2.lbl_pos < lbl1.lbl_pos then + (lid2, lbl2,p2)::lub_rec l1 rem2 + else + (lid1, lbl1,lub p1 p2)::lub_rec rem1 rem2 in + lub_rec l1 l2 -val unbound_constructor_error: Env.t -> Longident.t Location.loc -> 'a -val unbound_label_error: Env.t -> Longident.t Location.loc -> 'a +and lubs ps qs = match ps,qs with +| p::ps, q::qs -> lub p q :: lubs ps qs +| _,_ -> [] -val spellcheck: - Format.formatter -> - (('a -> 'a list -> 'a list) -> - Longident.t option -> 'b -> 'c list -> string list) -> - 'b -> Longident.t -> unit +(******************************) +(* Exported variant closing *) +(******************************) -end = struct -#1 "typetexp.ml" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +(* Apply pressure to variants *) -(* typetexp.ml,v 1.34.4.9 2002/01/07 08:39:16 garrigue Exp *) +let pressure_variants tdefs patl = + let pss = List.map (fun p -> [p;omega]) patl in + ignore (pressure_variants (Some tdefs) pss) -(* Typechecking of type expressions for the core language *) +(*****************************) +(* Utilities for diagnostics *) +(*****************************) -open Asttypes -open Misc -open Parsetree -open Typedtree -open Types -open Ctype +(* + Build up a working pattern matrix by forgetting + about guarded patterns +*) -exception Already_bound +let rec initial_matrix = function + [] -> [] + | {c_guard=Some _} :: rem -> initial_matrix rem + | {c_guard=None; c_lhs=p} :: rem -> [p] :: initial_matrix rem -type error = - Unbound_type_variable of string - | Unbound_type_constructor of Longident.t - | Unbound_type_constructor_2 of Path.t - | Type_arity_mismatch of Longident.t * int * int - | Bound_type_variable of string - | Recursive_type - | Unbound_row_variable of Longident.t - | Type_mismatch of (type_expr * type_expr) list - | Alias_type_mismatch of (type_expr * type_expr) list - | Present_has_conjunction of string - | Present_has_no_type of string - | Constructor_mismatch of type_expr * type_expr - | Not_a_variant of type_expr - | Variant_tags of string * string - | Invalid_variable_name of string - | Cannot_quantify of string * type_expr - | Multiple_constraints_on_type of Longident.t - | Method_mismatch of string * type_expr * type_expr - | Unbound_value of Longident.t - | Unbound_constructor of Longident.t - | Unbound_label of Longident.t - | Unbound_module of Longident.t - | Unbound_class of Longident.t - | Unbound_modtype of Longident.t - | Unbound_cltype of Longident.t - | Ill_typed_functor_application of Longident.t - | Illegal_reference_to_recursive_module - | Access_functor_as_structure of Longident.t - | Apply_structure_as_functor of Longident.t - | Cannot_scrape_alias of Longident.t * Path.t - | Opened_object of Path.t option - | Not_an_object of type_expr +(******************************************) +(* Look for a row that matches some value *) +(******************************************) -exception Error of Location.t * Env.t * error -exception Error_forward of Location.error +(* + Useful for seeing if the example of + non-matched value can indeed be matched + (by a guarded clause) +*) -type variable_context = int * (string, type_expr) Tbl.t -(* Local definitions *) +exception NoGuard -let instance_list = Ctype.instance_list Env.empty +let rec initial_all no_guard = function + | [] -> + if no_guard then + raise NoGuard + else + [] + | {c_lhs=pat; c_guard; _} :: rem -> + ([pat], pat.pat_loc) :: initial_all (no_guard && c_guard = None) rem -(* Narrowing unbound identifier errors. *) -let rec narrow_unbound_lid_error : 'a. _ -> _ -> _ -> _ -> 'a = - fun env loc lid make_error -> - let check_module mlid = - try ignore (Env.lookup_module ~load:true mlid env) with - | Not_found -> - narrow_unbound_lid_error env loc mlid (fun lid -> Unbound_module lid) - | Env.Recmodule -> - raise (Error (loc, env, Illegal_reference_to_recursive_module)) - in - begin match lid with - | Longident.Lident _ -> () - | Longident.Ldot (mlid, _) -> - check_module mlid; - let md = Env.find_module (Env.lookup_module ~load:true mlid env) env in - begin match Env.scrape_alias env md.md_type with - | Mty_functor _ -> - raise (Error (loc, env, Access_functor_as_structure mlid)) - | Mty_alias(_, p) -> - raise (Error (loc, env, Cannot_scrape_alias(mlid, p))) - | _ -> () - end - | Longident.Lapply (flid, mlid) -> - check_module flid; - let fmd = Env.find_module (Env.lookup_module ~load:true flid env) env in - begin match Env.scrape_alias env fmd.md_type with - | Mty_signature _ -> - raise (Error (loc, env, Apply_structure_as_functor flid)) - | Mty_alias(_, p) -> - raise (Error (loc, env, Cannot_scrape_alias(flid, p))) - | _ -> () - end; - check_module mlid; - let mmd = Env.find_module (Env.lookup_module ~load:true mlid env) env in - begin match Env.scrape_alias env mmd.md_type with - | Mty_alias(_, p) -> - raise (Error (loc, env, Cannot_scrape_alias(mlid, p))) - | _ -> - raise (Error (loc, env, Ill_typed_functor_application lid)) +let rec do_filter_var = function + | (_::ps,loc)::rem -> (ps,loc)::do_filter_var rem + | _ -> [] + +let do_filter_one q pss = + let rec filter_rec = function + | ({pat_desc = Tpat_alias(p,_,_)}::ps,loc)::pss -> + filter_rec ((p::ps,loc)::pss) + | ({pat_desc = Tpat_or(p1,p2,_)}::ps,loc)::pss -> + filter_rec ((p1::ps,loc)::(p2::ps,loc)::pss) + | (p::ps,loc)::pss -> + if simple_match q p + then (simple_match_args q p @ ps, loc) :: filter_rec pss + else filter_rec pss + | _ -> [] in + filter_rec pss + +let rec do_match pss qs = match qs with +| [] -> + begin match pss with + | ([],loc)::_ -> Some loc + | _ -> None + end +| q::qs -> match q with + | {pat_desc = Tpat_or (q1,q2,_)} -> + begin match do_match pss (q1::qs) with + | None -> do_match pss (q2::qs) + | r -> r end - end; - raise (Error (loc, env, make_error lid)) + | {pat_desc = Tpat_any} -> + do_match (do_filter_var pss) qs + | _ -> + let q0 = normalize_pat q in + (* [pss] will (or won't) match [q0 :: qs] regardless of the coherence of + its first column. *) + do_match (do_filter_one q0 pss) (simple_match_args q0 q @ qs) -let find_component (lookup : ?loc:_ -> _) make_error env loc lid = + +let check_partial_all v casel = try - match lid with - | Longident.Ldot (Longident.Lident "*predef*", s) -> - lookup ~loc (Longident.Lident s) Env.initial_safe_string - | _ -> - lookup ~loc lid env - with Not_found -> - narrow_unbound_lid_error env loc lid make_error - | Env.Recmodule -> - raise (Error (loc, env, Illegal_reference_to_recursive_module)) + let pss = initial_all true casel in + do_match pss [v] + with + | NoGuard -> None -let find_type env loc lid = - let path = - find_component Env.lookup_type (fun lid -> Unbound_type_constructor lid) - env loc lid - in - let decl = Env.find_type path env in - Builtin_attributes.check_deprecated loc decl.type_attributes (Path.name path); - (path, decl) +(************************) +(* Exhaustiveness check *) +(************************) -let find_constructor = - find_component Env.lookup_constructor (fun lid -> Unbound_constructor lid) -let find_all_constructors = - find_component Env.lookup_all_constructors - (fun lid -> Unbound_constructor lid) -let find_label = - find_component Env.lookup_label (fun lid -> Unbound_label lid) -let find_all_labels = - find_component Env.lookup_all_labels (fun lid -> Unbound_label lid) +(* conversion from Typedtree.pattern to Parsetree.pattern list *) +module Conv = struct + open Parsetree + let mkpat desc = Ast_helper.Pat.mk desc -let find_class env loc lid = - let (path, decl) as r = - find_component Env.lookup_class (fun lid -> Unbound_class lid) env loc lid - in - Builtin_attributes.check_deprecated loc decl.cty_attributes (Path.name path); - r + let name_counter = ref 0 + let fresh name = + let current = !name_counter in + name_counter := !name_counter + 1; + "#$" ^ name ^ string_of_int current -let find_value env loc lid = - Env.check_value_name (Longident.last lid) loc; - let (path, decl) as r = - find_component Env.lookup_value (fun lid -> Unbound_value lid) env loc lid - in - Builtin_attributes.check_deprecated loc decl.val_attributes (Path.name path); - r + let conv typed = + let constrs = Hashtbl.create 7 in + let labels = Hashtbl.create 7 in + let rec loop pat = + match pat.pat_desc with + Tpat_or (pa,pb,_) -> + mkpat (Ppat_or (loop pa, loop pb)) + | Tpat_var (_, ({txt="*extension*"} as nm)) -> (* PR#7330 *) + mkpat (Ppat_var nm) + | Tpat_any + | Tpat_var _ -> + mkpat Ppat_any + | Tpat_constant c -> + mkpat (Ppat_constant (Untypeast.constant c)) + | Tpat_alias (p,_,_) -> loop p + | Tpat_tuple lst -> + mkpat (Ppat_tuple (List.map loop lst)) + | Tpat_construct (cstr_lid, cstr, lst) -> + let id = fresh cstr.cstr_name in + let lid = { cstr_lid with txt = Longident.Lident id } in + Hashtbl.add constrs id cstr; + let arg = + match List.map loop lst with + | [] -> None + | [p] -> Some p + | lst -> Some (mkpat (Ppat_tuple lst)) + in + mkpat (Ppat_construct(lid, arg)) + | Tpat_variant(label,p_opt,_row_desc) -> + let arg = Misc.may_map loop p_opt in + mkpat (Ppat_variant(label, arg)) + | Tpat_record (subpatterns, _closed_flag) -> + let fields = + List.map + (fun (_, lbl, p) -> + let id = fresh lbl.lbl_name in + Hashtbl.add labels id lbl; + (mknoloc (Longident.Lident id), loop p)) + subpatterns + in + mkpat (Ppat_record (fields, Open)) + | Tpat_array lst -> + mkpat (Ppat_array (List.map loop lst)) + | Tpat_lazy p -> + mkpat (Ppat_lazy (loop p)) + in + let ps = loop typed in + (ps, constrs, labels) +end -let lookup_module ?(load=false) env loc lid = - find_component (fun ?loc lid env -> (Env.lookup_module ~load ?loc lid env)) - (fun lid -> Unbound_module lid) env loc lid -let find_module env loc lid = - let path = lookup_module ~load:true env loc lid in - let decl = Env.find_module path env in - (* No need to check for deprecated here, this is done in Env. *) - (path, decl) +(* Whether the counter-example contains an extension pattern *) +let contains_extension pat = + let r = ref false in + let rec loop = function + {pat_desc=Tpat_var (_, {txt="*extension*"})} -> + r := true + | p -> Typedtree.iter_pattern_desc loop p.pat_desc + in loop pat; !r -let find_modtype env loc lid = - let (path, decl) as r = - find_component Env.lookup_modtype (fun lid -> Unbound_modtype lid) - env loc lid - in - Builtin_attributes.check_deprecated loc decl.mtd_attributes (Path.name path); - r +(* Build an untyped or-pattern from its expected type *) +let ppat_of_type env ty = + match pats_of_type env ty with + [{pat_desc = Tpat_any}] -> + (Conv.mkpat Parsetree.Ppat_any, Hashtbl.create 0, Hashtbl.create 0) + | pats -> + Conv.conv (orify_many pats) -let find_class_type env loc lid = - let (path, decl) as r = - find_component Env.lookup_cltype (fun lid -> Unbound_cltype lid) - env loc lid - in - Builtin_attributes.check_deprecated loc decl.clty_attributes (Path.name path); - r +let do_check_partial ?pred exhaust loc casel pss = match pss with +| [] -> + (* + This can occur + - For empty matches generated by ocamlp4 (no warning) + - when all patterns have guards (then, casel <> []) + (specific warning) + Then match MUST be considered non-exhaustive, + otherwise compilation of PM is broken. + *) + begin match casel with + | [] -> () + | _ -> + if Warnings.is_active Warnings.All_clauses_guarded then + Location.prerr_warning loc Warnings.All_clauses_guarded + end ; + Partial +| ps::_ -> + begin match exhaust None pss (List.length ps) with + | Rnone -> Total + | Rsome [u] -> + let v = + match pred with + | Some pred -> + let (pattern,constrs,labels) = Conv.conv u in + let u' = pred constrs labels pattern in + (* pretty_pat u; + begin match u' with + None -> prerr_endline ": impossible" + | Some _ -> prerr_endline ": possible" + end; *) + u' + | None -> Some u + in + begin match v with + None -> Total + | Some v -> + if Warnings.is_active (Warnings.Partial_match "") then begin + let errmsg = + try + let buf = Buffer.create 16 in + let fmt = formatter_of_buffer buf in + top_pretty fmt v; + begin match check_partial_all v casel with + | None -> () + | Some _ -> + (* This is 'Some loc', where loc is the location of + a possibly matching clause. + Forget about loc, because printing two locations + is a pain in the top-level *) + Buffer.add_string buf + "\n(However, some guarded clause may match this value.)" + end; + if contains_extension v then + Buffer.add_string buf + "\nMatching over values of extensible variant types \ + (the *extension* above)\n\ + must include a wild card pattern in order to be exhaustive." + ; + Buffer.contents buf + with _ -> + "" + in + Location.prerr_warning loc (Warnings.Partial_match errmsg) + end; + Partial + end + | _ -> + fatal_error "Parmatch.check_partial" + end -let unbound_constructor_error env lid = - narrow_unbound_lid_error env lid.loc lid.txt - (fun lid -> Unbound_constructor lid) +(* +let do_check_partial_normal loc casel pss = + do_check_partial exhaust loc casel pss + *) -let unbound_label_error env lid = - narrow_unbound_lid_error env lid.loc lid.txt - (fun lid -> Unbound_label lid) +let do_check_partial_gadt pred loc casel pss = + do_check_partial ~pred exhaust_gadt loc casel pss -(* Support for first-class modules. *) -let transl_modtype_longident = ref (fun _ -> assert false) -let transl_modtype = ref (fun _ -> assert false) -let create_package_mty fake loc env (p, l) = - let l = - List.sort - (fun (s1, _t1) (s2, _t2) -> - if s1.txt = s2.txt then - raise (Error (loc, env, Multiple_constraints_on_type s1.txt)); - compare s1.txt s2.txt) - l - in - l, - List.fold_left - (fun mty (s, t) -> - let d = {ptype_name = mkloc (Longident.last s.txt) s.loc; - ptype_params = []; - ptype_cstrs = []; - ptype_kind = Ptype_abstract; - ptype_private = Asttypes.Public; - ptype_manifest = if fake then None else Some t; - ptype_attributes = []; - ptype_loc = loc} in - Ast_helper.Mty.mk ~loc - (Pmty_with (mty, [ Pwith_type ({ txt = s.txt; loc }, d) ])) - ) - (Ast_helper.Mty.mk ~loc (Pmty_ident p)) - l +(*****************) +(* Fragile check *) +(*****************) -(* Translation of type expressions *) +(* Collect all data types in a pattern *) -let type_variables = ref (Tbl.empty : (string, type_expr) Tbl.t) -let univars = ref ([] : (string * type_expr) list) -let pre_univars = ref ([] : type_expr list) -let used_variables = ref (Tbl.empty : (string, type_expr * Location.t) Tbl.t) +let rec add_path path = function + | [] -> [path] + | x::rem as paths -> + if Path.same path x then paths + else x::add_path path rem + +let extendable_path path = + not + (Path.same path Predef.path_bool || + Path.same path Predef.path_list || + Path.same path Predef.path_unit || + Path.same path Predef.path_option) + +let rec collect_paths_from_pat r p = match p.pat_desc with +| Tpat_construct(_, {cstr_tag=(Cstr_constant _|Cstr_block _|Cstr_unboxed)},ps) + -> + let path = get_type_path p.pat_type p.pat_env in + List.fold_left + collect_paths_from_pat + (if extendable_path path then add_path path r else r) + ps +| Tpat_any|Tpat_var _|Tpat_constant _| Tpat_variant (_,None,_) -> r +| Tpat_tuple ps | Tpat_array ps +| Tpat_construct (_, {cstr_tag=Cstr_extension _}, ps)-> + List.fold_left collect_paths_from_pat r ps +| Tpat_record (lps,_) -> + List.fold_left + (fun r (_, _, p) -> collect_paths_from_pat r p) + r lps +| Tpat_variant (_, Some p, _) | Tpat_alias (p,_,_) -> collect_paths_from_pat r p +| Tpat_or (p1,p2,_) -> + collect_paths_from_pat (collect_paths_from_pat r p1) p2 +| Tpat_lazy p + -> + collect_paths_from_pat r p + + +(* + Actual fragile check + 1. Collect data types in the patterns of the match. + 2. One exhaustivity check per datatype, considering that + the type is extended. +*) + +let do_check_fragile_param exhaust loc casel pss = + let exts = + List.fold_left + (fun r c -> collect_paths_from_pat r c.c_lhs) + [] casel in + match exts with + | [] -> () + | _ -> match pss with + | [] -> () + | ps::_ -> + List.iter + (fun ext -> + match exhaust (Some ext) pss (List.length ps) with + | Rnone -> + Location.prerr_warning + loc + (Warnings.Fragile_match (Path.name ext)) + | Rsome _ -> ()) + exts -let reset_type_variables () = - reset_global_level (); - Ctype.reset_reified_var_counter (); - type_variables := Tbl.empty +(*let do_check_fragile_normal = do_check_fragile_param exhaust*) +let do_check_fragile_gadt = do_check_fragile_param exhaust_gadt -let narrow () = - (increase_global_level (), !type_variables) +(********************************) +(* Exported unused clause check *) +(********************************) -let widen (gl, tv) = - restore_global_level gl; - type_variables := tv +let check_unused pred casel = + if Warnings.is_active Warnings.Unused_match + || List.exists (fun c -> c.c_rhs.exp_desc = Texp_unreachable) casel then + let rec do_rec pref = function + | [] -> () + | {c_lhs=q; c_guard; c_rhs} :: rem -> + let qs = [q] in + begin try + let pss = + get_mins le_pats (List.filter (compats qs) pref) in + (* First look for redundant or partially redundant patterns *) + let r = every_satisfiables (make_rows pss) (make_row qs) in + let refute = (c_rhs.exp_desc = Texp_unreachable) in + (* Do not warn for unused [pat -> .] *) + if r = Unused && refute then () else + let r = + (* Do not refine if there are no other lines *) + let skip = + r = Unused || (not refute && pref = []) || + not(refute || Warnings.is_active Warnings.Unreachable_case) in + if skip then r else + (* Then look for empty patterns *) + let sfs = satisfiables pss qs in + if sfs = [] then Unused else + let sfs = + List.map (function [u] -> u | _ -> assert false) sfs in + let u = orify_many sfs in + (*Format.eprintf "%a@." pretty_val u;*) + let (pattern,constrs,labels) = Conv.conv u in + let pattern = {pattern with Parsetree.ppat_loc = q.pat_loc} in + match pred refute constrs labels pattern with + None when not refute -> + Location.prerr_warning q.pat_loc Warnings.Unreachable_case; + Used + | _ -> r + in + match r with + | Unused -> + Location.prerr_warning + q.pat_loc Warnings.Unused_match + | Upartial ps -> + List.iter + (fun p -> + Location.prerr_warning + p.pat_loc Warnings.Unused_pat) + ps + | Used -> () + with Empty | Not_found | NoGuard -> assert false + end ; -let strict_ident c = (c = '_' || c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z') + if c_guard <> None then + do_rec pref rem + else + do_rec ([q]::pref) rem in -let validate_name = function - None -> None - | Some name as s -> - if name <> "" && strict_ident name.[0] then s else None + do_rec [] casel -let new_global_var ?name () = - new_global_var ?name:(validate_name name) () -let newvar ?name () = - newvar ?name:(validate_name name) () +(*********************************) +(* Exported irrefutability tests *) +(*********************************) -let type_variable loc name = - try - Tbl.find name !type_variables - with Not_found -> - raise(Error(loc, Env.empty, Unbound_type_variable ("'" ^ name))) +let irrefutable pat = le_pat pat omega -let transl_type_param env styp = - let loc = styp.ptyp_loc in - match styp.ptyp_desc with - Ptyp_any -> - let ty = new_global_var ~name:"_" () in - { ctyp_desc = Ttyp_any; ctyp_type = ty; ctyp_env = env; - ctyp_loc = loc; ctyp_attributes = styp.ptyp_attributes; } - | Ptyp_var name -> - let ty = - try - if name <> "" && name.[0] = '_' then - raise (Error (loc, Env.empty, Invalid_variable_name ("'" ^ name))); - ignore (Tbl.find name !type_variables); - raise Already_bound - with Not_found -> - let v = new_global_var ~name () in - type_variables := Tbl.add name v !type_variables; - v +let inactive ~partial pat = + match partial with + | Partial -> false + | Total -> begin + let rec loop pat = + match pat.pat_desc with + | Tpat_lazy _ | Tpat_array _ -> + false + | Tpat_any | Tpat_var _ | Tpat_variant (_, None, _) -> + true + | Tpat_constant c -> begin + match c with + | Const_string _ -> Config.safe_string + | Const_int _ | Const_char _ | Const_float _ + | Const_int32 _ | Const_int64 _ | Const_nativeint _ -> true + end + | Tpat_tuple ps | Tpat_construct (_, _, ps) -> + List.for_all (fun p -> loop p) ps + | Tpat_alias (p,_,_) | Tpat_variant (_, Some p, _) -> + loop p + | Tpat_record (ldps,_) -> + List.for_all + (fun (_, lbl, p) -> lbl.lbl_mut = Immutable && loop p) + ldps + | Tpat_or (p,q,_) -> + loop p && loop q in - { ctyp_desc = Ttyp_var name; ctyp_type = ty; ctyp_env = env; - ctyp_loc = loc; ctyp_attributes = styp.ptyp_attributes; } - | _ -> assert false - -let transl_type_param env styp = - (* Currently useless, since type parameters cannot hold attributes - (but this could easily be lifted in the future). *) - Builtin_attributes.warning_scope styp.ptyp_attributes - (fun () -> transl_type_param env styp) - - -let new_pre_univar ?name () = - let v = newvar ?name () in pre_univars := v :: !pre_univars; v + loop pat + end -let rec swap_list = function - x :: y :: l -> y :: x :: swap_list l - | l -> l -type policy = Fixed | Extensible | Univars -let rec transl_type env policy styp = - Builtin_attributes.warning_scope styp.ptyp_attributes - (fun () -> transl_type_aux env policy styp) -and transl_type_aux env policy styp = - let loc = styp.ptyp_loc in - let ctyp ctyp_desc ctyp_type = - { ctyp_desc; ctyp_type; ctyp_env = env; - ctyp_loc = loc; ctyp_attributes = styp.ptyp_attributes } - in - match styp.ptyp_desc with - Ptyp_any -> - let ty = - if policy = Univars then new_pre_univar () else - if policy = Fixed then - raise (Error (styp.ptyp_loc, env, Unbound_type_variable "_")) - else newvar () - in - ctyp Ttyp_any ty - | Ptyp_var name -> - let ty = - if name <> "" && name.[0] = '_' then - raise (Error (styp.ptyp_loc, env, Invalid_variable_name ("'" ^ name))); - begin try - instance env (List.assoc name !univars) - with Not_found -> try - instance env (fst(Tbl.find name !used_variables)) - with Not_found -> - let v = - if policy = Univars then new_pre_univar ~name () else newvar ~name () - in - used_variables := Tbl.add name (v, styp.ptyp_loc) !used_variables; - v - end - in - ctyp (Ttyp_var name) ty - | Ptyp_arrow(l, st1, st2) -> - let cty1 = transl_type env policy st1 in - let cty2 = transl_type env policy st2 in - let ty1 = cty1.ctyp_type in - let ty1 = - if Btype.is_optional l - then newty (Tconstr(Predef.path_option,[ty1], ref Mnil)) - else ty1 in - let ty = newty (Tarrow(l, ty1, cty2.ctyp_type, Cok)) in - ctyp (Ttyp_arrow (l, cty1, cty2)) ty - | Ptyp_tuple stl -> - assert (List.length stl >= 2); - let ctys = List.map (transl_type env policy) stl in - let ty = newty (Ttuple (List.map (fun ctyp -> ctyp.ctyp_type) ctys)) in - ctyp (Ttyp_tuple ctys) ty - | Ptyp_constr(lid, stl) -> - let (path, decl) = find_type env lid.loc lid.txt in - let stl = - match stl with - | [ {ptyp_desc=Ptyp_any} as t ] when decl.type_arity > 1 -> - List.map (fun _ -> t) decl.type_params - | _ -> stl - in - if List.length stl <> decl.type_arity then - raise(Error(styp.ptyp_loc, env, - Type_arity_mismatch(lid.txt, decl.type_arity, - List.length stl))); - let args = List.map (transl_type env policy) stl in - let params = instance_list decl.type_params in - let unify_param = - match decl.type_manifest with - None -> unify_var - | Some ty -> - if (repr ty).level = Btype.generic_level then unify_var else unify - in - List.iter2 - (fun (sty, cty) ty' -> - try unify_param env ty' cty.ctyp_type with Unify trace -> - raise (Error(sty.ptyp_loc, env, Type_mismatch (swap_list trace)))) - (List.combine stl args) params; - let constr = - newconstr path (List.map (fun ctyp -> ctyp.ctyp_type) args) in - begin try - Ctype.enforce_constraints env constr - with Unify trace -> - raise (Error(styp.ptyp_loc, env, Type_mismatch trace)) - end; - ctyp (Ttyp_constr (path, lid, args)) constr - | Ptyp_object (fields, o) -> - let ty, fields = transl_fields env policy o fields in - ctyp (Ttyp_object (fields, o)) (newobj ty) - | Ptyp_class(lid, stl) -> - let (path, decl, _is_variant) = - try - let path = Env.lookup_type lid.txt env in - let decl = Env.find_type path env in - let rec check decl = - match decl.type_manifest with - None -> raise Not_found - | Some ty -> - match (repr ty).desc with - Tvariant row when Btype.static_row row -> () - | Tconstr (path, _, _) -> - check (Env.find_type path env) - | _ -> raise Not_found - in check decl; - Location.deprecated styp.ptyp_loc - "old syntax for polymorphic variant type"; - (path, decl,true) - with Not_found -> try - let lid2 = - match lid.txt with - Longident.Lident s -> Longident.Lident ("#" ^ s) - | Longident.Ldot(r, s) -> Longident.Ldot (r, "#" ^ s) - | Longident.Lapply(_, _) -> fatal_error "Typetexp.transl_type" - in - let path = Env.lookup_type lid2 env in - let decl = Env.find_type path env in - (path, decl, false) - with Not_found -> - ignore (find_class env lid.loc lid.txt); assert false - in - if List.length stl <> decl.type_arity then - raise(Error(styp.ptyp_loc, env, - Type_arity_mismatch(lid.txt, decl.type_arity, - List.length stl))); - let args = List.map (transl_type env policy) stl in - let params = instance_list decl.type_params in - List.iter2 - (fun (sty, cty) ty' -> - try unify_var env ty' cty.ctyp_type with Unify trace -> - raise (Error(sty.ptyp_loc, env, Type_mismatch (swap_list trace)))) - (List.combine stl args) params; - let ty_args = List.map (fun ctyp -> ctyp.ctyp_type) args in - let ty = - try Ctype.expand_head env (newconstr path ty_args) - with Unify trace -> - raise (Error(styp.ptyp_loc, env, Type_mismatch trace)) - in - let ty = match ty.desc with - Tvariant row -> - let row = Btype.row_repr row in - let fields = - List.map - (fun (l,f) -> l, - match Btype.row_field_repr f with - | Rpresent (Some ty) -> - Reither(false, [ty], false, ref None) - | Rpresent None -> - Reither (true, [], false, ref None) - | _ -> f) - row.row_fields - in - let row = { row_closed = true; row_fields = fields; - row_bound = (); row_name = Some (path, ty_args); - row_fixed = false; row_more = newvar () } in - let static = Btype.static_row row in - let row = - if static then { row with row_more = newty Tnil } - else if policy <> Univars then row - else { row with row_more = new_pre_univar () } - in - newty (Tvariant row) - | Tobject (fi, _) -> - let _, tv = flatten_fields fi in - if policy = Univars then pre_univars := tv :: !pre_univars; - ty - | _ -> - assert false - in - ctyp (Ttyp_class (path, lid, args)) ty - | Ptyp_alias(st, alias) -> - let cty = - try - let t = - try List.assoc alias !univars - with Not_found -> - instance env (fst(Tbl.find alias !used_variables)) - in - let ty = transl_type env policy st in - begin try unify_var env t ty.ctyp_type with Unify trace -> - let trace = swap_list trace in - raise(Error(styp.ptyp_loc, env, Alias_type_mismatch trace)) - end; - ty - with Not_found -> - if !Clflags.principal then begin_def (); - let t = newvar () in - used_variables := Tbl.add alias (t, styp.ptyp_loc) !used_variables; - let ty = transl_type env policy st in - begin try unify_var env t ty.ctyp_type with Unify trace -> - let trace = swap_list trace in - raise(Error(styp.ptyp_loc, env, Alias_type_mismatch trace)) - end; - if !Clflags.principal then begin - end_def (); - generalize_structure t; - end; - let t = instance env t in - let px = Btype.proxy t in - begin match px.desc with - | Tvar None -> Btype.log_type px; px.desc <- Tvar (Some alias) - | Tunivar None -> Btype.log_type px; px.desc <- Tunivar (Some alias) - | _ -> () - end; - { ty with ctyp_type = t } - in - ctyp (Ttyp_alias (cty, alias)) cty.ctyp_type - | Ptyp_variant(fields, closed, present) -> - let name = ref None in - let mkfield l f = - newty (Tvariant {row_fields=[l,f]; row_more=newvar(); - row_bound=(); row_closed=true; - row_fixed=false; row_name=None}) in - let hfields = Hashtbl.create 17 in - let add_typed_field loc l f = - let h = Btype.hash_variant l in - try - let (l',f') = Hashtbl.find hfields h in - (* Check for tag conflicts *) - if l <> l' then raise(Error(styp.ptyp_loc, env, Variant_tags(l, l'))); - let ty = mkfield l f and ty' = mkfield l f' in - if equal env false [ty] [ty'] then () else - try unify env ty ty' - with Unify _trace -> - raise(Error(loc, env, Constructor_mismatch (ty,ty'))) - with Not_found -> - Hashtbl.add hfields h (l,f) - in - let add_field = function - Rtag (l, attrs, c, stl) -> - name := None; - let tl = - Builtin_attributes.warning_scope attrs - (fun () -> List.map (transl_type env policy) stl) - in - let f = match present with - Some present when not (List.mem l.txt present) -> - let ty_tl = List.map (fun cty -> cty.ctyp_type) tl in - Reither(c, ty_tl, false, ref None) - | _ -> - if List.length stl > 1 || c && stl <> [] then - raise(Error(styp.ptyp_loc, env, - Present_has_conjunction l.txt)); - match tl with [] -> Rpresent None - | st :: _ -> - Rpresent (Some st.ctyp_type) - in - add_typed_field styp.ptyp_loc l.txt f; - Ttag (l,attrs,c,tl) - | Rinherit sty -> - let cty = transl_type env policy sty in - let ty = cty.ctyp_type in - let nm = - match repr cty.ctyp_type with - {desc=Tconstr(p, tl, _)} -> Some(p, tl) - | _ -> None - in - begin try - (* Set name if there are no fields yet *) - Hashtbl.iter (fun _ _ -> raise Exit) hfields; - name := nm - with Exit -> - (* Unset it otherwise *) - name := None - end; - let fl = match expand_head env cty.ctyp_type, nm with - {desc=Tvariant row}, _ when Btype.static_row row -> - let row = Btype.row_repr row in - row.row_fields - | {desc=Tvar _}, Some(p, _) -> - raise(Error(sty.ptyp_loc, env, Unbound_type_constructor_2 p)) - | _ -> - raise(Error(sty.ptyp_loc, env, Not_a_variant ty)) - in - List.iter - (fun (l, f) -> - let f = match present with - Some present when not (List.mem l present) -> - begin match f with - Rpresent(Some ty) -> - Reither(false, [ty], false, ref None) - | Rpresent None -> - Reither(true, [], false, ref None) - | _ -> - assert false - end - | _ -> f - in - add_typed_field sty.ptyp_loc l f) - fl; - Tinherit cty - in - let tfields = List.map add_field fields in - let fields = Hashtbl.fold (fun _ p l -> p :: l) hfields [] in - begin match present with None -> () - | Some present -> - List.iter - (fun l -> if not (List.mem_assoc l fields) then - raise(Error(styp.ptyp_loc, env, Present_has_no_type l))) - present - end; - let row = - { row_fields = List.rev fields; row_more = newvar (); - row_bound = (); row_closed = (closed = Closed); - row_fixed = false; row_name = !name } in - let static = Btype.static_row row in - let row = - if static then { row with row_more = newty Tnil } - else if policy <> Univars then row - else { row with row_more = new_pre_univar () } - in - let ty = newty (Tvariant row) in - ctyp (Ttyp_variant (tfields, closed, present)) ty - | Ptyp_poly(vars, st) -> - let vars = List.map (fun v -> v.txt) vars in - begin_def(); - let new_univars = List.map (fun name -> name, newvar ~name ()) vars in - let old_univars = !univars in - univars := new_univars @ !univars; - let cty = transl_type env policy st in - let ty = cty.ctyp_type in - univars := old_univars; - end_def(); - generalize ty; - let ty_list = - List.fold_left - (fun tyl (name, ty1) -> - let v = Btype.proxy ty1 in - if deep_occur v ty then begin - match v.desc with - Tvar name when v.level = Btype.generic_level -> - v.desc <- Tunivar name; - v :: tyl - | _ -> - raise (Error (styp.ptyp_loc, env, Cannot_quantify (name, v))) - end else tyl) - [] new_univars - in - let ty' = Btype.newgenty (Tpoly(ty, List.rev ty_list)) in - unify_var env (newvar()) ty'; - ctyp (Ttyp_poly (vars, cty)) ty' - | Ptyp_package (p, l) -> - let l, mty = create_package_mty true styp.ptyp_loc env (p, l) in - let z = narrow () in - let mty = !transl_modtype env mty in - widen z; - let ptys = List.map (fun (s, pty) -> - s, transl_type env policy pty - ) l in - let path = !transl_modtype_longident styp.ptyp_loc env p.txt in - let ty = newty (Tpackage (path, - List.map (fun (s, _pty) -> s.txt) l, - List.map (fun (_,cty) -> cty.ctyp_type) ptys)) - in - ctyp (Ttyp_package { - pack_path = path; - pack_type = mty.mty_type; - pack_fields = ptys; - pack_txt = p; - }) ty - | Ptyp_extension ext -> - raise (Error_forward (Builtin_attributes.error_of_extension ext)) -and transl_poly_type env policy t = - transl_type env policy (Ast_helper.Typ.force_poly t) -and transl_fields env policy o fields = - let hfields = Hashtbl.create 17 in - let add_typed_field loc l ty = - try - let ty' = Hashtbl.find hfields l in - if equal env false [ty] [ty'] then () else - try unify env ty ty' - with Unify _trace -> - raise(Error(loc, env, Method_mismatch (l, ty, ty'))) - with Not_found -> - Hashtbl.add hfields l ty in - let add_field = function - | Otag (s, a, ty1) -> begin - let ty1 = - Builtin_attributes.warning_scope a - (fun () -> transl_poly_type env policy ty1) - in - let field = OTtag (s, a, ty1) in - add_typed_field ty1.ctyp_loc s.txt ty1.ctyp_type; - field - end - | Oinherit sty -> begin - let cty = transl_type env policy sty in - let nm = - match repr cty.ctyp_type with - {desc=Tconstr(p, _, _)} -> Some p - | _ -> None in - let t = expand_head env cty.ctyp_type in - match t, nm with - {desc=Tobject ({desc=(Tfield _ | Tnil) as tf}, _)}, _ -> begin - if opened_object t then - raise (Error (sty.ptyp_loc, env, Opened_object nm)); - let rec iter_add = function - | Tfield (s, _k, ty1, ty2) -> begin - add_typed_field sty.ptyp_loc s ty1; - iter_add ty2.desc - end - | Tnil -> () - | _ -> assert false in - iter_add tf; - OTinherit cty - end - | {desc=Tvar _}, Some p -> - raise (Error (sty.ptyp_loc, env, Unbound_type_constructor_2 p)) - | _ -> raise (Error (sty.ptyp_loc, env, Not_an_object t)) - end in - let object_fields = List.map add_field fields in - let fields = Hashtbl.fold (fun s ty l -> (s, ty) :: l) hfields [] in - let ty_init = - match o, policy with - | Closed, _ -> newty Tnil - | Open, Univars -> new_pre_univar () - | Open, _ -> newvar () in - let ty = List.fold_left (fun ty (s, ty') -> - newty (Tfield (s, Fpresent, ty', ty))) ty_init fields in - ty, object_fields +(*********************************) +(* Exported exhaustiveness check *) +(*********************************) -(* Make the rows "fixed" in this type, to make universal check easier *) -let rec make_fixed_univars ty = - let ty = repr ty in - if ty.level >= Btype.lowest_level then begin - Btype.mark_type_node ty; - match ty.desc with - | Tvariant row -> - let row = Btype.row_repr row in - if Btype.is_Tunivar (Btype.row_more row) then - ty.desc <- Tvariant - {row with row_fixed=true; - row_fields = List.map - (fun (s,f as p) -> match Btype.row_field_repr f with - Reither (c, tl, _m, r) -> s, Reither (c, tl, true, r) - | _ -> p) - row.row_fields}; - Btype.iter_row make_fixed_univars row - | _ -> - Btype.iter_type_expr make_fixed_univars ty - end +(* + Fragile check is performed when required and + on exhaustive matches only. +*) -let make_fixed_univars ty = - make_fixed_univars ty; - Btype.unmark_type ty +let check_partial_param do_check_partial do_check_fragile loc casel = + let pss = initial_matrix casel in + let pss = get_mins le_pats pss in + let total = do_check_partial loc casel pss in + if + total = Total && Warnings.is_active (Warnings.Fragile_match "") + then begin + do_check_fragile loc casel pss + end ; + total -let create_package_mty = create_package_mty false +(*let check_partial = + check_partial_param + do_check_partial_normal + do_check_fragile_normal*) -let globalize_used_variables env fixed = - let r = ref [] in - Tbl.iter - (fun name (ty, loc) -> - let v = new_global_var () in - let snap = Btype.snapshot () in - if try unify env v ty; true with _ -> Btype.backtrack snap; false - then try - r := (loc, v, Tbl.find name !type_variables) :: !r - with Not_found -> - if fixed && Btype.is_Tvar (repr ty) then - raise(Error(loc, env, Unbound_type_variable ("'"^name))); - let v2 = new_global_var () in - r := (loc, v, v2) :: !r; - type_variables := Tbl.add name v2 !type_variables) - !used_variables; - used_variables := Tbl.empty; - fun () -> - List.iter - (function (loc, t1, t2) -> - try unify env t1 t2 with Unify trace -> - raise (Error(loc, env, Type_mismatch trace))) - !r +let check_partial_gadt pred loc casel = + check_partial_param (do_check_partial_gadt pred) + do_check_fragile_gadt loc casel -let transl_simple_type env fixed styp = - univars := []; used_variables := Tbl.empty; - let typ = transl_type env (if fixed then Fixed else Extensible) styp in - globalize_used_variables env fixed (); - make_fixed_univars typ.ctyp_type; - typ -let transl_simple_type_univars env styp = - univars := []; used_variables := Tbl.empty; pre_univars := []; - begin_def (); - let typ = transl_type env Univars styp in - (* Only keep already global variables in used_variables *) - let new_variables = !used_variables in - used_variables := Tbl.empty; - Tbl.iter - (fun name p -> - if Tbl.mem name !type_variables then - used_variables := Tbl.add name p !used_variables) - new_variables; - globalize_used_variables env false (); - end_def (); - generalize typ.ctyp_type; - let univs = - List.fold_left - (fun acc v -> - let v = repr v in - match v.desc with - Tvar name when v.level = Btype.generic_level -> - v.desc <- Tunivar name; v :: acc - | _ -> acc) - [] !pre_univars - in - make_fixed_univars typ.ctyp_type; - { typ with ctyp_type = - instance env (Btype.newgenty (Tpoly (typ.ctyp_type, univs))) } +(*************************************) +(* Ambiguous variable in or-patterns *) +(*************************************) -let transl_simple_type_delayed env styp = - univars := []; used_variables := Tbl.empty; - let typ = transl_type env Extensible styp in - make_fixed_univars typ.ctyp_type; - (typ, globalize_used_variables env false) +(* Specification: ambiguous variables in or-patterns. -let transl_type_scheme env styp = - reset_type_variables(); - begin_def(); - let typ = transl_simple_type env false styp in - end_def(); - generalize typ.ctyp_type; - typ + The semantics of or-patterns in OCaml is specified with + a left-to-right bias: a value [v] matches the pattern [p | q] if it + matches [p] or [q], but if it matches both, the environment + captured by the match is the environment captured by [p], never the + one captured by [q]. + While this property is generally well-understood, one specific case + where users expect a different semantics is when a pattern is + followed by a when-guard: [| p when g -> e]. Consider for example: -(* Error report *) + | ((Const x, _) | (_, Const x)) when is_neutral x -> branch -open Format -open Printtyp + The semantics is clear: match the scrutinee against the pattern, if + it matches, test the guard, and if the guard passes, take the + branch. -let spellcheck ppf fold env lid = - let choices ~path name = - let env = fold (fun x xs -> x::xs) path env [] in - Misc.spellcheck env name in - match lid with - | Longident.Lapply _ -> () - | Longident.Lident s -> - Misc.did_you_mean ppf (fun () -> choices ~path:None s) - | Longident.Ldot (r, s) -> - Misc.did_you_mean ppf (fun () -> choices ~path:(Some r) s) + However, consider the input [(Const a, Const b)], where [a] fails + the test [is_neutral f], while [b] passes the test [is_neutral + b]. With the left-to-right semantics, the clause above is *not* + taken by its input: matching [(Const a, Const b)] against the + or-pattern succeeds in the left branch, it returns the environment + [x -> a], and then the guard [is_neutral a] is tested and fails, + the branch is not taken. Most users, however, intuitively expect + that any pair that has one side passing the test will take the + branch. They assume it is equivalent to the following: -let fold_descr fold get_name f = fold (fun descr acc -> f (get_name descr) acc) -let fold_simple fold4 f = fold4 (fun name _path _descr acc -> f name acc) + | (Const x, _) when is_neutral x -> branch + | (_, Const x) when is_neutral x -> branch -let fold_values = fold_simple Env.fold_values -let fold_types = fold_simple Env.fold_types -let fold_modules = fold_simple Env.fold_modules -let fold_constructors = fold_descr Env.fold_constructors (fun d -> d.cstr_name) -let fold_labels = fold_descr Env.fold_labels (fun d -> d.lbl_name) -let fold_classs = fold_simple Env.fold_classs -let fold_modtypes = fold_simple Env.fold_modtypes -let fold_cltypes = fold_simple Env.fold_cltypes + while it is not. -let report_error env ppf = function - | Unbound_type_variable name -> - (* we don't use "spellcheck" here: the function that raises this - error seems not to be called anywhere, so it's unclear how it - should be handled *) - fprintf ppf "Unbound type parameter %s@." name - | Unbound_type_constructor lid -> - fprintf ppf "Unbound type constructor %a" longident lid; - spellcheck ppf fold_types env lid; - | Unbound_type_constructor_2 p -> - fprintf ppf "The type constructor@ %a@ is not yet completely defined" - path p - | Type_arity_mismatch(lid, expected, provided) -> - fprintf ppf - "@[The type constructor %a@ expects %i argument(s),@ \ - but is here applied to %i argument(s)@]" - longident lid expected provided - | Bound_type_variable name -> - fprintf ppf "Already bound type parameter '%s" name - | Recursive_type -> - fprintf ppf "This type is recursive" - | Unbound_row_variable lid -> - (* we don't use "spellcheck" here: this error is not raised - anywhere so it's unclear how it should be handled *) - fprintf ppf "Unbound row variable in #%a" longident lid - | Type_mismatch trace -> - Printtyp.report_unification_error ppf Env.empty trace - (function ppf -> - fprintf ppf "This type") - (function ppf -> - fprintf ppf "should be an instance of type") - | Alias_type_mismatch trace -> - Printtyp.report_unification_error ppf Env.empty trace - (function ppf -> - fprintf ppf "This alias is bound to type") - (function ppf -> - fprintf ppf "but is used as an instance of type") - | Present_has_conjunction l -> - fprintf ppf "The present constructor %s has a conjunctive type" l - | Present_has_no_type l -> - fprintf ppf "The present constructor %s has no type" l - | Constructor_mismatch (ty, ty') -> - wrap_printing_env env (fun () -> - Printtyp.reset_and_mark_loops_list [ty; ty']; - fprintf ppf "@[%s %a@ %s@ %a@]" - "This variant type contains a constructor" - Printtyp.type_expr ty - "which should be" - Printtyp.type_expr ty') - | Not_a_variant ty -> - Printtyp.reset_and_mark_loops ty; - fprintf ppf - "@[The type %a@ does not expand to a polymorphic variant type@]" - Printtyp.type_expr ty; - begin match ty.desc with - | Tvar (Some s) -> - (* PR#7012: help the user that wrote 'Foo instead of `Foo *) - Misc.did_you_mean ppf (fun () -> ["`" ^ s]) - | _ -> () + The code below is dedicated to finding these confusing cases: the + cases where a guard uses "ambiguous" variables, that are bound to + different parts of the scrutinees by different sides of + a or-pattern. In other words, it finds the cases where the + specified left-to-right semantics is not equivalent to + a non-deterministic semantics (any branch can be taken) relatively + to a specific guard. +*) + +module IdSet = Set.Make(Ident) + +let pattern_vars p = IdSet.of_list (Typedtree.pat_bound_idents p) + +(* Row for ambiguous variable search, + unseen is the traditional pattern row, + seen is a list of position bindings *) + +type amb_row = { unseen : pattern list ; seen : IdSet.t list; } + + +(* Push binding variables now *) + +let rec do_push r p ps seen k = match p.pat_desc with +| Tpat_alias (p,x,_) -> do_push (IdSet.add x r) p ps seen k +| Tpat_var (x,_) -> + (omega,{ unseen = ps; seen=IdSet.add x r::seen; })::k +| Tpat_or (p1,p2,_) -> + do_push r p1 ps seen (do_push r p2 ps seen k) +| _ -> + (p,{ unseen = ps; seen = r::seen; })::k + +let rec push_vars = function + | [] -> [] + | { unseen = [] }::_ -> assert false + | { unseen = p::ps; seen; }::rem -> + do_push IdSet.empty p ps seen (push_vars rem) + +let collect_stable = function + | [] -> assert false + | { seen=xss; _}::rem -> + let rec c_rec xss = function + | [] -> xss + | {seen=yss; _}::rem -> + let xss = List.map2 IdSet.inter xss yss in + c_rec xss rem in + let inters = c_rec xss rem in + List.fold_left IdSet.union IdSet.empty inters + + +(*********************************************) +(* Filtering utilities for our specific rows *) +(*********************************************) + +(* Take a pattern matrix as a list (rows) of lists (columns) of patterns + | p1, p2, .., pn + | q1, q2, .., qn + | r1, r2, .., rn + | ... + + We split this matrix into a list of sub-matrices, one for each head + constructor appearing in the leftmost column. For each row whose + left column starts with a head constructor, remove this head + column, prepend one column for each argument of the constructor, + and add the resulting row in the sub-matrix corresponding to this + head constructor. + + Rows whose left column is omega (the Any pattern _) may match any + head constructor, so they are added to all groups. + + The list of sub-matrices is represented as a list of pair + (head constructor, submatrix) +*) + +let filter_all = + (* the head constructor (as a pattern with omega arguments) of + a pattern *) + let discr_head pat = + match pat.pat_desc with + | Tpat_record (lbls, closed) -> + (* a partial record pattern { f1 = p1; f2 = p2; _ } + needs to be expanded, otherwise matching against this head + would drop the pattern arguments for non-mentioned fields *) + let lbls = all_record_args lbls in + normalize_pat { pat with pat_desc = Tpat_record (lbls, closed) } + | _ -> normalize_pat pat + in + + (* insert a row of head [p] and rest [r] into the right group *) + let rec insert p r env = match env with + | [] -> + (* if no group matched this row, it has a head constructor that + was never seen before; add a new sub-matrix for this head *) + let p0 = discr_head p in + [p0,[{ r with unseen = simple_match_args p0 p @ r.unseen }]] + | (q0,rs) as bd::env -> + if simple_match q0 p then begin + let r = { r with unseen = simple_match_args q0 p@r.unseen; } in + (q0,r::rs)::env end - | Variant_tags (lab1, lab2) -> - fprintf ppf - "@[Variant tags `%s@ and `%s have the same hash value.@ %s@]" - lab1 lab2 "Change one of them." - | Invalid_variable_name name -> - fprintf ppf "The type variable name %s is not allowed in programs" name - | Cannot_quantify (name, v) -> - fprintf ppf - "@[The universal type variable '%s cannot be generalized:@ %s.@]" - name - (if Btype.is_Tvar v then "it escapes its scope" else - if Btype.is_Tunivar v then "it is already bound to another variable" - else "it is not a variable") - | Multiple_constraints_on_type s -> - fprintf ppf "Multiple constraints for type %a" longident s - | Method_mismatch (l, ty, ty') -> - wrap_printing_env env (fun () -> - Printtyp.reset_and_mark_loops_list [ty; ty']; - fprintf ppf "@[Method '%s' has type %a,@ which should be %a@]" - l Printtyp.type_expr ty Printtyp.type_expr ty') - | Unbound_value lid -> - fprintf ppf "Unbound value %a" longident lid; - spellcheck ppf fold_values env lid; - | Unbound_module lid -> - fprintf ppf "Unbound module %a" longident lid; - spellcheck ppf fold_modules env lid; - | Unbound_constructor lid -> - fprintf ppf "Unbound constructor %a" longident lid; - spellcheck ppf fold_constructors env lid; - | Unbound_label lid -> - fprintf ppf "Unbound record field %a" longident lid; - spellcheck ppf fold_labels env lid; - | Unbound_class lid -> - fprintf ppf "Unbound class %a" longident lid; - spellcheck ppf fold_classs env lid; - | Unbound_modtype lid -> - fprintf ppf "Unbound module type %a" longident lid; - spellcheck ppf fold_modtypes env lid; - | Unbound_cltype lid -> - fprintf ppf "Unbound class type %a" longident lid; - spellcheck ppf fold_cltypes env lid; - | Ill_typed_functor_application lid -> - fprintf ppf "Ill-typed functor application %a" longident lid - | Illegal_reference_to_recursive_module -> - fprintf ppf "Illegal recursive module reference" - | Access_functor_as_structure lid -> - fprintf ppf "The module %a is a functor, not a structure" longident lid - | Apply_structure_as_functor lid -> - fprintf ppf "The module %a is a structure, not a functor" longident lid - | Cannot_scrape_alias(lid, p) -> - fprintf ppf - "The module %a is an alias for module %a, which is missing" - longident lid path p - | Opened_object nm -> - fprintf ppf - "Illegal open object type%a" - (fun ppf -> function - Some p -> fprintf ppf "@ %a" path p - | None -> fprintf ppf "") nm - | Not_an_object ty -> - Printtyp.reset_and_mark_loops ty; - fprintf ppf "@[The type %a@ is not an object type@]" - Printtyp.type_expr ty + else bd::insert p r env in + + (* insert a row of head omega into all groups *) + let insert_omega r env = + List.map + (fun (q0,rs) -> + let r = + { r with unseen = simple_match_args q0 omega @ r.unseen; } in + (q0,r::rs)) + env + in + + let rec filter_rec env = function + | [] -> env + | ({pat_desc=(Tpat_var _|Tpat_alias _|Tpat_or _)},_)::_ -> assert false + | ({pat_desc=Tpat_any}, _)::rs -> filter_rec env rs + | (p,r)::rs -> filter_rec (insert p r env) rs in + + let rec filter_omega env = function + | [] -> env + | ({pat_desc=(Tpat_var _|Tpat_alias _|Tpat_or _)},_)::_ -> assert false + | ({pat_desc=Tpat_any},r)::rs -> filter_omega (insert_omega r env) rs + | _::rs -> filter_omega env rs in + + fun rs -> + (* first insert the rows with head constructors, + to get the definitive list of groups *) + let env = filter_rec [] rs in + (* then add the omega rows to all groups *) + filter_omega env rs + +(* Compute stable bindings *) + +let rec do_stable rs = match rs with +| [] -> assert false (* No empty matrix *) +| { unseen=[]; _ }::_ -> + collect_stable rs +| _ -> + let rs = push_vars rs in + if not (all_coherent (first_column rs)) then begin + (* If the first column is incoherent, then all the variables of this + matrix are stable. *) + List.fold_left (fun acc (_, { seen; _ }) -> + List.fold_left IdSet.union acc seen + ) IdSet.empty rs + end else begin + (* If the column is ill-typed but deemed coherent, we might spuriously + warn about some variables being unstable. + As sad as that might be, the warning can be silenced by splitting the + or-pattern... *) + match filter_all rs with + | [] -> + do_stable (List.map snd rs) + | (_,rs)::env -> + List.fold_left + (fun xs (_,rs) -> IdSet.inter xs (do_stable rs)) + (do_stable rs) env + end + +let stable p = do_stable [{unseen=[p]; seen=[];}] + + +(* All identifier paths that appear in an expression that occurs + as a clause right hand side or guard. + + The function is rather complex due to the compilation of + unpack patterns by introducing code in rhs expressions + and **guards**. -let () = - Location.register_error_of_exn - (function - | Error (loc, env, err) -> - Some (Location.error_of_printer loc (report_error env) err) - | Error_forward err -> - Some err - | _ -> - None - ) + For pattern (module M:S) -> e the code is + let module M_mod = unpack M .. in e + + Hence M is "free" in e iff M_mod is free in e. + + Not doing so will yield excessive warning in + (module (M:S) } ...) when true -> .... + as M is always present in + let module M_mod = unpack M .. in true +*) + +let all_rhs_idents exp = + let ids = ref IdSet.empty in + let module Iterator = TypedtreeIter.MakeIterator(struct + include TypedtreeIter.DefaultIteratorArgument + let enter_expression exp = match exp.exp_desc with + | Texp_ident (path, _lid, _descr) -> + List.iter + (fun id -> ids := IdSet.add id !ids) + (Path.heads path) + | _ -> () + +(* Very hackish, detect unpack pattern compilation + and perform "indirect check for them" *) + let is_unpack exp = + List.exists + (fun (attr, _) -> attr.txt = "#modulepat") exp.exp_attributes + + let leave_expression exp = + if is_unpack exp then begin match exp.exp_desc with + | Texp_letmodule + (id_mod,_, + {mod_desc= + Tmod_unpack ({exp_desc=Texp_ident (Path.Pident id_exp,_,_)},_)}, + _) -> + assert (IdSet.mem id_exp !ids) ; + if not (IdSet.mem id_mod !ids) then begin + ids := IdSet.remove id_exp !ids + end + | _ -> assert false + end + end) in + Iterator.iter_expression exp; + !ids + +let check_ambiguous_bindings = + let open Warnings in + let warn0 = Ambiguous_pattern [] in + fun cases -> + if is_active warn0 then + List.iter + (fun case -> match case with + | { c_guard=None ; _} -> () + | { c_lhs=p; c_guard=Some g; _} -> + let all = + IdSet.inter (pattern_vars p) (all_rhs_idents g) in + if not (IdSet.is_empty all) then begin + let st = stable p in + let ambiguous = IdSet.diff all st in + if not (IdSet.is_empty ambiguous) then begin + let pps = IdSet.elements ambiguous |> List.map Ident.name in + let warn = Ambiguous_pattern pps in + Location.prerr_warning p.pat_loc warn + end + end) + cases end -module Typedecl : sig -#1 "typedecl.mli" +module Ast_iterator : sig +#1 "ast_iterator.mli" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* Nicolas Ojeda Bar, LexiFi *) (* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* Copyright 2012 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -60433,107 +60013,73 @@ module Typedecl : sig (* *) (**************************************************************************) -(* Typing of type definitions and primitive definitions *) - -open Types -open Format - -val transl_type_decl: - Env.t -> Asttypes.rec_flag -> Parsetree.type_declaration list -> - Typedtree.type_declaration list * Env.t - -val transl_exception: - Env.t -> - Parsetree.extension_constructor -> Typedtree.extension_constructor * Env.t - -val transl_type_extension: - bool -> Env.t -> Location.t -> Parsetree.type_extension -> - Typedtree.type_extension * Env.t - -val transl_value_decl: - Env.t -> Location.t -> - Parsetree.value_description -> Typedtree.value_description * Env.t - -val transl_with_constraint: - Env.t -> Ident.t -> Path.t option -> Types.type_declaration -> - Parsetree.type_declaration -> Typedtree.type_declaration - -val abstract_type_decl: int -> type_declaration -val approx_type_decl: - Parsetree.type_declaration list -> - (Ident.t * type_declaration) list -val check_recmod_typedecl: - Env.t -> Location.t -> Ident.t list -> Path.t -> type_declaration -> unit -val check_coherence: - Env.t -> Location.t -> Ident.t -> type_declaration -> unit - -(* for fixed types *) -val is_fixed_type : Parsetree.type_declaration -> bool - -(* for typeclass.ml *) -val compute_variance_decls: - Env.t -> - (Ident.t * Types.type_declaration * Types.type_declaration * - Types.class_declaration * Types.class_type_declaration * - 'a Typedtree.class_infos) list -> - (Types.type_declaration * Types.type_declaration * - Types.class_declaration * Types.class_type_declaration) list - -(* for typeopt.ml *) -val get_unboxed_type_representation: Env.t -> type_expr -> type_expr option - +(** {!iterator} allows to implement AST inspection using open recursion. A + typical mapper would be based on {!default_iterator}, a trivial iterator, + and will fall back on it for handling the syntax it does not modify. *) -type native_repr_kind = Unboxed | Untagged +open Parsetree -type error = - Repeated_parameter - | Duplicate_constructor of string - | Too_many_constructors - | Duplicate_label of string - | Recursive_abbrev of string - | Cycle_in_def of string * type_expr - | Definition_mismatch of type_expr * Includecore.type_mismatch list - | Constraint_failed of type_expr * type_expr - | Inconsistent_constraint of Env.t * (type_expr * type_expr) list - | Type_clash of Env.t * (type_expr * type_expr) list - | Parameters_differ of Path.t * type_expr * type_expr - | Null_arity_external - | Missing_native_external - | Unbound_type_var of type_expr * type_declaration - | Cannot_extend_private_type of Path.t - | Not_extensible_type of Path.t - | Extension_mismatch of Path.t * Includecore.type_mismatch list - | Rebind_wrong_type of Longident.t * Env.t * (type_expr * type_expr) list - | Rebind_mismatch of Longident.t * Path.t * Path.t - | Rebind_private of Longident.t - | Bad_variance of int * (bool*bool*bool) * (bool*bool*bool) - | Unavailable_type_constructor of Path.t - | Bad_fixed_type of string - | Unbound_type_var_ext of type_expr * extension_constructor - | Varying_anonymous - | Val_in_structure - | Multiple_native_repr_attributes - | Cannot_unbox_or_untag_type of native_repr_kind - | Deep_unbox_or_untag_attribute of native_repr_kind - | Bad_immediate_attribute - | Bad_unboxed_attribute of string - | Wrong_unboxed_type_float - | Boxed_and_unboxed - | Nonrec_gadt +(** {1 A generic Parsetree iterator} *) -exception Error of Location.t * error +type iterator = { + attribute: iterator -> attribute -> unit; + attributes: iterator -> attribute list -> unit; + case: iterator -> case -> unit; + cases: iterator -> case list -> unit; + class_declaration: iterator -> class_declaration -> unit; + class_description: iterator -> class_description -> unit; + class_expr: iterator -> class_expr -> unit; + class_field: iterator -> class_field -> unit; + class_signature: iterator -> class_signature -> unit; + class_structure: iterator -> class_structure -> unit; + class_type: iterator -> class_type -> unit; + class_type_declaration: iterator -> class_type_declaration -> unit; + class_type_field: iterator -> class_type_field -> unit; + constructor_declaration: iterator -> constructor_declaration -> unit; + expr: iterator -> expression -> unit; + extension: iterator -> extension -> unit; + extension_constructor: iterator -> extension_constructor -> unit; + include_declaration: iterator -> include_declaration -> unit; + include_description: iterator -> include_description -> unit; + label_declaration: iterator -> label_declaration -> unit; + location: iterator -> Location.t -> unit; + module_binding: iterator -> module_binding -> unit; + module_declaration: iterator -> module_declaration -> unit; + module_expr: iterator -> module_expr -> unit; + module_type: iterator -> module_type -> unit; + module_type_declaration: iterator -> module_type_declaration -> unit; + open_description: iterator -> open_description -> unit; + pat: iterator -> pattern -> unit; + payload: iterator -> payload -> unit; + signature: iterator -> signature -> unit; + signature_item: iterator -> signature_item -> unit; + structure: iterator -> structure -> unit; + structure_item: iterator -> structure_item -> unit; + typ: iterator -> core_type -> unit; + type_declaration: iterator -> type_declaration -> unit; + type_extension: iterator -> type_extension -> unit; + type_kind: iterator -> type_kind -> unit; + value_binding: iterator -> value_binding -> unit; + value_description: iterator -> value_description -> unit; + with_constraint: iterator -> with_constraint -> unit; +} +(** A [iterator] record implements one "method" per syntactic category, + using an open recursion style: each method takes as its first + argument the iterator to be applied to children in the syntax + tree. *) -val report_error: formatter -> error -> unit +val default_iterator: iterator +(** A default iterator, which implements a "do not do anything" mapping. *) end = struct -#1 "typedecl.ml" +#1 "ast_iterator.ml" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Xavier Leroy and Jerome Vouillon, projet Cristal, INRIA Rocquencourt *) +(* Nicolas Ojeda Bar, LexiFi *) (* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* Copyright 2012 Institut National de Recherche en Informatique et *) (* en Automatique. *) (* *) (* All rights reserved. This file is distributed under the terms of *) @@ -60542,2641 +60088,1832 @@ end = struct (* *) (**************************************************************************) -(**** Typing of type definitions ****) - -open Misc -open Asttypes -open Parsetree -open Primitive -open Types -open Typetexp - -type native_repr_kind = Unboxed | Untagged - -type error = - Repeated_parameter - | Duplicate_constructor of string - | Too_many_constructors - | Duplicate_label of string - | Recursive_abbrev of string - | Cycle_in_def of string * type_expr - | Definition_mismatch of type_expr * Includecore.type_mismatch list - | Constraint_failed of type_expr * type_expr - | Inconsistent_constraint of Env.t * (type_expr * type_expr) list - | Type_clash of Env.t * (type_expr * type_expr) list - | Parameters_differ of Path.t * type_expr * type_expr - | Null_arity_external - | Missing_native_external - | Unbound_type_var of type_expr * type_declaration - | Cannot_extend_private_type of Path.t - | Not_extensible_type of Path.t - | Extension_mismatch of Path.t * Includecore.type_mismatch list - | Rebind_wrong_type of Longident.t * Env.t * (type_expr * type_expr) list - | Rebind_mismatch of Longident.t * Path.t * Path.t - | Rebind_private of Longident.t - | Bad_variance of int * (bool * bool * bool) * (bool * bool * bool) - | Unavailable_type_constructor of Path.t - | Bad_fixed_type of string - | Unbound_type_var_ext of type_expr * extension_constructor - | Varying_anonymous - | Val_in_structure - | Multiple_native_repr_attributes - | Cannot_unbox_or_untag_type of native_repr_kind - | Deep_unbox_or_untag_attribute of native_repr_kind - | Bad_immediate_attribute - | Bad_unboxed_attribute of string - | Wrong_unboxed_type_float - | Boxed_and_unboxed - | Nonrec_gadt - -open Typedtree - -exception Error of Location.t * error - -(* Note: do not factor the branches in the following pattern-matching: - the records must be constants for the compiler to do sharing on them. -*) -let get_unboxed_from_attributes sdecl = - - if !Clflags.bs_only then unboxed_false_default_false - else - - let unboxed = Builtin_attributes.has_unboxed sdecl.ptype_attributes in - let boxed = Builtin_attributes.has_boxed sdecl.ptype_attributes in - match boxed, unboxed, !Clflags.unboxed_types with - | true, true, _ -> raise (Error(sdecl.ptype_loc, Boxed_and_unboxed)) - | true, false, _ -> unboxed_false_default_false - | false, true, _ -> unboxed_true_default_false - | false, false, false -> unboxed_false_default_true - | false, false, true -> unboxed_true_default_true - -(* Enter all declared types in the environment as abstract types *) - -let enter_type rec_flag env sdecl id = - let needed = - match rec_flag with - | Asttypes.Nonrecursive -> - begin match sdecl.ptype_kind with - | Ptype_variant scds -> - List.iter (fun cd -> - if cd.pcd_res <> None then raise (Error(cd.pcd_loc, Nonrec_gadt))) - scds - | _ -> () - end; - Btype.is_row_name (Ident.name id) - | Asttypes.Recursive -> true - in - if not needed then env else - let decl = - { type_params = - List.map (fun _ -> Btype.newgenvar ()) sdecl.ptype_params; - type_arity = List.length sdecl.ptype_params; - type_kind = Type_abstract; - type_private = sdecl.ptype_private; - type_manifest = - begin match sdecl.ptype_manifest with None -> None - | Some _ -> Some(Ctype.newvar ()) end; - type_variance = List.map (fun _ -> Variance.full) sdecl.ptype_params; - type_newtype_level = None; - type_loc = sdecl.ptype_loc; - type_attributes = sdecl.ptype_attributes; - type_immediate = false; - type_unboxed = unboxed_false_default_false; - } - in - Env.add_type ~check:true id decl env - -let update_type temp_env env id loc = - let path = Path.Pident id in - let decl = Env.find_type path temp_env in - match decl.type_manifest with None -> () - | Some ty -> - let params = List.map (fun _ -> Ctype.newvar ()) decl.type_params in - try Ctype.unify env (Ctype.newconstr path params) ty - with Ctype.Unify trace -> - raise (Error(loc, Type_clash (env, trace))) - -(* We use the Ctype.expand_head_opt version of expand_head to get access - to the manifest type of private abbreviations. *) -let rec get_unboxed_type_representation env ty fuel = - if fuel < 0 then None else - let ty = Ctype.repr (Ctype.expand_head_opt env ty) in - match ty.desc with - | Tconstr (p, args, _) -> - begin match Env.find_type p env with - | exception Not_found -> Some ty - | {type_unboxed = {unboxed = false}} -> Some ty - | {type_params; type_kind = - Type_record ([{ld_type = ty2; _}], _) - | Type_variant [{cd_args = Cstr_tuple [ty2]; _}] - | Type_variant [{cd_args = Cstr_record [{ld_type = ty2; _}]; _}]} - - -> get_unboxed_type_representation env - (Ctype.apply env type_params ty2 args) (fuel - 1) - | {type_kind=Type_abstract} -> None - (* This case can occur when checking a recursive unboxed type - declaration. *) - | _ -> assert false (* only the above can be unboxed *) - end - | _ -> Some ty - -let get_unboxed_type_representation env ty = - (* Do not give too much fuel: PR#7424 *) - get_unboxed_type_representation env ty 100 -;; - -(* Determine if a type's values are represented by floats at run-time. *) -let is_float env ty = - match get_unboxed_type_representation env ty with - Some {desc = Tconstr(p, _, _); _} -> Path.same p Predef.path_float - | _ -> false - -(* Determine if a type definition defines a fixed type. (PW) *) -let is_fixed_type sd = - let rec has_row_var sty = - match sty.ptyp_desc with - Ptyp_alias (sty, _) -> has_row_var sty - | Ptyp_class _ - | Ptyp_object (_, Open) - | Ptyp_variant (_, Open, _) - | Ptyp_variant (_, Closed, Some _) -> true - | _ -> false - in - match sd.ptype_manifest with - None -> false - | Some sty -> - sd.ptype_kind = Ptype_abstract && - sd.ptype_private = Private && - has_row_var sty - -(* Set the row variable in a fixed type *) -let set_fixed_row env loc p decl = - let tm = - match decl.type_manifest with - None -> assert false - | Some t -> Ctype.expand_head env t - in - let rv = - match tm.desc with - Tvariant row -> - let row = Btype.row_repr row in - tm.desc <- Tvariant {row with row_fixed = true}; - if Btype.static_row row then Btype.newgenty Tnil - else row.row_more - | Tobject (ty, _) -> - snd (Ctype.flatten_fields ty) - | _ -> - raise (Error (loc, Bad_fixed_type "is not an object or variant")) - in - if not (Btype.is_Tvar rv) then - raise (Error (loc, Bad_fixed_type "has no row variable")); - rv.desc <- Tconstr (p, decl.type_params, ref Mnil) - -(* Translate one type declaration *) - -module StringSet = - Set.Make(struct - type t = string - let compare (x:t) y = compare x y - end) - -let make_params env params = - let make_param (sty, v) = - try - (transl_type_param env sty, v) - with Already_bound -> - raise(Error(sty.ptyp_loc, Repeated_parameter)) - in - List.map make_param params - -let transl_labels env closed lbls = - assert (lbls <> []); - let all_labels = ref StringSet.empty in - List.iter - (fun {pld_name = {txt=name; loc}} -> - if StringSet.mem name !all_labels then - raise(Error(loc, Duplicate_label name)); - all_labels := StringSet.add name !all_labels) - lbls; - let mk {pld_name=name;pld_mutable=mut;pld_type=arg;pld_loc=loc; - pld_attributes=attrs} = - Builtin_attributes.warning_scope attrs - (fun () -> - let arg = Ast_helper.Typ.force_poly arg in - let cty = transl_simple_type env closed arg in - {ld_id = Ident.create name.txt; ld_name = name; ld_mutable = mut; - ld_type = cty; ld_loc = loc; ld_attributes = attrs} - ) - in - let lbls = List.map mk lbls in - let lbls' = - List.map - (fun ld -> - let ty = ld.ld_type.ctyp_type in - let ty = match ty.desc with Tpoly(t,[]) -> t | _ -> ty in - {Types.ld_id = ld.ld_id; - ld_mutable = ld.ld_mutable; - ld_type = ty; - ld_loc = ld.ld_loc; - ld_attributes = ld.ld_attributes - } - ) - lbls in - lbls, lbls' - -let transl_constructor_arguments env closed = function - | Pcstr_tuple l -> - let l = List.map (transl_simple_type env closed) l in - Types.Cstr_tuple (List.map (fun t -> t.ctyp_type) l), - Cstr_tuple l - | Pcstr_record l -> - let lbls, lbls' = transl_labels env closed l in - Types.Cstr_record lbls', - Cstr_record lbls - -let make_constructor env type_path type_params sargs sret_type = - match sret_type with - | None -> - let args, targs = - transl_constructor_arguments env true sargs - in - targs, None, args, None, type_params - | Some sret_type -> - (* if it's a generalized constructor we must first narrow and - then widen so as to not introduce any new constraints *) - let z = narrow () in - reset_type_variables (); - let args, targs = - transl_constructor_arguments env false sargs - in - let tret_type = transl_simple_type env false sret_type in - let ret_type = tret_type.ctyp_type in - let params = - match (Ctype.repr ret_type).desc with - | Tconstr (p', params, _) when Path.same type_path p' -> - params - | _ -> - raise (Error (sret_type.ptyp_loc, Constraint_failed - (ret_type, Ctype.newconstr type_path type_params))) - in - widen z; - targs, Some tret_type, args, Some ret_type, params - -(* Check that the variable [id] is present in the [univ] list. *) -let check_type_var loc univ id = - let f t = (Btype.repr t).id = id in - if not (List.exists f univ) then raise (Error (loc, Wrong_unboxed_type_float)) +(* A generic Parsetree mapping class *) -(* Check that all the variables found in [ty] are in [univ]. - Because [ty] is the argument to an abstract type, the representation - of that abstract type could be any subexpression of [ty], in particular - any type variable present in [ty]. +(* +[@@@ocaml.warning "+9"] + (* Ensure that record patterns don't miss any field. *) *) -let rec check_unboxed_abstract_arg loc univ ty = - match ty.desc with - | Tvar _ -> check_type_var loc univ ty.id - | Tarrow (_, t1, t2, _) - | Tfield (_, _, t1, t2) -> - check_unboxed_abstract_arg loc univ t1; - check_unboxed_abstract_arg loc univ t2 - | Ttuple args - | Tconstr (_, args, _) - | Tpackage (_, _, args) -> - List.iter (check_unboxed_abstract_arg loc univ) args - | Tobject (fields, r) -> - check_unboxed_abstract_arg loc univ fields; - begin match !r with - | None -> () - | Some (_, args) -> List.iter (check_unboxed_abstract_arg loc univ) args - end - | Tnil - | Tunivar _ -> () - | Tlink e -> check_unboxed_abstract_arg loc univ e - | Tsubst _ -> assert false - | Tvariant { row_fields; row_more; row_name } -> - List.iter (check_unboxed_abstract_row_field loc univ) row_fields; - check_unboxed_abstract_arg loc univ row_more; - begin match row_name with - | None -> () - | Some (_, args) -> List.iter (check_unboxed_abstract_arg loc univ) args - end - | Tpoly (t, _) -> check_unboxed_abstract_arg loc univ t - -and check_unboxed_abstract_row_field loc univ (_, field) = - match field with - | Rpresent (Some ty) -> check_unboxed_abstract_arg loc univ ty - | Reither (_, args, _, r) -> - List.iter (check_unboxed_abstract_arg loc univ) args; - begin match !r with - | None -> () - | Some f -> check_unboxed_abstract_row_field loc univ ("", f) - end - | Rabsent - | Rpresent None -> () - -(* Check that the argument to a GADT constructor is compatible with unboxing - the type, given the universal parameters of the type. *) -let rec check_unboxed_gadt_arg loc univ env ty = - match get_unboxed_type_representation env ty with - | Some {desc = Tvar _; id} -> check_type_var loc univ id - | Some {desc = Tarrow _ | Ttuple _ | Tpackage _ | Tobject _ | Tnil - | Tvariant _; _} -> - () - (* A comment in [Translcore.transl_exp0] claims the above cannot be - represented by floats. *) - | Some {desc = Tconstr (p, args, _); _} -> - let tydecl = Env.find_type p env in - assert (not tydecl.type_unboxed.unboxed); - if tydecl.type_kind = Type_abstract then - List.iter (check_unboxed_abstract_arg loc univ) args - | Some {desc = Tfield _ | Tlink _ | Tsubst _; _} -> assert false - | Some {desc = Tunivar _; _} -> () - | Some {desc = Tpoly (t2, _); _} -> check_unboxed_gadt_arg loc univ env t2 - | None -> () - (* This case is tricky: the argument is another (or the same) type - in the same recursive definition. In this case we don't have to - check because we will also check that other type for correctness. *) -let transl_declaration env sdecl id = - (* Bind type parameters *) - reset_type_variables(); - Ctype.begin_def (); - let tparams = make_params env sdecl.ptype_params in - let params = List.map (fun (cty, _) -> cty.ctyp_type) tparams in - let cstrs = List.map - (fun (sty, sty', loc) -> - transl_simple_type env false sty, - transl_simple_type env false sty', loc) - sdecl.ptype_cstrs - in - let raw_status = get_unboxed_from_attributes sdecl in - if raw_status.unboxed && not raw_status.default then begin - match sdecl.ptype_kind with - | Ptype_abstract -> - raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute - "it is abstract")) - | Ptype_variant [{pcd_args = Pcstr_tuple []; _}] -> - raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute - "its constructor has no argument")) - | Ptype_variant [{pcd_args = Pcstr_tuple [_]; _}] -> () - | Ptype_variant [{pcd_args = Pcstr_tuple _; _}] -> - raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute - "its constructor has more than one argument")) - | Ptype_variant [{pcd_args = Pcstr_record - [{pld_mutable=Immutable; _}]; _}] -> () - | Ptype_variant [{pcd_args = Pcstr_record [{pld_mutable=Mutable; _}]; _}] -> - raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute "it is mutable")) - | Ptype_variant [{pcd_args = Pcstr_record _; _}] -> - raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute - "its constructor has more than one argument")) - | Ptype_variant _ -> - raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute - "it has more than one constructor")) - | Ptype_record [{pld_mutable=Immutable; _}] -> () - | Ptype_record [{pld_mutable=Mutable; _}] -> - raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute - "it is mutable")) - | Ptype_record _ -> - raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute - "it has more than one field")) - | Ptype_open -> - raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute - "extensible variant types cannot be unboxed")) - end; - let unboxed_status = - match sdecl.ptype_kind with - | Ptype_variant [{pcd_args = Pcstr_tuple [_]; _}] - | Ptype_variant [{pcd_args = Pcstr_record - [{pld_mutable = Immutable; _}]; _}] - | Ptype_record [{pld_mutable = Immutable; _}] -> - raw_status - | _ -> (* The type is not unboxable, mark it as boxed *) - unboxed_false_default_false - in - let unbox = unboxed_status.unboxed in - let (tkind, kind) = - match sdecl.ptype_kind with - | Ptype_abstract -> Ttype_abstract, Type_abstract - | Ptype_variant scstrs -> - assert (scstrs <> []); - if List.exists (fun cstr -> cstr.pcd_res <> None) scstrs then begin - match cstrs with - [] -> () - | (_,_,loc)::_ -> - Location.prerr_warning loc Warnings.Constraint_on_gadt - end; - let all_constrs = ref StringSet.empty in - List.iter - (fun {pcd_name = {txt = name}} -> - if StringSet.mem name !all_constrs then - raise(Error(sdecl.ptype_loc, Duplicate_constructor name)); - all_constrs := StringSet.add name !all_constrs) - scstrs; - if List.length - (List.filter (fun cd -> cd.pcd_args <> Pcstr_tuple []) scstrs) - > (Config.max_tag + 1) then - raise(Error(sdecl.ptype_loc, Too_many_constructors)); - let make_cstr scstr = - let name = Ident.create scstr.pcd_name.txt in - let targs, tret_type, args, ret_type, cstr_params = - make_constructor env (Path.Pident id) params - scstr.pcd_args scstr.pcd_res - in - if Config.flat_float_array && unbox then begin - (* Cannot unbox a type when the argument can be both float and - non-float because it interferes with the dynamic float array - optimization. This can only happen when the type is a GADT - and the argument is an existential type variable or an - unboxed (or abstract) type constructor applied to some - existential type variable. Of course we also have to rule - out any abstract type constructor applied to anything that - might be an existential type variable. - There is a difficulty with existential variables created - out of thin air (rather than bound by the declaration). - See PR#7511 and GPR#1133 for details. *) - match Datarepr.constructor_existentials args ret_type with - | _, [] -> () - | [argty], _ex -> - check_unboxed_gadt_arg sdecl.ptype_loc cstr_params env argty - | _ -> assert false - end; - let tcstr = - { cd_id = name; - cd_name = scstr.pcd_name; - cd_args = targs; - cd_res = tret_type; - cd_loc = scstr.pcd_loc; - cd_attributes = scstr.pcd_attributes } - in - let cstr = - { Types.cd_id = name; - cd_args = args; - cd_res = ret_type; - cd_loc = scstr.pcd_loc; - cd_attributes = scstr.pcd_attributes } - in - tcstr, cstr - in - let make_cstr scstr = - Builtin_attributes.warning_scope scstr.pcd_attributes - (fun () -> make_cstr scstr) - in - let tcstrs, cstrs = List.split (List.map make_cstr scstrs) in - Ttype_variant tcstrs, Type_variant cstrs - | Ptype_record lbls -> - let lbls, lbls' = transl_labels env true lbls in - let rep = - if !Clflags.bs_only then Record_regular else (* ATTENTION: revisit when we support @@unbox*) - if unbox then Record_unboxed false - else if List.for_all (fun l -> is_float env l.Types.ld_type) lbls' - then Record_float - else Record_regular - in - Ttype_record lbls, Type_record(lbls', rep) - | Ptype_open -> Ttype_open, Type_open - in - let (tman, man) = match sdecl.ptype_manifest with - None -> None, None - | Some sty -> - let no_row = not (is_fixed_type sdecl) in - let cty = transl_simple_type env no_row sty in - Some cty, Some cty.ctyp_type - in - let decl = - { type_params = params; - type_arity = List.length params; - type_kind = kind; - type_private = sdecl.ptype_private; - type_manifest = man; - type_variance = List.map (fun _ -> Variance.full) params; - type_newtype_level = None; - type_loc = sdecl.ptype_loc; - type_attributes = sdecl.ptype_attributes; - type_immediate = false; - type_unboxed = unboxed_status; - } in - (* Check constraints *) - List.iter - (fun (cty, cty', loc) -> - let ty = cty.ctyp_type in - let ty' = cty'.ctyp_type in - try Ctype.unify env ty ty' with Ctype.Unify tr -> - raise(Error(loc, Inconsistent_constraint (env, tr)))) - cstrs; - Ctype.end_def (); - (* Add abstract row *) - if is_fixed_type sdecl then begin - let p = - try Env.lookup_type (Longident.Lident(Ident.name id ^ "#row")) env - with Not_found -> assert false in - set_fixed_row env sdecl.ptype_loc p decl - end; - (* Check for cyclic abbreviations *) - begin match decl.type_manifest with None -> () - | Some ty -> - if Ctype.cyclic_abbrev env id ty then - raise(Error(sdecl.ptype_loc, Recursive_abbrev sdecl.ptype_name.txt)); - end; - { - typ_id = id; - typ_name = sdecl.ptype_name; - typ_params = tparams; - typ_type = decl; - typ_cstrs = cstrs; - typ_loc = sdecl.ptype_loc; - typ_manifest = tman; - typ_kind = tkind; - typ_private = sdecl.ptype_private; - typ_attributes = sdecl.ptype_attributes; - } +open Parsetree +open Location -(* Generalize a type declaration *) +type iterator = { + attribute: iterator -> attribute -> unit; + attributes: iterator -> attribute list -> unit; + case: iterator -> case -> unit; + cases: iterator -> case list -> unit; + class_declaration: iterator -> class_declaration -> unit; + class_description: iterator -> class_description -> unit; + class_expr: iterator -> class_expr -> unit; + class_field: iterator -> class_field -> unit; + class_signature: iterator -> class_signature -> unit; + class_structure: iterator -> class_structure -> unit; + class_type: iterator -> class_type -> unit; + class_type_declaration: iterator -> class_type_declaration -> unit; + class_type_field: iterator -> class_type_field -> unit; + constructor_declaration: iterator -> constructor_declaration -> unit; + expr: iterator -> expression -> unit; + extension: iterator -> extension -> unit; + extension_constructor: iterator -> extension_constructor -> unit; + include_declaration: iterator -> include_declaration -> unit; + include_description: iterator -> include_description -> unit; + label_declaration: iterator -> label_declaration -> unit; + location: iterator -> Location.t -> unit; + module_binding: iterator -> module_binding -> unit; + module_declaration: iterator -> module_declaration -> unit; + module_expr: iterator -> module_expr -> unit; + module_type: iterator -> module_type -> unit; + module_type_declaration: iterator -> module_type_declaration -> unit; + open_description: iterator -> open_description -> unit; + pat: iterator -> pattern -> unit; + payload: iterator -> payload -> unit; + signature: iterator -> signature -> unit; + signature_item: iterator -> signature_item -> unit; + structure: iterator -> structure -> unit; + structure_item: iterator -> structure_item -> unit; + typ: iterator -> core_type -> unit; + type_declaration: iterator -> type_declaration -> unit; + type_extension: iterator -> type_extension -> unit; + type_kind: iterator -> type_kind -> unit; + value_binding: iterator -> value_binding -> unit; + value_description: iterator -> value_description -> unit; + with_constraint: iterator -> with_constraint -> unit; +} +(** A [iterator] record implements one "method" per syntactic category, + using an open recursion style: each method takes as its first + argument the iterator to be applied to children in the syntax + tree. *) -let generalize_decl decl = - List.iter Ctype.generalize decl.type_params; - Btype.iter_type_expr_kind Ctype.generalize decl.type_kind; - begin match decl.type_manifest with - | None -> () - | Some ty -> Ctype.generalize ty - end +let iter_fst f (x, _) = f x +let iter_snd f (_, y) = f y +let iter_tuple f1 f2 (x, y) = f1 x; f2 y +let iter_tuple3 f1 f2 f3 (x, y, z) = f1 x; f2 y; f3 z +let iter_opt f = function None -> () | Some x -> f x -(* Check that all constraints are enforced *) +let iter_loc sub {loc; txt = _} = sub.location sub loc -module TypeSet = Btype.TypeSet -module TypeMap = Btype.TypeMap +module T = struct + (* Type expressions for the core language *) -let rec check_constraints_rec env loc visited ty = - let ty = Ctype.repr ty in - if TypeSet.mem ty !visited then () else begin - visited := TypeSet.add ty !visited; - match ty.desc with - | Tconstr (path, args, _) -> - let args' = List.map (fun _ -> Ctype.newvar ()) args in - let ty' = Ctype.newconstr path args' in - begin try Ctype.enforce_constraints env ty' - with Ctype.Unify _ -> assert false - | Not_found -> raise (Error(loc, Unavailable_type_constructor path)) - end; - if not (Ctype.matches env ty ty') then - raise (Error(loc, Constraint_failed (ty, ty'))); - List.iter (check_constraints_rec env loc visited) args - | Tpoly (ty, tl) -> - let _, ty = Ctype.instance_poly false tl ty in - check_constraints_rec env loc visited ty - | _ -> - Btype.iter_type_expr (check_constraints_rec env loc visited) ty - end + let row_field sub = function + | Rtag (_, attrs, _, tl) -> + sub.attributes sub attrs; List.iter (sub.typ sub) tl + | Rinherit t -> sub.typ sub t -module SMap = Map.Make(String) + let object_field sub = function + | Otag (_, attrs, t) -> + sub.attributes sub attrs; sub.typ sub t + | Oinherit t -> sub.typ sub t -let check_constraints_labels env visited l pl = - let rec get_loc name = function - [] -> assert false - | pld :: tl -> - if name = pld.pld_name.txt then pld.pld_type.ptyp_loc - else get_loc name tl - in - List.iter - (fun {Types.ld_id=name; ld_type=ty} -> - check_constraints_rec env (get_loc (Ident.name name) pl) visited ty) - l + let iter sub {ptyp_desc = desc; ptyp_loc = loc; ptyp_attributes = attrs} = + sub.location sub loc; + sub.attributes sub attrs; + match desc with + | Ptyp_any + | Ptyp_var _ -> () + | Ptyp_arrow (_lab, t1, t2) -> + sub.typ sub t1; sub.typ sub t2 + | Ptyp_tuple tyl -> List.iter (sub.typ sub) tyl + | Ptyp_constr (lid, tl) -> + iter_loc sub lid; List.iter (sub.typ sub) tl + | Ptyp_object (ol, _o) -> + List.iter (object_field sub) ol + | Ptyp_class (lid, tl) -> + iter_loc sub lid; List.iter (sub.typ sub) tl + | Ptyp_alias (t, _) -> sub.typ sub t + | Ptyp_variant (rl, _b, _ll) -> + List.iter (row_field sub) rl + | Ptyp_poly (_, t) -> sub.typ sub t + | Ptyp_package (lid, l) -> + iter_loc sub lid; + List.iter (iter_tuple (iter_loc sub) (sub.typ sub)) l + | Ptyp_extension x -> sub.extension sub x -let check_constraints env sdecl (_, decl) = - let visited = ref TypeSet.empty in - begin match decl.type_kind with - | Type_abstract -> () - | Type_variant l -> - let find_pl = function - Ptype_variant pl -> pl - | Ptype_record _ | Ptype_abstract | Ptype_open -> assert false - in - let pl = find_pl sdecl.ptype_kind in - let pl_index = - let foldf acc x = - SMap.add x.pcd_name.txt x acc - in - List.fold_left foldf SMap.empty pl - in - List.iter - (fun {Types.cd_id=name; cd_args; cd_res} -> - let {pcd_args; pcd_res; _} = - try SMap.find (Ident.name name) pl_index - with Not_found -> assert false in - begin match cd_args, pcd_args with - | Cstr_tuple tyl, Pcstr_tuple styl -> - List.iter2 - (fun sty ty -> - check_constraints_rec env sty.ptyp_loc visited ty) - styl tyl - | Cstr_record tyl, Pcstr_record styl -> - check_constraints_labels env visited tyl styl - | _ -> assert false - end; - match pcd_res, cd_res with - | Some sr, Some r -> - check_constraints_rec env sr.ptyp_loc visited r - | _ -> - () ) - l - | Type_record (l, _) -> - let find_pl = function - Ptype_record pl -> pl - | Ptype_variant _ | Ptype_abstract | Ptype_open -> assert false - in - let pl = find_pl sdecl.ptype_kind in - check_constraints_labels env visited l pl - | Type_open -> () - end; - begin match decl.type_manifest with - | None -> () - | Some ty -> - let sty = - match sdecl.ptype_manifest with Some sty -> sty | _ -> assert false - in - check_constraints_rec env sty.ptyp_loc visited ty - end + let iter_type_declaration sub + {ptype_name; ptype_params; ptype_cstrs; + ptype_kind; + ptype_private = _; + ptype_manifest; + ptype_attributes; + ptype_loc} = + iter_loc sub ptype_name; + List.iter (iter_fst (sub.typ sub)) ptype_params; + List.iter + (iter_tuple3 (sub.typ sub) (sub.typ sub) (sub.location sub)) + ptype_cstrs; + sub.type_kind sub ptype_kind; + iter_opt (sub.typ sub) ptype_manifest; + sub.location sub ptype_loc; + sub.attributes sub ptype_attributes -(* - If both a variant/record definition and a type equation are given, - need to check that the equation refers to a type of the same kind - with the same constructors and labels. -*) -let check_coherence env loc id decl = - match decl with - { type_kind = (Type_variant _ | Type_record _| Type_open); - type_manifest = Some ty } -> - begin match (Ctype.repr ty).desc with - Tconstr(path, args, _) -> - begin try - let decl' = Env.find_type path env in - let err = - if List.length args <> List.length decl.type_params - then [Includecore.Arity] - else if not (Ctype.equal env false args decl.type_params) - then [Includecore.Constraint] - else - Includecore.type_declarations ~loc ~equality:true env - (Path.last path) - decl' - id - (Subst.type_declaration - (Subst.add_type id path Subst.identity) decl) - in - if err <> [] then - raise(Error(loc, Definition_mismatch (ty, err))) - with Not_found -> - raise(Error(loc, Unavailable_type_constructor path)) - end - | _ -> raise(Error(loc, Definition_mismatch (ty, []))) - end - | _ -> () + let iter_type_kind sub = function + | Ptype_abstract -> () + | Ptype_variant l -> + List.iter (sub.constructor_declaration sub) l + | Ptype_record l -> List.iter (sub.label_declaration sub) l + | Ptype_open -> () -let check_abbrev env sdecl (id, decl) = - check_coherence env sdecl.ptype_loc id decl + let iter_constructor_arguments sub = function + | Pcstr_tuple l -> List.iter (sub.typ sub) l + | Pcstr_record l -> + List.iter (sub.label_declaration sub) l -(* Check that recursion is well-founded *) + let iter_type_extension sub + {ptyext_path; ptyext_params; + ptyext_constructors; + ptyext_private = _; + ptyext_attributes} = + iter_loc sub ptyext_path; + List.iter (sub.extension_constructor sub) ptyext_constructors; + List.iter (iter_fst (sub.typ sub)) ptyext_params; + sub.attributes sub ptyext_attributes -let check_well_founded env loc path to_check ty = - let visited = ref TypeMap.empty in - let rec check ty0 parents ty = - let ty = Btype.repr ty in - if TypeSet.mem ty parents then begin - (*Format.eprintf "@[%a@]@." Printtyp.raw_type_expr ty;*) - if match ty0.desc with - | Tconstr (p, _, _) -> Path.same p path - | _ -> false - then raise (Error (loc, Recursive_abbrev (Path.name path))) - else raise (Error (loc, Cycle_in_def (Path.name path, ty0))) - end; - let (fini, parents) = - try - let prev = TypeMap.find ty !visited in - if TypeSet.subset parents prev then (true, parents) else - (false, TypeSet.union parents prev) - with Not_found -> - (false, parents) - in - if fini then () else - let rec_ok = - match ty.desc with - Tconstr(p,_,_) -> - !Clflags.recursive_types && Ctype.is_contractive env p - | Tobject _ | Tvariant _ -> true - | _ -> !Clflags.recursive_types - in - let visited' = TypeMap.add ty parents !visited in - let arg_exn = - try - visited := visited'; - let parents = - if rec_ok then TypeSet.empty else TypeSet.add ty parents in - Btype.iter_type_expr (check ty0 parents) ty; - None - with e -> - visited := visited'; Some e - in - match ty.desc with - | Tconstr(p, _, _) when arg_exn <> None || to_check p -> - if to_check p then may raise arg_exn - else Btype.iter_type_expr (check ty0 TypeSet.empty) ty; - begin try - let ty' = Ctype.try_expand_once_opt env ty in - let ty0 = if TypeSet.is_empty parents then ty else ty0 in - check ty0 (TypeSet.add ty parents) ty' - with - Ctype.Cannot_expand -> may raise arg_exn - end - | _ -> may raise arg_exn - in - let snap = Btype.snapshot () in - try Ctype.wrap_trace_gadt_instances env (check ty TypeSet.empty) ty - with Ctype.Unify _ -> - (* Will be detected by check_recursion *) - Btype.backtrack snap + let iter_extension_constructor_kind sub = function + Pext_decl(ctl, cto) -> + iter_constructor_arguments sub ctl; iter_opt (sub.typ sub) cto + | Pext_rebind li -> + iter_loc sub li -let check_well_founded_manifest env loc path decl = - if decl.type_manifest = None then () else - let args = List.map (fun _ -> Ctype.newvar()) decl.type_params in - check_well_founded env loc path (Path.same path) (Ctype.newconstr path args) + let iter_extension_constructor sub + {pext_name; + pext_kind; + pext_loc; + pext_attributes} = + iter_loc sub pext_name; + iter_extension_constructor_kind sub pext_kind; + sub.location sub pext_loc; + sub.attributes sub pext_attributes -let check_well_founded_decl env loc path decl to_check = - let open Btype in - let it = - {type_iterators with - it_type_expr = (fun _ -> check_well_founded env loc path to_check)} in - it.it_type_declaration it (Ctype.instance_declaration decl) +end -(* Check for ill-defined abbrevs *) +module CT = struct + (* Type expressions for the class language *) -let check_recursion env loc path decl to_check = - (* to_check is true for potentially mutually recursive paths. - (path, decl) is the type declaration to be checked. *) + let iter sub {pcty_loc = loc; pcty_desc = desc; pcty_attributes = attrs} = + sub.location sub loc; + sub.attributes sub attrs; + match desc with + | Pcty_constr (lid, tys) -> + iter_loc sub lid; List.iter (sub.typ sub) tys + | Pcty_signature x -> sub.class_signature sub x + | Pcty_arrow (_lab, t, ct) -> + sub.typ sub t; sub.class_type sub ct + | Pcty_extension x -> sub.extension sub x + | Pcty_open (_ovf, lid, e) -> + iter_loc sub lid; sub.class_type sub e - if decl.type_params = [] then () else + let iter_field sub {pctf_desc = desc; pctf_loc = loc; pctf_attributes = attrs} + = + sub.location sub loc; + sub.attributes sub attrs; + match desc with + | Pctf_inherit ct -> sub.class_type sub ct + | Pctf_val (_s, _m, _v, t) -> sub.typ sub t + | Pctf_method (_s, _p, _v, t) -> sub.typ sub t + | Pctf_constraint (t1, t2) -> + sub.typ sub t1; sub.typ sub t2 + | Pctf_attribute x -> sub.attribute sub x + | Pctf_extension x -> sub.extension sub x - let visited = ref [] in + let iter_signature sub {pcsig_self; pcsig_fields} = + sub.typ sub pcsig_self; + List.iter (sub.class_type_field sub) pcsig_fields +end - let rec check_regular cpath args prev_exp ty = - let ty = Ctype.repr ty in - if not (List.memq ty !visited) then begin - visited := ty :: !visited; - match ty.desc with - | Tconstr(path', args', _) -> - if Path.same path path' then begin - if not (Ctype.equal env false args args') then - raise (Error(loc, - Parameters_differ(cpath, ty, Ctype.newconstr path args))) - end - (* Attempt to expand a type abbreviation if: - 1- [to_check path'] holds - (otherwise the expansion cannot involve [path]); - 2- we haven't expanded this type constructor before - (otherwise we could loop if [path'] is itself - a non-regular abbreviation). *) - else if to_check path' && not (List.mem path' prev_exp) then begin - try - (* Attempt expansion *) - let (params0, body0, _) = Env.find_type_expansion path' env in - let (params, body) = - Ctype.instance_parameterized_type params0 body0 in - begin - try List.iter2 (Ctype.unify env) params args' - with Ctype.Unify _ -> - raise (Error(loc, Constraint_failed - (ty, Ctype.newconstr path' params0))); - end; - check_regular path' args (path' :: prev_exp) body - with Not_found -> () - end; - List.iter (check_regular cpath args prev_exp) args' - | Tpoly (ty, tl) -> - let (_, ty) = Ctype.instance_poly ~keep_names:true false tl ty in - check_regular cpath args prev_exp ty - | _ -> - Btype.iter_type_expr (check_regular cpath args prev_exp) ty - end in +module MT = struct + (* Type expressions for the module language *) - Misc.may - (fun body -> - let (args, body) = - Ctype.instance_parameterized_type - ~keep_names:true decl.type_params body in - check_regular path args [] body) - decl.type_manifest + let iter sub {pmty_desc = desc; pmty_loc = loc; pmty_attributes = attrs} = + sub.location sub loc; + sub.attributes sub attrs; + match desc with + | Pmty_ident s -> iter_loc sub s + | Pmty_alias s -> iter_loc sub s + | Pmty_signature sg -> sub.signature sub sg + | Pmty_functor (s, mt1, mt2) -> + iter_loc sub s; + iter_opt (sub.module_type sub) mt1; + sub.module_type sub mt2 + | Pmty_with (mt, l) -> + sub.module_type sub mt; + List.iter (sub.with_constraint sub) l + | Pmty_typeof me -> sub.module_expr sub me + | Pmty_extension x -> sub.extension sub x -let check_abbrev_recursion env id_loc_list to_check tdecl = - let decl = tdecl.typ_type in - let id = tdecl.typ_id in - check_recursion env (List.assoc id id_loc_list) (Path.Pident id) decl to_check + let iter_with_constraint sub = function + | Pwith_type (lid, d) -> + iter_loc sub lid; sub.type_declaration sub d + | Pwith_module (lid, lid2) -> + iter_loc sub lid; iter_loc sub lid2 + | Pwith_typesubst (lid, d) -> + iter_loc sub lid; sub.type_declaration sub d + | Pwith_modsubst (s, lid) -> + iter_loc sub s; iter_loc sub lid -(* Compute variance *) + let iter_signature_item sub {psig_desc = desc; psig_loc = loc} = + sub.location sub loc; + match desc with + | Psig_value vd -> sub.value_description sub vd + | Psig_type (_rf, l) -> List.iter (sub.type_declaration sub) l + | Psig_typext te -> sub.type_extension sub te + | Psig_exception ed -> sub.extension_constructor sub ed + | Psig_module x -> sub.module_declaration sub x + | Psig_recmodule l -> + List.iter (sub.module_declaration sub) l + | Psig_modtype x -> sub.module_type_declaration sub x + | Psig_open x -> sub.open_description sub x + | Psig_include x -> sub.include_description sub x + | Psig_class l -> List.iter (sub.class_description sub) l + | Psig_class_type l -> + List.iter (sub.class_type_declaration sub) l + | Psig_extension (x, attrs) -> + sub.extension sub x; sub.attributes sub attrs + | Psig_attribute x -> sub.attribute sub x +end -let get_variance ty visited = - try TypeMap.find ty !visited with Not_found -> Variance.null -let compute_variance env visited vari ty = - let rec compute_variance_rec vari ty = - (* Format.eprintf "%a: %x@." Printtyp.type_expr ty (Obj.magic vari); *) - let ty = Ctype.repr ty in - let vari' = get_variance ty visited in - if Variance.subset vari vari' then () else - let vari = Variance.union vari vari' in - visited := TypeMap.add ty vari !visited; - let compute_same = compute_variance_rec vari in - match ty.desc with - Tarrow (_, ty1, ty2, _) -> - let open Variance in - let v = conjugate vari in - let v1 = - if mem May_pos v || mem May_neg v - then set May_weak true v else v - in - compute_variance_rec v1 ty1; - compute_same ty2 - | Ttuple tl -> - List.iter compute_same tl - | Tconstr (path, tl, _) -> - let open Variance in - if tl = [] then () else begin - try - let decl = Env.find_type path env in - let cvari f = mem f vari in - List.iter2 - (fun ty v -> - let cv f = mem f v in - let strict = - cvari Inv && cv Inj || (cvari Pos || cvari Neg) && cv Inv - in - if strict then compute_variance_rec full ty else - let p1 = inter v vari - and n1 = inter v (conjugate vari) in - let v1 = - union (inter covariant (union p1 (conjugate p1))) - (inter (conjugate covariant) (union n1 (conjugate n1))) - and weak = - cvari May_weak && (cv May_pos || cv May_neg) || - (cvari May_pos || cvari May_neg) && cv May_weak - in - let v2 = set May_weak weak v1 in - compute_variance_rec v2 ty) - tl decl.type_variance - with Not_found -> - List.iter (compute_variance_rec may_inv) tl - end - | Tobject (ty, _) -> - compute_same ty - | Tfield (_, _, ty1, ty2) -> - compute_same ty1; - compute_same ty2 - | Tsubst ty -> - compute_same ty - | Tvariant row -> - let row = Btype.row_repr row in - List.iter - (fun (_,f) -> - match Btype.row_field_repr f with - Rpresent (Some ty) -> - compute_same ty - | Reither (_, tyl, _, _) -> - let open Variance in - let upper = - List.fold_left (fun s f -> set f true s) - null [May_pos; May_neg; May_weak] - in - let v = inter vari upper in - (* cf PR#7269: - if List.length tyl > 1 then upper else inter vari upper *) - List.iter (compute_variance_rec v) tyl - | _ -> ()) - row.row_fields; - compute_same row.row_more - | Tpoly (ty, _) -> - compute_same ty - | Tvar _ | Tnil | Tlink _ | Tunivar _ -> () - | Tpackage (_, _, tyl) -> - let v = - Variance.(if mem Pos vari || mem Neg vari then full else may_inv) - in - List.iter (compute_variance_rec v) tyl - in - compute_variance_rec vari ty +module M = struct + (* Value expressions for the module language *) -let make p n i = - let open Variance in - set May_pos p (set May_neg n (set May_weak n (set Inj i null))) + let iter sub {pmod_loc = loc; pmod_desc = desc; pmod_attributes = attrs} = + sub.location sub loc; + sub.attributes sub attrs; + match desc with + | Pmod_ident x -> iter_loc sub x + | Pmod_structure str -> sub.structure sub str + | Pmod_functor (arg, arg_ty, body) -> + iter_loc sub arg; + iter_opt (sub.module_type sub) arg_ty; + sub.module_expr sub body + | Pmod_apply (m1, m2) -> + sub.module_expr sub m1; sub.module_expr sub m2 + | Pmod_constraint (m, mty) -> + sub.module_expr sub m; sub.module_type sub mty + | Pmod_unpack e -> sub.expr sub e + | Pmod_extension x -> sub.extension sub x -let compute_variance_type env check (required, loc) decl tyl = - (* Requirements *) - let required = - List.map (fun (c,n,i) -> if c || n then (c,n,i) else (true,true,i)) - required - in - (* Prepare *) - let params = List.map Btype.repr decl.type_params in - let tvl = ref TypeMap.empty in - (* Compute occurrences in the body *) - let open Variance in - List.iter - (fun (cn,ty) -> - compute_variance env tvl (if cn then full else covariant) ty) - tyl; - if check then begin - (* Check variance of parameters *) - let pos = ref 0 in - List.iter2 - (fun ty (c, n, i) -> - incr pos; - let var = get_variance ty tvl in - let (co,cn) = get_upper var and ij = mem Inj var in - if Btype.is_Tvar ty && (co && not c || cn && not n || not ij && i) - then raise (Error(loc, Bad_variance (!pos, (co,cn,ij), (c,n,i))))) - params required; - (* Check propagation from constrained parameters *) - let args = Btype.newgenty (Ttuple params) in - let fvl = Ctype.free_variables args in - let fvl = List.filter (fun v -> not (List.memq v params)) fvl in - (* If there are no extra variables there is nothing to do *) - if fvl = [] then () else - let tvl2 = ref TypeMap.empty in - List.iter2 - (fun ty (p,n,_) -> - if Btype.is_Tvar ty then () else - let v = - if p then if n then full else covariant else conjugate covariant in - compute_variance env tvl2 v ty) - params required; - let visited = ref TypeSet.empty in - let rec check ty = - let ty = Ctype.repr ty in - if TypeSet.mem ty !visited then () else - let visited' = TypeSet.add ty !visited in - visited := visited'; - let v1 = get_variance ty tvl in - let snap = Btype.snapshot () in - let v2 = - TypeMap.fold - (fun t vt v -> - if Ctype.equal env false [ty] [t] then union vt v else v) - !tvl2 null in - Btype.backtrack snap; - let (c1,n1) = get_upper v1 and (c2,n2,_,i2) = get_lower v2 in - if c1 && not c2 || n1 && not n2 then - if List.memq ty fvl then - let code = if not i2 then -2 else if c2 || n2 then -1 else -3 in - raise (Error (loc, Bad_variance (code, (c1,n1,false), (c2,n2,false)))) - else - Btype.iter_type_expr check ty - in - List.iter (fun (_,ty) -> check ty) tyl; - end; - List.map2 - (fun ty (p, n, i) -> - let v = get_variance ty tvl in - let tr = decl.type_private in - (* Use required variance where relevant *) - let concr = decl.type_kind <> Type_abstract (*|| tr = Type_new*) in - let (p, n) = - if tr = Private || not (Btype.is_Tvar ty) then (p, n) (* set *) - else (false, false) (* only check *) - and i = concr || i && tr = Private in - let v = union v (make p n i) in - let v = - if not concr then v else - if mem Pos v && mem Neg v then full else - if Btype.is_Tvar ty then v else - union v - (if p then if n then full else covariant else conjugate covariant) - in - if decl.type_kind = Type_abstract && tr = Public then v else - set May_weak (mem May_neg v) v) - params required + let iter_structure_item sub {pstr_loc = loc; pstr_desc = desc} = + sub.location sub loc; + match desc with + | Pstr_eval (x, attrs) -> + sub.expr sub x; sub.attributes sub attrs + | Pstr_value (_r, vbs) -> List.iter (sub.value_binding sub) vbs + | Pstr_primitive vd -> sub.value_description sub vd + | Pstr_type (_rf, l) -> List.iter (sub.type_declaration sub) l + | Pstr_typext te -> sub.type_extension sub te + | Pstr_exception ed -> sub.extension_constructor sub ed + | Pstr_module x -> sub.module_binding sub x + | Pstr_recmodule l -> List.iter (sub.module_binding sub) l + | Pstr_modtype x -> sub.module_type_declaration sub x + | Pstr_open x -> sub.open_description sub x + | Pstr_class l -> List.iter (sub.class_declaration sub) l + | Pstr_class_type l -> + List.iter (sub.class_type_declaration sub) l + | Pstr_include x -> sub.include_declaration sub x + | Pstr_extension (x, attrs) -> + sub.extension sub x; sub.attributes sub attrs + | Pstr_attribute x -> sub.attribute sub x +end -let add_false = List.map (fun ty -> false, ty) +module E = struct + (* Value expressions for the core language *) -(* A parameter is constrained if it is either instantiated, - or it is a variable appearing in another parameter *) -let constrained vars ty = - match ty.desc with - | Tvar _ -> List.exists (fun tl -> List.memq ty tl) vars - | _ -> true + let iter sub {pexp_loc = loc; pexp_desc = desc; pexp_attributes = attrs} = + sub.location sub loc; + sub.attributes sub attrs; + match desc with + | Pexp_ident x -> iter_loc sub x + | Pexp_constant _ -> () + | Pexp_let (_r, vbs, e) -> + List.iter (sub.value_binding sub) vbs; + sub.expr sub e + | Pexp_fun (_lab, def, p, e) -> + iter_opt (sub.expr sub) def; + sub.pat sub p; + sub.expr sub e + | Pexp_function pel -> sub.cases sub pel + | Pexp_apply (e, l) -> + sub.expr sub e; List.iter (iter_snd (sub.expr sub)) l + | Pexp_match (e, pel) -> + sub.expr sub e; sub.cases sub pel + | Pexp_try (e, pel) -> sub.expr sub e; sub.cases sub pel + | Pexp_tuple el -> List.iter (sub.expr sub) el + | Pexp_construct (lid, arg) -> + iter_loc sub lid; iter_opt (sub.expr sub) arg + | Pexp_variant (_lab, eo) -> + iter_opt (sub.expr sub) eo + | Pexp_record (l, eo) -> + List.iter (iter_tuple (iter_loc sub) (sub.expr sub)) l; + iter_opt (sub.expr sub) eo + | Pexp_field (e, lid) -> + sub.expr sub e; iter_loc sub lid + | Pexp_setfield (e1, lid, e2) -> + sub.expr sub e1; iter_loc sub lid; + sub.expr sub e2 + | Pexp_array el -> List.iter (sub.expr sub) el + | Pexp_ifthenelse (e1, e2, e3) -> + sub.expr sub e1; sub.expr sub e2; + iter_opt (sub.expr sub) e3 + | Pexp_sequence (e1, e2) -> + sub.expr sub e1; sub.expr sub e2 + | Pexp_while (e1, e2) -> + sub.expr sub e1; sub.expr sub e2 + | Pexp_for (p, e1, e2, _d, e3) -> + sub.pat sub p; sub.expr sub e1; sub.expr sub e2; + sub.expr sub e3 + | Pexp_coerce (e, t1, t2) -> + sub.expr sub e; iter_opt (sub.typ sub) t1; + sub.typ sub t2 + | Pexp_constraint (e, t) -> + sub.expr sub e; sub.typ sub t + | Pexp_send (e, _s) -> sub.expr sub e + | Pexp_new lid -> iter_loc sub lid + | Pexp_setinstvar (s, e) -> + iter_loc sub s; sub.expr sub e + | Pexp_override sel -> + List.iter (iter_tuple (iter_loc sub) (sub.expr sub)) sel + | Pexp_letmodule (s, me, e) -> + iter_loc sub s; sub.module_expr sub me; + sub.expr sub e + | Pexp_letexception (cd, e) -> + sub.extension_constructor sub cd; + sub.expr sub e + | Pexp_assert e -> sub.expr sub e + | Pexp_lazy e -> sub.expr sub e + | Pexp_poly (e, t) -> + sub.expr sub e; iter_opt (sub.typ sub) t + | Pexp_object cls -> sub.class_structure sub cls + | Pexp_newtype (_s, e) -> sub.expr sub e + | Pexp_pack me -> sub.module_expr sub me + | Pexp_open (_ovf, lid, e) -> + iter_loc sub lid; sub.expr sub e + | Pexp_extension x -> sub.extension sub x + | Pexp_unreachable -> () +end -let for_constr = function - | Types.Cstr_tuple l -> add_false l - | Types.Cstr_record l -> - List.map - (fun {Types.ld_mutable; ld_type} -> (ld_mutable = Mutable, ld_type)) - l +module P = struct + (* Patterns *) -let compute_variance_gadt env check (required, loc as rloc) decl - (tl, ret_type_opt) = - match ret_type_opt with - | None -> - compute_variance_type env check rloc {decl with type_private = Private} - (for_constr tl) - | Some ret_type -> - match Ctype.repr ret_type with - | {desc=Tconstr (_, tyl, _)} -> - (* let tyl = List.map (Ctype.expand_head env) tyl in *) - let tyl = List.map Ctype.repr tyl in - let fvl = List.map (Ctype.free_variables ?env:None) tyl in - let _ = - List.fold_left2 - (fun (fv1,fv2) ty (c,n,_) -> - match fv2 with [] -> assert false - | fv :: fv2 -> - (* fv1 @ fv2 = free_variables of other parameters *) - if (c||n) && constrained (fv1 @ fv2) ty then - raise (Error(loc, Varying_anonymous)); - (fv :: fv1, fv2)) - ([], fvl) tyl required - in - compute_variance_type env check rloc - {decl with type_params = tyl; type_private = Private} - (for_constr tl) - | _ -> assert false + let iter sub {ppat_desc = desc; ppat_loc = loc; ppat_attributes = attrs} = + sub.location sub loc; + sub.attributes sub attrs; + match desc with + | Ppat_any -> () + | Ppat_var s -> iter_loc sub s + | Ppat_alias (p, s) -> sub.pat sub p; iter_loc sub s + | Ppat_constant _ -> () + | Ppat_interval _ -> () + | Ppat_tuple pl -> List.iter (sub.pat sub) pl + | Ppat_construct (l, p) -> + iter_loc sub l; iter_opt (sub.pat sub) p + | Ppat_variant (_l, p) -> iter_opt (sub.pat sub) p + | Ppat_record (lpl, _cf) -> + List.iter (iter_tuple (iter_loc sub) (sub.pat sub)) lpl + | Ppat_array pl -> List.iter (sub.pat sub) pl + | Ppat_or (p1, p2) -> sub.pat sub p1; sub.pat sub p2 + | Ppat_constraint (p, t) -> + sub.pat sub p; sub.typ sub t + | Ppat_type s -> iter_loc sub s + | Ppat_lazy p -> sub.pat sub p + | Ppat_unpack s -> iter_loc sub s + | Ppat_exception p -> sub.pat sub p + | Ppat_extension x -> sub.extension sub x + | Ppat_open (lid, p) -> + iter_loc sub lid; sub.pat sub p -let compute_variance_extension env check decl ext rloc = - compute_variance_gadt env check rloc - {decl with type_params = ext.ext_type_params} - (ext.ext_args, ext.ext_ret_type) +end -let compute_variance_decl env check decl (required, _ as rloc) = - if (decl.type_kind = Type_abstract || decl.type_kind = Type_open) - && decl.type_manifest = None then - List.map - (fun (c, n, i) -> - make (not n) (not c) (decl.type_kind <> Type_abstract || i)) - required - else - let mn = - match decl.type_manifest with - None -> [] - | Some ty -> [false, ty] - in - match decl.type_kind with - Type_abstract | Type_open -> - compute_variance_type env check rloc decl mn - | Type_variant tll -> - if List.for_all (fun c -> c.Types.cd_res = None) tll then - compute_variance_type env check rloc decl - (mn @ List.flatten (List.map (fun c -> for_constr c.Types.cd_args) - tll)) - else begin - let mn = - List.map (fun (_,ty) -> (Types.Cstr_tuple [ty],None)) mn in - let tll = - mn @ List.map (fun c -> c.Types.cd_args, c.Types.cd_res) tll in - match List.map (compute_variance_gadt env check rloc decl) tll with - | vari :: rem -> - let varl = List.fold_left (List.map2 Variance.union) vari rem in - List.map - Variance.(fun v -> if mem Pos v && mem Neg v then full else v) - varl - | _ -> assert false - end - | Type_record (ftl, _) -> - compute_variance_type env check rloc decl - (mn @ List.map (fun {Types.ld_mutable; ld_type} -> - (ld_mutable = Mutable, ld_type)) ftl) +module CE = struct + (* Value expressions for the class language *) -let is_hash id = - let s = Ident.name id in - String.length s > 0 && s.[0] = '#' + let iter sub {pcl_loc = loc; pcl_desc = desc; pcl_attributes = attrs} = + sub.location sub loc; + sub.attributes sub attrs; + match desc with + | Pcl_constr (lid, tys) -> + iter_loc sub lid; List.iter (sub.typ sub) tys + | Pcl_structure s -> + sub.class_structure sub s + | Pcl_fun (_lab, e, p, ce) -> + iter_opt (sub.expr sub) e; + sub.pat sub p; + sub.class_expr sub ce + | Pcl_apply (ce, l) -> + sub.class_expr sub ce; + List.iter (iter_snd (sub.expr sub)) l + | Pcl_let (_r, vbs, ce) -> + List.iter (sub.value_binding sub) vbs; + sub.class_expr sub ce + | Pcl_constraint (ce, ct) -> + sub.class_expr sub ce; sub.class_type sub ct + | Pcl_extension x -> sub.extension sub x + | Pcl_open (_ovf, lid, e) -> + iter_loc sub lid; sub.class_expr sub e -let marked_as_immediate decl = - Builtin_attributes.immediate decl.type_attributes + let iter_kind sub = function + | Cfk_concrete (_o, e) -> sub.expr sub e + | Cfk_virtual t -> sub.typ sub t -let compute_immediacy env tdecl = - match (tdecl.type_kind, tdecl.type_manifest) with - | (Type_variant [{cd_args = Cstr_tuple [arg]; _}], _) - | (Type_variant [{cd_args = Cstr_record [{ld_type = arg; _}]; _}], _) - | (Type_record ([{ld_type = arg; _}], _), _) - when tdecl.type_unboxed.unboxed -> - begin match get_unboxed_type_representation env arg with - | Some argrepr -> not (Ctype.maybe_pointer_type env argrepr) - | None -> false - end - | (Type_variant (_ :: _ as cstrs), _) -> - not (List.exists (fun c -> c.Types.cd_args <> Types.Cstr_tuple []) cstrs) - | (Type_abstract, Some(typ)) -> - not (Ctype.maybe_pointer_type env typ) - | (Type_abstract, None) -> marked_as_immediate tdecl - | _ -> false + let iter_field sub {pcf_desc = desc; pcf_loc = loc; pcf_attributes = attrs} = + sub.location sub loc; + sub.attributes sub attrs; + match desc with + | Pcf_inherit (_o, ce, _s) -> sub.class_expr sub ce + | Pcf_val (s, _m, k) -> iter_loc sub s; iter_kind sub k + | Pcf_method (s, _p, k) -> + iter_loc sub s; iter_kind sub k + | Pcf_constraint (t1, t2) -> + sub.typ sub t1; sub.typ sub t2 + | Pcf_initializer e -> sub.expr sub e + | Pcf_attribute x -> sub.attribute sub x + | Pcf_extension x -> sub.extension sub x -(* Computes the fixpoint for the variance and immediacy of type declarations *) + let iter_structure sub {pcstr_self; pcstr_fields} = + sub.pat sub pcstr_self; + List.iter (sub.class_field sub) pcstr_fields -let rec compute_properties_fixpoint env decls required variances immediacies = - let new_decls = - List.map2 - (fun (id, decl) (variance, immediacy) -> - id, {decl with type_variance = variance; type_immediate = immediacy}) - decls (List.combine variances immediacies) - in - let new_env = - List.fold_right - (fun (id, decl) env -> Env.add_type ~check:true id decl env) - new_decls env - in - let new_variances = - List.map2 - (fun (_id, decl) -> compute_variance_decl new_env false decl) - new_decls required - in - let new_variances = - List.map2 (List.map2 Variance.union) new_variances variances in - let new_immediacies = - List.map - (fun (_id, decl) -> compute_immediacy new_env decl) - new_decls - in - if new_variances <> variances || new_immediacies <> immediacies then - compute_properties_fixpoint env decls required new_variances new_immediacies - else begin - (* List.iter (fun (id, decl) -> - Printf.eprintf "%s:" (Ident.name id); - List.iter (fun (v : Variance.t) -> - Printf.eprintf " %x" (Obj.magic v : int)) - decl.type_variance; - prerr_endline "") - new_decls; *) - List.iter (fun (_, decl) -> - if (marked_as_immediate decl) && (not decl.type_immediate) then - raise (Error (decl.type_loc, Bad_immediate_attribute)) - else ()) - new_decls; - List.iter2 - (fun (id, decl) req -> if not (is_hash id) then - ignore (compute_variance_decl new_env true decl req)) - new_decls required; - new_decls, new_env - end + let class_infos sub f {pci_virt = _; pci_params = pl; pci_name; pci_expr; + pci_loc; pci_attributes} = + List.iter (iter_fst (sub.typ sub)) pl; + iter_loc sub pci_name; + f pci_expr; + sub.location sub pci_loc; + sub.attributes sub pci_attributes +end -let init_variance (_id, decl) = - List.map (fun _ -> Variance.null) decl.type_params +(* Now, a generic AST mapper, to be extended to cover all kinds and + cases of the OCaml grammar. The default behavior of the mapper is + the identity. *) -let add_injectivity = - List.map - (function - | Covariant -> (true, false, false) - | Contravariant -> (false, true, false) - | Invariant -> (false, false, false) - ) +let default_iterator = + { + structure = (fun this l -> List.iter (this.structure_item this) l); + structure_item = M.iter_structure_item; + module_expr = M.iter; + signature = (fun this l -> List.iter (this.signature_item this) l); + signature_item = MT.iter_signature_item; + module_type = MT.iter; + with_constraint = MT.iter_with_constraint; + class_declaration = + (fun this -> CE.class_infos this (this.class_expr this)); + class_expr = CE.iter; + class_field = CE.iter_field; + class_structure = CE.iter_structure; + class_type = CT.iter; + class_type_field = CT.iter_field; + class_signature = CT.iter_signature; + class_type_declaration = + (fun this -> CE.class_infos this (this.class_type this)); + class_description = + (fun this -> CE.class_infos this (this.class_type this)); + type_declaration = T.iter_type_declaration; + type_kind = T.iter_type_kind; + typ = T.iter; + type_extension = T.iter_type_extension; + extension_constructor = T.iter_extension_constructor; + value_description = + (fun this {pval_name; pval_type; pval_prim = _; pval_loc; + pval_attributes} -> + iter_loc this pval_name; + this.typ this pval_type; + this.attributes this pval_attributes; + this.location this pval_loc + ); -(* for typeclass.ml *) -let compute_variance_decls env cldecls = - let decls, required = - List.fold_right - (fun (obj_id, obj_abbr, _cl_abbr, _clty, _cltydef, ci) (decls, req) -> - let variance = List.map snd ci.ci_params in - (obj_id, obj_abbr) :: decls, - (add_injectivity variance, ci.ci_loc) :: req) - cldecls ([],[]) - in - let (decls, _) = - compute_properties_fixpoint env decls required - (List.map init_variance decls) - (List.map (fun _ -> false) decls) - in - List.map2 - (fun (_,decl) (_, _, cl_abbr, clty, cltydef, _) -> - let variance = decl.type_variance in - (decl, {cl_abbr with type_variance = variance}, - {clty with cty_variance = variance}, - {cltydef with clty_variance = variance})) - decls cldecls + pat = P.iter; + expr = E.iter; -(* Check multiple declarations of labels/constructors *) + module_declaration = + (fun this {pmd_name; pmd_type; pmd_attributes; pmd_loc} -> + iter_loc this pmd_name; + this.module_type this pmd_type; + this.attributes this pmd_attributes; + this.location this pmd_loc + ); -let check_duplicates sdecl_list = - let labels = Hashtbl.create 7 and constrs = Hashtbl.create 7 in - List.iter - (fun sdecl -> match sdecl.ptype_kind with - Ptype_variant cl -> - List.iter - (fun pcd -> - try - let name' = Hashtbl.find constrs pcd.pcd_name.txt in - Location.prerr_warning pcd.pcd_loc - (Warnings.Duplicate_definitions - ("constructor", pcd.pcd_name.txt, name', - sdecl.ptype_name.txt)) - with Not_found -> - Hashtbl.add constrs pcd.pcd_name.txt sdecl.ptype_name.txt) - cl - | Ptype_record fl -> - List.iter - (fun {pld_name=cname;pld_loc=loc} -> - try - let name' = Hashtbl.find labels cname.txt in - Location.prerr_warning loc - (Warnings.Duplicate_definitions - ("label", cname.txt, name', sdecl.ptype_name.txt)) - with Not_found -> Hashtbl.add labels cname.txt sdecl.ptype_name.txt) - fl - | Ptype_abstract -> () - | Ptype_open -> ()) - sdecl_list + module_type_declaration = + (fun this {pmtd_name; pmtd_type; pmtd_attributes; pmtd_loc} -> + iter_loc this pmtd_name; + iter_opt (this.module_type this) pmtd_type; + this.attributes this pmtd_attributes; + this.location this pmtd_loc + ); -(* Force recursion to go through id for private types*) -let name_recursion sdecl id decl = - match decl with - | { type_kind = Type_abstract; - type_manifest = Some ty; - type_private = Private; } when is_fixed_type sdecl -> - let ty = Ctype.repr ty in - let ty' = Btype.newty2 ty.level ty.desc in - if Ctype.deep_occur ty ty' then - let td = Tconstr(Path.Pident id, decl.type_params, ref Mnil) in - Btype.link_type ty (Btype.newty2 ty.level td); - {decl with type_manifest = Some ty'} - else decl - | _ -> decl + module_binding = + (fun this {pmb_name; pmb_expr; pmb_attributes; pmb_loc} -> + iter_loc this pmb_name; this.module_expr this pmb_expr; + this.attributes this pmb_attributes; + this.location this pmb_loc + ); -(* Translate a set of type declarations, mutually recursive or not *) -let transl_type_decl env rec_flag sdecl_list = - (* Add dummy types for fixed rows *) - let fixed_types = List.filter is_fixed_type sdecl_list in - let sdecl_list = - List.map - (fun sdecl -> - let ptype_name = - mkloc (sdecl.ptype_name.txt ^"#row") sdecl.ptype_name.loc in - {sdecl with - ptype_name; ptype_kind = Ptype_abstract; ptype_manifest = None}) - fixed_types - @ sdecl_list - in - (* Create identifiers. *) - let id_list = - List.map (fun sdecl -> Ident.create sdecl.ptype_name.txt) sdecl_list - in - (* - Since we've introduced fresh idents, make sure the definition - level is at least the binding time of these events. Otherwise, - passing one of the recursively-defined type constrs as argument - to an abbreviation may fail. - *) - Ctype.init_def(Ident.current_time()); - Ctype.begin_def(); - (* Enter types. *) - let temp_env = - List.fold_left2 (enter_type rec_flag) env sdecl_list id_list in - (* Translate each declaration. *) - let current_slot = ref None in - let warn_unused = Warnings.is_active (Warnings.Unused_type_declaration "") in - let id_slots id = - match rec_flag with - | Asttypes.Recursive when warn_unused -> - (* See typecore.ml for a description of the algorithm used - to detect unused declarations in a set of recursive definitions. *) - let slot = ref [] in - let td = Env.find_type (Path.Pident id) temp_env in - let name = Ident.name id in - Env.set_type_used_callback - name td - (fun old_callback -> - match !current_slot with - | Some slot -> slot := (name, td) :: !slot - | None -> - List.iter (fun (name, d) -> Env.mark_type_used env name d) - (get_ref slot); - old_callback () - ); - id, Some slot - | Asttypes.Recursive | Asttypes.Nonrecursive -> - id, None - in - let transl_declaration name_sdecl (id, slot) = - current_slot := slot; - Builtin_attributes.warning_scope - name_sdecl.ptype_attributes - (fun () -> transl_declaration temp_env name_sdecl id) - in - let tdecls = - List.map2 transl_declaration sdecl_list (List.map id_slots id_list) in - let decls = - List.map (fun tdecl -> (tdecl.typ_id, tdecl.typ_type)) tdecls in - current_slot := None; - (* Check for duplicates *) - check_duplicates sdecl_list; - (* Build the final env. *) - let newenv = - List.fold_right - (fun (id, decl) env -> Env.add_type ~check:true id decl env) - decls env - in - (* Update stubs *) - begin match rec_flag with - | Asttypes.Nonrecursive -> () - | Asttypes.Recursive -> - List.iter2 - (fun id sdecl -> update_type temp_env newenv id sdecl.ptype_loc) - id_list sdecl_list - end; - (* Generalize type declarations. *) - Ctype.end_def(); - List.iter (fun (_, decl) -> generalize_decl decl) decls; - (* Check for ill-formed abbrevs *) - let id_loc_list = - List.map2 (fun id sdecl -> (id, sdecl.ptype_loc)) - id_list sdecl_list - in - List.iter (fun (id, decl) -> - check_well_founded_manifest newenv (List.assoc id id_loc_list) - (Path.Pident id) decl) - decls; - let to_check = - function Path.Pident id -> List.mem_assoc id id_loc_list | _ -> false in - List.iter (fun (id, decl) -> - check_well_founded_decl newenv (List.assoc id id_loc_list) (Path.Pident id) - decl to_check) - decls; - List.iter (check_abbrev_recursion newenv id_loc_list to_check) tdecls; - (* Check that all type variables are closed *) - List.iter2 - (fun sdecl tdecl -> - let decl = tdecl.typ_type in - match Ctype.closed_type_decl decl with - Some ty -> raise(Error(sdecl.ptype_loc, Unbound_type_var(ty,decl))) - | None -> ()) - sdecl_list tdecls; - (* Check that constraints are enforced *) - List.iter2 (check_constraints newenv) sdecl_list decls; - (* Name recursion *) - let decls = - List.map2 (fun sdecl (id, decl) -> id, name_recursion sdecl id decl) - sdecl_list decls - in - (* Add variances to the environment *) - let required = - List.map - (fun sdecl -> - add_injectivity (List.map snd sdecl.ptype_params), - sdecl.ptype_loc - ) - sdecl_list - in - let final_decls, final_env = - compute_properties_fixpoint env decls required - (List.map init_variance decls) - (List.map (fun _ -> false) decls) - in - (* Check re-exportation *) - List.iter2 (check_abbrev final_env) sdecl_list final_decls; - (* Keep original declaration *) - let final_decls = - List.map2 - (fun tdecl (_id2, decl) -> - { tdecl with typ_type = decl } - ) tdecls final_decls - in - (* Done *) - (final_decls, final_env) + open_description = + (fun this {popen_lid; popen_override = _; popen_attributes; popen_loc} -> + iter_loc this popen_lid; + this.location this popen_loc; + this.attributes this popen_attributes + ); -(* Translating type extensions *) -let transl_extension_constructor env type_path type_params - typext_params priv sext = - let id = Ident.create sext.pext_name.txt in - let args, ret_type, kind = - match sext.pext_kind with - Pext_decl(sargs, sret_type) -> - let targs, tret_type, args, ret_type, _ = - make_constructor env type_path typext_params - sargs sret_type - in - args, ret_type, Text_decl(targs, tret_type) - | Pext_rebind lid -> - let cdescr = Typetexp.find_constructor env lid.loc lid.txt in - let usage = - if cdescr.cstr_private = Private || priv = Public - then Env.Positive else Env.Privatize - in - Env.mark_constructor usage env (Longident.last lid.txt) cdescr; - let (args, cstr_res) = Ctype.instance_constructor cdescr in - let res, ret_type = - if cdescr.cstr_generalized then - let params = Ctype.instance_list env type_params in - let res = Ctype.newconstr type_path params in - let ret_type = Some (Ctype.newconstr type_path params) in - res, ret_type - else (Ctype.newconstr type_path typext_params), None - in - begin - try - Ctype.unify env cstr_res res - with Ctype.Unify trace -> - raise (Error(lid.loc, - Rebind_wrong_type(lid.txt, env, trace))) - end; - (* Remove "_" names from parameters used in the constructor *) - if not cdescr.cstr_generalized then begin - let vars = - Ctype.free_variables (Btype.newgenty (Ttuple args)) - in - List.iter - (function {desc = Tvar (Some "_")} as ty -> - if List.memq ty vars then ty.desc <- Tvar None - | _ -> ()) - typext_params - end; - (* Ensure that constructor's type matches the type being extended *) - let cstr_type_path, cstr_type_params = - match cdescr.cstr_res.desc with - Tconstr (p, _, _) -> - let decl = Env.find_type p env in - p, decl.type_params - | _ -> assert false - in - let cstr_types = - (Btype.newgenty - (Tconstr(cstr_type_path, cstr_type_params, ref Mnil))) - :: cstr_type_params - in - let ext_types = - (Btype.newgenty - (Tconstr(type_path, type_params, ref Mnil))) - :: type_params - in - if not (Ctype.equal env true cstr_types ext_types) then - raise (Error(lid.loc, - Rebind_mismatch(lid.txt, cstr_type_path, type_path))); - (* Disallow rebinding private constructors to non-private *) - begin - match cdescr.cstr_private, priv with - Private, Public -> - raise (Error(lid.loc, Rebind_private lid.txt)) - | _ -> () - end; - let path = - match cdescr.cstr_tag with - Cstr_extension(path, _) -> path - | _ -> assert false - in - let args = - match cdescr.cstr_inlined with - | None -> - Types.Cstr_tuple args - | Some decl -> - let tl = - match args with - | [ {desc=Tconstr(_, tl, _)} ] -> tl - | _ -> assert false - in - let decl = Ctype.instance_declaration decl in - assert (List.length decl.type_params = List.length tl); - List.iter2 (Ctype.unify env) decl.type_params tl; - let lbls = - match decl.type_kind with - | Type_record (lbls, Record_extension) -> lbls - | _ -> assert false - in - Types.Cstr_record lbls - in - args, ret_type, Text_rebind(path, lid) - in - let ext = - { ext_type_path = type_path; - ext_type_params = typext_params; - ext_args = args; - ext_ret_type = ret_type; - ext_private = priv; - Types.ext_loc = sext.pext_loc; - Types.ext_attributes = sext.pext_attributes; } - in - { ext_id = id; - ext_name = sext.pext_name; - ext_type = ext; - ext_kind = kind; - Typedtree.ext_loc = sext.pext_loc; - Typedtree.ext_attributes = sext.pext_attributes; } + include_description = + (fun this {pincl_mod; pincl_attributes; pincl_loc} -> + this.module_type this pincl_mod; + this.location this pincl_loc; + this.attributes this pincl_attributes + ); -let transl_extension_constructor env type_path type_params - typext_params priv sext = - Builtin_attributes.warning_scope sext.pext_attributes - (fun () -> transl_extension_constructor env type_path type_params - typext_params priv sext) + include_declaration = + (fun this {pincl_mod; pincl_attributes; pincl_loc} -> + this.module_expr this pincl_mod; + this.location this pincl_loc; + this.attributes this pincl_attributes + ); -let transl_type_extension extend env loc styext = - reset_type_variables(); - Ctype.begin_def(); - let (type_path, type_decl) = - let lid = styext.ptyext_path in - Typetexp.find_type env lid.loc lid.txt - in - begin - match type_decl.type_kind with - | Type_open -> begin - match type_decl.type_private with - | Private when extend -> begin - match - List.find - (function {pext_kind = Pext_decl _} -> true - | {pext_kind = Pext_rebind _} -> false) - styext.ptyext_constructors - with - | {pext_loc} -> - raise (Error(pext_loc, Cannot_extend_private_type type_path)) - | exception Not_found -> () - end - | _ -> () - end - | _ -> - raise (Error(loc, Not_extensible_type type_path)) - end; - let type_variance = - List.map (fun v -> - let (co, cn) = Variance.get_upper v in - (not cn, not co, false)) - type_decl.type_variance - in - let err = - if type_decl.type_arity <> List.length styext.ptyext_params then - [Includecore.Arity] - else - if List.for_all2 - (fun (c1, n1, _) (c2, n2, _) -> (not c2 || c1) && (not n2 || n1)) - type_variance - (add_injectivity (List.map snd styext.ptyext_params)) - then [] else [Includecore.Variance] - in - if err <> [] then - raise (Error(loc, Extension_mismatch (type_path, err))); - let ttype_params = make_params env styext.ptyext_params in - let type_params = List.map (fun (cty, _) -> cty.ctyp_type) ttype_params in - List.iter2 (Ctype.unify_var env) - (Ctype.instance_list env type_decl.type_params) - type_params; - let constructors = - List.map (transl_extension_constructor env type_path - type_decl.type_params type_params styext.ptyext_private) - styext.ptyext_constructors - in - Ctype.end_def(); - (* Generalize types *) - List.iter Ctype.generalize type_params; - List.iter - (fun ext -> - Btype.iter_type_expr_cstr_args Ctype.generalize ext.ext_type.ext_args; - may Ctype.generalize ext.ext_type.ext_ret_type) - constructors; - (* Check that all type variables are closed *) - List.iter - (fun ext -> - match Ctype.closed_extension_constructor ext.ext_type with - Some ty -> - raise(Error(ext.ext_loc, Unbound_type_var_ext(ty, ext.ext_type))) - | None -> ()) - constructors; - (* Check variances are correct *) - List.iter - (fun ext-> - ignore (compute_variance_extension env true type_decl - ext.ext_type (type_variance, loc))) - constructors; - (* Add extension constructors to the environment *) - let newenv = - List.fold_left - (fun env ext -> - Env.add_extension ~check:true ext.ext_id ext.ext_type env) - env constructors - in - let tyext = - { tyext_path = type_path; - tyext_txt = styext.ptyext_path; - tyext_params = ttype_params; - tyext_constructors = constructors; - tyext_private = styext.ptyext_private; - tyext_attributes = styext.ptyext_attributes; } - in - (tyext, newenv) -let transl_type_extension extend env loc styext = - Builtin_attributes.warning_scope styext.ptyext_attributes - (fun () -> transl_type_extension extend env loc styext) + value_binding = + (fun this {pvb_pat; pvb_expr; pvb_attributes; pvb_loc} -> + this.pat this pvb_pat; + this.expr this pvb_expr; + this.location this pvb_loc; + this.attributes this pvb_attributes + ); -let transl_exception env sext = - reset_type_variables(); - Ctype.begin_def(); - let ext = - transl_extension_constructor env - Predef.path_exn [] [] Asttypes.Public sext - in - Ctype.end_def(); - (* Generalize types *) - Btype.iter_type_expr_cstr_args Ctype.generalize ext.ext_type.ext_args; - may Ctype.generalize ext.ext_type.ext_ret_type; - (* Check that all type variables are closed *) - begin match Ctype.closed_extension_constructor ext.ext_type with - Some ty -> - raise (Error(ext.ext_loc, Unbound_type_var_ext(ty, ext.ext_type))) - | None -> () - end; - let newenv = Env.add_extension ~check:true ext.ext_id ext.ext_type env in - ext, newenv -type native_repr_attribute = - | Native_repr_attr_absent - | Native_repr_attr_present of native_repr_kind + constructor_declaration = + (fun this {pcd_name; pcd_args; pcd_res; pcd_loc; pcd_attributes} -> + iter_loc this pcd_name; + T.iter_constructor_arguments this pcd_args; + iter_opt (this.typ this) pcd_res; + this.location this pcd_loc; + this.attributes this pcd_attributes + ); -let get_native_repr_attribute attrs ~global_repr = - match - Attr_helper.get_no_payload_attribute ["unboxed"; "ocaml.unboxed"] attrs, - Attr_helper.get_no_payload_attribute ["untagged"; "ocaml.untagged"] attrs, - global_repr - with - | None, None, None -> Native_repr_attr_absent - | None, None, Some repr -> Native_repr_attr_present repr - | Some _, None, None -> Native_repr_attr_present Unboxed - | None, Some _, None -> Native_repr_attr_present Untagged - | Some { Location.loc }, _, _ - | _, Some { Location.loc }, _ -> - raise (Error (loc, Multiple_native_repr_attributes)) + label_declaration = + (fun this {pld_name; pld_type; pld_loc; pld_mutable = _; pld_attributes}-> + iter_loc this pld_name; + this.typ this pld_type; + this.location this pld_loc; + this.attributes this pld_attributes + ); -let native_repr_of_type env kind ty = - match kind, (Ctype.expand_head_opt env ty).desc with - | Untagged, Tconstr (path, _, _) when Path.same path Predef.path_int -> - Some Untagged_int - | Unboxed, Tconstr (path, _, _) when Path.same path Predef.path_float -> - Some Unboxed_float - | Unboxed, Tconstr (path, _, _) when Path.same path Predef.path_int32 -> - Some (Unboxed_integer Pint32) - | Unboxed, Tconstr (path, _, _) when Path.same path Predef.path_int64 -> - Some (Unboxed_integer Pint64) - | Unboxed, Tconstr (path, _, _) when Path.same path Predef.path_nativeint -> - Some (Unboxed_integer Pnativeint) - | _ -> - None + cases = (fun this l -> List.iter (this.case this) l); + case = + (fun this {pc_lhs; pc_guard; pc_rhs} -> + this.pat this pc_lhs; + iter_opt (this.expr this) pc_guard; + this.expr this pc_rhs + ); -(* Raises an error when [core_type] contains an [@unboxed] or [@untagged] - attribute in a strict sub-term. *) -let error_if_has_deep_native_repr_attributes core_type = - let open Ast_iterator in - let this_iterator = - { default_iterator with typ = fun iterator core_type -> - begin - match - get_native_repr_attribute core_type.ptyp_attributes ~global_repr:None - with - | Native_repr_attr_present kind -> - raise (Error (core_type.ptyp_loc, - Deep_unbox_or_untag_attribute kind)) - | Native_repr_attr_absent -> () - end; - default_iterator.typ iterator core_type } - in - default_iterator.typ this_iterator core_type + location = (fun _this _l -> ()); -let make_native_repr env core_type ty ~global_repr = - error_if_has_deep_native_repr_attributes core_type; - match get_native_repr_attribute core_type.ptyp_attributes ~global_repr with - | Native_repr_attr_absent -> - Same_as_ocaml_repr - | Native_repr_attr_present kind -> - begin match native_repr_of_type env kind ty with - | None -> - raise (Error (core_type.ptyp_loc, Cannot_unbox_or_untag_type kind)) - | Some repr -> repr - end + extension = (fun this (s, e) -> iter_loc this s; this.payload this e); + attribute = (fun this (s, e) -> iter_loc this s; this.payload this e); + attributes = (fun this l -> List.iter (this.attribute this) l); + payload = + (fun this -> function + | PStr x -> this.structure this x + | PSig x -> this.signature this x + | PTyp x -> this.typ this x + | PPat (x, g) -> this.pat this x; iter_opt (this.expr this) g + ); + } -let rec parse_native_repr_attributes env core_type ty ~global_repr = - match core_type.ptyp_desc, (Ctype.repr ty).desc, - get_native_repr_attribute core_type.ptyp_attributes ~global_repr:None - with - | Ptyp_arrow _, Tarrow _, Native_repr_attr_present kind -> - raise (Error (core_type.ptyp_loc, Cannot_unbox_or_untag_type kind)) - | Ptyp_arrow (_, ct1, ct2), Tarrow (_, t1, t2, _), _ -> - let repr_arg = make_native_repr env ct1 t1 ~global_repr in - let repr_args, repr_res = - parse_native_repr_attributes env ct2 t2 ~global_repr - in - (repr_arg :: repr_args, repr_res) - | Ptyp_arrow _, _, _ | _, Tarrow _, _ -> assert false - | _ -> ([], make_native_repr env core_type ty ~global_repr) +end +module Typetexp : sig +#1 "typetexp.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) +(* Typechecking of type expressions for the core language *) -let check_unboxable env loc ty = - let ty = Ctype.repr (Ctype.expand_head_opt env ty) in - try match ty.desc with - | Tconstr (p, _, _) -> - let tydecl = Env.find_type p env in - if tydecl.type_unboxed.unboxed then - Location.prerr_warning loc - (Warnings.Unboxable_type_in_prim_decl (Path.name p)) - | _ -> () - with Not_found -> () +open Types -(* Translate a value declaration *) -let transl_value_decl env loc valdecl = - let cty = Typetexp.transl_type_scheme env valdecl.pval_type in - let ty = cty.ctyp_type in - let v = - match valdecl.pval_prim with - [] when Env.is_in_signature env -> - { val_type = ty; val_kind = Val_reg; Types.val_loc = loc; - val_attributes = valdecl.pval_attributes } - | [] -> - raise (Error(valdecl.pval_loc, Val_in_structure)) - | _ -> - let global_repr = - match - get_native_repr_attribute valdecl.pval_attributes ~global_repr:None - with - | Native_repr_attr_present repr -> Some repr - | Native_repr_attr_absent -> None - in - let native_repr_args, native_repr_res = - if !Clflags.bs_only then - let rec scann (attrs : Parsetree.attributes) = - match attrs with - | ({txt = "internal.arity";_}, - PStr [ {pstr_desc = Pstr_eval - ( - ({pexp_desc = Pexp_constant (Pconst_integer (i,_))} : - Parsetree.expression) ,_)}]) :: _ -> - Some (int_of_string i) - | _ :: rest -> scann rest - | [] -> None - and make n = - if n = 0 then [] - else Primitive.Same_as_ocaml_repr :: make (n - 1) - in - match scann valdecl.pval_attributes with - | None -> parse_native_repr_attributes env valdecl.pval_type ty ~global_repr - | Some x -> make x , Primitive.Same_as_ocaml_repr - else - parse_native_repr_attributes env valdecl.pval_type ty ~global_repr - in - let prim = - Primitive.parse_declaration valdecl - ~native_repr_args - ~native_repr_res - in - let prim_native_name = prim.prim_native_name in - if prim.prim_arity = 0 && - not ( String.length prim_native_name > 3 && - String.unsafe_get prim_native_name 0 = 'B' && - String.unsafe_get prim_native_name 1 = 'S' && - String.unsafe_get prim_native_name 2 = ':' - ) && - (prim.prim_name = "" || (prim.prim_name.[0] <> '%' && prim.prim_name.[0] <> '#')) then - raise(Error(valdecl.pval_type.ptyp_loc, Null_arity_external)); - if !Clflags.native_code - && prim.prim_arity > 5 - && prim_native_name = "" - then raise(Error(valdecl.pval_type.ptyp_loc, Missing_native_external)); - Btype.iter_type_expr (check_unboxable env loc) ty; - { val_type = ty; val_kind = Val_prim prim; Types.val_loc = loc; - val_attributes = valdecl.pval_attributes } - in - let (id, newenv) = - Env.enter_value valdecl.pval_name.txt v env - ~check:(fun s -> Warnings.Unused_value_declaration s) - in - let desc = - { - val_id = id; - val_name = valdecl.pval_name; - val_desc = cty; val_val = v; - val_prim = valdecl.pval_prim; - val_loc = valdecl.pval_loc; - val_attributes = valdecl.pval_attributes; - } - in - desc, newenv +val transl_simple_type: + Env.t -> bool -> Parsetree.core_type -> Typedtree.core_type +val transl_simple_type_univars: + Env.t -> Parsetree.core_type -> Typedtree.core_type +val transl_simple_type_delayed: + Env.t -> Parsetree.core_type -> Typedtree.core_type * (unit -> unit) + (* Translate a type, but leave type variables unbound. Returns + the type and a function that binds the type variable. *) +val transl_type_scheme: + Env.t -> Parsetree.core_type -> Typedtree.core_type +val reset_type_variables: unit -> unit +val type_variable: Location.t -> string -> type_expr +val transl_type_param: + Env.t -> Parsetree.core_type -> Typedtree.core_type + +type variable_context +val narrow: unit -> variable_context +val widen: variable_context -> unit + +exception Already_bound + +type error = + Unbound_type_variable of string + | Unbound_type_constructor of Longident.t + | Unbound_type_constructor_2 of Path.t + | Type_arity_mismatch of Longident.t * int * int + | Bound_type_variable of string + | Recursive_type + | Unbound_row_variable of Longident.t + | Type_mismatch of (type_expr * type_expr) list + | Alias_type_mismatch of (type_expr * type_expr) list + | Present_has_conjunction of string + | Present_has_no_type of string + | Constructor_mismatch of type_expr * type_expr + | Not_a_variant of type_expr + | Variant_tags of string * string + | Invalid_variable_name of string + | Cannot_quantify of string * type_expr + | Multiple_constraints_on_type of Longident.t + | Method_mismatch of string * type_expr * type_expr + | Unbound_value of Longident.t + | Unbound_constructor of Longident.t + | Unbound_label of Longident.t + | Unbound_module of Longident.t + | Unbound_class of Longident.t + | Unbound_modtype of Longident.t + | Unbound_cltype of Longident.t + | Ill_typed_functor_application of Longident.t + | Illegal_reference_to_recursive_module + | Access_functor_as_structure of Longident.t + | Apply_structure_as_functor of Longident.t + | Cannot_scrape_alias of Longident.t * Path.t + | Opened_object of Path.t option + | Not_an_object of type_expr -let transl_value_decl env loc valdecl = - Builtin_attributes.warning_scope valdecl.pval_attributes - (fun () -> transl_value_decl env loc valdecl) +exception Error of Location.t * Env.t * error -(* Translate a "with" constraint -- much simplified version of - transl_type_decl. *) -let transl_with_constraint env id row_path orig_decl sdecl = - Env.mark_type_used env (Ident.name id) orig_decl; - reset_type_variables(); - Ctype.begin_def(); - let tparams = make_params env sdecl.ptype_params in - let params = List.map (fun (cty, _) -> cty.ctyp_type) tparams in - let orig_decl = Ctype.instance_declaration orig_decl in - let arity_ok = List.length params = orig_decl.type_arity in - if arity_ok then - List.iter2 (Ctype.unify_var env) params orig_decl.type_params; - let constraints = List.map - (function (ty, ty', loc) -> - try - let cty = transl_simple_type env false ty in - let cty' = transl_simple_type env false ty' in - let ty = cty.ctyp_type in - let ty' = cty'.ctyp_type in - Ctype.unify env ty ty'; - (cty, cty', loc) - with Ctype.Unify tr -> - raise(Error(loc, Inconsistent_constraint (env, tr)))) - sdecl.ptype_cstrs - in - let no_row = not (is_fixed_type sdecl) in - let (tman, man) = match sdecl.ptype_manifest with - None -> None, None - | Some sty -> - let cty = transl_simple_type env no_row sty in - Some cty, Some cty.ctyp_type - in - let priv = - if sdecl.ptype_private = Private then Private else - if arity_ok && orig_decl.type_kind <> Type_abstract - then orig_decl.type_private else sdecl.ptype_private - in - if arity_ok && orig_decl.type_kind <> Type_abstract - && sdecl.ptype_private = Private then - Location.deprecated sdecl.ptype_loc "spurious use of private"; - let type_kind, type_unboxed = - if arity_ok && man <> None then - orig_decl.type_kind, orig_decl.type_unboxed - else - Type_abstract, unboxed_false_default_false - in - let decl = - { type_params = params; - type_arity = List.length params; - type_kind; - type_private = priv; - type_manifest = man; - type_variance = []; - type_newtype_level = None; - type_loc = sdecl.ptype_loc; - type_attributes = sdecl.ptype_attributes; - type_immediate = false; - type_unboxed; - } - in - begin match row_path with None -> () - | Some p -> set_fixed_row env sdecl.ptype_loc p decl - end; - begin match Ctype.closed_type_decl decl with None -> () - | Some ty -> raise(Error(sdecl.ptype_loc, Unbound_type_var(ty,decl))) - end; - let decl = name_recursion sdecl id decl in - let type_variance = - compute_variance_decl env true decl - (add_injectivity (List.map snd sdecl.ptype_params), sdecl.ptype_loc) - in - let type_immediate = compute_immediacy env decl in - let decl = {decl with type_variance; type_immediate} in - Ctype.end_def(); - generalize_decl decl; - { - typ_id = id; - typ_name = sdecl.ptype_name; - typ_params = tparams; - typ_type = decl; - typ_cstrs = constraints; - typ_loc = sdecl.ptype_loc; - typ_manifest = tman; - typ_kind = Ttype_abstract; - typ_private = sdecl.ptype_private; - typ_attributes = sdecl.ptype_attributes; - } +val report_error: Env.t -> Format.formatter -> error -> unit -(* Approximate a type declaration: just make all types abstract *) +(* Support for first-class modules. *) +val transl_modtype_longident: (* from Typemod *) + (Location.t -> Env.t -> Longident.t -> Path.t) ref +val transl_modtype: (* from Typemod *) + (Env.t -> Parsetree.module_type -> Typedtree.module_type) ref +val create_package_mty: + Location.t -> Env.t -> Parsetree.package_type -> + (Longident.t Asttypes.loc * Parsetree.core_type) list * + Parsetree.module_type -let abstract_type_decl arity = - let rec make_params n = - if n <= 0 then [] else Ctype.newvar() :: make_params (n-1) in - Ctype.begin_def(); - let decl = - { type_params = make_params arity; - type_arity = arity; - type_kind = Type_abstract; - type_private = Public; - type_manifest = None; - type_variance = replicate_list Variance.full arity; - type_newtype_level = None; - type_loc = Location.none; - type_attributes = []; - type_immediate = false; - type_unboxed = unboxed_false_default_false; - } in - Ctype.end_def(); - generalize_decl decl; - decl +val find_type: + Env.t -> Location.t -> Longident.t -> Path.t * type_declaration +val find_constructor: + Env.t -> Location.t -> Longident.t -> constructor_description +val find_all_constructors: + Env.t -> Location.t -> Longident.t -> + (constructor_description * (unit -> unit)) list +val find_label: + Env.t -> Location.t -> Longident.t -> label_description +val find_all_labels: + Env.t -> Location.t -> Longident.t -> + (label_description * (unit -> unit)) list +val find_value: + Env.t -> Location.t -> Longident.t -> Path.t * value_description +val find_class: + Env.t -> Location.t -> Longident.t -> Path.t * class_declaration +val find_module: + Env.t -> Location.t -> Longident.t -> Path.t * module_declaration +val lookup_module: + ?load:bool -> Env.t -> Location.t -> Longident.t -> Path.t +val find_modtype: + Env.t -> Location.t -> Longident.t -> Path.t * modtype_declaration +val find_class_type: + Env.t -> Location.t -> Longident.t -> Path.t * class_type_declaration -let approx_type_decl sdecl_list = - List.map - (fun sdecl -> - (Ident.create sdecl.ptype_name.txt, - abstract_type_decl (List.length sdecl.ptype_params))) - sdecl_list +val unbound_constructor_error: Env.t -> Longident.t Location.loc -> 'a +val unbound_label_error: Env.t -> Longident.t Location.loc -> 'a -(* Variant of check_abbrev_recursion to check the well-formedness - conditions on type abbreviations defined within recursive modules. *) -let check_recmod_typedecl env loc recmod_ids path decl = - (* recmod_ids is the list of recursively-defined module idents. - (path, decl) is the type declaration to be checked. *) - let to_check path = - List.exists (fun id -> Path.isfree id path) recmod_ids in - check_well_founded_decl env loc path decl to_check; - check_recursion env loc path decl to_check +val spellcheck: + Format.formatter -> + (('a -> 'a list -> 'a list) -> + Longident.t option -> 'b -> 'c list -> string list) -> + 'b -> Longident.t -> unit +end = struct +#1 "typetexp.ml" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -(**** Error report ****) +(* typetexp.ml,v 1.34.4.9 2002/01/07 08:39:16 garrigue Exp *) -open Format +(* Typechecking of type expressions for the core language *) -let explain_unbound_gen ppf tv tl typ kwd pr = - try - let ti = List.find (fun ti -> Ctype.deep_occur tv (typ ti)) tl in - let ty0 = (* Hack to force aliasing when needed *) - Btype.newgenty (Tobject(tv, ref None)) in - Printtyp.reset_and_mark_loops_list [typ ti; ty0]; - fprintf ppf - ".@.@[In %s@ %a@;<1 -2>the variable %a is unbound@]" - kwd pr ti Printtyp.type_expr tv - with Not_found -> () +open Asttypes +open Misc +open Parsetree +open Typedtree +open Types +open Ctype -let explain_unbound ppf tv tl typ kwd lab = - explain_unbound_gen ppf tv tl typ kwd - (fun ppf ti -> fprintf ppf "%s%a" (lab ti) Printtyp.type_expr (typ ti)) +exception Already_bound -let explain_unbound_single ppf tv ty = - let trivial ty = - explain_unbound ppf tv [ty] (fun t -> t) "type" (fun _ -> "") in - match (Ctype.repr ty).desc with - Tobject(fi,_) -> - let (tl, rv) = Ctype.flatten_fields fi in - if rv == tv then trivial ty else - explain_unbound ppf tv tl (fun (_,_,t) -> t) - "method" (fun (lab,_,_) -> lab ^ ": ") - | Tvariant row -> - let row = Btype.row_repr row in - if row.row_more == tv then trivial ty else - explain_unbound ppf tv row.row_fields - (fun (_l,f) -> match Btype.row_field_repr f with - Rpresent (Some t) -> t - | Reither (_,[t],_,_) -> t - | Reither (_,tl,_,_) -> Btype.newgenty (Ttuple tl) - | _ -> Btype.newgenty (Ttuple[])) - "case" (fun (lab,_) -> "`" ^ lab ^ " of ") - | _ -> trivial ty +type error = + Unbound_type_variable of string + | Unbound_type_constructor of Longident.t + | Unbound_type_constructor_2 of Path.t + | Type_arity_mismatch of Longident.t * int * int + | Bound_type_variable of string + | Recursive_type + | Unbound_row_variable of Longident.t + | Type_mismatch of (type_expr * type_expr) list + | Alias_type_mismatch of (type_expr * type_expr) list + | Present_has_conjunction of string + | Present_has_no_type of string + | Constructor_mismatch of type_expr * type_expr + | Not_a_variant of type_expr + | Variant_tags of string * string + | Invalid_variable_name of string + | Cannot_quantify of string * type_expr + | Multiple_constraints_on_type of Longident.t + | Method_mismatch of string * type_expr * type_expr + | Unbound_value of Longident.t + | Unbound_constructor of Longident.t + | Unbound_label of Longident.t + | Unbound_module of Longident.t + | Unbound_class of Longident.t + | Unbound_modtype of Longident.t + | Unbound_cltype of Longident.t + | Ill_typed_functor_application of Longident.t + | Illegal_reference_to_recursive_module + | Access_functor_as_structure of Longident.t + | Apply_structure_as_functor of Longident.t + | Cannot_scrape_alias of Longident.t * Path.t + | Opened_object of Path.t option + | Not_an_object of type_expr +exception Error of Location.t * Env.t * error +exception Error_forward of Location.error -let tys_of_constr_args = function - | Types.Cstr_tuple tl -> tl - | Types.Cstr_record lbls -> List.map (fun l -> l.Types.ld_type) lbls -let report_error ppf = function - | Repeated_parameter -> - fprintf ppf "A type parameter occurs several times" - | Duplicate_constructor s -> - fprintf ppf "Two constructors are named %s" s - | Too_many_constructors -> - fprintf ppf - "@[Too many non-constant constructors@ -- maximum is %i %s@]" - (Config.max_tag + 1) "non-constant constructors" - | Duplicate_label s -> - fprintf ppf "Two labels are named %s" s - | Recursive_abbrev s -> - fprintf ppf "The type abbreviation %s is cyclic" s - | Cycle_in_def (s, ty) -> - Printtyp.reset_and_mark_loops ty; - fprintf ppf "@[The definition of %s contains a cycle:@ %a@]" - s Printtyp.type_expr ty - | Definition_mismatch (ty, errs) -> - Printtyp.reset_and_mark_loops ty; - fprintf ppf "@[@[%s@ %s@;<1 2>%a@]%a@]" - "This variant or record definition" "does not match that of type" - Printtyp.type_expr ty - (Includecore.report_type_mismatch "the original" "this" "definition") - errs - | Constraint_failed (ty, ty') -> - Printtyp.reset_and_mark_loops ty; - Printtyp.mark_loops ty'; - fprintf ppf "@[%s@ @[Type@ %a@ should be an instance of@ %a@]@]" - "Constraints are not satisfied in this type." - Printtyp.type_expr ty Printtyp.type_expr ty' - | Parameters_differ (path, ty, ty') -> - Printtyp.reset_and_mark_loops ty; - Printtyp.mark_loops ty'; - fprintf ppf - "@[In the definition of %s, type@ %a@ should be@ %a@]" - (Path.name path) Printtyp.type_expr ty Printtyp.type_expr ty' - | Inconsistent_constraint (env, trace) -> - fprintf ppf "The type constraints are not consistent.@."; - Printtyp.report_unification_error ppf env trace - (fun ppf -> fprintf ppf "Type") - (fun ppf -> fprintf ppf "is not compatible with type") - | Type_clash (env, trace) -> - Printtyp.report_unification_error ppf env trace - (function ppf -> - fprintf ppf "This type constructor expands to type") - (function ppf -> - fprintf ppf "but is used here with type") - | Null_arity_external -> - fprintf ppf "External identifiers must be functions" - | Missing_native_external -> - fprintf ppf "@[An external function with more than 5 arguments \ - requires a second stub function@ \ - for native-code compilation@]" - | Unbound_type_var (ty, decl) -> - fprintf ppf "A type variable is unbound in this type declaration"; - let ty = Ctype.repr ty in - begin match decl.type_kind, decl.type_manifest with - | Type_variant tl, _ -> - explain_unbound_gen ppf ty tl (fun c -> - let tl = tys_of_constr_args c.Types.cd_args in - Btype.newgenty (Ttuple tl) - ) - "case" (fun ppf c -> - fprintf ppf - "%s of %a" (Ident.name c.Types.cd_id) - Printtyp.constructor_arguments c.Types.cd_args) - | Type_record (tl, _), _ -> - explain_unbound ppf ty tl (fun l -> l.Types.ld_type) - "field" (fun l -> Ident.name l.Types.ld_id ^ ": ") - | Type_abstract, Some ty' -> - explain_unbound_single ppf ty ty' +type variable_context = int * (string, type_expr) Tbl.t + +(* Local definitions *) + +let instance_list = Ctype.instance_list Env.empty + +(* Narrowing unbound identifier errors. *) + +let rec narrow_unbound_lid_error : 'a. _ -> _ -> _ -> _ -> 'a = + fun env loc lid make_error -> + let check_module mlid = + try ignore (Env.lookup_module ~load:true mlid env) with + | Not_found -> + narrow_unbound_lid_error env loc mlid (fun lid -> Unbound_module lid) + | Env.Recmodule -> + raise (Error (loc, env, Illegal_reference_to_recursive_module)) + in + begin match lid with + | Longident.Lident _ -> () + | Longident.Ldot (mlid, _) -> + check_module mlid; + let md = Env.find_module (Env.lookup_module ~load:true mlid env) env in + begin match Env.scrape_alias env md.md_type with + | Mty_functor _ -> + raise (Error (loc, env, Access_functor_as_structure mlid)) + | Mty_alias(_, p) -> + raise (Error (loc, env, Cannot_scrape_alias(mlid, p))) | _ -> () end - | Unbound_type_var_ext (ty, ext) -> - fprintf ppf "A type variable is unbound in this extension constructor"; - let args = tys_of_constr_args ext.ext_args in - explain_unbound ppf ty args (fun c -> c) "type" (fun _ -> "") - | Cannot_extend_private_type path -> - fprintf ppf "@[%s@ %a@]" - "Cannot extend private type definition" - Printtyp.path path - | Not_extensible_type path -> - fprintf ppf "@[%s@ %a@ %s@]" - "Type definition" - Printtyp.path path - "is not extensible" - | Extension_mismatch (path, errs) -> - fprintf ppf "@[@[%s@ %s@;<1 2>%s@]%a@]" - "This extension" "does not match the definition of type" - (Path.name path) - (Includecore.report_type_mismatch - "the type" "this extension" "definition") - errs - | Rebind_wrong_type (lid, env, trace) -> - Printtyp.report_unification_error ppf env trace - (function ppf -> - fprintf ppf "The constructor %a@ has type" - Printtyp.longident lid) - (function ppf -> - fprintf ppf "but was expected to be of type") - | Rebind_mismatch (lid, p, p') -> - fprintf ppf - "@[%s@ %a@ %s@ %s@ %s@ %s@ %s@]" - "The constructor" Printtyp.longident lid - "extends type" (Path.name p) - "whose declaration does not match" - "the declaration of type" (Path.name p') - | Rebind_private lid -> - fprintf ppf "@[%s@ %a@ %s@]" - "The constructor" - Printtyp.longident lid - "is private" - | Bad_variance (n, v1, v2) -> - let variance (p,n,i) = - let inj = if i then "injective " else "" in - match p, n with - true, true -> inj ^ "invariant" - | true, false -> inj ^ "covariant" - | false, true -> inj ^ "contravariant" - | false, false -> if inj = "" then "unrestricted" else inj - in - let suffix n = - let teen = (n mod 100)/10 = 1 in - match n mod 10 with - | 1 when not teen -> "st" - | 2 when not teen -> "nd" - | 3 when not teen -> "rd" - | _ -> "th" - in - if n = -1 then - fprintf ppf "@[%s@ %s@ It" - "In this definition, a type variable has a variance that" - "is not reflected by its occurrence in type parameters." - else if n = -2 then - fprintf ppf "@[%s@ %s@]" - "In this definition, a type variable cannot be deduced" - "from the type parameters." - else if n = -3 then - fprintf ppf "@[%s@ %s@ It" - "In this definition, a type variable has a variance that" - "cannot be deduced from the type parameters." - else - fprintf ppf "@[%s@ %s@ The %d%s type parameter" - "In this definition, expected parameter" - "variances are not satisfied." - n (suffix n); - if n <> -2 then - fprintf ppf " was expected to be %s,@ but it is %s.@]" - (variance v2) (variance v1) - | Unavailable_type_constructor p -> - fprintf ppf "The definition of type %a@ is unavailable" Printtyp.path p - | Bad_fixed_type r -> - fprintf ppf "This fixed type %s" r - | Varying_anonymous -> - fprintf ppf "@[%s@ %s@ %s@]" - "In this GADT definition," "the variance of some parameter" - "cannot be checked" - | Val_in_structure -> - fprintf ppf "Value declarations are only allowed in signatures" - | Multiple_native_repr_attributes -> - fprintf ppf "Too many [@@unboxed]/[@@untagged] attributes" - | Cannot_unbox_or_untag_type Unboxed -> - fprintf ppf "Don't know how to unbox this type. Only float, int32, \ - int64 and nativeint can be unboxed" - | Cannot_unbox_or_untag_type Untagged -> - fprintf ppf "Don't know how to untag this type. Only int \ - can be untagged" - | Deep_unbox_or_untag_attribute kind -> - fprintf ppf - "The attribute '%s' should be attached to a direct argument or \ - result of the primitive, it should not occur deeply into its type" - (match kind with Unboxed -> "@unboxed" | Untagged -> "@untagged") - | Bad_immediate_attribute -> - fprintf ppf "@[%s@ %s@]" - "Types marked with the immediate attribute must be" - "non-pointer types like int or bool" - | Bad_unboxed_attribute msg -> - fprintf ppf "@[This type cannot be unboxed because@ %s.@]" msg - | Wrong_unboxed_type_float -> - fprintf ppf "@[This type cannot be unboxed because@ \ - it might contain both float and non-float values.@ \ - You should annotate it with [%@%@ocaml.boxed].@]" - | Boxed_and_unboxed -> - fprintf ppf "@[A type cannot be boxed and unboxed at the same time.@]" - | Nonrec_gadt -> - fprintf ppf - "@[GADT case syntax cannot be used in a 'nonrec' block.@]" - -let () = - Location.register_error_of_exn - (function - | Error (loc, err) -> - Some (Location.error_of_printer loc report_error err) + | Longident.Lapply (flid, mlid) -> + check_module flid; + let fmd = Env.find_module (Env.lookup_module ~load:true flid env) env in + begin match Env.scrape_alias env fmd.md_type with + | Mty_signature _ -> + raise (Error (loc, env, Apply_structure_as_functor flid)) + | Mty_alias(_, p) -> + raise (Error (loc, env, Cannot_scrape_alias(flid, p))) + | _ -> () + end; + check_module mlid; + let mmd = Env.find_module (Env.lookup_module ~load:true mlid env) env in + begin match Env.scrape_alias env mmd.md_type with + | Mty_alias(_, p) -> + raise (Error (loc, env, Cannot_scrape_alias(mlid, p))) | _ -> - None - ) + raise (Error (loc, env, Ill_typed_functor_application lid)) + end + end; + raise (Error (loc, env, make_error lid)) -end -module Lambda : sig -#1 "lambda.mli" -(**************************************************************************) -(* *) -(* OCaml *) -(* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) -(* *) -(* Copyright 1996 Institut National de Recherche en Informatique et *) -(* en Automatique. *) -(* *) -(* All rights reserved. This file is distributed under the terms of *) -(* the GNU Lesser General Public License version 2.1, with the *) -(* special exception on linking described in the file LICENSE. *) -(* *) -(**************************************************************************) +let find_component (lookup : ?loc:_ -> _) make_error env loc lid = + try + match lid with + | Longident.Ldot (Longident.Lident "*predef*", s) -> + lookup ~loc (Longident.Lident s) Env.initial_safe_string + | _ -> + lookup ~loc lid env + with Not_found -> + narrow_unbound_lid_error env loc lid make_error + | Env.Recmodule -> + raise (Error (loc, env, Illegal_reference_to_recursive_module)) -(* The "lambda" intermediate code *) +let find_type env loc lid = + let path = + find_component Env.lookup_type (fun lid -> Unbound_type_constructor lid) + env loc lid + in + let decl = Env.find_type path env in + Builtin_attributes.check_deprecated loc decl.type_attributes (Path.name path); + (path, decl) -open Asttypes +let find_constructor = + find_component Env.lookup_constructor (fun lid -> Unbound_constructor lid) +let find_all_constructors = + find_component Env.lookup_all_constructors + (fun lid -> Unbound_constructor lid) +let find_label = + find_component Env.lookup_label (fun lid -> Unbound_label lid) +let find_all_labels = + find_component Env.lookup_all_labels (fun lid -> Unbound_label lid) -type compile_time_constant = - | Big_endian - | Word_size - | Int_size - | Max_wosize - | Ostype_unix - | Ostype_win32 - | Ostype_cygwin - | Backend_type +let find_class env loc lid = + let (path, decl) as r = + find_component Env.lookup_class (fun lid -> Unbound_class lid) env loc lid + in + Builtin_attributes.check_deprecated loc decl.cty_attributes (Path.name path); + r -type loc_kind = - | Loc_FILE - | Loc_LINE - | Loc_MODULE - | Loc_LOC - | Loc_POS +let find_value env loc lid = + Env.check_value_name (Longident.last lid) loc; + let (path, decl) as r = + find_component Env.lookup_value (fun lid -> Unbound_value lid) env loc lid + in + Builtin_attributes.check_deprecated loc decl.val_attributes (Path.name path); + r -type tag_info = - | Blk_constructor of string * int (* Number of non-const constructors*) - | Blk_tuple - | Blk_array - | Blk_variant of string - | Blk_record of string array - | Blk_module of string list - | Blk_module_export of Ident.t list - | Blk_extension_slot - | Blk_extension - (* underlying is the same as tuple, immutable block - {[ - exception A of int * int - ]} - is translated into - {[ - [A, x, y] - ]} +let lookup_module ?(load=false) env loc lid = + find_component (fun ?loc lid env -> (Env.lookup_module ~load ?loc lid env)) + (fun lid -> Unbound_module lid) env loc lid - *) - | Blk_na of string (* This string only for debugging*) - | Blk_some - | Blk_some_not_nested (* ['a option] where ['a] can not inhabit a non-like value *) - | Blk_record_inlined of string array * string * int - | Blk_record_ext of string array - | Blk_lazy_general - | Blk_lazy_forward - | Blk_class (* ocaml style class *) -val default_tag_info : tag_info +let find_module env loc lid = + let path = lookup_module ~load:true env loc lid in + let decl = Env.find_module path env in + (* No need to check for deprecated here, this is done in Env. *) + (path, decl) -val ref_tag_info : tag_info +let find_modtype env loc lid = + let (path, decl) as r = + find_component Env.lookup_modtype (fun lid -> Unbound_modtype lid) + env loc lid + in + Builtin_attributes.check_deprecated loc decl.mtd_attributes (Path.name path); + r -type field_dbg_info = - | Fld_na - | Fld_record of string - | Fld_module of string - | Fld_record_inline of string - | Fld_record_extension of string - | Fld_tuple +let find_class_type env loc lid = + let (path, decl) as r = + find_component Env.lookup_cltype (fun lid -> Unbound_cltype lid) + env loc lid + in + Builtin_attributes.check_deprecated loc decl.clty_attributes (Path.name path); + r -val ref_field_info : field_dbg_info +let unbound_constructor_error env lid = + narrow_unbound_lid_error env lid.loc lid.txt + (fun lid -> Unbound_constructor lid) -type set_field_dbg_info = - | Fld_set_na - | Fld_record_set of string - | Fld_record_inline_set of string - | Fld_record_extension_set of string +let unbound_label_error env lid = + narrow_unbound_lid_error env lid.loc lid.txt + (fun lid -> Unbound_label lid) -val ref_field_set_info : set_field_dbg_info +(* Support for first-class modules. *) -type immediate_or_pointer = - | Immediate - | Pointer +let transl_modtype_longident = ref (fun _ -> assert false) +let transl_modtype = ref (fun _ -> assert false) -type initialization_or_assignment = - | Assignment - (* Initialization of in heap values, like [caml_initialize] C primitive. The - field should not have been read before and initialization should happen - only once. *) - | Heap_initialization - (* Initialization of roots only. Compiles to a simple store. - No checks are done to preserve GC invariants. *) - | Root_initialization +let create_package_mty fake loc env (p, l) = + let l = + List.sort + (fun (s1, _t1) (s2, _t2) -> + if s1.txt = s2.txt then + raise (Error (loc, env, Multiple_constraints_on_type s1.txt)); + compare s1.txt s2.txt) + l + in + l, + List.fold_left + (fun mty (s, t) -> + let d = {ptype_name = mkloc (Longident.last s.txt) s.loc; + ptype_params = []; + ptype_cstrs = []; + ptype_kind = Ptype_abstract; + ptype_private = Asttypes.Public; + ptype_manifest = if fake then None else Some t; + ptype_attributes = []; + ptype_loc = loc} in + Ast_helper.Mty.mk ~loc + (Pmty_with (mty, [ Pwith_type ({ txt = s.txt; loc }, d) ])) + ) + (Ast_helper.Mty.mk ~loc (Pmty_ident p)) + l -type is_safe = - | Safe - | Unsafe +(* Translation of type expressions *) -type pointer_info = - | Pt_constructor of string - | Pt_variant of string - | Pt_module_alias - | Pt_builtin_boolean - | Pt_shape_none - | Pt_na +let type_variables = ref (Tbl.empty : (string, type_expr) Tbl.t) +let univars = ref ([] : (string * type_expr) list) +let pre_univars = ref ([] : type_expr list) +let used_variables = ref (Tbl.empty : (string, type_expr * Location.t) Tbl.t) -val default_pointer_info : pointer_info +let reset_type_variables () = + reset_global_level (); + Ctype.reset_reified_var_counter (); + type_variables := Tbl.empty -type primitive = - | Pidentity - | Pbytes_to_string - | Pbytes_of_string - | Pignore - | Prevapply - | Pdirapply - | Ploc of loc_kind - (* Globals *) - | Pgetglobal of Ident.t - | Psetglobal of Ident.t - (* Operations on heap blocks *) - | Pmakeblock of int * tag_info * mutable_flag * block_shape - | Pfield of int * field_dbg_info - | Pfield_computed - | Psetfield of int * immediate_or_pointer * initialization_or_assignment * set_field_dbg_info - | Psetfield_computed of immediate_or_pointer * initialization_or_assignment - | Pfloatfield of int * field_dbg_info - | Psetfloatfield of int * initialization_or_assignment * set_field_dbg_info - | Pduprecord of Types.record_representation * int - (* Force lazy values *) - | Plazyforce - (* External call *) - | Pccall of Primitive.description - (* Exceptions *) - | Praise of raise_kind - (* Boolean operations *) - | Psequand | Psequor | Pnot - (* Integer operations *) - | Pnegint | Paddint | Psubint | Pmulint - | Pdivint of is_safe | Pmodint of is_safe - | Pandint | Porint | Pxorint - | Plslint | Plsrint | Pasrint - | Pintcomp of comparison - | Poffsetint of int - | Poffsetref of int - (* Float operations *) - | Pintoffloat | Pfloatofint - | Pnegfloat | Pabsfloat - | Paddfloat | Psubfloat | Pmulfloat | Pdivfloat - | Pfloatcomp of comparison - (* String operations *) - | Pstringlength | Pstringrefu | Pstringrefs - | Pbyteslength | Pbytesrefu | Pbytessetu | Pbytesrefs | Pbytessets - (* Array operations *) - | Pmakearray of array_kind * mutable_flag - | Pduparray of array_kind * mutable_flag - (** For [Pduparray], the argument must be an immutable array. - The arguments of [Pduparray] give the kind and mutability of the - array being *produced* by the duplication. *) - | Parraylength of array_kind - | Parrayrefu of array_kind - | Parraysetu of array_kind - | Parrayrefs of array_kind - | Parraysets of array_kind - (* Test if the argument is a block or an immediate integer *) - | Pisint - (* Test if the (integer) argument is outside an interval *) - | Pisout - (* Bitvect operations *) - | Pbittest - (* Operations on boxed integers (Nativeint.t, Int32.t, Int64.t) *) - | Pbintofint of boxed_integer - | Pintofbint of boxed_integer - | Pcvtbint of boxed_integer (*source*) * boxed_integer (*destination*) - | Pnegbint of boxed_integer - | Paddbint of boxed_integer - | Psubbint of boxed_integer - | Pmulbint of boxed_integer - | Pdivbint of { size : boxed_integer; is_safe : is_safe } - | Pmodbint of { size : boxed_integer; is_safe : is_safe } - | Pandbint of boxed_integer - | Porbint of boxed_integer - | Pxorbint of boxed_integer - | Plslbint of boxed_integer - | Plsrbint of boxed_integer - | Pasrbint of boxed_integer - | Pbintcomp of boxed_integer * comparison - (* Operations on big arrays: (unsafe, #dimensions, kind, layout) *) - | Pbigarrayref of bool * int * bigarray_kind * bigarray_layout - | Pbigarrayset of bool * int * bigarray_kind * bigarray_layout - (* size of the nth dimension of a big array *) - | Pbigarraydim of int - (* load/set 16,32,64 bits from a string: (unsafe)*) - | Pstring_load_16 of bool - | Pstring_load_32 of bool - | Pstring_load_64 of bool - | Pstring_set_16 of bool - | Pstring_set_32 of bool - | Pstring_set_64 of bool - (* load/set 16,32,64 bits from a - (char, int8_unsigned_elt, c_layout) Bigarray.Array1.t : (unsafe) *) - | Pbigstring_load_16 of bool - | Pbigstring_load_32 of bool - | Pbigstring_load_64 of bool - | Pbigstring_set_16 of bool - | Pbigstring_set_32 of bool - | Pbigstring_set_64 of bool - (* Compile time constants *) - | Pctconst of compile_time_constant - (* byte swap *) - | Pbswap16 - | Pbbswap of boxed_integer - (* Integer to external pointer *) - | Pint_as_pointer - (* Inhibition of optimisation *) - | Popaque +let narrow () = + (increase_global_level (), !type_variables) -and comparison = - Ceq | Cneq | Clt | Cgt | Cle | Cge +let widen (gl, tv) = + restore_global_level gl; + type_variables := tv -and array_kind = - Pgenarray | Paddrarray | Pintarray | Pfloatarray +let strict_ident c = (c = '_' || c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z') -and value_kind = - Pgenval | Pfloatval | Pboxedintval of boxed_integer | Pintval +let validate_name = function + None -> None + | Some name as s -> + if name <> "" && strict_ident name.[0] then s else None -and block_shape = - value_kind list option +let new_global_var ?name () = + new_global_var ?name:(validate_name name) () +let newvar ?name () = + newvar ?name:(validate_name name) () -and boxed_integer = Primitive.boxed_integer = - Pnativeint | Pint32 | Pint64 +let type_variable loc name = + try + Tbl.find name !type_variables + with Not_found -> + raise(Error(loc, Env.empty, Unbound_type_variable ("'" ^ name))) + +let transl_type_param env styp = + let loc = styp.ptyp_loc in + match styp.ptyp_desc with + Ptyp_any -> + let ty = new_global_var ~name:"_" () in + { ctyp_desc = Ttyp_any; ctyp_type = ty; ctyp_env = env; + ctyp_loc = loc; ctyp_attributes = styp.ptyp_attributes; } + | Ptyp_var name -> + let ty = + try + if name <> "" && name.[0] = '_' then + raise (Error (loc, Env.empty, Invalid_variable_name ("'" ^ name))); + ignore (Tbl.find name !type_variables); + raise Already_bound + with Not_found -> + let v = new_global_var ~name () in + type_variables := Tbl.add name v !type_variables; + v + in + { ctyp_desc = Ttyp_var name; ctyp_type = ty; ctyp_env = env; + ctyp_loc = loc; ctyp_attributes = styp.ptyp_attributes; } + | _ -> assert false + +let transl_type_param env styp = + (* Currently useless, since type parameters cannot hold attributes + (but this could easily be lifted in the future). *) + Builtin_attributes.warning_scope styp.ptyp_attributes + (fun () -> transl_type_param env styp) + + +let new_pre_univar ?name () = + let v = newvar ?name () in pre_univars := v :: !pre_univars; v + +let rec swap_list = function + x :: y :: l -> y :: x :: swap_list l + | l -> l + +type policy = Fixed | Extensible | Univars + +let rec transl_type env policy styp = + Builtin_attributes.warning_scope styp.ptyp_attributes + (fun () -> transl_type_aux env policy styp) + +and transl_type_aux env policy styp = + let loc = styp.ptyp_loc in + let ctyp ctyp_desc ctyp_type = + { ctyp_desc; ctyp_type; ctyp_env = env; + ctyp_loc = loc; ctyp_attributes = styp.ptyp_attributes } + in + match styp.ptyp_desc with + Ptyp_any -> + let ty = + if policy = Univars then new_pre_univar () else + if policy = Fixed then + raise (Error (styp.ptyp_loc, env, Unbound_type_variable "_")) + else newvar () + in + ctyp Ttyp_any ty + | Ptyp_var name -> + let ty = + if name <> "" && name.[0] = '_' then + raise (Error (styp.ptyp_loc, env, Invalid_variable_name ("'" ^ name))); + begin try + instance env (List.assoc name !univars) + with Not_found -> try + instance env (fst(Tbl.find name !used_variables)) + with Not_found -> + let v = + if policy = Univars then new_pre_univar ~name () else newvar ~name () + in + used_variables := Tbl.add name (v, styp.ptyp_loc) !used_variables; + v + end + in + ctyp (Ttyp_var name) ty + | Ptyp_arrow(l, st1, st2) -> + let cty1 = transl_type env policy st1 in + let cty2 = transl_type env policy st2 in + let ty1 = cty1.ctyp_type in + let ty1 = + if Btype.is_optional l + then newty (Tconstr(Predef.path_option,[ty1], ref Mnil)) + else ty1 in + let ty = newty (Tarrow(l, ty1, cty2.ctyp_type, Cok)) in + ctyp (Ttyp_arrow (l, cty1, cty2)) ty + | Ptyp_tuple stl -> + assert (List.length stl >= 2); + let ctys = List.map (transl_type env policy) stl in + let ty = newty (Ttuple (List.map (fun ctyp -> ctyp.ctyp_type) ctys)) in + ctyp (Ttyp_tuple ctys) ty + | Ptyp_constr(lid, stl) -> + let (path, decl) = find_type env lid.loc lid.txt in + let stl = + match stl with + | [ {ptyp_desc=Ptyp_any} as t ] when decl.type_arity > 1 -> + List.map (fun _ -> t) decl.type_params + | _ -> stl + in + if List.length stl <> decl.type_arity then + raise(Error(styp.ptyp_loc, env, + Type_arity_mismatch(lid.txt, decl.type_arity, + List.length stl))); + let args = List.map (transl_type env policy) stl in + let params = instance_list decl.type_params in + let unify_param = + match decl.type_manifest with + None -> unify_var + | Some ty -> + if (repr ty).level = Btype.generic_level then unify_var else unify + in + List.iter2 + (fun (sty, cty) ty' -> + try unify_param env ty' cty.ctyp_type with Unify trace -> + raise (Error(sty.ptyp_loc, env, Type_mismatch (swap_list trace)))) + (List.combine stl args) params; + let constr = + newconstr path (List.map (fun ctyp -> ctyp.ctyp_type) args) in + begin try + Ctype.enforce_constraints env constr + with Unify trace -> + raise (Error(styp.ptyp_loc, env, Type_mismatch trace)) + end; + ctyp (Ttyp_constr (path, lid, args)) constr + | Ptyp_object (fields, o) -> + let ty, fields = transl_fields env policy o fields in + ctyp (Ttyp_object (fields, o)) (newobj ty) + | Ptyp_class(lid, stl) -> + let (path, decl, _is_variant) = + try + let path = Env.lookup_type lid.txt env in + let decl = Env.find_type path env in + let rec check decl = + match decl.type_manifest with + None -> raise Not_found + | Some ty -> + match (repr ty).desc with + Tvariant row when Btype.static_row row -> () + | Tconstr (path, _, _) -> + check (Env.find_type path env) + | _ -> raise Not_found + in check decl; + Location.deprecated styp.ptyp_loc + "old syntax for polymorphic variant type"; + (path, decl,true) + with Not_found -> try + let lid2 = + match lid.txt with + Longident.Lident s -> Longident.Lident ("#" ^ s) + | Longident.Ldot(r, s) -> Longident.Ldot (r, "#" ^ s) + | Longident.Lapply(_, _) -> fatal_error "Typetexp.transl_type" + in + let path = Env.lookup_type lid2 env in + let decl = Env.find_type path env in + (path, decl, false) + with Not_found -> + ignore (find_class env lid.loc lid.txt); assert false + in + if List.length stl <> decl.type_arity then + raise(Error(styp.ptyp_loc, env, + Type_arity_mismatch(lid.txt, decl.type_arity, + List.length stl))); + let args = List.map (transl_type env policy) stl in + let params = instance_list decl.type_params in + List.iter2 + (fun (sty, cty) ty' -> + try unify_var env ty' cty.ctyp_type with Unify trace -> + raise (Error(sty.ptyp_loc, env, Type_mismatch (swap_list trace)))) + (List.combine stl args) params; + let ty_args = List.map (fun ctyp -> ctyp.ctyp_type) args in + let ty = + try Ctype.expand_head env (newconstr path ty_args) + with Unify trace -> + raise (Error(styp.ptyp_loc, env, Type_mismatch trace)) + in + let ty = match ty.desc with + Tvariant row -> + let row = Btype.row_repr row in + let fields = + List.map + (fun (l,f) -> l, + match Btype.row_field_repr f with + | Rpresent (Some ty) -> + Reither(false, [ty], false, ref None) + | Rpresent None -> + Reither (true, [], false, ref None) + | _ -> f) + row.row_fields + in + let row = { row_closed = true; row_fields = fields; + row_bound = (); row_name = Some (path, ty_args); + row_fixed = false; row_more = newvar () } in + let static = Btype.static_row row in + let row = + if static then { row with row_more = newty Tnil } + else if policy <> Univars then row + else { row with row_more = new_pre_univar () } + in + newty (Tvariant row) + | Tobject (fi, _) -> + let _, tv = flatten_fields fi in + if policy = Univars then pre_univars := tv :: !pre_univars; + ty + | _ -> + assert false + in + ctyp (Ttyp_class (path, lid, args)) ty + | Ptyp_alias(st, alias) -> + let cty = + try + let t = + try List.assoc alias !univars + with Not_found -> + instance env (fst(Tbl.find alias !used_variables)) + in + let ty = transl_type env policy st in + begin try unify_var env t ty.ctyp_type with Unify trace -> + let trace = swap_list trace in + raise(Error(styp.ptyp_loc, env, Alias_type_mismatch trace)) + end; + ty + with Not_found -> + if !Clflags.principal then begin_def (); + let t = newvar () in + used_variables := Tbl.add alias (t, styp.ptyp_loc) !used_variables; + let ty = transl_type env policy st in + begin try unify_var env t ty.ctyp_type with Unify trace -> + let trace = swap_list trace in + raise(Error(styp.ptyp_loc, env, Alias_type_mismatch trace)) + end; + if !Clflags.principal then begin + end_def (); + generalize_structure t; + end; + let t = instance env t in + let px = Btype.proxy t in + begin match px.desc with + | Tvar None -> Btype.log_type px; px.desc <- Tvar (Some alias) + | Tunivar None -> Btype.log_type px; px.desc <- Tunivar (Some alias) + | _ -> () + end; + { ty with ctyp_type = t } + in + ctyp (Ttyp_alias (cty, alias)) cty.ctyp_type + | Ptyp_variant(fields, closed, present) -> + let name = ref None in + let mkfield l f = + newty (Tvariant {row_fields=[l,f]; row_more=newvar(); + row_bound=(); row_closed=true; + row_fixed=false; row_name=None}) in + let hfields = Hashtbl.create 17 in + let add_typed_field loc l f = + let h = Btype.hash_variant l in + try + let (l',f') = Hashtbl.find hfields h in + (* Check for tag conflicts *) + if l <> l' then raise(Error(styp.ptyp_loc, env, Variant_tags(l, l'))); + let ty = mkfield l f and ty' = mkfield l f' in + if equal env false [ty] [ty'] then () else + try unify env ty ty' + with Unify _trace -> + raise(Error(loc, env, Constructor_mismatch (ty,ty'))) + with Not_found -> + Hashtbl.add hfields h (l,f) + in + let add_field = function + Rtag (l, attrs, c, stl) -> + name := None; + let tl = + Builtin_attributes.warning_scope attrs + (fun () -> List.map (transl_type env policy) stl) + in + let f = match present with + Some present when not (List.mem l.txt present) -> + let ty_tl = List.map (fun cty -> cty.ctyp_type) tl in + Reither(c, ty_tl, false, ref None) + | _ -> + if List.length stl > 1 || c && stl <> [] then + raise(Error(styp.ptyp_loc, env, + Present_has_conjunction l.txt)); + match tl with [] -> Rpresent None + | st :: _ -> + Rpresent (Some st.ctyp_type) + in + add_typed_field styp.ptyp_loc l.txt f; + Ttag (l,attrs,c,tl) + | Rinherit sty -> + let cty = transl_type env policy sty in + let ty = cty.ctyp_type in + let nm = + match repr cty.ctyp_type with + {desc=Tconstr(p, tl, _)} -> Some(p, tl) + | _ -> None + in + begin try + (* Set name if there are no fields yet *) + Hashtbl.iter (fun _ _ -> raise Exit) hfields; + name := nm + with Exit -> + (* Unset it otherwise *) + name := None + end; + let fl = match expand_head env cty.ctyp_type, nm with + {desc=Tvariant row}, _ when Btype.static_row row -> + let row = Btype.row_repr row in + row.row_fields + | {desc=Tvar _}, Some(p, _) -> + raise(Error(sty.ptyp_loc, env, Unbound_type_constructor_2 p)) + | _ -> + raise(Error(sty.ptyp_loc, env, Not_a_variant ty)) + in + List.iter + (fun (l, f) -> + let f = match present with + Some present when not (List.mem l present) -> + begin match f with + Rpresent(Some ty) -> + Reither(false, [ty], false, ref None) + | Rpresent None -> + Reither(true, [], false, ref None) + | _ -> + assert false + end + | _ -> f + in + add_typed_field sty.ptyp_loc l f) + fl; + Tinherit cty + in + let tfields = List.map add_field fields in + let fields = Hashtbl.fold (fun _ p l -> p :: l) hfields [] in + begin match present with None -> () + | Some present -> + List.iter + (fun l -> if not (List.mem_assoc l fields) then + raise(Error(styp.ptyp_loc, env, Present_has_no_type l))) + present + end; + let row = + { row_fields = List.rev fields; row_more = newvar (); + row_bound = (); row_closed = (closed = Closed); + row_fixed = false; row_name = !name } in + let static = Btype.static_row row in + let row = + if static then { row with row_more = newty Tnil } + else if policy <> Univars then row + else { row with row_more = new_pre_univar () } + in + let ty = newty (Tvariant row) in + ctyp (Ttyp_variant (tfields, closed, present)) ty + | Ptyp_poly(vars, st) -> + let vars = List.map (fun v -> v.txt) vars in + begin_def(); + let new_univars = List.map (fun name -> name, newvar ~name ()) vars in + let old_univars = !univars in + univars := new_univars @ !univars; + let cty = transl_type env policy st in + let ty = cty.ctyp_type in + univars := old_univars; + end_def(); + generalize ty; + let ty_list = + List.fold_left + (fun tyl (name, ty1) -> + let v = Btype.proxy ty1 in + if deep_occur v ty then begin + match v.desc with + Tvar name when v.level = Btype.generic_level -> + v.desc <- Tunivar name; + v :: tyl + | _ -> + raise (Error (styp.ptyp_loc, env, Cannot_quantify (name, v))) + end else tyl) + [] new_univars + in + let ty' = Btype.newgenty (Tpoly(ty, List.rev ty_list)) in + unify_var env (newvar()) ty'; + ctyp (Ttyp_poly (vars, cty)) ty' + | Ptyp_package (p, l) -> + let l, mty = create_package_mty true styp.ptyp_loc env (p, l) in + let z = narrow () in + let mty = !transl_modtype env mty in + widen z; + let ptys = List.map (fun (s, pty) -> + s, transl_type env policy pty + ) l in + let path = !transl_modtype_longident styp.ptyp_loc env p.txt in + let ty = newty (Tpackage (path, + List.map (fun (s, _pty) -> s.txt) l, + List.map (fun (_,cty) -> cty.ctyp_type) ptys)) + in + ctyp (Ttyp_package { + pack_path = path; + pack_type = mty.mty_type; + pack_fields = ptys; + pack_txt = p; + }) ty + | Ptyp_extension ext -> + raise (Error_forward (Builtin_attributes.error_of_extension ext)) -and bigarray_kind = - Pbigarray_unknown - | Pbigarray_float32 | Pbigarray_float64 - | Pbigarray_sint8 | Pbigarray_uint8 - | Pbigarray_sint16 | Pbigarray_uint16 - | Pbigarray_int32 | Pbigarray_int64 - | Pbigarray_caml_int | Pbigarray_native_int - | Pbigarray_complex32 | Pbigarray_complex64 +and transl_poly_type env policy t = + transl_type env policy (Ast_helper.Typ.force_poly t) -and bigarray_layout = - Pbigarray_unknown_layout - | Pbigarray_c_layout - | Pbigarray_fortran_layout +and transl_fields env policy o fields = + let hfields = Hashtbl.create 17 in + let add_typed_field loc l ty = + try + let ty' = Hashtbl.find hfields l in + if equal env false [ty] [ty'] then () else + try unify env ty ty' + with Unify _trace -> + raise(Error(loc, env, Method_mismatch (l, ty, ty'))) + with Not_found -> + Hashtbl.add hfields l ty in + let add_field = function + | Otag (s, a, ty1) -> begin + let ty1 = + Builtin_attributes.warning_scope a + (fun () -> transl_poly_type env policy ty1) + in + let field = OTtag (s, a, ty1) in + add_typed_field ty1.ctyp_loc s.txt ty1.ctyp_type; + field + end + | Oinherit sty -> begin + let cty = transl_type env policy sty in + let nm = + match repr cty.ctyp_type with + {desc=Tconstr(p, _, _)} -> Some p + | _ -> None in + let t = expand_head env cty.ctyp_type in + match t, nm with + {desc=Tobject ({desc=(Tfield _ | Tnil) as tf}, _)}, _ -> begin + if opened_object t then + raise (Error (sty.ptyp_loc, env, Opened_object nm)); + let rec iter_add = function + | Tfield (s, _k, ty1, ty2) -> begin + add_typed_field sty.ptyp_loc s ty1; + iter_add ty2.desc + end + | Tnil -> () + | _ -> assert false in + iter_add tf; + OTinherit cty + end + | {desc=Tvar _}, Some p -> + raise (Error (sty.ptyp_loc, env, Unbound_type_constructor_2 p)) + | _ -> raise (Error (sty.ptyp_loc, env, Not_an_object t)) + end in + let object_fields = List.map add_field fields in + let fields = Hashtbl.fold (fun s ty l -> (s, ty) :: l) hfields [] in + let ty_init = + match o, policy with + | Closed, _ -> newty Tnil + | Open, Univars -> new_pre_univar () + | Open, _ -> newvar () in + let ty = List.fold_left (fun ty (s, ty') -> + newty (Tfield (s, Fpresent, ty', ty))) ty_init fields in + ty, object_fields -and raise_kind = - | Raise_regular - | Raise_reraise - | Raise_notrace -type structured_constant = - Const_base of constant - | Const_pointer of int * pointer_info - | Const_block of int * tag_info * structured_constant list - | Const_float_array of string list - | Const_immstring of string +(* Make the rows "fixed" in this type, to make universal check easier *) +let rec make_fixed_univars ty = + let ty = repr ty in + if ty.level >= Btype.lowest_level then begin + Btype.mark_type_node ty; + match ty.desc with + | Tvariant row -> + let row = Btype.row_repr row in + if Btype.is_Tunivar (Btype.row_more row) then + ty.desc <- Tvariant + {row with row_fixed=true; + row_fields = List.map + (fun (s,f as p) -> match Btype.row_field_repr f with + Reither (c, tl, _m, r) -> s, Reither (c, tl, true, r) + | _ -> p) + row.row_fields}; + Btype.iter_row make_fixed_univars row + | _ -> + Btype.iter_type_expr make_fixed_univars ty + end -type inline_attribute = - | Always_inline (* [@inline] or [@inline always] *) - | Never_inline (* [@inline never] *) - | Unroll of int (* [@unroll x] *) - | Default_inline (* no [@inline] attribute *) +let make_fixed_univars ty = + make_fixed_univars ty; + Btype.unmark_type ty -type specialise_attribute = - | Always_specialise (* [@specialise] or [@specialise always] *) - | Never_specialise (* [@specialise never] *) - | Default_specialise (* no [@specialise] attribute *) +let create_package_mty = create_package_mty false -type function_kind = Curried | Tupled +let globalize_used_variables env fixed = + let r = ref [] in + Tbl.iter + (fun name (ty, loc) -> + let v = new_global_var () in + let snap = Btype.snapshot () in + if try unify env v ty; true with _ -> Btype.backtrack snap; false + then try + r := (loc, v, Tbl.find name !type_variables) :: !r + with Not_found -> + if fixed && Btype.is_Tvar (repr ty) then + raise(Error(loc, env, Unbound_type_variable ("'"^name))); + let v2 = new_global_var () in + r := (loc, v, v2) :: !r; + type_variables := Tbl.add name v2 !type_variables) + !used_variables; + used_variables := Tbl.empty; + fun () -> + List.iter + (function (loc, t1, t2) -> + try unify env t1 t2 with Unify trace -> + raise (Error(loc, env, Type_mismatch trace))) + !r -type let_kind = Strict | Alias | StrictOpt | Variable -(* Meaning of kinds for let x = e in e': - Strict: e may have side-effects; always evaluate e first - (If e is a simple expression, e.g. a variable or constant, - we may still substitute e'[x/e].) - Alias: e is pure, we can substitute e'[x/e] if x has 0 or 1 occurrences - in e' - StrictOpt: e does not have side-effects, but depend on the store; - we can discard e if x does not appear in e' - Variable: the variable x is assigned later in e' - *) +let transl_simple_type env fixed styp = + univars := []; used_variables := Tbl.empty; + let typ = transl_type env (if fixed then Fixed else Extensible) styp in + globalize_used_variables env fixed (); + make_fixed_univars typ.ctyp_type; + typ -type public_info = string option (* label name *) +let transl_simple_type_univars env styp = + univars := []; used_variables := Tbl.empty; pre_univars := []; + begin_def (); + let typ = transl_type env Univars styp in + (* Only keep already global variables in used_variables *) + let new_variables = !used_variables in + used_variables := Tbl.empty; + Tbl.iter + (fun name p -> + if Tbl.mem name !type_variables then + used_variables := Tbl.add name p !used_variables) + new_variables; + globalize_used_variables env false (); + end_def (); + generalize typ.ctyp_type; + let univs = + List.fold_left + (fun acc v -> + let v = repr v in + match v.desc with + Tvar name when v.level = Btype.generic_level -> + v.desc <- Tunivar name; v :: acc + | _ -> acc) + [] !pre_univars + in + make_fixed_univars typ.ctyp_type; + { typ with ctyp_type = + instance env (Btype.newgenty (Tpoly (typ.ctyp_type, univs))) } -type meth_kind = Self | Public of public_info | Cached +let transl_simple_type_delayed env styp = + univars := []; used_variables := Tbl.empty; + let typ = transl_type env Extensible styp in + make_fixed_univars typ.ctyp_type; + (typ, globalize_used_variables env false) -type shared_code = (int * int) list (* stack size -> code label *) +let transl_type_scheme env styp = + reset_type_variables(); + begin_def(); + let typ = transl_simple_type env false styp in + end_def(); + generalize typ.ctyp_type; + typ -type function_attribute = { - inline : inline_attribute; - specialise : specialise_attribute; - is_a_functor: bool; - stub: bool; -} -type switch_names = {consts: string array; blocks: string array} +(* Error report *) -type lambda = - Lvar of Ident.t - | Lconst of structured_constant - | Lapply of lambda_apply - | Lfunction of lfunction - | Llet of let_kind * value_kind * Ident.t * lambda * lambda - | Lletrec of (Ident.t * lambda) list * lambda - | Lprim of primitive * lambda list * Location.t - | Lswitch of lambda * lambda_switch * Location.t -(* switch on strings, clauses are sorted by string order, - strings are pairwise distinct *) - | Lstringswitch of - lambda * (string * lambda) list * lambda option * Location.t - | Lstaticraise of int * lambda list - | Lstaticcatch of lambda * (int * Ident.t list) * lambda - | Ltrywith of lambda * Ident.t * lambda - | Lifthenelse of lambda * lambda * lambda - | Lsequence of lambda * lambda - | Lwhile of lambda * lambda - | Lfor of Ident.t * lambda * lambda * direction_flag * lambda - | Lassign of Ident.t * lambda - | Lsend of meth_kind * lambda * lambda * lambda list * Location.t - | Levent of lambda * lambda_event - | Lifused of Ident.t * lambda +open Format +open Printtyp -and lfunction = - { kind: function_kind; - params: Ident.t list; - body: lambda; - attr: function_attribute; (* specified with [@inline] attribute *) - loc : Location.t; } +let spellcheck ppf fold env lid = + let choices ~path name = + let env = fold (fun x xs -> x::xs) path env [] in + Misc.spellcheck env name in + match lid with + | Longident.Lapply _ -> () + | Longident.Lident s -> + Misc.did_you_mean ppf (fun () -> choices ~path:None s) + | Longident.Ldot (r, s) -> + Misc.did_you_mean ppf (fun () -> choices ~path:(Some r) s) -and lambda_apply = - { ap_func : lambda; - ap_args : lambda list; - ap_loc : Location.t; - ap_should_be_tailcall : bool; (* true if [@tailcall] was specified *) - ap_inlined : inline_attribute; (* specified with the [@inlined] attribute *) - ap_specialised : specialise_attribute; } +let fold_descr fold get_name f = fold (fun descr acc -> f (get_name descr) acc) +let fold_simple fold4 f = fold4 (fun name _path _descr acc -> f name acc) -and lambda_switch = - { sw_numconsts: int; (* Number of integer cases *) - sw_consts: (int * lambda) list; (* Integer cases *) - sw_numblocks: int; (* Number of tag block cases *) - sw_blocks: (int * lambda) list; (* Tag block cases *) - sw_failaction : lambda option; (* Action to take if failure *) - sw_names: switch_names option } -and lambda_event = - { lev_loc: Location.t; - lev_kind: lambda_event_kind; - lev_repr: int ref option; - lev_env: Env.summary } +let fold_values = fold_simple Env.fold_values +let fold_types = fold_simple Env.fold_types +let fold_modules = fold_simple Env.fold_modules +let fold_constructors = fold_descr Env.fold_constructors (fun d -> d.cstr_name) +let fold_labels = fold_descr Env.fold_labels (fun d -> d.lbl_name) +let fold_classs = fold_simple Env.fold_classs +let fold_modtypes = fold_simple Env.fold_modtypes +let fold_cltypes = fold_simple Env.fold_cltypes -and lambda_event_kind = - Lev_before - | Lev_after of Types.type_expr - | Lev_function - | Lev_pseudo - | Lev_module_definition of Ident.t +let report_error env ppf = function + | Unbound_type_variable name -> + (* we don't use "spellcheck" here: the function that raises this + error seems not to be called anywhere, so it's unclear how it + should be handled *) + fprintf ppf "Unbound type parameter %s@." name + | Unbound_type_constructor lid -> + fprintf ppf "Unbound type constructor %a" longident lid; + spellcheck ppf fold_types env lid; + | Unbound_type_constructor_2 p -> + fprintf ppf "The type constructor@ %a@ is not yet completely defined" + path p + | Type_arity_mismatch(lid, expected, provided) -> + fprintf ppf + "@[The type constructor %a@ expects %i argument(s),@ \ + but is here applied to %i argument(s)@]" + longident lid expected provided + | Bound_type_variable name -> + fprintf ppf "Already bound type parameter '%s" name + | Recursive_type -> + fprintf ppf "This type is recursive" + | Unbound_row_variable lid -> + (* we don't use "spellcheck" here: this error is not raised + anywhere so it's unclear how it should be handled *) + fprintf ppf "Unbound row variable in #%a" longident lid + | Type_mismatch trace -> + Printtyp.report_unification_error ppf Env.empty trace + (function ppf -> + fprintf ppf "This type") + (function ppf -> + fprintf ppf "should be an instance of type") + | Alias_type_mismatch trace -> + Printtyp.report_unification_error ppf Env.empty trace + (function ppf -> + fprintf ppf "This alias is bound to type") + (function ppf -> + fprintf ppf "but is used as an instance of type") + | Present_has_conjunction l -> + fprintf ppf "The present constructor %s has a conjunctive type" l + | Present_has_no_type l -> + fprintf ppf "The present constructor %s has no type" l + | Constructor_mismatch (ty, ty') -> + wrap_printing_env env (fun () -> + Printtyp.reset_and_mark_loops_list [ty; ty']; + fprintf ppf "@[%s %a@ %s@ %a@]" + "This variant type contains a constructor" + Printtyp.type_expr ty + "which should be" + Printtyp.type_expr ty') + | Not_a_variant ty -> + Printtyp.reset_and_mark_loops ty; + fprintf ppf + "@[The type %a@ does not expand to a polymorphic variant type@]" + Printtyp.type_expr ty; + begin match ty.desc with + | Tvar (Some s) -> + (* PR#7012: help the user that wrote 'Foo instead of `Foo *) + Misc.did_you_mean ppf (fun () -> ["`" ^ s]) + | _ -> () + end + | Variant_tags (lab1, lab2) -> + fprintf ppf + "@[Variant tags `%s@ and `%s have the same hash value.@ %s@]" + lab1 lab2 "Change one of them." + | Invalid_variable_name name -> + fprintf ppf "The type variable name %s is not allowed in programs" name + | Cannot_quantify (name, v) -> + fprintf ppf + "@[The universal type variable '%s cannot be generalized:@ %s.@]" + name + (if Btype.is_Tvar v then "it escapes its scope" else + if Btype.is_Tunivar v then "it is already bound to another variable" + else "it is not a variable") + | Multiple_constraints_on_type s -> + fprintf ppf "Multiple constraints for type %a" longident s + | Method_mismatch (l, ty, ty') -> + wrap_printing_env env (fun () -> + Printtyp.reset_and_mark_loops_list [ty; ty']; + fprintf ppf "@[Method '%s' has type %a,@ which should be %a@]" + l Printtyp.type_expr ty Printtyp.type_expr ty') + | Unbound_value lid -> + fprintf ppf "Unbound value %a" longident lid; + spellcheck ppf fold_values env lid; + | Unbound_module lid -> + fprintf ppf "Unbound module %a" longident lid; + spellcheck ppf fold_modules env lid; + | Unbound_constructor lid -> + fprintf ppf "Unbound constructor %a" longident lid; + spellcheck ppf fold_constructors env lid; + | Unbound_label lid -> + fprintf ppf "Unbound record field %a" longident lid; + spellcheck ppf fold_labels env lid; + | Unbound_class lid -> + fprintf ppf "Unbound class %a" longident lid; + spellcheck ppf fold_classs env lid; + | Unbound_modtype lid -> + fprintf ppf "Unbound module type %a" longident lid; + spellcheck ppf fold_modtypes env lid; + | Unbound_cltype lid -> + fprintf ppf "Unbound class type %a" longident lid; + spellcheck ppf fold_cltypes env lid; + | Ill_typed_functor_application lid -> + fprintf ppf "Ill-typed functor application %a" longident lid + | Illegal_reference_to_recursive_module -> + fprintf ppf "Illegal recursive module reference" + | Access_functor_as_structure lid -> + fprintf ppf "The module %a is a functor, not a structure" longident lid + | Apply_structure_as_functor lid -> + fprintf ppf "The module %a is a structure, not a functor" longident lid + | Cannot_scrape_alias(lid, p) -> + fprintf ppf + "The module %a is an alias for module %a, which is missing" + longident lid path p + | Opened_object nm -> + fprintf ppf + "Illegal open object type%a" + (fun ppf -> function + Some p -> fprintf ppf "@ %a" path p + | None -> fprintf ppf "") nm + | Not_an_object ty -> + Printtyp.reset_and_mark_loops ty; + fprintf ppf "@[The type %a@ is not an object type@]" + Printtyp.type_expr ty -type program = - { module_ident : Ident.t; - main_module_block_size : int; - required_globals : Ident.Set.t; (* Modules whose initializer side effects - must occur before [code]. *) - code : lambda } -(* Lambda code for the middle-end. - * In the closure case the code is a sequence of assignments to a - preallocated block of size [main_module_block_size] using - (Setfield(Getglobal(module_ident))). The size is used to preallocate - the block. - * In the flambda case the code is an expression returning a block - value of size [main_module_block_size]. The size is used to build - the module root as an initialize_symbol - Initialize_symbol(module_name, 0, - [getfield 0; ...; getfield (main_module_block_size - 1)]) -*) +let () = + Location.register_error_of_exn + (function + | Error (loc, env, err) -> + Some (Location.error_of_printer loc (report_error env) err) + | Error_forward err -> + Some err + | _ -> + None + ) -(* Sharing key *) -val make_key: lambda -> lambda option +end +module Typedecl : sig +#1 "typedecl.mli" +(**************************************************************************) +(* *) +(* OCaml *) +(* *) +(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* *) +(* Copyright 1996 Institut National de Recherche en Informatique et *) +(* en Automatique. *) +(* *) +(* All rights reserved. This file is distributed under the terms of *) +(* the GNU Lesser General Public License version 2.1, with the *) +(* special exception on linking described in the file LICENSE. *) +(* *) +(**************************************************************************) -val const_unit: structured_constant -val lambda_assert_false: lambda -val lambda_unit: lambda -val name_lambda: let_kind -> lambda -> (Ident.t -> lambda) -> lambda -val name_lambda_list: lambda list -> (lambda list -> lambda) -> lambda +(* Typing of type definitions and primitive definitions *) -val iter: (lambda -> unit) -> lambda -> unit -module IdentSet: Set.S with type elt = Ident.t -val free_variables: lambda -> IdentSet.t -val free_methods: lambda -> IdentSet.t +open Types +open Format -val transl_normal_path: Path.t -> lambda (* Path.t is already normal *) -val transl_path: ?loc:Location.t -> Env.t -> Path.t -> lambda -[@@ocaml.deprecated "use transl_{module,value,extension,class}_path instead"] +val transl_type_decl: + Env.t -> Asttypes.rec_flag -> Parsetree.type_declaration list -> + Typedtree.type_declaration list * Env.t -val transl_module_path: ?loc:Location.t -> Env.t -> Path.t -> lambda -val transl_value_path: ?loc:Location.t -> Env.t -> Path.t -> lambda -val transl_extension_path: ?loc:Location.t -> Env.t -> Path.t -> lambda -val transl_class_path: ?loc:Location.t -> Env.t -> Path.t -> lambda +val transl_exception: + Env.t -> + Parsetree.extension_constructor -> Typedtree.extension_constructor * Env.t -val make_sequence: ('a -> lambda) -> 'a list -> lambda +val transl_type_extension: + bool -> Env.t -> Location.t -> Parsetree.type_extension -> + Typedtree.type_extension * Env.t -val subst_lambda: lambda Ident.tbl -> lambda -> lambda -val map : (lambda -> lambda) -> lambda -> lambda -val bind : let_kind -> Ident.t -> lambda -> lambda -> lambda +val transl_value_decl: + Env.t -> Location.t -> + Parsetree.value_description -> Typedtree.value_description * Env.t -val commute_comparison : comparison -> comparison -val negate_comparison : comparison -> comparison +val transl_with_constraint: + Env.t -> Ident.t -> Path.t option -> Types.type_declaration -> + Parsetree.type_declaration -> Typedtree.type_declaration -val default_function_attribute : function_attribute -val default_stub_attribute : function_attribute +val abstract_type_decl: int -> type_declaration +val approx_type_decl: + Parsetree.type_declaration list -> + (Ident.t * type_declaration) list +val check_recmod_typedecl: + Env.t -> Location.t -> Ident.t list -> Path.t -> type_declaration -> unit +val check_coherence: + Env.t -> Location.t -> Ident.t -> type_declaration -> unit -(***********************) -(* For static failures *) -(***********************) +(* for fixed types *) +val is_fixed_type : Parsetree.type_declaration -> bool -(* Get a new static failure ident *) -val next_raise_count : unit -> int -val next_negative_raise_count : unit -> int - (* Negative raise counts are used to compile 'match ... with - exception x -> ...'. This disabled some simplifications - performed by the Simplif module that assume that static raises - are in tail position in their handler. *) +(* for typeclass.ml *) +val compute_variance_decls: + Env.t -> + (Ident.t * Types.type_declaration * Types.type_declaration * + Types.class_declaration * Types.class_type_declaration * + 'a Typedtree.class_infos) list -> + (Types.type_declaration * Types.type_declaration * + Types.class_declaration * Types.class_type_declaration) list -val staticfail : lambda (* Anticipated static failure *) +(* for typeopt.ml *) +val get_unboxed_type_representation: Env.t -> type_expr -> type_expr option -(* Check anticipated failure, substitute its final value *) -val is_guarded: lambda -> bool -val patch_guarded : lambda -> lambda -> lambda -val raise_kind: raise_kind -> string -val lam_of_loc : loc_kind -> Location.t -> lambda +type native_repr_kind = Unboxed | Untagged -val merge_inline_attributes - : inline_attribute - -> inline_attribute - -> inline_attribute option +type error = + Repeated_parameter + | Duplicate_constructor of string + | Too_many_constructors + | Duplicate_label of string + | Recursive_abbrev of string + | Cycle_in_def of string * type_expr + | Definition_mismatch of type_expr * Includecore.type_mismatch list + | Constraint_failed of type_expr * type_expr + | Inconsistent_constraint of Env.t * (type_expr * type_expr) list + | Type_clash of Env.t * (type_expr * type_expr) list + | Parameters_differ of Path.t * type_expr * type_expr + | Null_arity_external + | Missing_native_external + | Unbound_type_var of type_expr * type_declaration + | Cannot_extend_private_type of Path.t + | Not_extensible_type of Path.t + | Extension_mismatch of Path.t * Includecore.type_mismatch list + | Rebind_wrong_type of Longident.t * Env.t * (type_expr * type_expr) list + | Rebind_mismatch of Longident.t * Path.t * Path.t + | Rebind_private of Longident.t + | Bad_variance of int * (bool*bool*bool) * (bool*bool*bool) + | Unavailable_type_constructor of Path.t + | Bad_fixed_type of string + | Unbound_type_var_ext of type_expr * extension_constructor + | Varying_anonymous + | Val_in_structure + | Multiple_native_repr_attributes + | Cannot_unbox_or_untag_type of native_repr_kind + | Deep_unbox_or_untag_attribute of native_repr_kind + | Bad_immediate_attribute + | Bad_unboxed_attribute of string + | Wrong_unboxed_type_float + | Boxed_and_unboxed + | Nonrec_gadt -val reset: unit -> unit +exception Error of Location.t * error + +val report_error: formatter -> error -> unit end = struct -#1 "lambda.ml" +#1 "typedecl.ml" (**************************************************************************) (* *) (* OCaml *) (* *) -(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) +(* Xavier Leroy and Jerome Vouillon, projet Cristal, INRIA Rocquencourt *) (* *) (* Copyright 1996 Institut National de Recherche en Informatique et *) (* en Automatique. *) @@ -63187,777 +61924,2186 @@ end = struct (* *) (**************************************************************************) +(**** Typing of type definitions ****) + open Misc -open Path open Asttypes +open Parsetree +open Primitive +open Types +open Typetexp -type compile_time_constant = - | Big_endian - | Word_size - | Int_size - | Max_wosize - | Ostype_unix - | Ostype_win32 - | Ostype_cygwin - | Backend_type +type native_repr_kind = Unboxed | Untagged -type loc_kind = - | Loc_FILE - | Loc_LINE - | Loc_MODULE - | Loc_LOC - | Loc_POS +type error = + Repeated_parameter + | Duplicate_constructor of string + | Too_many_constructors + | Duplicate_label of string + | Recursive_abbrev of string + | Cycle_in_def of string * type_expr + | Definition_mismatch of type_expr * Includecore.type_mismatch list + | Constraint_failed of type_expr * type_expr + | Inconsistent_constraint of Env.t * (type_expr * type_expr) list + | Type_clash of Env.t * (type_expr * type_expr) list + | Parameters_differ of Path.t * type_expr * type_expr + | Null_arity_external + | Missing_native_external + | Unbound_type_var of type_expr * type_declaration + | Cannot_extend_private_type of Path.t + | Not_extensible_type of Path.t + | Extension_mismatch of Path.t * Includecore.type_mismatch list + | Rebind_wrong_type of Longident.t * Env.t * (type_expr * type_expr) list + | Rebind_mismatch of Longident.t * Path.t * Path.t + | Rebind_private of Longident.t + | Bad_variance of int * (bool * bool * bool) * (bool * bool * bool) + | Unavailable_type_constructor of Path.t + | Bad_fixed_type of string + | Unbound_type_var_ext of type_expr * extension_constructor + | Varying_anonymous + | Val_in_structure + | Multiple_native_repr_attributes + | Cannot_unbox_or_untag_type of native_repr_kind + | Deep_unbox_or_untag_attribute of native_repr_kind + | Bad_immediate_attribute + | Bad_unboxed_attribute of string + | Wrong_unboxed_type_float + | Boxed_and_unboxed + | Nonrec_gadt -type tag_info = - | Blk_constructor of string * int (* Number of non-const constructors*) - | Blk_tuple - | Blk_array - | Blk_variant of string - | Blk_record of string array (* when its empty means we dont get such information *) - | Blk_module of string list - | Blk_module_export of Ident.t list - | Blk_extension_slot - | Blk_extension - | Blk_na of string - | Blk_some - | Blk_some_not_nested (* ['a option] where ['a] can not inhabit a non-like value *) - | Blk_record_inlined of string array * string * int - | Blk_record_ext of string array - | Blk_lazy_general - | Blk_lazy_forward - | Blk_class (* Ocaml style class*) -let default_tag_info : tag_info = Blk_na "" +open Typedtree + +exception Error of Location.t * error + +(* Note: do not factor the branches in the following pattern-matching: + the records must be constants for the compiler to do sharing on them. +*) +let get_unboxed_from_attributes sdecl = + + if !Clflags.bs_only then unboxed_false_default_false + else + + let unboxed = Builtin_attributes.has_unboxed sdecl.ptype_attributes in + let boxed = Builtin_attributes.has_boxed sdecl.ptype_attributes in + match boxed, unboxed, !Clflags.unboxed_types with + | true, true, _ -> raise (Error(sdecl.ptype_loc, Boxed_and_unboxed)) + | true, false, _ -> unboxed_false_default_false + | false, true, _ -> unboxed_true_default_false + | false, false, false -> unboxed_false_default_true + | false, false, true -> unboxed_true_default_true + +(* Enter all declared types in the environment as abstract types *) + +let enter_type rec_flag env sdecl id = + let needed = + match rec_flag with + | Asttypes.Nonrecursive -> + begin match sdecl.ptype_kind with + | Ptype_variant scds -> + List.iter (fun cd -> + if cd.pcd_res <> None then raise (Error(cd.pcd_loc, Nonrec_gadt))) + scds + | _ -> () + end; + Btype.is_row_name (Ident.name id) + | Asttypes.Recursive -> true + in + if not needed then env else + let decl = + { type_params = + List.map (fun _ -> Btype.newgenvar ()) sdecl.ptype_params; + type_arity = List.length sdecl.ptype_params; + type_kind = Type_abstract; + type_private = sdecl.ptype_private; + type_manifest = + begin match sdecl.ptype_manifest with None -> None + | Some _ -> Some(Ctype.newvar ()) end; + type_variance = List.map (fun _ -> Variance.full) sdecl.ptype_params; + type_newtype_level = None; + type_loc = sdecl.ptype_loc; + type_attributes = sdecl.ptype_attributes; + type_immediate = false; + type_unboxed = unboxed_false_default_false; + } + in + Env.add_type ~check:true id decl env + +let update_type temp_env env id loc = + let path = Path.Pident id in + let decl = Env.find_type path temp_env in + match decl.type_manifest with None -> () + | Some ty -> + let params = List.map (fun _ -> Ctype.newvar ()) decl.type_params in + try Ctype.unify env (Ctype.newconstr path params) ty + with Ctype.Unify trace -> + raise (Error(loc, Type_clash (env, trace))) + +(* We use the Ctype.expand_head_opt version of expand_head to get access + to the manifest type of private abbreviations. *) +let rec get_unboxed_type_representation env ty fuel = + if fuel < 0 then None else + let ty = Ctype.repr (Ctype.expand_head_opt env ty) in + match ty.desc with + | Tconstr (p, args, _) -> + begin match Env.find_type p env with + | exception Not_found -> Some ty + | {type_unboxed = {unboxed = false}} -> Some ty + | {type_params; type_kind = + Type_record ([{ld_type = ty2; _}], _) + | Type_variant [{cd_args = Cstr_tuple [ty2]; _}] + | Type_variant [{cd_args = Cstr_record [{ld_type = ty2; _}]; _}]} + + -> get_unboxed_type_representation env + (Ctype.apply env type_params ty2 args) (fuel - 1) + | {type_kind=Type_abstract} -> None + (* This case can occur when checking a recursive unboxed type + declaration. *) + | _ -> assert false (* only the above can be unboxed *) + end + | _ -> Some ty + +let get_unboxed_type_representation env ty = + (* Do not give too much fuel: PR#7424 *) + get_unboxed_type_representation env ty 100 +;; + +(* Determine if a type's values are represented by floats at run-time. *) +let is_float env ty = + match get_unboxed_type_representation env ty with + Some {desc = Tconstr(p, _, _); _} -> Path.same p Predef.path_float + | _ -> false + +(* Determine if a type definition defines a fixed type. (PW) *) +let is_fixed_type sd = + let rec has_row_var sty = + match sty.ptyp_desc with + Ptyp_alias (sty, _) -> has_row_var sty + | Ptyp_class _ + | Ptyp_object (_, Open) + | Ptyp_variant (_, Open, _) + | Ptyp_variant (_, Closed, Some _) -> true + | _ -> false + in + match sd.ptype_manifest with + None -> false + | Some sty -> + sd.ptype_kind = Ptype_abstract && + sd.ptype_private = Private && + has_row_var sty + +(* Set the row variable in a fixed type *) +let set_fixed_row env loc p decl = + let tm = + match decl.type_manifest with + None -> assert false + | Some t -> Ctype.expand_head env t + in + let rv = + match tm.desc with + Tvariant row -> + let row = Btype.row_repr row in + tm.desc <- Tvariant {row with row_fixed = true}; + if Btype.static_row row then Btype.newgenty Tnil + else row.row_more + | Tobject (ty, _) -> + snd (Ctype.flatten_fields ty) + | _ -> + raise (Error (loc, Bad_fixed_type "is not an object or variant")) + in + if not (Btype.is_Tvar rv) then + raise (Error (loc, Bad_fixed_type "has no row variable")); + rv.desc <- Tconstr (p, decl.type_params, ref Mnil) -let ref_tag_info : tag_info = Blk_record [| "contents" |] - -type field_dbg_info = - | Fld_na - | Fld_record of string - | Fld_module of string - | Fld_record_inline of string - | Fld_record_extension of string - | Fld_tuple +(* Translate one type declaration *) -let ref_field_info : field_dbg_info = Fld_record "contents" +module StringSet = + Set.Make(struct + type t = string + let compare (x:t) y = compare x y + end) -type set_field_dbg_info = - | Fld_set_na - | Fld_record_set of string - | Fld_record_inline_set of string - | Fld_record_extension_set of string +let make_params env params = + let make_param (sty, v) = + try + (transl_type_param env sty, v) + with Already_bound -> + raise(Error(sty.ptyp_loc, Repeated_parameter)) + in + List.map make_param params -let ref_field_set_info : set_field_dbg_info = Fld_record_set "contents" +let transl_labels env closed lbls = + assert (lbls <> []); + let all_labels = ref StringSet.empty in + List.iter + (fun {pld_name = {txt=name; loc}} -> + if StringSet.mem name !all_labels then + raise(Error(loc, Duplicate_label name)); + all_labels := StringSet.add name !all_labels) + lbls; + let mk {pld_name=name;pld_mutable=mut;pld_type=arg;pld_loc=loc; + pld_attributes=attrs} = + Builtin_attributes.warning_scope attrs + (fun () -> + let arg = Ast_helper.Typ.force_poly arg in + let cty = transl_simple_type env closed arg in + {ld_id = Ident.create name.txt; ld_name = name; ld_mutable = mut; + ld_type = cty; ld_loc = loc; ld_attributes = attrs} + ) + in + let lbls = List.map mk lbls in + let lbls' = + List.map + (fun ld -> + let ty = ld.ld_type.ctyp_type in + let ty = match ty.desc with Tpoly(t,[]) -> t | _ -> ty in + {Types.ld_id = ld.ld_id; + ld_mutable = ld.ld_mutable; + ld_type = ty; + ld_loc = ld.ld_loc; + ld_attributes = ld.ld_attributes + } + ) + lbls in + lbls, lbls' -type immediate_or_pointer = - | Immediate - | Pointer +let transl_constructor_arguments env closed = function + | Pcstr_tuple l -> + let l = List.map (transl_simple_type env closed) l in + Types.Cstr_tuple (List.map (fun t -> t.ctyp_type) l), + Cstr_tuple l + | Pcstr_record l -> + let lbls, lbls' = transl_labels env closed l in + Types.Cstr_record lbls', + Cstr_record lbls -type initialization_or_assignment = - | Assignment - | Heap_initialization - | Root_initialization +let make_constructor env type_path type_params sargs sret_type = + match sret_type with + | None -> + let args, targs = + transl_constructor_arguments env true sargs + in + targs, None, args, None, type_params + | Some sret_type -> + (* if it's a generalized constructor we must first narrow and + then widen so as to not introduce any new constraints *) + let z = narrow () in + reset_type_variables (); + let args, targs = + transl_constructor_arguments env false sargs + in + let tret_type = transl_simple_type env false sret_type in + let ret_type = tret_type.ctyp_type in + let params = + match (Ctype.repr ret_type).desc with + | Tconstr (p', params, _) when Path.same type_path p' -> + params + | _ -> + raise (Error (sret_type.ptyp_loc, Constraint_failed + (ret_type, Ctype.newconstr type_path type_params))) + in + widen z; + targs, Some tret_type, args, Some ret_type, params -type is_safe = - | Safe - | Unsafe +(* Check that the variable [id] is present in the [univ] list. *) +let check_type_var loc univ id = + let f t = (Btype.repr t).id = id in + if not (List.exists f univ) then raise (Error (loc, Wrong_unboxed_type_float)) -type primitive = - | Pidentity - | Pbytes_to_string - | Pbytes_of_string - | Pignore - | Prevapply - | Pdirapply - | Ploc of loc_kind - (* Globals *) - | Pgetglobal of Ident.t - | Psetglobal of Ident.t - (* Operations on heap blocks *) - | Pmakeblock of int * tag_info * mutable_flag * block_shape - | Pfield of int * field_dbg_info - | Pfield_computed - | Psetfield of int * immediate_or_pointer * initialization_or_assignment * set_field_dbg_info - | Psetfield_computed of immediate_or_pointer * initialization_or_assignment - | Pfloatfield of int * field_dbg_info - | Psetfloatfield of int * initialization_or_assignment * set_field_dbg_info - | Pduprecord of Types.record_representation * int - (* Force lazy values *) - | Plazyforce - (* External call *) - | Pccall of Primitive.description - (* Exceptions *) - | Praise of raise_kind - (* Boolean operations *) - | Psequand | Psequor | Pnot - (* Integer operations *) - | Pnegint | Paddint | Psubint | Pmulint - | Pdivint of is_safe | Pmodint of is_safe - | Pandint | Porint | Pxorint - | Plslint | Plsrint | Pasrint - | Pintcomp of comparison - | Poffsetint of int - | Poffsetref of int - (* Float operations *) - | Pintoffloat | Pfloatofint - | Pnegfloat | Pabsfloat - | Paddfloat | Psubfloat | Pmulfloat | Pdivfloat - | Pfloatcomp of comparison - (* String operations *) - | Pstringlength | Pstringrefu | Pstringrefs - | Pbyteslength | Pbytesrefu | Pbytessetu | Pbytesrefs | Pbytessets - (* Array operations *) - | Pmakearray of array_kind * mutable_flag - | Pduparray of array_kind * mutable_flag - | Parraylength of array_kind - | Parrayrefu of array_kind - | Parraysetu of array_kind - | Parrayrefs of array_kind - | Parraysets of array_kind - (* Test if the argument is a block or an immediate integer *) - | Pisint - (* Test if the (integer) argument is outside an interval *) - | Pisout - (* Bitvect operations *) - | Pbittest - (* Operations on boxed integers (Nativeint.t, Int32.t, Int64.t) *) - | Pbintofint of boxed_integer - | Pintofbint of boxed_integer - | Pcvtbint of boxed_integer (*source*) * boxed_integer (*destination*) - | Pnegbint of boxed_integer - | Paddbint of boxed_integer - | Psubbint of boxed_integer - | Pmulbint of boxed_integer - | Pdivbint of { size : boxed_integer; is_safe : is_safe } - | Pmodbint of { size : boxed_integer; is_safe : is_safe } - | Pandbint of boxed_integer - | Porbint of boxed_integer - | Pxorbint of boxed_integer - | Plslbint of boxed_integer - | Plsrbint of boxed_integer - | Pasrbint of boxed_integer - | Pbintcomp of boxed_integer * comparison - (* Operations on big arrays: (unsafe, #dimensions, kind, layout) *) - | Pbigarrayref of bool * int * bigarray_kind * bigarray_layout - | Pbigarrayset of bool * int * bigarray_kind * bigarray_layout - (* size of the nth dimension of a big array *) - | Pbigarraydim of int - (* load/set 16,32,64 bits from a string: (unsafe)*) - | Pstring_load_16 of bool - | Pstring_load_32 of bool - | Pstring_load_64 of bool - | Pstring_set_16 of bool - | Pstring_set_32 of bool - | Pstring_set_64 of bool - (* load/set 16,32,64 bits from a - (char, int8_unsigned_elt, c_layout) Bigarray.Array1.t : (unsafe) *) - | Pbigstring_load_16 of bool - | Pbigstring_load_32 of bool - | Pbigstring_load_64 of bool - | Pbigstring_set_16 of bool - | Pbigstring_set_32 of bool - | Pbigstring_set_64 of bool - (* Compile time constants *) - | Pctconst of compile_time_constant - (* byte swap *) - | Pbswap16 - | Pbbswap of boxed_integer - (* Integer to external pointer *) - | Pint_as_pointer - (* Inhibition of optimisation *) - | Popaque +(* Check that all the variables found in [ty] are in [univ]. + Because [ty] is the argument to an abstract type, the representation + of that abstract type could be any subexpression of [ty], in particular + any type variable present in [ty]. +*) +let rec check_unboxed_abstract_arg loc univ ty = + match ty.desc with + | Tvar _ -> check_type_var loc univ ty.id + | Tarrow (_, t1, t2, _) + | Tfield (_, _, t1, t2) -> + check_unboxed_abstract_arg loc univ t1; + check_unboxed_abstract_arg loc univ t2 + | Ttuple args + | Tconstr (_, args, _) + | Tpackage (_, _, args) -> + List.iter (check_unboxed_abstract_arg loc univ) args + | Tobject (fields, r) -> + check_unboxed_abstract_arg loc univ fields; + begin match !r with + | None -> () + | Some (_, args) -> List.iter (check_unboxed_abstract_arg loc univ) args + end + | Tnil + | Tunivar _ -> () + | Tlink e -> check_unboxed_abstract_arg loc univ e + | Tsubst _ -> assert false + | Tvariant { row_fields; row_more; row_name } -> + List.iter (check_unboxed_abstract_row_field loc univ) row_fields; + check_unboxed_abstract_arg loc univ row_more; + begin match row_name with + | None -> () + | Some (_, args) -> List.iter (check_unboxed_abstract_arg loc univ) args + end + | Tpoly (t, _) -> check_unboxed_abstract_arg loc univ t -and comparison = - Ceq | Cneq | Clt | Cgt | Cle | Cge +and check_unboxed_abstract_row_field loc univ (_, field) = + match field with + | Rpresent (Some ty) -> check_unboxed_abstract_arg loc univ ty + | Reither (_, args, _, r) -> + List.iter (check_unboxed_abstract_arg loc univ) args; + begin match !r with + | None -> () + | Some f -> check_unboxed_abstract_row_field loc univ ("", f) + end + | Rabsent + | Rpresent None -> () -and value_kind = - Pgenval | Pfloatval | Pboxedintval of boxed_integer | Pintval +(* Check that the argument to a GADT constructor is compatible with unboxing + the type, given the universal parameters of the type. *) +let rec check_unboxed_gadt_arg loc univ env ty = + match get_unboxed_type_representation env ty with + | Some {desc = Tvar _; id} -> check_type_var loc univ id + | Some {desc = Tarrow _ | Ttuple _ | Tpackage _ | Tobject _ | Tnil + | Tvariant _; _} -> + () + (* A comment in [Translcore.transl_exp0] claims the above cannot be + represented by floats. *) + | Some {desc = Tconstr (p, args, _); _} -> + let tydecl = Env.find_type p env in + assert (not tydecl.type_unboxed.unboxed); + if tydecl.type_kind = Type_abstract then + List.iter (check_unboxed_abstract_arg loc univ) args + | Some {desc = Tfield _ | Tlink _ | Tsubst _; _} -> assert false + | Some {desc = Tunivar _; _} -> () + | Some {desc = Tpoly (t2, _); _} -> check_unboxed_gadt_arg loc univ env t2 + | None -> () + (* This case is tricky: the argument is another (or the same) type + in the same recursive definition. In this case we don't have to + check because we will also check that other type for correctness. *) -and block_shape = - value_kind list option +let transl_declaration env sdecl id = + (* Bind type parameters *) + reset_type_variables(); + Ctype.begin_def (); + let tparams = make_params env sdecl.ptype_params in + let params = List.map (fun (cty, _) -> cty.ctyp_type) tparams in + let cstrs = List.map + (fun (sty, sty', loc) -> + transl_simple_type env false sty, + transl_simple_type env false sty', loc) + sdecl.ptype_cstrs + in + let raw_status = get_unboxed_from_attributes sdecl in + if raw_status.unboxed && not raw_status.default then begin + match sdecl.ptype_kind with + | Ptype_abstract -> + raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute + "it is abstract")) + | Ptype_variant [{pcd_args = Pcstr_tuple []; _}] -> + raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute + "its constructor has no argument")) + | Ptype_variant [{pcd_args = Pcstr_tuple [_]; _}] -> () + | Ptype_variant [{pcd_args = Pcstr_tuple _; _}] -> + raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute + "its constructor has more than one argument")) + | Ptype_variant [{pcd_args = Pcstr_record + [{pld_mutable=Immutable; _}]; _}] -> () + | Ptype_variant [{pcd_args = Pcstr_record [{pld_mutable=Mutable; _}]; _}] -> + raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute "it is mutable")) + | Ptype_variant [{pcd_args = Pcstr_record _; _}] -> + raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute + "its constructor has more than one argument")) + | Ptype_variant _ -> + raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute + "it has more than one constructor")) + | Ptype_record [{pld_mutable=Immutable; _}] -> () + | Ptype_record [{pld_mutable=Mutable; _}] -> + raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute + "it is mutable")) + | Ptype_record _ -> + raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute + "it has more than one field")) + | Ptype_open -> + raise(Error(sdecl.ptype_loc, Bad_unboxed_attribute + "extensible variant types cannot be unboxed")) + end; + let unboxed_status = + match sdecl.ptype_kind with + | Ptype_variant [{pcd_args = Pcstr_tuple [_]; _}] + | Ptype_variant [{pcd_args = Pcstr_record + [{pld_mutable = Immutable; _}]; _}] + | Ptype_record [{pld_mutable = Immutable; _}] -> + raw_status + | _ -> (* The type is not unboxable, mark it as boxed *) + unboxed_false_default_false + in + let unbox = unboxed_status.unboxed in + let (tkind, kind) = + match sdecl.ptype_kind with + | Ptype_abstract -> Ttype_abstract, Type_abstract + | Ptype_variant scstrs -> + assert (scstrs <> []); + if List.exists (fun cstr -> cstr.pcd_res <> None) scstrs then begin + match cstrs with + [] -> () + | (_,_,loc)::_ -> + Location.prerr_warning loc Warnings.Constraint_on_gadt + end; + let all_constrs = ref StringSet.empty in + List.iter + (fun {pcd_name = {txt = name}} -> + if StringSet.mem name !all_constrs then + raise(Error(sdecl.ptype_loc, Duplicate_constructor name)); + all_constrs := StringSet.add name !all_constrs) + scstrs; + if List.length + (List.filter (fun cd -> cd.pcd_args <> Pcstr_tuple []) scstrs) + > (Config.max_tag + 1) then + raise(Error(sdecl.ptype_loc, Too_many_constructors)); + let make_cstr scstr = + let name = Ident.create scstr.pcd_name.txt in + let targs, tret_type, args, ret_type, cstr_params = + make_constructor env (Path.Pident id) params + scstr.pcd_args scstr.pcd_res + in + if Config.flat_float_array && unbox then begin + (* Cannot unbox a type when the argument can be both float and + non-float because it interferes with the dynamic float array + optimization. This can only happen when the type is a GADT + and the argument is an existential type variable or an + unboxed (or abstract) type constructor applied to some + existential type variable. Of course we also have to rule + out any abstract type constructor applied to anything that + might be an existential type variable. + There is a difficulty with existential variables created + out of thin air (rather than bound by the declaration). + See PR#7511 and GPR#1133 for details. *) + match Datarepr.constructor_existentials args ret_type with + | _, [] -> () + | [argty], _ex -> + check_unboxed_gadt_arg sdecl.ptype_loc cstr_params env argty + | _ -> assert false + end; + let tcstr = + { cd_id = name; + cd_name = scstr.pcd_name; + cd_args = targs; + cd_res = tret_type; + cd_loc = scstr.pcd_loc; + cd_attributes = scstr.pcd_attributes } + in + let cstr = + { Types.cd_id = name; + cd_args = args; + cd_res = ret_type; + cd_loc = scstr.pcd_loc; + cd_attributes = scstr.pcd_attributes } + in + tcstr, cstr + in + let make_cstr scstr = + Builtin_attributes.warning_scope scstr.pcd_attributes + (fun () -> make_cstr scstr) + in + let tcstrs, cstrs = List.split (List.map make_cstr scstrs) in + Ttype_variant tcstrs, Type_variant cstrs + | Ptype_record lbls -> + let lbls, lbls' = transl_labels env true lbls in + let rep = + if !Clflags.bs_only then Record_regular else (* ATTENTION: revisit when we support @@unbox*) + if unbox then Record_unboxed false + else if List.for_all (fun l -> is_float env l.Types.ld_type) lbls' + then Record_float + else Record_regular + in + Ttype_record lbls, Type_record(lbls', rep) + | Ptype_open -> Ttype_open, Type_open + in + let (tman, man) = match sdecl.ptype_manifest with + None -> None, None + | Some sty -> + let no_row = not (is_fixed_type sdecl) in + let cty = transl_simple_type env no_row sty in + Some cty, Some cty.ctyp_type + in + let decl = + { type_params = params; + type_arity = List.length params; + type_kind = kind; + type_private = sdecl.ptype_private; + type_manifest = man; + type_variance = List.map (fun _ -> Variance.full) params; + type_newtype_level = None; + type_loc = sdecl.ptype_loc; + type_attributes = sdecl.ptype_attributes; + type_immediate = false; + type_unboxed = unboxed_status; + } in -and array_kind = - Pgenarray | Paddrarray | Pintarray | Pfloatarray + (* Check constraints *) + List.iter + (fun (cty, cty', loc) -> + let ty = cty.ctyp_type in + let ty' = cty'.ctyp_type in + try Ctype.unify env ty ty' with Ctype.Unify tr -> + raise(Error(loc, Inconsistent_constraint (env, tr)))) + cstrs; + Ctype.end_def (); + (* Add abstract row *) + if is_fixed_type sdecl then begin + let p = + try Env.lookup_type (Longident.Lident(Ident.name id ^ "#row")) env + with Not_found -> assert false in + set_fixed_row env sdecl.ptype_loc p decl + end; + (* Check for cyclic abbreviations *) + begin match decl.type_manifest with None -> () + | Some ty -> + if Ctype.cyclic_abbrev env id ty then + raise(Error(sdecl.ptype_loc, Recursive_abbrev sdecl.ptype_name.txt)); + end; + { + typ_id = id; + typ_name = sdecl.ptype_name; + typ_params = tparams; + typ_type = decl; + typ_cstrs = cstrs; + typ_loc = sdecl.ptype_loc; + typ_manifest = tman; + typ_kind = tkind; + typ_private = sdecl.ptype_private; + typ_attributes = sdecl.ptype_attributes; + } -and boxed_integer = Primitive.boxed_integer = - Pnativeint | Pint32 | Pint64 +(* Generalize a type declaration *) -and bigarray_kind = - Pbigarray_unknown - | Pbigarray_float32 | Pbigarray_float64 - | Pbigarray_sint8 | Pbigarray_uint8 - | Pbigarray_sint16 | Pbigarray_uint16 - | Pbigarray_int32 | Pbigarray_int64 - | Pbigarray_caml_int | Pbigarray_native_int - | Pbigarray_complex32 | Pbigarray_complex64 +let generalize_decl decl = + List.iter Ctype.generalize decl.type_params; + Btype.iter_type_expr_kind Ctype.generalize decl.type_kind; + begin match decl.type_manifest with + | None -> () + | Some ty -> Ctype.generalize ty + end + +(* Check that all constraints are enforced *) -and bigarray_layout = - Pbigarray_unknown_layout - | Pbigarray_c_layout - | Pbigarray_fortran_layout +module TypeSet = Btype.TypeSet +module TypeMap = Btype.TypeMap -and raise_kind = - | Raise_regular - | Raise_reraise - | Raise_notrace +let rec check_constraints_rec env loc visited ty = + let ty = Ctype.repr ty in + if TypeSet.mem ty !visited then () else begin + visited := TypeSet.add ty !visited; + match ty.desc with + | Tconstr (path, args, _) -> + let args' = List.map (fun _ -> Ctype.newvar ()) args in + let ty' = Ctype.newconstr path args' in + begin try Ctype.enforce_constraints env ty' + with Ctype.Unify _ -> assert false + | Not_found -> raise (Error(loc, Unavailable_type_constructor path)) + end; + if not (Ctype.matches env ty ty') then + raise (Error(loc, Constraint_failed (ty, ty'))); + List.iter (check_constraints_rec env loc visited) args + | Tpoly (ty, tl) -> + let _, ty = Ctype.instance_poly false tl ty in + check_constraints_rec env loc visited ty + | _ -> + Btype.iter_type_expr (check_constraints_rec env loc visited) ty + end -type pointer_info = - | Pt_constructor of string - | Pt_variant of string - | Pt_module_alias - | Pt_builtin_boolean - | Pt_shape_none - | Pt_na +module SMap = Map.Make(String) -let default_pointer_info = Pt_na - -type structured_constant = - Const_base of constant - | Const_pointer of int * pointer_info - | Const_block of int * tag_info * structured_constant list - | Const_float_array of string list - | Const_immstring of string +let check_constraints_labels env visited l pl = + let rec get_loc name = function + [] -> assert false + | pld :: tl -> + if name = pld.pld_name.txt then pld.pld_type.ptyp_loc + else get_loc name tl + in + List.iter + (fun {Types.ld_id=name; ld_type=ty} -> + check_constraints_rec env (get_loc (Ident.name name) pl) visited ty) + l +let check_constraints env sdecl (_, decl) = + let visited = ref TypeSet.empty in + begin match decl.type_kind with + | Type_abstract -> () + | Type_variant l -> + let find_pl = function + Ptype_variant pl -> pl + | Ptype_record _ | Ptype_abstract | Ptype_open -> assert false + in + let pl = find_pl sdecl.ptype_kind in + let pl_index = + let foldf acc x = + SMap.add x.pcd_name.txt x acc + in + List.fold_left foldf SMap.empty pl + in + List.iter + (fun {Types.cd_id=name; cd_args; cd_res} -> + let {pcd_args; pcd_res; _} = + try SMap.find (Ident.name name) pl_index + with Not_found -> assert false in + begin match cd_args, pcd_args with + | Cstr_tuple tyl, Pcstr_tuple styl -> + List.iter2 + (fun sty ty -> + check_constraints_rec env sty.ptyp_loc visited ty) + styl tyl + | Cstr_record tyl, Pcstr_record styl -> + check_constraints_labels env visited tyl styl + | _ -> assert false + end; + match pcd_res, cd_res with + | Some sr, Some r -> + check_constraints_rec env sr.ptyp_loc visited r + | _ -> + () ) + l + | Type_record (l, _) -> + let find_pl = function + Ptype_record pl -> pl + | Ptype_variant _ | Ptype_abstract | Ptype_open -> assert false + in + let pl = find_pl sdecl.ptype_kind in + check_constraints_labels env visited l pl + | Type_open -> () + end; + begin match decl.type_manifest with + | None -> () + | Some ty -> + let sty = + match sdecl.ptype_manifest with Some sty -> sty | _ -> assert false + in + check_constraints_rec env sty.ptyp_loc visited ty + end -type inline_attribute = - | Always_inline (* [@inline] or [@inline always] *) - | Never_inline (* [@inline never] *) - | Unroll of int (* [@unroll x] *) - | Default_inline (* no [@inline] attribute *) +(* + If both a variant/record definition and a type equation are given, + need to check that the equation refers to a type of the same kind + with the same constructors and labels. +*) +let check_coherence env loc id decl = + match decl with + { type_kind = (Type_variant _ | Type_record _| Type_open); + type_manifest = Some ty } -> + begin match (Ctype.repr ty).desc with + Tconstr(path, args, _) -> + begin try + let decl' = Env.find_type path env in + let err = + if List.length args <> List.length decl.type_params + then [Includecore.Arity] + else if not (Ctype.equal env false args decl.type_params) + then [Includecore.Constraint] + else + Includecore.type_declarations ~loc ~equality:true env + (Path.last path) + decl' + id + (Subst.type_declaration + (Subst.add_type id path Subst.identity) decl) + in + if err <> [] then + raise(Error(loc, Definition_mismatch (ty, err))) + with Not_found -> + raise(Error(loc, Unavailable_type_constructor path)) + end + | _ -> raise(Error(loc, Definition_mismatch (ty, []))) + end + | _ -> () -type specialise_attribute = - | Always_specialise (* [@specialise] or [@specialise always] *) - | Never_specialise (* [@specialise never] *) - | Default_specialise (* no [@specialise] attribute *) +let check_abbrev env sdecl (id, decl) = + check_coherence env sdecl.ptype_loc id decl -type function_kind = Curried | Tupled +(* Check that recursion is well-founded *) -type let_kind = Strict | Alias | StrictOpt | Variable +let check_well_founded env loc path to_check ty = + let visited = ref TypeMap.empty in + let rec check ty0 parents ty = + let ty = Btype.repr ty in + if TypeSet.mem ty parents then begin + (*Format.eprintf "@[%a@]@." Printtyp.raw_type_expr ty;*) + if match ty0.desc with + | Tconstr (p, _, _) -> Path.same p path + | _ -> false + then raise (Error (loc, Recursive_abbrev (Path.name path))) + else raise (Error (loc, Cycle_in_def (Path.name path, ty0))) + end; + let (fini, parents) = + try + let prev = TypeMap.find ty !visited in + if TypeSet.subset parents prev then (true, parents) else + (false, TypeSet.union parents prev) + with Not_found -> + (false, parents) + in + if fini then () else + let rec_ok = + match ty.desc with + Tconstr(p,_,_) -> + !Clflags.recursive_types && Ctype.is_contractive env p + | Tobject _ | Tvariant _ -> true + | _ -> !Clflags.recursive_types + in + let visited' = TypeMap.add ty parents !visited in + let arg_exn = + try + visited := visited'; + let parents = + if rec_ok then TypeSet.empty else TypeSet.add ty parents in + Btype.iter_type_expr (check ty0 parents) ty; + None + with e -> + visited := visited'; Some e + in + match ty.desc with + | Tconstr(p, _, _) when arg_exn <> None || to_check p -> + if to_check p then may raise arg_exn + else Btype.iter_type_expr (check ty0 TypeSet.empty) ty; + begin try + let ty' = Ctype.try_expand_once_opt env ty in + let ty0 = if TypeSet.is_empty parents then ty else ty0 in + check ty0 (TypeSet.add ty parents) ty' + with + Ctype.Cannot_expand -> may raise arg_exn + end + | _ -> may raise arg_exn + in + let snap = Btype.snapshot () in + try Ctype.wrap_trace_gadt_instances env (check ty TypeSet.empty) ty + with Ctype.Unify _ -> + (* Will be detected by check_recursion *) + Btype.backtrack snap -type public_info = string option (* label name *) +let check_well_founded_manifest env loc path decl = + if decl.type_manifest = None then () else + let args = List.map (fun _ -> Ctype.newvar()) decl.type_params in + check_well_founded env loc path (Path.same path) (Ctype.newconstr path args) -type meth_kind = Self | Public of public_info | Cached +let check_well_founded_decl env loc path decl to_check = + let open Btype in + let it = + {type_iterators with + it_type_expr = (fun _ -> check_well_founded env loc path to_check)} in + it.it_type_declaration it (Ctype.instance_declaration decl) -type shared_code = (int * int) list +(* Check for ill-defined abbrevs *) -type function_attribute = { - inline : inline_attribute; - specialise : specialise_attribute; - is_a_functor: bool; - stub: bool; -} -type switch_names = {consts: string array; blocks: string array} +let check_recursion env loc path decl to_check = + (* to_check is true for potentially mutually recursive paths. + (path, decl) is the type declaration to be checked. *) -type lambda = - Lvar of Ident.t - | Lconst of structured_constant - | Lapply of lambda_apply - | Lfunction of lfunction - | Llet of let_kind * value_kind * Ident.t * lambda * lambda - | Lletrec of (Ident.t * lambda) list * lambda - | Lprim of primitive * lambda list * Location.t - | Lswitch of lambda * lambda_switch * Location.t - | Lstringswitch of - lambda * (string * lambda) list * lambda option * Location.t - | Lstaticraise of int * lambda list - | Lstaticcatch of lambda * (int * Ident.t list) * lambda - | Ltrywith of lambda * Ident.t * lambda - | Lifthenelse of lambda * lambda * lambda - | Lsequence of lambda * lambda - | Lwhile of lambda * lambda - | Lfor of Ident.t * lambda * lambda * direction_flag * lambda - | Lassign of Ident.t * lambda - | Lsend of meth_kind * lambda * lambda * lambda list * Location.t - | Levent of lambda * lambda_event - | Lifused of Ident.t * lambda + if decl.type_params = [] then () else -and lfunction = - { kind: function_kind; - params: Ident.t list; - body: lambda; - attr: function_attribute; (* specified with [@inline] attribute *) - loc: Location.t; } + let visited = ref [] in -and lambda_apply = - { ap_func : lambda; - ap_args : lambda list; - ap_loc : Location.t; - ap_should_be_tailcall : bool; - ap_inlined : inline_attribute; - ap_specialised : specialise_attribute; } + let rec check_regular cpath args prev_exp ty = + let ty = Ctype.repr ty in + if not (List.memq ty !visited) then begin + visited := ty :: !visited; + match ty.desc with + | Tconstr(path', args', _) -> + if Path.same path path' then begin + if not (Ctype.equal env false args args') then + raise (Error(loc, + Parameters_differ(cpath, ty, Ctype.newconstr path args))) + end + (* Attempt to expand a type abbreviation if: + 1- [to_check path'] holds + (otherwise the expansion cannot involve [path]); + 2- we haven't expanded this type constructor before + (otherwise we could loop if [path'] is itself + a non-regular abbreviation). *) + else if to_check path' && not (List.mem path' prev_exp) then begin + try + (* Attempt expansion *) + let (params0, body0, _) = Env.find_type_expansion path' env in + let (params, body) = + Ctype.instance_parameterized_type params0 body0 in + begin + try List.iter2 (Ctype.unify env) params args' + with Ctype.Unify _ -> + raise (Error(loc, Constraint_failed + (ty, Ctype.newconstr path' params0))); + end; + check_regular path' args (path' :: prev_exp) body + with Not_found -> () + end; + List.iter (check_regular cpath args prev_exp) args' + | Tpoly (ty, tl) -> + let (_, ty) = Ctype.instance_poly ~keep_names:true false tl ty in + check_regular cpath args prev_exp ty + | _ -> + Btype.iter_type_expr (check_regular cpath args prev_exp) ty + end in -and lambda_switch = - { sw_numconsts: int; - sw_consts: (int * lambda) list; - sw_numblocks: int; - sw_blocks: (int * lambda) list; - sw_failaction : lambda option; - sw_names: switch_names option } + Misc.may + (fun body -> + let (args, body) = + Ctype.instance_parameterized_type + ~keep_names:true decl.type_params body in + check_regular path args [] body) + decl.type_manifest -and lambda_event = - { lev_loc: Location.t; - lev_kind: lambda_event_kind; - lev_repr: int ref option; - lev_env: Env.summary } +let check_abbrev_recursion env id_loc_list to_check tdecl = + let decl = tdecl.typ_type in + let id = tdecl.typ_id in + check_recursion env (List.assoc id id_loc_list) (Path.Pident id) decl to_check -and lambda_event_kind = - Lev_before - | Lev_after of Types.type_expr - | Lev_function - | Lev_pseudo - | Lev_module_definition of Ident.t +(* Compute variance *) -type program = - { module_ident : Ident.t; - main_module_block_size : int; - required_globals : Ident.Set.t; - code : lambda } +let get_variance ty visited = + try TypeMap.find ty !visited with Not_found -> Variance.null -let const_unit = Const_pointer(0, default_pointer_info) +let compute_variance env visited vari ty = + let rec compute_variance_rec vari ty = + (* Format.eprintf "%a: %x@." Printtyp.type_expr ty (Obj.magic vari); *) + let ty = Ctype.repr ty in + let vari' = get_variance ty visited in + if Variance.subset vari vari' then () else + let vari = Variance.union vari vari' in + visited := TypeMap.add ty vari !visited; + let compute_same = compute_variance_rec vari in + match ty.desc with + Tarrow (_, ty1, ty2, _) -> + let open Variance in + let v = conjugate vari in + let v1 = + if mem May_pos v || mem May_neg v + then set May_weak true v else v + in + compute_variance_rec v1 ty1; + compute_same ty2 + | Ttuple tl -> + List.iter compute_same tl + | Tconstr (path, tl, _) -> + let open Variance in + if tl = [] then () else begin + try + let decl = Env.find_type path env in + let cvari f = mem f vari in + List.iter2 + (fun ty v -> + let cv f = mem f v in + let strict = + cvari Inv && cv Inj || (cvari Pos || cvari Neg) && cv Inv + in + if strict then compute_variance_rec full ty else + let p1 = inter v vari + and n1 = inter v (conjugate vari) in + let v1 = + union (inter covariant (union p1 (conjugate p1))) + (inter (conjugate covariant) (union n1 (conjugate n1))) + and weak = + cvari May_weak && (cv May_pos || cv May_neg) || + (cvari May_pos || cvari May_neg) && cv May_weak + in + let v2 = set May_weak weak v1 in + compute_variance_rec v2 ty) + tl decl.type_variance + with Not_found -> + List.iter (compute_variance_rec may_inv) tl + end + | Tobject (ty, _) -> + compute_same ty + | Tfield (_, _, ty1, ty2) -> + compute_same ty1; + compute_same ty2 + | Tsubst ty -> + compute_same ty + | Tvariant row -> + let row = Btype.row_repr row in + List.iter + (fun (_,f) -> + match Btype.row_field_repr f with + Rpresent (Some ty) -> + compute_same ty + | Reither (_, tyl, _, _) -> + let open Variance in + let upper = + List.fold_left (fun s f -> set f true s) + null [May_pos; May_neg; May_weak] + in + let v = inter vari upper in + (* cf PR#7269: + if List.length tyl > 1 then upper else inter vari upper *) + List.iter (compute_variance_rec v) tyl + | _ -> ()) + row.row_fields; + compute_same row.row_more + | Tpoly (ty, _) -> + compute_same ty + | Tvar _ | Tnil | Tlink _ | Tunivar _ -> () + | Tpackage (_, _, tyl) -> + let v = + Variance.(if mem Pos vari || mem Neg vari then full else may_inv) + in + List.iter (compute_variance_rec v) tyl + in + compute_variance_rec vari ty -let lambda_assert_false = Lconst (Const_pointer(0, Pt_constructor "assert false")) +let make p n i = + let open Variance in + set May_pos p (set May_neg n (set May_weak n (set Inj i null))) + +let compute_variance_type env check (required, loc) decl tyl = + (* Requirements *) + let required = + List.map (fun (c,n,i) -> if c || n then (c,n,i) else (true,true,i)) + required + in + (* Prepare *) + let params = List.map Btype.repr decl.type_params in + let tvl = ref TypeMap.empty in + (* Compute occurrences in the body *) + let open Variance in + List.iter + (fun (cn,ty) -> + compute_variance env tvl (if cn then full else covariant) ty) + tyl; + if check then begin + (* Check variance of parameters *) + let pos = ref 0 in + List.iter2 + (fun ty (c, n, i) -> + incr pos; + let var = get_variance ty tvl in + let (co,cn) = get_upper var and ij = mem Inj var in + if Btype.is_Tvar ty && (co && not c || cn && not n || not ij && i) + then raise (Error(loc, Bad_variance (!pos, (co,cn,ij), (c,n,i))))) + params required; + (* Check propagation from constrained parameters *) + let args = Btype.newgenty (Ttuple params) in + let fvl = Ctype.free_variables args in + let fvl = List.filter (fun v -> not (List.memq v params)) fvl in + (* If there are no extra variables there is nothing to do *) + if fvl = [] then () else + let tvl2 = ref TypeMap.empty in + List.iter2 + (fun ty (p,n,_) -> + if Btype.is_Tvar ty then () else + let v = + if p then if n then full else covariant else conjugate covariant in + compute_variance env tvl2 v ty) + params required; + let visited = ref TypeSet.empty in + let rec check ty = + let ty = Ctype.repr ty in + if TypeSet.mem ty !visited then () else + let visited' = TypeSet.add ty !visited in + visited := visited'; + let v1 = get_variance ty tvl in + let snap = Btype.snapshot () in + let v2 = + TypeMap.fold + (fun t vt v -> + if Ctype.equal env false [ty] [t] then union vt v else v) + !tvl2 null in + Btype.backtrack snap; + let (c1,n1) = get_upper v1 and (c2,n2,_,i2) = get_lower v2 in + if c1 && not c2 || n1 && not n2 then + if List.memq ty fvl then + let code = if not i2 then -2 else if c2 || n2 then -1 else -3 in + raise (Error (loc, Bad_variance (code, (c1,n1,false), (c2,n2,false)))) + else + Btype.iter_type_expr check ty + in + List.iter (fun (_,ty) -> check ty) tyl; + end; + List.map2 + (fun ty (p, n, i) -> + let v = get_variance ty tvl in + let tr = decl.type_private in + (* Use required variance where relevant *) + let concr = decl.type_kind <> Type_abstract (*|| tr = Type_new*) in + let (p, n) = + if tr = Private || not (Btype.is_Tvar ty) then (p, n) (* set *) + else (false, false) (* only check *) + and i = concr || i && tr = Private in + let v = union v (make p n i) in + let v = + if not concr then v else + if mem Pos v && mem Neg v then full else + if Btype.is_Tvar ty then v else + union v + (if p then if n then full else covariant else conjugate covariant) + in + if decl.type_kind = Type_abstract && tr = Public then v else + set May_weak (mem May_neg v) v) + params required +let add_false = List.map (fun ty -> false, ty) -let lambda_unit = Lconst const_unit +(* A parameter is constrained if it is either instantiated, + or it is a variable appearing in another parameter *) +let constrained vars ty = + match ty.desc with + | Tvar _ -> List.exists (fun tl -> List.memq ty tl) vars + | _ -> true -let default_function_attribute = { - inline = Default_inline; - specialise = Default_specialise; - is_a_functor = false; - stub = false; -} +let for_constr = function + | Types.Cstr_tuple l -> add_false l + | Types.Cstr_record l -> + List.map + (fun {Types.ld_mutable; ld_type} -> (ld_mutable = Mutable, ld_type)) + l -let default_stub_attribute = - { default_function_attribute with stub = true } +let compute_variance_gadt env check (required, loc as rloc) decl + (tl, ret_type_opt) = + match ret_type_opt with + | None -> + compute_variance_type env check rloc {decl with type_private = Private} + (for_constr tl) + | Some ret_type -> + match Ctype.repr ret_type with + | {desc=Tconstr (_, tyl, _)} -> + (* let tyl = List.map (Ctype.expand_head env) tyl in *) + let tyl = List.map Ctype.repr tyl in + let fvl = List.map (Ctype.free_variables ?env:None) tyl in + let _ = + List.fold_left2 + (fun (fv1,fv2) ty (c,n,_) -> + match fv2 with [] -> assert false + | fv :: fv2 -> + (* fv1 @ fv2 = free_variables of other parameters *) + if (c||n) && constrained (fv1 @ fv2) ty then + raise (Error(loc, Varying_anonymous)); + (fv :: fv1, fv2)) + ([], fvl) tyl required + in + compute_variance_type env check rloc + {decl with type_params = tyl; type_private = Private} + (for_constr tl) + | _ -> assert false -(* Build sharing keys *) -(* - Those keys are later compared with Pervasives.compare. - For that reason, they should not include cycles. -*) +let compute_variance_extension env check decl ext rloc = + compute_variance_gadt env check rloc + {decl with type_params = ext.ext_type_params} + (ext.ext_args, ext.ext_ret_type) -exception Not_simple +let compute_variance_decl env check decl (required, _ as rloc) = + if (decl.type_kind = Type_abstract || decl.type_kind = Type_open) + && decl.type_manifest = None then + List.map + (fun (c, n, i) -> + make (not n) (not c) (decl.type_kind <> Type_abstract || i)) + required + else + let mn = + match decl.type_manifest with + None -> [] + | Some ty -> [false, ty] + in + match decl.type_kind with + Type_abstract | Type_open -> + compute_variance_type env check rloc decl mn + | Type_variant tll -> + if List.for_all (fun c -> c.Types.cd_res = None) tll then + compute_variance_type env check rloc decl + (mn @ List.flatten (List.map (fun c -> for_constr c.Types.cd_args) + tll)) + else begin + let mn = + List.map (fun (_,ty) -> (Types.Cstr_tuple [ty],None)) mn in + let tll = + mn @ List.map (fun c -> c.Types.cd_args, c.Types.cd_res) tll in + match List.map (compute_variance_gadt env check rloc decl) tll with + | vari :: rem -> + let varl = List.fold_left (List.map2 Variance.union) vari rem in + List.map + Variance.(fun v -> if mem Pos v && mem Neg v then full else v) + varl + | _ -> assert false + end + | Type_record (ftl, _) -> + compute_variance_type env check rloc decl + (mn @ List.map (fun {Types.ld_mutable; ld_type} -> + (ld_mutable = Mutable, ld_type)) ftl) -let max_raw = 32 +let is_hash id = + let s = Ident.name id in + String.length s > 0 && s.[0] = '#' -let make_key e = - let count = ref 0 (* Used for controling size *) - and make_key = Ident.make_key_generator () in - (* make_key is used for normalizing let-bound variables *) - let rec tr_rec env e = - incr count ; - if !count > max_raw then raise Not_simple ; (* Too big ! *) - match e with - | Lvar id -> - begin - try Ident.find_same id env - with Not_found -> e - end - | Lconst (Const_base (Const_string _)) -> - (* Mutable constants are not shared *) - raise Not_simple - | Lconst _ -> e - | Lapply ap -> - Lapply {ap with ap_func = tr_rec env ap.ap_func; - ap_args = tr_recs env ap.ap_args; - ap_loc = Location.none} - | Llet (Alias,_k,x,ex,e) -> (* Ignore aliases -> substitute *) - let ex = tr_rec env ex in - tr_rec (Ident.add x ex env) e - | Llet ((Strict | StrictOpt),_k,x,ex,Lvar v) when Ident.same v x -> - tr_rec env ex - | Llet (str,k,x,ex,e) -> - (* Because of side effects, keep other lets with normalized names *) - let ex = tr_rec env ex in - let y = make_key x in - Llet (str,k,y,ex,tr_rec (Ident.add x (Lvar y) env) e) - | Lprim (p,es,_) -> - Lprim (p,tr_recs env es, Location.none) - | Lswitch (e,sw,loc) -> - Lswitch (tr_rec env e,tr_sw env sw,loc) - | Lstringswitch (e,sw,d,_) -> - Lstringswitch - (tr_rec env e, - List.map (fun (s,e) -> s,tr_rec env e) sw, - tr_opt env d, - Location.none) - | Lstaticraise (i,es) -> - Lstaticraise (i,tr_recs env es) - | Lstaticcatch (e1,xs,e2) -> - Lstaticcatch (tr_rec env e1,xs,tr_rec env e2) - | Ltrywith (e1,x,e2) -> - Ltrywith (tr_rec env e1,x,tr_rec env e2) - | Lifthenelse (cond,ifso,ifnot) -> - Lifthenelse (tr_rec env cond,tr_rec env ifso,tr_rec env ifnot) - | Lsequence (e1,e2) -> - Lsequence (tr_rec env e1,tr_rec env e2) - | Lassign (x,e) -> - Lassign (x,tr_rec env e) - | Lsend (m,e1,e2,es,_loc) -> - Lsend (m,tr_rec env e1,tr_rec env e2,tr_recs env es,Location.none) - | Lifused (id,e) -> Lifused (id,tr_rec env e) - | Lletrec _|Lfunction _ - | Lfor _ | Lwhile _ -(* Beware: (PR#6412) the event argument to Levent - may include cyclic structure of type Type.typexpr *) - | Levent _ -> - raise Not_simple +let marked_as_immediate decl = + Builtin_attributes.immediate decl.type_attributes - and tr_recs env es = List.map (tr_rec env) es +let compute_immediacy env tdecl = + match (tdecl.type_kind, tdecl.type_manifest) with + | (Type_variant [{cd_args = Cstr_tuple [arg]; _}], _) + | (Type_variant [{cd_args = Cstr_record [{ld_type = arg; _}]; _}], _) + | (Type_record ([{ld_type = arg; _}], _), _) + when tdecl.type_unboxed.unboxed -> + begin match get_unboxed_type_representation env arg with + | Some argrepr -> not (Ctype.maybe_pointer_type env argrepr) + | None -> false + end + | (Type_variant (_ :: _ as cstrs), _) -> + not (List.exists (fun c -> c.Types.cd_args <> Types.Cstr_tuple []) cstrs) + | (Type_abstract, Some(typ)) -> + not (Ctype.maybe_pointer_type env typ) + | (Type_abstract, None) -> marked_as_immediate tdecl + | _ -> false - and tr_sw env sw = - { sw with - sw_consts = List.map (fun (i,e) -> i,tr_rec env e) sw.sw_consts ; - sw_blocks = List.map (fun (i,e) -> i,tr_rec env e) sw.sw_blocks ; - sw_failaction = tr_opt env sw.sw_failaction ; } +(* Computes the fixpoint for the variance and immediacy of type declarations *) - and tr_opt env = function - | None -> None - | Some e -> Some (tr_rec env e) in +let rec compute_properties_fixpoint env decls required variances immediacies = + let new_decls = + List.map2 + (fun (id, decl) (variance, immediacy) -> + id, {decl with type_variance = variance; type_immediate = immediacy}) + decls (List.combine variances immediacies) + in + let new_env = + List.fold_right + (fun (id, decl) env -> Env.add_type ~check:true id decl env) + new_decls env + in + let new_variances = + List.map2 + (fun (_id, decl) -> compute_variance_decl new_env false decl) + new_decls required + in + let new_variances = + List.map2 (List.map2 Variance.union) new_variances variances in + let new_immediacies = + List.map + (fun (_id, decl) -> compute_immediacy new_env decl) + new_decls + in + if new_variances <> variances || new_immediacies <> immediacies then + compute_properties_fixpoint env decls required new_variances new_immediacies + else begin + (* List.iter (fun (id, decl) -> + Printf.eprintf "%s:" (Ident.name id); + List.iter (fun (v : Variance.t) -> + Printf.eprintf " %x" (Obj.magic v : int)) + decl.type_variance; + prerr_endline "") + new_decls; *) + List.iter (fun (_, decl) -> + if (marked_as_immediate decl) && (not decl.type_immediate) then + raise (Error (decl.type_loc, Bad_immediate_attribute)) + else ()) + new_decls; + List.iter2 + (fun (id, decl) req -> if not (is_hash id) then + ignore (compute_variance_decl new_env true decl req)) + new_decls required; + new_decls, new_env + end - try - Some (tr_rec Ident.empty e) - with Not_simple -> None +let init_variance (_id, decl) = + List.map (fun _ -> Variance.null) decl.type_params -(***************) +let add_injectivity = + List.map + (function + | Covariant -> (true, false, false) + | Contravariant -> (false, true, false) + | Invariant -> (false, false, false) + ) -let name_lambda strict arg fn = - match arg with - Lvar id -> fn id - | _ -> let id = Ident.create "let" in Llet(strict, Pgenval, id, arg, fn id) +(* for typeclass.ml *) +let compute_variance_decls env cldecls = + let decls, required = + List.fold_right + (fun (obj_id, obj_abbr, _cl_abbr, _clty, _cltydef, ci) (decls, req) -> + let variance = List.map snd ci.ci_params in + (obj_id, obj_abbr) :: decls, + (add_injectivity variance, ci.ci_loc) :: req) + cldecls ([],[]) + in + let (decls, _) = + compute_properties_fixpoint env decls required + (List.map init_variance decls) + (List.map (fun _ -> false) decls) + in + List.map2 + (fun (_,decl) (_, _, cl_abbr, clty, cltydef, _) -> + let variance = decl.type_variance in + (decl, {cl_abbr with type_variance = variance}, + {clty with cty_variance = variance}, + {cltydef with clty_variance = variance})) + decls cldecls -let name_lambda_list args fn = - let rec name_list names = function - [] -> fn (List.rev names) - | (Lvar _ as arg) :: rem -> - name_list (arg :: names) rem - | arg :: rem -> - let id = Ident.create "let" in - Llet(Strict, Pgenval, id, arg, name_list (Lvar id :: names) rem) in - name_list [] args +(* Check multiple declarations of labels/constructors *) +let check_duplicates sdecl_list = + let labels = Hashtbl.create 7 and constrs = Hashtbl.create 7 in + List.iter + (fun sdecl -> match sdecl.ptype_kind with + Ptype_variant cl -> + List.iter + (fun pcd -> + try + let name' = Hashtbl.find constrs pcd.pcd_name.txt in + Location.prerr_warning pcd.pcd_loc + (Warnings.Duplicate_definitions + ("constructor", pcd.pcd_name.txt, name', + sdecl.ptype_name.txt)) + with Not_found -> + Hashtbl.add constrs pcd.pcd_name.txt sdecl.ptype_name.txt) + cl + | Ptype_record fl -> + List.iter + (fun {pld_name=cname;pld_loc=loc} -> + try + let name' = Hashtbl.find labels cname.txt in + Location.prerr_warning loc + (Warnings.Duplicate_definitions + ("label", cname.txt, name', sdecl.ptype_name.txt)) + with Not_found -> Hashtbl.add labels cname.txt sdecl.ptype_name.txt) + fl + | Ptype_abstract -> () + | Ptype_open -> ()) + sdecl_list -let iter_opt f = function - | None -> () - | Some e -> f e +(* Force recursion to go through id for private types*) +let name_recursion sdecl id decl = + match decl with + | { type_kind = Type_abstract; + type_manifest = Some ty; + type_private = Private; } when is_fixed_type sdecl -> + let ty = Ctype.repr ty in + let ty' = Btype.newty2 ty.level ty.desc in + if Ctype.deep_occur ty ty' then + let td = Tconstr(Path.Pident id, decl.type_params, ref Mnil) in + Btype.link_type ty (Btype.newty2 ty.level td); + {decl with type_manifest = Some ty'} + else decl + | _ -> decl -let iter f = function - Lvar _ - | Lconst _ -> () - | Lapply{ap_func = fn; ap_args = args} -> - f fn; List.iter f args - | Lfunction{body} -> - f body - | Llet(_str, _k, _id, arg, body) -> - f arg; f body - | Lletrec(decl, body) -> - f body; - List.iter (fun (_id, exp) -> f exp) decl - | Lprim(_p, args, _loc) -> - List.iter f args - | Lswitch(arg, sw,_) -> - f arg; - List.iter (fun (_key, case) -> f case) sw.sw_consts; - List.iter (fun (_key, case) -> f case) sw.sw_blocks; - iter_opt f sw.sw_failaction - | Lstringswitch (arg,cases,default,_) -> - f arg ; - List.iter (fun (_,act) -> f act) cases ; - iter_opt f default - | Lstaticraise (_,args) -> - List.iter f args - | Lstaticcatch(e1, _, e2) -> - f e1; f e2 - | Ltrywith(e1, _, e2) -> - f e1; f e2 - | Lifthenelse(e1, e2, e3) -> - f e1; f e2; f e3 - | Lsequence(e1, e2) -> - f e1; f e2 - | Lwhile(e1, e2) -> - f e1; f e2 - | Lfor(_v, e1, e2, _dir, e3) -> - f e1; f e2; f e3 - | Lassign(_, e) -> - f e - | Lsend (_k, met, obj, args, _) -> - List.iter f (met::obj::args) - | Levent (lam, _evt) -> - f lam - | Lifused (_v, e) -> - f e +(* Translate a set of type declarations, mutually recursive or not *) +let transl_type_decl env rec_flag sdecl_list = + (* Add dummy types for fixed rows *) + let fixed_types = List.filter is_fixed_type sdecl_list in + let sdecl_list = + List.map + (fun sdecl -> + let ptype_name = + mkloc (sdecl.ptype_name.txt ^"#row") sdecl.ptype_name.loc in + {sdecl with + ptype_name; ptype_kind = Ptype_abstract; ptype_manifest = None}) + fixed_types + @ sdecl_list + in + (* Create identifiers. *) + let id_list = + List.map (fun sdecl -> Ident.create sdecl.ptype_name.txt) sdecl_list + in + (* + Since we've introduced fresh idents, make sure the definition + level is at least the binding time of these events. Otherwise, + passing one of the recursively-defined type constrs as argument + to an abbreviation may fail. + *) + Ctype.init_def(Ident.current_time()); + Ctype.begin_def(); + (* Enter types. *) + let temp_env = + List.fold_left2 (enter_type rec_flag) env sdecl_list id_list in + (* Translate each declaration. *) + let current_slot = ref None in + let warn_unused = Warnings.is_active (Warnings.Unused_type_declaration "") in + let id_slots id = + match rec_flag with + | Asttypes.Recursive when warn_unused -> + (* See typecore.ml for a description of the algorithm used + to detect unused declarations in a set of recursive definitions. *) + let slot = ref [] in + let td = Env.find_type (Path.Pident id) temp_env in + let name = Ident.name id in + Env.set_type_used_callback + name td + (fun old_callback -> + match !current_slot with + | Some slot -> slot := (name, td) :: !slot + | None -> + List.iter (fun (name, d) -> Env.mark_type_used env name d) + (get_ref slot); + old_callback () + ); + id, Some slot + | Asttypes.Recursive | Asttypes.Nonrecursive -> + id, None + in + let transl_declaration name_sdecl (id, slot) = + current_slot := slot; + Builtin_attributes.warning_scope + name_sdecl.ptype_attributes + (fun () -> transl_declaration temp_env name_sdecl id) + in + let tdecls = + List.map2 transl_declaration sdecl_list (List.map id_slots id_list) in + let decls = + List.map (fun tdecl -> (tdecl.typ_id, tdecl.typ_type)) tdecls in + current_slot := None; + (* Check for duplicates *) + check_duplicates sdecl_list; + (* Build the final env. *) + let newenv = + List.fold_right + (fun (id, decl) env -> Env.add_type ~check:true id decl env) + decls env + in + (* Update stubs *) + begin match rec_flag with + | Asttypes.Nonrecursive -> () + | Asttypes.Recursive -> + List.iter2 + (fun id sdecl -> update_type temp_env newenv id sdecl.ptype_loc) + id_list sdecl_list + end; + (* Generalize type declarations. *) + Ctype.end_def(); + List.iter (fun (_, decl) -> generalize_decl decl) decls; + (* Check for ill-formed abbrevs *) + let id_loc_list = + List.map2 (fun id sdecl -> (id, sdecl.ptype_loc)) + id_list sdecl_list + in + List.iter (fun (id, decl) -> + check_well_founded_manifest newenv (List.assoc id id_loc_list) + (Path.Pident id) decl) + decls; + let to_check = + function Path.Pident id -> List.mem_assoc id id_loc_list | _ -> false in + List.iter (fun (id, decl) -> + check_well_founded_decl newenv (List.assoc id id_loc_list) (Path.Pident id) + decl to_check) + decls; + List.iter (check_abbrev_recursion newenv id_loc_list to_check) tdecls; + (* Check that all type variables are closed *) + List.iter2 + (fun sdecl tdecl -> + let decl = tdecl.typ_type in + match Ctype.closed_type_decl decl with + Some ty -> raise(Error(sdecl.ptype_loc, Unbound_type_var(ty,decl))) + | None -> ()) + sdecl_list tdecls; + (* Check that constraints are enforced *) + List.iter2 (check_constraints newenv) sdecl_list decls; + (* Name recursion *) + let decls = + List.map2 (fun sdecl (id, decl) -> id, name_recursion sdecl id decl) + sdecl_list decls + in + (* Add variances to the environment *) + let required = + List.map + (fun sdecl -> + add_injectivity (List.map snd sdecl.ptype_params), + sdecl.ptype_loc + ) + sdecl_list + in + let final_decls, final_env = + compute_properties_fixpoint env decls required + (List.map init_variance decls) + (List.map (fun _ -> false) decls) + in + (* Check re-exportation *) + List.iter2 (check_abbrev final_env) sdecl_list final_decls; + (* Keep original declaration *) + let final_decls = + List.map2 + (fun tdecl (_id2, decl) -> + { tdecl with typ_type = decl } + ) tdecls final_decls + in + (* Done *) + (final_decls, final_env) -module IdentSet = Set.Make(Ident) +(* Translating type extensions *) -let free_ids get l = - let fv = ref IdentSet.empty in - let rec free l = - iter free l; - fv := List.fold_right IdentSet.add (get l) !fv; - match l with - Lfunction{params} -> - List.iter (fun param -> fv := IdentSet.remove param !fv) params - | Llet(_str, _k, id, _arg, _body) -> - fv := IdentSet.remove id !fv - | Lletrec(decl, _body) -> - List.iter (fun (id, _exp) -> fv := IdentSet.remove id !fv) decl - | Lstaticcatch(_e1, (_,vars), _e2) -> - List.iter (fun id -> fv := IdentSet.remove id !fv) vars - | Ltrywith(_e1, exn, _e2) -> - fv := IdentSet.remove exn !fv - | Lfor(v, _e1, _e2, _dir, _e3) -> - fv := IdentSet.remove v !fv - | Lassign(id, _e) -> - fv := IdentSet.add id !fv - | Lvar _ | Lconst _ | Lapply _ - | Lprim _ | Lswitch _ | Lstringswitch _ | Lstaticraise _ - | Lifthenelse _ | Lsequence _ | Lwhile _ - | Lsend _ | Levent _ | Lifused _ -> () - in free l; !fv +let transl_extension_constructor env type_path type_params + typext_params priv sext = + let id = Ident.create sext.pext_name.txt in + let args, ret_type, kind = + match sext.pext_kind with + Pext_decl(sargs, sret_type) -> + let targs, tret_type, args, ret_type, _ = + make_constructor env type_path typext_params + sargs sret_type + in + args, ret_type, Text_decl(targs, tret_type) + | Pext_rebind lid -> + let cdescr = Typetexp.find_constructor env lid.loc lid.txt in + let usage = + if cdescr.cstr_private = Private || priv = Public + then Env.Positive else Env.Privatize + in + Env.mark_constructor usage env (Longident.last lid.txt) cdescr; + let (args, cstr_res) = Ctype.instance_constructor cdescr in + let res, ret_type = + if cdescr.cstr_generalized then + let params = Ctype.instance_list env type_params in + let res = Ctype.newconstr type_path params in + let ret_type = Some (Ctype.newconstr type_path params) in + res, ret_type + else (Ctype.newconstr type_path typext_params), None + in + begin + try + Ctype.unify env cstr_res res + with Ctype.Unify trace -> + raise (Error(lid.loc, + Rebind_wrong_type(lid.txt, env, trace))) + end; + (* Remove "_" names from parameters used in the constructor *) + if not cdescr.cstr_generalized then begin + let vars = + Ctype.free_variables (Btype.newgenty (Ttuple args)) + in + List.iter + (function {desc = Tvar (Some "_")} as ty -> + if List.memq ty vars then ty.desc <- Tvar None + | _ -> ()) + typext_params + end; + (* Ensure that constructor's type matches the type being extended *) + let cstr_type_path, cstr_type_params = + match cdescr.cstr_res.desc with + Tconstr (p, _, _) -> + let decl = Env.find_type p env in + p, decl.type_params + | _ -> assert false + in + let cstr_types = + (Btype.newgenty + (Tconstr(cstr_type_path, cstr_type_params, ref Mnil))) + :: cstr_type_params + in + let ext_types = + (Btype.newgenty + (Tconstr(type_path, type_params, ref Mnil))) + :: type_params + in + if not (Ctype.equal env true cstr_types ext_types) then + raise (Error(lid.loc, + Rebind_mismatch(lid.txt, cstr_type_path, type_path))); + (* Disallow rebinding private constructors to non-private *) + begin + match cdescr.cstr_private, priv with + Private, Public -> + raise (Error(lid.loc, Rebind_private lid.txt)) + | _ -> () + end; + let path = + match cdescr.cstr_tag with + Cstr_extension(path, _) -> path + | _ -> assert false + in + let args = + match cdescr.cstr_inlined with + | None -> + Types.Cstr_tuple args + | Some decl -> + let tl = + match args with + | [ {desc=Tconstr(_, tl, _)} ] -> tl + | _ -> assert false + in + let decl = Ctype.instance_declaration decl in + assert (List.length decl.type_params = List.length tl); + List.iter2 (Ctype.unify env) decl.type_params tl; + let lbls = + match decl.type_kind with + | Type_record (lbls, Record_extension) -> lbls + | _ -> assert false + in + Types.Cstr_record lbls + in + args, ret_type, Text_rebind(path, lid) + in + let ext = + { ext_type_path = type_path; + ext_type_params = typext_params; + ext_args = args; + ext_ret_type = ret_type; + ext_private = priv; + Types.ext_loc = sext.pext_loc; + Types.ext_attributes = sext.pext_attributes; } + in + { ext_id = id; + ext_name = sext.pext_name; + ext_type = ext; + ext_kind = kind; + Typedtree.ext_loc = sext.pext_loc; + Typedtree.ext_attributes = sext.pext_attributes; } -let free_variables l = - free_ids (function Lvar id -> [id] | _ -> []) l +let transl_extension_constructor env type_path type_params + typext_params priv sext = + Builtin_attributes.warning_scope sext.pext_attributes + (fun () -> transl_extension_constructor env type_path type_params + typext_params priv sext) -let free_methods l = - free_ids (function Lsend(Self, Lvar meth, _, _, _) -> [meth] | _ -> []) l +let transl_type_extension extend env loc styext = + reset_type_variables(); + Ctype.begin_def(); + let (type_path, type_decl) = + let lid = styext.ptyext_path in + Typetexp.find_type env lid.loc lid.txt + in + begin + match type_decl.type_kind with + | Type_open -> begin + match type_decl.type_private with + | Private when extend -> begin + match + List.find + (function {pext_kind = Pext_decl _} -> true + | {pext_kind = Pext_rebind _} -> false) + styext.ptyext_constructors + with + | {pext_loc} -> + raise (Error(pext_loc, Cannot_extend_private_type type_path)) + | exception Not_found -> () + end + | _ -> () + end + | _ -> + raise (Error(loc, Not_extensible_type type_path)) + end; + let type_variance = + List.map (fun v -> + let (co, cn) = Variance.get_upper v in + (not cn, not co, false)) + type_decl.type_variance + in + let err = + if type_decl.type_arity <> List.length styext.ptyext_params then + [Includecore.Arity] + else + if List.for_all2 + (fun (c1, n1, _) (c2, n2, _) -> (not c2 || c1) && (not n2 || n1)) + type_variance + (add_injectivity (List.map snd styext.ptyext_params)) + then [] else [Includecore.Variance] + in + if err <> [] then + raise (Error(loc, Extension_mismatch (type_path, err))); + let ttype_params = make_params env styext.ptyext_params in + let type_params = List.map (fun (cty, _) -> cty.ctyp_type) ttype_params in + List.iter2 (Ctype.unify_var env) + (Ctype.instance_list env type_decl.type_params) + type_params; + let constructors = + List.map (transl_extension_constructor env type_path + type_decl.type_params type_params styext.ptyext_private) + styext.ptyext_constructors + in + Ctype.end_def(); + (* Generalize types *) + List.iter Ctype.generalize type_params; + List.iter + (fun ext -> + Btype.iter_type_expr_cstr_args Ctype.generalize ext.ext_type.ext_args; + may Ctype.generalize ext.ext_type.ext_ret_type) + constructors; + (* Check that all type variables are closed *) + List.iter + (fun ext -> + match Ctype.closed_extension_constructor ext.ext_type with + Some ty -> + raise(Error(ext.ext_loc, Unbound_type_var_ext(ty, ext.ext_type))) + | None -> ()) + constructors; + (* Check variances are correct *) + List.iter + (fun ext-> + ignore (compute_variance_extension env true type_decl + ext.ext_type (type_variance, loc))) + constructors; + (* Add extension constructors to the environment *) + let newenv = + List.fold_left + (fun env ext -> + Env.add_extension ~check:true ext.ext_id ext.ext_type env) + env constructors + in + let tyext = + { tyext_path = type_path; + tyext_txt = styext.ptyext_path; + tyext_params = ttype_params; + tyext_constructors = constructors; + tyext_private = styext.ptyext_private; + tyext_attributes = styext.ptyext_attributes; } + in + (tyext, newenv) -(* Check if an action has a "when" guard *) -let raise_count = ref 0 +let transl_type_extension extend env loc styext = + Builtin_attributes.warning_scope styext.ptyext_attributes + (fun () -> transl_type_extension extend env loc styext) -let next_raise_count () = - incr raise_count ; - !raise_count +let transl_exception env sext = + reset_type_variables(); + Ctype.begin_def(); + let ext = + transl_extension_constructor env + Predef.path_exn [] [] Asttypes.Public sext + in + Ctype.end_def(); + (* Generalize types *) + Btype.iter_type_expr_cstr_args Ctype.generalize ext.ext_type.ext_args; + may Ctype.generalize ext.ext_type.ext_ret_type; + (* Check that all type variables are closed *) + begin match Ctype.closed_extension_constructor ext.ext_type with + Some ty -> + raise (Error(ext.ext_loc, Unbound_type_var_ext(ty, ext.ext_type))) + | None -> () + end; + let newenv = Env.add_extension ~check:true ext.ext_id ext.ext_type env in + ext, newenv -let negative_raise_count = ref 0 +type native_repr_attribute = + | Native_repr_attr_absent + | Native_repr_attr_present of native_repr_kind -let next_negative_raise_count () = - decr negative_raise_count ; - !negative_raise_count +let get_native_repr_attribute attrs ~global_repr = + match + Attr_helper.get_no_payload_attribute ["unboxed"; "ocaml.unboxed"] attrs, + Attr_helper.get_no_payload_attribute ["untagged"; "ocaml.untagged"] attrs, + global_repr + with + | None, None, None -> Native_repr_attr_absent + | None, None, Some repr -> Native_repr_attr_present repr + | Some _, None, None -> Native_repr_attr_present Unboxed + | None, Some _, None -> Native_repr_attr_present Untagged + | Some { Location.loc }, _, _ + | _, Some { Location.loc }, _ -> + raise (Error (loc, Multiple_native_repr_attributes)) -(* Anticipated staticraise, for guards *) -let staticfail = Lstaticraise (0,[]) +let native_repr_of_type env kind ty = + match kind, (Ctype.expand_head_opt env ty).desc with + | Untagged, Tconstr (path, _, _) when Path.same path Predef.path_int -> + Some Untagged_int + | Unboxed, Tconstr (path, _, _) when Path.same path Predef.path_float -> + Some Unboxed_float + | Unboxed, Tconstr (path, _, _) when Path.same path Predef.path_int32 -> + Some (Unboxed_integer Pint32) + | Unboxed, Tconstr (path, _, _) when Path.same path Predef.path_int64 -> + Some (Unboxed_integer Pint64) + | Unboxed, Tconstr (path, _, _) when Path.same path Predef.path_nativeint -> + Some (Unboxed_integer Pnativeint) + | _ -> + None -let rec is_guarded = function - | Lifthenelse(_cond, _body, Lstaticraise (0,[])) -> true - | Llet(_str, _k, _id, _lam, body) -> is_guarded body - | Levent(lam, _ev) -> is_guarded lam - | _ -> false +(* Raises an error when [core_type] contains an [@unboxed] or [@untagged] + attribute in a strict sub-term. *) +let error_if_has_deep_native_repr_attributes core_type = + let open Ast_iterator in + let this_iterator = + { default_iterator with typ = fun iterator core_type -> + begin + match + get_native_repr_attribute core_type.ptyp_attributes ~global_repr:None + with + | Native_repr_attr_present kind -> + raise (Error (core_type.ptyp_loc, + Deep_unbox_or_untag_attribute kind)) + | Native_repr_attr_absent -> () + end; + default_iterator.typ iterator core_type } + in + default_iterator.typ this_iterator core_type -let rec patch_guarded patch = function - | Lifthenelse (cond, body, Lstaticraise (0,[])) -> - Lifthenelse (cond, body, patch) - | Llet(str, k, id, lam, body) -> - Llet (str, k, id, lam, patch_guarded patch body) - | Levent(lam, ev) -> - Levent (patch_guarded patch lam, ev) - | _ -> fatal_error "Lambda.patch_guarded" +let make_native_repr env core_type ty ~global_repr = + error_if_has_deep_native_repr_attributes core_type; + match get_native_repr_attribute core_type.ptyp_attributes ~global_repr with + | Native_repr_attr_absent -> + Same_as_ocaml_repr + | Native_repr_attr_present kind -> + begin match native_repr_of_type env kind ty with + | None -> + raise (Error (core_type.ptyp_loc, Cannot_unbox_or_untag_type kind)) + | Some repr -> repr + end -(* Translate an access path *) +let rec parse_native_repr_attributes env core_type ty ~global_repr = + match core_type.ptyp_desc, (Ctype.repr ty).desc, + get_native_repr_attribute core_type.ptyp_attributes ~global_repr:None + with + | Ptyp_arrow _, Tarrow _, Native_repr_attr_present kind -> + raise (Error (core_type.ptyp_loc, Cannot_unbox_or_untag_type kind)) + | Ptyp_arrow (_, ct1, ct2), Tarrow (_, t1, t2, _), _ -> + let repr_arg = make_native_repr env ct1 t1 ~global_repr in + let repr_args, repr_res = + parse_native_repr_attributes env ct2 t2 ~global_repr + in + (repr_arg :: repr_args, repr_res) + | Ptyp_arrow _, _, _ | _, Tarrow _, _ -> assert false + | _ -> ([], make_native_repr env core_type ty ~global_repr) -let rec transl_normal_path = function - Pident id -> - if Ident.global id - then Lprim(Pgetglobal id, [], Location.none) - else Lvar id - | Pdot(p, s, pos) -> - Lprim(Pfield (pos, Fld_module s), [transl_normal_path p], Location.none) - | Papply _ -> - fatal_error "Lambda.transl_path" -(* Translation of identifiers *) +let check_unboxable env loc ty = + let ty = Ctype.repr (Ctype.expand_head_opt env ty) in + try match ty.desc with + | Tconstr (p, _, _) -> + let tydecl = Env.find_type p env in + if tydecl.type_unboxed.unboxed then + Location.prerr_warning loc + (Warnings.Unboxable_type_in_prim_decl (Path.name p)) + | _ -> () + with Not_found -> () -let transl_module_path ?(loc=Location.none) env path = - transl_normal_path (Env.normalize_path (Some loc) env path) +(* Translate a value declaration *) +let transl_value_decl env loc valdecl = + let cty = Typetexp.transl_type_scheme env valdecl.pval_type in + let ty = cty.ctyp_type in + let v = + match valdecl.pval_prim with + [] when Env.is_in_signature env -> + { val_type = ty; val_kind = Val_reg; Types.val_loc = loc; + val_attributes = valdecl.pval_attributes } + | [] -> + raise (Error(valdecl.pval_loc, Val_in_structure)) + | _ -> + let global_repr = + match + get_native_repr_attribute valdecl.pval_attributes ~global_repr:None + with + | Native_repr_attr_present repr -> Some repr + | Native_repr_attr_absent -> None + in + let native_repr_args, native_repr_res = + if !Clflags.bs_only then + let rec scann (attrs : Parsetree.attributes) = + match attrs with + | ({txt = "internal.arity";_}, + PStr [ {pstr_desc = Pstr_eval + ( + ({pexp_desc = Pexp_constant (Pconst_integer (i,_))} : + Parsetree.expression) ,_)}]) :: _ -> + Some (int_of_string i) + | _ :: rest -> scann rest + | [] -> None + and make n = + if n = 0 then [] + else Primitive.Same_as_ocaml_repr :: make (n - 1) + in + match scann valdecl.pval_attributes with + | None -> parse_native_repr_attributes env valdecl.pval_type ty ~global_repr + | Some x -> make x , Primitive.Same_as_ocaml_repr + else + parse_native_repr_attributes env valdecl.pval_type ty ~global_repr + in + let prim = + Primitive.parse_declaration valdecl + ~native_repr_args + ~native_repr_res + in + let prim_native_name = prim.prim_native_name in + if prim.prim_arity = 0 && + not ( String.length prim_native_name > 3 && + String.unsafe_get prim_native_name 0 = 'B' && + String.unsafe_get prim_native_name 1 = 'S' && + String.unsafe_get prim_native_name 2 = ':' + ) && + (prim.prim_name = "" || (prim.prim_name.[0] <> '%' && prim.prim_name.[0] <> '#')) then + raise(Error(valdecl.pval_type.ptyp_loc, Null_arity_external)); + if !Clflags.native_code + && prim.prim_arity > 5 + && prim_native_name = "" + then raise(Error(valdecl.pval_type.ptyp_loc, Missing_native_external)); + Btype.iter_type_expr (check_unboxable env loc) ty; + { val_type = ty; val_kind = Val_prim prim; Types.val_loc = loc; + val_attributes = valdecl.pval_attributes } + in + let (id, newenv) = + Env.enter_value valdecl.pval_name.txt v env + ~check:(fun s -> Warnings.Unused_value_declaration s) + in + let desc = + { + val_id = id; + val_name = valdecl.pval_name; + val_desc = cty; val_val = v; + val_prim = valdecl.pval_prim; + val_loc = valdecl.pval_loc; + val_attributes = valdecl.pval_attributes; + } + in + desc, newenv -let transl_value_path ?(loc=Location.none) env path = - transl_normal_path (Env.normalize_path_prefix (Some loc) env path) +let transl_value_decl env loc valdecl = + Builtin_attributes.warning_scope valdecl.pval_attributes + (fun () -> transl_value_decl env loc valdecl) -let transl_class_path = transl_value_path -let transl_extension_path = transl_value_path +(* Translate a "with" constraint -- much simplified version of + transl_type_decl. *) +let transl_with_constraint env id row_path orig_decl sdecl = + Env.mark_type_used env (Ident.name id) orig_decl; + reset_type_variables(); + Ctype.begin_def(); + let tparams = make_params env sdecl.ptype_params in + let params = List.map (fun (cty, _) -> cty.ctyp_type) tparams in + let orig_decl = Ctype.instance_declaration orig_decl in + let arity_ok = List.length params = orig_decl.type_arity in + if arity_ok then + List.iter2 (Ctype.unify_var env) params orig_decl.type_params; + let constraints = List.map + (function (ty, ty', loc) -> + try + let cty = transl_simple_type env false ty in + let cty' = transl_simple_type env false ty' in + let ty = cty.ctyp_type in + let ty' = cty'.ctyp_type in + Ctype.unify env ty ty'; + (cty, cty', loc) + with Ctype.Unify tr -> + raise(Error(loc, Inconsistent_constraint (env, tr)))) + sdecl.ptype_cstrs + in + let no_row = not (is_fixed_type sdecl) in + let (tman, man) = match sdecl.ptype_manifest with + None -> None, None + | Some sty -> + let cty = transl_simple_type env no_row sty in + Some cty, Some cty.ctyp_type + in + let priv = + if sdecl.ptype_private = Private then Private else + if arity_ok && orig_decl.type_kind <> Type_abstract + then orig_decl.type_private else sdecl.ptype_private + in + if arity_ok && orig_decl.type_kind <> Type_abstract + && sdecl.ptype_private = Private then + Location.deprecated sdecl.ptype_loc "spurious use of private"; + let type_kind, type_unboxed = + if arity_ok && man <> None then + orig_decl.type_kind, orig_decl.type_unboxed + else + Type_abstract, unboxed_false_default_false + in + let decl = + { type_params = params; + type_arity = List.length params; + type_kind; + type_private = priv; + type_manifest = man; + type_variance = []; + type_newtype_level = None; + type_loc = sdecl.ptype_loc; + type_attributes = sdecl.ptype_attributes; + type_immediate = false; + type_unboxed; + } + in + begin match row_path with None -> () + | Some p -> set_fixed_row env sdecl.ptype_loc p decl + end; + begin match Ctype.closed_type_decl decl with None -> () + | Some ty -> raise(Error(sdecl.ptype_loc, Unbound_type_var(ty,decl))) + end; + let decl = name_recursion sdecl id decl in + let type_variance = + compute_variance_decl env true decl + (add_injectivity (List.map snd sdecl.ptype_params), sdecl.ptype_loc) + in + let type_immediate = compute_immediacy env decl in + let decl = {decl with type_variance; type_immediate} in + Ctype.end_def(); + generalize_decl decl; + { + typ_id = id; + typ_name = sdecl.ptype_name; + typ_params = tparams; + typ_type = decl; + typ_cstrs = constraints; + typ_loc = sdecl.ptype_loc; + typ_manifest = tman; + typ_kind = Ttype_abstract; + typ_private = sdecl.ptype_private; + typ_attributes = sdecl.ptype_attributes; + } -(* compatibility alias, deprecated in the .mli *) -let transl_path = transl_value_path +(* Approximate a type declaration: just make all types abstract *) -(* Compile a sequence of expressions *) +let abstract_type_decl arity = + let rec make_params n = + if n <= 0 then [] else Ctype.newvar() :: make_params (n-1) in + Ctype.begin_def(); + let decl = + { type_params = make_params arity; + type_arity = arity; + type_kind = Type_abstract; + type_private = Public; + type_manifest = None; + type_variance = replicate_list Variance.full arity; + type_newtype_level = None; + type_loc = Location.none; + type_attributes = []; + type_immediate = false; + type_unboxed = unboxed_false_default_false; + } in + Ctype.end_def(); + generalize_decl decl; + decl -let rec make_sequence fn = function - [] -> lambda_unit - | [x] -> fn x - | x::rem -> - let lam = fn x in Lsequence(lam, make_sequence fn rem) +let approx_type_decl sdecl_list = + List.map + (fun sdecl -> + (Ident.create sdecl.ptype_name.txt, + abstract_type_decl (List.length sdecl.ptype_params))) + sdecl_list -(* Apply a substitution to a lambda-term. - Assumes that the bound variables of the lambda-term do not - belong to the domain of the substitution. - Assumes that the image of the substitution is out of reach - of the bound variables of the lambda-term (no capture). *) +(* Variant of check_abbrev_recursion to check the well-formedness + conditions on type abbreviations defined within recursive modules. *) -let subst_lambda s lam = - let rec subst = function - Lvar id as l -> - begin try Ident.find_same id s with Not_found -> l end - | Lconst _ as l -> l - | Lapply ap -> - Lapply{ap with ap_func = subst ap.ap_func; - ap_args = List.map subst ap.ap_args} - | Lfunction{kind; params; body; attr; loc} -> - Lfunction{kind; params; body = subst body; attr; loc} - | Llet(str, k, id, arg, body) -> Llet(str, k, id, subst arg, subst body) - | Lletrec(decl, body) -> Lletrec(List.map subst_decl decl, subst body) - | Lprim(p, args, loc) -> Lprim(p, List.map subst args, loc) - | Lswitch(arg, sw, loc) -> - Lswitch(subst arg, - {sw with sw_consts = List.map subst_case sw.sw_consts; - sw_blocks = List.map subst_case sw.sw_blocks; - sw_failaction = subst_opt sw.sw_failaction; }, - loc) - | Lstringswitch (arg,cases,default,loc) -> - Lstringswitch - (subst arg,List.map subst_strcase cases,subst_opt default,loc) - | Lstaticraise (i,args) -> Lstaticraise (i, List.map subst args) - | Lstaticcatch(e1, io, e2) -> Lstaticcatch(subst e1, io, subst e2) - | Ltrywith(e1, exn, e2) -> Ltrywith(subst e1, exn, subst e2) - | Lifthenelse(e1, e2, e3) -> Lifthenelse(subst e1, subst e2, subst e3) - | Lsequence(e1, e2) -> Lsequence(subst e1, subst e2) - | Lwhile(e1, e2) -> Lwhile(subst e1, subst e2) - | Lfor(v, e1, e2, dir, e3) -> Lfor(v, subst e1, subst e2, dir, subst e3) - | Lassign(id, e) -> Lassign(id, subst e) - | Lsend (k, met, obj, args, loc) -> - Lsend (k, subst met, subst obj, List.map subst args, loc) - | Levent (lam, evt) -> Levent (subst lam, evt) - | Lifused (v, e) -> Lifused (v, subst e) - and subst_decl (id, exp) = (id, subst exp) - and subst_case (key, case) = (key, subst case) - and subst_strcase (key, case) = (key, subst case) - and subst_opt = function - | None -> None - | Some e -> Some (subst e) - in subst lam +let check_recmod_typedecl env loc recmod_ids path decl = + (* recmod_ids is the list of recursively-defined module idents. + (path, decl) is the type declaration to be checked. *) + let to_check path = + List.exists (fun id -> Path.isfree id path) recmod_ids in + check_well_founded_decl env loc path decl to_check; + check_recursion env loc path decl to_check -let rec map f lam = - let lam = - match lam with - | Lvar _ -> lam - | Lconst _ -> lam - | Lapply { ap_func; ap_args; ap_loc; ap_should_be_tailcall; - ap_inlined; ap_specialised } -> - Lapply { - ap_func = map f ap_func; - ap_args = List.map (map f) ap_args; - ap_loc; - ap_should_be_tailcall; - ap_inlined; - ap_specialised; - } - | Lfunction { kind; params; body; attr; loc; } -> - Lfunction { kind; params; body = map f body; attr; loc; } - | Llet (str, k, v, e1, e2) -> - Llet (str, k, v, map f e1, map f e2) - | Lletrec (idel, e2) -> - Lletrec (List.map (fun (v, e) -> (v, map f e)) idel, map f e2) - | Lprim (p, el, loc) -> - Lprim (p, List.map (map f) el, loc) - | Lswitch (e, sw, loc) -> - Lswitch (map f e, - { sw_numconsts = sw.sw_numconsts; - sw_consts = List.map (fun (n, e) -> (n, map f e)) sw.sw_consts; - sw_numblocks = sw.sw_numblocks; - sw_blocks = List.map (fun (n, e) -> (n, map f e)) sw.sw_blocks; - sw_failaction = Misc.may_map (map f) sw.sw_failaction; - sw_names = sw.sw_names - }, - loc) - | Lstringswitch (e, sw, default, loc) -> - Lstringswitch ( - map f e, - List.map (fun (s, e) -> (s, map f e)) sw, - Misc.may_map (map f) default, - loc) - | Lstaticraise (i, args) -> - Lstaticraise (i, List.map (map f) args) - | Lstaticcatch (body, id, handler) -> - Lstaticcatch (map f body, id, map f handler) - | Ltrywith (e1, v, e2) -> - Ltrywith (map f e1, v, map f e2) - | Lifthenelse (e1, e2, e3) -> - Lifthenelse (map f e1, map f e2, map f e3) - | Lsequence (e1, e2) -> - Lsequence (map f e1, map f e2) - | Lwhile (e1, e2) -> - Lwhile (map f e1, map f e2) - | Lfor (v, e1, e2, dir, e3) -> - Lfor (v, map f e1, map f e2, dir, map f e3) - | Lassign (v, e) -> - Lassign (v, map f e) - | Lsend (k, m, o, el, loc) -> - Lsend (k, map f m, map f o, List.map (map f) el, loc) - | Levent (l, ev) -> - Levent (map f l, ev) - | Lifused (v, e) -> - Lifused (v, map f e) - in - f lam -(* To let-bind expressions to variables *) +(**** Error report ****) -let bind str var exp body = - match exp with - Lvar var' when Ident.same var var' -> body - | _ -> Llet(str, Pgenval, var, exp, body) +open Format -and commute_comparison = function -| Ceq -> Ceq| Cneq -> Cneq -| Clt -> Cgt | Cle -> Cge -| Cgt -> Clt | Cge -> Cle +let explain_unbound_gen ppf tv tl typ kwd pr = + try + let ti = List.find (fun ti -> Ctype.deep_occur tv (typ ti)) tl in + let ty0 = (* Hack to force aliasing when needed *) + Btype.newgenty (Tobject(tv, ref None)) in + Printtyp.reset_and_mark_loops_list [typ ti; ty0]; + fprintf ppf + ".@.@[In %s@ %a@;<1 -2>the variable %a is unbound@]" + kwd pr ti Printtyp.type_expr tv + with Not_found -> () -and negate_comparison = function -| Ceq -> Cneq| Cneq -> Ceq -| Clt -> Cge | Cle -> Cgt -| Cgt -> Cle | Cge -> Clt +let explain_unbound ppf tv tl typ kwd lab = + explain_unbound_gen ppf tv tl typ kwd + (fun ppf ti -> fprintf ppf "%s%a" (lab ti) Printtyp.type_expr (typ ti)) -let raise_kind = function - | Raise_regular -> "raise" - | Raise_reraise -> "reraise" - | Raise_notrace -> "raise_notrace" +let explain_unbound_single ppf tv ty = + let trivial ty = + explain_unbound ppf tv [ty] (fun t -> t) "type" (fun _ -> "") in + match (Ctype.repr ty).desc with + Tobject(fi,_) -> + let (tl, rv) = Ctype.flatten_fields fi in + if rv == tv then trivial ty else + explain_unbound ppf tv tl (fun (_,_,t) -> t) + "method" (fun (lab,_,_) -> lab ^ ": ") + | Tvariant row -> + let row = Btype.row_repr row in + if row.row_more == tv then trivial ty else + explain_unbound ppf tv row.row_fields + (fun (_l,f) -> match Btype.row_field_repr f with + Rpresent (Some t) -> t + | Reither (_,[t],_,_) -> t + | Reither (_,tl,_,_) -> Btype.newgenty (Ttuple tl) + | _ -> Btype.newgenty (Ttuple[])) + "case" (fun (lab,_) -> "`" ^ lab ^ " of ") + | _ -> trivial ty -let lam_of_loc kind loc = - let loc_start = loc.Location.loc_start in - let (file, lnum, cnum) = Location.get_pos_info loc_start in - - let file = Filename.basename file in - let enum = loc.Location.loc_end.Lexing.pos_cnum - - loc_start.Lexing.pos_cnum + cnum in - match kind with - | Loc_POS -> - Lconst (Const_block (0, Blk_tuple, [ - Const_immstring file; - Const_base (Const_int lnum); - Const_base (Const_int cnum); - Const_base (Const_int enum); - ])) - | Loc_FILE -> Lconst (Const_immstring file) - | Loc_MODULE -> - let filename = Filename.basename file in - let name = Env.get_unit_name () in - let module_name = if name = "" then "//"^filename^"//" else name in - Lconst (Const_immstring module_name) - | Loc_LOC -> - let loc = Printf.sprintf "File %S, line %d, characters %d-%d" - file lnum cnum enum in - Lconst (Const_immstring loc) - | Loc_LINE -> Lconst (Const_base (Const_int lnum)) +let tys_of_constr_args = function + | Types.Cstr_tuple tl -> tl + | Types.Cstr_record lbls -> List.map (fun l -> l.Types.ld_type) lbls -let merge_inline_attributes attr1 attr2 = - match attr1, attr2 with - | Default_inline, _ -> Some attr2 - | _, Default_inline -> Some attr1 - | _, _ -> - if attr1 = attr2 then Some attr1 - else None +let report_error ppf = function + | Repeated_parameter -> + fprintf ppf "A type parameter occurs several times" + | Duplicate_constructor s -> + fprintf ppf "Two constructors are named %s" s + | Too_many_constructors -> + fprintf ppf + "@[Too many non-constant constructors@ -- maximum is %i %s@]" + (Config.max_tag + 1) "non-constant constructors" + | Duplicate_label s -> + fprintf ppf "Two labels are named %s" s + | Recursive_abbrev s -> + fprintf ppf "The type abbreviation %s is cyclic" s + | Cycle_in_def (s, ty) -> + Printtyp.reset_and_mark_loops ty; + fprintf ppf "@[The definition of %s contains a cycle:@ %a@]" + s Printtyp.type_expr ty + | Definition_mismatch (ty, errs) -> + Printtyp.reset_and_mark_loops ty; + fprintf ppf "@[@[%s@ %s@;<1 2>%a@]%a@]" + "This variant or record definition" "does not match that of type" + Printtyp.type_expr ty + (Includecore.report_type_mismatch "the original" "this" "definition") + errs + | Constraint_failed (ty, ty') -> + Printtyp.reset_and_mark_loops ty; + Printtyp.mark_loops ty'; + fprintf ppf "@[%s@ @[Type@ %a@ should be an instance of@ %a@]@]" + "Constraints are not satisfied in this type." + Printtyp.type_expr ty Printtyp.type_expr ty' + | Parameters_differ (path, ty, ty') -> + Printtyp.reset_and_mark_loops ty; + Printtyp.mark_loops ty'; + fprintf ppf + "@[In the definition of %s, type@ %a@ should be@ %a@]" + (Path.name path) Printtyp.type_expr ty Printtyp.type_expr ty' + | Inconsistent_constraint (env, trace) -> + fprintf ppf "The type constraints are not consistent.@."; + Printtyp.report_unification_error ppf env trace + (fun ppf -> fprintf ppf "Type") + (fun ppf -> fprintf ppf "is not compatible with type") + | Type_clash (env, trace) -> + Printtyp.report_unification_error ppf env trace + (function ppf -> + fprintf ppf "This type constructor expands to type") + (function ppf -> + fprintf ppf "but is used here with type") + | Null_arity_external -> + fprintf ppf "External identifiers must be functions" + | Missing_native_external -> + fprintf ppf "@[An external function with more than 5 arguments \ + requires a second stub function@ \ + for native-code compilation@]" + | Unbound_type_var (ty, decl) -> + fprintf ppf "A type variable is unbound in this type declaration"; + let ty = Ctype.repr ty in + begin match decl.type_kind, decl.type_manifest with + | Type_variant tl, _ -> + explain_unbound_gen ppf ty tl (fun c -> + let tl = tys_of_constr_args c.Types.cd_args in + Btype.newgenty (Ttuple tl) + ) + "case" (fun ppf c -> + fprintf ppf + "%s of %a" (Ident.name c.Types.cd_id) + Printtyp.constructor_arguments c.Types.cd_args) + | Type_record (tl, _), _ -> + explain_unbound ppf ty tl (fun l -> l.Types.ld_type) + "field" (fun l -> Ident.name l.Types.ld_id ^ ": ") + | Type_abstract, Some ty' -> + explain_unbound_single ppf ty ty' + | _ -> () + end + | Unbound_type_var_ext (ty, ext) -> + fprintf ppf "A type variable is unbound in this extension constructor"; + let args = tys_of_constr_args ext.ext_args in + explain_unbound ppf ty args (fun c -> c) "type" (fun _ -> "") + | Cannot_extend_private_type path -> + fprintf ppf "@[%s@ %a@]" + "Cannot extend private type definition" + Printtyp.path path + | Not_extensible_type path -> + fprintf ppf "@[%s@ %a@ %s@]" + "Type definition" + Printtyp.path path + "is not extensible" + | Extension_mismatch (path, errs) -> + fprintf ppf "@[@[%s@ %s@;<1 2>%s@]%a@]" + "This extension" "does not match the definition of type" + (Path.name path) + (Includecore.report_type_mismatch + "the type" "this extension" "definition") + errs + | Rebind_wrong_type (lid, env, trace) -> + Printtyp.report_unification_error ppf env trace + (function ppf -> + fprintf ppf "The constructor %a@ has type" + Printtyp.longident lid) + (function ppf -> + fprintf ppf "but was expected to be of type") + | Rebind_mismatch (lid, p, p') -> + fprintf ppf + "@[%s@ %a@ %s@ %s@ %s@ %s@ %s@]" + "The constructor" Printtyp.longident lid + "extends type" (Path.name p) + "whose declaration does not match" + "the declaration of type" (Path.name p') + | Rebind_private lid -> + fprintf ppf "@[%s@ %a@ %s@]" + "The constructor" + Printtyp.longident lid + "is private" + | Bad_variance (n, v1, v2) -> + let variance (p,n,i) = + let inj = if i then "injective " else "" in + match p, n with + true, true -> inj ^ "invariant" + | true, false -> inj ^ "covariant" + | false, true -> inj ^ "contravariant" + | false, false -> if inj = "" then "unrestricted" else inj + in + let suffix n = + let teen = (n mod 100)/10 = 1 in + match n mod 10 with + | 1 when not teen -> "st" + | 2 when not teen -> "nd" + | 3 when not teen -> "rd" + | _ -> "th" + in + if n = -1 then + fprintf ppf "@[%s@ %s@ It" + "In this definition, a type variable has a variance that" + "is not reflected by its occurrence in type parameters." + else if n = -2 then + fprintf ppf "@[%s@ %s@]" + "In this definition, a type variable cannot be deduced" + "from the type parameters." + else if n = -3 then + fprintf ppf "@[%s@ %s@ It" + "In this definition, a type variable has a variance that" + "cannot be deduced from the type parameters." + else + fprintf ppf "@[%s@ %s@ The %d%s type parameter" + "In this definition, expected parameter" + "variances are not satisfied." + n (suffix n); + if n <> -2 then + fprintf ppf " was expected to be %s,@ but it is %s.@]" + (variance v2) (variance v1) + | Unavailable_type_constructor p -> + fprintf ppf "The definition of type %a@ is unavailable" Printtyp.path p + | Bad_fixed_type r -> + fprintf ppf "This fixed type %s" r + | Varying_anonymous -> + fprintf ppf "@[%s@ %s@ %s@]" + "In this GADT definition," "the variance of some parameter" + "cannot be checked" + | Val_in_structure -> + fprintf ppf "Value declarations are only allowed in signatures" + | Multiple_native_repr_attributes -> + fprintf ppf "Too many [@@unboxed]/[@@untagged] attributes" + | Cannot_unbox_or_untag_type Unboxed -> + fprintf ppf "Don't know how to unbox this type. Only float, int32, \ + int64 and nativeint can be unboxed" + | Cannot_unbox_or_untag_type Untagged -> + fprintf ppf "Don't know how to untag this type. Only int \ + can be untagged" + | Deep_unbox_or_untag_attribute kind -> + fprintf ppf + "The attribute '%s' should be attached to a direct argument or \ + result of the primitive, it should not occur deeply into its type" + (match kind with Unboxed -> "@unboxed" | Untagged -> "@untagged") + | Bad_immediate_attribute -> + fprintf ppf "@[%s@ %s@]" + "Types marked with the immediate attribute must be" + "non-pointer types like int or bool" + | Bad_unboxed_attribute msg -> + fprintf ppf "@[This type cannot be unboxed because@ %s.@]" msg + | Wrong_unboxed_type_float -> + fprintf ppf "@[This type cannot be unboxed because@ \ + it might contain both float and non-float values.@ \ + You should annotate it with [%@%@ocaml.boxed].@]" + | Boxed_and_unboxed -> + fprintf ppf "@[A type cannot be boxed and unboxed at the same time.@]" + | Nonrec_gadt -> + fprintf ppf + "@[GADT case syntax cannot be used in a 'nonrec' block.@]" -let reset () = - raise_count := 0 +let () = + Location.register_error_of_exn + (function + | Error (loc, err) -> + Some (Location.error_of_printer loc report_error err) + | _ -> + None + ) end module Typeopt : sig @@ -78093,7 +78239,7 @@ type meth_kind = Lambda.meth_kind type field_dbg_info = Lambda.field_dbg_info = | Fld_na - | Fld_record of string + | Fld_record of {name : string; mutable_flag : Asttypes.mutable_flag} | Fld_module of string | Fld_record_inline of string @@ -78305,7 +78451,7 @@ type meth_kind = Lambda.meth_kind type field_dbg_info = Lambda.field_dbg_info = | Fld_na - | Fld_record of string + | Fld_record of {name : string; mutable_flag : Asttypes.mutable_flag} | Fld_module of string | Fld_record_inline of string @@ -78316,7 +78462,7 @@ let str_of_field_info (x : field_dbg_info) : string option = match x with | Fld_na | Fld_tuple -> None - | Fld_record s + | Fld_record {name = s} | Fld_module s | Fld_record_inline s | Fld_record_extension s @@ -86076,7 +86222,7 @@ let array_index_by_int ?comment (e : t) (pos : int32) : t = | _ -> { expression_desc = Array_index (e, int ?comment pos); comment = None} let record_access (e : t) (name : string) (pos : int32) = - let name = Ext_ident.convert name in + (* let name = Ext_ident.convert name in *) match e.expression_desc with | Array (l,_) (* Float i -- should not appear here *) | Caml_block (l,_, _, _) when no_side_effect e @@ -88749,7 +88895,7 @@ let primitive ppf = function fprintf ppf "makeblock %i%a" tag block_shape shape | Pmakeblock(tag, _, Mutable, shape) -> fprintf ppf "makemutable %i%a" tag block_shape shape - | Pfield (n, (Fld_module s | Fld_record s)) -> fprintf ppf "field:%s/%i" s n + | Pfield (n, (Fld_module s | Fld_record {name=s})) -> fprintf ppf "field:%s/%i" s n | Pfield (n,_) -> fprintf ppf "field %i" n | Pfield_computed -> fprintf ppf "field_computed" | Psetfield(n, ptr, init, _) -> @@ -91931,11 +92077,11 @@ let make_record_matching loc all_labels def = function let access = match lbl.lbl_repres with | Record_regular -> - Lprim (Pfield (lbl.lbl_pos, Fld_record lbl.lbl_name), [arg], loc) + Lprim (Pfield (lbl.lbl_pos, !Lambda.fld_record lbl), [arg], loc) | Record_inlined _ -> Lprim (Pfield (lbl.lbl_pos, Fld_record_inline lbl.lbl_name), [arg], loc) | Record_unboxed _ -> arg - | Record_float -> Lprim (Pfloatfield (lbl.lbl_pos, Fld_record lbl.lbl_name), [arg], loc) + | Record_float -> Lprim (Pfloatfield (lbl.lbl_pos, !Lambda.fld_record lbl), [arg], loc) | Record_extension -> Lprim (Pfield (lbl.lbl_pos + 1, Fld_record_extension lbl.lbl_name), [arg], loc) in let str = @@ -94885,11 +95031,11 @@ and transl_exp0 e = let targ = transl_exp arg in begin match lbl.lbl_repres with Record_regular -> - Lprim (Pfield (lbl.lbl_pos, Fld_record lbl.lbl_name), [targ], e.exp_loc) + Lprim (Pfield (lbl.lbl_pos, !Lambda.fld_record lbl), [targ], e.exp_loc) | Record_inlined _ -> Lprim (Pfield (lbl.lbl_pos, Fld_record_inline lbl.lbl_name), [targ], e.exp_loc) | Record_unboxed _ -> targ - | Record_float -> Lprim (Pfloatfield (lbl.lbl_pos, Fld_record lbl.lbl_name), [targ], e.exp_loc) + | Record_float -> Lprim (Pfloatfield (lbl.lbl_pos, !Lambda.fld_record lbl), [targ], e.exp_loc) | Record_extension -> Lprim (Pfield (lbl.lbl_pos + 1, Fld_record_extension lbl.lbl_name), [targ], e.exp_loc) end @@ -94897,11 +95043,11 @@ and transl_exp0 e = let access = match lbl.lbl_repres with Record_regular -> - Psetfield(lbl.lbl_pos, maybe_pointer newval, Assignment, Fld_record_set lbl.lbl_name) + Psetfield(lbl.lbl_pos, maybe_pointer newval, Assignment, !Lambda.fld_record_set lbl) | Record_inlined _ -> Psetfield(lbl.lbl_pos, maybe_pointer newval, Assignment, Fld_record_inline_set lbl.lbl_name) | Record_unboxed _ -> assert false - | Record_float -> Psetfloatfield (lbl.lbl_pos, Assignment, Fld_record_set lbl.lbl_name) + | Record_float -> Psetfloatfield (lbl.lbl_pos, Assignment, !Lambda.fld_record_set lbl) | Record_extension -> Psetfield (lbl.lbl_pos + 1, maybe_pointer newval, Assignment, Fld_record_extension_set lbl.lbl_name) in @@ -95291,11 +95437,11 @@ and transl_record loc env fields repres opt_init_expr = let field_kind = value_kind env typ in let access = match repres with - Record_regular -> Pfield (i, Fld_record lbl.lbl_name) + Record_regular -> Pfield (i, !Lambda.fld_record lbl) | Record_inlined _ -> Pfield (i, Fld_record_inline lbl.lbl_name) | Record_unboxed _ -> assert false | Record_extension -> Pfield (i + 1, Fld_record_extension lbl.lbl_name) - | Record_float -> Pfloatfield (i, Fld_record lbl.lbl_name) in + | Record_float -> Pfloatfield (i, !Lambda.fld_record lbl) in Lprim(access, [Lvar init_id], loc), field_kind | Overridden (_lid, expr) -> let field_kind = value_kind expr.exp_env expr.exp_type in @@ -95307,17 +95453,16 @@ and transl_record loc env fields repres opt_init_expr = if Array.exists (fun (lbl, _) -> lbl.lbl_mut = Mutable) fields then Mutable else Immutable in - let all_labels_info = fields |> Array.map (fun (x,_) -> x.Types.lbl_name) in let lam = try if mut = Mutable then raise Not_constant; let cl = List.map extract_constant ll in match repres with - | Record_regular -> Lconst(Const_block(0, Lambda.Blk_record all_labels_info, cl)) - | Record_inlined {tag;name;num_nonconsts} -> Lconst(Const_block(tag, Lambda.Blk_record_inlined (all_labels_info,name,num_nonconsts), cl)) + | Record_regular -> Lconst(Const_block(0, !Lambda.blk_record fields, cl)) + | Record_inlined {tag;name;num_nonconsts} -> Lconst(Const_block(tag, !Lambda.blk_record_inlined fields name num_nonconsts, cl)) | Record_unboxed _ -> Lconst(match cl with [v] -> v | _ -> assert false) | Record_float -> - if !Clflags.bs_only then Lconst(Const_block(0, Lambda.Blk_record all_labels_info, cl)) + if !Clflags.bs_only then Lconst(Const_block(0, !Lambda.blk_record fields, cl)) else Lconst(Const_float_array(List.map extract_float cl)) | Record_extension -> @@ -95325,12 +95470,12 @@ and transl_record loc env fields repres opt_init_expr = with Not_constant -> match repres with Record_regular -> - Lprim(Pmakeblock(0, Lambda.Blk_record all_labels_info, mut, Some shape), ll, loc) + Lprim(Pmakeblock(0, !Lambda.blk_record fields, mut, Some shape), ll, loc) | Record_inlined {tag;name; num_nonconsts} -> - Lprim(Pmakeblock(tag, Lambda.Blk_record_inlined (all_labels_info, name, num_nonconsts), mut, Some shape), ll, loc) + Lprim(Pmakeblock(tag, !Lambda.blk_record_inlined fields name num_nonconsts, mut, Some shape), ll, loc) | Record_unboxed _ -> (match ll with [v] -> v | _ -> assert false) | Record_float -> - if !Clflags.bs_only then Lprim(Pmakeblock(0, Lambda.Blk_record all_labels_info, mut, Some shape), ll, loc) + if !Clflags.bs_only then Lprim(Pmakeblock(0, !Lambda.blk_record fields, mut, Some shape), ll, loc) else Lprim(Pmakearray (Pfloatarray, mut), ll, loc) | Record_extension -> @@ -95341,7 +95486,7 @@ and transl_record loc env fields repres opt_init_expr = | _ -> assert false in let slot = transl_extension_path env path in - Lprim(Pmakeblock(0, Lambda.Blk_record_ext all_labels_info, mut, Some (Pgenval :: shape)), slot :: ll, loc) + Lprim(Pmakeblock(0, !Lambda.blk_record_ext fields, mut, Some (Pgenval :: shape)), slot :: ll, loc) in begin match opt_init_expr with None -> lam @@ -95359,11 +95504,11 @@ and transl_record loc env fields repres opt_init_expr = let upd = match repres with Record_regular -> - Psetfield(lbl.lbl_pos, maybe_pointer expr, Assignment, Fld_record_set lbl.lbl_name) + Psetfield(lbl.lbl_pos, maybe_pointer expr, Assignment, !Lambda.fld_record_set lbl) | Record_inlined _ -> Psetfield(lbl.lbl_pos, maybe_pointer expr, Assignment, Fld_record_inline_set lbl.lbl_name) | Record_unboxed _ -> assert false - | Record_float -> Psetfloatfield (lbl.lbl_pos, Assignment, Fld_record_set lbl.lbl_name) + | Record_float -> Psetfloatfield (lbl.lbl_pos, Assignment, !Lambda.fld_record_set lbl) | Record_extension -> Psetfield(lbl.lbl_pos + 1, maybe_pointer expr, Assignment, Fld_record_extension_set lbl.lbl_name) in @@ -100455,8 +100600,9 @@ and expression_desc cxt ~(level:int) f x : cxt = (Ext_list.map_combine fields el Ext_ident.convert))) | Caml_block(el,_, _, Blk_record fields) -> expression_desc cxt ~level f (Object ( - (Ext_list.map_combine (Array.to_list fields) el Ext_ident.convert))) - (*FIXME: avoid allocaton *) + (List.combine (Array.to_list fields) el ))) + (* name convention of Record is slight different from modules + *) | Caml_block( el, mutable_flag, tag, tag_info) -> (* Note that, if we ignore more than tag [0] we loose some information @@ -107769,7 +107915,7 @@ let field (field_info : Lam_compat.field_dbg_info) e i = -> E.array_index_by_int ~comment e i - | Fld_record name + | Fld_record {name} -> E.record_access e name i | Fld_module name -> E.module_access e name i @@ -118925,6 +119071,16 @@ let emit_external_warnings : iterator= | _ -> default_iterator.expr self a ); + label_declaration = (fun self lbl -> + + Ext_list.iter lbl.pld_attributes + (fun attr -> + match attr with + | {txt = "bs.as"}, _ -> mark_used_bs_attribute attr + | _ -> () + ); + default_iterator.label_declaration self lbl + ); value_description = (fun self v -> match v with diff --git a/lib/4.06.1/whole_compiler.ml.d b/lib/4.06.1/whole_compiler.ml.d index 57d1fb3990..da8ea492c6 100644 --- a/lib/4.06.1/whole_compiler.ml.d +++ b/lib/4.06.1/whole_compiler.ml.d @@ -1 +1 @@ -../lib/4.06.1/whole_compiler.ml: ../ocaml/bytecomp/lambda.ml ../ocaml/bytecomp/lambda.mli ../ocaml/bytecomp/matching.ml ../ocaml/bytecomp/matching.mli ../ocaml/bytecomp/printlambda.ml ../ocaml/bytecomp/printlambda.mli ../ocaml/bytecomp/switch.ml ../ocaml/bytecomp/switch.mli ../ocaml/bytecomp/translattribute.ml ../ocaml/bytecomp/translattribute.mli ../ocaml/bytecomp/translclass.ml ../ocaml/bytecomp/translclass.mli ../ocaml/bytecomp/translcore.ml ../ocaml/bytecomp/translcore.mli ../ocaml/bytecomp/translmod.ml ../ocaml/bytecomp/translmod.mli ../ocaml/bytecomp/translobj.ml ../ocaml/bytecomp/translobj.mli ../ocaml/driver/compenv.ml ../ocaml/driver/compenv.mli ../ocaml/driver/compmisc.ml ../ocaml/driver/compmisc.mli ../ocaml/driver/pparse.ml ../ocaml/driver/pparse.mli ../ocaml/parsing/ast_helper.ml ../ocaml/parsing/ast_helper.mli ../ocaml/parsing/ast_invariants.ml ../ocaml/parsing/ast_invariants.mli ../ocaml/parsing/ast_iterator.ml ../ocaml/parsing/ast_iterator.mli ../ocaml/parsing/ast_mapper.ml ../ocaml/parsing/ast_mapper.mli ../ocaml/parsing/asttypes.mli ../ocaml/parsing/attr_helper.ml ../ocaml/parsing/attr_helper.mli ../ocaml/parsing/builtin_attributes.ml ../ocaml/parsing/builtin_attributes.mli ../ocaml/parsing/depend.ml ../ocaml/parsing/depend.mli ../ocaml/parsing/docstrings.ml ../ocaml/parsing/docstrings.mli ../ocaml/parsing/lexer.ml ../ocaml/parsing/lexer.mli ../ocaml/parsing/location.ml ../ocaml/parsing/location.mli ../ocaml/parsing/longident.ml ../ocaml/parsing/longident.mli ../ocaml/parsing/parse.ml ../ocaml/parsing/parse.mli ../ocaml/parsing/parser.ml ../ocaml/parsing/parser.mli ../ocaml/parsing/parsetree.mli ../ocaml/parsing/pprintast.ml ../ocaml/parsing/pprintast.mli ../ocaml/parsing/printast.ml ../ocaml/parsing/printast.mli ../ocaml/parsing/syntaxerr.ml ../ocaml/parsing/syntaxerr.mli ../ocaml/typing/annot.mli ../ocaml/typing/btype.ml ../ocaml/typing/btype.mli ../ocaml/typing/cmi_format.ml ../ocaml/typing/cmi_format.mli ../ocaml/typing/cmt_format.ml ../ocaml/typing/cmt_format.mli ../ocaml/typing/ctype.ml ../ocaml/typing/ctype.mli ../ocaml/typing/datarepr.ml ../ocaml/typing/datarepr.mli ../ocaml/typing/env.ml ../ocaml/typing/env.mli ../ocaml/typing/ident.ml ../ocaml/typing/ident.mli ../ocaml/typing/includeclass.ml ../ocaml/typing/includeclass.mli ../ocaml/typing/includecore.ml ../ocaml/typing/includecore.mli ../ocaml/typing/includemod.ml ../ocaml/typing/includemod.mli ../ocaml/typing/mtype.ml ../ocaml/typing/mtype.mli ../ocaml/typing/oprint.ml ../ocaml/typing/oprint.mli ../ocaml/typing/outcometree.mli ../ocaml/typing/parmatch.ml ../ocaml/typing/parmatch.mli ../ocaml/typing/path.ml ../ocaml/typing/path.mli ../ocaml/typing/predef.ml ../ocaml/typing/predef.mli ../ocaml/typing/primitive.ml ../ocaml/typing/primitive.mli ../ocaml/typing/printtyp.ml ../ocaml/typing/printtyp.mli ../ocaml/typing/printtyped.ml ../ocaml/typing/printtyped.mli ../ocaml/typing/stypes.ml ../ocaml/typing/stypes.mli ../ocaml/typing/subst.ml ../ocaml/typing/subst.mli ../ocaml/typing/tast_mapper.ml ../ocaml/typing/tast_mapper.mli ../ocaml/typing/typeclass.ml ../ocaml/typing/typeclass.mli ../ocaml/typing/typecore.ml ../ocaml/typing/typecore.mli ../ocaml/typing/typedecl.ml ../ocaml/typing/typedecl.mli ../ocaml/typing/typedtree.ml ../ocaml/typing/typedtree.mli ../ocaml/typing/typedtreeIter.ml ../ocaml/typing/typedtreeIter.mli ../ocaml/typing/typemod.ml ../ocaml/typing/typemod.mli ../ocaml/typing/typeopt.ml ../ocaml/typing/typeopt.mli ../ocaml/typing/types.ml ../ocaml/typing/types.mli ../ocaml/typing/typetexp.ml ../ocaml/typing/typetexp.mli ../ocaml/typing/untypeast.ml ../ocaml/typing/untypeast.mli ../ocaml/utils/arg_helper.ml ../ocaml/utils/arg_helper.mli ../ocaml/utils/ccomp.ml ../ocaml/utils/ccomp.mli ../ocaml/utils/clflags.ml ../ocaml/utils/clflags.mli ../ocaml/utils/consistbl.ml ../ocaml/utils/consistbl.mli ../ocaml/utils/identifiable.ml ../ocaml/utils/identifiable.mli ../ocaml/utils/misc.ml ../ocaml/utils/misc.mli ../ocaml/utils/numbers.ml ../ocaml/utils/numbers.mli ../ocaml/utils/profile.ml ../ocaml/utils/profile.mli ../ocaml/utils/tbl.ml ../ocaml/utils/tbl.mli ../ocaml/utils/terminfo.ml ../ocaml/utils/terminfo.mli ../ocaml/utils/warnings.ml ../ocaml/utils/warnings.mli ./common/bs_loc.ml ./common/bs_loc.mli ./common/bs_version.ml ./common/bs_version.mli ./common/bs_warnings.ml ./common/bs_warnings.mli ./common/ext_log.ml ./common/ext_log.mli ./common/js_config.ml ./common/js_config.mli ./common/lam_methname.ml ./common/lam_methname.mli ./common/ml_binary.ml ./common/ml_binary.mli ./core/bs_conditional_initial.ml ./core/bs_conditional_initial.mli ./core/config_util.ml ./core/config_util.mli ./core/config_whole_compiler.ml ./core/config_whole_compiler.mli ./core/j.ml ./core/js_analyzer.ml ./core/js_analyzer.mli ./core/js_arr.ml ./core/js_arr.mli ./core/js_ast_util.ml ./core/js_ast_util.mli ./core/js_block_runtime.ml ./core/js_block_runtime.mli ./core/js_call_info.ml ./core/js_call_info.mli ./core/js_closure.ml ./core/js_closure.mli ./core/js_cmj_format.ml ./core/js_cmj_format.mli ./core/js_cmj_load.ml ./core/js_cmj_load.mli ./core/js_dump.ml ./core/js_dump.mli ./core/js_dump_import_export.ml ./core/js_dump_import_export.mli ./core/js_dump_lit.ml ./core/js_dump_program.ml ./core/js_dump_program.mli ./core/js_dump_property.ml ./core/js_dump_property.mli ./core/js_dump_string.ml ./core/js_dump_string.mli ./core/js_exp_make.ml ./core/js_exp_make.mli ./core/js_fold.ml ./core/js_fold_basic.ml ./core/js_fold_basic.mli ./core/js_fun_env.ml ./core/js_fun_env.mli ./core/js_implementation.ml ./core/js_implementation.mli ./core/js_long.ml ./core/js_long.mli ./core/js_map.ml ./core/js_name_of_module_id.ml ./core/js_name_of_module_id.mli ./core/js_number.ml ./core/js_number.mli ./core/js_of_lam_array.ml ./core/js_of_lam_array.mli ./core/js_of_lam_block.ml ./core/js_of_lam_block.mli ./core/js_of_lam_exception.ml ./core/js_of_lam_exception.mli ./core/js_of_lam_option.ml ./core/js_of_lam_option.mli ./core/js_of_lam_polyvar.ml ./core/js_of_lam_polyvar.mli ./core/js_of_lam_string.ml ./core/js_of_lam_string.mli ./core/js_of_lam_tuple.ml ./core/js_of_lam_tuple.mli ./core/js_of_lam_variant.ml ./core/js_of_lam_variant.mli ./core/js_op.ml ./core/js_op_util.ml ./core/js_op_util.mli ./core/js_output.ml ./core/js_output.mli ./core/js_packages_info.ml ./core/js_packages_info.mli ./core/js_packages_state.ml ./core/js_packages_state.mli ./core/js_pass_debug.ml ./core/js_pass_debug.mli ./core/js_pass_flatten.ml ./core/js_pass_flatten.mli ./core/js_pass_flatten_and_mark_dead.ml ./core/js_pass_flatten_and_mark_dead.mli ./core/js_pass_scope.ml ./core/js_pass_scope.mli ./core/js_pass_tailcall_inline.ml ./core/js_pass_tailcall_inline.mli ./core/js_shake.ml ./core/js_shake.mli ./core/js_stmt_make.ml ./core/js_stmt_make.mli ./core/lam.ml ./core/lam.mli ./core/lam_analysis.ml ./core/lam_analysis.mli ./core/lam_arity.ml ./core/lam_arity.mli ./core/lam_arity_analysis.ml ./core/lam_arity_analysis.mli ./core/lam_beta_reduce.ml ./core/lam_beta_reduce.mli ./core/lam_beta_reduce_util.ml ./core/lam_beta_reduce_util.mli ./core/lam_bounded_vars.ml ./core/lam_bounded_vars.mli ./core/lam_closure.ml ./core/lam_closure.mli ./core/lam_coercion.ml ./core/lam_coercion.mli ./core/lam_compat.ml ./core/lam_compat.mli ./core/lam_compile.ml ./core/lam_compile.mli ./core/lam_compile_const.ml ./core/lam_compile_const.mli ./core/lam_compile_context.ml ./core/lam_compile_context.mli ./core/lam_compile_env.ml ./core/lam_compile_env.mli ./core/lam_compile_external_call.ml ./core/lam_compile_external_call.mli ./core/lam_compile_external_obj.ml ./core/lam_compile_external_obj.mli ./core/lam_compile_main.ml ./core/lam_compile_main.mli ./core/lam_compile_primitive.ml ./core/lam_compile_primitive.mli ./core/lam_compile_util.ml ./core/lam_compile_util.mli ./core/lam_constant.ml ./core/lam_constant.mli ./core/lam_constant_convert.ml ./core/lam_constant_convert.mli ./core/lam_convert.ml ./core/lam_convert.mli ./core/lam_dce.ml ./core/lam_dce.mli ./core/lam_dispatch_primitive.ml ./core/lam_dispatch_primitive.mli ./core/lam_eta_conversion.ml ./core/lam_eta_conversion.mli ./core/lam_exit_code.ml ./core/lam_exit_code.mli ./core/lam_exit_count.ml ./core/lam_exit_count.mli ./core/lam_free_variables.ml ./core/lam_free_variables.mli ./core/lam_group.ml ./core/lam_group.mli ./core/lam_hit.ml ./core/lam_hit.mli ./core/lam_id_kind.ml ./core/lam_id_kind.mli ./core/lam_inline_util.ml ./core/lam_inline_util.mli ./core/lam_iter.ml ./core/lam_iter.mli ./core/lam_module_ident.ml ./core/lam_module_ident.mli ./core/lam_pass_alpha_conversion.ml ./core/lam_pass_alpha_conversion.mli ./core/lam_pass_collect.ml ./core/lam_pass_collect.mli ./core/lam_pass_count.ml ./core/lam_pass_count.mli ./core/lam_pass_deep_flatten.ml ./core/lam_pass_deep_flatten.mli ./core/lam_pass_eliminate_ref.ml ./core/lam_pass_eliminate_ref.mli ./core/lam_pass_exits.ml ./core/lam_pass_exits.mli ./core/lam_pass_lets_dce.ml ./core/lam_pass_lets_dce.mli ./core/lam_pass_remove_alias.ml ./core/lam_pass_remove_alias.mli ./core/lam_pointer_info.ml ./core/lam_pointer_info.mli ./core/lam_primitive.ml ./core/lam_primitive.mli ./core/lam_print.ml ./core/lam_print.mli ./core/lam_scc.ml ./core/lam_scc.mli ./core/lam_stats.ml ./core/lam_stats.mli ./core/lam_stats_export.ml ./core/lam_stats_export.mli ./core/lam_subst.ml ./core/lam_subst.mli ./core/lam_tag_info.ml ./core/lam_util.ml ./core/lam_util.mli ./core/lam_var_stats.ml ./core/lam_var_stats.mli ./core/ocaml_options.ml ./core/ocaml_options.mli ./core/primitive_compat.ml ./core/primitive_compat.mli ./depends/ast_extract.ml ./depends/ast_extract.mli ./depends/binary_ast.ml ./depends/binary_ast.mli ./depends/bs_exception.ml ./depends/bs_exception.mli ./ext/ext_arg.ml ./ext/ext_arg.mli ./ext/ext_array.ml ./ext/ext_array.mli ./ext/ext_buffer.ml ./ext/ext_buffer.mli ./ext/ext_bytes.ml ./ext/ext_bytes.mli ./ext/ext_char.ml ./ext/ext_char.mli ./ext/ext_digest.ml ./ext/ext_digest.mli ./ext/ext_filename.ml ./ext/ext_filename.mli ./ext/ext_fmt.ml ./ext/ext_format.ml ./ext/ext_format.mli ./ext/ext_ident.ml ./ext/ext_ident.mli ./ext/ext_int.ml ./ext/ext_int.mli ./ext/ext_io.ml ./ext/ext_io.mli ./ext/ext_js_regex.ml ./ext/ext_js_regex.mli ./ext/ext_json_parse.ml ./ext/ext_json_parse.mli ./ext/ext_json_types.ml ./ext/ext_list.ml ./ext/ext_list.mli ./ext/ext_modulename.ml ./ext/ext_modulename.mli ./ext/ext_namespace.ml ./ext/ext_namespace.mli ./ext/ext_option.ml ./ext/ext_option.mli ./ext/ext_path.ml ./ext/ext_path.mli ./ext/ext_pervasives.ml ./ext/ext_pervasives.mli ./ext/ext_position.ml ./ext/ext_position.mli ./ext/ext_pp.ml ./ext/ext_pp.mli ./ext/ext_pp_scope.ml ./ext/ext_pp_scope.mli ./ext/ext_ref.ml ./ext/ext_ref.mli ./ext/ext_scc.ml ./ext/ext_scc.mli ./ext/ext_string.ml ./ext/ext_string.mli ./ext/ext_sys.ml ./ext/ext_sys.mli ./ext/ext_utf8.ml ./ext/ext_utf8.mli ./ext/ext_util.ml ./ext/ext_util.mli ./ext/hash_set.ml ./ext/hash_set.mli ./ext/hash_set_gen.ml ./ext/hash_set_ident_mask.ml ./ext/hash_set_ident_mask.mli ./ext/hash_set_poly.ml ./ext/hash_set_poly.mli ./ext/hashtbl_gen.ml ./ext/hashtbl_make.ml ./ext/hashtbl_make.mli ./ext/ident_hash_set.ml ./ext/ident_hash_set.mli ./ext/ident_hashtbl.ml ./ext/ident_hashtbl.mli ./ext/ident_map.ml ./ext/ident_map.mli ./ext/ident_set.ml ./ext/ident_set.mli ./ext/int_hashtbl.ml ./ext/int_hashtbl.mli ./ext/int_map.ml ./ext/int_map.mli ./ext/int_vec.ml ./ext/int_vec.mli ./ext/int_vec_util.ml ./ext/int_vec_util.mli ./ext/int_vec_vec.ml ./ext/int_vec_vec.mli ./ext/js_reserved_map.ml ./ext/js_reserved_map.mli ./ext/js_runtime_modules.ml ./ext/literals.ml ./ext/literals.mli ./ext/map_gen.ml ./ext/ordered_hash_map_gen.ml ./ext/ordered_hash_map_local_ident.ml ./ext/ordered_hash_map_local_ident.mli ./ext/resize_array.ml ./ext/resize_array.mli ./ext/set_gen.ml ./ext/string_hash_set.ml ./ext/string_hash_set.mli ./ext/string_hashtbl.ml ./ext/string_hashtbl.mli ./ext/string_map.ml ./ext/string_map.mli ./ext/vec_gen.ml ./main/js_main.ml ./main/js_main.mli ./outcome_printer/outcome_printer_ns.ml ./outcome_printer/outcome_printer_ns.mli ./outcome_printer/reason_outcome_printer_main.ml ./outcome_printer/reason_syntax_util.ml ./outcome_printer/reason_syntax_util.mli ./outcome_printer/tweaked_reason_oprint.ml ./stubs/bs_hash_stubs.ml ./super_errors/super_env.ml ./super_errors/super_location.ml ./super_errors/super_main.ml ./super_errors/super_misc.ml ./super_errors/super_misc.mli ./super_errors/super_pparse.ml ./super_errors/super_reason_react.ml ./super_errors/super_reason_react.mli ./super_errors/super_typecore.ml ./super_errors/super_typemod.ml ./super_errors/super_typetexp.ml ./super_errors/super_warnings.ml ./syntax/ast_attributes.ml ./syntax/ast_attributes.mli ./syntax/ast_bs_open.ml ./syntax/ast_bs_open.mli ./syntax/ast_comb.ml ./syntax/ast_comb.mli ./syntax/ast_compatible.ml ./syntax/ast_compatible.mli ./syntax/ast_core_type.ml ./syntax/ast_core_type.mli ./syntax/ast_core_type_class_type.ml ./syntax/ast_core_type_class_type.mli ./syntax/ast_derive.ml ./syntax/ast_derive.mli ./syntax/ast_derive_abstract.ml ./syntax/ast_derive_abstract.mli ./syntax/ast_derive_js_mapper.ml ./syntax/ast_derive_js_mapper.mli ./syntax/ast_derive_projector.ml ./syntax/ast_derive_projector.mli ./syntax/ast_derive_util.ml ./syntax/ast_derive_util.mli ./syntax/ast_exp.ml ./syntax/ast_exp.mli ./syntax/ast_exp_apply.ml ./syntax/ast_exp_apply.mli ./syntax/ast_exp_extension.ml ./syntax/ast_exp_extension.mli ./syntax/ast_external.ml ./syntax/ast_external.mli ./syntax/ast_external_mk.ml ./syntax/ast_external_mk.mli ./syntax/ast_external_process.ml ./syntax/ast_external_process.mli ./syntax/ast_literal.ml ./syntax/ast_literal.mli ./syntax/ast_open_cxt.ml ./syntax/ast_open_cxt.mli ./syntax/ast_pat.ml ./syntax/ast_pat.mli ./syntax/ast_payload.ml ./syntax/ast_payload.mli ./syntax/ast_polyvar.ml ./syntax/ast_polyvar.mli ./syntax/ast_reason_pp.ml ./syntax/ast_reason_pp.mli ./syntax/ast_signature.ml ./syntax/ast_signature.mli ./syntax/ast_structure.ml ./syntax/ast_structure.mli ./syntax/ast_tdcls.ml ./syntax/ast_tdcls.mli ./syntax/ast_tuple_pattern_flatten.ml ./syntax/ast_tuple_pattern_flatten.mli ./syntax/ast_utf8_string.ml ./syntax/ast_utf8_string.mli ./syntax/ast_utf8_string_interp.ml ./syntax/ast_utf8_string_interp.mli ./syntax/ast_util.ml ./syntax/ast_util.mli ./syntax/bs_ast_invariant.ml ./syntax/bs_ast_invariant.mli ./syntax/bs_ast_mapper.ml ./syntax/bs_ast_mapper.mli ./syntax/bs_builtin_ppx.ml ./syntax/bs_builtin_ppx.mli ./syntax/bs_syntaxerr.ml ./syntax/bs_syntaxerr.mli ./syntax/external_arg_spec.ml ./syntax/external_arg_spec.mli ./syntax/external_ffi_types.ml ./syntax/external_ffi_types.mli ./syntax/ppx_entry.ml ./syntax/reactjs_jsx_ppx_v2.ml ./syntax/reactjs_jsx_ppx_v3.ml \ No newline at end of file +../lib/4.06.1/whole_compiler.ml: ../ocaml/bytecomp/lambda.ml ../ocaml/bytecomp/lambda.mli ../ocaml/bytecomp/matching.ml ../ocaml/bytecomp/matching.mli ../ocaml/bytecomp/printlambda.ml ../ocaml/bytecomp/printlambda.mli ../ocaml/bytecomp/switch.ml ../ocaml/bytecomp/switch.mli ../ocaml/bytecomp/translattribute.ml ../ocaml/bytecomp/translattribute.mli ../ocaml/bytecomp/translclass.ml ../ocaml/bytecomp/translclass.mli ../ocaml/bytecomp/translcore.ml ../ocaml/bytecomp/translcore.mli ../ocaml/bytecomp/translmod.ml ../ocaml/bytecomp/translmod.mli ../ocaml/bytecomp/translobj.ml ../ocaml/bytecomp/translobj.mli ../ocaml/driver/compenv.ml ../ocaml/driver/compenv.mli ../ocaml/driver/compmisc.ml ../ocaml/driver/compmisc.mli ../ocaml/driver/pparse.ml ../ocaml/driver/pparse.mli ../ocaml/parsing/ast_helper.ml ../ocaml/parsing/ast_helper.mli ../ocaml/parsing/ast_invariants.ml ../ocaml/parsing/ast_invariants.mli ../ocaml/parsing/ast_iterator.ml ../ocaml/parsing/ast_iterator.mli ../ocaml/parsing/ast_mapper.ml ../ocaml/parsing/ast_mapper.mli ../ocaml/parsing/asttypes.mli ../ocaml/parsing/attr_helper.ml ../ocaml/parsing/attr_helper.mli ../ocaml/parsing/builtin_attributes.ml ../ocaml/parsing/builtin_attributes.mli ../ocaml/parsing/depend.ml ../ocaml/parsing/depend.mli ../ocaml/parsing/docstrings.ml ../ocaml/parsing/docstrings.mli ../ocaml/parsing/lexer.ml ../ocaml/parsing/lexer.mli ../ocaml/parsing/location.ml ../ocaml/parsing/location.mli ../ocaml/parsing/longident.ml ../ocaml/parsing/longident.mli ../ocaml/parsing/parse.ml ../ocaml/parsing/parse.mli ../ocaml/parsing/parser.ml ../ocaml/parsing/parser.mli ../ocaml/parsing/parsetree.mli ../ocaml/parsing/pprintast.ml ../ocaml/parsing/pprintast.mli ../ocaml/parsing/printast.ml ../ocaml/parsing/printast.mli ../ocaml/parsing/syntaxerr.ml ../ocaml/parsing/syntaxerr.mli ../ocaml/typing/annot.mli ../ocaml/typing/btype.ml ../ocaml/typing/btype.mli ../ocaml/typing/cmi_format.ml ../ocaml/typing/cmi_format.mli ../ocaml/typing/cmt_format.ml ../ocaml/typing/cmt_format.mli ../ocaml/typing/ctype.ml ../ocaml/typing/ctype.mli ../ocaml/typing/datarepr.ml ../ocaml/typing/datarepr.mli ../ocaml/typing/env.ml ../ocaml/typing/env.mli ../ocaml/typing/ident.ml ../ocaml/typing/ident.mli ../ocaml/typing/includeclass.ml ../ocaml/typing/includeclass.mli ../ocaml/typing/includecore.ml ../ocaml/typing/includecore.mli ../ocaml/typing/includemod.ml ../ocaml/typing/includemod.mli ../ocaml/typing/mtype.ml ../ocaml/typing/mtype.mli ../ocaml/typing/oprint.ml ../ocaml/typing/oprint.mli ../ocaml/typing/outcometree.mli ../ocaml/typing/parmatch.ml ../ocaml/typing/parmatch.mli ../ocaml/typing/path.ml ../ocaml/typing/path.mli ../ocaml/typing/predef.ml ../ocaml/typing/predef.mli ../ocaml/typing/primitive.ml ../ocaml/typing/primitive.mli ../ocaml/typing/printtyp.ml ../ocaml/typing/printtyp.mli ../ocaml/typing/printtyped.ml ../ocaml/typing/printtyped.mli ../ocaml/typing/stypes.ml ../ocaml/typing/stypes.mli ../ocaml/typing/subst.ml ../ocaml/typing/subst.mli ../ocaml/typing/tast_mapper.ml ../ocaml/typing/tast_mapper.mli ../ocaml/typing/typeclass.ml ../ocaml/typing/typeclass.mli ../ocaml/typing/typecore.ml ../ocaml/typing/typecore.mli ../ocaml/typing/typedecl.ml ../ocaml/typing/typedecl.mli ../ocaml/typing/typedtree.ml ../ocaml/typing/typedtree.mli ../ocaml/typing/typedtreeIter.ml ../ocaml/typing/typedtreeIter.mli ../ocaml/typing/typemod.ml ../ocaml/typing/typemod.mli ../ocaml/typing/typeopt.ml ../ocaml/typing/typeopt.mli ../ocaml/typing/types.ml ../ocaml/typing/types.mli ../ocaml/typing/typetexp.ml ../ocaml/typing/typetexp.mli ../ocaml/typing/untypeast.ml ../ocaml/typing/untypeast.mli ../ocaml/utils/arg_helper.ml ../ocaml/utils/arg_helper.mli ../ocaml/utils/ccomp.ml ../ocaml/utils/ccomp.mli ../ocaml/utils/clflags.ml ../ocaml/utils/clflags.mli ../ocaml/utils/consistbl.ml ../ocaml/utils/consistbl.mli ../ocaml/utils/identifiable.ml ../ocaml/utils/identifiable.mli ../ocaml/utils/misc.ml ../ocaml/utils/misc.mli ../ocaml/utils/numbers.ml ../ocaml/utils/numbers.mli ../ocaml/utils/profile.ml ../ocaml/utils/profile.mli ../ocaml/utils/tbl.ml ../ocaml/utils/tbl.mli ../ocaml/utils/terminfo.ml ../ocaml/utils/terminfo.mli ../ocaml/utils/warnings.ml ../ocaml/utils/warnings.mli ./common/bs_loc.ml ./common/bs_loc.mli ./common/bs_version.ml ./common/bs_version.mli ./common/bs_warnings.ml ./common/bs_warnings.mli ./common/ext_log.ml ./common/ext_log.mli ./common/js_config.ml ./common/js_config.mli ./common/lam_methname.ml ./common/lam_methname.mli ./common/ml_binary.ml ./common/ml_binary.mli ./core/bs_conditional_initial.ml ./core/bs_conditional_initial.mli ./core/config_util.ml ./core/config_util.mli ./core/config_whole_compiler.ml ./core/config_whole_compiler.mli ./core/j.ml ./core/js_analyzer.ml ./core/js_analyzer.mli ./core/js_arr.ml ./core/js_arr.mli ./core/js_ast_util.ml ./core/js_ast_util.mli ./core/js_block_runtime.ml ./core/js_block_runtime.mli ./core/js_call_info.ml ./core/js_call_info.mli ./core/js_closure.ml ./core/js_closure.mli ./core/js_cmj_format.ml ./core/js_cmj_format.mli ./core/js_cmj_load.ml ./core/js_cmj_load.mli ./core/js_dump.ml ./core/js_dump.mli ./core/js_dump_import_export.ml ./core/js_dump_import_export.mli ./core/js_dump_lit.ml ./core/js_dump_program.ml ./core/js_dump_program.mli ./core/js_dump_property.ml ./core/js_dump_property.mli ./core/js_dump_string.ml ./core/js_dump_string.mli ./core/js_exp_make.ml ./core/js_exp_make.mli ./core/js_fold.ml ./core/js_fold_basic.ml ./core/js_fold_basic.mli ./core/js_fun_env.ml ./core/js_fun_env.mli ./core/js_implementation.ml ./core/js_implementation.mli ./core/js_long.ml ./core/js_long.mli ./core/js_map.ml ./core/js_name_of_module_id.ml ./core/js_name_of_module_id.mli ./core/js_number.ml ./core/js_number.mli ./core/js_of_lam_array.ml ./core/js_of_lam_array.mli ./core/js_of_lam_block.ml ./core/js_of_lam_block.mli ./core/js_of_lam_exception.ml ./core/js_of_lam_exception.mli ./core/js_of_lam_option.ml ./core/js_of_lam_option.mli ./core/js_of_lam_polyvar.ml ./core/js_of_lam_polyvar.mli ./core/js_of_lam_string.ml ./core/js_of_lam_string.mli ./core/js_of_lam_tuple.ml ./core/js_of_lam_tuple.mli ./core/js_of_lam_variant.ml ./core/js_of_lam_variant.mli ./core/js_op.ml ./core/js_op_util.ml ./core/js_op_util.mli ./core/js_output.ml ./core/js_output.mli ./core/js_packages_info.ml ./core/js_packages_info.mli ./core/js_packages_state.ml ./core/js_packages_state.mli ./core/js_pass_debug.ml ./core/js_pass_debug.mli ./core/js_pass_flatten.ml ./core/js_pass_flatten.mli ./core/js_pass_flatten_and_mark_dead.ml ./core/js_pass_flatten_and_mark_dead.mli ./core/js_pass_scope.ml ./core/js_pass_scope.mli ./core/js_pass_tailcall_inline.ml ./core/js_pass_tailcall_inline.mli ./core/js_shake.ml ./core/js_shake.mli ./core/js_stmt_make.ml ./core/js_stmt_make.mli ./core/lam.ml ./core/lam.mli ./core/lam_analysis.ml ./core/lam_analysis.mli ./core/lam_arity.ml ./core/lam_arity.mli ./core/lam_arity_analysis.ml ./core/lam_arity_analysis.mli ./core/lam_beta_reduce.ml ./core/lam_beta_reduce.mli ./core/lam_beta_reduce_util.ml ./core/lam_beta_reduce_util.mli ./core/lam_bounded_vars.ml ./core/lam_bounded_vars.mli ./core/lam_closure.ml ./core/lam_closure.mli ./core/lam_coercion.ml ./core/lam_coercion.mli ./core/lam_compat.ml ./core/lam_compat.mli ./core/lam_compile.ml ./core/lam_compile.mli ./core/lam_compile_const.ml ./core/lam_compile_const.mli ./core/lam_compile_context.ml ./core/lam_compile_context.mli ./core/lam_compile_env.ml ./core/lam_compile_env.mli ./core/lam_compile_external_call.ml ./core/lam_compile_external_call.mli ./core/lam_compile_external_obj.ml ./core/lam_compile_external_obj.mli ./core/lam_compile_main.ml ./core/lam_compile_main.mli ./core/lam_compile_primitive.ml ./core/lam_compile_primitive.mli ./core/lam_compile_util.ml ./core/lam_compile_util.mli ./core/lam_constant.ml ./core/lam_constant.mli ./core/lam_constant_convert.ml ./core/lam_constant_convert.mli ./core/lam_convert.ml ./core/lam_convert.mli ./core/lam_dce.ml ./core/lam_dce.mli ./core/lam_dispatch_primitive.ml ./core/lam_dispatch_primitive.mli ./core/lam_eta_conversion.ml ./core/lam_eta_conversion.mli ./core/lam_exit_code.ml ./core/lam_exit_code.mli ./core/lam_exit_count.ml ./core/lam_exit_count.mli ./core/lam_free_variables.ml ./core/lam_free_variables.mli ./core/lam_group.ml ./core/lam_group.mli ./core/lam_hit.ml ./core/lam_hit.mli ./core/lam_id_kind.ml ./core/lam_id_kind.mli ./core/lam_inline_util.ml ./core/lam_inline_util.mli ./core/lam_iter.ml ./core/lam_iter.mli ./core/lam_module_ident.ml ./core/lam_module_ident.mli ./core/lam_pass_alpha_conversion.ml ./core/lam_pass_alpha_conversion.mli ./core/lam_pass_collect.ml ./core/lam_pass_collect.mli ./core/lam_pass_count.ml ./core/lam_pass_count.mli ./core/lam_pass_deep_flatten.ml ./core/lam_pass_deep_flatten.mli ./core/lam_pass_eliminate_ref.ml ./core/lam_pass_eliminate_ref.mli ./core/lam_pass_exits.ml ./core/lam_pass_exits.mli ./core/lam_pass_lets_dce.ml ./core/lam_pass_lets_dce.mli ./core/lam_pass_remove_alias.ml ./core/lam_pass_remove_alias.mli ./core/lam_pointer_info.ml ./core/lam_pointer_info.mli ./core/lam_primitive.ml ./core/lam_primitive.mli ./core/lam_print.ml ./core/lam_print.mli ./core/lam_scc.ml ./core/lam_scc.mli ./core/lam_stats.ml ./core/lam_stats.mli ./core/lam_stats_export.ml ./core/lam_stats_export.mli ./core/lam_subst.ml ./core/lam_subst.mli ./core/lam_tag_info.ml ./core/lam_util.ml ./core/lam_util.mli ./core/lam_var_stats.ml ./core/lam_var_stats.mli ./core/ocaml_options.ml ./core/ocaml_options.mli ./core/primitive_compat.ml ./core/primitive_compat.mli ./core/record_attributes_check.ml ./depends/ast_extract.ml ./depends/ast_extract.mli ./depends/binary_ast.ml ./depends/binary_ast.mli ./depends/bs_exception.ml ./depends/bs_exception.mli ./ext/ext_arg.ml ./ext/ext_arg.mli ./ext/ext_array.ml ./ext/ext_array.mli ./ext/ext_buffer.ml ./ext/ext_buffer.mli ./ext/ext_bytes.ml ./ext/ext_bytes.mli ./ext/ext_char.ml ./ext/ext_char.mli ./ext/ext_digest.ml ./ext/ext_digest.mli ./ext/ext_filename.ml ./ext/ext_filename.mli ./ext/ext_fmt.ml ./ext/ext_format.ml ./ext/ext_format.mli ./ext/ext_ident.ml ./ext/ext_ident.mli ./ext/ext_int.ml ./ext/ext_int.mli ./ext/ext_io.ml ./ext/ext_io.mli ./ext/ext_js_regex.ml ./ext/ext_js_regex.mli ./ext/ext_json_parse.ml ./ext/ext_json_parse.mli ./ext/ext_json_types.ml ./ext/ext_list.ml ./ext/ext_list.mli ./ext/ext_modulename.ml ./ext/ext_modulename.mli ./ext/ext_namespace.ml ./ext/ext_namespace.mli ./ext/ext_option.ml ./ext/ext_option.mli ./ext/ext_path.ml ./ext/ext_path.mli ./ext/ext_pervasives.ml ./ext/ext_pervasives.mli ./ext/ext_position.ml ./ext/ext_position.mli ./ext/ext_pp.ml ./ext/ext_pp.mli ./ext/ext_pp_scope.ml ./ext/ext_pp_scope.mli ./ext/ext_ref.ml ./ext/ext_ref.mli ./ext/ext_scc.ml ./ext/ext_scc.mli ./ext/ext_string.ml ./ext/ext_string.mli ./ext/ext_sys.ml ./ext/ext_sys.mli ./ext/ext_utf8.ml ./ext/ext_utf8.mli ./ext/ext_util.ml ./ext/ext_util.mli ./ext/hash_set.ml ./ext/hash_set.mli ./ext/hash_set_gen.ml ./ext/hash_set_ident_mask.ml ./ext/hash_set_ident_mask.mli ./ext/hash_set_poly.ml ./ext/hash_set_poly.mli ./ext/hashtbl_gen.ml ./ext/hashtbl_make.ml ./ext/hashtbl_make.mli ./ext/ident_hash_set.ml ./ext/ident_hash_set.mli ./ext/ident_hashtbl.ml ./ext/ident_hashtbl.mli ./ext/ident_map.ml ./ext/ident_map.mli ./ext/ident_set.ml ./ext/ident_set.mli ./ext/int_hashtbl.ml ./ext/int_hashtbl.mli ./ext/int_map.ml ./ext/int_map.mli ./ext/int_vec.ml ./ext/int_vec.mli ./ext/int_vec_util.ml ./ext/int_vec_util.mli ./ext/int_vec_vec.ml ./ext/int_vec_vec.mli ./ext/js_reserved_map.ml ./ext/js_reserved_map.mli ./ext/js_runtime_modules.ml ./ext/literals.ml ./ext/literals.mli ./ext/map_gen.ml ./ext/ordered_hash_map_gen.ml ./ext/ordered_hash_map_local_ident.ml ./ext/ordered_hash_map_local_ident.mli ./ext/resize_array.ml ./ext/resize_array.mli ./ext/set_gen.ml ./ext/string_hash_set.ml ./ext/string_hash_set.mli ./ext/string_hashtbl.ml ./ext/string_hashtbl.mli ./ext/string_map.ml ./ext/string_map.mli ./ext/vec_gen.ml ./main/js_main.ml ./main/js_main.mli ./outcome_printer/outcome_printer_ns.ml ./outcome_printer/outcome_printer_ns.mli ./outcome_printer/reason_outcome_printer_main.ml ./outcome_printer/reason_syntax_util.ml ./outcome_printer/reason_syntax_util.mli ./outcome_printer/tweaked_reason_oprint.ml ./stubs/bs_hash_stubs.ml ./super_errors/super_env.ml ./super_errors/super_location.ml ./super_errors/super_main.ml ./super_errors/super_misc.ml ./super_errors/super_misc.mli ./super_errors/super_pparse.ml ./super_errors/super_reason_react.ml ./super_errors/super_reason_react.mli ./super_errors/super_typecore.ml ./super_errors/super_typemod.ml ./super_errors/super_typetexp.ml ./super_errors/super_warnings.ml ./syntax/ast_attributes.ml ./syntax/ast_attributes.mli ./syntax/ast_bs_open.ml ./syntax/ast_bs_open.mli ./syntax/ast_comb.ml ./syntax/ast_comb.mli ./syntax/ast_compatible.ml ./syntax/ast_compatible.mli ./syntax/ast_core_type.ml ./syntax/ast_core_type.mli ./syntax/ast_core_type_class_type.ml ./syntax/ast_core_type_class_type.mli ./syntax/ast_derive.ml ./syntax/ast_derive.mli ./syntax/ast_derive_abstract.ml ./syntax/ast_derive_abstract.mli ./syntax/ast_derive_js_mapper.ml ./syntax/ast_derive_js_mapper.mli ./syntax/ast_derive_projector.ml ./syntax/ast_derive_projector.mli ./syntax/ast_derive_util.ml ./syntax/ast_derive_util.mli ./syntax/ast_exp.ml ./syntax/ast_exp.mli ./syntax/ast_exp_apply.ml ./syntax/ast_exp_apply.mli ./syntax/ast_exp_extension.ml ./syntax/ast_exp_extension.mli ./syntax/ast_external.ml ./syntax/ast_external.mli ./syntax/ast_external_mk.ml ./syntax/ast_external_mk.mli ./syntax/ast_external_process.ml ./syntax/ast_external_process.mli ./syntax/ast_literal.ml ./syntax/ast_literal.mli ./syntax/ast_open_cxt.ml ./syntax/ast_open_cxt.mli ./syntax/ast_pat.ml ./syntax/ast_pat.mli ./syntax/ast_payload.ml ./syntax/ast_payload.mli ./syntax/ast_polyvar.ml ./syntax/ast_polyvar.mli ./syntax/ast_reason_pp.ml ./syntax/ast_reason_pp.mli ./syntax/ast_signature.ml ./syntax/ast_signature.mli ./syntax/ast_structure.ml ./syntax/ast_structure.mli ./syntax/ast_tdcls.ml ./syntax/ast_tdcls.mli ./syntax/ast_tuple_pattern_flatten.ml ./syntax/ast_tuple_pattern_flatten.mli ./syntax/ast_utf8_string.ml ./syntax/ast_utf8_string.mli ./syntax/ast_utf8_string_interp.ml ./syntax/ast_utf8_string_interp.mli ./syntax/ast_util.ml ./syntax/ast_util.mli ./syntax/bs_ast_invariant.ml ./syntax/bs_ast_invariant.mli ./syntax/bs_ast_mapper.ml ./syntax/bs_ast_mapper.mli ./syntax/bs_builtin_ppx.ml ./syntax/bs_builtin_ppx.mli ./syntax/bs_syntaxerr.ml ./syntax/bs_syntaxerr.mli ./syntax/external_arg_spec.ml ./syntax/external_arg_spec.mli ./syntax/external_ffi_types.ml ./syntax/external_ffi_types.mli ./syntax/ppx_entry.ml ./syntax/reactjs_jsx_ppx_v2.ml ./syntax/reactjs_jsx_ppx_v3.ml \ No newline at end of file diff --git a/ocaml b/ocaml index fabbb4fd00..a6a8c754b8 160000 --- a/ocaml +++ b/ocaml @@ -1 +1 @@ -Subproject commit fabbb4fd002600c8eedd2597879b749b9d01fe95 +Subproject commit a6a8c754b8810f48546393e7c7df57851a0559c5 diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000000..45d8c47113 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,282 @@ +{ + "name": "bs-platform", + "version": "6.3.0-dev.1", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "browser-stdout": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.0.tgz", + "integrity": "sha1-81HTKWnTL6XXpVZxVCY9korjvR8=", + "dev": true + }, + "commander": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz", + "integrity": "sha1-nJkJQXbhIkDLItbFFGCYQA/g99Q=", + "dev": true, + "requires": { + "graceful-readlink": ">= 1.0.0" + } + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "debug": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz", + "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "diff": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.2.0.tgz", + "integrity": "sha1-yc45Okt8vQsFinJck98pkCeGj/k=", + "dev": true + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "graceful-readlink": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz", + "integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=", + "dev": true + }, + "growl": { + "version": "1.9.2", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.9.2.tgz", + "integrity": "sha1-Dqd0NxXbjY3ixe3hd14bRayFwC8=", + "dev": true + }, + "has-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz", + "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=", + "dev": true + }, + "he": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", + "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", + "dev": true + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "json3": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/json3/-/json3-3.3.2.tgz", + "integrity": "sha1-PAQ0dD35Pi9cQq7nsZvLSDV19OE=", + "dev": true + }, + "lodash._baseassign": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz", + "integrity": "sha1-jDigmVAPIVrQnlnxci/QxSv+Ck4=", + "dev": true, + "requires": { + "lodash._basecopy": "^3.0.0", + "lodash.keys": "^3.0.0" + } + }, + "lodash._basecopy": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz", + "integrity": "sha1-jaDmqHbPNEwK2KVIghEd08XHyjY=", + "dev": true + }, + "lodash._basecreate": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash._basecreate/-/lodash._basecreate-3.0.3.tgz", + "integrity": "sha1-G8ZhYU2qf8MRt9A78WgGoCE8+CE=", + "dev": true + }, + "lodash._getnative": { + "version": "3.9.1", + "resolved": "https://registry.npmjs.org/lodash._getnative/-/lodash._getnative-3.9.1.tgz", + "integrity": "sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U=", + "dev": true + }, + "lodash._isiterateecall": { + "version": "3.0.9", + "resolved": "https://registry.npmjs.org/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz", + "integrity": "sha1-UgOte6Ql+uhCRg5pbbnPPmqsBXw=", + "dev": true + }, + "lodash.create": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/lodash.create/-/lodash.create-3.1.1.tgz", + "integrity": "sha1-1/KEnw29p+BGgruM1yqwIkYd6+c=", + "dev": true, + "requires": { + "lodash._baseassign": "^3.0.0", + "lodash._basecreate": "^3.0.0", + "lodash._isiterateecall": "^3.0.0" + } + }, + "lodash.isarguments": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz", + "integrity": "sha1-L1c9hcaiQon/AGY7SRwdM4/zRYo=", + "dev": true + }, + "lodash.isarray": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/lodash.isarray/-/lodash.isarray-3.0.4.tgz", + "integrity": "sha1-eeTriMNqgSKvhvhEqpvNhRtfu1U=", + "dev": true + }, + "lodash.keys": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz", + "integrity": "sha1-TbwEcrFWvlCgsoaFXRvQsMZWCYo=", + "dev": true, + "requires": { + "lodash._getnative": "^3.0.0", + "lodash.isarguments": "^3.0.0", + "lodash.isarray": "^3.0.0" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "dev": true, + "requires": { + "minimist": "0.0.8" + } + }, + "mocha": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-3.5.3.tgz", + "integrity": "sha512-/6na001MJWEtYxHOV1WLfsmR4YIynkUEhBwzsb+fk2qmQ3iqsi258l/Q2MWHJMImAcNpZ8DEdYAK72NHoIQ9Eg==", + "dev": true, + "requires": { + "browser-stdout": "1.3.0", + "commander": "2.9.0", + "debug": "2.6.8", + "diff": "3.2.0", + "escape-string-regexp": "1.0.5", + "glob": "7.1.1", + "growl": "1.9.2", + "he": "1.1.1", + "json3": "3.3.2", + "lodash.create": "3.1.1", + "mkdirp": "0.5.1", + "supports-color": "3.1.2" + }, + "dependencies": { + "glob": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.1.tgz", + "integrity": "sha1-gFIR3wT6rxxjo2ADBs31reULLsg=", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.2", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + } + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "supports-color": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.1.2.tgz", + "integrity": "sha1-cqJiiU2dQIuVbKBf83su2KbiotU=", + "dev": true, + "requires": { + "has-flag": "^1.0.0" + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + } + } +} diff --git a/package.json b/package.json index e116672526..43ef6657c6 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "jasmine-core": "^2.6.2", "karma": "^1.7.0", "karma-jasmine-html-reporter": "^0.2.2", - "mocha": "^3.4.1", + "mocha": "^3.5.3", "mocha-lcov-reporter": "^1.3.0", "should": "^11.2.1", "should-equal": "^1.0.1", @@ -20,7 +20,7 @@ "bsb": "lib/bsb", "bsc": "lib/bsc", "bsrefmt": "lib/bsrefmt", - "bstracing" : "lib/bstracing" + "bstracing": "lib/bstracing" }, "scripts": { "test": "node scripts/ciTest.js -all", @@ -33,7 +33,7 @@ "postinstall": "node scripts/install.js" }, "name": "bs-platform", - "version": "6.3.0-dev.1", + "version": "7.0.0-dev.2", "description": "bucklescript compiler, ocaml standard libary by bucklescript and its required runtime support", "repository": { "type": "git",